@scalar/oas-utils 0.11.1 → 0.12.0

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.
Files changed (126) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/helpers/index.d.ts +0 -82
  3. package/dist/helpers/index.d.ts.map +1 -1
  4. package/dist/helpers/index.js +0 -78
  5. package/dist/migrations/migrate-to-indexdb.d.ts.map +1 -1
  6. package/dist/migrations/migrate-to-indexdb.js +1 -1
  7. package/dist/migrations/v-2.5.0/types.generated.d.ts +428 -34
  8. package/dist/migrations/v-2.5.0/types.generated.d.ts.map +1 -1
  9. package/package.json +7 -61
  10. package/dist/entities/cookie/cookie.d.ts +0 -15
  11. package/dist/entities/cookie/cookie.d.ts.map +0 -1
  12. package/dist/entities/cookie/cookie.js +0 -12
  13. package/dist/entities/cookie/index.d.ts +0 -2
  14. package/dist/entities/cookie/index.d.ts.map +0 -1
  15. package/dist/entities/cookie/index.js +0 -1
  16. package/dist/entities/environment/environment.d.ts +0 -12
  17. package/dist/entities/environment/environment.d.ts.map +0 -1
  18. package/dist/entities/environment/environment.js +0 -8
  19. package/dist/entities/environment/index.d.ts +0 -2
  20. package/dist/entities/environment/index.d.ts.map +0 -1
  21. package/dist/entities/environment/index.js +0 -1
  22. package/dist/entities/hotkeys/hotkeys.d.ts +0 -15
  23. package/dist/entities/hotkeys/hotkeys.d.ts.map +0 -1
  24. package/dist/entities/hotkeys/hotkeys.js +0 -118
  25. package/dist/entities/hotkeys/index.d.ts +0 -2
  26. package/dist/entities/hotkeys/index.d.ts.map +0 -1
  27. package/dist/entities/hotkeys/index.js +0 -1
  28. package/dist/entities/shared/index.d.ts +0 -2
  29. package/dist/entities/shared/index.d.ts.map +0 -1
  30. package/dist/entities/shared/index.js +0 -1
  31. package/dist/entities/shared/utility.d.ts +0 -5
  32. package/dist/entities/shared/utility.d.ts.map +0 -1
  33. package/dist/entities/shared/utility.js +0 -9
  34. package/dist/entities/spec/collection.d.ts +0 -133
  35. package/dist/entities/spec/collection.d.ts.map +0 -1
  36. package/dist/entities/spec/collection.js +0 -95
  37. package/dist/entities/spec/index.d.ts +0 -12
  38. package/dist/entities/spec/index.d.ts.map +0 -1
  39. package/dist/entities/spec/index.js +0 -10
  40. package/dist/entities/spec/operation.d.ts +0 -99
  41. package/dist/entities/spec/operation.d.ts.map +0 -1
  42. package/dist/entities/spec/operation.js +0 -6
  43. package/dist/entities/spec/parameters.d.ts +0 -44
  44. package/dist/entities/spec/parameters.d.ts.map +0 -1
  45. package/dist/entities/spec/parameters.js +0 -41
  46. package/dist/entities/spec/request-examples.d.ts +0 -380
  47. package/dist/entities/spec/request-examples.d.ts.map +0 -1
  48. package/dist/entities/spec/request-examples.js +0 -449
  49. package/dist/entities/spec/requests.d.ts +0 -137
  50. package/dist/entities/spec/requests.d.ts.map +0 -1
  51. package/dist/entities/spec/requests.js +0 -123
  52. package/dist/entities/spec/server.d.ts +0 -15
  53. package/dist/entities/spec/server.d.ts.map +0 -1
  54. package/dist/entities/spec/server.js +0 -67
  55. package/dist/entities/spec/spec-objects.d.ts +0 -171
  56. package/dist/entities/spec/spec-objects.d.ts.map +0 -1
  57. package/dist/entities/spec/spec-objects.js +0 -134
  58. package/dist/entities/spec/x-scalar-environments.d.ts +0 -22
  59. package/dist/entities/spec/x-scalar-environments.d.ts.map +0 -1
  60. package/dist/entities/spec/x-scalar-environments.js +0 -22
  61. package/dist/entities/spec/x-scalar-secrets.d.ts +0 -6
  62. package/dist/entities/spec/x-scalar-secrets.d.ts.map +0 -1
  63. package/dist/entities/spec/x-scalar-secrets.js +0 -8
  64. package/dist/entities/workspace/index.d.ts +0 -2
  65. package/dist/entities/workspace/index.d.ts.map +0 -1
  66. package/dist/entities/workspace/index.js +0 -1
  67. package/dist/entities/workspace/workspace.d.ts +0 -236
  68. package/dist/entities/workspace/workspace.d.ts.map +0 -1
  69. package/dist/entities/workspace/workspace.js +0 -49
  70. package/dist/helpers/fetch-document.d.ts +0 -7
  71. package/dist/helpers/fetch-document.d.ts.map +0 -1
  72. package/dist/helpers/fetch-document.js +0 -32
  73. package/dist/helpers/fetch-with-proxy-fallback.d.ts +0 -15
  74. package/dist/helpers/fetch-with-proxy-fallback.d.ts.map +0 -1
  75. package/dist/helpers/fetch-with-proxy-fallback.js +0 -29
  76. package/dist/helpers/normalize-mime-type-object.d.ts +0 -8
  77. package/dist/helpers/normalize-mime-type-object.d.ts.map +0 -1
  78. package/dist/helpers/normalize-mime-type-object.js +0 -21
  79. package/dist/helpers/normalize-mime-type.d.ts +0 -10
  80. package/dist/helpers/normalize-mime-type.d.ts.map +0 -1
  81. package/dist/helpers/normalize-mime-type.js +0 -12
  82. package/dist/helpers/operation-stability.d.ts +0 -19
  83. package/dist/helpers/operation-stability.d.ts.map +0 -1
  84. package/dist/helpers/operation-stability.js +0 -24
  85. package/dist/helpers/schema-model.d.ts +0 -5
  86. package/dist/helpers/schema-model.d.ts.map +0 -1
  87. package/dist/helpers/schema-model.js +0 -14
  88. package/dist/helpers/security/get-schemes.d.ts +0 -97
  89. package/dist/helpers/security/get-schemes.d.ts.map +0 -1
  90. package/dist/helpers/security/get-schemes.js +0 -8
  91. package/dist/helpers/security/has-token.d.ts +0 -4
  92. package/dist/helpers/security/has-token.d.ts.map +0 -1
  93. package/dist/helpers/security/has-token.js +0 -19
  94. package/dist/helpers/security/index.d.ts +0 -3
  95. package/dist/helpers/security/index.d.ts.map +0 -1
  96. package/dist/helpers/security/index.js +0 -2
  97. package/dist/helpers/servers.d.ts +0 -24
  98. package/dist/helpers/servers.d.ts.map +0 -1
  99. package/dist/helpers/servers.js +0 -146
  100. package/dist/helpers/should-ignore-entity.d.ts +0 -8
  101. package/dist/helpers/should-ignore-entity.d.ts.map +0 -1
  102. package/dist/helpers/should-ignore-entity.js +0 -4
  103. package/dist/migrations/generate-types.d.ts +0 -2
  104. package/dist/migrations/generate-types.d.ts.map +0 -1
  105. package/dist/migrations/generate-types.js +0 -53
  106. package/dist/spec-getters/get-example-from-schema.d.ts +0 -36
  107. package/dist/spec-getters/get-example-from-schema.d.ts.map +0 -1
  108. package/dist/spec-getters/get-example-from-schema.js +0 -521
  109. package/dist/spec-getters/get-parameters-from-operation.d.ts +0 -17
  110. package/dist/spec-getters/get-parameters-from-operation.d.ts.map +0 -1
  111. package/dist/spec-getters/get-parameters-from-operation.js +0 -40
  112. package/dist/spec-getters/get-request-body-from-operation.d.ts +0 -14
  113. package/dist/spec-getters/get-request-body-from-operation.d.ts.map +0 -1
  114. package/dist/spec-getters/get-request-body-from-operation.js +0 -176
  115. package/dist/spec-getters/get-server-variable-examples.d.ts +0 -4
  116. package/dist/spec-getters/get-server-variable-examples.d.ts.map +0 -1
  117. package/dist/spec-getters/get-server-variable-examples.js +0 -12
  118. package/dist/spec-getters/index.d.ts +0 -5
  119. package/dist/spec-getters/index.d.ts.map +0 -1
  120. package/dist/spec-getters/index.js +0 -4
  121. package/dist/transforms/import-spec.d.ts +0 -64
  122. package/dist/transforms/import-spec.d.ts.map +0 -1
  123. package/dist/transforms/import-spec.js +0 -397
  124. package/dist/transforms/index.d.ts +0 -2
  125. package/dist/transforms/index.d.ts.map +0 -1
  126. package/dist/transforms/index.js +0 -1
