@scalar/workspace-store 0.20.0 → 0.21.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 (174) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/README.md +2 -2
  3. package/dist/client.d.ts +40 -4
  4. package/dist/client.d.ts.map +1 -1
  5. package/dist/client.js +58 -23
  6. package/dist/client.js.map +2 -2
  7. package/dist/events/bus.d.ts +13 -1
  8. package/dist/events/bus.d.ts.map +1 -1
  9. package/dist/events/bus.js +46 -10
  10. package/dist/events/bus.js.map +3 -3
  11. package/dist/events/definitions/cookie.d.ts +20 -0
  12. package/dist/events/definitions/cookie.d.ts.map +1 -0
  13. package/dist/events/definitions/cookie.js +1 -0
  14. package/dist/events/definitions/cookie.js.map +7 -0
  15. package/dist/events/definitions/document.d.ts +8 -2
  16. package/dist/events/definitions/document.d.ts.map +1 -1
  17. package/dist/events/definitions/index.d.ts +4 -1
  18. package/dist/events/definitions/index.d.ts.map +1 -1
  19. package/dist/events/definitions/operation.d.ts +0 -13
  20. package/dist/events/definitions/operation.d.ts.map +1 -1
  21. package/dist/events/definitions/server.d.ts +2 -2
  22. package/dist/events/definitions/server.d.ts.map +1 -1
  23. package/dist/events/definitions/tabs.d.ts +40 -0
  24. package/dist/events/definitions/tabs.d.ts.map +1 -0
  25. package/dist/events/definitions/tabs.js +1 -0
  26. package/dist/events/definitions/tabs.js.map +7 -0
  27. package/dist/events/definitions/ui.d.ts +39 -4
  28. package/dist/events/definitions/ui.d.ts.map +1 -1
  29. package/dist/events/definitions/workspace.d.ts +18 -0
  30. package/dist/events/definitions/workspace.d.ts.map +1 -0
  31. package/dist/events/definitions/workspace.js +1 -0
  32. package/dist/events/definitions/workspace.js.map +7 -0
  33. package/dist/helpers/generate-unique-value.d.ts +19 -6
  34. package/dist/helpers/generate-unique-value.d.ts.map +1 -1
  35. package/dist/helpers/generate-unique-value.js +12 -7
  36. package/dist/helpers/generate-unique-value.js.map +2 -2
  37. package/dist/helpers/unpack-proxy.d.ts +14 -1
  38. package/dist/helpers/unpack-proxy.d.ts.map +1 -1
  39. package/dist/helpers/unpack-proxy.js +51 -1
  40. package/dist/helpers/unpack-proxy.js.map +3 -3
  41. package/dist/mutators/auth.d.ts +1 -1
  42. package/dist/mutators/auth.d.ts.map +1 -1
  43. package/dist/mutators/auth.js +24 -21
  44. package/dist/mutators/auth.js.map +2 -2
  45. package/dist/mutators/cookie.d.ts +21 -13
  46. package/dist/mutators/cookie.d.ts.map +1 -1
  47. package/dist/mutators/cookie.js +34 -26
  48. package/dist/mutators/cookie.js.map +3 -3
  49. package/dist/mutators/document.d.ts +9 -2
  50. package/dist/mutators/document.d.ts.map +1 -1
  51. package/dist/mutators/document.js +18 -3
  52. package/dist/mutators/document.js.map +2 -2
  53. package/dist/mutators/index.d.ts +4 -14
  54. package/dist/mutators/index.d.ts.map +1 -1
  55. package/dist/mutators/index.js +15 -9
  56. package/dist/mutators/index.js.map +2 -2
  57. package/dist/mutators/operation.d.ts +23 -101
  58. package/dist/mutators/operation.d.ts.map +1 -1
  59. package/dist/mutators/operation.js +132 -96
  60. package/dist/mutators/operation.js.map +2 -2
  61. package/dist/mutators/server.d.ts +1 -1
  62. package/dist/mutators/server.d.ts.map +1 -1
  63. package/dist/mutators/server.js +6 -5
  64. package/dist/mutators/server.js.map +2 -2
  65. package/dist/mutators/workspace.d.ts +6 -0
  66. package/dist/mutators/workspace.d.ts.map +1 -0
  67. package/dist/mutators/workspace.js +24 -0
  68. package/dist/mutators/workspace.js.map +7 -0
  69. package/dist/navigation/get-navigation-options.d.ts.map +1 -1
  70. package/dist/navigation/get-navigation-options.js +4 -4
  71. package/dist/navigation/get-navigation-options.js.map +2 -2
  72. package/dist/navigation/helpers/traverse-document.d.ts +1 -0
  73. package/dist/navigation/helpers/traverse-document.d.ts.map +1 -1
  74. package/dist/navigation/helpers/traverse-document.js +16 -2
  75. package/dist/navigation/helpers/traverse-document.js.map +2 -2
  76. package/dist/navigation/helpers/traverse-examples.js +2 -2
  77. package/dist/navigation/helpers/traverse-examples.js.map +2 -2
  78. package/dist/navigation/helpers/traverse-paths.d.ts +6 -3
  79. package/dist/navigation/helpers/traverse-paths.d.ts.map +1 -1
  80. package/dist/navigation/helpers/traverse-paths.js +4 -9
  81. package/dist/navigation/helpers/traverse-paths.js.map +2 -2
  82. package/dist/navigation/helpers/traverse-tags.d.ts +0 -1
  83. package/dist/navigation/helpers/traverse-tags.d.ts.map +1 -1
  84. package/dist/navigation/helpers/traverse-tags.js +57 -49
  85. package/dist/navigation/helpers/traverse-tags.js.map +3 -3
  86. package/dist/persistence/index.d.ts +6 -0
  87. package/dist/persistence/index.d.ts.map +1 -1
  88. package/dist/persistence/index.js +18 -0
  89. package/dist/persistence/index.js.map +2 -2
  90. package/dist/persistence/indexdb.d.ts +1 -0
  91. package/dist/persistence/indexdb.d.ts.map +1 -1
  92. package/dist/persistence/indexdb.js +6 -1
  93. package/dist/persistence/indexdb.js.map +2 -2
  94. package/dist/plugins/client/persistence.d.ts.map +1 -1
  95. package/dist/plugins/client/persistence.js +6 -0
  96. package/dist/plugins/client/persistence.js.map +2 -2
  97. package/dist/schemas/extensions/document/x-scalar-environments.d.ts +1 -0
  98. package/dist/schemas/extensions/document/x-scalar-environments.d.ts.map +1 -1
  99. package/dist/schemas/extensions/document/x-scalar-environments.js.map +2 -2
  100. package/dist/schemas/extensions/document/x-scalar-set-operation-security.d.ts +13 -0
  101. package/dist/schemas/extensions/document/x-scalar-set-operation-security.d.ts.map +1 -0
  102. package/dist/schemas/extensions/document/x-scalar-set-operation-security.js +8 -0
  103. package/dist/schemas/extensions/document/x-scalar-set-operation-security.js.map +7 -0
  104. package/dist/schemas/extensions/general/x-scalar-cookies.d.ts +36 -0
  105. package/dist/schemas/extensions/general/x-scalar-cookies.d.ts.map +1 -0
  106. package/dist/schemas/extensions/general/x-scalar-cookies.js +15 -0
  107. package/dist/schemas/extensions/general/x-scalar-cookies.js.map +7 -0
  108. package/dist/schemas/extensions/general/x-scalar-order.d.ts +12 -0
  109. package/dist/schemas/extensions/general/x-scalar-order.d.ts.map +1 -0
  110. package/dist/schemas/extensions/general/x-scalar-order.js +8 -0
  111. package/dist/schemas/extensions/general/x-scalar-order.js.map +7 -0
  112. package/dist/schemas/extensions/tag/x-tag-groups.d.ts +10 -5
  113. package/dist/schemas/extensions/tag/x-tag-groups.d.ts.map +1 -1
  114. package/dist/schemas/extensions/tag/x-tag-groups.js +15 -10
  115. package/dist/schemas/extensions/tag/x-tag-groups.js.map +2 -2
  116. package/dist/schemas/extensions/workspace/x-scalar-active-proxy.d.ts +18 -0
  117. package/dist/schemas/extensions/workspace/x-scalar-active-proxy.d.ts.map +1 -0
  118. package/dist/schemas/extensions/workspace/x-scalar-active-proxy.js +8 -0
  119. package/dist/schemas/extensions/workspace/x-scalar-active-proxy.js.map +7 -0
  120. package/dist/schemas/extensions.d.ts +1 -1
  121. package/dist/schemas/extensions.js +1 -1
  122. package/dist/schemas/extensions.js.map +2 -2
  123. package/dist/schemas/inmemory-workspace.d.ts +41 -27
  124. package/dist/schemas/inmemory-workspace.d.ts.map +1 -1
  125. package/dist/schemas/navigation.d.ts +4 -1
  126. package/dist/schemas/navigation.d.ts.map +1 -1
  127. package/dist/schemas/navigation.js +2 -1
  128. package/dist/schemas/navigation.js.map +2 -2
  129. package/dist/schemas/reference-config/index.d.ts +20 -13
  130. package/dist/schemas/reference-config/index.d.ts.map +1 -1
  131. package/dist/schemas/reference-config/settings.d.ts +20 -13
  132. package/dist/schemas/reference-config/settings.d.ts.map +1 -1
  133. package/dist/schemas/reference-config/settings.js +2 -0
  134. package/dist/schemas/reference-config/settings.js.map +2 -2
  135. package/dist/schemas/v3.1/strict/openapi-document.d.ts +685 -448
  136. package/dist/schemas/v3.1/strict/openapi-document.d.ts.map +1 -1
  137. package/dist/schemas/v3.1/strict/openapi-document.js +10 -10
  138. package/dist/schemas/v3.1/strict/openapi-document.js.map +2 -2
  139. package/dist/schemas/v3.1/strict/operation.d.ts +1 -5
  140. package/dist/schemas/v3.1/strict/operation.d.ts.map +1 -1
  141. package/dist/schemas/v3.1/strict/operation.js +1 -5
  142. package/dist/schemas/v3.1/strict/operation.js.map +2 -2
  143. package/dist/schemas/v3.1/strict/tag.d.ts +4 -1
  144. package/dist/schemas/v3.1/strict/tag.d.ts.map +1 -1
  145. package/dist/schemas/v3.1/strict/tag.js +3 -1
  146. package/dist/schemas/v3.1/strict/tag.js.map +2 -2
  147. package/dist/schemas/v3.1/strict/type-guards.d.ts +6 -0
  148. package/dist/schemas/v3.1/strict/type-guards.d.ts.map +1 -1
  149. package/dist/schemas/v3.1/strict/type-guards.js +4 -0
  150. package/dist/schemas/v3.1/strict/type-guards.js.map +2 -2
  151. package/dist/schemas/workspace-specification/config.d.ts +20 -13
  152. package/dist/schemas/workspace-specification/config.d.ts.map +1 -1
  153. package/dist/schemas/workspace-specification/index.d.ts +21 -14
  154. package/dist/schemas/workspace-specification/index.d.ts.map +1 -1
  155. package/dist/schemas/workspace.d.ts +170 -109
  156. package/dist/schemas/workspace.d.ts.map +1 -1
  157. package/dist/schemas/workspace.js +8 -6
  158. package/dist/schemas/workspace.js.map +2 -2
  159. package/dist/server.d.ts +1 -1
  160. package/dist/workspace-plugin.d.ts +3 -0
  161. package/dist/workspace-plugin.d.ts.map +1 -1
  162. package/package.json +8 -7
  163. package/dist/schemas/extensions/document/x-scalar-document-security.d.ts +0 -13
  164. package/dist/schemas/extensions/document/x-scalar-document-security.d.ts.map +0 -1
  165. package/dist/schemas/extensions/document/x-scalar-document-security.js +0 -8
  166. package/dist/schemas/extensions/document/x-scalar-document-security.js.map +0 -7
  167. package/dist/schemas/extensions/operation/x-scalar-operation-identifiers.d.ts +0 -13
  168. package/dist/schemas/extensions/operation/x-scalar-operation-identifiers.d.ts.map +0 -1
  169. package/dist/schemas/extensions/operation/x-scalar-operation-identifiers.js +0 -9
  170. package/dist/schemas/extensions/operation/x-scalar-operation-identifiers.js.map +0 -7
  171. package/dist/schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-cookies.d.ts +0 -32
  172. package/dist/schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-cookies.d.ts.map +0 -1
  173. package/dist/schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-cookies.js +0 -13
  174. package/dist/schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-cookies.js.map +0 -7
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/mutators/auth.ts"],
4
- "sourcesContent": ["import type { HttpMethod } from '@scalar/helpers/http/http-methods'\n\nimport type { AuthEvents } from '@/events/definitions/auth'\nimport { generateUniqueValue } from '@/helpers/generate-unique-value'\nimport { getResolvedRef } from '@/helpers/get-resolved-ref'\nimport { mergeObjects } from '@/helpers/merge-object'\nimport type { WorkspaceDocument } from '@/schemas'\nimport type { SecurityRequirementObject } from '@/schemas/v3.1/strict/security-requirement'\n\n/**\n * AuthMeta defines the meta information needed to specify whether the authentication operation\n * is being performed at the document level (entire API), or for a specific operation (specific path and method).\n *\n * - If type is 'document', the operation applies to the whole OpenAPI document.\n * - If type is 'operation', it targets a specific operation, identified by its path and method.\n */\nexport type AuthMeta =\n | {\n type: 'document'\n }\n | {\n type: 'operation'\n path: string\n method: HttpMethod\n }\n\n/**\n * Updates the selected security schemes for either the entire document or a specific operation.\n * - Adds newly created security schemes (if any) to the workspace document's components.\n * - Ensures that each new scheme name is unique within the document by using `generateUniqueValue`.\n * - Updates the `x-scalar-selected-security` property on the target (document or operation) to reflect the new set of selected security schemes.\n * - Corrects and maintains the selected index so it points to a valid security scheme.\n *\n * @param document - The workspace OpenAPI document to mutate (can be null, in which case nothing happens)\n * @param selectedSecuritySchemes - The current list of selected security scheme objects\n * @param create - Array of new schemes to create, each with a name and a scheme definition\n * @param meta - Location to update: whole document or a specific operation (`{ type: 'document' }` or `{ type: 'operation', path, method }`)\n *\n * Example usage:\n * ```\n * updateSelectedSecuritySchemes({\n * document,\n * selectedSecuritySchemes: [{ bearerAuth: [] }],\n * create: [\n * { name: 'ApiKeyAuth', scheme: { type: 'apiKey', in: 'header', name: 'X-API-Key' } }\n * ],\n * meta: { type: 'document' }\n * })\n * ```\n */\nexport const updateSelectedSecuritySchemes = (\n document: WorkspaceDocument | null,\n { selectedRequirements, newSchemes, meta }: AuthEvents['auth:update:selected-security-schemes'],\n) => {\n if (!document) {\n return\n }\n\n // Helper to get the target (whole document or a specific operation)\n const getTarget = () => {\n if (meta.type === 'document') {\n return document\n }\n\n return getResolvedRef(document.paths?.[meta.path]?.[meta.method])\n }\n\n // Create any new security schemes required, ensuring unique names for the components\n const createdSchemes = newSchemes\n .map((scheme) => {\n const name = generateUniqueValue({\n defaultValue: scheme.name,\n validation: (value) => !document.components?.securitySchemes?.[value],\n maxRetries: 100,\n })\n\n if (!name) {\n return\n }\n\n // Ensure components and securitySchemes exist\n if (!document.components) {\n document.components = {}\n }\n if (!document.components.securitySchemes) {\n document.components.securitySchemes = {}\n }\n\n // Add the new security scheme definition\n document.components.securitySchemes[name] = scheme.scheme\n\n // Return an OpenAPI Security Requirement Object for this new scheme (empty scope array)\n return {\n [name]: [],\n }\n })\n .filter(Boolean) as SecurityRequirementObject[]\n\n const target = getTarget()\n\n const newSelectedSecuritySchemes = [...selectedRequirements, ...createdSchemes]\n\n // If the target (document/operation) doesn't exist, do nothing\n if (!target) {\n return\n }\n\n // Ensure the x-scalar-selected-security structure exists on the target\n if (!target['x-scalar-selected-security']) {\n target['x-scalar-selected-security'] = {\n selectedIndex: -1,\n selectedSchemes: [],\n }\n }\n\n const selectedIndex = target['x-scalar-selected-security'].selectedIndex\n\n // Update the schemes array\n target['x-scalar-selected-security'].selectedSchemes = newSelectedSecuritySchemes\n\n // Adjust selected index if there are schemes and the index is unset/invalid\n if (newSelectedSecuritySchemes.length > 0 && selectedIndex < 0) {\n target['x-scalar-selected-security'].selectedIndex = 0\n }\n\n // If the selected index is now out of bounds, select the last available\n if (selectedIndex >= newSelectedSecuritySchemes.length) {\n target['x-scalar-selected-security'].selectedIndex = newSelectedSecuritySchemes.length - 1\n }\n}\n\n/**\n * Updates a security scheme in the OpenAPI document's components object.\n * Handles updates for HTTP, API Key, and OAuth2 types, saving secret information and configuration for UI-auth flows.\n *\n * @param document - The OpenAPI workspace document (can be null)\n * @param data - The update information, including type and payload\n * @param name - The name of the security scheme in document.components.securitySchemes\n *\n * Example usage:\n *\n * updateSecurityScheme({\n * document,\n * data: {\n * type: 'http',\n * payload: {\n * username: 'user123',\n * password: 'pw123',\n * token: 'tokenval'\n * }\n * },\n * name: 'MyHttpAuth',\n * })\n */\nexport const updateSecurityScheme = (\n document: WorkspaceDocument | null,\n { payload, name }: AuthEvents['auth:update:security-scheme'],\n) => {\n const target = getResolvedRef(document?.components?.securitySchemes?.[name])\n if (!target) {\n console.error(`Security scheme ${name} not found`)\n return\n }\n\n // Handle HTTP (basic, bearer, etc.)\n if (target.type === payload.type) {\n mergeObjects(target, payload)\n }\n\n return target\n}\n\n/**\n * Sets the selected authentication tab (scheme) index for the given OpenAPI document or operation.\n * - When on the document level, updates the 'selectedIndex' on the document's x-scalar-selected-security extension.\n * - When on an operation (endpoint) level, updates the 'selectedIndex' for that operation's x-scalar-selected-security.\n *\n * Also initializes the x-scalar-selected-security extension if it does not exist.\n *\n * @param document The OpenAPI document object (may be null)\n * @param index The index to set as selected\n * @param meta Context where the selection applies ('document' or specific operation)\n *\n * @example\n * // Document-level tab selection\n * updateSelectedAuthTab({\n * document,\n * index: 1,\n * meta: { type: 'document' }\n * });\n *\n * // Operation-level tab selection (e.g., GET /pets)\n * updateSelectedAuthTab({\n * document,\n * index: 0,\n * meta: { type: 'operation', path: '/pets', method: 'get' }\n * });\n */\nexport const updateSelectedAuthTab = (\n document: WorkspaceDocument | null,\n { index, meta }: AuthEvents['auth:update:active-index'],\n) => {\n if (!document) {\n return\n }\n\n // Determine the target object for setting the auth tab index:\n // - Document/root level\n // - Operation/endpoint level (if meta specifies operation)\n const getTarget = () => {\n if (meta.type === 'document') {\n return document\n }\n return getResolvedRef(document.paths?.[meta.path]?.[meta.method])\n }\n\n const target = getTarget()\n if (!target) {\n return\n }\n\n // Ensure the 'x-scalar-selected-security' extension exists\n if (!target['x-scalar-selected-security']) {\n target['x-scalar-selected-security'] = {\n selectedIndex: 0,\n selectedSchemes: [],\n }\n }\n\n // Set the selected auth tab index\n target['x-scalar-selected-security'].selectedIndex = index\n}\n\n/**\n * Updates the scopes for a specific security requirement in the selected security schemes of\n * a document or operation.\n *\n * @param document - The OpenAPI WorkspaceDocument to update.\n * @param id - An array of scheme names that uniquely identifies the target security requirement.\n * For example: ['OAuth', 'ApiKeyAuth']\n * @param name - The security scheme name to update scopes for (e.g., 'OAuth').\n * @param scopes - The new list of scopes to set. For example: ['read:pets', 'write:pets']\n * @param meta - The context specifying whether the update is at the document-level or operation-level.\n *\n * Example usage:\n * ```ts\n * // Suppose your document (or operation) x-scalar-selected-security looks like:\n * // \"x-scalar-selected-security\": {\n * // selectedIndex: 0,\n * // selectedSchemes: [\n * // { \"OAuth\": [\"read:pets\"] },\n * // { \"ApiKeyAuth\": [] }\n * // ]\n * // }\n *\n * updateSelectedScopes({\n * document,\n * id: [\"OAuth\"], // identifies the scheme object: { \"OAuth\": [...] }\n * name: \"OAuth\", // scheme name to update within this security requirement\n * scopes: [\"write:pets\"], // new scopes array\n * meta: { type: \"document\" }\n * })\n * // After, the first scheme becomes: { \"OAuth\": [\"write:pets\"] }\n * ```\n */\nexport const updateSelectedScopes = (\n document: WorkspaceDocument | null,\n { id, name, scopes, meta }: AuthEvents['auth:update:selected-scopes'],\n) => {\n if (!document) {\n return\n }\n\n // Determine the target object (document or the operation)\n const getTarget = () => {\n if (meta.type === 'document') {\n return document\n }\n return getResolvedRef(document.paths?.[meta.path]?.[meta.method])\n }\n\n const target = getTarget()\n\n if (!target) {\n return\n }\n\n // Array of security requirement objects under x-scalar-selected-security\n const selectedSchemes = target['x-scalar-selected-security']?.selectedSchemes\n\n if (!selectedSchemes) {\n return\n }\n\n // Find the security requirement that matches the given id (scheme key names)\n // For example: if id = [\"OAuth\"], matches { OAuth: [...] }\n const scheme = selectedSchemes.find((scheme) => JSON.stringify(Object.keys(scheme)) === JSON.stringify(id))\n\n if (!scheme) {\n return\n }\n\n // Set the scopes array for the named security scheme within the found security requirement\n scheme[name] = scopes\n}\n\n/**\n * Deletes one or more security schemes from an OpenAPI WorkspaceDocument,\n * and removes all references to those schemes from selected security, document-level security,\n * and operation-level security/selected security (e.g., on paths).\n *\n * Example usage:\n *\n * ```ts\n * deleteSecurityScheme({\n * document, // The OpenAPI document to update\n * names: ['ApiKeyAuth', 'BearerAuth'], // The names of security schemes you want to delete\n * });\n * ```\n *\n * After running this function:\n * - The named security schemes are removed from the components.securitySchemes section.\n * - All document-level and operation-level security entries referencing those schemes are removed.\n * - Any extended x-scalar-selected-security references to those schemes are also removed.\n */\nexport const deleteSecurityScheme = (\n document: WorkspaceDocument | null,\n { names }: AuthEvents['auth:delete:security-scheme'],\n) => {\n if (!document) {\n // Early exit if there is no document to modify\n return\n }\n\n // Get the mutable reference to securitySchemes in components (may be a proxy/resolved reference)\n const target = getResolvedRef(document.components?.securitySchemes)\n\n if (!target) {\n // If there are no security schemes to delete from, return early\n return\n }\n\n // Remove each named security scheme from the components.securitySchemes object\n names.forEach((name) => {\n delete target[name]\n })\n\n // Function to remove any security requirement objects that reference given scheme names.\n const filterSecuritySchemes = (schemes: SecurityRequirementObject[]) => {\n // Remove schemes whose key is included in the `names` to be deleted.\n return schemes.filter((scheme) => !names.some((name) => Object.keys(scheme).includes(name)))\n }\n\n // -- Remove from document-level `x-scalar-selected-security` extension, if present\n if (document['x-scalar-selected-security']) {\n const selectedSecurity = document['x-scalar-selected-security']\n selectedSecurity.selectedSchemes = filterSecuritySchemes(selectedSecurity.selectedSchemes)\n }\n\n // -- Remove from document-level `security` property, if present\n if (document['security']) {\n document['security'] = filterSecuritySchemes(document['security'])\n }\n\n // -- For each path and operation, remove deleted security schemes from operation-level security and custom extension\n Object.values(document.paths ?? {}).forEach((path) => {\n Object.values(path).forEach((operation) => {\n if (typeof operation !== 'object') {\n // Ignore operations that are not objects (could be undefined)\n return\n }\n\n // Get mutable reference for the operation (could resolve $ref proxies)\n const resolvedOperation = getResolvedRef(operation)\n\n // Remove from operation-level security array\n if ('security' in resolvedOperation && resolvedOperation['security']) {\n resolvedOperation['security'] = filterSecuritySchemes(resolvedOperation['security'])\n }\n\n // Remove from operation-level x-scalar-selected-security array\n if ('x-scalar-selected-security' in resolvedOperation && resolvedOperation['x-scalar-selected-security']) {\n resolvedOperation['x-scalar-selected-security'].selectedSchemes = filterSecuritySchemes(\n resolvedOperation['x-scalar-selected-security'].selectedSchemes,\n )\n }\n })\n })\n}\n"],
5
- "mappings": "AAGA,SAAS,2BAA2B;AACpC,SAAS,sBAAsB;AAC/B,SAAS,oBAAoB;AA6CtB,MAAM,gCAAgC,CAC3C,UACA,EAAE,sBAAsB,YAAY,KAAK,MACtC;AACH,MAAI,CAAC,UAAU;AACb;AAAA,EACF;AAGA,QAAM,YAAY,MAAM;AACtB,QAAI,KAAK,SAAS,YAAY;AAC5B,aAAO;AAAA,IACT;AAEA,WAAO,eAAe,SAAS,QAAQ,KAAK,IAAI,IAAI,KAAK,MAAM,CAAC;AAAA,EAClE;AAGA,QAAM,iBAAiB,WACpB,IAAI,CAAC,WAAW;AACf,UAAM,OAAO,oBAAoB;AAAA,MAC/B,cAAc,OAAO;AAAA,MACrB,YAAY,CAAC,UAAU,CAAC,SAAS,YAAY,kBAAkB,KAAK;AAAA,MACpE,YAAY;AAAA,IACd,CAAC;AAED,QAAI,CAAC,MAAM;AACT;AAAA,IACF;AAGA,QAAI,CAAC,SAAS,YAAY;AACxB,eAAS,aAAa,CAAC;AAAA,IACzB;AACA,QAAI,CAAC,SAAS,WAAW,iBAAiB;AACxC,eAAS,WAAW,kBAAkB,CAAC;AAAA,IACzC;AAGA,aAAS,WAAW,gBAAgB,IAAI,IAAI,OA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SAAS,4BAA4B;AAC9D,qBAAiB,kBAAkB,sBAAsB,iBAAiB,eAAe;AAAA,EAC3F;AAGA,MAAI,SAAS,UAAU,GAAG;AACxB,aAAS,UAAU,IAAI,sBAAsB,SAAS,UAAU,CAAC;AAAA,EACnE;AAGA,SAAO,OAAO,SAAS,SAAS,CAAC,CAAC,EAAE,QAAQ,CAAC,SAAS;AACpD,WAAO,OAAO,IAAI,EAAE,QAAQ,CAAC,cAAc;AACzC,UAAI,OAAO,cAAc,UAAU;AAEjC;AAAA,MACF;AAGA,YAAM,oBAAoB,eAAe,SAAS;AAGlD,UAAI,cAAc,qBAAqB,kBAAkB,UAAU,GAAG;AACpE,0BAAkB,UAAU,IAAI,sBAAsB,kBAAkB,UAAU,CAAC;AAAA,MACrF;AAGA,UAAI,gCAAgC,qBAAqB,kBAAkB,4BAA4B,GAAG;AACxG,0BAAkB,4BAA4B,EAAE,kBAAkB;AAAA,UAChE,kBAAkB,4BAA4B,EAAE;AAAA,QAClD;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AACH;",
4
+ "sourcesContent": ["import type { HttpMethod } from '@scalar/helpers/http/http-methods'\n\nimport type { AuthEvents } from '@/events/definitions/auth'\nimport { generateUniqueValue } from '@/helpers/generate-unique-value'\nimport { getResolvedRef } from '@/helpers/get-resolved-ref'\nimport { mergeObjects } from '@/helpers/merge-object'\nimport type { WorkspaceDocument } from '@/schemas'\nimport type { SecurityRequirementObject } from '@/schemas/v3.1/strict/security-requirement'\n\n/**\n * AuthMeta defines the meta information needed to specify whether the authentication operation\n * is being performed at the document level (entire API), or for a specific operation (specific path and method).\n *\n * - If type is 'document', the operation applies to the whole OpenAPI document.\n * - If type is 'operation', it targets a specific operation, identified by its path and method.\n */\nexport type AuthMeta =\n | {\n type: 'document'\n }\n | {\n type: 'operation'\n path: string\n method: HttpMethod\n }\n\n/**\n * Updates the selected security schemes for either the entire document or a specific operation.\n * - Adds newly created security schemes (if any) to the workspace document's components.\n * - Ensures that each new scheme name is unique within the document by using `generateUniqueValue`.\n * - Updates the `x-scalar-selected-security` property on the target (document or operation) to reflect the new set of selected security schemes.\n * - Corrects and maintains the selected index so it points to a valid security scheme.\n *\n * @param document - The workspace OpenAPI document to mutate (can be null, in which case nothing happens)\n * @param selectedSecuritySchemes - The current list of selected security scheme objects\n * @param create - Array of new schemes to create, each with a name and a scheme definition\n * @param meta - Location to update: whole document or a specific operation (`{ type: 'document' }` or `{ type: 'operation', path, method }`)\n *\n * Example usage:\n * ```\n * updateSelectedSecuritySchemes({\n * document,\n * selectedSecuritySchemes: [{ bearerAuth: [] }],\n * create: [\n * { name: 'ApiKeyAuth', scheme: { type: 'apiKey', in: 'header', name: 'X-API-Key' } }\n * ],\n * meta: { type: 'document' }\n * })\n * ```\n */\nexport const updateSelectedSecuritySchemes = async (\n document: WorkspaceDocument | null,\n { selectedRequirements, newSchemes, meta }: AuthEvents['auth:update:selected-security-schemes'],\n) => {\n if (!document) {\n return\n }\n\n // Helper to get the target (whole document or a specific operation)\n const getTarget = () => {\n if (meta.type === 'document') {\n return document\n }\n\n return getResolvedRef(document.paths?.[meta.path]?.[meta.method])\n }\n\n const createdSecurityRequirements = await Promise.all(\n newSchemes.map(async (newScheme) => {\n const uniqueSchemeName = await generateUniqueValue({\n defaultValue: newScheme.name,\n validation: (value) => !document.components?.securitySchemes?.[value],\n maxRetries: 100,\n })\n\n if (!uniqueSchemeName) {\n return\n }\n\n // Ensure components and securitySchemes exist\n if (!document.components) {\n document.components = {}\n }\n if (!document.components.securitySchemes) {\n document.components.securitySchemes = {}\n }\n\n // Add the new security scheme definition\n document.components.securitySchemes[uniqueSchemeName] = newScheme.scheme\n\n // Return an OpenAPI Security Requirement Object for this new scheme (empty scope array)\n return {\n [uniqueSchemeName]: [],\n }\n }),\n )\n\n // Create any new security schemes required, ensuring unique names for the components\n const createdSchemes = createdSecurityRequirements.filter(Boolean) as SecurityRequirementObject[]\n\n const target = getTarget()\n\n const newSelectedSecuritySchemes = [...selectedRequirements, ...createdSchemes]\n\n // If the target (document/operation) doesn't exist, do nothing\n if (!target) {\n return\n }\n\n // Ensure the x-scalar-selected-security structure exists on the target\n if (!target['x-scalar-selected-security']) {\n target['x-scalar-selected-security'] = {\n selectedIndex: -1,\n selectedSchemes: [],\n }\n }\n\n const selectedIndex = target['x-scalar-selected-security'].selectedIndex\n\n // Update the schemes array\n target['x-scalar-selected-security'].selectedSchemes = newSelectedSecuritySchemes\n\n // Adjust selected index if there are schemes and the index is unset/invalid\n if (newSelectedSecuritySchemes.length > 0 && selectedIndex < 0) {\n target['x-scalar-selected-security'].selectedIndex = 0\n }\n\n // If the selected index is now out of bounds, select the last available\n if (selectedIndex >= newSelectedSecuritySchemes.length) {\n target['x-scalar-selected-security'].selectedIndex = newSelectedSecuritySchemes.length - 1\n }\n}\n\n/**\n * Updates a security scheme in the OpenAPI document's components object.\n * Handles updates for HTTP, API Key, and OAuth2 types, saving secret information and configuration for UI-auth flows.\n *\n * @param document - The OpenAPI workspace document (can be null)\n * @param data - The update information, including type and payload\n * @param name - The name of the security scheme in document.components.securitySchemes\n *\n * Example usage:\n *\n * updateSecurityScheme({\n * document,\n * data: {\n * type: 'http',\n * payload: {\n * username: 'user123',\n * password: 'pw123',\n * token: 'tokenval'\n * }\n * },\n * name: 'MyHttpAuth',\n * })\n */\nexport const updateSecurityScheme = (\n document: WorkspaceDocument | null,\n { payload, name }: AuthEvents['auth:update:security-scheme'],\n) => {\n const target = getResolvedRef(document?.components?.securitySchemes?.[name])\n if (!target) {\n console.error(`Security scheme ${name} not found`)\n return\n }\n\n // Handle HTTP (basic, bearer, etc.)\n if (target.type === payload.type) {\n mergeObjects(target, payload)\n }\n\n return target\n}\n\n/**\n * Sets the selected authentication tab (scheme) index for the given OpenAPI document or operation.\n * - When on the document level, updates the 'selectedIndex' on the document's x-scalar-selected-security extension.\n * - When on an operation (endpoint) level, updates the 'selectedIndex' for that operation's x-scalar-selected-security.\n *\n * Also initializes the x-scalar-selected-security extension if it does not exist.\n *\n * @param document The OpenAPI document object (may be null)\n * @param index The index to set as selected\n * @param meta Context where the selection applies ('document' or specific operation)\n *\n * @example\n * // Document-level tab selection\n * updateSelectedAuthTab({\n * document,\n * index: 1,\n * meta: { type: 'document' }\n * });\n *\n * // Operation-level tab selection (e.g., GET /pets)\n * updateSelectedAuthTab({\n * document,\n * index: 0,\n * meta: { type: 'operation', path: '/pets', method: 'get' }\n * });\n */\nexport const updateSelectedAuthTab = (\n document: WorkspaceDocument | null,\n { index, meta }: AuthEvents['auth:update:active-index'],\n) => {\n if (!document) {\n return\n }\n\n // Determine the target object for setting the auth tab index:\n // - Document/root level\n // - Operation/endpoint level (if meta specifies operation)\n const getTarget = () => {\n if (meta.type === 'document') {\n return document\n }\n return getResolvedRef(document.paths?.[meta.path]?.[meta.method])\n }\n\n const target = getTarget()\n if (!target) {\n return\n }\n\n // Ensure the 'x-scalar-selected-security' extension exists\n if (!target['x-scalar-selected-security']) {\n target['x-scalar-selected-security'] = {\n selectedIndex: 0,\n selectedSchemes: [],\n }\n }\n\n // Set the selected auth tab index\n target['x-scalar-selected-security'].selectedIndex = index\n}\n\n/**\n * Updates the scopes for a specific security requirement in the selected security schemes of\n * a document or operation.\n *\n * @param document - The OpenAPI WorkspaceDocument to update.\n * @param id - An array of scheme names that uniquely identifies the target security requirement.\n * For example: ['OAuth', 'ApiKeyAuth']\n * @param name - The security scheme name to update scopes for (e.g., 'OAuth').\n * @param scopes - The new list of scopes to set. For example: ['read:pets', 'write:pets']\n * @param meta - The context specifying whether the update is at the document-level or operation-level.\n *\n * Example usage:\n * ```ts\n * // Suppose your document (or operation) x-scalar-selected-security looks like:\n * // \"x-scalar-selected-security\": {\n * // selectedIndex: 0,\n * // selectedSchemes: [\n * // { \"OAuth\": [\"read:pets\"] },\n * // { \"ApiKeyAuth\": [] }\n * // ]\n * // }\n *\n * updateSelectedScopes({\n * document,\n * id: [\"OAuth\"], // identifies the scheme object: { \"OAuth\": [...] }\n * name: \"OAuth\", // scheme name to update within this security requirement\n * scopes: [\"write:pets\"], // new scopes array\n * meta: { type: \"document\" }\n * })\n * // After, the first scheme becomes: { \"OAuth\": [\"write:pets\"] }\n * ```\n */\nexport const updateSelectedScopes = (\n document: WorkspaceDocument | null,\n { id, name, scopes, meta }: AuthEvents['auth:update:selected-scopes'],\n) => {\n if (!document) {\n return\n }\n\n // Determine the target object (document or the operation)\n const getTarget = () => {\n if (meta.type === 'document') {\n return document\n }\n return getResolvedRef(document.paths?.[meta.path]?.[meta.method])\n }\n\n const target = getTarget()\n\n if (!target) {\n return\n }\n\n // Array of security requirement objects under x-scalar-selected-security\n const selectedSchemes = target['x-scalar-selected-security']?.selectedSchemes\n\n if (!selectedSchemes) {\n return\n }\n\n // Find the security requirement that matches the given id (scheme key names)\n // For example: if id = [\"OAuth\"], matches { OAuth: [...] }\n const scheme = selectedSchemes.find((scheme) => JSON.stringify(Object.keys(scheme)) === JSON.stringify(id))\n\n if (!scheme) {\n return\n }\n\n // Set the scopes array for the named security scheme within the found security requirement\n scheme[name] = scopes\n}\n\n/**\n * Deletes one or more security schemes from an OpenAPI WorkspaceDocument,\n * and removes all references to those schemes from selected security, document-level security,\n * and operation-level security/selected security (e.g., on paths).\n *\n * Example usage:\n *\n * ```ts\n * deleteSecurityScheme({\n * document, // The OpenAPI document to update\n * names: ['ApiKeyAuth', 'BearerAuth'], // The names of security schemes you want to delete\n * });\n * ```\n *\n * After running this function:\n * - The named security schemes are removed from the components.securitySchemes section.\n * - All document-level and operation-level security entries referencing those schemes are removed.\n * - Any extended x-scalar-selected-security references to those schemes are also removed.\n */\nexport const deleteSecurityScheme = (\n document: WorkspaceDocument | null,\n { names }: AuthEvents['auth:delete:security-scheme'],\n) => {\n if (!document) {\n // Early exit if there is no document to modify\n return\n }\n\n // Get the mutable reference to securitySchemes in components (may be a proxy/resolved reference)\n const target = getResolvedRef(document.components?.securitySchemes)\n\n if (!target) {\n // If there are no security schemes to delete from, return early\n return\n }\n\n // Remove each named security scheme from the components.securitySchemes object\n names.forEach((name) => {\n delete target[name]\n })\n\n // Function to remove any security requirement objects that reference given scheme names.\n const filterSecuritySchemes = (schemes: SecurityRequirementObject[]) => {\n // Remove schemes whose key is included in the `names` to be deleted.\n return schemes.filter((scheme) => !names.some((name) => Object.keys(scheme).includes(name)))\n }\n\n // -- Remove from document-level `x-scalar-selected-security` extension, if present\n if (document['x-scalar-selected-security']) {\n const selectedSecurity = document['x-scalar-selected-security']\n selectedSecurity.selectedSchemes = filterSecuritySchemes(selectedSecurity.selectedSchemes)\n }\n\n // -- Remove from document-level `security` property, if present\n if (document['security']) {\n document['security'] = filterSecuritySchemes(document['security'])\n }\n\n // -- For each path and operation, remove deleted security schemes from operation-level security and custom extension\n Object.values(document.paths ?? {}).forEach((path) => {\n Object.values(path).forEach((operation) => {\n if (typeof operation !== 'object') {\n // Ignore operations that are not objects (could be undefined)\n return\n }\n\n // Get mutable reference for the operation (could resolve $ref proxies)\n const resolvedOperation = getResolvedRef(operation)\n\n // Remove from operation-level security array\n if ('security' in resolvedOperation && resolvedOperation['security']) {\n resolvedOperation['security'] = filterSecuritySchemes(resolvedOperation['security'])\n }\n\n // Remove from operation-level x-scalar-selected-security array\n if ('x-scalar-selected-security' in resolvedOperation && resolvedOperation['x-scalar-selected-security']) {\n resolvedOperation['x-scalar-selected-security'].selectedSchemes = filterSecuritySchemes(\n resolvedOperation['x-scalar-selected-security'].selectedSchemes,\n )\n }\n })\n })\n}\n"],
5
+ "mappings": "AAGA,SAAS,2BAA2B;AACpC,SAAS,sBAAsB;AAC/B,SAAS,oBAAoB;AA6CtB,MAAM,gCAAgC,OAC3C,UACA,EAAE,sBAAsB,YAAY,KAAK,MACtC;AACH,MAAI,CAAC,UAAU;AACb;AAAA,EACF;AAGA,QAAM,YAAY,MAAM;AACtB,QAAI,KAAK,SAAS,YAAY;AAC5B,aAAO;AAAA,IACT;AAEA,WAAO,eAAe,SAAS,QAAQ,KAAK,IAAI,IAAI,KAAK,MAAM,CA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
- import type { UnknownObject } from '../helpers/general.js';
2
- import type { XScalarClientConfigCookie, XScalarClientConfigCookies } from '../schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-cookies.js';
1
+ import type { CookieEvents } from '../events/definitions/cookie.js';
2
+ import type { Workspace, WorkspaceDocument } from '../schemas.js';
3
+ import { type XScalarCookie } from '../schemas/extensions/general/x-scalar-cookies.js';
3
4
  /**
4
- * Cookie mutators for managing client configuration cookies in OpenAPI documents.
5
- * Provides functions to add and delete cookies from the document's x-scalar-client-config-cookies extension.
5
+ * Adds OR updates a cookie to the document or workspace.
6
6
  *
7
- * @param store - The workspace store containing the documents
8
- * @param documentName - The name of the document to operate on
9
- * @returns Object containing addCookie and deleteCookie functions
7
+ * @param document - current document if available
8
+ * @param workspace - current workspace if available
9
+ * @param payload - The cookie configuration to add or update
10
+ * @param index - Optional index for updating an existing cookie
11
+ * @param collectionType - Whether this is for a document or workspace
12
+ * @returns the parsed cookie that was added or updated or undefined if the collection is not found
10
13
  */
