@kubb/plugin-oas 3.0.0-alpha.2 → 3.0.0-alpha.21

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 (101) hide show
  1. package/README.md +13 -4
  2. package/dist/OperationGenerator-CHXolL0o.d.cts +553 -0
  3. package/dist/OperationGenerator-CHXolL0o.d.ts +553 -0
  4. package/dist/Schema-Ch0dHkM5.d.ts +22 -0
  5. package/dist/Schema-ClNodlyP.d.cts +22 -0
  6. package/dist/chunk-6UWOTOZJ.cjs +92 -0
  7. package/dist/chunk-6UWOTOZJ.cjs.map +1 -0
  8. package/dist/chunk-AZKUU24F.js +700 -0
  9. package/dist/chunk-AZKUU24F.js.map +1 -0
  10. package/dist/chunk-DFQJ57GH.js +45 -0
  11. package/dist/chunk-DFQJ57GH.js.map +1 -0
  12. package/dist/chunk-GF26SDHQ.js +28 -0
  13. package/dist/chunk-GF26SDHQ.js.map +1 -0
  14. package/dist/chunk-HP5WAFBU.cjs +48 -0
  15. package/dist/chunk-HP5WAFBU.cjs.map +1 -0
  16. package/dist/chunk-JNGUNN72.cjs +708 -0
  17. package/dist/chunk-JNGUNN72.cjs.map +1 -0
  18. package/dist/chunk-PADR76WZ.cjs +4 -0
  19. package/dist/chunk-PADR76WZ.cjs.map +1 -0
  20. package/dist/chunk-R47XMJ32.js +3 -0
  21. package/dist/chunk-R47XMJ32.js.map +1 -0
  22. package/dist/{chunk-Y4V7HHX7.js → chunk-THGCWF2O.js} +8 -13
  23. package/dist/{chunk-Y4V7HHX7.js.map → chunk-THGCWF2O.js.map} +1 -1
  24. package/dist/chunk-TRA5BTWI.js +88 -0
  25. package/dist/chunk-TRA5BTWI.js.map +1 -0
  26. package/dist/chunk-UO57DZPV.cjs +36 -0
  27. package/dist/chunk-UO57DZPV.cjs.map +1 -0
  28. package/dist/chunk-ZWHQ54JM.cjs +32 -0
  29. package/dist/chunk-ZWHQ54JM.cjs.map +1 -0
  30. package/dist/components.cjs +20 -17
  31. package/dist/components.cjs.map +1 -1
  32. package/dist/components.d.cts +12 -8
  33. package/dist/components.d.ts +12 -8
  34. package/dist/components.js +3 -17
  35. package/dist/components.js.map +1 -1
  36. package/dist/generators.cjs +14 -0
  37. package/dist/generators.cjs.map +1 -0
  38. package/dist/generators.d.cts +10 -0
  39. package/dist/generators.d.ts +10 -0
  40. package/dist/generators.js +5 -0
  41. package/dist/generators.js.map +1 -0
  42. package/dist/hooks.cjs +101 -57
  43. package/dist/hooks.cjs.map +1 -1
  44. package/dist/hooks.d.cts +40 -8
  45. package/dist/hooks.d.ts +40 -8
  46. package/dist/hooks.js +90 -53
  47. package/dist/hooks.js.map +1 -1
  48. package/dist/index.cjs +283 -261
  49. package/dist/index.cjs.map +1 -1
  50. package/dist/index.d.cts +6 -77
  51. package/dist/index.d.ts +6 -77
  52. package/dist/index.js +235 -240
  53. package/dist/index.js.map +1 -1
  54. package/dist/utils.cjs +32 -87
  55. package/dist/utils.cjs.map +1 -1
  56. package/dist/utils.d.cts +7 -41
  57. package/dist/utils.d.ts +7 -41
  58. package/dist/utils.js +8 -86
  59. package/dist/utils.js.map +1 -1
  60. package/package.json +20 -14
  61. package/src/OperationGenerator.ts +75 -43
  62. package/src/SchemaGenerator.ts +44 -18
  63. package/src/SchemaMapper.ts +1 -1
  64. package/src/components/Oas.tsx +9 -3
  65. package/src/components/Operation.tsx +1 -1
  66. package/src/components/Schema.tsx +2 -102
  67. package/src/generator.tsx +133 -0
  68. package/src/generators/index.ts +1 -0
  69. package/src/generators/jsonGenerator.ts +32 -0
  70. package/src/hooks/index.ts +2 -0
  71. package/src/hooks/useOperationManager.ts +76 -28
  72. package/src/hooks/useSchemaManager.ts +77 -0
  73. package/src/index.ts +3 -9
  74. package/src/plugin.ts +64 -47
  75. package/src/types.ts +23 -12
  76. package/src/utils/getParams.ts +2 -2
  77. package/src/utils/index.ts +2 -2
  78. package/dist/OperationGenerator-CeM_9pxW.d.cts +0 -60
  79. package/dist/OperationGenerator-DhUhvRJE.d.ts +0 -60
  80. package/dist/Schema-DefwBJMc.d.ts +0 -35
  81. package/dist/Schema-an5hOrjZ.d.cts +0 -35
  82. package/dist/SchemaMapper-CsBQ6eEx.d.cts +0 -248
  83. package/dist/SchemaMapper-CsBQ6eEx.d.ts +0 -248
  84. package/dist/chunk-CJXRFYEF.cjs +0 -698
  85. package/dist/chunk-CJXRFYEF.cjs.map +0 -1
  86. package/dist/chunk-DRLYORTT.cjs +0 -3265
  87. package/dist/chunk-DRLYORTT.cjs.map +0 -1
  88. package/dist/chunk-K6KUETAI.js +0 -698
  89. package/dist/chunk-K6KUETAI.js.map +0 -1
  90. package/dist/chunk-LEACSHKT.js +0 -3265
  91. package/dist/chunk-LEACSHKT.js.map +0 -1
  92. package/dist/chunk-P42X362U.cjs +0 -101
  93. package/dist/chunk-P42X362U.cjs.map +0 -1
  94. package/dist/chunk-QLJIL3U5.cjs +0 -35
  95. package/dist/chunk-QLJIL3U5.cjs.map +0 -1
  96. package/dist/chunk-UB552H4J.js +0 -101
  97. package/dist/chunk-UB552H4J.js.map +0 -1
  98. package/dist/types-Dte3MA6H.d.cts +0 -143
  99. package/dist/types-Dte3MA6H.d.ts +0 -143
  100. package/src/utils/getGroupedByTagFiles.ts +0 -82
  101. package/src/utils/refSorter.ts +0 -13
