@xube/kit-sdk 0.1.0

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.
@@ -0,0 +1,87 @@
1
+ import { makeApi, Zodios, type ZodiosOptions } from "@zodios/core";
2
+ import { z } from "zod";
3
+
4
+ {{#if imports}}
5
+ {{#each imports}}
6
+ import { {{{@key}}} } from "./{{{this}}}"
7
+ {{/each}}
8
+ {{/if}}
9
+
10
+ {{#if types}}
11
+ {{#each types}}
12
+ export {{{this}}};
13
+ {{/each}}
14
+ {{/if}}
15
+
16
+ {{#each schemas}}
17
+ export const {{@key}}{{#if (lookup ../emittedType @key)}}: z.ZodType<{{@key}}>{{/if}} = {{{this}}};
18
+ export type T{{@key}} = z.infer<typeof {{@key}}>;
19
+ {{/each}}
20
+
21
+ export const endpoints = makeApi([
22
+ {{#each endpoints}}
23
+ {
24
+ method: "{{method}}",
25
+ path: "{{path}}",
26
+ {{#if @root.options.withAlias}}
27
+ {{#if alias}}
28
+ alias: "{{alias}}",
29
+ {{/if}}
30
+ {{/if}}
31
+ {{#if description}}
32
+ description: `{{description}}`,
33
+ {{/if}}
34
+ {{#if requestFormat}}
35
+ requestFormat: "{{requestFormat}}",
36
+ {{/if}}
37
+ {{#if parameters}}
38
+ parameters: [
39
+ {{#each parameters}}
40
+ {
41
+ name: "{{name}}",
42
+ {{#if description}}
43
+ description: `{{description}}`,
44
+ {{/if}}
45
+ {{#if type}}
46
+ type: "{{type}}",
47
+ {{/if}}
48
+ schema: {{{schema}}}
49
+ },
50
+ {{/each}}
51
+ ],
52
+ {{/if}}
53
+ response: {{{response}}},
54
+ {{#if errors.length}}
55
+ errors: [
56
+ {{#each errors}}
57
+ {
58
+ {{#ifeq status "default" }}
59
+ status: "default",
60
+ {{else}}
61
+ status: {{status}},
62
+ {{/ifeq}}
63
+ {{#if description}}
64
+ description: `{{description}}`,
65
+ {{/if}}
66
+ schema: {{{schema}}}
67
+ },
68
+ {{/each}}
69
+ ]
70
+ {{/if}}
71
+ },
72
+ {{/each}}
73
+ ]);
74
+
75
+ export const {{options.apiClientName}} = new Zodios({{#if options.baseUrl}}"{{options.baseUrl}}", {{/if}}endpoints);
76
+
77
+ export function createApiClient(baseUrl: string, options?: ZodiosOptions) {
78
+ return new Zodios(baseUrl, endpoints, {
79
+ ...options,
80
+ axiosConfig: {
81
+ ...(options?.axiosConfig ?? {}),
82
+ headers: {
83
+ ...(options?.axiosConfig?.headers ?? {})
84
+ }
85
+ }
86
+ });
87
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "extends": "../kit-build/tsconfig.json",
3
+ "compilerOptions": {
4
+ "rootDir": "./src",
5
+ "outDir": "./dist"
6
+ },
7
+ "exclude": [
8
+ "**/*.test.ts",
9
+ "**/*.mock.ts",
10
+ "dist",
11
+ ],
12
+ "references": []
13
+ }