@kubb/plugin-oas 2.26.3 → 2.26.5
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/dist/{OperationGenerator-BV6QRtkW.d.cts → OperationGenerator-8tADySO6.d.cts} +1 -1
- package/dist/{OperationGenerator-DO5tNGuT.d.ts → OperationGenerator-DvyNt6Xi.d.ts} +1 -1
- package/dist/{Schema-CkGDfE-r.d.ts → Schema-BCe0nBHJ.d.ts} +1 -1
- package/dist/{Schema-CxKiczSe.d.cts → Schema-tJWinW5z.d.cts} +1 -1
- package/dist/{SchemaMapper-BLcXlDBz.d.cts → SchemaMapper-CAEI86qj.d.cts} +4 -4
- package/dist/{SchemaMapper-BLcXlDBz.d.ts → SchemaMapper-CAEI86qj.d.ts} +4 -4
- package/dist/{chunk-P42X362U.cjs → chunk-2BGY3BRC.cjs} +3 -3
- package/dist/{chunk-P42X362U.cjs.map → chunk-2BGY3BRC.cjs.map} +1 -1
- package/dist/{chunk-UB552H4J.js → chunk-2YX4XBMY.js} +3 -3
- package/dist/{chunk-UB552H4J.js.map → chunk-2YX4XBMY.js.map} +1 -1
- package/dist/{chunk-Y4V7HHX7.js → chunk-B3QCCJ62.js} +9 -9
- package/dist/chunk-B3QCCJ62.js.map +1 -0
- package/dist/{chunk-QLJIL3U5.cjs → chunk-HUFRXC4N.cjs} +9 -9
- package/dist/chunk-HUFRXC4N.cjs.map +1 -0
- package/dist/{chunk-LZQCNTEQ.js → chunk-NLKNZBXU.js} +30 -2
- package/dist/chunk-NLKNZBXU.js.map +1 -0
- package/dist/{chunk-MCFS76QE.cjs → chunk-OV72HOID.cjs} +23 -23
- package/dist/{chunk-MCFS76QE.cjs.map → chunk-OV72HOID.cjs.map} +1 -1
- package/dist/{chunk-7667TDWD.js → chunk-U3JET6VT.js} +3 -3
- package/dist/{chunk-YQ6GIIKL.cjs → chunk-WF523MBA.cjs} +49 -21
- package/dist/chunk-WF523MBA.cjs.map +1 -0
- package/dist/components.cjs +5 -5
- package/dist/components.d.cts +4 -5
- package/dist/components.d.ts +4 -5
- package/dist/components.js +3 -3
- package/dist/hooks.cjs +13 -13
- package/dist/hooks.d.cts +3 -4
- package/dist/hooks.d.ts +3 -4
- package/dist/hooks.js +3 -3
- package/dist/index.cjs +25 -37
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -6
- package/dist/index.d.ts +5 -6
- package/dist/index.js +11 -23
- package/dist/index.js.map +1 -1
- package/dist/{types-Db0qp8u-.d.cts → types-RVAPVtNi.d.cts} +1 -4
- package/dist/{types-Db0qp8u-.d.ts → types-RVAPVtNi.d.ts} +1 -4
- package/dist/utils.cjs +8 -8
- package/dist/utils.d.cts +3 -4
- package/dist/utils.d.ts +3 -4
- package/dist/utils.js +3 -3
- package/package.json +13 -13
- package/src/SchemaGenerator.ts +29 -0
- package/src/SchemaMapper.ts +4 -4
- package/src/plugin.ts +7 -20
- package/src/types.ts +1 -4
- package/src/utils/parseFromConfig.ts +7 -7
- package/dist/chunk-LZQCNTEQ.js.map +0 -1
- package/dist/chunk-QLJIL3U5.cjs.map +0 -1
- package/dist/chunk-Y4V7HHX7.js.map +0 -1
- package/dist/chunk-YQ6GIIKL.cjs.map +0 -1
- /package/dist/{chunk-7667TDWD.js.map → chunk-U3JET6VT.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
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; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkHUFRXC4Ncjs = require('./chunk-HUFRXC4N.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkWF523MBAcjs = require('./chunk-WF523MBA.cjs');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
@@ -13,30 +13,22 @@ var _chunkYQ6GIIKLcjs = require('./chunk-YQ6GIIKL.cjs');
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _chunk2BGY3BRCcjs = require('./chunk-2BGY3BRC.cjs');
|
|
17
17
|
|
|
18
18
|
// src/index.ts
|
|
19
|
-
|
|
19
|
+
_chunk2BGY3BRCcjs.init_cjs_shims.call(void 0, );
|
|
20
20
|
|
|
21
21
|
// src/plugin.ts
|
|
22
|
-
|
|
22
|
+
_chunk2BGY3BRCcjs.init_cjs_shims.call(void 0, );
|
|
23
23
|
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
24
24
|
var _core = require('@kubb/core');
|
|
25
25
|
var _transformers = require('@kubb/core/transformers'); var _transformers2 = _interopRequireDefault(_transformers);
|
|
26
26
|
var pluginOasName = "plugin-oas";
|
|
27
27
|
var pluginOas = _core.createPlugin.call(void 0, (options) => {
|
|
28
|
-
const {
|
|
29
|
-
|
|
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 }) => {
|
|
28
|
+
const { output = { path: "schemas", export: false }, validate = true, serverIndex = 0, contentType, oasClass } = options;
|
|
29
|
+
const getOas = async ({ config, logger }) => {
|
|
38
30
|
try {
|
|
39
|
-
const oas = await
|
|
31
|
+
const oas = await _chunkHUFRXC4Ncjs.parseFromConfig.call(void 0, config, oasClass);
|
|
40
32
|
if (validate) {
|
|
41
33
|
await oas.valdiate();
|
|
42
34
|
}
|
|
@@ -44,7 +36,7 @@ var pluginOas = _core.createPlugin.call(void 0, (options) => {
|
|
|
44
36
|
} catch (e) {
|
|
45
37
|
const error = e;
|
|
46
38
|
logger.emit("warning", _optionalChain([error, 'optionalAccess', _ => _.message]));
|
|
47
|
-
return
|
|
39
|
+
return _chunkHUFRXC4Ncjs.parseFromConfig.call(void 0, config, oasClass);
|
|
48
40
|
}
|
|
49
41
|
};
|
|
50
42
|
return {
|
|
@@ -53,12 +45,12 @@ var pluginOas = _core.createPlugin.call(void 0, (options) => {
|
|
|
53
45
|
api() {
|
|
54
46
|
const { config, logger } = this;
|
|
55
47
|
return {
|
|
56
|
-
getOas(
|
|
57
|
-
return getOas({ config, logger
|
|
48
|
+
getOas() {
|
|
49
|
+
return getOas({ config, logger });
|
|
58
50
|
},
|
|
59
51
|
async getSchemas({ includes } = {}) {
|
|
60
52
|
const oas = await this.getOas();
|
|
61
|
-
return
|
|
53
|
+
return _chunk2BGY3BRCcjs.getSchemas.call(void 0, { oas, contentType, includes });
|
|
62
54
|
},
|
|
63
55
|
async getBaseURL() {
|
|
64
56
|
const oasInstance = await this.getOas();
|
|
@@ -90,14 +82,10 @@ var pluginOas = _core.createPlugin.call(void 0, (options) => {
|
|
|
90
82
|
}
|
|
91
83
|
const oas = await getOas({
|
|
92
84
|
config: this.config,
|
|
93
|
-
logger: this.logger
|
|
94
|
-
formatOptions: {
|
|
95
|
-
filterSet: filter,
|
|
96
|
-
sortSet: sort
|
|
97
|
-
}
|
|
85
|
+
logger: this.logger
|
|
98
86
|
});
|
|
99
87
|
await oas.dereference();
|
|
100
|
-
const schemas =
|
|
88
|
+
const schemas = _chunk2BGY3BRCcjs.getSchemas.call(void 0, { oas, contentType });
|
|
101
89
|
const mapSchema = async ([name, schema]) => {
|
|
102
90
|
const resolvedPath = this.resolvePath({
|
|
103
91
|
baseName: `${name}.json`,
|
|
@@ -127,21 +115,21 @@ var pluginOas = _core.createPlugin.call(void 0, (options) => {
|
|
|
127
115
|
});
|
|
128
116
|
|
|
129
117
|
// src/OperationGenerator.ts
|
|
130
|
-
|
|
118
|
+
_chunk2BGY3BRCcjs.init_cjs_shims.call(void 0, );
|
|
131
119
|
|
|
132
120
|
|
|
133
121
|
var _operationsByMethod, _OperationGenerator_instances, getOptions_fn, isExcluded_fn, isIncluded_fn, methods_get;
|
|
134
122
|
var OperationGenerator = class extends _core.Generator {
|
|
135
123
|
constructor() {
|
|
136
124
|
super(...arguments);
|
|
137
|
-
|
|
138
|
-
|
|
125
|
+
_chunk2BGY3BRCcjs.__privateAdd.call(void 0, this, _OperationGenerator_instances);
|
|
126
|
+
_chunk2BGY3BRCcjs.__privateAdd.call(void 0, this, _operationsByMethod, {});
|
|
139
127
|
}
|
|
140
128
|
get operationsByMethod() {
|
|
141
|
-
return
|
|
129
|
+
return _chunk2BGY3BRCcjs.__privateGet.call(void 0, this, _operationsByMethod);
|
|
142
130
|
}
|
|
143
131
|
set operationsByMethod(paths) {
|
|
144
|
-
|
|
132
|
+
_chunk2BGY3BRCcjs.__privateSet.call(void 0, this, _operationsByMethod, paths);
|
|
145
133
|
}
|
|
146
134
|
getSchemas(operation, { forStatusCode, resolveName = (name) => name } = {}) {
|
|
147
135
|
const pathParamsSchema = this.context.oas.getParametersSchema(operation, "path");
|
|
@@ -224,9 +212,9 @@ var OperationGenerator = class extends _core.Generator {
|
|
|
224
212
|
const methods = Object.keys(method);
|
|
225
213
|
methods.forEach((method2) => {
|
|
226
214
|
const operation = oas.operation(path2, method2);
|
|
227
|
-
if (operation &&
|
|
228
|
-
const isExcluded =
|
|
229
|
-
const isIncluded = this.context.include ?
|
|
215
|
+
if (operation && _chunk2BGY3BRCcjs.__privateGet.call(void 0, this, _OperationGenerator_instances, methods_get)[method2]) {
|
|
216
|
+
const isExcluded = _chunk2BGY3BRCcjs.__privateMethod.call(void 0, this, _OperationGenerator_instances, isExcluded_fn).call(this, operation, method2);
|
|
217
|
+
const isIncluded = this.context.include ? _chunk2BGY3BRCcjs.__privateMethod.call(void 0, this, _OperationGenerator_instances, isIncluded_fn).call(this, operation, method2) : true;
|
|
230
218
|
if (isIncluded && !isExcluded) {
|
|
231
219
|
if (!acc[path2]) {
|
|
232
220
|
acc[path2] = {};
|
|
@@ -247,8 +235,8 @@ var OperationGenerator = class extends _core.Generator {
|
|
|
247
235
|
const methods = this.operationsByMethod[path2] ? Object.keys(this.operationsByMethod[path2]) : [];
|
|
248
236
|
methods.forEach((method) => {
|
|
249
237
|
const { operation } = _optionalChain([this, 'access', _37 => _37.operationsByMethod, 'access', _38 => _38[path2], 'optionalAccess', _39 => _39[method]]);
|
|
250
|
-
const options =
|
|
251
|
-
const promiseMethod = _optionalChain([
|
|
238
|
+
const options = _chunk2BGY3BRCcjs.__privateMethod.call(void 0, this, _OperationGenerator_instances, getOptions_fn).call(this, operation, method);
|
|
239
|
+
const promiseMethod = _optionalChain([_chunk2BGY3BRCcjs.__privateGet.call(void 0, this, _OperationGenerator_instances, methods_get), 'access', _40 => _40[method], 'optionalAccess', _41 => _41.call, 'call', _42 => _42(this, operation, {
|
|
252
240
|
...this.options,
|
|
253
241
|
...options
|
|
254
242
|
})]);
|
|
@@ -403,5 +391,5 @@ var src_default = definePluginDefault;
|
|
|
403
391
|
|
|
404
392
|
|
|
405
393
|
|
|
406
|
-
exports.OperationGenerator = OperationGenerator; exports.SchemaGenerator =
|
|
394
|
+
exports.OperationGenerator = OperationGenerator; exports.SchemaGenerator = _chunkWF523MBAcjs.SchemaGenerator; exports.default = src_default; exports.isKeyword = _chunkWF523MBAcjs.isKeyword; exports.pluginOas = pluginOas; exports.pluginOasName = pluginOasName; exports.schemaKeywords = _chunkWF523MBAcjs.schemaKeywords;
|
|
407
395
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/kub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A;AAEa,IAAA;AACC,MAAA;AACd,IAAA;AAEa,IAAA;AACC,MAAA;AACd,IAAA;AACD,EAAA;AAEM,EAAA;AACT;AAAA;AAAA;AAAA;AAAA;AAKW;AACU,EAAA;AACL,EAAA;AAEK,EAAA;AACJ,IAAA;AACC,MAAA;AACd,IAAA;AAEa,IAAA;AACC,MAAA;AACd,IAAA;AAEa,IAAA;AACC,MAAA;AACd,IAAA;AAEa,IAAA;AACC,MAAA;AACd,IAAA;AACD,EAAA;AAEM,EAAA;AACT;AAiGY;AACH,EAAA;AACK,IAAA;AACC,IAAA;AACC,IAAA;AACF,IAAA;AACG,IAAA;AACP,IAAA;AACG,IAAA;AACF,IAAA;AACT,EAAA;AACF;AHmKmB;AACA;AC9Wf;AAES;AD+WM;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/kubb/kubb/packages/plugin-oas/dist/index.cjs","sourcesContent":[null,"import { pluginOas } from './plugin.ts'\n\nexport type {\n GetOperationGeneratorOptions,\n OperationMethodResult,\n} from './OperationGenerator.ts'\nexport { OperationGenerator } from './OperationGenerator.ts'\nexport { pluginOas, pluginOasName } from './plugin.ts'\nexport type {\n GetSchemaGeneratorOptions,\n SchemaGeneratorBuildOptions,\n SchemaGeneratorOptions,\n} from './SchemaGenerator.ts'\nexport type { SchemaMethodResult } from './SchemaGenerator.ts'\nexport { SchemaGenerator } from './SchemaGenerator.ts'\nexport type {\n Schema,\n SchemaKeyword,\n SchemaKeywordBase,\n SchemaKeywordMapper,\n SchemaMapper,\n} from './SchemaMapper.ts'\nexport { isKeyword, schemaKeywords } from './SchemaMapper.ts'\nexport type * from './types.ts'\n\n/**\n * @deprecated Use `import { pluginOas } from '@kubb/plugin-oas'` instead\n */\nconst definePluginDefault = pluginOas\n\nexport default definePluginDefault\n","import path from 'node:path'\n\nimport { createPlugin } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\n\nimport { getSchemas } from './utils/getSchemas.ts'\n\nimport type { Config } from '@kubb/core'\nimport type { Logger } from '@kubb/core/logger'\nimport type { Oas, OasTypes } from '@kubb/oas'\nimport type { FormatOptions } from '@kubb/oas/parser'\nimport type { PluginOas } from './types.ts'\nimport { parseFromConfig } from './utils/parseFromConfig.ts'\n\nexport const pluginOasName = 'plugin-oas' satisfies PluginOas['name']\n\nexport const pluginOas = createPlugin<PluginOas>((options) => {\n const {\n output = { path: 'schemas', export: false },\n experimentalFilter: filter,\n experimentalSort: sort,\n validate = true,\n serverIndex = 0,\n contentType,\n oasClass,\n } = options\n\n const getOas = async ({ config, logger, formatOptions }: { config: Config; logger: Logger; formatOptions?: FormatOptions }): Promise<Oas> => {\n try {\n // needs to be in a different variable or the catch here will not work(return of a promise instead)\n const oas = await parseFromConfig(config, formatOptions, oasClass)\n\n if (validate) {\n await oas.valdiate()\n }\n\n return oas\n } catch (e) {\n const error = e as Error\n\n logger.emit('warning', error?.message)\n return parseFromConfig(config, {}, oasClass)\n }\n }\n\n return {\n name: pluginOasName,\n options,\n\n api() {\n const { config, logger } = this\n\n return {\n getOas(formatOptions) {\n return getOas({ config, logger, formatOptions })\n },\n async getSchemas({ includes } = {}) {\n const oas = await this.getOas()\n return getSchemas({ oas, contentType, includes })\n },\n async getBaseURL() {\n const oasInstance = await this.getOas()\n const baseURL = oasInstance.api.servers?.at(serverIndex)?.url\n return baseURL\n },\n contentType,\n }\n },\n resolvePath(baseName) {\n if (output === false) {\n return undefined\n }\n\n const root = path.resolve(this.config.root, this.config.output.path)\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n return camelCase(name, { isFile: type === 'file' })\n },\n async writeFile(path, source) {\n if (!path.endsWith('.json') || !source) {\n return\n }\n\n return this.fileManager.write(path, source, { sanity: false })\n },\n async buildStart() {\n if (!output) {\n return\n }\n\n const oas = await getOas({\n config: this.config,\n logger: this.logger,\n formatOptions: {\n filterSet: filter,\n sortSet: sort,\n },\n })\n await oas.dereference()\n const schemas = getSchemas({ oas, contentType })\n\n const mapSchema = async ([name, schema]: [string, OasTypes.SchemaObject]) => {\n const resolvedPath = this.resolvePath({\n baseName: `${name}.json`,\n pluginKey: this.plugin.key,\n })\n\n const resvoledFileName = this.resolveName({\n name: `${name}.json`,\n pluginKey: [pluginOasName],\n type: 'file',\n }) as `${string}.json`\n\n if (!resolvedPath) {\n return\n }\n\n await this.addFile({\n path: resolvedPath,\n baseName: resvoledFileName,\n source: JSON.stringify(schema),\n meta: {\n pluginKey: this.plugin.key,\n },\n })\n }\n\n const promises = Object.entries(schemas).map(mapSchema)\n await Promise.all(promises)\n },\n }\n})\n","import { type FileMetaBase, Generator } from '@kubb/core'\nimport transformers from '@kubb/core/transformers'\n\nimport type { PluginFactoryOptions, PluginManager } from '@kubb/core'\nimport type * as KubbFile from '@kubb/fs/types'\n\nimport type { Plugin } from '@kubb/core'\nimport type { HttpMethod, Oas, OasTypes, Operation, contentType } from '@kubb/oas'\nimport type { Exclude, Include, OperationSchemas, OperationsByMethod, Override } from './types.ts'\n\nexport type GetOperationGeneratorOptions<T extends OperationGenerator<any, any, any>> = T extends OperationGenerator<infer Options, any, any> ? Options : never\n\nexport type OperationMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>\n\ntype Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {\n oas: Oas\n exclude: Array<Exclude> | undefined\n include: Array<Include> | undefined\n override: Array<Override<TOptions>> | undefined\n contentType: contentType | undefined\n pluginManager: PluginManager\n /**\n * Current plugin\n */\n plugin: Plugin<TPluginOptions>\n mode: KubbFile.Mode\n}\n\nexport abstract class OperationGenerator<\n TOptions = unknown,\n TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions,\n TFileMeta extends FileMetaBase = FileMetaBase,\n> extends Generator<TOptions, Context<TOptions, TPluginOptions>> {\n #operationsByMethod: OperationsByMethod = {}\n get operationsByMethod(): OperationsByMethod {\n return this.#operationsByMethod\n }\n\n set operationsByMethod(paths: OperationsByMethod) {\n this.#operationsByMethod = paths\n }\n\n #getOptions(operation: Operation, method: HttpMethod): Partial<TOptions> {\n const { override = [] } = this.context\n\n return (\n override.find(({ pattern, type }) => {\n if (type === 'tag') {\n return !!operation.getTags()[0]?.name.match(pattern)\n }\n\n if (type === 'operationId') {\n return !!operation.getOperationId().match(pattern)\n }\n\n if (type === 'path') {\n return !!operation.path.match(pattern)\n }\n\n if (type === 'method') {\n return !!method.match(pattern)\n }\n\n return false\n })?.options || {}\n )\n }\n /**\n *\n * @deprecated\n */\n #isExcluded(operation: Operation, method: HttpMethod): boolean {\n const { exclude = [] } = this.context\n let matched = false\n\n exclude.forEach(({ pattern, type }) => {\n if (type === 'tag' && !matched) {\n matched = !!operation.getTags()[0]?.name.match(pattern)\n }\n\n if (type === 'operationId' && !matched) {\n matched = !!operation.getOperationId().match(pattern)\n }\n\n if (type === 'path' && !matched) {\n matched = !!operation.path.match(pattern)\n }\n\n if (type === 'method' && !matched) {\n matched = !!method.match(pattern)\n }\n })\n\n return matched\n }\n /**\n *\n * @deprecated\n */\n #isIncluded(operation: Operation, method: HttpMethod): boolean {\n const { include = [] } = this.context\n let matched = false\n\n include.forEach(({ pattern, type }) => {\n if (type === 'tag' && !matched) {\n matched = !!operation.getTags()[0]?.name.match(pattern)\n }\n\n if (type === 'operationId' && !matched) {\n matched = !!operation.getOperationId().match(pattern)\n }\n\n if (type === 'path' && !matched) {\n matched = !!operation.path.match(pattern)\n }\n\n if (type === 'method' && !matched) {\n matched = !!method.match(pattern)\n }\n })\n\n return matched\n }\n\n getSchemas(\n operation: Operation,\n { forStatusCode, resolveName = (name) => name }: { forStatusCode?: string | number; resolveName?: (name: string) => string } = {},\n ): OperationSchemas {\n const pathParamsSchema = this.context.oas.getParametersSchema(operation, 'path')\n const queryParamsSchema = this.context.oas.getParametersSchema(operation, 'query')\n const headerParamsSchema = this.context.oas.getParametersSchema(operation, 'header')\n const requestSchema = this.context.oas.getRequestSchema(operation)\n const responseStatusCode =\n forStatusCode || (operation.schema.responses && Object.keys(operation.schema.responses).find((key) => key.startsWith('2'))) || 200\n const responseSchema = this.context.oas.getResponseSchema(operation, responseStatusCode)\n const statusCodes = operation.getResponseStatusCodes().map((statusCode) => {\n let name = statusCode\n if (name === 'default') {\n name = 'error'\n }\n\n const schema = this.context.oas.getResponseSchema(operation, statusCode)\n\n return {\n name: resolveName(transformers.pascalCase(`${operation.getOperationId()} ${name}`)),\n description: (operation.getResponseByStatusCode(statusCode) as OasTypes.ResponseObject)?.description,\n schema,\n operation,\n operationName: transformers.pascalCase(`${operation.getOperationId()}`),\n statusCode: name === 'error' ? undefined : Number(statusCode),\n keys: schema?.properties ? Object.keys(schema.properties) : undefined,\n }\n })\n\n return {\n pathParams: pathParamsSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operation.getOperationId()} PathParams`)),\n operation,\n operationName: transformers.pascalCase(`${operation.getOperationId()}`),\n schema: pathParamsSchema,\n keys: pathParamsSchema.properties ? Object.keys(pathParamsSchema.properties) : undefined,\n }\n : undefined,\n queryParams: queryParamsSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operation.getOperationId()} QueryParams`)),\n operation,\n operationName: transformers.pascalCase(`${operation.getOperationId()}`),\n schema: queryParamsSchema,\n keys: queryParamsSchema.properties ? Object.keys(queryParamsSchema.properties) : [],\n }\n : undefined,\n headerParams: headerParamsSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operation.getOperationId()} HeaderParams`)),\n operation,\n operationName: transformers.pascalCase(`${operation.getOperationId()}`),\n schema: headerParamsSchema,\n keys: headerParamsSchema.properties ? Object.keys(headerParamsSchema.properties) : undefined,\n }\n : undefined,\n request: requestSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operation.getOperationId()} ${operation.method === 'get' ? 'queryRequest' : 'mutationRequest'}`)),\n description: (operation.schema.requestBody as OasTypes.RequestBodyObject)?.description,\n operation,\n operationName: transformers.pascalCase(`${operation.getOperationId()}`),\n schema: requestSchema,\n keys: requestSchema.properties ? Object.keys(requestSchema.properties) : undefined,\n keysToOmit: requestSchema.properties\n ? Object.keys(requestSchema.properties).filter((key) => {\n const item = requestSchema.properties?.[key] as OasTypes.SchemaObject\n\n return item?.readOnly\n })\n : undefined,\n }\n : undefined,\n response: {\n name: resolveName(transformers.pascalCase(`${operation.getOperationId()} ${operation.method === 'get' ? 'queryResponse' : 'mutationResponse'}`)),\n description: operation.getResponseAsJSONSchema(responseStatusCode)?.at(0)?.description,\n operation,\n operationName: transformers.pascalCase(`${operation.getOperationId()}`),\n schema: responseSchema,\n statusCode: Number(responseStatusCode),\n keys: responseSchema?.properties ? Object.keys(responseSchema.properties) : undefined,\n keysToOmit: responseSchema?.properties\n ? Object.keys(responseSchema.properties).filter((key) => {\n const item = responseSchema.properties?.[key] as OasTypes.SchemaObject\n return item?.writeOnly\n })\n : undefined,\n },\n errors: statusCodes.filter((item) => item.statusCode?.toString().startsWith('4') || item.statusCode?.toString().startsWith('5')),\n statusCodes,\n }\n }\n\n get #methods() {\n return {\n get: this.get,\n post: this.post,\n patch: this.patch,\n put: this.put,\n delete: this.delete,\n head: undefined,\n options: undefined,\n trace: undefined,\n } as const\n }\n\n async build(): Promise<Array<KubbFile.File<TFileMeta>>> {\n const { oas } = this.context\n\n const paths = oas.getPaths()\n this.operationsByMethod = Object.entries(paths).reduce((acc, [path, method]) => {\n const methods = Object.keys(method) as HttpMethod[]\n\n methods.forEach((method) => {\n const operation = oas.operation(path, method)\n if (operation && this.#methods[method]) {\n const isExcluded = this.#isExcluded(operation, method)\n const isIncluded = this.context.include ? this.#isIncluded(operation, method) : true\n\n if (isIncluded && !isExcluded) {\n if (!acc[path]) {\n acc[path] = {} as OperationsByMethod['get']\n }\n acc[path] = {\n ...acc[path],\n [method]: {\n operation,\n schemas: this.getSchemas(operation),\n },\n } as OperationsByMethod['get']\n }\n }\n })\n\n return acc\n }, {} as OperationsByMethod)\n\n const promises = Object.keys(this.operationsByMethod).reduce((acc, path) => {\n const methods = this.operationsByMethod[path] ? (Object.keys(this.operationsByMethod[path]!) as HttpMethod[]) : []\n\n methods.forEach((method) => {\n const { operation } = this.operationsByMethod[path]?.[method]!\n const options = this.#getOptions(operation, method)\n const promiseMethod = this.#methods[method]?.call(this, operation, {\n ...this.options,\n ...options,\n })\n const promiseOperation = this.operation.call(this, operation, {\n ...this.options,\n ...options,\n })\n\n if (promiseMethod) {\n acc.push(promiseMethod)\n }\n if (promiseOperation) {\n acc.push(promiseOperation)\n }\n })\n\n return acc\n }, [] as OperationMethodResult<TFileMeta>[])\n\n const operations = Object.values(this.operationsByMethod).map((item) => Object.values(item).map((item) => item.operation))\n\n promises.push(this.all(operations.flat().filter(Boolean), this.operationsByMethod))\n\n const files = await Promise.all(promises)\n\n // using .flat because operationGenerator[method] can return a array of files or just one file\n return files.flat().filter(Boolean)\n }\n\n /**\n * Operation\n */\n async operation(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta> {\n return null\n }\n\n /**\n * GET\n */\n async get(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta> {\n return null\n }\n\n /**\n * POST\n */\n async post(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta> {\n return null\n }\n /**\n * PATCH\n */\n async patch(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta> {\n return null\n }\n\n /**\n * PUT\n */\n async put(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta> {\n return null\n }\n\n /**\n * DELETE\n */\n async delete(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta> {\n return null\n }\n\n /**\n * Combination of GET, POST, PATCH, PUT, DELETE\n */\n async all(operations: Operation[], paths: OperationsByMethod): OperationMethodResult<TFileMeta> {\n return null\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-oas/dist/index.cjs","../src/index.ts","../src/plugin.ts","../src/OperationGenerator.ts"],"names":["path","method"],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;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ACF,IAAA;AACT,EAAA;AACF;AHuJmB;AACA;AClWf;AAES;ADmWM;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/kubb/kubb/packages/plugin-oas/dist/index.cjs","sourcesContent":[null,"import { pluginOas } from './plugin.ts'\n\nexport type {\n GetOperationGeneratorOptions,\n OperationMethodResult,\n} from './OperationGenerator.ts'\nexport { OperationGenerator } from './OperationGenerator.ts'\nexport { pluginOas, pluginOasName } from './plugin.ts'\nexport type {\n GetSchemaGeneratorOptions,\n SchemaGeneratorBuildOptions,\n SchemaGeneratorOptions,\n} from './SchemaGenerator.ts'\nexport type { SchemaMethodResult } from './SchemaGenerator.ts'\nexport { SchemaGenerator } from './SchemaGenerator.ts'\nexport type {\n Schema,\n SchemaKeyword,\n SchemaKeywordBase,\n SchemaKeywordMapper,\n SchemaMapper,\n} from './SchemaMapper.ts'\nexport { isKeyword, schemaKeywords } from './SchemaMapper.ts'\nexport type * from './types.ts'\n\n/**\n * @deprecated Use `import { pluginOas } from '@kubb/plugin-oas'` instead\n */\nconst definePluginDefault = pluginOas\n\nexport default definePluginDefault\n","import path from 'node:path'\n\nimport { createPlugin } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\n\nimport { getSchemas } from './utils/getSchemas.ts'\n\nimport type { Config } from '@kubb/core'\nimport type { Logger } from '@kubb/core/logger'\nimport type { Oas, OasTypes } from '@kubb/oas'\nimport type { PluginOas } from './types.ts'\nimport { parseFromConfig } from './utils/parseFromConfig.ts'\n\nexport const pluginOasName = 'plugin-oas' satisfies PluginOas['name']\n\nexport const pluginOas = createPlugin<PluginOas>((options) => {\n const { output = { path: 'schemas', export: false }, validate = true, serverIndex = 0, contentType, oasClass } = options\n\n const getOas = async ({ config, logger }: { config: Config; logger: Logger }): Promise<Oas> => {\n try {\n // needs to be in a different variable or the catch here will not work(return of a promise instead)\n const oas = await parseFromConfig(config, oasClass)\n\n if (validate) {\n await oas.valdiate()\n }\n\n return oas\n } catch (e) {\n const error = e as Error\n\n logger.emit('warning', error?.message)\n return parseFromConfig(config, oasClass)\n }\n }\n\n return {\n name: pluginOasName,\n options,\n\n api() {\n const { config, logger } = this\n\n return {\n getOas() {\n return getOas({ config, logger })\n },\n async getSchemas({ includes } = {}) {\n const oas = await this.getOas()\n return getSchemas({ oas, contentType, includes })\n },\n async getBaseURL() {\n const oasInstance = await this.getOas()\n const baseURL = oasInstance.api.servers?.at(serverIndex)?.url\n return baseURL\n },\n contentType,\n }\n },\n resolvePath(baseName) {\n if (output === false) {\n return undefined\n }\n\n const root = path.resolve(this.config.root, this.config.output.path)\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n return camelCase(name, { isFile: type === 'file' })\n },\n async writeFile(path, source) {\n if (!path.endsWith('.json') || !source) {\n return\n }\n\n return this.fileManager.write(path, source, { sanity: false })\n },\n async buildStart() {\n if (!output) {\n return\n }\n\n const oas = await getOas({\n config: this.config,\n logger: this.logger,\n })\n await oas.dereference()\n const schemas = getSchemas({ oas, contentType })\n\n const mapSchema = async ([name, schema]: [string, OasTypes.SchemaObject]) => {\n const resolvedPath = this.resolvePath({\n baseName: `${name}.json`,\n pluginKey: this.plugin.key,\n })\n\n const resvoledFileName = this.resolveName({\n name: `${name}.json`,\n pluginKey: [pluginOasName],\n type: 'file',\n }) as `${string}.json`\n\n if (!resolvedPath) {\n return\n }\n\n await this.addFile({\n path: resolvedPath,\n baseName: resvoledFileName,\n source: JSON.stringify(schema),\n meta: {\n pluginKey: this.plugin.key,\n },\n })\n }\n\n const promises = Object.entries(schemas).map(mapSchema)\n await Promise.all(promises)\n },\n }\n})\n","import { type FileMetaBase, Generator } from '@kubb/core'\nimport transformers from '@kubb/core/transformers'\n\nimport type { PluginFactoryOptions, PluginManager } from '@kubb/core'\nimport type * as KubbFile from '@kubb/fs/types'\n\nimport type { Plugin } from '@kubb/core'\nimport type { HttpMethod, Oas, OasTypes, Operation, contentType } from '@kubb/oas'\nimport type { Exclude, Include, OperationSchemas, OperationsByMethod, Override } from './types.ts'\n\nexport type GetOperationGeneratorOptions<T extends OperationGenerator<any, any, any>> = T extends OperationGenerator<infer Options, any, any> ? Options : never\n\nexport type OperationMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>\n\ntype Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {\n oas: Oas\n exclude: Array<Exclude> | undefined\n include: Array<Include> | undefined\n override: Array<Override<TOptions>> | undefined\n contentType: contentType | undefined\n pluginManager: PluginManager\n /**\n * Current plugin\n */\n plugin: Plugin<TPluginOptions>\n mode: KubbFile.Mode\n}\n\nexport abstract class OperationGenerator<\n TOptions = unknown,\n TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions,\n TFileMeta extends FileMetaBase = FileMetaBase,\n> extends Generator<TOptions, Context<TOptions, TPluginOptions>> {\n #operationsByMethod: OperationsByMethod = {}\n get operationsByMethod(): OperationsByMethod {\n return this.#operationsByMethod\n }\n\n set operationsByMethod(paths: OperationsByMethod) {\n this.#operationsByMethod = paths\n }\n\n #getOptions(operation: Operation, method: HttpMethod): Partial<TOptions> {\n const { override = [] } = this.context\n\n return (\n override.find(({ pattern, type }) => {\n if (type === 'tag') {\n return !!operation.getTags()[0]?.name.match(pattern)\n }\n\n if (type === 'operationId') {\n return !!operation.getOperationId().match(pattern)\n }\n\n if (type === 'path') {\n return !!operation.path.match(pattern)\n }\n\n if (type === 'method') {\n return !!method.match(pattern)\n }\n\n return false\n })?.options || {}\n )\n }\n /**\n *\n * @deprecated\n */\n #isExcluded(operation: Operation, method: HttpMethod): boolean {\n const { exclude = [] } = this.context\n let matched = false\n\n exclude.forEach(({ pattern, type }) => {\n if (type === 'tag' && !matched) {\n matched = !!operation.getTags()[0]?.name.match(pattern)\n }\n\n if (type === 'operationId' && !matched) {\n matched = !!operation.getOperationId().match(pattern)\n }\n\n if (type === 'path' && !matched) {\n matched = !!operation.path.match(pattern)\n }\n\n if (type === 'method' && !matched) {\n matched = !!method.match(pattern)\n }\n })\n\n return matched\n }\n /**\n *\n * @deprecated\n */\n #isIncluded(operation: Operation, method: HttpMethod): boolean {\n const { include = [] } = this.context\n let matched = false\n\n include.forEach(({ pattern, type }) => {\n if (type === 'tag' && !matched) {\n matched = !!operation.getTags()[0]?.name.match(pattern)\n }\n\n if (type === 'operationId' && !matched) {\n matched = !!operation.getOperationId().match(pattern)\n }\n\n if (type === 'path' && !matched) {\n matched = !!operation.path.match(pattern)\n }\n\n if (type === 'method' && !matched) {\n matched = !!method.match(pattern)\n }\n })\n\n return matched\n }\n\n getSchemas(\n operation: Operation,\n { forStatusCode, resolveName = (name) => name }: { forStatusCode?: string | number; resolveName?: (name: string) => string } = {},\n ): OperationSchemas {\n const pathParamsSchema = this.context.oas.getParametersSchema(operation, 'path')\n const queryParamsSchema = this.context.oas.getParametersSchema(operation, 'query')\n const headerParamsSchema = this.context.oas.getParametersSchema(operation, 'header')\n const requestSchema = this.context.oas.getRequestSchema(operation)\n const responseStatusCode =\n forStatusCode || (operation.schema.responses && Object.keys(operation.schema.responses).find((key) => key.startsWith('2'))) || 200\n const responseSchema = this.context.oas.getResponseSchema(operation, responseStatusCode)\n const statusCodes = operation.getResponseStatusCodes().map((statusCode) => {\n let name = statusCode\n if (name === 'default') {\n name = 'error'\n }\n\n const schema = this.context.oas.getResponseSchema(operation, statusCode)\n\n return {\n name: resolveName(transformers.pascalCase(`${operation.getOperationId()} ${name}`)),\n description: (operation.getResponseByStatusCode(statusCode) as OasTypes.ResponseObject)?.description,\n schema,\n operation,\n operationName: transformers.pascalCase(`${operation.getOperationId()}`),\n statusCode: name === 'error' ? undefined : Number(statusCode),\n keys: schema?.properties ? Object.keys(schema.properties) : undefined,\n }\n })\n\n return {\n pathParams: pathParamsSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operation.getOperationId()} PathParams`)),\n operation,\n operationName: transformers.pascalCase(`${operation.getOperationId()}`),\n schema: pathParamsSchema,\n keys: pathParamsSchema.properties ? Object.keys(pathParamsSchema.properties) : undefined,\n }\n : undefined,\n queryParams: queryParamsSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operation.getOperationId()} QueryParams`)),\n operation,\n operationName: transformers.pascalCase(`${operation.getOperationId()}`),\n schema: queryParamsSchema,\n keys: queryParamsSchema.properties ? Object.keys(queryParamsSchema.properties) : [],\n }\n : undefined,\n headerParams: headerParamsSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operation.getOperationId()} HeaderParams`)),\n operation,\n operationName: transformers.pascalCase(`${operation.getOperationId()}`),\n schema: headerParamsSchema,\n keys: headerParamsSchema.properties ? Object.keys(headerParamsSchema.properties) : undefined,\n }\n : undefined,\n request: requestSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operation.getOperationId()} ${operation.method === 'get' ? 'queryRequest' : 'mutationRequest'}`)),\n description: (operation.schema.requestBody as OasTypes.RequestBodyObject)?.description,\n operation,\n operationName: transformers.pascalCase(`${operation.getOperationId()}`),\n schema: requestSchema,\n keys: requestSchema.properties ? Object.keys(requestSchema.properties) : undefined,\n keysToOmit: requestSchema.properties\n ? Object.keys(requestSchema.properties).filter((key) => {\n const item = requestSchema.properties?.[key] as OasTypes.SchemaObject\n\n return item?.readOnly\n })\n : undefined,\n }\n : undefined,\n response: {\n name: resolveName(transformers.pascalCase(`${operation.getOperationId()} ${operation.method === 'get' ? 'queryResponse' : 'mutationResponse'}`)),\n description: operation.getResponseAsJSONSchema(responseStatusCode)?.at(0)?.description,\n operation,\n operationName: transformers.pascalCase(`${operation.getOperationId()}`),\n schema: responseSchema,\n statusCode: Number(responseStatusCode),\n keys: responseSchema?.properties ? Object.keys(responseSchema.properties) : undefined,\n keysToOmit: responseSchema?.properties\n ? Object.keys(responseSchema.properties).filter((key) => {\n const item = responseSchema.properties?.[key] as OasTypes.SchemaObject\n return item?.writeOnly\n })\n : undefined,\n },\n errors: statusCodes.filter((item) => item.statusCode?.toString().startsWith('4') || item.statusCode?.toString().startsWith('5')),\n statusCodes,\n }\n }\n\n get #methods() {\n return {\n get: this.get,\n post: this.post,\n patch: this.patch,\n put: this.put,\n delete: this.delete,\n head: undefined,\n options: undefined,\n trace: undefined,\n } as const\n }\n\n async build(): Promise<Array<KubbFile.File<TFileMeta>>> {\n const { oas } = this.context\n\n const paths = oas.getPaths()\n this.operationsByMethod = Object.entries(paths).reduce((acc, [path, method]) => {\n const methods = Object.keys(method) as HttpMethod[]\n\n methods.forEach((method) => {\n const operation = oas.operation(path, method)\n if (operation && this.#methods[method]) {\n const isExcluded = this.#isExcluded(operation, method)\n const isIncluded = this.context.include ? this.#isIncluded(operation, method) : true\n\n if (isIncluded && !isExcluded) {\n if (!acc[path]) {\n acc[path] = {} as OperationsByMethod['get']\n }\n acc[path] = {\n ...acc[path],\n [method]: {\n operation,\n schemas: this.getSchemas(operation),\n },\n } as OperationsByMethod['get']\n }\n }\n })\n\n return acc\n }, {} as OperationsByMethod)\n\n const promises = Object.keys(this.operationsByMethod).reduce((acc, path) => {\n const methods = this.operationsByMethod[path] ? (Object.keys(this.operationsByMethod[path]!) as HttpMethod[]) : []\n\n methods.forEach((method) => {\n const { operation } = this.operationsByMethod[path]?.[method]!\n const options = this.#getOptions(operation, method)\n const promiseMethod = this.#methods[method]?.call(this, operation, {\n ...this.options,\n ...options,\n })\n const promiseOperation = this.operation.call(this, operation, {\n ...this.options,\n ...options,\n })\n\n if (promiseMethod) {\n acc.push(promiseMethod)\n }\n if (promiseOperation) {\n acc.push(promiseOperation)\n }\n })\n\n return acc\n }, [] as OperationMethodResult<TFileMeta>[])\n\n const operations = Object.values(this.operationsByMethod).map((item) => Object.values(item).map((item) => item.operation))\n\n promises.push(this.all(operations.flat().filter(Boolean), this.operationsByMethod))\n\n const files = await Promise.all(promises)\n\n // using .flat because operationGenerator[method] can return a array of files or just one file\n return files.flat().filter(Boolean)\n }\n\n /**\n * Operation\n */\n async operation(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta> {\n return null\n }\n\n /**\n * GET\n */\n async get(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta> {\n return null\n }\n\n /**\n * POST\n */\n async post(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta> {\n return null\n }\n /**\n * PATCH\n */\n async patch(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta> {\n return null\n }\n\n /**\n * PUT\n */\n async put(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta> {\n return null\n }\n\n /**\n * DELETE\n */\n async delete(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta> {\n return null\n }\n\n /**\n * Combination of GET, POST, PATCH, PUT, DELETE\n */\n async all(operations: Operation[], paths: OperationsByMethod): OperationMethodResult<TFileMeta> {\n return null\n }\n}\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import * as _kubb_core from '@kubb/core';
|
|
2
2
|
import { FileMetaBase, ResolveNameParams, PluginFactoryOptions, Generator, PluginManager, Plugin } from '@kubb/core';
|
|
3
|
-
import { O as Options, P as PluginOas, a as OperationSchema, R as Refs, b as Override } from './types-
|
|
4
|
-
export { A as API, E as Exclude, I as Include, f as OperationSchemas, g as OperationsByMethod, d as Ref, c as ResolvePathOptions, e as Resolver } from './types-
|
|
5
|
-
export { G as GetOperationGeneratorOptions, a as OperationGenerator, O as OperationMethodResult } from './OperationGenerator-
|
|
3
|
+
import { O as Options, P as PluginOas, a as OperationSchema, R as Refs, b as Override } from './types-RVAPVtNi.cjs';
|
|
4
|
+
export { A as API, E as Exclude, I as Include, f as OperationSchemas, g as OperationsByMethod, d as Ref, c as ResolvePathOptions, e as Resolver } from './types-RVAPVtNi.cjs';
|
|
5
|
+
export { G as GetOperationGeneratorOptions, a as OperationGenerator, O as OperationMethodResult } from './OperationGenerator-8tADySO6.cjs';
|
|
6
6
|
import * as KubbFile from '@kubb/fs/types';
|
|
7
7
|
import { SchemaObject, Oas, contentType } from '@kubb/oas';
|
|
8
|
-
import { S as Schema, a as SchemaKeywordMapper } from './SchemaMapper-
|
|
9
|
-
export { b as SchemaKeyword, c as SchemaKeywordBase, d as SchemaMapper, i as isKeyword, s as schemaKeywords } from './SchemaMapper-
|
|
10
|
-
import '@kubb/oas/parser';
|
|
8
|
+
import { S as Schema, a as SchemaKeywordMapper } from './SchemaMapper-CAEI86qj.cjs';
|
|
9
|
+
export { b as SchemaKeyword, c as SchemaKeywordBase, d as SchemaMapper, i as isKeyword, s as schemaKeywords } from './SchemaMapper-CAEI86qj.cjs';
|
|
11
10
|
|
|
12
11
|
declare const pluginOasName = "plugin-oas";
|
|
13
12
|
declare const pluginOas: (options?: Options | undefined) => _kubb_core.UserPluginWithLifeCycle<PluginOas>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import * as _kubb_core from '@kubb/core';
|
|
2
2
|
import { FileMetaBase, ResolveNameParams, PluginFactoryOptions, Generator, PluginManager, Plugin } from '@kubb/core';
|
|
3
|
-
import { O as Options, P as PluginOas, a as OperationSchema, R as Refs, b as Override } from './types-
|
|
4
|
-
export { A as API, E as Exclude, I as Include, f as OperationSchemas, g as OperationsByMethod, d as Ref, c as ResolvePathOptions, e as Resolver } from './types-
|
|
5
|
-
export { G as GetOperationGeneratorOptions, a as OperationGenerator, O as OperationMethodResult } from './OperationGenerator-
|
|
3
|
+
import { O as Options, P as PluginOas, a as OperationSchema, R as Refs, b as Override } from './types-RVAPVtNi.js';
|
|
4
|
+
export { A as API, E as Exclude, I as Include, f as OperationSchemas, g as OperationsByMethod, d as Ref, c as ResolvePathOptions, e as Resolver } from './types-RVAPVtNi.js';
|
|
5
|
+
export { G as GetOperationGeneratorOptions, a as OperationGenerator, O as OperationMethodResult } from './OperationGenerator-DvyNt6Xi.js';
|
|
6
6
|
import * as KubbFile from '@kubb/fs/types';
|
|
7
7
|
import { SchemaObject, Oas, contentType } from '@kubb/oas';
|
|
8
|
-
import { S as Schema, a as SchemaKeywordMapper } from './SchemaMapper-
|
|
9
|
-
export { b as SchemaKeyword, c as SchemaKeywordBase, d as SchemaMapper, i as isKeyword, s as schemaKeywords } from './SchemaMapper-
|
|
10
|
-
import '@kubb/oas/parser';
|
|
8
|
+
import { S as Schema, a as SchemaKeywordMapper } from './SchemaMapper-CAEI86qj.js';
|
|
9
|
+
export { b as SchemaKeyword, c as SchemaKeywordBase, d as SchemaMapper, i as isKeyword, s as schemaKeywords } from './SchemaMapper-CAEI86qj.js';
|
|
11
10
|
|
|
12
11
|
declare const pluginOasName = "plugin-oas";
|
|
13
12
|
declare const pluginOas: (options?: Options | undefined) => _kubb_core.UserPluginWithLifeCycle<PluginOas>;
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
parseFromConfig
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-B3QCCJ62.js";
|
|
4
4
|
import {
|
|
5
5
|
SchemaGenerator,
|
|
6
6
|
isKeyword,
|
|
7
7
|
schemaKeywords
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-NLKNZBXU.js";
|
|
9
9
|
import {
|
|
10
10
|
__privateAdd,
|
|
11
11
|
__privateGet,
|
|
@@ -13,30 +13,22 @@ import {
|
|
|
13
13
|
__privateSet,
|
|
14
14
|
getSchemas,
|
|
15
15
|
init_esm_shims
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-2YX4XBMY.js";
|
|
17
17
|
|
|
18
18
|
// src/index.ts
|
|
19
19
|
init_esm_shims();
|
|
20
20
|
|
|
21
21
|
// src/plugin.ts
|
|
22
22
|
init_esm_shims();
|
|
23
|
-
import path from "path";
|
|
23
|
+
import path from "node:path";
|
|
24
24
|
import { createPlugin } from "@kubb/core";
|
|
25
25
|
import { camelCase } from "@kubb/core/transformers";
|
|
26
26
|
var pluginOasName = "plugin-oas";
|
|
27
27
|
var pluginOas = createPlugin((options) => {
|
|
28
|
-
const {
|
|
29
|
-
|
|
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 }) => {
|
|
28
|
+
const { output = { path: "schemas", export: false }, validate = true, serverIndex = 0, contentType, oasClass } = options;
|
|
29
|
+
const getOas = async ({ config, logger }) => {
|
|
38
30
|
try {
|
|
39
|
-
const oas = await parseFromConfig(config,
|
|
31
|
+
const oas = await parseFromConfig(config, oasClass);
|
|
40
32
|
if (validate) {
|
|
41
33
|
await oas.valdiate();
|
|
42
34
|
}
|
|
@@ -44,7 +36,7 @@ var pluginOas = createPlugin((options) => {
|
|
|
44
36
|
} catch (e) {
|
|
45
37
|
const error = e;
|
|
46
38
|
logger.emit("warning", error?.message);
|
|
47
|
-
return parseFromConfig(config,
|
|
39
|
+
return parseFromConfig(config, oasClass);
|
|
48
40
|
}
|
|
49
41
|
};
|
|
50
42
|
return {
|
|
@@ -53,8 +45,8 @@ var pluginOas = createPlugin((options) => {
|
|
|
53
45
|
api() {
|
|
54
46
|
const { config, logger } = this;
|
|
55
47
|
return {
|
|
56
|
-
getOas(
|
|
57
|
-
return getOas({ config, logger
|
|
48
|
+
getOas() {
|
|
49
|
+
return getOas({ config, logger });
|
|
58
50
|
},
|
|
59
51
|
async getSchemas({ includes } = {}) {
|
|
60
52
|
const oas = await this.getOas();
|
|
@@ -90,11 +82,7 @@ var pluginOas = createPlugin((options) => {
|
|
|
90
82
|
}
|
|
91
83
|
const oas = await getOas({
|
|
92
84
|
config: this.config,
|
|
93
|
-
logger: this.logger
|
|
94
|
-
formatOptions: {
|
|
95
|
-
filterSet: filter,
|
|
96
|
-
sortSet: sort
|
|
97
|
-
}
|
|
85
|
+
logger: this.logger
|
|
98
86
|
});
|
|
99
87
|
await oas.dereference();
|
|
100
88
|
const schemas = getSchemas({ oas, contentType });
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/plugin.ts","../src/OperationGenerator.ts"],"sourcesContent":["import { pluginOas } from './plugin.ts'\n\nexport type {\n GetOperationGeneratorOptions,\n OperationMethodResult,\n} from './OperationGenerator.ts'\nexport { OperationGenerator } from './OperationGenerator.ts'\nexport { pluginOas, pluginOasName } from './plugin.ts'\nexport type {\n GetSchemaGeneratorOptions,\n SchemaGeneratorBuildOptions,\n SchemaGeneratorOptions,\n} from './SchemaGenerator.ts'\nexport type { SchemaMethodResult } from './SchemaGenerator.ts'\nexport { SchemaGenerator } from './SchemaGenerator.ts'\nexport type {\n Schema,\n SchemaKeyword,\n SchemaKeywordBase,\n SchemaKeywordMapper,\n SchemaMapper,\n} from './SchemaMapper.ts'\nexport { isKeyword, schemaKeywords } from './SchemaMapper.ts'\nexport type * from './types.ts'\n\n/**\n * @deprecated Use `import { pluginOas } from '@kubb/plugin-oas'` instead\n */\nconst definePluginDefault = pluginOas\n\nexport default definePluginDefault\n","import path from 'node:path'\n\nimport { createPlugin } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\n\nimport { getSchemas } from './utils/getSchemas.ts'\n\nimport type { Config } from '@kubb/core'\nimport type { Logger } from '@kubb/core/logger'\nimport type { Oas, OasTypes } from '@kubb/oas'\nimport type { FormatOptions } from '@kubb/oas/parser'\nimport type { PluginOas } from './types.ts'\nimport { parseFromConfig } from './utils/parseFromConfig.ts'\n\nexport const pluginOasName = 'plugin-oas' satisfies PluginOas['name']\n\nexport const pluginOas = createPlugin<PluginOas>((options) => {\n const {\n output = { path: 'schemas', export: false },\n experimentalFilter: filter,\n experimentalSort: sort,\n validate = true,\n serverIndex = 0,\n contentType,\n oasClass,\n } = options\n\n const getOas = async ({ config, logger, formatOptions }: { config: Config; logger: Logger; formatOptions?: FormatOptions }): Promise<Oas> => {\n try {\n // needs to be in a different variable or the catch here will not work(return of a promise instead)\n const oas = await parseFromConfig(config, formatOptions, oasClass)\n\n if (validate) {\n await oas.valdiate()\n }\n\n return oas\n } catch (e) {\n const error = e as Error\n\n logger.emit('warning', error?.message)\n return parseFromConfig(config, {}, oasClass)\n }\n }\n\n return {\n name: pluginOasName,\n options,\n\n api() {\n const { config, logger } = this\n\n return {\n getOas(formatOptions) {\n return getOas({ config, logger, formatOptions })\n },\n async getSchemas({ includes } = {}) {\n const oas = await this.getOas()\n return getSchemas({ oas, contentType, includes })\n },\n async getBaseURL() {\n const oasInstance = await this.getOas()\n const baseURL = oasInstance.api.servers?.at(serverIndex)?.url\n return baseURL\n },\n contentType,\n }\n },\n resolvePath(baseName) {\n if (output === false) {\n return undefined\n }\n\n const root = path.resolve(this.config.root, this.config.output.path)\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n return camelCase(name, { isFile: type === 'file' })\n },\n async writeFile(path, source) {\n if (!path.endsWith('.json') || !source) {\n return\n }\n\n return this.fileManager.write(path, source, { sanity: false })\n },\n async buildStart() {\n if (!output) {\n return\n }\n\n const oas = await getOas({\n config: this.config,\n logger: this.logger,\n formatOptions: {\n filterSet: filter,\n sortSet: sort,\n },\n })\n await oas.dereference()\n const schemas = getSchemas({ oas, contentType })\n\n const mapSchema = async ([name, schema]: [string, OasTypes.SchemaObject]) => {\n const resolvedPath = this.resolvePath({\n baseName: `${name}.json`,\n pluginKey: this.plugin.key,\n })\n\n const resvoledFileName = this.resolveName({\n name: `${name}.json`,\n pluginKey: [pluginOasName],\n type: 'file',\n }) as `${string}.json`\n\n if (!resolvedPath) {\n return\n }\n\n await this.addFile({\n path: resolvedPath,\n baseName: resvoledFileName,\n source: JSON.stringify(schema),\n meta: {\n pluginKey: this.plugin.key,\n },\n })\n }\n\n const promises = Object.entries(schemas).map(mapSchema)\n await Promise.all(promises)\n },\n }\n})\n","import { type FileMetaBase, Generator } from '@kubb/core'\nimport transformers from '@kubb/core/transformers'\n\nimport type { PluginFactoryOptions, PluginManager } from '@kubb/core'\nimport type * as KubbFile from '@kubb/fs/types'\n\nimport type { Plugin } from '@kubb/core'\nimport type { HttpMethod, Oas, OasTypes, Operation, contentType } from '@kubb/oas'\nimport type { Exclude, Include, OperationSchemas, OperationsByMethod, Override } from './types.ts'\n\nexport type GetOperationGeneratorOptions<T extends OperationGenerator<any, any, any>> = T extends OperationGenerator<infer Options, any, any> ? Options : never\n\nexport type OperationMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>\n\ntype Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {\n oas: Oas\n exclude: Array<Exclude> | undefined\n include: Array<Include> | undefined\n override: Array<Override<TOptions>> | undefined\n contentType: contentType | undefined\n pluginManager: PluginManager\n /**\n * Current plugin\n */\n plugin: Plugin<TPluginOptions>\n mode: KubbFile.Mode\n}\n\nexport abstract class OperationGenerator<\n TOptions = unknown,\n TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions,\n TFileMeta extends FileMetaBase = FileMetaBase,\n> extends Generator<TOptions, Context<TOptions, TPluginOptions>> {\n #operationsByMethod: OperationsByMethod = {}\n get operationsByMethod(): OperationsByMethod {\n return this.#operationsByMethod\n }\n\n set operationsByMethod(paths: OperationsByMethod) {\n this.#operationsByMethod = paths\n }\n\n #getOptions(operation: Operation, method: HttpMethod): Partial<TOptions> {\n const { override = [] } = this.context\n\n return (\n override.find(({ pattern, type }) => {\n if (type === 'tag') {\n return !!operation.getTags()[0]?.name.match(pattern)\n }\n\n if (type === 'operationId') {\n return !!operation.getOperationId().match(pattern)\n }\n\n if (type === 'path') {\n return !!operation.path.match(pattern)\n }\n\n if (type === 'method') {\n return !!method.match(pattern)\n }\n\n return false\n })?.options || {}\n )\n }\n /**\n *\n * @deprecated\n */\n #isExcluded(operation: Operation, method: HttpMethod): boolean {\n const { exclude = [] } = this.context\n let matched = false\n\n exclude.forEach(({ pattern, type }) => {\n if (type === 'tag' && !matched) {\n matched = !!operation.getTags()[0]?.name.match(pattern)\n }\n\n if (type === 'operationId' && !matched) {\n matched = !!operation.getOperationId().match(pattern)\n }\n\n if (type === 'path' && !matched) {\n matched = !!operation.path.match(pattern)\n }\n\n if (type === 'method' && !matched) {\n matched = !!method.match(pattern)\n }\n })\n\n return matched\n }\n /**\n *\n * @deprecated\n */\n #isIncluded(operation: Operation, method: HttpMethod): boolean {\n const { include = [] } = this.context\n let matched = false\n\n include.forEach(({ pattern, type }) => {\n if (type === 'tag' && !matched) {\n matched = !!operation.getTags()[0]?.name.match(pattern)\n }\n\n if (type === 'operationId' && !matched) {\n matched = !!operation.getOperationId().match(pattern)\n }\n\n if (type === 'path' && !matched) {\n matched = !!operation.path.match(pattern)\n }\n\n if (type === 'method' && !matched) {\n matched = !!method.match(pattern)\n }\n })\n\n return matched\n }\n\n getSchemas(\n operation: Operation,\n { forStatusCode, resolveName = (name) => name }: { forStatusCode?: string | number; resolveName?: (name: string) => string } = {},\n ): OperationSchemas {\n const pathParamsSchema = this.context.oas.getParametersSchema(operation, 'path')\n const queryParamsSchema = this.context.oas.getParametersSchema(operation, 'query')\n const headerParamsSchema = this.context.oas.getParametersSchema(operation, 'header')\n const requestSchema = this.context.oas.getRequestSchema(operation)\n const responseStatusCode =\n forStatusCode || (operation.schema.responses && Object.keys(operation.schema.responses).find((key) => key.startsWith('2'))) || 200\n const responseSchema = this.context.oas.getResponseSchema(operation, responseStatusCode)\n const statusCodes = operation.getResponseStatusCodes().map((statusCode) => {\n let name = statusCode\n if (name === 'default') {\n name = 'error'\n }\n\n const schema = this.context.oas.getResponseSchema(operation, statusCode)\n\n return {\n name: resolveName(transformers.pascalCase(`${operation.getOperationId()} ${name}`)),\n description: (operation.getResponseByStatusCode(statusCode) as OasTypes.ResponseObject)?.description,\n schema,\n operation,\n operationName: transformers.pascalCase(`${operation.getOperationId()}`),\n statusCode: name === 'error' ? undefined : Number(statusCode),\n keys: schema?.properties ? Object.keys(schema.properties) : undefined,\n }\n })\n\n return {\n pathParams: pathParamsSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operation.getOperationId()} PathParams`)),\n operation,\n operationName: transformers.pascalCase(`${operation.getOperationId()}`),\n schema: pathParamsSchema,\n keys: pathParamsSchema.properties ? Object.keys(pathParamsSchema.properties) : undefined,\n }\n : undefined,\n queryParams: queryParamsSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operation.getOperationId()} QueryParams`)),\n operation,\n operationName: transformers.pascalCase(`${operation.getOperationId()}`),\n schema: queryParamsSchema,\n keys: queryParamsSchema.properties ? Object.keys(queryParamsSchema.properties) : [],\n }\n : undefined,\n headerParams: headerParamsSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operation.getOperationId()} HeaderParams`)),\n operation,\n operationName: transformers.pascalCase(`${operation.getOperationId()}`),\n schema: headerParamsSchema,\n keys: headerParamsSchema.properties ? Object.keys(headerParamsSchema.properties) : undefined,\n }\n : undefined,\n request: requestSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operation.getOperationId()} ${operation.method === 'get' ? 'queryRequest' : 'mutationRequest'}`)),\n description: (operation.schema.requestBody as OasTypes.RequestBodyObject)?.description,\n operation,\n operationName: transformers.pascalCase(`${operation.getOperationId()}`),\n schema: requestSchema,\n keys: requestSchema.properties ? Object.keys(requestSchema.properties) : undefined,\n keysToOmit: requestSchema.properties\n ? Object.keys(requestSchema.properties).filter((key) => {\n const item = requestSchema.properties?.[key] as OasTypes.SchemaObject\n\n return item?.readOnly\n })\n : undefined,\n }\n : undefined,\n response: {\n name: resolveName(transformers.pascalCase(`${operation.getOperationId()} ${operation.method === 'get' ? 'queryResponse' : 'mutationResponse'}`)),\n description: operation.getResponseAsJSONSchema(responseStatusCode)?.at(0)?.description,\n operation,\n operationName: transformers.pascalCase(`${operation.getOperationId()}`),\n schema: responseSchema,\n statusCode: Number(responseStatusCode),\n keys: responseSchema?.properties ? Object.keys(responseSchema.properties) : undefined,\n keysToOmit: responseSchema?.properties\n ? Object.keys(responseSchema.properties).filter((key) => {\n const item = responseSchema.properties?.[key] as OasTypes.SchemaObject\n return item?.writeOnly\n })\n : undefined,\n },\n errors: statusCodes.filter((item) => item.statusCode?.toString().startsWith('4') || item.statusCode?.toString().startsWith('5')),\n statusCodes,\n }\n }\n\n get #methods() {\n return {\n get: this.get,\n post: this.post,\n patch: this.patch,\n put: this.put,\n delete: this.delete,\n head: undefined,\n options: undefined,\n trace: undefined,\n } as const\n }\n\n async build(): Promise<Array<KubbFile.File<TFileMeta>>> {\n const { oas } = this.context\n\n const paths = oas.getPaths()\n this.operationsByMethod = Object.entries(paths).reduce((acc, [path, method]) => {\n const methods = Object.keys(method) as HttpMethod[]\n\n methods.forEach((method) => {\n const operation = oas.operation(path, method)\n if (operation && this.#methods[method]) {\n const isExcluded = this.#isExcluded(operation, method)\n const isIncluded = this.context.include ? this.#isIncluded(operation, method) : true\n\n if (isIncluded && !isExcluded) {\n if (!acc[path]) {\n acc[path] = {} as OperationsByMethod['get']\n }\n acc[path] = {\n ...acc[path],\n [method]: {\n operation,\n schemas: this.getSchemas(operation),\n },\n } as OperationsByMethod['get']\n }\n }\n })\n\n return acc\n }, {} as OperationsByMethod)\n\n const promises = Object.keys(this.operationsByMethod).reduce((acc, path) => {\n const methods = this.operationsByMethod[path] ? (Object.keys(this.operationsByMethod[path]!) as HttpMethod[]) : []\n\n methods.forEach((method) => {\n const { operation } = this.operationsByMethod[path]?.[method]!\n const options = this.#getOptions(operation, method)\n const promiseMethod = this.#methods[method]?.call(this, operation, {\n ...this.options,\n ...options,\n })\n const promiseOperation = this.operation.call(this, operation, {\n ...this.options,\n ...options,\n })\n\n if (promiseMethod) {\n acc.push(promiseMethod)\n }\n if (promiseOperation) {\n acc.push(promiseOperation)\n }\n })\n\n return acc\n }, [] as OperationMethodResult<TFileMeta>[])\n\n const operations = Object.values(this.operationsByMethod).map((item) => Object.values(item).map((item) => item.operation))\n\n promises.push(this.all(operations.flat().filter(Boolean), this.operationsByMethod))\n\n const files = await Promise.all(promises)\n\n // using .flat because operationGenerator[method] can return a array of files or just one file\n return files.flat().filter(Boolean)\n }\n\n /**\n * Operation\n */\n async operation(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta> {\n return null\n }\n\n /**\n * GET\n */\n async get(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta> {\n return null\n }\n\n /**\n * POST\n */\n async post(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta> {\n return null\n }\n /**\n * PATCH\n */\n async patch(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta> {\n return null\n }\n\n /**\n * PUT\n */\n async put(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta> {\n return null\n }\n\n /**\n * DELETE\n */\n async delete(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta> {\n return null\n }\n\n /**\n * Combination of GET, POST, PATCH, PUT, DELETE\n */\n async all(operations: Operation[], paths: OperationsByMethod): OperationMethodResult<TFileMeta> {\n return null\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;ACAA;AAAA,OAAO,UAAU;AAEjB,SAAS,oBAAoB;AAC7B,SAAS,iBAAiB;AAWnB,IAAM,gBAAgB;AAEtB,IAAM,YAAY,aAAwB,CAAC,YAAY;AAC5D,QAAM;AAAA,IACJ,SAAS,EAAE,MAAM,WAAW,QAAQ,MAAM;AAAA,IAC1C,oBAAoB;AAAA,IACpB,kBAAkB;AAAA,IAClB,WAAW;AAAA,IACX,cAAc;AAAA,IACd;AAAA,IACA;AAAA,EACF,IAAI;AAEJ,QAAM,SAAS,OAAO,EAAE,QAAQ,QAAQ,cAAc,MAAuF;AAC3I,QAAI;AAEF,YAAM,MAAM,MAAM,gBAAgB,QAAQ,eAAe,QAAQ;AAEjE,UAAI,UAAU;AACZ,cAAM,IAAI,SAAS;AAAA,MACrB;AAEA,aAAO;AAAA,IACT,SAAS,GAAG;AACV,YAAM,QAAQ;AAEd,aAAO,KAAK,WAAW,OAAO,OAAO;AACrC,aAAO,gBAAgB,QAAQ,CAAC,GAAG,QAAQ;AAAA,IAC7C;AAAA,EACF;AAEA,SAAO;AAAA,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ationGenerator.ts"],"sourcesContent":["import { pluginOas } from './plugin.ts'\n\nexport type {\n GetOperationGeneratorOptions,\n OperationMethodResult,\n} from './OperationGenerator.ts'\nexport { OperationGenerator } from './OperationGenerator.ts'\nexport { pluginOas, pluginOasName } from './plugin.ts'\nexport type {\n GetSchemaGeneratorOptions,\n SchemaGeneratorBuildOptions,\n SchemaGeneratorOptions,\n} from './SchemaGenerator.ts'\nexport type { SchemaMethodResult } from './SchemaGenerator.ts'\nexport { SchemaGenerator } from './SchemaGenerator.ts'\nexport type {\n Schema,\n SchemaKeyword,\n SchemaKeywordBase,\n SchemaKeywordMapper,\n SchemaMapper,\n} from './SchemaMapper.ts'\nexport { isKeyword, schemaKeywords } from './SchemaMapper.ts'\nexport type * from './types.ts'\n\n/**\n * @deprecated Use `import { pluginOas } from '@kubb/plugin-oas'` instead\n */\nconst definePluginDefault = pluginOas\n\nexport default definePluginDefault\n","import path from 'node:path'\n\nimport { createPlugin } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\n\nimport { getSchemas } from './utils/getSchemas.ts'\n\nimport type { Config } from '@kubb/core'\nimport type { Logger } from '@kubb/core/logger'\nimport type { Oas, OasTypes } from '@kubb/oas'\nimport type { PluginOas } from './types.ts'\nimport { parseFromConfig } from './utils/parseFromConfig.ts'\n\nexport const pluginOasName = 'plugin-oas' satisfies PluginOas['name']\n\nexport const pluginOas = createPlugin<PluginOas>((options) => {\n const { output = { path: 'schemas', export: false }, validate = true, serverIndex = 0, contentType, oasClass } = options\n\n const getOas = async ({ config, logger }: { config: Config; logger: Logger }): Promise<Oas> => {\n try {\n // needs to be in a different variable or the catch here will not work(return of a promise instead)\n const oas = await parseFromConfig(config, oasClass)\n\n if (validate) {\n await oas.valdiate()\n }\n\n return oas\n } catch (e) {\n const error = e as Error\n\n logger.emit('warning', error?.message)\n return parseFromConfig(config, oasClass)\n }\n }\n\n return {\n name: pluginOasName,\n options,\n\n api() {\n const { config, logger } = this\n\n return {\n getOas() {\n return getOas({ config, logger })\n },\n async getSchemas({ includes } = {}) {\n const oas = await this.getOas()\n return getSchemas({ oas, contentType, includes })\n },\n async getBaseURL() {\n const oasInstance = await this.getOas()\n const baseURL = oasInstance.api.servers?.at(serverIndex)?.url\n return baseURL\n },\n contentType,\n }\n },\n resolvePath(baseName) {\n if (output === false) {\n return undefined\n }\n\n const root = path.resolve(this.config.root, this.config.output.path)\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n return camelCase(name, { isFile: type === 'file' })\n },\n async writeFile(path, source) {\n if (!path.endsWith('.json') || !source) {\n return\n }\n\n return this.fileManager.write(path, source, { sanity: false })\n },\n async buildStart() {\n if (!output) {\n return\n }\n\n const oas = await getOas({\n config: this.config,\n logger: this.logger,\n })\n await oas.dereference()\n const schemas = getSchemas({ oas, contentType })\n\n const mapSchema = async ([name, schema]: [string, OasTypes.SchemaObject]) => {\n const resolvedPath = this.resolvePath({\n baseName: `${name}.json`,\n pluginKey: this.plugin.key,\n })\n\n const resvoledFileName = this.resolveName({\n name: `${name}.json`,\n pluginKey: [pluginOasName],\n type: 'file',\n }) as `${string}.json`\n\n if (!resolvedPath) {\n return\n }\n\n await this.addFile({\n path: resolvedPath,\n baseName: resvoledFileName,\n source: JSON.stringify(schema),\n meta: {\n pluginKey: this.plugin.key,\n },\n })\n }\n\n const promises = Object.entries(schemas).map(mapSchema)\n await Promise.all(promises)\n },\n }\n})\n","import { type FileMetaBase, Generator } from '@kubb/core'\nimport transformers from '@kubb/core/transformers'\n\nimport type { PluginFactoryOptions, PluginManager } from '@kubb/core'\nimport type * as KubbFile from '@kubb/fs/types'\n\nimport type { Plugin } from '@kubb/core'\nimport type { HttpMethod, Oas, OasTypes, Operation, contentType } from '@kubb/oas'\nimport type { Exclude, Include, OperationSchemas, OperationsByMethod, Override } from './types.ts'\n\nexport type GetOperationGeneratorOptions<T extends OperationGenerator<any, any, any>> = T extends OperationGenerator<infer Options, any, any> ? Options : never\n\nexport type OperationMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>\n\ntype Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {\n oas: Oas\n exclude: Array<Exclude> | undefined\n include: Array<Include> | undefined\n override: Array<Override<TOptions>> | undefined\n contentType: contentType | undefined\n pluginManager: PluginManager\n /**\n * Current plugin\n */\n plugin: Plugin<TPluginOptions>\n mode: KubbFile.Mode\n}\n\nexport abstract class OperationGenerator<\n TOptions = unknown,\n TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions,\n TFileMeta extends FileMetaBase = FileMetaBase,\n> extends Generator<TOptions, Context<TOptions, TPluginOptions>> {\n #operationsByMethod: OperationsByMethod = {}\n get operationsByMethod(): OperationsByMethod {\n return this.#operationsByMethod\n }\n\n set operationsByMethod(paths: OperationsByMethod) {\n this.#operationsByMethod = paths\n }\n\n #getOptions(operation: Operation, method: HttpMethod): Partial<TOptions> {\n const { override = [] } = this.context\n\n return (\n override.find(({ pattern, type }) => {\n if (type === 'tag') {\n return !!operation.getTags()[0]?.name.match(pattern)\n }\n\n if (type === 'operationId') {\n return !!operation.getOperationId().match(pattern)\n }\n\n if (type === 'path') {\n return !!operation.path.match(pattern)\n }\n\n if (type === 'method') {\n return !!method.match(pattern)\n }\n\n return false\n })?.options || {}\n )\n }\n /**\n *\n * @deprecated\n */\n #isExcluded(operation: Operation, method: HttpMethod): boolean {\n const { exclude = [] } = this.context\n let matched = false\n\n exclude.forEach(({ pattern, type }) => {\n if (type === 'tag' && !matched) {\n matched = !!operation.getTags()[0]?.name.match(pattern)\n }\n\n if (type === 'operationId' && !matched) {\n matched = !!operation.getOperationId().match(pattern)\n }\n\n if (type === 'path' && !matched) {\n matched = !!operation.path.match(pattern)\n }\n\n if (type === 'method' && !matched) {\n matched = !!method.match(pattern)\n }\n })\n\n return matched\n }\n /**\n *\n * @deprecated\n */\n #isIncluded(operation: Operation, method: HttpMethod): boolean {\n const { include = [] } = this.context\n let matched = false\n\n include.forEach(({ pattern, type }) => {\n if (type === 'tag' && !matched) {\n matched = !!operation.getTags()[0]?.name.match(pattern)\n }\n\n if (type === 'operationId' && !matched) {\n matched = !!operation.getOperationId().match(pattern)\n }\n\n if (type === 'path' && !matched) {\n matched = !!operation.path.match(pattern)\n }\n\n if (type === 'method' && !matched) {\n matched = !!method.match(pattern)\n }\n })\n\n return matched\n }\n\n getSchemas(\n operation: Operation,\n { forStatusCode, resolveName = (name) => name }: { forStatusCode?: string | number; resolveName?: (name: string) => string } = {},\n ): OperationSchemas {\n const pathParamsSchema = this.context.oas.getParametersSchema(operation, 'path')\n const queryParamsSchema = this.context.oas.getParametersSchema(operation, 'query')\n const headerParamsSchema = this.context.oas.getParametersSchema(operation, 'header')\n const requestSchema = this.context.oas.getRequestSchema(operation)\n const responseStatusCode =\n forStatusCode || (operation.schema.responses && Object.keys(operation.schema.responses).find((key) => key.startsWith('2'))) || 200\n const responseSchema = this.context.oas.getResponseSchema(operation, responseStatusCode)\n const statusCodes = operation.getResponseStatusCodes().map((statusCode) => {\n let name = statusCode\n if (name === 'default') {\n name = 'error'\n }\n\n const schema = this.context.oas.getResponseSchema(operation, statusCode)\n\n return {\n name: resolveName(transformers.pascalCase(`${operation.getOperationId()} ${name}`)),\n description: (operation.getResponseByStatusCode(statusCode) as OasTypes.ResponseObject)?.description,\n schema,\n operation,\n operationName: transformers.pascalCase(`${operation.getOperationId()}`),\n statusCode: name === 'error' ? undefined : Number(statusCode),\n keys: schema?.properties ? Object.keys(schema.properties) : undefined,\n }\n })\n\n return {\n pathParams: pathParamsSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operation.getOperationId()} PathParams`)),\n operation,\n operationName: transformers.pascalCase(`${operation.getOperationId()}`),\n schema: pathParamsSchema,\n keys: pathParamsSchema.properties ? Object.keys(pathParamsSchema.properties) : undefined,\n }\n : undefined,\n queryParams: queryParamsSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operation.getOperationId()} QueryParams`)),\n operation,\n operationName: transformers.pascalCase(`${operation.getOperationId()}`),\n schema: queryParamsSchema,\n keys: queryParamsSchema.properties ? Object.keys(queryParamsSchema.properties) : [],\n }\n : undefined,\n headerParams: headerParamsSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operation.getOperationId()} HeaderParams`)),\n operation,\n operationName: transformers.pascalCase(`${operation.getOperationId()}`),\n schema: headerParamsSchema,\n keys: headerParamsSchema.properties ? Object.keys(headerParamsSchema.properties) : undefined,\n }\n : undefined,\n request: requestSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operation.getOperationId()} ${operation.method === 'get' ? 'queryRequest' : 'mutationRequest'}`)),\n description: (operation.schema.requestBody as OasTypes.RequestBodyObject)?.description,\n operation,\n operationName: transformers.pascalCase(`${operation.getOperationId()}`),\n schema: requestSchema,\n keys: requestSchema.properties ? Object.keys(requestSchema.properties) : undefined,\n keysToOmit: requestSchema.properties\n ? Object.keys(requestSchema.properties).filter((key) => {\n const item = requestSchema.properties?.[key] as OasTypes.SchemaObject\n\n return item?.readOnly\n })\n : undefined,\n }\n : undefined,\n response: {\n name: resolveName(transformers.pascalCase(`${operation.getOperationId()} ${operation.method === 'get' ? 'queryResponse' : 'mutationResponse'}`)),\n description: operation.getResponseAsJSONSchema(responseStatusCode)?.at(0)?.description,\n operation,\n operationName: transformers.pascalCase(`${operation.getOperationId()}`),\n schema: responseSchema,\n statusCode: Number(responseStatusCode),\n keys: responseSchema?.properties ? Object.keys(responseSchema.properties) : undefined,\n keysToOmit: responseSchema?.properties\n ? Object.keys(responseSchema.properties).filter((key) => {\n const item = responseSchema.properties?.[key] as OasTypes.SchemaObject\n return item?.writeOnly\n })\n : undefined,\n },\n errors: statusCodes.filter((item) => item.statusCode?.toString().startsWith('4') || item.statusCode?.toString().startsWith('5')),\n statusCodes,\n }\n }\n\n get #methods() {\n return {\n get: this.get,\n post: this.post,\n patch: this.patch,\n put: this.put,\n delete: this.delete,\n head: undefined,\n options: undefined,\n trace: undefined,\n } as const\n }\n\n async build(): Promise<Array<KubbFile.File<TFileMeta>>> {\n const { oas } = this.context\n\n const paths = oas.getPaths()\n this.operationsByMethod = Object.entries(paths).reduce((acc, [path, method]) => {\n const methods = Object.keys(method) as HttpMethod[]\n\n methods.forEach((method) => {\n const operation = oas.operation(path, method)\n if (operation && this.#methods[method]) {\n const isExcluded = this.#isExcluded(operation, method)\n const isIncluded = this.context.include ? this.#isIncluded(operation, method) : true\n\n if (isIncluded && !isExcluded) {\n if (!acc[path]) {\n acc[path] = {} as OperationsByMethod['get']\n }\n acc[path] = {\n ...acc[path],\n [method]: {\n operation,\n schemas: this.getSchemas(operation),\n },\n } as OperationsByMethod['get']\n }\n }\n })\n\n return acc\n }, {} as OperationsByMethod)\n\n const promises = Object.keys(this.operationsByMethod).reduce((acc, path) => {\n const methods = this.operationsByMethod[path] ? (Object.keys(this.operationsByMethod[path]!) as HttpMethod[]) : []\n\n methods.forEach((method) => {\n const { operation } = this.operationsByMethod[path]?.[method]!\n const options = this.#getOptions(operation, method)\n const promiseMethod = this.#methods[method]?.call(this, operation, {\n ...this.options,\n ...options,\n })\n const promiseOperation = this.operation.call(this, operation, {\n ...this.options,\n ...options,\n })\n\n if (promiseMethod) {\n acc.push(promiseMethod)\n }\n if (promiseOperation) {\n acc.push(promiseOperation)\n }\n })\n\n return acc\n }, [] as OperationMethodResult<TFileMeta>[])\n\n const operations = Object.values(this.operationsByMethod).map((item) => Object.values(item).map((item) => item.operation))\n\n promises.push(this.all(operations.flat().filter(Boolean), this.operationsByMethod))\n\n const files = await Promise.all(promises)\n\n // using .flat because operationGenerator[method] can return a array of files or just one file\n return files.flat().filter(Boolean)\n }\n\n /**\n * Operation\n */\n async operation(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta> {\n return null\n }\n\n /**\n * GET\n */\n async get(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta> {\n return null\n }\n\n /**\n * POST\n */\n async post(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta> {\n return null\n }\n /**\n * PATCH\n */\n async patch(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta> {\n return null\n }\n\n /**\n * PUT\n */\n async put(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta> {\n return null\n }\n\n /**\n * DELETE\n */\n async delete(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta> {\n return null\n }\n\n /**\n * Combination of GET, POST, PATCH, PUT, DELETE\n */\n async all(operations: Operation[], paths: OperationsByMethod): OperationMethodResult<TFileMeta> {\n return null\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;ACAA;AAAA,OAAO,UAAU;AAEjB,SAAS,oBAAoB;AAC7B,SAAS,iBAAiB;AAUnB,IAAM,gBAAgB;AAEtB,IAAM,YAAY,aAAwB,CAAC,YAAY;AAC5D,QAAM,EAAE,SAAS,EAAE,MAAM,WAAW,QAAQ,MAAM,GAAG,WAAW,MAAM,cAAc,GAAG,aAAa,SAAS,IAAI;AAEjH,QAAM,SAAS,OAAO,EAAE,QAAQ,OAAO,MAAwD;AAC7F,QAAI;AAEF,YAAM,MAAM,MAAM,gBAAgB,QAAQ,QAAQ;AAElD,UAAI,UAAU;AACZ,cAAM,IAAI,SAAS;AAAA,MACrB;AAEA,aAAO;AAAA,IACT,SAAS,GAAG;AACV,YAAM,QAAQ;AAEd,aAAO,KAAK,WAAW,OAAO,OAAO;AACrC,aAAO,gBAAgB,QAAQ,QAAQ;AAAA,IACzC;AAAA,EACF;AAEA,SAAO;AAAA,IACL,MAAM;AAAA,IACN;AAAA,IAEA,MAAM;AACJ,YAAM,EAAE,QAAQ,OAAO,IAAI;AAE3B,aAAO;AAAA,QACL,SAAS;AACP,iBAAO,OAAO,EAAE,QAAQ,OAAO,CAAC;AAAA,QAClC;AAAA,QACA,MAAM,WAAW,EAAE,SAAS,IAAI,CAAC,GAAG;AAClC,gBAAM,MAAM,MAAM,KAAK,OAAO;AAC9B,iBAAO,WAAW,EAAE,KAAK,aAAa,SAAS,CAAC;AAAA,QAClD;AAAA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AU;AAEd,UAAQ,QAAQ,CAAC,EAAE,SAAS,KAAK,MAAM;AACrC,QAAI,SAAS,SAAS,CAAC,SAAS;AAC9B,gBAAU,CAAC,CAAC,UAAU,QAAQ,EAAE,CAAC,GAAG,KAAK,MAAM,OAAO;AAAA,IACxD;AAEA,QAAI,SAAS,iBAAiB,CAAC,SAAS;AACtC,gBAAU,CAAC,CAAC,UAAU,eAAe,EAAE,MAAM,OAAO;AAAA,IACtD;AAEA,QAAI,SAAS,UAAU,CAAC,SAAS;AAC/B,gBAAU,CAAC,CAAC,UAAU,KAAK,MAAM,OAAO;AAAA,IAC1C;AAEA,QAAI,SAAS,YAAY,CAAC,SAAS;AACjC,gBAAU,CAAC,CAAC,OAAO,MAAM,OAAO;AAAA,IAClC;AAAA,EACF,CAAC;AAED,SAAO;AACT;AAiGI,cAAQ,WAAG;AACb,SAAO;AAAA,IACL,KAAK,KAAK;AAAA,IACV,MAAM,KAAK;AAAA,IACX,OAAO,KAAK;AAAA,IACZ,KAAK,KAAK;AAAA,IACV,QAAQ,KAAK;AAAA,IACb,MAAM;AAAA,IACN,SAAS;AAAA,IACT,OAAO;AAAA,EACT;AACF;;;AF1MF,IAAM,sBAAsB;AAE5B,IAAO,cAAQ;","names":["path","path","method","item"]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Plugin, ResolveNameParams, PluginFactoryOptions } from '@kubb/core';
|
|
2
2
|
import * as KubbFile from '@kubb/fs/types';
|
|
3
3
|
import { Oas, contentType, OasTypes, SchemaObject, Operation, HttpMethod } from '@kubb/oas';
|
|
4
|
-
import { FormatOptions } from '@kubb/oas/parser';
|
|
5
4
|
|
|
6
5
|
type Mode = 'schemas' | 'responses' | 'requestBodies';
|
|
7
6
|
type GetSchemasProps = {
|
|
@@ -17,7 +16,7 @@ type ResolvePathOptions = {
|
|
|
17
16
|
type?: ResolveNameParams['type'];
|
|
18
17
|
};
|
|
19
18
|
type API = {
|
|
20
|
-
getOas: (
|
|
19
|
+
getOas: () => Promise<Oas>;
|
|
21
20
|
getSchemas: (options?: Pick<GetSchemasProps, 'includes'>) => Promise<Record<string, SchemaObject>>;
|
|
22
21
|
getBaseURL: () => Promise<string | undefined>;
|
|
23
22
|
contentType?: contentType;
|
|
@@ -49,8 +48,6 @@ type Options = {
|
|
|
49
48
|
* By default, this is set based on the first used contentType..
|
|
50
49
|
*/
|
|
51
50
|
contentType?: contentType;
|
|
52
|
-
experimentalFilter?: FormatOptions['filterSet'];
|
|
53
|
-
experimentalSort?: FormatOptions['sortSet'];
|
|
54
51
|
oasClass?: typeof Oas;
|
|
55
52
|
};
|
|
56
53
|
/**
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Plugin, ResolveNameParams, PluginFactoryOptions } from '@kubb/core';
|
|
2
2
|
import * as KubbFile from '@kubb/fs/types';
|
|
3
3
|
import { Oas, contentType, OasTypes, SchemaObject, Operation, HttpMethod } from '@kubb/oas';
|
|
4
|
-
import { FormatOptions } from '@kubb/oas/parser';
|
|
5
4
|
|
|
6
5
|
type Mode = 'schemas' | 'responses' | 'requestBodies';
|
|
7
6
|
type GetSchemasProps = {
|
|
@@ -17,7 +16,7 @@ type ResolvePathOptions = {
|
|
|
17
16
|
type?: ResolveNameParams['type'];
|
|
18
17
|
};
|
|
19
18
|
type API = {
|
|
20
|
-
getOas: (
|
|
19
|
+
getOas: () => Promise<Oas>;
|
|
21
20
|
getSchemas: (options?: Pick<GetSchemasProps, 'includes'>) => Promise<Record<string, SchemaObject>>;
|
|
22
21
|
getBaseURL: () => Promise<string | undefined>;
|
|
23
22
|
contentType?: contentType;
|
|
@@ -49,8 +48,6 @@ type Options = {
|
|
|
49
48
|
* By default, this is set based on the first used contentType..
|
|
50
49
|
*/
|
|
51
50
|
contentType?: contentType;
|
|
52
|
-
experimentalFilter?: FormatOptions['filterSet'];
|
|
53
|
-
experimentalSort?: FormatOptions['sortSet'];
|
|
54
51
|
oasClass?: typeof Oas;
|
|
55
52
|
};
|
|
56
53
|
/**
|
package/dist/utils.cjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
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; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkHUFRXC4Ncjs = require('./chunk-HUFRXC4N.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunk2BGY3BRCcjs = require('./chunk-2BGY3BRC.cjs');
|
|
9
9
|
|
|
10
10
|
// src/utils/index.ts
|
|
11
|
-
|
|
11
|
+
_chunk2BGY3BRCcjs.init_cjs_shims.call(void 0, );
|
|
12
12
|
|
|
13
13
|
// src/utils/getComments.ts
|
|
14
|
-
|
|
14
|
+
_chunk2BGY3BRCcjs.init_cjs_shims.call(void 0, );
|
|
15
15
|
var _transformers = require('@kubb/core/transformers'); var _transformers2 = _interopRequireDefault(_transformers);
|
|
16
16
|
var _utils = require('@kubb/core/utils');
|
|
17
17
|
function getComments(operation) {
|
|
@@ -24,7 +24,7 @@ function getComments(operation) {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
// src/utils/getGroupedByTagFiles.ts
|
|
27
|
-
|
|
27
|
+
_chunk2BGY3BRCcjs.init_cjs_shims.call(void 0, );
|
|
28
28
|
var _path = require('path');
|
|
29
29
|
var _core = require('@kubb/core');
|
|
30
30
|
|
|
@@ -69,7 +69,7 @@ async function getGroupedByTagFiles({ logger, files, plugin, template, exportAs,
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
// src/utils/getParams.ts
|
|
72
|
-
|
|
72
|
+
_chunk2BGY3BRCcjs.init_cjs_shims.call(void 0, );
|
|
73
73
|
var _oas = require('@kubb/oas');
|
|
74
74
|
|
|
75
75
|
function getASTParams(operationSchema, {
|
|
@@ -104,7 +104,7 @@ function getPathParams(operationSchema, options = {}) {
|
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
// src/utils/refSorter.ts
|
|
107
|
-
|
|
107
|
+
_chunk2BGY3BRCcjs.init_cjs_shims.call(void 0, );
|
|
108
108
|
function refsSorter(a, b) {
|
|
109
109
|
if (_optionalChain([Object, 'access', _10 => _10.keys, 'call', _11 => _11(a.import.refs), 'optionalAccess', _12 => _12.length]) < _optionalChain([Object, 'access', _13 => _13.keys, 'call', _14 => _14(b.import.refs), 'optionalAccess', _15 => _15.length])) {
|
|
110
110
|
return -1;
|
|
@@ -123,5 +123,5 @@ function refsSorter(a, b) {
|
|
|
123
123
|
|
|
124
124
|
|
|
125
125
|
|
|
126
|
-
exports.getASTParams = getASTParams; exports.getComments = getComments; exports.getGroupedByTagFiles = getGroupedByTagFiles; exports.getPathParams = getPathParams; exports.getSchemaFactory =
|
|
126
|
+
exports.getASTParams = getASTParams; exports.getComments = getComments; exports.getGroupedByTagFiles = getGroupedByTagFiles; exports.getPathParams = getPathParams; exports.getSchemaFactory = _chunk2BGY3BRCcjs.getSchemaFactory; exports.getSchemas = _chunk2BGY3BRCcjs.getSchemas; exports.parseFromConfig = _chunkHUFRXC4Ncjs.parseFromConfig; exports.refsSorter = refsSorter;
|
|
127
127
|
//# sourceMappingURL=utils.cjs.map
|