diff --git a/package-lock.json b/package-lock.json index a59a930..119dbd9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@netcracker/qubership-apihub-api-diff", - "version": "1.1.0-next.0", + "version": "1.1.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@netcracker/qubership-apihub-api-diff", - "version": "1.1.0-next.0", + "version": "1.1.1", "dependencies": { "@netcracker/qubership-apihub-api-unifier": "1.0.4", "@netcracker/qubership-apihub-json-crawl": "1.0.4", diff --git a/package.json b/package.json index 5016ce1..9bed3ac 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@netcracker/qubership-apihub-api-diff", - "version": "1.1.1-dev.0", + "version": "1.1.1", "module": "./dist/index.es.js", "main": "./dist/index.cjs.js", "types": "./dist/index.d.ts", diff --git a/src/core/constants.ts b/src/core/constants.ts index 7ce3d36..398e827 100644 --- a/src/core/constants.ts +++ b/src/core/constants.ts @@ -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 -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] diff --git a/src/index.ts b/src/index.ts index 6932c9e..2004574 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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' diff --git a/src/jsonSchema/jsonSchema.classify.ts b/src/jsonSchema/jsonSchema.classify.ts index c69af2b..c759ced 100644 --- a/src/jsonSchema/jsonSchema.classify.ts +++ b/src/jsonSchema/jsonSchema.classify.ts @@ -4,7 +4,7 @@ import { breakingIfAfterTrue, nonBreaking, PARENT_JUMP, - semiBreaking, + risky, strictResolveValueFromContext, unclassified, } from '../core' @@ -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 ] diff --git a/src/jsonSchema/jsonSchema.rules.ts b/src/jsonSchema/jsonSchema.rules.ts index 876b1bd..9232ff9 100644 --- a/src/jsonSchema/jsonSchema.rules.ts +++ b/src/jsonSchema/jsonSchema.rules.ts @@ -7,10 +7,12 @@ import { booleanClassifier, breaking, breakingIf, + deepEqualsUniqueItemsArrayMappingResolver, diffDescription, nonBreaking, onlyAddBreaking, reverseClassifyRuleTransformer, + risky, TEMPLATE_PARAM_ACTION, TEMPLATE_PARAM_PLACE, TEMPLATE_PARAM_PREPOSITION, @@ -19,8 +21,6 @@ import { TEMPLATE_PARAM_SCOPE, transformCompareRules, unclassified, - deepEqualsUniqueItemsArrayMappingResolver, - semiBreaking, } from '../core' import { enumClassifyRule, @@ -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)) { diff --git a/src/types/compare.ts b/src/types/compare.ts index df8974b..5cad881 100644 --- a/src/types/compare.ts +++ b/src/types/compare.ts @@ -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 { + type: T scope: CompareScope description?: string } -export interface DiffAdd extends DiffBase { +export interface DiffAdd extends DiffBase { 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 @@ -29,7 +29,7 @@ export interface DiffAdd extends DiffBase { afterNormalizedValue: unknown } -export interface DiffRemove extends DiffBase { +export interface DiffRemove extends DiffBase { 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 @@ -39,7 +39,7 @@ export interface DiffRemove extends DiffBase { beforeNormalizedValue: unknown } -export interface DiffReplace extends DiffBase { +export interface DiffReplace extends DiffBase { 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 @@ -55,7 +55,7 @@ export interface DiffReplace extends DiffBase { beforeNormalizedValue: unknown } -export interface DiffRename extends DiffBase { +export interface DiffRename extends DiffBase { 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 @@ -69,7 +69,7 @@ export interface DiffRename extends DiffBase { beforeKey: unknown } -export type Diff = DiffAdd | DiffRemove | DiffReplace | DiffRename +export type Diff = DiffAdd | DiffRemove | DiffReplace | DiffRename export interface CompareResult { diffs: Diff[] diff --git a/test/compatibility-suites/openapi/response-body-schema.test.ts b/test/compatibility-suites/openapi/response-body-schema.test.ts index 6c9b2bc..4794ae9 100644 --- a/test/compatibility-suites/openapi/response-body-schema.test.ts +++ b/test/compatibility-suites/openapi/response-body-schema.test.ts @@ -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' @@ -160,7 +160,7 @@ describe('Openapi3 ResponseBody.Schema ', () => { expect.objectContaining({ action: DiffAction.remove, beforeDeclarationPaths: [[...RESPONSE_SCHEMA_PATH, 'enum']], - type: semiBreaking, + type: risky, }), ])) }) @@ -172,7 +172,7 @@ describe('Openapi3 ResponseBody.Schema ', () => { expect.objectContaining({ action: DiffAction.add, afterDeclarationPaths: [[...RESPONSE_SCHEMA_PATH, 'enum', 2]], - type: semiBreaking, + type: risky, }), ])) }) @@ -189,7 +189,7 @@ describe('Openapi3 ResponseBody.Schema ', () => { expect.objectContaining({ action: DiffAction.add, afterDeclarationPaths: [[...RESPONSE_SCHEMA_PATH, 'enum', 1]], - type: semiBreaking, + type: risky, }), ], ))