@scalar/oas-utils 0.4.18 → 0.4.21

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.
Files changed (45) hide show
  1. package/CHANGELOG.md +54 -0
  2. package/dist/entities/spec/request-examples.d.ts +55 -55
  3. package/dist/entities/spec/request-examples.d.ts.map +1 -1
  4. package/dist/entities/spec/request-examples.js.map +2 -2
  5. package/dist/helpers/index.d.ts +1 -0
  6. package/dist/helpers/index.d.ts.map +1 -1
  7. package/dist/helpers/index.js +2 -0
  8. package/dist/helpers/index.js.map +2 -2
  9. package/dist/helpers/operation-to-har/operation-to-har.d.ts +1 -2
  10. package/dist/helpers/operation-to-har/operation-to-har.d.ts.map +1 -1
  11. package/dist/helpers/operation-to-har/operation-to-har.js +4 -3
  12. package/dist/helpers/operation-to-har/operation-to-har.js.map +2 -2
  13. package/dist/helpers/operation-to-har/process-body.d.ts +5 -2
  14. package/dist/helpers/operation-to-har/process-body.d.ts.map +1 -1
  15. package/dist/helpers/operation-to-har/process-body.js +4 -5
  16. package/dist/helpers/operation-to-har/process-body.js.map +2 -2
  17. package/dist/helpers/operation-to-har/process-parameters.d.ts +2 -4
  18. package/dist/helpers/operation-to-har/process-parameters.d.ts.map +1 -1
  19. package/dist/helpers/operation-to-har/process-parameters.js +3 -8
  20. package/dist/helpers/operation-to-har/process-parameters.js.map +2 -2
  21. package/dist/helpers/operation-to-har/process-security-schemes.js +1 -1
  22. package/dist/helpers/operation-to-har/process-security-schemes.js.map +2 -2
  23. package/dist/helpers/servers.d.ts +24 -0
  24. package/dist/helpers/servers.d.ts.map +1 -0
  25. package/dist/helpers/servers.js +97 -0
  26. package/dist/helpers/servers.js.map +7 -0
  27. package/dist/spec-getters/get-example-from-schema.d.ts +3 -2
  28. package/dist/spec-getters/get-example-from-schema.d.ts.map +1 -1
  29. package/dist/spec-getters/get-example-from-schema.js +55 -39
  30. package/dist/spec-getters/get-example-from-schema.js.map +2 -2
  31. package/dist/spec-getters/get-parameters-from-operation.d.ts.map +1 -1
  32. package/dist/spec-getters/get-parameters-from-operation.js +4 -1
  33. package/dist/spec-getters/get-parameters-from-operation.js.map +2 -2
  34. package/dist/spec-getters/get-request-body-from-operation.d.ts.map +1 -1
  35. package/dist/spec-getters/get-request-body-from-operation.js +5 -4
  36. package/dist/spec-getters/get-request-body-from-operation.js.map +2 -2
  37. package/dist/transforms/import-spec.d.ts +0 -4
  38. package/dist/transforms/import-spec.d.ts.map +1 -1
  39. package/dist/transforms/import-spec.js +2 -69
  40. package/dist/transforms/import-spec.js.map +2 -2
  41. package/dist/transforms/index.d.ts +1 -1
  42. package/dist/transforms/index.d.ts.map +1 -1
  43. package/dist/transforms/index.js +0 -2
  44. package/dist/transforms/index.js.map +2 -2
  45. package/package.json +10 -9
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/spec-getters/get-request-body-from-operation.ts"],
4
- "sourcesContent": ["import { json2xml } from '@scalar/helpers/file/json2xml'\nimport type { ContentType } from '@scalar/types/legacy'\n\nimport type { Operation } from '@/entities/spec'\nimport { normalizeMimeTypeObject } from '@/helpers/normalize-mime-type-object'\nimport { prettyPrintJson } from '@/helpers/pretty-print-json'\nimport { getExampleFromSchema } from './get-example-from-schema'\nimport { getParametersFromOperation } from './get-parameters-from-operation'\n\ntype AnyObject = Record<string, any>\n\n/**\n * Transform the object into a nested array of objects\n * that represent the key-value pairs of the object.\n */\nfunction getParamsFromObject(\n obj: AnyObject,\n nested = false,\n field?: string,\n): {\n name: string\n value: any\n}[] {\n return Object.entries(obj).flatMap(([key, value]) => {\n const name = field ?? key\n\n if (Array.isArray(value) && !nested) {\n return getParamsFromObject(value, true, key)\n }\n\n if (typeof value === 'object' && !(value instanceof File) && value !== null) {\n // Nested object inside formData field: no way to represent it, so just serialize to JSON string\n value = JSON.stringify(value)\n }\n\n return [{ name, value }]\n })\n}\n// Define preferred standard mime types (order indicates preference)\nconst standardMimeTypes: ContentType[] = [\n 'application/json',\n 'application/octet-stream',\n 'application/x-www-form-urlencoded',\n 'application/xml',\n 'multipart/form-data',\n 'text/plain',\n]\n\n/**\n * Get the request body from the operation.\n */\nexport function getRequestBodyFromOperation(\n operation: Pick<Operation, 'requestBody' | 'parameters'>,\n selectedExampleKey?: string | number,\n omitEmptyAndOptionalProperties?: boolean,\n): {\n mimeType: ContentType\n text?: string | undefined\n params?: {\n name: string\n value?: string | File\n }[]\n} | null {\n const originalContent = operation.requestBody?.content\n const content = normalizeMimeTypeObject(originalContent)\n\n // First try to find a standard mime type\n const mimeType =\n standardMimeTypes.find((currentMimeType) => !!content?.[currentMimeType]) ??\n ((Object.keys(content ?? {})[0] || 'application/json') as ContentType)\n\n // Handle JSON-like content types (e.g., application/vnd.github+json)\n const isJsonLike = mimeType.includes('json') || mimeType.endsWith('+json')\n\n /** Examples */\n const examples = content?.[mimeType]?.examples ?? content?.['application/json']?.examples\n\n // Let's use the first example\n const selectedExample = examples?.[selectedExampleKey ?? Object.keys(examples ?? {})[0] ?? '']\n\n if (selectedExample) {\n return {\n mimeType,\n text: prettyPrintJson('value' in selectedExample ? selectedExample.value : selectedExample),\n }\n }\n\n /**\n * Body Parameters (Swagger 2.0)\n *\n * \u201DThe payload that's appended to the HTTP request. Since there can only be one payload, there can only\n * be one body parameter. The name of the body parameter has no effect on the parameter itself and is used\n * for documentation purposes only. Since Form parameters are also in the payload, body and form\n * parameters cannot exist together for the same operation.\u201D\n */\n const bodyParameters = getParametersFromOperation(\n operation.parameters ?? [],\n // TODO: Add path parameters\n [], // operation.path ?? [],\n 'body',\n false,\n )\n\n if (bodyParameters.length > 0) {\n return {\n mimeType: 'application/json',\n text: prettyPrintJson(bodyParameters[0]?.value ?? ''),\n }\n }\n\n /**\n * FormData Parameters (Swagger 2.0)\n *\n * \u201DForm - Used to describe the payload of an HTTP request when either application/x-www-form-urlencoded,\n * multipart/form-data or both are used as the content type of the request (in Swagger's definition, the\n * consumes property of an operation). This is the only parameter type that can be used to send files,\n * thus supporting the file type. Since form parameters are sent in the payload, they cannot be declared\n * together with a body parameter for the same operation. Form parameters have a different format based on\n * the content-type used (for further details, consult http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4):\n * - application/x-www-form-urlencoded - Similar to the format of Query parameters but as a payload.\n * For example, foo=1&bar=swagger - both foo and bar are form parameters. This is normally used for simple\n * parameters that are being transferred.\n * - multipart/form-data - each parameter takes a section in the payload with an internal header.\n * For example, for the header Content-Disposition: form-data; name=\"submit-name\" the name of the parameter is\n * submit-name. This type of form parameters is more commonly used for file transfers.\u201D\n */\n\n const formDataParameters = getParametersFromOperation(\n operation.parameters ?? [],\n // TODO: Add path parameters\n [], // operation.path ?? [],\n 'formData',\n false,\n )\n\n if (formDataParameters.length > 0) {\n return {\n mimeType: 'application/x-www-form-urlencoded',\n params: formDataParameters.map((parameter) => ({\n name: parameter.name,\n /**\n * TODO: This value MUST be a string\n * Figure out why this is not always a string\n *\n * JSON.stringify is a TEMPORARY fix\n */\n value: typeof parameter.value === 'string' ? parameter.value : JSON.stringify(parameter.value),\n })),\n }\n }\n\n // If no mime type is supported, exit early\n if (!mimeType) {\n return null\n }\n\n // Get the request body object for the mime type\n const requestBodyObject = content?.[mimeType]\n\n // Get example from operation\n const example = requestBodyObject?.example ? requestBodyObject?.example : undefined\n\n // Update the JSON handling section\n if (isJsonLike) {\n const exampleFromSchema = requestBodyObject?.schema\n ? getExampleFromSchema(requestBodyObject?.schema, {\n mode: 'write',\n omitEmptyAndOptionalProperties: omitEmptyAndOptionalProperties ?? false,\n })\n : null\n\n const body = example ?? exampleFromSchema\n\n return {\n mimeType,\n text: body ? (typeof body === 'string' ? body : JSON.stringify(body, null, 2)) : undefined,\n }\n }\n\n // XML\n if (mimeType === 'application/xml') {\n const exampleFromSchema = requestBodyObject?.schema\n ? getExampleFromSchema(requestBodyObject?.schema, {\n xml: true,\n mode: 'write',\n })\n : null\n\n return {\n mimeType,\n text: example ?? json2xml(exampleFromSchema, ' '),\n }\n }\n\n // Binary data\n if (mimeType === 'application/octet-stream') {\n return {\n mimeType,\n text: 'BINARY',\n }\n }\n\n // Plain text\n if (mimeType === 'text/plain') {\n const exampleFromSchema = requestBodyObject?.schema\n ? getExampleFromSchema(requestBodyObject?.schema, {\n xml: true,\n mode: 'write',\n })\n : null\n\n return {\n mimeType,\n text: example ?? exampleFromSchema ?? '',\n }\n }\n\n // URL encoded data\n if (mimeType === 'multipart/form-data' || mimeType === 'application/x-www-form-urlencoded') {\n const exampleFromSchema = requestBodyObject?.schema\n ? getExampleFromSchema(requestBodyObject?.schema, {\n xml: true,\n mode: 'write',\n })\n : null\n\n return {\n mimeType,\n params: getParamsFromObject(example ?? exampleFromSchema ?? {}),\n }\n }\n\n return null\n}\n"],
5
- "mappings": "AAAA,SAAS,gBAAgB;AAIzB,SAAS,+BAA+B;AACxC,SAAS,uBAAuB;AAChC,SAAS,4BAA4B;AACrC,SAAS,kCAAkC;AAQ3C,SAAS,oBACP,KACA,SAAS,OACT,OAIE;AACF,SAAO,OAAO,QAAQ,GAAG,EAAE,QAAQ,CAAC,CAAC,KAAK,KAAK,MAAM;AACnD,UAAM,OAAO,SAAS;AAEtB,QAAI,MAAM,QAAQ,KAAK,KAAK,CAAC,QAAQ;AACnC,aAAO,oBAAoB,OAAO,MAAM,GAAG;AAAA,IAC7C;AAEA,QAAI,OAAO,UAAU,YAAY,EAAE,iBAAiB,SAAS,UAAU,MAAM;AAE3E,cAAQ,KAAK,UAAU,KAAK;AAAA,IAC9B;AAEA,WAAO,CAAC,EAAE,MAAM,MAAM,CAAC;AAAA,EACzB,CAAC;AACH;AAEA,MAAM,oBAAmC;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAKO,SAAS,4BACd,WACA,oBACA,gCAQO;AACP,QAAM,kBAAkB,UAAU,aAAa;AAC/C,QAAM,UAAU,wBAAwB,eAAe;AAGvD,QAAM,WACJ,kBAAkB,KAAK,CAAC,oBA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I,YAAY;AACd,UAAM,oBAAoB,mBAAmB,SACzC,qBAAqB,mBAAmB,QAAQ;AAAA,MAC9C,MAAM;AAAA,MACN,gCAAgC,kCAAkC;AAAA,IACpE,CAAC,IACD;AAEJ,UAAM,OAAO,WAAW;AAExB,WAAO;AAAA,MACL;AAAA,MACA,MAAM,OAAQ,OAAO,SAAS,WAAW,OAAO,KAAK,UAAU,MAAM,MAAM,CAAC,IAAK;AAAA,IACnF;AAAA,EACF;AAGA,MAAI,aAAa,mBAAmB;AAClC,UAAM,oBAAoB,mBAAmB,SACzC,qBAAqB,mBAAmB,QAAQ;AAAA,MAC9C,KAAK;AAAA,MACL,MAAM;AAAA,IACR,CAAC,IACD;AAEJ,WAAO;AAAA,MACL;AAAA,MACA,MAAM,WAAW,SAAS,mBAAmB,IAAI;AAAA,IACnD;AAAA,EACF;AAGA,MAAI,aAAa,4BAA4B;AAC3C,WAAO;AAAA,MACL;AAAA,MACA,MAAM;AAAA,IACR;AAAA,EACF;AAGA,MAAI,aAAa,cAAc;AAC7B,UAAM,oBAAoB,mBAAmB,SACzC,qBAAqB,mBAAmB,QAAQ;AAAA,MAC9C,KAAK;AAAA,MACL,MAAM;AAAA,IACR,CAAC,IACD;AAEJ,WAAO;AAAA,MACL;AAAA,MACA,MAAM,WAAW,qBAAqB;AAAA,IACxC;AAAA,EACF;AAGA,MAAI,aAAa,yBAAyB,aAAa,qCAAqC;AAC1F,UAAM,oBAAoB,mBAAmB,SACzC,qBAAqB,mBAAmB,QAAQ;AAAA,MAC9C,KAAK;AAAA,MACL,MAAM;AAAA,IACR,CAAC,IACD;AAEJ,WAAO;AAAA,MACL;AAAA,MACA,QAAQ,oBAAoB,WAAW,qBAAqB,CAAC,CAAC;AAAA,IAChE;AAAA,EACF;AAEA,SAAO;AACT;",
4
+ "sourcesContent": ["import { json2xml } from '@scalar/helpers/file/json2xml'\nimport type { ContentType } from '@scalar/types/legacy'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\n\nimport type { Operation } from '@/entities/spec'\nimport { normalizeMimeTypeObject } from '@/helpers/normalize-mime-type-object'\nimport { prettyPrintJson } from '@/helpers/pretty-print-json'\nimport { getExampleFromSchema } from './get-example-from-schema'\nimport { getParametersFromOperation } from './get-parameters-from-operation'\n\ntype AnyObject = Record<string, any>\n\n/**\n * Transform the object into a nested array of objects\n * that represent the key-value pairs of the object.\n */\nfunction getParamsFromObject(\n obj: AnyObject,\n nested = false,\n field?: string,\n): {\n name: string\n value: any\n}[] {\n return Object.entries(obj).flatMap(([key, value]) => {\n const name = field ?? key\n\n if (Array.isArray(value) && !nested) {\n return getParamsFromObject(value, true, key)\n }\n\n if (typeof value === 'object' && !(value instanceof File) && value !== null) {\n // Nested object inside formData field: no way to represent it, so just serialize to JSON string\n value = JSON.stringify(value)\n }\n\n return [{ name, value }]\n })\n}\n// Define preferred standard mime types (order indicates preference)\nconst standardMimeTypes: ContentType[] = [\n 'application/json',\n 'application/octet-stream',\n 'application/x-www-form-urlencoded',\n 'application/xml',\n 'multipart/form-data',\n 'text/plain',\n]\n\n/**\n * Get the request body from the operation.\n */\nexport function getRequestBodyFromOperation(\n operation: Pick<Operation, 'requestBody' | 'parameters'>,\n selectedExampleKey?: string | number,\n omitEmptyAndOptionalProperties?: boolean,\n): {\n mimeType: ContentType\n text?: string | undefined\n params?: {\n name: string\n value?: string | File\n }[]\n} | null {\n const originalContent = operation.requestBody?.content\n const content = normalizeMimeTypeObject(originalContent)\n\n // First try to find a standard mime type\n const mimeType =\n standardMimeTypes.find((currentMimeType) => !!content?.[currentMimeType]) ??\n ((Object.keys(content ?? {})[0] || 'application/json') as ContentType)\n\n // Handle JSON-like content types (e.g., application/vnd.github+json)\n const isJsonLike = mimeType.includes('json') || mimeType.endsWith('+json')\n\n /** Examples */\n const examples = content?.[mimeType]?.examples ?? content?.['application/json']?.examples\n\n // Let's use the first example\n const selectedExample = examples?.[selectedExampleKey ?? Object.keys(examples ?? {})[0] ?? '']\n\n if (selectedExample) {\n return {\n mimeType,\n text: prettyPrintJson('value' in selectedExample ? selectedExample.value : selectedExample),\n }\n }\n\n /**\n * Body Parameters (Swagger 2.0)\n *\n * \u201DThe payload that's appended to the HTTP request. Since there can only be one payload, there can only\n * be one body parameter. The name of the body parameter has no effect on the parameter itself and is used\n * for documentation purposes only. Since Form parameters are also in the payload, body and form\n * parameters cannot exist together for the same operation.\u201D\n */\n const bodyParameters = getParametersFromOperation(\n operation.parameters ?? [],\n // TODO: Add path parameters\n [], // operation.path ?? [],\n 'body',\n false,\n )\n\n if (bodyParameters.length > 0) {\n return {\n mimeType: 'application/json',\n text: prettyPrintJson(bodyParameters[0]?.value ?? ''),\n }\n }\n\n /**\n * FormData Parameters (Swagger 2.0)\n *\n * \u201DForm - Used to describe the payload of an HTTP request when either application/x-www-form-urlencoded,\n * multipart/form-data or both are used as the content type of the request (in Swagger's definition, the\n * consumes property of an operation). This is the only parameter type that can be used to send files,\n * thus supporting the file type. Since form parameters are sent in the payload, they cannot be declared\n * together with a body parameter for the same operation. Form parameters have a different format based on\n * the content-type used (for further details, consult http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4):\n * - application/x-www-form-urlencoded - Similar to the format of Query parameters but as a payload.\n * For example, foo=1&bar=swagger - both foo and bar are form parameters. This is normally used for simple\n * parameters that are being transferred.\n * - multipart/form-data - each parameter takes a section in the payload with an internal header.\n * For example, for the header Content-Disposition: form-data; name=\"submit-name\" the name of the parameter is\n * submit-name. This type of form parameters is more commonly used for file transfers.\u201D\n */\n\n const formDataParameters = getParametersFromOperation(\n operation.parameters ?? [],\n // TODO: Add path parameters\n [], // operation.path ?? [],\n 'formData',\n false,\n )\n\n if (formDataParameters.length > 0) {\n return {\n mimeType: 'application/x-www-form-urlencoded',\n params: formDataParameters.map((parameter) => ({\n name: parameter.name,\n /**\n * TODO: This value MUST be a string\n * Figure out why this is not always a string\n *\n * JSON.stringify is a TEMPORARY fix\n */\n value: typeof parameter.value === 'string' ? parameter.value : JSON.stringify(parameter.value),\n })),\n }\n }\n\n // If no mime type is supported, exit early\n if (!mimeType) {\n return null\n }\n\n // Get the request body object for the mime type\n const requestBodyObject = content?.[mimeType]\n\n // Get example from operation\n const example = requestBodyObject?.example ? requestBodyObject?.example : undefined\n\n // Update the JSON handling section\n if (isJsonLike) {\n const exampleFromSchema = requestBodyObject?.schema\n ? getExampleFromSchema(getResolvedRef(requestBodyObject?.schema), {\n mode: 'write',\n omitEmptyAndOptionalProperties: omitEmptyAndOptionalProperties ?? false,\n })\n : null\n\n const body = example ?? exampleFromSchema\n\n return {\n mimeType,\n text: body ? (typeof body === 'string' ? body : JSON.stringify(body, null, 2)) : undefined,\n }\n }\n\n // XML\n if (mimeType === 'application/xml') {\n const exampleFromSchema = requestBodyObject?.schema\n ? getExampleFromSchema(getResolvedRef(requestBodyObject?.schema), {\n xml: true,\n mode: 'write',\n })\n : null\n\n return {\n mimeType,\n text: example ?? json2xml(exampleFromSchema, ' '),\n }\n }\n\n // Binary data\n if (mimeType === 'application/octet-stream') {\n return {\n mimeType,\n text: 'BINARY',\n }\n }\n\n // Plain text\n if (mimeType === 'text/plain') {\n const exampleFromSchema = requestBodyObject?.schema\n ? getExampleFromSchema(getResolvedRef(requestBodyObject?.schema), {\n xml: true,\n mode: 'write',\n })\n : null\n\n return {\n mimeType,\n text: example ?? exampleFromSchema ?? '',\n }\n }\n\n // URL encoded data\n if (mimeType === 'multipart/form-data' || mimeType === 'application/x-www-form-urlencoded') {\n const exampleFromSchema = requestBodyObject?.schema\n ? getExampleFromSchema(getResolvedRef(requestBodyObject?.schema), {\n xml: true,\n mode: 'write',\n })\n : null\n\n return {\n mimeType,\n params: getParamsFromObject(example ?? exampleFromSchema ?? {}),\n }\n }\n\n return null\n}\n"],
5
+ "mappings": "AAAA,SAAS,gBAAgB;AAEzB,SAAS,sBAAsB;AAG/B,SAAS,+BAA+B;AACxC,SAAS,uBAAuB;AAChC,SAAS,4BAA4B;AACrC,SAAS,kCAAkC;AAQ3C,SAA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MACL;AAAA,MACA,MAAM;AAAA,IACR;AAAA,EACF;AAGA,MAAI,aAAa,cAAc;AAC7B,UAAM,oBAAoB,mBAAmB,SACzC,qBAAqB,eAAe,mBAAmB,MAAM,GAAG;AAAA,MAC9D,KAAK;AAAA,MACL,MAAM;AAAA,IACR,CAAC,IACD;AAEJ,WAAO;AAAA,MACL;AAAA,MACA,MAAM,WAAW,qBAAqB;AAAA,IACxC;AAAA,EACF;AAGA,MAAI,aAAa,yBAAyB,aAAa,qCAAqC;AAC1F,UAAM,oBAAoB,mBAAmB,SACzC,qBAAqB,eAAe,mBAAmB,MAAM,GAAG;AAAA,MAC9D,KAAK;AAAA,MACL,MAAM;AAAA,IACR,CAAC,IACD;AAEJ,WAAO;AAAA,MACL;AAAA,MACA,QAAQ,oBAAoB,WAAW,qBAAqB,CAAC,CAAC;AAAA,IAChE;AAAA,EACF;AAEA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -61,8 +61,4 @@ dereferencedDocument, authentication, baseServerURL, documentUrl, servers: confi
61
61
  importWarnings: string[];
