@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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
## 5.0.0-alpha.6 (2025-09-17)
|
|
2
2
|
|
|
3
|
+
## 5.0.0-alpha.24
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- 2ead9d0: **BREAKING CHANGE:** operationIdFactory is removed, please use OverwriteOperationIdPlugin instead.
|
|
8
|
+
|
|
9
|
+
### Minor Changes
|
|
10
|
+
|
|
11
|
+
- 0a2eb2f: **Feat:** server-sent event support.
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [0a2eb2f]
|
|
16
|
+
- keq@5.0.0-alpha.24
|
|
17
|
+
|
|
3
18
|
## 5.0.0-alpha.23
|
|
4
19
|
|
|
5
20
|
### Minor Changes
|
package/dist/cli.cjs
CHANGED
|
@@ -147,29 +147,8 @@ var IgnoreMatcher = class _IgnoreMatcher {
|
|
|
147
147
|
}
|
|
148
148
|
};
|
|
149
149
|
|
|
150
|
-
// src/types/qs.ts
|
|
151
|
-
var import_typebox = require("@sinclair/typebox");
|
|
152
|
-
|
|
153
|
-
// src/constants/qs-array-format.ts
|
|
154
|
-
var QsArrayFormat = /* @__PURE__ */ ((QsArrayFormat2) => {
|
|
155
|
-
QsArrayFormat2["brackets"] = "brackets";
|
|
156
|
-
QsArrayFormat2["indices"] = "indices";
|
|
157
|
-
QsArrayFormat2["repeat"] = "repeat";
|
|
158
|
-
QsArrayFormat2["comma"] = "comma";
|
|
159
|
-
QsArrayFormat2["space"] = "space";
|
|
160
|
-
QsArrayFormat2["pipe"] = "pipe";
|
|
161
|
-
return QsArrayFormat2;
|
|
162
|
-
})(QsArrayFormat || {});
|
|
163
|
-
|
|
164
|
-
// src/types/qs.ts
|
|
165
|
-
var Qs = import_typebox.Type.Object({
|
|
166
|
-
indices: import_typebox.Type.Optional(import_typebox.Type.Boolean()),
|
|
167
|
-
arrayFormat: import_typebox.Type.Optional(import_typebox.Type.Enum(QsArrayFormat)),
|
|
168
|
-
allowDots: import_typebox.Type.Optional(import_typebox.Type.Boolean())
|
|
169
|
-
});
|
|
170
|
-
|
|
171
150
|
// src/types/runtime-config.ts
|
|
172
|
-
var
|
|
151
|
+
var import_typebox = require("@sinclair/typebox");
|
|
173
152
|
|
|
174
153
|
// src/constants/file-naming-style.ts
|
|
175
154
|
var FileNamingStyle = /* @__PURE__ */ ((FileNamingStyle2) => {
|
|
@@ -188,12 +167,12 @@ var FileNamingStyle = /* @__PURE__ */ ((FileNamingStyle2) => {
|
|
|
188
167
|
})(FileNamingStyle || {});
|
|
189
168
|
|
|
190
169
|
// src/types/runtime-config.ts
|
|
191
|
-
var RuntimeConfig =
|
|
192
|
-
mode:
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
170
|
+
var RuntimeConfig = import_typebox.Type.Object({
|
|
171
|
+
mode: import_typebox.Type.Optional(
|
|
172
|
+
import_typebox.Type.Union([
|
|
173
|
+
import_typebox.Type.Literal("micro-function"),
|
|
174
|
+
import_typebox.Type.Literal("nestjs-module"),
|
|
175
|
+
import_typebox.Type.Literal("none")
|
|
197
176
|
], { default: "micro-function" })
|
|
198
177
|
),
|
|
199
178
|
/**
|
|
@@ -202,27 +181,22 @@ var RuntimeConfig = import_typebox2.Type.Object({
|
|
|
202
181
|
* If not specified, the module system will be inferred from the nearest package.json "type" field
|
|
203
182
|
* or defaults to "cjs" if no package.json is found.
|
|
204
183
|
*/
|
|
205
|
-
esm:
|
|
184
|
+
esm: import_typebox.Type.Optional(import_typebox.Type.Boolean({ default: false })),
|
|
206
185
|
/**
|
|
207
186
|
* Output directory for generated files
|
|
208
187
|
*/
|
|
209
|
-
outdir:
|
|
188
|
+
outdir: import_typebox.Type.String({ default: `${process.cwd()}/api` }),
|
|
210
189
|
/**
|
|
211
190
|
* File naming style for generated files
|
|
212
191
|
*/
|
|
213
|
-
fileNamingStyle:
|
|
214
|
-
modules:
|
|
215
|
-
|
|
216
|
-
qs: import_typebox2.Type.Optional(import_typebox2.Type.Union([
|
|
217
|
-
Qs,
|
|
218
|
-
import_typebox2.Type.Function([import_typebox2.Type.Any()], Qs)
|
|
219
|
-
])),
|
|
220
|
-
debug: import_typebox2.Type.Optional(import_typebox2.Type.Boolean({ default: false })),
|
|
192
|
+
fileNamingStyle: import_typebox.Type.Enum(FileNamingStyle, { default: "snakeCase" /* snakeCase */ }),
|
|
193
|
+
modules: import_typebox.Type.Record(import_typebox.Type.String(), import_typebox.Type.String()),
|
|
194
|
+
debug: import_typebox.Type.Optional(import_typebox.Type.Boolean({ default: false })),
|
|
221
195
|
/**
|
|
222
196
|
* Whether to tolerate wrong openapi/swagger structure
|
|
223
197
|
*/
|
|
224
|
-
tolerant:
|
|
225
|
-
plugins:
|
|
198
|
+
tolerant: import_typebox.Type.Optional(import_typebox.Type.Boolean({ default: false })),
|
|
199
|
+
plugins: import_typebox.Type.Optional(import_typebox.Type.Array(import_typebox.Type.Any(), { default: [] }))
|
|
226
200
|
});
|
|
227
201
|
|
|
228
202
|
// src/compiler/tasks/setup/utils/validate-modules.ts
|
|
@@ -300,20 +274,13 @@ function main(compiler, options) {
|
|
|
300
274
|
await import_fs_extra2.default.ensureDir(".keq");
|
|
301
275
|
rc.debug = true;
|
|
302
276
|
}
|
|
303
|
-
|
|
304
|
-
rc.tolerant = true;
|
|
305
|
-
}
|
|
277
|
+
rc.tolerant = Boolean(rc.tolerant);
|
|
306
278
|
const packageJsonInfo = findNearestPackageJson();
|
|
307
279
|
if (packageJsonInfo) {
|
|
308
280
|
const moduleSystem = getProjectModuleSystem(packageJsonInfo);
|
|
309
281
|
rc.esm = moduleSystem === "esm";
|
|
310
282
|
}
|
|
311
283
|
context.rc = rc;
|
|
312
|
-
if (rc.plugins && rc.plugins.length) {
|
|
313
|
-
for (const plugin of rc.plugins) {
|
|
314
|
-
plugin.apply(compiler);
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
284
|
let matcher = new IgnoreMatcher([]);
|
|
318
285
|
if (result.filepath) {
|
|
319
286
|
const ignoreFilepath = import_path.default.resolve(import_path.default.dirname(result.filepath), ".keqignore");
|
|
@@ -362,12 +329,6 @@ var import_openapi_parser2 = require("@scalar/openapi-parser");
|
|
|
362
329
|
// src/models/artifact.ts
|
|
363
330
|
var path3 = __toESM(require("path"), 1);
|
|
364
331
|
|
|
365
|
-
// src/models/utils/to-comment.ts
|
|
366
|
-
function toComment(msg) {
|
|
367
|
-
if (!msg) return "";
|
|
368
|
-
return msg.split("\n").map((str) => `// ${str}`).join("\n");
|
|
369
|
-
}
|
|
370
|
-
|
|
371
332
|
// src/models/anchor.ts
|
|
372
333
|
var AnchorBlock = class {
|
|
373
334
|
constructor(artifact) {
|
|
@@ -446,7 +407,6 @@ var HeaderComment = [
|
|
|
446
407
|
var Artifact = class {
|
|
447
408
|
id;
|
|
448
409
|
filepath;
|
|
449
|
-
warns = [];
|
|
450
410
|
content;
|
|
451
411
|
extensionName;
|
|
452
412
|
anchor = new Anchor(this);
|
|
@@ -459,20 +419,8 @@ var Artifact = class {
|
|
|
459
419
|
get dirname() {
|
|
460
420
|
return path3.dirname(this.filepath);
|
|
461
421
|
}
|
|
462
|
-
addWarn(message) {
|
|
463
|
-
this.warns.push(message);
|
|
464
|
-
}
|
|
465
422
|
renderer() {
|
|
466
|
-
|
|
467
|
-
if (this.warns.length) {
|
|
468
|
-
$warns = toComment([
|
|
469
|
-
"!!! Here is some Problems !!!",
|
|
470
|
-
"",
|
|
471
|
-
this.warns
|
|
472
|
-
].join("\n"));
|
|
473
|
-
$warns += "\n\n";
|
|
474
|
-
}
|
|
475
|
-
return `${HeaderComment}${$warns}${this.content}`;
|
|
423
|
+
return `${HeaderComment}${this.content}`;
|
|
476
424
|
}
|
|
477
425
|
};
|
|
478
426
|
|
|
@@ -663,7 +611,6 @@ var OperationDefinition = class {
|
|
|
663
611
|
};
|
|
664
612
|
|
|
665
613
|
// src/models/api-document_v3_1.ts
|
|
666
|
-
var import_openapi_shaking = require("@opendoc/openapi-shaking");
|
|
667
614
|
var ApiDocumentV3_1 = class _ApiDocumentV3_1 {
|
|
668
615
|
module;
|
|
669
616
|
specification;
|
|
@@ -706,31 +653,6 @@ var ApiDocumentV3_1 = class _ApiDocumentV3_1 {
|
|
|
706
653
|
}
|
|
707
654
|
return false;
|
|
708
655
|
}
|
|
709
|
-
sharking(filter2) {
|
|
710
|
-
const isAccepted = (pathname, method, operation) => {
|
|
711
|
-
if (!SupportedMethods.includes(method)) return false;
|
|
712
|
-
const operationDefinition = new OperationDefinition({
|
|
713
|
-
method,
|
|
714
|
-
pathname,
|
|
715
|
-
operation,
|
|
716
|
-
module: this.module,
|
|
717
|
-
document: this
|
|
718
|
-
});
|
|
719
|
-
return filter2(operationDefinition);
|
|
720
|
-
};
|
|
721
|
-
const sharkedSwagger = (0, import_openapi_shaking.openapiShakingSync)(
|
|
722
|
-
this.specification,
|
|
723
|
-
isAccepted,
|
|
724
|
-
{ tolerant: true }
|
|
725
|
-
);
|
|
726
|
-
return new _ApiDocumentV3_1(
|
|
727
|
-
sharkedSwagger,
|
|
728
|
-
new ModuleDefinition(
|
|
729
|
-
this.module.name,
|
|
730
|
-
`file://${this.module.name}.v3_1.sharked.json`
|
|
731
|
-
)
|
|
732
|
-
);
|
|
733
|
-
}
|
|
734
656
|
static unknown() {
|
|
735
657
|
return new _ApiDocumentV3_1({}, ModuleDefinition.unknown());
|
|
736
658
|
}
|
|
@@ -868,25 +790,6 @@ function dereferenceOperation(swagger) {
|
|
|
868
790
|
return removeUndefinedRef(shadow);
|
|
869
791
|
}
|
|
870
792
|
|
|
871
|
-
// src/utils/openapi-utils/update-operation-id.ts
|
|
872
|
-
var R9 = __toESM(require("ramda"), 1);
|
|
873
|
-
function updateOperationId(swagger, fn) {
|
|
874
|
-
const shadow = R9.clone(swagger);
|
|
875
|
-
for (const [pathname, pathItem] of Object.entries(shadow.paths || {})) {
|
|
876
|
-
for (const m in pathItem) {
|
|
877
|
-
const method = m.toLowerCase();
|
|
878
|
-
if (!SupportedMethods.includes(method)) continue;
|
|
879
|
-
if (typeof pathItem[m] !== "object" || Array.isArray(pathItem[m]) || pathItem[m] === null) continue;
|
|
880
|
-
const operation = pathItem[m];
|
|
881
|
-
const operationId = fn(method, pathname, operation);
|
|
882
|
-
if (typeof operationId === "string" && operationId.length > 0) {
|
|
883
|
-
operation.operationId = operationId;
|
|
884
|
-
}
|
|
885
|
-
}
|
|
886
|
-
}
|
|
887
|
-
return shadow;
|
|
888
|
-
}
|
|
889
|
-
|
|
890
793
|
// src/utils/json-schema-utils/is-array.ts
|
|
891
794
|
function isArray(schema) {
|
|
892
795
|
return schema.type === "array";
|
|
@@ -942,6 +845,31 @@ function To3_1(openapi) {
|
|
|
942
845
|
return specification;
|
|
943
846
|
}
|
|
944
847
|
|
|
848
|
+
// src/utils/openapi-utils/map-operation.ts
|
|
849
|
+
var R9 = __toESM(require("ramda"), 1);
|
|
850
|
+
function mapOperation(specification, mapper) {
|
|
851
|
+
const shadow = R9.clone(specification);
|
|
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
|
+
pathItem[m] = mapper(method, pathname, operation);
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
return shadow;
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
// src/utils/openapi-utils/map-parameter.ts
|
|
865
|
+
function mapParameter(specification, mapper) {
|
|
866
|
+
return mapOperation(specification, (method, pathname, operation) => {
|
|
867
|
+
if (!operation.parameters) return operation;
|
|
868
|
+
operation.parameters = operation.parameters.map((parameter) => mapper(method, pathname, operation, parameter));
|
|
869
|
+
return operation;
|
|
870
|
+
});
|
|
871
|
+
}
|
|
872
|
+
|
|
945
873
|
// src/utils/openapi-utils/index.ts
|
|
946
874
|
var OpenapiUtils = class {
|
|
947
875
|
static isRefDefined = isRefDefined;
|
|
@@ -949,7 +877,9 @@ var OpenapiUtils = class {
|
|
|
949
877
|
static dereferenceDeep = dereferenceDeep;
|
|
950
878
|
static removeUndefinedRef = removeUndefinedRef;
|
|
951
879
|
static dereferenceOperation = dereferenceOperation;
|
|
952
|
-
static
|
|
880
|
+
static mapOperation = mapOperation;
|
|
881
|
+
static mapParameter = mapParameter;
|
|
882
|
+
// static updateOperationId = updateOperationId
|
|
953
883
|
static to3_1 = To3_1;
|
|
954
884
|
};
|
|
955
885
|
|
|
@@ -976,7 +906,7 @@ function main2(compiler, options) {
|
|
|
976
906
|
if (!content) {
|
|
977
907
|
throw new Exception(moduleDefinition, `Cannot download document from ${moduleDefinition.address}`);
|
|
978
908
|
}
|
|
979
|
-
|
|
909
|
+
const spec = JSON.parse(content);
|
|
980
910
|
const { valid, errors } = await (0, import_openapi_parser2.validate)(spec);
|
|
981
911
|
if (!valid) {
|
|
982
912
|
const message = `${moduleDefinition.name} module openapi/swagger file does not conform to the openapi specifications or have grammatical errors, which may cause unexpected errors:
|
|
@@ -984,14 +914,6 @@ ${errors?.map((e) => ` - ${e.message}`).join("\n")}`;
|
|
|
984
914
|
task2.output = message;
|
|
985
915
|
}
|
|
986
916
|
OpenapiUtils.dereferenceOperation(spec);
|
|
987
|
-
const rc2 = context.rc;
|
|
988
|
-
if (rc2?.operationIdFactory) {
|
|
989
|
-
const operationIdFactory = rc2.operationIdFactory;
|
|
990
|
-
spec = OpenapiUtils.updateOperationId(
|
|
991
|
-
spec,
|
|
992
|
-
(method, pathname, operation) => operationIdFactory({ method, pathname, operation, module: moduleDefinition })
|
|
993
|
-
);
|
|
994
|
-
}
|
|
995
917
|
const document = new ApiDocumentV3_1(
|
|
996
918
|
spec,
|
|
997
919
|
moduleDefinition
|
|
@@ -1235,7 +1157,7 @@ function perfectErrorMessage() {
|
|
|
1235
1157
|
// src/plugins/eslint/index.ts
|
|
1236
1158
|
var import_eslint = require("eslint");
|
|
1237
1159
|
|
|
1238
|
-
// src/plugins/prettier/
|
|
1160
|
+
// src/plugins/prettier/prettier.plugin.ts
|
|
1239
1161
|
var import_child_process = require("child_process");
|
|
1240
1162
|
var import_util = require("util");
|
|
1241
1163
|
var execAsync = (0, import_util.promisify)(import_child_process.exec);
|
|
@@ -1517,7 +1439,12 @@ var DeclarationRenderer2 = class {
|
|
|
1517
1439
|
}
|
|
1518
1440
|
const $responses = Object.entries(operation.responses).map(([statusCode, response]) => {
|
|
1519
1441
|
if (!JsonSchemaUtils.isRef(response)) {
|
|
1520
|
-
const $value = Object.
|
|
1442
|
+
const $value = Object.entries(response.content || {}).map(([mediaType, mediaTypeObject]) => [mediaType, mediaTypeObject.schema]).map(([mediaType, schema]) => {
|
|
1443
|
+
if (mediaType.includes("text/event-stream")) return "ReadableStream<ServerSentEvent>";
|
|
1444
|
+
if (mediaType.includes("multipart/form-data")) return "FormData";
|
|
1445
|
+
if (!schema) return "unknown";
|
|
1446
|
+
return JsonSchemaTransformer.toDeclaration(schema, options);
|
|
1447
|
+
}).join(" | ");
|
|
1521
1448
|
return indent(2, `${statusCode}: ${$value || "void"}`);
|
|
1522
1449
|
}
|
|
1523
1450
|
}).join("\n");
|
|
@@ -1599,7 +1526,7 @@ var DeclarationRenderer2 = class {
|
|
|
1599
1526
|
return `import type { ${schemaName} as ${alias(schemaName)} } from "${filepath}"`;
|
|
1600
1527
|
}).map((str) => str.replace(/ from "(\.\.?\/.+?)(\.ts|\.mts|\.cts|\.js|\.cjs|\.mjs)?"/, this.options.esm ? ' from "$1.js"' : ' from "$1"'));
|
|
1601
1528
|
return [
|
|
1602
|
-
'import type { KeqOperation, KeqPathParameterInit, KeqQueryInit } from "keq"',
|
|
1529
|
+
'import type { KeqOperation, KeqPathParameterInit, KeqQueryInit, ServerSentEvent } from "keq"',
|
|
1603
1530
|
...$schemaDefinitions
|
|
1604
1531
|
].join("\n");
|
|
1605
1532
|
}
|
|
@@ -1665,8 +1592,21 @@ var DeclarationRenderer2 = class {
|
|
|
1665
1592
|
// src/transformers/operation-definition/micro-function.renderer.ts
|
|
1666
1593
|
var R17 = __toESM(require("ramda"), 1);
|
|
1667
1594
|
|
|
1668
|
-
// src/transformers/operation-definition/typescript-
|
|
1595
|
+
// src/transformers/operation-definition/typescript-snippet.ts
|
|
1669
1596
|
var R16 = __toESM(require("ramda"), 1);
|
|
1597
|
+
|
|
1598
|
+
// src/constants/qs-array-format.ts
|
|
1599
|
+
var QsArrayFormat = /* @__PURE__ */ ((QsArrayFormat2) => {
|
|
1600
|
+
QsArrayFormat2["brackets"] = "brackets";
|
|
1601
|
+
QsArrayFormat2["indices"] = "indices";
|
|
1602
|
+
QsArrayFormat2["repeat"] = "repeat";
|
|
1603
|
+
QsArrayFormat2["comma"] = "comma";
|
|
1604
|
+
QsArrayFormat2["space"] = "space";
|
|
1605
|
+
QsArrayFormat2["pipe"] = "pipe";
|
|
1606
|
+
return QsArrayFormat2;
|
|
1607
|
+
})(QsArrayFormat || {});
|
|
1608
|
+
|
|
1609
|
+
// src/transformers/operation-definition/typescript-snippet.ts
|
|
1670
1610
|
var OperationDefinitionSnippet = class {
|
|
1671
1611
|
constructor(operationDefinition, options) {
|
|
1672
1612
|
this.operationDefinition = operationDefinition;
|
|
@@ -1675,27 +1615,42 @@ var OperationDefinitionSnippet = class {
|
|
|
1675
1615
|
}
|
|
1676
1616
|
typeName;
|
|
1677
1617
|
getQsParameters(parameter) {
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
return this.options.qs;
|
|
1682
|
-
}
|
|
1618
|
+
let arrayFormat;
|
|
1619
|
+
let allowDots;
|
|
1620
|
+
let indices;
|
|
1683
1621
|
const style = parameter.style || "form";
|
|
1684
1622
|
const explode = parameter.explode ?? true;
|
|
1685
|
-
if (
|
|
1686
|
-
|
|
1687
|
-
} else if (explode) {
|
|
1688
|
-
return { arrayFormat: "repeat" };
|
|
1623
|
+
if ("x-qs-array-format" in parameter) {
|
|
1624
|
+
arrayFormat = parameter["x-qs-array-format"];
|
|
1689
1625
|
} else {
|
|
1690
|
-
if (style === "
|
|
1691
|
-
|
|
1692
|
-
} else if (
|
|
1693
|
-
|
|
1694
|
-
} else
|
|
1695
|
-
|
|
1626
|
+
if (style === "deepObject") {
|
|
1627
|
+
arrayFormat = "brackets" /* brackets */;
|
|
1628
|
+
} else if (explode) {
|
|
1629
|
+
arrayFormat = "repeat" /* repeat */;
|
|
1630
|
+
} else {
|
|
1631
|
+
if (style === "form") {
|
|
1632
|
+
arrayFormat = "comma" /* comma */;
|
|
1633
|
+
} else if (style === "spaceDelimited") {
|
|
1634
|
+
arrayFormat = "space" /* space */;
|
|
1635
|
+
} else if (style === "pipeDelimited") {
|
|
1636
|
+
arrayFormat = "pipe" /* pipe */;
|
|
1637
|
+
}
|
|
1696
1638
|
}
|
|
1697
1639
|
}
|
|
1698
|
-
|
|
1640
|
+
if ("x-qs-allow-dots" in parameter) {
|
|
1641
|
+
allowDots = Boolean(parameter["x-qs-allow-dots"]);
|
|
1642
|
+
}
|
|
1643
|
+
if ("x-qs-indices" in parameter) {
|
|
1644
|
+
indices = Boolean(parameter["x-qs-indices"]);
|
|
1645
|
+
}
|
|
1646
|
+
if (arrayFormat || allowDots !== void 0 || indices !== void 0) {
|
|
1647
|
+
return {
|
|
1648
|
+
...arrayFormat ? { arrayFormat } : {},
|
|
1649
|
+
...allowDots !== void 0 ? { allowDots } : {},
|
|
1650
|
+
...indices !== void 0 ? { indices } : {}
|
|
1651
|
+
};
|
|
1652
|
+
}
|
|
1653
|
+
return void 0;
|
|
1699
1654
|
}
|
|
1700
1655
|
// render: "if (args && 'Authorization' in args) req.header('Authorization', args['Authorization'])"
|
|
1701
1656
|
renderRequestHeaders() {
|
|
@@ -2011,8 +1966,7 @@ var NestjsClientRenderer = class {
|
|
|
2011
1966
|
const moduleName = changeCase2.pascalCase(this.document.module.name);
|
|
2012
1967
|
const $dependencies = this.renderDependencies();
|
|
2013
1968
|
const $operations = this.document.operations.map((operation) => OperationDefinitionTransformer.toNestjsMethod(operation, {
|
|
2014
|
-
esm: this.options.esm
|
|
2015
|
-
qs: this.options.qs
|
|
1969
|
+
esm: this.options.esm
|
|
2016
1970
|
})).join("\n\n");
|
|
2017
1971
|
return [
|
|
2018
1972
|
"/* @anchor:file:start */",
|
|
@@ -2399,7 +2353,6 @@ var MicroFunctionGenerator = class _MicroFunctionGenerator {
|
|
|
2399
2353
|
id: _MicroFunctionGenerator.getOperationDefinitionArtifactId(operationDefinition),
|
|
2400
2354
|
filepath,
|
|
2401
2355
|
content: OperationDefinitionTransformer.toMicroFunction(operationDefinition, {
|
|
2402
|
-
qs: rc.qs,
|
|
2403
2356
|
esm: rc.esm,
|
|
2404
2357
|
getOperationDefinitionDeclarationFilepath(operationDefinition2) {
|
|
2405
2358
|
const relativePath = path10.relative(
|
|
@@ -2524,7 +2477,6 @@ var NestjsModuleGenerator = class _NestjsModuleGenerator {
|
|
|
2524
2477
|
filepath,
|
|
2525
2478
|
content: ApiDocumentTransformer.toNestjsClient(document, {
|
|
2526
2479
|
esm: rc.esm,
|
|
2527
|
-
qs: rc.qs,
|
|
2528
2480
|
getOperationDefinitionDeclarationFilepath(operationDefinition) {
|
|
2529
2481
|
const relativePath = path11.relative(
|
|
2530
2482
|
dirpath,
|
|
@@ -2661,7 +2613,7 @@ var DownloadLocalFilePlugin = class _DownloadLocalFilePlugin {
|
|
|
2661
2613
|
};
|
|
2662
2614
|
|
|
2663
2615
|
// src/plugins/shaking/shaking.plugin.ts
|
|
2664
|
-
var
|
|
2616
|
+
var import_openapi_shaking = require("@opendoc/openapi-shaking");
|
|
2665
2617
|
var ShakingPlugin = class _ShakingPlugin {
|
|
2666
2618
|
apply(compiler) {
|
|
2667
2619
|
compiler.hooks.beforeCompile.tap(_ShakingPlugin.name, (task) => {
|
|
@@ -2671,6 +2623,7 @@ var ShakingPlugin = class _ShakingPlugin {
|
|
|
2671
2623
|
});
|
|
2672
2624
|
}
|
|
2673
2625
|
shaking(compiler, document) {
|
|
2626
|
+
const rc = compiler.context.rc;
|
|
2674
2627
|
const matcher = compiler.context.matcher;
|
|
2675
2628
|
const isAccepted = (pathname, method, operation) => {
|
|
2676
2629
|
if (!SupportedMethods.includes(method)) return false;
|
|
@@ -2682,10 +2635,10 @@ var ShakingPlugin = class _ShakingPlugin {
|
|
|
2682
2635
|
document
|
|
2683
2636
|
}));
|
|
2684
2637
|
};
|
|
2685
|
-
const sharkedSwagger = (0,
|
|
2638
|
+
const sharkedSwagger = (0, import_openapi_shaking.openapiShakingSync)(
|
|
2686
2639
|
document.specification,
|
|
2687
2640
|
isAccepted,
|
|
2688
|
-
{ tolerant:
|
|
2641
|
+
{ tolerant: rc.tolerant }
|
|
2689
2642
|
);
|
|
2690
2643
|
return new ApiDocumentV3_1(
|
|
2691
2644
|
sharkedSwagger,
|
|
@@ -2779,6 +2732,11 @@ var InitializePlugin = class _InitializePlugin {
|
|
|
2779
2732
|
} else if (rc.mode === "nestjs-module") {
|
|
2780
2733
|
new GenerateNestjsModulePlugin().apply(compiler);
|
|
2781
2734
|
}
|
|
2735
|
+
if (rc.plugins && rc.plugins.length) {
|
|
2736
|
+
for (const plugin of rc.plugins) {
|
|
2737
|
+
plugin.apply(compiler);
|
|
2738
|
+
}
|
|
2739
|
+
}
|
|
2782
2740
|
});
|
|
2783
2741
|
if (this.options.includes && this.options.includes.length) {
|
|
2784
2742
|
const modulesIncludes = this.options.includes;
|
|
@@ -2804,6 +2762,9 @@ var InitializePlugin = class _InitializePlugin {
|
|
|
2804
2762
|
}
|
|
2805
2763
|
};
|
|
2806
2764
|
|
|
2765
|
+
// src/plugins/overwrite-query-options/overwrite-query-options.plugin.ts
|
|
2766
|
+
var QsArrayFormatUnion = Object.values(QsArrayFormat);
|
|
2767
|
+
|
|
2807
2768
|
// src/compiler/compiler.ts
|
|
2808
2769
|
var Compiler = class {
|
|
2809
2770
|
constructor(options) {
|