@scalar/oas-utils 0.2.118 → 0.2.120

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 CHANGED
@@ -1,5 +1,23 @@
1
1
  # @scalar/oas-utils
2
2
 
3
+ ## 0.2.120
4
+
5
+ ### Patch Changes
6
+
7
+ - cd75eeb: fix: update collection in multi doc
8
+ - Updated dependencies [39c0f47]
9
+ - @scalar/types@0.1.1
10
+ - @scalar/themes@0.9.79
11
+
12
+ ## 0.2.119
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies [1437882]
17
+ - Updated dependencies [e00fa7e]
18
+ - Updated dependencies [632978d]
19
+ - @scalar/themes@0.9.78
20
+
3
21
  ## 0.2.118
4
22
 
5
23
  ### Patch Changes
@@ -17,7 +17,9 @@ export declare const parseSchema: (spec: string | UnknownObject, { shouldLoad }?
17
17
  }>;
18
18
  /** Converts selected security requirements to uids */
19
19
  export declare const getSelectedSecuritySchemeUids: (securityRequirements: (string | string[])[], preferredSecurityNames: (string | string[])[] | undefined, securitySchemeMap: Record<string, SecurityScheme["uid"]>) => SelectedSecuritySchemeUids;
20
- export type ImportSpecToWorkspaceArgs = Pick<CollectionPayload, 'documentUrl' | 'watchMode'> & Pick<ApiReferenceConfiguration, 'authentication' | 'baseServerURL' | 'servers'> & {
20
+ /** Create a "uid" from a slug */
21
+ export declare const getSlugUid: (slug: string) => Collection["uid"];
22
+ export type ImportSpecToWorkspaceArgs = Pick<CollectionPayload, 'documentUrl' | 'watchMode'> & Pick<ApiReferenceConfiguration, 'authentication' | 'baseServerURL' | 'servers' | 'slug'> & {
21
23
  /** Sets the preferred security scheme on the collection instead of the requests */
22
24
  setCollectionSecurity?: boolean;
23
25
  /** Call the load step from the parser */
@@ -36,7 +38,7 @@ export type ImportSpecToWorkspaceArgs = Pick<CollectionPayload, 'documentUrl' |
36
38
  * - Proper linking between related components
37
39
  * - Easy lookup and reference of dependent entities
38
40
  */
39
- export declare function importSpecToWorkspace(spec: string | UnknownObject, { authentication, baseServerURL, documentUrl, servers: configuredServers, setCollectionSecurity, shouldLoad, watchMode, }?: ImportSpecToWorkspaceArgs): Promise<{
41
+ export declare function importSpecToWorkspace(spec: string | UnknownObject, { authentication, baseServerURL, documentUrl, servers: configuredServers, setCollectionSecurity, slug, shouldLoad, watchMode, }?: ImportSpecToWorkspaceArgs): Promise<{
40
42
  error: false;
41
43
  collection: Collection;
42
44
  requests: Request[];
@@ -1 +1 @@
1
- {"version":3,"file":"import-spec.d.ts","sourceRoot":"","sources":["../../src/transforms/import-spec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAA;AAC3E,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;AAMjC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAA;AAC5E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAGxD,mFAAmF;AACnF,eAAO,MAAM,WAAW,SAAgB,MAAM,GAAG,aAAa;;;IAkC1D;;;OAGG;YAC8C,WAAW,CAAC,QAAQ;;EAGxE,CAAA;AAED,sDAAsD;AACtD,eAAO,MAAM,6BAA6B,yBAClB,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,0BACnB,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,iCAC1B,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,KAAK,CAAC,CAAC,KACvD,0BAWF,CAAA;AAED,MAAM,MAAM,yBAAyB,GAAG,IAAI,CAAC,iBAAiB,EAA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EACJ,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,WAAW,CAAC,QAAQ,CAAA;IAC5B,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,CAAC;IAAC,UAAU,EAAE,SAAS,CAAA;CAAE,CACnE,CAkUA;AAED;;GAEG;AACH,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,WAAW,CAAC,YAAY,EAAE,GAAG,SAAS,EAC/C,EAAE,aAAa,EAAE,GAAE,IAAI,CAAC,yBAAyB,EAAE,eAAe,CAAM,GACvE,MAAM,EAAE,CAwCV"}
@@ -60,6 +60,8 @@ const getSelectedSecuritySchemeUids = (securityRequirements, preferredSecurityNa
60
60
  .filter(isDefined);
61
61
  return uids;
62
62
  };
63
+ /** Create a "uid" from a slug */
64
+ const getSlugUid = (slug) => `slug-uid-${slug}`;
63
65
  /**
64
66
  * Imports an OpenAPI document and converts it to workspace entities (Collection, Request, Server, etc.)
65
67
  *
@@ -73,7 +75,7 @@ const getSelectedSecuritySchemeUids = (securityRequirements, preferredSecurityNa
73
75
  * - Proper linking between related components
74
76
  * - Easy lookup and reference of dependent entities
75
77
  */
76
- async function importSpecToWorkspace(spec, { authentication, baseServerURL, documentUrl, servers: configuredServers, setCollectionSecurity = false, shouldLoad, watchMode = false, } = {}) {
78
+ async function importSpecToWorkspace(spec, { authentication, baseServerURL, documentUrl, servers: configuredServers, setCollectionSecurity = false, slug, shouldLoad, watchMode = false, } = {}) {
77
79
  const { schema, errors } = await parseSchema(spec, { shouldLoad });
78
80
  const importWarnings = [...errors.map((e) => e.message)];
79
81
  if (!schema)
@@ -310,7 +312,10 @@ async function importSpecToWorkspace(spec, { authentication, baseServerURL, docu
310
312
  const selectedSecuritySchemeUids = (securityRequirements.length || preferredSecurityNames?.length) && setCollectionSecurity
311
313
  ? getSelectedSecuritySchemeUids(securityRequirements, preferredSecurityNames, securitySchemeMap)
312
314
  : [];
315
+ // Set the uid as a prefixed slug if we have one
316
+ const slugObj = slug?.length ? { uid: getSlugUid(slug) } : {};
313
317
  const collection = collectionSchema.parse({
318
+ ...slugObj,
314
319
  ...schema,
315
320
  watchMode,
316
321
  documentUrl,
@@ -394,4 +399,4 @@ function getFallbackUrl() {
394
399
  return window.location.origin;
395
400
  }
396
401
 
397
- export { getSelectedSecuritySchemeUids, getServersFromOpenApiDocument, importSpecToWorkspace, parseSchema };
402
+ export { getSelectedSecuritySchemeUids, getServersFromOpenApiDocument, getSlugUid, importSpecToWorkspace, parseSchema };
@@ -1 +1 @@
1
- export { getSelectedSecuritySchemeUids, getServersFromOpenApiDocument, importSpecToWorkspace, parseSchema } from './import-spec.js';
1
+ export { getSelectedSecuritySchemeUids, getServersFromOpenApiDocument, getSlugUid, 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.118",
19
+ "version": "0.2.120",
20
20
  "engines": {
21
21
  "node": ">=18"
22
22
  },
@@ -128,8 +128,8 @@
128
128
  "zod": "^3.23.8",
129
129
  "@scalar/object-utils": "1.1.13",
130
130
  "@scalar/openapi-types": "0.1.9",
131
- "@scalar/themes": "0.9.77",
132
- "@scalar/types": "0.1.0"
131
+ "@scalar/themes": "0.9.79",
132
+ "@scalar/types": "0.1.1"
133
133
  },
134
134
  "devDependencies": {
135
135
  "type-fest": "^4.20.0",