@openapi-qraft/plugin 1.14.0-beta.2 → 1.14.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/lib/open-api/getOperationName.d.ts +2 -1
- package/dist/lib/open-api/getOperationName.d.ts.map +1 -1
- package/dist/lib/open-api/getOperationName.js +8 -6
- package/dist/lib/open-api/getOperationName.js.map +1 -1
- package/dist/lib/processOperationNameModifierOption.d.ts +1 -13
- package/dist/lib/processOperationNameModifierOption.d.ts.map +1 -1
- package/dist/lib/processOperationNameModifierOption.js +31 -23
- package/dist/lib/processOperationNameModifierOption.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/package.json +1 -1
- package/src/lib/open-api/getOperationName.ts +11 -9
- package/src/lib/processOperationNameModifierOption.ts +50 -37
- package/src/packageVersion.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,5 +3,6 @@
|
|
|
3
3
|
* This will use the operation ID - if available - and otherwise fallback
|
|
4
4
|
* on a generated name from the URL
|
|
5
5
|
*/
|
|
6
|
-
export declare const getOperationName: (url: string, method: string, operationId
|
|
6
|
+
export declare const getOperationName: (url: string, method: string, operationId: string | undefined) => string;
|
|
7
|
+
export declare const getOperationIdName: (operationId: string) => string;
|
|
7
8
|
//# sourceMappingURL=getOperationName.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getOperationName.d.ts","sourceRoot":"","sources":["../../../src/lib/open-api/getOperationName.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,QACtB,MAAM,UACH,MAAM,
|
|
1
|
+
{"version":3,"file":"getOperationName.d.ts","sourceRoot":"","sources":["../../../src/lib/open-api/getOperationName.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,QACtB,MAAM,UACH,MAAM,eACD,MAAM,GAAG,SAAS,KAC9B,MASF,CAAC;AAEF,eAAO,MAAM,kBAAkB,gBAAiB,MAAM,KAAG,MAOxD,CAAC"}
|
|
@@ -5,16 +5,18 @@ import camelCase from 'camelcase';
|
|
|
5
5
|
* on a generated name from the URL
|
|
6
6
|
*/
|
|
7
7
|
export const getOperationName = (url, method, operationId) => {
|
|
8
|
-
if (operationId)
|
|
9
|
-
return
|
|
10
|
-
.replace(/^[^a-zA-Z]+/g, '')
|
|
11
|
-
.replace(/[^\w-]+/g, '-')
|
|
12
|
-
.trim());
|
|
13
|
-
}
|
|
8
|
+
if (operationId)
|
|
9
|
+
return getOperationIdName(operationId);
|
|
14
10
|
const urlWithoutPlaceholders = url
|
|
15
11
|
.replace(/[^/]*?{api-version}.*?\//g, '')
|
|
16
12
|
.replace(/{(.*?)}/g, '')
|
|
17
13
|
.replace(/\//g, '-');
|
|
18
14
|
return camelCase(`${method}-${urlWithoutPlaceholders}`);
|
|
19
15
|
};
|
|
16
|
+
export const getOperationIdName = (operationId) => {
|
|
17
|
+
return camelCase(operationId
|
|
18
|
+
.replace(/^[^a-zA-Z]+/g, '')
|
|
19
|
+
.replace(/[^\w-]+/g, '-')
|
|
20
|
+
.trim());
|
|
21
|
+
};
|
|
20
22
|
//# sourceMappingURL=getOperationName.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getOperationName.js","sourceRoot":"","sources":["../../../src/lib/open-api/getOperationName.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,GAAW,EACX,MAAc,EACd,
|
|
1
|
+
{"version":3,"file":"getOperationName.js","sourceRoot":"","sources":["../../../src/lib/open-api/getOperationName.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,GAAW,EACX,MAAc,EACd,WAA+B,EACvB,EAAE;IACV,IAAI,WAAW;QAAE,OAAO,kBAAkB,CAAC,WAAW,CAAC,CAAC;IAExD,MAAM,sBAAsB,GAAG,GAAG;SAC/B,OAAO,CAAC,2BAA2B,EAAE,EAAE,CAAC;SACxC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;SACvB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAEvB,OAAO,SAAS,CAAC,GAAG,MAAM,IAAI,sBAAsB,EAAE,CAAC,CAAC;AAC1D,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,WAAmB,EAAU,EAAE;IAChE,OAAO,SAAS,CACd,WAAW;SACR,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC;SAC3B,OAAO,CAAC,UAAU,EAAE,GAAG,CAAC;SACxB,IAAI,EAAE,CACV,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -8,19 +8,7 @@ export declare const processOperationNameModifierOption: (modifiers: OperationNa
|
|
|
8
8
|
modifiers: OperationNameModifier[];
|
|
9
9
|
}[];
|
|
10
10
|
services: {
|
|
11
|
-
operations:
|
|
12
|
-
name: string;
|
|
13
|
-
method: "get" | "put" | "post" | "patch" | "delete" | "options" | "head" | "trace";
|
|
14
|
-
path: string;
|
|
15
|
-
description: string | undefined;
|
|
16
|
-
summary: string | undefined;
|
|
17
|
-
deprecated: boolean | undefined;
|
|
18
|
-
mediaType: string | undefined;
|
|
19
|
-
errors: Record<string, string | undefined>;
|
|
20
|
-
success: Record<string, string | undefined>;
|
|
21
|
-
parameters: Record<string, any> | undefined;
|
|
22
|
-
security: Record<string, string[] | undefined>[] | undefined;
|
|
23
|
-
}[];
|
|
11
|
+
operations: import("./open-api/getServices.js").ServiceOperation[];
|
|
24
12
|
name: string;
|
|
25
13
|
variableName: string;
|
|
26
14
|
typeName: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processOperationNameModifierOption.d.ts","sourceRoot":"","sources":["../../src/lib/processOperationNameModifierOption.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"processOperationNameModifierOption.d.ts","sourceRoot":"","sources":["../../src/lib/processOperationNameModifierOption.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACpD,OAAO,EACL,oBAAoB,EAErB,MAAM,0BAA0B,CAAC;AAGlC,eAAO,MAAM,kCAAkC,cAClC,qBAAqB,EAAE,YACxB,OAAO,EAAE;;;;;;;;;;;;;;CAmIpB,CAAC;AAMF,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,EAAE,oBAAoB,EAAE,GAAG,SAAS,CAAC;IAC5C;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,0BAA0B,EAAE,MAAM,CAAC;IACnC;;OAEG;IACH,4BAA4B,EAAE,MAAM,CAAC;CACtC,CAAC;AAEF;;;;;;;;;;GAUG;AACH,wBAAgB,0BAA0B,CACxC,GAAG,WAAW,EAAE,MAAM,EAAE,GACvB,qBAAqB,EAAE,CAwCzB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createServicePathMatch } from './createServicePathMatch.js';
|
|
2
|
+
import { getOperationIdName } from './open-api/getOperationName.js';
|
|
2
3
|
import { parseOperationGlobs, } from './parseOperationGlobs.js';
|
|
3
4
|
import { splitCommaSeparatedGlobs } from './splitCommaSeparatedGlobs.js';
|
|
4
5
|
export const processOperationNameModifierOption = (modifiers, services) => {
|
|
@@ -12,31 +13,38 @@ export const processOperationNameModifierOption = (modifiers, services) => {
|
|
|
12
13
|
isPathMatch: createServicePathMatch(splitCommaSeparatedGlobs(modifier.pathGlobs)),
|
|
13
14
|
}));
|
|
14
15
|
const serviceOperationReplacements = new Map();
|
|
15
|
-
const
|
|
16
|
+
for (const service of services) {
|
|
16
17
|
serviceOperationReplacements.set(service.name, new Map());
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
18
|
+
for (const operation of service.operations) {
|
|
19
|
+
const operationReplacements = serviceOperationReplacements.get(service.name);
|
|
20
|
+
if (!operationReplacements)
|
|
21
|
+
throw new Error('operationReplacements not found');
|
|
22
|
+
const operationModifiers = operationNameModifiers.filter((modifier) => modifier.isPathMatch(operation.path) &&
|
|
23
|
+
(modifier.methods === undefined ||
|
|
24
|
+
modifier.methods.includes(operation.method)) &&
|
|
25
|
+
normalizeOperationNameModifierRegex(modifier.operationNameModifierRegex).test(operation.name));
|
|
26
|
+
const replacedOperationName = getOperationIdName(operationModifiers.reduce((operationName, modifier) => operationName.replace(normalizeOperationNameModifierRegex(modifier.operationNameModifierRegex), modifier.operationNameModifierReplace), operation.name));
|
|
27
|
+
if (replacedOperationName !== operation.name) {
|
|
28
|
+
if (!operationReplacements.has(replacedOperationName))
|
|
29
|
+
operationReplacements.set(replacedOperationName, new Map());
|
|
30
|
+
operationReplacements.get(replacedOperationName)?.set(operation.name, operationModifiers.map(({ isPathMatch: _, ...operationModifiersRest }) => operationModifiersRest));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const replacedOperationNamesServices = services.map((service) => ({
|
|
35
|
+
...service,
|
|
36
|
+
operations: service.operations.map((operation) => {
|
|
37
|
+
const operationReplacements = serviceOperationReplacements.get(service.name);
|
|
38
|
+
if (!operationReplacements)
|
|
39
|
+
return operation;
|
|
40
|
+
for (const [replacedName, originalMap] of operationReplacements) {
|
|
41
|
+
if (originalMap.has(operation.name)) {
|
|
42
|
+
return { ...operation, name: replacedName };
|
|
32
43
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}),
|
|
38
|
-
};
|
|
39
|
-
});
|
|
44
|
+
}
|
|
45
|
+
return operation;
|
|
46
|
+
}),
|
|
47
|
+
}));
|
|
40
48
|
const errors = Array.from(serviceOperationReplacements).flatMap(([serviceName, modifiedOperations]) => Array.from(modifiedOperations).flatMap(([replacedOperationName, operationModifierMap]) => {
|
|
41
49
|
if (operationModifierMap.size > 1) {
|
|
42
50
|
return Array.from(operationModifierMap).map(([originalOperationName, modifiers]) => ({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processOperationNameModifierOption.js","sourceRoot":"","sources":["../../src/lib/processOperationNameModifierOption.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"processOperationNameModifierOption.js","sourceRoot":"","sources":["../../src/lib/processOperationNameModifierOption.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEpE,OAAO,EAEL,mBAAmB,GACpB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAEzE,MAAM,CAAC,MAAM,kCAAkC,GAAG,CAChD,SAAkC,EAClC,QAAmB,EACnB,EAAE;IACF,IAAI,CAAC,SAAS,CAAC,MAAM;QACnB,OAAO;YACL,MAAM,EAAE,EAAE;YACV,QAAQ;SACT,CAAC;IAEJ,MAAM,sBAAsB,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QAC1D,GAAG,QAAQ;QACX,WAAW,EAAE,sBAAsB,CACjC,wBAAwB,CAAC,QAAQ,CAAC,SAAS,CAAC,CAC7C;KACF,CAAC,CAAC,CAAC;IAMJ,MAAM,4BAA4B,GAAG,IAAI,GAAG,EAMzC,CAAC;IAEJ,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,4BAA4B,CAAC,GAA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,eAAe,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,CAClD,CAAC;QAEF,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,mBAAmB,CAAC,iBAAiB,CAAC,CAAC;QAEtE,IAAI,CAAC,wBAAwB,CAAC,SAAS,CAAC,CAAC,MAAM;YAC7C,MAAM,IAAI,KAAK,CACb,sBAAsB,SAAS,4CAA4C,CAC5E,CAAC;QAEJ,4BAA4B,CAAC,IAAI,CAAC;YAChC,OAAO;YACP,SAAS;YACT,0BAA0B,EAAE,YAAY,CAAC,IAAI,EAAE;YAC/C,4BAA4B,EAAE,cAAc,CAAC,IAAI,EAAE;SACpD,CAAC,CAAC;IACL,CAAC;IAED,OAAO,4BAA4B,CAAC;AACtC,CAAC"}
|
package/dist/packageVersion.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const packageVersion = "1.14.0-beta.
|
|
1
|
+
export declare const packageVersion = "1.14.0-beta.3";
|
|
2
2
|
//# sourceMappingURL=packageVersion.d.ts.map
|
package/dist/packageVersion.js
CHANGED
package/package.json
CHANGED
|
@@ -8,16 +8,9 @@ import camelCase from 'camelcase';
|
|
|
8
8
|
export const getOperationName = (
|
|
9
9
|
url: string,
|
|
10
10
|
method: string,
|
|
11
|
-
operationId
|
|
11
|
+
operationId: string | undefined
|
|
12
12
|
): string => {
|
|
13
|
-
if (operationId)
|
|
14
|
-
return camelCase(
|
|
15
|
-
operationId
|
|
16
|
-
.replace(/^[^a-zA-Z]+/g, '')
|
|
17
|
-
.replace(/[^\w-]+/g, '-')
|
|
18
|
-
.trim()
|
|
19
|
-
);
|
|
20
|
-
}
|
|
13
|
+
if (operationId) return getOperationIdName(operationId);
|
|
21
14
|
|
|
22
15
|
const urlWithoutPlaceholders = url
|
|
23
16
|
.replace(/[^/]*?{api-version}.*?\//g, '')
|
|
@@ -26,3 +19,12 @@ export const getOperationName = (
|
|
|
26
19
|
|
|
27
20
|
return camelCase(`${method}-${urlWithoutPlaceholders}`);
|
|
28
21
|
};
|
|
22
|
+
|
|
23
|
+
export const getOperationIdName = (operationId: string): string => {
|
|
24
|
+
return camelCase(
|
|
25
|
+
operationId
|
|
26
|
+
.replace(/^[^a-zA-Z]+/g, '')
|
|
27
|
+
.replace(/[^\w-]+/g, '-')
|
|
28
|
+
.trim()
|
|
29
|
+
);
|
|
30
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createServicePathMatch } from './createServicePathMatch.js';
|
|
2
|
+
import { getOperationIdName } from './open-api/getOperationName.js';
|
|
2
3
|
import { Service } from './open-api/getServices.js';
|
|
3
4
|
import {
|
|
4
5
|
OperationGlobMethods,
|
|
@@ -35,30 +36,29 @@ export const processOperationNameModifierOption = (
|
|
|
35
36
|
>
|
|
36
37
|
>();
|
|
37
38
|
|
|
38
|
-
const
|
|
39
|
+
for (const service of services) {
|
|
39
40
|
serviceOperationReplacements.set(service.name, new Map());
|
|
40
41
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
service.name
|
|
46
|
-
);
|
|
42
|
+
for (const operation of service.operations) {
|
|
43
|
+
const operationReplacements = serviceOperationReplacements.get(
|
|
44
|
+
service.name
|
|
45
|
+
);
|
|
47
46
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
47
|
+
if (!operationReplacements)
|
|
48
|
+
throw new Error('operationReplacements not found');
|
|
49
|
+
|
|
50
|
+
const operationModifiers = operationNameModifiers.filter(
|
|
51
|
+
(modifier) =>
|
|
52
|
+
modifier.isPathMatch(operation.path) &&
|
|
53
|
+
(modifier.methods === undefined ||
|
|
54
|
+
modifier.methods.includes(operation.method)) &&
|
|
55
|
+
normalizeOperationNameModifierRegex(
|
|
56
|
+
modifier.operationNameModifierRegex
|
|
57
|
+
).test(operation.name)
|
|
58
|
+
);
|
|
60
59
|
|
|
61
|
-
|
|
60
|
+
const replacedOperationName = getOperationIdName(
|
|
61
|
+
operationModifiers.reduce(
|
|
62
62
|
(operationName, modifier) =>
|
|
63
63
|
operationName.replace(
|
|
64
64
|
normalizeOperationNameModifierRegex(
|
|
@@ -67,27 +67,40 @@ export const processOperationNameModifierOption = (
|
|
|
67
67
|
modifier.operationNameModifierReplace
|
|
68
68
|
),
|
|
69
69
|
operation.name
|
|
70
|
+
)
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
if (replacedOperationName !== operation.name) {
|
|
74
|
+
if (!operationReplacements.has(replacedOperationName))
|
|
75
|
+
operationReplacements.set(replacedOperationName, new Map());
|
|
76
|
+
operationReplacements.get(replacedOperationName)?.set(
|
|
77
|
+
operation.name,
|
|
78
|
+
operationModifiers.map(
|
|
79
|
+
({ isPathMatch: _, ...operationModifiersRest }) =>
|
|
80
|
+
operationModifiersRest
|
|
81
|
+
)
|
|
70
82
|
);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const replacedOperationNamesServices = services.map((service) => ({
|
|
88
|
+
...service,
|
|
89
|
+
operations: service.operations.map((operation) => {
|
|
90
|
+
const operationReplacements = serviceOperationReplacements.get(
|
|
91
|
+
service.name
|
|
92
|
+
);
|
|
93
|
+
if (!operationReplacements) return operation;
|
|
71
94
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
operationReplacements.get(replacedOperationName)?.set(
|
|
76
|
-
operation.name,
|
|
77
|
-
operationModifiers.map(
|
|
78
|
-
({ isPathMatch: _, ...operationModifiersRest }) =>
|
|
79
|
-
operationModifiersRest
|
|
80
|
-
)
|
|
81
|
-
);
|
|
95
|
+
for (const [replacedName, originalMap] of operationReplacements) {
|
|
96
|
+
if (originalMap.has(operation.name)) {
|
|
97
|
+
return { ...operation, name: replacedName };
|
|
82
98
|
}
|
|
99
|
+
}
|
|
83
100
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
};
|
|
88
|
-
}),
|
|
89
|
-
};
|
|
90
|
-
});
|
|
101
|
+
return operation;
|
|
102
|
+
}),
|
|
103
|
+
}));
|
|
91
104
|
|
|
92
105
|
const errors = Array.from(serviceOperationReplacements).flatMap(
|
|
93
106
|
([serviceName, modifiedOperations]) =>
|
package/src/packageVersion.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// This file was generated automatically
|
|
2
|
-
export const packageVersion = '1.14.0-beta.
|
|
2
|
+
export const packageVersion = '1.14.0-beta.3';
|