@kubb/plugin-client 0.0.0-canary-20241104172400

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 (58) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +53 -0
  3. package/client.ts +65 -0
  4. package/dist/chunk-I2NEG5CE.js +222 -0
  5. package/dist/chunk-I2NEG5CE.js.map +1 -0
  6. package/dist/chunk-IIY26RTZ.cjs +232 -0
  7. package/dist/chunk-IIY26RTZ.cjs.map +1 -0
  8. package/dist/chunk-PHUXTZZT.js +159 -0
  9. package/dist/chunk-PHUXTZZT.js.map +1 -0
  10. package/dist/chunk-UBMTYBLG.cjs +162 -0
  11. package/dist/chunk-UBMTYBLG.cjs.map +1 -0
  12. package/dist/client.cjs +45 -0
  13. package/dist/client.cjs.map +1 -0
  14. package/dist/client.d.cts +35 -0
  15. package/dist/client.d.ts +35 -0
  16. package/dist/client.js +33 -0
  17. package/dist/client.js.map +1 -0
  18. package/dist/components.cjs +16 -0
  19. package/dist/components.cjs.map +1 -0
  20. package/dist/components.d.cts +40 -0
  21. package/dist/components.d.ts +40 -0
  22. package/dist/components.js +3 -0
  23. package/dist/components.js.map +1 -0
  24. package/dist/generators.cjs +21 -0
  25. package/dist/generators.cjs.map +1 -0
  26. package/dist/generators.d.cts +11 -0
  27. package/dist/generators.d.ts +11 -0
  28. package/dist/generators.js +4 -0
  29. package/dist/generators.js.map +1 -0
  30. package/dist/index.cjs +17 -0
  31. package/dist/index.cjs.map +1 -0
  32. package/dist/index.d.cts +8 -0
  33. package/dist/index.d.ts +8 -0
  34. package/dist/index.js +4 -0
  35. package/dist/index.js.map +1 -0
  36. package/dist/types-DXab6SYO.d.cts +92 -0
  37. package/dist/types-DXab6SYO.d.ts +92 -0
  38. package/package.json +117 -0
  39. package/src/components/Client.tsx +199 -0
  40. package/src/components/Operations.tsx +28 -0
  41. package/src/components/index.ts +2 -0
  42. package/src/generators/__snapshots__/deletePet.ts +13 -0
  43. package/src/generators/__snapshots__/deletePetObject.ts +13 -0
  44. package/src/generators/__snapshots__/findByTags.ts +13 -0
  45. package/src/generators/__snapshots__/findByTagsFull.ts +13 -0
  46. package/src/generators/__snapshots__/findByTagsObject.ts +15 -0
  47. package/src/generators/__snapshots__/findByTagsWithZod.ts +13 -0
  48. package/src/generators/__snapshots__/findByTagsWithZodFull.ts +13 -0
  49. package/src/generators/__snapshots__/importPath.ts +13 -0
  50. package/src/generators/__snapshots__/operations.ts +82 -0
  51. package/src/generators/__snapshots__/updatePetById.ts +12 -0
  52. package/src/generators/clientGenerator.tsx +67 -0
  53. package/src/generators/groupedClientGenerator.tsx +70 -0
  54. package/src/generators/index.ts +3 -0
  55. package/src/generators/operationsGenerator.tsx +26 -0
  56. package/src/index.ts +2 -0
  57. package/src/plugin.ts +122 -0
  58. package/src/types.ts +93 -0
