generator-kodly-react-app 1.0.6 → 1.0.10
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/generators/app/index.js +63 -11
- package/generators/app/templates/.env.dev +4 -0
- package/generators/app/templates/.env.sandbox +4 -0
- package/generators/app/templates/STRUCTURE.md +661 -0
- package/generators/app/templates/components.json +22 -0
- package/generators/app/templates/index.html +14 -6
- package/generators/app/templates/openapi-ts.config.ts +29 -0
- package/generators/app/templates/package.json +46 -26
- package/generators/app/templates/public/favicon.svg +4 -0
- package/generators/app/templates/src/app.tsx +8 -8
- package/generators/app/templates/src/components/layout/language-switcher.tsx +40 -0
- package/generators/app/templates/src/components/layout/theme-switcher.tsx +37 -0
- package/generators/app/templates/src/components/theme/theme-provider.tsx +22 -28
- package/generators/app/templates/src/components/ui/button.tsx +34 -32
- package/generators/app/templates/src/components/ui/card.tsx +76 -0
- package/generators/app/templates/src/components/ui/field.tsx +242 -0
- package/generators/app/templates/src/components/ui/form.tsx +129 -0
- package/generators/app/templates/src/components/ui/input-group.tsx +170 -0
- package/generators/app/templates/src/components/ui/input.tsx +19 -21
- package/generators/app/templates/src/components/ui/label.tsx +24 -0
- package/generators/app/templates/src/components/ui/select.tsx +184 -0
- package/generators/app/templates/src/components/ui/separator.tsx +31 -0
- package/generators/app/templates/src/components/ui/textarea.tsx +22 -0
- package/generators/app/templates/src/index.css +83 -26
- package/generators/app/templates/src/lib/api/client.ts +4 -5
- package/generators/app/templates/src/lib/i18n.ts +31 -16
- package/generators/app/templates/src/lib/routes.ts +14 -0
- package/generators/app/templates/src/lib/utils/error-handler.ts +7 -2
- package/generators/app/templates/src/lib/utils/init-form-schema.ts +12 -0
- package/generators/app/templates/src/lib/utils.ts +3 -4
- package/generators/app/templates/src/locales/en/common.json +5 -0
- package/generators/app/templates/src/locales/en/theme.json +5 -0
- package/generators/app/templates/src/locales/index.ts +31 -0
- package/generators/app/templates/src/locales/ja/common.json +5 -0
- package/generators/app/templates/src/locales/ja/theme.json +6 -0
- package/generators/app/templates/src/main.tsx +19 -15
- package/generators/app/templates/src/modules/app/layouts/app-layout.tsx +37 -0
- package/generators/app/templates/src/modules/app/locales/app-en.json +9 -0
- package/generators/app/templates/src/modules/app/locales/app-ja.json +9 -0
- package/generators/app/templates/src/modules/auth/components/forgot-password-form.tsx +74 -0
- package/generators/app/templates/src/modules/auth/components/login-form.tsx +95 -0
- package/generators/app/templates/src/modules/auth/components/reset-password-form.tsx +112 -0
- package/generators/app/templates/src/modules/auth/components/signup-form.tsx +92 -0
- package/generators/app/templates/src/modules/auth/contexts/auth-context.tsx +11 -0
- package/generators/app/templates/src/modules/auth/hooks/use-auth-hook.ts +175 -0
- package/generators/app/templates/src/modules/auth/layouts/auth-layout.tsx +28 -0
- package/generators/app/templates/src/modules/auth/locales/auth-en.json +105 -0
- package/generators/app/templates/src/modules/auth/locales/auth-ja.json +105 -0
- package/generators/app/templates/src/modules/landing/components/auth-hero.tsx +34 -0
- package/generators/app/templates/src/modules/landing/components/welcome-hero.tsx +24 -0
- package/generators/app/templates/src/modules/landing/landing-page-layout.tsx +24 -0
- package/generators/app/templates/src/modules/landing/landing-page.tsx +17 -0
- package/generators/app/templates/src/modules/landing/layouts/landing-page-layout.tsx +24 -0
- package/generators/app/templates/src/modules/landing/locales/landing-en.json +12 -0
- package/generators/app/templates/src/modules/landing/locales/landing-ja.json +11 -0
- package/generators/app/templates/src/openapi-client-config.ts +6 -0
- package/generators/app/templates/src/routeTree.gen.ts +268 -3
- package/generators/app/templates/src/router.tsx +2 -2
- package/generators/app/templates/src/routes/__root.tsx +3 -3
- package/generators/app/templates/src/routes/_landing/index.tsx +10 -0
- package/generators/app/templates/src/routes/_landing/route.tsx +14 -0
- package/generators/app/templates/src/routes/app/index.tsx +4 -21
- package/generators/app/templates/src/routes/app/route.tsx +12 -8
- package/generators/app/templates/src/routes/auth/forgot-password.tsx +10 -0
- package/generators/app/templates/src/routes/auth/login.tsx +6 -7
- package/generators/app/templates/src/routes/auth/reset-password.tsx +15 -0
- package/generators/app/templates/src/routes/auth/route.tsx +23 -6
- package/generators/app/templates/src/routes/auth/signup.tsx +11 -0
- package/generators/app/templates/src/sdk/@tanstack/react-query.gen.ts +91 -0
- package/generators/app/templates/src/sdk/client/client.gen.ts +167 -0
- package/generators/app/templates/src/sdk/client/index.ts +23 -0
- package/generators/app/templates/src/sdk/client/types.gen.ts +197 -0
- package/generators/app/templates/src/sdk/client/utils.gen.ts +213 -0
- package/generators/app/templates/src/sdk/client.gen.ts +18 -0
- package/generators/app/templates/src/sdk/core/auth.gen.ts +42 -0
- package/generators/app/templates/src/sdk/core/bodySerializer.gen.ts +100 -0
- package/generators/app/templates/src/sdk/core/params.gen.ts +176 -0
- package/generators/app/templates/src/sdk/core/pathSerializer.gen.ts +181 -0
- package/generators/app/templates/src/sdk/core/queryKeySerializer.gen.ts +136 -0
- package/generators/app/templates/src/sdk/core/serverSentEvents.gen.ts +266 -0
- package/generators/app/templates/src/sdk/core/types.gen.ts +118 -0
- package/generators/app/templates/src/sdk/core/utils.gen.ts +143 -0
- package/generators/app/templates/src/sdk/index.ts +4 -0
- package/generators/app/templates/src/sdk/schemas.gen.ts +195 -0
- package/generators/app/templates/src/sdk/sdk.gen.ts +80 -0
- package/generators/app/templates/src/sdk/types.gen.ts +158 -0
- package/generators/app/templates/src/sdk/zod.gen.ts +148 -0
- package/generators/app/templates/src/vite-env.d.ts +2 -1
- package/generators/app/templates/tsconfig.json +1 -1
- package/generators/app/templates/vite.config.js +35 -21
- package/generators/constants.js +9 -9
- package/package.json +3 -2
- package/generators/app/templates/.env.example +0 -5
- package/generators/app/templates/README.md +0 -57
- package/generators/app/templates/src/locales/en.json +0 -18
- package/generators/app/templates/src/modules/auth/auth-context.tsx +0 -13
- package/generators/app/templates/src/modules/auth/login/login-form.tsx +0 -49
- package/generators/app/templates/src/modules/auth/login/login-page.tsx +0 -12
- package/generators/app/templates/src/modules/auth/use-auth-hook.ts +0 -87
- package/generators/app/templates/src/routes/index.tsx +0 -12
- package/generators/app/templates/types.d.ts +0 -3
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
AxiosError,
|
|
5
|
+
AxiosInstance,
|
|
6
|
+
AxiosRequestHeaders,
|
|
7
|
+
AxiosResponse,
|
|
8
|
+
AxiosStatic,
|
|
9
|
+
CreateAxiosDefaults,
|
|
10
|
+
} from 'axios';
|
|
11
|
+
|
|
12
|
+
import type { Auth } from '../core/auth.gen';
|
|
13
|
+
import type {
|
|
14
|
+
ServerSentEventsOptions,
|
|
15
|
+
ServerSentEventsResult,
|
|
16
|
+
} from '../core/serverSentEvents.gen';
|
|
17
|
+
import type {
|
|
18
|
+
Client as CoreClient,
|
|
19
|
+
Config as CoreConfig,
|
|
20
|
+
} from '../core/types.gen';
|
|
21
|
+
|
|
22
|
+
export interface Config<T extends ClientOptions = ClientOptions>
|
|
23
|
+
extends Omit<CreateAxiosDefaults, 'auth' | 'baseURL' | 'headers' | 'method'>,
|
|
24
|
+
CoreConfig {
|
|
25
|
+
/**
|
|
26
|
+
* Axios implementation. You can use this option to provide either an
|
|
27
|
+
* `AxiosStatic` or an `AxiosInstance`.
|
|
28
|
+
*
|
|
29
|
+
* @default axios
|
|
30
|
+
*/
|
|
31
|
+
axios?: AxiosStatic | AxiosInstance;
|
|
32
|
+
/**
|
|
33
|
+
* Base URL for all requests made by this client.
|
|
34
|
+
*/
|
|
35
|
+
baseURL?: T['baseURL'];
|
|
36
|
+
/**
|
|
37
|
+
* An object containing any HTTP headers that you want to pre-populate your
|
|
38
|
+
* `Headers` object with.
|
|
39
|
+
*
|
|
40
|
+
* {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more}
|
|
41
|
+
*/
|
|
42
|
+
headers?:
|
|
43
|
+
| AxiosRequestHeaders
|
|
44
|
+
| Record<
|
|
45
|
+
string,
|
|
46
|
+
| string
|
|
47
|
+
| number
|
|
48
|
+
| boolean
|
|
49
|
+
| (string | number | boolean)[]
|
|
50
|
+
| null
|
|
51
|
+
| undefined
|
|
52
|
+
| unknown
|
|
53
|
+
>;
|
|
54
|
+
/**
|
|
55
|
+
* Throw an error instead of returning it in the response?
|
|
56
|
+
*
|
|
57
|
+
* @default false
|
|
58
|
+
*/
|
|
59
|
+
throwOnError?: T['throwOnError'];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface RequestOptions<
|
|
63
|
+
TData = unknown,
|
|
64
|
+
ThrowOnError extends boolean = boolean,
|
|
65
|
+
Url extends string = string,
|
|
66
|
+
> extends Config<{
|
|
67
|
+
throwOnError: ThrowOnError;
|
|
68
|
+
}>,
|
|
69
|
+
Pick<
|
|
70
|
+
ServerSentEventsOptions<TData>,
|
|
71
|
+
| 'onSseError'
|
|
72
|
+
| 'onSseEvent'
|
|
73
|
+
| 'sseDefaultRetryDelay'
|
|
74
|
+
| 'sseMaxRetryAttempts'
|
|
75
|
+
| 'sseMaxRetryDelay'
|
|
76
|
+
> {
|
|
77
|
+
/**
|
|
78
|
+
* Any body that you want to add to your request.
|
|
79
|
+
*
|
|
80
|
+
* {@link https://developer.mozilla.org/docs/Web/API/fetch#body}
|
|
81
|
+
*/
|
|
82
|
+
body?: unknown;
|
|
83
|
+
path?: Record<string, unknown>;
|
|
84
|
+
query?: Record<string, unknown>;
|
|
85
|
+
/**
|
|
86
|
+
* Security mechanism(s) to use for the request.
|
|
87
|
+
*/
|
|
88
|
+
security?: ReadonlyArray<Auth>;
|
|
89
|
+
url: Url;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface ClientOptions {
|
|
93
|
+
baseURL?: string;
|
|
94
|
+
throwOnError?: boolean;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export type RequestResult<
|
|
98
|
+
TData = unknown,
|
|
99
|
+
TError = unknown,
|
|
100
|
+
ThrowOnError extends boolean = boolean,
|
|
101
|
+
> = ThrowOnError extends true
|
|
102
|
+
? Promise<
|
|
103
|
+
AxiosResponse<
|
|
104
|
+
TData extends Record<string, unknown> ? TData[keyof TData] : TData
|
|
105
|
+
>
|
|
106
|
+
>
|
|
107
|
+
: Promise<
|
|
108
|
+
| (AxiosResponse<
|
|
109
|
+
TData extends Record<string, unknown> ? TData[keyof TData] : TData
|
|
110
|
+
> & { error: undefined })
|
|
111
|
+
| (AxiosError<
|
|
112
|
+
TError extends Record<string, unknown> ? TError[keyof TError] : TError
|
|
113
|
+
> & {
|
|
114
|
+
data: undefined;
|
|
115
|
+
error: TError extends Record<string, unknown>
|
|
116
|
+
? TError[keyof TError]
|
|
117
|
+
: TError;
|
|
118
|
+
})
|
|
119
|
+
>;
|
|
120
|
+
|
|
121
|
+
type MethodFn = <
|
|
122
|
+
TData = unknown,
|
|
123
|
+
TError = unknown,
|
|
124
|
+
ThrowOnError extends boolean = false,
|
|
125
|
+
>(
|
|
126
|
+
options: Omit<RequestOptions<TData, ThrowOnError>, 'method'>,
|
|
127
|
+
) => RequestResult<TData, TError, ThrowOnError>;
|
|
128
|
+
|
|
129
|
+
type SseFn = <
|
|
130
|
+
TData = unknown,
|
|
131
|
+
TError = unknown,
|
|
132
|
+
ThrowOnError extends boolean = false,
|
|
133
|
+
>(
|
|
134
|
+
options: Omit<RequestOptions<TData, ThrowOnError>, 'method'>,
|
|
135
|
+
) => Promise<ServerSentEventsResult<TData, TError>>;
|
|
136
|
+
|
|
137
|
+
type RequestFn = <
|
|
138
|
+
TData = unknown,
|
|
139
|
+
TError = unknown,
|
|
140
|
+
ThrowOnError extends boolean = false,
|
|
141
|
+
>(
|
|
142
|
+
options: Omit<RequestOptions<TData, ThrowOnError>, 'method'> &
|
|
143
|
+
Pick<Required<RequestOptions<TData, ThrowOnError>>, 'method'>,
|
|
144
|
+
) => RequestResult<TData, TError, ThrowOnError>;
|
|
145
|
+
|
|
146
|
+
type BuildUrlFn = <
|
|
147
|
+
TData extends {
|
|
148
|
+
body?: unknown;
|
|
149
|
+
path?: Record<string, unknown>;
|
|
150
|
+
query?: Record<string, unknown>;
|
|
151
|
+
url: string;
|
|
152
|
+
},
|
|
153
|
+
>(
|
|
154
|
+
options: TData & Options<TData>,
|
|
155
|
+
) => string;
|
|
156
|
+
|
|
157
|
+
export type Client = CoreClient<
|
|
158
|
+
RequestFn,
|
|
159
|
+
Config,
|
|
160
|
+
MethodFn,
|
|
161
|
+
BuildUrlFn,
|
|
162
|
+
SseFn
|
|
163
|
+
> & {
|
|
164
|
+
instance: AxiosInstance;
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* The `createClientConfig()` function will be called on client initialization
|
|
169
|
+
* and the returned object will become the client's initial configuration.
|
|
170
|
+
*
|
|
171
|
+
* You may want to initialize your client this way instead of calling
|
|
172
|
+
* `setConfig()`. This is useful for example if you're using Next.js
|
|
173
|
+
* to ensure your client always has the correct values.
|
|
174
|
+
*/
|
|
175
|
+
export type CreateClientConfig<T extends ClientOptions = ClientOptions> = (
|
|
176
|
+
override?: Config<ClientOptions & T>,
|
|
177
|
+
) => Config<Required<ClientOptions> & T>;
|
|
178
|
+
|
|
179
|
+
export interface TDataShape {
|
|
180
|
+
body?: unknown;
|
|
181
|
+
headers?: unknown;
|
|
182
|
+
path?: unknown;
|
|
183
|
+
query?: unknown;
|
|
184
|
+
url: string;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>;
|
|
188
|
+
|
|
189
|
+
export type Options<
|
|
190
|
+
TData extends TDataShape = TDataShape,
|
|
191
|
+
ThrowOnError extends boolean = boolean,
|
|
192
|
+
TResponse = unknown,
|
|
193
|
+
> = OmitKeys<
|
|
194
|
+
RequestOptions<TResponse, ThrowOnError>,
|
|
195
|
+
'body' | 'path' | 'query' | 'url'
|
|
196
|
+
> &
|
|
197
|
+
([TData] extends [never] ? unknown : Omit<TData, 'url'>);
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
+
|
|
3
|
+
import { getAuthToken } from '../core/auth.gen';
|
|
4
|
+
import type { QuerySerializerOptions } from '../core/bodySerializer.gen';
|
|
5
|
+
import {
|
|
6
|
+
serializeArrayParam,
|
|
7
|
+
serializeObjectParam,
|
|
8
|
+
serializePrimitiveParam,
|
|
9
|
+
} from '../core/pathSerializer.gen';
|
|
10
|
+
import { getUrl } from '../core/utils.gen';
|
|
11
|
+
import type { Client, ClientOptions, Config, RequestOptions } from './types.gen';
|
|
12
|
+
|
|
13
|
+
export const createQuerySerializer = <T = unknown>({
|
|
14
|
+
parameters = {},
|
|
15
|
+
...args
|
|
16
|
+
}: QuerySerializerOptions = {}) => {
|
|
17
|
+
const querySerializer = (queryParams: T) => {
|
|
18
|
+
const search: string[] = [];
|
|
19
|
+
if (queryParams && typeof queryParams === 'object') {
|
|
20
|
+
for (const name in queryParams) {
|
|
21
|
+
const value = queryParams[name];
|
|
22
|
+
|
|
23
|
+
if (value === undefined || value === null) {
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const options = parameters[name] || args;
|
|
28
|
+
|
|
29
|
+
if (Array.isArray(value)) {
|
|
30
|
+
const serializedArray = serializeArrayParam({
|
|
31
|
+
allowReserved: options.allowReserved,
|
|
32
|
+
explode: true,
|
|
33
|
+
name,
|
|
34
|
+
style: 'form',
|
|
35
|
+
value,
|
|
36
|
+
...options.array,
|
|
37
|
+
});
|
|
38
|
+
if (serializedArray) search.push(serializedArray);
|
|
39
|
+
} else if (typeof value === 'object') {
|
|
40
|
+
const serializedObject = serializeObjectParam({
|
|
41
|
+
allowReserved: options.allowReserved,
|
|
42
|
+
explode: true,
|
|
43
|
+
name,
|
|
44
|
+
style: 'deepObject',
|
|
45
|
+
value: value as Record<string, unknown>,
|
|
46
|
+
...options.object,
|
|
47
|
+
});
|
|
48
|
+
if (serializedObject) search.push(serializedObject);
|
|
49
|
+
} else {
|
|
50
|
+
const serializedPrimitive = serializePrimitiveParam({
|
|
51
|
+
allowReserved: options.allowReserved,
|
|
52
|
+
name,
|
|
53
|
+
value: value as string,
|
|
54
|
+
});
|
|
55
|
+
if (serializedPrimitive) search.push(serializedPrimitive);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return search.join('&');
|
|
60
|
+
};
|
|
61
|
+
return querySerializer;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const checkForExistence = (
|
|
65
|
+
options: Pick<RequestOptions, 'auth' | 'query'> & {
|
|
66
|
+
headers: Record<any, unknown>;
|
|
67
|
+
},
|
|
68
|
+
name?: string,
|
|
69
|
+
): boolean => {
|
|
70
|
+
if (!name) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
if (name in options.headers || options.query?.[name]) {
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
if (
|
|
77
|
+
'Cookie' in options.headers &&
|
|
78
|
+
options.headers['Cookie'] &&
|
|
79
|
+
typeof options.headers['Cookie'] === 'string'
|
|
80
|
+
) {
|
|
81
|
+
return options.headers['Cookie'].includes(`${name}=`);
|
|
82
|
+
}
|
|
83
|
+
return false;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export const setAuthParams = async ({
|
|
87
|
+
security,
|
|
88
|
+
...options
|
|
89
|
+
}: Pick<Required<RequestOptions>, 'security'> &
|
|
90
|
+
Pick<RequestOptions, 'auth' | 'query'> & {
|
|
91
|
+
headers: Record<any, unknown>;
|
|
92
|
+
}) => {
|
|
93
|
+
for (const auth of security) {
|
|
94
|
+
if (checkForExistence(options, auth.name)) {
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
const token = await getAuthToken(auth, options.auth);
|
|
98
|
+
|
|
99
|
+
if (!token) {
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const name = auth.name ?? 'Authorization';
|
|
104
|
+
|
|
105
|
+
switch (auth.in) {
|
|
106
|
+
case 'query':
|
|
107
|
+
if (!options.query) {
|
|
108
|
+
options.query = {};
|
|
109
|
+
}
|
|
110
|
+
options.query[name] = token;
|
|
111
|
+
break;
|
|
112
|
+
case 'cookie': {
|
|
113
|
+
const value = `${name}=${token}`;
|
|
114
|
+
if ('Cookie' in options.headers && options.headers['Cookie']) {
|
|
115
|
+
options.headers['Cookie'] = `${options.headers['Cookie']}; ${value}`;
|
|
116
|
+
} else {
|
|
117
|
+
options.headers['Cookie'] = value;
|
|
118
|
+
}
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
case 'header':
|
|
122
|
+
default:
|
|
123
|
+
options.headers[name] = token;
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
export const buildUrl: Client['buildUrl'] = (options) => {
|
|
130
|
+
const instanceBaseUrl = options.axios?.defaults?.baseURL;
|
|
131
|
+
|
|
132
|
+
const baseUrl =
|
|
133
|
+
!!options.baseURL && typeof options.baseURL === 'string'
|
|
134
|
+
? options.baseURL
|
|
135
|
+
: instanceBaseUrl;
|
|
136
|
+
|
|
137
|
+
return getUrl({
|
|
138
|
+
baseUrl: baseUrl as string,
|
|
139
|
+
path: options.path,
|
|
140
|
+
// let `paramsSerializer()` handle query params if it exists
|
|
141
|
+
query: !options.paramsSerializer ? options.query : undefined,
|
|
142
|
+
querySerializer:
|
|
143
|
+
typeof options.querySerializer === 'function'
|
|
144
|
+
? options.querySerializer
|
|
145
|
+
: createQuerySerializer(options.querySerializer),
|
|
146
|
+
url: options.url,
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
export const mergeConfigs = (a: Config, b: Config): Config => {
|
|
151
|
+
const config = { ...a, ...b };
|
|
152
|
+
config.headers = mergeHeaders(a.headers, b.headers);
|
|
153
|
+
return config;
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Special Axios headers keywords allowing to set headers by request method.
|
|
158
|
+
*/
|
|
159
|
+
export const axiosHeadersKeywords = [
|
|
160
|
+
'common',
|
|
161
|
+
'delete',
|
|
162
|
+
'get',
|
|
163
|
+
'head',
|
|
164
|
+
'patch',
|
|
165
|
+
'post',
|
|
166
|
+
'put',
|
|
167
|
+
] as const;
|
|
168
|
+
|
|
169
|
+
export const mergeHeaders = (
|
|
170
|
+
...headers: Array<Required<Config>['headers'] | undefined>
|
|
171
|
+
): Record<any, unknown> => {
|
|
172
|
+
const mergedHeaders: Record<any, unknown> = {};
|
|
173
|
+
for (const header of headers) {
|
|
174
|
+
if (!header || typeof header !== 'object') {
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const iterator = Object.entries(header);
|
|
179
|
+
|
|
180
|
+
for (const [key, value] of iterator) {
|
|
181
|
+
if (
|
|
182
|
+
axiosHeadersKeywords.includes(
|
|
183
|
+
key as (typeof axiosHeadersKeywords)[number],
|
|
184
|
+
) &&
|
|
185
|
+
typeof value === 'object'
|
|
186
|
+
) {
|
|
187
|
+
mergedHeaders[key] = {
|
|
188
|
+
...(mergedHeaders[key] as Record<any, unknown>),
|
|
189
|
+
...value,
|
|
190
|
+
};
|
|
191
|
+
} else if (value === null) {
|
|
192
|
+
delete mergedHeaders[key];
|
|
193
|
+
} else if (Array.isArray(value)) {
|
|
194
|
+
for (const v of value) {
|
|
195
|
+
// @ts-expect-error
|
|
196
|
+
mergedHeaders[key] = [...(mergedHeaders[key] ?? []), v as string];
|
|
197
|
+
}
|
|
198
|
+
} else if (value !== undefined) {
|
|
199
|
+
// assume object headers are meant to be JSON stringified, i.e. their
|
|
200
|
+
// content value in OpenAPI specification is 'application/json'
|
|
201
|
+
mergedHeaders[key] =
|
|
202
|
+
typeof value === 'object' ? JSON.stringify(value) : (value as string);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return mergedHeaders;
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
export const createConfig = <T extends ClientOptions = ClientOptions>(
|
|
210
|
+
override: Config<Omit<ClientOptions, keyof T> & T> = {},
|
|
211
|
+
): Config<Omit<ClientOptions, keyof T> & T> => ({
|
|
212
|
+
...override,
|
|
213
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
+
|
|
3
|
+
import { createClientConfig } from '@/openapi-client-config.ts';
|
|
4
|
+
|
|
5
|
+
import { type ClientOptions, type Config, createClient, createConfig } from './client';
|
|
6
|
+
import type { ClientOptions as ClientOptions2 } from './types.gen';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The `createClientConfig()` function will be called on client initialization
|
|
10
|
+
* and the returned object will become the client's initial configuration.
|
|
11
|
+
*
|
|
12
|
+
* You may want to initialize your client this way instead of calling
|
|
13
|
+
* `setConfig()`. This is useful for example if you're using Next.js
|
|
14
|
+
* to ensure your client always has the correct values.
|
|
15
|
+
*/
|
|
16
|
+
export type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>;
|
|
17
|
+
|
|
18
|
+
export const client = createClient(createClientConfig(createConfig<ClientOptions2>({ baseURL: 'https://sandbox.beta.kodly.dev/proxy/95-2' })));
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
+
|
|
3
|
+
export type AuthToken = string | undefined;
|
|
4
|
+
|
|
5
|
+
export interface Auth {
|
|
6
|
+
/**
|
|
7
|
+
* Which part of the request do we use to send the auth?
|
|
8
|
+
*
|
|
9
|
+
* @default 'header'
|
|
10
|
+
*/
|
|
11
|
+
in?: 'header' | 'query' | 'cookie';
|
|
12
|
+
/**
|
|
13
|
+
* Header or query parameter name.
|
|
14
|
+
*
|
|
15
|
+
* @default 'Authorization'
|
|
16
|
+
*/
|
|
17
|
+
name?: string;
|
|
18
|
+
scheme?: 'basic' | 'bearer';
|
|
19
|
+
type: 'apiKey' | 'http';
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const getAuthToken = async (
|
|
23
|
+
auth: Auth,
|
|
24
|
+
callback: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken,
|
|
25
|
+
): Promise<string | undefined> => {
|
|
26
|
+
const token =
|
|
27
|
+
typeof callback === 'function' ? await callback(auth) : callback;
|
|
28
|
+
|
|
29
|
+
if (!token) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (auth.scheme === 'bearer') {
|
|
34
|
+
return `Bearer ${token}`;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (auth.scheme === 'basic') {
|
|
38
|
+
return `Basic ${btoa(token)}`;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return token;
|
|
42
|
+
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
ArrayStyle,
|
|
5
|
+
ObjectStyle,
|
|
6
|
+
SerializerOptions,
|
|
7
|
+
} from './pathSerializer.gen';
|
|
8
|
+
|
|
9
|
+
export type QuerySerializer = (query: Record<string, unknown>) => string;
|
|
10
|
+
|
|
11
|
+
export type BodySerializer = (body: any) => any;
|
|
12
|
+
|
|
13
|
+
type QuerySerializerOptionsObject = {
|
|
14
|
+
allowReserved?: boolean;
|
|
15
|
+
array?: Partial<SerializerOptions<ArrayStyle>>;
|
|
16
|
+
object?: Partial<SerializerOptions<ObjectStyle>>;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export type QuerySerializerOptions = QuerySerializerOptionsObject & {
|
|
20
|
+
/**
|
|
21
|
+
* Per-parameter serialization overrides. When provided, these settings
|
|
22
|
+
* override the global array/object settings for specific parameter names.
|
|
23
|
+
*/
|
|
24
|
+
parameters?: Record<string, QuerySerializerOptionsObject>;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const serializeFormDataPair = (
|
|
28
|
+
data: FormData,
|
|
29
|
+
key: string,
|
|
30
|
+
value: unknown,
|
|
31
|
+
): void => {
|
|
32
|
+
if (typeof value === 'string' || value instanceof Blob) {
|
|
33
|
+
data.append(key, value);
|
|
34
|
+
} else if (value instanceof Date) {
|
|
35
|
+
data.append(key, value.toISOString());
|
|
36
|
+
} else {
|
|
37
|
+
data.append(key, JSON.stringify(value));
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const serializeUrlSearchParamsPair = (
|
|
42
|
+
data: URLSearchParams,
|
|
43
|
+
key: string,
|
|
44
|
+
value: unknown,
|
|
45
|
+
): void => {
|
|
46
|
+
if (typeof value === 'string') {
|
|
47
|
+
data.append(key, value);
|
|
48
|
+
} else {
|
|
49
|
+
data.append(key, JSON.stringify(value));
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export const formDataBodySerializer = {
|
|
54
|
+
bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>(
|
|
55
|
+
body: T,
|
|
56
|
+
): FormData => {
|
|
57
|
+
const data = new FormData();
|
|
58
|
+
|
|
59
|
+
Object.entries(body).forEach(([key, value]) => {
|
|
60
|
+
if (value === undefined || value === null) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (Array.isArray(value)) {
|
|
64
|
+
value.forEach((v) => serializeFormDataPair(data, key, v));
|
|
65
|
+
} else {
|
|
66
|
+
serializeFormDataPair(data, key, value);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
return data;
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export const jsonBodySerializer = {
|
|
75
|
+
bodySerializer: <T>(body: T): string =>
|
|
76
|
+
JSON.stringify(body, (_key, value) =>
|
|
77
|
+
typeof value === 'bigint' ? value.toString() : value,
|
|
78
|
+
),
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export const urlSearchParamsBodySerializer = {
|
|
82
|
+
bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>(
|
|
83
|
+
body: T,
|
|
84
|
+
): string => {
|
|
85
|
+
const data = new URLSearchParams();
|
|
86
|
+
|
|
87
|
+
Object.entries(body).forEach(([key, value]) => {
|
|
88
|
+
if (value === undefined || value === null) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
if (Array.isArray(value)) {
|
|
92
|
+
value.forEach((v) => serializeUrlSearchParamsPair(data, key, v));
|
|
93
|
+
} else {
|
|
94
|
+
serializeUrlSearchParamsPair(data, key, value);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
return data.toString();
|
|
99
|
+
},
|
|
100
|
+
};
|