11
- export declare const cookieMutators: (document?: UnknownObject & {
12
- "x-scalar-client-config-cookies"?: XScalarClientConfigCookies;
13
- }) => {
14
- addCookie: (cookie: XScalarClientConfigCookie) => boolean;
15
- deleteCookie: (cookieName: string) => boolean;
16
- };
14
+ export declare const upsertCookie: (collection: WorkspaceDocument | Workspace | null, { payload, index }: CookieEvents["cookie:upsert:cookie"]) => XScalarCookie | undefined;
15
+ /**
16
+ * Deletes a cookie from the document or workspace by index.
17
+ *
18
+ * @param document - current document if available
19
+ * @param workspace - current workspace if available
20
+ * @param index - Index of the cookie to delete
21
+ * @param collectionType - Whether this is for a document or workspace
22
+ * @returns true if the cookie was deleted, false otherwise
23
+ */
24
+ export declare const deleteCookie: (collection: WorkspaceDocument | Workspace | null, { index }: CookieEvents["cookie:delete:cookie"]) => boolean;
17
25
  //# sourceMappingURL=cookie.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cookie.d.ts","sourceRoot":"","sources":["../../src/mutators/cookie.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,KAAK,EACV,yBAAyB,EACzB,0BAA0B,EAC3B,MAAM,+EAA+E,CAAA;AAEtF;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,GACzB,WAAW,aAAa,GAAG;IAAE,gCAAgC,CAAC,EAAE,0BAA0B,CAAA;CAAE;wBAwBjE,yBAAyB;+BA+BlB,MAAM;CAazC,CAAA"}
