@scalar/oas-utils 0.10.8 → 0.10.10

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 (129) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/entities/cookie/cookie.js +11 -15
  3. package/dist/entities/cookie/index.js +1 -5
  4. package/dist/entities/environment/environment.js +7 -11
  5. package/dist/entities/environment/index.js +1 -5
  6. package/dist/entities/hotkeys/hotkeys.js +116 -111
  7. package/dist/entities/hotkeys/index.js +1 -6
  8. package/dist/entities/shared/index.js +1 -7
  9. package/dist/entities/shared/utility.js +9 -9
  10. package/dist/entities/spec/collection.js +91 -89
  11. package/dist/entities/spec/index.js +10 -59
  12. package/dist/entities/spec/operation.js +6 -6
  13. package/dist/entities/spec/parameters.js +38 -38
  14. package/dist/entities/spec/request-examples.js +421 -331
  15. package/dist/entities/spec/requests.js +102 -84
  16. package/dist/entities/spec/server.js +61 -46
  17. package/dist/entities/spec/spec-objects.js +121 -76
  18. package/dist/entities/spec/x-scalar-environments.js +18 -20
  19. package/dist/entities/spec/x-scalar-secrets.js +6 -8
  20. package/dist/entities/workspace/index.js +1 -7
  21. package/dist/entities/workspace/workspace.js +47 -46
  22. package/dist/helpers/client-plugins.js +13 -13
  23. package/dist/helpers/fetch-document.js +30 -25
  24. package/dist/helpers/fetch-with-proxy-fallback.js +26 -21
  25. package/dist/helpers/index.d.ts +1 -2
  26. package/dist/helpers/index.d.ts.map +1 -1
  27. package/dist/helpers/index.js +80 -119
  28. package/dist/helpers/normalize-mime-type-object.js +19 -18
  29. package/dist/helpers/normalize-mime-type.js +11 -9
  30. package/dist/helpers/operation-stability.js +25 -20
  31. package/dist/helpers/parse.d.ts +0 -4
  32. package/dist/helpers/parse.d.ts.map +1 -1
  33. package/dist/helpers/parse.js +77 -77
  34. package/dist/helpers/schema-model.js +13 -16
  35. package/dist/helpers/security/get-schemes.js +7 -8
  36. package/dist/helpers/security/has-token.js +18 -19
  37. package/dist/helpers/security/index.js +2 -7
  38. package/dist/helpers/servers.js +128 -79
  39. package/dist/helpers/should-ignore-entity.js +4 -5
  40. package/dist/migrations/data-version.js +15 -7
  41. package/dist/migrations/generate-types.js +34 -37
  42. package/dist/migrations/index.js +4 -18
  43. package/dist/migrations/local-storage.js +31 -29
  44. package/dist/migrations/migrate-to-indexdb.js +706 -529
  45. package/dist/migrations/migrator.js +58 -54
  46. package/dist/migrations/semver.js +24 -24
  47. package/dist/migrations/v-0.0.0/types.generated.js +1 -1
  48. package/dist/migrations/v-2.1.0/migration.js +272 -258
  49. package/dist/migrations/v-2.1.0/types.generated.js +1 -1
  50. package/dist/migrations/v-2.2.0/migration.js +99 -96
  51. package/dist/migrations/v-2.2.0/types.generated.js +1 -1
  52. package/dist/migrations/v-2.3.0/migration.js +45 -48
  53. package/dist/migrations/v-2.3.0/types.generated.js +1 -1
  54. package/dist/migrations/v-2.4.0/migration.js +25 -25
  55. package/dist/migrations/v-2.4.0/types.generated.js +1 -1
  56. package/dist/migrations/v-2.5.0/migration.js +122 -139
  57. package/dist/migrations/v-2.5.0/types.generated.js +1 -1
  58. package/dist/spec-getters/get-example-from-schema.js +489 -385
  59. package/dist/spec-getters/get-parameters-from-operation.js +39 -23
  60. package/dist/spec-getters/get-request-body-from-operation.d.ts.map +1 -1
  61. package/dist/spec-getters/get-request-body-from-operation.js +168 -126
  62. package/dist/spec-getters/get-server-variable-examples.js +10 -13
  63. package/dist/spec-getters/index.js +4 -11
  64. package/dist/transforms/import-spec.js +381 -291
  65. package/dist/transforms/index.js +1 -11
  66. package/package.json +15 -19
  67. package/dist/entities/cookie/cookie.js.map +0 -7
  68. package/dist/entities/cookie/index.js.map +0 -7
  69. package/dist/entities/environment/environment.js.map +0 -7
  70. package/dist/entities/environment/index.js.map +0 -7
  71. package/dist/entities/hotkeys/hotkeys.js.map +0 -7
  72. package/dist/entities/hotkeys/index.js.map +0 -7
  73. package/dist/entities/shared/index.js.map +0 -7
  74. package/dist/entities/shared/utility.js.map +0 -7
  75. package/dist/entities/spec/collection.js.map +0 -7
  76. package/dist/entities/spec/index.js.map +0 -7
  77. package/dist/entities/spec/operation.js.map +0 -7
  78. package/dist/entities/spec/parameters.js.map +0 -7
  79. package/dist/entities/spec/request-examples.js.map +0 -7
  80. package/dist/entities/spec/requests.js.map +0 -7
  81. package/dist/entities/spec/server.js.map +0 -7
  82. package/dist/entities/spec/spec-objects.js.map +0 -7
  83. package/dist/entities/spec/x-scalar-environments.js.map +0 -7
  84. package/dist/entities/spec/x-scalar-secrets.js.map +0 -7
  85. package/dist/entities/workspace/index.js.map +0 -7
  86. package/dist/entities/workspace/workspace.js.map +0 -7
  87. package/dist/helpers/client-plugins.js.map +0 -7
  88. package/dist/helpers/fetch-document.js.map +0 -7
  89. package/dist/helpers/fetch-with-proxy-fallback.js.map +0 -7
  90. package/dist/helpers/index.js.map +0 -7
  91. package/dist/helpers/normalize-mime-type-object.js.map +0 -7
  92. package/dist/helpers/normalize-mime-type.js.map +0 -7
  93. package/dist/helpers/operation-stability.js.map +0 -7
  94. package/dist/helpers/parse.js.map +0 -7
  95. package/dist/helpers/pretty-print-json.d.ts +0 -9
  96. package/dist/helpers/pretty-print-json.d.ts.map +0 -1
  97. package/dist/helpers/pretty-print-json.js +0 -38
  98. package/dist/helpers/pretty-print-json.js.map +0 -7
  99. package/dist/helpers/schema-model.js.map +0 -7
  100. package/dist/helpers/security/get-schemes.js.map +0 -7
  101. package/dist/helpers/security/has-token.js.map +0 -7
  102. package/dist/helpers/security/index.js.map +0 -7
  103. package/dist/helpers/servers.js.map +0 -7
  104. package/dist/helpers/should-ignore-entity.js.map +0 -7
  105. package/dist/migrations/data-version.js.map +0 -7
  106. package/dist/migrations/generate-types.js.map +0 -7
  107. package/dist/migrations/index.js.map +0 -7
  108. package/dist/migrations/local-storage.js.map +0 -7
  109. package/dist/migrations/migrate-to-indexdb.js.map +0 -7
  110. package/dist/migrations/migrator.js.map +0 -7
  111. package/dist/migrations/semver.js.map +0 -7
  112. package/dist/migrations/v-0.0.0/types.generated.js.map +0 -7
  113. package/dist/migrations/v-2.1.0/migration.js.map +0 -7
  114. package/dist/migrations/v-2.1.0/types.generated.js.map +0 -7
  115. package/dist/migrations/v-2.2.0/migration.js.map +0 -7
  116. package/dist/migrations/v-2.2.0/types.generated.js.map +0 -7
  117. package/dist/migrations/v-2.3.0/migration.js.map +0 -7
  118. package/dist/migrations/v-2.3.0/types.generated.js.map +0 -7
  119. package/dist/migrations/v-2.4.0/migration.js.map +0 -7
  120. package/dist/migrations/v-2.4.0/types.generated.js.map +0 -7
  121. package/dist/migrations/v-2.5.0/migration.js.map +0 -7
  122. package/dist/migrations/v-2.5.0/types.generated.js.map +0 -7
  123. package/dist/spec-getters/get-example-from-schema.js.map +0 -7
  124. package/dist/spec-getters/get-parameters-from-operation.js.map +0 -7
  125. package/dist/spec-getters/get-request-body-from-operation.js.map +0 -7
  126. package/dist/spec-getters/get-server-variable-examples.js.map +0 -7
  127. package/dist/spec-getters/index.js.map +0 -7
  128. package/dist/transforms/import-spec.js.map +0 -7
  129. package/dist/transforms/index.js.map +0 -7
