@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/index.js
CHANGED
|
@@ -3,29 +3,8 @@ function defineKeqConfig(config) {
|
|
|
3
3
|
return config;
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
// src/types/qs.ts
|
|
7
|
-
import { Type } from "@sinclair/typebox";
|
|
8
|
-
|
|
9
|
-
// src/constants/qs-array-format.ts
|
|
10
|
-
var QsArrayFormat = /* @__PURE__ */ ((QsArrayFormat2) => {
|
|
11
|
-
QsArrayFormat2["brackets"] = "brackets";
|
|
12
|
-
QsArrayFormat2["indices"] = "indices";
|
|
13
|
-
QsArrayFormat2["repeat"] = "repeat";
|
|
14
|
-
QsArrayFormat2["comma"] = "comma";
|
|
15
|
-
QsArrayFormat2["space"] = "space";
|
|
16
|
-
QsArrayFormat2["pipe"] = "pipe";
|
|
17
|
-
return QsArrayFormat2;
|
|
18
|
-
})(QsArrayFormat || {});
|
|
19
|
-
|
|
20
|
-
// src/types/qs.ts
|
|
21
|
-
var Qs = Type.Object({
|
|
22
|
-
indices: Type.Optional(Type.Boolean()),
|
|
23
|
-
arrayFormat: Type.Optional(Type.Enum(QsArrayFormat)),
|
|
24
|
-
allowDots: Type.Optional(Type.Boolean())
|
|
25
|
-
});
|
|
26
|
-
|
|
27
6
|
// src/types/runtime-config.ts
|
|
28
|
-
import { Type
|
|
7
|
+
import { Type } from "@sinclair/typebox";
|
|
29
8
|
|
|
30
9
|
// src/constants/file-naming-style.ts
|
|
31
10
|
var FileNamingStyle = /* @__PURE__ */ ((FileNamingStyle2) => {
|
|
@@ -44,12 +23,12 @@ var FileNamingStyle = /* @__PURE__ */ ((FileNamingStyle2) => {
|
|
|
44
23
|
})(FileNamingStyle || {});
|
|
45
24
|
|
|
46
25
|
// src/types/runtime-config.ts
|
|
47
|
-
var RuntimeConfig =
|
|
48
|
-
mode:
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
26
|
+
var RuntimeConfig = Type.Object({
|
|
27
|
+
mode: Type.Optional(
|
|
28
|
+
Type.Union([
|
|
29
|
+
Type.Literal("micro-function"),
|
|
30
|
+
Type.Literal("nestjs-module"),
|
|
31
|
+
Type.Literal("none")
|
|
53
32
|
], { default: "micro-function" })
|
|
54
33
|
),
|
|
55
34
|
/**
|
|
@@ -58,29 +37,35 @@ var RuntimeConfig = Type2.Object({
|
|
|
58
37
|
* If not specified, the module system will be inferred from the nearest package.json "type" field
|
|
59
38
|
* or defaults to "cjs" if no package.json is found.
|
|
60
39
|
*/
|
|
61
|
-
esm:
|
|
40
|
+
esm: Type.Optional(Type.Boolean({ default: false })),
|
|
62
41
|
/**
|
|
63
42
|
* Output directory for generated files
|
|
64
43
|
*/
|
|
65
|
-
outdir:
|
|
44
|
+
outdir: Type.String({ default: `${process.cwd()}/api` }),
|
|
66
45
|
/**
|
|
67
46
|
* File naming style for generated files
|
|
68
47
|
*/
|
|
69
|
-
fileNamingStyle:
|
|
70
|
-
modules:
|
|
71
|
-
|
|
72
|
-
qs: Type2.Optional(Type2.Union([
|
|
73
|
-
Qs,
|
|
74
|
-
Type2.Function([Type2.Any()], Qs)
|
|
75
|
-
])),
|
|
76
|
-
debug: Type2.Optional(Type2.Boolean({ default: false })),
|
|
48
|
+
fileNamingStyle: Type.Enum(FileNamingStyle, { default: "snakeCase" /* snakeCase */ }),
|
|
49
|
+
modules: Type.Record(Type.String(), Type.String()),
|
|
50
|
+
debug: Type.Optional(Type.Boolean({ default: false })),
|
|
77
51
|
/**
|
|
78
52
|
* Whether to tolerate wrong openapi/swagger structure
|
|
79
53
|
*/
|
|
80
|
-
tolerant:
|
|
81
|
-
plugins:
|
|
54
|
+
tolerant: Type.Optional(Type.Boolean({ default: false })),
|
|
55
|
+
plugins: Type.Optional(Type.Array(Type.Any(), { default: [] }))
|
|
82
56
|
});
|
|
83
57
|
|
|
58
|
+
// src/constants/qs-array-format.ts
|
|
59
|
+
var QsArrayFormat = /* @__PURE__ */ ((QsArrayFormat2) => {
|
|
60
|
+
QsArrayFormat2["brackets"] = "brackets";
|
|
61
|
+
QsArrayFormat2["indices"] = "indices";
|
|
62
|
+
QsArrayFormat2["repeat"] = "repeat";
|
|
63
|
+
QsArrayFormat2["comma"] = "comma";
|
|
64
|
+
QsArrayFormat2["space"] = "space";
|
|
65
|
+
QsArrayFormat2["pipe"] = "pipe";
|
|
66
|
+
return QsArrayFormat2;
|
|
67
|
+
})(QsArrayFormat || {});
|
|
68
|
+
|
|
84
69
|
// src/constants/supported-methods.ts
|
|
85
70
|
var SupportedMethods = [
|
|
86
71
|
"get",
|
|
@@ -268,20 +253,13 @@ function main(compiler, options) {
|
|
|
268
253
|
await fs3.ensureDir(".keq");
|
|
269
254
|
rc.debug = true;
|
|
270
255
|
}
|
|
271
|
-
|
|
272
|
-
rc.tolerant = true;
|
|
273
|
-
}
|
|
256
|
+
rc.tolerant = Boolean(rc.tolerant);
|
|
274
257
|
const packageJsonInfo = findNearestPackageJson();
|
|
275
258
|
if (packageJsonInfo) {
|
|
276
259
|
const moduleSystem = getProjectModuleSystem(packageJsonInfo);
|
|
277
260
|
rc.esm = moduleSystem === "esm";
|
|
278
261
|
}
|
|
279
262
|
context.rc = rc;
|
|
280
|
-
if (rc.plugins && rc.plugins.length) {
|
|
281
|
-
for (const plugin of rc.plugins) {
|
|
282
|
-
plugin.apply(compiler);
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
263
|
let matcher = new IgnoreMatcher([]);
|
|
286
264
|
if (result.filepath) {
|
|
287
265
|
const ignoreFilepath = path2.resolve(path2.dirname(result.filepath), ".keqignore");
|
|
@@ -330,12 +308,6 @@ import { validate } from "@scalar/openapi-parser";
|
|
|
330
308
|
// src/models/artifact.ts
|
|
331
309
|
import * as path3 from "path";
|
|
332
310
|
|
|
333
|
-
// src/models/utils/to-comment.ts
|
|
334
|
-
function toComment(msg) {
|
|
335
|
-
if (!msg) return "";
|
|
336
|
-
return msg.split("\n").map((str) => `// ${str}`).join("\n");
|
|
337
|
-
}
|
|
338
|
-
|
|
339
311
|
// src/models/anchor.ts
|
|
340
312
|
var AnchorBlock = class {
|
|
341
313
|
constructor(artifact) {
|
|
@@ -414,7 +386,6 @@ var HeaderComment = [
|
|
|
414
386
|
var Artifact = class {
|
|
415
387
|
id;
|
|
416
388
|
filepath;
|
|
417
|
-
warns = [];
|
|
418
389
|
content;
|
|
419
390
|
extensionName;
|
|
420
391
|
anchor = new Anchor(this);
|
|
@@ -427,20 +398,8 @@ var Artifact = class {
|
|
|
427
398
|
get dirname() {
|
|
428
399
|
return path3.dirname(this.filepath);
|
|
429
400
|
}
|
|
430
|
-
addWarn(message) {
|
|
431
|
-
this.warns.push(message);
|
|
432
|
-
}
|
|
433
401
|
renderer() {
|
|
434
|
-
|
|
435
|
-
if (this.warns.length) {
|
|
436
|
-
$warns = toComment([
|
|
437
|
-
"!!! Here is some Problems !!!",
|
|
438
|
-
"",
|
|
439
|
-
this.warns
|
|
440
|
-
].join("\n"));
|
|
441
|
-
$warns += "\n\n";
|
|
442
|
-
}
|
|
443
|
-
return `${HeaderComment}${$warns}${this.content}`;
|
|
402
|
+
return `${HeaderComment}${this.content}`;
|
|
444
403
|
}
|
|
445
404
|
};
|
|
446
405
|
|
|
@@ -639,7 +598,6 @@ var logger = {
|
|
|
639
598
|
};
|
|
640
599
|
|
|
641
600
|
// src/models/api-document_v3_1.ts
|
|
642
|
-
import { openapiShakingSync } from "@opendoc/openapi-shaking";
|
|
643
601
|
var ApiDocumentV3_1 = class _ApiDocumentV3_1 {
|
|
644
602
|
module;
|
|
645
603
|
specification;
|
|
@@ -682,31 +640,6 @@ var ApiDocumentV3_1 = class _ApiDocumentV3_1 {
|
|
|
682
640
|
}
|
|
683
641
|
return false;
|
|
684
642
|
}
|
|
685
|
-
sharking(filter2) {
|
|
686
|
-
const isAccepted = (pathname, method, operation) => {
|
|
687
|
-
if (!SupportedMethods.includes(method)) return false;
|
|
688
|
-
const operationDefinition = new OperationDefinition({
|
|
689
|
-
method,
|
|
690
|
-
pathname,
|
|
691
|
-
operation,
|
|
692
|
-
module: this.module,
|
|
693
|
-
document: this
|
|
694
|
-
});
|
|
695
|
-
return filter2(operationDefinition);
|
|
696
|
-
};
|
|
697
|
-
const sharkedSwagger = openapiShakingSync(
|
|
698
|
-
this.specification,
|
|
699
|
-
isAccepted,
|
|
700
|
-
{ tolerant: true }
|
|
701
|
-
);
|
|
702
|
-
return new _ApiDocumentV3_1(
|
|
703
|
-
sharkedSwagger,
|
|
704
|
-
new ModuleDefinition(
|
|
705
|
-
this.module.name,
|
|
706
|
-
`file://${this.module.name}.v3_1.sharked.json`
|
|
707
|
-
)
|
|
708
|
-
);
|
|
709
|
-
}
|
|
710
643
|
static unknown() {
|
|
711
644
|
return new _ApiDocumentV3_1({}, ModuleDefinition.unknown());
|
|
712
645
|
}
|
|
@@ -844,25 +777,6 @@ function dereferenceOperation(swagger) {
|
|
|
844
777
|
return removeUndefinedRef(shadow);
|
|
845
778
|
}
|
|
846
779
|
|
|
847
|
-
// src/utils/openapi-utils/update-operation-id.ts
|
|
848
|
-
import * as R9 from "ramda";
|
|
849
|
-
function updateOperationId(swagger, fn) {
|
|
850
|
-
const shadow = R9.clone(swagger);
|
|
851
|
-
for (const [pathname, pathItem] of Object.entries(shadow.paths || {})) {
|
|
852
|
-
for (const m in pathItem) {
|
|
853
|
-
const method = m.toLowerCase();
|
|
854
|
-
if (!SupportedMethods.includes(method)) continue;
|
|
855
|
-
if (typeof pathItem[m] !== "object" || Array.isArray(pathItem[m]) || pathItem[m] === null) continue;
|
|
856
|
-
const operation = pathItem[m];
|
|
857
|
-
const operationId = fn(method, pathname, operation);
|
|
858
|
-
if (typeof operationId === "string" && operationId.length > 0) {
|
|
859
|
-
operation.operationId = operationId;
|
|
860
|
-
}
|
|
861
|
-
}
|
|
862
|
-
}
|
|
863
|
-
return shadow;
|
|
864
|
-
}
|
|
865
|
-
|
|
866
780
|
// src/utils/json-schema-utils/is-array.ts
|
|
867
781
|
function isArray(schema) {
|
|
868
782
|
return schema.type === "array";
|
|
@@ -918,6 +832,31 @@ function To3_1(openapi) {
|
|
|
918
832
|
return specification;
|
|
919
833
|
}
|
|
920
834
|
|
|
835
|
+
// src/utils/openapi-utils/map-operation.ts
|
|
836
|
+
import * as R9 from "ramda";
|
|
837
|
+
function mapOperation(specification, mapper) {
|
|
838
|
+
const shadow = R9.clone(specification);
|
|
839
|
+
for (const [pathname, pathItem] of Object.entries(shadow.paths || {})) {
|
|
840
|
+
for (const m in pathItem) {
|
|
841
|
+
const method = m.toLowerCase();
|
|
842
|
+
if (!SupportedMethods.includes(method)) continue;
|
|
843
|
+
if (typeof pathItem[m] !== "object" || Array.isArray(pathItem[m]) || pathItem[m] === null) continue;
|
|
844
|
+
const operation = pathItem[m];
|
|
845
|
+
pathItem[m] = mapper(method, pathname, operation);
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
return shadow;
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
// src/utils/openapi-utils/map-parameter.ts
|
|
852
|
+
function mapParameter(specification, mapper) {
|
|
853
|
+
return mapOperation(specification, (method, pathname, operation) => {
|
|
854
|
+
if (!operation.parameters) return operation;
|
|
855
|
+
operation.parameters = operation.parameters.map((parameter) => mapper(method, pathname, operation, parameter));
|
|
856
|
+
return operation;
|
|
857
|
+
});
|
|
858
|
+
}
|
|
859
|
+
|
|
921
860
|
// src/utils/openapi-utils/index.ts
|
|
922
861
|
var OpenapiUtils = class {
|
|
923
862
|
static isRefDefined = isRefDefined;
|
|
@@ -925,7 +864,9 @@ var OpenapiUtils = class {
|
|
|
925
864
|
static dereferenceDeep = dereferenceDeep;
|
|
926
865
|
static removeUndefinedRef = removeUndefinedRef;
|
|
927
866
|
static dereferenceOperation = dereferenceOperation;
|
|
928
|
-
static
|
|
867
|
+
static mapOperation = mapOperation;
|
|
868
|
+
static mapParameter = mapParameter;
|
|
869
|
+
// static updateOperationId = updateOperationId
|
|
929
870
|
static to3_1 = To3_1;
|
|
930
871
|
};
|
|
931
872
|
|
|
@@ -952,7 +893,7 @@ function main2(compiler, options) {
|
|
|
952
893
|
if (!content) {
|
|
953
894
|
throw new Exception(moduleDefinition, `Cannot download document from ${moduleDefinition.address}`);
|
|
954
895
|
}
|
|
955
|
-
|
|
896
|
+
const spec = JSON.parse(content);
|
|
956
897
|
const { valid, errors } = await validate(spec);
|
|
957
898
|
if (!valid) {
|
|
958
899
|
const message = `${moduleDefinition.name} module openapi/swagger file does not conform to the openapi specifications or have grammatical errors, which may cause unexpected errors:
|
|
@@ -960,14 +901,6 @@ ${errors?.map((e) => ` - ${e.message}`).join("\n")}`;
|
|
|
960
901
|
task2.output = message;
|
|
961
902
|
}
|
|
962
903
|
OpenapiUtils.dereferenceOperation(spec);
|
|
963
|
-
const rc2 = context.rc;
|
|
964
|
-
if (rc2?.operationIdFactory) {
|
|
965
|
-
const operationIdFactory = rc2.operationIdFactory;
|
|
966
|
-
spec = OpenapiUtils.updateOperationId(
|
|
967
|
-
spec,
|
|
968
|
-
(method, pathname, operation) => operationIdFactory({ method, pathname, operation, module: moduleDefinition })
|
|
969
|
-
);
|
|
970
|
-
}
|
|
971
904
|
const document = new ApiDocumentV3_1(
|
|
972
905
|
spec,
|
|
973
906
|
moduleDefinition
|
|
@@ -1211,7 +1144,7 @@ function perfectErrorMessage() {
|
|
|
1211
1144
|
// src/plugins/eslint/index.ts
|
|
1212
1145
|
import { ESLint } from "eslint";
|
|
1213
1146
|
|
|
1214
|
-
// src/plugins/prettier/
|
|
1147
|
+
// src/plugins/prettier/prettier.plugin.ts
|
|
1215
1148
|
import { exec } from "child_process";
|
|
1216
1149
|
import { promisify } from "util";
|
|
1217
1150
|
var execAsync = promisify(exec);
|
|
@@ -1493,7 +1426,12 @@ var DeclarationRenderer2 = class {
|
|
|
1493
1426
|
}
|
|
1494
1427
|
const $responses = Object.entries(operation.responses).map(([statusCode, response]) => {
|
|
1495
1428
|
if (!JsonSchemaUtils.isRef(response)) {
|
|
1496
|
-
const $value = Object.
|
|
1429
|
+
const $value = Object.entries(response.content || {}).map(([mediaType, mediaTypeObject]) => [mediaType, mediaTypeObject.schema]).map(([mediaType, schema]) => {
|
|
1430
|
+
if (mediaType.includes("text/event-stream")) return "ReadableStream<ServerSentEvent>";
|
|
1431
|
+
if (mediaType.includes("multipart/form-data")) return "FormData";
|
|
1432
|
+
if (!schema) return "unknown";
|
|
1433
|
+
return JsonSchemaTransformer.toDeclaration(schema, options);
|
|
1434
|
+
}).join(" | ");
|
|
1497
1435
|
return indent(2, `${statusCode}: ${$value || "void"}`);
|
|
1498
1436
|
}
|
|
1499
1437
|
}).join("\n");
|
|
@@ -1575,7 +1513,7 @@ var DeclarationRenderer2 = class {
|
|
|
1575
1513
|
return `import type { ${schemaName} as ${alias(schemaName)} } from "${filepath}"`;
|
|
1576
1514
|
}).map((str) => str.replace(/ from "(\.\.?\/.+?)(\.ts|\.mts|\.cts|\.js|\.cjs|\.mjs)?"/, this.options.esm ? ' from "$1.js"' : ' from "$1"'));
|
|
1577
1515
|
return [
|
|
1578
|
-
'import type { KeqOperation, KeqPathParameterInit, KeqQueryInit } from "keq"',
|
|
1516
|
+
'import type { KeqOperation, KeqPathParameterInit, KeqQueryInit, ServerSentEvent } from "keq"',
|
|
1579
1517
|
...$schemaDefinitions
|
|
1580
1518
|
].join("\n");
|
|
1581
1519
|
}
|
|
@@ -1641,7 +1579,7 @@ var DeclarationRenderer2 = class {
|
|
|
1641
1579
|
// src/transformers/operation-definition/micro-function.renderer.ts
|
|
1642
1580
|
import * as R17 from "ramda";
|
|
1643
1581
|
|
|
1644
|
-
// src/transformers/operation-definition/typescript-
|
|
1582
|
+
// src/transformers/operation-definition/typescript-snippet.ts
|
|
1645
1583
|
import * as R16 from "ramda";
|
|
1646
1584
|
var OperationDefinitionSnippet = class {
|
|
1647
1585
|
constructor(operationDefinition, options) {
|
|
@@ -1651,27 +1589,42 @@ var OperationDefinitionSnippet = class {
|
|
|
1651
1589
|
}
|
|
1652
1590
|
typeName;
|
|
1653
1591
|
getQsParameters(parameter) {
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
return this.options.qs;
|
|
1658
|
-
}
|
|
1592
|
+
let arrayFormat;
|
|
1593
|
+
let allowDots;
|
|
1594
|
+
let indices;
|
|
1659
1595
|
const style = parameter.style || "form";
|
|
1660
1596
|
const explode = parameter.explode ?? true;
|
|
1661
|
-
if (
|
|
1662
|
-
|
|
1663
|
-
} else if (explode) {
|
|
1664
|
-
return { arrayFormat: "repeat" };
|
|
1597
|
+
if ("x-qs-array-format" in parameter) {
|
|
1598
|
+
arrayFormat = parameter["x-qs-array-format"];
|
|
1665
1599
|
} else {
|
|
1666
|
-
if (style === "
|
|
1667
|
-
|
|
1668
|
-
} else if (
|
|
1669
|
-
|
|
1670
|
-
} else
|
|
1671
|
-
|
|
1600
|
+
if (style === "deepObject") {
|
|
1601
|
+
arrayFormat = "brackets" /* brackets */;
|
|
1602
|
+
} else if (explode) {
|
|
1603
|
+
arrayFormat = "repeat" /* repeat */;
|
|
1604
|
+
} else {
|
|
1605
|
+
if (style === "form") {
|
|
1606
|
+
arrayFormat = "comma" /* comma */;
|
|
1607
|
+
} else if (style === "spaceDelimited") {
|
|
1608
|
+
arrayFormat = "space" /* space */;
|
|
1609
|
+
} else if (style === "pipeDelimited") {
|
|
1610
|
+
arrayFormat = "pipe" /* pipe */;
|
|
1611
|
+
}
|
|
1672
1612
|
}
|
|
1673
1613
|
}
|
|
1674
|
-
|
|
1614
|
+
if ("x-qs-allow-dots" in parameter) {
|
|
1615
|
+
allowDots = Boolean(parameter["x-qs-allow-dots"]);
|
|
1616
|
+
}
|
|
1617
|
+
if ("x-qs-indices" in parameter) {
|
|
1618
|
+
indices = Boolean(parameter["x-qs-indices"]);
|
|
1619
|
+
}
|
|
1620
|
+
if (arrayFormat || allowDots !== void 0 || indices !== void 0) {
|
|
1621
|
+
return {
|
|
1622
|
+
...arrayFormat ? { arrayFormat } : {},
|
|
1623
|
+
...allowDots !== void 0 ? { allowDots } : {},
|
|
1624
|
+
...indices !== void 0 ? { indices } : {}
|
|
1625
|
+
};
|
|
1626
|
+
}
|
|
1627
|
+
return void 0;
|
|
1675
1628
|
}
|
|
1676
1629
|
// render: "if (args && 'Authorization' in args) req.header('Authorization', args['Authorization'])"
|
|
1677
1630
|
renderRequestHeaders() {
|
|
@@ -1987,8 +1940,7 @@ var NestjsClientRenderer = class {
|
|
|
1987
1940
|
const moduleName = changeCase2.pascalCase(this.document.module.name);
|
|
1988
1941
|
const $dependencies = this.renderDependencies();
|
|
1989
1942
|
const $operations = this.document.operations.map((operation) => OperationDefinitionTransformer.toNestjsMethod(operation, {
|
|
1990
|
-
esm: this.options.esm
|
|
1991
|
-
qs: this.options.qs
|
|
1943
|
+
esm: this.options.esm
|
|
1992
1944
|
})).join("\n\n");
|
|
1993
1945
|
return [
|
|
1994
1946
|
"/* @anchor:file:start */",
|
|
@@ -2375,7 +2327,6 @@ var MicroFunctionGenerator = class _MicroFunctionGenerator {
|
|
|
2375
2327
|
id: _MicroFunctionGenerator.getOperationDefinitionArtifactId(operationDefinition),
|
|
2376
2328
|
filepath,
|
|
2377
2329
|
content: OperationDefinitionTransformer.toMicroFunction(operationDefinition, {
|
|
2378
|
-
qs: rc.qs,
|
|
2379
2330
|
esm: rc.esm,
|
|
2380
2331
|
getOperationDefinitionDeclarationFilepath(operationDefinition2) {
|
|
2381
2332
|
const relativePath = path10.relative(
|
|
@@ -2500,7 +2451,6 @@ var NestjsModuleGenerator = class _NestjsModuleGenerator {
|
|
|
2500
2451
|
filepath,
|
|
2501
2452
|
content: ApiDocumentTransformer.toNestjsClient(document, {
|
|
2502
2453
|
esm: rc.esm,
|
|
2503
|
-
qs: rc.qs,
|
|
2504
2454
|
getOperationDefinitionDeclarationFilepath(operationDefinition) {
|
|
2505
2455
|
const relativePath = path11.relative(
|
|
2506
2456
|
dirpath,
|
|
@@ -2637,7 +2587,7 @@ var DownloadLocalFilePlugin = class _DownloadLocalFilePlugin {
|
|
|
2637
2587
|
};
|
|
2638
2588
|
|
|
2639
2589
|
// src/plugins/shaking/shaking.plugin.ts
|
|
2640
|
-
import { openapiShakingSync
|
|
2590
|
+
import { openapiShakingSync } from "@opendoc/openapi-shaking";
|
|
2641
2591
|
var ShakingPlugin = class _ShakingPlugin {
|
|
2642
2592
|
apply(compiler) {
|
|
2643
2593
|
compiler.hooks.beforeCompile.tap(_ShakingPlugin.name, (task) => {
|
|
@@ -2647,6 +2597,7 @@ var ShakingPlugin = class _ShakingPlugin {
|
|
|
2647
2597
|
});
|
|
2648
2598
|
}
|
|
2649
2599
|
shaking(compiler, document) {
|
|
2600
|
+
const rc = compiler.context.rc;
|
|
2650
2601
|
const matcher = compiler.context.matcher;
|
|
2651
2602
|
const isAccepted = (pathname, method, operation) => {
|
|
2652
2603
|
if (!SupportedMethods.includes(method)) return false;
|
|
@@ -2658,10 +2609,10 @@ var ShakingPlugin = class _ShakingPlugin {
|
|
|
2658
2609
|
document
|
|
2659
2610
|
}));
|
|
2660
2611
|
};
|
|
2661
|
-
const sharkedSwagger =
|
|
2612
|
+
const sharkedSwagger = openapiShakingSync(
|
|
2662
2613
|
document.specification,
|
|
2663
2614
|
isAccepted,
|
|
2664
|
-
{ tolerant:
|
|
2615
|
+
{ tolerant: rc.tolerant }
|
|
2665
2616
|
);
|
|
2666
2617
|
return new ApiDocumentV3_1(
|
|
2667
2618
|
sharkedSwagger,
|
|
@@ -2755,6 +2706,11 @@ var InitializePlugin = class _InitializePlugin {
|
|
|
2755
2706
|
} else if (rc.mode === "nestjs-module") {
|
|
2756
2707
|
new GenerateNestjsModulePlugin().apply(compiler);
|
|
2757
2708
|
}
|
|
2709
|
+
if (rc.plugins && rc.plugins.length) {
|
|
2710
|
+
for (const plugin of rc.plugins) {
|
|
2711
|
+
plugin.apply(compiler);
|
|
2712
|
+
}
|
|
2713
|
+
}
|
|
2758
2714
|
});
|
|
2759
2715
|
if (this.options.includes && this.options.includes.length) {
|
|
2760
2716
|
const modulesIncludes = this.options.includes;
|
|
@@ -2780,6 +2736,9 @@ var InitializePlugin = class _InitializePlugin {
|
|
|
2780
2736
|
}
|
|
2781
2737
|
};
|
|
2782
2738
|
|
|
2739
|
+
// src/plugins/overwrite-query-options/overwrite-query-options.plugin.ts
|
|
2740
|
+
var QsArrayFormatUnion = Object.values(QsArrayFormat);
|
|
2741
|
+
|
|
2783
2742
|
// src/compiler/compiler.ts
|
|
2784
2743
|
var Compiler = class {
|
|
2785
2744
|
constructor(options) {
|