dowwntime 1.3.9 → 1.4.0
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/dist/cli.mjs +34 -28
- package/dist/cli.mjs.map +1 -1
- package/dist/index.mjs +34 -28
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -28318,39 +28318,45 @@ const run = async (options) => {
|
|
|
28318
28318
|
}));
|
|
28319
28319
|
if (dereferenceResult.errors?.[0] || !dereferenceResult.schema) throw new Error("Failed to dereference OpenAPI spec.", { cause: dereferenceResult.errors?.[0] });
|
|
28320
28320
|
const schema$6 = dereferenceResult.schema;
|
|
28321
|
-
const
|
|
28322
|
-
if (
|
|
28321
|
+
const servers = options.baseUrl ? [{ url: options.baseUrl }] : schema$6.servers ?? [];
|
|
28322
|
+
if (servers.length === 0) throw new Error("No base URL found in OpenAPI spec and no baseUrl option provided.");
|
|
28323
|
+
const multipleServers = servers.length > 1;
|
|
28323
28324
|
const fetchConfigurations = /* @__PURE__ */ new Map();
|
|
28324
|
-
|
|
28325
|
-
const
|
|
28326
|
-
|
|
28327
|
-
if (
|
|
28328
|
-
|
|
28329
|
-
|
|
28330
|
-
|
|
28331
|
-
|
|
28332
|
-
let
|
|
28333
|
-
if (
|
|
28334
|
-
|
|
28335
|
-
|
|
28336
|
-
|
|
28337
|
-
|
|
28338
|
-
|
|
28339
|
-
|
|
28340
|
-
|
|
28341
|
-
|
|
28342
|
-
if (!exampleValue) {
|
|
28343
|
-
debug$1(`No example value for path parameter ${param.name} in ${path$4}`);
|
|
28325
|
+
for (const server of servers) {
|
|
28326
|
+
const baseUrl = server.url;
|
|
28327
|
+
const serverLabel = server.description ?? new URL(baseUrl).host;
|
|
28328
|
+
if (schema$6.paths) for (const path$4 of Object.keys(schema$6.paths)) {
|
|
28329
|
+
const pathItem = schema$6.paths[path$4];
|
|
28330
|
+
if (!pathItem) continue;
|
|
28331
|
+
if (!pathItem.get) continue;
|
|
28332
|
+
const url$2 = new URL(path$4, baseUrl);
|
|
28333
|
+
let _path = path$4;
|
|
28334
|
+
if ("200" in (pathItem.get?.responses ?? {}) && "text/event-stream" in (pathItem.get.responses?.["200"]?.content ?? {})) continue;
|
|
28335
|
+
for (const param of pathItem.get.parameters || []) {
|
|
28336
|
+
let exampleValue = options.getExampleValue?.(param.name, path$4) ?? param.example ?? param.examples?.[0] ?? param.schema?.example ?? param.schema?.examples?.[0];
|
|
28337
|
+
if (!exampleValue && (param.required || param.in === "path") && "enum" in param.schema) {
|
|
28338
|
+
const enumValues = param.schema.enum;
|
|
28339
|
+
if (Array.isArray(enumValues) && enumValues.length > 0) exampleValue = enumValues[0];
|
|
28340
|
+
}
|
|
28341
|
+
if (!exampleValue && param.required) {
|
|
28342
|
+
debug$1(`No example value for parameter ${param.name} in ${path$4}`);
|
|
28344
28343
|
continue;
|
|
28345
28344
|
}
|
|
28346
|
-
|
|
28347
|
-
|
|
28348
|
-
|
|
28345
|
+
if (param.in === "path") {
|
|
28346
|
+
if (!exampleValue) {
|
|
28347
|
+
debug$1(`No example value for path parameter ${param.name} in ${path$4}`);
|
|
28348
|
+
continue;
|
|
28349
|
+
}
|
|
28350
|
+
const placeholder = `{${param.name}}`;
|
|
28351
|
+
_path = _path.replace(placeholder, exampleValue);
|
|
28352
|
+
url$2.pathname = _path;
|
|
28353
|
+
}
|
|
28354
|
+
if (!exampleValue) continue;
|
|
28355
|
+
if (param.in === "query") url$2.searchParams.set(param.name, exampleValue);
|
|
28349
28356
|
}
|
|
28350
|
-
|
|
28351
|
-
|
|
28357
|
+
const key = multipleServers ? `[${serverLabel}] ${path$4}` : path$4;
|
|
28358
|
+
fetchConfigurations.set(key, url$2);
|
|
28352
28359
|
}
|
|
28353
|
-
fetchConfigurations.set(path$4, url$2);
|
|
28354
28360
|
}
|
|
28355
28361
|
const measurements = new Storage(options.storagePath, options.maxSpaceUsageBytes ?? 262144 * .95);
|
|
28356
28362
|
const measure = async (path$4) => {
|