@scalar/types 0.1.13 → 0.1.15

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 (75) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/api-reference/api-reference-configuration.d.ts +41 -11
  3. package/dist/api-reference/api-reference-configuration.d.ts.map +1 -1
  4. package/dist/api-reference/api-reference-configuration.js +274 -290
  5. package/dist/api-reference/api-reference-configuration.js.map +7 -0
  6. package/dist/api-reference/api-reference-configuration.test.js +224 -0
  7. package/dist/api-reference/api-reference-configuration.test.js.map +7 -0
  8. package/dist/api-reference/api-reference-plugin.d.ts +16 -2
  9. package/dist/api-reference/api-reference-plugin.d.ts.map +1 -1
  10. package/dist/api-reference/api-reference-plugin.js +28 -22
  11. package/dist/api-reference/api-reference-plugin.js.map +7 -0
  12. package/dist/api-reference/authentication-configuration.d.ts +2 -2
  13. package/dist/api-reference/authentication-configuration.d.ts.map +1 -1
  14. package/dist/api-reference/authentication-configuration.js +1 -0
  15. package/dist/api-reference/authentication-configuration.js.map +7 -0
  16. package/dist/api-reference/authentication-configuration.test-d.js +45 -0
  17. package/dist/api-reference/authentication-configuration.test-d.js.map +7 -0
  18. package/dist/api-reference/html-api.d.ts +1 -1
  19. package/dist/api-reference/html-api.d.ts.map +1 -1
  20. package/dist/api-reference/html-api.js +1 -0
  21. package/dist/api-reference/html-api.js.map +7 -0
  22. package/dist/api-reference/html-rendering-configuration.d.ts +1 -1
  23. package/dist/api-reference/html-rendering-configuration.d.ts.map +1 -1
  24. package/dist/api-reference/html-rendering-configuration.js +19 -21
  25. package/dist/api-reference/html-rendering-configuration.js.map +7 -0
  26. package/dist/api-reference/index.d.ts +4 -5
  27. package/dist/api-reference/index.d.ts.map +1 -1
  28. package/dist/api-reference/index.js +17 -3
  29. package/dist/api-reference/index.js.map +7 -0
  30. package/dist/entities/index.d.ts +1 -1
  31. package/dist/entities/index.d.ts.map +1 -1
  32. package/dist/entities/index.js +21 -1
  33. package/dist/entities/index.js.map +7 -0
  34. package/dist/entities/security-scheme.d.ts +104 -0
  35. package/dist/entities/security-scheme.d.ts.map +1 -1
  36. package/dist/entities/security-scheme.js +118 -157
  37. package/dist/entities/security-scheme.js.map +7 -0
  38. package/dist/entities/security-scheme.test.js +318 -0
  39. package/dist/entities/security-scheme.test.js.map +7 -0
  40. package/dist/index.d.ts +2 -2
  41. package/dist/index.d.ts.map +1 -1
  42. package/dist/index.js +3 -4
  43. package/dist/index.js.map +7 -0
  44. package/dist/legacy/index.d.ts +1 -1
  45. package/dist/legacy/index.d.ts.map +1 -1
  46. package/dist/legacy/index.js +2 -1
  47. package/dist/legacy/index.js.map +7 -0
  48. package/dist/legacy/reference-config.d.ts +2 -2
  49. package/dist/legacy/reference-config.d.ts.map +1 -1
  50. package/dist/legacy/reference-config.js +10 -8
  51. package/dist/legacy/reference-config.js.map +7 -0
  52. package/dist/snippetz/index.d.ts +1 -1
  53. package/dist/snippetz/index.d.ts.map +1 -1
  54. package/dist/snippetz/index.js +2 -1
  55. package/dist/snippetz/index.js.map +7 -0
  56. package/dist/snippetz/snippetz.d.ts +1 -1
  57. package/dist/snippetz/snippetz.d.ts.map +1 -1
  58. package/dist/snippetz/snippetz.js +39 -40
  59. package/dist/snippetz/snippetz.js.map +7 -0
  60. package/dist/snippetz/snippetz.test-d.js +28 -0
  61. package/dist/snippetz/snippetz.test-d.js.map +7 -0
  62. package/dist/utils/index.d.ts +2 -2
  63. package/dist/utils/index.d.ts.map +1 -1
  64. package/dist/utils/index.js +5 -1
  65. package/dist/utils/index.js.map +7 -0
  66. package/dist/utils/nanoid.js +7 -11
  67. package/dist/utils/nanoid.js.map +7 -0
  68. package/dist/utils/nanoid.test.js +29 -0
  69. package/dist/utils/nanoid.test.js.map +7 -0
  70. package/dist/utils/utility-types.js +1 -0
  71. package/dist/utils/utility-types.js.map +7 -0
  72. package/package.json +6 -10
  73. package/dist/api-reference/helpers/migrate-theme-variables.d.ts +0 -10
  74. package/dist/api-reference/helpers/migrate-theme-variables.d.ts.map +0 -1
  75. package/dist/api-reference/helpers/migrate-theme-variables.js +0 -22
