@scalar/types 0.7.3 → 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 +6 -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,55 +1,51 @@
1
- import { z } from "zod";
1
+ import { z } from 'zod';
2
2
  const openApiExtensionSchema = z.object({
3
- /**
4
- * Name of specification extension property. Has to start with `x-`.
5
- *
6
- * @example
7
- * ```yaml
8
- * x-custom-extension: foobar
9
- * ```
10
- */
11
- name: z.string().regex(/^x-/),
12
- /**
13
- * Vue component to render the specification extension
14
- */
15
- component: z.unknown(),
16
- /**
17
- * Custom renderer to render the specification extension
18
- */
19
- renderer: z.unknown().optional()
3
+ /**
4
+ * Name of specification extension property. Has to start with `x-`.
5
+ *
6
+ * @example
7
+ * ```yaml
8
+ * x-custom-extension: foobar
9
+ * ```
10
+ */
11
+ name: z.string().regex(/^x-/),
12
+ /**
13
+ * Vue component to render the specification extension
14
+ */
15
+ component: z.unknown(),
16
+ /**
17
+ * Custom renderer to render the specification extension
18
+ */
19
+ renderer: z.unknown().optional(),
20
20
  });
21
21
  const viewComponentSchema = z.object({
22
- /**
23
- * Vue component to render in the view
24
- */
25
- component: z.unknown(),
26
- /**
27
- * Custom renderer to render the view component (e.g., ReactRenderer)
28
- */
29
- renderer: z.unknown().optional(),
30
- /**
31
- * Additional props to pass to the component
32
- */
33
- props: z.record(z.string(), z.any()).optional()
22
+ /**
23
+ * Vue component to render in the view
24
+ */
25
+ component: z.unknown(),
26
+ /**
27
+ * Custom renderer to render the view component (e.g., ReactRenderer)
28
+ */
29
+ renderer: z.unknown().optional(),
30
+ /**
31
+ * Additional props to pass to the component
32
+ */
33
+ props: z.record(z.string(), z.any()).optional(),
34
34
  });
35
35
  const viewsSchema = z.object({
36
- /**
37
- * Renders after the Models section
38
- */
39
- "content.end": z.array(viewComponentSchema).optional()
40
- });
41
- const apiReferencePluginSchema = z.function({
42
- input: [],
43
- output: z.object({
44
- name: z.string(),
45
- extensions: z.array(openApiExtensionSchema),
46
36
  /**
47
- * Components to render at specific views in the API Reference
37
+ * Renders after the Models section
48
38
  */
49
- views: viewsSchema.optional()
50
- })
39
+ 'content.end': z.array(viewComponentSchema).optional(),
40
+ });
41
+ export const apiReferencePluginSchema = z.function({
42
+ input: [],
43
+ output: z.object({
44
+ name: z.string(),
45
+ extensions: z.array(openApiExtensionSchema),
46
+ /**
47
+ * Components to render at specific views in the API Reference
48
+ */
49
+ views: viewsSchema.optional(),
50
+ }),
51
51
  });