@@ -1,91 +1,109 @@
1
- import {
2
- XCodeSamplesSchema,
3
- XPostResponseSchema
4
- } from "@scalar/openapi-types/schemas/extensions";
5
- import { oasSecurityRequirementSchema } from "@scalar/types/entities";
6
- import { XScalarStability } from "@scalar/types/legacy";
7
- import { nanoidSchema } from "@scalar/types/utils";
8
- import { z } from "zod";
9
- import { selectedSecuritySchemeUidSchema } from "../../entities/shared/utility.js";
10
- import { oasParameterSchema } from "./parameters.js";
11
- import { xScalarExampleSchema } from "./request-examples.js";
12
- import { oasExternalDocumentationSchema } from "./spec-objects.js";
13
- const requestMethods = ["delete", "get", "head", "options", "patch", "post", "put", "trace"];
1
+ import { XCodeSamplesSchema, XPostResponseSchema, } from '@scalar/openapi-types/schemas/extensions';
2
+ import { oasSecurityRequirementSchema } from '@scalar/types/entities';
3
+ import { XScalarStability } from '@scalar/types/legacy';
4
+ import { nanoidSchema } from '@scalar/types/utils';
5
+ import { z } from 'zod';
6
+ import { selectedSecuritySchemeUidSchema } from '../../entities/shared/utility.js';
7
+ import { oasParameterSchema } from './parameters.js';
8
+ import { xScalarExampleSchema } from './request-examples.js';
9
+ import { oasExternalDocumentationSchema } from './spec-objects.js';
10
+ const requestMethods = ['delete', 'get', 'head', 'options', 'patch', 'post', 'put', 'trace'];
14
11
  const requestBodySchema = z.any();
