@scalar/workspace-store 0.32.1 → 0.34.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/CHANGELOG.md +89 -0
  2. package/dist/client.js +1 -1
  3. package/dist/client.js.map +2 -2
  4. package/dist/entities/auth/schema.d.ts +10 -0
  5. package/dist/entities/auth/schema.d.ts.map +1 -1
  6. package/dist/events/definitions/operation.d.ts +14 -0
  7. package/dist/events/definitions/operation.d.ts.map +1 -1
  8. package/dist/events/definitions/tag.d.ts +12 -6
  9. package/dist/events/definitions/tag.d.ts.map +1 -1
  10. package/dist/events/definitions/ui.d.ts +21 -8
  11. package/dist/events/definitions/ui.d.ts.map +1 -1
  12. package/dist/events/definitions/workspace.d.ts +4 -0
  13. package/dist/events/definitions/workspace.d.ts.map +1 -1
  14. package/dist/mutators/index.d.ts +4 -0
  15. package/dist/mutators/index.d.ts.map +1 -1
  16. package/dist/mutators/operation/index.d.ts +1 -0
  17. package/dist/mutators/operation/index.d.ts.map +1 -1
  18. package/dist/mutators/operation/index.js +3 -1
  19. package/dist/mutators/operation/index.js.map +2 -2
  20. package/dist/mutators/operation/operation.d.ts +9 -1
  21. package/dist/mutators/operation/operation.d.ts.map +1 -1
  22. package/dist/mutators/operation/operation.js +31 -36
  23. package/dist/mutators/operation/operation.js.map +2 -2
  24. package/dist/mutators/operation/parameters.d.ts.map +1 -1
  25. package/dist/mutators/operation/parameters.js +7 -8
  26. package/dist/mutators/operation/parameters.js.map +2 -2
  27. package/dist/mutators/server.d.ts.map +1 -1
  28. package/dist/mutators/server.js +5 -1
  29. package/dist/mutators/server.js.map +2 -2
  30. package/dist/mutators/tag.d.ts +8 -0
  31. package/dist/mutators/tag.d.ts.map +1 -1
  32. package/dist/mutators/tag.js +55 -12
  33. package/dist/mutators/tag.js.map +2 -2
  34. package/dist/mutators/workspace.js +1 -1
  35. package/dist/mutators/workspace.js.map +2 -2
  36. package/dist/navigation/helpers/get-tag-entries.d.ts +22 -0
  37. package/dist/navigation/helpers/get-tag-entries.d.ts.map +1 -0
  38. package/dist/navigation/helpers/get-tag-entries.js +30 -0
  39. package/dist/navigation/helpers/get-tag-entries.js.map +7 -0
  40. package/dist/navigation/helpers/traverse-examples.d.ts.map +1 -1
  41. package/dist/navigation/helpers/traverse-examples.js +1 -1
  42. package/dist/navigation/helpers/traverse-examples.js.map +2 -2
  43. package/dist/navigation/helpers/update-order-ids.d.ts +29 -0
  44. package/dist/navigation/helpers/update-order-ids.d.ts.map +1 -0
  45. package/dist/navigation/helpers/update-order-ids.js +54 -0
  46. package/dist/navigation/helpers/update-order-ids.js.map +7 -0
  47. package/dist/navigation/index.d.ts +1 -0
  48. package/dist/navigation/index.d.ts.map +1 -1
  49. package/dist/navigation/index.js +3 -1
  50. package/dist/navigation/index.js.map +2 -2
  51. package/dist/persistence/index.d.ts +16 -0
  52. package/dist/persistence/index.d.ts.map +1 -1
  53. package/dist/persistence/index.js +17 -1
  54. package/dist/persistence/index.js.map +2 -2
  55. package/dist/persistence/indexdb.d.ts.map +1 -1
  56. package/dist/persistence/indexdb.js +1 -2
  57. package/dist/persistence/indexdb.js.map +2 -2
  58. package/dist/schemas/extensions/operation/x-draft-examples.d.ts +7 -0
  59. package/dist/schemas/extensions/operation/x-draft-examples.d.ts.map +1 -0
  60. package/dist/schemas/extensions/operation/x-draft-examples.js +8 -0
  61. package/dist/schemas/extensions/operation/x-draft-examples.js.map +7 -0
  62. package/dist/schemas/extensions/tag/index.d.ts +2 -0
  63. package/dist/schemas/extensions/tag/index.d.ts.map +1 -0
  64. package/dist/schemas/extensions/tag/index.js +1 -0
  65. package/dist/schemas/extensions/tag/index.js.map +7 -0
  66. package/dist/schemas/extensions/tag/x-tag-groups.d.ts +1 -2
  67. package/dist/schemas/extensions/tag/x-tag-groups.d.ts.map +1 -1
  68. package/dist/schemas/extensions/tag/x-tag-groups.js.map +1 -1
  69. package/dist/schemas/extensions/workspace/x-scalar-active-proxy.d.ts +2 -2
  70. package/dist/schemas/extensions/workspace/x-scalar-active-proxy.d.ts.map +1 -1
  71. package/dist/schemas/extensions/workspace/x-scalar-active-proxy.js +1 -1
  72. package/dist/schemas/extensions/workspace/x-scalar-active-proxy.js.map +2 -2
  73. package/dist/schemas/inmemory-workspace.d.ts +42 -5
  74. package/dist/schemas/inmemory-workspace.d.ts.map +1 -1
  75. package/dist/schemas/inmemory-workspace.js +3 -1
  76. package/dist/schemas/inmemory-workspace.js.map +2 -2
  77. package/dist/schemas/reference-config/index.d.ts +2 -0
  78. package/dist/schemas/reference-config/index.d.ts.map +1 -1
  79. package/dist/schemas/reference-config/settings.d.ts +2 -0
  80. package/dist/schemas/reference-config/settings.d.ts.map +1 -1
  81. package/dist/schemas/v3.1/strict/openapi-document.d.ts +70 -0
  82. package/dist/schemas/v3.1/strict/openapi-document.d.ts.map +1 -1
  83. package/dist/schemas/v3.1/strict/operation.d.ts +4 -1
  84. package/dist/schemas/v3.1/strict/operation.d.ts.map +1 -1
  85. package/dist/schemas/v3.1/strict/operation.js +3 -1
  86. package/dist/schemas/v3.1/strict/operation.js.map +2 -2
  87. package/dist/schemas/workspace-specification/index.d.ts +1 -1
  88. package/dist/schemas/workspace.d.ts +62 -5646
  89. package/dist/schemas/workspace.d.ts.map +1 -1
  90. package/dist/schemas/workspace.js +4 -16
  91. package/dist/schemas/workspace.js.map +2 -2
  92. package/dist/server.d.ts +1 -1
  93. package/package.json +11 -6
@@ -1,4 +1,5 @@
1
1
  import type { HttpMethod } from '@scalar/helpers/http/http-methods';
2
+ import type { TraversedTag } from '../../schemas/navigation.js';
2
3
  /**
3
4
  * Available actions that can be triggered from the command palette.
4
5
  * Each action may have an associated payload type.
@@ -7,23 +8,30 @@ export type CommandPalettePayload = {
7
8
  /** Trigger the import flow for OpenAPI, Swagger, Postman, or cURL */
8
9
  'import-from-openapi-swagger-postman-curl': undefined;
9
10
  /** Create a new document in the workspace */
10
- 'create-document': undefined;
11
+ 'create-openapi-document': undefined;
11
12
  /** Add a new tag to organize requests */
12
13
  'add-tag': {
13
- /** The document id to add the tag to */
14
- documentId?: string;
14
+ /** The name of the document to add the tag to */
15
+ documentName?: string;
16
+ };
17
+ /** Edit an existing tag name */
18
+ 'edit-tag': {
19
+ /** The current name of the tag to pre-fill in the input */
20
+ tag: TraversedTag;
21
+ /** The name of the document the tag belongs to */
22
+ documentName: string;
15
23
  };
16
24
  /** Create a new HTTP request */
17
25
  'create-request': {
18
- /** The document id to create the request in */
19
- documentId?: string;
26
+ /** The name of the document to create the request in */
27
+ documentName?: string;
20
28
  /** The tag id to add the request to (optional) */
21
29
  tagId?: string;
22
30
  };
23
31
  /** Add a new example to an existing request */
24
32
  'add-example': {
25
- /** The document id to add the example to */
26
- documentId?: string;
33
+ /** The name of the document to add the example to */
34
+ documentName?: string;
27
35
  /** The operation id to add the example to */
28
36
  operationId?: string;
29
37
  };