@@ -1,217 +1,211 @@
1
- import { z } from 'zod';
2
- import { ApiReferencePluginSchema } from './api-reference-plugin.js';
3
- import { migrateThemeVariables } from './helpers/migrate-theme-variables.js';
4
-
5
- /** Available theme presets for the API reference */
1
+ import { z } from "zod";
2
+ import { ApiReferencePluginSchema } from "./api-reference-plugin.js";
6
3
  const themeIdEnum = z.enum([
7
- 'alternate',
8
- 'default',
9
- 'moon',
10
- 'purple',
11
- 'solarized',
12
- 'bluePlanet',
13
- 'deepSpace',
14
- 'saturn',
15
- 'kepler',
16
- 'elysiajs',
17
- 'fastify',
18
- 'mars',
19
- 'laserwave',
20
- 'none',
4
+ "alternate",
5
+ "default",
6
+ "moon",
7
+ "purple",
8
+ "solarized",
9
+ "bluePlanet",
10
+ "deepSpace",
11
+ "saturn",
12
+ "kepler",
13
+ "elysiajs",
14
+ "fastify",
15
+ "mars",
16
+ "laserwave",
17
+ "none"
21
18
  ]);
22
- /** Valid keys that can be used with CTRL/CMD to open the search modal */
23
19
  const searchHotKeyEnum = z.enum([
24
- 'a',
25
- 'b',
26
- 'c',
27
- 'd',
28
- 'e',
29
- 'f',
30
- 'g',
31
- 'h',
32
- 'i',
33
- 'j',
34
- 'k',
35
- 'l',
36
- 'm',
37
- 'n',
38
- 'o',
39
- 'p',
40
- 'q',
41
- 'r',
42
- 's',
43
- 't',
44
- 'u',
45
- 'v',
46
- 'w',
47
- 'x',
48
- 'y',
49
- 'z',
20
+ "a",
21
+ "b",
22
+ "c",
23
+ "d",
24
+ "e",
25
+ "f",
26
+ "g",
27
+ "h",
28
+ "i",
29
+ "j",
30
+ "k",
31
+ "l",
32
+ "m",
33
+ "n",
34
+ "o",
35
+ "p",
36
+ "q",
37
+ "r",
38
+ "s",
39
+ "t",
40
+ "u",
41
+ "v",
42
+ "w",
43
+ "x",
44
+ "y",
45
+ "z"
50
46
  ]);