12
+ /** Open API Compliant Request Validator */
15
13
  const oasRequestSchema = z.object({
16
- /**
17
- * A list of tags for API documentation control. Tags can be used for logical
18
- * grouping of operations by resources or any other qualifier.
19
- *
20
- * These tags are the openapi spec tag names, not uids
21
- */
22
- "tags": z.string().array().optional(),
23
- /** A short summary of what the operation does. */
24
- "summary": z.string().optional(),
25
- /** A verbose explanation of the operation behavior. CommonMark syntax MAY be used for rich text representation. */
26
- "description": z.string().optional(),
27
- /**
28
- * Unique string used to identify the operation. The id MUST be unique among all operations described in the API.
29
- * The operationId value is case-sensitive. Tools and libraries MAY use the operationId to uniquely identify an
30
- * operation, therefore, it is RECOMMENDED to follow bin common programming naming conventions./
31
- */
32
- "operationId": z.string().optional(),
33
- /**
34
- * A declaration of which security mechanisms can be used across the API. The list of
35
- * values includes alternative security requirement objects that can be used. Only
36
- * one of the security requirement objects need to be satisfied to authorize a request.
37
- * Individual operations can override this definition. To make security optional, an empty
38
- * security requirement ({}) can be included in the array.
39
- */
40
- "security": z.array(oasSecurityRequirementSchema).optional(),
41
- /**
42
- * The request body applicable for this operation. The requestBody is fully supported in HTTP methods where the
43
- * HTTP 1.1 specification [RFC7231] has explicitly defined semantics for request bodies. In other cases where the
44
- * HTTP spec is vague (such as GET, HEAD and DELETE), requestBody is permitted but does not have well-defined
45
- * semantics and SHOULD be avoided if possible.
46
- */
47
- "requestBody": requestBodySchema.optional(),
48
- /**
49
- * Request parameters
50
- */
51
- "parameters": oasParameterSchema.array().optional(),
52
- /**
53
- * External documentation object
54
- */
55
- "externalDocs": oasExternalDocumentationSchema.optional(),
56
- "deprecated": z.boolean().optional(),
57
- /** Response formats */
58
- "responses": z.record(z.string(), z.any()).optional(),
59
- /** Callbacks */
60
- "callbacks": z.record(z.string(), z.record(z.string(), z.record(z.string(), z.any()))).optional(),
61
- /** xScalar examples */
62
- "x-scalar-examples": z.record(z.string(), xScalarExampleSchema).optional(),
63
- /** Hide operations */
64
- "x-internal": z.boolean().optional(),
65
- /** Ignore operations */
66
- "x-scalar-ignore": z.boolean().optional()
14
+ /**
15
+ * A list of tags for API documentation control. Tags can be used for logical
16
+ * grouping of operations by resources or any other qualifier.
17
+ *
18
+ * These tags are the openapi spec tag names, not uids
19
+ */
20
+ 'tags': z.string().array().optional(),
21
+ /** A short summary of what the operation does. */
22
+ 'summary': z.string().optional(),
23
+ /** A verbose explanation of the operation behavior. CommonMark syntax MAY be used for rich text representation. */
24
+ 'description': z.string().optional(),
25
+ /**
26
+ * Unique string used to identify the operation. The id MUST be unique among all operations described in the API.
27
+ * The operationId value is case-sensitive. Tools and libraries MAY use the operationId to uniquely identify an
28
+ * operation, therefore, it is RECOMMENDED to follow bin common programming naming conventions./
29
+ */
30
+ 'operationId': z.string().optional(),
31
+ /**
32
+ * A declaration of which security mechanisms can be used across the API. The list of
33
+ * values includes alternative security requirement objects that can be used. Only
34
+ * one of the security requirement objects need to be satisfied to authorize a request.
35
+ * Individual operations can override this definition. To make security optional, an empty
36
+ * security requirement ({}) can be included in the array.
37
+ */
38
+ 'security': z.array(oasSecurityRequirementSchema).optional(),
39
+ /**
40
+ * The request body applicable for this operation. The requestBody is fully supported in HTTP methods where the
41
+ * HTTP 1.1 specification [RFC7231] has explicitly defined semantics for request bodies. In other cases where the
42
+ * HTTP spec is vague (such as GET, HEAD and DELETE), requestBody is permitted but does not have well-defined
43
+ * semantics and SHOULD be avoided if possible.
44
+ */
45
+ 'requestBody': requestBodySchema.optional(),
46
+ /**
47
+ * Request parameters
48
+ */
49
+ 'parameters': oasParameterSchema.array().optional(),
50
+ /**
51
+ * External documentation object
52
+ */
53
+ 'externalDocs': oasExternalDocumentationSchema.optional(),
54
+ 'deprecated': z.boolean().optional(),
55
+ /** Response formats */
56
+ 'responses': z.record(z.string(), z.any()).optional(),
57
+ /** Callbacks */
58
+ 'callbacks': z.record(z.string(), z.record(z.string(), z.record(z.string(), z.any()))).optional(),
59
+ /** xScalar examples */
60
+ 'x-scalar-examples': z.record(z.string(), xScalarExampleSchema).optional(),
61
+ /** Hide operations */
62
+ 'x-internal': z.boolean().optional(),
63
+ /** Ignore operations */
64
+ 'x-scalar-ignore': z.boolean().optional(),
67
65
  });
