@skmtc/core 0.0.331 → 0.0.332

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.
@@ -1,5 +1,5 @@
1
1
  import type { OpenAPIV3 } from 'openapi-types';
2
- import type { Method } from '../../types/Method.js';
2
+ import { type Method } from '../../types/Method.js';
3
3
  import type { ParseContext } from '../../context/ParseContext.js';
4
4
  import { OasOperation } from './Operation.js';
5
5
  import type { OasPathItem } from '../pathItem/PathItem.js';
@@ -1 +1 @@
1
- {"version":3,"file":"toOperationsV3.d.ts","sourceRoot":"","sources":["../../../src/oas/operation/toOperationsV3.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAIjE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAG7C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAE1D,KAAK,aAAa,GAAG;IACnB,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,WAAW,CAAA;CACtB,CAAA;AAED,KAAK,iBAAiB,GAAG;IACvB,SAAS,EAAE,SAAS,CAAC,eAAe,CAAA;IACpC,aAAa,EAAE,aAAa,CAAA;IAC5B,OAAO,EAAE,YAAY,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,aAAa,0CAIvB,iBAAiB,KAAG,YAqCtB,CAAA;AAED,KAAK,kBAAkB,GAAG;IACxB,KAAK,EAAE,SAAS,CAAC,WAAW,CAAA;IAC5B,OAAO,EAAE,YAAY,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,cAAc,uBAGxB,kBAAkB,KAAG,YAAY,EAqDnC,CAAA"}
1
+ {"version":3,"file":"toOperationsV3.d.ts","sourceRoot":"","sources":["../../../src/oas/operation/toOperationsV3.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,EAAgB,KAAK,MAAM,EAAE,MAAM,uBAAuB,CAAA;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAIjE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAG7C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAE1D,KAAK,aAAa,GAAG;IACnB,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,WAAW,CAAA;CACtB,CAAA;AAED,KAAK,iBAAiB,GAAG;IACvB,SAAS,EAAE,SAAS,CAAC,eAAe,CAAA;IACpC,aAAa,EAAE,aAAa,CAAA;IAC5B,OAAO,EAAE,YAAY,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,aAAa,0CAIvB,iBAAiB,KAAG,YAqCtB,CAAA;AAED,KAAK,kBAAkB,GAAG;IACxB,KAAK,EAAE,SAAS,CAAC,WAAW,CAAA;IAC5B,OAAO,EAAE,YAAY,CAAA;CACtB,CAAA;AAOD,eAAO,MAAM,cAAc,uBAGxB,kBAAkB,KAAG,YAAY,EAqDnC,CAAA"}
@@ -1,3 +1,4 @@
1
+ import { methodValues } from '../../types/Method.js';
1
2
  import { toRequestBodyV3 } from '../requestBody/toRequestBodiesV3.js';
2
3
  import { toResponsesV3 } from '../response/toResponseV3.js';
3
4
  import { toParameterListV3 } from '../parameter/toParameterV3.js';
@@ -28,19 +29,25 @@ export const toOperationsV3 = ({ paths, context }) => {
28
29
  if (!pathItem) {
29
30
  return [];
30
31
  }
31
- const { get, post, put, delete: deleteMethod, options, head, patch, trace, ...rest } = pathItem;
32
- const pathItemObject = toPathItemV3({ pathItem: rest, context });
33
- const methodObjects = {
34
- get,
35
- post,
36
- put,
37
- delete: deleteMethod,
38
- options,
39
- head,
40
- patch,
41
- trace
42
- };
43
- return Object.entries(methodObjects)
32
+ const cleaned = Object.entries(pathItem).reduce(({ rest, methodObject }, [key, operation]) => {
33
+ const isMethod = methodValues.includes(key);
34
+ if (isMethod) {
35
+ const { [key]: method, ...remaining } = rest;
36
+ return {
37
+ rest: remaining,
38
+ methodObject: {
39
+ ...methodObject,
40
+ [method]: operation
41
+ }
42
+ };
43
+ }
44
+ return { rest, methodObject };
45
+ }, {
46
+ rest: pathItem,
47
+ methodObject: {}
48
+ });
49
+ const pathItemObject = toPathItemV3({ pathItem: cleaned.rest, context });
50
+ return Object.entries(cleaned.methodObject)
44
51
  .map(([method, operation]) => {
45
52
  return context.trace(method, () => {
46
53
  if (!operation) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skmtc/core",
3
- "version": "0.0.331",
3
+ "version": "0.0.332",
4
4
  "main": "./script/mod.js",
5
5
  "module": "./esm/mod.js",
6
6
  "exports": {
@@ -1,5 +1,5 @@
1
1
  import type { OpenAPIV3 } from 'openapi-types';
2
- import type { Method } from '../../types/Method.js';
2
+ import { type Method } from '../../types/Method.js';
3
3
  import type { ParseContext } from '../../context/ParseContext.js';
4
4
  import { OasOperation } from './Operation.js';
5
5
  import type { OasPathItem } from '../pathItem/PathItem.js';
@@ -1 +1 @@
1
- {"version":3,"file":"toOperationsV3.d.ts","sourceRoot":"","sources":["../../../src/oas/operation/toOperationsV3.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAIjE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAG7C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAE1D,KAAK,aAAa,GA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CAAC,WAAW,CAAA;IAC5B,OAAO,EAAE,YAAY,CAAA;CACtB,CAAA;AAOD,eAAO,MAAM,cAAc,uBAGxB,kBAAkB,KAAG,YAAY,EAqDnC,CAAA"}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.toOperationsV3 = exports.toOperationV3 = void 0;
4
+ const Method_js_1 = require("../../types/Method.js");
4
5
  const toRequestBodiesV3_js_1 = require("../requestBody/toRequestBodiesV3.js");
5
6
  const toResponseV3_js_1 = require("../response/toResponseV3.js");
6
7
  const toParameterV3_js_1 = require("../parameter/toParameterV3.js");
@@ -32,19 +33,25 @@ const toOperationsV3 = ({ paths, context }) => {
32
33
  if (!pathItem) {
33
34
  return [];
34
35
  }
35
- const { get, post, put, delete: deleteMethod, options, head, patch, trace, ...rest } = pathItem;
36
- const pathItemObject = (0, toPathItemV3_js_1.toPathItemV3)({ pathItem: rest, context });
37
- const methodObjects = {
38
- get,
39
- post,
40
- put,
41
- delete: deleteMethod,
42
- options,
43
- head,
44
- patch,
45
- trace
46
- };
47
- return Object.entries(methodObjects)
36
+ const cleaned = Object.entries(pathItem).reduce(({ rest, methodObject }, [key, operation]) => {
37
+ const isMethod = Method_js_1.methodValues.includes(key);
38
+ if (isMethod) {
39
+ const { [key]: method, ...remaining } = rest;
40
+ return {
41
+ rest: remaining,
42
+ methodObject: {
43
+ ...methodObject,
44
+ [method]: operation
45
+ }
46
+ };
47
+ }
48
+ return { rest, methodObject };
49
+ }, {
50
+ rest: pathItem,
51
+ methodObject: {}
52
+ });
53
+ const pathItemObject = (0, toPathItemV3_js_1.toPathItemV3)({ pathItem: cleaned.rest, context });
54
+ return Object.entries(cleaned.methodObject)
48
55
  .map(([method, operation]) => {
49
56
  return context.trace(method, () => {
50
57
  if (!operation) {