Skip to content

Commit c034d00

Browse files
committed
feat: Review
1 parent bac1e30 commit c034d00

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

src/apitypes/rest/rest.changes.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ import {
8282
getOperationTags,
8383
OperationsMap,
8484
} from '../../components'
85-
import { checkApiKind, getApiKindFormLabels } from '../../components/compare/bwc.validation'
85+
import { createApiKindChecker, getApiKindFormLabels } from '../../components/compare/bwc.validation'
8686

8787
export const compareDocuments: DocumentsCompare = async (
8888
operationsMap: OperationsMap,
@@ -135,7 +135,7 @@ export const compareDocuments: DocumentsCompare = async (
135135
normalizedResult: false,
136136
afterValueNormalizedProperty: AFTER_VALUE_NORMALIZED_PROPERTY,
137137
beforeValueNormalizedProperty: BEFORE_VALUE_NORMALIZED_PROPERTY,
138-
apiCompatibilityScopeFunction: checkApiKind(
138+
apiCompatibilityScopeFunction: createApiKindChecker(
139139
prevDoc?.apiKind ?? getApiKindFormLabels(prevDocData?.info, prevDoc?.labels, previousVersionLabels),
140140
currDoc?.apiKind ?? getApiKindFormLabels(currDocData?.info, currDoc?.labels, currentVersionLabels),
141141
),

src/components/compare/bwc.validation.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,15 @@ const checkAllMethodsHaveSameApiKind = (obj: unknown, apiKind: string): boolean
7979

8080
const ROOT_PATH_LENGTH = 0
8181
const PATH_ITEM_PATH_LENGTH = 2
82-
const MAX_BWC_FLAG_PATH_LENGTH = 3
82+
const OPERATION_OBJECT_PATH_LENGTH = 3
8383

84-
export const checkApiKind = (
84+
export const createApiKindChecker = (
8585
prevApiKind: string = API_KIND.BWC,
8686
currApiKind: string = API_KIND.BWC,
8787
): ApiCompatibilityScopeFunction => {
8888
const defaultApiCompatibilityKind = (prevApiKind === API_KIND.NO_BWC || currApiKind === API_KIND.NO_BWC)
8989
? ApiCompatibilityKind.NOT_BACKWARD_COMPATIBLE
90-
: undefined
90+
: ApiCompatibilityKind.BACKWARD_COMPATIBLE
9191

9292
return (
9393
path?: JsonPath,
@@ -98,7 +98,7 @@ export const checkApiKind = (
9898
/*
9999
* Calculating Api Kind for the entire document as the default
100100
* If there is a NO_BWC marker on:
101-
* - Publish label
101+
* - Version labels and Document labels
102102
* - Document API info section
103103
*/
104104
if (pathLength === ROOT_PATH_LENGTH) {
@@ -110,7 +110,7 @@ export const checkApiKind = (
110110
* Level 3: When individual operations are deleted/added
111111
*/
112112
const isFirstPathSegmentPaths = path?.[0] === 'paths'
113-
if (!isFirstPathSegmentPaths || pathLength < PATH_ITEM_PATH_LENGTH || pathLength > MAX_BWC_FLAG_PATH_LENGTH) {
113+
if (!isFirstPathSegmentPaths || pathLength < PATH_ITEM_PATH_LENGTH || pathLength > OPERATION_OBJECT_PATH_LENGTH) {
114114
return undefined
115115
}
116116

src/components/document.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { BuildConfigFile, BuilderContext, FILE_KIND, SourceFile, TextFile, VersionDocument } from '../types'
17+
import { ApiKind, BuildConfigFile, BuilderContext, FILE_KIND, SourceFile, TextFile, VersionDocument } from '../types'
1818
import { API_KIND, API_KIND_LABEL, DOCUMENT_TYPE, FILE_FORMAT_UNKNOWN } from '../consts'
1919
import { createVersionInternalDocument, getDocumentTitle, getFileExtension, isObject, rawToApiKind } from '../utils'
2020
import { buildBinaryDocument, REST_KIND_KEY, unknownApiBuilder } from '../apitypes'
@@ -56,7 +56,7 @@ export const buildDocument = async (parsedFile: SourceFile, file: BuildConfigFil
5656
}
5757
}
5858

59-
export const findApiKindLabel = (fileLabels: unknown, versionLabels: unknown): string => {
59+
export const findApiKindLabel = (fileLabels: unknown, versionLabels: unknown): ApiKind => {
6060
if (!Array.isArray(fileLabels) && !Array.isArray(versionLabels)) {
6161
return API_KIND.BWC
6262
}

src/types/external/version.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ export type ResolvedVersion = {
3737
// operationSummary?: object
3838
// createdAt: string
3939
// createdBy: string
40-
// versionLabels?: string[]
4140
}
4241

4342
export type OperationTypes = {

src/types/internal/apiBuilder.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ import {
2020
BuildConfigRef,
2121
ExportFormat,
2222
FileId,
23-
GroupDocumentsResolver, Labels,
23+
GroupDocumentsResolver,
24+
Labels,
2425
OperationId,
2526
OperationsApiType,
2627
PackageId,

0 commit comments

Comments
 (0)