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/index.mjs CHANGED
@@ -28351,39 +28351,45 @@ const run = async (options) => {
28351
28351
  }));
28352
28352
  if (dereferenceResult.errors?.[0] || !dereferenceResult.schema) throw new Error("Failed to dereference OpenAPI spec.", { cause: dereferenceResult.errors?.[0] });
28353
28353
  const schema$6 = dereferenceResult.schema;
28354
- const baseUrl = options.baseUrl ?? schema$6.servers?.[0]?.url;
28355
- if (!baseUrl) throw new Error("No base URL found in OpenAPI spec and no baseUrl option provided.");
28354
+ const servers = options.baseUrl ? [{ url: options.baseUrl }] : schema$6.servers ?? [];
28355
+ if (servers.length === 0) throw new Error("No base URL found in OpenAPI spec and no baseUrl option provided.");
28356
+ const multipleServers = servers.length > 1;
28356
28357
  const fetchConfigurations = /* @__PURE__ */ new Map();
28357
- if (schema$6.paths) for (const path$2 of Object.keys(schema$6.paths)) {
28358
- const pathItem = schema$6.paths[path$2];
28359
- if (!pathItem) continue;
28360
- if (!pathItem.get) continue;
28361
- const url$2 = new URL(path$2, baseUrl);
28362
- let _path = path$2;
28363
- if ("200" in (pathItem.get?.responses ?? {}) && "text/event-stream" in (pathItem.get.responses?.["200"]?.content ?? {})) continue;
28364
- for (const param of pathItem.get.parameters || []) {
28365
- let exampleValue = options.getExampleValue?.(param.name, path$2) ?? param.example ?? param.examples?.[0] ?? param.schema?.example ?? param.schema?.examples?.[0];
28366
- if (!exampleValue && (param.required || param.in === "path") && "enum" in param.schema) {
28367
- const enumValues = param.schema.enum;
28368
- if (Array.isArray(enumValues) && enumValues.length > 0) exampleValue = enumValues[0];
28369
- }
28370
- if (!exampleValue && param.required) {
28371
- debug$1(`No example value for parameter ${param.name} in ${path$2}`);
28372
- continue;
28373
- }
28374
- if (param.in === "path") {
28375
- if (!exampleValue) {
28376
- debug$1(`No example value for path parameter ${param.name} in ${path$2}`);
28358
+ for (const server of servers) {
28359
+ const baseUrl = server.url;
28360
+ const serverLabel = server.description ?? new URL(baseUrl).host;
28361
+ if (schema$6.paths) for (const path$2 of Object.keys(schema$6.paths)) {
28362
+ const pathItem = schema$6.paths[path$2];
28363
+ if (!pathItem) continue;
28364
+ if (!pathItem.get) continue;
28365
+ const url$2 = new URL(path$2, baseUrl);
28366
+ let _path = path$2;
28367
+ if ("200" in (pathItem.get?.responses ?? {}) && "text/event-stream" in (pathItem.get.responses?.["200"]?.content ?? {})) continue;
28368
+ for (const param of pathItem.get.parameters || []) {
28369
+ let exampleValue = options.getExampleValue?.(param.name, path$2) ?? param.example ?? param.examples?.[0] ?? param.schema?.example ?? param.schema?.examples?.[0];
28370
+ if (!exampleValue && (param.required || param.in === "path") && "enum" in param.schema) {
28371
+ const enumValues = param.schema.enum;
28372
+ if (Array.isArray(enumValues) && enumValues.length > 0) exampleValue = enumValues[0];
28373
+ }
28374
+ if (!exampleValue && param.required) {
28375
+ debug$1(`No example value for parameter ${param.name} in ${path$2}`);
28377
28376
  continue;
28378
28377
  }
28379
- const placeholder = `{${param.name}}`;
28380
- _path = _path.replace(placeholder, exampleValue);
28381
- url$2.pathname = _path;
28378
+ if (param.in === "path") {
28379
+ if (!exampleValue) {
28380
+ debug$1(`No example value for path parameter ${param.name} in ${path$2}`);
28381
+ continue;
28382
+ }
28383
+ const placeholder = `{${param.name}}`;
28384
+ _path = _path.replace(placeholder, exampleValue);
28385
+ url$2.pathname = _path;
28386
+ }
28387
+ if (!exampleValue) continue;
28388
+ if (param.in === "query") url$2.searchParams.set(param.name, exampleValue);
28382
28389
  }
28383
- if (!exampleValue) continue;
28384
- if (param.in === "query") url$2.searchParams.set(param.name, exampleValue);
28390
+ const key = multipleServers ? `[${serverLabel}] ${path$2}` : path$2;
28391
+ fetchConfigurations.set(key, url$2);
28385
28392
  }
28386
- fetchConfigurations.set(path$2, url$2);
28387
28393
  }
28388
28394
  const measurements = new Storage(options.storagePath, options.maxSpaceUsageBytes ?? 262144 * .95);
28389
28395
  const measure = async (path$2) => {