@scalar/types 0.7.2 → 0.7.4

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 (46) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/api-reference/api-client-configuration.js +3 -7
  3. package/dist/api-reference/api-client-plugin.js +32 -30
  4. package/dist/api-reference/api-reference-configuration.js +404 -361
  5. package/dist/api-reference/api-reference-plugin.js +43 -47
  6. package/dist/api-reference/authentication-configuration.js +1 -1
  7. package/dist/api-reference/authentication-configuration.test-d.js +41 -42
  8. package/dist/api-reference/base-configuration.js +150 -146
  9. package/dist/api-reference/html-api.js +1 -1
  10. package/dist/api-reference/html-rendering-configuration.js +19 -20
  11. package/dist/api-reference/index.js +5 -26
  12. package/dist/api-reference/source-configuration.js +105 -96
  13. package/dist/entities/index.js +1 -21
  14. package/dist/entities/security-scheme.js +179 -140
  15. package/dist/index.js +6 -6
  16. package/dist/legacy/index.js +1 -5
  17. package/dist/legacy/reference-config.js +6 -10
  18. package/dist/snippetz/index.js +1 -6
  19. package/dist/snippetz/snippetz.js +35 -31
  20. package/dist/snippetz/snippetz.test-d.js +30 -27
  21. package/dist/utils/index.js +1 -5
  22. package/dist/utils/nanoid.js +7 -7
  23. package/dist/utils/utility-types.js +1 -1
  24. package/package.json +5 -9
  25. package/dist/api-reference/api-client-configuration.js.map +0 -7
  26. package/dist/api-reference/api-client-plugin.js.map +0 -7
  27. package/dist/api-reference/api-reference-configuration.js.map +0 -7
  28. package/dist/api-reference/api-reference-plugin.js.map +0 -7
  29. package/dist/api-reference/authentication-configuration.js.map +0 -7
  30. package/dist/api-reference/authentication-configuration.test-d.js.map +0 -7
  31. package/dist/api-reference/base-configuration.js.map +0 -7
  32. package/dist/api-reference/html-api.js.map +0 -7
  33. package/dist/api-reference/html-rendering-configuration.js.map +0 -7
  34. package/dist/api-reference/index.js.map +0 -7
  35. package/dist/api-reference/source-configuration.js.map +0 -7
  36. package/dist/entities/index.js.map +0 -7
  37. package/dist/entities/security-scheme.js.map +0 -7
  38. package/dist/index.js.map +0 -7
  39. package/dist/legacy/index.js.map +0 -7
  40. package/dist/legacy/reference-config.js.map +0 -7
  41. package/dist/snippetz/index.js.map +0 -7
  42. package/dist/snippetz/snippetz.js.map +0 -7
  43. package/dist/snippetz/snippetz.test-d.js.map +0 -7
  44. package/dist/utils/index.js.map +0 -7
  45. package/dist/utils/nanoid.js.map +0 -7
  46. package/dist/utils/utility-types.js.map +0 -7
