@scalar/oas-utils 0.4.1 → 0.4.3

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 (106) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/entities/spec/request-examples.d.ts +27 -27
  3. package/dist/entities/spec/request-examples.d.ts.map +1 -1
  4. package/dist/entities/spec/request-examples.js +4 -4
  5. package/dist/entities/spec/request-examples.js.map +2 -2
  6. package/dist/entities/spec/spec-objects.d.ts.map +1 -1
  7. package/dist/entities/spec/spec-objects.js +1 -1
  8. package/dist/entities/spec/spec-objects.js.map +1 -1
  9. package/dist/helpers/index.d.ts +77 -18
  10. package/dist/helpers/index.d.ts.map +1 -1
  11. package/dist/helpers/index.js +69 -21
  12. package/dist/helpers/index.js.map +2 -2
  13. package/dist/helpers/redirect-to-proxy.d.ts +0 -4
  14. package/dist/helpers/redirect-to-proxy.d.ts.map +1 -1
  15. package/dist/helpers/redirect-to-proxy.js +2 -13
  16. package/dist/helpers/redirect-to-proxy.js.map +2 -2
  17. package/dist/helpers/security/get-schemes.d.ts.map +1 -1
  18. package/dist/helpers/security/get-schemes.js +1 -1
  19. package/dist/helpers/security/get-schemes.js.map +2 -2
  20. package/dist/migrations/local-storage.d.ts +1 -1
  21. package/dist/migrations/local-storage.d.ts.map +1 -1
  22. package/dist/migrations/local-storage.js +1 -1
  23. package/dist/migrations/local-storage.js.map +2 -2
  24. package/dist/migrations/v-2.1.0/migration.d.ts.map +1 -1
  25. package/dist/migrations/v-2.1.0/migration.js +2 -1
  26. package/dist/migrations/v-2.1.0/migration.js.map +2 -2
  27. package/dist/spec-getters/get-request-body-from-operation.d.ts.map +1 -1
  28. package/dist/spec-getters/get-request-body-from-operation.js +1 -1
  29. package/dist/spec-getters/get-request-body-from-operation.js.map +2 -2
  30. package/dist/transforms/import-spec.d.ts +1 -1
  31. package/dist/transforms/import-spec.d.ts.map +1 -1
  32. package/dist/transforms/import-spec.js +9 -6
  33. package/dist/transforms/import-spec.js.map +2 -2
  34. package/package.json +8 -7
  35. package/dist/helpers/create-hash.d.ts +0 -7
  36. package/dist/helpers/create-hash.d.ts.map +0 -1
  37. package/dist/helpers/create-hash.js +0 -18
  38. package/dist/helpers/create-hash.js.map +0 -7
  39. package/dist/helpers/ensure-protocol.d.ts +0 -3
  40. package/dist/helpers/ensure-protocol.d.ts.map +0 -1
  41. package/dist/helpers/ensure-protocol.js +0 -11
  42. package/dist/helpers/ensure-protocol.js.map +0 -7
  43. package/dist/helpers/find-variables.d.ts +0 -5
  44. package/dist/helpers/find-variables.d.ts.map +0 -1
  45. package/dist/helpers/find-variables.js +0 -8
  46. package/dist/helpers/find-variables.js.map +0 -7
  47. package/dist/helpers/http-methods.d.ts +0 -29
  48. package/dist/helpers/http-methods.d.ts.map +0 -1
  49. package/dist/helpers/http-methods.js +0 -66
  50. package/dist/helpers/http-methods.js.map +0 -7
  51. package/dist/helpers/http-status-codes.d.ts +0 -8
  52. package/dist/helpers/http-status-codes.d.ts.map +0 -1
  53. package/dist/helpers/http-status-codes.js +0 -321
  54. package/dist/helpers/http-status-codes.js.map +0 -7
  55. package/dist/helpers/is-defined.d.ts +0 -13
  56. package/dist/helpers/is-defined.d.ts.map +0 -1
  57. package/dist/helpers/is-defined.js +0 -5
  58. package/dist/helpers/is-defined.js.map +0 -7
  59. package/dist/helpers/is-local-url.d.ts +0 -5
  60. package/dist/helpers/is-local-url.d.ts.map +0 -1
  61. package/dist/helpers/is-local-url.js +0 -13
  62. package/dist/helpers/is-local-url.js.map +0 -7
  63. package/dist/helpers/is-valid-url.d.ts +0 -12
  64. package/dist/helpers/is-valid-url.d.ts.map +0 -1
  65. package/dist/helpers/is-valid-url.js +0 -11
  66. package/dist/helpers/is-valid-url.js.map +0 -7
  67. package/dist/helpers/iterate-title.d.ts +0 -5
  68. package/dist/helpers/iterate-title.d.ts.map +0 -1
  69. package/dist/helpers/iterate-title.js +0 -12
  70. package/dist/helpers/iterate-title.js.map +0 -7
  71. package/dist/helpers/json2xml.d.ts +0 -5
  72. package/dist/helpers/json2xml.d.ts.map +0 -1
  73. package/dist/helpers/json2xml.js +0 -45
  74. package/dist/helpers/json2xml.js.map +0 -7
  75. package/dist/helpers/local-storage.d.ts +0 -16
  76. package/dist/helpers/local-storage.d.ts.map +0 -1
  77. package/dist/helpers/local-storage.js +0 -15
  78. package/dist/helpers/local-storage.js.map +0 -7
  79. package/dist/helpers/make-url-absolute.d.ts +0 -5
  80. package/dist/helpers/make-url-absolute.d.ts.map +0 -1
  81. package/dist/helpers/make-url-absolute.js +0 -13
  82. package/dist/helpers/make-url-absolute.js.map +0 -7
  83. package/dist/helpers/merge-urls.d.ts +0 -15
  84. package/dist/helpers/merge-urls.d.ts.map +0 -1
  85. package/dist/helpers/merge-urls.js +0 -56
  86. package/dist/helpers/merge-urls.js.map +0 -7
  87. package/dist/helpers/object.d.ts +0 -10
  88. package/dist/helpers/object.d.ts.map +0 -1
  89. package/dist/helpers/object.js +0 -15
  90. package/dist/helpers/object.js.map +0 -7
  91. package/dist/helpers/omit-undefined-values.d.ts +0 -7
  92. package/dist/helpers/omit-undefined-values.d.ts.map +0 -1
  93. package/dist/helpers/omit-undefined-values.js +0 -19
  94. package/dist/helpers/omit-undefined-values.js.map +0 -7
  95. package/dist/helpers/regex-helpers.d.ts +0 -10
  96. package/dist/helpers/regex-helpers.d.ts.map +0 -1
  97. package/dist/helpers/regex-helpers.js +0 -13
  98. package/dist/helpers/regex-helpers.js.map +0 -7
  99. package/dist/helpers/replace-variables.d.ts +0 -5
  100. package/dist/helpers/replace-variables.d.ts.map +0 -1
  101. package/dist/helpers/replace-variables.js +0 -15
  102. package/dist/helpers/replace-variables.js.map +0 -7
  103. package/dist/helpers/string.d.ts +0 -15
  104. package/dist/helpers/string.d.ts.map +0 -1
  105. package/dist/helpers/string.js +0 -7
  106. package/dist/helpers/string.js.map +0 -7
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/transforms/import-spec.ts"],
4
- "sourcesContent": ["import { 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 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 { isHttpMethod } from '@/helpers/http-methods'\nimport { isDefined } from '@/helpers/is-defined'\nimport { combineUrlAndPath } from '@/helpers/merge-urls'\nimport { schemaModel } from '@/helpers/schema-model'\nimport {\n type Oauth2FlowPayload,\n type SecurityScheme,\n type SecuritySchemePayload,\n securitySchemeSchema,\n} from '@scalar/types/entities'\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 })\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: OpenAPIV3_1.OperationObject = path[method]\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 // Add list of UIDs to associate security schemes\n // As per the spec if there is operation level security we ignore the top level requirements\n if (operationSecurity?.length) {\n requestPayload.security = operationSecurity.map((s: OpenAPIV3_1.SecurityRequirementObject) => {\n const keys = Object.keys(s)\n\n // Handle the case of {} for optional\n if (keys.length) {\n const [key] = Object.keys(s)\n if (key) {\n return {\n [key]: s[key],\n }\n }\n }\n return s\n })\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 * 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 { baseServerURL }: Pick<ApiReferenceConfiguration, 'baseServerURL'> = {},\n): Server[] {\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 // 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\u2019s 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,cAAc;AACvB,SAA0B,aAAa,MAAM,eAAe;AAQ5D,SAAkD,wBAAwB;AAE1E,SAA8B,gCAAgC;AAC9D,SAA4C,qBAAqB;AACjE,SAAsB,oBAAoB;AAC1C,SAAmB,iBAAiB;AACpC,SAAS,oBAAoB;AAC7B,SAAS,iBAAiB;AAC1B,SAAS,yBAAyB;AAClC,SAAS,mBAAmB;AAC5B;AAAA,EAIE;AAAA,OACK;AAEP,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,QAA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AAK,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;AAKO,SAAS,8BACd,SACA,EAAE,cAAc,IAAsD,CAAC,GAC7D;AACV,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;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,oDAA+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 { 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 })\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 // Add list of UIDs to associate security schemes\n // As per the spec if there is operation level security we ignore the top level requirements\n if (operationSecurity?.length) {\n requestPayload.security = operationSecurity.map((s: OpenAPIV3_1.SecurityRequirementObject) => {\n const keys = Object.keys(s)\n\n // Handle the case of {} for optional\n if (keys.length) {\n const [key] = Object.keys(s)\n if (key) {\n return {\n [key]: s[key],\n }\n }\n }\n return s\n })\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 * 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 { baseServerURL }: Pick<ApiReferenceConfiguration, 'baseServerURL'> = {},\n): Server[] {\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 // 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\u2019s 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,C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;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAKO,SAAS,8BACd,SACA,EAAE,cAAc,IAAsD,CAAC,GAC7D;AACV,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;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,oDAA+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;",
6
6
  "names": ["securityRequirements", "preferredSecurityNames", "selectedSecuritySchemeUids"]
7
7
  }
