@scalar/workspace-store 0.20.0 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/README.md +2 -2
- package/dist/client.d.ts +40 -4
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +58 -23
- package/dist/client.js.map +2 -2
- package/dist/events/bus.d.ts +13 -1
- package/dist/events/bus.d.ts.map +1 -1
- package/dist/events/bus.js +46 -10
- package/dist/events/bus.js.map +3 -3
- package/dist/events/definitions/cookie.d.ts +20 -0
- package/dist/events/definitions/cookie.d.ts.map +1 -0
- package/dist/events/definitions/cookie.js +1 -0
- package/dist/events/definitions/cookie.js.map +7 -0
- package/dist/events/definitions/document.d.ts +8 -2
- package/dist/events/definitions/document.d.ts.map +1 -1
- package/dist/events/definitions/index.d.ts +4 -1
- package/dist/events/definitions/index.d.ts.map +1 -1
- package/dist/events/definitions/operation.d.ts +0 -13
- package/dist/events/definitions/operation.d.ts.map +1 -1
- package/dist/events/definitions/server.d.ts +2 -2
- package/dist/events/definitions/server.d.ts.map +1 -1
- package/dist/events/definitions/tabs.d.ts +40 -0
- package/dist/events/definitions/tabs.d.ts.map +1 -0
- package/dist/events/definitions/tabs.js +1 -0
- package/dist/events/definitions/tabs.js.map +7 -0
- package/dist/events/definitions/ui.d.ts +39 -4
- package/dist/events/definitions/ui.d.ts.map +1 -1
- package/dist/events/definitions/workspace.d.ts +18 -0
- package/dist/events/definitions/workspace.d.ts.map +1 -0
- package/dist/events/definitions/workspace.js +1 -0
- package/dist/events/definitions/workspace.js.map +7 -0
- package/dist/helpers/generate-unique-value.d.ts +19 -6
- package/dist/helpers/generate-unique-value.d.ts.map +1 -1
- package/dist/helpers/generate-unique-value.js +12 -7
- package/dist/helpers/generate-unique-value.js.map +2 -2
- package/dist/helpers/unpack-proxy.d.ts +14 -1
- package/dist/helpers/unpack-proxy.d.ts.map +1 -1
- package/dist/helpers/unpack-proxy.js +51 -1
- package/dist/helpers/unpack-proxy.js.map +3 -3
- package/dist/mutators/auth.d.ts +1 -1
- package/dist/mutators/auth.d.ts.map +1 -1
- package/dist/mutators/auth.js +24 -21
- package/dist/mutators/auth.js.map +2 -2
- package/dist/mutators/cookie.d.ts +21 -13
- package/dist/mutators/cookie.d.ts.map +1 -1
- package/dist/mutators/cookie.js +34 -26
- package/dist/mutators/cookie.js.map +3 -3
- package/dist/mutators/document.d.ts +9 -2
- package/dist/mutators/document.d.ts.map +1 -1
- package/dist/mutators/document.js +18 -3
- package/dist/mutators/document.js.map +2 -2
- package/dist/mutators/index.d.ts +4 -14
- package/dist/mutators/index.d.ts.map +1 -1
- package/dist/mutators/index.js +15 -9
- package/dist/mutators/index.js.map +2 -2
- package/dist/mutators/operation.d.ts +23 -101
- package/dist/mutators/operation.d.ts.map +1 -1
- package/dist/mutators/operation.js +132 -96
- package/dist/mutators/operation.js.map +2 -2
- package/dist/mutators/server.d.ts +1 -1
- package/dist/mutators/server.d.ts.map +1 -1
- package/dist/mutators/server.js +6 -5
- package/dist/mutators/server.js.map +2 -2
- package/dist/mutators/workspace.d.ts +6 -0
- package/dist/mutators/workspace.d.ts.map +1 -0
- package/dist/mutators/workspace.js +24 -0
- package/dist/mutators/workspace.js.map +7 -0
- package/dist/navigation/get-navigation-options.d.ts.map +1 -1
- package/dist/navigation/get-navigation-options.js +4 -4
- package/dist/navigation/get-navigation-options.js.map +2 -2
- package/dist/navigation/helpers/traverse-document.d.ts +1 -0
- package/dist/navigation/helpers/traverse-document.d.ts.map +1 -1
- package/dist/navigation/helpers/traverse-document.js +16 -2
- package/dist/navigation/helpers/traverse-document.js.map +2 -2
- package/dist/navigation/helpers/traverse-examples.js +2 -2
- package/dist/navigation/helpers/traverse-examples.js.map +2 -2
- package/dist/navigation/helpers/traverse-paths.d.ts +6 -3
- package/dist/navigation/helpers/traverse-paths.d.ts.map +1 -1
- package/dist/navigation/helpers/traverse-paths.js +4 -9
- package/dist/navigation/helpers/traverse-paths.js.map +2 -2
- package/dist/navigation/helpers/traverse-tags.d.ts +0 -1
- package/dist/navigation/helpers/traverse-tags.d.ts.map +1 -1
- package/dist/navigation/helpers/traverse-tags.js +57 -49
- package/dist/navigation/helpers/traverse-tags.js.map +3 -3
- package/dist/persistence/index.d.ts +6 -0
- package/dist/persistence/index.d.ts.map +1 -1
- package/dist/persistence/index.js +18 -0
- package/dist/persistence/index.js.map +2 -2
- package/dist/persistence/indexdb.d.ts +1 -0
- package/dist/persistence/indexdb.d.ts.map +1 -1
- package/dist/persistence/indexdb.js +6 -1
- package/dist/persistence/indexdb.js.map +2 -2
- package/dist/plugins/client/persistence.d.ts.map +1 -1
- package/dist/plugins/client/persistence.js +6 -0
- package/dist/plugins/client/persistence.js.map +2 -2
- package/dist/schemas/extensions/document/x-scalar-environments.d.ts +1 -0
- package/dist/schemas/extensions/document/x-scalar-environments.d.ts.map +1 -1
- package/dist/schemas/extensions/document/x-scalar-environments.js.map +2 -2
- package/dist/schemas/extensions/document/x-scalar-set-operation-security.d.ts +13 -0
- package/dist/schemas/extensions/document/x-scalar-set-operation-security.d.ts.map +1 -0
- package/dist/schemas/extensions/document/x-scalar-set-operation-security.js +8 -0
- package/dist/schemas/extensions/document/x-scalar-set-operation-security.js.map +7 -0
- package/dist/schemas/extensions/general/x-scalar-cookies.d.ts +36 -0
- package/dist/schemas/extensions/general/x-scalar-cookies.d.ts.map +1 -0
- package/dist/schemas/extensions/general/x-scalar-cookies.js +15 -0
- package/dist/schemas/extensions/general/x-scalar-cookies.js.map +7 -0
- package/dist/schemas/extensions/general/x-scalar-order.d.ts +12 -0
- package/dist/schemas/extensions/general/x-scalar-order.d.ts.map +1 -0
- package/dist/schemas/extensions/general/x-scalar-order.js +8 -0
- package/dist/schemas/extensions/general/x-scalar-order.js.map +7 -0
- package/dist/schemas/extensions/tag/x-tag-groups.d.ts +10 -5
- package/dist/schemas/extensions/tag/x-tag-groups.d.ts.map +1 -1
- package/dist/schemas/extensions/tag/x-tag-groups.js +15 -10
- package/dist/schemas/extensions/tag/x-tag-groups.js.map +2 -2
- package/dist/schemas/extensions/workspace/x-scalar-active-proxy.d.ts +18 -0
- package/dist/schemas/extensions/workspace/x-scalar-active-proxy.d.ts.map +1 -0
- package/dist/schemas/extensions/workspace/x-scalar-active-proxy.js +8 -0
- package/dist/schemas/extensions/workspace/x-scalar-active-proxy.js.map +7 -0
- package/dist/schemas/extensions.d.ts +1 -1
- package/dist/schemas/extensions.js +1 -1
- package/dist/schemas/extensions.js.map +2 -2
- package/dist/schemas/inmemory-workspace.d.ts +41 -27
- package/dist/schemas/inmemory-workspace.d.ts.map +1 -1
- package/dist/schemas/navigation.d.ts +4 -1
- package/dist/schemas/navigation.d.ts.map +1 -1
- package/dist/schemas/navigation.js +2 -1
- package/dist/schemas/navigation.js.map +2 -2
- package/dist/schemas/reference-config/index.d.ts +20 -13
- package/dist/schemas/reference-config/index.d.ts.map +1 -1
- package/dist/schemas/reference-config/settings.d.ts +20 -13
- package/dist/schemas/reference-config/settings.d.ts.map +1 -1
- package/dist/schemas/reference-config/settings.js +2 -0
- package/dist/schemas/reference-config/settings.js.map +2 -2
- package/dist/schemas/v3.1/strict/openapi-document.d.ts +685 -448
- package/dist/schemas/v3.1/strict/openapi-document.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/openapi-document.js +10 -10
- package/dist/schemas/v3.1/strict/openapi-document.js.map +2 -2
- package/dist/schemas/v3.1/strict/operation.d.ts +1 -5
- package/dist/schemas/v3.1/strict/operation.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/operation.js +1 -5
- package/dist/schemas/v3.1/strict/operation.js.map +2 -2
- package/dist/schemas/v3.1/strict/tag.d.ts +4 -1
- package/dist/schemas/v3.1/strict/tag.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/tag.js +3 -1
- package/dist/schemas/v3.1/strict/tag.js.map +2 -2
- package/dist/schemas/v3.1/strict/type-guards.d.ts +6 -0
- package/dist/schemas/v3.1/strict/type-guards.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/type-guards.js +4 -0
- package/dist/schemas/v3.1/strict/type-guards.js.map +2 -2
- package/dist/schemas/workspace-specification/config.d.ts +20 -13
- package/dist/schemas/workspace-specification/config.d.ts.map +1 -1
- package/dist/schemas/workspace-specification/index.d.ts +21 -14
- package/dist/schemas/workspace-specification/index.d.ts.map +1 -1
- package/dist/schemas/workspace.d.ts +170 -109
- package/dist/schemas/workspace.d.ts.map +1 -1
- package/dist/schemas/workspace.js +8 -6
- package/dist/schemas/workspace.js.map +2 -2
- package/dist/server.d.ts +1 -1
- package/dist/workspace-plugin.d.ts +3 -0
- package/dist/workspace-plugin.d.ts.map +1 -1
- package/package.json +8 -7
- package/dist/schemas/extensions/document/x-scalar-document-security.d.ts +0 -13
- package/dist/schemas/extensions/document/x-scalar-document-security.d.ts.map +0 -1
- package/dist/schemas/extensions/document/x-scalar-document-security.js +0 -8
- package/dist/schemas/extensions/document/x-scalar-document-security.js.map +0 -7
- package/dist/schemas/extensions/operation/x-scalar-operation-identifiers.d.ts +0 -13
- package/dist/schemas/extensions/operation/x-scalar-operation-identifiers.d.ts.map +0 -1
- package/dist/schemas/extensions/operation/x-scalar-operation-identifiers.js +0 -9
- package/dist/schemas/extensions/operation/x-scalar-operation-identifiers.js.map +0 -7
- package/dist/schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-cookies.d.ts +0 -32
- package/dist/schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-cookies.d.ts.map +0 -1
- package/dist/schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-cookies.js +0 -13
- package/dist/schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-cookies.js.map +0 -7
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { HttpMethod } from '@scalar/helpers/http/http-methods';
|
|
2
|
+
import type { OperationEvents } from '../events/definitions/operation.js';
|
|
2
3
|
import type { WorkspaceDocument } from '../schemas.js';
|
|
3
4
|
/**
|
|
4
5
|
* Describes the minimal identity for an operation in the workspace document.
|
|
@@ -38,20 +39,15 @@ export type OperationExampleMeta = OperationMeta & {
|
|
|
38
39
|
*
|
|
39
40
|
* Example:
|
|
40
41
|
* ```ts
|
|
41
|
-
* updateOperationSummary(
|
|
42
|
+
* updateOperationSummary(
|
|
42
43
|
* document,
|
|
44
|
+
* {
|
|
43
45
|
* meta: { method: 'get', path: '/users/{id}' },
|
|
44
46
|
* payload: { summary: 'Get a single user' },
|
|
45
47
|
* })
|
|
46
48
|
* ```
|
|
47
49
|
*/
|
|
48
|
-
export declare const updateOperationSummary: (
|
|
49
|
-
document: WorkspaceDocument | null;
|
|
50
|
-
payload: {
|
|
51
|
-
summary: string;
|
|
52
|
-
};
|
|
53
|
-
meta: OperationMeta;
|
|
54
|
-
}) => void;
|
|
50
|
+
export declare const updateOperationSummary: (document: WorkspaceDocument | null, { meta, payload: { summary } }: OperationEvents["operation:update:summary"]) => void;
|
|
55
51
|
/**
|
|
56
52
|
* Stores the chosen HTTP method under `x-scalar-method` on the operation.
|
|
57
53
|
* This does not move the operation to a different method slot under `paths`;
|
|
@@ -67,36 +63,25 @@ export declare const updateOperationSummary: ({ document, meta, payload: { summa
|
|
|
67
63
|
* })
|
|
68
64
|
* ```
|
|
69
65
|
*/
|
|
70
|
-
export declare const
|
|
71
|
-
document: WorkspaceDocument | null;
|
|
72
|
-
payload: {
|
|
73
|
-
method: HttpMethod;
|
|
74
|
-
};
|
|
75
|
-
meta: OperationMeta;
|
|
76
|
-
}) => void;
|
|
66
|
+
export declare const updateOperationMethod: (document: WorkspaceDocument | null, { meta, payload: { method } }: OperationEvents["operation:update:method"]) => void;
|
|
77
67
|
/**
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
68
|
+
* Moves the operation to a new path in the document and synchronizes path
|
|
69
|
+
* parameters in `operation.parameters` with the placeholders present in the
|
|
70
|
+
* provided `path` (e.g. `/users/{id}`). When path parameters change,
|
|
71
|
+
* intelligently syncs them by preserving configurations for renamed parameters
|
|
72
|
+
* (detected by position) and existing parameters. Existing non-path parameters
|
|
73
|
+
* are preserved. The operation is removed from the old path location.
|
|
83
74
|
*
|
|
84
75
|
* Example:
|
|
85
76
|
* ```ts
|
|
86
|
-
*
|
|
77
|
+
* updateOperationPath({
|
|
87
78
|
* document,
|
|
88
79
|
* meta: { method: 'get', path: '/users/{id}' },
|
|
89
|
-
* payload: { path: '/users/{
|
|
80
|
+
* payload: { path: '/users/{userId}' },
|
|
90
81
|
* })
|
|
91
82
|
* ```
|
|
92
83
|
*/
|
|
93
|
-
export declare const
|
|
94
|
-
document: WorkspaceDocument | null;
|
|
95
|
-
payload: {
|
|
96
|
-
path: string;
|
|
97
|
-
};
|
|
98
|
-
meta: OperationMeta;
|
|
99
|
-
}) => void;
|
|
84
|
+
export declare const updateOperationPath: (document: WorkspaceDocument | null, { meta, payload: { path } }: OperationEvents["operation:update:path"]) => void;
|
|
100
85
|
/** ------------------------------------------------------------------------------------------------
|
|
101
86
|
* Operation Parameters Mutators
|
|
102
87
|
* ------------------------------------------------------------------------------------------------ */
|
|
@@ -115,16 +100,7 @@ export declare const updateOperationPathDraft: ({ document, meta, payload: { pat
|
|
|
115
100
|
* })
|
|
116
101
|
* ```
|
|
117
102
|
*/
|
|
118
|
-
export declare const addOperationParameter: (
|
|
119
|
-
document: WorkspaceDocument | null;
|
|
120
|
-
type: "header" | "path" | "query" | "cookie";
|
|
121
|
-
payload: {
|
|
122
|
-
key: string;
|
|
123
|
-
value: string;
|
|
124
|
-
isEnabled: boolean;
|
|
125
|
-
};
|
|
126
|
-
meta: OperationExampleMeta;
|
|
127
|
-
}) => void;
|
|
103
|
+
export declare const addOperationParameter: (document: WorkspaceDocument | null, { meta, payload, type }: OperationEvents["operation:add:parameter"]) => void;
|
|
128
104
|
/**
|
|
129
105
|
* Updates an existing parameter of a given `type` by its index within that
|
|
130
106
|
* type subset (e.g. the N-th query parameter). Supports updating name, value,
|
|
@@ -142,17 +118,7 @@ export declare const addOperationParameter: ({ document, meta, payload, type, }:
|
|
|
142
118
|
* })
|
|
143
119
|
* ```
|
|
144
120
|
*/
|
|
145
|
-
export declare const updateOperationParameter: (
|
|
146
|
-
document: WorkspaceDocument | null;
|
|
147
|
-
type: "header" | "path" | "query" | "cookie";
|
|
148
|
-
index: number;
|
|
149
|
-
payload: Partial<{
|
|
150
|
-
key: string;
|
|
151
|
-
value: string;
|
|
152
|
-
isEnabled: boolean;
|
|
153
|
-
}>;
|
|
154
|
-
meta: OperationExampleMeta;
|
|
155
|
-
}) => void;
|
|
121
|
+
export declare const updateOperationParameter: (document: WorkspaceDocument | null, { meta, type, payload, index }: OperationEvents["operation:update:parameter"]) => void;
|
|
156
122
|
/**
|
|
157
123
|
* Removes a parameter from the operation by resolving its position within
|
|
158
124
|
* the filtered list of parameters of the specified `type`.
|
|
@@ -168,12 +134,7 @@ export declare const updateOperationParameter: ({ document, meta, type, payload,
|
|
|
168
134
|
* })
|
|
169
135
|
* ```
|
|
170
136
|
*/
|
|
171
|
-
export declare const deleteOperationParameter: (
|
|
172
|
-
document: WorkspaceDocument | null;
|
|
173
|
-
type: "header" | "path" | "query" | "cookie";
|
|
174
|
-
index: number;
|
|
175
|
-
meta: OperationExampleMeta;
|
|
176
|
-
}) => void;
|
|
137
|
+
export declare const deleteOperationParameter: (document: WorkspaceDocument | null, { meta, index, type }: OperationEvents["operation:delete:parameter"]) => void;
|
|
177
138
|
/**
|
|
178
139
|
* Deletes all parameters of a given `type` from the operation.
|
|
179
140
|
* Safely no-ops if the document or operation does not exist.
|
|
@@ -187,11 +148,7 @@ export declare const deleteOperationParameter: ({ document, meta, index, type, }
|
|
|
187
148
|
* })
|
|
188
149
|
* ```
|
|
189
150
|
*/
|
|
190
|
-
export declare const deleteAllOperationParameters: (
|
|
191
|
-
document: WorkspaceDocument | null;
|
|
192
|
-
type: "header" | "path" | "query" | "cookie";
|
|
193
|
-
meta: OperationMeta;
|
|
194
|
-
}) => void;
|
|
151
|
+
export declare const deleteAllOperationParameters: (document: WorkspaceDocument | null, { meta, type }: OperationEvents["operation:delete-all:parameters"]) => void;
|
|
195
152
|
/** ------------------------------------------------------------------------------------------------
|
|
196
153
|
* Operation Request Body Mutators
|
|
197
154
|
* ------------------------------------------------------------------------------------------------ */
|
|
@@ -209,13 +166,7 @@ export declare const deleteAllOperationParameters: ({ document, meta, type, }: {
|
|
|
209
166
|
* })
|
|
210
167
|
* ```
|
|
211
168
|
*/
|
|
212
|
-
export declare const updateOperationRequestBodyContentType: (
|
|
213
|
-
document: WorkspaceDocument | null;
|
|
214
|
-
payload: {
|
|
215
|
-
contentType: string;
|
|
216
|
-
};
|
|
217
|
-
meta: OperationExampleMeta;
|
|
218
|
-
}) => void;
|
|
169
|
+
export declare const updateOperationRequestBodyContentType: (document: WorkspaceDocument | null, { meta, payload }: OperationEvents["operation:update:requestBody:contentType"]) => void;
|
|
219
170
|
/**
|
|
220
171
|
* Creates or updates a concrete example value for a specific request-body
|
|
221
172
|
* `contentType` and `exampleKey`. Safely no-ops if the document or operation
|
|
@@ -231,14 +182,7 @@ export declare const updateOperationRequestBodyContentType: ({ document, meta, p
|
|
|
231
182
|
* })
|
|
232
183
|
* ```
|
|
233
184
|
*/
|
|
234
|
-
export declare const updateOperationRequestBodyExample: (
|
|
235
|
-
document: WorkspaceDocument | null;
|
|
236
|
-
contentType: string;
|
|
237
|
-
payload: {
|
|
238
|
-
value: string | File | undefined;
|
|
239
|
-
};
|
|
240
|
-
meta: OperationExampleMeta;
|
|
241
|
-
}) => void;
|
|
185
|
+
export declare const updateOperationRequestBodyExample: (document: WorkspaceDocument | null, { meta, payload, contentType }: OperationEvents["operation:update:requestBody:value"]) => void;
|
|
242
186
|
/**
|
|
243
187
|
* Appends a form-data row to the request-body example identified by
|
|
244
188
|
* `contentType` and `exampleKey`. Initializes the example as an array when
|
|
@@ -254,15 +198,7 @@ export declare const updateOperationRequestBodyExample: ({ document, meta, paylo
|
|
|
254
198
|
* })
|
|
255
199
|
* ```
|
|
256
200
|
*/
|
|
257
|
-
export declare const addOperationRequestBodyFormRow: (
|
|
258
|
-
document: WorkspaceDocument | null;
|
|
259
|
-
payload: Partial<{
|
|
260
|
-
key: string;
|
|
261
|
-
value?: string | File;
|
|
262
|
-
}>;
|
|
263
|
-
contentType: string;
|
|
264
|
-
meta: OperationExampleMeta;
|
|
265
|
-
}) => void;
|
|
201
|
+
export declare const addOperationRequestBodyFormRow: (document: WorkspaceDocument | null, { meta, payload, contentType }: OperationEvents["operation:add:requestBody:formRow"]) => void;
|
|
266
202
|
/**
|
|
267
203
|
* Updates a form-data row at a given `index` for the specified example and
|
|
268
204
|
* `contentType`. Setting `payload.value` to `null` clears the value (sets to
|
|
@@ -279,16 +215,7 @@ export declare const addOperationRequestBodyFormRow: ({ document, meta, payload,
|
|
|
279
215
|
* })
|
|
280
216
|
* ```
|
|
281
217
|
*/
|
|
282
|
-
export declare const updateOperationRequestBodyFormRow: (
|
|
283
|
-
document: WorkspaceDocument | null;
|
|
284
|
-
index: number;
|
|
285
|
-
payload: Partial<{
|
|
286
|
-
key: string;
|
|
287
|
-
value: string | File | null;
|
|
288
|
-
}>;
|
|
289
|
-
contentType: string;
|
|
290
|
-
meta: OperationExampleMeta;
|
|
291
|
-
}) => void;
|
|
218
|
+
export declare const updateOperationRequestBodyFormRow: (document: WorkspaceDocument | null, { meta, index, payload, contentType }: OperationEvents["operation:update:requestBody:formRow"]) => void;
|
|
292
219
|
/**
|
|
293
220
|
* Deletes a form-data row at a given `index` from the example for the given
|
|
294
221
|
* `contentType`. If the example becomes empty, the example entry is removed.
|
|
@@ -304,10 +231,5 @@ export declare const updateOperationRequestBodyFormRow: ({ document, meta, index
|
|
|
304
231
|
* })
|
|
305
232
|
* ```
|
|
306
233
|
*/
|
|
307
|
-
export declare const deleteOperationRequestBodyFormRow: (
|
|
308
|
-
document: WorkspaceDocument | null;
|
|
309
|
-
index: number;
|
|
310
|
-
contentType: string;
|
|
311
|
-
meta: OperationExampleMeta;
|
|
312
|
-
}) => void;
|
|
234
|
+
export declare const deleteOperationRequestBodyFormRow: (document: WorkspaceDocument | null, { meta, index, contentType }: OperationEvents["operation:delete:requestBody:formRow"]) => void;
|
|
313
235
|
//# sourceMappingURL=operation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../../src/mutators/operation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AAGnE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../../src/mutators/operation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AAGnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAGrE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAKlD;;;;;;;;GAQG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,UAAU,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,oBAAoB,GAAG,aAAa,GAAG;IACjD,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AA8GD;;sGAEsG;AAEtG;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,sBAAsB,GACjC,UAAU,iBAAiB,GAAG,IAAI,EAClC,gCAAgC,eAAe,CAAC,0BAA0B,CAAC,SAY5E,CAAA;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,qBAAqB,GAChC,UAAU,iBAAiB,GAAG,IAAI,EAClC,+BAA+B,eAAe,CAAC,yBAAyB,CAAC,SAiB1E,CAAA;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,mBAAmB,GAC9B,UAAU,iBAAiB,GAAG,IAAI,EAClC,6BAA6B,eAAe,CAAC,uBAAuB,CAAC,SAoDtE,CAAA;AAED;;sGAEsG;AAEtG;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,qBAAqB,GAChC,UAAU,iBAAiB,GAAG,IAAI,EAClC,yBAAyB,eAAe,CAAC,yBAAyB,CAAC,SA8BpE,CAAA;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,wBAAwB,GACnC,UAAU,iBAAiB,GAAG,IAAI,EAClC,gCAAgC,eAAe,CAAC,4BAA4B,CAAC,SA8C9E,CAAA;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,wBAAwB,GACnC,UAAU,iBAAiB,GAAG,IAAI,EAClC,uBAAuB,eAAe,CAAC,4BAA4B,CAAC,SAwBrE,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,4BAA4B,GACvC,UAAU,iBAAiB,GAAG,IAAI,EAClC,gBAAgB,eAAe,CAAC,iCAAiC,CAAC,SAanE,CAAA;AAED;;sGAEsG;AAEtG;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,qCAAqC,GAChD,UAAU,iBAAiB,GAAG,IAAI,EAClC,mBAAmB,eAAe,CAAC,0CAA0C,CAAC,SAwB/E,CAAA;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,iCAAiC,GAC5C,UAAU,iBAAiB,GAAG,IAAI,EAClC,gCAAgC,eAAe,CAAC,oCAAoC,CAAC,SAuCtF,CAAA;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,8BAA8B,GACzC,UAAU,iBAAiB,GAAG,IAAI,EAClC,gCAAgC,eAAe,CAAC,mCAAmC,CAAC,SAqDrF,CAAA;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,iCAAiC,GAC5C,UAAU,iBAAiB,GAAG,IAAI,EAClC,uCAAuC,eAAe,CAAC,sCAAsC,CAAC,SAqC/F,CAAA;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,iCAAiC,GAC5C,UAAU,iBAAiB,GAAG,IAAI,EAClC,8BAA8B,eAAe,CAAC,sCAAsC,CAAC,SAmCtF,CAAA"}
|
|
@@ -1,9 +1,73 @@
|
|
|
1
|
+
import { findVariables } from "@scalar/helpers/regex/find-variables";
|
|
1
2
|
import { getResolvedRef } from "../helpers/get-resolved-ref.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import { unpackProxyObject } from "../helpers/unpack-proxy.js";
|
|
4
|
+
import { isContentTypeParameterObject } from "../schemas/v3.1/strict/type-guards.js";
|
|
5
|
+
const getParameterPositions = (path, parameters) => {
|
|
6
|
+
const positions = {};
|
|
7
|
+
for (const paramName of parameters) {
|
|
8
|
+
const position = path.indexOf(`{${paramName}}`);
|
|
9
|
+
if (position !== -1) {
|
|
10
|
+
positions[paramName] = position;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return positions;
|
|
14
|
+
};
|
|
15
|
+
const syncParametersForPathChange = (newPath, oldPath, existingParameters) => {
|
|
16
|
+
const oldPathParams = findVariables(oldPath, { includePath: true, includeEnv: false }).filter(
|
|
17
|
+
(v) => v !== void 0
|
|
18
|
+
);
|
|
19
|
+
const newPathParams = findVariables(newPath, { includePath: true, includeEnv: false }).filter(
|
|
20
|
+
(v) => v !== void 0
|
|
21
|
+
);
|
|
22
|
+
const oldPositions = getParameterPositions(oldPath, oldPathParams);
|
|
23
|
+
const newPositions = getParameterPositions(newPath, newPathParams);
|
|
24
|
+
const pathParameters = [];
|
|
25
|
+
const nonPathParameters = [];
|
|
26
|
+
for (const param of existingParameters) {
|
|
27
|
+
const resolved = getResolvedRef(param);
|
|
28
|
+
if (resolved?.in === "path") {
|
|
29
|
+
pathParameters.push(param);
|
|
30
|
+
} else {
|
|
31
|
+
nonPathParameters.push(param);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const existingPathParamsByName = /* @__PURE__ */ new Map();
|
|
35
|
+
for (const param of pathParameters) {
|
|
36
|
+
const resolved = getResolvedRef(param);
|
|
37
|
+
if (resolved?.name) {
|
|
38
|
+
existingPathParamsByName.set(resolved.name, param);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const usedOldParams = /* @__PURE__ */ new Set();
|
|
42
|
+
const syncedPathParameters = [];
|
|
43
|
+
for (const newParamName of newPathParams) {
|
|
44
|
+
if (existingPathParamsByName.has(newParamName)) {
|
|
45
|
+
syncedPathParameters.push(existingPathParamsByName.get(newParamName));
|
|
46
|
+
usedOldParams.add(newParamName);
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
const newParamPosition = newPositions[newParamName];
|
|
50
|
+
const oldParamAtPosition = oldPathParams.find(
|
|
51
|
+
(oldParam) => oldPositions[oldParam] === newParamPosition && !usedOldParams.has(oldParam)
|
|
52
|
+
);
|
|
53
|
+
if (oldParamAtPosition && existingPathParamsByName.has(oldParamAtPosition)) {
|
|
54
|
+
const oldParam = existingPathParamsByName.get(oldParamAtPosition);
|
|
55
|
+
const resolved = getResolvedRef(oldParam);
|
|
56
|
+
if (resolved) {
|
|
57
|
+
resolved.name = newParamName;
|
|
58
|
+
syncedPathParameters.push(oldParam);
|
|
59
|
+
usedOldParams.add(oldParamAtPosition);
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
syncedPathParameters.push({
|
|
64
|
+
name: newParamName,
|
|
65
|
+
in: "path"
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
return [...syncedPathParameters, ...nonPathParameters];
|
|
69
|
+
};
|
|
70
|
+
const updateOperationSummary = (document, { meta, payload: { summary } }) => {
|
|
7
71
|
if (!document) {
|
|
8
72
|
return;
|
|
9
73
|
}
|
|
@@ -13,25 +77,21 @@ const updateOperationSummary = ({
|
|
|
13
77
|
}
|
|
14
78
|
operation.summary = summary;
|
|
15
79
|
};
|
|
16
|
-
const
|
|
17
|
-
document
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}) => {
|
|
21
|
-
if (!document) {
|
|
80
|
+
const updateOperationMethod = (document, { meta, payload: { method } }) => {
|
|
81
|
+
const operation = getResolvedRef(document?.paths?.[meta.path]?.[meta.method]);
|
|
82
|
+
if (!operation) {
|
|
83
|
+
console.error("Operation not found", { meta, document });
|
|
22
84
|
return;
|
|
23
85
|
}
|
|
24
|
-
const
|
|
25
|
-
if (!
|
|
86
|
+
const path = document?.paths?.[meta.path];
|
|
87
|
+
if (!path) {
|
|
88
|
+
console.error("Path not found", { meta, document });
|
|
26
89
|
return;
|
|
27
90
|
}
|
|
28
|
-
|
|
91
|
+
path[method] = unpackProxyObject(operation);
|
|
92
|
+
delete path[meta.method];
|
|
29
93
|
};
|
|
30
|
-
const
|
|
31
|
-
document,
|
|
32
|
-
meta,
|
|
33
|
-
payload: { path }
|
|
34
|
-
}) => {
|
|
94
|
+
const updateOperationPath = (document, { meta, payload: { path } }) => {
|
|
35
95
|
if (!document) {
|
|
36
96
|
return;
|
|
37
97
|
}
|
|
@@ -39,24 +99,35 @@ const updateOperationPathDraft = ({
|
|
|
39
99
|
if (!operation) {
|
|
40
100
|
return;
|
|
41
101
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
102
|
+
if (meta.path === path) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const oldPathParams = findVariables(meta.path, { includePath: true, includeEnv: false }).filter(
|
|
106
|
+
(v) => v !== void 0
|
|
107
|
+
);
|
|
108
|
+
const newPathParams = findVariables(path, { includePath: true, includeEnv: false }).filter(
|
|
109
|
+
(v) => v !== void 0
|
|
110
|
+
);
|
|
111
|
+
if (oldPathParams.length > 0 || newPathParams.length > 0) {
|
|
112
|
+
const existingParameters = operation.parameters ?? [];
|
|
113
|
+
operation.parameters = syncParametersForPathChange(path, meta.path, existingParameters);
|
|
114
|
+
}
|
|
115
|
+
if (!document.paths) {
|
|
116
|
+
document.paths = {};
|
|
117
|
+
}
|
|
118
|
+
if (!document.paths[path]) {
|
|
119
|
+
document.paths[path] = {};
|
|
120
|
+
}
|
|
121
|
+
document.paths[path][meta.method] = unpackProxyObject(operation);
|
|
122
|
+
const oldPath = document.paths[meta.path];
|
|
123
|
+
if (oldPath) {
|
|
124
|
+
delete oldPath[meta.method];
|
|
125
|
+
if (Object.keys(oldPath).length === 0) {
|
|
126
|
+
delete document.paths[meta.path];
|
|
127
|
+
}
|
|
128
|
+
}
|
|
53
129
|
};
|
|
54
|
-
const addOperationParameter = ({
|
|
55
|
-
document,
|
|
56
|
-
meta,
|
|
57
|
-
payload,
|
|
58
|
-
type
|
|
59
|
-
}) => {
|
|
130
|
+
const addOperationParameter = (document, { meta, payload, type }) => {
|
|
60
131
|
if (!document) {
|
|
61
132
|
return;
|
|
62
133
|
}
|
|
@@ -79,13 +150,7 @@ const addOperationParameter = ({
|
|
|
79
150
|
}
|
|
80
151
|
});
|
|
81
152
|
};
|
|
82
|
-
const updateOperationParameter = ({
|
|
83
|
-
document,
|
|
84
|
-
meta,
|
|
85
|
-
type,
|
|
86
|
-
payload,
|
|
87
|
-
index
|
|
88
|
-
}) => {
|
|
153
|
+
const updateOperationParameter = (document, { meta, type, payload, index }) => {
|
|
89
154
|
if (!document) {
|
|
90
155
|
return;
|
|
91
156
|
}
|
|
@@ -99,24 +164,24 @@ const updateOperationParameter = ({
|
|
|
99
164
|
return;
|
|
100
165
|
}
|
|
101
166
|
parameter.name = payload.key ?? parameter.name ?? "";
|
|
102
|
-
if (
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
167
|
+
if (isContentTypeParameterObject(parameter)) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
if (!parameter.examples) {
|
|
171
|
+
parameter.examples = {};
|
|
172
|
+
}
|
|
173
|
+
const example = getResolvedRef(parameter.examples[meta.exampleKey]);
|
|
174
|
+
if (!example) {
|
|
175
|
+
parameter.examples[meta.exampleKey] = {
|
|
176
|
+
value: payload.value ?? "",
|
|
177
|
+
"x-disabled": payload.isEnabled === void 0 ? false : !payload.isEnabled
|
|
178
|
+
};
|
|
179
|
+
return;
|
|
112
180
|
}
|
|
181
|
+
example.value = payload.value ?? example?.value ?? "";
|
|
182
|
+
example["x-disabled"] = payload.isEnabled === void 0 ? example["x-disabled"] : !payload.isEnabled;
|
|
113
183
|
};
|
|
114
|
-
const deleteOperationParameter = ({
|
|
115
|
-
document,
|
|
116
|
-
meta,
|
|
117
|
-
index,
|
|
118
|
-
type
|
|
119
|
-
}) => {
|
|
184
|
+
const deleteOperationParameter = (document, { meta, index, type }) => {
|
|
120
185
|
if (!document) {
|
|
121
186
|
return;
|
|
122
187
|
}
|
|
@@ -132,11 +197,7 @@ const deleteOperationParameter = ({
|
|
|
132
197
|
const actualIndex = operation.parameters?.findIndex((it) => getResolvedRef(it) === parameter);
|
|
133
198
|
operation.parameters?.splice(actualIndex, 1);
|
|
134
199
|
};
|
|
135
|
-
const deleteAllOperationParameters = ({
|
|
136
|
-
document,
|
|
137
|
-
meta,
|
|
138
|
-
type
|
|
139
|
-
}) => {
|
|
200
|
+
const deleteAllOperationParameters = (document, { meta, type }) => {
|
|
140
201
|
if (!document) {
|
|
141
202
|
return;
|
|
142
203
|
}
|
|
@@ -146,11 +207,7 @@ const deleteAllOperationParameters = ({
|
|
|
146
207
|
}
|
|
147
208
|
operation.parameters = operation.parameters?.filter((it) => getResolvedRef(it).in !== type) ?? [];
|
|
148
209
|
};
|
|
149
|
-
const updateOperationRequestBodyContentType = ({
|
|
150
|
-
document,
|
|
151
|
-
meta,
|
|
152
|
-
payload
|
|
153
|
-
}) => {
|
|
210
|
+
const updateOperationRequestBodyContentType = (document, { meta, payload }) => {
|
|
154
211
|
if (!document) {
|
|
155
212
|
return;
|
|
156
213
|
}
|
|
@@ -170,12 +227,7 @@ const updateOperationRequestBodyContentType = ({
|
|
|
170
227
|
}
|
|
171
228
|
requestBody["x-scalar-selected-content-type"][meta.exampleKey] = payload.contentType;
|
|
172
229
|
};
|
|
173
|
-
const updateOperationRequestBodyExample = ({
|
|
174
|
-
document,
|
|
175
|
-
meta,
|
|
176
|
-
payload,
|
|
177
|
-
contentType
|
|
178
|
-
}) => {
|
|
230
|
+
const updateOperationRequestBodyExample = (document, { meta, payload, contentType }) => {
|
|
179
231
|
if (!document) {
|
|
180
232
|
return;
|
|
181
233
|
}
|
|
@@ -207,12 +259,7 @@ const updateOperationRequestBodyExample = ({
|
|
|
207
259
|
}
|
|
208
260
|
example.value = payload.value;
|
|
209
261
|
};
|
|
210
|
-
const addOperationRequestBodyFormRow = ({
|
|
211
|
-
document,
|
|
212
|
-
meta,
|
|
213
|
-
payload,
|
|
214
|
-
contentType
|
|
215
|
-
}) => {
|
|
262
|
+
const addOperationRequestBodyFormRow = (document, { meta, payload, contentType }) => {
|
|
216
263
|
if (!document) {
|
|
217
264
|
return;
|
|
218
265
|
}
|
|
@@ -253,13 +300,7 @@ const addOperationRequestBodyFormRow = ({
|
|
|
253
300
|
value: payload.value ?? ""
|
|
254
301
|
});
|
|
255
302
|
};
|
|
256
|
-
const updateOperationRequestBodyFormRow = ({
|
|
257
|
-
document,
|
|
258
|
-
meta,
|
|
259
|
-
index,
|
|
260
|
-
payload,
|
|
261
|
-
contentType
|
|
262
|
-
}) => {
|
|
303
|
+
const updateOperationRequestBodyFormRow = (document, { meta, index, payload, contentType }) => {
|
|
263
304
|
if (!document) {
|
|
264
305
|
return;
|
|
265
306
|
}
|
|
@@ -290,12 +331,7 @@ const updateOperationRequestBodyFormRow = ({
|
|
|
290
331
|
value: payload.value === null ? void 0 : payload.value ?? example.value[index]?.value ?? ""
|
|
291
332
|
};
|
|
292
333
|
};
|
|
293
|
-
const deleteOperationRequestBodyFormRow = ({
|
|
294
|
-
document,
|
|
295
|
-
meta,
|
|
296
|
-
index,
|
|
297
|
-
contentType
|
|
298
|
-
}) => {
|
|
334
|
+
const deleteOperationRequestBodyFormRow = (document, { meta, index, contentType }) => {
|
|
299
335
|
if (!document) {
|
|
300
336
|
return;
|
|
301
337
|
}
|
|
@@ -329,9 +365,9 @@ export {
|
|
|
329
365
|
deleteAllOperationParameters,
|
|
330
366
|
deleteOperationParameter,
|
|
331
367
|
deleteOperationRequestBodyFormRow,
|
|
332
|
-
|
|
368
|
+
updateOperationMethod,
|
|
333
369
|
updateOperationParameter,
|
|
334
|
-
|
|
370
|
+
updateOperationPath,
|
|
335
371
|
updateOperationRequestBodyContentType,
|
|
336
372
|
updateOperationRequestBodyExample,
|
|
337
373
|
updateOperationRequestBodyFormRow,
|