@djangocfg/api 2.1.356 → 2.1.357
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/README.md +53 -632
- package/dist/auth-server.cjs +717 -200
- package/dist/auth-server.cjs.map +1 -1
- package/dist/auth-server.mjs +717 -200
- package/dist/auth-server.mjs.map +1 -1
- package/dist/auth.cjs +843 -783
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +58 -37
- package/dist/auth.d.ts +58 -37
- package/dist/auth.mjs +846 -784
- package/dist/auth.mjs.map +1 -1
- package/dist/clients.cjs +1427 -0
- package/dist/clients.cjs.map +1 -1
- package/dist/clients.d.cts +1686 -0
- package/dist/clients.d.ts +1686 -0
- package/dist/clients.mjs +1427 -0
- package/dist/clients.mjs.map +1 -1
- package/dist/hooks.cjs +1277 -1924
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.cts +18 -1206
- package/dist/hooks.d.ts +18 -1206
- package/dist/hooks.mjs +1253 -1900
- package/dist/hooks.mjs.map +1 -1
- package/dist/index.cjs +545 -1232
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1389 -1455
- package/dist/index.d.ts +1389 -1455
- package/dist/index.mjs +545 -1232
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -2
- package/src/_api/generated/_cfg_accounts/api.ts +11 -3
- package/src/_api/generated/_cfg_accounts/hooks/index.ts +3 -0
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsApiKeyRegenerateCreate.ts +64 -0
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsApiKeyRetrieve.ts +65 -0
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsApiKeyTestCreate.ts +64 -0
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthConnectionsList.ts +43 -3
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthDisconnectCreate.ts +43 -3
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthGithubAuthorizeCreate.ts +43 -3
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthGithubCallbackCreate.ts +43 -3
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthProvidersRetrieve.ts +43 -3
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOtpRequestCreate.ts +43 -3
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOtpVerifyCreate.ts +43 -3
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileAvatarCreate.ts +43 -3
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileDeleteCreate.ts +43 -3
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfilePartialPartialUpdate.ts +43 -3
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfilePartialUpdate.ts +43 -3
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileRetrieve.ts +43 -3
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileUpdatePartialUpdate.ts +43 -3
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileUpdateUpdate.ts +43 -3
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsTokenRefreshCreate.ts +43 -3
- package/src/_api/generated/_cfg_accounts/index.ts +1 -1
- package/src/_api/generated/_cfg_accounts/schemas/APIKey.ts +13 -0
- package/src/_api/generated/_cfg_accounts/schemas/APIKeyRegenerate.ts +12 -0
- package/src/_api/generated/_cfg_accounts/schemas/APIKeyRequest.ts +13 -0
- package/src/_api/generated/{_cfg_totp/schemas/DeviceListStatusEnum.ts → _cfg_accounts/schemas/APIKeyTestRequest.ts} +4 -2
- package/src/_api/generated/_cfg_accounts/schemas/APIKeyTestResult.ts +12 -0
- package/src/_api/generated/_cfg_accounts/schemas/AccountDeleteResponse.ts +1 -1
- package/src/_api/generated/_cfg_accounts/schemas/CentrifugoToken.ts +2 -2
- package/src/_api/generated/_cfg_accounts/schemas/CfgUserUpdateRequest.ts +3 -2
- package/src/_api/generated/_cfg_accounts/schemas/OAuthCallbackRequestRequest.ts +1 -1
- package/src/_api/generated/_cfg_accounts/schemas/OAuthConnection.ts +6 -6
- package/src/_api/generated/_cfg_accounts/schemas/OAuthDisconnectRequestRequest.ts +2 -2
- package/src/_api/generated/_cfg_accounts/schemas/{ProviderEnum.ts → OAuthProviderEnum.ts} +2 -2
- package/src/_api/generated/_cfg_accounts/schemas/OAuthTokenResponse.ts +5 -5
- package/src/_api/generated/_cfg_accounts/schemas/OTPVerifyRequest.ts +1 -1
- package/src/_api/generated/_cfg_accounts/schemas/OTPVerifyResponse.ts +3 -3
- package/src/_api/generated/_cfg_accounts/schemas/PatchedCfgUserUpdateRequest.ts +3 -2
- package/src/_api/generated/_cfg_accounts/schemas/User.ts +12 -10
- package/src/_api/generated/_cfg_accounts/schemas/cfg_accounts_oauth_connections_response_200_AutoRef.ts +10 -0
- package/src/_api/generated/_cfg_accounts/schemas/cfg_accounts_oauth_disconnect_response_200_AutoRef.ts +11 -0
- package/src/_api/generated/_cfg_accounts/schemas/index.ts +8 -1
- package/src/_api/generated/_cfg_centrifugo/api.ts +3 -3
- package/src/_api/generated/_cfg_centrifugo/hooks/useCfgCentrifugoAuthTokenRetrieve.ts +43 -3
- package/src/_api/generated/_cfg_centrifugo/index.ts +1 -1
- package/src/_api/generated/_cfg_centrifugo/schemas/ConnectionTokenResponse.ts +2 -2
- package/src/_api/generated/_cfg_totp/api.ts +9 -3
- package/src/_api/generated/_cfg_totp/hooks/useCfgTotpBackupCodesRegenerateCreate.ts +43 -3
- package/src/_api/generated/_cfg_totp/hooks/useCfgTotpBackupCodesRetrieve.ts +43 -3
- package/src/_api/generated/_cfg_totp/hooks/useCfgTotpDevicesDestroy.ts +7 -3
- package/src/_api/generated/_cfg_totp/hooks/useCfgTotpDevicesRetrieve.ts +43 -3
- package/src/_api/generated/_cfg_totp/hooks/useCfgTotpDisableCreate.ts +43 -3
- package/src/_api/generated/_cfg_totp/hooks/useCfgTotpSetupConfirmCreate.ts +43 -3
- package/src/_api/generated/_cfg_totp/hooks/useCfgTotpSetupCreate.ts +43 -3
- package/src/_api/generated/_cfg_totp/hooks/useCfgTotpVerifyBackupCreate.ts +43 -3
- package/src/_api/generated/_cfg_totp/hooks/useCfgTotpVerifyCreate.ts +43 -3
- package/src/_api/generated/_cfg_totp/index.ts +1 -1
- package/src/_api/generated/_cfg_totp/schemas/ConfirmSetupRequest.ts +1 -1
- package/src/_api/generated/_cfg_totp/schemas/ConfirmSetupResponse.ts +1 -1
- package/src/_api/generated/_cfg_totp/schemas/DeviceList.ts +5 -5
- package/src/_api/generated/_cfg_totp/schemas/DeviceStatusEnum.ts +9 -0
- package/src/_api/generated/_cfg_totp/schemas/SetupResponse.ts +2 -2
- package/src/_api/generated/_cfg_totp/schemas/TotpVerifyUser.ts +11 -9
- package/src/_api/generated/_cfg_totp/schemas/VerifyBackupRequest.ts +1 -1
- package/src/_api/generated/_cfg_totp/schemas/VerifyRequest.ts +1 -1
- package/src/_api/generated/_cfg_totp/schemas/VerifyResponse.ts +2 -2
- package/src/_api/generated/_cfg_totp/schemas/cfg_totp_disable_response_200_AutoRef.ts +9 -0
- package/src/_api/generated/_cfg_totp/schemas/index.ts +2 -1
- package/src/_api/generated/index.ts +3 -1
- package/src/_api/generated/sdk.gen.ts +80 -813
- package/src/_api/generated/types.gen.ts +320 -159
- package/src/auth/context/AccountsContext.tsx +18 -6
- package/src/auth/context/AuthContext.tsx +11 -3
- package/src/auth/hooks/useDeleteAccount.ts +2 -2
- package/src/auth/hooks/useGithubAuth.ts +3 -3
- package/src/auth/hooks/useTokenRefresh.ts +2 -2
- package/src/auth/hooks/useTwoFactor.ts +3 -3
- package/src/auth/hooks/useTwoFactorSetup.ts +3 -3
- package/src/auth/hooks/useTwoFactorStatus.ts +3 -3
- package/src/auth/middlewares/tokenRefresh.ts +2 -2
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useApiKey.ts +73 -0
- package/src/index.ts +12 -16
package/dist/hooks.mjs
CHANGED
|
@@ -1,1634 +1,866 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use client";
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
4
|
|
|
6
|
-
// src/
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
// src/_api/generated/cfg_accounts/_utils/fetchers/accounts__auth.ts
|
|
10
|
-
import { consola as consola4 } from "consola";
|
|
11
|
-
|
|
12
|
-
// src/_api/generated/cfg_accounts/_utils/schemas/TokenRefresh.schema.ts
|
|
13
|
-
import { z } from "zod";
|
|
14
|
-
var TokenRefreshSchema = z.object({
|
|
15
|
-
access: z.string(),
|
|
16
|
-
refresh: z.string()
|
|
17
|
-
});
|
|
5
|
+
// src/hooks/useApiKey.ts
|
|
6
|
+
import { useCallback, useState } from "react";
|
|
18
7
|
|
|
19
|
-
// src/_api/generated/
|
|
20
|
-
|
|
21
|
-
static {
|
|
22
|
-
__name(this, "Auth");
|
|
23
|
-
}
|
|
24
|
-
client;
|
|
25
|
-
constructor(client) {
|
|
26
|
-
this.client = client;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Refresh JWT token.
|
|
30
|
-
*/
|
|
31
|
-
async accountsTokenRefreshCreate(data) {
|
|
32
|
-
const response = await this.client.request("POST", "/cfg/accounts/token/refresh/", { body: data });
|
|
33
|
-
return response;
|
|
34
|
-
}
|
|
35
|
-
};
|
|
8
|
+
// src/_api/generated/_cfg_accounts/hooks/useCfgAccountsApiKeyRegenerateCreate.ts
|
|
9
|
+
import useSWRMutation from "swr/mutation";
|
|
36
10
|
|
|
37
|
-
// src/_api/generated/
|
|
38
|
-
var
|
|
39
|
-
|
|
40
|
-
__name(this, "Oauth");
|
|
41
|
-
}
|
|
42
|
-
client;
|
|
43
|
-
constructor(client) {
|
|
44
|
-
this.client = client;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* List OAuth connections
|
|
48
|
-
*
|
|
49
|
-
* Get all OAuth connections for the current user.
|
|
50
|
-
*/
|
|
51
|
-
async accountsOauthConnectionsList() {
|
|
52
|
-
const response = await this.client.request("GET", "/cfg/accounts/oauth/connections/");
|
|
53
|
-
return response.results || response;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Disconnect OAuth provider
|
|
57
|
-
*
|
|
58
|
-
* Remove OAuth connection for the specified provider.
|
|
59
|
-
*/
|
|
60
|
-
async accountsOauthDisconnectCreate(data) {
|
|
61
|
-
const response = await this.client.request("POST", "/cfg/accounts/oauth/disconnect/", { body: data });
|
|
62
|
-
return response;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Start GitHub OAuth
|
|
66
|
-
*
|
|
67
|
-
* Generate GitHub OAuth authorization URL. Redirect user to this URL to
|
|
68
|
-
* start authentication.
|
|
69
|
-
*/
|
|
70
|
-
async accountsOauthGithubAuthorizeCreate(data) {
|
|
71
|
-
const response = await this.client.request("POST", "/cfg/accounts/oauth/github/authorize/", { body: data });
|
|
72
|
-
return response;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Complete GitHub OAuth
|
|
76
|
-
*
|
|
77
|
-
* Exchange authorization code for JWT tokens. Call this after GitHub
|
|
78
|
-
* redirects back with code.
|
|
79
|
-
*/
|
|
80
|
-
async accountsOauthGithubCallbackCreate(data) {
|
|
81
|
-
const response = await this.client.request("POST", "/cfg/accounts/oauth/github/callback/", { body: data });
|
|
82
|
-
return response;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* List OAuth providers
|
|
86
|
-
*
|
|
87
|
-
* Get list of available OAuth providers for authentication.
|
|
88
|
-
*/
|
|
89
|
-
async accountsOauthProvidersRetrieve() {
|
|
90
|
-
const response = await this.client.request("GET", "/cfg/accounts/oauth/providers/");
|
|
91
|
-
return response;
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
// src/_api/generated/cfg_accounts/accounts__user_profile/client.ts
|
|
96
|
-
var UserProfile = class {
|
|
97
|
-
static {
|
|
98
|
-
__name(this, "UserProfile");
|
|
99
|
-
}
|
|
100
|
-
client;
|
|
101
|
-
constructor(client) {
|
|
102
|
-
this.client = client;
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Get current user profile
|
|
106
|
-
*
|
|
107
|
-
* Retrieve the current authenticated user's profile information.
|
|
108
|
-
*/
|
|
109
|
-
async accountsProfileRetrieve() {
|
|
110
|
-
const response = await this.client.request("GET", "/cfg/accounts/profile/");
|
|
111
|
-
return response;
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Upload user avatar
|
|
115
|
-
*
|
|
116
|
-
* Upload avatar image for the current authenticated user. Accepts
|
|
117
|
-
* multipart/form-data with 'avatar' field.
|
|
118
|
-
*/
|
|
119
|
-
async accountsProfileAvatarCreate(data) {
|
|
120
|
-
const formData = new FormData();
|
|
121
|
-
formData.append("avatar", data.avatar);
|
|
122
|
-
const response = await this.client.request("POST", "/cfg/accounts/profile/avatar/", { formData });
|
|
123
|
-
return response;
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Delete user account
|
|
127
|
-
*
|
|
128
|
-
* Permanently delete the current user's account. This operation: -
|
|
129
|
-
* Deactivates the account (user cannot log in) - Anonymizes personal data
|
|
130
|
-
* (GDPR compliance) - Frees up the email address for re-registration -
|
|
131
|
-
* Preserves audit trail The account can be restored by an administrator if
|
|
132
|
-
* needed.
|
|
133
|
-
*/
|
|
134
|
-
async accountsProfileDeleteCreate() {
|
|
135
|
-
const response = await this.client.request("POST", "/cfg/accounts/profile/delete/");
|
|
136
|
-
return response;
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Partial update user profile
|
|
140
|
-
*
|
|
141
|
-
* Partially update the current authenticated user's profile information.
|
|
142
|
-
* Supports avatar upload.
|
|
143
|
-
*/
|
|
144
|
-
async accountsProfilePartialUpdate(data) {
|
|
145
|
-
const response = await this.client.request("PUT", "/cfg/accounts/profile/partial/", { body: data });
|
|
146
|
-
return response;
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Partial update user profile
|
|
150
|
-
*
|
|
151
|
-
* Partially update the current authenticated user's profile information.
|
|
152
|
-
* Supports avatar upload.
|
|
153
|
-
*/
|
|
154
|
-
async accountsProfilePartialPartialUpdate(data) {
|
|
155
|
-
const response = await this.client.request("PATCH", "/cfg/accounts/profile/partial/", { body: data });
|
|
156
|
-
return response;
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Update user profile
|
|
160
|
-
*
|
|
161
|
-
* Update the current authenticated user's profile information.
|
|
162
|
-
*/
|
|
163
|
-
async accountsProfileUpdateUpdate(data) {
|
|
164
|
-
const response = await this.client.request("PUT", "/cfg/accounts/profile/update/", { body: data });
|
|
165
|
-
return response;
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* Update user profile
|
|
169
|
-
*
|
|
170
|
-
* Update the current authenticated user's profile information.
|
|
171
|
-
*/
|
|
172
|
-
async accountsProfileUpdatePartialUpdate(data) {
|
|
173
|
-
const response = await this.client.request("PATCH", "/cfg/accounts/profile/update/", { body: data });
|
|
174
|
-
return response;
|
|
175
|
-
}
|
|
11
|
+
// src/_api/generated/core/bodySerializer.gen.ts
|
|
12
|
+
var jsonBodySerializer = {
|
|
13
|
+
bodySerializer: /* @__PURE__ */ __name((body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value), "bodySerializer")
|
|
176
14
|
};
|
|
177
15
|
|
|
178
|
-
// src/_api/generated/
|
|
179
|
-
var
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
constructor(client) {
|
|
185
|
-
this.client = client;
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* Request OTP code to email.
|
|
189
|
-
*/
|
|
190
|
-
async otpRequestCreate(data) {
|
|
191
|
-
const response = await this.client.request("POST", "/cfg/accounts/otp/request/", { body: data });
|
|
192
|
-
return response;
|
|
193
|
-
}
|
|
194
|
-
/**
|
|
195
|
-
* Verify OTP code and return JWT tokens or 2FA session. If user has 2FA
|
|
196
|
-
* enabled: - Returns requires_2fa=True with session_id - Client must
|
|
197
|
-
* complete 2FA verification at /cfg/totp/verify/ If user has no 2FA: -
|
|
198
|
-
* Returns JWT tokens and user data directly
|
|
199
|
-
*/
|
|
200
|
-
async otpVerifyCreate(data) {
|
|
201
|
-
const response = await this.client.request("POST", "/cfg/accounts/otp/verify/", { body: data });
|
|
202
|
-
return response;
|
|
203
|
-
}
|
|
16
|
+
// src/_api/generated/core/params.gen.ts
|
|
17
|
+
var extraPrefixesMap = {
|
|
18
|
+
$body_: "body",
|
|
19
|
+
$headers_: "headers",
|
|
20
|
+
$path_: "path",
|
|
21
|
+
$query_: "query"
|
|
204
22
|
};
|
|
23
|
+
var extraPrefixes = Object.entries(extraPrefixesMap);
|
|
205
24
|
|
|
206
|
-
// src/_api/generated/
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
25
|
+
// src/_api/generated/core/serverSentEvents.gen.ts
|
|
26
|
+
function createSseClient({
|
|
27
|
+
onRequest,
|
|
28
|
+
onSseError,
|
|
29
|
+
onSseEvent,
|
|
30
|
+
responseTransformer,
|
|
31
|
+
responseValidator,
|
|
32
|
+
sseDefaultRetryDelay,
|
|
33
|
+
sseMaxRetryAttempts,
|
|
34
|
+
sseMaxRetryDelay,
|
|
35
|
+
sseSleepFn,
|
|
36
|
+
url,
|
|
37
|
+
...options
|
|
38
|
+
}) {
|
|
39
|
+
let lastEventId;
|
|
40
|
+
const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
41
|
+
const createStream = /* @__PURE__ */ __name(async function* () {
|
|
42
|
+
let retryDelay = sseDefaultRetryDelay ?? 3e3;
|
|
43
|
+
let attempt = 0;
|
|
44
|
+
const signal = options.signal ?? new AbortController().signal;
|
|
45
|
+
while (true) {
|
|
46
|
+
if (signal.aborted) break;
|
|
47
|
+
attempt++;
|
|
48
|
+
const headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
|
|
49
|
+
if (lastEventId !== void 0) {
|
|
50
|
+
headers.set("Last-Event-ID", lastEventId);
|
|
224
51
|
}
|
|
225
|
-
}
|
|
226
|
-
const finalHeaders = { ...headers };
|
|
227
|
-
let requestBody;
|
|
228
|
-
if (formData) {
|
|
229
|
-
requestBody = formData;
|
|
230
|
-
} else if (binaryBody) {
|
|
231
|
-
finalHeaders["Content-Type"] = "application/octet-stream";
|
|
232
|
-
requestBody = binaryBody;
|
|
233
|
-
} else if (body) {
|
|
234
|
-
finalHeaders["Content-Type"] = "application/json";
|
|
235
|
-
requestBody = JSON.stringify(body);
|
|
236
|
-
}
|
|
237
|
-
const response = await fetch(finalUrl, {
|
|
238
|
-
method,
|
|
239
|
-
headers: finalHeaders,
|
|
240
|
-
body: requestBody,
|
|
241
|
-
credentials: "include"
|
|
242
|
-
// Include Django session cookies
|
|
243
|
-
});
|
|
244
|
-
let data = null;
|
|
245
|
-
const contentType = response.headers.get("content-type") ?? "";
|
|
246
|
-
if (response.status !== 204) {
|
|
247
|
-
if (responseType === "blob") {
|
|
248
|
-
data = await response.blob();
|
|
249
|
-
} else if (responseType === "text") {
|
|
250
|
-
data = await response.text();
|
|
251
|
-
} else if (responseType === "json") {
|
|
252
|
-
data = await response.json();
|
|
253
|
-
} else if (contentType.includes("application/json")) {
|
|
254
|
-
data = await response.json();
|
|
255
|
-
} else if (contentType.startsWith("text/")) {
|
|
256
|
-
data = await response.text();
|
|
257
|
-
} else {
|
|
258
|
-
data = await response.blob();
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
const responseHeaders = {};
|
|
262
|
-
response.headers.forEach((value, key) => {
|
|
263
|
-
responseHeaders[key] = value;
|
|
264
|
-
});
|
|
265
|
-
return {
|
|
266
|
-
data,
|
|
267
|
-
status: response.status,
|
|
268
|
-
statusText: response.statusText,
|
|
269
|
-
headers: responseHeaders
|
|
270
|
-
};
|
|
271
|
-
}
|
|
272
|
-
};
|
|
273
|
-
|
|
274
|
-
// src/_api/generated/cfg_accounts/errors.ts
|
|
275
|
-
var APIError = class extends Error {
|
|
276
|
-
constructor(statusCode, statusText, response, url, message) {
|
|
277
|
-
super(message || `HTTP ${statusCode}: ${statusText}`);
|
|
278
|
-
this.statusCode = statusCode;
|
|
279
|
-
this.statusText = statusText;
|
|
280
|
-
this.response = response;
|
|
281
|
-
this.url = url;
|
|
282
|
-
this.name = "APIError";
|
|
283
|
-
}
|
|
284
|
-
static {
|
|
285
|
-
__name(this, "APIError");
|
|
286
|
-
}
|
|
287
|
-
/**
|
|
288
|
-
* Get error details from response.
|
|
289
|
-
* DRF typically returns: { "detail": "Error message" } or { "field": ["error1", "error2"] }
|
|
290
|
-
*/
|
|
291
|
-
get details() {
|
|
292
|
-
if (typeof this.response === "object" && this.response !== null) {
|
|
293
|
-
return this.response;
|
|
294
|
-
}
|
|
295
|
-
return null;
|
|
296
|
-
}
|
|
297
|
-
/**
|
|
298
|
-
* Get field-specific validation errors from DRF.
|
|
299
|
-
* Returns: { "field_name": ["error1", "error2"], ... }
|
|
300
|
-
*/
|
|
301
|
-
get fieldErrors() {
|
|
302
|
-
const details = this.details;
|
|
303
|
-
if (!details) return null;
|
|
304
|
-
const fieldErrors = {};
|
|
305
|
-
for (const [key, value] of Object.entries(details)) {
|
|
306
|
-
if (Array.isArray(value)) {
|
|
307
|
-
fieldErrors[key] = value;
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
return Object.keys(fieldErrors).length > 0 ? fieldErrors : null;
|
|
311
|
-
}
|
|
312
|
-
/**
|
|
313
|
-
* Get single error message from DRF.
|
|
314
|
-
* Checks for "detail", "message", or first field error.
|
|
315
|
-
*/
|
|
316
|
-
get errorMessage() {
|
|
317
|
-
const details = this.details;
|
|
318
|
-
if (!details) return this.message;
|
|
319
|
-
if (details.detail) {
|
|
320
|
-
return Array.isArray(details.detail) ? details.detail.join(", ") : String(details.detail);
|
|
321
|
-
}
|
|
322
|
-
if (details.error) {
|
|
323
|
-
return String(details.error);
|
|
324
|
-
}
|
|
325
|
-
if (details.message) {
|
|
326
|
-
return String(details.message);
|
|
327
|
-
}
|
|
328
|
-
const fieldErrors = this.fieldErrors;
|
|
329
|
-
if (fieldErrors) {
|
|
330
|
-
const firstField = Object.keys(fieldErrors)[0];
|
|
331
|
-
if (firstField) {
|
|
332
|
-
return `${firstField}: ${fieldErrors[firstField]?.join(", ")}`;
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
return this.message;
|
|
336
|
-
}
|
|
337
|
-
// Helper methods for common HTTP status codes
|
|
338
|
-
get isValidationError() {
|
|
339
|
-
return this.statusCode === 400;
|
|
340
|
-
}
|
|
341
|
-
get isAuthError() {
|
|
342
|
-
return this.statusCode === 401;
|
|
343
|
-
}
|
|
344
|
-
get isPermissionError() {
|
|
345
|
-
return this.statusCode === 403;
|
|
346
|
-
}
|
|
347
|
-
get isNotFoundError() {
|
|
348
|
-
return this.statusCode === 404;
|
|
349
|
-
}
|
|
350
|
-
get isServerError() {
|
|
351
|
-
return this.statusCode >= 500 && this.statusCode < 600;
|
|
352
|
-
}
|
|
353
|
-
};
|
|
354
|
-
var NetworkError = class extends Error {
|
|
355
|
-
constructor(message, url, originalError) {
|
|
356
|
-
super(message);
|
|
357
|
-
this.url = url;
|
|
358
|
-
this.originalError = originalError;
|
|
359
|
-
this.name = "NetworkError";
|
|
360
|
-
}
|
|
361
|
-
static {
|
|
362
|
-
__name(this, "NetworkError");
|
|
363
|
-
}
|
|
364
|
-
};
|
|
365
|
-
|
|
366
|
-
// src/_api/generated/cfg_accounts/logger.ts
|
|
367
|
-
import { createConsola } from "consola";
|
|
368
|
-
var DEFAULT_CONFIG = {
|
|
369
|
-
enabled: process.env.NODE_ENV !== "production",
|
|
370
|
-
logRequests: true,
|
|
371
|
-
logResponses: true,
|
|
372
|
-
logErrors: true,
|
|
373
|
-
logBodies: true,
|
|
374
|
-
logHeaders: false
|
|
375
|
-
};
|
|
376
|
-
var SENSITIVE_HEADERS = [
|
|
377
|
-
"authorization",
|
|
378
|
-
"cookie",
|
|
379
|
-
"set-cookie",
|
|
380
|
-
"x-api-key",
|
|
381
|
-
"x-csrf-token"
|
|
382
|
-
];
|
|
383
|
-
var APILogger = class {
|
|
384
|
-
static {
|
|
385
|
-
__name(this, "APILogger");
|
|
386
|
-
}
|
|
387
|
-
config;
|
|
388
|
-
consola;
|
|
389
|
-
constructor(config = {}) {
|
|
390
|
-
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
391
|
-
this.consola = config.consola || createConsola({
|
|
392
|
-
level: this.config.enabled ? 4 : 0
|
|
393
|
-
});
|
|
394
|
-
}
|
|
395
|
-
/**
|
|
396
|
-
* Enable logging
|
|
397
|
-
*/
|
|
398
|
-
enable() {
|
|
399
|
-
this.config.enabled = true;
|
|
400
|
-
}
|
|
401
|
-
/**
|
|
402
|
-
* Disable logging
|
|
403
|
-
*/
|
|
404
|
-
disable() {
|
|
405
|
-
this.config.enabled = false;
|
|
406
|
-
}
|
|
407
|
-
/**
|
|
408
|
-
* Update configuration
|
|
409
|
-
*/
|
|
410
|
-
setConfig(config) {
|
|
411
|
-
this.config = { ...this.config, ...config };
|
|
412
|
-
}
|
|
413
|
-
/**
|
|
414
|
-
* Filter sensitive headers
|
|
415
|
-
*/
|
|
416
|
-
filterHeaders(headers) {
|
|
417
|
-
if (!headers) return {};
|
|
418
|
-
const filtered = {};
|
|
419
|
-
Object.keys(headers).forEach((key) => {
|
|
420
|
-
const lowerKey = key.toLowerCase();
|
|
421
|
-
if (SENSITIVE_HEADERS.includes(lowerKey)) {
|
|
422
|
-
filtered[key] = "***";
|
|
423
|
-
} else {
|
|
424
|
-
filtered[key] = headers[key] || "";
|
|
425
|
-
}
|
|
426
|
-
});
|
|
427
|
-
return filtered;
|
|
428
|
-
}
|
|
429
|
-
/**
|
|
430
|
-
* Log request
|
|
431
|
-
*/
|
|
432
|
-
logRequest(request) {
|
|
433
|
-
if (!this.config.enabled || !this.config.logRequests) return;
|
|
434
|
-
const { method, url, headers, body } = request;
|
|
435
|
-
this.consola.start(`${method} ${url}`);
|
|
436
|
-
if (this.config.logHeaders && headers) {
|
|
437
|
-
this.consola.debug("Headers:", this.filterHeaders(headers));
|
|
438
|
-
}
|
|
439
|
-
if (this.config.logBodies && body) {
|
|
440
|
-
this.consola.debug("Body:", body);
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
/**
|
|
444
|
-
* Log response
|
|
445
|
-
*/
|
|
446
|
-
logResponse(request, response) {
|
|
447
|
-
if (!this.config.enabled || !this.config.logResponses) return;
|
|
448
|
-
const { method, url } = request;
|
|
449
|
-
const { status, statusText, data, duration } = response;
|
|
450
|
-
const statusColor = status >= 500 ? "red" : status >= 400 ? "yellow" : status >= 300 ? "cyan" : "green";
|
|
451
|
-
this.consola.success(
|
|
452
|
-
`${method} ${url} ${status} ${statusText} (${duration}ms)`
|
|
453
|
-
);
|
|
454
|
-
if (this.config.logBodies && data) {
|
|
455
|
-
this.consola.debug("Response:", data);
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
/**
|
|
459
|
-
* Log error
|
|
460
|
-
*/
|
|
461
|
-
logError(request, error) {
|
|
462
|
-
if (!this.config.enabled || !this.config.logErrors) return;
|
|
463
|
-
const { method, url } = request;
|
|
464
|
-
const { message, statusCode, fieldErrors, duration } = error;
|
|
465
|
-
this.consola.error(
|
|
466
|
-
`${method} ${url} ${statusCode || "Network"} Error (${duration}ms)`
|
|
467
|
-
);
|
|
468
|
-
this.consola.error("Message:", message);
|
|
469
|
-
if (fieldErrors && Object.keys(fieldErrors).length > 0) {
|
|
470
|
-
this.consola.error("Field Errors:");
|
|
471
|
-
Object.entries(fieldErrors).forEach(([field, errors]) => {
|
|
472
|
-
errors.forEach((err) => {
|
|
473
|
-
this.consola.error(` \u2022 ${field}: ${err}`);
|
|
474
|
-
});
|
|
475
|
-
});
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
/**
|
|
479
|
-
* Log general info
|
|
480
|
-
*/
|
|
481
|
-
info(message, ...args) {
|
|
482
|
-
if (!this.config.enabled) return;
|
|
483
|
-
this.consola.info(message, ...args);
|
|
484
|
-
}
|
|
485
|
-
/**
|
|
486
|
-
* Log warning
|
|
487
|
-
*/
|
|
488
|
-
warn(message, ...args) {
|
|
489
|
-
if (!this.config.enabled) return;
|
|
490
|
-
this.consola.warn(message, ...args);
|
|
491
|
-
}
|
|
492
|
-
/**
|
|
493
|
-
* Log error
|
|
494
|
-
*/
|
|
495
|
-
error(message, ...args) {
|
|
496
|
-
if (!this.config.enabled) return;
|
|
497
|
-
this.consola.error(message, ...args);
|
|
498
|
-
}
|
|
499
|
-
/**
|
|
500
|
-
* Log debug
|
|
501
|
-
*/
|
|
502
|
-
debug(message, ...args) {
|
|
503
|
-
if (!this.config.enabled) return;
|
|
504
|
-
this.consola.debug(message, ...args);
|
|
505
|
-
}
|
|
506
|
-
/**
|
|
507
|
-
* Log success
|
|
508
|
-
*/
|
|
509
|
-
success(message, ...args) {
|
|
510
|
-
if (!this.config.enabled) return;
|
|
511
|
-
this.consola.success(message, ...args);
|
|
512
|
-
}
|
|
513
|
-
/**
|
|
514
|
-
* Create a sub-logger with prefix
|
|
515
|
-
*/
|
|
516
|
-
withTag(tag) {
|
|
517
|
-
return this.consola.withTag(tag);
|
|
518
|
-
}
|
|
519
|
-
};
|
|
520
|
-
var defaultLogger = new APILogger();
|
|
521
|
-
|
|
522
|
-
// src/_api/generated/cfg_accounts/retry.ts
|
|
523
|
-
import pRetry, { AbortError } from "p-retry";
|
|
524
|
-
var DEFAULT_RETRY_CONFIG = {
|
|
525
|
-
retries: 3,
|
|
526
|
-
factor: 2,
|
|
527
|
-
minTimeout: 1e3,
|
|
528
|
-
maxTimeout: 6e4,
|
|
529
|
-
randomize: true,
|
|
530
|
-
onFailedAttempt: /* @__PURE__ */ __name(() => {
|
|
531
|
-
}, "onFailedAttempt")
|
|
532
|
-
};
|
|
533
|
-
function shouldRetry(error) {
|
|
534
|
-
if (error instanceof NetworkError) {
|
|
535
|
-
return true;
|
|
536
|
-
}
|
|
537
|
-
if (error instanceof APIError) {
|
|
538
|
-
const status = error.statusCode;
|
|
539
|
-
if (status >= 500 && status < 600) {
|
|
540
|
-
return true;
|
|
541
|
-
}
|
|
542
|
-
if (status === 429) {
|
|
543
|
-
return true;
|
|
544
|
-
}
|
|
545
|
-
return false;
|
|
546
|
-
}
|
|
547
|
-
return true;
|
|
548
|
-
}
|
|
549
|
-
__name(shouldRetry, "shouldRetry");
|
|
550
|
-
async function withRetry(fn, config) {
|
|
551
|
-
const finalConfig = { ...DEFAULT_RETRY_CONFIG, ...config };
|
|
552
|
-
return pRetry(
|
|
553
|
-
async () => {
|
|
554
52
|
try {
|
|
555
|
-
|
|
53
|
+
const requestInit = {
|
|
54
|
+
redirect: "follow",
|
|
55
|
+
...options,
|
|
56
|
+
body: options.serializedBody,
|
|
57
|
+
headers,
|
|
58
|
+
signal
|
|
59
|
+
};
|
|
60
|
+
let request = new Request(url, requestInit);
|
|
61
|
+
if (onRequest) {
|
|
62
|
+
request = await onRequest(url, requestInit);
|
|
63
|
+
}
|
|
64
|
+
const _fetch = options.fetch ?? globalThis.fetch;
|
|
65
|
+
const response = await _fetch(request);
|
|
66
|
+
if (!response.ok) throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
|
|
67
|
+
if (!response.body) throw new Error("No body in SSE response");
|
|
68
|
+
const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
|
|
69
|
+
let buffer = "";
|
|
70
|
+
const abortHandler = /* @__PURE__ */ __name(() => {
|
|
71
|
+
try {
|
|
72
|
+
reader.cancel();
|
|
73
|
+
} catch {
|
|
74
|
+
}
|
|
75
|
+
}, "abortHandler");
|
|
76
|
+
signal.addEventListener("abort", abortHandler);
|
|
77
|
+
try {
|
|
78
|
+
while (true) {
|
|
79
|
+
const { done, value } = await reader.read();
|
|
80
|
+
if (done) break;
|
|
81
|
+
buffer += value;
|
|
82
|
+
buffer = buffer.replace(/\r\n?/g, "\n");
|
|
83
|
+
const chunks = buffer.split("\n\n");
|
|
84
|
+
buffer = chunks.pop() ?? "";
|
|
85
|
+
for (const chunk of chunks) {
|
|
86
|
+
const lines = chunk.split("\n");
|
|
87
|
+
const dataLines = [];
|
|
88
|
+
let eventName;
|
|
89
|
+
for (const line of lines) {
|
|
90
|
+
if (line.startsWith("data:")) {
|
|
91
|
+
dataLines.push(line.replace(/^data:\s*/, ""));
|
|
92
|
+
} else if (line.startsWith("event:")) {
|
|
93
|
+
eventName = line.replace(/^event:\s*/, "");
|
|
94
|
+
} else if (line.startsWith("id:")) {
|
|
95
|
+
lastEventId = line.replace(/^id:\s*/, "");
|
|
96
|
+
} else if (line.startsWith("retry:")) {
|
|
97
|
+
const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
|
|
98
|
+
if (!Number.isNaN(parsed)) {
|
|
99
|
+
retryDelay = parsed;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
let data;
|
|
104
|
+
let parsedJson = false;
|
|
105
|
+
if (dataLines.length) {
|
|
106
|
+
const rawData = dataLines.join("\n");
|
|
107
|
+
try {
|
|
108
|
+
data = JSON.parse(rawData);
|
|
109
|
+
parsedJson = true;
|
|
110
|
+
} catch {
|
|
111
|
+
data = rawData;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
if (parsedJson) {
|
|
115
|
+
if (responseValidator) {
|
|
116
|
+
await responseValidator(data);
|
|
117
|
+
}
|
|
118
|
+
if (responseTransformer) {
|
|
119
|
+
data = await responseTransformer(data);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
onSseEvent?.({
|
|
123
|
+
data,
|
|
124
|
+
event: eventName,
|
|
125
|
+
id: lastEventId,
|
|
126
|
+
retry: retryDelay
|
|
127
|
+
});
|
|
128
|
+
if (dataLines.length) {
|
|
129
|
+
yield data;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
} finally {
|
|
134
|
+
signal.removeEventListener("abort", abortHandler);
|
|
135
|
+
reader.releaseLock();
|
|
136
|
+
}
|
|
137
|
+
break;
|
|
556
138
|
} catch (error) {
|
|
557
|
-
|
|
558
|
-
|
|
139
|
+
onSseError?.(error);
|
|
140
|
+
if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) {
|
|
141
|
+
break;
|
|
559
142
|
}
|
|
560
|
-
|
|
143
|
+
const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 3e4);
|
|
144
|
+
await sleep(backoff);
|
|
561
145
|
}
|
|
562
|
-
},
|
|
563
|
-
{
|
|
564
|
-
retries: finalConfig.retries,
|
|
565
|
-
factor: finalConfig.factor,
|
|
566
|
-
minTimeout: finalConfig.minTimeout,
|
|
567
|
-
maxTimeout: finalConfig.maxTimeout,
|
|
568
|
-
randomize: finalConfig.randomize,
|
|
569
|
-
onFailedAttempt: finalConfig.onFailedAttempt ? (error) => {
|
|
570
|
-
const pRetryError = error;
|
|
571
|
-
finalConfig.onFailedAttempt({
|
|
572
|
-
error: pRetryError,
|
|
573
|
-
attemptNumber: pRetryError.attemptNumber,
|
|
574
|
-
retriesLeft: pRetryError.retriesLeft
|
|
575
|
-
});
|
|
576
|
-
} : void 0
|
|
577
146
|
}
|
|
578
|
-
);
|
|
147
|
+
}, "createStream");
|
|
148
|
+
const stream = createStream();
|
|
149
|
+
return { stream };
|
|
579
150
|
}
|
|
580
|
-
__name(
|
|
151
|
+
__name(createSseClient, "createSseClient");
|
|
581
152
|
|
|
582
|
-
// src/_api/generated/
|
|
583
|
-
var
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
153
|
+
// src/_api/generated/core/pathSerializer.gen.ts
|
|
154
|
+
var separatorArrayExplode = /* @__PURE__ */ __name((style) => {
|
|
155
|
+
switch (style) {
|
|
156
|
+
case "label":
|
|
157
|
+
return ".";
|
|
158
|
+
case "matrix":
|
|
159
|
+
return ";";
|
|
160
|
+
case "simple":
|
|
161
|
+
return ",";
|
|
162
|
+
default:
|
|
163
|
+
return "&";
|
|
164
|
+
}
|
|
165
|
+
}, "separatorArrayExplode");
|
|
166
|
+
var separatorArrayNoExplode = /* @__PURE__ */ __name((style) => {
|
|
167
|
+
switch (style) {
|
|
168
|
+
case "form":
|
|
169
|
+
return ",";
|
|
170
|
+
case "pipeDelimited":
|
|
171
|
+
return "|";
|
|
172
|
+
case "spaceDelimited":
|
|
173
|
+
return "%20";
|
|
174
|
+
default:
|
|
175
|
+
return ",";
|
|
176
|
+
}
|
|
177
|
+
}, "separatorArrayNoExplode");
|
|
178
|
+
var separatorObjectExplode = /* @__PURE__ */ __name((style) => {
|
|
179
|
+
switch (style) {
|
|
180
|
+
case "label":
|
|
181
|
+
return ".";
|
|
182
|
+
case "matrix":
|
|
183
|
+
return ";";
|
|
184
|
+
case "simple":
|
|
185
|
+
return ",";
|
|
186
|
+
default:
|
|
187
|
+
return "&";
|
|
188
|
+
}
|
|
189
|
+
}, "separatorObjectExplode");
|
|
190
|
+
var serializeArrayParam = /* @__PURE__ */ __name(({
|
|
191
|
+
allowReserved,
|
|
192
|
+
explode,
|
|
193
|
+
name,
|
|
194
|
+
style,
|
|
195
|
+
value
|
|
196
|
+
}) => {
|
|
197
|
+
if (!explode) {
|
|
198
|
+
const joinedValues2 = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode(style));
|
|
199
|
+
switch (style) {
|
|
200
|
+
case "label":
|
|
201
|
+
return `.${joinedValues2}`;
|
|
202
|
+
case "matrix":
|
|
203
|
+
return `;${name}=${joinedValues2}`;
|
|
204
|
+
case "simple":
|
|
205
|
+
return joinedValues2;
|
|
206
|
+
default:
|
|
207
|
+
return `${name}=${joinedValues2}`;
|
|
606
208
|
}
|
|
607
|
-
this.auth = new Auth(this);
|
|
608
|
-
this.oauth = new Oauth(this);
|
|
609
|
-
this.user_profile = new UserProfile(this);
|
|
610
|
-
this.accounts = new Accounts(this);
|
|
611
209
|
}
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
*/
|
|
617
|
-
getCsrfToken() {
|
|
618
|
-
const name = "csrftoken";
|
|
619
|
-
const value = `; ${document.cookie}`;
|
|
620
|
-
const parts = value.split(`; ${name}=`);
|
|
621
|
-
if (parts.length === 2) {
|
|
622
|
-
return parts.pop()?.split(";").shift() || null;
|
|
210
|
+
const separator = separatorArrayExplode(style);
|
|
211
|
+
const joinedValues = value.map((v) => {
|
|
212
|
+
if (style === "label" || style === "simple") {
|
|
213
|
+
return allowReserved ? v : encodeURIComponent(v);
|
|
623
214
|
}
|
|
624
|
-
return
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
215
|
+
return serializePrimitiveParam({
|
|
216
|
+
allowReserved,
|
|
217
|
+
name,
|
|
218
|
+
value: v
|
|
219
|
+
});
|
|
220
|
+
}).join(separator);
|
|
221
|
+
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
222
|
+
}, "serializeArrayParam");
|
|
223
|
+
var serializePrimitiveParam = /* @__PURE__ */ __name(({
|
|
224
|
+
allowReserved,
|
|
225
|
+
name,
|
|
226
|
+
value
|
|
227
|
+
}) => {
|
|
228
|
+
if (value === void 0 || value === null) {
|
|
229
|
+
return "";
|
|
230
|
+
}
|
|
231
|
+
if (typeof value === "object") {
|
|
232
|
+
throw new Error(
|
|
233
|
+
"Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these."
|
|
234
|
+
);
|
|
638
235
|
}
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
236
|
+
return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
|
|
237
|
+
}, "serializePrimitiveParam");
|
|
238
|
+
var serializeObjectParam = /* @__PURE__ */ __name(({
|
|
239
|
+
allowReserved,
|
|
240
|
+
explode,
|
|
241
|
+
name,
|
|
242
|
+
style,
|
|
243
|
+
value,
|
|
244
|
+
valueOnly
|
|
245
|
+
}) => {
|
|
246
|
+
if (value instanceof Date) {
|
|
247
|
+
return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
|
|
248
|
+
}
|
|
249
|
+
if (style !== "deepObject" && !explode) {
|
|
250
|
+
let values = [];
|
|
251
|
+
Object.entries(value).forEach(([key, v]) => {
|
|
252
|
+
values = [...values, key, allowReserved ? v : encodeURIComponent(v)];
|
|
253
|
+
});
|
|
254
|
+
const joinedValues2 = values.join(",");
|
|
255
|
+
switch (style) {
|
|
256
|
+
case "form":
|
|
257
|
+
return `${name}=${joinedValues2}`;
|
|
258
|
+
case "label":
|
|
259
|
+
return `.${joinedValues2}`;
|
|
260
|
+
case "matrix":
|
|
261
|
+
return `;${name}=${joinedValues2}`;
|
|
262
|
+
default:
|
|
263
|
+
return joinedValues2;
|
|
656
264
|
}
|
|
657
|
-
return this._makeRequest(method, path, options);
|
|
658
265
|
}
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
body: options?.formData || options?.body,
|
|
684
|
-
timestamp: startTime
|
|
685
|
-
});
|
|
686
|
-
}
|
|
687
|
-
try {
|
|
688
|
-
const response = await this.httpClient.request({
|
|
689
|
-
method,
|
|
690
|
-
url,
|
|
691
|
-
headers,
|
|
692
|
-
params: options?.params,
|
|
693
|
-
body: options?.body,
|
|
694
|
-
formData: options?.formData,
|
|
695
|
-
binaryBody: options?.binaryBody,
|
|
696
|
-
responseType: options?.responseType
|
|
697
|
-
});
|
|
698
|
-
const duration = Date.now() - startTime;
|
|
699
|
-
if (response.status >= 400) {
|
|
700
|
-
const error = new APIError(
|
|
701
|
-
response.status,
|
|
702
|
-
response.statusText,
|
|
703
|
-
response.data,
|
|
704
|
-
url
|
|
705
|
-
);
|
|
706
|
-
if (this.logger) {
|
|
707
|
-
this.logger.logError(
|
|
708
|
-
{
|
|
709
|
-
method,
|
|
710
|
-
url,
|
|
711
|
-
headers,
|
|
712
|
-
body: options?.formData || options?.body,
|
|
713
|
-
timestamp: startTime
|
|
714
|
-
},
|
|
715
|
-
{
|
|
716
|
-
message: error.message,
|
|
717
|
-
statusCode: response.status,
|
|
718
|
-
duration,
|
|
719
|
-
timestamp: Date.now()
|
|
720
|
-
}
|
|
721
|
-
);
|
|
722
|
-
}
|
|
723
|
-
throw error;
|
|
724
|
-
}
|
|
725
|
-
if (this.logger) {
|
|
726
|
-
this.logger.logResponse(
|
|
727
|
-
{
|
|
728
|
-
method,
|
|
729
|
-
url,
|
|
730
|
-
headers,
|
|
731
|
-
body: options?.formData || options?.body,
|
|
732
|
-
timestamp: startTime
|
|
733
|
-
},
|
|
734
|
-
{
|
|
735
|
-
status: response.status,
|
|
736
|
-
statusText: response.statusText,
|
|
737
|
-
data: response.data,
|
|
738
|
-
duration,
|
|
739
|
-
timestamp: Date.now()
|
|
740
|
-
}
|
|
741
|
-
);
|
|
742
|
-
}
|
|
743
|
-
return response.data;
|
|
744
|
-
} catch (error) {
|
|
745
|
-
const duration = Date.now() - startTime;
|
|
746
|
-
if (error instanceof APIError) {
|
|
747
|
-
throw error;
|
|
266
|
+
const separator = separatorObjectExplode(style);
|
|
267
|
+
const joinedValues = Object.entries(value).map(
|
|
268
|
+
([key, v]) => serializePrimitiveParam({
|
|
269
|
+
allowReserved,
|
|
270
|
+
name: style === "deepObject" ? `${name}[${key}]` : key,
|
|
271
|
+
value: v
|
|
272
|
+
})
|
|
273
|
+
).join(separator);
|
|
274
|
+
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
275
|
+
}, "serializeObjectParam");
|
|
276
|
+
|
|
277
|
+
// src/_api/generated/core/utils.gen.ts
|
|
278
|
+
var PATH_PARAM_RE = /\{[^{}]+\}/g;
|
|
279
|
+
var defaultPathSerializer = /* @__PURE__ */ __name(({ path, url: _url }) => {
|
|
280
|
+
let url = _url;
|
|
281
|
+
const matches = _url.match(PATH_PARAM_RE);
|
|
282
|
+
if (matches) {
|
|
283
|
+
for (const match of matches) {
|
|
284
|
+
let explode = false;
|
|
285
|
+
let name = match.substring(1, match.length - 1);
|
|
286
|
+
let style = "simple";
|
|
287
|
+
if (name.endsWith("*")) {
|
|
288
|
+
explode = true;
|
|
289
|
+
name = name.substring(0, name.length - 1);
|
|
748
290
|
}
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
} catch {
|
|
756
|
-
return false;
|
|
757
|
-
}
|
|
758
|
-
})();
|
|
759
|
-
if (isCrossOrigin) {
|
|
760
|
-
const entries = performance.getEntriesByName(url, "resource");
|
|
761
|
-
if (entries.length > 0) {
|
|
762
|
-
const last = entries[entries.length - 1];
|
|
763
|
-
possiblyCors = "responseStatus" in last && last.responseStatus === 0;
|
|
764
|
-
}
|
|
765
|
-
}
|
|
766
|
-
} catch {
|
|
767
|
-
}
|
|
291
|
+
if (name.startsWith(".")) {
|
|
292
|
+
name = name.substring(1);
|
|
293
|
+
style = "label";
|
|
294
|
+
} else if (name.startsWith(";")) {
|
|
295
|
+
name = name.substring(1);
|
|
296
|
+
style = "matrix";
|
|
768
297
|
}
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
if (possiblyCors) {
|
|
773
|
-
this.logger.error(` \u2192 Possibly blocked by CORS policy (configure CORS on the server)`);
|
|
774
|
-
}
|
|
298
|
+
const value = path[name];
|
|
299
|
+
if (value === void 0 || value === null) {
|
|
300
|
+
continue;
|
|
775
301
|
}
|
|
776
|
-
if (
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
detail: {
|
|
780
|
-
url,
|
|
781
|
-
method,
|
|
782
|
-
error: error instanceof Error ? error.message : String(error),
|
|
783
|
-
possibly_cors: possiblyCors,
|
|
784
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
785
|
-
},
|
|
786
|
-
bubbles: true,
|
|
787
|
-
cancelable: false
|
|
788
|
-
}));
|
|
789
|
-
} catch {
|
|
790
|
-
}
|
|
302
|
+
if (Array.isArray(value)) {
|
|
303
|
+
url = url.replace(match, serializeArrayParam({ explode, name, style, value }));
|
|
304
|
+
continue;
|
|
791
305
|
}
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
{
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
}
|
|
802
|
-
{
|
|
803
|
-
message: networkError.message,
|
|
804
|
-
duration,
|
|
805
|
-
timestamp: Date.now()
|
|
806
|
-
}
|
|
306
|
+
if (typeof value === "object") {
|
|
307
|
+
url = url.replace(
|
|
308
|
+
match,
|
|
309
|
+
serializeObjectParam({
|
|
310
|
+
explode,
|
|
311
|
+
name,
|
|
312
|
+
style,
|
|
313
|
+
value,
|
|
314
|
+
valueOnly: true
|
|
315
|
+
})
|
|
807
316
|
);
|
|
317
|
+
continue;
|
|
808
318
|
}
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
}
|
|
819
|
-
logger;
|
|
820
|
-
constructor(logger) {
|
|
821
|
-
this.logger = logger;
|
|
822
|
-
}
|
|
823
|
-
getItem(key) {
|
|
824
|
-
try {
|
|
825
|
-
if (typeof window !== "undefined" && window.localStorage) {
|
|
826
|
-
const value = localStorage.getItem(key);
|
|
827
|
-
this.logger?.debug(`LocalStorage.getItem("${key}"): ${value ? "found" : "not found"}`);
|
|
828
|
-
return value;
|
|
319
|
+
if (style === "matrix") {
|
|
320
|
+
url = url.replace(
|
|
321
|
+
match,
|
|
322
|
+
`;${serializePrimitiveParam({
|
|
323
|
+
name,
|
|
324
|
+
value
|
|
325
|
+
})}`
|
|
326
|
+
);
|
|
327
|
+
continue;
|
|
829
328
|
}
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
329
|
+
const replaceValue = encodeURIComponent(
|
|
330
|
+
style === "label" ? `.${value}` : value
|
|
331
|
+
);
|
|
332
|
+
url = url.replace(match, replaceValue);
|
|
833
333
|
}
|
|
834
|
-
return null;
|
|
835
334
|
}
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
335
|
+
return url;
|
|
336
|
+
}, "defaultPathSerializer");
|
|
337
|
+
var getUrl = /* @__PURE__ */ __name(({
|
|
338
|
+
baseUrl,
|
|
339
|
+
path,
|
|
340
|
+
query,
|
|
341
|
+
querySerializer,
|
|
342
|
+
url: _url
|
|
343
|
+
}) => {
|
|
344
|
+
const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
|
|
345
|
+
let url = (baseUrl ?? "") + pathUrl;
|
|
346
|
+
if (path) {
|
|
347
|
+
url = defaultPathSerializer({ path, url });
|
|
348
|
+
}
|
|
349
|
+
let search = query ? querySerializer(query) : "";
|
|
350
|
+
if (search.startsWith("?")) {
|
|
351
|
+
search = search.substring(1);
|
|
352
|
+
}
|
|
353
|
+
if (search) {
|
|
354
|
+
url += `?${search}`;
|
|
355
|
+
}
|
|
356
|
+
return url;
|
|
357
|
+
}, "getUrl");
|
|
358
|
+
function getValidRequestBody(options) {
|
|
359
|
+
const hasBody = options.body !== void 0;
|
|
360
|
+
const isSerializedBody = hasBody && options.bodySerializer;
|
|
361
|
+
if (isSerializedBody) {
|
|
362
|
+
if ("serializedBody" in options) {
|
|
363
|
+
const hasSerializedBody = options.serializedBody !== void 0 && options.serializedBody !== "";
|
|
364
|
+
return hasSerializedBody ? options.serializedBody : null;
|
|
846
365
|
}
|
|
366
|
+
return options.body !== "" ? options.body : null;
|
|
847
367
|
}
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
if (typeof window !== "undefined" && window.localStorage) {
|
|
851
|
-
localStorage.removeItem(key);
|
|
852
|
-
this.logger?.debug(`LocalStorage.removeItem("${key}"): success`);
|
|
853
|
-
} else {
|
|
854
|
-
this.logger?.warn("LocalStorage not available: window.localStorage is undefined");
|
|
855
|
-
}
|
|
856
|
-
} catch (error) {
|
|
857
|
-
this.logger?.error("LocalStorage.removeItem failed:", error);
|
|
858
|
-
}
|
|
368
|
+
if (hasBody) {
|
|
369
|
+
return options.body;
|
|
859
370
|
}
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
var OAuthConnectionProvider = /* @__PURE__ */ ((OAuthConnectionProvider2) => {
|
|
864
|
-
OAuthConnectionProvider2["GITHUB"] = "github";
|
|
865
|
-
return OAuthConnectionProvider2;
|
|
866
|
-
})(OAuthConnectionProvider || {});
|
|
867
|
-
|
|
868
|
-
// src/_api/generated/cfg_accounts/_utils/schemas/AccountDeleteResponse.schema.ts
|
|
869
|
-
import { z as z2 } from "zod";
|
|
870
|
-
var AccountDeleteResponseSchema = z2.object({
|
|
871
|
-
success: z2.boolean(),
|
|
872
|
-
message: z2.string()
|
|
873
|
-
});
|
|
874
|
-
|
|
875
|
-
// src/_api/generated/cfg_accounts/_utils/schemas/CentrifugoToken.schema.ts
|
|
876
|
-
import { z as z3 } from "zod";
|
|
877
|
-
var CentrifugoTokenSchema = z3.object({
|
|
878
|
-
token: z3.string(),
|
|
879
|
-
centrifugo_url: z3.string(),
|
|
880
|
-
expires_at: z3.string().datetime({ offset: true }),
|
|
881
|
-
channels: z3.array(z3.string())
|
|
882
|
-
});
|
|
883
|
-
|
|
884
|
-
// src/_api/generated/cfg_accounts/_utils/schemas/CfgAccountsProfileAvatarCreateRequest.schema.ts
|
|
885
|
-
import { z as z4 } from "zod";
|
|
886
|
-
var CfgAccountsProfileAvatarCreateRequestSchema = z4.object({
|
|
887
|
-
avatar: z4.union([z4.instanceof(File), z4.instanceof(Blob)])
|
|
888
|
-
});
|
|
889
|
-
|
|
890
|
-
// src/_api/generated/cfg_accounts/_utils/schemas/OAuthAuthorizeRequestRequest.schema.ts
|
|
891
|
-
import { z as z5 } from "zod";
|
|
892
|
-
var OAuthAuthorizeRequestRequestSchema = z5.object({
|
|
893
|
-
redirect_uri: z5.string().optional(),
|
|
894
|
-
source_url: z5.string().optional()
|
|
895
|
-
});
|
|
896
|
-
|
|
897
|
-
// src/_api/generated/cfg_accounts/_utils/schemas/OAuthAuthorizeResponse.schema.ts
|
|
898
|
-
import { z as z6 } from "zod";
|
|
899
|
-
var OAuthAuthorizeResponseSchema = z6.object({
|
|
900
|
-
authorization_url: z6.string(),
|
|
901
|
-
state: z6.string()
|
|
902
|
-
});
|
|
903
|
-
|
|
904
|
-
// src/_api/generated/cfg_accounts/_utils/schemas/OAuthCallbackRequestRequest.schema.ts
|
|
905
|
-
import { z as z7 } from "zod";
|
|
906
|
-
var OAuthCallbackRequestRequestSchema = z7.object({
|
|
907
|
-
code: z7.string().min(10).max(500),
|
|
908
|
-
state: z7.string().min(20).max(100),
|
|
909
|
-
redirect_uri: z7.string().optional()
|
|
910
|
-
});
|
|
911
|
-
|
|
912
|
-
// src/_api/generated/cfg_accounts/_utils/schemas/OAuthConnection.schema.ts
|
|
913
|
-
import { z as z8 } from "zod";
|
|
914
|
-
var OAuthConnectionSchema = z8.object({
|
|
915
|
-
id: z8.number().int(),
|
|
916
|
-
provider: z8.nativeEnum(OAuthConnectionProvider),
|
|
917
|
-
provider_display: z8.string(),
|
|
918
|
-
provider_username: z8.string(),
|
|
919
|
-
provider_email: z8.email(),
|
|
920
|
-
provider_avatar_url: z8.string(),
|
|
921
|
-
connected_at: z8.string().datetime({ offset: true }),
|
|
922
|
-
last_login_at: z8.string().datetime({ offset: true })
|
|
923
|
-
});
|
|
924
|
-
|
|
925
|
-
// src/_api/generated/cfg_accounts/_utils/schemas/OAuthDisconnectRequestRequest.schema.ts
|
|
926
|
-
import { z as z9 } from "zod";
|
|
927
|
-
var OAuthDisconnectRequestRequestSchema = z9.object({
|
|
928
|
-
provider: z9.nativeEnum(OAuthConnectionProvider)
|
|
929
|
-
});
|
|
930
|
-
|
|
931
|
-
// src/_api/generated/cfg_accounts/_utils/schemas/OAuthError.schema.ts
|
|
932
|
-
import { z as z10 } from "zod";
|
|
933
|
-
var OAuthErrorSchema = z10.object({
|
|
934
|
-
error: z10.string(),
|
|
935
|
-
error_description: z10.string().optional()
|
|
936
|
-
});
|
|
937
|
-
|
|
938
|
-
// src/_api/generated/cfg_accounts/_utils/schemas/OAuthProvidersResponse.schema.ts
|
|
939
|
-
import { z as z11 } from "zod";
|
|
940
|
-
var OAuthProvidersResponseSchema = z11.object({
|
|
941
|
-
providers: z11.array(z11.record(z11.string(), z11.any()))
|
|
942
|
-
});
|
|
943
|
-
|
|
944
|
-
// src/_api/generated/cfg_accounts/_utils/schemas/OAuthTokenResponse.schema.ts
|
|
945
|
-
import { z as z12 } from "zod";
|
|
946
|
-
var OAuthTokenResponseSchema = z12.object({
|
|
947
|
-
requires_2fa: z12.boolean().optional(),
|
|
948
|
-
session_id: z12.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i).nullable().optional(),
|
|
949
|
-
access: z12.string().nullable().optional(),
|
|
950
|
-
refresh: z12.string().nullable().optional(),
|
|
951
|
-
user: z12.record(z12.string(), z12.any()).nullable().optional(),
|
|
952
|
-
is_new_user: z12.boolean(),
|
|
953
|
-
is_new_connection: z12.boolean(),
|
|
954
|
-
should_prompt_2fa: z12.boolean().optional()
|
|
955
|
-
});
|
|
956
|
-
|
|
957
|
-
// src/_api/generated/cfg_accounts/_utils/schemas/OTPErrorResponse.schema.ts
|
|
958
|
-
import { z as z13 } from "zod";
|
|
959
|
-
var OTPErrorResponseSchema = z13.object({
|
|
960
|
-
error: z13.string(),
|
|
961
|
-
error_code: z13.string().nullable().optional(),
|
|
962
|
-
retry_after: z13.number().int().nullable().optional()
|
|
963
|
-
});
|
|
964
|
-
|
|
965
|
-
// src/_api/generated/cfg_accounts/_utils/schemas/OTPRequestRequest.schema.ts
|
|
966
|
-
import { z as z14 } from "zod";
|
|
967
|
-
var OTPRequestRequestSchema = z14.object({
|
|
968
|
-
identifier: z14.string().min(1),
|
|
969
|
-
source_url: z14.string().optional()
|
|
970
|
-
});
|
|
971
|
-
|
|
972
|
-
// src/_api/generated/cfg_accounts/_utils/schemas/OTPRequestResponse.schema.ts
|
|
973
|
-
import { z as z15 } from "zod";
|
|
974
|
-
var OTPRequestResponseSchema = z15.object({
|
|
975
|
-
message: z15.string()
|
|
976
|
-
});
|
|
977
|
-
|
|
978
|
-
// src/_api/generated/cfg_accounts/_utils/schemas/OTPVerifyRequest.schema.ts
|
|
979
|
-
import { z as z16 } from "zod";
|
|
980
|
-
var OTPVerifyRequestSchema = z16.object({
|
|
981
|
-
identifier: z16.string().min(1),
|
|
982
|
-
otp: z16.string().min(6).max(6),
|
|
983
|
-
source_url: z16.string().optional()
|
|
984
|
-
});
|
|
985
|
-
|
|
986
|
-
// src/_api/generated/cfg_accounts/_utils/schemas/OTPVerifyResponse.schema.ts
|
|
987
|
-
import { z as z18 } from "zod";
|
|
988
|
-
|
|
989
|
-
// src/_api/generated/cfg_accounts/_utils/schemas/User.schema.ts
|
|
990
|
-
import { z as z17 } from "zod";
|
|
991
|
-
var UserSchema = z17.object({
|
|
992
|
-
id: z17.number().int(),
|
|
993
|
-
email: z17.email(),
|
|
994
|
-
first_name: z17.string().max(50).optional(),
|
|
995
|
-
last_name: z17.string().max(50).optional(),
|
|
996
|
-
full_name: z17.string(),
|
|
997
|
-
initials: z17.string(),
|
|
998
|
-
display_username: z17.string(),
|
|
999
|
-
company: z17.string().max(100).optional(),
|
|
1000
|
-
phone: z17.string().max(20).optional(),
|
|
1001
|
-
position: z17.string().max(100).optional(),
|
|
1002
|
-
language: z17.string().max(10).optional(),
|
|
1003
|
-
avatar: z17.string().nullable(),
|
|
1004
|
-
is_staff: z17.boolean(),
|
|
1005
|
-
is_superuser: z17.boolean(),
|
|
1006
|
-
date_joined: z17.string().datetime({ offset: true }),
|
|
1007
|
-
last_login: z17.string().datetime({ offset: true }).nullable(),
|
|
1008
|
-
unanswered_messages_count: z17.number().int(),
|
|
1009
|
-
centrifugo: CentrifugoTokenSchema.nullable()
|
|
1010
|
-
});
|
|
1011
|
-
|
|
1012
|
-
// src/_api/generated/cfg_accounts/_utils/schemas/OTPVerifyResponse.schema.ts
|
|
1013
|
-
var OTPVerifyResponseSchema = z18.object({
|
|
1014
|
-
requires_2fa: z18.boolean().optional(),
|
|
1015
|
-
session_id: z18.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i).nullable().optional(),
|
|
1016
|
-
refresh: z18.string().nullable().optional(),
|
|
1017
|
-
access: z18.string().nullable().optional(),
|
|
1018
|
-
user: UserSchema.nullable().optional(),
|
|
1019
|
-
should_prompt_2fa: z18.boolean().optional()
|
|
1020
|
-
});
|
|
1021
|
-
|
|
1022
|
-
// src/_api/generated/cfg_accounts/_utils/schemas/PatchedUserProfileUpdateRequest.schema.ts
|
|
1023
|
-
import { z as z19 } from "zod";
|
|
1024
|
-
var PatchedUserProfileUpdateRequestSchema = z19.object({
|
|
1025
|
-
first_name: z19.string().max(50).optional(),
|
|
1026
|
-
last_name: z19.string().max(50).optional(),
|
|
1027
|
-
company: z19.string().max(100).optional(),
|
|
1028
|
-
phone: z19.string().max(20).optional(),
|
|
1029
|
-
position: z19.string().max(100).optional(),
|
|
1030
|
-
language: z19.string().max(10).optional()
|
|
1031
|
-
});
|
|
1032
|
-
|
|
1033
|
-
// src/_api/generated/cfg_accounts/_utils/schemas/TokenRefreshRequest.schema.ts
|
|
1034
|
-
import { z as z20 } from "zod";
|
|
1035
|
-
var TokenRefreshRequestSchema = z20.object({
|
|
1036
|
-
refresh: z20.string().min(1)
|
|
1037
|
-
});
|
|
1038
|
-
|
|
1039
|
-
// src/_api/generated/cfg_accounts/_utils/schemas/UserProfileUpdateRequest.schema.ts
|
|
1040
|
-
import { z as z21 } from "zod";
|
|
1041
|
-
var UserProfileUpdateRequestSchema = z21.object({
|
|
1042
|
-
first_name: z21.string().max(50).optional(),
|
|
1043
|
-
last_name: z21.string().max(50).optional(),
|
|
1044
|
-
company: z21.string().max(100).optional(),
|
|
1045
|
-
phone: z21.string().max(20).optional(),
|
|
1046
|
-
position: z21.string().max(100).optional(),
|
|
1047
|
-
language: z21.string().max(10).optional()
|
|
1048
|
-
});
|
|
371
|
+
return void 0;
|
|
372
|
+
}
|
|
373
|
+
__name(getValidRequestBody, "getValidRequestBody");
|
|
1049
374
|
|
|
1050
|
-
// src/_api/generated/
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
try {
|
|
1056
|
-
return OTPRequestResponseSchema.parse(response);
|
|
1057
|
-
} catch (error) {
|
|
1058
|
-
consola.error("\u274C Zod Validation Failed");
|
|
1059
|
-
consola.box(`createAccountsOtpRequestCreate
|
|
1060
|
-
Path: /cfg/accounts/otp/request/
|
|
1061
|
-
Method: POST`);
|
|
1062
|
-
if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
|
|
1063
|
-
consola.error("Validation Issues:");
|
|
1064
|
-
error.issues.forEach((issue, index) => {
|
|
1065
|
-
consola.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
|
|
1066
|
-
consola.error(` \u251C\u2500 Message: ${issue.message}`);
|
|
1067
|
-
if (issue.expected) consola.error(` \u251C\u2500 Expected: ${issue.expected}`);
|
|
1068
|
-
if (issue.received) consola.error(` \u2514\u2500 Received: ${issue.received}`);
|
|
1069
|
-
});
|
|
1070
|
-
}
|
|
1071
|
-
consola.error("Response data:", response);
|
|
1072
|
-
if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
|
|
1073
|
-
try {
|
|
1074
|
-
const event = new CustomEvent("zod-validation-error", {
|
|
1075
|
-
detail: {
|
|
1076
|
-
operation: "createAccountsOtpRequestCreate",
|
|
1077
|
-
path: "/cfg/accounts/otp/request/",
|
|
1078
|
-
method: "POST",
|
|
1079
|
-
error,
|
|
1080
|
-
response,
|
|
1081
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
1082
|
-
},
|
|
1083
|
-
bubbles: true,
|
|
1084
|
-
cancelable: false
|
|
1085
|
-
});
|
|
1086
|
-
window.dispatchEvent(event);
|
|
1087
|
-
} catch (eventError) {
|
|
1088
|
-
consola.warn("Failed to dispatch validation error event:", eventError);
|
|
1089
|
-
}
|
|
1090
|
-
}
|
|
1091
|
-
throw error;
|
|
375
|
+
// src/_api/generated/core/auth.gen.ts
|
|
376
|
+
var getAuthToken = /* @__PURE__ */ __name(async (auth2, callback) => {
|
|
377
|
+
const token = typeof callback === "function" ? await callback(auth2) : callback;
|
|
378
|
+
if (!token) {
|
|
379
|
+
return;
|
|
1092
380
|
}
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
async function createAccountsOtpVerifyCreate(data, client) {
|
|
1096
|
-
const api = client || getAPIInstance();
|
|
1097
|
-
const response = await api.accounts.otpVerifyCreate(data);
|
|
1098
|
-
try {
|
|
1099
|
-
return OTPVerifyResponseSchema.parse(response);
|
|
1100
|
-
} catch (error) {
|
|
1101
|
-
consola.error("\u274C Zod Validation Failed");
|
|
1102
|
-
consola.box(`createAccountsOtpVerifyCreate
|
|
1103
|
-
Path: /cfg/accounts/otp/verify/
|
|
1104
|
-
Method: POST`);
|
|
1105
|
-
if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
|
|
1106
|
-
consola.error("Validation Issues:");
|
|
1107
|
-
error.issues.forEach((issue, index) => {
|
|
1108
|
-
consola.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
|
|
1109
|
-
consola.error(` \u251C\u2500 Message: ${issue.message}`);
|
|
1110
|
-
if (issue.expected) consola.error(` \u251C\u2500 Expected: ${issue.expected}`);
|
|
1111
|
-
if (issue.received) consola.error(` \u2514\u2500 Received: ${issue.received}`);
|
|
1112
|
-
});
|
|
1113
|
-
}
|
|
1114
|
-
consola.error("Response data:", response);
|
|
1115
|
-
if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
|
|
1116
|
-
try {
|
|
1117
|
-
const event = new CustomEvent("zod-validation-error", {
|
|
1118
|
-
detail: {
|
|
1119
|
-
operation: "createAccountsOtpVerifyCreate",
|
|
1120
|
-
path: "/cfg/accounts/otp/verify/",
|
|
1121
|
-
method: "POST",
|
|
1122
|
-
error,
|
|
1123
|
-
response,
|
|
1124
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
1125
|
-
},
|
|
1126
|
-
bubbles: true,
|
|
1127
|
-
cancelable: false
|
|
1128
|
-
});
|
|
1129
|
-
window.dispatchEvent(event);
|
|
1130
|
-
} catch (eventError) {
|
|
1131
|
-
consola.warn("Failed to dispatch validation error event:", eventError);
|
|
1132
|
-
}
|
|
1133
|
-
}
|
|
1134
|
-
throw error;
|
|
381
|
+
if (auth2.scheme === "bearer") {
|
|
382
|
+
return `Bearer ${token}`;
|
|
1135
383
|
}
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
// src/_api/generated/cfg_accounts/_utils/fetchers/accounts__oauth.ts
|
|
1140
|
-
import { consola as consola2 } from "consola";
|
|
1141
|
-
async function getAccountsOauthConnectionsList(client) {
|
|
1142
|
-
const api = client || getAPIInstance();
|
|
1143
|
-
const response = await api.oauth.accountsOauthConnectionsList();
|
|
1144
|
-
try {
|
|
1145
|
-
return OAuthConnectionSchema.array().parse(response);
|
|
1146
|
-
} catch (error) {
|
|
1147
|
-
consola2.error("\u274C Zod Validation Failed");
|
|
1148
|
-
consola2.box(`getAccountsOauthConnectionsList
|
|
1149
|
-
Path: /cfg/accounts/oauth/connections/
|
|
1150
|
-
Method: GET`);
|
|
1151
|
-
if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
|
|
1152
|
-
consola2.error("Validation Issues:");
|
|
1153
|
-
error.issues.forEach((issue, index) => {
|
|
1154
|
-
consola2.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
|
|
1155
|
-
consola2.error(` \u251C\u2500 Message: ${issue.message}`);
|
|
1156
|
-
if (issue.expected) consola2.error(` \u251C\u2500 Expected: ${issue.expected}`);
|
|
1157
|
-
if (issue.received) consola2.error(` \u2514\u2500 Received: ${issue.received}`);
|
|
1158
|
-
});
|
|
1159
|
-
}
|
|
1160
|
-
consola2.error("Response data:", response);
|
|
1161
|
-
if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
|
|
1162
|
-
try {
|
|
1163
|
-
const event = new CustomEvent("zod-validation-error", {
|
|
1164
|
-
detail: {
|
|
1165
|
-
operation: "getAccountsOauthConnectionsList",
|
|
1166
|
-
path: "/cfg/accounts/oauth/connections/",
|
|
1167
|
-
method: "GET",
|
|
1168
|
-
error,
|
|
1169
|
-
response,
|
|
1170
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
1171
|
-
},
|
|
1172
|
-
bubbles: true,
|
|
1173
|
-
cancelable: false
|
|
1174
|
-
});
|
|
1175
|
-
window.dispatchEvent(event);
|
|
1176
|
-
} catch (eventError) {
|
|
1177
|
-
consola2.warn("Failed to dispatch validation error event:", eventError);
|
|
1178
|
-
}
|
|
1179
|
-
}
|
|
1180
|
-
throw error;
|
|
384
|
+
if (auth2.scheme === "basic") {
|
|
385
|
+
return `Basic ${btoa(token)}`;
|
|
1181
386
|
}
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
387
|
+
return token;
|
|
388
|
+
}, "getAuthToken");
|
|
389
|
+
|
|
390
|
+
// src/_api/generated/client/utils.gen.ts
|
|
391
|
+
var createQuerySerializer = /* @__PURE__ */ __name(({
|
|
392
|
+
parameters = {},
|
|
393
|
+
...args
|
|
394
|
+
} = {}) => {
|
|
395
|
+
const querySerializer = /* @__PURE__ */ __name((queryParams) => {
|
|
396
|
+
const search = [];
|
|
397
|
+
if (queryParams && typeof queryParams === "object") {
|
|
398
|
+
for (const name in queryParams) {
|
|
399
|
+
const value = queryParams[name];
|
|
400
|
+
if (value === void 0 || value === null) {
|
|
401
|
+
continue;
|
|
402
|
+
}
|
|
403
|
+
const options = parameters[name] || args;
|
|
404
|
+
if (Array.isArray(value)) {
|
|
405
|
+
const serializedArray = serializeArrayParam({
|
|
406
|
+
allowReserved: options.allowReserved,
|
|
407
|
+
explode: true,
|
|
408
|
+
name,
|
|
409
|
+
style: "form",
|
|
410
|
+
value,
|
|
411
|
+
...options.array
|
|
412
|
+
});
|
|
413
|
+
if (serializedArray) search.push(serializedArray);
|
|
414
|
+
} else if (typeof value === "object") {
|
|
415
|
+
const serializedObject = serializeObjectParam({
|
|
416
|
+
allowReserved: options.allowReserved,
|
|
417
|
+
explode: true,
|
|
418
|
+
name,
|
|
419
|
+
style: "deepObject",
|
|
420
|
+
value,
|
|
421
|
+
...options.object
|
|
422
|
+
});
|
|
423
|
+
if (serializedObject) search.push(serializedObject);
|
|
424
|
+
} else {
|
|
425
|
+
const serializedPrimitive = serializePrimitiveParam({
|
|
426
|
+
allowReserved: options.allowReserved,
|
|
427
|
+
name,
|
|
428
|
+
value
|
|
429
|
+
});
|
|
430
|
+
if (serializedPrimitive) search.push(serializedPrimitive);
|
|
431
|
+
}
|
|
1227
432
|
}
|
|
1228
433
|
}
|
|
1229
|
-
|
|
434
|
+
return search.join("&");
|
|
435
|
+
}, "querySerializer");
|
|
436
|
+
return querySerializer;
|
|
437
|
+
}, "createQuerySerializer");
|
|
438
|
+
var getParseAs = /* @__PURE__ */ __name((contentType) => {
|
|
439
|
+
if (!contentType) {
|
|
440
|
+
return "stream";
|
|
441
|
+
}
|
|
442
|
+
const cleanContent = contentType.split(";")[0]?.trim();
|
|
443
|
+
if (!cleanContent) {
|
|
444
|
+
return;
|
|
445
|
+
}
|
|
446
|
+
if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) {
|
|
447
|
+
return "json";
|
|
448
|
+
}
|
|
449
|
+
if (cleanContent === "multipart/form-data") {
|
|
450
|
+
return "formData";
|
|
451
|
+
}
|
|
452
|
+
if (["application/", "audio/", "image/", "video/"].some((type) => cleanContent.startsWith(type))) {
|
|
453
|
+
return "blob";
|
|
454
|
+
}
|
|
455
|
+
if (cleanContent.startsWith("text/")) {
|
|
456
|
+
return "text";
|
|
457
|
+
}
|
|
458
|
+
return;
|
|
459
|
+
}, "getParseAs");
|
|
460
|
+
var checkForExistence = /* @__PURE__ */ __name((options, name) => {
|
|
461
|
+
if (!name) {
|
|
462
|
+
return false;
|
|
1230
463
|
}
|
|
1231
|
-
}
|
|
1232
|
-
|
|
1233
|
-
async function createAccountsOauthGithubCallbackCreate(data, client) {
|
|
1234
|
-
const api = client || getAPIInstance();
|
|
1235
|
-
const response = await api.oauth.accountsOauthGithubCallbackCreate(data);
|
|
1236
|
-
try {
|
|
1237
|
-
return OAuthTokenResponseSchema.parse(response);
|
|
1238
|
-
} catch (error) {
|
|
1239
|
-
consola2.error("\u274C Zod Validation Failed");
|
|
1240
|
-
consola2.box(`createAccountsOauthGithubCallbackCreate
|
|
1241
|
-
Path: /cfg/accounts/oauth/github/callback/
|
|
1242
|
-
Method: POST`);
|
|
1243
|
-
if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
|
|
1244
|
-
consola2.error("Validation Issues:");
|
|
1245
|
-
error.issues.forEach((issue, index) => {
|
|
1246
|
-
consola2.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
|
|
1247
|
-
consola2.error(` \u251C\u2500 Message: ${issue.message}`);
|
|
1248
|
-
if (issue.expected) consola2.error(` \u251C\u2500 Expected: ${issue.expected}`);
|
|
1249
|
-
if (issue.received) consola2.error(` \u2514\u2500 Received: ${issue.received}`);
|
|
1250
|
-
});
|
|
1251
|
-
}
|
|
1252
|
-
consola2.error("Response data:", response);
|
|
1253
|
-
if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
|
|
1254
|
-
try {
|
|
1255
|
-
const event = new CustomEvent("zod-validation-error", {
|
|
1256
|
-
detail: {
|
|
1257
|
-
operation: "createAccountsOauthGithubCallbackCreate",
|
|
1258
|
-
path: "/cfg/accounts/oauth/github/callback/",
|
|
1259
|
-
method: "POST",
|
|
1260
|
-
error,
|
|
1261
|
-
response,
|
|
1262
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
1263
|
-
},
|
|
1264
|
-
bubbles: true,
|
|
1265
|
-
cancelable: false
|
|
1266
|
-
});
|
|
1267
|
-
window.dispatchEvent(event);
|
|
1268
|
-
} catch (eventError) {
|
|
1269
|
-
consola2.warn("Failed to dispatch validation error event:", eventError);
|
|
1270
|
-
}
|
|
1271
|
-
}
|
|
1272
|
-
throw error;
|
|
464
|
+
if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) {
|
|
465
|
+
return true;
|
|
1273
466
|
}
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
consola2.box(`getAccountsOauthProvidersRetrieve
|
|
1284
|
-
Path: /cfg/accounts/oauth/providers/
|
|
1285
|
-
Method: GET`);
|
|
1286
|
-
if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
|
|
1287
|
-
consola2.error("Validation Issues:");
|
|
1288
|
-
error.issues.forEach((issue, index) => {
|
|
1289
|
-
consola2.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
|
|
1290
|
-
consola2.error(` \u251C\u2500 Message: ${issue.message}`);
|
|
1291
|
-
if (issue.expected) consola2.error(` \u251C\u2500 Expected: ${issue.expected}`);
|
|
1292
|
-
if (issue.received) consola2.error(` \u2514\u2500 Received: ${issue.received}`);
|
|
1293
|
-
});
|
|
467
|
+
return false;
|
|
468
|
+
}, "checkForExistence");
|
|
469
|
+
var setAuthParams = /* @__PURE__ */ __name(async ({
|
|
470
|
+
security,
|
|
471
|
+
...options
|
|
472
|
+
}) => {
|
|
473
|
+
for (const auth2 of security) {
|
|
474
|
+
if (checkForExistence(options, auth2.name)) {
|
|
475
|
+
continue;
|
|
1294
476
|
}
|
|
1295
|
-
|
|
1296
|
-
if (
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
477
|
+
const token = await getAuthToken(auth2, options.auth);
|
|
478
|
+
if (!token) {
|
|
479
|
+
continue;
|
|
480
|
+
}
|
|
481
|
+
const name = auth2.name ?? "Authorization";
|
|
482
|
+
switch (auth2.in) {
|
|
483
|
+
case "query":
|
|
484
|
+
if (!options.query) {
|
|
485
|
+
options.query = {};
|
|
486
|
+
}
|
|
487
|
+
options.query[name] = token;
|
|
488
|
+
break;
|
|
489
|
+
case "cookie":
|
|
490
|
+
options.headers.append("Cookie", `${name}=${token}`);
|
|
491
|
+
break;
|
|
492
|
+
case "header":
|
|
493
|
+
default:
|
|
494
|
+
options.headers.set(name, token);
|
|
495
|
+
break;
|
|
1314
496
|
}
|
|
1315
|
-
throw error;
|
|
1316
497
|
}
|
|
1317
|
-
}
|
|
1318
|
-
__name(
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
498
|
+
}, "setAuthParams");
|
|
499
|
+
var buildUrl = /* @__PURE__ */ __name((options) => getUrl({
|
|
500
|
+
baseUrl: options.baseUrl,
|
|
501
|
+
path: options.path,
|
|
502
|
+
query: options.query,
|
|
503
|
+
querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer(options.querySerializer),
|
|
504
|
+
url: options.url
|
|
505
|
+
}), "buildUrl");
|
|
506
|
+
var mergeConfigs = /* @__PURE__ */ __name((a, b) => {
|
|
507
|
+
const config = { ...a, ...b };
|
|
508
|
+
if (config.baseUrl?.endsWith("/")) {
|
|
509
|
+
config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
|
|
510
|
+
}
|
|
511
|
+
config.headers = mergeHeaders(a.headers, b.headers);
|
|
512
|
+
return config;
|
|
513
|
+
}, "mergeConfigs");
|
|
514
|
+
var headersEntries = /* @__PURE__ */ __name((headers) => {
|
|
515
|
+
const entries = [];
|
|
516
|
+
headers.forEach((value, key) => {
|
|
517
|
+
entries.push([key, value]);
|
|
518
|
+
});
|
|
519
|
+
return entries;
|
|
520
|
+
}, "headersEntries");
|
|
521
|
+
var mergeHeaders = /* @__PURE__ */ __name((...headers) => {
|
|
522
|
+
const mergedHeaders = new Headers();
|
|
523
|
+
for (const header of headers) {
|
|
524
|
+
if (!header) {
|
|
525
|
+
continue;
|
|
1340
526
|
}
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
cancelable: false
|
|
1355
|
-
});
|
|
1356
|
-
window.dispatchEvent(event);
|
|
1357
|
-
} catch (eventError) {
|
|
1358
|
-
consola3.warn("Failed to dispatch validation error event:", eventError);
|
|
527
|
+
const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header);
|
|
528
|
+
for (const [key, value] of iterator) {
|
|
529
|
+
if (value === null) {
|
|
530
|
+
mergedHeaders.delete(key);
|
|
531
|
+
} else if (Array.isArray(value)) {
|
|
532
|
+
for (const v of value) {
|
|
533
|
+
mergedHeaders.append(key, v);
|
|
534
|
+
}
|
|
535
|
+
} else if (value !== void 0) {
|
|
536
|
+
mergedHeaders.set(
|
|
537
|
+
key,
|
|
538
|
+
typeof value === "object" ? JSON.stringify(value) : value
|
|
539
|
+
);
|
|
1359
540
|
}
|
|
1360
541
|
}
|
|
1361
|
-
throw error;
|
|
1362
542
|
}
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
if (
|
|
1376
|
-
|
|
1377
|
-
error.issues.forEach((issue, index) => {
|
|
1378
|
-
consola3.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
|
|
1379
|
-
consola3.error(` \u251C\u2500 Message: ${issue.message}`);
|
|
1380
|
-
if (issue.expected) consola3.error(` \u251C\u2500 Expected: ${issue.expected}`);
|
|
1381
|
-
if (issue.received) consola3.error(` \u2514\u2500 Received: ${issue.received}`);
|
|
1382
|
-
});
|
|
1383
|
-
}
|
|
1384
|
-
consola3.error("Response data:", response);
|
|
1385
|
-
if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
|
|
1386
|
-
try {
|
|
1387
|
-
const event = new CustomEvent("zod-validation-error", {
|
|
1388
|
-
detail: {
|
|
1389
|
-
operation: "createAccountsProfileAvatarCreate",
|
|
1390
|
-
path: "/cfg/accounts/profile/avatar/",
|
|
1391
|
-
method: "POST",
|
|
1392
|
-
error,
|
|
1393
|
-
response,
|
|
1394
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
1395
|
-
},
|
|
1396
|
-
bubbles: true,
|
|
1397
|
-
cancelable: false
|
|
1398
|
-
});
|
|
1399
|
-
window.dispatchEvent(event);
|
|
1400
|
-
} catch (eventError) {
|
|
1401
|
-
consola3.warn("Failed to dispatch validation error event:", eventError);
|
|
1402
|
-
}
|
|
543
|
+
return mergedHeaders;
|
|
544
|
+
}, "mergeHeaders");
|
|
545
|
+
var Interceptors = class {
|
|
546
|
+
static {
|
|
547
|
+
__name(this, "Interceptors");
|
|
548
|
+
}
|
|
549
|
+
fns = [];
|
|
550
|
+
clear() {
|
|
551
|
+
this.fns = [];
|
|
552
|
+
}
|
|
553
|
+
eject(id) {
|
|
554
|
+
const index = this.getInterceptorIndex(id);
|
|
555
|
+
if (this.fns[index]) {
|
|
556
|
+
this.fns[index] = null;
|
|
1403
557
|
}
|
|
1404
|
-
throw error;
|
|
1405
558
|
}
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
} catch (error) {
|
|
1414
|
-
consola3.error("\u274C Zod Validation Failed");
|
|
1415
|
-
consola3.box(`createAccountsProfileDeleteCreate
|
|
1416
|
-
Path: /cfg/accounts/profile/delete/
|
|
1417
|
-
Method: POST`);
|
|
1418
|
-
if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
|
|
1419
|
-
consola3.error("Validation Issues:");
|
|
1420
|
-
error.issues.forEach((issue, index) => {
|
|
1421
|
-
consola3.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
|
|
1422
|
-
consola3.error(` \u251C\u2500 Message: ${issue.message}`);
|
|
1423
|
-
if (issue.expected) consola3.error(` \u251C\u2500 Expected: ${issue.expected}`);
|
|
1424
|
-
if (issue.received) consola3.error(` \u2514\u2500 Received: ${issue.received}`);
|
|
1425
|
-
});
|
|
559
|
+
exists(id) {
|
|
560
|
+
const index = this.getInterceptorIndex(id);
|
|
561
|
+
return Boolean(this.fns[index]);
|
|
562
|
+
}
|
|
563
|
+
getInterceptorIndex(id) {
|
|
564
|
+
if (typeof id === "number") {
|
|
565
|
+
return this.fns[id] ? id : -1;
|
|
1426
566
|
}
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
method: "POST",
|
|
1435
|
-
error,
|
|
1436
|
-
response,
|
|
1437
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
1438
|
-
},
|
|
1439
|
-
bubbles: true,
|
|
1440
|
-
cancelable: false
|
|
1441
|
-
});
|
|
1442
|
-
window.dispatchEvent(event);
|
|
1443
|
-
} catch (eventError) {
|
|
1444
|
-
consola3.warn("Failed to dispatch validation error event:", eventError);
|
|
1445
|
-
}
|
|
567
|
+
return this.fns.indexOf(id);
|
|
568
|
+
}
|
|
569
|
+
update(id, fn) {
|
|
570
|
+
const index = this.getInterceptorIndex(id);
|
|
571
|
+
if (this.fns[index]) {
|
|
572
|
+
this.fns[index] = fn;
|
|
573
|
+
return id;
|
|
1446
574
|
}
|
|
1447
|
-
|
|
575
|
+
return false;
|
|
1448
576
|
}
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
577
|
+
use(fn) {
|
|
578
|
+
this.fns.push(fn);
|
|
579
|
+
return this.fns.length - 1;
|
|
580
|
+
}
|
|
581
|
+
};
|
|
582
|
+
var createInterceptors = /* @__PURE__ */ __name(() => ({
|
|
583
|
+
error: new Interceptors(),
|
|
584
|
+
request: new Interceptors(),
|
|
585
|
+
response: new Interceptors()
|
|
586
|
+
}), "createInterceptors");
|
|
587
|
+
var defaultQuerySerializer = createQuerySerializer({
|
|
588
|
+
allowReserved: false,
|
|
589
|
+
array: {
|
|
590
|
+
explode: true,
|
|
591
|
+
style: "form"
|
|
592
|
+
},
|
|
593
|
+
object: {
|
|
594
|
+
explode: true,
|
|
595
|
+
style: "deepObject"
|
|
596
|
+
}
|
|
597
|
+
});
|
|
598
|
+
var defaultHeaders = {
|
|
599
|
+
"Content-Type": "application/json"
|
|
600
|
+
};
|
|
601
|
+
var createConfig = /* @__PURE__ */ __name((override = {}) => ({
|
|
602
|
+
...jsonBodySerializer,
|
|
603
|
+
headers: defaultHeaders,
|
|
604
|
+
parseAs: "auto",
|
|
605
|
+
querySerializer: defaultQuerySerializer,
|
|
606
|
+
...override
|
|
607
|
+
}), "createConfig");
|
|
608
|
+
|
|
609
|
+
// src/_api/generated/client/client.gen.ts
|
|
610
|
+
var createClient = /* @__PURE__ */ __name((config = {}) => {
|
|
611
|
+
let _config = mergeConfigs(createConfig(), config);
|
|
612
|
+
const getConfig = /* @__PURE__ */ __name(() => ({ ..._config }), "getConfig");
|
|
613
|
+
const setConfig = /* @__PURE__ */ __name((config2) => {
|
|
614
|
+
_config = mergeConfigs(_config, config2);
|
|
615
|
+
return getConfig();
|
|
616
|
+
}, "setConfig");
|
|
617
|
+
const interceptors = createInterceptors();
|
|
618
|
+
const beforeRequest = /* @__PURE__ */ __name(async (options) => {
|
|
619
|
+
const opts = {
|
|
620
|
+
..._config,
|
|
621
|
+
...options,
|
|
622
|
+
fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
|
|
623
|
+
headers: mergeHeaders(_config.headers, options.headers),
|
|
624
|
+
serializedBody: void 0
|
|
625
|
+
};
|
|
626
|
+
if (opts.security) {
|
|
627
|
+
await setAuthParams({
|
|
628
|
+
...opts,
|
|
629
|
+
security: opts.security
|
|
1468
630
|
});
|
|
1469
631
|
}
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
try {
|
|
1473
|
-
const event = new CustomEvent("zod-validation-error", {
|
|
1474
|
-
detail: {
|
|
1475
|
-
operation: "partialUpdateAccountsProfilePartialUpdate",
|
|
1476
|
-
path: "/cfg/accounts/profile/partial/",
|
|
1477
|
-
method: "PUT",
|
|
1478
|
-
error,
|
|
1479
|
-
response,
|
|
1480
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
1481
|
-
},
|
|
1482
|
-
bubbles: true,
|
|
1483
|
-
cancelable: false
|
|
1484
|
-
});
|
|
1485
|
-
window.dispatchEvent(event);
|
|
1486
|
-
} catch (eventError) {
|
|
1487
|
-
consola3.warn("Failed to dispatch validation error event:", eventError);
|
|
1488
|
-
}
|
|
632
|
+
if (opts.requestValidator) {
|
|
633
|
+
await opts.requestValidator(opts);
|
|
1489
634
|
}
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
}
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
const api = client || getAPIInstance();
|
|
1496
|
-
const response = await api.user_profile.accountsProfilePartialPartialUpdate(data);
|
|
1497
|
-
try {
|
|
1498
|
-
return UserSchema.parse(response);
|
|
1499
|
-
} catch (error) {
|
|
1500
|
-
consola3.error("\u274C Zod Validation Failed");
|
|
1501
|
-
consola3.box(`partialUpdateAccountsProfilePartialPartialUpdate
|
|
1502
|
-
Path: /cfg/accounts/profile/partial/
|
|
1503
|
-
Method: PATCH`);
|
|
1504
|
-
if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
|
|
1505
|
-
consola3.error("Validation Issues:");
|
|
1506
|
-
error.issues.forEach((issue, index) => {
|
|
1507
|
-
consola3.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
|
|
1508
|
-
consola3.error(` \u251C\u2500 Message: ${issue.message}`);
|
|
1509
|
-
if (issue.expected) consola3.error(` \u251C\u2500 Expected: ${issue.expected}`);
|
|
1510
|
-
if (issue.received) consola3.error(` \u2514\u2500 Received: ${issue.received}`);
|
|
1511
|
-
});
|
|
635
|
+
if (opts.body !== void 0 && opts.bodySerializer) {
|
|
636
|
+
opts.serializedBody = opts.bodySerializer(opts.body);
|
|
637
|
+
}
|
|
638
|
+
if (opts.body === void 0 || opts.serializedBody === "") {
|
|
639
|
+
opts.headers.delete("Content-Type");
|
|
1512
640
|
}
|
|
1513
|
-
|
|
1514
|
-
|
|
641
|
+
const resolvedOpts = opts;
|
|
642
|
+
const url = buildUrl(resolvedOpts);
|
|
643
|
+
return { opts: resolvedOpts, url };
|
|
644
|
+
}, "beforeRequest");
|
|
645
|
+
const request = /* @__PURE__ */ __name(async (options) => {
|
|
646
|
+
const throwOnError = options.throwOnError ?? _config.throwOnError;
|
|
647
|
+
const responseStyle = options.responseStyle ?? _config.responseStyle;
|
|
648
|
+
let request2;
|
|
649
|
+
let response;
|
|
650
|
+
try {
|
|
651
|
+
const { opts, url } = await beforeRequest(options);
|
|
652
|
+
const requestInit = {
|
|
653
|
+
redirect: "follow",
|
|
654
|
+
...opts,
|
|
655
|
+
body: getValidRequestBody(opts)
|
|
656
|
+
};
|
|
657
|
+
request2 = new Request(url, requestInit);
|
|
658
|
+
for (const fn of interceptors.request.fns) {
|
|
659
|
+
if (fn) {
|
|
660
|
+
request2 = await fn(request2, opts);
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
const _fetch = opts.fetch;
|
|
664
|
+
response = await _fetch(request2);
|
|
665
|
+
for (const fn of interceptors.response.fns) {
|
|
666
|
+
if (fn) {
|
|
667
|
+
response = await fn(response, request2, opts);
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
const result = {
|
|
671
|
+
request: request2,
|
|
672
|
+
response
|
|
673
|
+
};
|
|
674
|
+
if (response.ok) {
|
|
675
|
+
const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
|
|
676
|
+
if (response.status === 204 || response.headers.get("Content-Length") === "0") {
|
|
677
|
+
let emptyData;
|
|
678
|
+
switch (parseAs) {
|
|
679
|
+
case "arrayBuffer":
|
|
680
|
+
case "blob":
|
|
681
|
+
case "text":
|
|
682
|
+
emptyData = await response[parseAs]();
|
|
683
|
+
break;
|
|
684
|
+
case "formData":
|
|
685
|
+
emptyData = new FormData();
|
|
686
|
+
break;
|
|
687
|
+
case "stream":
|
|
688
|
+
emptyData = response.body;
|
|
689
|
+
break;
|
|
690
|
+
case "json":
|
|
691
|
+
default:
|
|
692
|
+
emptyData = {};
|
|
693
|
+
break;
|
|
694
|
+
}
|
|
695
|
+
return opts.responseStyle === "data" ? emptyData : {
|
|
696
|
+
data: emptyData,
|
|
697
|
+
...result
|
|
698
|
+
};
|
|
699
|
+
}
|
|
700
|
+
let data;
|
|
701
|
+
switch (parseAs) {
|
|
702
|
+
case "arrayBuffer":
|
|
703
|
+
case "blob":
|
|
704
|
+
case "formData":
|
|
705
|
+
case "text":
|
|
706
|
+
data = await response[parseAs]();
|
|
707
|
+
break;
|
|
708
|
+
case "json": {
|
|
709
|
+
const text = await response.text();
|
|
710
|
+
data = text ? JSON.parse(text) : {};
|
|
711
|
+
break;
|
|
712
|
+
}
|
|
713
|
+
case "stream":
|
|
714
|
+
return opts.responseStyle === "data" ? response.body : {
|
|
715
|
+
data: response.body,
|
|
716
|
+
...result
|
|
717
|
+
};
|
|
718
|
+
}
|
|
719
|
+
if (parseAs === "json") {
|
|
720
|
+
if (opts.responseValidator) {
|
|
721
|
+
await opts.responseValidator(data);
|
|
722
|
+
}
|
|
723
|
+
if (opts.responseTransformer) {
|
|
724
|
+
data = await opts.responseTransformer(data);
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
return opts.responseStyle === "data" ? data : {
|
|
728
|
+
data,
|
|
729
|
+
...result
|
|
730
|
+
};
|
|
731
|
+
}
|
|
732
|
+
const textError = await response.text();
|
|
733
|
+
let jsonError;
|
|
1515
734
|
try {
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
cancelable: false
|
|
1527
|
-
});
|
|
1528
|
-
window.dispatchEvent(event);
|
|
1529
|
-
} catch (eventError) {
|
|
1530
|
-
consola3.warn("Failed to dispatch validation error event:", eventError);
|
|
735
|
+
jsonError = JSON.parse(textError);
|
|
736
|
+
} catch {
|
|
737
|
+
}
|
|
738
|
+
throw jsonError ?? textError;
|
|
739
|
+
} catch (error) {
|
|
740
|
+
let finalError = error;
|
|
741
|
+
for (const fn of interceptors.error.fns) {
|
|
742
|
+
if (fn) {
|
|
743
|
+
finalError = await fn(finalError, response, request2, options);
|
|
744
|
+
}
|
|
1531
745
|
}
|
|
746
|
+
finalError = finalError || {};
|
|
747
|
+
if (throwOnError) {
|
|
748
|
+
throw finalError;
|
|
749
|
+
}
|
|
750
|
+
return responseStyle === "data" ? void 0 : {
|
|
751
|
+
error: finalError,
|
|
752
|
+
request: request2,
|
|
753
|
+
response
|
|
754
|
+
};
|
|
1532
755
|
}
|
|
1533
|
-
|
|
1534
|
-
}
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
756
|
+
}, "request");
|
|
757
|
+
const makeMethodFn = /* @__PURE__ */ __name((method) => (options) => request({ ...options, method }), "makeMethodFn");
|
|
758
|
+
const makeSseFn = /* @__PURE__ */ __name((method) => async (options) => {
|
|
759
|
+
const { opts, url } = await beforeRequest(options);
|
|
760
|
+
return createSseClient({
|
|
761
|
+
...opts,
|
|
762
|
+
body: opts.body,
|
|
763
|
+
method,
|
|
764
|
+
onRequest: /* @__PURE__ */ __name(async (url2, init) => {
|
|
765
|
+
let request2 = new Request(url2, init);
|
|
766
|
+
for (const fn of interceptors.request.fns) {
|
|
767
|
+
if (fn) {
|
|
768
|
+
request2 = await fn(request2, opts);
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
return request2;
|
|
772
|
+
}, "onRequest"),
|
|
773
|
+
serializedBody: getValidRequestBody(opts),
|
|
774
|
+
url
|
|
775
|
+
});
|
|
776
|
+
}, "makeSseFn");
|
|
777
|
+
const _buildUrl = /* @__PURE__ */ __name((options) => buildUrl({ ..._config, ...options }), "_buildUrl");
|
|
778
|
+
return {
|
|
779
|
+
buildUrl: _buildUrl,
|
|
780
|
+
connect: makeMethodFn("CONNECT"),
|
|
781
|
+
delete: makeMethodFn("DELETE"),
|
|
782
|
+
get: makeMethodFn("GET"),
|
|
783
|
+
getConfig,
|
|
784
|
+
head: makeMethodFn("HEAD"),
|
|
785
|
+
interceptors,
|
|
786
|
+
options: makeMethodFn("OPTIONS"),
|
|
787
|
+
patch: makeMethodFn("PATCH"),
|
|
788
|
+
post: makeMethodFn("POST"),
|
|
789
|
+
put: makeMethodFn("PUT"),
|
|
790
|
+
request,
|
|
791
|
+
setConfig,
|
|
792
|
+
sse: {
|
|
793
|
+
connect: makeSseFn("CONNECT"),
|
|
794
|
+
delete: makeSseFn("DELETE"),
|
|
795
|
+
get: makeSseFn("GET"),
|
|
796
|
+
head: makeSseFn("HEAD"),
|
|
797
|
+
options: makeSseFn("OPTIONS"),
|
|
798
|
+
patch: makeSseFn("PATCH"),
|
|
799
|
+
post: makeSseFn("POST"),
|
|
800
|
+
put: makeSseFn("PUT"),
|
|
801
|
+
trace: makeSseFn("TRACE")
|
|
802
|
+
},
|
|
803
|
+
trace: makeMethodFn("TRACE")
|
|
804
|
+
};
|
|
805
|
+
}, "createClient");
|
|
806
|
+
|
|
807
|
+
// src/_api/generated/helpers/auth.ts
|
|
808
|
+
var ACCESS_KEY = "cfg.access_token";
|
|
809
|
+
var REFRESH_KEY = "cfg.refresh_token";
|
|
810
|
+
var API_KEY_KEY = "cfg.api_key";
|
|
811
|
+
var isBrowser = typeof window !== "undefined";
|
|
812
|
+
var localStorageBackend = {
|
|
813
|
+
get(key) {
|
|
814
|
+
if (!isBrowser) return null;
|
|
815
|
+
try {
|
|
816
|
+
return window.localStorage.getItem(key);
|
|
817
|
+
} catch {
|
|
818
|
+
return null;
|
|
1555
819
|
}
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
method: "PUT",
|
|
1564
|
-
error,
|
|
1565
|
-
response,
|
|
1566
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
1567
|
-
},
|
|
1568
|
-
bubbles: true,
|
|
1569
|
-
cancelable: false
|
|
1570
|
-
});
|
|
1571
|
-
window.dispatchEvent(event);
|
|
1572
|
-
} catch (eventError) {
|
|
1573
|
-
consola3.warn("Failed to dispatch validation error event:", eventError);
|
|
1574
|
-
}
|
|
820
|
+
},
|
|
821
|
+
set(key, value) {
|
|
822
|
+
if (!isBrowser) return;
|
|
823
|
+
try {
|
|
824
|
+
if (value === null) window.localStorage.removeItem(key);
|
|
825
|
+
else window.localStorage.setItem(key, value);
|
|
826
|
+
} catch {
|
|
1575
827
|
}
|
|
1576
|
-
throw error;
|
|
1577
828
|
}
|
|
1578
|
-
}
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
Method: PATCH`);
|
|
1590
|
-
if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
|
|
1591
|
-
consola3.error("Validation Issues:");
|
|
1592
|
-
error.issues.forEach((issue, index) => {
|
|
1593
|
-
consola3.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
|
|
1594
|
-
consola3.error(` \u251C\u2500 Message: ${issue.message}`);
|
|
1595
|
-
if (issue.expected) consola3.error(` \u251C\u2500 Expected: ${issue.expected}`);
|
|
1596
|
-
if (issue.received) consola3.error(` \u2514\u2500 Received: ${issue.received}`);
|
|
1597
|
-
});
|
|
829
|
+
};
|
|
830
|
+
var COOKIE_MAX_AGE = 60 * 60 * 24 * 30;
|
|
831
|
+
var cookieBackend = {
|
|
832
|
+
get(key) {
|
|
833
|
+
if (!isBrowser) return null;
|
|
834
|
+
try {
|
|
835
|
+
const re = new RegExp(`(?:^|;\\s*)${encodeURIComponent(key)}=([^;]*)`);
|
|
836
|
+
const m = document.cookie.match(re);
|
|
837
|
+
return m ? decodeURIComponent(m[1]) : null;
|
|
838
|
+
} catch {
|
|
839
|
+
return null;
|
|
1598
840
|
}
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
},
|
|
1611
|
-
bubbles: true,
|
|
1612
|
-
cancelable: false
|
|
1613
|
-
});
|
|
1614
|
-
window.dispatchEvent(event);
|
|
1615
|
-
} catch (eventError) {
|
|
1616
|
-
consola3.warn("Failed to dispatch validation error event:", eventError);
|
|
841
|
+
},
|
|
842
|
+
set(key, value) {
|
|
843
|
+
if (!isBrowser) return;
|
|
844
|
+
try {
|
|
845
|
+
const k = encodeURIComponent(key);
|
|
846
|
+
const secure = window.location.protocol === "https:" ? "; Secure" : "";
|
|
847
|
+
if (value === null) {
|
|
848
|
+
document.cookie = `${k}=; Path=/; Max-Age=0; SameSite=Lax${secure}`;
|
|
849
|
+
} else {
|
|
850
|
+
const v = encodeURIComponent(value);
|
|
851
|
+
document.cookie = `${k}=${v}; Path=/; Max-Age=${COOKIE_MAX_AGE}; SameSite=Lax${secure}`;
|
|
1617
852
|
}
|
|
853
|
+
} catch {
|
|
1618
854
|
}
|
|
1619
|
-
throw error;
|
|
1620
855
|
}
|
|
1621
|
-
}
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
// src/_api/generated/cfg_accounts/index.ts
|
|
1625
|
-
var TOKEN_KEY = "auth_token";
|
|
1626
|
-
var REFRESH_TOKEN_KEY = "refresh_token";
|
|
856
|
+
};
|
|
857
|
+
var _storage = localStorageBackend;
|
|
858
|
+
var _storageMode = "localStorage";
|
|
1627
859
|
function detectLocale() {
|
|
1628
860
|
try {
|
|
1629
861
|
if (typeof document !== "undefined") {
|
|
1630
|
-
const
|
|
1631
|
-
if (
|
|
862
|
+
const m = document.cookie.match(/(?:^|;\s*)NEXT_LOCALE=([^;]*)/);
|
|
863
|
+
if (m) return decodeURIComponent(m[1]);
|
|
1632
864
|
}
|
|
1633
865
|
if (typeof navigator !== "undefined" && navigator.language) {
|
|
1634
866
|
return navigator.language;
|
|
@@ -1638,386 +870,507 @@ function detectLocale() {
|
|
|
1638
870
|
return null;
|
|
1639
871
|
}
|
|
1640
872
|
__name(detectLocale, "detectLocale");
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
_refreshToken = null;
|
|
1649
|
-
_locale = null;
|
|
1650
|
-
storage;
|
|
1651
|
-
options;
|
|
1652
|
-
// Sub-clients
|
|
1653
|
-
auth;
|
|
1654
|
-
oauth;
|
|
1655
|
-
user_profile;
|
|
1656
|
-
accounts;
|
|
1657
|
-
constructor(baseUrl, options) {
|
|
1658
|
-
this.baseUrl = baseUrl;
|
|
1659
|
-
this.options = options;
|
|
1660
|
-
const logger = options?.loggerConfig ? new APILogger(options.loggerConfig) : void 0;
|
|
1661
|
-
this.storage = options?.storage || new LocalStorageAdapter(logger);
|
|
1662
|
-
this._locale = options?.locale || null;
|
|
1663
|
-
this._loadTokensFromStorage();
|
|
1664
|
-
this._client = new APIClient(this.baseUrl, {
|
|
1665
|
-
httpClient: this.options?.httpClient,
|
|
1666
|
-
retryConfig: this.options?.retryConfig,
|
|
1667
|
-
loggerConfig: this.options?.loggerConfig,
|
|
1668
|
-
tokenGetter: /* @__PURE__ */ __name(() => this.getToken(), "tokenGetter")
|
|
1669
|
-
});
|
|
1670
|
-
this._injectAuthHeader();
|
|
1671
|
-
this.auth = this._client.auth;
|
|
1672
|
-
this.oauth = this._client.oauth;
|
|
1673
|
-
this.user_profile = this._client.user_profile;
|
|
1674
|
-
this.accounts = this._client.accounts;
|
|
1675
|
-
}
|
|
1676
|
-
_loadTokensFromStorage() {
|
|
1677
|
-
this._token = this.storage.getItem(TOKEN_KEY);
|
|
1678
|
-
this._refreshToken = this.storage.getItem(REFRESH_TOKEN_KEY);
|
|
1679
|
-
}
|
|
1680
|
-
_reinitClients() {
|
|
1681
|
-
this._client = new APIClient(this.baseUrl, {
|
|
1682
|
-
httpClient: this.options?.httpClient,
|
|
1683
|
-
retryConfig: this.options?.retryConfig,
|
|
1684
|
-
loggerConfig: this.options?.loggerConfig,
|
|
1685
|
-
tokenGetter: /* @__PURE__ */ __name(() => this.getToken(), "tokenGetter")
|
|
1686
|
-
});
|
|
1687
|
-
this._injectAuthHeader();
|
|
1688
|
-
this.auth = this._client.auth;
|
|
1689
|
-
this.oauth = this._client.oauth;
|
|
1690
|
-
this.user_profile = this._client.user_profile;
|
|
1691
|
-
this.accounts = this._client.accounts;
|
|
873
|
+
function defaultBaseUrl() {
|
|
874
|
+
try {
|
|
875
|
+
if (typeof process !== "undefined" && process.env) {
|
|
876
|
+
if (process.env.NEXT_PUBLIC_STATIC_BUILD === "true") return "";
|
|
877
|
+
return process.env.NEXT_PUBLIC_API_URL || "";
|
|
878
|
+
}
|
|
879
|
+
} catch {
|
|
1692
880
|
}
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
...token ? { "Authorization": `Bearer ${token}` } : {},
|
|
1703
|
-
...locale ? { "Accept-Language": locale } : {}
|
|
1704
|
-
}
|
|
1705
|
-
};
|
|
1706
|
-
return originalRequest(method, path, mergedOptions);
|
|
1707
|
-
};
|
|
881
|
+
return "";
|
|
882
|
+
}
|
|
883
|
+
__name(defaultBaseUrl, "defaultBaseUrl");
|
|
884
|
+
function defaultApiKey() {
|
|
885
|
+
try {
|
|
886
|
+
if (typeof process !== "undefined" && process.env?.NEXT_PUBLIC_API_KEY) {
|
|
887
|
+
return process.env.NEXT_PUBLIC_API_KEY;
|
|
888
|
+
}
|
|
889
|
+
} catch {
|
|
1708
890
|
}
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
891
|
+
return null;
|
|
892
|
+
}
|
|
893
|
+
__name(defaultApiKey, "defaultApiKey");
|
|
894
|
+
var _localeOverride = null;
|
|
895
|
+
var _apiKeyOverride = null;
|
|
896
|
+
var _baseUrlOverride = null;
|
|
897
|
+
var _withCredentials = true;
|
|
898
|
+
var _onUnauthorized = null;
|
|
899
|
+
var _refreshHandler = null;
|
|
900
|
+
var _refreshInflight = null;
|
|
901
|
+
var RETRY_MARKER = "X-Auth-Retry";
|
|
902
|
+
var _client = null;
|
|
903
|
+
function pushClientConfig() {
|
|
904
|
+
if (!_client) return;
|
|
905
|
+
_client.setConfig({
|
|
906
|
+
baseUrl: auth.getBaseUrl(),
|
|
907
|
+
credentials: _withCredentials ? "include" : "same-origin"
|
|
908
|
+
});
|
|
909
|
+
}
|
|
910
|
+
__name(pushClientConfig, "pushClientConfig");
|
|
911
|
+
var auth = {
|
|
912
|
+
// ── Storage mode ──────────────────────────────────────────────────
|
|
913
|
+
getStorageMode() {
|
|
914
|
+
return _storageMode;
|
|
915
|
+
},
|
|
916
|
+
setStorageMode(mode) {
|
|
917
|
+
_storageMode = mode;
|
|
918
|
+
_storage = mode === "cookie" ? cookieBackend : localStorageBackend;
|
|
919
|
+
},
|
|
920
|
+
// ── Bearer token ──────────────────────────────────────────────────
|
|
1712
921
|
getToken() {
|
|
1713
|
-
return
|
|
1714
|
-
}
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
922
|
+
return _storage.get(ACCESS_KEY);
|
|
923
|
+
},
|
|
924
|
+
setToken(token) {
|
|
925
|
+
_storage.set(ACCESS_KEY, token);
|
|
926
|
+
},
|
|
1718
927
|
getRefreshToken() {
|
|
1719
|
-
return
|
|
1720
|
-
}
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
* @param refreshToken - JWT refresh token (optional)
|
|
1725
|
-
*/
|
|
1726
|
-
setToken(token, refreshToken) {
|
|
1727
|
-
this._token = token;
|
|
1728
|
-
this.storage.setItem(TOKEN_KEY, token);
|
|
1729
|
-
if (refreshToken) {
|
|
1730
|
-
this._refreshToken = refreshToken;
|
|
1731
|
-
this.storage.setItem(REFRESH_TOKEN_KEY, refreshToken);
|
|
1732
|
-
}
|
|
1733
|
-
this._reinitClients();
|
|
1734
|
-
}
|
|
1735
|
-
/**
|
|
1736
|
-
* Clear all tokens
|
|
1737
|
-
*/
|
|
928
|
+
return _storage.get(REFRESH_KEY);
|
|
929
|
+
},
|
|
930
|
+
setRefreshToken(token) {
|
|
931
|
+
_storage.set(REFRESH_KEY, token);
|
|
932
|
+
},
|
|
1738
933
|
clearTokens() {
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
this.storage.removeItem(REFRESH_TOKEN_KEY);
|
|
1743
|
-
this._reinitClients();
|
|
1744
|
-
}
|
|
1745
|
-
/**
|
|
1746
|
-
* Check if user is authenticated
|
|
1747
|
-
*/
|
|
934
|
+
_storage.set(ACCESS_KEY, null);
|
|
935
|
+
_storage.set(REFRESH_KEY, null);
|
|
936
|
+
},
|
|
1748
937
|
isAuthenticated() {
|
|
1749
|
-
return
|
|
1750
|
-
}
|
|
938
|
+
return _storage.get(ACCESS_KEY) !== null;
|
|
939
|
+
},
|
|
940
|
+
// ── API key ───────────────────────────────────────────────────────
|
|
941
|
+
getApiKey() {
|
|
942
|
+
return _apiKeyOverride ?? _storage.get(API_KEY_KEY) ?? defaultApiKey();
|
|
943
|
+
},
|
|
944
|
+
setApiKey(key) {
|
|
945
|
+
_apiKeyOverride = key;
|
|
946
|
+
},
|
|
947
|
+
setApiKeyPersist(key) {
|
|
948
|
+
_apiKeyOverride = key;
|
|
949
|
+
_storage.set(API_KEY_KEY, key);
|
|
950
|
+
},
|
|
951
|
+
clearApiKey() {
|
|
952
|
+
_apiKeyOverride = null;
|
|
953
|
+
_storage.set(API_KEY_KEY, null);
|
|
954
|
+
},
|
|
955
|
+
// ── Locale ────────────────────────────────────────────────────────
|
|
956
|
+
getLocale() {
|
|
957
|
+
return _localeOverride ?? detectLocale();
|
|
958
|
+
},
|
|
959
|
+
setLocale(locale) {
|
|
960
|
+
_localeOverride = locale;
|
|
961
|
+
},
|
|
962
|
+
// ── Base URL ──────────────────────────────────────────────────────
|
|
963
|
+
getBaseUrl() {
|
|
964
|
+
const url = _baseUrlOverride ?? defaultBaseUrl();
|
|
965
|
+
return url.replace(/\/$/, "");
|
|
966
|
+
},
|
|
967
|
+
setBaseUrl(url) {
|
|
968
|
+
_baseUrlOverride = url ? url.replace(/\/$/, "") : null;
|
|
969
|
+
pushClientConfig();
|
|
970
|
+
},
|
|
971
|
+
// ── Credentials toggle ────────────────────────────────────────────
|
|
972
|
+
getWithCredentials() {
|
|
973
|
+
return _withCredentials;
|
|
974
|
+
},
|
|
975
|
+
setWithCredentials(value) {
|
|
976
|
+
_withCredentials = value;
|
|
977
|
+
pushClientConfig();
|
|
978
|
+
},
|
|
979
|
+
// ── 401 handler ───────────────────────────────────────────────────
|
|
1751
980
|
/**
|
|
1752
|
-
*
|
|
1753
|
-
*
|
|
981
|
+
* Fired when the server returns 401 AND no refresh path recovers it
|
|
982
|
+
* (no refresh token, no refresh handler, refresh failed, or retry
|
|
983
|
+
* still 401). The app should clear local state and redirect to login.
|
|
984
|
+
*
|
|
985
|
+
* NOT fired for 401 that gets transparently recovered by the refresh
|
|
986
|
+
* handler — those are invisible to callers.
|
|
1754
987
|
*/
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
}
|
|
988
|
+
onUnauthorized(cb) {
|
|
989
|
+
_onUnauthorized = cb;
|
|
990
|
+
},
|
|
1759
991
|
/**
|
|
1760
|
-
*
|
|
992
|
+
* Register the refresh strategy. The handler receives the current
|
|
993
|
+
* refresh token and must call your refresh endpoint, returning
|
|
994
|
+
* `{ access, refresh? }` on success or `null` on failure.
|
|
995
|
+
*
|
|
996
|
+
* @example
|
|
997
|
+
* auth.setRefreshHandler(async (refresh) => {
|
|
998
|
+
* const { data } = await Auth.tokenRefreshCreate({ body: { refresh } });
|
|
999
|
+
* return data ? { access: data.access, refresh: data.refresh } : null;
|
|
1000
|
+
* });
|
|
1761
1001
|
*/
|
|
1762
|
-
|
|
1763
|
-
|
|
1002
|
+
setRefreshHandler(fn) {
|
|
1003
|
+
_refreshHandler = fn;
|
|
1004
|
+
}
|
|
1005
|
+
};
|
|
1006
|
+
async function tryRefresh() {
|
|
1007
|
+
if (_refreshInflight) return _refreshInflight;
|
|
1008
|
+
if (!_refreshHandler) return null;
|
|
1009
|
+
const refresh = auth.getRefreshToken();
|
|
1010
|
+
if (!refresh) return null;
|
|
1011
|
+
_refreshInflight = (async () => {
|
|
1012
|
+
try {
|
|
1013
|
+
const result = await _refreshHandler(refresh);
|
|
1014
|
+
if (!result?.access) return null;
|
|
1015
|
+
auth.setToken(result.access);
|
|
1016
|
+
if (result.refresh) auth.setRefreshToken(result.refresh);
|
|
1017
|
+
return result.access;
|
|
1018
|
+
} catch {
|
|
1019
|
+
return null;
|
|
1020
|
+
} finally {
|
|
1021
|
+
_refreshInflight = null;
|
|
1022
|
+
}
|
|
1023
|
+
})();
|
|
1024
|
+
return _refreshInflight;
|
|
1025
|
+
}
|
|
1026
|
+
__name(tryRefresh, "tryRefresh");
|
|
1027
|
+
function installAuthOnClient(client2) {
|
|
1028
|
+
if (_client) return;
|
|
1029
|
+
_client = client2;
|
|
1030
|
+
client2.setConfig({
|
|
1031
|
+
baseUrl: auth.getBaseUrl(),
|
|
1032
|
+
credentials: _withCredentials ? "include" : "same-origin"
|
|
1033
|
+
});
|
|
1034
|
+
client2.interceptors.request.use((request) => {
|
|
1035
|
+
const token = auth.getToken();
|
|
1036
|
+
if (token) request.headers.set("Authorization", `Bearer ${token}`);
|
|
1037
|
+
const locale = auth.getLocale();
|
|
1038
|
+
if (locale) request.headers.set("Accept-Language", locale);
|
|
1039
|
+
const apiKey = auth.getApiKey();
|
|
1040
|
+
if (apiKey) request.headers.set("X-API-Key", apiKey);
|
|
1041
|
+
try {
|
|
1042
|
+
const tz = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
1043
|
+
if (tz) request.headers.set("X-Timezone", tz);
|
|
1044
|
+
} catch {
|
|
1045
|
+
}
|
|
1046
|
+
request.headers.set("X-Client-Time", (/* @__PURE__ */ new Date()).toISOString());
|
|
1047
|
+
return request;
|
|
1048
|
+
});
|
|
1049
|
+
client2.interceptors.response.use(async (response, request) => {
|
|
1050
|
+
if (response.status !== 401) return response;
|
|
1051
|
+
if (request.headers.get(RETRY_MARKER)) {
|
|
1052
|
+
if (_onUnauthorized) {
|
|
1053
|
+
try {
|
|
1054
|
+
_onUnauthorized(response);
|
|
1055
|
+
} catch {
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
return response;
|
|
1059
|
+
}
|
|
1060
|
+
const newToken = await tryRefresh();
|
|
1061
|
+
if (!newToken) {
|
|
1062
|
+
if (_onUnauthorized) {
|
|
1063
|
+
try {
|
|
1064
|
+
_onUnauthorized(response);
|
|
1065
|
+
} catch {
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
return response;
|
|
1069
|
+
}
|
|
1070
|
+
const retry = request.clone();
|
|
1071
|
+
retry.headers.set("Authorization", `Bearer ${newToken}`);
|
|
1072
|
+
retry.headers.set(RETRY_MARKER, "1");
|
|
1073
|
+
try {
|
|
1074
|
+
const retried = await fetch(retry);
|
|
1075
|
+
if (retried.status === 401 && _onUnauthorized) {
|
|
1076
|
+
try {
|
|
1077
|
+
_onUnauthorized(retried);
|
|
1078
|
+
} catch {
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
return retried;
|
|
1082
|
+
} catch {
|
|
1083
|
+
if (_onUnauthorized) {
|
|
1084
|
+
try {
|
|
1085
|
+
_onUnauthorized(response);
|
|
1086
|
+
} catch {
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
return response;
|
|
1090
|
+
}
|
|
1091
|
+
});
|
|
1092
|
+
}
|
|
1093
|
+
__name(installAuthOnClient, "installAuthOnClient");
|
|
1094
|
+
|
|
1095
|
+
// src/_api/generated/client.gen.ts
|
|
1096
|
+
var client = createClient(createConfig({ baseUrl: "http://localhost:8000" }));
|
|
1097
|
+
installAuthOnClient(client);
|
|
1098
|
+
|
|
1099
|
+
// src/_api/generated/sdk.gen.ts
|
|
1100
|
+
var CfgAccountsApiKey = class {
|
|
1101
|
+
static {
|
|
1102
|
+
__name(this, "CfgAccountsApiKey");
|
|
1764
1103
|
}
|
|
1765
1104
|
/**
|
|
1766
|
-
*
|
|
1767
|
-
*
|
|
1105
|
+
* Get API key details
|
|
1106
|
+
*
|
|
1107
|
+
* Retrieve the current user's API key (masked) and metadata.
|
|
1768
1108
|
*/
|
|
1769
|
-
|
|
1770
|
-
|
|
1109
|
+
static cfgAccountsApiKeyRetrieve(options) {
|
|
1110
|
+
return (options?.client ?? client).get({
|
|
1111
|
+
security: [{ scheme: "bearer", type: "http" }, {
|
|
1112
|
+
in: "cookie",
|
|
1113
|
+
name: "sessionid",
|
|
1114
|
+
type: "apiKey"
|
|
1115
|
+
}],
|
|
1116
|
+
url: "/cfg/accounts/api-key/",
|
|
1117
|
+
...options
|
|
1118
|
+
});
|
|
1771
1119
|
}
|
|
1772
1120
|
/**
|
|
1773
|
-
*
|
|
1121
|
+
* Regenerate API key
|
|
1122
|
+
*
|
|
1123
|
+
* Generate a new API key. The full key is returned only once.
|
|
1774
1124
|
*/
|
|
1775
|
-
|
|
1776
|
-
return
|
|
1125
|
+
static cfgAccountsApiKeyRegenerateCreate(options) {
|
|
1126
|
+
return (options.client ?? client).post({
|
|
1127
|
+
security: [{ scheme: "bearer", type: "http" }, {
|
|
1128
|
+
in: "cookie",
|
|
1129
|
+
name: "sessionid",
|
|
1130
|
+
type: "apiKey"
|
|
1131
|
+
}],
|
|
1132
|
+
url: "/cfg/accounts/api-key/regenerate/",
|
|
1133
|
+
...options,
|
|
1134
|
+
headers: {
|
|
1135
|
+
"Content-Type": "application/json",
|
|
1136
|
+
...options.headers
|
|
1137
|
+
}
|
|
1138
|
+
});
|
|
1777
1139
|
}
|
|
1778
1140
|
/**
|
|
1779
|
-
*
|
|
1780
|
-
* @returns Path to the OpenAPI schema JSON file
|
|
1141
|
+
* Test API key
|
|
1781
1142
|
*
|
|
1782
|
-
*
|
|
1783
|
-
* You can load it dynamically using:
|
|
1784
|
-
* ```typescript
|
|
1785
|
-
* const schema = await fetch('./schema.json').then(r => r.json());
|
|
1786
|
-
* // or using fs in Node.js:
|
|
1787
|
-
* // const schema = JSON.parse(fs.readFileSync('./schema.json', 'utf-8'));
|
|
1788
|
-
* ```
|
|
1143
|
+
* Test whether an API key is valid without consuming it.
|
|
1789
1144
|
*/
|
|
1790
|
-
|
|
1791
|
-
return
|
|
1145
|
+
static cfgAccountsApiKeyTestCreate(options) {
|
|
1146
|
+
return (options.client ?? client).post({
|
|
1147
|
+
security: [{ scheme: "bearer", type: "http" }, {
|
|
1148
|
+
in: "cookie",
|
|
1149
|
+
name: "sessionid",
|
|
1150
|
+
type: "apiKey"
|
|
1151
|
+
}],
|
|
1152
|
+
url: "/cfg/accounts/api-key/test/",
|
|
1153
|
+
...options,
|
|
1154
|
+
headers: {
|
|
1155
|
+
"Content-Type": "application/json",
|
|
1156
|
+
...options.headers
|
|
1157
|
+
}
|
|
1158
|
+
});
|
|
1792
1159
|
}
|
|
1793
1160
|
};
|
|
1794
1161
|
|
|
1795
|
-
// src/_api/generated/
|
|
1796
|
-
|
|
1797
|
-
var
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
if (globalAPI) return;
|
|
1802
|
-
if (typeof process === "undefined" || !process.env) return;
|
|
1803
|
-
const baseUrl = process.env.NEXT_PUBLIC_API_URL || process.env.VITE_API_URL || process.env.REACT_APP_API_URL || process.env.API_URL;
|
|
1804
|
-
if (baseUrl) {
|
|
1805
|
-
globalAPI = new API(baseUrl);
|
|
1806
|
-
}
|
|
1807
|
-
}
|
|
1808
|
-
__name(tryAutoConfigureFromEnv, "tryAutoConfigureFromEnv");
|
|
1809
|
-
function getAPIInstance() {
|
|
1810
|
-
tryAutoConfigureFromEnv();
|
|
1811
|
-
if (!globalAPI) {
|
|
1812
|
-
throw new Error(
|
|
1813
|
-
'API not configured. Call configureAPI() with your base URL before using fetchers or hooks.\n\nExample:\n import { configureAPI } from "./api-instance"\n configureAPI({ baseUrl: "https://api.example.com" })\n\nOr set environment variable: NEXT_PUBLIC_API_URL, VITE_API_URL, or REACT_APP_API_URL'
|
|
1814
|
-
);
|
|
1815
|
-
}
|
|
1816
|
-
return globalAPI;
|
|
1817
|
-
}
|
|
1818
|
-
__name(getAPIInstance, "getAPIInstance");
|
|
1162
|
+
// src/_api/generated/_cfg_accounts/schemas/APIKeyRegenerate.ts
|
|
1163
|
+
import { z } from "zod";
|
|
1164
|
+
var APIKeyRegenerateSchema = z.object({
|
|
1165
|
+
key: z.string(),
|
|
1166
|
+
reissued_at: z.string().datetime({ offset: true })
|
|
1167
|
+
});
|
|
1819
1168
|
|
|
1820
|
-
// src/_api/generated/
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
error.issues.forEach((issue, index) => {
|
|
1834
|
-
consola4.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
|
|
1835
|
-
consola4.error(` \u251C\u2500 Message: ${issue.message}`);
|
|
1836
|
-
if (issue.expected) consola4.error(` \u251C\u2500 Expected: ${issue.expected}`);
|
|
1837
|
-
if (issue.received) consola4.error(` \u2514\u2500 Received: ${issue.received}`);
|
|
1838
|
-
});
|
|
1839
|
-
}
|
|
1840
|
-
consola4.error("Response data:", response);
|
|
1841
|
-
if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
|
|
1842
|
-
try {
|
|
1843
|
-
const event = new CustomEvent("zod-validation-error", {
|
|
1844
|
-
detail: {
|
|
1845
|
-
operation: "createAccountsTokenRefreshCreate",
|
|
1846
|
-
path: "/cfg/accounts/token/refresh/",
|
|
1169
|
+
// src/_api/generated/_cfg_accounts/hooks/useCfgAccountsApiKeyRegenerateCreate.ts
|
|
1170
|
+
function useCfgAccountsApiKeyRegenerateCreate(config) {
|
|
1171
|
+
return useSWRMutation(
|
|
1172
|
+
["cfg_accounts_api_key_regenerate_create"],
|
|
1173
|
+
async (_key, { arg }) => {
|
|
1174
|
+
const res = await CfgAccountsApiKey.cfgAccountsApiKeyRegenerateCreate({ ...arg, throwOnError: true });
|
|
1175
|
+
const data = res.data;
|
|
1176
|
+
const parsed = APIKeyRegenerateSchema.safeParse(data);
|
|
1177
|
+
if (!parsed.success) {
|
|
1178
|
+
console.warn(
|
|
1179
|
+
"[zod] response did not match schema",
|
|
1180
|
+
{
|
|
1181
|
+
operation: "cfg_accounts_api_key_regenerate_create",
|
|
1847
1182
|
method: "POST",
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
}
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1183
|
+
path: "/cfg/accounts/api-key/regenerate/",
|
|
1184
|
+
issues: parsed.error.issues,
|
|
1185
|
+
data
|
|
1186
|
+
}
|
|
1187
|
+
);
|
|
1188
|
+
if (typeof window !== "undefined") {
|
|
1189
|
+
try {
|
|
1190
|
+
window.dispatchEvent(
|
|
1191
|
+
new CustomEvent("zod-validation-error", {
|
|
1192
|
+
detail: {
|
|
1193
|
+
operation: "cfg_accounts_api_key_regenerate_create",
|
|
1194
|
+
method: "POST",
|
|
1195
|
+
path: "/cfg/accounts/api-key/regenerate/",
|
|
1196
|
+
issues: parsed.error.issues,
|
|
1197
|
+
data,
|
|
1198
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
1199
|
+
},
|
|
1200
|
+
bubbles: true,
|
|
1201
|
+
cancelable: false
|
|
1202
|
+
})
|
|
1203
|
+
);
|
|
1204
|
+
} catch {
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
return data;
|
|
1858
1208
|
}
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
__name(createAccountsTokenRefreshCreate, "createAccountsTokenRefreshCreate");
|
|
1864
|
-
|
|
1865
|
-
// src/_api/generated/cfg_accounts/_utils/hooks/accounts__auth.ts
|
|
1866
|
-
function useCreateAccountsTokenRefreshCreate() {
|
|
1867
|
-
const { mutate } = useSWRConfig();
|
|
1868
|
-
return async (data, client) => {
|
|
1869
|
-
const result = await createAccountsTokenRefreshCreate(data, client);
|
|
1870
|
-
mutate("cfg-accounts-token-refresh");
|
|
1871
|
-
return result;
|
|
1872
|
-
};
|
|
1209
|
+
return parsed.data;
|
|
1210
|
+
},
|
|
1211
|
+
config
|
|
1212
|
+
);
|
|
1873
1213
|
}
|
|
1874
|
-
__name(
|
|
1214
|
+
__name(useCfgAccountsApiKeyRegenerateCreate, "useCfgAccountsApiKeyRegenerateCreate");
|
|
1875
1215
|
|
|
1876
|
-
// src/_api/generated/
|
|
1216
|
+
// src/_api/generated/_cfg_accounts/hooks/useCfgAccountsApiKeyRetrieve.ts
|
|
1877
1217
|
import useSWR from "swr";
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
)
|
|
1884
|
-
}
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
mutate("cfg-accounts-oauth-disconnect");
|
|
1891
|
-
return result;
|
|
1892
|
-
};
|
|
1893
|
-
}
|
|
1894
|
-
__name(useCreateAccountsOauthDisconnectCreate, "useCreateAccountsOauthDisconnectCreate");
|
|
1895
|
-
function useCreateAccountsOauthGithubAuthorizeCreate() {
|
|
1896
|
-
const { mutate } = useSWRConfig2();
|
|
1897
|
-
return async (data, client) => {
|
|
1898
|
-
const result = await createAccountsOauthGithubAuthorizeCreate(data, client);
|
|
1899
|
-
mutate("cfg-accounts-oauth-github-authorize");
|
|
1900
|
-
return result;
|
|
1901
|
-
};
|
|
1902
|
-
}
|
|
1903
|
-
__name(useCreateAccountsOauthGithubAuthorizeCreate, "useCreateAccountsOauthGithubAuthorizeCreate");
|
|
1904
|
-
function useCreateAccountsOauthGithubCallbackCreate() {
|
|
1905
|
-
const { mutate } = useSWRConfig2();
|
|
1906
|
-
return async (data, client) => {
|
|
1907
|
-
const result = await createAccountsOauthGithubCallbackCreate(data, client);
|
|
1908
|
-
mutate("cfg-accounts-oauth-github-callback");
|
|
1909
|
-
return result;
|
|
1910
|
-
};
|
|
1911
|
-
}
|
|
1912
|
-
__name(useCreateAccountsOauthGithubCallbackCreate, "useCreateAccountsOauthGithubCallbackCreate");
|
|
1913
|
-
function useAccountsOauthProvidersRetrieve(client) {
|
|
1218
|
+
|
|
1219
|
+
// src/_api/generated/_cfg_accounts/schemas/APIKey.ts
|
|
1220
|
+
import { z as z2 } from "zod";
|
|
1221
|
+
var APIKeySchema = z2.object({
|
|
1222
|
+
key: z2.string(),
|
|
1223
|
+
reissued_at: z2.string().datetime({ offset: true }).nullable(),
|
|
1224
|
+
created_at: z2.string().datetime({ offset: true })
|
|
1225
|
+
});
|
|
1226
|
+
|
|
1227
|
+
// src/_api/generated/_cfg_accounts/hooks/useCfgAccountsApiKeyRetrieve.ts
|
|
1228
|
+
function useCfgAccountsApiKeyRetrieve(args, config) {
|
|
1229
|
+
const key = ["cfg_accounts_api_key_retrieve", args ?? {}];
|
|
1914
1230
|
return useSWR(
|
|
1915
|
-
|
|
1916
|
-
() =>
|
|
1231
|
+
key,
|
|
1232
|
+
async () => {
|
|
1233
|
+
const res = await CfgAccountsApiKey.cfgAccountsApiKeyRetrieve({ ...args ?? {}, throwOnError: true });
|
|
1234
|
+
const data = res.data;
|
|
1235
|
+
const parsed = APIKeySchema.safeParse(data);
|
|
1236
|
+
if (!parsed.success) {
|
|
1237
|
+
console.warn(
|
|
1238
|
+
"[zod] response did not match schema",
|
|
1239
|
+
{
|
|
1240
|
+
operation: "cfg_accounts_api_key_retrieve",
|
|
1241
|
+
method: "GET",
|
|
1242
|
+
path: "/cfg/accounts/api-key/",
|
|
1243
|
+
issues: parsed.error.issues,
|
|
1244
|
+
data
|
|
1245
|
+
}
|
|
1246
|
+
);
|
|
1247
|
+
if (typeof window !== "undefined") {
|
|
1248
|
+
try {
|
|
1249
|
+
window.dispatchEvent(
|
|
1250
|
+
new CustomEvent("zod-validation-error", {
|
|
1251
|
+
detail: {
|
|
1252
|
+
operation: "cfg_accounts_api_key_retrieve",
|
|
1253
|
+
method: "GET",
|
|
1254
|
+
path: "/cfg/accounts/api-key/",
|
|
1255
|
+
issues: parsed.error.issues,
|
|
1256
|
+
data,
|
|
1257
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
1258
|
+
},
|
|
1259
|
+
bubbles: true,
|
|
1260
|
+
cancelable: false
|
|
1261
|
+
})
|
|
1262
|
+
);
|
|
1263
|
+
} catch {
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
return data;
|
|
1267
|
+
}
|
|
1268
|
+
return parsed.data;
|
|
1269
|
+
},
|
|
1270
|
+
config
|
|
1917
1271
|
);
|
|
1918
1272
|
}
|
|
1919
|
-
__name(
|
|
1273
|
+
__name(useCfgAccountsApiKeyRetrieve, "useCfgAccountsApiKeyRetrieve");
|
|
1274
|
+
|
|
1275
|
+
// src/_api/generated/_cfg_accounts/hooks/useCfgAccountsApiKeyTestCreate.ts
|
|
1276
|
+
import useSWRMutation2 from "swr/mutation";
|
|
1277
|
+
|
|
1278
|
+
// src/_api/generated/_cfg_accounts/schemas/APIKeyTestResult.ts
|
|
1279
|
+
import { z as z3 } from "zod";
|
|
1280
|
+
var APIKeyTestResultSchema = z3.object({
|
|
1281
|
+
valid: z3.boolean(),
|
|
1282
|
+
user_id: z3.string().nullable()
|
|
1283
|
+
});
|
|
1920
1284
|
|
|
1921
|
-
// src/_api/generated/
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1285
|
+
// src/_api/generated/_cfg_accounts/hooks/useCfgAccountsApiKeyTestCreate.ts
|
|
1286
|
+
function useCfgAccountsApiKeyTestCreate(config) {
|
|
1287
|
+
return useSWRMutation2(
|
|
1288
|
+
["cfg_accounts_api_key_test_create"],
|
|
1289
|
+
async (_key, { arg }) => {
|
|
1290
|
+
const res = await CfgAccountsApiKey.cfgAccountsApiKeyTestCreate({ ...arg, throwOnError: true });
|
|
1291
|
+
const data = res.data;
|
|
1292
|
+
const parsed = APIKeyTestResultSchema.safeParse(data);
|
|
1293
|
+
if (!parsed.success) {
|
|
1294
|
+
console.warn(
|
|
1295
|
+
"[zod] response did not match schema",
|
|
1296
|
+
{
|
|
1297
|
+
operation: "cfg_accounts_api_key_test_create",
|
|
1298
|
+
method: "POST",
|
|
1299
|
+
path: "/cfg/accounts/api-key/test/",
|
|
1300
|
+
issues: parsed.error.issues,
|
|
1301
|
+
data
|
|
1302
|
+
}
|
|
1303
|
+
);
|
|
1304
|
+
if (typeof window !== "undefined") {
|
|
1305
|
+
try {
|
|
1306
|
+
window.dispatchEvent(
|
|
1307
|
+
new CustomEvent("zod-validation-error", {
|
|
1308
|
+
detail: {
|
|
1309
|
+
operation: "cfg_accounts_api_key_test_create",
|
|
1310
|
+
method: "POST",
|
|
1311
|
+
path: "/cfg/accounts/api-key/test/",
|
|
1312
|
+
issues: parsed.error.issues,
|
|
1313
|
+
data,
|
|
1314
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
1315
|
+
},
|
|
1316
|
+
bubbles: true,
|
|
1317
|
+
cancelable: false
|
|
1318
|
+
})
|
|
1319
|
+
);
|
|
1320
|
+
} catch {
|
|
1321
|
+
}
|
|
1322
|
+
}
|
|
1323
|
+
return data;
|
|
1324
|
+
}
|
|
1325
|
+
return parsed.data;
|
|
1326
|
+
},
|
|
1327
|
+
config
|
|
1928
1328
|
);
|
|
1929
1329
|
}
|
|
1930
|
-
__name(
|
|
1931
|
-
function useCreateAccountsProfileAvatarCreate() {
|
|
1932
|
-
const { mutate } = useSWRConfig3();
|
|
1933
|
-
return async (data, client) => {
|
|
1934
|
-
const result = await createAccountsProfileAvatarCreate(data, client);
|
|
1935
|
-
mutate("cfg-accounts-profile-avatar");
|
|
1936
|
-
return result;
|
|
1937
|
-
};
|
|
1938
|
-
}
|
|
1939
|
-
__name(useCreateAccountsProfileAvatarCreate, "useCreateAccountsProfileAvatarCreate");
|
|
1940
|
-
function useCreateAccountsProfileDeleteCreate() {
|
|
1941
|
-
const { mutate } = useSWRConfig3();
|
|
1942
|
-
return async (client) => {
|
|
1943
|
-
const result = await createAccountsProfileDeleteCreate(client);
|
|
1944
|
-
mutate("cfg-accounts-profile-delete");
|
|
1945
|
-
return result;
|
|
1946
|
-
};
|
|
1947
|
-
}
|
|
1948
|
-
__name(useCreateAccountsProfileDeleteCreate, "useCreateAccountsProfileDeleteCreate");
|
|
1949
|
-
function usePartialUpdateAccountsProfilePartialUpdate() {
|
|
1950
|
-
const { mutate } = useSWRConfig3();
|
|
1951
|
-
return async (data, client) => {
|
|
1952
|
-
const result = await partialUpdateAccountsProfilePartialUpdate(data, client);
|
|
1953
|
-
mutate("cfg-accounts-profile");
|
|
1954
|
-
return result;
|
|
1955
|
-
};
|
|
1956
|
-
}
|
|
1957
|
-
__name(usePartialUpdateAccountsProfilePartialUpdate, "usePartialUpdateAccountsProfilePartialUpdate");
|
|
1958
|
-
function usePartialUpdateAccountsProfilePartialPartialUpdate() {
|
|
1959
|
-
const { mutate } = useSWRConfig3();
|
|
1960
|
-
return async (data, client) => {
|
|
1961
|
-
const result = await partialUpdateAccountsProfilePartialPartialUpdate(data, client);
|
|
1962
|
-
mutate("cfg-accounts-profile-partial");
|
|
1963
|
-
return result;
|
|
1964
|
-
};
|
|
1965
|
-
}
|
|
1966
|
-
__name(usePartialUpdateAccountsProfilePartialPartialUpdate, "usePartialUpdateAccountsProfilePartialPartialUpdate");
|
|
1967
|
-
function useUpdateAccountsProfileUpdateUpdate() {
|
|
1968
|
-
const { mutate } = useSWRConfig3();
|
|
1969
|
-
return async (data, client) => {
|
|
1970
|
-
const result = await updateAccountsProfileUpdateUpdate(data, client);
|
|
1971
|
-
mutate("cfg-accounts-profile");
|
|
1972
|
-
return result;
|
|
1973
|
-
};
|
|
1974
|
-
}
|
|
1975
|
-
__name(useUpdateAccountsProfileUpdateUpdate, "useUpdateAccountsProfileUpdateUpdate");
|
|
1976
|
-
function usePartialUpdateAccountsProfileUpdatePartialUpdate() {
|
|
1977
|
-
const { mutate } = useSWRConfig3();
|
|
1978
|
-
return async (data, client) => {
|
|
1979
|
-
const result = await partialUpdateAccountsProfileUpdatePartialUpdate(data, client);
|
|
1980
|
-
mutate("cfg-accounts-profile");
|
|
1981
|
-
return result;
|
|
1982
|
-
};
|
|
1983
|
-
}
|
|
1984
|
-
__name(usePartialUpdateAccountsProfileUpdatePartialUpdate, "usePartialUpdateAccountsProfileUpdatePartialUpdate");
|
|
1330
|
+
__name(useCfgAccountsApiKeyTestCreate, "useCfgAccountsApiKeyTestCreate");
|
|
1985
1331
|
|
|
1986
|
-
// src/
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
const {
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
1332
|
+
// src/hooks/useApiKey.ts
|
|
1333
|
+
function useApiKey() {
|
|
1334
|
+
const { data, isLoading, mutate } = useCfgAccountsApiKeyRetrieve();
|
|
1335
|
+
const { trigger: regenerateTrigger, isMutating: isRegenerating } = useCfgAccountsApiKeyRegenerateCreate();
|
|
1336
|
+
const { trigger: testTrigger, isMutating: isTesting } = useCfgAccountsApiKeyTestCreate();
|
|
1337
|
+
const [freshKey, setFreshKey] = useState(null);
|
|
1338
|
+
const apiKey = freshKey ?? (data?.key ?? null);
|
|
1339
|
+
const reissuedAt = data?.reissued_at ?? null;
|
|
1340
|
+
const createdAt = data?.created_at ?? null;
|
|
1341
|
+
const regenerate = useCallback(async () => {
|
|
1342
|
+
const result = await regenerateTrigger({});
|
|
1343
|
+
const newKey = result?.key;
|
|
1344
|
+
if (newKey) {
|
|
1345
|
+
setFreshKey(newKey);
|
|
1346
|
+
}
|
|
1347
|
+
}, [regenerateTrigger]);
|
|
1348
|
+
const testKey = useCallback(async (key) => {
|
|
1349
|
+
const result = await testTrigger({ body: { key } });
|
|
1350
|
+
const record = result;
|
|
1351
|
+
return {
|
|
1352
|
+
valid: Boolean(record?.valid),
|
|
1353
|
+
userId: record?.user_id ?? null
|
|
1354
|
+
};
|
|
1355
|
+
}, [testTrigger]);
|
|
1356
|
+
const refresh = useCallback(() => {
|
|
1357
|
+
setFreshKey(null);
|
|
1358
|
+
mutate();
|
|
1359
|
+
}, [mutate]);
|
|
1360
|
+
return {
|
|
1361
|
+
apiKey,
|
|
1362
|
+
reissuedAt,
|
|
1363
|
+
createdAt,
|
|
1364
|
+
isLoading,
|
|
1365
|
+
isRegenerating,
|
|
1366
|
+
isTesting,
|
|
1367
|
+
regenerate,
|
|
1368
|
+
testKey,
|
|
1369
|
+
refresh
|
|
2003
1370
|
};
|
|
2004
1371
|
}
|
|
2005
|
-
__name(
|
|
1372
|
+
__name(useApiKey, "useApiKey");
|
|
2006
1373
|
export {
|
|
2007
|
-
|
|
2008
|
-
useAccountsOauthProvidersRetrieve,
|
|
2009
|
-
useAccountsProfileRetrieve,
|
|
2010
|
-
useCreateAccountsOauthDisconnectCreate,
|
|
2011
|
-
useCreateAccountsOauthGithubAuthorizeCreate,
|
|
2012
|
-
useCreateAccountsOauthGithubCallbackCreate,
|
|
2013
|
-
useCreateAccountsOtpRequestCreate,
|
|
2014
|
-
useCreateAccountsOtpVerifyCreate,
|
|
2015
|
-
useCreateAccountsProfileAvatarCreate,
|
|
2016
|
-
useCreateAccountsProfileDeleteCreate,
|
|
2017
|
-
useCreateAccountsTokenRefreshCreate,
|
|
2018
|
-
usePartialUpdateAccountsProfilePartialPartialUpdate,
|
|
2019
|
-
usePartialUpdateAccountsProfilePartialUpdate,
|
|
2020
|
-
usePartialUpdateAccountsProfileUpdatePartialUpdate,
|
|
2021
|
-
useUpdateAccountsProfileUpdateUpdate
|
|
1374
|
+
useApiKey
|
|
2022
1375
|
};
|
|
2023
1376
|
//# sourceMappingURL=hooks.mjs.map
|