@@ -38,7 +46,7 @@ export type CommandPalettePayload = {
38
46
  * This ensures that when an action is dispatched, it must include the correct payload type.
39
47
  *
40
48
  * Example:
41
- * - { action: 'create-document', payload: undefined }
49
+ * - { action: 'create-openapi-document', payload: undefined }
42
50
  * - { action: 'import-curl-command', payload: { curl: 'curl ...' } }
43
51
  */
44
52
  export type CommandPaletteAction<K extends keyof CommandPalettePayload = keyof CommandPalettePayload> = {
@@ -172,8 +180,13 @@ export type UIEvents = {
172
180
  * It can be a document page, a workspace page, or an example page
173
181
  */
174
182
  'ui:navigate': {
183
+ /** If true, the navigation will replace the current route instead of pushing a new one */
184
+ replace?: boolean;
185
+ /** The namespace of the workspace to navigate to */
175
186
  namespace?: string;
187
+ /** The slug of the workspace to navigate to */
176
188
  workspaceSlug?: string;
189
+ /** The callback to call when the navigation is complete */
177
190
  callback?: (status: 'success' | 'error') => void;
178
191
  } & ({
179
192
  page: 'document';
@@ -1 +1 @@
1
- {"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../../../src/events/definitions/ui.ts"],"names":[],"mappings":"AAAA,OAAO,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AG,UAAU,CAAA;QACxF,YAAY,CAAC,EAAE,MAAM,CAAA;KACtB,GACD;QACE,IAAI,EAAE,WAAW,CAAA;QACjB,IAAI,EAAE,aAAa,GAAG,SAAS,GAAG,UAAU,CAAA;KAC7C,GACD;QACE,IAAI,EAAE,SAAS,CAAA;QACf,YAAY,CAAC,EAAE,MAAM,CAAA;QACrB,IAAI,EAAE,MAAM,CAAA;QACZ,MAAM,EAAE,UAAU,CAAA;QAClB,WAAW,EAAE,MAAM,CAAA;KACpB,CACJ,CAAA;CACF,CAAA"}
@@ -22,5 +22,9 @@ export type WorkspaceEvents = {
22
22
  * Update the active environment on the workspace
23
23
  */
24
24
  'workspace:update:active-environment': string | null;
25
+ /**
26
+ * Update the dispaly name of the workspace
27
+ */
28
+ 'workspace:update:name': string;
25
29
  };
26
30
  //# sourceMappingURL=workspace.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../../src/events/definitions/workspace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAE7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAEpD,iDAAiD;AACjD,MAAM,MAAM,eAAe,GAAG;IAC5B;;OAEG;IACH,+BAA+B,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9C;;OAEG;IACH,6BAA6B,EAAE,SAAS,CAAA;IACxC;;OAEG;IACH,wBAAwB,EAAE,MAAM,GAAG,SAAS,CAAA;IAC5C;;OAEG;IACH,kCAAkC,EAAE,eAAe,CAAA;IACnD;;OAEG;IACH,qCAAqC,EAAE,MAAM,GAAG,IAAI,CAAA;CACrD,CAAA"}
1
+ {"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../../src/events/definitions/workspace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAE7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAEpD,iDAAiD;AACjD,MAAM,MAAM,eAAe,GAAG;IAC5B;;OAEG;IACH,+BAA+B,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9C;;OAEG;IACH,6BAA6B,EAAE,SAAS,CAAA;IACxC;;OAEG;IACH,wBAAwB,EAAE,MAAM,GAAG,SAAS,CAAA;IAC5C;;OAEG;IACH,kCAAkC,EAAE,eAAe,CAAA;IACnD;;OAEG;IACH,qCAAqC,EAAE,MAAM,GAAG,IAAI,CAAA;IACpD;;OAEG;IACH,uBAAuB,EAAE,MAAM,CAAA;CAChC,CAAA"}
@@ -94,6 +94,7 @@ export declare function generateClientMutators(store: WorkspaceStore | null): {
94
94
  updateOperationSummary: (payload: import("../events/index.js").OperationEvents["operation:update:summary"]) => void;
95
95
  updateOperationPathMethod: (payload: import("../events/index.js").OperationEvents["operation:update:pathMethod"]) => void;
96
96
  deleteOperation: (payload: import("../events/index.js").OperationEvents["operation:delete:operation"]) => void;
97
+ createOperationDraftExample: (payload: import("../events/index.js").OperationEvents["operation:create:draft-example"]) => void;
97
98
  deleteOperationExample: (payload: import("../events/index.js").OperationEvents["operation:delete:example"]) => void;
98
99
  updateOperationExtension: (payload: import("../events/index.js").OperationEvents["operation:update:extension"]) => void;
99
100
  updateOperationExtraParameters: (payload: import("../events/index.js").OperationEvents["operation:update:extra-parameters"]) => void;
@@ -115,6 +116,7 @@ export declare function generateClientMutators(store: WorkspaceStore | null): {
115
116
  };
116
117
  tag: {
117
118
  createTag: (payload: import("../events/definitions/tag.js").TagEvents["tag:create:tag"]) => void;
119
+ editTag: (payload: import("../events/definitions/tag.js").TagEvents["tag:edit:tag"]) => void;
118
120
  deleteTag: (payload: import("../events/definitions/tag.js").TagEvents["tag:delete:tag"]) => void;
119
121
  };
120
122
  environment: {
@@ -175,6 +177,7 @@ export declare function generateClientMutators(store: WorkspaceStore | null): {
175
177
  updateOperationSummary: (payload: import("../events/index.js").OperationEvents["operation:update:summary"]) => void;
176
178
  updateOperationPathMethod: (payload: import("../events/index.js").OperationEvents["operation:update:pathMethod"]) => void;
177
179
  deleteOperation: (payload: import("../events/index.js").OperationEvents["operation:delete:operation"]) => void;
180
+ createOperationDraftExample: (payload: import("../events/index.js").OperationEvents["operation:create:draft-example"]) => void;
178
181
  deleteOperationExample: (payload: import("../events/index.js").OperationEvents["operation:delete:example"]) => void;
179
182
  updateOperationExtension: (payload: import("../events/index.js").OperationEvents["operation:update:extension"]) => void;
180
183
  updateOperationExtraParameters: (payload: import("../events/index.js").OperationEvents["operation:update:extra-parameters"]) => void;
@@ -196,6 +199,7 @@ export declare function generateClientMutators(store: WorkspaceStore | null): {
196
199
  };
197
200
  tag: {
198
201
  createTag: (payload: import("../events/definitions/tag.js").TagEvents["tag:create:tag"]) => void;
202
+ editTag: (payload: import("../events/definitions/tag.js").TagEvents["tag:edit:tag"]) => void;
199
203
  deleteTag: (payload: import("../events/definitions/tag.js").TagEvents["tag:delete:tag"]) => void;
200
204
  };
201
205
  environment: {
@@ -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"}
@@ -10,6 +10,7 @@ export declare const operationMutatorsFactory: ({ document, store, }: {
10
10
  updateOperationSummary: (payload: OperationEvents["operation:update:summary"]) => void;
11
11
  updateOperationPathMethod: (payload: OperationEvents["operation:update:pathMethod"]) => void;
12
12
  deleteOperation: (payload: OperationEvents["operation:delete:operation"]) => void;
13
+ createOperationDraftExample: (payload: OperationEvents["operation:create:draft-example"]) => void;
13
14
  deleteOperationExample: (payload: OperationEvents["operation:delete:example"]) => void;
14
15
  updateOperationExtension: (payload: OperationEvents["operation:update:extension"]) => void;
15
16
  updateOperationExtraParameters: (payload: OperationEvents["operation:update:extra-parameters"]) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/mutators/operation/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAC7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAqBrE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAElD,eAAO,MAAM,wBAAwB,GAAI,sBAGtC;IACD,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAAA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zC,eAAe,CAAC,4BAA4B,CAAC;8CAEvC,eAAe,CAAC,mCAAmC,CAAC;wCAE1D,eAAe,CAAC,4BAA4B,CAAC;wCAE7C,eAAe,CAAC,4BAA4B,CAAC;4CAEzC,eAAe,CAAC,iCAAiC,CAAC;qDAEzC,eAAe,CAAC,0CAA0C,CAAC;iDAE/D,eAAe,CAAC,oCAAoC,CAAC;mDAEnD,eAAe,CAAC,wCAAwC,CAAC;oCAExE,WAAW,CAAC,2BAA2B,CAAC;sCAEtC,eAAe,CAAC,0BAA0B,CAAC;CAGhF,CAAA"}
@@ -7,6 +7,7 @@ import { updateOperationExtension } from "../../mutators/operation/extensions.js
7
7
  import { addResponseToHistory, reloadOperationHistory } from "../../mutators/operation/history.js";
8
8
  import {
9
9
  createOperation,
10
+ createOperationDraftExample,
10
11
  deleteOperation,
11
12
  deleteOperationExample,
12
13
  updateOperationPathMethod,
@@ -24,9 +25,10 @@ const operationMutatorsFactory = ({
24
25
  }) => {
25
26
  return {
26
27
  createOperation: (payload) => createOperation(store, payload),
27
- updateOperationSummary: (payload) => updateOperationSummary(document, payload),
28
+ updateOperationSummary: (payload) => updateOperationSummary(store, document, payload),
28
29
  updateOperationPathMethod: (payload) => updateOperationPathMethod(document, store, payload),
29
30
  deleteOperation: (payload) => deleteOperation(store, payload),
31
+ createOperationDraftExample: (payload) => createOperationDraftExample(store, payload),
30
32
  deleteOperationExample: (payload) => deleteOperationExample(store, payload),
31
33
  updateOperationExtension: (payload) => updateOperationExtension(document, payload),
32
34
  updateOperationExtraParameters: (payload) => updateOperationExtraParameters(document, payload),
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/mutators/operation/index.ts"],
4
- "sourcesContent": ["import type { WorkspaceStore } from '@/client'\nimport type { HooksEvents } from '@/events/definitions/hooks'\nimport type { OperationEvents } from '@/events/definitions/operation'\nimport {\n updateOperationRequestBodyContentType,\n updateOperationRequestBodyExample,\n updateOperationRequestBodyFormValue,\n} from '@/mutators/operation/body'\nimport { updateOperationExtension } from '@/mutators/operation/extensions'\nimport { addResponseToHistory, reloadOperationHistory } from '@/mutators/operation/history'\nimport {\n createOperation,\n deleteOperation,\n deleteOperationExample,\n updateOperationPathMethod,\n updateOperationSummary,\n} from '@/mutators/operation/operation'\nimport {\n deleteAllOperationParameters,\n deleteOperationParameter,\n updateOperationExtraParameters,\n upsertOperationParameter,\n} from '@/mutators/operation/parameters'\nimport type { WorkspaceDocument } from '@/schemas'\n\nexport const operationMutatorsFactory = ({\n document,\n store,\n}: {\n document: WorkspaceDocument | null\n store: WorkspaceStore | null\n}) => {\n return {\n createOperation: (payload: OperationEvents['operation:create:operation']) => createOperation(store, payload),\n updateOperationSummary: (payload: OperationEvents['operation:update:summary']) =>\n updateOperationSummary(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 updateOperationExtension: (payload: OperationEvents['operation:update:extension']) =>\n updateOperationExtension(document, payload),\n updateOperationExtraParameters: (payload: OperationEvents['operation:update:extra-parameters']) =>\n updateOperationExtraParameters(document, payload),\n upsertOperationParameter: (payload: OperationEvents['operation:upsert:parameter']) =>\n upsertOperationParameter(document, payload),\n deleteOperationParameter: (payload: OperationEvents['operation:delete:parameter']) =>\n deleteOperationParameter(document, payload),\n deleteAllOperationParameters: (payload: OperationEvents['operation:delete-all:parameters']) =>\n deleteAllOperationParameters(document, payload),\n updateOperationRequestBodyContentType: (payload: OperationEvents['operation:update:requestBody:contentType']) =>\n updateOperationRequestBodyContentType(document, payload),\n updateOperationRequestBodyExample: (payload: OperationEvents['operation:update:requestBody:value']) =>\n updateOperationRequestBodyExample(document, payload),\n updateOperationRequestBodyFormValue: (payload: OperationEvents['operation:update:requestBody:formValue']) =>\n updateOperationRequestBodyFormValue(document, payload),\n addResponseToHistory: (payload: HooksEvents['hooks:on:request:complete']) =>\n addResponseToHistory(store, document, payload),\n reloadOperationHistory: (payload: OperationEvents['operation:reload:history']) =>\n reloadOperationHistory(store, document, payload),\n }\n}\n"],
5
- "mappings": "AAGA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,gCAAgC;AACzC,SAAS,sBAAsB,8BAA8B;AAC7D;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGA,MAAM,2BAA2B,CAAC;AAAA,EACvC;AAAA,EACA;AACF,MAGM;AACJ,SAAO;AAAA,IACL,iBAAiB,CAAC,YAA2D,gBAAgB,OAAO,OAAO;AAAA,IAC3G,wBAAwB,CAAC,YACvB,uBAAuB,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,0BAA0B,CAAC,YACzB,yBAAyB,UAAU,OAAO;AAAA,IAC5C,gCAAgC,CAAC,YAC/B,+BAA+B,UAAU,OAAO;AAAA,IAClD,0BAA0B,CAAC,YACzB,yBAAyB,UAAU,OAAO;AAAA,IAC5C,0BAA0B,CAAC,YACzB,yBAAyB,UAAU,OAAO;AAAA,IAC5C,8BAA8B,CAAC,YAC7B,6BAA6B,UAAU,OAAO;AAAA,IAChD,uCAAuC,CAAC,YACtC,sCAAsC,UAAU,OAAO;AAAA,IACzD,mCAAmC,CAAC,YAClC,kCAAkC,UAAU,OAAO;AAAA,IACrD,qCAAqC,CAAC,YACpC,oCAAoC,UAAU,OAAO;AAAA,IACvD,sBAAsB,CAAC,YACrB,qBAAqB,OAAO,UAAU,OAAO;AAAA,IAC/C,wBAAwB,CAAC,YACvB,uBAAuB,OAAO,UAAU,OAAO;AAAA,EACnD;AACF;",
4
+ "sourcesContent": ["import type { WorkspaceStore } from '@/client'\nimport type { HooksEvents } from '@/events/definitions/hooks'\nimport type { OperationEvents } from '@/events/definitions/operation'\nimport {\n updateOperationRequestBodyContentType,\n updateOperationRequestBodyExample,\n updateOperationRequestBodyFormValue,\n} from '@/mutators/operation/body'\nimport { updateOperationExtension } from '@/mutators/operation/extensions'\nimport { addResponseToHistory, reloadOperationHistory } from '@/mutators/operation/history'\nimport {\n createOperation,\n createOperationDraftExample,\n deleteOperation,\n deleteOperationExample,\n updateOperationPathMethod,\n updateOperationSummary,\n} from '@/mutators/operation/operation'\nimport {\n deleteAllOperationParameters,\n deleteOperationParameter,\n updateOperationExtraParameters,\n upsertOperationParameter,\n} from '@/mutators/operation/parameters'\nimport type { WorkspaceDocument } from '@/schemas'\n\nexport const operationMutatorsFactory = ({\n document,\n store,\n}: {\n document: WorkspaceDocument | null\n store: WorkspaceStore | null\n}) => {\n return {\n createOperation: (payload: OperationEvents['operation:create:operation']) => createOperation(store, payload),\n updateOperationSummary: (payload: OperationEvents['operation:update:summary']) =>\n updateOperationSummary(store, document, payload),\n updateOperationPathMethod: (payload: OperationEvents['operation:update:pathMethod']) =>\n updateOperationPathMethod(document, store, payload),\n deleteOperation: (payload: OperationEvents['operation:delete:operation']) => deleteOperation(store, payload),\n createOperationDraftExample: (payload: OperationEvents['operation:create:draft-example']) =>\n createOperationDraftExample(store, payload),\n deleteOperationExample: (payload: OperationEvents['operation:delete:example']) =>\n deleteOperationExample(store, payload),\n updateOperationExtension: (payload: OperationEvents['operation:update:extension']) =>\n updateOperationExtension(document, payload),\n updateOperationExtraParameters: (payload: OperationEvents['operation:update:extra-parameters']) =>\n updateOperationExtraParameters(document, payload),\n upsertOperationParameter: (payload: OperationEvents['operation:upsert:parameter']) =>\n upsertOperationParameter(document, payload),\n deleteOperationParameter: (payload: OperationEvents['operation:delete:parameter']) =>\n deleteOperationParameter(document, payload),\n deleteAllOperationParameters: (payload: OperationEvents['operation:delete-all:parameters']) =>\n deleteAllOperationParameters(document, payload),\n updateOperationRequestBodyContentType: (payload: OperationEvents['operation:update:requestBody:contentType']) =>\n updateOperationRequestBodyContentType(document, payload),\n updateOperationRequestBodyExample: (payload: OperationEvents['operation:update:requestBody:value']) =>\n updateOperationRequestBodyExample(document, payload),\n updateOperationRequestBodyFormValue: (payload: OperationEvents['operation:update:requestBody:formValue']) =>\n updateOperationRequestBodyFormValue(document, payload),\n addResponseToHistory: (payload: HooksEvents['hooks:on:request:complete']) =>\n addResponseToHistory(store, document, payload),\n reloadOperationHistory: (payload: OperationEvents['operation:reload:history']) =>\n reloadOperationHistory(store, document, payload),\n }\n}\n"],
5
+ "mappings": "AAGA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,gCAAgC;AACzC,SAAS,sBAAsB,8BAA8B;AAC7D;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGA,MAAM,2BAA2B,CAAC;AAAA,EACvC;AAAA,EACA;AACF,MAGM;AACJ,SAAO;AAAA,IACL,iBAAiB,CAAC,YAA2D,gBAAgB,OAAO,OAAO;AAAA,IAC3G,wBAAwB,CAAC,YACvB,uBAAuB,OAAO,UAAU,OAAO;AAAA,IACjD,2BAA2B,CAAC,YAC1B,0BAA0B,UAAU,OAAO,OAAO;AAAA,IACpD,iBAAiB,CAAC,YAA2D,gBAAgB,OAAO,OAAO;AAAA,IAC3G,6BAA6B,CAAC,YAC5B,4BAA4B,OAAO,OAAO;AAAA,IAC5C,wBAAwB,CAAC,YACvB,uBAAuB,OAAO,OAAO;AAAA,IACvC,0BAA0B,CAAC,YACzB,yBAAyB,UAAU,OAAO;AAAA,IAC5C,gCAAgC,CAAC,YAC/B,+BAA+B,UAAU,OAAO;AAAA,IAClD,0BAA0B,CAAC,YACzB,yBAAyB,UAAU,OAAO;AAAA,IAC5C,0BAA0B,CAAC,YACzB,yBAAyB,UAAU,OAAO;AAAA,IAC5C,8BAA8B,CAAC,YAC7B,6BAA6B,UAAU,OAAO;AAAA,IAChD,uCAAuC,CAAC,YACtC,sCAAsC,UAAU,OAAO;AAAA,IACzD,mCAAmC,CAAC,YAClC,kCAAkC,UAAU,OAAO;AAAA,IACrD,qCAAqC,CAAC,YACpC,oCAAoC,UAAU,OAAO;AAAA,IACvD,sBAAsB,CAAC,YACrB,qBAAqB,OAAO,UAAU,OAAO;AAAA,IAC/C,wBAAwB,CAAC,YACvB,uBAAuB,OAAO,UAAU,OAAO;AAAA,EACnD;AACF;",
6
6
  "names": []
7
7
  }
@@ -32,7 +32,7 @@ export declare const createOperation: (workspaceStore: WorkspaceStore | null, pa
32
32
  * })
33
33
  * ```
34
34
  */
35
- export declare const updateOperationSummary: (document: WorkspaceDocument | null, { meta, payload: { summary } }: OperationEvents["operation:update:summary"]) => void;
35
+ export declare const updateOperationSummary: (store: WorkspaceStore | null, document: WorkspaceDocument | null, { meta, payload: { summary } }: OperationEvents["operation:update:summary"]) => void;
36
36
  /**
37
37
  * Updates the HTTP method and/or path of an operation and moves it to the new location.
38
38
  * This function:
@@ -65,6 +65,14 @@ export declare const updateOperationPathMethod: (document: WorkspaceDocument | n
65
65
  * ```
66
66
  */
67
67
  export declare const deleteOperation: (workspace: WorkspaceStore | null, { meta, documentName }: OperationEvents["operation:delete:operation"]) => void;
68
+ /**
69
+ * Adds an example name to the 'x-draft-examples' array for a specific operation in a document.
70
+ *
71
+ * - Finds the target operation using the provided path and method within the specified document.
72
+ * - If the operation is found and has an 'x-draft-examples' array, pushes the new exampleName to it.
73
+ * - Safely no-ops if the document or operation does not exist.
74
+ */
75
+ export declare const createOperationDraftExample: (workspace: WorkspaceStore | null, { meta: { path, method }, documentName, exampleName }: OperationEvents["operation:create:draft-example"]) => void;
68
76
  /**
69
77
  * Deletes an example with the given exampleKey from operation parameters and request body.
70
78
  *
@@ -1 +1 @@
1
- {"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../../../src/mutators/operation/operation.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAOrE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAIlD;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,eAAe,GAC1B,gBAAgB,cAAc,GAAG,IAAI,EACrC,SAAS,eAAe,CAAC,4BAA4B,CAAC,KACrD,MAAM,GAAG,SAwDX,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,sBAAsB,GACjC,UAAU,iBAAiB,GAAG,IAAI,EAClC,gCAAgC,eAAe,CAAC,0BAA0B,CAAC,SAY5E,CAAA;AAwDD;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,yBAAyB,GACpC,UAAU,iBAAiB,GAAG,IAAI,EAClC,OAAO,cAAc,GAAG,IAAI,EAC5B,+CAA+C,eAAe,CAAC,6BAA6B,CAAC,KAC5F,IA+FF,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,eAAe,GAC1B,WAAW,cAAc,GAAG,IAAI,EAChC,wBAAwB,eAAe,CAAC,4BAA4B,CAAC,SAgBtE,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,GACjC,WAAW,cAAc,GAAG,IAAI,EAChC,sDAAsD,eAAe,CAAC,0BAA0B,CAAC,SAyClG,CAAA"}
1
+ {"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../../../src/mutators/operation/operation.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAOrE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAElD;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,eAAe,GAC1B,gBAAgB,cAAc,GAAG,IAAI,EACrC,SAAS,eAAe,CAAC,4BAA4B,CAAC,KACrD,MAAM,GAAG,SAwDX,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,sBAAsB,GACjC,OAAO,cAAc,GAAG,IAAI,EAC5B,UAAU,iBAAiB,GAAG,IAAI,EAClC,gCAAgC,eAAe,CAAC,0BAA0B,CAAC,SAqB5E,CAAA;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,yBAAyB,GACpC,UAAU,iBAAiB,GAAG,IAAI,EAClC,OAAO,cAAc,GAAG,IAAI,EAC5B,+CAA+C,eAAe,CAAC,6BAA6B,CAAC,KAC5F,IA+FF,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,eAAe,GAC1B,WAAW,cAAc,GAAG,IAAI,EAChC,wBAAwB,eAAe,CAAC,4BAA4B,CAAC,SAgBtE,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B,GACtC,WAAW,cAAc,GAAG,IAAI,EAChC,uDAAuD,eAAe,CAAC,gCAAgC,CAAC,SAuBzG,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,GACjC,WAAW,cAAc,GAAG,IAAI,EAChC,sDAAsD,eAAe,CAAC,0BAA0B,CAAC,SAiDlG,CAAA"}
@@ -6,7 +6,7 @@ import { unpackProxyObject } from "../../helpers/unpack-proxy.js";
6
6
  import { syncParametersForPathChange } from "../../mutators/operation/helpers/sync-path-parameters.js";
7
7
  import { getOperationEntries } from "../../navigation/index.js";
8
8
  import { getNavigationOptions } from "../../navigation/get-navigation-options.js";
9
- import { canHaveOrder, getOpenapiObject } from "../../navigation/helpers/get-openapi-object.js";
9
+ import { updateOrderIds } from "../../navigation/helpers/update-order-ids.js";
10
10
  const createOperation = (workspaceStore, payload) => {
11
11
  const document = workspaceStore?.workspace.documents[payload.documentName];
12
12
  if (!document) {
@@ -44,8 +44,12 @@ const createOperation = (workspaceStore, payload) => {
44
44
  payload.callback?.(true);
45
45
  return normalizedPath;
46
46
  };
47
- const updateOperationSummary = (document, { meta, payload: { summary } }) => {
48
- if (!document) {
47
+ const updateOperationSummary = (store, document, { meta, payload: { summary } }) => {
48
+ if (!document || !store) {
49
+ return;
50
+ }
51
+ const documentName = document["x-scalar-navigation"]?.name;
52
+ if (documentName === void 0) {
49
53
  return;
50
54
  }
51
55
  const operation = getResolvedRef(document.paths?.[meta.path]?.[meta.method]);
@@ -53,38 +57,7 @@ const updateOperationSummary = (document, { meta, payload: { summary } }) => {
53
57
  return;
54
58
  }
55
59
  operation.summary = summary;
56
- };
57
- const updateOperationOrderId = ({
58
- store,
59
- operation,
60
- generateId,
61
- method,
62
- path,
63
- entries
64
- }) => {
65
- entries?.forEach((entry) => {
66
- if (!canHaveOrder(entry.parent)) {
67
- return;
68
- }
69
- const parentOpenAPIObject = getOpenapiObject({ store, entry: entry.parent });
70
- if (!parentOpenAPIObject || !("x-scalar-order" in parentOpenAPIObject)) {
71
- return;
72
- }
73
- const order = parentOpenAPIObject["x-scalar-order"];
74
- const index = order?.indexOf(entry.id);
75
- if (!Array.isArray(order) || typeof index !== "number" || index < 0) {
76
- return;
77
- }
78
- const parentTag = entry.parent.type === "tag" && "name" in parentOpenAPIObject ? { tag: parentOpenAPIObject, id: entry.parent.id } : void 0;
79
- order[index] = generateId({
80
- type: "operation",
81
- path,
82
- method,
83
- operation,
84
- parentId: entry.parent.id,
85
- parentTag
86
- });
87
- });
60
+ store.buildSidebar(documentName);
88
61
  };
89
62
  const updateOperationPathMethod = (document, store, { meta, payload: { method, path }, callback }) => {
90
63
  const methodChanged = meta.method !== method;
@@ -125,7 +98,7 @@ const updateOperationPathMethod = (document, store, { meta, payload: { method, p
125
98
  const operationEntriesMap = getOperationEntries(documentNavigation);
126
99
  const entries = operationEntriesMap.get(`${meta.path}|${meta.method}`);
127
100
  if (entries) {
128
- updateOperationOrderId({ store, operation, generateId, method: finalMethod, path: finalPath, entries });
101
+ updateOrderIds({ store, operation, generateId, method: finalMethod, path: finalPath, entries });
129
102
  }
130
103
  if (!document.paths) {
131
104
  document.paths = {};
@@ -159,6 +132,22 @@ const deleteOperation = (workspace, { meta, documentName }) => {
159
132
  delete document.paths?.[meta.path];
160
133
  }
161
134
  };
135
+ const createOperationDraftExample = (workspace, { meta: { path, method }, documentName, exampleName }) => {
136
+ const document = workspace?.workspace.documents[documentName];
137
+ if (!document) {
138
+ console.error("Document not found", { documentName });
139
+ return;
140
+ }
141
+ const operation = getResolvedRef(document.paths?.[path]?.[method]);
142
+ if (!operation) {
143
+ console.error("Operation not found", { path, method });
144
+ return;
145
+ }
146
+ operation["x-draft-examples"] ??= [];
147
+ const dedupe = new Set(operation["x-draft-examples"]);
148
+ dedupe.add(exampleName);
149
+ operation["x-draft-examples"] = Array.from(dedupe);
150
+ };
162
151
  const deleteOperationExample = (workspace, { meta: { path, method, exampleKey }, documentName }) => {
163
152
  const document = workspace?.workspace.documents[documentName];
164
153
  if (!document) {
@@ -168,6 +157,11 @@ const deleteOperationExample = (workspace, { meta: { path, method, exampleKey },
168
157
  if (!operation) {
169
158
  return;
170
159
  }
160
+ const dedupe = new Set(operation["x-draft-examples"] ?? []);
161
+ dedupe.delete(exampleKey);
162
+ if (operation["x-draft-examples"] !== void 0) {
163
+ operation["x-draft-examples"] = Array.from(dedupe);
164
+ }
171
165
  operation.parameters?.forEach((parameter) => {
172
166
  const resolvedParameter = getResolvedRef(parameter);
173
167
  if ("content" in resolvedParameter && resolvedParameter.content) {
@@ -189,6 +183,7 @@ const deleteOperationExample = (workspace, { meta: { path, method, exampleKey },
189
183
  };
190
184
  export {
191
185
  createOperation,
186
+ createOperationDraftExample,
192
187
  deleteOperation,
193
188
  deleteOperationExample,
194
189
  updateOperationPathMethod,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/mutators/operation/operation.ts"],
4
- "sourcesContent": ["import type { HttpMethod } from '@scalar/helpers/http/http-methods'\nimport { isHttpMethod } from '@scalar/helpers/http/is-http-method'\nimport { preventPollution } from '@scalar/helpers/object/prevent-pollution'\nimport { findVariables } from '@scalar/helpers/regex/find-variables'\n\nimport type { WorkspaceStore } from '@/client'\nimport type { OperationEvents } from '@/events/definitions/operation'\nimport { getResolvedRef } from '@/helpers/get-resolved-ref'\nimport { unpackProxyObject } from '@/helpers/unpack-proxy'\nimport { syncParametersForPathChange } from '@/mutators/operation/helpers/sync-path-parameters'\nimport { getOperationEntries } from '@/navigation'\nimport { getNavigationOptions } from '@/navigation/get-navigation-options'\nimport { canHaveOrder, getOpenapiObject } from '@/navigation/helpers/get-openapi-object'\nimport type { WorkspaceDocument } from '@/schemas'\nimport type { IdGenerator, TraversedOperation, TraversedWebhook, WithParent } from '@/schemas/navigation'\nimport type { OperationObject } from '@/schemas/v3.1/strict/operation'\n\n/**\n * Creates a new operation at a specific path and method in the document.\n * Automatically normalizes the path to ensure it starts with a slash.\n *\n * Returns the normalized path if successful, undefined otherwise.\n *\n * Example:\n * ```ts\n * createOperation(\n * document,\n * 'users',\n * 'get',\n * { tags: ['Users'] },\n * )\n * ```\n */\nexport const createOperation = (\n workspaceStore: WorkspaceStore | null,\n payload: OperationEvents['operation:create:operation'],\n): string | undefined => {\n const document = workspaceStore?.workspace.documents[payload.documentName]\n if (!document) {\n payload.callback?.(false)\n return undefined\n }\n\n const { path, method, operation } = payload\n\n /** Ensure the path starts with a slash */\n const normalizedPath = path.startsWith('/') ? path : `/${path}`\n\n /** Create the operation in the document */\n if (!document.paths) {\n document.paths = {}\n }\n\n if (!document.paths[normalizedPath]) {\n document.paths[normalizedPath] = {}\n }\n\n /** Prevent pollution of the path and method */\n preventPollution(normalizedPath)\n preventPollution(method)\n\n /** Create the operation in the document */\n document.paths[normalizedPath][method] = operation\n\n // Make sure that we are selecting the new operation server\n const { servers } = operation\n const firstServer = unpackProxyObject(servers?.[0])\n\n // For now we only support document servers but in the future we might support operation servers\n for (const server of servers ?? []) {\n // If the server does not exist in the document, add it\n if (!document.servers?.some((s) => s.url === server.url)) {\n if (!document.servers) {\n document.servers = []\n }\n document.servers.push(unpackProxyObject(server))\n }\n }\n\n // Update the selected server to the first server of the created operation\n if (firstServer) {\n document['x-scalar-selected-server'] = firstServer.url\n }\n\n // Sync path variables\n const newParameters = syncParametersForPathChange(normalizedPath, normalizedPath, operation.parameters ?? [])\n if (newParameters.length > 0) {\n operation.parameters = newParameters\n }\n\n payload.callback?.(true)\n return normalizedPath\n}\n\n/**\n * Updates the `summary` of an operation.\n * Safely no-ops if the document or operation does not exist.\n *\n * Example:\n * ```ts\n * updateOperationSummary(\n * document,\n * {\n * meta: { method: 'get', path: '/users/{id}' },\n * payload: { summary: 'Get a single user' },\n * })\n * ```\n */\nexport const updateOperationSummary = (\n document: WorkspaceDocument | null,\n { meta, payload: { summary } }: OperationEvents['operation:update:summary'],\n) => {\n if (!document) {\n return\n }\n\n const operation = getResolvedRef(document.paths?.[meta.path]?.[meta.method as HttpMethod])\n if (!operation) {\n return\n }\n\n operation.summary = summary\n}\n\n/**\n * Updates the order ID of an operation in the sidebar.\n * Used when changing path or method so we do not lose the sidebar ordering\n */\nconst updateOperationOrderId = ({\n store,\n operation,\n generateId,\n method,\n path,\n entries,\n}: {\n store: WorkspaceStore\n operation: OperationObject\n generateId: IdGenerator\n method: HttpMethod\n path: string\n entries: (WithParent<TraversedOperation> | WithParent<TraversedWebhook>)[]\n}) => {\n // Loop over the entries and replace the ID in the x-scalar-order with the new ID\n entries?.forEach((entry) => {\n if (!canHaveOrder(entry.parent)) {\n return\n }\n\n // Ensure we have an x-scalar-order property\n const parentOpenAPIObject = getOpenapiObject({ store, entry: entry.parent })\n if (!parentOpenAPIObject || !('x-scalar-order' in parentOpenAPIObject)) {\n return\n }\n\n const order = parentOpenAPIObject['x-scalar-order']\n const index = order?.indexOf(entry.id)\n if (!Array.isArray(order) || typeof index !== 'number' || index < 0) {\n return\n }\n\n const parentTag =\n entry.parent.type === 'tag' && 'name' in parentOpenAPIObject\n ? { tag: parentOpenAPIObject, id: entry.parent.id }\n : undefined\n\n // Generate the new ID based on whether this is an operation or webhook\n order[index] = generateId({\n type: 'operation',\n path,\n method,\n operation,\n parentId: entry.parent.id,\n parentTag,\n })\n })\n}\n\n/**\n * Updates the HTTP method and/or path of an operation and moves it to the new location.\n * This function:\n * 1. Moves the operation from the old method/path to the new method/path under paths\n * 2. Updates x-scalar-order to maintain the operation's position in the sidebar\n * 3. Syncs path parameters when the path changes\n *\n * Safely no-ops if nothing has changed, or if the document or operation does not exist.\n *\n * Example:\n * ```ts\n * updateOperationPathMethod({\n * document,\n * store,\n * meta: { method: 'get', path: '/users' },\n * payload: { method: 'post', path: '/api/users' },\n * })\n * ```\n */\nexport const updateOperationPathMethod = (\n document: WorkspaceDocument | null,\n store: WorkspaceStore | null,\n { meta, payload: { method, path }, callback }: OperationEvents['operation:update:pathMethod'],\n): void => {\n const methodChanged = meta.method !== method\n const pathChanged = meta.path !== path\n\n // If nothing has changed, no need to do anything\n if (!methodChanged && !pathChanged) {\n callback('no-change')\n return\n }\n\n // Determine the final method and path\n const finalMethod = methodChanged ? method : meta.method\n const finalPath = pathChanged ? path : meta.path\n\n // Check for conflicts at the target location\n if (document?.paths?.[finalPath]?.[finalMethod as HttpMethod]) {\n callback('conflict')\n return\n }\n\n const documentNavigation = document?.['x-scalar-navigation']\n if (!documentNavigation || !store) {\n console.error('Document or workspace not found', { document })\n return\n }\n\n const operation = getResolvedRef(document.paths?.[meta.path]?.[meta.method as HttpMethod])\n if (!operation) {\n console.error('Operation not found', { meta, document })\n return\n }\n\n // Sync path parameters if the path has changed\n if (pathChanged) {\n const oldPathParams = findVariables(meta.path, { includePath: true, includeEnv: false }).filter(\n (v): v is string => v !== undefined,\n )\n const newPathParams = findVariables(finalPath, { includePath: true, includeEnv: false }).filter(\n (v): v is string => v !== undefined,\n )\n\n if (oldPathParams.length > 0 || newPathParams.length > 0) {\n const existingParameters = operation.parameters ?? []\n operation.parameters = syncParametersForPathChange(finalPath, meta.path, existingParameters)\n }\n }\n\n /**\n * We don't pass navigation options as we don't have config on the client,\n * and we don't change path or method on the references\n */\n const { generateId } = getNavigationOptions(documentNavigation.name)\n\n /** Grabs all of the current operation entries for the given path and method */\n const operationEntriesMap = getOperationEntries(documentNavigation)\n const entries = operationEntriesMap.get(`${meta.path}|${meta.method}`)\n\n // Updates the order ID so we don't lose the sidebar ordering when it rebuilds\n if (entries) {\n updateOperationOrderId({ store, operation, generateId, method: finalMethod, path: finalPath, entries })\n }\n\n // Initialize the paths object if it does not exist\n if (!document.paths) {\n document.paths = {}\n }\n\n // Initialize the new path if it does not exist\n if (!document.paths[finalPath]) {\n document.paths[finalPath] = {}\n }\n\n // Prevent assigning dangerous keys to the path items object\n preventPollution(finalPath)\n preventPollution(meta.path)\n preventPollution(finalMethod)\n\n // Move the operation to the new location\n document.paths[finalPath][finalMethod] = unpackProxyObject(operation)\n\n // Remove the operation from the old location\n const oldPathItems = document.paths[meta.path]\n if (oldPathItems && isHttpMethod(meta.method)) {\n delete oldPathItems[meta.method]\n\n // If the old path has no more operations, remove the path entry\n if (Object.keys(oldPathItems).length === 0) {\n delete document.paths[meta.path]\n }\n }\n\n // We need to reset the history for the operation when the path or method changes\n store.history.clearOperationHistory(document['x-scalar-navigation']?.name ?? '', meta.path, meta.method)\n\n callback('success')\n}\n\n/**\n * Deletes an operation from the workspace\n *\n * Example:\n * ```ts\n * deleteOperation({\n * document,\n * meta: { method: 'get', path: '/users' },\n * })\n * ```\n */\nexport const deleteOperation = (\n workspace: WorkspaceStore | null,\n { meta, documentName }: OperationEvents['operation:delete:operation'],\n) => {\n const document = workspace?.workspace.documents[documentName]\n if (!document) {\n return\n }\n\n preventPollution(meta.path)\n preventPollution(meta.method)\n\n delete document.paths?.[meta.path]?.[meta.method]\n\n // If the path has no more operations, remove the path entry\n if (Object.keys(document.paths?.[meta.path] ?? {}).length === 0) {\n delete document.paths?.[meta.path]\n }\n}\n\n/**\n * Deletes an example with the given exampleKey from operation parameters and request body.\n *\n * - Finds the target operation within the specified document and path/method.\n * - Removes example values matching exampleKey from both parameter-level and content-level examples.\n * - Safely no-ops if the document, operation, or request body does not exist.\n */\nexport const deleteOperationExample = (\n workspace: WorkspaceStore | null,\n { meta: { path, method, exampleKey }, documentName }: OperationEvents['operation:delete:example'],\n) => {\n // Find the document in workspace based on documentName\n const document = workspace?.workspace.documents[documentName]\n if (!document) {\n return\n }\n\n // Get the operation object for the given path and method\n const operation = getResolvedRef(document.paths?.[path]?.[method])\n if (!operation) {\n return\n }\n\n // Remove the example from all operation parameters\n operation.parameters?.forEach((parameter) => {\n const resolvedParameter = getResolvedRef(parameter)\n\n // Remove from content-level examples (if parameter uses content)\n if ('content' in resolvedParameter && resolvedParameter.content) {\n Object.values(resolvedParameter.content).forEach((mediaType) => {\n delete mediaType.examples?.[exampleKey]\n })\n }\n\n // Remove from parameter-level examples\n if ('examples' in resolvedParameter && resolvedParameter.examples) {\n delete resolvedParameter.examples?.[exampleKey]\n }\n })\n\n // Remove the example from request body content types (if requestBody exists)\n const requestBody = getResolvedRef(operation.requestBody)\n if (!requestBody) {\n return\n }\n\n // For each media type, remove the example matching exampleKey\n Object.values(requestBody.content ?? {}).forEach((mediaType) => {\n delete mediaType.examples?.[exampleKey]\n })\n}\n"],
5
- "mappings": "AACA,SAAS,oBAAoB;AAC7B,SAAS,wBAAwB;AACjC,SAAS,qBAAqB;AAI9B,SAAS,sBAAsB;AAC/B,SAAS,yBAAyB;AAClC,SAAS,mCAAmC;AAC5C,SAAS,2BAA2B;AACpC,SAAS,4BAA4B;AACrC,SAAS,cAAc,wBAAwB;AAqBxC,MAAM,kBAAkB,CAC7B,gBACA,YACuB;AACvB,QAAM,WAAW,gBAAgB,UAAU,UA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;AAAA,IACH;AAGA,QAAI,cAAc,qBAAqB,kBAAkB,UAAU;AACjE,aAAO,kBAAkB,WAAW,UAAU;AAAA,IAChD;AAAA,EACF,CAAC;AAGD,QAAM,cAAc,eAAe,UAAU,WAAW;AACxD,MAAI,CAAC,aAAa;AAChB;AAAA,EACF;AAGA,SAAO,OAAO,YAAY,WAAW,CAAC,CAAC,EAAE,QAAQ,CAAC,cAAc;AAC9D,WAAO,UAAU,WAAW,UAAU;AAAA,EACxC,CAAC;AACH;",
4
+ "sourcesContent": ["import type { HttpMethod } from '@scalar/helpers/http/http-methods'\nimport { isHttpMethod } from '@scalar/helpers/http/is-http-method'\nimport { preventPollution } from '@scalar/helpers/object/prevent-pollution'\nimport { findVariables } from '@scalar/helpers/regex/find-variables'\n\nimport type { WorkspaceStore } from '@/client'\nimport type { OperationEvents } from '@/events/definitions/operation'\nimport { getResolvedRef } from '@/helpers/get-resolved-ref'\nimport { unpackProxyObject } from '@/helpers/unpack-proxy'\nimport { syncParametersForPathChange } from '@/mutators/operation/helpers/sync-path-parameters'\nimport { getOperationEntries } from '@/navigation'\nimport { getNavigationOptions } from '@/navigation/get-navigation-options'\nimport { updateOrderIds } from '@/navigation/helpers/update-order-ids'\nimport type { WorkspaceDocument } from '@/schemas'\n\n/**\n * Creates a new operation at a specific path and method in the document.\n * Automatically normalizes the path to ensure it starts with a slash.\n *\n * Returns the normalized path if successful, undefined otherwise.\n *\n * Example:\n * ```ts\n * createOperation(\n * document,\n * 'users',\n * 'get',\n * { tags: ['Users'] },\n * )\n * ```\n */\nexport const createOperation = (\n workspaceStore: WorkspaceStore | null,\n payload: OperationEvents['operation:create:operation'],\n): string | undefined => {\n const document = workspaceStore?.workspace.documents[payload.documentName]\n if (!document) {\n payload.callback?.(false)\n return undefined\n }\n\n const { path, method, operation } = payload\n\n /** Ensure the path starts with a slash */\n const normalizedPath = path.startsWith('/') ? path : `/${path}`\n\n /** Create the operation in the document */\n if (!document.paths) {\n document.paths = {}\n }\n\n if (!document.paths[normalizedPath]) {\n document.paths[normalizedPath] = {}\n }\n\n /** Prevent pollution of the path and method */\n preventPollution(normalizedPath)\n preventPollution(method)\n\n /** Create the operation in the document */\n document.paths[normalizedPath][method] = operation\n\n // Make sure that we are selecting the new operation server\n const { servers } = operation\n const firstServer = unpackProxyObject(servers?.[0])\n\n // For now we only support document servers but in the future we might support operation servers\n for (const server of servers ?? []) {\n // If the server does not exist in the document, add it\n if (!document.servers?.some((s) => s.url === server.url)) {\n if (!document.servers) {\n document.servers = []\n }\n document.servers.push(unpackProxyObject(server))\n }\n }\n\n // Update the selected server to the first server of the created operation\n if (firstServer) {\n document['x-scalar-selected-server'] = firstServer.url\n }\n\n // Sync path variables\n const newParameters = syncParametersForPathChange(normalizedPath, normalizedPath, operation.parameters ?? [])\n if (newParameters.length > 0) {\n operation.parameters = newParameters\n }\n\n payload.callback?.(true)\n return normalizedPath\n}\n\n/**\n * Updates the `summary` of an operation.\n * Safely no-ops if the document or operation does not exist.\n *\n * Example:\n * ```ts\n * updateOperationSummary(\n * document,\n * {\n * meta: { method: 'get', path: '/users/{id}' },\n * payload: { summary: 'Get a single user' },\n * })\n * ```\n */\nexport const updateOperationSummary = (\n store: WorkspaceStore | null,\n document: WorkspaceDocument | null,\n { meta, payload: { summary } }: OperationEvents['operation:update:summary'],\n) => {\n if (!document || !store) {\n return\n }\n\n const documentName = document['x-scalar-navigation']?.name\n if (documentName === undefined) {\n return\n }\n\n const operation = getResolvedRef(document.paths?.[meta.path]?.[meta.method as HttpMethod])\n if (!operation) {\n return\n }\n\n operation.summary = summary\n\n // Rebuild the sidebar to reflect the cahnges\n // We can't just go any find all the entries this operation is part so we just rebuild the sidebar\n store.buildSidebar(documentName)\n}\n\n/**\n * Updates the HTTP method and/or path of an operation and moves it to the new location.\n * This function:\n * 1. Moves the operation from the old method/path to the new method/path under paths\n * 2. Updates x-scalar-order to maintain the operation's position in the sidebar\n * 3. Syncs path parameters when the path changes\n *\n * Safely no-ops if nothing has changed, or if the document or operation does not exist.\n *\n * Example:\n * ```ts\n * updateOperationPathMethod({\n * document,\n * store,\n * meta: { method: 'get', path: '/users' },\n * payload: { method: 'post', path: '/api/users' },\n * })\n * ```\n */\nexport const updateOperationPathMethod = (\n document: WorkspaceDocument | null,\n store: WorkspaceStore | null,\n { meta, payload: { method, path }, callback }: OperationEvents['operation:update:pathMethod'],\n): void => {\n const methodChanged = meta.method !== method\n const pathChanged = meta.path !== path\n\n // If nothing has changed, no need to do anything\n if (!methodChanged && !pathChanged) {\n callback('no-change')\n return\n }\n\n // Determine the final method and path\n const finalMethod = methodChanged ? method : meta.method\n const finalPath = pathChanged ? path : meta.path\n\n // Check for conflicts at the target location\n if (document?.paths?.[finalPath]?.[finalMethod as HttpMethod]) {\n callback('conflict')\n return\n }\n\n const documentNavigation = document?.['x-scalar-navigation']\n if (!documentNavigation || !store) {\n console.error('Document or workspace not found', { document })\n return\n }\n\n const operation = getResolvedRef(document.paths?.[meta.path]?.[meta.method as HttpMethod])\n if (!operation) {\n console.error('Operation not found', { meta, document })\n return\n }\n\n // Sync path parameters if the path has changed\n if (pathChanged) {\n const oldPathParams = findVariables(meta.path, { includePath: true, includeEnv: false }).filter(\n (v): v is string => v !== undefined,\n )\n const newPathParams = findVariables(finalPath, { includePath: true, includeEnv: false }).filter(\n (v): v is string => v !== undefined,\n )\n\n if (oldPathParams.length > 0 || newPathParams.length > 0) {\n const existingParameters = operation.parameters ?? []\n operation.parameters = syncParametersForPathChange(finalPath, meta.path, existingParameters)\n }\n }\n\n /**\n * We don't pass navigation options as we don't have config on the client,\n * and we don't change path or method on the references\n */\n const { generateId } = getNavigationOptions(documentNavigation.name)\n\n /** Grabs all of the current operation entries for the given path and method */\n const operationEntriesMap = getOperationEntries(documentNavigation)\n const entries = operationEntriesMap.get(`${meta.path}|${meta.method}`)\n\n // Updates the order ID so we don't lose the sidebar ordering when it rebuilds\n if (entries) {\n updateOrderIds({ store, operation, generateId, method: finalMethod, path: finalPath, entries })\n }\n\n // Initialize the paths object if it does not exist\n if (!document.paths) {\n document.paths = {}\n }\n\n // Initialize the new path if it does not exist\n if (!document.paths[finalPath]) {\n document.paths[finalPath] = {}\n }\n\n // Prevent assigning dangerous keys to the path items object\n preventPollution(finalPath)\n preventPollution(meta.path)\n preventPollution(finalMethod)\n\n // Move the operation to the new location\n document.paths[finalPath][finalMethod] = unpackProxyObject(operation)\n\n // Remove the operation from the old location\n const oldPathItems = document.paths[meta.path]\n if (oldPathItems && isHttpMethod(meta.method)) {\n delete oldPathItems[meta.method]\n\n // If the old path has no more operations, remove the path entry\n if (Object.keys(oldPathItems).length === 0) {\n delete document.paths[meta.path]\n }\n }\n\n // We need to reset the history for the operation when the path or method changes\n store.history.clearOperationHistory(document['x-scalar-navigation']?.name ?? '', meta.path, meta.method)\n\n callback('success')\n}\n\n/**\n * Deletes an operation from the workspace\n *\n * Example:\n * ```ts\n * deleteOperation({\n * document,\n * meta: { method: 'get', path: '/users' },\n * })\n * ```\n */\nexport const deleteOperation = (\n workspace: WorkspaceStore | null,\n { meta, documentName }: OperationEvents['operation:delete:operation'],\n) => {\n const document = workspace?.workspace.documents[documentName]\n if (!document) {\n return\n }\n\n preventPollution(meta.path)\n preventPollution(meta.method)\n\n delete document.paths?.[meta.path]?.[meta.method]\n\n // If the path has no more operations, remove the path entry\n if (Object.keys(document.paths?.[meta.path] ?? {}).length === 0) {\n delete document.paths?.[meta.path]\n }\n}\n\n/**\n * Adds an example name to the 'x-draft-examples' array for a specific operation in a document.\n *\n * - Finds the target operation using the provided path and method within the specified document.\n * - If the operation is found and has an 'x-draft-examples' array, pushes the new exampleName to it.\n * - Safely no-ops if the document or operation does not exist.\n */\nexport const createOperationDraftExample = (\n workspace: WorkspaceStore | null,\n { meta: { path, method }, documentName, exampleName }: OperationEvents['operation:create:draft-example'],\n) => {\n const document = workspace?.workspace.documents[documentName]\n if (!document) {\n console.error('Document not found', { documentName })\n return\n }\n\n const operation = getResolvedRef(document.paths?.[path]?.[method])\n if (!operation) {\n console.error('Operation not found', { path, method })\n return\n }\n\n // Ensure that the x-draft-examples array exists\n operation['x-draft-examples'] ??= []\n\n // Remove duplicates\n const dedupe = new Set(operation['x-draft-examples'])\n // Add the new example name\n dedupe.add(exampleName)\n // Update the operation with the new x-draft-examples array\n operation['x-draft-examples'] = Array.from(dedupe)\n}\n\n/**\n * Deletes an example with the given exampleKey from operation parameters and request body.\n *\n * - Finds the target operation within the specified document and path/method.\n * - Removes example values matching exampleKey from both parameter-level and content-level examples.\n * - Safely no-ops if the document, operation, or request body does not exist.\n */\nexport const deleteOperationExample = (\n workspace: WorkspaceStore | null,\n { meta: { path, method, exampleKey }, documentName }: OperationEvents['operation:delete:example'],\n) => {\n // Find the document in workspace based on documentName\n const document = workspace?.workspace.documents[documentName]\n if (!document) {\n return\n }\n\n // Get the operation object for the given path and method\n const operation = getResolvedRef(document.paths?.[path]?.[method])\n if (!operation) {\n return\n }\n\n // Remove the example from the x-draft-examples array\n const dedupe = new Set(operation['x-draft-examples'] ?? [])\n dedupe.delete(exampleKey)\n\n if (operation['x-draft-examples'] !== undefined) {\n operation['x-draft-examples'] = Array.from(dedupe)\n }\n\n // Remove the example from all operation parameters\n operation.parameters?.forEach((parameter) => {\n const resolvedParameter = getResolvedRef(parameter)\n\n // Remove from content-level examples (if parameter uses content)\n if ('content' in resolvedParameter && resolvedParameter.content) {\n Object.values(resolvedParameter.content).forEach((mediaType) => {\n delete mediaType.examples?.[exampleKey]\n })\n }\n\n // Remove from parameter-level examples\n if ('examples' in resolvedParameter && resolvedParameter.examples) {\n delete resolvedParameter.examples?.[exampleKey]\n }\n })\n\n // Remove the example from request body content types (if requestBody exists)\n const requestBody = getResolvedRef(operation.requestBody)\n if (!requestBody) {\n return\n }\n\n // For each media type, remove the example matching exampleKey\n Object.values(requestBody.content ?? {}).forEach((mediaType) => {\n delete mediaType.examples?.[exampleKey]\n })\n}\n"],
5
+ "mappings": "AACA,SAAS,oBAAoB;AAC7B,SAAS,wBAAwB;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MAAM,QAAW;AAC/C,cAAU,kBAAkB,IAAI,MAAM,KAAK,MAAM;AAAA,EACnD;AAGA,YAAU,YAAY,QAAQ,CAAC,cAAc;AAC3C,UAAM,oBAAoB,eAAe,SAAS;AAGlD,QAAI,aAAa,qBAAqB,kBAAkB,SAAS;AAC/D,aAAO,OAAO,kBAAkB,OAAO,EAAE,QAAQ,CAAC,cAAc;AAC9D,eAAO,UAAU,WAAW,UAAU;AAAA,MACxC,CAAC;AAAA,IACH;AAGA,QAAI,cAAc,qBAAqB,kBAAkB,UAAU;AACjE,aAAO,kBAAkB,WAAW,UAAU;AAAA,IAChD;AAAA,EACF,CAAC;AAGD,QAAM,cAAc,eAAe,UAAU,WAAW;AACxD,MAAI,CAAC,aAAa;AAChB;AAAA,EACF;AAGA,SAAO,OAAO,YAAY,WAAW,CAAC,CAAC,EAAE,QAAQ,CAAC,cAAc;AAC9D,WAAO,UAAU,WAAW,UAAU;AAAA,EACxC,CAAC;AACH;",
6
6
  "names": []
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"parameters.d.ts","sourceRoot":"","sources":["../../../src/mutators/operation/parameters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAGrE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAIlD;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,wBAAwB,GACnC,UAAU,iBAAiB,GAAG,IAAI,EAClC,4CAA4C,eAAe,CAAC,4BAA4B,CAAC,SA8C1F,CAAA;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,8BAA8B,GACzC,UAAU,iBAAiB,GAAG,IAAI,EAClC,uCAAuC,eAAe,CAAC,mCAAmC,CAAC,SA8C5F,CAAA;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,wBAAwB,GACnC,UAAU,iBAAiB,GAAG,IAAI,EAClC,6BAA6B,eAAe,CAAC,4BAA4B,CAAC,SA0B3E,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,4BAA4B,GACvC,UAAU,iBAAiB,GAAG,IAAI,EAClC,gBAAgB,eAAe,CAAC,iCAAiC,CAAC,SAanE,CAAA"}
1
+ {"version":3,"file":"parameters.d.ts","sourceRoot":"","sources":["../../../src/mutators/operation/parameters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAGrE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAKlD;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,wBAAwB,GACnC,UAAU,iBAAiB,GAAG,IAAI,EAClC,4CAA4C,eAAe,CAAC,4BAA4B,CAAC,SA+C1F,CAAA;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,8BAA8B,GACzC,UAAU,iBAAiB,GAAG,IAAI,EAClC,uCAAuC,eAAe,CAAC,mCAAmC,CAAC,SA8C5F,CAAA;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,wBAAwB,GACnC,UAAU,iBAAiB,GAAG,IAAI,EAClC,6BAA6B,eAAe,CAAC,4BAA4B,CAAC,SA0B3E,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,4BAA4B,GACvC,UAAU,iBAAiB,GAAG,IAAI,EAClC,gBAAgB,eAAe,CAAC,iCAAiC,CAAC,SAanE,CAAA"}
@@ -1,17 +1,16 @@
1
1
  import { getResolvedRef } from "../../helpers/get-resolved-ref.js";
2
2
  import { unpackProxyObject } from "../../helpers/unpack-proxy.js";
3
- import { isContentTypeParameterObject } from "../../schemas/v3.1/strict/type-guards.js";
4
3
  const upsertOperationParameter = (document, { meta, type, payload, originalParameter }) => {
5
4
  if (originalParameter) {
6
- originalParameter.name = payload.name;
7
- if (isContentTypeParameterObject(originalParameter)) {
8
- return;
5
+ const param = originalParameter;
6
+ param.name = payload.name;
7
+ if (!param.examples) {
8
+ param.examples = {};
9
9
  }
10
- if (!originalParameter.examples) {
11
- originalParameter.examples = {};
10
+ if (!param.examples[meta.exampleKey]) {
11
+ param.examples[meta.exampleKey] = {};
12
12
  }
13
- originalParameter.examples[meta.exampleKey] ||= {};
14
- const example = getResolvedRef(originalParameter.examples[meta.exampleKey]);
13
+ const example = getResolvedRef(param.examples[meta.exampleKey]);
15
14
  example.value = payload.value;
16
15
  example["x-disabled"] = payload.isDisabled;
17
16
  return;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/mutators/operation/parameters.ts"],
4
- "sourcesContent": ["import type { OperationEvents } from '@/events/definitions/operation'\nimport { getResolvedRef } from '@/helpers/get-resolved-ref'\nimport { unpackProxyObject } from '@/helpers/unpack-proxy'\nimport type { WorkspaceDocument } from '@/schemas'\nimport type { DisableParametersConfig } from '@/schemas/extensions/operation/x-scalar-disable-parameters'\nimport { isContentTypeParameterObject } from '@/schemas/v3.1/strict/type-guards'\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"],
5
- "mappings": "AACA,SAAS,sBAAsB;AAC/B,SAAS,yBAAyB;AAGlC,SAAS,oCAAoC;AAmBtC,MAAM,2BAA2B,CACtC,UACA,EAAE,MAAM,MAAM,SAAS,kBAAkB,MACtC;AAEH,MAAI,mBAAmB;AACrB,sBAAkB,OAAO,QAAQ;AAEjC,QAAI,6BAA6B,iBAAiB,GAAG;AAEnD;AAAA,IACF;AAEA,QAAI,CAAC,kBAAkB,UAAU;AAC/B,wBAAkB,WAAW,CAAC;AAAA,IAChC;AAGA,sBAAkB,SAAS,KAAK,UAAU,MAAM,CAAC;AACjD,UAAM,UAAU,eAAe,kBAAkB,SAAS,KAAK,UAAU,CAAC;AAG1E,YAAQ,QAAQ,QAAQ;AACxB,YAAQ,YAAY,IAAI,QAAQ;AAChC;AAAA,EACF;AAGA,QAAM,YAAY,eAAe,UAAU,QAAQ,KAAK,IAAI,IAAI,KAAK,MAAM,CAAC;AAC5E,MAAI,CAAC,WAAW;AACd,YAAQ,MAAM,uBAAuB,EAAE,MAAM,SAAS,CAAC;AACvD;AAAA,EACF;AAEA,YAAU,eAAe,CAAC;AAC1B,YAAU,WAAW,KAAK;AAAA,IACxB,MAAM,QAAQ;AAAA,IACd,IAAI;AAAA,IACJ,UAAU,SAAS,SAAS,OAAO;AAAA,IACnC,UAAU;AAAA,MACR,CAAC,KAAK,UAAU,GAAG;AAAA,QACjB,OAAO,QAAQ;AAAA;AAAA,QAEf,cAAc;AAAA,MAChB;AAAA,IACF;AAAA,EACF,CAAC;AACD;AACF;AAkBO,MAAM,iCAAiC,CAC5C,UACA,EAAE,MAAM,MAAM,SAAS,IAAI,SAAS,MACjC;AAKH,MAAI,CAAC,UAAU;AACb;AAAA,EACF;AAGA,QAAM,YAAY,eAAe,SAAS,QAAQ,KA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a;AAAA,MAChB,KAAK,YAAY,OAAO,CAAC,GAAG,MAAM,MAAM,SAAS;AAAA,MACjD,EAAE,OAAO,EAAE;AAAA,IACb;AAAA,EACF;AACF;AAeO,MAAM,+BAA+B,CAC1C,UACA,EAAE,MAAM,KAAK,MACV;AACH,MAAI,CAAC,UAAU;AACb;AAAA,EACF;AAEA,QAAM,YAAY,eAAe,SAAS,QAAQ,KAAK,IAAI,IAAI,KAAK,MAAM,CAAC;AAC3E,MAAI,CAAC,WAAW;AACd;AAAA,EACF;AAGA,YAAU,aAAa,UAAU,YAAY,OAAO,CAAC,OAAO,eAAe,EAAE,EAAE,OAAO,IAAI,KAAK,CAAC;AAClG;",
4
+ "sourcesContent": ["import type { OperationEvents } from '@/events/definitions/operation'\nimport { getResolvedRef } from '@/helpers/get-resolved-ref'\nimport { unpackProxyObject } from '@/helpers/unpack-proxy'\nimport type { WorkspaceDocument } from '@/schemas'\nimport type { DisableParametersConfig } from '@/schemas/extensions/operation/x-scalar-disable-parameters'\nimport type { ExampleObject } from '@/schemas/v3.1/strict/example'\nimport type { ReferenceType } from '@/schemas/v3.1/strict/reference'\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 // To support content-type parameters in the API client, we just assume an\n // examples property can be set.\n const param = originalParameter as typeof originalParameter & {\n examples: Record<string, ReferenceType<ExampleObject>>\n }\n param.name = payload.name\n if (!param.examples) {\n param.examples = {}\n }\n\n // Create the example if it doesn't exist\n if (!param.examples[meta.exampleKey]) {\n param.examples[meta.exampleKey] = {}\n }\n const example = getResolvedRef(param.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"],
5
+ "mappings": "AACA,SAAS,sBAAsB;AAC/B,SAAS,yBAAyB;AAuB3B,MAAM,2BAA2B,CACtC,UACA,EAAE,MAAM,MAAM,SAAS,kBAAkB,MACtC;AAEH,MAAI,mBAAmB;AAGrB,UAAM,QAAQ;AAGd,UAAM,OAAO,QAAQ;AACrB,QAAI,CAAC,MAAM,UAAU;AACnB,YAAM,WAAW,CAAC;AAAA,IACpB;AAGA,QAAI,CAAC,MAAM,SAAS,KAAK,UAAU,GAAG;AACpC,YAAM,SAAS,KAAK,UAAU,IAAI,CAAC;AAAA,IACrC;AACA,UAAM,UAAU,eAAe,MAAM,SAAS,KAAK,UAAU,CAAC;AAG9D,YAAQ,QAAQ,QAAQ;AACxB,YAAQ,YAAY,IAAI,QAAQ;AAChC;AAAA,EACF;AAGA,QAAM,YAAY,eAAe,UAAU,QAAQ,KAAK,IAAI,IAAI,KAAK,MAAM,CAAC;AAC5E,MAAI,CAAC,WAAW;AACd,YAAQ,MAAM,uBAAuB,EAAE,MAAM,SAAS,CAAC;AACvD;AAAA,EACF;AAEA,YAAU,eAAe,CAAC;AAC1B,YAAU,WAAW,KAAK;AAAA,IACxB,MAAM,QAAQ;AAAA,IACd,IAAI;AAAA,IACJ,UAAU,SAAS,SAAS,OAAO;AAAA,IACnC,UAAU;AAAA,MACR,CAAC,KAAK,UAAU,GAAG;AAAA,QACjB,OAAO,QAAQ;AAAA;AAAA,QAEf,cAAc;AAAA,MAChB;AAAA,IACF;AAAA,EACF,CAAC;AACD;AACF;AAkBO,MAAM,iCAAiC,CAC5C,UACA,EAAE,MAAM,MAAM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CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,GAC/B,UAAU,iBAAiB,GAAG,IAAI,EAClC,SAAS,YAAY,CAAC,wBAAwB,CAAC,KAC9C,MAAM,GAAG,SAiBX,CAAA;AAED,eAAO,MAAM,qBAAqB,GAAI,cAAc;IAAE,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAAA;CAAE;;4BAG9D,YAAY,CAAC,sBAAsB,CAAC;4BACpC,YAAY,CAAC,sBAAsB,CAAC;qCAC3B,YAAY,CAAC,yBAAyB,CAAC;oCAExC,YAAY,CAAC,wBAAwB,CAAC;CAEzE,CAAA"}
@@ -1,4 +1,5 @@
1
1
  import { findVariables } from "@scalar/helpers/regex/find-variables";
2
+ import { unpackProxyObject } from "../helpers/unpack-proxy.js";
2
3
  import { coerceValue } from "../schemas/typebox-coerce.js";
3
4
  import { ServerObjectSchema } from "../schemas/v3.1/strict/openapi-document.js";
4
5
  const addServer = (document) => {
@@ -53,7 +54,10 @@ const syncVariablesForUrlChange = (newUrl, oldUrl, existingVariables) => {
53
54
  return syncedVariables;
54
55
  };
55
56
  const updateServer = (document, { index, server }) => {
56
- const oldServer = document?.servers?.[index];
57
+ if (!document) {
58
+ return void 0;
59
+ }
60
+ const oldServer = unpackProxyObject(document.servers?.[index], { depth: 1 });
57
61
  if (!oldServer) {
58
62
  console.error("Server not found at index:", index);
59
63
  return void 0;