@skmtc/core 0.58.3 → 0.58.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.
Files changed (35) hide show
  1. package/esm/context/BuiltOnRead.d.ts +37 -0
  2. package/esm/context/BuiltOnRead.js +199 -0
  3. package/esm/context/CoreContext.js +11 -5
  4. package/esm/context/GenerateContext.js +8 -1
  5. package/esm/context/ParseContext.js +116 -11
  6. package/esm/context/Subject.d.ts +29 -2
  7. package/esm/context/Subject.js +67 -6
  8. package/esm/oas/document/Document.d.ts +5 -1
  9. package/esm/oas/document/Document.js +10 -1
  10. package/esm/oas/document/documentSource.d.ts +37 -0
  11. package/esm/oas/document/documentSource.js +27 -0
  12. package/esm/parse/v3-0/operation/toOperationsV3.d.ts +14 -0
  13. package/esm/parse/v3-0/operation/toOperationsV3.js +68 -67
  14. package/esm/parse/v3-1/operation/toOperationsV3.d.ts +14 -0
  15. package/esm/parse/v3-1/operation/toOperationsV3.js +68 -67
  16. package/esm/parse/v3-2/operation/toOperationsV3.d.ts +14 -0
  17. package/esm/parse/v3-2/operation/toOperationsV3.js +69 -68
  18. package/package.json +1 -1
  19. package/script/context/BuiltOnRead.d.ts +37 -0
  20. package/script/context/BuiltOnRead.js +203 -0
  21. package/script/context/CoreContext.js +11 -5
  22. package/script/context/GenerateContext.js +8 -1
  23. package/script/context/ParseContext.js +116 -11
  24. package/script/context/Subject.d.ts +29 -2
  25. package/script/context/Subject.js +67 -6
  26. package/script/oas/document/Document.d.ts +5 -1
  27. package/script/oas/document/Document.js +10 -1
  28. package/script/oas/document/documentSource.d.ts +37 -0
  29. package/script/oas/document/documentSource.js +36 -0
  30. package/script/parse/v3-0/operation/toOperationsV3.d.ts +14 -0
  31. package/script/parse/v3-0/operation/toOperationsV3.js +71 -69
  32. package/script/parse/v3-1/operation/toOperationsV3.d.ts +14 -0
  33. package/script/parse/v3-1/operation/toOperationsV3.js +71 -69
  34. package/script/parse/v3-2/operation/toOperationsV3.d.ts +14 -0
  35. package/script/parse/v3-2/operation/toOperationsV3.js +72 -70
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toOperationsV3 = exports.toOperationV3 = void 0;
3
+ exports.toPathOperationsV3 = exports.toOperationsV3 = exports.toOperationV3 = void 0;
4
4
  const toRequestBodiesV3_js_1 = require("../requestBody/toRequestBodiesV3.js");
5
5
  const toResponseV3_js_1 = require("../response/toResponseV3.js");
6
6
  const toParameterV3_js_1 = require("../parameter/toParameterV3.js");
@@ -53,75 +53,77 @@ const toOperationV3 = ({ operation, operationInfo, stackTrail, context }) => {
53
53
  };
54
54
  exports.toOperationV3 = toOperationV3;
