@scalar/workspace-store 0.18.1 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/client.d.ts.map +1 -1
  3. package/dist/client.js +1 -1
  4. package/dist/client.js.map +2 -2
  5. package/dist/events/definitions/auth.d.ts +77 -14
  6. package/dist/events/definitions/auth.d.ts.map +1 -1
  7. package/dist/events/definitions/document.d.ts +5 -1
  8. package/dist/events/definitions/document.d.ts.map +1 -1
  9. package/dist/events/definitions/index.d.ts +1 -2
  10. package/dist/events/definitions/index.d.ts.map +1 -1
  11. package/dist/events/definitions/operation.d.ts +200 -0
  12. package/dist/events/definitions/operation.d.ts.map +1 -1
  13. package/dist/events/definitions/server.d.ts +20 -28
  14. package/dist/events/definitions/server.d.ts.map +1 -1
  15. package/dist/events/definitions/ui.d.ts +5 -0
  16. package/dist/events/definitions/ui.d.ts.map +1 -1
  17. package/dist/events/index.d.ts +2 -2
  18. package/dist/events/index.d.ts.map +1 -1
  19. package/dist/events/index.js.map +2 -2
  20. package/dist/helpers/generate-unique-value.d.ts +40 -0
  21. package/dist/helpers/generate-unique-value.d.ts.map +1 -0
  22. package/dist/helpers/generate-unique-value.js +42 -0
  23. package/dist/helpers/generate-unique-value.js.map +7 -0
  24. package/dist/helpers/overrides-proxy.d.ts.map +1 -1
  25. package/dist/helpers/overrides-proxy.js +1 -1
  26. package/dist/helpers/overrides-proxy.js.map +2 -2
  27. package/dist/helpers/unpack-proxy.d.ts +1 -1
  28. package/dist/helpers/unpack-proxy.d.ts.map +1 -1
  29. package/dist/helpers/unpack-proxy.js.map +2 -2
  30. package/dist/mutators/auth.d.ts +147 -0
  31. package/dist/mutators/auth.d.ts.map +1 -0
  32. package/dist/mutators/auth.js +156 -0
  33. package/dist/mutators/auth.js.map +7 -0
  34. package/dist/mutators/document.d.ts +6 -0
  35. package/dist/mutators/document.d.ts.map +1 -0
  36. package/dist/mutators/document.js +10 -0
  37. package/dist/mutators/document.js.map +7 -0
  38. package/dist/mutators/index.d.ts +12 -7
  39. package/dist/mutators/index.d.ts.map +1 -1
  40. package/dist/mutators/index.js +74 -1
  41. package/dist/mutators/index.js.map +3 -3
  42. package/dist/mutators/operation.d.ts +313 -0
  43. package/dist/mutators/operation.d.ts.map +1 -0
  44. package/dist/mutators/operation.js +340 -0
  45. package/dist/mutators/operation.js.map +7 -0
  46. package/dist/mutators/server.d.ts +43 -8
  47. package/dist/mutators/server.d.ts.map +1 -1
  48. package/dist/mutators/server.js +112 -20
  49. package/dist/mutators/server.js.map +2 -2
  50. package/dist/navigation/helpers/traverse-document.d.ts +1 -0
  51. package/dist/navigation/helpers/traverse-document.d.ts.map +1 -1
  52. package/dist/navigation/helpers/traverse-document.js +2 -1
  53. package/dist/navigation/helpers/traverse-document.js.map +2 -2
  54. package/dist/plugins/client/persistence.d.ts +2 -1
  55. package/dist/plugins/client/persistence.d.ts.map +1 -1
  56. package/dist/plugins/client/persistence.js +11 -9
  57. package/dist/plugins/client/persistence.js.map +2 -2
  58. package/dist/schemas/extensions/document/x-scalar-document-security.d.ts +13 -0
  59. package/dist/schemas/extensions/document/x-scalar-document-security.d.ts.map +1 -0
  60. package/dist/schemas/extensions/document/x-scalar-document-security.js +8 -0
  61. package/dist/schemas/extensions/document/x-scalar-document-security.js.map +7 -0
  62. package/dist/schemas/extensions/operation/x-scalar-operation-identifiers.d.ts +13 -0
  63. package/dist/schemas/extensions/operation/x-scalar-operation-identifiers.d.ts.map +1 -0
  64. package/dist/schemas/extensions/operation/x-scalar-operation-identifiers.js +9 -0
  65. package/dist/schemas/extensions/operation/x-scalar-operation-identifiers.js.map +7 -0
  66. package/dist/schemas/extensions/operation/x-scalar-selected-content-type.d.ts +21 -0
  67. package/dist/schemas/extensions/operation/x-scalar-selected-content-type.d.ts.map +1 -0
  68. package/dist/schemas/extensions/operation/x-scalar-selected-content-type.js +8 -0
  69. package/dist/schemas/extensions/operation/x-scalar-selected-content-type.js.map +7 -0
  70. package/dist/schemas/extensions/security/x-scalar-selected-security.d.ts +17 -0
  71. package/dist/schemas/extensions/security/x-scalar-selected-security.d.ts.map +1 -0
  72. package/dist/schemas/extensions/security/x-scalar-selected-security.js +14 -0
  73. package/dist/schemas/extensions/security/x-scalar-selected-security.js.map +7 -0
  74. package/dist/schemas/extensions/server/x-scalar-selected-server.d.ts +8 -0
  75. package/dist/schemas/extensions/server/x-scalar-selected-server.d.ts.map +1 -0
  76. package/dist/schemas/extensions/server/x-scalar-selected-server.js +8 -0
  77. package/dist/schemas/extensions/server/x-scalar-selected-server.js.map +7 -0
  78. package/dist/schemas/inmemory-workspace.d.ts +44 -8
  79. package/dist/schemas/inmemory-workspace.d.ts.map +1 -1
  80. package/dist/schemas/navigation.d.ts +5 -0
  81. package/dist/schemas/navigation.d.ts.map +1 -1
  82. package/dist/schemas/navigation.js +1 -0
  83. package/dist/schemas/navigation.js.map +2 -2
  84. package/dist/schemas/reference-config/index.d.ts +22 -4
  85. package/dist/schemas/reference-config/index.d.ts.map +1 -1
  86. package/dist/schemas/reference-config/settings.d.ts +22 -4
  87. package/dist/schemas/reference-config/settings.d.ts.map +1 -1
  88. package/dist/schemas/v3.1/strict/openapi-document.d.ts +752 -138
  89. package/dist/schemas/v3.1/strict/openapi-document.d.ts.map +1 -1
  90. package/dist/schemas/v3.1/strict/openapi-document.js +12 -1
  91. package/dist/schemas/v3.1/strict/openapi-document.js.map +2 -2
  92. package/dist/schemas/v3.1/strict/operation.d.ts +10 -6
  93. package/dist/schemas/v3.1/strict/operation.d.ts.map +1 -1
  94. package/dist/schemas/v3.1/strict/operation.js +9 -7
  95. package/dist/schemas/v3.1/strict/operation.js.map +2 -2
  96. package/dist/schemas/v3.1/strict/request-body.d.ts +6 -3
  97. package/dist/schemas/v3.1/strict/request-body.d.ts.map +1 -1
  98. package/dist/schemas/v3.1/strict/request-body.js +15 -8
  99. package/dist/schemas/v3.1/strict/request-body.js.map +2 -2
  100. package/dist/schemas/workspace-specification/config.d.ts +22 -4
  101. package/dist/schemas/workspace-specification/config.d.ts.map +1 -1
  102. package/dist/schemas/workspace-specification/index.d.ts +22 -4
  103. package/dist/schemas/workspace-specification/index.d.ts.map +1 -1
  104. package/dist/schemas/workspace.d.ts +154 -28
  105. package/dist/schemas/workspace.d.ts.map +1 -1
  106. package/package.json +5 -5
  107. package/dist/helpers/debounce.d.ts +0 -28
  108. package/dist/helpers/debounce.d.ts.map +0 -1
  109. package/dist/helpers/debounce.js +0 -31
  110. package/dist/helpers/debounce.js.map +0 -7
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/mutators/operation.ts"],
4
+ "sourcesContent": ["import type { HttpMethod } from '@scalar/helpers/http/http-methods'\n\nimport { getResolvedRef } from '@/helpers/get-resolved-ref'\nimport type { WorkspaceDocument } from '@/schemas'\n\n/**\n * Describes the minimal identity for an operation in the workspace document.\n * It is used by mutators to find the target operation under `paths`.\n *\n * Example:\n * ```ts\n * const meta: OperationMeta = { method: 'get', path: '/users/{id}' }\n * ```\n */\nexport type OperationMeta = {\n method: HttpMethod\n path: string\n}\n\n/**\n * Extends {@link OperationMeta} with an `exampleKey` to address a specific\n * example variant (e.g. per environment or scenario) for request/parameters.\n *\n * Example:\n * ```ts\n * const meta: OperationExampleMeta = {\n * method: 'post',\n * path: '/upload',\n * exampleKey: 'default',\n * }\n * ```\n */\nexport type OperationExampleMeta = OperationMeta & {\n exampleKey: string\n}\n\n/** ------------------------------------------------------------------------------------------------\n * Operation Draft Mutators\n * ------------------------------------------------------------------------------------------------ */\n\n/**\n * Updates the `summary` of an operation.\n * Safely no-ops if the document or operation does not exist.\n *\n * Example:\n * ```ts\n * updateOperationSummary({\n * document,\n * meta: { method: 'get', path: '/users/{id}' },\n * payload: { summary: 'Get a single user' },\n * })\n * ```\n */\nexport const updateOperationSummary = ({\n document,\n meta,\n payload: { summary },\n}: {\n document: WorkspaceDocument | null\n payload: { summary: string }\n meta: OperationMeta\n}) => {\n if (!document) {\n return\n }\n\n const operation = getResolvedRef(document.paths?.[meta.path]?.[meta.method as HttpMethod])\n\n if (!operation) {\n return\n }\n\n operation.summary = summary\n}\n\n/**\n * Stores the chosen HTTP method under `x-scalar-method` on the operation.\n * This does not move the operation to a different method slot under `paths`;\n * it records the desired method as an extension for downstream consumers.\n * Safely no-ops if the document or operation does not exist.\n *\n * Example:\n * ```ts\n * updateOperationMethodDraft({\n * document,\n * meta: { method: 'get', path: '/users' },\n * payload: { method: 'post' },\n * })\n * ```\n */\nexport const updateOperationMethodDraft = ({\n document,\n meta,\n payload: { method },\n}: {\n document: WorkspaceDocument | null\n payload: { method: HttpMethod }\n meta: OperationMeta\n}) => {\n if (!document) {\n return\n }\n\n const operation = getResolvedRef(document.paths?.[meta.path]?.[meta.method])\n\n if (!operation) {\n return\n }\n\n operation['x-scalar-method'] = method\n}\n\n/**\n * Records a normalized path for the operation under `x-scalar-path`, and\n * synchronizes path parameters in `operation.parameters` with the placeholders\n * present in the provided `path` (e.g. `/users/{id}`). Existing non-path\n * parameters are preserved.\n * Safely no-ops if the document or operation does not exist.\n *\n * Example:\n * ```ts\n * updateOperationPathDraft({\n * document,\n * meta: { method: 'get', path: '/users/{id}' },\n * payload: { path: '/users/{id}' },\n * })\n * ```\n */\nexport const updateOperationPathDraft = ({\n document,\n meta,\n payload: { path },\n}: {\n document: WorkspaceDocument | null\n payload: { path: string }\n meta: OperationMeta\n}) => {\n if (!document) {\n return\n }\n\n const operation = getResolvedRef(document.paths?.[meta.path]?.[meta.method])\n\n if (!operation) {\n return\n }\n\n operation['x-scalar-path'] = path\n\n // Extract the path variables from the path\n const pathVariables = Array.from(path.matchAll(/{([^\\/}]+)}/g), (m) => m[1])\n\n // now we need to update the operation path variables\n const pathVariablesWithoutPathParameters = operation.parameters?.filter((it) => getResolvedRef(it).in !== 'path')\n\n operation.parameters = [\n ...(pathVariablesWithoutPathParameters ?? []),\n ...pathVariables.map((it) => ({\n name: it ?? '',\n in: 'path' as const,\n required: true,\n })),\n ]\n}\n\n/** ------------------------------------------------------------------------------------------------\n * Operation Parameters Mutators\n * ------------------------------------------------------------------------------------------------ */\n\n/**\n * Adds a parameter to the operation with an example value tracked by `exampleKey`.\n * For `path` parameters `required` is set to true automatically.\n * Safely no-ops if the document or operation does not exist.\n *\n * Example:\n * ```ts\n * addOperationParameter({\n * document,\n * type: 'query',\n * meta: { method: 'get', path: '/search', exampleKey: 'default' },\n * payload: { key: 'q', value: 'john', isEnabled: true },\n * })\n * ```\n */\nexport const addOperationParameter = ({\n document,\n meta,\n payload,\n type,\n}: {\n document: WorkspaceDocument | null\n type: 'header' | 'path' | 'query' | 'cookie'\n payload: {\n key: string\n value: string\n isEnabled: boolean\n }\n meta: OperationExampleMeta\n}) => {\n if (!document) {\n return\n }\n\n const operation = getResolvedRef(document.paths?.[meta.path]?.[meta.method])\n\n // Don't proceed if operation doesn't exist\n if (!operation) {\n return\n }\n\n // Initialize parameters array if it doesn't exist\n if (!operation.parameters) {\n operation.parameters = []\n }\n\n // Add the new parameter\n operation.parameters.push({\n name: payload.key,\n in: type,\n required: type === 'path' ? true : false,\n examples: {\n [meta.exampleKey]: {\n value: payload.value,\n 'x-disabled': !payload.isEnabled,\n },\n },\n })\n}\n\n/**\n * Updates an existing parameter of a given `type` by its index within that\n * type subset (e.g. the N-th query parameter). Supports updating name, value,\n * and enabled state for the targeted example.\n * Safely no-ops if the document, operation, or parameter does not exist.\n *\n * Example:\n * ```ts\n * updateOperationParameter({\n * document,\n * type: 'query',\n * index: 0,\n * meta: { method: 'get', path: '/search', exampleKey: 'default' },\n * payload: { value: 'alice', isEnabled: true },\n * })\n * ```\n */\nexport const updateOperationParameter = ({\n document,\n meta,\n type,\n payload,\n index,\n}: {\n document: WorkspaceDocument | null\n type: 'header' | 'path' | 'query' | 'cookie'\n index: number\n payload: Partial<{\n key: string\n value: string\n isEnabled: boolean\n }>\n meta: OperationExampleMeta\n}) => {\n if (!document) {\n return\n }\n\n const operation = getResolvedRef(document.paths?.[meta.path]?.[meta.method])\n\n // Don't proceed if operation doesn't exist\n if (!operation) {\n return\n }\n\n // Get all resolved parameters of the specified type\n // The passed index corresponds to this filtered list\n const resolvedParameters = operation.parameters?.map((it) => getResolvedRef(it)).filter((it) => it.in === type) ?? []\n const parameter = resolvedParameters[index]\n\n // Don't proceed if parameter doesn't exist\n if (!parameter) {\n return\n }\n\n parameter.name = payload.key ?? parameter.name ?? ''\n\n // TODO: handle content-type parameters\n if ('examples' in parameter) {\n if (!parameter.examples) {\n parameter.examples = {}\n }\n\n const example = getResolvedRef(parameter.examples[meta.exampleKey])\n\n if (!example) {\n return\n }\n\n example.value = payload.value ?? example?.value ?? ''\n example['x-disabled'] = payload.isEnabled === undefined ? example['x-disabled'] : !payload.isEnabled\n }\n}\n\n/**\n * Removes a parameter from the operation by resolving its position within\n * the filtered list of parameters of the specified `type`.\n * Safely no-ops if the document, operation, or parameter does not exist.\n *\n * Example:\n * ```ts\n * deleteOperationParameter({\n * document,\n * type: 'header',\n * index: 1,\n * meta: { method: 'get', path: '/users', exampleKey: 'default' },\n * })\n * ```\n */\nexport const deleteOperationParameter = ({\n document,\n meta,\n index,\n type,\n}: {\n document: WorkspaceDocument | null\n type: 'header' | 'path' | 'query' | 'cookie'\n index: number\n meta: OperationExampleMeta\n}) => {\n if (!document) {\n return\n }\n\n const operation = getResolvedRef(document.paths?.[meta.path]?.[meta.method])\n\n // Don't proceed if operation doesn't exist\n if (!operation) {\n return\n }\n\n // Translate the index from the filtered list to the actual parameters array\n const resolvedParameters = operation.parameters?.map((it) => getResolvedRef(it)).filter((it) => it.in === type) ?? []\n const parameter = resolvedParameters[index]\n\n // Don't proceed if parameter doesn't exist\n if (!parameter) {\n return\n }\n\n const actualIndex = operation.parameters?.findIndex((it) => getResolvedRef(it) === parameter) as number\n\n // Remove the parameter from the operation\n operation.parameters?.splice(actualIndex, 1)\n}\n\n/**\n * Deletes all parameters of a given `type` from the operation.\n * Safely no-ops if the document or operation does not exist.\n *\n * Example:\n * ```ts\n * deleteAllOperationParameters({\n * document,\n * type: 'cookie',\n * meta: { method: 'get', path: '/users' },\n * })\n * ```\n */\nexport const deleteAllOperationParameters = ({\n document,\n meta,\n type,\n}: {\n document: WorkspaceDocument | null\n type: 'header' | 'path' | 'query' | 'cookie'\n meta: OperationMeta\n}) => {\n if (!document) {\n return\n }\n\n const operation = getResolvedRef(document.paths?.[meta.path]?.[meta.method])\n\n // Don't proceed if operation doesn't exist\n if (!operation) {\n return\n }\n\n // Filter out parameters of the specified type\n operation.parameters = operation.parameters?.filter((it) => getResolvedRef(it).in !== type) ?? []\n}\n\n/** ------------------------------------------------------------------------------------------------\n * Operation Request Body Mutators\n * ------------------------------------------------------------------------------------------------ */\n\n/**\n * Sets the selected request-body content type for the current `exampleKey`.\n * This stores the selection under `x-scalar-selected-content-type` on the\n * resolved requestBody. Safely no-ops if the document or operation does not exist.\n *\n * Example:\n * ```ts\n * updateOperationRequestBodyContentType({\n * document,\n * meta: { method: 'post', path: '/upload', exampleKey: 'default' },\n * payload: { contentType: 'multipart/form-data' },\n * })\n * ```\n */\nexport const updateOperationRequestBodyContentType = ({\n document,\n meta,\n payload,\n}: {\n document: WorkspaceDocument | null\n payload: {\n contentType: string\n }\n meta: OperationExampleMeta\n}) => {\n if (!document) {\n return\n }\n\n const operation = getResolvedRef(document.paths?.[meta.path]?.[meta.method])\n\n // Don't proceed if operation doesn't exist\n if (!operation) {\n return\n }\n\n let requestBody = getResolvedRef(operation.requestBody)\n\n if (!requestBody) {\n operation.requestBody = {\n content: {},\n }\n requestBody = getResolvedRef(operation.requestBody)\n }\n\n if (!requestBody!['x-scalar-selected-content-type']) {\n requestBody!['x-scalar-selected-content-type'] = {}\n }\n\n requestBody!['x-scalar-selected-content-type'][meta.exampleKey] = payload.contentType\n}\n\n/**\n * Creates or updates a concrete example value for a specific request-body\n * `contentType` and `exampleKey`. Safely no-ops if the document or operation\n * does not exist.\n *\n * Example:\n * ```ts\n * updateOperationRequestBodyExample({\n * document,\n * contentType: 'application/json',\n * meta: { method: 'post', path: '/users', exampleKey: 'default' },\n * payload: { value: JSON.stringify({ name: 'Ada' }) },\n * })\n * ```\n */\nexport const updateOperationRequestBodyExample = ({\n document,\n meta,\n payload,\n contentType,\n}: {\n document: WorkspaceDocument | null\n contentType: string\n payload: {\n value: string | File | undefined\n }\n meta: OperationExampleMeta\n}) => {\n if (!document) {\n return\n }\n\n const operation = getResolvedRef(document.paths?.[meta.path]?.[meta.method])\n\n // Don't proceed if operation doesn't exist\n if (!operation) {\n return\n }\n\n let requestBody = getResolvedRef(operation.requestBody)\n\n if (!requestBody) {\n operation.requestBody = {\n content: {},\n }\n requestBody = getResolvedRef(operation.requestBody)\n }\n\n if (!requestBody!.content[contentType]) {\n requestBody!.content[contentType] = {\n examples: {},\n }\n }\n\n // Ensure examples object exists and get a resolved reference\n const mediaType = requestBody!.content[contentType]!\n mediaType.examples ??= {}\n const examples = getResolvedRef(mediaType.examples)!\n\n const example = getResolvedRef(examples[meta.exampleKey])\n\n if (!example) {\n examples[meta.exampleKey] = {\n value: payload.value,\n }\n return\n }\n\n example.value = payload.value\n}\n\n/**\n * Appends a form-data row to the request-body example identified by\n * `contentType` and `exampleKey`. Initializes the example as an array when\n * needed. Safely no-ops if the document or operation does not exist.\n *\n * Example:\n * ```ts\n * addOperationRequestBodyFormRow({\n * document,\n * contentType: 'multipart/form-data',\n * meta: { method: 'post', path: '/upload', exampleKey: 'default' },\n * payload: { key: 'file', value: new File(['x'], 'a.txt') },\n * })\n * ```\n */\nexport const addOperationRequestBodyFormRow = ({\n document,\n meta,\n payload,\n contentType,\n}: {\n document: WorkspaceDocument | null\n payload: Partial<{ key: string; value?: string | File }>\n contentType: string\n meta: OperationExampleMeta\n}) => {\n if (!document) {\n return\n }\n\n const operation = getResolvedRef(document.paths?.[meta.path]?.[meta.method])\n\n // Don't proceed if operation doesn't exist\n if (!operation) {\n return\n }\n\n let requestBody = getResolvedRef(operation.requestBody)\n\n if (!requestBody) {\n operation.requestBody = {\n content: {},\n }\n requestBody = getResolvedRef(operation.requestBody)\n }\n\n if (!requestBody!.content[contentType]) {\n requestBody!.content[contentType] = {\n examples: {},\n }\n }\n\n if (!requestBody!.content[contentType]!.examples) {\n requestBody!.content[contentType]!.examples = {}\n }\n\n const examples = getResolvedRef(requestBody!.content[contentType]!.examples)\n\n const example = getResolvedRef(examples[meta.exampleKey])\n\n if (!example || !Array.isArray(example.value)) {\n examples[meta.exampleKey] = {\n value: [\n {\n name: payload.key,\n value: payload.value,\n },\n ],\n }\n return\n }\n\n // Add the new row to the example\n example.value.push({\n name: payload.key ?? '',\n value: payload.value ?? '',\n })\n}\n\n/**\n * Updates a form-data row at a given `index` for the specified example and\n * `contentType`. Setting `payload.value` to `null` clears the value (sets to\n * `undefined`). Safely no-ops if the document, operation, or example does not exist.\n *\n * Example:\n * ```ts\n * updateOperationRequestBodyFormRow({\n * document,\n * index: 0,\n * contentType: 'multipart/form-data',\n * meta: { method: 'post', path: '/upload', exampleKey: 'default' },\n * payload: { key: 'description', value: 'Profile picture' },\n * })\n * ```\n */\nexport const updateOperationRequestBodyFormRow = ({\n document,\n meta,\n index,\n payload,\n contentType,\n}: {\n document: WorkspaceDocument | null\n index: number\n payload: Partial<{ key: string; value: string | File | null }>\n contentType: string\n meta: OperationExampleMeta\n}) => {\n if (!document) {\n return\n }\n\n const operation = getResolvedRef(document.paths?.[meta.path]?.[meta.method])\n\n // Don't proceed if operation doesn't exist\n if (!operation) {\n return\n }\n\n let requestBody = getResolvedRef(operation.requestBody)\n\n if (!requestBody) {\n operation.requestBody = {\n content: {},\n }\n requestBody = getResolvedRef(operation.requestBody)\n }\n\n if (!requestBody!.content[contentType]) {\n return\n }\n\n const examples = getResolvedRef(requestBody!.content[contentType]!.examples)\n\n if (!examples) {\n return\n }\n\n const example = getResolvedRef(examples[meta.exampleKey])\n\n if (!example || !Array.isArray(example.value)) {\n return\n }\n\n example.value[index] = {\n name: payload.key ?? example.value[index]?.name ?? '',\n value: payload.value === null ? undefined : (payload.value ?? example.value[index]?.value ?? ''),\n }\n}\n\n/**\n * Deletes a form-data row at a given `index` from the example for the given\n * `contentType`. If the example becomes empty, the example entry is removed.\n * Safely no-ops if the document, operation, example, or row does not exist.\n *\n * Example:\n * ```ts\n * deleteOperationRequestBodyFormRow({\n * document,\n * index: 0,\n * contentType: 'multipart/form-data',\n * meta: { method: 'post', path: '/upload', exampleKey: 'default' },\n * })\n * ```\n */\nexport const deleteOperationRequestBodyFormRow = ({\n document,\n meta,\n index,\n contentType,\n}: {\n document: WorkspaceDocument | null\n index: number\n contentType: string\n meta: OperationExampleMeta\n}) => {\n if (!document) {\n return\n }\n\n const operation = getResolvedRef(document.paths?.[meta.path]?.[meta.method])\n\n // Don't proceed if operation doesn't exist\n if (!operation) {\n return\n }\n\n const requestBody = getResolvedRef(operation.requestBody)\n\n if (!requestBody) {\n return\n }\n\n if (!requestBody.content[contentType]) {\n return\n }\n\n const examples = getResolvedRef(requestBody.content[contentType]!.examples)\n\n if (!examples) {\n return\n }\n\n const example = getResolvedRef(examples[meta.exampleKey])\n\n if (!example || !Array.isArray(example.value)) {\n return\n }\n\n example.value.splice(index, 1)\n\n if (example.value.length === 0) {\n delete requestBody.content[contentType]!.examples![meta.exampleKey]\n }\n}\n"],
5
+ "mappings": "AAEA,SAAS,sBAAsB;AAmDxB,MAAM,yBAAyB,CAAC;AAAA,EACrC;AAAA,EACA;AAAA,EACA,SAAS,EAAE,QAAQ;AACrB,MAIM;AACJ,MAAI,CAAC,UAAU;AACb;AAAA,EACF;AAEA,QAAM,YAAY,eAAe,SAAS,QAAQ,KAAK,IAAI,IAAI,KAAK,MAAoB,CAAC;AAEzF,MAAI,CAAC,WAAW;AACd;AAAA,EACF;AAEA,YAAU,UAAU;AACtB;AAiBO,MAAM,6BAA6B,CAAC;AAAA,EACzC;AAAA,EACA;AAAA,EACA,SAAS,EAAE,OAAO;AACpB,MAIM;AACJ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,MAAM,KAAK,IAAI;AAAA,IACrB,MAAM,QAAQ,OAAO,QAAQ,MAAM,KAAK,GAAG,QAAQ;AAAA,IACnD,OAAO,QAAQ,UAAU,OAAO,SAAa,QAAQ,SAAS,QAAQ,MAAM,KAAK,GAAG,SAAS;AAAA,EAC/F;AACF;AAiBO,MAAM,oCAAoC,CAAC;AAAA,EAChD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAKM;AACJ,MAAI,CAAC,UAAU;AACb;AAAA,EACF;AAEA,QAAM,YAAY,eAAe,SAAS,QAAQ,KAAK,IAAI,IAAI,KAAK,MAAM,CAAC;AAG3E,MAAI,CAAC,WAAW;AACd;AAAA,EACF;AAEA,QAAM,cAAc,eAAe,UAAU,WAAW;AAExD,MAAI,CAAC,aAAa;AAChB;AAAA,EACF;AAEA,MAAI,CAAC,YAAY,QAAQ,WAAW,GAAG;AACrC;AAAA,EACF;AAEA,QAAM,WAAW,eAAe,YAAY,QAAQ,WAAW,EAAG,QAAQ;AAE1E,MAAI,CAAC,UAAU;AACb;AAAA,EACF;AAEA,QAAM,UAAU,eAAe,SAAS,KAAK,UAAU,CAAC;AAExD,MAAI,CAAC,WAAW,CAAC,MAAM,QAAQ,QAAQ,KAAK,GAAG;AAC7C;AAAA,EACF;AAEA,UAAQ,MAAM,OAAO,OAAO,CAAC;AAE7B,MAAI,QAAQ,MAAM,WAAW,GAAG;AAC9B,WAAO,YAAY,QAAQ,WAAW,EAAG,SAAU,KAAK,UAAU;AAAA,EACpE;AACF;",
6
+ "names": []
7
+ }
@@ -1,12 +1,47 @@
1
- import type { ServerObject } from '../schemas/v3.1/strict/openapi-document.js';
1
+ import type { ServerEvents } from '../events/definitions/server.js';
2
+ import { type ServerObject } from '../schemas/v3.1/strict/openapi-document.js';
3
+ import type { WorkspaceDocument } from '../schemas/workspace.js';
2
4
  /**
3
- * Provides mutator functions for managing an array of OpenAPI ServerObject entries.
5
+ * Adds a new ServerObject to the document.
4
6
  *
5
- * @param target - The array of ServerObject to mutate. If not provided, mutators will be no-ops.
6
- * @returns An object with addServer and deleteServer methods.
7
+ * @param document - The document to add the server to
8
+ * @returns the new server object or undefined if the document is not found
7
9
  */
