@scalar/workspace-store 0.54.2 → 0.54.4
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 +19 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +25 -0
- package/dist/entities/auth/schema.d.ts +105 -15
- package/dist/entities/auth/schema.d.ts.map +1 -1
- package/dist/helpers/dynamic-ref.d.ts +24 -0
- package/dist/helpers/dynamic-ref.d.ts.map +1 -0
- package/dist/helpers/dynamic-ref.js +74 -0
- package/dist/helpers/for-each-path-item-operation.d.ts +33 -0
- package/dist/helpers/for-each-path-item-operation.d.ts.map +1 -0
- package/dist/helpers/for-each-path-item-operation.js +75 -0
- package/dist/mutators/auth.d.ts.map +1 -1
- package/dist/mutators/auth.js +7 -13
- package/dist/mutators/operation/body.d.ts.map +1 -1
- package/dist/mutators/operation/body.js +3 -2
- package/dist/mutators/operation/extensions.d.ts.map +1 -1
- package/dist/mutators/operation/extensions.js +2 -1
- package/dist/mutators/operation/history.d.ts.map +1 -1
- package/dist/mutators/operation/history.js +3 -2
- package/dist/mutators/operation/operation.d.ts.map +1 -1
- package/dist/mutators/operation/operation.js +16 -16
- package/dist/mutators/operation/parameters.d.ts.map +1 -1
- package/dist/mutators/operation/parameters.js +30 -9
- package/dist/mutators/server.d.ts.map +1 -1
- package/dist/mutators/server.js +2 -1
- package/dist/mutators/tag.d.ts.map +1 -1
- package/dist/mutators/tag.js +9 -15
- package/dist/navigation/helpers/get-openapi-object.d.ts.map +1 -1
- package/dist/navigation/helpers/get-openapi-object.js +2 -1
- package/dist/navigation/helpers/traverse-paths.d.ts.map +1 -1
- package/dist/navigation/helpers/traverse-paths.js +5 -8
- package/dist/navigation/helpers/traverse-webhooks.d.ts.map +1 -1
- package/dist/navigation/helpers/traverse-webhooks.js +4 -7
- package/dist/request-example/builder/body/build-request-body.d.ts.map +1 -1
- package/dist/request-example/builder/body/build-request-body.js +81 -7
- package/dist/request-example/builder/header/de-serialize-parameter.js +37 -4
- package/dist/request-example/builder/helpers/get-example-from-schema.d.ts +4 -1
- 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 +97 -38
- package/dist/request-example/builder/security/build-request-security.d.ts.map +1 -1
- package/dist/request-example/builder/security/build-request-security.js +9 -4
- package/dist/request-example/context/get-request-example-context.d.ts.map +1 -1
- package/dist/request-example/context/get-request-example-context.js +3 -2
- package/dist/schemas/reference-config/index.d.ts +21 -3
- package/dist/schemas/reference-config/index.d.ts.map +1 -1
- package/dist/schemas/reference-config/settings.d.ts +21 -3
- package/dist/schemas/reference-config/settings.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/components.d.ts +11 -2
- package/dist/schemas/v3.1/strict/components.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/components.js +1 -1
- package/dist/schemas/v3.1/strict/openapi-document.d.ts +735 -105
- package/dist/schemas/v3.1/strict/openapi-document.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/openapi-document.js +2 -2
- package/dist/schemas/v3.1/strict/paths.d.ts +12 -2
- package/dist/schemas/v3.1/strict/paths.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/paths.js +2 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +12 -9
- package/package.json +5 -5
|
@@ -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;AAQ3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAGlD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAA;AAEzE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,6BAA6B,GACxC,OAAO,cAAc,GAAG,IAAI,EAC5B,UAAU,iBAAiB,GAAG,IAAI,EAClC,4CAA4C,UAAU,CAAC,uCAAuC,CAAC,kBA+EhG,CAAA;AA2BD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,oBAAoB,GAC/B,UAAU,iBAAiB,GAAG,IAAI,EAClC,mBAAmB,UAAU,CAAC,6BAA6B,CAAC,+NAiB7D,CAAA;AA6CD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,qBAAqB,GAChC,OAAO,cAAc,GAAG,IAAI,EAC5B,UAAU,iBAAiB,GAAG,IAAI,EAClC,iBAAiB,UAAU,CAAC,0BAA0B,CAAC,SAiDxD,CAAA;AAaD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,eAAO,MAAM,oBAAoB,GAC/B,OAAO,cAAc,GAAG,IAAI,EAC5B,UAAU,iBAAiB,GAAG,IAAI,EAClC,4BAA4B,UAAU,CAAC,6BAA6B,CAAC,SAmDtE,CAAA;AAiED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,WAAW,GACtB,OAAO,cAAc,GAAG,IAAI,EAC5B,UAAU,iBAAiB,GAAG,IAAI,EAClC,0DAA0D,UAAU,CAAC,oBAAoB,CAAC,SAuD3F,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,WAAW,GACtB,OAAO,cAAc,GAAG,IAAI,EAC5B,UAAU,iBAAiB,GAAG,IAAI,EAClC,2BAA2B,UAAU,CAAC,oBAAoB,CAAC,SAuB5D,CAAA;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,oBAAoB,GAC/B,OAAO,cAAc,GAAG,IAAI,EAC5B,UAAU,iBAAiB,GAAG,IAAI,EAClC,WAAW,UAAU,CAAC,6BAA6B,CAAC,SAmFrD,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;0CAElD,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,4 +1,5 @@
|
|
|
1
1
|
import { generateUniqueValue } from '../helpers/generate-unique-value.js';
|
|
2
|
+
import { forEachPathItemOperation, getPathItemOperation } from '../helpers/for-each-path-item-operation.js';
|
|
2
3
|
import { getResolvedRef } from '../helpers/get-resolved-ref.js';
|
|
3
4
|
import { isNonOptionalSecurityRequirement } from '../helpers/is-non-optional-security-requirement.js';
|
|
4
5
|
import { mergeObjects } from '../helpers/merge-object.js';
|
|
@@ -205,7 +206,7 @@ export const updateSelectedAuthTab = (store, document, { index, meta }) => {
|
|
|
205
206
|
return;
|
|
206
207
|
}
|
|
207
208
|
// Ensure the path/method exists in the document
|
|
208
|
-
if (meta.type === 'operation' && document.paths?.[meta.path]
|
|
209
|
+
if (meta.type === 'operation' && getPathItemOperation(document.paths?.[meta.path], meta.method) === undefined) {
|
|
209
210
|
return;
|
|
210
211
|
}
|
|
211
212
|
// Determine the target object for setting the auth tab index:
|
|
@@ -352,11 +353,8 @@ const walkSelectedSchemes = (store, document, transform) => {
|
|
|
352
353
|
});
|
|
353
354
|
};
|
|
354
355
|
apply({ type: 'document', documentName });
|
|
355
|
-
Object.entries(document.paths ?? {}).forEach(([path,
|
|
356
|
-
|
|
357
|
-
if (typeof operation !== 'object') {
|
|
358
|
-
return;
|
|
359
|
-
}
|
|
356
|
+
Object.entries(document.paths ?? {}).forEach(([path, pathItemRef]) => {
|
|
357
|
+
forEachPathItemOperation(pathItemRef, (method) => {
|
|
360
358
|
apply({ type: 'operation', documentName, path, method });
|
|
361
359
|
});
|
|
362
360
|
});
|
|
@@ -505,14 +503,10 @@ export const deleteSecurityScheme = (store, document, { names }) => {
|
|
|
505
503
|
document['security'] = filterSecuritySchemes(document['security']);
|
|
506
504
|
}
|
|
507
505
|
// -- For each path and operation, remove deleted security schemes from operation-level security and custom extension
|
|
508
|
-
Object.entries(document.paths ?? {}).forEach(([path,
|
|
509
|
-
|
|
510
|
-
if (typeof operation !== 'object') {
|
|
511
|
-
// Ignore operations that are not objects (could be undefined)
|
|
512
|
-
return;
|
|
513
|
-
}
|
|
506
|
+
Object.entries(document.paths ?? {}).forEach(([path, pathItemRef]) => {
|
|
507
|
+
forEachPathItemOperation(pathItemRef, (method, operationRef) => {
|
|
514
508
|
// Get mutable reference for the operation (could resolve $ref proxies)
|
|
515
|
-
const resolvedOperation = getResolvedRef(
|
|
509
|
+
const resolvedOperation = getResolvedRef(operationRef);
|
|
516
510
|
// Remove from operation-level security array
|
|
517
511
|
if ('security' in resolvedOperation && resolvedOperation['security']) {
|
|
518
512
|
resolvedOperation['security'] = filterSecuritySchemes(resolvedOperation['security']);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"body.d.ts","sourceRoot":"","sources":["../../../src/mutators/operation/body.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;
|
|
1
|
+
{"version":3,"file":"body.d.ts","sourceRoot":"","sources":["../../../src/mutators/operation/body.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAIrE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAoClD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,qCAAqC,GAChD,UAAU,iBAAiB,GAAG,IAAI,EAClC,mBAAmB,eAAe,CAAC,0CAA0C,CAAC,SAwB/E,CAAA;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,iCAAiC,GAC5C,UAAU,iBAAiB,GAAG,IAAI,EAClC,gCAAgC,eAAe,CAAC,oCAAoC,CAAC,SAStF,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,mCAAmC,GAC9C,UAAU,iBAAiB,GAAG,IAAI,EAClC,gCAAgC,eAAe,CAAC,wCAAwC,CAAC,SAS1F,CAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getPathItemOperation } from '../../helpers/for-each-path-item-operation.js';
|
|
1
2
|
import { getResolvedRef } from '../../helpers/get-resolved-ref.js';
|
|
2
3
|
import { unpackProxyObject } from '../../helpers/unpack-proxy.js';
|
|
3
4
|
import { isOpenApiDocument } from '../../schemas/type-guards.js';
|
|
@@ -6,7 +7,7 @@ const findOrCreateRequestBodyExample = (document, contentType, meta) => {
|
|
|
6
7
|
if (!isOpenApiDocument(document)) {
|
|
7
8
|
return null;
|
|
8
9
|
}
|
|
9
|
-
const operation = getResolvedRef(document.paths?.[meta.path]
|
|
10
|
+
const operation = getResolvedRef(getPathItemOperation(document.paths?.[meta.path], meta.method));
|
|
10
11
|
if (!operation) {
|
|
11
12
|
return null;
|
|
12
13
|
}
|
|
@@ -43,7 +44,7 @@ export const updateOperationRequestBodyContentType = (document, { meta, payload
|
|
|
43
44
|
if (!isOpenApiDocument(document)) {
|
|
44
45
|
return;
|
|
45
46
|
}
|
|
46
|
-
const operation = getResolvedRef(document.paths?.[meta.path]
|
|
47
|
+
const operation = getResolvedRef(getPathItemOperation(document.paths?.[meta.path], meta.method));
|
|
47
48
|
if (!operation) {
|
|
48
49
|
return;
|
|
49
50
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extensions.d.ts","sourceRoot":"","sources":["../../../src/mutators/operation/extensions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"extensions.d.ts","sourceRoot":"","sources":["../../../src/mutators/operation/extensions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAI/C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAGlD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,wBAAwB,GACnC,UAAU,iBAAiB,GAAG,IAAI,EAClC,mBAAmB,eAAe,CAAC,4BAA4B,CAAC,SAWjE,CAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getPathItemOperation } from '../../helpers/for-each-path-item-operation.js';
|
|
1
2
|
import { getResolvedRef } from '../../helpers/get-resolved-ref.js';
|
|
2
3
|
import { mergeObjects } from '../../helpers/merge-object.js';
|
|
3
4
|
import { isOpenApiDocument } from '../../schemas/type-guards.js';
|
|
@@ -17,7 +18,7 @@ export const updateOperationExtension = (document, { meta, payload }) => {
|
|
|
17
18
|
if (!isOpenApiDocument(document)) {
|
|
18
19
|
return;
|
|
19
20
|
}
|
|
20
|
-
const operation = getResolvedRef(document.paths?.[meta.path]
|
|
21
|
+
const operation = getResolvedRef(getPathItemOperation(document.paths?.[meta.path], meta.method));
|
|
21
22
|
if (!operation) {
|
|
22
23
|
return;
|
|
23
24
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../../src/mutators/operation/history.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAC7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;
|
|
1
|
+
{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../../src/mutators/operation/history.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAC7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAGrE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAQlD,eAAO,MAAM,oBAAoB,GAC/B,OAAO,cAAc,GAAG,IAAI,EAC5B,UAAU,iBAAiB,GAAG,IAAI,EAClC,mBAAmB,WAAW,CAAC,2BAA2B,CAAC,kBA4C5D,CAAA;AAED,eAAO,MAAM,sBAAsB,GACjC,OAAO,cAAc,GAAG,IAAI,EAC5B,UAAU,iBAAiB,GAAG,IAAI,EAClC,2BAA2B,eAAe,CAAC,0BAA0B,CAAC,SA4BvE,CAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getPathItemOperation } from '../../helpers/for-each-path-item-operation.js';
|
|
1
2
|
import { getResolvedRef } from '../../helpers/get-resolved-ref.js';
|
|
2
3
|
import { isOpenApiDocument } from '../../schemas/type-guards.js';
|
|
3
4
|
import { isContentTypeParameterObject } from '../../schemas/v3.1/strict/type-guards.js';
|
|
@@ -12,7 +13,7 @@ export const addResponseToHistory = async (store, document, { payload, meta }) =
|
|
|
12
13
|
if (!documentName || !payload) {
|
|
13
14
|
return;
|
|
14
15
|
}
|
|
15
|
-
const operation = getResolvedRef(document.paths?.[meta.path]
|
|
16
|
+
const operation = getResolvedRef(getPathItemOperation(document.paths?.[meta.path], meta.method));
|
|
16
17
|
if (!operation) {
|
|
17
18
|
return;
|
|
18
19
|
}
|
|
@@ -48,7 +49,7 @@ export const reloadOperationHistory = (store, document, { meta, index, callback
|
|
|
48
49
|
console.error('Document not found', meta.path, meta.method);
|
|
49
50
|
return;
|
|
50
51
|
}
|
|
51
|
-
const operation = getResolvedRef(document.paths?.[meta.path]
|
|
52
|
+
const operation = getResolvedRef(getPathItemOperation(document.paths?.[meta.path], meta.method));
|
|
52
53
|
if (!operation) {
|
|
53
54
|
console.error('Operation not found', meta.path, meta.method);
|
|
54
55
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../../../src/mutators/operation/operation.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;
|
|
1
|
+
{"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../../../src/mutators/operation/operation.ts"],"names":[],"mappings":"AAKA,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;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,mBAAmB,GAC9B,OAAO,cAAc,GAAG,IAAI,EAC5B,UAAU,iBAAiB,GAAG,IAAI,EAClC,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,IAoGF,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,SAiDlG,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,sBAAsB,GACjC,WAAW,cAAc,GAAG,IAAI,EAChC,+DAA+D,eAAe,CAAC,0BAA0B,CAAC,SAuE3G,CAAA"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isHttpMethod } from '@scalar/helpers/http/is-http-method';
|
|
2
2
|
import { preventPollution } from '@scalar/helpers/object/prevent-pollution';
|
|
3
3
|
import { findVariables } from '@scalar/helpers/regex/find-variables';
|
|
4
|
+
import { deletePathItemOperation, getPathItemOperation, pathItemIsEmpty, setPathItemOperation, } from '../../helpers/for-each-path-item-operation.js';
|
|
4
5
|
import { getResolvedRef } from '../../helpers/get-resolved-ref.js';
|
|
5
6
|
import { unpackProxyObject } from '../../helpers/unpack-proxy.js';
|
|
6
7
|
import { syncParametersForPathChange } from '../../mutators/operation/helpers/sync-path-parameters.js';
|
|
@@ -44,7 +45,7 @@ export const createOperation = (workspaceStore, payload) => {
|
|
|
44
45
|
preventPollution(normalizedPath);
|
|
45
46
|
preventPollution(method);
|
|
46
47
|
/** Create the operation in the document */
|
|
47
|
-
document.paths[normalizedPath]
|
|
48
|
+
setPathItemOperation(document.paths[normalizedPath], method, operation);
|
|
48
49
|
// Make sure that we are selecting the new operation server
|
|
49
50
|
const { servers } = operation;
|
|
50
51
|
const firstServer = unpackProxyObject(servers?.[0]);
|
|
@@ -91,7 +92,7 @@ export const updateOperationMeta = (store, document, { meta, payload }) => {
|
|
|
91
92
|
if (documentName === undefined) {
|
|
92
93
|
return;
|
|
93
94
|
}
|
|
94
|
-
const operation = getResolvedRef(document.paths?.[meta.path]
|
|
95
|
+
const operation = getResolvedRef(getPathItemOperation(document.paths?.[meta.path], meta.method));
|
|
95
96
|
if (!operation) {
|
|
96
97
|
console.error('Operation not found', { meta, document });
|
|
97
98
|
return;
|
|
@@ -136,7 +137,7 @@ export const updateOperationPathMethod = (document, store, { meta, payload: { me
|
|
|
136
137
|
return;
|
|
137
138
|
}
|
|
138
139
|
// Check for conflicts at the target location
|
|
139
|
-
if (document.paths?.[finalPath]
|
|
140
|
+
if (getPathItemOperation(document.paths?.[finalPath], finalMethod)) {
|
|
140
141
|
callback('conflict', blurTargetSelector);
|
|
141
142
|
return;
|
|
142
143
|
}
|
|
@@ -145,7 +146,7 @@ export const updateOperationPathMethod = (document, store, { meta, payload: { me
|
|
|
145
146
|
console.error('Document navigation missing', { document });
|
|
146
147
|
return;
|
|
147
148
|
}
|
|
148
|
-
const operation = getResolvedRef(document.paths?.[meta.path]
|
|
149
|
+
const operation = getResolvedRef(getPathItemOperation(document.paths?.[meta.path], meta.method));
|
|
149
150
|
if (!operation) {
|
|
150
151
|
console.error('Operation not found', { meta, document });
|
|
151
152
|
return;
|
|
@@ -185,13 +186,12 @@ export const updateOperationPathMethod = (document, store, { meta, payload: { me
|
|
|
185
186
|
preventPollution(meta.path);
|
|
186
187
|
preventPollution(finalMethod);
|
|
187
188
|
// Move the operation to the new location
|
|
188
|
-
document.paths[finalPath]
|
|
189
|
+
setPathItemOperation(document.paths[finalPath], finalMethod, unpackProxyObject(operation));
|
|
189
190
|
// Remove the operation from the old location
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
if (Object.keys(oldPathItems).length === 0) {
|
|
191
|
+
if (isHttpMethod(meta.method)) {
|
|
192
|
+
deletePathItemOperation(document.paths[meta.path], meta.method);
|
|
193
|
+
// If the old path is now empty, remove the path entry (path-level metadata is kept otherwise)
|
|
194
|
+
if (pathItemIsEmpty(document.paths[meta.path])) {
|
|
195
195
|
delete document.paths[meta.path];
|
|
196
196
|
}
|
|
197
197
|
}
|
|
@@ -217,9 +217,9 @@ export const deleteOperation = (workspace, { meta, documentName }) => {
|
|
|
217
217
|
}
|
|
218
218
|
preventPollution(meta.path);
|
|
219
219
|
preventPollution(meta.method);
|
|
220
|
-
|
|
221
|
-
// If the path
|
|
222
|
-
if (
|
|
220
|
+
deletePathItemOperation(document.paths?.[meta.path], meta.method);
|
|
221
|
+
// If the path is now empty, remove the path entry (path-level metadata is kept otherwise)
|
|
222
|
+
if (pathItemIsEmpty(document.paths?.[meta.path])) {
|
|
223
223
|
delete document.paths?.[meta.path];
|
|
224
224
|
}
|
|
225
225
|
};
|
|
@@ -236,7 +236,7 @@ export const createOperationDraftExample = (workspace, { meta: { path, method },
|
|
|
236
236
|
console.error('Document not found', { documentName });
|
|
237
237
|
return;
|
|
238
238
|
}
|
|
239
|
-
const operation = getResolvedRef(document.paths?.[path]
|
|
239
|
+
const operation = getResolvedRef(getPathItemOperation(document.paths?.[path], method));
|
|
240
240
|
if (!operation) {
|
|
241
241
|
console.error('Operation not found', { path, method });
|
|
242
242
|
return;
|
|
@@ -264,7 +264,7 @@ export const deleteOperationExample = (workspace, { meta: { path, method, exampl
|
|
|
264
264
|
return;
|
|
265
265
|
}
|
|
266
266
|
// Get the operation object for the given path and method
|
|
267
|
-
const operation = getResolvedRef(document.paths?.[path]
|
|
267
|
+
const operation = getResolvedRef(getPathItemOperation(document.paths?.[path], method));
|
|
268
268
|
if (!operation) {
|
|
269
269
|
return;
|
|
270
270
|
}
|
|
@@ -314,7 +314,7 @@ export const renameOperationExample = (workspace, { meta: { path, method, exampl
|
|
|
314
314
|
if (!isOpenApiDocument(document)) {
|
|
315
315
|
return;
|
|
316
316
|
}
|
|
317
|
-
const operation = getResolvedRef(document.paths?.[path]
|
|
317
|
+
const operation = getResolvedRef(getPathItemOperation(document.paths?.[path], method));
|
|
318
318
|
if (!operation) {
|
|
319
319
|
return;
|
|
320
320
|
}
|
|
@@ -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;AAIrE,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,SAkD1F,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,SAanE,CAAA"}
|
|
@@ -1,6 +1,25 @@
|
|
|
1
|
+
import { getPathItemOperation } from '../../helpers/for-each-path-item-operation.js';
|
|
1
2
|
import { getResolvedRef } from '../../helpers/get-resolved-ref.js';
|
|
2
3
|
import { unpackProxyObject } from '../../helpers/unpack-proxy.js';
|
|
3
4
|
import { isOpenApiDocument } from '../../schemas/type-guards.js';
|
|
5
|
+
const getPathItemsForParameterMutation = (pathItemRef) => {
|
|
6
|
+
if (!pathItemRef || typeof pathItemRef !== 'object') {
|
|
7
|
+
return [];
|
|
8
|
+
}
|
|
9
|
+
if ('$ref' in pathItemRef) {
|
|
10
|
+
const targets = [];
|
|
11
|
+
const refWrapper = pathItemRef;
|
|
12
|
+
if (refWrapper.parameters !== undefined) {
|
|
13
|
+
targets.push(refWrapper);
|
|
14
|
+
}
|
|
15
|
+
const resolved = getResolvedRef(pathItemRef);
|
|
16
|
+
if (resolved) {
|
|
17
|
+
targets.push(resolved);
|
|
18
|
+
}
|
|
19
|
+
return targets;
|
|
20
|
+
}
|
|
21
|
+
return [pathItemRef];
|
|
22
|
+
};
|
|
4
23
|
/**
|
|
5
24
|
* Updates an existing parameter of a given `type` by its index within that
|
|
6
25
|
* type subset (e.g. the N-th query parameter). Supports updating name, value,
|
|
@@ -42,7 +61,7 @@ export const upsertOperationParameter = (document, { meta, type, payload, origin
|
|
|
42
61
|
if (!isOpenApiDocument(document)) {
|
|
43
62
|
return;
|
|
44
63
|
}
|
|
45
|
-
const operation = getResolvedRef(document.paths?.[meta.path]
|
|
64
|
+
const operation = getResolvedRef(getPathItemOperation(document.paths?.[meta.path], meta.method));
|
|
46
65
|
if (!operation) {
|
|
47
66
|
console.error('Operation not found', { meta, document });
|
|
48
67
|
return;
|
|
@@ -84,7 +103,7 @@ export const updateOperationExtraParameters = (document, { type, meta, payload,
|
|
|
84
103
|
return;
|
|
85
104
|
}
|
|
86
105
|
// Resolve the referenced operation from the document using the path and method
|
|
87
|
-
const operation = getResolvedRef(document.paths?.[meta.path]
|
|
106
|
+
const operation = getResolvedRef(getPathItemOperation(document.paths?.[meta.path], meta.method));
|
|
88
107
|
if (!operation) {
|
|
89
108
|
return;
|
|
90
109
|
}
|
|
@@ -130,7 +149,7 @@ export const deleteOperationParameter = (document, { meta, originalParameter })
|
|
|
130
149
|
if (!isOpenApiDocument(document)) {
|
|
131
150
|
return;
|
|
132
151
|
}
|
|
133
|
-
const operation = getResolvedRef(document.paths?.[meta.path]
|
|
152
|
+
const operation = getResolvedRef(getPathItemOperation(document.paths?.[meta.path], meta.method));
|
|
134
153
|
// Lets check if its on the operation first as its more likely
|
|
135
154
|
const operationIndex = operation?.parameters?.findIndex((it) => getResolvedRef(it) === originalParameter) ?? -1;
|
|
136
155
|
// We cannot call splice on a proxy object, so we unwrap the array and filter it
|
|
@@ -138,11 +157,13 @@ export const deleteOperationParameter = (document, { meta, originalParameter })
|
|
|
138
157
|
operation.parameters = unpackProxyObject(operation.parameters?.filter((_, i) => i !== operationIndex), { depth: 1 });
|
|
139
158
|
return;
|
|
140
159
|
}
|
|
141
|
-
// If it wasn't on the operation it might be on the path
|
|
142
|
-
const path
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
160
|
+
// If it wasn't on the operation it might be on the path (wrapper siblings or $ref-value)
|
|
161
|
+
for (const path of getPathItemsForParameterMutation(document.paths?.[meta.path])) {
|
|
162
|
+
const pathIndex = path.parameters?.findIndex((parameter) => getResolvedRef(parameter) === originalParameter) ?? -1;
|
|
163
|
+
if (pathIndex >= 0) {
|
|
164
|
+
path.parameters = unpackProxyObject(path.parameters?.filter((_, i) => i !== pathIndex), { depth: 1 });
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
146
167
|
}
|
|
147
168
|
};
|
|
148
169
|
/**
|
|
@@ -162,7 +183,7 @@ export const deleteAllOperationParameters = (document, { meta, type }) => {
|
|
|
162
183
|
if (!isOpenApiDocument(document)) {
|
|
163
184
|
return;
|
|
164
185
|
}
|
|
165
|
-
const operation = getResolvedRef(document.paths?.[meta.path]
|
|
186
|
+
const operation = getResolvedRef(getPathItemOperation(document.paths?.[meta.path], meta.method));
|
|
166
187
|
if (!operation) {
|
|
167
188
|
return;
|
|
168
189
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/mutators/server.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,4BAA4B,CAAA;AAE9E,OAAO,KAAK,EAAE,YAAY,EAAc,MAAM,6BAA6B,CAAA;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/mutators/server.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,4BAA4B,CAAA;AAE9E,OAAO,KAAK,EAAE,YAAY,EAAc,MAAM,6BAA6B,CAAA;AAM3E,OAAO,EAAE,KAAK,YAAY,EAAsB,MAAM,wCAAwC,CAAA;AAC9F,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAyB5D;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAC5B,UAAU,iBAAiB,GAAG,IAAI,EAClC,UAAU,YAAY,CAAC,2BAA2B,CAAC,+BAUpD,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,SAAS,GACpB,UAAU,iBAAiB,GAAG,IAAI,EAClC,uBAAuB,YAAY,CAAC,mBAAmB,CAAC,KACvD,YAAY,GAAG,SAmBjB,CAAA;AAgFD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,YAAY,GACvB,UAAU,iBAAiB,GAAG,IAAI,EAClC,yBAAyB,YAAY,CAAC,sBAAsB,CAAC,KAC5D,YAAY,GAAG,SAgCjB,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,GACvB,UAAU,iBAAiB,GAAG,IAAI,EAClC,iBAAiB,YAAY,CAAC,sBAAsB,CAAC,SAatD,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAI,UAAU,iBAAiB,GAAG,IAAI,EAAE,UAAU,YAAY,CAAC,sBAAsB,CAAC,SAS9G,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,qBAAqB,GAChC,UAAU,iBAAiB,GAAG,IAAI,EAClC,6BAA6B,YAAY,CAAC,yBAAyB,CAAC,sFAWrE,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,GAC/B,UAAU,iBAAiB,GAAG,IAAI,EAClC,eAAe,YAAY,CAAC,wBAAwB,CAAC,KACpD,MAAM,GAAG,SAaX,CAAA;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,4BAA4B,GACvC,UAAU,iBAAiB,GAAG,IAAI,EAClC,UAAU,YAAY,CAAC,iCAAiC,CAAC,KACxD,MAAM,GAAG,SAOX,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,6BAA6B,GACxC,UAAU,iBAAiB,GAAG,IAAI,EAClC,sBAAsB,YAAY,CAAC,kCAAkC,CAAC,KACrE,4BAA4B,GAAG,SAcjC,CAAA;AAED,eAAO,MAAM,qBAAqB,GAAI,cAAc;IAAE,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAAA;CAAE;iCAEzD,YAAY,CAAC,2BAA2B,CAAC;yBACjD,YAAY,CAAC,mBAAmB,CAAC;4BAC9B,YAAY,CAAC,sBAAsB,CAAC;4BACpC,YAAY,CAAC,sBAAsB,CAAC;4BACpC,YAAY,CAAC,sBAAsB,CAAC;qCAC3B,YAAY,CAAC,yBAAyB,CAAC;oCAExC,YAAY,CAAC,wBAAwB,CAAC;4CAC9B,YAAY,CAAC,iCAAiC,CAAC;6CAE9C,YAAY,CAAC,kCAAkC,CAAC;CAG5F,CAAA"}
|
package/dist/mutators/server.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { findVariables } from '@scalar/helpers/regex/find-variables';
|
|
2
|
+
import { getPathItemOperation } from '../helpers/for-each-path-item-operation.js';
|
|
2
3
|
import { getResolvedRef } from '../helpers/get-resolved-ref.js';
|
|
3
4
|
import { unpackProxyObject } from '../helpers/unpack-proxy.js';
|
|
4
5
|
import { isAsyncApiDocument, isOpenApiDocument } from '../schemas/type-guards.js';
|
|
@@ -15,7 +16,7 @@ const getServerTarget = (document, meta) => {
|
|
|
15
16
|
if (meta.type === 'document') {
|
|
16
17
|
return document;
|
|
17
18
|
}
|
|
18
|
-
return getResolvedRef(document.paths?.[meta.path]
|
|
19
|
+
return getResolvedRef(getPathItemOperation(document.paths?.[meta.path], meta.method)) ?? null;
|
|
19
20
|
};
|
|
20
21
|
/**
|
|
21
22
|
* Initializes the servers for the document or operation based on meta.
|
|
@@ -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;
|
|
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,SA+B/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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { forEachPathItemOperation, getPathItemOperation } from '../helpers/for-each-path-item-operation.js';
|
|
1
2
|
import { getResolvedRef } from '../helpers/get-resolved-ref.js';
|
|
2
3
|
import { unpackProxyObject } from '../helpers/unpack-proxy.js';
|
|
3
4
|
import { getNavigationOptions } from '../navigation/get-navigation-options.js';
|
|
@@ -55,7 +56,7 @@ export const editTag = (store, payload) => {
|
|
|
55
56
|
payload.tag.children?.forEach((child) => {
|
|
56
57
|
// Operation
|
|
57
58
|
if (child.type === 'operation') {
|
|
58
|
-
const operation = getResolvedRef(document.paths?.[child.path]
|
|
59
|
+
const operation = getResolvedRef(getPathItemOperation(document.paths?.[child.path], child.method));
|
|
59
60
|
if (operation && 'tags' in operation) {
|
|
60
61
|
const plainTags = unpackProxyObject(operation.tags, { depth: null });
|
|
61
62
|
operation.tags = plainTags?.map((tag) => (tag === oldName ? newName : tag));
|
|
@@ -63,7 +64,7 @@ export const editTag = (store, payload) => {
|
|
|
63
64
|
}
|
|
64
65
|
// Webhook
|
|
65
66
|
else if (child.type === 'webhook') {
|
|
66
|
-
const webhook = getResolvedRef(document.webhooks?.[child.name]
|
|
67
|
+
const webhook = getResolvedRef(getPathItemOperation(document.webhooks?.[child.name], child.method));
|
|
67
68
|
if (webhook && 'tags' in webhook) {
|
|
68
69
|
const plainTags = unpackProxyObject(webhook.tags, { depth: null });
|
|
69
70
|
webhook.tags = plainTags?.map((tag) => (tag === oldName ? newName : tag));
|
|
@@ -108,13 +109,9 @@ export const deleteTag = (workspace, payload) => {
|
|
|
108
109
|
return;
|
|
109
110
|
}
|
|
110
111
|
// Clear tags from all operations that have this tag
|
|
111
|
-
Object.values(document.paths ?? {}).forEach((
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
if (typeof operation !== 'object' || Array.isArray(operation)) {
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
const resolvedOperation = getResolvedRef(operation);
|
|
112
|
+
Object.values(document.paths ?? {}).forEach((pathItemRef) => {
|
|
113
|
+
forEachPathItemOperation(pathItemRef, (_method, operationRef) => {
|
|
114
|
+
const resolvedOperation = getResolvedRef(operationRef);
|
|
118
115
|
if ('tags' in resolvedOperation) {
|
|
119
116
|
const plainTags = unpackProxyObject(resolvedOperation.tags, { depth: 1 });
|
|
120
117
|
resolvedOperation.tags = plainTags?.filter((tag) => tag !== payload.name);
|
|
@@ -122,12 +119,9 @@ export const deleteTag = (workspace, payload) => {
|
|
|
122
119
|
});
|
|
123
120
|
});
|
|
124
121
|
// Remove the tag from all webhooks that have this tag
|
|
125
|
-
Object.values(document.webhooks ?? {}).forEach((
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
const resolvedOperation = getResolvedRef(operation);
|
|
122
|
+
Object.values(document.webhooks ?? {}).forEach((pathItemRef) => {
|
|
123
|
+
forEachPathItemOperation(pathItemRef, (_method, operationRef) => {
|
|
124
|
+
const resolvedOperation = getResolvedRef(operationRef);
|
|
131
125
|
const plainTags = unpackProxyObject(resolvedOperation.tags, { depth: 1 });
|
|
132
126
|
resolvedOperation.tags = plainTags?.filter((tag) => tag !== payload.name);
|
|
133
127
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-openapi-object.d.ts","sourceRoot":"","sources":["../../../src/navigation/helpers/get-openapi-object.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"get-openapi-object.d.ts","sourceRoot":"","sources":["../../../src/navigation/helpers/get-openapi-object.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAG9C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAE/G,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAA;AAIxF,KAAK,kBAAkB,GAAG,iBAAiB,GAAG,YAAY,GAAG,kBAAkB,CAAA;AAE/E,KAAK,gBAAgB,CAAC,KAAK,SAAS,kBAAkB,IAAI,KAAK,SAAS,iBAAiB,GACrF,iBAAiB,GACjB,KAAK,SAAS,YAAY,GACxB,SAAS,GACT,KAAK,SAAS,kBAAkB,GAC9B,eAAe,GACf,KAAK,CAAA;AAEb,0EAA0E;AAC1E,eAAO,MAAM,YAAY,GAAI,OAAO,cAAc,KAAG,KAAK,IAAI,kBACmB,CAAA;AAEjF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,gBAAgB,GAAI,KAAK,SAAS,kBAAkB,EAAE,mBAGhE;IACD,KAAK,EAAE,cAAc,CAAA;IACrB,KAAK,EAAE,KAAK,CAAA;CACb,KAAG,gBAAgB,CAAC,KAAK,CAAC,GAAG,IAoC7B,CAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getPathItemOperation } from '../../helpers/for-each-path-item-operation.js';
|
|
1
2
|
import { getResolvedRef } from '../../helpers/get-resolved-ref.js';
|
|
2
3
|
import { isOpenApiDocument } from '../../schemas/type-guards.js';
|
|
3
4
|
import { getParentEntry } from './get-parent-entry.js';
|
|
@@ -46,7 +47,7 @@ export const getOpenapiObject = ({ store, entry, }) => {
|
|
|
46
47
|
}
|
|
47
48
|
if (entry.type === 'operation') {
|
|
48
49
|
// Fetch and resolve the referenced operation object at the given path/method
|
|
49
|
-
return getResolvedRef(document.paths?.[entry.path]
|
|
50
|
+
return (getResolvedRef(getPathItemOperation(document.paths?.[entry.path], entry.method)) ?? null);
|
|
50
51
|
}
|
|
51
52
|
// If entry type is unknown, return null
|
|
52
53
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"traverse-paths.d.ts","sourceRoot":"","sources":["../../../src/navigation/helpers/traverse-paths.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"traverse-paths.d.ts","sourceRoot":"","sources":["../../../src/navigation/helpers/traverse-paths.ts"],"names":[],"mappings":"AAOA,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;AAI9F,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;CA0D7C,CAAA"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { isHttpMethod } from '@scalar/helpers/http/is-http-method';
|
|
2
|
-
import { objectKeys } from '@scalar/helpers/object/object-keys';
|
|
3
1
|
import { escapeJsonPointer } from '@scalar/json-magic/helpers/escape-json-pointer';
|
|
2
|
+
import { forEachPathItemOperation } from '../../helpers/for-each-path-item-operation.js';
|
|
4
3
|
import { getResolvedRef, mergeSiblingReferences } from '../../helpers/get-resolved-ref.js';
|
|
5
4
|
import { isHidden } from '../../helpers/is-hidden.js';
|
|
6
5
|
import { traverseOperationExamples } from '../../navigation/helpers/traverse-examples.js';
|
|
@@ -74,16 +73,14 @@ const createOperationEntry = ({ ref, operation, method, path, generateId, parent
|
|
|
74
73
|
export const traversePaths = ({ document, tagsMap, generateId, documentId, operationTitleSource, }) => {
|
|
75
74
|
const untaggedOperations = [];
|
|
76
75
|
// Traverse paths
|
|
77
|
-
Object.entries(document.paths ?? {}).forEach(([path,
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
const _operation = pathItemObject?.[method];
|
|
81
|
-
const operation = getResolvedRef(_operation, mergeSiblingReferences);
|
|
76
|
+
Object.entries(document.paths ?? {}).forEach(([path, pathItemRef]) => {
|
|
77
|
+
forEachPathItemOperation(pathItemRef, (method, operationRef) => {
|
|
78
|
+
const operation = getResolvedRef(operationRef, mergeSiblingReferences);
|
|
82
79
|
if (!operation) {
|
|
83
80
|
return;
|
|
84
81
|
}
|
|
85
82
|
// Skip if the operation is internal or scalar-ignore
|
|
86
|
-
if (isHidden(operation)
|
|
83
|
+
if (isHidden(operation)) {
|
|
87
84
|
return;
|
|
88
85
|
}
|
|
89
86
|
const ref = `#/paths/${escapeJsonPointer(path)}/${method}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"traverse-webhooks.d.ts","sourceRoot":"","sources":["../../../src/navigation/helpers/traverse-webhooks.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"traverse-webhooks.d.ts","sourceRoot":"","sources":["../../../src/navigation/helpers/traverse-webhooks.ts"],"names":[],"mappings":"AAMA,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;AA2DzG;;;;;;;;;;;;;;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,EAuDnB,CAAA"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { objectKeys } from '@scalar/helpers/object/object-keys';
|
|
1
|
+
import { forEachPathItemOperation } from '../../helpers/for-each-path-item-operation.js';
|
|
3
2
|
import { getResolvedRef, mergeSiblingReferences } from '../../helpers/get-resolved-ref.js';
|
|
4
3
|
import { isHidden } from '../../helpers/is-hidden.js';
|
|
5
4
|
import { isDeprecatedOperation } from '../../navigation/helpers/traverse-paths.js';
|
|
@@ -53,11 +52,9 @@ const createWebhookEntry = ({ ref, method, name, title, generateId, parentTag, w
|
|
|
53
52
|
export const traverseWebhooks = ({ document, tagsMap, generateId, untaggedWebhooksParentId, documentId, }) => {
|
|
54
53
|
const untagged = [];
|
|
55
54
|
// Traverse webhooks
|
|
56
|
-
Object.entries(document.webhooks ?? {}).forEach(([name,
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const _operation = pathItemObject?.[method];
|
|
60
|
-
const operation = getResolvedRef(_operation, mergeSiblingReferences);
|
|
55
|
+
Object.entries(document.webhooks ?? {}).forEach(([name, pathItemRef]) => {
|
|
56
|
+
forEachPathItemOperation(pathItemRef, (method, operationRef) => {
|
|
57
|
+
const operation = getResolvedRef(operationRef, mergeSiblingReferences);
|
|
61
58
|
if (!operation) {
|
|
62
59
|
return;
|
|
63
60
|
}
|
|
@@ -1 +1 @@
|
|
|
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;AAOjG,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;KACd,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;AAED,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,GAAG,QAAQ,GAAG,UAAU,GAAG,GAAG,CAAA;
|
|
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;AAOjG,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;KACd,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;AAED,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,GAAG,QAAQ,GAAG,UAAU,GAAG,GAAG,CAAA;AA2GrD;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAC3B,aAAa,iBAAiB,GAAG,SAAS;AAC1C,qCAAqC;AACrC,oBAAuB;AACvB,sEAAsE;AACtE,kCAAkC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KACvD,WAAW,GAAG,IA2RhB,CAAA"}
|