@scalar/oas-utils 0.2.85 → 0.2.86
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 +7 -0
- package/dist/entities/spec/collection.d.ts +6 -6
- package/dist/entities/spec/collection.js +1 -1
- package/dist/entities/spec/index.d.ts +1 -0
- package/dist/entities/spec/index.d.ts.map +1 -1
- package/dist/entities/spec/index.js +1 -0
- package/dist/entities/spec/requests.d.ts +1 -1
- package/dist/entities/workspace/workspace.d.ts +3 -3
- package/dist/entities/workspace/workspace.js +1 -1
- package/dist/migrations/data-version.d.ts +1 -1
- package/dist/migrations/data-version.js +1 -1
- package/dist/migrations/migrator.d.ts +2 -2
- package/dist/migrations/migrator.d.ts.map +1 -1
- package/dist/migrations/migrator.js +4 -0
- package/dist/migrations/v-2.2.0/types.generated.d.ts +21 -2
- package/dist/migrations/v-2.2.0/types.generated.d.ts.map +1 -1
- package/dist/migrations/v-2.3.0/index.d.ts +3 -0
- package/dist/migrations/v-2.3.0/index.d.ts.map +1 -0
- package/dist/migrations/v-2.3.0/index.js +1 -0
- package/dist/migrations/v-2.3.0/migration.d.ts +5 -0
- package/dist/migrations/v-2.3.0/migration.d.ts.map +1 -0
- package/dist/migrations/v-2.3.0/migration.js +55 -0
- package/dist/migrations/v-2.3.0/types.generated.d.ts +38 -0
- package/dist/migrations/v-2.3.0/types.generated.d.ts.map +1 -0
- package/dist/spec-getters/index.d.ts +0 -1
- package/dist/spec-getters/index.d.ts.map +1 -1
- package/dist/spec-getters/index.js +0 -1
- package/dist/transforms/import-spec.d.ts +7 -6
- package/dist/transforms/import-spec.d.ts.map +1 -1
- package/dist/transforms/import-spec.js +19 -13
- package/package.json +9 -4
- package/dist/spec-getters/getRequestFromOperation.d.ts +0 -10
- package/dist/spec-getters/getRequestFromOperation.d.ts.map +0 -1
- package/dist/spec-getters/getRequestFromOperation.js +0 -48
package/CHANGELOG.md
CHANGED
|
@@ -97,7 +97,7 @@ export declare const oasCollectionSchema: z.ZodObject<{
|
|
|
97
97
|
webhooks: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
98
98
|
/** A custom icon representing the collection */
|
|
99
99
|
'x-scalar-icon': z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
100
|
-
'x-scalar-environment': z.ZodOptional<z.ZodString>;
|
|
100
|
+
'x-scalar-active-environment': z.ZodOptional<z.ZodString>;
|
|
101
101
|
'x-scalar-environments': z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
102
102
|
description: z.ZodOptional<z.ZodString>;
|
|
103
103
|
color: z.ZodOptional<z.ZodString>;
|
|
@@ -165,7 +165,7 @@ export declare const oasCollectionSchema: z.ZodObject<{
|
|
|
165
165
|
} | undefined;
|
|
166
166
|
components?: Record<string, unknown> | undefined;
|
|
167
167
|
webhooks?: Record<string, unknown> | undefined;
|
|
168
|
-
'x-scalar-environment'?: string | undefined;
|
|
168
|
+
'x-scalar-active-environment'?: string | undefined;
|
|
169
169
|
'x-scalar-environments'?: Record<string, {
|
|
170
170
|
variables: Record<string, string | {
|
|
171
171
|
default: string;
|
|
@@ -207,7 +207,7 @@ export declare const oasCollectionSchema: z.ZodObject<{
|
|
|
207
207
|
components?: Record<string, unknown> | undefined;
|
|
208
208
|
webhooks?: Record<string, unknown> | undefined;
|
|
209
209
|
'x-scalar-icon'?: string | undefined;
|
|
210
|
-
'x-scalar-environment'?: string | undefined;
|
|
210
|
+
'x-scalar-active-environment'?: string | undefined;
|
|
211
211
|
'x-scalar-environments'?: Record<string, {
|
|
212
212
|
variables: Record<string, string | {
|
|
213
213
|
default?: string | undefined;
|
|
@@ -378,7 +378,7 @@ export declare const collectionSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
378
378
|
webhooks: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
379
379
|
/** A custom icon representing the collection */
|
|
380
380
|
'x-scalar-icon': z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
381
|
-
'x-scalar-environment': z.ZodOptional<z.ZodString>;
|
|
381
|
+
'x-scalar-active-environment': z.ZodOptional<z.ZodString>;
|
|
382
382
|
'x-scalar-environments': z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
383
383
|
description: z.ZodOptional<z.ZodString>;
|
|
384
384
|
color: z.ZodOptional<z.ZodString>;
|
|
@@ -488,7 +488,7 @@ export declare const collectionSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
488
488
|
} | undefined;
|
|
489
489
|
components?: Record<string, unknown> | undefined;
|
|
490
490
|
webhooks?: Record<string, unknown> | undefined;
|
|
491
|
-
'x-scalar-environment'?: string | undefined;
|
|
491
|
+
'x-scalar-active-environment'?: string | undefined;
|
|
492
492
|
'x-scalar-environments'?: Record<string, {
|
|
493
493
|
variables: Record<string, string | {
|
|
494
494
|
default: string;
|
|
@@ -534,7 +534,7 @@ export declare const collectionSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
534
534
|
components?: Record<string, unknown> | undefined;
|
|
535
535
|
webhooks?: Record<string, unknown> | undefined;
|
|
536
536
|
'x-scalar-icon'?: string | undefined;
|
|
537
|
-
'x-scalar-environment'?: string | undefined;
|
|
537
|
+
'x-scalar-active-environment'?: string | undefined;
|
|
538
538
|
'x-scalar-environments'?: Record<string, {
|
|
539
539
|
variables: Record<string, string | {
|
|
540
540
|
default?: string | undefined;
|
|
@@ -38,7 +38,7 @@ const oasCollectionSchema = z.object({
|
|
|
38
38
|
'webhooks': z.record(z.string(), z.unknown()).optional(),
|
|
39
39
|
/** A custom icon representing the collection */
|
|
40
40
|
'x-scalar-icon': z.string().optional().default('interface-content-folder'),
|
|
41
|
-
'x-scalar-environment': z.string().optional(),
|
|
41
|
+
'x-scalar-active-environment': z.string().optional(),
|
|
42
42
|
'x-scalar-environments': xScalarEnvironmentsSchema.optional(),
|
|
43
43
|
'x-scalar-secrets': xScalarSecretsSchema.optional(),
|
|
44
44
|
// These properties will be stripped out and mapped back as id lists
|
|
@@ -5,6 +5,7 @@ export * from './request-examples.js';
|
|
|
5
5
|
export * from './spec-objects.js';
|
|
6
6
|
export * from './parameters.js';
|
|
7
7
|
export * from './security.js';
|
|
8
|
+
export * from './x-scalar-environments.js';
|
|
8
9
|
type FetchRequest = Request;
|
|
9
10
|
export type { FetchRequest };
|
|
10
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,UAAU,CAAA;AACxB,cAAc,YAAY,CAAA;AAC1B,cAAc,oBAAoB,CAAA;AAClC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,UAAU,CAAA;AACxB,cAAc,YAAY,CAAA;AAC1B,cAAc,oBAAoB,CAAA;AAClC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,yBAAyB,CAAA;AAEvC,KAAK,YAAY,GAAG,OAAO,CAAA;AAC3B,YAAY,EAAE,YAAY,EAAE,CAAA"}
|
|
@@ -5,3 +5,4 @@ export { convertExampleToXScalar, createExampleFromRequest, createParamInstance,
|
|
|
5
5
|
export { oasContactSchema, oasExternalDocumentationSchema, oasInfoSchema, oasLicenseSchema, oasTagSchema, tagSchema, xScalarNestedSchema } from './spec-objects.js';
|
|
6
6
|
export { oasParameterSchema, parameterStyleSchema, parameterTypeSchema } from './parameters.js';
|
|
7
7
|
export { oasSecurityRequirementSchema, oasSecuritySchemeSchema, pkceOptions, securityApiKeySchema, securityHttpSchema, securityOauthSchema, securityOpenIdSchema, securitySchemeApiKeyIn, securitySchemeSchema } from './security.js';
|
|
8
|
+
export { xScalarEnvVarSchema, xScalarEnvironmentSchema, xScalarEnvironmentsSchema } from './x-scalar-environments.js';
|
|
@@ -551,7 +551,6 @@ export declare const requestSchema: z.ZodObject<z.objectUtil.extendShape<Omit<{
|
|
|
551
551
|
deprecated?: boolean | undefined;
|
|
552
552
|
examples?: (string | undefined)[] | undefined;
|
|
553
553
|
operationId?: string | undefined;
|
|
554
|
-
method?: "options" | "connect" | "delete" | "get" | "head" | "patch" | "post" | "put" | "trace" | undefined;
|
|
555
554
|
parameters?: {
|
|
556
555
|
name: string;
|
|
557
556
|
in: "path" | "query" | "header" | "cookie";
|
|
@@ -569,6 +568,7 @@ export declare const requestSchema: z.ZodObject<z.objectUtil.extendShape<Omit<{
|
|
|
569
568
|
}[] | undefined;
|
|
570
569
|
requestBody?: any;
|
|
571
570
|
responses?: Record<string, any> | undefined;
|
|
571
|
+
method?: "options" | "connect" | "delete" | "get" | "head" | "patch" | "post" | "put" | "trace" | undefined;
|
|
572
572
|
}>;
|
|
573
573
|
export type Request = z.infer<typeof requestSchema>;
|
|
574
574
|
export type RequestPayload = z.input<typeof requestSchema>;
|
|
@@ -20,7 +20,7 @@ export declare const workspaceSchema: z.ZodObject<{
|
|
|
20
20
|
/** List of all collection uids in a given workspace */
|
|
21
21
|
collections: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
22
22
|
/** List of all environment uids in a given workspace */
|
|
23
|
-
environments: z.ZodDefault<z.
|
|
23
|
+
environments: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
24
24
|
/** Customize hotkeys */
|
|
25
25
|
hotKeyConfig: z.ZodOptional<z.ZodObject<{
|
|
26
26
|
modifiers: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodDefault<z.ZodOptional<z.ZodEnum<["Meta", "Control", "Shift", "Alt", "default"]>>>, "many">>>;
|
|
@@ -60,7 +60,7 @@ export declare const workspaceSchema: z.ZodObject<{
|
|
|
60
60
|
name: string;
|
|
61
61
|
description: string;
|
|
62
62
|
collections: string[];
|
|
63
|
-
environments: string
|
|
63
|
+
environments: Record<string, string>;
|
|
64
64
|
activeEnvironmentId: string;
|
|
65
65
|
cookies: string[];
|
|
66
66
|
themeId: "default" | "alternate" | "moon" | "purple" | "solarized" | "bluePlanet" | "deepSpace" | "saturn" | "kepler" | "elysiajs" | "fastify" | "mars" | "none";
|
|
@@ -77,7 +77,7 @@ export declare const workspaceSchema: z.ZodObject<{
|
|
|
77
77
|
name?: string | undefined;
|
|
78
78
|
description?: string | undefined;
|
|
79
79
|
collections?: string[] | undefined;
|
|
80
|
-
environments?: string
|
|
80
|
+
environments?: Record<string, string> | undefined;
|
|
81
81
|
hotKeyConfig?: {
|
|
82
82
|
modifiers?: ("Meta" | "Control" | "Shift" | "Alt" | "default" | undefined)[] | undefined;
|
|
83
83
|
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" | ";" | "=" | "," | "`" | "[" | "\\" | "]", {
|
|
@@ -26,7 +26,7 @@ const workspaceSchema = z.object({
|
|
|
26
26
|
/** List of all collection uids in a given workspace */
|
|
27
27
|
collections: z.array(z.string()).default([]),
|
|
28
28
|
/** List of all environment uids in a given workspace */
|
|
29
|
-
environments: z.
|
|
29
|
+
environments: z.record(z.string()).default({}),
|
|
30
30
|
/** Customize hotkeys */
|
|
31
31
|
hotKeyConfig: hotKeyConfigSchema,
|
|
32
32
|
/** Active Environment ID to use for requests */
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* - 2.1.0 - refactor
|
|
8
8
|
* - 2.2.0 - auth compliancy
|
|
9
9
|
*/
|
|
10
|
-
export declare const DATA_VERSION = "2.
|
|
10
|
+
export declare const DATA_VERSION = "2.3.0";
|
|
11
11
|
/** The localStorage key under which the data version is stored */
|
|
12
12
|
export declare const DATA_VERSION_LS_LEY = "scalar_api_client_data_version";
|
|
13
13
|
//# sourceMappingURL=data-version.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type v_2_3_0 } from '../migrations/v-2.3.0/index.js';
|
|
2
2
|
/** Handles all data migrations per entity */
|
|
3
|
-
export declare const migrator: () =>
|
|
3
|
+
export declare const migrator: () => v_2_3_0.DataArray;
|
|
4
4
|
//# sourceMappingURL=migrator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrator.d.ts","sourceRoot":"","sources":["../../src/migrations/migrator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"migrator.d.ts","sourceRoot":"","sources":["../../src/migrations/migrator.ts"],"names":[],"mappings":"AAOA,OAAO,EAAmB,KAAK,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAEpE,6CAA6C;AAC7C,eAAO,MAAM,QAAQ,QAAO,OAAO,CAAC,SAsCnC,CAAA"}
|
|
@@ -2,6 +2,7 @@ import { getLocalStorageVersion, parseLocalStorage } from './local-storage.js';
|
|
|
2
2
|
import { semverLessThan } from './semver.js';
|
|
3
3
|
import { migrate_v_2_1_0 } from './v-2.1.0/migration.js';
|
|
4
4
|
import { migrate_v_2_2_0 } from './v-2.2.0/migration.js';
|
|
5
|
+
import { migrate_v_2_3_0 } from './v-2.3.0/migration.js';
|
|
5
6
|
|
|
6
7
|
/** Handles all data migrations per entity */
|
|
7
8
|
const migrator = () => {
|
|
@@ -25,6 +26,9 @@ const migrator = () => {
|
|
|
25
26
|
// 2.1.0 -> 2.2.0 migration
|
|
26
27
|
if (semverLessThan(dataVersion, '2.2.0'))
|
|
27
28
|
data = migrate_v_2_2_0(data);
|
|
29
|
+
// 2.2.0 -> 2.3.0 migration
|
|
30
|
+
if (semverLessThan(dataVersion, '2.3.0'))
|
|
31
|
+
data = migrate_v_2_3_0(data);
|
|
28
32
|
// Convert to data array
|
|
29
33
|
data = {
|
|
30
34
|
collections: Object.values(data.collections),
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Cookie as Ck } from '../../entities/cookie/index.js';
|
|
2
2
|
import type { Environment as E } from '../../entities/environment/index.js';
|
|
3
3
|
import type { Collection as Co, Request as R, RequestExample as RE, Server as S, SecurityScheme as SS, Tag as T } from '../../entities/spec/index.js';
|
|
4
|
-
import type { Workspace as W } from '../../entities/workspace/index.js';
|
|
5
4
|
/**
|
|
6
5
|
* The most current types are not generated
|
|
7
6
|
*/
|
|
@@ -14,7 +13,27 @@ export declare namespace v_2_2_0 {
|
|
|
14
13
|
type SecurityScheme = SS;
|
|
15
14
|
type Server = S;
|
|
16
15
|
type Tag = T;
|
|
17
|
-
type Workspace =
|
|
16
|
+
type Workspace = {
|
|
17
|
+
uid: string;
|
|
18
|
+
name: string;
|
|
19
|
+
description: string;
|
|
20
|
+
isReadOnly: boolean;
|
|
21
|
+
collections: string[];
|
|
22
|
+
environments: string[];
|
|
23
|
+
hotKeyConfig?: {
|
|
24
|
+
modifiers: ('Meta' | 'Control' | 'Shift' | 'Alt' | 'default')[];
|
|
25
|
+
hotKeys?: {
|
|
26
|
+
[x: string]: {
|
|
27
|
+
modifiers?: ('Meta' | 'Control' | 'Shift' | 'Alt' | 'default')[] | undefined;
|
|
28
|
+
event: 'closeModal' | 'navigateSearchResultsDown' | 'selectSearchResult' | 'navigateSearchResultsUp' | 'openCommandPalette' | 'createNew' | 'toggleSidebar' | 'addTopNav' | 'closeTopNav' | 'navigateTopNavLeft' | 'navigateTopNavRight' | 'focusAddressBar' | 'jumpToTab' | 'jumpToLastTab' | 'focusRequestSearch';
|
|
29
|
+
};
|
|
30
|
+
} | undefined;
|
|
31
|
+
} | undefined;
|
|
32
|
+
activeEnvironmentId: string;
|
|
33
|
+
cookies: string[];
|
|
34
|
+
proxyUrl?: string | undefined;
|
|
35
|
+
themeId: 'alternate' | 'default' | 'moon' | 'purple' | 'solarized' | 'bluePlanet' | 'deepSpace' | 'saturn' | 'kepler' | 'mars' | 'none';
|
|
36
|
+
};
|
|
18
37
|
type DataRecord = {
|
|
19
38
|
collections: Record<string, Collection>;
|
|
20
39
|
cookies: Record<string, Cookie>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.generated.d.ts","sourceRoot":"","sources":["../../../src/migrations/v-2.2.0/types.generated.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,EAAE,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,KAAK,EAAE,WAAW,IAAI,CAAC,EAAE,MAAM,wBAAwB,CAAA;AAC9D,OAAO,KAAK,EACV,UAAU,IAAI,EAAE,EAChB,OAAO,IAAI,CAAC,EACZ,cAAc,IAAI,EAAE,EACpB,MAAM,IAAI,CAAC,EACX,cAAc,IAAI,EAAE,EACpB,GAAG,IAAI,CAAC,EACT,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"types.generated.d.ts","sourceRoot":"","sources":["../../../src/migrations/v-2.2.0/types.generated.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,EAAE,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,KAAK,EAAE,WAAW,IAAI,CAAC,EAAE,MAAM,wBAAwB,CAAA;AAC9D,OAAO,KAAK,EACV,UAAU,IAAI,EAAE,EAChB,OAAO,IAAI,CAAC,EACZ,cAAc,IAAI,EAAE,EACpB,MAAM,IAAI,CAAC,EACX,cAAc,IAAI,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migrations/v-2.3.0/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,mBAAmB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { migrate_v_2_3_0 } from './migration.js';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { v_2_2_0 } from '../../migrations/v-2.2.0/types.generated';
|
|
2
|
+
import type { v_2_3_0 } from './types.generated';
|
|
3
|
+
/** V-2.2.0 to V-2.3.0 migration */
|
|
4
|
+
export declare const migrate_v_2_3_0: (data: v_2_2_0.DataRecord) => v_2_3_0.DataRecord;
|
|
5
|
+
//# sourceMappingURL=migration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration.d.ts","sourceRoot":"","sources":["../../../src/migrations/v-2.3.0/migration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sCAAsC,CAAA;AAEnE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAEhD,mCAAmC;AACnC,eAAO,MAAM,eAAe,SACpB,OAAO,CAAC,UAAU,KACvB,OAAO,CAAC,UAgEV,CAAA"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/** V-2.2.0 to V-2.3.0 migration */
|
|
2
|
+
const migrate_v_2_3_0 = (data) => {
|
|
3
|
+
console.info('Performing data migration v-2.2.0 to v-2.3.0');
|
|
4
|
+
const environments = data.environments;
|
|
5
|
+
const workspaces = Object.values(data.workspaces).reduce((prev, w) => {
|
|
6
|
+
const workspaceEnvironments = {};
|
|
7
|
+
Object.entries(environments).forEach(([envId, envData]) => {
|
|
8
|
+
const parsedData = typeof envData.value === 'string'
|
|
9
|
+
? JSON.parse(envData.value)
|
|
10
|
+
: envData.value;
|
|
11
|
+
if (envId === 'default') {
|
|
12
|
+
Object.assign(workspaceEnvironments, parsedData);
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
prev[w.uid] = {
|
|
16
|
+
...w,
|
|
17
|
+
environments: workspaceEnvironments,
|
|
18
|
+
};
|
|
19
|
+
return prev;
|
|
20
|
+
}, {});
|
|
21
|
+
const collections = Object.values(data.collections).reduce((prev, c) => {
|
|
22
|
+
prev[c.uid] = {
|
|
23
|
+
...c,
|
|
24
|
+
'x-scalar-environments': c['x-scalar-environments'] || {},
|
|
25
|
+
};
|
|
26
|
+
return prev;
|
|
27
|
+
}, {});
|
|
28
|
+
Object.values(workspaces).forEach((workspace) => {
|
|
29
|
+
Object.entries(environments).forEach(([envKey, envData]) => {
|
|
30
|
+
if (envKey !== 'default') {
|
|
31
|
+
const parsedData = typeof envData.value === 'string'
|
|
32
|
+
? JSON.parse(envData.value)
|
|
33
|
+
: envData.value;
|
|
34
|
+
const envName = envData.name;
|
|
35
|
+
Object.values(collections).forEach((collection) => {
|
|
36
|
+
collection['x-scalar-environments'] =
|
|
37
|
+
collection['x-scalar-environments'] || {};
|
|
38
|
+
collection['x-scalar-environments'][envName] = {
|
|
39
|
+
variables: parsedData,
|
|
40
|
+
};
|
|
41
|
+
if (workspace.activeEnvironmentId === envKey) {
|
|
42
|
+
collection['x-scalar-active-environment'] = envName ?? '';
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
return {
|
|
49
|
+
...data,
|
|
50
|
+
collections,
|
|
51
|
+
workspaces,
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export { migrate_v_2_3_0 };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Cookie as Ck } from '../../entities/cookie/index.js';
|
|
2
|
+
import type { Environment as E } from '../../entities/environment/index.js';
|
|
3
|
+
import type { Collection as Co, Request as R, RequestExample as RE, Server as S, SecurityScheme as SS, Tag as T } from '../../entities/spec/index.js';
|
|
4
|
+
import type { Workspace as W } from '../../entities/workspace/index.js';
|
|
5
|
+
export declare namespace v_2_3_0 {
|
|
6
|
+
type Cookie = Ck;
|
|
7
|
+
type Environment = E;
|
|
8
|
+
type Collection = Co;
|
|
9
|
+
type Request = R;
|
|
10
|
+
type RequestExample = RE;
|
|
11
|
+
type SecurityScheme = SS;
|
|
12
|
+
type Server = S;
|
|
13
|
+
type Tag = T;
|
|
14
|
+
type Workspace = W;
|
|
15
|
+
type DataRecord = {
|
|
16
|
+
collections: Record<string, Collection>;
|
|
17
|
+
cookies: Record<string, Cookie>;
|
|
18
|
+
environments: Record<string, Environment>;
|
|
19
|
+
requestExamples: Record<string, RequestExample>;
|
|
20
|
+
requests: Record<string, Request>;
|
|
21
|
+
securitySchemes: Record<string, SecurityScheme>;
|
|
22
|
+
servers: Record<string, Server>;
|
|
23
|
+
tags: Record<string, Tag>;
|
|
24
|
+
workspaces: Record<string, Workspace>;
|
|
25
|
+
};
|
|
26
|
+
type DataArray = {
|
|
27
|
+
collections: Collection[];
|
|
28
|
+
cookies: Cookie[];
|
|
29
|
+
environments: Environment[];
|
|
30
|
+
requestExamples: RequestExample[];
|
|
31
|
+
requests: Request[];
|
|
32
|
+
securitySchemes: SecurityScheme[];
|
|
33
|
+
servers: Server[];
|
|
34
|
+
tags: Tag[];
|
|
35
|
+
workspaces: Workspace[];
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=types.generated.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.generated.d.ts","sourceRoot":"","sources":["../../../src/migrations/v-2.3.0/types.generated.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,EAAE,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,KAAK,EAAE,WAAW,IAAI,CAAC,EAAE,MAAM,wBAAwB,CAAA;AAC9D,OAAO,KAAK,EACV,UAAU,IAAI,EAAE,EAChB,OAAO,IAAI,CAAC,EACZ,cAAc,IAAI,EAAE,EACpB,MAAM,IAAI,CAAC,EACX,cAAc,IAAI,EAAE,E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,QAAQ,EAAE,OAAO,EAAE,CAAA;QACnB,eAAe,EAAE,cAAc,EAAE,CAAA;QACjC,OAAO,EAAE,MAAM,EAAE,CAAA;QACjB,IAAI,EAAE,GAAG,EAAE,CAAA;QACX,UAAU,EAAE,SAAS,EAAE,CAAA;KACxB,CAAA;CACF"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export * from './getExampleFromSchema.js';
|
|
2
2
|
export * from './getParametersFromOperation.js';
|
|
3
3
|
export * from './getRequestBodyFromOperation.js';
|
|
4
|
-
export * from './getRequestFromOperation.js';
|
|
5
4
|
export * from './getServerVariableExamples.js';
|
|
6
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/spec-getters/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAA;AACtC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,+BAA+B,CAAA;AAC7C,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/spec-getters/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAA;AACtC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,+BAA+B,CAAA;AAC7C,cAAc,6BAA6B,CAAA"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { getExampleFromSchema } from './getExampleFromSchema.js';
|
|
2
2
|
export { getParametersFromOperation } from './getParametersFromOperation.js';
|
|
3
3
|
export { getRequestBodyFromOperation } from './getRequestBodyFromOperation.js';
|
|
4
|
-
export { getRequestFromOperation } from './getRequestFromOperation.js';
|
|
5
4
|
export { getServerVariableExamples } from './getServerVariableExamples.js';
|
|
@@ -4,20 +4,21 @@ import type { OpenAPIV3, OpenAPIV3_1 } from '@scalar/openapi-types';
|
|
|
4
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
|
-
export declare const parseSchema: (spec: string | UnknownObject
|
|
7
|
+
export declare const parseSchema: (spec: string | UnknownObject, { shouldLoad }?: {
|
|
8
|
+
shouldLoad?: boolean | undefined;
|
|
9
|
+
}) => Promise<{
|
|
8
10
|
/**
|
|
9
11
|
* Temporary fix for the parser returning an empty array
|
|
10
12
|
* TODO: remove this once the parser is fixed
|
|
11
13
|
*/
|
|
12
14
|
schema: OpenAPIV3.Document | OpenAPIV3_1.Document;
|
|
13
|
-
errors: (
|
|
14
|
-
code: any;
|
|
15
|
-
message: any;
|
|
16
|
-
} | import("@scalar/openapi-parser").ErrorObject)[];
|
|
15
|
+
errors: import("@scalar/openapi-parser").ErrorObject[];
|
|
17
16
|
}>;
|
|
18
17
|
export type ImportSpecToWorkspaceArgs = Pick<CollectionPayload, 'documentUrl' | 'watchMode'> & Pick<ReferenceConfiguration, 'authentication' | 'baseServerURL' | 'servers'> & {
|
|
19
18
|
/** Sets the preferred security scheme on the collection instead of the requests */
|
|
20
19
|
setCollectionSecurity?: boolean;
|
|
20
|
+
/** Call the load step from the parser */
|
|
21
|
+
shouldLoad?: boolean;
|
|
21
22
|
};
|
|
22
23
|
/**
|
|
23
24
|
* Imports an OpenAPI document and converts it to workspace entities (Collection, Request, Server, etc.)
|
|
@@ -32,7 +33,7 @@ export type ImportSpecToWorkspaceArgs = Pick<CollectionPayload, 'documentUrl' |
|
|
|
32
33
|
* - Proper linking between related components
|
|
33
34
|
* - Easy lookup and reference of dependent entities
|
|
34
35
|
*/
|
|
35
|
-
export declare function importSpecToWorkspace(spec: string | UnknownObject, { authentication, baseServerURL, documentUrl, servers: overloadServers, setCollectionSecurity, watchMode, }?: ImportSpecToWorkspaceArgs): Promise<{
|
|
36
|
+
export declare function importSpecToWorkspace(spec: string | UnknownObject, { authentication, baseServerURL, documentUrl, servers: overloadServers, setCollectionSecurity, shouldLoad, watchMode, }?: ImportSpecToWorkspaceArgs): Promise<{
|
|
36
37
|
error: false;
|
|
37
38
|
collection: Collection;
|
|
38
39
|
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,EAMT,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAEL,KAAK,cAAc,EAGpB,MAAM,0BAA0B,CAAA;
|
|
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,EAMT,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAEL,KAAK,cAAc,EAGpB,MAAM,0BAA0B,CAAA;AAUjC,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACnE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAGxD,mFAAmF;AACnF,eAAO,MAAM,WAAW,SAChB,MAAM,GAAG,aAAa;;;IA+B1B;;;OAGG;YAEC,SAAS,CAAC,QAAQ,GAClB,WAAW,CAAC,QAAQ;;EAG3B,CAAA;AAED,MAAM,MAAM,yBAAyB,GAAG,IAAI,CAC1C,iBAAiB,EACjB,aAAa,GAAG,WAAW,CAC5B,GACC,IAAI,CACF,sBAAsB,EACtB,gBAAgB,GAAG,eAAe,GAAG,SAAS,CAC/C,GAAG;IACF,mFAAmF;IACnF,qBAAqB,CAAC,EAAE,OAAO,CAAA;IAC/B,yCAAyC;IACzC,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB,CAAA;AAEH;;;;;;;;;;;;GAYG;AACH,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,MAAM,GAAG,aAAa,EAC5B,EACE,cAAc,EACd,aAAa,EACb,WAAW,EACX,OAAO,EAAE,eAAe,EACxB,qBAA6B,EAC7B,UAAU,EACV,SAAiB,GAClB,GAAE,yBAA8B,GAChC,OAAO,CACN;IACE,KAAK,EAAE,KAAK,CAAA;IACZ,UAAU,EAAE,UAAU,CAAA;IACtB,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,MAAM,EAAE,SAAS,CAAC,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAA;IACjD,QAAQ,EAAE,cAAc,EAAE,CAAA;IAC1B,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,IAAI,EAAE,GAAG,EAAE,CAAA;IACX,eAAe,EAAE,cAAc,EAAE,CAAA;CAClC,GACD;IAAE,KAAK,EAAE,IAAI,CAAC;IAAC,cAAc,EAAE,MAAM,EAAE,CAAA;CAAE,CAC5C,CAsVA"}
|
|
@@ -10,18 +10,24 @@ import { createExampleFromRequest } from '../entities/spec/request-examples.js';
|
|
|
10
10
|
import { collectionSchema } from '../entities/spec/collection.js';
|
|
11
11
|
|
|
12
12
|
/** Takes a string or object and parses it into an openapi spec compliant schema */
|
|
13
|
-
const parseSchema = async (spec) => {
|
|
13
|
+
const parseSchema = async (spec, { shouldLoad = true } = {}) => {
|
|
14
14
|
// TODO: Plugins for URLs and files with the proxy is missing here.
|
|
15
15
|
// @see packages/api-reference/src/helpers/parse.ts
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
16
|
+
let filesystem = spec;
|
|
17
|
+
let loadErrors = [];
|
|
18
|
+
if (shouldLoad) {
|
|
19
|
+
const resp = await load(spec).catch((e) => ({
|
|
20
|
+
errors: [
|
|
21
|
+
{
|
|
22
|
+
code: e.code,
|
|
23
|
+
message: e.message,
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
filesystem: [],
|
|
27
|
+
}));
|
|
28
|
+
filesystem = resp.filesystem;
|
|
29
|
+
loadErrors = resp.errors ?? [];
|
|
30
|
+
}
|
|
25
31
|
const { specification } = upgrade(filesystem);
|
|
26
32
|
const { schema, errors: derefErrors = [] } = await dereference(specification);
|
|
27
33
|
if (!schema)
|
|
@@ -48,8 +54,8 @@ const parseSchema = async (spec) => {
|
|
|
48
54
|
* - Proper linking between related components
|
|
49
55
|
* - Easy lookup and reference of dependent entities
|
|
50
56
|
*/
|
|
51
|
-
async function importSpecToWorkspace(spec, { authentication, baseServerURL, documentUrl, servers: overloadServers, setCollectionSecurity = false, watchMode = false, } = {}) {
|
|
52
|
-
const { schema, errors } = await parseSchema(spec);
|
|
57
|
+
async function importSpecToWorkspace(spec, { authentication, baseServerURL, documentUrl, servers: overloadServers, setCollectionSecurity = false, shouldLoad, watchMode = false, } = {}) {
|
|
58
|
+
const { schema, errors } = await parseSchema(spec, { shouldLoad });
|
|
53
59
|
const importWarnings = [...errors.map((e) => e.message)];
|
|
54
60
|
if (!schema)
|
|
55
61
|
return { importWarnings, error: true };
|
|
@@ -284,7 +290,7 @@ async function importSpecToWorkspace(spec, { authentication, baseServerURL, docu
|
|
|
284
290
|
});
|
|
285
291
|
// ---------------------------------------------------------------------------
|
|
286
292
|
// Generate Collection
|
|
287
|
-
const securityKeys = Object.keys(security);
|
|
293
|
+
const securityKeys = Object.keys(schema.security?.[0] ?? security ?? {});
|
|
288
294
|
let selectedSecuritySchemeUids = [];
|
|
289
295
|
/** Selected security scheme UIDs for the collection, defaults to the first key */
|
|
290
296
|
if (setCollectionSecurity && securityKeys.length) {
|
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"specification",
|
|
17
17
|
"yaml"
|
|
18
18
|
],
|
|
19
|
-
"version": "0.2.
|
|
19
|
+
"version": "0.2.86",
|
|
20
20
|
"engines": {
|
|
21
21
|
"node": ">=18"
|
|
22
22
|
},
|
|
@@ -38,6 +38,11 @@
|
|
|
38
38
|
"types": "./dist/migrations/index.d.ts",
|
|
39
39
|
"default": "./dist/migrations/index.js"
|
|
40
40
|
},
|
|
41
|
+
"./migrations/v-2.3.0": {
|
|
42
|
+
"import": "./dist/migrations/v-2.3.0/index.js",
|
|
43
|
+
"types": "./dist/migrations/v-2.3.0/index.d.ts",
|
|
44
|
+
"default": "./dist/migrations/v-2.3.0/index.js"
|
|
45
|
+
},
|
|
41
46
|
"./migrations/v-2.2.0": {
|
|
42
47
|
"import": "./dist/migrations/v-2.2.0/index.js",
|
|
43
48
|
"types": "./dist/migrations/v-2.2.0/index.d.ts",
|
|
@@ -111,9 +116,9 @@
|
|
|
111
116
|
"nanoid": "^5.0.7",
|
|
112
117
|
"yaml": "^2.4.5",
|
|
113
118
|
"zod": "^3.23.8",
|
|
119
|
+
"@scalar/object-utils": "1.1.12",
|
|
114
120
|
"@scalar/openapi-types": "0.1.5",
|
|
115
121
|
"@scalar/themes": "0.9.54",
|
|
116
|
-
"@scalar/object-utils": "1.1.12",
|
|
117
122
|
"@scalar/types": "0.0.23"
|
|
118
123
|
},
|
|
119
124
|
"devDependencies": {
|
|
@@ -121,9 +126,9 @@
|
|
|
121
126
|
"vite": "^5.4.10",
|
|
122
127
|
"vitest": "^1.6.0",
|
|
123
128
|
"zod-to-ts": "github:amritk/zod-to-ts#build",
|
|
124
|
-
"@scalar/
|
|
129
|
+
"@scalar/build-tooling": "0.1.12",
|
|
125
130
|
"@scalar/openapi-parser": "0.8.10",
|
|
126
|
-
"@scalar/
|
|
131
|
+
"@scalar/openapi-types": "0.1.5"
|
|
127
132
|
},
|
|
128
133
|
"scripts": {
|
|
129
134
|
"build": "scalar-build-rollup",
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { HarRequestWithPath, TransformedOperation } from '@scalar/types/legacy';
|
|
2
|
-
export declare const getRequestFromOperation: (operation: TransformedOperation, options?: {
|
|
3
|
-
/**
|
|
4
|
-
* If the path will be URL encoded, you may want to replace {curlyBrackets} with __UNDERSCORES__ to indicate an
|
|
5
|
-
* variable.
|
|
6
|
-
*/
|
|
7
|
-
replaceVariables?: boolean;
|
|
8
|
-
requiredOnly?: boolean;
|
|
9
|
-
}, selectedExampleKey?: string | number, omitEmptyAndOptionalProperties?: boolean) => Partial<HarRequestWithPath>;
|
|
10
|
-
//# sourceMappingURL=getRequestFromOperation.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getRequestFromOperation.d.ts","sourceRoot":"","sources":["../../src/spec-getters/getRequestFromOperation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,kBAAkB,EAGlB,oBAAoB,EACrB,MAAM,sBAAsB,CAAA;AAM7B,eAAO,MAAM,uBAAuB,cACvB,oBAAoB,YACrB;IACR;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB,uBACoB,MAAM,GAAG,MAAM,mCACH,OAAO,KACvC,OAAO,CAAC,kBAAkB,CAgE5B,CAAA"}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { getParametersFromOperation } from './getParametersFromOperation.js';
|
|
2
|
-
import { getRequestBodyFromOperation } from './getRequestBodyFromOperation.js';
|
|
3
|
-
import { REGEX } from '../helpers/regexHelpers.js';
|
|
4
|
-
|
|
5
|
-
const getRequestFromOperation = (operation, options, selectedExampleKey, omitEmptyAndOptionalProperties) => {
|
|
6
|
-
// Replace all variables of the format {something} with the uppercase variable name without the brackets
|
|
7
|
-
let path = operation.path;
|
|
8
|
-
// {id} -> 123
|
|
9
|
-
const pathParameters = getParametersFromOperation(operation, 'path', false);
|
|
10
|
-
if (pathParameters.length) {
|
|
11
|
-
const pathVariables = path.match(REGEX.PATH);
|
|
12
|
-
if (pathVariables) {
|
|
13
|
-
pathVariables.forEach((variable) => {
|
|
14
|
-
const variableName = variable.replace(/{|}/g, '');
|
|
15
|
-
if (pathParameters) {
|
|
16
|
-
const parameter = pathParameters.find((param) => param.name === variableName);
|
|
17
|
-
if (parameter?.value) {
|
|
18
|
-
path = path.replace(variable, parameter.value.toString());
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
// {id} -> __ID__
|
|
25
|
-
if (options?.replaceVariables === true) {
|
|
26
|
-
const pathVariables = path.match(REGEX.PATH);
|
|
27
|
-
if (pathVariables) {
|
|
28
|
-
pathVariables.forEach((variable) => {
|
|
29
|
-
const variableName = variable.replace(/{|}/g, '');
|
|
30
|
-
path = path.replace(variable, `__${variableName.toUpperCase()}__`);
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
const requestBody = getRequestBodyFromOperation(operation, selectedExampleKey, omitEmptyAndOptionalProperties);
|
|
35
|
-
return {
|
|
36
|
-
method: operation.httpVerb.toUpperCase(),
|
|
37
|
-
path,
|
|
38
|
-
postData: requestBody?.body,
|
|
39
|
-
headers: [
|
|
40
|
-
...getParametersFromOperation(operation, 'header', options?.requiredOnly),
|
|
41
|
-
...(requestBody?.headers ?? []),
|
|
42
|
-
],
|
|
43
|
-
queryString: getParametersFromOperation(operation, 'query', options?.requiredOnly),
|
|
44
|
-
cookies: getParametersFromOperation(operation, 'cookie', options?.requiredOnly),
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
export { getRequestFromOperation };
|