@scalar/workspace-store 0.68.2 → 0.68.3
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 +24 -0
- package/dist/channel-example/get-async-api-protocols.d.ts +3 -1
- package/dist/channel-example/get-async-api-protocols.d.ts.map +1 -1
- package/dist/channel-example/get-async-api-protocols.js +6 -2
- package/dist/channel-example/get-asyncapi-security-requirements.d.ts +14 -2
- package/dist/channel-example/get-asyncapi-security-requirements.d.ts.map +1 -1
- package/dist/channel-example/get-asyncapi-security-requirements.js +89 -32
- package/dist/channel-example/get-channel-connection-context.d.ts.map +1 -1
- package/dist/channel-example/get-channel-connection-context.js +3 -4
- package/dist/channel-example/get-channel-connection-security.d.ts +3 -2
- package/dist/channel-example/get-channel-connection-security.d.ts.map +1 -1
- package/dist/channel-example/get-channel-connection-security.js +4 -6
- package/dist/channel-example/get-channel-operations.d.ts.map +1 -1
- package/dist/channel-example/get-channel-operations.js +2 -1
- package/dist/channel-example/get-channel-parameters.d.ts.map +1 -1
- package/dist/channel-example/get-channel-parameters.js +2 -1
- package/dist/channel-example/index.d.ts +2 -2
- package/dist/channel-example/index.d.ts.map +1 -1
- package/dist/channel-example/index.js +2 -2
- package/dist/channel-example/resolve-channel.d.ts.map +1 -1
- package/dist/channel-example/resolve-channel.js +2 -1
- package/dist/channel-example/resolve-operation-channel.d.ts.map +1 -1
- package/dist/channel-example/resolve-operation-channel.js +4 -2
- package/dist/channel-example/resolve-operation-with-traits.d.ts +1 -3
- package/dist/channel-example/resolve-operation-with-traits.d.ts.map +1 -1
- package/dist/channel-example/resolve-operation-with-traits.js +3 -41
- package/dist/channel-example/servers.d.ts.map +1 -1
- package/dist/channel-example/servers.js +2 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +8 -4
- package/dist/entities/auth/schema.d.ts +5 -0
- package/dist/entities/auth/schema.d.ts.map +1 -1
- package/dist/events/definitions/operation.d.ts +7 -0
- package/dist/events/definitions/operation.d.ts.map +1 -1
- package/dist/helpers/asyncapi-chunk-groups.d.ts.map +1 -1
- package/dist/helpers/asyncapi-chunk-groups.js +8 -4
- package/dist/helpers/asyncapi-model-chunk-reference.d.ts.map +1 -1
- package/dist/helpers/asyncapi-model-chunk-reference.js +2 -1
- package/dist/helpers/auth-secret-fields.d.ts +11 -0
- package/dist/helpers/auth-secret-fields.d.ts.map +1 -1
- package/dist/helpers/auth-secret-fields.js +22 -0
- package/dist/helpers/encode-path-parameter.d.ts.map +1 -1
- package/dist/helpers/encode-path-parameter.js +11 -12
- package/dist/helpers/external-examples.d.ts.map +1 -1
- package/dist/helpers/external-examples.js +6 -3
- package/dist/helpers/get-boolean-schema.d.ts +7 -0
- package/dist/helpers/get-boolean-schema.d.ts.map +1 -0
- package/dist/helpers/get-boolean-schema.js +5 -0
- package/dist/helpers/get-resolved-ref-deep.d.ts.map +1 -1
- package/dist/helpers/normalize-boolean-schemas.d.ts.map +1 -1
- package/dist/helpers/normalize-boolean-schemas.js +6 -1
- package/dist/helpers/operation-examples.d.ts.map +1 -1
- package/dist/helpers/operation-examples.js +2 -1
- package/dist/helpers/querystring-parameter.d.ts.map +1 -1
- package/dist/helpers/querystring-parameter.js +6 -6
- package/dist/helpers/resolve-security-requirements.d.ts.map +1 -1
- package/dist/helpers/resolve-security-requirements.js +38 -19
- package/dist/helpers/resolve-traits.d.ts +3 -0
- package/dist/helpers/resolve-traits.d.ts.map +1 -0
- package/dist/helpers/resolve-traits.js +68 -0
- package/dist/helpers/serialize-stream-example.js +1 -1
- package/dist/helpers/use-external-examples.d.ts.map +1 -1
- package/dist/helpers/use-external-examples.js +10 -5
- package/dist/mutators/auth.d.ts.map +1 -1
- package/dist/mutators/auth.js +2 -1
- package/dist/mutators/operation/helpers/har-to-operation.d.ts.map +1 -1
- package/dist/mutators/operation/helpers/har-to-operation.js +4 -2
- package/dist/mutators/operation/operation.d.ts.map +1 -1
- package/dist/mutators/operation/operation.js +4 -2
- package/dist/mutators/operation/parameters.d.ts.map +1 -1
- package/dist/mutators/operation/parameters.js +23 -1
- package/dist/mutators/tag.d.ts.map +1 -1
- package/dist/mutators/tag.js +4 -2
- package/dist/navigation/get-navigation-options.js +6 -5
- package/dist/navigation/helpers/traverse-asyncapi-document.d.ts.map +1 -1
- package/dist/navigation/helpers/traverse-asyncapi-document.js +27 -20
- package/dist/navigation/helpers/traverse-paths.js +1 -1
- package/dist/navigation/helpers/traverse-schemas.d.ts.map +1 -1
- package/dist/navigation/helpers/traverse-schemas.js +2 -1
- package/dist/plugins/bundler/index.d.ts.map +1 -1
- package/dist/plugins/bundler/index.js +2 -1
- package/dist/plugins/bundler/openapi-document.d.ts.map +1 -1
- package/dist/plugins/bundler/openapi-document.js +2 -1
- package/dist/request-example/builder/body/build-multipart.d.ts.map +1 -1
- package/dist/request-example/builder/body/build-multipart.js +18 -16
- package/dist/request-example/builder/body/encode-multipart-body.d.ts.map +1 -1
- package/dist/request-example/builder/body/encode-multipart-body.js +2 -1
- 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 +2 -1
- package/dist/request-example/builder/body/schema-value-coercion.d.ts.map +1 -1
- package/dist/request-example/builder/body/schema-value-coercion.js +4 -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 +12 -2
- package/dist/request-example/builder/header/filter-disabled-properties.d.ts +3 -0
- package/dist/request-example/builder/header/filter-disabled-properties.d.ts.map +1 -0
- package/dist/request-example/builder/header/filter-disabled-properties.js +18 -0
- package/dist/request-example/builder/header/filter-global-cookies.d.ts +1 -1
- package/dist/request-example/builder/header/filter-global-cookies.d.ts.map +1 -1
- package/dist/request-example/builder/header/filter-global-cookies.js +15 -3
- package/dist/request-example/builder/header/is-param-disabled.d.ts +1 -1
- 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 -2
- 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 +20 -16
- package/dist/request-example/builder/helpers/get-example.d.ts +2 -0
- package/dist/request-example/builder/helpers/get-example.d.ts.map +1 -1
- package/dist/request-example/builder/helpers/get-example.js +15 -5
- package/dist/request-example/builder/index.d.ts +1 -0
- package/dist/request-example/builder/index.d.ts.map +1 -1
- package/dist/request-example/builder/index.js +1 -0
- package/dist/request-example/builder/resolve-request-factory-url.d.ts.map +1 -1
- package/dist/request-example/builder/resolve-request-factory-url.js +9 -8
- package/dist/request-example/builder/security/secret-types.d.ts +13 -3
- package/dist/request-example/builder/security/secret-types.d.ts.map +1 -1
- package/dist/request-example/context/headers.js +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 +63 -25
- package/dist/request-example/context/security/get-selected-security.js +1 -1
- package/dist/request-example/context/security/merge-security.d.ts.map +1 -1
- package/dist/request-example/context/security/merge-security.js +2 -1
- package/dist/request-example/index.d.ts +1 -1
- package/dist/request-example/index.d.ts.map +1 -1
- package/dist/request-example/index.js +1 -1
- package/dist/request-example/xml/get-xml-example.js +2 -1
- package/dist/request-example/xml/write-xml.d.ts.map +1 -1
- package/dist/request-example/xml/write-xml.js +6 -5
- package/dist/resolve.d.ts +1 -1
- package/dist/resolve.d.ts.map +1 -1
- package/dist/resolve.js +16 -1
- package/dist/schemas/extensions/example/x-disabled.d.ts +4 -0
- package/dist/schemas/extensions/example/x-disabled.d.ts.map +1 -1
- package/dist/schemas/extensions/example/x-disabled.js +3 -1
- package/dist/schemas/navigation.d.ts +1 -1
- package/dist/schemas/navigation.d.ts.map +1 -1
- package/dist/schemas/reference-config/index.d.ts +1 -0
- package/dist/schemas/reference-config/index.d.ts.map +1 -1
- package/dist/schemas/reference-config/settings.d.ts +1 -0
- package/dist/schemas/reference-config/settings.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/example.d.ts +3 -0
- package/dist/schemas/v3.1/strict/example.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/openapi-document.d.ts +36 -6
- package/dist/schemas/v3.1/strict/openapi-document.d.ts.map +1 -1
- package/dist/schemas/v3.2/strict/example.d.ts +3 -0
- package/dist/schemas/v3.2/strict/example.d.ts.map +1 -1
- package/dist/schemas/v3.2/strict/openapi-document.d.ts +36 -6
- package/dist/schemas/v3.2/strict/openapi-document.d.ts.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +4 -2
- package/package.json +9 -9
|
@@ -25,8 +25,9 @@ const absoluteReference = (reference, base) => {
|
|
|
25
25
|
* Relative keys in referenced documents become absolute to keep distinct document bases apart.
|
|
26
26
|
*/
|
|
27
27
|
export const resolveSecurityRequirements = async (document, { origin = '/', loaders }) => {
|
|
28
|
-
if (typeof document.openapi !== 'string' || !/^3\.2\.\d+$/.test(document.openapi))
|
|
28
|
+
if (typeof document.openapi !== 'string' || !/^3\.2\.\d+$/.test(document.openapi)) {
|
|
29
29
|
return;
|
|
30
|
+
}
|
|
30
31
|
const originalKeys = isObject(document[ORIGINAL_KEYS]) ? document[ORIGINAL_KEYS] : {};
|
|
31
32
|
const components = isObject(document.components) ? document.components : {};
|
|
32
33
|
const schemes = isObject(components.securitySchemes) ? components.securitySchemes : {};
|
|
@@ -44,8 +45,9 @@ export const resolveSecurityRequirements = async (document, { origin = '/', load
|
|
|
44
45
|
const processedDocuments = new Set();
|
|
45
46
|
const cache = new Map();
|
|
46
47
|
const visit = async (node, path, base, external) => {
|
|
47
|
-
if (node === null || typeof node !== 'object' || visited.has(node) || isSchemaPath(path))
|
|
48
|
+
if (node === null || typeof node !== 'object' || visited.has(node) || isSchemaPath(path)) {
|
|
48
49
|
return;
|
|
50
|
+
}
|
|
49
51
|
visited.add(node);
|
|
50
52
|
// Security is a fixed field on document and operation objects, not arbitrary example payloads.
|
|
51
53
|
const operationKey = path.at(-1) ?? '';
|
|
@@ -53,11 +55,13 @@ export const resolveSecurityRequirements = async (document, { origin = '/', load
|
|
|
53
55
|
const isDocument = path.length === 0 || (path[0] === 'x-ext' && path.length === 2);
|
|
54
56
|
if (isObject(node) && (isDocument || isOperation) && Array.isArray(node.security)) {
|
|
55
57
|
for (const [index, requirement] of node.security.entries()) {
|
|
56
|
-
if (!isObject(requirement))
|
|
58
|
+
if (!isObject(requirement)) {
|
|
57
59
|
continue;
|
|
60
|
+
}
|
|
58
61
|
for (const [name, scopes] of Object.entries(requirement)) {
|
|
59
|
-
if (namedSchemes.has(name) || !Array.isArray(scopes))
|
|
62
|
+
if (namedSchemes.has(name) || !Array.isArray(scopes)) {
|
|
60
63
|
continue;
|
|
64
|
+
}
|
|
61
65
|
const uri = (() => {
|
|
62
66
|
try {
|
|
63
67
|
return Object.hasOwn(aliases, name) && typeof aliases[name] === 'string'
|
|
@@ -68,8 +72,9 @@ export const resolveSecurityRequirements = async (document, { origin = '/', load
|
|
|
68
72
|
return undefined;
|
|
69
73
|
}
|
|
70
74
|
})();
|
|
71
|
-
if (uri === undefined)
|
|
75
|
+
if (uri === undefined) {
|
|
72
76
|
continue;
|
|
77
|
+
}
|
|
73
78
|
const key = await generateUniqueValue({
|
|
74
79
|
defaultValue: external ? uri : name,
|
|
75
80
|
validation: (candidate) => !namedSchemes.has(candidate) &&
|
|
@@ -77,8 +82,9 @@ export const resolveSecurityRequirements = async (document, { origin = '/', load
|
|
|
77
82
|
(!external || candidate === name || !Object.hasOwn(requirement, candidate)),
|
|
78
83
|
maxRetries: Object.keys(schemes).length + 1,
|
|
79
84
|
});
|
|
80
|
-
if (key === undefined)
|
|
85
|
+
if (key === undefined) {
|
|
81
86
|
continue;
|
|
87
|
+
}
|
|
82
88
|
if (!Object.hasOwn(aliases, key)) {
|
|
83
89
|
const reference = { $ref: uri };
|
|
84
90
|
await bundle({ components: { securitySchemes: { target: reference } } }, {
|
|
@@ -106,8 +112,9 @@ export const resolveSecurityRequirements = async (document, { origin = '/', load
|
|
|
106
112
|
])),
|
|
107
113
|
}
|
|
108
114
|
: target;
|
|
109
|
-
if (!Value.Check(SecuritySchemeObjectSchema, validationTarget))
|
|
115
|
+
if (!Value.Check(SecuritySchemeObjectSchema, validationTarget)) {
|
|
110
116
|
continue;
|
|
117
|
+
}
|
|
111
118
|
Object.defineProperty(schemes, key, {
|
|
112
119
|
value: reference,
|
|
113
120
|
enumerable: true,
|
|
@@ -125,8 +132,9 @@ export const resolveSecurityRequirements = async (document, { origin = '/', load
|
|
|
125
132
|
Object.defineProperty(mapping, name, { value: key, enumerable: true, writable: true, configurable: true });
|
|
126
133
|
originalKeys[location] = mapping;
|
|
127
134
|
document[ORIGINAL_KEYS] = originalKeys;
|
|
128
|
-
if (key === name)
|
|
135
|
+
if (key === name) {
|
|
129
136
|
continue;
|
|
137
|
+
}
|
|
130
138
|
const previous = Object.hasOwn(requirement, key) ? requirement[key] : [];
|
|
131
139
|
Object.defineProperty(requirement, key, {
|
|
132
140
|
value: [...new Set([...(Array.isArray(previous) ? previous : []), ...scopes])],
|
|
@@ -140,8 +148,9 @@ export const resolveSecurityRequirements = async (document, { origin = '/', load
|
|
|
140
148
|
}
|
|
141
149
|
}
|
|
142
150
|
for (const [key, child] of Object.entries(node)) {
|
|
143
|
-
if (key.startsWith('x-') || key === 'example' || key === 'examples' || key === 'security')
|
|
151
|
+
if (key.startsWith('x-') || key === 'example' || key === 'examples' || key === 'security') {
|
|
144
152
|
continue;
|
|
153
|
+
}
|
|
145
154
|
await visit(child, [...path, key], base, external);
|
|
146
155
|
}
|
|
147
156
|
};
|
|
@@ -150,14 +159,17 @@ export const resolveSecurityRequirements = async (document, { origin = '/', load
|
|
|
150
159
|
// URI-only dependencies can load further documents, so process newly embedded documents too.
|
|
151
160
|
while (isObject(document['x-ext'])) {
|
|
152
161
|
const next = Object.entries(document['x-ext']).find(([key]) => !processedDocuments.has(key));
|
|
153
|
-
if (!next)
|
|
162
|
+
if (!next) {
|
|
154
163
|
break;
|
|
164
|
+
}
|
|
155
165
|
const [key, external] = next;
|
|
156
166
|
processedDocuments.add(key);
|
|
157
|
-
if (!isObject(external))
|
|
167
|
+
if (!isObject(external)) {
|
|
158
168
|
continue;
|
|
159
|
-
|
|
169
|
+
}
|
|
170
|
+
if (typeof external.openapi === 'string' && !/^3\.2\.\d+$/.test(external.openapi)) {
|
|
160
171
|
continue;
|
|
172
|
+
}
|
|
161
173
|
const mappings = document['x-ext-urls'];
|
|
162
174
|
const retrieval = isObject(mappings) && typeof mappings[key] === 'string' ? mappings[key] : key;
|
|
163
175
|
const retrievalUri = resolveReferencePath(entryBase, retrieval);
|
|
@@ -179,20 +191,24 @@ export const restoreSecurityRequirements = (document) => {
|
|
|
179
191
|
})();
|
|
180
192
|
if (!Array.isArray(path) ||
|
|
181
193
|
!path.every((segment) => typeof segment === 'string' && !isPollutionKey(segment)) ||
|
|
182
|
-
!isObject(mapping))
|
|
194
|
+
!isObject(mapping)) {
|
|
183
195
|
continue;
|
|
196
|
+
}
|
|
184
197
|
const requirement = path.reduce((parent, segment) => {
|
|
185
|
-
if (parent === null || typeof parent !== 'object' || !Object.hasOwn(parent, segment))
|
|
198
|
+
if (parent === null || typeof parent !== 'object' || !Object.hasOwn(parent, segment)) {
|
|
186
199
|
return undefined;
|
|
200
|
+
}
|
|
187
201
|
return Reflect.get(parent, segment);
|
|
188
202
|
}, document);
|
|
189
|
-
if (!isObject(requirement))
|
|
203
|
+
if (!isObject(requirement)) {
|
|
190
204
|
continue;
|
|
205
|
+
}
|
|
191
206
|
const entries = Object.entries(mapping).flatMap(([original, rewritten]) => typeof rewritten === 'string' && Object.hasOwn(requirement, rewritten)
|
|
192
207
|
? [{ original, rewritten, scopes: requirement[rewritten] }]
|
|
193
208
|
: []);
|
|
194
|
-
for (const { rewritten } of entries)
|
|
209
|
+
for (const { rewritten } of entries) {
|
|
195
210
|
delete requirement[rewritten];
|
|
211
|
+
}
|
|
196
212
|
for (const { original, scopes } of entries) {
|
|
197
213
|
Object.defineProperty(requirement, original, {
|
|
198
214
|
value: scopes,
|
|
@@ -210,12 +226,15 @@ export const restoreSecurityRequirements = (document) => {
|
|
|
210
226
|
isObject(components) &&
|
|
211
227
|
Object.hasOwn(components, 'securitySchemes') &&
|
|
212
228
|
isObject(components.securitySchemes)) {
|
|
213
|
-
for (const key of Object.keys(metadata.schemes))
|
|
229
|
+
for (const key of Object.keys(metadata.schemes)) {
|
|
214
230
|
delete components.securitySchemes[key];
|
|
215
|
-
|
|
231
|
+
}
|
|
232
|
+
if (!metadata.hadSecuritySchemes && Object.keys(components.securitySchemes).length === 0) {
|
|
216
233
|
delete components.securitySchemes;
|
|
217
|
-
|
|
234
|
+
}
|
|
235
|
+
if (!metadata.hadComponents && Object.keys(components).length === 0) {
|
|
218
236
|
delete document.components;
|
|
237
|
+
}
|
|
219
238
|
}
|
|
220
239
|
delete document[ALIASES];
|
|
221
240
|
delete document[ORIGINAL_KEYS];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-traits.d.ts","sourceRoot":"","sources":["../../src/helpers/resolve-traits.ts"],"names":[],"mappings":"AAoEA,uFAAuF;AACvF,eAAO,MAAM,aAAa,GAAI,CAAC,SAAS,MAAM,EAAE,QAAQ,CAAC,EAAE,QAAQ,SAAS,MAAM,EAAE,KAAG,CAetF,CAAA"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { isObject } from '@scalar/helpers/object/is-object';
|
|
2
|
+
import { getResolvedRef } from './get-resolved-ref.js';
|
|
3
|
+
const schemaMaps = new Set(['properties', 'patternProperties', '$defs', 'definitions', 'dependentSchemas']);
|
|
4
|
+
const dataFields = new Set(['example', 'examples', 'default', 'enum', 'const', 'value', 'dataValue']);
|
|
5
|
+
/**
|
|
6
|
+
* Apply JSON Merge Patch to resolved trait fields. Unlike mergeObjects, null removes a key.
|
|
7
|
+
* Resolve schema references before merging so a message can extend referenced trait headers.
|
|
8
|
+
*/
|
|
9
|
+
const mergeTraitFields = (target, patch, context = 'object', ancestors = new WeakMap()) => {
|
|
10
|
+
// Reply channels identify a location in the document, so retain their reference wrappers.
|
|
11
|
+
if (context === 'reference') {
|
|
12
|
+
return patch;
|
|
13
|
+
}
|
|
14
|
+
const resolvedPatch = context === 'object' && isObject(patch) && typeof patch.$ref === 'string' ? getResolvedRef(patch) : patch;
|
|
15
|
+
if (!isObject(resolvedPatch)) {
|
|
16
|
+
return resolvedPatch;
|
|
17
|
+
}
|
|
18
|
+
// Resolved schemas can be recursive. Keep their cycles without changing the source document.
|
|
19
|
+
if (ancestors.has(resolvedPatch)) {
|
|
20
|
+
return ancestors.get(resolvedPatch);
|
|
21
|
+
}
|
|
22
|
+
const resolvedTarget = context === 'object' && isObject(target) && typeof target.$ref === 'string' ? getResolvedRef(target) : target;
|
|
23
|
+
const result = isObject(resolvedTarget) ? { ...resolvedTarget } : {};
|
|
24
|
+
ancestors.set(resolvedPatch, result);
|
|
25
|
+
for (const [key, value] of Object.entries(resolvedPatch)) {
|
|
26
|
+
if (value === null) {
|
|
27
|
+
delete result[key];
|
|
28
|
+
}
|
|
29
|
+
else if (value !== undefined) {
|
|
30
|
+
// Schema names and example data can contain literal $ref keys without being references.
|
|
31
|
+
const childContext = context === 'data'
|
|
32
|
+
? 'data'
|
|
33
|
+
: context === 'map'
|
|
34
|
+
? 'object'
|
|
35
|
+
: key === 'channel'
|
|
36
|
+
? 'reference'
|
|
37
|
+
: dataFields.has(key) || key.startsWith('x-')
|
|
38
|
+
? 'data'
|
|
39
|
+
: schemaMaps.has(key)
|
|
40
|
+
? 'map'
|
|
41
|
+
: 'object';
|
|
42
|
+
// Define an own property even for schema properties named __proto__.
|
|
43
|
+
Object.defineProperty(result, key, {
|
|
44
|
+
value: mergeTraitFields(Object.hasOwn(result, key) ? result[key] : undefined, value, childContext, ancestors),
|
|
45
|
+
enumerable: true,
|
|
46
|
+
configurable: true,
|
|
47
|
+
writable: true,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
ancestors.delete(resolvedPatch);
|
|
52
|
+
return result;
|
|
53
|
+
};
|
|
54
|
+
/** Merge traits in order, then apply the target's own fields with highest priority. */
|
|
55
|
+
export const resolveTraits = (target, traits) => {
|
|
56
|
+
if (traits.length === 0) {
|
|
57
|
+
return target;
|
|
58
|
+
}
|
|
59
|
+
const inherited = traits.reduce((fields, trait) => {
|
|
60
|
+
const resolved = getResolvedRef(trait);
|
|
61
|
+
return resolved ? mergeTraitFields(fields, resolved) : fields;
|
|
62
|
+
}, {});
|
|
63
|
+
// Only overlay fields supplied by traits. Unrelated fields keep their references and identity.
|
|
64
|
+
const overrides = Object.fromEntries(Object.entries(target).filter(([key]) => Object.hasOwn(inherited, key)));
|
|
65
|
+
const merged = mergeTraitFields(inherited, overrides);
|
|
66
|
+
const ownFields = Object.fromEntries(Object.entries(target).filter(([key]) => !Object.hasOwn(inherited, key)));
|
|
67
|
+
return { ...ownFields, ...merged };
|
|
68
|
+
};
|
|
@@ -11,7 +11,7 @@ export const serializeStreamExample = (value, contentType, singleItem) => {
|
|
|
11
11
|
return undefined;
|
|
12
12
|
}
|
|
13
13
|
const format = getStreamFormat(contentType);
|
|
14
|
-
const items = singleItem
|
|
14
|
+
const items = !singleItem && Array.isArray(value) ? value : [value];
|
|
15
15
|
if (format === 'json-lines') {
|
|
16
16
|
return items.map((item) => `${JSON.stringify(item)}\n`).join('');
|
|
17
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-external-examples.d.ts","sourceRoot":"","sources":["../../src/helpers/use-external-examples.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,GAAG,EAOT,MAAM,KAAK,CAAA;AAEZ,OAAO,EAAE,KAAK,uBAAuB,EAAiC,MAAM,6BAA6B,CAAA;AACzG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAA;AAE3E,4FAA4F;AAC5F,eAAO,MAAM,iBAAiB,EAAE,YAAY,CAAC,MAAM,uBAAuB,CAA+B,CAAA;AAEzG,0GAA0G;AAC1G,eAAO,MAAM,oBAAoB,GAAI,QAAQ,GAAG,CAAC,OAAO,GAAG,uBAAuB,GAAG,IAAI,CAAC,KAAG,GAAG,CAAC,OAAO,
|
|
1
|
+
{"version":3,"file":"use-external-examples.d.ts","sourceRoot":"","sources":["../../src/helpers/use-external-examples.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,GAAG,EAOT,MAAM,KAAK,CAAA;AAEZ,OAAO,EAAE,KAAK,uBAAuB,EAAiC,MAAM,6BAA6B,CAAA;AACzG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAA;AAE3E,4FAA4F;AAC5F,eAAO,MAAM,iBAAiB,EAAE,YAAY,CAAC,MAAM,uBAAuB,CAA+B,CAAA;AAEzG,0GAA0G;AAC1G,eAAO,MAAM,oBAAoB,GAAI,QAAQ,GAAG,CAAC,OAAO,GAAG,uBAAuB,GAAG,IAAI,CAAC,KAAG,GAAG,CAAC,OAAO,CAyBvG,CAAA;AAED,gGAAgG;AAChG,eAAO,MAAM,mBAAmB,GAC9B,UAAU,MAAM,CAAC,aAAa,GAAG,SAAS,CAAC,EAAE,EAC7C,UAAS,MAAM,OAAoB,EACnC,WAAW,MAAM,uBAAuB,KACvC;IACD,OAAO,EAAE,WAAW,CAAC,OAAO,CAAC,CAAA;IAC7B,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,CAAA;IAC5B,OAAO,EAAE,CAAC,OAAO,EAAE,aAAa,GAAG,SAAS,KAAK,aAAa,GAAG,SAAS,CAAA;IAC1E,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CA8C3B,CAAA"}
|
|
@@ -10,8 +10,9 @@ export const useExampleVisibility = (target) => {
|
|
|
10
10
|
observer?.disconnect();
|
|
11
11
|
visible.value = false;
|
|
12
12
|
const node = element && ('$el' in element ? element.$el : element);
|
|
13
|
-
if (typeof Element === 'undefined' || !(node instanceof Element))
|
|
13
|
+
if (typeof Element === 'undefined' || !(node instanceof Element)) {
|
|
14
14
|
return;
|
|
15
|
+
}
|
|
15
16
|
if (typeof IntersectionObserver === 'undefined') {
|
|
16
17
|
visible.value = true;
|
|
17
18
|
return;
|
|
@@ -32,22 +33,26 @@ export const useExternalExamples = (examples, enabled = () => true, resolver) =>
|
|
|
32
33
|
.filter((example) => example !== undefined && example.value === undefined && !!example.externalValue)
|
|
33
34
|
.map((example) => getResolver()(example)));
|
|
34
35
|
watchEffect(() => {
|
|
35
|
-
if (!enabled())
|
|
36
|
+
if (!enabled()) {
|
|
36
37
|
return;
|
|
38
|
+
}
|
|
37
39
|
for (const state of states.value) {
|
|
38
|
-
if (state.status === 'idle')
|
|
40
|
+
if (state.status === 'idle') {
|
|
39
41
|
void state.load();
|
|
42
|
+
}
|
|
40
43
|
}
|
|
41
44
|
});
|
|
42
45
|
return {
|
|
43
46
|
pending: computed(() => states.value.some((state) => state.status !== 'loaded')),
|
|
44
47
|
failed: computed(() => states.value.some((state) => state.status === 'error')),
|
|
45
48
|
resolve: (example) => {
|
|
46
|
-
if (!example || example.value !== undefined || !example.externalValue)
|
|
49
|
+
if (!example || example.value !== undefined || !example.externalValue) {
|
|
47
50
|
return example;
|
|
51
|
+
}
|
|
48
52
|
const state = getResolver()(example);
|
|
49
|
-
if (state.status !== 'loaded')
|
|
53
|
+
if (state.status !== 'loaded') {
|
|
50
54
|
return example;
|
|
55
|
+
}
|
|
51
56
|
// A 3.2 example can pair structured data with external wire text. Keep both in the
|
|
52
57
|
// resolved view so raw consumers display the download and form editors retain the data.
|
|
53
58
|
if (example.dataValue !== undefined && state.serializedValue !== undefined) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/mutators/auth.ts"],"names":[],"mappings":"AAAA,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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,SAsFrD,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
|
@@ -590,8 +590,9 @@ export const deleteSecurityScheme = (store, document, { names }) => {
|
|
|
590
590
|
forEachPathItemOperation(pathItemRef, (method, operationRef) => {
|
|
591
591
|
// Get mutable reference for the operation (could resolve $ref proxies)
|
|
592
592
|
const resolvedOperation = getResolvedRef(operationRef);
|
|
593
|
-
if (!resolvedOperation)
|
|
593
|
+
if (!resolvedOperation) {
|
|
594
594
|
return;
|
|
595
|
+
}
|
|
595
596
|
// Remove from operation-level security array
|
|
596
597
|
if ('security' in resolvedOperation && resolvedOperation['security']) {
|
|
597
598
|
resolvedOperation['security'] = filterSecuritySchemes(resolvedOperation['security']);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"har-to-operation.d.ts","sourceRoot":"","sources":["../../../../src/mutators/operation/helpers/har-to-operation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAElD,OAAO,KAAK,EAAE,eAAe,EAAmB,MAAM,8DAA8D,CAAA;AAKpH,KAAK,mBAAmB,GAAG;IACzB,6BAA6B;IAC7B,UAAU,EAAE,UAAU,CAAA;IACtB,oEAAoE;IACpE,UAAU,EAAE,MAAM,CAAA;IAClB,4CAA4C;IAC5C,aAAa,CAAC,EAAE,eAAe,CAAA;IAC/B,4CAA4C;IAC5C,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACvC,CAAA;AAyBD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,cAAc,GAAI,2DAK5B,mBAAmB,KAAG,
|
|
1
|
+
{"version":3,"file":"har-to-operation.d.ts","sourceRoot":"","sources":["../../../../src/mutators/operation/helpers/har-to-operation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAElD,OAAO,KAAK,EAAE,eAAe,EAAmB,MAAM,8DAA8D,CAAA;AAKpH,KAAK,mBAAmB,GAAG;IACzB,6BAA6B;IAC7B,UAAU,EAAE,UAAU,CAAA;IACtB,oEAAoE;IACpE,UAAU,EAAE,MAAM,CAAA;IAClB,4CAA4C;IAC5C,aAAa,CAAC,EAAE,eAAe,CAAA;IAC/B,4CAA4C;IAC5C,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACvC,CAAA;AAyBD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,cAAc,GAAI,2DAK5B,mBAAmB,KAAG,eA4HxB,CAAA"}
|
|
@@ -98,8 +98,9 @@ export const harToOperation = ({ harRequest, exampleKey, baseOperation = {}, pat
|
|
|
98
98
|
}
|
|
99
99
|
// Resolve the request body in case it is a reference
|
|
100
100
|
const requestBody = getResolvedRef(baseOperation.requestBody);
|
|
101
|
-
if (!requestBody)
|
|
101
|
+
if (!requestBody) {
|
|
102
102
|
return baseOperation;
|
|
103
|
+
}
|
|
103
104
|
// Ensure the content type exists in the requestBody
|
|
104
105
|
if (!requestBody.content[mimeType]) {
|
|
105
106
|
requestBody.content[mimeType] = {
|
|
@@ -150,8 +151,9 @@ const setParameterDisabled = (param, exampleKey, disabled) => {
|
|
|
150
151
|
return;
|
|
151
152
|
}
|
|
152
153
|
const example = getResolvedRef(param.examples[exampleKey]);
|
|
153
|
-
if (example)
|
|
154
|
+
if (example) {
|
|
154
155
|
example['x-disabled'] = disabled;
|
|
156
|
+
}
|
|
155
157
|
};
|
|
156
158
|
/**
|
|
157
159
|
* Finds an existing parameter in the parameters array or creates a new one.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../../../src/mutators/operation/operation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAarE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAGlD;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,eAAe,GAC1B,gBAAgB,cAAc,GAAG,IAAI,EACrC,SAAS,eAAe,CAAC,4BAA4B,CAAC,KACrD,MAAM,GAAG,SA0DX,CAAA;AAED;;;;;;;;;;;GA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,mBAAmB,eAAe,CAAC,uBAAuB,CAAC,SAsB5D,CAAA;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,yBAAyB,GACpC,UAAU,iBAAiB,GAAG,IAAI,EAClC,OAAO,cAAc,GAAG,IAAI,EAC5B,mEAAmE,eAAe,CAAC,6BAA6B,CAAC,KAChH,IAkGF,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,eAAe,GAC1B,WAAW,cAAc,GAAG,IAAI,EAChC,wBAAwB,eAAe,CAAC,4BAA4B,CAAC,SAgBtE,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B,GACtC,WAAW,cAAc,GAAG,IAAI,EAChC,uDAAuD,eAAe,CAAC,gCAAgC,CAAC,SAuBzG,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,GACjC,WAAW,cAAc,GAAG,IAAI,EAChC,sDAAsD,eAAe,CAAC,0BAA0B,CAAC,SAoDlG,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,sBAAsB,GACjC,WAAW,cAAc,GAAG,IAAI,EAChC,+DAA+D,eAAe,CAAC,0BAA0B,CAAC,SA0E3G,CAAA"}
|
|
@@ -274,8 +274,9 @@ export const deleteOperationExample = (workspace, { meta: { path, method, exampl
|
|
|
274
274
|
// Remove the example from all operation parameters
|
|
275
275
|
operation.parameters?.forEach((parameter) => {
|
|
276
276
|
const resolvedParameter = getResolvedRef(parameter);
|
|
277
|
-
if (!resolvedParameter)
|
|
277
|
+
if (!resolvedParameter) {
|
|
278
278
|
return;
|
|
279
|
+
}
|
|
279
280
|
// Remove from content-level examples (if parameter uses content)
|
|
280
281
|
if ('content' in resolvedParameter && resolvedParameter.content) {
|
|
281
282
|
Object.values(resolvedParameter.content).forEach((mediaType) => {
|
|
@@ -325,8 +326,9 @@ export const renameOperationExample = (workspace, { meta: { path, method, exampl
|
|
|
325
326
|
const records = [];
|
|
326
327
|
operation.parameters?.forEach((parameter) => {
|
|
327
328
|
const resolvedParameter = getResolvedRef(parameter);
|
|
328
|
-
if (!resolvedParameter)
|
|
329
|
+
if (!resolvedParameter) {
|
|
329
330
|
return;
|
|
331
|
+
}
|
|
330
332
|
if ('examples' in resolvedParameter && resolvedParameter.examples) {
|
|
331
333
|
records.push(resolvedParameter.examples);
|
|
332
334
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parameters.d.ts","sourceRoot":"","sources":["../../../src/mutators/operation/parameters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;
|
|
1
|
+
{"version":3,"file":"parameters.d.ts","sourceRoot":"","sources":["../../../src/mutators/operation/parameters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAOrE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAmClD;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,wBAAwB,GACnC,UAAU,iBAAiB,GAAG,IAAI,EAClC,4CAA4C,eAAe,CAAC,4BAA4B,CAAC,SA4H1F,CAAA;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,8BAA8B,GACzC,UAAU,iBAAiB,GAAG,IAAI,EAClC,uCAAuC,eAAe,CAAC,mCAAmC,CAAC,SA8C5F,CAAA;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,wBAAwB,GACnC,UAAU,iBAAiB,GAAG,IAAI,EAClC,6BAA6B,eAAe,CAAC,4BAA4B,CAAC,SAkC3E,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,4BAA4B,GACvC,UAAU,iBAAiB,GAAG,IAAI,EAClC,gBAAgB,eAAe,CAAC,iCAAiC,CAAC,SAgBnE,CAAA"}
|
|
@@ -3,6 +3,7 @@ import { getParameterExample } from '../../helpers/get-parameter-example.js';
|
|
|
3
3
|
import { getResolvedRef } from '../../helpers/get-resolved-ref.js';
|
|
4
4
|
import { getQuerystringParameter, serializeQuerystringParameter } from '../../helpers/querystring-parameter.js';
|
|
5
5
|
import { unpackProxyObject } from '../../helpers/unpack-proxy.js';
|
|
6
|
+
import { isParamDisabled } from '../../request-example/builder/header/is-param-disabled.js';
|
|
6
7
|
import { isOpenApiDocument } from '../../schemas/type-guards.js';
|
|
7
8
|
import { isContentTypeParameterObject } from '../../schemas/v3.2/strict/type-guards.js';
|
|
8
9
|
const getPathItemsForParameterMutation = (pathItemRef) => {
|
|
@@ -47,6 +48,7 @@ export const upsertOperationParameter = (document, { meta, type, payload, origin
|
|
|
47
48
|
const preserveQuerystringValue = querystring && payload.value === serializeQuerystringParameter(querystring);
|
|
48
49
|
const param = originalParameter;
|
|
49
50
|
const selected = getParameterExample(param, meta.exampleKey);
|
|
51
|
+
const inheritedDisabled = isParamDisabled(param, selected.example);
|
|
50
52
|
const target = param.in !== 'querystring' && !selected.serialized && isContentTypeParameterObject(param)
|
|
51
53
|
? Object.values(param.content ?? {})[0]
|
|
52
54
|
: param;
|
|
@@ -117,7 +119,27 @@ export const upsertOperationParameter = (document, { meta, type, payload, origin
|
|
|
117
119
|
example.value = payload.value;
|
|
118
120
|
}
|
|
119
121
|
}
|
|
120
|
-
|
|
122
|
+
if (payload.propertyState) {
|
|
123
|
+
// Freeze the inherited state before changing values: adding the first populated field
|
|
124
|
+
// must not implicitly enable every untouched sibling.
|
|
125
|
+
const states = { '[]': inheritedDisabled, ...example['x-scalar-disabled-properties'] };
|
|
126
|
+
const { path, previousPath, isDisabled } = payload.propertyState;
|
|
127
|
+
if (previousPath) {
|
|
128
|
+
delete states[JSON.stringify(previousPath)];
|
|
129
|
+
}
|
|
130
|
+
const key = JSON.stringify(path);
|
|
131
|
+
if (isDisabled === undefined) {
|
|
132
|
+
delete states[key];
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
states[key] = isDisabled;
|
|
136
|
+
}
|
|
137
|
+
example['x-scalar-disabled-properties'] = states;
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
example['x-disabled'] = payload.isDisabled;
|
|
141
|
+
delete example['x-scalar-disabled-properties'];
|
|
142
|
+
}
|
|
121
143
|
return;
|
|
122
144
|
}
|
|
123
145
|
// We are adding a new parameter
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tag.d.ts","sourceRoot":"","sources":["../../src/mutators/tag.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AASzD;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,GAAI,OAAO,cAAc,GAAG,IAAI,EAAE,SAAS,SAAS,CAAC,gBAAgB,CAAC,SAe3F,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,OAAO,GAAI,OAAO,cAAc,GAAG,IAAI,EAAE,SAAS,SAAS,CAAC,cAAc,CAAC,SAqEvF,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,SAAS,GAAI,WAAW,cAAc,GAAG,IAAI,EAAE,SAAS,SAAS,CAAC,gBAAgB,CAAC,
|
|
1
|
+
{"version":3,"file":"tag.d.ts","sourceRoot":"","sources":["../../src/mutators/tag.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AASzD;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,GAAI,OAAO,cAAc,GAAG,IAAI,EAAE,SAAS,SAAS,CAAC,gBAAgB,CAAC,SAe3F,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,OAAO,GAAI,OAAO,cAAc,GAAG,IAAI,EAAE,SAAS,SAAS,CAAC,cAAc,CAAC,SAqEvF,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,SAAS,GAAI,WAAW,cAAc,GAAG,IAAI,EAAE,SAAS,SAAS,CAAC,gBAAgB,CAAC,SAqC/F,CAAA;AAED,eAAO,MAAM,kBAAkB,GAAI,WAAW;IAAE,KAAK,EAAE,cAAc,GAAG,IAAI,CAAA;CAAE;yBAErD,SAAS,CAAC,gBAAgB,CAAC;uBAC7B,SAAS,CAAC,cAAc,CAAC;yBACvB,SAAS,CAAC,gBAAgB,CAAC;CAEnD,CAAA"}
|
package/dist/mutators/tag.js
CHANGED
|
@@ -112,8 +112,9 @@ export const deleteTag = (workspace, payload) => {
|
|
|
112
112
|
Object.values(document.paths ?? {}).forEach((pathItemRef) => {
|
|
113
113
|
forEachPathItemOperation(pathItemRef, (_method, operationRef) => {
|
|
114
114
|
const resolvedOperation = getResolvedRef(operationRef);
|
|
115
|
-
if (!resolvedOperation)
|
|
115
|
+
if (!resolvedOperation) {
|
|
116
116
|
return;
|
|
117
|
+
}
|
|
117
118
|
if ('tags' in resolvedOperation) {
|
|
118
119
|
const plainTags = unpackProxyObject(resolvedOperation.tags, { depth: 1 });
|
|
119
120
|
resolvedOperation.tags = plainTags?.filter((tag) => tag !== payload.name);
|
|
@@ -124,8 +125,9 @@ export const deleteTag = (workspace, payload) => {
|
|
|
124
125
|
Object.values(document.webhooks ?? {}).forEach((pathItemRef) => {
|
|
125
126
|
forEachPathItemOperation(pathItemRef, (_method, operationRef) => {
|
|
126
127
|
const resolvedOperation = getResolvedRef(operationRef);
|
|
127
|
-
if (!resolvedOperation)
|
|
128
|
+
if (!resolvedOperation) {
|
|
128
129
|
return;
|
|
130
|
+
}
|
|
129
131
|
const plainTags = unpackProxyObject(resolvedOperation.tags, { depth: 1 });
|
|
130
132
|
resolvedOperation.tags = plainTags?.filter((tag) => tag !== payload.name);
|
|
131
133
|
});
|
|
@@ -6,11 +6,12 @@ import { DEFAULT_MODELS_SECTION_LABEL } from '@scalar/types/api-reference';
|
|
|
6
6
|
* Extension methods retain exact case because HTTP method tokens are case-sensitive.
|
|
7
7
|
* Normalizing COPY and copy would collapse distinct operations onto the same anchor.
|
|
8
8
|
*/
|
|
9
|
-
const getMethodId = (method) =>
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
: method
|
|
9
|
+
const getMethodId = (method) => {
|
|
10
|
+
if (!isHttpMethod(method)) {
|
|
11
|
+
return method;
|
|
12
|
+
}
|
|
13
|
+
return method === method.toLowerCase() ? method.toUpperCase() : `additionalOperations/${method}`;
|
|
14
|
+
};
|
|
14
15
|
/**
|
|
15
16
|
* Returns options for traversing an OpenAPI document, allowing customization of
|
|
16
17
|
* how IDs and slugs are generated for tags, headings, models, operations, and webhooks.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"traverse-asyncapi-document.d.ts","sourceRoot":"","sources":["../../../src/navigation/helpers/traverse-asyncapi-document.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAyB,gBAAgB,EAA2B,MAAM,4BAA4B,CAAA;
|
|
1
|
+
{"version":3,"file":"traverse-asyncapi-document.d.ts","sourceRoot":"","sources":["../../../src/navigation/helpers/traverse-asyncapi-document.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAyB,gBAAgB,EAA2B,MAAM,4BAA4B,CAAA;AAOlH,OAAO,EAAE,KAAK,iBAAiB,EAAwB,MAAM,qCAAqC,CAAA;AAOlG,OAAO,KAAK,EAKV,iBAAiB,EAGlB,MAAM,sBAAsB,CAAA;AAM7B,oFAAoF;AACpF,KAAK,wCAAwC,GAAG,gBAAgB,GAAG;IACjE,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAA;IAC3B,eAAe,CAAC,EAAE,MAAM,CAAA;CACzB,CAAA;AA0iBD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,wBAAwB,GACnC,cAAc,MAAM,EACpB,UAAU,wCAAwC,EAClD,UAAU,iBAAiB,KAC1B,iBA+HF,CAAA"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { sortByOrder } from '@scalar/helpers/array/sort-by-order';
|
|
2
2
|
import { objectKeys } from '@scalar/helpers/object/object-keys';
|
|
3
|
+
import { resolveOperationWithTraits } from '../../channel-example/resolve-operation-with-traits.js';
|
|
4
|
+
import { getNameFromRef } from '../../helpers/get-name-from-ref.js';
|
|
3
5
|
import { getResolvedRef, mergeSiblingReferences } from '../../helpers/get-resolved-ref.js';
|
|
4
6
|
import { isHidden } from '../../helpers/is-hidden.js';
|
|
5
7
|
import { unpackProxyObject } from '../../helpers/unpack-proxy.js';
|
|
@@ -40,7 +42,7 @@ const getMessageTitle = (message, messageName) => pickNonEmpty(message.title, me
|
|
|
40
42
|
/**
|
|
41
43
|
* Parses a channel JSON pointer (`#/channels/<name>`) into the key used in `document.channels`.
|
|
42
44
|
*/
|
|
43
|
-
const getChannelNameFromRef = (ref) => ref
|
|
45
|
+
const getChannelNameFromRef = (ref) => getNameFromRef(ref, ['channels']);
|
|
44
46
|
/**
|
|
45
47
|
* Resolves the channel referenced by an operation.
|
|
46
48
|
*
|
|
@@ -81,19 +83,16 @@ const resolveOperationMessageNames = (operation, channel, channelName) => {
|
|
|
81
83
|
if (operation.messages.length === 0) {
|
|
82
84
|
return [];
|
|
83
85
|
}
|
|
84
|
-
const channelScopePrefix = `#/channels/${channelName}/messages/`;
|
|
85
86
|
const names = new Set();
|
|
86
87
|
for (const messageRef of operation.messages) {
|
|
87
88
|
if (!('$ref' in messageRef)) {
|
|
88
89
|
continue;
|
|
89
90
|
}
|
|
90
91
|
// Common case: a channel-scoped reference like `#/channels/<name>/messages/<id>`.
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
continue;
|
|
96
|
-
}
|
|
92
|
+
const candidate = getNameFromRef(messageRef.$ref, ['channels', channelName, 'messages']);
|
|
93
|
+
if (candidate && channelMessages[candidate]) {
|
|
94
|
+
names.add(candidate);
|
|
95
|
+
continue;
|
|
97
96
|
}
|
|
98
97
|
// Fallback: a channel-level message that points to the same target.
|
|
99
98
|
for (const [name, entry] of Object.entries(channelMessages)) {
|
|
@@ -137,10 +136,10 @@ const sortMessages = (entries) => {
|
|
|
137
136
|
entries.sort((a, b) => a.title.localeCompare(b.title));
|
|
138
137
|
};
|
|
139
138
|
/**
|
|
140
|
-
* Builds
|
|
139
|
+
* Builds message entries beneath a channel or operation.
|
|
141
140
|
* Resolves each message ref, skips hidden messages, and sorts the result by title.
|
|
142
141
|
*/
|
|
143
|
-
const createMessageEntries = ({ channelName, channel,
|
|
142
|
+
const createMessageEntries = ({ channelName, channel, parentId, messageNames, generateId, }) => {
|
|
144
143
|
const messages = messageNames.flatMap((messageName) => {
|
|
145
144
|
const messageNode = channel.messages?.[messageName];
|
|
146
145
|
if (!messageNode) {
|
|
@@ -157,7 +156,7 @@ const createMessageEntries = ({ channelName, channel, operationId, messageNames,
|
|
|
157
156
|
type: 'asyncapi-message',
|
|
158
157
|
messageName,
|
|
159
158
|
channelName,
|
|
160
|
-
parentId
|
|
159
|
+
parentId,
|
|
161
160
|
}),
|
|
162
161
|
title: getMessageTitle(message, messageName),
|
|
163
162
|
messageName,
|
|
@@ -185,7 +184,7 @@ const createOperationEntry = ({ operationName, operation, channel, channelName,
|
|
|
185
184
|
const messageEntries = createMessageEntries({
|
|
186
185
|
channelName,
|
|
187
186
|
channel,
|
|
188
|
-
operationId,
|
|
187
|
+
parentId: operationId,
|
|
189
188
|
messageNames: resolveOperationMessageNames(operation, channel, channelName),
|
|
190
189
|
generateId,
|
|
191
190
|
});
|
|
@@ -204,7 +203,7 @@ const createOperationEntry = ({ operationName, operation, channel, channelName,
|
|
|
204
203
|
* Builds a channel navigation entry from a bucket and the operations to render under it.
|
|
205
204
|
* The same channel may appear at the document root and under each of its channel-level tags.
|
|
206
205
|
* Writes `x-scalar-order` on the source channel (when it is not a bare `$ref`) so other code can reuse the order.
|
|
207
|
-
* Returns `undefined` when the channel is hidden or
|
|
206
|
+
* Returns `undefined` when the channel is hidden or all its declared operations are hidden.
|
|
208
207
|
*/
|
|
209
208
|
const createChannelEntry = ({ bucket, operationEntries, generateId, parentId, parentTag, operationsSorter, document, }) => {
|
|
210
209
|
if (isHidden(bucket.channel)) {
|
|
@@ -229,15 +228,26 @@ const createChannelEntry = ({ bucket, operationEntries, generateId, parentId, pa
|
|
|
229
228
|
return entry ? [entry] : [];
|
|
230
229
|
});
|
|
231
230
|
sortOperations(operations, operationsSorter);
|
|
232
|
-
|
|
231
|
+
// A channel with hidden operations must not expose their messages through the fallback.
|
|
232
|
+
if (operations.length === 0 && bucket.operations.length > 0) {
|
|
233
233
|
return undefined;
|
|
234
234
|
}
|
|
235
|
+
// Keep channel-only messages reachable without duplicating messages already owned by an operation.
|
|
236
|
+
const operationMessageNames = new Set(bucket.operations.flatMap(({ operation }) => resolveOperationMessageNames(operation, bucket.channel, bucket.channelName)));
|
|
237
|
+
const messages = createMessageEntries({
|
|
238
|
+
channelName: bucket.channelName,
|
|
239
|
+
channel: bucket.channel,
|
|
240
|
+
parentId: channelId,
|
|
241
|
+
messageNames: objectKeys(bucket.channel.messages ?? {}).filter((name) => !operationMessageNames.has(name)),
|
|
242
|
+
generateId,
|
|
243
|
+
});
|
|
244
|
+
const children = [...operations, ...messages];
|
|
235
245
|
// Persist the rendered order back onto the source channel for downstream consumers.
|
|
236
246
|
// We skip channels that are stored as references, since the order should live on the target.
|
|
237
247
|
const channelNode = document.channels?.[bucket.channelName];
|
|
238
248
|
if (channelNode && !('$ref' in channelNode)) {
|
|
239
249
|
const orderedChannel = channelNode;
|
|
240
|
-
orderedChannel['x-scalar-order'] =
|
|
250
|
+
orderedChannel['x-scalar-order'] = children.map((child) => child.id);
|
|
241
251
|
}
|
|
242
252
|
return {
|
|
243
253
|
type: 'asyncapi-channel',
|
|
@@ -245,7 +255,7 @@ const createChannelEntry = ({ bucket, operationEntries, generateId, parentId, pa
|
|
|
245
255
|
title: getChannelTitle(bucket.channel, bucket.channelName),
|
|
246
256
|
channelName: bucket.channelName,
|
|
247
257
|
channelAddress: bucket.channelAddress,
|
|
248
|
-
children
|
|
258
|
+
children,
|
|
249
259
|
};
|
|
250
260
|
};
|
|
251
261
|
/**
|
|
@@ -344,10 +354,7 @@ const collectChannelBuckets = (document) => {
|
|
|
344
354
|
if (!operationNode) {
|
|
345
355
|
continue;
|
|
346
356
|
}
|
|
347
|
-
const operation = getResolvedRef(operationNode, mergeSiblingReferences);
|
|
348
|
-
if (isHidden(operation)) {
|
|
349
|
-
continue;
|
|
350
|
-
}
|
|
357
|
+
const operation = resolveOperationWithTraits(getResolvedRef(operationNode, mergeSiblingReferences));
|
|
351
358
|
const resolved = resolveOperationChannel(document, operation);
|
|
352
359
|
if (!resolved) {
|
|
353
360
|
continue;
|
|
@@ -30,7 +30,7 @@ const createOperationEntry = ({ ref, operation, method, path, generateId, parent
|
|
|
30
30
|
path: path,
|
|
31
31
|
parentId: parentId,
|
|
32
32
|
});
|
|
33
|
-
const title = operationTitleSource
|
|
33
|
+
const title = operationTitleSource !== 'path' && operation.summary?.trim() ? operation.summary : path;
|
|
34
34
|
const isDeprecated = isDeprecatedOperation(operation);
|
|
35
35
|
const examples = traverseOperationExamples(operation).map((example) => ({
|
|
36
36
|
type: 'example',
|
|
@@ -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":"AAMA,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"}
|