@scalar/workspace-store 0.22.2 → 0.24.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +86 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +3 -2
- package/dist/client.js.map +2 -2
- package/dist/events/definitions/document.d.ts +7 -0
- package/dist/events/definitions/document.d.ts.map +1 -1
- package/dist/events/definitions/hooks.d.ts +25 -0
- package/dist/events/definitions/hooks.d.ts.map +1 -0
- package/dist/events/definitions/hooks.js +1 -0
- package/dist/events/definitions/hooks.js.map +7 -0
- package/dist/events/definitions/index.d.ts +2 -1
- package/dist/events/definitions/index.d.ts.map +1 -1
- package/dist/events/definitions/operation.d.ts +34 -24
- package/dist/events/definitions/operation.d.ts.map +1 -1
- package/dist/events/definitions/tag.d.ts +9 -2
- package/dist/events/definitions/tag.d.ts.map +1 -1
- package/dist/events/definitions/ui.d.ts +20 -10
- package/dist/events/definitions/ui.d.ts.map +1 -1
- package/dist/events/definitions/workspace.d.ts +5 -0
- package/dist/events/definitions/workspace.d.ts.map +1 -1
- package/dist/helpers/is-non-optional-security-requirement.d.ts +4 -0
- package/dist/helpers/is-non-optional-security-requirement.d.ts.map +1 -0
- package/dist/helpers/is-non-optional-security-requirement.js +7 -0
- package/dist/helpers/is-non-optional-security-requirement.js.map +7 -0
- package/dist/helpers/merge-object.d.ts +6 -1
- package/dist/helpers/merge-object.d.ts.map +1 -1
- package/dist/helpers/merge-object.js +4 -3
- package/dist/helpers/merge-object.js.map +2 -2
- package/dist/mutators/auth.d.ts.map +1 -1
- package/dist/mutators/auth.js +2 -1
- package/dist/mutators/auth.js.map +2 -2
- package/dist/mutators/document.d.ts +6 -0
- package/dist/mutators/document.d.ts.map +1 -1
- package/dist/mutators/document.js +7 -0
- package/dist/mutators/document.js.map +2 -2
- package/dist/mutators/index.d.ts +4 -5
- package/dist/mutators/index.d.ts.map +1 -1
- package/dist/mutators/index.js +12 -7
- package/dist/mutators/index.js.map +2 -2
- package/dist/mutators/operation.d.ts +36 -19
- package/dist/mutators/operation.d.ts.map +1 -1
- package/dist/mutators/operation.js +181 -65
- package/dist/mutators/operation.js.map +2 -2
- package/dist/mutators/tabs.js +5 -5
- package/dist/mutators/tabs.js.map +2 -2
- package/dist/mutators/tag.d.ts +12 -0
- package/dist/mutators/tag.d.ts.map +1 -1
- package/dist/mutators/tag.js +40 -3
- package/dist/mutators/tag.js.map +2 -2
- package/dist/mutators/workspace.d.ts +8 -0
- package/dist/mutators/workspace.d.ts.map +1 -1
- package/dist/mutators/workspace.js +7 -0
- package/dist/mutators/workspace.js.map +2 -2
- package/dist/navigation/helpers/get-operation-entries.d.ts +5 -5
- package/dist/navigation/helpers/get-operation-entries.d.ts.map +1 -1
- package/dist/navigation/helpers/get-operation-entries.js.map +2 -2
- package/dist/navigation/index.d.ts +1 -0
- package/dist/navigation/index.d.ts.map +1 -1
- package/dist/navigation/index.js +2 -0
- package/dist/navigation/index.js.map +2 -2
- package/dist/plugins/client/index.d.ts +0 -1
- package/dist/plugins/client/index.d.ts.map +1 -1
- package/dist/plugins/client/index.js.map +2 -2
- package/dist/schemas/extensions/schema/x-examples.d.ts +10 -0
- package/dist/schemas/extensions/schema/x-examples.d.ts.map +1 -0
- package/dist/schemas/extensions/schema/x-examples.js +8 -0
- package/dist/schemas/extensions/schema/x-examples.js.map +7 -0
- package/dist/schemas/inmemory-workspace.d.ts +28 -4
- package/dist/schemas/inmemory-workspace.d.ts.map +1 -1
- package/dist/schemas/reference-config/index.d.ts +16 -4
- package/dist/schemas/reference-config/index.d.ts.map +1 -1
- package/dist/schemas/reference-config/index.js.map +2 -2
- package/dist/schemas/reference-config/settings.d.ts +13 -1
- package/dist/schemas/reference-config/settings.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/openapi-document.d.ts +442 -34
- package/dist/schemas/v3.1/strict/openapi-document.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/schema.d.ts +16 -1
- package/dist/schemas/v3.1/strict/schema.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/schema.js +2 -0
- package/dist/schemas/v3.1/strict/schema.js.map +2 -2
- package/dist/schemas/v3.1/strict/security-requirement.d.ts +4 -4
- package/dist/schemas/v3.1/strict/security-requirement.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/security-requirement.js +6 -4
- package/dist/schemas/v3.1/strict/security-requirement.js.map +2 -2
- package/dist/schemas/workspace-specification/config.d.ts +14 -2
- package/dist/schemas/workspace-specification/config.d.ts.map +1 -1
- package/dist/schemas/workspace-specification/index.d.ts +15 -3
- package/dist/schemas/workspace-specification/index.d.ts.map +1 -1
- package/dist/schemas/workspace.d.ts +93 -9
- package/dist/schemas/workspace.d.ts.map +1 -1
- package/package.json +9 -9
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import type { HttpMethod } from '@scalar/helpers/http/http-methods';
|
|
2
2
|
import type { OperationExampleMeta, OperationMeta } from '../../mutators/index.js';
|
|
3
|
-
import type { OperationObject } from '../../schemas/v3.1/strict/
|
|
3
|
+
import type { OperationObject } from '../../schemas/v3.1/strict/openapi-document.js';
|
|
4
4
|
/** Event definitions for the operation */
|
|
5
5
|
export type OperationEvents = {
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
7
|
+
* The hotkey trigger for sending the request
|
|
8
|
+
* We handle this inside of the OperationBlock component so we can build the request first then fire the event
|
|
9
9
|
*/
|
|
10
|
-
'operation:send:request':
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
'operation:send:request:hotkey': undefined;
|
|
11
|
+
/** Cancel the in progress request */
|
|
12
|
+
'operation:cancel:request': undefined;
|
|
13
13
|
/**
|
|
14
14
|
* Create a new operation at a specific path and method in the document.
|
|
15
15
|
* Triggers when the user creates a new endpoint via the command palette or other UI.
|
|
@@ -42,31 +42,40 @@ export type OperationEvents = {
|
|
|
42
42
|
meta: OperationMeta;
|
|
43
43
|
};
|
|
44
44
|
/**
|
|
45
|
-
* Update the HTTP method for the operation.
|
|
46
|
-
* Triggers when the user changes the HTTP verb (e.g., from GET to POST) in the UI for a given operation.
|
|
45
|
+
* Update the HTTP method or path for the operation.
|
|
46
|
+
* Triggers when the user changes the HTTP verb (e.g., from GET to POST) or path in the UI for a given operation.
|
|
47
|
+
* We send the full payload each time
|
|
47
48
|
*/
|
|
48
|
-
'operation:update:
|
|
49
|
+
'operation:update:pathMethod': {
|
|
49
50
|
payload: {
|
|
50
|
-
/** The new method for the operation */
|
|
51
|
+
/** The new or old method for the operation */
|
|
51
52
|
method: HttpMethod;
|
|
53
|
+
/** The new or old path for the operation */
|
|
54
|
+
path: string;
|
|
52
55
|
};
|
|
53
56
|
/** Identifies the target operation by original method and path */
|
|
54
|
-
meta:
|
|
57
|
+
meta: OperationMeta;
|
|
58
|
+
/** Callback, on completion */
|
|
59
|
+
callback: (status: 'conflict' | 'no-change' | 'success') => void;
|
|
55
60
|
};
|
|
56
61
|
/**
|
|
57
|
-
*
|
|
58
|
-
* Triggers when the user changes the endpoint path for a given operation in the UI.
|
|
59
|
-
* - `payload.path` is the new path for the operation.
|
|
60
|
-
* - `meta` identifies the operation by its original method and path.
|
|
62
|
+
* Delete an operation from the workspace
|
|
61
63
|
*/
|
|
62
|
-
'operation:
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
path: string;
|
|
66
|
-
};
|
|
64
|
+
'operation:delete:operation': {
|
|
65
|
+
/** The document name where the operation should be deleted */
|
|
66
|
+
documentName: string;
|
|
67
67
|
/** Identifies the target operation by original method and path */
|
|
68
68
|
meta: OperationMeta;
|
|
69
69
|
};
|
|
70
|
+
/**
|
|
71
|
+
* Delete an example from the operation
|
|
72
|
+
*/
|
|
73
|
+
'operation:delete:example': {
|
|
74
|
+
/** The document name where the operation should be deleted */
|
|
75
|
+
documentName: string;
|
|
76
|
+
/** Identifies the target operation by original method and path */
|
|
77
|
+
meta: OperationExampleMeta;
|
|
78
|
+
};
|
|
70
79
|
/** ------------------------------------------------------------------------------------------------
|
|
71
80
|
* Operation Parameters Mutators
|
|
72
81
|
* ------------------------------------------------------------------------------------------------ */
|
|
@@ -87,7 +96,7 @@ export type OperationEvents = {
|
|
|
87
96
|
/** The example value for the parameter to add */
|
|
88
97
|
value: string;
|
|
89
98
|
/** Whether the parameter is enabled */
|
|
90
|
-
|
|
99
|
+
isDisabled: boolean;
|
|
91
100
|
};
|
|
92
101
|
/** Identifies the target operation and example variant for the added parameter */
|
|
93
102
|
meta: OperationExampleMeta;
|
|
@@ -109,12 +118,12 @@ export type OperationEvents = {
|
|
|
109
118
|
* Partial payload with new properties for the parameter (optional).
|
|
110
119
|
* - key: The new name of the parameter (if being renamed).
|
|
111
120
|
* - value: The new example value for the parameter.
|
|
112
|
-
* -
|
|
121
|
+
* - isDisabled: Whether the parameter is marked as disabled.
|
|
113
122
|
*/
|
|
114
123
|
payload: Partial<{
|
|
115
124
|
key: string;
|
|
116
125
|
value: string;
|
|
117
|
-
|
|
126
|
+
isDisabled: boolean;
|
|
118
127
|
}>;
|
|
119
128
|
/**
|
|
120
129
|
* Identifies the target operation and example variant for the updated parameter.
|
|
@@ -194,7 +203,8 @@ export type OperationEvents = {
|
|
|
194
203
|
/** The payload containing the details of the form-data row to update */
|
|
195
204
|
payload: Partial<{
|
|
196
205
|
key: string;
|
|
197
|
-
value
|
|
206
|
+
value: string | File | null;
|
|
207
|
+
isDisabled: boolean;
|
|
198
208
|
}>;
|
|
199
209
|
/** The content type of the request body */
|
|
200
210
|
contentType: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../../../src/events/definitions/operation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AAEnE,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AACrE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"operation.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ChF,KAAK,EAAE,MAAM,CAAA;QACb,2CAA2C;QAC3C,WAAW,EAAE,MAAM,CAAA;QACnB,wFAAwF;QACxF,IAAI,EAAE,oBAAoB,CAAA;KAC3B,CAAA;CACF,CAAA"}
|
|
@@ -8,8 +8,15 @@ export type TagEvents = {
|
|
|
8
8
|
name: string;
|
|
9
9
|
/** The name of the document to add the tag to */
|
|
10
10
|
documentName: string;
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Delete a tag from the workspace
|
|
14
|
+
*/
|
|
15
|
+
'tag:delete:tag': {
|
|
16
|
+
/** The document to delete the tag from */
|
|
17
|
+
documentName: string;
|
|
18
|
+
/** The name of the tag to delete */
|
|
19
|
+
name: string;
|
|
13
20
|
};
|
|
14
21
|
};
|
|
15
22
|
//# sourceMappingURL=tag.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tag.d.ts","sourceRoot":"","sources":["../../../src/events/definitions/tag.ts"],"names":[],"mappings":"AAAA,mDAAmD;AACnD,MAAM,MAAM,SAAS,GAAG;IACtB;;OAEG;IACH,gBAAgB,EAAE;QAChB,oCAAoC;QACpC,IAAI,EAAE,MAAM,CAAA;QACZ,iDAAiD;QACjD,YAAY,EAAE,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"tag.d.ts","sourceRoot":"","sources":["../../../src/events/definitions/tag.ts"],"names":[],"mappings":"AAAA,mDAAmD;AACnD,MAAM,MAAM,SAAS,GAAG;IACtB;;OAEG;IACH,gBAAgB,EAAE;QAChB,oCAAoC;QACpC,IAAI,EAAE,MAAM,CAAA;QACZ,iDAAiD;QACjD,YAAY,EAAE,MAAM,CAAA;KACrB,CAAA;IACD;;OAEG;IACH,gBAAgB,EAAE;QAChB,0CAA0C;QAC1C,YAAY,EAAE,MAAM,CAAA;QACpB,oCAAoC;QACpC,IAAI,EAAE,MAAM,CAAA;KACb,CAAA;CACF,CAAA"}
|
|
@@ -9,11 +9,24 @@ type CommandPalettePayload = {
|
|
|
9
9
|
/** Create a new document in the workspace */
|
|
10
10
|
'create-document': undefined;
|
|
11
11
|
/** Add a new tag to organize requests */
|
|
12
|
-
'add-tag':
|
|
12
|
+
'add-tag': {
|
|
13
|
+
/** The document id to add the tag to */
|
|
14
|
+
documentId?: string;
|
|
15
|
+
};
|
|
13
16
|
/** Create a new HTTP request */
|
|
14
|
-
'create-request':
|
|
17
|
+
'create-request': {
|
|
18
|
+
/** The document id to create the request in */
|
|
19
|
+
documentId?: string;
|
|
20
|
+
/** The tag id to add the request to (optional) */
|
|
21
|
+
tagId?: string;
|
|
22
|
+
};
|
|
15
23
|
/** Add a new example to an existing request */
|
|
16
|
-
'add-example':
|
|
24
|
+
'add-example': {
|
|
25
|
+
/** The document id to add the example to */
|
|
26
|
+
documentId?: string;
|
|
27
|
+
/** The operation id to add the example to */
|
|
28
|
+
operationId?: string;
|
|
29
|
+
};
|
|
17
30
|
/** Import a request from a cURL command string */
|
|
18
31
|
'import-curl-command': {
|
|
19
32
|
/** The cURL command string to parse and import */
|
|
@@ -71,7 +84,9 @@ export type UIEvents = {
|
|
|
71
84
|
* Focus the address bar input field.
|
|
72
85
|
* Typically triggered by keyboard shortcuts for quick navigation.
|
|
73
86
|
*/
|
|
74
|
-
'ui:focus:address-bar': KeyboardEventPayload
|
|
87
|
+
'ui:focus:address-bar': KeyboardEventPayload | {
|
|
88
|
+
position?: 'start' | 'end' | number;
|
|
89
|
+
} | undefined;
|
|
75
90
|
/**
|
|
76
91
|
* Focus the send button to execute a request.
|
|
77
92
|
* Useful for keyboard-driven workflows.
|
|
@@ -103,12 +118,7 @@ export type UIEvents = {
|
|
|
103
118
|
* Close the API Client modal.
|
|
104
119
|
* Typically triggered by escape key or clicking outside the modal.
|
|
105
120
|
*/
|
|
106
|
-
'ui:close:client-modal': KeyboardEventPayload;
|
|
107
|
-
/**
|
|
108
|
-
* Hide the modal in modal mode.
|
|
109
|
-
* Generic close action for modal display contexts.
|
|
110
|
-
*/
|
|
111
|
-
'hide:modal': undefined;
|
|
121
|
+
'ui:close:client-modal': KeyboardEventPayload | undefined;
|
|
112
122
|
/**
|
|
113
123
|
* Open the command palette.
|
|
114
124
|
* Can optionally pre-fill with a specific action to execute.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../../../src/events/definitions/ui.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AAEnE;;;GAGG;AACH,KAAK,qBAAqB,GAAG;IAC3B,qEAAqE;IACrE,0CAA0C,EAAE,SAAS,CAAA;IACrD,6CAA6C;IAC7C,iBAAiB,EAAE,SAAS,CAAA;IAC5B,yCAAyC;IACzC,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../../../src/events/definitions/ui.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AAEnE;;;GAGG;AACH,KAAK,qBAAqB,GAAG;IAC3B,qEAAqE;IACrE,0CAA0C,EAAE,SAAS,CAAA;IACrD,6CAA6C;IAC7C,iBAAiB,EAAE,SAAS,CAAA;IAC5B,yCAAyC;IACzC,SAAS,EAAE;QACT,wCAAwC;QACxC,UAAU,CAAC,EAAE,MAAM,CAAA;KACpB,CAAA;IACD,gCAAgC;IAChC,gBAAgB,EAAE;QAChB,+CAA+C;QAC/C,UAAU,CAAC,EAAE,MAAM,CAAA;QACnB,kDAAkD;QAClD,KAAK,CAAC,EAAE,MAAM,CAAA;KACf,CAAA;IACD,+CAA+C;IAC/C,aAAa,EAAE;QACb,4CAA4C;QAC5C,UAAU,CAAC,EAAE,MAAM,CAAA;QACnB,6CAA6C;QAC7C,WAAW,CAAC,EAAE,MAAM,CAAA;KACrB,CAAA;IACD,kDAAkD;IAClD,qBAAqB,EAAE;QACrB,kDAAkD;QAClD,IAAI,EAAE,MAA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,SAAS,CAAA;IAM3D;;;OAGG;IACH,iBAAiB,EAAE,qBAAqB,GAAG;QACzC,iEAAiE;QACjE,IAAI,CAAC,EAAE,OAAO,CAAA;KACf,CAAA;IAED;;;;OAIG;IACH,iBAAiB,EAAE,qBAAqB,CAAA;IAExC;;;OAGG;IACH,uBAAuB,EAAE,qBAAqB,CAAA;IAE9C;;;OAGG;IACH,oBAAoB,EAAE,qBAAqB,CAAA;IAE3C;;;OAGG;IACH,mBAAmB,EAAE,qBAAqB,CAAA;CAC3C,CAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ThemeId } from '@scalar/themes';
|
|
2
|
+
import type { AvailableClient } from '@scalar/types/snippetz';
|
|
2
3
|
import type { ColorMode } from '../../schemas/workspace.js';
|
|
3
4
|
/** Event definitions for the openapi document */
|
|
4
5
|
export type WorkspaceEvents = {
|
|
@@ -14,5 +15,9 @@ export type WorkspaceEvents = {
|
|
|
14
15
|
* Update the theme of the workspace
|
|
15
16
|
*/
|
|
16
17
|
'workspace:update:theme': ThemeId;
|
|
18
|
+
/**
|
|
19
|
+
* Update the selected client on the workspace
|
|
20
|
+
*/
|
|
21
|
+
'workspace:update:selected-client': AvailableClient;
|
|
17
22
|
};
|
|
18
23
|
//# 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,OAAO,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../../src/events/definitions/workspace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAC7C,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,OAAO,CAAA;IACjC;;OAEG;IACH,kCAAkC,EAAE,eAAe,CAAA;CACpD,CAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { SecurityRequirementObject } from '../schemas/v3.1/strict/openapi-document.js';
|
|
2
|
+
/** Type guard to determine if a security requirement is non-optional */
|
|
3
|
+
export declare const isNonOptionalSecurityRequirement: (securityRequirement: SecurityRequirementObject | undefined) => securityRequirement is Record<string, string[]>;
|
|
4
|
+
//# sourceMappingURL=is-non-optional-security-requirement.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-non-optional-security-requirement.d.ts","sourceRoot":"","sources":["../../src/helpers/is-non-optional-security-requirement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,wCAAwC,CAAA;AAEvF,wEAAwE;AACxE,eAAO,MAAM,gCAAgC,GAC3C,qBAAqB,yBAAyB,GAAG,SAAS,KACzD,mBAAmB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAEhD,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
const isNonOptionalSecurityRequirement = (securityRequirement) => {
|
|
2
|
+
return securityRequirement !== void 0 && Object.keys(securityRequirement).length > 0;
|
|
3
|
+
};
|
|
4
|
+
export {
|
|
5
|
+
isNonOptionalSecurityRequirement
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=is-non-optional-security-requirement.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/helpers/is-non-optional-security-requirement.ts"],
|
|
4
|
+
"sourcesContent": ["import type { SecurityRequirementObject } from '@/schemas/v3.1/strict/openapi-document'\n\n/** Type guard to determine if a security requirement is non-optional */\nexport const isNonOptionalSecurityRequirement = (\n securityRequirement: SecurityRequirementObject | undefined,\n): securityRequirement is Record<string, string[]> => {\n return securityRequirement !== undefined && Object.keys(securityRequirement).length > 0\n}\n"],
|
|
5
|
+
"mappings": "AAGO,MAAM,mCAAmC,CAC9C,wBACoD;AACpD,SAAO,wBAAwB,UAAa,OAAO,KAAK,mBAAmB,EAAE,SAAS;AACxF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -27,5 +27,10 @@
|
|
|
27
27
|
* const target = { age: 30 }
|
|
28
28
|
* mergeObjects(target, obj) // Safely merges without infinite recursion
|
|
29
29
|
*/
|
|
30
|
-
export declare const mergeObjects: <R>(a: Record<string, unknown>, b: Record<string, unknown>,
|
|
30
|
+
export declare const mergeObjects: <R>(a: Record<string, unknown>, b: Record<string, unknown>,
|
|
31
|
+
/**
|
|
32
|
+
* By default we overwrite array indexes, our store is built on this assumption when coercing the document
|
|
33
|
+
* Alternatively we may want to prevent this behaviour when merging with defaults and replace the whole array instead
|
|
34
|
+
*/
|
|
35
|
+
replaceArrays?: boolean, cache?: Set<unknown>) => R;
|
|
31
36
|
//# sourceMappingURL=merge-object.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge-object.d.ts","sourceRoot":"","sources":["../../src/helpers/merge-object.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,YAAY,GAAI,CAAC,EAC5B,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC1B,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"merge-object.d.ts","sourceRoot":"","sources":["../../src/helpers/merge-object.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,YAAY,GAAI,CAAC,EAC5B,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC1B,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;AAC1B;;;GAGG;AACH,uBAAqB,EACrB,QAAO,GAAG,CAAC,OAAO,CAAa,KAC9B,CA4CF,CAAA"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { getRaw } from "@scalar/json-magic/magic-proxy";
|
|
2
|
-
const mergeObjects = (a, b, cache = /* @__PURE__ */ new Set()) => {
|
|
2
|
+
const mergeObjects = (a, b, replaceArrays = false, cache = /* @__PURE__ */ new Set()) => {
|
|
3
3
|
for (const key in b) {
|
|
4
4
|
if (!(key in a)) {
|
|
5
5
|
a[key] = b[key];
|
|
6
6
|
} else {
|
|
7
7
|
const aValue = a[key];
|
|
8
8
|
const bValue = b[key];
|
|
9
|
-
|
|
9
|
+
const shouldReplaceArrays = replaceArrays && (Array.isArray(aValue) || Array.isArray(bValue));
|
|
10
|
+
if (typeof aValue === "object" && aValue !== null && typeof bValue === "object" && bValue !== null && !shouldReplaceArrays) {
|
|
10
11
|
const rawA = getRaw(aValue);
|
|
11
12
|
const rawB = getRaw(bValue);
|
|
12
13
|
if (cache.has(rawA) || cache.has(rawB)) {
|
|
@@ -14,7 +15,7 @@ const mergeObjects = (a, b, cache = /* @__PURE__ */ new Set()) => {
|
|
|
14
15
|
}
|
|
15
16
|
cache.add(rawA);
|
|
16
17
|
cache.add(rawB);
|
|
17
|
-
mergeObjects(aValue, bValue, cache);
|
|
18
|
+
mergeObjects(aValue, bValue, replaceArrays, cache);
|
|
18
19
|
} else {
|
|
19
20
|
try {
|
|
20
21
|
a[key] = bValue;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/helpers/merge-object.ts"],
|
|
4
|
-
"sourcesContent": ["import { getRaw } from '@scalar/json-magic/magic-proxy'\n\nimport type { UnknownObject } from '@/helpers/general'\n\n/**\n * Deep merges two objects, combining their properties recursively.\n * Handles circular references by tracking visited objects to prevent infinite recursion.\n *\n * \u26A0\uFE0F Note: This operation assumes there are no key collisions between the objects.\n * Use isKeyCollisions() to check for collisions before merging.\n *\n * @param a - Target object to merge into\n * @param b - Source object to merge from\n * @param cache - Set of visited objects to prevent circular reference issues\n * @returns The merged object (mutates and returns a)\n *\n * @example\n * // Simple merge\n * const a = { name: 'John' }\n * const b = { age: 30 }\n * mergeObjects(a, b) // { name: 'John', age: 30 }\n *\n * // Nested merge\n * const a = { user: { name: 'John' } }\n * const b = { user: { age: 30 } }\n * mergeObjects(a, b) // { user: { name: 'John', age: 30 } }\n *\n * // Circular reference safe\n * const obj = { name: 'John' }\n * obj.self = obj\n * const target = { age: 30 }\n * mergeObjects(target, obj) // Safely merges without infinite recursion\n */\nexport const mergeObjects = <R>(\n a: Record<string, unknown>,\n b: Record<string, unknown>,\n cache: Set<unknown> = new Set(),\n): R => {\n for (const key in b) {\n if (!(key in a)) {\n a[key] = b[key]\n } else {\n const aValue = a[key]\n const bValue = b[key]\n\n if (typeof aValue === 'object'
|
|
5
|
-
"mappings": "AAAA,SAAS,cAAc;AAiChB,MAAM,eAAe,CAC1B,GACA,
|
|
4
|
+
"sourcesContent": ["import { getRaw } from '@scalar/json-magic/magic-proxy'\n\nimport type { UnknownObject } from '@/helpers/general'\n\n/**\n * Deep merges two objects, combining their properties recursively.\n * Handles circular references by tracking visited objects to prevent infinite recursion.\n *\n * \u26A0\uFE0F Note: This operation assumes there are no key collisions between the objects.\n * Use isKeyCollisions() to check for collisions before merging.\n *\n * @param a - Target object to merge into\n * @param b - Source object to merge from\n * @param cache - Set of visited objects to prevent circular reference issues\n * @returns The merged object (mutates and returns a)\n *\n * @example\n * // Simple merge\n * const a = { name: 'John' }\n * const b = { age: 30 }\n * mergeObjects(a, b) // { name: 'John', age: 30 }\n *\n * // Nested merge\n * const a = { user: { name: 'John' } }\n * const b = { user: { age: 30 } }\n * mergeObjects(a, b) // { user: { name: 'John', age: 30 } }\n *\n * // Circular reference safe\n * const obj = { name: 'John' }\n * obj.self = obj\n * const target = { age: 30 }\n * mergeObjects(target, obj) // Safely merges without infinite recursion\n */\nexport const mergeObjects = <R>(\n a: Record<string, unknown>,\n b: Record<string, unknown>,\n /**\n * By default we overwrite array indexes, our store is built on this assumption when coercing the document\n * Alternatively we may want to prevent this behaviour when merging with defaults and replace the whole array instead\n */\n replaceArrays = false,\n cache: Set<unknown> = new Set(),\n): R => {\n for (const key in b) {\n if (!(key in a)) {\n a[key] = b[key]\n } else {\n const aValue = a[key]\n const bValue = b[key]\n\n /** Replace whole array instead of replacing each index */\n const shouldReplaceArrays = replaceArrays && (Array.isArray(aValue) || Array.isArray(bValue))\n\n if (\n typeof aValue === 'object' &&\n aValue !== null &&\n typeof bValue === 'object' &&\n bValue !== null &&\n !shouldReplaceArrays\n ) {\n const rawA = getRaw(aValue as UnknownObject)\n const rawB = getRaw(bValue as UnknownObject)\n\n // Check for circular references before recursive merge\n if (cache.has(rawA) || cache.has(rawB)) {\n // Skip merging this branch to prevent infinite recursion\n continue\n }\n\n // Add objects to cache before recursive call\n cache.add(rawA)\n cache.add(rawB)\n\n mergeObjects(aValue as Record<string, unknown>, bValue as Record<string, unknown>, replaceArrays, cache)\n } else {\n try {\n a[key] = bValue // Overwrite with b's value if not an object\n } catch (error) {\n console.warn(`Issue setting ${key} on object`)\n console.warn(error)\n }\n }\n }\n }\n\n return a as R\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,cAAc;AAiChB,MAAM,eAAe,CAC1B,GACA,GAKA,gBAAgB,OAChB,QAAsB,oBAAI,IAAI,MACxB;AACN,aAAW,OAAO,GAAG;AACnB,QAAI,EAAE,OAAO,IAAI;AACf,QAAE,GAAG,IAAI,EAAE,GAAG;AAAA,IAChB,OAAO;AACL,YAAM,SAAS,EAAE,GAAG;AACpB,YAAM,SAAS,EAAE,GAAG;AAGpB,YAAM,sBAAsB,kBAAkB,MAAM,QAAQ,MAAM,KAAK,MAAM,QAAQ,MAAM;AAE3F,UACE,OAAO,WAAW,YAClB,WAAW,QACX,OAAO,WAAW,YAClB,WAAW,QACX,CAAC,qBACD;AACA,cAAM,OAAO,OAAO,MAAuB;AAC3C,cAAM,OAAO,OAAO,MAAuB;AAG3C,YAAI,MAAM,IAAI,IAAI,KAAK,MAAM,IAAI,IAAI,GAAG;AAEtC;AAAA,QACF;AAGA,cAAM,IAAI,IAAI;AACd,cAAM,IAAI,IAAI;AAEd,qBAAa,QAAmC,QAAmC,eAAe,KAAK;AAAA,MACzG,OAAO;AACL,YAAI;AACF,YAAE,GAAG,IAAI;AAAA,QACX,SAAS,OAAO;AACd,kBAAQ,KAAK,iBAAiB,GAAG,YAAY;AAC7C,kBAAQ,KAAK,KAAK;AAAA,QACpB;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/mutators/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AAEnE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/mutators/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AAEnE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AAK3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAGlD;;;;;;GAMG;AACH,MAAM,MAAM,QAAQ,GAChB;IACE,IAAI,EAAE,UAAU,CAAA;CACjB,GACD;IACE,IAAI,EAAE,WAAW,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,UAAU,CAAA;CACnB,CAAA;AAEL;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,6BAA6B,GACxC,UAAU,iBAAiB,GAAG,IAAI,EAClC,4CAA4C,UAAU,CAAC,uCAAuC,CAAC,kBA+EhG,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,oBAAoB,GAC/B,UAAU,iBAAiB,GAAG,IAAI,EAClC,mBAAmB,UAAU,CAAC,6BAA6B,CAAC;;;;;cAc7D,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,qBAAqB,GAChC,UAAU,iBAAiB,GAAG,IAAI,EAClC,iBAAiB,UAAU,CAAC,0BAA0B,CAAC,SA+BxD,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,oBAAoB,GAC/B,UAAU,iBAAiB,GAAG,IAAI,EAClC,4BAA4B,UAAU,CAAC,6BAA6B,CAAC,SAsCtE,CAAA;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,oBAAoB,GAC/B,UAAU,iBAAiB,GAAG,IAAI,EAClC,WAAW,UAAU,CAAC,6BAA6B,CAAC,SA6DrD,CAAA"}
|
package/dist/mutators/auth.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { generateUniqueValue } from "../helpers/generate-unique-value.js";
|
|
2
2
|
import { getResolvedRef } from "../helpers/get-resolved-ref.js";
|
|
3
|
+
import { isNonOptionalSecurityRequirement } from "../helpers/is-non-optional-security-requirement.js";
|
|
3
4
|
import { mergeObjects } from "../helpers/merge-object.js";
|
|
4
5
|
const updateSelectedSecuritySchemes = async (document, { selectedRequirements, newSchemes, meta }) => {
|
|
5
6
|
if (!document) {
|
|
@@ -106,7 +107,7 @@ const updateSelectedScopes = (document, { id, name, scopes, meta }) => {
|
|
|
106
107
|
return;
|
|
107
108
|
}
|
|
108
109
|
const scheme = selectedSchemes.find((scheme2) => JSON.stringify(Object.keys(scheme2)) === JSON.stringify(id));
|
|
109
|
-
if (!scheme) {
|
|
110
|
+
if (!isNonOptionalSecurityRequirement(scheme)) {
|
|
110
111
|
return;
|
|
111
112
|
}
|
|
112
113
|
scheme[name] = scopes;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/mutators/auth.ts"],
|
|
4
|
-
"sourcesContent": ["import type { HttpMethod } from '@scalar/helpers/http/http-methods'\n\nimport type { AuthEvents } from '@/events/definitions/auth'\nimport { generateUniqueValue } from '@/helpers/generate-unique-value'\nimport { getResolvedRef } from '@/helpers/get-resolved-ref'\nimport { mergeObjects } from '@/helpers/merge-object'\nimport type { WorkspaceDocument } from '@/schemas'\nimport type { SecurityRequirementObject } from '@/schemas/v3.1/strict/security-requirement'\n\n/**\n * AuthMeta defines the meta information needed to specify whether the authentication operation\n * is being performed at the document level (entire API), or for a specific operation (specific path and method).\n *\n * - If type is 'document', the operation applies to the whole OpenAPI document.\n * - If type is 'operation', it targets a specific operation, identified by its path and method.\n */\nexport type AuthMeta =\n | {\n type: 'document'\n }\n | {\n type: 'operation'\n path: string\n method: HttpMethod\n }\n\n/**\n * Updates the selected security schemes for either the entire document or a specific operation.\n * - Adds newly created security schemes (if any) to the workspace document's components.\n * - Ensures that each new scheme name is unique within the document by using `generateUniqueValue`.\n * - Updates the `x-scalar-selected-security` property on the target (document or operation) to reflect the new set of selected security schemes.\n * - Corrects and maintains the selected index so it points to a valid security scheme.\n *\n * @param document - The workspace OpenAPI document to mutate (can be null, in which case nothing happens)\n * @param selectedSecuritySchemes - The current list of selected security scheme objects\n * @param create - Array of new schemes to create, each with a name and a scheme definition\n * @param meta - Location to update: whole document or a specific operation (`{ type: 'document' }` or `{ type: 'operation', path, method }`)\n *\n * Example usage:\n * ```\n * updateSelectedSecuritySchemes({\n * document,\n * selectedSecuritySchemes: [{ bearerAuth: [] }],\n * create: [\n * { name: 'ApiKeyAuth', scheme: { type: 'apiKey', in: 'header', name: 'X-API-Key' } }\n * ],\n * meta: { type: 'document' }\n * })\n * ```\n */\nexport const updateSelectedSecuritySchemes = async (\n document: WorkspaceDocument | null,\n { selectedRequirements, newSchemes, meta }: AuthEvents['auth:update:selected-security-schemes'],\n) => {\n if (!document) {\n return\n }\n\n // Helper to get the target (whole document or a specific operation)\n const getTarget = () => {\n if (meta.type === 'document') {\n return document\n }\n\n return getResolvedRef(document.paths?.[meta.path]?.[meta.method])\n }\n\n const createdSecurityRequirements = await Promise.all(\n newSchemes.map(async (newScheme) => {\n const uniqueSchemeName = await generateUniqueValue({\n defaultValue: newScheme.name,\n validation: (value) => !document.components?.securitySchemes?.[value],\n maxRetries: 100,\n })\n\n if (!uniqueSchemeName) {\n return\n }\n\n // Ensure components and securitySchemes exist\n if (!document.components) {\n document.components = {}\n }\n if (!document.components.securitySchemes) {\n document.components.securitySchemes = {}\n }\n\n // Add the new security scheme definition\n document.components.securitySchemes[uniqueSchemeName] = newScheme.scheme\n\n // Return an OpenAPI Security Requirement Object for this new scheme (empty scope array)\n return {\n [uniqueSchemeName]: [],\n }\n }),\n )\n\n // Create any new security schemes required, ensuring unique names for the components\n const createdSchemes = createdSecurityRequirements.filter(Boolean) as SecurityRequirementObject[]\n\n const target = getTarget()\n\n const newSelectedSecuritySchemes = [...selectedRequirements, ...createdSchemes]\n\n // If the target (document/operation) doesn't exist, do nothing\n if (!target) {\n return\n }\n\n // Ensure the x-scalar-selected-security structure exists on the target\n if (!target['x-scalar-selected-security']) {\n target['x-scalar-selected-security'] = {\n selectedIndex: -1,\n selectedSchemes: [],\n }\n }\n\n const selectedIndex = target['x-scalar-selected-security'].selectedIndex\n\n // Update the schemes array\n target['x-scalar-selected-security'].selectedSchemes = newSelectedSecuritySchemes\n\n // Adjust selected index if there are schemes and the index is unset/invalid\n if (newSelectedSecuritySchemes.length > 0 && selectedIndex < 0) {\n target['x-scalar-selected-security'].selectedIndex = 0\n }\n\n // If the selected index is now out of bounds, select the last available\n if (selectedIndex >= newSelectedSecuritySchemes.length) {\n target['x-scalar-selected-security'].selectedIndex = newSelectedSecuritySchemes.length - 1\n }\n}\n\n/**\n * Updates a security scheme in the OpenAPI document's components object.\n * Handles updates for HTTP, API Key, and OAuth2 types, saving secret information and configuration for UI-auth flows.\n *\n * @param document - The OpenAPI workspace document (can be null)\n * @param data - The update information, including type and payload\n * @param name - The name of the security scheme in document.components.securitySchemes\n *\n * Example usage:\n *\n * updateSecurityScheme({\n * document,\n * data: {\n * type: 'http',\n * payload: {\n * username: 'user123',\n * password: 'pw123',\n * token: 'tokenval'\n * }\n * },\n * name: 'MyHttpAuth',\n * })\n */\nexport const updateSecurityScheme = (\n document: WorkspaceDocument | null,\n { payload, name }: AuthEvents['auth:update:security-scheme'],\n) => {\n const target = getResolvedRef(document?.components?.securitySchemes?.[name])\n if (!target) {\n console.error(`Security scheme ${name} not found`)\n return\n }\n\n // Handle HTTP (basic, bearer, etc.)\n if (target.type === payload.type) {\n mergeObjects(target, payload)\n }\n\n return target\n}\n\n/**\n * Sets the selected authentication tab (scheme) index for the given OpenAPI document or operation.\n * - When on the document level, updates the 'selectedIndex' on the document's x-scalar-selected-security extension.\n * - When on an operation (endpoint) level, updates the 'selectedIndex' for that operation's x-scalar-selected-security.\n *\n * Also initializes the x-scalar-selected-security extension if it does not exist.\n *\n * @param document The OpenAPI document object (may be null)\n * @param index The index to set as selected\n * @param meta Context where the selection applies ('document' or specific operation)\n *\n * @example\n * // Document-level tab selection\n * updateSelectedAuthTab({\n * document,\n * index: 1,\n * meta: { type: 'document' }\n * });\n *\n * // Operation-level tab selection (e.g., GET /pets)\n * updateSelectedAuthTab({\n * document,\n * index: 0,\n * meta: { type: 'operation', path: '/pets', method: 'get' }\n * });\n */\nexport const updateSelectedAuthTab = (\n document: WorkspaceDocument | null,\n { index, meta }: AuthEvents['auth:update:active-index'],\n) => {\n if (!document) {\n return\n }\n\n // Determine the target object for setting the auth tab index:\n // - Document/root level\n // - Operation/endpoint level (if meta specifies operation)\n const getTarget = () => {\n if (meta.type === 'document') {\n return document\n }\n return getResolvedRef(document.paths?.[meta.path]?.[meta.method])\n }\n\n const target = getTarget()\n if (!target) {\n return\n }\n\n // Ensure the 'x-scalar-selected-security' extension exists\n if (!target['x-scalar-selected-security']) {\n target['x-scalar-selected-security'] = {\n selectedIndex: 0,\n selectedSchemes: [],\n }\n }\n\n // Set the selected auth tab index\n target['x-scalar-selected-security'].selectedIndex = index\n}\n\n/**\n * Updates the scopes for a specific security requirement in the selected security schemes of\n * a document or operation.\n *\n * @param document - The OpenAPI WorkspaceDocument to update.\n * @param id - An array of scheme names that uniquely identifies the target security requirement.\n * For example: ['OAuth', 'ApiKeyAuth']\n * @param name - The security scheme name to update scopes for (e.g., 'OAuth').\n * @param scopes - The new list of scopes to set. For example: ['read:pets', 'write:pets']\n * @param meta - The context specifying whether the update is at the document-level or operation-level.\n *\n * Example usage:\n * ```ts\n * // Suppose your document (or operation) x-scalar-selected-security looks like:\n * // \"x-scalar-selected-security\": {\n * // selectedIndex: 0,\n * // selectedSchemes: [\n * // { \"OAuth\": [\"read:pets\"] },\n * // { \"ApiKeyAuth\": [] }\n * // ]\n * // }\n *\n * updateSelectedScopes({\n * document,\n * id: [\"OAuth\"], // identifies the scheme object: { \"OAuth\": [...] }\n * name: \"OAuth\", // scheme name to update within this security requirement\n * scopes: [\"write:pets\"], // new scopes array\n * meta: { type: \"document\" }\n * })\n * // After, the first scheme becomes: { \"OAuth\": [\"write:pets\"] }\n * ```\n */\nexport const updateSelectedScopes = (\n document: WorkspaceDocument | null,\n { id, name, scopes, meta }: AuthEvents['auth:update:selected-scopes'],\n) => {\n if (!document) {\n return\n }\n\n // Determine the target object (document or the operation)\n const getTarget = () => {\n if (meta.type === 'document') {\n return document\n }\n return getResolvedRef(document.paths?.[meta.path]?.[meta.method])\n }\n\n const target = getTarget()\n\n if (!target) {\n return\n }\n\n // Array of security requirement objects under x-scalar-selected-security\n const selectedSchemes = target['x-scalar-selected-security']?.selectedSchemes\n\n if (!selectedSchemes) {\n return\n }\n\n // Find the security requirement that matches the given id (scheme key names)\n // For example: if id = [\"OAuth\"], matches { OAuth: [...] }\n const scheme = selectedSchemes.find((scheme) => JSON.stringify(Object.keys(scheme)) === JSON.stringify(id))\n\n if (!scheme) {\n return\n }\n\n // Set the scopes array for the named security scheme within the found security requirement\n scheme[name] = scopes\n}\n\n/**\n * Deletes one or more security schemes from an OpenAPI WorkspaceDocument,\n * and removes all references to those schemes from selected security, document-level security,\n * and operation-level security/selected security (e.g., on paths).\n *\n * Example usage:\n *\n * ```ts\n * deleteSecurityScheme({\n * document, // The OpenAPI document to update\n * names: ['ApiKeyAuth', 'BearerAuth'], // The names of security schemes you want to delete\n * });\n * ```\n *\n * After running this function:\n * - The named security schemes are removed from the components.securitySchemes section.\n * - All document-level and operation-level security entries referencing those schemes are removed.\n * - Any extended x-scalar-selected-security references to those schemes are also removed.\n */\nexport const deleteSecurityScheme = (\n document: WorkspaceDocument | null,\n { names }: AuthEvents['auth:delete:security-scheme'],\n) => {\n if (!document) {\n // Early exit if there is no document to modify\n return\n }\n\n // Get the mutable reference to securitySchemes in components (may be a proxy/resolved reference)\n const target = getResolvedRef(document.components?.securitySchemes)\n\n if (!target) {\n // If there are no security schemes to delete from, return early\n return\n }\n\n // Remove each named security scheme from the components.securitySchemes object\n names.forEach((name) => {\n delete target[name]\n })\n\n // Function to remove any security requirement objects that reference given scheme names.\n const filterSecuritySchemes = (schemes: SecurityRequirementObject[]) => {\n // Remove schemes whose key is included in the `names` to be deleted.\n return schemes.filter((scheme) => !names.some((name) => Object.keys(scheme).includes(name)))\n }\n\n // -- Remove from document-level `x-scalar-selected-security` extension, if present\n if (document['x-scalar-selected-security']) {\n const selectedSecurity = document['x-scalar-selected-security']\n selectedSecurity.selectedSchemes = filterSecuritySchemes(selectedSecurity.selectedSchemes)\n }\n\n // -- Remove from document-level `security` property, if present\n if (document['security']) {\n document['security'] = filterSecuritySchemes(document['security'])\n }\n\n // -- For each path and operation, remove deleted security schemes from operation-level security and custom extension\n Object.values(document.paths ?? {}).forEach((path) => {\n Object.values(path).forEach((operation) => {\n if (typeof operation !== 'object') {\n // Ignore operations that are not objects (could be undefined)\n return\n }\n\n // Get mutable reference for the operation (could resolve $ref proxies)\n const resolvedOperation = getResolvedRef(operation)\n\n // Remove from operation-level security array\n if ('security' in resolvedOperation && resolvedOperation['security']) {\n resolvedOperation['security'] = filterSecuritySchemes(resolvedOperation['security'])\n }\n\n // Remove from operation-level x-scalar-selected-security array\n if ('x-scalar-selected-security' in resolvedOperation && resolvedOperation['x-scalar-selected-security']) {\n resolvedOperation['x-scalar-selected-security'].selectedSchemes = filterSecuritySchemes(\n resolvedOperation['x-scalar-selected-security'].selectedSchemes,\n )\n }\n })\n })\n}\n"],
|
|
5
|
-
"mappings": "AAGA,SAAS,2BAA2B;AACpC,SAAS,sBAAsB;AAC/B,SAAS,oBAAoB;AA6CtB,MAAM,gCAAgC,OAC3C,UACA,EAAE,sBAAsB,YAAY,KAAK,MACtC;AACH,MAAI,CAAC,UAAU;AACb;AAAA,EACF;AAGA,QAAM,YAAY,MAAM;AACtB,QAAI,KAAK,SAAS,YAAY;AAC5B,aAAO;AAAA,IACT;AAEA,WAAO,eAAe,SAAS,QAAQ,KAAK,IAAI,IAAI,KAAK,MAAM,CAAC;AAAA,EAClE;AAEA,QAAM,8BAA8B,MAAM,QAAQ;AAAA,IAChD,WAAW,IAAI,OAAO,cAAc;AAClC,YAAM,mBAAmB,MAAM,oBAAoB;AAAA,QACjD,cAAc,UAAU;AAAA,QACxB,YAAY,CAAC,UAAU,CAAC,SAAS,YAAY,kBAAkB,KAAK;AAAA,QACpE,YAAY;AAAA,MACd,CAAC;AAED,UAAI,CAAC,kBAAkB;AACrB;AAAA,MACF;AAGA,UAAI,CAAC,SAAS,YAAY;AACxB,iBAAS,aAAa,CAAC;AAAA,MACzB;AACA,UAAI,CAA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T;AACA,WAAO,eAAe,SAAS,QAAQ,KAAK,IAAI,IAAI,KAAK,MAAM,CAAC;AAAA,EAClE;AAEA,QAAM,SAAS,UAAU;AACzB,MAAI,CAAC,QAAQ;AACX;AAAA,EACF;AAGA,MAAI,CAAC,OAAO,4BAA4B,GAAG;AACzC,WAAO,4BAA4B,IAAI;AAAA,MACrC,eAAe;AAAA,MACf,iBAAiB,CAAC;AAAA,IACpB;AAAA,EACF;AAGA,SAAO,4BAA4B,EAAE,gBAAgB;AACvD;AAkCO,MAAM,uBAAuB,CAClC,UACA,EAAE,IAAI,MAAM,QAAQ,KAAK,MACtB;AACH,MAAI,CAAC,UAAU;AACb;AAAA,EACF;AAGA,QAAM,YAAY,MAAM;AACtB,QAAI,KAAK,SAAS,YAAY;AAC5B,aAAO;AAAA,IACT;AACA,WAAO,eAAe,SAAS,QAAQ,KAAK,IAAI,IAAI,KAAK,MAAM,CAAC;AAAA,EAClE;AAEA,QAAM,SAAS,UAAU;AAEzB,MAAI,CAAC,QAAQ;AACX;AAAA,EACF;AAGA,QAAM,kBAAkB,OAAO,4BAA4B,GAAG;AAE9D,MAAI,CAAC,iBAAiB;AACpB;AAAA,EACF;AAIA,QAAM,SAAS,gBAAgB,KAAK,CAACA,YAAW,KAAK,UAAU,OAAO,KAAKA,OAAM,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;
|
|
4
|
+
"sourcesContent": ["import type { HttpMethod } from '@scalar/helpers/http/http-methods'\n\nimport type { AuthEvents } from '@/events/definitions/auth'\nimport { generateUniqueValue } from '@/helpers/generate-unique-value'\nimport { getResolvedRef } from '@/helpers/get-resolved-ref'\nimport { isNonOptionalSecurityRequirement } from '@/helpers/is-non-optional-security-requirement'\nimport { mergeObjects } from '@/helpers/merge-object'\nimport type { WorkspaceDocument } from '@/schemas'\nimport type { SecurityRequirementObject } from '@/schemas/v3.1/strict/security-requirement'\n\n/**\n * AuthMeta defines the meta information needed to specify whether the authentication operation\n * is being performed at the document level (entire API), or for a specific operation (specific path and method).\n *\n * - If type is 'document', the operation applies to the whole OpenAPI document.\n * - If type is 'operation', it targets a specific operation, identified by its path and method.\n */\nexport type AuthMeta =\n | {\n type: 'document'\n }\n | {\n type: 'operation'\n path: string\n method: HttpMethod\n }\n\n/**\n * Updates the selected security schemes for either the entire document or a specific operation.\n * - Adds newly created security schemes (if any) to the workspace document's components.\n * - Ensures that each new scheme name is unique within the document by using `generateUniqueValue`.\n * - Updates the `x-scalar-selected-security` property on the target (document or operation) to reflect the new set of selected security schemes.\n * - Corrects and maintains the selected index so it points to a valid security scheme.\n *\n * @param document - The workspace OpenAPI document to mutate (can be null, in which case nothing happens)\n * @param selectedSecuritySchemes - The current list of selected security scheme objects\n * @param create - Array of new schemes to create, each with a name and a scheme definition\n * @param meta - Location to update: whole document or a specific operation (`{ type: 'document' }` or `{ type: 'operation', path, method }`)\n *\n * Example usage:\n * ```\n * updateSelectedSecuritySchemes({\n * document,\n * selectedSecuritySchemes: [{ bearerAuth: [] }],\n * create: [\n * { name: 'ApiKeyAuth', scheme: { type: 'apiKey', in: 'header', name: 'X-API-Key' } }\n * ],\n * meta: { type: 'document' }\n * })\n * ```\n */\nexport const updateSelectedSecuritySchemes = async (\n document: WorkspaceDocument | null,\n { selectedRequirements, newSchemes, meta }: AuthEvents['auth:update:selected-security-schemes'],\n) => {\n if (!document) {\n return\n }\n\n // Helper to get the target (whole document or a specific operation)\n const getTarget = () => {\n if (meta.type === 'document') {\n return document\n }\n\n return getResolvedRef(document.paths?.[meta.path]?.[meta.method])\n }\n\n const createdSecurityRequirements = await Promise.all(\n newSchemes.map(async (newScheme) => {\n const uniqueSchemeName = await generateUniqueValue({\n defaultValue: newScheme.name,\n validation: (value) => !document.components?.securitySchemes?.[value],\n maxRetries: 100,\n })\n\n if (!uniqueSchemeName) {\n return\n }\n\n // Ensure components and securitySchemes exist\n if (!document.components) {\n document.components = {}\n }\n if (!document.components.securitySchemes) {\n document.components.securitySchemes = {}\n }\n\n // Add the new security scheme definition\n document.components.securitySchemes[uniqueSchemeName] = newScheme.scheme\n\n // Return an OpenAPI Security Requirement Object for this new scheme (empty scope array)\n return {\n [uniqueSchemeName]: [],\n }\n }),\n )\n\n // Create any new security schemes required, ensuring unique names for the components\n const createdSchemes = createdSecurityRequirements.filter(Boolean) as SecurityRequirementObject[]\n\n const target = getTarget()\n\n const newSelectedSecuritySchemes = [...selectedRequirements, ...createdSchemes]\n\n // If the target (document/operation) doesn't exist, do nothing\n if (!target) {\n return\n }\n\n // Ensure the x-scalar-selected-security structure exists on the target\n if (!target['x-scalar-selected-security']) {\n target['x-scalar-selected-security'] = {\n selectedIndex: -1,\n selectedSchemes: [],\n }\n }\n\n const selectedIndex = target['x-scalar-selected-security'].selectedIndex\n\n // Update the schemes array\n target['x-scalar-selected-security'].selectedSchemes = newSelectedSecuritySchemes\n\n // Adjust selected index if there are schemes and the index is unset/invalid\n if (newSelectedSecuritySchemes.length > 0 && selectedIndex < 0) {\n target['x-scalar-selected-security'].selectedIndex = 0\n }\n\n // If the selected index is now out of bounds, select the last available\n if (selectedIndex >= newSelectedSecuritySchemes.length) {\n target['x-scalar-selected-security'].selectedIndex = newSelectedSecuritySchemes.length - 1\n }\n}\n\n/**\n * Updates a security scheme in the OpenAPI document's components object.\n * Handles updates for HTTP, API Key, and OAuth2 types, saving secret information and configuration for UI-auth flows.\n *\n * @param document - The OpenAPI workspace document (can be null)\n * @param data - The update information, including type and payload\n * @param name - The name of the security scheme in document.components.securitySchemes\n *\n * Example usage:\n *\n * updateSecurityScheme({\n * document,\n * data: {\n * type: 'http',\n * payload: {\n * username: 'user123',\n * password: 'pw123',\n * token: 'tokenval'\n * }\n * },\n * name: 'MyHttpAuth',\n * })\n */\nexport const updateSecurityScheme = (\n document: WorkspaceDocument | null,\n { payload, name }: AuthEvents['auth:update:security-scheme'],\n) => {\n const target = getResolvedRef(document?.components?.securitySchemes?.[name])\n if (!target) {\n console.error(`Security scheme ${name} not found`)\n return\n }\n\n // Handle HTTP (basic, bearer, etc.)\n if (target.type === payload.type) {\n mergeObjects(target, payload)\n }\n\n return target\n}\n\n/**\n * Sets the selected authentication tab (scheme) index for the given OpenAPI document or operation.\n * - When on the document level, updates the 'selectedIndex' on the document's x-scalar-selected-security extension.\n * - When on an operation (endpoint) level, updates the 'selectedIndex' for that operation's x-scalar-selected-security.\n *\n * Also initializes the x-scalar-selected-security extension if it does not exist.\n *\n * @param document The OpenAPI document object (may be null)\n * @param index The index to set as selected\n * @param meta Context where the selection applies ('document' or specific operation)\n *\n * @example\n * // Document-level tab selection\n * updateSelectedAuthTab({\n * document,\n * index: 1,\n * meta: { type: 'document' }\n * });\n *\n * // Operation-level tab selection (e.g., GET /pets)\n * updateSelectedAuthTab({\n * document,\n * index: 0,\n * meta: { type: 'operation', path: '/pets', method: 'get' }\n * });\n */\nexport const updateSelectedAuthTab = (\n document: WorkspaceDocument | null,\n { index, meta }: AuthEvents['auth:update:active-index'],\n) => {\n if (!document) {\n return\n }\n\n // Determine the target object for setting the auth tab index:\n // - Document/root level\n // - Operation/endpoint level (if meta specifies operation)\n const getTarget = () => {\n if (meta.type === 'document') {\n return document\n }\n return getResolvedRef(document.paths?.[meta.path]?.[meta.method])\n }\n\n const target = getTarget()\n if (!target) {\n return\n }\n\n // Ensure the 'x-scalar-selected-security' extension exists\n if (!target['x-scalar-selected-security']) {\n target['x-scalar-selected-security'] = {\n selectedIndex: 0,\n selectedSchemes: [],\n }\n }\n\n // Set the selected auth tab index\n target['x-scalar-selected-security'].selectedIndex = index\n}\n\n/**\n * Updates the scopes for a specific security requirement in the selected security schemes of\n * a document or operation.\n *\n * @param document - The OpenAPI WorkspaceDocument to update.\n * @param id - An array of scheme names that uniquely identifies the target security requirement.\n * For example: ['OAuth', 'ApiKeyAuth']\n * @param name - The security scheme name to update scopes for (e.g., 'OAuth').\n * @param scopes - The new list of scopes to set. For example: ['read:pets', 'write:pets']\n * @param meta - The context specifying whether the update is at the document-level or operation-level.\n *\n * Example usage:\n * ```ts\n * // Suppose your document (or operation) x-scalar-selected-security looks like:\n * // \"x-scalar-selected-security\": {\n * // selectedIndex: 0,\n * // selectedSchemes: [\n * // { \"OAuth\": [\"read:pets\"] },\n * // { \"ApiKeyAuth\": [] }\n * // ]\n * // }\n *\n * updateSelectedScopes({\n * document,\n * id: [\"OAuth\"], // identifies the scheme object: { \"OAuth\": [...] }\n * name: \"OAuth\", // scheme name to update within this security requirement\n * scopes: [\"write:pets\"], // new scopes array\n * meta: { type: \"document\" }\n * })\n * // After, the first scheme becomes: { \"OAuth\": [\"write:pets\"] }\n * ```\n */\nexport const updateSelectedScopes = (\n document: WorkspaceDocument | null,\n { id, name, scopes, meta }: AuthEvents['auth:update:selected-scopes'],\n) => {\n if (!document) {\n return\n }\n\n // Determine the target object (document or the operation)\n const getTarget = () => {\n if (meta.type === 'document') {\n return document\n }\n return getResolvedRef(document.paths?.[meta.path]?.[meta.method])\n }\n\n const target = getTarget()\n\n if (!target) {\n return\n }\n\n // Array of security requirement objects under x-scalar-selected-security\n const selectedSchemes = target['x-scalar-selected-security']?.selectedSchemes\n\n if (!selectedSchemes) {\n return\n }\n\n // Find the security requirement that matches the given id (scheme key names)\n // For example: if id = [\"OAuth\"], matches { OAuth: [...] }\n const scheme = selectedSchemes.find((scheme) => JSON.stringify(Object.keys(scheme)) === JSON.stringify(id))\n\n // If the scheme is optional, do nothing as it cannot have scopes\n if (!isNonOptionalSecurityRequirement(scheme)) {\n return\n }\n\n // Set the scopes array for the named security scheme within the found security requirement\n scheme[name] = scopes\n}\n\n/**\n * Deletes one or more security schemes from an OpenAPI WorkspaceDocument,\n * and removes all references to those schemes from selected security, document-level security,\n * and operation-level security/selected security (e.g., on paths).\n *\n * Example usage:\n *\n * ```ts\n * deleteSecurityScheme({\n * document, // The OpenAPI document to update\n * names: ['ApiKeyAuth', 'BearerAuth'], // The names of security schemes you want to delete\n * });\n * ```\n *\n * After running this function:\n * - The named security schemes are removed from the components.securitySchemes section.\n * - All document-level and operation-level security entries referencing those schemes are removed.\n * - Any extended x-scalar-selected-security references to those schemes are also removed.\n */\nexport const deleteSecurityScheme = (\n document: WorkspaceDocument | null,\n { names }: AuthEvents['auth:delete:security-scheme'],\n) => {\n if (!document) {\n // Early exit if there is no document to modify\n return\n }\n\n // Get the mutable reference to securitySchemes in components (may be a proxy/resolved reference)\n const target = getResolvedRef(document.components?.securitySchemes)\n\n if (!target) {\n // If there are no security schemes to delete from, return early\n return\n }\n\n // Remove each named security scheme from the components.securitySchemes object\n names.forEach((name) => {\n delete target[name]\n })\n\n // Function to remove any security requirement objects that reference given scheme names.\n const filterSecuritySchemes = (schemes: SecurityRequirementObject[]) => {\n // Remove schemes whose key is included in the `names` to be deleted.\n return schemes.filter((scheme) => !names.some((name) => Object.keys(scheme).includes(name)))\n }\n\n // -- Remove from document-level `x-scalar-selected-security` extension, if present\n if (document['x-scalar-selected-security']) {\n const selectedSecurity = document['x-scalar-selected-security']\n selectedSecurity.selectedSchemes = filterSecuritySchemes(selectedSecurity.selectedSchemes)\n }\n\n // -- Remove from document-level `security` property, if present\n if (document['security']) {\n document['security'] = filterSecuritySchemes(document['security'])\n }\n\n // -- For each path and operation, remove deleted security schemes from operation-level security and custom extension\n Object.values(document.paths ?? {}).forEach((path) => {\n Object.values(path).forEach((operation) => {\n if (typeof operation !== 'object') {\n // Ignore operations that are not objects (could be undefined)\n return\n }\n\n // Get mutable reference for the operation (could resolve $ref proxies)\n const resolvedOperation = getResolvedRef(operation)\n\n // Remove from operation-level security array\n if ('security' in resolvedOperation && resolvedOperation['security']) {\n resolvedOperation['security'] = filterSecuritySchemes(resolvedOperation['security'])\n }\n\n // Remove from operation-level x-scalar-selected-security array\n if ('x-scalar-selected-security' in resolvedOperation && resolvedOperation['x-scalar-selected-security']) {\n resolvedOperation['x-scalar-selected-security'].selectedSchemes = filterSecuritySchemes(\n resolvedOperation['x-scalar-selected-security'].selectedSchemes,\n )\n }\n })\n })\n}\n"],
|
|
5
|
+
"mappings": "AAGA,SAAS,2BA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BAAqB,kBAAkB,UAAU,GAAG;AACpE,0BAAkB,UAAU,IAAI,sBAAsB,kBAAkB,UAAU,CAAC;AAAA,MACrF;AAGA,UAAI,gCAAgC,qBAAqB,kBAAkB,4BAA4B,GAAG;AACxG,0BAAkB,4BAA4B,EAAE,kBAAkB;AAAA,UAChE,kBAAkB,4BAA4B,EAAE;AAAA,QAClD;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AACH;",
|
|
6
6
|
"names": ["scheme"]
|
|
7
7
|
}
|
|
@@ -13,4 +13,10 @@ export declare const updateWatchMode: (document: WorkspaceDocument | null, watch
|
|
|
13
13
|
*/
|
|
14
14
|
export declare const updateDocumentIcon: (document: WorkspaceDocument | null, icon: string) => void;
|
|
15
15
|
export declare const createEmptyDocument: (store: WorkspaceStore | null, payload: DocumentEvents["document:create:empty-document"]) => Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Deletes a document from the workspace by its name.
|
|
18
|
+
*
|
|
19
|
+
* Safely no-ops if the store is null.
|
|
20
|
+
*/
|
|
21
|
+
export declare const deleteDocument: (store: WorkspaceStore | null, payload: DocumentEvents["document:delete:document"]) => void;
|
|
16
22
|
//# sourceMappingURL=document.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../src/mutators/document.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AACnE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAElD;;GAEG;AACH,eAAO,MAAM,cAAc,GAAI,UAAU,iBAAiB,GAAG,IAAI,SAMhE,CAAA;AAED,eAAO,MAAM,eAAe,GAAI,UAAU,iBAAiB,GAAG,IAAI,EAAE,WAAW,OAAO,SAMrF,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAI,UAAU,iBAAiB,GAAG,IAAI,EAAE,MAAM,MAAM,SASlF,CAAA;AAED,eAAO,MAAM,mBAAmB,GAC9B,OAAO,cAAc,GAAG,IAAI,EAC5B,SAAS,cAAc,CAAC,gCAAgC,CAAC,kBA4B1D,CAAA"}
|
|
1
|
+
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../src/mutators/document.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AACnE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAElD;;GAEG;AACH,eAAO,MAAM,cAAc,GAAI,UAAU,iBAAiB,GAAG,IAAI,SAMhE,CAAA;AAED,eAAO,MAAM,eAAe,GAAI,UAAU,iBAAiB,GAAG,IAAI,EAAE,WAAW,OAAO,SAMrF,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAI,UAAU,iBAAiB,GAAG,IAAI,EAAE,MAAM,MAAM,SASlF,CAAA;AAED,eAAO,MAAM,mBAAmB,GAC9B,OAAO,cAAc,GAAG,IAAI,EAC5B,SAAS,cAAc,CAAC,gCAAgC,CAAC,kBA4B1D,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,OAAO,cAAc,GAAG,IAAI,EAAE,SAAS,cAAc,CAAC,0BAA0B,CAAC,SAM/G,CAAA"}
|
|
@@ -40,8 +40,15 @@ const createEmptyDocument = async (store, payload) => {
|
|
|
40
40
|
});
|
|
41
41
|
payload.callback?.(true);
|
|
42
42
|
};
|
|
43
|
+
const deleteDocument = (store, payload) => {
|
|
44
|
+
if (!store) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
store.deleteDocument(payload.name);
|
|
48
|
+
};
|
|
43
49
|
export {
|
|
44
50
|
createEmptyDocument,
|
|
51
|
+
deleteDocument,
|
|
45
52
|
toggleSecurity,
|
|
46
53
|
updateDocumentIcon,
|
|
47
54
|
updateWatchMode
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/mutators/document.ts"],
|
|
4
|
-
"sourcesContent": ["import type { WorkspaceStore } from '@/client'\nimport type { DocumentEvents } from '@/events/definitions/document'\nimport type { WorkspaceDocument } from '@/schemas'\n\n/**\n * Toggle setting selected security schemes at the operation level\n */\nexport const toggleSecurity = (document: WorkspaceDocument | null) => {\n if (!document) {\n return\n }\n\n document['x-scalar-set-operation-security'] = !document['x-scalar-set-operation-security']\n}\n\nexport const updateWatchMode = (document: WorkspaceDocument | null, watchMode: boolean) => {\n if (!document) {\n return\n }\n\n document['x-scalar-watch-mode'] = watchMode\n}\n\n/**\n * Update the document icon and also update the corresponding sidebar entry\n *\n * Does not perform a sidebar rebuild for performance benefit\n */\nexport const updateDocumentIcon = (document: WorkspaceDocument | null, icon: string) => {\n if (!document || !document['x-scalar-navigation']) {\n return\n }\n\n // Update the document icon\n document['x-scalar-icon'] = icon\n // Update the sidebar document icon\n document['x-scalar-navigation'].icon = icon\n}\n\nexport const createEmptyDocument = async (\n store: WorkspaceStore | null,\n payload: DocumentEvents['document:create:empty-document'],\n) => {\n if (!store) {\n return\n }\n\n // Check if the document already exists\n // name should be unique\n if (store.workspace.documents[payload.name]) {\n payload.callback?.(false)\n return\n }\n\n await store.addDocument({\n name: payload.name,\n document: {\n openapi: '3.1.0',\n info: { title: payload.name, version: '1.0.0' },\n paths: {\n '/': {\n get: {},\n },\n },\n 'x-scalar-icon': payload.icon,\n },\n })\n\n payload.callback?.(true)\n}\n"],
|
|
5
|
-
"mappings": "AAOO,MAAM,iBAAiB,CAAC,aAAuC;AACpE,MAAI,CAAC,UAAU;AACb;AAAA,EACF;AAEA,WAAS,iCAAiC,IAAI,CAAC,SAAS,iCAAiC;AAC3F;AAEO,MAAM,kBAAkB,CAAC,UAAoC,cAAuB;AACzF,MAAI,CAAC,UAAU;AACb;AAAA,EACF;AAEA,WAAS,qBAAqB,IAAI;AACpC;AAOO,MAAM,qBAAqB,CAAC,UAAoC,SAAiB;AACtF,MAAI,CAAC,YAAY,CAAC,SAAS,qBAAqB,GAAG;AACjD;AAAA,EACF;AAGA,WAAS,eAAe,IAAI;AAE5B,WAAS,qBAAqB,EAAE,OAAO;AACzC;AAEO,MAAM,sBAAsB,OACjC,OACA,YACG;AACH,MAAI,CAAC,OAAO;AACV;AAAA,EACF;AAIA,MAAI,MAAM,UAAU,UAAU,QAAQ,IAAI,GAAG;AAC3C,YAAQ,WAAW,KAAK;AACxB;AAAA,EACF;AAEA,QAAM,MAAM,YAAY;AAAA,IACtB,MAAM,QAAQ;AAAA,IACd,UAAU;AAAA,MACR,SAAS;AAAA,MACT,MAAM,EAAE,OAAO,QAAQ,MAAM,SAAS,QAAQ;AAAA,MAC9C,OAAO;AAAA,QACL,KAAK;AAAA,UACH,KAAK,CAAC;AAAA,QACR;AAAA,MACF;AAAA,MACA,iBAAiB,QAAQ;AAAA,IAC3B;AAAA,EACF,CAAC;AAED,UAAQ,WAAW,IAAI;AACzB;",
|
|
4
|
+
"sourcesContent": ["import type { WorkspaceStore } from '@/client'\nimport type { DocumentEvents } from '@/events/definitions/document'\nimport type { WorkspaceDocument } from '@/schemas'\n\n/**\n * Toggle setting selected security schemes at the operation level\n */\nexport const toggleSecurity = (document: WorkspaceDocument | null) => {\n if (!document) {\n return\n }\n\n document['x-scalar-set-operation-security'] = !document['x-scalar-set-operation-security']\n}\n\nexport const updateWatchMode = (document: WorkspaceDocument | null, watchMode: boolean) => {\n if (!document) {\n return\n }\n\n document['x-scalar-watch-mode'] = watchMode\n}\n\n/**\n * Update the document icon and also update the corresponding sidebar entry\n *\n * Does not perform a sidebar rebuild for performance benefit\n */\nexport const updateDocumentIcon = (document: WorkspaceDocument | null, icon: string) => {\n if (!document || !document['x-scalar-navigation']) {\n return\n }\n\n // Update the document icon\n document['x-scalar-icon'] = icon\n // Update the sidebar document icon\n document['x-scalar-navigation'].icon = icon\n}\n\nexport const createEmptyDocument = async (\n store: WorkspaceStore | null,\n payload: DocumentEvents['document:create:empty-document'],\n) => {\n if (!store) {\n return\n }\n\n // Check if the document already exists\n // name should be unique\n if (store.workspace.documents[payload.name]) {\n payload.callback?.(false)\n return\n }\n\n await store.addDocument({\n name: payload.name,\n document: {\n openapi: '3.1.0',\n info: { title: payload.name, version: '1.0.0' },\n paths: {\n '/': {\n get: {},\n },\n },\n 'x-scalar-icon': payload.icon,\n },\n })\n\n payload.callback?.(true)\n}\n\n/**\n * Deletes a document from the workspace by its name.\n *\n * Safely no-ops if the store is null.\n */\nexport const deleteDocument = (store: WorkspaceStore | null, payload: DocumentEvents['document:delete:document']) => {\n if (!store) {\n return\n }\n\n store.deleteDocument(payload.name)\n}\n"],
|
|
5
|
+
"mappings": "AAOO,MAAM,iBAAiB,CAAC,aAAuC;AACpE,MAAI,CAAC,UAAU;AACb;AAAA,EACF;AAEA,WAAS,iCAAiC,IAAI,CAAC,SAAS,iCAAiC;AAC3F;AAEO,MAAM,kBAAkB,CAAC,UAAoC,cAAuB;AACzF,MAAI,CAAC,UAAU;AACb;AAAA,EACF;AAEA,WAAS,qBAAqB,IAAI;AACpC;AAOO,MAAM,qBAAqB,CAAC,UAAoC,SAAiB;AACtF,MAAI,CAAC,YAAY,CAAC,SAAS,qBAAqB,GAAG;AACjD;AAAA,EACF;AAGA,WAAS,eAAe,IAAI;AAE5B,WAAS,qBAAqB,EAAE,OAAO;AACzC;AAEO,MAAM,sBAAsB,OACjC,OACA,YACG;AACH,MAAI,CAAC,OAAO;AACV;AAAA,EACF;AAIA,MAAI,MAAM,UAAU,UAAU,QAAQ,IAAI,GAAG;AAC3C,YAAQ,WAAW,KAAK;AACxB;AAAA,EACF;AAEA,QAAM,MAAM,YAAY;AAAA,IACtB,MAAM,QAAQ;AAAA,IACd,UAAU;AAAA,MACR,SAAS;AAAA,MACT,MAAM,EAAE,OAAO,QAAQ,MAAM,SAAS,QAAQ;AAAA,MAC9C,OAAO;AAAA,QACL,KAAK;AAAA,UACH,KAAK,CAAC;AAAA,QACR;AAAA,MACF;AAAA,MACA,iBAAiB,QAAQ;AAAA,IAC3B;AAAA,EACF,CAAC;AAED,UAAQ,WAAW,IAAI;AACzB;AAOO,MAAM,iBAAiB,CAAC,OAA8B,YAAwD;AACnH,MAAI,CAAC,OAAO;AACV;AAAA,EACF;AAEA,QAAM,eAAe,QAAQ,IAAI;AACnC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/mutators/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/** biome-ignore-all lint/performance/noBarrelFile: Mutators entry point */
|
|
2
1
|
import type { WorkspaceStore } from '../client.js';
|
|
3
2
|
import type { ServerObject } from '../schemas/v3.1/strict/openapi-document.js';
|
|
4
3
|
/**
|
|
@@ -87,11 +86,11 @@ export declare function generateClientMutators(store: WorkspaceStore): {
|
|
|
87
86
|
};
|
|
88
87
|
export { type AuthMeta, deleteSecurityScheme, updateSecurityScheme, updateSelectedAuthTab, updateSelectedScopes, updateSelectedSecuritySchemes, } from './auth.js';
|
|
89
88
|
export { deleteCookie, upsertCookie } from './cookie.js';
|
|
90
|
-
export { createEmptyDocument, toggleSecurity, updateDocumentIcon, updateWatchMode } from './document.js';
|
|
89
|
+
export { createEmptyDocument, deleteDocument, toggleSecurity, updateDocumentIcon, updateWatchMode } from './document.js';
|
|
91
90
|
export { upsertEnvironment, upsertEnvironmentVariable, } from './environment.js';
|
|
92
|
-
export { type OperationExampleMeta, type OperationMeta, addOperationParameter, addOperationRequestBodyFormRow, createOperation, deleteAllOperationParameters, deleteOperationParameter, deleteOperationRequestBodyFormRow,
|
|
91
|
+
export { type OperationExampleMeta, type OperationMeta, addOperationParameter, addOperationRequestBodyFormRow, createOperation, deleteAllOperationParameters, deleteOperation, deleteOperationExample, deleteOperationParameter, deleteOperationRequestBodyFormRow, updateOperationParameter, updateOperationPathMethod, updateOperationRequestBodyContentType, updateOperationRequestBodyExample, updateOperationRequestBodyFormRow, updateOperationSummary, } from './operation.js';
|
|
93
92
|
export { addServer, deleteServer, updateSelectedServer, updateServer, updateServerVariables, } from './server.js';
|
|
94
93
|
export { addTab, closeOtherTabs, closeTab, focusLastTab, focusTab, navigateNextTab, navigatePreviousTab, updateTabs, } from './tabs.js';
|
|
95
|
-
export { createTag } from './tag.js';
|
|
96
|
-
export { updateActiveProxy, updateColorMode, updateTheme } from './workspace.js';
|
|
94
|
+
export { createTag, deleteTag } from './tag.js';
|
|
95
|
+
export { updateActiveProxy, updateColorMode, updateSelectedClient, updateTheme } from './workspace.js';
|
|
97
96
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mutators/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mutators/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAI9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAA;AAE1E;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,cAAc;IAmGxD;;OAEG;;;gCAxFwB,YAAY,KAAG,OAAO;gCAatB,MAAM,KAAG,OAAO;;;;;;;IA6E3C;;;OAGG;;;;;;;;;;;;;;;;;;;;;;;gCA7FwB,YAAY,KAAG,OAAO;gCAatB,MAAM,KAAG,OAAO;;;IAmF3C;;;;OAIG;gBACS,MAAM;;;;;;;;;;;;;;;;;;;;;;gCArGS,YAAY,KAAG,OAAO;gCAatB,MAAM,KAAG,OAAO;;;EA0F9C;AAED,OAAO,EACL,KAAK,QAAQ,EACb,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,EACpB,6BAA6B,GAC9B,MAAM,Q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