@scalar/workspace-store 0.25.3 → 0.26.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/client.d.ts.map +1 -1
  3. package/dist/client.js +25 -19
  4. package/dist/client.js.map +2 -2
  5. package/dist/events/definitions/hooks.d.ts +13 -2
  6. package/dist/events/definitions/hooks.d.ts.map +1 -1
  7. package/dist/events/definitions/operation.d.ts +22 -8
  8. package/dist/events/definitions/operation.d.ts.map +1 -1
  9. package/dist/events/definitions/ui.d.ts +12 -0
  10. package/dist/events/definitions/ui.d.ts.map +1 -1
  11. package/dist/helpers/apply-selective-updates.d.ts +1 -1
  12. package/dist/helpers/apply-selective-updates.d.ts.map +1 -1
  13. package/dist/helpers/apply-selective-updates.js +13 -3
  14. package/dist/helpers/apply-selective-updates.js.map +3 -3
  15. package/dist/mutators/fetch-request-to-har.d.ts +62 -0
  16. package/dist/mutators/fetch-request-to-har.d.ts.map +1 -0
  17. package/dist/mutators/fetch-request-to-har.js +117 -0
  18. package/dist/mutators/fetch-request-to-har.js.map +7 -0
  19. package/dist/mutators/fetch-response-to-har.d.ts +67 -0
  20. package/dist/mutators/fetch-response-to-har.d.ts.map +1 -0
  21. package/dist/mutators/fetch-response-to-har.js +104 -0
  22. package/dist/mutators/fetch-response-to-har.js.map +7 -0
  23. package/dist/mutators/har-to-operation.d.ts +37 -0
  24. package/dist/mutators/har-to-operation.d.ts.map +1 -0
  25. package/dist/mutators/har-to-operation.js +146 -0
  26. package/dist/mutators/har-to-operation.js.map +7 -0
  27. package/dist/mutators/index.d.ts +4 -0
  28. package/dist/mutators/index.d.ts.map +1 -1
  29. package/dist/mutators/operation.d.ts +9 -7
  30. package/dist/mutators/operation.d.ts.map +1 -1
  31. package/dist/mutators/operation.js +117 -46
  32. package/dist/mutators/operation.js.map +2 -2
  33. package/dist/schemas/extensions/document/x-scalar-is-dirty.d.ts +43 -0
  34. package/dist/schemas/extensions/document/x-scalar-is-dirty.d.ts.map +1 -0
  35. package/dist/schemas/extensions/document/x-scalar-is-dirty.js +9 -0
  36. package/dist/schemas/extensions/document/x-scalar-is-dirty.js.map +7 -0
  37. package/dist/schemas/extensions/operation/x-scalar-history.d.ts +217 -0
  38. package/dist/schemas/extensions/operation/x-scalar-history.d.ts.map +1 -0
  39. package/dist/schemas/extensions/operation/x-scalar-history.js +100 -0
  40. package/dist/schemas/extensions/operation/x-scalar-history.js.map +7 -0
  41. package/dist/schemas/inmemory-workspace.d.ts +64 -0
  42. package/dist/schemas/inmemory-workspace.d.ts.map +1 -1
  43. package/dist/schemas/reference-config/index.d.ts +64 -0
  44. package/dist/schemas/reference-config/index.d.ts.map +1 -1
  45. package/dist/schemas/reference-config/settings.d.ts +64 -0
  46. package/dist/schemas/reference-config/settings.d.ts.map +1 -1
  47. package/dist/schemas/v3.1/strict/openapi-document.d.ts +2306 -1
  48. package/dist/schemas/v3.1/strict/openapi-document.d.ts.map +1 -1
  49. package/dist/schemas/v3.1/strict/openapi-document.js +3 -1
  50. package/dist/schemas/v3.1/strict/openapi-document.js.map +2 -2
  51. package/dist/schemas/v3.1/strict/operation.d.ts +64 -1
  52. package/dist/schemas/v3.1/strict/operation.d.ts.map +1 -1
  53. package/dist/schemas/v3.1/strict/operation.js +3 -1
  54. package/dist/schemas/v3.1/strict/operation.js.map +2 -2
  55. package/dist/schemas/workspace.d.ts +448 -0
  56. package/dist/schemas/workspace.d.ts.map +1 -1
  57. package/package.json +5 -5
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/mutators/har-to-operation.ts"],
4
+ "sourcesContent": ["import type { HarRequest } from '@scalar/snippetz'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport type { OperationObject, ParameterObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\nimport type { ReferenceType } from '@scalar/workspace-store/schemas/v3.1/strict/reference'\n\nimport { isContentTypeParameterObject } from '@/schemas/v3.1/strict/type-guards'\n\ntype HarToOperationProps = {\n /** HAR request to convert */\n harRequest: HarRequest\n /** Name of the example to populate (e.g., 'default', 'example1') */\n exampleKey: string\n /** Optional base operation to merge with */\n baseOperation?: OperationObject\n /** Optional path variables to merge with */\n pathVariables?: Record<string, string>\n}\n\nconst preprocessParameters = (\n parameters: ReferenceType<ParameterObject>[],\n pathVariables: Record<string, string>,\n exampleKey: string,\n) => {\n parameters.forEach((param) => {\n const resolvedParam = getResolvedRef(param)\n if (isContentTypeParameterObject(resolvedParam)) {\n return\n }\n\n setParameterDisabled(getResolvedRef(param), exampleKey, true)\n\n if (resolvedParam.in === 'path') {\n resolvedParam.examples ||= {}\n resolvedParam.examples[exampleKey] = {\n value: pathVariables[resolvedParam.name] ?? '',\n 'x-disabled': false,\n }\n }\n })\n}\n\n/**\n * Converts a HAR request back to an OpenAPI Operation object with populated examples.\n *\n * This function is the reverse of operationToHar - it takes a HAR request and\n * converts it back into an OpenAPI operation structure, populating the example\n * values based on the HAR request data.\n *\n * The conversion handles:\n * - URL parsing to extract path and query parameters\n * - Header extraction and mapping to operation parameters\n * - Query string parsing and mapping to parameters\n * - Cookie extraction and mapping to cookie parameters\n * - Request body extraction and mapping to requestBody with examples\n * - Content-Type detection and media type assignment\n *\n * Note: This function focuses on populating examples and does not reconstruct\n * schema definitions. If you need full schema generation, consider combining\n * this with a schema inference tool.\n *\n * @see https://w3c.github.io/web-performance/specs/HAR/Overview.html\n * @see https://spec.openapis.org/oas/v3.1.0#operation-object\n */\nexport const harToOperation = ({\n harRequest,\n exampleKey,\n baseOperation = {},\n pathVariables = {},\n}: HarToOperationProps): OperationObject => {\n // Ensure parameters array exists on the base operation\n if (!baseOperation.parameters) {\n baseOperation.parameters = []\n }\n\n // Set any other parameters as disabled and set the path variables\n preprocessParameters(baseOperation.parameters, pathVariables, exampleKey)\n\n // Process query string parameters from the HAR request\n if (harRequest.queryString && harRequest.queryString.length > 0) {\n for (const queryParam of harRequest.queryString) {\n const param = findOrCreateParameter(baseOperation.parameters, queryParam.name, 'query')\n\n if (!param || isContentTypeParameterObject(param)) {\n continue\n }\n\n param.examples ||= {}\n param.examples[exampleKey] = {\n value: queryParam.value,\n 'x-disabled': false,\n }\n }\n }\n\n // Process headers from the HAR request\n if (harRequest.headers && harRequest.headers.length > 0) {\n for (const header of harRequest.headers) {\n const param = findOrCreateParameter(baseOperation.parameters, header.name, 'header')\n\n if (!param || isContentTypeParameterObject(param)) {\n continue\n }\n\n param.examples ||= {}\n param.examples[exampleKey] = {\n value: header.value,\n 'x-disabled': false,\n }\n }\n }\n\n // Process cookies from the HAR request\n if (harRequest.cookies && harRequest.cookies.length > 0) {\n for (const cookie of harRequest.cookies) {\n const param = findOrCreateParameter(baseOperation.parameters, cookie.name, 'cookie')\n\n if (!param || isContentTypeParameterObject(param)) {\n continue\n }\n\n param.examples ||= {}\n param.examples[exampleKey] = {\n value: cookie.value,\n 'x-disabled': false,\n }\n }\n }\n\n // Process request body from the HAR request\n if (harRequest.postData) {\n const { mimeType, text, params } = harRequest.postData\n\n // Ensure requestBody exists on the base operation\n if (!baseOperation.requestBody) {\n baseOperation.requestBody = {\n content: {},\n }\n }\n\n // Resolve the request body in case it is a reference\n const requestBody = getResolvedRef(baseOperation.requestBody)\n\n // Ensure the content type exists in the requestBody\n if (!requestBody.content[mimeType]) {\n requestBody.content[mimeType] = {\n schema: {\n type: 'object',\n },\n }\n }\n\n // Get the media type object\n const mediaType = requestBody.content[mimeType]\n if (!mediaType) {\n return baseOperation\n }\n\n // Ensure examples object exists\n mediaType.examples ||= {}\n\n // Convert the HAR postData to an example value\n let exampleValue: any\n\n // If params exist (form data), convert to array\n if (params && params.length > 0) {\n exampleValue = []\n for (const param of params) {\n exampleValue.push({\n name: param.name,\n value: param.value,\n 'x-disabled': false,\n })\n }\n } else {\n exampleValue = text\n }\n\n // Add the example to the media type\n mediaType.examples[exampleKey] = {\n value: exampleValue,\n 'x-disabled': false,\n }\n\n // Update the selected media type\n requestBody['x-scalar-selected-content-type'] ||= {}\n requestBody['x-scalar-selected-content-type'][exampleKey] = mimeType\n }\n\n return baseOperation\n}\n\nconst setParameterDisabled = (param: ParameterObject, exampleKey: string, disabled: boolean): void => {\n if (isContentTypeParameterObject(param)) {\n return\n }\n\n if (!param.examples?.[exampleKey]) {\n return\n }\n\n getResolvedRef(param.examples[exampleKey])['x-disabled'] = disabled\n}\n\n/**\n * Finds an existing parameter in the parameters array or creates a new one.\n * This ensures we do not create duplicate parameters.\n */\nconst findOrCreateParameter = (\n parameters: ReferenceType<ParameterObject>[],\n name: string,\n inValue: 'query' | 'header' | 'path' | 'cookie',\n): ParameterObject => {\n // Try to find existing parameter using getResolvedRef to handle references\n for (const param of parameters) {\n const resolved = getResolvedRef(param)\n if (isContentTypeParameterObject(resolved)) {\n continue\n }\n\n // Check if parameter location matches\n if (resolved.in !== inValue) {\n continue\n }\n\n // For headers, use case-insensitive comparison; otherwise use exact match\n const namesMatch =\n inValue === 'header' ? resolved.name.toLowerCase() === name.toLowerCase() : resolved.name === name\n\n if (namesMatch) {\n return resolved\n }\n }\n\n // Create new parameter with schema\n const newParam: ParameterObject = {\n name,\n in: inValue,\n schema: {\n type: 'string',\n },\n }\n\n parameters.push(newParam)\n return newParam\n}\n"],
5
+ "mappings": "AACA,SAAS,sBAAsB;AAI/B,SAAS,oCAAoC;AAa7C,MAAM,uBAAuB,CAC3B,YACA,eACA,eACG;AACH,aAAW,QAAQ,CAAC,UAAU;AAC5B,UAAM,gBAAgB,eAAe,KAAK;AAC1C,QAAI,6BAA6B,aAAa,GAAG;AAC/C;AAAA,IACF;AAEA,yBAAqB,eAAe,KAAK,GAAG,YAAY,IAAI;AAE5D,QAAI,cAAc,OAAO,QAAQ;AAC/B,oBAAc,aAAa,CAAC;AAC5B,oBAAc,SAAS,UAAU,IAAI;AAAA,QACnC,OAAO,cAAc,cAAc,IAAI,KAAK;AAAA,QAC5C,cAAc;AAAA,MA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,eAAe,KAAK;AACrC,QAAI,6BAA6B,QAAQ,GAAG;AAC1C;AAAA,IACF;AAGA,QAAI,SAAS,OAAO,SAAS;AAC3B;AAAA,IACF;AAGA,UAAM,aACJ,YAAY,WAAW,SAAS,KAAK,YAAY,MAAM,KAAK,YAAY,IAAI,SAAS,SAAS;AAEhG,QAAI,YAAY;AACd,aAAO;AAAA,IACT;AAAA,EACF;AAGA,QAAM,WAA4B;AAAA,IAChC;AAAA,IACA,IAAI;AAAA,IACJ,QAAQ;AAAA,MACN,MAAM;AAAA,IACR;AAAA,EACF;AAEA,aAAW,KAAK,QAAQ;AACxB,SAAO;AACT;",
6
+ "names": []
7
+ }
@@ -104,6 +104,8 @@ export declare function generateClientMutators(store: WorkspaceStore | null): {
104
104
  updateOperationRequestBodyContentType: (payload: import("../events/definitions/operation.js").OperationEvents["operation:update:requestBody:contentType"]) => void;
105
105
  updateOperationRequestBodyExample: (payload: import("../events/definitions/operation.js").OperationEvents["operation:update:requestBody:value"]) => void;
106
106
  updateOperationRequestBodyFormValue: (payload: import("../events/definitions/operation.js").OperationEvents["operation:update:requestBody:formValue"]) => void;
107
+ addResponseToHistory: (payload: import("../events/definitions/hooks.js").HooksEvents["hooks:on:request:complete"]) => Promise<void>;
108
+ reloadOperationHistory: (payload: import("../events/definitions/operation.js").OperationEvents["operation:reload:history"]) => void;
107
109
  };