66
+ /**
67
+ * An OpenAPI extension to indicate the stability of the operation
68
+ *
69
+ * @example
70
+ * ```yaml
71
+ * x-scalar-stability: deprecated
72
+ * ```
73
+ */
68
74
  const ScalarStabilitySchema = z.object({
69
- "x-scalar-stability": z.enum([XScalarStability.Deprecated, XScalarStability.Experimental, XScalarStability.Stable]).optional().catch(void 0)
75
+ 'x-scalar-stability': z
76
+ .enum([XScalarStability.Deprecated, XScalarStability.Experimental, XScalarStability.Stable])
77
+ .optional()
78
+ .catch(undefined),
70
79
  });
80
+ /**
81
+ * Extended properties added to the spec definition for client usage
82
+ *
83
+ * WARNING: DO NOT ADD PROPERTIES THAT SHARE A NAME WITH OAS OPERATION ENTITIES
84
+ *
85
+ * This object is directly converted to a spec operation during saving
86
+ */
71
87
  const extendedRequestSchema = z.object({
72
- type: z.literal("request").optional().default("request"),
73
- uid: nanoidSchema.brand(),
74
- /** Path Key */
75
- path: z.string().optional().default(""),
76
- /** Request Method */
77
- method: z.enum(requestMethods).default("get"),
78
- /** List of server UIDs specific to the request */
79
- servers: z.string().brand().array().default([]),
80
- /** The currently selected server */
81
- selectedServerUid: z.string().brand().optional().nullable().default(null),
82
- /** List of example UIDs associated with the request */
83
- examples: z.string().brand().array().default([]),
84
- /** List of security scheme UIDs associated with the request */
85
- selectedSecuritySchemeUids: selectedSecuritySchemeUidSchema
88
+ type: z.literal('request').optional().default('request'),
89
+ uid: nanoidSchema.brand(),
90
+ /** Path Key */
91
+ path: z.string().optional().default(''),
92
+ /** Request Method */
93
+ method: z.enum(requestMethods).default('get'),
94
+ /** List of server UIDs specific to the request */
95
+ servers: z.string().brand().array().default([]),
96
+ /** The currently selected server */
97
+ selectedServerUid: z.string().brand().optional().nullable().default(null),
98
+ /** List of example UIDs associated with the request */
99
+ examples: z.string().brand().array().default([]),
100
+ /** List of security scheme UIDs associated with the request */
101
+ selectedSecuritySchemeUids: selectedSecuritySchemeUidSchema,
86
102
  });
