Skip to content

Commit b25ce4d

Browse files
committed
Merge remote-tracking branch 'refs/remotes/origin/develop' into feature/export-build-tasks-support
# Conflicts: # src/builder.ts # src/types/internal/apiBuilder.ts
2 parents b37f04c + d0f1648 commit b25ce4d

File tree

27 files changed

+344
-172
lines changed

27 files changed

+344
-172
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@alagishev
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
name: delete-dist-tag
2+
3+
on:
4+
delete:
5+
6+
jobs:
7+
delete-dist-tag:
8+
uses: netcracker/qubership-apihub-ci/.github/workflows/delete-dist-tag.yaml@main

.github/workflows/frontend-ci.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Frontend CI Workflow
1+
name: frontend-ci
22

33
on:
44
push:
@@ -10,7 +10,6 @@ on:
1010
- bugfix/*
1111
tags:
1212
- '**'
13-
delete:
1413

1514
jobs:
1615
call-frontend-ci-workflow:

package-lock.json

Lines changed: 22 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@netcracker/qubership-apihub-api-processor",
3-
"version": "3.1.1",
3+
"version": "4.0.1",
44
"description": "",
55
"license": "Apache-2.0",
66
"module": "dist/esm/src/index.js",
@@ -28,14 +28,11 @@
2828
"operation:test": "node ./test/operation.js",
2929
"profile": "node --inspect-brk ./test/profile.js",
3030
"test:coverage": "jest --verbose --coverage",
31-
"feature-start": "feature-start --featureName",
32-
"feature-finish": "feature-finish",
33-
"release-start": "release-start",
34-
"release-finish": "release-finish"
31+
"update-lock-file": "update-lock-file @netcracker"
3532
},
3633
"dependencies": {
37-
"@netcracker/qubership-apihub-api-diff": "dev",
38-
"@netcracker/qubership-apihub-api-unifier": "1.0.4",
34+
"@netcracker/qubership-apihub-api-diff": "2.0.0",
35+
"@netcracker/qubership-apihub-api-unifier": "2.0.0",
3936
"@netcracker/qubership-apihub-json-crawl": "1.0.4",
4037
"@netcracker/qubership-apihub-graphapi": "1.0.8",
4138
"adm-zip": "0.5.10",
@@ -52,7 +49,7 @@
5249
"swagger2openapi": "^7.0.8"
5350
},
5451
"devDependencies": {
55-
"@netcracker/qubership-apihub-npm-gitflow": "2.2.2",
52+
"@netcracker/qubership-apihub-npm-gitflow": "3.0.1",
5653
"@types/adm-zip": "0.5.7",
5754
"@types/jest": "^29.5.12",
5855
"@types/js-yaml": "^4.0.5",

src/apitypes/rest/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { OpenAPIV3 } from 'openapi-types'
1919
import { buildRestDocument, dumpRestDocument } from './rest.document'
2020
import { REST_API_TYPE, REST_DOCUMENT_TYPE } from './rest.consts'
2121
import { compareRestOperationsData } from './rest.changes'
22-
import { buildRestOperations } from './rest.operations'
22+
import { buildRestOperations, createNormalizedOperationId } from './rest.operations'
2323
import { parseRestFile } from './rest.parser'
2424

2525
import { ApiBuilder } from '../../types'
@@ -34,4 +34,5 @@ export const restApiBuilder: ApiBuilder<OpenAPIV3.Document> = {
3434
buildOperations: buildRestOperations,
3535
dumpDocument: dumpRestDocument,
3636
compareOperationsData: compareRestOperationsData,
37+
createNormalizedOperationId: createNormalizedOperationId,
3738
}

src/apitypes/rest/rest.operations.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,20 @@
1717
import { OpenAPIV3 } from 'openapi-types'
1818

1919
import { buildRestOperation } from './rest.operation'
20-
import { OperationsBuilder } from '../../types'
21-
import { createBundlingErrorHandler, removeComponents, removeFirstSlash, slugify } from '../../utils'
20+
import { OperationIdNormalizer, OperationsBuilder } from '../../types'
21+
import {
22+
createBundlingErrorHandler,
23+
IGNORE_PATH_PARAM_UNIFIED_PLACEHOLDER,
24+
removeComponents,
25+
removeFirstSlash,
26+
slugify,
27+
} from '../../utils'
2228
import { getOperationBasePath } from './rest.utils'
2329
import type * as TYPE from './rest.types'
2430
import { HASH_FLAG, INLINE_REFS_FLAG, MESSAGE_SEVERITY, NORMALIZE_OPTIONS, ORIGINS_SYMBOL } from '../../consts'
2531
import { asyncFunction } from '../../utils/async'
2632
import { logLongBuild, syncDebugPerformance } from '../../utils/logs'
27-
import { normalize } from '@netcracker/qubership-apihub-api-unifier'
33+
import { normalize, RefErrorType } from '@netcracker/qubership-apihub-api-unifier'
2834

2935
export const buildRestOperations: OperationsBuilder<OpenAPIV3.Document> = async (document, ctx, debugCtx) => {
3036
const documentWithoutComponents = removeComponents(document.data)
@@ -38,8 +44,8 @@ export const buildRestOperations: OperationsBuilder<OpenAPIV3.Document> = async
3844
originsFlag: ORIGINS_SYMBOL,
3945
hashFlag: HASH_FLAG,
4046
source: document.data,
41-
onRefResolveError: (_: string, __: PropertyKey[], ref: string) =>
42-
bundlingErrorHandler([`The $ref "${ref}" references an invalid location in the document.`]),
47+
onRefResolveError: (message: string, _path: PropertyKey[], _ref: string, errorType: RefErrorType) =>
48+
bundlingErrorHandler([{ message, errorType }]),
4349
},
4450
) as OpenAPIV3.Document
4551
const refsOnlyDocument = normalize(
@@ -106,3 +112,8 @@ export const buildRestOperations: OperationsBuilder<OpenAPIV3.Document> = async
106112
}
107113
return operations
108114
}
115+
116+
export const createNormalizedOperationId: OperationIdNormalizer = (operation) => {
117+
const { metadata: { path, method } } = operation
118+
return slugify(`${path}-${method}`, [], IGNORE_PATH_PARAM_UNIFIED_PLACEHOLDER)
119+
}

src/apitypes/rest/rest.types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@ import type { OpenAPIV3 } from 'openapi-types'
1818

1919
import type { ApiOperation, NotificationMessage, VersionDocument } from '../../types'
2020
import { REST_DOCUMENT_TYPE, REST_KIND_KEY, REST_SCOPES } from './rest.consts'
21+
import { NormalizedPath } from '../../utils'
2122

2223
export type RestScopeType = keyof typeof REST_SCOPES
2324
export type RestDocumentType = (typeof REST_DOCUMENT_TYPE)[keyof typeof REST_DOCUMENT_TYPE]
2425
export type CustomTags = Record<string, unknown>
2526

2627
export interface RestOperationMeta {
27-
path: string // `/packages/*/version/*`
28+
path: NormalizedPath // `/packages/*/version/*`
2829
originalPath: string // `/packages/{packageId}/version/{version}`
2930
method: OpenAPIV3.HttpMethods // `get` | `post` | ...
3031
tags?: string[] // operations tags

src/builder.ts

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,10 @@ export class PackageVersionBuilder implements IPackageVersionBuilder {
341341
packageId = packageId ?? this.config.packageId
342342

343343
if (this.canBeResolvedLocally(version, packageId)) {
344-
const currentOperations = operationIds ? this.operationList.filter(({ operationId }) => operationIds.includes(operationId)) : this.operationList
344+
const currentApiTypeOperations = this.operationList.filter((operation) => operation.apiType === apiType)
345+
const currentOperations = operationIds
346+
? currentApiTypeOperations.filter(({ operationId }) => operationIds.includes(operationId))
347+
: currentApiTypeOperations
345348
return { operations: currentOperations }
346349
}
347350

@@ -498,6 +501,8 @@ export class PackageVersionBuilder implements IPackageVersionBuilder {
498501
throw new Error('No versionResolver provided')
499502
}
500503

504+
// includeOperations=true is only used to extract unique apiTypes (see getUniqueApiTypesFromVersions)
505+
// the operations map itself is no longer used in processor
501506
const versionContent = await versionResolver(packageId, version, true)
502507

503508
if (!versionContent) {
@@ -576,10 +581,9 @@ export class PackageVersionBuilder implements IPackageVersionBuilder {
576581
const operationsTypes: OperationTypes[] = []
577582

578583
for (const apiType of this.existingOperationsApiTypes) {
579-
const operationsHashMap = this.operationsHashMapByApiType(apiType)
580584
operationsTypes.push({
581585
apiType: apiType,
582-
operations: operationsHashMap,
586+
operationsCount: this.operations.size,
583587
})
584588
}
585589

@@ -592,18 +596,6 @@ export class PackageVersionBuilder implements IPackageVersionBuilder {
592596
return new Set(apiTypes)
593597
}
594598

595-
private operationsHashMapByApiType(operationsApiType: OperationsApiType): ResolvedVersionOperationsHashMap {
596-
const hashMap: ResolvedVersionOperationsHashMap = {}
597-
598-
for (const { apiType, operationId, dataHash } of this.operations.values()) {
599-
if (apiType === operationsApiType) {
600-
hashMap[operationId] = dataHash
601-
}
602-
}
603-
604-
return hashMap
605-
}
606-
607599
async parseFile(fileId: string, source: Blob): Promise<SourceFile | null> {
608600
if (this.parsedFiles.has(fileId)) {
609601
return this.parsedFiles.get(fileId) ?? null

0 commit comments

Comments
 (0)