@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.
Files changed (75) hide show
  1. package/esm/context/StackTrail.js +3 -13
  2. package/esm/context/documentTrail.d.ts +17 -0
  3. package/esm/context/documentTrail.js +28 -0
  4. package/esm/parse/isPlainObject.d.ts +2 -0
  5. package/esm/parse/isPlainObject.js +2 -0
  6. package/esm/parse/pathParameters.d.ts +57 -0
  7. package/esm/parse/pathParameters.js +138 -0
  8. package/esm/parse/securityRequirements.d.ts +63 -0
  9. package/esm/parse/securityRequirements.js +128 -0
  10. package/esm/parse/toComponentEntries.js +1 -2
  11. package/esm/parse/v3-0/document/toDocumentFieldsV3.js +21 -7
  12. package/esm/parse/v3-0/operation/toOperationsV3.js +7 -1
  13. package/esm/parse/v3-0/parameter/toParameterV3.d.ts +7 -0
  14. package/esm/parse/v3-0/parameter/toParameterV3.js +19 -11
  15. package/esm/parse/v3-0/pathItem/toPathItemV3.d.ts +7 -1
  16. package/esm/parse/v3-0/pathItem/toPathItemV3.js +5 -3
  17. package/esm/parse/v3-0/securityRequirement/toSecurityRequirement.d.ts +2 -1
  18. package/esm/parse/v3-0/securityRequirement/toSecurityRequirement.js +2 -4
  19. package/esm/parse/v3-0/webhook/toWebhooksV3.js +7 -1
  20. package/esm/parse/v3-1/document/toDocumentFieldsV3.js +21 -7
  21. package/esm/parse/v3-1/operation/toOperationsV3.js +7 -1
  22. package/esm/parse/v3-1/parameter/toParameterV3.d.ts +7 -0
  23. package/esm/parse/v3-1/parameter/toParameterV3.js +19 -11
  24. package/esm/parse/v3-1/pathItem/toPathItemV3.d.ts +7 -1
  25. package/esm/parse/v3-1/pathItem/toPathItemV3.js +5 -3
  26. package/esm/parse/v3-1/securityRequirement/toSecurityRequirement.d.ts +2 -1
  27. package/esm/parse/v3-1/securityRequirement/toSecurityRequirement.js +2 -4
  28. package/esm/parse/v3-1/webhook/toWebhooksV3.js +7 -1
  29. package/esm/parse/v3-2/document/toDocumentFieldsV3.js +21 -7
  30. package/esm/parse/v3-2/operation/toOperationsV3.js +11 -10
  31. package/esm/parse/v3-2/parameter/toParameterV3.d.ts +7 -0
  32. package/esm/parse/v3-2/parameter/toParameterV3.js +30 -24
  33. package/esm/parse/v3-2/pathItem/toPathItemV3.d.ts +6 -13
  34. package/esm/parse/v3-2/pathItem/toPathItemV3.js +5 -30
  35. package/esm/parse/v3-2/securityRequirement/toSecurityRequirement.d.ts +2 -1
  36. package/esm/parse/v3-2/securityRequirement/toSecurityRequirement.js +2 -4
  37. package/esm/parse/v3-2/webhook/toWebhooksV3.js +11 -10
  38. package/package.json +1 -1
  39. package/script/context/StackTrail.js +3 -13
  40. package/script/context/documentTrail.d.ts +17 -0
  41. package/script/context/documentTrail.js +34 -0
  42. package/script/parse/isPlainObject.d.ts +2 -0
  43. package/script/parse/isPlainObject.js +4 -1
  44. package/script/parse/pathParameters.d.ts +57 -0
  45. package/script/parse/pathParameters.js +144 -0
  46. package/script/parse/securityRequirements.d.ts +63 -0
  47. package/script/parse/securityRequirements.js +134 -0
  48. package/script/parse/toComponentEntries.js +1 -2
  49. package/script/parse/v3-0/document/toDocumentFieldsV3.js +21 -7
  50. package/script/parse/v3-0/operation/toOperationsV3.js +7 -1
  51. package/script/parse/v3-0/parameter/toParameterV3.d.ts +7 -0
  52. package/script/parse/v3-0/parameter/toParameterV3.js +22 -13
  53. package/script/parse/v3-0/pathItem/toPathItemV3.d.ts +7 -1
  54. package/script/parse/v3-0/pathItem/toPathItemV3.js +4 -2
  55. package/script/parse/v3-0/securityRequirement/toSecurityRequirement.d.ts +2 -1
  56. package/script/parse/v3-0/securityRequirement/toSecurityRequirement.js +2 -4
  57. package/script/parse/v3-0/webhook/toWebhooksV3.js +7 -1
  58. package/script/parse/v3-1/document/toDocumentFieldsV3.js +21 -7
  59. package/script/parse/v3-1/operation/toOperationsV3.js +7 -1
  60. package/script/parse/v3-1/parameter/toParameterV3.d.ts +7 -0
  61. package/script/parse/v3-1/parameter/toParameterV3.js +22 -13
  62. package/script/parse/v3-1/pathItem/toPathItemV3.d.ts +7 -1
  63. package/script/parse/v3-1/pathItem/toPathItemV3.js +4 -2
  64. package/script/parse/v3-1/securityRequirement/toSecurityRequirement.d.ts +2 -1
  65. package/script/parse/v3-1/securityRequirement/toSecurityRequirement.js +2 -4
  66. package/script/parse/v3-1/webhook/toWebhooksV3.js +7 -1
  67. package/script/parse/v3-2/document/toDocumentFieldsV3.js +21 -7
  68. package/script/parse/v3-2/operation/toOperationsV3.js +10 -9
  69. package/script/parse/v3-2/parameter/toParameterV3.d.ts +7 -0
  70. package/script/parse/v3-2/parameter/toParameterV3.js +33 -26
  71. package/script/parse/v3-2/pathItem/toPathItemV3.d.ts +6 -13
  72. package/script/parse/v3-2/pathItem/toPathItemV3.js +5 -31
  73. package/script/parse/v3-2/securityRequirement/toSecurityRequirement.d.ts +2 -1
  74. package/script/parse/v3-2/securityRequirement/toSecurityRequirement.js +2 -4
  75. 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 declare const toPathItemV3: ({ pathItem, stackTrail, context }: ToPathItemV3Args) => OasPathItem;
11
- export type PathItemResult = {
12
- valid: true;
13
- pathItem: OasPathItem | undefined;
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.toPathItemResultV3 = exports.toPathItemV3 = void 0;
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
- return new PathItem_js_1.OasPathItem({
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: stackTrail.trace('parameters', st => (0, toParameterV3_js_1.toParameterListV3)({ parameters, stackTrail: st, context })),
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: Record<string, string[]>[] | undefined;
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
- if (!security) {
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, toPathItemV3_js_1.toPathItemResultV3)({
96
- pathItem: cleaned.rest,
97
- stackTrail: nameStack,
98
- context
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,