package/dist/index.cjs CHANGED
@@ -1,148 +1,100 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
1
+ 'use strict';
2
2
 
3
- var _chunkQLJIL3U5cjs = require('./chunk-QLJIL3U5.cjs');
3
+ var chunkUO57DZPV_cjs = require('./chunk-UO57DZPV.cjs');
4
+ var chunk6UWOTOZJ_cjs = require('./chunk-6UWOTOZJ.cjs');
5
+ require('./chunk-PADR76WZ.cjs');
6
+ var chunkJNGUNN72_cjs = require('./chunk-JNGUNN72.cjs');
7
+ var chunkHP5WAFBU_cjs = require('./chunk-HP5WAFBU.cjs');
8
+ require('./chunk-ZWHQ54JM.cjs');
9
+ var core = require('@kubb/core');
10
+ var transformers = require('@kubb/core/transformers');
11
+ var path = require('path');
4
12
 
13
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
5
14
 
15
+ var transformers__default = /*#__PURE__*/_interopDefault(transformers);
16
+ var path__default = /*#__PURE__*/_interopDefault(path);
6
17
 
7
-
8
- var _chunkCJXRFYEFcjs = require('./chunk-CJXRFYEF.cjs');
9
-
10
-
11
-
12
-
13
-
14
-
15
-
16
- var _chunkP42X362Ucjs = require('./chunk-P42X362U.cjs');
17
-
18
- // src/index.ts
19
- _chunkP42X362Ucjs.init_cjs_shims.call(void 0, );
20
-
21
- // src/plugin.ts
22
- _chunkP42X362Ucjs.init_cjs_shims.call(void 0, );
23
- var _path = require('path'); var _path2 = _interopRequireDefault(_path);
24
- var _core = require('@kubb/core');
25
- var _transformers = require('@kubb/core/transformers'); var _transformers2 = _interopRequireDefault(_transformers);
26
- var pluginOasName = "plugin-oas";
27
- var pluginOas = _core.createPlugin.call(void 0, (options) => {
28
- const {
29
- output = { path: "schemas", export: false },
30
- experimentalFilter: filter,
31
- experimentalSort: sort,
32
- validate = true,
33
- serverIndex = 0,
34
- contentType,
35
- oasClass
36
- } = options;
37
- const getOas = async ({ config, logger, formatOptions }) => {
38
- try {
39
- const oas = await _chunkQLJIL3U5cjs.parseFromConfig.call(void 0, config, formatOptions, oasClass);
40
- if (validate) {
41
- await oas.valdiate();
18
+ var OperationGenerator = class extends core.BaseGenerator {
19
+ #operationsByMethod = {};
20
+ get operationsByMethod() {
21
+ return this.#operationsByMethod;
22
+ }
23
+ set operationsByMethod(paths) {
24
+ this.#operationsByMethod = paths;
25
+ }
26
+ #getOptions(operation, method) {
27
+ const { override = [] } = this.context;
28
+ return override.find(({ pattern, type }) => {
29
+ if (type === "tag") {
30
+ return !!operation.getTags()[0]?.name.match(pattern);
42
31
  }
43
- return oas;
44
- } catch (e) {
45
- const error = e;
46
- logger.emit("warning", _optionalChain([error, 'optionalAccess', _ => _.message]));
47
- return _chunkQLJIL3U5cjs.parseFromConfig.call(void 0, config, {}, oasClass);
48
- }
49
- };
50
- return {
51
- name: pluginOasName,
52
- options,
53
- context() {
54
- const { config, logger } = this;
55
- return {
56
- getOas(formatOptions) {
57
- return getOas({ config, logger, formatOptions });
58
- },
59
- async getSchemas({ includes } = {}) {
60
- const oas = await this.getOas();
61
- return _chunkP42X362Ucjs.getSchemas.call(void 0, { oas, contentType, includes });
62
- },
63
- async getBaseURL() {
64
- const oasInstance = await this.getOas();
65
- const baseURL = _optionalChain([oasInstance, 'access', _2 => _2.api, 'access', _3 => _3.servers, 'optionalAccess', _4 => _4.at, 'call', _5 => _5(serverIndex), 'optionalAccess', _6 => _6.url]);
66
- return baseURL;
67
- },
68
- contentType
69
- };
70
- },
71
- resolvePath(baseName) {
72
- if (output === false) {
73
- return void 0;
32
+ if (type === "operationId") {
33
+ return !!operation.getOperationId().match(pattern);
74
34
  }
75
- const root = _path2.default.resolve(this.config.root, this.config.output.path);
76
- return _path2.default.resolve(root, output.path, baseName);
77
- },
78
- resolveName(name, type) {
79
- return _transformers.camelCase.call(void 0, name, { isFile: type === "file" });
80
- },
81
- async buildStart() {
82
- if (!output) {
83
- return;
35
+ if (type === "path") {
36
+ return !!operation.path.match(pattern);
84
37
  }
85
- const oas = await getOas({
86
- config: this.config,
87
- logger: this.logger,
88
- formatOptions: {
89
- filterSet: filter,
90
- sortSet: sort
91
- }
92
- });
93
- await oas.dereference();
94
- const schemas = _chunkP42X362Ucjs.getSchemas.call(void 0, { oas, contentType });
95
- const mapSchema = async ([name, schema]) => {
96
- const resolvedPath = this.resolvePath({
97
- baseName: `${name}.json`,
98
- pluginKey: this.plugin.key
99
- });
100
- const resvoledFileName = this.resolveName({
101
- name: `${name}.json`,
102
- pluginKey: [pluginOasName],
103
- type: "file"
104
- });
105
- if (!resolvedPath) {
106
- return;
107
- }
108
- await this.addFile({
109
- path: resolvedPath,
110
- baseName: resvoledFileName,
111
- source: JSON.stringify(schema),
112
- meta: {
113
- pluginKey: this.plugin.key
114
- }
115
- });
116
- };
117
- const promises = Object.entries(schemas).map(mapSchema);
118
- await Promise.all(promises);
119
- }
120
- };
121
- });
122
-
123
- // src/OperationGenerator.ts
124
- _chunkP42X362Ucjs.init_cjs_shims.call(void 0, );
125
-
126
-
127
- var _operationsByMethod, _OperationGenerator_instances, getOptions_fn, isExcluded_fn, isIncluded_fn, methods_get;
128
- var OperationGenerator = class extends _core.Generator {
129
- constructor() {
130
- super(...arguments);
131
- _chunkP42X362Ucjs.__privateAdd.call(void 0, this, _OperationGenerator_instances);
132
- _chunkP42X362Ucjs.__privateAdd.call(void 0, this, _operationsByMethod, {});
38
+ if (type === "method") {
39
+ return !!method.match(pattern);
40
+ }
41
+ return false;
42
+ })?.options || {};
133
43
  }
134
- get operationsByMethod() {
135
- return _chunkP42X362Ucjs.__privateGet.call(void 0, this, _operationsByMethod);
44
+ /**
45
+ *
46
+ * @deprecated
47
+ */
48
+ #isExcluded(operation, method) {
49
+ const { exclude = [] } = this.context;
50
+ let matched = false;
51
+ exclude.forEach(({ pattern, type }) => {
52
+ if (type === "tag" && !matched) {
53
+ matched = !!operation.getTags()[0]?.name.match(pattern);
54
+ }
55
+ if (type === "operationId" && !matched) {
56
+ matched = !!operation.getOperationId().match(pattern);
57
+ }
58
+ if (type === "path" && !matched) {
59
+ matched = !!operation.path.match(pattern);
60
+ }
61
+ if (type === "method" && !matched) {
62
+ matched = !!method.match(pattern);
63
+ }
64
+ });
65
+ return matched;
136
66
  }
137
- set operationsByMethod(paths) {
138
- _chunkP42X362Ucjs.__privateSet.call(void 0, this, _operationsByMethod, paths);
67
+ /**
68
+ *
69
+ * @deprecated
70
+ */
71
+ #isIncluded(operation, method) {
72
+ const { include = [] } = this.context;
73
+ let matched = false;
74
+ include.forEach(({ pattern, type }) => {
75
+ if (type === "tag" && !matched) {
76
+ matched = !!operation.getTags()[0]?.name.match(pattern);
77
+ }
78
+ if (type === "operationId" && !matched) {
79
+ matched = !!operation.getOperationId().match(pattern);
80
+ }
81
+ if (type === "path" && !matched) {
82
+ matched = !!operation.path.match(pattern);
83
+ }
84
+ if (type === "method" && !matched) {
85
+ matched = !!method.match(pattern);
86
+ }
87
+ });
88
+ return matched;
139
89
  }
140
- getSchemas(operation, { forStatusCode, resolveName = (name) => name } = {}) {
90
+ getSchemas(operation, {
91
+ resolveName = (name) => name
92
+ } = {}) {
141
93
  const pathParamsSchema = this.context.oas.getParametersSchema(operation, "path");
142
94
  const queryParamsSchema = this.context.oas.getParametersSchema(operation, "query");
143
95
  const headerParamsSchema = this.context.oas.getParametersSchema(operation, "header");
144
96
  const requestSchema = this.context.oas.getRequestSchema(operation);
145
- const responseStatusCode = forStatusCode || operation.schema.responses && Object.keys(operation.schema.responses).find((key) => key.startsWith("2")) || 200;
97
+ const responseStatusCode = operation.schema.responses && Object.keys(operation.schema.responses).find((key) => key.startsWith("2")) || 200;
146
98
  const responseSchema = this.context.oas.getResponseSchema(operation, responseStatusCode);
147
99
  const statusCodes = operation.getResponseStatusCodes().map((statusCode) => {
148
100
  let name = statusCode;
@@ -151,76 +103,77 @@ var OperationGenerator = class extends _core.Generator {
151
103
  }
152
104
  const schema = this.context.oas.getResponseSchema(operation, statusCode);
153
105
  return {
154
- name: resolveName(_transformers2.default.pascalCase(`${operation.getOperationId()} ${name}`)),
155
- description: _optionalChain([operation, 'access', _7 => _7.getResponseByStatusCode, 'call', _8 => _8(statusCode), 'optionalAccess', _9 => _9.description]),
106
+ name: resolveName(transformers__default.default.pascalCase(`${operation.getOperationId()} ${name}`)),
107
+ description: operation.getResponseByStatusCode(statusCode)?.description,
156
108
  schema,
157
109
  operation,
158
- operationName: _transformers2.default.pascalCase(`${operation.getOperationId()}`),
110
+ operationName: transformers__default.default.pascalCase(`${operation.getOperationId()}`),
159
111
  statusCode: name === "error" ? void 0 : Number(statusCode),
160
- keys: _optionalChain([schema, 'optionalAccess', _10 => _10.properties]) ? Object.keys(schema.properties) : void 0
112
+ keys: schema?.properties ? Object.keys(schema.properties) : void 0
161
113
  };
162
114
  });
163
115
  return {
164
116
  pathParams: pathParamsSchema ? {
165
- name: resolveName(_transformers2.default.pascalCase(`${operation.getOperationId()} PathParams`)),
117
+ name: resolveName(transformers__default.default.pascalCase(`${operation.getOperationId()} PathParams`)),
166
118
  operation,
167
- operationName: _transformers2.default.pascalCase(`${operation.getOperationId()}`),
119
+ operationName: transformers__default.default.pascalCase(`${operation.getOperationId()}`),
168
120
  schema: pathParamsSchema,
169
121
  keys: pathParamsSchema.properties ? Object.keys(pathParamsSchema.properties) : void 0
170
122
  } : void 0,
171
123
  queryParams: queryParamsSchema ? {
172
- name: resolveName(_transformers2.default.pascalCase(`${operation.getOperationId()} QueryParams`)),
124
+ name: resolveName(transformers__default.default.pascalCase(`${operation.getOperationId()} QueryParams`)),
173
125
  operation,
174
- operationName: _transformers2.default.pascalCase(`${operation.getOperationId()}`),
126
+ operationName: transformers__default.default.pascalCase(`${operation.getOperationId()}`),
175
127
  schema: queryParamsSchema,
176
128
  keys: queryParamsSchema.properties ? Object.keys(queryParamsSchema.properties) : []
177
129
  } : void 0,
178
130
  headerParams: headerParamsSchema ? {
179
- name: resolveName(_transformers2.default.pascalCase(`${operation.getOperationId()} HeaderParams`)),
131
+ name: resolveName(transformers__default.default.pascalCase(`${operation.getOperationId()} HeaderParams`)),
180
132
  operation,
181
- operationName: _transformers2.default.pascalCase(`${operation.getOperationId()}`),
133
+ operationName: transformers__default.default.pascalCase(`${operation.getOperationId()}`),
182
134
  schema: headerParamsSchema,
183
135
  keys: headerParamsSchema.properties ? Object.keys(headerParamsSchema.properties) : void 0
184
136
  } : void 0,
185
137
  request: requestSchema ? {
186
- name: resolveName(_transformers2.default.pascalCase(`${operation.getOperationId()} ${operation.method === "get" ? "queryRequest" : "mutationRequest"}`)),
187
- description: _optionalChain([operation, 'access', _11 => _11.schema, 'access', _12 => _12.requestBody, 'optionalAccess', _13 => _13.description]),
138
+ name: resolveName(transformers__default.default.pascalCase(`${operation.getOperationId()} ${operation.method === "get" ? "queryRequest" : "mutationRequest"}`)),
139
+ description: operation.schema.requestBody?.description,
188
140
  operation,
189
- operationName: _transformers2.default.pascalCase(`${operation.getOperationId()}`),
141
+ operationName: transformers__default.default.pascalCase(`${operation.getOperationId()}`),
190
142
  schema: requestSchema,
191
143
  keys: requestSchema.properties ? Object.keys(requestSchema.properties) : void 0,
192
144
  keysToOmit: requestSchema.properties ? Object.keys(requestSchema.properties).filter((key) => {
193
- const item = _optionalChain([requestSchema, 'access', _14 => _14.properties, 'optionalAccess', _15 => _15[key]]);
194
- return _optionalChain([item, 'optionalAccess', _16 => _16.readOnly]);
145
+ const item = requestSchema.properties?.[key];
146
+ return item?.readOnly;
195
147
  }) : void 0
196
148
  } : void 0,
197
149
  response: {
198
- name: resolveName(_transformers2.default.pascalCase(`${operation.getOperationId()} ${operation.method === "get" ? "queryResponse" : "mutationResponse"}`)),
199
- description: _optionalChain([operation, 'access', _17 => _17.getResponseAsJSONSchema, 'call', _18 => _18(responseStatusCode), 'optionalAccess', _19 => _19.at, 'call', _20 => _20(0), 'optionalAccess', _21 => _21.description]),
150
+ name: resolveName(transformers__default.default.pascalCase(`${operation.getOperationId()} ${operation.method === "get" ? "queryResponse" : "mutationResponse"}`)),
151
+ description: operation.getResponseAsJSONSchema(responseStatusCode)?.at(0)?.description,
200
152
  operation,
201
- operationName: _transformers2.default.pascalCase(`${operation.getOperationId()}`),
153
+ operationName: transformers__default.default.pascalCase(`${operation.getOperationId()}`),
202
154
  schema: responseSchema,
203
155
  statusCode: Number(responseStatusCode),
204
- keys: _optionalChain([responseSchema, 'optionalAccess', _22 => _22.properties]) ? Object.keys(responseSchema.properties) : void 0,
205
- keysToOmit: _optionalChain([responseSchema, 'optionalAccess', _23 => _23.properties]) ? Object.keys(responseSchema.properties).filter((key) => {
206
- const item = _optionalChain([responseSchema, 'access', _24 => _24.properties, 'optionalAccess', _25 => _25[key]]);
207
- return _optionalChain([item, 'optionalAccess', _26 => _26.writeOnly]);
156
+ keys: responseSchema?.properties ? Object.keys(responseSchema.properties) : void 0,
157
+ keysToOmit: responseSchema?.properties ? Object.keys(responseSchema.properties).filter((key) => {
158
+ const item = responseSchema.properties?.[key];
159
+ return item?.writeOnly;
208
160
  }) : void 0
209
161
  },
210
- errors: statusCodes.filter((item) => _optionalChain([item, 'access', _27 => _27.statusCode, 'optionalAccess', _28 => _28.toString, 'call', _29 => _29(), 'access', _30 => _30.startsWith, 'call', _31 => _31("4")]) || _optionalChain([item, 'access', _32 => _32.statusCode, 'optionalAccess', _33 => _33.toString, 'call', _34 => _34(), 'access', _35 => _35.startsWith, 'call', _36 => _36("5")])),
162
+ errors: statusCodes.filter((item) => item.statusCode?.toString().startsWith("4") || item.statusCode?.toString().startsWith("5")),
211
163
  statusCodes
212
164
  };
213
165
  }
214
- async build() {
166
+ #methods = ["get", "post", "patch", "put", "delete"];
167
+ async build(...generators) {
215
168
  const { oas } = this.context;
216
169
  const paths = oas.getPaths();
217
170
  this.operationsByMethod = Object.entries(paths).reduce((acc, [path2, method]) => {
218
171
  const methods = Object.keys(method);
219
172
  methods.forEach((method2) => {
220
173
  const operation = oas.operation(path2, method2);
221
- if (operation && _chunkP42X362Ucjs.__privateGet.call(void 0, this, _OperationGenerator_instances, methods_get)[method2]) {
222
- const isExcluded = _chunkP42X362Ucjs.__privateMethod.call(void 0, this, _OperationGenerator_instances, isExcluded_fn).call(this, operation, method2);
223
- const isIncluded = this.context.include ? _chunkP42X362Ucjs.__privateMethod.call(void 0, this, _OperationGenerator_instances, isIncluded_fn).call(this, operation, method2) : true;
174
+ if (operation && [this.#methods].some((methods2) => method2 === operation.method)) {
175
+ const isExcluded = this.#isExcluded(operation, method2);
176
+ const isIncluded = this.context.include ? this.#isIncluded(operation, method2) : true;
224
177
  if (isIncluded && !isExcluded) {
225
178
  if (!acc[path2]) {
226
179
  acc[path2] = {};
@@ -240,27 +193,54 @@ var OperationGenerator = class extends _core.Generator {
240
193
  const promises = Object.keys(this.operationsByMethod).reduce((acc, path2) => {
241
194
  const methods = this.operationsByMethod[path2] ? Object.keys(this.operationsByMethod[path2]) : [];
242
195
  methods.forEach((method) => {
243
- const { operation } = _optionalChain([this, 'access', _37 => _37.operationsByMethod, 'access', _38 => _38[path2], 'optionalAccess', _39 => _39[method]]);
244
- const options = _chunkP42X362Ucjs.__privateMethod.call(void 0, this, _OperationGenerator_instances, getOptions_fn).call(this, operation, method);
245
- const promiseMethod = _optionalChain([_chunkP42X362Ucjs.__privateGet.call(void 0, this, _OperationGenerator_instances, methods_get), 'access', _40 => _40[method], 'optionalAccess', _41 => _41.call, 'call', _42 => _42(this, operation, {
246
- ...this.options,
247
- ...options
248
- })]);
196
+ const { operation } = this.operationsByMethod[path2]?.[method];
197
+ const options = this.#getOptions(operation, method);
198
+ const methodToCall = this[method];
199
+ if (typeof methodToCall === "function") {
200
+ const promiseMethod = methodToCall?.call(this, operation, {
201
+ ...this.options,
202
+ ...options
203
+ });
204
+ if (promiseMethod) {
205
+ acc.push(promiseMethod);
206
+ }
207
+ }
249
208
  const promiseOperation = this.operation.call(this, operation, {
250
209
  ...this.options,
251
210
  ...options
252
211
  });
253
- if (promiseMethod) {
254
- acc.push(promiseMethod);
255
- }
256
212
  if (promiseOperation) {
257
213
  acc.push(promiseOperation);
258
214
  }
215
+ generators?.forEach((generator) => {
216
+ const promise = generator.operation?.({
217
+ instance: this,
218
+ operation,
219
+ options: {
220
+ ...this.options,
221
+ ...options
222
+ }
223
+ });
224
+ if (promise) {
225
+ acc.push(promise);
226
+ }
227
+ });
259
228
  });
260
229
  return acc;
261
230
  }, []);
262
231
  const operations = Object.values(this.operationsByMethod).map((item) => Object.values(item).map((item2) => item2.operation));
263
232
  promises.push(this.all(operations.flat().filter(Boolean), this.operationsByMethod));
233
+ generators?.forEach((generator) => {
234
+ const promise = generator.operations?.({
235
+ instance: this,
236
+ operations: operations.flat().filter(Boolean),
237
+ operationsByMethod: this.operationsByMethod,
238
+ options: this.options
239
+ });
240
+ if (promise) {
241
+ promises.push(promise);
242
+ }
243
+ });
264
244
  const files = await Promise.all(promises);
265
245
  return files.flat().filter(Boolean);
266
246
  }
@@ -268,134 +248,176 @@ var OperationGenerator = class extends _core.Generator {
268
248
  * Operation
269
249
  */
270
250
  async operation(operation, options) {
271
- return null;
251
+ return [];
272
252
  }
273
253
  /**
274
254
  * GET
275
255
  */
276
256
  async get(operation, options) {
277
- return null;
257
+ return [];
278
258
  }
279
259
  /**
280
260
  * POST
281
261
  */
282
262
  async post(operation, options) {
283
- return null;
263
+ return [];
284
264
  }
285
265
  /**
286
266
  * PATCH
287
267
  */
288
268
  async patch(operation, options) {
289
- return null;
269
+ return [];
290
270
  }
291
271
  /**
292
272
  * PUT
293
273
  */
294
274
  async put(operation, options) {
295
- return null;
275
+ return [];
296
276
  }
297
277
  /**
298
278
  * DELETE
299
279
  */
300
280
  async delete(operation, options) {
301
- return null;
281
+ return [];
302
282
  }
303
283
  /**
304
284
  * Combination of GET, POST, PATCH, PUT, DELETE
305
285
  */
306
286
  async all(operations, paths) {
307
- return null;
287
+ return [];
308
288
  }
309
289
  };
310
- _operationsByMethod = new WeakMap();
311
- _OperationGenerator_instances = new WeakSet();
312
- getOptions_fn = function(operation, method) {
313
- const { override = [] } = this.context;
314
- return _optionalChain([override, 'access', _43 => _43.find, 'call', _44 => _44(({ pattern, type }) => {
315
- if (type === "tag") {
316
- return !!_optionalChain([operation, 'access', _45 => _45.getTags, 'call', _46 => _46(), 'access', _47 => _47[0], 'optionalAccess', _48 => _48.name, 'access', _49 => _49.match, 'call', _50 => _50(pattern)]);
317
- }
318
- if (type === "operationId") {
319
- return !!operation.getOperationId().match(pattern);
320
- }
321
- if (type === "path") {
322
- return !!operation.path.match(pattern);
323
- }
324
- if (type === "method") {
325
- return !!method.match(pattern);
326
- }
327
- return false;
328
- }), 'optionalAccess', _51 => _51.options]) || {};
329
- };
330
- /**
331
- *
332
- * @deprecated
333
- */
334
- isExcluded_fn = function(operation, method) {
335
- const { exclude = [] } = this.context;
336
- let matched = false;
337
- exclude.forEach(({ pattern, type }) => {
338
- if (type === "tag" && !matched) {
339
- matched = !!_optionalChain([operation, 'access', _52 => _52.getTags, 'call', _53 => _53(), 'access', _54 => _54[0], 'optionalAccess', _55 => _55.name, 'access', _56 => _56.match, 'call', _57 => _57(pattern)]);
340
- }
341
- if (type === "operationId" && !matched) {
342
- matched = !!operation.getOperationId().match(pattern);
343
- }
344
- if (type === "path" && !matched) {
345
- matched = !!operation.path.match(pattern);
346
- }
347
- if (type === "method" && !matched) {
348
- matched = !!method.match(pattern);
349
- }
350
- });
351
- return matched;
352
- };
353
- /**
354
- *
355
- * @deprecated
356
- */
357
- isIncluded_fn = function(operation, method) {
358
- const { include = [] } = this.context;
359
- let matched = false;
360
- include.forEach(({ pattern, type }) => {
361
- if (type === "tag" && !matched) {
362
- matched = !!_optionalChain([operation, 'access', _58 => _58.getTags, 'call', _59 => _59(), 'access', _60 => _60[0], 'optionalAccess', _61 => _61.name, 'access', _62 => _62.match, 'call', _63 => _63(pattern)]);
363
- }
364
- if (type === "operationId" && !matched) {
365
- matched = !!operation.getOperationId().match(pattern);
366
- }
367
- if (type === "path" && !matched) {
368
- matched = !!operation.path.match(pattern);
369
- }
370
- if (type === "method" && !matched) {
371
- matched = !!method.match(pattern);
290
+ var pluginOasName = "plugin-oas";
291
+ var pluginOas = core.createPlugin((options) => {
292
+ const {
293
+ output = {
294
+ path: "schemas",
295
+ export: false,
296
+ exportType: "barrelNamed"
297
+ },
298
+ experimentalFilter: filter,
299
+ experimentalSort: sort,
300
+ validate = true,
301
+ generators = [chunk6UWOTOZJ_cjs.jsonGenerator],
302
+ serverIndex = 0,
303
+ contentType,
304
+ oasClass
305
+ } = options;
306
+ const getOas = async ({ config, logger, formatOptions }) => {
307
+ try {
308
+ const oas = await chunkUO57DZPV_cjs.parseFromConfig(config, formatOptions, oasClass);
309
+ if (validate) {
310
+ await oas.valdiate();
311
+ }
312
+ return oas;
313
+ } catch (e) {
314
+ const error = e;
315
+ logger.emit("warning", error?.message);
316
+ return chunkUO57DZPV_cjs.parseFromConfig(config, {}, oasClass);
372
317
  }
373
- });
374
- return matched;
375
- };
376
- methods_get = function() {
318
+ };
377
319
  return {
378
- get: this.get,
379
- post: this.post,
380
- patch: this.patch,
381
- put: this.put,
382
- delete: this.delete,
383
- head: void 0,
384
- options: void 0,
385
- trace: void 0
320
+ name: pluginOasName,
321
+ options: {
322
+ output,
323
+ ...options
324
+ },
325
+ context() {
326
+ const { config, logger } = this;
327
+ return {
328
+ getOas(formatOptions) {
329
+ return getOas({ config, logger, formatOptions });
330
+ },
331
+ async getSchemas({ includes } = {}) {
332
+ const oas = await this.getOas();
333
+ return chunkHP5WAFBU_cjs.getSchemas({ oas, contentType, includes });
334
+ },
335
+ async getBaseURL() {
336
+ const oasInstance = await this.getOas();
337
+ return oasInstance.api.servers?.at(serverIndex)?.url;
338
+ },
339
+ contentType
340
+ };
341
+ },
342
+ resolvePath(baseName, pathMode, options2) {
343
+ const root = path__default.default.resolve(this.config.root, this.config.output.path);
344
+ const mode = pathMode ?? core.FileManager.getMode(path__default.default.resolve(root, output.path));
345
+ if (mode === "single") {
346
+ return path__default.default.resolve(root, output.path);
347
+ }
348
+ return path__default.default.resolve(root, output.path, baseName);
349
+ },
350
+ async buildStart() {
351
+ if (!output) {
352
+ return;
353
+ }
354
+ const oas = await getOas({
355
+ config: this.config,
356
+ logger: this.logger,
357
+ formatOptions: {
358
+ filterSet: filter,
359
+ sortSet: sort
360
+ }
361
+ });
362
+ await oas.dereference();
363
+ const schemaGenerator = new chunkJNGUNN72_cjs.SchemaGenerator(
364
+ {
365
+ unknownType: "unknown",
366
+ dateType: "date",
367
+ transformers: {},
368
+ ...this.plugin.options
369
+ },
370
+ {
371
+ oas,
372
+ pluginManager: this.pluginManager,
373
+ plugin: this.plugin,
374
+ contentType,
375
+ include: void 0,
376
+ override: void 0,
377
+ mode: "split",
378
+ output: output.path
379
+ }
380
+ );
381
+ const schemaFiles = await schemaGenerator.build(...generators);
382
+ await this.addFile(...schemaFiles);
383
+ const operationGenerator = new OperationGenerator(this.plugin.options, {
384
+ oas,
385
+ pluginManager: this.pluginManager,
386
+ plugin: this.plugin,
387
+ contentType,
388
+ exclude: void 0,
389
+ include: void 0,
390
+ override: void 0,
391
+ mode: "split"
392
+ });
393
+ const operationFiles = await operationGenerator.build(...generators);
394
+ await this.addFile(...operationFiles);
395
+ }
386
396
  };
387
- };
388
-
389
- // src/index.ts
390
- var definePluginDefault = pluginOas;
391
- var src_default = definePluginDefault;
392
-
393
-
394
-
395
-
396
-
397
-
398
-
397
+ });
399
398
 
400
- exports.OperationGenerator = OperationGenerator; exports.SchemaGenerator = _chunkCJXRFYEFcjs.SchemaGenerator; exports.default = src_default; exports.isKeyword = _chunkCJXRFYEFcjs.isKeyword; exports.pluginOas = pluginOas; exports.pluginOasName = pluginOasName; exports.schemaKeywords = _chunkCJXRFYEFcjs.schemaKeywords;
399
+ Object.defineProperty(exports, "createGenerator", {
400
+ enumerable: true,
401
+ get: function () { return chunk6UWOTOZJ_cjs.createGenerator; }
402
+ });
403
+ Object.defineProperty(exports, "createReactGenerator", {
404
+ enumerable: true,
405
+ get: function () { return chunk6UWOTOZJ_cjs.createReactGenerator; }
406
+ });
407
+ Object.defineProperty(exports, "SchemaGenerator", {
408
+ enumerable: true,
409
+ get: function () { return chunkJNGUNN72_cjs.SchemaGenerator; }
410
+ });
411
+ Object.defineProperty(exports, "isKeyword", {
412
+ enumerable: true,
413
+ get: function () { return chunkJNGUNN72_cjs.isKeyword; }
414
+ });
415
+ Object.defineProperty(exports, "schemaKeywords", {
416
+ enumerable: true,
417
+ get: function () { return chunkJNGUNN72_cjs.schemaKeywords; }
418
+ });
419
+ exports.OperationGenerator = OperationGenerator;
420
+ exports.pluginOas = pluginOas;
421
+ exports.pluginOasName = pluginOasName;
422
+ //# sourceMappingURL=index.cjs.map
401
423
  //# sourceMappingURL=index.cjs.map