@scalar/workspace-store 0.68.1 → 0.68.2
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 +10 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +8 -1
- package/dist/helpers/chunk-index.d.ts +2 -0
- package/dist/helpers/chunk-index.d.ts.map +1 -1
- package/dist/helpers/chunk-index.js +8 -1
- package/dist/helpers/encode-path-parameter.d.ts +20 -0
- package/dist/helpers/encode-path-parameter.d.ts.map +1 -0
- package/dist/helpers/encode-path-parameter.js +51 -0
- package/dist/helpers/get-tag-kind.d.ts +6 -0
- package/dist/helpers/get-tag-kind.d.ts.map +1 -0
- package/dist/helpers/get-tag-kind.js +7 -0
- package/dist/helpers/resolve-form-schema.d.ts +9 -0
- package/dist/helpers/resolve-form-schema.d.ts.map +1 -0
- package/dist/helpers/resolve-form-schema.js +143 -0
- package/dist/helpers/resolve-schema-with-annotations.d.ts +11 -0
- package/dist/helpers/resolve-schema-with-annotations.d.ts.map +1 -0
- package/dist/helpers/resolve-schema-with-annotations.js +57 -0
- package/dist/helpers/resolve-security-requirements.d.ts +15 -0
- package/dist/helpers/resolve-security-requirements.d.ts.map +1 -0
- package/dist/helpers/resolve-security-requirements.js +222 -0
- package/dist/navigation/helpers/get-navigation-tag-names.d.ts +5 -0
- package/dist/navigation/helpers/get-navigation-tag-names.d.ts.map +1 -0
- package/dist/navigation/helpers/get-navigation-tag-names.js +3 -0
- package/dist/navigation/helpers/traverse-paths.d.ts.map +1 -1
- package/dist/navigation/helpers/traverse-paths.js +4 -2
- package/dist/navigation/helpers/traverse-schemas.d.ts.map +1 -1
- package/dist/navigation/helpers/traverse-schemas.js +4 -2
- package/dist/navigation/helpers/traverse-tags.d.ts.map +1 -1
- package/dist/navigation/helpers/traverse-tags.js +8 -4
- package/dist/navigation/helpers/traverse-webhooks.d.ts.map +1 -1
- package/dist/navigation/helpers/traverse-webhooks.js +4 -2
- package/dist/request-example/builder/body/build-request-body.d.ts.map +1 -1
- package/dist/request-example/builder/body/build-request-body.js +3 -5
- package/dist/request-example/builder/body/schema-value-coercion.d.ts.map +1 -1
- package/dist/request-example/builder/body/schema-value-coercion.js +5 -7
- package/dist/request-example/builder/build-request.d.ts.map +1 -1
- package/dist/request-example/builder/build-request.js +3 -0
- package/dist/request-example/builder/header/build-request-parameters.d.ts +7 -1
- package/dist/request-example/builder/header/build-request-parameters.d.ts.map +1 -1
- package/dist/request-example/builder/header/build-request-parameters.js +22 -1
- package/dist/request-example/builder/request-factory.d.ts +6 -1
- package/dist/request-example/builder/request-factory.d.ts.map +1 -1
- package/dist/request-example/builder/request-factory.js +3 -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 +22 -7
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +34 -7
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @scalar/workspace-store
|
|
2
2
|
|
|
3
|
+
## 0.68.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#10491](https://github.com/scalar/scalar/pull/10491): Use OpenAPI 3.2 tag categories to keep badges and audience labels out of navigation groups and display them on operations.
|
|
8
|
+
- [#10489](https://github.com/scalar/scalar/pull/10489): Report invalid non-exploded structured cookies in OpenAPI 3.2 documents and prevent invalid request and code sample generation. Recommend `style: cookie` with `explode: true`.
|
|
9
|
+
- [#10480](https://github.com/scalar/scalar/pull/10480): Resolve structural allOf object fields and annotation-only wrappers and selected oneOf/anyOf variants in form body fields, preserving descriptions, nested inputs, and multipart value types when switching variants.
|
|
10
|
+
- [#10487](https://github.com/scalar/scalar/pull/10487): Honor OpenAPI 3.2 allowReserved for path parameters while escaping forbidden path characters and preserving the encoded path in Ruby code examples.
|
|
11
|
+
- [#10488](https://github.com/scalar/scalar/pull/10488): Resolve OpenAPI 3.2 security requirements by URI, including relative references based on the document URI, while preserving named schemes and authored exports.
|
|
12
|
+
|
|
3
13
|
## 0.68.1
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,YAAY,EAAU,MAAM,2BAA2B,CAAA;AAErE,OAAO,EAAE,KAAK,UAAU,EAAe,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAQ7E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAI5C,OAAO,EAAE,KAAK,SAAS,EAAmB,MAAM,iBAAiB,CAAA;AACjE,OAAO,EAAE,KAAK,YAAY,EAAsB,MAAM,oBAAoB,CAAA;AAM1E,OAAO,EAAE,KAAK,uBAAuB,EAAiC,MAAM,6BAA6B,CAAA;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,YAAY,EAAU,MAAM,2BAA2B,CAAA;AAErE,OAAO,EAAE,KAAK,UAAU,EAAe,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAQ7E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAI5C,OAAO,EAAE,KAAK,SAAS,EAAmB,MAAM,iBAAiB,CAAA;AACjE,OAAO,EAAE,KAAK,YAAY,EAAsB,MAAM,oBAAoB,CAAA;AAM1E,OAAO,EAAE,KAAK,uBAAuB,EAAiC,MAAM,6BAA6B,CAAA;AAUzG,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAA;AAc5E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAA;AAKrE,OAAO,EAGL,KAAK,eAAe,EACrB,MAAM,wCAAwC,CAAA;AAC/C,OAAO,KAAK,EACV,sBAAsB,EACtB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,GAAG,OAAO,CAAA;IAC5D;;;;;;;;;OASG;IACH,cAAc,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1C;;;;;;;;;;OAUG;IACH,eAAe,IAAI,iBAAiB,CAAA;IACpC;;;;;;;OAOG;IACH,aAAa,CAAC,KAAK,EAAE,iBAAiB,GAAG,IAAI,CAAA;IAC7C;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,gCAAgC,CAAC,aAAa,EAAE,sBAAsB,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAAA;IAC3F;;;;;;;;;;;;;;;;;;;OAmBG;IACH,cAAc,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,OAAO,CACtD;QACE,EAAE,EAAE,KAAK,CAAA;QACT,IAAI,EAAE,iBAAiB,GAAG,cAAc,GAAG,qBAAqB,CAAA;QAChE,OAAO,EAAE,MAAM,CAAA;KAChB,GACD;QACE,EAAE,EAAE,IAAI,CAAA;QACR,OAAO,EAAE,UAAU,CAAC,OAAO,KAAK,CAAC,CAAC,OAAO,CAAC,CAAA;QAC1C,SAAS,EAAE,UAAU,CAAC,OAAO,KAAK,CAAC,CAAC,WAAW,CAAC,CAAA;QAChD,YAAY,EAAE,CACZ,iBAAiB,EACb;YACE,iBAAiB,EAAE,UAAU,CAAC,OAAO,CAAC,EAAE,CAAA;SACzC,GACD;YACE,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;SAC1C,KACF,OAAO,CAAC,IAAI,CAAC,CAAA;KACnB,CACJ,CAAA;CACF,CAAA;AAyDD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,oBAAoB,GAAI,iBAAiB,cAAc,KAAG,cA0vCtE,CAAA;AAGD,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA"}
|
package/dist/client.js
CHANGED
|
@@ -28,6 +28,7 @@ import { getResolvedRef } from './helpers/get-resolved-ref.js';
|
|
|
28
28
|
import { mergeObjects } from './helpers/merge-object.js';
|
|
29
29
|
import { normalizeBooleanSchemas } from './helpers/normalize-boolean-schemas.js';
|
|
30
30
|
import { createOverridesProxy } from './helpers/overrides-proxy.js';
|
|
31
|
+
import { resolveSecurityRequirements, restoreSecurityRequirements } from './helpers/resolve-security-requirements.js';
|
|
31
32
|
import { unpackProxyObject } from './helpers/unpack-proxy.js';
|
|
32
33
|
import { createNavigation, traverseAsyncApiDocument } from './navigation/index.js';
|
|
33
34
|
import { externalValueResolver, loadingStatus, normalizeAuthSchemes, normalizeRefs, openApiDocument, refsEverywhere, removeExtraScalarKeys, resolveOpenApiDocument, restoreOriginalRefs, syncPathParameters, } from './plugins/bundler/index.js';
|
|
@@ -579,6 +580,7 @@ export const createWorkspaceStore = (workspaceProps) => {
|
|
|
579
580
|
urlMap: true,
|
|
580
581
|
origin: input.documentSource, // use the document origin (if provided) as the base URL for resolution
|
|
581
582
|
}));
|
|
583
|
+
await resolveSecurityRequirements(getRaw(strictDocument), { origin: input.documentSource, loaders });
|
|
582
584
|
// We coerce the values only when the document is not preprocessed by the server-side-store
|
|
583
585
|
const coerced = withMeasurementSync('coerceValue', () => coerce(openapiSchema, normalizeBooleanSchemas(deepClone(strictDocument))));
|
|
584
586
|
withMeasurementSync('mergeObjects', () => mergeObjects(strictDocument, coerced));
|
|
@@ -696,6 +698,9 @@ export const createWorkspaceStore = (workspaceProps) => {
|
|
|
696
698
|
* @returns The editable document object, or null if not found.
|
|
697
699
|
*/
|
|
698
700
|
const getEditableDocument = async (documentName) => {
|
|
701
|
+
if (!Object.hasOwn(workspace.documents, documentName))
|
|
702
|
+
return null;
|
|
703
|
+
preventPollution(documentName, 'workspace document name');
|
|
699
704
|
const rawDocument = unpackProxyObject(workspace.documents[documentName], { depth: 1 });
|
|
700
705
|
if (!rawDocument) {
|
|
701
706
|
// If the document does not exist, return null
|
|
@@ -704,7 +709,9 @@ export const createWorkspaceStore = (workspaceProps) => {
|
|
|
704
709
|
// This is the shared cleanup boundary for editing and saving. Both JSON and YAML
|
|
705
710
|
// exports read the cleaned saved baseline, so serializers need no marker filtering.
|
|
706
711
|
// Reverse all external references and restore original $refs.
|
|
707
|
-
const
|
|
712
|
+
const authoredDocument = deepClone(rawDocument);
|
|
713
|
+
restoreSecurityRequirements(authoredDocument);
|
|
714
|
+
const original = (await bundle(authoredDocument, {
|
|
708
715
|
plugins: [openApiDocument(), restoreOriginalRefs(), removeExtraScalarKeys()],
|
|
709
716
|
treeShake: false,
|
|
710
717
|
urlMap: true,
|
|
@@ -54,6 +54,8 @@ export type ChunkIndex = {
|
|
|
54
54
|
* to the wrong chunk.
|
|
55
55
|
*/
|
|
56
56
|
export declare const fillChunkRef: (template: string, values?: Record<string, string>) => string;
|
|
57
|
+
/** Encodes a component name as a URI-safe JSON Pointer segment for SSR asset references. */
|
|
58
|
+
export declare const encodeSsrComponentName: (value: string) => string;
|
|
57
59
|
/**
|
|
58
60
|
* Builds the reference templates for one document.
|
|
59
61
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunk-index.d.ts","sourceRoot":"","sources":["../../src/helpers/chunk-index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAE7D;;;;;GAKG;AACH,eAAO,MAAM,eAAe,yBAAyB,CAAA;AAKrD,0FAA0F;AAC1F,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,KAAK,CAAA;AAExC,wFAAwF;AACxF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,iCAAiC;IACjC,UAAU,EAAE,MAAM,CAAA;IAClB,mCAAmC;IACnC,UAAU,EAAE,MAAM,CAAA;IAClB,gBAAgB;IAChB,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED;;;;;;GAMG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,SAAS,CAAA;IACf;;;;;;OAMG;IACH,IAAI,EAAE,IAAI,CAAC,iBAAiB,EAAE,YAAY,CAAC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SAAQ,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,KAAG,MAGlF,CAAA;AAKH,4FAA4F;AAC5F,eAAO,MAAM,sBAAsB,GAAI,OAAO,MAAM,KAAG,MAAsD,CAAA;AA0B7G;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAC5B,MAAM;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,KACtF,iBAkBF,CAAA;AAED,8DAA8D;AAC9D,eAAO,MAAM,cAAc,GAAI,KAAK,MAAM,KAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,IAAI,CAAA;CAAsC,CAAA;AAEhH;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,GAAI,oCAAoC,iBAAiB,KAAG,iBAGvF,CAAA;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,GAAI,oCAK7B;IACD,IAAI,EAAE,SAAS,CAAA;IACf,IAAI,EAAE,iBAAiB,CAAA;IACvB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;IACnD,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;CAC/C,KAAG,UAYF,CAAA;AAUF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,gBAAgB,GAAI,UAAU,OAAO,KAAG,OAqDpD,CAAA"}
|
|
@@ -24,6 +24,8 @@ const TEMPLATE_SLOT = /\{\{|\}\}|\{(\w+)\}/g;
|
|
|
24
24
|
export const fillChunkRef = (template, values = {}) => template.replace(TEMPLATE_SLOT, (match, slot) => slot === undefined ? match.charAt(0) : (values[slot] ?? match));
|
|
25
25
|
/** Escapes text inlined into a template verbatim, so its braces are not read back as slots. */
|
|
26
26
|
const escapeTemplateLiteral = (text) => text.replaceAll('{', '{{').replaceAll('}', '}}');
|
|
27
|
+
/** Encodes a component name as a URI-safe JSON Pointer segment for SSR asset references. */
|
|
28
|
+
export const encodeSsrComponentName = (value) => encodeURIComponent(escapeJsonPointer(value));
|
|
27
29
|
const identity = (value) => value;
|
|
28
30
|
/**
|
|
29
31
|
* How each template slot is spelled, per mode.
|
|
@@ -39,7 +41,12 @@ const identity = (value) => value;
|
|
|
39
41
|
*/
|
|
40
42
|
const SLOT_ENCODERS = {
|
|
41
43
|
static: { type: encodeChunkName, name: encodeChunkName, path: encodeChunkName, method: identity },
|
|
42
|
-
ssr: {
|
|
44
|
+
ssr: {
|
|
45
|
+
type: identity,
|
|
46
|
+
name: encodeSsrComponentName,
|
|
47
|
+
path: escapeJsonPointer,
|
|
48
|
+
method: identity,
|
|
49
|
+
},
|
|
43
50
|
};
|
|
44
51
|
/**
|
|
45
52
|
* Builds the reference templates for one document.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Encodes a path parameter, preserving only path-safe reserved characters and
|
|
3
|
+
* existing percent-encoded triples when OpenAPI reserved expansion is enabled.
|
|
4
|
+
* Slashes, query/fragment delimiters, and brackets must remain escaped.
|
|
5
|
+
*/
|
|
6
|
+
export declare const encodePathParameter: (value: string, allowReserved?: boolean) => string;
|
|
7
|
+
/** Style metadata retained until environment substitution and path encoding. */
|
|
8
|
+
export type ReservedPathParameter = {
|
|
9
|
+
/** Structured input retains array items and object entries for style delimiters. */
|
|
10
|
+
value: unknown;
|
|
11
|
+
/** Original preview value lets request hooks override path.variables. */
|
|
12
|
+
originalValue: string;
|
|
13
|
+
style: string;
|
|
14
|
+
explode: boolean;
|
|
15
|
+
};
|
|
16
|
+
/** Serializes OpenAPI reserved path expansion without exposing forbidden delimiters. */
|
|
17
|
+
export declare const serializeReservedPathParameter: (name: string, parameter: Pick<ReservedPathParameter, "value" | "style" | "explode">, replace?: (value: string) => string) => string;
|
|
18
|
+
/** Rejects dot segments that browser URL parsing would silently remove. */
|
|
19
|
+
export declare const assertReservedPathUrl: (url: string) => void;
|
|
20
|
+
//# sourceMappingURL=encode-path-parameter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encode-path-parameter.d.ts","sourceRoot":"","sources":["../../src/helpers/encode-path-parameter.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAAI,OAAO,MAAM,EAAE,uBAAqB,KAAG,MAS1E,CAAA;AAED,gFAAgF;AAChF,MAAM,MAAM,qBAAqB,GAAG;IAClC,oFAAoF;IACpF,KAAK,EAAE,OAAO,CAAA;IACd,yEAAyE;IACzE,aAAa,EAAE,MAAM,CAAA;IACrB,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,wFAAwF;AACxF,eAAO,MAAM,8BAA8B,GACzC,MAAM,MAAM,EACZ,WAAW,IAAI,CAAC,qBAAqB,EAAE,OAAO,GAAG,OAAO,GAAG,SAAS,CAAC,EACrE,UAAS,CAAC,KAAK,EAAE,MAAM,KAAK,MAAyB,KACpD,MAgCF,CAAA;AAED,2EAA2E;AAC3E,eAAO,MAAM,qBAAqB,GAAI,KAAK,MAAM,KAAG,IAKnD,CAAA"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { isObjectLike } from '@scalar/helpers/object/is-object';
|
|
2
|
+
/**
|
|
3
|
+
* Encodes a path parameter, preserving only path-safe reserved characters and
|
|
4
|
+
* existing percent-encoded triples when OpenAPI reserved expansion is enabled.
|
|
5
|
+
* Slashes, query/fragment delimiters, and brackets must remain escaped.
|
|
6
|
+
*/
|
|
7
|
+
export const encodePathParameter = (value, allowReserved = false) => {
|
|
8
|
+
if (!allowReserved) {
|
|
9
|
+
return encodeURIComponent(value);
|
|
10
|
+
}
|
|
11
|
+
return value.replace(/%[0-9a-f]{2}|[\s\S]/giu, (character) => /^%[0-9a-f]{2}$/i.test(character) || /^[!$&'()*+,;=:@]$/.test(character)
|
|
12
|
+
? character
|
|
13
|
+
: encodeURIComponent(character));
|
|
14
|
+
};
|
|
15
|
+
/** Serializes OpenAPI reserved path expansion without exposing forbidden delimiters. */
|
|
16
|
+
export const serializeReservedPathParameter = (name, parameter, replace = (value) => value) => {
|
|
17
|
+
const { value, style, explode } = parameter;
|
|
18
|
+
const encode = (item) => encodePathParameter(replace(String(item)), true);
|
|
19
|
+
const entries = isObjectLike(value) && !Array.isArray(value) ? Object.entries(value) : undefined;
|
|
20
|
+
const array = Array.isArray(value) ? value : undefined;
|
|
21
|
+
if (style === 'matrix') {
|
|
22
|
+
if (entries && explode) {
|
|
23
|
+
return entries.map(([key, item]) => `;${encode(key)}=${encode(item)}`).join('');
|
|
24
|
+
}
|
|
25
|
+
if (array && explode) {
|
|
26
|
+
return array.map((item) => `;${encode(name)}=${encode(item)}`).join('');
|
|
27
|
+
}
|
|
28
|
+
const data = entries
|
|
29
|
+
? entries.flatMap(([key, item]) => [encode(key), encode(item)]).join(',')
|
|
30
|
+
: array
|
|
31
|
+
? array.map(encode).join(',')
|
|
32
|
+
: encode(value);
|
|
33
|
+
return `;${encode(name)}=${data}`;
|
|
34
|
+
}
|
|
35
|
+
const delimiter = style === 'label' && explode ? '.' : ',';
|
|
36
|
+
const data = entries
|
|
37
|
+
? entries
|
|
38
|
+
.map(([key, item]) => explode ? `${encode(key)}=${encode(item)}` : `${encode(key)}${delimiter}${encode(item)}`)
|
|
39
|
+
.join(delimiter)
|
|
40
|
+
: array
|
|
41
|
+
? array.map(encode).join(delimiter)
|
|
42
|
+
: encode(value);
|
|
43
|
+
return style === 'label' ? `.${data}` : data;
|
|
44
|
+
};
|
|
45
|
+
/** Rejects dot segments that browser URL parsing would silently remove. */
|
|
46
|
+
export const assertReservedPathUrl = (url) => {
|
|
47
|
+
const path = url.split(/[?#]/, 1)[0] ?? '';
|
|
48
|
+
if (path.split('/').some((segment) => /^(?:\.|%2e){1,2}$/i.test(segment))) {
|
|
49
|
+
throw new URIError('Reserved path parameters cannot form dot segments because browsers normalize them.');
|
|
50
|
+
}
|
|
51
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { OpenApiDocument, TagObject } from '../schemas/v3.2/strict/openapi-document.js';
|
|
2
|
+
/** Categories with presentation behavior in Scalar. Custom kinds retain legacy navigation. */
|
|
3
|
+
export type TagKind = 'nav' | 'badge' | 'audience';
|
|
4
|
+
/** Only OpenAPI 3.2 gives tag kinds meaning; earlier documents keep their existing groups. */
|
|
5
|
+
export declare const getTagKind: (document: Pick<OpenApiDocument, "openapi">, tag?: TagObject) => TagKind;
|
|
6
|
+
//# sourceMappingURL=get-tag-kind.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-tag-kind.d.ts","sourceRoot":"","sources":["../../src/helpers/get-tag-kind.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAA;AAExF,8FAA8F;AAC9F,MAAM,MAAM,OAAO,GAAG,KAAK,GAAG,OAAO,GAAG,UAAU,CAAA;AAElD,8FAA8F;AAC9F,eAAO,MAAM,UAAU,GAAI,UAAU,IAAI,CAAC,eAAe,EAAE,SAAS,CAAC,EAAE,MAAM,SAAS,KAAG,OAKxF,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Only OpenAPI 3.2 gives tag kinds meaning; earlier documents keep their existing groups. */
|
|
2
|
+
export const getTagKind = (document, tag) => {
|
|
3
|
+
if (document.openapi.startsWith('3.2.') && (tag?.kind === 'badge' || tag?.kind === 'audience')) {
|
|
4
|
+
return tag.kind;
|
|
5
|
+
}
|
|
6
|
+
return 'nav';
|
|
7
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { SchemaObject } from '../schemas/v3.2/strict/openapi-document.js';
|
|
2
|
+
import type { MaybeRefSchemaObject } from '../schemas/v3.2/strict/schema.js';
|
|
3
|
+
/**
|
|
4
|
+
* Expose the selected request-body shape to form editors and serializers without changing the
|
|
5
|
+
* API description. Use the example generator's branch selection so field types match its values.
|
|
6
|
+
* Unselected alternatives remain on the view for validation, but do not contribute form fields.
|
|
7
|
+
*/
|
|
8
|
+
export declare const resolveFormSchema: (schema: MaybeRefSchemaObject | undefined, compositionSelection?: Record<string, number>) => SchemaObject | undefined;
|
|
9
|
+
//# sourceMappingURL=resolve-form-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-form-schema.d.ts","sourceRoot":"","sources":["../../src/helpers/resolve-form-schema.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAA;AAC1E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAA;AAMxE;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAC5B,QAAQ,oBAAoB,GAAG,SAAS,EACxC,uBAAuB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAC5C,YAAY,GAAG,SAyJjB,CAAA"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { objectEntries } from '@scalar/helpers/object/object-entries';
|
|
2
|
+
import { selectExampleComposition } from '../request-example/builder/helpers/get-example-from-schema.js';
|
|
3
|
+
import { resolve } from '../resolve.js';
|
|
4
|
+
import { isNumberSchema, isObjectSchema } from '../schemas/v3.2/strict/type-guards.js';
|
|
5
|
+
import { getSchemaAnnotations, resolveSchemaWithAnnotations } from './resolve-schema-with-annotations.js';
|
|
6
|
+
import { unpackProxyShallow } from './unpack-proxy.js';
|
|
7
|
+
/**
|
|
8
|
+
* Expose the selected request-body shape to form editors and serializers without changing the
|
|
9
|
+
* API description. Use the example generator's branch selection so field types match its values.
|
|
10
|
+
* Unselected alternatives remain on the view for validation, but do not contribute form fields.
|
|
11
|
+
*/
|
|
12
|
+
export const resolveFormSchema = (schema, compositionSelection) => {
|
|
13
|
+
const ancestors = new Set();
|
|
14
|
+
const visit = (input, path, selection) => {
|
|
15
|
+
const source = resolve.schema(input);
|
|
16
|
+
const resolved = resolveSchemaWithAnnotations(input);
|
|
17
|
+
if (!source || !resolved || !input) {
|
|
18
|
+
return resolved;
|
|
19
|
+
}
|
|
20
|
+
const identity = unpackProxyShallow(input);
|
|
21
|
+
// Recursive properties remain opaque leaves instead of expanding an infinite form.
|
|
22
|
+
if (ancestors.has(identity)) {
|
|
23
|
+
return isObjectSchema(resolved) ? { ...resolved, properties: undefined } : resolved;
|
|
24
|
+
}
|
|
25
|
+
ancestors.add(identity);
|
|
26
|
+
try {
|
|
27
|
+
if (source.allOf?.length) {
|
|
28
|
+
let choiceIndex = 0;
|
|
29
|
+
const members = source.allOf.map((member) => {
|
|
30
|
+
const memberSchema = resolve.schema(member);
|
|
31
|
+
const isChoice = Boolean(memberSchema?.oneOf || memberSchema?.anyOf);
|
|
32
|
+
return visit(member, isChoice ? [...path, String(choiceIndex++)] : path, selection) ?? member;
|
|
33
|
+
});
|
|
34
|
+
if (!resolved.allOf) {
|
|
35
|
+
return resolveSchemaWithAnnotations({ ...source, allOf: members });
|
|
36
|
+
}
|
|
37
|
+
const { allOf: _allOf, ...siblings } = source;
|
|
38
|
+
const parts = [visit(siblings, path, selection), ...members].filter((member) => member !== undefined);
|
|
39
|
+
const typed = parts.filter((member) => 'type' in member && member.type !== undefined);
|
|
40
|
+
const first = typed[0];
|
|
41
|
+
if (!first || !('type' in first) || Array.isArray(first.type)) {
|
|
42
|
+
return resolved;
|
|
43
|
+
}
|
|
44
|
+
const type = typed.some((member) => 'type' in member && member.type === 'integer') &&
|
|
45
|
+
(first.type === 'integer' || first.type === 'number')
|
|
46
|
+
? 'integer'
|
|
47
|
+
: first.type;
|
|
48
|
+
// Incompatible intersections have no single input type. Keep them as opaque leaves.
|
|
49
|
+
if (typed.some((member) => 'type' in member && member.type !== type && !(type === 'integer' && member.type === 'number'))) {
|
|
50
|
+
return resolved;
|
|
51
|
+
}
|
|
52
|
+
const annotations = Object.assign({}, ...parts.map(getSchemaAnnotations));
|
|
53
|
+
const result = { ...first, ...annotations, ...siblings, type, allOf: source.allOf };
|
|
54
|
+
Reflect.deleteProperty(result, '__scalar_');
|
|
55
|
+
if (isObjectSchema(result)) {
|
|
56
|
+
const properties = {};
|
|
57
|
+
const required = new Set();
|
|
58
|
+
for (const part of parts) {
|
|
59
|
+
if ('required' in part) {
|
|
60
|
+
for (const name of part.required ?? []) {
|
|
61
|
+
required.add(name);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if ('properties' in part) {
|
|
65
|
+
for (const [name, child] of objectEntries(part.properties ?? {})) {
|
|
66
|
+
const previous = properties[name];
|
|
67
|
+
properties[name] = previous
|
|
68
|
+
? (visit({ __scalar_: '', allOf: [previous, child] }, [...path, name], selection) ?? child)
|
|
69
|
+
: child;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
result.properties = properties;
|
|
74
|
+
result.required = [...required];
|
|
75
|
+
}
|
|
76
|
+
if (isNumberSchema(result)) {
|
|
77
|
+
const minima = parts.flatMap((part) => 'minimum' in part && part.minimum !== undefined ? [part.minimum] : []);
|
|
78
|
+
const maxima = parts.flatMap((part) => 'maximum' in part && part.maximum !== undefined ? [part.maximum] : []);
|
|
79
|
+
if (minima.length) {
|
|
80
|
+
result.minimum = Math.max(...minima);
|
|
81
|
+
}
|
|
82
|
+
if (maxima.length) {
|
|
83
|
+
result.maximum = Math.min(...maxima);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return result;
|
|
87
|
+
}
|
|
88
|
+
const properties = isObjectSchema(resolved) && resolved.properties
|
|
89
|
+
? Object.fromEntries(objectEntries(resolved.properties).map(([key, child]) => [
|
|
90
|
+
key,
|
|
91
|
+
visit(child, [...path, key], selection) ?? child,
|
|
92
|
+
]))
|
|
93
|
+
: undefined;
|
|
94
|
+
const base = properties ? { ...resolved, properties } : resolved;
|
|
95
|
+
const keyword = resolved.oneOf ? 'oneOf' : 'anyOf';
|
|
96
|
+
const candidate = selectExampleComposition(resolved, path, { compositionSelection: selection });
|
|
97
|
+
if (!candidate) {
|
|
98
|
+
return base;
|
|
99
|
+
}
|
|
100
|
+
const selectionKey = [...path, keyword].join('.');
|
|
101
|
+
const { [selectionKey]: _selection, ...remainingSelection } = selection ?? {};
|
|
102
|
+
const selected = visit(candidate, path, remainingSelection);
|
|
103
|
+
if (!selected) {
|
|
104
|
+
return base;
|
|
105
|
+
}
|
|
106
|
+
const result = { ...base, ...selected, [keyword]: resolved[keyword] };
|
|
107
|
+
if ('type' in result) {
|
|
108
|
+
Reflect.deleteProperty(result, '__scalar_');
|
|
109
|
+
}
|
|
110
|
+
if (isNumberSchema(result)) {
|
|
111
|
+
// Parent and branch bounds both apply; selecting a variant must not weaken validation.
|
|
112
|
+
if ('minimum' in base &&
|
|
113
|
+
'minimum' in selected &&
|
|
114
|
+
base.minimum !== undefined &&
|
|
115
|
+
selected.minimum !== undefined) {
|
|
116
|
+
result.minimum = Math.max(base.minimum, selected.minimum);
|
|
117
|
+
}
|
|
118
|
+
if ('maximum' in base &&
|
|
119
|
+
'maximum' in selected &&
|
|
120
|
+
base.maximum !== undefined &&
|
|
121
|
+
selected.maximum !== undefined) {
|
|
122
|
+
result.maximum = Math.min(base.maximum, selected.maximum);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
if (resolved.description !== undefined) {
|
|
126
|
+
result.description = resolved.description;
|
|
127
|
+
}
|
|
128
|
+
if (isObjectSchema(result)) {
|
|
129
|
+
const baseProperties = 'properties' in base ? base.properties : undefined;
|
|
130
|
+
const selectedProperties = 'properties' in selected ? selected.properties : undefined;
|
|
131
|
+
const baseRequired = 'required' in base ? base.required : undefined;
|
|
132
|
+
const selectedRequired = 'required' in selected ? selected.required : undefined;
|
|
133
|
+
result.properties = { ...baseProperties, ...selectedProperties };
|
|
134
|
+
result.required = [...new Set([...(baseRequired ?? []), ...(selectedRequired ?? [])])];
|
|
135
|
+
}
|
|
136
|
+
return result;
|
|
137
|
+
}
|
|
138
|
+
finally {
|
|
139
|
+
ancestors.delete(identity);
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
return visit(schema, ['requestBody'], compositionSelection);
|
|
143
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { SchemaObject } from '../schemas/v3.2/strict/openapi-document.js';
|
|
2
|
+
import type { MaybeRefSchemaObject } from '../schemas/v3.2/strict/schema.js';
|
|
3
|
+
/** Extract annotation keywords without copying validation constraints into a form projection. */
|
|
4
|
+
export declare const getSchemaAnnotations: (schema: SchemaObject) => Record<string, unknown>;
|
|
5
|
+
/**
|
|
6
|
+
* Expose the value schema inside an annotation-only allOf wrapper for form editors and serializers.
|
|
7
|
+
* Multiple value schemas retain their composition, since combining their constraints requires more
|
|
8
|
+
* than spreading their keywords. The returned view does not mutate the API description.
|
|
9
|
+
*/
|
|
10
|
+
export declare const resolveSchemaWithAnnotations: (schema: MaybeRefSchemaObject | undefined) => SchemaObject | undefined;
|
|
11
|
+
//# sourceMappingURL=resolve-schema-with-annotations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-schema-with-annotations.d.ts","sourceRoot":"","sources":["../../src/helpers/resolve-schema-with-annotations.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAA;AAC1E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAA;AAmBxE,iGAAiG;AACjG,eAAO,MAAM,oBAAoB,GAAI,QAAQ,YAAY,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CACK,CAAA;AAEvF;;;;GAIG;AACH,eAAO,MAAM,4BAA4B,GAAI,QAAQ,oBAAoB,GAAG,SAAS,KAAG,YAAY,GAAG,SAuCtG,CAAA"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { resolve } from '../resolve.js';
|
|
2
|
+
import { unpackProxyShallow } from './unpack-proxy.js';
|
|
3
|
+
const annotationKeys = new Set([
|
|
4
|
+
'title',
|
|
5
|
+
'description',
|
|
6
|
+
'default',
|
|
7
|
+
'examples',
|
|
8
|
+
'example',
|
|
9
|
+
'deprecated',
|
|
10
|
+
'readOnly',
|
|
11
|
+
'writeOnly',
|
|
12
|
+
'$comment',
|
|
13
|
+
'externalDocs',
|
|
14
|
+
// TypeBox marks schemas without an explicit type; this does not constrain their value.
|
|
15
|
+
'__scalar_',
|
|
16
|
+
]);
|
|
17
|
+
/** Extract annotation keywords without copying validation constraints into a form projection. */
|
|
18
|
+
export const getSchemaAnnotations = (schema) => Object.fromEntries(Object.entries(schema).filter(([key]) => annotationKeys.has(key)));
|
|
19
|
+
/**
|
|
20
|
+
* Expose the value schema inside an annotation-only allOf wrapper for form editors and serializers.
|
|
21
|
+
* Multiple value schemas retain their composition, since combining their constraints requires more
|
|
22
|
+
* than spreading their keywords. The returned view does not mutate the API description.
|
|
23
|
+
*/
|
|
24
|
+
export const resolveSchemaWithAnnotations = (schema) => {
|
|
25
|
+
const seen = new Set();
|
|
26
|
+
const visit = (input) => {
|
|
27
|
+
const resolved = resolve.schema(input);
|
|
28
|
+
if (!resolved?.allOf?.length || !input) {
|
|
29
|
+
return resolved;
|
|
30
|
+
}
|
|
31
|
+
if (Object.keys(resolved).some((key) => key !== 'allOf' && key !== '$ref' && !annotationKeys.has(key))) {
|
|
32
|
+
return resolved;
|
|
33
|
+
}
|
|
34
|
+
const identity = unpackProxyShallow(input);
|
|
35
|
+
if (seen.has(identity)) {
|
|
36
|
+
return resolved;
|
|
37
|
+
}
|
|
38
|
+
seen.add(identity);
|
|
39
|
+
const members = resolved.allOf.map((member) => resolve.schema(member));
|
|
40
|
+
if (members.some((member) => !member)) {
|
|
41
|
+
return resolved;
|
|
42
|
+
}
|
|
43
|
+
const valueMembers = members.filter((member) => member && Object.keys(member).some((key) => !annotationKeys.has(key)));
|
|
44
|
+
const valueMember = valueMembers[0];
|
|
45
|
+
if (valueMembers.length !== 1 || !valueMember) {
|
|
46
|
+
return resolved;
|
|
47
|
+
}
|
|
48
|
+
const valueIndex = members.indexOf(valueMember);
|
|
49
|
+
const valueSchema = visit(resolved.allOf[valueIndex]);
|
|
50
|
+
const annotations = Object.assign({}, ...members.filter((member) => member !== valueMember && member !== undefined).map(getSchemaAnnotations));
|
|
51
|
+
const { allOf: _allOf, ...siblings } = resolved;
|
|
52
|
+
const result = { ...valueSchema, ...annotations, ...siblings };
|
|
53
|
+
Reflect.deleteProperty(result, '__scalar_');
|
|
54
|
+
return result;
|
|
55
|
+
};
|
|
56
|
+
return visit(schema);
|
|
57
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type LoaderPlugin } from '@scalar/json-magic/bundle';
|
|
2
|
+
type SecurityUriOptions = {
|
|
3
|
+
origin?: string;
|
|
4
|
+
loaders: LoaderPlugin[];
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Makes URI requirements available to the existing name-based auth consumers.
|
|
8
|
+
* Aliases live only in the working document; export removes them and restores authored keys.
|
|
9
|
+
* Relative keys in referenced documents become absolute to keep distinct document bases apart.
|
|
10
|
+
*/
|
|
11
|
+
export declare const resolveSecurityRequirements: (document: Record<string, unknown>, { origin, loaders }: SecurityUriOptions) => Promise<void>;
|
|
12
|
+
/** Remove runtime URI aliases while keeping edited scopes and authored requirement spellings. */
|
|
13
|
+
export declare const restoreSecurityRequirements: (document: Record<string, unknown>) => void;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=resolve-security-requirements.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-security-requirements.d.ts","sourceRoot":"","sources":["../../src/helpers/resolve-security-requirements.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,YAAY,EAAgC,MAAM,2BAA2B,CAAA;AAa3F,KAAK,kBAAkB,GAAG;IACxB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,YAAY,EAAE,CAAA;CACxB,CAAA;AAUD;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,GACtC,UAAU,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,qBAA2B,kBAAkB,KAC5C,OAAO,CAAC,IAAI,CA4Id,CAAA;AAED,iGAAiG;AACjG,eAAO,MAAM,2BAA2B,GAAI,UAAU,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAG,IAsD/E,CAAA"}
|