@keq-request/cli 5.0.0-alpha.23 → 5.0.0-alpha.25
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 +23 -0
- package/dist/cli.cjs +112 -151
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +112 -151
- 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 +110 -151
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +110 -151
- 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 +173 -94
- package/dist/plugins.cjs.map +1 -1
- package/dist/plugins.js +171 -94
- 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/cli.js
CHANGED
|
@@ -124,29 +124,8 @@ var IgnoreMatcher = class _IgnoreMatcher {
|
|
|
124
124
|
}
|
|
125
125
|
};
|
|
126
126
|
|
|
127
|
-
// src/types/qs.ts
|
|
128
|
-
import { Type } from "@sinclair/typebox";
|
|
129
|
-
|
|
130
|
-
// src/constants/qs-array-format.ts
|
|
131
|
-
var QsArrayFormat = /* @__PURE__ */ ((QsArrayFormat2) => {
|
|
132
|
-
QsArrayFormat2["brackets"] = "brackets";
|
|
133
|
-
QsArrayFormat2["indices"] = "indices";
|
|
134
|
-
QsArrayFormat2["repeat"] = "repeat";
|
|
135
|
-
QsArrayFormat2["comma"] = "comma";
|
|
136
|
-
QsArrayFormat2["space"] = "space";
|
|
137
|
-
QsArrayFormat2["pipe"] = "pipe";
|
|
138
|
-
return QsArrayFormat2;
|
|
139
|
-
})(QsArrayFormat || {});
|
|
140
|
-
|
|
141
|
-
// src/types/qs.ts
|
|
142
|
-
var Qs = Type.Object({
|
|
143
|
-
indices: Type.Optional(Type.Boolean()),
|
|
144
|
-
arrayFormat: Type.Optional(Type.Enum(QsArrayFormat)),
|
|
145
|
-
allowDots: Type.Optional(Type.Boolean())
|
|
146
|
-
});
|
|
147
|
-
|
|
148
127
|
// src/types/runtime-config.ts
|
|
149
|
-
import { Type
|
|
128
|
+
import { Type } from "@sinclair/typebox";
|
|
150
129
|
|
|
151
130
|
// src/constants/file-naming-style.ts
|
|
152
131
|
var FileNamingStyle = /* @__PURE__ */ ((FileNamingStyle2) => {
|
|
@@ -165,12 +144,12 @@ var FileNamingStyle = /* @__PURE__ */ ((FileNamingStyle2) => {
|
|
|
165
144
|
})(FileNamingStyle || {});
|
|
166
145
|
|
|
167
146
|
// src/types/runtime-config.ts
|
|
168
|
-
var RuntimeConfig =
|
|
169
|
-
mode:
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
147
|
+
var RuntimeConfig = Type.Object({
|
|
148
|
+
mode: Type.Optional(
|
|
149
|
+
Type.Union([
|
|
150
|
+
Type.Literal("micro-function"),
|
|
151
|
+
Type.Literal("nestjs-module"),
|
|
152
|
+
Type.Literal("none")
|
|
174
153
|
], { default: "micro-function" })
|
|
175
154
|
),
|
|
176
155
|
/**
|
|
@@ -179,27 +158,22 @@ var RuntimeConfig = Type2.Object({
|
|
|
179
158
|
* If not specified, the module system will be inferred from the nearest package.json "type" field
|
|
180
159
|
* or defaults to "cjs" if no package.json is found.
|
|
181
160
|
*/
|
|
182
|
-
esm:
|
|
161
|
+
esm: Type.Optional(Type.Boolean({ default: false })),
|
|
183
162
|
/**
|
|
184
163
|
* Output directory for generated files
|
|
185
164
|
*/
|
|
186
|
-
outdir:
|
|
165
|
+
outdir: Type.String({ default: `${process.cwd()}/api` }),
|
|
187
166
|
/**
|
|
188
167
|
* File naming style for generated files
|
|
189
168
|
*/
|
|
190
|
-
fileNamingStyle:
|
|
191
|
-
modules:
|
|
192
|
-
|
|
193
|
-
qs: Type2.Optional(Type2.Union([
|
|
194
|
-
Qs,
|
|
195
|
-
Type2.Function([Type2.Any()], Qs)
|
|
196
|
-
])),
|
|
197
|
-
debug: Type2.Optional(Type2.Boolean({ default: false })),
|
|
169
|
+
fileNamingStyle: Type.Enum(FileNamingStyle, { default: "snakeCase" /* snakeCase */ }),
|
|
170
|
+
modules: Type.Record(Type.String(), Type.String()),
|
|
171
|
+
debug: Type.Optional(Type.Boolean({ default: false })),
|
|
198
172
|
/**
|
|
199
173
|
* Whether to tolerate wrong openapi/swagger structure
|
|
200
174
|
*/
|
|
201
|
-
tolerant:
|
|
202
|
-
plugins:
|
|
175
|
+
tolerant: Type.Optional(Type.Boolean({ default: false })),
|
|
176
|
+
plugins: Type.Optional(Type.Array(Type.Any(), { default: [] }))
|
|
203
177
|
});
|
|
204
178
|
|
|
205
179
|
// src/compiler/tasks/setup/utils/validate-modules.ts
|
|
@@ -277,20 +251,13 @@ function main(compiler, options) {
|
|
|
277
251
|
await fs3.ensureDir(".keq");
|
|
278
252
|
rc.debug = true;
|
|
279
253
|
}
|
|
280
|
-
|
|
281
|
-
rc.tolerant = true;
|
|
282
|
-
}
|
|
254
|
+
rc.tolerant = Boolean(rc.tolerant);
|
|
283
255
|
const packageJsonInfo = findNearestPackageJson();
|
|
284
256
|
if (packageJsonInfo) {
|
|
285
257
|
const moduleSystem = getProjectModuleSystem(packageJsonInfo);
|
|
286
258
|
rc.esm = moduleSystem === "esm";
|
|
287
259
|
}
|
|
288
260
|
context.rc = rc;
|
|
289
|
-
if (rc.plugins && rc.plugins.length) {
|
|
290
|
-
for (const plugin of rc.plugins) {
|
|
291
|
-
plugin.apply(compiler);
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
261
|
let matcher = new IgnoreMatcher([]);
|
|
295
262
|
if (result.filepath) {
|
|
296
263
|
const ignoreFilepath = path2.resolve(path2.dirname(result.filepath), ".keqignore");
|
|
@@ -339,12 +306,6 @@ import { validate } from "@scalar/openapi-parser";
|
|
|
339
306
|
// src/models/artifact.ts
|
|
340
307
|
import * as path3 from "path";
|
|
341
308
|
|
|
342
|
-
// src/models/utils/to-comment.ts
|
|
343
|
-
function toComment(msg) {
|
|
344
|
-
if (!msg) return "";
|
|
345
|
-
return msg.split("\n").map((str) => `// ${str}`).join("\n");
|
|
346
|
-
}
|
|
347
|
-
|
|
348
309
|
// src/models/anchor.ts
|
|
349
310
|
var AnchorBlock = class {
|
|
350
311
|
constructor(artifact) {
|
|
@@ -423,7 +384,6 @@ var HeaderComment = [
|
|
|
423
384
|
var Artifact = class {
|
|
424
385
|
id;
|
|
425
386
|
filepath;
|
|
426
|
-
warns = [];
|
|
427
387
|
content;
|
|
428
388
|
extensionName;
|
|
429
389
|
anchor = new Anchor(this);
|
|
@@ -436,20 +396,8 @@ var Artifact = class {
|
|
|
436
396
|
get dirname() {
|
|
437
397
|
return path3.dirname(this.filepath);
|
|
438
398
|
}
|
|
439
|
-
addWarn(message) {
|
|
440
|
-
this.warns.push(message);
|
|
441
|
-
}
|
|
442
399
|
renderer() {
|
|
443
|
-
|
|
444
|
-
if (this.warns.length) {
|
|
445
|
-
$warns = toComment([
|
|
446
|
-
"!!! Here is some Problems !!!",
|
|
447
|
-
"",
|
|
448
|
-
this.warns
|
|
449
|
-
].join("\n"));
|
|
450
|
-
$warns += "\n\n";
|
|
451
|
-
}
|
|
452
|
-
return `${HeaderComment}${$warns}${this.content}`;
|
|
400
|
+
return `${HeaderComment}${this.content}`;
|
|
453
401
|
}
|
|
454
402
|
};
|
|
455
403
|
|
|
@@ -640,7 +588,6 @@ var OperationDefinition = class {
|
|
|
640
588
|
};
|
|
641
589
|
|
|
642
590
|
// src/models/api-document_v3_1.ts
|
|
643
|
-
import { openapiShakingSync } from "@opendoc/openapi-shaking";
|
|
644
591
|
var ApiDocumentV3_1 = class _ApiDocumentV3_1 {
|
|
645
592
|
module;
|
|
646
593
|
specification;
|
|
@@ -683,31 +630,6 @@ var ApiDocumentV3_1 = class _ApiDocumentV3_1 {
|
|
|
683
630
|
}
|
|
684
631
|
return false;
|
|
685
632
|
}
|
|
686
|
-
sharking(filter2) {
|
|
687
|
-
const isAccepted = (pathname, method, operation) => {
|
|
688
|
-
if (!SupportedMethods.includes(method)) return false;
|
|
689
|
-
const operationDefinition = new OperationDefinition({
|
|
690
|
-
method,
|
|
691
|
-
pathname,
|
|
692
|
-
operation,
|
|
693
|
-
module: this.module,
|
|
694
|
-
document: this
|
|
695
|
-
});
|
|
696
|
-
return filter2(operationDefinition);
|
|
697
|
-
};
|
|
698
|
-
const sharkedSwagger = openapiShakingSync(
|
|
699
|
-
this.specification,
|
|
700
|
-
isAccepted,
|
|
701
|
-
{ tolerant: true }
|
|
702
|
-
);
|
|
703
|
-
return new _ApiDocumentV3_1(
|
|
704
|
-
sharkedSwagger,
|
|
705
|
-
new ModuleDefinition(
|
|
706
|
-
this.module.name,
|
|
707
|
-
`file://${this.module.name}.v3_1.sharked.json`
|
|
708
|
-
)
|
|
709
|
-
);
|
|
710
|
-
}
|
|
711
633
|
static unknown() {
|
|
712
634
|
return new _ApiDocumentV3_1({}, ModuleDefinition.unknown());
|
|
713
635
|
}
|
|
@@ -845,25 +767,6 @@ function dereferenceOperation(swagger) {
|
|
|
845
767
|
return removeUndefinedRef(shadow);
|
|
846
768
|
}
|
|
847
769
|
|
|
848
|
-
// src/utils/openapi-utils/update-operation-id.ts
|
|
849
|
-
import * as R9 from "ramda";
|
|
850
|
-
function updateOperationId(swagger, fn) {
|
|
851
|
-
const shadow = R9.clone(swagger);
|
|
852
|
-
for (const [pathname, pathItem] of Object.entries(shadow.paths || {})) {
|
|
853
|
-
for (const m in pathItem) {
|
|
854
|
-
const method = m.toLowerCase();
|
|
855
|
-
if (!SupportedMethods.includes(method)) continue;
|
|
856
|
-
if (typeof pathItem[m] !== "object" || Array.isArray(pathItem[m]) || pathItem[m] === null) continue;
|
|
857
|
-
const operation = pathItem[m];
|
|
858
|
-
const operationId = fn(method, pathname, operation);
|
|
859
|
-
if (typeof operationId === "string" && operationId.length > 0) {
|
|
860
|
-
operation.operationId = operationId;
|
|
861
|
-
}
|
|
862
|
-
}
|
|
863
|
-
}
|
|
864
|
-
return shadow;
|
|
865
|
-
}
|
|
866
|
-
|
|
867
770
|
// src/utils/json-schema-utils/is-array.ts
|
|
868
771
|
function isArray(schema) {
|
|
869
772
|
return schema.type === "array";
|
|
@@ -919,6 +822,31 @@ function To3_1(openapi) {
|
|
|
919
822
|
return specification;
|
|
920
823
|
}
|
|
921
824
|
|
|
825
|
+
// src/utils/openapi-utils/map-operation.ts
|
|
826
|
+
import * as R9 from "ramda";
|
|
827
|
+
function mapOperation(specification, mapper) {
|
|
828
|
+
const shadow = R9.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
|
+
|
|
922
850
|
// src/utils/openapi-utils/index.ts
|
|
923
851
|
var OpenapiUtils = class {
|
|
924
852
|
static isRefDefined = isRefDefined;
|
|
@@ -926,7 +854,9 @@ var OpenapiUtils = class {
|
|
|
926
854
|
static dereferenceDeep = dereferenceDeep;
|
|
927
855
|
static removeUndefinedRef = removeUndefinedRef;
|
|
928
856
|
static dereferenceOperation = dereferenceOperation;
|
|
929
|
-
static
|
|
857
|
+
static mapOperation = mapOperation;
|
|
858
|
+
static mapParameter = mapParameter;
|
|
859
|
+
// static updateOperationId = updateOperationId
|
|
930
860
|
static to3_1 = To3_1;
|
|
931
861
|
};
|
|
932
862
|
|
|
@@ -953,7 +883,7 @@ function main2(compiler, options) {
|
|
|
953
883
|
if (!content) {
|
|
954
884
|
throw new Exception(moduleDefinition, `Cannot download document from ${moduleDefinition.address}`);
|
|
955
885
|
}
|
|
956
|
-
|
|
886
|
+
const spec = JSON.parse(content);
|
|
957
887
|
const { valid, errors } = await validate(spec);
|
|
958
888
|
if (!valid) {
|
|
959
889
|
const message = `${moduleDefinition.name} module openapi/swagger file does not conform to the openapi specifications or have grammatical errors, which may cause unexpected errors:
|
|
@@ -961,14 +891,6 @@ ${errors?.map((e) => ` - ${e.message}`).join("\n")}`;
|
|
|
961
891
|
task2.output = message;
|
|
962
892
|
}
|
|
963
893
|
OpenapiUtils.dereferenceOperation(spec);
|
|
964
|
-
const rc2 = context.rc;
|
|
965
|
-
if (rc2?.operationIdFactory) {
|
|
966
|
-
const operationIdFactory = rc2.operationIdFactory;
|
|
967
|
-
spec = OpenapiUtils.updateOperationId(
|
|
968
|
-
spec,
|
|
969
|
-
(method, pathname, operation) => operationIdFactory({ method, pathname, operation, module: moduleDefinition })
|
|
970
|
-
);
|
|
971
|
-
}
|
|
972
894
|
const document = new ApiDocumentV3_1(
|
|
973
895
|
spec,
|
|
974
896
|
moduleDefinition
|
|
@@ -1212,7 +1134,7 @@ function perfectErrorMessage() {
|
|
|
1212
1134
|
// src/plugins/eslint/index.ts
|
|
1213
1135
|
import { ESLint } from "eslint";
|
|
1214
1136
|
|
|
1215
|
-
// src/plugins/prettier/
|
|
1137
|
+
// src/plugins/prettier/prettier.plugin.ts
|
|
1216
1138
|
import { exec } from "child_process";
|
|
1217
1139
|
import { promisify } from "util";
|
|
1218
1140
|
var execAsync = promisify(exec);
|
|
@@ -1494,7 +1416,12 @@ var DeclarationRenderer2 = class {
|
|
|
1494
1416
|
}
|
|
1495
1417
|
const $responses = Object.entries(operation.responses).map(([statusCode, response]) => {
|
|
1496
1418
|
if (!JsonSchemaUtils.isRef(response)) {
|
|
1497
|
-
const $value = Object.
|
|
1419
|
+
const $value = Object.entries(response.content || {}).map(([mediaType, mediaTypeObject]) => [mediaType, mediaTypeObject.schema]).map(([mediaType, schema]) => {
|
|
1420
|
+
if (mediaType.includes("text/event-stream")) return "ReadableStream<ServerSentEvent>";
|
|
1421
|
+
if (mediaType.includes("multipart/form-data")) return "FormData";
|
|
1422
|
+
if (!schema) return "unknown";
|
|
1423
|
+
return JsonSchemaTransformer.toDeclaration(schema, options);
|
|
1424
|
+
}).join(" | ");
|
|
1498
1425
|
return indent(2, `${statusCode}: ${$value || "void"}`);
|
|
1499
1426
|
}
|
|
1500
1427
|
}).join("\n");
|
|
@@ -1576,7 +1503,7 @@ var DeclarationRenderer2 = class {
|
|
|
1576
1503
|
return `import type { ${schemaName} as ${alias(schemaName)} } from "${filepath}"`;
|
|
1577
1504
|
}).map((str) => str.replace(/ from "(\.\.?\/.+?)(\.ts|\.mts|\.cts|\.js|\.cjs|\.mjs)?"/, this.options.esm ? ' from "$1.js"' : ' from "$1"'));
|
|
1578
1505
|
return [
|
|
1579
|
-
'import type { KeqOperation, KeqPathParameterInit, KeqQueryInit } from "keq"',
|
|
1506
|
+
'import type { KeqOperation, KeqPathParameterInit, KeqQueryInit, ServerSentEvent } from "keq"',
|
|
1580
1507
|
...$schemaDefinitions
|
|
1581
1508
|
].join("\n");
|
|
1582
1509
|
}
|
|
@@ -1642,8 +1569,21 @@ var DeclarationRenderer2 = class {
|
|
|
1642
1569
|
// src/transformers/operation-definition/micro-function.renderer.ts
|
|
1643
1570
|
import * as R17 from "ramda";
|
|
1644
1571
|
|
|
1645
|
-
// src/transformers/operation-definition/typescript-
|
|
1572
|
+
// src/transformers/operation-definition/typescript-snippet.ts
|
|
1646
1573
|
import * as R16 from "ramda";
|
|
1574
|
+
|
|
1575
|
+
// src/constants/qs-array-format.ts
|
|
1576
|
+
var QsArrayFormat = /* @__PURE__ */ ((QsArrayFormat2) => {
|
|
1577
|
+
QsArrayFormat2["brackets"] = "brackets";
|
|
1578
|
+
QsArrayFormat2["indices"] = "indices";
|
|
1579
|
+
QsArrayFormat2["repeat"] = "repeat";
|
|
1580
|
+
QsArrayFormat2["comma"] = "comma";
|
|
1581
|
+
QsArrayFormat2["space"] = "space";
|
|
1582
|
+
QsArrayFormat2["pipe"] = "pipe";
|
|
1583
|
+
return QsArrayFormat2;
|
|
1584
|
+
})(QsArrayFormat || {});
|
|
1585
|
+
|
|
1586
|
+
// src/transformers/operation-definition/typescript-snippet.ts
|
|
1647
1587
|
var OperationDefinitionSnippet = class {
|
|
1648
1588
|
constructor(operationDefinition, options) {
|
|
1649
1589
|
this.operationDefinition = operationDefinition;
|
|
@@ -1652,27 +1592,42 @@ var OperationDefinitionSnippet = class {
|
|
|
1652
1592
|
}
|
|
1653
1593
|
typeName;
|
|
1654
1594
|
getQsParameters(parameter) {
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
return this.options.qs;
|
|
1659
|
-
}
|
|
1595
|
+
let arrayFormat;
|
|
1596
|
+
let allowDots;
|
|
1597
|
+
let indices;
|
|
1660
1598
|
const style = parameter.style || "form";
|
|
1661
1599
|
const explode = parameter.explode ?? true;
|
|
1662
|
-
if (
|
|
1663
|
-
|
|
1664
|
-
} else if (explode) {
|
|
1665
|
-
return { arrayFormat: "repeat" };
|
|
1600
|
+
if ("x-qs-array-format" in parameter) {
|
|
1601
|
+
arrayFormat = parameter["x-qs-array-format"];
|
|
1666
1602
|
} else {
|
|
1667
|
-
if (style === "
|
|
1668
|
-
|
|
1669
|
-
} else if (
|
|
1670
|
-
|
|
1671
|
-
} else
|
|
1672
|
-
|
|
1603
|
+
if (style === "deepObject") {
|
|
1604
|
+
arrayFormat = "brackets" /* brackets */;
|
|
1605
|
+
} else if (explode) {
|
|
1606
|
+
arrayFormat = "repeat" /* repeat */;
|
|
1607
|
+
} else {
|
|
1608
|
+
if (style === "form") {
|
|
1609
|
+
arrayFormat = "comma" /* comma */;
|
|
1610
|
+
} else if (style === "spaceDelimited") {
|
|
1611
|
+
arrayFormat = "space" /* space */;
|
|
1612
|
+
} else if (style === "pipeDelimited") {
|
|
1613
|
+
arrayFormat = "pipe" /* pipe */;
|
|
1614
|
+
}
|
|
1673
1615
|
}
|
|
1674
1616
|
}
|
|
1675
|
-
|
|
1617
|
+
if ("x-qs-allow-dots" in parameter) {
|
|
1618
|
+
allowDots = Boolean(parameter["x-qs-allow-dots"]);
|
|
1619
|
+
}
|
|
1620
|
+
if ("x-qs-indices" in parameter) {
|
|
1621
|
+
indices = Boolean(parameter["x-qs-indices"]);
|
|
1622
|
+
}
|
|
1623
|
+
if (arrayFormat || allowDots !== void 0 || indices !== void 0) {
|
|
1624
|
+
return {
|
|
1625
|
+
...arrayFormat ? { arrayFormat } : {},
|
|
1626
|
+
...allowDots !== void 0 ? { allowDots } : {},
|
|
1627
|
+
...indices !== void 0 ? { indices } : {}
|
|
1628
|
+
};
|
|
1629
|
+
}
|
|
1630
|
+
return void 0;
|
|
1676
1631
|
}
|
|
1677
1632
|
// render: "if (args && 'Authorization' in args) req.header('Authorization', args['Authorization'])"
|
|
1678
1633
|
renderRequestHeaders() {
|
|
@@ -1806,7 +1761,7 @@ var OperationDefinitionMicroFunctionRenderer = class {
|
|
|
1806
1761
|
` const req = request.${$method}<${this.typeName("ResponseBodies")}[STATUS]>("${pathname}")`,
|
|
1807
1762
|
" .option('module', { name: moduleName, pathname, method })",
|
|
1808
1763
|
"",
|
|
1809
|
-
$mediaType
|
|
1764
|
+
$mediaType ? indent(2, $mediaType) : void 0,
|
|
1810
1765
|
" /* @anchor:query:start */",
|
|
1811
1766
|
$queryParameters ? indent(2, $queryParameters) : void 0,
|
|
1812
1767
|
" /* @anchor:query:end */",
|
|
@@ -1988,8 +1943,7 @@ var NestjsClientRenderer = class {
|
|
|
1988
1943
|
const moduleName = changeCase2.pascalCase(this.document.module.name);
|
|
1989
1944
|
const $dependencies = this.renderDependencies();
|
|
1990
1945
|
const $operations = this.document.operations.map((operation) => OperationDefinitionTransformer.toNestjsMethod(operation, {
|
|
1991
|
-
esm: this.options.esm
|
|
1992
|
-
qs: this.options.qs
|
|
1946
|
+
esm: this.options.esm
|
|
1993
1947
|
})).join("\n\n");
|
|
1994
1948
|
return [
|
|
1995
1949
|
"/* @anchor:file:start */",
|
|
@@ -2376,7 +2330,6 @@ var MicroFunctionGenerator = class _MicroFunctionGenerator {
|
|
|
2376
2330
|
id: _MicroFunctionGenerator.getOperationDefinitionArtifactId(operationDefinition),
|
|
2377
2331
|
filepath,
|
|
2378
2332
|
content: OperationDefinitionTransformer.toMicroFunction(operationDefinition, {
|
|
2379
|
-
qs: rc.qs,
|
|
2380
2333
|
esm: rc.esm,
|
|
2381
2334
|
getOperationDefinitionDeclarationFilepath(operationDefinition2) {
|
|
2382
2335
|
const relativePath = path10.relative(
|
|
@@ -2501,7 +2454,6 @@ var NestjsModuleGenerator = class _NestjsModuleGenerator {
|
|
|
2501
2454
|
filepath,
|
|
2502
2455
|
content: ApiDocumentTransformer.toNestjsClient(document, {
|
|
2503
2456
|
esm: rc.esm,
|
|
2504
|
-
qs: rc.qs,
|
|
2505
2457
|
getOperationDefinitionDeclarationFilepath(operationDefinition) {
|
|
2506
2458
|
const relativePath = path11.relative(
|
|
2507
2459
|
dirpath,
|
|
@@ -2638,7 +2590,7 @@ var DownloadLocalFilePlugin = class _DownloadLocalFilePlugin {
|
|
|
2638
2590
|
};
|
|
2639
2591
|
|
|
2640
2592
|
// src/plugins/shaking/shaking.plugin.ts
|
|
2641
|
-
import { openapiShakingSync
|
|
2593
|
+
import { openapiShakingSync } from "@opendoc/openapi-shaking";
|
|
2642
2594
|
var ShakingPlugin = class _ShakingPlugin {
|
|
2643
2595
|
apply(compiler) {
|
|
2644
2596
|
compiler.hooks.beforeCompile.tap(_ShakingPlugin.name, (task) => {
|
|
@@ -2648,6 +2600,7 @@ var ShakingPlugin = class _ShakingPlugin {
|
|
|
2648
2600
|
});
|
|
2649
2601
|
}
|
|
2650
2602
|
shaking(compiler, document) {
|
|
2603
|
+
const rc = compiler.context.rc;
|
|
2651
2604
|
const matcher = compiler.context.matcher;
|
|
2652
2605
|
const isAccepted = (pathname, method, operation) => {
|
|
2653
2606
|
if (!SupportedMethods.includes(method)) return false;
|
|
@@ -2659,10 +2612,10 @@ var ShakingPlugin = class _ShakingPlugin {
|
|
|
2659
2612
|
document
|
|
2660
2613
|
}));
|
|
2661
2614
|
};
|
|
2662
|
-
const sharkedSwagger =
|
|
2615
|
+
const sharkedSwagger = openapiShakingSync(
|
|
2663
2616
|
document.specification,
|
|
2664
2617
|
isAccepted,
|
|
2665
|
-
{ tolerant:
|
|
2618
|
+
{ tolerant: rc.tolerant }
|
|
2666
2619
|
);
|
|
2667
2620
|
return new ApiDocumentV3_1(
|
|
2668
2621
|
sharkedSwagger,
|
|
@@ -2756,6 +2709,11 @@ var InitializePlugin = class _InitializePlugin {
|
|
|
2756
2709
|
} else if (rc.mode === "nestjs-module") {
|
|
2757
2710
|
new GenerateNestjsModulePlugin().apply(compiler);
|
|
2758
2711
|
}
|
|
2712
|
+
if (rc.plugins && rc.plugins.length) {
|
|
2713
|
+
for (const plugin of rc.plugins) {
|
|
2714
|
+
plugin.apply(compiler);
|
|
2715
|
+
}
|
|
2716
|
+
}
|
|
2759
2717
|
});
|
|
2760
2718
|
if (this.options.includes && this.options.includes.length) {
|
|
2761
2719
|
const modulesIncludes = this.options.includes;
|
|
@@ -2781,6 +2739,9 @@ var InitializePlugin = class _InitializePlugin {
|
|
|
2781
2739
|
}
|
|
2782
2740
|
};
|
|
2783
2741
|
|
|
2742
|
+
// src/plugins/overwrite-query-options/overwrite-query-options.plugin.ts
|
|
2743
|
+
var QsArrayFormatUnion = Object.values(QsArrayFormat);
|
|
2744
|
+
|
|
2784
2745
|
// src/compiler/compiler.ts
|
|
2785
2746
|
var Compiler = class {
|
|
2786
2747
|
constructor(options) {
|