@scalar/oas-utils 0.2.58 → 0.2.59
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 +8 -0
- package/dist/diff/diff.js +40 -0
- package/dist/diff/index.d.ts +1 -0
- package/dist/diff/index.d.ts.map +1 -1
- package/dist/diff/index.js +1 -1
- package/dist/entities/spec/collection.d.ts +40 -0
- package/dist/entities/spec/collection.d.ts.map +1 -1
- package/dist/entities/spec/collection.js +17 -0
- package/dist/entities/spec/index.js +1 -1
- package/dist/entities/spec/security.d.ts +118 -0
- package/dist/entities/spec/security.d.ts.map +1 -1
- package/dist/entities/spec/security.js +1 -1
- package/dist/entities/spec/server.d.ts +4 -4
- package/dist/entities/spec/server.js +1 -1
- package/dist/helpers/fetchSpecFromUrl.d.ts +1 -1
- package/dist/helpers/fetchSpecFromUrl.d.ts.map +1 -1
- package/dist/helpers/fetchSpecFromUrl.js +5 -2
- package/dist/migrations/v-2.1.0/migration.d.ts +2 -0
- package/dist/migrations/v-2.1.0/migration.d.ts.map +1 -1
- package/dist/migrations/v-2.1.0/migration.js +2 -0
- package/dist/transforms/export-spec.d.ts +3 -0
- package/dist/transforms/export-spec.d.ts.map +1 -1
- package/dist/transforms/import-spec.d.ts +9 -2
- package/dist/transforms/import-spec.d.ts.map +1 -1
- package/dist/transforms/import-spec.js +13 -6
- package/dist/transforms/index.js +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import microdiff from 'microdiff';
|
|
2
|
+
|
|
3
|
+
const types = {
|
|
4
|
+
CREATE: 'add',
|
|
5
|
+
REMOVE: 'remove',
|
|
6
|
+
CHANGE: 'modify',
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Compare two specs and return the changes for each request entry
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
function diffSpec(a, b) {
|
|
13
|
+
const diff = microdiff(a, b);
|
|
14
|
+
const requestChanges = {};
|
|
15
|
+
diff
|
|
16
|
+
.filter((d) => d.path[0] === 'paths')
|
|
17
|
+
.forEach((d) => {
|
|
18
|
+
const key = d.path
|
|
19
|
+
.slice(0, 3)
|
|
20
|
+
.map((p) => String(p).replaceAll('/', '~1'))
|
|
21
|
+
.join('/');
|
|
22
|
+
if (!requestChanges[key])
|
|
23
|
+
requestChanges[key] = {
|
|
24
|
+
type: types[d.type],
|
|
25
|
+
mutations: [],
|
|
26
|
+
};
|
|
27
|
+
if (d.type === 'CHANGE') {
|
|
28
|
+
requestChanges[key].mutations.push({
|
|
29
|
+
...d,
|
|
30
|
+
path: d.path.slice(3),
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
else if (d.type === 'CREATE') {
|
|
34
|
+
requestChanges[key].value = d.value;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
return JSON.stringify(requestChanges, null, 2);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export { diffSpec };
|
package/dist/diff/index.d.ts
CHANGED
package/dist/diff/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/diff/index.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/diff/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA"}
|
package/dist/diff/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export { diffSpec } from './diff.js';
|
|
@@ -98,6 +98,20 @@ export declare const extendedCollectionSchema: z.ZodObject<{
|
|
|
98
98
|
token?: string | undefined;
|
|
99
99
|
clientSecret?: string | undefined;
|
|
100
100
|
}>]>>>;
|
|
101
|
+
/** A link to where this document is stored, useful for live sync and possibly git sync down the line */
|
|
102
|
+
documentUrl: z.ZodOptional<z.ZodString>;
|
|
103
|
+
/**
|
|
104
|
+
* Enables polling of OpenAPI document urls
|
|
105
|
+
*
|
|
106
|
+
* @remarks Only effective when `documentUrl` is set
|
|
107
|
+
*/
|
|
108
|
+
watchForChanges: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
109
|
+
/**
|
|
110
|
+
* Status of the watcher from above
|
|
111
|
+
*
|
|
112
|
+
* @defaults to idle for all collections, doesn't mean that it can watch for changes
|
|
113
|
+
*/
|
|
114
|
+
watchForChangesStatus: z.ZodDefault<z.ZodOptional<z.ZodEnum<["IDLE", "WATCHING", "ERROR"]>>>;
|
|
101
115
|
}, "strip", z.ZodTypeAny, {
|
|
102
116
|
uid: string;
|
|
103
117
|
children: string[];
|
|
@@ -133,6 +147,9 @@ export declare const extendedCollectionSchema: z.ZodObject<{
|
|
|
133
147
|
token: string;
|
|
134
148
|
clientSecret: string;
|
|
135
149
|
}>;
|
|
150
|
+
watchForChanges: boolean;
|
|
151
|
+
watchForChangesStatus: "IDLE" | "WATCHING" | "ERROR";
|
|
152
|
+
documentUrl?: string | undefined;
|
|
136
153
|
}, {
|
|
137
154
|
uid?: string | undefined;
|
|
138
155
|
children?: (string | undefined)[] | undefined;
|
|
@@ -168,6 +185,9 @@ export declare const extendedCollectionSchema: z.ZodObject<{
|
|
|
168
185
|
token?: string | undefined;
|
|
169
186
|
clientSecret?: string | undefined;
|
|
170
187
|
}> | undefined;
|
|
188
|
+
documentUrl?: string | undefined;
|
|
189
|
+
watchForChanges?: boolean | undefined;
|
|
190
|
+
watchForChangesStatus?: "IDLE" | "WATCHING" | "ERROR" | undefined;
|
|
171
191
|
}>;
|
|
172
192
|
export declare const collectionSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
173
193
|
type: z.ZodDefault<z.ZodOptional<z.ZodLiteral<"collection">>>;
|
|
@@ -361,6 +381,20 @@ export declare const collectionSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
361
381
|
token?: string | undefined;
|
|
362
382
|
clientSecret?: string | undefined;
|
|
363
383
|
}>]>>>;
|
|
384
|
+
/** A link to where this document is stored, useful for live sync and possibly git sync down the line */
|
|
385
|
+
documentUrl: z.ZodOptional<z.ZodString>;
|
|
386
|
+
/**
|
|
387
|
+
* Enables polling of OpenAPI document urls
|
|
388
|
+
*
|
|
389
|
+
* @remarks Only effective when `documentUrl` is set
|
|
390
|
+
*/
|
|
391
|
+
watchForChanges: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
392
|
+
/**
|
|
393
|
+
* Status of the watcher from above
|
|
394
|
+
*
|
|
395
|
+
* @defaults to idle for all collections, doesn't mean that it can watch for changes
|
|
396
|
+
*/
|
|
397
|
+
watchForChangesStatus: z.ZodDefault<z.ZodOptional<z.ZodEnum<["IDLE", "WATCHING", "ERROR"]>>>;
|
|
364
398
|
}>, "strip", z.ZodTypeAny, {
|
|
365
399
|
type: "collection";
|
|
366
400
|
uid: string;
|
|
@@ -400,6 +434,8 @@ export declare const collectionSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
400
434
|
token: string;
|
|
401
435
|
clientSecret: string;
|
|
402
436
|
}>;
|
|
437
|
+
watchForChanges: boolean;
|
|
438
|
+
watchForChangesStatus: "IDLE" | "WATCHING" | "ERROR";
|
|
403
439
|
externalDocs?: {
|
|
404
440
|
url: string;
|
|
405
441
|
description?: string | undefined;
|
|
@@ -424,6 +460,7 @@ export declare const collectionSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
424
460
|
} | undefined;
|
|
425
461
|
components?: Record<string, unknown> | undefined;
|
|
426
462
|
webhooks?: Record<string, unknown> | undefined;
|
|
463
|
+
documentUrl?: string | undefined;
|
|
427
464
|
}, {
|
|
428
465
|
type?: "collection" | undefined;
|
|
429
466
|
uid?: string | undefined;
|
|
@@ -487,6 +524,9 @@ export declare const collectionSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
487
524
|
token?: string | undefined;
|
|
488
525
|
clientSecret?: string | undefined;
|
|
489
526
|
}> | undefined;
|
|
527
|
+
documentUrl?: string | undefined;
|
|
528
|
+
watchForChanges?: boolean | undefined;
|
|
529
|
+
watchForChangesStatus?: "IDLE" | "WATCHING" | "ERROR" | undefined;
|
|
490
530
|
}>;
|
|
491
531
|
export type Collection = z.infer<typeof collectionSchema>;
|
|
492
532
|
export type CollectionPayload = z.input<typeof collectionSchema>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/collection.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAyCvB,eAAO,MAAM,wBAAwB;;IAEnC,qEAAqE;;IAErE,oCAAoC;;IAEpC,wDAAwD;;IAExD,gDAAgD;;IAEhD,8CAA8C;;IAE9C,gEAAgE;;IAEhE;;;;;OAKG
|
|
1
|
+
{"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/collection.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAyCvB,eAAO,MAAM,wBAAwB;;IAEnC,qEAAqE;;IAErE,oCAAoC;;IAEpC,wDAAwD;;IAExD,gDAAgD;;IAEhD,8CAA8C;;IAE9C,gEAAgE;;IAEhE;;;;;OAKG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAEH,wGAAwG;;IAExG;;;;OAIG;;IAEH;;;;OAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKH,CAAA;AAEF,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA/D3B;;;;;;OAMG;;;;;;;;;;;;IAGH,uBAAuB;;IAEvB,uBAAuB;;IAEvB,gDAAgD;;;;IAYhD,qEAAqE;;IAErE,oCAAoC;;IAEpC,wDAAwD;;IAExD,gDAAgD;;IAEhD,8CAA8C;;IAE9C,gEAAgE;;IAEhE;;;;;OAKG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAEH,wGAAwG;;IAExG;;;;OAIG;;IAEH;;;;OAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EASJ,CAAA;AACD,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAA;AACzD,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAA"}
|
|
@@ -59,6 +59,23 @@ const extendedCollectionSchema = z.object({
|
|
|
59
59
|
* The entry will contain the secret values (but not the schema definition)
|
|
60
60
|
*/
|
|
61
61
|
auth: z.record(nanoidSchema, securitySchemeExampleValueSchema).default({}),
|
|
62
|
+
/** A link to where this document is stored, useful for live sync and possibly git sync down the line */
|
|
63
|
+
documentUrl: z.string().optional(),
|
|
64
|
+
/**
|
|
65
|
+
* Enables polling of OpenAPI document urls
|
|
66
|
+
*
|
|
67
|
+
* @remarks Only effective when `documentUrl` is set
|
|
68
|
+
*/
|
|
69
|
+
watchForChanges: z.boolean().optional().default(false),
|
|
70
|
+
/**
|
|
71
|
+
* Status of the watcher from above
|
|
72
|
+
*
|
|
73
|
+
* @defaults to idle for all collections, doesn't mean that it can watch for changes
|
|
74
|
+
*/
|
|
75
|
+
watchForChangesStatus: z
|
|
76
|
+
.enum(['IDLE', 'WATCHING', 'ERROR'])
|
|
77
|
+
.optional()
|
|
78
|
+
.default('IDLE'),
|
|
62
79
|
});
|
|
63
80
|
const collectionSchema = oasCollectionSchema.merge(extendedCollectionSchema);
|
|
64
81
|
|
|
@@ -4,4 +4,4 @@ export { oasRequestSchema, requestMethods, requestSchema } from './requests.js';
|
|
|
4
4
|
export { createExampleFromRequest, createParamInstance, exampleRequestBodyEncoding, exampleRequestBodySchema, requestExampleParametersSchema, requestExampleSchema } from './request-examples.js';
|
|
5
5
|
export { oasContactSchema, oasExternalDocumentationSchema, oasInfoSchema, oasLicenseSchema, oasTagSchema, tagSchema, xScalarNestedSchema } from './spec-objects.js';
|
|
6
6
|
export { oasParameterSchema, parameterStyleSchema, parameterTypeSchema } from './parameters.js';
|
|
7
|
-
export { authExampleFromSchema, oasSecurityRequirementSchema, oasSecuritySchemeSchema, securityApiKeySchema, securityHttpSchema, securityOauthSchema, securityOpenIdSchema, securitySchemeApiKeyIn, securitySchemeExampleValueSchema, securitySchemeSchema } from './security.js';
|
|
7
|
+
export { authExampleFromSchema, oasOauthFlowSchema, oasSecurityRequirementSchema, oasSecuritySchemeSchema, securityApiKeySchema, securityHttpSchema, securityOauthSchema, securityOpenIdSchema, securitySchemeApiKeyIn, securitySchemeExampleValueSchema, securitySchemeSchema } from './security.js';
|
|
@@ -210,6 +210,124 @@ export declare const securityOpenIdSchema: z.ZodObject<z.objectUtil.extendShape<
|
|
|
210
210
|
openIdConnectUrl?: string | undefined;
|
|
211
211
|
}>;
|
|
212
212
|
export type SecuritySchemaOpenId = z.infer<typeof securityOpenIdSchema>;
|
|
213
|
+
export declare const oasOauthFlowSchema: z.ZodDefault<z.ZodOptional<z.ZodDiscriminatedUnion<"type", [z.ZodObject<z.objectUtil.extendShape<{
|
|
214
|
+
/**
|
|
215
|
+
* The URL to be used for obtaining refresh tokens. This MUST be in the form of a
|
|
216
|
+
* URL. The OAuth2 standard requires the use of TLS.
|
|
217
|
+
*/
|
|
218
|
+
refreshUrl: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
219
|
+
/**
|
|
220
|
+
* REQUIRED. The available scopes for the OAuth2 security scheme. A map
|
|
221
|
+
* between the scope name and a short description for it. The map MAY be empty.
|
|
222
|
+
*/
|
|
223
|
+
scopes: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodMap<z.ZodString, z.ZodOptional<z.ZodString>>, z.ZodRecord<z.ZodString, z.ZodOptional<z.ZodString>>, z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>]>>>;
|
|
224
|
+
selectedScopes: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
|
|
225
|
+
}, {
|
|
226
|
+
type: z.ZodLiteral<"implicit">;
|
|
227
|
+
authorizationUrl: z.ZodDefault<z.ZodString>;
|
|
228
|
+
'x-scalar-redirect-uri': z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
229
|
+
}>, "strip", z.ZodTypeAny, {
|
|
230
|
+
type: "implicit";
|
|
231
|
+
refreshUrl: string;
|
|
232
|
+
scopes: Map<string, string | undefined> | Record<string, string | undefined> | {};
|
|
233
|
+
selectedScopes: string[];
|
|
234
|
+
authorizationUrl: string;
|
|
235
|
+
'x-scalar-redirect-uri': string;
|
|
236
|
+
}, {
|
|
237
|
+
type: "implicit";
|
|
238
|
+
refreshUrl?: string | undefined;
|
|
239
|
+
scopes?: Map<string, string | undefined> | Record<string, string | undefined> | {} | undefined;
|
|
240
|
+
selectedScopes?: string[] | undefined;
|
|
241
|
+
authorizationUrl?: string | undefined;
|
|
242
|
+
'x-scalar-redirect-uri'?: string | undefined;
|
|
243
|
+
}>, z.ZodObject<z.objectUtil.extendShape<{
|
|
244
|
+
/**
|
|
245
|
+
* The URL to be used for obtaining refresh tokens. This MUST be in the form of a
|
|
246
|
+
* URL. The OAuth2 standard requires the use of TLS.
|
|
247
|
+
*/
|
|
248
|
+
refreshUrl: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
249
|
+
/**
|
|
250
|
+
* REQUIRED. The available scopes for the OAuth2 security scheme. A map
|
|
251
|
+
* between the scope name and a short description for it. The map MAY be empty.
|
|
252
|
+
*/
|
|
253
|
+
scopes: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodMap<z.ZodString, z.ZodOptional<z.ZodString>>, z.ZodRecord<z.ZodString, z.ZodOptional<z.ZodString>>, z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>]>>>;
|
|
254
|
+
selectedScopes: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
|
|
255
|
+
}, {
|
|
256
|
+
type: z.ZodLiteral<"password">;
|
|
257
|
+
tokenUrl: z.ZodDefault<z.ZodString>;
|
|
258
|
+
}>, "strip", z.ZodTypeAny, {
|
|
259
|
+
type: "password";
|
|
260
|
+
refreshUrl: string;
|
|
261
|
+
scopes: Map<string, string | undefined> | Record<string, string | undefined> | {};
|
|
262
|
+
selectedScopes: string[];
|
|
263
|
+
tokenUrl: string;
|
|
264
|
+
}, {
|
|
265
|
+
type: "password";
|
|
266
|
+
refreshUrl?: string | undefined;
|
|
267
|
+
scopes?: Map<string, string | undefined> | Record<string, string | undefined> | {} | undefined;
|
|
268
|
+
selectedScopes?: string[] | undefined;
|
|
269
|
+
tokenUrl?: string | undefined;
|
|
270
|
+
}>, z.ZodObject<z.objectUtil.extendShape<{
|
|
271
|
+
/**
|
|
272
|
+
* The URL to be used for obtaining refresh tokens. This MUST be in the form of a
|
|
273
|
+
* URL. The OAuth2 standard requires the use of TLS.
|
|
274
|
+
*/
|
|
275
|
+
refreshUrl: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
276
|
+
/**
|
|
277
|
+
* REQUIRED. The available scopes for the OAuth2 security scheme. A map
|
|
278
|
+
* between the scope name and a short description for it. The map MAY be empty.
|
|
279
|
+
*/
|
|
280
|
+
scopes: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodMap<z.ZodString, z.ZodOptional<z.ZodString>>, z.ZodRecord<z.ZodString, z.ZodOptional<z.ZodString>>, z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>]>>>;
|
|
281
|
+
selectedScopes: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
|
|
282
|
+
}, {
|
|
283
|
+
type: z.ZodLiteral<"clientCredentials">;
|
|
284
|
+
tokenUrl: z.ZodDefault<z.ZodString>;
|
|
285
|
+
}>, "strip", z.ZodTypeAny, {
|
|
286
|
+
type: "clientCredentials";
|
|
287
|
+
refreshUrl: string;
|
|
288
|
+
scopes: Map<string, string | undefined> | Record<string, string | undefined> | {};
|
|
289
|
+
selectedScopes: string[];
|
|
290
|
+
tokenUrl: string;
|
|
291
|
+
}, {
|
|
292
|
+
type: "clientCredentials";
|
|
293
|
+
refreshUrl?: string | undefined;
|
|
294
|
+
scopes?: Map<string, string | undefined> | Record<string, string | undefined> | {} | undefined;
|
|
295
|
+
selectedScopes?: string[] | undefined;
|
|
296
|
+
tokenUrl?: string | undefined;
|
|
297
|
+
}>, z.ZodObject<z.objectUtil.extendShape<{
|
|
298
|
+
/**
|
|
299
|
+
* The URL to be used for obtaining refresh tokens. This MUST be in the form of a
|
|
300
|
+
* URL. The OAuth2 standard requires the use of TLS.
|
|
301
|
+
*/
|
|
302
|
+
refreshUrl: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
303
|
+
/**
|
|
304
|
+
* REQUIRED. The available scopes for the OAuth2 security scheme. A map
|
|
305
|
+
* between the scope name and a short description for it. The map MAY be empty.
|
|
306
|
+
*/
|
|
307
|
+
scopes: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodMap<z.ZodString, z.ZodOptional<z.ZodString>>, z.ZodRecord<z.ZodString, z.ZodOptional<z.ZodString>>, z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>]>>>;
|
|
308
|
+
selectedScopes: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
|
|
309
|
+
}, {
|
|
310
|
+
type: z.ZodLiteral<"authorizationCode">;
|
|
311
|
+
authorizationUrl: z.ZodDefault<z.ZodString>;
|
|
312
|
+
'x-scalar-redirect-uri': z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
313
|
+
tokenUrl: z.ZodDefault<z.ZodString>;
|
|
314
|
+
}>, "strip", z.ZodTypeAny, {
|
|
315
|
+
type: "authorizationCode";
|
|
316
|
+
refreshUrl: string;
|
|
317
|
+
scopes: Map<string, string | undefined> | Record<string, string | undefined> | {};
|
|
318
|
+
selectedScopes: string[];
|
|
319
|
+
authorizationUrl: string;
|
|
320
|
+
'x-scalar-redirect-uri': string;
|
|
321
|
+
tokenUrl: string;
|
|
322
|
+
}, {
|
|
323
|
+
type: "authorizationCode";
|
|
324
|
+
refreshUrl?: string | undefined;
|
|
325
|
+
scopes?: Map<string, string | undefined> | Record<string, string | undefined> | {} | undefined;
|
|
326
|
+
selectedScopes?: string[] | undefined;
|
|
327
|
+
authorizationUrl?: string | undefined;
|
|
328
|
+
'x-scalar-redirect-uri'?: string | undefined;
|
|
329
|
+
tokenUrl?: string | undefined;
|
|
330
|
+
}>]>>>;
|
|
213
331
|
export declare const securityOauthSchema: z.ZodObject<z.objectUtil.extendShape<z.objectUtil.extendShape<{
|
|
214
332
|
description: z.ZodOptional<z.ZodString>;
|
|
215
333
|
}, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"security.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/security.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AA6CvB;;;GAGG;AACH,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAO3C,CAAA;AAEF,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAC9C,OAAO,gCAAgC,CACxC,CAAA;AAED,gDAAgD;AAChD,MAAM,MAAM,gCAAgC,GAAG,OAAO,CACpD,0BAA0B,EAC1B;IAAE,IAAI,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAC5B,CAAA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WAGG;;;;;;;;;;;;;;;;;;;QARH;;;WAGG;;QAEH;;;WAGG;;;;;;;;;;;;;;;;;;;;;;;;;IA6CH,oEAAoE;;;;IA1IpE,0EAA0E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAoL1E,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"}
|
|
@@ -224,4 +224,4 @@ const securitySchemeSchema = z.union([
|
|
|
224
224
|
securityOauthSchema,
|
|
225
225
|
]);
|
|
226
226
|
|
|
227
|
-
export { authExampleFromSchema, oasSecurityRequirementSchema, oasSecuritySchemeSchema, securityApiKeySchema, securityHttpSchema, securityOauthSchema, securityOpenIdSchema, securitySchemeApiKeyIn, securitySchemeExampleValueSchema, securitySchemeSchema };
|
|
227
|
+
export { authExampleFromSchema, oasOauthFlowSchema, oasSecurityRequirementSchema, oasSecuritySchemeSchema, securityApiKeySchema, securityHttpSchema, securityOauthSchema, securityOpenIdSchema, securitySchemeApiKeyIn, securitySchemeExampleValueSchema, securitySchemeSchema };
|
|
@@ -17,7 +17,7 @@ export declare const oasServerSchema: z.ZodObject<{
|
|
|
17
17
|
* the host location is relative to the location where the OpenAPI document is being served. Variable substitutions
|
|
18
18
|
* will be made when a variable is named in {brackets}.
|
|
19
19
|
*/
|
|
20
|
-
url: z.ZodOptional<z.ZodString
|
|
20
|
+
url: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
21
21
|
/**
|
|
22
22
|
* An optional string describing the host designated by the URL. CommonMark syntax MAY be used for rich text
|
|
23
23
|
* representation.
|
|
@@ -30,8 +30,8 @@ export declare const oasServerSchema: z.ZodObject<{
|
|
|
30
30
|
enum?: [string, ...string[]];
|
|
31
31
|
}>>>;
|
|
32
32
|
}, "strip", z.ZodTypeAny, {
|
|
33
|
+
url: string;
|
|
33
34
|
description?: string | undefined;
|
|
34
|
-
url?: string | undefined;
|
|
35
35
|
variables?: Record<string, Omit<OpenAPIV3_1.ServerVariableObject, "enum"> & {
|
|
36
36
|
enum?: [string, ...string[]];
|
|
37
37
|
}> | undefined;
|
|
@@ -48,7 +48,7 @@ export declare const serverSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
48
48
|
* the host location is relative to the location where the OpenAPI document is being served. Variable substitutions
|
|
49
49
|
* will be made when a variable is named in {brackets}.
|
|
50
50
|
*/
|
|
51
|
-
url: z.ZodOptional<z.ZodString
|
|
51
|
+
url: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
52
52
|
/**
|
|
53
53
|
* An optional string describing the host designated by the URL. CommonMark syntax MAY be used for rich text
|
|
54
54
|
* representation.
|
|
@@ -64,8 +64,8 @@ export declare const serverSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
64
64
|
uid: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
65
65
|
}>, "strip", z.ZodTypeAny, {
|
|
66
66
|
uid: string;
|
|
67
|
+
url: string;
|
|
67
68
|
description?: string | undefined;
|
|
68
|
-
url?: string | undefined;
|
|
69
69
|
variables?: Record<string, Omit<OpenAPIV3_1.ServerVariableObject, "enum"> & {
|
|
70
70
|
enum?: [string, ...string[]];
|
|
71
71
|
}> | undefined;
|
|
@@ -30,7 +30,7 @@ const oasServerSchema = z.object({
|
|
|
30
30
|
* the host location is relative to the location where the OpenAPI document is being served. Variable substitutions
|
|
31
31
|
* will be made when a variable is named in {brackets}.
|
|
32
32
|
*/
|
|
33
|
-
url: z.string().optional(),
|
|
33
|
+
url: z.string().optional().default(''),
|
|
34
34
|
/**
|
|
35
35
|
* An optional string describing the host designated by the URL. CommonMark syntax MAY be used for rich text
|
|
36
36
|
* representation.
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @throws an error if the fetch fails
|
|
5
5
|
*/
|
|
6
|
-
export declare function fetchSpecFromUrl(url: string, proxy?: string): Promise<string>;
|
|
6
|
+
export declare function fetchSpecFromUrl(url: string, proxy?: string, beautify?: boolean): Promise<string>;
|
|
7
7
|
//# sourceMappingURL=fetchSpecFromUrl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchSpecFromUrl.d.ts","sourceRoot":"","sources":["../../src/helpers/fetchSpecFromUrl.ts"],"names":[],"mappings":"AASA;;;;GAIG;AACH,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,MAAM,EACX,KAAK,CAAC,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"fetchSpecFromUrl.d.ts","sourceRoot":"","sources":["../../src/helpers/fetchSpecFromUrl.ts"],"names":[],"mappings":"AASA;;;;GAIG;AACH,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,MAAM,EACX,KAAK,CAAC,EAAE,MAAM,EACd,QAAQ,UAAO,GACd,OAAO,CAAC,MAAM,CAAC,CA8BjB"}
|
|
@@ -10,7 +10,7 @@ const NEW_PROXY_URL = 'https://proxy.scalar.com';
|
|
|
10
10
|
*
|
|
11
11
|
* @throws an error if the fetch fails
|
|
12
12
|
*/
|
|
13
|
-
async function fetchSpecFromUrl(url, proxy) {
|
|
13
|
+
async function fetchSpecFromUrl(url, proxy, beautify = true) {
|
|
14
14
|
// This replaces the OLD_PROXY_URL with the NEW_PROXY_URL on the fly.
|
|
15
15
|
if (proxy === OLD_PROXY_URL) {
|
|
16
16
|
// eslint-disable-next-line no-param-reassign
|
|
@@ -27,7 +27,10 @@ async function fetchSpecFromUrl(url, proxy) {
|
|
|
27
27
|
throw new Error(`Failed to fetch the specification (Status: ${response.status})`);
|
|
28
28
|
}
|
|
29
29
|
// If it’s JSON, make it pretty
|
|
30
|
-
|
|
30
|
+
if (beautify)
|
|
31
|
+
return formatJsonOrYamlString(await response.text());
|
|
32
|
+
else
|
|
33
|
+
return await response.text();
|
|
31
34
|
}
|
|
32
35
|
|
|
33
36
|
export { fetchSpecFromUrl };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration.d.ts","sourceRoot":"","sources":["../../../src/migrations/v-2.1.0/migration.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sCAAsC,CAAA;AAInE,mCAAmC;AACnC,eAAO,MAAM,eAAe,SAAU,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC;;;;;;;;;;oBAG/C,CAAC;mBAIjB,CADJ;qBAA4C,CAAC;;;;0BAKlC,CAAC;mBACR,CAAA
|
|
1
|
+
{"version":3,"file":"migration.d.ts","sourceRoot":"","sources":["../../../src/migrations/v-2.1.0/migration.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sCAAsC,CAAA;AAInE,mCAAmC;AACnC,eAAO,MAAM,eAAe,SAAU,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC;;;;;;;;;;oBAG/C,CAAC;mBAIjB,CADJ;qBAA4C,CAAC;;;;0BAKlC,CAAC;mBACR,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAiDsD,CAAC;;;;oBASlD,CAAC;;;;;;wBAIF,CAAR;;;;;;sCAM2B,GAAG;oHAMoB,GAAsB;iCAGhE,GAAC;+BACS,GAAG;;+BAKb,CAAC;0BAED,CAAC;4BAIY,CAAA;wBAAoC,CAAC;wBAAqC,CAAC;0BACpF,CAAC;2BAAsC,CAAC;2BAGvC,CAAC;2BAAsC,CAAC;4BACxC,CAAC;;;kBACR,CAAD;;;;;;;;oBAQD,CAAC;2BAAqC,CAAC;sBAElB,CAAC;wBACA,CAAC;oBAAkC,CAAC;oBAG1D,CAAF;sBAAmC,CAAC;uBAE5B,CAAC;uBAAoC,CAAC;uBAChB,CAAC;wBACtB,CAAC;;;;;;oBAOS,CAAC;2BACR,CAAC;sBAAmC,CAAC;wBACtC,CAAC;oBACR,CAAC;oBAAmC,CAAC;sBAE7B,CAAC;uBACa,CAAC;uBAAoC,CAAC;uBAC7C,CAAC;wBACT,CAAC;;;;;;oBAIe,CAAC;2BACd,CAAC;sBACG,CAAC;wBACF,CAAC;oBAIlB,CAAD;oBACG,CAAA;sBACQ,CAAC;uBAGX,CAAF;uBAAoC,CAAC;uBACjC,CAAA;wBAGI,CAAH;;;;;;oBAKyC,CAAC;2BAChC,CAAA;sBACS,CAAC;wBACnB,CAAC;oBAAmC,CAAA;oBACf,CAAC;sBAChB,CAAC;uBAAoC,CAAC;uBACjB,CAAC;uBACjB,CAAC;wBAEU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBAWvB,CAAD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAyI4f,CAAC;;6BAA4E,CAAC;;;;;;;;;;CAD9kB,CAAA"}
|
|
@@ -41,6 +41,8 @@ export declare function exportSpecFromWorkspace({ collection, requests, }: {
|
|
|
41
41
|
token: string;
|
|
42
42
|
clientSecret: string;
|
|
43
43
|
}>;
|
|
44
|
+
watchForChanges: boolean;
|
|
45
|
+
watchForChangesStatus: "IDLE" | "WATCHING" | "ERROR";
|
|
44
46
|
externalDocs?: {
|
|
45
47
|
url: string;
|
|
46
48
|
description?: string | undefined;
|
|
@@ -65,5 +67,6 @@ export declare function exportSpecFromWorkspace({ collection, requests, }: {
|
|
|
65
67
|
} | undefined;
|
|
66
68
|
components?: Record<string, unknown> | undefined;
|
|
67
69
|
webhooks?: Record<string, unknown> | undefined;
|
|
70
|
+
documentUrl?: string | undefined;
|
|
68
71
|
};
|
|
69
72
|
//# sourceMappingURL=export-spec.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export-spec.d.ts","sourceRoot":"","sources":["../../src/transforms/export-spec.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,UAAU,EACf,KAAK,OAAO,EAEb,MAAM,iBAAiB,CAAA;AAMxB,wBAAgB,uBAAuB,CAAC,EACtC,UAAU,EACV,QAAQ,GACT,EAAE;IACD,UAAU,EAAE,UAAU,CAAA;IACtB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAClC
|
|
1
|
+
{"version":3,"file":"export-spec.d.ts","sourceRoot":"","sources":["../../src/transforms/export-spec.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,UAAU,EACf,KAAK,OAAO,EAEb,MAAM,iBAAiB,CAAA;AAMxB,wBAAgB,uBAAuB,CAAC,EACtC,UAAU,EACV,QAAQ,GACT,EAAE;IACD,UAAU,EAAE,UAAU,CAAA;IACtB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAClC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAEA"}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
import { type Collection, type Request, type RequestExample, type Server, type Tag } from '../entities/spec/index.js';
|
|
1
|
+
import { type Collection, type CollectionPayload, type Request, type RequestExample, type Server, type Tag } from '../entities/spec/index.js';
|
|
2
2
|
import { type SecurityScheme } from '../entities/spec/security.js';
|
|
3
|
+
import type { OpenAPIV3, OpenAPIV3_1 } from '@scalar/openapi-types';
|
|
3
4
|
import type { AuthenticationState } from '@scalar/types/legacy';
|
|
4
5
|
import type { UnknownObject } from '@scalar/types/utils';
|
|
6
|
+
/** Takes a string or object and parses it into an openapi spec compliant schema */
|
|
7
|
+
export declare const parseSchema: (spec: string | UnknownObject) => Promise<{
|
|
8
|
+
schema: OpenAPIV3.Document | OpenAPIV3_1.Document;
|
|
9
|
+
errors: import("@scalar/openapi-parser").ErrorObject[];
|
|
10
|
+
}>;
|
|
5
11
|
/**
|
|
6
12
|
* Import an OpenAPI spec file and convert it to workspace entities
|
|
7
13
|
*
|
|
@@ -10,10 +16,11 @@ import type { UnknownObject } from '@scalar/types/utils';
|
|
|
10
16
|
* created and used at various levels we will index via the uids to create
|
|
11
17
|
* the relationships
|
|
12
18
|
*/
|
|
13
|
-
export declare function importSpecToWorkspace(spec: string | UnknownObject, preferredSecurityScheme?: AuthenticationState
|
|
19
|
+
export declare function importSpecToWorkspace(spec: string | UnknownObject, { documentUrl, watchForChanges, preferredSecurityScheme, }?: Pick<CollectionPayload, 'documentUrl' | 'watchForChanges'> & Pick<Partial<AuthenticationState>, 'preferredSecurityScheme'>): Promise<{
|
|
14
20
|
error: false;
|
|
15
21
|
collection: Collection;
|
|
16
22
|
requests: Request[];
|
|
23
|
+
schema: OpenAPIV3.Document | OpenAPIV3_1.Document;
|
|
17
24
|
examples: RequestExample[];
|
|
18
25
|
servers: Server[];
|
|
19
26
|
tags: Tag[];
|
|
@@ -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,OAAO,EACZ,KAAK,cAAc,EAGnB,KAAK,MAAM,EACX,KAAK,GAAG,EAOT,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,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,EAOT,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,KAAK,cAAc,EAGpB,MAAM,0BAA0B,CAAA;AAIjC,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACnE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAiCxD,mFAAmF;AACnF,eAAO,MAAM,WAAW,SAAgB,MAAM,GAAG,aAAa;YAKjC,SAAS,CAAC,QAAQ,GAAG,WAAW,CAAC,QAAQ;;EACrE,CAAA;AAED;;;;;;;GAOG;AACH,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,MAAM,GAAG,aAAa,EAC5B,EACE,WAAW,EACX,eAAe,EACf,uBAAuB,GACxB,GAAE,IAAI,CAAC,iBAAiB,EAAE,aAAa,GAAG,iBAAiB,CAAC,GAC3D,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,EAAE,yBAAyB,CAAM,GACnE,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,CAiQA"}
|
|
@@ -32,6 +32,13 @@ const convertOauth2Flows = (security, nameKey) => {
|
|
|
32
32
|
nameKey,
|
|
33
33
|
};
|
|
34
34
|
};
|
|
35
|
+
/** Takes a string or object and parses it into an openapi spec compliant schema */
|
|
36
|
+
const parseSchema = async (spec) => {
|
|
37
|
+
const { filesystem } = await load(spec);
|
|
38
|
+
const { specification } = upgrade(filesystem);
|
|
39
|
+
const { schema, errors = [] } = await dereference(specification);
|
|
40
|
+
return { schema: schema, errors };
|
|
41
|
+
};
|
|
35
42
|
/**
|
|
36
43
|
* Import an OpenAPI spec file and convert it to workspace entities
|
|
37
44
|
*
|
|
@@ -40,11 +47,8 @@ const convertOauth2Flows = (security, nameKey) => {
|
|
|
40
47
|
* created and used at various levels we will index via the uids to create
|
|
41
48
|
* the relationships
|
|
42
49
|
*/
|
|
43
|
-
async function importSpecToWorkspace(spec, preferredSecurityScheme) {
|
|
44
|
-
const {
|
|
45
|
-
const { specification } = upgrade(filesystem);
|
|
46
|
-
const { schema: _schema, errors = [] } = await dereference(specification);
|
|
47
|
-
const schema = _schema;
|
|
50
|
+
async function importSpecToWorkspace(spec, { documentUrl, watchForChanges, preferredSecurityScheme, } = {}) {
|
|
51
|
+
const { schema, errors } = await parseSchema(spec);
|
|
48
52
|
const importWarnings = [...errors.map((e) => e.message)];
|
|
49
53
|
if (!schema)
|
|
50
54
|
return { importWarnings, error: true };
|
|
@@ -222,6 +226,8 @@ async function importSpecToWorkspace(spec, preferredSecurityScheme) {
|
|
|
222
226
|
}, {});
|
|
223
227
|
const collection = collectionSchema.parse({
|
|
224
228
|
...schema,
|
|
229
|
+
watchForChanges,
|
|
230
|
+
documentUrl,
|
|
225
231
|
auth,
|
|
226
232
|
requests: requests.map((r) => r.uid),
|
|
227
233
|
servers: servers.map((s) => s.uid),
|
|
@@ -241,6 +247,7 @@ async function importSpecToWorkspace(spec, preferredSecurityScheme) {
|
|
|
241
247
|
return {
|
|
242
248
|
error: false,
|
|
243
249
|
servers,
|
|
250
|
+
schema,
|
|
244
251
|
requests,
|
|
245
252
|
examples,
|
|
246
253
|
collection,
|
|
@@ -249,4 +256,4 @@ async function importSpecToWorkspace(spec, preferredSecurityScheme) {
|
|
|
249
256
|
};
|
|
250
257
|
}
|
|
251
258
|
|
|
252
|
-
export { importSpecToWorkspace };
|
|
259
|
+
export { importSpecToWorkspace, parseSchema };
|
package/dist/transforms/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { importSpecToWorkspace } from './import-spec.js';
|
|
1
|
+
export { importSpecToWorkspace, parseSchema } from './import-spec.js';
|
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"specification",
|
|
17
17
|
"yaml"
|
|
18
18
|
],
|
|
19
|
-
"version": "0.2.
|
|
19
|
+
"version": "0.2.59",
|
|
20
20
|
"engines": {
|
|
21
21
|
"node": ">=18"
|
|
22
22
|
},
|
|
@@ -106,9 +106,9 @@
|
|
|
106
106
|
"nanoid": "^5.0.7",
|
|
107
107
|
"yaml": "^2.4.5",
|
|
108
108
|
"zod": "^3.23.8",
|
|
109
|
-
"@scalar/object-utils": "1.1.10",
|
|
110
|
-
"@scalar/themes": "0.9.39",
|
|
111
109
|
"@scalar/openapi-types": "0.1.3",
|
|
110
|
+
"@scalar/object-utils": "1.1.10",
|
|
111
|
+
"@scalar/themes": "0.9.40",
|
|
112
112
|
"@scalar/types": "0.0.16"
|
|
113
113
|
},
|
|
114
114
|
"devDependencies": {
|
|
@@ -118,8 +118,8 @@
|
|
|
118
118
|
"vitest": "^1.6.0",
|
|
119
119
|
"zod-to-ts": "^1.2.0",
|
|
120
120
|
"@scalar/build-tooling": "0.1.11",
|
|
121
|
-
"@scalar/openapi-
|
|
122
|
-
"@scalar/openapi-
|
|
121
|
+
"@scalar/openapi-types": "0.1.3",
|
|
122
|
+
"@scalar/openapi-parser": "0.8.7"
|
|
123
123
|
},
|
|
124
124
|
"scripts": {
|
|
125
125
|
"build": "scalar-build-rollup",
|