@@ -1,100 +1,109 @@
1
- import z from "zod";
2
- const sourceConfigurationSchema = z.object({
3
- default: z.boolean().default(false).optional().catch(false),
4
- /**
5
- * URL to an OpenAPI/Swagger document
6
- * @example
7
- * ```ts
8
- * const oldConfiguration = {
9
- * spec: {
10
- * url: 'https://example.com/openapi.json',
11
- * },
12
- * }
13
- *
14
- * const newConfiguration = {
15
- * url: 'https://example.com/openapi.json',
16
- * }
17
- * ```
18
- **/
19
- url: z.string().optional(),
20
- /**
21
- * Directly embed the OpenAPI document.
22
- * Can be a string, object, function returning an object, or null.
23
- *
24
- * @remarks It's recommended to pass a URL instead of content.
25
- * @example
26
- * ```ts
27
- * const oldConfiguration = {
28
- * spec: {
29
- * content: '…',
30
- * },
31
- * }
32
- *
33
- * const newConfiguration = {
34
- * content: '…',
35
- * }
36
- * ```
37
- **/
38
- content: z.union([
39
- z.string(),
40
- z.null(),
41
- z.record(z.string(), z.any()),
42
- z.function({
43
- input: [],
44
- output: z.record(z.string(), z.any())
45
- })
46
- ]).optional(),
47
- /**
48
- * The title of the OpenAPI document.
49
- *
50
- * @example 'Scalar Galaxy'
51
- *
52
- * @deprecated Please move `title` to the top level and remove the `spec` prefix.
53
- */
54
- title: z.string().optional(),
55
- /**
56
- * The slug of the OpenAPI document used in the URL.
57
- *
58
- * If none is passed, the title will be used.
59
- *
60
- * If no title is used, it'll just use the index.
61
- *
62
- * @example 'scalar-galaxy'
63
- *
64
- * @deprecated Please move `slug` to the top level and remove the `spec` prefix.
65
- */
66
- slug: z.string().optional(),
67
- /**
68
- * The OpenAPI/Swagger document to render
69
- *
70
- * @deprecated Use `url` and `content` on the top level instead.
71
- **/
72
- spec: z.object({
1
+ import z from 'zod';
2
+ /**
3
+ * A source is any potential document input used for API Reference
4
+ * and API Client integrations. Sources may be specified in the configuration
5
+ * or used independently. Some configurations may have multiple sources.
6
+ */
7
+ export const sourceConfigurationSchema = z.object({
8
+ default: z.boolean().default(false).optional().catch(false),
9
+ /**
10
+ * URL to an OpenAPI/Swagger document
11
+ * @example
12
+ * ```ts
13
+ * const oldConfiguration = {
14
+ * spec: {
15
+ * url: 'https://example.com/openapi.json',
16
+ * },
17
+ * }
18
+ *
19
+ * const newConfiguration = {
20
+ * url: 'https://example.com/openapi.json',
21
+ * }
22
+ * ```
23
+ **/
73
24
  url: z.string().optional(),
74
- content: z.union([
75
- z.string(),
76
- z.null(),
77
- z.record(z.string(), z.any()),
78
- z.function({
79
- input: [],
80
- output: z.record(z.string(), z.any())
81
- })
82
- ]).optional()
83
- }).optional(),
84
- /**
85
- * Agent Scalar configuration
86
- **/
87
- agent: z.object({
88
- key: z.string().optional(),
89
- disabled: z.boolean().optional(),
90
25
  /**
91
- * When true, hide the control to add more APIs in the agent chat.
92
- * Only preloaded/registry documents are shown; the public API list is not offered.
26
+ * Directly embed the OpenAPI document.
27
+ * Can be a string, object, function returning an object, or null.
28
+ *
29
+ * @remarks It's recommended to pass a URL instead of content.
30
+ * @example
31
+ * ```ts
32
+ * const oldConfiguration = {
33
+ * spec: {
34
+ * content: '…',
35
+ * },
36
+ * }
37
+ *
38
+ * const newConfiguration = {
39
+ * content: '…',
40
+ * }
41
+ * ```
42
+ **/
43
+ content: z
44
+ .union([
45
+ z.string(),
46
+ z.null(),
47
+ z.record(z.string(), z.any()),
48
+ z.function({
49
+ input: [],
50
+ output: z.record(z.string(), z.any()),
51
+ }),
52
+ ])
53
+ .optional(),
54
+ /**
55
+ * The title of the OpenAPI document.
56
+ *
57
+ * @example 'Scalar Galaxy'
58
+ *
59
+ * @deprecated Please move `title` to the top level and remove the `spec` prefix.
60
+ */
61
+ title: z.string().optional(),
62
+ /**
63
+ * The slug of the OpenAPI document used in the URL.
64
+ *
65
+ * If none is passed, the title will be used.
66
+ *
67
+ * If no title is used, it'll just use the index.
68
+ *
69
+ * @example 'scalar-galaxy'
70
+ *
71
+ * @deprecated Please move `slug` to the top level and remove the `spec` prefix.
93
72
  */
94
- hideAddApi: z.boolean().optional()
95
- }).optional()
73
+ slug: z.string().optional(),
74
+ /**
75
+ * The OpenAPI/Swagger document to render
76
+ *
77
+ * @deprecated Use `url` and `content` on the top level instead.
78
+ **/
79
+ spec: z
80
+ .object({
81
+ url: z.string().optional(),
82
+ content: z
83
+ .union([
84
+ z.string(),
85
+ z.null(),
86
+ z.record(z.string(), z.any()),
87
+ z.function({
88
+ input: [],
89
+ output: z.record(z.string(), z.any()),
90
+ }),
91
+ ])
92
+ .optional(),
93
+ })
94
+ .optional(),
95
+ /**
96
+ * Agent Scalar configuration
97
+ **/
98
+ agent: z
99
+ .object({
100
+ key: z.string().optional(),
101
+ disabled: z.boolean().optional(),
102
+ /**
103
+ * When true, hide the control to add more APIs in the agent chat.
104
+ * Only preloaded/registry documents are shown; the public API list is not offered.
105
+ */
106
+ hideAddApi: z.boolean().optional(),
107
+ })
108
+ .optional(),
96
109
  });
97
- export {
98
- sourceConfigurationSchema
99
- };
100
- //# sourceMappingURL=source-configuration.js.map
@@ -1,21 +1 @@
1
- import {
2
- oasSecurityRequirementSchema,
3
- oasSecuritySchemeSchema,
4
- pkceOptions,
5
- securityApiKeySchema,
6
- securityHttpSchema,
7
- securityOauthSchema,
8
- securityOpenIdSchema,
9
- securitySchemeSchema
10
- } from "./security-scheme.js";
11
- export {
12
- oasSecurityRequirementSchema,
13
- oasSecuritySchemeSchema,
14
- pkceOptions,
15
- securityApiKeySchema,
16
- securityHttpSchema,
17
- securityOauthSchema,
18
- securityOpenIdSchema,
19
- securitySchemeSchema
20
- };
21
- //# sourceMappingURL=index.js.map
1
+ export { oasSecurityRequirementSchema, oasSecuritySchemeSchema, pkceOptions, securityApiKeySchema, securityHttpSchema, securityOauthSchema, securityOpenIdSchema, securitySchemeSchema, } from './security-scheme.js';
@@ -1,161 +1,200 @@
1
- import { z } from "zod";
2
- import { nanoidSchema } from "../utils/nanoid.js";
1
+ import { z } from 'zod';
2
+ import { nanoidSchema } from '../utils/nanoid.js';
3
+ // ---------------------------------------------------------------------------
4
+ // COMMON PROPS FOR ALL SECURITY SCHEMES
5
+ /** Some common properties used in all security schemes */
3
6
  const commonProps = z.object({
4
- /* A description for security scheme. CommonMark syntax MAY be used for rich text representation. */
5
- description: z.string().optional()
7
+ /* A description for security scheme. CommonMark syntax MAY be used for rich text representation. */
8
+ description: z.string().optional(),
6
9
  });
7
10
  const extendedSecuritySchema = z.object({
8
- uid: nanoidSchema.brand(),
9
- /** The name key that links a security requirement to a security object */
10
- nameKey: z.string().optional().default("")
11
+ uid: nanoidSchema.brand(),
12
+ /** The name key that links a security requirement to a security object */
13
+ nameKey: z.string().optional().default(''),
11
14
  });
12
- const securitySchemeApiKeyIn = ["query", "header", "cookie"];
15
+ // ---------------------------------------------------------------------------
16
+ // API KEY
17
+ const securitySchemeApiKeyIn = ['query', 'header', 'cookie'];
13
18
  const oasSecuritySchemeApiKey = commonProps.extend({
14
- type: z.literal("apiKey"),
15
- /** REQUIRED. The name of the header, query or cookie parameter to be used. */
16
- name: z.string().optional().default(""),
17
- /** REQUIRED. The location of the API key. Valid values are "query", "header" or "cookie". */
18
- in: z.enum(securitySchemeApiKeyIn).optional().default("header").catch("header")
19
+ type: z.literal('apiKey'),
20
+ /** REQUIRED. The name of the header, query or cookie parameter to be used. */
21
+ name: z.string().optional().default(''),
22
+ /** REQUIRED. The location of the API key. Valid values are "query", "header" or "cookie". */
23
+ in: z.enum(securitySchemeApiKeyIn).optional().default('header').catch('header'),
19
24
  });
20
25
  const apiKeyValueSchema = z.object({
21
- value: z.string().default("")
26
+ value: z.string().default(''),
22
27
  });
23
- const securityApiKeySchema = oasSecuritySchemeApiKey.merge(extendedSecuritySchema).merge(apiKeyValueSchema);
28
+ export const securityApiKeySchema = oasSecuritySchemeApiKey.merge(extendedSecuritySchema).merge(apiKeyValueSchema);
29
+ // ---------------------------------------------------------------------------
30
+ // HTTP
24
31
  const oasSecuritySchemeHttp = commonProps.extend({
25
- type: z.literal("http"),
26
- /**
27
- * REQUIRED. The name of the HTTP Authorization scheme to be used in the Authorization header as defined in
28
- * [RFC7235]. The values used SHOULD be registered in the IANA Authentication Scheme registry.
29
- */
30
- scheme: z.string().toLowerCase().pipe(z.enum(["basic", "bearer"])).optional().default("basic"),
31
- /**
32
- * A hint to the client to identify how the bearer token is formatted.
33
- * Bearer tokens are usually generated by an authorization server, so
34
- * this information is primarily for documentation purposes.
35
- */
36
- bearerFormat: z.union([z.literal("JWT"), z.string()]).optional().default("JWT")
32
+ type: z.literal('http'),
33
+ /**
34
+ * REQUIRED. The name of the HTTP Authorization scheme to be used in the Authorization header as defined in
35
+ * [RFC7235]. The values used SHOULD be registered in the IANA Authentication Scheme registry.
36
+ */
37
+ scheme: z
38
+ .string()
39
+ .toLowerCase()
40
+ .pipe(z.enum(['basic', 'bearer']))
41
+ .optional()
42
+ .default('basic'),
43
+ /**
44
+ * A hint to the client to identify how the bearer token is formatted.
45
+ * Bearer tokens are usually generated by an authorization server, so
46
+ * this information is primarily for documentation purposes.
47
+ */
48
+ bearerFormat: z
49
+ .union([z.literal('JWT'), z.string()])
50
+ .optional()
51
+ .default('JWT'),
37
52
  });
38
53
  const httpValueSchema = z.object({
39
- username: z.string().default(""),
40
- password: z.string().default(""),
41
- token: z.string().default("")
54
+ username: z.string().default(''),
55
+ password: z.string().default(''),
56
+ token: z.string().default(''),
42
57
  });
43
- const securityHttpSchema = oasSecuritySchemeHttp.merge(extendedSecuritySchema).merge(httpValueSchema);
58
+ export const securityHttpSchema = oasSecuritySchemeHttp.merge(extendedSecuritySchema).merge(httpValueSchema);
59
+ // ---------------------------------------------------------------------------
60
+ // OPENID CONNECT
44
61
  const oasSecuritySchemeOpenId = commonProps.extend({
45
- type: z.literal("openIdConnect"),
46
- /**
47
- * REQUIRED. OpenId Connect URL to discover OAuth2 configuration values. This MUST be in the
48
- * form of a URL. The OpenID Connect standard requires the use of TLS.
49
- */
50
- openIdConnectUrl: z.string().optional().default("")
62
+ type: z.literal('openIdConnect'),
63
+ /**
64
+ * REQUIRED. OpenId Connect URL to discover OAuth2 configuration values. This MUST be in the
65
+ * form of a URL. The OpenID Connect standard requires the use of TLS.
66
+ */
67
+ openIdConnectUrl: z.string().optional().default(''),
51
68
  });
52
- const securityOpenIdSchema = oasSecuritySchemeOpenId.merge(extendedSecuritySchema);
53
- const authorizationUrl = z.string().default("");
54
- const tokenUrl = z.string().default("");
69
+ export const securityOpenIdSchema = oasSecuritySchemeOpenId.merge(extendedSecuritySchema);
70
+ // ---------------------------------------------------------------------------
71
+ /**
72
+ * REQUIRED. The authorization URL to be used for this flow. This MUST be in
73
+ * the form of a URL. The OAuth2 standard requires the use of TLS.
74
+ */
75
+ const authorizationUrl = z.string().default('');
76
+ /**
77
+ * REQUIRED. The token URL to be used for this flow. This MUST be in the
78
+ * form of a URL. The OAuth2 standard requires the use of TLS.
79
+ */
80
+ const tokenUrl = z.string().default('');
81
+ /** Common properties used across all oauth2 flows */
55
82
  const flowsCommon = z.object({
56
- /**
57
- * The URL to be used for obtaining refresh tokens. This MUST be in the form of a
58
- * URL. The OAuth2 standard requires the use of TLS.
59
- */
60
- "refreshUrl": z.string().optional().default(""),
61
- /**
62
- * REQUIRED. The available scopes for the OAuth2 security scheme. A map
63
- * between the scope name and a short description for it. The map MAY be empty.
64
- */
65
- "scopes": z.record(z.string(), z.string().optional().default("")).optional().default({}).catch({}),
66
- "selectedScopes": z.array(z.string()).optional().default([]),
67
- /** Extension to save the client Id associated with an oauth flow */
68
- "x-scalar-client-id": z.string().optional().default(""),
69
- /** The auth token */
70
- "token": z.string().default(""),
71
- /** Additional query parameters for the OAuth authorization request. Example: { prompt: 'consent', audience: 'scalar' }. */
72
- "x-scalar-security-query": z.record(z.string(), z.string()).optional(),
73
- /** Additional body parameters for the OAuth token request. Example: { audience: 'foo' }. */
74
- "x-scalar-security-body": z.record(z.string(), z.string()).optional(),
75
- /** Extension to specify custom token name in the response (defaults to 'access_token') */
76
- "x-tokenName": z.string().optional()
83
+ /**
84
+ * The URL to be used for obtaining refresh tokens. This MUST be in the form of a
85
+ * URL. The OAuth2 standard requires the use of TLS.
86
+ */
87
+ 'refreshUrl': z.string().optional().default(''),
88
+ /**
89
+ * REQUIRED. The available scopes for the OAuth2 security scheme. A map
90
+ * between the scope name and a short description for it. The map MAY be empty.
91
+ */
92
+ 'scopes': z.record(z.string(), z.string().optional().default('')).optional().default({}).catch({}),
93
+ 'selectedScopes': z.array(z.string()).optional().default([]),
94
+ /** Extension to save the client Id associated with an oauth flow */
95
+ 'x-scalar-client-id': z.string().optional().default(''),
96
+ /** The auth token */
97
+ 'token': z.string().default(''),
98
+ /** Additional query parameters for the OAuth authorization request. Example: { prompt: 'consent', audience: 'scalar' }. */
99
+ 'x-scalar-security-query': z.record(z.string(), z.string()).optional(),
100
+ /** Additional body parameters for the OAuth token request. Example: { audience: 'foo' }. */
101
+ 'x-scalar-security-body': z.record(z.string(), z.string()).optional(),
102
+ /** Extension to specify custom token name in the response (defaults to 'access_token') */
103
+ 'x-tokenName': z.string().optional(),
77
104
  });
78
- const defaultRedirectUri = typeof window !== "undefined" ? window.location.origin + window.location.pathname : "";
79
- const pkceOptions = ["SHA-256", "plain", "no"];
80
- const credentialsLocationExtension = z.enum(["header", "body"]).optional();
105
+ /** Setup a default redirect uri if we can */
106
+ const defaultRedirectUri = typeof window !== 'undefined' ? window.location.origin + window.location.pathname : '';
107
+ /** Options for the x-usePkce extension */
108
+ export const pkceOptions = ['SHA-256', 'plain', 'no'];
109
+ const credentialsLocationExtension = z.enum(['header', 'body']).optional();
110
+ /** Oauth2 security scheme */
81
111
  const oasSecuritySchemeOauth2 = commonProps.extend({
82
- type: z.literal("oauth2"),
83
- /** The default scopes for the oauth flow */
84
- "x-default-scopes": z.array(z.string()).optional(),
85
- /** REQUIRED. An object containing configuration information for the flow types supported. */
86
- flows: z.object({
87
- /** Configuration for the OAuth Implicit flow */
88
- implicit: flowsCommon.extend({
89
- "type": z.literal("implicit").default("implicit"),
90
- authorizationUrl,
91
- "x-scalar-redirect-uri": z.string().optional().default(defaultRedirectUri)
92
- }),
93
- /** Configuration for the OAuth Resource Owner Password flow */
94
- password: flowsCommon.extend({
95
- type: z.literal("password").default("password"),
96
- tokenUrl,
97
- clientSecret: z.string().default(""),
98
- username: z.string().default(""),
99
- password: z.string().default(""),
100
- "x-scalar-credentials-location": credentialsLocationExtension
101
- }),
102
- /** Configuration for the OAuth Client Credentials flow. Previously called application in OpenAPI 2.0. */
103
- clientCredentials: flowsCommon.extend({
104
- type: z.literal("clientCredentials").default("clientCredentials"),
105
- tokenUrl,
106
- clientSecret: z.string().default(""),
107
- "x-scalar-credentials-location": credentialsLocationExtension
108
- }),
109
- /** Configuration for the OAuth Authorization Code flow. Previously called accessCode in OpenAPI 2.0.*/
110
- authorizationCode: flowsCommon.extend({
111
- "type": z.literal("authorizationCode").default("authorizationCode"),
112
- authorizationUrl,
113
- "x-usePkce": z.enum(pkceOptions).optional().default("no"),
114
- "x-scalar-redirect-uri": z.string().optional().default(defaultRedirectUri),
115
- tokenUrl,
116
- clientSecret: z.string().default(""),
117
- "x-scalar-credentials-location": credentialsLocationExtension
112
+ type: z.literal('oauth2'),
113
+ /** The default scopes for the oauth flow */
114
+ 'x-default-scopes': z.array(z.string()).optional(),
115
+ /** REQUIRED. An object containing configuration information for the flow types supported. */
116
+ flows: z
117
+ .object({
118
+ /** Configuration for the OAuth Implicit flow */
119
+ implicit: flowsCommon.extend({
120
+ 'type': z.literal('implicit').default('implicit'),
121
+ authorizationUrl,
122
+ 'x-scalar-redirect-uri': z.string().optional().default(defaultRedirectUri),
123
+ }),
124
+ /** Configuration for the OAuth Resource Owner Password flow */
125
+ password: flowsCommon.extend({
126
+ type: z.literal('password').default('password'),
127
+ tokenUrl,
128
+ clientSecret: z.string().default(''),
129
+ username: z.string().default(''),
130
+ password: z.string().default(''),
131
+ 'x-scalar-credentials-location': credentialsLocationExtension,
132
+ }),
133
+ /** Configuration for the OAuth Client Credentials flow. Previously called application in OpenAPI 2.0. */
134
+ clientCredentials: flowsCommon.extend({
135
+ type: z.literal('clientCredentials').default('clientCredentials'),
136
+ tokenUrl,
137
+ clientSecret: z.string().default(''),
138
+ 'x-scalar-credentials-location': credentialsLocationExtension,
139
+ }),
140
+ /** Configuration for the OAuth Authorization Code flow. Previously called accessCode in OpenAPI 2.0.*/
141
+ authorizationCode: flowsCommon.extend({
142
+ 'type': z.literal('authorizationCode').default('authorizationCode'),
143
+ authorizationUrl,
144
+ 'x-usePkce': z.enum(pkceOptions).optional().default('no'),
145
+ 'x-scalar-redirect-uri': z.string().optional().default(defaultRedirectUri),
146
+ tokenUrl,
147
+ clientSecret: z.string().default(''),
148
+ 'x-scalar-credentials-location': credentialsLocationExtension,
149
+ }),
118
150
  })
119
- }).partial().default({
120
- implicit: {
121
- selectedScopes: [],
122
- scopes: {},
123
- "x-scalar-client-id": "",
124
- refreshUrl: "",
125
- token: "",
126
- type: "implicit",
127
- authorizationUrl: "http://localhost:8080",
128
- "x-scalar-redirect-uri": defaultRedirectUri
129
- }
130
- })
151
+ .partial()
152
+ .default({
153
+ implicit: {
154
+ selectedScopes: [],
155
+ scopes: {},
156
+ 'x-scalar-client-id': '',
157
+ refreshUrl: '',
158
+ token: '',
159
+ type: 'implicit',
160
+ authorizationUrl: 'http://localhost:8080',
161
+ 'x-scalar-redirect-uri': defaultRedirectUri,
162
+ },
163
+ }),
131
164
  });
132
- const securityOauthSchema = oasSecuritySchemeOauth2.merge(extendedSecuritySchema);
133
- const oasSecurityRequirementSchema = z.record(z.string(), z.array(z.string()).optional().default([]));
134
- const oasSecuritySchemeSchema = z.union([
135
- oasSecuritySchemeApiKey,
136
- oasSecuritySchemeHttp,
137
- oasSecuritySchemeOauth2,
138
- oasSecuritySchemeOpenId
165
+ export const securityOauthSchema = oasSecuritySchemeOauth2.merge(extendedSecuritySchema);
166
+ // ---------------------------------------------------------------------------
167
+ // Final Types
168
+ /**
169
+ * Security Requirement
170
+ * Lists the required security schemes to execute this operation OR the whole collection/spec.
171
+ * The name used for each property MUST correspond to a security scheme declared in the Security
172
+ * Schemes under the Components Object.
173
+ *
174
+ * The key (name) here will be matched to the key of the securityScheme for linking
175
+ *
176
+ * @see https://spec.openapis.org/oas/latest.html#security-requirement-object
177
+ */
178
+ export const oasSecurityRequirementSchema = z.record(z.string(), z.array(z.string()).optional().default([]));
179
+ /** OAS Compliant security schemes */
180
+ export const oasSecuritySchemeSchema = z.union([
181
+ oasSecuritySchemeApiKey,
182
+ oasSecuritySchemeHttp,
183
+ oasSecuritySchemeOauth2,
184
+ oasSecuritySchemeOpenId,
139
185
  ]);
140
- const securitySchemeSchema = z.discriminatedUnion("type", [securityApiKeySchema, securityHttpSchema, securityOpenIdSchema, securityOauthSchema]).transform((data) => {
141
- if (data.type === "oauth2" && data["x-default-scopes"]?.length) {
142
- const keys = Object.keys(data.flows);
143
- keys.forEach((key) => {
144
- if (data.flows[key]?.selectedScopes && data["x-default-scopes"]) {
145
- data.flows[key].selectedScopes = [data["x-default-scopes"]].flat();
146
- }
147
- });
148
- }
149
- return data;
186
+ /** Extended security schemes for workspace usage */
187
+ export const securitySchemeSchema = z
188
+ .discriminatedUnion('type', [securityApiKeySchema, securityHttpSchema, securityOpenIdSchema, securityOauthSchema])
189
+ .transform((data) => {
190
+ // Set selected scopes from x-default-scopes
191
+ if (data.type === 'oauth2' && data['x-default-scopes']?.length) {
192
+ const keys = Object.keys(data.flows);
193
+ keys.forEach((key) => {
194
+ if (data.flows[key]?.selectedScopes && data['x-default-scopes']) {
195
+ data.flows[key].selectedScopes = [data['x-default-scopes']].flat();
196
+ }
197
+ });
198
+ }
199
+ return data;
150
200
  });
151
- export {
152
- oasSecurityRequirementSchema,
153
- oasSecuritySchemeSchema,
154
- pkceOptions,
155
- securityApiKeySchema,
156
- securityHttpSchema,
157
- securityOauthSchema,
158
- securityOpenIdSchema,
159
- securitySchemeSchema
160
- };
161
- //# sourceMappingURL=security-scheme.js.map
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- export * from "./api-reference/index.js";
2
- import { XScalarStability } from "./legacy/index.js";
3
- export {
4
- XScalarStability
5
- };
6
- //# sourceMappingURL=index.js.map
1
+ /**
2
+ * We should not use these exports anymore, but we need them for commonjs compatibility.
3
+ */
4
+ // biome-ignore lint/performance/noReExportAll: leave this to avoid copy exports
5
+ export * from './api-reference/index.js';
6
+ export { XScalarStability } from './legacy/index.js';
@@ -1,5 +1 @@
1
- import { XScalarStability } from "./reference-config.js";
2
- export {
3
- XScalarStability
4
- };
5
- //# sourceMappingURL=index.js.map
1
+ export { XScalarStability } from './reference-config.js';
@@ -1,10 +1,6 @@
1
- var XScalarStability = /* @__PURE__ */ ((XScalarStability2) => {
2
- XScalarStability2["Deprecated"] = "deprecated";
3
- XScalarStability2["Experimental"] = "experimental";
4
- XScalarStability2["Stable"] = "stable";
5
- return XScalarStability2;
6
- })(XScalarStability || {});
7
- export {
8
- XScalarStability
9
- };
10
- //# sourceMappingURL=reference-config.js.map
1
+ export var XScalarStability;
2
+ (function (XScalarStability) {
3
+ XScalarStability["Deprecated"] = "deprecated";
4
+ XScalarStability["Experimental"] = "experimental";
5
+ XScalarStability["Stable"] = "stable";
6
+ })(XScalarStability || (XScalarStability = {}));
@@ -1,6 +1 @@
1
- import { AVAILABLE_CLIENTS, GROUPED_CLIENTS } from "./snippetz.js";
2
- export {
3
- AVAILABLE_CLIENTS,
4
- GROUPED_CLIENTS
5
- };
6
- //# sourceMappingURL=index.js.map
1
+ export { AVAILABLE_CLIENTS, GROUPED_CLIENTS } from './snippetz.js';