62
62
  collection: undefined;
63
63
  }>;
64
- /**
65
- * Retrieves a list of servers from an OpenAPI document and converts them to a list of Server entities.
66
- */
67
- export declare function getServersFromOpenApiDocument(servers: OpenAPIV3_1.ServerObject[] | undefined, { baseServerURL, documentUrl, }?: Pick<ApiReferenceConfiguration, 'baseServerURL'> & Pick<ImportSpecToWorkspaceArgs, 'documentUrl'>): Server[];
68
64
  //# sourceMappingURL=import-spec.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"import-spec.d.ts","sourceRoot":"","sources":["../../src/transforms/import-spec.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAA;AAE5E,OAAO,EAEL,KAAK,cAAc,EAGpB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,KAAK,EAAE,aAAa,EAA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AAA;IAC3C,mFAAmF;IACnF,qBAAqB,CAAC,EAAE,OAAO,CAAA;IAC/B,yCAAyC;IACzC,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB,CAAA;AAEH;;;;;;;;;;;;GAYG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,EAC3C;AACE,mFAAmF;AACnF,oBAAoB,EACpB,cAAc,EACd,aAAa,EACb,WAAW,EACX,OAAO,EAAE,iBAAiB,EAC1B,qBAA6B,EAC7B,IAAI,EACJ,UAAU,EACV,SAAiB,GAClB,GAAE,yBAA8B,GAChC,OAAO,CACN;IACE,KAAK,EAAE,KAAK,CAAA;IACZ,UAAU,EAAE,UAAU,CAAA;IACtB,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAA;IAC5B,QAAQ,EAAE,cAAc,EAAE,CAAA;IAC1B,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,IAAI,EAAE,GAAG,EAAE,CAAA;IACX,eAAe,EAAE,cAAc,EAAE,CAAA;CAClC,GACD;IAAE,KAAK,EAAE,IAAI,CAAC;IAAC,cAAc,EAAE,MAAM,EAAE,CAAC;IAAC,UAAU,EAAE,SAAS,CAAA;CAAE,CACnE,CA4WA"}