87
- const requestSchema = oasRequestSchema.omit({ "x-scalar-examples": true }).merge(XCodeSamplesSchema).merge(ScalarStabilitySchema).merge(extendedRequestSchema).merge(XPostResponseSchema);
88
- export {
89
- requestSchema
90
- };
91
- //# sourceMappingURL=requests.js.map
103
+ /** Unified request schema for client usage */
104
+ export const requestSchema = oasRequestSchema
105
+ .omit({ 'x-scalar-examples': true })
106
+ .merge(XCodeSamplesSchema)
107
+ .merge(ScalarStabilitySchema)
108
+ .merge(extendedRequestSchema)
109
+ .merge(XPostResponseSchema);
@@ -1,52 +1,67 @@
1
- import { nanoidSchema } from "@scalar/types/utils";
2
- import { z } from "zod";
1
+ import { nanoidSchema } from '@scalar/types/utils';
2
+ import { z } from 'zod';
3
+ /**
4
+ * Server Variable Object
5
+ *
6
+ * An object representing a Server Variable for server URL template substitution.
7
+ *
8
+ * @see https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.1.md#server-variable-object
9
+ */
3
10
  const oasServerVariableSchema = z.object({
4
- /**
5
- * An enumeration of string values to be used if the substitution options are from a limited set. The array MUST NOT be empty.
6
- */
7
- enum: z.array(z.string()).optional(),
8
- /**
9
- * REQUIRED. The default value to use for substitution, which SHALL be sent if an alternate value is not supplied.
10
- * Note this behavior is different than the Schema Object's treatment of default values, because in those cases
11
- * parameter values are optional. If the enum is defined, the value MUST exist in the enum's values.
12
- */
13
- default: z.string().optional(),
14
- /**
15
- * An optional description for the server variable. CommonMark syntax MAY be used for rich text representation.
16
- */
17
- description: z.string().optional()
11
+ /**
12
+ * An enumeration of string values to be used if the substitution options are from a limited set. The array MUST NOT be empty.
13
+ */
14
+ enum: z.array(z.string()).optional(),
15
+ /**
16
+ * REQUIRED. The default value to use for substitution, which SHALL be sent if an alternate value is not supplied.
17
+ * Note this behavior is different than the Schema Object's treatment of default values, because in those cases
18
+ * parameter values are optional. If the enum is defined, the value MUST exist in the enum's values.
19
+ */
20
+ default: z.string().optional(),
21
+ /**
22
+ * An optional description for the server variable. CommonMark syntax MAY be used for rich text representation.
23
+ */
24
+ description: z.string().optional(),
18
25
  });