8
- export declare const serverMutators: (target?: ServerObject[]) => {
9
- addServer: (server: ServerObject) => boolean;
10
- deleteServer: (url: string) => boolean;
11
- };
10
+ export declare const addServer: (document: WorkspaceDocument | null) => ServerObject | undefined;
11
+ /**
12
+ * Updates a ServerObject in the document.
13
+ * When the URL changes, intelligently syncs variables by preserving configurations
14
+ * for renamed variables (detected by position) and existing variables.
15
+ *
16
+ * @param document - The document containing the server to update
17
+ * @param index - The index of the server to update
18
+ * @param server - The partial server object with fields to update
19
+ * @returns the updated server object or undefined if the server is not found
20
+ */
21
+ export declare const updateServer: (document: WorkspaceDocument | null, { index, server }: ServerEvents["server:update:server"]) => ServerObject | undefined;
22
+ /**
23
+ * Deletes a ServerObject at the specified index from the target array.
24
+ *
25
+ * @param document - The document to delete the server from
26
+ * @param index - The index of the server to delete.
27
+ */
28
+ export declare const deleteServer: (document: WorkspaceDocument | null, { index }: ServerEvents["server:delete:server"]) => void;
29
+ /**
30
+ * Updates a server variable for the selected server
31
+ *
32
+ * @param document - The document to update the server variables in
33
+ * @param index - The index of the server to update
34
+ * @param key - The key of the variable to update
35
+ * @param value - The new value of the variable
36
+ * @returns the updated variable or undefined if the variable is not found
37
+ */
38
+ export declare const updateServerVariables: (document: WorkspaceDocument | null, { index, key, value }: ServerEvents["server:update:variables"]) => import("../schemas/v3.1/strict/openapi-document.js").ServerVariableObject | undefined;
39
+ /**
40
+ * Updates the selected server for the document
41
+ *
42
+ * @param document - The document to update the selected server in
43
+ * @param index - The index of the server to update
44
+ * @returns the url of the selected server or undefined if the server is not found
45
+ */
46
+ export declare const updateSelectedServer: (document: WorkspaceDocument | null, { index }: ServerEvents["server:update:selected"]) => string | undefined;
12
47
  //# sourceMappingURL=server.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/mutators/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAA;AAE1E;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GAAI,SAAS,YAAY,EAAE;wBAMzB,YAAY,KAAG,OAAO;wBAatB,MAAM,KAAG,OAAO;CAc5C,CAAA"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/mutators/server.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AAE/D,OAAO,EAAE,KAAK,YAAY,EAAsB,MAAM,wCAAwC,CAAA;AAC9F,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAE5D;;;;;GAKG;AACH,eAAO,MAAM,SAAS,GAAI,UAAU,iBAAiB,GAAG,IAAI,KAAG,YAAY,GAAG,SAc7E,CAAA;AAgFD;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY,GACvB,UAAU,iBAAiB,GAAG,IAAI,EAClC,mBAAmB,YAAY,CAAC,sBAAsB,CAAC,KACtD,YAAY,GAAG,SA+BjB,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAI,UAAU,iBAAiB,GAAG,IAAI,EAAE,WAAW,YAAY,CAAC,sBAAsB,CAAC,SAY/G,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,GAChC,UAAU,iBAAiB,GAAG,IAAI,EAClC,uBAAuB,YAAY,CAAC,yBAAyB,CAAC,sFAkB/D,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,GAC/B,UAAU,iBAAiB,GAAG,IAAI,EAClC,WAAW,YAAY,CAAC,wBAAwB,CAAC,KAChD,MAAM,GAAG,SAUX,CAAA"}
