Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@netcracker/qubership-apihub-api-diff",
"version": "1.0.5-dev.1",
"version": "1.0.5-feature-rename-label-semi-breaking-changes-two.0",
"module": "./dist/index.es.js",
"main": "./dist/index.cjs.js",
"types": "./dist/index.d.ts",
Expand Down
4 changes: 2 additions & 2 deletions src/core/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ export const DiffAction = {
export const ClassifierType = {
breaking: 'breaking',
nonBreaking: 'non-breaking',
semiBreaking: 'semi-breaking',
risky: 'risky',
annotation: 'annotation',
unclassified: 'unclassified',
deprecated: 'deprecated',
} as const
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so we finally decided to get rid of "semi-breaking" term or is this another layer?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In scope of this issue- we get rename semi-breaking to risky in all the code FE team is responsible to.
So, the only place when semi-breaking term could be used is in a mapping DTOs received from BE (where semi-breaking is not renamed) and FE entities.


export const { breaking, nonBreaking, semiBreaking, unclassified, annotation, deprecated } = ClassifierType
export const { breaking, nonBreaking, risky, unclassified, annotation, deprecated } = ClassifierType

// predefined classifiers
export const allNonBreaking: ClassifyRule = [nonBreaking, nonBreaking, nonBreaking]
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export { COMPARE_MODE_DEFAULT, COMPARE_MODE_OPERATION } from './types'

export {
ClassifierType, DiffAction, DIFF_META_KEY, breaking, nonBreaking, unclassified, annotation, deprecated, semiBreaking,
ClassifierType, DiffAction, DIFF_META_KEY, breaking, nonBreaking, unclassified, annotation, deprecated, risky,
} from './core'

export { apiDiff } from './api'
Expand Down
6 changes: 3 additions & 3 deletions src/jsonSchema/jsonSchema.classify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
breakingIfAfterTrue,
nonBreaking,
PARENT_JUMP,
semiBreaking,
risky,
strictResolveValueFromContext,
unclassified,
} from '../core'
Expand Down Expand Up @@ -101,8 +101,8 @@ export const enumClassifyRule: ClassifyRule = [
({ before }) => (isNotEmptyArray(before.parent) ? nonBreaking : breaking),
({ after }) => (isNotEmptyArray(after.parent) ? breaking : nonBreaking),
breaking,
({ before }) => (isNotEmptyArray(before.parent) ? semiBreaking : nonBreaking),
({ after }) => (isNotEmptyArray(after.parent) ? nonBreaking: semiBreaking ),
({ before }) => (isNotEmptyArray(before.parent) ? risky : nonBreaking),
({ after }) => (isNotEmptyArray(after.parent) ? nonBreaking: risky ),
nonBreaking
]

