@scalar/oas-utils 0.2.84 → 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 +15 -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/request-examples.d.ts.map +1 -1
- package/dist/entities/spec/request-examples.js +12 -5
- 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/helpers/httpMethods.d.ts +3 -1
- package/dist/helpers/httpMethods.d.ts.map +1 -1
- package/dist/helpers/httpMethods.js +5 -1
- package/dist/helpers/index.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 +88 -81
- package/package.json +7 -2
- 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
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @scalar/oas-utils
|
|
2
2
|
|
|
3
|
+
## 0.2.86
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 3eb0d11: feat: moved api-client auth into references
|
|
8
|
+
- b66a85c: feat: adds v-2.3.0 migration for workspace type
|
|
9
|
+
|
|
10
|
+
## 0.2.85
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- 3b4a788: feat: sets form request examples defaulting
|
|
15
|
+
- 4c5be96: feat: adds isHttpMethod to helpers
|
|
16
|
+
- 4c5be96: fix: sorts method based on path in import spec
|
|
17
|
+
|
|
3
18
|
## 0.2.84
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -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';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request-examples.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/request-examples.ts"],"names":[],"mappings":"AAOA,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;AAKtC;;;;;GAKG;AACH,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAczC,CAAA;AAUF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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAEvC,CAAA;AAEF,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA;AAOjE,2DAA2D;AAC3D,eAAO,MAAM,oBAAoB;IAC/B,qCAAqC;;;;QA3CrC;;;;WAIG;;QAEH,0EAA0E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8C1E,CAAA;AAEF,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA;AAEjE;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,cAAc;;;;;;;;;;;;;;;;EA8D9D;AAKD,6DAA6D;AAC7D,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,gBAAgB;;;;;;;;;;;;;;EA8C1D;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,MAAM,GACd,cAAc,CA2GhB"}
|
|
@@ -325,12 +325,19 @@ function createExampleFromRequest(request, name, server) {
|
|
|
325
325
|
body.activeBody = 'binary';
|
|
326
326
|
body.binary = undefined;
|
|
327
327
|
}
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
*/
|
|
331
|
-
if (requestBody?.body?.mimeType === 'application/x-www-form-urlencoded') {
|
|
328
|
+
if (requestBody?.body?.mimeType === 'application/x-www-form-urlencoded' ||
|
|
329
|
+
requestBody?.body?.mimeType === 'multipart/form-data') {
|
|
332
330
|
body.activeBody = 'formData';
|
|
333
|
-
body.formData =
|
|
331
|
+
body.formData = {
|
|
332
|
+
encoding: requestBody.body.mimeType === 'application/x-www-form-urlencoded'
|
|
333
|
+
? 'urlencoded'
|
|
334
|
+
: 'form-data',
|
|
335
|
+
value: (requestBody.body.params || []).map((param) => ({
|
|
336
|
+
key: param.name,
|
|
337
|
+
value: param.value || '',
|
|
338
|
+
enabled: true,
|
|
339
|
+
})),
|
|
340
|
+
};
|
|
334
341
|
}
|
|
335
342
|
}
|
|
336
343
|
const serverVariables = server ? getServerVariableExamples(server) : {};
|
|
@@ -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 */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type RequestMethod } from '../entities/spec/requests.js';
|
|
2
2
|
/**
|
|
3
3
|
* HTTP methods in a specific order
|
|
4
4
|
* Do not change the order
|
|
@@ -23,5 +23,7 @@ export declare const getHttpMethodInfo: (methodName: string) => {
|
|
|
23
23
|
color: string;
|
|
24
24
|
backgroundColor: string;
|
|
25
25
|
};
|
|
26
|
+
/** Type guard which takes in a string and returns true if it is in fact an HTTPMethod */
|
|
27
|
+
export declare const isHttpMethod: (method: string) => method is RequestMethod;
|
|
26
28
|
export {};
|
|
27
29
|
//# sourceMappingURL=httpMethods.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"httpMethods.d.ts","sourceRoot":"","sources":["../../src/helpers/httpMethods.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"httpMethods.d.ts","sourceRoot":"","sources":["../../src/helpers/httpMethods.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAkB,MAAM,0BAA0B,CAAA;AAE7E;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE;KAC3B,CAAC,IAAI,aAAa,GAAG;QACpB,KAAK,EAAE,MAAM,CAAA;QACb,KAAK,EAAE,MAAM,CAAA;QACb,eAAe,EAAE,MAAM,CAAA;KACxB;CA+CO,CAAA;AAEV,yCAAyC;AACzC,QAAA,MAAM,YAAY,6CAA8C,CAAA;AAChE,KAAK,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAA;AAE/C,0DAA0D;AAC1D,eAAO,MAAM,iBAAiB,WACpB,aAAa,KACpB,MAAM,IAAI,UAAyD,CAAA;AAEtE;;GAEG;AACH,eAAO,MAAM,iBAAiB,eAAgB,MAAM;WAhEzC,MAAM;WACN,MAAM;qBACI,MAAM;CAuE1B,CAAA;AAED,yFAAyF;AACzF,eAAO,MAAM,YAAY,WAAY,MAAM,KAAG,MAAM,IAAI,aACN,CAAA"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { requestMethods } from '../entities/spec/requests.js';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* HTTP methods in a specific order
|
|
3
5
|
* Do not change the order
|
|
@@ -64,5 +66,7 @@ const getHttpMethodInfo = (methodName) => {
|
|
|
64
66
|
backgroundColor: 'bg-c-2',
|
|
65
67
|
});
|
|
66
68
|
};
|
|
69
|
+
/** Type guard which takes in a string and returns true if it is in fact an HTTPMethod */
|
|
70
|
+
const isHttpMethod = (method) => requestMethods.includes(method);
|
|
67
71
|
|
|
68
|
-
export { REQUEST_METHODS, canMethodHaveBody, getHttpMethodInfo };
|
|
72
|
+
export { REQUEST_METHODS, canMethodHaveBody, getHttpMethodInfo, isHttpMethod };
|
package/dist/helpers/index.js
CHANGED
|
@@ -3,7 +3,7 @@ export { createHash } from './createHash.js';
|
|
|
3
3
|
export { fetchSpecFromUrl } from './fetchSpecFromUrl.js';
|
|
4
4
|
export { fetchWithProxyFallback } from './fetchWithProxyFallback.js';
|
|
5
5
|
export { findVariables } from './findVariables.js';
|
|
6
|
-
export { REQUEST_METHODS, canMethodHaveBody, getHttpMethodInfo } from './httpMethods.js';
|
|
6
|
+
export { REQUEST_METHODS, canMethodHaveBody, getHttpMethodInfo, isHttpMethod } from './httpMethods.js';
|
|
7
7
|
export { httpStatusCodes } from './httpStatusCodes.js';
|
|
8
8
|
export { isLocalUrl } from './isLocalUrl.js';
|
|
9
9
|
export { isValidUrl } from './isValidUrl.js';
|
|
@@ -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,EAAE,EACpB,GAAG,IAAI,CAAC,EACT,MAAM,iBAAiB,CAAA;AAExB;;GAEG;AACH,yBAAiB,OAAO,CAAC;IACvB,KAAY,MAAM,GAAG,EAAE,CAAA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rate_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,EACpB,GAAG,IAAI,CAAC,EACT,MAAM,iBAAiB,CAAA;AACxB,OAAO,KAAK,EAAE,SAAS,IAAI,CAAC,EAAE,MAAM,sBAAsB,CAAA;AAE1D,yBAA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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,
|
|
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"}
|
|
@@ -1,26 +1,33 @@
|
|
|
1
1
|
import { securitySchemeSchema } from '../entities/spec/security.js';
|
|
2
|
+
import { isHttpMethod } from '../helpers/httpMethods.js';
|
|
2
3
|
import { schemaModel } from '../helpers/schema-model.js';
|
|
3
4
|
import { keysOf } from '@scalar/object-utils/arrays';
|
|
4
5
|
import { load, upgrade, dereference } from '@scalar/openapi-parser';
|
|
5
6
|
import { serverSchema } from '../entities/spec/server.js';
|
|
6
|
-
import {
|
|
7
|
+
import { requestSchema } from '../entities/spec/requests.js';
|
|
7
8
|
import { tagSchema } from '../entities/spec/spec-objects.js';
|
|
8
9
|
import { createExampleFromRequest } from '../entities/spec/request-examples.js';
|
|
9
10
|
import { collectionSchema } from '../entities/spec/collection.js';
|
|
10
11
|
|
|
11
12
|
/** Takes a string or object and parses it into an openapi spec compliant schema */
|
|
12
|
-
const parseSchema = async (spec) => {
|
|
13
|
+
const parseSchema = async (spec, { shouldLoad = true } = {}) => {
|
|
13
14
|
// TODO: Plugins for URLs and files with the proxy is missing here.
|
|
14
15
|
// @see packages/api-reference/src/helpers/parse.ts
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
+
}
|
|
24
31
|
const { specification } = upgrade(filesystem);
|
|
25
32
|
const { schema, errors: derefErrors = [] } = await dereference(specification);
|
|
26
33
|
if (!schema)
|
|
@@ -47,8 +54,8 @@ const parseSchema = async (spec) => {
|
|
|
47
54
|
* - Proper linking between related components
|
|
48
55
|
* - Easy lookup and reference of dependent entities
|
|
49
56
|
*/
|
|
50
|
-
async function importSpecToWorkspace(spec, { authentication, baseServerURL, documentUrl, servers: overloadServers, setCollectionSecurity = false, watchMode = false, } = {}) {
|
|
51
|
-
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 });
|
|
52
59
|
const importWarnings = [...errors.map((e) => e.message)];
|
|
53
60
|
if (!schema)
|
|
54
61
|
return { importWarnings, error: true };
|
|
@@ -161,77 +168,77 @@ async function importSpecToWorkspace(spec, { authentication, baseServerURL, docu
|
|
|
161
168
|
// Path level servers must be saved
|
|
162
169
|
const pathServers = serverSchema.array().parse(path.servers ?? []);
|
|
163
170
|
servers.push(...pathServers);
|
|
164
|
-
|
|
171
|
+
// Creates a sorted array of methods based on the path object.
|
|
172
|
+
const methods = Object.keys(path).filter(isHttpMethod);
|
|
173
|
+
methods.forEach((method) => {
|
|
165
174
|
const operation = path[method];
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
175
|
+
const operationServers = serverSchema
|
|
176
|
+
.array()
|
|
177
|
+
.parse(operation.servers ?? []);
|
|
178
|
+
servers.push(...operationServers);
|
|
179
|
+
// We will save a list of all tags to ensure they exists at the top level
|
|
180
|
+
// TODO: make sure we add any loose requests with no tags to the collection children
|
|
181
|
+
operation.tags?.forEach((t) => tagNames.add(t));
|
|
182
|
+
// Remove security here and add it correctly below
|
|
183
|
+
const { security: operationSecurity, ...operationWithoutSecurity } = operation;
|
|
184
|
+
// Grab the security requirements for this operation
|
|
185
|
+
const securityRequirements = (operationSecurity ??
|
|
186
|
+
schema.security ??
|
|
187
|
+
[]).flatMap((s) => {
|
|
188
|
+
const keys = Object.keys(s);
|
|
189
|
+
if (keys.length)
|
|
190
|
+
return keys[0];
|
|
191
|
+
else
|
|
192
|
+
return [];
|
|
193
|
+
});
|
|
194
|
+
let selectedSecuritySchemeUids = [];
|
|
195
|
+
// Set the initially selected security scheme
|
|
196
|
+
if (securityRequirements.length && !setCollectionSecurity) {
|
|
197
|
+
const name = authentication?.preferredSecurityScheme &&
|
|
198
|
+
securityRequirements.includes(authentication.preferredSecurityScheme ?? '')
|
|
199
|
+
? authentication.preferredSecurityScheme
|
|
200
|
+
: securityRequirements[0];
|
|
201
|
+
const uid = securitySchemeMap[name];
|
|
202
|
+
selectedSecuritySchemeUids = [uid];
|
|
203
|
+
}
|
|
204
|
+
const requestPayload = {
|
|
205
|
+
...operationWithoutSecurity,
|
|
206
|
+
method,
|
|
207
|
+
path: pathString,
|
|
208
|
+
selectedSecuritySchemeUids,
|
|
209
|
+
// Merge path and operation level parameters
|
|
210
|
+
parameters: [
|
|
211
|
+
...(path?.parameters ?? []),
|
|
212
|
+
...(operation.parameters ?? []),
|
|
213
|
+
],
|
|
214
|
+
servers: [...pathServers, ...operationServers].map((s) => s.uid),
|
|
215
|
+
};
|
|
216
|
+
// Remove any examples from the request payload as they conflict with our examples property and are not valid
|
|
217
|
+
if (requestPayload.examples) {
|
|
218
|
+
console.warn('[@scalar/api-client] operation.examples is not a valid openapi property');
|
|
219
|
+
delete requestPayload.examples;
|
|
220
|
+
}
|
|
221
|
+
// Add list of UIDs to associate security schemes
|
|
222
|
+
// As per the spec if there is operation level security we ignore the top level requirements
|
|
223
|
+
if (operationSecurity?.length)
|
|
224
|
+
requestPayload.security = operationSecurity.map((s) => {
|
|
180
225
|
const keys = Object.keys(s);
|
|
181
|
-
|
|
182
|
-
|
|
226
|
+
// Handle the case of {} for optional
|
|
227
|
+
if (keys.length) {
|
|
228
|
+
const [key] = Object.keys(s);
|
|
229
|
+
return {
|
|
230
|
+
[key]: s[key],
|
|
231
|
+
};
|
|
232
|
+
}
|
|
183
233
|
else
|
|
184
|
-
return
|
|
234
|
+
return s;
|
|
185
235
|
});
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
: securityRequirements[0];
|
|
193
|
-
const uid = securitySchemeMap[name];
|
|
194
|
-
selectedSecuritySchemeUids = [uid];
|
|
195
|
-
}
|
|
196
|
-
const requestPayload = {
|
|
197
|
-
...operationWithoutSecurity,
|
|
198
|
-
method,
|
|
199
|
-
path: pathString,
|
|
200
|
-
selectedSecuritySchemeUids,
|
|
201
|
-
// Merge path and operation level parameters
|
|
202
|
-
parameters: [
|
|
203
|
-
...(path?.parameters ?? []),
|
|
204
|
-
...(operation.parameters ?? []),
|
|
205
|
-
],
|
|
206
|
-
servers: [...pathServers, ...operationServers].map((s) => s.uid),
|
|
207
|
-
};
|
|
208
|
-
// Remove any examples from the request payload as they conflict with our examples property and are not valid
|
|
209
|
-
if (requestPayload.examples) {
|
|
210
|
-
console.warn('[@scalar/api-client] operation.examples is not a valid openapi property');
|
|
211
|
-
delete requestPayload.examples;
|
|
212
|
-
}
|
|
213
|
-
// Add list of UIDs to associate security schemes
|
|
214
|
-
// As per the spec if there is operation level security we ignore the top level requirements
|
|
215
|
-
if (operationSecurity?.length)
|
|
216
|
-
requestPayload.security = operationSecurity.map((s) => {
|
|
217
|
-
const keys = Object.keys(s);
|
|
218
|
-
// Handle the case of {} for optional
|
|
219
|
-
if (keys.length) {
|
|
220
|
-
const [key] = Object.keys(s);
|
|
221
|
-
return {
|
|
222
|
-
[key]: s[key],
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
else
|
|
226
|
-
return s;
|
|
227
|
-
});
|
|
228
|
-
// Save parse the request
|
|
229
|
-
const request = schemaModel(requestPayload, requestSchema, false);
|
|
230
|
-
if (!request)
|
|
231
|
-
importWarnings.push(`${method} Request at ${path} is invalid.`);
|
|
232
|
-
else
|
|
233
|
-
requests.push(request);
|
|
234
|
-
}
|
|
236
|
+
// Save parse the request
|
|
237
|
+
const request = schemaModel(requestPayload, requestSchema, false);
|
|
238
|
+
if (!request)
|
|
239
|
+
importWarnings.push(`${method} Request at ${path} is invalid.`);
|
|
240
|
+
else
|
|
241
|
+
requests.push(request);
|
|
235
242
|
});
|
|
236
243
|
});
|
|
237
244
|
// ---------------------------------------------------------------------------
|
|
@@ -283,7 +290,7 @@ async function importSpecToWorkspace(spec, { authentication, baseServerURL, docu
|
|
|
283
290
|
});
|
|
284
291
|
// ---------------------------------------------------------------------------
|
|
285
292
|
// Generate Collection
|
|
286
|
-
const securityKeys = Object.keys(security);
|
|
293
|
+
const securityKeys = Object.keys(schema.security?.[0] ?? security ?? {});
|
|
287
294
|
let selectedSecuritySchemeUids = [];
|
|
288
295
|
/** Selected security scheme UIDs for the collection, defaults to the first key */
|
|
289
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",
|
|
@@ -112,8 +117,8 @@
|
|
|
112
117
|
"yaml": "^2.4.5",
|
|
113
118
|
"zod": "^3.23.8",
|
|
114
119
|
"@scalar/object-utils": "1.1.12",
|
|
115
|
-
"@scalar/themes": "0.9.54",
|
|
116
120
|
"@scalar/openapi-types": "0.1.5",
|
|
121
|
+
"@scalar/themes": "0.9.54",
|
|
117
122
|
"@scalar/types": "0.0.23"
|
|
118
123
|
},
|
|
119
124
|
"devDependencies": {
|
|
@@ -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 };
|