@kubb/plugin-oas 3.0.0-alpha.16 → 3.0.0-alpha.18
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/README.md +0 -4
- package/dist/{chunk-D2N6LDLT.js → chunk-4CQVMYRG.js} +7 -16
- package/dist/chunk-4CQVMYRG.js.map +1 -0
- package/dist/{chunk-2QECZEUD.js → chunk-DFQJ57GH.js} +4 -35
- package/dist/chunk-DFQJ57GH.js.map +1 -0
- package/dist/chunk-GF26SDHQ.js +28 -0
- package/dist/chunk-GF26SDHQ.js.map +1 -0
- package/dist/{chunk-PUFCST25.cjs → chunk-HP5WAFBU.cjs} +2 -38
- package/dist/chunk-HP5WAFBU.cjs.map +1 -0
- package/dist/{chunk-7Q5B67MW.cjs → chunk-OO5R4UIK.cjs} +6 -408
- package/dist/chunk-OO5R4UIK.cjs.map +1 -0
- package/dist/chunk-PADR76WZ.cjs +4 -0
- package/dist/chunk-PADR76WZ.cjs.map +1 -0
- package/dist/chunk-R47XMJ32.js +3 -0
- package/dist/chunk-R47XMJ32.js.map +1 -0
- package/dist/{chunk-LCPCIS3S.cjs → chunk-RQG4KIFG.cjs} +7 -16
- package/dist/chunk-RQG4KIFG.cjs.map +1 -0
- package/dist/chunk-THGCWF2O.js +30 -0
- package/dist/chunk-THGCWF2O.js.map +1 -0
- package/dist/chunk-UO57DZPV.cjs +36 -0
- package/dist/chunk-UO57DZPV.cjs.map +1 -0
- package/dist/{chunk-7XBQZ7AX.js → chunk-V4LP5BFJ.js} +6 -404
- package/dist/chunk-V4LP5BFJ.js.map +1 -0
- package/dist/chunk-ZWHQ54JM.cjs +32 -0
- package/dist/chunk-ZWHQ54JM.cjs.map +1 -0
- package/dist/components.cjs +5 -5
- package/dist/components.js +2 -2
- package/dist/generators.cjs +4 -4
- package/dist/generators.js +3 -3
- package/dist/hooks.cjs +9 -31
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.js +3 -25
- package/dist/hooks.js.map +1 -1
- package/dist/index.cjs +402 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +392 -5
- package/dist/index.js.map +1 -1
- package/dist/utils.cjs +8 -29
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +2 -10
- package/dist/utils.d.ts +2 -10
- package/dist/utils.js +3 -23
- package/dist/utils.js.map +1 -1
- package/package.json +8 -11
- package/src/SchemaGenerator.ts +1 -1
- package/src/hooks/useSchemaManager.ts +3 -2
- package/src/utils/index.ts +0 -1
- package/dist/chunk-2QECZEUD.js.map +0 -1
- package/dist/chunk-4OQEPWOG.js +0 -38
- package/dist/chunk-4OQEPWOG.js.map +0 -1
- package/dist/chunk-7Q5B67MW.cjs.map +0 -1
- package/dist/chunk-7XBQZ7AX.js.map +0 -1
- package/dist/chunk-CQDZGAA6.cjs +0 -3176
- package/dist/chunk-CQDZGAA6.cjs.map +0 -1
- package/dist/chunk-CYF724QJ.js +0 -3171
- package/dist/chunk-CYF724QJ.js.map +0 -1
- package/dist/chunk-D2N6LDLT.js.map +0 -1
- package/dist/chunk-LCPCIS3S.cjs.map +0 -1
- package/dist/chunk-PUFCST25.cjs.map +0 -1
- package/dist/chunk-TYQZ2BD7.cjs +0 -42
- package/dist/chunk-TYQZ2BD7.cjs.map +0 -1
- package/src/utils/refSorter.ts +0 -13
|
@@ -1,19 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var chunkTYQZ2BD7_cjs = require('./chunk-TYQZ2BD7.cjs');
|
|
3
|
+
var chunkZWHQ54JM_cjs = require('./chunk-ZWHQ54JM.cjs');
|
|
5
4
|
var transformers = require('@kubb/core/transformers');
|
|
6
5
|
var react = require('@kubb/react');
|
|
6
|
+
var jsxRuntime = require('@kubb/react/jsx-runtime');
|
|
7
7
|
|
|
8
|
-
// src/generators/index.ts
|
|
9
|
-
chunkTYQZ2BD7_cjs.init_cjs_shims();
|
|
10
|
-
|
|
11
|
-
// src/generators/jsonGenerator.ts
|
|
12
|
-
chunkTYQZ2BD7_cjs.init_cjs_shims();
|
|
13
|
-
|
|
14
|
-
// src/generator.tsx
|
|
15
|
-
chunkTYQZ2BD7_cjs.init_cjs_shims();
|
|
16
|
-
var import_jsx_runtime = chunkTYQZ2BD7_cjs.__toESM(chunkCQDZGAA6_cjs.require_jsx_runtime(), 1);
|
|
17
8
|
function createGenerator(parseOptions) {
|
|
18
9
|
return parseOptions;
|
|
19
10
|
}
|
|
@@ -30,7 +21,7 @@ function createReactGenerator(parseOptions) {
|
|
|
30
21
|
});
|
|
31
22
|
const Component = parseOptions.Operations.bind(this);
|
|
32
23
|
root.render(
|
|
33
|
-
/* @__PURE__ */
|
|
24
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.App, { pluginManager, plugin, mode, children: /* @__PURE__ */ jsxRuntime.jsx(chunkZWHQ54JM_cjs.Oas, { oas, operations, generator: instance, children: /* @__PURE__ */ jsxRuntime.jsx(Component, { operations, instance, operationsByMethod, options }) }) })
|
|
34
25
|
);
|
|
35
26
|
return root.files;
|
|
36
27
|
},
|
|
@@ -44,7 +35,7 @@ function createReactGenerator(parseOptions) {
|
|
|
44
35
|
});
|
|
45
36
|
const Component = parseOptions.Operation.bind(this);
|
|
46
37
|
root.render(
|
|
47
|
-
/* @__PURE__ */
|
|
38
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.App, { pluginManager, plugin: { ...plugin, options }, mode, children: /* @__PURE__ */ jsxRuntime.jsx(chunkZWHQ54JM_cjs.Oas, { oas, operations: [operation], generator: instance, children: /* @__PURE__ */ jsxRuntime.jsx(chunkZWHQ54JM_cjs.Oas.Operation, { operation, children: /* @__PURE__ */ jsxRuntime.jsx(Component, { operation, options, instance }) }) }) })
|
|
48
39
|
);
|
|
49
40
|
return root.files;
|
|
50
41
|
},
|
|
@@ -58,7 +49,7 @@ function createReactGenerator(parseOptions) {
|
|
|
58
49
|
});
|
|
59
50
|
const Component = parseOptions.Schema.bind(this);
|
|
60
51
|
root.render(
|
|
61
|
-
/* @__PURE__ */
|
|
52
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.App, { pluginManager, plugin: { ...plugin, options }, mode, children: /* @__PURE__ */ jsxRuntime.jsx(chunkZWHQ54JM_cjs.Oas, { oas, children: /* @__PURE__ */ jsxRuntime.jsx(chunkZWHQ54JM_cjs.Oas.Schema, { name: schema.name, value: schema.value, tree: schema.tree, children: /* @__PURE__ */ jsxRuntime.jsx(Component, { schema, options, instance }) }) }) })
|
|
62
53
|
);
|
|
63
54
|
return root.files;
|
|
64
55
|
}
|
|
@@ -95,5 +86,5 @@ var jsonGenerator = createGenerator({
|
|
|
95
86
|
exports.createGenerator = createGenerator;
|
|
96
87
|
exports.createReactGenerator = createReactGenerator;
|
|
97
88
|
exports.jsonGenerator = jsonGenerator;
|
|
98
|
-
//# sourceMappingURL=chunk-
|
|
99
|
-
//# sourceMappingURL=chunk-
|
|
89
|
+
//# sourceMappingURL=chunk-RQG4KIFG.cjs.map
|
|
90
|
+
//# sourceMappingURL=chunk-RQG4KIFG.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/generator.tsx","../src/generators/jsonGenerator.ts"],"names":["createRoot","App","jsx","Oas","camelCase"],"mappings":";;;;;;;AA2CO,SAAS,gBAAuD,YAA+D,EAAA;AACpI,EAAO,OAAA,YAAA,CAAA;AACT,CAAA;AAaO,SAAS,qBAA4D,YAAoE,EAAA;AAC9I,EAAO,OAAA;AAAA,IACL,GAAG,YAAA;AAAA,IACH,MAAM,UAAW,CAAA,EAAE,UAAU,OAAS,EAAA,UAAA,EAAY,oBAAsB,EAAA;AACtE,MAAI,IAAA,CAAC,aAAa,UAAY,EAAA;AAC5B,QAAA,OAAO,EAAC,CAAA;AAAA,OACV;AAEA,MAAA,MAAM,EAAE,aAAe,EAAA,GAAA,EAAK,MAAQ,EAAA,IAAA,KAAS,QAAS,CAAA,OAAA,CAAA;AACtD,MAAA,MAAM,OAAOA,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IO,IAAM,gBAAgB,eAA2B,CAAA;AAAA,EACtD,IAAM,EAAA,YAAA;AAAA,EACN,MAAM,MAAA,CAAO,EAAE,MAAA,EAAQ,UAAY,EAAA;AACjC,IAAA,MAAM,EAAE,aAAA,EAAe,MAAO,EAAA,GAAI,QAAS,CAAA,OAAA,CAAA;AAC3C,IAAM,MAAA,IAAA,GAAO,cAAc,OAAQ,CAAA;AAAA,MACjC,IAAA,EAAME,sBAAU,CAAA,MAAA,CAAO,IAAI,CAAA;AAAA,MAC3B,OAAS,EAAA,OAAA;AAAA,MACT,IAAM,EAAA,OAAA;AAAA,MACN,WAAW,MAAO,CAAA,GAAA;AAAA,KACnB,CAAA,CAAA;AAED,IAAO,OAAA;AAAA,MACL;AAAA,QACE,GAAG,IAAA;AAAA,QACH,OAAS,EAAA;AAAA,UACP;AAAA,YACE,IAAA,EAAMA,sBAAU,CAAA,MAAA,CAAO,IAAI,CAAA;AAAA,YAC3B,YAAc,EAAA,KAAA;AAAA,YACd,WAAa,EAAA,KAAA;AAAA,YACb,KAAO,EAAA,IAAA,CAAK,SAAU,CAAA,MAAA,CAAO,KAAK,CAAA;AAAA,WACpC;AAAA,SACF;AAAA,OACF;AAAA,KACF,CAAA;AAAA,GACF;AACF,CAAC","file":"chunk-RQG4KIFG.cjs","sourcesContent":["import type { PluginFactoryOptions } from '@kubb/core'\nimport type * as KubbFile from '@kubb/fs/types'\nimport type { Operation, SchemaObject } from '@kubb/oas'\nimport { Oas } from '@kubb/plugin-oas/components'\nimport { App, createRoot } from '@kubb/react'\nimport type { KubbNode } from '@kubb/react/types'\nimport type { OperationGenerator } from './OperationGenerator.ts'\nimport type { SchemaGenerator, SchemaGeneratorOptions } from './SchemaGenerator.ts'\nimport type { Schema } from './SchemaMapper.ts'\nimport type { OperationsByMethod } from './types.ts'\n\ntype OperationsProps<TOptions extends PluginFactoryOptions> = {\n instance: Omit<OperationGenerator<TOptions>, 'build'>\n options: TOptions['resolvedOptions']\n operations: Array<Operation>\n operationsByMethod: OperationsByMethod\n}\n\ntype OperationProps<TOptions extends PluginFactoryOptions> = {\n instance: Omit<OperationGenerator<TOptions>, 'build'>\n options: TOptions['resolvedOptions']\n operation: Operation\n}\n\ntype SchemaProps<TOptions extends PluginFactoryOptions> = {\n instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>\n schema: {\n name: string\n tree: Array<Schema>\n value: SchemaObject\n }\n options: TOptions['resolvedOptions']\n}\n\nexport type GeneratorOptions<TOptions extends PluginFactoryOptions> = {\n name: string\n operations?: (this: GeneratorOptions<TOptions>, props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>\n operation?: (this: GeneratorOptions<TOptions>, props: OperationProps<TOptions>) => Promise<KubbFile.File[]>\n schema?: (this: GeneratorOptions<TOptions>, props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>\n}\n\nexport type Generator<TOptions extends PluginFactoryOptions> = GeneratorOptions<TOptions>\n\nexport function createGenerator<TOptions extends PluginFactoryOptions>(parseOptions: GeneratorOptions<TOptions>): Generator<TOptions> {\n return parseOptions\n}\n\nexport type ReactGeneratorOptions<TOptions extends PluginFactoryOptions> = {\n name: string\n Operations?: (this: ReactGeneratorOptions<TOptions>, props: OperationsProps<TOptions>) => KubbNode\n Operation?: (this: ReactGeneratorOptions<TOptions>, props: OperationProps<TOptions>) => KubbNode\n Schema?: (this: ReactGeneratorOptions<TOptions>, props: SchemaProps<TOptions>) => KubbNode\n /**\n * Combine all react nodes and only render ones(to string or render)\n */\n render?: () => any\n}\n\nexport function createReactGenerator<TOptions extends PluginFactoryOptions>(parseOptions: ReactGeneratorOptions<TOptions>): Generator<TOptions> {\n return {\n ...parseOptions,\n async operations({ instance, options, operations, operationsByMethod }) {\n if (!parseOptions.Operations) {\n return []\n }\n\n const { pluginManager, oas, plugin, mode } = instance.context\n const root = createRoot({\n logger: pluginManager.logger,\n })\n\n const Component = parseOptions.Operations.bind(this)\n\n root.render(\n <App pluginManager={pluginManager} plugin={plugin} mode={mode}>\n <Oas oas={oas} operations={operations} generator={instance}>\n <Component operations={operations} instance={instance} operationsByMethod={operationsByMethod} options={options} />\n </Oas>\n </App>,\n )\n\n return root.files\n },\n async operation({ instance, operation, options }) {\n if (!parseOptions.Operation) {\n return []\n }\n\n const { pluginManager, oas, plugin, mode } = instance.context\n const root = createRoot({\n logger: pluginManager.logger,\n })\n\n const Component = parseOptions.Operation.bind(this)\n\n root.render(\n <App pluginManager={pluginManager} plugin={{ ...plugin, options }} mode={mode}>\n <Oas oas={oas} operations={[operation]} generator={instance}>\n <Oas.Operation operation={operation}>\n <Component operation={operation} options={options} instance={instance} />\n </Oas.Operation>\n </Oas>\n </App>,\n )\n\n return root.files\n },\n async schema({ instance, schema, options }) {\n if (!parseOptions.Schema) {\n return []\n }\n\n const { pluginManager, oas, plugin, mode } = instance.context\n const root = createRoot({\n logger: pluginManager.logger,\n })\n\n const Component = parseOptions.Schema.bind(this)\n\n root.render(\n <App pluginManager={pluginManager} plugin={{ ...plugin, options }} mode={mode}>\n <Oas oas={oas}>\n <Oas.Schema name={schema.name} value={schema.value} tree={schema.tree}>\n <Component schema={schema} options={options} instance={instance} />\n </Oas.Schema>\n </Oas>\n </App>,\n )\n\n return root.files\n },\n }\n}\n","import { camelCase } from '@kubb/core/transformers'\nimport { createGenerator } from '../generator.tsx'\nimport type { PluginOas } from '../types.ts'\n\nexport const jsonGenerator = createGenerator<PluginOas>({\n name: 'plugin-oas',\n async schema({ schema, instance }) {\n const { pluginManager, plugin } = instance.context\n const file = pluginManager.getFile({\n name: camelCase(schema.name),\n extName: '.json',\n mode: 'split',\n pluginKey: plugin.key,\n })\n\n return [\n {\n ...file,\n sources: [\n {\n name: camelCase(schema.name),\n isExportable: false,\n isIndexable: false,\n value: JSON.stringify(schema.value),\n },\n ],\n },\n ]\n },\n})\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { resolve } from 'node:path';
|
|
2
|
+
import { URLPath } from '@kubb/core/utils';
|
|
3
|
+
import { parse } from '@kubb/oas/parser';
|
|
4
|
+
import { Oas } from '@kubb/oas';
|
|
5
|
+
import yaml from '@stoplight/yaml';
|
|
6
|
+
|
|
7
|
+
// src/utils/parseFromConfig.ts
|
|
8
|
+
function parseFromConfig(config, options = {}, oasClass = Oas) {
|
|
9
|
+
if ("data" in config.input) {
|
|
10
|
+
if (typeof config.input.data === "object") {
|
|
11
|
+
const api2 = JSON.parse(JSON.stringify(config.input.data));
|
|
12
|
+
return parse(api2, options, oasClass);
|
|
13
|
+
}
|
|
14
|
+
try {
|
|
15
|
+
const api2 = yaml.parse(config.input.data);
|
|
16
|
+
return parse(api2, options, oasClass);
|
|
17
|
+
} catch (e) {
|
|
18
|
+
}
|
|
19
|
+
const api = JSON.parse(JSON.stringify(config.input.data));
|
|
20
|
+
return parse(api, options, oasClass);
|
|
21
|
+
}
|
|
22
|
+
if (new URLPath(config.input.path).isURL) {
|
|
23
|
+
return parse(config.input.path, options, oasClass);
|
|
24
|
+
}
|
|
25
|
+
return parse(resolve(config.root, config.input.path), options, oasClass);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export { parseFromConfig };
|
|
29
|
+
//# sourceMappingURL=chunk-THGCWF2O.js.map
|
|
30
|
+
//# sourceMappingURL=chunk-THGCWF2O.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/parseFromConfig.ts"],"names":["api"],"mappings":";;;;;;;AAUO,SAAS,gBAAgB,MAAgB,EAAA,OAAA,GAAyB,EAAC,EAAG,WAAuB,GAAmB,EAAA;AACrH,EAAI,IAAA,MAAA,IAAU,OAAO,KAAO,EAAA;AAC1B,IAAA,IAAI,OAAO,MAAA,CAAO,KAAM,CAAA,IAAA,KAAS,QAAU,EAAA;AACzC,MAAMA,MAAAA,IAAAA,GAA4B,KAAK,KAAM,CAAA,IAAA,CAAK,UAAU,MAAO,CAAA,KAAA,CAAM,IAAI,CAAC,CAAA,CAAA;AAC9E,MAAO,OAAA,KAAA,CAAMA,IAAK,EAAA,OAAA,EAAS,QAAQ,CAAA,CAAA;AAAA,KACrC;AAEA,IAAI,IAAA;AACF,MAAA,MAAMA,IAAc,GAAA,IAAA,CAAK,KAAM,CAAA,MAAA,CAAO,MAAM,IAAc,CAAA,CAAA;AAE1D,MAAO,OAAA,KAAA,CAAMA,IAAK,EAAA,OAAA,EAAS,QAAQ,CAAA,CAAA;AAAA,aAC5B,CAAG,EAAA;AAAA,KAEZ;AAEA,IAAM,MAAA,GAAA,GAA4B,KAAK,KAAM,CAAA,IAAA,CAAK,UAAU,MAAO,CAAA,KAAA,CAAM,IAAI,CAAC,CAAA,CAAA;AAE9E,IAAO,OAAA,KAAA,CAAM,GAAK,EAAA,OAAA,EAAS,QAAQ,CAAA,CAAA;AAAA,GACrC;AAEA,EAAA,IAAI,IAAI,OAAQ,CAAA,MAAA,CAAO,KAAM,CAAA,IAAI,EAAE,KAAO,EAAA;AACxC,IAAA,OAAO,KAAM,CAAA,MAAA,CAAO,KAAM,CAAA,IAAA,EAAM,SAAS,QAAQ,CAAA,CAAA;AAAA,GACnD;AAEA,EAAO,OAAA,KAAA,CAAM,QAAQ,MAAO,CAAA,IAAA,EAAM,OAAO,KAAM,CAAA,IAAI,CAAG,EAAA,OAAA,EAAS,QAAQ,CAAA,CAAA;AACzE","file":"chunk-THGCWF2O.js","sourcesContent":["import { resolve } from 'node:path'\n\nimport { URLPath } from '@kubb/core/utils'\n\nimport { type FormatOptions, parse } from '@kubb/oas/parser'\n\nimport type { Config } from '@kubb/core'\nimport { Oas, type OasTypes } from '@kubb/oas'\nimport yaml from '@stoplight/yaml'\n\nexport function parseFromConfig(config: Config, options: FormatOptions = {}, oasClass: typeof Oas = Oas): Promise<Oas> {\n if ('data' in config.input) {\n if (typeof config.input.data === 'object') {\n const api: OasTypes.OASDocument = JSON.parse(JSON.stringify(config.input.data)) as OasTypes.OASDocument\n return parse(api, options, oasClass)\n }\n\n try {\n const api: string = yaml.parse(config.input.data as string) as string\n\n return parse(api, options, oasClass)\n } catch (e) {\n /* empty */\n }\n\n const api: OasTypes.OASDocument = JSON.parse(JSON.stringify(config.input.data)) as OasTypes.OASDocument\n\n return parse(api, options, oasClass)\n }\n\n if (new URLPath(config.input.path).isURL) {\n return parse(config.input.path, options, oasClass)\n }\n\n return parse(resolve(config.root, config.input.path), options, oasClass)\n}\n"]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var path = require('path');
|
|
4
|
+
var utils = require('@kubb/core/utils');
|
|
5
|
+
var parser = require('@kubb/oas/parser');
|
|
6
|
+
var oas = require('@kubb/oas');
|
|
7
|
+
var yaml = require('@stoplight/yaml');
|
|
8
|
+
|
|
9
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
|
|
11
|
+
var yaml__default = /*#__PURE__*/_interopDefault(yaml);
|
|
12
|
+
|
|
13
|
+
// src/utils/parseFromConfig.ts
|
|
14
|
+
function parseFromConfig(config, options = {}, oasClass = oas.Oas) {
|
|
15
|
+
if ("data" in config.input) {
|
|
16
|
+
if (typeof config.input.data === "object") {
|
|
17
|
+
const api2 = JSON.parse(JSON.stringify(config.input.data));
|
|
18
|
+
return parser.parse(api2, options, oasClass);
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
const api2 = yaml__default.default.parse(config.input.data);
|
|
22
|
+
return parser.parse(api2, options, oasClass);
|
|
23
|
+
} catch (e) {
|
|
24
|
+
}
|
|
25
|
+
const api = JSON.parse(JSON.stringify(config.input.data));
|
|
26
|
+
return parser.parse(api, options, oasClass);
|
|
27
|
+
}
|
|
28
|
+
if (new utils.URLPath(config.input.path).isURL) {
|
|
29
|
+
return parser.parse(config.input.path, options, oasClass);
|
|
30
|
+
}
|
|
31
|
+
return parser.parse(path.resolve(config.root, config.input.path), options, oasClass);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
exports.parseFromConfig = parseFromConfig;
|
|
35
|
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A,GACnD;AAEA,EAAO,OAAAA,YAAA,CAAMG,aAAQ,MAAO,CAAA,IAAA,EAAM,OAAO,KAAM,CAAA,IAAI,CAAG,EAAA,OAAA,EAAS,QAAQ,CAAA,CAAA;AACzE","file":"chunk-UO57DZPV.cjs","sourcesContent":["import { resolve } from 'node:path'\n\nimport { URLPath } from '@kubb/core/utils'\n\nimport { type FormatOptions, parse } from '@kubb/oas/parser'\n\nimport type { Config } from '@kubb/core'\nimport { Oas, type OasTypes } from '@kubb/oas'\nimport yaml from '@stoplight/yaml'\n\nexport function parseFromConfig(config: Config, options: FormatOptions = {}, oasClass: typeof Oas = Oas): Promise<Oas> {\n if ('data' in config.input) {\n if (typeof config.input.data === 'object') {\n const api: OasTypes.OASDocument = JSON.parse(JSON.stringify(config.input.data)) as OasTypes.OASDocument\n return parse(api, options, oasClass)\n }\n\n try {\n const api: string = yaml.parse(config.input.data as string) as string\n\n return parse(api, options, oasClass)\n } catch (e) {\n /* empty */\n }\n\n const api: OasTypes.OASDocument = JSON.parse(JSON.stringify(config.input.data)) as OasTypes.OASDocument\n\n return parse(api, options, oasClass)\n }\n\n if (new URLPath(config.input.path).isURL) {\n return parse(config.input.path, options, oasClass)\n }\n\n return parse(resolve(config.root, config.input.path), options, oasClass)\n}\n"]}
|
|
@@ -1,299 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { init_esm_shims } from './chunk-4OQEPWOG.js';
|
|
4
|
-
import { createPlugin, FileManager, BaseGenerator } from '@kubb/core';
|
|
1
|
+
import { getSchemaFactory, getSchemas } from './chunk-DFQJ57GH.js';
|
|
2
|
+
import { BaseGenerator } from '@kubb/core';
|
|
5
3
|
import transformers, { pascalCase } from '@kubb/core/transformers';
|
|
6
|
-
import path from 'node:path';
|
|
7
4
|
import { getUniqueName } from '@kubb/core/utils';
|
|
8
5
|
import { isReference } from '@kubb/oas';
|
|
9
6
|
import { uniqueWith, isDeepEqual, isNumber } from 'remeda';
|
|
10
7
|
|
|
11
|
-
// src/index.ts
|
|
12
|
-
init_esm_shims();
|
|
13
|
-
|
|
14
|
-
// src/OperationGenerator.ts
|
|
15
|
-
init_esm_shims();
|
|
16
|
-
var OperationGenerator = class extends BaseGenerator {
|
|
17
|
-
#operationsByMethod = {};
|
|
18
|
-
get operationsByMethod() {
|
|
19
|
-
return this.#operationsByMethod;
|
|
20
|
-
}
|
|
21
|
-
set operationsByMethod(paths) {
|
|
22
|
-
this.#operationsByMethod = paths;
|
|
23
|
-
}
|
|
24
|
-
#getOptions(operation, method) {
|
|
25
|
-
const { override = [] } = this.context;
|
|
26
|
-
return override.find(({ pattern, type }) => {
|
|
27
|
-
if (type === "tag") {
|
|
28
|
-
return !!operation.getTags()[0]?.name.match(pattern);
|
|
29
|
-
}
|
|
30
|
-
if (type === "operationId") {
|
|
31
|
-
return !!operation.getOperationId().match(pattern);
|
|
32
|
-
}
|
|
33
|
-
if (type === "path") {
|
|
34
|
-
return !!operation.path.match(pattern);
|
|
35
|
-
}
|
|
36
|
-
if (type === "method") {
|
|
37
|
-
return !!method.match(pattern);
|
|
38
|
-
}
|
|
39
|
-
return false;
|
|
40
|
-
})?.options || {};
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
*
|
|
44
|
-
* @deprecated
|
|
45
|
-
*/
|
|
46
|
-
#isExcluded(operation, method) {
|
|
47
|
-
const { exclude = [] } = this.context;
|
|
48
|
-
let matched = false;
|
|
49
|
-
exclude.forEach(({ pattern, type }) => {
|
|
50
|
-
if (type === "tag" && !matched) {
|
|
51
|
-
matched = !!operation.getTags()[0]?.name.match(pattern);
|
|
52
|
-
}
|
|
53
|
-
if (type === "operationId" && !matched) {
|
|
54
|
-
matched = !!operation.getOperationId().match(pattern);
|
|
55
|
-
}
|
|
56
|
-
if (type === "path" && !matched) {
|
|
57
|
-
matched = !!operation.path.match(pattern);
|
|
58
|
-
}
|
|
59
|
-
if (type === "method" && !matched) {
|
|
60
|
-
matched = !!method.match(pattern);
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
return matched;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
*
|
|
67
|
-
* @deprecated
|
|
68
|
-
*/
|
|
69
|
-
#isIncluded(operation, method) {
|
|
70
|
-
const { include = [] } = this.context;
|
|
71
|
-
let matched = false;
|
|
72
|
-
include.forEach(({ pattern, type }) => {
|
|
73
|
-
if (type === "tag" && !matched) {
|
|
74
|
-
matched = !!operation.getTags()[0]?.name.match(pattern);
|
|
75
|
-
}
|
|
76
|
-
if (type === "operationId" && !matched) {
|
|
77
|
-
matched = !!operation.getOperationId().match(pattern);
|
|
78
|
-
}
|
|
79
|
-
if (type === "path" && !matched) {
|
|
80
|
-
matched = !!operation.path.match(pattern);
|
|
81
|
-
}
|
|
82
|
-
if (type === "method" && !matched) {
|
|
83
|
-
matched = !!method.match(pattern);
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
return matched;
|
|
87
|
-
}
|
|
88
|
-
getSchemas(operation, {
|
|
89
|
-
resolveName = (name) => name
|
|
90
|
-
} = {}) {
|
|
91
|
-
const pathParamsSchema = this.context.oas.getParametersSchema(operation, "path");
|
|
92
|
-
const queryParamsSchema = this.context.oas.getParametersSchema(operation, "query");
|
|
93
|
-
const headerParamsSchema = this.context.oas.getParametersSchema(operation, "header");
|
|
94
|
-
const requestSchema = this.context.oas.getRequestSchema(operation);
|
|
95
|
-
const responseStatusCode = operation.schema.responses && Object.keys(operation.schema.responses).find((key) => key.startsWith("2")) || 200;
|
|
96
|
-
const responseSchema = this.context.oas.getResponseSchema(operation, responseStatusCode);
|
|
97
|
-
const statusCodes = operation.getResponseStatusCodes().map((statusCode) => {
|
|
98
|
-
let name = statusCode;
|
|
99
|
-
if (name === "default") {
|
|
100
|
-
name = "error";
|
|
101
|
-
}
|
|
102
|
-
const schema = this.context.oas.getResponseSchema(operation, statusCode);
|
|
103
|
-
return {
|
|
104
|
-
name: resolveName(transformers.pascalCase(`${operation.getOperationId()} ${name}`)),
|
|
105
|
-
description: operation.getResponseByStatusCode(statusCode)?.description,
|
|
106
|
-
schema,
|
|
107
|
-
operation,
|
|
108
|
-
operationName: transformers.pascalCase(`${operation.getOperationId()}`),
|
|
109
|
-
statusCode: name === "error" ? void 0 : Number(statusCode),
|
|
110
|
-
keys: schema?.properties ? Object.keys(schema.properties) : void 0
|
|
111
|
-
};
|
|
112
|
-
});
|
|
113
|
-
return {
|
|
114
|
-
pathParams: pathParamsSchema ? {
|
|
115
|
-
name: resolveName(transformers.pascalCase(`${operation.getOperationId()} PathParams`)),
|
|
116
|
-
operation,
|
|
117
|
-
operationName: transformers.pascalCase(`${operation.getOperationId()}`),
|
|
118
|
-
schema: pathParamsSchema,
|
|
119
|
-
keys: pathParamsSchema.properties ? Object.keys(pathParamsSchema.properties) : void 0
|
|
120
|
-
} : void 0,
|
|
121
|
-
queryParams: queryParamsSchema ? {
|
|
122
|
-
name: resolveName(transformers.pascalCase(`${operation.getOperationId()} QueryParams`)),
|
|
123
|
-
operation,
|
|
124
|
-
operationName: transformers.pascalCase(`${operation.getOperationId()}`),
|
|
125
|
-
schema: queryParamsSchema,
|
|
126
|
-
keys: queryParamsSchema.properties ? Object.keys(queryParamsSchema.properties) : []
|
|
127
|
-
} : void 0,
|
|
128
|
-
headerParams: headerParamsSchema ? {
|
|
129
|
-
name: resolveName(transformers.pascalCase(`${operation.getOperationId()} HeaderParams`)),
|
|
130
|
-
operation,
|
|
131
|
-
operationName: transformers.pascalCase(`${operation.getOperationId()}`),
|
|
132
|
-
schema: headerParamsSchema,
|
|
133
|
-
keys: headerParamsSchema.properties ? Object.keys(headerParamsSchema.properties) : void 0
|
|
134
|
-
} : void 0,
|
|
135
|
-
request: requestSchema ? {
|
|
136
|
-
name: resolveName(transformers.pascalCase(`${operation.getOperationId()} ${operation.method === "get" ? "queryRequest" : "mutationRequest"}`)),
|
|
137
|
-
description: operation.schema.requestBody?.description,
|
|
138
|
-
operation,
|
|
139
|
-
operationName: transformers.pascalCase(`${operation.getOperationId()}`),
|
|
140
|
-
schema: requestSchema,
|
|
141
|
-
keys: requestSchema.properties ? Object.keys(requestSchema.properties) : void 0,
|
|
142
|
-
keysToOmit: requestSchema.properties ? Object.keys(requestSchema.properties).filter((key) => {
|
|
143
|
-
const item = requestSchema.properties?.[key];
|
|
144
|
-
return item?.readOnly;
|
|
145
|
-
}) : void 0
|
|
146
|
-
} : void 0,
|
|
147
|
-
response: {
|
|
148
|
-
name: resolveName(transformers.pascalCase(`${operation.getOperationId()} ${operation.method === "get" ? "queryResponse" : "mutationResponse"}`)),
|
|
149
|
-
description: operation.getResponseAsJSONSchema(responseStatusCode)?.at(0)?.description,
|
|
150
|
-
operation,
|
|
151
|
-
operationName: transformers.pascalCase(`${operation.getOperationId()}`),
|
|
152
|
-
schema: responseSchema,
|
|
153
|
-
statusCode: Number(responseStatusCode),
|
|
154
|
-
keys: responseSchema?.properties ? Object.keys(responseSchema.properties) : void 0,
|
|
155
|
-
keysToOmit: responseSchema?.properties ? Object.keys(responseSchema.properties).filter((key) => {
|
|
156
|
-
const item = responseSchema.properties?.[key];
|
|
157
|
-
return item?.writeOnly;
|
|
158
|
-
}) : void 0
|
|
159
|
-
},
|
|
160
|
-
errors: statusCodes.filter((item) => item.statusCode?.toString().startsWith("4") || item.statusCode?.toString().startsWith("5")),
|
|
161
|
-
statusCodes
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
#methods = ["get", "post", "patch", "put", "delete"];
|
|
165
|
-
async build(...generators) {
|
|
166
|
-
const { oas } = this.context;
|
|
167
|
-
const paths = oas.getPaths();
|
|
168
|
-
this.operationsByMethod = Object.entries(paths).reduce((acc, [path2, method]) => {
|
|
169
|
-
const methods = Object.keys(method);
|
|
170
|
-
methods.forEach((method2) => {
|
|
171
|
-
const operation = oas.operation(path2, method2);
|
|
172
|
-
if (operation && [this.#methods].some((methods2) => method2 === operation.method)) {
|
|
173
|
-
const isExcluded = this.#isExcluded(operation, method2);
|
|
174
|
-
const isIncluded = this.context.include ? this.#isIncluded(operation, method2) : true;
|
|
175
|
-
if (isIncluded && !isExcluded) {
|
|
176
|
-
if (!acc[path2]) {
|
|
177
|
-
acc[path2] = {};
|
|
178
|
-
}
|
|
179
|
-
acc[path2] = {
|
|
180
|
-
...acc[path2],
|
|
181
|
-
[method2]: {
|
|
182
|
-
operation,
|
|
183
|
-
schemas: this.getSchemas(operation)
|
|
184
|
-
}
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
return acc;
|
|
190
|
-
}, {});
|
|
191
|
-
const promises = Object.keys(this.operationsByMethod).reduce((acc, path2) => {
|
|
192
|
-
const methods = this.operationsByMethod[path2] ? Object.keys(this.operationsByMethod[path2]) : [];
|
|
193
|
-
methods.forEach((method) => {
|
|
194
|
-
const { operation } = this.operationsByMethod[path2]?.[method];
|
|
195
|
-
const options = this.#getOptions(operation, method);
|
|
196
|
-
const methodToCall = this[method];
|
|
197
|
-
if (typeof methodToCall === "function") {
|
|
198
|
-
const promiseMethod = methodToCall?.call(this, operation, {
|
|
199
|
-
...this.options,
|
|
200
|
-
...options
|
|
201
|
-
});
|
|
202
|
-
if (promiseMethod) {
|
|
203
|
-
acc.push(promiseMethod);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
const promiseOperation = this.operation.call(this, operation, {
|
|
207
|
-
...this.options,
|
|
208
|
-
...options
|
|
209
|
-
});
|
|
210
|
-
if (promiseOperation) {
|
|
211
|
-
acc.push(promiseOperation);
|
|
212
|
-
}
|
|
213
|
-
generators?.forEach((generator) => {
|
|
214
|
-
const promise = generator.operation?.({
|
|
215
|
-
instance: this,
|
|
216
|
-
operation,
|
|
217
|
-
options: {
|
|
218
|
-
...this.options,
|
|
219
|
-
...options
|
|
220
|
-
}
|
|
221
|
-
});
|
|
222
|
-
if (promise) {
|
|
223
|
-
acc.push(promise);
|
|
224
|
-
}
|
|
225
|
-
});
|
|
226
|
-
});
|
|
227
|
-
return acc;
|
|
228
|
-
}, []);
|
|
229
|
-
const operations = Object.values(this.operationsByMethod).map((item) => Object.values(item).map((item2) => item2.operation));
|
|
230
|
-
promises.push(this.all(operations.flat().filter(Boolean), this.operationsByMethod));
|
|
231
|
-
generators?.forEach((generator) => {
|
|
232
|
-
const promise = generator.operations?.({
|
|
233
|
-
instance: this,
|
|
234
|
-
operations: operations.flat().filter(Boolean),
|
|
235
|
-
operationsByMethod: this.operationsByMethod,
|
|
236
|
-
options: this.options
|
|
237
|
-
});
|
|
238
|
-
if (promise) {
|
|
239
|
-
promises.push(promise);
|
|
240
|
-
}
|
|
241
|
-
});
|
|
242
|
-
const files = await Promise.all(promises);
|
|
243
|
-
return files.flat().filter(Boolean);
|
|
244
|
-
}
|
|
245
|
-
/**
|
|
246
|
-
* Operation
|
|
247
|
-
*/
|
|
248
|
-
async operation(operation, options) {
|
|
249
|
-
return [];
|
|
250
|
-
}
|
|
251
|
-
/**
|
|
252
|
-
* GET
|
|
253
|
-
*/
|
|
254
|
-
async get(operation, options) {
|
|
255
|
-
return [];
|
|
256
|
-
}
|
|
257
|
-
/**
|
|
258
|
-
* POST
|
|
259
|
-
*/
|
|
260
|
-
async post(operation, options) {
|
|
261
|
-
return [];
|
|
262
|
-
}
|
|
263
|
-
/**
|
|
264
|
-
* PATCH
|
|
265
|
-
*/
|
|
266
|
-
async patch(operation, options) {
|
|
267
|
-
return [];
|
|
268
|
-
}
|
|
269
|
-
/**
|
|
270
|
-
* PUT
|
|
271
|
-
*/
|
|
272
|
-
async put(operation, options) {
|
|
273
|
-
return [];
|
|
274
|
-
}
|
|
275
|
-
/**
|
|
276
|
-
* DELETE
|
|
277
|
-
*/
|
|
278
|
-
async delete(operation, options) {
|
|
279
|
-
return [];
|
|
280
|
-
}
|
|
281
|
-
/**
|
|
282
|
-
* Combination of GET, POST, PATCH, PUT, DELETE
|
|
283
|
-
*/
|
|
284
|
-
async all(operations, paths) {
|
|
285
|
-
return [];
|
|
286
|
-
}
|
|
287
|
-
};
|
|
288
|
-
|
|
289
|
-
// src/plugin.ts
|
|
290
|
-
init_esm_shims();
|
|
291
|
-
|
|
292
|
-
// src/SchemaGenerator.ts
|
|
293
|
-
init_esm_shims();
|
|
294
|
-
|
|
295
8
|
// src/SchemaMapper.ts
|
|
296
|
-
init_esm_shims();
|
|
297
9
|
var schemaKeywords = {
|
|
298
10
|
any: "any",
|
|
299
11
|
strict: "strict",
|
|
@@ -343,8 +55,6 @@ var schemaKeywords = {
|
|
|
343
55
|
function isKeyword(meta, keyword) {
|
|
344
56
|
return meta.keyword === keyword;
|
|
345
57
|
}
|
|
346
|
-
|
|
347
|
-
// src/SchemaGenerator.ts
|
|
348
58
|
var SchemaGenerator = class _SchemaGenerator extends BaseGenerator {
|
|
349
59
|
// Collect the types of all referenced schemas, so we can export them later
|
|
350
60
|
refs = {};
|
|
@@ -932,7 +642,7 @@ var SchemaGenerator = class _SchemaGenerator extends BaseGenerator {
|
|
|
932
642
|
...baseItems
|
|
933
643
|
].filter(Boolean);
|
|
934
644
|
}
|
|
935
|
-
if (!["boolean", "object", "number", "string", "integer"].includes(schema.type)) {
|
|
645
|
+
if (!["boolean", "object", "number", "string", "integer", "null"].includes(schema.type)) {
|
|
936
646
|
this.context.pluginManager.logger.emit("warning", `Schema type '${schema.type}' is not valid for schema ${parentName}.${name}`);
|
|
937
647
|
}
|
|
938
648
|
return [{ keyword: schema.type }, ...baseItems];
|
|
@@ -985,114 +695,6 @@ var SchemaGenerator = class _SchemaGenerator extends BaseGenerator {
|
|
|
985
695
|
}
|
|
986
696
|
};
|
|
987
697
|
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
const {
|
|
992
|
-
output = {
|
|
993
|
-
path: "schemas",
|
|
994
|
-
export: false,
|
|
995
|
-
exportType: "barrelNamed"
|
|
996
|
-
},
|
|
997
|
-
experimentalFilter: filter,
|
|
998
|
-
experimentalSort: sort,
|
|
999
|
-
validate = true,
|
|
1000
|
-
generators = [jsonGenerator],
|
|
1001
|
-
serverIndex = 0,
|
|
1002
|
-
contentType,
|
|
1003
|
-
oasClass
|
|
1004
|
-
} = options;
|
|
1005
|
-
const getOas = async ({ config, logger, formatOptions }) => {
|
|
1006
|
-
try {
|
|
1007
|
-
const oas = await parseFromConfig(config, formatOptions, oasClass);
|
|
1008
|
-
if (validate) {
|
|
1009
|
-
await oas.valdiate();
|
|
1010
|
-
}
|
|
1011
|
-
return oas;
|
|
1012
|
-
} catch (e) {
|
|
1013
|
-
const error = e;
|
|
1014
|
-
logger.emit("warning", error?.message);
|
|
1015
|
-
return parseFromConfig(config, {}, oasClass);
|
|
1016
|
-
}
|
|
1017
|
-
};
|
|
1018
|
-
return {
|
|
1019
|
-
name: pluginOasName,
|
|
1020
|
-
output,
|
|
1021
|
-
options,
|
|
1022
|
-
context() {
|
|
1023
|
-
const { config, logger } = this;
|
|
1024
|
-
return {
|
|
1025
|
-
getOas(formatOptions) {
|
|
1026
|
-
return getOas({ config, logger, formatOptions });
|
|
1027
|
-
},
|
|
1028
|
-
async getSchemas({ includes } = {}) {
|
|
1029
|
-
const oas = await this.getOas();
|
|
1030
|
-
return getSchemas({ oas, contentType, includes });
|
|
1031
|
-
},
|
|
1032
|
-
async getBaseURL() {
|
|
1033
|
-
const oasInstance = await this.getOas();
|
|
1034
|
-
return oasInstance.api.servers?.at(serverIndex)?.url;
|
|
1035
|
-
},
|
|
1036
|
-
contentType
|
|
1037
|
-
};
|
|
1038
|
-
},
|
|
1039
|
-
resolvePath(baseName, pathMode, options2) {
|
|
1040
|
-
const root = path.resolve(this.config.root, this.config.output.path);
|
|
1041
|
-
const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path));
|
|
1042
|
-
if (mode === "single") {
|
|
1043
|
-
return path.resolve(root, output.path);
|
|
1044
|
-
}
|
|
1045
|
-
return path.resolve(root, output.path, baseName);
|
|
1046
|
-
},
|
|
1047
|
-
async buildStart() {
|
|
1048
|
-
if (!output) {
|
|
1049
|
-
return;
|
|
1050
|
-
}
|
|
1051
|
-
const oas = await getOas({
|
|
1052
|
-
config: this.config,
|
|
1053
|
-
logger: this.logger,
|
|
1054
|
-
formatOptions: {
|
|
1055
|
-
filterSet: filter,
|
|
1056
|
-
sortSet: sort
|
|
1057
|
-
}
|
|
1058
|
-
});
|
|
1059
|
-
await oas.dereference();
|
|
1060
|
-
const schemaGenerator = new SchemaGenerator(
|
|
1061
|
-
{
|
|
1062
|
-
unknownType: "unknown",
|
|
1063
|
-
dateType: "date",
|
|
1064
|
-
transformers: {},
|
|
1065
|
-
...this.plugin.options
|
|
1066
|
-
},
|
|
1067
|
-
{
|
|
1068
|
-
oas,
|
|
1069
|
-
pluginManager: this.pluginManager,
|
|
1070
|
-
plugin: this.plugin,
|
|
1071
|
-
contentType,
|
|
1072
|
-
include: void 0,
|
|
1073
|
-
override: void 0,
|
|
1074
|
-
mode: "split",
|
|
1075
|
-
output: output.path
|
|
1076
|
-
}
|
|
1077
|
-
);
|
|
1078
|
-
const schemaFiles = await schemaGenerator.build(...generators);
|
|
1079
|
-
await this.addFile(...schemaFiles);
|
|
1080
|
-
const operationGenerator = new OperationGenerator(this.plugin.options, {
|
|
1081
|
-
oas,
|
|
1082
|
-
pluginManager: this.pluginManager,
|
|
1083
|
-
plugin: this.plugin,
|
|
1084
|
-
contentType,
|
|
1085
|
-
exclude: void 0,
|
|
1086
|
-
include: void 0,
|
|
1087
|
-
override: void 0,
|
|
1088
|
-
mode: "split"
|
|
1089
|
-
});
|
|
1090
|
-
const operationFiles = await operationGenerator.build(...generators);
|
|
1091
|
-
await this.addFile(...operationFiles);
|
|
1092
|
-
}
|
|
1093
|
-
};
|
|
1094
|
-
});
|
|
1095
|
-
|
|
1096
|
-
export { OperationGenerator, SchemaGenerator, isKeyword, pluginOas, pluginOasName, schemaKeywords };
|
|
1097
|
-
//# sourceMappingURL=chunk-7XBQZ7AX.js.map
|
|
1098
|
-
//# sourceMappingURL=chunk-7XBQZ7AX.js.map
|
|
698
|
+
export { SchemaGenerator, isKeyword, schemaKeywords };
|
|
699
|
+
//# sourceMappingURL=chunk-V4LP5BFJ.js.map
|
|
700
|
+
//# sourceMappingURL=chunk-V4LP5BFJ.js.map
|