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 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 baseUrl = options.baseUrl ?? schema$6.servers?.[0]?.url;
28322
- if (!baseUrl) throw new Error("No base URL found in OpenAPI spec and no baseUrl option provided.");
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
- if (schema$6.paths) for (const path$4 of Object.keys(schema$6.paths)) {
28325
- const pathItem = schema$6.paths[path$4];
28326
- if (!pathItem) continue;
28327
- if (!pathItem.get) continue;
28328
- const url$2 = new URL(path$4, baseUrl);
28329
- let _path = path$4;
28330
- if ("200" in (pathItem.get?.responses ?? {}) && "text/event-stream" in (pathItem.get.responses?.["200"]?.content ?? {})) continue;
28331
- for (const param of pathItem.get.parameters || []) {
28332
- let exampleValue = options.getExampleValue?.(param.name, path$4) ?? param.example ?? param.examples?.[0] ?? param.schema?.example ?? param.schema?.examples?.[0];
28333
- if (!exampleValue && (param.required || param.in === "path") && "enum" in param.schema) {
28334
- const enumValues = param.schema.enum;
28335
- if (Array.isArray(enumValues) && enumValues.length > 0) exampleValue = enumValues[0];
28336
- }
28337
- if (!exampleValue && param.required) {
28338
- debug$1(`No example value for parameter ${param.name} in ${path$4}`);
28339
- continue;
28340
- }
28341
- if (param.in === "path") {
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
- const placeholder = `{${param.name}}`;
28347
- _path = _path.replace(placeholder, exampleValue);
28348
- url$2.pathname = _path;
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
- if (!exampleValue) continue;
28351
- if (param.in === "query") url$2.searchParams.set(param.name, exampleValue);
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) => {