Expand Down
6 changes: 3 additions & 3 deletions src/jsonSchema/jsonSchema.rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ import {
booleanClassifier,
breaking,
breakingIf,
deepEqualsUniqueItemsArrayMappingResolver,
diffDescription,
nonBreaking,
onlyAddBreaking,
reverseClassifyRuleTransformer,
risky,
TEMPLATE_PARAM_ACTION,
TEMPLATE_PARAM_PLACE,
TEMPLATE_PARAM_PREPOSITION,
Expand All @@ -19,8 +21,6 @@ import {
TEMPLATE_PARAM_SCOPE,
transformCompareRules,
unclassified,
deepEqualsUniqueItemsArrayMappingResolver,
semiBreaking,
} from '../core'
import {
enumClassifyRule,
Expand Down Expand Up @@ -123,7 +123,7 @@ export const jsonSchemaRules = ({
'/default': simpleRule([nonBreaking, breaking, breaking], resolveSchemaDescriptionTemplates('default value')),

'/enum': {
$: [breaking, nonBreaking, breaking, nonBreaking, semiBreaking, nonBreaking],
$: [breaking, nonBreaking, breaking, nonBreaking, risky, nonBreaking],
mapping: deepEqualsUniqueItemsArrayMappingResolver,
'/*': ({ key, value }) => {
if (!isNumber(key)) {
Expand Down
14 changes: 7 additions & 7 deletions src/types/compare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ export const COMPARE_SCOPE_ROOT: CompareScope = 'root'
/**
* Diff should be unique by [type, beforeDeclarationPaths, afterDeclarationPaths, scope]
*/
interface DiffBase {
type: DiffType
interface DiffBase<T> {
type: T
scope: CompareScope
description?: string
}

export interface DiffAdd extends DiffBase {
export interface DiffAdd<T = DiffType> extends DiffBase<T> {
action: typeof DiffAction.add
/**
* declaration path in after document. Empty array can be if value doesn't exist in 'after' spec or value have synthetic origin
Expand All @@ -29,7 +29,7 @@ export interface DiffAdd extends DiffBase {
afterNormalizedValue: unknown
}

export interface DiffRemove extends DiffBase {
export interface DiffRemove<T = DiffType> extends DiffBase<T> {
action: typeof DiffAction.remove
/**
* declaration path in before document. Empty array can be if value doesn't exist in 'before' spec or value have synthetic origin
Expand All @@ -39,7 +39,7 @@ export interface DiffRemove extends DiffBase {
beforeNormalizedValue: unknown
}

export interface DiffReplace extends DiffBase {
export interface DiffReplace<T = DiffType> extends DiffBase<T> {
action: typeof DiffAction.replace
/**
* declaration path in before document. Empty array can be if value doesn't exist in 'before' spec or value have synthetic origin
Expand All @@ -55,7 +55,7 @@ export interface DiffReplace extends DiffBase {
beforeNormalizedValue: unknown
}

export interface DiffRename extends DiffBase {
export interface DiffRename<T = DiffType> extends DiffBase<T> {
action: typeof DiffAction.rename
/**
* declaration path in before document. Empty array can be if value doesn't exist in 'before' spec or value have synthetic origin
Expand All @@ -69,7 +69,7 @@ export interface DiffRename extends DiffBase {
beforeKey: unknown
}

export type Diff = DiffAdd | DiffRemove | DiffReplace | DiffRename
export type Diff<T = DiffType> = DiffAdd<T> | DiffRemove<T> | DiffReplace<T> | DiffRename<T>

export interface CompareResult {
diffs: Diff[]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { compareFiles, compareFilesWithMerge, TEST_DEFAULTS_DECLARATION_PATHS } from '../utils'
import { diffsMatcher } from '../../helper/matchers'
import { annotation, breaking, DiffAction, nonBreaking, semiBreaking } from '../../../src'
import { annotation, breaking, DiffAction, nonBreaking, risky } from '../../../src'
import { JSON_SCHEMA_NODE_SYNTHETIC_TYPE_ANY } from '@netcracker/qubership-apihub-api-unifier'

const SUITE_ID = 'response-body-schema'
Expand Down Expand Up @@ -160,7 +160,7 @@ describe('Openapi3 ResponseBody.Schema ', () => {
expect.objectContaining({
action: DiffAction.remove,
beforeDeclarationPaths: [[...RESPONSE_SCHEMA_PATH, 'enum']],
type: semiBreaking,
type: risky,
}),
]))
})
Expand All @@ -172,7 +172,7 @@ describe('Openapi3 ResponseBody.Schema ', () => {
expect.objectContaining({
action: DiffAction.add,
afterDeclarationPaths: [[...RESPONSE_SCHEMA_PATH, 'enum', 2]],
type: semiBreaking,
type: risky,
}),
]))
})
Expand All @@ -189,7 +189,7 @@ describe('Openapi3 ResponseBody.Schema ', () => {
expect.objectContaining({
action: DiffAction.add,
afterDeclarationPaths: [[...RESPONSE_SCHEMA_PATH, 'enum', 1]],
type: semiBreaking,
type: risky,
}),
],
))
Expand Down