108
110
  server: {
109
111
  addServer: () => import("../schemas/v3.1/strict/server.js").ServerObject | undefined;
@@ -185,6 +187,8 @@ export declare function generateClientMutators(store: WorkspaceStore | null): {
185
187
  updateOperationRequestBodyContentType: (payload: import("../events/definitions/operation.js").OperationEvents["operation:update:requestBody:contentType"]) => void;
186
188
  updateOperationRequestBodyExample: (payload: import("../events/definitions/operation.js").OperationEvents["operation:update:requestBody:value"]) => void;
187
189
  updateOperationRequestBodyFormValue: (payload: import("../events/definitions/operation.js").OperationEvents["operation:update:requestBody:formValue"]) => void;
190
+ addResponseToHistory: (payload: import("../events/definitions/hooks.js").HooksEvents["hooks:on:request:complete"]) => Promise<void>;
191
+ reloadOperationHistory: (payload: import("../events/definitions/operation.js").OperationEvents["operation:reload:history"]) => void;
188
192
  };
189
193
  server: {
190
194
  addServer: () => import("../schemas/v3.1/strict/server.js").ServerObject | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mutators/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAa9C;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI;IAqC/D;;OAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAEH;;;OAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAEH;;;;OAIG;gBACS,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAErB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mutators/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAa9C;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI;IAqC/D;;OAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAEH;;;OAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAEH;;;;OAIG;gBACS,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAErB"}
@@ -1,4 +1,5 @@
1
1
  import type { WorkspaceStore } from '../client.js';
2
+ import type { HooksEvents } from '../events/definitions/hooks.js';
2
3
  import type { OperationEvents } from '../events/definitions/operation.js';
3
4
  import type { WorkspaceDocument } from '../schemas.js';
4
5
  /**
@@ -93,7 +94,7 @@ export declare const deleteOperationExample: (workspace: WorkspaceStore | null,
93
94
  * })
94
95
  * ```
95
96
  */
96
- export declare const upsertOperationParameter: (document: WorkspaceDocument | null, { meta, type, payload, index }: OperationEvents["operation:upsert:parameter"]) => void;
97
+ export declare const upsertOperationParameter: (document: WorkspaceDocument | null, { meta, type, payload, originalParameter }: OperationEvents["operation:upsert:parameter"]) => void;
97
98
  /**
98
99
  * Updates the disabled state of a default parameter for an operation.
99
100
  * Default parameters are inherited from higher-level configurations (like collection or server defaults)
@@ -112,21 +113,18 @@ export declare const upsertOperationParameter: (document: WorkspaceDocument | nu
112
113
  */
113
114
  export declare const updateOperationExtraParameters: (document: WorkspaceDocument | null, { type, meta, payload, in: location }: OperationEvents["operation:update:extra-parameters"]) => void;
114
115
  /**
115
- * Removes a parameter from the operation by resolving its position within
116
- * the filtered list of parameters of the specified `type`.
117
- * Safely no-ops if the document, operation, or parameter does not exist.
116
+ * Removes a parameter from the operation OR path
118
117
  *
119
118
  * Example:
120
119
  * ```ts
121
120
  * deleteOperationParameter({
122
121
  * document,
123
- * type: 'header',
124
- * index: 1,
122
+ * originalParameter,
125
123
  * meta: { method: 'get', path: '/users', exampleKey: 'default' },
126
124
  * })
127
125
  * ```
128
126
  */
129
- export declare const deleteOperationParameter: (document: WorkspaceDocument | null, { meta, index, type }: OperationEvents["operation:delete:parameter"]) => void;
127
+ export declare const deleteOperationParameter: (document: WorkspaceDocument | null, { meta, originalParameter }: OperationEvents["operation:delete:parameter"]) => void;
130
128
  /**
131
129
  * Deletes all parameters of a given `type` from the operation.
132
130
  * Safely no-ops if the document or operation does not exist.
@@ -181,6 +179,8 @@ export declare const updateOperationRequestBodyExample: (document: WorkspaceDocu
181
179
  * This needs special handling as we store it as an array of objects with a schema type of object
182
180
  */
183
181
  export declare const updateOperationRequestBodyFormValue: (document: WorkspaceDocument | null, { meta, payload, contentType }: OperationEvents["operation:update:requestBody:formValue"]) => void;
182
+ export declare const addResponseToHistory: (document: WorkspaceDocument | null, { payload, meta }: HooksEvents["hooks:on:request:complete"]) => Promise<void>;
183
+ export declare const reloadOperationHistory: (document: WorkspaceDocument | null, { meta, index, callback }: OperationEvents["operation:reload:history"]) => void;
184
184
  export declare const operationMutatorsFactory: ({ document, store, }: {
185
185
  document: WorkspaceDocument | null;
186
186
  store: WorkspaceStore | null;
@@ -197,5 +197,7 @@ export declare const operationMutatorsFactory: ({ document, store, }: {
197
197
  updateOperationRequestBodyContentType: (payload: OperationEvents["operation:update:requestBody:contentType"]) => void;
198
198
  updateOperationRequestBodyExample: (payload: OperationEvents["operation:update:requestBody:value"]) => void;
199
199
  updateOperationRequestBodyFormValue: (payload: OperationEvents["operation:update:requestBody:formValue"]) => void;
200
+ addResponseToHistory: (payload: HooksEvents["hooks:on:request:complete"]) => Promise<void>;
201
+ reloadOperationHistory: (payload: OperationEvents["operation:reload:history"]) => void;
200
202
  };
201
203
  //# sourceMappingURL=operation.d.ts.map
@@ -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,CAAA;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAMrE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AA+GlD;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,eAAe,GAC1B,gBAAgB,cAAc,GAAG,IAAI,EACrC,SAAS,eAAe,CAAC,4BAA4B,CAAC,KACrD,MAAM,GAAG,SAkDX,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,sBAAsB,GACjC,UAAU,iBAAiB,GAAG,IAAI,EAClC,gCAAg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F,CAAA"}
@@ -3,6 +3,9 @@ import { preventPollution } from "@scalar/helpers/object/prevent-pollution";
3
3
  import { findVariables } from "@scalar/helpers/regex/find-variables";
4
4
  import { getResolvedRef } from "../helpers/get-resolved-ref.js";
5
5
  import { unpackProxyObject } from "../helpers/unpack-proxy.js";
6
+ import { fetchRequestToHar } from "../mutators/fetch-request-to-har.js";
7
+ import { fetchResponseToHar } from "../mutators/fetch-response-to-har.js";
8
+ import { harToOperation } from "../mutators/har-to-operation.js";
6
9
  import { getOpenapiObject, getOperationEntries } from "../navigation/index.js";
7
10
  import { getNavigationOptions } from "../navigation/get-navigation-options.js";
8
11
  import { canHaveOrder } from "../navigation/helpers/get-openapi-object.js";
@@ -201,6 +204,7 @@ const updateOperationPathMethod = (document, store, { meta, payload: { method, p
201
204
  delete document.paths[meta.path];
202
205
  }
203
206
  }
207
+ delete operation["x-scalar-history"];
204
208
  callback("success");
205
209
  };
206
210
  const deleteOperation = (workspace, { meta, documentName }) => {
@@ -243,42 +247,40 @@ const deleteOperationExample = (workspace, { meta: { path, method, exampleKey },
243
247
  delete mediaType.examples?.[exampleKey];
244
248
  });
245
249
  };
246
- const upsertOperationParameter = (document, { meta, type, payload, index }) => {
247
- if (!document) {
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;
248
263
  return;
249
264
  }
250
- const operation = getResolvedRef(document.paths?.[meta.path]?.[meta.method]);
265
+ const operation = getResolvedRef(document?.paths?.[meta.path]?.[meta.method]);
251
266
  if (!operation) {
267
+ console.error("Operation not found", { meta, document });
252
268
  return;
253
269
  }
254
- const resolvedParameters = operation.parameters?.map((it) => getResolvedRef(it)).filter((it) => it.in === type) ?? [];
255
- const parameter = resolvedParameters[index];
256
- if (!parameter) {
257
- operation.parameters ||= [];
258
- operation.parameters.push({
259
- name: payload.name,
260
- in: type,
261
- required: type === "path" ? true : false,
262
- examples: {
263
- [meta.exampleKey]: {
264
- value: payload.value,
265
- "x-disabled": payload.isDisabled ?? false
266
- }
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
267
280
  }
268
- });
269
- return;
270
- }
271
- parameter.name = payload.name;
272
- if (isContentTypeParameterObject(parameter)) {
273
- return;
274
- }
275
- if (!parameter.examples) {
276
- parameter.examples = {};
277
- }
278
- parameter.examples[meta.exampleKey] ||= {};
279
- const example = getResolvedRef(parameter.examples[meta.exampleKey]);
280
- example.value = payload.value;
281
- example["x-disabled"] = payload.isDisabled;
281
+ }
282
+ });
283
+ return;
282
284
  };
283
285
  const updateOperationExtraParameters = (document, { type, meta, payload, in: location }) => {
284
286
  if (!document) {
@@ -307,24 +309,24 @@ const updateOperationExtraParameters = (document, { type, meta, payload, in: loc
307
309
  [meta.name]: payload.isDisabled ?? false
308
310
  };
309
311
  };
310
- const deleteOperationParameter = (document, { meta, index, type }) => {
311
- if (!document) {
312
- return;
313
- }
314
- const operation = getResolvedRef(document.paths?.[meta.path]?.[meta.method]);
315
- if (!operation) {
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
+ );
316
320
  return;
317
321
  }
318
- const resolvedParameters = operation.parameters?.map((it) => getResolvedRef(it)).filter((it) => it.in === type) ?? [];
319
- const parameter = resolvedParameters[index];
320
- if (!parameter) {
321
- return;
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
+ );
322
329
  }
323
- const actualIndex = operation.parameters?.findIndex((it) => getResolvedRef(it) === parameter);
324
- operation.parameters = unpackProxyObject(
325
- operation.parameters?.filter((_, i) => i !== actualIndex),
326
- { depth: 1 }
327
- );
328
330
  };
329
331
  const deleteAllOperationParameters = (document, { meta, type }) => {
330
332
  if (!document) {
@@ -390,6 +392,71 @@ const updateOperationRequestBodyFormValue = (document, { meta, payload, contentT
390
392
  }
391
393
  example.value = unpackProxyObject(payload, { depth: 3 });
392
394
  };
395
+ const HISTORY_LIMIT = 5;
396
+ const addResponseToHistory = async (document, { payload, meta }) => {
397
+ if (!document || !payload) {
398
+ return;
399
+ }
400
+ const operation = getResolvedRef(document.paths?.[meta.path]?.[meta.method]);
401
+ if (!operation) {
402
+ return;
403
+ }
404
+ const operationParameters = operation.parameters ?? [];
405
+ const variables = operationParameters.reduce((acc, param) => {
406
+ const resolvedParam = getResolvedRef(param);
407
+ if (isContentTypeParameterObject(resolvedParam)) {
408
+ return acc;
409
+ }
410
+ if (resolvedParam.in === "path") {
411
+ acc[resolvedParam.name] = getResolvedRef(resolvedParam.examples?.[meta.exampleKey])?.value ?? "";
412
+ }
413
+ return acc;
414
+ }, {});
415
+ const requestHar = await fetchRequestToHar({ request: payload.request });
416
+ const responseHar = await fetchResponseToHar({ response: payload.response });
417
+ operation["x-scalar-history"] ||= [];
418
+ if (operation["x-scalar-history"].length >= HISTORY_LIMIT) {
419
+ operation["x-scalar-history"] = unpackProxyObject(
420
+ operation["x-scalar-history"].filter((_, i) => i !== 0),
421
+ { depth: 1 }
422
+ );
423
+ }
424
+ operation["x-scalar-history"].push({
425
+ response: responseHar,
426
+ request: requestHar,
427
+ meta: {
428
+ example: meta.exampleKey
429
+ },
430
+ time: payload.duration,
431
+ timestamp: payload.timestamp,
432
+ requestMetadata: {
433
+ variables
434
+ }
435
+ });
436
+ };
437
+ const reloadOperationHistory = (document, { meta, index, callback }) => {
438
+ if (!document) {
439
+ console.error("Document not found", meta.path, meta.method);
440
+ return;
441
+ }
442
+ const operation = getResolvedRef(document.paths?.[meta.path]?.[meta.method]);
443
+ if (!operation) {
444
+ console.error("Operation not found", meta.path, meta.method);
445
+ return;
446
+ }
447
+ const historyItem = operation["x-scalar-history"]?.[index];
448
+ if (!historyItem) {
449
+ console.error("History item not found", index);
450
+ return;
451
+ }
452
+ harToOperation({
453
+ harRequest: historyItem.request,
454
+ exampleKey: "draft",
455
+ baseOperation: operation,
456
+ pathVariables: historyItem.requestMetadata.variables
457
+ });
458
+ callback("success");
459
+ };
393
460
  const operationMutatorsFactory = ({
394
461
  document,
395
462
  store
@@ -406,16 +473,20 @@ const operationMutatorsFactory = ({
406
473
  deleteAllOperationParameters: (payload) => deleteAllOperationParameters(document, payload),
407
474
  updateOperationRequestBodyContentType: (payload) => updateOperationRequestBodyContentType(document, payload),
408
475
  updateOperationRequestBodyExample: (payload) => updateOperationRequestBodyExample(document, payload),
409
- updateOperationRequestBodyFormValue: (payload) => updateOperationRequestBodyFormValue(document, payload)
476
+ updateOperationRequestBodyFormValue: (payload) => updateOperationRequestBodyFormValue(document, payload),
477
+ addResponseToHistory: (payload) => addResponseToHistory(document, payload),
478
+ reloadOperationHistory: (payload) => reloadOperationHistory(document, payload)
410
479
  };
411
480
  };
412
481
  export {
482
+ addResponseToHistory,
413
483
  createOperation,
414
484
  deleteAllOperationParameters,
415
485
  deleteOperation,
416
486
  deleteOperationExample,
417
487
  deleteOperationParameter,
418
488
  operationMutatorsFactory,
489
+ reloadOperationHistory,
419
490
  updateOperationExtraParameters,
420
491
  updateOperationPathMethod,
421
492
  updateOperationRequestBodyContentType,
@@ -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, 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 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\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 }\n}\n"],
5
- "mappings": "AACA,SAAS,oBAAoB;AAC7B,SAAS,wBAAwB;AACjC,SAAS,qBAAqB;AAI9B,SAAS,sBAAsB;AAC/B,SAAS,yBAAyB;AAClC,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;AACjE,QAAM,eAAe,sBAAsB,SAAS,aAAa;AAGjE,QAAM,iBAAoC,CAAC;AAC3C,QAAM,oBAAsD,CAAC;AAE7D,aAAW,SAAS,oBAAoB;AACtC,UAAM,WAAW,eAAe,KAAK;AACrC,QAAI,UAAU,OAAO,QAAQ;AAC3B,qBAAe,KAAK,QAAQ;AAAA,IAC9B,OAAO;AACL,wBAAkB,KAAK,KAAK;AAAA,IAC9B;AAAA,EACF;AAGA,QAAM,2BAA2B,oBAAI,IAA6B;AAClE,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AAS;AACZ,YAAQ,MAAM,qBAAqB,KAAK,UAAU;AAClD;AAAA,EACF;AAEA,UAAQ,QAAQ;AAClB;AAOO,MAAM,sCAAsC,CACjD,UACA,EAAE,MAAM,SAAS,YAAY,MAC1B;AACH,QAAM,UAAU,+BAA+B,UAAU,aAAa,IAAI;AAC1E,MAAI,CAAC,SAAS;AACZ,YAAQ,MAAM,qBAAqB,KAAK,UAAU;AAClD;AAAA,EACF;AAEA,UAAQ,QAAQ,kBAAkB,SAAS,EAAE,OAAO,EAAE,CAAC;AACzD;AAEO,MAAM,2BAA2B,CAAC;AAAA,EACvC;AAAA,EACA;AACF,MAGM;AACJ,SAAO;AAAA,IACL,iBAAiB,CAAC,YAA2D,gBAAgB,OAAO,OAAO;AAAA,IAC3G,wBAAwB,CAAC,YACvB,uBAAuB,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,EACzD;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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ACzB,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
  }
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Schema for the "x-scalar-is-dirty" OpenAPI extension.
3
+ * This extension allows specifying an optional boolean value,
4
+ * which can be used to track if the document state is dirty.
5
+ *
6
+ * This is used to track if the document has been modified since it was last saved.
7
+ *
8
+ * @example
9
+ * ```yaml
10
+ * x-scalar-is-dirty: true
11
+ * ```
12
+ *
13
+ * @example
14
+ * ```yaml
15
+ * x-scalar-is-dirty: false
16
+ * ```
17
+ */
18
+ export declare const XScalarIsDirtySchema: import("@scalar/typebox").TObject<{
19
+ /** Whether the document state is dirty, this is used to track if the document has been modified since it was last saved */
20
+ 'x-scalar-is-dirty': import("@scalar/typebox").TOptional<import("@scalar/typebox").TBoolean>;
21
+ }>;
22
+ /**
23
+ * Schema for the "x-scalar-is-dirty" OpenAPI extension.
24
+ * This extension allows specifying an optional boolean value,
25
+ * which can be used to track if the document state is dirty.
26
+ *
27
+ * This is used to track if the document has been modified since it was last saved.
28
+ *
29
+ * @example
30
+ * ```yaml
31
+ * x-scalar-is-dirty: true
32
+ * ```
33
+ *
34
+ * @example
35
+ * ```yaml
36
+ * x-scalar-is-dirty: false
37
+ * ```
38
+ */
39
+ export type XScalarIsDirty = {
40
+ /** Whether the document state is dirty, this is used to track if the document has been modified since it was last saved */
41
+ 'x-scalar-is-dirty'?: boolean;
42
+ };
43
+ //# sourceMappingURL=x-scalar-is-dirty.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"x-scalar-is-dirty.d.ts","sourceRoot":"","sources":["../../../../src/schemas/extensions/document/x-scalar-is-dirty.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,oBAAoB;IAC/B,2HAA2H;;EAE3H,CAAA;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,2HAA2H;IAC3H,mBAAmB,CAAC,EAAE,OAAO,CAAA;CAC9B,CAAA"}
@@ -0,0 +1,9 @@
1
+ import { Type } from "@scalar/typebox";
2
+ const XScalarIsDirtySchema = Type.Object({
3
+ /** Whether the document state is dirty, this is used to track if the document has been modified since it was last saved */
4
+ "x-scalar-is-dirty": Type.Optional(Type.Boolean())
5
+ });
6
+ export {
7
+ XScalarIsDirtySchema
8
+ };
9
+ //# sourceMappingURL=x-scalar-is-dirty.js.map