package/package.json CHANGED
@@ -16,7 +16,7 @@
16
16
  "specification",
17
17
  "yaml"
18
18
  ],
19
- "version": "0.4.1",
19
+ "version": "0.4.3",
20
20
  "engines": {
21
21
  "node": ">=20"
22
22
  },
@@ -93,10 +93,11 @@
93
93
  "type-fest": "^4.20.0",
94
94
  "yaml": "^2.4.5",
95
95
  "zod": "3.24.1",
96
- "@scalar/openapi-types": "0.3.1",
97
- "@scalar/themes": "0.13.1",
98
96
  "@scalar/object-utils": "1.2.1",
99
- "@scalar/types": "0.2.1"
97
+ "@scalar/types": "0.2.2",
98
+ "@scalar/openapi-types": "0.3.2",
99
+ "@scalar/themes": "0.13.2",
100
+ "@scalar/helpers": "0.0.2"
100
101
  },
101
102
  "devDependencies": {
102
103
  "@types/node": "^20.17.10",
@@ -104,9 +105,9 @@
104
105
  "vite": "5.4.19",
105
106
  "vitest": "^1.6.0",
106
107
  "zod-to-ts": "github:amritk/zod-to-ts#build",
107
- "@scalar/build-tooling": "0.2.1",
108
- "@scalar/openapi-parser": "0.13.0",
109
- "@scalar/openapi-types": "0.3.1"
108
+ "@scalar/build-tooling": "0.2.2",
109
+ "@scalar/openapi-parser": "0.15.0",
110
+ "@scalar/openapi-types": "0.3.2"
110
111
  },
