@kubb/plugin-swr 3.0.0-alpha.0 → 3.0.0-alpha.2
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/components.d.cts +1 -1
- package/dist/components.d.ts +1 -1
- package/dist/{index-Ca8KyrCA.d.cts → index-B3C-JOIU.d.cts} +0 -5
- package/dist/{index-Ca8KyrCA.d.ts → index-B3C-JOIU.d.ts} +0 -5
- package/dist/index.cjs +3 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -11
- package/dist/index.d.ts +2 -11
- package/dist/index.js +2 -15
- package/dist/index.js.map +1 -1
- package/package.json +15 -15
- package/src/index.ts +0 -11
- package/src/plugin.ts +2 -9
- package/src/types.ts +0 -6
package/dist/components.d.cts
CHANGED
package/dist/components.d.ts
CHANGED
|
@@ -295,10 +295,5 @@ type ResolvedOptions = {
|
|
|
295
295
|
parser: Options['parser'];
|
|
296
296
|
};
|
|
297
297
|
type PluginSwr = PluginFactoryOptions<'plugin-swr', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
298
|
-
declare module '@kubb/core' {
|
|
299
|
-
interface _Register {
|
|
300
|
-
['@kubb/plugin-swr']: PluginSwr;
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
298
|
|
|
304
299
|
export { Mutation as M, type Options as O, type PluginSwr as P, Query as Q, QueryOptions as a };
|
|
@@ -295,10 +295,5 @@ type ResolvedOptions = {
|
|
|
295
295
|
parser: Options['parser'];
|
|
296
296
|
};
|
|
297
297
|
type PluginSwr = PluginFactoryOptions<'plugin-swr', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
298
|
-
declare module '@kubb/core' {
|
|
299
|
-
interface _Register {
|
|
300
|
-
['@kubb/plugin-swr']: PluginSwr;
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
298
|
|
|
304
299
|
export { Mutation as M, type Options as O, type PluginSwr as P, Query as Q, QueryOptions as a };
|
package/dist/index.cjs
CHANGED
|
@@ -118,14 +118,14 @@ var pluginSwr = _core.createPlugin.call(void 0, (options) => {
|
|
|
118
118
|
},
|
|
119
119
|
async buildStart() {
|
|
120
120
|
const [swaggerPlugin] = _core.PluginManager.getDependedPlugins(this.plugins, [_pluginoas.pluginOasName]);
|
|
121
|
-
const oas = await swaggerPlugin.
|
|
121
|
+
const oas = await swaggerPlugin.context.getOas();
|
|
122
122
|
const root = _path2.default.resolve(this.config.root, this.config.output.path);
|
|
123
123
|
const mode = _core.FileManager.getMode(_path2.default.resolve(root, output.path));
|
|
124
124
|
const operationGenerator = new OperationGenerator(this.plugin.options, {
|
|
125
125
|
oas,
|
|
126
126
|
pluginManager: this.pluginManager,
|
|
127
127
|
plugin: this.plugin,
|
|
128
|
-
contentType: swaggerPlugin.
|
|
128
|
+
contentType: swaggerPlugin.context.contentType,
|
|
129
129
|
exclude,
|
|
130
130
|
include,
|
|
131
131
|
override,
|
|
@@ -134,12 +134,6 @@ var pluginSwr = _core.createPlugin.call(void 0, (options) => {
|
|
|
134
134
|
const files = await operationGenerator.build();
|
|
135
135
|
await this.addFile(...files);
|
|
136
136
|
},
|
|
137
|
-
async writeFile(path2, source) {
|
|
138
|
-
if (!path2.endsWith(".ts") || !source) {
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
return this.fileManager.write(path2, source, { sanity: false });
|
|
142
|
-
},
|
|
143
137
|
async buildEnd() {
|
|
144
138
|
if (this.config.output.write === false) {
|
|
145
139
|
return;
|
|
@@ -167,14 +161,7 @@ var pluginSwr = _core.createPlugin.call(void 0, (options) => {
|
|
|
167
161
|
};
|
|
168
162
|
});
|
|
169
163
|
|
|
170
|
-
// src/index.ts
|
|
171
|
-
var definePluginDefault = pluginSwr;
|
|
172
|
-
var definePlugin = pluginSwr;
|
|
173
|
-
var src_default = definePluginDefault;
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
164
|
|
|
178
165
|
|
|
179
|
-
exports.
|
|
166
|
+
exports.pluginSwr = pluginSwr; exports.pluginSwrName = pluginSwrName;
|
|
180
167
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-swr/dist/index.cjs","../src/plugin.ts","../src/OperationGenerator.tsx","../src/index.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACNA,wEAAiB;AAEjB,kCAAyD;AACzD,uDAAsC;AACtC,yCAA+B;AAC/B,6CAA8B;AAC9B,gDAAqC;AACrC,2CAA6B;AAC7B,6CAA8B;ADO9B;AACA;AEhBA;AACA,yDAAoB;AACpB,oCAAgC;AAyBpB,qDAAA;AAhBL,IAAM,mBAAA,EAAN,MAAA,QAAiC,8BAA6D;AAAA,EACnG,MAAM,GAAA,CAAI,SAAA,EAAsB,OAAA,EAAwE;AACtG,IAAA,MAAM,EAAE,GAAA,EAAK,aAAA,EAAe,MAAA,EAAQ,KAAK,EAAA,EAAI,IAAA,CAAK,OAAA;AAElD,IAAA,MAAM,KAAA,EAAO,+BAAA;AAAW,MACtB,MAAA,EAAQ,aAAA,CAAc;AAAA,IACxB,CAAC,CAAA;AAED,IAAA,GAAA,CAAI,iBAAC,OAAA,mBAAQ,SAAA,6BAAW,QAAA,GAAS,iBAAC,OAAA,qBAAQ,SAAA,6BAAW,cAAA,EAAc;AACjE,MAAA,OAAO,CAAC,CAAA;AAAA,IACV;AAEA,IAAA,IAAA,CAAK,MAAA;AAAA,sBACH,6BAAA,UAAC,EAAA,EAAI,aAAA,EAA8B,MAAA,EAAQ,EAAE,GAAG,MAAA,EAAQ,QAAQ,CAAA,EAAG,IAAA,EACjE,QAAA,kBAAA,6BAAA,eAAC,EAAA,EAAI,GAAA,EAAU,UAAA,EAAY,CAAC,SAAS,CAAA,EAAG,SAAA,EAAW,IAAA,EACjD,QAAA,kBAAA,6BAAA,eAAC,CAAI,SAAA,EAAJ,EAAc,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QAAA;AACrB,UAAA;AACS,UAAA;AAClB,QAAA;AACH,MAAA;AAEqB,MAAA;AACW,QAAA;AAChC,MAAA;AAEU,MAAA;AACkC,QAAA;AAC5C,MAAA;AAEO,MAAA;AACT,IAAA;AACmB,IAAA;AACqD,MAAA;AAE3B,MAAA;AACC,MAAA;AACN,MAAA;AAEP,MAAA;AAC7B,QAAA;AACoB,QAAA;AACP,QAAA;AACkB,QAAA;AAC/B,QAAA;AACA,QAAA;AACA,QAAA;AACA,QAAA;AACD,MAAA;AAE4C,MAAA;AAClB,MAAA;AAC7B,IAAA;AAC8B,IAAA;AACU,MAAA;AACpC,QAAA;AACF,MAAA;AAE4C,MAAA;AAC9C,IAAA;AACiB,IAAA;AACyB,MAAA;AACtC,QAAA;AACF,MAAA;AAE4C,MAAA;AAEjB,MAAA;AACD,QAAA;AACT,UAAA;AACW,UAAA;AACX,UAAA;AACb,UAAA;AAC4B,UAAA;AAC5B,UAAA;AACA,UAAA;AACD,QAAA;AAE8B,QAAA;AACjC,MAAA;AAEkC,MAAA;AAChC,QAAA;AACA,QAAA;AACmC,QAAA;AACtB,QAAA;AACd,MAAA;AACH,IAAA;AACF,EAAA;AACD;AD8BkD;AACA;AGjKvB;AAIA;AAEb;AH+JoC;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/kubb/kubb/packages/plugin-swr/dist/index.cjs","sourcesContent":[null,"import path from 'node:path'\n\nimport { FileManager, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { renderTemplate } from '@kubb/core/utils'\nimport { pluginOasName } from '@kubb/plugin-oas'\nimport { getGroupedByTagFiles } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\n\nimport { OperationGenerator } from './OperationGenerator.tsx'\nimport { Mutation, Query, QueryOptions } from './components/index.ts'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'\nimport type { PluginSwr } from './types.ts'\n\nexport const pluginSwrName = 'plugin-swr' satisfies PluginSwr['name']\n\nexport const pluginSwr = createPlugin<PluginSwr>((options) => {\n const { output = { path: 'hooks' }, group, exclude = [], include, override = [], parser, transformers = {}, templates, dataReturnType = 'data' } = options\n const template = group?.output ? group.output : `${output.path}/{{tag}}SWRController`\n\n return {\n name: pluginSwrName,\n options: {\n extName: output.extName,\n templates: {\n mutation: Mutation.templates,\n query: Query.templates,\n queryOptions: QueryOptions.templates,\n ...templates,\n },\n client: {\n importPath: '@kubb/plugin-client/client',\n ...options.client,\n },\n dataReturnType,\n parser,\n },\n pre: [pluginOasName, pluginTsName, parser === 'zod' ? pluginZodName : undefined].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (options?.tag && group?.type === 'tag') {\n const tag = camelCase(options.tag)\n\n return path.resolve(root, renderTemplate(template, { tag }), baseName)\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n let resolvedName = camelCase(name)\n\n if (type === 'file' || type === 'function') {\n resolvedName = camelCase(name, {\n prefix: 'use',\n isFile: type === 'file',\n })\n }\n\n if (type === 'type') {\n resolvedName = pascalCase(name)\n }\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async buildStart() {\n const [swaggerPlugin]: [Plugin<SwaggerPluginOptions>] = PluginManager.getDependedPlugins<SwaggerPluginOptions>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.api.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType: swaggerPlugin.api.contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const files = await operationGenerator.build()\n await this.addFile(...files)\n },\n async writeFile(path, source) {\n if (!path.endsWith('.ts') || !source) {\n return\n }\n\n return this.fileManager.write(path, source, { sanity: false })\n },\n async buildEnd() {\n if (this.config.output.write === false) {\n return\n }\n\n const root = path.resolve(this.config.root, this.config.output.path)\n\n if (group?.type === 'tag') {\n const rootFiles = await getGroupedByTagFiles({\n logger: this.logger,\n files: this.fileManager.files,\n plugin: this.plugin,\n template,\n exportAs: group.exportAs || '{{tag}}SWRHooks',\n root,\n output,\n })\n\n await this.addFile(...rootFiles)\n }\n\n await this.fileManager.addIndexes({\n root,\n output,\n meta: { pluginKey: this.plugin.key },\n logger: this.logger,\n })\n },\n }\n})\n","import { OperationGenerator as Generator } from '@kubb/plugin-oas'\nimport { Oas } from '@kubb/plugin-oas/components'\nimport { App, createRoot } from '@kubb/react'\n\nimport { Mutation } from './components/Mutation.tsx'\nimport { Query } from './components/Query.tsx'\n\nimport type { Operation } from '@kubb/oas'\nimport type { OperationMethodResult } from '@kubb/plugin-oas'\nimport type { FileMeta, PluginSwr } from './types.ts'\n\nexport class OperationGenerator extends Generator<PluginSwr['resolvedOptions'], PluginSwr, FileMeta> {\n async get(operation: Operation, options: PluginSwr['resolvedOptions']): OperationMethodResult<FileMeta> {\n const { oas, pluginManager, plugin, mode } = this.context\n\n const root = createRoot({\n logger: pluginManager.logger,\n })\n\n if (!options.templates?.query || !options.templates?.queryOptions) {\n return []\n }\n\n root.render(\n <App pluginManager={pluginManager} plugin={{ ...plugin, options }} mode={mode}>\n <Oas oas={oas} operations={[operation]} generator={this}>\n <Oas.Operation operation={operation}>\n <Query.File\n templates={{\n query: options.templates.query,\n queryOptions: options.templates.queryOptions,\n }}\n />\n </Oas.Operation>\n </Oas>\n </App>,\n )\n\n return root.files\n }\n\n async post(operation: Operation, options: PluginSwr['resolvedOptions']): OperationMethodResult<FileMeta> {\n const { oas, pluginManager, plugin, mode } = this.context\n\n const root = createRoot({\n logger: pluginManager.logger,\n })\n\n if (!options.templates?.mutation) {\n return []\n }\n\n root.render(\n <App pluginManager={pluginManager} plugin={{ ...plugin, options }} mode={mode}>\n <Oas oas={oas} operations={[operation]} generator={this}>\n <Oas.Operation operation={operation}>\n <Mutation.File templates={options.templates.mutation} />\n </Oas.Operation>\n </Oas>\n </App>,\n )\n\n return root.files\n }\n\n async put(operation: Operation, options: PluginSwr['resolvedOptions']): OperationMethodResult<FileMeta> {\n return this.post(operation, options)\n }\n async patch(operation: Operation, options: PluginSwr['resolvedOptions']): OperationMethodResult<FileMeta> {\n return this.post(operation, options)\n }\n async delete(operation: Operation, options: PluginSwr['resolvedOptions']): OperationMethodResult<FileMeta> {\n return this.post(operation, options)\n }\n}\n","import { pluginSwr } from './plugin.ts'\n\nexport { pluginSwr, pluginSwrName } from './plugin.ts'\nexport type { PluginSwr } from './types.ts'\n\n/**\n * @deprecated Use `import { pluginSwr } from '@kubb/plugin-swr'` instead\n */\nconst definePluginDefault = pluginSwr\n/**\n * @deprecated Use `import { pluginSwr } from '@kubb/plugin-swr'` instead\n */\nexport const definePlugin = pluginSwr\n\nexport default definePluginDefault\n"]}
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-swr/dist/index.cjs","../src/plugin.ts","../src/OperationGenerator.tsx"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACNA,wEAAiB;AAEjB,kCAAyD;AACzD,uDAAsC;AACtC,yCAA+B;AAC/B,6CAA8B;AAC9B,gDAAqC;AACrC,2CAA6B;AAC7B,6CAA8B;ADO9B;AACA;AEhBA;AACA,yDAAoB;AACpB,oCAAgC;AAyBpB,qDAAA;AAhBL,IAAM,mBAAA,EAAN,MAAA,QAAiC,8BAA6D;AAAA,EACnG,MAAM,GAAA,CAAI,SAAA,EAAsB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ACjC,MAAA;AAEkC,MAAA;AAChC,QAAA;AACA,QAAA;AACmC,QAAA;AACtB,QAAA;AACd,MAAA;AACH,IAAA;AACF,EAAA;AACD;AD+BkD;AACA;AACA;AACA","file":"/home/runner/work/kubb/kubb/packages/plugin-swr/dist/index.cjs","sourcesContent":[null,"import path from 'node:path'\n\nimport { FileManager, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { renderTemplate } from '@kubb/core/utils'\nimport { pluginOasName } from '@kubb/plugin-oas'\nimport { getGroupedByTagFiles } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\n\nimport { OperationGenerator } from './OperationGenerator.tsx'\nimport { Mutation, Query, QueryOptions } from './components/index.ts'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'\nimport type { PluginSwr } from './types.ts'\n\nexport const pluginSwrName = 'plugin-swr' satisfies PluginSwr['name']\n\nexport const pluginSwr = createPlugin<PluginSwr>((options) => {\n const { output = { path: 'hooks' }, group, exclude = [], include, override = [], parser, transformers = {}, templates, dataReturnType = 'data' } = options\n const template = group?.output ? group.output : `${output.path}/{{tag}}SWRController`\n\n return {\n name: pluginSwrName,\n options: {\n extName: output.extName,\n templates: {\n mutation: Mutation.templates,\n query: Query.templates,\n queryOptions: QueryOptions.templates,\n ...templates,\n },\n client: {\n importPath: '@kubb/plugin-client/client',\n ...options.client,\n },\n dataReturnType,\n parser,\n },\n pre: [pluginOasName, pluginTsName, parser === 'zod' ? pluginZodName : undefined].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (options?.tag && group?.type === 'tag') {\n const tag = camelCase(options.tag)\n\n return path.resolve(root, renderTemplate(template, { tag }), baseName)\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n let resolvedName = camelCase(name)\n\n if (type === 'file' || type === 'function') {\n resolvedName = camelCase(name, {\n prefix: 'use',\n isFile: type === 'file',\n })\n }\n\n if (type === 'type') {\n resolvedName = pascalCase(name)\n }\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async buildStart() {\n const [swaggerPlugin]: [Plugin<SwaggerPluginOptions>] = PluginManager.getDependedPlugins<SwaggerPluginOptions>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.context.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType: swaggerPlugin.context.contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const files = await operationGenerator.build()\n await this.addFile(...files)\n },\n async buildEnd() {\n if (this.config.output.write === false) {\n return\n }\n\n const root = path.resolve(this.config.root, this.config.output.path)\n\n if (group?.type === 'tag') {\n const rootFiles = await getGroupedByTagFiles({\n logger: this.logger,\n files: this.fileManager.files,\n plugin: this.plugin,\n template,\n exportAs: group.exportAs || '{{tag}}SWRHooks',\n root,\n output,\n })\n\n await this.addFile(...rootFiles)\n }\n\n await this.fileManager.addIndexes({\n root,\n output,\n meta: { pluginKey: this.plugin.key },\n logger: this.logger,\n })\n },\n }\n})\n","import { OperationGenerator as Generator } from '@kubb/plugin-oas'\nimport { Oas } from '@kubb/plugin-oas/components'\nimport { App, createRoot } from '@kubb/react'\n\nimport { Mutation } from './components/Mutation.tsx'\nimport { Query } from './components/Query.tsx'\n\nimport type { Operation } from '@kubb/oas'\nimport type { OperationMethodResult } from '@kubb/plugin-oas'\nimport type { FileMeta, PluginSwr } from './types.ts'\n\nexport class OperationGenerator extends Generator<PluginSwr['resolvedOptions'], PluginSwr, FileMeta> {\n async get(operation: Operation, options: PluginSwr['resolvedOptions']): OperationMethodResult<FileMeta> {\n const { oas, pluginManager, plugin, mode } = this.context\n\n const root = createRoot({\n logger: pluginManager.logger,\n })\n\n if (!options.templates?.query || !options.templates?.queryOptions) {\n return []\n }\n\n root.render(\n <App pluginManager={pluginManager} plugin={{ ...plugin, options }} mode={mode}>\n <Oas oas={oas} operations={[operation]} generator={this}>\n <Oas.Operation operation={operation}>\n <Query.File\n templates={{\n query: options.templates.query,\n queryOptions: options.templates.queryOptions,\n }}\n />\n </Oas.Operation>\n </Oas>\n </App>,\n )\n\n return root.files\n }\n\n async post(operation: Operation, options: PluginSwr['resolvedOptions']): OperationMethodResult<FileMeta> {\n const { oas, pluginManager, plugin, mode } = this.context\n\n const root = createRoot({\n logger: pluginManager.logger,\n })\n\n if (!options.templates?.mutation) {\n return []\n }\n\n root.render(\n <App pluginManager={pluginManager} plugin={{ ...plugin, options }} mode={mode}>\n <Oas oas={oas} operations={[operation]} generator={this}>\n <Oas.Operation operation={operation}>\n <Mutation.File templates={options.templates.mutation} />\n </Oas.Operation>\n </Oas>\n </App>,\n )\n\n return root.files\n }\n\n async put(operation: Operation, options: PluginSwr['resolvedOptions']): OperationMethodResult<FileMeta> {\n return this.post(operation, options)\n }\n async patch(operation: Operation, options: PluginSwr['resolvedOptions']): OperationMethodResult<FileMeta> {\n return this.post(operation, options)\n }\n async delete(operation: Operation, options: PluginSwr['resolvedOptions']): OperationMethodResult<FileMeta> {\n return this.post(operation, options)\n }\n}\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _kubb_core from '@kubb/core';
|
|
2
|
-
import { O as Options, P as PluginSwr } from './index-
|
|
2
|
+
import { O as Options, P as PluginSwr } from './index-B3C-JOIU.cjs';
|
|
3
3
|
import '@kubb/core/utils';
|
|
4
4
|
import '@kubb/oas';
|
|
5
5
|
import 'react';
|
|
@@ -9,13 +9,4 @@ import '@kubb/plugin-oas';
|
|
|
9
9
|
declare const pluginSwrName = "plugin-swr";
|
|
10
10
|
declare const pluginSwr: (options?: Options | undefined) => _kubb_core.UserPluginWithLifeCycle<PluginSwr>;
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
* @deprecated Use `import { pluginSwr } from '@kubb/plugin-swr'` instead
|
|
14
|
-
*/
|
|
15
|
-
declare const definePluginDefault: (options?: Options | undefined) => _kubb_core.UserPluginWithLifeCycle<PluginSwr>;
|
|
16
|
-
/**
|
|
17
|
-
* @deprecated Use `import { pluginSwr } from '@kubb/plugin-swr'` instead
|
|
18
|
-
*/
|
|
19
|
-
declare const definePlugin: (options?: Options | undefined) => _kubb_core.UserPluginWithLifeCycle<PluginSwr>;
|
|
20
|
-
|
|
21
|
-
export { PluginSwr, definePluginDefault as default, definePlugin, pluginSwr, pluginSwrName };
|
|
12
|
+
export { PluginSwr, pluginSwr, pluginSwrName };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _kubb_core from '@kubb/core';
|
|
2
|
-
import { O as Options, P as PluginSwr } from './index-
|
|
2
|
+
import { O as Options, P as PluginSwr } from './index-B3C-JOIU.js';
|
|
3
3
|
import '@kubb/core/utils';
|
|
4
4
|
import '@kubb/oas';
|
|
5
5
|
import 'react';
|
|
@@ -9,13 +9,4 @@ import '@kubb/plugin-oas';
|
|
|
9
9
|
declare const pluginSwrName = "plugin-swr";
|
|
10
10
|
declare const pluginSwr: (options?: Options | undefined) => _kubb_core.UserPluginWithLifeCycle<PluginSwr>;
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
* @deprecated Use `import { pluginSwr } from '@kubb/plugin-swr'` instead
|
|
14
|
-
*/
|
|
15
|
-
declare const definePluginDefault: (options?: Options | undefined) => _kubb_core.UserPluginWithLifeCycle<PluginSwr>;
|
|
16
|
-
/**
|
|
17
|
-
* @deprecated Use `import { pluginSwr } from '@kubb/plugin-swr'` instead
|
|
18
|
-
*/
|
|
19
|
-
declare const definePlugin: (options?: Options | undefined) => _kubb_core.UserPluginWithLifeCycle<PluginSwr>;
|
|
20
|
-
|
|
21
|
-
export { PluginSwr, definePluginDefault as default, definePlugin, pluginSwr, pluginSwrName };
|
|
12
|
+
export { PluginSwr, pluginSwr, pluginSwrName };
|
package/dist/index.js
CHANGED
|
@@ -118,14 +118,14 @@ var pluginSwr = createPlugin((options) => {
|
|
|
118
118
|
},
|
|
119
119
|
async buildStart() {
|
|
120
120
|
const [swaggerPlugin] = PluginManager.getDependedPlugins(this.plugins, [pluginOasName]);
|
|
121
|
-
const oas = await swaggerPlugin.
|
|
121
|
+
const oas = await swaggerPlugin.context.getOas();
|
|
122
122
|
const root = path.resolve(this.config.root, this.config.output.path);
|
|
123
123
|
const mode = FileManager.getMode(path.resolve(root, output.path));
|
|
124
124
|
const operationGenerator = new OperationGenerator(this.plugin.options, {
|
|
125
125
|
oas,
|
|
126
126
|
pluginManager: this.pluginManager,
|
|
127
127
|
plugin: this.plugin,
|
|
128
|
-
contentType: swaggerPlugin.
|
|
128
|
+
contentType: swaggerPlugin.context.contentType,
|
|
129
129
|
exclude,
|
|
130
130
|
include,
|
|
131
131
|
override,
|
|
@@ -134,12 +134,6 @@ var pluginSwr = createPlugin((options) => {
|
|
|
134
134
|
const files = await operationGenerator.build();
|
|
135
135
|
await this.addFile(...files);
|
|
136
136
|
},
|
|
137
|
-
async writeFile(path2, source) {
|
|
138
|
-
if (!path2.endsWith(".ts") || !source) {
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
return this.fileManager.write(path2, source, { sanity: false });
|
|
142
|
-
},
|
|
143
137
|
async buildEnd() {
|
|
144
138
|
if (this.config.output.write === false) {
|
|
145
139
|
return;
|
|
@@ -166,14 +160,7 @@ var pluginSwr = createPlugin((options) => {
|
|
|
166
160
|
}
|
|
167
161
|
};
|
|
168
162
|
});
|
|
169
|
-
|
|
170
|
-
// src/index.ts
|
|
171
|
-
var definePluginDefault = pluginSwr;
|
|
172
|
-
var definePlugin = pluginSwr;
|
|
173
|
-
var src_default = definePluginDefault;
|
|
174
163
|
export {
|
|
175
|
-
src_default as default,
|
|
176
|
-
definePlugin,
|
|
177
164
|
pluginSwr,
|
|
178
165
|
pluginSwrName
|
|
179
166
|
};
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/plugin.ts","../src/OperationGenerator.tsx","../src/index.ts"],"sourcesContent":["import path from 'node:path'\n\nimport { FileManager, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { renderTemplate } from '@kubb/core/utils'\nimport { pluginOasName } from '@kubb/plugin-oas'\nimport { getGroupedByTagFiles } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\n\nimport { OperationGenerator } from './OperationGenerator.tsx'\nimport { Mutation, Query, QueryOptions } from './components/index.ts'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'\nimport type { PluginSwr } from './types.ts'\n\nexport const pluginSwrName = 'plugin-swr' satisfies PluginSwr['name']\n\nexport const pluginSwr = createPlugin<PluginSwr>((options) => {\n const { output = { path: 'hooks' }, group, exclude = [], include, override = [], parser, transformers = {}, templates, dataReturnType = 'data' } = options\n const template = group?.output ? group.output : `${output.path}/{{tag}}SWRController`\n\n return {\n name: pluginSwrName,\n options: {\n extName: output.extName,\n templates: {\n mutation: Mutation.templates,\n query: Query.templates,\n queryOptions: QueryOptions.templates,\n ...templates,\n },\n client: {\n importPath: '@kubb/plugin-client/client',\n ...options.client,\n },\n dataReturnType,\n parser,\n },\n pre: [pluginOasName, pluginTsName, parser === 'zod' ? pluginZodName : undefined].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (options?.tag && group?.type === 'tag') {\n const tag = camelCase(options.tag)\n\n return path.resolve(root, renderTemplate(template, { tag }), baseName)\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n let resolvedName = camelCase(name)\n\n if (type === 'file' || type === 'function') {\n resolvedName = camelCase(name, {\n prefix: 'use',\n isFile: type === 'file',\n })\n }\n\n if (type === 'type') {\n resolvedName = pascalCase(name)\n }\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async buildStart() {\n const [swaggerPlugin]: [Plugin<SwaggerPluginOptions>] = PluginManager.getDependedPlugins<SwaggerPluginOptions>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.api.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType: swaggerPlugin.api.contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const files = await operationGenerator.build()\n await this.addFile(...files)\n },\n async writeFile(path, source) {\n if (!path.endsWith('.ts') || !source) {\n return\n }\n\n return this.fileManager.write(path, source, { sanity: false })\n },\n async buildEnd() {\n if (this.config.output.write === false) {\n return\n }\n\n const root = path.resolve(this.config.root, this.config.output.path)\n\n if (group?.type === 'tag') {\n const rootFiles = await getGroupedByTagFiles({\n logger: this.logger,\n files: this.fileManager.files,\n plugin: this.plugin,\n template,\n exportAs: group.exportAs || '{{tag}}SWRHooks',\n root,\n output,\n })\n\n await this.addFile(...rootFiles)\n }\n\n await this.fileManager.addIndexes({\n root,\n output,\n meta: { pluginKey: this.plugin.key },\n logger: this.logger,\n })\n },\n }\n})\n","import { OperationGenerator as Generator } from '@kubb/plugin-oas'\nimport { Oas } from '@kubb/plugin-oas/components'\nimport { App, createRoot } from '@kubb/react'\n\nimport { Mutation } from './components/Mutation.tsx'\nimport { Query } from './components/Query.tsx'\n\nimport type { Operation } from '@kubb/oas'\nimport type { OperationMethodResult } from '@kubb/plugin-oas'\nimport type { FileMeta, PluginSwr } from './types.ts'\n\nexport class OperationGenerator extends Generator<PluginSwr['resolvedOptions'], PluginSwr, FileMeta> {\n async get(operation: Operation, options: PluginSwr['resolvedOptions']): OperationMethodResult<FileMeta> {\n const { oas, pluginManager, plugin, mode } = this.context\n\n const root = createRoot({\n logger: pluginManager.logger,\n })\n\n if (!options.templates?.query || !options.templates?.queryOptions) {\n return []\n }\n\n root.render(\n <App pluginManager={pluginManager} plugin={{ ...plugin, options }} mode={mode}>\n <Oas oas={oas} operations={[operation]} generator={this}>\n <Oas.Operation operation={operation}>\n <Query.File\n templates={{\n query: options.templates.query,\n queryOptions: options.templates.queryOptions,\n }}\n />\n </Oas.Operation>\n </Oas>\n </App>,\n )\n\n return root.files\n }\n\n async post(operation: Operation, options: PluginSwr['resolvedOptions']): OperationMethodResult<FileMeta> {\n const { oas, pluginManager, plugin, mode } = this.context\n\n const root = createRoot({\n logger: pluginManager.logger,\n })\n\n if (!options.templates?.mutation) {\n return []\n }\n\n root.render(\n <App pluginManager={pluginManager} plugin={{ ...plugin, options }} mode={mode}>\n <Oas oas={oas} operations={[operation]} generator={this}>\n <Oas.Operation operation={operation}>\n <Mutation.File templates={options.templates.mutation} />\n </Oas.Operation>\n </Oas>\n </App>,\n )\n\n return root.files\n }\n\n async put(operation: Operation, options: PluginSwr['resolvedOptions']): OperationMethodResult<FileMeta> {\n return this.post(operation, options)\n }\n async patch(operation: Operation, options: PluginSwr['resolvedOptions']): OperationMethodResult<FileMeta> {\n return this.post(operation, options)\n }\n async delete(operation: Operation, options: PluginSwr['resolvedOptions']): OperationMethodResult<FileMeta> {\n return this.post(operation, options)\n }\n}\n","import { pluginSwr } from './plugin.ts'\n\nexport { pluginSwr, pluginSwrName } from './plugin.ts'\nexport type { PluginSwr } from './types.ts'\n\n/**\n * @deprecated Use `import { pluginSwr } from '@kubb/plugin-swr'` instead\n */\nconst definePluginDefault = pluginSwr\n/**\n * @deprecated Use `import { pluginSwr } from '@kubb/plugin-swr'` instead\n */\nexport const definePlugin = pluginSwr\n\nexport default definePluginDefault\n"],"mappings":";;;;;;;AAAA,OAAO,UAAU;AAEjB,SAAS,aAAa,eAAe,oBAAoB;AACzD,SAAS,WAAW,kBAAkB;AACtC,SAAS,sBAAsB;AAC/B,SAAS,qBAAqB;AAC9B,SAAS,4BAA4B;AACrC,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB;;;ACR9B,SAAS,sBAAsB,iBAAiB;AAChD,SAAS,WAAW;AACpB,SAAS,KAAK,kBAAkB;AAyBpB;AAhBL,IAAM,qBAAN,cAAiC,UAA6D;AAAA,EACnG,MAAM,IAAI,WAAsB,SAAwE;AACtG,UAAM,EAAE,KAAK,eAAe,QAAQ,KAAK,IAAI,KAAK;AAElD,UAAM,OAAO,WAAW;AAAA,MACtB,QAAQ,cAAc;AAAA,IACxB,CAAC;AAED,QAAI,CAAC,QAAQ,WAAW,SAAS,CAAC,QAAQ,WAAW,cAAc;AACjE,aAAO,CAAC;AAAA,IACV;AAEA,SAAK;AAAA,MACH,oBAAC,OAAI,eAA8B,QAAQ,EAAE,GAAG,QAAQ,QAAQ,GAAG,MACjE,8BAAC,OAAI,KAAU,YAAY,CAAC,SAAS,GAAG,WAAW,MACjD,8BAAC,IAAI,WAAJ,EAAc,WACb;AAAA,QAAC,MAAM;AAAA,QAAN;AAAA,UACC,WAAW;AAAA,YACT,OAAO,QAAQ,UAAU;AAAA,YACzB,cAAc,QAAQ,UAAU;AAAA,UAClC;AAAA;AAAA,MACF,GACF,GACF,GACF;AAAA,IACF;AAEA,WAAO,KAAK;AAAA,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B,IAAO,cAAQ;","names":["options","path"]}
|
|
1
|
+
{"version":3,"sources":["../src/plugin.ts","../src/OperationGenerator.tsx"],"sourcesContent":["import path from 'node:path'\n\nimport { FileManager, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { renderTemplate } from '@kubb/core/utils'\nimport { pluginOasName } from '@kubb/plugin-oas'\nimport { getGroupedByTagFiles } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\n\nimport { OperationGenerator } from './OperationGenerator.tsx'\nimport { Mutation, Query, QueryOptions } from './components/index.ts'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'\nimport type { PluginSwr } from './types.ts'\n\nexport const pluginSwrName = 'plugin-swr' satisfies PluginSwr['name']\n\nexport const pluginSwr = createPlugin<PluginSwr>((options) => {\n const { output = { path: 'hooks' }, group, exclude = [], include, override = [], parser, transformers = {}, templates, dataReturnType = 'data' } = options\n const template = group?.output ? group.output : `${output.path}/{{tag}}SWRController`\n\n return {\n name: pluginSwrName,\n options: {\n extName: output.extName,\n templates: {\n mutation: Mutation.templates,\n query: Query.templates,\n queryOptions: QueryOptions.templates,\n ...templates,\n },\n client: {\n importPath: '@kubb/plugin-client/client',\n ...options.client,\n },\n dataReturnType,\n parser,\n },\n pre: [pluginOasName, pluginTsName, parser === 'zod' ? pluginZodName : undefined].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (options?.tag && group?.type === 'tag') {\n const tag = camelCase(options.tag)\n\n return path.resolve(root, renderTemplate(template, { tag }), baseName)\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n let resolvedName = camelCase(name)\n\n if (type === 'file' || type === 'function') {\n resolvedName = camelCase(name, {\n prefix: 'use',\n isFile: type === 'file',\n })\n }\n\n if (type === 'type') {\n resolvedName = pascalCase(name)\n }\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async buildStart() {\n const [swaggerPlugin]: [Plugin<SwaggerPluginOptions>] = PluginManager.getDependedPlugins<SwaggerPluginOptions>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.context.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType: swaggerPlugin.context.contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const files = await operationGenerator.build()\n await this.addFile(...files)\n },\n async buildEnd() {\n if (this.config.output.write === false) {\n return\n }\n\n const root = path.resolve(this.config.root, this.config.output.path)\n\n if (group?.type === 'tag') {\n const rootFiles = await getGroupedByTagFiles({\n logger: this.logger,\n files: this.fileManager.files,\n plugin: this.plugin,\n template,\n exportAs: group.exportAs || '{{tag}}SWRHooks',\n root,\n output,\n })\n\n await this.addFile(...rootFiles)\n }\n\n await this.fileManager.addIndexes({\n root,\n output,\n meta: { pluginKey: this.plugin.key },\n logger: this.logger,\n })\n },\n }\n})\n","import { OperationGenerator as Generator } from '@kubb/plugin-oas'\nimport { Oas } from '@kubb/plugin-oas/components'\nimport { App, createRoot } from '@kubb/react'\n\nimport { Mutation } from './components/Mutation.tsx'\nimport { Query } from './components/Query.tsx'\n\nimport type { Operation } from '@kubb/oas'\nimport type { OperationMethodResult } from '@kubb/plugin-oas'\nimport type { FileMeta, PluginSwr } from './types.ts'\n\nexport class OperationGenerator extends Generator<PluginSwr['resolvedOptions'], PluginSwr, FileMeta> {\n async get(operation: Operation, options: PluginSwr['resolvedOptions']): OperationMethodResult<FileMeta> {\n const { oas, pluginManager, plugin, mode } = this.context\n\n const root = createRoot({\n logger: pluginManager.logger,\n })\n\n if (!options.templates?.query || !options.templates?.queryOptions) {\n return []\n }\n\n root.render(\n <App pluginManager={pluginManager} plugin={{ ...plugin, options }} mode={mode}>\n <Oas oas={oas} operations={[operation]} generator={this}>\n <Oas.Operation operation={operation}>\n <Query.File\n templates={{\n query: options.templates.query,\n queryOptions: options.templates.queryOptions,\n }}\n />\n </Oas.Operation>\n </Oas>\n </App>,\n )\n\n return root.files\n }\n\n async post(operation: Operation, options: PluginSwr['resolvedOptions']): OperationMethodResult<FileMeta> {\n const { oas, pluginManager, plugin, mode } = this.context\n\n const root = createRoot({\n logger: pluginManager.logger,\n })\n\n if (!options.templates?.mutation) {\n return []\n }\n\n root.render(\n <App pluginManager={pluginManager} plugin={{ ...plugin, options }} mode={mode}>\n <Oas oas={oas} operations={[operation]} generator={this}>\n <Oas.Operation operation={operation}>\n <Mutation.File templates={options.templates.mutation} />\n </Oas.Operation>\n </Oas>\n </App>,\n )\n\n return root.files\n }\n\n async put(operation: Operation, options: PluginSwr['resolvedOptions']): OperationMethodResult<FileMeta> {\n return this.post(operation, options)\n }\n async patch(operation: Operation, options: PluginSwr['resolvedOptions']): OperationMethodResult<FileMeta> {\n return this.post(operation, options)\n }\n async delete(operation: Operation, options: PluginSwr['resolvedOptions']): OperationMethodResult<FileMeta> {\n return this.post(operation, options)\n }\n}\n"],"mappings":";;;;;;;AAAA,OAAO,UAAU;AAEjB,SAAS,aAAa,eAAe,oBAAoB;AACzD,SAAS,WAAW,kBAAkB;AACtC,SAAS,sBAAsB;AAC/B,SAAS,qBAAqB;AAC9B,SAAS,4BAA4B;AACrC,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB;;;ACR9B,SAAS,sBAAsB,iBAAiB;AAChD,SAAS,WAAW;AACpB,SAAS,KAAK,kBAAkB;AAyBpB;AAhBL,IAAM,qB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M,qBAAqB;AAAA,UAC3C,QAAQ,KAAK;AAAA,UACb,OAAO,KAAK,YAAY;AAAA,UACxB,QAAQ,KAAK;AAAA,UACb;AAAA,UACA,UAAU,MAAM,YAAY;AAAA,UAC5B;AAAA,UACA;AAAA,QACF,CAAC;AAED,cAAM,KAAK,QAAQ,GAAG,SAAS;AAAA,MACjC;AAEA,YAAM,KAAK,YAAY,WAAW;AAAA,QAChC;AAAA,QACA;AAAA,QACA,MAAM,EAAE,WAAW,KAAK,OAAO,IAAI;AAAA,QACnC,QAAQ,KAAK;AAAA,MACf,CAAC;AAAA,IACH;AAAA,EACF;AACF,CAAC;","names":["options"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-swr",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.2",
|
|
4
4
|
"description": "Generator plugin-swr",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -55,27 +55,27 @@
|
|
|
55
55
|
"!/**/__tests__/**"
|
|
56
56
|
],
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@kubb/core": "3.0.0-alpha.
|
|
59
|
-
"@kubb/fs": "3.0.0-alpha.
|
|
60
|
-
"@kubb/oas": "3.0.0-alpha.
|
|
61
|
-
"@kubb/parser-ts": "3.0.0-alpha.
|
|
62
|
-
"@kubb/plugin-client": "3.0.0-alpha.
|
|
63
|
-
"@kubb/plugin-oas": "3.0.0-alpha.
|
|
64
|
-
"@kubb/plugin-ts": "3.0.0-alpha.
|
|
65
|
-
"@kubb/
|
|
66
|
-
"@kubb/
|
|
58
|
+
"@kubb/core": "3.0.0-alpha.2",
|
|
59
|
+
"@kubb/fs": "3.0.0-alpha.2",
|
|
60
|
+
"@kubb/oas": "3.0.0-alpha.2",
|
|
61
|
+
"@kubb/parser-ts": "3.0.0-alpha.2",
|
|
62
|
+
"@kubb/plugin-client": "3.0.0-alpha.2",
|
|
63
|
+
"@kubb/plugin-oas": "3.0.0-alpha.2",
|
|
64
|
+
"@kubb/plugin-ts": "3.0.0-alpha.2",
|
|
65
|
+
"@kubb/plugin-zod": "3.0.0-alpha.2",
|
|
66
|
+
"@kubb/react": "3.0.0-alpha.2"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
|
-
"@types/react": "^18.3.
|
|
69
|
+
"@types/react": "^18.3.4",
|
|
70
70
|
"react": "^18.3.1",
|
|
71
71
|
"tsup": "^8.2.4",
|
|
72
72
|
"typescript": "^5.5.4",
|
|
73
|
-
"@kubb/config-biome": "3.0.0-alpha.
|
|
74
|
-
"@kubb/config-ts": "3.0.0-alpha.
|
|
75
|
-
"@kubb/config-tsup": "3.0.0-alpha.
|
|
73
|
+
"@kubb/config-biome": "3.0.0-alpha.2",
|
|
74
|
+
"@kubb/config-ts": "3.0.0-alpha.2",
|
|
75
|
+
"@kubb/config-tsup": "3.0.0-alpha.2"
|
|
76
76
|
},
|
|
77
77
|
"peerDependencies": {
|
|
78
|
-
"@kubb/react": "3.0.0-alpha.
|
|
78
|
+
"@kubb/react": "3.0.0-alpha.2"
|
|
79
79
|
},
|
|
80
80
|
"engines": {
|
|
81
81
|
"node": ">=20"
|
package/src/index.ts
CHANGED
|
@@ -2,14 +2,3 @@ import { pluginSwr } from './plugin.ts'
|
|
|
2
2
|
|
|
3
3
|
export { pluginSwr, pluginSwrName } from './plugin.ts'
|
|
4
4
|
export type { PluginSwr } from './types.ts'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @deprecated Use `import { pluginSwr } from '@kubb/plugin-swr'` instead
|
|
8
|
-
*/
|
|
9
|
-
const definePluginDefault = pluginSwr
|
|
10
|
-
/**
|
|
11
|
-
* @deprecated Use `import { pluginSwr } from '@kubb/plugin-swr'` instead
|
|
12
|
-
*/
|
|
13
|
-
export const definePlugin = pluginSwr
|
|
14
|
-
|
|
15
|
-
export default definePluginDefault
|
package/src/plugin.ts
CHANGED
|
@@ -82,7 +82,7 @@ export const pluginSwr = createPlugin<PluginSwr>((options) => {
|
|
|
82
82
|
async buildStart() {
|
|
83
83
|
const [swaggerPlugin]: [Plugin<SwaggerPluginOptions>] = PluginManager.getDependedPlugins<SwaggerPluginOptions>(this.plugins, [pluginOasName])
|
|
84
84
|
|
|
85
|
-
const oas = await swaggerPlugin.
|
|
85
|
+
const oas = await swaggerPlugin.context.getOas()
|
|
86
86
|
const root = path.resolve(this.config.root, this.config.output.path)
|
|
87
87
|
const mode = FileManager.getMode(path.resolve(root, output.path))
|
|
88
88
|
|
|
@@ -90,7 +90,7 @@ export const pluginSwr = createPlugin<PluginSwr>((options) => {
|
|
|
90
90
|
oas,
|
|
91
91
|
pluginManager: this.pluginManager,
|
|
92
92
|
plugin: this.plugin,
|
|
93
|
-
contentType: swaggerPlugin.
|
|
93
|
+
contentType: swaggerPlugin.context.contentType,
|
|
94
94
|
exclude,
|
|
95
95
|
include,
|
|
96
96
|
override,
|
|
@@ -100,13 +100,6 @@ export const pluginSwr = createPlugin<PluginSwr>((options) => {
|
|
|
100
100
|
const files = await operationGenerator.build()
|
|
101
101
|
await this.addFile(...files)
|
|
102
102
|
},
|
|
103
|
-
async writeFile(path, source) {
|
|
104
|
-
if (!path.endsWith('.ts') || !source) {
|
|
105
|
-
return
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
return this.fileManager.write(path, source, { sanity: false })
|
|
109
|
-
},
|
|
110
103
|
async buildEnd() {
|
|
111
104
|
if (this.config.output.write === false) {
|
|
112
105
|
return
|
package/src/types.ts
CHANGED
|
@@ -117,9 +117,3 @@ export type FileMeta = {
|
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
export type PluginSwr = PluginFactoryOptions<'plugin-swr', Options, ResolvedOptions, never, ResolvePathOptions>
|
|
120
|
-
|
|
121
|
-
declare module '@kubb/core' {
|
|
122
|
-
export interface _Register {
|
|
123
|
-
['@kubb/plugin-swr']: PluginSwr
|
|
124
|
-
}
|
|
125
|
-
}
|