@@ -1,6 +1,5 @@
1
1
  import { isDefined } from "@scalar/helpers/array/is-defined";
2
2
  import { isHttpMethod } from "@scalar/helpers/http/is-http-method";
3
- import { combineUrlAndPath } from "@scalar/helpers/url/merge-urls";
4
3
  import { keysOf } from "@scalar/object-utils/arrays";
5
4
  import { dereference, load, upgrade } from "@scalar/openapi-parser";
6
5
  import {
@@ -12,6 +11,7 @@ import { requestSchema } from "../entities/spec/requests.js";
12
11
  import { serverSchema } from "../entities/spec/server.js";
13
12
  import { tagSchema } from "../entities/spec/spec-objects.js";
14
13
  import { schemaModel } from "../helpers/schema-model.js";
14
+ import { getServersFromDocument } from "../helpers/servers.js";
15
15
  const dereferenceDocument = async (document, { shouldLoad = true } = {}) => {
16
16
  if (document === null || typeof document === "string" && document.trim() === "") {
17
17
  console.warn("[@scalar/oas-utils] Empty OpenAPI document provided.");
@@ -95,17 +95,11 @@ async function importSpecToWorkspace(content, {
95
95
  }
96
96
  const start = performance.now();
97
97
  const requests = [];
98
- const collectionServers = getServersFromOpenApiDocument(configuredServers || schema.servers, {
98
+ const collectionServers = getServersFromDocument(configuredServers || schema.servers, {
99
99
  baseServerURL,
100
100
  documentUrl
101
101
  });
102
102
  const operationServers = [];
103
- if (!collectionServers.length) {
104
- const fallbackUrl = getFallbackUrl();
105
- if (fallbackUrl) {
106
- collectionServers.push(serverSchema.parse({ url: fallbackUrl }));
107
- }
108
- }
109
103
  const tagNames = /* @__PURE__ */ new Set();
110
104
  const security = schema.components?.securitySchemes ?? schema?.securityDefinitions ?? {};
111
105
  if (authentication?.oAuth2 || authentication?.apiKey || authentication?.http) {
@@ -304,69 +298,8 @@ async function importSpecToWorkspace(content, {
304
298
  securitySchemes
305
299
  };
306
300
  }
307
- function getBaseUrlFromDocumentUrl(documentUrl) {
308
- try {
309
- const url = new URL(documentUrl);
310
- return `${url.protocol}//${url.hostname}${url.port ? `:${url.port}` : ""}`;
311
- } catch {
312
- return void 0;
313
- }
314
- }
315
- function getServersFromOpenApiDocument(servers, {
316
- baseServerURL,
317
- documentUrl
318
- } = {}) {
319
- if (!servers?.length && documentUrl) {
320
- const newServerUrl = getBaseUrlFromDocumentUrl(documentUrl);
321
- if (newServerUrl) {
322
- return [serverSchema.parse({ url: newServerUrl })];
323
- }
324
- }
325
- if (!servers || !Array.isArray(servers)) {
326
- return [];
327
- }
328
- return servers.map((server) => {
329
- try {
330
- const parsedSchema = serverSchema.parse(server);
331
- if (parsedSchema?.url?.startsWith("/")) {
332
- if (baseServerURL) {
333
- parsedSchema.url = combineUrlAndPath(baseServerURL, parsedSchema.url);
334
- return parsedSchema;
335
- }
336
- if (documentUrl) {
337
- const baseUrl = getBaseUrlFromDocumentUrl(documentUrl);
338
- if (baseUrl) {
339
- parsedSchema.url = combineUrlAndPath(baseUrl, parsedSchema.url);
340
- }
341
- return parsedSchema;
342
- }
343
- const fallbackUrl = getFallbackUrl();
344
- if (fallbackUrl) {
345
- parsedSchema.url = combineUrlAndPath(fallbackUrl, parsedSchema.url.replace(/^\//, ""));
346
- return parsedSchema;
347
- }
348
- }
349
- return parsedSchema;
350
- } catch (error) {
351
- console.warn("Oops, that's an invalid server configuration.");
352
- console.warn("Server:", server);
353
- console.warn("Error:", error);
354
- return void 0;
355
- }
356
- }).filter(isDefined);
357
- }
358
- function getFallbackUrl() {
359
- if (typeof window === "undefined") {
360
- return void 0;
361
- }
362
- if (typeof window?.location?.origin !== "string") {
363
- return void 0;
364
- }
365
- return window.location.origin;
366
- }
367
301
  export {
368
302
  getSelectedSecuritySchemeUids,
369
- getServersFromOpenApiDocument,
370
303
  getSlugUid,
371
304
  importSpecToWorkspace,
372
305
  parseSchema
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/transforms/import-spec.ts"],
4
- "sourcesContent": ["import { isDefined } from '@scalar/helpers/array/is-defined'\nimport { isHttpMethod } from '@scalar/helpers/http/is-http-method'\nimport { combineUrlAndPath } from '@scalar/helpers/url/merge-urls'\nimport { keysOf } from '@scalar/object-utils/arrays'\nimport { type LoadResult, dereference, load, upgrade } from '@scalar/openapi-parser'\nimport type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport type { ApiReferenceConfiguration } from '@scalar/types/api-reference'\nimport type { SecuritySchemeOauth2 } from '@scalar/types/entities'\nimport {\n type Oauth2FlowPayload,\n type SecurityScheme,\n type SecuritySchemePayload,\n securitySchemeSchema,\n} from '@scalar/types/entities'\nimport type { UnknownObject } from '@scalar/types/utils'\nimport type { Entries } from 'type-fest'\n\nimport type { SelectedSecuritySchemeUids } from '@/entities/shared/utility'\nimport { type Collection, type CollectionPayload, collectionSchema } from '@/entities/spec/collection'\nimport type { RequestParameterPayload } from '@/entities/spec/parameters'\nimport { type RequestExample, createExampleFromRequest } from '@/entities/spec/request-examples'\nimport { type Request, type RequestPayload, requestSchema } from '@/entities/spec/requests'\nimport { type Server, serverSchema } from '@/entities/spec/server'\nimport { type Tag, tagSchema } from '@/entities/spec/spec-objects'\nimport { schemaModel } from '@/helpers/schema-model'\n\nconst dereferenceDocument = async (\n document: string | UnknownObject,\n { shouldLoad = true }: { shouldLoad?: boolean } = {},\n) => {\n if (document === null || (typeof document === 'string' && document.trim() === '')) {\n console.warn('[@scalar/oas-utils] Empty OpenAPI document provided.')\n\n return {\n schema: {} as OpenAPIV3_1.Document,\n errors: [],\n }\n }\n\n let filesystem: LoadResult['filesystem'] | string | UnknownObject = document\n let loadErrors: LoadResult['errors'] = []\n\n if (shouldLoad) {\n // TODO: Plugins for URLs and files with the proxy are missing here.\n // @see packages/api-reference/src/helpers/parse.ts\n const response = await load(document).catch((e) => ({\n errors: [\n {\n code: e.code,\n message: e.message,\n },\n ],\n filesystem: [],\n }))\n filesystem = response.filesystem\n loadErrors = response.errors ?? []\n }\n\n const { specification } = upgrade(filesystem)\n const { schema, errors: derefErrors = [] } = await dereference(specification)\n\n return {\n schema,\n errors: [...loadErrors, ...derefErrors],\n }\n}\n\n/** Takes a string or object and parses it into an openapi spec compliant schema */\nexport const parseSchema = async (\n originalDocument: string | UnknownObject | undefined,\n {\n shouldLoad = true,\n /** If a dereferenced document is provided, we will skip the dereferencing step. */\n dereferencedDocument = undefined,\n }: { shouldLoad?: boolean; dereferencedDocument?: OpenAPIV3_1.Document } = {},\n) => {\n // Skip, if a dereferenced document is provided\n const { schema, errors } = dereferencedDocument\n ? {\n schema: dereferencedDocument,\n errors: [],\n }\n : // Otherwise, dereference the original document\n await dereferenceDocument(originalDocument ?? '', {\n shouldLoad,\n })\n\n if (!schema) {\n console.warn('[@scalar/oas-utils] OpenAPI Parser Warning: Schema is undefined')\n }\n\n return {\n /**\n * Temporary fix for the parser returning an empty array\n * TODO: remove this once the parser is fixed\n */\n schema: (Array.isArray(schema) ? {} : schema) as OpenAPIV3_1.Document,\n errors,\n }\n}\n\n/** Converts selected security requirements to uids */\nexport const getSelectedSecuritySchemeUids = (\n securityRequirements: (string | string[])[],\n preferredSecurityNames: (string | string[])[] = [],\n securitySchemeMap: Record<string, SecurityScheme['uid']>,\n): SelectedSecuritySchemeUids => {\n // Set the first security requirement if no preferred security schemes are set\n const names =\n securityRequirements[0] && !preferredSecurityNames.length ? [securityRequirements[0]] : preferredSecurityNames\n\n // Map names to uids\n const uids = names\n .map((name) =>\n Array.isArray(name) ? name.map((k) => securitySchemeMap[k]).filter(isDefined) : securitySchemeMap[name],\n )\n .filter(isDefined)\n\n return uids\n}\n\n/** Create a \"uid\" from a slug */\nexport const getSlugUid = (slug: string) => `slug-uid-${slug}` as Collection['uid']\n\nexport type ImportSpecToWorkspaceArgs = Pick<CollectionPayload, 'documentUrl' | 'watchMode'> &\n Pick<ApiReferenceConfiguration, 'authentication' | 'baseServerURL' | 'servers' | 'slug'> & {\n /** The dereferenced document */\n dereferencedDocument?: OpenAPIV3_1.Document\n /** Sets the preferred security scheme on the collection instead of the requests */\n useCollectionSecurity?: boolean\n /** Call the load step from the parser */\n shouldLoad?: boolean\n }\n\n/**\n * Imports an OpenAPI document and converts it to workspace entities (Collection, Request, Server, etc.)\n *\n * The imported entities maintain a close mapping to the original OpenAPI specification to enable:\n * - Bi-directional translation between spec and workspace entities\n * - Preservation of specification details and structure\n * - Accurate representation of relationships between components\n *\n * Relationships between entities are maintained through unique identifiers (UIDs) which allow:\n * - Flexible organization at different levels (workspace, collection, request)\n * - Proper linking between related components\n * - Easy lookup and reference of dependent entities\n */\nexport async function importSpecToWorkspace(\n content: string | UnknownObject | undefined,\n {\n /** If a dereferenced document is provided, we will skip the dereferencing step. */\n dereferencedDocument,\n authentication,\n baseServerURL,\n documentUrl,\n servers: configuredServers,\n useCollectionSecurity = false,\n slug,\n shouldLoad,\n watchMode = false,\n }: ImportSpecToWorkspaceArgs = {},\n): Promise<\n | {\n error: false\n collection: Collection\n requests: Request[]\n schema: OpenAPIV3_1.Document\n examples: RequestExample[]\n servers: Server[]\n tags: Tag[]\n securitySchemes: SecurityScheme[]\n }\n | { error: true; importWarnings: string[]; collection: undefined }\n> {\n const { schema, errors } = await parseSchema(content, { shouldLoad, dereferencedDocument })\n const importWarnings: string[] = [...errors.map((e) => e.message)]\n\n if (!schema) {\n return { importWarnings, error: true, collection: undefined }\n }\n // ---------------------------------------------------------------------------\n // Some entities will be broken out as individual lists for modification in the workspace\n const start = performance.now()\n const requests: Request[] = []\n\n // Add the base server url to collection servers\n const collectionServers: Server[] = getServersFromOpenApiDocument(configuredServers || schema.servers, {\n baseServerURL,\n documentUrl,\n })\n\n // Store operation servers\n const operationServers: Server[] = []\n\n // Fallback to the current window.location.origin if no servers are provided\n if (!collectionServers.length) {\n const fallbackUrl = getFallbackUrl()\n\n if (fallbackUrl) {\n collectionServers.push(serverSchema.parse({ url: fallbackUrl }))\n }\n }\n\n /**\n * List of all tag strings. For non compliant specs we may need to\n * add top level tag objects for missing tag objects\n */\n const tagNames: Set<string> = new Set()\n\n // ---------------------------------------------------------------------------\n // SECURITY HANDLING\n\n const security = schema.components?.securitySchemes ?? schema?.securityDefinitions ?? {}\n\n // @ts-expect-error - Toss out a deprecated warning for the old authentication state\n if (authentication?.oAuth2 || authentication?.apiKey || authentication?.http) {\n console.warn(\n `DEPRECATION WARNING: It looks like you're using legacy authentication config. Please migrate to use the updated config. See https://github.com/scalar/scalar/blob/main/documentation/configuration.md#authentication-partial This will be removed in a future version.`,\n )\n }\n\n const securitySchemes = (Object.entries(security) as Entries<Record<string, OpenAPIV3_1.SecuritySchemeObject>>)\n .map?.(([nameKey, _scheme]) => {\n // Apply any transforms we need before parsing\n const payload = {\n ..._scheme,\n // Add the new auth config overrides, we keep the old code below for backwards compatibility\n ...(authentication?.securitySchemes?.[nameKey] ?? {}),\n nameKey,\n } as SecuritySchemePayload\n\n // For oauth2 we need to add the type to the flows + prefill from authentication\n if (payload.type === 'oauth2' && payload.flows) {\n const flowKeys = Object.keys(payload.flows) as Array<keyof typeof payload.flows>\n\n flowKeys.forEach((key) => {\n if (!payload.flows?.[key] || _scheme.type !== 'oauth2') {\n return\n }\n const authFlow = (authentication?.securitySchemes?.[nameKey] as SecuritySchemeOauth2)?.flows?.[key] ?? {}\n\n // This part handles setting of flows via the new auth config, the rest can be removed in a future version\n payload.flows[key] = {\n ...(_scheme.flows?.[key] ?? {}),\n ...authFlow,\n } satisfies Oauth2FlowPayload\n\n const flow = payload.flows[key] as Oauth2FlowPayload\n\n // Set the type\n flow.type = key\n\n // Prefill values from authorization config - old deprecated config\n // @ts-expect-error - deprecated\n if (authentication?.oAuth2) {\n // @ts-expect-error - deprecated\n if (authentication.oAuth2.accessToken) {\n // @ts-expect-error - deprecated\n flow.token = authentication.oAuth2.accessToken\n }\n\n // @ts-expect-error - deprecated\n if (authentication.oAuth2.clientId) {\n // @ts-expect-error - deprecated\n flow['x-scalar-client-id'] = authentication.oAuth2.clientId\n }\n\n // @ts-expect-error - deprecated\n if (authentication.oAuth2.scopes) {\n // @ts-expect-error - deprecated\n flow.selectedScopes = authentication.oAuth2.scopes\n }\n\n if (flow.type === 'password') {\n // @ts-expect-error - deprecated\n flow.username = authentication.oAuth2.username\n // @ts-expect-error - deprecated\n flow.password = authentication.oAuth2.password\n }\n }\n\n // Convert scopes to an object\n if (Array.isArray(flow.scopes)) {\n flow.scopes = flow.scopes.reduce((prev, s) => ({ ...prev, [s]: '' }), {})\n }\n\n // Handle x-defaultClientId\n if (flow['x-defaultClientId']) {\n flow['x-scalar-client-id'] = flow['x-defaultClientId']\n }\n })\n }\n // Otherwise we just prefill - old deprecated config\n else if (authentication) {\n // ApiKey\n // @ts-expect-error - deprecated\n if (payload.type === 'apiKey' && authentication.apiKey?.token) {\n // @ts-expect-error - deprecated\n payload.value = authentication.apiKey.token\n }\n // HTTP\n else if (payload.type === 'http') {\n // @ts-expect-error - deprecated\n if (payload.scheme === 'basic' && authentication.http?.basic) {\n // @ts-expect-error - deprecated\n payload.username = authentication.http.basic.username ?? ''\n // @ts-expect-error - deprecated\n payload.password = authentication.http.basic.password ?? ''\n }\n // Bearer\n // @ts-expect-error - deprecated\n else if (payload.scheme === 'bearer' && authentication.http?.bearer?.token) {\n // @ts-expect-error - deprecated\n payload.token = authentication.http.bearer.token ?? ''\n }\n }\n }\n\n const scheme = schemaModel(payload, securitySchemeSchema, false)\n if (!scheme) {\n importWarnings.push(`Security scheme ${nameKey} is invalid.`)\n }\n\n return scheme\n })\n .filter((v) => !!v)\n\n // Map of security scheme names to UIDs\n const securitySchemeMap: Record<string, SecurityScheme['uid']> = {}\n securitySchemes.forEach((s) => {\n securitySchemeMap[s.nameKey] = s.uid\n })\n\n // ---------------------------------------------------------------------------\n // REQUEST HANDLING\n\n keysOf(schema.paths ?? {}).forEach((pathString) => {\n const path = schema?.paths?.[pathString]\n\n if (!path) {\n return\n }\n // Path level servers must be saved\n const pathServers = serverSchema.array().parse(path.servers ?? [])\n for (const server of pathServers) {\n collectionServers.push(server)\n }\n\n // Creates a sorted array of methods based on the path object.\n const methods = Object.keys(path).filter(isHttpMethod)\n\n methods.forEach((method) => {\n const operation = path[method]\n if (!operation) {\n return\n }\n\n const operationLevelServers = serverSchema.array().parse(operation.servers ?? [])\n\n for (const server of operationLevelServers) {\n operationServers.push(server)\n }\n\n // We will save a list of all tags to ensure they exists at the top level\n // TODO: make sure we add any loose requests with no tags to the collection children\n operation.tags?.forEach((t: string) => tagNames.add(t))\n\n // Remove security here and add it correctly below\n const { security: operationSecurity, ...operationWithoutSecurity } = operation\n\n const securityRequirements: (string | string[])[] = (operationSecurity ?? schema.security ?? [])\n .map((s: OpenAPIV3_1.SecurityRequirementObject) => {\n const keys = Object.keys(s)\n return keys.length > 1 ? keys : keys[0]\n })\n .filter(isDefined)\n\n // Filter the preferred security schemes to only include the ones that are in the security requirements\n const preferredSecurityNames = [authentication?.preferredSecurityScheme ?? []].flat().filter((name) => {\n // Match up complex security requirements, array to array\n if (Array.isArray(name)) {\n // We match every element in the array\n return securityRequirements.some(\n (r) => Array.isArray(r) && r.length === name.length && r.every((v, i) => v === name[i]),\n )\n }\n return securityRequirements.includes(name)\n })\n\n // Set the initially selected security scheme\n const selectedSecuritySchemeUids =\n securityRequirements.length && !useCollectionSecurity\n ? getSelectedSecuritySchemeUids(securityRequirements, preferredSecurityNames, securitySchemeMap)\n : []\n\n const requestPayload: RequestPayload = {\n ...operationWithoutSecurity,\n method,\n path: pathString,\n security: operationSecurity,\n selectedServerUid: operationLevelServers?.[0]?.uid,\n selectedSecuritySchemeUids,\n // Merge path and operation level parameters\n parameters: [...(path?.parameters ?? []), ...(operation.parameters ?? [])] as RequestParameterPayload[],\n servers: [...pathServers, ...operationLevelServers].map((s) => s.uid),\n }\n\n // Remove any examples from the request payload as they conflict with our examples property and are not valid\n if (requestPayload.examples) {\n console.warn('[@scalar/api-client] operation.examples is not a valid openapi property')\n delete requestPayload.examples\n }\n\n // Save parse the request\n const request = schemaModel(requestPayload, requestSchema, false)\n\n if (!request) {\n importWarnings.push(`${method} Request at ${path} is invalid.`)\n } else {\n requests.push(request)\n }\n })\n })\n\n // ---------------------------------------------------------------------------\n // TAG HANDLING\n\n // TODO: We may need to handle de-duping tags\n const tags = schemaModel(schema?.tags ?? [], tagSchema.array(), false) ?? []\n\n // Delete any tag names that already have a definition\n tags.forEach((t) => tagNames.delete(t.name))\n\n // Add an entry for any tags that are used but do not have a definition\n tagNames.forEach((name) => name && tags.push(tagSchema.parse({ name })))\n\n // Tag name to UID map\n const tagMap: Record<string, Tag> = {}\n tags.forEach((t) => {\n tagMap[t.name] = t\n })\n\n // Add all tags by default. We will remove nested ones\n const collectionChildren = new Set<Collection['children'][number]>(tags.map((t) => t.uid))\n\n // Nested folders go before any requests\n tags.forEach((t) => {\n t['x-scalar-children']?.forEach((c) => {\n // Add the uid to the appropriate parent.children\n const nestedUid = tagMap[c.tagName]?.uid\n\n if (nestedUid) {\n t.children.push(nestedUid)\n\n // Remove the nested uid from the root folder\n collectionChildren.delete(nestedUid)\n }\n })\n })\n\n // Add the request UIDs to the tag children (or collection root)\n requests.forEach((r) => {\n if (r.tags?.length) {\n r.tags.forEach((t) => {\n tagMap[t]?.children.push(r.uid)\n })\n } else {\n collectionChildren.add(r.uid)\n }\n })\n\n // ---------------------------------------------------------------------------\n\n const examples: RequestExample[] = []\n\n // Ensure each request has at least 1 example\n requests.forEach((request) => {\n // TODO: Need to handle parsing examples\n // if (request['x-scalar-examples']) return\n\n // Create the initial example\n const example = createExampleFromRequest(request, 'Default Example')\n\n examples.push(example)\n request.examples.push(example.uid)\n })\n\n // ---------------------------------------------------------------------------\n // Generate Collection\n\n // Grab the security requirements for this operation\n const securityRequirements: SelectedSecuritySchemeUids = (schema.security ?? [])\n .map((s: OpenAPIV3_1.SecurityRequirementObject) => {\n const keys = Object.keys(s)\n return keys.length > 1 ? keys : keys[0]\n })\n .filter(isDefined)\n\n // Here we do not filter these as we let the preferredSecurityScheme override the requirements\n const preferredSecurityNames = [authentication?.preferredSecurityScheme ?? []].flat()\n\n // Set the initially selected security scheme\n const selectedSecuritySchemeUids =\n (securityRequirements.length || preferredSecurityNames?.length) && useCollectionSecurity\n ? getSelectedSecuritySchemeUids(securityRequirements, preferredSecurityNames, securitySchemeMap)\n : []\n\n // Set the uid as a prefixed slug if we have one\n const slugObj = slug?.length ? { uid: getSlugUid(slug) } : {}\n\n const collection = collectionSchema.parse({\n ...slugObj,\n ...schema,\n watchMode,\n documentUrl,\n useCollectionSecurity,\n requests: requests.map((r) => r.uid),\n servers: collectionServers.map((s) => s.uid),\n tags: tags.map((t) => t.uid),\n children: [...collectionChildren],\n security: schema.security ?? [{}],\n selectedServerUid: collectionServers?.[0]?.uid,\n selectedSecuritySchemeUids,\n components: {\n ...schema.components,\n },\n securitySchemes: securitySchemes.map((s) => s.uid),\n })\n\n const end = performance.now()\n console.log(`workspace: ${Math.round(end - start)} ms`)\n\n /**\n * Servers and requests will be saved in top level maps and indexed via UID to\n * maintain specification relationships\n */\n return {\n error: false,\n servers: [...collectionServers, ...operationServers],\n schema,\n requests,\n examples,\n collection,\n tags,\n securitySchemes,\n }\n}\n\n/**\n * Extracts the base URL (protocol + hostname) from a document URL.\n * Falls back to the original URL if it's not a valid URL.\n */\nfunction getBaseUrlFromDocumentUrl(documentUrl: string): string | undefined {\n try {\n const url = new URL(documentUrl)\n return `${url.protocol}//${url.hostname}${url.port ? `:${url.port}` : ''}`\n } catch {\n // If the documentUrl is not a valid URL, we can't use it\n return undefined\n }\n}\n\n/**\n * Retrieves a list of servers from an OpenAPI document and converts them to a list of Server entities.\n */\nexport function getServersFromOpenApiDocument(\n servers: OpenAPIV3_1.ServerObject[] | undefined,\n {\n baseServerURL,\n documentUrl,\n }: Pick<ApiReferenceConfiguration, 'baseServerURL'> & Pick<ImportSpecToWorkspaceArgs, 'documentUrl'> = {},\n): Server[] {\n // If the document doesn't have any servers, try to use the documentUrl as the default server.\n if (!servers?.length && documentUrl) {\n const newServerUrl = getBaseUrlFromDocumentUrl(documentUrl)\n\n if (newServerUrl) {\n return [serverSchema.parse({ url: newServerUrl })]\n }\n }\n\n // If the servers are not an array, return an empty array.\n if (!servers || !Array.isArray(servers)) {\n return []\n }\n\n return servers\n .map((server): Server | undefined => {\n try {\n // Validate the server against the schema\n const parsedSchema = serverSchema.parse(server)\n\n // Prepend with the base server URL (if the given URL is relative)\n if (parsedSchema?.url?.startsWith('/')) {\n // Use the base server URL (if provided)\n if (baseServerURL) {\n parsedSchema.url = combineUrlAndPath(baseServerURL, parsedSchema.url)\n\n return parsedSchema\n }\n\n if (documentUrl) {\n const baseUrl = getBaseUrlFromDocumentUrl(documentUrl)\n\n if (baseUrl) {\n parsedSchema.url = combineUrlAndPath(baseUrl, parsedSchema.url)\n }\n\n return parsedSchema\n }\n\n // Fallback to the current window origin\n const fallbackUrl = getFallbackUrl()\n\n if (fallbackUrl) {\n parsedSchema.url = combineUrlAndPath(fallbackUrl, parsedSchema.url.replace(/^\\//, ''))\n\n return parsedSchema\n }\n }\n\n // Must be good, return it\n return parsedSchema\n } catch (error) {\n console.warn(\"Oops, that's an invalid server configuration.\")\n console.warn('Server:', server)\n console.warn('Error:', error)\n\n // Return undefined to remove the server\n return undefined\n }\n })\n .filter(isDefined)\n}\n\n/**\n * Fallback to the current window.location.origin, if available\n */\nfunction getFallbackUrl() {\n if (typeof window === 'undefined') {\n return undefined\n }\n\n if (typeof window?.location?.origin !== 'string') {\n return undefined\n }\n\n return window.location.origin\n}\n"],
5
- "mappings": "AAAA,SAAS,iBAAiB;AAC1B,SAAS,oBAAoB;AAC7B,SAAS,yBAAyB;AAClC,SAAS,cAAc;AACvB,SAA0B,aAAa,MAAM,eAAe;AAI5D;AAAA,EAIE;AAAA,OACK;AAKP,SAAkD,wBAAwB;AAE1E,SAA8B,gCAAgC;AAC9D,SAA4C,qBAAqB;AACjE,SAAsB,oBAAoB;AAC1C,SAAmB,iBAAiB;AACpC,SAAS,mBAAmB;AAE5B,MAAM,sBAAsB,OAC1B,UACA,EAAE,aAAa,KAAK,IAA8B,CAAC,MAChD;AACH,MAAI,aAAa,QAAS,OAAO,aAAa,YAAY,SAAS,KAAK,MAAM,IAAK;AACjF,YAAQ,KAAK,sDAAsD;AAEnE,WAAO;AAAA,MACL,QAAQ,CAAC;AAAA,MACT,QAAQ,CAAC;AAAA,IACX;AAAA,EACF;AAEA,MAAI,aAAgE;AACpE,MAAI,aAAmC,CAAC;AAExC,MAAI,YAAY;AAGd,UAAM,WAAW,MAAM,KAAK,QAAQ,EAAE,MAAM,CAAC,OAAO;AAAA,MAClD,QAAQ;AAAA,QACN;AAAA,UACE,MAAM,EAAE;AAAA,UACR,SAAS,EAAE;AAAA,QACb;AAAA,MACF;AAAA,MACA,YAAY,CAAC;AAAA,IACf,EAAE;AACF,iBAAa,SAAS;AACtB,iBAAa,SAAS,UAAU,CAAC;AAAA,EACnC;AAEA,QAAM,EAAE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AC9F;AAEV,MAAI,CAAC,SAAS,UAAU,aAAa;AACnC,UAAM,eAAe,0BAA0B,WAAW;AAE1D,QAAI,cAAc;AAChB,aAAO,CAAC,aAAa,MAAM,EAAE,KAAK,aAAa,CAAC,CAAC;AAAA,IACnD;AAAA,EACF;AAGA,MAAI,CAAC,WAAW,CAAC,MAAM,QAAQ,OAAO,GAAG;AACvC,WAAO,CAAC;AAAA,EACV;AAEA,SAAO,QACJ,IAAI,CAAC,WAA+B;AACnC,QAAI;AAEF,YAAM,eAAe,aAAa,MAAM,MAAM;AAG9C,UAAI,cAAc,KAAK,WAAW,GAAG,GAAG;AAEtC,YAAI,eAAe;AACjB,uBAAa,MAAM,kBAAkB,eAAe,aAAa,GAAG;AAEpE,iBAAO;AAAA,QACT;AAEA,YAAI,aAAa;AACf,gBAAM,UAAU,0BAA0B,WAAW;AAErD,cAAI,SAAS;AACX,yBAAa,MAAM,kBAAkB,SAAS,aAAa,GAAG;AAAA,UAChE;AAEA,iBAAO;AAAA,QACT;AAGA,cAAM,cAAc,eAAe;AAEnC,YAAI,aAAa;AACf,uBAAa,MAAM,kBAAkB,aAAa,aAAa,IAAI,QAAQ,OAAO,EAAE,CAAC;AAErF,iBAAO;AAAA,QACT;AAAA,MACF;AAGA,aAAO;AAAA,IACT,SAAS,OAAO;AACd,cAAQ,KAAK,+CAA+C;AAC5D,cAAQ,KAAK,WAAW,MAAM;AAC9B,cAAQ,KAAK,UAAU,KAAK;AAG5B,aAAO;AAAA,IACT;AAAA,EACF,CAAC,EACA,OAAO,SAAS;AACrB;AAKA,SAAS,iBAAiB;AACxB,MAAI,OAAO,WAAW,aAAa;AACjC,WAAO;AAAA,EACT;AAEA,MAAI,OAAO,QAAQ,UAAU,WAAW,UAAU;AAChD,WAAO;AAAA,EACT;AAEA,SAAO,OAAO,SAAS;AACzB;",
4
+ "sourcesContent": ["import { isDefined } from '@scalar/helpers/array/is-defined'\nimport { isHttpMethod } from '@scalar/helpers/http/is-http-method'\nimport { keysOf } from '@scalar/object-utils/arrays'\nimport { type LoadResult, dereference, load, upgrade } from '@scalar/openapi-parser'\nimport type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport type { ApiReferenceConfiguration } from '@scalar/types/api-reference'\nimport type { SecuritySchemeOauth2 } from '@scalar/types/entities'\nimport {\n type Oauth2FlowPayload,\n type SecurityScheme,\n type SecuritySchemePayload,\n securitySchemeSchema,\n} from '@scalar/types/entities'\nimport type { UnknownObject } from '@scalar/types/utils'\nimport type { Entries } from 'type-fest'\n\nimport type { SelectedSecuritySchemeUids } from '@/entities/shared/utility'\nimport { type Collection, type CollectionPayload, collectionSchema } from '@/entities/spec/collection'\nimport type { RequestParameterPayload } from '@/entities/spec/parameters'\nimport { type RequestExample, createExampleFromRequest } from '@/entities/spec/request-examples'\nimport { type Request, type RequestPayload, requestSchema } from '@/entities/spec/requests'\nimport { type Server, serverSchema } from '@/entities/spec/server'\nimport { type Tag, tagSchema } from '@/entities/spec/spec-objects'\nimport { schemaModel } from '@/helpers/schema-model'\nimport { getServersFromDocument } from '@/helpers/servers'\n\nconst dereferenceDocument = async (\n document: string | UnknownObject,\n { shouldLoad = true }: { shouldLoad?: boolean } = {},\n) => {\n if (document === null || (typeof document === 'string' && document.trim() === '')) {\n console.warn('[@scalar/oas-utils] Empty OpenAPI document provided.')\n\n return {\n schema: {} as OpenAPIV3_1.Document,\n errors: [],\n }\n }\n\n let filesystem: LoadResult['filesystem'] | string | UnknownObject = document\n let loadErrors: LoadResult['errors'] = []\n\n if (shouldLoad) {\n // TODO: Plugins for URLs and files with the proxy are missing here.\n // @see packages/api-reference/src/helpers/parse.ts\n const response = await load(document).catch((e) => ({\n errors: [\n {\n code: e.code,\n message: e.message,\n },\n ],\n filesystem: [],\n }))\n filesystem = response.filesystem\n loadErrors = response.errors ?? []\n }\n\n const { specification } = upgrade(filesystem)\n const { schema, errors: derefErrors = [] } = await dereference(specification)\n\n return {\n schema,\n errors: [...loadErrors, ...derefErrors],\n }\n}\n\n/** Takes a string or object and parses it into an openapi spec compliant schema */\nexport const parseSchema = async (\n originalDocument: string | UnknownObject | undefined,\n {\n shouldLoad = true,\n /** If a dereferenced document is provided, we will skip the dereferencing step. */\n dereferencedDocument = undefined,\n }: { shouldLoad?: boolean; dereferencedDocument?: OpenAPIV3_1.Document } = {},\n) => {\n // Skip, if a dereferenced document is provided\n const { schema, errors } = dereferencedDocument\n ? {\n schema: dereferencedDocument,\n errors: [],\n }\n : // Otherwise, dereference the original document\n await dereferenceDocument(originalDocument ?? '', {\n shouldLoad,\n })\n\n if (!schema) {\n console.warn('[@scalar/oas-utils] OpenAPI Parser Warning: Schema is undefined')\n }\n\n return {\n /**\n * Temporary fix for the parser returning an empty array\n * TODO: remove this once the parser is fixed\n */\n schema: (Array.isArray(schema) ? {} : schema) as OpenAPIV3_1.Document,\n errors,\n }\n}\n\n/** Converts selected security requirements to uids */\nexport const getSelectedSecuritySchemeUids = (\n securityRequirements: (string | string[])[],\n preferredSecurityNames: (string | string[])[] = [],\n securitySchemeMap: Record<string, SecurityScheme['uid']>,\n): SelectedSecuritySchemeUids => {\n // Set the first security requirement if no preferred security schemes are set\n const names =\n securityRequirements[0] && !preferredSecurityNames.length ? [securityRequirements[0]] : preferredSecurityNames\n\n // Map names to uids\n const uids = names\n .map((name) =>\n Array.isArray(name) ? name.map((k) => securitySchemeMap[k]).filter(isDefined) : securitySchemeMap[name],\n )\n .filter(isDefined)\n\n return uids\n}\n\n/** Create a \"uid\" from a slug */\nexport const getSlugUid = (slug: string) => `slug-uid-${slug}` as Collection['uid']\n\nexport type ImportSpecToWorkspaceArgs = Pick<CollectionPayload, 'documentUrl' | 'watchMode'> &\n Pick<ApiReferenceConfiguration, 'authentication' | 'baseServerURL' | 'servers' | 'slug'> & {\n /** The dereferenced document */\n dereferencedDocument?: OpenAPIV3_1.Document\n /** Sets the preferred security scheme on the collection instead of the requests */\n useCollectionSecurity?: boolean\n /** Call the load step from the parser */\n shouldLoad?: boolean\n }\n\n/**\n * Imports an OpenAPI document and converts it to workspace entities (Collection, Request, Server, etc.)\n *\n * The imported entities maintain a close mapping to the original OpenAPI specification to enable:\n * - Bi-directional translation between spec and workspace entities\n * - Preservation of specification details and structure\n * - Accurate representation of relationships between components\n *\n * Relationships between entities are maintained through unique identifiers (UIDs) which allow:\n * - Flexible organization at different levels (workspace, collection, request)\n * - Proper linking between related components\n * - Easy lookup and reference of dependent entities\n */\nexport async function importSpecToWorkspace(\n content: string | UnknownObject | undefined,\n {\n /** If a dereferenced document is provided, we will skip the dereferencing step. */\n dereferencedDocument,\n authentication,\n baseServerURL,\n documentUrl,\n servers: configuredServers,\n useCollectionSecurity = false,\n slug,\n shouldLoad,\n watchMode = false,\n }: ImportSpecToWorkspaceArgs = {},\n): Promise<\n | {\n error: false\n collection: Collection\n requests: Request[]\n schema: OpenAPIV3_1.Document\n examples: RequestExample[]\n servers: Server[]\n tags: Tag[]\n securitySchemes: SecurityScheme[]\n }\n | { error: true; importWarnings: string[]; collection: undefined }\n> {\n const { schema, errors } = await parseSchema(content, { shouldLoad, dereferencedDocument })\n const importWarnings: string[] = [...errors.map((e) => e.message)]\n\n if (!schema) {\n return { importWarnings, error: true, collection: undefined }\n }\n // ---------------------------------------------------------------------------\n // Some entities will be broken out as individual lists for modification in the workspace\n const start = performance.now()\n const requests: Request[] = []\n\n // Add the base server url to collection servers\n const collectionServers: Server[] = getServersFromDocument(configuredServers || schema.servers, {\n baseServerURL,\n documentUrl,\n })\n\n // Store operation servers\n const operationServers: Server[] = []\n\n /**\n * List of all tag strings. For non compliant specs we may need to\n * add top level tag objects for missing tag objects\n */\n const tagNames: Set<string> = new Set()\n\n // ---------------------------------------------------------------------------\n // SECURITY HANDLING\n\n const security = schema.components?.securitySchemes ?? schema?.securityDefinitions ?? {}\n\n // @ts-expect-error - Toss out a deprecated warning for the old authentication state\n if (authentication?.oAuth2 || authentication?.apiKey || authentication?.http) {\n console.warn(\n `DEPRECATION WARNING: It looks like you're using legacy authentication config. Please migrate to use the updated config. See https://github.com/scalar/scalar/blob/main/documentation/configuration.md#authentication-partial This will be removed in a future version.`,\n )\n }\n\n const securitySchemes = (Object.entries(security) as Entries<Record<string, OpenAPIV3_1.SecuritySchemeObject>>)\n .map?.(([nameKey, _scheme]) => {\n // Apply any transforms we need before parsing\n const payload = {\n ..._scheme,\n // Add the new auth config overrides, we keep the old code below for backwards compatibility\n ...(authentication?.securitySchemes?.[nameKey] ?? {}),\n nameKey,\n } as SecuritySchemePayload\n\n // For oauth2 we need to add the type to the flows + prefill from authentication\n if (payload.type === 'oauth2' && payload.flows) {\n const flowKeys = Object.keys(payload.flows) as Array<keyof typeof payload.flows>\n\n flowKeys.forEach((key) => {\n if (!payload.flows?.[key] || _scheme.type !== 'oauth2') {\n return\n }\n const authFlow = (authentication?.securitySchemes?.[nameKey] as SecuritySchemeOauth2)?.flows?.[key] ?? {}\n\n // This part handles setting of flows via the new auth config, the rest can be removed in a future version\n payload.flows[key] = {\n ...(_scheme.flows?.[key] ?? {}),\n ...authFlow,\n } satisfies Oauth2FlowPayload\n\n const flow = payload.flows[key] as Oauth2FlowPayload\n\n // Set the type\n flow.type = key\n\n // Prefill values from authorization config - old deprecated config\n // @ts-expect-error - deprecated\n if (authentication?.oAuth2) {\n // @ts-expect-error - deprecated\n if (authentication.oAuth2.accessToken) {\n // @ts-expect-error - deprecated\n flow.token = authentication.oAuth2.accessToken\n }\n\n // @ts-expect-error - deprecated\n if (authentication.oAuth2.clientId) {\n // @ts-expect-error - deprecated\n flow['x-scalar-client-id'] = authentication.oAuth2.clientId\n }\n\n // @ts-expect-error - deprecated\n if (authentication.oAuth2.scopes) {\n // @ts-expect-error - deprecated\n flow.selectedScopes = authentication.oAuth2.scopes\n }\n\n if (flow.type === 'password') {\n // @ts-expect-error - deprecated\n flow.username = authentication.oAuth2.username\n // @ts-expect-error - deprecated\n flow.password = authentication.oAuth2.password\n }\n }\n\n // Convert scopes to an object\n if (Array.isArray(flow.scopes)) {\n flow.scopes = flow.scopes.reduce((prev, s) => ({ ...prev, [s]: '' }), {})\n }\n\n // Handle x-defaultClientId\n if (flow['x-defaultClientId']) {\n flow['x-scalar-client-id'] = flow['x-defaultClientId']\n }\n })\n }\n // Otherwise we just prefill - old deprecated config\n else if (authentication) {\n // ApiKey\n // @ts-expect-error - deprecated\n if (payload.type === 'apiKey' && authentication.apiKey?.token) {\n // @ts-expect-error - deprecated\n payload.value = authentication.apiKey.token\n }\n // HTTP\n else if (payload.type === 'http') {\n // @ts-expect-error - deprecated\n if (payload.scheme === 'basic' && authentication.http?.basic) {\n // @ts-expect-error - deprecated\n payload.username = authentication.http.basic.username ?? ''\n // @ts-expect-error - deprecated\n payload.password = authentication.http.basic.password ?? ''\n }\n // Bearer\n // @ts-expect-error - deprecated\n else if (payload.scheme === 'bearer' && authentication.http?.bearer?.token) {\n // @ts-expect-error - deprecated\n payload.token = authentication.http.bearer.token ?? ''\n }\n }\n }\n\n const scheme = schemaModel(payload, securitySchemeSchema, false)\n if (!scheme) {\n importWarnings.push(`Security scheme ${nameKey} is invalid.`)\n }\n\n return scheme\n })\n .filter((v) => !!v)\n\n // Map of security scheme names to UIDs\n const securitySchemeMap: Record<string, SecurityScheme['uid']> = {}\n securitySchemes.forEach((s) => {\n securitySchemeMap[s.nameKey] = s.uid\n })\n\n // ---------------------------------------------------------------------------\n // REQUEST HANDLING\n\n keysOf(schema.paths ?? {}).forEach((pathString) => {\n const path = schema?.paths?.[pathString]\n\n if (!path) {\n return\n }\n // Path level servers must be saved\n const pathServers = serverSchema.array().parse(path.servers ?? [])\n for (const server of pathServers) {\n collectionServers.push(server)\n }\n\n // Creates a sorted array of methods based on the path object.\n const methods = Object.keys(path).filter(isHttpMethod)\n\n methods.forEach((method) => {\n const operation = path[method]\n if (!operation) {\n return\n }\n\n const operationLevelServers = serverSchema.array().parse(operation.servers ?? [])\n\n for (const server of operationLevelServers) {\n operationServers.push(server)\n }\n\n // We will save a list of all tags to ensure they exists at the top level\n // TODO: make sure we add any loose requests with no tags to the collection children\n operation.tags?.forEach((t: string) => tagNames.add(t))\n\n // Remove security here and add it correctly below\n const { security: operationSecurity, ...operationWithoutSecurity } = operation\n\n const securityRequirements: (string | string[])[] = (operationSecurity ?? schema.security ?? [])\n .map((s: OpenAPIV3_1.SecurityRequirementObject) => {\n const keys = Object.keys(s)\n return keys.length > 1 ? keys : keys[0]\n })\n .filter(isDefined)\n\n // Filter the preferred security schemes to only include the ones that are in the security requirements\n const preferredSecurityNames = [authentication?.preferredSecurityScheme ?? []].flat().filter((name) => {\n // Match up complex security requirements, array to array\n if (Array.isArray(name)) {\n // We match every element in the array\n return securityRequirements.some(\n (r) => Array.isArray(r) && r.length === name.length && r.every((v, i) => v === name[i]),\n )\n }\n return securityRequirements.includes(name)\n })\n\n // Set the initially selected security scheme\n const selectedSecuritySchemeUids =\n securityRequirements.length && !useCollectionSecurity\n ? getSelectedSecuritySchemeUids(securityRequirements, preferredSecurityNames, securitySchemeMap)\n : []\n\n const requestPayload: RequestPayload = {\n ...operationWithoutSecurity,\n method,\n path: pathString,\n security: operationSecurity,\n selectedServerUid: operationLevelServers?.[0]?.uid,\n selectedSecuritySchemeUids,\n // Merge path and operation level parameters\n parameters: [...(path?.parameters ?? []), ...(operation.parameters ?? [])] as RequestParameterPayload[],\n servers: [...pathServers, ...operationLevelServers].map((s) => s.uid),\n }\n\n // Remove any examples from the request payload as they conflict with our examples property and are not valid\n if (requestPayload.examples) {\n console.warn('[@scalar/api-client] operation.examples is not a valid openapi property')\n delete requestPayload.examples\n }\n\n // Save parse the request\n const request = schemaModel(requestPayload, requestSchema, false)\n\n if (!request) {\n importWarnings.push(`${method} Request at ${path} is invalid.`)\n } else {\n requests.push(request)\n }\n })\n })\n\n // ---------------------------------------------------------------------------\n // TAG HANDLING\n\n // TODO: We may need to handle de-duping tags\n const tags = schemaModel(schema?.tags ?? [], tagSchema.array(), false) ?? []\n\n // Delete any tag names that already have a definition\n tags.forEach((t) => tagNames.delete(t.name))\n\n // Add an entry for any tags that are used but do not have a definition\n tagNames.forEach((name) => name && tags.push(tagSchema.parse({ name })))\n\n // Tag name to UID map\n const tagMap: Record<string, Tag> = {}\n tags.forEach((t) => {\n tagMap[t.name] = t\n })\n\n // Add all tags by default. We will remove nested ones\n const collectionChildren = new Set<Collection['children'][number]>(tags.map((t) => t.uid))\n\n // Nested folders go before any requests\n tags.forEach((t) => {\n t['x-scalar-children']?.forEach((c) => {\n // Add the uid to the appropriate parent.children\n const nestedUid = tagMap[c.tagName]?.uid\n\n if (nestedUid) {\n t.children.push(nestedUid)\n\n // Remove the nested uid from the root folder\n collectionChildren.delete(nestedUid)\n }\n })\n })\n\n // Add the request UIDs to the tag children (or collection root)\n requests.forEach((r) => {\n if (r.tags?.length) {\n r.tags.forEach((t) => {\n tagMap[t]?.children.push(r.uid)\n })\n } else {\n collectionChildren.add(r.uid)\n }\n })\n\n // ---------------------------------------------------------------------------\n\n const examples: RequestExample[] = []\n\n // Ensure each request has at least 1 example\n requests.forEach((request) => {\n // TODO: Need to handle parsing examples\n // if (request['x-scalar-examples']) return\n\n // Create the initial example\n const example = createExampleFromRequest(request, 'Default Example')\n\n examples.push(example)\n request.examples.push(example.uid)\n })\n\n // ---------------------------------------------------------------------------\n // Generate Collection\n\n // Grab the security requirements for this operation\n const securityRequirements: SelectedSecuritySchemeUids = (schema.security ?? [])\n .map((s: OpenAPIV3_1.SecurityRequirementObject) => {\n const keys = Object.keys(s)\n return keys.length > 1 ? keys : keys[0]\n })\n .filter(isDefined)\n\n // Here we do not filter these as we let the preferredSecurityScheme override the requirements\n const preferredSecurityNames = [authentication?.preferredSecurityScheme ?? []].flat()\n\n // Set the initially selected security scheme\n const selectedSecuritySchemeUids =\n (securityRequirements.length || preferredSecurityNames?.length) && useCollectionSecurity\n ? getSelectedSecuritySchemeUids(securityRequirements, preferredSecurityNames, securitySchemeMap)\n : []\n\n // Set the uid as a prefixed slug if we have one\n const slugObj = slug?.length ? { uid: getSlugUid(slug) } : {}\n\n const collection = collectionSchema.parse({\n ...slugObj,\n ...schema,\n watchMode,\n documentUrl,\n useCollectionSecurity,\n requests: requests.map((r) => r.uid),\n servers: collectionServers.map((s) => s.uid),\n tags: tags.map((t) => t.uid),\n children: [...collectionChildren],\n security: schema.security ?? [{}],\n selectedServerUid: collectionServers?.[0]?.uid,\n selectedSecuritySchemeUids,\n components: {\n ...schema.components,\n },\n securitySchemes: securitySchemes.map((s) => s.uid),\n })\n\n const end = performance.now()\n console.log(`workspace: ${Math.round(end - start)} ms`)\n\n /**\n * Servers and requests will be saved in top level maps and indexed via UID to\n * maintain specification relationships\n */\n return {\n error: false,\n servers: [...collectionServers, ...operationServers],\n schema,\n requests,\n examples,\n collection,\n tags,\n securitySchemes,\n }\n}\n"],
5
+ "mappings": "AAAA,SAAS,iBAAiB;AAC1B,SAAS,oBAAoB;AAC7B,SAAS,cAAc;AACvB,SAA0B,aAAa,MAAM,eAAe;AAI5D;AAAA,EAIE;AAAA,OACK;AAKP,SAAkD,wBAAwB;AAE1E,SAA8B,gCAAgC;AAC9D,SAA4C,qBAAqB;AACjE,SAAsB,oBAAoB;AAC1C,SAAmB,iBAAiB;AACpC,SAAS,mBAAmB;AAC5B,SAAS,8BAA8B;AAEvC,MAAM,sBAAsB,OAC1B,UACA,EAAE,aAAa,KAAK,IAA8B,CAAC,MAChD;AACH,MAAI,aAAa,QAAS,OAAO,aAAa,YAAY,SAAS,KAAK,MAAM,IAAK;AACjF,YAAQ,KAAK,sDAAsD;AAEnE,WAAO;AAAA,MACL,QAAQ,CAAC;AAAA,MACT,QAAQ,CAAC;AAAA,IACX;AAAA,EACF;AAEA,MAAI,aAAgE;AACpE,MAAI,aAAmC,CAAC;AAExC,MAAI,YAAY;AAGd,UAAM,WAAW,MAAM,KAAK,QAAQ,EAAE,MAAM,CAAC,OAAO;AAAA,MAClD,QAAQ;AAAA,QACN;AAAA,UACE,MAAM,EAAE;AAAA,UACR,SAAS,EAAE;AAAA,QACb;AAAA,MACF;AAAA,MACA,YA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wB,iBAAiB,IAC7F,CAAC;AAGP,QAAM,UAAU,MAAM,SAAS,EAAE,KAAK,WAAW,IAAI,EAAE,IAAI,CAAC;AAE5D,QAAM,aAAa,iBAAiB,MAAM;AAAA,IACxC,GAAG;AAAA,IACH,GAAG;AAAA,IACH;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU,SAAS,IAAI,CAAC,MAAM,EAAE,GAAG;AAAA,IACnC,SAAS,kBAAkB,IAAI,CAAC,MAAM,EAAE,GAAG;AAAA,IAC3C,MAAM,KAAK,IAAI,CAAC,MAAM,EAAE,GAAG;AAAA,IAC3B,UAAU,CAAC,GAAG,kBAAkB;AAAA,IAChC,UAAU,OAAO,YAAY,CAAC,CAAC,CAAC;AAAA,IAChC,mBAAmB,oBAAoB,CAAC,GAAG;AAAA,IAC3C;AAAA,IACA,YAAY;AAAA,MACV,GAAG,OAAO;AAAA,IACZ;AAAA,IACA,iBAAiB,gBAAgB,IAAI,CAAC,MAAM,EAAE,GAAG;AAAA,EACnD,CAAC;AAED,QAAM,MAAM,YAAY,IAAI;AAC5B,UAAQ,IAAI,cAAc,KAAK,MAAM,MAAM,KAAK,CAAC,KAAK;AAMtD,SAAO;AAAA,IACL,OAAO;AAAA,IACP,SAAS,CAAC,GAAG,mBAAmB,GAAG,gBAAgB;AAAA,IACnD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;",
6
6
  "names": ["securityRequirements", "preferredSecurityNames", "selectedSecuritySchemeUids"]
7
7
  }
@@ -1,2 +1,2 @@
1
- export { getSlugUid, importSpecToWorkspace, getServersFromOpenApiDocument, parseSchema, type ImportSpecToWorkspaceArgs, } from './import-spec.js';
1
+ export { getSlugUid, importSpecToWorkspace, parseSchema, type ImportSpecToWorkspaceArgs, } from './import-spec.js';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/transforms/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,qBAAqB,EACrB,6BAA6B,EAC7B,WAAW,EACX,KAAK,yBAAyB,GAC/B,MAAM,eAAe,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/transforms/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,qBAAqB,EACrB,WAAW,EACX,KAAK,yBAAyB,GAC/B,MAAM,eAAe,CAAA"}
@@ -1,11 +1,9 @@
1
1
  import {
2
2
  getSlugUid,
3
3
  importSpecToWorkspace,
4
- getServersFromOpenApiDocument,
5
4
  parseSchema
6
5
  } from "./import-spec.js";
7
6
  export {
8
- getServersFromOpenApiDocument,
9
7
  getSlugUid,
10
8
  importSpecToWorkspace,
11
9
  parseSchema
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/transforms/index.ts"],
4
- "sourcesContent": ["export {\n getSlugUid,\n importSpecToWorkspace,\n getServersFromOpenApiDocument,\n parseSchema,\n type ImportSpecToWorkspaceArgs,\n} from './import-spec'\n"],
5
- "mappings": "AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;",
4
+ "sourcesContent": ["export {\n getSlugUid,\n importSpecToWorkspace,\n parseSchema,\n type ImportSpecToWorkspaceArgs,\n} from './import-spec'\n"],
5
+ "mappings": "AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -16,7 +16,7 @@
16
16
  "specification",
17
17
  "yaml"
18
18
  ],
19
- "version": "0.4.18",
19
+ "version": "0.4.21",
20
20
  "engines": {
21
21
  "node": ">=20"
22
22
  },
@@ -99,12 +99,13 @@
99
99
  "type-fest": "4.41.0",
100
100
  "yaml": "2.8.0",
101
101
  "zod": "3.24.1",
102
- "@scalar/helpers": "0.0.7",
102
+ "@scalar/helpers": "0.0.8",
103
+ "@scalar/json-magic": "0.3.0",
103
104
  "@scalar/openapi-types": "0.3.7",
104
- "@scalar/object-utils": "1.2.3",
105
- "@scalar/themes": "0.13.12",
106
- "@scalar/types": "0.2.11",
107
- "@scalar/workspace-store": "0.12.0"
105
+ "@scalar/object-utils": "1.2.4",
106
+ "@scalar/themes": "0.13.13",
107
+ "@scalar/types": "0.2.12",
108
+ "@scalar/workspace-store": "0.14.1"
108
109
  },
109
110
  "devDependencies": {
110
111
  "@types/node": "^22.9.0",
@@ -112,9 +113,9 @@
112
113
  "vite": "6.1.6",
113
114
  "vitest": "^3.2.4",
114
115
  "zod-to-ts": "github:amritk/zod-to-ts#build",
115
- "@scalar/build-tooling": "0.2.4",
116
- "@scalar/openapi-types": "0.3.7",
117
- "@scalar/openapi-parser": "0.19.0"
116
+ "@scalar/openapi-parser": "0.20.0",
117
+ "@scalar/build-tooling": "0.2.6",
118
+ "@scalar/openapi-types": "0.3.7"
118
119
  },
119
120
  "scripts": {
120
121
  "build": "scalar-build-esbuild",