@scalar/workspace-store 0.64.0 → 0.66.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 +121 -0
- package/README.md +45 -10
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +109 -10
- package/dist/entities/auth/schema.d.ts +351 -20
- package/dist/entities/auth/schema.d.ts.map +1 -1
- package/dist/entities/auth/schema.js +3 -1
- package/dist/events/definitions/auth.d.ts +1 -2
- package/dist/events/definitions/auth.d.ts.map +1 -1
- package/dist/events/definitions/operation.d.ts +3 -4
- package/dist/events/definitions/operation.d.ts.map +1 -1
- package/dist/events/definitions/server.d.ts +1 -2
- package/dist/events/definitions/server.d.ts.map +1 -1
- package/dist/events/definitions/ui.d.ts +3 -4
- package/dist/events/definitions/ui.d.ts.map +1 -1
- package/dist/events/old-definitions.d.ts +1 -2
- package/dist/events/old-definitions.d.ts.map +1 -1
- package/dist/helpers/chunk-index.d.ts +20 -2
- package/dist/helpers/chunk-index.d.ts.map +1 -1
- package/dist/helpers/chunk-index.js +14 -1
- package/dist/helpers/external-examples.d.ts +2 -0
- package/dist/helpers/external-examples.d.ts.map +1 -1
- package/dist/helpers/external-examples.js +1 -0
- package/dist/helpers/for-each-path-item-operation.d.ts +6 -5
- package/dist/helpers/for-each-path-item-operation.d.ts.map +1 -1
- package/dist/helpers/for-each-path-item-operation.js +40 -14
- package/dist/helpers/get-example-value.d.ts +15 -0
- package/dist/helpers/get-example-value.d.ts.map +1 -0
- package/dist/helpers/get-example-value.js +28 -0
- package/dist/helpers/get-parameter-example.d.ts +14 -0
- package/dist/helpers/get-parameter-example.d.ts.map +1 -0
- package/dist/helpers/get-parameter-example.js +19 -0
- package/dist/helpers/get-resolved-ref.d.ts.map +1 -1
- package/dist/helpers/get-resolved-ref.js +12 -1
- package/dist/helpers/normalize-boolean-schemas.d.ts +10 -0
- package/dist/helpers/normalize-boolean-schemas.d.ts.map +1 -0
- package/dist/helpers/normalize-boolean-schemas.js +193 -0
- package/dist/helpers/operation-examples.d.ts.map +1 -1
- package/dist/helpers/operation-examples.js +5 -2
- package/dist/helpers/querystring-parameter.d.ts +21 -0
- package/dist/helpers/querystring-parameter.d.ts.map +1 -0
- package/dist/helpers/querystring-parameter.js +108 -0
- package/dist/helpers/serialize-stream-example.d.ts +8 -0
- package/dist/helpers/serialize-stream-example.d.ts.map +1 -0
- package/dist/helpers/serialize-stream-example.js +52 -0
- package/dist/helpers/use-external-examples.d.ts.map +1 -1
- package/dist/helpers/use-external-examples.js +8 -1
- package/dist/mutators/index.d.ts +3 -3
- package/dist/mutators/operation/body.d.ts.map +1 -1
- package/dist/mutators/operation/body.js +9 -2
- package/dist/mutators/operation/operation.d.ts.map +1 -1
- package/dist/mutators/operation/operation.js +4 -7
- package/dist/mutators/operation/parameters.d.ts.map +1 -1
- package/dist/mutators/operation/parameters.js +43 -3
- package/dist/navigation/get-navigation-options.d.ts.map +1 -1
- package/dist/navigation/get-navigation-options.js +19 -4
- package/dist/navigation/helpers/traverse-paths.d.ts.map +1 -1
- package/dist/navigation/helpers/traverse-paths.js +2 -2
- package/dist/navigation/helpers/traverse-webhooks.d.ts.map +1 -1
- package/dist/navigation/helpers/traverse-webhooks.js +2 -2
- package/dist/navigation/helpers/update-order-ids.d.ts +1 -2
- package/dist/navigation/helpers/update-order-ids.d.ts.map +1 -1
- package/dist/plugins/bundler/index.d.ts +1 -0
- package/dist/plugins/bundler/index.d.ts.map +1 -1
- package/dist/plugins/bundler/index.js +11 -3
- package/dist/plugins/bundler/openapi-document.d.ts +6 -0
- package/dist/plugins/bundler/openapi-document.d.ts.map +1 -0
- package/dist/plugins/bundler/openapi-document.js +57 -0
- package/dist/request-example/builder/body/build-multipart.d.ts +29 -0
- package/dist/request-example/builder/body/build-multipart.d.ts.map +1 -0
- package/dist/request-example/builder/body/build-multipart.js +191 -0
- package/dist/request-example/builder/body/build-request-body.d.ts +6 -1
- package/dist/request-example/builder/body/build-request-body.d.ts.map +1 -1
- package/dist/request-example/builder/body/build-request-body.js +80 -23
- package/dist/request-example/builder/body/encode-multipart-body.d.ts +8 -8
- package/dist/request-example/builder/body/encode-multipart-body.d.ts.map +1 -1
- package/dist/request-example/builder/body/encode-multipart-body.js +56 -18
- package/dist/request-example/builder/body/get-request-body-example.d.ts.map +1 -1
- package/dist/request-example/builder/body/get-request-body-example.js +20 -6
- package/dist/request-example/builder/body/multipart-limits.d.ts +3 -0
- package/dist/request-example/builder/body/multipart-limits.d.ts.map +1 -0
- package/dist/request-example/builder/body/multipart-limits.js +2 -0
- package/dist/request-example/builder/body/serialize-form-property.d.ts +2 -0
- package/dist/request-example/builder/body/serialize-form-property.d.ts.map +1 -1
- package/dist/request-example/builder/body/serialize-form-property.js +3 -2
- package/dist/request-example/builder/body/serialize-multipart-array.d.ts +1 -1
- package/dist/request-example/builder/build-request.d.ts.map +1 -1
- package/dist/request-example/builder/build-request.js +7 -1
- package/dist/request-example/builder/header/build-request-parameters.d.ts +2 -0
- package/dist/request-example/builder/header/build-request-parameters.d.ts.map +1 -1
- package/dist/request-example/builder/header/build-request-parameters.js +54 -11
- package/dist/request-example/builder/header/is-param-disabled.d.ts.map +1 -1
- package/dist/request-example/builder/header/is-param-disabled.js +3 -1
- package/dist/request-example/builder/header/serialize-parameter.d.ts +11 -0
- package/dist/request-example/builder/header/serialize-parameter.d.ts.map +1 -1
- package/dist/request-example/builder/header/serialize-parameter.js +22 -0
- package/dist/request-example/builder/helpers/get-example-from-schema.d.ts.map +1 -1
- package/dist/request-example/builder/helpers/get-example-from-schema.js +42 -3
- package/dist/request-example/builder/helpers/get-example.d.ts.map +1 -1
- package/dist/request-example/builder/helpers/get-example.js +5 -2
- package/dist/request-example/builder/index.d.ts +2 -2
- package/dist/request-example/builder/index.d.ts.map +1 -1
- package/dist/request-example/builder/index.js +1 -1
- package/dist/request-example/builder/request-factory.d.ts +7 -0
- package/dist/request-example/builder/request-factory.d.ts.map +1 -1
- package/dist/request-example/builder/request-factory.js +10 -1
- package/dist/request-example/builder/resolve-request-factory-url.d.ts.map +1 -1
- package/dist/request-example/builder/resolve-request-factory-url.js +18 -2
- package/dist/request-example/builder/security/secret-types.d.ts +4 -1
- package/dist/request-example/builder/security/secret-types.d.ts.map +1 -1
- package/dist/request-example/context/headers.d.ts +1 -2
- package/dist/request-example/context/headers.d.ts.map +1 -1
- package/dist/request-example/context/security/extract-security-scheme-secrets.d.ts.map +1 -1
- package/dist/request-example/context/security/extract-security-scheme-secrets.js +15 -0
- package/dist/request-example/index.d.ts +5 -2
- package/dist/request-example/index.d.ts.map +1 -1
- package/dist/request-example/index.js +4 -1
- package/dist/request-example/types.d.ts +1 -2
- package/dist/request-example/types.d.ts.map +1 -1
- package/dist/request-example/xml/serialize-xml-part.d.ts +9 -0
- package/dist/request-example/xml/serialize-xml-part.d.ts.map +1 -0
- package/dist/request-example/xml/serialize-xml-part.js +12 -0
- package/dist/schemas/extensions/operation/x-code-samples.d.ts +22 -0
- package/dist/schemas/extensions/operation/x-code-samples.d.ts.map +1 -1
- package/dist/schemas/extensions/operation/x-code-samples.js +4 -0
- package/dist/schemas/extensions.d.ts +9 -0
- package/dist/schemas/extensions.d.ts.map +1 -1
- package/dist/schemas/extensions.js +9 -0
- package/dist/schemas/navigation.d.ts +40 -34
- package/dist/schemas/navigation.d.ts.map +1 -1
- package/dist/schemas/navigation.js +2 -3
- package/dist/schemas/reference-config/index.d.ts +24 -4
- package/dist/schemas/reference-config/index.d.ts.map +1 -1
- package/dist/schemas/reference-config/settings.d.ts +24 -4
- package/dist/schemas/reference-config/settings.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/oauthflows.d.ts +26 -0
- package/dist/schemas/v3.1/strict/oauthflows.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/oauthflows.js +3 -0
- package/dist/schemas/v3.1/strict/openapi-document.d.ts +1582 -147
- package/dist/schemas/v3.1/strict/openapi-document.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/operation.d.ts +8 -0
- package/dist/schemas/v3.1/strict/operation.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/path-item.d.ts +19 -0
- package/dist/schemas/v3.1/strict/path-item.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/path-item.js +5 -0
- package/dist/schemas/v3.2/openapi/index.d.ts +5 -0
- package/dist/schemas/v3.2/openapi/index.d.ts.map +1 -1
- package/dist/schemas/v3.2/openapi/index.js +48 -12
- package/dist/schemas/v3.2/openapi/reference.d.ts.map +1 -1
- package/dist/schemas/v3.2/openapi/reference.js +11 -3
- package/dist/schemas/v3.2/strict/openapi-document.d.ts +842 -140
- package/dist/schemas/v3.2/strict/openapi-document.d.ts.map +1 -1
- package/dist/schemas/v3.2/strict/openapi-document.js +6 -14
- package/dist/schemas/v3.2/strict/operation.d.ts +8 -0
- package/dist/schemas/v3.2/strict/operation.d.ts.map +1 -1
- package/dist/schemas/v3.2/strict/parameter.d.ts +14 -0
- package/dist/schemas/v3.2/strict/parameter.d.ts.map +1 -1
- package/dist/schemas/v3.2/strict/parameter.js +2 -0
- package/dist/server.d.ts +10 -6
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +67 -45
- package/package.json +19 -9
- package/dist/schemas/v3.1/openapi/index.d.ts +0 -149
- package/dist/schemas/v3.1/openapi/index.d.ts.map +0 -1
- package/dist/schemas/v3.1/openapi/index.js +0 -732
- package/dist/schemas/v3.1/openapi/reference.d.ts +0 -4
- package/dist/schemas/v3.1/openapi/reference.d.ts.map +0 -1
- package/dist/schemas/v3.1/openapi/reference.js +0 -29
package/dist/server.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Buffer } from 'node:buffer';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
2
3
|
import { upgrade as upgradeAsyncApi } from '@scalar/asyncapi-upgrader';
|
|
3
4
|
import { isHttpMethod } from '@scalar/helpers/http/is-http-method';
|
|
4
5
|
import { parseJsonPointerSegments } from '@scalar/helpers/json/parse-json-pointer-segments';
|
|
@@ -12,7 +13,7 @@ import { createMagicProxy, getRaw } from '@scalar/json-magic/magic-proxy';
|
|
|
12
13
|
import { upgrade } from '@scalar/openapi-upgrader';
|
|
13
14
|
import { asyncApiObjectSchema } from '@scalar/schemas/asyncapi/3.1';
|
|
14
15
|
import { coerce } from '@scalar/validation';
|
|
15
|
-
import { CHUNK_INDEX_KEY, buildChunkIndex, chunkRefTemplates,
|
|
16
|
+
import { CHUNK_INDEX_KEY, buildChunkIndex, chunkRefTemplates, fillChunkRef, navigationHeader, } from './helpers/chunk-index.js';
|
|
16
17
|
import { createChunkWriter } from './helpers/create-chunk-writer.js';
|
|
17
18
|
import { deepClone } from './helpers/deep-clone.js';
|
|
18
19
|
import { encodeChunkName } from './helpers/encode-chunk-name.js';
|
|
@@ -20,13 +21,17 @@ import { forEachPathItemOperation, getResolvedPathItem } from './helpers/for-eac
|
|
|
20
21
|
import { keyOf } from './helpers/general.js';
|
|
21
22
|
import { getResolvedRef } from './helpers/get-resolved-ref.js';
|
|
22
23
|
import { mergeObjects } from './helpers/merge-object.js';
|
|
24
|
+
import { normalizeBooleanSchemas } from './helpers/normalize-boolean-schemas.js';
|
|
23
25
|
import { createNavigation, traverseAsyncApiDocument } from './navigation/index.js';
|
|
26
|
+
import { resolveOpenApiDocument } from './plugins/bundler/openapi-document.js';
|
|
24
27
|
import { extensions } from './schemas/extensions.js';
|
|
25
28
|
import { isAsyncApiDocument } from './schemas/type-guards.js';
|
|
26
29
|
import { coerceValue } from './schemas/typebox-coerce.js';
|
|
27
30
|
import { OpenAPIDocumentSchema, } from './schemas/v3.2/strict/openapi-document.js';
|
|
28
31
|
const DEFAULT_ASSETS_FOLDER = 'assets';
|
|
29
32
|
export const WORKSPACE_FILE_NAME = 'scalar-workspace.json';
|
|
33
|
+
/** Custom methods must remain distinct even on case-insensitive filesystems. */
|
|
34
|
+
const getOperationChunkFilename = (method) => isHttpMethod(method) && method === method.toLowerCase() ? method : `additional-${Buffer.from(method).toString('hex')}`;
|
|
30
35
|
/**
|
|
31
36
|
* Wraps a document so local `$ref`s resolve while the store inspects it.
|
|
32
37
|
*
|
|
@@ -39,7 +44,9 @@ export const WORKSPACE_FILE_NAME = 'scalar-workspace.json';
|
|
|
39
44
|
* read through: everything the store keeps is unwrapped with `getRaw` first, because `$ref-value` is
|
|
40
45
|
* enumerable on a proxy and serializing one would inline every referenced value beside its `$ref`.
|
|
41
46
|
*/
|
|
42
|
-
const resolveLocalReferences = (document) => createMagicProxy(document
|
|
47
|
+
const resolveLocalReferences = (document) => createMagicProxy(document, {
|
|
48
|
+
documentUri: resolveOpenApiDocument(document, '/')?.baseUri,
|
|
49
|
+
});
|
|
43
50
|
/**
|
|
44
51
|
* The keys `@scalar/json-magic` bundling parks external documents under.
|
|
45
52
|
*
|
|
@@ -63,14 +70,8 @@ const BUNDLED_EXTERNAL_KEYS = [bundleExtensions.externalDocuments, bundleExtensi
|
|
|
63
70
|
* coercion drops them and leaves every rewritten reference dangling, which is how a split-file
|
|
64
71
|
* document loses the operations it keeps in its other files.
|
|
65
72
|
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
* document — but that is what the store already does with every other field coercion passes through
|
|
69
|
-
* untouched (`info` among them), so cloning only these two would buy consistency nowhere. It would
|
|
70
|
-
* also be the worst place to pay for it: `x-ext` holds every external document that was bundled in,
|
|
71
|
-
* so cloning it roughly doubles peak memory at ingest, and `deepClone` recurses per level and throws
|
|
72
|
-
* on input nested a few thousand deep. Cloning the caller's document as a whole is the fix, and it
|
|
73
|
-
* belongs with the aliasing the store already has rather than here.
|
|
73
|
+
* Use the normalized source so external boolean schema targets keep their converted semantics.
|
|
74
|
+
* Changed targets were copied during normalization; unchanged buckets remain shared and are not mutated here.
|
|
74
75
|
*/
|
|
75
76
|
const preserveBundledExternals = (source, target) => {
|
|
76
77
|
for (const key of BUNDLED_EXTERNAL_KEYS) {
|
|
@@ -108,19 +109,17 @@ export function filterHttpMethodsOnly(paths) {
|
|
|
108
109
|
if (path.startsWith('x-')) {
|
|
109
110
|
continue;
|
|
110
111
|
}
|
|
111
|
-
const
|
|
112
|
+
const operations = new Map();
|
|
112
113
|
forEachPathItemOperation(pathItemRef, (method, operation) => {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
filteredMethods[method] = getRaw(getResolvedRef(operation) ?? operation);
|
|
120
|
-
}
|
|
114
|
+
// Unwrapped because the caller hands us a resolved document. A magic proxy enumerates a
|
|
115
|
+
// virtual `$ref-value`, so storing one would inline every referenced component beside its
|
|
116
|
+
// `$ref` when the chunk is written — and a self-referential schema would never finish
|
|
117
|
+
// serializing. Unwrapping one level is enough: the proxy wraps lazily, so a raw target's
|
|
118
|
+
// children are already raw.
|
|
119
|
+
operations.set(method, getRaw(getResolvedRef(operation) ?? operation));
|
|
121
120
|
});
|
|
122
|
-
if (
|
|
123
|
-
result[path] =
|
|
121
|
+
if (operations.size > 0) {
|
|
122
|
+
result[path] = Object.fromEntries(operations);
|
|
124
123
|
}
|
|
125
124
|
}
|
|
126
125
|
return result;
|
|
@@ -147,23 +146,21 @@ export function escapePaths(paths) {
|
|
|
147
146
|
* Externalizes components by turning them into refs.
|
|
148
147
|
*/
|
|
149
148
|
export function externalizeComponentReferences(document, meta) {
|
|
150
|
-
const result = {};
|
|
151
149
|
if (!document.components) {
|
|
152
|
-
return
|
|
150
|
+
return {};
|
|
153
151
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
Object.keys(component).
|
|
152
|
+
// Define both dictionary levels as own properties so untrusted keys cannot invoke prototype setters.
|
|
153
|
+
return Object.fromEntries(Object.entries(document.components)
|
|
154
|
+
.filter(([, component]) => component && typeof component === 'object')
|
|
155
|
+
.map(([type, component]) => [
|
|
156
|
+
type,
|
|
157
|
+
Object.fromEntries(Object.keys(component).map((name) => {
|
|
160
158
|
const ref = meta.mode === 'ssr'
|
|
161
159
|
? `${meta.baseUrl}/${meta.name}/components/${type}/${name}#`
|
|
162
160
|
: `./chunks/${encodeChunkName(meta.name)}/components/${encodeChunkName(type)}/${encodeChunkName(name)}.json#`;
|
|
163
|
-
|
|
164
|
-
})
|
|
165
|
-
|
|
166
|
-
return result;
|
|
161
|
+
return [name, { '$ref': ref, $global: true }];
|
|
162
|
+
})),
|
|
163
|
+
]));
|
|
167
164
|
}
|
|
168
165
|
/**
|
|
169
166
|
* Externalizes paths operations by turning them into refs.
|
|
@@ -188,6 +185,17 @@ export function externalizePathReferences(document, meta) {
|
|
|
188
185
|
: `./chunks/${encodeChunkName(meta.name)}/operations/${encodeChunkName(path)}/${type}.json#`;
|
|
189
186
|
result[path][type] = { '$ref': ref, $global: true };
|
|
190
187
|
}
|
|
188
|
+
else if (type === 'additionalOperations') {
|
|
189
|
+
result[path][type] = Object.fromEntries(Object.keys(pathItem.additionalOperations ?? {}).map((method) => [
|
|
190
|
+
method,
|
|
191
|
+
{
|
|
192
|
+
'$ref': meta.mode === 'ssr'
|
|
193
|
+
? `${meta.baseUrl}/${meta.name}/operations/${escapedPath}/${getOperationChunkFilename(method)}#`
|
|
194
|
+
: `./chunks/${encodeChunkName(meta.name)}/operations/${encodeChunkName(path)}/${getOperationChunkFilename(method)}.json#`,
|
|
195
|
+
$global: true,
|
|
196
|
+
},
|
|
197
|
+
]));
|
|
198
|
+
}
|
|
191
199
|
else if (type !== '$ref' && type !== '$ref-value') {
|
|
192
200
|
// Skip the reference plumbing merged in by getResolvedPathItem. The referenced path item is
|
|
193
201
|
// externalized on its own and its operations are externalized above, so keeping the `$ref`
|
|
@@ -347,8 +355,10 @@ export async function createServerWorkspaceStore(workspaceProps) {
|
|
|
347
355
|
return;
|
|
348
356
|
}
|
|
349
357
|
const upgradedDocument = upgrade(document, '3.1');
|
|
350
|
-
|
|
351
|
-
|
|
358
|
+
// Copy only containers changed by normalization; unchanged x-ext graphs remain shared.
|
|
359
|
+
const normalizedDocument = normalizeBooleanSchemas(upgradedDocument);
|
|
360
|
+
const documentV3 = coerceValue(OpenAPIDocumentSchema, normalizedDocument);
|
|
361
|
+
preserveBundledExternals(normalizedDocument, documentV3);
|
|
352
362
|
// Everything that inspects the document reads through this; everything that stores a piece of it
|
|
353
363
|
// stores the raw `documentV3` or a `getRaw` of the piece.
|
|
354
364
|
const resolvedDocument = resolveLocalReferences(documentV3);
|
|
@@ -357,7 +367,16 @@ export async function createServerWorkspaceStore(workspaceProps) {
|
|
|
357
367
|
// Components need no resolution: they are externalized as authored, and the client resolves the
|
|
358
368
|
// references inside them the same way it resolves the ones this store leaves behind.
|
|
359
369
|
components: documentV3.components,
|
|
360
|
-
operations: resolvedDocument.paths &&
|
|
370
|
+
operations: resolvedDocument.paths &&
|
|
371
|
+
escapePaths(Object.fromEntries(Object.entries(filterHttpMethodsOnly(resolvedDocument.paths)).map(([path, operations]) => [
|
|
372
|
+
path,
|
|
373
|
+
workspaceProps.mode === 'ssr'
|
|
374
|
+
? Object.fromEntries(Object.entries(operations).map(([method, operation]) => [
|
|
375
|
+
getOperationChunkFilename(method),
|
|
376
|
+
operation,
|
|
377
|
+
]))
|
|
378
|
+
: operations,
|
|
379
|
+
]))),
|
|
361
380
|
};
|
|
362
381
|
assets[meta.name] = documentAssets;
|
|
363
382
|
const options = workspaceProps.mode === 'ssr'
|
|
@@ -371,19 +390,22 @@ export async function createServerWorkspaceStore(workspaceProps) {
|
|
|
371
390
|
// These references will be resolved asynchronously when needed through the workspace's get() method.
|
|
372
391
|
if (workspaceProps.compact) {
|
|
373
392
|
const refs = chunkRefTemplates(options);
|
|
374
|
-
// The navigation joins the chunks, so `get()` and the generated chunk files can serve it.
|
|
393
|
+
// The navigation joins the chunks, so `get()` and the generated chunk files can serve it. The
|
|
394
|
+
// whole tree is served, header included, so a chunk stands on its own the way every other one
|
|
395
|
+
// does; the client keeps the children and already holds the header.
|
|
375
396
|
documentAssets.navigation = navigation;
|
|
376
397
|
// `components` and `paths` are dropped from the document: the index carries every reference
|
|
377
398
|
// that was in them, plus the path-item keys that were never externalized.
|
|
378
399
|
const { components: _components, paths: _paths, ...documentWithoutChunkedSections } = documentV3;
|
|
379
|
-
// Cast because a compact document is a wire form rather than a document: its
|
|
380
|
-
//
|
|
381
|
-
// undoes as it ingests
|
|
400
|
+
// Cast because a compact document is a wire form rather than a document: its two chunked
|
|
401
|
+
// sections are absent and its navigation children are elsewhere, both of which the client
|
|
402
|
+
// undoes — the sections as it ingests the document, the children when they are asked for.
|
|
382
403
|
workspace.documents[meta.name] = {
|
|
383
404
|
...documentMeta,
|
|
384
405
|
...documentWithoutChunkedSections,
|
|
385
406
|
[CHUNK_INDEX_KEY]: buildChunkIndex({ mode: options.mode, refs, components, paths }),
|
|
386
|
-
[extensions.document.navigation]:
|
|
407
|
+
[extensions.document.navigation]: navigationHeader(navigation),
|
|
408
|
+
[extensions.document.navigationChunk]: fillChunkRef(refs.navigation),
|
|
387
409
|
};
|
|
388
410
|
}
|
|
389
411
|
else {
|
|
@@ -454,11 +476,11 @@ export async function createServerWorkspaceStore(workspaceProps) {
|
|
|
454
476
|
throw 'Mode has to be set to `static` to generate filesystem workspace chunks';
|
|
455
477
|
}
|
|
456
478
|
// Write the workspace document
|
|
457
|
-
const basePath =
|
|
479
|
+
const basePath = resolve(workspaceProps.directory ?? DEFAULT_ASSETS_FOLDER);
|
|
458
480
|
const writeChunk = await createChunkWriter(basePath);
|
|
459
481
|
await writeChunk([WORKSPACE_FILE_NAME], workspace);
|
|
460
482
|
for (const [name, { components, operations, navigation }] of Object.entries(assets)) {
|
|
461
|
-
// Only compact documents
|
|
483
|
+
// Only compact documents chunk their navigation; otherwise it stays whole on the document.
|
|
462
484
|
if (navigation !== undefined) {
|
|
463
485
|
await writeChunk(['chunks', encodeChunkName(name), 'navigation.json'], navigation);
|
|
464
486
|
}
|
|
@@ -477,7 +499,7 @@ export async function createServerWorkspaceStore(workspaceProps) {
|
|
|
477
499
|
encodeChunkName(name),
|
|
478
500
|
'operations',
|
|
479
501
|
encodeChunkName(unescapeJsonPointer(path)),
|
|
480
|
-
`${
|
|
502
|
+
`${getOperationChunkFilename(method)}.json`,
|
|
481
503
|
], operation);
|
|
482
504
|
}
|
|
483
505
|
}
|
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"openapi",
|
|
17
17
|
"scalar"
|
|
18
18
|
],
|
|
19
|
-
"version": "0.
|
|
19
|
+
"version": "0.66.0",
|
|
20
20
|
"engines": {
|
|
21
21
|
"node": ">=22"
|
|
22
22
|
},
|
|
@@ -127,6 +127,16 @@
|
|
|
127
127
|
"types": "./dist/schemas/v3.1/strict/type-guards.d.ts",
|
|
128
128
|
"default": "./dist/schemas/v3.1/strict/type-guards.js"
|
|
129
129
|
},
|
|
130
|
+
"./schemas/v3.2/strict/openapi-document": {
|
|
131
|
+
"import": "./dist/schemas/v3.2/strict/openapi-document.js",
|
|
132
|
+
"types": "./dist/schemas/v3.2/strict/openapi-document.d.ts",
|
|
133
|
+
"default": "./dist/schemas/v3.2/strict/openapi-document.js"
|
|
134
|
+
},
|
|
135
|
+
"./schemas/v3.2/strict/type-guards": {
|
|
136
|
+
"import": "./dist/schemas/v3.2/strict/type-guards.js",
|
|
137
|
+
"types": "./dist/schemas/v3.2/strict/type-guards.d.ts",
|
|
138
|
+
"default": "./dist/schemas/v3.2/strict/type-guards.js"
|
|
139
|
+
},
|
|
130
140
|
"./server": {
|
|
131
141
|
"import": "./dist/server.js",
|
|
132
142
|
"types": "./dist/server.d.ts",
|
|
@@ -143,15 +153,15 @@
|
|
|
143
153
|
"CHANGELOG.md"
|
|
144
154
|
],
|
|
145
155
|
"dependencies": {
|
|
146
|
-
"@scalar/asyncapi-upgrader": "0.1.
|
|
147
|
-
"@scalar/helpers": "0.
|
|
148
|
-
"@scalar/json-magic": "0.
|
|
149
|
-
"@scalar/openapi-upgrader": "0.
|
|
150
|
-
"@scalar/schemas": "0.
|
|
151
|
-
"@scalar/snippetz": "0.
|
|
156
|
+
"@scalar/asyncapi-upgrader": "0.1.12",
|
|
157
|
+
"@scalar/helpers": "0.14.0",
|
|
158
|
+
"@scalar/json-magic": "0.15.1",
|
|
159
|
+
"@scalar/openapi-upgrader": "0.3.1",
|
|
160
|
+
"@scalar/schemas": "0.12.0",
|
|
161
|
+
"@scalar/snippetz": "0.10.1",
|
|
152
162
|
"@scalar/typebox": "0.1.3",
|
|
153
|
-
"@scalar/types": "0.
|
|
154
|
-
"@scalar/validation": "0.6.
|
|
163
|
+
"@scalar/types": "0.22.0",
|
|
164
|
+
"@scalar/validation": "0.6.5",
|
|
155
165
|
"js-base64": "^3.9.2",
|
|
156
166
|
"type-fest": "^5.8.0",
|
|
157
167
|
"vue": "^3.5.40",
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import { type Schema } from '@scalar/validation';
|
|
2
|
-
/** Options for {@link generateSchema}. */
|
|
3
|
-
type GenerateSchemaOptions = {
|
|
4
|
-
/**
|
|
5
|
-
* The Schema Object schema to use for every position that holds one.
|
|
6
|
-
*
|
|
7
|
-
* Defaults to {@link generateSchemaObject} called with the same `maybeRef`. Supply your own to
|
|
8
|
-
* change how schemas are represented. It must be constructed with the same `maybeRef` passed
|
|
9
|
-
* here, since that is what decides how references are represented.
|
|
10
|
-
*/
|
|
11
|
-
readonly schemaObject?: Schema;
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* Builds the OpenAPI Schema Object schema, the self-referential type every schema position uses.
|
|
15
|
-
*
|
|
16
|
-
* Exported so callers can supply their own to {@link generateSchema} rather than the default.
|
|
17
|
-
*/
|
|
18
|
-
export declare const generateSchemaObject: (maybeRef: (inner: Schema) => Schema) => Schema;
|
|
19
|
-
export declare const generateSchema: (maybeRef: (inner: Schema) => Schema, options?: GenerateSchemaOptions) => import("@scalar/validation").IntersectionSchema<readonly [import("@scalar/validation").ObjectSchema<{
|
|
20
|
-
openapi: import("@scalar/validation").StringSchema;
|
|
21
|
-
info: import("@scalar/validation").IntersectionSchema<readonly [import("@scalar/validation").ObjectSchema<{
|
|
22
|
-
title: import("@scalar/validation").StringSchema;
|
|
23
|
-
version: import("@scalar/validation").StringSchema;
|
|
24
|
-
summary: import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
|
|
25
|
-
description: import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
|
|
26
|
-
termsOfService: import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
|
|
27
|
-
contact: import("@scalar/validation").OptionalSchema<import("@scalar/validation").ObjectSchema<{
|
|
28
|
-
name: import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
|
|
29
|
-
url: import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
|
|
30
|
-
email: import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
|
|
31
|
-
}>>;
|
|
32
|
-
license: import("@scalar/validation").OptionalSchema<import("@scalar/validation").ObjectSchema<{
|
|
33
|
-
name: import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
|
|
34
|
-
identifier: import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
|
|
35
|
-
url: import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
|
|
36
|
-
}>>;
|
|
37
|
-
}>, import("@scalar/validation").ObjectSchema<{
|
|
38
|
-
'x-scalar-sdk-installation': import("@scalar/validation").OptionalSchema<import("@scalar/validation").ArraySchema<import("@scalar/validation").ObjectSchema<{
|
|
39
|
-
lang: import("@scalar/validation").StringSchema;
|
|
40
|
-
description: import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
|
|
41
|
-
source: import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
|
|
42
|
-
}>>>;
|
|
43
|
-
}>, import("@scalar/validation").ObjectSchema<{
|
|
44
|
-
'x-scalar-links': import("@scalar/validation").OptionalSchema<import("@scalar/validation").ArraySchema<import("@scalar/validation").ObjectSchema<{
|
|
45
|
-
name: import("@scalar/validation").StringSchema;
|
|
46
|
-
url: import("@scalar/validation").StringSchema;
|
|
47
|
-
}>>>;
|
|
48
|
-
}>]>;
|
|
49
|
-
jsonSchemaDialect: import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
|
|
50
|
-
servers: import("@scalar/validation").OptionalSchema<import("@scalar/validation").ArraySchema<import("@scalar/validation").ObjectSchema<{
|
|
51
|
-
url: import("@scalar/validation").StringSchema;
|
|
52
|
-
description: import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
|
|
53
|
-
variables: import("@scalar/validation").OptionalSchema<import("@scalar/validation").RecordSchema<import("@scalar/validation").StringSchema, import("@scalar/validation").ObjectSchema<{
|
|
54
|
-
enum: import("@scalar/validation").OptionalSchema<import("@scalar/validation").ArraySchema<import("@scalar/validation").StringSchema>>;
|
|
55
|
-
default: import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
|
|
56
|
-
description: import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
|
|
57
|
-
}>>>;
|
|
58
|
-
}>>>;
|
|
59
|
-
paths: import("@scalar/validation").OptionalSchema<import("@scalar/validation").RecordSchema<import("@scalar/validation").StringSchema, import("@scalar/validation").ObjectSchema<Record<string, any>>>>;
|
|
60
|
-
webhooks: import("@scalar/validation").OptionalSchema<import("@scalar/validation").RecordSchema<import("@scalar/validation").StringSchema, import("@scalar/validation").ObjectSchema<Record<string, any>>>>;
|
|
61
|
-
components: import("@scalar/validation").OptionalSchema<import("@scalar/validation").ObjectSchema<Record<string, any>>>;
|
|
62
|
-
security: import("@scalar/validation").OptionalSchema<import("@scalar/validation").ArraySchema<import("@scalar/validation").RecordSchema<import("@scalar/validation").StringSchema, import("@scalar/validation").ArraySchema<import("@scalar/validation").StringSchema>>>>;
|
|
63
|
-
tags: import("@scalar/validation").OptionalSchema<import("@scalar/validation").ArraySchema<import("@scalar/validation").IntersectionSchema<readonly [import("@scalar/validation").ObjectSchema<{
|
|
64
|
-
name: import("@scalar/validation").StringSchema;
|
|
65
|
-
summary: import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
|
|
66
|
-
description: import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
|
|
67
|
-
parent: import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
|
|
68
|
-
kind: import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
|
|
69
|
-
externalDocs: import("@scalar/validation").OptionalSchema<import("@scalar/validation").ObjectSchema<{
|
|
70
|
-
url: import("@scalar/validation").StringSchema;
|
|
71
|
-
description: import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
|
|
72
|
-
}>>;
|
|
73
|
-
}>, import("@scalar/validation").ObjectSchema<{
|
|
74
|
-
'x-displayName': import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
|
|
75
|
-
}>, import("@scalar/validation").ObjectSchema<{
|
|
76
|
-
'x-internal': import("@scalar/validation").OptionalSchema<import("@scalar/validation").BooleanSchema>;
|
|
77
|
-
}>, import("@scalar/validation").ObjectSchema<{
|
|
78
|
-
'x-scalar-ignore': import("@scalar/validation").OptionalSchema<import("@scalar/validation").BooleanSchema>;
|
|
79
|
-
}>, import("@scalar/validation").ObjectSchema<{
|
|
80
|
-
'x-scalar-order': import("@scalar/validation").OptionalSchema<import("@scalar/validation").ArraySchema<import("@scalar/validation").StringSchema>>;
|
|
81
|
-
}>]>>>;
|
|
82
|
-
externalDocs: import("@scalar/validation").OptionalSchema<import("@scalar/validation").ObjectSchema<{
|
|
83
|
-
url: import("@scalar/validation").StringSchema;
|
|
84
|
-
description: import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
|
|
85
|
-
}>>;
|
|
86
|
-
}>, import("@scalar/validation").ObjectSchema<{
|
|
87
|
-
'x-original-oas-version': import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
|
|
88
|
-
"x-scalar-navigation": import("@scalar/validation").OptionalSchema<import("@scalar/validation").AnySchema>;
|
|
89
|
-
}>, import("@scalar/validation").ObjectSchema<{
|
|
90
|
-
'x-scalar-original-source-url': import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
|
|
91
|
-
}>, import("@scalar/validation").ObjectSchema<{
|
|
92
|
-
'x-tagGroups': import("@scalar/validation").OptionalSchema<import("@scalar/validation").ArraySchema<import("@scalar/validation").IntersectionSchema<readonly [import("@scalar/validation").ObjectSchema<{
|
|
93
|
-
name: import("@scalar/validation").StringSchema;
|
|
94
|
-
tags: import("@scalar/validation").ArraySchema<import("@scalar/validation").StringSchema>;
|
|
95
|
-
}>, import("@scalar/validation").ObjectSchema<{
|
|
96
|
-
'x-scalar-order': import("@scalar/validation").OptionalSchema<import("@scalar/validation").ArraySchema<import("@scalar/validation").StringSchema>>;
|
|
97
|
-
}>]>>>;
|
|
98
|
-
}>, import("@scalar/validation").ObjectSchema<{
|
|
99
|
-
'x-scalar-environments': import("@scalar/validation").OptionalSchema<import("@scalar/validation").RecordSchema<import("@scalar/validation").StringSchema, import("@scalar/validation").ObjectSchema<{
|
|
100
|
-
description: import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
|
|
101
|
-
color: import("@scalar/validation").StringSchema;
|
|
102
|
-
variables: import("@scalar/validation").ArraySchema<import("@scalar/validation").ObjectSchema<{
|
|
103
|
-
name: import("@scalar/validation").StringSchema;
|
|
104
|
-
value: import("@scalar/validation").UnionSchema<readonly [import("@scalar/validation").ObjectSchema<{
|
|
105
|
-
description: import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
|
|
106
|
-
default: import("@scalar/validation").StringSchema;
|
|
107
|
-
}>, import("@scalar/validation").StringSchema]>;
|
|
108
|
-
}>>;
|
|
109
|
-
}>>>;
|
|
110
|
-
}>, import("@scalar/validation").ObjectSchema<{
|
|
111
|
-
'x-scalar-selected-server': import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
|
|
112
|
-
}>, import("@scalar/validation").ObjectSchema<{
|
|
113
|
-
'x-scalar-icon': import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
|
|
114
|
-
}>, import("@scalar/validation").ObjectSchema<{
|
|
115
|
-
'x-scalar-order': import("@scalar/validation").OptionalSchema<import("@scalar/validation").ArraySchema<import("@scalar/validation").StringSchema>>;
|
|
116
|
-
}>, import("@scalar/validation").ObjectSchema<{
|
|
117
|
-
'x-scalar-cookies': import("@scalar/validation").OptionalSchema<import("@scalar/validation").ArraySchema<import("@scalar/validation").ObjectSchema<{
|
|
118
|
-
name: import("@scalar/validation").StringSchema;
|
|
119
|
-
value: import("@scalar/validation").StringSchema;
|
|
120
|
-
domain: import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
|
|
121
|
-
path: import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
|
|
122
|
-
isDisabled: import("@scalar/validation").OptionalSchema<import("@scalar/validation").BooleanSchema>;
|
|
123
|
-
}>>>;
|
|
124
|
-
}>, import("@scalar/validation").ObjectSchema<{
|
|
125
|
-
'x-scalar-original-document-hash': import("@scalar/validation").StringSchema;
|
|
126
|
-
}>, import("@scalar/validation").ObjectSchema<{
|
|
127
|
-
'x-scalar-is-dirty': import("@scalar/validation").OptionalSchema<import("@scalar/validation").BooleanSchema>;
|
|
128
|
-
}>, import("@scalar/validation").ObjectSchema<{
|
|
129
|
-
'x-scalar-active-environment': import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
|
|
130
|
-
}>, import("@scalar/validation").ObjectSchema<{
|
|
131
|
-
'x-scalar-watch-mode': import("@scalar/validation").OptionalSchema<import("@scalar/validation").BooleanSchema>;
|
|
132
|
-
}>, import("@scalar/validation").ObjectSchema<{
|
|
133
|
-
'x-scalar-registry-meta': import("@scalar/validation").OptionalSchema<import("@scalar/validation").ObjectSchema<{
|
|
134
|
-
namespace: import("@scalar/validation").StringSchema;
|
|
135
|
-
slug: import("@scalar/validation").StringSchema;
|
|
136
|
-
version: import("@scalar/validation").StringSchema;
|
|
137
|
-
commitHash: import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
|
|
138
|
-
conflictCheckedAgainstHash: import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
|
|
139
|
-
hasConflict: import("@scalar/validation").OptionalSchema<import("@scalar/validation").BooleanSchema>;
|
|
140
|
-
}>>;
|
|
141
|
-
}>, import("@scalar/validation").ObjectSchema<{
|
|
142
|
-
'x-scalar-default-request-body-view': import("@scalar/validation").OptionalSchema<import("@scalar/validation").UnionSchema<readonly [import("@scalar/validation").LiteralSchema<"form">, import("@scalar/validation").LiteralSchema<"raw">]>>;
|
|
143
|
-
}>, import("@scalar/validation").ObjectSchema<{
|
|
144
|
-
'x-pre-request': import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
|
|
145
|
-
}>, import("@scalar/validation").ObjectSchema<{
|
|
146
|
-
'x-post-response': import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
|
|
147
|
-
}>]>;
|
|
148
|
-
export {};
|
|
149
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/schemas/v3.1/openapi/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EAaZ,MAAM,oBAAoB,CAAA;AA8C3B,0CAA0C;AAC1C,KAAK,qBAAqB,GAAG;IAC3B;;;;;;OAMG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAC/B,CAAA;AA8DD;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAAI,UAAU,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,KAAG,MAyM1E,CAAA;AAED,eAAO,MAAM,cAAc,GAAI,UAAU,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,EAAE,UAAS,qBAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAs2BtG,CAAA"}
|