19
- const extendedServerVariableSchema = oasServerVariableSchema.extend({
20
- /** The value of the variable */
21
- value: z.string().optional()
22
- }).refine((data) => {
23
- if (Array.isArray(data.enum) && !data.enum.includes(data.default ?? "") && data.enum.length > 0) {
24
- data.default = data.enum[0];
25
- }
26
- if (Array.isArray(data.enum) && data.enum.length === 0) {
27
- delete data.enum;
28
- }
29
- return true;
26
+ /** Extended schema for server variables */
27
+ const extendedServerVariableSchema = oasServerVariableSchema
28
+ .extend({
29
+ /** The value of the variable */
30
+ value: z.string().optional(),
31
+ })
32
+ .refine((data) => {
33
+ // Set default to the first enum value if invalid
34
+ if (Array.isArray(data.enum) && !data.enum.includes(data.default ?? '') && data.enum.length > 0) {
35
+ data.default = data.enum[0];
36
+ }
37
+ if (Array.isArray(data.enum) && data.enum.length === 0) {
38
+ delete data.enum;
39
+ }
40
+ // Always return true since we've modified the data to be valid
41
+ return true;
30
42
  });
43
+ /**
44
+ * Server Object
45
+ *
46
+ * An object representing a Server.
47
+ *
48
+ * @see https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.1.md#server-object
49
+ */
31
50
  const oasServerSchema = z.object({
32
- /**
33
- * REQUIRED. A URL to the target host. This URL supports Server Variables and MAY be relative, to indicate that
34
- * the host location is relative to the location where the OpenAPI document is being served. Variable substitutions
35
- * will be made when a variable is named in {brackets}.
36
- */
37
- url: z.string(),
38
- /**
39
- * An optional string describing the host designated by the URL. CommonMark syntax MAY be used for rich text
40
- * representation.
41
- */
42
- description: z.string().optional(),
43
- /** A map between a variable name and its value. The value is used for substitution in the server's URL template. */
44
- variables: z.record(z.string(), extendedServerVariableSchema).optional()
51
+ /**
52
+ * REQUIRED. A URL to the target host. This URL supports Server Variables and MAY be relative, to indicate that
53
+ * the host location is relative to the location where the OpenAPI document is being served. Variable substitutions
54
+ * will be made when a variable is named in {brackets}.
55
+ */
56
+ url: z.string(),
57
+ /**
58
+ * An optional string describing the host designated by the URL. CommonMark syntax MAY be used for rich text
59
+ * representation.
60
+ */
61
+ description: z.string().optional(),
62
+ /** A map between a variable name and its value. The value is used for substitution in the server's URL template. */
63
+ variables: z.record(z.string(), extendedServerVariableSchema).optional(),
45
64
  });
46
- const serverSchema = oasServerSchema.extend({
47
- uid: nanoidSchema.brand()
65
+ export const serverSchema = oasServerSchema.extend({
66
+ uid: nanoidSchema.brand(),
48
67
  });
49
- export {
50
- serverSchema
51
- };
52
- //# sourceMappingURL=server.js.map
@@ -1,79 +1,124 @@
1
- import { omitUndefinedValues } from "@scalar/helpers/object/omit-undefined-values";
2
- import { XScalarSdkInstallationSchema } from "@scalar/openapi-types/schemas/extensions";
3
- import { nanoidSchema } from "@scalar/types/utils";
4
- import { z } from "zod";
5
- const oasLicenseSchema = z.object({
6
- /** REQUIRED. The license name used for the API. */
7
- name: z.string().optional().nullable().catch(null),
8
- /** An SPDX license expression for the API. The identifier field is mutually exclusive of the url field. */
9
- identifier: z.string().optional().catch(void 0),
10
- /**
11
- * A URI for the license used for the API. This MUST be in the form of a URI. The url field is mutually exclusive of the identifier field.
12
- */
13
- url: z.string().url().optional().catch(void 0)
14
- }).transform(omitUndefinedValues);
15
- const oasContactSchema = z.object({
16
- /** The identifying name of the contact person/organization. */
17
- name: z.string().optional(),
18
- /** The URL pointing to the contact information. This MUST be in the form of a URL. */
19
- url: z.string().url().optional().catch(void 0),
20
- /** The email address of the contact person/organization. This MUST be in the form of an email address. */
21
- email: z.string().optional().catch(void 0)
22
- }).transform(omitUndefinedValues);
23
- const oasInfoSchema = z.object({
24
- /** REQUIRED. The title of the API. */
25
- title: z.string().catch("API"),
26
- /** A short summary of the API. */
27
- summary: z.string().optional().catch(void 0),
28
- /** A description of the API. CommonMark syntax MAY be used for rich text representation. */
29
- description: z.string().optional().catch(void 0),
30
- /** A URL to the Terms of Service for the API. This MUST be in the form of a URL. */
31
- termsOfService: z.string().url().optional().catch(void 0),
32
- /** The contact information for the exposed API. */
33
- contact: oasContactSchema.optional().catch(void 0),
34
- /** The license information for the exposed API. */
35
- license: oasLicenseSchema.optional().catch(void 0),
36
- /**
37
- * REQUIRED. The version of the OpenAPI Document (which is distinct from the OpenAPI Specification version or the
38
- * version of the API being described or the version of the OpenAPI Description).
39
- */
40
- version: z.string().catch("1.0")
41
- }).merge(XScalarSdkInstallationSchema).transform(omitUndefinedValues);
42
- const oasExternalDocumentationSchema = z.object({
43
- /** A description of the target documentation. CommonMark syntax MAY be used for rich text representation. */
44
- description: z.string().optional().catch(void 0),
45
- /** REQUIRED. The URL for the target documentation. This MUST be in the form of a URL. */
46
- url: z.string()
47
- }).transform(omitUndefinedValues);
48
- const xScalarNestedSchema = z.object({
49
- tagName: z.string()
50
- }).array();
1
+ import { omitUndefinedValues } from '@scalar/helpers/object/omit-undefined-values';
2
+ import { XScalarSdkInstallationSchema } from '@scalar/openapi-types/schemas/extensions';
3
+ import { nanoidSchema } from '@scalar/types/utils';
4
+ import { z } from 'zod';
5
+ /**
6
+ * License Object
7
+ *
8
+ * License information for the exposed API.
9
+ *
10
+ * @see https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.1.md#license-object
11
+ */
12
+ export const oasLicenseSchema = z
13
+ .object({
14
+ /** REQUIRED. The license name used for the API. */
15
+ name: z.string().optional().nullable().catch(null),
16
+ /** An SPDX license expression for the API. The identifier field is mutually exclusive of the url field. */
17
+ identifier: z.string().optional().catch(undefined),
18
+ /**
19
+ * A URI for the license used for the API. This MUST be in the form of a URI. The url field is mutually exclusive of the identifier field.
20
+ */
21
+ url: z.string().url().optional().catch(undefined),
22
+ })
23
+ .transform(omitUndefinedValues);
24
+ /**
25
+ * Contact Object
26
+ *
27
+ * Contact information for the exposed API.
28
+ *
29
+ * @see https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.1.md#contact-object
30
+ */
31
+ export const oasContactSchema = z
32
+ .object({
33
+ /** The identifying name of the contact person/organization. */
34
+ name: z.string().optional(),
35
+ /** The URL pointing to the contact information. This MUST be in the form of a URL. */
36
+ url: z.string().url().optional().catch(undefined),
37
+ /** The email address of the contact person/organization. This MUST be in the form of an email address. */
38
+ email: z.string().optional().catch(undefined),
39
+ })
40
+ .transform(omitUndefinedValues);
41
+ /**
42
+ * Info Object
43
+ *
44
+ * The object provides metadata about the API. The metadata MAY be used by the clients if needed,
45
+ * and MAY be presented in editing or documentation generation tools for convenience.
46
+ *
47
+ * @see https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.1.md#info-object
48
+ */
49
+ export const oasInfoSchema = z
50
+ .object({
51
+ /** REQUIRED. The title of the API. */
52
+ title: z.string().catch('API'),
53
+ /** A short summary of the API. */
54
+ summary: z.string().optional().catch(undefined),
55
+ /** A description of the API. CommonMark syntax MAY be used for rich text representation. */
56
+ description: z.string().optional().catch(undefined),
57
+ /** A URL to the Terms of Service for the API. This MUST be in the form of a URL. */
58
+ termsOfService: z.string().url().optional().catch(undefined),
59
+ /** The contact information for the exposed API. */
60
+ contact: oasContactSchema.optional().catch(undefined),
61
+ /** The license information for the exposed API. */
62
+ license: oasLicenseSchema.optional().catch(undefined),
63
+ /**
64
+ * REQUIRED. The version of the OpenAPI Document (which is distinct from the OpenAPI Specification version or the
65
+ * version of the API being described or the version of the OpenAPI Description).
66
+ */
67
+ version: z.string().catch('1.0'),
68
+ })
69
+ .merge(XScalarSdkInstallationSchema)
70
+ .transform(omitUndefinedValues);
71
+ /**
72
+ * External Documentation Object
73
+ *
74
+ * Allows referencing an external resource for extended documentation.
75
+ *
76
+ * @see https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.1.md#external-documentation-object
77
+ */
78
+ export const oasExternalDocumentationSchema = z
79
+ .object({
80
+ /** A description of the target documentation. CommonMark syntax MAY be used for rich text representation. */
81
+ description: z.string().optional().catch(undefined),
82
+ /** REQUIRED. The URL for the target documentation. This MUST be in the form of a URL. */
83
+ url: z.string(),
84
+ })
85
+ .transform(omitUndefinedValues);
86
+ // not used but kept for consistency
87
+ // export type ExternalDocumentation = z.infer<typeof oasExternalDocumentationSchema>
88
+ const xScalarNestedSchema = z
89
+ .object({
90
+ tagName: z.string(),
91
+ })
92
+ .array();
93
+ /**
94
+ * Tag Object
95
+ *
96
+ * Adds metadata to a single tag that is used by the Operation Object. It is not mandatory to have a Tag Object per tag
97
+ * defined in the Operation Object instances.
98
+ *
99
+ * @see https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.1.md#tag-object
100
+ */
51
101
  const oasTagSchema = z.object({
52
- // TODO: Remove
53
- /**
54
- * @deprecated Needs to be remove as it is not a spec property
55
- */
56
- "type": z.literal("tag").optional().default("tag"),
57
- /** REQUIRED. The name of the tag. */
58
- "name": z.string(),
59
- /** A description for the tag. CommonMark syntax MAY be used for rich text representation. */
60
- "description": z.string().optional().catch(void 0),
61
- /** Additional external documentation for this tag. */
62
- "externalDocs": oasExternalDocumentationSchema.optional(),
63
- "x-scalar-children": xScalarNestedSchema.default([]).optional(),
64
- /** Hide collections */
65
- "x-internal": z.boolean().optional(),
66
- "x-scalar-ignore": z.boolean().optional()
102
+ // TODO: Remove
103
+ /**
104
+ * @deprecated Needs to be remove as it is not a spec property
105
+ */
106
+ 'type': z.literal('tag').optional().default('tag'),
107
+ /** REQUIRED. The name of the tag. */
108
+ 'name': z.string(),
109
+ /** A description for the tag. CommonMark syntax MAY be used for rich text representation. */
110
+ 'description': z.string().optional().catch(undefined),
111
+ /** Additional external documentation for this tag. */
112
+ 'externalDocs': oasExternalDocumentationSchema.optional(),
113
+ 'x-scalar-children': xScalarNestedSchema.default([]).optional(),
114
+ /** Hide collections */
115
+ 'x-internal': z.boolean().optional(),
116
+ 'x-scalar-ignore': z.boolean().optional(),
67
117
  });
68
- const tagSchema = oasTagSchema.extend({
69
- uid: nanoidSchema.brand(),
70
- children: z.union([z.string().brand(), z.string().brand()]).array().default([])
118
+ export const tagSchema = oasTagSchema.extend({
119
+ uid: nanoidSchema.brand(),
120
+ children: z
121
+ .union([z.string().brand(), z.string().brand()])
122
+ .array()
123
+ .default([]),
71
124
  });
72
- export {
73
- oasContactSchema,
74
- oasExternalDocumentationSchema,
75
- oasInfoSchema,
76
- oasLicenseSchema,
77
- tagSchema
78
- };
79
- //# sourceMappingURL=spec-objects.js.map
@@ -1,24 +1,22 @@
1
- import { z } from "zod";
1
+ import { z } from 'zod';
2
2
  const xScalarEnvVarSchema = z.union([
3
- z.object({
4
- description: z.string().optional(),
5
- default: z.string().default("")
6
- }),
7
- z.string()
3
+ z.object({
4
+ description: z.string().optional(),
5
+ default: z.string().default(''),
6
+ }),
7
+ z.string(),
8
8
  ]);
9
+ // not used but kept for consistency
10
+ // export type XScalarEnvVar = z.infer<typeof xScalarEnvVarSchema>
9
11
  const xScalarEnvironmentSchema = z.object({
10
- description: z.string().optional(),
11
- color: z.string().optional(),
12
- /** A map of variables by name */
13
- variables: z.record(z.string(), xScalarEnvVarSchema)
12
+ description: z.string().optional(),
13
+ color: z.string().optional(),
14
+ /** A map of variables by name */
15
+ variables: z.record(z.string(), xScalarEnvVarSchema),
14
16
  });
15
- const xScalarEnvironmentsSchema = z.record(
16
- /** Name */
17
- z.string(),
18
- /** Environment definition */
19
- xScalarEnvironmentSchema
20
- );
21
- export {
22
- xScalarEnvironmentsSchema
23
- };
24
- //# sourceMappingURL=x-scalar-environments.js.map
17
+ /** A map of environments by name */
18
+ export const xScalarEnvironmentsSchema = z.record(
19
+ /** Name */
20
+ z.string(),
21
+ /** Environment definition */
22
+ xScalarEnvironmentSchema);
@@ -1,10 +1,8 @@
1
- import { z } from "zod";
1
+ import { z } from 'zod';
2
2
  const xScalarSecretVarSchema = z.object({
3
- description: z.string().optional(),
4
- example: z.string().optional()
3
+ description: z.string().optional(),
4
+ example: z.string().optional(),
5
5
  });
6
- const xScalarSecretsSchema = z.record(z.string(), xScalarSecretVarSchema);
7
- export {
8
- xScalarSecretsSchema
9
- };
10
- //# sourceMappingURL=x-scalar-secrets.js.map
6
+ export const xScalarSecretsSchema = z.record(z.string(), xScalarSecretVarSchema);
7
+ // not used but kept for consistency
8
+ // export type XScalarSecrets = z.infer<typeof xScalarSecretsSchema>
@@ -1,7 +1 @@
1
- import {
2
- workspaceSchema
3
- } from "./workspace.js";
4
- export {
5
- workspaceSchema
6
- };
7
- //# sourceMappingURL=index.js.map
1
+ export { workspaceSchema, } from './workspace.js';