1
+ {"version":3,"file":"cookie.d.ts","sourceRoot":"","sources":["../../src/mutators/cookie.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AAC/D,OAAO,KAAK,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAC7D,OAAO,EAAE,KAAK,aAAa,EAAuB,MAAM,+CAA+C,CAAA;AAGvG;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY,GACvB,YAAY,iBAAiB,GAAG,SAAS,GAAG,IAAI,EAChD,oBAAoB,YAAY,CAAC,sBAAsB,CAAC,KACvD,aAAa,GAAG,SA8BlB,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,GACvB,YAAY,iBAAiB,GAAG,SAAS,GAAG,IAAI,EAChD,WAAW,YAAY,CAAC,sBAAsB,CAAC,KAC9C,OAWF,CAAA"}
@@ -1,31 +1,39 @@
1
- const cookieMutators = (document) => {
2
- const addCookie = (cookie) => {
3
- if (!document) {
4
- return false;
1
+ import { xScalarCookieSchema } from "../schemas/extensions/general/x-scalar-cookies.js";
2
+ import { coerceValue } from "../schemas/typebox-coerce.js";
3
+ const upsertCookie = (collection, { payload, index }) => {
4
+ if (!collection) {
5
+ return;
6
+ }
7
+ if (!collection["x-scalar-cookies"]) {
8
+ collection["x-scalar-cookies"] = [];
9
+ }
10
+ if (index !== void 0) {
11
+ if (index < 0 || index >= collection["x-scalar-cookies"].length) {
12
+ return;
5
13
  }
6
- if (!document["x-scalar-client-config-cookies"]) {
7
- document["x-scalar-client-config-cookies"] = {};
8
- }
9
- if (document["x-scalar-client-config-cookies"][cookie.name]) {
10
- console.warn(`Cookie with name "${cookie.name}" already exists in the document.`);
11
- return false;
12
- }
13
- document["x-scalar-client-config-cookies"][cookie.name] = cookie;
14
- return true;
15
- };
16
- const deleteCookie = (cookieName) => {
17
- if (!document || !document["x-scalar-client-config-cookies"]) {
18
- return false;
19
- }
20
- delete document["x-scalar-client-config-cookies"][cookieName];
21
- return true;
22
- };
23
- return {
24
- addCookie,
25
- deleteCookie
26
- };
14
+ const parsed2 = coerceValue(xScalarCookieSchema, {
15
+ ...collection["x-scalar-cookies"][index],
16
+ ...payload
17
+ });
18
+ collection["x-scalar-cookies"][index] = parsed2;
19
+ return parsed2;
20
+ }
21
+ const parsed = coerceValue(xScalarCookieSchema, payload);
22
+ collection["x-scalar-cookies"].push(parsed);
23
+ return parsed;
24
+ };
25
+ const deleteCookie = (collection, { index }) => {
26
+ if (!collection || !collection["x-scalar-cookies"]) {
27
+ return false;
28
+ }
29
+ if (index < 0 || index >= collection["x-scalar-cookies"].length) {
30
+ return false;
31
+ }
32
+ collection["x-scalar-cookies"].splice(index, 1);
33
+ return true;
27
34
  };
28
35
  export {
29
- cookieMutators
36
+ deleteCookie,
37
+ upsertCookie
30
38
  };
31
39
  //# sourceMappingURL=cookie.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/mutators/cookie.ts"],
4
- "sourcesContent": ["import type { UnknownObject } from '@/helpers/general'\nimport type {\n XScalarClientConfigCookie,\n XScalarClientConfigCookies,\n} from '@/schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-cookies'\n\n/**\n * Cookie mutators for managing client configuration cookies in OpenAPI documents.\n * Provides functions to add and delete cookies from the document's x-scalar-client-config-cookies extension.\n *\n * @param store - The workspace store containing the documents\n * @param documentName - The name of the document to operate on\n * @returns Object containing addCookie and deleteCookie functions\n */\nexport const cookieMutators = (\n document?: UnknownObject & { 'x-scalar-client-config-cookies'?: XScalarClientConfigCookies },\n) => {\n /**\n * Adds a new cookie to the document's client configuration.\n * If a cookie with the same name already exists, it will log a warning and return false.\n *\n * @param cookie - The cookie configuration to add\n * @returns true if the cookie was added successfully, false if it already exists\n *\n * @example\n * // Add a new authentication cookie\n * const success = addCookie({\n * name: 'auth-token',\n * value: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',\n * domain: '.example.com',\n * path: '/'\n * })\n *\n * if (success) {\n * console.log('Cookie added successfully')\n * } else {\n * console.log('Cookie already exists')\n * }\n */\n const addCookie = (cookie: XScalarClientConfigCookie) => {\n if (!document) {\n return false\n }\n\n if (!document['x-scalar-client-config-cookies']) {\n document['x-scalar-client-config-cookies'] = {}\n }\n\n if (document['x-scalar-client-config-cookies'][cookie.name]) {\n console.warn(`Cookie with name \"${cookie.name}\" already exists in the document.`)\n return false\n }\n\n document['x-scalar-client-config-cookies'][cookie.name] = cookie\n return true\n }\n\n /**\n * Removes a cookie from the document's x-scalar-client-config-cookies extension by its name.\n * Returns false if the document or cookies object does not exist, otherwise deletes the cookie and returns true.\n *\n * @param cookieName - The name of the cookie to remove\n *\n * @example\n * // Remove an authentication cookie\n * deleteCookie('auth-token')\n *\n * // Remove a session cookie\n * deleteCookie('session-id')\n */\n const deleteCookie = (cookieName: string) => {\n if (!document || !document['x-scalar-client-config-cookies']) {\n return false\n }\n\n delete document['x-scalar-client-config-cookies'][cookieName]\n return true\n }\n\n return {\n addCookie,\n deleteCookie,\n }\n}\n"],
5
- "mappings": "AAcO,MAAM,iBAAiB,CAC5B,aACG;AAuBH,QAAM,YAAY,CAAC,WAAsC;AACvD,QAAI,CAAC,UAAU;AACb,aAAO;AAAA,IACT;AAEA,QAAI,CAAC,SAAS,gCAAgC,GAAG;AAC/C,eAAS,gCAAgC,IAAI,CAAC;AAAA,IAChD;AAEA,QAAI,SAAS,gCAAgC,EAAE,OAAO,IAAI,GAAG;AAC3D,cAAQ,KAAK,qBAAqB,OAAO,IAAI,mCAAmC;AAChF,aAAO;AAAA,IACT;AAEA,aAAS,gCAAgC,EAAE,OAAO,IAAI,IAAI;AAC1D,WAAO;AAAA,EACT;AAeA,QAAM,eAAe,CAAC,eAAuB;AAC3C,QAAI,CAAC,YAAY,CAAC,SAAS,gCAAgC,GAAG;AAC5D,aAAO;AAAA,IACT;AAEA,WAAO,SAAS,gCAAgC,EAAE,UAAU;AAC5D,WAAO;AAAA,EACT;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;",
6
- "names": []
4
+ "sourcesContent": ["import type { CookieEvents } from '@/events/definitions/cookie'\nimport type { Workspace, WorkspaceDocument } from '@/schemas'\nimport { type XScalarCookie, xScalarCookieSchema } from '@/schemas/extensions/general/x-scalar-cookies'\nimport { coerceValue } from '@/schemas/typebox-coerce'\n\n/**\n * Adds OR updates a cookie to the document or workspace.\n *\n * @param document - current document if available\n * @param workspace - current workspace if available\n * @param payload - The cookie configuration to add or update\n * @param index - Optional index for updating an existing cookie\n * @param collectionType - Whether this is for a document or workspace\n * @returns the parsed cookie that was added or updated or undefined if the collection is not found\n */\nexport const upsertCookie = (\n collection: WorkspaceDocument | Workspace | null,\n { payload, index }: CookieEvents['cookie:upsert:cookie'],\n): XScalarCookie | undefined => {\n if (!collection) {\n return\n }\n\n if (!collection['x-scalar-cookies']) {\n collection['x-scalar-cookies'] = []\n }\n\n if (index !== undefined) {\n // Update existing cookie at index\n if (index < 0 || index >= collection['x-scalar-cookies'].length) {\n return\n }\n\n // Ensure we parse the payload but keep the existing cookie data\n const parsed = coerceValue(xScalarCookieSchema, {\n ...collection['x-scalar-cookies'][index],\n ...payload,\n })\n\n // Update\n collection['x-scalar-cookies'][index] = parsed\n return parsed\n }\n\n // Add new cookie\n const parsed = coerceValue(xScalarCookieSchema, payload)\n collection['x-scalar-cookies'].push(parsed)\n return parsed\n}\n\n/**\n * Deletes a cookie from the document or workspace by index.\n *\n * @param document - current document if available\n * @param workspace - current workspace if available\n * @param index - Index of the cookie to delete\n * @param collectionType - Whether this is for a document or workspace\n * @returns true if the cookie was deleted, false otherwise\n */\nexport const deleteCookie = (\n collection: WorkspaceDocument | Workspace | null,\n { index }: CookieEvents['cookie:delete:cookie'],\n): boolean => {\n if (!collection || !collection['x-scalar-cookies']) {\n return false\n }\n\n if (index < 0 || index >= collection['x-scalar-cookies'].length) {\n return false\n }\n\n collection['x-scalar-cookies'].splice(index, 1)\n return true\n}\n"],
5
+ "mappings": "AAEA,SAA6B,2BAA2B;AACxD,SAAS,mBAAmB;AAYrB,MAAM,eAAe,CAC1B,YACA,EAAE,SAAS,MAAM,MACa;AAC9B,MAAI,CAAC,YAAY;AACf;AAAA,EACF;AAEA,MAAI,CAAC,WAAW,kBAAkB,GAAG;AACnC,eAAW,kBAAkB,IAAI,CAAC;AAAA,EACpC;AAEA,MAAI,UAAU,QAAW;AAEvB,QAAI,QAAQ,KAAK,SAAS,WAAW,kBAAkB,EAAE,QAAQ;AAC/D;AAAA,IACF;AAGA,UAAMA,UAAS,YAAY,qBAAqB;AAAA,MAC9C,GAAG,WAAW,kBAAkB,EAAE,KAAK;AAAA,MACvC,GAAG;AAAA,IACL,CAAC;AAGD,eAAW,kBAAkB,EAAE,KAAK,IAAIA;AACxC,WAAOA;AAAA,EACT;AAGA,QAAM,SAAS,YAAY,qBAAqB,OAAO;AACvD,aAAW,kBAAkB,EAAE,KAAK,MAAM;AAC1C,SAAO;AACT;AAWO,MAAM,eAAe,CAC1B,YACA,EAAE,MAAM,MACI;AACZ,MAAI,CAAC,cAAc,CAAC,WAAW,kBAAkB,GAAG;AAClD,WAAO;AAAA,EACT;AAEA,MAAI,QAAQ,KAAK,SAAS,WAAW,kBAAkB,EAAE,QAAQ;AAC/D,WAAO;AAAA,EACT;AAEA,aAAW,kBAAkB,EAAE,OAAO,OAAO,CAAC;AAC9C,SAAO;AACT;",
6
+ "names": ["parsed"]
7
7
  }
@@ -1,6 +1,13 @@
1
1
  import type { WorkspaceDocument } from '../schemas.js';
2
2
  /**
3
- * Toggle use document security
3
+ * Toggle setting selected security schemes at the operation level
4
4
  */
5
- export declare const toggleDocumentSecurity: (document: WorkspaceDocument | null) => void;
5
+ export declare const toggleSecurity: (document: WorkspaceDocument | null) => void;
6
+ export declare const updateWatchMode: (document: WorkspaceDocument | null, watchMode: boolean) => void;
7
+ /**
8
+ * Update the document icon and also update the corresponding sidebar entry
9
+ *
10
+ * Does not perform a sidebar rebuild for performance benefit
11
+ */
12
+ export declare const updateDocumentIcon: (document: WorkspaceDocument | null, icon: string) => void;
6
13
  //# sourceMappingURL=document.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../src/mutators/document.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAElD;;GAEG;AACH,eAAO,MAAM,sBAAsB,GAAI,UAAU,iBAAiB,GAAG,IAAI,SAMxE,CAAA"}
1
+ {"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../src/mutators/document.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAElD;;GAEG;AACH,eAAO,MAAM,cAAc,GAAI,UAAU,iBAAiB,GAAG,IAAI,SAMhE,CAAA;AAED,eAAO,MAAM,eAAe,GAAI,UAAU,iBAAiB,GAAG,IAAI,EAAE,WAAW,OAAO,SAMrF,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAI,UAAU,iBAAiB,GAAG,IAAI,EAAE,MAAM,MAAM,SASlF,CAAA"}
@@ -1,10 +1,25 @@
1
- const toggleDocumentSecurity = (document) => {
1
+ const toggleSecurity = (document) => {
2
2
  if (!document) {
3
3
  return;
4
4
  }
5
- document["x-scalar-document-security"] = !document["x-scalar-document-security"];
5
+ document["x-scalar-set-operation-security"] = !document["x-scalar-set-operation-security"];
6
+ };
7
+ const updateWatchMode = (document, watchMode) => {
8
+ if (!document) {
9
+ return;
10
+ }
11
+ document["x-scalar-watch-mode"] = watchMode;
12
+ };
13
+ const updateDocumentIcon = (document, icon) => {
14
+ if (!document || !document["x-scalar-navigation"]) {
15
+ return;
16
+ }
17
+ document["x-scalar-icon"] = icon;
18
+ document["x-scalar-navigation"].icon = icon;
6
19
  };
7
20
  export {
8
- toggleDocumentSecurity
21
+ toggleSecurity,
22
+ updateDocumentIcon,
23
+ updateWatchMode
9
24
  };
10
25
  //# sourceMappingURL=document.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/mutators/document.ts"],
4
- "sourcesContent": ["import type { WorkspaceDocument } from '@/schemas'\n\n/**\n * Toggle use document security\n */\nexport const toggleDocumentSecurity = (document: WorkspaceDocument | null) => {\n if (!document) {\n return\n }\n\n document['x-scalar-document-security'] = !document['x-scalar-document-security']\n}\n"],
5
- "mappings": "AAKO,MAAM,yBAAyB,CAAC,aAAuC;AAC5E,MAAI,CAAC,UAAU;AACb;AAAA,EACF;AAEA,WAAS,4BAA4B,IAAI,CAAC,SAAS,4BAA4B;AACjF;",
4
+ "sourcesContent": ["import type { WorkspaceDocument } from '@/schemas'\n\n/**\n * Toggle setting selected security schemes at the operation level\n */\nexport const toggleSecurity = (document: WorkspaceDocument | null) => {\n if (!document) {\n return\n }\n\n document['x-scalar-set-operation-security'] = !document['x-scalar-set-operation-security']\n}\n\nexport const updateWatchMode = (document: WorkspaceDocument | null, watchMode: boolean) => {\n if (!document) {\n return\n }\n\n document['x-scalar-watch-mode'] = watchMode\n}\n\n/**\n * Update the document icon and also update the corresponding sidebar entry\n *\n * Does not perform a sidebar rebuild for performance benefit\n */\nexport const updateDocumentIcon = (document: WorkspaceDocument | null, icon: string) => {\n if (!document || !document['x-scalar-navigation']) {\n return\n }\n\n // Update the document icon\n document['x-scalar-icon'] = icon\n // Update the sidebar document icon\n document['x-scalar-navigation'].icon = icon\n}\n"],
5
+ "mappings": "AAKO,MAAM,iBAAiB,CAAC,aAAuC;AACpE,MAAI,CAAC,UAAU;AACb;AAAA,EACF;AAEA,WAAS,iCAAiC,IAAI,CAAC,SAAS,iCAAiC;AAC3F;AAEO,MAAM,kBAAkB,CAAC,UAAoC,cAAuB;AACzF,MAAI,CAAC,UAAU;AACb;AAAA,EACF;AAEA,WAAS,qBAAqB,IAAI;AACpC;AAOO,MAAM,qBAAqB,CAAC,UAAoC,SAAiB;AACtF,MAAI,CAAC,YAAY,CAAC,SAAS,qBAAqB,GAAG;AACjD;AAAA,EACF;AAGA,WAAS,eAAe,IAAI;AAE5B,WAAS,qBAAqB,EAAE,OAAO;AACzC;",
6
6
  "names": []
7
7
  }
@@ -14,10 +14,6 @@ export declare function generateClientMutators(store: WorkspaceStore): {
14
14
  * Returns mutators for the workspace-level configuration.
15
15
  */
16
16
  workspace: () => {
17
- cookieMutators: {
18
- addCookie: (cookie: import("../schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-cookies.js").XScalarClientConfigCookie) => boolean;
19
- deleteCookie: (cookieName: string) => boolean;
20
- };
21
17
  serverMutators: {
22
18
  addServer: (server: ServerObject) => boolean;
23
19
  deleteServer: (url: string) => boolean;
@@ -43,10 +39,6 @@ export declare function generateClientMutators(store: WorkspaceStore): {
43
39
  addSecurityScheme: (name: string, securityScheme: import("../schemas/v3.1/strict/openapi-document.js").SecuritySchemeObject) => boolean;
44
40
  deleteSecurityScheme: (name: string) => boolean;
45
41
  };
46
- cookieMutators: {
47
- addCookie: (cookie: import("../schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-cookies.js").XScalarClientConfigCookie) => boolean;
48
- deleteCookie: (cookieName: string) => boolean;
49
- };
50
42
  serverMutators: {
51
43
  addServer: (server: ServerObject) => boolean;
52
44
  deleteServer: (url: string) => boolean;
@@ -69,10 +61,6 @@ export declare function generateClientMutators(store: WorkspaceStore): {
69
61
  addSecurityScheme: (name: string, securityScheme: import("../schemas/v3.1/strict/openapi-document.js").SecuritySchemeObject) => boolean;
70
62
  deleteSecurityScheme: (name: string) => boolean;
71
63
  };
72
- cookieMutators: {
73
- addCookie: (cookie: import("../schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-cookies.js").XScalarClientConfigCookie) => boolean;
74
- deleteCookie: (cookieName: string) => boolean;
75
- };
76
64
  serverMutators: {
77
65
  addServer: (server: ServerObject) => boolean;
78
66
  deleteServer: (url: string) => boolean;
@@ -80,8 +68,10 @@ export declare function generateClientMutators(store: WorkspaceStore): {
80
68
  };
81
69
  };
82
70
  export { type AuthMeta, deleteSecurityScheme, updateSecurityScheme, updateSelectedAuthTab, updateSelectedScopes, updateSelectedSecuritySchemes, } from './auth.js';
83
- export { toggleDocumentSecurity } from './document.js';
71
+ export { deleteCookie, upsertCookie } from './cookie.js';
72
+ export { toggleSecurity, updateDocumentIcon, updateWatchMode } from './document.js';
84
73
  export { upsertEnvironment, upsertEnvironmentVariable, } from './environment.js';
85
- export { type OperationExampleMeta, type OperationMeta, addOperationParameter, addOperationRequestBodyFormRow, deleteAllOperationParameters, deleteOperationParameter, deleteOperationRequestBodyFormRow, updateOperationMethodDraft as updateOperationMethod, updateOperationParameter, updateOperationPathDraft as updateOperationPath, updateOperationRequestBodyContentType, updateOperationRequestBodyExample, updateOperationRequestBodyFormRow, updateOperationSummary, } from './operation.js';
74
+ export { type OperationExampleMeta, type OperationMeta, addOperationParameter, addOperationRequestBodyFormRow, deleteAllOperationParameters, deleteOperationParameter, deleteOperationRequestBodyFormRow, updateOperationMethod, updateOperationParameter, updateOperationPath, updateOperationRequestBodyContentType, updateOperationRequestBodyExample, updateOperationRequestBodyFormRow, updateOperationSummary, } from './operation.js';
86
75
  export { addServer, deleteServer, updateSelectedServer, updateServer, updateServerVariables, } from './server.js';
76
+ export { updateActiveProxy, updateColorMode, updateTheme } from './workspace.js';
87
77
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mutators/index.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAK9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAA;AAE1E;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,cAAc;IAqGxD;;OAEG;;;;;;;gCA1FwB,YAAY,KAAG,OAAO;gCAatB,MAAM,KAAG,OAAO;;;;;;;IA+E3C;;;OAGG;;;;;;;;;;;;;;;;;;gCA/FwB,YAAY,KAAG,OAAO;gCAatB,MAAM,KAAG,OAAO;;;IAqF3C;;;;OAIG;gBACS,MAAM;;;;;;;;;;;;;;;;;gCAvGS,YAAY,KAAG,OAAO;gCAatB,MAAM,KAAG,OAAO;;;EA4F9C;AAED,OAAO,EACL,KAAK,QAAQ,EACb,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,EACpB,6BAA6B,GAC9B,MAAM,QAAQ,CAAA;AACf,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA;AACnD,OAAO,EACL,iBAAiB,EACjB,yBAAyB,GAC1B,MAAM,eAAe,CAAA;AACtB,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,aAAa,EAClB,qBAAqB,EACrB,8BAA8B,EAC9B,4BAA4B,EAC5B,wBAAwB,EACxB,iCAAiC,EACjC,0BAA0B,IAAI,qBAAqB,EACnD,wBAAwB,EACxB,wBAAwB,IAAI,mBAAmB,EAC/C,qCAAqC,EACrC,iCAAiC,EACjC,iCAAiC,EACjC,sBAAsB,GACvB,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,SAAS,EACT,YAAY,EACZ,oBAAoB,EACpB,YAAY,EACZ,qBAAqB,GACtB,MAAM,UAAU,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mutators/index.ts"],"names":[],"mappings":"AAAA,2EAA2E;A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} from "../mutators/cookie.js";
2
1
  import { getDocument } from "../mutators/helpers.js";
3
2
  import { requestMutators } from "../mutators/request.js";
4
3
  import { securitySchemeMutators } from "../mutators/security-schemes.js";
@@ -41,7 +40,6 @@ function generateClientMutators(store) {
41
40
  return {
42
41
  requestMutators: requestMutators(document),
43
42
  securitySchemeMutators: securitySchemeMutators(document?.components?.securitySchemes),
44
- cookieMutators: cookieMutators(document),
45
43
  serverMutators: serverMutators(document?.servers)
46
44
  };
47
45
  };
@@ -54,7 +52,6 @@ function generateClientMutators(store) {
54
52
  store.workspace["x-scalar-client-config-security-schemes"] = {};
55
53
  }
56
54
  return {
57
- cookieMutators: cookieMutators(store.workspace),
58
55
  serverMutators: serverMutators(store.workspace["x-scalar-client-config-servers"]),
59
56
  securitySchemeMutators: securitySchemeMutators(store.workspace["x-scalar-client-config-security-schemes"])
60
57
  };
@@ -84,7 +81,8 @@ import {
84
81
  updateSelectedScopes,
85
82
  updateSelectedSecuritySchemes
86
83
  } from "./auth.js";
87
- import { toggleDocumentSecurity } from "./document.js";
84
+ import { deleteCookie, upsertCookie } from "./cookie.js";
85
+ import { toggleSecurity, updateDocumentIcon, updateWatchMode } from "./document.js";
88
86
  import {
89
87
  upsertEnvironment,
90
88
  upsertEnvironmentVariable
@@ -95,9 +93,9 @@ import {
95
93
  deleteAllOperationParameters,
96
94
  deleteOperationParameter,
97
95
  deleteOperationRequestBodyFormRow,
98
- updateOperationMethodDraft,
96
+ updateOperationMethod,
99
97
  updateOperationParameter,
100
- updateOperationPathDraft,
98
+ updateOperationPath,
101
99
  updateOperationRequestBodyContentType,
102
100
  updateOperationRequestBodyExample,
103
101
  updateOperationRequestBodyFormRow,
@@ -110,20 +108,25 @@ import {
110
108
  updateServer,
111
109
  updateServerVariables
112
110
  } from "./server.js";
111
+ import { updateActiveProxy, updateColorMode, updateTheme } from "./workspace.js";
113
112
  export {
114
113
  addOperationParameter,
115
114
  addOperationRequestBodyFormRow,
116
115
  addServer,
117
116
  deleteAllOperationParameters,
117
+ deleteCookie,
118
118
  deleteOperationParameter,
119
119
  deleteOperationRequestBodyFormRow,
120
120
  deleteSecurityScheme,
121
121
  deleteServer,
122
122
  generateClientMutators,
123
- toggleDocumentSecurity,
124
- updateOperationMethodDraft as updateOperationMethod,
123
+ toggleSecurity,
124
+ updateActiveProxy,
125
+ updateColorMode,
126
+ updateDocumentIcon,
127
+ updateOperationMethod,
125
128
  updateOperationParameter,
126
- updateOperationPathDraft as updateOperationPath,
129
+ updateOperationPath,
127
130
  updateOperationRequestBodyContentType,
128
131
  updateOperationRequestBodyExample,
129
132
  updateOperationRequestBodyFormRow,
@@ -135,6 +138,9 @@ export {
135
138
  updateSelectedServer,
136
139
  updateServer,
137
140
  updateServerVariables,
141
+ updateTheme,
142
+ updateWatchMode,
143
+ upsertCookie,
138
144
  upsertEnvironment,
139
145
  upsertEnvironmentVariable
140
146
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/mutators/index.ts"],
4
- "sourcesContent": ["/** biome-ignore-all lint/performance/noBarrelFile: Mutators entry point */\nimport type { WorkspaceStore } from '@/client'\nimport { cookieMutators } from '@/mutators/cookie'\nimport { getDocument } from '@/mutators/helpers'\nimport { requestMutators } from '@/mutators/request'\nimport { securitySchemeMutators } from '@/mutators/security-schemes'\nimport type { ServerObject } from '@/schemas/v3.1/strict/openapi-document'\n\n/**\n * Generates a set of mutators for managing OpenAPI document and workspace state.\n *\n * @deprecated use the individual mutators instead, this will be removed after we move fully to the new store\n *\n * @param store - The workspace store containing all documents and workspace-level data\n * @returns An object with mutators for the workspace, the active document, and any named document\n */\nexport function generateClientMutators(store: WorkspaceStore) {\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 */\n 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\n /**\n * Returns mutators for a specific document by name.\n *\n * @param documentName - The name of the document to get mutators for\n * @returns An object containing mutators for requests, request examples, security schemes, environments, and cookies\n */\n const documentMutators = (documentName: string) => {\n const document = getDocument(store, documentName)\n\n if (document) {\n // Make sure the document has a servers array\n if (!document.servers) {\n document.servers = []\n }\n\n // Make sure the document has the securitySchema object\n if (!document.components) {\n document.components = {}\n }\n\n if (!document.components.securitySchemes) {\n document.components.securitySchemes = {}\n }\n }\n\n return {\n requestMutators: requestMutators(document),\n securitySchemeMutators: securitySchemeMutators(document?.components?.securitySchemes),\n cookieMutators: cookieMutators(document),\n serverMutators: serverMutators(document?.servers),\n }\n }\n\n /**\n * Returns mutators for the workspace-level configuration.\n *\n * @returns An object containing mutators for environments and cookies at the workspace level\n */\n const workspaceMutators = () => {\n const workspace = store.workspace\n\n // Make sure the workspace has a servers array\n if (!workspace['x-scalar-client-config-servers']) {\n workspace['x-scalar-client-config-servers'] = []\n }\n\n // Make sure the workspace has the securitySchema object\n if (!store.workspace['x-scalar-client-config-security-schemes']) {\n store.workspace['x-scalar-client-config-security-schemes'] = {}\n }\n\n return {\n cookieMutators: cookieMutators(store.workspace),\n serverMutators: serverMutators(store.workspace['x-scalar-client-config-servers']),\n securitySchemeMutators: securitySchemeMutators(store.workspace['x-scalar-client-config-security-schemes']),\n }\n }\n\n return {\n /**\n * Returns mutators for the workspace-level configuration.\n */\n workspace: () => workspaceMutators(),\n /**\n * Returns mutators for the currently active document.\n * Falls back to the first document if no active document is set.\n */\n active: () =>\n documentMutators(store.workspace['x-scalar-active-document'] ?? Object.keys(store.workspace.documents)[0] ?? ''),\n /**\n * Returns mutators for a specific document by name.\n *\n * @param name - The name of the document\n */\n doc: (name: string) => documentMutators(name),\n }\n}\n\nexport {\n type AuthMeta,\n deleteSecurityScheme,\n updateSecurityScheme,\n updateSelectedAuthTab,\n updateSelectedScopes,\n updateSelectedSecuritySchemes,\n} from './auth'\nexport { toggleDocumentSecurity } from './document'\nexport {\n upsertEnvironment,\n upsertEnvironmentVariable,\n} from './environment'\nexport {\n type OperationExampleMeta,\n type OperationMeta,\n addOperationParameter,\n addOperationRequestBodyFormRow,\n deleteAllOperationParameters,\n deleteOperationParameter,\n deleteOperationRequestBodyFormRow,\n updateOperationMethodDraft as updateOperationMethod,\n updateOperationParameter,\n updateOperationPathDraft as updateOperationPath,\n updateOperationRequestBodyContentType,\n updateOperationRequestBodyExample,\n updateOperationRequestBodyFormRow,\n updateOperationSummary,\n} from './operation'\nexport {\n addServer,\n deleteServer,\n updateSelectedServer,\n updateServer,\n updateServerVariables,\n} from './server'\n"],
5
- "mappings": "AAEA,SAAS,sBAAsB;AAC/B,SAAS,mBAAmB;AAC5B,SAAS,uBAAuB;AAChC,SAAS,8BAA8B;AAWhC,SAAS,uBAAuB,OAAuB;AAO5D,QAAM,iBAAiB,CAAC,WAA4B;AAMlD,UAAMA,aAAY,CAAC,WAAkC;AACnD,UAAI,CAAC,QAAQ;AACX,eAAO;AAAA,MACT;AACA,aAAO,KAAK,MAAM;AAClB,aAAO;AAAA,IACT;AAOA,UAAMC,gBAAe,CAAC,QAAyB;AAC7C,UAAI,CAAC,QAAQ;AACX,eAAO;AAAA,MACT;AACA,YAAM,YAAY,CAAC,GAAG,OAAO,OAAO,CAAC,OAAO,GAAG,QAAQ,GAAG,CAAC;AAC3D,aAAO,OAAO,GAAG,OAAO,MAAM;AAC9B,aAAO,KAAK,GAAG,SAAS;AACxB,aAAO;AAAA,IACT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A,IAMjH,KAAK,CAAC,SAAiB,iBAAiB,IAAI;AAAA,EAC9C;AACF;AAEA;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,8BAA8B;AACvC;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP;AAAA,EAGE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAC8B;AAAA,EAC9B;AAAA,EAC4B;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;",
4
+ "sourcesContent": ["/** biome-ignore-all lint/performance/noBarrelFile: Mutators entry point */\nimport type { WorkspaceStore } from '@/client'\nimport { getDocument } from '@/mutators/helpers'\nimport { requestMutators } from '@/mutators/request'\nimport { securitySchemeMutators } from '@/mutators/security-schemes'\nimport type { ServerObject } from '@/schemas/v3.1/strict/openapi-document'\n\n/**\n * Generates a set of mutators for managing OpenAPI document and workspace state.\n *\n * @deprecated use the individual mutators instead, this will be removed after we move fully to the new store\n *\n * @param store - The workspace store containing all documents and workspace-level data\n * @returns An object with mutators for the workspace, the active document, and any named document\n */\nexport function generateClientMutators(store: WorkspaceStore) {\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 */\n 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\n /**\n * Returns mutators for a specific document by name.\n *\n * @param documentName - The name of the document to get mutators for\n * @returns An object containing mutators for requests, request examples, security schemes, environments, and cookies\n */\n const documentMutators = (documentName: string) => {\n const document = getDocument(store, documentName)\n\n if (document) {\n // Make sure the document has a servers array\n if (!document.servers) {\n document.servers = []\n }\n\n // Make sure the document has the securitySchema object\n if (!document.components) {\n document.components = {}\n }\n\n if (!document.components.securitySchemes) {\n document.components.securitySchemes = {}\n }\n }\n\n return {\n requestMutators: requestMutators(document),\n securitySchemeMutators: securitySchemeMutators(document?.components?.securitySchemes),\n serverMutators: serverMutators(document?.servers),\n }\n }\n\n /**\n * Returns mutators for the workspace-level configuration.\n *\n * @returns An object containing mutators for environments and cookies at the workspace level\n */\n const workspaceMutators = () => {\n const workspace = store.workspace\n\n // Make sure the workspace has a servers array\n if (!workspace['x-scalar-client-config-servers']) {\n workspace['x-scalar-client-config-servers'] = []\n }\n\n // Make sure the workspace has the securitySchema object\n if (!store.workspace['x-scalar-client-config-security-schemes']) {\n store.workspace['x-scalar-client-config-security-schemes'] = {}\n }\n\n return {\n serverMutators: serverMutators(store.workspace['x-scalar-client-config-servers']),\n securitySchemeMutators: securitySchemeMutators(store.workspace['x-scalar-client-config-security-schemes']),\n }\n }\n\n return {\n /**\n * Returns mutators for the workspace-level configuration.\n */\n workspace: () => workspaceMutators(),\n /**\n * Returns mutators for the currently active document.\n * Falls back to the first document if no active document is set.\n */\n active: () =>\n documentMutators(store.workspace['x-scalar-active-document'] ?? Object.keys(store.workspace.documents)[0] ?? ''),\n /**\n * Returns mutators for a specific document by name.\n *\n * @param name - The name of the document\n */\n doc: (name: string) => documentMutators(name),\n }\n}\n\nexport {\n type AuthMeta,\n deleteSecurityScheme,\n updateSecurityScheme,\n updateSelectedAuthTab,\n updateSelectedScopes,\n updateSelectedSecuritySchemes,\n} from './auth'\nexport { deleteCookie, upsertCookie } from './cookie'\nexport { toggleSecurity, updateDocumentIcon, updateWatchMode } from './document'\nexport {\n upsertEnvironment,\n upsertEnvironmentVariable,\n} from './environment'\nexport {\n type OperationExampleMeta,\n type OperationMeta,\n addOperationParameter,\n addOperationRequestBodyFormRow,\n deleteAllOperationParameters,\n deleteOperationParameter,\n deleteOperationRequestBodyFormRow,\n updateOperationMethod,\n updateOperationParameter,\n updateOperationPath,\n updateOperationRequestBodyContentType,\n updateOperationRequestBodyExample,\n updateOperationRequestBodyFormRow,\n updateOperationSummary,\n} from './operation'\nexport {\n addServer,\n deleteServer,\n updateSelectedServer,\n updateServer,\n updateServerVariables,\n} from './server'\nexport { updateActiveProxy, updateColorMode, updateTheme } from './workspace'\n"],
5
+ "mappings": "AAEA,SAAS,mBAAmB;AAC5B,SAAS,uBAAuB;AAChC,SAAS,8BAA8B;AAWhC,SAAS,uBAAuB,OAAuB;AAO5D,QAAM,iBAAiB,CAAC,WAA4B;AAMlD,UAAMA,aAAY,CAAC,WAAkC;AACnD,UAAI,CAAC,QAAQ;AACX,eAAO;AAAA,MACT;AACA,aAAO,KAAK,MAAM;AAClB,aAAO;AAAA,IACT;AAOA,UAAMC,gBAAe,CAAC,QAAyB;AAC7C,UAAI,CAAC,QAAQ;AACX,eAAO;AAAA,MACT;AACA,YAAM,YAAY,CAAC,GAAG,OAAO,OAAO,CAAC,OAAO,GAAG,QAAQ,GAAG,CAAC;AAC3D,aAAO,OAAO,GAAG,OAAO,MAAM;AAC9B,aAAO,KAAK,GAAG,SAAS;AACxB,aAAO;AAAA,IACT;AAEA,WAAO;AAAA,MACL,WAAAD;AAAA,MACA,cAAAC;AAAA,IACF;AAAA,EACF;AAQA,QAAM,mBAAmB,CAAC,iBAAyB;AACjD,UAAM,WAAW,YAAY,OAAO,YAAY;AAEhD,QAAI,UAAU;AAEZ,UAAI,CAAC,SAAS,SAAS;AACrB,iBAAS,UAAU,CAAC;AAAA,MACtB;AAGA,UAAI,CA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