@keq-request/cli 5.0.0-alpha.27 → 5.0.0-alpha.28
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 +12 -0
- package/dist/cli.cjs +132 -86
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +132 -86
- 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 +137 -93
- 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 +136 -91
- 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/download-http-file/download-http-file.plugin.d.ts +2 -2
- package/dist/plugins/download-http-file/download-http-file.plugin.d.ts.map +1 -1
- package/dist/plugins/download-local-file/download-local-file.plugin.d.ts.map +1 -1
- package/dist/plugins/shaking/shaking.plugin.d.ts.map +1 -1
- package/dist/plugins.cjs +25 -12
- package/dist/plugins.cjs.map +1 -1
- package/dist/plugins.js +25 -12
- package/dist/plugins.js.map +1 -1
- package/dist/types/address.d.ts +8 -0
- package/dist/types/address.d.ts.map +1 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/runtime-config.d.ts +16 -7
- package/dist/types/runtime-config.d.ts.map +1 -1
- package/dist/utils/is-valid-url.d.ts +16 -0
- package/dist/utils/is-valid-url.d.ts.map +1 -0
- package/package.json +3 -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
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { Address } from '../types/address.js';
|
|
1
2
|
export declare class ModuleDefinition {
|
|
2
3
|
name: string;
|
|
3
|
-
address:
|
|
4
|
-
constructor(name: string, address: string);
|
|
4
|
+
address: Address;
|
|
5
|
+
constructor(name: string, address: string | Address);
|
|
5
6
|
static unknown(): ModuleDefinition;
|
|
6
7
|
}
|
|
7
8
|
//# sourceMappingURL=module-definition.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module-definition.d.ts","sourceRoot":"","sources":["../../src/models/module-definition.ts"],"names":[],"mappings":"AAAA,qBAAa,gBAAgB;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"module-definition.d.ts","sourceRoot":"","sources":["../../src/models/module-definition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAG5C,qBAAa,gBAAgB;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,OAAO,CAAA;gBAEJ,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO;IAUnD,MAAM,CAAC,OAAO,IAAI,gBAAgB;CAGnC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Compiler } from '../../compiler/index.js';
|
|
2
|
-
import { Plugin } from '../../types/
|
|
2
|
+
import { Plugin, Address } from '../../types/index.js';
|
|
3
3
|
export declare class DownloadHttpFilePlugin implements Plugin {
|
|
4
4
|
apply(compiler: Compiler): void;
|
|
5
|
-
download(address:
|
|
5
|
+
download(address: Address): Promise<string>;
|
|
6
6
|
deserialize(content: string): object;
|
|
7
7
|
}
|
|
8
8
|
//# sourceMappingURL=download-http-file.plugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"download-http-file.plugin.d.ts","sourceRoot":"","sources":["../../../src/plugins/download-http-file/download-http-file.plugin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"download-http-file.plugin.d.ts","sourceRoot":"","sources":["../../../src/plugins/download-http-file/download-http-file.plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAC9C,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAIlD,qBAAa,sBAAuB,YAAW,MAAM;IACnD,KAAK,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IAYzB,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC;IAiBjD,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;CAKrC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"download-local-file.plugin.d.ts","sourceRoot":"","sources":["../../../src/plugins/download-local-file/download-local-file.plugin.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"download-local-file.plugin.d.ts","sourceRoot":"","sources":["../../../src/plugins/download-local-file/download-local-file.plugin.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAKzC,qBAAa,uBAAwB,YAAW,MAAM;IACpD,KAAK,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;CAkBhC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shaking.plugin.d.ts","sourceRoot":"","sources":["../../../src/plugins/shaking/shaking.plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAC9C,OAAO,EAAE,eAAe,EAAyC,MAAM,mBAAmB,CAAA;AAK1F,qBAAa,aAAc,YAAW,MAAM;IAC1C,KAAK,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IAY/B,OAAO,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,eAAe,GAAG,eAAe;
|
|
1
|
+
{"version":3,"file":"shaking.plugin.d.ts","sourceRoot":"","sources":["../../../src/plugins/shaking/shaking.plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAC9C,OAAO,EAAE,eAAe,EAAyC,MAAM,mBAAmB,CAAA;AAK1F,qBAAa,aAAc,YAAW,MAAM;IAC1C,KAAK,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IAY/B,OAAO,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,eAAe,GAAG,eAAe;CAmCxE"}
|
package/dist/plugins.cjs
CHANGED
|
@@ -251,10 +251,14 @@ var ModuleDefinition = class _ModuleDefinition {
|
|
|
251
251
|
address;
|
|
252
252
|
constructor(name, address) {
|
|
253
253
|
this.name = name;
|
|
254
|
-
|
|
254
|
+
if (typeof address === "string") {
|
|
255
|
+
this.address = { url: address, headers: {}, encoding: "utf8" };
|
|
256
|
+
} else {
|
|
257
|
+
this.address = address;
|
|
258
|
+
}
|
|
255
259
|
}
|
|
256
260
|
static unknown() {
|
|
257
|
-
return new _ModuleDefinition("", "");
|
|
261
|
+
return new _ModuleDefinition("", { url: "", headers: {}, encoding: "utf8" });
|
|
258
262
|
}
|
|
259
263
|
};
|
|
260
264
|
|
|
@@ -2121,24 +2125,25 @@ var ChineseToPinyinPlugin = class _ChineseToPinyinPlugin {
|
|
|
2121
2125
|
};
|
|
2122
2126
|
|
|
2123
2127
|
// src/plugins/download-http-file/download-http-file.plugin.ts
|
|
2124
|
-
var validUrl = __toESM(require("valid-url"), 1);
|
|
2125
2128
|
var DownloadHttpFilePlugin = class _DownloadHttpFilePlugin {
|
|
2126
2129
|
apply(compiler) {
|
|
2127
2130
|
compiler.hooks.download.tapPromise(_DownloadHttpFilePlugin.name, async (address, task) => {
|
|
2128
|
-
|
|
2131
|
+
const { url } = address;
|
|
2132
|
+
if (!url.startsWith("http://") && !url.startsWith("https://")) return void 0;
|
|
2129
2133
|
const content = await this.download(address);
|
|
2130
2134
|
const spec = this.deserialize(content);
|
|
2131
2135
|
return JSON.stringify(spec);
|
|
2132
2136
|
});
|
|
2133
2137
|
}
|
|
2134
2138
|
async download(address) {
|
|
2139
|
+
const { url, headers } = address;
|
|
2135
2140
|
try {
|
|
2136
|
-
const res = await fetch(
|
|
2141
|
+
const res = await fetch(url, { headers });
|
|
2137
2142
|
if (res.status >= 400) throw new Error(`failed with status code ${res.status}`);
|
|
2138
2143
|
return await res.text();
|
|
2139
2144
|
} catch (e) {
|
|
2140
2145
|
if (e instanceof Error) {
|
|
2141
|
-
e.message = `Unable get the openapi/swagger file from ${
|
|
2146
|
+
e.message = `Unable get the openapi/swagger file from ${url}: ${e.message}`;
|
|
2142
2147
|
}
|
|
2143
2148
|
throw e;
|
|
2144
2149
|
}
|
|
@@ -2154,17 +2159,21 @@ var DownloadHttpFilePlugin = class _DownloadHttpFilePlugin {
|
|
|
2154
2159
|
var path9 = __toESM(require("path"), 1);
|
|
2155
2160
|
var fs = __toESM(require("fs/promises"), 1);
|
|
2156
2161
|
var yaml = __toESM(require("js-yaml"), 1);
|
|
2162
|
+
var import_url = require("url");
|
|
2157
2163
|
var DownloadLocalFilePlugin = class _DownloadLocalFilePlugin {
|
|
2158
2164
|
apply(compiler) {
|
|
2159
2165
|
compiler.hooks.download.tapPromise(_DownloadLocalFilePlugin.name, async (address, task) => {
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
const
|
|
2166
|
+
const { url, encoding } = address;
|
|
2167
|
+
if (!url.startsWith("file://")) return void 0;
|
|
2168
|
+
const filepath = (0, import_url.fileURLToPath)(url);
|
|
2169
|
+
const fileExt = path9.extname(filepath);
|
|
2170
|
+
const content = await fs.readFile(filepath, encoding);
|
|
2171
|
+
const str = typeof content === "string" ? content : content.toString(encoding);
|
|
2163
2172
|
if ([".yml", ".yaml"].includes(fileExt)) {
|
|
2164
|
-
const value = yaml.load(
|
|
2173
|
+
const value = yaml.load(str);
|
|
2165
2174
|
return JSON.stringify(OpenapiUtils.to3_1(value));
|
|
2166
2175
|
} else if (fileExt === ".json") {
|
|
2167
|
-
return JSON.stringify(OpenapiUtils.to3_1(JSON.parse(
|
|
2176
|
+
return JSON.stringify(OpenapiUtils.to3_1(JSON.parse(str)));
|
|
2168
2177
|
}
|
|
2169
2178
|
});
|
|
2170
2179
|
}
|
|
@@ -2202,7 +2211,11 @@ var ShakingPlugin = class _ShakingPlugin {
|
|
|
2202
2211
|
sharkedSwagger,
|
|
2203
2212
|
new ModuleDefinition(
|
|
2204
2213
|
document.module.name,
|
|
2205
|
-
|
|
2214
|
+
{
|
|
2215
|
+
url: `memory://${document.module.name}.v3_1.sharked.json`,
|
|
2216
|
+
headers: {},
|
|
2217
|
+
encoding: "utf8"
|
|
2218
|
+
}
|
|
2206
2219
|
)
|
|
2207
2220
|
);
|
|
2208
2221
|
}
|