@scalar/oas-utils 0.2.140 → 0.2.141
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 +12 -0
- package/dist/entities/cookie/cookie.js +14 -13
- package/dist/entities/cookie/cookie.js.map +7 -0
- package/dist/entities/cookie/index.d.ts +1 -1
- package/dist/entities/cookie/index.d.ts.map +1 -1
- package/dist/entities/cookie/index.js +5 -1
- package/dist/entities/cookie/index.js.map +7 -0
- package/dist/entities/environment/environment.js +10 -9
- package/dist/entities/environment/environment.js.map +7 -0
- package/dist/entities/environment/index.d.ts +1 -1
- package/dist/entities/environment/index.d.ts.map +1 -1
- package/dist/entities/environment/index.js +5 -1
- package/dist/entities/environment/index.js.map +7 -0
- package/dist/entities/hotkeys/hotkeys.js +109 -116
- package/dist/entities/hotkeys/hotkeys.js.map +7 -0
- package/dist/entities/hotkeys/index.d.ts +1 -1
- package/dist/entities/hotkeys/index.d.ts.map +1 -1
- package/dist/entities/hotkeys/index.js +6 -1
- package/dist/entities/hotkeys/index.js.map +7 -0
- package/dist/entities/shared/index.d.ts +1 -1
- package/dist/entities/shared/index.d.ts.map +1 -1
- package/dist/entities/shared/index.js +7 -1
- package/dist/entities/shared/index.js.map +7 -0
- package/dist/entities/shared/utility.js +9 -12
- package/dist/entities/shared/utility.js.map +7 -0
- package/dist/entities/spec/collection.d.ts.map +1 -1
- package/dist/entities/spec/collection.js +91 -94
- package/dist/entities/spec/collection.js.map +7 -0
- package/dist/entities/spec/index.d.ts +8 -8
- package/dist/entities/spec/index.d.ts.map +1 -1
- package/dist/entities/spec/index.js +59 -9
- package/dist/entities/spec/index.js.map +7 -0
- package/dist/entities/spec/operation.d.ts +1 -1
- package/dist/entities/spec/operation.d.ts.map +1 -1
- package/dist/entities/spec/operation.js +5 -8
- package/dist/entities/spec/operation.js.map +7 -0
- package/dist/entities/spec/operation.test.js +43 -0
- package/dist/entities/spec/operation.test.js.map +7 -0
- package/dist/entities/spec/parameters.d.ts +1 -1
- package/dist/entities/spec/parameters.d.ts.map +1 -1
- package/dist/entities/spec/parameters.js +40 -38
- package/dist/entities/spec/parameters.js.map +7 -0
- package/dist/entities/spec/parameters.test.js +71 -0
- package/dist/entities/spec/parameters.test.js.map +7 -0
- package/dist/entities/spec/request-example.test.js +637 -0
- package/dist/entities/spec/request-example.test.js.map +7 -0
- package/dist/entities/spec/request-examples.d.ts +3 -3
- package/dist/entities/spec/request-examples.d.ts.map +1 -1
- package/dist/entities/spec/request-examples.js +323 -338
- package/dist/entities/spec/request-examples.js.map +7 -0
- package/dist/entities/spec/requests.d.ts +6 -8
- package/dist/entities/spec/requests.d.ts.map +1 -1
- package/dist/entities/spec/requests.js +80 -101
- package/dist/entities/spec/requests.js.map +7 -0
- package/dist/entities/spec/server.js +47 -63
- package/dist/entities/spec/server.js.map +7 -0
- package/dist/entities/spec/server.test.js +120 -0
- package/dist/entities/spec/server.test.js.map +7 -0
- package/dist/entities/spec/spec-objects.d.ts.map +1 -1
- package/dist/entities/spec/spec-objects.js +77 -121
- package/dist/entities/spec/spec-objects.js.map +7 -0
- package/dist/entities/spec/spec-objects.test.js +205 -0
- package/dist/entities/spec/spec-objects.test.js.map +7 -0
- package/dist/entities/spec/x-scalar-environments.js +21 -18
- package/dist/entities/spec/x-scalar-environments.js.map +7 -0
- package/dist/entities/spec/x-scalar-environments.test.js +11 -0
- package/dist/entities/spec/x-scalar-environments.test.js.map +7 -0
- package/dist/entities/spec/x-scalar-secrets.js +8 -6
- package/dist/entities/spec/x-scalar-secrets.js.map +7 -0
- package/dist/entities/spec/x-scalar-secrets.test.js +11 -0
- package/dist/entities/spec/x-scalar-secrets.test.js.map +7 -0
- package/dist/entities/workspace/index.d.ts +1 -1
- package/dist/entities/workspace/index.d.ts.map +1 -1
- package/dist/entities/workspace/index.js +7 -1
- package/dist/entities/workspace/index.js.map +7 -0
- package/dist/entities/workspace/workspace.js +46 -50
- package/dist/entities/workspace/workspace.js.map +7 -0
- package/dist/helpers/create-hash.js +15 -18
- package/dist/helpers/create-hash.js.map +7 -0
- package/dist/helpers/ensure-protocol.js +9 -10
- package/dist/helpers/ensure-protocol.js.map +7 -0
- package/dist/helpers/ensure-protocol.test.js +70 -0
- package/dist/helpers/ensure-protocol.test.js.map +7 -0
- package/dist/helpers/fetch-document.js +24 -32
- package/dist/helpers/fetch-document.js.map +7 -0
- package/dist/helpers/fetch-document.test.js +63 -0
- package/dist/helpers/fetch-document.test.js.map +7 -0
- package/dist/helpers/fetch-with-proxy-fallback.js +20 -28
- package/dist/helpers/fetch-with-proxy-fallback.js.map +7 -0
- package/dist/helpers/find-variables.d.ts +1 -1
- package/dist/helpers/find-variables.d.ts.map +1 -1
- package/dist/helpers/find-variables.js +6 -8
- package/dist/helpers/find-variables.js.map +7 -0
- package/dist/helpers/find-variables.test.js +20 -0
- package/dist/helpers/find-variables.test.js.map +7 -0
- package/dist/helpers/http-methods.d.ts +1 -1
- package/dist/helpers/http-methods.d.ts.map +1 -1
- package/dist/helpers/http-methods.js +60 -66
- package/dist/helpers/http-methods.js.map +7 -0
- package/dist/helpers/http-status-codes.js +319 -317
- package/dist/helpers/http-status-codes.js.map +7 -0
- package/dist/helpers/index.d.ts +27 -27
- package/dist/helpers/index.d.ts.map +1 -1
- package/dist/helpers/index.js +73 -27
- package/dist/helpers/index.js.map +7 -0
- package/dist/helpers/is-defined.js +5 -14
- package/dist/helpers/is-defined.js.map +7 -0
- package/dist/helpers/is-defined.test.js +37 -0
- package/dist/helpers/is-defined.test.js.map +7 -0
- package/dist/helpers/is-local-url.js +11 -16
- package/dist/helpers/is-local-url.js.map +7 -0
- package/dist/helpers/is-local-url.test.js +40 -0
- package/dist/helpers/is-local-url.test.js.map +7 -0
- package/dist/helpers/is-valid-url.js +9 -18
- package/dist/helpers/is-valid-url.js.map +7 -0
- package/dist/helpers/is-valid-url.test.js +17 -0
- package/dist/helpers/is-valid-url.test.js.map +7 -0
- package/dist/helpers/iterate-title.js +11 -15
- package/dist/helpers/iterate-title.js.map +7 -0
- package/dist/helpers/json2xml.js +40 -47
- package/dist/helpers/json2xml.js.map +7 -0
- package/dist/helpers/json2xml.test.js +19 -0
- package/dist/helpers/json2xml.test.js.map +7 -0
- package/dist/helpers/local-storage.js +13 -15
- package/dist/helpers/local-storage.js.map +7 -0
- package/dist/helpers/make-url-absolute.js +11 -17
- package/dist/helpers/make-url-absolute.js.map +7 -0
- package/dist/helpers/make-url-absolute.test.js +61 -0
- package/dist/helpers/make-url-absolute.test.js.map +7 -0
- package/dist/helpers/merge-urls.js +50 -75
- package/dist/helpers/merge-urls.js.map +7 -0
- package/dist/helpers/merge-urls.test.js +339 -0
- package/dist/helpers/merge-urls.test.js.map +7 -0
- package/dist/helpers/normalize-mime-type-object.js +21 -31
- package/dist/helpers/normalize-mime-type-object.js.map +7 -0
- package/dist/helpers/normalize-mime-type-object.test.js +53 -0
- package/dist/helpers/normalize-mime-type-object.test.js.map +7 -0
- package/dist/helpers/normalize-mime-type.js +8 -18
- package/dist/helpers/normalize-mime-type.js.map +7 -0
- package/dist/helpers/normalize-mime-type.test.js +33 -0
- package/dist/helpers/normalize-mime-type.test.js.map +7 -0
- package/dist/helpers/object.js +12 -18
- package/dist/helpers/object.js.map +7 -0
- package/dist/helpers/omit-undefined-values.js +17 -19
- package/dist/helpers/omit-undefined-values.js.map +7 -0
- package/dist/helpers/omit-undefined-values.test.js +89 -0
- package/dist/helpers/omit-undefined-values.test.js.map +7 -0
- package/dist/helpers/parse.js +71 -83
- package/dist/helpers/parse.js.map +7 -0
- package/dist/helpers/parse.test.js +45 -0
- package/dist/helpers/parse.test.js.map +7 -0
- package/dist/helpers/pretty-print-json.js +31 -35
- package/dist/helpers/pretty-print-json.js.map +7 -0
- package/dist/helpers/pretty-print-json.test.js +28 -0
- package/dist/helpers/pretty-print-json.test.js.map +7 -0
- package/dist/helpers/redirect-to-proxy.js +46 -83
- package/dist/helpers/redirect-to-proxy.js.map +7 -0
- package/dist/helpers/redirect-to-proxy.test.js +54 -0
- package/dist/helpers/redirect-to-proxy.test.js.map +7 -0
- package/dist/helpers/regex-helpers.js +11 -9
- package/dist/helpers/regex-helpers.js.map +7 -0
- package/dist/helpers/regex-helpers.test.js +154 -0
- package/dist/helpers/regex-helpers.test.js.map +7 -0
- package/dist/helpers/replace-variables.js +13 -16
- package/dist/helpers/replace-variables.js.map +7 -0
- package/dist/helpers/replace-variables.test.js +30 -0
- package/dist/helpers/replace-variables.test.js.map +7 -0
- package/dist/helpers/schema-model.js +15 -14
- package/dist/helpers/schema-model.js.map +7 -0
- package/dist/helpers/security/get-schemes.d.ts +1 -1
- package/dist/helpers/security/get-schemes.d.ts.map +1 -1
- package/dist/helpers/security/get-schemes.js +7 -9
- package/dist/helpers/security/get-schemes.js.map +7 -0
- package/dist/helpers/security/get-schemes.test.js +71 -0
- package/dist/helpers/security/get-schemes.test.js.map +7 -0
- package/dist/helpers/security/has-token.js +18 -19
- package/dist/helpers/security/has-token.js.map +7 -0
- package/dist/helpers/security/has-token.test.js +157 -0
- package/dist/helpers/security/has-token.test.js.map +7 -0
- package/dist/helpers/security/index.d.ts +2 -2
- package/dist/helpers/security/index.d.ts.map +1 -1
- package/dist/helpers/security/index.js +7 -2
- package/dist/helpers/security/index.js.map +7 -0
- package/dist/helpers/should-ignore-entity.d.ts +2 -2
- package/dist/helpers/should-ignore-entity.d.ts.map +1 -1
- package/dist/helpers/should-ignore-entity.js +5 -6
- package/dist/helpers/should-ignore-entity.js.map +7 -0
- package/dist/helpers/ssr-state.js +6 -6
- package/dist/helpers/ssr-state.js.map +7 -0
- package/dist/helpers/string.js +6 -18
- package/dist/helpers/string.js.map +7 -0
- package/dist/migrations/data-version.js +7 -17
- package/dist/migrations/data-version.js.map +7 -0
- package/dist/migrations/generate-types.js +56 -0
- package/dist/migrations/generate-types.js.map +7 -0
- package/dist/migrations/index.d.ts +3 -3
- package/dist/migrations/index.d.ts.map +1 -1
- package/dist/migrations/index.js +10 -3
- package/dist/migrations/index.js.map +7 -0
- package/dist/migrations/local-storage.d.ts +1 -1
- package/dist/migrations/local-storage.d.ts.map +1 -1
- package/dist/migrations/local-storage.js +27 -32
- package/dist/migrations/local-storage.js.map +7 -0
- package/dist/migrations/migrator.d.ts +1 -1
- package/dist/migrations/migrator.d.ts.map +1 -1
- package/dist/migrations/migrator.js +51 -58
- package/dist/migrations/migrator.js.map +7 -0
- package/dist/migrations/semver.js +23 -25
- package/dist/migrations/semver.js.map +7 -0
- package/dist/migrations/semver.test.js +21 -0
- package/dist/migrations/semver.test.js.map +7 -0
- package/dist/migrations/v-0.0.0/types.generated.js +1 -0
- package/dist/migrations/v-0.0.0/types.generated.js.map +7 -0
- package/dist/migrations/v-2.1.0/migration.d.ts +2 -2
- package/dist/migrations/v-2.1.0/migration.d.ts.map +1 -1
- package/dist/migrations/v-2.1.0/migration.js +256 -273
- package/dist/migrations/v-2.1.0/migration.js.map +7 -0
- package/dist/migrations/v-2.1.0/types.generated.js +1 -0
- package/dist/migrations/v-2.1.0/types.generated.js.map +7 -0
- package/dist/migrations/v-2.2.0/migration.d.ts +2 -2
- package/dist/migrations/v-2.2.0/migration.d.ts.map +1 -1
- package/dist/migrations/v-2.2.0/migration.js +95 -100
- package/dist/migrations/v-2.2.0/migration.js.map +7 -0
- package/dist/migrations/v-2.2.0/types.generated.js +1 -0
- package/dist/migrations/v-2.2.0/types.generated.js.map +7 -0
- package/dist/migrations/v-2.3.0/migration.d.ts +2 -2
- package/dist/migrations/v-2.3.0/migration.d.ts.map +1 -1
- package/dist/migrations/v-2.3.0/migration.js +47 -46
- package/dist/migrations/v-2.3.0/migration.js.map +7 -0
- package/dist/migrations/v-2.3.0/types.generated.js +1 -0
- package/dist/migrations/v-2.3.0/types.generated.js.map +7 -0
- package/dist/migrations/v-2.4.0/migration.d.ts +2 -2
- package/dist/migrations/v-2.4.0/migration.d.ts.map +1 -1
- package/dist/migrations/v-2.4.0/migration.js +24 -26
- package/dist/migrations/v-2.4.0/migration.js.map +7 -0
- package/dist/migrations/v-2.4.0/migration.test.js +90 -0
- package/dist/migrations/v-2.4.0/migration.test.js.map +7 -0
- package/dist/migrations/v-2.4.0/types.generated.js +1 -0
- package/dist/migrations/v-2.4.0/types.generated.js.map +7 -0
- package/dist/migrations/v-2.5.0/migration.d.ts +2 -2
- package/dist/migrations/v-2.5.0/migration.d.ts.map +1 -1
- package/dist/migrations/v-2.5.0/migration.js +135 -119
- package/dist/migrations/v-2.5.0/migration.js.map +7 -0
- package/dist/migrations/v-2.5.0/migration.test.js +108 -0
- package/dist/migrations/v-2.5.0/migration.test.js.map +7 -0
- package/dist/migrations/v-2.5.0/types.generated.d.ts +8 -8
- package/dist/migrations/v-2.5.0/types.generated.d.ts.map +1 -1
- package/dist/migrations/v-2.5.0/types.generated.js +1 -0
- package/dist/migrations/v-2.5.0/types.generated.js.map +7 -0
- package/dist/spec-getters/get-example-from-schema.js +206 -268
- package/dist/spec-getters/get-example-from-schema.js.map +7 -0
- package/dist/spec-getters/get-example-from-schema.test.js +1092 -0
- package/dist/spec-getters/get-example-from-schema.test.js.map +7 -0
- package/dist/spec-getters/get-parameters-from-operation.js +22 -42
- package/dist/spec-getters/get-parameters-from-operation.js.map +7 -0
- package/dist/spec-getters/get-parameters-from-operation.test.js +178 -0
- package/dist/spec-getters/get-parameters-from-operation.test.js.map +7 -0
- package/dist/spec-getters/get-request-body-from-operation.js +110 -162
- package/dist/spec-getters/get-request-body-from-operation.js.map +7 -0
- package/dist/spec-getters/get-request-body-from-operation.test.js +289 -0
- package/dist/spec-getters/get-request-body-from-operation.test.js.map +7 -0
- package/dist/spec-getters/get-server-variable-examples.d.ts +1 -1
- package/dist/spec-getters/get-server-variable-examples.d.ts.map +1 -1
- package/dist/spec-getters/get-server-variable-examples.js +12 -11
- package/dist/spec-getters/get-server-variable-examples.js.map +7 -0
- package/dist/spec-getters/index.d.ts +4 -4
- package/dist/spec-getters/index.d.ts.map +1 -1
- package/dist/spec-getters/index.js +11 -4
- package/dist/spec-getters/index.js.map +7 -0
- package/dist/transforms/import-spec.d.ts +6 -6
- package/dist/transforms/import-spec.d.ts.map +1 -1
- package/dist/transforms/import-spec.js +313 -425
- package/dist/transforms/import-spec.js.map +7 -0
- package/dist/transforms/import-spec.test.js +1124 -0
- package/dist/transforms/import-spec.test.js.map +7 -0
- package/dist/transforms/index.d.ts +1 -1
- package/dist/transforms/index.d.ts.map +1 -1
- package/dist/transforms/index.js +7 -1
- package/dist/transforms/index.js.map +7 -0
- package/package.json +9 -10
|
@@ -1,99 +1,96 @@
|
|
|
1
|
-
import { selectedSecuritySchemeUidSchema } from
|
|
2
|
-
import { xScalarEnvironmentsSchema } from
|
|
3
|
-
import { xScalarSecretsSchema } from
|
|
4
|
-
import { oasSecurityRequirementSchema } from
|
|
5
|
-
import { nanoidSchema } from
|
|
6
|
-
import { z } from
|
|
7
|
-
import {
|
|
8
|
-
|
|
1
|
+
import { selectedSecuritySchemeUidSchema } from "../../entities/shared/utility.js";
|
|
2
|
+
import { xScalarEnvironmentsSchema } from "../../entities/spec/x-scalar-environments.js";
|
|
3
|
+
import { xScalarSecretsSchema } from "../../entities/spec/x-scalar-secrets.js";
|
|
4
|
+
import { oasSecurityRequirementSchema } from "@scalar/types/entities";
|
|
5
|
+
import { nanoidSchema } from "@scalar/types/utils";
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
import { oasExternalDocumentationSchema, oasInfoSchema } from "./spec-objects.js";
|
|
9
8
|
const oasCollectionSchema = z.object({
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
// servers
|
|
47
|
-
// tags
|
|
48
|
-
// security
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated
|
|
11
|
+
*
|
|
12
|
+
* Needs to be remove as it is not a spec property
|
|
13
|
+
*/
|
|
14
|
+
"type": z.literal("collection").optional().default("collection"),
|
|
15
|
+
"openapi": z.union([z.string(), z.literal("3.0.0"), z.literal("3.1.0"), z.literal("4.0.0")]).optional().default("3.1.0"),
|
|
16
|
+
"jsonSchemaDialect": z.string().optional(),
|
|
17
|
+
"info": oasInfoSchema.catch({
|
|
18
|
+
title: "API",
|
|
19
|
+
version: "1.0"
|
|
20
|
+
}),
|
|
21
|
+
/**
|
|
22
|
+
* A declaration of which security mechanisms can be used across the API. The list of
|
|
23
|
+
* values includes alternative security requirement objects that can be used. Only
|
|
24
|
+
* one of the security requirement objects need to be satisfied to authorize a request.
|
|
25
|
+
* Individual operations can override this definition. To make security optional, an empty
|
|
26
|
+
* security requirement ({}) can be included in the array.
|
|
27
|
+
*/
|
|
28
|
+
"security": z.array(oasSecurityRequirementSchema).optional().default([]),
|
|
29
|
+
"externalDocs": oasExternalDocumentationSchema.optional(),
|
|
30
|
+
/** TODO: Type these */
|
|
31
|
+
"components": z.record(z.string(), z.unknown()).optional(),
|
|
32
|
+
/** TODO: Type these */
|
|
33
|
+
"webhooks": z.record(z.string(), z.unknown()).optional(),
|
|
34
|
+
/** A custom icon representing the collection */
|
|
35
|
+
"x-scalar-icon": z.string().optional().default("interface-content-folder"),
|
|
36
|
+
"x-scalar-active-environment": z.string().optional(),
|
|
37
|
+
"x-scalar-environments": xScalarEnvironmentsSchema.optional(),
|
|
38
|
+
"x-scalar-secrets": xScalarSecretsSchema.optional()
|
|
39
|
+
// These properties will be stripped out and mapped back as id lists
|
|
40
|
+
// servers
|
|
41
|
+
// paths/**
|
|
42
|
+
// servers
|
|
43
|
+
// tags
|
|
44
|
+
// security
|
|
49
45
|
});
|
|
50
46
|
const extendedCollectionSchema = z.object({
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
* @defaults to idle for all collections, doesn't mean that it can watch for changes
|
|
94
|
-
*/
|
|
95
|
-
watchModeStatus: z.enum(['IDLE', 'WATCHING', 'ERROR']).optional().default('IDLE'),
|
|
47
|
+
uid: nanoidSchema.brand(),
|
|
48
|
+
/** A list of security schemes UIDs associated with the collection */
|
|
49
|
+
securitySchemes: z.string().array().default([]),
|
|
50
|
+
/** List of currently selected security scheme UIDs, these can be overridden per request */
|
|
51
|
+
selectedSecuritySchemeUids: selectedSecuritySchemeUidSchema,
|
|
52
|
+
/** The currently selected server */
|
|
53
|
+
selectedServerUid: z.string().brand().optional(),
|
|
54
|
+
/** UIDs which refer to servers on the workspace base */
|
|
55
|
+
servers: z.string().brand().array().default([]),
|
|
56
|
+
/** Request UIDs associated with a collection */
|
|
57
|
+
requests: z.string().brand().array().default([]),
|
|
58
|
+
/** Tag UIDs associated with the collection */
|
|
59
|
+
tags: z.string().brand().array().default([]),
|
|
60
|
+
/** List of requests without tags and top level tag "folders" */
|
|
61
|
+
children: z.union([z.string().brand(), z.string().brand()]).array().default([]),
|
|
62
|
+
/**
|
|
63
|
+
* A link to where this document is stored
|
|
64
|
+
*
|
|
65
|
+
* - Used for watch mode
|
|
66
|
+
* - Possibly useful for Git sync down the line
|
|
67
|
+
*/
|
|
68
|
+
documentUrl: z.string().optional(),
|
|
69
|
+
/**
|
|
70
|
+
* Enables polling of OpenAPI document urls
|
|
71
|
+
*
|
|
72
|
+
* @remarks Only effective when `documentUrl` is set
|
|
73
|
+
*/
|
|
74
|
+
watchMode: z.boolean().optional().default(false),
|
|
75
|
+
/** Keeps track of which integration is associated with the specific collection */
|
|
76
|
+
integration: z.string().nullable().optional(),
|
|
77
|
+
/**
|
|
78
|
+
* Selected authentication will be set at the collection level instead of the request level
|
|
79
|
+
*
|
|
80
|
+
* @default false
|
|
81
|
+
*/
|
|
82
|
+
useCollectionSecurity: z.boolean().optional().default(false),
|
|
83
|
+
/**
|
|
84
|
+
* Status of the watcher from above
|
|
85
|
+
*
|
|
86
|
+
* @defaults to idle for all collections, doesn't mean that it can watch for changes
|
|
87
|
+
*/
|
|
88
|
+
watchModeStatus: z.enum(["IDLE", "WATCHING", "ERROR"]).optional().default("IDLE")
|
|
96
89
|
});
|
|
97
90
|
const collectionSchema = oasCollectionSchema.merge(extendedCollectionSchema);
|
|
98
|
-
|
|
99
|
-
|
|
91
|
+
export {
|
|
92
|
+
collectionSchema,
|
|
93
|
+
extendedCollectionSchema,
|
|
94
|
+
oasCollectionSchema
|
|
95
|
+
};
|
|
96
|
+
//# sourceMappingURL=collection.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/entities/spec/collection.ts"],
|
|
4
|
+
"sourcesContent": ["import { selectedSecuritySchemeUidSchema } from '@/entities/shared/utility'\nimport { xScalarEnvironmentsSchema } from '@/entities/spec/x-scalar-environments'\nimport { xScalarSecretsSchema } from '@/entities/spec/x-scalar-secrets'\nimport { oasSecurityRequirementSchema } from '@scalar/types/entities'\nimport { type ENTITY_BRANDS, nanoidSchema } from '@scalar/types/utils'\nimport { z } from 'zod'\n\nimport { oasExternalDocumentationSchema, oasInfoSchema } from './spec-objects'\n\nexport const oasCollectionSchema = z.object({\n /**\n * @deprecated\n *\n * Needs to be remove as it is not a spec property\n */\n 'type': z.literal('collection').optional().default('collection'),\n 'openapi': z\n .union([z.string(), z.literal('3.0.0'), z.literal('3.1.0'), z.literal('4.0.0')])\n .optional()\n .default('3.1.0'),\n 'jsonSchemaDialect': z.string().optional(),\n 'info': oasInfoSchema.catch({\n title: 'API',\n version: '1.0',\n }),\n /**\n * A declaration of which security mechanisms can be used across the API. The list of\n * values includes alternative security requirement objects that can be used. Only\n * one of the security requirement objects need to be satisfied to authorize a request.\n * Individual operations can override this definition. To make security optional, an empty\n * security requirement ({}) can be included in the array.\n */\n 'security': z.array(oasSecurityRequirementSchema).optional().default([]),\n 'externalDocs': oasExternalDocumentationSchema.optional(),\n /** TODO: Type these */\n 'components': z.record(z.string(), z.unknown()).optional(),\n /** TODO: Type these */\n 'webhooks': z.record(z.string(), z.unknown()).optional(),\n /** A custom icon representing the collection */\n 'x-scalar-icon': z.string().optional().default('interface-content-folder'),\n 'x-scalar-active-environment': z.string().optional(),\n 'x-scalar-environments': xScalarEnvironmentsSchema.optional(),\n 'x-scalar-secrets': xScalarSecretsSchema.optional(),\n // These properties will be stripped out and mapped back as id lists\n // servers\n // paths/**\n // servers\n // tags\n // security\n})\n\nexport const extendedCollectionSchema = z.object({\n uid: nanoidSchema.brand<ENTITY_BRANDS['COLLECTION']>(),\n /** A list of security schemes UIDs associated with the collection */\n securitySchemes: z.string().array().default([]),\n /** List of currently selected security scheme UIDs, these can be overridden per request */\n selectedSecuritySchemeUids: selectedSecuritySchemeUidSchema,\n /** The currently selected server */\n selectedServerUid: z.string().brand<ENTITY_BRANDS['SERVER']>().optional(),\n /** UIDs which refer to servers on the workspace base */\n servers: z.string().brand<ENTITY_BRANDS['SERVER']>().array().default([]),\n /** Request UIDs associated with a collection */\n requests: z.string().brand<ENTITY_BRANDS['OPERATION']>().array().default([]),\n /** Tag UIDs associated with the collection */\n tags: z.string().brand<ENTITY_BRANDS['TAG']>().array().default([]),\n /** List of requests without tags and top level tag \"folders\" */\n children: z\n .union([z.string().brand<ENTITY_BRANDS['OPERATION']>(), z.string().brand<ENTITY_BRANDS['TAG']>()])\n .array()\n .default([]),\n /**\n * A link to where this document is stored\n *\n * - Used for watch mode\n * - Possibly useful for Git sync down the line\n */\n documentUrl: z.string().optional(),\n /**\n * Enables polling of OpenAPI document urls\n *\n * @remarks Only effective when `documentUrl` is set\n */\n watchMode: z.boolean().optional().default(false),\n /** Keeps track of which integration is associated with the specific collection */\n integration: z.string().nullable().optional(),\n /**\n * Selected authentication will be set at the collection level instead of the request level\n *\n * @default false\n */\n useCollectionSecurity: z.boolean().optional().default(false),\n /**\n * Status of the watcher from above\n *\n * @defaults to idle for all collections, doesn't mean that it can watch for changes\n */\n watchModeStatus: z.enum(['IDLE', 'WATCHING', 'ERROR']).optional().default('IDLE'),\n})\n\nexport const collectionSchema = oasCollectionSchema.merge(extendedCollectionSchema)\nexport type Collection = z.infer<typeof collectionSchema>\nexport type CollectionPayload = z.input<typeof collectionSchema>\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,uCAAuC;AAChD,SAAS,iCAAiC;AAC1C,SAAS,4BAA4B;AACrC,SAAS,oCAAoC;AAC7C,SAA6B,oBAAoB;AACjD,SAAS,SAAS;AAElB,SAAS,gCAAgC,qBAAqB;AAEvD,MAAM,sBAAsB,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAM1C,QAAQ,EAAE,QAAQ,YAAY,EAAE,SAAS,EAAE,QAAQ,YAAY;AAAA,EAC/D,WAAW,EACR,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,QAAQ,OAAO,GAAG,EAAE,QAAQ,OAAO,GAAG,EAAE,QAAQ,OAAO,CAAC,CAAC,EAC9E,SAAS,EACT,QAAQ,OAAO;AAAA,EAClB,qBAAqB,EAAE,OAAO,EAAE,SAAS;AAAA,EACzC,QAAQ,cAAc,MAAM;AAAA,IAC1B,OAAO;AAAA,IACP,SAAS;AAAA,EACX,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQD,YAAY,EAAE,MAAM,4BAA4B,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;AAAA,EACvE,gBAAgB,+BAA+B,SAAS;AAAA;AAAA,EAExD,cAAc,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,QAAQ,CAAC,EAAE,SAAS;AAAA;AAAA,EAEzD,YAAY,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,QAAQ,CAAC,EAAE,SAAS;AAAA;AAAA,EAEvD,iBAAiB,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,0BAA0B;AAAA,EACzE,+BAA+B,EAAE,OAAO,EAAE,SAAS;AAAA,EACnD,yBAAyB,0BAA0B,SAAS;AAAA,EAC5D,oBAAoB,qBAAqB,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOpD,CAAC;AAEM,MAAM,2BAA2B,EAAE,OAAO;AAAA,EAC/C,KAAK,aAAa,MAAmC;AAAA;AAAA,EAErD,iBAAiB,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;AAAA;AAAA,EAE9C,4BAA4B;AAAA;AAAA,EAE5B,mBAAmB,EAAE,OAAO,EAAE,MAA+B,EAAE,SAAS;AAAA;AAAA,EAExE,SAAS,EAAE,OAAO,EAAE,MAA+B,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;AAAA;AAAA,EAEvE,UAAU,EAAE,OAAO,EAAE,MAAkC,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;AAAA;AAAA,EAE3E,MAAM,EAAE,OAAO,EAAE,MAA4B,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;AAAA;AAAA,EAEjE,UAAU,EACP,MAAM,CAAC,EAAE,OAAO,EAAE,MAAkC,GAAG,EAAE,OAAO,EAAE,MAA4B,CAAC,CAAC,EAChG,MAAM,EACN,QAAQ,CAAC,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOb,aAAa,EAAE,OAAO,EAAE,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMjC,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,KAAK;AAAA;AAAA,EAE/C,aAAa,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAM5C,uBAAuB,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAM3D,iBAAiB,EAAE,KAAK,CAAC,QAAQ,YAAY,OAAO,CAAC,EAAE,SAAS,EAAE,QAAQ,MAAM;AAClF,CAAC;AAEM,MAAM,mBAAmB,oBAAoB,MAAM,wBAAwB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export { collectionSchema, type Collection, type CollectionPayload } from './collection.
|
|
2
|
-
export { oasParameterSchema, type RequestParameter, type RequestParameterPayload } from './parameters.
|
|
3
|
-
export { serverSchema, type Server, type ServerPayload } from './server.
|
|
4
|
-
export { requestSchema, type Request, type RequestPayload, type RequestMethod, type ResponseInstance, type RequestEvent, } from './requests.
|
|
5
|
-
export { requestExampleSchema, createExampleFromRequest, requestExampleParametersSchema, type RequestExample, type RequestExampleParameter, } from './request-examples.
|
|
6
|
-
export { tagSchema, oasExternalDocumentationSchema, oasInfoSchema, oasContactSchema, oasLicenseSchema, type Tag, type TagPayload, } from './spec-objects.
|
|
7
|
-
export { type Operation, type OperationPayload, operationSchema, } from './operation.
|
|
8
|
-
export { xScalarEnvironmentsSchema, type XScalarEnvironment, type XScalarEnvironments, } from './x-scalar-environments.
|
|
1
|
+
export { collectionSchema, type Collection, type CollectionPayload } from './collection.js';
|
|
2
|
+
export { oasParameterSchema, type RequestParameter, type RequestParameterPayload } from './parameters.js';
|
|
3
|
+
export { serverSchema, type Server, type ServerPayload } from './server.js';
|
|
4
|
+
export { requestSchema, type Request, type RequestPayload, type RequestMethod, type ResponseInstance, type RequestEvent, } from './requests.js';
|
|
5
|
+
export { requestExampleSchema, createExampleFromRequest, requestExampleParametersSchema, type RequestExample, type RequestExampleParameter, } from './request-examples.js';
|
|
6
|
+
export { tagSchema, oasExternalDocumentationSchema, oasInfoSchema, oasContactSchema, oasLicenseSchema, type Tag, type TagPayload, } from './spec-objects.js';
|
|
7
|
+
export { type Operation, type OperationPayload, operationSchema, } from './operation.js';
|
|
8
|
+
export { xScalarEnvironmentsSchema, type XScalarEnvironment, type XScalarEnvironments, } from './x-scalar-environments.js';
|
|
9
9
|
/** Re-exported here for ease of use but we should use the other ones directly */
|
|
10
10
|
export { type Oauth2Flow, type Oauth2FlowPayload, type SecuritySchemaHttp, type SecuritySchemaOpenId, type SecurityScheme, type SecuritySchemeApiKey, type SecuritySchemeOauth2, type SecuritySchemeOauth2Payload, type SecuritySchemePayload, oasSecurityRequirementSchema, oasSecuritySchemeSchema, pkceOptions, securityApiKeySchema, securityHttpSchema, securityOauthSchema, securityOpenIdSchema, securitySchemeSchema, } from '@scalar/types/entities';
|
|
11
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,KAAK,UAAU,EAAE,KAAK,iBAAiB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,KAAK,UAAU,EAAE,KAAK,iBAAiB,EAAE,MAAM,cAAc,CAAA;AACxF,OAAO,EAAE,kBAAkB,EAAE,KAAK,gBAAgB,EAAE,KAAK,uBAAuB,EAAE,MAAM,cAAc,CAAA;AACtG,OAAO,EAAE,YAAY,EAAE,KAAK,MAAM,EAAE,KAAK,aAAa,EAAE,MAAM,UAAU,CAAA;AACxE,OAAO,EACL,aAAa,EACb,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,YAAY,GAClB,MAAM,YAAY,CAAA;AAEnB,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EACxB,8BAA8B,EAC9B,KAAK,cAAc,EACnB,KAAK,uBAAuB,GAC7B,MAAM,oBAAoB,CAAA;AAE3B,OAAO,EACL,SAAS,EACT,8BAA8B,EAC9B,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,KAAK,GAAG,EACR,KAAK,UAAU,GAChB,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EACL,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,eAAe,GAChB,MAAM,aAAa,CAAA;AAEpB,OAAO,EACL,yBAAyB,EACzB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,GACzB,MAAM,yBAAyB,CAAA;AAEhC,iFAAiF;AACjF,OAAO,EACL,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACnB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,2BAA2B,EAChC,KAAK,qBAAqB,EAC1B,4BAA4B,EAC5B,uBAAuB,EACvB,WAAW,EACX,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,wBAAwB,CAAA"}
|
|
@@ -1,9 +1,59 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { collectionSchema } from "./collection.js";
|
|
2
|
+
import { oasParameterSchema } from "./parameters.js";
|
|
3
|
+
import { serverSchema } from "./server.js";
|
|
4
|
+
import {
|
|
5
|
+
requestSchema
|
|
6
|
+
} from "./requests.js";
|
|
7
|
+
import {
|
|
8
|
+
requestExampleSchema,
|
|
9
|
+
createExampleFromRequest,
|
|
10
|
+
requestExampleParametersSchema
|
|
11
|
+
} from "./request-examples.js";
|
|
12
|
+
import {
|
|
13
|
+
tagSchema,
|
|
14
|
+
oasExternalDocumentationSchema,
|
|
15
|
+
oasInfoSchema,
|
|
16
|
+
oasContactSchema,
|
|
17
|
+
oasLicenseSchema
|
|
18
|
+
} from "./spec-objects.js";
|
|
19
|
+
import {
|
|
20
|
+
operationSchema
|
|
21
|
+
} from "./operation.js";
|
|
22
|
+
import {
|
|
23
|
+
xScalarEnvironmentsSchema
|
|
24
|
+
} from "./x-scalar-environments.js";
|
|
25
|
+
import {
|
|
26
|
+
oasSecurityRequirementSchema,
|
|
27
|
+
oasSecuritySchemeSchema,
|
|
28
|
+
pkceOptions,
|
|
29
|
+
securityApiKeySchema,
|
|
30
|
+
securityHttpSchema,
|
|
31
|
+
securityOauthSchema,
|
|
32
|
+
securityOpenIdSchema,
|
|
33
|
+
securitySchemeSchema
|
|
34
|
+
} from "@scalar/types/entities";
|
|
35
|
+
export {
|
|
36
|
+
collectionSchema,
|
|
37
|
+
createExampleFromRequest,
|
|
38
|
+
oasContactSchema,
|
|
39
|
+
oasExternalDocumentationSchema,
|
|
40
|
+
oasInfoSchema,
|
|
41
|
+
oasLicenseSchema,
|
|
42
|
+
oasParameterSchema,
|
|
43
|
+
oasSecurityRequirementSchema,
|
|
44
|
+
oasSecuritySchemeSchema,
|
|
45
|
+
operationSchema,
|
|
46
|
+
pkceOptions,
|
|
47
|
+
requestExampleParametersSchema,
|
|
48
|
+
requestExampleSchema,
|
|
49
|
+
requestSchema,
|
|
50
|
+
securityApiKeySchema,
|
|
51
|
+
securityHttpSchema,
|
|
52
|
+
securityOauthSchema,
|
|
53
|
+
securityOpenIdSchema,
|
|
54
|
+
securitySchemeSchema,
|
|
55
|
+
serverSchema,
|
|
56
|
+
tagSchema,
|
|
57
|
+
xScalarEnvironmentsSchema
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/entities/spec/index.ts"],
|
|
4
|
+
"sourcesContent": ["export { collectionSchema, type Collection, type CollectionPayload } from './collection'\nexport { oasParameterSchema, type RequestParameter, type RequestParameterPayload } from './parameters'\nexport { serverSchema, type Server, type ServerPayload } from './server'\nexport {\n requestSchema,\n type Request,\n type RequestPayload,\n type RequestMethod,\n type ResponseInstance,\n type RequestEvent,\n} from './requests'\n\nexport {\n requestExampleSchema,\n createExampleFromRequest,\n requestExampleParametersSchema,\n type RequestExample,\n type RequestExampleParameter,\n} from './request-examples'\n\nexport {\n tagSchema,\n oasExternalDocumentationSchema,\n oasInfoSchema,\n oasContactSchema,\n oasLicenseSchema,\n type Tag,\n type TagPayload,\n} from './spec-objects'\n\nexport {\n type Operation,\n type OperationPayload,\n operationSchema,\n} from './operation'\n\nexport {\n xScalarEnvironmentsSchema,\n type XScalarEnvironment,\n type XScalarEnvironments,\n} from './x-scalar-environments'\n\n/** Re-exported here for ease of use but we should use the other ones directly */\nexport {\n type Oauth2Flow,\n type Oauth2FlowPayload,\n type SecuritySchemaHttp,\n type SecuritySchemaOpenId,\n type SecurityScheme,\n type SecuritySchemeApiKey,\n type SecuritySchemeOauth2,\n type SecuritySchemeOauth2Payload,\n type SecuritySchemePayload,\n oasSecurityRequirementSchema,\n oasSecuritySchemeSchema,\n pkceOptions,\n securityApiKeySchema,\n securityHttpSchema,\n securityOauthSchema,\n securityOpenIdSchema,\n securitySchemeSchema,\n} from '@scalar/types/entities'\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,wBAAiE;AAC1E,SAAS,0BAA+E;AACxF,SAAS,oBAAqD;AAC9D;AAAA,EACE;AAAA,OAMK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AAEP;AAAA,EAGE;AAAA,OACK;AAEP;AAAA,EACE;AAAA,OAGK;AAGP;AAAA,EAUE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Aliases Request to Operation which is closer to the spec,
|
|
3
3
|
* also will not conflict with the builtin Request class
|
|
4
4
|
*/
|
|
5
|
-
import { type RequestPayload, type Request as RequestType } from './requests.
|
|
5
|
+
import { type RequestPayload, type Request as RequestType } from './requests.js';
|
|
6
6
|
export type Operation = RequestType;
|
|
7
7
|
export type OperationPayload = RequestPayload;
|
|
8
8
|
export declare const operationSchema: import("zod").ZodObject<import("zod").objectUtil.extendShape<import("zod").objectUtil.extendShape<import("zod").objectUtil.extendShape<Omit<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/operation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,OAAO,IAAI,WAAW,EAAiB,MAAM,
|
|
1
|
+
{"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/operation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,OAAO,IAAI,WAAW,EAAiB,MAAM,YAAY,CAAA;AAE5F,MAAM,MAAM,SAAS,GAAG,WAAW,CAAA;AACnC,MAAM,MAAM,gBAAgB,GAAG,cAAc,CAAA;AAC7C,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aACwV,CAAC;YAAkC,CAAC;;;aAAoE,CAAC;YAAuB,CAAC;;;;;;;;aAAqT,CAAC;YAAkC,CAAC;;;aAAoE,CAAC;YAAuB,CAAC;;;;;;;;aAAwT,CAAC;YAAkC,CAAC;;;aAAoE,CAAC;YAAuB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EADxzC,CAAA"}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import { requestSchema } from
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Aliases Request to Operation which is closer to the spec,
|
|
5
|
-
* also will not conflict with the builtin Request class
|
|
6
|
-
*/
|
|
1
|
+
import { requestSchema } from "./requests.js";
|
|
7
2
|
const operationSchema = requestSchema;
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
export {
|
|
4
|
+
operationSchema
|
|
5
|
+
};
|
|
6
|
+
//# sourceMappingURL=operation.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/entities/spec/operation.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Aliases Request to Operation which is closer to the spec,\n * also will not conflict with the builtin Request class\n */\nimport { type RequestPayload, type Request as RequestType, requestSchema } from './requests'\n\nexport type Operation = RequestType\nexport type OperationPayload = RequestPayload\nexport const operationSchema = requestSchema\n"],
|
|
5
|
+
"mappings": "AAIA,SAA2D,qBAAqB;AAIzE,MAAM,kBAAkB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { operationSchema } from "./operation.js";
|
|
3
|
+
describe("operationSchema", () => {
|
|
4
|
+
describe("x-scalar-stability", () => {
|
|
5
|
+
it("parses deprecated", () => {
|
|
6
|
+
expect(
|
|
7
|
+
operationSchema.parse({
|
|
8
|
+
"x-scalar-stability": "deprecated"
|
|
9
|
+
})
|
|
10
|
+
).toMatchObject({
|
|
11
|
+
"x-scalar-stability": "deprecated"
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
it("parses experimental", () => {
|
|
15
|
+
expect(
|
|
16
|
+
operationSchema.parse({
|
|
17
|
+
"x-scalar-stability": "experimental"
|
|
18
|
+
})
|
|
19
|
+
).toMatchObject({
|
|
20
|
+
"x-scalar-stability": "experimental"
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
it("parses stable", () => {
|
|
24
|
+
expect(
|
|
25
|
+
operationSchema.parse({
|
|
26
|
+
"x-scalar-stability": "stable"
|
|
27
|
+
})
|
|
28
|
+
).toMatchObject({
|
|
29
|
+
"x-scalar-stability": "stable"
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
it("parses unknown", () => {
|
|
33
|
+
expect(
|
|
34
|
+
operationSchema.parse({
|
|
35
|
+
"x-scalar-stability": "unknown"
|
|
36
|
+
})
|
|
37
|
+
).toMatchObject({
|
|
38
|
+
"x-scalar-stability": void 0
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
//# sourceMappingURL=operation.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/entities/spec/operation.test.ts"],
|
|
4
|
+
"sourcesContent": ["import { describe, expect, it } from 'vitest'\n\nimport { operationSchema } from './operation'\n\ndescribe('operationSchema', () => {\n describe('x-scalar-stability', () => {\n it('parses deprecated', () => {\n expect(\n operationSchema.parse({\n 'x-scalar-stability': 'deprecated',\n }),\n ).toMatchObject({\n 'x-scalar-stability': 'deprecated',\n })\n })\n\n it('parses experimental', () => {\n expect(\n operationSchema.parse({\n 'x-scalar-stability': 'experimental',\n }),\n ).toMatchObject({\n 'x-scalar-stability': 'experimental',\n })\n })\n\n it('parses stable', () => {\n expect(\n operationSchema.parse({\n 'x-scalar-stability': 'stable',\n }),\n ).toMatchObject({\n 'x-scalar-stability': 'stable',\n })\n })\n\n it('parses unknown', () => {\n expect(\n operationSchema.parse({\n 'x-scalar-stability': 'unknown',\n }),\n ).toMatchObject({\n 'x-scalar-stability': undefined,\n })\n })\n })\n})\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,UAAU,QAAQ,UAAU;AAErC,SAAS,uBAAuB;AAEhC,SAAS,mBAAmB,MAAM;AAChC,WAAS,sBAAsB,MAAM;AACnC,OAAG,qBAAqB,MAAM;AAC5B;AAAA,QACE,gBAAgB,MAAM;AAAA,UACpB,sBAAsB;AAAA,QACxB,CAAC;AAAA,MACH,EAAE,cAAc;AAAA,QACd,sBAAsB;AAAA,MACxB,CAAC;AAAA,IACH,CAAC;AAED,OAAG,uBAAuB,MAAM;AAC9B;AAAA,QACE,gBAAgB,MAAM;AAAA,UACpB,sBAAsB;AAAA,QACxB,CAAC;AAAA,MACH,EAAE,cAAc;AAAA,QACd,sBAAsB;AAAA,MACxB,CAAC;AAAA,IACH,CAAC;AAED,OAAG,iBAAiB,MAAM;AACxB;AAAA,QACE,gBAAgB,MAAM;AAAA,UACpB,sBAAsB;AAAA,QACxB,CAAC;AAAA,MACH,EAAE,cAAc;AAAA,QACd,sBAAsB;AAAA,MACxB,CAAC;AAAA,IACH,CAAC;AAED,OAAG,kBAAkB,MAAM;AACzB;AAAA,QACE,gBAAgB,MAAM;AAAA,UACpB,sBAAsB;AAAA,QACxB,CAAC;AAAA,MACH,EAAE,cAAc;AAAA,QACd,sBAAsB;AAAA,MACxB,CAAC;AAAA,IACH,CAAC;AAAA,EACH,CAAC;AACH,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import type { OpenAPIV3_1 } from '@scalar/openapi-types';
|
|
3
|
-
import type { RequestExampleParameter } from './request-examples.
|
|
3
|
+
import type { RequestExampleParameter } from './request-examples.js';
|
|
4
4
|
export declare const parameterTypeSchema: z.ZodEnum<["path", "query", "header", "cookie"]>;
|
|
5
5
|
export type ParamType = z.infer<typeof parameterTypeSchema>;
|
|
6
6
|
export declare const parameterStyleSchema: z.ZodEnum<["matrix", "simple", "form", "label", "spaceDelimited", "pipeDelimited", "deepObject"]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parameters.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/parameters.ts"],"names":[],"mappings":"AACA,OAAO,EAAkB,CAAC,EAAE,MAAM,KAAK,CAAA;AACvC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"parameters.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/parameters.ts"],"names":[],"mappings":"AACA,OAAO,EAAkB,CAAC,EAAE,MAAM,KAAK,CAAA;AACvC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAA;AAEjE,eAAO,MAAM,mBAAmB,kDAAgD,CAAA;AAChF,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAE3D,eAAO,MAAM,oBAAoB,mGAQ/B,CAAA;AACF,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA;AACjE,MAAM,MAAM,gBAAgB,GAAG,MAAM,CACnC,MAAM,EACN;IACE,MAAM,CAAC,EAAE,WAAW,CAAC,QAAQ,CAAA;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAA;IAClD,OAAO,CAAC,EAAE,uBAAuB,CAAA;CAClC,CACF,CAAA;AACD,eAAO,MAAM,sBAAsB,cAAc,CAAA;AAEjD;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;;IAI7B,yBAAyB;;IAEzB,yBAAyB;;;;IAIzB,wFAAwF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgBjD,CAAA;AAEzC,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAA;AACjE,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAA"}
|
|
@@ -1,42 +1,44 @@
|
|
|
1
|
-
import { z } from
|
|
2
|
-
|
|
3
|
-
const parameterTypeSchema = z.enum(['path', 'query', 'header', 'cookie']);
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
const parameterTypeSchema = z.enum(["path", "query", "header", "cookie"]);
|
|
4
3
|
const parameterStyleSchema = z.enum([
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
"matrix",
|
|
5
|
+
"simple",
|
|
6
|
+
"form",
|
|
7
|
+
"label",
|
|
8
|
+
"spaceDelimited",
|
|
9
|
+
"pipeDelimited",
|
|
10
|
+
"deepObject"
|
|
12
11
|
]);
|
|
13
|
-
z.unknown();
|
|
14
|
-
/**
|
|
15
|
-
* OpenAPI compliant parameters object
|
|
16
|
-
*/
|
|
12
|
+
const parameterExampleSchema = z.unknown();
|
|
17
13
|
const oasParameterSchema = z.object({
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
14
|
+
in: parameterTypeSchema,
|
|
15
|
+
name: z.string(),
|
|
16
|
+
description: z.string().optional(),
|
|
17
|
+
/** Defaulted to false */
|
|
18
|
+
required: z.boolean().optional().default(false),
|
|
19
|
+
/** Defaulted to false */
|
|
20
|
+
deprecated: z.boolean().optional().default(false),
|
|
21
|
+
schema: z.unknown().optional(),
|
|
22
|
+
content: z.unknown().optional(),
|
|
23
|
+
/** Defaulted according to @url https://spec.openapis.org/oas/v3.1.0#parameter-object */
|
|
24
|
+
style: parameterStyleSchema.optional(),
|
|
25
|
+
example: z.unknown().optional(),
|
|
26
|
+
examples: z.union([
|
|
27
|
+
z.record(
|
|
28
|
+
z.string(),
|
|
29
|
+
z.object({
|
|
30
|
+
value: z.unknown().optional(),
|
|
31
|
+
summary: z.string().optional(),
|
|
32
|
+
externalValue: z.string().optional()
|
|
33
|
+
})
|
|
34
|
+
),
|
|
35
|
+
z.array(z.unknown())
|
|
36
|
+
]).optional()
|
|
40
37
|
});
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
export {
|
|
39
|
+
oasParameterSchema,
|
|
40
|
+
parameterExampleSchema,
|
|
41
|
+
parameterStyleSchema,
|
|
42
|
+
parameterTypeSchema
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=parameters.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/entities/spec/parameters.ts"],
|
|
4
|
+
"sourcesContent": ["import type { OpenAPI } from '@scalar/openapi-types'\nimport { type ZodSchema, z } from 'zod'\nimport type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport type { RequestExampleParameter } from './request-examples'\n\nexport const parameterTypeSchema = z.enum(['path', 'query', 'header', 'cookie'])\nexport type ParamType = z.infer<typeof parameterTypeSchema>\n\nexport const parameterStyleSchema = z.enum([\n 'matrix',\n 'simple',\n 'form',\n 'label',\n 'spaceDelimited',\n 'pipeDelimited',\n 'deepObject',\n])\nexport type ParameterStyle = z.infer<typeof parameterStyleSchema>\nexport type ParameterContent = Record<\n string,\n {\n schema?: OpenAPIV3_1.Document\n examples?: Record<string, RequestExampleParameter>\n example?: RequestExampleParameter\n }\n>\nexport const parameterExampleSchema = z.unknown()\n\n/**\n * OpenAPI compliant parameters object\n */\nexport const oasParameterSchema = z.object({\n in: parameterTypeSchema,\n name: z.string(),\n description: z.string().optional(),\n /** Defaulted to false */\n required: z.boolean().optional().default(false),\n /** Defaulted to false */\n deprecated: z.boolean().optional().default(false),\n schema: z.unknown().optional(),\n content: z.unknown().optional(),\n /** Defaulted according to @url https://spec.openapis.org/oas/v3.1.0#parameter-object */\n style: parameterStyleSchema.optional(),\n example: z.unknown().optional(),\n examples: z\n .union([\n z.record(\n z.string(),\n z.object({\n value: z.unknown().optional(),\n summary: z.string().optional(),\n externalValue: z.string().optional(),\n }),\n ),\n z.array(z.unknown()),\n ])\n .optional(),\n}) satisfies ZodSchema<OpenAPI.Parameter>\n\nexport type RequestParameter = z.infer<typeof oasParameterSchema>\nexport type RequestParameterPayload = z.input<typeof oasParameterSchema>\n"],
|
|
5
|
+
"mappings": "AACA,SAAyB,SAAS;AAI3B,MAAM,sBAAsB,EAAE,KAAK,CAAC,QAAQ,SAAS,UAAU,QAAQ,CAAC;AAGxE,MAAM,uBAAuB,EAAE,KAAK;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAUM,MAAM,yBAAyB,EAAE,QAAQ;AAKzC,MAAM,qBAAqB,EAAE,OAAO;AAAA,EACzC,IAAI;AAAA,EACJ,MAAM,EAAE,OAAO;AAAA,EACf,aAAa,EAAE,OAAO,EAAE,SAAS;AAAA;AAAA,EAEjC,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,KAAK;AAAA;AAAA,EAE9C,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,KAAK;AAAA,EAChD,QAAQ,EAAE,QAAQ,EAAE,SAAS;AAAA,EAC7B,SAAS,EAAE,QAAQ,EAAE,SAAS;AAAA;AAAA,EAE9B,OAAO,qBAAqB,SAAS;AAAA,EACrC,SAAS,EAAE,QAAQ,EAAE,SAAS;AAAA,EAC9B,UAAU,EACP,MAAM;AAAA,IACL,EAAE;AAAA,MACA,EAAE,OAAO;AAAA,MACT,EAAE,OAAO;AAAA,QACP,OAAO,EAAE,QAAQ,EAAE,SAAS;AAAA,QAC5B,SAAS,EAAE,OAAO,EAAE,SAAS;AAAA,QAC7B,eAAe,EAAE,OAAO,EAAE,SAAS;AAAA,MACrC,CAAC;AAAA,IACH;AAAA,IACA,EAAE,MAAM,EAAE,QAAQ,CAAC;AAAA,EACrB,CAAC,EACA,SAAS;AACd,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { oasParameterSchema } from "../../entities/spec/parameters.js";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
describe("oasParameterSchema", () => {
|
|
5
|
+
it("should validate a parameter with a correct example", () => {
|
|
6
|
+
const validParameterWithExample = {
|
|
7
|
+
in: "query",
|
|
8
|
+
name: "limit",
|
|
9
|
+
example: 10
|
|
10
|
+
};
|
|
11
|
+
expect(() => oasParameterSchema.parse(validParameterWithExample)).not.toThrow();
|
|
12
|
+
});
|
|
13
|
+
it("should validate examples as a record with correct structure", () => {
|
|
14
|
+
const validExamples = {
|
|
15
|
+
milkyWay: {
|
|
16
|
+
value: "Milky Way",
|
|
17
|
+
summary: "Our galaxy"
|
|
18
|
+
},
|
|
19
|
+
andromeda: {
|
|
20
|
+
value: "Andromeda",
|
|
21
|
+
summary: "Nearest major galaxy"
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
const validParameter = {
|
|
25
|
+
in: "query",
|
|
26
|
+
name: "galaxy",
|
|
27
|
+
examples: validExamples
|
|
28
|
+
};
|
|
29
|
+
expect(() => oasParameterSchema.parse(validParameter)).not.toThrow();
|
|
30
|
+
});
|
|
31
|
+
it("should fail validation if examples have incorrect structure", () => {
|
|
32
|
+
const invalidExamples = {
|
|
33
|
+
milkyWay: {
|
|
34
|
+
value: "Milky Way"
|
|
35
|
+
// Summary is optional, so this should not cause a failure
|
|
36
|
+
},
|
|
37
|
+
andromeda: "This should be an object, not a string"
|
|
38
|
+
};
|
|
39
|
+
const invalidParameter = {
|
|
40
|
+
in: "query",
|
|
41
|
+
name: "galaxy",
|
|
42
|
+
examples: invalidExamples
|
|
43
|
+
};
|
|
44
|
+
expect(() => oasParameterSchema.parse(invalidParameter)).toThrow(z.ZodError);
|
|
45
|
+
});
|
|
46
|
+
it("should validate examples as an array", () => {
|
|
47
|
+
const validParameter = {
|
|
48
|
+
in: "query",
|
|
49
|
+
name: "galaxy",
|
|
50
|
+
examples: ["Milky Way", "Andromeda"]
|
|
51
|
+
};
|
|
52
|
+
expect(() => oasParameterSchema.parse(validParameter)).not.toThrow();
|
|
53
|
+
});
|
|
54
|
+
it("should validate examples with a single array item", () => {
|
|
55
|
+
const validParameter = {
|
|
56
|
+
in: "query",
|
|
57
|
+
name: "galaxy",
|
|
58
|
+
examples: ["Milky Way"]
|
|
59
|
+
};
|
|
60
|
+
expect(() => oasParameterSchema.parse(validParameter)).not.toThrow();
|
|
61
|
+
});
|
|
62
|
+
it("should validate with an empty array of examples", () => {
|
|
63
|
+
const validParameter = {
|
|
64
|
+
in: "query",
|
|
65
|
+
name: "galaxy",
|
|
66
|
+
examples: []
|
|
67
|
+
};
|
|
68
|
+
expect(() => oasParameterSchema.parse(validParameter)).not.toThrow();
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
//# sourceMappingURL=parameters.test.js.map
|