@keq-request/cli 5.0.0-alpha.27 → 5.0.0-alpha.29
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 +19 -0
- package/dist/cli.cjs +1060 -1112
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +1180 -1232
- package/dist/cli.js.map +1 -1
- package/dist/compiler/compiler.d.ts.map +1 -1
- package/dist/compiler/tasks/setup/index.d.ts.map +1 -1
- package/dist/compiler/tasks/setup/utils/index.d.ts +0 -1
- package/dist/compiler/tasks/setup/utils/index.d.ts.map +1 -1
- package/dist/compiler/tasks/setup/utils/parse-runtime-config.d.ts +3 -0
- package/dist/compiler/tasks/setup/utils/parse-runtime-config.d.ts.map +1 -0
- package/dist/compiler/types/compiler-context.d.ts +1 -1
- package/dist/compiler/types/compiler-context.d.ts.map +1 -1
- package/dist/compiler/types/compiler-hooks.d.ts +2 -1
- package/dist/compiler/types/compiler-hooks.d.ts.map +1 -1
- package/dist/define-config.d.ts +3 -0
- package/dist/define-config.d.ts.map +1 -0
- package/dist/index.cjs +1130 -1184
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1041 -1094
- package/dist/index.js.map +1 -1
- package/dist/models/module-definition.d.ts +3 -2
- package/dist/models/module-definition.d.ts.map +1 -1
- package/dist/plugins/body-fallback/constants/index.d.ts +2 -0
- package/dist/plugins/body-fallback/constants/index.d.ts.map +1 -0
- package/dist/plugins/body-fallback/constants/metadata-storage.d.ts +6 -0
- package/dist/plugins/body-fallback/constants/metadata-storage.d.ts.map +1 -0
- package/dist/plugins/body-fallback/index.d.ts +3 -0
- package/dist/plugins/body-fallback/index.d.ts.map +1 -1
- package/dist/plugins/chinese-to-pinyin/chinese-to-pinyin.plugin.d.ts +3 -0
- package/dist/plugins/chinese-to-pinyin/chinese-to-pinyin.plugin.d.ts.map +1 -1
- package/dist/plugins/chinese-to-pinyin/constants/index.d.ts +2 -0
- package/dist/plugins/chinese-to-pinyin/constants/index.d.ts.map +1 -0
- package/dist/plugins/chinese-to-pinyin/constants/metadata-storage.d.ts +6 -0
- package/dist/plugins/chinese-to-pinyin/constants/metadata-storage.d.ts.map +1 -0
- package/dist/plugins/download-http-file/constants/index.d.ts +2 -0
- package/dist/plugins/download-http-file/constants/index.d.ts.map +1 -0
- package/dist/plugins/download-http-file/constants/metadata-storage.d.ts +6 -0
- package/dist/plugins/download-http-file/constants/metadata-storage.d.ts.map +1 -0
- package/dist/plugins/download-http-file/download-http-file.plugin.d.ts +5 -2
- package/dist/plugins/download-http-file/download-http-file.plugin.d.ts.map +1 -1
- package/dist/plugins/download-local-file/constants/index.d.ts +2 -0
- package/dist/plugins/download-local-file/constants/index.d.ts.map +1 -0
- package/dist/plugins/download-local-file/constants/metadata-storage.d.ts +6 -0
- package/dist/plugins/download-local-file/constants/metadata-storage.d.ts.map +1 -0
- package/dist/plugins/download-local-file/download-local-file.plugin.d.ts +3 -0
- package/dist/plugins/download-local-file/download-local-file.plugin.d.ts.map +1 -1
- package/dist/plugins/eslint/constants/index.d.ts +2 -0
- package/dist/plugins/eslint/constants/index.d.ts.map +1 -0
- package/dist/plugins/eslint/constants/metadata-storage.d.ts +6 -0
- package/dist/plugins/eslint/constants/metadata-storage.d.ts.map +1 -0
- package/dist/plugins/eslint/eslint.plugin.d.ts +18 -0
- package/dist/plugins/eslint/eslint.plugin.d.ts.map +1 -0
- package/dist/plugins/eslint/index.d.ts +1 -14
- package/dist/plugins/eslint/index.d.ts.map +1 -1
- package/dist/plugins/generate-declaration/generate-declaration.plugin.d.ts.map +1 -1
- package/dist/plugins/generate-declaration/generators/schema-declaration/schema.generator.d.ts.map +1 -1
- package/dist/plugins/generate-micro-function/generate-micro-function.plugin.d.ts.map +1 -1
- package/dist/plugins/generate-nestjs-module/generate-nestjs-module.d.ts.map +1 -1
- package/dist/plugins/initialize/initialize.plugin.d.ts.map +1 -1
- package/dist/plugins/prettier/constants/index.d.ts +2 -0
- package/dist/plugins/prettier/constants/index.d.ts.map +1 -0
- package/dist/plugins/prettier/constants/metadata-storage.d.ts +6 -0
- package/dist/plugins/prettier/constants/metadata-storage.d.ts.map +1 -0
- package/dist/plugins/prettier/prettier.plugin.d.ts +3 -0
- package/dist/plugins/prettier/prettier.plugin.d.ts.map +1 -1
- package/dist/plugins/shaking/constants/index.d.ts +2 -0
- package/dist/plugins/shaking/constants/index.d.ts.map +1 -0
- package/dist/plugins/shaking/constants/metadata-storage.d.ts +6 -0
- package/dist/plugins/shaking/constants/metadata-storage.d.ts.map +1 -0
- package/dist/plugins/shaking/shaking.plugin.d.ts +3 -0
- package/dist/plugins/shaking/shaking.plugin.d.ts.map +1 -1
- package/dist/plugins/terminal-select/constants/index.d.ts +2 -0
- package/dist/plugins/terminal-select/constants/index.d.ts.map +1 -0
- package/dist/plugins/terminal-select/constants/metadata-storage.d.ts +6 -0
- package/dist/plugins/terminal-select/constants/metadata-storage.d.ts.map +1 -0
- package/dist/plugins/terminal-select/terminal-select.plugin.d.ts +3 -0
- package/dist/plugins/terminal-select/terminal-select.plugin.d.ts.map +1 -1
- package/dist/plugins.cjs +208 -47
- package/dist/plugins.cjs.map +1 -1
- package/dist/plugins.js +208 -47
- package/dist/plugins.js.map +1 -1
- package/dist/translators/index.d.ts +3 -0
- package/dist/translators/index.d.ts.map +1 -0
- package/dist/translators/micro-function.translator.d.ts +5 -0
- package/dist/translators/micro-function.translator.d.ts.map +1 -0
- package/dist/translators/nestjs.translator.d.ts +5 -0
- package/dist/translators/nestjs.translator.d.ts.map +1 -0
- package/dist/translators.cjs +2061 -0
- package/dist/translators.cjs.map +1 -0
- package/dist/translators.js +2023 -0
- package/dist/translators.js.map +1 -0
- package/dist/types/address.d.ts +8 -0
- package/dist/types/address.d.ts.map +1 -0
- package/dist/types/index.d.ts +3 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/runtime-config.d.ts +39 -8
- package/dist/types/runtime-config.d.ts.map +1 -1
- package/dist/types/translator.d.ts +5 -0
- package/dist/types/translator.d.ts.map +1 -0
- package/dist/utils/is-valid-url.d.ts +16 -0
- package/dist/utils/is-valid-url.d.ts.map +1 -0
- package/package.json +8 -3
- package/dist/compiler/tasks/setup/utils/validate-modules.d.ts +0 -2
- package/dist/compiler/tasks/setup/utils/validate-modules.d.ts.map +0 -1
- package/dist/define-keq-config.d.ts +0 -3
- package/dist/define-keq-config.d.ts.map +0 -1
package/dist/cli.cjs
CHANGED
|
@@ -53,7 +53,6 @@ var import_tapable4 = require("tapable");
|
|
|
53
53
|
// src/compiler/tasks/setup/index.ts
|
|
54
54
|
var import_fs_extra2 = __toESM(require("fs-extra"), 1);
|
|
55
55
|
var import_path = __toESM(require("path"), 1);
|
|
56
|
-
var import_value = require("@sinclair/typebox/value");
|
|
57
56
|
var import_cosmiconfig = require("cosmiconfig");
|
|
58
57
|
|
|
59
58
|
// src/utils/ignore-matcher.ts
|
|
@@ -147,8 +146,51 @@ var IgnoreMatcher = class _IgnoreMatcher {
|
|
|
147
146
|
}
|
|
148
147
|
};
|
|
149
148
|
|
|
150
|
-
// src/
|
|
149
|
+
// src/compiler/tasks/setup/utils/find-nearest-package-json.ts
|
|
150
|
+
var import_node_fs = __toESM(require("fs"), 1);
|
|
151
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
152
|
+
function findNearestPackageJson(startDir = process.cwd()) {
|
|
153
|
+
let dir = startDir;
|
|
154
|
+
while (true) {
|
|
155
|
+
const pkgPath = import_node_path.default.join(dir, "package.json");
|
|
156
|
+
if (import_node_fs.default.existsSync(pkgPath)) {
|
|
157
|
+
const json = JSON.parse(import_node_fs.default.readFileSync(pkgPath, "utf8"));
|
|
158
|
+
return { json, path: pkgPath };
|
|
159
|
+
}
|
|
160
|
+
const parent = import_node_path.default.dirname(dir);
|
|
161
|
+
if (parent === dir) break;
|
|
162
|
+
dir = parent;
|
|
163
|
+
}
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// src/compiler/tasks/setup/utils/get-project-module-system.ts
|
|
168
|
+
function getProjectModuleSystem(pkgInfo) {
|
|
169
|
+
if (!pkgInfo?.json) return "cjs";
|
|
170
|
+
const { json } = pkgInfo;
|
|
171
|
+
if (json.type === "module") return "esm";
|
|
172
|
+
return "cjs";
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// src/compiler/tasks/setup/utils/parse-runtime-config.ts
|
|
176
|
+
var import_value = require("@sinclair/typebox/value");
|
|
177
|
+
|
|
178
|
+
// src/types/address.ts
|
|
151
179
|
var import_typebox = require("@sinclair/typebox");
|
|
180
|
+
var Address = import_typebox.Type.Object({
|
|
181
|
+
url: import_typebox.Type.String(),
|
|
182
|
+
headers: import_typebox.Type.Optional(import_typebox.Type.Record(import_typebox.Type.String(), import_typebox.Type.String(), { default: {} })),
|
|
183
|
+
encoding: import_typebox.Type.Optional(
|
|
184
|
+
import_typebox.Type.Union([
|
|
185
|
+
import_typebox.Type.Literal("utf8"),
|
|
186
|
+
import_typebox.Type.Literal("ascii")
|
|
187
|
+
], { default: "utf8" })
|
|
188
|
+
)
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
// src/types/runtime-config.ts
|
|
192
|
+
var R2 = __toESM(require("ramda"), 1);
|
|
193
|
+
var import_typebox2 = require("@sinclair/typebox");
|
|
152
194
|
|
|
153
195
|
// src/constants/file-naming-style.ts
|
|
154
196
|
var FileNamingStyle = /* @__PURE__ */ ((FileNamingStyle2) => {
|
|
@@ -166,168 +208,173 @@ var FileNamingStyle = /* @__PURE__ */ ((FileNamingStyle2) => {
|
|
|
166
208
|
return FileNamingStyle2;
|
|
167
209
|
})(FileNamingStyle || {});
|
|
168
210
|
|
|
211
|
+
// src/utils/is-valid-url.ts
|
|
212
|
+
var URL_REGEX = /^[a-zA-Z][a-zA-Z0-9+.-]*:\/\/(?:[^\s@]+@)?[^\s/:?#]*(?::\d+)?(?:\/[^\s?#]*)?(?:\?[^\s#]*)?(?:#[^\s]*)?$/;
|
|
213
|
+
function isValidURL(url) {
|
|
214
|
+
return URL_REGEX.test(url);
|
|
215
|
+
}
|
|
216
|
+
|
|
169
217
|
// src/types/runtime-config.ts
|
|
170
|
-
var
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
)
|
|
218
|
+
var Modules = import_typebox2.Type.Transform(
|
|
219
|
+
import_typebox2.Type.Record(
|
|
220
|
+
import_typebox2.Type.String(),
|
|
221
|
+
import_typebox2.Type.Union([import_typebox2.Type.String(), Address])
|
|
222
|
+
)
|
|
223
|
+
).Decode((value) => {
|
|
224
|
+
const keys2 = Object.keys(value);
|
|
225
|
+
for (const key of keys2) {
|
|
226
|
+
if (!/^[A-Za-z_][A-Za-z0-9_$]*$/.test(key)) {
|
|
227
|
+
throw new Error(`Module name "${key}" is not valid. It must start with a letter or underscore, and can only contain letters, numbers, and underscores.`);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
const keysGroupByLowerCase = R2.groupBy(R2.toLower, keys2);
|
|
231
|
+
for (const groupKey in keysGroupByLowerCase) {
|
|
232
|
+
const keys3 = keysGroupByLowerCase[groupKey] || [];
|
|
233
|
+
if (keys3.length > 1) {
|
|
234
|
+
throw new Error(`Module names ${keys3.map((name) => `"${name}"`).join(", ")} are case-insensitively duplicated.`);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
for (const key in value) {
|
|
238
|
+
const url = typeof value[key] === "string" ? value[key] : value[key].url;
|
|
239
|
+
if (isValidURL(url)) continue;
|
|
240
|
+
throw new Error(`The ${JSON.stringify(url)} of module "${key}" is not a valid URL.`);
|
|
241
|
+
}
|
|
242
|
+
return R2.map(
|
|
243
|
+
(item) => typeof item !== "string" ? item : { url: item, headers: {}, encoding: "utf8" },
|
|
244
|
+
value
|
|
245
|
+
);
|
|
246
|
+
}).Encode((value) => value);
|
|
247
|
+
var RawConfig = import_typebox2.Type.Object({
|
|
178
248
|
/**
|
|
179
249
|
* Whether to generate ES Module code
|
|
180
250
|
*
|
|
181
251
|
* If not specified, the module system will be inferred from the nearest package.json "type" field
|
|
182
252
|
* or defaults to "cjs" if no package.json is found.
|
|
183
253
|
*/
|
|
184
|
-
esm:
|
|
254
|
+
esm: import_typebox2.Type.Optional(import_typebox2.Type.Boolean({ default: false })),
|
|
185
255
|
/**
|
|
186
256
|
* Output directory for generated files
|
|
187
257
|
*/
|
|
188
|
-
outdir:
|
|
258
|
+
outdir: import_typebox2.Type.String({ default: `${process.cwd()}/api` }),
|
|
189
259
|
/**
|
|
190
260
|
* File naming style for generated files
|
|
191
261
|
*/
|
|
192
|
-
fileNamingStyle:
|
|
193
|
-
|
|
194
|
-
|
|
262
|
+
fileNamingStyle: import_typebox2.Type.Enum(FileNamingStyle, { default: "snakeCase" /* snakeCase */ }),
|
|
263
|
+
/**
|
|
264
|
+
* OpenAPI/Swagger document sources
|
|
265
|
+
*
|
|
266
|
+
* A map of module names to their document URLs or Address objects.
|
|
267
|
+
* The module name must be a valid JavaScript identifier.
|
|
268
|
+
*/
|
|
269
|
+
modules: Modules,
|
|
270
|
+
/**
|
|
271
|
+
* Enable debug mode to output detailed logs during compilation
|
|
272
|
+
*/
|
|
273
|
+
debug: import_typebox2.Type.Optional(import_typebox2.Type.Boolean({ default: false })),
|
|
195
274
|
/**
|
|
196
275
|
* Whether to tolerate wrong openapi/swagger structure
|
|
197
276
|
*/
|
|
198
|
-
tolerant:
|
|
199
|
-
|
|
277
|
+
tolerant: import_typebox2.Type.Optional(import_typebox2.Type.Boolean({ default: false })),
|
|
278
|
+
/**
|
|
279
|
+
* Translators to transform generated code
|
|
280
|
+
*
|
|
281
|
+
* Used to customize the code generation process for different frameworks or patterns.
|
|
282
|
+
* Can be a single translator or an array of translators.
|
|
283
|
+
*/
|
|
284
|
+
translators: import_typebox2.Type.Optional(
|
|
285
|
+
import_typebox2.Type.Transform(
|
|
286
|
+
import_typebox2.Type.Union([
|
|
287
|
+
import_typebox2.Type.Unsafe(import_typebox2.Type.Any()),
|
|
288
|
+
import_typebox2.Type.Array(import_typebox2.Type.Unsafe(import_typebox2.Type.Any()))
|
|
289
|
+
], { default: [] })
|
|
290
|
+
).Decode((value) => {
|
|
291
|
+
if (value === void 0) return [];
|
|
292
|
+
if (Array.isArray(value)) return value;
|
|
293
|
+
return [value];
|
|
294
|
+
}).Encode((value) => value)
|
|
295
|
+
),
|
|
296
|
+
/**
|
|
297
|
+
* Plugins to extend code generation functionality
|
|
298
|
+
*
|
|
299
|
+
* An array of plugin instances that can hook into various stages of the compilation process,
|
|
300
|
+
* such as code transformation, formatting, linting, or custom file generation.
|
|
301
|
+
*/
|
|
302
|
+
plugins: import_typebox2.Type.Optional(import_typebox2.Type.Array(import_typebox2.Type.Unsafe(import_typebox2.Type.Any()), { default: [] }))
|
|
200
303
|
});
|
|
201
304
|
|
|
202
|
-
// src/compiler/tasks/setup/utils/
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
if (
|
|
209
|
-
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
const keysGroupByLowerCase = R2.groupBy(R2.toLower, keys2);
|
|
213
|
-
for (const groupKey in keysGroupByLowerCase) {
|
|
214
|
-
const keys3 = keysGroupByLowerCase[groupKey] || [];
|
|
215
|
-
if (keys3.length > 1) {
|
|
216
|
-
throw new Error(`Module names ${keys3.map((name) => `"${name}"`).join(", ")} are case-insensitively duplicated.`);
|
|
305
|
+
// src/compiler/tasks/setup/utils/parse-runtime-config.ts
|
|
306
|
+
function parseRuntimeConfig(data) {
|
|
307
|
+
try {
|
|
308
|
+
const originalPlugins = typeof data === "object" && data !== null && "plugins" in data ? data.plugins : void 0;
|
|
309
|
+
const originTranslators = typeof data === "object" && data !== null && "translators" in data ? data.translators : void 0;
|
|
310
|
+
const parsed = import_value.Value.Parse(RawConfig, data);
|
|
311
|
+
if (originalPlugins !== void 0) {
|
|
312
|
+
parsed.plugins = originalPlugins;
|
|
217
313
|
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
const address = modules[key];
|
|
221
|
-
if (import_validator.default.isURL(address, { require_host: true, require_protocol: true, protocols: ["http", "https"] })) {
|
|
222
|
-
continue;
|
|
314
|
+
if (originTranslators !== void 0) {
|
|
315
|
+
parsed.translators = originTranslators;
|
|
223
316
|
}
|
|
224
|
-
|
|
225
|
-
|
|
317
|
+
return parsed;
|
|
318
|
+
} catch (error) {
|
|
319
|
+
if (error instanceof Error) {
|
|
320
|
+
error.message = `Invalid Config: ${error.message}`;
|
|
226
321
|
}
|
|
227
|
-
throw
|
|
322
|
+
throw error;
|
|
228
323
|
}
|
|
229
324
|
}
|
|
230
325
|
|
|
231
|
-
// src/
|
|
232
|
-
var
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
}
|
|
246
|
-
return null;
|
|
326
|
+
// src/plugins/eslint/eslint.plugin.ts
|
|
327
|
+
var import_eslint = require("eslint");
|
|
328
|
+
|
|
329
|
+
// src/plugins/prettier/prettier.plugin.ts
|
|
330
|
+
var import_child_process = require("child_process");
|
|
331
|
+
var import_util = require("util");
|
|
332
|
+
var execAsync = (0, import_util.promisify)(import_child_process.exec);
|
|
333
|
+
|
|
334
|
+
// src/plugins/body-fallback/index.ts
|
|
335
|
+
var R21 = __toESM(require("ramda"), 1);
|
|
336
|
+
|
|
337
|
+
// src/utils/json-schema-utils/is-array.ts
|
|
338
|
+
function isArray(schema) {
|
|
339
|
+
return schema.type === "array";
|
|
247
340
|
}
|
|
248
341
|
|
|
249
|
-
// src/
|
|
250
|
-
function
|
|
251
|
-
|
|
252
|
-
const { json } = pkgInfo;
|
|
253
|
-
if (json.type === "module") return "esm";
|
|
254
|
-
return "cjs";
|
|
342
|
+
// src/utils/json-schema-utils/is-mixed.ts
|
|
343
|
+
function isMixed(schema) {
|
|
344
|
+
return Array.isArray(schema.type);
|
|
255
345
|
}
|
|
256
346
|
|
|
257
|
-
// src/
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
return {
|
|
261
|
-
task: async (context, task) => {
|
|
262
|
-
const result = options?.config ? await explore.load(options.config) : await explore.search();
|
|
263
|
-
if (!result || "isEmpty" in result && result.isEmpty) {
|
|
264
|
-
throw new Error("Cannot find config file.");
|
|
265
|
-
}
|
|
266
|
-
if (!import_value.Value.Check(RuntimeConfig, result.config)) {
|
|
267
|
-
const errors = [...import_value.Value.Errors(RuntimeConfig, result.config)];
|
|
268
|
-
const message = errors.map(({ path: path13, message: message2 }) => `${path13}: ${message2}`).join("\n");
|
|
269
|
-
throw new Error(`Invalid Config: ${message}`);
|
|
270
|
-
}
|
|
271
|
-
const rc = import_value.Value.Default(RuntimeConfig, result.config);
|
|
272
|
-
validateModules(rc.modules);
|
|
273
|
-
if (options?.debug) {
|
|
274
|
-
await import_fs_extra2.default.ensureDir(".keq");
|
|
275
|
-
rc.debug = true;
|
|
276
|
-
}
|
|
277
|
-
rc.tolerant = Boolean(rc.tolerant);
|
|
278
|
-
const packageJsonInfo = findNearestPackageJson();
|
|
279
|
-
if (packageJsonInfo) {
|
|
280
|
-
const moduleSystem = getProjectModuleSystem(packageJsonInfo);
|
|
281
|
-
rc.esm = moduleSystem === "esm";
|
|
282
|
-
}
|
|
283
|
-
context.rc = rc;
|
|
284
|
-
let matcher = new IgnoreMatcher([]);
|
|
285
|
-
if (result.filepath) {
|
|
286
|
-
const ignoreFilepath = import_path.default.resolve(import_path.default.dirname(result.filepath), ".keqignore");
|
|
287
|
-
if (await import_fs_extra2.default.exists(ignoreFilepath)) {
|
|
288
|
-
matcher = await IgnoreMatcher.read(ignoreFilepath);
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
const ignoreRules = options.ignore === false ? [] : options.ignore?.rules || [];
|
|
292
|
-
for (const rule of ignoreRules) {
|
|
293
|
-
matcher.append({
|
|
294
|
-
persist: !!rule.persist,
|
|
295
|
-
ignore: rule.ignore,
|
|
296
|
-
moduleName: rule.moduleName,
|
|
297
|
-
operationMethod: rule.operationMethod,
|
|
298
|
-
operationPathname: rule.operationPathname
|
|
299
|
-
});
|
|
300
|
-
}
|
|
301
|
-
context.matcher = matcher;
|
|
302
|
-
await compiler.hooks.setup.promise(task);
|
|
303
|
-
}
|
|
304
|
-
};
|
|
347
|
+
// src/utils/json-schema-utils/is-non-array.ts
|
|
348
|
+
function isNonArray(schema) {
|
|
349
|
+
return typeof schema.type === "string" && schema.type !== "array";
|
|
305
350
|
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
skip: options?.skip,
|
|
311
|
-
task: (context, task) => task.newListr(
|
|
312
|
-
[
|
|
313
|
-
main(compiler, options),
|
|
314
|
-
{
|
|
315
|
-
task: (context2, task2) => compiler.hooks.afterSetup.promise(task2)
|
|
316
|
-
}
|
|
317
|
-
],
|
|
318
|
-
{
|
|
319
|
-
concurrent: false
|
|
320
|
-
}
|
|
321
|
-
)
|
|
322
|
-
};
|
|
351
|
+
|
|
352
|
+
// src/utils/json-schema-utils/is-ref.ts
|
|
353
|
+
function isRef(schema) {
|
|
354
|
+
return "$ref" in schema;
|
|
323
355
|
}
|
|
324
356
|
|
|
325
|
-
// src/
|
|
326
|
-
var
|
|
327
|
-
|
|
357
|
+
// src/utils/json-schema-utils/index.ts
|
|
358
|
+
var JsonSchemaUtils = class {
|
|
359
|
+
static isRef = isRef;
|
|
360
|
+
static isArray = isArray;
|
|
361
|
+
static isNonArray = isNonArray;
|
|
362
|
+
static isMixed = isMixed;
|
|
363
|
+
};
|
|
364
|
+
|
|
365
|
+
// src/plugins/generate-micro-function/generate-micro-function.plugin.ts
|
|
366
|
+
var import_tapable2 = require("tapable");
|
|
367
|
+
|
|
368
|
+
// src/plugins/generate-micro-function/constants/metadata-storage.ts
|
|
369
|
+
var MetadataStorage3 = /* @__PURE__ */ new WeakMap();
|
|
370
|
+
|
|
371
|
+
// src/plugins/generate-micro-function/generators/micro_function/micro-function.generator.ts
|
|
372
|
+
var R20 = __toESM(require("ramda"), 1);
|
|
373
|
+
var path8 = __toESM(require("path"), 1);
|
|
374
|
+
var changeCase6 = __toESM(require("change-case"), 1);
|
|
328
375
|
|
|
329
376
|
// src/models/artifact.ts
|
|
330
|
-
var
|
|
377
|
+
var path2 = __toESM(require("path"), 1);
|
|
331
378
|
|
|
332
379
|
// src/models/anchor.ts
|
|
333
380
|
var AnchorBlock = class {
|
|
@@ -413,11 +460,11 @@ var Artifact = class {
|
|
|
413
460
|
constructor(options) {
|
|
414
461
|
this.id = options.id;
|
|
415
462
|
this.filepath = options.filepath;
|
|
416
|
-
this.extensionName = options.extensionName ||
|
|
463
|
+
this.extensionName = options.extensionName || path2.extname(options.filepath);
|
|
417
464
|
this.content = options.content;
|
|
418
465
|
}
|
|
419
466
|
get dirname() {
|
|
420
|
-
return
|
|
467
|
+
return path2.dirname(this.filepath);
|
|
421
468
|
}
|
|
422
469
|
renderer() {
|
|
423
470
|
return `${HeaderComment}${this.content}`;
|
|
@@ -433,10 +480,14 @@ var ModuleDefinition = class _ModuleDefinition {
|
|
|
433
480
|
address;
|
|
434
481
|
constructor(name, address) {
|
|
435
482
|
this.name = name;
|
|
436
|
-
|
|
483
|
+
if (typeof address === "string") {
|
|
484
|
+
this.address = { url: address, headers: {}, encoding: "utf8" };
|
|
485
|
+
} else {
|
|
486
|
+
this.address = address;
|
|
487
|
+
}
|
|
437
488
|
}
|
|
438
489
|
static unknown() {
|
|
439
|
-
return new _ModuleDefinition("", "");
|
|
490
|
+
return new _ModuleDefinition("", { url: "", headers: {}, encoding: "utf8" });
|
|
440
491
|
}
|
|
441
492
|
};
|
|
442
493
|
|
|
@@ -648,8 +699,8 @@ var ApiDocumentV3_1 = class _ApiDocumentV3_1 {
|
|
|
648
699
|
}
|
|
649
700
|
isRefDefined($ref) {
|
|
650
701
|
if ($ref.startsWith("#/")) {
|
|
651
|
-
const
|
|
652
|
-
return R5.path(
|
|
702
|
+
const path12 = $ref.replace("#/", "").split("/");
|
|
703
|
+
return R5.path(path12, this.specification) !== void 0;
|
|
653
704
|
}
|
|
654
705
|
return false;
|
|
655
706
|
}
|
|
@@ -661,532 +712,22 @@ var ApiDocumentV3_1 = class _ApiDocumentV3_1 {
|
|
|
661
712
|
// src/models/asset.ts
|
|
662
713
|
var Asset = class {
|
|
663
714
|
path;
|
|
664
|
-
constructor(
|
|
665
|
-
this.path =
|
|
666
|
-
}
|
|
667
|
-
};
|
|
668
|
-
|
|
669
|
-
// src/exception.ts
|
|
670
|
-
var import_ts_custom_error = require("ts-custom-error");
|
|
671
|
-
var import_word_wrap = __toESM(require("word-wrap"), 1);
|
|
672
|
-
var Exception = class extends import_ts_custom_error.CustomError {
|
|
673
|
-
constructor(module2, message) {
|
|
674
|
-
const moduleName = typeof module2 === "string" ? module2 : module2.name;
|
|
675
|
-
const msg = (0, import_word_wrap.default)(message, { width: 60, indent: " " });
|
|
676
|
-
super(`${moduleName} module failed to compile:
|
|
677
|
-
${msg}`);
|
|
678
|
-
Object.defineProperty(this, "name", { value: "KeqCLI_Exception" });
|
|
715
|
+
constructor(path12) {
|
|
716
|
+
this.path = path12;
|
|
679
717
|
}
|
|
680
718
|
};
|
|
681
719
|
|
|
682
|
-
// src/
|
|
683
|
-
|
|
684
|
-
let value;
|
|
685
|
-
for (const key of $ref.split("/")) {
|
|
686
|
-
if (key === "#") {
|
|
687
|
-
value = swagger;
|
|
688
|
-
} else {
|
|
689
|
-
value = value[key];
|
|
690
|
-
}
|
|
691
|
-
if (!value) break;
|
|
692
|
-
}
|
|
693
|
-
return value;
|
|
694
|
-
}
|
|
695
|
-
|
|
696
|
-
// src/utils/openapi-utils/dereference-operation.ts
|
|
697
|
-
var R8 = __toESM(require("ramda"), 1);
|
|
698
|
-
var import_jsonpointer2 = __toESM(require("jsonpointer"), 1);
|
|
699
|
-
var import_jsonpath_plus4 = require("jsonpath-plus");
|
|
720
|
+
// src/plugins/generate-declaration/generate-declaration.plugin.ts
|
|
721
|
+
var import_tapable = require("tapable");
|
|
700
722
|
|
|
701
|
-
// src/
|
|
702
|
-
var
|
|
703
|
-
var
|
|
704
|
-
var import_jsonpath_plus3 = require("jsonpath-plus");
|
|
723
|
+
// src/plugins/generate-declaration/generators/operation-declaration/operation.generator.ts
|
|
724
|
+
var path7 = __toESM(require("path"), 1);
|
|
725
|
+
var changeCase5 = __toESM(require("change-case"), 1);
|
|
705
726
|
|
|
706
|
-
// src/
|
|
707
|
-
var
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
const path13 = $ref.replace("#/", "").split("/");
|
|
711
|
-
return R6.path(path13, swagger) !== void 0;
|
|
712
|
-
}
|
|
713
|
-
return false;
|
|
714
|
-
}
|
|
715
|
-
|
|
716
|
-
// src/utils/openapi-utils/remove-undefined-ref.ts
|
|
717
|
-
function removeUndefinedRef(swagger) {
|
|
718
|
-
const shadow = R7.clone(swagger);
|
|
719
|
-
const matches = (0, import_jsonpath_plus3.JSONPath)({
|
|
720
|
-
path: "$..*['$ref']^",
|
|
721
|
-
json: swagger,
|
|
722
|
-
resultType: "all"
|
|
723
|
-
});
|
|
724
|
-
for (const match of matches) {
|
|
725
|
-
if (match.value.$ref && !isRefDefined(match.value.$ref, swagger)) {
|
|
726
|
-
import_jsonpointer.default.set(shadow, match.pointer, R7.omit(["$ref"], match.value));
|
|
727
|
-
}
|
|
728
|
-
}
|
|
729
|
-
return shadow;
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
// src/utils/openapi-utils/dereference-operation.ts
|
|
733
|
-
function dereferencePathObject(swagger) {
|
|
734
|
-
const matches = (0, import_jsonpath_plus4.JSONPath)({
|
|
735
|
-
path: "$.paths.*.$ref^",
|
|
736
|
-
json: swagger,
|
|
737
|
-
resultType: "all"
|
|
738
|
-
});
|
|
739
|
-
for (const match of matches) {
|
|
740
|
-
const value = dereference(match.value.$ref, swagger);
|
|
741
|
-
import_jsonpointer2.default.set(swagger, match.pointer, value);
|
|
742
|
-
}
|
|
743
|
-
}
|
|
744
|
-
function dereferenceRequestBody(swagger) {
|
|
745
|
-
const matches = (0, import_jsonpath_plus4.JSONPath)({
|
|
746
|
-
path: "$.paths.*.*.requestBody.$ref^",
|
|
747
|
-
json: swagger,
|
|
748
|
-
resultType: "all"
|
|
749
|
-
});
|
|
750
|
-
for (const match of matches) {
|
|
751
|
-
const value = dereference(match.value.$ref, swagger);
|
|
752
|
-
import_jsonpointer2.default.set(swagger, match.pointer, value);
|
|
753
|
-
}
|
|
754
|
-
}
|
|
755
|
-
function dereferenceResponses(swagger) {
|
|
756
|
-
const matches = [
|
|
757
|
-
...(0, import_jsonpath_plus4.JSONPath)({
|
|
758
|
-
path: "$.paths.*.*.responses.*.$ref^",
|
|
759
|
-
json: swagger,
|
|
760
|
-
resultType: "all"
|
|
761
|
-
}),
|
|
762
|
-
...(0, import_jsonpath_plus4.JSONPath)({
|
|
763
|
-
path: "$.paths.*.*.responses.*.headers.*.$ref^",
|
|
764
|
-
json: swagger,
|
|
765
|
-
resultType: "all"
|
|
766
|
-
})
|
|
767
|
-
];
|
|
768
|
-
for (const match of matches) {
|
|
769
|
-
const value = dereference(match.value.$ref, swagger);
|
|
770
|
-
import_jsonpointer2.default.set(swagger, match.pointer, value);
|
|
771
|
-
}
|
|
772
|
-
}
|
|
773
|
-
function dereferenceParameters(swagger) {
|
|
774
|
-
const matches = (0, import_jsonpath_plus4.JSONPath)({
|
|
775
|
-
path: "$.paths.*.*.parameters.*.$ref^",
|
|
776
|
-
json: swagger,
|
|
777
|
-
resultType: "all"
|
|
778
|
-
});
|
|
779
|
-
for (const match of matches) {
|
|
780
|
-
const value = dereference(match.value.$ref, swagger);
|
|
781
|
-
import_jsonpointer2.default.set(swagger, match.pointer, value);
|
|
782
|
-
}
|
|
783
|
-
}
|
|
784
|
-
function dereferenceOperation(swagger) {
|
|
785
|
-
const shadow = R8.clone(swagger);
|
|
786
|
-
dereferencePathObject(shadow);
|
|
787
|
-
dereferenceRequestBody(shadow);
|
|
788
|
-
dereferenceResponses(shadow);
|
|
789
|
-
dereferenceParameters(shadow);
|
|
790
|
-
return removeUndefinedRef(shadow);
|
|
791
|
-
}
|
|
792
|
-
|
|
793
|
-
// src/utils/json-schema-utils/is-array.ts
|
|
794
|
-
function isArray(schema) {
|
|
795
|
-
return schema.type === "array";
|
|
796
|
-
}
|
|
797
|
-
|
|
798
|
-
// src/utils/json-schema-utils/is-mixed.ts
|
|
799
|
-
function isMixed(schema) {
|
|
800
|
-
return Array.isArray(schema.type);
|
|
801
|
-
}
|
|
802
|
-
|
|
803
|
-
// src/utils/json-schema-utils/is-non-array.ts
|
|
804
|
-
function isNonArray(schema) {
|
|
805
|
-
return typeof schema.type === "string" && schema.type !== "array";
|
|
806
|
-
}
|
|
807
|
-
|
|
808
|
-
// src/utils/json-schema-utils/is-ref.ts
|
|
809
|
-
function isRef(schema) {
|
|
810
|
-
return "$ref" in schema;
|
|
811
|
-
}
|
|
812
|
-
|
|
813
|
-
// src/utils/json-schema-utils/index.ts
|
|
814
|
-
var JsonSchemaUtils = class {
|
|
815
|
-
static isRef = isRef;
|
|
816
|
-
static isArray = isArray;
|
|
817
|
-
static isNonArray = isNonArray;
|
|
818
|
-
static isMixed = isMixed;
|
|
819
|
-
};
|
|
820
|
-
|
|
821
|
-
// src/utils/openapi-utils/dereference-deep.ts
|
|
822
|
-
function dereferenceDeep($ref, swagger) {
|
|
823
|
-
const stack = [$ref];
|
|
824
|
-
let value;
|
|
825
|
-
while (true) {
|
|
826
|
-
const last2 = stack[stack.length - 1];
|
|
827
|
-
value = dereference(last2, swagger);
|
|
828
|
-
if (JsonSchemaUtils.isRef(value)) {
|
|
829
|
-
if (!stack.includes(value.$ref)) {
|
|
830
|
-
stack.push(value.$ref);
|
|
831
|
-
continue;
|
|
832
|
-
} else {
|
|
833
|
-
throw new Error(`Circular reference detected: ${stack.join(" -> ")} -> ${value.$ref}`);
|
|
834
|
-
}
|
|
835
|
-
}
|
|
836
|
-
break;
|
|
837
|
-
}
|
|
838
|
-
return value;
|
|
839
|
-
}
|
|
840
|
-
|
|
841
|
-
// src/utils/openapi-utils/to-3_1.ts
|
|
842
|
-
var import_openapi_parser = require("@scalar/openapi-parser");
|
|
843
|
-
function To3_1(openapi) {
|
|
844
|
-
const { specification } = (0, import_openapi_parser.upgrade)(openapi);
|
|
845
|
-
return specification;
|
|
846
|
-
}
|
|
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
|
-
|
|
873
|
-
// src/utils/openapi-utils/index.ts
|
|
874
|
-
var OpenapiUtils = class {
|
|
875
|
-
static isRefDefined = isRefDefined;
|
|
876
|
-
static dereference = dereference;
|
|
877
|
-
static dereferenceDeep = dereferenceDeep;
|
|
878
|
-
static removeUndefinedRef = removeUndefinedRef;
|
|
879
|
-
static dereferenceOperation = dereferenceOperation;
|
|
880
|
-
static mapOperation = mapOperation;
|
|
881
|
-
static mapParameter = mapParameter;
|
|
882
|
-
// static updateOperationId = updateOperationId
|
|
883
|
-
static to3_1 = To3_1;
|
|
884
|
-
};
|
|
885
|
-
|
|
886
|
-
// src/compiler/tasks/download/index.ts
|
|
887
|
-
function main2(compiler, options) {
|
|
888
|
-
return {
|
|
889
|
-
task: (context, task) => {
|
|
890
|
-
if (!context.rc || !context.matcher) {
|
|
891
|
-
throw new Error("Please run setup task first.");
|
|
892
|
-
}
|
|
893
|
-
const rc = context.rc;
|
|
894
|
-
const matcher = context.matcher;
|
|
895
|
-
context.documents = [];
|
|
896
|
-
return task.newListr(
|
|
897
|
-
Object.entries(rc.modules).map(([moduleName, address]) => new ModuleDefinition(moduleName, address)).map((moduleDefinition) => ({
|
|
898
|
-
title: moduleDefinition.name,
|
|
899
|
-
task: async (ctx, task2) => {
|
|
900
|
-
if (options?.skipIgnoredModules && matcher.isModuleIgnored(moduleDefinition)) {
|
|
901
|
-
task2.skip(`(${moduleDefinition.name}) is ignored`);
|
|
902
|
-
return;
|
|
903
|
-
}
|
|
904
|
-
task2.output = `Downloaded from ${moduleDefinition.address}`;
|
|
905
|
-
const content = await compiler.hooks.download.promise(moduleDefinition.address, moduleDefinition, task2);
|
|
906
|
-
if (!content) {
|
|
907
|
-
throw new Exception(moduleDefinition, `Cannot download document from ${moduleDefinition.address}`);
|
|
908
|
-
}
|
|
909
|
-
const spec = JSON.parse(content);
|
|
910
|
-
const { valid, errors } = await (0, import_openapi_parser2.validate)(spec);
|
|
911
|
-
if (!valid) {
|
|
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:
|
|
913
|
-
${errors?.map((e) => ` - ${e.message}`).join("\n")}`;
|
|
914
|
-
task2.output = message;
|
|
915
|
-
}
|
|
916
|
-
OpenapiUtils.dereferenceOperation(spec);
|
|
917
|
-
const document = new ApiDocumentV3_1(
|
|
918
|
-
spec,
|
|
919
|
-
moduleDefinition
|
|
920
|
-
);
|
|
921
|
-
ctx.documents?.push(document);
|
|
922
|
-
}
|
|
923
|
-
})),
|
|
924
|
-
{
|
|
925
|
-
concurrent: true,
|
|
926
|
-
exitOnError: false,
|
|
927
|
-
collectErrors: "minimal",
|
|
928
|
-
rendererOptions: {
|
|
929
|
-
collapseSubtasks: false,
|
|
930
|
-
// collapseSkips: false,
|
|
931
|
-
suffixSkips: true,
|
|
932
|
-
timer: import_listr2.PRESET_TIMER
|
|
933
|
-
}
|
|
934
|
-
}
|
|
935
|
-
);
|
|
936
|
-
}
|
|
937
|
-
};
|
|
938
|
-
}
|
|
939
|
-
function createDownloadTask(compiler, options) {
|
|
940
|
-
return {
|
|
941
|
-
title: "Download",
|
|
942
|
-
enabled: options?.enabled,
|
|
943
|
-
skip: options?.skip,
|
|
944
|
-
task: (_, task) => task.newListr(
|
|
945
|
-
[
|
|
946
|
-
main2(compiler, options),
|
|
947
|
-
{
|
|
948
|
-
task: (context, task2) => compiler.hooks.afterDownload.promise(task2)
|
|
949
|
-
}
|
|
950
|
-
],
|
|
951
|
-
{
|
|
952
|
-
concurrent: false
|
|
953
|
-
}
|
|
954
|
-
)
|
|
955
|
-
};
|
|
956
|
-
}
|
|
957
|
-
|
|
958
|
-
// src/compiler/tasks/persist/index.ts
|
|
959
|
-
var path6 = __toESM(require("path"), 1);
|
|
960
|
-
var import_fs_extra3 = __toESM(require("fs-extra"), 1);
|
|
961
|
-
function createPersistArtifactTask() {
|
|
962
|
-
return {
|
|
963
|
-
title: "Write files",
|
|
964
|
-
task: async (context, task) => {
|
|
965
|
-
if (!context.rc) throw new Error("Please run setup task first.");
|
|
966
|
-
if (!context.artifacts || context.artifacts.length === 0) {
|
|
967
|
-
task.skip("No compiled artifacts to persist.");
|
|
968
|
-
return;
|
|
969
|
-
}
|
|
970
|
-
const rc = context.rc;
|
|
971
|
-
const artifacts = context.artifacts;
|
|
972
|
-
const total = artifacts.length;
|
|
973
|
-
let completed = 0;
|
|
974
|
-
const files = await Promise.all(artifacts.map(async (artifact) => {
|
|
975
|
-
const realpath = `./${path6.join(rc.outdir, artifact.filepath)}`;
|
|
976
|
-
await import_fs_extra3.default.ensureFile(realpath);
|
|
977
|
-
await import_fs_extra3.default.writeFile(realpath, artifact.renderer());
|
|
978
|
-
completed += 1;
|
|
979
|
-
task.output = `Persisted ${completed}/${total} files`;
|
|
980
|
-
return new Asset(path6.resolve(realpath));
|
|
981
|
-
}));
|
|
982
|
-
context.assets = files;
|
|
983
|
-
}
|
|
984
|
-
};
|
|
985
|
-
}
|
|
986
|
-
function createPersistIgnoreTask() {
|
|
987
|
-
return {
|
|
988
|
-
title: "Update .keqignore",
|
|
989
|
-
task: async (context, task) => {
|
|
990
|
-
if (!context.matcher) throw new Error("Please run setup task first.");
|
|
991
|
-
const matcher = context.matcher;
|
|
992
|
-
await matcher.write(".keqignore");
|
|
993
|
-
}
|
|
994
|
-
};
|
|
995
|
-
}
|
|
996
|
-
function main3() {
|
|
997
|
-
return {
|
|
998
|
-
task: (context, task) => task.newListr(
|
|
999
|
-
[
|
|
1000
|
-
createPersistArtifactTask(),
|
|
1001
|
-
createPersistIgnoreTask()
|
|
1002
|
-
],
|
|
1003
|
-
{
|
|
1004
|
-
concurrent: true,
|
|
1005
|
-
rendererOptions: {
|
|
1006
|
-
collapseSubtasks: true
|
|
1007
|
-
}
|
|
1008
|
-
}
|
|
1009
|
-
)
|
|
1010
|
-
};
|
|
1011
|
-
}
|
|
1012
|
-
function createPersistTask(compiler, options) {
|
|
1013
|
-
return {
|
|
1014
|
-
title: "Persist",
|
|
1015
|
-
enabled: options?.enabled,
|
|
1016
|
-
skip: options?.skip,
|
|
1017
|
-
task: (context, task) => task.newListr(
|
|
1018
|
-
[
|
|
1019
|
-
main3(),
|
|
1020
|
-
{
|
|
1021
|
-
task: (context2, task2) => compiler.hooks.afterPersist.promise(task2)
|
|
1022
|
-
}
|
|
1023
|
-
],
|
|
1024
|
-
{
|
|
1025
|
-
concurrent: false
|
|
1026
|
-
}
|
|
1027
|
-
)
|
|
1028
|
-
};
|
|
1029
|
-
}
|
|
1030
|
-
|
|
1031
|
-
// src/compiler/tasks/compile/index.ts
|
|
1032
|
-
function main4(compiler) {
|
|
1033
|
-
return {
|
|
1034
|
-
task: async (context, task) => {
|
|
1035
|
-
if (!context.rc) throw new Error("Please run setup task first.");
|
|
1036
|
-
if (!context.documents) throw new Error("Please run shaking task first.");
|
|
1037
|
-
context.artifacts = [];
|
|
1038
|
-
await compiler.hooks.compile.promise(task);
|
|
1039
|
-
}
|
|
1040
|
-
};
|
|
1041
|
-
}
|
|
1042
|
-
function createCompileTask(compiler, options) {
|
|
1043
|
-
return {
|
|
1044
|
-
title: "Compile",
|
|
1045
|
-
enabled: options?.enabled,
|
|
1046
|
-
skip: options?.skip,
|
|
1047
|
-
task: (context, task) => task.newListr(
|
|
1048
|
-
[
|
|
1049
|
-
{
|
|
1050
|
-
task: (context2, task2) => compiler.hooks.beforeCompile.promise(task2)
|
|
1051
|
-
},
|
|
1052
|
-
main4(compiler),
|
|
1053
|
-
{
|
|
1054
|
-
task: (context2, task2) => compiler.hooks.afterCompile.promise(task2)
|
|
1055
|
-
}
|
|
1056
|
-
],
|
|
1057
|
-
{
|
|
1058
|
-
concurrent: false
|
|
1059
|
-
}
|
|
1060
|
-
)
|
|
1061
|
-
};
|
|
1062
|
-
}
|
|
1063
|
-
|
|
1064
|
-
// src/compiler/intercepter/print-information.ts
|
|
1065
|
-
function proxyTaskWrapper(pluginName, task) {
|
|
1066
|
-
return new Proxy(task, {
|
|
1067
|
-
set(target, prop2, value) {
|
|
1068
|
-
if (prop2 !== "output") {
|
|
1069
|
-
return Reflect.set(target, prop2, value);
|
|
1070
|
-
}
|
|
1071
|
-
target.output = `[Plugin: ${pluginName}] ${value}`;
|
|
1072
|
-
return true;
|
|
1073
|
-
}
|
|
1074
|
-
});
|
|
1075
|
-
}
|
|
1076
|
-
function printInformation(taskIndex) {
|
|
1077
|
-
return {
|
|
1078
|
-
register: (tap) => {
|
|
1079
|
-
const fn = tap.fn;
|
|
1080
|
-
if (tap.type === "promise") {
|
|
1081
|
-
tap.fn = (...args) => {
|
|
1082
|
-
const task = args[taskIndex];
|
|
1083
|
-
const proxyTask = proxyTaskWrapper(tap.name, task);
|
|
1084
|
-
args[taskIndex] = proxyTask;
|
|
1085
|
-
proxyTask.output = "Processing...";
|
|
1086
|
-
return fn(...args);
|
|
1087
|
-
};
|
|
1088
|
-
}
|
|
1089
|
-
if (tap.type === "sync") {
|
|
1090
|
-
tap.fn = (...args) => {
|
|
1091
|
-
const task = args[taskIndex];
|
|
1092
|
-
const proxyTask = proxyTaskWrapper(tap.name, task);
|
|
1093
|
-
args[taskIndex] = proxyTask;
|
|
1094
|
-
proxyTask.output = "Processing...";
|
|
1095
|
-
return fn(...args);
|
|
1096
|
-
};
|
|
1097
|
-
}
|
|
1098
|
-
if (tap.type === "async") {
|
|
1099
|
-
tap.fn = (...args) => {
|
|
1100
|
-
const task = args[taskIndex];
|
|
1101
|
-
const proxyTask = proxyTaskWrapper(tap.name, task);
|
|
1102
|
-
args[taskIndex] = proxyTask;
|
|
1103
|
-
proxyTask.output = "Processing...";
|
|
1104
|
-
return fn(...args);
|
|
1105
|
-
};
|
|
1106
|
-
}
|
|
1107
|
-
return tap;
|
|
1108
|
-
}
|
|
1109
|
-
};
|
|
1110
|
-
}
|
|
1111
|
-
|
|
1112
|
-
// src/compiler/intercepter/perfect-error-message.ts
|
|
1113
|
-
var R10 = __toESM(require("ramda"), 1);
|
|
1114
|
-
function perfectErrorMessage() {
|
|
1115
|
-
return {
|
|
1116
|
-
register: (tap) => {
|
|
1117
|
-
const fn = tap.fn;
|
|
1118
|
-
function prefix(err) {
|
|
1119
|
-
if (err instanceof Error) {
|
|
1120
|
-
err.message = `[Plugin: ${tap.name}] ${err.message}`;
|
|
1121
|
-
}
|
|
1122
|
-
}
|
|
1123
|
-
if (tap.type === "promise") {
|
|
1124
|
-
tap.fn = async (...args) => {
|
|
1125
|
-
try {
|
|
1126
|
-
return await fn(...args);
|
|
1127
|
-
} catch (err) {
|
|
1128
|
-
prefix(err);
|
|
1129
|
-
throw err;
|
|
1130
|
-
}
|
|
1131
|
-
};
|
|
1132
|
-
}
|
|
1133
|
-
if (tap.type === "sync") {
|
|
1134
|
-
tap.fn = (...args) => {
|
|
1135
|
-
try {
|
|
1136
|
-
return fn(...args);
|
|
1137
|
-
} catch (err) {
|
|
1138
|
-
prefix(err);
|
|
1139
|
-
throw err;
|
|
1140
|
-
}
|
|
1141
|
-
};
|
|
1142
|
-
}
|
|
1143
|
-
if (tap.type === "async") {
|
|
1144
|
-
tap.fn = (...args) => {
|
|
1145
|
-
const callback = R10.last(args);
|
|
1146
|
-
return fn(...R10.init(args), (err, result) => {
|
|
1147
|
-
prefix(err);
|
|
1148
|
-
return callback(err, result);
|
|
1149
|
-
});
|
|
1150
|
-
};
|
|
1151
|
-
}
|
|
1152
|
-
return tap;
|
|
1153
|
-
}
|
|
1154
|
-
};
|
|
1155
|
-
}
|
|
1156
|
-
|
|
1157
|
-
// src/plugins/eslint/index.ts
|
|
1158
|
-
var import_eslint = require("eslint");
|
|
1159
|
-
|
|
1160
|
-
// src/plugins/prettier/prettier.plugin.ts
|
|
1161
|
-
var import_child_process = require("child_process");
|
|
1162
|
-
var import_util = require("util");
|
|
1163
|
-
var execAsync = (0, import_util.promisify)(import_child_process.exec);
|
|
1164
|
-
|
|
1165
|
-
// src/plugins/body-fallback/index.ts
|
|
1166
|
-
var R22 = __toESM(require("ramda"), 1);
|
|
1167
|
-
|
|
1168
|
-
// src/plugins/generate-micro-function/generate-micro-function.plugin.ts
|
|
1169
|
-
var import_tapable2 = require("tapable");
|
|
1170
|
-
|
|
1171
|
-
// src/plugins/generate-micro-function/constants/metadata-storage.ts
|
|
1172
|
-
var MetadataStorage = /* @__PURE__ */ new WeakMap();
|
|
1173
|
-
|
|
1174
|
-
// src/plugins/generate-micro-function/generators/micro_function/micro-function.generator.ts
|
|
1175
|
-
var R21 = __toESM(require("ramda"), 1);
|
|
1176
|
-
var path10 = __toESM(require("path"), 1);
|
|
1177
|
-
var changeCase6 = __toESM(require("change-case"), 1);
|
|
1178
|
-
|
|
1179
|
-
// src/plugins/generate-declaration/generate-declaration.plugin.ts
|
|
1180
|
-
var import_tapable = require("tapable");
|
|
1181
|
-
|
|
1182
|
-
// src/plugins/generate-declaration/generators/operation-declaration/operation.generator.ts
|
|
1183
|
-
var path9 = __toESM(require("path"), 1);
|
|
1184
|
-
var changeCase5 = __toESM(require("change-case"), 1);
|
|
1185
|
-
|
|
1186
|
-
// src/transformers/json-schema/comment.renderer.ts
|
|
1187
|
-
var CommentRenderer = class {
|
|
1188
|
-
constructor(schema) {
|
|
1189
|
-
this.schema = schema;
|
|
727
|
+
// src/transformers/json-schema/comment.renderer.ts
|
|
728
|
+
var CommentRenderer = class {
|
|
729
|
+
constructor(schema) {
|
|
730
|
+
this.schema = schema;
|
|
1190
731
|
}
|
|
1191
732
|
render() {
|
|
1192
733
|
const schema = this.schema;
|
|
@@ -1211,7 +752,7 @@ var CommentRenderer = class {
|
|
|
1211
752
|
};
|
|
1212
753
|
|
|
1213
754
|
// src/transformers/json-schema/declaration.renderer.ts
|
|
1214
|
-
var
|
|
755
|
+
var R7 = __toESM(require("ramda"), 1);
|
|
1215
756
|
|
|
1216
757
|
// src/utils/indent.ts
|
|
1217
758
|
function indent(space, text) {
|
|
@@ -1221,9 +762,9 @@ function indent(space, text) {
|
|
|
1221
762
|
}
|
|
1222
763
|
|
|
1223
764
|
// src/transformers/json-schema/reference.transformer.ts
|
|
1224
|
-
var
|
|
765
|
+
var R6 = __toESM(require("ramda"), 1);
|
|
1225
766
|
var ReferenceTransformer = class {
|
|
1226
|
-
static toDeclaration(schema, alias2 =
|
|
767
|
+
static toDeclaration(schema, alias2 = R6.identity) {
|
|
1227
768
|
if (!schema.$ref || !schema.$ref.startsWith("#")) return `unknown /* ${schema.$ref.replace("*/", "*\\/")} */`;
|
|
1228
769
|
const parts = schema.$ref.split("/");
|
|
1229
770
|
return alias2(parts[parts.length - 1]) || "unknown";
|
|
@@ -1279,7 +820,7 @@ var DeclarationRenderer = class {
|
|
|
1279
820
|
return "any[]";
|
|
1280
821
|
}
|
|
1281
822
|
renderObject(schema) {
|
|
1282
|
-
if ((!schema.properties ||
|
|
823
|
+
if ((!schema.properties || R7.isEmpty(schema.properties)) && (!schema.additionalProperties || R7.isEmpty(schema.additionalProperties))) {
|
|
1283
824
|
return "object";
|
|
1284
825
|
}
|
|
1285
826
|
const $properties = Object.entries(schema.properties || {}).map(([propertyName, propertySchema]) => {
|
|
@@ -1345,7 +886,7 @@ var JsonSchemaTransformer = class {
|
|
|
1345
886
|
};
|
|
1346
887
|
|
|
1347
888
|
// src/transformers/schema-definition/schema-definition.transformer.ts
|
|
1348
|
-
var
|
|
889
|
+
var R8 = __toESM(require("ramda"), 1);
|
|
1349
890
|
var SchemaDefinitionTransformer = class {
|
|
1350
891
|
static toDeclaration(schemaDefinition, options) {
|
|
1351
892
|
const dependencies = schemaDefinition.getDependencies();
|
|
@@ -1365,7 +906,7 @@ var SchemaDefinitionTransformer = class {
|
|
|
1365
906
|
`type ${schemaDefinition.name} = unknown`,
|
|
1366
907
|
"",
|
|
1367
908
|
"/* @anchor:file:end */"
|
|
1368
|
-
].filter(
|
|
909
|
+
].filter(R8.isNotNil).join("\n");
|
|
1369
910
|
}
|
|
1370
911
|
if (JsonSchemaUtils.isNonArray(schemaDefinition.schema) && schemaDefinition.schema.type === "object") {
|
|
1371
912
|
const $schema = JsonSchemaTransformer.toDeclaration(schemaDefinition.schema);
|
|
@@ -1378,7 +919,7 @@ var SchemaDefinitionTransformer = class {
|
|
|
1378
919
|
$declaration,
|
|
1379
920
|
"",
|
|
1380
921
|
"/* @anchor:file:end */"
|
|
1381
|
-
].filter(
|
|
922
|
+
].filter(R8.isNotNil).join("\n");
|
|
1382
923
|
}
|
|
1383
924
|
return [
|
|
1384
925
|
"/* @anchor:file:start */",
|
|
@@ -1388,12 +929,12 @@ var SchemaDefinitionTransformer = class {
|
|
|
1388
929
|
`export type ${schemaDefinition.name} = ${JsonSchemaTransformer.toDeclaration(schemaDefinition.schema)}`,
|
|
1389
930
|
"",
|
|
1390
931
|
"/* @anchor:file:end */"
|
|
1391
|
-
].filter(
|
|
932
|
+
].filter(R8.isNotNil).join("\n");
|
|
1392
933
|
}
|
|
1393
934
|
};
|
|
1394
935
|
|
|
1395
936
|
// src/transformers/operation-definition/comment.renderer.ts
|
|
1396
|
-
var
|
|
937
|
+
var R9 = __toESM(require("ramda"), 1);
|
|
1397
938
|
var CommentRenderer2 = class {
|
|
1398
939
|
constructor(operationDefinition) {
|
|
1399
940
|
this.operationDefinition = operationDefinition;
|
|
@@ -1403,11 +944,11 @@ var CommentRenderer2 = class {
|
|
|
1403
944
|
if (!operation.summary && !operation.description) return "";
|
|
1404
945
|
const lines = ["/**"];
|
|
1405
946
|
if (operation.summary && typeof operation.summary === "string") {
|
|
1406
|
-
lines.push(` * ${
|
|
947
|
+
lines.push(` * ${R9.trim(operation.summary)}`);
|
|
1407
948
|
lines.push(" *");
|
|
1408
949
|
}
|
|
1409
950
|
if (operation.description && typeof operation.description === "string") {
|
|
1410
|
-
lines.push(` * @description ${
|
|
951
|
+
lines.push(` * @description ${R9.trim(operation.description)}`);
|
|
1411
952
|
}
|
|
1412
953
|
lines.push(" */");
|
|
1413
954
|
return lines.join("\n");
|
|
@@ -1415,7 +956,7 @@ var CommentRenderer2 = class {
|
|
|
1415
956
|
};
|
|
1416
957
|
|
|
1417
958
|
// src/transformers/operation-definition/declaration.renderer.ts
|
|
1418
|
-
var
|
|
959
|
+
var R14 = __toESM(require("ramda"), 1);
|
|
1419
960
|
|
|
1420
961
|
// src/transformers/operation-definition/utils/type-name-factory.ts
|
|
1421
962
|
var changeCase = __toESM(require("change-case"), 1);
|
|
@@ -1424,6 +965,182 @@ function typeNameFactory(operationDefinition) {
|
|
|
1424
965
|
return (name) => `${pascalCaseOperationId}${name}`;
|
|
1425
966
|
}
|
|
1426
967
|
|
|
968
|
+
// src/utils/openapi-utils/dereference.ts
|
|
969
|
+
function dereference($ref, swagger) {
|
|
970
|
+
let value;
|
|
971
|
+
for (const key of $ref.split("/")) {
|
|
972
|
+
if (key === "#") {
|
|
973
|
+
value = swagger;
|
|
974
|
+
} else {
|
|
975
|
+
value = value[key];
|
|
976
|
+
}
|
|
977
|
+
if (!value) break;
|
|
978
|
+
}
|
|
979
|
+
return value;
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
// src/utils/openapi-utils/dereference-operation.ts
|
|
983
|
+
var R12 = __toESM(require("ramda"), 1);
|
|
984
|
+
var import_jsonpointer2 = __toESM(require("jsonpointer"), 1);
|
|
985
|
+
var import_jsonpath_plus4 = require("jsonpath-plus");
|
|
986
|
+
|
|
987
|
+
// src/utils/openapi-utils/remove-undefined-ref.ts
|
|
988
|
+
var R11 = __toESM(require("ramda"), 1);
|
|
989
|
+
var import_jsonpointer = __toESM(require("jsonpointer"), 1);
|
|
990
|
+
var import_jsonpath_plus3 = require("jsonpath-plus");
|
|
991
|
+
|
|
992
|
+
// src/utils/openapi-utils/is-ref-defined.ts
|
|
993
|
+
var R10 = __toESM(require("ramda"), 1);
|
|
994
|
+
function isRefDefined($ref, swagger) {
|
|
995
|
+
if ($ref.startsWith("#/")) {
|
|
996
|
+
const path12 = $ref.replace("#/", "").split("/");
|
|
997
|
+
return R10.path(path12, swagger) !== void 0;
|
|
998
|
+
}
|
|
999
|
+
return false;
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
// src/utils/openapi-utils/remove-undefined-ref.ts
|
|
1003
|
+
function removeUndefinedRef(swagger) {
|
|
1004
|
+
const shadow = R11.clone(swagger);
|
|
1005
|
+
const matches = (0, import_jsonpath_plus3.JSONPath)({
|
|
1006
|
+
path: "$..*['$ref']^",
|
|
1007
|
+
json: swagger,
|
|
1008
|
+
resultType: "all"
|
|
1009
|
+
});
|
|
1010
|
+
for (const match of matches) {
|
|
1011
|
+
if (match.value.$ref && !isRefDefined(match.value.$ref, swagger)) {
|
|
1012
|
+
import_jsonpointer.default.set(shadow, match.pointer, R11.omit(["$ref"], match.value));
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
return shadow;
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
// src/utils/openapi-utils/dereference-operation.ts
|
|
1019
|
+
function dereferencePathObject(swagger) {
|
|
1020
|
+
const matches = (0, import_jsonpath_plus4.JSONPath)({
|
|
1021
|
+
path: "$.paths.*.$ref^",
|
|
1022
|
+
json: swagger,
|
|
1023
|
+
resultType: "all"
|
|
1024
|
+
});
|
|
1025
|
+
for (const match of matches) {
|
|
1026
|
+
const value = dereference(match.value.$ref, swagger);
|
|
1027
|
+
import_jsonpointer2.default.set(swagger, match.pointer, value);
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
function dereferenceRequestBody(swagger) {
|
|
1031
|
+
const matches = (0, import_jsonpath_plus4.JSONPath)({
|
|
1032
|
+
path: "$.paths.*.*.requestBody.$ref^",
|
|
1033
|
+
json: swagger,
|
|
1034
|
+
resultType: "all"
|
|
1035
|
+
});
|
|
1036
|
+
for (const match of matches) {
|
|
1037
|
+
const value = dereference(match.value.$ref, swagger);
|
|
1038
|
+
import_jsonpointer2.default.set(swagger, match.pointer, value);
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
function dereferenceResponses(swagger) {
|
|
1042
|
+
const matches = [
|
|
1043
|
+
...(0, import_jsonpath_plus4.JSONPath)({
|
|
1044
|
+
path: "$.paths.*.*.responses.*.$ref^",
|
|
1045
|
+
json: swagger,
|
|
1046
|
+
resultType: "all"
|
|
1047
|
+
}),
|
|
1048
|
+
...(0, import_jsonpath_plus4.JSONPath)({
|
|
1049
|
+
path: "$.paths.*.*.responses.*.headers.*.$ref^",
|
|
1050
|
+
json: swagger,
|
|
1051
|
+
resultType: "all"
|
|
1052
|
+
})
|
|
1053
|
+
];
|
|
1054
|
+
for (const match of matches) {
|
|
1055
|
+
const value = dereference(match.value.$ref, swagger);
|
|
1056
|
+
import_jsonpointer2.default.set(swagger, match.pointer, value);
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
function dereferenceParameters(swagger) {
|
|
1060
|
+
const matches = (0, import_jsonpath_plus4.JSONPath)({
|
|
1061
|
+
path: "$.paths.*.*.parameters.*.$ref^",
|
|
1062
|
+
json: swagger,
|
|
1063
|
+
resultType: "all"
|
|
1064
|
+
});
|
|
1065
|
+
for (const match of matches) {
|
|
1066
|
+
const value = dereference(match.value.$ref, swagger);
|
|
1067
|
+
import_jsonpointer2.default.set(swagger, match.pointer, value);
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
function dereferenceOperation(swagger) {
|
|
1071
|
+
const shadow = R12.clone(swagger);
|
|
1072
|
+
dereferencePathObject(shadow);
|
|
1073
|
+
dereferenceRequestBody(shadow);
|
|
1074
|
+
dereferenceResponses(shadow);
|
|
1075
|
+
dereferenceParameters(shadow);
|
|
1076
|
+
return removeUndefinedRef(shadow);
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
// src/utils/openapi-utils/dereference-deep.ts
|
|
1080
|
+
function dereferenceDeep($ref, swagger) {
|
|
1081
|
+
const stack = [$ref];
|
|
1082
|
+
let value;
|
|
1083
|
+
while (true) {
|
|
1084
|
+
const last2 = stack[stack.length - 1];
|
|
1085
|
+
value = dereference(last2, swagger);
|
|
1086
|
+
if (JsonSchemaUtils.isRef(value)) {
|
|
1087
|
+
if (!stack.includes(value.$ref)) {
|
|
1088
|
+
stack.push(value.$ref);
|
|
1089
|
+
continue;
|
|
1090
|
+
} else {
|
|
1091
|
+
throw new Error(`Circular reference detected: ${stack.join(" -> ")} -> ${value.$ref}`);
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
break;
|
|
1095
|
+
}
|
|
1096
|
+
return value;
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
// src/utils/openapi-utils/to-3_1.ts
|
|
1100
|
+
var import_openapi_parser = require("@scalar/openapi-parser");
|
|
1101
|
+
function To3_1(openapi) {
|
|
1102
|
+
const { specification } = (0, import_openapi_parser.upgrade)(openapi);
|
|
1103
|
+
return specification;
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
// src/utils/openapi-utils/map-operation.ts
|
|
1107
|
+
var R13 = __toESM(require("ramda"), 1);
|
|
1108
|
+
function mapOperation(specification, mapper) {
|
|
1109
|
+
const shadow = R13.clone(specification);
|
|
1110
|
+
for (const [pathname, pathItem] of Object.entries(shadow.paths || {})) {
|
|
1111
|
+
for (const m in pathItem) {
|
|
1112
|
+
const method = m.toLowerCase();
|
|
1113
|
+
if (!SupportedMethods.includes(method)) continue;
|
|
1114
|
+
if (typeof pathItem[m] !== "object" || Array.isArray(pathItem[m]) || pathItem[m] === null) continue;
|
|
1115
|
+
const operation = pathItem[m];
|
|
1116
|
+
pathItem[m] = mapper(method, pathname, operation);
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
return shadow;
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
// src/utils/openapi-utils/map-parameter.ts
|
|
1123
|
+
function mapParameter(specification, mapper) {
|
|
1124
|
+
return mapOperation(specification, (method, pathname, operation) => {
|
|
1125
|
+
if (!operation.parameters) return operation;
|
|
1126
|
+
operation.parameters = operation.parameters.map((parameter) => mapper(method, pathname, operation, parameter));
|
|
1127
|
+
return operation;
|
|
1128
|
+
});
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
// src/utils/openapi-utils/index.ts
|
|
1132
|
+
var OpenapiUtils = class {
|
|
1133
|
+
static isRefDefined = isRefDefined;
|
|
1134
|
+
static dereference = dereference;
|
|
1135
|
+
static dereferenceDeep = dereferenceDeep;
|
|
1136
|
+
static removeUndefinedRef = removeUndefinedRef;
|
|
1137
|
+
static dereferenceOperation = dereferenceOperation;
|
|
1138
|
+
static mapOperation = mapOperation;
|
|
1139
|
+
static mapParameter = mapParameter;
|
|
1140
|
+
// static updateOperationId = updateOperationId
|
|
1141
|
+
static to3_1 = To3_1;
|
|
1142
|
+
};
|
|
1143
|
+
|
|
1427
1144
|
// src/transformers/operation-definition/declaration.renderer.ts
|
|
1428
1145
|
var alias = (name) => `${name}Schema`;
|
|
1429
1146
|
var DeclarationRenderer2 = class {
|
|
@@ -1434,7 +1151,7 @@ var DeclarationRenderer2 = class {
|
|
|
1434
1151
|
}
|
|
1435
1152
|
typeName;
|
|
1436
1153
|
renderResponseBodies(operation, options) {
|
|
1437
|
-
if (!operation.responses ||
|
|
1154
|
+
if (!operation.responses || R14.isEmpty(operation.responses)) {
|
|
1438
1155
|
return `export interface ${this.typeName("ResponseBodies")} {}`;
|
|
1439
1156
|
}
|
|
1440
1157
|
const $responses = Object.entries(operation.responses).map(([statusCode, response]) => {
|
|
@@ -1585,15 +1302,28 @@ var DeclarationRenderer2 = class {
|
|
|
1585
1302
|
"}",
|
|
1586
1303
|
"",
|
|
1587
1304
|
"/* @anchor:file:end */"
|
|
1588
|
-
].filter(
|
|
1305
|
+
].filter(R14.isNotNil).join("\n");
|
|
1589
1306
|
}
|
|
1590
1307
|
};
|
|
1591
1308
|
|
|
1592
1309
|
// src/transformers/operation-definition/micro-function.renderer.ts
|
|
1593
|
-
var
|
|
1310
|
+
var R16 = __toESM(require("ramda"), 1);
|
|
1311
|
+
|
|
1312
|
+
// src/exception.ts
|
|
1313
|
+
var import_ts_custom_error = require("ts-custom-error");
|
|
1314
|
+
var import_word_wrap = __toESM(require("word-wrap"), 1);
|
|
1315
|
+
var Exception = class extends import_ts_custom_error.CustomError {
|
|
1316
|
+
constructor(module2, message) {
|
|
1317
|
+
const moduleName = typeof module2 === "string" ? module2 : module2.name;
|
|
1318
|
+
const msg = (0, import_word_wrap.default)(message, { width: 60, indent: " " });
|
|
1319
|
+
super(`${moduleName} module failed to compile:
|
|
1320
|
+
${msg}`);
|
|
1321
|
+
Object.defineProperty(this, "name", { value: "KeqCLI_Exception" });
|
|
1322
|
+
}
|
|
1323
|
+
};
|
|
1594
1324
|
|
|
1595
1325
|
// src/transformers/operation-definition/typescript-snippet.ts
|
|
1596
|
-
var
|
|
1326
|
+
var R15 = __toESM(require("ramda"), 1);
|
|
1597
1327
|
|
|
1598
1328
|
// src/constants/qs-array-format.ts
|
|
1599
1329
|
var QsArrayFormat = /* @__PURE__ */ ((QsArrayFormat2) => {
|
|
@@ -1663,7 +1393,7 @@ var OperationDefinitionSnippet = class {
|
|
|
1663
1393
|
const { operation } = this.operationDefinition;
|
|
1664
1394
|
const $query = (operation.parameters || []).filter((p) => !JsonSchemaUtils.isRef(p)).filter((p) => p.in === "query").map((p) => {
|
|
1665
1395
|
const option = this.getQsParameters(p);
|
|
1666
|
-
const $option = !option ||
|
|
1396
|
+
const $option = !option || R15.isEmpty(option) ? "" : `, ${JSON.stringify(option)}`;
|
|
1667
1397
|
return `if (args && ${JSON.stringify(p.name)} in args) req.query(${JSON.stringify(p.name)}, args[${JSON.stringify(p.name)}]${$option})`;
|
|
1668
1398
|
}).join("\n");
|
|
1669
1399
|
return $query;
|
|
@@ -1733,7 +1463,7 @@ var OperationDefinitionSnippet = class {
|
|
|
1733
1463
|
} catch (err) {
|
|
1734
1464
|
return this.renderErrorComment(err, mediaType);
|
|
1735
1465
|
}
|
|
1736
|
-
}).filter(
|
|
1466
|
+
}).filter(R15.isNotNil).join("\n");
|
|
1737
1467
|
return $requestBody;
|
|
1738
1468
|
}
|
|
1739
1469
|
renderErrorComment(err, mediaType) {
|
|
@@ -1808,7 +1538,7 @@ var OperationDefinitionMicroFunctionRenderer = class {
|
|
|
1808
1538
|
`${operationId}.pathname = pathname`,
|
|
1809
1539
|
`${operationId}.method = method`,
|
|
1810
1540
|
"/* @anchor:file:end */"
|
|
1811
|
-
].filter(
|
|
1541
|
+
].filter(R16.isNotNil).join("\n");
|
|
1812
1542
|
}
|
|
1813
1543
|
renderDependencies() {
|
|
1814
1544
|
const declarationFilepath = this.options.getOperationDefinitionDeclarationFilepath(this.operationDefinition);
|
|
@@ -1835,7 +1565,7 @@ var OperationDefinitionMicroFunctionRenderer = class {
|
|
|
1835
1565
|
};
|
|
1836
1566
|
|
|
1837
1567
|
// src/transformers/operation-definition/nestjs-method.renderer.ts
|
|
1838
|
-
var
|
|
1568
|
+
var R17 = __toESM(require("ramda"), 1);
|
|
1839
1569
|
var OperationDefinitionNestjsMethodRenderer = class {
|
|
1840
1570
|
constructor(operationDefinition, options) {
|
|
1841
1571
|
this.operationDefinition = operationDefinition;
|
|
@@ -1888,7 +1618,7 @@ var OperationDefinitionNestjsMethodRenderer = class {
|
|
|
1888
1618
|
"",
|
|
1889
1619
|
" return req",
|
|
1890
1620
|
"}"
|
|
1891
|
-
].filter(
|
|
1621
|
+
].filter(R17.isNotNil).join("\n");
|
|
1892
1622
|
}
|
|
1893
1623
|
renderOperationDeclaration(operationDefinition) {
|
|
1894
1624
|
const { operationId } = operationDefinition;
|
|
@@ -1908,163 +1638,61 @@ var OperationDefinitionNestjsMethodRenderer = class {
|
|
|
1908
1638
|
// src/transformers/operation-definition/operation-definition.transformer.ts
|
|
1909
1639
|
var OperationDefinitionTransformer = class {
|
|
1910
1640
|
static toDeclaration(operationDefinition, options) {
|
|
1911
|
-
return new DeclarationRenderer2(operationDefinition, options).render();
|
|
1912
|
-
}
|
|
1913
|
-
static toMicroFunction(operationDefinition, options) {
|
|
1914
|
-
return new OperationDefinitionMicroFunctionRenderer(operationDefinition, options).render();
|
|
1915
|
-
}
|
|
1916
|
-
static toNestjsMethod(operationDefinition, options) {
|
|
1917
|
-
return new OperationDefinitionNestjsMethodRenderer(operationDefinition, options).render();
|
|
1918
|
-
}
|
|
1919
|
-
static toComment(operationDefinition) {
|
|
1920
|
-
return new CommentRenderer2(operationDefinition).render();
|
|
1921
|
-
}
|
|
1922
|
-
};
|
|
1923
|
-
|
|
1924
|
-
// src/transformers/entrypoint/entrypoint.transformer.ts
|
|
1925
|
-
var path7 = __toESM(require("path"), 1);
|
|
1926
|
-
var EntrypointTransformer = class {
|
|
1927
|
-
static toTypescript(exports2, options) {
|
|
1928
|
-
const $exports = exports2.map((exportArtifact) => {
|
|
1929
|
-
const relativePath = path7.relative(
|
|
1930
|
-
options.dirpath,
|
|
1931
|
-
exportArtifact.filepath
|
|
1932
|
-
).replace(/(\.ts|\.mts|\.cts|\.js|\.cjs|\.mjs)?$/, options.esm ? ".js" : "");
|
|
1933
|
-
return relativePath.startsWith(".") ? `export * from '${relativePath}'` : `export * from './${relativePath}'`;
|
|
1934
|
-
});
|
|
1935
|
-
return [
|
|
1936
|
-
"/* @anchor:file:start */",
|
|
1937
|
-
"",
|
|
1938
|
-
...$exports,
|
|
1939
|
-
"",
|
|
1940
|
-
"/* @anchor:file:end */"
|
|
1941
|
-
].join("\n");
|
|
1942
|
-
}
|
|
1943
|
-
};
|
|
1944
|
-
|
|
1945
|
-
// src/transformers/api-document/nestjs-client.renderer.ts
|
|
1946
|
-
var R19 = __toESM(require("ramda"), 1);
|
|
1947
|
-
var changeCase2 = __toESM(require("change-case"), 1);
|
|
1948
|
-
var NestjsClientRenderer = class {
|
|
1949
|
-
constructor(document, options) {
|
|
1950
|
-
this.document = document;
|
|
1951
|
-
this.options = options;
|
|
1952
|
-
}
|
|
1953
|
-
renderDependencies() {
|
|
1954
|
-
const $operations = this.document.operations.map((operationDefinition) => {
|
|
1955
|
-
const filepath = this.options.getOperationDefinitionDeclarationFilepath(operationDefinition);
|
|
1956
|
-
const typeName = typeNameFactory(operationDefinition);
|
|
1957
|
-
return `import type { ${typeName("Operation")}, ${typeName("ResponseBodies")}, ${typeName("RequestParameters")} } from "${filepath}"`;
|
|
1958
|
-
}).map((str) => str.replace(/ from "(\.\.?\/.+?)(\.ts|\.mts|\.cts|\.js|\.cjs|\.mjs)?"/, this.options.esm ? ' from "$1.js"' : ' from "$1"'));
|
|
1959
|
-
return [
|
|
1960
|
-
'import { Injectable, Logger } from "@nestjs/common"',
|
|
1961
|
-
'import { Keq, KeqRequest } from "keq"',
|
|
1962
|
-
...$operations
|
|
1963
|
-
].join("\n");
|
|
1964
|
-
}
|
|
1965
|
-
render() {
|
|
1966
|
-
const moduleName = changeCase2.pascalCase(this.document.module.name);
|
|
1967
|
-
const $dependencies = this.renderDependencies();
|
|
1968
|
-
const $operations = this.document.operations.map((operation) => OperationDefinitionTransformer.toNestjsMethod(operation, {
|
|
1969
|
-
esm: this.options.esm
|
|
1970
|
-
})).join("\n\n");
|
|
1971
|
-
return [
|
|
1972
|
-
"/* @anchor:file:start */",
|
|
1973
|
-
"",
|
|
1974
|
-
$dependencies,
|
|
1975
|
-
"",
|
|
1976
|
-
"@Injectable()",
|
|
1977
|
-
`export class ${moduleName}Client {`,
|
|
1978
|
-
` private readonly logger = new Logger(${moduleName}Client.name)`,
|
|
1979
|
-
"",
|
|
1980
|
-
" constructor(",
|
|
1981
|
-
" // @anchor:client-constructor-parameters:start",
|
|
1982
|
-
" private readonly request: KeqRequest,",
|
|
1983
|
-
" // @anchor:client-constructor-parameters:end",
|
|
1984
|
-
" ) {}",
|
|
1985
|
-
"",
|
|
1986
|
-
indent(2, $operations),
|
|
1987
|
-
"}",
|
|
1988
|
-
"",
|
|
1989
|
-
"/* @anchor:file:end */"
|
|
1990
|
-
].filter(R19.isNotNil).join("\n");
|
|
1641
|
+
return new DeclarationRenderer2(operationDefinition, options).render();
|
|
1642
|
+
}
|
|
1643
|
+
static toMicroFunction(operationDefinition, options) {
|
|
1644
|
+
return new OperationDefinitionMicroFunctionRenderer(operationDefinition, options).render();
|
|
1645
|
+
}
|
|
1646
|
+
static toNestjsMethod(operationDefinition, options) {
|
|
1647
|
+
return new OperationDefinitionNestjsMethodRenderer(operationDefinition, options).render();
|
|
1648
|
+
}
|
|
1649
|
+
static toComment(operationDefinition) {
|
|
1650
|
+
return new CommentRenderer2(operationDefinition).render();
|
|
1991
1651
|
}
|
|
1992
1652
|
};
|
|
1993
1653
|
|
|
1994
|
-
// src/transformers/
|
|
1995
|
-
var
|
|
1996
|
-
var
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
1654
|
+
// src/transformers/entrypoint/entrypoint.transformer.ts
|
|
1655
|
+
var path5 = __toESM(require("path"), 1);
|
|
1656
|
+
var EntrypointTransformer = class {
|
|
1657
|
+
static toTypescript(exports2, options) {
|
|
1658
|
+
const $exports = exports2.map((exportArtifact) => {
|
|
1659
|
+
const relativePath = path5.relative(
|
|
1660
|
+
options.dirpath,
|
|
1661
|
+
exportArtifact.filepath
|
|
1662
|
+
).replace(/(\.ts|\.mts|\.cts|\.js|\.cjs|\.mjs)?$/, options.esm ? ".js" : "");
|
|
1663
|
+
return relativePath.startsWith(".") ? `export * from '${relativePath}'` : `export * from './${relativePath}'`;
|
|
1664
|
+
});
|
|
2004
1665
|
return [
|
|
2005
1666
|
"/* @anchor:file:start */",
|
|
2006
|
-
'import { Module, Inject, ConfigurableModuleBuilder, Global } from "@nestjs/common"',
|
|
2007
|
-
'import { KeqRequest } from "keq"',
|
|
2008
|
-
'import { KeqModuleOptions } from "@keq-request/nestjs"',
|
|
2009
|
-
`import { ${moduleName}Client } from "${clientFilepath}"`,
|
|
2010
|
-
"",
|
|
2011
|
-
"",
|
|
2012
|
-
"const { ConfigurableModuleClass, MODULE_OPTIONS_TOKEN, OPTIONS_TYPE, ASYNC_OPTIONS_TYPE } = new ConfigurableModuleBuilder<KeqModuleOptions>().build()",
|
|
2013
|
-
"",
|
|
2014
|
-
"@Global()",
|
|
2015
|
-
"@Module({",
|
|
2016
|
-
" imports: [],",
|
|
2017
|
-
" controllers: [],",
|
|
2018
|
-
` providers: [${moduleName}Client],`,
|
|
2019
|
-
` exports: [${moduleName}Client],`,
|
|
2020
|
-
"})",
|
|
2021
|
-
`export class ${moduleName}Module extends ConfigurableModuleClass {`,
|
|
2022
1667
|
"",
|
|
2023
|
-
|
|
2024
|
-
" @Inject(MODULE_OPTIONS_TOKEN) private readonly options: KeqModuleOptions,",
|
|
2025
|
-
" private readonly request: KeqRequest,",
|
|
2026
|
-
" ) {",
|
|
2027
|
-
" super()",
|
|
2028
|
-
" }",
|
|
2029
|
-
"",
|
|
2030
|
-
" onModuleInit() {",
|
|
2031
|
-
" if (this.options.middlewares) {",
|
|
2032
|
-
" for (const middleware of this.options.middlewares) {",
|
|
2033
|
-
" this.request.use(middleware)",
|
|
2034
|
-
" }",
|
|
2035
|
-
" }",
|
|
2036
|
-
" }",
|
|
2037
|
-
"}",
|
|
1668
|
+
...$exports,
|
|
2038
1669
|
"",
|
|
2039
1670
|
"/* @anchor:file:end */"
|
|
2040
1671
|
].join("\n");
|
|
2041
1672
|
}
|
|
2042
1673
|
};
|
|
2043
1674
|
|
|
2044
|
-
// src/transformers/api-document/
|
|
2045
|
-
var
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
return new NestjsClientRenderer(document, options).render();
|
|
2051
|
-
}
|
|
2052
|
-
};
|
|
1675
|
+
// src/transformers/api-document/nestjs-client.renderer.ts
|
|
1676
|
+
var R18 = __toESM(require("ramda"), 1);
|
|
1677
|
+
var changeCase2 = __toESM(require("change-case"), 1);
|
|
1678
|
+
|
|
1679
|
+
// src/transformers/api-document/nestjs-module.renderer.ts
|
|
1680
|
+
var changeCase3 = __toESM(require("change-case"), 1);
|
|
2053
1681
|
|
|
2054
1682
|
// src/plugins/generate-declaration/generators/schema-declaration/schema.generator.ts
|
|
2055
|
-
var
|
|
2056
|
-
var
|
|
1683
|
+
var R19 = __toESM(require("ramda"), 1);
|
|
1684
|
+
var path6 = __toESM(require("path"), 1);
|
|
2057
1685
|
var changeCase4 = __toESM(require("change-case"), 1);
|
|
2058
1686
|
|
|
2059
1687
|
// src/plugins/generate-declaration/constants/metadata-storage.ts
|
|
2060
|
-
var
|
|
1688
|
+
var MetadataStorage4 = /* @__PURE__ */ new WeakMap();
|
|
2061
1689
|
|
|
2062
1690
|
// src/plugins/generate-declaration/generators/schema-declaration/schema.generator.ts
|
|
2063
1691
|
var SCHEMA_GENERATOR = "schemaGenerator";
|
|
2064
1692
|
var SchemaDeclarationGenerator = class _SchemaDeclarationGenerator {
|
|
2065
1693
|
async compile(compiler, task) {
|
|
2066
1694
|
const context = compiler.context;
|
|
2067
|
-
const metadata =
|
|
1695
|
+
const metadata = MetadataStorage4.get(compiler);
|
|
2068
1696
|
const rc = context.rc;
|
|
2069
1697
|
const documents = context.documents;
|
|
2070
1698
|
const schemaDefinitions = documents.flatMap((document) => document.schemas);
|
|
@@ -2080,7 +1708,7 @@ var SchemaDeclarationGenerator = class _SchemaDeclarationGenerator {
|
|
|
2080
1708
|
])
|
|
2081
1709
|
)
|
|
2082
1710
|
);
|
|
2083
|
-
const entrypoints =
|
|
1711
|
+
const entrypoints = R19.collectBy(
|
|
2084
1712
|
(schemaDefinition) => schemaDefinition.module.name,
|
|
2085
1713
|
schemaDefinitions
|
|
2086
1714
|
).map((schemaDefinitions2) => [
|
|
@@ -2095,7 +1723,7 @@ var SchemaDeclarationGenerator = class _SchemaDeclarationGenerator {
|
|
|
2095
1723
|
}
|
|
2096
1724
|
generateSchemaDefinitionsArtifact(schemaDefinition, rc) {
|
|
2097
1725
|
const filepath = _SchemaDeclarationGenerator.getSchemaDefinitionArtifactFilepath(schemaDefinition, rc.fileNamingStyle);
|
|
2098
|
-
const dirpath =
|
|
1726
|
+
const dirpath = path6.dirname(filepath);
|
|
2099
1727
|
const artifact = new Artifact({
|
|
2100
1728
|
id: _SchemaDeclarationGenerator.getSchemaDefinitionArtifactId(schemaDefinition),
|
|
2101
1729
|
filepath,
|
|
@@ -2104,7 +1732,7 @@ var SchemaDeclarationGenerator = class _SchemaDeclarationGenerator {
|
|
|
2104
1732
|
{
|
|
2105
1733
|
esm: rc.esm,
|
|
2106
1734
|
getDependentSchemaDefinitionFilepath(dependentSchemaDefinition) {
|
|
2107
|
-
const relativePath =
|
|
1735
|
+
const relativePath = path6.relative(
|
|
2108
1736
|
dirpath,
|
|
2109
1737
|
_SchemaDeclarationGenerator.getSchemaDefinitionArtifactFilepath(dependentSchemaDefinition, rc.fileNamingStyle)
|
|
2110
1738
|
);
|
|
@@ -2118,7 +1746,7 @@ var SchemaDeclarationGenerator = class _SchemaDeclarationGenerator {
|
|
|
2118
1746
|
}
|
|
2119
1747
|
generateEntrypointArtifact(moduleDefinition, exports2, rc) {
|
|
2120
1748
|
const filepath = _SchemaDeclarationGenerator.getEntrypointArtifactFilepath(moduleDefinition, rc.fileNamingStyle);
|
|
2121
|
-
const dirpath =
|
|
1749
|
+
const dirpath = path6.dirname(filepath);
|
|
2122
1750
|
const artifact = new Artifact({
|
|
2123
1751
|
id: _SchemaDeclarationGenerator.getEntrypointArtifactId(moduleDefinition),
|
|
2124
1752
|
filepath,
|
|
@@ -2137,7 +1765,7 @@ var SchemaDeclarationGenerator = class _SchemaDeclarationGenerator {
|
|
|
2137
1765
|
].join("/");
|
|
2138
1766
|
}
|
|
2139
1767
|
static getEntrypointArtifactId(moduleDefinition) {
|
|
2140
|
-
return `${moduleDefinition.address}/components/schemas/entrypoint?generator=${SCHEMA_GENERATOR}`;
|
|
1768
|
+
return `${moduleDefinition.address.url}/components/schemas/entrypoint?generator=${SCHEMA_GENERATOR}`;
|
|
2141
1769
|
}
|
|
2142
1770
|
static getSchemaDefinitionArtifactFilepath(schemaDefinition, fileNamingStyle) {
|
|
2143
1771
|
const filename = `${changeCase4[fileNamingStyle](schemaDefinition.name)}.schema.ts`;
|
|
@@ -2160,7 +1788,7 @@ var OPERATION_GENERATOR = "operationDeclarationGenerator";
|
|
|
2160
1788
|
var OperationDeclarationGenerator = class _OperationDeclarationGenerator {
|
|
2161
1789
|
async compile(compiler, task) {
|
|
2162
1790
|
const context = compiler.context;
|
|
2163
|
-
const metadata =
|
|
1791
|
+
const metadata = MetadataStorage4.get(compiler);
|
|
2164
1792
|
const rc = context.rc;
|
|
2165
1793
|
const documents = context.documents;
|
|
2166
1794
|
const operationDefinitions = documents.flatMap((document) => document.operations);
|
|
@@ -2180,7 +1808,7 @@ var OperationDeclarationGenerator = class _OperationDeclarationGenerator {
|
|
|
2180
1808
|
}
|
|
2181
1809
|
generateOperationDefinitionArtifact(operationDefinition, rc) {
|
|
2182
1810
|
const filepath = _OperationDeclarationGenerator.getOperationDefinitionArtifactFilepath(operationDefinition, rc.fileNamingStyle);
|
|
2183
|
-
const dirpath =
|
|
1811
|
+
const dirpath = path7.dirname(filepath);
|
|
2184
1812
|
const artifact = new Artifact({
|
|
2185
1813
|
id: _OperationDeclarationGenerator.getOperationDefinitionArtifactId(operationDefinition),
|
|
2186
1814
|
filepath,
|
|
@@ -2189,7 +1817,7 @@ var OperationDeclarationGenerator = class _OperationDeclarationGenerator {
|
|
|
2189
1817
|
{
|
|
2190
1818
|
esm: rc.esm,
|
|
2191
1819
|
getDependentSchemaDefinitionFilepath(dependentSchemaDefinition) {
|
|
2192
|
-
const relativePath =
|
|
1820
|
+
const relativePath = path7.relative(
|
|
2193
1821
|
dirpath,
|
|
2194
1822
|
SchemaDeclarationGenerator.getSchemaDefinitionArtifactFilepath(dependentSchemaDefinition, rc.fileNamingStyle)
|
|
2195
1823
|
);
|
|
@@ -2203,7 +1831,7 @@ var OperationDeclarationGenerator = class _OperationDeclarationGenerator {
|
|
|
2203
1831
|
}
|
|
2204
1832
|
generateEntrypointArtifact(moduleDefinition, exports2, rc) {
|
|
2205
1833
|
const filepath = _OperationDeclarationGenerator.getEntrypointArtifactFilepath(moduleDefinition, rc.fileNamingStyle);
|
|
2206
|
-
const dirpath =
|
|
1834
|
+
const dirpath = path7.dirname(filepath);
|
|
2207
1835
|
const artifact = new Artifact({
|
|
2208
1836
|
id: _OperationDeclarationGenerator.getEntrypointArtifactId(moduleDefinition),
|
|
2209
1837
|
filepath,
|
|
@@ -2235,7 +1863,7 @@ var OperationDeclarationGenerator = class _OperationDeclarationGenerator {
|
|
|
2235
1863
|
].join("/");
|
|
2236
1864
|
}
|
|
2237
1865
|
static getEntrypointArtifactId(moduleDefinition) {
|
|
2238
|
-
return `${moduleDefinition.address}/paths/entrypoint?generator=${OPERATION_GENERATOR}`;
|
|
1866
|
+
return `${moduleDefinition.address.url}/paths/entrypoint?generator=${OPERATION_GENERATOR}`;
|
|
2239
1867
|
}
|
|
2240
1868
|
};
|
|
2241
1869
|
|
|
@@ -2248,6 +1876,7 @@ var GenerateDeclarationPlugin = class _GenerateDeclarationPlugin {
|
|
|
2248
1876
|
constructor() {
|
|
2249
1877
|
}
|
|
2250
1878
|
apply(compiler) {
|
|
1879
|
+
if (MetadataStorage4.has(compiler)) return;
|
|
2251
1880
|
_GenerateDeclarationPlugin.register(compiler);
|
|
2252
1881
|
compiler.hooks.compile.tapPromise(_GenerateDeclarationPlugin.name, async (task) => {
|
|
2253
1882
|
compiler.context.artifacts?.push(
|
|
@@ -2257,8 +1886,8 @@ var GenerateDeclarationPlugin = class _GenerateDeclarationPlugin {
|
|
|
2257
1886
|
});
|
|
2258
1887
|
}
|
|
2259
1888
|
static register(compiler) {
|
|
2260
|
-
if (!
|
|
2261
|
-
|
|
1889
|
+
if (!MetadataStorage4.has(compiler)) {
|
|
1890
|
+
MetadataStorage4.set(compiler, {
|
|
2262
1891
|
hooks: {
|
|
2263
1892
|
afterEntrypointArtifactGenerated: new import_tapable.AsyncSeriesWaterfallHook(["artifact", "task"]),
|
|
2264
1893
|
afterSchemaDeclarationArtifactGenerated: new import_tapable.AsyncSeriesWaterfallHook(["artifact", "schemaDefinition", "task"]),
|
|
@@ -2266,7 +1895,7 @@ var GenerateDeclarationPlugin = class _GenerateDeclarationPlugin {
|
|
|
2266
1895
|
}
|
|
2267
1896
|
});
|
|
2268
1897
|
}
|
|
2269
|
-
return
|
|
1898
|
+
return MetadataStorage4.get(compiler);
|
|
2270
1899
|
}
|
|
2271
1900
|
static of(compiler) {
|
|
2272
1901
|
return this.register(compiler);
|
|
@@ -2311,7 +1940,7 @@ var RequestGenerator = class _RequestGenerator {
|
|
|
2311
1940
|
var MICRO_FUNCTION_GENERATOR = "microFunctionGenerator";
|
|
2312
1941
|
var MicroFunctionGenerator = class _MicroFunctionGenerator {
|
|
2313
1942
|
async compile(compiler, task) {
|
|
2314
|
-
const metadata =
|
|
1943
|
+
const metadata = MetadataStorage3.get(compiler);
|
|
2315
1944
|
const context = compiler.context;
|
|
2316
1945
|
const rc = context.rc;
|
|
2317
1946
|
const documents = context.documents;
|
|
@@ -2329,7 +1958,7 @@ var MicroFunctionGenerator = class _MicroFunctionGenerator {
|
|
|
2329
1958
|
)
|
|
2330
1959
|
);
|
|
2331
1960
|
const entrypoints = await Promise.all(
|
|
2332
|
-
|
|
1961
|
+
R20.collectBy(
|
|
2333
1962
|
(operationDefinition) => operationDefinition.module.name,
|
|
2334
1963
|
operationDefinitions
|
|
2335
1964
|
).map((operationDefinitions2) => [
|
|
@@ -2348,21 +1977,21 @@ var MicroFunctionGenerator = class _MicroFunctionGenerator {
|
|
|
2348
1977
|
}
|
|
2349
1978
|
generateOperationDefinitionArtifact(operationDefinition, rc) {
|
|
2350
1979
|
const filepath = _MicroFunctionGenerator.getOperationDefinitionArtifactFilepath(operationDefinition, rc.fileNamingStyle);
|
|
2351
|
-
const dirpath =
|
|
1980
|
+
const dirpath = path8.dirname(filepath);
|
|
2352
1981
|
const artifact = new Artifact({
|
|
2353
1982
|
id: _MicroFunctionGenerator.getOperationDefinitionArtifactId(operationDefinition),
|
|
2354
1983
|
filepath,
|
|
2355
1984
|
content: OperationDefinitionTransformer.toMicroFunction(operationDefinition, {
|
|
2356
1985
|
esm: rc.esm,
|
|
2357
1986
|
getOperationDefinitionDeclarationFilepath(operationDefinition2) {
|
|
2358
|
-
const relativePath =
|
|
1987
|
+
const relativePath = path8.relative(
|
|
2359
1988
|
dirpath,
|
|
2360
1989
|
OperationDeclarationGenerator.getOperationDefinitionArtifactFilepath(operationDefinition2, rc.fileNamingStyle)
|
|
2361
1990
|
);
|
|
2362
1991
|
return relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
|
|
2363
1992
|
},
|
|
2364
1993
|
getRequestFilepath() {
|
|
2365
|
-
const relativePath =
|
|
1994
|
+
const relativePath = path8.relative(
|
|
2366
1995
|
dirpath,
|
|
2367
1996
|
RequestGenerator.getRequestArtifactFilepath()
|
|
2368
1997
|
);
|
|
@@ -2414,6 +2043,7 @@ var GenerateMicroFunctionPlugin = class _GenerateMicroFunctionPlugin {
|
|
|
2414
2043
|
microFunctionGenerator = new MicroFunctionGenerator();
|
|
2415
2044
|
requestGenerator = new RequestGenerator();
|
|
2416
2045
|
apply(compiler) {
|
|
2046
|
+
if (MetadataStorage3.has(compiler)) return;
|
|
2417
2047
|
_GenerateMicroFunctionPlugin.register(compiler);
|
|
2418
2048
|
compiler.hooks.compile.tapPromise(_GenerateMicroFunctionPlugin.name, async (task) => {
|
|
2419
2049
|
const artifacts = [
|
|
@@ -2424,15 +2054,15 @@ var GenerateMicroFunctionPlugin = class _GenerateMicroFunctionPlugin {
|
|
|
2424
2054
|
});
|
|
2425
2055
|
}
|
|
2426
2056
|
static register(compiler) {
|
|
2427
|
-
if (!
|
|
2428
|
-
|
|
2057
|
+
if (!MetadataStorage3.has(compiler)) {
|
|
2058
|
+
MetadataStorage3.set(compiler, {
|
|
2429
2059
|
hooks: {
|
|
2430
2060
|
afterEntrypointArtifactGenerated: new import_tapable2.AsyncSeriesWaterfallHook(["artifact", "task"]),
|
|
2431
2061
|
afterMicroFunctionArtifactGenerated: new import_tapable2.AsyncSeriesWaterfallHook(["artifact", "operationDefinition", "task"])
|
|
2432
2062
|
}
|
|
2433
2063
|
});
|
|
2434
2064
|
}
|
|
2435
|
-
return
|
|
2065
|
+
return MetadataStorage3.get(compiler);
|
|
2436
2066
|
}
|
|
2437
2067
|
static of(compiler) {
|
|
2438
2068
|
return this.register(compiler);
|
|
@@ -2442,328 +2072,646 @@ var GenerateMicroFunctionPlugin = class _GenerateMicroFunctionPlugin {
|
|
|
2442
2072
|
// src/plugins/generate-nestjs-module/generate-nestjs-module.ts
|
|
2443
2073
|
var import_tapable3 = require("tapable");
|
|
2444
2074
|
|
|
2445
|
-
// src/plugins/generate-nestjs-module/constants/metadata-storage.ts
|
|
2446
|
-
var MetadataStorage3 = /* @__PURE__ */ new WeakMap();
|
|
2447
|
-
|
|
2448
2075
|
// src/plugins/generate-nestjs-module/generators/nestjs-module.generator.ts
|
|
2449
|
-
var path11 = __toESM(require("path"), 1);
|
|
2450
2076
|
var changeCase7 = __toESM(require("change-case"), 1);
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2077
|
+
|
|
2078
|
+
// src/plugins/chinese-to-pinyin/chinese-to-pinyin.plugin.ts
|
|
2079
|
+
var import_swagger_fix = require("swagger-fix");
|
|
2080
|
+
|
|
2081
|
+
// src/plugins/download-http-file/constants/metadata-storage.ts
|
|
2082
|
+
var MetadataStorage8 = /* @__PURE__ */ new WeakMap();
|
|
2083
|
+
|
|
2084
|
+
// src/plugins/download-http-file/download-http-file.plugin.ts
|
|
2085
|
+
var DownloadHttpFilePlugin = class _DownloadHttpFilePlugin {
|
|
2086
|
+
apply(compiler) {
|
|
2087
|
+
if (MetadataStorage8.has(compiler)) return;
|
|
2088
|
+
_DownloadHttpFilePlugin.register(compiler);
|
|
2089
|
+
compiler.hooks.download.tapPromise(_DownloadHttpFilePlugin.name, async (address, task) => {
|
|
2090
|
+
const { url } = address;
|
|
2091
|
+
if (!url.startsWith("http://") && !url.startsWith("https://")) return void 0;
|
|
2092
|
+
const content = await this.download(address);
|
|
2093
|
+
const spec = this.deserialize(content);
|
|
2094
|
+
return JSON.stringify(spec);
|
|
2469
2095
|
});
|
|
2470
|
-
return artifact;
|
|
2471
2096
|
}
|
|
2472
|
-
|
|
2473
|
-
const
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2097
|
+
async download(address) {
|
|
2098
|
+
const { url, headers } = address;
|
|
2099
|
+
try {
|
|
2100
|
+
const res = await fetch(url, { headers });
|
|
2101
|
+
if (res.status >= 400) throw new Error(`failed with status code ${res.status}`);
|
|
2102
|
+
return await res.text();
|
|
2103
|
+
} catch (e) {
|
|
2104
|
+
if (e instanceof Error) {
|
|
2105
|
+
e.message = `Unable get the openapi/swagger file from ${url}: ${e.message}`;
|
|
2106
|
+
}
|
|
2107
|
+
throw e;
|
|
2108
|
+
}
|
|
2109
|
+
}
|
|
2110
|
+
deserialize(content) {
|
|
2111
|
+
const json = JSON.parse(content);
|
|
2112
|
+
const spec = OpenapiUtils.to3_1(json);
|
|
2113
|
+
return spec;
|
|
2114
|
+
}
|
|
2115
|
+
static register(compiler) {
|
|
2116
|
+
if (!MetadataStorage8.has(compiler)) {
|
|
2117
|
+
MetadataStorage8.set(compiler, {
|
|
2118
|
+
hooks: {}
|
|
2119
|
+
});
|
|
2120
|
+
}
|
|
2121
|
+
return MetadataStorage8.get(compiler);
|
|
2122
|
+
}
|
|
2123
|
+
static of(compiler) {
|
|
2124
|
+
return this.register(compiler);
|
|
2125
|
+
}
|
|
2126
|
+
};
|
|
2127
|
+
|
|
2128
|
+
// src/plugins/download-local-file/download-local-file.plugin.ts
|
|
2129
|
+
var path9 = __toESM(require("path"), 1);
|
|
2130
|
+
var fs3 = __toESM(require("fs/promises"), 1);
|
|
2131
|
+
var yaml = __toESM(require("js-yaml"), 1);
|
|
2132
|
+
var import_url = require("url");
|
|
2133
|
+
|
|
2134
|
+
// src/plugins/download-local-file/constants/metadata-storage.ts
|
|
2135
|
+
var MetadataStorage9 = /* @__PURE__ */ new WeakMap();
|
|
2136
|
+
|
|
2137
|
+
// src/plugins/download-local-file/download-local-file.plugin.ts
|
|
2138
|
+
var DownloadLocalFilePlugin = class _DownloadLocalFilePlugin {
|
|
2139
|
+
apply(compiler) {
|
|
2140
|
+
if (MetadataStorage9.has(compiler)) return;
|
|
2141
|
+
_DownloadLocalFilePlugin.register(compiler);
|
|
2142
|
+
compiler.hooks.download.tapPromise(_DownloadLocalFilePlugin.name, async (address, task) => {
|
|
2143
|
+
const { url, encoding } = address;
|
|
2144
|
+
if (!url.startsWith("file://")) return void 0;
|
|
2145
|
+
const filepath = (0, import_url.fileURLToPath)(url);
|
|
2146
|
+
const fileExt = path9.extname(filepath);
|
|
2147
|
+
const content = await fs3.readFile(filepath, encoding);
|
|
2148
|
+
const str = typeof content === "string" ? content : content.toString(encoding);
|
|
2149
|
+
if ([".yml", ".yaml"].includes(fileExt)) {
|
|
2150
|
+
const value = yaml.load(str);
|
|
2151
|
+
return JSON.stringify(OpenapiUtils.to3_1(value));
|
|
2152
|
+
} else if (fileExt === ".json") {
|
|
2153
|
+
return JSON.stringify(OpenapiUtils.to3_1(JSON.parse(str)));
|
|
2154
|
+
}
|
|
2488
2155
|
});
|
|
2489
|
-
return artifact;
|
|
2490
2156
|
}
|
|
2491
|
-
|
|
2492
|
-
|
|
2157
|
+
static register(compiler) {
|
|
2158
|
+
if (!MetadataStorage9.has(compiler)) {
|
|
2159
|
+
MetadataStorage9.set(compiler, {
|
|
2160
|
+
hooks: {}
|
|
2161
|
+
});
|
|
2162
|
+
}
|
|
2163
|
+
return MetadataStorage9.get(compiler);
|
|
2164
|
+
}
|
|
2165
|
+
static of(compiler) {
|
|
2166
|
+
return this.register(compiler);
|
|
2167
|
+
}
|
|
2168
|
+
};
|
|
2169
|
+
|
|
2170
|
+
// src/plugins/shaking/shaking.plugin.ts
|
|
2171
|
+
var import_openapi_shaking = require("@opendoc/openapi-shaking");
|
|
2172
|
+
|
|
2173
|
+
// src/plugins/shaking/constants/metadata-storage.ts
|
|
2174
|
+
var MetadataStorage10 = /* @__PURE__ */ new WeakMap();
|
|
2175
|
+
|
|
2176
|
+
// src/plugins/shaking/shaking.plugin.ts
|
|
2177
|
+
var ShakingPlugin = class _ShakingPlugin {
|
|
2178
|
+
apply(compiler) {
|
|
2179
|
+
if (MetadataStorage10.has(compiler)) return;
|
|
2180
|
+
_ShakingPlugin.register(compiler);
|
|
2181
|
+
compiler.hooks.beforeCompile.tap(_ShakingPlugin.name, (task) => {
|
|
2182
|
+
const matcher = compiler.context.matcher;
|
|
2183
|
+
const documents = compiler.context.documents;
|
|
2184
|
+
compiler.context.documents = documents.map((document) => this.shaking(compiler, document)).filter((document) => !document.isEmpty()).filter((document) => !matcher.isModuleIgnored(document.module));
|
|
2185
|
+
});
|
|
2186
|
+
}
|
|
2187
|
+
shaking(compiler, document) {
|
|
2493
2188
|
const rc = compiler.context.rc;
|
|
2494
|
-
const
|
|
2495
|
-
const
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2189
|
+
const matcher = compiler.context.matcher;
|
|
2190
|
+
const isAccepted = (pathname, method, operation) => {
|
|
2191
|
+
if (!SupportedMethods.includes(method)) return false;
|
|
2192
|
+
return !matcher.isOperationIgnored(new OperationDefinition({
|
|
2193
|
+
method,
|
|
2194
|
+
pathname,
|
|
2195
|
+
operation,
|
|
2196
|
+
module: document.module,
|
|
2197
|
+
document
|
|
2198
|
+
}));
|
|
2199
|
+
};
|
|
2200
|
+
const sharkedSwagger = (0, import_openapi_shaking.openapiShakingSync)(
|
|
2201
|
+
document.specification,
|
|
2202
|
+
isAccepted,
|
|
2203
|
+
{ tolerant: rc.tolerant }
|
|
2501
2204
|
);
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
document,
|
|
2506
|
-
|
|
2507
|
-
|
|
2205
|
+
return new ApiDocumentV3_1(
|
|
2206
|
+
sharkedSwagger,
|
|
2207
|
+
new ModuleDefinition(
|
|
2208
|
+
document.module.name,
|
|
2209
|
+
{
|
|
2210
|
+
url: `memory://${document.module.name}.v3_1.sharked.json`,
|
|
2211
|
+
headers: {},
|
|
2212
|
+
encoding: "utf8"
|
|
2213
|
+
}
|
|
2214
|
+
)
|
|
2508
2215
|
);
|
|
2509
|
-
return [...nestjsModuleArtifacts, ...nestjsClientArtifacts];
|
|
2510
2216
|
}
|
|
2511
|
-
static
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
return filepath.join("/");
|
|
2217
|
+
static register(compiler) {
|
|
2218
|
+
if (!MetadataStorage10.has(compiler)) {
|
|
2219
|
+
MetadataStorage10.set(compiler, {
|
|
2220
|
+
hooks: {}
|
|
2221
|
+
});
|
|
2222
|
+
}
|
|
2223
|
+
return MetadataStorage10.get(compiler);
|
|
2519
2224
|
}
|
|
2520
|
-
static
|
|
2521
|
-
return
|
|
2225
|
+
static of(compiler) {
|
|
2226
|
+
return this.register(compiler);
|
|
2522
2227
|
}
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2228
|
+
};
|
|
2229
|
+
|
|
2230
|
+
// src/plugins/terminal-select/utils/select-operation-definitions.ts
|
|
2231
|
+
var import_inquirer_select_pro = require("inquirer-select-pro");
|
|
2232
|
+
var import_prompt_adapter_inquirer = require("@listr2/prompt-adapter-inquirer");
|
|
2233
|
+
async function selectOperationDefinitions(task, operationDefinitions) {
|
|
2234
|
+
const selectedOperationDefinitions = await task.prompt(import_prompt_adapter_inquirer.ListrInquirerPromptAdapter).run(
|
|
2235
|
+
import_inquirer_select_pro.select,
|
|
2236
|
+
{
|
|
2237
|
+
message: "Select Pathname",
|
|
2238
|
+
defaultValue: [],
|
|
2239
|
+
options: (input) => {
|
|
2240
|
+
const items = operationDefinitions.map((op) => ({ name: `${op.module.name} ${op.method.toUpperCase()} ${op.pathname}`, value: op }));
|
|
2241
|
+
if (!input) return items;
|
|
2242
|
+
const keys2 = input.trim().toLowerCase().split(/\s+/);
|
|
2243
|
+
return items.filter((i) => {
|
|
2244
|
+
const name = i.name.toLowerCase();
|
|
2245
|
+
return keys2.every((q) => name.includes(q));
|
|
2246
|
+
});
|
|
2247
|
+
}
|
|
2248
|
+
}
|
|
2249
|
+
);
|
|
2250
|
+
return selectedOperationDefinitions;
|
|
2251
|
+
}
|
|
2252
|
+
|
|
2253
|
+
// src/plugins/terminal-select/constants/metadata-storage.ts
|
|
2254
|
+
var MetadataStorage11 = /* @__PURE__ */ new WeakMap();
|
|
2255
|
+
|
|
2256
|
+
// src/plugins/terminal-select/terminal-select.plugin.ts
|
|
2257
|
+
var TerminalSelectPlugin = class _TerminalSelectPlugin {
|
|
2258
|
+
constructor(options) {
|
|
2259
|
+
this.options = options;
|
|
2260
|
+
}
|
|
2261
|
+
apply(compiler) {
|
|
2262
|
+
if (MetadataStorage11.has(compiler)) return;
|
|
2263
|
+
_TerminalSelectPlugin.register(compiler);
|
|
2264
|
+
compiler.hooks.afterDownload.tapPromise(_TerminalSelectPlugin.name, async (task) => {
|
|
2265
|
+
const context = compiler.context;
|
|
2266
|
+
const matcher = context.matcher;
|
|
2267
|
+
const documents = context.documents;
|
|
2268
|
+
const operationDefinitions = documents.flatMap((document) => document.operations);
|
|
2269
|
+
const selectedOperationDefinitions = await selectOperationDefinitions(task, operationDefinitions);
|
|
2270
|
+
if (this.options.clear) {
|
|
2271
|
+
matcher.append({
|
|
2272
|
+
persist: false,
|
|
2273
|
+
ignore: true,
|
|
2274
|
+
moduleName: "*",
|
|
2275
|
+
operationMethod: "*",
|
|
2276
|
+
operationPathname: "*"
|
|
2277
|
+
});
|
|
2278
|
+
}
|
|
2279
|
+
for (const op of selectedOperationDefinitions) {
|
|
2280
|
+
matcher.append({
|
|
2281
|
+
persist: !!this.options.persist,
|
|
2282
|
+
ignore: this.options.mode === "add",
|
|
2283
|
+
moduleName: op.module.name,
|
|
2284
|
+
operationMethod: op.method,
|
|
2285
|
+
operationPathname: op.pathname
|
|
2286
|
+
});
|
|
2287
|
+
}
|
|
2288
|
+
});
|
|
2289
|
+
}
|
|
2290
|
+
static register(compiler) {
|
|
2291
|
+
if (!MetadataStorage11.has(compiler)) {
|
|
2292
|
+
MetadataStorage11.set(compiler, {
|
|
2293
|
+
hooks: {}
|
|
2294
|
+
});
|
|
2295
|
+
}
|
|
2296
|
+
return MetadataStorage11.get(compiler);
|
|
2531
2297
|
}
|
|
2532
|
-
static
|
|
2533
|
-
return
|
|
2298
|
+
static of(compiler) {
|
|
2299
|
+
return this.register(compiler);
|
|
2534
2300
|
}
|
|
2535
2301
|
};
|
|
2536
2302
|
|
|
2537
|
-
// src/plugins/
|
|
2538
|
-
var
|
|
2539
|
-
|
|
2303
|
+
// src/plugins/initialize/initialize.plugin.ts
|
|
2304
|
+
var R22 = __toESM(require("ramda"), 1);
|
|
2305
|
+
var InitializePlugin = class _InitializePlugin {
|
|
2306
|
+
constructor(options) {
|
|
2307
|
+
this.options = options;
|
|
2308
|
+
}
|
|
2540
2309
|
apply(compiler) {
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2310
|
+
compiler.hooks.setup.tap(_InitializePlugin.name, (task) => {
|
|
2311
|
+
const plugins = [
|
|
2312
|
+
new DownloadHttpFilePlugin(),
|
|
2313
|
+
new DownloadLocalFilePlugin()
|
|
2314
|
+
];
|
|
2315
|
+
if (this.options.build) {
|
|
2316
|
+
plugins.push(new ShakingPlugin());
|
|
2317
|
+
}
|
|
2318
|
+
if (this.options.interactive) {
|
|
2319
|
+
plugins.push(
|
|
2320
|
+
new TerminalSelectPlugin(
|
|
2321
|
+
typeof this.options.interactive === "object" ? this.options.interactive : { mode: "except" }
|
|
2322
|
+
)
|
|
2323
|
+
);
|
|
2324
|
+
}
|
|
2325
|
+
const rc = compiler.context.rc;
|
|
2326
|
+
plugins.push(
|
|
2327
|
+
...R22.unnest(
|
|
2328
|
+
(rc.translators || []).map((translator) => {
|
|
2329
|
+
const plugins2 = translator.apply();
|
|
2330
|
+
return plugins2;
|
|
2331
|
+
})
|
|
2332
|
+
)
|
|
2333
|
+
);
|
|
2334
|
+
if (rc.plugins && rc.plugins.length) {
|
|
2335
|
+
plugins.push(...rc.plugins);
|
|
2336
|
+
}
|
|
2337
|
+
for (const plugin of plugins) {
|
|
2338
|
+
plugin.apply(compiler);
|
|
2339
|
+
}
|
|
2545
2340
|
});
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2341
|
+
if (this.options.includes && this.options.includes.length) {
|
|
2342
|
+
const modulesIncludes = this.options.includes;
|
|
2343
|
+
compiler.hooks.afterSetup.tap(_InitializePlugin.name, (task) => {
|
|
2344
|
+
const rc = compiler.context.rc;
|
|
2345
|
+
const matcher = compiler.context.matcher;
|
|
2346
|
+
const notExistModules = modulesIncludes.filter((moduleName) => !(moduleName in rc.modules));
|
|
2347
|
+
if (notExistModules.length) {
|
|
2348
|
+
throw new Error(`Cannot find module(s) ${notExistModules.join(", ")} in config file.`);
|
|
2349
|
+
}
|
|
2350
|
+
const ignoredModules = R22.difference(R22.keys(rc.modules), modulesIncludes);
|
|
2351
|
+
for (const moduleName of ignoredModules) {
|
|
2352
|
+
matcher.append({
|
|
2353
|
+
persist: false,
|
|
2354
|
+
ignore: true,
|
|
2355
|
+
moduleName,
|
|
2356
|
+
operationMethod: "*",
|
|
2357
|
+
operationPathname: "*"
|
|
2358
|
+
});
|
|
2552
2359
|
}
|
|
2553
2360
|
});
|
|
2554
2361
|
}
|
|
2555
|
-
return MetadataStorage3.get(compiler);
|
|
2556
|
-
}
|
|
2557
|
-
static of(compiler) {
|
|
2558
|
-
return MetadataStorage3.get(compiler);
|
|
2559
2362
|
}
|
|
2560
2363
|
};
|
|
2561
2364
|
|
|
2562
|
-
// src/plugins/
|
|
2563
|
-
var
|
|
2365
|
+
// src/plugins/overwrite-query-options/overwrite-query-options.plugin.ts
|
|
2366
|
+
var QsArrayFormatUnion = Object.values(QsArrayFormat);
|
|
2564
2367
|
|
|
2565
|
-
// src/
|
|
2566
|
-
var
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
const spec = this.deserialize(content);
|
|
2573
|
-
return JSON.stringify(spec);
|
|
2574
|
-
});
|
|
2368
|
+
// src/translators/micro-function.translator.ts
|
|
2369
|
+
var MicroFunctionTranslator = class {
|
|
2370
|
+
apply() {
|
|
2371
|
+
return [
|
|
2372
|
+
new GenerateDeclarationPlugin(),
|
|
2373
|
+
new GenerateMicroFunctionPlugin()
|
|
2374
|
+
];
|
|
2575
2375
|
}
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2376
|
+
};
|
|
2377
|
+
|
|
2378
|
+
// src/compiler/tasks/setup/index.ts
|
|
2379
|
+
var explore = (0, import_cosmiconfig.cosmiconfig)("keq");
|
|
2380
|
+
function main(compiler, options) {
|
|
2381
|
+
return {
|
|
2382
|
+
task: async (context, task) => {
|
|
2383
|
+
const result = options?.config ? await explore.load(options.config) : await explore.search();
|
|
2384
|
+
if (!result || "isEmpty" in result && result.isEmpty) {
|
|
2385
|
+
throw new Error("Cannot find config file.");
|
|
2584
2386
|
}
|
|
2585
|
-
|
|
2387
|
+
const rc = parseRuntimeConfig(result.config);
|
|
2388
|
+
if (options?.debug) {
|
|
2389
|
+
await import_fs_extra2.default.ensureDir(".keq");
|
|
2390
|
+
rc.debug = true;
|
|
2391
|
+
}
|
|
2392
|
+
rc.tolerant = Boolean(rc.tolerant);
|
|
2393
|
+
if (!rc.translators || !rc.translators.length) {
|
|
2394
|
+
rc.translators = [new MicroFunctionTranslator()];
|
|
2395
|
+
}
|
|
2396
|
+
const packageJsonInfo = findNearestPackageJson();
|
|
2397
|
+
if (packageJsonInfo) {
|
|
2398
|
+
const moduleSystem = getProjectModuleSystem(packageJsonInfo);
|
|
2399
|
+
rc.esm = moduleSystem === "esm";
|
|
2400
|
+
}
|
|
2401
|
+
context.rc = rc;
|
|
2402
|
+
let matcher = new IgnoreMatcher([]);
|
|
2403
|
+
if (result.filepath) {
|
|
2404
|
+
const ignoreFilepath = import_path.default.resolve(import_path.default.dirname(result.filepath), ".keqignore");
|
|
2405
|
+
if (await import_fs_extra2.default.exists(ignoreFilepath)) {
|
|
2406
|
+
matcher = await IgnoreMatcher.read(ignoreFilepath);
|
|
2407
|
+
}
|
|
2408
|
+
}
|
|
2409
|
+
const ignoreRules = options.ignore === false ? [] : options.ignore?.rules || [];
|
|
2410
|
+
for (const rule of ignoreRules) {
|
|
2411
|
+
matcher.append({
|
|
2412
|
+
persist: !!rule.persist,
|
|
2413
|
+
ignore: rule.ignore,
|
|
2414
|
+
moduleName: rule.moduleName,
|
|
2415
|
+
operationMethod: rule.operationMethod,
|
|
2416
|
+
operationPathname: rule.operationPathname
|
|
2417
|
+
});
|
|
2418
|
+
}
|
|
2419
|
+
context.matcher = matcher;
|
|
2420
|
+
await compiler.hooks.setup.promise(task);
|
|
2586
2421
|
}
|
|
2587
|
-
}
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2422
|
+
};
|
|
2423
|
+
}
|
|
2424
|
+
function createSetupTask(compiler, options) {
|
|
2425
|
+
return {
|
|
2426
|
+
title: "Setup",
|
|
2427
|
+
enabled: options?.enabled,
|
|
2428
|
+
skip: options?.skip,
|
|
2429
|
+
task: (context, task) => task.newListr(
|
|
2430
|
+
[
|
|
2431
|
+
main(compiler, options),
|
|
2432
|
+
{
|
|
2433
|
+
task: (context2, task2) => compiler.hooks.afterSetup.promise(task2)
|
|
2434
|
+
}
|
|
2435
|
+
],
|
|
2436
|
+
{
|
|
2437
|
+
concurrent: false
|
|
2438
|
+
}
|
|
2439
|
+
)
|
|
2440
|
+
};
|
|
2441
|
+
}
|
|
2594
2442
|
|
|
2595
|
-
// src/
|
|
2596
|
-
var
|
|
2597
|
-
var
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
const
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2443
|
+
// src/compiler/tasks/download/index.ts
|
|
2444
|
+
var import_listr2 = require("listr2");
|
|
2445
|
+
var import_openapi_parser2 = require("@scalar/openapi-parser");
|
|
2446
|
+
function main2(compiler, options) {
|
|
2447
|
+
return {
|
|
2448
|
+
task: (context, task) => {
|
|
2449
|
+
if (!context.rc || !context.matcher) {
|
|
2450
|
+
throw new Error("Please run setup task first.");
|
|
2451
|
+
}
|
|
2452
|
+
const rc = context.rc;
|
|
2453
|
+
const matcher = context.matcher;
|
|
2454
|
+
context.documents = [];
|
|
2455
|
+
return task.newListr(
|
|
2456
|
+
Object.entries(rc.modules).map(([moduleName, address]) => new ModuleDefinition(moduleName, address)).map((moduleDefinition) => ({
|
|
2457
|
+
title: moduleDefinition.name,
|
|
2458
|
+
task: async (ctx, task2) => {
|
|
2459
|
+
if (options?.skipIgnoredModules && matcher.isModuleIgnored(moduleDefinition)) {
|
|
2460
|
+
task2.skip(`(${moduleDefinition.name}) is ignored`);
|
|
2461
|
+
return;
|
|
2462
|
+
}
|
|
2463
|
+
task2.output = `Downloaded from ${moduleDefinition.address.url}`;
|
|
2464
|
+
const content = await compiler.hooks.download.promise(moduleDefinition.address, moduleDefinition, task2);
|
|
2465
|
+
if (!content) {
|
|
2466
|
+
throw new Exception(moduleDefinition, `Cannot download document from ${moduleDefinition.address.url}`);
|
|
2467
|
+
}
|
|
2468
|
+
const spec = JSON.parse(content);
|
|
2469
|
+
const { valid, errors } = await (0, import_openapi_parser2.validate)(spec);
|
|
2470
|
+
if (!valid) {
|
|
2471
|
+
const message = `${moduleDefinition.name} module openapi/swagger file does not conform to the openapi specifications or have grammatical errors, which may cause unexpected errors:
|
|
2472
|
+
${errors?.map((e) => ` - ${e.message}`).join("\n")}`;
|
|
2473
|
+
task2.output = message;
|
|
2474
|
+
}
|
|
2475
|
+
OpenapiUtils.dereferenceOperation(spec);
|
|
2476
|
+
const document = new ApiDocumentV3_1(
|
|
2477
|
+
spec,
|
|
2478
|
+
moduleDefinition
|
|
2479
|
+
);
|
|
2480
|
+
ctx.documents?.push(document);
|
|
2481
|
+
}
|
|
2482
|
+
})),
|
|
2483
|
+
{
|
|
2484
|
+
concurrent: true,
|
|
2485
|
+
exitOnError: false,
|
|
2486
|
+
collectErrors: "minimal",
|
|
2487
|
+
rendererOptions: {
|
|
2488
|
+
collapseSubtasks: false,
|
|
2489
|
+
// collapseSkips: false,
|
|
2490
|
+
suffixSkips: true,
|
|
2491
|
+
timer: import_listr2.PRESET_TIMER
|
|
2492
|
+
}
|
|
2493
|
+
}
|
|
2494
|
+
);
|
|
2495
|
+
}
|
|
2496
|
+
};
|
|
2497
|
+
}
|
|
2498
|
+
function createDownloadTask(compiler, options) {
|
|
2499
|
+
return {
|
|
2500
|
+
title: "Download",
|
|
2501
|
+
enabled: options?.enabled,
|
|
2502
|
+
skip: options?.skip,
|
|
2503
|
+
task: (_, task) => task.newListr(
|
|
2504
|
+
[
|
|
2505
|
+
main2(compiler, options),
|
|
2506
|
+
{
|
|
2507
|
+
task: (context, task2) => compiler.hooks.afterDownload.promise(task2)
|
|
2508
|
+
}
|
|
2509
|
+
],
|
|
2510
|
+
{
|
|
2511
|
+
concurrent: false
|
|
2512
|
+
}
|
|
2513
|
+
)
|
|
2514
|
+
};
|
|
2515
|
+
}
|
|
2516
|
+
|
|
2517
|
+
// src/compiler/tasks/persist/index.ts
|
|
2518
|
+
var path11 = __toESM(require("path"), 1);
|
|
2519
|
+
var import_fs_extra3 = __toESM(require("fs-extra"), 1);
|
|
2520
|
+
function createPersistArtifactTask() {
|
|
2521
|
+
return {
|
|
2522
|
+
title: "Write files",
|
|
2523
|
+
task: async (context, task) => {
|
|
2524
|
+
if (!context.rc) throw new Error("Please run setup task first.");
|
|
2525
|
+
if (!context.artifacts || context.artifacts.length === 0) {
|
|
2526
|
+
task.skip("No compiled artifacts to persist.");
|
|
2527
|
+
return;
|
|
2528
|
+
}
|
|
2529
|
+
const rc = context.rc;
|
|
2530
|
+
const artifacts = context.artifacts;
|
|
2531
|
+
const total = artifacts.length;
|
|
2532
|
+
let completed = 0;
|
|
2533
|
+
const files = await Promise.all(artifacts.map(async (artifact) => {
|
|
2534
|
+
const realpath = `./${path11.join(rc.outdir, artifact.filepath)}`;
|
|
2535
|
+
await import_fs_extra3.default.ensureFile(realpath);
|
|
2536
|
+
await import_fs_extra3.default.writeFile(realpath, artifact.renderer());
|
|
2537
|
+
completed += 1;
|
|
2538
|
+
task.output = `Persisted ${completed}/${total} files`;
|
|
2539
|
+
return new Asset(path11.resolve(realpath));
|
|
2540
|
+
}));
|
|
2541
|
+
context.assets = files;
|
|
2542
|
+
}
|
|
2543
|
+
};
|
|
2544
|
+
}
|
|
2545
|
+
function createPersistIgnoreTask() {
|
|
2546
|
+
return {
|
|
2547
|
+
title: "Update .keqignore",
|
|
2548
|
+
task: async (context, task) => {
|
|
2549
|
+
if (!context.matcher) throw new Error("Please run setup task first.");
|
|
2550
|
+
const matcher = context.matcher;
|
|
2551
|
+
await matcher.write(".keqignore");
|
|
2552
|
+
}
|
|
2553
|
+
};
|
|
2554
|
+
}
|
|
2555
|
+
function main3() {
|
|
2556
|
+
return {
|
|
2557
|
+
task: (context, task) => task.newListr(
|
|
2558
|
+
[
|
|
2559
|
+
createPersistArtifactTask(),
|
|
2560
|
+
createPersistIgnoreTask()
|
|
2561
|
+
],
|
|
2562
|
+
{
|
|
2563
|
+
concurrent: true,
|
|
2564
|
+
rendererOptions: {
|
|
2565
|
+
collapseSubtasks: true
|
|
2566
|
+
}
|
|
2567
|
+
}
|
|
2568
|
+
)
|
|
2569
|
+
};
|
|
2570
|
+
}
|
|
2571
|
+
function createPersistTask(compiler, options) {
|
|
2572
|
+
return {
|
|
2573
|
+
title: "Persist",
|
|
2574
|
+
enabled: options?.enabled,
|
|
2575
|
+
skip: options?.skip,
|
|
2576
|
+
task: (context, task) => task.newListr(
|
|
2577
|
+
[
|
|
2578
|
+
main3(),
|
|
2579
|
+
{
|
|
2580
|
+
task: (context2, task2) => compiler.hooks.afterPersist.promise(task2)
|
|
2581
|
+
}
|
|
2582
|
+
],
|
|
2583
|
+
{
|
|
2584
|
+
concurrent: false
|
|
2610
2585
|
}
|
|
2611
|
-
|
|
2612
|
-
}
|
|
2613
|
-
}
|
|
2586
|
+
)
|
|
2587
|
+
};
|
|
2588
|
+
}
|
|
2614
2589
|
|
|
2615
|
-
// src/
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
}
|
|
2624
|
-
}
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
{
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
`file://${document.module.name}.v3_1.sharked.json`
|
|
2648
|
-
)
|
|
2649
|
-
);
|
|
2650
|
-
}
|
|
2651
|
-
};
|
|
2590
|
+
// src/compiler/tasks/compile/index.ts
|
|
2591
|
+
function main4(compiler) {
|
|
2592
|
+
return {
|
|
2593
|
+
task: async (context, task) => {
|
|
2594
|
+
if (!context.rc) throw new Error("Please run setup task first.");
|
|
2595
|
+
if (!context.documents) throw new Error("Please run shaking task first.");
|
|
2596
|
+
context.artifacts = [];
|
|
2597
|
+
await compiler.hooks.compile.promise(task);
|
|
2598
|
+
}
|
|
2599
|
+
};
|
|
2600
|
+
}
|
|
2601
|
+
function createCompileTask(compiler, options) {
|
|
2602
|
+
return {
|
|
2603
|
+
title: "Compile",
|
|
2604
|
+
enabled: options?.enabled,
|
|
2605
|
+
skip: options?.skip,
|
|
2606
|
+
task: (context, task) => task.newListr(
|
|
2607
|
+
[
|
|
2608
|
+
{
|
|
2609
|
+
task: (context2, task2) => compiler.hooks.beforeCompile.promise(task2)
|
|
2610
|
+
},
|
|
2611
|
+
main4(compiler),
|
|
2612
|
+
{
|
|
2613
|
+
task: (context2, task2) => compiler.hooks.afterCompile.promise(task2)
|
|
2614
|
+
}
|
|
2615
|
+
],
|
|
2616
|
+
{
|
|
2617
|
+
concurrent: false
|
|
2618
|
+
}
|
|
2619
|
+
)
|
|
2620
|
+
};
|
|
2621
|
+
}
|
|
2652
2622
|
|
|
2653
|
-
// src/
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
{
|
|
2660
|
-
message: "Select Pathname",
|
|
2661
|
-
defaultValue: [],
|
|
2662
|
-
options: (input) => {
|
|
2663
|
-
const items = operationDefinitions.map((op) => ({ name: `${op.module.name} ${op.method.toUpperCase()} ${op.pathname}`, value: op }));
|
|
2664
|
-
if (!input) return items;
|
|
2665
|
-
const keys2 = input.trim().toLowerCase().split(/\s+/);
|
|
2666
|
-
return items.filter((i) => {
|
|
2667
|
-
const name = i.name.toLowerCase();
|
|
2668
|
-
return keys2.every((q) => name.includes(q));
|
|
2669
|
-
});
|
|
2623
|
+
// src/compiler/intercepter/print-information.ts
|
|
2624
|
+
function proxyTaskWrapper(pluginName, task) {
|
|
2625
|
+
return new Proxy(task, {
|
|
2626
|
+
set(target, prop2, value) {
|
|
2627
|
+
if (prop2 !== "output") {
|
|
2628
|
+
return Reflect.set(target, prop2, value);
|
|
2670
2629
|
}
|
|
2630
|
+
target.output = `[Plugin: ${pluginName}] ${value}`;
|
|
2631
|
+
return true;
|
|
2671
2632
|
}
|
|
2672
|
-
);
|
|
2673
|
-
return selectedOperationDefinitions;
|
|
2633
|
+
});
|
|
2674
2634
|
}
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
const selectedOperationDefinitions = await selectOperationDefinitions(task, operationDefinitions);
|
|
2688
|
-
if (this.options.clear) {
|
|
2689
|
-
matcher.append({
|
|
2690
|
-
persist: false,
|
|
2691
|
-
ignore: true,
|
|
2692
|
-
moduleName: "*",
|
|
2693
|
-
operationMethod: "*",
|
|
2694
|
-
operationPathname: "*"
|
|
2695
|
-
});
|
|
2635
|
+
function printInformation(taskIndex) {
|
|
2636
|
+
return {
|
|
2637
|
+
register: (tap) => {
|
|
2638
|
+
const fn = tap.fn;
|
|
2639
|
+
if (tap.type === "promise") {
|
|
2640
|
+
tap.fn = (...args) => {
|
|
2641
|
+
const task = args[taskIndex];
|
|
2642
|
+
const proxyTask = proxyTaskWrapper(tap.name, task);
|
|
2643
|
+
args[taskIndex] = proxyTask;
|
|
2644
|
+
proxyTask.output = "Processing...";
|
|
2645
|
+
return fn(...args);
|
|
2646
|
+
};
|
|
2696
2647
|
}
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
}
|
|
2648
|
+
if (tap.type === "sync") {
|
|
2649
|
+
tap.fn = (...args) => {
|
|
2650
|
+
const task = args[taskIndex];
|
|
2651
|
+
const proxyTask = proxyTaskWrapper(tap.name, task);
|
|
2652
|
+
args[taskIndex] = proxyTask;
|
|
2653
|
+
proxyTask.output = "Processing...";
|
|
2654
|
+
return fn(...args);
|
|
2655
|
+
};
|
|
2705
2656
|
}
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2657
|
+
if (tap.type === "async") {
|
|
2658
|
+
tap.fn = (...args) => {
|
|
2659
|
+
const task = args[taskIndex];
|
|
2660
|
+
const proxyTask = proxyTaskWrapper(tap.name, task);
|
|
2661
|
+
args[taskIndex] = proxyTask;
|
|
2662
|
+
proxyTask.output = "Processing...";
|
|
2663
|
+
return fn(...args);
|
|
2664
|
+
};
|
|
2665
|
+
}
|
|
2666
|
+
return tap;
|
|
2667
|
+
}
|
|
2668
|
+
};
|
|
2669
|
+
}
|
|
2709
2670
|
|
|
2710
|
-
// src/
|
|
2671
|
+
// src/compiler/intercepter/perfect-error-message.ts
|
|
2711
2672
|
var R23 = __toESM(require("ramda"), 1);
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
new GenerateDeclarationPlugin().apply(compiler);
|
|
2721
|
-
if (this.options.build) {
|
|
2722
|
-
new ShakingPlugin().apply(compiler);
|
|
2723
|
-
}
|
|
2724
|
-
if (this.options.interactive) {
|
|
2725
|
-
new TerminalSelectPlugin(
|
|
2726
|
-
typeof this.options.interactive === "object" ? this.options.interactive : { mode: "except" }
|
|
2727
|
-
).apply(compiler);
|
|
2673
|
+
function perfectErrorMessage() {
|
|
2674
|
+
return {
|
|
2675
|
+
register: (tap) => {
|
|
2676
|
+
const fn = tap.fn;
|
|
2677
|
+
function prefix(err) {
|
|
2678
|
+
if (err instanceof Error) {
|
|
2679
|
+
err.message = `[Plugin: ${tap.name}] ${err.message}`;
|
|
2680
|
+
}
|
|
2728
2681
|
}
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2682
|
+
if (tap.type === "promise") {
|
|
2683
|
+
tap.fn = async (...args) => {
|
|
2684
|
+
try {
|
|
2685
|
+
return await fn(...args);
|
|
2686
|
+
} catch (err) {
|
|
2687
|
+
prefix(err);
|
|
2688
|
+
throw err;
|
|
2689
|
+
}
|
|
2690
|
+
};
|
|
2734
2691
|
}
|
|
2735
|
-
if (
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2692
|
+
if (tap.type === "sync") {
|
|
2693
|
+
tap.fn = (...args) => {
|
|
2694
|
+
try {
|
|
2695
|
+
return fn(...args);
|
|
2696
|
+
} catch (err) {
|
|
2697
|
+
prefix(err);
|
|
2698
|
+
throw err;
|
|
2699
|
+
}
|
|
2700
|
+
};
|
|
2739
2701
|
}
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
const notExistModules = modulesIncludes.filter((moduleName) => !(moduleName in rc.modules));
|
|
2747
|
-
if (notExistModules.length) {
|
|
2748
|
-
throw new Error(`Cannot find module(s) ${notExistModules.join(", ")} in config file.`);
|
|
2749
|
-
}
|
|
2750
|
-
const ignoredModules = R23.difference(R23.keys(rc.modules), modulesIncludes);
|
|
2751
|
-
for (const moduleName of ignoredModules) {
|
|
2752
|
-
matcher.append({
|
|
2753
|
-
persist: false,
|
|
2754
|
-
ignore: true,
|
|
2755
|
-
moduleName,
|
|
2756
|
-
operationMethod: "*",
|
|
2757
|
-
operationPathname: "*"
|
|
2702
|
+
if (tap.type === "async") {
|
|
2703
|
+
tap.fn = (...args) => {
|
|
2704
|
+
const callback = R23.last(args);
|
|
2705
|
+
return fn(...R23.init(args), (err, result) => {
|
|
2706
|
+
prefix(err);
|
|
2707
|
+
return callback(err, result);
|
|
2758
2708
|
});
|
|
2759
|
-
}
|
|
2760
|
-
}
|
|
2709
|
+
};
|
|
2710
|
+
}
|
|
2711
|
+
return tap;
|
|
2761
2712
|
}
|
|
2762
|
-
}
|
|
2763
|
-
}
|
|
2764
|
-
|
|
2765
|
-
// src/plugins/overwrite-query-options/overwrite-query-options.plugin.ts
|
|
2766
|
-
var QsArrayFormatUnion = Object.values(QsArrayFormat);
|
|
2713
|
+
};
|
|
2714
|
+
}
|
|
2767
2715
|
|
|
2768
2716
|
// src/compiler/compiler.ts
|
|
2769
2717
|
var Compiler = class {
|