@scalar/workspace-store 0.19.0 → 0.20.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 +14 -0
- package/dist/events/definitions/auth.d.ts +20 -2
- package/dist/events/definitions/auth.d.ts.map +1 -1
- package/dist/events/definitions/document.d.ts +5 -1
- package/dist/events/definitions/document.d.ts.map +1 -1
- package/dist/events/definitions/index.d.ts +1 -2
- package/dist/events/definitions/index.d.ts.map +1 -1
- package/dist/events/definitions/server.d.ts +20 -28
- package/dist/events/definitions/server.d.ts.map +1 -1
- package/dist/events/index.d.ts +2 -2
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js.map +2 -2
- package/dist/mutators/auth.d.ts +10 -73
- package/dist/mutators/auth.d.ts.map +1 -1
- package/dist/mutators/auth.js +24 -91
- package/dist/mutators/auth.js.map +2 -2
- package/dist/mutators/document.d.ts +6 -0
- package/dist/mutators/document.d.ts.map +1 -0
- package/dist/mutators/document.js +10 -0
- package/dist/mutators/document.js.map +7 -0
- package/dist/mutators/index.d.ts +10 -7
- package/dist/mutators/index.d.ts.map +1 -1
- package/dist/mutators/index.js +36 -1
- package/dist/mutators/index.js.map +3 -3
- package/dist/mutators/server.d.ts +43 -8
- package/dist/mutators/server.d.ts.map +1 -1
- package/dist/mutators/server.js +112 -20
- package/dist/mutators/server.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 +2 -1
- package/dist/navigation/helpers/traverse-document.js.map +2 -2
- package/dist/plugins/client/persistence.d.ts +2 -1
- package/dist/plugins/client/persistence.d.ts.map +1 -1
- package/dist/plugins/client/persistence.js +11 -9
- package/dist/plugins/client/persistence.js.map +2 -2
- package/dist/schemas/extensions/document/x-scalar-document-security.d.ts +13 -0
- package/dist/schemas/extensions/document/x-scalar-document-security.d.ts.map +1 -0
- package/dist/schemas/extensions/document/x-scalar-document-security.js +8 -0
- package/dist/schemas/extensions/document/x-scalar-document-security.js.map +7 -0
- package/dist/schemas/extensions/security/x-scalar-selected-security.d.ts +7 -7
- package/dist/schemas/extensions/security/x-scalar-selected-security.d.ts.map +1 -1
- package/dist/schemas/extensions/security/x-scalar-selected-security.js +2 -2
- package/dist/schemas/extensions/security/x-scalar-selected-security.js.map +2 -2
- package/dist/schemas/extensions/server/x-scalar-selected-server.d.ts +8 -0
- package/dist/schemas/extensions/server/x-scalar-selected-server.d.ts.map +1 -0
- package/dist/schemas/extensions/server/x-scalar-selected-server.js +8 -0
- package/dist/schemas/extensions/server/x-scalar-selected-server.js.map +7 -0
- package/dist/schemas/inmemory-workspace.d.ts +20 -8
- package/dist/schemas/inmemory-workspace.d.ts.map +1 -1
- package/dist/schemas/navigation.d.ts +5 -0
- package/dist/schemas/navigation.d.ts.map +1 -1
- package/dist/schemas/navigation.js +1 -0
- package/dist/schemas/navigation.js.map +2 -2
- package/dist/schemas/reference-config/index.d.ts +10 -4
- package/dist/schemas/reference-config/index.d.ts.map +1 -1
- package/dist/schemas/reference-config/settings.d.ts +10 -4
- package/dist/schemas/reference-config/settings.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/openapi-document.d.ts +343 -137
- package/dist/schemas/v3.1/strict/openapi-document.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/openapi-document.js +8 -0
- package/dist/schemas/v3.1/strict/openapi-document.js.map +2 -2
- package/dist/schemas/v3.1/strict/operation.d.ts +2 -2
- package/dist/schemas/workspace-specification/config.d.ts +10 -4
- package/dist/schemas/workspace-specification/config.d.ts.map +1 -1
- package/dist/schemas/workspace-specification/index.d.ts +10 -4
- package/dist/schemas/workspace-specification/index.d.ts.map +1 -1
- package/dist/schemas/workspace.d.ts +70 -28
- package/dist/schemas/workspace.d.ts.map +1 -1
- package/package.json +5 -5
- package/dist/helpers/debounce.d.ts +0 -28
- package/dist/helpers/debounce.d.ts.map +0 -1
- package/dist/helpers/debounce.js +0 -31
- package/dist/helpers/debounce.js.map +0 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @scalar/workspace-store
|
|
2
2
|
|
|
3
|
+
## 0.20.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#7279](https://github.com/scalar/scalar/pull/7279) [`7ccd035`](https://github.com/scalar/scalar/commit/7ccd0351de104f78ef9c6e16538753d302c50d47) Thanks [@DemonHa](https://github.com/DemonHa)! - feat(api-client): integrate new sidebar with v2 routing
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [#7305](https://github.com/scalar/scalar/pull/7305) [`c7a4690`](https://github.com/scalar/scalar/commit/c7a4690cec484ee16cee8dcba7ef5cb0fbb98133) Thanks [@amritk](https://github.com/amritk)! - chore: minor auth changes, code re-org, type safety
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [[`9c9dbba`](https://github.com/scalar/scalar/commit/9c9dbbaa940667303f0ace59469fd78c2a741937), [`4bec1ba`](https://github.com/scalar/scalar/commit/4bec1ba332e919c4ee32dcfbfb07bd8ee42c4d74)]:
|
|
14
|
+
- @scalar/helpers@0.1.1
|
|
15
|
+
- @scalar/json-magic@0.8.1
|
|
16
|
+
|
|
3
17
|
## 0.19.0
|
|
4
18
|
|
|
5
19
|
### Minor Changes
|
|
@@ -1,5 +1,23 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PartialDeep } from 'type-fest';
|
|
2
|
+
import type { AuthMeta } from '../../mutators/auth.js';
|
|
2
3
|
import type { SecurityRequirementObject, SecuritySchemeObject } from '../../schemas/v3.1/strict/openapi-document.js';
|
|
4
|
+
import type { ApiKeyObject, HttpObject, OAuth2Object } from '../../schemas/v3.1/strict/security-scheme.js';
|
|
5
|
+
/**
|
|
6
|
+
* SecuritySchemeUpdate represents the possible updates that can be made
|
|
7
|
+
* to an OpenAPI security scheme object via UI interactions.
|
|
8
|
+
*
|
|
9
|
+
* - `http`: Updates to HTTP type schemes (e.g. basic, bearer), allowing token, username, and password changes.
|
|
10
|
+
* - `apiKey`: Updates to API Key type schemes, allowing the key name and its value to be updated.
|
|
11
|
+
* - `oauth2`: Updates to OAuth2 type schemes for each supported OAuth2 flow.
|
|
12
|
+
* - Can set various properties such as auth/token URLs, tokens, PKCE method, client credentials, etc.
|
|
13
|
+
*/
|
|
14
|
+
export type SecuritySchemeUpdatePayload = ({
|
|
15
|
+
type: 'http';
|
|
16
|
+
} & Partial<Omit<HttpObject, 'type'>>) | ({
|
|
17
|
+
type: 'apiKey';
|
|
18
|
+
} & Partial<Omit<ApiKeyObject, 'type'>>) | ({
|
|
19
|
+
type: 'oauth2';
|
|
20
|
+
} & PartialDeep<Omit<OAuth2Object, 'type'>>);
|
|
3
21
|
/** Event definitions for auth */
|
|
4
22
|
export type AuthEvents = {
|
|
5
23
|
/**
|
|
@@ -39,7 +57,7 @@ export type AuthEvents = {
|
|
|
39
57
|
*/
|
|
40
58
|
'auth:update:security-scheme': {
|
|
41
59
|
/** The data to update the security scheme with */
|
|
42
|
-
|
|
60
|
+
payload: SecuritySchemeUpdatePayload;
|
|
43
61
|
/** The name of the security scheme to update */
|
|
44
62
|
name: string;
|
|
45
63
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/events/definitions/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/events/definitions/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAE5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,KAAK,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,MAAM,wCAAwC,CAAA;AAC7G,OAAO,KAAK,EAAE,YAAY,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AAI,EAAE,QAAQ,CAAA;KACf,CAAA;IAED;;;;;;;;;OASG;IACH,6BAA6B,EAAE;QAC7B,8CAA8C;QAC9C,KAAK,EAAE,MAAM,EAAE,CAAA;KAChB,CAAA;CACF,CAAA"}
|
|
@@ -7,8 +7,12 @@ export type DocumentEvents = {
|
|
|
7
7
|
*/
|
|
8
8
|
'document:update:info': PartialDeep<InfoObject>;
|
|
9
9
|
/**
|
|
10
|
-
* Update the icon of the active document
|
|
10
|
+
* Update the icon of the active document
|
|
11
11
|
*/
|
|
12
12
|
'document:update:icon': string;
|
|
13
|
+
/**
|
|
14
|
+
* Toggle use document security
|
|
15
|
+
*/
|
|
16
|
+
'document:toggle:document-security': undefined;
|
|
13
17
|
};
|
|
14
18
|
//# sourceMappingURL=document.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../../src/events/definitions/document.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAE5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAA;AAE5D,iDAAiD;AACjD,MAAM,MAAM,cAAc,GAAG;IAC3B;;OAEG;IACH,sBAAsB,EAAE,WAAW,CAAC,UAAU,CAAC,CAAA;IAC/C;;OAEG;IACH,sBAAsB,EAAE,MAAM,CAAA;CAC/
|
|
1
|
+
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../../src/events/definitions/document.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAE5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAA;AAE5D,iDAAiD;AACjD,MAAM,MAAM,cAAc,GAAG;IAC3B;;OAEG;IACH,sBAAsB,EAAE,WAAW,CAAC,UAAU,CAAC,CAAA;IAC/C;;OAEG;IACH,sBAAsB,EAAE,MAAM,CAAA;IAC9B;;OAEG;IACH,mCAAmC,EAAE,SAAS,CAAA;CAC/C,CAAA"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { EnvironmentEvents } from '../../events/definitions/environment.js';
|
|
2
|
-
import type { ServerObject } from '../../schemas/v3.1/strict/openapi-document.js';
|
|
3
2
|
import type { AnalyticsEvents } from './analytics.js';
|
|
4
3
|
import type { AuthEvents } from './auth.js';
|
|
5
4
|
import type { DocumentEvents } from './document.js';
|
|
@@ -7,6 +6,6 @@ import type { MetaEvents } from './meta.js';
|
|
|
7
6
|
import type { OperationEvents } from './operation.js';
|
|
8
7
|
import type { ServerEvents } from './server.js';
|
|
9
8
|
import type { UIEvents } from './ui.js';
|
|
10
|
-
export type ApiReferenceEvents
|
|
9
|
+
export type ApiReferenceEvents = AuthEvents & AnalyticsEvents & DocumentEvents & EnvironmentEvents & MetaEvents & OperationEvents & ServerEvents & UIEvents;
|
|
11
10
|
export type { CollectionType } from './common.js';
|
|
12
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/events/definitions/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/events/definitions/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AAEzE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACxC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACxC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAC5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAA;AAEpC,MAAM,MAAM,kBAAkB,GAAG,UAAU,GACzC,eAAe,GACf,cAAc,GACd,iBAAiB,GACjB,UAAU,GACV,eAAe,GACf,YAAY,GACZ,QAAQ,CAAA;AAEV,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA"}
|
|
@@ -1,50 +1,42 @@
|
|
|
1
1
|
import type { ServerObject } from '../../schemas/v3.1/strict/openapi-document.js';
|
|
2
|
-
export type ServerEvents
|
|
2
|
+
export type ServerEvents = {
|
|
3
3
|
/**
|
|
4
|
-
* Add a new server to the document
|
|
4
|
+
* Add a new blank server to the document
|
|
5
5
|
*/
|
|
6
|
-
'add:server':
|
|
7
|
-
/** The new server payload to add */
|
|
8
|
-
server: ServerObject;
|
|
9
|
-
};
|
|
6
|
+
'server:add:server': undefined;
|
|
10
7
|
/**
|
|
11
|
-
*
|
|
8
|
+
* Update the entire server object
|
|
12
9
|
*/
|
|
13
|
-
'
|
|
14
|
-
/** The
|
|
15
|
-
|
|
10
|
+
'server:update:server': {
|
|
11
|
+
/** The index of the server to update */
|
|
12
|
+
index: number;
|
|
13
|
+
/** The new server payload to update */
|
|
14
|
+
server: Partial<ServerObject>;
|
|
16
15
|
};
|
|
17
16
|
/**
|
|
18
|
-
*
|
|
17
|
+
* Delete a server from the document
|
|
19
18
|
*/
|
|
20
|
-
'
|
|
21
|
-
/** The
|
|
22
|
-
|
|
19
|
+
'server:delete:server': {
|
|
20
|
+
/** The index of the server to delete */
|
|
21
|
+
index: number;
|
|
23
22
|
};
|
|
24
23
|
/**
|
|
25
24
|
* Update the selected server variable for the document
|
|
26
25
|
*/
|
|
27
|
-
'update:
|
|
26
|
+
'server:update:variables': {
|
|
27
|
+
/** The index of the server to update */
|
|
28
|
+
index: number;
|
|
28
29
|
/** The key of the variable to update */
|
|
29
30
|
key: string;
|
|
30
31
|
/** The new value of the variable */
|
|
31
32
|
value: string;
|
|
32
33
|
};
|
|
33
34
|
/**
|
|
34
|
-
* Update the selected server
|
|
35
|
-
*/
|
|
36
|
-
'update:selected-server-properties': {
|
|
37
|
-
/** The key of the property to update */
|
|
38
|
-
key: T;
|
|
39
|
-
/** The new value of the property */
|
|
40
|
-
value: ServerObject[T];
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* Replace all servers in the document
|
|
35
|
+
* Update the selected server for the document
|
|
44
36
|
*/
|
|
45
|
-
'update:
|
|
46
|
-
/** The
|
|
47
|
-
|
|
37
|
+
'server:update:selected': {
|
|
38
|
+
/** The index of the server to update */
|
|
39
|
+
index: number;
|
|
48
40
|
};
|
|
49
41
|
};
|
|
50
42
|
//# sourceMappingURL=server.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/events/definitions/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAA;AAE1E,MAAM,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/events/definitions/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAA;AAE1E,MAAM,MAAM,YAAY,GAAG;IACzB;;OAEG;IACH,mBAAmB,EAAE,SAAS,CAAA;IAC9B;;OAEG;IACH,sBAAsB,EAAE;QACtB,wCAAwC;QACxC,KAAK,EAAE,MAAM,CAAA;QACb,uCAAuC;QACvC,MAAM,EAAE,OAAO,CAAC,YAAY,CAAC,CAAA;KAC9B,CAAA;IACD;;OAEG;IACH,sBAAsB,EAAE;QACtB,wCAAwC;QACxC,KAAK,EAAE,MAAM,CAAA;KACd,CAAA;IACD;;OAEG;IACH,yBAAyB,EAAE;QACzB,wCAAwC;QACxC,KAAK,EAAE,MAAM,CAAA;QACb,wCAAwC;QACxC,GAAG,EAAE,MAAM,CAAA;QACX,oCAAoC;QACpC,KAAK,EAAE,MAAM,CAAA;KACd,CAAA;IACD;;OAEG;IACH,wBAAwB,EAAE;QACxB,wCAAwC;QACxC,KAAK,EAAE,MAAM,CAAA;KACd,CAAA;CACF,CAAA"}
|
package/dist/events/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { type WorkspaceEventBus, createWorkspaceEventBus } from './bus.js';
|
|
2
|
-
export type { CollectionType } from './definitions/index.js';
|
|
2
|
+
export type { ApiReferenceEvents, CollectionType } from './definitions/index.js';
|
|
3
3
|
export { onCustomEvent } from './listeners.js';
|
|
4
|
-
export {
|
|
4
|
+
export { emitCustomEvent } from './old-definitions.js';
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/events/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,OAAO,CAAA;AACvE,YAAY,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/events/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,OAAO,CAAA;AACvE,YAAY,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA"}
|
package/dist/events/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/events/index.ts"],
|
|
4
|
-
"sourcesContent": ["// biome-ignore lint/performance/noBarrelFile: Entry point for /events\nexport { type WorkspaceEventBus, createWorkspaceEventBus } from './bus'\nexport type { CollectionType } from './definitions'\nexport { onCustomEvent } from './listeners'\nexport {
|
|
5
|
-
"mappings": "AACA,SAAiC,+BAA+B;AAEhE,SAAS,qBAAqB;AAC9B,
|
|
4
|
+
"sourcesContent": ["// biome-ignore lint/performance/noBarrelFile: Entry point for /events\nexport { type WorkspaceEventBus, createWorkspaceEventBus } from './bus'\nexport type { ApiReferenceEvents, CollectionType } from './definitions'\nexport { onCustomEvent } from './listeners'\nexport { emitCustomEvent } from './old-definitions'\n"],
|
|
5
|
+
"mappings": "AACA,SAAiC,+BAA+B;AAEhE,SAAS,qBAAqB;AAC9B,SAAS,uBAAuB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/mutators/auth.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { HttpMethod } from '@scalar/helpers/http/http-methods';
|
|
2
|
+
import type { AuthEvents } from '../events/definitions/auth.js';
|
|
2
3
|
import type { WorkspaceDocument } from '../schemas.js';
|
|
3
|
-
import type { SecurityRequirementObject } from '../schemas/v3.1/strict/security-requirement.js';
|
|
4
|
-
import type { SecuritySchemeObject } from '../schemas/v3.1/strict/security-scheme.js';
|
|
5
4
|
/**
|
|
6
5
|
* AuthMeta defines the meta information needed to specify whether the authentication operation
|
|
7
6
|
* is being performed at the document level (entire API), or for a specific operation (specific path and method).
|
|
@@ -40,52 +39,7 @@ export type AuthMeta = {
|
|
|
40
39
|
* })
|
|
41
40
|
* ```
|
|
42
41
|
*/
|
|
43
|
-
export declare const updateSelectedSecuritySchemes: (
|
|
44
|
-
document: WorkspaceDocument | null;
|
|
45
|
-
selectedRequirements: SecurityRequirementObject[];
|
|
46
|
-
newSchemes: {
|
|
47
|
-
name: string;
|
|
48
|
-
scheme: SecuritySchemeObject;
|
|
49
|
-
}[];
|
|
50
|
-
meta: AuthMeta;
|
|
51
|
-
}) => void;
|
|
52
|
-
/**
|
|
53
|
-
* SecuritySchemeUpdate represents the possible updates that can be made
|
|
54
|
-
* to an OpenAPI security scheme object via UI interactions.
|
|
55
|
-
*
|
|
56
|
-
* - `http`: Updates to HTTP type schemes (e.g. basic, bearer), allowing token, username, and password changes.
|
|
57
|
-
* - `apiKey`: Updates to API Key type schemes, allowing the key name and its value to be updated.
|
|
58
|
-
* - `oauth2`: Updates to OAuth2 type schemes for each supported OAuth2 flow.
|
|
59
|
-
* - Can set various properties such as auth/token URLs, tokens, PKCE method, client credentials, etc.
|
|
60
|
-
*/
|
|
61
|
-
export type SecuritySchemeUpdate = {
|
|
62
|
-
type: 'http';
|
|
63
|
-
payload: Partial<{
|
|
64
|
-
token: string;
|
|
65
|
-
username: string;
|
|
66
|
-
password: string;
|
|
67
|
-
}>;
|
|
68
|
-
} | {
|
|
69
|
-
type: 'apiKey';
|
|
70
|
-
payload: Partial<{
|
|
71
|
-
name: string;
|
|
72
|
-
value: string;
|
|
73
|
-
}>;
|
|
74
|
-
} | {
|
|
75
|
-
type: 'oauth2';
|
|
76
|
-
flow: 'implicit' | 'password' | 'clientCredentials' | 'authorizationCode';
|
|
77
|
-
payload: Partial<{
|
|
78
|
-
authUrl: string;
|
|
79
|
-
tokenUrl: string;
|
|
80
|
-
token: string;
|
|
81
|
-
redirectUrl: string;
|
|
82
|
-
clientId: string;
|
|
83
|
-
clientSecret: string;
|
|
84
|
-
usePkce: 'no' | 'SHA-256' | 'plain';
|
|
85
|
-
username: string;
|
|
86
|
-
password: string;
|
|
87
|
-
}>;
|
|
88
|
-
};
|
|
42
|
+
export declare const updateSelectedSecuritySchemes: (document: WorkspaceDocument | null, { selectedRequirements, newSchemes, meta }: AuthEvents["auth:update:selected-security-schemes"]) => void;
|
|
89
43
|
/**
|
|
90
44
|
* Updates a security scheme in the OpenAPI document's components object.
|
|
91
45
|
* Handles updates for HTTP, API Key, and OAuth2 types, saving secret information and configuration for UI-auth flows.
|
|
@@ -109,15 +63,11 @@ export type SecuritySchemeUpdate = {
|
|
|
109
63
|
* name: 'MyHttpAuth',
|
|
110
64
|
* })
|
|
111
65
|
*/
|
|
112
|
-
export declare const updateSecurityScheme: (
|
|
113
|
-
document: WorkspaceDocument | null;
|
|
114
|
-
data: SecuritySchemeUpdate;
|
|
115
|
-
name: string;
|
|
116
|
-
}) => void;
|
|
66
|
+
export declare const updateSecurityScheme: (document: WorkspaceDocument | null, { payload, name }: AuthEvents["auth:update:security-scheme"]) => import("../schemas/v3.1/strict/security-scheme.js").ApiKeyObject | import("../schemas/v3.1/strict/security-scheme.js").HttpObject | import("../schemas/v3.1/strict/security-scheme.js").OAuth2Object | import("../schemas/v3.1/strict/security-scheme.js").OpenIdConnectObject | undefined;
|
|
117
67
|
/**
|
|
118
68
|
* Sets the selected authentication tab (scheme) index for the given OpenAPI document or operation.
|
|
119
|
-
* - When on the document level, updates the '
|
|
120
|
-
* - When on an operation (endpoint) level, updates the '
|
|
69
|
+
* - When on the document level, updates the 'selectedIndex' on the document's x-scalar-selected-security extension.
|
|
70
|
+
* - When on an operation (endpoint) level, updates the 'selectedIndex' for that operation's x-scalar-selected-security.
|
|
121
71
|
*
|
|
122
72
|
* Also initializes the x-scalar-selected-security extension if it does not exist.
|
|
123
73
|
*
|
|
@@ -140,11 +90,7 @@ export declare const updateSecurityScheme: ({ document, data, name, }: {
|
|
|
140
90
|
* meta: { type: 'operation', path: '/pets', method: 'get' }
|
|
141
91
|
* });
|
|
142
92
|
*/
|
|
143
|
-
export declare const updateSelectedAuthTab: (
|
|
144
|
-
document: WorkspaceDocument | null;
|
|
145
|
-
index: number;
|
|
146
|
-
meta: AuthMeta;
|
|
147
|
-
}) => void;
|
|
93
|
+
export declare const updateSelectedAuthTab: (document: WorkspaceDocument | null, { index, meta }: AuthEvents["auth:update:active-index"]) => void;
|
|
148
94
|
/**
|
|
149
95
|
* Updates the scopes for a specific security requirement in the selected security schemes of
|
|
150
96
|
* a document or operation.
|
|
@@ -160,8 +106,8 @@ export declare const updateSelectedAuthTab: ({ document, index, meta, }: {
|
|
|
160
106
|
* ```ts
|
|
161
107
|
* // Suppose your document (or operation) x-scalar-selected-security looks like:
|
|
162
108
|
* // "x-scalar-selected-security": {
|
|
163
|
-
* //
|
|
164
|
-
* //
|
|
109
|
+
* // selectedIndex: 0,
|
|
110
|
+
* // selectedSchemes: [
|
|
165
111
|
* // { "OAuth": ["read:pets"] },
|
|
166
112
|
* // { "ApiKeyAuth": [] }
|
|
167
113
|
* // ]
|
|
@@ -177,13 +123,7 @@ export declare const updateSelectedAuthTab: ({ document, index, meta, }: {
|
|
|
177
123
|
* // After, the first scheme becomes: { "OAuth": ["write:pets"] }
|
|
178
124
|
* ```
|
|
179
125
|
*/
|
|
180
|
-
export declare const updateSelectedScopes: (
|
|
181
|
-
document: WorkspaceDocument | null;
|
|
182
|
-
id: string[];
|
|
183
|
-
name: string;
|
|
184
|
-
scopes: string[];
|
|
185
|
-
meta: AuthMeta;
|
|
186
|
-
}) => void;
|
|
126
|
+
export declare const updateSelectedScopes: (document: WorkspaceDocument | null, { id, name, scopes, meta }: AuthEvents["auth:update:selected-scopes"]) => void;
|
|
187
127
|
/**
|
|
188
128
|
* Deletes one or more security schemes from an OpenAPI WorkspaceDocument,
|
|
189
129
|
* and removes all references to those schemes from selected security, document-level security,
|
|
@@ -203,8 +143,5 @@ export declare const updateSelectedScopes: ({ document, id, name, scopes, meta,
|
|
|
203
143
|
* - All document-level and operation-level security entries referencing those schemes are removed.
|
|
204
144
|
* - Any extended x-scalar-selected-security references to those schemes are also removed.
|
|
205
145
|
*/
|
|
206
|
-
export declare const deleteSecurityScheme: (
|
|
207
|
-
document: WorkspaceDocument | null;
|
|
208
|
-
names: string[];
|
|
209
|
-
}) => void;
|
|
146
|
+
export declare const deleteSecurityScheme: (document: WorkspaceDocument | null, { names }: AuthEvents["auth:delete:security-scheme"]) => void;
|
|
210
147
|
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/mutators/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAA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AC,SA6DrD,CAAA"}
|
package/dist/mutators/auth.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import { generateUniqueValue } from "../helpers/generate-unique-value.js";
|
|
2
2
|
import { getResolvedRef } from "../helpers/get-resolved-ref.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
selectedRequirements,
|
|
6
|
-
newSchemes,
|
|
7
|
-
meta
|
|
8
|
-
}) => {
|
|
3
|
+
import { mergeObjects } from "../helpers/merge-object.js";
|
|
4
|
+
const updateSelectedSecuritySchemes = (document, { selectedRequirements, newSchemes, meta }) => {
|
|
9
5
|
if (!document) {
|
|
10
6
|
return;
|
|
11
7
|
}
|
|
@@ -42,88 +38,31 @@ const updateSelectedSecuritySchemes = ({
|
|
|
42
38
|
}
|
|
43
39
|
if (!target["x-scalar-selected-security"]) {
|
|
44
40
|
target["x-scalar-selected-security"] = {
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
selectedIndex: -1,
|
|
42
|
+
selectedSchemes: []
|
|
47
43
|
};
|
|
48
44
|
}
|
|
49
|
-
const selectedIndex = target["x-scalar-selected-security"]
|
|
50
|
-
target["x-scalar-selected-security"]
|
|
45
|
+
const selectedIndex = target["x-scalar-selected-security"].selectedIndex;
|
|
46
|
+
target["x-scalar-selected-security"].selectedSchemes = newSelectedSecuritySchemes;
|
|
51
47
|
if (newSelectedSecuritySchemes.length > 0 && selectedIndex < 0) {
|
|
52
|
-
target["x-scalar-selected-security"]
|
|
48
|
+
target["x-scalar-selected-security"].selectedIndex = 0;
|
|
53
49
|
}
|
|
54
50
|
if (selectedIndex >= newSelectedSecuritySchemes.length) {
|
|
55
|
-
target["x-scalar-selected-security"]
|
|
51
|
+
target["x-scalar-selected-security"].selectedIndex = newSelectedSecuritySchemes.length - 1;
|
|
56
52
|
}
|
|
57
53
|
};
|
|
58
|
-
const updateSecurityScheme = ({
|
|
59
|
-
document
|
|
60
|
-
data,
|
|
61
|
-
name
|
|
62
|
-
}) => {
|
|
63
|
-
if (!document) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
const target = getResolvedRef(document.components?.securitySchemes?.[name]);
|
|
54
|
+
const updateSecurityScheme = (document, { payload, name }) => {
|
|
55
|
+
const target = getResolvedRef(document?.components?.securitySchemes?.[name]);
|
|
67
56
|
if (!target) {
|
|
57
|
+
console.error(`Security scheme ${name} not found`);
|
|
68
58
|
return;
|
|
69
59
|
}
|
|
70
|
-
if (target.type ===
|
|
71
|
-
|
|
72
|
-
target["x-scalar-secret-username"] = data.payload.username;
|
|
73
|
-
}
|
|
74
|
-
if (data.payload.password) {
|
|
75
|
-
target["x-scalar-secret-password"] = data.payload.password;
|
|
76
|
-
}
|
|
77
|
-
if (data.payload.token) {
|
|
78
|
-
target["x-scalar-secret-token"] = data.payload.token;
|
|
79
|
-
}
|
|
80
|
-
} else if (target.type === "apiKey" && data.type === "apiKey") {
|
|
81
|
-
if (data.payload.name) {
|
|
82
|
-
target.name = data.payload.name;
|
|
83
|
-
}
|
|
84
|
-
if (data.payload.value) {
|
|
85
|
-
target["x-scalar-secret-token"] = data.payload.value;
|
|
86
|
-
}
|
|
87
|
-
} else if (target.type === "oauth2" && data.type === "oauth2") {
|
|
88
|
-
const flow = target.flows[data.flow];
|
|
89
|
-
if (!flow) {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
if (data.payload.authUrl && "authorizationUrl" in flow) {
|
|
93
|
-
flow.authorizationUrl = data.payload.authUrl;
|
|
94
|
-
}
|
|
95
|
-
if (data.payload.tokenUrl && "tokenUrl" in flow) {
|
|
96
|
-
flow.tokenUrl = data.payload.tokenUrl;
|
|
97
|
-
}
|
|
98
|
-
if (data.payload.token && "x-scalar-secret-token" in flow) {
|
|
99
|
-
flow["x-scalar-secret-token"] = data.payload.token;
|
|
100
|
-
}
|
|
101
|
-
if (data.payload.redirectUrl && "x-scalar-secret-redirect-uri" in flow) {
|
|
102
|
-
flow["x-scalar-secret-redirect-uri"] = data.payload.redirectUrl;
|
|
103
|
-
}
|
|
104
|
-
if (data.payload.clientId && "x-scalar-secret-client-id" in flow) {
|
|
105
|
-
flow["x-scalar-secret-client-id"] = data.payload.clientId;
|
|
106
|
-
}
|
|
107
|
-
if (data.payload.clientSecret && "x-scalar-secret-client-secret" in flow) {
|
|
108
|
-
flow["x-scalar-secret-client-secret"] = data.payload.clientSecret;
|
|
109
|
-
}
|
|
110
|
-
if (data.payload.usePkce && "x-usePkce" in flow) {
|
|
111
|
-
flow["x-usePkce"] = data.payload.usePkce;
|
|
112
|
-
}
|
|
113
|
-
if (data.payload.username && "x-scalar-secret-username" in flow) {
|
|
114
|
-
flow["x-scalar-secret-username"] = data.payload.username;
|
|
115
|
-
}
|
|
116
|
-
if (data.payload.password && "x-scalar-secret-password" in flow) {
|
|
117
|
-
flow["x-scalar-secret-password"] = data.payload.password;
|
|
118
|
-
}
|
|
60
|
+
if (target.type === payload.type) {
|
|
61
|
+
mergeObjects(target, payload);
|
|
119
62
|
}
|
|
120
|
-
return;
|
|
63
|
+
return target;
|
|
121
64
|
};
|
|
122
|
-
const updateSelectedAuthTab = ({
|
|
123
|
-
document,
|
|
124
|
-
index,
|
|
125
|
-
meta
|
|
126
|
-
}) => {
|
|
65
|
+
const updateSelectedAuthTab = (document, { index, meta }) => {
|
|
127
66
|
if (!document) {
|
|
128
67
|
return;
|
|
129
68
|
}
|
|
@@ -139,19 +78,13 @@ const updateSelectedAuthTab = ({
|
|
|
139
78
|
}
|
|
140
79
|
if (!target["x-scalar-selected-security"]) {
|
|
141
80
|
target["x-scalar-selected-security"] = {
|
|
142
|
-
|
|
143
|
-
|
|
81
|
+
selectedIndex: 0,
|
|
82
|
+
selectedSchemes: []
|
|
144
83
|
};
|
|
145
84
|
}
|
|
146
|
-
target["x-scalar-selected-security"]
|
|
85
|
+
target["x-scalar-selected-security"].selectedIndex = index;
|
|
147
86
|
};
|
|
148
|
-
const updateSelectedScopes = ({
|
|
149
|
-
document,
|
|
150
|
-
id,
|
|
151
|
-
name,
|
|
152
|
-
scopes,
|
|
153
|
-
meta
|
|
154
|
-
}) => {
|
|
87
|
+
const updateSelectedScopes = (document, { id, name, scopes, meta }) => {
|
|
155
88
|
if (!document) {
|
|
156
89
|
return;
|
|
157
90
|
}
|
|
@@ -165,7 +98,7 @@ const updateSelectedScopes = ({
|
|
|
165
98
|
if (!target) {
|
|
166
99
|
return;
|
|
167
100
|
}
|
|
168
|
-
const selectedSchemes = target["x-scalar-selected-security"]?.
|
|
101
|
+
const selectedSchemes = target["x-scalar-selected-security"]?.selectedSchemes;
|
|
169
102
|
if (!selectedSchemes) {
|
|
170
103
|
return;
|
|
171
104
|
}
|
|
@@ -175,7 +108,7 @@ const updateSelectedScopes = ({
|
|
|
175
108
|
}
|
|
176
109
|
scheme[name] = scopes;
|
|
177
110
|
};
|
|
178
|
-
const deleteSecurityScheme = (
|
|
111
|
+
const deleteSecurityScheme = (document, { names }) => {
|
|
179
112
|
if (!document) {
|
|
180
113
|
return;
|
|
181
114
|
}
|
|
@@ -191,7 +124,7 @@ const deleteSecurityScheme = ({ document, names }) => {
|
|
|
191
124
|
};
|
|
192
125
|
if (document["x-scalar-selected-security"]) {
|
|
193
126
|
const selectedSecurity = document["x-scalar-selected-security"];
|
|
194
|
-
selectedSecurity
|
|
127
|
+
selectedSecurity.selectedSchemes = filterSecuritySchemes(selectedSecurity.selectedSchemes);
|
|
195
128
|
}
|
|
196
129
|
if (document["security"]) {
|
|
197
130
|
document["security"] = filterSecuritySchemes(document["security"]);
|
|
@@ -206,8 +139,8 @@ const deleteSecurityScheme = ({ document, names }) => {
|
|
|
206
139
|
resolvedOperation["security"] = filterSecuritySchemes(resolvedOperation["security"]);
|
|
207
140
|
}
|
|
208
141
|
if ("x-scalar-selected-security" in resolvedOperation && resolvedOperation["x-scalar-selected-security"]) {
|
|
209
|
-
resolvedOperation["x-scalar-selected-security"]
|
|
210
|
-
resolvedOperation["x-scalar-selected-security"]
|
|
142
|
+
resolvedOperation["x-scalar-selected-security"].selectedSchemes = filterSecuritySchemes(
|
|
143
|
+
resolvedOperation["x-scalar-selected-security"].selectedSchemes
|
|
211
144
|
);
|
|
212
145
|
}
|
|
213
146
|
});
|