@scalar/oas-utils 0.2.60 → 0.2.62
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 +17 -0
- package/dist/entities/hotkeys/hotkeys.d.ts +1 -1
- package/dist/entities/hotkeys/hotkeys.d.ts.map +1 -1
- package/dist/entities/hotkeys/hotkeys.js +1 -1
- package/dist/entities/spec/collection.d.ts +8 -0
- package/dist/entities/spec/collection.d.ts.map +1 -1
- package/dist/entities/spec/collection.js +2 -0
- package/dist/entities/spec/request-examples.d.ts.map +1 -1
- package/dist/entities/spec/request-examples.js +7 -0
- package/dist/entities/spec/requests.d.ts +2 -2
- package/dist/entities/workspace/workspace.d.ts +10 -10
- package/dist/migrations/v-2.1.0/migration.d.ts +1 -0
- package/dist/migrations/v-2.1.0/migration.d.ts.map +1 -1
- package/dist/migrations/v-2.1.0/migration.js +1 -0
- package/dist/transforms/export-spec.d.ts +1 -0
- package/dist/transforms/export-spec.d.ts.map +1 -1
- package/dist/transforms/import-spec.d.ts +6 -2
- package/dist/transforms/import-spec.d.ts.map +1 -1
- package/dist/transforms/import-spec.js +60 -9
- package/package.json +5 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @scalar/oas-utils
|
|
2
2
|
|
|
3
|
+
## 0.2.62
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 097ab40: fix: add mapping of header to headers for api client ingress
|
|
8
|
+
- Updated dependencies [197e3ae]
|
|
9
|
+
- @scalar/themes@0.9.43
|
|
10
|
+
|
|
11
|
+
## 0.2.61
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- d7a6c55: feat: updates n hotkey event name
|
|
16
|
+
- 69bda25: feat: synced up client auth with references
|
|
17
|
+
- Updated dependencies [2456afa]
|
|
18
|
+
- @scalar/themes@0.9.42
|
|
19
|
+
|
|
3
20
|
## 0.2.60
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Array of all of the events that we support
|
|
3
3
|
*/
|
|
4
|
-
export declare const HOTKEY_EVENT_NAMES: readonly ["closeModal", "navigateSearchResultsDown", "selectSearchResult", "navigateSearchResultsUp", "openCommandPalette", "
|
|
4
|
+
export declare const HOTKEY_EVENT_NAMES: readonly ["closeModal", "navigateSearchResultsDown", "selectSearchResult", "navigateSearchResultsUp", "openCommandPalette", "createNew", "toggleSidebar", "addTopNav", "closeTopNav", "navigateTopNavLeft", "navigateTopNavRight", "focusAddressBar", "jumpToTab", "jumpToLastTab", "focusRequestSearch"];
|
|
5
5
|
export type HotkeyEventName = (typeof HOTKEY_EVENT_NAMES)[number];
|
|
6
6
|
/**
|
|
7
7
|
* Array of all of the hotkeys that we support
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hotkeys.d.ts","sourceRoot":"","sources":["../../../src/entities/hotkeys/hotkeys.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,kBAAkB,
|
|
1
|
+
{"version":3,"file":"hotkeys.d.ts","sourceRoot":"","sources":["../../../src/entities/hotkeys/hotkeys.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,kBAAkB,2SAgBrB,CAAA;AACV,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAA;AAEjE;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,8hBAyFf,CAAA;AACV,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAA"}
|
|
@@ -3,6 +3,8 @@ export declare const extendedCollectionSchema: z.ZodObject<{
|
|
|
3
3
|
uid: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
4
4
|
/** A list of security schemes UIDs associated with the collection */
|
|
5
5
|
securitySchemes: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
6
|
+
/** List of currently selected security scheme UIDs, these can be overridden per request */
|
|
7
|
+
selectedSecuritySchemeUids: z.ZodDefault<z.ZodArray<z.ZodDefault<z.ZodOptional<z.ZodString>>, "many">>;
|
|
6
8
|
/** The currently selected server */
|
|
7
9
|
selectedServerUid: z.ZodDefault<z.ZodString>;
|
|
8
10
|
/** UIDs which refer to servers on the workspace base */
|
|
@@ -116,6 +118,7 @@ export declare const extendedCollectionSchema: z.ZodObject<{
|
|
|
116
118
|
uid: string;
|
|
117
119
|
children: string[];
|
|
118
120
|
securitySchemes: string[];
|
|
121
|
+
selectedSecuritySchemeUids: string[];
|
|
119
122
|
selectedServerUid: string;
|
|
120
123
|
servers: string[];
|
|
121
124
|
requests: string[];
|
|
@@ -154,6 +157,7 @@ export declare const extendedCollectionSchema: z.ZodObject<{
|
|
|
154
157
|
uid?: string | undefined;
|
|
155
158
|
children?: (string | undefined)[] | undefined;
|
|
156
159
|
securitySchemes?: string[] | undefined;
|
|
160
|
+
selectedSecuritySchemeUids?: (string | undefined)[] | undefined;
|
|
157
161
|
selectedServerUid?: string | undefined;
|
|
158
162
|
servers?: (string | undefined)[] | undefined;
|
|
159
163
|
requests?: (string | undefined)[] | undefined;
|
|
@@ -286,6 +290,8 @@ export declare const collectionSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
286
290
|
uid: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
287
291
|
/** A list of security schemes UIDs associated with the collection */
|
|
288
292
|
securitySchemes: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
293
|
+
/** List of currently selected security scheme UIDs, these can be overridden per request */
|
|
294
|
+
selectedSecuritySchemeUids: z.ZodDefault<z.ZodArray<z.ZodDefault<z.ZodOptional<z.ZodString>>, "many">>;
|
|
289
295
|
/** The currently selected server */
|
|
290
296
|
selectedServerUid: z.ZodDefault<z.ZodString>;
|
|
291
297
|
/** UIDs which refer to servers on the workspace base */
|
|
@@ -403,6 +409,7 @@ export declare const collectionSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
403
409
|
security: Record<string, string[]>[];
|
|
404
410
|
'x-scalar-icon': string;
|
|
405
411
|
securitySchemes: string[];
|
|
412
|
+
selectedSecuritySchemeUids: string[];
|
|
406
413
|
selectedServerUid: string;
|
|
407
414
|
servers: string[];
|
|
408
415
|
requests: string[];
|
|
@@ -493,6 +500,7 @@ export declare const collectionSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
493
500
|
webhooks?: Record<string, unknown> | undefined;
|
|
494
501
|
'x-scalar-icon'?: string | undefined;
|
|
495
502
|
securitySchemes?: string[] | undefined;
|
|
503
|
+
selectedSecuritySchemeUids?: (string | undefined)[] | undefined;
|
|
496
504
|
selectedServerUid?: string | undefined;
|
|
497
505
|
servers?: (string | undefined)[] | undefined;
|
|
498
506
|
requests?: (string | undefined)[] | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/collection.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAyCvB,eAAO,MAAM,wBAAwB;;IAEnC,qEAAqE;;IAErE,oCAAoC;;IAEpC,wDAAwD;;IAExD,gDAAgD;;IAEhD,8CAA8C;;IAE9C,gEAAgE;;IAEhE;;;;;OAKG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAEH,wGAAwG;;IAExG;;;;OAIG;;IAEH;;;;OAIG
|
|
1
|
+
{"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/collection.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAyCvB,eAAO,MAAM,wBAAwB;;IAEnC,qEAAqE;;IAErE,2FAA2F;;IAE3F,oCAAoC;;IA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of security schemes UIDs associated with the collection */
|
|
44
44
|
securitySchemes: z.string().array().default([]),
|
|
45
|
+
/** List of currently selected security scheme UIDs, these can be overridden per request */
|
|
46
|
+
selectedSecuritySchemeUids: nanoidSchema.array().default([]),
|
|
45
47
|
/** The currently selected server */
|
|
46
48
|
selectedServerUid: z.string().default(''),
|
|
47
49
|
/** UIDs which refer to servers on the workspace base */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request-examples.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/request-examples.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AACpD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACzC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAEtC,eAAO,MAAM,8BAA8B;;;;;;IAMzC,kFAAkF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAUlF,CAAA;AAEF,kFAAkF;AAClF,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAC3C,OAAO,8BAA8B,CACtC,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,uEAQ7B,CAAA;AACV,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,0BAA0B,CAAC,CAAC,MAAM,CAAC,CAAA;AAEtE,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;YAjCnC,kFAAkF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoDlF,CAAA;AACF,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAA;AAEzE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[],
|
|
114
114
|
cookie: [],
|
|
115
|
+
// deprecated TODO: add zod transform to remove
|
|
115
116
|
header: [],
|
|
117
|
+
headers: [],
|
|
116
118
|
};
|
|
117
119
|
// Populated the separated params
|
|
118
120
|
request.parameters?.forEach((p) => parameters[p.in].push(createParamInstance(p)));
|
|
121
|
+
// TODO: add zod transform to remove header and only support headers
|
|
122
|
+
if (parameters.header.length > 0) {
|
|
123
|
+
parameters.headers = parameters.header;
|
|
124
|
+
parameters.header = [];
|
|
125
|
+
}
|
|
119
126
|
// ---------------------------------------------------------------------------
|
|
120
127
|
// Handle request body defaulting for various content type encodings
|
|
121
128
|
const body = {
|
|
@@ -255,11 +255,11 @@ export declare const requestSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
255
255
|
path: string;
|
|
256
256
|
type: "request";
|
|
257
257
|
uid: string;
|
|
258
|
+
selectedSecuritySchemeUids: string[];
|
|
258
259
|
selectedServerUid: string;
|
|
259
260
|
servers: string[];
|
|
260
261
|
examples: string[];
|
|
261
262
|
method: "options" | "delete" | "get" | "connect" | "head" | "patch" | "post" | "put" | "trace";
|
|
262
|
-
selectedSecuritySchemeUids: string[];
|
|
263
263
|
description?: string | undefined;
|
|
264
264
|
summary?: string | undefined;
|
|
265
265
|
externalDocs?: {
|
|
@@ -293,6 +293,7 @@ export declare const requestSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
293
293
|
url?: string | undefined;
|
|
294
294
|
} | undefined;
|
|
295
295
|
security?: Record<string, string[] | undefined>[] | undefined;
|
|
296
|
+
selectedSecuritySchemeUids?: (string | undefined)[] | undefined;
|
|
296
297
|
selectedServerUid?: string | undefined;
|
|
297
298
|
servers?: (string | undefined)[] | undefined;
|
|
298
299
|
tags?: string[] | undefined;
|
|
@@ -312,7 +313,6 @@ export declare const requestSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
312
313
|
}[] | undefined;
|
|
313
314
|
requestBody?: any;
|
|
314
315
|
responses?: Record<string, any> | undefined;
|
|
315
|
-
selectedSecuritySchemeUids?: (string | undefined)[] | undefined;
|
|
316
316
|
}>;
|
|
317
317
|
export type Request = z.infer<typeof requestSchema>;
|
|
318
318
|
export type RequestPayload = z.input<typeof requestSchema>;
|
|
@@ -3,12 +3,12 @@ declare const modifiers: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodDefault<z.Zo
|
|
|
3
3
|
export type HotKeyModifiers = z.infer<typeof modifiers>;
|
|
4
4
|
declare const hotKeys: z.ZodRecord<z.ZodEnum<["Space", "Backspace", "Tab", "Enter", "Escape", "ArrowDown", "ArrowLeft", "ArrowRight", "ArrowUp", "End", "Home", "PageDown", "PageUp", "Delete", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "*", "+", "-", ".", "/", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12", ";", "=", ",", "-", ".", "/", "`", "[", "\\", "]", ""]>, z.ZodObject<{
|
|
5
5
|
modifiers: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodDefault<z.ZodOptional<z.ZodEnum<["Meta", "Control", "Shift", "Alt", "default"]>>>, "many">>>>;
|
|
6
|
-
event: z.ZodEnum<["closeModal", "navigateSearchResultsDown", "selectSearchResult", "navigateSearchResultsUp", "openCommandPalette", "
|
|
6
|
+
event: z.ZodEnum<["closeModal", "navigateSearchResultsDown", "selectSearchResult", "navigateSearchResultsUp", "openCommandPalette", "createNew", "toggleSidebar", "addTopNav", "closeTopNav", "navigateTopNavLeft", "navigateTopNavRight", "focusAddressBar", "jumpToTab", "jumpToLastTab", "focusRequestSearch"]>;
|
|
7
7
|
}, "strip", z.ZodTypeAny, {
|
|
8
|
-
event: "closeModal" | "navigateSearchResultsDown" | "selectSearchResult" | "navigateSearchResultsUp" | "openCommandPalette" | "
|
|
8
|
+
event: "closeModal" | "navigateSearchResultsDown" | "selectSearchResult" | "navigateSearchResultsUp" | "openCommandPalette" | "createNew" | "toggleSidebar" | "addTopNav" | "closeTopNav" | "navigateTopNavLeft" | "navigateTopNavRight" | "focusAddressBar" | "jumpToTab" | "jumpToLastTab" | "focusRequestSearch";
|
|
9
9
|
modifiers?: ("Meta" | "Control" | "Shift" | "Alt" | "default")[] | undefined;
|
|
10
10
|
}, {
|
|
11
|
-
event: "closeModal" | "navigateSearchResultsDown" | "selectSearchResult" | "navigateSearchResultsUp" | "openCommandPalette" | "
|
|
11
|
+
event: "closeModal" | "navigateSearchResultsDown" | "selectSearchResult" | "navigateSearchResultsUp" | "openCommandPalette" | "createNew" | "toggleSidebar" | "addTopNav" | "closeTopNav" | "navigateTopNavLeft" | "navigateTopNavRight" | "focusAddressBar" | "jumpToTab" | "jumpToLastTab" | "focusRequestSearch";
|
|
12
12
|
modifiers?: ("Meta" | "Control" | "Shift" | "Alt" | "default" | undefined)[] | undefined;
|
|
13
13
|
}>>;
|
|
14
14
|
export type HotKeyConfig = z.infer<typeof hotKeys>;
|
|
@@ -28,24 +28,24 @@ export declare const workspaceSchema: z.ZodObject<{
|
|
|
28
28
|
modifiers: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodDefault<z.ZodOptional<z.ZodEnum<["Meta", "Control", "Shift", "Alt", "default"]>>>, "many">>>;
|
|
29
29
|
hotKeys: z.ZodOptional<z.ZodRecord<z.ZodEnum<["Space", "Backspace", "Tab", "Enter", "Escape", "ArrowDown", "ArrowLeft", "ArrowRight", "ArrowUp", "End", "Home", "PageDown", "PageUp", "Delete", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "*", "+", "-", ".", "/", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12", ";", "=", ",", "-", ".", "/", "`", "[", "\\", "]", ""]>, z.ZodObject<{
|
|
30
30
|
modifiers: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodDefault<z.ZodOptional<z.ZodEnum<["Meta", "Control", "Shift", "Alt", "default"]>>>, "many">>>>;
|
|
31
|
-
event: z.ZodEnum<["closeModal", "navigateSearchResultsDown", "selectSearchResult", "navigateSearchResultsUp", "openCommandPalette", "
|
|
31
|
+
event: z.ZodEnum<["closeModal", "navigateSearchResultsDown", "selectSearchResult", "navigateSearchResultsUp", "openCommandPalette", "createNew", "toggleSidebar", "addTopNav", "closeTopNav", "navigateTopNavLeft", "navigateTopNavRight", "focusAddressBar", "jumpToTab", "jumpToLastTab", "focusRequestSearch"]>;
|
|
32
32
|
}, "strip", z.ZodTypeAny, {
|
|
33
|
-
event: "closeModal" | "navigateSearchResultsDown" | "selectSearchResult" | "navigateSearchResultsUp" | "openCommandPalette" | "
|
|
33
|
+
event: "closeModal" | "navigateSearchResultsDown" | "selectSearchResult" | "navigateSearchResultsUp" | "openCommandPalette" | "createNew" | "toggleSidebar" | "addTopNav" | "closeTopNav" | "navigateTopNavLeft" | "navigateTopNavRight" | "focusAddressBar" | "jumpToTab" | "jumpToLastTab" | "focusRequestSearch";
|
|
34
34
|
modifiers?: ("Meta" | "Control" | "Shift" | "Alt" | "default")[] | undefined;
|
|
35
35
|
}, {
|
|
36
|
-
event: "closeModal" | "navigateSearchResultsDown" | "selectSearchResult" | "navigateSearchResultsUp" | "openCommandPalette" | "
|
|
36
|
+
event: "closeModal" | "navigateSearchResultsDown" | "selectSearchResult" | "navigateSearchResultsUp" | "openCommandPalette" | "createNew" | "toggleSidebar" | "addTopNav" | "closeTopNav" | "navigateTopNavLeft" | "navigateTopNavRight" | "focusAddressBar" | "jumpToTab" | "jumpToLastTab" | "focusRequestSearch";
|
|
37
37
|
modifiers?: ("Meta" | "Control" | "Shift" | "Alt" | "default" | undefined)[] | undefined;
|
|
38
38
|
}>>>;
|
|
39
39
|
}, "strip", z.ZodTypeAny, {
|
|
40
40
|
modifiers: ("Meta" | "Control" | "Shift" | "Alt" | "default")[];
|
|
41
41
|
hotKeys?: Partial<Record<"" | "/" | "Space" | "Backspace" | "Tab" | "Enter" | "Escape" | "ArrowDown" | "ArrowLeft" | "ArrowRight" | "ArrowUp" | "End" | "Home" | "PageDown" | "PageUp" | "Delete" | "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z" | "*" | "+" | "-" | "." | "F1" | "F2" | "F3" | "F4" | "F5" | "F6" | "F7" | "F8" | "F9" | "F10" | "F11" | "F12" | ";" | "=" | "," | "`" | "[" | "\\" | "]", {
|
|
42
|
-
event: "closeModal" | "navigateSearchResultsDown" | "selectSearchResult" | "navigateSearchResultsUp" | "openCommandPalette" | "
|
|
42
|
+
event: "closeModal" | "navigateSearchResultsDown" | "selectSearchResult" | "navigateSearchResultsUp" | "openCommandPalette" | "createNew" | "toggleSidebar" | "addTopNav" | "closeTopNav" | "navigateTopNavLeft" | "navigateTopNavRight" | "focusAddressBar" | "jumpToTab" | "jumpToLastTab" | "focusRequestSearch";
|
|
43
43
|
modifiers?: ("Meta" | "Control" | "Shift" | "Alt" | "default")[] | undefined;
|
|
44
44
|
}>> | undefined;
|
|
45
45
|
}, {
|
|
46
46
|
modifiers?: ("Meta" | "Control" | "Shift" | "Alt" | "default" | undefined)[] | undefined;
|
|
47
47
|
hotKeys?: Partial<Record<"" | "/" | "Space" | "Backspace" | "Tab" | "Enter" | "Escape" | "ArrowDown" | "ArrowLeft" | "ArrowRight" | "ArrowUp" | "End" | "Home" | "PageDown" | "PageUp" | "Delete" | "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z" | "*" | "+" | "-" | "." | "F1" | "F2" | "F3" | "F4" | "F5" | "F6" | "F7" | "F8" | "F9" | "F10" | "F11" | "F12" | ";" | "=" | "," | "`" | "[" | "\\" | "]", {
|
|
48
|
-
event: "closeModal" | "navigateSearchResultsDown" | "selectSearchResult" | "navigateSearchResultsUp" | "openCommandPalette" | "
|
|
48
|
+
event: "closeModal" | "navigateSearchResultsDown" | "selectSearchResult" | "navigateSearchResultsUp" | "openCommandPalette" | "createNew" | "toggleSidebar" | "addTopNav" | "closeTopNav" | "navigateTopNavLeft" | "navigateTopNavRight" | "focusAddressBar" | "jumpToTab" | "jumpToLastTab" | "focusRequestSearch";
|
|
49
49
|
modifiers?: ("Meta" | "Control" | "Shift" | "Alt" | "default" | undefined)[] | undefined;
|
|
50
50
|
}>> | undefined;
|
|
51
51
|
}>>;
|
|
@@ -70,7 +70,7 @@ export declare const workspaceSchema: z.ZodObject<{
|
|
|
70
70
|
hotKeyConfig?: {
|
|
71
71
|
modifiers: ("Meta" | "Control" | "Shift" | "Alt" | "default")[];
|
|
72
72
|
hotKeys?: Partial<Record<"" | "/" | "Space" | "Backspace" | "Tab" | "Enter" | "Escape" | "ArrowDown" | "ArrowLeft" | "ArrowRight" | "ArrowUp" | "End" | "Home" | "PageDown" | "PageUp" | "Delete" | "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z" | "*" | "+" | "-" | "." | "F1" | "F2" | "F3" | "F4" | "F5" | "F6" | "F7" | "F8" | "F9" | "F10" | "F11" | "F12" | ";" | "=" | "," | "`" | "[" | "\\" | "]", {
|
|
73
|
-
event: "closeModal" | "navigateSearchResultsDown" | "selectSearchResult" | "navigateSearchResultsUp" | "openCommandPalette" | "
|
|
73
|
+
event: "closeModal" | "navigateSearchResultsDown" | "selectSearchResult" | "navigateSearchResultsUp" | "openCommandPalette" | "createNew" | "toggleSidebar" | "addTopNav" | "closeTopNav" | "navigateTopNavLeft" | "navigateTopNavRight" | "focusAddressBar" | "jumpToTab" | "jumpToLastTab" | "focusRequestSearch";
|
|
74
74
|
modifiers?: ("Meta" | "Control" | "Shift" | "Alt" | "default")[] | undefined;
|
|
75
75
|
}>> | undefined;
|
|
76
76
|
} | undefined;
|
|
@@ -85,7 +85,7 @@ export declare const workspaceSchema: z.ZodObject<{
|
|
|
85
85
|
hotKeyConfig?: {
|
|
86
86
|
modifiers?: ("Meta" | "Control" | "Shift" | "Alt" | "default" | undefined)[] | undefined;
|
|
87
87
|
hotKeys?: Partial<Record<"" | "/" | "Space" | "Backspace" | "Tab" | "Enter" | "Escape" | "ArrowDown" | "ArrowLeft" | "ArrowRight" | "ArrowUp" | "End" | "Home" | "PageDown" | "PageUp" | "Delete" | "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z" | "*" | "+" | "-" | "." | "F1" | "F2" | "F3" | "F4" | "F5" | "F6" | "F7" | "F8" | "F9" | "F10" | "F11" | "F12" | ";" | "=" | "," | "`" | "[" | "\\" | "]", {
|
|
88
|
-
event: "closeModal" | "navigateSearchResultsDown" | "selectSearchResult" | "navigateSearchResultsUp" | "openCommandPalette" | "
|
|
88
|
+
event: "closeModal" | "navigateSearchResultsDown" | "selectSearchResult" | "navigateSearchResultsUp" | "openCommandPalette" | "createNew" | "toggleSidebar" | "addTopNav" | "closeTopNav" | "navigateTopNavLeft" | "navigateTopNavRight" | "focusAddressBar" | "jumpToTab" | "jumpToLastTab" | "focusRequestSearch";
|
|
89
89
|
modifiers?: ("Meta" | "Control" | "Shift" | "Alt" | "default" | undefined)[] | undefined;
|
|
90
90
|
}>> | undefined;
|
|
91
91
|
} | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration.d.ts","sourceRoot":"","sources":["../../../src/migrations/v-2.1.0/migration.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sCAAsC,CAAA;AAInE,mCAAmC;AACnC,eAAO,MAAM,eAAe,SAAU,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC;;;;;;;;;;oBAG/C,CAAC;mBAIjB,CADJ;qBAA4C,CAAC;;;;0BAKlC,CAAC;mBACR,CAAA
|
|
1
|
+
{"version":3,"file":"migration.d.ts","sourceRoot":"","sources":["../../../src/migrations/v-2.1.0/migration.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sCAAsC,CAAA;AAInE,mCAAmC;AACnC,eAAO,MAAM,eAAe,SAAU,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC;;;;;;;;;;oBAG/C,CAAC;mBAIjB,CADJ;qBAA4C,CAAC;;;;0BAKlC,CAAC;mBACR,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAiDsD,CAAC;;;;oBASlD,CAAC;;;;;;wBAIF,CAAR;;;;;;sCAM2B,GAAG;oHAMoB,GAAsB;iCAGhE,GAAC;+BACS,GAAG;;+BAKb,CAAC;0BAED,CAAC;4BAIY,CAAA;wBAAoC,CAAC;wBAAqC,CAAC;0BACpF,CAAC;2BAAsC,CAAC;2BAGvC,CAAC;2BAAsC,CAAC;4BACxC,CAAC;;;kBACR,CAAD;;;;;;;;oBAQD,CAAC;2BAAqC,CAAC;sBAElB,CAAC;wBACA,CAAC;oBAAkC,CAAC;oBAG1D,CAAF;sBAAmC,CAAC;uBAE5B,CAAC;uBAAoC,CAAC;uBAChB,CAAC;wBACtB,CAAC;;;;;;oBAOS,CAAC;2BACR,CAAC;sBAAmC,CAAC;wBACtC,CAAC;oBACR,CAAC;oBAAmC,CAAC;sBAE7B,CAAC;uBACa,CAAC;uBACJ,CAAC;uBAAoC,CAAC;wBAC9C,CAAA;;;;;;oBAIS,CAAC;2BACA,CAAC;sBAChB,CAAC;wBACK,CAAC;oBACL,CAAC;oBAGN,CAAC;sBAEN,CAAJ;uBACS,CAAC;uBAEI,CAAC;uBACkB,CAAC;wBAAkC,CAAC;;;;;;oBAS/D,CAAC;2BAAqC,CAAC;sBACnC,CAAC;wBACW,CAAC;oBACjB,CAAJ;oBAAmC,CAAC;sBACf,CAAC;uBACf,CAAC;uBAAoC,CAAC;uBACjB,CAAC;wBACnB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBAYP,CAAN;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBA0Iyd,CAAC;;6BAA4E,CAAC;;;;;;;;;;CADtiB,CAAA"}
|
|
@@ -110,6 +110,7 @@ const migrate_v_2_1_0 = (data) => {
|
|
|
110
110
|
'externalDocs': c.spec?.externalDocs,
|
|
111
111
|
'uid': c.uid,
|
|
112
112
|
securitySchemes,
|
|
113
|
+
'selectedSecuritySchemeUids': [],
|
|
113
114
|
'selectedServerUid': c.selectedServerUid || c.spec?.serverUids?.[0] || '',
|
|
114
115
|
'servers': c.spec?.serverUids || [],
|
|
115
116
|
'requests': [...requestUids],
|
|
@@ -10,6 +10,7 @@ export declare function exportSpecFromWorkspace({ collection, requests, }: {
|
|
|
10
10
|
security: Record<string, string[]>[];
|
|
11
11
|
'x-scalar-icon': string;
|
|
12
12
|
securitySchemes: string[];
|
|
13
|
+
selectedSecuritySchemeUids: string[];
|
|
13
14
|
selectedServerUid: string;
|
|
14
15
|
servers: string[];
|
|
15
16
|
requests: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export-spec.d.ts","sourceRoot":"","sources":["../../src/transforms/export-spec.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,UAAU,EACf,KAAK,OAAO,EAEb,MAAM,iBAAiB,CAAA;AAMxB,wBAAgB,uBAAuB,CAAC,EACtC,UAAU,EACV,QAAQ,GACT,EAAE;IACD,UAAU,EAAE,UAAU,CAAA;IACtB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAClC
|
|
1
|
+
{"version":3,"file":"export-spec.d.ts","sourceRoot":"","sources":["../../src/transforms/export-spec.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,UAAU,EACf,KAAK,OAAO,EAEb,MAAM,iBAAiB,CAAA;AAMxB,wBAAgB,uBAAuB,CAAC,EACtC,UAAU,EACV,QAAQ,GACT,EAAE;IACD,UAAU,EAAE,UAAU,CAAA;IACtB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAClC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAEA"}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { type Collection, type CollectionPayload, type Request, type RequestExample, type Server, type Tag } from '../entities/spec/index.js';
|
|
2
2
|
import { type SecurityScheme } from '../entities/spec/security.js';
|
|
3
3
|
import type { OpenAPIV3, OpenAPIV3_1 } from '@scalar/openapi-types';
|
|
4
|
-
import type {
|
|
4
|
+
import type { ReferenceConfiguration } from '@scalar/types/legacy';
|
|
5
5
|
import type { UnknownObject } from '@scalar/types/utils';
|
|
6
6
|
/** Takes a string or object and parses it into an openapi spec compliant schema */
|
|
7
7
|
export declare const parseSchema: (spec: string | UnknownObject) => Promise<{
|
|
8
8
|
schema: OpenAPIV3.Document | OpenAPIV3_1.Document;
|
|
9
9
|
errors: import("@scalar/openapi-parser").ErrorObject[];
|
|
10
10
|
}>;
|
|
11
|
+
export type ImportSpecToWorkspaceArgs = Pick<CollectionPayload, 'documentUrl' | 'watchForChanges'> & Pick<ReferenceConfiguration, 'authentication'> & {
|
|
12
|
+
/** Sets the preferred security scheme on the collection instead of the requests */
|
|
13
|
+
setCollectionSecurity?: boolean;
|
|
14
|
+
};
|
|
11
15
|
/**
|
|
12
16
|
* Import an OpenAPI spec file and convert it to workspace entities
|
|
13
17
|
*
|
|
@@ -16,7 +20,7 @@ export declare const parseSchema: (spec: string | UnknownObject) => Promise<{
|
|
|
16
20
|
* created and used at various levels we will index via the uids to create
|
|
17
21
|
* the relationships
|
|
18
22
|
*/
|
|
19
|
-
export declare function importSpecToWorkspace(spec: string | UnknownObject, { documentUrl,
|
|
23
|
+
export declare function importSpecToWorkspace(spec: string | UnknownObject, { authentication, documentUrl, setCollectionSecurity, watchForChanges, }?: ImportSpecToWorkspaceArgs): Promise<{
|
|
20
24
|
error: false;
|
|
21
25
|
collection: Collection;
|
|
22
26
|
requests: Request[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import-spec.d.ts","sourceRoot":"","sources":["../../src/transforms/import-spec.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,OAAO,EACZ,KAAK,cAAc,EAGnB,KAAK,MAAM,EACX,KAAK,GAAG,EAOT,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,KAAK,cAAc,
|
|
1
|
+
{"version":3,"file":"import-spec.d.ts","sourceRoot":"","sources":["../../src/transforms/import-spec.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,OAAO,EACZ,KAAK,cAAc,EAGnB,KAAK,MAAM,EACX,KAAK,GAAG,EAOT,MAAM,iBAAiB,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We need to convert from openapi spec flows to our singular flow object here
|
|
13
13
|
* If we ever go spec compliant (flows), we will no longer need this conversion
|
|
14
14
|
*/
|
|
15
|
-
const convertOauth2Flows = (security, nameKey) => {
|
|
15
|
+
const convertOauth2Flows = (security, nameKey, auth) => {
|
|
16
16
|
if (security.type === 'oauth2') {
|
|
17
17
|
const entries = Object.entries(security.flows ?? {});
|
|
18
18
|
if (entries.length) {
|
|
19
19
|
const [[type, flow]] = entries;
|
|
20
|
-
|
|
20
|
+
const payload = {
|
|
21
21
|
...security,
|
|
22
22
|
nameKey,
|
|
23
23
|
flow: {
|
|
@@ -25,6 +25,15 @@ const convertOauth2Flows = (security, nameKey) => {
|
|
|
25
25
|
type,
|
|
26
26
|
},
|
|
27
27
|
};
|
|
28
|
+
if (auth?.oAuth2 && payload.flow) {
|
|
29
|
+
// Set client id
|
|
30
|
+
if (auth.oAuth2.clientId)
|
|
31
|
+
payload['x-scalar-client-id'] = auth.oAuth2.clientId;
|
|
32
|
+
// Set selected scopes
|
|
33
|
+
if (auth.oAuth2.scopes)
|
|
34
|
+
payload.flow.selectedScopes = auth.oAuth2.scopes;
|
|
35
|
+
}
|
|
36
|
+
return payload;
|
|
28
37
|
}
|
|
29
38
|
}
|
|
30
39
|
return {
|
|
@@ -32,6 +41,40 @@ const convertOauth2Flows = (security, nameKey) => {
|
|
|
32
41
|
nameKey,
|
|
33
42
|
};
|
|
34
43
|
};
|
|
44
|
+
/** Pre-fill baseValues if we have authentication config */
|
|
45
|
+
const getBaseValues = (scheme, auth) => {
|
|
46
|
+
if (!auth)
|
|
47
|
+
return {};
|
|
48
|
+
// ApiKey
|
|
49
|
+
if (scheme.type === 'apiKey')
|
|
50
|
+
return { value: auth.apiKey?.token ?? '' };
|
|
51
|
+
// HTTP
|
|
52
|
+
else if (scheme.type === 'http') {
|
|
53
|
+
if (scheme.scheme === 'basic')
|
|
54
|
+
return {
|
|
55
|
+
username: auth.http?.basic?.username ?? '',
|
|
56
|
+
password: auth.http?.basic?.password ?? '',
|
|
57
|
+
};
|
|
58
|
+
else if (scheme.scheme === 'bearer')
|
|
59
|
+
return { token: auth.http?.bearer?.token ?? '' };
|
|
60
|
+
}
|
|
61
|
+
// oauth2 implicit only for now, when we support multi flow can expand this
|
|
62
|
+
else if (scheme.type === 'oauth2') {
|
|
63
|
+
if (scheme.flow?.type === 'implicit')
|
|
64
|
+
return {
|
|
65
|
+
type: 'oauth-implicit',
|
|
66
|
+
token: auth.oAuth2?.accessToken ?? '',
|
|
67
|
+
};
|
|
68
|
+
else if (scheme.flow?.type === 'password')
|
|
69
|
+
return {
|
|
70
|
+
type: 'oauth-password',
|
|
71
|
+
token: auth.oAuth2?.accessToken ?? '',
|
|
72
|
+
username: auth.oAuth2?.username ?? '',
|
|
73
|
+
password: auth.oAuth2?.password ?? '',
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
return {};
|
|
77
|
+
};
|
|
35
78
|
/** Takes a string or object and parses it into an openapi spec compliant schema */
|
|
36
79
|
const parseSchema = async (spec) => {
|
|
37
80
|
const { filesystem } = await load(spec);
|
|
@@ -47,7 +90,7 @@ const parseSchema = async (spec) => {
|
|
|
47
90
|
* created and used at various levels we will index via the uids to create
|
|
48
91
|
* the relationships
|
|
49
92
|
*/
|
|
50
|
-
async function importSpecToWorkspace(spec, { documentUrl,
|
|
93
|
+
async function importSpecToWorkspace(spec, { authentication, documentUrl, setCollectionSecurity = false, watchForChanges = false, } = {}) {
|
|
51
94
|
const { schema, errors } = await parseSchema(spec);
|
|
52
95
|
const importWarnings = [...errors.map((e) => e.message)];
|
|
53
96
|
if (!schema)
|
|
@@ -76,7 +119,7 @@ async function importSpecToWorkspace(spec, { documentUrl, watchForChanges, prefe
|
|
|
76
119
|
const scheme = schemaModel(
|
|
77
120
|
// We must convert flows to a singular object, technically not spec compliant so we grab the first
|
|
78
121
|
s.type === 'oauth2'
|
|
79
|
-
? convertOauth2Flows(s, nameKey)
|
|
122
|
+
? convertOauth2Flows(s, nameKey, authentication)
|
|
80
123
|
: {
|
|
81
124
|
...s,
|
|
82
125
|
nameKey,
|
|
@@ -124,10 +167,10 @@ async function importSpecToWorkspace(spec, { documentUrl, watchForChanges, prefe
|
|
|
124
167
|
});
|
|
125
168
|
let selectedSecuritySchemeUids = [];
|
|
126
169
|
// Set the initially selected security scheme
|
|
127
|
-
if (securityRequirements.length) {
|
|
128
|
-
const name = preferredSecurityScheme &&
|
|
129
|
-
securityRequirements.includes(preferredSecurityScheme ?? '')
|
|
130
|
-
? preferredSecurityScheme
|
|
170
|
+
if (securityRequirements.length && !setCollectionSecurity) {
|
|
171
|
+
const name = authentication?.preferredSecurityScheme &&
|
|
172
|
+
securityRequirements.includes(authentication.preferredSecurityScheme ?? '')
|
|
173
|
+
? authentication.preferredSecurityScheme
|
|
131
174
|
: securityRequirements[0];
|
|
132
175
|
const uid = securitySchemeMap[name];
|
|
133
176
|
selectedSecuritySchemeUids = [uid];
|
|
@@ -219,11 +262,18 @@ async function importSpecToWorkspace(spec, { documentUrl, watchForChanges, prefe
|
|
|
219
262
|
// Generate Collection
|
|
220
263
|
// Create the auth examples
|
|
221
264
|
const auth = securitySchemes?.reduce((prev, s) => {
|
|
222
|
-
const
|
|
265
|
+
const baseValues = getBaseValues(s, authentication);
|
|
266
|
+
const example = authExampleFromSchema(s, baseValues);
|
|
223
267
|
if (example)
|
|
224
268
|
prev[s.uid] = example;
|
|
225
269
|
return prev;
|
|
226
270
|
}, {});
|
|
271
|
+
/** Selected security scheme UIDs for the collection */
|
|
272
|
+
let selectedSecuritySchemeUids = [];
|
|
273
|
+
if (setCollectionSecurity && authentication?.preferredSecurityScheme) {
|
|
274
|
+
const uid = securitySchemeMap[authentication.preferredSecurityScheme];
|
|
275
|
+
selectedSecuritySchemeUids = [uid];
|
|
276
|
+
}
|
|
227
277
|
const collection = collectionSchema.parse({
|
|
228
278
|
...schema,
|
|
229
279
|
watchForChanges,
|
|
@@ -235,6 +285,7 @@ async function importSpecToWorkspace(spec, { documentUrl, watchForChanges, prefe
|
|
|
235
285
|
children: [...collectionChildren],
|
|
236
286
|
security: schema.security ?? [{}],
|
|
237
287
|
selectedServerUid: servers?.[0]?.uid,
|
|
288
|
+
selectedSecuritySchemeUids,
|
|
238
289
|
components: {
|
|
239
290
|
...schema.components,
|
|
240
291
|
},
|
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"specification",
|
|
17
17
|
"yaml"
|
|
18
18
|
],
|
|
19
|
-
"version": "0.2.
|
|
19
|
+
"version": "0.2.62",
|
|
20
20
|
"engines": {
|
|
21
21
|
"node": ">=18"
|
|
22
22
|
},
|
|
@@ -107,19 +107,18 @@
|
|
|
107
107
|
"yaml": "^2.4.5",
|
|
108
108
|
"zod": "^3.23.8",
|
|
109
109
|
"@scalar/object-utils": "1.1.10",
|
|
110
|
+
"@scalar/themes": "0.9.43",
|
|
110
111
|
"@scalar/openapi-types": "0.1.4",
|
|
111
|
-
"@scalar/themes": "0.9.41",
|
|
112
112
|
"@scalar/types": "0.0.17"
|
|
113
113
|
},
|
|
114
114
|
"devDependencies": {
|
|
115
|
-
"rollup": "^4.16.4",
|
|
116
115
|
"type-fest": "^4.20.0",
|
|
117
|
-
"vite": "^5.
|
|
116
|
+
"vite": "^5.4.9",
|
|
118
117
|
"vitest": "^1.6.0",
|
|
119
118
|
"zod-to-ts": "^1.2.0",
|
|
120
119
|
"@scalar/build-tooling": "0.1.11",
|
|
121
|
-
"@scalar/openapi-
|
|
122
|
-
"@scalar/openapi-
|
|
120
|
+
"@scalar/openapi-types": "0.1.4",
|
|
121
|
+
"@scalar/openapi-parser": "0.8.8"
|
|
123
122
|
},
|
|
124
123
|
"scripts": {
|
|
125
124
|
"build": "scalar-build-rollup",
|