@skmtc/core 0.35.1 → 0.35.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/esm/context/StackTrail.js +3 -13
- package/esm/context/documentTrail.d.ts +17 -0
- package/esm/context/documentTrail.js +28 -0
- package/esm/parse/isPlainObject.d.ts +2 -0
- package/esm/parse/isPlainObject.js +2 -0
- package/esm/parse/pathParameters.d.ts +57 -0
- package/esm/parse/pathParameters.js +138 -0
- package/esm/parse/securityRequirements.d.ts +63 -0
- package/esm/parse/securityRequirements.js +128 -0
- package/esm/parse/toComponentEntries.js +1 -2
- package/esm/parse/v3-0/document/toDocumentFieldsV3.js +21 -7
- package/esm/parse/v3-0/operation/toOperationsV3.js +7 -1
- package/esm/parse/v3-0/parameter/toParameterV3.d.ts +7 -0
- package/esm/parse/v3-0/parameter/toParameterV3.js +19 -11
- package/esm/parse/v3-0/pathItem/toPathItemV3.d.ts +7 -1
- package/esm/parse/v3-0/pathItem/toPathItemV3.js +5 -3
- package/esm/parse/v3-0/securityRequirement/toSecurityRequirement.d.ts +2 -1
- package/esm/parse/v3-0/securityRequirement/toSecurityRequirement.js +2 -4
- package/esm/parse/v3-0/webhook/toWebhooksV3.js +7 -1
- package/esm/parse/v3-1/document/toDocumentFieldsV3.js +21 -7
- package/esm/parse/v3-1/operation/toOperationsV3.js +7 -1
- package/esm/parse/v3-1/parameter/toParameterV3.d.ts +7 -0
- package/esm/parse/v3-1/parameter/toParameterV3.js +19 -11
- package/esm/parse/v3-1/pathItem/toPathItemV3.d.ts +7 -1
- package/esm/parse/v3-1/pathItem/toPathItemV3.js +5 -3
- package/esm/parse/v3-1/securityRequirement/toSecurityRequirement.d.ts +2 -1
- package/esm/parse/v3-1/securityRequirement/toSecurityRequirement.js +2 -4
- package/esm/parse/v3-1/webhook/toWebhooksV3.js +7 -1
- package/esm/parse/v3-2/document/toDocumentFieldsV3.js +21 -7
- package/esm/parse/v3-2/operation/toOperationsV3.js +11 -10
- package/esm/parse/v3-2/parameter/toParameterV3.d.ts +7 -0
- package/esm/parse/v3-2/parameter/toParameterV3.js +30 -24
- package/esm/parse/v3-2/pathItem/toPathItemV3.d.ts +6 -13
- package/esm/parse/v3-2/pathItem/toPathItemV3.js +5 -30
- package/esm/parse/v3-2/securityRequirement/toSecurityRequirement.d.ts +2 -1
- package/esm/parse/v3-2/securityRequirement/toSecurityRequirement.js +2 -4
- package/esm/parse/v3-2/webhook/toWebhooksV3.js +11 -10
- package/package.json +1 -1
- package/script/context/StackTrail.js +3 -13
- package/script/context/documentTrail.d.ts +17 -0
- package/script/context/documentTrail.js +34 -0
- package/script/parse/isPlainObject.d.ts +2 -0
- package/script/parse/isPlainObject.js +4 -1
- package/script/parse/pathParameters.d.ts +57 -0
- package/script/parse/pathParameters.js +144 -0
- package/script/parse/securityRequirements.d.ts +63 -0
- package/script/parse/securityRequirements.js +134 -0
- package/script/parse/toComponentEntries.js +1 -2
- package/script/parse/v3-0/document/toDocumentFieldsV3.js +21 -7
- package/script/parse/v3-0/operation/toOperationsV3.js +7 -1
- package/script/parse/v3-0/parameter/toParameterV3.d.ts +7 -0
- package/script/parse/v3-0/parameter/toParameterV3.js +22 -13
- package/script/parse/v3-0/pathItem/toPathItemV3.d.ts +7 -1
- package/script/parse/v3-0/pathItem/toPathItemV3.js +4 -2
- package/script/parse/v3-0/securityRequirement/toSecurityRequirement.d.ts +2 -1
- package/script/parse/v3-0/securityRequirement/toSecurityRequirement.js +2 -4
- package/script/parse/v3-0/webhook/toWebhooksV3.js +7 -1
- package/script/parse/v3-1/document/toDocumentFieldsV3.js +21 -7
- package/script/parse/v3-1/operation/toOperationsV3.js +7 -1
- package/script/parse/v3-1/parameter/toParameterV3.d.ts +7 -0
- package/script/parse/v3-1/parameter/toParameterV3.js +22 -13
- package/script/parse/v3-1/pathItem/toPathItemV3.d.ts +7 -1
- package/script/parse/v3-1/pathItem/toPathItemV3.js +4 -2
- package/script/parse/v3-1/securityRequirement/toSecurityRequirement.d.ts +2 -1
- package/script/parse/v3-1/securityRequirement/toSecurityRequirement.js +2 -4
- package/script/parse/v3-1/webhook/toWebhooksV3.js +7 -1
- package/script/parse/v3-2/document/toDocumentFieldsV3.js +21 -7
- package/script/parse/v3-2/operation/toOperationsV3.js +10 -9
- package/script/parse/v3-2/parameter/toParameterV3.d.ts +7 -0
- package/script/parse/v3-2/parameter/toParameterV3.js +33 -26
- package/script/parse/v3-2/pathItem/toPathItemV3.d.ts +6 -13
- package/script/parse/v3-2/pathItem/toPathItemV3.js +5 -31
- package/script/parse/v3-2/securityRequirement/toSecurityRequirement.d.ts +2 -1
- package/script/parse/v3-2/securityRequirement/toSecurityRequirement.js +2 -4
- package/script/parse/v3-2/webhook/toWebhooksV3.js +10 -9
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { OpenAPIV3 } from 'openapi-types';
|
|
2
2
|
import type { ParseContextType } from '../../../context/parseTypes.js';
|
|
3
|
+
import type { BrokenPathParameter } from '../../pathParameters.js';
|
|
3
4
|
import { OasPathItem } from '../../../oas/pathItem/PathItem.js';
|
|
4
5
|
import type { StackTrail } from '../../../context/StackTrail.js';
|
|
5
6
|
export type ToPathItemV3Args = {
|
|
@@ -7,17 +8,9 @@ export type ToPathItemV3Args = {
|
|
|
7
8
|
stackTrail: StackTrail;
|
|
8
9
|
context: ParseContextType;
|
|
9
10
|
};
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
} | {
|
|
15
|
-
valid: false;
|
|
11
|
+
export type PathItemV3 = {
|
|
12
|
+
pathItem: OasPathItem;
|
|
13
|
+
/** Path-level parameters that failed to parse; the caller drops each operation they apply to. */
|
|
14
|
+
brokenParameters: BrokenPathParameter[];
|
|
16
15
|
};
|
|
17
|
-
|
|
18
|
-
* Parses a path item's shared fields without letting a throw escape. A
|
|
19
|
-
* path-level parameter that fails validation (for example `in: body`) logs
|
|
20
|
-
* one `INVALID_OPERATION` at the path and returns `{ valid: false }`, so
|
|
21
|
-
* the caller skips that path and keeps the rest.
|
|
22
|
-
*/
|
|
23
|
-
export declare const toPathItemResultV3: ({ pathItem, stackTrail, context }: ToPathItemV3Args) => PathItemResult;
|
|
16
|
+
export declare const toPathItemV3: ({ pathItem, stackTrail, context }: ToPathItemV3Args) => PathItemV3;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.toPathItemV3 = void 0;
|
|
4
4
|
const toParameterV3_js_1 = require("../parameter/toParameterV3.js");
|
|
5
5
|
const PathItem_js_1 = require("../../../oas/pathItem/PathItem.js");
|
|
6
6
|
const toServerV3_js_1 = require("../server/toServerV3.js");
|
|
7
7
|
const tryParseAt_js_1 = require("../../../context/tryParseAt.js");
|
|
8
8
|
const toSpecificationExtensionsV3_js_1 = require("../specificationExtensions/toSpecificationExtensionsV3.js");
|
|
9
|
-
const isEmpty_js_1 = require("../../../helpers/isEmpty.js");
|
|
10
9
|
const toPathItemV3 = ({ pathItem, stackTrail, context }) => {
|
|
11
10
|
const { summary, description, parameters, servers, ...skipped } = pathItem;
|
|
12
|
-
|
|
11
|
+
const pathParameters = stackTrail.trace('parameters', st => (0, toParameterV3_js_1.toPathParameterListV3)({ parameters, stackTrail: st, context }));
|
|
12
|
+
const oasPathItem = new PathItem_js_1.OasPathItem({
|
|
13
13
|
summary,
|
|
14
14
|
description,
|
|
15
|
-
parameters:
|
|
15
|
+
parameters: pathParameters.parameters,
|
|
16
16
|
servers: (0, tryParseAt_js_1.tryParseAt)({
|
|
17
17
|
stackTrail,
|
|
18
18
|
key: 'servers',
|
|
@@ -29,32 +29,6 @@ const toPathItemV3 = ({ pathItem, stackTrail, context }) => {
|
|
|
29
29
|
parentType: 'pathItem'
|
|
30
30
|
})
|
|
31
31
|
});
|
|
32
|
+
return { pathItem: oasPathItem, brokenParameters: pathParameters.broken };
|
|
32
33
|
};
|
|
33
34
|
exports.toPathItemV3 = toPathItemV3;
|
|
34
|
-
/**
|
|
35
|
-
* Parses a path item's shared fields without letting a throw escape. A
|
|
36
|
-
* path-level parameter that fails validation (for example `in: body`) logs
|
|
37
|
-
* one `INVALID_OPERATION` at the path and returns `{ valid: false }`, so
|
|
38
|
-
* the caller skips that path and keeps the rest.
|
|
39
|
-
*/
|
|
40
|
-
const toPathItemResultV3 = ({ pathItem, stackTrail, context }) => {
|
|
41
|
-
if ((0, isEmpty_js_1.isEmpty)(pathItem)) {
|
|
42
|
-
return { valid: true, pathItem: undefined };
|
|
43
|
-
}
|
|
44
|
-
try {
|
|
45
|
-
return { valid: true, pathItem: (0, exports.toPathItemV3)({ pathItem, stackTrail, context }) };
|
|
46
|
-
}
|
|
47
|
-
catch (error) {
|
|
48
|
-
const normalized = error instanceof Error ? error : new Error(String(error));
|
|
49
|
-
context.logIssueNoKey({
|
|
50
|
-
parent: pathItem,
|
|
51
|
-
level: 'error',
|
|
52
|
-
message: normalized.message,
|
|
53
|
-
cause: normalized,
|
|
54
|
-
stackTrail,
|
|
55
|
-
type: 'INVALID_OPERATION'
|
|
56
|
-
});
|
|
57
|
-
return { valid: false };
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
exports.toPathItemResultV3 = toPathItemResultV3;
|
|
@@ -2,7 +2,8 @@ import type { ParseContextType } from '../../../context/parseTypes.js';
|
|
|
2
2
|
import { OasSecurityRequirement } from '../../../oas/securityRequirement/SecurityRequirement.js';
|
|
3
3
|
import type { StackTrail } from '../../../context/StackTrail.js';
|
|
4
4
|
export type ToSecurityRequirementsV3Args = {
|
|
5
|
-
security
|
|
5
|
+
/** Raw `security`; malformed input throws (see `toSecurityRequirementObjects`). */
|
|
6
|
+
security: unknown;
|
|
6
7
|
stackTrail: StackTrail;
|
|
7
8
|
context: ParseContextType;
|
|
8
9
|
};
|
|
@@ -2,11 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.toSecurityRequirementsV3 = void 0;
|
|
4
4
|
const SecurityRequirement_js_1 = require("../../../oas/securityRequirement/SecurityRequirement.js");
|
|
5
|
+
const securityRequirements_js_1 = require("../../securityRequirements.js");
|
|
5
6
|
const toSecurityRequirementsV3 = ({ security, stackTrail, context }) => {
|
|
6
|
-
|
|
7
|
-
return undefined;
|
|
8
|
-
}
|
|
9
|
-
return security.map(requirement => {
|
|
7
|
+
return (0, securityRequirements_js_1.toSecurityRequirementObjects)(security)?.map(requirement => {
|
|
10
8
|
return new SecurityRequirement_js_1.OasSecurityRequirement({ requirement }, context.oasDocument);
|
|
11
9
|
});
|
|
12
10
|
};
|
|
@@ -6,6 +6,7 @@ const toResponseV3_js_1 = require("../response/toResponseV3.js");
|
|
|
6
6
|
const toParameterV3_js_1 = require("../parameter/toParameterV3.js");
|
|
7
7
|
const Webhook_js_1 = require("../../../oas/webhook/Webhook.js");
|
|
8
8
|
const toPathItemV3_js_1 = require("../pathItem/toPathItemV3.js");
|
|
9
|
+
const isEmpty_js_1 = require("../../../helpers/isEmpty.js");
|
|
9
10
|
const methods_js_1 = require("../methods.js");
|
|
10
11
|
const dropAdditionalOperationsV3_js_1 = require("../pathItem/dropAdditionalOperationsV3.js");
|
|
11
12
|
const warnQuerystringConflictsV3_js_1 = require("../parameter/warnQuerystringConflictsV3.js");
|
|
@@ -13,6 +14,7 @@ const toSpecificationExtensionsV3_js_1 = require("../specificationExtensions/toS
|
|
|
13
14
|
const toSecurityRequirement_js_1 = require("../securityRequirement/toSecurityRequirement.js");
|
|
14
15
|
const toExternalDocs_js_1 = require("../externalDocs/toExternalDocs.js");
|
|
15
16
|
const toServerV3_js_1 = require("../server/toServerV3.js");
|
|
17
|
+
const pathParameters_js_1 = require("../../pathParameters.js");
|
|
16
18
|
/**
|
|
17
19
|
* Parses a single webhook Operation Object into an {@link OasWebhook}.
|
|
18
20
|
*
|
|
@@ -92,15 +94,11 @@ const toWebhooksV3 = ({ webhooks, stackTrail, context }) => {
|
|
|
92
94
|
rest: fixedFields,
|
|
93
95
|
methodObject: {}
|
|
94
96
|
});
|
|
95
|
-
const pathItemResult = (0,
|
|
96
|
-
pathItem: cleaned.rest,
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
if (!pathItemResult.valid) {
|
|
101
|
-
return [];
|
|
102
|
-
}
|
|
103
|
-
const pathItemObject = pathItemResult.pathItem;
|
|
97
|
+
const pathItemResult = !(0, isEmpty_js_1.isEmpty)(cleaned.rest)
|
|
98
|
+
? (0, toPathItemV3_js_1.toPathItemV3)({ pathItem: cleaned.rest, stackTrail: nameStack, context })
|
|
99
|
+
: undefined;
|
|
100
|
+
const pathItemObject = pathItemResult?.pathItem;
|
|
101
|
+
const brokenParameters = pathItemResult?.brokenParameters ?? [];
|
|
104
102
|
return Object.entries(cleaned.methodObject)
|
|
105
103
|
.map(([method, operation]) => {
|
|
106
104
|
// Use `nameStack` (the trail with the webhook name already
|
|
@@ -110,6 +108,9 @@ const toWebhooksV3 = ({ webhooks, stackTrail, context }) => {
|
|
|
110
108
|
if (!operation) {
|
|
111
109
|
return;
|
|
112
110
|
}
|
|
111
|
+
if ((0, pathParameters_js_1.isDroppedByPathParameter)({ brokenParameters, operation, stackTrail: st, context })) {
|
|
112
|
+
return undefined;
|
|
113
|
+
}
|
|
113
114
|
try {
|
|
114
115
|
return (0, exports.toWebhookV3)({
|
|
115
116
|
operation,
|