@kubb/plugin-oas 3.10.9 → 3.10.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/dist/{OperationGenerator-BFmQs4BO.d.cts → OperationGenerator-CF1rxGSV.d.ts} +2 -273
  2. package/dist/{OperationGenerator-BFmQs4BO.d.ts → OperationGenerator-DxdJDBEc.d.cts} +2 -273
  3. package/dist/{Schema-Cmvkb9CW.d.ts → Schema-AjebpeVY.d.ts} +1 -1
  4. package/dist/{Schema-BunfYze0.d.cts → Schema-M6983FL1.d.cts} +1 -1
  5. package/dist/SchemaMapper-B21ZmWag.d.cts +275 -0
  6. package/dist/SchemaMapper-B21ZmWag.d.ts +275 -0
  7. package/dist/chunk-6S7YFY6F.js +33 -0
  8. package/dist/chunk-6S7YFY6F.js.map +1 -0
  9. package/dist/chunk-76E35IZ2.js +56 -0
  10. package/dist/chunk-76E35IZ2.js.map +1 -0
  11. package/dist/chunk-DTD4ZUDA.cjs +36 -0
  12. package/dist/chunk-DTD4ZUDA.cjs.map +1 -0
  13. package/dist/{chunk-645JWRLP.js → chunk-HLZZQQYR.js} +33 -91
  14. package/dist/chunk-HLZZQQYR.js.map +1 -0
  15. package/dist/chunk-RSHQODEK.cjs +35 -0
  16. package/dist/chunk-RSHQODEK.cjs.map +1 -0
  17. package/dist/{chunk-Y6YAXTK5.cjs → chunk-S3UPJP7I.cjs} +5 -5
  18. package/dist/chunk-S3UPJP7I.cjs.map +1 -0
  19. package/dist/{chunk-6HG3X5MB.js → chunk-S7ZYTJXL.js} +3 -3
  20. package/dist/chunk-S7ZYTJXL.js.map +1 -0
  21. package/dist/{chunk-CORFYCCW.cjs → chunk-WAB2O4DX.cjs} +116 -176
  22. package/dist/chunk-WAB2O4DX.cjs.map +1 -0
  23. package/dist/chunk-YWMMI3MO.cjs +59 -0
  24. package/dist/chunk-YWMMI3MO.cjs.map +1 -0
  25. package/dist/chunk-Z4S5R2AE.js +29 -0
  26. package/dist/chunk-Z4S5R2AE.js.map +1 -0
  27. package/dist/components.cjs +0 -1
  28. package/dist/components.d.cts +4 -3
  29. package/dist/components.d.ts +4 -3
  30. package/dist/components.js +0 -1
  31. package/dist/generators.cjs +3 -5
  32. package/dist/generators.d.cts +2 -1
  33. package/dist/generators.d.ts +2 -1
  34. package/dist/generators.js +2 -4
  35. package/dist/hooks.cjs +3 -2
  36. package/dist/hooks.cjs.map +1 -1
  37. package/dist/hooks.d.cts +3 -2
  38. package/dist/hooks.d.ts +3 -2
  39. package/dist/hooks.js +2 -1
  40. package/dist/hooks.js.map +1 -1
  41. package/dist/index.cjs +13 -12
  42. package/dist/index.cjs.map +1 -1
  43. package/dist/index.d.cts +3 -2
  44. package/dist/index.d.ts +3 -2
  45. package/dist/index.js +7 -6
  46. package/dist/index.js.map +1 -1
  47. package/dist/mocks.cjs +733 -0
  48. package/dist/mocks.cjs.map +1 -0
  49. package/dist/mocks.d.cts +15 -0
  50. package/dist/mocks.d.ts +15 -0
  51. package/dist/mocks.js +731 -0
  52. package/dist/mocks.js.map +1 -0
  53. package/dist/utils.cjs +61 -18
  54. package/dist/utils.cjs.map +1 -1
  55. package/dist/utils.d.cts +2 -1
  56. package/dist/utils.d.ts +2 -1
  57. package/dist/utils.js +51 -1
  58. package/dist/utils.js.map +1 -1
  59. package/package.json +16 -8
  60. package/src/SchemaGenerator.ts +32 -40
  61. package/src/generator.tsx +1 -1
  62. package/src/generators/jsonGenerator.ts +2 -1
  63. package/src/mocks/index.ts +1 -0
  64. package/src/mocks/schemas.ts +728 -0
  65. package/src/utils/parseFromConfig.ts +1 -1
  66. package/dist/chunk-645JWRLP.js.map +0 -1
  67. package/dist/chunk-6HG3X5MB.js.map +0 -1
  68. package/dist/chunk-CORFYCCW.cjs.map +0 -1
  69. package/dist/chunk-DEDONPUL.cjs +0 -114
  70. package/dist/chunk-DEDONPUL.cjs.map +0 -1
  71. package/dist/chunk-PADR76WZ.cjs +0 -4
  72. package/dist/chunk-PADR76WZ.cjs.map +0 -1
  73. package/dist/chunk-QPFZUPQA.js +0 -100
  74. package/dist/chunk-QPFZUPQA.js.map +0 -1
  75. package/dist/chunk-R47XMJ32.js +0 -3
  76. package/dist/chunk-R47XMJ32.js.map +0 -1
  77. package/dist/chunk-Y6YAXTK5.cjs.map +0 -1
