@scalar/workspace-store 0.34.4 → 0.35.2

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 (95) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/dist/client.d.ts.map +1 -1
  3. package/dist/client.js +2 -2
  4. package/dist/client.js.map +2 -2
  5. package/dist/entities/auth/index.d.ts +13 -0
  6. package/dist/entities/auth/index.d.ts.map +1 -1
  7. package/dist/entities/auth/index.js +18 -0
  8. package/dist/entities/auth/index.js.map +2 -2
  9. package/dist/entities/auth/schema.d.ts +24 -19
  10. package/dist/entities/auth/schema.d.ts.map +1 -1
  11. package/dist/entities/auth/schema.js +1 -1
  12. package/dist/entities/auth/schema.js.map +2 -2
  13. package/dist/events/definitions/auth.d.ts +9 -0
  14. package/dist/events/definitions/auth.d.ts.map +1 -1
  15. package/dist/events/definitions/document.d.ts +0 -4
  16. package/dist/events/definitions/document.d.ts.map +1 -1
  17. package/dist/events/definitions/index.d.ts +1 -0
  18. package/dist/events/definitions/index.d.ts.map +1 -1
  19. package/dist/events/definitions/operation.d.ts +7 -9
  20. package/dist/events/definitions/operation.d.ts.map +1 -1
  21. package/dist/events/definitions/server.d.ts +45 -12
  22. package/dist/events/definitions/server.d.ts.map +1 -1
  23. package/dist/events/definitions/ui.d.ts +6 -0
  24. package/dist/events/definitions/ui.d.ts.map +1 -1
  25. package/dist/events/index.d.ts +1 -1
  26. package/dist/events/index.d.ts.map +1 -1
  27. package/dist/events/index.js.map +2 -2
  28. package/dist/mutators/auth.d.ts +1 -0
  29. package/dist/mutators/auth.d.ts.map +1 -1
  30. package/dist/mutators/auth.js +24 -5
  31. package/dist/mutators/auth.js.map +2 -2
  32. package/dist/mutators/document.d.ts +0 -5
  33. package/dist/mutators/document.d.ts.map +1 -1
  34. package/dist/mutators/document.js +0 -8
  35. package/dist/mutators/document.js.map +2 -2
  36. package/dist/mutators/index.d.ts +10 -6
  37. package/dist/mutators/index.d.ts.map +1 -1
  38. package/dist/mutators/operation/index.d.ts +1 -1
  39. package/dist/mutators/operation/index.d.ts.map +1 -1
  40. package/dist/mutators/operation/index.js +3 -3
  41. package/dist/mutators/operation/index.js.map +2 -2
  42. package/dist/mutators/operation/operation.d.ts +4 -6
  43. package/dist/mutators/operation/operation.d.ts.map +1 -1
  44. package/dist/mutators/operation/operation.js +5 -4
  45. package/dist/mutators/operation/operation.js.map +2 -2
  46. package/dist/mutators/server.d.ts +35 -15
  47. package/dist/mutators/server.d.ts.map +1 -1
  48. package/dist/mutators/server.js +63 -31
  49. package/dist/mutators/server.js.map +2 -2
  50. package/dist/plugins/bundler/helpers.d.ts.map +1 -1
  51. package/dist/plugins/bundler/helpers.js +2 -2
  52. package/dist/plugins/bundler/helpers.js.map +2 -2
  53. package/dist/plugins/bundler/index.d.ts.map +1 -1
  54. package/dist/plugins/bundler/index.js +7 -0
  55. package/dist/plugins/bundler/index.js.map +2 -2
  56. package/dist/schemas/extensions/general/x-scalar-active-environment.d.ts.map +1 -0
  57. package/dist/schemas/extensions/general/x-scalar-active-environment.js.map +7 -0
  58. package/dist/schemas/extensions/workspace/index.d.ts +0 -1
  59. package/dist/schemas/extensions/workspace/index.d.ts.map +1 -1
  60. package/dist/schemas/extensions/workspace/index.js +0 -4
  61. package/dist/schemas/extensions/workspace/index.js.map +2 -2
  62. package/dist/schemas/inmemory-workspace.d.ts +14 -11
  63. package/dist/schemas/inmemory-workspace.d.ts.map +1 -1
  64. package/dist/schemas/reference-config/index.d.ts +4 -3
  65. package/dist/schemas/reference-config/index.d.ts.map +1 -1
  66. package/dist/schemas/reference-config/settings.d.ts +4 -3
  67. package/dist/schemas/reference-config/settings.d.ts.map +1 -1
  68. package/dist/schemas/v3.1/strict/openapi-document.d.ts +144 -111
  69. package/dist/schemas/v3.1/strict/openapi-document.d.ts.map +1 -1
  70. package/dist/schemas/v3.1/strict/openapi-document.js +4 -5
  71. package/dist/schemas/v3.1/strict/openapi-document.js.map +2 -2
  72. package/dist/schemas/v3.1/strict/operation.d.ts +4 -1
  73. package/dist/schemas/v3.1/strict/operation.d.ts.map +1 -1
  74. package/dist/schemas/v3.1/strict/operation.js +5 -1
  75. package/dist/schemas/v3.1/strict/operation.js.map +2 -2
  76. package/dist/schemas/workspace.d.ts +13 -10
  77. package/dist/schemas/workspace.d.ts.map +1 -1
  78. package/dist/schemas/workspace.js +3 -3
  79. package/dist/schemas/workspace.js.map +2 -2
  80. package/dist/server.d.ts.map +1 -1
  81. package/dist/server.js +17 -2
  82. package/dist/server.js.map +2 -2
  83. package/package.json +7 -7
  84. package/dist/helpers/json-path-utils.d.ts +0 -23
  85. package/dist/helpers/json-path-utils.d.ts.map +0 -1
  86. package/dist/helpers/json-path-utils.js +0 -16
  87. package/dist/helpers/json-path-utils.js.map +0 -7
  88. package/dist/schemas/extensions/document/x-scalar-set-operation-security.d.ts +0 -13
  89. package/dist/schemas/extensions/document/x-scalar-set-operation-security.d.ts.map +0 -1
  90. package/dist/schemas/extensions/document/x-scalar-set-operation-security.js +0 -8
  91. package/dist/schemas/extensions/document/x-scalar-set-operation-security.js.map +0 -7
  92. package/dist/schemas/extensions/workspace/x-scalar-active-environment.d.ts.map +0 -1
  93. package/dist/schemas/extensions/workspace/x-scalar-active-environment.js.map +0 -7
  94. /package/dist/schemas/extensions/{workspace → general}/x-scalar-active-environment.d.ts +0 -0
  95. /package/dist/schemas/extensions/{workspace → general}/x-scalar-active-environment.js +0 -0
@@ -59,6 +59,16 @@ const updateSelectedSecuritySchemes = async (store, document, { selectedRequirem
59
59
  { selectedIndex: getSelectedIndex(), selectedSchemes: newSelectedSecuritySchemes }
60
60
  );
61
61
  };