52
- export {
53
- apiReferencePluginSchema
54
- };
55
- //# sourceMappingURL=api-reference-plugin.js.map
@@ -1 +1 @@
1
- //# sourceMappingURL=authentication-configuration.js.map
1
+ export {};
@@ -1,45 +1,44 @@
1
- import { assertType, describe, it } from "vitest";
2
- describe("ApiReferenceConfiguration", () => {
3
- it("ensure we are generating correct types for preferredSecurityScheme", () => {
4
- assertType({ preferredSecurityScheme: "apiKey" });
5
- assertType({ preferredSecurityScheme: ["apiKey", "bearerAuth"] });
6
- assertType({
7
- preferredSecurityScheme: ["apiKey", ["basic", "oauth2"], ["apiKey", "bearerAuth", "oauth2"]]
1
+ import { assertType, describe, it } from 'vitest';
2
+ describe('ApiReferenceConfiguration', () => {
3
+ it('ensure we are generating correct types for preferredSecurityScheme', () => {
4
+ assertType({ preferredSecurityScheme: 'apiKey' });
5
+ assertType({ preferredSecurityScheme: ['apiKey', 'bearerAuth'] });
6
+ assertType({
7
+ preferredSecurityScheme: ['apiKey', ['basic', 'oauth2'], ['apiKey', 'bearerAuth', 'oauth2']],
8
+ });
9
+ assertType({
10
+ // @ts-expect-error incorrect type
11
+ preferredSecurityScheme: 47,
12
+ });
13
+ assertType({
14
+ // @ts-expect-error incorrect type
15
+ preferredSecurityScheme: [22, null],
16
+ });
8
17
  });
9
- assertType({
10
- // @ts-expect-error incorrect type
11
- preferredSecurityScheme: 47
18
+ it('ensure we are generating correct types for securitySchemes', () => {
19
+ assertType({
20
+ securitySchemes: {
21
+ apiKey: { type: 'apiKey', name: 'api_key', in: 'header' },
22
+ },
23
+ });
24
+ assertType({
25
+ securitySchemes: {
26
+ bearerAuth: { type: 'http', scheme: 'bearer', bearerFormat: 'JWT' },
27
+ },
28
+ });
29
+ assertType({
30
+ securitySchemes: {
31
+ oauth2: {
32
+ type: 'oauth2',
33
+ flows: {
34
+ implicit: { scopes: { 'read:items': 'Read access to items' } },
35
+ password: {
36
+ username: 'username',
37
+ password: 'password',
38
+ },
39
+ },
40
+ },
41
+ },
42
+ });
12
43
  });
13
- assertType({
14
- // @ts-expect-error incorrect type
15
- preferredSecurityScheme: [22, null]
16
- });
17
- });
18
- it("ensure we are generating correct types for securitySchemes", () => {
19
- assertType({
20
- securitySchemes: {
21
- apiKey: { type: "apiKey", name: "api_key", in: "header" }
22
- }
23
- });
24
- assertType({
25
- securitySchemes: {
26
- bearerAuth: { type: "http", scheme: "bearer", bearerFormat: "JWT" }
27
- }
28
- });
29
- assertType({
30
- securitySchemes: {
31
- oauth2: {
32
- type: "oauth2",
33
- flows: {
34
- implicit: { scopes: { "read:items": "Read access to items" } },
35
- password: {
36
- username: "username",
37
- password: "password"
38
- }
39
- }
40
- }
41
- }
42
- });
43
- });
44
44
  });
45
- //# sourceMappingURL=authentication-configuration.test-d.js.map
@@ -1,147 +1,151 @@
1
- import z from "zod";
2
- import { apiClientPluginSchema } from "./api-client-plugin.js";
3
- const OLD_PROXY_URL = "https://api.scalar.com/request-proxy";
4
- const NEW_PROXY_URL = "https://proxy.scalar.com";
5
- const baseConfigurationSchema = z.object({
6
- /**
7
- * The title of the OpenAPI document.
8
- *
9
- * @example 'Scalar Galaxy'
10
- */
11
- title: z.string().optional(),
12
- /**
13
- * The slug of the OpenAPI document used in the URL.
14
- *
15
- * If none is passed, the title will be used.
16
- *
17
- * If no title is used, it'll just use the index.
18
- *
19
- * @example 'scalar-galaxy'
20
- */
21
- slug: z.string().optional(),
22
- /** Prefill authentication */
23
- authentication: z.any().optional(),
24
- // Temp until we bring in the new auth
25
- /** Base URL for the API server */
26
- baseServerURL: z.string().optional(),
27
- /**
28
- * Whether to hide the client button
29
- * @default false
30
- */
31
- hideClientButton: z.boolean().optional().default(false).catch(false),
32
- /** URL to a request proxy for the API client */
33
- proxyUrl: z.string().optional(),
34
- /** Key used with CTRL/CMD to open the search modal (defaults to 'k' e.g. CMD+k) */
35
- searchHotKey: z.enum([
36
- "a",
37
- "b",
38
- "c",
39
- "d",
40
- "e",
41
- "f",
42
- "g",
43
- "h",
44
- "i",
45
- "j",
46
- "k",
47
- "l",
48
- "m",
49
- "n",
50
- "o",
51
- "p",
52
- "q",
53
- "r",
54
- "s",
55
- "t",
56
- "u",
57
- "v",
58
- "w",
59
- "x",
60
- "y",
61
- "z"
62
- ]).optional(),
63
- /** List of OpenAPI server objects */
64
- servers: z.array(z.any()).optional(),
65
- // Using any for OpenAPIV3_1.ServerObject
66
- /**
67
- * Whether to show the sidebar
68
- * @default true
69
- */
70
- showSidebar: z.boolean().optional().default(true).catch(true),
71
- /**
72
- * Whether and when to show the developer tools.
73
- *
74
- * @default 'localhost' to only show the toolbar on localhost or similar hosts
75
- */
76
- showDeveloperTools: z.enum(["always", "localhost", "never"]).optional().default("localhost").catch("localhost"),
77
- /**
78
- * Sets the visibility of the developer tools
79
- * @default 'localhost' to only show the toolbar on localhost or similar hosts
80
- * @deprecated Use showDeveloperTools instead
81
- */
82
- showToolbar: z.enum(["always", "localhost", "never"]).optional().default("localhost").catch("localhost"),
83
- /**
84
- * Whether to use the operation summary or the operation path for the sidebar and search
85
- * @default 'summary'
86
- */
87
- operationTitleSource: z.enum(["summary", "path"]).optional().default("summary").catch("summary"),
88
- /** A string to use one of the color presets */
89
- theme: z.enum([
90
- "alternate",
91
- "default",
92
- "moon",
93
- "purple",
94
- "solarized",
95
- "bluePlanet",
96
- "deepSpace",
97
- "saturn",
98
- "kepler",
99
- "elysiajs",
100
- "fastify",
101
- "mars",
102
- "laserwave",
103
- "none"
104
- ]).optional().default("default").catch("default"),
105
- /** Integration type identifier */
106
- _integration: z.enum([
107
- "adonisjs",
108
- "astro",
109
- "docusaurus",
110
- "dotnet",
111
- "elysiajs",
112
- "express",
113
- "fastapi",
114
- "fastify",
115
- "go",
116
- "hono",
117
- "html",
118
- "laravel",
119
- "litestar",
120
- "nestjs",
121
- "nextjs",
122
- "nitro",
123
- "nuxt",
124
- "platformatic",
125
- "react",
126
- "rust",
127
- "svelte",
128
- "vue"
129
- ]).nullable().optional(),
130
- /** onRequestSent is fired when a request is sent */
131
- onRequestSent: z.function({
132
- input: [z.string()],
133
- output: z.void()
134
- }).optional(),
135
- /** Whether to persist auth to local storage */
136
- persistAuth: z.boolean().optional().default(false).catch(false),
137
- /** Plugins for the API client */
138
- plugins: z.array(apiClientPluginSchema).optional(),
139
- /** Enables / disables telemetry*/
140
- telemetry: z.boolean().optional().default(true)
1
+ import z from 'zod';
2
+ import { apiClientPluginSchema } from './api-client-plugin.js';
3
+ export const OLD_PROXY_URL = 'https://api.scalar.com/request-proxy';
4
+ export const NEW_PROXY_URL = 'https://proxy.scalar.com';
5
+ /** Shared configuration for the Api Reference and Api Client */
6
+ export const baseConfigurationSchema = z.object({
7
+ /**
8
+ * The title of the OpenAPI document.
9
+ *
10
+ * @example 'Scalar Galaxy'
11
+ */
12
+ title: z.string().optional(),
13
+ /**
14
+ * The slug of the OpenAPI document used in the URL.
15
+ *
16
+ * If none is passed, the title will be used.
17
+ *
18
+ * If no title is used, it'll just use the index.
19
+ *
20
+ * @example 'scalar-galaxy'
21
+ */
22
+ slug: z.string().optional(),
23
+ /** Prefill authentication */
24
+ authentication: z.any().optional(), // Temp until we bring in the new auth
25
+ /** Base URL for the API server */
26
+ baseServerURL: z.string().optional(),
27
+ /**
28
+ * Whether to hide the client button
29
+ * @default false
30
+ */
31
+ hideClientButton: z.boolean().optional().default(false).catch(false),
32
+ /** URL to a request proxy for the API client */
33
+ proxyUrl: z.string().optional(),
34
+ /** Key used with CTRL/CMD to open the search modal (defaults to 'k' e.g. CMD+k) */
35
+ searchHotKey: z
36
+ .enum([
37
+ 'a',
38
+ 'b',
39
+ 'c',
40
+ 'd',
41
+ 'e',
42
+ 'f',
43
+ 'g',
44
+ 'h',
45
+ 'i',
46
+ 'j',
47
+ 'k',
48
+ 'l',
49
+ 'm',
50
+ 'n',
51
+ 'o',
52
+ 'p',
53
+ 'q',
54
+ 'r',
55
+ 's',
56
+ 't',
57
+ 'u',
58
+ 'v',
59
+ 'w',
60
+ 'x',
61
+ 'y',
62
+ 'z',
63
+ ])
64
+ .optional(),
65
+ /** List of OpenAPI server objects */
66
+ servers: z.array(z.any()).optional(), // Using any for OpenAPIV3_1.ServerObject
67
+ /**
68
+ * Whether to show the sidebar
69
+ * @default true
70
+ */
71
+ showSidebar: z.boolean().optional().default(true).catch(true),
72
+ /**
73
+ * Whether and when to show the developer tools.
74
+ *
75
+ * @default 'localhost' to only show the toolbar on localhost or similar hosts
76
+ */
77
+ showDeveloperTools: z.enum(['always', 'localhost', 'never']).optional().default('localhost').catch('localhost'),
78
+ /**
79
+ * Sets the visibility of the developer tools
80
+ * @default 'localhost' to only show the toolbar on localhost or similar hosts
81
+ * @deprecated Use showDeveloperTools instead
82
+ */
83
+ showToolbar: z.enum(['always', 'localhost', 'never']).optional().default('localhost').catch('localhost'),
84
+ /**
85
+ * Whether to use the operation summary or the operation path for the sidebar and search
86
+ * @default 'summary'
87
+ */
88
+ operationTitleSource: z.enum(['summary', 'path']).optional().default('summary').catch('summary'),
89
+ /** A string to use one of the color presets */
90
+ theme: z
91
+ .enum([
92
+ 'alternate',
93
+ 'default',
94
+ 'moon',
95
+ 'purple',
96
+ 'solarized',
97
+ 'bluePlanet',
98
+ 'deepSpace',
99
+ 'saturn',
100
+ 'kepler',
101
+ 'elysiajs',
102
+ 'fastify',
103
+ 'mars',
104
+ 'laserwave',
105
+ 'none',
106
+ ])
107
+ .optional()
108
+ .default('default')
109
+ .catch('default'),
110
+ /** Integration type identifier */
111
+ _integration: z
112
+ .enum([
113
+ 'adonisjs',
114
+ 'astro',
115
+ 'docusaurus',
116
+ 'dotnet',
117
+ 'elysiajs',
118
+ 'express',
119
+ 'fastapi',
120
+ 'fastify',
121
+ 'go',
122
+ 'hono',
123
+ 'html',
124
+ 'laravel',
125
+ 'litestar',
126
+ 'nestjs',
127
+ 'nextjs',
128
+ 'nitro',
129
+ 'nuxt',
130
+ 'platformatic',
131
+ 'react',
132
+ 'rust',
133
+ 'svelte',
134
+ 'vue',
135
+ ])
136
+ .nullable()
137
+ .optional(),
138
+ /** onRequestSent is fired when a request is sent */
139
+ onRequestSent: z
140
+ .function({
141
+ input: [z.string()],
142
+ output: z.void(),
143
+ })
144
+ .optional(),
145
+ /** Whether to persist auth to local storage */
146
+ persistAuth: z.boolean().optional().default(false).catch(false),
147
+ /** Plugins for the API client */
148
+ plugins: z.array(apiClientPluginSchema).optional(),
149
+ /** Enables / disables telemetry*/
150
+ telemetry: z.boolean().optional().default(true),
141
151
  });
142
- export {
143
- NEW_PROXY_URL,
144
- OLD_PROXY_URL,
145
- baseConfigurationSchema
146
- };
147
- //# sourceMappingURL=base-configuration.js.map
@@ -1 +1 @@
1
- //# sourceMappingURL=html-api.js.map
1
+ export {};
@@ -1,21 +1,20 @@
1
- import { z } from "zod";
2
- const htmlRenderingConfigurationSchema = z.object({
3
- /**
4
- * The URL to the Scalar API Reference JS CDN.
5
- *
6
- * Use this to pin a specific version of the Scalar API Reference.
7
- *
8
- * @default https://cdn.jsdelivr.net/npm/@scalar/api-reference
9
- *
10
- * @example https://cdn.jsdelivr.net/npm/@scalar/api-reference@1.25.122
11
- */
12
- cdn: z.string().optional().default("https://cdn.jsdelivr.net/npm/@scalar/api-reference"),
13
- /**
14
- * The title of the page.
15
- */
16
- pageTitle: z.string().optional().default("Scalar API Reference")
1
+ import { z } from 'zod';
2
+ /**
3
+ * Zod schema for HTML rendering configuration
4
+ */
5
+ export const htmlRenderingConfigurationSchema = z.object({
6
+ /**
7
+ * The URL to the Scalar API Reference JS CDN.
8
+ *
9
+ * Use this to pin a specific version of the Scalar API Reference.
10
+ *
11
+ * @default https://cdn.jsdelivr.net/npm/@scalar/api-reference
12
+ *
13
+ * @example https://cdn.jsdelivr.net/npm/@scalar/api-reference@1.25.122
14
+ */
15
+ cdn: z.string().optional().default('https://cdn.jsdelivr.net/npm/@scalar/api-reference'),
16
+ /**
17
+ * The title of the page.
18
+ */
19
+ pageTitle: z.string().optional().default('Scalar API Reference'),
17
20
  });
18
- export {
19
- htmlRenderingConfigurationSchema
20
- };
21
- //# sourceMappingURL=html-rendering-configuration.js.map
@@ -1,26 +1,5 @@
1
- import {
2
- apiClientConfigurationSchema
3
- } from "./api-client-configuration.js";
4
- import { apiClientPluginSchema, hooksSchema } from "./api-client-plugin.js";
5
- import {
6
- apiReferenceConfigurationSchema,
7
- apiReferenceConfigurationWithSourceSchema,
8
- isConfigurationWithSources
9
- } from "./api-reference-configuration.js";
10
- import {
11
- htmlRenderingConfigurationSchema
12
- } from "./html-rendering-configuration.js";
13
- import {
14
- sourceConfigurationSchema
15
- } from "./source-configuration.js";
16
- export {
17
- apiClientConfigurationSchema,
18
- apiClientPluginSchema,
19
- apiReferenceConfigurationSchema,
20
- apiReferenceConfigurationWithSourceSchema,
21
- hooksSchema,
22
- htmlRenderingConfigurationSchema,
23
- isConfigurationWithSources,
24
- sourceConfigurationSchema
25
- };
26
- //# sourceMappingURL=index.js.map
1
+ export { apiClientConfigurationSchema, } from './api-client-configuration.js';
2
+ export { apiClientPluginSchema, hooksSchema } from './api-client-plugin.js';
3
+ export { apiReferenceConfigurationSchema, apiReferenceConfigurationWithSourceSchema, isConfigurationWithSources, } from './api-reference-configuration.js';
4
+ export { htmlRenderingConfigurationSchema, } from './html-rendering-configuration.js';
5
+ export { sourceConfigurationSchema, } from './source-configuration.js';