@@ -1,100 +0,0 @@
1
- import transformers, { isValidVarName, camelCase } from '@kubb/core/transformers';
2
- import { URLPath } from '@kubb/core/utils';
3
- import { Oas, parse, isParameterObject } from '@kubb/oas';
4
- export { isOptional } from '@kubb/oas';
5
- import { resolve } from 'node:path';
6
- import yaml from '@stoplight/yaml';
7
- import { getDefaultBanner } from '@kubb/core';
8
- import { isFunction } from 'remeda';
9
-
10
- // src/utils/getComments.ts
11
- function getComments(operation) {
12
- return [
13
- operation.getDescription() && `@description ${operation.getDescription()}`,
14
- operation.getSummary() && `@summary ${operation.getSummary()}`,
15
- operation.path && `{@link ${new URLPath(operation.path).URL}}`,
16
- operation.isDeprecated() && "@deprecated"
17
- ].filter(Boolean).map((text) => transformers.trim(text));
18
- }
19
- function getASTParams(operationSchema, {
20
- typed = false,
21
- override
22
- } = {}) {
23
- if (!operationSchema || !operationSchema.schema.properties || !operationSchema.name) {
24
- return [];
25
- }
26
- return Object.entries(operationSchema.schema.properties).map(([name, schema]) => {
27
- const isParam = isParameterObject(schema);
28
- const data = {
29
- name,
30
- enabled: !!name,
31
- required: isParam ? schema.required : true,
32
- type: typed ? `${operationSchema.name}["${name}"]` : void 0
33
- };
34
- return override ? override(data) : data;
35
- });
36
- }
37
- function getPathParams(operationSchema, options = {}) {
38
- return getASTParams(operationSchema, options).reduce((acc, curr) => {
39
- if (curr.name && curr.enabled) {
40
- let name = isValidVarName(curr.name) ? curr.name : camelCase(curr.name);
41
- if (options.casing === "camelcase") {
42
- name = camelCase(name);
43
- }
44
- acc[name] = {
45
- default: curr.default,
46
- type: curr.type,
47
- optional: !curr.required
48
- };
49
- }
50
- return acc;
51
- }, {});
52
- }
53
- function parseFromConfig(config, oasClass = Oas) {
54
- if ("data" in config.input) {
55
- if (typeof config.input.data === "object") {
56
- const api2 = JSON.parse(JSON.stringify(config.input.data));
57
- return parse(api2, oasClass);
58
- }
59
- try {
60
- const api2 = yaml.parse(config.input.data);
61
- return parse(api2, oasClass);
62
- } catch (e) {
63
- }
64
- const api = JSON.parse(JSON.stringify(config.input.data));
65
- return parse(api, oasClass);
66
- }
67
- if (new URLPath(config.input.path).isURL) {
68
- return parse(config.input.path, oasClass);
69
- }
70
- return parse(resolve(config.root, config.input.path), oasClass);
71
- }
72
- function getBanner({ output, oas, config }) {
73
- let banner = "";
74
- if (config?.output?.defaultBanner !== false && config) {
75
- const { title, description, version } = oas.api?.info || {};
76
- banner = getDefaultBanner({ title, description, version, config });
77
- }
78
- if (!output.banner) {
79
- return banner;
80
- }
81
- if (isFunction(output.banner)) {
82
- return `${output.banner(oas)}
83
- ${banner}`;
84
- }
85
- return `${output.banner}
86
- ${banner}`;
87
- }
88
- function getFooter({ output, oas }) {
89
- if (!output.footer) {
90
- return void 0;
91
- }
92
- if (isFunction(output.footer)) {
93
- return output.footer(oas);
94
- }
95
- return output.footer;
96
- }
97
-
98
- export { getBanner, getComments, getFooter, getPathParams, parseFromConfig };
99
- //# sourceMappingURL=chunk-QPFZUPQA.js.map
100
- //# sourceMappingURL=chunk-QPFZUPQA.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/utils/getComments.ts","../src/utils/getParams.ts","../src/utils/parseFromConfig.ts","../src/utils/getBanner.ts","../src/utils/getFooter.ts"],"names":["api","URLPath","isFunction"],"mappings":";;;;;;;;;;AAKO,SAAS,YAAY,SAAgC,EAAA;AAC1D,EAAO,OAAA;AAAA,IACL,UAAU,cAAe,EAAA,IAAK,CAAgB,aAAA,EAAA,SAAA,CAAU,gBAAgB,CAAA,CAAA;AAAA,IACxE,UAAU,UAAW,EAAA,IAAK,CAAY,SAAA,EAAA,SAAA,CAAU,YAAY,CAAA,C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AA;AAChB","file":"chunk-QPFZUPQA.js","sourcesContent":["import transformers from '@kubb/core/transformers'\nimport { URLPath } from '@kubb/core/utils'\n\nimport type { Operation } from '@kubb/oas'\n\nexport function getComments(operation: Operation): string[] {\n return [\n operation.getDescription() && `@description ${operation.getDescription()}`,\n operation.getSummary() && `@summary ${operation.getSummary()}`,\n operation.path && `{@link ${new URLPath(operation.path).URL}}`,\n operation.isDeprecated() && '@deprecated',\n ]\n .filter(Boolean)\n .map((text) => transformers.trim(text))\n}\n","import { isParameterObject } from '@kubb/oas'\n\nimport { camelCase, isValidVarName } from '@kubb/core/transformers'\nimport type { FunctionParamsAST } from '@kubb/core/utils'\nimport type { OasTypes } from '@kubb/oas'\nimport type { Params } from '@kubb/react/types'\nimport type { OperationSchema } from '../types.ts'\n/**\n *\n * @deprecated\n * TODO move to operationManager hook\n */\nexport function getASTParams(\n operationSchema: OperationSchema | undefined,\n {\n typed = false,\n override,\n }: {\n typed?: boolean\n override?: (data: FunctionParamsAST) => FunctionParamsAST\n } = {},\n): FunctionParamsAST[] {\n if (!operationSchema || !operationSchema.schema.properties || !operationSchema.name) {\n return []\n }\n\n return Object.entries(operationSchema.schema.properties).map(([name, schema]: [string, OasTypes.SchemaObject]) => {\n const isParam = isParameterObject(schema)\n const data: FunctionParamsAST = {\n name,\n enabled: !!name,\n required: isParam ? schema.required : true,\n type: typed ? `${operationSchema.name}[\"${name}\"]` : undefined,\n }\n\n return override ? override(data) : data\n })\n}\n\nexport function getPathParams(\n operationSchema: OperationSchema | undefined,\n options: {\n typed?: boolean\n casing?: 'camelcase'\n override?: (data: FunctionParamsAST) => FunctionParamsAST\n } = {},\n) {\n return getASTParams(operationSchema, options).reduce((acc, curr) => {\n if (curr.name && curr.enabled) {\n let name = isValidVarName(curr.name) ? curr.name : camelCase(curr.name)\n\n if (options.casing === 'camelcase') {\n name = camelCase(name)\n }\n\n acc[name] = {\n default: curr.default,\n type: curr.type,\n optional: !curr.required,\n }\n }\n\n return acc\n }, {} as Params)\n}\n","import { resolve } from 'node:path'\n\nimport { URLPath } from '@kubb/core/utils'\n\nimport { parse } from '@kubb/oas'\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, 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, oasClass)\n }\n\n try {\n const api: string = yaml.parse(config.input.data as string) as string\n\n return parse(api, 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, oasClass)\n }\n\n if (new URLPath(config.input.path).isURL) {\n return parse(config.input.path, oasClass)\n }\n\n return parse(resolve(config.root, config.input.path), oasClass)\n}\n","import { getDefaultBanner, type Config, type Output } from '@kubb/core'\nimport type { Oas } from '@kubb/oas'\nimport { isFunction } from 'remeda'\n\ntype Props = {\n oas: Oas\n output: Output<Oas>\n config?: Config\n}\n\nexport function getBanner({ output, oas, config }: Props) {\n let banner = ''\n if (config?.output?.defaultBanner !== false && config) {\n const { title, description, version } = oas.api?.info || {}\n\n banner = getDefaultBanner({ title, description, version, config })\n }\n\n if (!output.banner) {\n return banner\n }\n\n if (isFunction(output.banner)) {\n return `${output.banner(oas)}\\n${banner}`\n }\n\n return `${output.banner}\\n${banner}`\n}\n","import type { Output } from '@kubb/core'\nimport type { Oas } from '@kubb/oas'\nimport { isFunction } from 'remeda'\n\ntype Props = {\n oas: Oas\n output: Output<Oas>\n}\n\nexport function getFooter({ output, oas }: Props) {\n if (!output.footer) {\n return undefined\n }\n\n if (isFunction(output.footer)) {\n return output.footer(oas)\n }\n\n return output.footer\n}\n"]}
@@ -1,3 +0,0 @@
1
-
2
- //# sourceMappingURL=chunk-R47XMJ32.js.map
3
- //# sourceMappingURL=chunk-R47XMJ32.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"chunk-R47XMJ32.js"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/generator.tsx","../src/generators/jsonGenerator.ts"],"names":["createRoot","App","jsx","Oas","camelCase","getBanner","getFooter"],"mappings":";;;;;;;;AA2CO,SAAS,gBAAuD,YAA+D,EAAA;AACpI,EAAO,OAAA,YAAA;AACT;AAgBO,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;AAAA;AAGV,MAAA,MAAM,EAAE,aAAe,EAAA,GAAA,EAAK,MAAQ,EAAA,IAAA,KAAS,QAAS,CAAA,OAAA;AACtD,MAAA,MAAM,OAAOA,gBAAW,CAAA;AAAA,QACtB,QAAQ,aAAc,CAAA;AAAA,OACvB,CAAA;AAED,MAAA,MAAM,SAAY,GAAA,YAAA,CAAa,UAAW,CAAA,IAAA,CAAK,IAAI,CAAA;AAEnD,MAAK,IAAA,CAAA,MAAA;AAAA,uCACFC,SAAI,EAAA,EAAA,aAAA,EAA8B,QAAgB,IACjD,EAAA,QAAA,kBAAAC,cAAA,CAACC,yBAAI,GAAU,EAAA,UAAA,EAAwB,SAAW,EAAA,QAAA,EAChD,yCAAC,SAAU,EAAA,EAAA,UAAA,EAAwB,UAAoB,kBAAwC,EAAA,OAAA,EAAkB,GACnH,CACF,EAAA;AAAA,OACF;AAEA,MAAA,OAAO,IAAK,CAAA,KAAA;AAAA,KACd;AAAA,IACA,MAAM,SAAU,CAAA,EAAE,QAAU,EAAA,SAAA,EAAW,SAAW,EAAA;AAChD,MAAI,IAAA,CAAC,aAAa,SAAW,EAAA;AAC3B,QAAA,OAAO,EAA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AAQ,CAAA,GAAA;AAAA,UACtB,MAAA,EAAQ,OAAO,OAAQ,CAAA,MAAA;AAAA,UACvB,QAAQ,aAAc,CAAA;AAAA,SACvB,CAAA;AAAA,QACD,MAAA,EAAQC,2BAAU,CAAA,EAAE,GAAK,EAAA,QAAA,CAAS,OAAQ,CAAA,GAAA,EAAK,MAAQ,EAAA,MAAA,CAAO,OAAQ,CAAA,MAAA,EAAQ;AAAA;AAChF,KACF;AAAA;AAEJ,CAAC","file":"chunk-Y6YAXTK5.cjs","sourcesContent":["import type { PluginFactoryOptions } from '@kubb/core'\nimport type { KubbFile } from '@kubb/core/fs'\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 options: TOptions['resolvedOptions']\n schema: {\n name: string\n tree: Array<Schema>\n value: SchemaObject\n }\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\n/****\n * Creates a generator that uses React component functions to generate files for OpenAPI operations and schemas.\n *\n * The returned generator exposes async methods for generating files from operations, a single operation, or a schema, using the corresponding React components if provided. If a component is not defined, the method returns an empty array.\n *\n * @returns A generator object with async methods for operations, operation, and schema file generation.\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} schemaObject={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 { getBanner, getFooter } from '@kubb/plugin-oas/utils'\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 banner: getBanner({\n oas: instance.context.oas,\n output: plugin.options.output,\n config: pluginManager.config,\n }),\n format: getFooter({ oas: instance.context.oas, output: plugin.options.output }),\n },\n ]\n },\n})\n"]}