55
55
  const toOperationsV3 = ({ paths, stackTrail, context }) => {
56
- return Object.entries(paths).flatMap(([path, pathItem]) => {
57
- return stackTrail.trace(path, pathStack => {
58
- if (!pathItem) {
59
- return [];
60
- }
61
- const cleaned = Object.entries(pathItem).reduce(({ rest, methodObject }, [key, operation]) => {
62
- const method = (0, methods_js_1.toPathItemMethod)(key);
63
- if (method) {
64
- const { [method]: _deleted, ...remaining } = rest;
65
- return {
66
- rest: remaining,
67
- methodObject: {
68
- ...methodObject,
69
- [method]: operation
70
- }
71
- };
56
+ return Object.entries(paths).flatMap(([path, pathItem]) => stackTrail.trace(path, pathStack => pathItem ? (0, exports.toPathOperationsV3)({ path, pathItem, stackTrail: pathStack, context }) : []));
57
+ };
58
+ exports.toOperationsV3 = toOperationsV3;
59
+ /**
60
+ * The operations of the path item at `path`. They share one parsed path
61
+ * item. With `method`, only the operation at that method is parsed.
62
+ */
63
+ const toPathOperationsV3 = ({ path, pathItem, stackTrail: pathStack, context, method: only }) => {
64
+ const cleaned = Object.entries(pathItem).reduce(({ rest, methodObject }, [key, operation]) => {
65
+ const method = (0, methods_js_1.toPathItemMethod)(key);
66
+ if (method) {
67
+ const { [method]: _deleted, ...remaining } = rest;
68
+ return {
69
+ rest: remaining,
70
+ methodObject: {
71
+ ...methodObject,
72
+ [method]: operation
72
73
  }
73
- return { rest, methodObject };
74
- }, {
75
- rest: pathItem,
76
- methodObject: {}
77
- });
78
- const pathItemResult = !(0, isEmpty_js_1.isEmpty)(cleaned.rest)
79
- ? (0, toPathItemV3_js_1.toPathItemV3)({ pathItem: cleaned.rest, stackTrail: pathStack, context })
80
- : undefined;
81
- const pathItemObject = pathItemResult?.pathItem;
82
- const brokenParameters = pathItemResult?.brokenParameters ?? [];
83
- return Object.entries(cleaned.methodObject)
84
- .map(([method, operation]) => {
85
- // Use `pathStack` (the trail with `path` already pushed),
86
- // not the outer `stackTrail` — otherwise downstream traces
87
- // record paths:<method>:... and lose the actual path
88
- // segment, which breaks `OasDocument.removeItem` and the
89
- // dependency-ref invalidation it backs.
90
- return pathStack.trace(method, st => {
91
- if (!operation) {
92
- return;
93
- }
94
- if ((0, pathParameters_js_1.isDroppedByPathParameter)({ brokenParameters, operation, stackTrail: st, context })) {
95
- return undefined;
96
- }
97
- try {
98
- return (0, exports.toOperationV3)({
99
- operation,
100
- operationInfo: {
101
- method: method,
102
- path,
103
- pathItem: pathItemObject
104
- },
105
- stackTrail: st,
106
- context
107
- });
108
- }
109
- catch (error) {
110
- const normalized = error instanceof Error ? error : new Error(String(error));
111
- context.logIssueNoKey({
112
- parent: operation,
113
- level: 'error',
114
- message: normalized.message,
115
- cause: normalized,
116
- stackTrail: st,
117
- type: 'INVALID_OPERATION'
118
- });
119
- return undefined;
120
- }
74
+ };
75
+ }
76
+ return { rest, methodObject };
77
+ }, {
78
+ rest: pathItem,
79
+ methodObject: {}
80
+ });
81
+ const pathItemResult = !(0, isEmpty_js_1.isEmpty)(cleaned.rest)
82
+ ? (0, toPathItemV3_js_1.toPathItemV3)({ pathItem: cleaned.rest, stackTrail: pathStack, context })
83
+ : undefined;
84
+ const pathItemObject = pathItemResult?.pathItem;
85
+ const brokenParameters = pathItemResult?.brokenParameters ?? [];
86
+ return Object.entries(cleaned.methodObject)
87
+ .filter(([method]) => only === undefined || method === only)
88
+ .map(([method, operation]) => {
89
+ // Use `pathStack` (the trail with `path` already pushed),
90
+ // not the outer `stackTrail` — otherwise downstream traces
91
+ // record paths:<method>:... and lose the actual path
92
+ // segment, which breaks `OasDocument.removeItem` and the
93
+ // dependency-ref invalidation it backs.
94
+ return pathStack.trace(method, st => {
95
+ if (!operation) {
96
+ return;
97
+ }
98
+ if ((0, pathParameters_js_1.isDroppedByPathParameter)({ brokenParameters, operation, stackTrail: st, context })) {
99
+ return undefined;
100
+ }
101
+ try {
102
+ return (0, exports.toOperationV3)({
103
+ operation,
104
+ operationInfo: {
105
+ method: method,
106
+ path,
107
+ pathItem: pathItemObject
108
+ },
109
+ stackTrail: st,
110
+ context
121
111
  });
122
- })
123
- .filter((item) => Boolean(item));
112
+ }
113
+ catch (error) {
114
+ const normalized = error instanceof Error ? error : new Error(String(error));
115
+ context.logIssueNoKey({
116
+ parent: operation,
117
+ level: 'error',
118
+ message: normalized.message,
119
+ cause: normalized,
120
+ stackTrail: st,
121
+ type: 'INVALID_OPERATION'
122
+ });
123
+ return undefined;
124
+ }
124
125
  });
125
- });
126
+ })
127
+ .filter((item) => Boolean(item));
126
128
  };
127
- exports.toOperationsV3 = toOperationsV3;
129
+ exports.toPathOperationsV3 = toPathOperationsV3;
@@ -22,4 +22,18 @@ export type ToOperationsV3Args = {
22
22
  context: ParseContextType;
23
23
  };
24
24
  export declare const toOperationsV3: ({ paths, stackTrail, context }: ToOperationsV3Args) => OasOperation[];
25
+ export type ToPathOperationsV3Args = {
26
+ path: string;
27
+ pathItem: OpenAPIV3.PathItemObject;
28
+ /** The trail of the path item, with `path` already pushed. */
29
+ stackTrail: StackTrail;
30
+ context: ParseContextType;
31
+ /** Parses only the operation at this method. */
32
+ method?: Method;
33
+ };
34
+ /**
35
+ * The operations of the path item at `path`. They share one parsed path
36
+ * item. With `method`, only the operation at that method is parsed.
37
+ */
38
+ export declare const toPathOperationsV3: ({ path, pathItem, stackTrail: pathStack, context, method: only }: ToPathOperationsV3Args) => OasOperation[];
25
39
  export {};
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toOperationsV3 = exports.toOperationV3 = void 0;
3
+ exports.toPathOperationsV3 = exports.toOperationsV3 = exports.toOperationV3 = void 0;
4
4
  const toRequestBodiesV3_js_1 = require("../requestBody/toRequestBodiesV3.js");
5
5
  const toResponseV3_js_1 = require("../response/toResponseV3.js");
6
6
  const toParameterV3_js_1 = require("../parameter/toParameterV3.js");
@@ -56,75 +56,77 @@ const toOperationsV3 = ({ paths, stackTrail, context }) => {
56
56
  if (!paths) {
57
57
  return [];
58
58
  }
59
- return Object.entries(paths).flatMap(([path, pathItem]) => {
60
- return stackTrail.trace(path, pathStack => {
61
- if (!pathItem) {
62
- return [];
63
- }
64
- const cleaned = Object.entries(pathItem).reduce(({ rest, methodObject }, [key, operation]) => {
65
- const method = (0, methods_js_1.toPathItemMethod)(key);
66
- if (method) {
67
- const { [method]: _deleted, ...remaining } = rest;
68
- return {
69
- rest: remaining,
70
- methodObject: {
71
- ...methodObject,
72
- [method]: operation
73
- }
74
- };
59
+ return Object.entries(paths).flatMap(([path, pathItem]) => stackTrail.trace(path, pathStack => pathItem ? (0, exports.toPathOperationsV3)({ path, pathItem, stackTrail: pathStack, context }) : []));
60
+ };
61
+ exports.toOperationsV3 = toOperationsV3;
62
+ /**
63
+ * The operations of the path item at `path`. They share one parsed path
64
+ * item. With `method`, only the operation at that method is parsed.
65
+ */
66
+ const toPathOperationsV3 = ({ path, pathItem, stackTrail: pathStack, context, method: only }) => {
67
+ const cleaned = Object.entries(pathItem).reduce(({ rest, methodObject }, [key, operation]) => {
68
+ const method = (0, methods_js_1.toPathItemMethod)(key);
69
+ if (method) {
70
+ const { [method]: _deleted, ...remaining } = rest;
71
+ return {
72
+ rest: remaining,
73
+ methodObject: {
74
+ ...methodObject,
75
+ [method]: operation
75
76
  }
76
- return { rest, methodObject };
77
- }, {
78
- rest: pathItem,
79
- methodObject: {}
80
- });
81
- const pathItemResult = !(0, isEmpty_js_1.isEmpty)(cleaned.rest)
82
- ? (0, toPathItemV3_js_1.toPathItemV3)({ pathItem: cleaned.rest, stackTrail: pathStack, context })
83
- : undefined;
84
- const pathItemObject = pathItemResult?.pathItem;
85
- const brokenParameters = pathItemResult?.brokenParameters ?? [];
86
- return Object.entries(cleaned.methodObject)
87
- .map(([method, operation]) => {
88
- // Use `pathStack` (the trail with `path` already pushed),
89
- // not the outer `stackTrail` — otherwise downstream traces
90
- // record paths:<method>:... and lose the actual path
91
- // segment, which breaks `OasDocument.removeItem` and the
92
- // dependency-ref invalidation it backs.
93
- return pathStack.trace(method, st => {
94
- if (!operation) {
95
- return;
96
- }
97
- if ((0, pathParameters_js_1.isDroppedByPathParameter)({ brokenParameters, operation, stackTrail: st, context })) {
98
- return undefined;
99
- }
100
- try {
101
- return (0, exports.toOperationV3)({
102
- operation,
103
- operationInfo: {
104
- method: method,
105
- path,
106
- pathItem: pathItemObject
107
- },
108
- stackTrail: st,
109
- context
110
- });
111
- }
112
- catch (error) {
113
- const normalized = error instanceof Error ? error : new Error(String(error));
114
- context.logIssueNoKey({
115
- parent: operation,
116
- level: 'error',
117
- message: normalized.message,
118
- cause: normalized,
119
- stackTrail: st,
120
- type: 'INVALID_OPERATION'
121
- });
122
- return undefined;
123
- }
77
+ };
78
+ }
79
+ return { rest, methodObject };
80
+ }, {
81
+ rest: pathItem,
82
+ methodObject: {}
83
+ });
84
+ const pathItemResult = !(0, isEmpty_js_1.isEmpty)(cleaned.rest)
85
+ ? (0, toPathItemV3_js_1.toPathItemV3)({ pathItem: cleaned.rest, stackTrail: pathStack, context })
86
+ : undefined;
87
+ const pathItemObject = pathItemResult?.pathItem;
88
+ const brokenParameters = pathItemResult?.brokenParameters ?? [];
89
+ return Object.entries(cleaned.methodObject)
90
+ .filter(([method]) => only === undefined || method === only)
91
+ .map(([method, operation]) => {
92
+ // Use `pathStack` (the trail with `path` already pushed),
93
+ // not the outer `stackTrail` — otherwise downstream traces
94
+ // record paths:<method>:... and lose the actual path
95
+ // segment, which breaks `OasDocument.removeItem` and the
96
+ // dependency-ref invalidation it backs.
97
+ return pathStack.trace(method, st => {
98
+ if (!operation) {
99
+ return;
100
+ }
101
+ if ((0, pathParameters_js_1.isDroppedByPathParameter)({ brokenParameters, operation, stackTrail: st, context })) {
102
+ return undefined;
103
+ }
104
+ try {
105
+ return (0, exports.toOperationV3)({
106
+ operation,
107
+ operationInfo: {
108
+ method: method,
109
+ path,
110
+ pathItem: pathItemObject
111
+ },
112
+ stackTrail: st,
113
+ context
124
114
  });
125
- })
126
- .filter((item) => Boolean(item));
115
+ }
116
+ catch (error) {
117
+ const normalized = error instanceof Error ? error : new Error(String(error));
118
+ context.logIssueNoKey({
119
+ parent: operation,
120
+ level: 'error',
121
+ message: normalized.message,
122
+ cause: normalized,
123
+ stackTrail: st,
124
+ type: 'INVALID_OPERATION'
125
+ });
126
+ return undefined;
127
+ }
127
128
  });
128
- });
129
+ })
130
+ .filter((item) => Boolean(item));
129
131
  };
130
- exports.toOperationsV3 = toOperationsV3;
132
+ exports.toPathOperationsV3 = toPathOperationsV3;
@@ -22,4 +22,18 @@ export type ToOperationsV3Args = {
22
22
  context: ParseContextType;
23
23
  };
24
24
  export declare const toOperationsV3: ({ paths, stackTrail, context }: ToOperationsV3Args) => OasOperation[];
25
+ export type ToPathOperationsV3Args = {
26
+ path: string;
27
+ pathItem: OpenAPIV3.PathItemObject;
28
+ /** The trail of the path item, with `path` already pushed. */
29
+ stackTrail: StackTrail;
30
+ context: ParseContextType;
31
+ /** Parses only the operation at this method. */
32
+ method?: Method;
33
+ };
34
+ /**
35
+ * The operations of the path item at `path`. They share one parsed path
36
+ * item. With `method`, only the operation at that method is parsed.
37
+ */
38
+ export declare const toPathOperationsV3: ({ path, pathItem, stackTrail: pathStack, context, method: only }: ToPathOperationsV3Args) => OasOperation[];
25
39
  export {};
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toOperationsV3 = exports.toOperationV3 = void 0;
3
+ exports.toPathOperationsV3 = exports.toOperationsV3 = exports.toOperationV3 = void 0;
4
4
  const toRequestBodiesV3_js_1 = require("../requestBody/toRequestBodiesV3.js");
5
5
  const toResponseV3_js_1 = require("../response/toResponseV3.js");
6
6
  const toParameterV3_js_1 = require("../parameter/toParameterV3.js");
@@ -59,76 +59,78 @@ const toOperationsV3 = ({ paths, stackTrail, context }) => {
59
59
  if (!paths) {
60
60
  return [];
61
61
  }
62
- return Object.entries(paths).flatMap(([path, pathItem]) => {
63
- return stackTrail.trace(path, pathStack => {
64
- if (!pathItem) {
65
- return [];
66
- }
67
- const fixedFields = (0, dropAdditionalOperationsV3_js_1.dropAdditionalOperationsV3)({ pathItem, stackTrail: pathStack, context });
68
- const cleaned = Object.entries(fixedFields).reduce(({ rest, methodObject }, [key, operation]) => {
69
- const method = (0, methods_js_1.toPathItemMethod)(key);
70
- if (method) {
71
- const { [method]: _deleted, ...remaining } = rest;
72
- return {
73
- rest: remaining,
74
- methodObject: {
75
- ...methodObject,
76
- [method]: operation
77
- }
78
- };
62
+ return Object.entries(paths).flatMap(([path, pathItem]) => stackTrail.trace(path, pathStack => pathItem ? (0, exports.toPathOperationsV3)({ path, pathItem, stackTrail: pathStack, context }) : []));
63
+ };
64
+ exports.toOperationsV3 = toOperationsV3;
65
+ /**
66
+ * The operations of the path item at `path`. They share one parsed path
67
+ * item. With `method`, only the operation at that method is parsed.
68
+ */
69
+ const toPathOperationsV3 = ({ path, pathItem, stackTrail: pathStack, context, method: only }) => {
70
+ const fixedFields = (0, dropAdditionalOperationsV3_js_1.dropAdditionalOperationsV3)({ pathItem, stackTrail: pathStack, context });
71
+ const cleaned = Object.entries(fixedFields).reduce(({ rest, methodObject }, [key, operation]) => {
72
+ const method = (0, methods_js_1.toPathItemMethod)(key);
73
+ if (method) {
74
+ const { [method]: _deleted, ...remaining } = rest;
75
+ return {
76
+ rest: remaining,
77
+ methodObject: {
78
+ ...methodObject,
79
+ [method]: operation
79
80
  }
80
- return { rest, methodObject };
81
- }, {
82
- rest: fixedFields,
83
- methodObject: {}
84
- });
85
- const pathItemResult = !(0, isEmpty_js_1.isEmpty)(cleaned.rest)
86
- ? (0, toPathItemV3_js_1.toPathItemV3)({ pathItem: cleaned.rest, stackTrail: pathStack, context })
87
- : undefined;
88
- const pathItemObject = pathItemResult?.pathItem;
89
- const brokenParameters = pathItemResult?.brokenParameters ?? [];
90
- return Object.entries(cleaned.methodObject)
91
- .map(([method, operation]) => {
92
- // Use `pathStack` (the trail with `path` already pushed),
93
- // not the outer `stackTrail` — otherwise downstream traces
94
- // record paths:<method>:... and lose the actual path
95
- // segment, which breaks `OasDocument.removeItem` and the
96
- // dependency-ref invalidation it backs.
97
- return pathStack.trace(method, st => {
98
- if (!operation) {
99
- return;
100
- }
101
- if ((0, pathParameters_js_1.isDroppedByPathParameter)({ brokenParameters, operation, stackTrail: st, context })) {
102
- return undefined;
103
- }
104
- try {
105
- return (0, exports.toOperationV3)({
106
- operation,
107
- operationInfo: {
108
- method: method,
109
- path,
110
- pathItem: pathItemObject
111
- },
112
- stackTrail: st,
113
- context
114
- });
115
- }
116
- catch (error) {
117
- const normalized = error instanceof Error ? error : new Error(String(error));
118
- context.logIssueNoKey({
119
- parent: operation,
120
- level: 'error',
121
- message: normalized.message,
122
- cause: normalized,
123
- stackTrail: st,
124
- type: 'INVALID_OPERATION'
125
- });
126
- return undefined;
127
- }
81
+ };
82
+ }
83
+ return { rest, methodObject };
84
+ }, {
85
+ rest: fixedFields,
86
+ methodObject: {}
87
+ });
88
+ const pathItemResult = !(0, isEmpty_js_1.isEmpty)(cleaned.rest)
89
+ ? (0, toPathItemV3_js_1.toPathItemV3)({ pathItem: cleaned.rest, stackTrail: pathStack, context })
90
+ : undefined;
91
+ const pathItemObject = pathItemResult?.pathItem;
92
+ const brokenParameters = pathItemResult?.brokenParameters ?? [];
93
+ return Object.entries(cleaned.methodObject)
94
+ .filter(([method]) => only === undefined || method === only)
95
+ .map(([method, operation]) => {
96
+ // Use `pathStack` (the trail with `path` already pushed),
97
+ // not the outer `stackTrail` — otherwise downstream traces
98
+ // record paths:<method>:... and lose the actual path
99
+ // segment, which breaks `OasDocument.removeItem` and the
100
+ // dependency-ref invalidation it backs.
101
+ return pathStack.trace(method, st => {
102
+ if (!operation) {
103
+ return;
104
+ }
105
+ if ((0, pathParameters_js_1.isDroppedByPathParameter)({ brokenParameters, operation, stackTrail: st, context })) {
106
+ return undefined;
107
+ }
108
+ try {
109
+ return (0, exports.toOperationV3)({
110
+ operation,
111
+ operationInfo: {
112
+ method: method,
113
+ path,
114
+ pathItem: pathItemObject
115
+ },
116
+ stackTrail: st,
117
+ context
128
118
  });
129
- })
130
- .filter((item) => Boolean(item));
119
+ }
120
+ catch (error) {
121
+ const normalized = error instanceof Error ? error : new Error(String(error));
122
+ context.logIssueNoKey({
123
+ parent: operation,
124
+ level: 'error',
125
+ message: normalized.message,
126
+ cause: normalized,
127
+ stackTrail: st,
128
+ type: 'INVALID_OPERATION'
129
+ });
130
+ return undefined;
131
+ }
131
132
  });
132
- });
133
+ })
134
+ .filter((item) => Boolean(item));
133
135
  };
134
- exports.toOperationsV3 = toOperationsV3;
136
+ exports.toPathOperationsV3 = toPathOperationsV3;