@scalar/oas-utils 0.2.77 → 0.2.78
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 +11 -0
- package/dist/entities/spec/collection.d.ts +0 -278
- package/dist/entities/spec/collection.d.ts.map +1 -1
- package/dist/entities/spec/collection.js +1 -8
- package/dist/entities/spec/index.js +1 -1
- package/dist/entities/spec/requests.d.ts +2 -2
- package/dist/entities/spec/security.d.ts +1123 -783
- package/dist/entities/spec/security.d.ts.map +1 -1
- package/dist/entities/spec/security.js +73 -133
- package/dist/entities/workspace/workspace.d.ts +3 -7
- package/dist/entities/workspace/workspace.d.ts.map +1 -1
- package/dist/entities/workspace/workspace.js +0 -2
- package/dist/migrations/data-version.d.ts +3 -2
- package/dist/migrations/data-version.d.ts.map +1 -1
- package/dist/migrations/data-version.js +3 -2
- package/dist/migrations/local-storage.d.ts.map +1 -1
- package/dist/migrations/local-storage.js +3 -5
- package/dist/migrations/migrator.d.ts +2 -2
- package/dist/migrations/migrator.d.ts.map +1 -1
- package/dist/migrations/migrator.js +16 -13
- package/dist/migrations/v-0.0.0/types.generated.d.ts +139 -90
- package/dist/migrations/v-0.0.0/types.generated.d.ts.map +1 -1
- package/dist/migrations/v-2.1.0/migration.d.ts +11 -340
- package/dist/migrations/v-2.1.0/migration.d.ts.map +1 -1
- package/dist/migrations/v-2.1.0/migration.js +67 -46
- package/dist/migrations/v-2.1.0/types.generated.d.ts +353 -28
- package/dist/migrations/v-2.1.0/types.generated.d.ts.map +1 -1
- package/dist/migrations/v-2.2.0/index.d.ts +3 -0
- package/dist/migrations/v-2.2.0/index.d.ts.map +1 -0
- package/dist/migrations/v-2.2.0/index.js +1 -0
- package/dist/migrations/v-2.2.0/migration.d.ts +5 -0
- package/dist/migrations/v-2.2.0/migration.d.ts.map +1 -0
- package/dist/migrations/v-2.2.0/migration.js +110 -0
- package/dist/migrations/v-2.2.0/types.generated.d.ts +41 -0
- package/dist/migrations/v-2.2.0/types.generated.d.ts.map +1 -0
- package/dist/transforms/import-spec.d.ts +1 -3
- package/dist/transforms/import-spec.d.ts.map +1 -1
- package/dist/transforms/import-spec.js +54 -96
- package/dist/transforms/index.js +1 -1
- package/package.json +12 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"security.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/security.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"security.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/security.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAsBvB,eAAO,MAAM,sBAAsB,wCAAyC,CAAA;AAc5E,eAAO,MAAM,oBAAoB;;;;IAV/B,8EAA8E;;IAE9E,6FAA6F;;;;IAb7F,0EAA0E;;;;;;;;;;;;;;;;;;;;EAuBjD,CAAA;AAC3B,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA;AAkCvE,eAAO,MAAM,kBAAkB;;;;IA3B7B;;;OAGG;;IAOH;;;;OAIG;;;;IA7CH,0EAA0E;;;;;;;;;;;;;;;;;;;;;;;;;;EA4DnD,CAAA;AACzB,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAA;AAanE,eAAO,MAAM,oBAAoB;;;;IAP/B;;;OAGG;;;;IAtEH,0EAA0E;;;;;;;;;;;;;;EA4E3E,CAAA;AACD,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA;AA4CvE,0CAA0C;AAC1C,eAAO,MAAM,WAAW,qCAAsC,CAAA;AAuD9D,eAAO,MAAM,mBAAmB;;;;IAlD9B,6FAA6F;;;YAhC7F;;;eAGG;;YAEH;;;eAGG;;;YAMH,oEAAoE;;YAEpE,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;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E;;YAEpE,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAhBrB;;;eAGG;;YAEH;;;eAGG;;;YAMH,oEAAoE;;YAEpE,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;YAhBrB;;;eAGG;;YAEH;;;eAGG;;;YAMH,oEAAoE;;YAEpE,qBAAqB;;;;;YA8Cf;;;;eAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAjKT,0EAA0E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAoO1E,CAAA;AAEF;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA;AACjE,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA"}
|
|
@@ -1,83 +1,6 @@
|
|
|
1
|
-
import { schemaModel } from '../../helpers/schema-model.js';
|
|
2
1
|
import { z } from 'zod';
|
|
3
2
|
import { nanoidSchema } from '../shared/utility.js';
|
|
4
3
|
|
|
5
|
-
// ---------------------------------------------------------------------------
|
|
6
|
-
// Collection values for Security Schemes
|
|
7
|
-
const apiKeyExampleSchema = z.object({
|
|
8
|
-
type: z.literal('apiKey').default('apiKey'),
|
|
9
|
-
name: z.string().default(''),
|
|
10
|
-
value: z.string().default(''),
|
|
11
|
-
});
|
|
12
|
-
const httpExampleSchema = z.object({
|
|
13
|
-
type: z.literal('http').default('http'),
|
|
14
|
-
username: z.string().default(''),
|
|
15
|
-
password: z.string().default(''),
|
|
16
|
-
token: z.string().default(''),
|
|
17
|
-
});
|
|
18
|
-
const oauthImplicitExampleSchema = z.object({
|
|
19
|
-
type: z.literal('oauth-implicit').default('oauth-implicit'),
|
|
20
|
-
token: z.string().default(''),
|
|
21
|
-
});
|
|
22
|
-
const oauthPasswordExampleSchema = z.object({
|
|
23
|
-
type: z.literal('oauth-password').default('oauth-password'),
|
|
24
|
-
token: z.string().default(''),
|
|
25
|
-
username: z.string().default(''),
|
|
26
|
-
password: z.string().default(''),
|
|
27
|
-
clientSecret: z.string().default(''),
|
|
28
|
-
});
|
|
29
|
-
const oauthClientCredentialsExampleSchema = z.object({
|
|
30
|
-
type: z.literal('oauth-clientCredentials').default('oauth-clientCredentials'),
|
|
31
|
-
token: z.string().default(''),
|
|
32
|
-
clientSecret: z.string().default(''),
|
|
33
|
-
});
|
|
34
|
-
const oauthAuthorizationCodeExampleSchema = z.object({
|
|
35
|
-
type: z.literal('oauth-authorizationCode').default('oauth-authorizationCode'),
|
|
36
|
-
token: z.string().default(''),
|
|
37
|
-
clientSecret: z.string().default(''),
|
|
38
|
-
});
|
|
39
|
-
/**
|
|
40
|
-
* Value schema for each type of OAuth Flow
|
|
41
|
-
* Request Examples can store populated values for a given security scheme
|
|
42
|
-
*/
|
|
43
|
-
const securitySchemeExampleValueSchema = z.union([
|
|
44
|
-
apiKeyExampleSchema,
|
|
45
|
-
httpExampleSchema,
|
|
46
|
-
oauthImplicitExampleSchema,
|
|
47
|
-
oauthPasswordExampleSchema,
|
|
48
|
-
oauthClientCredentialsExampleSchema,
|
|
49
|
-
oauthAuthorizationCodeExampleSchema,
|
|
50
|
-
]);
|
|
51
|
-
/**
|
|
52
|
-
* Generates a base set of example data for a given securityScheme
|
|
53
|
-
*
|
|
54
|
-
* TODO: we can probably remove this unless we really want to keep it separate
|
|
55
|
-
*/
|
|
56
|
-
function authExampleFromSchema(scheme, baseValues = {}) {
|
|
57
|
-
try {
|
|
58
|
-
if (scheme.type === 'apiKey') {
|
|
59
|
-
return schemaModel({ name: scheme.name, ...baseValues }, apiKeyExampleSchema, false);
|
|
60
|
-
}
|
|
61
|
-
if (scheme.type === 'http') {
|
|
62
|
-
return schemaModel(baseValues, httpExampleSchema, false);
|
|
63
|
-
}
|
|
64
|
-
if (scheme.type === 'oauth2') {
|
|
65
|
-
if (scheme.flow.type === 'authorizationCode')
|
|
66
|
-
return schemaModel(baseValues, oauthAuthorizationCodeExampleSchema, false);
|
|
67
|
-
if (scheme.flow.type === 'clientCredentials')
|
|
68
|
-
return schemaModel(baseValues, oauthClientCredentialsExampleSchema, false);
|
|
69
|
-
if (scheme.flow.type === 'implicit')
|
|
70
|
-
return schemaModel(baseValues, oauthImplicitExampleSchema, false);
|
|
71
|
-
if (scheme.flow.type === 'password')
|
|
72
|
-
return schemaModel(baseValues, oauthPasswordExampleSchema, false);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
catch (e) {
|
|
76
|
-
console.error(e);
|
|
77
|
-
}
|
|
78
|
-
console.warn('[@scalar/oas-utils:security] Invalid schema for oauth example', scheme, baseValues);
|
|
79
|
-
return null;
|
|
80
|
-
}
|
|
81
4
|
// ---------------------------------------------------------------------------
|
|
82
5
|
// COMMON PROPS FOR ALL SECURITY SCHEMES
|
|
83
6
|
/** Some common properties used in all security schemes */
|
|
@@ -100,7 +23,12 @@ const oasSecuritySchemeApiKey = commonProps.extend({
|
|
|
100
23
|
/** REQUIRED. The location of the API key. Valid values are "query", "header" or "cookie". */
|
|
101
24
|
in: z.enum(securitySchemeApiKeyIn).optional().default('header'),
|
|
102
25
|
});
|
|
103
|
-
const
|
|
26
|
+
const apiKeyValueSchema = z.object({
|
|
27
|
+
value: z.string().default(''),
|
|
28
|
+
});
|
|
29
|
+
const securityApiKeySchema = oasSecuritySchemeApiKey
|
|
30
|
+
.merge(extendedSecuritySchema)
|
|
31
|
+
.merge(apiKeyValueSchema);
|
|
104
32
|
// ---------------------------------------------------------------------------
|
|
105
33
|
// HTTP
|
|
106
34
|
const oasSecuritySchemeHttp = commonProps.extend({
|
|
@@ -125,7 +53,14 @@ const oasSecuritySchemeHttp = commonProps.extend({
|
|
|
125
53
|
.optional()
|
|
126
54
|
.default('JWT'),
|
|
127
55
|
});
|
|
128
|
-
const
|
|
56
|
+
const httpValueSchema = z.object({
|
|
57
|
+
username: z.string().default(''),
|
|
58
|
+
password: z.string().default(''),
|
|
59
|
+
token: z.string().default(''),
|
|
60
|
+
});
|
|
61
|
+
const securityHttpSchema = oasSecuritySchemeHttp
|
|
62
|
+
.merge(extendedSecuritySchema)
|
|
63
|
+
.merge(httpValueSchema);
|
|
129
64
|
// ---------------------------------------------------------------------------
|
|
130
65
|
// OPENID CONNECT
|
|
131
66
|
const oasSecuritySchemeOpenId = commonProps.extend({
|
|
@@ -149,25 +84,25 @@ const authorizationUrl = z.string().default('');
|
|
|
149
84
|
*/
|
|
150
85
|
const tokenUrl = z.string().default('');
|
|
151
86
|
/** Common properties used across all oauth2 flows */
|
|
152
|
-
const
|
|
87
|
+
const flowsCommon = z.object({
|
|
153
88
|
/**
|
|
154
89
|
* The URL to be used for obtaining refresh tokens. This MUST be in the form of a
|
|
155
90
|
* URL. The OAuth2 standard requires the use of TLS.
|
|
156
91
|
*/
|
|
157
|
-
refreshUrl: z.string().optional().default(''),
|
|
92
|
+
'refreshUrl': z.string().optional().default(''),
|
|
158
93
|
/**
|
|
159
94
|
* REQUIRED. The available scopes for the OAuth2 security scheme. A map
|
|
160
95
|
* between the scope name and a short description for it. The map MAY be empty.
|
|
161
96
|
*/
|
|
162
|
-
scopes: z
|
|
163
|
-
.
|
|
164
|
-
z.map(z.string(), z.string().optional()),
|
|
165
|
-
z.record(z.string(), z.string().optional()),
|
|
166
|
-
z.object({}),
|
|
167
|
-
])
|
|
97
|
+
'scopes': z
|
|
98
|
+
.record(z.string(), z.string().optional().default(''))
|
|
168
99
|
.optional()
|
|
169
100
|
.default({}),
|
|
170
|
-
selectedScopes: z.array(z.string()).optional().default([]),
|
|
101
|
+
'selectedScopes': z.array(z.string()).optional().default([]),
|
|
102
|
+
/** Extension to save the client Id associated with an oauth flow */
|
|
103
|
+
'x-scalar-client-id': z.string().optional().default(''),
|
|
104
|
+
/** The auth token */
|
|
105
|
+
'token': z.string().default(''),
|
|
171
106
|
});
|
|
172
107
|
/** Setup a default redirect uri if we can */
|
|
173
108
|
const defaultRedirectUri = typeof window !== 'undefined'
|
|
@@ -175,52 +110,57 @@ const defaultRedirectUri = typeof window !== 'undefined'
|
|
|
175
110
|
: '';
|
|
176
111
|
/** Options for the x-usePkce extension */
|
|
177
112
|
const pkceOptions = ['SHA-256', 'plain', 'no'];
|
|
178
|
-
|
|
179
|
-
.discriminatedUnion('type', [
|
|
180
|
-
/** Configuration for the OAuth Implicit flow */
|
|
181
|
-
oauthCommon.extend({
|
|
182
|
-
'type': z.literal('implicit'),
|
|
183
|
-
authorizationUrl,
|
|
184
|
-
'x-scalar-redirect-uri': z
|
|
185
|
-
.string()
|
|
186
|
-
.optional()
|
|
187
|
-
.default(defaultRedirectUri),
|
|
188
|
-
}),
|
|
189
|
-
/** Configuration for the OAuth Resource Owner Password flow */
|
|
190
|
-
oauthCommon.extend({
|
|
191
|
-
type: z.literal('password'),
|
|
192
|
-
tokenUrl,
|
|
193
|
-
}),
|
|
194
|
-
/** Configuration for the OAuth Client Credentials flow. Previously called application in OpenAPI 2.0. */
|
|
195
|
-
oauthCommon.extend({
|
|
196
|
-
type: z.literal('clientCredentials'),
|
|
197
|
-
tokenUrl,
|
|
198
|
-
}),
|
|
199
|
-
/** Configuration for the OAuth Authorization Code flow. Previously called accessCode in OpenAPI 2.0.*/
|
|
200
|
-
oauthCommon.extend({
|
|
201
|
-
'type': z.literal('authorizationCode'),
|
|
202
|
-
authorizationUrl,
|
|
203
|
-
/**
|
|
204
|
-
* Whether to use PKCE for the authorization code flow.
|
|
205
|
-
*
|
|
206
|
-
* TODO: add docs
|
|
207
|
-
*/
|
|
208
|
-
'x-usePkce': z.enum(pkceOptions).optional().default('no'),
|
|
209
|
-
'x-scalar-redirect-uri': z
|
|
210
|
-
.string()
|
|
211
|
-
.optional()
|
|
212
|
-
.default(defaultRedirectUri),
|
|
213
|
-
tokenUrl,
|
|
214
|
-
}),
|
|
215
|
-
])
|
|
216
|
-
.optional()
|
|
217
|
-
.default({ type: 'implicit', authorizationUrl: 'http://localhost:8080' });
|
|
113
|
+
/** Oauth2 security scheme */
|
|
218
114
|
const oasSecuritySchemeOauth2 = commonProps.extend({
|
|
219
|
-
|
|
115
|
+
type: z.literal('oauth2'),
|
|
220
116
|
/** REQUIRED. An object containing configuration information for the flow types supported. */
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
117
|
+
flows: z
|
|
118
|
+
.object({
|
|
119
|
+
/** Configuration for the OAuth Implicit flow */
|
|
120
|
+
implicit: flowsCommon.extend({
|
|
121
|
+
'type': z.literal('implicit'),
|
|
122
|
+
authorizationUrl,
|
|
123
|
+
'x-scalar-redirect-uri': z
|
|
124
|
+
.string()
|
|
125
|
+
.optional()
|
|
126
|
+
.default(defaultRedirectUri),
|
|
127
|
+
}),
|
|
128
|
+
/** Configuration for the OAuth Resource Owner Password flow */
|
|
129
|
+
password: flowsCommon.extend({
|
|
130
|
+
type: z.literal('password'),
|
|
131
|
+
tokenUrl,
|
|
132
|
+
clientSecret: z.string().default(''),
|
|
133
|
+
username: z.string().default(''),
|
|
134
|
+
password: z.string().default(''),
|
|
135
|
+
}),
|
|
136
|
+
/** Configuration for the OAuth Client Credentials flow. Previously called application in OpenAPI 2.0. */
|
|
137
|
+
clientCredentials: flowsCommon.extend({
|
|
138
|
+
type: z.literal('clientCredentials'),
|
|
139
|
+
tokenUrl,
|
|
140
|
+
clientSecret: z.string().default(''),
|
|
141
|
+
}),
|
|
142
|
+
/** Configuration for the OAuth Authorization Code flow. Previously called accessCode in OpenAPI 2.0.*/
|
|
143
|
+
authorizationCode: flowsCommon.extend({
|
|
144
|
+
'type': z.literal('authorizationCode'),
|
|
145
|
+
authorizationUrl,
|
|
146
|
+
/**
|
|
147
|
+
* Whether to use PKCE for the authorization code flow.
|
|
148
|
+
*
|
|
149
|
+
* TODO: add docs
|
|
150
|
+
*/
|
|
151
|
+
'x-usePkce': z.enum(pkceOptions).optional().default('no'),
|
|
152
|
+
'x-scalar-redirect-uri': z
|
|
153
|
+
.string()
|
|
154
|
+
.optional()
|
|
155
|
+
.default(defaultRedirectUri),
|
|
156
|
+
tokenUrl,
|
|
157
|
+
'clientSecret': z.string().default(''),
|
|
158
|
+
}),
|
|
159
|
+
})
|
|
160
|
+
.partial()
|
|
161
|
+
.default({
|
|
162
|
+
implicit: { type: 'implicit', authorizationUrl: 'http://localhost:8080' },
|
|
163
|
+
}),
|
|
224
164
|
});
|
|
225
165
|
const securityOauthSchema = oasSecuritySchemeOauth2.merge(extendedSecuritySchema);
|
|
226
166
|
// ---------------------------------------------------------------------------
|
|
@@ -251,4 +191,4 @@ const securitySchemeSchema = z.union([
|
|
|
251
191
|
securityOauthSchema,
|
|
252
192
|
]);
|
|
253
193
|
|
|
254
|
-
export {
|
|
194
|
+
export { oasSecurityRequirementSchema, oasSecuritySchemeSchema, pkceOptions, securityApiKeySchema, securityHttpSchema, securityOauthSchema, securityOpenIdSchema, securitySchemeApiKeyIn, securitySchemeSchema };
|
|
@@ -17,8 +17,6 @@ export declare const workspaceSchema: z.ZodObject<{
|
|
|
17
17
|
name: z.ZodDefault<z.ZodString>;
|
|
18
18
|
/** Workspace description */
|
|
19
19
|
description: z.ZodDefault<z.ZodString>;
|
|
20
|
-
/** Controls read only mode for most entitites, but not things like params */
|
|
21
|
-
isReadOnly: z.ZodDefault<z.ZodBoolean>;
|
|
22
20
|
/** List of all collection uids in a given workspace */
|
|
23
21
|
collections: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
24
22
|
/** List of all environment uids in a given workspace */
|
|
@@ -56,17 +54,16 @@ export declare const workspaceSchema: z.ZodObject<{
|
|
|
56
54
|
/** Workspace level proxy for all requests to be sent through */
|
|
57
55
|
proxyUrl: z.ZodOptional<z.ZodString>;
|
|
58
56
|
/** Workspace level theme, we might move this to user level later */
|
|
59
|
-
themeId: z.ZodDefault<z.ZodOptional<z.ZodEnum<["alternate", "default", "moon", "purple", "solarized", "bluePlanet", "deepSpace", "saturn", "kepler", "mars", "none"]>>>;
|
|
57
|
+
themeId: z.ZodDefault<z.ZodOptional<z.ZodEnum<["alternate", "default", "moon", "purple", "solarized", "bluePlanet", "deepSpace", "saturn", "kepler", "elysiajs", "fastify", "mars", "none"]>>>;
|
|
60
58
|
}, "strip", z.ZodTypeAny, {
|
|
61
59
|
uid: string;
|
|
62
60
|
name: string;
|
|
63
61
|
description: string;
|
|
64
|
-
isReadOnly: boolean;
|
|
65
62
|
collections: string[];
|
|
66
63
|
environments: string[];
|
|
67
64
|
activeEnvironmentId: string;
|
|
68
65
|
cookies: string[];
|
|
69
|
-
themeId: "default" | "alternate" | "moon" | "purple" | "solarized" | "bluePlanet" | "deepSpace" | "saturn" | "kepler" | "mars" | "none";
|
|
66
|
+
themeId: "default" | "alternate" | "moon" | "purple" | "solarized" | "bluePlanet" | "deepSpace" | "saturn" | "kepler" | "elysiajs" | "fastify" | "mars" | "none";
|
|
70
67
|
hotKeyConfig?: {
|
|
71
68
|
modifiers: ("Meta" | "Control" | "Shift" | "Alt" | "default")[];
|
|
72
69
|
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" | ";" | "=" | "," | "`" | "[" | "\\" | "]", {
|
|
@@ -79,7 +76,6 @@ export declare const workspaceSchema: z.ZodObject<{
|
|
|
79
76
|
uid?: string | undefined;
|
|
80
77
|
name?: string | undefined;
|
|
81
78
|
description?: string | undefined;
|
|
82
|
-
isReadOnly?: boolean | undefined;
|
|
83
79
|
collections?: string[] | undefined;
|
|
84
80
|
environments?: string[] | undefined;
|
|
85
81
|
hotKeyConfig?: {
|
|
@@ -92,7 +88,7 @@ export declare const workspaceSchema: z.ZodObject<{
|
|
|
92
88
|
activeEnvironmentId?: string | undefined;
|
|
93
89
|
cookies?: string[] | undefined;
|
|
94
90
|
proxyUrl?: string | undefined;
|
|
95
|
-
themeId?: "default" | "alternate" | "moon" | "purple" | "solarized" | "bluePlanet" | "deepSpace" | "saturn" | "kepler" | "mars" | "none" | undefined;
|
|
91
|
+
themeId?: "default" | "alternate" | "moon" | "purple" | "solarized" | "bluePlanet" | "deepSpace" | "saturn" | "kepler" | "elysiajs" | "fastify" | "mars" | "none" | undefined;
|
|
96
92
|
}>;
|
|
97
93
|
/** The base scalar workspace */
|
|
98
94
|
export type Workspace = z.infer<typeof workspaceSchema>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../../src/entities/workspace/workspace.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AASvB,QAAA,MAAM,SAAS,yIAAoD,CAAA;AAEnE,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,CAAA;AAEvD,QAAA,MAAM,OAAO;;;;;;;;;GAMZ,CAAA;AACD,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,OAAO,CAAC,CAAA;AASlD,eAAO,MAAM,eAAe;;;IAG1B,4BAA4B;;IAE5B,
|
|
1
|
+
{"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../../src/entities/workspace/workspace.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AASvB,QAAA,MAAM,SAAS,yIAAoD,CAAA;AAEnE,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,CAAA;AAEvD,QAAA,MAAM,OAAO;;;;;;;;;GAMZ,CAAA;AACD,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,OAAO,CAAC,CAAA;AASlD,eAAO,MAAM,eAAe;;;IAG1B,4BAA4B;;IAE5B,uDAAuD;;IAEvD,wDAAwD;;IAExD,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;IAExB,iDAAiD;;IAEjD,mDAAmD;;IAEnD,gEAAgE;;IAEhE,oEAAoE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAEpE,CAAA;AAEF,gCAAgC;AAChC,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAA;AACvD,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAA"}
|
|
@@ -23,8 +23,6 @@ const workspaceSchema = z.object({
|
|
|
23
23
|
name: z.string().default('Default Workspace'),
|
|
24
24
|
/** Workspace description */
|
|
25
25
|
description: z.string().default('Basic Scalar Workspace'),
|
|
26
|
-
/** Controls read only mode for most entitites, but not things like params */
|
|
27
|
-
isReadOnly: z.boolean().default(false),
|
|
28
26
|
/** List of all collection uids in a given workspace */
|
|
29
27
|
collections: z.array(z.string()).default([]),
|
|
30
28
|
/** List of all environment uids in a given workspace */
|
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
* previous data versions:
|
|
5
5
|
* - undefined
|
|
6
6
|
* - 0.0.0
|
|
7
|
-
* - 2.1.0
|
|
7
|
+
* - 2.1.0 - refactor
|
|
8
|
+
* - 2.2.0 - auth compliancy
|
|
8
9
|
*/
|
|
9
|
-
export declare const DATA_VERSION = "2.
|
|
10
|
+
export declare const DATA_VERSION = "2.2.0";
|
|
10
11
|
/** The localStorage key under which the data version is stored */
|
|
11
12
|
export declare const DATA_VERSION_LS_LEY = "scalar_api_client_data_version";
|
|
12
13
|
//# sourceMappingURL=data-version.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-version.d.ts","sourceRoot":"","sources":["../../src/migrations/data-version.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"data-version.d.ts","sourceRoot":"","sources":["../../src/migrations/data-version.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,UAAU,CAAA;AAEnC,kEAAkE;AAClE,eAAO,MAAM,mBAAmB,mCAAmC,CAAA"}
|
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
* previous data versions:
|
|
5
5
|
* - undefined
|
|
6
6
|
* - 0.0.0
|
|
7
|
-
* - 2.1.0
|
|
7
|
+
* - 2.1.0 - refactor
|
|
8
|
+
* - 2.2.0 - auth compliancy
|
|
8
9
|
*/
|
|
9
|
-
const DATA_VERSION = '2.
|
|
10
|
+
const DATA_VERSION = '2.2.0';
|
|
10
11
|
/** The localStorage key under which the data version is stored */
|
|
11
12
|
const DATA_VERSION_LS_LEY = 'scalar_api_client_data_version';
|
|
12
13
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-storage.d.ts","sourceRoot":"","sources":["../../src/migrations/local-storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAKxC;;GAEG;AACH,eAAO,MAAM,iBAAiB,UACrB,CAAC,OAAO,OAAO,EAAE,MAAM,OAAO,OAAO,CAAC,KAC5C,MAAM,CAAC,MAAM,EAAE,OAAO,CAKxB,CAAA;AAED,oDAAoD;AACpD,eAAO,MAAM,sBAAsB,QAAO,
|
|
1
|
+
{"version":3,"file":"local-storage.d.ts","sourceRoot":"","sources":["../../src/migrations/local-storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAKxC;;GAEG;AACH,eAAO,MAAM,iBAAiB,UACrB,CAAC,OAAO,OAAO,EAAE,MAAM,OAAO,OAAO,CAAC,KAC5C,MAAM,CAAC,MAAM,EAAE,OAAO,CAKxB,CAAA;AAED,oDAAoD;AACpD,eAAO,MAAM,sBAAsB,QAAO,MAqBzC,CAAA"}
|
|
@@ -13,22 +13,20 @@ const parseLocalStorage = (lsKey) => {
|
|
|
13
13
|
const getLocalStorageVersion = () => {
|
|
14
14
|
const collectionStr = localStorage.getItem('collection');
|
|
15
15
|
const dataVersion = localStorage.getItem(DATA_VERSION_LS_LEY);
|
|
16
|
+
if (dataVersion)
|
|
17
|
+
return dataVersion;
|
|
16
18
|
// No flatted means first version
|
|
17
19
|
if (!collectionStr?.length || collectionStr?.[0] === '{')
|
|
18
20
|
return '0.0.0';
|
|
19
|
-
// Flatted + types means 2.1.0
|
|
21
|
+
// Flatted + types means > 2.1.0 but we should have a data version
|
|
20
22
|
try {
|
|
21
23
|
const [collection] = Object.values(parse(collectionStr) ?? {});
|
|
22
24
|
if (collection?.type === 'collection')
|
|
23
25
|
return '2.1.0';
|
|
24
|
-
if (dataVersion)
|
|
25
|
-
return dataVersion;
|
|
26
26
|
return '0.0.0';
|
|
27
27
|
}
|
|
28
28
|
catch (e) {
|
|
29
29
|
console.error(e);
|
|
30
|
-
if (dataVersion)
|
|
31
|
-
return dataVersion;
|
|
32
30
|
return '0.0.0';
|
|
33
31
|
}
|
|
34
32
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type v_2_2_0 } from '../migrations/v-2.2.0/index.js';
|
|
2
2
|
/** Handles all data migrations per entity */
|
|
3
|
-
export declare const migrator: () =>
|
|
3
|
+
export declare const migrator: () => v_2_2_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":"AAMA,OAAO,EAAmB,KAAK,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAEpE,6CAA6C;AAC7C,eAAO,MAAM,QAAQ,QAAO,OAAO,CAAC,SAoCnC,CAAA"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
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
|
+
import { migrate_v_2_2_0 } from './v-2.2.0/migration.js';
|
|
4
5
|
|
|
5
6
|
/** Handles all data migrations per entity */
|
|
6
7
|
const migrator = () => {
|
|
@@ -21,19 +22,21 @@ const migrator = () => {
|
|
|
21
22
|
// 0.0.0 -> 2.1.0 migration
|
|
22
23
|
if (semverLessThan(dataVersion, '2.1.0'))
|
|
23
24
|
data = migrate_v_2_1_0(data);
|
|
24
|
-
//
|
|
25
|
-
|
|
26
|
-
data =
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
25
|
+
// 2.1.0 -> 2.2.0 migration
|
|
26
|
+
if (semverLessThan(dataVersion, '2.2.0'))
|
|
27
|
+
data = migrate_v_2_2_0(data);
|
|
28
|
+
// Convert to data array
|
|
29
|
+
data = {
|
|
30
|
+
collections: Object.values(data.collections),
|
|
31
|
+
cookies: Object.values(data.cookies),
|
|
32
|
+
environments: Object.values(data.environments),
|
|
33
|
+
requestExamples: Object.values(data.requestExamples),
|
|
34
|
+
requests: Object.values(data.requests),
|
|
35
|
+
securitySchemes: Object.values(data.securitySchemes),
|
|
36
|
+
servers: Object.values(data.servers),
|
|
37
|
+
tags: Object.values(data.tags),
|
|
38
|
+
workspaces: Object.values(data.workspaces),
|
|
39
|
+
};
|
|
37
40
|
return data;
|
|
38
41
|
};
|
|
39
42
|
|