51
- /** Supported integration types */
52
- const integrationEnum = z
53
- .enum([
54
- 'adonisjs',
55
- 'docusaurus',
56
- 'dotnet',
57
- 'elysiajs',
58
- 'express',
59
- 'fastapi',
60
- 'fastify',
61
- 'go',
62
- 'hono',
63
- 'html',
64
- 'laravel',
65
- 'litestar',
66
- 'nestjs',
67
- 'nextjs',
68
- 'nitro',
69
- 'nuxt',
70
- 'platformatic',
71
- 'react',
72
- 'rust',
73
- 'svelte',
74
- 'vue',
75
- ])
76
- .nullable();
77
- /** Configuration for the OpenAPI/Swagger specification */
47
+ const integrationEnum = z.enum([
48
+ "adonisjs",
49
+ "docusaurus",
50
+ "dotnet",
51
+ "elysiajs",
52
+ "express",
53
+ "fastapi",
54
+ "fastify",
55
+ "go",
56
+ "hono",
57
+ "html",
58
+ "laravel",
59
+ "litestar",
60
+ "nestjs",
61
+ "nextjs",
62
+ "nitro",
63
+ "nuxt",
64
+ "platformatic",
65
+ "react",
66
+ "rust",
67
+ "svelte",
68
+ "vue"
69
+ ]).nullable();
78
70
  const specConfigurationSchema = z.object({
79
- /**
80
- * URL to an OpenAPI/Swagger document
81
- *
82
- * @deprecated Please move `url` to the top level and remove the `spec` prefix.
83
- *
84
- * @example
85
- * ```ts
86
- * const oldConfiguration = {
87
- * spec: {
88
- * url: 'https://example.com/openapi.json',
89
- * },
90
- * }
91
- *
92
- * const newConfiguration = {
93
- * url: 'https://example.com/openapi.json',
94
- * }
95
- * ```
96
- **/
97
- url: z.string().optional(),
98
- /**
99
- * Directly embed the OpenAPI document.
100
- * Can be a string, object, function returning an object, or null.
101
- *
102
- * @remarks It's recommended to pass a URL instead of content.
103
- *
104
- * @deprecated Please move `content` to the top level and remove the `spec` prefix.
105
- *
106
- * @example
107
- * ```ts
108
- * const oldConfiguration = {
109
- * spec: {
110
- * content: '…',
111
- * },
112
- * }
113
- *
114
- * const newConfiguration = {
115
- * content: '…',
116
- * }
117
- * ```
118
- **/
119
- content: z.union([z.string(), z.record(z.any()), z.function().returns(z.record(z.any())), z.null()]).optional(),
120
- /**
121
- * The title of the OpenAPI document.
122
- *
123
- * @example 'Scalar Galaxy'
124
- *
125
- * @deprecated Please move `title` to the top level and remove the `spec` prefix.
126
- */
127
- title: z.string().optional(),
128
- /**
129
- * The slug of the OpenAPI document used in the URL.
130
- *
131
- * If none is passed, the title will be used.
132
- *
133
- * If no title is used, it'll just use the index.
134
- *
135
- * @example 'scalar-galaxy'
136
- *
137
- * @deprecated Please move `slug` to the top level and remove the `spec` prefix.
138
- */
139
- slug: z.string().optional(),
71
+ /**
72
+ * URL to an OpenAPI/Swagger document
73
+ *
74
+ * @deprecated Please move `url` to the top level and remove the `spec` prefix.
75
+ *
76
+ * @example
77
+ * ```ts
78
+ * const oldConfiguration = {
79
+ * spec: {
80
+ * url: 'https://example.com/openapi.json',
81
+ * },
82
+ * }
83
+ *
84
+ * const newConfiguration = {
85
+ * url: 'https://example.com/openapi.json',
86
+ * }
87
+ * ```
88
+ **/
89
+ url: z.string().optional(),
90
+ /**
91
+ * Directly embed the OpenAPI document.
92
+ * Can be a string, object, function returning an object, or null.
93
+ *
94
+ * @remarks It's recommended to pass a URL instead of content.
95
+ *
96
+ * @deprecated Please move `content` to the top level and remove the `spec` prefix.
97
+ *
98
+ * @example
99
+ * ```ts
100
+ * const oldConfiguration = {
101
+ * spec: {
102
+ * content: '…',
103
+ * },
104
+ * }
105
+ *
106
+ * const newConfiguration = {
107
+ * content: '…',
108
+ * }
109
+ * ```
110
+ **/
111
+ content: z.union([z.string(), z.record(z.any()), z.function().returns(z.record(z.any())), z.null()]).optional(),
112
+ /**
113
+ * The title of the OpenAPI document.
114
+ *
115
+ * @example 'Scalar Galaxy'
116
+ *
117
+ * @deprecated Please move `title` to the top level and remove the `spec` prefix.
118
+ */
119
+ title: z.string().optional(),
120
+ /**
121
+ * The slug of the OpenAPI document used in the URL.
122
+ *
123
+ * If none is passed, the title will be used.
124
+ *
125
+ * If no title is used, it'll just use the index.
126
+ *
127
+ * @example 'scalar-galaxy'
128
+ *
129
+ * @deprecated Please move `slug` to the top level and remove the `spec` prefix.
130
+ */
131
+ slug: z.string().optional()
140
132
  });
