@scalar/workspace-store 0.26.0 → 0.26.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -0
- package/dist/events/definitions/operation.d.ts +11 -8
- package/dist/events/definitions/operation.d.ts.map +1 -1
- package/dist/mutators/operation.d.ts +4 -7
- package/dist/mutators/operation.d.ts.map +1 -1
- package/dist/mutators/operation.js +43 -45
- package/dist/mutators/operation.js.map +2 -2
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# @scalar/workspace-store
|
|
2
2
|
|
|
3
|
+
## 0.26.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#7894](https://github.com/scalar/scalar/pull/7894): fix: the import and export of redirect to proxy
|
|
8
|
+
|
|
9
|
+
#### Updated Dependencies
|
|
10
|
+
|
|
11
|
+
- **@scalar/helpers@0.2.9**
|
|
12
|
+
- [#7894](https://github.com/scalar/scalar/pull/7894): fix: the import and export of redirect to proxy
|
|
13
|
+
|
|
14
|
+
- **@scalar/json-magic@0.9.3**
|
|
15
|
+
|
|
16
|
+
- **@scalar/object-utils@1.2.23**
|
|
17
|
+
|
|
18
|
+
- **@scalar/types@0.5.10**
|
|
19
|
+
|
|
20
|
+
- **@scalar/openapi-upgrader@0.1.8**
|
|
21
|
+
|
|
22
|
+
- **@scalar/snippetz@0.6.8**
|
|
23
|
+
|
|
24
|
+
## 0.26.1
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- [#7888](https://github.com/scalar/scalar/pull/7888): fix: more robust parameter upsert and deletion
|
|
29
|
+
|
|
3
30
|
## 0.26.0
|
|
4
31
|
|
|
5
32
|
### Minor Changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { HttpMethod } from '@scalar/helpers/http/http-methods';
|
|
2
|
-
import type { OperationObject } from '../../schemas/v3.1/strict/openapi-document.js';
|
|
2
|
+
import type { OperationObject, ParameterObject } from '../../schemas/v3.1/strict/openapi-document.js';
|
|
3
3
|
/**
|
|
4
4
|
* Describes the minimal identity for an operation in the workspace document.
|
|
5
5
|
* It is used by mutators to find the target operation under `paths`.
|
|
@@ -117,9 +117,12 @@ export type OperationEvents = {
|
|
|
117
117
|
*/
|
|
118
118
|
type: 'path' | 'query' | 'header' | 'cookie';
|
|
119
119
|
/**
|
|
120
|
-
*
|
|
120
|
+
* We pass the parameter back instead of the index due to all of these transforms
|
|
121
|
+
* we do along the way (merging with global parameters, etc). This is much safer for editing/adding
|
|
122
|
+
*
|
|
123
|
+
* If its null then we are adding a new parameter
|
|
121
124
|
*/
|
|
122
|
-
|
|
125
|
+
originalParameter: ParameterObject | null;
|
|
123
126
|
/**
|
|
124
127
|
* Partial payload with new properties for the parameter (optional).
|
|
125
128
|
* - name: The new name of the parameter (if being renamed).
|
|
@@ -164,11 +167,11 @@ export type OperationEvents = {
|
|
|
164
167
|
* Fires when the user removes a parameter (by type and index) from an operation.
|
|
165
168
|
*/
|
|
166
169
|
'operation:delete:parameter': {
|
|
167
|
-
/**
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
170
|
+
/**
|
|
171
|
+
* We pass the parameter back instead of the index due to all of these transforms
|
|
172
|
+
* we do along the way (merging with global parameters, etc). This is much safer for deleting
|
|
173
|
+
*/
|
|
174
|
+
originalParameter: ParameterObject;
|
|
172
175
|
meta: OperationExampleMeta;
|
|
173
176
|
};
|
|
174
177
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../../../src/events/definitions/operation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AAEnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAA;
|
|
1
|
+
{"version":3,"file":"operation.d.ts","sourceR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
* ```
|
|
96
96
|
*/
|
|
97
|
-
export declare const upsertOperationParameter: (document: WorkspaceDocument | null, { meta, type, payload,
|
|
97
|
+
export declare const upsertOperationParameter: (document: WorkspaceDocument | null, { meta, type, payload, originalParameter }: OperationEvents["operation:upsert:parameter"]) => void;
|
|
98
98
|
/**
|
|
99
99
|
* Updates the disabled state of a default parameter for an operation.
|
|
100
100
|
* Default parameters are inherited from higher-level configurations (like collection or server defaults)
|
|
@@ -113,21 +113,18 @@ export declare const upsertOperationParameter: (document: WorkspaceDocument | nu
|
|
|
113
113
|
*/
|
|
114
114
|
export declare const updateOperationExtraParameters: (document: WorkspaceDocument | null, { type, meta, payload, in: location }: OperationEvents["operation:update:extra-parameters"]) => void;
|
|
115
115
|
/**
|
|
116
|
-
* Removes a parameter from the operation
|
|
117
|
-
* the filtered list of parameters of the specified `type`.
|
|
118
|
-
* Safely no-ops if the document, operation, or parameter does not exist.
|
|
116
|
+
* Removes a parameter from the operation OR path
|
|
119
117
|
*
|
|
120
118
|
* Example:
|
|
121
119
|
* ```ts
|
|
122
120
|
* deleteOperationParameter({
|
|
123
121
|
* document,
|
|
124
|
-
*
|
|
125
|
-
* index: 1,
|
|
122
|
+
* originalParameter,
|
|
126
123
|
* meta: { method: 'get', path: '/users', exampleKey: 'default' },
|
|
127
124
|
* })
|
|
128
125
|
* ```
|
|
129
126
|
*/
|
|
130
|
-
export declare const deleteOperationParameter: (document: WorkspaceDocument | null, { meta,
|
|
127
|
+
export declare const deleteOperationParameter: (document: WorkspaceDocument | null, { meta, originalParameter }: OperationEvents["operation:delete:parameter"]) => void;
|
|
131
128
|
/**
|
|
132
129
|
* Deletes all parameters of a given `type` from the operation.
|
|
133
130
|
* Safely no-ops if the document or operation does not exist.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../../src/mutators/operation.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAA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AC;4CAEzC,eAAe,CAAC,iCAAiC,CAAC;qDAEzC,eAAe,CAAC,0CAA0C,CAAC;iDAE/D,eAAe,CAAC,oCAAoC,CAAC;mDAEnD,eAAe,CAAC,wCAAwC,CAAC;oCAExE,WAAW,CAAC,2BAA2B,CAAC;sCAEtC,eAAe,CAAC,0BAA0B,CAAC;CAGhF,CAAA"}
|
|
@@ -247,42 +247,40 @@ const deleteOperationExample = (workspace, { meta: { path, method, exampleKey },
|
|
|
247
247
|
delete mediaType.examples?.[exampleKey];
|
|
248
248
|
});
|
|
249
249
|
};
|
|
250
|
-
const upsertOperationParameter = (document, { meta, type, payload,
|
|
251
|
-
if (
|
|
250
|
+
const upsertOperationParameter = (document, { meta, type, payload, originalParameter }) => {
|
|
251
|
+
if (originalParameter) {
|
|
252
|
+
originalParameter.name = payload.name;
|
|
253
|
+
if (isContentTypeParameterObject(originalParameter)) {
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
if (!originalParameter.examples) {
|
|
257
|
+
originalParameter.examples = {};
|
|
258
|
+
}
|
|
259
|
+
originalParameter.examples[meta.exampleKey] ||= {};
|
|
260
|
+
const example = getResolvedRef(originalParameter.examples[meta.exampleKey]);
|
|
261
|
+
example.value = payload.value;
|
|
262
|
+
example["x-disabled"] = payload.isDisabled;
|
|
252
263
|
return;
|
|
253
264
|
}
|
|
254
|
-
const operation = getResolvedRef(document
|
|
265
|
+
const operation = getResolvedRef(document?.paths?.[meta.path]?.[meta.method]);
|
|
255
266
|
if (!operation) {
|
|
267
|
+
console.error("Operation not found", { meta, document });
|
|
256
268
|
return;
|
|
257
269
|
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
value: payload.value,
|
|
269
|
-
"x-disabled": payload.isDisabled ?? false
|
|
270
|
-
}
|
|
270
|
+
operation.parameters ||= [];
|
|
271
|
+
operation.parameters.push({
|
|
272
|
+
name: payload.name,
|
|
273
|
+
in: type,
|
|
274
|
+
required: type === "path" ? true : false,
|
|
275
|
+
examples: {
|
|
276
|
+
[meta.exampleKey]: {
|
|
277
|
+
value: payload.value,
|
|
278
|
+
// We always want a new parameter to be enabled by default
|
|
279
|
+
"x-disabled": false
|
|
271
280
|
}
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
parameter.name = payload.name;
|
|
276
|
-
if (isContentTypeParameterObject(parameter)) {
|
|
277
|
-
return;
|
|
278
|
-
}
|
|
279
|
-
if (!parameter.examples) {
|
|
280
|
-
parameter.examples = {};
|
|
281
|
-
}
|
|
282
|
-
parameter.examples[meta.exampleKey] ||= {};
|
|
283
|
-
const example = getResolvedRef(parameter.examples[meta.exampleKey]);
|
|
284
|
-
example.value = payload.value;
|
|
285
|
-
example["x-disabled"] = payload.isDisabled;
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
return;
|
|
286
284
|
};
|
|
287
285
|
const updateOperationExtraParameters = (document, { type, meta, payload, in: location }) => {
|
|
288
286
|
if (!document) {
|
|
@@ -311,24 +309,24 @@ const updateOperationExtraParameters = (document, { type, meta, payload, in: loc
|
|
|
311
309
|
[meta.name]: payload.isDisabled ?? false
|
|
312
310
|
};
|
|
313
311
|
};
|
|
314
|
-
const deleteOperationParameter = (document, { meta,
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
312
|
+
const deleteOperationParameter = (document, { meta, originalParameter }) => {
|
|
313
|
+
const operation = getResolvedRef(document?.paths?.[meta.path]?.[meta.method]);
|
|
314
|
+
const operationIndex = operation?.parameters?.findIndex((it) => getResolvedRef(it) === originalParameter) ?? -1;
|
|
315
|
+
if (operation && operationIndex >= 0) {
|
|
316
|
+
operation.parameters = unpackProxyObject(
|
|
317
|
+
operation.parameters?.filter((_, i) => i !== operationIndex),
|
|
318
|
+
{ depth: 1 }
|
|
319
|
+
);
|
|
320
320
|
return;
|
|
321
321
|
}
|
|
322
|
-
const
|
|
323
|
-
const
|
|
324
|
-
if (
|
|
325
|
-
|
|
322
|
+
const path = getResolvedRef(document?.paths?.[meta.path]);
|
|
323
|
+
const pathIndex = path?.parameters?.findIndex((it) => getResolvedRef(it) === originalParameter) ?? -1;
|
|
324
|
+
if (path && pathIndex >= 0) {
|
|
325
|
+
path.parameters = unpackProxyObject(
|
|
326
|
+
path.parameters?.filter((_, i) => i !== pathIndex),
|
|
327
|
+
{ depth: 1 }
|
|
328
|
+
);
|
|
326
329
|
}
|
|
327
|
-
const actualIndex = operation.parameters?.findIndex((it) => getResolvedRef(it) === parameter);
|
|
328
|
-
operation.parameters = unpackProxyObject(
|
|
329
|
-
operation.parameters?.filter((_, i) => i !== actualIndex),
|
|
330
|
-
{ depth: 1 }
|
|
331
|
-
);
|
|
332
330
|
};
|
|
333
331
|
const deleteAllOperationParameters = (document, { meta, type }) => {
|
|
334
332
|
if (!document) {
|
|
@@ -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, index }: OperationEvents['operation:upsert:parameter'],\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 // Get all resolved parameters of the specified type\n // The passed index corresponds to this filtered list\n const resolvedParameters = operation.parameters?.map((it) => getResolvedRef(it)).filter((it) => it.in === type) ?? []\n const parameter = resolvedParameters[index]\n\n // If it doesn't exist we probably need to add a new parameter (we can do length check as well if we want)\n if (!parameter) {\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 'x-disabled': payload.isDisabled ?? false,\n },\n },\n })\n return\n }\n\n parameter.name = payload.name\n\n if (isContentTypeParameterObject(parameter)) {\n // TODO: handle content-type parameters\n return\n }\n\n if (!parameter.examples) {\n parameter.examples = {}\n }\n\n // Create the example if it doesn't exist\n parameter.examples[meta.exampleKey] ||= {}\n const example = getResolvedRef(parameter.examples[meta.exampleKey])!\n\n // Update the example value and disabled state\n example.value = payload.value\n example['x-disabled'] = payload.isDisabled\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 by resolving its position within\n * the filtered list of parameters of the specified `type`.\n * Safely no-ops if the document, operation, or parameter does not exist.\n *\n * Example:\n * ```ts\n * deleteOperationParameter({\n * document,\n * type: 'header',\n * index: 1,\n * meta: { method: 'get', path: '/users', exampleKey: 'default' },\n * })\n * ```\n */\nexport const deleteOperationParameter = (\n document: WorkspaceDocument | null,\n { meta, index, type }: OperationEvents['operation:delete:parameter'],\n) => {\n if (!document) {\n return\n }\n\n const operation = getResolvedRef(document.paths?.[meta.path]?.[meta.method])\n\n // Don't proceed if operation doesn't exist\n if (!operation) {\n return\n }\n\n // Translate the index from the filtered list to the actual parameters array\n const resolvedParameters = operation.parameters?.map((it) => getResolvedRef(it)).filter((it) => it.in === type) ?? []\n const parameter = resolvedParameters[index]\n if (!parameter) {\n return\n }\n\n const actualIndex = operation.parameters?.findIndex((it) => getResolvedRef(it) === parameter) as number\n\n // We cannot call splice on a proxy object, so we unwrap the array and filter it\n operation.parameters = unpackProxyObject(\n operation.parameters?.filter((_, i) => i !== actualIndex),\n { depth: 1 },\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['operation:reload:history']) =>\n reloadOperationHistory(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,4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,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 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['operation:reload:history']) =>\n reloadOperationHistory(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,EAC5B;AACA,QAAM,gBAAgB,cAAc,SAAS,EAAE,aAAa,MAAM,YAAY,MAAM,CAAC,EAAE;AAAA,IACrF,CAAC,MAAmB,MAAM;AAAA,EAC5B;AAEA,QAAM,eAAe,sBAAsB,SAAS,aAAa;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AAO;AAAA,IACL,iBAAiB,CAAC,YAA2D,gBAAgB,OAAO,OAAO;AAAA,IAC3G,wBAAwB,CAAC,YACvB,uBAAuB,UAAU,OAAO;AAAA,IAC1C,2BAA2B,CAAC,YAC1B,0BAA0B,UAAU,OAAO,OAAO;AAAA,IACpD,iBAAiB,CAAC,YAA2D,gBAAgB,OAAO,OAAO;AAAA,IAC3G,wBAAwB,CAAC,YACvB,uBAAuB,OAAO,OAAO;AAAA,IACvC,gCAAgC,CAAC,YAC/B,+BAA+B,UAAU,OAAO;AAAA,IAClD,0BAA0B,CAAC,YACzB,yBAAyB,UAAU,OAAO;AAAA,IAC5C,0BAA0B,CAAC,YACzB,yBAAyB,UAAU,OAAO;AAAA,IAC5C,8BAA8B,CAAC,YAC7B,6BAA6B,UAAU,OAAO;AAAA,IAChD,uCAAuC,CAAC,YACtC,sCAAsC,UAAU,OAAO;AAAA,IACzD,mCAAmC,CAAC,YAClC,kCAAkC,UAAU,OAAO;AAAA,IACrD,qCAAqC,CAAC,YACpC,oCAAoC,UAAU,OAAO;AAAA,IACvD,sBAAsB,CAAC,YACrB,qBAAqB,UAAU,OAAO;AAAA,IACxC,wBAAwB,CAAC,YACvB,uBAAuB,UAAU,OAAO;AAAA,EAC5C;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"openapi",
|
|
17
17
|
"scalar"
|
|
18
18
|
],
|
|
19
|
-
"version": "0.26.
|
|
19
|
+
"version": "0.26.2",
|
|
20
20
|
"engines": {
|
|
21
21
|
"node": ">=18"
|
|
22
22
|
},
|
|
@@ -114,13 +114,13 @@
|
|
|
114
114
|
"vue": "^3.5.26",
|
|
115
115
|
"yaml": "^2.8.0",
|
|
116
116
|
"@scalar/code-highlight": "0.2.2",
|
|
117
|
-
"@scalar/
|
|
118
|
-
"@scalar/
|
|
119
|
-
"@scalar/
|
|
120
|
-
"@scalar/object-utils": "1.2.22",
|
|
121
|
-
"@scalar/types": "0.5.9",
|
|
117
|
+
"@scalar/json-magic": "0.9.3",
|
|
118
|
+
"@scalar/helpers": "0.2.9",
|
|
119
|
+
"@scalar/object-utils": "1.2.23",
|
|
122
120
|
"@scalar/openapi-upgrader": "0.1.8",
|
|
123
|
-
"@scalar/themes": "0.13.26"
|
|
121
|
+
"@scalar/themes": "0.13.26",
|
|
122
|
+
"@scalar/types": "0.5.10",
|
|
123
|
+
"@scalar/snippetz": "0.6.8"
|
|
124
124
|
},
|
|
125
125
|
"devDependencies": {
|
|
126
126
|
"@google-cloud/storage": "7.16.0",
|