@kubb/plugin-client 5.5.4 → 5.5.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-client",
3
- "version": "5.5.4",
3
+ "version": "5.5.6",
4
4
  "description": "Generate typed API operations against your own client module.",
5
5
  "keywords": [
6
6
  "api-client",
@@ -44,17 +44,17 @@
44
44
  "registry": "https://registry.npmjs.org/"
45
45
  },
46
46
  "dependencies": {
47
- "@kubb/plugin-ts": "^5.0.4",
48
- "@kubb/plugin-zod": "^5.4.3"
47
+ "@kubb/plugin-ts": "^5.0.7",
48
+ "@kubb/plugin-zod": "^5.4.5"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@internals/client": "0.0.0",
52
52
  "@internals/shared": "0.0.0",
53
- "kubb": "^5.5.2",
53
+ "kubb": "^5.8.0",
54
54
  "typescript": "^6.0.3"
55
55
  },
56
56
  "peerDependencies": {
57
- "kubb": "^5.5.2"
57
+ "kubb": "^5.8.0"
58
58
  },
59
59
  "engines": {
60
60
  "node": ">=22"
@@ -62,10 +62,7 @@
62
62
  "scripts": {
63
63
  "build": "tsdown",
64
64
  "clean": "node -e \"require('node:fs').rmSync('./dist', {recursive:true,force:true})\"",
65
- "lint": "oxlint .",
66
- "lint:fix": "oxlint --fix .",
67
65
  "start": "tsdown --watch",
68
- "test": "vitest --passWithNoTests",
69
- "typecheck": "tsc -p ./tsconfig.json --noEmit --emitDeclarationOnly false"
66
+ "typecheck": "tsc"
70
67
  }
71
68
  }
package/src/plugin.ts CHANGED
@@ -1,10 +1,11 @@
1
1
  import { createGroupConfig } from '@internals/shared'
2
- import { definePlugin, Resolver } from 'kubb/kit'
2
+ import { addGenerator, definePlugin, Resolver, setMacros, setResolver } from 'kubb/kit'
3
+ import { version } from '../package.json'
3
4
  import { pluginTsName } from '@kubb/plugin-ts'
4
5
  import { pluginZodName } from '@kubb/plugin-zod'
5
6
  import { clientGenerator } from './generators/clientGenerator.tsx'
6
7
  import { defaultMacros, resolverClient } from '@internals/client'
7
- import type { PluginClient, ResolvedOptions, ResolverClient } from './types.ts'
8
+ import type { PluginClient, ResolverClient } from './types.ts'
8
9
 
9
10
  /**
10
11
  * Canonical plugin name for `@kubb/plugin-client`.
@@ -21,51 +22,43 @@ export const pluginClientName = 'plugin-client' satisfies PluginClient['name']
21
22
  * pluginClient({ importPath: '../api/client' })
22
23
  * ```
23
24
  */
24
- export const pluginClient = definePlugin<PluginClient>((options) => {
25
- const {
26
- output = { path: 'clients', barrel: { type: 'named' } },
27
- exclude = [],
28
- include,
29
- override = [],
30
- importPath,
31
- throwOnErrorDefault = true,
32
- validator = false,
33
- group,
34
- resolver: userResolver,
35
- } = options
25
+ export const pluginClient = definePlugin<PluginClient>({
26
+ meta: { name: pluginClientName, version, compatibility: { kubb: '>=5.8.0' } },
27
+ dependencies: (options) => ({ [pluginTsName]: { optional: true }, [pluginZodName]: { optional: !options.validator } }),
28
+ setup(options) {
29
+ const {
30
+ output = { path: 'clients', barrel: { type: 'named' } },
31
+ exclude = [],
32
+ include,
33
+ override = [],
34
+ importPath,
35
+ throwOnErrorDefault = true,
36
+ validator = false,
37
+ group,
38
+ resolver: userResolver,
39
+ } = options
36
40
 
37
- const resolved: ResolvedOptions = {
38
- output,
39
- exclude,
40
- include,
41
- override,
42
- group: createGroupConfig(group),
43
- importPath,
44
- baseURL: undefined,
45
- throwOnErrorDefault,
46
- validator,
47
- returnType: 'plain',
48
- sdk: undefined,
49
- resolver: userResolver ? Resolver.merge<ResolverClient>(resolverClient, userResolver) : resolverClient,
50
- }
41
+ const resolver = userResolver ? Resolver.merge<ResolverClient>(resolverClient, userResolver) : resolverClient
51
42
 
52
- return {
53
- name: pluginClientName,
54
- options,
55
- dependencies: [pluginTsName, pluginZodName],
56
- hooks: {
57
- 'kubb:plugin:setup'(ctx) {
58
- if (validator && !ctx.config.plugins?.some((plugin) => plugin.name === pluginZodName)) {
59
- throw new Error(`${pluginClientName}: \`validator\` needs ${pluginZodName}. Add pluginZod() to the plugins or set \`validator: false\`.`)
60
- }
43
+ setResolver(resolver)
44
+ setMacros([...defaultMacros, ...(options.macros ?? [])])
45
+ addGenerator(clientGenerator)
61
46
 
62
- ctx.setOptions(resolved)
63
- ctx.setResolver(resolved.resolver)
64
- ctx.setMacros([...defaultMacros, ...(options.macros ?? [])])
65
- ctx.addGenerator(clientGenerator)
66
- },
67
- },
68
- }
47
+ return {
48
+ output,
49
+ exclude,
50
+ include,
51
+ override,
52
+ group: createGroupConfig(group),
53
+ importPath,
54
+ baseURL: undefined,
55
+ throwOnErrorDefault,
56
+ validator,
57
+ returnType: 'plain',
58
+ sdk: undefined,
59
+ resolver,
60
+ }
61
+ },
69
62
  })
70
63
 
71
64
  export default pluginClient