@scalar/workspace-store 0.4.1 → 0.5.0
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 +6 -0
- package/dist/client.d.ts +25035 -6283
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +5 -2
- package/dist/client.js.map +2 -2
- package/dist/helpers/general.d.ts +1 -0
- package/dist/helpers/general.d.ts.map +1 -1
- package/dist/helpers/general.js +5 -1
- package/dist/helpers/general.js.map +2 -2
- package/dist/navigation/helpers/traverse-document.d.ts +2 -2
- package/dist/navigation/helpers/traverse-document.d.ts.map +1 -1
- package/dist/navigation/helpers/traverse-document.js.map +2 -2
- package/dist/navigation/helpers/traverse-paths.d.ts +2 -2
- package/dist/navigation/helpers/traverse-paths.d.ts.map +1 -1
- package/dist/navigation/helpers/traverse-paths.js +4 -0
- package/dist/navigation/helpers/traverse-paths.js.map +2 -2
- package/dist/navigation/helpers/traverse-schemas.d.ts +2 -2
- package/dist/navigation/helpers/traverse-schemas.d.ts.map +1 -1
- package/dist/navigation/helpers/traverse-schemas.js +1 -1
- package/dist/navigation/helpers/traverse-schemas.js.map +2 -2
- package/dist/navigation/helpers/traverse-tags.d.ts +2 -2
- package/dist/navigation/helpers/traverse-tags.d.ts.map +1 -1
- package/dist/navigation/helpers/traverse-tags.js +2 -2
- package/dist/navigation/helpers/traverse-tags.js.map +2 -2
- package/dist/navigation/helpers/traverse-webhooks.d.ts +2 -2
- package/dist/navigation/helpers/traverse-webhooks.d.ts.map +1 -1
- package/dist/navigation/helpers/traverse-webhooks.js +4 -0
- package/dist/navigation/helpers/traverse-webhooks.js.map +2 -2
- package/dist/navigation/types.d.ts +11 -10
- package/dist/navigation/types.d.ts.map +1 -1
- package/dist/schemas/typebox-coerce.d.ts +26 -0
- package/dist/schemas/typebox-coerce.d.ts.map +1 -0
- package/dist/schemas/typebox-coerce.js +8 -0
- package/dist/schemas/typebox-coerce.js.map +7 -0
- package/dist/schemas/v3.1/compose.d.ts +6 -0
- package/dist/schemas/v3.1/compose.d.ts.map +1 -0
- package/dist/schemas/v3.1/compose.js +8 -0
- package/dist/schemas/v3.1/compose.js.map +7 -0
- package/dist/schemas/v3.1/strict/callback.d.ts +3 -0
- package/dist/schemas/v3.1/strict/callback.d.ts.map +1 -0
- package/dist/schemas/v3.1/strict/callback.js +15 -0
- package/dist/schemas/v3.1/strict/callback.js.map +7 -0
- package/dist/schemas/v3.1/strict/components.d.ts +7824 -0
- package/dist/schemas/v3.1/strict/components.d.ts.map +1 -0
- package/dist/schemas/v3.1/strict/components.js +46 -0
- package/dist/schemas/v3.1/strict/components.js.map +7 -0
- package/dist/schemas/{openapi-v3 → v3.1/strict}/contact.d.ts +4 -2
- package/dist/schemas/v3.1/strict/contact.d.ts.map +1 -0
- package/dist/schemas/v3.1/strict/contact.js +18 -0
- package/dist/schemas/v3.1/strict/contact.js.map +7 -0
- package/dist/schemas/{openapi-v3 → v3.1/strict}/discriminator.d.ts +4 -2
- package/dist/schemas/v3.1/strict/discriminator.d.ts.map +1 -0
- package/dist/schemas/v3.1/strict/discriminator.js +16 -0
- package/dist/schemas/v3.1/strict/discriminator.js.map +7 -0
- package/dist/schemas/{openapi-v3 → v3.1/strict}/encoding.d.ts +7 -16
- package/dist/schemas/v3.1/strict/encoding.d.ts.map +1 -0
- package/dist/schemas/v3.1/strict/encoding.js +17 -0
- package/dist/schemas/v3.1/strict/encoding.js.map +7 -0
- package/dist/schemas/{openapi-v3 → v3.1/strict}/example.d.ts +4 -2
- package/dist/schemas/v3.1/strict/example.d.ts.map +1 -0
- package/dist/schemas/v3.1/strict/example.js +20 -0
- package/dist/schemas/v3.1/strict/example.js.map +7 -0
- package/dist/schemas/v3.1/strict/extensions.d.ts +4 -0
- package/dist/schemas/v3.1/strict/extensions.d.ts.map +1 -0
- package/dist/schemas/v3.1/strict/extensions.js +6 -0
- package/dist/schemas/v3.1/strict/extensions.js.map +7 -0
- package/dist/schemas/v3.1/strict/external-documentation.d.ts +10 -0
- package/dist/schemas/v3.1/strict/external-documentation.d.ts.map +1 -0
- package/dist/schemas/v3.1/strict/external-documentation.js +16 -0
- package/dist/schemas/v3.1/strict/external-documentation.js.map +7 -0
- package/dist/schemas/v3.1/strict/header.d.ts +133 -0
- package/dist/schemas/v3.1/strict/header.d.ts.map +1 -0
- package/dist/schemas/v3.1/strict/header.js +48 -0
- package/dist/schemas/v3.1/strict/header.js.map +7 -0
- package/dist/schemas/{openapi-v3 → v3.1/strict}/info.d.ts +8 -6
- package/dist/schemas/v3.1/strict/info.d.ts.map +1 -0
- package/dist/schemas/v3.1/strict/info.js +28 -0
- package/dist/schemas/v3.1/strict/info.js.map +7 -0
- package/dist/schemas/{openapi-v3 → v3.1/strict}/license.d.ts +4 -2
- package/dist/schemas/v3.1/strict/license.d.ts.map +1 -0
- package/dist/schemas/v3.1/strict/license.js +18 -0
- package/dist/schemas/v3.1/strict/license.js.map +7 -0
- package/dist/schemas/{openapi-v3 → v3.1/strict}/link.d.ts +8 -6
- package/dist/schemas/v3.1/strict/link.d.ts.map +1 -0
- package/dist/schemas/v3.1/strict/link.js +25 -0
- package/dist/schemas/v3.1/strict/link.js.map +7 -0
- package/dist/schemas/v3.1/strict/media-header-encoding.d.ts +329 -0
- package/dist/schemas/v3.1/strict/media-header-encoding.d.ts.map +1 -0
- package/dist/schemas/v3.1/strict/media-header-encoding.js +19 -0
- package/dist/schemas/v3.1/strict/media-header-encoding.js.map +7 -0
- package/dist/schemas/{openapi-v3 → v3.1/strict}/media-type.d.ts +20 -34
- package/dist/schemas/v3.1/strict/media-type.d.ts.map +1 -0
- package/dist/schemas/v3.1/strict/media-type.js +27 -0
- package/dist/schemas/v3.1/strict/media-type.js.map +7 -0
- package/dist/schemas/{openapi-v3 → v3.1/strict}/oauth-flow.d.ts +4 -2
- package/dist/schemas/v3.1/strict/oauth-flow.d.ts.map +1 -0
- package/dist/schemas/v3.1/strict/oauth-flow.js +20 -0
- package/dist/schemas/v3.1/strict/oauth-flow.js.map +7 -0
- package/dist/schemas/{openapi-v3 → v3.1/strict}/oauthflows.d.ts +12 -10
- package/dist/schemas/v3.1/strict/oauthflows.d.ts.map +1 -0
- package/dist/schemas/v3.1/strict/oauthflows.js +21 -0
- package/dist/schemas/v3.1/strict/oauthflows.js.map +7 -0
- package/dist/schemas/v3.1/strict/openapi-document.d.ts +49 -0
- package/dist/schemas/v3.1/strict/openapi-document.d.ts.map +1 -0
- package/dist/schemas/v3.1/strict/openapi-document.js +55 -0
- package/dist/schemas/v3.1/strict/openapi-document.js.map +7 -0
- package/dist/schemas/v3.1/strict/operation.d.ts +572 -0
- package/dist/schemas/v3.1/strict/operation.d.ts.map +1 -0
- package/dist/schemas/v3.1/strict/operation.js +46 -0
- package/dist/schemas/v3.1/strict/operation.js.map +7 -0
- package/dist/schemas/v3.1/strict/parameter.d.ts +396 -0
- package/dist/schemas/v3.1/strict/parameter.d.ts.map +1 -0
- package/dist/schemas/v3.1/strict/parameter.js +56 -0
- package/dist/schemas/v3.1/strict/parameter.js.map +7 -0
- package/dist/schemas/v3.1/strict/path-item.d.ts +205 -0
- package/dist/schemas/v3.1/strict/path-item.d.ts.map +1 -0
- package/dist/schemas/v3.1/strict/path-item.js +41 -0
- package/dist/schemas/v3.1/strict/path-item.js.map +7 -0
- package/dist/schemas/v3.1/strict/path-operations.d.ts +7816 -0
- package/dist/schemas/v3.1/strict/path-operations.d.ts.map +1 -0
- package/dist/schemas/v3.1/strict/path-operations.js +19 -0
- package/dist/schemas/v3.1/strict/path-operations.js.map +7 -0
- package/dist/schemas/v3.1/strict/paths.d.ts +3536 -0
- package/dist/schemas/{openapi-v3/openapi-document.d.ts.map → v3.1/strict/paths.d.ts.map} +1 -1
- package/dist/schemas/v3.1/strict/paths.js +16 -0
- package/dist/schemas/v3.1/strict/paths.js.map +7 -0
- package/dist/schemas/{openapi-v3 → v3.1/strict}/reference.d.ts +15 -6
- package/dist/schemas/v3.1/strict/reference.d.ts.map +1 -0
- package/dist/schemas/v3.1/strict/reference.js +26 -0
- package/dist/schemas/v3.1/strict/reference.js.map +7 -0
- package/dist/schemas/v3.1/strict/request-body.d.ts +112 -0
- package/dist/schemas/v3.1/strict/request-body.d.ts.map +1 -0
- package/dist/schemas/v3.1/strict/request-body.js +19 -0
- package/dist/schemas/v3.1/strict/request-body.js.map +7 -0
- package/dist/schemas/v3.1/strict/response.d.ts +242 -0
- package/dist/schemas/v3.1/strict/response.d.ts.map +1 -0
- package/dist/schemas/v3.1/strict/response.js +23 -0
- package/dist/schemas/v3.1/strict/response.js.map +7 -0
- package/dist/schemas/v3.1/strict/responses.d.ts +254 -0
- package/dist/schemas/v3.1/strict/responses.d.ts.map +1 -0
- package/dist/schemas/v3.1/strict/responses.js +13 -0
- package/dist/schemas/v3.1/strict/responses.js.map +7 -0
- package/dist/schemas/{openapi-v3 → v3.1/strict}/schema.d.ts +12 -8
- package/dist/schemas/v3.1/strict/schema.d.ts.map +1 -0
- package/dist/schemas/v3.1/strict/schema.js +34 -0
- package/dist/schemas/v3.1/strict/schema.js.map +7 -0
- package/dist/schemas/{openapi-v3 → v3.1/strict}/security-requirement.d.ts +3 -1
- package/dist/schemas/v3.1/strict/security-requirement.d.ts.map +1 -0
- package/dist/schemas/v3.1/strict/security-requirement.js +15 -0
- package/dist/schemas/v3.1/strict/security-requirement.js.map +7 -0
- package/dist/schemas/{openapi-v3 → v3.1/strict}/security-scheme.d.ts +40 -38
- package/dist/schemas/v3.1/strict/security-scheme.d.ts.map +1 -0
- package/dist/schemas/{openapi-v3 → v3.1/strict}/security-scheme.js +21 -16
- package/dist/schemas/v3.1/strict/security-scheme.js.map +7 -0
- package/dist/schemas/{openapi-v3 → v3.1/strict}/server-variable.d.ts +4 -2
- package/dist/schemas/v3.1/strict/server-variable.d.ts.map +1 -0
- package/dist/schemas/v3.1/strict/server-variable.js +18 -0
- package/dist/schemas/v3.1/strict/server-variable.js.map +7 -0
- package/dist/schemas/{openapi-v3 → v3.1/strict}/server.d.ts +6 -4
- package/dist/schemas/v3.1/strict/server.d.ts.map +1 -0
- package/dist/schemas/v3.1/strict/server.js +19 -0
- package/dist/schemas/v3.1/strict/server.js.map +7 -0
- package/dist/schemas/v3.1/strict/tag.d.ts +17 -0
- package/dist/schemas/v3.1/strict/tag.d.ts.map +1 -0
- package/dist/schemas/v3.1/strict/tag.js +25 -0
- package/dist/schemas/v3.1/strict/tag.js.map +7 -0
- package/dist/schemas/{openapi-v3 → v3.1/strict}/xml.d.ts +4 -2
- package/dist/schemas/v3.1/strict/xml.d.ts.map +1 -0
- package/dist/schemas/v3.1/strict/xml.js +22 -0
- package/dist/schemas/v3.1/strict/xml.js.map +7 -0
- package/dist/schemas/v3.1/type-guard.d.ts +3 -0
- package/dist/schemas/v3.1/type-guard.d.ts.map +1 -0
- package/dist/schemas/v3.1/type-guard.js +7 -0
- package/dist/schemas/v3.1/type-guard.js.map +7 -0
- package/dist/schemas/workspace.d.ts +49 -14750
- package/dist/schemas/workspace.d.ts.map +1 -1
- package/dist/schemas/workspace.js +5 -4
- package/dist/schemas/workspace.js.map +2 -2
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js.map +2 -2
- package/dist/server.d.ts +2579 -5
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +14 -6
- package/dist/server.js.map +2 -2
- package/package.json +5 -4
- package/dist/schemas/openapi-v3/callback.d.ts +0 -1156
- package/dist/schemas/openapi-v3/callback.d.ts.map +0 -1
- package/dist/schemas/openapi-v3/callback.js +0 -11
- package/dist/schemas/openapi-v3/callback.js.map +0 -7
- package/dist/schemas/openapi-v3/components.d.ts +0 -2597
- package/dist/schemas/openapi-v3/components.d.ts.map +0 -1
- package/dist/schemas/openapi-v3/components.js +0 -38
- package/dist/schemas/openapi-v3/components.js.map +0 -7
- package/dist/schemas/openapi-v3/contact.d.ts.map +0 -1
- package/dist/schemas/openapi-v3/contact.js +0 -13
- package/dist/schemas/openapi-v3/contact.js.map +0 -7
- package/dist/schemas/openapi-v3/discriminator.d.ts.map +0 -1
- package/dist/schemas/openapi-v3/discriminator.js +0 -11
- package/dist/schemas/openapi-v3/discriminator.js.map +0 -7
- package/dist/schemas/openapi-v3/encoding.d.ts.map +0 -1
- package/dist/schemas/openapi-v3/encoding.js +0 -13
- package/dist/schemas/openapi-v3/encoding.js.map +0 -7
- package/dist/schemas/openapi-v3/example.d.ts.map +0 -1
- package/dist/schemas/openapi-v3/example.js +0 -15
- package/dist/schemas/openapi-v3/example.js.map +0 -7
- package/dist/schemas/openapi-v3/external-documentation.d.ts +0 -8
- package/dist/schemas/openapi-v3/external-documentation.d.ts.map +0 -1
- package/dist/schemas/openapi-v3/external-documentation.js +0 -11
- package/dist/schemas/openapi-v3/external-documentation.js.map +0 -7
- package/dist/schemas/openapi-v3/header.d.ts +0 -18
- package/dist/schemas/openapi-v3/header.d.ts.map +0 -1
- package/dist/schemas/openapi-v3/header.js +0 -13
- package/dist/schemas/openapi-v3/header.js.map +0 -7
- package/dist/schemas/openapi-v3/info.d.ts.map +0 -1
- package/dist/schemas/openapi-v3/info.js +0 -23
- package/dist/schemas/openapi-v3/info.js.map +0 -7
- package/dist/schemas/openapi-v3/license.d.ts.map +0 -1
- package/dist/schemas/openapi-v3/license.js +0 -13
- package/dist/schemas/openapi-v3/license.js.map +0 -7
- package/dist/schemas/openapi-v3/link.d.ts.map +0 -1
- package/dist/schemas/openapi-v3/link.js +0 -20
- package/dist/schemas/openapi-v3/link.js.map +0 -7
- package/dist/schemas/openapi-v3/media-type.d.ts.map +0 -1
- package/dist/schemas/openapi-v3/media-type.js +0 -19
- package/dist/schemas/openapi-v3/media-type.js.map +0 -7
- package/dist/schemas/openapi-v3/oauth-flow.d.ts.map +0 -1
- package/dist/schemas/openapi-v3/oauth-flow.js +0 -15
- package/dist/schemas/openapi-v3/oauth-flow.js.map +0 -7
- package/dist/schemas/openapi-v3/oauthflows.d.ts.map +0 -1
- package/dist/schemas/openapi-v3/oauthflows.js +0 -16
- package/dist/schemas/openapi-v3/oauthflows.js.map +0 -7
- package/dist/schemas/openapi-v3/openapi-document.d.ts +0 -4941
- package/dist/schemas/openapi-v3/openapi-document.js +0 -35
- package/dist/schemas/openapi-v3/openapi-document.js.map +0 -7
- package/dist/schemas/openapi-v3/operation-without-callback.d.ts +0 -200
- package/dist/schemas/openapi-v3/operation-without-callback.d.ts.map +0 -1
- package/dist/schemas/openapi-v3/operation-without-callback.js +0 -39
- package/dist/schemas/openapi-v3/operation-without-callback.js.map +0 -7
- package/dist/schemas/openapi-v3/parameter.d.ts +0 -25
- package/dist/schemas/openapi-v3/parameter.d.ts.map +0 -1
- package/dist/schemas/openapi-v3/parameter.js +0 -22
- package/dist/schemas/openapi-v3/parameter.js.map +0 -7
- package/dist/schemas/openapi-v3/path-item.d.ts +0 -1167
- package/dist/schemas/openapi-v3/path-item.d.ts.map +0 -1
- package/dist/schemas/openapi-v3/path-item.js +0 -37
- package/dist/schemas/openapi-v3/path-item.js.map +0 -7
- package/dist/schemas/openapi-v3/paths.d.ts +0 -1154
- package/dist/schemas/openapi-v3/paths.d.ts.map +0 -1
- package/dist/schemas/openapi-v3/paths.js +0 -11
- package/dist/schemas/openapi-v3/paths.js.map +0 -7
- package/dist/schemas/openapi-v3/reference.d.ts.map +0 -1
- package/dist/schemas/openapi-v3/reference.js +0 -17
- package/dist/schemas/openapi-v3/reference.js.map +0 -7
- package/dist/schemas/openapi-v3/request-body.d.ts +0 -56
- package/dist/schemas/openapi-v3/request-body.d.ts.map +0 -1
- package/dist/schemas/openapi-v3/request-body.js +0 -14
- package/dist/schemas/openapi-v3/request-body.js.map +0 -7
- package/dist/schemas/openapi-v3/response.d.ts +0 -88
- package/dist/schemas/openapi-v3/response.d.ts.map +0 -1
- package/dist/schemas/openapi-v3/response.js +0 -19
- package/dist/schemas/openapi-v3/response.js.map +0 -7
- package/dist/schemas/openapi-v3/responses.d.ts +0 -99
- package/dist/schemas/openapi-v3/responses.d.ts.map +0 -1
- package/dist/schemas/openapi-v3/responses.js +0 -8
- package/dist/schemas/openapi-v3/responses.js.map +0 -7
- package/dist/schemas/openapi-v3/schema.d.ts.map +0 -1
- package/dist/schemas/openapi-v3/schema.js +0 -22
- package/dist/schemas/openapi-v3/schema.js.map +0 -7
- package/dist/schemas/openapi-v3/security-requirement.d.ts.map +0 -1
- package/dist/schemas/openapi-v3/security-requirement.js +0 -10
- package/dist/schemas/openapi-v3/security-requirement.js.map +0 -7
- package/dist/schemas/openapi-v3/security-scheme.d.ts.map +0 -1
- package/dist/schemas/openapi-v3/security-scheme.js.map +0 -7
- package/dist/schemas/openapi-v3/server-variable.d.ts.map +0 -1
- package/dist/schemas/openapi-v3/server-variable.js +0 -13
- package/dist/schemas/openapi-v3/server-variable.js.map +0 -7
- package/dist/schemas/openapi-v3/server.d.ts.map +0 -1
- package/dist/schemas/openapi-v3/server.js +0 -14
- package/dist/schemas/openapi-v3/server.js.map +0 -7
- package/dist/schemas/openapi-v3/tag.d.ts +0 -13
- package/dist/schemas/openapi-v3/tag.d.ts.map +0 -1
- package/dist/schemas/openapi-v3/tag.js +0 -14
- package/dist/schemas/openapi-v3/tag.js.map +0 -7
- package/dist/schemas/openapi-v3/xml.d.ts.map +0 -1
- package/dist/schemas/openapi-v3/xml.js +0 -17
- package/dist/schemas/openapi-v3/xml.js.map +0 -7
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAG/E,OAAO,EAAoB,KAAK,uBAAuB,EAAE,MAAM,cAAc,CAAA;AAG7E,OAAO,EAAyB,KAAK,eAAe,EAAE,MAAM,wCAAwC,CAAA;AACpG,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA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from "./navigation/index.js";
|
|
6
6
|
import { extensions } from "./schemas/extensions.js";
|
|
7
|
+
import { coerceValue } from "./schemas/typebox-coerce.js";
|
|
8
|
+
import { OpenAPIDocumentSchema } from "./schemas/v3.1/strict/openapi-document.js";
|
|
9
|
+
import { keyOf } from "./helpers/general.js";
|
|
7
10
|
const DEFAULT_ASSETS_FOLDER = "assets";
|
|
8
11
|
const WORKSPACE_FILE_NAME = "scalar-workspace.json";
|
|
9
12
|
const httpMethods = /* @__PURE__ */ new Set(["get", "put", "post", "delete", "options", "head", "patch", "trace"]);
|
|
@@ -38,6 +41,9 @@ function externalizeComponentReferences(document, meta) {
|
|
|
38
41
|
return result;
|
|
39
42
|
}
|
|
40
43
|
Object.entries(document.components).forEach(([type, component]) => {
|
|
44
|
+
if (!component || typeof component !== "object") {
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
41
47
|
result[type] = {};
|
|
42
48
|
Object.keys(component).forEach((name) => {
|
|
43
49
|
const ref = meta.mode === "ssr" ? `${meta.baseUrl}/${meta.name}/components/${type}/${name}#` : `${meta.directory}/chunks/${meta.name}/components/${type}/${name}.json#`;
|
|
@@ -52,17 +58,18 @@ function externalizePathReferences(document, meta) {
|
|
|
52
58
|
return result;
|
|
53
59
|
}
|
|
54
60
|
Object.entries(document.paths).forEach(([path, pathItem]) => {
|
|
55
|
-
if (!pathItem) {
|
|
61
|
+
if (!pathItem || typeof pathItem !== "object") {
|
|
56
62
|
return result;
|
|
57
63
|
}
|
|
64
|
+
const pathItemRecord = pathItem;
|
|
58
65
|
result[path] = {};
|
|
59
66
|
const escapedPath = escapeJsonPointer(path);
|
|
60
|
-
|
|
67
|
+
keyOf(pathItemRecord).forEach((type) => {
|
|
61
68
|
if (httpMethods.has(type)) {
|
|
62
69
|
const ref = meta.mode === "ssr" ? `${meta.baseUrl}/${meta.name}/operations/${escapedPath}/${type}#` : `${meta.directory}/chunks/${meta.name}/operations/${escapedPath}/${type}.json#`;
|
|
63
70
|
result[path][type] = { "$ref": ref, $global: true };
|
|
64
71
|
} else {
|
|
65
|
-
result[path][type] =
|
|
72
|
+
result[path][type] = pathItemRecord[type];
|
|
66
73
|
}
|
|
67
74
|
});
|
|
68
75
|
});
|
|
@@ -71,7 +78,8 @@ function externalizePathReferences(document, meta) {
|
|
|
71
78
|
function createServerWorkspaceStore(workspaceProps) {
|
|
72
79
|
const documents = workspaceProps.documents.map((el) => {
|
|
73
80
|
const document = upgrade(el.document).specification;
|
|
74
|
-
|
|
81
|
+
const castedDocument = coerceValue(OpenAPIDocumentSchema, document);
|
|
82
|
+
return { ...el, document: castedDocument };
|
|
75
83
|
});
|
|
76
84
|
const assets = documents.reduce((acc, { name, document }) => {
|
|
77
85
|
acc[name] = {
|
|
@@ -181,7 +189,7 @@ function createServerWorkspaceStore(workspaceProps) {
|
|
|
181
189
|
*/
|
|
182
190
|
addDocument: (document, meta) => {
|
|
183
191
|
const { name, ...documentMeta } = meta;
|
|
184
|
-
const documentV3 = upgrade(document).specification;
|
|
192
|
+
const documentV3 = coerceValue(OpenAPIDocumentSchema, upgrade(document).specification);
|
|
185
193
|
assets[meta.name] = {
|
|
186
194
|
components: documentV3.components,
|
|
187
195
|
operations: documentV3.paths && escapePaths(filterHttpMethodsOnly(documentV3.paths))
|
|
@@ -189,7 +197,7 @@ function createServerWorkspaceStore(workspaceProps) {
|
|
|
189
197
|
const options = workspaceProps.mode === "ssr" ? { mode: workspaceProps.mode, name, baseUrl: workspaceProps.baseUrl } : { mode: workspaceProps.mode, name, directory: workspaceProps.directory ?? DEFAULT_ASSETS_FOLDER };
|
|
190
198
|
const components = externalizeComponentReferences(documentV3, options);
|
|
191
199
|
const paths = externalizePathReferences(documentV3, options);
|
|
192
|
-
const { entries } = createNavigation(
|
|
200
|
+
const { entries } = createNavigation(documentV3, workspaceProps.config ?? {});
|
|
193
201
|
workspace.documents[meta.name] = {
|
|
194
202
|
...documentMeta,
|
|
195
203
|
...documentV3,
|
package/dist/server.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/server.ts"],
|
|
4
|
-
"sourcesContent": ["import { escapeJsonPointer, upgrade } from '@scalar/openapi-parser'\nimport type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport { getValueByPath, parseJsonPointer } from './helpers/json-path-utils'\nimport type { WorkspaceDocumentMeta, WorkspaceMeta } from './schemas/workspace'\nimport fs from 'node:fs/promises'\nimport { cwd } from 'node:process'\nimport { createNavigation, type createNavigationOptions } from '@/navigation'\nimport { extensions } from '@/schemas/extensions'\n\nconst DEFAULT_ASSETS_FOLDER = 'assets'\nexport const WORKSPACE_FILE_NAME = 'scalar-workspace.json'\n\n// TODO: support input document from different sources\ntype CreateServerWorkspaceStoreBase = {\n documents: {\n name: string\n document: Record<string, unknown> | string\n meta?: WorkspaceDocumentMeta\n }[]\n meta?: WorkspaceMeta\n config?: createNavigationOptions\n}\ntype CreateServerWorkspaceStore =\n | ({\n directory?: string\n mode: 'static'\n } & CreateServerWorkspaceStoreBase)\n | ({\n baseUrl: string\n mode: 'ssr'\n } & CreateServerWorkspaceStoreBase)\n\nconst httpMethods = new Set(['get', 'put', 'post', 'delete', 'options', 'head', 'patch', 'trace'])\n\n/**\n * Filters an OpenAPI PathsObject to only include standard HTTP methods.\n * Removes any vendor extensions or other non-HTTP properties.\n *\n * @param paths - The OpenAPI PathsObject to filter\n * @returns A new PathsObject containing only standard HTTP methods\n *\n * @example\n * Input: {\n * \"/users\": {\n * \"get\": {...},\n * \"x-custom\": {...},\n * \"post\": {...}\n * }\n * }\n * Output: {\n * \"/users\": {\n * \"get\": {...},\n * \"post\": {...}\n * }\n * }\n */\nexport function filterHttpMethodsOnly(paths: OpenAPIV3_1.PathsObject) {\n const result: OpenAPIV3_1.PathsObject = {}\n\n for (const [path, methods] of Object.entries(paths)) {\n if (!methods) {\n continue\n }\n\n const filteredMethods: Record<string, any> = {}\n\n for (const [method, operation] of Object.entries(methods)) {\n if (httpMethods.has(method.toLowerCase())) {\n filteredMethods[method] = operation\n }\n }\n\n if (Object.keys(filteredMethods).length > 0) {\n result[path] = filteredMethods\n }\n }\n\n return result\n}\n\n/**\n * Escapes path keys in an OpenAPI PathsObject to be JSON Pointer compatible.\n * This is necessary because OpenAPI paths can contain characters that need to be escaped\n * when used as JSON Pointer references (like '/' and '~').\n *\n * @example\n * Input: { \"/users/{id}\": { ... } }\n * Output: { \"/users~1{id}\": { ... } }\n */\nexport function escapePaths(paths: OpenAPIV3_1.PathsObject) {\n const result: OpenAPIV3_1.PathsObject = {}\n Object.keys(paths).forEach((path) => {\n result[escapeJsonPointer(path)] = paths[path]\n })\n\n return result\n}\n\n/**\n * Externalizes components by turning them into refs.\n */\nexport function externalizeComponentReferences(\n document: OpenAPIV3_1.Document,\n meta: { mode: 'ssr'; name: string; baseUrl: string } | { mode: 'static'; name: string; directory: string },\n) {\n const result: Record<string, any> = {}\n\n if (!document.components) {\n return result\n }\n\n Object.entries(document.components).forEach(([type, component]) => {\n result[type] = {}\n Object.keys(component).forEach((name) => {\n const ref =\n meta.mode === 'ssr'\n ? `${meta.baseUrl}/${meta.name}/components/${type}/${name}#`\n : `${meta.directory}/chunks/${meta.name}/components/${type}/${name}.json#`\n\n result[type][name] = { '$ref': ref, $global: true }\n })\n })\n\n return result\n}\n\n/**\n * Externalizes paths operations by turning them into refs.\n */\nexport function externalizePathReferences(\n document: OpenAPIV3_1.Document,\n meta: { mode: 'ssr'; name: string; baseUrl: string } | { mode: 'static'; name: string; directory: string },\n) {\n const result: Record<string, any> = {}\n\n if (!document.paths) {\n return result\n }\n\n Object.entries(document.paths).forEach(([path, pathItem]) => {\n if (!pathItem) {\n return result\n }\n\n result[path] = {}\n\n const escapedPath = escapeJsonPointer(path)\n\n Object.keys(pathItem).forEach((type) => {\n if (httpMethods.has(type)) {\n const ref =\n meta.mode === 'ssr'\n ? `${meta.baseUrl}/${meta.name}/operations/${escapedPath}/${type}#`\n : `${meta.directory}/chunks/${meta.name}/operations/${escapedPath}/${type}.json#`\n\n result[path][type] = { '$ref': ref, $global: true }\n } else {\n result[path][type] = pathItem[type]\n }\n })\n })\n\n return result\n}\n\n/**\n * Create server state workspace store\n */\nexport function createServerWorkspaceStore(workspaceProps: CreateServerWorkspaceStore) {\n const documents = workspaceProps.documents.map((el) => {\n const document = upgrade(el.document).specification\n\n return { ...el, document }\n })\n\n /**\n * A map of document chunks that can be loaded asynchronously by the client.\n * Each document is split into components and operations to enable lazy loading.\n * The keys are document names and values contain the components and operations\n * for that document.\n */\n const assets = documents.reduce<\n Record<string, { components?: OpenAPIV3_1.ComponentsObject; operations?: Record<string, unknown> }>\n >((acc, { name, document }) => {\n acc[name] = {\n components: document.components,\n operations: document.paths && escapePaths(filterHttpMethodsOnly(document.paths)),\n }\n return acc\n }, {})\n\n /**\n * Base workspace document containing essential metadata and document references.\n *\n * This workspace document provides the minimal information needed for initial rendering.\n * All components and path operations are replaced with references to enable lazy loading.\n *\n * In SSR mode, references point to API endpoints.\n * In static mode, references point to filesystem chunks.\n */\n const workspace = {\n ...workspaceProps.meta,\n documents: documents.reduce<Record<string, Record<string, unknown>>>((acc, { name, document, meta }) => {\n const options =\n workspaceProps.mode === 'ssr'\n ? { mode: workspaceProps.mode, name, baseUrl: workspaceProps.baseUrl }\n : { mode: workspaceProps.mode, name, directory: workspaceProps.directory ?? DEFAULT_ASSETS_FOLDER }\n\n // Transform the original document by setting all the components and paths operations on refs\n const components = externalizeComponentReferences(document, options)\n const paths = externalizePathReferences(document, options)\n\n // Here we create the sidebar\n const { entries } = createNavigation(document, workspaceProps.config ?? {})\n\n acc[name] = { ...meta, ...document, components, paths, [extensions.document.navigation]: entries }\n return acc\n }, {}),\n }\n\n return {\n /**\n * Generates workspace chunks by writing components and operations to the filesystem.\n *\n * This method is only available in static mode. It creates a directory structure containing:\n * - A workspace file with metadata and document references\n * - Component chunks split by type (schemas, parameters, etc)\n * - Operation chunks split by path and HTTP method\n *\n * The generated workspace references will be relative file paths pointing to these chunks.\n *\n * @throws {Error} If called when mode is not 'static'\n */\n generateWorkspaceChunks: async () => {\n if (workspaceProps.mode !== 'static') {\n throw 'Mode has to be set to `static` to generate filesystem workspace chunks'\n }\n\n // Write the workspace document\n const basePath = `${cwd()}/${workspaceProps.directory ?? DEFAULT_ASSETS_FOLDER}`\n await fs.mkdir(basePath, { recursive: true })\n\n // Write the workspace contents on the file system\n await fs.writeFile(`${basePath}/${WORKSPACE_FILE_NAME}`, JSON.stringify(workspace))\n\n // Write the chunks\n for (const [name, { components, operations }] of Object.entries(assets)) {\n // Write the components chunks\n if (components) {\n for (const [type, component] of Object.entries(components as Record<string, Record<string, unknown>>)) {\n const componentPath = `${basePath}/chunks/${name}/components/${type}`\n await fs.mkdir(componentPath, { recursive: true })\n\n for (const [key, value] of Object.entries(component)) {\n await fs.writeFile(`${componentPath}/${key}.json`, JSON.stringify(value))\n }\n }\n }\n\n // Write the operations chunks\n if (operations) {\n for (const [path, methods] of Object.entries(operations as Record<string, Record<string, unknown>>)) {\n const operationPath = `${basePath}/chunks/${name}/operations/${path}`\n await fs.mkdir(operationPath, { recursive: true })\n\n for (const [method, operation] of Object.entries(methods)) {\n await fs.writeFile(`${operationPath}/${method}.json`, JSON.stringify(operation))\n }\n }\n }\n }\n },\n /**\n * Returns the workspace document containing metadata and all sparse documents.\n *\n * The workspace document includes:\n * - Global workspace metadata (theme, active document, etc)\n * - Document metadata and sparse document\n * - In SSR mode: References point to in-memory chunks\n * - In static mode: References point to filesystem chunks\n *\n * @returns The complete workspace document\n */\n getWorkspace: () => {\n return workspace\n },\n /**\n * Retrieves a chunk of data from the workspace using a JSON Pointer\n *\n * A JSON Pointer is a string that references a specific location in a JSON document.\n * Only components and operations chunks can be retrieved.\n *\n * @example\n * ```ts\n * // Get a component\n * get('#/document-name/components/schemas/User')\n *\n * // Get an operation\n * get('#/document-name/operations/pets/get')\n * ```\n *\n * @param pointer - The JSON Pointer string to locate the chunk\n * @returns The chunk data if found, undefined otherwise\n */\n get: (pointer: string) => {\n return getValueByPath(assets, parseJsonPointer(pointer))\n },\n /**\n * Adds a new document to the workspace.\n *\n * The document will be:\n * - Upgraded to OpenAPI 3.1 if needed\n * - Split into components and operations chunks\n * - Have its references externalized based on the workspace mode\n * - Added to the workspace with its metadata\n *\n * @param document - The OpenAPI document to add\n * @param meta - Document metadata including required name and optional settings\n */\n addDocument: (document: Record<string, unknown>, meta: { name: string } & WorkspaceDocumentMeta) => {\n const { name, ...documentMeta } = meta\n\n const documentV3 = upgrade(document).specification\n\n // add the assets\n assets[meta.name] = {\n components: documentV3.components,\n operations: documentV3.paths && escapePaths(filterHttpMethodsOnly(documentV3.paths)),\n }\n\n const options =\n workspaceProps.mode === 'ssr'\n ? { mode: workspaceProps.mode, name, baseUrl: workspaceProps.baseUrl }\n : { mode: workspaceProps.mode, name, directory: workspaceProps.directory ?? DEFAULT_ASSETS_FOLDER }\n\n const components = externalizeComponentReferences(documentV3, options)\n const paths = externalizePathReferences(documentV3, options)\n\n // Build the sidebar entries\n const { entries } = createNavigation(document, workspaceProps.config ?? {})\n\n // The document is now a minimal version with externalized references to components and operations.\n // These references will be resolved asynchronously when needed through the workspace's get() method.\n workspace.documents[meta.name] = {\n ...documentMeta,\n ...documentV3,\n components,\n paths,\n [extensions.document.navigation]: entries,\n }\n },\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,mBAAmB,eAAe;
|
|
4
|
+
"sourcesContent": ["import { escapeJsonPointer, upgrade } from '@scalar/openapi-parser'\nimport { getValueByPath, parseJsonPointer } from './helpers/json-path-utils'\nimport type { WorkspaceDocumentMeta, WorkspaceMeta } from './schemas/workspace'\nimport fs from 'node:fs/promises'\nimport { cwd } from 'node:process'\nimport { createNavigation, type createNavigationOptions } from '@/navigation'\nimport { extensions } from '@/schemas/extensions'\nimport { coerceValue } from '@/schemas/typebox-coerce'\nimport { OpenAPIDocumentSchema, type OpenApiDocument } from '@/schemas/v3.1/strict/openapi-document'\nimport type { PathsObject } from '@/schemas/v3.1/strict/paths'\nimport { keyOf } from '@/helpers/general'\nimport type { ComponentsObject } from '@/schemas/v3.1/strict/components'\nimport type { OperationObject } from '@/schemas/v3.1/strict/path-operations'\n\nconst DEFAULT_ASSETS_FOLDER = 'assets'\nexport const WORKSPACE_FILE_NAME = 'scalar-workspace.json'\n\n// TODO: support input document from different sources\ntype CreateServerWorkspaceStoreBase = {\n documents: {\n name: string\n document: Record<string, unknown> | string\n meta?: WorkspaceDocumentMeta\n }[]\n meta?: WorkspaceMeta\n config?: createNavigationOptions\n}\ntype CreateServerWorkspaceStore =\n | ({\n directory?: string\n mode: 'static'\n } & CreateServerWorkspaceStoreBase)\n | ({\n baseUrl: string\n mode: 'ssr'\n } & CreateServerWorkspaceStoreBase)\n\nconst httpMethods = new Set(['get', 'put', 'post', 'delete', 'options', 'head', 'patch', 'trace'])\n\n/**\n * Filters an OpenAPI PathsObject to only include standard HTTP methods.\n * Removes any vendor extensions or other non-HTTP properties.\n *\n * @param paths - The OpenAPI PathsObject to filter\n * @returns A new PathsObject containing only standard HTTP methods\n *\n * @example\n * Input: {\n * \"/users\": {\n * \"get\": {...},\n * \"x-custom\": {...},\n * \"post\": {...}\n * }\n * }\n * Output: {\n * \"/users\": {\n * \"get\": {...},\n * \"post\": {...}\n * }\n * }\n */\nexport function filterHttpMethodsOnly(paths: PathsObject) {\n const result: Record<string, Record<string, OperationObject>> = {}\n\n // Todo: skip extension properties\n for (const [path, methods] of Object.entries(paths)) {\n if (!methods) {\n continue\n }\n\n const filteredMethods: Record<string, any> = {}\n\n for (const [method, operation] of Object.entries(methods)) {\n if (httpMethods.has(method.toLowerCase())) {\n filteredMethods[method] = operation\n }\n }\n\n if (Object.keys(filteredMethods).length > 0) {\n result[path] = filteredMethods\n }\n }\n\n return result\n}\n\n/**\n * Escapes path keys in an OpenAPI PathsObject to be JSON Pointer compatible.\n * This is necessary because OpenAPI paths can contain characters that need to be escaped\n * when used as JSON Pointer references (like '/' and '~').\n *\n * @example\n * Input: { \"/users/{id}\": { ... } }\n * Output: { \"/users~1{id}\": { ... } }\n */\nexport function escapePaths(paths: Record<string, Record<string, OperationObject>>) {\n const result: Record<string, Record<string, OperationObject>> = {}\n Object.keys(paths).forEach((path) => {\n result[escapeJsonPointer(path)] = paths[path]\n })\n\n return result\n}\n\n/**\n * Externalizes components by turning them into refs.\n */\nexport function externalizeComponentReferences(\n document: OpenApiDocument,\n meta: { mode: 'ssr'; name: string; baseUrl: string } | { mode: 'static'; name: string; directory: string },\n) {\n const result: Record<string, any> = {}\n\n if (!document.components) {\n return result\n }\n\n Object.entries(document.components).forEach(([type, component]) => {\n if (!component || typeof component !== 'object') {\n return result\n }\n\n result[type] = {}\n Object.keys(component).forEach((name) => {\n const ref =\n meta.mode === 'ssr'\n ? `${meta.baseUrl}/${meta.name}/components/${type}/${name}#`\n : `${meta.directory}/chunks/${meta.name}/components/${type}/${name}.json#`\n\n result[type][name] = { '$ref': ref, $global: true }\n })\n })\n\n return result\n}\n\n/**\n * Externalizes paths operations by turning them into refs.\n */\nexport function externalizePathReferences(\n document: OpenApiDocument,\n meta: { mode: 'ssr'; name: string; baseUrl: string } | { mode: 'static'; name: string; directory: string },\n) {\n const result: Record<string, any> = {}\n\n if (!document.paths) {\n return result\n }\n\n Object.entries(document.paths).forEach(([path, pathItem]) => {\n if (!pathItem || typeof pathItem !== 'object') {\n return result\n }\n\n const pathItemRecord = pathItem as Record<string, unknown>\n\n result[path] = {}\n\n const escapedPath = escapeJsonPointer(path)\n\n keyOf(pathItemRecord).forEach((type) => {\n if (httpMethods.has(type)) {\n const ref =\n meta.mode === 'ssr'\n ? `${meta.baseUrl}/${meta.name}/operations/${escapedPath}/${type}#`\n : `${meta.directory}/chunks/${meta.name}/operations/${escapedPath}/${type}.json#`\n\n result[path][type] = { '$ref': ref, $global: true }\n } else {\n result[path][type] = pathItemRecord[type]\n }\n })\n })\n\n return result\n}\n\n/**\n * Create server state workspace store\n */\nexport function createServerWorkspaceStore(workspaceProps: CreateServerWorkspaceStore) {\n const documents = workspaceProps.documents.map((el) => {\n const document = upgrade(el.document).specification\n\n const castedDocument = coerceValue(OpenAPIDocumentSchema, document)\n\n return { ...el, document: castedDocument }\n })\n\n /**\n * A map of document chunks that can be loaded asynchronously by the client.\n * Each document is split into components and operations to enable lazy loading.\n * The keys are document names and values contain the components and operations\n * for that document.\n */\n const assets = documents.reduce<\n Record<string, { components?: ComponentsObject; operations?: Record<string, Record<string, OperationObject>> }>\n >((acc, { name, document }) => {\n acc[name] = {\n components: document.components,\n operations: document.paths && escapePaths(filterHttpMethodsOnly(document.paths)),\n }\n return acc\n }, {})\n\n /**\n * Base workspace document containing essential metadata and document references.\n *\n * This workspace document provides the minimal information needed for initial rendering.\n * All components and path operations are replaced with references to enable lazy loading.\n *\n * In SSR mode, references point to API endpoints.\n * In static mode, references point to filesystem chunks.\n */\n const workspace = {\n ...workspaceProps.meta,\n documents: documents.reduce<Record<string, Record<string, unknown>>>((acc, { name, document, meta }) => {\n const options =\n workspaceProps.mode === 'ssr'\n ? { mode: workspaceProps.mode, name, baseUrl: workspaceProps.baseUrl }\n : { mode: workspaceProps.mode, name, directory: workspaceProps.directory ?? DEFAULT_ASSETS_FOLDER }\n\n // Transform the original document by setting all the components and paths operations on refs\n const components = externalizeComponentReferences(document, options)\n const paths = externalizePathReferences(document, options)\n\n // Here we create the sidebar\n const { entries } = createNavigation(document, workspaceProps.config ?? {})\n\n acc[name] = { ...meta, ...document, components, paths, [extensions.document.navigation]: entries }\n return acc\n }, {}),\n }\n\n return {\n /**\n * Generates workspace chunks by writing components and operations to the filesystem.\n *\n * This method is only available in static mode. It creates a directory structure containing:\n * - A workspace file with metadata and document references\n * - Component chunks split by type (schemas, parameters, etc)\n * - Operation chunks split by path and HTTP method\n *\n * The generated workspace references will be relative file paths pointing to these chunks.\n *\n * @throws {Error} If called when mode is not 'static'\n */\n generateWorkspaceChunks: async () => {\n if (workspaceProps.mode !== 'static') {\n throw 'Mode has to be set to `static` to generate filesystem workspace chunks'\n }\n\n // Write the workspace document\n const basePath = `${cwd()}/${workspaceProps.directory ?? DEFAULT_ASSETS_FOLDER}`\n await fs.mkdir(basePath, { recursive: true })\n\n // Write the workspace contents on the file system\n await fs.writeFile(`${basePath}/${WORKSPACE_FILE_NAME}`, JSON.stringify(workspace))\n\n // Write the chunks\n for (const [name, { components, operations }] of Object.entries(assets)) {\n // Write the components chunks\n if (components) {\n for (const [type, component] of Object.entries(components as Record<string, Record<string, unknown>>)) {\n const componentPath = `${basePath}/chunks/${name}/components/${type}`\n await fs.mkdir(componentPath, { recursive: true })\n\n for (const [key, value] of Object.entries(component)) {\n await fs.writeFile(`${componentPath}/${key}.json`, JSON.stringify(value))\n }\n }\n }\n\n // Write the operations chunks\n if (operations) {\n for (const [path, methods] of Object.entries(operations)) {\n const operationPath = `${basePath}/chunks/${name}/operations/${path}`\n await fs.mkdir(operationPath, { recursive: true })\n\n for (const [method, operation] of Object.entries(methods)) {\n await fs.writeFile(`${operationPath}/${method}.json`, JSON.stringify(operation))\n }\n }\n }\n }\n },\n /**\n * Returns the workspace document containing metadata and all sparse documents.\n *\n * The workspace document includes:\n * - Global workspace metadata (theme, active document, etc)\n * - Document metadata and sparse document\n * - In SSR mode: References point to in-memory chunks\n * - In static mode: References point to filesystem chunks\n *\n * @returns The complete workspace document\n */\n getWorkspace: () => {\n return workspace\n },\n /**\n * Retrieves a chunk of data from the workspace using a JSON Pointer\n *\n * A JSON Pointer is a string that references a specific location in a JSON document.\n * Only components and operations chunks can be retrieved.\n *\n * @example\n * ```ts\n * // Get a component\n * get('#/document-name/components/schemas/User')\n *\n * // Get an operation\n * get('#/document-name/operations/pets/get')\n * ```\n *\n * @param pointer - The JSON Pointer string to locate the chunk\n * @returns The chunk data if found, undefined otherwise\n */\n get: (pointer: string) => {\n return getValueByPath(assets, parseJsonPointer(pointer))\n },\n /**\n * Adds a new document to the workspace.\n *\n * The document will be:\n * - Upgraded to OpenAPI 3.1 if needed\n * - Split into components and operations chunks\n * - Have its references externalized based on the workspace mode\n * - Added to the workspace with its metadata\n *\n * @param document - The OpenAPI document to add\n * @param meta - Document metadata including required name and optional settings\n */\n addDocument: (document: Record<string, unknown>, meta: { name: string } & WorkspaceDocumentMeta) => {\n const { name, ...documentMeta } = meta\n\n const documentV3 = coerceValue(OpenAPIDocumentSchema, upgrade(document).specification)\n\n // add the assets\n assets[meta.name] = {\n components: documentV3.components,\n operations: documentV3.paths && escapePaths(filterHttpMethodsOnly(documentV3.paths)),\n }\n\n const options =\n workspaceProps.mode === 'ssr'\n ? { mode: workspaceProps.mode, name, baseUrl: workspaceProps.baseUrl }\n : { mode: workspaceProps.mode, name, directory: workspaceProps.directory ?? DEFAULT_ASSETS_FOLDER }\n\n const components = externalizeComponentReferences(documentV3, options)\n const paths = externalizePathReferences(documentV3, options)\n\n // Build the sidebar entries\n const { entries } = createNavigation(documentV3, workspaceProps.config ?? {})\n\n // The document is now a minimal version with externalized references to components and operations.\n // These references will be resolved asynchronously when needed through the workspace's get() method.\n workspace.documents[meta.name] = {\n ...documentMeta,\n ...documentV3,\n components,\n paths,\n [extensions.document.navigation]: entries,\n }\n },\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,mBAAmB,eAAe;AAC3C,SAAS,gBAAgB,wBAAwB;AAEjD,OAAO,QAAQ;AACf,SAAS,WAAW;AACpB,SAAS,wBAAsD;AAC/D,SAAS,kBAAkB;AAC3B,SAAS,mBAAmB;AAC5B,SAAS,6BAAmD;AAE5D,SAAS,aAAa;AAItB,MAAM,wBAAwB;AACvB,MAAM,sBAAsB;AAsBnC,MAAM,cAAc,oBAAI,IAAI,CAAC,OAAO,OAAO,QAAQ,UAAU,WAAW,QAAQ,SAAS,OAAO,CAAC;AAwB1F,SAAS,sBAAsB,OAAoB;AACxD,QAAM,SAA0D,CAAC;AAGjE,aAAW,CAAC,MAAM,OAAO,KAAK,OAAO,QAAQ,KAAK,GAAG;AACnD,QAAI,CAAC,SAAS;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G,YAAM,aAAa,+BAA+B,YAAY,OAAO;AACrE,YAAM,QAAQ,0BAA0B,YAAY,OAAO;AAG3D,YAAM,EAAE,QAAQ,IAAI,iBAAiB,YAAY,eAAe,UAAU,CAAC,CAAC;AAI5E,gBAAU,UAAU,KAAK,IAAI,IAAI;AAAA,QAC/B,GAAG;AAAA,QACH,GAAG;AAAA,QACH;AAAA,QACA;AAAA,QACA,CAAC,WAAW,SAAS,UAAU,GAAG;AAAA,MACpC;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"openapi",
|
|
17
17
|
"scalar"
|
|
18
18
|
],
|
|
19
|
-
"version": "0.
|
|
19
|
+
"version": "0.5.0",
|
|
20
20
|
"engines": {
|
|
21
21
|
"node": ">=18"
|
|
22
22
|
},
|
|
@@ -43,15 +43,16 @@
|
|
|
43
43
|
"CHANGELOG.md"
|
|
44
44
|
],
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@sinclair/typebox": "0.34.
|
|
46
|
+
"@sinclair/typebox": "0.34.33",
|
|
47
47
|
"github-slugger": "^2.0.0",
|
|
48
48
|
"vue": "^3.5.12",
|
|
49
49
|
"@scalar/code-highlight": "0.1.4",
|
|
50
|
-
"@scalar/openapi-parser": "0.17.0",
|
|
51
50
|
"@scalar/helpers": "0.0.4",
|
|
52
|
-
"@scalar/openapi-types": "0.3.3"
|
|
51
|
+
"@scalar/openapi-types": "0.3.3",
|
|
52
|
+
"@scalar/openapi-parser": "0.17.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
+
"@google-cloud/storage": "7.13.0",
|
|
55
56
|
"fastify": "^5.3.3",
|
|
56
57
|
"vite": "5.4.19",
|
|
57
58
|
"vitest": "^1.6.0",
|