@@ -0,0 +1,40 @@
1
+ import { Operation } from '@kubb/oas';
2
+ import { OperationSchemas } from '@kubb/plugin-oas';
3
+ import { FunctionParams } from '@kubb/react';
4
+ import { KubbNode } from '@kubb/react/types';
5
+ import { P as PluginClient } from './types-DXab6SYO.cjs';
6
+ import '@kubb/core';
7
+
8
+ type Props = {
9
+ /**
10
+ * Name of the function
11
+ */
12
+ name: string;
13
+ isExportable?: boolean;
14
+ isIndexable?: boolean;
15
+ baseURL: string | undefined;
16
+ dataReturnType: PluginClient['resolvedOptions']['dataReturnType'];
17
+ paramsType: PluginClient['resolvedOptions']['pathParamsType'];
18
+ pathParamsType: PluginClient['resolvedOptions']['pathParamsType'];
19
+ parser: PluginClient['resolvedOptions']['parser'] | undefined;
20
+ typeSchemas: OperationSchemas;
21
+ zodSchemas: OperationSchemas | undefined;
22
+ operation: Operation;
23
+ };
24
+ type GetParamsProps = {
25
+ paramsType: PluginClient['resolvedOptions']['paramsType'];
26
+ pathParamsType: PluginClient['resolvedOptions']['pathParamsType'];
27
+ typeSchemas: OperationSchemas;
28
+ };
29
+ declare function Client({ name, isExportable, isIndexable, typeSchemas, baseURL, dataReturnType, parser, zodSchemas, paramsType, pathParamsType, operation, }: Props): KubbNode;
30
+ declare namespace Client {
31
+ var getParams: ({ paramsType, pathParamsType, typeSchemas }: GetParamsProps) => FunctionParams;
32
+ }
33
+
34
+ type OperationsProps = {
35
+ name: string;
36
+ operations: Array<Operation>;
37
+ };
38
+ declare function Operations({ name, operations }: OperationsProps): JSX.Element;
39
+
40
+ export { Client, Operations };
@@ -0,0 +1,40 @@
1
+ import { Operation } from '@kubb/oas';
2
+ import { OperationSchemas } from '@kubb/plugin-oas';
3
+ import { FunctionParams } from '@kubb/react';
4
+ import { KubbNode } from '@kubb/react/types';
5
+ import { P as PluginClient } from './types-DXab6SYO.js';
6
+ import '@kubb/core';
7
+
8
+ type Props = {
9
+ /**
10
+ * Name of the function
11
+ */
12
+ name: string;
13
+ isExportable?: boolean;
14
+ isIndexable?: boolean;
15
+ baseURL: string | undefined;
16
+ dataReturnType: PluginClient['resolvedOptions']['dataReturnType'];
17
+ paramsType: PluginClient['resolvedOptions']['pathParamsType'];
18
+ pathParamsType: PluginClient['resolvedOptions']['pathParamsType'];
19
+ parser: PluginClient['resolvedOptions']['parser'] | undefined;
20
+ typeSchemas: OperationSchemas;
21
+ zodSchemas: OperationSchemas | undefined;
22
+ operation: Operation;
23
+ };
24
+ type GetParamsProps = {
25
+ paramsType: PluginClient['resolvedOptions']['paramsType'];
26
+ pathParamsType: PluginClient['resolvedOptions']['pathParamsType'];
27
+ typeSchemas: OperationSchemas;
28
+ };
29
+ declare function Client({ name, isExportable, isIndexable, typeSchemas, baseURL, dataReturnType, parser, zodSchemas, paramsType, pathParamsType, operation, }: Props): KubbNode;
30
+ declare namespace Client {
31
+ var getParams: ({ paramsType, pathParamsType, typeSchemas }: GetParamsProps) => FunctionParams;
32
+ }
33
+
34
+ type OperationsProps = {
35
+ name: string;
36
+ operations: Array<Operation>;
37
+ };
38
+ declare function Operations({ name, operations }: OperationsProps): JSX.Element;
39
+
40
+ export { Client, Operations };
@@ -0,0 +1,3 @@
1
+ export { Client, Operations } from './chunk-PHUXTZZT.js';
2
+ //# sourceMappingURL=components.js.map
3
+ //# sourceMappingURL=components.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"components.js"}
@@ -0,0 +1,21 @@
1
+ 'use strict';
2
+
3
+ var chunkIIY26RTZ_cjs = require('./chunk-IIY26RTZ.cjs');
4
+ require('./chunk-UBMTYBLG.cjs');
5
+
6
+
7
+
8
+ Object.defineProperty(exports, "clientGenerator", {
9
+ enumerable: true,
10
+ get: function () { return chunkIIY26RTZ_cjs.clientGenerator; }
11
+ });
12
+ Object.defineProperty(exports, "groupedClientGenerator", {
13
+ enumerable: true,
14
+ get: function () { return chunkIIY26RTZ_cjs.groupedClientGenerator; }
15
+ });
16
+ Object.defineProperty(exports, "operationsGenerator", {
17
+ enumerable: true,
18
+ get: function () { return chunkIIY26RTZ_cjs.operationsGenerator; }
19
+ });
20
+ //# sourceMappingURL=generators.cjs.map
21
+ //# sourceMappingURL=generators.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"generators.cjs"}
@@ -0,0 +1,11 @@
1
+ import * as _kubb_plugin_oas from '@kubb/plugin-oas';
2
+ import { P as PluginClient } from './types-DXab6SYO.cjs';
3
+ import '@kubb/core';
4
+
5
+ declare const clientGenerator: _kubb_plugin_oas.Generator<PluginClient>;
6
+
7
+ declare const operationsGenerator: _kubb_plugin_oas.Generator<PluginClient>;
8
+
9
+ declare const groupedClientGenerator: _kubb_plugin_oas.Generator<PluginClient>;
10
+
11
+ export { clientGenerator, groupedClientGenerator, operationsGenerator };
@@ -0,0 +1,11 @@
1
+ import * as _kubb_plugin_oas from '@kubb/plugin-oas';
2
+ import { P as PluginClient } from './types-DXab6SYO.js';
3
+ import '@kubb/core';
4
+
5
+ declare const clientGenerator: _kubb_plugin_oas.Generator<PluginClient>;
6
+
7
+ declare const operationsGenerator: _kubb_plugin_oas.Generator<PluginClient>;
8
+
9
+ declare const groupedClientGenerator: _kubb_plugin_oas.Generator<PluginClient>;
10
+
11
+ export { clientGenerator, groupedClientGenerator, operationsGenerator };
@@ -0,0 +1,4 @@
1
+ export { clientGenerator, groupedClientGenerator, operationsGenerator } from './chunk-I2NEG5CE.js';
2
+ import './chunk-PHUXTZZT.js';
3
+ //# sourceMappingURL=generators.js.map
4
+ //# sourceMappingURL=generators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"generators.js"}
package/dist/index.cjs ADDED
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ var chunkIIY26RTZ_cjs = require('./chunk-IIY26RTZ.cjs');
4
+ require('./chunk-UBMTYBLG.cjs');
5
+
6
+
7
+
8
+ Object.defineProperty(exports, "pluginClient", {
9
+ enumerable: true,
10
+ get: function () { return chunkIIY26RTZ_cjs.pluginClient; }
11
+ });
12
+ Object.defineProperty(exports, "pluginClientName", {
13
+ enumerable: true,
14
+ get: function () { return chunkIIY26RTZ_cjs.pluginClientName; }
15
+ });
16
+ //# sourceMappingURL=index.cjs.map
17
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
@@ -0,0 +1,8 @@
1
+ import * as _kubb_core from '@kubb/core';
2
+ import { O as Options, P as PluginClient } from './types-DXab6SYO.cjs';
3
+ import '@kubb/plugin-oas';
4
+
5
+ declare const pluginClientName = "plugin-client";
6
+ declare const pluginClient: (options?: Options | undefined) => _kubb_core.UserPluginWithLifeCycle<PluginClient>;
7
+
8
+ export { PluginClient, pluginClient, pluginClientName };
@@ -0,0 +1,8 @@
1
+ import * as _kubb_core from '@kubb/core';
2
+ import { O as Options, P as PluginClient } from './types-DXab6SYO.js';
3
+ import '@kubb/plugin-oas';
4
+
5
+ declare const pluginClientName = "plugin-client";
6
+ declare const pluginClient: (options?: Options | undefined) => _kubb_core.UserPluginWithLifeCycle<PluginClient>;
7
+
8
+ export { PluginClient, pluginClient, pluginClientName };
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export { pluginClient, pluginClientName } from './chunk-I2NEG5CE.js';
2
+ import './chunk-PHUXTZZT.js';
3
+ //# sourceMappingURL=index.js.map
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -0,0 +1,92 @@
1
+ import { PluginFactoryOptions, Output, Group, ResolveNameParams } from '@kubb/core';
2
+ import { ResolvePathOptions, Exclude, Include, Override, Generator } from '@kubb/plugin-oas';
3
+
4
+ type Options = {
5
+ /**
6
+ * Specify the export location for the files and define the behavior of the output
7
+ * @default { path: 'clients', barrelType: 'named' }
8
+ */
9
+ output?: Output;
10
+ /**
11
+ * Group the clients based on the provided name.
12
+ */
13
+ group?: Group;
14
+ /**
15
+ * Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
16
+ */
17
+ exclude?: Array<Exclude>;
18
+ /**
19
+ * Array containing include parameters to include tags/operations/methods/paths.
20
+ */
21
+ include?: Array<Include>;
22
+ /**
23
+ * Array containing override parameters to override `options` based on tags/operations/methods/paths.
24
+ */
25
+ override?: Array<Override<ResolvedOptions>>;
26
+ /**
27
+ * Create `operations.ts` file with all operations grouped by methods.
28
+ * @default false
29
+ */
30
+ operations?: boolean;
31
+ /**
32
+ * Path to the client import path that will be used to do the API calls.
33
+ * It will be used as `import client from '${client.importPath}'`.
34
+ * It allows both relative and absolute path but be aware that we will not change the path.
35
+ * @default '@kubb/plugin-client/client'
36
+ */
37
+ importPath?: string;
38
+ /**
39
+ * Allows you to set a custom base url for all generated calls.
40
+ */
41
+ baseURL?: string;
42
+ /**
43
+ * ReturnType that will be used when calling the client.
44
+ * - 'data' will return ResponseConfig[data].
45
+ * - 'full' will return ResponseConfig.
46
+ * @default 'data'
47
+ */
48
+ dataReturnType?: 'data' | 'full';
49
+ /**
50
+ * How to pass your params
51
+ * - 'object' will return the params and pathParams as an object.
52
+ * - 'inline' will return the params as comma separated params.
53
+ * @default 'inline'
54
+ */
55
+ paramsType?: 'object' | 'inline';
56
+ /**
57
+ * How to pass your pathParams.
58
+ * - 'object' will return the pathParams as an object.
59
+ * - 'inline' will return the pathParams as comma separated params.
60
+ * @default 'inline'
61
+ */
62
+ pathParamsType?: 'object' | 'inline';
63
+ /**
64
+ * Which parser can be used before returning the data
65
+ * - 'zod' will use `@kubb/plugin-zod` to parse the data.
66
+ * @default 'client'
67
+ */
68
+ parser?: 'client' | 'zod';
69
+ transformers?: {
70
+ /**
71
+ * Customize the names based on the type that is provided by the plugin.
72
+ */
73
+ name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
74
+ };
75
+ /**
76
+ * Define some generators next to the client generators
77
+ */
78
+ generators?: Array<Generator<PluginClient>>;
79
+ };
80
+ type ResolvedOptions = {
81
+ output: Output;
82
+ group?: Options['group'];
83
+ baseURL: string | undefined;
84
+ parser: NonNullable<Options['parser']>;
85
+ importPath: NonNullable<Options['importPath']>;
86
+ dataReturnType: NonNullable<Options['dataReturnType']>;
87
+ pathParamsType: NonNullable<Options['pathParamsType']>;
88
+ paramsType: NonNullable<Options['paramsType']>;
89
+ };
90
+ type PluginClient = PluginFactoryOptions<'plugin-client', Options, ResolvedOptions, never, ResolvePathOptions>;
91
+
92
+ export type { Options as O, PluginClient as P };
@@ -0,0 +1,92 @@
1
+ import { PluginFactoryOptions, Output, Group, ResolveNameParams } from '@kubb/core';
2
+ import { ResolvePathOptions, Exclude, Include, Override, Generator } from '@kubb/plugin-oas';
3
+
4
+ type Options = {
5
+ /**
6
+ * Specify the export location for the files and define the behavior of the output
7
+ * @default { path: 'clients', barrelType: 'named' }
8
+ */
9
+ output?: Output;
10
+ /**
11
+ * Group the clients based on the provided name.
12
+ */
13
+ group?: Group;
14
+ /**
15
+ * Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
16
+ */
17
+ exclude?: Array<Exclude>;
18
+ /**
19
+ * Array containing include parameters to include tags/operations/methods/paths.
20
+ */
21
+ include?: Array<Include>;
22
+ /**
23
+ * Array containing override parameters to override `options` based on tags/operations/methods/paths.
24
+ */
25
+ override?: Array<Override<ResolvedOptions>>;
26
+ /**
27
+ * Create `operations.ts` file with all operations grouped by methods.
28
+ * @default false
29
+ */
30
+ operations?: boolean;
31
+ /**
32
+ * Path to the client import path that will be used to do the API calls.
33
+ * It will be used as `import client from '${client.importPath}'`.
34
+ * It allows both relative and absolute path but be aware that we will not change the path.
35
+ * @default '@kubb/plugin-client/client'
36
+ */
37
+ importPath?: string;
38
+ /**
39
+ * Allows you to set a custom base url for all generated calls.
40
+ */
41
+ baseURL?: string;
42
+ /**
43
+ * ReturnType that will be used when calling the client.
44
+ * - 'data' will return ResponseConfig[data].
45
+ * - 'full' will return ResponseConfig.
46
+ * @default 'data'
47
+ */
48
+ dataReturnType?: 'data' | 'full';
49
+ /**
50
+ * How to pass your params
51
+ * - 'object' will return the params and pathParams as an object.
52
+ * - 'inline' will return the params as comma separated params.
53
+ * @default 'inline'
54
+ */
55
+ paramsType?: 'object' | 'inline';
56
+ /**
57
+ * How to pass your pathParams.
58
+ * - 'object' will return the pathParams as an object.
59
+ * - 'inline' will return the pathParams as comma separated params.
60
+ * @default 'inline'
61
+ */
62
+ pathParamsType?: 'object' | 'inline';
63
+ /**
64
+ * Which parser can be used before returning the data
65
+ * - 'zod' will use `@kubb/plugin-zod` to parse the data.
66
+ * @default 'client'
67
+ */
68
+ parser?: 'client' | 'zod';
69
+ transformers?: {
70
+ /**
71
+ * Customize the names based on the type that is provided by the plugin.
72
+ */
73
+ name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
74
+ };
75
+ /**
76
+ * Define some generators next to the client generators
77
+ */
78
+ generators?: Array<Generator<PluginClient>>;
79
+ };
80
+ type ResolvedOptions = {
81
+ output: Output;
82
+ group?: Options['group'];
83
+ baseURL: string | undefined;
84
+ parser: NonNullable<Options['parser']>;
85
+ importPath: NonNullable<Options['importPath']>;
86
+ dataReturnType: NonNullable<Options['dataReturnType']>;
87
+ pathParamsType: NonNullable<Options['pathParamsType']>;
88
+ paramsType: NonNullable<Options['paramsType']>;
89
+ };
90
+ type PluginClient = PluginFactoryOptions<'plugin-client', Options, ResolvedOptions, never, ResolvePathOptions>;
91
+
92
+ export type { Options as O, PluginClient as P };
package/package.json ADDED
@@ -0,0 +1,117 @@
1
+ {
2
+ "name": "@kubb/plugin-client",
3
+ "version": "0.0.0-canary-20241104172400",
4
+ "description": "Generator plugin-client",
5
+ "keywords": [
6
+ "typescript",
7
+ "plugins",
8
+ "kubb",
9
+ "codegen",
10
+ "swagger",
11
+ "openapi",
12
+ "axios"
13
+ ],
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git://github.com/kubb-labs/kubb.git",
17
+ "directory": "packages/plugin-client"
18
+ },
19
+ "license": "MIT",
20
+ "author": "Stijn Van Hulle <stijn@stijnvanhulle.be",
21
+ "sideEffects": false,
22
+ "type": "module",
23
+ "exports": {
24
+ ".": {
25
+ "import": "./dist/index.js",
26
+ "require": "./dist/index.cjs",
27
+ "default": "./dist/index.cjs"
28
+ },
29
+ "./generators": {
30
+ "import": "./dist/generators.js",
31
+ "require": "./dist/generators.cjs",
32
+ "default": "./dist/generators.cjs"
33
+ },
34
+ "./components": {
35
+ "import": "./dist/components.js",
36
+ "require": "./dist/components.cjs",
37
+ "default": "./dist/components.cjs"
38
+ },
39
+ "./client": {
40
+ "import": "./dist/client.js",
41
+ "require": "./dist/client.cjs",
42
+ "default": "./dist/client.cjs"
43
+ },
44
+ "./ts-client": {
45
+ "import": "./client.ts",
46
+ "require": "./client.ts",
47
+ "default": "./client.ts"
48
+ },
49
+ "./package.json": "./package.json",
50
+ "./*": "./*"
51
+ },
52
+ "main": "dist/index.cjs",
53
+ "module": "dist/index.js",
54
+ "types": "./dist/index.d.ts",
55
+ "typesVersions": {
56
+ "*": {
57
+ "components": [
58
+ "./dist/components.d.ts"
59
+ ],
60
+ "generators": [
61
+ "./dist/generators.d.ts"
62
+ ]
63
+ }
64
+ },
65
+ "files": [
66
+ "src",
67
+ "dist",
68
+ "client.ts",
69
+ "*.d.ts",
70
+ "*.d.cts",
71
+ "!/**/**.test.**",
72
+ "!/**/__tests__/**"
73
+ ],
74
+ "dependencies": {
75
+ "@kubb/core": "0.0.0-canary-20241104172400",
76
+ "@kubb/fs": "0.0.0-canary-20241104172400",
77
+ "@kubb/oas": "0.0.0-canary-20241104172400",
78
+ "@kubb/plugin-oas": "0.0.0-canary-20241104172400",
79
+ "@kubb/plugin-ts": "0.0.0-canary-20241104172400",
80
+ "@kubb/plugin-zod": "0.0.0-canary-20241104172400",
81
+ "@kubb/react": "0.0.0-canary-20241104172400"
82
+ },
83
+ "devDependencies": {
84
+ "axios": "^1.7.7",
85
+ "tsup": "^8.3.5",
86
+ "typescript": "^5.6.3",
87
+ "@kubb/config-ts": "0.0.0-canary-20241104172400",
88
+ "@kubb/config-tsup": "0.0.0-canary-20241104172400"
89
+ },
90
+ "peerDependencies": {
91
+ "axios": "^1.7.2",
92
+ "@kubb/react": "0.0.0-canary-20241104172400"
93
+ },
94
+ "peerDependenciesMeta": {
95
+ "axios": {
96
+ "optional": true
97
+ }
98
+ },
99
+ "engines": {
100
+ "node": ">=20"
101
+ },
102
+ "publishConfig": {
103
+ "access": "public",
104
+ "registry": "https://registry.npmjs.org/"
105
+ },
106
+ "scripts": {
107
+ "build": "tsup",
108
+ "clean": "npx rimraf ./dist",
109
+ "lint": "bun biome lint .",
110
+ "lint:fix": "bun biome lint --apply-unsafe .",
111
+ "release": "pnpm publish --no-git-check",
112
+ "release:canary": "bash ../../.github/canary.sh && node ../../scripts/build.js canary && pnpm publish --no-git-check",
113
+ "start": "tsup --watch",
114
+ "test": "vitest --passWithNoTests",
115
+ "typecheck": "tsc -p ./tsconfig.json --noEmit --emitDeclarationOnly false"
116
+ }
117
+ }