@@ -1,26 +1,118 @@
1
- const serverMutators = (target) => {
2
- const addServer = (server) => {
3
- if (!target) {
4
- return false;
1
+ import { findVariables } from "@scalar/helpers/regex/find-variables";
2
+ import { coerceValue } from "../schemas/typebox-coerce.js";
3
+ import { ServerObjectSchema } from "../schemas/v3.1/strict/openapi-document.js";
4
+ const addServer = (document) => {
5
+ if (!document) {
6
+ return void 0;
7
+ }
8
+ const parsed = coerceValue(ServerObjectSchema, {});
9
+ if (!document.servers) {
10
+ document.servers = [];
11
+ }
12
+ document.servers.push(parsed);
13
+ return parsed;
14
+ };
15
+ const getVariablePositions = (url, variables) => {
16
+ const positions = {};
17
+ for (const varName of variables) {
18
+ const position = url.indexOf(`{${varName}}`);
19
+ if (position !== -1) {
20
+ positions[varName] = position;
21
+ }
22
+ }
23
+ return positions;
24
+ };
25
+ const syncVariablesForUrlChange = (newUrl, oldUrl, existingVariables) => {
26
+ const oldVariables = findVariables(oldUrl, { includePath: true, includeEnv: false }).filter(
27
+ (v) => v !== void 0
28
+ );
29
+ const newVariables = findVariables(newUrl, { includePath: true, includeEnv: false }).filter(
30
+ (v) => v !== void 0
31
+ );
32
+ const oldPositions = getVariablePositions(oldUrl, oldVariables);
33
+ const newPositions = getVariablePositions(newUrl, newVariables);
34
+ const usedOldVariables = /* @__PURE__ */ new Set();
35
+ const syncedVariables = {};
36
+ for (const newVar of newVariables) {
37
+ if (existingVariables[newVar]) {
38
+ syncedVariables[newVar] = existingVariables[newVar];
39
+ usedOldVariables.add(newVar);
40
+ continue;
41
+ }
42
+ const newVarPosition = newPositions[newVar];
43
+ const oldVarAtPosition = oldVariables.find(
44
+ (oldVar) => oldPositions[oldVar] === newVarPosition && !usedOldVariables.has(oldVar)
45
+ );
46
+ if (oldVarAtPosition && existingVariables[oldVarAtPosition]) {
47
+ syncedVariables[newVar] = existingVariables[oldVarAtPosition];
48
+ usedOldVariables.add(oldVarAtPosition);
49
+ continue;
5
50
  }
6
- target.push(server);
7
- return true;
8
- };
9
- const deleteServer = (url) => {
10
- if (!target) {
11
- return false;
51
+ syncedVariables[newVar] = { default: "" };
52
+ }
53
+ return syncedVariables;
54
+ };
55
+ const updateServer = (document, { index, server }) => {
56
+ const oldServer = document?.servers?.[index];
57
+ if (!oldServer) {
58
+ console.error("Server not found at index:", index);
59
+ return void 0;
60
+ }
61
+ const oldUrl = oldServer.url;
62
+ const updatedServer = coerceValue(ServerObjectSchema, { ...oldServer, ...server });
63
+ const hasUrlChanged = oldUrl && oldUrl !== updatedServer.url;
64
+ if (hasUrlChanged) {
65
+ const existingVariables = updatedServer.variables ?? {};
66
+ updatedServer.variables = syncVariablesForUrlChange(updatedServer.url, oldUrl, existingVariables);
67
+ if (document["x-scalar-selected-server"] === oldUrl) {
68
+ document["x-scalar-selected-server"] = updatedServer.url;
12
69
  }
13
- const newTarget = [...target.filter((it) => it.url !== url)];
14
- target.splice(0, target.length);
15
- target.push(...newTarget);
16
- return true;
17
- };
18
- return {
19
- addServer,
20
- deleteServer
21
- };
70
+ }
71
+ if (!document.servers) {
72
+ document.servers = [updatedServer];
73
+ } else {
74
+ document.servers[index] = updatedServer;
75
+ }
76
+ return updatedServer;
77
+ };
78
+ const deleteServer = (document, { index }) => {
79
+ if (!document?.servers) {
80
+ return;
81
+ }
82
+ const url = document.servers[index]?.url;
83
+ document.servers.splice(index, 1);
84
+ if (document["x-scalar-selected-server"] === url) {
85
+ document["x-scalar-selected-server"] = document.servers[0]?.url ?? void 0;
86
+ }
87
+ };
88
+ const updateServerVariables = (document, { index, key, value }) => {
89
+ const variable = document?.servers?.[index]?.variables?.[key];
90
+ if (!variable) {
91
+ console.error("Variable not found", key, index);
92
+ return;
93
+ }
94
+ variable.default = value;
95
+ const url = document?.servers?.[index]?.url;
96
+ if (!url) {
97
+ console.error("URL not found", index);
98
+ return;
99
+ }
100
+ return variable;
101
+ };
102
+ const updateSelectedServer = (document, { index }) => {
103
+ const url = document?.servers?.[index]?.url;
104
+ if (!url) {
105
+ console.error("Server not found", index, document?.servers);
106
+ return;
107
+ }
108
+ document["x-scalar-selected-server"] = url;
109
+ return document["x-scalar-selected-server"];
22
110
  };
23
111
  export {
24
- serverMutators
112
+ addServer,
113
+ deleteServer,
114
+ updateSelectedServer,
115
+ updateServer,
116
+ updateServerVariables
25
117
  };
26
118
  //# sourceMappingURL=server.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/mutators/server.ts"],
4
- "sourcesContent": ["import type { ServerObject } from '@/schemas/v3.1/strict/openapi-document'\n\n/**\n * Provides mutator functions for managing an array of OpenAPI ServerObject entries.\n *\n * @param target - The array of ServerObject to mutate. If not provided, mutators will be no-ops.\n * @returns An object with addServer and deleteServer methods.\n */\nexport const serverMutators = (target?: ServerObject[]) => {\n /**\n * Adds a new ServerObject to the target array.\n * @param server - The ServerObject to add.\n * @returns true if the server was added, false if target is undefined.\n */\n const addServer = (server: ServerObject): boolean => {\n if (!target) {\n return false\n }\n target.push(server)\n return true\n }\n\n /**\n * Deletes a ServerObject at the specified index from the target array.\n * @param index - The index of the server to delete.\n * @returns true if the server was deleted, false if target is undefined.\n */\n const deleteServer = (url: string): boolean => {\n if (!target) {\n return false\n }\n const newTarget = [...target.filter((it) => it.url !== url)]\n target.splice(0, target.length)\n target.push(...newTarget)\n return true\n }\n\n return {\n addServer,\n deleteServer,\n }\n}\n"],
5
- "mappings": "AAQO,MAAM,iBAAiB,CAAC,WAA4B;AAMzD,QAAM,YAAY,CAAC,WAAkC;AACnD,QAAI,CAAC,QAAQ;AACX,aAAO;AAAA,IACT;AACA,WAAO,KAAK,MAAM;AAClB,WAAO;AAAA,EACT;AAOA,QAAM,eAAe,CAAC,QAAyB;AAC7C,QAAI,CAAC,QAAQ;AACX,aAAO;AAAA,IACT;AACA,UAAM,YAAY,CAAC,GAAG,OAAO,OAAO,CAAC,OAAO,GAAG,QAAQ,GAAG,CAAC;AAC3D,WAAO,OAAO,GAAG,OAAO,MAAM;AAC9B,WAAO,KAAK,GAAG,SAAS;AACxB,WAAO;AAAA,EACT;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["import { findVariables } from '@scalar/helpers/regex/find-variables'\n\nimport type { ServerEvents } from '@/events/definitions/server'\nimport { coerceValue } from '@/schemas/typebox-coerce'\nimport { type ServerObject, ServerObjectSchema } from '@/schemas/v3.1/strict/openapi-document'\nimport type { WorkspaceDocument } from '@/schemas/workspace'\n\n/**\n * Adds a new ServerObject to the document.\n *\n * @param document - The document to add the server to\n * @returns the new server object or undefined if the document is not found\n */\nexport const addServer = (document: WorkspaceDocument | null): ServerObject | undefined => {\n if (!document) {\n return undefined\n }\n\n const parsed = coerceValue(ServerObjectSchema, {})\n\n // Initialize the servers array if it doesn't exist\n if (!document.servers) {\n document.servers = []\n }\n\n document.servers.push(parsed)\n return parsed\n}\n\n/**\n * Creates a map of variable names to their character positions in a URL.\n * Used to detect renamed variables by position matching.\n */\nconst getVariablePositions = (url: string, variables: readonly string[]): Record<string, number> => {\n const positions: Record<string, number> = {}\n\n for (const varName of variables) {\n const position = url.indexOf(`{${varName}}`)\n if (position !== -1) {\n positions[varName] = position\n }\n }\n\n return positions\n}\n\ntype VariableConfig = {\n description?: string\n default?: string\n enum?: string[]\n}\n\n/**\n * Syncs server variables when the URL changes.\n *\n * Preserves variable configurations by:\n * 1. Keeping variables with matching names\n * 2. Renaming variables at the same position\n * 3. Creating new variables with empty defaults\n */\nconst syncVariablesForUrlChange = (\n newUrl: string,\n oldUrl: string,\n existingVariables: Record<string, VariableConfig>,\n): Record<string, VariableConfig> => {\n // Filter out undefined values from findVariables results\n const oldVariables = findVariables(oldUrl, { includePath: true, includeEnv: false }).filter(\n (v): v is string => v !== undefined,\n )\n const newVariables = findVariables(newUrl, { includePath: true, includeEnv: false }).filter(\n (v): v is string => v !== undefined,\n )\n\n const oldPositions = getVariablePositions(oldUrl, oldVariables)\n const newPositions = getVariablePositions(newUrl, newVariables)\n\n const usedOldVariables = new Set<string>()\n const syncedVariables: Record<string, VariableConfig> = {}\n\n for (const newVar of newVariables) {\n // Case 1: Variable with same name exists - preserve its config\n if (existingVariables[newVar]) {\n syncedVariables[newVar] = existingVariables[newVar]\n usedOldVariables.add(newVar)\n continue\n }\n\n // Case 2: Check for variable at same position (likely a rename)\n const newVarPosition = newPositions[newVar]\n const oldVarAtPosition = oldVariables.find(\n (oldVar) => oldPositions[oldVar] === newVarPosition && !usedOldVariables.has(oldVar),\n )\n\n if (oldVarAtPosition && existingVariables[oldVarAtPosition]) {\n // Rename: transfer the old variable's config to the new name\n syncedVariables[newVar] = existingVariables[oldVarAtPosition]\n usedOldVariables.add(oldVarAtPosition)\n continue\n }\n\n // Case 3: New variable - create with empty default\n syncedVariables[newVar] = { default: '' }\n }\n\n return syncedVariables\n}\n\n/**\n * Updates a ServerObject in the document.\n * When the URL changes, intelligently syncs variables by preserving configurations\n * for renamed variables (detected by position) and existing variables.\n *\n * @param document - The document containing the server to update\n * @param index - The index of the server to update\n * @param server - The partial server object with fields to update\n * @returns the updated server object or undefined if the server is not found\n */\nexport const updateServer = (\n document: WorkspaceDocument | null,\n { index, server }: ServerEvents['server:update:server'],\n): ServerObject | undefined => {\n const oldServer = document?.servers?.[index]\n\n if (!oldServer) {\n console.error('Server not found at index:', index)\n return undefined\n }\n\n const oldUrl = oldServer.url\n const updatedServer = coerceValue(ServerObjectSchema, { ...oldServer, ...server })\n\n // Sync variables if the URL changed\n const hasUrlChanged = oldUrl && oldUrl !== updatedServer.url\n if (hasUrlChanged) {\n const existingVariables = updatedServer.variables ?? {}\n updatedServer.variables = syncVariablesForUrlChange(updatedServer.url, oldUrl, existingVariables)\n\n // If the selected server is the one being updated, set the selected server to the new server\n if (document['x-scalar-selected-server'] === oldUrl) {\n document['x-scalar-selected-server'] = updatedServer.url\n }\n }\n\n // Ensure servers array exists and update the server at the specified index\n if (!document.servers) {\n document.servers = [updatedServer]\n } else {\n document.servers[index] = updatedServer\n }\n\n return updatedServer\n}\n\n/**\n * Deletes a ServerObject at the specified index from the target array.\n *\n * @param document - The document to delete the server from\n * @param index - The index of the server to delete.\n */\nexport const deleteServer = (document: WorkspaceDocument | null, { index }: ServerEvents['server:delete:server']) => {\n if (!document?.servers) {\n return\n }\n\n const url = document.servers[index]?.url\n document.servers.splice(index, 1)\n\n // If the selected server is the one being deleted, set the selected server to the first one after removal\n if (document['x-scalar-selected-server'] === url) {\n document['x-scalar-selected-server'] = document.servers[0]?.url ?? undefined\n }\n}\n\n/**\n * Updates a server variable for the selected server\n *\n * @param document - The document to update the server variables in\n * @param index - The index of the server to update\n * @param key - The key of the variable to update\n * @param value - The new value of the variable\n * @returns the updated variable or undefined if the variable is not found\n */\nexport const updateServerVariables = (\n document: WorkspaceDocument | null,\n { index, key, value }: ServerEvents['server:update:variables'],\n) => {\n const variable = document?.servers?.[index]?.variables?.[key]\n if (!variable) {\n console.error('Variable not found', key, index)\n return\n }\n\n variable.default = value\n\n // Now we need to make the url reflect the new variable value\n const url = document?.servers?.[index]?.url\n if (!url) {\n console.error('URL not found', index)\n return\n }\n\n return variable\n}\n\n/**\n * Updates the selected server for the document\n *\n * @param document - The document to update the selected server in\n * @param index - The index of the server to update\n * @returns the url of the selected server or undefined if the server is not found\n */\nexport const updateSelectedServer = (\n document: WorkspaceDocument | null,\n { index }: ServerEvents['server:update:selected'],\n): string | undefined => {\n const url = document?.servers?.[index]?.url\n if (!url) {\n console.error('Server not found', index, document?.servers)\n return\n }\n\n // Set it and return the url\n document['x-scalar-selected-server'] = url\n return document['x-scalar-selected-server']\n}\n"],
5
+ "mappings": "AAAA,SAAS,qBAAqB;AAG9B,SAAS,mBAAmB;AAC5B,SAA4B,0BAA0B;AAS/C,MAAM,YAAY,CAAC,aAAiE;AACzF,MAAI,CAAC,UAAU;AACb,WAAO;AAAA,EACT;AAEA,QAAM,SAAS,YAAY,oBAAoB,CAAC,CAAC;AAGjD,MAAI,CAAC,SAAS,SAAS;AACrB,aAAS,UAAU,CAAC;AAAA,EACtB;AAEA,WAAS,QAAQ,KAAK,MAAM;AAC5B,SAAO;AACT;AAMA,MAAM,uBAAuB,CAAC,KAAa,cAAyD;A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AM,MAAM,UAAU,UAAU,KAAK,GAAG;AACxC,MAAI,CAAC,KAAK;AACR,YAAQ,MAAM,oBAAoB,OAAO,UAAU,OAAO;AAC1D;AAAA,EACF;AAGA,WAAS,0BAA0B,IAAI;AACvC,SAAO,SAAS,0BAA0B;AAC5C;",
6
6
  "names": []
7
7
  }
@@ -14,6 +14,7 @@ export declare const traverseDocument: (documentName: string, document: OpenApiD
14
14
  id: string;
15
15
  type: "document";
16
16
  title: string;
17
+ name: string;
17
18
  children: TraversedEntry[];
18
19
  };
19
20
  //# sourceMappingURL=traverse-document.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"traverse-document.d.ts","sourceRoot":"","sources":["../../../src/navigation/helpers/traverse-document.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAqB,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC7E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAA;AAC7E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAA;AAQrF;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,GAAI,cAAc,MAAM,EAAE,UAAU,eAAe,EAAE,SAAS,qBAAqB;;;;;CA6F/G,CAAA"}
1
+ {"version":3,"file":"traverse-document.d.ts","sourceRoot":"","sources":["../../../src/navigation/helpers/traverse-document.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAqB,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC7E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAA;AAC7E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAA;AAQrF;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,GAAI,cAAc,MAAM,EAAE,UAAU,eAAe,EAAE,SAAS,qBAAqB;;;;;;CA8F/G,CAAA"}
@@ -76,7 +76,8 @@ const traverseDocument = (documentName, document, config) => {
76
76
  return {
77
77
  id: documentId,
78
78
  type: "document",
79
- title: documentName,
79
+ title: document.info.title,
80
+ name: documentName,
80
81
  children: entries
81
82
  };
82
83
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/navigation/helpers/traverse-document.ts"],
4
- "sourcesContent": ["import { getNavigationOptions } from '@/navigation/get-navigation-options'\nimport type { TagsMap } from '@/navigation/types'\nimport type { TraversedDocument, TraversedEntry } from '@/schemas/navigation'\nimport type { OpenApiDocument } from '@/schemas/v3.1/strict/openapi-document'\nimport type { DocumentConfiguration } from '@/schemas/workspace-specification/config'\n\nimport { traverseDescription } from './traverse-description'\nimport { traversePaths } from './traverse-paths'\nimport { traverseSchemas } from './traverse-schemas'\nimport { traverseTags } from './traverse-tags'\nimport { traverseWebhooks } from './traverse-webhooks'\n\n/**\n * Traverses an OpenAPI Document to generate navigation structure and metadata.\n *\n * This function processes the OpenAPI document to create:\n * - A hierarchical navigation structure for the sidebar\n * - A mapping of IDs to titles for mobile header navigation\n * - Tag-based organization of operations and webhooks\n * - Optional schema/model documentation\n */\nexport const traverseDocument = (documentName: string, document: OpenApiDocument, config?: DocumentConfiguration) => {\n const { hideModels, tagsSorter, operationsSorter, generateId } = getNavigationOptions(documentName, config)\n\n const documentId = generateId({\n type: 'document',\n info: document.info,\n name: documentName,\n })\n\n /** Map of tags and their entries */\n const tagsMap: TagsMap = new Map(\n document.tags?.map((tag) => [\n tag.name ?? 'Untitled Tag',\n { id: generateId({ type: 'tag', tag, parentId: documentId }), parentId: documentId, tag, entries: [] },\n ]) ?? [],\n )\n\n /** Generate entries for the document info description field */\n const entries: TraversedEntry[] = traverseDescription({\n generateId,\n parentId: documentId,\n info: document.info,\n })\n\n /** Traverse all the document path */\n traversePaths({ document, tagsMap, generateId, documentId })\n\n const untaggedWebhooksParentId = generateId({\n type: 'webhook',\n name: '',\n parentId: documentId,\n })\n\n const untaggedWebhooks = traverseWebhooks({\n document,\n generateId,\n tagsMap,\n untaggedWebhooksParentId,\n documentId,\n })\n\n const tagsEntries = traverseTags({\n document,\n tagsMap,\n documentId,\n options: { tagsSorter, operationsSorter, generateId },\n })\n\n // Add tagged operations, webhooks and tagGroups\n entries.push(...tagsEntries)\n\n // Add untagged webhooks\n if (untaggedWebhooks.length) {\n entries.push({\n type: 'tag',\n id: untaggedWebhooksParentId,\n title: 'Webhooks',\n name: 'Webhooks',\n children: untaggedWebhooks,\n isGroup: false,\n isWebhooks: true,\n })\n }\n\n // Add models if they are not hidden\n if (!hideModels && document.components?.schemas) {\n const untaggedModels = traverseSchemas({\n documentId,\n document,\n generateId,\n tagsMap,\n })\n\n if (untaggedModels.length) {\n entries.push({\n type: 'models',\n id: generateId({\n type: 'model',\n parentId: documentId,\n }),\n title: 'Models',\n name: 'Models',\n children: untaggedModels,\n })\n }\n }\n\n return {\n id: documentId,\n type: 'document',\n title: documentName,\n children: entries,\n } satisfies TraversedDocument\n}\n"],
5
- "mappings": "AAAA,SAAS,4BAA4B;AAMrC,SAAS,2BAA2B;AACpC,SAAS,qBAAqB;AAC9B,SAAS,uBAAuB;AAChC,SAAS,oBAAoB;AAC7B,SAAS,wBAAwB;AAW1B,MAAM,mBAAmB,CAAC,cAAsB,UAA2B,WAAmC;AACnH,QAAM,EAAE,YAAY,YAAY,kBAAkB,WAAW,IAAI,qBAAqB,cAAc,MAAM;AAE1G,QAAM,aAAa,WAAW;AAAA,IAC5B,MAAM;AAAA,IACN,MAAM,SAAS;AAAA,IACf,MAAM;AAAA,EACR,CAAC;AAGD,QAAM,UAAmB,IAAI;AAAA,IAC3B,SAAS,MAAM,IAAI,CAAC,QAAQ;AAAA,MAC1B,IAAI,QAAQ;AAAA,MACZ,EAAE,IAAI,WAAW,EAAE,MAAM,OAAO,KAAK,UAAU,WAAW,CAAC,GAAG,UAAU,YAAY,KAAK,SAAS,CAAC,EAAE;AAAA,IACvG,CAAC,KAAK,CAAC;AAAA,EACT;AAGA,QAAM,UAA4B,oBAAoB;AAAA,IACpD;AAAA,IACA,UAAU;AAAA,IACV,MAAM,SAAS;AAAA,EACjB,CAAC;AAGD,gBAAc,EAAE,UAAU,SAAS,YAAY,WAAW,CAAC;AAE3D,QAAM,2BAA2B,WAAW;AAAA,IAC1C,MAAM;AAAA,IACN,MAAM;AAAA,IACN,UAAU;AAAA,EACZ,CAAC;AAED,QAAM,mBAAmB,iBAAiB;AAAA,IACxC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AAED,QAAM,cAAc,aAAa;AAAA,IAC/B;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS,EAAE,YAAY,kBAAkB,WAAW;AAAA,EACtD,CAAC;AAGD,UAAQ,KAAK,GAAG,WAAW;AAG3B,MAAI,iBAAiB,QAAQ;AAC3B,YAAQ,KAAK;AAAA,MACX,MAAM;AAAA,MACN,IAAI;AAAA,MACJ,OAAO;AAAA,MACP,MAAM;AAAA,MACN,UAAU;AAAA,MACV,SAAS;AAAA,MACT,YAAY;AAAA,IACd,CAAC;AAAA,EACH;AAGA,MAAI,CAAC,cAAc,SAAS,YAAY,SAAS;AAC/C,UAAM,iBAAiB,gBAAgB;AAAA,MACrC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAED,QAAI,eAAe,QAAQ;AACzB,cAAQ,KAAK;AAAA,QACX,MAAM;AAAA,QACN,IAAI,WAAW;AAAA,UACb,MAAM;AAAA,UACN,UAAU;AAAA,QACZ,CAAC;AAAA,QACD,OAAO;AAAA,QACP,MAAM;AAAA,QACN,UAAU;AAAA,MACZ,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AAAA,IACL,IAAI;AAAA,IACJ,MAAM;AAAA,IACN,OAAO;AAAA,IACP,UAAU;AAAA,EACZ;AACF;",
4
+ "sourcesContent": ["import { getNavigationOptions } from '@/navigation/get-navigation-options'\nimport type { TagsMap } from '@/navigation/types'\nimport type { TraversedDocument, TraversedEntry } from '@/schemas/navigation'\nimport type { OpenApiDocument } from '@/schemas/v3.1/strict/openapi-document'\nimport type { DocumentConfiguration } from '@/schemas/workspace-specification/config'\n\nimport { traverseDescription } from './traverse-description'\nimport { traversePaths } from './traverse-paths'\nimport { traverseSchemas } from './traverse-schemas'\nimport { traverseTags } from './traverse-tags'\nimport { traverseWebhooks } from './traverse-webhooks'\n\n/**\n * Traverses an OpenAPI Document to generate navigation structure and metadata.\n *\n * This function processes the OpenAPI document to create:\n * - A hierarchical navigation structure for the sidebar\n * - A mapping of IDs to titles for mobile header navigation\n * - Tag-based organization of operations and webhooks\n * - Optional schema/model documentation\n */\nexport const traverseDocument = (documentName: string, document: OpenApiDocument, config?: DocumentConfiguration) => {\n const { hideModels, tagsSorter, operationsSorter, generateId } = getNavigationOptions(documentName, config)\n\n const documentId = generateId({\n type: 'document',\n info: document.info,\n name: documentName,\n })\n\n /** Map of tags and their entries */\n const tagsMap: TagsMap = new Map(\n document.tags?.map((tag) => [\n tag.name ?? 'Untitled Tag',\n { id: generateId({ type: 'tag', tag, parentId: documentId }), parentId: documentId, tag, entries: [] },\n ]) ?? [],\n )\n\n /** Generate entries for the document info description field */\n const entries: TraversedEntry[] = traverseDescription({\n generateId,\n parentId: documentId,\n info: document.info,\n })\n\n /** Traverse all the document path */\n traversePaths({ document, tagsMap, generateId, documentId })\n\n const untaggedWebhooksParentId = generateId({\n type: 'webhook',\n name: '',\n parentId: documentId,\n })\n\n const untaggedWebhooks = traverseWebhooks({\n document,\n generateId,\n tagsMap,\n untaggedWebhooksParentId,\n documentId,\n })\n\n const tagsEntries = traverseTags({\n document,\n tagsMap,\n documentId,\n options: { tagsSorter, operationsSorter, generateId },\n })\n\n // Add tagged operations, webhooks and tagGroups\n entries.push(...tagsEntries)\n\n // Add untagged webhooks\n if (untaggedWebhooks.length) {\n entries.push({\n type: 'tag',\n id: untaggedWebhooksParentId,\n title: 'Webhooks',\n name: 'Webhooks',\n children: untaggedWebhooks,\n isGroup: false,\n isWebhooks: true,\n })\n }\n\n // Add models if they are not hidden\n if (!hideModels && document.components?.schemas) {\n const untaggedModels = traverseSchemas({\n documentId,\n document,\n generateId,\n tagsMap,\n })\n\n if (untaggedModels.length) {\n entries.push({\n type: 'models',\n id: generateId({\n type: 'model',\n parentId: documentId,\n }),\n title: 'Models',\n name: 'Models',\n children: untaggedModels,\n })\n }\n }\n\n return {\n id: documentId,\n type: 'document',\n title: document.info.title,\n name: documentName,\n children: entries,\n } satisfies TraversedDocument\n}\n"],
5
+ "mappings": "AAAA,SAAS,4BAA4B;AAMrC,SAAS,2BAA2B;AACpC,SAAS,qBAAqB;AAC9B,SAAS,uBAAuB;AAChC,SAAS,oBAAoB;AAC7B,SAAS,wBAAwB;AAW1B,MAAM,mBAAmB,CAAC,cAAsB,UAA2B,WAAmC;AACnH,QAAM,EAAE,YAAY,YAAY,kBAAkB,WAAW,IAAI,qBAAqB,cAAc,MAAM;AAE1G,QAAM,aAAa,WAAW;AAAA,IAC5B,MAAM;AAAA,IACN,MAAM,SAAS;AAAA,IACf,MAAM;AAAA,EACR,CAAC;AAGD,QAAM,UAAmB,IAAI;AAAA,IAC3B,SAAS,MAAM,IAAI,CAAC,QAAQ;AAAA,MAC1B,IAAI,QAAQ;AAAA,MACZ,EAAE,IAAI,WAAW,EAAE,MAAM,OAAO,KAAK,UAAU,WAAW,CAAC,GAAG,UAAU,YAAY,KAAK,SAAS,CAAC,EAAE;AAAA,IACvG,CAAC,KAAK,CAAC;AAAA,EACT;AAGA,QAAM,UAA4B,oBAAoB;AAAA,IACpD;AAAA,IACA,UAAU;AAAA,IACV,MAAM,SAAS;AAAA,EACjB,CAAC;AAGD,gBAAc,EAAE,UAAU,SAAS,YAAY,WAAW,CAAC;AAE3D,QAAM,2BAA2B,WAAW;AAAA,IAC1C,MAAM;AAAA,IACN,MAAM;AAAA,IACN,UAAU;AAAA,EACZ,CAAC;AAED,QAAM,mBAAmB,iBAAiB;AAAA,IACxC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AAED,QAAM,cAAc,aAAa;AAAA,IAC/B;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS,EAAE,YAAY,kBAAkB,WAAW;AAAA,EACtD,CAAC;AAGD,UAAQ,KAAK,GAAG,WAAW;AAG3B,MAAI,iBAAiB,QAAQ;AAC3B,YAAQ,KAAK;AAAA,MACX,MAAM;AAAA,MACN,IAAI;AAAA,MACJ,OAAO;AAAA,MACP,MAAM;AAAA,MACN,UAAU;AAAA,MACV,SAAS;AAAA,MACT,YAAY;AAAA,IACd,CAAC;AAAA,EACH;AAGA,MAAI,CAAC,cAAc,SAAS,YAAY,SAAS;AAC/C,UAAM,iBAAiB,gBAAgB;AAAA,MACrC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAED,QAAI,eAAe,QAAQ;AACzB,cAAQ,KAAK;AAAA,QACX,MAAM;AAAA,QACN,IAAI,WAAW;AAAA,UACb,MAAM;AAAA,UACN,UAAU;AAAA,QACZ,CAAC;AAAA,QACD,OAAO;AAAA,QACP,MAAM;AAAA,QACN,UAAU;AAAA,MACZ,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AAAA,IACL,IAAI;AAAA,IACJ,MAAM;AAAA,IACN,OAAO,SAAS,KAAK;AAAA,IACrB,MAAM;AAAA,IACN,UAAU;AAAA,EACZ;AACF;",
6
6
  "names": []
7
7
  }
@@ -6,8 +6,9 @@ import type { WorkspacePlugin } from '../../workspace-plugin.js';
6
6
  *
7
7
  * This avoids excessive writes to IndexedDB or other persistence layer when changes occur rapidly.
8
8
  */
9
- export declare const persistencePlugin: ({ workspaceId, debounceDelay, }: {
9
+ export declare const persistencePlugin: ({ workspaceId, debounceDelay, maxWait, }: {
10
10
  workspaceId: string;
11
11
  debounceDelay?: number;
12
+ maxWait?: number;
12
13
  }) => Promise<WorkspacePlugin>;
13
14
  //# sourceMappingURL=persistence.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"persistence.d.ts","sourceRoot":"","sources":["../../../src/plugins/client/persistence.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAEzD;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,GAAU,iCAGrC;IACD,WAAW,EAAE,MAAM,CAAA;IACnB,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB,KAAG,OAAO,CAAC,eAAe,CA0D1B,CAAA"}
1
+ {"version":3,"file":"persistence.d.ts","sourceRoot":"","sources":["../../../src/plugins/client/persistence.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAEzD;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,GAAU,0CAKrC;IACD,WAAW,EAAE,MAAM,CAAA;IACnB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,KAAG,OAAO,CAAC,eAAe,CA0D1B,CAAA"}
@@ -1,11 +1,13 @@
1
- import { debounce } from "../../helpers/debounce.js";
1
+ import { debounce } from "@scalar/helpers/general/debounce";
2
2
  import { createWorkspaceStorePersistence } from "../../persistence/index.js";
3
3
  const persistencePlugin = async ({
4
4
  workspaceId,
5
- debounceDelay
5
+ debounceDelay = 500,
6
+ /** Maximum time in milliseconds to wait before forcing execution, even with continuous calls. */
7
+ maxWait = 1e4
6
8
  }) => {
7
9
  const persistence = await createWorkspaceStorePersistence();
8
- const { execute } = debounce({ delay: debounceDelay ?? 500 });
10
+ const { execute } = debounce({ delay: debounceDelay, maxWait });
9
11
  return {
10
12
  hooks: {
11
13
  /**
@@ -14,35 +16,35 @@ const persistencePlugin = async ({
14
16
  */
15
17
  onWorkspaceStateChanges(event) {
16
18
  if (event.type === "meta") {
17
- return execute(["meta", workspaceId], () => persistence.meta.setItem(workspaceId, event.value));
19
+ return execute(`meta-${workspaceId}`, () => persistence.meta.setItem(workspaceId, event.value));
18
20
  }
19
21
  if (event.type === "documentConfigs") {
20
22
  return execute(
21
- ["documentConfigs", workspaceId, event.documentName],
23
+ `documentConfigs-${workspaceId}-${event.documentName}`,
22
24
  () => persistence.documentConfigs.setItem(workspaceId, event.documentName, event.value)
23
25
  );
24
26
  }
25
27
  if (event.type === "documents") {
26
28
  return execute(
27
- ["documents", workspaceId, event.documentName],
29
+ `documents-${workspaceId}-${event.documentName}`,
28
30
  () => persistence.documents.setItem(workspaceId, event.documentName, event.value)
29
31
  );
30
32
  }
31
33
  if (event.type === "intermediateDocuments") {
32
34
  return execute(
33
- ["intermediateDocuments", workspaceId, event.documentName],
35
+ `intermediateDocuments-${workspaceId}-${event.documentName}`,
34
36
  () => persistence.intermediateDocuments.setItem(workspaceId, event.documentName, event.value)
35
37
  );
36
38
  }
37
39
  if (event.type === "originalDocuments") {
38
40
  return execute(
39
- ["originalDocuments", workspaceId, event.documentName],
41
+ `originalDocuments-${workspaceId}-${event.documentName}`,
40
42
  () => persistence.originalDocuments.setItem(workspaceId, event.documentName, event.value)
41
43
  );
42
44
  }
43
45
  if (event.type === "overrides") {
44
46
  return execute(
45
- ["overrides", workspaceId, event.documentName],
47
+ `overrides-${workspaceId}-${event.documentName}`,
46
48
  () => persistence.overrides.setItem(workspaceId, event.documentName, event.value)
47
49
  );
48
50
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/plugins/client/persistence.ts"],
4
- "sourcesContent": ["import { debounce } from '@/helpers/debounce'\nimport { createWorkspaceStorePersistence } from '@/persistence'\nimport type { WorkspacePlugin } from '@/workspace-plugin'\n\n/**\n * Plugin to persist workspace state changes with debounced writes.\n * Each type of change (meta, documentConfigs, documents, etc.) is debounced by key (type + workspaceId + optional documentName).\n * The debounce delay can be customized, defaults to 500ms.\n *\n * This avoids excessive writes to IndexedDB or other persistence layer when changes occur rapidly.\n */\nexport const persistencePlugin = async ({\n workspaceId,\n debounceDelay,\n}: {\n workspaceId: string\n debounceDelay?: number\n}): Promise<WorkspacePlugin> => {\n // Create the persistence instance (e.g., IndexedDB, localForage, etc.)\n const persistence = await createWorkspaceStorePersistence()\n // Debounced execute function for batching similar state changes\n const { execute } = debounce({ delay: debounceDelay ?? 500 })\n\n return {\n hooks: {\n /**\n * Handles all workspace state change events.\n * Each write is debounced by a composite key to prevent frequent writes for the same entity.\n */\n onWorkspaceStateChanges(event) {\n // If the event is for workspace meta data, debounce by workspaceId\n if (event.type === 'meta') {\n return execute(['meta', workspaceId], () => persistence.meta.setItem(workspaceId, event.value))\n }\n\n // Debounce per document config and workspace\n if (event.type === 'documentConfigs') {\n return execute(['documentConfigs', workspaceId, event.documentName], () =>\n persistence.documentConfigs.setItem(workspaceId, event.documentName, event.value),\n )\n }\n\n // Debounce per document content and workspace\n if (event.type === 'documents') {\n return execute(['documents', workspaceId, event.documentName], () =>\n persistence.documents.setItem(workspaceId, event.documentName, event.value),\n )\n }\n\n // Debounce per intermediate document and workspace\n if (event.type === 'intermediateDocuments') {\n return execute(['intermediateDocuments', workspaceId, event.documentName], () =>\n persistence.intermediateDocuments.setItem(workspaceId, event.documentName, event.value),\n )\n }\n\n // Debounce per original document and workspace\n if (event.type === 'originalDocuments') {\n return execute(['originalDocuments', workspaceId, event.documentName], () =>\n persistence.originalDocuments.setItem(workspaceId, event.documentName, event.value),\n )\n }\n\n // Debounce per document override and workspace\n if (event.type === 'overrides') {\n return execute(['overrides', workspaceId, event.documentName], () =>\n persistence.overrides.setItem(workspaceId, event.documentName, event.value),\n )\n }\n\n // No action for other event types\n return\n },\n },\n }\n}\n"],
5
- "mappings": "AAAA,SAAS,gBAAgB;AACzB,SAAS,uCAAuC;AAUzC,MAAM,oBAAoB,OAAO;AAAA,EACtC;AAAA,EACA;AACF,MAGgC;AAE9B,QAAM,cAAc,MAAM,gCAAgC;AAE1D,QAAM,EAAE,QAAQ,IAAI,SAAS,EAAE,OAAO,iBAAiB,IAAI,CAAC;AAE5D,SAAO;AAAA,IACL,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,MAKL,wBAAwB,OAAO;AAE7B,YAAI,MAAM,SAAS,QAAQ;AACzB,iBAAO,QAAQ,CAAC,QAAQ,WAAW,GAAG,MAAM,YAAY,KAAK,QAAQ,aAAa,MAAM,KAAK,CAAC;AAAA,QAChG;AAGA,YAAI,MAAM,SAAS,mBAAmB;AACpC,iBAAO;AAAA,YAAQ,CAAC,mBAAmB,aAAa,MAAM,YAAY;AAAA,YAAG,MACnE,YAAY,gBAAgB,QAAQ,aAAa,MAAM,cAAc,MAAM,KAAK;AAAA,UAClF;AAAA,QACF;AAGA,YAAI,MAAM,SAAS,aAAa;AAC9B,iBAAO;AAAA,YAAQ,CAAC,aAAa,aAAa,MAAM,YAAY;AAAA,YAAG,MAC7D,YAAY,UAAU,QAAQ,aAAa,MAAM,cAAc,MAAM,KAAK;AAAA,UAC5E;AAAA,QACF;AAGA,YAAI,MAAM,SAAS,yBAAyB;AAC1C,iBAAO;AAAA,YAAQ,CAAC,yBAAyB,aAAa,MAAM,YAAY;AAAA,YAAG,MACzE,YAAY,sBAAsB,QAAQ,aAAa,MAAM,cAAc,MAAM,KAAK;AAAA,UACxF;AAAA,QACF;AAGA,YAAI,MAAM,SAAS,qBAAqB;AACtC,iBAAO;AAAA,YAAQ,CAAC,qBAAqB,aAAa,MAAM,YAAY;AAAA,YAAG,MACrE,YAAY,kBAAkB,QAAQ,aAAa,MAAM,cAAc,MAAM,KAAK;AAAA,UACpF;AAAA,QACF;AAGA,YAAI,MAAM,SAAS,aAAa;AAC9B,iBAAO;AAAA,YAAQ,CAAC,aAAa,aAAa,MAAM,YAAY;AAAA,YAAG,MAC7D,YAAY,UAAU,QAAQ,aAAa,MAAM,cAAc,MAAM,KAAK;AAAA,UAC5E;AAAA,QACF;AAGA;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["import { debounce } from '@scalar/helpers/general/debounce'\n\nimport { createWorkspaceStorePersistence } from '@/persistence'\nimport type { WorkspacePlugin } from '@/workspace-plugin'\n\n/**\n * Plugin to persist workspace state changes with debounced writes.\n * Each type of change (meta, documentConfigs, documents, etc.) is debounced by key (type + workspaceId + optional documentName).\n * The debounce delay can be customized, defaults to 500ms.\n *\n * This avoids excessive writes to IndexedDB or other persistence layer when changes occur rapidly.\n */\nexport const persistencePlugin = async ({\n workspaceId,\n debounceDelay = 500,\n /** Maximum time in milliseconds to wait before forcing execution, even with continuous calls. */\n maxWait = 10000,\n}: {\n workspaceId: string\n debounceDelay?: number\n maxWait?: number\n}): Promise<WorkspacePlugin> => {\n // Create the persistence instance (e.g., IndexedDB, localForage, etc.)\n const persistence = await createWorkspaceStorePersistence()\n // Debounced execute function for batching similar state changes\n const { execute } = debounce({ delay: debounceDelay, maxWait })\n\n return {\n hooks: {\n /**\n * Handles all workspace state change events.\n * Each write is debounced by a composite key to prevent frequent writes for the same entity.\n */\n onWorkspaceStateChanges(event) {\n // If the event is for workspace meta data, debounce by workspaceId\n if (event.type === 'meta') {\n return execute(`meta-${workspaceId}`, () => persistence.meta.setItem(workspaceId, event.value))\n }\n\n // Debounce per document config and workspace\n if (event.type === 'documentConfigs') {\n return execute(`documentConfigs-${workspaceId}-${event.documentName}`, () =>\n persistence.documentConfigs.setItem(workspaceId, event.documentName, event.value),\n )\n }\n\n // Debounce per document content and workspace\n if (event.type === 'documents') {\n return execute(`documents-${workspaceId}-${event.documentName}`, () =>\n persistence.documents.setItem(workspaceId, event.documentName, event.value),\n )\n }\n\n // Debounce per intermediate document and workspace\n if (event.type === 'intermediateDocuments') {\n return execute(`intermediateDocuments-${workspaceId}-${event.documentName}`, () =>\n persistence.intermediateDocuments.setItem(workspaceId, event.documentName, event.value),\n )\n }\n\n // Debounce per original document and workspace\n if (event.type === 'originalDocuments') {\n return execute(`originalDocuments-${workspaceId}-${event.documentName}`, () =>\n persistence.originalDocuments.setItem(workspaceId, event.documentName, event.value),\n )\n }\n\n // Debounce per document override and workspace\n if (event.type === 'overrides') {\n return execute(`overrides-${workspaceId}-${event.documentName}`, () =>\n persistence.overrides.setItem(workspaceId, event.documentName, event.value),\n )\n }\n\n // No action for other event types\n return\n },\n },\n }\n}\n"],
5
+ "mappings": "AAAA,SAAS,gBAAgB;AAEzB,SAAS,uCAAuC;AAUzC,MAAM,oBAAoB,OAAO;AAAA,EACtC;AAAA,EACA,gBAAgB;AAAA;AAAA,EAEhB,UAAU;AACZ,MAIgC;AAE9B,QAAM,cAAc,MAAM,gCAAgC;AAE1D,QAAM,EAAE,QAAQ,IAAI,SAAS,EAAE,OAAO,eAAe,QAAQ,CAAC;AAE9D,SAAO;AAAA,IACL,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,MAKL,wBAAwB,OAAO;AAE7B,YAAI,MAAM,SAAS,QAAQ;AACzB,iBAAO,QAAQ,QAAQ,WAAW,IAAI,MAAM,YAAY,KAAK,QAAQ,aAAa,MAAM,KAAK,CAAC;AAAA,QAChG;AAGA,YAAI,MAAM,SAAS,mBAAmB;AACpC,iBAAO;AAAA,YAAQ,mBAAmB,WAAW,IAAI,MAAM,YAAY;AAAA,YAAI,MACrE,YAAY,gBAAgB,QAAQ,aAAa,MAAM,cAAc,MAAM,KAAK;AAAA,UAClF;AAAA,QACF;AAGA,YAAI,MAAM,SAAS,aAAa;AAC9B,iBAAO;AAAA,YAAQ,aAAa,WAAW,IAAI,MAAM,YAAY;AAAA,YAAI,MAC/D,YAAY,UAAU,QAAQ,aAAa,MAAM,cAAc,MAAM,KAAK;AAAA,UAC5E;AAAA,QACF;AAGA,YAAI,MAAM,SAAS,yBAAyB;AAC1C,iBAAO;AAAA,YAAQ,yBAAyB,WAAW,IAAI,MAAM,YAAY;AAAA,YAAI,MAC3E,YAAY,sBAAsB,QAAQ,aAAa,MAAM,cAAc,MAAM,KAAK;AAAA,UACxF;AAAA,QACF;AAGA,YAAI,MAAM,SAAS,qBAAqB;AACtC,iBAAO;AAAA,YAAQ,qBAAqB,WAAW,IAAI,MAAM,YAAY;AAAA,YAAI,MACvE,YAAY,kBAAkB,QAAQ,aAAa,MAAM,cAAc,MAAM,KAAK;AAAA,UACpF;AAAA,QACF;AAGA,YAAI,MAAM,SAAS,aAAa;AAC9B,iBAAO;AAAA,YAAQ,aAAa,WAAW,IAAI,MAAM,YAAY;AAAA,YAAI,MAC/D,YAAY,UAAU,QAAQ,aAAa,MAAM,cAAc,MAAM,KAAK;AAAA,UAC5E;AAAA,QACF;AAGA;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,13 @@
1
+ export declare const XScalarDocumentSecuritySchema: import("@scalar/typebox").TObject<{
2
+ 'x-scalar-document-security': import("@scalar/typebox").TOptional<import("@scalar/typebox").TBoolean>;
3
+ }>;
4
+ export type XScalarDocumentSecurity = {
5
+ /**
6
+ * XScalarDocumentSecurity Extension
7
+ *
8
+ * If enabled we use/set the selected security schemes on the document level
9
+ * If disabled we use/set the selected security schemes on the operation level
10
+ */
11
+ 'x-scalar-document-security'?: boolean;
12
+ };
13
+ //# sourceMappingURL=x-scalar-document-security.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"x-scalar-document-security.d.ts","sourceRoot":"","sources":["../../../../src/schemas/extensions/document/x-scalar-document-security.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,6BAA6B;;EAExC,CAAA;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC;;;;;OAKG;IACH,4BAA4B,CAAC,EAAE,OAAO,CAAA;CACvC,CAAA"}
@@ -0,0 +1,8 @@
1
+ import { Type } from "@scalar/typebox";
2
+ const XScalarDocumentSecuritySchema = Type.Object({
3
+ "x-scalar-document-security": Type.Optional(Type.Boolean())
4
+ });
5
+ export {
6
+ XScalarDocumentSecuritySchema
7
+ };
8
+ //# sourceMappingURL=x-scalar-document-security.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/schemas/extensions/document/x-scalar-document-security.ts"],
4
+ "sourcesContent": ["import { Type } from '@scalar/typebox'\n\nexport const XScalarDocumentSecuritySchema = Type.Object({\n 'x-scalar-document-security': Type.Optional(Type.Boolean()),\n})\n\nexport type XScalarDocumentSecurity = {\n /**\n * XScalarDocumentSecurity Extension\n *\n * If enabled we use/set the selected security schemes on the document level\n * If disabled we use/set the selected security schemes on the operation level\n */\n 'x-scalar-document-security'?: boolean\n}\n"],
5
+ "mappings": "AAAA,SAAS,YAAY;AAEd,MAAM,gCAAgC,KAAK,OAAO;AAAA,EACvD,8BAA8B,KAAK,SAAS,KAAK,QAAQ,CAAC;AAC5D,CAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,13 @@
1
+ import { type Static } from '@scalar/typebox';
2
+ /**
3
+ * path and method identifiers for Scalar operations
4
+ *
5
+ * Used internally by Scalar to keep track of operations
6
+ * as a draft state when you edit the path/method before saving the new operation
7
+ */
8
+ export declare const XScalarOperationIdentifiersSchema: import("@scalar/typebox").TObject<{
9
+ 'x-scalar-path': import("@scalar/typebox").TOptional<import("@scalar/typebox").TString>;
10
+ 'x-scalar-method': import("@scalar/typebox").TOptional<import("@scalar/typebox").TString>;
11
+ }>;
12
+ export type XScalarOperationIdentifiers = Static<typeof XScalarOperationIdentifiersSchema>;
13
+ //# sourceMappingURL=x-scalar-operation-identifiers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"x-scalar-operation-identifiers.d.ts","sourceRoot":"","sources":["../../../../src/schemas/extensions/operation/x-scalar-operation-identifiers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAQ,MAAM,iBAAiB,CAAA;AAEnD;;;;;GAKG;AACH,eAAO,MAAM,iCAAiC;;;EAG5C,CAAA;AAEF,MAAM,MAAM,2BAA2B,GAAG,MAAM,CAAC,OAAO,iCAAiC,CAAC,CAAA"}
@@ -0,0 +1,9 @@
1
+ import { Type } from "@scalar/typebox";
2
+ const XScalarOperationIdentifiersSchema = Type.Object({
3
+ "x-scalar-path": Type.Optional(Type.String()),
4
+ "x-scalar-method": Type.Optional(Type.String())
5
+ });
6
+ export {
7
+ XScalarOperationIdentifiersSchema
8
+ };
9
+ //# sourceMappingURL=x-scalar-operation-identifiers.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/schemas/extensions/operation/x-scalar-operation-identifiers.ts"],
4
+ "sourcesContent": ["import { type Static, Type } from '@scalar/typebox'\n\n/**\n * path and method identifiers for Scalar operations\n *\n * Used internally by Scalar to keep track of operations\n * as a draft state when you edit the path/method before saving the new operation\n */\nexport const XScalarOperationIdentifiersSchema = Type.Object({\n 'x-scalar-path': Type.Optional(Type.String()),\n 'x-scalar-method': Type.Optional(Type.String()),\n})\n\nexport type XScalarOperationIdentifiers = Static<typeof XScalarOperationIdentifiersSchema>\n"],
5
+ "mappings": "AAAA,SAAsB,YAAY;AAQ3B,MAAM,oCAAoC,KAAK,OAAO;AAAA,EAC3D,iBAAiB,KAAK,SAAS,KAAK,OAAO,CAAC;AAAA,EAC5C,mBAAmB,KAAK,SAAS,KAAK,OAAO,CAAC;AAChD,CAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Schema for the x-scalar-selected-content-type extension on an OpenAPI operation.
3
+ *
4
+ * The key represents the example name, and the value is the selected content type string.
5
+ * Used by Scalar to track which content type is selected for each example in request or response bodies.
6
+ */
7
+ export declare const XScalarSelectedContentTypeSchema: import("@scalar/typebox").TObject<{
8
+ 'x-scalar-selected-content-type': import("@scalar/typebox").TOptional<import("@scalar/typebox").TRecord<import("@scalar/typebox").TString, import("@scalar/typebox").TString>>;
9
+ }>;
10
+ /**
11
+ * Type definition for the x-scalar-selected-content-type extension on an OpenAPI operation.
12
+ *
13
+ * The key represents the example name, and the value is the selected content type string.
14
+ * Used by Scalar to track which content type is selected for each example in request or response bodies.
15
+ */
16
+ export type XScalarSelectedContentType = {
17
+ 'x-scalar-selected-content-type'?: {
18
+ [key: string]: string;
19
+ };
20
+ };
21
+ //# sourceMappingURL=x-scalar-selected-content-type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"x-scalar-selected-content-type.d.ts","sourceRoot":"","sources":["../../../../src/schemas/extensions/operation/x-scalar-selected-content-type.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,eAAO,MAAM,gCAAgC;;EAE3C,CAAA;AAEF;;;;;GAKG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACvC,gCAAgC,CAAC,EAAE;QACjC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KACtB,CAAA;CACF,CAAA"}
@@ -0,0 +1,8 @@
1
+ import { Type } from "@scalar/typebox";
2
+ const XScalarSelectedContentTypeSchema = Type.Object({
3
+ "x-scalar-selected-content-type": Type.Optional(Type.Record(Type.String(), Type.String()))
4
+ });
5
+ export {
6
+ XScalarSelectedContentTypeSchema
7
+ };
8
+ //# sourceMappingURL=x-scalar-selected-content-type.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/schemas/extensions/operation/x-scalar-selected-content-type.ts"],
4
+ "sourcesContent": ["import { Type } from '@scalar/typebox'\n\n/**\n * Schema for the x-scalar-selected-content-type extension on an OpenAPI operation.\n *\n * The key represents the example name, and the value is the selected content type string.\n * Used by Scalar to track which content type is selected for each example in request or response bodies.\n */\nexport const XScalarSelectedContentTypeSchema = Type.Object({\n 'x-scalar-selected-content-type': Type.Optional(Type.Record(Type.String(), Type.String())),\n})\n\n/**\n * Type definition for the x-scalar-selected-content-type extension on an OpenAPI operation.\n *\n * The key represents the example name, and the value is the selected content type string.\n * Used by Scalar to track which content type is selected for each example in request or response bodies.\n */\nexport type XScalarSelectedContentType = {\n 'x-scalar-selected-content-type'?: {\n [key: string]: string\n }\n}\n"],
5
+ "mappings": "AAAA,SAAS,YAAY;AAQd,MAAM,mCAAmC,KAAK,OAAO;AAAA,EAC1D,kCAAkC,KAAK,SAAS,KAAK,OAAO,KAAK,OAAO,GAAG,KAAK,OAAO,CAAC,CAAC;AAC3F,CAAC;",
6
+ "names": []
7
+ }