@@ -1,397 +0,0 @@
1
- import { isDefined } from '@scalar/helpers/array/is-defined';
2
- import { isHttpMethod } from '@scalar/helpers/http/is-http-method';
3
- import { keysOf } from '@scalar/object-utils/arrays';
4
- import { dereference, load, upgrade } from '@scalar/openapi-parser';
5
- import { securitySchemeSchema, } from '@scalar/types/entities';
6
- import { collectionSchema } from '../entities/spec/collection.js';
7
- import { createExampleFromRequest } from '../entities/spec/request-examples.js';
8
- import { requestSchema } from '../entities/spec/requests.js';
9
- import { serverSchema } from '../entities/spec/server.js';
10
- import { tagSchema } from '../entities/spec/spec-objects.js';
11
- import { schemaModel } from '../helpers/schema-model.js';
12
- import { getServersFromDocument } from '../helpers/servers.js';
13
- const dereferenceDocument = async (document, { shouldLoad = true } = {}) => {
14
- if (document === null || (typeof document === 'string' && document.trim() === '')) {
15
- console.warn('[@scalar/oas-utils] Empty OpenAPI document provided.');
16
- return {
17
- schema: {},
18
- errors: [],
19
- };
20
- }
21
- let filesystem = document;
22
- let loadErrors = [];
23
- if (shouldLoad) {
24
- // TODO: Plugins for URLs and files with the proxy are missing here.
25
- // @see packages/api-reference/src/helpers/parse.ts
26
- const response = await load(document).catch((e) => ({
27
- errors: [
28
- {
29
- code: e.code,
30
- message: e.message,
31
- },
32
- ],
33
- filesystem: [],
34
- }));
35
- filesystem = response.filesystem;
36
- loadErrors = response.errors ?? [];
37
- }
38
- const { specification } = upgrade(filesystem);
39
- const { schema, errors: derefErrors = [] } = dereference(specification);
40
- return {
41
- schema,
42
- errors: [...loadErrors, ...derefErrors],
43
- };
44
- };
45
- /** Takes a string or object and parses it into an openapi spec compliant schema */
46
- export const parseSchema = async (originalDocument, { shouldLoad = true,
47
- /** If a dereferenced document is provided, we will skip the dereferencing step. */
48
- dereferencedDocument = undefined, } = {}) => {
49
- // Skip, if a dereferenced document is provided
50
- const { schema, errors } = dereferencedDocument
51
- ? {
52
- schema: dereferencedDocument,
53
- errors: [],
54
- }
55
- : // Otherwise, dereference the original document
56
- await dereferenceDocument(originalDocument ?? '', {
57
- shouldLoad,
58
- });
59
- if (!schema) {
60
- console.warn('[@scalar/oas-utils] OpenAPI Parser Warning: Schema is undefined');
61
- }
62
- return {
63
- /**
64
- * Temporary fix for the parser returning an empty array
65
- * TODO: remove this once the parser is fixed
66
- */
67
- schema: (Array.isArray(schema) ? {} : schema),
68
- errors,
69
- };
70
- };
71
- /** Converts selected security requirements to uids */
72
- export const getSelectedSecuritySchemeUids = (securityRequirements, preferredSecurityNames = [], securitySchemeMap) => {
73
- // Set the first security requirement if no preferred security schemes are set
74
- const names = securityRequirements[0] && !preferredSecurityNames.length ? [securityRequirements[0]] : preferredSecurityNames;
75
- // Map names to uids
76
- const uids = names
77
- .map((name) => Array.isArray(name) ? name.map((k) => securitySchemeMap[k]).filter(isDefined) : securitySchemeMap[name])
78
- .filter(isDefined);
79
- return uids;
80
- };
81
- /** Create a "uid" from a slug */
82
- export const getSlugUid = (slug) => `slug-uid-${slug}`;
83
- /**
84
- * Imports an OpenAPI document and converts it to workspace entities (Collection, Request, Server, etc.)
85
- *
86
- * The imported entities maintain a close mapping to the original OpenAPI specification to enable:
87
- * - Bi-directional translation between spec and workspace entities
88
- * - Preservation of specification details and structure
89
- * - Accurate representation of relationships between components
90
- *
91
- * Relationships between entities are maintained through unique identifiers (UIDs) which allow:
92
- * - Flexible organization at different levels (workspace, collection, request)
93
- * - Proper linking between related components
94
- * - Easy lookup and reference of dependent entities
95
- */
96
- export async function importSpecToWorkspace(content, {
97
- /** If a dereferenced document is provided, we will skip the dereferencing step. */
98
- dereferencedDocument, authentication, baseServerURL, documentUrl, servers: configuredServers, useCollectionSecurity = false, slug, shouldLoad, watchMode = false, } = {}) {
99
- const { schema, errors } = await parseSchema(content, { shouldLoad, dereferencedDocument });
100
- const importWarnings = [...errors.map((e) => e.message)];
101
- if (!schema) {
102
- return { importWarnings, error: true, collection: undefined };
103
- }
104
- // ---------------------------------------------------------------------------
105
- // Some entities will be broken out as individual lists for modification in the workspace
106
- const start = performance.now();
107
- const requests = [];
108
- // Add the base server url to collection servers
109
- const collectionServers = getServersFromDocument(configuredServers || schema.servers, {
110
- baseServerURL,
111
- documentUrl,
112
- });
113
- // Store operation servers
114
- const operationServers = [];
115
- /**
116
- * List of all tag strings. For non compliant specs we may need to
117
- * add top level tag objects for missing tag objects
118
- */
119
- const tagNames = new Set();
120
- // ---------------------------------------------------------------------------
121
- // SECURITY HANDLING
122
- const security = schema.components?.securitySchemes ?? schema?.securityDefinitions ?? {};
123
- // @ts-expect-error - Toss out a deprecated warning for the old authentication state
124
- if (authentication?.oAuth2 || authentication?.apiKey || authentication?.http) {
125
- console.warn(`DEPRECATION WARNING: It looks like you're using legacy authentication config. Please migrate to use the updated config. See https://github.com/scalar/scalar/blob/main/documentation/configuration.md#authentication-partial This will be removed in a future version.`);
126
- }
127
- const securitySchemes = Object.entries(security)
128
- .map?.(([nameKey, _scheme]) => {
129
- // Apply any transforms we need before parsing
130
- const payload = {
131
- ..._scheme,
132
- // Add the new auth config overrides, we keep the old code below for backwards compatibility
133
- ...(authentication?.securitySchemes?.[nameKey] ?? {}),
134
- nameKey,
135
- };
136
- // For oauth2 we need to add the type to the flows + prefill from authentication
137
- if (payload.type === 'oauth2' && payload.flows) {
138
- const flowKeys = Object.keys(payload.flows);
139
- flowKeys.forEach((key) => {
140
- if (!payload.flows?.[key] || _scheme.type !== 'oauth2') {
141
- return;
142
- }
143
- const authFlow = authentication?.securitySchemes?.[nameKey]?.flows?.[key] ?? {};
144
- // This part handles setting of flows via the new auth config, the rest can be removed in a future version
145
- payload.flows[key] = {
146
- ...(_scheme.flows?.[key] ?? {}),
147
- ...authFlow,
148
- };
149
- const flow = payload.flows[key];
150
- // Set the type
151
- flow.type = key;
152
- // Prefill values from authorization config - old deprecated config
153
- // @ts-expect-error - deprecated
154
- if (authentication?.oAuth2) {
155
- // @ts-expect-error - deprecated
156
- if (authentication.oAuth2.accessToken) {
157
- // @ts-expect-error - deprecated
158
- flow.token = authentication.oAuth2.accessToken;
159
- }
160
- // @ts-expect-error - deprecated
161
- if (authentication.oAuth2.clientId) {
162
- // @ts-expect-error - deprecated
163
- flow['x-scalar-client-id'] = authentication.oAuth2.clientId;
164
- }
165
- // @ts-expect-error - deprecated
166
- if (authentication.oAuth2.scopes) {
167
- // @ts-expect-error - deprecated
168
- flow.selectedScopes = authentication.oAuth2.scopes;
169
- }
170
- if (flow.type === 'password') {
171
- // @ts-expect-error - deprecated
172
- flow.username = authentication.oAuth2.username;
173
- // @ts-expect-error - deprecated
174
- flow.password = authentication.oAuth2.password;
175
- }
176
- }
177
- // Convert scopes to an object
178
- if (Array.isArray(flow.scopes)) {
179
- flow.scopes = flow.scopes.reduce((prev, s) => ({ ...prev, [s]: '' }), {});
180
- }
181
- // Handle x-defaultClientId
182
- if (flow['x-defaultClientId']) {
183
- flow['x-scalar-client-id'] = flow['x-defaultClientId'];
184
- }
185
- });
186
- }
187
- // Otherwise we just prefill - old deprecated config
188
- else if (authentication) {
189
- // ApiKey
190
- // @ts-expect-error - deprecated
191
- if (payload.type === 'apiKey' && authentication.apiKey?.token) {
192
- // @ts-expect-error - deprecated
193
- payload.value = authentication.apiKey.token;
194
- }
195
- // HTTP
196
- else if (payload.type === 'http') {
197
- // @ts-expect-error - deprecated
198
- if (payload.scheme === 'basic' && authentication.http?.basic) {
199
- // @ts-expect-error - deprecated
200
- payload.username = authentication.http.basic.username ?? '';
201
- // @ts-expect-error - deprecated
202
- payload.password = authentication.http.basic.password ?? '';
203
- }
204
- // Bearer
205
- // @ts-expect-error - deprecated
206
- else if (payload.scheme === 'bearer' && authentication.http?.bearer?.token) {
207
- // @ts-expect-error - deprecated
208
- payload.token = authentication.http.bearer.token ?? '';
209
- }
210
- }
211
- }
212
- const scheme = schemaModel(payload, securitySchemeSchema, false);
213
- if (!scheme) {
214
- importWarnings.push(`Security scheme ${nameKey} is invalid.`);
215
- }
216
- return scheme;
217
- })
218
- .filter((v) => !!v);
219
- // Map of security scheme names to UIDs
220
- const securitySchemeMap = {};
221
- securitySchemes.forEach((s) => {
222
- securitySchemeMap[s.nameKey] = s.uid;
223
- });
224
- // ---------------------------------------------------------------------------
225
- // REQUEST HANDLING
226
- keysOf(schema.paths ?? {}).forEach((pathString) => {
227
- const path = schema?.paths?.[pathString];
228
- if (!path) {
229
- return;
230
- }
231
- // Path level servers must be saved
232
- const pathServers = serverSchema.array().parse(path.servers ?? []);
233
- for (const server of pathServers) {
234
- collectionServers.push(server);
235
- }
236
- // Creates a sorted array of methods based on the path object.
237
- const methods = Object.keys(path).filter(isHttpMethod);
238
- methods.forEach((method) => {
239
- const operation = path[method];
240
- if (!operation) {
241
- return;
242
- }
243
- const operationLevelServers = serverSchema.array().parse(operation.servers ?? []);
244
- for (const server of operationLevelServers) {
245
- operationServers.push(server);
246
- }
247
- // We will save a list of all tags to ensure they exists at the top level
248
- // TODO: make sure we add any loose requests with no tags to the collection children
249
- operation.tags?.forEach((t) => tagNames.add(t));
250
- // Remove security here and add it correctly below
251
- const { security: operationSecurity, ...operationWithoutSecurity } = operation;
252
- const securityRequirements = (operationSecurity ?? schema.security ?? [])
253
- .map((s) => {
254
- const keys = Object.keys(s);
255
- return keys.length > 1 ? keys : keys[0];
256
- })
257
- .filter(isDefined);
258
- // Filter the preferred security schemes to only include the ones that are in the security requirements
259
- const preferredSecurityNames = [authentication?.preferredSecurityScheme ?? []].flat().filter((name) => {
260
- // Match up complex security requirements, array to array
261
- if (Array.isArray(name)) {
262
- // We match every element in the array
263
- return securityRequirements.some((r) => Array.isArray(r) && r.length === name.length && r.every((v, i) => v === name[i]));
264
- }
265
- return securityRequirements.includes(name);
266
- });
267
- // Set the initially selected security scheme
268
- const selectedSecuritySchemeUids = securityRequirements.length && !useCollectionSecurity
269
- ? getSelectedSecuritySchemeUids(securityRequirements, preferredSecurityNames, securitySchemeMap)
270
- : [];
271
- const requestPayload = {
272
- ...operationWithoutSecurity,
273
- method,
274
- path: pathString,
275
- security: operationSecurity,
276
- selectedServerUid: operationLevelServers?.[0]?.uid,
277
- selectedSecuritySchemeUids,
278
- // Merge path and operation level parameters
279
- parameters: [...(path?.parameters ?? []), ...(operation.parameters ?? [])],
280
- servers: [...pathServers, ...operationLevelServers].map((s) => s.uid),
281
- };
282
- // Remove any examples from the request payload as they conflict with our examples property and are not valid
283
- if (requestPayload.examples) {
284
- console.warn('[@scalar/api-client] operation.examples is not a valid openapi property');
285
- delete requestPayload.examples;
286
- }
287
- // Save parse the request
288
- const request = schemaModel(requestPayload, requestSchema, false);
289
- if (!request) {
290
- importWarnings.push(`${method} Request at ${path} is invalid.`);
291
- }
292
- else {
293
- requests.push(request);
294
- }
295
- });
296
- });
297
- // ---------------------------------------------------------------------------
298
- // TAG HANDLING
299
- // TODO: We may need to handle de-duping tags
300
- const tags = schemaModel(schema?.tags ?? [], tagSchema.array(), false) ?? [];
301
- // Delete any tag names that already have a definition
302
- tags.forEach((t) => tagNames.delete(t.name));
303
- // Add an entry for any tags that are used but do not have a definition
304
- tagNames.forEach((name) => name && tags.push(tagSchema.parse({ name })));
305
- // Tag name to UID map
306
- const tagMap = {};
307
- tags.forEach((t) => {
308
- tagMap[t.name] = t;
309
- });
310
- // Add all tags by default. We will remove nested ones
311
- const collectionChildren = new Set(tags.map((t) => t.uid));
312
- // Nested folders go before any requests
313
- tags.forEach((t) => {
314
- t['x-scalar-children']?.forEach((c) => {
315
- // Add the uid to the appropriate parent.children
316
- const nestedUid = tagMap[c.tagName]?.uid;
317
- if (nestedUid) {
318
- t.children.push(nestedUid);
319
- // Remove the nested uid from the root folder
320
- collectionChildren.delete(nestedUid);
321
- }
322
- });
323
- });
324
- // Add the request UIDs to the tag children (or collection root)
325
- requests.forEach((r) => {
326
- if (r.tags?.length) {
327
- r.tags.forEach((t) => {
328
- tagMap[t]?.children.push(r.uid);
329
- });
330
- }
331
- else {
332
- collectionChildren.add(r.uid);
333
- }
334
- });
335
- // ---------------------------------------------------------------------------
336
- const examples = [];
337
- // Ensure each request has at least 1 example
338
- requests.forEach((request) => {
339
- // TODO: Need to handle parsing examples
340
- // if (request['x-scalar-examples']) return
341
- // Create the initial example
342
- const example = createExampleFromRequest(request, 'Default Example');
343
- examples.push(example);
344
- request.examples.push(example.uid);
345
- });
346
- // ---------------------------------------------------------------------------
347
- // Generate Collection
348
- // Grab the security requirements for this operation
349
- const securityRequirements = (schema.security ?? [])
350
- .map((s) => {
351
- const keys = Object.keys(s);
352
- return keys.length > 1 ? keys : keys[0];
353
- })
354
- .filter(isDefined);
355
- // Here we do not filter these as we let the preferredSecurityScheme override the requirements
356
- const preferredSecurityNames = [authentication?.preferredSecurityScheme ?? []].flat();
357
- // Set the initially selected security scheme
358
- const selectedSecuritySchemeUids = (securityRequirements.length || preferredSecurityNames?.length) && useCollectionSecurity
359
- ? getSelectedSecuritySchemeUids(securityRequirements, preferredSecurityNames, securitySchemeMap)
360
- : [];
361
- // Set the uid as a prefixed slug if we have one
362
- const slugObj = slug?.length ? { uid: getSlugUid(slug) } : {};
363
- const collection = collectionSchema.parse({
364
- ...slugObj,
365
- ...schema,
366
- watchMode,
367
- documentUrl,
368
- useCollectionSecurity,
369
- requests: requests.map((r) => r.uid),
370
- servers: collectionServers.map((s) => s.uid),
371
- tags: tags.map((t) => t.uid),
372
- children: [...collectionChildren],
373
- security: schema.security ?? [{}],
374
- selectedServerUid: collectionServers?.[0]?.uid,
375
- selectedSecuritySchemeUids,
376
- components: {
377
- ...schema.components,
378
- },
379
- securitySchemes: securitySchemes.map((s) => s.uid),
380
- });
381
- const end = performance.now();
382
- console.log(`workspace: ${Math.round(end - start)} ms`);
383
- /**
384
- * Servers and requests will be saved in top level maps and indexed via UID to
385
- * maintain specification relationships
386
- */
387
- return {
388
- error: false,
389
- servers: [...collectionServers, ...operationServers],
390
- schema,
391
- requests,
392
- examples,
393
- collection,
394
- tags,
395
- securitySchemes,
396
- };
397
- }
@@ -1,2 +0,0 @@
1
- export { getSlugUid, importSpecToWorkspace, parseSchema, type ImportSpecToWorkspaceArgs, } from './import-spec.js';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/transforms/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,qBAAqB,EACrB,WAAW,EACX,KAAK,yBAAyB,GAC/B,MAAM,eAAe,CAAA"}
@@ -1 +0,0 @@
1
- export { getSlugUid, importSpecToWorkspace, parseSchema, } from './import-spec.js';