141
- /** Configuration for path-based routing */
142
133
  const pathRoutingSchema = z.object({
143
- /** Base path for the API reference */
144
- basePath: z.string(),
134
+ /** Base path for the API reference */
135
+ basePath: z.string()
145
136
  });
146
- /** Configuration for the Api Client */
147
137
  const apiClientConfigurationSchema = z.object({
148
- /**
149
- * URL to an OpenAPI/Swagger document
150
- **/
151
- url: z.string().optional(),
152
- /**
153
- * Directly embed the OpenAPI document.
154
- * Can be a string, object, function returning an object, or null.
155
- *
156
- * @remarks It's recommended to pass a URL instead of content.
157
- **/
158
- content: z.union([z.string(), z.record(z.any()), z.function().returns(z.record(z.any())), z.null()]).optional(),
159
- /**
160
- * The title of the OpenAPI document.
161
- *
162
- * @example 'Scalar Galaxy'
163
- */
164
- title: z.string().optional(),
165
- /**
166
- * The slug of the OpenAPI document used in the URL.
167
- *
168
- * If none is passed, the title will be used.
169
- *
170
- * If no title is used, it'll just use the index.
171
- *
172
- * @example 'scalar-galaxy'
173
- */
174
- slug: z.string().optional(),
175
- /**
176
- * The OpenAPI/Swagger document to render
177
- *
178
- * @deprecated Use `url` and `content` on the top level instead.
179
- **/
180
- spec: specConfigurationSchema.optional(),
181
- /** Prefill authentication */
182
- authentication: z.any().optional(), // Temp until we bring in the new auth
183
- /** Base URL for the API server */
184
- baseServerURL: z.string().optional(),
185
- /**
186
- * Whether to hide the client button
187
- * @default false
188
- */
189
- hideClientButton: z.boolean().optional().default(false).catch(false),
190
- /** URL to a request proxy for the API client */
191
- proxyUrl: z.string().optional(),
192
- /** Key used with CTRL/CMD to open the search modal (defaults to 'k' e.g. CMD+k) */
193
- searchHotKey: searchHotKeyEnum.optional(),
194
- /** List of OpenAPI server objects */
195
- servers: z.array(z.any()).optional(), // Using any for OpenAPIV3_1.ServerObject
196
- /**
197
- * Whether to show the sidebar
198
- * @default true
199
- */
200
- showSidebar: z.boolean().optional().default(true).catch(true),
201
- /** A string to use one of the color presets */
202
- theme: themeIdEnum.optional().default('default').catch('default'),
203
- /** Integration type identifier */
204
- _integration: integrationEnum.optional(),
205
- /** onRequestSent is fired when a request is sent */
206
- onRequestSent: z.function().args(z.string()).returns(z.void()).optional(),
138
+ /**
139
+ * URL to an OpenAPI/Swagger document
140
+ **/
141
+ url: z.string().optional(),
142
+ /**
143
+ * Directly embed the OpenAPI document.
144
+ * Can be a string, object, function returning an object, or null.
145
+ *
146
+ * @remarks It's recommended to pass a URL instead of content.
147
+ **/
148
+ content: z.union([z.string(), z.record(z.any()), z.function().returns(z.record(z.any())), z.null()]).optional(),
149
+ /**
150
+ * The title of the OpenAPI document.
151
+ *
152
+ * @example 'Scalar Galaxy'
153
+ */
154
+ title: z.string().optional(),
155
+ /**
156
+ * The slug of the OpenAPI document used in the URL.
157
+ *
158
+ * If none is passed, the title will be used.
159
+ *
160
+ * If no title is used, it'll just use the index.
161
+ *
162
+ * @example 'scalar-galaxy'
163
+ */
164
+ slug: z.string().optional(),
165
+ /**
166
+ * The OpenAPI/Swagger document to render
167
+ *
168
+ * @deprecated Use `url` and `content` on the top level instead.
169
+ **/
170
+ spec: specConfigurationSchema.optional(),
171
+ /** Prefill authentication */
172
+ authentication: z.any().optional(),
173
+ // Temp until we bring in the new auth
174
+ /** Base URL for the API server */
175
+ baseServerURL: z.string().optional(),
176
+ /**
177
+ * Whether to hide the client button
178
+ * @default false
179
+ */
180
+ hideClientButton: z.boolean().optional().default(false).catch(false),
181
+ /** URL to a request proxy for the API client */
182
+ proxyUrl: z.string().optional(),
183
+ /** Key used with CTRL/CMD to open the search modal (defaults to 'k' e.g. CMD+k) */
184
+ searchHotKey: searchHotKeyEnum.optional(),
185
+ /** List of OpenAPI server objects */
186
+ servers: z.array(z.any()).optional(),
187
+ // Using any for OpenAPIV3_1.ServerObject
188
+ /**
189
+ * Whether to show the sidebar
190
+ * @default true
191
+ */
192
+ showSidebar: z.boolean().optional().default(true).catch(true),
193
+ /** A string to use one of the color presets */
194
+ theme: themeIdEnum.optional().default("default").catch("default"),
195
+ /** Integration type identifier */
196
+ _integration: integrationEnum.optional(),
197
+ /** onRequestSent is fired when a request is sent */
198
+ onRequestSent: z.function().args(z.string()).returns(z.void()).optional(),
199
+ /** Whether to persist auth to local storage */
200
+ persistAuth: z.boolean().optional().default(false).catch(false)
207
201
  });
