@kubb/plugin-fetch 5.6.1 → 5.6.4

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.
@@ -21,7 +21,7 @@
21
21
  "optionalDependencies": ["plugin-zod"],
22
22
  "compatibility": {
23
23
  "kubb": ">=5.8.3",
24
- "node": ">=22"
24
+ "node": ">=22.12"
25
25
  },
26
26
  "role": "client",
27
27
  "options": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-fetch",
3
- "version": "5.6.1",
3
+ "version": "5.6.4",
4
4
  "description": "Generate a slim, type-safe HTTP client with Kubb based on the native Fetch api.",
5
5
  "keywords": [
6
6
  "api-client",
@@ -55,9 +55,14 @@
55
55
  },
56
56
  "exports": {
57
57
  ".": {
58
- "types": "./dist/index.d.ts",
59
- "import": "./dist/index.js",
60
- "require": "./dist/index.cjs"
58
+ "import": {
59
+ "types": "./dist/index.d.ts",
60
+ "default": "./dist/index.js"
61
+ },
62
+ "require": {
63
+ "types": "./dist/index.d.cts",
64
+ "default": "./dist/index.cjs"
65
+ }
61
66
  },
62
67
  "./package.json": "./package.json",
63
68
  "./kubb-extension.json": "./kubb-extension.json",
@@ -75,20 +80,20 @@
75
80
  "registry": "https://registry.npmjs.org/"
76
81
  },
77
82
  "dependencies": {
78
- "@kubb/plugin-ts": "^5.0.11",
79
- "@kubb/plugin-zod": "^5.4.9"
83
+ "@kubb/plugin-ts": "^5.0.14",
84
+ "@kubb/plugin-zod": "^5.4.12"
80
85
  },
81
86
  "devDependencies": {
82
87
  "@internals/client": "0.0.0",
83
88
  "@internals/shared": "0.0.0",
84
- "kubb": "^5.9.2",
89
+ "kubb": "^5.10.3",
85
90
  "typescript": "^6.0.3"
86
91
  },
87
92
  "peerDependencies": {
88
- "kubb": "^5.9.2"
93
+ "kubb": "^5.10.3"
89
94
  },
90
95
  "engines": {
91
- "node": ">=22"
96
+ "node": ">=22.12"
92
97
  },
93
98
  "scripts": {
94
99
  "build": "tsdown",
package/src/plugin.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import path from 'node:path'
2
- import { createSdkGenerator, defaultMacros, resolverClient } from '@internals/client'
2
+ import { createSdkGenerator, defaultMacros, isValidatorEnabled, resolverClient } from '@internals/client'
3
3
  import { createGroupConfig } from '@internals/shared'
4
- import { addGenerator, defineExtension, injectFile, Resolver, setMacros, setResolver, useConfig } from 'kubb/kit'
4
+ import { addGenerator, assertPluginOption, defineExtension, injectFile, Resolver, setMacros, setResolver, useConfig } from 'kubb/kit'
5
5
  import { compatibility } from '../kubb-extension.json'
6
6
  import { version } from '../package.json'
7
7
  import { pluginTsName } from '@kubb/plugin-ts'
@@ -41,9 +41,9 @@ export const pluginFetchName = 'plugin-fetch' satisfies PluginFetch['name']
41
41
  export const pluginFetch = defineExtension<PluginFetch>({
42
42
  kind: 'plugin',
43
43
  meta: { name: pluginFetchName, version, compatibility },
44
- // Both are ordering hints, skipped when the plugin is not in the pipeline. `plugin-ts` supplies
45
- // the operation types unless it is absent, in which case `pluginZod({ inferred: true })` does.
46
- dependencies: { [pluginTsName]: { optional: true }, [pluginZodName]: { optional: true } },
44
+ // `plugin-ts` supplies the operation types unless it is absent, in which case `pluginZod({ inferred: true })`
45
+ // does. `plugin-zod` is required once `validator` enables a direction, so a missing one fails setup instead of codegen.
46
+ dependencies: (options) => ({ [pluginTsName]: { optional: true }, [pluginZodName]: { optional: !isValidatorEnabled(options.validator) } }),
47
47
  setup(options) {
48
48
  const config = useConfig()
49
49
  const {
@@ -74,6 +74,27 @@ export const pluginFetch = defineExtension<PluginFetch>({
74
74
  resolver: userResolver ? Resolver.merge<ResolverClient>(resolverClient, userResolver) : resolverClient,
75
75
  }
76
76
 
77
+ const allowedReturnTypes = ['full', 'data', 'plain'] satisfies Array<ResolvedOptions['returnType']>
78
+ assertPluginOption({ plugin: pluginFetchName, option: 'returnType', value: returnType, allowed: allowedReturnTypes })
79
+ // An override replaces `returnType` per operation, so its values are checked too.
80
+ for (const [index, entry] of override.entries()) {
81
+ if (entry.options.returnType === undefined) continue
82
+ assertPluginOption({
83
+ plugin: pluginFetchName,
84
+ option: `override[${index}].options.returnType`,
85
+ value: entry.options.returnType,
86
+ allowed: allowedReturnTypes,
87
+ })
88
+ }
89
+ if (resolved.sdk) {
90
+ assertPluginOption({
91
+ plugin: pluginFetchName,
92
+ option: 'sdk.mode',
93
+ value: resolved.sdk.mode,
94
+ allowed: ['tag', 'flat'] satisfies Array<NonNullable<ResolvedOptions['sdk']>['mode']>,
95
+ })
96
+ }
97
+
77
98
  setResolver(resolved.resolver)
78
99
  setMacros([...defaultMacros, ...(options.macros ?? [])])
79
100
 
@@ -1,8 +0,0 @@
1
- //#region \0rolldown/runtime.js
2
- var __defProp = Object.defineProperty;
3
- var __name = (target, value) => __defProp(target, "name", {
4
- value,
5
- configurable: true
6
- });
7
- //#endregion
8
- export { __name as t };