@scalar/oas-utils 0.2.47 → 0.2.49

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,21 @@
1
1
  # @scalar/oas-utils
2
2
 
3
+ ## 0.2.49
4
+
5
+ ### Patch Changes
6
+
7
+ - cd8ba1c: feat: added setting of initial security schemes in the client
8
+
9
+ ## 0.2.48
10
+
11
+ ### Patch Changes
12
+
13
+ - dc20180: feat(api-client): custom icons for collections
14
+ - Updated dependencies [f961940]
15
+ - Updated dependencies [f961940]
16
+ - @scalar/types@0.0.11
17
+ - @scalar/themes@0.9.32
18
+
3
19
  ## 0.2.47
4
20
 
5
21
  ### Patch Changes
@@ -260,6 +260,8 @@ export declare const collectionSchema: z.ZodObject<z.objectUtil.extendShape<{
260
260
  components: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
261
261
  /** TODO: Type these */
262
262
  webhooks: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
263
+ /** A custom icon representing the collection */
264
+ 'x-scalar-icon': z.ZodDefault<z.ZodOptional<z.ZodString>>;
263
265
  }, {
264
266
  uid: z.ZodDefault<z.ZodOptional<z.ZodString>>;
265
267
  /** A list of security schemes UIDs associated with the collection */
@@ -365,6 +367,7 @@ export declare const collectionSchema: z.ZodObject<z.objectUtil.extendShape<{
365
367
  children: string[];
366
368
  openapi: string;
367
369
  security: Record<string, string[]>[];
370
+ 'x-scalar-icon': string;
368
371
  securitySchemes: string[];
369
372
  selectedServerUid: string;
370
373
  servers: string[];
@@ -451,6 +454,7 @@ export declare const collectionSchema: z.ZodObject<z.objectUtil.extendShape<{
451
454
  security?: Record<string, string[] | undefined>[] | undefined;
452
455
  components?: Record<string, unknown> | undefined;
453
456
  webhooks?: Record<string, unknown> | undefined;
457
+ 'x-scalar-icon'?: string | undefined;
454
458
  securitySchemes?: string[] | undefined;
455
459
  selectedServerUid?: string | undefined;
456
460
  servers?: (string | undefined)[] | undefined;
@@ -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;AAuCvB,eAAO,MAAM,wBAAwB;;IAEnC,qEAAqE;;IAErE,oCAAoC;;IAEpC,wDAAwD;;IAExD,gDAAgD;;IAEhD,8CAA8C;;IAE9C,gEAAgE;;IAEhE;;;;;OAKG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAEH,CAAA;AAEF,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA5C3B;;;;;;OAMG;;;;;;;;;;;;IAGH,uBAAuB;;IAEvB,uBAAuB;;;;IAYvB,qEAAqE;;IAErE,oCAAoC;;IAEpC,wDAAwD;;IAExD,gDAAgD;;IAEhD,8CAA8C;;IAE9C,gEAAgE;;IAEhE;;;;;OAKG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAMJ,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"}
1
+ {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ocumentationSchema } from './spec-objects.js
4
4
  import { nanoidSchema } from '../shared/utility.js';
5
5
 
6
6
  const oasCollectionSchema = z.object({
7
- type: z.literal('collection').optional().default('collection'),
8
- openapi: z
7
+ 'type': z.literal('collection').optional().default('collection'),
8
+ 'openapi': z
9
9
  .union([
10
10
  z.string(),
11
11
  z.literal('3.0.0'),
@@ -14,8 +14,8 @@ const oasCollectionSchema = z.object({
14
14
  ])
15
15
  .optional()
16
16
  .default('3.1.0'),
17
- jsonSchemaDialect: z.string().optional(),
18
- info: oasInfoSchema.optional(),
17
+ 'jsonSchemaDialect': z.string().optional(),
18
+ 'info': oasInfoSchema.optional(),
19
19
  /**
20
20
  * A declaration of which security mechanisms can be used across the API. The list of
21
21
  * values includes alternative security requirement objects that can be used. Only
@@ -23,12 +23,14 @@ const oasCollectionSchema = z.object({
23
23
  * Individual operations can override this definition. To make security optional, an empty
24
24
  * security requirement ({}) can be included in the array.
25
25
  */
26
- security: z.array(oasSecurityRequirementSchema).optional().default([]),
27
- externalDocs: oasExternalDocumentationSchema.optional(),
26
+ 'security': z.array(oasSecurityRequirementSchema).optional().default([]),
27
+ 'externalDocs': oasExternalDocumentationSchema.optional(),
28
28
  /** TODO: Type these */
29
- components: z.record(z.string(), z.unknown()).optional(),
29
+ 'components': z.record(z.string(), z.unknown()).optional(),
30
30
  /** TODO: Type these */
31
- webhooks: z.record(z.string(), z.unknown()).optional(),
31
+ 'webhooks': z.record(z.string(), z.unknown()).optional(),
32
+ /** A custom icon representing the collection */
33
+ 'x-scalar-icon': z.string().optional().default('interface-content-folder'),
32
34
  // These properties will be stripped out and mapped back as id lists
33
35
  // servers
34
36
  // paths/**
@@ -62,6 +62,7 @@ export declare const migrate_v_2_1_0: (data: Omit<v_0_0_0.Data, "folders">) => {
62
62
  clientSecret: string;
63
63
  }>;
64
64
  children: string[];
65
+ 'x-scalar-icon': string;
65
66
  }[];
66
67
  cookies: v_0_0_0.Cookie[];
67
68
  environments: {
@@ -1 +1 @@
1
-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AC7C,CAAC;wBACT,CAAC;;;;;;oBAIe,CAAC;2BACd,CAAC;sBAGN,CAAC;wBAER,CAAA;oBACO,CAAC;oBAEG,CAAC;sBACiB,CAAC;uBAC9B,CAAH;uBAGO,CAAJ;uBACQ,CAAC;wBAIX,CADC;;;;;;oBAGmB,CAAA;2BAChB,CAAF;sBAAmC,CAAC;wBACb,CAAC;oBACjB,CAAC;oBAAoC,CAAA;sBAClB,CAAC;uBACjB,CAAC;uBAEY,CAAC;uBAChB,CAAC;wBACP,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBAWK,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAuI2jB,CAAC;;6BAA4E,CAAC;;;;;;;;;;CADrpB,CAAA"}
@@ -103,19 +103,20 @@ const migrate_v_2_1_0 = (data) => {
103
103
  return prev;
104
104
  }, {});
105
105
  return {
106
- type: 'collection',
107
- openapi: c.spec?.openapi || '3.1.0',
108
- info: c.spec?.info || { title: 'OpenAPI Spec', version: '0.0.1' },
109
- security: c.spec?.security || [],
110
- externalDocs: c.spec?.externalDocs,
111
- uid: c.uid,
106
+ 'type': 'collection',
107
+ 'openapi': c.spec?.openapi || '3.1.0',
108
+ 'info': c.spec?.info || { title: 'OpenAPI Spec', version: '0.0.1' },
109
+ 'security': c.spec?.security || [],
110
+ 'externalDocs': c.spec?.externalDocs,
111
+ 'uid': c.uid,
112
112
  securitySchemes,
113
- selectedServerUid: c.selectedServerUid || c.spec?.serverUids?.[0] || '',
114
- servers: c.spec?.serverUids || [],
115
- requests: [...requestUids],
116
- tags: [...tagUids],
113
+ 'selectedServerUid': c.selectedServerUid || c.spec?.serverUids?.[0] || '',
114
+ 'servers': c.spec?.serverUids || [],
115
+ 'requests': [...requestUids],
116
+ 'tags': [...tagUids],
117
117
  auth,
118
- children: c.childUids || [],
118
+ 'children': c.childUids || [],
119
+ 'x-scalar-icon': 'interface-content-folder',
119
120
  };
120
121
  });
121
122
  // Cookies
@@ -8,6 +8,7 @@ export declare function exportSpecFromWorkspace({ collection, requests, }: {
8
8
  children: string[];
9
9
  openapi: string;
10
10
  security: Record<string, string[]>[];
11
+ 'x-scalar-icon': string;
11
12
  securitySchemes: string[];
12
13
  selectedServerUid: string;
13
14
  servers: string[];
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAEA"}
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,5 +1,6 @@
1
1
  import { type Collection, 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 { AuthenticationState } from '@scalar/types/legacy';
3
4
  import type { UnknownObject } from '@scalar/types/utils';
4
5
  /**
5
6
  * Import an OpenAPI spec file and convert it to workspace entities
@@ -9,7 +10,7 @@ import type { UnknownObject } from '@scalar/types/utils';
9
10
  * created and used at various levels we will index via the uids to create
10
11
  * the relationships
11
12
  */
12
- export declare function importSpecToWorkspace(spec: string | UnknownObject): Promise<{
13
+ export declare function importSpecToWorkspace(spec: string | UnknownObject, preferredSecurityScheme?: AuthenticationState['preferredSecurityScheme']): Promise<{
13
14
  error: false;
14
15
  collection: Collection;
15
16
  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,OAAO,EACZ,KAAK,cAAc,EAGnB,KAAK,MAAM,EACX,KAAK,GAAG,EAOT,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,KAAK,cAAc,EAGpB,MAAM,0BAA0B,CAAA;AAKjC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAiCxD;;;;;;;GAOG;AACH,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,MAAM,GAAG,aAAa,GAC3B,OAAO,CACN;IACE,KAAK,EAAE,KAAK,CAAA;IACZ,UAAU,EAAE,UAAU,CAAA;IACtB,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,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,CAwOA"}
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;AAKjC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAiCxD;;;;;;;GAOG;AACH,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,MAAM,GAAG,aAAa,EAC5B,uBAAuB,CAAC,EAAE,mBAAmB,CAAC,yBAAyB,CAAC,GACvE,OAAO,CACN;IACE,KAAK,EAAE,KAAK,CAAA;IACZ,UAAU,EAAE,UAAU,CAAA;IACtB,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,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"}
@@ -40,7 +40,7 @@ const convertOauth2Flows = (security, nameKey) => {
40
40
  * created and used at various levels we will index via the uids to create
41
41
  * the relationships
42
42
  */
43
- async function importSpecToWorkspace(spec) {
43
+ async function importSpecToWorkspace(spec, preferredSecurityScheme) {
44
44
  const { filesystem } = await load(spec);
45
45
  const { specification } = upgrade(filesystem);
46
46
  const { schema: _schema, errors = [] } = await dereference(specification);
@@ -107,12 +107,32 @@ async function importSpecToWorkspace(spec) {
107
107
  // TODO: make sure we add any loose requests with no tags to the collection children
108
108
  operation.tags?.forEach((t) => tagNames.add(t));
109
109
  // Remove security here and add it correctly below
110
- const { security: removed, ...operationWithoutSecurity } = operation;
110
+ const { security: operationSecurity, ...operationWithoutSecurity } = operation;
111
+ // Grab the security requirements for this operation
112
+ const securityRequirements = (operationSecurity ??
113
+ schema.security ??
114
+ []).flatMap((s) => {
115
+ const keys = Object.keys(s);
116
+ if (keys.length)
117
+ return keys[0];
118
+ else
119
+ return [];
120
+ });
121
+ let selectedSecuritySchemeUids = [];
122
+ // Set the initially selected security scheme
123
+ if (securityRequirements.length) {
124
+ const name = preferredSecurityScheme &&
125
+ securityRequirements.includes(preferredSecurityScheme ?? '')
126
+ ? preferredSecurityScheme
127
+ : securityRequirements[0];
128
+ const uid = securitySchemeMap[name];
129
+ selectedSecuritySchemeUids = [uid];
130
+ }
111
131
  const requestPayload = {
112
132
  ...operationWithoutSecurity,
113
133
  method,
114
134
  path: pathString,
115
- selectedSecuritySchemeUids: [],
135
+ selectedSecuritySchemeUids,
116
136
  // Merge path and operation level parameters
117
137
  parameters: [
118
138
  ...(path?.parameters ?? []),
@@ -122,8 +142,8 @@ async function importSpecToWorkspace(spec) {
122
142
  };
123
143
  // Add list of UIDs to associate security schemes
124
144
  // As per the spec if there is operation level security we ignore the top level requirements
125
- if (operation.security?.length)
126
- requestPayload.security = operation.security?.map((s) => {
145
+ if (operationSecurity?.length)
146
+ requestPayload.security = operationSecurity.map((s) => {
127
147
  const keys = Object.keys(s);
128
148
  // Handle the case of {} for optional
129
149
  if (keys.length) {
package/package.json CHANGED
@@ -16,7 +16,7 @@
16
16
  "specification",
17
17
  "yaml"
18
18
  ],
19
- "version": "0.2.47",
19
+ "version": "0.2.49",
20
20
  "engines": {
21
21
  "node": ">=18"
22
22
  },
@@ -92,10 +92,10 @@
92
92
  "nanoid": "^5.0.7",
93
93
  "yaml": "^2.4.5",
94
94
  "zod": "^3.23.8",
95
- "@scalar/object-utils": "1.1.9",
96
- "@scalar/themes": "0.9.31",
97
95
  "@scalar/openapi-types": "0.1.1",
98
- "@scalar/types": "0.0.10"
96
+ "@scalar/themes": "0.9.32",
97
+ "@scalar/object-utils": "1.1.9",
98
+ "@scalar/types": "0.0.11"
99
99
  },
100
100
  "devDependencies": {
101
101
  "rollup": "^4.16.4",
@@ -105,7 +105,7 @@
105
105
  "zod-to-ts": "^1.2.0",
106
106
  "@scalar/build-tooling": "0.1.10",
107
107
  "@scalar/openapi-types": "0.1.1",
108
- "@scalar/openapi-parser": "0.8.3"
108
+ "@scalar/openapi-parser": "0.8.4"
109
109
  },
110
110
  "scripts": {
111
111
  "build": "scalar-build-rollup",