208
- /** Configuration for the Api Client without the transform since it cannot be merged */
209
- const _apiReferenceConfigurationSchema = apiClientConfigurationSchema.merge(z.object({
202
+ const _apiReferenceConfigurationSchema = apiClientConfigurationSchema.merge(
203
+ z.object({
210
204
  /**
211
205
  * The layout to use for the references
212
206
  * @default 'modern'
213
207
  */
214
- layout: z.enum(['modern', 'classic']).optional().default('modern').catch('modern'),
208
+ layout: z.enum(["modern", "classic"]).optional().default("modern").catch("modern"),
215
209
  /**
216
210
  * URL to a request proxy for the API client
217
211
  * @deprecated Use proxyUrl instead
@@ -222,7 +216,7 @@ const _apiReferenceConfigurationSchema = apiClientConfigurationSchema.merge(z.ob
222
216
  */
223
217
  plugins: z.array(ApiReferencePluginSchema).optional(),
224
218
  /**
225
- * Whether the spec input should show
219
+ * Allows the user to inject an editor for the spec
226
220
  * @default false
227
221
  */
228
222
  isEditable: z.boolean().optional().default(false).catch(false),
@@ -254,7 +248,7 @@ const _apiReferenceConfigurationSchema = apiClientConfigurationSchema.merge(z.ob
254
248
  /** Whether dark mode is on or off initially (light mode) */
255
249
  darkMode: z.boolean().optional(),
256
250
  /** forceDarkModeState makes it always this state no matter what */
257
- forceDarkModeState: z.enum(['dark', 'light']).optional(),
251
+ forceDarkModeState: z.enum(["dark", "light"]).optional(),
258
252
  /**
259
253
  * Whether to show the dark mode toggle
260
254
  * @default false
@@ -264,7 +258,8 @@ const _apiReferenceConfigurationSchema = apiClientConfigurationSchema.merge(z.ob
264
258
  * If used, passed data will be added to the HTML header
265
259
  * @see https://unhead.unjs.io/usage/composables/use-seo-meta
266
260
  */
267
- metaData: z.any().optional(), // Using any for UseSeoMetaInput since it's an external type
261
+ metaData: z.any().optional(),
262
+ // Using any for UseSeoMetaInput since it's an external type
268
263
  /**
269
264
  * Path to a favicon image
270
265
  * @default undefined
@@ -275,16 +270,12 @@ const _apiReferenceConfigurationSchema = apiClientConfigurationSchema.merge(z.ob
275
270
  * List of httpsnippet clients to hide from the clients menu
276
271
  * By default hides Unirest, pass `[]` to show all clients
277
272
  */
278
- hiddenClients: z
279
- .union([z.record(z.union([z.boolean(), z.array(z.string())])), z.array(z.string()), z.literal(true)])
280
- .optional(),
273
+ hiddenClients: z.union([z.record(z.union([z.boolean(), z.array(z.string())])), z.array(z.string()), z.literal(true)]).optional(),
281
274
  /** Determine the HTTP client that's selected by default */
282
- defaultHttpClient: z
283
- .object({
284
- targetKey: z.custom(),
285
- clientKey: z.string(),
286
- })
287
- .optional(),
275
+ defaultHttpClient: z.object({
276
+ targetKey: z.custom(),
277
+ clientKey: z.string()
278
+ }).optional(),
288
279
  /** Custom CSS to be added to the page */
289
280
  customCss: z.string().optional(),
290
281
  /** onSpecUpdate is fired on spec/swagger content change */
@@ -318,69 +309,59 @@ const _apiReferenceConfigurationSchema = apiClientConfigurationSchema.merge(z.ob
318
309
  * @returns A string ID used to generate the URL hash
319
310
  * @default (heading) => `#description/${heading.slug}`
320
311
  */
321
- generateHeadingSlug: z
322
- .function()
323
- .args(z.object({
324
- slug: z.string().default('headingSlug'),
325
- }))
326
- .returns(z.string())
327
- .optional(),
312
+ generateHeadingSlug: z.function().args(
313
+ z.object({
314
+ slug: z.string().default("headingSlug")
315
+ })
316
+ ).returns(z.string()).optional(),
328
317
  /**
329
318
  * Customize the model portion of the hash
330
319
  * @param model - The model object with a name property
331
320
  * @returns A string ID used to generate the URL hash
332
321
  * @default (model) => slug(model.name)
333
322
  */
334
- generateModelSlug: z
335
- .function()
336
- .args(z.object({
337
- name: z.string().default('modelName'),
338
- }))
339
- .returns(z.string())
340
- .optional(),
323
+ generateModelSlug: z.function().args(
324
+ z.object({
325
+ name: z.string().default("modelName")
326
+ })
327
+ ).returns(z.string()).optional(),
341
328
  /**
342
329
  * Customize the tag portion of the hash
343
330
  * @param tag - The tag object
344
331
  * @returns A string ID used to generate the URL hash
345
332
  * @default (tag) => slug(tag.name)
346
333
  */
347
- generateTagSlug: z
348
- .function()
349
- .args(z.object({
350
- name: z.string().default('tagName'),
351
- }))
352
- .returns(z.string())
353
- .optional(),
334
+ generateTagSlug: z.function().args(
335
+ z.object({
336
+ name: z.string().default("tagName")
337
+ })
338
+ ).returns(z.string()).optional(),
354
339
  /**
355
340
  * Customize the operation portion of the hash
356
341
  * @param operation - The operation object
357
342
  * @returns A string ID used to generate the URL hash
358
343
  * @default (operation) => `${operation.method}${operation.path}`
359
344
  */
360
- generateOperationSlug: z
361
- .function()
362
- .args(z.object({
345
+ generateOperationSlug: z.function().args(
346
+ z.object({
363
347
  path: z.string(),
364
348
  operationId: z.string().optional(),
365
349
  method: z.string(),
366
- summary: z.string().optional(),
367
- }))
368
- .returns(z.string())
369
- .optional(),
350
+ summary: z.string().optional()
351
+ })
352
+ ).returns(z.string()).optional(),
370
353
  /**
371
354
  * Customize the webhook portion of the hash
372
355
  * @param webhook - The webhook object
373
356
  * @returns A string ID used to generate the URL hash
374
357
  * @default (webhook) => slug(webhook.name)
375
358
  */
376
- generateWebhookSlug: z
377
- .function()
378
- .args(z.object({
359
+ generateWebhookSlug: z.function().args(
360
+ z.object({
379
361
  name: z.string(),
380
- method: z.string().optional(),
381
- }))
382
- .returns(z.string())
383
- .optional(),
362
+ method: z.string().optional()
363
+ })
364
+ ).returns(z.string()).optional(),
384
365
  /**
385
366
  * To handle redirects, pass a function that will recieve:
386
367
  * - The current path with hash if pathRouting is enabled
@@ -413,54 +394,57 @@ const _apiReferenceConfigurationSchema = apiClientConfigurationSchema.merge(z.ob
413
394
  * Function to sort tags
414
395
  * @default 'alpha' for alphabetical sorting
415
396
  */
416
- tagsSorter: z.union([z.literal('alpha'), z.function().args(z.any(), z.any()).returns(z.number())]).optional(),
397
+ tagsSorter: z.union([z.literal("alpha"), z.function().args(z.any(), z.any()).returns(z.number())]).optional(),
417
398
  /**
418
399
  * Function to sort operations
419
400
  * @default 'alpha' for alphabetical sorting
420
401
  */
421
- operationsSorter: z
422
- .union([z.literal('alpha'), z.literal('method'), z.function().args(z.any(), z.any()).returns(z.number())])
423
- .optional(),
424
- }));
425
- const OLD_PROXY_URL = 'https://api.scalar.com/request-proxy';
426
- const NEW_PROXY_URL = 'https://proxy.scalar.com';
427
- /** Migrate the configuration through a transform */
402
+ operationsSorter: z.union([z.literal("alpha"), z.literal("method"), z.function().args(z.any(), z.any()).returns(z.number())]).optional()
403
+ })
404
+ );
405
+ const OLD_PROXY_URL = "https://api.scalar.com/request-proxy";
406
+ const NEW_PROXY_URL = "https://proxy.scalar.com";
428
407
  const migrateConfiguration = (_configuration) => {
429
- const configuration = { ..._configuration };
430
- // Remove the spec prefix
431
- if (configuration.spec?.url) {
432
- console.warn(`[DEPRECATED] You're using the deprecated 'spec.url' attribute. Remove the spec prefix and move the 'url' attribute to the top level.`);
433
- configuration.url = configuration.spec.url;
434
- delete configuration.spec;
435
- }
436
- if (configuration.spec?.content) {
437
- console.warn(`[DEPRECATED] You're using the deprecated 'spec.content' attribute. Remove the spec prefix and move the 'content' attribute to the top level.`);
438
- configuration.content = configuration.spec.content;
439
- delete configuration.spec;
440
- }
441
- // Migrate legacy theme variables
442
- if (configuration.customCss) {
443
- configuration.customCss = migrateThemeVariables(configuration.customCss);
408
+ const configuration = { ..._configuration };
409
+ if (configuration.spec?.url) {
410
+ console.warn(
411
+ `[DEPRECATED] You're using the deprecated 'spec.url' attribute. Remove the spec prefix and move the 'url' attribute to the top level.`
412
+ );
413
+ configuration.url = configuration.spec.url;
414
+ delete configuration.spec;
415
+ }
416
+ if (configuration.spec?.content) {
417
+ console.warn(
418
+ `[DEPRECATED] You're using the deprecated 'spec.content' attribute. Remove the spec prefix and move the 'content' attribute to the top level.`
419
+ );
420
+ configuration.content = configuration.spec.content;
421
+ delete configuration.spec;
422
+ }
423
+ if (configuration.proxy) {
424
+ console.warn(
425
+ `[DEPRECATED] You're using the deprecated 'proxy' attribute, rename it to 'proxyUrl' or update the package.`
426
+ );
427
+ if (!configuration.proxyUrl) {
428
+ configuration.proxyUrl = configuration.proxy;
444
429
  }
445
- // Migrate proxy URL
446
- if (configuration.proxy) {
447
- console.warn(`[DEPRECATED] You're using the deprecated 'proxy' attribute, rename it to 'proxyUrl' or update the package.`);
448
- if (!configuration.proxyUrl) {
449
- configuration.proxyUrl = configuration.proxy;
450
- }
451
- delete configuration.proxy;
452
- }
453
- if (configuration.proxyUrl === OLD_PROXY_URL) {
454
- console.warn(`[DEPRECATED] Warning: configuration.proxyUrl points to our old proxy (${OLD_PROXY_URL}).`);
455
- console.warn(`[DEPRECATED] We are overwriting the value and use the new proxy URL (${NEW_PROXY_URL}) instead.`);
456
- console.warn(`[DEPRECATED] Action Required: You should manually update your configuration to use the new URL (${NEW_PROXY_URL}). Read more: https://github.com/scalar/scalar`);
457
- configuration.proxyUrl = NEW_PROXY_URL;
458
- }
459
- return configuration;
430
+ delete configuration.proxy;
431
+ }
432
+ if (configuration.proxyUrl === OLD_PROXY_URL) {
433
+ console.warn(`[DEPRECATED] Warning: configuration.proxyUrl points to our old proxy (${OLD_PROXY_URL}).`);
434
+ console.warn(`[DEPRECATED] We are overwriting the value and use the new proxy URL (${NEW_PROXY_URL}) instead.`);
435
+ console.warn(
436
+ `[DEPRECATED] Action Required: You should manually update your configuration to use the new URL (${NEW_PROXY_URL}). Read more: https://github.com/scalar/scalar`
437
+ );
438
+ configuration.proxyUrl = NEW_PROXY_URL;
439
+ }
440
+ return configuration;
460
441
  };
461
- /** Configuration for the Api Reference */
462
442
  const apiReferenceConfigurationSchema = _apiReferenceConfigurationSchema.transform(migrateConfiguration);
463
- /** Typeguard to check to narrow the configs to the one with sources */
464
- const isConfigurationWithSources = (config) => Boolean(!Array.isArray(config) && config && 'sources' in config && Array.isArray(config.sources));
465
-
466
- export { apiClientConfigurationSchema, apiReferenceConfigurationSchema, isConfigurationWithSources, specConfigurationSchema };
443
+ const isConfigurationWithSources = (config) => Boolean(!Array.isArray(config) && config && "sources" in config && Array.isArray(config.sources));
444
+ export {
445
+ apiClientConfigurationSchema,
446
+ apiReferenceConfigurationSchema,
447
+ isConfigurationWithSources,
448
+ specConfigurationSchema
449
+ };
450
+ //# sourceMappingURL=api-reference-configuration.js.map