111
112
  "scripts": {
112
113
  "build": "scalar-build-esbuild",
@@ -1,7 +0,0 @@
1
- /**
2
- * Simple 32 bit non-secure hash from a string input
3
- *
4
- * @see https://stackoverflow.com/a/7616484/1624255
5
- */
6
- export declare const createHash: (input?: string) => number;
7
- //# sourceMappingURL=create-hash.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"create-hash.d.ts","sourceRoot":"","sources":["../../src/helpers/create-hash.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,UAAU,WAAY,MAAM,KAAG,MAe3C,CAAA"}
@@ -1,18 +0,0 @@
1
- const createHash = (input) => {
2
- let chr = 0;
3
- let hash = 0;
4
- let i = 0;
5
- if (!input?.length) {
6
- return hash;
7
- }
8
- for (i = 0; i < input.length; i++) {
9
- chr = input.charCodeAt(i);
10
- hash = (hash << 5) - hash + chr;
11
- hash |= 0;
12
- }
13
- return hash;
14
- };
15
- export {
16
- createHash
17
- };
18
- //# sourceMappingURL=create-hash.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/helpers/create-hash.ts"],
4
- "sourcesContent": ["/**\n * Simple 32 bit non-secure hash from a string input\n *\n * @see https://stackoverflow.com/a/7616484/1624255\n */\nexport const createHash = (input?: string): number => {\n let chr = 0\n let hash = 0\n let i = 0\n\n if (!input?.length) {\n return hash\n }\n\n for (i = 0; i < input.length; i++) {\n chr = input.charCodeAt(i)\n hash = (hash << 5) - hash + chr\n hash |= 0 // Convert to 32bit integer\n }\n return hash\n}\n"],
5
- "mappings": "AAKO,MAAM,aAAa,CAAC,UAA2B;AACpD,MAAI,MAAM;AACV,MAAI,OAAO;AACX,MAAI,IAAI;AAER,MAAI,CAAC,OAAO,QAAQ;AAClB,WAAO;AAAA,EACT;AAEA,OAAK,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AACjC,UAAM,MAAM,WAAW,CAAC;AACxB,YAAQ,QAAQ,KAAK,OAAO;AAC5B,YAAQ;AAAA,EACV;AACA,SAAO;AACT;",
6
- "names": []
7
- }
@@ -1,3 +0,0 @@
1
- /** Ensure URL has a protocol prefix */
2
- export declare function ensureProtocol(url: string): string;
3
- //# sourceMappingURL=ensure-protocol.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ensure-protocol.d.ts","sourceRoot":"","sources":["../../src/helpers/ensure-protocol.ts"],"names":[],"mappings":"AAEA,uCAAuC;AACvC,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAOlD"}
@@ -1,11 +0,0 @@
1
- import { REGEX } from "./regex-helpers.js";
2
- function ensureProtocol(url) {
3
- if (REGEX.PROTOCOL.test(url)) {
4
- return url;
5
- }
6
- return `http://${url.replace(/^\//, "")}`;
7
- }
8
- export {
9
- ensureProtocol
10
- };
11
- //# sourceMappingURL=ensure-protocol.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/helpers/ensure-protocol.ts"],
4
- "sourcesContent": ["import { REGEX } from './regex-helpers'\n\n/** Ensure URL has a protocol prefix */\nexport function ensureProtocol(url: string): string {\n if (REGEX.PROTOCOL.test(url)) {\n return url\n }\n\n // Default to http if no protocol is specified\n return `http://${url.replace(/^\\//, '')}`\n}\n"],
5
- "mappings": "AAAA,SAAS,aAAa;AAGf,SAAS,eAAe,KAAqB;AAClD,MAAI,MAAM,SAAS,KAAK,GAAG,GAAG;AAC5B,WAAO;AAAA,EACT;AAGA,SAAO,UAAU,IAAI,QAAQ,OAAO,EAAE,CAAC;AACzC;",
6
- "names": []
7
- }
@@ -1,5 +0,0 @@
1
- /**
2
- * Find all strings wrapped in {} or {{}} in value.
3
- */
4
- export declare const findVariables: (value: string) => string[];
5
- //# sourceMappingURL=find-variables.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"find-variables.d.ts","sourceRoot":"","sources":["../../src/helpers/find-variables.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,aAAa,UAAW,MAAM,aAE1C,CAAA"}
@@ -1,8 +0,0 @@
1
- import { REGEX } from "./regex-helpers.js";
2
- const findVariables = (value) => {
3
- return [...value.matchAll(REGEX.PATH), ...value.matchAll(REGEX.VARIABLES)].map((match) => match[1]?.trim()) || [];
4
- };
5
- export {
6
- findVariables
7
- };
8
- //# sourceMappingURL=find-variables.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/helpers/find-variables.ts"],
4
- "sourcesContent": ["import { REGEX } from './regex-helpers'\n\n/**\n * Find all strings wrapped in {} or {{}} in value.\n */\nexport const findVariables = (value: string) => {\n return [...value.matchAll(REGEX.PATH), ...value.matchAll(REGEX.VARIABLES)].map((match) => match[1]?.trim()) || []\n}\n"],
5
- "mappings": "AAAA,SAAS,aAAa;AAKf,MAAM,gBAAgB,CAAC,UAAkB;AAC9C,SAAO,CAAC,GAAG,MAAM,SAAS,MAAM,IAAI,GAAG,GAAG,MAAM,SAAS,MAAM,SAAS,CAAC,EAAE,IAAI,CAAC,UAAU,MAAM,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC;AAClH;",
6
- "names": []
7
- }
@@ -1,29 +0,0 @@
1
- import { type RequestMethod } from '../entities/spec/requests.js';
2
- /**
3
- * HTTP methods in a specific order
4
- * Do not change the order
5
- */
6
- export declare const REQUEST_METHODS: {
7
- [x in RequestMethod]: {
8
- short: string;
9
- color: string;
10
- backgroundColor: string;
11
- };
12
- };
13
- /** HTTP Methods which can have a body */
14
- declare const BODY_METHODS: readonly ["post", "put", "patch", "delete"];
15
- type BodyMethod = (typeof BODY_METHODS)[number];
16
- /** Makes a check to see if this method CAN have a body */
17
- export declare const canMethodHaveBody: (method: RequestMethod) => method is BodyMethod;
18
- /**
19
- * Accepts an HTTP Method name and returns some properties for the tag
20
- */
21
- export declare const getHttpMethodInfo: (methodName: string) => {
22
- short: string;
23
- color: string;
24
- backgroundColor: string;
25
- };
26
- /** Type guard which takes in a string and returns true if it is in fact an HTTPMethod */
27
- export declare const isHttpMethod: (method?: string | undefined) => method is RequestMethod;
28
- export {};
29
- //# sourceMappingURL=http-methods.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"http-methods.d.ts","sourceRoot":"","sources":["../../src/helpers/http-methods.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAkB,MAAM,0BAA0B,CAAA;AAE7E;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE;KAC3B,CAAC,IAAI,aAAa,GAAG;QACpB,KAAK,EAAE,MAAM,CAAA;QACb,KAAK,EAAE,MAAM,CAAA;QACb,eAAe,EAAE,MAAM,CAAA;KACxB;CA+CO,CAAA;AAEV,yCAAyC;AACzC,QAAA,MAAM,YAAY,6CAA8C,CAAA;AAChE,KAAK,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAA;AAE/C,0DAA0D;AAC1D,eAAO,MAAM,iBAAiB,WAAY,aAAa,KAAG,MAAM,IAAI,UACvB,CAAA;AAE7C;;GAEG;AACH,eAAO,MAAM,iBAAiB,eAAgB,MAAM;WA/DzC,MAAM;WACN,MAAM;qBACI,MAAM;CAsE1B,CAAA;AAED,yFAAyF;AACzF,eAAO,MAAM,YAAY,YAAa,MAAM,GAAG,SAAS,KAAG,MAAM,IAAI,aACF,CAAA"}
@@ -1,66 +0,0 @@
1
- import { requestMethods } from "../entities/spec/requests.js";
2
- const REQUEST_METHODS = {
3
- get: {
4
- short: "GET",
5
- color: "text-blue",
6
- backgroundColor: "bg-blue/10"
7
- },
8
- post: {
9
- short: "POST",
10
- color: "text-green",
11
- backgroundColor: "bg-green/10"
12
- },
13
- put: {
14
- short: "PUT",
15
- color: "text-orange",
16
- backgroundColor: "bg-orange/10"
17
- },
18
- patch: {
19
- short: "PATCH",
20
- color: "text-yellow",
21
- backgroundColor: "bg-yellow/10"
22
- },
23
- delete: {
24
- short: "DEL",
25
- color: "text-red",
26
- backgroundColor: "bg-red/10"
27
- },
28
- options: {
29
- short: "OPTS",
30
- color: "text-purple",
31
- backgroundColor: "bg-purple/10"
32
- },
33
- head: {
34
- short: "HEAD",
35
- color: "text-scalar-c-2",
36
- backgroundColor: "bg-c-2/10"
37
- },
38
- connect: {
39
- short: "CONN",
40
- color: "text-c-2",
41
- backgroundColor: "bg-c-2/10"
42
- },
43
- trace: {
44
- short: "TRACE",
45
- color: "text-c-2",
46
- backgroundColor: "bg-c-2/10"
47
- }
48
- };
49
- const BODY_METHODS = ["post", "put", "patch", "delete"];
50
- const canMethodHaveBody = (method) => BODY_METHODS.includes(method);
51
- const getHttpMethodInfo = (methodName) => {
52
- const normalizedMethod = methodName.trim().toLowerCase();
53
- return REQUEST_METHODS[normalizedMethod] ?? {
54
- short: normalizedMethod,
55
- color: "text-c-2",
56
- backgroundColor: "bg-c-2"
57
- };
58
- };
59
- const isHttpMethod = (method) => method ? requestMethods.includes(method) : false;
60
- export {
61
- REQUEST_METHODS,
62
- canMethodHaveBody,
63
- getHttpMethodInfo,
64
- isHttpMethod
65
- };
66
- //# sourceMappingURL=http-methods.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/helpers/http-methods.ts"],
4
- "sourcesContent": ["import { type RequestMethod, requestMethods } from '@/entities/spec/requests'\n\n/**\n * HTTP methods in a specific order\n * Do not change the order\n */\nexport const REQUEST_METHODS: {\n [x in RequestMethod]: {\n short: string\n color: string\n backgroundColor: string\n }\n} = {\n get: {\n short: 'GET',\n color: 'text-blue',\n backgroundColor: 'bg-blue/10',\n },\n post: {\n short: 'POST',\n color: 'text-green',\n backgroundColor: 'bg-green/10',\n },\n put: {\n short: 'PUT',\n color: 'text-orange',\n backgroundColor: 'bg-orange/10',\n },\n patch: {\n short: 'PATCH',\n color: 'text-yellow',\n backgroundColor: 'bg-yellow/10',\n },\n delete: {\n short: 'DEL',\n color: 'text-red',\n backgroundColor: 'bg-red/10',\n },\n options: {\n short: 'OPTS',\n color: 'text-purple',\n backgroundColor: 'bg-purple/10',\n },\n head: {\n short: 'HEAD',\n color: 'text-scalar-c-2',\n backgroundColor: 'bg-c-2/10',\n },\n connect: {\n short: 'CONN',\n color: 'text-c-2',\n backgroundColor: 'bg-c-2/10',\n },\n trace: {\n short: 'TRACE',\n color: 'text-c-2',\n backgroundColor: 'bg-c-2/10',\n },\n} as const\n\n/** HTTP Methods which can have a body */\nconst BODY_METHODS = ['post', 'put', 'patch', 'delete'] as const\ntype BodyMethod = (typeof BODY_METHODS)[number]\n\n/** Makes a check to see if this method CAN have a body */\nexport const canMethodHaveBody = (method: RequestMethod): method is BodyMethod =>\n BODY_METHODS.includes(method as BodyMethod)\n\n/**\n * Accepts an HTTP Method name and returns some properties for the tag\n */\nexport const getHttpMethodInfo = (methodName: string) => {\n const normalizedMethod = methodName.trim().toLowerCase()\n return (\n REQUEST_METHODS[normalizedMethod as RequestMethod] ?? {\n short: normalizedMethod,\n color: 'text-c-2',\n backgroundColor: 'bg-c-2',\n }\n )\n}\n\n/** Type guard which takes in a string and returns true if it is in fact an HTTPMethod */\nexport const isHttpMethod = (method?: string | undefined): method is RequestMethod =>\n method ? requestMethods.includes(method as RequestMethod) : false\n"],
5
- "mappings": "AAAA,SAA6B,sBAAsB;AAM5C,MAAM,kBAMT;AAAA,EACF,KAAK;AAAA,IACH,OAAO;AAAA,IACP,OAAO;AAAA,IACP,iBAAiB;AAAA,EACnB;AAAA,EACA,MAAM;AAAA,IACJ,OAAO;AAAA,IACP,OAAO;AAAA,IACP,iBAAiB;AAAA,EACnB;AAAA,EACA,KAAK;AAAA,IACH,OAAO;AAAA,IACP,OAAO;AAAA,IACP,iBAAiB;AAAA,EACnB;AAAA,EACA,OAAO;AAAA,IACL,OAAO;AAAA,IACP,OAAO;AAAA,IACP,iBAAiB;AAAA,EACnB;AAAA,EACA,QAAQ;AAAA,IACN,OAAO;AAAA,IACP,OAAO;AAAA,IACP,iBAAiB;AAAA,EACnB;AAAA,EACA,SAAS;AAAA,IACP,OAAO;AAAA,IACP,OAAO;AAAA,IACP,iBAAiB;AAAA,EACnB;AAAA,EACA,MAAM;AAAA,IACJ,OAAO;AAAA,IACP,OAAO;AAAA,IACP,iBAAiB;AAAA,EACnB;AAAA,EACA,SAAS;AAAA,IACP,OAAO;AAAA,IACP,OAAO;AAAA,IACP,iBAAiB;AAAA,EACnB;AAAA,EACA,OAAO;AAAA,IACL,OAAO;AAAA,IACP,OAAO;AAAA,IACP,iBAAiB;AAAA,EACnB;AACF;AAGA,MAAM,eAAe,CAAC,QAAQ,OAAO,SAAS,QAAQ;AAI/C,MAAM,oBAAoB,CAAC,WAChC,aAAa,SAAS,MAAoB;AAKrC,MAAM,oBAAoB,CAAC,eAAuB;AACvD,QAAM,mBAAmB,WAAW,KAAK,EAAE,YAAY;AACvD,SACE,gBAAgB,gBAAiC,KAAK;AAAA,IACpD,OAAO;AAAA,IACP,OAAO;AAAA,IACP,iBAAiB;AAAA,EACnB;AAEJ;AAGO,MAAM,eAAe,CAAC,WAC3B,SAAS,eAAe,SAAS,MAAuB,IAAI;",
6
- "names": []
7
- }
@@ -1,8 +0,0 @@
1
- export type HttpStatusCode = {
2
- name: string;
3
- url: string;
4
- color: string;
5
- };
6
- export type HttpStatusCodes = Record<string, HttpStatusCode>;
7
- export declare const httpStatusCodes: HttpStatusCodes;
8
- //# sourceMappingURL=http-status-codes.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"http-status-codes.d.ts","sourceRoot":"","sources":["../../src/helpers/http-status-codes.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;AAE5D,eAAO,MAAM,eAAe,EAAE,eA4T7B,CAAA"}