@scalar/workspace-store 0.68.0 → 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 +17 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +8 -1
- package/dist/entities/auth/schema.d.ts +390 -0
- package/dist/entities/auth/schema.d.ts.map +1 -1
- package/dist/entities/auth/schema.js +12 -8
- package/dist/events/definitions/auth.d.ts +7 -0
- package/dist/events/definitions/auth.d.ts.map +1 -1
- package/dist/helpers/auth-secret-fields.d.ts +9 -0
- package/dist/helpers/auth-secret-fields.d.ts.map +1 -0
- package/dist/helpers/auth-secret-fields.js +42 -0
- 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/mutators/auth.d.ts +1 -0
- package/dist/mutators/auth.d.ts.map +1 -1
- package/dist/mutators/auth.js +29 -0
- package/dist/mutators/index.d.ts +2 -0
- package/dist/mutators/index.d.ts.map +1 -1
- 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/helpers/get-example-from-schema.d.ts +2 -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 +25 -4
- 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/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/security/extract-security-scheme-secrets.d.ts.map +1 -1
- package/dist/request-example/context/security/extract-security-scheme-secrets.js +33 -34
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +34 -7
- package/package.json +8 -8
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { isHttpMethod } from '@scalar/helpers/http/is-http-method';
|
|
2
|
+
import { isObject } from '@scalar/helpers/object/is-object';
|
|
3
|
+
import { isPollutionKey } from '@scalar/helpers/object/prevent-pollution';
|
|
4
|
+
import { isSchemaPath } from '@scalar/helpers/openapi/is-schema-path';
|
|
5
|
+
import { bundle, resolveReferencePath } from '@scalar/json-magic/bundle';
|
|
6
|
+
import { createMagicProxy } from '@scalar/json-magic/magic-proxy';
|
|
7
|
+
import { Value } from '@scalar/typebox/value';
|
|
8
|
+
import { generateUniqueValue } from '../helpers/generate-unique-value.js';
|
|
9
|
+
import { getResolvedRef } from '../helpers/get-resolved-ref.js';
|
|
10
|
+
import { normalizeAuthSchemes } from '../plugins/bundler/index.js';
|
|
11
|
+
import { resolveOpenApiDocument } from '../plugins/bundler/openapi-document.js';
|
|
12
|
+
import { SecuritySchemeObjectSchema } from '../schemas/v3.2/strict/openapi-document.js';
|
|
13
|
+
const ALIASES = 'x-scalar-security-uri-aliases';
|
|
14
|
+
const ORIGINAL_KEYS = 'x-scalar-original-security-keys';
|
|
15
|
+
/** Resolve the URI portion separately so filesystem origins do not interpret fragments as filenames. */
|
|
16
|
+
const absoluteReference = (reference, base) => {
|
|
17
|
+
const separator = reference.indexOf('#');
|
|
18
|
+
const resource = separator === -1 ? reference : reference.slice(0, separator);
|
|
19
|
+
const fragment = separator === -1 ? '' : reference.slice(separator);
|
|
20
|
+
return `${resource ? resolveReferencePath(base, resource) : base}${fragment}`;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Makes URI requirements available to the existing name-based auth consumers.
|
|
24
|
+
* Aliases live only in the working document; export removes them and restores authored keys.
|
|
25
|
+
* Relative keys in referenced documents become absolute to keep distinct document bases apart.
|
|
26
|
+
*/
|
|
27
|
+
export const resolveSecurityRequirements = async (document, { origin = '/', loaders }) => {
|
|
28
|
+
if (typeof document.openapi !== 'string' || !/^3\.2\.\d+$/.test(document.openapi))
|
|
29
|
+
return;
|
|
30
|
+
const originalKeys = isObject(document[ORIGINAL_KEYS]) ? document[ORIGINAL_KEYS] : {};
|
|
31
|
+
const components = isObject(document.components) ? document.components : {};
|
|
32
|
+
const schemes = isObject(components.securitySchemes) ? components.securitySchemes : {};
|
|
33
|
+
const metadata = isObject(document[ALIASES])
|
|
34
|
+
? document[ALIASES]
|
|
35
|
+
: {
|
|
36
|
+
hadComponents: isObject(document.components),
|
|
37
|
+
hadSecuritySchemes: isObject(components.securitySchemes),
|
|
38
|
+
schemes: {},
|
|
39
|
+
};
|
|
40
|
+
const aliases = isObject(metadata.schemes) ? metadata.schemes : {};
|
|
41
|
+
metadata.schemes = aliases;
|
|
42
|
+
const namedSchemes = new Set(Object.keys(schemes).filter((name) => !Object.hasOwn(aliases, name)));
|
|
43
|
+
const visited = new WeakSet();
|
|
44
|
+
const processedDocuments = new Set();
|
|
45
|
+
const cache = new Map();
|
|
46
|
+
const visit = async (node, path, base, external) => {
|
|
47
|
+
if (node === null || typeof node !== 'object' || visited.has(node) || isSchemaPath(path))
|
|
48
|
+
return;
|
|
49
|
+
visited.add(node);
|
|
50
|
+
// Security is a fixed field on document and operation objects, not arbitrary example payloads.
|
|
51
|
+
const operationKey = path.at(-1) ?? '';
|
|
52
|
+
const isOperation = isHttpMethod(operationKey) || path.at(-2) === 'additionalOperations';
|
|
53
|
+
const isDocument = path.length === 0 || (path[0] === 'x-ext' && path.length === 2);
|
|
54
|
+
if (isObject(node) && (isDocument || isOperation) && Array.isArray(node.security)) {
|
|
55
|
+
for (const [index, requirement] of node.security.entries()) {
|
|
56
|
+
if (!isObject(requirement))
|
|
57
|
+
continue;
|
|
58
|
+
for (const [name, scopes] of Object.entries(requirement)) {
|
|
59
|
+
if (namedSchemes.has(name) || !Array.isArray(scopes))
|
|
60
|
+
continue;
|
|
61
|
+
const uri = (() => {
|
|
62
|
+
try {
|
|
63
|
+
return Object.hasOwn(aliases, name) && typeof aliases[name] === 'string'
|
|
64
|
+
? aliases[name]
|
|
65
|
+
: absoluteReference(name, base);
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
})();
|
|
71
|
+
if (uri === undefined)
|
|
72
|
+
continue;
|
|
73
|
+
const key = await generateUniqueValue({
|
|
74
|
+
defaultValue: external ? uri : name,
|
|
75
|
+
validation: (candidate) => !namedSchemes.has(candidate) &&
|
|
76
|
+
(!Object.hasOwn(aliases, candidate) || aliases[candidate] === uri) &&
|
|
77
|
+
(!external || candidate === name || !Object.hasOwn(requirement, candidate)),
|
|
78
|
+
maxRetries: Object.keys(schemes).length + 1,
|
|
79
|
+
});
|
|
80
|
+
if (key === undefined)
|
|
81
|
+
continue;
|
|
82
|
+
if (!Object.hasOwn(aliases, key)) {
|
|
83
|
+
const reference = { $ref: uri };
|
|
84
|
+
await bundle({ components: { securitySchemes: { target: reference } } }, {
|
|
85
|
+
root: document,
|
|
86
|
+
origin,
|
|
87
|
+
treeShake: false,
|
|
88
|
+
urlMap: true,
|
|
89
|
+
cache,
|
|
90
|
+
plugins: [...loaders, normalizeAuthSchemes()],
|
|
91
|
+
hooks: { resolveDocument: resolveOpenApiDocument },
|
|
92
|
+
});
|
|
93
|
+
// Validate the target before exposing an auth option; missing pointers and non-schemes
|
|
94
|
+
// keep their original requirement and never acquire a misleading working alias.
|
|
95
|
+
const proxy = createMagicProxy({ ...document, 'x-scalar-security-uri-target': reference }, {
|
|
96
|
+
documentUri: resolveOpenApiDocument(document, origin)?.baseUri,
|
|
97
|
+
});
|
|
98
|
+
const target = getResolvedRef(proxy['x-scalar-security-uri-target']);
|
|
99
|
+
// The strict runtime schema requires refreshUrl, while authored OAuth flows may omit it.
|
|
100
|
+
const validationTarget = isObject(target) && target.type === 'oauth2' && isObject(target.flows)
|
|
101
|
+
? {
|
|
102
|
+
...target,
|
|
103
|
+
flows: Object.fromEntries(Object.entries(target.flows).map(([flow, value]) => [
|
|
104
|
+
flow,
|
|
105
|
+
isObject(value) ? { refreshUrl: '', ...value } : value,
|
|
106
|
+
])),
|
|
107
|
+
}
|
|
108
|
+
: target;
|
|
109
|
+
if (!Value.Check(SecuritySchemeObjectSchema, validationTarget))
|
|
110
|
+
continue;
|
|
111
|
+
Object.defineProperty(schemes, key, {
|
|
112
|
+
value: reference,
|
|
113
|
+
enumerable: true,
|
|
114
|
+
writable: true,
|
|
115
|
+
configurable: true,
|
|
116
|
+
});
|
|
117
|
+
Object.defineProperty(aliases, key, { value: uri, enumerable: true, writable: true, configurable: true });
|
|
118
|
+
components.securitySchemes = schemes;
|
|
119
|
+
document.components = components;
|
|
120
|
+
document[ALIASES] = metadata;
|
|
121
|
+
}
|
|
122
|
+
if (external) {
|
|
123
|
+
const location = JSON.stringify([...path, 'security', String(index)]);
|
|
124
|
+
const mapping = isObject(originalKeys[location]) ? originalKeys[location] : {};
|
|
125
|
+
Object.defineProperty(mapping, name, { value: key, enumerable: true, writable: true, configurable: true });
|
|
126
|
+
originalKeys[location] = mapping;
|
|
127
|
+
document[ORIGINAL_KEYS] = originalKeys;
|
|
128
|
+
if (key === name)
|
|
129
|
+
continue;
|
|
130
|
+
const previous = Object.hasOwn(requirement, key) ? requirement[key] : [];
|
|
131
|
+
Object.defineProperty(requirement, key, {
|
|
132
|
+
value: [...new Set([...(Array.isArray(previous) ? previous : []), ...scopes])],
|
|
133
|
+
enumerable: true,
|
|
134
|
+
writable: true,
|
|
135
|
+
configurable: true,
|
|
136
|
+
});
|
|
137
|
+
delete requirement[name];
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
for (const [key, child] of Object.entries(node)) {
|
|
143
|
+
if (key.startsWith('x-') || key === 'example' || key === 'examples' || key === 'security')
|
|
144
|
+
continue;
|
|
145
|
+
await visit(child, [...path, key], base, external);
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
const entryBase = resolveOpenApiDocument(document, origin)?.baseUri ?? origin;
|
|
149
|
+
await visit(document, [], entryBase, false);
|
|
150
|
+
// URI-only dependencies can load further documents, so process newly embedded documents too.
|
|
151
|
+
while (isObject(document['x-ext'])) {
|
|
152
|
+
const next = Object.entries(document['x-ext']).find(([key]) => !processedDocuments.has(key));
|
|
153
|
+
if (!next)
|
|
154
|
+
break;
|
|
155
|
+
const [key, external] = next;
|
|
156
|
+
processedDocuments.add(key);
|
|
157
|
+
if (!isObject(external))
|
|
158
|
+
continue;
|
|
159
|
+
if (typeof external.openapi === 'string' && !/^3\.2\.\d+$/.test(external.openapi))
|
|
160
|
+
continue;
|
|
161
|
+
const mappings = document['x-ext-urls'];
|
|
162
|
+
const retrieval = isObject(mappings) && typeof mappings[key] === 'string' ? mappings[key] : key;
|
|
163
|
+
const retrievalUri = resolveReferencePath(entryBase, retrieval);
|
|
164
|
+
await visit(external, ['x-ext', key], resolveOpenApiDocument(external, retrievalUri)?.baseUri ?? retrievalUri, true);
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
/** Remove runtime URI aliases while keeping edited scopes and authored requirement spellings. */
|
|
168
|
+
export const restoreSecurityRequirements = (document) => {
|
|
169
|
+
const originalKeys = Object.hasOwn(document, ORIGINAL_KEYS) ? document[ORIGINAL_KEYS] : undefined;
|
|
170
|
+
if (isObject(originalKeys)) {
|
|
171
|
+
for (const [location, mapping] of Object.entries(originalKeys)) {
|
|
172
|
+
const path = (() => {
|
|
173
|
+
try {
|
|
174
|
+
return JSON.parse(location);
|
|
175
|
+
}
|
|
176
|
+
catch {
|
|
177
|
+
return undefined;
|
|
178
|
+
}
|
|
179
|
+
})();
|
|
180
|
+
if (!Array.isArray(path) ||
|
|
181
|
+
!path.every((segment) => typeof segment === 'string' && !isPollutionKey(segment)) ||
|
|
182
|
+
!isObject(mapping))
|
|
183
|
+
continue;
|
|
184
|
+
const requirement = path.reduce((parent, segment) => {
|
|
185
|
+
if (parent === null || typeof parent !== 'object' || !Object.hasOwn(parent, segment))
|
|
186
|
+
return undefined;
|
|
187
|
+
return Reflect.get(parent, segment);
|
|
188
|
+
}, document);
|
|
189
|
+
if (!isObject(requirement))
|
|
190
|
+
continue;
|
|
191
|
+
const entries = Object.entries(mapping).flatMap(([original, rewritten]) => typeof rewritten === 'string' && Object.hasOwn(requirement, rewritten)
|
|
192
|
+
? [{ original, rewritten, scopes: requirement[rewritten] }]
|
|
193
|
+
: []);
|
|
194
|
+
for (const { rewritten } of entries)
|
|
195
|
+
delete requirement[rewritten];
|
|
196
|
+
for (const { original, scopes } of entries) {
|
|
197
|
+
Object.defineProperty(requirement, original, {
|
|
198
|
+
value: scopes,
|
|
199
|
+
enumerable: true,
|
|
200
|
+
writable: true,
|
|
201
|
+
configurable: true,
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
const metadata = Object.hasOwn(document, ALIASES) ? document[ALIASES] : undefined;
|
|
207
|
+
const components = Object.hasOwn(document, 'components') ? document.components : undefined;
|
|
208
|
+
if (isObject(metadata) &&
|
|
209
|
+
isObject(metadata.schemes) &&
|
|
210
|
+
isObject(components) &&
|
|
211
|
+
Object.hasOwn(components, 'securitySchemes') &&
|
|
212
|
+
isObject(components.securitySchemes)) {
|
|
213
|
+
for (const key of Object.keys(metadata.schemes))
|
|
214
|
+
delete components.securitySchemes[key];
|
|
215
|
+
if (!metadata.hadSecuritySchemes && Object.keys(components.securitySchemes).length === 0)
|
|
216
|
+
delete components.securitySchemes;
|
|
217
|
+
if (!metadata.hadComponents && Object.keys(components).length === 0)
|
|
218
|
+
delete document.components;
|
|
219
|
+
}
|
|
220
|
+
delete document[ALIASES];
|
|
221
|
+
delete document[ORIGINAL_KEYS];
|
|
222
|
+
};
|
package/dist/mutators/auth.d.ts
CHANGED
|
@@ -157,6 +157,7 @@ export declare const authMutatorsFactory: ({ document, store, }: {
|
|
|
157
157
|
clearSelectedSecuritySchemes: (payload: AuthEvents["auth:clear:selected-security-schemes"]) => void;
|
|
158
158
|
updateSecurityScheme: (payload: AuthEvents["auth:update:security-scheme"]) => SecuritySchemeObject | undefined;
|
|
159
159
|
updateSecuritySchemeSecrets: (payload: AuthEvents["auth:update:security-scheme-secrets"]) => void;
|
|
160
|
+
resetSecuritySchemeSecret: (payload: AuthEvents["auth:reset:security-scheme-secret"]) => void;
|
|
160
161
|
clearSecuritySchemeSecrets: (payload: AuthEvents["auth:clear:security-scheme-secrets"]) => void;
|
|
161
162
|
updateSelectedAuthTab: (payload: AuthEvents["auth:update:active-index"]) => void;
|
|
162
163
|
updateSelectedScopes: (payload: AuthEvents["auth:update:selected-scopes"]) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/mutators/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/mutators/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AAU3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAGlD,OAAO,KAAK,EAAgB,oBAAoB,EAAE,MAAM,uCAAuC,CAAA;AAuC/F;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,6BAA6B,GACxC,OAAO,cAAc,GAAG,IAAI,EAC5B,UAAU,iBAAiB,GAAG,IAAI,EAClC,4CAA4C,UAAU,CAAC,uCAAuC,CAAC,kBAgFhG,CAAA;AAwBD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,oBAAoB,GAC/B,UAAU,iBAAiB,GAAG,IAAI,EAClC,mBAAmB,UAAU,CAAC,6BAA6B,CAAC,qCAwB7D,CAAA;AAqED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,qBAAqB,GAChC,OAAO,cAAc,GAAG,IAAI,EAC5B,UAAU,iBAAiB,GAAG,IAAI,EAClC,iBAAiB,UAAU,CAAC,0BAA0B,CAAC,SAgDxD,CAAA;AAaD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,eAAO,MAAM,oBAAoB,GAC/B,OAAO,cAAc,GAAG,IAAI,EAC5B,UAAU,iBAAiB,GAAG,IAAI,EAClC,6CAA6C,UAAU,CAAC,6BAA6B,CAAC,SA0EvF,CAAA;AAqED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,WAAW,GACtB,OAAO,cAAc,GAAG,IAAI,EAC5B,UAAU,iBAAiB,GAAG,IAAI,EAClC,0DAA0D,UAAU,CAAC,oBAAoB,CAAC,SA2D3F,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,WAAW,GACtB,OAAO,cAAc,GAAG,IAAI,EAC5B,UAAU,iBAAiB,GAAG,IAAI,EAClC,2BAA2B,UAAU,CAAC,oBAAoB,CAAC,SAwB5D,CAAA;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,oBAAoB,GAC/B,OAAO,cAAc,GAAG,IAAI,EAC5B,UAAU,iBAAiB,GAAG,IAAI,EAClC,WAAW,UAAU,CAAC,6BAA6B,CAAC,SAoFrD,CAAA;AAED,eAAO,MAAM,mBAAmB,GAAI,sBAGjC;IACD,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAAA;IAClC,KAAK,EAAE,cAAc,GAAG,IAAI,CAAA;CAC7B;6CAE4C,UAAU,CAAC,uCAAuC,CAAC;4CAEpD,UAAU,CAAC,sCAAsC,CAAC;oCAE1D,UAAU,CAAC,6BAA6B,CAAC;2CAElC,UAAU,CAAC,qCAAqC,CAAC;yCAEnD,UAAU,CAAC,mCAAmC,CAAC;0CAE9C,UAAU,CAAC,oCAAoC,CAAC;qCAErD,UAAU,CAAC,0BAA0B,CAAC;oCAEvC,UAAU,CAAC,6BAA6B,CAAC;2BAElD,UAAU,CAAC,oBAAoB,CAAC;2BAChC,UAAU,CAAC,oBAAoB,CAAC;oCACvB,UAAU,CAAC,6BAA6B,CAAC;CAG5E,CAAA"}
|
package/dist/mutators/auth.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { resetSecretField, updateClearedSecretFields } from '../helpers/auth-secret-fields.js';
|
|
2
|
+
import { deepClone } from '../helpers/deep-clone.js';
|
|
1
3
|
import { forEachPathItemOperation, getPathItemOperation } from '../helpers/for-each-path-item-operation.js';
|
|
2
4
|
import { generateUniqueValue } from '../helpers/generate-unique-value.js';
|
|
3
5
|
import { getResolvedRef } from '../helpers/get-resolved-ref.js';
|
|
@@ -197,8 +199,34 @@ const updateSecuritySchemeSecrets = (store, document, { payload, name, overwrite
|
|
|
197
199
|
? unpackProxyObject(auth, { depth: 1 })
|
|
198
200
|
: { ...payload };
|
|
199
201
|
mergeObjects(result, payload);
|
|
202
|
+
updateClearedSecretFields(result, payload);
|
|
200
203
|
store?.auth.setAuthSecrets(documentName, name, result);
|
|
201
204
|
};
|
|
205
|
+
const resetSecuritySchemeSecret = (store, document, { name, flow, field }) => {
|
|
206
|
+
const documentName = getAuthDocumentName(document);
|
|
207
|
+
if (!documentName || !store) {
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
const auth = store.auth.getAuthSecrets(documentName, name);
|
|
211
|
+
if (!auth) {
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
const secrets = deepClone(auth);
|
|
215
|
+
if (flow) {
|
|
216
|
+
if (secrets.type !== 'oauth2' && secrets.type !== 'openIdConnect') {
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
const flowSecrets = secrets[flow];
|
|
220
|
+
if (!flowSecrets) {
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
resetSecretField(flowSecrets, field);
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
resetSecretField(secrets, field);
|
|
227
|
+
}
|
|
228
|
+
store.auth.setAuthSecrets(documentName, name, secrets);
|
|
229
|
+
};
|
|
202
230
|
const clearSecuritySchemeSecrets = (store, document, { name }) => {
|
|
203
231
|
const documentName = getAuthDocumentName(document);
|
|
204
232
|
if (!documentName) {
|
|
@@ -590,6 +618,7 @@ export const authMutatorsFactory = ({ document, store, }) => {
|
|
|
590
618
|
clearSelectedSecuritySchemes: (payload) => clearSelectedSecuritySchemes(store, document, payload),
|
|
591
619
|
updateSecurityScheme: (payload) => updateSecurityScheme(document, payload),
|
|
592
620
|
updateSecuritySchemeSecrets: (payload) => updateSecuritySchemeSecrets(store, document, payload),
|
|
621
|
+
resetSecuritySchemeSecret: (payload) => resetSecuritySchemeSecret(store, document, payload),
|
|
593
622
|
clearSecuritySchemeSecrets: (payload) => clearSecuritySchemeSecrets(store, document, payload),
|
|
594
623
|
updateSelectedAuthTab: (payload) => updateSelectedAuthTab(store, document, payload),
|
|
595
624
|
updateSelectedScopes: (payload) => updateSelectedScopes(store, document, payload),
|
package/dist/mutators/index.d.ts
CHANGED
|
@@ -68,6 +68,7 @@ export declare function generateClientMutators(store: WorkspaceStore | null): {
|
|
|
68
68
|
clearSelectedSecuritySchemes: (payload: import("../events/definitions/auth.js").AuthEvents["auth:clear:selected-security-schemes"]) => void;
|
|
69
69
|
updateSecurityScheme: (payload: import("../events/definitions/auth.js").AuthEvents["auth:update:security-scheme"]) => import("../schemas/v3.2/strict/security-scheme.js").SecuritySchemeObject | undefined;
|
|
70
70
|
updateSecuritySchemeSecrets: (payload: import("../events/definitions/auth.js").AuthEvents["auth:update:security-scheme-secrets"]) => void;
|
|
71
|
+
resetSecuritySchemeSecret: (payload: import("../events/definitions/auth.js").AuthEvents["auth:reset:security-scheme-secret"]) => void;
|
|
71
72
|
clearSecuritySchemeSecrets: (payload: import("../events/definitions/auth.js").AuthEvents["auth:clear:security-scheme-secrets"]) => void;
|
|
72
73
|
updateSelectedAuthTab: (payload: import("../events/definitions/auth.js").AuthEvents["auth:update:active-index"]) => void;
|
|
73
74
|
updateSelectedScopes: (payload: import("../events/definitions/auth.js").AuthEvents["auth:update:selected-scopes"]) => void;
|
|
@@ -159,6 +160,7 @@ export declare function generateClientMutators(store: WorkspaceStore | null): {
|
|
|
159
160
|
clearSelectedSecuritySchemes: (payload: import("../events/definitions/auth.js").AuthEvents["auth:clear:selected-security-schemes"]) => void;
|
|
160
161
|
updateSecurityScheme: (payload: import("../events/definitions/auth.js").AuthEvents["auth:update:security-scheme"]) => import("../schemas/v3.2/strict/security-scheme.js").SecuritySchemeObject | undefined;
|
|
161
162
|
updateSecuritySchemeSecrets: (payload: import("../events/definitions/auth.js").AuthEvents["auth:update:security-scheme-secrets"]) => void;
|
|
163
|
+
resetSecuritySchemeSecret: (payload: import("../events/definitions/auth.js").AuthEvents["auth:reset:security-scheme-secret"]) => void;
|
|
162
164
|
clearSecuritySchemeSecrets: (payload: import("../events/definitions/auth.js").AuthEvents["auth:clear:security-scheme-secrets"]) => void;
|
|
163
165
|
updateSelectedAuthTab: (payload: import("../events/definitions/auth.js").AuthEvents["auth:update:active-index"]) => void;
|
|
164
166
|
updateSelectedScopes: (payload: import("../events/definitions/auth.js").AuthEvents["auth:update:selected-scopes"]) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mutators/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAa9C;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI;IAqC/D;;OAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAEH;;;OAGG
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mutators/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAa9C;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI;IAqC/D;;OAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAEH;;;OAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAEH;;;;OAIG;gBACS,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAErB"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { TagsMap } from '../../navigation/types.js';
|
|
2
|
+
import type { OpenApiDocument } from '../../schemas/v3.2/strict/openapi-document.js';
|
|
3
|
+
/** Label tags must not create operation groups, but undeclared tags still do. */
|
|
4
|
+
export declare const getNavigationTagNames: (document: OpenApiDocument, names: string[] | undefined, tagsMap: TagsMap) => string[];
|
|
5
|
+
//# sourceMappingURL=get-navigation-tag-names.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-navigation-tag-names.d.ts","sourceRoot":"","sources":["../../../src/navigation/helpers/get-navigation-tag-names.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAA;AAE7E,iFAAiF;AACjF,eAAO,MAAM,qBAAqB,GAChC,UAAU,eAAe,EACzB,OAAO,MAAM,EAAE,GAAG,SAAS,EAC3B,SAAS,OAAO,KACf,MAAM,EAA2F,CAAA"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { getTagKind } from '../../helpers/get-tag-kind.js';
|
|
2
|
+
/** Label tags must not create operation groups, but undeclared tags still do. */
|
|
3
|
+
export const getNavigationTagNames = (document, names, tagsMap) => names?.filter((name) => getTagKind(document, tagsMap.get(name)?.tag) === 'nav') ?? [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"traverse-paths.d.ts","sourceRoot":"","sources":["../../../src/navigation/helpers/traverse-paths.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,oBAAoB,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAE5F,OAAO,KAAK,EAA+B,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAC3F,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAA;
|
|
1
|
+
{"version":3,"file":"traverse-paths.d.ts","sourceRoot":"","sources":["../../../src/navigation/helpers/traverse-paths.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,oBAAoB,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAE5F,OAAO,KAAK,EAA+B,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAC3F,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAA;AAK9F,eAAO,MAAM,qBAAqB,GAAI,WAAW,eAAe,YAE/D,CAAA;AAsED;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,aAAa,GAAI,sEAM3B;IACD,QAAQ,EAAE,eAAe,CAAA;IACzB,oCAAoC;IACpC,OAAO,EAAE,OAAO,CAAA;IAChB,0DAA0D;IAC1D,UAAU,EAAE,mBAAmB,CAAC,YAAY,CAAC,CAAA;IAC7C,kBAAkB;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,oFAAoF;IACpF,oBAAoB,CAAC,EAAE,oBAAoB,CAAA;CAC5C,KAAG;IAAE,kBAAkB,EAAE,kBAAkB,EAAE,CAAA;CA2D7C,CAAA"}
|
|
@@ -4,6 +4,7 @@ import { getResolvedRef, mergeSiblingReferences } from '../../helpers/get-resolv
|
|
|
4
4
|
import { isHidden } from '../../helpers/is-hidden.js';
|
|
5
5
|
import { traverseOperationExamples } from '../../navigation/helpers/traverse-examples.js';
|
|
6
6
|
import { XScalarStabilityValues } from '../../schemas/extensions/operation/index.js';
|
|
7
|
+
import { getNavigationTagNames } from './get-navigation-tag-names.js';
|
|
7
8
|
import { getTag } from './get-tag.js';
|
|
8
9
|
export const isDeprecatedOperation = (operation) => {
|
|
9
10
|
return operation.deprecated || operation['x-scalar-stability'] === XScalarStabilityValues.Deprecated;
|
|
@@ -85,8 +86,9 @@ export const traversePaths = ({ document, tagsMap, generateId, documentId, opera
|
|
|
85
86
|
}
|
|
86
87
|
const ref = `#/paths/${escapeJsonPointer(path)}/${getPathItemOperationKey(method)}`;
|
|
87
88
|
// Traverse tags
|
|
88
|
-
|
|
89
|
-
|
|
89
|
+
const navigationTags = getNavigationTagNames(document, operation.tags, tagsMap);
|
|
90
|
+
if (navigationTags.length) {
|
|
91
|
+
navigationTags.forEach((tagName) => {
|
|
90
92
|
const { tag, id: tagId } = getTag({
|
|
91
93
|
tagsMap,
|
|
92
94
|
name: tagName,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"traverse-schemas.d.ts","sourceRoot":"","sources":["../../../src/navigation/helpers/traverse-schemas.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"traverse-schemas.d.ts","sourceRoot":"","sources":["../../../src/navigation/helpers/traverse-schemas.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AACtE,OAAO,KAAK,EAAa,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtE,OAAO,KAAK,EAAE,eAAe,EAAgB,MAAM,wCAAwC,CAAA;AA2C3F;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,GAAI,gDAK7B;IACD,QAAQ,EAAE,eAAe,CAAA;IACzB,wCAAwC;IACxC,OAAO,EAAE,OAAO,CAAA;IAChB,UAAU,EAAE,mBAAmB,CAAC,YAAY,CAAC,CAAA;IAC7C,UAAU,EAAE,MAAM,CAAA;CACnB,KAAG,eAAe,EAmDlB,CAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getResolvedRef, mergeSiblingReferences } from '../../helpers/get-resolved-ref.js';
|
|
2
2
|
import { isHidden } from '../../helpers/is-hidden.js';
|
|
3
|
+
import { getNavigationTagNames } from '../../navigation/helpers/get-navigation-tag-names.js';
|
|
3
4
|
import { getTag } from '../../navigation/helpers/get-tag.js';
|
|
4
5
|
/** Creates a traversed schema entry from an OpenAPI schema object.
|
|
5
6
|
*
|
|
@@ -46,8 +47,9 @@ export const traverseSchemas = ({ document, tagsMap, generateId, documentId, })
|
|
|
46
47
|
}
|
|
47
48
|
const ref = `#/components/schemas/${name}`;
|
|
48
49
|
// Add to tags
|
|
49
|
-
|
|
50
|
-
|
|
50
|
+
const navigationTags = getNavigationTagNames(document, schema?.['x-tags'], tagsMap);
|
|
51
|
+
if (navigationTags.length) {
|
|
52
|
+
navigationTags.forEach((tagName) => {
|
|
51
53
|
const { tag, id: tagId } = getTag({ tagsMap, name: tagName, documentId, generateId });
|
|
52
54
|
tagsMap.get(tagName)?.entries.push(createSchemaEntry({
|
|
53
55
|
ref,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"traverse-tags.d.ts","sourceRoot":"","sources":["../../../src/navigation/helpers/traverse-tags.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"traverse-tags.d.ts","sourceRoot":"","sources":["../../../src/navigation/helpers/traverse-tags.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AACtE,OAAO,KAAK,EAAE,cAAc,EAAgB,MAAM,sBAAsB,CAAA;AACxE,OAAO,KAAK,EAAE,eAAe,EAAa,MAAM,wCAAwC,CAAA;AAIxF,KAAK,OAAO,GAAG,IAAI,CAAC,mBAAmB,EAAE,YAAY,GAAG,kBAAkB,GAAG,YAAY,CAAC,CAAA;AAmS1F;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,GAAI,2FAK1B;IACD,QAAQ,EAAE,eAAe,CAAA;IACzB,oCAAoC;IACpC,OAAO,EAAE,OAAO,CAAA;IAChB,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,OAAO,CAAA;CACjB,KAAG,cAAc,EAuEjB,CAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { sortByOrder } from '@scalar/helpers/array/sort-by-order';
|
|
2
|
+
import { getTagKind } from '../../helpers/get-tag-kind.js';
|
|
2
3
|
import { isHidden } from '../../helpers/is-hidden.js';
|
|
3
4
|
import { unpackProxyObject } from '../../helpers/unpack-proxy.js';
|
|
4
5
|
import { getXKeysFromObject } from '../../navigation/helpers/get-x-keys.js';
|
|
@@ -57,7 +58,7 @@ const createTagEntry = ({ tag, generateId, children, isGroup = false, isTagGroup
|
|
|
57
58
|
* @returns Array of processed and sorted tag entries
|
|
58
59
|
*/
|
|
59
60
|
/** Sorts tags and returns entries */
|
|
60
|
-
const getSortedTagEntries = ({ _keys, tagsMap, options: { tagsSorter, operationsSorter, generateId }, documentId, sortOrder, }) => {
|
|
61
|
+
const getSortedTagEntries = ({ _keys, document, tagsMap, options: { tagsSorter, operationsSorter, generateId }, documentId, sortOrder, }) => {
|
|
61
62
|
/**
|
|
62
63
|
* Process each tag and its entries:
|
|
63
64
|
* - Skip internal and ignored tags
|
|
@@ -67,7 +68,7 @@ const getSortedTagEntries = ({ _keys, tagsMap, options: { tagsSorter, operations
|
|
|
67
68
|
const entries = _keys.flatMap((key) => {
|
|
68
69
|
const { tag, entries } = getTag({ tagsMap, name: key, documentId, generateId });
|
|
69
70
|
// Skip if the tag is internal or scalar-ignore
|
|
70
|
-
if (isHidden(tag)) {
|
|
71
|
+
if (isHidden(tag) || getTagKind(document, tag) !== 'nav') {
|
|
71
72
|
return [];
|
|
72
73
|
}
|
|
73
74
|
const sortOrder = tag['x-scalar-order'];
|
|
@@ -167,7 +168,7 @@ const nestTagsByParent = ({ flatEntries, document, originalOrders, }) => {
|
|
|
167
168
|
hadOwnOperations.set(entry.name, (entry.children?.length ?? 0) > 0);
|
|
168
169
|
}
|
|
169
170
|
}
|
|
170
|
-
const parentOf = getParentMap(document.tags ?? []);
|
|
171
|
+
const parentOf = getParentMap((document.tags ?? []).filter((tag) => getTagKind(document, tag) === 'nav'));
|
|
171
172
|
// Re-parent entries by reference, tracking which ones leave the top level.
|
|
172
173
|
const nested = new Set();
|
|
173
174
|
const gainedNestedTags = new Set();
|
|
@@ -232,7 +233,7 @@ export const traverseTags = ({ document, tagsMap, documentId, options: { generat
|
|
|
232
233
|
// Native OpenAPI 3.2 tag nesting via `parent` takes precedence over x-tagGroups, but only
|
|
233
234
|
// when at least one `parent` resolves to another declared tag outside a circular reference.
|
|
234
235
|
// A stray or misspelled `parent` value must not disable the legacy `x-tagGroups` handling.
|
|
235
|
-
const parentOf = getParentMap(document.tags ?? []);
|
|
236
|
+
const parentOf = getParentMap((document.tags ?? []).filter((tag) => getTagKind(document, tag) === 'nav'));
|
|
236
237
|
const hasNestedTags = Array.from(parentOf.keys()).some((name) => !isCyclic(parentOf, name));
|
|
237
238
|
if (hasNestedTags) {
|
|
238
239
|
// The flat traversal rewrites tag-level `x-scalar-order`, so capture the original values
|
|
@@ -244,6 +245,7 @@ export const traverseTags = ({ document, tagsMap, documentId, options: { generat
|
|
|
244
245
|
}
|
|
245
246
|
}
|
|
246
247
|
const flatEntries = getSortedTagEntries({
|
|
248
|
+
document,
|
|
247
249
|
_keys: Array.from(tagsMap.keys()),
|
|
248
250
|
tagsMap,
|
|
249
251
|
options: { generateId, tagsSorter, operationsSorter },
|
|
@@ -257,6 +259,7 @@ export const traverseTags = ({ document, tagsMap, documentId, options: { generat
|
|
|
257
259
|
const tagGroups = document['x-tagGroups'];
|
|
258
260
|
return tagGroups.flatMap((tagGroup) => {
|
|
259
261
|
const entries = getSortedTagEntries({
|
|
262
|
+
document,
|
|
260
263
|
_keys: tagGroup.tags,
|
|
261
264
|
tagsMap,
|
|
262
265
|
options: { tagsSorter, operationsSorter, generateId },
|
|
@@ -280,6 +283,7 @@ export const traverseTags = ({ document, tagsMap, documentId, options: { generat
|
|
|
280
283
|
// Ungrouped regular tags
|
|
281
284
|
const keys = Array.from(tagsMap.keys());
|
|
282
285
|
const tags = getSortedTagEntries({
|
|
286
|
+
document,
|
|
283
287
|
_keys: keys,
|
|
284
288
|
tagsMap,
|
|
285
289
|
options: { generateId, tagsSorter, operationsSorter },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"traverse-webhooks.d.ts","sourceRoot":"","sources":["../../../src/navigation/helpers/traverse-webhooks.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AACtE,OAAO,KAAK,EAAa,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AACvE,OAAO,KAAK,EAAE,eAAe,EAA8B,MAAM,wCAAwC,CAAA;
|
|
1
|
+
{"version":3,"file":"traverse-webhooks.d.ts","sourceRoot":"","sources":["../../../src/navigation/helpers/traverse-webhooks.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AACtE,OAAO,KAAK,EAAa,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AACvE,OAAO,KAAK,EAAE,eAAe,EAA8B,MAAM,wCAAwC,CAAA;AA4DzG;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,gBAAgB,GAAI,0EAM9B;IACD,uBAAuB;IACvB,QAAQ,EAAE,eAAe,CAAA;IACzB,6CAA6C;IAC7C,OAAO,EAAE,OAAO,CAAA;IAChB,UAAU,EAAE,mBAAmB,CAAC,YAAY,CAAC,CAAA;IAC7C,wBAAwB,EAAE,MAAM,CAAA;IAChC,UAAU,EAAE,MAAM,CAAA;CACnB,KAAG,gBAAgB,EAwDnB,CAAA"}
|
|
@@ -2,6 +2,7 @@ import { forEachPathItemOperation, getPathItemOperationKey } from '../../helpers
|
|
|
2
2
|
import { getResolvedRef, mergeSiblingReferences } from '../../helpers/get-resolved-ref.js';
|
|
3
3
|
import { isHidden } from '../../helpers/is-hidden.js';
|
|
4
4
|
import { isDeprecatedOperation } from '../../navigation/helpers/traverse-paths.js';
|
|
5
|
+
import { getNavigationTagNames } from './get-navigation-tag-names.js';
|
|
5
6
|
import { getTag } from './get-tag.js';
|
|
6
7
|
/** Creates a traversed webhook entry from an OpenAPI webhook object.
|
|
7
8
|
*
|
|
@@ -63,8 +64,9 @@ export const traverseWebhooks = ({ document, tagsMap, generateId, untaggedWebhoo
|
|
|
63
64
|
return;
|
|
64
65
|
}
|
|
65
66
|
const ref = `#/webhooks/${name}/${getPathItemOperationKey(method)}`;
|
|
66
|
-
|
|
67
|
-
|
|
67
|
+
const navigationTags = getNavigationTagNames(document, operation.tags, tagsMap);
|
|
68
|
+
if (navigationTags.length) {
|
|
69
|
+
navigationTags.forEach((tagName) => {
|
|
68
70
|
const { tag, id: tagId } = getTag({ tagsMap, name: tagName, documentId, generateId });
|
|
69
71
|
tagsMap.get(tagName)?.entries.push(createWebhookEntry({
|
|
70
72
|
ref,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-request-body.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/body/build-request-body.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"build-request-body.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/body/build-request-body.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0DAA0D,CAAA;AAMjG,OAAO,EACL,KAAK,aAAa,EAKnB,MAAM,mBAAmB,CAAA;AAO1B,KAAK,QAAQ,GAAG;IACd,IAAI,EAAE,UAAU,CAAA;IAChB,KAAK,EAAE,CACH;QACE,IAAI,EAAE,MAAM,CAAA;QACZ,GAAG,EAAE,MAAM,CAAA;QACX,KAAK,EAAE,MAAM,CAAA;QACb,WAAW,CAAC,EAAE,MAAM,CAAA;KACrB,GACD;QACE,IAAI,EAAE,MAAM,CAAA;QACZ,GAAG,EAAE,MAAM,CAAA;QACX,KAAK,EAAE,IAAI,CAAA;QACX,WAAW,CAAC,EAAE,MAAM,CAAA;KACrB,GACD;QACE,IAAI,EAAE,MAAM,CAAA;QACZ,GAAG,EAAE,MAAM,CAAA;QACX,KAAK,EAAE,IAAI,CAAA;QACX,WAAW,CAAC,EAAE,MAAM,CAAA;KACrB,CACJ,EAAE,CAAA;CACJ,CAAA;AAwBD,KAAK,UAAU,GAAG;IAChB,IAAI,EAAE,YAAY,CAAA;IAClB,KAAK,EAAE;QACL,GAAG,EAAE,MAAM,CAAA;QACX,KAAK,EAAE,MAAM,CAAA;KACd,EAAE,CAAA;CACJ,CAAA;AAED,KAAK,GAAG,GAAG;IACT,IAAI,EAAE,KAAK,CAAA;IACX,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAAA;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,MAAM,MAAM,WAAW,GACnB,QAAQ,GACR,UAAU,GACV,GAAG,GACH;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,aAAa,EAAE,CAAA;CAAE,CAAA;AA2CtE;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAC3B,aAAa,iBAAiB,GAAG,SAAS;AAC1C,qCAAqC;AACrC,oBAAuB;AACvB,sEAAsE;AACtE,kCAAkC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACxD,iBAAiB,MAAM,KACtB,WAAW,GAAG,IAiXhB,CAAA"}
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import { parseMimeType } from '@scalar/helpers/http/mime-type';
|
|
3
3
|
import { isObject } from '@scalar/helpers/object/is-object';
|
|
4
4
|
import { setValueAtPath } from '@scalar/helpers/object/set-value-at-path';
|
|
5
|
-
import { getResolvedRef, mergeSiblingReferences } from '@scalar/workspace-store/helpers/get-resolved-ref';
|
|
6
5
|
import { unpackProxyObject } from '@scalar/workspace-store/helpers/unpack-proxy';
|
|
7
6
|
import { isObjectSchema } from '@scalar/workspace-store/schemas/v3.2/strict/type-guards';
|
|
8
7
|
import { getExampleValue, getExplicitExampleText } from '../../../helpers/get-example-value.js';
|
|
8
|
+
import { resolveFormSchema } from '../../../helpers/resolve-form-schema.js';
|
|
9
9
|
import { buildMultipart, getMultipartItemSchema, isPositionalMultipart, needsMultipartEncoding, } from './build-multipart.js';
|
|
10
10
|
import { getExampleFromBody } from './get-request-body-example.js';
|
|
11
11
|
import { getSelectedBodyContentType } from './get-selected-body-content-type.js';
|
|
@@ -90,7 +90,7 @@ requestBodyCompositionSelection, openapiVersion) => {
|
|
|
90
90
|
// object schema that declares it outside `required`, so undeclared and required keys are
|
|
91
91
|
// always kept. This mirrors the unchecked-by-default checkbox in the Test Request panel.
|
|
92
92
|
// The array (edited) form path is unaffected: it carries its own per-row `isDisabled`.
|
|
93
|
-
const resolvedBodySchema =
|
|
93
|
+
const resolvedBodySchema = resolveFormSchema(requestBody.content[bodyContentType]?.schema, requestBodyCompositionSelection);
|
|
94
94
|
const objectBodySchema = resolvedBodySchema && isObjectSchema(resolvedBodySchema) ? resolvedBodySchema : undefined;
|
|
95
95
|
// Composition (allOf/oneOf/anyOf) can mark a property required inside a subschema we do not
|
|
96
96
|
// merge here, so skip dropping entirely for composed schemas rather than risk removing an
|
|
@@ -171,9 +171,7 @@ requestBodyCompositionSelection, openapiVersion) => {
|
|
|
171
171
|
// lazily allocate the regrouped object for its top-level key and push it into
|
|
172
172
|
// `entries` at the position of the *first* matching row, then keep folding leaves
|
|
173
173
|
// into the same live object reference so interleaved flat rows keep their order.
|
|
174
|
-
const multipartSchema = result.mode === 'formdata'
|
|
175
|
-
? getResolvedRef(requestBody.content[bodyContentType]?.schema, mergeSiblingReferences)
|
|
176
|
-
: undefined;
|
|
174
|
+
const multipartSchema = result.mode === 'formdata' ? resolvedBodySchema : undefined;
|
|
177
175
|
const entries = result.mode === 'formdata' ? regroupMultipartRows(exampleValue, multipartSchema) : exampleValue;
|
|
178
176
|
// Loop over all entries and add them to the form
|
|
179
177
|
entries.forEach(({ name, value }) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-value-coercion.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/body/schema-value-coercion.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8DAA8D,CAAA;AAShG;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAAI,QAAQ,YAAY,GAAG,SAAS,EAAE,UAAU,MAAM,EAAE,KAAG,YAAY,GAAG,SASvG,CAAA;AA2BD;;;;;;;;GAQG;AACH,eAAO,MAAM,2BAA2B,GAAI,OAAO,OAAO,EAAE,QAAQ,YAAY,GAAG,SAAS,KAAG,OAe9F,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,GAAI,OAAO,OAAO,KAAG,OAUnD,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,6BAA6B,GAAI,QAAQ,OAAO,aAG1C,MAAM,UAAU,OAAO,
|
|
1
|
+
{"version":3,"file":"schema-value-coercion.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/body/schema-value-coercion.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8DAA8D,CAAA;AAShG;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAAI,QAAQ,YAAY,GAAG,SAAS,EAAE,UAAU,MAAM,EAAE,KAAG,YAAY,GAAG,SASvG,CAAA;AA2BD;;;;;;;;GAQG;AACH,eAAO,MAAM,2BAA2B,GAAI,OAAO,OAAO,EAAE,QAAQ,YAAY,GAAG,SAAS,KAAG,OAe9F,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,GAAI,OAAO,OAAO,KAAG,OAUnD,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,6BAA6B,GAAI,QAAQ,OAAO,aAG1C,MAAM,UAAU,OAAO,YAgBzC,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { resolveSchemaWithAnnotations } from '@scalar/workspace-store/helpers/resolve-schema-with-annotations';
|
|
2
2
|
import { isObjectSchema } from '@scalar/workspace-store/schemas/v3.2/strict/type-guards';
|
|
3
3
|
/** Normalize a schema's `type` (string | string[] | absent) into a plain string array. */
|
|
4
4
|
const normalizeSchemaTypes = (schema) => {
|
|
@@ -10,12 +10,12 @@ const normalizeSchemaTypes = (schema) => {
|
|
|
10
10
|
* or undefined when any segment is not a declared object property.
|
|
11
11
|
*/
|
|
12
12
|
export const resolveLeafSchema = (schema, segments) => {
|
|
13
|
-
let current = schema;
|
|
13
|
+
let current = resolveSchemaWithAnnotations(schema);
|
|
14
14
|
for (const segment of segments) {
|
|
15
15
|
if (!current || !isObjectSchema(current) || !current.properties) {
|
|
16
16
|
return undefined;
|
|
17
17
|
}
|
|
18
|
-
current =
|
|
18
|
+
current = resolveSchemaWithAnnotations(current.properties[segment]);
|
|
19
19
|
}
|
|
20
20
|
return current;
|
|
21
21
|
};
|
|
@@ -97,15 +97,13 @@ export const coerceUntypedValue = (value) => {
|
|
|
97
97
|
* back into nested objects.
|
|
98
98
|
*/
|
|
99
99
|
export const buildDottedNestedRowPredicate = (schema) => {
|
|
100
|
-
const resolved = schema ?
|
|
100
|
+
const resolved = schema ? resolveSchemaWithAnnotations(schema) : undefined;
|
|
101
101
|
if (!resolved || !isObjectSchema(resolved) || !resolved.properties) {
|
|
102
102
|
return (_name, _value) => false;
|
|
103
103
|
}
|
|
104
104
|
const nestedTopKeys = new Set();
|
|
105
105
|
for (const [key, child] of Object.entries(resolved.properties)) {
|
|
106
|
-
const childResolved = child
|
|
107
|
-
? getResolvedRef(child, mergeSiblingReferences)
|
|
108
|
-
: undefined;
|
|
106
|
+
const childResolved = child ? resolveSchemaWithAnnotations(child) : undefined;
|
|
109
107
|
if (childResolved && isObjectSchema(childResolved) && childResolved.properties) {
|
|
110
108
|
nestedTopKeys.add(key);
|
|
111
109
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-request.d.ts","sourceRoot":"","sources":["../../../src/request-example/builder/build-request.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,MAAM,EAAW,MAAM,8BAA8B,CAAA;AAQnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAA;AAC/E,OAAO,EACL,KAAK,6BAA6B,EAEnC,MAAM,uDAAuD,CAAA;AAK9D;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;AAwClD;;;;;;;GAOG;AACH,eAAO,MAAM,2BAA2B,GACtC,SAAS,cAAc,EACvB,cAAc,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACpC,iBAAiB;IAAE,6BAA6B,CAAC,EAAE,OAAO,CAAA;CAAE,KAC3D,MAyBF,CAAA;AAED;;;;;KAKK;AACL,MAAM,MAAM,gBAAgB,GAAG;IAC7B,kGAAkG;IAClG,cAAc,EAAE,cAAc,CAAA;IAC9B,2BAA2B;IAC3B,UAAU,EAAE,eAAe,CAAA;IAC3B,0DAA0D;IAC1D,YAAY,EAAE,OAAO,CAAA;CACtB,CAAA;AAED,wGAAwG;AACxG,eAAO,MAAM,oBAAoB,EAAG,sBAA+B,CAAA;AAEnE,MAAM,MAAM,uBAAuB,GAAG,6BAA6B,GAAG,OAAO,oBAAoB,CAAA;AAEjG,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,gBAAgB,EAAE,uBAAuB,CAAC,CAAA;AAElF,eAAO,MAAM,YAAY,GACvB,SAAS,cAAc,EACvB,SAAS;IACP,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACpC;;;OAGG;IACH,6BAA6B,CAAC,EAAE,OAAO,CAAA;CACxC,KACA,
|
|
1
|
+
{"version":3,"file":"build-request.d.ts","sourceRoot":"","sources":["../../../src/request-example/builder/build-request.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,MAAM,EAAW,MAAM,8BAA8B,CAAA;AAQnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAA;AAC/E,OAAO,EACL,KAAK,6BAA6B,EAEnC,MAAM,uDAAuD,CAAA;AAK9D;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;AAwClD;;;;;;;GAOG;AACH,eAAO,MAAM,2BAA2B,GACtC,SAAS,cAAc,EACvB,cAAc,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACpC,iBAAiB;IAAE,6BAA6B,CAAC,EAAE,OAAO,CAAA;CAAE,KAC3D,MAyBF,CAAA;AAED;;;;;KAKK;AACL,MAAM,MAAM,gBAAgB,GAAG;IAC7B,kGAAkG;IAClG,cAAc,EAAE,cAAc,CAAA;IAC9B,2BAA2B;IAC3B,UAAU,EAAE,eAAe,CAAA;IAC3B,0DAA0D;IAC1D,YAAY,EAAE,OAAO,CAAA;CACtB,CAAA;AAED,wGAAwG;AACxG,eAAO,MAAM,oBAAoB,EAAG,sBAA+B,CAAA;AAEnE,MAAM,MAAM,uBAAuB,GAAG,6BAA6B,GAAG,OAAO,oBAAoB,CAAA;AAEjG,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,gBAAgB,EAAE,uBAAuB,CAAC,CAAA;AAElF,eAAO,MAAM,YAAY,GACvB,SAAS,cAAc,EACvB,SAAS;IACP,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACpC;;;OAGG;IACH,6BAA6B,CAAC,EAAE,OAAO,CAAA;CACxC,KACA,kBASF,CAAA"}
|
|
@@ -68,6 +68,9 @@ export const resolveExecutableRequestUrl = (request, envVariables, resolveOption
|
|
|
68
68
|
/** Catch-all code when an unexpected synchronous error escapes a helper during request construction. */
|
|
69
69
|
export const BUILD_REQUEST_FAILED = 'BUILD_REQUEST_FAILED';
|
|
70
70
|
export const buildRequest = (request, options) => {
|
|
71
|
+
if (request.cookieErrors?.length) {
|
|
72
|
+
return err(BUILD_REQUEST_FAILED, request.cookieErrors[0]);
|
|
73
|
+
}
|
|
71
74
|
const guarded = safeRun(() => buildRequestInner(request, options));
|
|
72
75
|
if (!guarded.ok) {
|
|
73
76
|
return err(BUILD_REQUEST_FAILED, guarded.error);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type XScalarCookie } from '@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies';
|
|
2
2
|
import type { ParameterObject, ReferenceType } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document';
|
|
3
|
+
import type { ReservedPathParameter } from '../../../helpers/encode-path-parameter.js';
|
|
3
4
|
/**
|
|
4
5
|
* Converts the parameters into a set of headers, cookies and url params while
|
|
5
6
|
* replacing environment variables and extracting example values. Also builds up a record of the path
|
|
@@ -14,10 +15,15 @@ export declare const buildRequestParameters: (
|
|
|
14
15
|
/** All parameters */
|
|
15
16
|
parameters?: ReferenceType<ParameterObject>[],
|
|
16
17
|
/** The key of the current example */
|
|
17
|
-
exampleName?: string
|
|
18
|
+
exampleName?: string,
|
|
19
|
+
/** Reserved path expansion was introduced in OpenAPI 3.2. */
|
|
20
|
+
openapiVersion?: string) => {
|
|
18
21
|
cookies: XScalarCookie[];
|
|
22
|
+
/** Invalid active cookie parameters that prevent sending this request. */
|
|
23
|
+
cookieErrors?: string[];
|
|
19
24
|
headers: Record<string, string>;
|
|
20
25
|
pathVariables: Record<string, string>;
|
|
26
|
+
reservedPathParameters?: Record<string, ReservedPathParameter>;
|
|
21
27
|
allowReservedQueryParameters: Set<string>;
|
|
22
28
|
urlParams: URLSearchParams;
|
|
23
29
|
serializedQuery?: string[];
|