62
+ const clearSelectedSecuritySchemes = (store, document, { meta }) => {
63
+ const documentName = document?.["x-scalar-navigation"]?.name;
64
+ if (!documentName) {
65
+ return;
66
+ }
67
+ if (meta.type === "document") {
68
+ return store?.auth.clearAuthSelectedSchemas({ type: "document", documentName });
69
+ }
70
+ return store?.auth.clearAuthSelectedSchemas({ type: "operation", documentName, path: meta.path, method: meta.method });
71
+ };
62
72
  const updateSecurityScheme = (document, { payload, name }) => {
63
73
  const target = getResolvedRef(document?.components?.securitySchemes?.[name]);
64
74
  if (!target) {
@@ -166,13 +176,19 @@ const deleteSecurityScheme = (store, document, { names }) => {
166
176
  names.forEach((name) => {
167
177
  delete target[name];
168
178
  });
169
- const filterSecuritySchemes = (schemes) => {
179
+ const clampIndex = (index, length) => {
180
+ return Math.max(0, Math.min(index, length - 1));
181
+ };
182
+ const filterSecuritySchemes = (_schemes) => {
183
+ const schemes = unpackProxyObject(_schemes, { depth: 1 }) ?? [];
170
184
  return schemes.filter((scheme) => !names.some((name) => Object.keys(scheme).includes(name)));
171
185
  };
172
186
  const documentSelectedSecurity = store?.auth.getAuthSelectedSchemas({ type: "document", documentName });
173
187
  if (documentSelectedSecurity) {
174
- documentSelectedSecurity.selectedSchemes = filterSecuritySchemes(
175
- unpackProxyObject(documentSelectedSecurity.selectedSchemes, { depth: 1 }) ?? []
188
+ documentSelectedSecurity.selectedSchemes = filterSecuritySchemes(documentSelectedSecurity.selectedSchemes);
189
+ documentSelectedSecurity.selectedIndex = clampIndex(
190
+ documentSelectedSecurity.selectedIndex,
191
+ documentSelectedSecurity.selectedSchemes.length
176
192
  );
177
193
  }
178
194
  if (document["security"]) {
@@ -194,8 +210,10 @@ const deleteSecurityScheme = (store, document, { names }) => {
194
210
  method
195
211
  });
196
212
  if (operationSelectedSecurity) {
197
- operationSelectedSecurity.selectedSchemes = filterSecuritySchemes(
198
- unpackProxyObject(operationSelectedSecurity.selectedSchemes, { depth: 1 }) ?? []
213
+ operationSelectedSecurity.selectedSchemes = filterSecuritySchemes(operationSelectedSecurity.selectedSchemes);
214
+ operationSelectedSecurity.selectedIndex = clampIndex(
215
+ operationSelectedSecurity.selectedIndex,
216
+ operationSelectedSecurity.selectedSchemes.length
199
217
  );
200
218
  }
201
219
  });
@@ -207,6 +225,7 @@ const authMutatorsFactory = ({
207
225
  }) => {
208
226
  return {
209
227
  updateSelectedSecuritySchemes: (payload) => updateSelectedSecuritySchemes(store, document, payload),
228
+ clearSelectedSecuritySchemes: (payload) => clearSelectedSecuritySchemes(store, document, payload),
210
229
  updateSecurityScheme: (payload) => updateSecurityScheme(document, payload),
211
230
  updateSecuritySchemeSecrets: (payload) => updateSecuritySchemeSecrets(store, document, payload),
212
231
  clearSecuritySchemeSecrets: (payload) => clearSecuritySchemeSecrets(store, document, payload),
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/mutators/auth.ts"],
4
- "sourcesContent": ["import type { WorkspaceStore } from '@/client'\nimport type { AuthEvents } from '@/events/definitions/auth'\nimport { generateUniqueValue } from '@/helpers/generate-unique-value'\nimport { getResolvedRef } from '@/helpers/get-resolved-ref'\nimport { isNonOptionalSecurityRequirement } from '@/helpers/is-non-optional-security-requirement'\nimport { mergeObjects } from '@/helpers/merge-object'\nimport { unpackProxyObject } from '@/helpers/unpack-proxy'\nimport type { WorkspaceDocument } from '@/schemas'\nimport type { SecurityRequirementObject } from '@/schemas/v3.1/strict/security-requirement'\nimport type { OAuth2Object } from '@/schemas/v3.1/strict/security-scheme'\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 store: WorkspaceStore | null,\n document: WorkspaceDocument | null,\n { selectedRequirements, newSchemes, meta }: AuthEvents['auth:update:selected-security-schemes'],\n) => {\n const documentName = document?.['x-scalar-navigation']?.name\n if (!documentName) {\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 store?.auth.getAuthSelectedSchemas({ type: 'document', documentName })\n }\n\n return store?.auth.getAuthSelectedSchemas({ type: 'operation', documentName, path: meta.path, method: 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 const getSelectedIndex = () => {\n if (!target?.selectedIndex) {\n return 0\n }\n\n if (target.selectedIndex >= newSelectedSecuritySchemes.length) {\n return newSelectedSecuritySchemes.length - 1\n }\n\n return target.selectedIndex\n }\n\n // if (payload. === 'document') {\n if (meta.type === 'document') {\n return store?.auth.setAuthSelectedSchemas(\n { type: 'document', documentName },\n { selectedIndex: getSelectedIndex(), selectedSchemes: newSelectedSecuritySchemes },\n )\n }\n return store?.auth.setAuthSelectedSchemas(\n { type: 'operation', documentName, path: meta.path, method: meta.method },\n { selectedIndex: getSelectedIndex(), selectedSchemes: newSelectedSecuritySchemes },\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\nconst updateSecuritySchemeSecrets = (\n store: WorkspaceStore | null,\n document: WorkspaceDocument | null,\n { payload, name, overwrite = false }: AuthEvents['auth:update:security-scheme-secrets'],\n) => {\n const documentName = document?.['x-scalar-navigation']?.name\n if (!documentName) {\n return\n }\n\n // If we want to remove properties then we should set replace to true\n if (overwrite) {\n store?.auth.setAuthSecrets(documentName, name, payload)\n return\n }\n\n const auth = store?.auth.getAuthSecrets(documentName, name)\n const result = mergeObjects(\n unpackProxyObject(auth, { depth: 1 }) ?? {},\n payload,\n ) as AuthEvents['auth:update:security-scheme-secrets']['payload']\n store?.auth.setAuthSecrets(documentName, name, result)\n}\n\nconst clearSecuritySchemeSecrets = (\n store: WorkspaceStore | null,\n document: WorkspaceDocument | null,\n { name }: AuthEvents['auth:clear:security-scheme-secrets'],\n) => {\n const documentName = document?.['x-scalar-navigation']?.name\n if (!documentName) {\n return\n }\n\n store?.auth.clearAuthSecrets(documentName, name)\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 store: WorkspaceStore | null,\n document: WorkspaceDocument | null,\n { index, meta }: AuthEvents['auth:update:active-index'],\n) => {\n const documentName = document?.['x-scalar-navigation']?.name\n if (!documentName) {\n return\n }\n\n // Ensure the path/method exists in the document\n if (meta.type === 'operation' && document?.paths?.[meta.path]?.[meta.method] === undefined) {\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 store?.auth.getAuthSelectedSchemas({ type: 'document', documentName })\n }\n return store?.auth.getAuthSelectedSchemas({ type: 'operation', documentName, path: meta.path, method: meta.method })\n }\n\n const target = getTarget()\n\n if (!target) {\n if (meta.type === 'document') {\n return store?.auth.setAuthSelectedSchemas(\n { type: 'document', documentName },\n { selectedIndex: index, selectedSchemes: [] },\n )\n }\n return store?.auth.setAuthSelectedSchemas(\n { type: 'operation', documentName, path: meta.path, method: meta.method },\n { selectedIndex: index, selectedSchemes: [] },\n )\n }\n\n // Set the selected index\n target.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. Also allow to add a new scope to the scheme.\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 newScopePayload - The payload to add a new scope with\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 store: WorkspaceStore | null,\n document: WorkspaceDocument | null,\n { id, name, scopes, newScopePayload, meta }: AuthEvents['auth:update:selected-scopes'],\n) => {\n const documentName = document?.['x-scalar-navigation']?.name\n if (!documentName) {\n return\n }\n\n // Determine the target object (document or the operation)\n const getTarget = () => {\n if (meta.type === 'document') {\n return store?.auth.getAuthSelectedSchemas({ type: 'document', documentName })\n }\n return store?.auth.getAuthSelectedSchemas({ type: 'operation', documentName, path: meta.path, method: meta.method })\n }\n\n const target = getTarget()\n if (!target) {\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 = target.selectedSchemes.find((scheme) => JSON.stringify(Object.keys(scheme)) === JSON.stringify(id))\n\n // If the scheme is optional, do nothing as it cannot have scopes\n if (!isNonOptionalSecurityRequirement(scheme)) {\n return\n }\n\n // If we have a new scope payload, add it to the scheme\n if (newScopePayload) {\n const securityScheme = getResolvedRef(document.components?.securitySchemes?.[name])\n const flow = (securityScheme as OAuth2Object)?.flows?.[newScopePayload?.flowType]\n if (!flow) {\n return\n }\n flow.scopes ||= {}\n\n flow.scopes[newScopePayload.name] = newScopePayload.description\n scheme[name] = [...scopes, newScopePayload.name]\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 store: WorkspaceStore | null,\n document: WorkspaceDocument | null,\n { names }: AuthEvents['auth:delete:security-scheme'],\n) => {\n const documentName = document?.['x-scalar-navigation']?.name\n if (!documentName) {\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 const documentSelectedSecurity = store?.auth.getAuthSelectedSchemas({ type: 'document', documentName })\n\n // -- Remove from document-level `x-scalar-selected-security` extension, if present\n if (documentSelectedSecurity) {\n documentSelectedSecurity.selectedSchemes = filterSecuritySchemes(\n unpackProxyObject(documentSelectedSecurity.selectedSchemes, { depth: 1 }) ?? [],\n )\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.entries(document.paths ?? {}).forEach(([path, pathItemObject]) => {\n Object.entries(pathItemObject).forEach(([method, 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 const operationSelectedSecurity = store?.auth.getAuthSelectedSchemas({\n type: 'operation',\n documentName,\n path,\n method,\n })\n if (operationSelectedSecurity) {\n operationSelectedSecurity.selectedSchemes = filterSecuritySchemes(\n unpackProxyObject(operationSelectedSecurity.selectedSchemes, { depth: 1 }) ?? [],\n )\n }\n })\n })\n}\n\nexport const authMutatorsFactory = ({\n document,\n store,\n}: {\n document: WorkspaceDocument | null\n store: WorkspaceStore | null\n}) => {\n return {\n updateSelectedSecuritySchemes: (payload: AuthEvents['auth:update:selected-security-schemes']) =>\n updateSelectedSecuritySchemes(store, document, payload),\n updateSecurityScheme: (payload: AuthEvents['auth:update:security-scheme']) =>\n updateSecurityScheme(document, payload),\n updateSecuritySchemeSecrets: (payload: AuthEvents['auth:update:security-scheme-secrets']) =>\n updateSecuritySchemeSecrets(store, document, payload),\n clearSecuritySchemeSecrets: (payload: AuthEvents['auth:clear:security-scheme-secrets']) =>\n clearSecuritySchemeSecrets(store, document, payload),\n updateSelectedAuthTab: (payload: AuthEvents['auth:update:active-index']) =>\n updateSelectedAuthTab(store, document, payload),\n updateSelectedScopes: (payload: AuthEvents['auth:update:selected-scopes']) =>\n updateSelectedScopes(store, document, payload),\n deleteSecurityScheme: (payload: AuthEvents['auth:delete:security-scheme']) =>\n deleteSecurityScheme(store, document, payload),\n }\n}\n"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A4B,CAAC,YAC3B,2BAA2B,OAAO,UAAU,OAAO;AAAA,IACrD,uBAAuB,CAAC,YACtB,sBAAsB,OAAO,UAAU,OAAO;AAAA,IAChD,sBAAsB,CAAC,YACrB,qBAAqB,OAAO,UAAU,OAAO;AAAA,IAC/C,sBAAsB,CAAC,YACrB,qBAAqB,OAAO,UAAU,OAAO;AAAA,EACjD;AACF;",
4
+ "sourcesContent": ["import type { WorkspaceStore } from '@/client'\nimport type { AuthEvents } from '@/events/definitions/auth'\nimport { generateUniqueValue } from '@/helpers/generate-unique-value'\nimport { getResolvedRef } from '@/helpers/get-resolved-ref'\nimport { isNonOptionalSecurityRequirement } from '@/helpers/is-non-optional-security-requirement'\nimport { mergeObjects } from '@/helpers/merge-object'\nimport { unpackProxyObject } from '@/helpers/unpack-proxy'\nimport type { WorkspaceDocument } from '@/schemas'\nimport type { SecurityRequirementObject } from '@/schemas/v3.1/strict/security-requirement'\nimport type { OAuth2Object } from '@/schemas/v3.1/strict/security-scheme'\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 store: WorkspaceStore | null,\n document: WorkspaceDocument | null,\n { selectedRequirements, newSchemes, meta }: AuthEvents['auth:update:selected-security-schemes'],\n) => {\n const documentName = document?.['x-scalar-navigation']?.name\n if (!documentName) {\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 store?.auth.getAuthSelectedSchemas({ type: 'document', documentName })\n }\n\n return store?.auth.getAuthSelectedSchemas({ type: 'operation', documentName, path: meta.path, method: 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 const getSelectedIndex = () => {\n if (!target?.selectedIndex) {\n return 0\n }\n\n if (target.selectedIndex >= newSelectedSecuritySchemes.length) {\n return newSelectedSecuritySchemes.length - 1\n }\n\n return target.selectedIndex\n }\n\n // if (payload. === 'document') {\n if (meta.type === 'document') {\n return store?.auth.setAuthSelectedSchemas(\n { type: 'document', documentName },\n { selectedIndex: getSelectedIndex(), selectedSchemes: newSelectedSecuritySchemes },\n )\n }\n return store?.auth.setAuthSelectedSchemas(\n { type: 'operation', documentName, path: meta.path, method: meta.method },\n { selectedIndex: getSelectedIndex(), selectedSchemes: newSelectedSecuritySchemes },\n )\n}\n\n/**\n * Clears the selected security schemes from the workspace store for a document or operation.\n * This function will remove any selection state related to security (auth) for either the entire document\n * or for a specific operation if meta.type is 'operation'.\n * If the document name cannot be determined, nothing happens.\n */\nconst clearSelectedSecuritySchemes = (\n store: WorkspaceStore | null,\n document: WorkspaceDocument | null,\n { meta }: AuthEvents['auth:clear:selected-security-schemes'],\n) => {\n const documentName = document?.['x-scalar-navigation']?.name\n if (!documentName) {\n return\n }\n\n if (meta.type === 'document') {\n return store?.auth.clearAuthSelectedSchemas({ type: 'document', documentName })\n }\n return store?.auth.clearAuthSelectedSchemas({ type: 'operation', documentName, path: meta.path, method: meta.method })\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\nconst updateSecuritySchemeSecrets = (\n store: WorkspaceStore | null,\n document: WorkspaceDocument | null,\n { payload, name, overwrite = false }: AuthEvents['auth:update:security-scheme-secrets'],\n) => {\n const documentName = document?.['x-scalar-navigation']?.name\n if (!documentName) {\n return\n }\n\n // If we want to remove properties then we should set replace to true\n if (overwrite) {\n store?.auth.setAuthSecrets(documentName, name, payload)\n return\n }\n\n const auth = store?.auth.getAuthSecrets(documentName, name)\n const result = mergeObjects(\n unpackProxyObject(auth, { depth: 1 }) ?? {},\n payload,\n ) as AuthEvents['auth:update:security-scheme-secrets']['payload']\n store?.auth.setAuthSecrets(documentName, name, result)\n}\n\nconst clearSecuritySchemeSecrets = (\n store: WorkspaceStore | null,\n document: WorkspaceDocument | null,\n { name }: AuthEvents['auth:clear:security-scheme-secrets'],\n) => {\n const documentName = document?.['x-scalar-navigation']?.name\n if (!documentName) {\n return\n }\n\n store?.auth.clearAuthSecrets(documentName, name)\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 store: WorkspaceStore | null,\n document: WorkspaceDocument | null,\n { index, meta }: AuthEvents['auth:update:active-index'],\n) => {\n const documentName = document?.['x-scalar-navigation']?.name\n if (!documentName) {\n return\n }\n\n // Ensure the path/method exists in the document\n if (meta.type === 'operation' && document?.paths?.[meta.path]?.[meta.method] === undefined) {\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 store?.auth.getAuthSelectedSchemas({ type: 'document', documentName })\n }\n return store?.auth.getAuthSelectedSchemas({ type: 'operation', documentName, path: meta.path, method: meta.method })\n }\n\n const target = getTarget()\n\n if (!target) {\n if (meta.type === 'document') {\n return store?.auth.setAuthSelectedSchemas(\n { type: 'document', documentName },\n { selectedIndex: index, selectedSchemes: [] },\n )\n }\n return store?.auth.setAuthSelectedSchemas(\n { type: 'operation', documentName, path: meta.path, method: meta.method },\n { selectedIndex: index, selectedSchemes: [] },\n )\n }\n\n // Set the selected index\n target.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. Also allow to add a new scope to the scheme.\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 newScopePayload - The payload to add a new scope with\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 store: WorkspaceStore | null,\n document: WorkspaceDocument | null,\n { id, name, scopes, newScopePayload, meta }: AuthEvents['auth:update:selected-scopes'],\n) => {\n const documentName = document?.['x-scalar-navigation']?.name\n if (!documentName) {\n return\n }\n\n // Determine the target object (document or the operation)\n const getTarget = () => {\n if (meta.type === 'document') {\n return store?.auth.getAuthSelectedSchemas({ type: 'document', documentName })\n }\n return store?.auth.getAuthSelectedSchemas({ type: 'operation', documentName, path: meta.path, method: meta.method })\n }\n\n const target = getTarget()\n if (!target) {\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 = target.selectedSchemes.find((scheme) => JSON.stringify(Object.keys(scheme)) === JSON.stringify(id))\n\n // If the scheme is optional, do nothing as it cannot have scopes\n if (!isNonOptionalSecurityRequirement(scheme)) {\n return\n }\n\n // If we have a new scope payload, add it to the scheme\n if (newScopePayload) {\n const securityScheme = getResolvedRef(document.components?.securitySchemes?.[name])\n const flow = (securityScheme as OAuth2Object)?.flows?.[newScopePayload?.flowType]\n if (!flow) {\n return\n }\n flow.scopes ||= {}\n\n flow.scopes[newScopePayload.name] = newScopePayload.description\n scheme[name] = [...scopes, newScopePayload.name]\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 store: WorkspaceStore | null,\n document: WorkspaceDocument | null,\n { names }: AuthEvents['auth:delete:security-scheme'],\n) => {\n const documentName = document?.['x-scalar-navigation']?.name\n if (!documentName) {\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 const clampIndex = (index: number, length: number) => {\n return Math.max(0, Math.min(index, length - 1))\n }\n\n // Function to remove any security requirement objects that reference given scheme names.\n const filterSecuritySchemes = (_schemes: SecurityRequirementObject[]) => {\n const schemes = unpackProxyObject(_schemes, { depth: 1 }) ?? []\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 const documentSelectedSecurity = store?.auth.getAuthSelectedSchemas({ type: 'document', documentName })\n\n // -- Remove from document-level `x-scalar-selected-security` extension, if present\n if (documentSelectedSecurity) {\n documentSelectedSecurity.selectedSchemes = filterSecuritySchemes(documentSelectedSecurity.selectedSchemes)\n documentSelectedSecurity.selectedIndex = clampIndex(\n documentSelectedSecurity.selectedIndex,\n documentSelectedSecurity.selectedSchemes.length,\n )\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.entries(document.paths ?? {}).forEach(([path, pathItemObject]) => {\n Object.entries(pathItemObject).forEach(([method, 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 const operationSelectedSecurity = store?.auth.getAuthSelectedSchemas({\n type: 'operation',\n documentName,\n path,\n method,\n })\n if (operationSelectedSecurity) {\n operationSelectedSecurity.selectedSchemes = filterSecuritySchemes(operationSelectedSecurity.selectedSchemes)\n operationSelectedSecurity.selectedIndex = clampIndex(\n operationSelectedSecurity.selectedIndex,\n operationSelectedSecurity.selectedSchemes.length,\n )\n }\n })\n })\n}\n\nexport const authMutatorsFactory = ({\n document,\n store,\n}: {\n document: WorkspaceDocument | null\n store: WorkspaceStore | null\n}) => {\n return {\n updateSelectedSecuritySchemes: (payload: AuthEvents['auth:update:selected-security-schemes']) =>\n updateSelectedSecuritySchemes(store, document, payload),\n clearSelectedSecuritySchemes: (payload: AuthEvents['auth:clear:selected-security-schemes']) =>\n clearSelectedSecuritySchemes(store, document, payload),\n updateSecurityScheme: (payload: AuthEvents['auth:update:security-scheme']) =>\n updateSecurityScheme(document, payload),\n updateSecuritySchemeSecrets: (payload: AuthEvents['auth:update:security-scheme-secrets']) =>\n updateSecuritySchemeSecrets(store, document, payload),\n clearSecuritySchemeSecrets: (payload: AuthEvents['auth:clear:security-scheme-secrets']) =>\n clearSecuritySchemeSecrets(store, document, payload),\n updateSelectedAuthTab: (payload: AuthEvents['auth:update:active-index']) =>\n updateSelectedAuthTab(store, document, payload),\n updateSelectedScopes: (payload: AuthEvents['auth:update:selected-scopes']) =>\n updateSelectedScopes(store, document, payload),\n deleteSecurityScheme: (payload: AuthEvents['auth:delete:security-scheme']) =>\n deleteSecurityScheme(store, document, payload),\n }\n}\n"],
5
+ "mappings": "AAEA,SAAS,2BAA2B;AACpC,SAAS,sBAAsB;AAC/B,SAAS,wCAAwC;AACjD,SAAS,oBAAoB;AAC7B,SAAS,yBAAyB;AA6B3B,MAAM,gCAAgC,OAC3C,OACA,UACA,EAAE,sBAAsB,YAAY,KAAK,MACtC;AACH,QAAM,eAAe,WAAW,qBAAqB,GAAG;AACxD,MAAI,CAAC,cAAc;AACjB;AAAA,EACF;AAGA,QAAM,YAAY,MAAM;AACtB,QAAI,KAAK,SAAS,YAAY;AAC5B,aAAO,OAAO,KAAK,uBAAuB,EAAE,MAAM,YAAY,aAAa,CAAC;AAAA,IAC9E;AAEA,WAAO,OAAO,KAAK,uBAAuB,EAAE,MAAM,aAAa,cAAc,MAAM,KAAK,MAAM,QAAQ,KAAK,OAAO,CAAC;AAAA,EACrH;AAEA,QAAM,8BAA8B,MAAM,QAAQ;AAAA,IAChD,WAAW,IAAI,OAAO,cAAc;AAClC,YAAM,mBAAmB,MAAM,oBAAoB;AAAA,QACjD,cAAc,UAAU;AAAA,QACxB,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BAA2B,OAAO,UAAU,OAAO;AAAA,IACrD,uBAAuB,CAAC,YACtB,sBAAsB,OAAO,UAAU,OAAO;AAAA,IAChD,sBAAsB,CAAC,YACrB,qBAAqB,OAAO,UAAU,OAAO;AAAA,IAC/C,sBAAsB,CAAC,YACrB,qBAAqB,OAAO,UAAU,OAAO;AAAA,EACjD;AACF;",
6
6
  "names": ["scheme"]
7
7
  }
@@ -1,10 +1,6 @@
1
1
  import type { WorkspaceStore } from '../client.js';
2
2
  import type { DocumentEvents } from '../events/definitions/document.js';
3
3
  import type { WorkspaceDocument } from '../schemas.js';
4
- /**
5
- * Toggle setting selected security schemes at the operation level
6
- */
7
- export declare const toggleSecurity: (document: WorkspaceDocument | null) => void;
8
4
  /**
9
5
  * Updates the "watch mode" state of the given document.
10
6
  *
@@ -53,7 +49,6 @@ export declare const documentMutatorsFactory: ({ document, store, }: {
53
49
  document: WorkspaceDocument | null;
54
50
  store: WorkspaceStore | null;
55
51
  }) => {
56
- toggleSecurity: () => void;
57
52
  updateDocumentInfo: (payload: DocumentEvents["document:update:info"]) => void;
58
53
  updateWatchMode: (payload: DocumentEvents["document:update:watch-mode"]) => void;
59
54
  updateDocumentIcon: (payload: DocumentEvents["document:update:icon"]) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../src/mutators/document.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AAEnE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAElD;;GAEG;AACH,eAAO,MAAM,cAAc,GAAI,UAAU,iBAAiB,GAAG,IAAI,SAMhE,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,GAAI,UAAU,iBAAiB,GAAG,IAAI,EAAE,WAAW,OAAO,SAOrF,CAAA;AAED;;;;;;;;;GASG;AACH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AAsB,CAAC,SAahD,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAI,UAAU,iBAAiB,GAAG,IAAI,EAAE,MAAM,MAAM,SASlF,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,mBAAmB,GAC9B,OAAO,cAAc,GAAG,IAAI,EAC5B,SAAS,cAAc,CAAC,gCAAgC,CAAC,kBA8B1D,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,OAAO,cAAc,GAAG,IAAI,EAAE,SAAS,cAAc,CAAC,0BAA0B,CAAC,SAM/G,CAAA;AAED,eAAO,MAAM,uBAAuB,GAAI,sBAGrC;IACD,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAAA;IAClC,KAAK,EAAE,cAAc,GAAG,IAAI,CAAA;CAC7B;kCAEiC,cAAc,CAAC,sBAAsB,CAAC;+BACzC,cAAc,CAAC,4BAA4B,CAAC;kCACzC,cAAc,CAAC,sBAAsB,CAAC;mCACrC,cAAc,CAAC,gCAAgC,CAAC;8BAErD,cAAc,CAAC,0BAA0B,CAAC;CAEvE,CAAA"}
@@ -1,10 +1,4 @@
1
1
  import { mergeObjects } from "../helpers/merge-object.js";
2
- const toggleSecurity = (document) => {
3
- if (!document) {
4
- return;
5
- }
6
- document["x-scalar-set-operation-security"] = !document["x-scalar-set-operation-security"];
7
- };
8
2
  const updateWatchMode = (document, watchMode) => {
9
3
  if (!document) {
10
4
  return;
@@ -61,7 +55,6 @@ const documentMutatorsFactory = ({
61
55
  store
62
56
  }) => {
63
57
  return {
64
- toggleSecurity: () => toggleSecurity(document),
65
58
  updateDocumentInfo: (payload) => updateDocumentInfo(document, payload),
66
59
  updateWatchMode: (payload) => updateWatchMode(document, payload),
67
60
  updateDocumentIcon: (payload) => updateDocumentIcon(document, payload),
@@ -73,7 +66,6 @@ export {
73
66
  createEmptyDocument,
74
67
  deleteDocument,
75
68
  documentMutatorsFactory,
76
- toggleSecurity,
77
69
  updateDocumentIcon,
78
70
  updateDocumentInfo,
79
71
  updateWatchMode
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/mutators/document.ts"],
4
- "sourcesContent": ["import type { WorkspaceStore } from '@/client'\nimport type { DocumentEvents } from '@/events/definitions/document'\nimport { mergeObjects } from '@/helpers/merge-object'\nimport 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\n/**\n * Updates the \"watch mode\" state of the given document.\n *\n * @param document WorkspaceDocument or null \u2013 The document to modify.\n * @param watchMode boolean \u2013 True enables watch mode, false disables it.\n *\n * If document is null, does nothing.\n */\nexport const updateWatchMode = (document: WorkspaceDocument | null, watchMode: boolean) => {\n if (!document) {\n return\n }\n\n // Set (or unset) the x-scalar-watch-mode property on the document\n document['x-scalar-watch-mode'] = watchMode\n}\n\n/**\n * Updates the document's info object (typically, title, description, version, etc.).\n *\n * Uses a shallow merge: only properties present in payload will be overwritten or added.\n *\n * @param document WorkspaceDocument | null \u2013 The document whose info should be updated.\n * @param payload DocumentEvents['document:update:info'] \u2013 Partial info fields to update/merge.\n *\n * If document is null, does nothing.\n */\nexport const updateDocumentInfo = (\n document: WorkspaceDocument | null,\n payload: DocumentEvents['document:update:info'],\n) => {\n if (!document) {\n return\n }\n // Merge the given payload into the document's info object\n mergeObjects(document.info, payload)\n\n // Update the document title if it is present and the navigation object is present\n // We do this because we don't want to rebuild the entire navigation object if only the title is changed\n if (payload.title && document['x-scalar-navigation']) {\n document['x-scalar-navigation'].title = payload.title\n }\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\n/**\n * Creates an empty OpenAPI document and adds it to the workspace.\n *\n * - If the store is null, this is a no-op.\n * - The document name must be unique; if already present, callback is called with `false`.\n * - On success, a new OpenAPI 3.1.0 document is added with a basic path and info.\n * - Callback is called with `true` if document is created.\n *\n * @param store WorkspaceStore | null \u2013 The workspace store to add the document to.\n * @param payload DocumentEvents['document:create:empty-document'] \u2013 Contains name, icon, and callback.\n */\nexport const createEmptyDocument = async (\n store: WorkspaceStore | null,\n payload: DocumentEvents['document:create:empty-document'],\n) => {\n if (!store) {\n return\n }\n\n // Check if the document already exists by name for uniqueness\n if (store.workspace.documents[payload.name]) {\n // Document name already exists, call callback with false\n payload.callback?.(false)\n return\n }\n\n // Add a new empty OpenAPI 3.1.0 document with minimal info and icon\n await store.addDocument({\n name: payload.name,\n document: {\n openapi: '3.1.0',\n info: { title: payload.name, version: '1.0.0' },\n paths: {\n '/': {\n get: {},\n },\n },\n 'x-scalar-icon': payload.icon,\n },\n })\n\n // Notify success via callback\n payload.callback?.(true)\n}\n\n/**\n * Deletes a document from the workspace by its name.\n *\n * Safely no-ops if the store is null.\n */\nexport const deleteDocument = (store: WorkspaceStore | null, payload: DocumentEvents['document:delete:document']) => {\n if (!store) {\n return\n }\n\n store.deleteDocument(payload.name)\n}\n\nexport const documentMutatorsFactory = ({\n document,\n store,\n}: {\n document: WorkspaceDocument | null\n store: WorkspaceStore | null\n}) => {\n return {\n toggleSecurity: () => toggleSecurity(document),\n updateDocumentInfo: (payload: DocumentEvents['document:update:info']) => updateDocumentInfo(document, payload),\n updateWatchMode: (payload: DocumentEvents['document:update:watch-mode']) => updateWatchMode(document, payload),\n updateDocumentIcon: (payload: DocumentEvents['document:update:icon']) => updateDocumentIcon(document, payload),\n createEmptyDocument: (payload: DocumentEvents['document:create:empty-document']) =>\n createEmptyDocument(store, payload),\n deleteDocument: (payload: DocumentEvents['document:delete:document']) => deleteDocument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A,QAAM,eAAe,QAAQ,IAAI;AACnC;AAEO,MAAM,0BAA0B,CAAC;AAAA,EACtC;AAAA,EACA;AACF,MAGM;AACJ,SAAO;AAAA,IACL,gBAAgB,MAAM,eAAe,QAAQ;AAAA,IAC7C,oBAAoB,CAAC,YAAoD,mBAAmB,UAAU,OAAO;AAAA,IAC7G,iBAAiB,CAAC,YAA0D,gBAAgB,UAAU,OAAO;AAAA,IAC7G,oBAAoB,CAAC,YAAoD,mBAAmB,UAAU,OAAO;AAAA,IAC7G,qBAAqB,CAAC,YACpB,oBAAoB,OAAO,OAAO;AAAA,IACpC,gBAAgB,CAAC,YAAwD,eAAe,OAAO,OAAO;AAAA,EACxG;AACF;",
4
+ "sourcesContent": ["import type { WorkspaceStore } from '@/client'\nimport type { DocumentEvents } from '@/events/definitions/document'\nimport { mergeObjects } from '@/helpers/merge-object'\nimport type { WorkspaceDocument } from '@/schemas'\n\n/**\n * Updates the \"watch mode\" state of the given document.\n *\n * @param document WorkspaceDocument or null \u2013 The document to modify.\n * @param watchMode boolean \u2013 True enables watch mode, false disables it.\n *\n * If document is null, does nothing.\n */\nexport const updateWatchMode = (document: WorkspaceDocument | null, watchMode: boolean) => {\n if (!document) {\n return\n }\n\n // Set (or unset) the x-scalar-watch-mode property on the document\n document['x-scalar-watch-mode'] = watchMode\n}\n\n/**\n * Updates the document's info object (typically, title, description, version, etc.).\n *\n * Uses a shallow merge: only properties present in payload will be overwritten or added.\n *\n * @param document WorkspaceDocument | null \u2013 The document whose info should be updated.\n * @param payload DocumentEvents['document:update:info'] \u2013 Partial info fields to update/merge.\n *\n * If document is null, does nothing.\n */\nexport const updateDocumentInfo = (\n document: WorkspaceDocument | null,\n payload: DocumentEvents['document:update:info'],\n) => {\n if (!document) {\n return\n }\n // Merge the given payload into the document's info object\n mergeObjects(document.info, payload)\n\n // Update the document title if it is present and the navigation object is present\n // We do this because we don't want to rebuild the entire navigation object if only the title is changed\n if (payload.title && document['x-scalar-navigation']) {\n document['x-scalar-navigation'].title = payload.title\n }\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\n/**\n * Creates an empty OpenAPI document and adds it to the workspace.\n *\n * - If the store is null, this is a no-op.\n * - The document name must be unique; if already present, callback is called with `false`.\n * - On success, a new OpenAPI 3.1.0 document is added with a basic path and info.\n * - Callback is called with `true` if document is created.\n *\n * @param store WorkspaceStore | null \u2013 The workspace store to add the document to.\n * @param payload DocumentEvents['document:create:empty-document'] \u2013 Contains name, icon, and callback.\n */\nexport const createEmptyDocument = async (\n store: WorkspaceStore | null,\n payload: DocumentEvents['document:create:empty-document'],\n) => {\n if (!store) {\n return\n }\n\n // Check if the document already exists by name for uniqueness\n if (store.workspace.documents[payload.name]) {\n // Document name already exists, call callback with false\n payload.callback?.(false)\n return\n }\n\n // Add a new empty OpenAPI 3.1.0 document with minimal info and icon\n await store.addDocument({\n name: payload.name,\n document: {\n openapi: '3.1.0',\n info: { title: payload.name, version: '1.0.0' },\n paths: {\n '/': {\n get: {},\n },\n },\n 'x-scalar-icon': payload.icon,\n },\n })\n\n // Notify success via callback\n payload.callback?.(true)\n}\n\n/**\n * Deletes a document from the workspace by its name.\n *\n * Safely no-ops if the store is null.\n */\nexport const deleteDocument = (store: WorkspaceStore | null, payload: DocumentEvents['document:delete:document']) => {\n if (!store) {\n return\n }\n\n store.deleteDocument(payload.name)\n}\n\nexport const documentMutatorsFactory = ({\n document,\n store,\n}: {\n document: WorkspaceDocument | null\n store: WorkspaceStore | null\n}) => {\n return {\n updateDocumentInfo: (payload: DocumentEvents['document:update:info']) => updateDocumentInfo(document, payload),\n updateWatchMode: (payload: DocumentEvents['document:update:watch-mode']) => updateWatchMode(document, payload),\n updateDocumentIcon: (payload: DocumentEvents['document:update:icon']) => updateDocumentIcon(document, payload),\n createEmptyDocument: (payload: DocumentEvents['document:create:empty-document']) =>\n createEmptyDocument(store, payload),\n deleteDocument: (payload: DocumentEvents['document:delete:document']) => deleteDocument(store, payload),\n }\n}\n"],
5
+ "mappings": "AAEA,SAAS,oBAAoB;AAWtB,MAAM,kBAAkB,CAAC,UAAoC,cAAuB;AACzF,MAAI,CAAC,UAAU;AACb;AAAA,EACF;AAGA,WAAS,qBAAqB,IAAI;AACpC;AAYO,MAAM,qBAAqB,CAChC,UACA,YACG;AACH,MAAI,CAAC,UAAU;AACb;AAAA,EACF;AAEA,eAAa,SAAS,MAAM,OAAO;AAInC,MAAI,QAAQ,SAAS,SAAS,qBAAqB,GAAG;AACpD,aAAS,qBAAqB,EAAE,QAAQ,QAAQ;AAAA,EAClD;AACF;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;AAaO,MAAM,sBAAsB,OACjC,OACA,YACG;AACH,MAAI,CAAC,OAAO;AACV;AAAA,EACF;AAGA,MAAI,MAAM,UAAU,UAAU,QAAQ,IAAI,GAAG;AAE3C,YAAQ,WAAW,KAAK;AACxB;AAAA,EACF;AAGA,QAAM,MAAM,YAAY;AAAA,IACtB,MAAM,QAAQ;AAAA,IACd,UAAU;AAAA,MACR,SAAS;AAAA,MACT,MAAM,EAAE,OAAO,QAAQ,MAAM,SAAS,QAAQ;AAAA,MAC9C,OAAO;AAAA,QACL,KAAK;AAAA,UACH,KAAK,CAAC;AAAA,QACR;AAAA,MACF;AAAA,MACA,iBAAiB,QAAQ;AAAA,IAC3B;AAAA,EACF,CAAC;AAGD,UAAQ,WAAW,IAAI;AACzB;AAOO,MAAM,iBAAiB,CAAC,OAA8B,YAAwD;AACnH,MAAI,CAAC,OAAO;AACV;AAAA,EACF;AAEA,QAAM,eAAe,QAAQ,IAAI;AACnC;AAEO,MAAM,0BAA0B,CAAC;AAAA,EACtC;AAAA,EACA;AACF,MAGM;AACJ,SAAO;AAAA,IACL,oBAAoB,CAAC,YAAoD,mBAAmB,UAAU,OAAO;AAAA,IAC7G,iBAAiB,CAAC,YAA0D,gBAAgB,UAAU,OAAO;AAAA,IAC7G,oBAAoB,CAAC,YAAoD,mBAAmB,UAAU,OAAO;AAAA,IAC7G,qBAAqB,CAAC,YACpB,oBAAoB,OAAO,OAAO;AAAA,IACpC,gBAAgB,CAAC,YAAwD,eAAe,OAAO,OAAO;AAAA,EACxG;AACF;",
6
6
  "names": []
7
7
  }
@@ -64,6 +64,7 @@ export declare function generateClientMutators(store: WorkspaceStore | null): {
64
64
  active: () => {
65
65
  auth: {
66
66
  updateSelectedSecuritySchemes: (payload: import("../events/definitions/auth.js").AuthEvents["auth:update:selected-security-schemes"]) => Promise<void>;
67
+ clearSelectedSecuritySchemes: (payload: import("../events/definitions/auth.js").AuthEvents["auth:clear:selected-security-schemes"]) => void;
67
68
  updateSecurityScheme: (payload: import("../events/definitions/auth.js").AuthEvents["auth:update:security-scheme"]) => import("../schemas/v3.1/strict/security-scheme.js").ApiKeyObject | import("../schemas/v3.1/strict/security-scheme.js").HttpObject | import("../schemas/v3.1/strict/security-scheme.js").OAuth2Object | import("../schemas/v3.1/strict/security-scheme.js").OpenIdConnectObject | undefined;
68
69
  updateSecuritySchemeSecrets: (payload: import("../events/definitions/auth.js").AuthEvents["auth:update:security-scheme-secrets"]) => void;
69
70
  clearSecuritySchemeSecrets: (payload: import("../events/definitions/auth.js").AuthEvents["auth:clear:security-scheme-secrets"]) => void;
@@ -82,7 +83,6 @@ export declare function generateClientMutators(store: WorkspaceStore | null): {
82
83
  }) => boolean;
83
84
  };
84
85
  document: {
85
- toggleSecurity: () => void;
86
86
  updateDocumentInfo: (payload: import("../events/definitions/document.js").DocumentEvents["document:update:info"]) => void;
87
87
  updateWatchMode: (payload: import("../events/definitions/document.js").DocumentEvents["document:update:watch-mode"]) => void;
88
88
  updateDocumentIcon: (payload: import("../events/definitions/document.js").DocumentEvents["document:update:icon"]) => void;
@@ -91,7 +91,7 @@ export declare function generateClientMutators(store: WorkspaceStore | null): {
91
91
  };
92
92
  operation: {
93
93
  createOperation: (payload: import("../events/index.js").OperationEvents["operation:create:operation"]) => string | undefined;
94
- updateOperationSummary: (payload: import("../events/index.js").OperationEvents["operation:update:summary"]) => void;
94
+ updateOperationMeta: (payload: import("../events/index.js").OperationEvents["operation:update:meta"]) => void;
95
95
  updateOperationPathMethod: (payload: import("../events/index.js").OperationEvents["operation:update:pathMethod"]) => void;
96
96
  deleteOperation: (payload: import("../events/index.js").OperationEvents["operation:delete:operation"]) => void;
97
97
  createOperationDraftExample: (payload: import("../events/index.js").OperationEvents["operation:create:draft-example"]) => void;
@@ -108,9 +108,11 @@ export declare function generateClientMutators(store: WorkspaceStore | null): {
108
108
  reloadOperationHistory: (payload: import("../events/index.js").OperationEvents["operation:reload:history"]) => void;
109
109
  };
110
110
  server: {
111
- addServer: () => import("../schemas/v3.1/strict/server.js").ServerObject | undefined;
111
+ initializeServers: (payload: import("../events/definitions/server.js").ServerEvents["server:initialize:servers"]) => import("../schemas/v3.1/strict/server.js").ServerObject[] | undefined;
112
+ addServer: (payload: import("../events/definitions/server.js").ServerEvents["server:add:server"]) => import("../schemas/v3.1/strict/server.js").ServerObject | undefined;
112
113
  updateServer: (payload: import("../events/definitions/server.js").ServerEvents["server:update:server"]) => import("../schemas/v3.1/strict/server.js").ServerObject | undefined;
113
114
  deleteServer: (payload: import("../events/definitions/server.js").ServerEvents["server:delete:server"]) => void;
115
+ clearServers: (payload: import("../events/definitions/server.js").ServerEvents["server:clear:servers"]) => void;
114
116
  updateServerVariables: (payload: import("../events/definitions/server.js").ServerEvents["server:update:variables"]) => import("../schemas/v3.1/strict/server-variable.js").ServerVariableObject | undefined;
115
117
  updateSelectedServer: (payload: import("../events/definitions/server.js").ServerEvents["server:update:selected"]) => string | undefined;
116
118
  };
@@ -147,6 +149,7 @@ export declare function generateClientMutators(store: WorkspaceStore | null): {
147
149
  doc: (name: string) => {
148
150
  auth: {
149
151
  updateSelectedSecuritySchemes: (payload: import("../events/definitions/auth.js").AuthEvents["auth:update:selected-security-schemes"]) => Promise<void>;
152
+ clearSelectedSecuritySchemes: (payload: import("../events/definitions/auth.js").AuthEvents["auth:clear:selected-security-schemes"]) => void;
150
153
  updateSecurityScheme: (payload: import("../events/definitions/auth.js").AuthEvents["auth:update:security-scheme"]) => import("../schemas/v3.1/strict/security-scheme.js").ApiKeyObject | import("../schemas/v3.1/strict/security-scheme.js").HttpObject | import("../schemas/v3.1/strict/security-scheme.js").OAuth2Object | import("../schemas/v3.1/strict/security-scheme.js").OpenIdConnectObject | undefined;
151
154
  updateSecuritySchemeSecrets: (payload: import("../events/definitions/auth.js").AuthEvents["auth:update:security-scheme-secrets"]) => void;
152
155
  clearSecuritySchemeSecrets: (payload: import("../events/definitions/auth.js").AuthEvents["auth:clear:security-scheme-secrets"]) => void;
@@ -165,7 +168,6 @@ export declare function generateClientMutators(store: WorkspaceStore | null): {
165
168
  }) => boolean;
166
169
  };
167
170
  document: {
168
- toggleSecurity: () => void;
169
171
  updateDocumentInfo: (payload: import("../events/definitions/document.js").DocumentEvents["document:update:info"]) => void;
170
172
  updateWatchMode: (payload: import("../events/definitions/document.js").DocumentEvents["document:update:watch-mode"]) => void;
171
173
  updateDocumentIcon: (payload: import("../events/definitions/document.js").DocumentEvents["document:update:icon"]) => void;
@@ -174,7 +176,7 @@ export declare function generateClientMutators(store: WorkspaceStore | null): {
174
176
  };
175
177
  operation: {
176
178
  createOperation: (payload: import("../events/index.js").OperationEvents["operation:create:operation"]) => string | undefined;
177
- updateOperationSummary: (payload: import("../events/index.js").OperationEvents["operation:update:summary"]) => void;
179
+ updateOperationMeta: (payload: import("../events/index.js").OperationEvents["operation:update:meta"]) => void;
178
180
  updateOperationPathMethod: (payload: import("../events/index.js").OperationEvents["operation:update:pathMethod"]) => void;
179
181
  deleteOperation: (payload: import("../events/index.js").OperationEvents["operation:delete:operation"]) => void;
180
182
  createOperationDraftExample: (payload: import("../events/index.js").OperationEvents["operation:create:draft-example"]) => void;
@@ -191,9 +193,11 @@ export declare function generateClientMutators(store: WorkspaceStore | null): {
191
193
  reloadOperationHistory: (payload: import("../events/index.js").OperationEvents["operation:reload:history"]) => void;
192
194
  };
193
195
  server: {
194
- addServer: () => import("../schemas/v3.1/strict/server.js").ServerObject | undefined;
196
+ initializeServers: (payload: import("../events/definitions/server.js").ServerEvents["server:initialize:servers"]) => import("../schemas/v3.1/strict/server.js").ServerObject[] | undefined;
197
+ addServer: (payload: import("../events/definitions/server.js").ServerEvents["server:add:server"]) => import("../schemas/v3.1/strict/server.js").ServerObject | undefined;
195
198
  updateServer: (payload: import("../events/definitions/server.js").ServerEvents["server:update:server"]) => import("../schemas/v3.1/strict/server.js").ServerObject | undefined;
196
199
  deleteServer: (payload: import("../events/definitions/server.js").ServerEvents["server:delete:server"]) => void;
200
+ clearServers: (payload: import("../events/definitions/server.js").ServerEvents["server:clear:servers"]) => void;
197
201
  updateServerVariables: (payload: import("../events/definitions/server.js").ServerEvents["server:update:variables"]) => import("../schemas/v3.1/strict/server-variable.js").ServerVariableObject | undefined;
198
202
  updateSelectedServer: (payload: import("../events/definitions/server.js").ServerEvents["server:update:selected"]) => string | undefined;
199
203
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mutators/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAa9C;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI;IAqC/D;;OAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAEH;;;OAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAEH;;;;OAIG;gBACS,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAErB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mutators/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAa9C;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI;IAqC/D;;OAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAEH;;;OAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAEH;;;;OAIG;gBACS,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAErB"}
@@ -7,7 +7,7 @@ export declare const operationMutatorsFactory: ({ document, store, }: {
7
7
  store: WorkspaceStore | null;
8
8
  }) => {
9
9
  createOperation: (payload: OperationEvents["operation:create:operation"]) => string | undefined;
10
- updateOperationSummary: (payload: OperationEvents["operation:update:summary"]) => void;
10
+ updateOperationMeta: (payload: OperationEvents["operation:update:meta"]) => void;
11
11
  updateOperationPathMethod: (payload: OperationEvents["operation:update:pathMethod"]) => void;
12
12
  deleteOperation: (payload: OperationEvents["operation:delete:operation"]) => void;
13
13
  createOperationDraftExample: (payload: OperationEvents["operation:create:draft-example"]) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/mutators/operation/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAA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AQ,EAAE,iBAAiB,GAAG,IAAI,CAAA;IAClC,KAAK,EAAE,cAAc,GAAG,IAAI,CAAA;CAC7B;+BAE8B,eAAe,CAAC,4BAA4B,CAAC;mCACzC,eAAe,CAAC,uBAAuB,CAAC;yCAElC,eAAe,CAAC,6BAA6B,CAAC;+BAExD,eAAe,CAAC,4BAA4B,CAAC;2CACjC,eAAe,CAAC,gCAAgC,CAAC;sCAEtD,eAAe,CAAC,0BAA0B,CAAC;wCAEzC,eAAe,CAAC,4BAA4B,CAAC;8CAEvC,eAAe,CAAC,mCAAmC,CAAC;wCAE1D,eAAe,CAAC,4BAA4B,CAAC;wCAE7C,eAAe,CAAC,4BAA4B,CAAC;4CAEzC,eAAe,CAAC,iCAAiC,CAAC;qDAEzC,eAAe,CAAC,0CAA0C,CAAC;iDAE/D,eAAe,CAAC,oCAAoC,CAAC;mDAEnD,eAAe,CAAC,wCAAwC,CAAC;oCAExE,WAAW,CAAC,2BAA2B,CAAC;sCAEtC,eAAe,CAAC,0BAA0B,CAAC;CAGhF,CAAA"}
@@ -10,8 +10,8 @@ import {
10
10
  createOperationDraftExample,
11
11
  deleteOperation,
12
12
  deleteOperationExample,
13
- updateOperationPathMethod,
14
- updateOperationSummary
13
+ updateOperationMeta,
14
+ updateOperationPathMethod
15
15
  } from "../../mutators/operation/operation.js";
16
16
  import {
17
17
  deleteAllOperationParameters,
@@ -25,7 +25,7 @@ const operationMutatorsFactory = ({
25
25
  }) => {
26
26
  return {
27
27
  createOperation: (payload) => createOperation(store, payload),
28
- updateOperationSummary: (payload) => updateOperationSummary(store, document, payload),
28
+ updateOperationMeta: (payload) => updateOperationMeta(store, document, payload),
29
29
  updateOperationPathMethod: (payload) => updateOperationPathMethod(document, store, payload),
30
30
  deleteOperation: (payload) => deleteOperation(store, payload),
31
31
  createOperationDraftExample: (payload) => createOperationDraftExample(store, payload),
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/mutators/operation/index.ts"],
4
- "sourcesContent": ["import type { WorkspaceStore } from '@/client'\nimport type { HooksEvents } from '@/events/definitions/hooks'\nimport type { OperationEvents } from '@/events/definitions/operation'\nimport {\n updateOperationRequestBodyContentType,\n updateOperationRequestBodyExample,\n updateOperationRequestBodyFormValue,\n} from '@/mutators/operation/body'\nimport { updateOperationExtension } from '@/mutators/operation/extensions'\nimport { addResponseToHistory, reloadOperationHistory } from '@/mutators/operation/history'\nimport {\n createOperation,\n createOperationDraftExample,\n deleteOperation,\n deleteOperationExample,\n updateOperationPathMethod,\n updateOperationSummary,\n} from '@/mutators/operation/operation'\nimport {\n deleteAllOperationParameters,\n deleteOperationParameter,\n updateOperationExtraParameters,\n upsertOperationParameter,\n} from '@/mutators/operation/parameters'\nimport type { WorkspaceDocument } from '@/schemas'\n\nexport const operationMutatorsFactory = ({\n document,\n store,\n}: {\n document: WorkspaceDocument | null\n store: WorkspaceStore | null\n}) => {\n return {\n createOperation: (payload: OperationEvents['operation:create:operation']) => createOperation(store, payload),\n updateOperationSummary: (payload: OperationEvents['operation:update:summary']) =>\n updateOperationSummary(store, document, payload),\n updateOperationPathMethod: (payload: OperationEvents['operation:update:pathMethod']) =>\n updateOperationPathMethod(document, store, payload),\n deleteOperation: (payload: OperationEvents['operation:delete:operation']) => deleteOperation(store, payload),\n createOperationDraftExample: (payload: OperationEvents['operation:create:draft-example']) =>\n createOperationDraftExample(store, payload),\n deleteOperationExample: (payload: OperationEvents['operation:delete:example']) =>\n deleteOperationExample(store, payload),\n updateOperationExtension: (payload: OperationEvents['operation:update:extension']) =>\n updateOperationExtension(document, payload),\n updateOperationExtraParameters: (payload: OperationEvents['operation:update:extra-parameters']) =>\n updateOperationExtraParameters(document, payload),\n upsertOperationParameter: (payload: OperationEvents['operation:upsert:parameter']) =>\n upsertOperationParameter(document, payload),\n deleteOperationParameter: (payload: OperationEvents['operation:delete:parameter']) =>\n deleteOperationParameter(document, payload),\n deleteAllOperationParameters: (payload: OperationEvents['operation:delete-all:parameters']) =>\n deleteAllOperationParameters(document, payload),\n updateOperationRequestBodyContentType: (payload: OperationEvents['operation:update:requestBody:contentType']) =>\n updateOperationRequestBodyContentType(document, payload),\n updateOperationRequestBodyExample: (payload: OperationEvents['operation:update:requestBody:value']) =>\n updateOperationRequestBodyExample(document, payload),\n updateOperationRequestBodyFormValue: (payload: OperationEvents['operation:update:requestBody:formValue']) =>\n updateOperationRequestBodyFormValue(document, payload),\n addResponseToHistory: (payload: HooksEvents['hooks:on:request:complete']) =>\n addResponseToHistory(store, document, payload),\n reloadOperationHistory: (payload: OperationEvents['operation:reload:history']) =>\n reloadOperationHistory(store, document, payload),\n }\n}\n"],
5
- "mappings": "AAGA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,gCAAgC;AACzC,SAAS,sBAAsB,8BAA8B;AAC7D;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGA,MAAM,2BAA2B,CAAC;AAAA,EACvC;AAAA,EACA;AACF,MAGM;AACJ,SAAO;AAAA,IACL,iBAAiB,CAAC,YAA2D,gBAAgB,OAAO,OAAO;AAAA,IAC3G,wBAAwB,CAAC,YACvB,uBAAuB,OAAO,UAAU,OAAO;AAAA,IACjD,2BAA2B,CAAC,YAC1B,0BAA0B,UAAU,OAAO,OAAO;AAAA,IACpD,iBAAiB,CAAC,YAA2D,gBAAgB,OAAO,OAAO;AAAA,IAC3G,6BAA6B,CAAC,YAC5B,4BAA4B,OAAO,OAAO;AAAA,IAC5C,wBAAwB,CAAC,YACvB,uBAAuB,OAAO,OAAO;AAAA,IACvC,0BAA0B,CAAC,YACzB,yBAAyB,UAAU,OAAO;AAAA,IAC5C,gCAAgC,CAAC,YAC/B,+BAA+B,UAAU,OAAO;AAAA,IAClD,0BAA0B,CAAC,YACzB,yBAAyB,UAAU,OAAO;AAAA,IAC5C,0BAA0B,CAAC,YACzB,yBAAyB,UAAU,OAAO;AAAA,IAC5C,8BAA8B,CAAC,YAC7B,6BAA6B,UAAU,OAAO;AAAA,IAChD,uCAAuC,CAAC,YACtC,sCAAsC,UAAU,OAAO;AAAA,IACzD,mCAAmC,CAAC,YAClC,kCAAkC,UAAU,OAAO;AAAA,IACrD,qCAAqC,CAAC,YACpC,oCAAoC,UAAU,OAAO;AAAA,IACvD,sBAAsB,CAAC,YACrB,qBAAqB,OAAO,UAAU,OAAO;AAAA,IAC/C,wBAAwB,CAAC,YACvB,uBAAuB,OAAO,UAAU,OAAO;AAAA,EACnD;AACF;",
4
+ "sourcesContent": ["import type { WorkspaceStore } from '@/client'\nimport type { HooksEvents } from '@/events/definitions/hooks'\nimport type { OperationEvents } from '@/events/definitions/operation'\nimport {\n updateOperationRequestBodyContentType,\n updateOperationRequestBodyExample,\n updateOperationRequestBodyFormValue,\n} from '@/mutators/operation/body'\nimport { updateOperationExtension } from '@/mutators/operation/extensions'\nimport { addResponseToHistory, reloadOperationHistory } from '@/mutators/operation/history'\nimport {\n createOperation,\n createOperationDraftExample,\n deleteOperation,\n deleteOperationExample,\n updateOperationMeta,\n updateOperationPathMethod,\n} from '@/mutators/operation/operation'\nimport {\n deleteAllOperationParameters,\n deleteOperationParameter,\n updateOperationExtraParameters,\n upsertOperationParameter,\n} from '@/mutators/operation/parameters'\nimport type { WorkspaceDocument } from '@/schemas'\n\nexport const operationMutatorsFactory = ({\n document,\n store,\n}: {\n document: WorkspaceDocument | null\n store: WorkspaceStore | null\n}) => {\n return {\n createOperation: (payload: OperationEvents['operation:create:operation']) => createOperation(store, payload),\n updateOperationMeta: (payload: OperationEvents['operation:update:meta']) =>\n updateOperationMeta(store, document, payload),\n updateOperationPathMethod: (payload: OperationEvents['operation:update:pathMethod']) =>\n updateOperationPathMethod(document, store, payload),\n deleteOperation: (payload: OperationEvents['operation:delete:operation']) => deleteOperation(store, payload),\n createOperationDraftExample: (payload: OperationEvents['operation:create:draft-example']) =>\n createOperationDraftExample(store, payload),\n deleteOperationExample: (payload: OperationEvents['operation:delete:example']) =>\n deleteOperationExample(store, payload),\n updateOperationExtension: (payload: OperationEvents['operation:update:extension']) =>\n updateOperationExtension(document, payload),\n updateOperationExtraParameters: (payload: OperationEvents['operation:update:extra-parameters']) =>\n updateOperationExtraParameters(document, payload),\n upsertOperationParameter: (payload: OperationEvents['operation:upsert:parameter']) =>\n upsertOperationParameter(document, payload),\n deleteOperationParameter: (payload: OperationEvents['operation:delete:parameter']) =>\n deleteOperationParameter(document, payload),\n deleteAllOperationParameters: (payload: OperationEvents['operation:delete-all:parameters']) =>\n deleteAllOperationParameters(document, payload),\n updateOperationRequestBodyContentType: (payload: OperationEvents['operation:update:requestBody:contentType']) =>\n updateOperationRequestBodyContentType(document, payload),\n updateOperationRequestBodyExample: (payload: OperationEvents['operation:update:requestBody:value']) =>\n updateOperationRequestBodyExample(document, payload),\n updateOperationRequestBodyFormValue: (payload: OperationEvents['operation:update:requestBody:formValue']) =>\n updateOperationRequestBodyFormValue(document, payload),\n addResponseToHistory: (payload: HooksEvents['hooks:on:request:complete']) =>\n addResponseToHistory(store, document, payload),\n reloadOperationHistory: (payload: OperationEvents['operation:reload:history']) =>\n reloadOperationHistory(store, document, payload),\n }\n}\n"],
5
+ "mappings": "AAGA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,gCAAgC;AACzC,SAAS,sBAAsB,8BAA8B;AAC7D;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGA,MAAM,2BAA2B,CAAC;AAAA,EACvC;AAAA,EACA;AACF,MAGM;AACJ,SAAO;AAAA,IACL,iBAAiB,CAAC,YAA2D,gBAAgB,OAAO,OAAO;AAAA,IAC3G,qBAAqB,CAAC,YACpB,oBAAoB,OAAO,UAAU,OAAO;AAAA,IAC9C,2BAA2B,CAAC,YAC1B,0BAA0B,UAAU,OAAO,OAAO;AAAA,IACpD,iBAAiB,CAAC,YAA2D,gBAAgB,OAAO,OAAO;AAAA,IAC3G,6BAA6B,CAAC,YAC5B,4BAA4B,OAAO,OAAO;AAAA,IAC5C,wBAAwB,CAAC,YACvB,uBAAuB,OAAO,OAAO;AAAA,IACvC,0BAA0B,CAAC,YACzB,yBAAyB,UAAU,OAAO;AAAA,IAC5C,gCAAgC,CAAC,YAC/B,+BAA+B,UAAU,OAAO;AAAA,IAClD,0BAA0B,CAAC,YACzB,yBAAyB,UAAU,OAAO;AAAA,IAC5C,0BAA0B,CAAC,YACzB,yBAAyB,UAAU,OAAO;AAAA,IAC5C,8BAA8B,CAAC,YAC7B,6BAA6B,UAAU,OAAO;AAAA,IAChD,uCAAuC,CAAC,YACtC,sCAAsC,UAAU,OAAO;AAAA,IACzD,mCAAmC,CAAC,YAClC,kCAAkC,UAAU,OAAO;AAAA,IACrD,qCAAqC,CAAC,YACpC,oCAAoC,UAAU,OAAO;AAAA,IACvD,sBAAsB,CAAC,YACrB,qBAAqB,OAAO,UAAU,OAAO;AAAA,IAC/C,wBAAwB,CAAC,YACvB,uBAAuB,OAAO,UAAU,OAAO;AAAA,EACnD;AACF;",
6
6
  "names": []
7
7
  }
@@ -19,20 +19,18 @@ import type { WorkspaceDocument } from '../../schemas.js';
19
19
  */
20
20
  export declare const createOperation: (workspaceStore: WorkspaceStore | null, payload: OperationEvents["operation:create:operation"]) => string | undefined;
21
21
  /**
22
- * Updates the `summary` of an operation.
22
+ * Updates the `description` of an operation.
23
23
  * Safely no-ops if the document or operation does not exist.
24
24
  *
25
25
  * Example:
26
26
  * ```ts
27
- * updateOperationSummary(
27
+ * updateOperationDescription(
28
28
  * document,
29
- * {
30
- * meta: { method: 'get', path: '/users/{id}' },
31
- * payload: { summary: 'Get a single user' },
29
+ * { meta: { method: 'get', path: '/users' }, payload: { description: 'Get a single user' },
32
30
  * })
33
31
  * ```
34
32
  */
35
- export declare const updateOperationSummary: (store: WorkspaceStore | null, document: WorkspaceDocument | null, { meta, payload: { summary } }: OperationEvents["operation:update:summary"]) => void;
33
+ export declare const updateOperationMeta: (store: WorkspaceStore | null, document: WorkspaceDocument | null, { meta, payload }: OperationEvents["operation:update:meta"]) => void;
36
34
  /**
37
35
  * Updates the HTTP method and/or path of an operation and moves it to the new location.
38
36
  * This function:
@@ -1 +1 @@
1
- {"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../../../src/mutators/operation/operation.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAOrE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAElD;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,eAAe,GAC1B,gBAAgB,cAAc,GAAG,IAAI,EACrC,SAAS,eAAe,CAAC,4BAA4B,CAAC,KACrD,MAAM,GAAG,SAwDX,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,sBAAsB,GACjC,OAAO,cAAc,GAAG,IAAI,EAC5B,UAAU,iBAAiB,GAAG,IAAI,EAClC,gCAAgC,eAAe,CAAC,0BAA0B,CAAC,SAqB5E,CAAA;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,yBAAyB,GACpC,UAAU,iBAAiB,GAAG,IAAI,EAClC,OAAO,cAAc,GAAG,IAAI,EAC5B,+CAA+C,eAAe,CAAC,6BAA6B,CAAC,KAC5F,IA+FF,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,eAAe,GAC1B,WAAW,cAAc,GAAG,IAAI,EAChC,wBAAwB,eAAe,CAAC,4BAA4B,CAAC,SAgBtE,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B,GACtC,WAAW,cAA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H,eAAO,MAAM,sBAAsB,GACjC,WAAW,cAAc,GAAG,IAAI,EAChC,sDAAsD,eAAe,CAAC,0BAA0B,CAAC,SAiDlG,CAAA"}
@@ -44,7 +44,7 @@ const createOperation = (workspaceStore, payload) => {
44
44
  payload.callback?.(true);
45
45
  return normalizedPath;
46
46
  };
47
- const updateOperationSummary = (store, document, { meta, payload: { summary } }) => {
47
+ const updateOperationMeta = (store, document, { meta, payload }) => {
48
48
  if (!document || !store) {
49
49
  return;
50
50
  }
@@ -54,9 +54,10 @@ const updateOperationSummary = (store, document, { meta, payload: { summary } })
54
54
  }
55
55
  const operation = getResolvedRef(document.paths?.[meta.path]?.[meta.method]);
56
56
  if (!operation) {
57
+ console.error("Operation not found", { meta, document });
57
58
  return;
58
59
  }
59
- operation.summary = summary;
60
+ Object.assign(operation, payload);
60
61
  store.buildSidebar(documentName);
61
62
  };
62
63
  const updateOperationPathMethod = (document, store, { meta, payload: { method, path }, callback }) => {
@@ -186,7 +187,7 @@ export {
186
187
  createOperationDraftExample,
187
188
  deleteOperation,
188
189
  deleteOperationExample,
189
- updateOperationPathMethod,
190
- updateOperationSummary
190
+ updateOperationMeta,
191
+ updateOperationPathMethod
191
192
  };
192
193
  //# sourceMappingURL=operation.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/mutators/operation/operation.ts"],
4
- "sourcesContent": ["import type { HttpMethod } from '@scalar/helpers/http/http-methods'\nimport { isHttpMethod } from '@scalar/helpers/http/is-http-method'\nimport { preventPollution } from '@scalar/helpers/object/prevent-pollution'\nimport { findVariables } from '@scalar/helpers/regex/find-variables'\n\nimport type { WorkspaceStore } from '@/client'\nimport type { OperationEvents } from '@/events/definitions/operation'\nimport { getResolvedRef } from '@/helpers/get-resolved-ref'\nimport { unpackProxyObject } from '@/helpers/unpack-proxy'\nimport { syncParametersForPathChange } from '@/mutators/operation/helpers/sync-path-parameters'\nimport { getOperationEntries } from '@/navigation'\nimport { getNavigationOptions } from '@/navigation/get-navigation-options'\nimport { updateOrderIds } from '@/navigation/helpers/update-order-ids'\nimport type { WorkspaceDocument } from '@/schemas'\n\n/**\n * Creates a new operation at a specific path and method in the document.\n * Automatically normalizes the path to ensure it starts with a slash.\n *\n * Returns the normalized path if successful, undefined otherwise.\n *\n * Example:\n * ```ts\n * createOperation(\n * document,\n * 'users',\n * 'get',\n * { tags: ['Users'] },\n * )\n * ```\n */\nexport const createOperation = (\n workspaceStore: WorkspaceStore | null,\n payload: OperationEvents['operation:create:operation'],\n): string | undefined => {\n const document = workspaceStore?.workspace.documents[payload.documentName]\n if (!document) {\n payload.callback?.(false)\n return undefined\n }\n\n const { path, method, operation } = payload\n\n /** Ensure the path starts with a slash */\n const normalizedPath = path.startsWith('/') ? path : `/${path}`\n\n /** Create the operation in the document */\n if (!document.paths) {\n document.paths = {}\n }\n\n if (!document.paths[normalizedPath]) {\n document.paths[normalizedPath] = {}\n }\n\n /** Prevent pollution of the path and method */\n preventPollution(normalizedPath)\n preventPollution(method)\n\n /** Create the operation in the document */\n document.paths[normalizedPath][method] = operation\n\n // Make sure that we are selecting the new operation server\n const { servers } = operation\n const firstServer = unpackProxyObject(servers?.[0])\n\n // For now we only support document servers but in the future we might support operation servers\n for (const server of servers ?? []) {\n // If the server does not exist in the document, add it\n if (!document.servers?.some((s) => s.url === server.url)) {\n if (!document.servers) {\n document.servers = []\n }\n document.servers.push(unpackProxyObject(server))\n }\n }\n\n // Update the selected server to the first server of the created operation\n if (firstServer) {\n document['x-scalar-selected-server'] = firstServer.url\n }\n\n // Sync path variables\n const newParameters = syncParametersForPathChange(normalizedPath, normalizedPath, operation.parameters ?? [])\n if (newParameters.length > 0) {\n operation.parameters = newParameters\n }\n\n payload.callback?.(true)\n return normalizedPath\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 * {\n * meta: { method: 'get', path: '/users/{id}' },\n * payload: { summary: 'Get a single user' },\n * })\n * ```\n */\nexport const updateOperationSummary = (\n store: WorkspaceStore | null,\n document: WorkspaceDocument | null,\n { meta, payload: { summary } }: OperationEvents['operation:update:summary'],\n) => {\n if (!document || !store) {\n return\n }\n\n const documentName = document['x-scalar-navigation']?.name\n if (documentName === undefined) {\n return\n }\n\n const operation = getResolvedRef(document.paths?.[meta.path]?.[meta.method as HttpMethod])\n if (!operation) {\n return\n }\n\n operation.summary = summary\n\n // Rebuild the sidebar to reflect the cahnges\n // We can't just go any find all the entries this operation is part so we just rebuild the sidebar\n store.buildSidebar(documentName)\n}\n\n/**\n * Updates the HTTP method and/or path of an operation and moves it to the new location.\n * This function:\n * 1. Moves the operation from the old method/path to the new method/path under paths\n * 2. Updates x-scalar-order to maintain the operation's position in the sidebar\n * 3. Syncs path parameters when the path changes\n *\n * Safely no-ops if nothing has changed, or if the document or operation does not exist.\n *\n * Example:\n * ```ts\n * updateOperationPathMethod({\n * document,\n * store,\n * meta: { method: 'get', path: '/users' },\n * payload: { method: 'post', path: '/api/users' },\n * })\n * ```\n */\nexport const updateOperationPathMethod = (\n document: WorkspaceDocument | null,\n store: WorkspaceStore | null,\n { meta, payload: { method, path }, callback }: OperationEvents['operation:update:pathMethod'],\n): void => {\n const methodChanged = meta.method !== method\n const pathChanged = meta.path !== path\n\n // If nothing has changed, no need to do anything\n if (!methodChanged && !pathChanged) {\n callback('no-change')\n return\n }\n\n // Determine the final method and path\n const finalMethod = methodChanged ? method : meta.method\n const finalPath = pathChanged ? path : meta.path\n\n // Check for conflicts at the target location\n if (document?.paths?.[finalPath]?.[finalMethod as HttpMethod]) {\n callback('conflict')\n return\n }\n\n const documentNavigation = document?.['x-scalar-navigation']\n if (!documentNavigation || !store) {\n console.error('Document or workspace not found', { document })\n return\n }\n\n const operation = getResolvedRef(document.paths?.[meta.path]?.[meta.method as HttpMethod])\n if (!operation) {\n console.error('Operation not found', { meta, document })\n return\n }\n\n // Sync path parameters if the path has changed\n if (pathChanged) {\n const oldPathParams = findVariables(meta.path, { includePath: true, includeEnv: false }).filter(\n (v): v is string => v !== undefined,\n )\n const newPathParams = findVariables(finalPath, { includePath: true, includeEnv: false }).filter(\n (v): v is string => v !== undefined,\n )\n\n if (oldPathParams.length > 0 || newPathParams.length > 0) {\n const existingParameters = operation.parameters ?? []\n operation.parameters = syncParametersForPathChange(finalPath, meta.path, existingParameters)\n }\n }\n\n /**\n * We don't pass navigation options as we don't have config on the client,\n * and we don't change path or method on the references\n */\n const { generateId } = getNavigationOptions(documentNavigation.name)\n\n /** Grabs all of the current operation entries for the given path and method */\n const operationEntriesMap = getOperationEntries(documentNavigation)\n const entries = operationEntriesMap.get(`${meta.path}|${meta.method}`)\n\n // Updates the order ID so we don't lose the sidebar ordering when it rebuilds\n if (entries) {\n updateOrderIds({ store, operation, generateId, method: finalMethod, path: finalPath, entries })\n }\n\n // Initialize the paths object if it does not exist\n if (!document.paths) {\n document.paths = {}\n }\n\n // Initialize the new path if it does not exist\n if (!document.paths[finalPath]) {\n document.paths[finalPath] = {}\n }\n\n // Prevent assigning dangerous keys to the path items object\n preventPollution(finalPath)\n preventPollution(meta.path)\n preventPollution(finalMethod)\n\n // Move the operation to the new location\n document.paths[finalPath][finalMethod] = unpackProxyObject(operation)\n\n // Remove the operation from the old location\n const oldPathItems = document.paths[meta.path]\n if (oldPathItems && isHttpMethod(meta.method)) {\n delete oldPathItems[meta.method]\n\n // If the old path has no more operations, remove the path entry\n if (Object.keys(oldPathItems).length === 0) {\n delete document.paths[meta.path]\n }\n }\n\n // We need to reset the history for the operation when the path or method changes\n store.history.clearOperationHistory(document['x-scalar-navigation']?.name ?? '', meta.path, meta.method)\n\n callback('success')\n}\n\n/**\n * Deletes an operation from the workspace\n *\n * Example:\n * ```ts\n * deleteOperation({\n * document,\n * meta: { method: 'get', path: '/users' },\n * })\n * ```\n */\nexport const deleteOperation = (\n workspace: WorkspaceStore | null,\n { meta, documentName }: OperationEvents['operation:delete:operation'],\n) => {\n const document = workspace?.workspace.documents[documentName]\n if (!document) {\n return\n }\n\n preventPollution(meta.path)\n preventPollution(meta.method)\n\n delete document.paths?.[meta.path]?.[meta.method]\n\n // If the path has no more operations, remove the path entry\n if (Object.keys(document.paths?.[meta.path] ?? {}).length === 0) {\n delete document.paths?.[meta.path]\n }\n}\n\n/**\n * Adds an example name to the 'x-draft-examples' array for a specific operation in a document.\n *\n * - Finds the target operation using the provided path and method within the specified document.\n * - If the operation is found and has an 'x-draft-examples' array, pushes the new exampleName to it.\n * - Safely no-ops if the document or operation does not exist.\n */\nexport const createOperationDraftExample = (\n workspace: WorkspaceStore | null,\n { meta: { path, method }, documentName, exampleName }: OperationEvents['operation:create:draft-example'],\n) => {\n const document = workspace?.workspace.documents[documentName]\n if (!document) {\n console.error('Document not found', { documentName })\n return\n }\n\n const operation = getResolvedRef(document.paths?.[path]?.[method])\n if (!operation) {\n console.error('Operation not found', { path, method })\n return\n }\n\n // Ensure that the x-draft-examples array exists\n operation['x-draft-examples'] ??= []\n\n // Remove duplicates\n const dedupe = new Set(operation['x-draft-examples'])\n // Add the new example name\n dedupe.add(exampleName)\n // Update the operation with the new x-draft-examples array\n operation['x-draft-examples'] = Array.from(dedupe)\n}\n\n/**\n * Deletes an example with the given exampleKey from operation parameters and request body.\n *\n * - Finds the target operation within the specified document and path/method.\n * - Removes example values matching exampleKey from both parameter-level and content-level examples.\n * - Safely no-ops if the document, operation, or request body does not exist.\n */\nexport const deleteOperationExample = (\n workspace: WorkspaceStore | null,\n { meta: { path, method, exampleKey }, documentName }: OperationEvents['operation:delete:example'],\n) => {\n // Find the document in workspace based on documentName\n const document = workspace?.workspace.documents[documentName]\n if (!document) {\n return\n }\n\n // Get the operation object for the given path and method\n const operation = getResolvedRef(document.paths?.[path]?.[method])\n if (!operation) {\n return\n }\n\n // Remove the example from the x-draft-examples array\n const dedupe = new Set(operation['x-draft-examples'] ?? [])\n dedupe.delete(exampleKey)\n\n if (operation['x-draft-examples'] !== undefined) {\n operation['x-draft-examples'] = Array.from(dedupe)\n }\n\n // Remove the example from all operation parameters\n operation.parameters?.forEach((parameter) => {\n const resolvedParameter = getResolvedRef(parameter)\n\n // Remove from content-level examples (if parameter uses content)\n if ('content' in resolvedParameter && resolvedParameter.content) {\n Object.values(resolvedParameter.content).forEach((mediaType) => {\n delete mediaType.examples?.[exampleKey]\n })\n }\n\n // Remove from parameter-level examples\n if ('examples' in resolvedParameter && resolvedParameter.examples) {\n delete resolvedParameter.examples?.[exampleKey]\n }\n })\n\n // Remove the example from request body content types (if requestBody exists)\n const requestBody = getResolvedRef(operation.requestBody)\n if (!requestBody) {\n return\n }\n\n // For each media type, remove the example matching exampleKey\n Object.values(requestBody.content ?? {}).forEach((mediaType) => {\n delete mediaType.examples?.[exampleKey]\n })\n}\n"],
5
- "mappings": "AACA,SAAS,oBAAoB;AAC7B,SAAS,wBAAwB;AACjC,SAAS,qBAAqB;AAI9B,SAAS,sBAAsB;AAC/B,SAAS,yBAAyB;AAClC,SAAS,mCAAmC;AAC5C,SAAS,2BAA2B;AACpC,SAAS,4BAA4B;AACrC,SAAS,sBAAsB;AAmBxB,MAAM,kBAAkB,CAC7B,gBACA,YACuB;AACvB,QAAM,WAAW,gBAAgB,UAAU,UAAU,QAAQ,YAAY;AACzE,MAAI,CAAC,UAAU;AACb,YAAQ,WAAW,KAAK;AACxB,WAAO;AAAA,EACT;AAEA,QAAM,EAAE,MAAM,QAAQ,UAAU,IAAI;AAGpC,QAAM,iBAAiB,KAAK,WAAW,GAAG,IAAI,OAAO,IAAI,IAAI;AAG7D,MAAI,CAAC,SAAS,OAAO;AACnB,aAAS,QAAQ,CAAC;AAAA,EACpB;AAEA,MAAI,CAAC,SAAS,MAAM,cAAc,GAAG;AACnC,aAAS,MAAM,cAAc,IAAI,CAAC;AAAA,EACpC;AAGA,mBAAiB,cAAc;AAC/B,mBAAiB,MAAM;AAGvB,WAAS,MAAM,cAAc,EAAE,MAAM,IAAI;AAGzC,QAAM,EAAE,QAAQ,IAAI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AAU,kBAAkB,MAAM,CAAC;AAGnC,QAAM,SAAS,IAAI,IAAI,UAAU,kBAAkB,CAAC;AAEpD,SAAO,IAAI,WAAW;AAEtB,YAAU,kBAAkB,IAAI,MAAM,KAAK,MAAM;AACnD;AASO,MAAM,yBAAyB,CACpC,WACA,EAAE,MAAM,EAAE,MAAM,QAAQ,WAAW,GAAG,aAAa,MAChD;AAEH,QAAM,WAAW,WAAW,UAAU,UAAU,YAAY;AAC5D,MAAI,CAAC,UAAU;AACb;AAAA,EACF;AAGA,QAAM,YAAY,eAAe,SAAS,QAAQ,IAAI,IAAI,MAAM,CAAC;AACjE,MAAI,CAAC,WAAW;AACd;AAAA,EACF;AAGA,QAAM,SAAS,IAAI,IAAI,UAAU,kBAAkB,KAAK,CAAC,CAAC;AAC1D,SAAO,OAAO,UAAU;AAExB,MAAI,UAAU,kBAAkB,MAAM,QAAW;AAC/C,cAAU,kBAAkB,IAAI,MAAM,KAAK,MAAM;AAAA,EACnD;AAGA,YAAU,YAAY,QAAQ,CAAC,cAAc;AAC3C,UAAM,oBAAoB,eAAe,SAAS;AAGlD,QAAI,aAAa,qBAAqB,kBAAkB,SAAS;AAC/D,aAAO,OAAO,kBAAkB,OAAO,EAAE,QAAQ,CAAC,cAAc;AAC9D,eAAO,UAAU,WAAW,UAAU;AAAA,MACxC,CAAC;AAAA,IACH;AAGA,QAAI,cAAc,qBAAqB,kBAAkB,UAAU;AACjE,aAAO,kBAAkB,WAAW,UAAU;AAAA,IAChD;AAAA,EACF,CAAC;AAGD,QAAM,cAAc,eAAe,UAAU,WAAW;AACxD,MAAI,CAAC,aAAa;AAChB;AAAA,EACF;AAGA,SAAO,OAAO,YAAY,WAAW,CAAC,CAAC,EAAE,QAAQ,CAAC,cAAc;AAC9D,WAAO,UAAU,WAAW,UAAU;AAAA,EACxC,CAAC;AACH;",
4
+ "sourcesContent": ["import type { HttpMethod } from '@scalar/helpers/http/http-methods'\nimport { isHttpMethod } from '@scalar/helpers/http/is-http-method'\nimport { preventPollution } from '@scalar/helpers/object/prevent-pollution'\nimport { findVariables } from '@scalar/helpers/regex/find-variables'\n\nimport type { WorkspaceStore } from '@/client'\nimport type { OperationEvents } from '@/events/definitions/operation'\nimport { getResolvedRef } from '@/helpers/get-resolved-ref'\nimport { unpackProxyObject } from '@/helpers/unpack-proxy'\nimport { syncParametersForPathChange } from '@/mutators/operation/helpers/sync-path-parameters'\nimport { getOperationEntries } from '@/navigation'\nimport { getNavigationOptions } from '@/navigation/get-navigation-options'\nimport { updateOrderIds } from '@/navigation/helpers/update-order-ids'\nimport type { WorkspaceDocument } from '@/schemas'\n\n/**\n * Creates a new operation at a specific path and method in the document.\n * Automatically normalizes the path to ensure it starts with a slash.\n *\n * Returns the normalized path if successful, undefined otherwise.\n *\n * Example:\n * ```ts\n * createOperation(\n * document,\n * 'users',\n * 'get',\n * { tags: ['Users'] },\n * )\n * ```\n */\nexport const createOperation = (\n workspaceStore: WorkspaceStore | null,\n payload: OperationEvents['operation:create:operation'],\n): string | undefined => {\n const document = workspaceStore?.workspace.documents[payload.documentName]\n if (!document) {\n payload.callback?.(false)\n return undefined\n }\n\n const { path, method, operation } = payload\n\n /** Ensure the path starts with a slash */\n const normalizedPath = path.startsWith('/') ? path : `/${path}`\n\n /** Create the operation in the document */\n if (!document.paths) {\n document.paths = {}\n }\n\n if (!document.paths[normalizedPath]) {\n document.paths[normalizedPath] = {}\n }\n\n /** Prevent pollution of the path and method */\n preventPollution(normalizedPath)\n preventPollution(method)\n\n /** Create the operation in the document */\n document.paths[normalizedPath][method] = operation\n\n // Make sure that we are selecting the new operation server\n const { servers } = operation\n const firstServer = unpackProxyObject(servers?.[0])\n\n // For now we only support document servers but in the future we might support operation servers\n for (const server of servers ?? []) {\n // If the server does not exist in the document, add it\n if (!document.servers?.some((s) => s.url === server.url)) {\n if (!document.servers) {\n document.servers = []\n }\n document.servers.push(unpackProxyObject(server))\n }\n }\n\n // Update the selected server to the first server of the created operation\n if (firstServer) {\n document['x-scalar-selected-server'] = firstServer.url\n }\n\n // Sync path variables\n const newParameters = syncParametersForPathChange(normalizedPath, normalizedPath, operation.parameters ?? [])\n if (newParameters.length > 0) {\n operation.parameters = newParameters\n }\n\n payload.callback?.(true)\n return normalizedPath\n}\n\n/**\n * Updates the `description` of an operation.\n * Safely no-ops if the document or operation does not exist.\n *\n * Example:\n * ```ts\n * updateOperationDescription(\n * document,\n * { meta: { method: 'get', path: '/users' }, payload: { description: 'Get a single user' },\n * })\n * ```\n */\nexport const updateOperationMeta = (\n store: WorkspaceStore | null,\n document: WorkspaceDocument | null,\n { meta, payload }: OperationEvents['operation:update:meta'],\n) => {\n if (!document || !store) {\n return\n }\n\n const documentName = document['x-scalar-navigation']?.name\n if (documentName === undefined) {\n return\n }\n\n const operation = getResolvedRef(document.paths?.[meta.path]?.[meta.method as HttpMethod])\n if (!operation) {\n console.error('Operation not found', { meta, document })\n return\n }\n\n // Update the description of the operation\n Object.assign(operation, payload)\n\n // Rebuild the sidebar to reflect the cahnges\n store.buildSidebar(documentName)\n}\n\n/**\n * Updates the HTTP method and/or path of an operation and moves it to the new location.\n * This function:\n * 1. Moves the operation from the old method/path to the new method/path under paths\n * 2. Updates x-scalar-order to maintain the operation's position in the sidebar\n * 3. Syncs path parameters when the path changes\n *\n * Safely no-ops if nothing has changed, or if the document or operation does not exist.\n *\n * Example:\n * ```ts\n * updateOperationPathMethod({\n * document,\n * store,\n * meta: { method: 'get', path: '/users' },\n * payload: { method: 'post', path: '/api/users' },\n * })\n * ```\n */\nexport const updateOperationPathMethod = (\n document: WorkspaceDocument | null,\n store: WorkspaceStore | null,\n { meta, payload: { method, path }, callback }: OperationEvents['operation:update:pathMethod'],\n): void => {\n const methodChanged = meta.method !== method\n const pathChanged = meta.path !== path\n\n // If nothing has changed, no need to do anything\n if (!methodChanged && !pathChanged) {\n callback('no-change')\n return\n }\n\n // Determine the final method and path\n const finalMethod = methodChanged ? method : meta.method\n const finalPath = pathChanged ? path : meta.path\n\n // Check for conflicts at the target location\n if (document?.paths?.[finalPath]?.[finalMethod as HttpMethod]) {\n callback('conflict')\n return\n }\n\n const documentNavigation = document?.['x-scalar-navigation']\n if (!documentNavigation || !store) {\n console.error('Document or workspace not found', { document })\n return\n }\n\n const operation = getResolvedRef(document.paths?.[meta.path]?.[meta.method as HttpMethod])\n if (!operation) {\n console.error('Operation not found', { meta, document })\n return\n }\n\n // Sync path parameters if the path has changed\n if (pathChanged) {\n const oldPathParams = findVariables(meta.path, { includePath: true, includeEnv: false }).filter(\n (v): v is string => v !== undefined,\n )\n const newPathParams = findVariables(finalPath, { includePath: true, includeEnv: false }).filter(\n (v): v is string => v !== undefined,\n )\n\n if (oldPathParams.length > 0 || newPathParams.length > 0) {\n const existingParameters = operation.parameters ?? []\n operation.parameters = syncParametersForPathChange(finalPath, meta.path, existingParameters)\n }\n }\n\n /**\n * We don't pass navigation options as we don't have config on the client,\n * and we don't change path or method on the references\n */\n const { generateId } = getNavigationOptions(documentNavigation.name)\n\n /** Grabs all of the current operation entries for the given path and method */\n const operationEntriesMap = getOperationEntries(documentNavigation)\n const entries = operationEntriesMap.get(`${meta.path}|${meta.method}`)\n\n // Updates the order ID so we don't lose the sidebar ordering when it rebuilds\n if (entries) {\n updateOrderIds({ store, operation, generateId, method: finalMethod, path: finalPath, entries })\n }\n\n // Initialize the paths object if it does not exist\n if (!document.paths) {\n document.paths = {}\n }\n\n // Initialize the new path if it does not exist\n if (!document.paths[finalPath]) {\n document.paths[finalPath] = {}\n }\n\n // Prevent assigning dangerous keys to the path items object\n preventPollution(finalPath)\n preventPollution(meta.path)\n preventPollution(finalMethod)\n\n // Move the operation to the new location\n document.paths[finalPath][finalMethod] = unpackProxyObject(operation)\n\n // Remove the operation from the old location\n const oldPathItems = document.paths[meta.path]\n if (oldPathItems && isHttpMethod(meta.method)) {\n delete oldPathItems[meta.method]\n\n // If the old path has no more operations, remove the path entry\n if (Object.keys(oldPathItems).length === 0) {\n delete document.paths[meta.path]\n }\n }\n\n // We need to reset the history for the operation when the path or method changes\n store.history.clearOperationHistory(document['x-scalar-navigation']?.name ?? '', meta.path, meta.method)\n\n callback('success')\n}\n\n/**\n * Deletes an operation from the workspace\n *\n * Example:\n * ```ts\n * deleteOperation({\n * document,\n * meta: { method: 'get', path: '/users' },\n * })\n * ```\n */\nexport const deleteOperation = (\n workspace: WorkspaceStore | null,\n { meta, documentName }: OperationEvents['operation:delete:operation'],\n) => {\n const document = workspace?.workspace.documents[documentName]\n if (!document) {\n return\n }\n\n preventPollution(meta.path)\n preventPollution(meta.method)\n\n delete document.paths?.[meta.path]?.[meta.method]\n\n // If the path has no more operations, remove the path entry\n if (Object.keys(document.paths?.[meta.path] ?? {}).length === 0) {\n delete document.paths?.[meta.path]\n }\n}\n\n/**\n * Adds an example name to the 'x-draft-examples' array for a specific operation in a document.\n *\n * - Finds the target operation using the provided path and method within the specified document.\n * - If the operation is found and has an 'x-draft-examples' array, pushes the new exampleName to it.\n * - Safely no-ops if the document or operation does not exist.\n */\nexport const createOperationDraftExample = (\n workspace: WorkspaceStore | null,\n { meta: { path, method }, documentName, exampleName }: OperationEvents['operation:create:draft-example'],\n) => {\n const document = workspace?.workspace.documents[documentName]\n if (!document) {\n console.error('Document not found', { documentName })\n return\n }\n\n const operation = getResolvedRef(document.paths?.[path]?.[method])\n if (!operation) {\n console.error('Operation not found', { path, method })\n return\n }\n\n // Ensure that the x-draft-examples array exists\n operation['x-draft-examples'] ??= []\n\n // Remove duplicates\n const dedupe = new Set(operation['x-draft-examples'])\n // Add the new example name\n dedupe.add(exampleName)\n // Update the operation with the new x-draft-examples array\n operation['x-draft-examples'] = Array.from(dedupe)\n}\n\n/**\n * Deletes an example with the given exampleKey from operation parameters and request body.\n *\n * - Finds the target operation within the specified document and path/method.\n * - Removes example values matching exampleKey from both parameter-level and content-level examples.\n * - Safely no-ops if the document, operation, or request body does not exist.\n */\nexport const deleteOperationExample = (\n workspace: WorkspaceStore | null,\n { meta: { path, method, exampleKey }, documentName }: OperationEvents['operation:delete:example'],\n) => {\n // Find the document in workspace based on documentName\n const document = workspace?.workspace.documents[documentName]\n if (!document) {\n return\n }\n\n // Get the operation object for the given path and method\n const operation = getResolvedRef(document.paths?.[path]?.[method])\n if (!operation) {\n return\n }\n\n // Remove the example from the x-draft-examples array\n const dedupe = new Set(operation['x-draft-examples'] ?? [])\n dedupe.delete(exampleKey)\n\n if (operation['x-draft-examples'] !== undefined) {\n operation['x-draft-examples'] = Array.from(dedupe)\n }\n\n // Remove the example from all operation parameters\n operation.parameters?.forEach((parameter) => {\n const resolvedParameter = getResolvedRef(parameter)\n\n // Remove from content-level examples (if parameter uses content)\n if ('content' in resolvedParameter && resolvedParameter.content) {\n Object.values(resolvedParameter.content).forEach((mediaType) => {\n delete mediaType.examples?.[exampleKey]\n })\n }\n\n // Remove from parameter-level examples\n if ('examples' in resolvedParameter && resolvedParameter.examples) {\n delete resolvedParameter.examples?.[exampleKey]\n }\n })\n\n // Remove the example from request body content types (if requestBody exists)\n const requestBody = getResolvedRef(operation.requestBody)\n if (!requestBody) {\n return\n }\n\n // For each media type, remove the example matching exampleKey\n Object.values(requestBody.content ?? {}).forEach((mediaType) => {\n delete mediaType.examples?.[exampleKey]\n })\n}\n"],
5
+ "mappings": "AACA,SAAS,oBAAoB;AAC7B,SAAS,wBAAwB;AACjC,SAAS,qBAAqB;AAI9B,SAAS,sBAAsB;AAC/B,SAAS,yBAAyB;AAClC,SAAS,mCAAmC;AAC5C,SAAS,2BAA2B;AACpC,SAAS,4BAA4B;AACrC,SAAS,sBAAsB;AAmBxB,MAAM,kBAAkB,CAC7B,gBACA,YACuB;AACvB,QAAM,WAAW,gBAAgB,UAAU,UAAU,QAAQ,YAAY;AACzE,MAAI,CAAC,UAAU;AACb,YAAQ,WAAW,KAAK;AACxB,WAAO;AAAA,EACT;AAEA,QAAM,EAAE,MAAM,QAAQ,UAAU,IAAI;AAGpC,QAAM,iBAAiB,KAAK,WAAW,GAAG,IAAI,OAAO,IAAI,IAAI;AA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