@keq-request/cli 5.0.0-alpha.23 → 5.0.0-alpha.24
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 +15 -0
- package/dist/cli.cjs +111 -150
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +111 -150
- package/dist/cli.js.map +1 -1
- package/dist/compiler/tasks/download/index.d.ts.map +1 -1
- package/dist/compiler/tasks/setup/index.d.ts.map +1 -1
- package/dist/index.cjs +109 -150
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +109 -150
- package/dist/index.js.map +1 -1
- package/dist/models/api-document_v3_1.d.ts +0 -1
- package/dist/models/api-document_v3_1.d.ts.map +1 -1
- package/dist/models/artifact.d.ts +0 -2
- package/dist/models/artifact.d.ts.map +1 -1
- package/dist/plugins/generate-micro-function/generators/micro_function/micro-function.generator.d.ts.map +1 -1
- package/dist/plugins/generate-nestjs-module/generators/nestjs-module.generator.d.ts.map +1 -1
- package/dist/plugins/index.d.ts +2 -0
- package/dist/plugins/index.d.ts.map +1 -1
- package/dist/plugins/initialize/initialize.plugin.d.ts.map +1 -1
- package/dist/plugins/overwrite-operation-id/index.d.ts +2 -0
- package/dist/plugins/overwrite-operation-id/index.d.ts.map +1 -0
- package/dist/plugins/overwrite-operation-id/overwrite-operation-id.plugin.d.ts +20 -0
- package/dist/plugins/overwrite-operation-id/overwrite-operation-id.plugin.d.ts.map +1 -0
- package/dist/plugins/overwrite-query-options/index.d.ts +2 -0
- package/dist/plugins/overwrite-query-options/index.d.ts.map +1 -0
- package/dist/plugins/overwrite-query-options/overwrite-query-options.plugin.d.ts +18 -0
- package/dist/plugins/overwrite-query-options/overwrite-query-options.plugin.d.ts.map +1 -0
- package/dist/plugins/prettier/index.d.ts +1 -5
- package/dist/plugins/prettier/index.d.ts.map +1 -1
- package/dist/plugins/prettier/prettier.plugin.d.ts +6 -0
- package/dist/plugins/prettier/prettier.plugin.d.ts.map +1 -0
- package/dist/plugins/shaking/shaking.plugin.d.ts.map +1 -1
- package/dist/plugins.cjs +172 -93
- package/dist/plugins.cjs.map +1 -1
- package/dist/plugins.js +170 -93
- package/dist/plugins.js.map +1 -1
- package/dist/transformers/api-document/nestjs-client.renderer.d.ts +0 -3
- package/dist/transformers/api-document/nestjs-client.renderer.d.ts.map +1 -1
- package/dist/transformers/operation-definition/declaration.renderer.d.ts.map +1 -1
- package/dist/transformers/operation-definition/micro-function.renderer.d.ts +1 -1
- package/dist/transformers/operation-definition/micro-function.renderer.d.ts.map +1 -1
- package/dist/transformers/operation-definition/nestjs-method.renderer.d.ts +1 -1
- package/dist/transformers/operation-definition/nestjs-method.renderer.d.ts.map +1 -1
- package/dist/transformers/operation-definition/{typescript-helper.d.ts → typescript-snippet.d.ts} +1 -4
- package/dist/transformers/operation-definition/typescript-snippet.d.ts.map +1 -0
- package/dist/types/index.d.ts +0 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/runtime-config.d.ts +1 -17
- package/dist/types/runtime-config.d.ts.map +1 -1
- package/dist/utils/openapi-utils/index.d.ts +4 -2
- package/dist/utils/openapi-utils/index.d.ts.map +1 -1
- package/dist/utils/openapi-utils/map-operation.d.ts +4 -0
- package/dist/utils/openapi-utils/map-operation.d.ts.map +1 -0
- package/dist/utils/openapi-utils/map-parameter.d.ts +4 -0
- package/dist/utils/openapi-utils/map-parameter.d.ts.map +1 -0
- package/package.json +3 -3
- package/dist/transformers/operation-definition/typescript-helper.d.ts.map +0 -1
- package/dist/types/operation-id-factory.d.ts +0 -10
- package/dist/types/operation-id-factory.d.ts.map +0 -1
- package/dist/types/qs.d.ts +0 -9
- package/dist/types/qs.d.ts.map +0 -1
- package/dist/utils/openapi-utils/update-operation-id.d.ts +0 -5
- package/dist/utils/openapi-utils/update-operation-id.d.ts.map +0 -1
package/dist/plugins.js
CHANGED
|
@@ -27,7 +27,7 @@ var EslintPlugin = class _EslintPlugin {
|
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
// src/plugins/prettier/
|
|
30
|
+
// src/plugins/prettier/prettier.plugin.ts
|
|
31
31
|
import { exec } from "child_process";
|
|
32
32
|
import { promisify } from "util";
|
|
33
33
|
var execAsync = promisify(exec);
|
|
@@ -88,12 +88,6 @@ import * as changeCase6 from "change-case";
|
|
|
88
88
|
// src/models/artifact.ts
|
|
89
89
|
import * as path from "path";
|
|
90
90
|
|
|
91
|
-
// src/models/utils/to-comment.ts
|
|
92
|
-
function toComment(msg) {
|
|
93
|
-
if (!msg) return "";
|
|
94
|
-
return msg.split("\n").map((str) => `// ${str}`).join("\n");
|
|
95
|
-
}
|
|
96
|
-
|
|
97
91
|
// src/models/anchor.ts
|
|
98
92
|
var AnchorBlock = class {
|
|
99
93
|
constructor(artifact) {
|
|
@@ -172,7 +166,6 @@ var HeaderComment = [
|
|
|
172
166
|
var Artifact = class {
|
|
173
167
|
id;
|
|
174
168
|
filepath;
|
|
175
|
-
warns = [];
|
|
176
169
|
content;
|
|
177
170
|
extensionName;
|
|
178
171
|
anchor = new Anchor(this);
|
|
@@ -185,20 +178,8 @@ var Artifact = class {
|
|
|
185
178
|
get dirname() {
|
|
186
179
|
return path.dirname(this.filepath);
|
|
187
180
|
}
|
|
188
|
-
addWarn(message) {
|
|
189
|
-
this.warns.push(message);
|
|
190
|
-
}
|
|
191
181
|
renderer() {
|
|
192
|
-
|
|
193
|
-
if (this.warns.length) {
|
|
194
|
-
$warns = toComment([
|
|
195
|
-
"!!! Here is some Problems !!!",
|
|
196
|
-
"",
|
|
197
|
-
this.warns
|
|
198
|
-
].join("\n"));
|
|
199
|
-
$warns += "\n\n";
|
|
200
|
-
}
|
|
201
|
-
return `${HeaderComment}${$warns}${this.content}`;
|
|
182
|
+
return `${HeaderComment}${this.content}`;
|
|
202
183
|
}
|
|
203
184
|
};
|
|
204
185
|
|
|
@@ -408,7 +389,6 @@ var logger = {
|
|
|
408
389
|
};
|
|
409
390
|
|
|
410
391
|
// src/models/api-document_v3_1.ts
|
|
411
|
-
import { openapiShakingSync } from "@opendoc/openapi-shaking";
|
|
412
392
|
var ApiDocumentV3_1 = class _ApiDocumentV3_1 {
|
|
413
393
|
module;
|
|
414
394
|
specification;
|
|
@@ -451,31 +431,6 @@ var ApiDocumentV3_1 = class _ApiDocumentV3_1 {
|
|
|
451
431
|
}
|
|
452
432
|
return false;
|
|
453
433
|
}
|
|
454
|
-
sharking(filter) {
|
|
455
|
-
const isAccepted = (pathname, method, operation) => {
|
|
456
|
-
if (!SupportedMethods.includes(method)) return false;
|
|
457
|
-
const operationDefinition = new OperationDefinition({
|
|
458
|
-
method,
|
|
459
|
-
pathname,
|
|
460
|
-
operation,
|
|
461
|
-
module: this.module,
|
|
462
|
-
document: this
|
|
463
|
-
});
|
|
464
|
-
return filter(operationDefinition);
|
|
465
|
-
};
|
|
466
|
-
const sharkedSwagger = openapiShakingSync(
|
|
467
|
-
this.specification,
|
|
468
|
-
isAccepted,
|
|
469
|
-
{ tolerant: true }
|
|
470
|
-
);
|
|
471
|
-
return new _ApiDocumentV3_1(
|
|
472
|
-
sharkedSwagger,
|
|
473
|
-
new ModuleDefinition(
|
|
474
|
-
this.module.name,
|
|
475
|
-
`file://${this.module.name}.v3_1.sharked.json`
|
|
476
|
-
)
|
|
477
|
-
);
|
|
478
|
-
}
|
|
479
434
|
static unknown() {
|
|
480
435
|
return new _ApiDocumentV3_1({}, ModuleDefinition.unknown());
|
|
481
436
|
}
|
|
@@ -840,25 +795,6 @@ function dereferenceOperation(swagger) {
|
|
|
840
795
|
return removeUndefinedRef(shadow);
|
|
841
796
|
}
|
|
842
797
|
|
|
843
|
-
// src/utils/openapi-utils/update-operation-id.ts
|
|
844
|
-
import * as R11 from "ramda";
|
|
845
|
-
function updateOperationId(swagger, fn) {
|
|
846
|
-
const shadow = R11.clone(swagger);
|
|
847
|
-
for (const [pathname, pathItem] of Object.entries(shadow.paths || {})) {
|
|
848
|
-
for (const m in pathItem) {
|
|
849
|
-
const method = m.toLowerCase();
|
|
850
|
-
if (!SupportedMethods.includes(method)) continue;
|
|
851
|
-
if (typeof pathItem[m] !== "object" || Array.isArray(pathItem[m]) || pathItem[m] === null) continue;
|
|
852
|
-
const operation = pathItem[m];
|
|
853
|
-
const operationId = fn(method, pathname, operation);
|
|
854
|
-
if (typeof operationId === "string" && operationId.length > 0) {
|
|
855
|
-
operation.operationId = operationId;
|
|
856
|
-
}
|
|
857
|
-
}
|
|
858
|
-
}
|
|
859
|
-
return shadow;
|
|
860
|
-
}
|
|
861
|
-
|
|
862
798
|
// src/utils/openapi-utils/dereference-deep.ts
|
|
863
799
|
function dereferenceDeep($ref, swagger) {
|
|
864
800
|
const stack = [$ref];
|
|
@@ -886,6 +822,31 @@ function To3_1(openapi) {
|
|
|
886
822
|
return specification;
|
|
887
823
|
}
|
|
888
824
|
|
|
825
|
+
// src/utils/openapi-utils/map-operation.ts
|
|
826
|
+
import * as R11 from "ramda";
|
|
827
|
+
function mapOperation(specification, mapper) {
|
|
828
|
+
const shadow = R11.clone(specification);
|
|
829
|
+
for (const [pathname, pathItem] of Object.entries(shadow.paths || {})) {
|
|
830
|
+
for (const m in pathItem) {
|
|
831
|
+
const method = m.toLowerCase();
|
|
832
|
+
if (!SupportedMethods.includes(method)) continue;
|
|
833
|
+
if (typeof pathItem[m] !== "object" || Array.isArray(pathItem[m]) || pathItem[m] === null) continue;
|
|
834
|
+
const operation = pathItem[m];
|
|
835
|
+
pathItem[m] = mapper(method, pathname, operation);
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
return shadow;
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
// src/utils/openapi-utils/map-parameter.ts
|
|
842
|
+
function mapParameter(specification, mapper) {
|
|
843
|
+
return mapOperation(specification, (method, pathname, operation) => {
|
|
844
|
+
if (!operation.parameters) return operation;
|
|
845
|
+
operation.parameters = operation.parameters.map((parameter) => mapper(method, pathname, operation, parameter));
|
|
846
|
+
return operation;
|
|
847
|
+
});
|
|
848
|
+
}
|
|
849
|
+
|
|
889
850
|
// src/utils/openapi-utils/index.ts
|
|
890
851
|
var OpenapiUtils = class {
|
|
891
852
|
static isRefDefined = isRefDefined;
|
|
@@ -893,7 +854,9 @@ var OpenapiUtils = class {
|
|
|
893
854
|
static dereferenceDeep = dereferenceDeep;
|
|
894
855
|
static removeUndefinedRef = removeUndefinedRef;
|
|
895
856
|
static dereferenceOperation = dereferenceOperation;
|
|
896
|
-
static
|
|
857
|
+
static mapOperation = mapOperation;
|
|
858
|
+
static mapParameter = mapParameter;
|
|
859
|
+
// static updateOperationId = updateOperationId
|
|
897
860
|
static to3_1 = To3_1;
|
|
898
861
|
};
|
|
899
862
|
|
|
@@ -912,7 +875,12 @@ var DeclarationRenderer2 = class {
|
|
|
912
875
|
}
|
|
913
876
|
const $responses = Object.entries(operation.responses).map(([statusCode, response]) => {
|
|
914
877
|
if (!JsonSchemaUtils.isRef(response)) {
|
|
915
|
-
const $value = Object.
|
|
878
|
+
const $value = Object.entries(response.content || {}).map(([mediaType, mediaTypeObject]) => [mediaType, mediaTypeObject.schema]).map(([mediaType, schema]) => {
|
|
879
|
+
if (mediaType.includes("text/event-stream")) return "ReadableStream<ServerSentEvent>";
|
|
880
|
+
if (mediaType.includes("multipart/form-data")) return "FormData";
|
|
881
|
+
if (!schema) return "unknown";
|
|
882
|
+
return JsonSchemaTransformer.toDeclaration(schema, options);
|
|
883
|
+
}).join(" | ");
|
|
916
884
|
return indent(2, `${statusCode}: ${$value || "void"}`);
|
|
917
885
|
}
|
|
918
886
|
}).join("\n");
|
|
@@ -994,7 +962,7 @@ var DeclarationRenderer2 = class {
|
|
|
994
962
|
return `import type { ${schemaName} as ${alias(schemaName)} } from "${filepath}"`;
|
|
995
963
|
}).map((str) => str.replace(/ from "(\.\.?\/.+?)(\.ts|\.mts|\.cts|\.js|\.cjs|\.mjs)?"/, this.options.esm ? ' from "$1.js"' : ' from "$1"'));
|
|
996
964
|
return [
|
|
997
|
-
'import type { KeqOperation, KeqPathParameterInit, KeqQueryInit } from "keq"',
|
|
965
|
+
'import type { KeqOperation, KeqPathParameterInit, KeqQueryInit, ServerSentEvent } from "keq"',
|
|
998
966
|
...$schemaDefinitions
|
|
999
967
|
].join("\n");
|
|
1000
968
|
}
|
|
@@ -1073,8 +1041,21 @@ ${msg}`);
|
|
|
1073
1041
|
}
|
|
1074
1042
|
};
|
|
1075
1043
|
|
|
1076
|
-
// src/transformers/operation-definition/typescript-
|
|
1044
|
+
// src/transformers/operation-definition/typescript-snippet.ts
|
|
1077
1045
|
import * as R13 from "ramda";
|
|
1046
|
+
|
|
1047
|
+
// src/constants/qs-array-format.ts
|
|
1048
|
+
var QsArrayFormat = /* @__PURE__ */ ((QsArrayFormat2) => {
|
|
1049
|
+
QsArrayFormat2["brackets"] = "brackets";
|
|
1050
|
+
QsArrayFormat2["indices"] = "indices";
|
|
1051
|
+
QsArrayFormat2["repeat"] = "repeat";
|
|
1052
|
+
QsArrayFormat2["comma"] = "comma";
|
|
1053
|
+
QsArrayFormat2["space"] = "space";
|
|
1054
|
+
QsArrayFormat2["pipe"] = "pipe";
|
|
1055
|
+
return QsArrayFormat2;
|
|
1056
|
+
})(QsArrayFormat || {});
|
|
1057
|
+
|
|
1058
|
+
// src/transformers/operation-definition/typescript-snippet.ts
|
|
1078
1059
|
var OperationDefinitionSnippet = class {
|
|
1079
1060
|
constructor(operationDefinition, options) {
|
|
1080
1061
|
this.operationDefinition = operationDefinition;
|
|
@@ -1083,27 +1064,42 @@ var OperationDefinitionSnippet = class {
|
|
|
1083
1064
|
}
|
|
1084
1065
|
typeName;
|
|
1085
1066
|
getQsParameters(parameter) {
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
return this.options.qs;
|
|
1090
|
-
}
|
|
1067
|
+
let arrayFormat;
|
|
1068
|
+
let allowDots;
|
|
1069
|
+
let indices;
|
|
1091
1070
|
const style = parameter.style || "form";
|
|
1092
1071
|
const explode = parameter.explode ?? true;
|
|
1093
|
-
if (
|
|
1094
|
-
|
|
1095
|
-
} else if (explode) {
|
|
1096
|
-
return { arrayFormat: "repeat" };
|
|
1072
|
+
if ("x-qs-array-format" in parameter) {
|
|
1073
|
+
arrayFormat = parameter["x-qs-array-format"];
|
|
1097
1074
|
} else {
|
|
1098
|
-
if (style === "
|
|
1099
|
-
|
|
1100
|
-
} else if (
|
|
1101
|
-
|
|
1102
|
-
} else
|
|
1103
|
-
|
|
1075
|
+
if (style === "deepObject") {
|
|
1076
|
+
arrayFormat = "brackets" /* brackets */;
|
|
1077
|
+
} else if (explode) {
|
|
1078
|
+
arrayFormat = "repeat" /* repeat */;
|
|
1079
|
+
} else {
|
|
1080
|
+
if (style === "form") {
|
|
1081
|
+
arrayFormat = "comma" /* comma */;
|
|
1082
|
+
} else if (style === "spaceDelimited") {
|
|
1083
|
+
arrayFormat = "space" /* space */;
|
|
1084
|
+
} else if (style === "pipeDelimited") {
|
|
1085
|
+
arrayFormat = "pipe" /* pipe */;
|
|
1086
|
+
}
|
|
1104
1087
|
}
|
|
1105
1088
|
}
|
|
1106
|
-
|
|
1089
|
+
if ("x-qs-allow-dots" in parameter) {
|
|
1090
|
+
allowDots = Boolean(parameter["x-qs-allow-dots"]);
|
|
1091
|
+
}
|
|
1092
|
+
if ("x-qs-indices" in parameter) {
|
|
1093
|
+
indices = Boolean(parameter["x-qs-indices"]);
|
|
1094
|
+
}
|
|
1095
|
+
if (arrayFormat || allowDots !== void 0 || indices !== void 0) {
|
|
1096
|
+
return {
|
|
1097
|
+
...arrayFormat ? { arrayFormat } : {},
|
|
1098
|
+
...allowDots !== void 0 ? { allowDots } : {},
|
|
1099
|
+
...indices !== void 0 ? { indices } : {}
|
|
1100
|
+
};
|
|
1101
|
+
}
|
|
1102
|
+
return void 0;
|
|
1107
1103
|
}
|
|
1108
1104
|
// render: "if (args && 'Authorization' in args) req.header('Authorization', args['Authorization'])"
|
|
1109
1105
|
renderRequestHeaders() {
|
|
@@ -1419,8 +1415,7 @@ var NestjsClientRenderer = class {
|
|
|
1419
1415
|
const moduleName = changeCase2.pascalCase(this.document.module.name);
|
|
1420
1416
|
const $dependencies = this.renderDependencies();
|
|
1421
1417
|
const $operations = this.document.operations.map((operation) => OperationDefinitionTransformer.toNestjsMethod(operation, {
|
|
1422
|
-
esm: this.options.esm
|
|
1423
|
-
qs: this.options.qs
|
|
1418
|
+
esm: this.options.esm
|
|
1424
1419
|
})).join("\n\n");
|
|
1425
1420
|
return [
|
|
1426
1421
|
"/* @anchor:file:start */",
|
|
@@ -1807,7 +1802,6 @@ var MicroFunctionGenerator = class _MicroFunctionGenerator {
|
|
|
1807
1802
|
id: _MicroFunctionGenerator.getOperationDefinitionArtifactId(operationDefinition),
|
|
1808
1803
|
filepath,
|
|
1809
1804
|
content: OperationDefinitionTransformer.toMicroFunction(operationDefinition, {
|
|
1810
|
-
qs: rc.qs,
|
|
1811
1805
|
esm: rc.esm,
|
|
1812
1806
|
getOperationDefinitionDeclarationFilepath(operationDefinition2) {
|
|
1813
1807
|
const relativePath = path7.relative(
|
|
@@ -1969,7 +1963,6 @@ var NestjsModuleGenerator = class _NestjsModuleGenerator {
|
|
|
1969
1963
|
filepath,
|
|
1970
1964
|
content: ApiDocumentTransformer.toNestjsClient(document, {
|
|
1971
1965
|
esm: rc.esm,
|
|
1972
|
-
qs: rc.qs,
|
|
1973
1966
|
getOperationDefinitionDeclarationFilepath(operationDefinition) {
|
|
1974
1967
|
const relativePath = path8.relative(
|
|
1975
1968
|
dirpath,
|
|
@@ -2119,7 +2112,7 @@ var DownloadLocalFilePlugin = class _DownloadLocalFilePlugin {
|
|
|
2119
2112
|
};
|
|
2120
2113
|
|
|
2121
2114
|
// src/plugins/shaking/shaking.plugin.ts
|
|
2122
|
-
import { openapiShakingSync
|
|
2115
|
+
import { openapiShakingSync } from "@opendoc/openapi-shaking";
|
|
2123
2116
|
var ShakingPlugin = class _ShakingPlugin {
|
|
2124
2117
|
apply(compiler) {
|
|
2125
2118
|
compiler.hooks.beforeCompile.tap(_ShakingPlugin.name, (task) => {
|
|
@@ -2129,6 +2122,7 @@ var ShakingPlugin = class _ShakingPlugin {
|
|
|
2129
2122
|
});
|
|
2130
2123
|
}
|
|
2131
2124
|
shaking(compiler, document) {
|
|
2125
|
+
const rc = compiler.context.rc;
|
|
2132
2126
|
const matcher = compiler.context.matcher;
|
|
2133
2127
|
const isAccepted = (pathname, method, operation) => {
|
|
2134
2128
|
if (!SupportedMethods.includes(method)) return false;
|
|
@@ -2140,10 +2134,10 @@ var ShakingPlugin = class _ShakingPlugin {
|
|
|
2140
2134
|
document
|
|
2141
2135
|
}));
|
|
2142
2136
|
};
|
|
2143
|
-
const sharkedSwagger =
|
|
2137
|
+
const sharkedSwagger = openapiShakingSync(
|
|
2144
2138
|
document.specification,
|
|
2145
2139
|
isAccepted,
|
|
2146
|
-
{ tolerant:
|
|
2140
|
+
{ tolerant: rc.tolerant }
|
|
2147
2141
|
);
|
|
2148
2142
|
return new ApiDocumentV3_1(
|
|
2149
2143
|
sharkedSwagger,
|
|
@@ -2237,6 +2231,11 @@ var InitializePlugin = class _InitializePlugin {
|
|
|
2237
2231
|
} else if (rc.mode === "nestjs-module") {
|
|
2238
2232
|
new GenerateNestjsModulePlugin().apply(compiler);
|
|
2239
2233
|
}
|
|
2234
|
+
if (rc.plugins && rc.plugins.length) {
|
|
2235
|
+
for (const plugin of rc.plugins) {
|
|
2236
|
+
plugin.apply(compiler);
|
|
2237
|
+
}
|
|
2238
|
+
}
|
|
2240
2239
|
});
|
|
2241
2240
|
if (this.options.includes && this.options.includes.length) {
|
|
2242
2241
|
const modulesIncludes = this.options.includes;
|
|
@@ -2261,6 +2260,82 @@ var InitializePlugin = class _InitializePlugin {
|
|
|
2261
2260
|
}
|
|
2262
2261
|
}
|
|
2263
2262
|
};
|
|
2263
|
+
|
|
2264
|
+
// src/plugins/overwrite-operation-id/overwrite-operation-id.plugin.ts
|
|
2265
|
+
var OverwriteOperationIdPlugin = class _OverwriteOperationIdPlugin {
|
|
2266
|
+
constructor(factory) {
|
|
2267
|
+
this.factory = factory;
|
|
2268
|
+
}
|
|
2269
|
+
apply(compiler) {
|
|
2270
|
+
compiler.hooks.afterDownload.tap(_OverwriteOperationIdPlugin.name, () => {
|
|
2271
|
+
const documents = compiler.context.documents;
|
|
2272
|
+
const factory = this.factory;
|
|
2273
|
+
compiler.context.documents = documents.map((document) => {
|
|
2274
|
+
const spec = OpenapiUtils.mapOperation(
|
|
2275
|
+
document.specification,
|
|
2276
|
+
(method, pathname, operation) => {
|
|
2277
|
+
const operationId = factory({ method, pathname, operation, module: document.module });
|
|
2278
|
+
if (typeof operationId === "string") {
|
|
2279
|
+
if (operationId.length === 0) {
|
|
2280
|
+
throw new Exception(document.module, `The generated operationId for [${method.toUpperCase()} ${pathname}] is an empty string.`);
|
|
2281
|
+
}
|
|
2282
|
+
operation.operationId = operationId;
|
|
2283
|
+
return operation;
|
|
2284
|
+
}
|
|
2285
|
+
return operation;
|
|
2286
|
+
}
|
|
2287
|
+
);
|
|
2288
|
+
return new ApiDocumentV3_1(spec, document.module);
|
|
2289
|
+
});
|
|
2290
|
+
});
|
|
2291
|
+
}
|
|
2292
|
+
};
|
|
2293
|
+
|
|
2294
|
+
// src/plugins/overwrite-query-options/overwrite-query-options.plugin.ts
|
|
2295
|
+
var QsArrayFormatUnion = Object.values(QsArrayFormat);
|
|
2296
|
+
var OverwriteQueryOptionsPlugin = class _OverwriteQueryOptionsPlugin {
|
|
2297
|
+
constructor(factory) {
|
|
2298
|
+
this.factory = factory;
|
|
2299
|
+
}
|
|
2300
|
+
apply(compiler) {
|
|
2301
|
+
compiler.hooks.afterDownload.tap(_OverwriteQueryOptionsPlugin.name, (task) => {
|
|
2302
|
+
const documents = compiler.context.documents;
|
|
2303
|
+
const factory = this.factory;
|
|
2304
|
+
compiler.context.documents = documents.map((document) => {
|
|
2305
|
+
const specification = OpenapiUtils.mapParameter(
|
|
2306
|
+
document.specification,
|
|
2307
|
+
(method, pathname, operation, parameter) => {
|
|
2308
|
+
const qsOptions = typeof factory === "function" ? factory({ parameter, operation, pathname, method, module: document.module }) : factory;
|
|
2309
|
+
if (!qsOptions) return parameter;
|
|
2310
|
+
if (qsOptions.arrayFormat) {
|
|
2311
|
+
if (!QsArrayFormatUnion.includes(qsOptions.arrayFormat)) {
|
|
2312
|
+
throw new Exception(document.module, `The 'arrayFormat' value '${qsOptions.arrayFormat}' for the query parameter '${parameter.name}' in [${method.toUpperCase()} ${pathname}] is invalid.`);
|
|
2313
|
+
}
|
|
2314
|
+
parameter["x-qs-array-format"] = qsOptions.arrayFormat;
|
|
2315
|
+
}
|
|
2316
|
+
if (qsOptions.allowDots !== void 0) {
|
|
2317
|
+
if (typeof qsOptions.allowDots !== "boolean") {
|
|
2318
|
+
throw new Exception(document.module, `The 'allowDots' value for the query parameter '${parameter.name}' in [${method.toUpperCase()} ${pathname}] must be a boolean.`);
|
|
2319
|
+
}
|
|
2320
|
+
parameter["x-qs-allow-dots"] = Boolean(qsOptions.allowDots);
|
|
2321
|
+
}
|
|
2322
|
+
if (qsOptions.indices !== void 0) {
|
|
2323
|
+
if (typeof qsOptions.indices !== "boolean") {
|
|
2324
|
+
throw new Exception(document.module, `The 'indices' value for the query parameter '${parameter.name}' in [${method.toUpperCase()} ${pathname}] must be a boolean.`);
|
|
2325
|
+
}
|
|
2326
|
+
parameter["x-qs-indices"] = Boolean(qsOptions.indices);
|
|
2327
|
+
}
|
|
2328
|
+
return parameter;
|
|
2329
|
+
}
|
|
2330
|
+
);
|
|
2331
|
+
return new ApiDocumentV3_1(
|
|
2332
|
+
specification,
|
|
2333
|
+
document.module
|
|
2334
|
+
);
|
|
2335
|
+
});
|
|
2336
|
+
});
|
|
2337
|
+
}
|
|
2338
|
+
};
|
|
2264
2339
|
export {
|
|
2265
2340
|
BodyFallbackPlugin,
|
|
2266
2341
|
ChineseToPinyinPlugin,
|
|
@@ -2278,6 +2353,8 @@ export {
|
|
|
2278
2353
|
NestjsModuleGenerator,
|
|
2279
2354
|
OPERATION_GENERATOR,
|
|
2280
2355
|
OperationDeclarationGenerator,
|
|
2356
|
+
OverwriteOperationIdPlugin,
|
|
2357
|
+
OverwriteQueryOptionsPlugin,
|
|
2281
2358
|
PrettierPlugin,
|
|
2282
2359
|
RequestGenerator,
|
|
2283
2360
|
SCHEMA_GENERATOR,
|