@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.
- package/CHANGELOG.md +15 -0
- package/dist/api-reference/api-client-configuration.js +3 -7
- package/dist/api-reference/api-client-plugin.js +32 -30
- package/dist/api-reference/api-reference-configuration.js +404 -361
- package/dist/api-reference/api-reference-plugin.js +43 -47
- package/dist/api-reference/authentication-configuration.js +1 -1
- package/dist/api-reference/authentication-configuration.test-d.js +41 -42
- package/dist/api-reference/base-configuration.js +150 -146
- package/dist/api-reference/html-api.js +1 -1
- package/dist/api-reference/html-rendering-configuration.js +19 -20
- package/dist/api-reference/index.js +5 -26
- package/dist/api-reference/source-configuration.js +105 -96
- package/dist/entities/index.js +1 -21
- package/dist/entities/security-scheme.js +179 -140
- package/dist/index.js +6 -6
- package/dist/legacy/index.js +1 -5
- package/dist/legacy/reference-config.js +6 -10
- package/dist/snippetz/index.js +1 -6
- package/dist/snippetz/snippetz.js +35 -31
- package/dist/snippetz/snippetz.test-d.js +30 -27
- package/dist/utils/index.js +1 -5
- package/dist/utils/nanoid.js +7 -7
- package/dist/utils/utility-types.js +1 -1
- package/package.json +5 -9
- package/dist/api-reference/api-client-configuration.js.map +0 -7
- package/dist/api-reference/api-client-plugin.js.map +0 -7
- package/dist/api-reference/api-reference-configuration.js.map +0 -7
- package/dist/api-reference/api-reference-plugin.js.map +0 -7
- package/dist/api-reference/authentication-configuration.js.map +0 -7
- package/dist/api-reference/authentication-configuration.test-d.js.map +0 -7
- package/dist/api-reference/base-configuration.js.map +0 -7
- package/dist/api-reference/html-api.js.map +0 -7
- package/dist/api-reference/html-rendering-configuration.js.map +0 -7
- package/dist/api-reference/index.js.map +0 -7
- package/dist/api-reference/source-configuration.js.map +0 -7
- package/dist/entities/index.js.map +0 -7
- package/dist/entities/security-scheme.js.map +0 -7
- package/dist/index.js.map +0 -7
- package/dist/legacy/index.js.map +0 -7
- package/dist/legacy/reference-config.js.map +0 -7
- package/dist/snippetz/index.js.map +0 -7
- package/dist/snippetz/snippetz.js.map +0 -7
- package/dist/snippetz/snippetz.test-d.js.map +0 -7
- package/dist/utils/index.js.map +0 -7
- package/dist/utils/nanoid.js.map +0 -7
- package/dist/utils/utility-types.js.map +0 -7
|
@@ -1,100 +1,109 @@
|
|
|
1
|
-
import z from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
*
|
|
92
|
-
*
|
|
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
|
-
|
|
95
|
-
|
|
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
|
package/dist/entities/index.js
CHANGED
|
@@ -1,21 +1 @@
|
|
|
1
|
-
|
|
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
|
|
2
|
-
import { nanoidSchema } from
|
|
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
|
-
|
|
5
|
-
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
15
|
+
// ---------------------------------------------------------------------------
|
|
16
|
+
// API KEY
|
|
17
|
+
const securitySchemeApiKeyIn = ['query', 'header', 'cookie'];
|
|
13
18
|
const oasSecuritySchemeApiKey = commonProps.extend({
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
-
|
|
54
|
-
|
|
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
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
-
|
|
79
|
-
const
|
|
80
|
-
|
|
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
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
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
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
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
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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';
|
package/dist/legacy/index.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
var XScalarStability
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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 = {}));
|