@scalar/workspace-store 0.22.1 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +35 -0
- package/dist/events/definitions/document.d.ts +7 -0
- package/dist/events/definitions/document.d.ts.map +1 -1
- package/dist/events/definitions/operation.d.ts +29 -19
- package/dist/events/definitions/operation.d.ts.map +1 -1
- package/dist/events/definitions/tag.d.ts +9 -2
- package/dist/events/definitions/tag.d.ts.map +1 -1
- package/dist/events/definitions/ui.d.ts +17 -4
- package/dist/events/definitions/ui.d.ts.map +1 -1
- package/dist/mutators/document.d.ts +6 -0
- package/dist/mutators/document.d.ts.map +1 -1
- package/dist/mutators/document.js +7 -0
- package/dist/mutators/document.js.map +2 -2
- package/dist/mutators/index.d.ts +3 -3
- package/dist/mutators/index.d.ts.map +1 -1
- package/dist/mutators/index.js +10 -6
- package/dist/mutators/index.js.map +2 -2
- package/dist/mutators/operation.d.ts +21 -19
- package/dist/mutators/operation.d.ts.map +1 -1
- package/dist/mutators/operation.js +118 -65
- package/dist/mutators/operation.js.map +2 -2
- package/dist/mutators/tag.d.ts +12 -0
- package/dist/mutators/tag.d.ts.map +1 -1
- package/dist/mutators/tag.js +40 -3
- package/dist/mutators/tag.js.map +2 -2
- package/dist/navigation/helpers/get-operation-entries.d.ts +5 -5
- package/dist/navigation/helpers/get-operation-entries.d.ts.map +1 -1
- package/dist/navigation/helpers/get-operation-entries.js.map +2 -2
- package/dist/navigation/index.d.ts +1 -0
- package/dist/navigation/index.d.ts.map +1 -1
- package/dist/navigation/index.js +2 -0
- package/dist/navigation/index.js.map +2 -2
- package/dist/schemas/extensions/general/x-scalar-cookies.d.ts +7 -1
- package/dist/schemas/extensions/general/x-scalar-cookies.d.ts.map +1 -1
- package/dist/schemas/extensions/general/x-scalar-cookies.js +1 -0
- package/dist/schemas/extensions/general/x-scalar-cookies.js.map +2 -2
- package/dist/schemas/inmemory-workspace.d.ts +2 -0
- package/dist/schemas/inmemory-workspace.d.ts.map +1 -1
- package/dist/schemas/reference-config/index.d.ts +1 -0
- package/dist/schemas/reference-config/index.d.ts.map +1 -1
- package/dist/schemas/reference-config/settings.d.ts +1 -0
- package/dist/schemas/reference-config/settings.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/openapi-document.d.ts +34 -0
- package/dist/schemas/v3.1/strict/openapi-document.d.ts.map +1 -1
- package/dist/schemas/workspace-specification/config.d.ts +1 -0
- package/dist/schemas/workspace-specification/config.d.ts.map +1 -1
- package/dist/schemas/workspace-specification/index.d.ts +1 -0
- package/dist/schemas/workspace-specification/index.d.ts.map +1 -1
- package/dist/schemas/workspace.d.ts +9 -0
- package/dist/schemas/workspace.d.ts.map +1 -1
- package/package.json +9 -9
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { isHttpMethod } from "@scalar/helpers/http/is-http-method";
|
|
2
|
+
import { objectKeys } from "@scalar/helpers/object/object-keys";
|
|
2
3
|
import { preventPollution } from "@scalar/helpers/object/prevent-pollution";
|
|
3
4
|
import { findVariables } from "@scalar/helpers/regex/find-variables";
|
|
4
5
|
import { getResolvedRef } from "../helpers/get-resolved-ref.js";
|
|
5
6
|
import { unpackProxyObject } from "../helpers/unpack-proxy.js";
|
|
6
|
-
import { getOpenapiObject } from "../navigation/index.js";
|
|
7
|
+
import { getOpenapiObject, getOperationEntries } from "../navigation/index.js";
|
|
7
8
|
import { getNavigationOptions } from "../navigation/get-navigation-options.js";
|
|
8
9
|
import { canHaveOrder } from "../navigation/helpers/get-openapi-object.js";
|
|
9
|
-
import { getOperationEntries } from "../navigation/helpers/get-operation-entries.js";
|
|
10
10
|
import { isContentTypeParameterObject } from "../schemas/v3.1/strict/type-guards.js";
|
|
11
11
|
const getParameterPositions = (path, parameters) => {
|
|
12
12
|
const positions = {};
|
|
@@ -103,24 +103,14 @@ const updateOperationSummary = (document, { meta, payload: { summary } }) => {
|
|
|
103
103
|
}
|
|
104
104
|
operation.summary = summary;
|
|
105
105
|
};
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
const operation = getResolvedRef(document.paths?.[meta.path]?.[meta.method]);
|
|
116
|
-
if (!operation) {
|
|
117
|
-
console.error("Operation not found", { meta, document });
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
const documentConfig = store?.getDocumentConfiguration(documentName);
|
|
121
|
-
const { generateId } = getNavigationOptions(documentName, documentConfig);
|
|
122
|
-
const operationsMap = getOperationEntries(document["x-scalar-navigation"]);
|
|
123
|
-
const entries = operationsMap.get(`${meta.path}|${meta.method}`);
|
|
106
|
+
const updateOperationOrderId = ({
|
|
107
|
+
store,
|
|
108
|
+
operation,
|
|
109
|
+
generateId,
|
|
110
|
+
method,
|
|
111
|
+
path,
|
|
112
|
+
entries
|
|
113
|
+
}) => {
|
|
124
114
|
entries?.forEach((entry) => {
|
|
125
115
|
if (!canHaveOrder(entry.parent)) {
|
|
126
116
|
return;
|
|
@@ -137,62 +127,114 @@ const updateOperationMethod = (document, store, { meta, payload: { method } }, c
|
|
|
137
127
|
const parentTag = entry.parent.type === "tag" && "name" in parentOpenAPIObject ? { tag: parentOpenAPIObject, id: entry.parent.id } : void 0;
|
|
138
128
|
order[index] = generateId({
|
|
139
129
|
type: "operation",
|
|
140
|
-
path
|
|
130
|
+
path,
|
|
141
131
|
method,
|
|
142
132
|
operation,
|
|
143
133
|
parentId: entry.parent.id,
|
|
144
134
|
parentTag
|
|
145
135
|
});
|
|
146
136
|
});
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
137
|
+
};
|
|
138
|
+
const updateOperationPathMethod = (document, store, { meta, payload: { method, path } }, callback) => {
|
|
139
|
+
const methodChanged = meta.method !== method;
|
|
140
|
+
const pathChanged = meta.path !== path;
|
|
141
|
+
if (!methodChanged && !pathChanged) {
|
|
142
|
+
callback("no-change");
|
|
150
143
|
return;
|
|
151
144
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
if (
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
} else {
|
|
158
|
-
callback?.(true);
|
|
145
|
+
const finalMethod = methodChanged ? method : meta.method;
|
|
146
|
+
const finalPath = pathChanged ? path : meta.path;
|
|
147
|
+
if (document?.paths?.[finalPath]?.[finalMethod]) {
|
|
148
|
+
callback("conflict");
|
|
149
|
+
return;
|
|
159
150
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
151
|
+
const documentNavigation = document?.["x-scalar-navigation"];
|
|
152
|
+
if (!documentNavigation || !store) {
|
|
153
|
+
console.error("Document or workspace not found", { document });
|
|
163
154
|
return;
|
|
164
155
|
}
|
|
165
156
|
const operation = getResolvedRef(document.paths?.[meta.path]?.[meta.method]);
|
|
166
157
|
if (!operation) {
|
|
158
|
+
console.error("Operation not found", { meta, document });
|
|
167
159
|
return;
|
|
168
160
|
}
|
|
169
|
-
if (
|
|
170
|
-
|
|
161
|
+
if (pathChanged) {
|
|
162
|
+
const oldPathParams = findVariables(meta.path, { includePath: true, includeEnv: false }).filter(
|
|
163
|
+
(v) => v !== void 0
|
|
164
|
+
);
|
|
165
|
+
const newPathParams = findVariables(finalPath, { includePath: true, includeEnv: false }).filter(
|
|
166
|
+
(v) => v !== void 0
|
|
167
|
+
);
|
|
168
|
+
if (oldPathParams.length > 0 || newPathParams.length > 0) {
|
|
169
|
+
const existingParameters = operation.parameters ?? [];
|
|
170
|
+
operation.parameters = syncParametersForPathChange(finalPath, meta.path, existingParameters);
|
|
171
|
+
}
|
|
171
172
|
}
|
|
172
|
-
const
|
|
173
|
-
|
|
174
|
-
);
|
|
175
|
-
const
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
if (oldPathParams.length > 0 || newPathParams.length > 0) {
|
|
179
|
-
const existingParameters = operation.parameters ?? [];
|
|
180
|
-
operation.parameters = syncParametersForPathChange(path, meta.path, existingParameters);
|
|
173
|
+
const documentConfig = store.getDocumentConfiguration(documentNavigation.name);
|
|
174
|
+
const { generateId } = getNavigationOptions(documentNavigation.name, documentConfig);
|
|
175
|
+
const operationEntriesMap = getOperationEntries(documentNavigation);
|
|
176
|
+
const entries = operationEntriesMap.get(`${meta.path}|${meta.method}`);
|
|
177
|
+
if (entries) {
|
|
178
|
+
updateOperationOrderId({ store, operation, generateId, method: finalMethod, path: finalPath, entries });
|
|
181
179
|
}
|
|
182
180
|
if (!document.paths) {
|
|
183
181
|
document.paths = {};
|
|
184
182
|
}
|
|
185
|
-
if (!document.paths[
|
|
186
|
-
document.paths[
|
|
183
|
+
if (!document.paths[finalPath]) {
|
|
184
|
+
document.paths[finalPath] = {};
|
|
187
185
|
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
186
|
+
preventPollution(finalPath);
|
|
187
|
+
preventPollution(meta.path);
|
|
188
|
+
preventPollution(finalMethod);
|
|
189
|
+
document.paths[finalPath][finalMethod] = unpackProxyObject(operation);
|
|
190
|
+
const oldPathItems = document.paths[meta.path];
|
|
191
|
+
if (oldPathItems && isHttpMethod(meta.method)) {
|
|
192
|
+
delete oldPathItems[meta.method];
|
|
193
|
+
if (Object.keys(oldPathItems).length === 0) {
|
|
193
194
|
delete document.paths[meta.path];
|
|
194
195
|
}
|
|
195
196
|
}
|
|
197
|
+
callback("success");
|
|
198
|
+
};
|
|
199
|
+
const deleteOperation = (workspace, { meta, documentName }) => {
|
|
200
|
+
const document = workspace?.workspace.documents[documentName];
|
|
201
|
+
if (!document) {
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
preventPollution(meta.path);
|
|
205
|
+
preventPollution(meta.method);
|
|
206
|
+
delete document.paths?.[meta.path]?.[meta.method];
|
|
207
|
+
if (Object.keys(document.paths?.[meta.path] ?? {}).length === 0) {
|
|
208
|
+
delete document.paths?.[meta.path];
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
const deleteOperationExample = (workspace, { meta: { path, method, exampleKey }, documentName }) => {
|
|
212
|
+
const document = workspace?.workspace.documents[documentName];
|
|
213
|
+
if (!document) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
const operation = getResolvedRef(document.paths?.[path]?.[method]);
|
|
217
|
+
if (!operation) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
operation.parameters?.forEach((parameter) => {
|
|
221
|
+
const resolvedParameter = getResolvedRef(parameter);
|
|
222
|
+
if ("content" in resolvedParameter && resolvedParameter.content) {
|
|
223
|
+
Object.values(resolvedParameter.content).forEach((mediaType) => {
|
|
224
|
+
delete mediaType.examples?.[exampleKey];
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
if ("examples" in resolvedParameter && resolvedParameter.examples) {
|
|
228
|
+
delete resolvedParameter.examples?.[exampleKey];
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
const requestBody = getResolvedRef(operation.requestBody);
|
|
232
|
+
if (!requestBody) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
Object.values(requestBody.content ?? {}).forEach((mediaType) => {
|
|
236
|
+
delete mediaType.examples?.[exampleKey];
|
|
237
|
+
});
|
|
196
238
|
};
|
|
197
239
|
const addOperationParameter = (document, { meta, payload, type }) => {
|
|
198
240
|
if (!document) {
|
|
@@ -212,7 +254,7 @@ const addOperationParameter = (document, { meta, payload, type }) => {
|
|
|
212
254
|
examples: {
|
|
213
255
|
[meta.exampleKey]: {
|
|
214
256
|
value: payload.value,
|
|
215
|
-
"x-disabled":
|
|
257
|
+
"x-disabled": Boolean(payload.isDisabled)
|
|
216
258
|
}
|
|
217
259
|
}
|
|
218
260
|
});
|
|
@@ -241,12 +283,12 @@ const updateOperationParameter = (document, { meta, type, payload, index }) => {
|
|
|
241
283
|
if (!example) {
|
|
242
284
|
parameter.examples[meta.exampleKey] = {
|
|
243
285
|
value: payload.value ?? "",
|
|
244
|
-
"x-disabled": payload.
|
|
286
|
+
"x-disabled": Boolean(payload.isDisabled)
|
|
245
287
|
};
|
|
246
288
|
return;
|
|
247
289
|
}
|
|
248
290
|
example.value = payload.value ?? example?.value ?? "";
|
|
249
|
-
example["x-disabled"] = payload.
|
|
291
|
+
example["x-disabled"] = Boolean(payload.isDisabled ?? example["x-disabled"]);
|
|
250
292
|
};
|
|
251
293
|
const deleteOperationParameter = (document, { meta, index, type }) => {
|
|
252
294
|
if (!document) {
|
|
@@ -262,7 +304,10 @@ const deleteOperationParameter = (document, { meta, index, type }) => {
|
|
|
262
304
|
return;
|
|
263
305
|
}
|
|
264
306
|
const actualIndex = operation.parameters?.findIndex((it) => getResolvedRef(it) === parameter);
|
|
265
|
-
operation.parameters
|
|
307
|
+
operation.parameters = unpackProxyObject(
|
|
308
|
+
operation.parameters?.filter((_, i) => i !== actualIndex),
|
|
309
|
+
{ depth: 1 }
|
|
310
|
+
);
|
|
266
311
|
};
|
|
267
312
|
const deleteAllOperationParameters = (document, { meta, type }) => {
|
|
268
313
|
if (!document) {
|
|
@@ -356,7 +401,8 @@ const addOperationRequestBodyFormRow = (document, { meta, payload, contentType }
|
|
|
356
401
|
value: [
|
|
357
402
|
{
|
|
358
403
|
name: payload.key,
|
|
359
|
-
value: payload.value
|
|
404
|
+
value: payload.value,
|
|
405
|
+
isDisabled: false
|
|
360
406
|
}
|
|
361
407
|
]
|
|
362
408
|
};
|
|
@@ -364,7 +410,8 @@ const addOperationRequestBodyFormRow = (document, { meta, payload, contentType }
|
|
|
364
410
|
}
|
|
365
411
|
example.value.push({
|
|
366
412
|
name: payload.key ?? "",
|
|
367
|
-
value: payload.value ?? ""
|
|
413
|
+
value: payload.value ?? "",
|
|
414
|
+
isDisabled: false
|
|
368
415
|
});
|
|
369
416
|
};
|
|
370
417
|
const updateOperationRequestBodyFormRow = (document, { meta, index, payload, contentType }) => {
|
|
@@ -393,10 +440,12 @@ const updateOperationRequestBodyFormRow = (document, { meta, index, payload, con
|
|
|
393
440
|
if (!example || !Array.isArray(example.value)) {
|
|
394
441
|
return;
|
|
395
442
|
}
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
443
|
+
for (const key of objectKeys(payload)) {
|
|
444
|
+
if (example.value[index]) {
|
|
445
|
+
preventPollution(key, "updateOperationRequestBodyFormRow");
|
|
446
|
+
example.value[index][key === "key" ? "name" : key] = payload[key];
|
|
447
|
+
}
|
|
448
|
+
}
|
|
400
449
|
};
|
|
401
450
|
const deleteOperationRequestBodyFormRow = (document, { meta, index, contentType }) => {
|
|
402
451
|
if (!document) {
|
|
@@ -421,7 +470,10 @@ const deleteOperationRequestBodyFormRow = (document, { meta, index, contentType
|
|
|
421
470
|
if (!example || !Array.isArray(example.value)) {
|
|
422
471
|
return;
|
|
423
472
|
}
|
|
424
|
-
example.value
|
|
473
|
+
example.value = unpackProxyObject(
|
|
474
|
+
example.value.filter((_, i) => i !== index),
|
|
475
|
+
{ depth: 1 }
|
|
476
|
+
);
|
|
425
477
|
if (example.value.length === 0) {
|
|
426
478
|
delete requestBody.content[contentType].examples[meta.exampleKey];
|
|
427
479
|
}
|
|
@@ -431,11 +483,12 @@ export {
|
|
|
431
483
|
addOperationRequestBodyFormRow,
|
|
432
484
|
createOperation,
|
|
433
485
|
deleteAllOperationParameters,
|
|
486
|
+
deleteOperation,
|
|
487
|
+
deleteOperationExample,
|
|
434
488
|
deleteOperationParameter,
|
|
435
489
|
deleteOperationRequestBodyFormRow,
|
|
436
|
-
updateOperationMethod,
|
|
437
490
|
updateOperationParameter,
|
|
438
|
-
|
|
491
|
+
updateOperationPathMethod,
|
|
439
492
|
updateOperationRequestBodyContentType,
|
|
440
493
|
updateOperationRequestBodyExample,
|
|
441
494
|
updateOperationRequestBodyFormRow,
|
|
@@ -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 { OperationEvents } from '@/events/definitions/operation'\nimport { getResolvedRef } from '@/helpers/get-resolved-ref'\nimport { unpackProxyObject } from '@/helpers/unpack-proxy'\nimport { getOpenapiObject } from '@/navigation'\nimport { getNavigationOptions } from '@/navigation/get-navigation-options'\nimport { canHaveOrder } from '@/navigation/helpers/get-openapi-object'\nimport { getOperationEntries } from '@/navigation/helpers/get-operation-entries'\nimport type { WorkspaceDocument } from '@/schemas'\nimport type { 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 * Describes the minimal identity for an operation in the workspace document.\n * It is used by mutators to find the target operation under `paths`.\n *\n * Example:\n * ```ts\n * const meta: OperationMeta = { method: 'get', path: '/users/{id}' }\n * ```\n */\nexport type OperationMeta = {\n method: HttpMethod\n path: string\n}\n\n/**\n * Extends {@link OperationMeta} with an `exampleKey` to address a specific\n * example variant (e.g. per environment or scenario) for request/parameters.\n *\n * Example:\n * ```ts\n * const meta: OperationExampleMeta = {\n * method: 'post',\n * path: '/upload',\n * exampleKey: 'default',\n * }\n * ```\n */\nexport type OperationExampleMeta = OperationMeta & {\n exampleKey: string\n}\n\n/** ------------------------------------------------------------------------------------------------\n * 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, keeping original references\n const pathParameters: ReferenceType<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(param)\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, ReferenceType<ParameterObject>>()\n for (const param of pathParameters) {\n const resolved = getResolvedRef(param)\n if (resolved?.name) {\n existingPathParamsByName.set(resolved.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 if (oldParamAtPosition && existingPathParamsByName.has(oldParamAtPosition)) {\n // Rename: transfer the old parameter's config to the new name\n const oldParam = existingPathParamsByName.get(oldParamAtPosition)!\n const resolved = getResolvedRef(oldParam)\n if (resolved) {\n resolved.name = newParamName\n syncedPathParameters.push(oldParam)\n usedOldParams.add(oldParamAtPosition)\n continue\n }\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 [...syncedPathParameters, ...nonPathParameters]\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 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 HTTP method of an operation and moves it to the new method slot.\n * This function:\n * 1. Moves the operation from the old method to the new method under paths\n * 2. Updates x-scalar-order to maintain the operation's position in the sidebar\n * 3. Rebuilds the sidebar to reflect the changes\n *\n * Safely no-ops if the document or operation does not exist.\n *\n * Example:\n * ```ts\n * updateOperationMethod({\n * document,\n * store,\n * meta: { method: 'get', path: '/users' },\n * payload: { method: 'post' },\n * })\n * ```\n */\nexport const updateOperationMethod = (\n document: WorkspaceDocument | null,\n store: WorkspaceStore | null,\n { meta, payload: { method } }: OperationEvents['operation:update:method'],\n callback?: (success: boolean) => void,\n) => {\n // If the method has not changed, no need to do anything\n if (meta.method === method || !isHttpMethod(method)) {\n return\n }\n\n const documentName = document?.['x-scalar-navigation']?.name\n if (!document?.['x-scalar-navigation'] || !documentName || !store) {\n console.error('Document or workspace not found', { document })\n return\n }\n\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 // Get the document configuration to generate IDs consistently\n // If no store is provided (e.g., in tests), use default configuration\n const documentConfig = store?.getDocumentConfiguration(documentName)\n const { generateId } = getNavigationOptions(documentName, documentConfig)\n\n /** Generate an operations map of the document */\n const operationsMap = getOperationEntries(document['x-scalar-navigation'])\n\n /** Grabs all of the current operation entries for the given path and method */\n const entries = operationsMap.get(`${meta.path}|${meta.method}`)\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: meta.path,\n method: method,\n operation: operation,\n parentId: entry.parent.id,\n parentTag,\n })\n })\n\n // Prevent assigning dangerous keys to the path items object\n preventPollution(meta.path)\n\n // Now ensure we replace the actual operation in the document\n const pathItems = document.paths?.[meta.path]\n if (!pathItems) {\n return\n }\n\n pathItems[method] = unpackProxyObject(operation)\n delete pathItems[meta.method]\n\n // Rebuild the sidebar with the updated order (if store is available)\n if (store) {\n const success = store.buildSidebar(documentName)\n callback?.(success)\n } else {\n callback?.(true)\n }\n}\n\n/**\n * Moves the operation to a new path in the document and synchronizes path\n * parameters in `operation.parameters` with the placeholders present in the\n * provided `path` (e.g. `/users/{id}`). When path parameters change,\n * intelligently syncs them by preserving configurations for renamed parameters\n * (detected by position) and existing parameters. Existing non-path parameters\n * are preserved. The operation is removed from the old path location.\n *\n * Example:\n * ```ts\n * updateOperationPath({\n * document,\n * meta: { method: 'get', path: '/users/{id}' },\n * payload: { path: '/users/{userId}' },\n * })\n * ```\n */\nexport const updateOperationPath = (\n document: WorkspaceDocument | null,\n { meta, payload: { path } }: OperationEvents['operation:update:path'],\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 // If the path has not changed, no need to move the operation\n if (meta.path === path) {\n return\n }\n\n // Sync path parameters if either the old or new path has path parameters\n const oldPathParams = findVariables(meta.path, { includePath: true, includeEnv: false }).filter(\n (v): v is string => v !== undefined,\n )\n const newPathParams = findVariables(path, { 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(path, meta.path, existingParameters)\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[path]) {\n document.paths[path] = {}\n }\n\n // Move the operation to the new path\n document.paths[path][meta.method] = unpackProxyObject(operation)\n\n // Remove the operation from the old path\n const oldPath = document.paths[meta.path]\n if (oldPath) {\n delete oldPath[meta.method]\n\n // If the old path has no more operations, remove the path entry\n if (Object.keys(oldPath).length === 0) {\n delete document.paths[meta.path]\n }\n }\n}\n\n/** ------------------------------------------------------------------------------------------------\n * Operation Parameters Mutators\n * ------------------------------------------------------------------------------------------------ */\n\n/**\n * Adds a parameter to the operation with an example value tracked by `exampleKey`.\n * For `path` parameters `required` is set to true automatically.\n * Safely no-ops if the document or operation does not exist.\n *\n * Example:\n * ```ts\n * addOperationParameter({\n * document,\n * type: 'query',\n * meta: { method: 'get', path: '/search', exampleKey: 'default' },\n * payload: { key: 'q', value: 'john', isEnabled: true },\n * })\n * ```\n */\nexport const addOperationParameter = (\n document: WorkspaceDocument | null,\n { meta, payload, type }: OperationEvents['operation:add: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 // Initialize parameters array if it doesn't exist\n if (!operation.parameters) {\n operation.parameters = []\n }\n\n // Add the new parameter\n operation.parameters.push({\n name: payload.key,\n in: type,\n required: type === 'path' ? true : false,\n examples: {\n [meta.exampleKey]: {\n value: payload.value,\n 'x-disabled': !payload.isEnabled,\n },\n },\n })\n}\n\n/**\n * Updates an existing parameter of a given `type` by its index within that\n * type subset (e.g. the N-th query parameter). Supports updating name, value,\n * and enabled state for the targeted example.\n * Safely no-ops if the document, operation, or parameter does not exist.\n *\n * Example:\n * ```ts\n * updateOperationParameter({\n * document,\n * type: 'query',\n * index: 0,\n * meta: { method: 'get', path: '/search', exampleKey: 'default' },\n * payload: { value: 'alice', isEnabled: true },\n * })\n * ```\n */\nexport const updateOperationParameter = (\n document: WorkspaceDocument | null,\n { meta, type, payload, index }: OperationEvents['operation:update: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 // 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 if (!parameter) {\n return\n }\n\n parameter.name = payload.key ?? parameter.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 const example = getResolvedRef(parameter.examples[meta.exampleKey])\n\n // Create the example if it doesn't exist\n if (!example) {\n parameter.examples[meta.exampleKey] = {\n value: payload.value ?? '',\n 'x-disabled': payload.isEnabled === undefined ? false : !payload.isEnabled,\n }\n return\n }\n\n // Update existing example value\n example.value = payload.value ?? example?.value ?? ''\n example['x-disabled'] = payload.isEnabled === undefined ? example['x-disabled'] : !payload.isEnabled\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 // Remove the parameter from the operation\n operation.parameters?.splice(actualIndex, 1)\n}\n\n/**\n * Deletes all parameters of a given `type` from the operation.\n * Safely no-ops if the document or operation does not exist.\n *\n * Example:\n * ```ts\n * deleteAllOperationParameters({\n * document,\n * type: 'cookie',\n * meta: { method: 'get', path: '/users' },\n * })\n * ```\n */\nexport const deleteAllOperationParameters = (\n document: 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/**\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 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!.content[contentType]) {\n requestBody!.content[contentType] = {\n examples: {},\n }\n }\n\n // Ensure examples object exists and get a resolved reference\n const mediaType = requestBody!.content[contentType]!\n mediaType.examples ??= {}\n const examples = getResolvedRef(mediaType.examples)!\n\n const example = getResolvedRef(examples[meta.exampleKey])\n if (!example) {\n examples[meta.exampleKey] = {\n value: payload.value,\n }\n return\n }\n\n example.value = payload.value\n}\n\n/**\n * Appends a form-data row to the request-body example identified by\n * `contentType` and `exampleKey`. Initializes the example as an array when\n * needed. Safely no-ops if the document or operation does not exist.\n *\n * Example:\n * ```ts\n * addOperationRequestBodyFormRow({\n * document,\n * contentType: 'multipart/form-data',\n * meta: { method: 'post', path: '/upload', exampleKey: 'default' },\n * payload: { key: 'file', value: new File(['x'], 'a.txt') },\n * })\n * ```\n */\nexport const addOperationRequestBodyFormRow = (\n document: WorkspaceDocument | null,\n { meta, payload, contentType }: OperationEvents['operation:add:requestBody:formRow'],\n) => {\n if (!document) {\n return\n }\n\n const operation = getResolvedRef(document.paths?.[meta.path]?.[meta.method])\n\n // Don't proceed if operation doesn't exist\n if (!operation) {\n return\n }\n\n let requestBody = getResolvedRef(operation.requestBody)\n\n if (!requestBody) {\n operation.requestBody = {\n content: {},\n }\n requestBody = getResolvedRef(operation.requestBody)\n }\n\n if (!requestBody!.content[contentType]) {\n requestBody!.content[contentType] = {\n examples: {},\n }\n }\n\n if (!requestBody!.content[contentType]!.examples) {\n requestBody!.content[contentType]!.examples = {}\n }\n\n const examples = getResolvedRef(requestBody!.content[contentType]!.examples)\n\n const example = getResolvedRef(examples[meta.exampleKey])\n\n if (!example || !Array.isArray(example.value)) {\n examples[meta.exampleKey] = {\n value: [\n {\n name: payload.key,\n value: payload.value,\n },\n ],\n }\n return\n }\n\n // Add the new row to the example\n example.value.push({\n name: payload.key ?? '',\n value: payload.value ?? '',\n })\n}\n\n/**\n * Updates a form-data row at a given `index` for the specified example and\n * `contentType`. Setting `payload.value` to `null` clears the value (sets to\n * `undefined`). Safely no-ops if the document, operation, or example does not exist.\n *\n * Example:\n * ```ts\n * updateOperationRequestBodyFormRow({\n * document,\n * index: 0,\n * contentType: 'multipart/form-data',\n * meta: { method: 'post', path: '/upload', exampleKey: 'default' },\n * payload: { key: 'description', value: 'Profile picture' },\n * })\n * ```\n */\nexport const updateOperationRequestBodyFormRow = (\n document: WorkspaceDocument | null,\n { meta, index, payload, contentType }: OperationEvents['operation:update:requestBody:formRow'],\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!.content[contentType]) {\n return\n }\n\n const examples = getResolvedRef(requestBody!.content[contentType]!.examples)\n if (!examples) {\n return\n }\n\n const example = getResolvedRef(examples[meta.exampleKey])\n if (!example || !Array.isArray(example.value)) {\n return\n }\n\n example.value[index] = {\n name: payload.key ?? example.value[index]?.name ?? '',\n value: payload.value === null ? undefined : (payload.value ?? example.value[index]?.value ?? ''),\n }\n}\n\n/**\n * Deletes a form-data row at a given `index` from the example for the given\n * `contentType`. If the example becomes empty, the example entry is removed.\n * Safely no-ops if the document, operation, example, or row does not exist.\n *\n * Example:\n * ```ts\n * deleteOperationRequestBodyFormRow({\n * document,\n * index: 0,\n * contentType: 'multipart/form-data',\n * meta: { method: 'post', path: '/upload', exampleKey: 'default' },\n * })\n * ```\n */\nexport const deleteOperationRequestBodyFormRow = (\n document: WorkspaceDocument | null,\n { meta, index, contentType }: OperationEvents['operation:delete:requestBody:formRow'],\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 const requestBody = getResolvedRef(operation.requestBody)\n if (!requestBody) {\n return\n }\n\n if (!requestBody.content[contentType]) {\n return\n }\n\n const examples = getResolvedRef(requestBody.content[contentType]!.examples)\n if (!examples) {\n return\n }\n\n const example = getResolvedRef(examples[meta.exampleKey])\n if (!example || !Array.isArray(example.value)) {\n return\n }\n\n example.value.splice(index, 1)\n\n if (example.value.length === 0) {\n delete requestBody.content[contentType]!.examples![meta.exampleKey]\n }\n}\n"],
|
|
5
|
-
"mappings": "AACA,SAAS,oBAAoB;AAC7B,SAAS,wBAAwB;AACjC,SAAS,qBAAqB;AAI9B,SAAS,sBAAsB;AAC/B,SAAS,yBAAyB;AAClC,SAAS,wBAAwB;AACjC,SAAS,4BAA4B;AACrC,SAAS,oBAAoB;AAC7B,SAAS,2BAA2B;AAIpC,SAAS,oCAAoC;AAyC7C,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,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,UAAU;AAAA,EACpE;AACF;",
|
|
4
|
+
"sourcesContent": ["import type { HttpMethod } from '@scalar/helpers/http/http-methods'\nimport { isHttpMethod } from '@scalar/helpers/http/is-http-method'\nimport { objectKeys } from '@scalar/helpers/object/object-keys'\nimport { preventPollution } from '@scalar/helpers/object/prevent-pollution'\nimport { findVariables } from '@scalar/helpers/regex/find-variables'\n\nimport type { WorkspaceStore } from '@/client'\nimport type { OperationEvents } from '@/events/definitions/operation'\nimport { getResolvedRef } from '@/helpers/get-resolved-ref'\nimport { unpackProxyObject } from '@/helpers/unpack-proxy'\nimport { 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 { IdGenerator, TraversedOperation, TraversedWebhook, WithParent } from '@/schemas/navigation'\nimport type { 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 * Describes the minimal identity for an operation in the workspace document.\n * It is used by mutators to find the target operation under `paths`.\n *\n * Example:\n * ```ts\n * const meta: OperationMeta = { method: 'get', path: '/users/{id}' }\n * ```\n */\nexport type OperationMeta = {\n method: HttpMethod\n path: string\n}\n\n/**\n * Extends {@link OperationMeta} with an `exampleKey` to address a specific\n * example variant (e.g. per environment or scenario) for request/parameters.\n *\n * Example:\n * ```ts\n * const meta: OperationExampleMeta = {\n * method: 'post',\n * path: '/upload',\n * exampleKey: 'default',\n * }\n * ```\n */\nexport type OperationExampleMeta = OperationMeta & {\n exampleKey: string\n}\n\n/** ------------------------------------------------------------------------------------------------\n * 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, keeping original references\n const pathParameters: ReferenceType<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(param)\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, ReferenceType<ParameterObject>>()\n for (const param of pathParameters) {\n const resolved = getResolvedRef(param)\n if (resolved?.name) {\n existingPathParamsByName.set(resolved.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 if (oldParamAtPosition && existingPathParamsByName.has(oldParamAtPosition)) {\n // Rename: transfer the old parameter's config to the new name\n const oldParam = existingPathParamsByName.get(oldParamAtPosition)!\n const resolved = getResolvedRef(oldParam)\n if (resolved) {\n resolved.name = newParamName\n syncedPathParameters.push(oldParam)\n usedOldParams.add(oldParamAtPosition)\n continue\n }\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 [...syncedPathParameters, ...nonPathParameters]\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 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 } }: OperationEvents['operation:update:pathMethod'],\n callback: OperationEvents['operation:update:pathMethod']['callback'],\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]) {\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])\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 // Get the document configuration to generate IDs consistently\n const documentConfig = store.getDocumentConfiguration(documentNavigation.name)\n const { generateId } = getNavigationOptions(documentNavigation.name, documentConfig)\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 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 * Adds a parameter to the operation with an example value tracked by `exampleKey`.\n * For `path` parameters `required` is set to true automatically.\n * Safely no-ops if the document or operation does not exist.\n *\n * Example:\n * ```ts\n * addOperationParameter({\n * document,\n * type: 'query',\n * meta: { method: 'get', path: '/search', exampleKey: 'default' },\n * payload: { key: 'q', value: 'john', isDisabled: false },\n * })\n * ```\n */\nexport const addOperationParameter = (\n document: WorkspaceDocument | null,\n { meta, payload, type }: OperationEvents['operation:add: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 // Initialize parameters array if it doesn't exist\n if (!operation.parameters) {\n operation.parameters = []\n }\n\n // Add the new parameter\n operation.parameters.push({\n name: payload.key,\n in: type,\n required: type === 'path' ? true : false,\n examples: {\n [meta.exampleKey]: {\n value: payload.value,\n 'x-disabled': Boolean(payload.isDisabled),\n },\n },\n })\n}\n\n/**\n * Updates an existing parameter of a given `type` by its index within that\n * type subset (e.g. the N-th query parameter). Supports updating name, value,\n * and enabled state for the targeted example.\n * Safely no-ops if the document, operation, or parameter does not exist.\n *\n * Example:\n * ```ts\n * updateOperationParameter({\n * document,\n * type: 'query',\n * index: 0,\n * meta: { method: 'get', path: '/search', exampleKey: 'default' },\n * payload: { value: 'alice', isDisabled: false },\n * })\n * ```\n */\nexport const updateOperationParameter = (\n document: WorkspaceDocument | null,\n { meta, type, payload, index }: OperationEvents['operation:update: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 // 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 if (!parameter) {\n return\n }\n\n parameter.name = payload.key ?? parameter.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 const example = getResolvedRef(parameter.examples[meta.exampleKey])\n\n // Create the example if it doesn't exist\n if (!example) {\n parameter.examples[meta.exampleKey] = {\n value: payload.value ?? '',\n 'x-disabled': Boolean(payload.isDisabled),\n }\n return\n }\n\n // Update existing example value\n example.value = payload.value ?? example?.value ?? ''\n example['x-disabled'] = Boolean(payload.isDisabled ?? example['x-disabled'])\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/**\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 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!.content[contentType]) {\n requestBody!.content[contentType] = {\n examples: {},\n }\n }\n\n // Ensure examples object exists and get a resolved reference\n const mediaType = requestBody!.content[contentType]!\n mediaType.examples ??= {}\n const examples = getResolvedRef(mediaType.examples)!\n\n const example = getResolvedRef(examples[meta.exampleKey])\n if (!example) {\n examples[meta.exampleKey] = {\n value: payload.value,\n }\n return\n }\n\n example.value = payload.value\n}\n\n/**\n * Appends a form-data row to the request-body example identified by\n * `contentType` and `exampleKey`. Initializes the example as an array when\n * needed. Safely no-ops if the document or operation does not exist.\n *\n * Example:\n * ```ts\n * addOperationRequestBodyFormRow({\n * document,\n * contentType: 'multipart/form-data',\n * meta: { method: 'post', path: '/upload', exampleKey: 'default' },\n * payload: { key: 'file', value: new File(['x'], 'a.txt') },\n * })\n * ```\n */\nexport const addOperationRequestBodyFormRow = (\n document: WorkspaceDocument | null,\n { meta, payload, contentType }: OperationEvents['operation:add:requestBody:formRow'],\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!.content[contentType]) {\n requestBody!.content[contentType] = {\n examples: {},\n }\n }\n\n if (!requestBody!.content[contentType]!.examples) {\n requestBody!.content[contentType]!.examples = {}\n }\n\n const examples = getResolvedRef(requestBody!.content[contentType]!.examples)\n const example = getResolvedRef(examples[meta.exampleKey])\n\n if (!example || !Array.isArray(example.value)) {\n examples[meta.exampleKey] = {\n value: [\n {\n name: payload.key,\n value: payload.value,\n isDisabled: false,\n },\n ],\n }\n return\n }\n\n // Add the new row to the example\n example.value.push({\n name: payload.key ?? '',\n value: payload.value ?? '',\n isDisabled: false,\n })\n}\n\n/**\n * Updates a form-data row at a given `index` for the specified example and\n * `contentType`. Setting `payload.value` to `null` clears the value (sets to\n * `undefined`). Safely no-ops if the document, operation, or example does not exist.\n *\n * Example:\n * ```ts\n * updateOperationRequestBodyFormRow({\n * document,\n * index: 0,\n * contentType: 'multipart/form-data',\n * meta: { method: 'post', path: '/upload', exampleKey: 'default' },\n * payload: { key: 'description', value: 'Profile picture' },\n * })\n * ```\n */\nexport const updateOperationRequestBodyFormRow = (\n document: WorkspaceDocument | null,\n { meta, index, payload, contentType }: OperationEvents['operation:update:requestBody:formRow'],\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!.content[contentType]) {\n return\n }\n\n const examples = getResolvedRef(requestBody!.content[contentType]!.examples)\n if (!examples) {\n return\n }\n\n const example = getResolvedRef(examples[meta.exampleKey])\n if (!example || !Array.isArray(example.value)) {\n return\n }\n\n // Only set the properties that are present in the payload\n for (const key of objectKeys(payload)) {\n if (example.value[index]) {\n preventPollution(key, 'updateOperationRequestBodyFormRow')\n example.value[index][key === 'key' ? 'name' : key] = payload[key]\n }\n }\n}\n\n/**\n * Deletes a form-data row at a given `index` from the example for the given\n * `contentType`. If the example becomes empty, the example entry is removed.\n * Safely no-ops if the document, operation, example, or row does not exist.\n *\n * Example:\n * ```ts\n * deleteOperationRequestBodyFormRow({\n * document,\n * index: 0,\n * contentType: 'multipart/form-data',\n * meta: { method: 'post', path: '/upload', exampleKey: 'default' },\n * })\n * ```\n */\nexport const deleteOperationRequestBodyFormRow = (\n document: WorkspaceDocument | null,\n { meta, index, contentType }: OperationEvents['operation:delete:requestBody:formRow'],\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 const requestBody = getResolvedRef(operation.requestBody)\n if (!requestBody) {\n return\n }\n\n if (!requestBody.content[contentType]) {\n return\n }\n\n const examples = getResolvedRef(requestBody.content[contentType]!.examples)\n if (!examples) {\n return\n }\n\n const example = getResolvedRef(examples[meta.exampleKey])\n if (!example || !Array.isArray(example.value)) {\n return\n }\n\n // We cannot call splice on a proxy object, so we unwrap the array and filter it\n example.value = unpackProxyObject(\n example.value.filter((_, i) => i !== index),\n { depth: 1 },\n )\n\n if (example.value.length === 0) {\n delete requestBody.content[contentType]!.examples![meta.exampleKey]\n }\n}\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;AAC3B,SAAS,wBAAwB;AACjC,SAAS,qBAAqB;AAI9B,SAAS,sBAAsB;AAC/B,SAAS,yBAAyB;AAClC,SAAS,kBAAkB,2BAA2B;AACtD,SAAS,4BAA4B;AACrC,SAAS,oBAAoB;AAK7B,SAAS,oCAAoC;AAyC7C,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,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C;AACxD,MAAI,CAAC,WAAW,CAAC,MAAM,QAAQ,QAAQ,KAAK,GAAG;AAC7C;AAAA,EACF;AAGA,UAAQ,QAAQ;AAAA,IACd,QAAQ,MAAM,OAAO,CAAC,GAAG,MAAM,MAAM,KAAK;AAAA,IAC1C,EAAE,OAAO,EAAE;AAAA,EACb;AAEA,MAAI,QAAQ,MAAM,WAAW,GAAG;AAC9B,WAAO,YAAY,QAAQ,WAAW,EAAG,SAAU,KAAK,UAAU;AAAA,EACpE;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/mutators/tag.d.ts
CHANGED
|
@@ -9,4 +9,16 @@ import type { TagEvents } from '../events/definitions/tag.js';
|
|
|
9
9
|
* @param payload - The name of the tag to add
|
|
10
10
|
*/
|
|
11
11
|
export declare const createTag: (store: WorkspaceStore | null, payload: TagEvents["tag:create:tag"]) => void;
|
|
12
|
+
/**
|
|
13
|
+
* Deletes a tag from the workspace
|
|
14
|
+
*
|
|
15
|
+
* Example:
|
|
16
|
+
* ```ts
|
|
17
|
+
* deleteTag({
|
|
18
|
+
* document,
|
|
19
|
+
* name: 'tag',
|
|
20
|
+
* })
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare const deleteTag: (workspace: WorkspaceStore | null, payload: TagEvents["tag:delete:tag"]) => void;
|
|
12
24
|
//# sourceMappingURL=tag.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tag.d.ts","sourceRoot":"","sources":["../../src/mutators/tag.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;
|
|
1
|
+
{"version":3,"file":"tag.d.ts","sourceRoot":"","sources":["../../src/mutators/tag.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AAIzD;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,GAAI,OAAO,cAAc,GAAG,IAAI,EAAE,SAAS,SAAS,CAAC,gBAAgB,CAAC,SAe3F,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,SAAS,GAAI,WAAW,cAAc,GAAG,IAAI,EAAE,SAAS,SAAS,CAAC,gBAAgB,CAAC,SA8C/F,CAAA"}
|
package/dist/mutators/tag.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { getResolvedRef } from "../helpers/get-resolved-ref.js";
|
|
2
|
+
import { unpackProxyObject } from "../helpers/unpack-proxy.js";
|
|
1
3
|
const createTag = (store, payload) => {
|
|
2
4
|
const document = store?.workspace.documents[payload.documentName];
|
|
3
5
|
if (!document) {
|
|
4
6
|
console.error("Document not found", { payload, store });
|
|
5
|
-
payload.callback?.(false);
|
|
6
7
|
return;
|
|
7
8
|
}
|
|
8
9
|
if (!document.tags) {
|
|
@@ -11,9 +12,45 @@ const createTag = (store, payload) => {
|
|
|
11
12
|
document.tags.push({
|
|
12
13
|
name: payload.name
|
|
13
14
|
});
|
|
14
|
-
|
|
15
|
+
};
|
|
16
|
+
const deleteTag = (workspace, payload) => {
|
|
17
|
+
const document = workspace?.workspace.documents[payload.documentName];
|
|
18
|
+
if (!document) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
Object.values(document.paths ?? {}).forEach((path) => {
|
|
22
|
+
Object.values(path).forEach((operation) => {
|
|
23
|
+
if (typeof operation !== "object" || Array.isArray(operation)) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const resolvedOperation = getResolvedRef(operation);
|
|
27
|
+
if ("tags" in resolvedOperation) {
|
|
28
|
+
resolvedOperation.tags = unpackProxyObject(
|
|
29
|
+
resolvedOperation.tags?.filter((tag) => tag !== payload.name),
|
|
30
|
+
{ depth: 2 }
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
Object.values(document.webhooks ?? {}).forEach((webhook) => {
|
|
36
|
+
Object.values(webhook).forEach((operation) => {
|
|
37
|
+
if (typeof operation !== "object" || Array.isArray(operation)) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const resolvedOperation = getResolvedRef(operation);
|
|
41
|
+
resolvedOperation.tags = unpackProxyObject(
|
|
42
|
+
resolvedOperation.tags?.filter((tag) => tag !== payload.name),
|
|
43
|
+
{ depth: 2 }
|
|
44
|
+
);
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
document.tags = unpackProxyObject(
|
|
48
|
+
document.tags?.filter((tag) => tag.name !== payload.name),
|
|
49
|
+
{ depth: 2 }
|
|
50
|
+
);
|
|
15
51
|
};
|
|
16
52
|
export {
|
|
17
|
-
createTag
|
|
53
|
+
createTag,
|
|
54
|
+
deleteTag
|
|
18
55
|
};
|
|
19
56
|
//# sourceMappingURL=tag.js.map
|
package/dist/mutators/tag.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/mutators/tag.ts"],
|
|
4
|
-
"sourcesContent": ["import type { WorkspaceStore } from '@/client'\nimport type { TagEvents } from '@/events/definitions/tag'\n\n/**\n * Adds a new tag to the WorkspaceDocument's `tags` array.\n *\n * If the document or its tags property does not exist, the function safely no-ops or initializes `tags` as needed.\n *\n * @param document - The target WorkspaceDocument\n * @param payload - The name of the tag to add\n */\nexport const createTag = (store: WorkspaceStore | null, payload: TagEvents['tag:create:tag']) => {\n const document = store?.workspace.documents[payload.documentName]\n\n if (!document) {\n console.error('Document not found', { payload, store })\n
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import type { WorkspaceStore } from '@/client'\nimport type { TagEvents } from '@/events/definitions/tag'\nimport { getResolvedRef } from '@/helpers/get-resolved-ref'\nimport { unpackProxyObject } from '@/helpers/unpack-proxy'\n\n/**\n * Adds a new tag to the WorkspaceDocument's `tags` array.\n *\n * If the document or its tags property does not exist, the function safely no-ops or initializes `tags` as needed.\n *\n * @param document - The target WorkspaceDocument\n * @param payload - The name of the tag to add\n */\nexport const createTag = (store: WorkspaceStore | null, payload: TagEvents['tag:create:tag']) => {\n const document = store?.workspace.documents[payload.documentName]\n\n if (!document) {\n console.error('Document not found', { payload, store })\n return\n }\n\n if (!document.tags) {\n document.tags = []\n }\n\n document.tags.push({\n name: payload.name,\n })\n}\n\n/**\n * Deletes a tag from the workspace\n *\n * Example:\n * ```ts\n * deleteTag({\n * document,\n * name: 'tag',\n * })\n * ```\n */\nexport const deleteTag = (workspace: WorkspaceStore | null, payload: TagEvents['tag:delete:tag']) => {\n const document = workspace?.workspace.documents[payload.documentName]\n if (!document) {\n return\n }\n\n // Clear tags from all operations that have this tag\n Object.values(document.paths ?? {}).forEach((path) => {\n Object.values(path).forEach((operation) => {\n // Only process operations that are objects\n if (typeof operation !== 'object' || Array.isArray(operation)) {\n return\n }\n\n const resolvedOperation = getResolvedRef(operation)\n\n if ('tags' in resolvedOperation) {\n resolvedOperation.tags = unpackProxyObject(\n resolvedOperation.tags?.filter((tag) => tag !== payload.name),\n { depth: 2 },\n )\n }\n })\n })\n\n // Remove the tag from all webhooks that have this tag\n Object.values(document.webhooks ?? {}).forEach((webhook) => {\n Object.values(webhook).forEach((operation) => {\n if (typeof operation !== 'object' || Array.isArray(operation)) {\n return\n }\n\n const resolvedOperation = getResolvedRef(operation)\n\n resolvedOperation.tags = unpackProxyObject(\n resolvedOperation.tags?.filter((tag) => tag !== payload.name),\n { depth: 2 },\n )\n })\n })\n\n // Remove the tag from the document tags array\n document.tags = unpackProxyObject(\n document.tags?.filter((tag) => tag.name !== payload.name),\n { depth: 2 },\n )\n}\n"],
|
|
5
|
+
"mappings": "AAEA,SAAS,sBAAsB;AAC/B,SAAS,yBAAyB;AAU3B,MAAM,YAAY,CAAC,OAA8B,YAAyC;AAC/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O;AAAA,IACd,SAAS,MAAM,OAAO,CAAC,QAAQ,IAAI,SAAS,QAAQ,IAAI;AAAA,IACxD,EAAE,OAAO,EAAE;AAAA,EACb;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { TraversedDocument, TraversedOperation, TraversedWebhook, WithParent } from '../../schemas/navigation.js';
|
|
2
|
-
type
|
|
2
|
+
export type OperationEntriesMap = Map<string, (WithParent<TraversedOperation> | WithParent<TraversedWebhook>)[]>;
|
|
3
3
|
/**
|
|
4
4
|
* Builds a map of all operations and webhooks in a document, indexed by path/name and method.
|
|
5
5
|
*
|
|
@@ -7,8 +7,9 @@ type EntriesMap = Map<string, (WithParent<TraversedOperation> | WithParent<Trave
|
|
|
7
7
|
* entries. Multiple entries can share the same path|method key (for example, when operations are
|
|
8
8
|
* duplicated across different tags or groups).
|
|
9
9
|
*
|
|
10
|
-
* Performance note: If this function is called frequently, consider generating this map once when
|
|
11
|
-
* creating the sidebar state rather than recalculating it in mutators
|
|
10
|
+
* ~Performance note: If this function is called frequently, consider generating this map once when
|
|
11
|
+
* creating the sidebar state rather than recalculating it in mutators.~
|
|
12
|
+
* Update: we are now generating it features/operation and its drilled down from there
|
|
12
13
|
*
|
|
13
14
|
* @param document - The traversed OpenAPI document to extract operations from
|
|
14
15
|
* @returns A map where keys are `path|method` (for operations) or `name|method` (for webhooks),
|
|
@@ -19,6 +20,5 @@ type EntriesMap = Map<string, (WithParent<TraversedOperation> | WithParent<Trave
|
|
|
19
20
|
* const entries = getOperationEntries(document)
|
|
20
21
|
* const getUsers = entries.get('/users|get') // Array of all GET /users operations
|
|
21
22
|
*/
|
|
22
|
-
export declare const getOperationEntries: (document: TraversedDocument) =>
|
|
23
|
-
export {};
|
|
23
|
+
export declare const getOperationEntries: (document: TraversedDocument) => OperationEntriesMap;
|
|
24
24
|
//# sourceMappingURL=get-operation-entries.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-operation-entries.d.ts","sourceRoot":"","sources":["../../../src/navigation/helpers/get-operation-entries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EAEjB,kBAAkB,EAClB,gBAAgB,EAChB,UAAU,EACX,MAAM,sBAAsB,CAAA;AAE7B,
|
|
1
|
+
{"version":3,"file":"get-operation-entries.d.ts","sourceRoot":"","sources":["../../../src/navigation/helpers/get-operation-entries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EAEjB,kBAAkB,EAClB,gBAAgB,EAChB,UAAU,EACX,MAAM,sBAAsB,CAAA;AAE7B,MAAM,MAAM,mBAAmB,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,UAAU,CAAC,kBAAkB,CAAC,GAAG,UAAU,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAA;AAEhH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,mBAAmB,GAAI,UAAU,iBAAiB,KAAG,mBA2DjE,CAAA"}
|