@scalar/workspace-store 0.28.1 → 0.28.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/dist/client.d.ts +10 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +42 -2
- package/dist/client.js.map +2 -2
- package/dist/entities/auth/index.d.ts +75 -0
- package/dist/entities/auth/index.d.ts.map +1 -0
- package/dist/entities/auth/index.js +89 -0
- package/dist/entities/auth/index.js.map +7 -0
- package/dist/entities/auth/schema.d.ts +7318 -0
- package/dist/entities/auth/schema.d.ts.map +1 -0
- package/dist/entities/auth/schema.js +74 -0
- package/dist/entities/auth/schema.js.map +7 -0
- package/dist/entities/history/index.d.ts +93 -0
- package/dist/entities/history/index.d.ts.map +1 -0
- package/dist/entities/history/index.js +62 -0
- package/dist/entities/history/index.js.map +7 -0
- package/dist/entities/history/schema.d.ts +234 -0
- package/dist/entities/history/schema.d.ts.map +1 -0
- package/dist/{schemas/extensions/operation/x-scalar-history.js → entities/history/schema.js} +5 -6
- package/dist/{schemas/extensions/operation/x-scalar-history.js.map → entities/history/schema.js.map} +3 -3
- package/dist/events/definitions/auth.d.ts +14 -0
- package/dist/events/definitions/auth.d.ts.map +1 -1
- package/dist/mutators/auth.d.ts +10 -17
- package/dist/mutators/auth.d.ts.map +1 -1
- package/dist/mutators/auth.js +87 -57
- package/dist/mutators/auth.js.map +2 -2
- package/dist/mutators/index.d.ts +4 -12
- package/dist/mutators/index.d.ts.map +1 -1
- package/dist/mutators/index.js +1 -1
- package/dist/mutators/index.js.map +2 -2
- package/dist/mutators/operation.d.ts +2 -2
- package/dist/mutators/operation.d.ts.map +1 -1
- package/dist/mutators/operation.js +9 -16
- package/dist/mutators/operation.js.map +2 -2
- package/dist/mutators/server.d.ts.map +1 -1
- package/dist/mutators/server.js +0 -3
- package/dist/mutators/server.js.map +2 -2
- package/dist/persistence/index.d.ts +16 -3
- package/dist/persistence/index.d.ts.map +1 -1
- package/dist/persistence/index.js +47 -3
- package/dist/persistence/index.js.map +2 -2
- package/dist/plugins/bundler/index.d.ts +7 -0
- package/dist/plugins/bundler/index.d.ts.map +1 -1
- package/dist/plugins/bundler/index.js +17 -0
- package/dist/plugins/bundler/index.js.map +2 -2
- package/dist/plugins/client/persistence.d.ts.map +1 -1
- package/dist/plugins/client/persistence.js +12 -0
- package/dist/plugins/client/persistence.js.map +2 -2
- package/dist/resolve.d.ts +9 -0
- package/dist/resolve.d.ts.map +1 -0
- package/dist/resolve.js +28 -0
- package/dist/resolve.js.map +7 -0
- package/dist/schemas/extensions/security/index.d.ts +2 -0
- package/dist/schemas/extensions/security/index.d.ts.map +1 -0
- package/dist/schemas/extensions/security/index.js +1 -0
- package/dist/schemas/extensions/security/index.js.map +7 -0
- package/dist/schemas/inmemory-workspace.d.ts +2952 -149
- package/dist/schemas/inmemory-workspace.d.ts.map +1 -1
- package/dist/schemas/inmemory-workspace.js +5 -1
- package/dist/schemas/inmemory-workspace.js.map +2 -2
- package/dist/schemas/reference-config/index.d.ts +35 -149
- package/dist/schemas/reference-config/index.d.ts.map +1 -1
- package/dist/schemas/reference-config/settings.d.ts +35 -149
- package/dist/schemas/reference-config/settings.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/oauth-flow.d.ts +5 -35
- package/dist/schemas/v3.1/strict/oauth-flow.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/oauth-flow.js +1 -16
- package/dist/schemas/v3.1/strict/oauth-flow.js.map +2 -2
- package/dist/schemas/v3.1/strict/oauthflows.d.ts +0 -29
- package/dist/schemas/v3.1/strict/oauthflows.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/openapi-document.d.ts +1245 -6744
- package/dist/schemas/v3.1/strict/openapi-document.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/openapi-document.js +2 -10
- package/dist/schemas/v3.1/strict/openapi-document.js.map +2 -2
- package/dist/schemas/v3.1/strict/operation.d.ts +1 -70
- package/dist/schemas/v3.1/strict/operation.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/operation.js +1 -7
- package/dist/schemas/v3.1/strict/operation.js.map +2 -2
- package/dist/schemas/v3.1/strict/ref-definitions.d.ts +0 -1
- package/dist/schemas/v3.1/strict/ref-definitions.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/ref-definitions.js +1 -3
- package/dist/schemas/v3.1/strict/ref-definitions.js.map +2 -2
- package/dist/schemas/v3.1/strict/schema.d.ts +50 -46
- package/dist/schemas/v3.1/strict/schema.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/schema.js +5 -2
- package/dist/schemas/v3.1/strict/schema.js.map +2 -2
- package/dist/schemas/v3.1/strict/security-scheme.d.ts +3 -11
- package/dist/schemas/v3.1/strict/security-scheme.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/security-scheme.js +0 -7
- package/dist/schemas/v3.1/strict/security-scheme.js.map +2 -2
- package/dist/schemas/workspace.d.ts +245 -1043
- package/dist/schemas/workspace.d.ts.map +1 -1
- package/dist/workspace-plugin.d.ts +8 -0
- package/dist/workspace-plugin.d.ts.map +1 -1
- package/package.json +26 -6
- package/dist/schemas/extensions/operation/x-scalar-history.d.ts +0 -217
- package/dist/schemas/extensions/operation/x-scalar-history.d.ts.map +0 -1
- package/dist/schemas/extensions/security/x-scalar-selected-security.d.ts +0 -17
- package/dist/schemas/extensions/security/x-scalar-selected-security.d.ts.map +0 -1
- package/dist/schemas/extensions/security/x-scalar-selected-security.js +0 -14
- package/dist/schemas/extensions/security/x-scalar-selected-security.js.map +0 -7
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/mutators/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 { HooksEvents } from '@/events/definitions/hooks'\nimport type { OperationEvents } from '@/events/definitions/operation'\nimport { getResolvedRef } from '@/helpers/get-resolved-ref'\nimport { unpackProxyObject } from '@/helpers/unpack-proxy'\nimport { fetchRequestToHar } from '@/mutators/fetch-request-to-har'\nimport { fetchResponseToHar } from '@/mutators/fetch-response-to-har'\nimport { harToOperation } from '@/mutators/har-to-operation'\nimport { getOpenapiObject, getOperationEntries } from '@/navigation'\nimport { getNavigationOptions } from '@/navigation/get-navigation-options'\nimport { canHaveOrder } from '@/navigation/helpers/get-openapi-object'\nimport type { WorkspaceDocument } from '@/schemas'\nimport type { DisableParametersConfig } from '@/schemas/extensions/operation/x-scalar-disable-parameters'\nimport type { IdGenerator, TraversedOperation, TraversedWebhook, WithParent } from '@/schemas/navigation'\nimport type { ExampleObject, OperationObject, ParameterObject } from '@/schemas/v3.1/strict/openapi-document'\nimport type { ReferenceType } from '@/schemas/v3.1/strict/reference'\nimport { isContentTypeParameterObject } from '@/schemas/v3.1/strict/type-guards'\n\n/** ------------------------------------------------------------------------------------------------\n * Helper Functions for Path Parameter Synchronization\n * ------------------------------------------------------------------------------------------------ */\n\n/**\n * Creates a map of parameter names to their character positions in a path.\n * Used to detect renamed path parameters by position matching.\n */\nconst getParameterPositions = (path: string, parameters: readonly string[]): Record<string, number> => {\n const positions: Record<string, number> = {}\n\n for (const paramName of parameters) {\n const position = path.indexOf(`{${paramName}}`)\n if (position !== -1) {\n positions[paramName] = position\n }\n }\n\n return positions\n}\n\n/**\n * Syncs path parameters when the path changes.\n *\n * Preserves parameter configurations by:\n * 1. Keeping parameters with matching names\n * 2. Renaming parameters at the same position\n * 3. Creating new parameters with empty examples\n * 4. Removing parameters that no longer exist in the new path\n */\nconst syncParametersForPathChange = (\n newPath: string,\n oldPath: string,\n existingParameters: ReferenceType<ParameterObject>[],\n): ReferenceType<ParameterObject>[] => {\n // Extract path parameter names from both paths\n const oldPathParams = findVariables(oldPath, { includePath: true, includeEnv: false }).filter(\n (v): v is string => v !== undefined,\n )\n const newPathParams = findVariables(newPath, { includePath: true, includeEnv: false }).filter(\n (v): v is string => v !== undefined,\n )\n\n const oldPositions = getParameterPositions(oldPath, oldPathParams)\n const newPositions = getParameterPositions(newPath, newPathParams)\n\n // Separate path and non-path parameters, resolving each parameter only once\n const pathParameters: ParameterObject[] = []\n const nonPathParameters: ReferenceType<ParameterObject>[] = []\n\n for (const param of existingParameters) {\n const resolved = getResolvedRef(param)\n if (resolved?.in === 'path') {\n pathParameters.push(resolved)\n } else {\n nonPathParameters.push(param)\n }\n }\n\n // Create a map of existing path parameters by name for quick lookup\n const existingPathParamsByName = new Map<string, ParameterObject>()\n for (const param of pathParameters) {\n if (param.name) {\n existingPathParamsByName.set(param.name, param)\n }\n }\n\n const usedOldParams = new Set<string>()\n const syncedPathParameters: ReferenceType<ParameterObject>[] = []\n\n for (const newParamName of newPathParams) {\n // Case 1: Parameter with same name exists - preserve its config\n if (existingPathParamsByName.has(newParamName)) {\n syncedPathParameters.push(existingPathParamsByName.get(newParamName)!)\n usedOldParams.add(newParamName)\n continue\n }\n\n // Case 2: Check for parameter at same position (likely a rename)\n const newParamPosition = newPositions[newParamName]\n const oldParamAtPosition = oldPathParams.find(\n (oldParam) => oldPositions[oldParam] === newParamPosition && !usedOldParams.has(oldParam),\n )\n\n // Rename: transfer the old parameter's config to the new name\n if (oldParamAtPosition && existingPathParamsByName.has(oldParamAtPosition)) {\n const oldParam = existingPathParamsByName.get(oldParamAtPosition)!\n oldParam.name = newParamName\n syncedPathParameters.push(oldParam)\n usedOldParams.add(oldParamAtPosition)\n continue\n }\n\n // Case 3: New parameter - create with empty examples\n syncedPathParameters.push({\n name: newParamName,\n in: 'path',\n })\n }\n\n // Return all parameters: synced path parameters + preserved non-path parameters\n return unpackProxyObject([...syncedPathParameters, ...nonPathParameters], { depth: 1 })\n}\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 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 document: WorkspaceDocument | null,\n { meta, payload: { summary } }: OperationEvents['operation:update:summary'],\n) => {\n if (!document) {\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\n/**\n * Updates the order ID of an operation in the sidebar.\n * Used when changing path or method so we do not lose the sidebar ordering\n */\nconst updateOperationOrderId = ({\n store,\n operation,\n generateId,\n method,\n path,\n entries,\n}: {\n store: WorkspaceStore\n operation: OperationObject\n generateId: IdGenerator\n method: HttpMethod\n path: string\n entries: (WithParent<TraversedOperation> | WithParent<TraversedWebhook>)[]\n}) => {\n // Loop over the entries and replace the ID in the x-scalar-order with the new ID\n entries?.forEach((entry) => {\n if (!canHaveOrder(entry.parent)) {\n return\n }\n\n // Ensure we have an x-scalar-order property\n const parentOpenAPIObject = getOpenapiObject({ store, entry: entry.parent })\n if (!parentOpenAPIObject || !('x-scalar-order' in parentOpenAPIObject)) {\n return\n }\n\n const order = parentOpenAPIObject['x-scalar-order']\n const index = order?.indexOf(entry.id)\n if (!Array.isArray(order) || typeof index !== 'number' || index < 0) {\n return\n }\n\n const parentTag =\n entry.parent.type === 'tag' && 'name' in parentOpenAPIObject\n ? { tag: parentOpenAPIObject, id: entry.parent.id }\n : undefined\n\n // Generate the new ID based on whether this is an operation or webhook\n order[index] = generateId({\n type: 'operation',\n path,\n method,\n operation,\n parentId: entry.parent.id,\n parentTag,\n })\n })\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 updateOperationOrderId({ 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 delete operation['x-scalar-history']\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 * 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 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\n/** ------------------------------------------------------------------------------------------------\n * Operation Parameters Mutators\n * ------------------------------------------------------------------------------------------------ */\n\n/**\n * Updates an existing parameter of a given `type` by its index within that\n * type subset (e.g. the N-th query parameter). Supports updating name, value,\n * and enabled state for the targeted example.\n * Safely no-ops if the document, operation, or parameter does not exist.\n *\n * Example:\n * ```ts\n * updateOperationParameter({\n * document,\n * type: 'query',\n * index: 0,\n * meta: { method: 'get', path: '/search', exampleKey: 'default' },\n * payload: { value: 'alice', isDisabled: false },\n * })\n * ```\n */\nexport const upsertOperationParameter = (\n document: WorkspaceDocument | null,\n { meta, type, payload, originalParameter }: OperationEvents['operation:upsert:parameter'],\n) => {\n // We are editing an existing parameter\n if (originalParameter) {\n originalParameter.name = payload.name\n\n if (isContentTypeParameterObject(originalParameter)) {\n // TODO: handle content-type parameters\n return\n }\n\n if (!originalParameter.examples) {\n originalParameter.examples = {}\n }\n\n // Create the example if it doesn't exist\n originalParameter.examples[meta.exampleKey] ||= {}\n const example = getResolvedRef(originalParameter.examples[meta.exampleKey])!\n\n // Update the example value and disabled state\n example.value = payload.value\n example['x-disabled'] = payload.isDisabled\n return\n }\n\n // We are adding a new parameter\n const operation = getResolvedRef(document?.paths?.[meta.path]?.[meta.method])\n if (!operation) {\n console.error('Operation not found', { meta, document })\n return\n }\n\n operation.parameters ||= []\n operation.parameters.push({\n name: payload.name,\n in: type,\n required: type === 'path' ? true : false,\n examples: {\n [meta.exampleKey]: {\n value: payload.value,\n // We always want a new parameter to be enabled by default\n 'x-disabled': false,\n },\n },\n })\n return\n}\n\n/**\n * Updates the disabled state of a default parameter for an operation.\n * Default parameters are inherited from higher-level configurations (like collection or server defaults)\n * and this allows individual operations to selectively disable them without removing them entirely.\n *\n * The disabled state is stored in the `x-scalar-disable-parameters` extension object, organized by\n * parameter type and example key. Missing objects are initialized automatically.\n *\n * @param document - The current workspace document\n * @param type - The parameter type (e.g., 'header'). Determines the storage key ('default-headers' for headers)\n * @param meta.path - Path of the operation (e.g., '/users')\n * @param meta.method - HTTP method of the operation (e.g., 'get')\n * @param meta.exampleKey - Key identifying the relevant example\n * @param meta.key - The specific parameter key being updated\n * @param payload.isDisabled - Whether the parameter should be disabled\n */\nexport const updateOperationExtraParameters = (\n document: WorkspaceDocument | null,\n { type, meta, payload, in: location }: OperationEvents['operation:update:extra-parameters'],\n) => {\n type Type = OperationEvents['operation:update:extra-parameters']['type']\n type In = OperationEvents['operation:update:extra-parameters']['in']\n\n // Ensure there's a valid document\n if (!document) {\n return\n }\n\n // Resolve the referenced operation from the document using the path and method\n const operation = getResolvedRef(document.paths?.[meta.path]?.[meta.method])\n if (!operation) {\n return\n }\n\n // Initialize the 'x-scalar-disable-parameters' object if it doesn't exist\n if (!operation['x-scalar-disable-parameters']) {\n operation['x-scalar-disable-parameters'] = {}\n }\n\n /**\n * Maps parameter type and location to the corresponding config key.\n * Only valid combinations are defined here.\n */\n const mapping: Partial<Record<Type, Partial<Record<In, keyof DisableParametersConfig>>>> = {\n global: { cookie: 'global-cookies' },\n default: { header: 'default-headers' },\n }\n\n const key = mapping[type]?.[location]\n\n if (!key) {\n return\n }\n\n // Initialize the 'default-headers' object within 'x-scalar-disable-parameters' if it doesn't exist\n if (!operation['x-scalar-disable-parameters'][key]) {\n operation['x-scalar-disable-parameters'][key] = {}\n }\n\n // Update (or create) the entry for the specific example and key, preserving any existing settings\n operation['x-scalar-disable-parameters'][key][meta.exampleKey] = {\n ...(operation['x-scalar-disable-parameters'][key][meta.exampleKey] ?? {}),\n [meta.name]: payload.isDisabled ?? false,\n }\n}\n\n/**\n * Removes a parameter from the operation OR path\n *\n * Example:\n * ```ts\n * deleteOperationParameter({\n * document,\n * originalParameter,\n * meta: { method: 'get', path: '/users', exampleKey: 'default' },\n * })\n * ```\n */\nexport const deleteOperationParameter = (\n document: WorkspaceDocument | null,\n { meta, originalParameter }: OperationEvents['operation:delete:parameter'],\n) => {\n const operation = getResolvedRef(document?.paths?.[meta.path]?.[meta.method])\n\n // Lets check if its on the operation first as its more likely\n const operationIndex = operation?.parameters?.findIndex((it) => getResolvedRef(it) === originalParameter) ?? -1\n\n // We cannot call splice on a proxy object, so we unwrap the array and filter it\n if (operation && operationIndex >= 0) {\n operation.parameters = unpackProxyObject(\n operation.parameters?.filter((_, i) => i !== operationIndex),\n { depth: 1 },\n )\n return\n }\n\n // If it wasn't on the operation it might be on the path\n const path = getResolvedRef(document?.paths?.[meta.path])\n const pathIndex = path?.parameters?.findIndex((it) => getResolvedRef(it) === originalParameter) ?? -1\n\n if (path && pathIndex >= 0) {\n path.parameters = unpackProxyObject(\n path.parameters?.filter((_, i) => i !== pathIndex),\n { depth: 1 },\n )\n }\n}\n\n/**\n * Deletes all parameters of a given `type` from the operation.\n * Safely no-ops if the document or operation does not exist.\n *\n * Example:\n * ```ts\n * deleteAllOperationParameters({\n * document,\n * type: 'cookie',\n * meta: { method: 'get', path: '/users' },\n * })\n * ```\n */\nexport const deleteAllOperationParameters = (\n document: WorkspaceDocument | null,\n { meta, type }: OperationEvents['operation:delete-all:parameters'],\n) => {\n if (!document) {\n return\n }\n\n const operation = getResolvedRef(document.paths?.[meta.path]?.[meta.method])\n if (!operation) {\n return\n }\n\n // Filter out parameters of the specified type\n operation.parameters = operation.parameters?.filter((it) => getResolvedRef(it).in !== type) ?? []\n}\n\n/** ------------------------------------------------------------------------------------------------\n * Operation Request Body Mutators\n * ------------------------------------------------------------------------------------------------ */\n\n/**\n * Sets the selected request-body content type for the current `exampleKey`.\n * This stores the selection under `x-scalar-selected-content-type` on the\n * resolved requestBody. Safely no-ops if the document or operation does not exist.\n *\n * Example:\n * ```ts\n * updateOperationRequestBodyContentType({\n * document,\n * meta: { method: 'post', path: '/upload', exampleKey: 'default' },\n * payload: { contentType: 'multipart/form-data' },\n * })\n * ```\n */\nexport const updateOperationRequestBodyContentType = (\n document: WorkspaceDocument | null,\n { meta, payload }: OperationEvents['operation:update:requestBody:contentType'],\n) => {\n if (!document) {\n return\n }\n\n const operation = getResolvedRef(document.paths?.[meta.path]?.[meta.method])\n if (!operation) {\n return\n }\n\n let requestBody = getResolvedRef(operation.requestBody)\n if (!requestBody) {\n operation.requestBody = {\n content: {},\n }\n requestBody = getResolvedRef(operation.requestBody)\n }\n\n if (!requestBody!['x-scalar-selected-content-type']) {\n requestBody!['x-scalar-selected-content-type'] = {}\n }\n\n requestBody!['x-scalar-selected-content-type'][meta.exampleKey] = payload.contentType\n}\n\n/** Ensure the json that we need exists up to the example object in the request body */\nconst findOrCreateRequestBodyExample = (\n document: WorkspaceDocument | null,\n contentType: string,\n meta: OperationEvents['operation:update:requestBody:contentType']['meta'],\n): ExampleObject | null => {\n const operation = getResolvedRef(document?.paths?.[meta.path]?.[meta.method])\n if (!operation) {\n return null\n }\n\n // Ensure that the request body exists\n let requestBody = getResolvedRef(operation.requestBody)\n if (!requestBody) {\n operation.requestBody = {\n content: {},\n }\n requestBody = getResolvedRef(operation.requestBody)\n }\n\n // Ensure that the example exists\n requestBody.content[contentType] ||= {}\n requestBody.content[contentType].examples ||= {}\n requestBody.content[contentType].examples[meta.exampleKey] ||= {}\n\n const example = getResolvedRef(requestBody.content[contentType].examples?.[meta.exampleKey])\n return example ?? null\n}\n\n/**\n * Creates or updates a concrete example value for a specific request-body\n * `contentType` and `exampleKey`. Safely no-ops if the document or operation\n * does not exist.\n *\n * Example:\n * ```ts\n * updateOperationRequestBodyExample({\n * document,\n * contentType: 'application/json',\n * meta: { method: 'post', path: '/users', exampleKey: 'default' },\n * payload: { value: JSON.stringify({ name: 'Ada' }) },\n * })\n * ```\n */\nexport const updateOperationRequestBodyExample = (\n document: WorkspaceDocument | null,\n { meta, payload, contentType }: OperationEvents['operation:update:requestBody:value'],\n) => {\n const example = findOrCreateRequestBodyExample(document, contentType, meta)\n if (!example) {\n console.error('Example not found', meta.exampleKey)\n return\n }\n\n example.value = payload\n}\n\n/**\n * Stores the form data for the request body example\n *\n * This needs special handling as we store it as an array of objects with a schema type of object\n */\nexport const updateOperationRequestBodyFormValue = (\n document: WorkspaceDocument | null,\n { meta, payload, contentType }: OperationEvents['operation:update:requestBody:formValue'],\n) => {\n const example = findOrCreateRequestBodyExample(document, contentType, meta)\n if (!example) {\n console.error('Example not found', meta.exampleKey)\n return\n }\n\n example.value = unpackProxyObject(payload, { depth: 3 })\n}\n\nconst HISTORY_LIMIT = 5\n\nexport const addResponseToHistory = async (\n document: WorkspaceDocument | null,\n { payload, meta }: HooksEvents['hooks:on:request:complete'],\n) => {\n if (!document || !payload) {\n return\n }\n\n const operation = getResolvedRef(document.paths?.[meta.path]?.[meta.method])\n if (!operation) {\n return\n }\n\n const operationParameters = operation.parameters ?? []\n\n // Get all the variables from the operation parameters\n const variables = operationParameters.reduce<Record<string, string>>((acc, param) => {\n const resolvedParam = getResolvedRef(param)\n if (isContentTypeParameterObject(resolvedParam)) {\n return acc\n }\n if (resolvedParam.in === 'path') {\n acc[resolvedParam.name] = getResolvedRef(resolvedParam.examples?.[meta.exampleKey])?.value ?? ''\n }\n return acc\n }, {})\n\n const requestHar = await fetchRequestToHar({ request: payload.request })\n const responseHar = await fetchResponseToHar({ response: payload.response })\n\n operation['x-scalar-history'] ||= []\n // If the history is full, remove the oldest entry\n if (operation['x-scalar-history'].length >= HISTORY_LIMIT) {\n // We need to unpack the history array to avoid proxy object issues\n operation['x-scalar-history'] = unpackProxyObject(\n operation['x-scalar-history'].filter((_, i) => i !== 0),\n { depth: 1 },\n )\n }\n // Add the new entry to the history\n operation['x-scalar-history'].push({\n response: responseHar,\n request: requestHar,\n meta: {\n example: meta.exampleKey,\n },\n time: payload.duration,\n timestamp: payload.timestamp,\n requestMetadata: {\n variables,\n },\n })\n}\n\nexport const reloadOperationHistory = (\n document: WorkspaceDocument | null,\n { meta, index, callback }: OperationEvents['operation:reload:history'],\n) => {\n if (!document) {\n console.error('Document not found', meta.path, meta.method)\n return\n }\n\n const operation = getResolvedRef(document.paths?.[meta.path]?.[meta.method])\n if (!operation) {\n console.error('Operation not found', meta.path, meta.method)\n return\n }\n\n const historyItem = operation['x-scalar-history']?.[index]\n if (!historyItem) {\n console.error('History item not found', index)\n return\n }\n\n harToOperation({\n harRequest: historyItem.request,\n exampleKey: 'draft',\n baseOperation: operation,\n pathVariables: historyItem.requestMetadata.variables,\n })\n callback('success')\n}\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(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 deleteOperationExample: (payload: OperationEvents['operation:delete:example']) =>\n deleteOperationExample(store, 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(document, payload),\n reloadOperationHistory: (payload: OperationEvents['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AAC,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,UAAU,OAAO;AAAA,IACxC,wBAAwB,CAAC,YACvB,uBAAuB,UAAU,OAAO;AAAA,EAC5C;AACF;",
|
|
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 { HooksEvents } from '@/events/definitions/hooks'\nimport type { OperationEvents } from '@/events/definitions/operation'\nimport { getResolvedRef } from '@/helpers/get-resolved-ref'\nimport { unpackProxyObject } from '@/helpers/unpack-proxy'\nimport { fetchRequestToHar } from '@/mutators/fetch-request-to-har'\nimport { fetchResponseToHar } from '@/mutators/fetch-response-to-har'\nimport { harToOperation } from '@/mutators/har-to-operation'\nimport { getOpenapiObject, getOperationEntries } from '@/navigation'\nimport { getNavigationOptions } from '@/navigation/get-navigation-options'\nimport { canHaveOrder } from '@/navigation/helpers/get-openapi-object'\nimport type { WorkspaceDocument } from '@/schemas'\nimport type { DisableParametersConfig } from '@/schemas/extensions/operation/x-scalar-disable-parameters'\nimport type { IdGenerator, TraversedOperation, TraversedWebhook, WithParent } from '@/schemas/navigation'\nimport type { ExampleObject, OperationObject, ParameterObject } from '@/schemas/v3.1/strict/openapi-document'\nimport type { ReferenceType } from '@/schemas/v3.1/strict/reference'\nimport { isContentTypeParameterObject } from '@/schemas/v3.1/strict/type-guards'\n\n/** ------------------------------------------------------------------------------------------------\n * Helper Functions for Path Parameter Synchronization\n * ------------------------------------------------------------------------------------------------ */\n\n/**\n * Creates a map of parameter names to their character positions in a path.\n * Used to detect renamed path parameters by position matching.\n */\nconst getParameterPositions = (path: string, parameters: readonly string[]): Record<string, number> => {\n const positions: Record<string, number> = {}\n\n for (const paramName of parameters) {\n const position = path.indexOf(`{${paramName}}`)\n if (position !== -1) {\n positions[paramName] = position\n }\n }\n\n return positions\n}\n\n/**\n * Syncs path parameters when the path changes.\n *\n * Preserves parameter configurations by:\n * 1. Keeping parameters with matching names\n * 2. Renaming parameters at the same position\n * 3. Creating new parameters with empty examples\n * 4. Removing parameters that no longer exist in the new path\n */\nconst syncParametersForPathChange = (\n newPath: string,\n oldPath: string,\n existingParameters: ReferenceType<ParameterObject>[],\n): ReferenceType<ParameterObject>[] => {\n // Extract path parameter names from both paths\n const oldPathParams = findVariables(oldPath, { includePath: true, includeEnv: false }).filter(\n (v): v is string => v !== undefined,\n )\n const newPathParams = findVariables(newPath, { includePath: true, includeEnv: false }).filter(\n (v): v is string => v !== undefined,\n )\n\n const oldPositions = getParameterPositions(oldPath, oldPathParams)\n const newPositions = getParameterPositions(newPath, newPathParams)\n\n // Separate path and non-path parameters, resolving each parameter only once\n const pathParameters: ParameterObject[] = []\n const nonPathParameters: ReferenceType<ParameterObject>[] = []\n\n for (const param of existingParameters) {\n const resolved = getResolvedRef(param)\n if (resolved?.in === 'path') {\n pathParameters.push(resolved)\n } else {\n nonPathParameters.push(param)\n }\n }\n\n // Create a map of existing path parameters by name for quick lookup\n const existingPathParamsByName = new Map<string, ParameterObject>()\n for (const param of pathParameters) {\n if (param.name) {\n existingPathParamsByName.set(param.name, param)\n }\n }\n\n const usedOldParams = new Set<string>()\n const syncedPathParameters: ReferenceType<ParameterObject>[] = []\n\n for (const newParamName of newPathParams) {\n // Case 1: Parameter with same name exists - preserve its config\n if (existingPathParamsByName.has(newParamName)) {\n syncedPathParameters.push(existingPathParamsByName.get(newParamName)!)\n usedOldParams.add(newParamName)\n continue\n }\n\n // Case 2: Check for parameter at same position (likely a rename)\n const newParamPosition = newPositions[newParamName]\n const oldParamAtPosition = oldPathParams.find(\n (oldParam) => oldPositions[oldParam] === newParamPosition && !usedOldParams.has(oldParam),\n )\n\n // Rename: transfer the old parameter's config to the new name\n if (oldParamAtPosition && existingPathParamsByName.has(oldParamAtPosition)) {\n const oldParam = existingPathParamsByName.get(oldParamAtPosition)!\n oldParam.name = newParamName\n syncedPathParameters.push(oldParam)\n usedOldParams.add(oldParamAtPosition)\n continue\n }\n\n // Case 3: New parameter - create with empty examples\n syncedPathParameters.push({\n name: newParamName,\n in: 'path',\n })\n }\n\n // Return all parameters: synced path parameters + preserved non-path parameters\n return unpackProxyObject([...syncedPathParameters, ...nonPathParameters], { depth: 1 })\n}\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 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 document: WorkspaceDocument | null,\n { meta, payload: { summary } }: OperationEvents['operation:update:summary'],\n) => {\n if (!document) {\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\n/**\n * Updates the order ID of an operation in the sidebar.\n * Used when changing path or method so we do not lose the sidebar ordering\n */\nconst updateOperationOrderId = ({\n store,\n operation,\n generateId,\n method,\n path,\n entries,\n}: {\n store: WorkspaceStore\n operation: OperationObject\n generateId: IdGenerator\n method: HttpMethod\n path: string\n entries: (WithParent<TraversedOperation> | WithParent<TraversedWebhook>)[]\n}) => {\n // Loop over the entries and replace the ID in the x-scalar-order with the new ID\n entries?.forEach((entry) => {\n if (!canHaveOrder(entry.parent)) {\n return\n }\n\n // Ensure we have an x-scalar-order property\n const parentOpenAPIObject = getOpenapiObject({ store, entry: entry.parent })\n if (!parentOpenAPIObject || !('x-scalar-order' in parentOpenAPIObject)) {\n return\n }\n\n const order = parentOpenAPIObject['x-scalar-order']\n const index = order?.indexOf(entry.id)\n if (!Array.isArray(order) || typeof index !== 'number' || index < 0) {\n return\n }\n\n const parentTag =\n entry.parent.type === 'tag' && 'name' in parentOpenAPIObject\n ? { tag: parentOpenAPIObject, id: entry.parent.id }\n : undefined\n\n // Generate the new ID based on whether this is an operation or webhook\n order[index] = generateId({\n type: 'operation',\n path,\n method,\n operation,\n parentId: entry.parent.id,\n parentTag,\n })\n })\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 updateOperationOrderId({ 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 * 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 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\n/** ------------------------------------------------------------------------------------------------\n * Operation Parameters Mutators\n * ------------------------------------------------------------------------------------------------ */\n\n/**\n * Updates an existing parameter of a given `type` by its index within that\n * type subset (e.g. the N-th query parameter). Supports updating name, value,\n * and enabled state for the targeted example.\n * Safely no-ops if the document, operation, or parameter does not exist.\n *\n * Example:\n * ```ts\n * updateOperationParameter({\n * document,\n * type: 'query',\n * index: 0,\n * meta: { method: 'get', path: '/search', exampleKey: 'default' },\n * payload: { value: 'alice', isDisabled: false },\n * })\n * ```\n */\nexport const upsertOperationParameter = (\n document: WorkspaceDocument | null,\n { meta, type, payload, originalParameter }: OperationEvents['operation:upsert:parameter'],\n) => {\n // We are editing an existing parameter\n if (originalParameter) {\n originalParameter.name = payload.name\n\n if (isContentTypeParameterObject(originalParameter)) {\n // TODO: handle content-type parameters\n return\n }\n\n if (!originalParameter.examples) {\n originalParameter.examples = {}\n }\n\n // Create the example if it doesn't exist\n originalParameter.examples[meta.exampleKey] ||= {}\n const example = getResolvedRef(originalParameter.examples[meta.exampleKey])!\n\n // Update the example value and disabled state\n example.value = payload.value\n example['x-disabled'] = payload.isDisabled\n return\n }\n\n // We are adding a new parameter\n const operation = getResolvedRef(document?.paths?.[meta.path]?.[meta.method])\n if (!operation) {\n console.error('Operation not found', { meta, document })\n return\n }\n\n operation.parameters ||= []\n operation.parameters.push({\n name: payload.name,\n in: type,\n required: type === 'path' ? true : false,\n examples: {\n [meta.exampleKey]: {\n value: payload.value,\n // We always want a new parameter to be enabled by default\n 'x-disabled': false,\n },\n },\n })\n return\n}\n\n/**\n * Updates the disabled state of a default parameter for an operation.\n * Default parameters are inherited from higher-level configurations (like collection or server defaults)\n * and this allows individual operations to selectively disable them without removing them entirely.\n *\n * The disabled state is stored in the `x-scalar-disable-parameters` extension object, organized by\n * parameter type and example key. Missing objects are initialized automatically.\n *\n * @param document - The current workspace document\n * @param type - The parameter type (e.g., 'header'). Determines the storage key ('default-headers' for headers)\n * @param meta.path - Path of the operation (e.g., '/users')\n * @param meta.method - HTTP method of the operation (e.g., 'get')\n * @param meta.exampleKey - Key identifying the relevant example\n * @param meta.key - The specific parameter key being updated\n * @param payload.isDisabled - Whether the parameter should be disabled\n */\nexport const updateOperationExtraParameters = (\n document: WorkspaceDocument | null,\n { type, meta, payload, in: location }: OperationEvents['operation:update:extra-parameters'],\n) => {\n type Type = OperationEvents['operation:update:extra-parameters']['type']\n type In = OperationEvents['operation:update:extra-parameters']['in']\n\n // Ensure there's a valid document\n if (!document) {\n return\n }\n\n // Resolve the referenced operation from the document using the path and method\n const operation = getResolvedRef(document.paths?.[meta.path]?.[meta.method])\n if (!operation) {\n return\n }\n\n // Initialize the 'x-scalar-disable-parameters' object if it doesn't exist\n if (!operation['x-scalar-disable-parameters']) {\n operation['x-scalar-disable-parameters'] = {}\n }\n\n /**\n * Maps parameter type and location to the corresponding config key.\n * Only valid combinations are defined here.\n */\n const mapping: Partial<Record<Type, Partial<Record<In, keyof DisableParametersConfig>>>> = {\n global: { cookie: 'global-cookies' },\n default: { header: 'default-headers' },\n }\n\n const key = mapping[type]?.[location]\n\n if (!key) {\n return\n }\n\n // Initialize the 'default-headers' object within 'x-scalar-disable-parameters' if it doesn't exist\n if (!operation['x-scalar-disable-parameters'][key]) {\n operation['x-scalar-disable-parameters'][key] = {}\n }\n\n // Update (or create) the entry for the specific example and key, preserving any existing settings\n operation['x-scalar-disable-parameters'][key][meta.exampleKey] = {\n ...(operation['x-scalar-disable-parameters'][key][meta.exampleKey] ?? {}),\n [meta.name]: payload.isDisabled ?? false,\n }\n}\n\n/**\n * Removes a parameter from the operation OR path\n *\n * Example:\n * ```ts\n * deleteOperationParameter({\n * document,\n * originalParameter,\n * meta: { method: 'get', path: '/users', exampleKey: 'default' },\n * })\n * ```\n */\nexport const deleteOperationParameter = (\n document: WorkspaceDocument | null,\n { meta, originalParameter }: OperationEvents['operation:delete:parameter'],\n) => {\n const operation = getResolvedRef(document?.paths?.[meta.path]?.[meta.method])\n\n // Lets check if its on the operation first as its more likely\n const operationIndex = operation?.parameters?.findIndex((it) => getResolvedRef(it) === originalParameter) ?? -1\n\n // We cannot call splice on a proxy object, so we unwrap the array and filter it\n if (operation && operationIndex >= 0) {\n operation.parameters = unpackProxyObject(\n operation.parameters?.filter((_, i) => i !== operationIndex),\n { depth: 1 },\n )\n return\n }\n\n // If it wasn't on the operation it might be on the path\n const path = getResolvedRef(document?.paths?.[meta.path])\n const pathIndex = path?.parameters?.findIndex((it) => getResolvedRef(it) === originalParameter) ?? -1\n\n if (path && pathIndex >= 0) {\n path.parameters = unpackProxyObject(\n path.parameters?.filter((_, i) => i !== pathIndex),\n { depth: 1 },\n )\n }\n}\n\n/**\n * Deletes all parameters of a given `type` from the operation.\n * Safely no-ops if the document or operation does not exist.\n *\n * Example:\n * ```ts\n * deleteAllOperationParameters({\n * document,\n * type: 'cookie',\n * meta: { method: 'get', path: '/users' },\n * })\n * ```\n */\nexport const deleteAllOperationParameters = (\n document: WorkspaceDocument | null,\n { meta, type }: OperationEvents['operation:delete-all:parameters'],\n) => {\n if (!document) {\n return\n }\n\n const operation = getResolvedRef(document.paths?.[meta.path]?.[meta.method])\n if (!operation) {\n return\n }\n\n // Filter out parameters of the specified type\n operation.parameters = operation.parameters?.filter((it) => getResolvedRef(it).in !== type) ?? []\n}\n\n/** ------------------------------------------------------------------------------------------------\n * Operation Request Body Mutators\n * ------------------------------------------------------------------------------------------------ */\n\n/**\n * Sets the selected request-body content type for the current `exampleKey`.\n * This stores the selection under `x-scalar-selected-content-type` on the\n * resolved requestBody. Safely no-ops if the document or operation does not exist.\n *\n * Example:\n * ```ts\n * updateOperationRequestBodyContentType({\n * document,\n * meta: { method: 'post', path: '/upload', exampleKey: 'default' },\n * payload: { contentType: 'multipart/form-data' },\n * })\n * ```\n */\nexport const updateOperationRequestBodyContentType = (\n document: WorkspaceDocument | null,\n { meta, payload }: OperationEvents['operation:update:requestBody:contentType'],\n) => {\n if (!document) {\n return\n }\n\n const operation = getResolvedRef(document.paths?.[meta.path]?.[meta.method])\n if (!operation) {\n return\n }\n\n let requestBody = getResolvedRef(operation.requestBody)\n if (!requestBody) {\n operation.requestBody = {\n content: {},\n }\n requestBody = getResolvedRef(operation.requestBody)\n }\n\n if (!requestBody!['x-scalar-selected-content-type']) {\n requestBody!['x-scalar-selected-content-type'] = {}\n }\n\n requestBody!['x-scalar-selected-content-type'][meta.exampleKey] = payload.contentType\n}\n\n/** Ensure the json that we need exists up to the example object in the request body */\nconst findOrCreateRequestBodyExample = (\n document: WorkspaceDocument | null,\n contentType: string,\n meta: OperationEvents['operation:update:requestBody:contentType']['meta'],\n): ExampleObject | null => {\n const operation = getResolvedRef(document?.paths?.[meta.path]?.[meta.method])\n if (!operation) {\n return null\n }\n\n // Ensure that the request body exists\n let requestBody = getResolvedRef(operation.requestBody)\n if (!requestBody) {\n operation.requestBody = {\n content: {},\n }\n requestBody = getResolvedRef(operation.requestBody)\n }\n\n // Ensure that the example exists\n requestBody.content[contentType] ||= {}\n requestBody.content[contentType].examples ||= {}\n requestBody.content[contentType].examples[meta.exampleKey] ||= {}\n\n const example = getResolvedRef(requestBody.content[contentType].examples?.[meta.exampleKey])\n return example ?? null\n}\n\n/**\n * Creates or updates a concrete example value for a specific request-body\n * `contentType` and `exampleKey`. Safely no-ops if the document or operation\n * does not exist.\n *\n * Example:\n * ```ts\n * updateOperationRequestBodyExample({\n * document,\n * contentType: 'application/json',\n * meta: { method: 'post', path: '/users', exampleKey: 'default' },\n * payload: { value: JSON.stringify({ name: 'Ada' }) },\n * })\n * ```\n */\nexport const updateOperationRequestBodyExample = (\n document: WorkspaceDocument | null,\n { meta, payload, contentType }: OperationEvents['operation:update:requestBody:value'],\n) => {\n const example = findOrCreateRequestBodyExample(document, contentType, meta)\n if (!example) {\n console.error('Example not found', meta.exampleKey)\n return\n }\n\n example.value = payload\n}\n\n/**\n * Stores the form data for the request body example\n *\n * This needs special handling as we store it as an array of objects with a schema type of object\n */\nexport const updateOperationRequestBodyFormValue = (\n document: WorkspaceDocument | null,\n { meta, payload, contentType }: OperationEvents['operation:update:requestBody:formValue'],\n) => {\n const example = findOrCreateRequestBodyExample(document, contentType, meta)\n if (!example) {\n console.error('Example not found', meta.exampleKey)\n return\n }\n\n example.value = unpackProxyObject(payload, { depth: 3 })\n}\n\nexport const addResponseToHistory = async (\n store: WorkspaceStore | null,\n document: WorkspaceDocument | null,\n { payload, meta }: HooksEvents['hooks:on:request:complete'],\n) => {\n const documentName = document?.['x-scalar-navigation']?.name\n if (!document || !documentName || !payload) {\n return\n }\n\n const operation = getResolvedRef(document.paths?.[meta.path]?.[meta.method])\n if (!operation) {\n return\n }\n\n const operationParameters = operation.parameters ?? []\n\n // Get all the variables from the operation parameters\n const variables = operationParameters.reduce<Record<string, string>>((acc, param) => {\n const resolvedParam = getResolvedRef(param)\n if (isContentTypeParameterObject(resolvedParam)) {\n return acc\n }\n if (resolvedParam.in === 'path') {\n acc[resolvedParam.name] = getResolvedRef(resolvedParam.examples?.[meta.exampleKey])?.value ?? ''\n }\n return acc\n }, {})\n\n const requestHar = await fetchRequestToHar({ request: payload.request })\n const responseHar = await fetchResponseToHar({ response: payload.response })\n\n store?.history.addHistory(documentName, meta.path, meta.method, {\n response: responseHar,\n request: requestHar,\n meta: {\n example: meta.exampleKey,\n },\n time: payload.duration,\n timestamp: payload.timestamp,\n requestMetadata: {\n variables,\n },\n })\n}\n\nexport const reloadOperationHistory = (\n store: WorkspaceStore | null,\n document: WorkspaceDocument | null,\n { meta, index, callback }: OperationEvents['operation:reload:history'],\n) => {\n if (!document) {\n console.error('Document not found', meta.path, meta.method)\n return\n }\n\n const operation = getResolvedRef(document.paths?.[meta.path]?.[meta.method])\n if (!operation) {\n console.error('Operation not found', meta.path, meta.method)\n return\n }\n\n const historyItem = store?.history.getHistory(document['x-scalar-navigation']?.name ?? '', meta.path, meta.method)?.[\n index\n ]\n if (!historyItem) {\n console.error('History item not found', index)\n return\n }\n\n harToOperation({\n harRequest: historyItem.request,\n exampleKey: 'draft',\n baseOperation: operation,\n pathVariables: historyItem.requestMetadata.variables,\n })\n callback('success')\n}\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(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 deleteOperationExample: (payload: OperationEvents['operation:delete:example']) =>\n deleteOperationExample(store, 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": "AACA,SAAS,oBAAoB;AAC7B,SAAS,wBAAwB;AACjC,SAAS,qBAAqB;AAK9B,SAAS,sBAAsB;AAC/B,SAAS,yBAAyB;AAClC,SAAS,yBAAyB;AAClC,SAAS,0BAA0B;AACnC,SAAS,sBAAsB;AAC/B,SAAS,kBAAkB,2BAA2B;AACtD,SAAS,4BAA4B;AACrC,SAAS,oBAAoB;AAM7B,SAAS,oCAAoC;AAU7C,MAAM,wBAAwB,CAAC,MAAc,eAA0D;AACrG,QAAM,YAAoC,CAAC;AAE3C,aAAW,aAAa,YAAY;AAClC,UAAM,WAAW,KAAK,QAAQ,IAAI,SAAS,GAAG;AAC9C,QAAI,aAAa,IAAI;AACnB,gBAAU,SAAS,IAAI;AAAA,IACzB;AAAA,EACF;AAEA,SAAO;AACT;AAWA,MAAM,8BAA8B,CAClC,SACA,SACA,uBACqC;AAErC,QAAM,gBAAgB,cAAc,SAAS,EAAE,aAAa,MAAM,YAAY,MAAM,CAAC,EAAE;AAAA,IACrF,CAAC,MAAmB,MAAM;AAAA,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W,YAAY,CAAC,sBAAsB,CAAC,SAY/G,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,GAChC,UAAU,iBAAiB,GAAG,IAAI,EAClC,uBAAuB,YAAY,CAAC,yBAAyB,CAAC,sFAkB/D,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,GAC/B,UAAU,iBAAiB,GAAG,IAAI,EAClC,SAAS,YAAY,CAAC,wBAAwB,CAAC,KAC9C,MAAM,GAAG,SAiBX,CAAA;AAED,eAAO,MAAM,qBAAqB,GAAI,cAAc;IAAE,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAAA;CAAE;;4BAG9D,YAAY,CAAC,sBAAsB,CAAC;4BACpC,YAAY,CAAC,sBAAsB,CAAC;qCAC3B,YAAY,CAAC,yBAAyB,CAAC;oCAExC,YAAY,CAAC,wBAAwB,CAAC;CAEzE,CAAA"}
|
package/dist/mutators/server.js
CHANGED
|
@@ -107,9 +107,6 @@ const updateSelectedServer = (document, { url }) => {
|
|
|
107
107
|
document["x-scalar-selected-server"] = "";
|
|
108
108
|
return "";
|
|
109
109
|
}
|
|
110
|
-
if (!document.servers?.some((server) => server.url === url)) {
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
110
|
document["x-scalar-selected-server"] = document["x-scalar-selected-server"] === url ? "" : url;
|
|
114
111
|
return document["x-scalar-selected-server"];
|
|
115
112
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/mutators/server.ts"],
|
|
4
|
-
"sourcesContent": ["import { findVariables } from '@scalar/helpers/regex/find-variables'\n\nimport type { ServerEvents } from '@/events/definitions/server'\nimport { coerceValue } from '@/schemas/typebox-coerce'\nimport { type ServerObject, ServerObjectSchema } from '@/schemas/v3.1/strict/openapi-document'\nimport type { WorkspaceDocument } from '@/schemas/workspace'\n\n/**\n * Adds a new ServerObject to the document.\n *\n * @param document - The document to add the server to\n * @returns the new server object or undefined if the document is not found\n */\nexport const addServer = (document: WorkspaceDocument | null): ServerObject | undefined => {\n if (!document) {\n return undefined\n }\n\n const parsed = coerceValue(ServerObjectSchema, {})\n\n // Initialize the servers array if it doesn't exist\n if (!document.servers) {\n document.servers = []\n }\n\n document.servers.push(parsed)\n return parsed\n}\n\n/**\n * Creates a map of variable names to their character positions in a URL.\n * Used to detect renamed variables by position matching.\n */\nconst getVariablePositions = (url: string, variables: readonly string[]): Record<string, number> => {\n const positions: Record<string, number> = {}\n\n for (const varName of variables) {\n const position = url.indexOf(`{${varName}}`)\n if (position !== -1) {\n positions[varName] = position\n }\n }\n\n return positions\n}\n\ntype VariableConfig = {\n description?: string\n default?: string\n enum?: string[]\n}\n\n/**\n * Syncs server variables when the URL changes.\n *\n * Preserves variable configurations by:\n * 1. Keeping variables with matching names\n * 2. Renaming variables at the same position\n * 3. Creating new variables with empty defaults\n */\nconst syncVariablesForUrlChange = (\n newUrl: string,\n oldUrl: string,\n existingVariables: Record<string, VariableConfig>,\n): Record<string, VariableConfig> => {\n // Filter out undefined values from findVariables results\n const oldVariables = findVariables(oldUrl, { includePath: true, includeEnv: false }).filter(\n (v): v is string => v !== undefined,\n )\n const newVariables = findVariables(newUrl, { includePath: true, includeEnv: false }).filter(\n (v): v is string => v !== undefined,\n )\n\n const oldPositions = getVariablePositions(oldUrl, oldVariables)\n const newPositions = getVariablePositions(newUrl, newVariables)\n\n const usedOldVariables = new Set<string>()\n const syncedVariables: Record<string, VariableConfig> = {}\n\n for (const newVar of newVariables) {\n // Case 1: Variable with same name exists - preserve its config\n if (existingVariables[newVar]) {\n syncedVariables[newVar] = existingVariables[newVar]\n usedOldVariables.add(newVar)\n continue\n }\n\n // Case 2: Check for variable at same position (likely a rename)\n const newVarPosition = newPositions[newVar]\n const oldVarAtPosition = oldVariables.find(\n (oldVar) => oldPositions[oldVar] === newVarPosition && !usedOldVariables.has(oldVar),\n )\n\n if (oldVarAtPosition && existingVariables[oldVarAtPosition]) {\n // Rename: transfer the old variable's config to the new name\n syncedVariables[newVar] = existingVariables[oldVarAtPosition]\n usedOldVariables.add(oldVarAtPosition)\n continue\n }\n\n // Case 3: New variable - create with empty default\n syncedVariables[newVar] = { default: '' }\n }\n\n return syncedVariables\n}\n\n/**\n * Updates a ServerObject in the document.\n * When the URL changes, intelligently syncs variables by preserving configurations\n * for renamed variables (detected by position) and existing variables.\n *\n * @param document - The document containing the server to update\n * @param index - The index of the server to update\n * @param server - The partial server object with fields to update\n * @returns the updated server object or undefined if the server is not found\n */\nexport const updateServer = (\n document: WorkspaceDocument | null,\n { index, server }: ServerEvents['server:update:server'],\n): ServerObject | undefined => {\n const oldServer = document?.servers?.[index]\n\n if (!oldServer) {\n console.error('Server not found at index:', index)\n return undefined\n }\n\n const oldUrl = oldServer.url\n const updatedServer = coerceValue(ServerObjectSchema, { ...oldServer, ...server })\n\n // Sync variables if the URL changed\n const hasUrlChanged = oldUrl && oldUrl !== updatedServer.url\n if (hasUrlChanged) {\n const existingVariables = updatedServer.variables ?? {}\n updatedServer.variables = syncVariablesForUrlChange(updatedServer.url, oldUrl, existingVariables)\n\n // If the selected server is the one being updated, set the selected server to the new server\n if (document['x-scalar-selected-server'] === oldUrl) {\n document['x-scalar-selected-server'] = updatedServer.url\n }\n }\n\n // Ensure servers array exists and update the server at the specified index\n if (!document.servers) {\n document.servers = [updatedServer]\n } else {\n document.servers[index] = updatedServer\n }\n\n return updatedServer\n}\n\n/**\n * Deletes a ServerObject at the specified index from the target array.\n *\n * @param document - The document to delete the server from\n * @param index - The index of the server to delete.\n */\nexport const deleteServer = (document: WorkspaceDocument | null, { index }: ServerEvents['server:delete:server']) => {\n if (!document?.servers) {\n return\n }\n\n const url = document.servers[index]?.url\n document.servers.splice(index, 1)\n\n // If the selected server is the one being deleted, set the selected server to the first one after removal\n if (document['x-scalar-selected-server'] === url) {\n document['x-scalar-selected-server'] = document.servers[0]?.url ?? undefined\n }\n}\n\n/**\n * Updates a server variable for the selected server\n *\n * @param document - The document to update the server variables in\n * @param index - The index of the server to update\n * @param key - The key of the variable to update\n * @param value - The new value of the variable\n * @returns the updated variable or undefined if the variable is not found\n */\nexport const updateServerVariables = (\n document: WorkspaceDocument | null,\n { index, key, value }: ServerEvents['server:update:variables'],\n) => {\n const variable = document?.servers?.[index]?.variables?.[key]\n if (!variable) {\n console.error('Variable not found', key, index)\n return\n }\n\n variable.default = value\n\n // Now we need to make the url reflect the new variable value\n const url = document?.servers?.[index]?.url\n if (!url) {\n console.error('URL not found', index)\n return\n }\n\n return variable\n}\n\n/**\n * Updates the selected server for the document\n *\n * @param document - The document to update the selected server in\n * @param index - The index of the server to update\n * @returns the url of the selected server or undefined if the server is not found\n */\nexport const updateSelectedServer = (\n document: WorkspaceDocument | null,\n { url }: ServerEvents['server:update:selected'],\n): string | undefined => {\n if (!document) {\n return\n }\n\n // We are explicitly de-selecting the server\n if (url === '') {\n document['x-scalar-selected-server'] = ''\n return ''\n }\n\n
|
|
5
|
-
"mappings": "AAAA,SAAS,qBAAqB;AAG9B,SAAS,mBAAmB;AAC5B,SAA4B,0BAA0B;AAS/C,MAAM,YAAY,CAAC,aAAiE;AACzF,MAAI,CAAC,UAAU;AACb,WAAO;AAAA,EACT;AAEA,QAAM,SAAS,YAAY,oBAAoB,CAAC,CAAC;AAGjD,MAAI,CAAC,SAAS,SAAS;AACrB,aAAS,UAAU,CAAC;AAAA,EACtB;AAEA,WAAS,QAAQ,KAAK,MAAM;AAC5B,SAAO;AACT;AAMA,MAAM,uBAAuB,CAAC,KAAa,cAAyD;AAClG,QAAM,YAAoC,CAAC;AAE3C,aAAW,WAAW,WAAW;AAC/B,UAAM,WAAW,IAAI,QAAQ,IAAI,OAAO,GAAG;AAC3C,QAAI,aAAa,IAAI;AACnB,gBAAU,OAAO,IAAI;AAAA,IACvB;AAAA,EACF;AAEA,SAAO;AACT;AAgBA,MAAM,4BAA4B,CAChC,QACA,QACA,sBACmC;AAEnC,QAAM,eAAe,cAAc,QAA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Y,0BAA0B,cAAc,KAAK,QAAQ,iBAAiB;AAGhG,QAAI,SAAS,0BAA0B,MAAM,QAAQ;AACnD,eAAS,0BAA0B,IAAI,cAAc;AAAA,IACvD;AAAA,EACF;AAGA,MAAI,CAAC,SAAS,SAAS;AACrB,aAAS,UAAU,CAAC,aAAa;AAAA,EACnC,OAAO;AACL,aAAS,QAAQ,KAAK,IAAI;AAAA,EAC5B;AAEA,SAAO;AACT;AAQO,MAAM,eAAe,CAAC,UAAoC,EAAE,MAAM,MAA4C;AACnH,MAAI,CAAC,UAAU,SAAS;AACtB;AAAA,EACF;AAEA,QAAM,MAAM,SAAS,QAAQ,KAAK,GAAG;AACrC,WAAS,QAAQ,OAAO,OAAO,CAAC;AAGhC,MAAI,SAAS,0BAA0B,MAAM,KAAK;AAChD,aAAS,0BAA0B,IAAI,SAAS,QAAQ,CAAC,GAAG,OAAO;AAAA,EACrE;AACF;AAWO,MAAM,wBAAwB,CACnC,UACA,EAAE,OAAO,KAAK,MAAM,MACjB;AACH,QAAM,WAAW,UAAU,UAAU,KAAK,GAAG,YAAY,GAAG;AAC5D,MAAI,CAAC,UAAU;AACb,YAAQ,MAAM,sBAAsB,KAAK,KAAK;AAC9C;AAAA,EACF;AAEA,WAAS,UAAU;AAGnB,QAAM,MAAM,UAAU,UAAU,KAAK,GAAG;AACxC,MAAI,CAAC,KAAK;AACR,YAAQ,MAAM,iBAAiB,KAAK;AACpC;AAAA,EACF;AAEA,SAAO;AACT;AASO,MAAM,uBAAuB,CAClC,UACA,EAAE,IAAI,MACiB;AACvB,MAAI,CAAC,UAAU;AACb;AAAA,EACF;AAGA,MAAI,QAAQ,IAAI;AACd,aAAS,0BAA0B,IAAI;AACvC,WAAO;AAAA,EACT;
|
|
4
|
+
"sourcesContent": ["import { findVariables } from '@scalar/helpers/regex/find-variables'\n\nimport type { ServerEvents } from '@/events/definitions/server'\nimport { coerceValue } from '@/schemas/typebox-coerce'\nimport { type ServerObject, ServerObjectSchema } from '@/schemas/v3.1/strict/openapi-document'\nimport type { WorkspaceDocument } from '@/schemas/workspace'\n\n/**\n * Adds a new ServerObject to the document.\n *\n * @param document - The document to add the server to\n * @returns the new server object or undefined if the document is not found\n */\nexport const addServer = (document: WorkspaceDocument | null): ServerObject | undefined => {\n if (!document) {\n return undefined\n }\n\n const parsed = coerceValue(ServerObjectSchema, {})\n\n // Initialize the servers array if it doesn't exist\n if (!document.servers) {\n document.servers = []\n }\n\n document.servers.push(parsed)\n return parsed\n}\n\n/**\n * Creates a map of variable names to their character positions in a URL.\n * Used to detect renamed variables by position matching.\n */\nconst getVariablePositions = (url: string, variables: readonly string[]): Record<string, number> => {\n const positions: Record<string, number> = {}\n\n for (const varName of variables) {\n const position = url.indexOf(`{${varName}}`)\n if (position !== -1) {\n positions[varName] = position\n }\n }\n\n return positions\n}\n\ntype VariableConfig = {\n description?: string\n default?: string\n enum?: string[]\n}\n\n/**\n * Syncs server variables when the URL changes.\n *\n * Preserves variable configurations by:\n * 1. Keeping variables with matching names\n * 2. Renaming variables at the same position\n * 3. Creating new variables with empty defaults\n */\nconst syncVariablesForUrlChange = (\n newUrl: string,\n oldUrl: string,\n existingVariables: Record<string, VariableConfig>,\n): Record<string, VariableConfig> => {\n // Filter out undefined values from findVariables results\n const oldVariables = findVariables(oldUrl, { includePath: true, includeEnv: false }).filter(\n (v): v is string => v !== undefined,\n )\n const newVariables = findVariables(newUrl, { includePath: true, includeEnv: false }).filter(\n (v): v is string => v !== undefined,\n )\n\n const oldPositions = getVariablePositions(oldUrl, oldVariables)\n const newPositions = getVariablePositions(newUrl, newVariables)\n\n const usedOldVariables = new Set<string>()\n const syncedVariables: Record<string, VariableConfig> = {}\n\n for (const newVar of newVariables) {\n // Case 1: Variable with same name exists - preserve its config\n if (existingVariables[newVar]) {\n syncedVariables[newVar] = existingVariables[newVar]\n usedOldVariables.add(newVar)\n continue\n }\n\n // Case 2: Check for variable at same position (likely a rename)\n const newVarPosition = newPositions[newVar]\n const oldVarAtPosition = oldVariables.find(\n (oldVar) => oldPositions[oldVar] === newVarPosition && !usedOldVariables.has(oldVar),\n )\n\n if (oldVarAtPosition && existingVariables[oldVarAtPosition]) {\n // Rename: transfer the old variable's config to the new name\n syncedVariables[newVar] = existingVariables[oldVarAtPosition]\n usedOldVariables.add(oldVarAtPosition)\n continue\n }\n\n // Case 3: New variable - create with empty default\n syncedVariables[newVar] = { default: '' }\n }\n\n return syncedVariables\n}\n\n/**\n * Updates a ServerObject in the document.\n * When the URL changes, intelligently syncs variables by preserving configurations\n * for renamed variables (detected by position) and existing variables.\n *\n * @param document - The document containing the server to update\n * @param index - The index of the server to update\n * @param server - The partial server object with fields to update\n * @returns the updated server object or undefined if the server is not found\n */\nexport const updateServer = (\n document: WorkspaceDocument | null,\n { index, server }: ServerEvents['server:update:server'],\n): ServerObject | undefined => {\n const oldServer = document?.servers?.[index]\n\n if (!oldServer) {\n console.error('Server not found at index:', index)\n return undefined\n }\n\n const oldUrl = oldServer.url\n const updatedServer = coerceValue(ServerObjectSchema, { ...oldServer, ...server })\n\n // Sync variables if the URL changed\n const hasUrlChanged = oldUrl && oldUrl !== updatedServer.url\n if (hasUrlChanged) {\n const existingVariables = updatedServer.variables ?? {}\n updatedServer.variables = syncVariablesForUrlChange(updatedServer.url, oldUrl, existingVariables)\n\n // If the selected server is the one being updated, set the selected server to the new server\n if (document['x-scalar-selected-server'] === oldUrl) {\n document['x-scalar-selected-server'] = updatedServer.url\n }\n }\n\n // Ensure servers array exists and update the server at the specified index\n if (!document.servers) {\n document.servers = [updatedServer]\n } else {\n document.servers[index] = updatedServer\n }\n\n return updatedServer\n}\n\n/**\n * Deletes a ServerObject at the specified index from the target array.\n *\n * @param document - The document to delete the server from\n * @param index - The index of the server to delete.\n */\nexport const deleteServer = (document: WorkspaceDocument | null, { index }: ServerEvents['server:delete:server']) => {\n if (!document?.servers) {\n return\n }\n\n const url = document.servers[index]?.url\n document.servers.splice(index, 1)\n\n // If the selected server is the one being deleted, set the selected server to the first one after removal\n if (document['x-scalar-selected-server'] === url) {\n document['x-scalar-selected-server'] = document.servers[0]?.url ?? undefined\n }\n}\n\n/**\n * Updates a server variable for the selected server\n *\n * @param document - The document to update the server variables in\n * @param index - The index of the server to update\n * @param key - The key of the variable to update\n * @param value - The new value of the variable\n * @returns the updated variable or undefined if the variable is not found\n */\nexport const updateServerVariables = (\n document: WorkspaceDocument | null,\n { index, key, value }: ServerEvents['server:update:variables'],\n) => {\n const variable = document?.servers?.[index]?.variables?.[key]\n if (!variable) {\n console.error('Variable not found', key, index)\n return\n }\n\n variable.default = value\n\n // Now we need to make the url reflect the new variable value\n const url = document?.servers?.[index]?.url\n if (!url) {\n console.error('URL not found', index)\n return\n }\n\n return variable\n}\n\n/**\n * Updates the selected server for the document\n *\n * @param document - The document to update the selected server in\n * @param index - The index of the server to update\n * @returns the url of the selected server or undefined if the server is not found\n */\nexport const updateSelectedServer = (\n document: WorkspaceDocument | null,\n { url }: ServerEvents['server:update:selected'],\n): string | undefined => {\n if (!document) {\n return\n }\n\n // We are explicitly de-selecting the server\n if (url === '') {\n document['x-scalar-selected-server'] = ''\n return ''\n }\n\n /**\n * [un]set it and return the url,\n * we specifically use en empty string to indicate that the user has unset the selected server\n */\n document['x-scalar-selected-server'] = document['x-scalar-selected-server'] === url ? '' : url\n return document['x-scalar-selected-server']\n}\n\nexport const serverMutatorsFactory = ({ document }: { document: WorkspaceDocument | null }) => {\n return {\n addServer: () => addServer(document),\n updateServer: (payload: ServerEvents['server:update:server']) => updateServer(document, payload),\n deleteServer: (payload: ServerEvents['server:delete:server']) => deleteServer(document, payload),\n updateServerVariables: (payload: ServerEvents['server:update:variables']) =>\n updateServerVariables(document, payload),\n updateSelectedServer: (payload: ServerEvents['server:update:selected']) => updateSelectedServer(document, payload),\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,qBAAqB;AAG9B,SAAS,mBAAmB;AAC5B,SAA4B,0BAA0B;AAS/C,MAAM,YAAY,CAAC,aAAiE;AACzF,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AsB,KAAK,KAAK;AAC9C;AAAA,EACF;AAEA,WAAS,UAAU;AAGnB,QAAM,MAAM,UAAU,UAAU,KAAK,GAAG;AACxC,MAAI,CAAC,KAAK;AACR,YAAQ,MAAM,iBAAiB,KAAK;AACpC;AAAA,EACF;AAEA,SAAO;AACT;AASO,MAAM,uBAAuB,CAClC,UACA,EAAE,IAAI,MACiB;AACvB,MAAI,CAAC,UAAU;AACb;AAAA,EACF;AAGA,MAAI,QAAQ,IAAI;AACd,aAAS,0BAA0B,IAAI;AACvC,WAAO;AAAA,EACT;AAMA,WAAS,0BAA0B,IAAI,SAAS,0BAA0B,MAAM,MAAM,KAAK;AAC3F,SAAO,SAAS,0BAA0B;AAC5C;AAEO,MAAM,wBAAwB,CAAC,EAAE,SAAS,MAA8C;AAC7F,SAAO;AAAA,IACL,WAAW,MAAM,UAAU,QAAQ;AAAA,IACnC,cAAc,CAAC,YAAkD,aAAa,UAAU,OAAO;AAAA,IAC/F,cAAc,CAAC,YAAkD,aAAa,UAAU,OAAO;AAAA,IAC/F,uBAAuB,CAAC,YACtB,sBAAsB,UAAU,OAAO;AAAA,IACzC,sBAAsB,CAAC,YAAoD,qBAAqB,UAAU,OAAO;AAAA,EACnH;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { PathMethodHistory } from '../entities/history/schema.js';
|
|
1
2
|
import type { InMemoryWorkspace } from '../schemas/inmemory-workspace.js';
|
|
2
3
|
import type { WorkspaceMeta } from '../schemas/workspace.js';
|
|
3
4
|
type WorkspaceKey = {
|
|
@@ -50,6 +51,18 @@ export declare const createWorkspaceStorePersistence: () => Promise<{
|
|
|
50
51
|
*/
|
|
51
52
|
setItem: (workspaceId: string, documentName: string, data: InMemoryWorkspace["overrides"][string]) => Promise<void>;
|
|
52
53
|
};
|
|
54
|
+
history: {
|
|
55
|
+
/**
|
|
56
|
+
* Set history for a document.
|
|
57
|
+
*/
|
|
58
|
+
setItem: (workspaceId: string, documentName: string, data: PathMethodHistory) => Promise<void>;
|
|
59
|
+
};
|
|
60
|
+
auth: {
|
|
61
|
+
/**
|
|
62
|
+
* Set auth for a document.
|
|
63
|
+
*/
|
|
64
|
+
setItem: (workspaceId: string, documentName: string, data: InMemoryWorkspace["auth"][string]) => Promise<void>;
|
|
65
|
+
};
|
|
53
66
|
workspace: {
|
|
54
67
|
/**
|
|
55
68
|
* Retrieves a workspace by its ID.
|
|
@@ -64,18 +77,18 @@ export declare const createWorkspaceStorePersistence: () => Promise<{
|
|
|
64
77
|
* Returns an empty array if no workspaces exist.
|
|
65
78
|
*/
|
|
66
79
|
getAll: () => Promise<{
|
|
67
|
-
slug: string;
|
|
68
80
|
name: string;
|
|
69
81
|
namespace: string;
|
|
82
|
+
slug: string;
|
|
70
83
|
teamUid: string;
|
|
71
84
|
}[]>;
|
|
72
85
|
/**
|
|
73
86
|
* Retrieves all workspaces for a given team UID.
|
|
74
87
|
*/
|
|
75
88
|
getAllByTeamUid: (teamUid: string) => Promise<{
|
|
76
|
-
slug: string;
|
|
77
89
|
name: string;
|
|
78
90
|
namespace: string;
|
|
91
|
+
slug: string;
|
|
79
92
|
teamUid: string;
|
|
80
93
|
}[]>;
|
|
81
94
|
/**
|
|
@@ -84,9 +97,9 @@ export declare const createWorkspaceStorePersistence: () => Promise<{
|
|
|
84
97
|
* If a workspace with the same ID already exists, it will be replaced.
|
|
85
98
|
*/
|
|
86
99
|
setItem: ({ namespace, slug }: WorkspaceKey, value: WorkspaceStoreShape) => Promise<{
|
|
87
|
-
slug: string;
|
|
88
100
|
name: string;
|
|
89
101
|
namespace: string;
|
|
102
|
+
slug: string;
|
|
90
103
|
teamUid: string;
|
|
91
104
|
}>;
|
|
92
105
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/persistence/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","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;WAKG;;;;;;;QAKH;;WAEG;mCAC8B,MAAM;;;;;;QAIvC;;;;WAIG;uCAC4C,YAAY,SAAS,mBAAmB;;;;;;QA2DvF;;WAEG;0CACqC,QAAQ,CAAC,YAAY,CAAC,KAAG,OAAO,CAAC,IAAI,CAAC;sCAoB1C,MAAM,gBAAgB,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC;QAWhF;;WAEG;mCAC8B,QAAQ,CAAC,YAAY,CAAC,KAAG,OAAO,CAAC,OAAO,CAAC;;;EAQ/E,CAAA"}
|
|
@@ -41,6 +41,14 @@ const createWorkspaceStorePersistence = async () => {
|
|
|
41
41
|
overrides: {
|
|
42
42
|
schema: Type.Object({ workspaceId: Type.String(), documentName: Type.String(), data: Type.Any() }),
|
|
43
43
|
keyPath: ["workspaceId", "documentName"]
|
|
44
|
+
},
|
|
45
|
+
history: {
|
|
46
|
+
schema: Type.Object({ workspaceId: Type.String(), documentName: Type.String(), data: Type.Any() }),
|
|
47
|
+
keyPath: ["workspaceId", "documentName"]
|
|
48
|
+
},
|
|
49
|
+
auth: {
|
|
50
|
+
schema: Type.Object({ workspaceId: Type.String(), documentName: Type.String(), data: Type.Any() }),
|
|
51
|
+
keyPath: ["workspaceId", "documentName"]
|
|
44
52
|
}
|
|
45
53
|
}
|
|
46
54
|
});
|
|
@@ -50,6 +58,8 @@ const createWorkspaceStorePersistence = async () => {
|
|
|
50
58
|
const originalDocumentTable = connection.get("originalDocuments");
|
|
51
59
|
const intermediateDocumentTable = connection.get("intermediateDocuments");
|
|
52
60
|
const overridesTable = connection.get("overrides");
|
|
61
|
+
const historyTable = connection.get("history");
|
|
62
|
+
const authTable = connection.get("auth");
|
|
53
63
|
return {
|
|
54
64
|
close: () => {
|
|
55
65
|
connection.closeDatabase();
|
|
@@ -94,6 +104,22 @@ const createWorkspaceStorePersistence = async () => {
|
|
|
94
104
|
await overridesTable.addItem({ workspaceId, documentName }, { data });
|
|
95
105
|
}
|
|
96
106
|
},
|
|
107
|
+
history: {
|
|
108
|
+
/**
|
|
109
|
+
* Set history for a document.
|
|
110
|
+
*/
|
|
111
|
+
setItem: async (workspaceId, documentName, data) => {
|
|
112
|
+
await historyTable.addItem({ workspaceId, documentName }, { data });
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
auth: {
|
|
116
|
+
/**
|
|
117
|
+
* Set auth for a document.
|
|
118
|
+
*/
|
|
119
|
+
setItem: async (workspaceId, documentName, data) => {
|
|
120
|
+
await authTable.addItem({ workspaceId, documentName }, { data });
|
|
121
|
+
}
|
|
122
|
+
},
|
|
97
123
|
workspace: {
|
|
98
124
|
/**
|
|
99
125
|
* Retrieves a workspace by its ID.
|
|
@@ -114,6 +140,8 @@ const createWorkspaceStorePersistence = async () => {
|
|
|
114
140
|
const workspaceIntermediateDocuments = await intermediateDocumentTable.getRange([id]);
|
|
115
141
|
const workspaceOverrides = await overridesTable.getRange([id]);
|
|
116
142
|
const workspaceMeta = await metaTable.getItem({ workspaceId: id });
|
|
143
|
+
const workspaceHistory = await historyTable.getRange([id]);
|
|
144
|
+
const workspaceAuth = await authTable.getRange([id]);
|
|
117
145
|
return {
|
|
118
146
|
name: workspace.name,
|
|
119
147
|
teamUid: workspace.teamUid,
|
|
@@ -128,7 +156,9 @@ const createWorkspaceStorePersistence = async () => {
|
|
|
128
156
|
workspaceIntermediateDocuments.map((item) => [item.documentName, item.data])
|
|
129
157
|
),
|
|
130
158
|
overrides: Object.fromEntries(workspaceOverrides.map((item) => [item.documentName, item.data])),
|
|
131
|
-
meta: workspaceMeta?.data
|
|
159
|
+
meta: workspaceMeta?.data,
|
|
160
|
+
history: Object.fromEntries(workspaceHistory.map((item) => [item.documentName, item.data])),
|
|
161
|
+
auth: Object.fromEntries(workspaceAuth.map((item) => [item.documentName, item.data]))
|
|
132
162
|
}
|
|
133
163
|
};
|
|
134
164
|
},
|
|
@@ -182,6 +212,16 @@ const createWorkspaceStorePersistence = async () => {
|
|
|
182
212
|
return overridesTable.addItem({ workspaceId: id, documentName: name }, { data });
|
|
183
213
|
})
|
|
184
214
|
);
|
|
215
|
+
await Promise.all(
|
|
216
|
+
Object.entries(value.workspace.history ?? {}).map(([name, data]) => {
|
|
217
|
+
return historyTable.addItem({ workspaceId: id, documentName: name }, { data });
|
|
218
|
+
})
|
|
219
|
+
);
|
|
220
|
+
await Promise.all(
|
|
221
|
+
Object.entries(value.workspace.auth ?? {}).map(([name, data]) => {
|
|
222
|
+
return authTable.addItem({ workspaceId: id, documentName: name }, { data });
|
|
223
|
+
})
|
|
224
|
+
);
|
|
185
225
|
return workspace;
|
|
186
226
|
},
|
|
187
227
|
/**
|
|
@@ -197,7 +237,9 @@ const createWorkspaceStorePersistence = async () => {
|
|
|
197
237
|
documentsTable.deleteRange([id]),
|
|
198
238
|
originalDocumentTable.deleteRange([id]),
|
|
199
239
|
intermediateDocumentTable.deleteRange([id]),
|
|
200
|
-
overridesTable.deleteRange([id])
|
|
240
|
+
overridesTable.deleteRange([id]),
|
|
241
|
+
historyTable.deleteRange([id]),
|
|
242
|
+
authTable.deleteRange([id])
|
|
201
243
|
]);
|
|
202
244
|
},
|
|
203
245
|
deleteDocument: async (workspaceId, documentName) => {
|
|
@@ -205,7 +247,9 @@ const createWorkspaceStorePersistence = async () => {
|
|
|
205
247
|
documentsTable.deleteItem({ workspaceId, documentName }),
|
|
206
248
|
intermediateDocumentTable.deleteItem({ workspaceId, documentName }),
|
|
207
249
|
originalDocumentTable.deleteItem({ workspaceId, documentName }),
|
|
208
|
-
overridesTable.deleteItem({ workspaceId, documentName })
|
|
250
|
+
overridesTable.deleteItem({ workspaceId, documentName }),
|
|
251
|
+
historyTable.deleteItem({ workspaceId, documentName }),
|
|
252
|
+
authTable.deleteItem({ workspaceId, documentName })
|
|
209
253
|
]);
|
|
210
254
|
},
|
|
211
255
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/persistence/index.ts"],
|
|
4
|
-
"sourcesContent": ["import { Type } from '@scalar/typebox'\n\nimport { createIndexDbConnection } from '@/persistence/indexdb'\nimport type { InMemoryWorkspace } from '@/schemas/inmemory-workspace'\nimport type { WorkspaceMeta } from '@/schemas/workspace'\n\ntype WorkspaceKey = {\n namespace?: string\n slug: string\n}\n\ntype WorkspaceStoreShape = {\n teamUid?: string\n name: string\n workspace: InMemoryWorkspace\n}\n\n/** Generates a workspace ID from namespace and slug. */\nconst getWorkspaceId = (namespace: string, slug: string) => `${namespace}/${slug}`\n\n/**\n * Creates the persistence layer for the workspace store using IndexedDB.\n * This sets up all the required tables for storing workspace chunk information,\n * such as workspace meta, documents, original documents, intermediate documents, overrides, etc.\n * Each logical group (meta, documents, etc) gets its own table keyed appropriately for efficient sub-document access.\n * Returns an object containing `meta`, `documents`, `originalDocuments`, `intermediateDocuments`, `overrides`,\n * `documentMeta`, `documentConfigs`, and `workspace` sections, each exposing a `setItem` method\n * for upsetting records, and in the case of `workspace`, also `getItem` and `deleteItem`.\n */\nexport const createWorkspaceStorePersistence = async () => {\n // Create the database connection and setup all required tables for workspace storage.\n const connection = await createIndexDbConnection({\n name: 'scalar-workspace-store',\n version: 1,\n tables: {\n workspace: {\n schema: Type.Object({\n /** Visual name for a given workspace */\n name: Type.String(),\n /** When logged in all new workspaces (remote and local) are scoped to a team */\n teamUid: Type.String({ default: 'local' }),\n /** Namespace associated with a remote workspace */\n namespace: Type.String({ default: 'local' }),\n /** Slug associated with a remote workspace */\n slug: Type.String({ default: 'local' }),\n }),\n keyPath: ['namespace', 'slug'],\n indexes: {\n teamUid: ['teamUid'],\n },\n },\n meta: {\n schema: Type.Object({ workspaceId: Type.String(), data: Type.Any() }),\n keyPath: ['workspaceId'],\n },\n documents: {\n schema: Type.Object({ workspaceId: Type.String(), documentName: Type.String(), data: Type.Any() }),\n keyPath: ['workspaceId', 'documentName'],\n },\n originalDocuments: {\n schema: Type.Object({ workspaceId: Type.String(), documentName: Type.String(), data: Type.Any() }),\n keyPath: ['workspaceId', 'documentName'],\n },\n intermediateDocuments: {\n schema: Type.Object({ workspaceId: Type.String(), documentName: Type.String(), data: Type.Any() }),\n keyPath: ['workspaceId', 'documentName'],\n },\n overrides: {\n schema: Type.Object({ workspaceId: Type.String(), documentName: Type.String(), data: Type.Any() }),\n keyPath: ['workspaceId', 'documentName'],\n },\n },\n })\n\n // Tables wrappers for each logical section.\n const workspaceTable = connection.get('workspace')\n const metaTable = connection.get('meta')\n const documentsTable = connection.get('documents')\n const originalDocumentTable = connection.get('originalDocuments')\n const intermediateDocumentTable = connection.get('intermediateDocuments')\n const overridesTable = connection.get('overrides')\n\n // The returned persistence API with logical sections for each table and mapping.\n return {\n close: () => {\n connection.closeDatabase()\n },\n meta: {\n /**\n * Set meta data for a workspace.\n */\n setItem: async (workspaceId: string, data: WorkspaceMeta) => {\n await metaTable.addItem({ workspaceId }, { data })\n },\n },\n documents: {\n /**\n * Set (persist) a workspace document using workspaceId and documentName as composite key.\n */\n setItem: async (workspaceId: string, documentName: string, data: InMemoryWorkspace['documents'][string]) => {\n await documentsTable.addItem({ workspaceId, documentName }, { data })\n },\n },\n originalDocuments: {\n /**\n * Set an original (raw) document for a workspace/document pair.\n */\n setItem: async (\n workspaceId: string,\n documentName: string,\n data: InMemoryWorkspace['originalDocuments'][string],\n ) => {\n await originalDocumentTable.addItem({ workspaceId, documentName }, { data })\n },\n },\n intermediateDocuments: {\n /**\n * Set an intermediate (transformed) document for a workspace/document pair.\n */\n setItem: async (\n workspaceId: string,\n documentName: string,\n data: InMemoryWorkspace['intermediateDocuments'][string],\n ) => {\n await intermediateDocumentTable.addItem({ workspaceId, documentName }, { data })\n },\n },\n overrides: {\n /**\n * Set document overrides for a workspace/document pair.\n */\n setItem: async (workspaceId: string, documentName: string, data: InMemoryWorkspace['overrides'][string]) => {\n await overridesTable.addItem({ workspaceId, documentName }, { data })\n },\n },\n workspace: {\n /**\n * Retrieves a workspace by its ID.\n * Returns undefined if the workspace does not exist.\n * Gathers all workspace 'chunk' tables and assembles a full workspace shape.\n */\n getItem: async ({\n namespace,\n slug,\n }: Required<WorkspaceKey>): Promise<(WorkspaceStoreShape & Required<WorkspaceKey>) | undefined> => {\n const workspace = await workspaceTable.getItem({ namespace, slug })\n\n if (!workspace) {\n return undefined\n }\n\n // Create a composite key for the workspace chunks.\n const id = getWorkspaceId(namespace, slug)\n\n // Retrieve all chunk records for this workspace.\n const workspaceDocuments = await documentsTable.getRange([id])\n const workspaceOriginalDocuments = await originalDocumentTable.getRange([id])\n const workspaceIntermediateDocuments = await intermediateDocumentTable.getRange([id])\n const workspaceOverrides = await overridesTable.getRange([id])\n const workspaceMeta = await metaTable.getItem({ workspaceId: id })\n\n // Compose the workspace structure from table records.\n return {\n name: workspace.name,\n teamUid: workspace.teamUid,\n namespace: workspace.namespace,\n slug: workspace.slug,\n workspace: {\n documents: Object.fromEntries(workspaceDocuments.map((item) => [item.documentName, item.data])),\n originalDocuments: Object.fromEntries(\n workspaceOriginalDocuments.map((item) => [item.documentName, item.data]),\n ),\n intermediateDocuments: Object.fromEntries(\n workspaceIntermediateDocuments.map((item) => [item.documentName, item.data]),\n ),\n overrides: Object.fromEntries(workspaceOverrides.map((item) => [item.documentName, item.data])),\n meta: workspaceMeta?.data,\n },\n }\n },\n\n /**\n * Retrieves all workspaces from the database.\n * Returns only the workspace ID and name for each workspace.\n * To get the full workspace data including documents and metadata, use getItem() with a specific ID.\n * Returns an empty array if no workspaces exist.\n */\n getAll: async () => {\n return await workspaceTable.getAll()\n },\n\n /**\n * Retrieves all workspaces for a given team UID.\n */\n getAllByTeamUid: async (teamUid: string) => {\n return await workspaceTable.getRange([teamUid], 'teamUid')\n },\n\n /**\n * Saves a workspace to the database.\n * All chunks (meta, documents, configs, etc.) are upsert in their respective tables.\n * If a workspace with the same ID already exists, it will be replaced.\n */\n setItem: async ({ namespace = 'local', slug }: WorkspaceKey, value: WorkspaceStoreShape) => {\n const workspace = await workspaceTable.addItem(\n { namespace, slug },\n {\n name: value.name,\n teamUid: value.teamUid ?? 'local',\n },\n )\n\n const id = getWorkspaceId(namespace, slug)\n\n // Save all meta info for workspace.\n await metaTable.addItem({ workspaceId: id }, { data: value.workspace.meta })\n\n // Persist all workspace documents (chunks).\n await Promise.all(\n Object.entries(value.workspace.documents ?? {}).map(([name, data]) => {\n return documentsTable.addItem({ workspaceId: id, documentName: name }, { data })\n }),\n )\n\n // Persist all original documents.\n await Promise.all(\n Object.entries(value.workspace.originalDocuments ?? {}).map(([name, data]) => {\n return originalDocumentTable.addItem({ workspaceId: id, documentName: name }, { data })\n }),\n )\n\n // Persist all intermediate documents.\n await Promise.all(\n Object.entries(value.workspace.intermediateDocuments ?? {}).map(([name, data]) => {\n return intermediateDocumentTable.addItem({ workspaceId: id, documentName: name }, { data })\n }),\n )\n\n // Persist all document overrides.\n await Promise.all(\n Object.entries(value.workspace.overrides ?? {}).map(([name, data]) => {\n return overridesTable.addItem({ workspaceId: id, documentName: name }, { data })\n }),\n )\n\n return workspace\n },\n\n /**\n * Deletes an entire workspace and all associated chunk records from all tables by ID.\n */\n deleteItem: async ({ namespace, slug }: Required<WorkspaceKey>): Promise<void> => {\n const id = getWorkspaceId(namespace, slug)\n\n await workspaceTable.deleteItem({ namespace, slug })\n\n // Remove all workspace-related records from all chunk tables.\n await Promise.all([\n // By id\n metaTable.deleteItem({ workspaceId: id }),\n\n // By range (composite-key tables)\n documentsTable.deleteRange([id]),\n originalDocumentTable.deleteRange([id]),\n intermediateDocumentTable.deleteRange([id]),\n overridesTable.deleteRange([id]),\n ])\n },\n\n deleteDocument: async (workspaceId: string, documentName: string): Promise<void> => {\n await Promise.all([\n documentsTable.deleteItem({ workspaceId, documentName }),\n intermediateDocumentTable.deleteItem({ workspaceId, documentName }),\n originalDocumentTable.deleteItem({ workspaceId, documentName }),\n overridesTable.deleteItem({ workspaceId, documentName }),\n ])\n },\n\n /**\n * Checks if a workspace with the given ID exists in the store.\n */\n has: async ({ namespace, slug }: Required<WorkspaceKey>): Promise<boolean> => {\n return (await workspaceTable.getItem({ namespace, slug })) !== undefined\n },\n },\n clear: async () => {\n await workspaceTable.deleteAll()\n },\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,YAAY;
|
|
4
|
+
"sourcesContent": ["import { Type } from '@scalar/typebox'\n\nimport type { PathMethodHistory } from '@/entities/history/schema'\nimport { createIndexDbConnection } from '@/persistence/indexdb'\nimport type { InMemoryWorkspace } from '@/schemas/inmemory-workspace'\nimport type { WorkspaceMeta } from '@/schemas/workspace'\n\ntype WorkspaceKey = {\n namespace?: string\n slug: string\n}\n\ntype WorkspaceStoreShape = {\n teamUid?: string\n name: string\n workspace: InMemoryWorkspace\n}\n\n/** Generates a workspace ID from namespace and slug. */\nconst getWorkspaceId = (namespace: string, slug: string) => `${namespace}/${slug}`\n\n/**\n * Creates the persistence layer for the workspace store using IndexedDB.\n * This sets up all the required tables for storing workspace chunk information,\n * such as workspace meta, documents, original documents, intermediate documents, overrides, etc.\n * Each logical group (meta, documents, etc) gets its own table keyed appropriately for efficient sub-document access.\n * Returns an object containing `meta`, `documents`, `originalDocuments`, `intermediateDocuments`, `overrides`,\n * `documentMeta`, `documentConfigs`, and `workspace` sections, each exposing a `setItem` method\n * for upsetting records, and in the case of `workspace`, also `getItem` and `deleteItem`.\n */\nexport const createWorkspaceStorePersistence = async () => {\n // Create the database connection and setup all required tables for workspace storage.\n const connection = await createIndexDbConnection({\n name: 'scalar-workspace-store',\n version: 1,\n tables: {\n workspace: {\n schema: Type.Object({\n /** Visual name for a given workspace */\n name: Type.String(),\n /** When logged in all new workspaces (remote and local) are scoped to a team */\n teamUid: Type.String({ default: 'local' }),\n /** Namespace associated with a remote workspace */\n namespace: Type.String({ default: 'local' }),\n /** Slug associated with a remote workspace */\n slug: Type.String({ default: 'local' }),\n }),\n keyPath: ['namespace', 'slug'],\n indexes: {\n teamUid: ['teamUid'],\n },\n },\n meta: {\n schema: Type.Object({ workspaceId: Type.String(), data: Type.Any() }),\n keyPath: ['workspaceId'],\n },\n documents: {\n schema: Type.Object({ workspaceId: Type.String(), documentName: Type.String(), data: Type.Any() }),\n keyPath: ['workspaceId', 'documentName'],\n },\n originalDocuments: {\n schema: Type.Object({ workspaceId: Type.String(), documentName: Type.String(), data: Type.Any() }),\n keyPath: ['workspaceId', 'documentName'],\n },\n intermediateDocuments: {\n schema: Type.Object({ workspaceId: Type.String(), documentName: Type.String(), data: Type.Any() }),\n keyPath: ['workspaceId', 'documentName'],\n },\n overrides: {\n schema: Type.Object({ workspaceId: Type.String(), documentName: Type.String(), data: Type.Any() }),\n keyPath: ['workspaceId', 'documentName'],\n },\n history: {\n schema: Type.Object({ workspaceId: Type.String(), documentName: Type.String(), data: Type.Any() }),\n keyPath: ['workspaceId', 'documentName'],\n },\n auth: {\n schema: Type.Object({ workspaceId: Type.String(), documentName: Type.String(), data: Type.Any() }),\n keyPath: ['workspaceId', 'documentName'],\n },\n },\n })\n\n // Tables wrappers for each logical section.\n const workspaceTable = connection.get('workspace')\n const metaTable = connection.get('meta')\n const documentsTable = connection.get('documents')\n const originalDocumentTable = connection.get('originalDocuments')\n const intermediateDocumentTable = connection.get('intermediateDocuments')\n const overridesTable = connection.get('overrides')\n const historyTable = connection.get('history')\n const authTable = connection.get('auth')\n\n // The returned persistence API with logical sections for each table and mapping.\n return {\n close: () => {\n connection.closeDatabase()\n },\n meta: {\n /**\n * Set meta data for a workspace.\n */\n setItem: async (workspaceId: string, data: WorkspaceMeta) => {\n await metaTable.addItem({ workspaceId }, { data })\n },\n },\n documents: {\n /**\n * Set (persist) a workspace document using workspaceId and documentName as composite key.\n */\n setItem: async (workspaceId: string, documentName: string, data: InMemoryWorkspace['documents'][string]) => {\n await documentsTable.addItem({ workspaceId, documentName }, { data })\n },\n },\n originalDocuments: {\n /**\n * Set an original (raw) document for a workspace/document pair.\n */\n setItem: async (\n workspaceId: string,\n documentName: string,\n data: InMemoryWorkspace['originalDocuments'][string],\n ) => {\n await originalDocumentTable.addItem({ workspaceId, documentName }, { data })\n },\n },\n intermediateDocuments: {\n /**\n * Set an intermediate (transformed) document for a workspace/document pair.\n */\n setItem: async (\n workspaceId: string,\n documentName: string,\n data: InMemoryWorkspace['intermediateDocuments'][string],\n ) => {\n await intermediateDocumentTable.addItem({ workspaceId, documentName }, { data })\n },\n },\n overrides: {\n /**\n * Set document overrides for a workspace/document pair.\n */\n setItem: async (workspaceId: string, documentName: string, data: InMemoryWorkspace['overrides'][string]) => {\n await overridesTable.addItem({ workspaceId, documentName }, { data })\n },\n },\n history: {\n /**\n * Set history for a document.\n */\n setItem: async (workspaceId: string, documentName: string, data: PathMethodHistory) => {\n await historyTable.addItem({ workspaceId, documentName }, { data })\n },\n },\n auth: {\n /**\n * Set auth for a document.\n */\n setItem: async (workspaceId: string, documentName: string, data: InMemoryWorkspace['auth'][string]) => {\n await authTable.addItem({ workspaceId, documentName }, { data })\n },\n },\n workspace: {\n /**\n * Retrieves a workspace by its ID.\n * Returns undefined if the workspace does not exist.\n * Gathers all workspace 'chunk' tables and assembles a full workspace shape.\n */\n getItem: async ({\n namespace,\n slug,\n }: Required<WorkspaceKey>): Promise<(WorkspaceStoreShape & Required<WorkspaceKey>) | undefined> => {\n const workspace = await workspaceTable.getItem({ namespace, slug })\n\n if (!workspace) {\n return undefined\n }\n\n // Create a composite key for the workspace chunks.\n const id = getWorkspaceId(namespace, slug)\n\n // Retrieve all chunk records for this workspace.\n const workspaceDocuments = await documentsTable.getRange([id])\n const workspaceOriginalDocuments = await originalDocumentTable.getRange([id])\n const workspaceIntermediateDocuments = await intermediateDocumentTable.getRange([id])\n const workspaceOverrides = await overridesTable.getRange([id])\n const workspaceMeta = await metaTable.getItem({ workspaceId: id })\n const workspaceHistory = await historyTable.getRange([id])\n const workspaceAuth = await authTable.getRange([id])\n\n // Compose the workspace structure from table records.\n return {\n name: workspace.name,\n teamUid: workspace.teamUid,\n namespace: workspace.namespace,\n slug: workspace.slug,\n workspace: {\n documents: Object.fromEntries(workspaceDocuments.map((item) => [item.documentName, item.data])),\n originalDocuments: Object.fromEntries(\n workspaceOriginalDocuments.map((item) => [item.documentName, item.data]),\n ),\n intermediateDocuments: Object.fromEntries(\n workspaceIntermediateDocuments.map((item) => [item.documentName, item.data]),\n ),\n overrides: Object.fromEntries(workspaceOverrides.map((item) => [item.documentName, item.data])),\n meta: workspaceMeta?.data,\n history: Object.fromEntries(workspaceHistory.map((item) => [item.documentName, item.data])),\n auth: Object.fromEntries(workspaceAuth.map((item) => [item.documentName, item.data])),\n },\n }\n },\n\n /**\n * Retrieves all workspaces from the database.\n * Returns only the workspace ID and name for each workspace.\n * To get the full workspace data including documents and metadata, use getItem() with a specific ID.\n * Returns an empty array if no workspaces exist.\n */\n getAll: async () => {\n return await workspaceTable.getAll()\n },\n\n /**\n * Retrieves all workspaces for a given team UID.\n */\n getAllByTeamUid: async (teamUid: string) => {\n return await workspaceTable.getRange([teamUid], 'teamUid')\n },\n\n /**\n * Saves a workspace to the database.\n * All chunks (meta, documents, configs, etc.) are upsert in their respective tables.\n * If a workspace with the same ID already exists, it will be replaced.\n */\n setItem: async ({ namespace = 'local', slug }: WorkspaceKey, value: WorkspaceStoreShape) => {\n const workspace = await workspaceTable.addItem(\n { namespace, slug },\n {\n name: value.name,\n teamUid: value.teamUid ?? 'local',\n },\n )\n\n const id = getWorkspaceId(namespace, slug)\n\n // Save all meta info for workspace.\n await metaTable.addItem({ workspaceId: id }, { data: value.workspace.meta })\n\n // Persist all workspace documents (chunks).\n await Promise.all(\n Object.entries(value.workspace.documents ?? {}).map(([name, data]) => {\n return documentsTable.addItem({ workspaceId: id, documentName: name }, { data })\n }),\n )\n\n // Persist all original documents.\n await Promise.all(\n Object.entries(value.workspace.originalDocuments ?? {}).map(([name, data]) => {\n return originalDocumentTable.addItem({ workspaceId: id, documentName: name }, { data })\n }),\n )\n\n // Persist all intermediate documents.\n await Promise.all(\n Object.entries(value.workspace.intermediateDocuments ?? {}).map(([name, data]) => {\n return intermediateDocumentTable.addItem({ workspaceId: id, documentName: name }, { data })\n }),\n )\n\n // Persist all document overrides.\n await Promise.all(\n Object.entries(value.workspace.overrides ?? {}).map(([name, data]) => {\n return overridesTable.addItem({ workspaceId: id, documentName: name }, { data })\n }),\n )\n\n // Persist all history.\n await Promise.all(\n Object.entries(value.workspace.history ?? {}).map(([name, data]) => {\n return historyTable.addItem({ workspaceId: id, documentName: name }, { data })\n }),\n )\n\n // Persist all auth.\n await Promise.all(\n Object.entries(value.workspace.auth ?? {}).map(([name, data]) => {\n return authTable.addItem({ workspaceId: id, documentName: name }, { data })\n }),\n )\n\n return workspace\n },\n\n /**\n * Deletes an entire workspace and all associated chunk records from all tables by ID.\n */\n deleteItem: async ({ namespace, slug }: Required<WorkspaceKey>): Promise<void> => {\n const id = getWorkspaceId(namespace, slug)\n\n await workspaceTable.deleteItem({ namespace, slug })\n\n // Remove all workspace-related records from all chunk tables.\n await Promise.all([\n // By id\n metaTable.deleteItem({ workspaceId: id }),\n\n // By range (composite-key tables)\n documentsTable.deleteRange([id]),\n originalDocumentTable.deleteRange([id]),\n intermediateDocumentTable.deleteRange([id]),\n overridesTable.deleteRange([id]),\n historyTable.deleteRange([id]),\n authTable.deleteRange([id]),\n ])\n },\n\n deleteDocument: async (workspaceId: string, documentName: string): Promise<void> => {\n await Promise.all([\n documentsTable.deleteItem({ workspaceId, documentName }),\n intermediateDocumentTable.deleteItem({ workspaceId, documentName }),\n originalDocumentTable.deleteItem({ workspaceId, documentName }),\n overridesTable.deleteItem({ workspaceId, documentName }),\n historyTable.deleteItem({ workspaceId, documentName }),\n authTable.deleteItem({ workspaceId, documentName }),\n ])\n },\n\n /**\n * Checks if a workspace with the given ID exists in the store.\n */\n has: async ({ namespace, slug }: Required<WorkspaceKey>): Promise<boolean> => {\n return (await workspaceTable.getItem({ namespace, slug })) !== undefined\n },\n },\n clear: async () => {\n await workspaceTable.deleteAll()\n },\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,YAAY;AAGrB,SAAS,+BAA+B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AAA,MAEA,gBAAgB,OAAO,aAAqB,iBAAwC;AAClF,cAAM,QAAQ,IAAI;AAAA,UAChB,eAAe,WAAW,EAAE,aAAa,aAAa,CAAC;AAAA,UACvD,0BAA0B,WAAW,EAAE,aAAa,aAAa,CAAC;AAAA,UAClE,sBAAsB,WAAW,EAAE,aAAa,aAAa,CAAC;AAAA,UAC9D,eAAe,WAAW,EAAE,aAAa,aAAa,CAAC;AAAA,UACvD,aAAa,WAAW,EAAE,aAAa,aAAa,CAAC;AAAA,UACrD,UAAU,WAAW,EAAE,aAAa,aAAa,CAAC;AAAA,QACpD,CAAC;AAAA,MACH;AAAA;AAAA;AAAA;AAAA,MAKA,KAAK,OAAO,EAAE,WAAW,KAAK,MAAgD;AAC5E,eAAQ,MAAM,eAAe,QAAQ,EAAE,WAAW,KAAK,CAAC,MAAO;AAAA,MACjE;AAAA,IACF;AAAA,IACA,OAAO,YAAY;AACjB,YAAM,eAAe,UAAU;AAAA,IACjC;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -84,4 +84,11 @@ export declare const restoreOriginalRefs: () => LifecyclePlugin;
|
|
|
84
84
|
* ```
|
|
85
85
|
*/
|
|
86
86
|
export declare const normalizeAuthSchemes: () => LifecyclePlugin;
|
|
87
|
+
/**
|
|
88
|
+
* Lifecycle plugin to normalize $ref nodes:
|
|
89
|
+
* Ensures that for any non-schema object containing a $ref, only $ref,
|
|
90
|
+
* summary, description, and $status properties are preserved.
|
|
91
|
+
* This keeps $ref references clean and predictable for downstream consumers.
|
|
92
|
+
*/
|
|
93
|
+
export declare const normalizeRefs: () => LifecyclePlugin;
|
|
87
94
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/bundler/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAKhE;;;;;GAKG;AACH,eAAO,MAAM,aAAa,QAAO,eAahC,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,qBAAqB,QAAO,eA+BxC,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,QAAO,eAwCjC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,mBAAmB,QAAO,eAuBtC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,oBAAoB,QAAO,eAuBvC,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/bundler/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAKhE;;;;;GAKG;AACH,eAAO,MAAM,aAAa,QAAO,eAahC,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,qBAAqB,QAAO,eA+BxC,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,QAAO,eAwCjC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,mBAAmB,QAAO,eAuBtC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,oBAAoB,QAAO,eAuBvC,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,aAAa,QAAO,eAmBhC,CAAA"}
|