@djangocfg/api 2.1.261 → 2.1.263

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/auth-server.cjs +9 -0
  2. package/dist/auth-server.cjs.map +1 -1
  3. package/dist/auth-server.mjs +9 -0
  4. package/dist/auth-server.mjs.map +1 -1
  5. package/dist/auth.cjs +27 -0
  6. package/dist/auth.cjs.map +1 -1
  7. package/dist/auth.mjs +27 -0
  8. package/dist/auth.mjs.map +1 -1
  9. package/dist/clients.cjs +65 -1
  10. package/dist/clients.cjs.map +1 -1
  11. package/dist/clients.d.cts +145 -122
  12. package/dist/clients.d.ts +145 -122
  13. package/dist/clients.mjs +65 -1
  14. package/dist/clients.mjs.map +1 -1
  15. package/dist/hooks.cjs +47 -1
  16. package/dist/hooks.cjs.map +1 -1
  17. package/dist/hooks.d.cts +91 -68
  18. package/dist/hooks.d.ts +91 -68
  19. package/dist/hooks.mjs +47 -1
  20. package/dist/hooks.mjs.map +1 -1
  21. package/dist/index.cjs +56 -1
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.d.cts +89 -89
  24. package/dist/index.d.ts +89 -89
  25. package/dist/index.mjs +56 -1
  26. package/dist/index.mjs.map +1 -1
  27. package/package.json +2 -2
  28. package/src/_api/generated/cfg_accounts/_utils/fetchers/accounts__oauth.ts +46 -2
  29. package/src/_api/generated/cfg_accounts/_utils/hooks/accounts__oauth.ts +3 -2
  30. package/src/_api/generated/cfg_accounts/accounts/models.ts +12 -12
  31. package/src/_api/generated/cfg_accounts/accounts__oauth/client.ts +1 -1
  32. package/src/_api/generated/cfg_accounts/accounts__oauth/models.ts +55 -55
  33. package/src/_api/generated/cfg_accounts/accounts__user_profile/models.ts +23 -23
  34. package/src/_api/generated/cfg_accounts/client.ts +8 -0
  35. package/src/_api/generated/cfg_accounts/errors.ts +5 -0
  36. package/src/_api/generated/cfg_centrifugo/client.ts +8 -0
  37. package/src/_api/generated/cfg_centrifugo/errors.ts +5 -0
  38. package/src/_api/generated/cfg_totp/client.ts +8 -0
  39. package/src/_api/generated/cfg_totp/errors.ts +5 -0
  40. package/src/_api/generated/cfg_totp/totp__backup_codes/models.ts +14 -14
  41. package/src/_api/generated/cfg_totp/totp__totp_management/models.ts +10 -10
  42. package/src/_api/generated/cfg_totp/totp__totp_setup/models.ts +25 -25
  43. package/src/_api/generated/cfg_totp/totp__totp_verification/models.ts +8 -8
package/dist/hooks.d.cts CHANGED
@@ -39,13 +39,15 @@ declare enum OAuthConnectionProvider {
39
39
  }
40
40
 
41
41
  /**
42
- * Response with available OAuth providers.
42
+ * Request to start OAuth flow.
43
43
  *
44
- * Response model (includes read-only fields).
44
+ * Request model (no read-only fields).
45
45
  */
46
- interface OAuthProvidersResponse {
47
- /** List of available OAuth providers */
48
- providers: Array<Record<string, any>>;
46
+ interface OAuthAuthorizeRequestRequest$1 {
47
+ /** URL to redirect after OAuth authorization. If not provided, uses config's site_url + callback_path */
48
+ redirect_uri?: string;
49
+ /** Optional source URL for registration tracking */
50
+ source_url?: string;
49
51
  }
50
52
  /**
51
53
  * Request to disconnect OAuth provider.
@@ -59,15 +61,60 @@ interface OAuthDisconnectRequestRequest$1 {
59
61
  provider: OAuthConnectionProvider;
60
62
  }
61
63
  /**
62
- * Request to start OAuth flow.
64
+ * Request to complete OAuth flow (callback handler).
63
65
  *
64
66
  * Request model (no read-only fields).
65
67
  */
66
- interface OAuthAuthorizeRequestRequest$1 {
67
- /** URL to redirect after OAuth authorization. If not provided, uses config's site_url + callback_path */
68
+ interface OAuthCallbackRequestRequest$1 {
69
+ /** Authorization code from OAuth provider callback */
70
+ code: string;
71
+ /** State token for CSRF verification (from authorize response) */
72
+ state: string;
73
+ /** Same redirect_uri used in authorize request. If not provided, uses config's site_url + callback_path */
68
74
  redirect_uri?: string;
69
- /** Optional source URL for registration tracking */
70
- source_url?: string;
75
+ }
76
+ /**
77
+ * Response with OAuth authorization URL.
78
+ *
79
+ * Response model (includes read-only fields).
80
+ */
81
+ interface OAuthAuthorizeResponse$1 {
82
+ /** Full URL to redirect user to OAuth provider */
83
+ authorization_url: string;
84
+ /** State token for CSRF protection. Store this and verify on callback. */
85
+ state: string;
86
+ }
87
+ /**
88
+ * Response with available OAuth providers.
89
+ *
90
+ * Response model (includes read-only fields).
91
+ */
92
+ interface OAuthProvidersResponse {
93
+ /** List of available OAuth providers */
94
+ providers: Array<Record<string, any>>;
95
+ }
96
+ /**
97
+ * Serializer for OAuth connection info (user-facing).
98
+ *
99
+ * Response model (includes read-only fields).
100
+ */
101
+ interface OAuthConnection {
102
+ id: number;
103
+ /** OAuth provider name (github, google, etc.)
104
+
105
+ * `github` - GitHub */
106
+ provider: OAuthConnectionProvider;
107
+ provider_display: string;
108
+ /** Username on the OAuth provider platform */
109
+ provider_username: string;
110
+ /** Email from OAuth provider (may differ from user.email) */
111
+ provider_email: string;
112
+ /** Avatar URL from OAuth provider */
113
+ provider_avatar_url: string;
114
+ /** When this OAuth connection was created */
115
+ connected_at: string;
116
+ /** Last time this OAuth connection was used for login */
117
+ last_login_at: string;
71
118
  }
72
119
  /**
73
120
  * Response with JWT tokens after OAuth authentication. When 2FA is required: -
@@ -95,30 +142,6 @@ interface OAuthTokenResponse$1 {
95
142
  /** True if user should be prompted to enable 2FA */
96
143
  should_prompt_2fa?: boolean;
97
144
  }
98
- /**
99
- * Response with OAuth authorization URL.
100
- *
101
- * Response model (includes read-only fields).
102
- */
103
- interface OAuthAuthorizeResponse$1 {
104
- /** Full URL to redirect user to OAuth provider */
105
- authorization_url: string;
106
- /** State token for CSRF protection. Store this and verify on callback. */
107
- state: string;
108
- }
109
- /**
110
- * Request to complete OAuth flow (callback handler).
111
- *
112
- * Request model (no read-only fields).
113
- */
114
- interface OAuthCallbackRequestRequest$1 {
115
- /** Authorization code from OAuth provider callback */
116
- code: string;
117
- /** State token for CSRF verification (from authorize response) */
118
- state: string;
119
- /** Same redirect_uri used in authorize request. If not provided, uses config's site_url + callback_path */
120
- redirect_uri?: string;
121
- }
122
145
 
123
146
  /**
124
147
  * API endpoints for Oauth.
@@ -131,7 +154,7 @@ declare class Oauth {
131
154
  *
132
155
  * Get all OAuth connections for the current user.
133
156
  */
134
- accountsOauthConnectionsList(): Promise<any>;
157
+ accountsOauthConnectionsList(): Promise<OAuthConnection[]>;
135
158
  /**
136
159
  * Disconnect OAuth provider
137
160
  *
@@ -160,19 +183,6 @@ declare class Oauth {
160
183
  accountsOauthProvidersRetrieve(): Promise<OAuthProvidersResponse>;
161
184
  }
162
185
 
163
- /**
164
- * Serializer for updating user profile.
165
- *
166
- * Request model (no read-only fields).
167
- */
168
- interface PatchedUserProfileUpdateRequest$1 {
169
- first_name?: string;
170
- last_name?: string;
171
- company?: string;
172
- phone?: string;
173
- position?: string;
174
- language?: string;
175
- }
176
186
  /**
177
187
  * Serializer for user details.
178
188
  *
@@ -203,6 +213,27 @@ interface User$2 {
203
213
  unanswered_messages_count: number;
204
214
  centrifugo: CentrifugoToken$1 | null;
205
215
  }
216
+ /**
217
+ * Serializer for updating user profile.
218
+ *
219
+ * Request model (no read-only fields).
220
+ */
221
+ interface PatchedUserProfileUpdateRequest$1 {
222
+ first_name?: string;
223
+ last_name?: string;
224
+ company?: string;
225
+ phone?: string;
226
+ position?: string;
227
+ language?: string;
228
+ }
229
+ /**
230
+ *
231
+ * Request model (no read-only fields).
232
+ */
233
+ interface CfgAccountsProfileAvatarCreateRequest$1 {
234
+ /** Avatar image file (JPEG, PNG, GIF, WebP, max 5MB) */
235
+ avatar: File | Blob;
236
+ }
206
237
  /**
207
238
  * Response serializer for account deletion.
208
239
  *
@@ -227,14 +258,6 @@ interface UserProfileUpdateRequest$1 {
227
258
  position?: string;
228
259
  language?: string;
229
260
  }
230
- /**
231
- *
232
- * Request model (no read-only fields).
233
- */
234
- interface CfgAccountsProfileAvatarCreateRequest$1 {
235
- /** Avatar image file (JPEG, PNG, GIF, WebP, max 5MB) */
236
- avatar: File | Blob;
237
- }
238
261
  /**
239
262
  * Nested serializer for Centrifugo WebSocket connection token.
240
263
  *
@@ -329,17 +352,6 @@ interface OTPRequestResponse$1 {
329
352
  /** Success message */
330
353
  message: string;
331
354
  }
332
- /**
333
- * Serializer for OTP request.
334
- *
335
- * Request model (no read-only fields).
336
- */
337
- interface OTPRequestRequest$1 {
338
- /** Email address for OTP delivery */
339
- identifier: string;
340
- /** Source URL for tracking registration (e.g., https://my.djangocfg.com) */
341
- source_url?: string;
342
- }
343
355
  /**
344
356
  * OTP verification response. When 2FA is required: - requires_2fa: True -
345
357
  * session_id: UUID of 2FA verification session - refresh/access/user: null
@@ -361,6 +373,17 @@ interface OTPVerifyResponse$1 {
361
373
  /** Whether user should be prompted to enable 2FA */
362
374
  should_prompt_2fa?: boolean;
363
375
  }
376
+ /**
377
+ * Serializer for OTP request.
378
+ *
379
+ * Request model (no read-only fields).
380
+ */
381
+ interface OTPRequestRequest$1 {
382
+ /** Email address for OTP delivery */
383
+ identifier: string;
384
+ /** Source URL for tracking registration (e.g., https://my.djangocfg.com) */
385
+ source_url?: string;
386
+ }
364
387
  /**
365
388
  * Serializer for user details.
366
389
  *
@@ -1068,7 +1091,7 @@ declare function useCreateAccountsTokenRefreshCreate(): (data: TokenRefreshReque
1068
1091
  * @method GET
1069
1092
  * @path /cfg/accounts/oauth/connections/
1070
1093
  */
1071
- declare function useAccountsOauthConnectionsList(client?: API): ReturnType<typeof useSWR<any>>;
1094
+ declare function useAccountsOauthConnectionsList(client?: API): ReturnType<typeof useSWR<OAuthConnection[]>>;
1072
1095
  /**
1073
1096
  * Disconnect OAuth provider
1074
1097
  *
package/dist/hooks.d.ts CHANGED
@@ -39,13 +39,15 @@ declare enum OAuthConnectionProvider {
39
39
  }
40
40
 
41
41
  /**
42
- * Response with available OAuth providers.
42
+ * Request to start OAuth flow.
43
43
  *
44
- * Response model (includes read-only fields).
44
+ * Request model (no read-only fields).
45
45
  */
46
- interface OAuthProvidersResponse {
47
- /** List of available OAuth providers */
48
- providers: Array<Record<string, any>>;
46
+ interface OAuthAuthorizeRequestRequest$1 {
47
+ /** URL to redirect after OAuth authorization. If not provided, uses config's site_url + callback_path */
48
+ redirect_uri?: string;
49
+ /** Optional source URL for registration tracking */
50
+ source_url?: string;
49
51
  }
50
52
  /**
51
53
  * Request to disconnect OAuth provider.
@@ -59,15 +61,60 @@ interface OAuthDisconnectRequestRequest$1 {
59
61
  provider: OAuthConnectionProvider;
60
62
  }
61
63
  /**
62
- * Request to start OAuth flow.
64
+ * Request to complete OAuth flow (callback handler).
63
65
  *
64
66
  * Request model (no read-only fields).
65
67
  */
66
- interface OAuthAuthorizeRequestRequest$1 {
67
- /** URL to redirect after OAuth authorization. If not provided, uses config's site_url + callback_path */
68
+ interface OAuthCallbackRequestRequest$1 {
69
+ /** Authorization code from OAuth provider callback */
70
+ code: string;
71
+ /** State token for CSRF verification (from authorize response) */
72
+ state: string;
73
+ /** Same redirect_uri used in authorize request. If not provided, uses config's site_url + callback_path */
68
74
  redirect_uri?: string;
69
- /** Optional source URL for registration tracking */
70
- source_url?: string;
75
+ }
76
+ /**
77
+ * Response with OAuth authorization URL.
78
+ *
79
+ * Response model (includes read-only fields).
80
+ */
81
+ interface OAuthAuthorizeResponse$1 {
82
+ /** Full URL to redirect user to OAuth provider */
83
+ authorization_url: string;
84
+ /** State token for CSRF protection. Store this and verify on callback. */
85
+ state: string;
86
+ }
87
+ /**
88
+ * Response with available OAuth providers.
89
+ *
90
+ * Response model (includes read-only fields).
91
+ */
92
+ interface OAuthProvidersResponse {
93
+ /** List of available OAuth providers */
94
+ providers: Array<Record<string, any>>;
95
+ }
96
+ /**
97
+ * Serializer for OAuth connection info (user-facing).
98
+ *
99
+ * Response model (includes read-only fields).
100
+ */
101
+ interface OAuthConnection {
102
+ id: number;
103
+ /** OAuth provider name (github, google, etc.)
104
+
105
+ * `github` - GitHub */
106
+ provider: OAuthConnectionProvider;
107
+ provider_display: string;
108
+ /** Username on the OAuth provider platform */
109
+ provider_username: string;
110
+ /** Email from OAuth provider (may differ from user.email) */
111
+ provider_email: string;
112
+ /** Avatar URL from OAuth provider */
113
+ provider_avatar_url: string;
114
+ /** When this OAuth connection was created */
115
+ connected_at: string;
116
+ /** Last time this OAuth connection was used for login */
117
+ last_login_at: string;
71
118
  }
72
119
  /**
73
120
  * Response with JWT tokens after OAuth authentication. When 2FA is required: -
@@ -95,30 +142,6 @@ interface OAuthTokenResponse$1 {
95
142
  /** True if user should be prompted to enable 2FA */
96
143
  should_prompt_2fa?: boolean;
97
144
  }
98
- /**
99
- * Response with OAuth authorization URL.
100
- *
101
- * Response model (includes read-only fields).
102
- */
103
- interface OAuthAuthorizeResponse$1 {
104
- /** Full URL to redirect user to OAuth provider */
105
- authorization_url: string;
106
- /** State token for CSRF protection. Store this and verify on callback. */
107
- state: string;
108
- }
109
- /**
110
- * Request to complete OAuth flow (callback handler).
111
- *
112
- * Request model (no read-only fields).
113
- */
114
- interface OAuthCallbackRequestRequest$1 {
115
- /** Authorization code from OAuth provider callback */
116
- code: string;
117
- /** State token for CSRF verification (from authorize response) */
118
- state: string;
119
- /** Same redirect_uri used in authorize request. If not provided, uses config's site_url + callback_path */
120
- redirect_uri?: string;
121
- }
122
145
 
123
146
  /**
124
147
  * API endpoints for Oauth.
@@ -131,7 +154,7 @@ declare class Oauth {
131
154
  *
132
155
  * Get all OAuth connections for the current user.
133
156
  */
134
- accountsOauthConnectionsList(): Promise<any>;
157
+ accountsOauthConnectionsList(): Promise<OAuthConnection[]>;
135
158
  /**
136
159
  * Disconnect OAuth provider
137
160
  *
@@ -160,19 +183,6 @@ declare class Oauth {
160
183
  accountsOauthProvidersRetrieve(): Promise<OAuthProvidersResponse>;
161
184
  }
162
185
 
163
- /**
164
- * Serializer for updating user profile.
165
- *
166
- * Request model (no read-only fields).
167
- */
168
- interface PatchedUserProfileUpdateRequest$1 {
169
- first_name?: string;
170
- last_name?: string;
171
- company?: string;
172
- phone?: string;
173
- position?: string;
174
- language?: string;
175
- }
176
186
  /**
177
187
  * Serializer for user details.
178
188
  *
@@ -203,6 +213,27 @@ interface User$2 {
203
213
  unanswered_messages_count: number;
204
214
  centrifugo: CentrifugoToken$1 | null;
205
215
  }
216
+ /**
217
+ * Serializer for updating user profile.
218
+ *
219
+ * Request model (no read-only fields).
220
+ */
221
+ interface PatchedUserProfileUpdateRequest$1 {
222
+ first_name?: string;
223
+ last_name?: string;
224
+ company?: string;
225
+ phone?: string;
226
+ position?: string;
227
+ language?: string;
228
+ }
229
+ /**
230
+ *
231
+ * Request model (no read-only fields).
232
+ */
233
+ interface CfgAccountsProfileAvatarCreateRequest$1 {
234
+ /** Avatar image file (JPEG, PNG, GIF, WebP, max 5MB) */
235
+ avatar: File | Blob;
236
+ }
206
237
  /**
207
238
  * Response serializer for account deletion.
208
239
  *
@@ -227,14 +258,6 @@ interface UserProfileUpdateRequest$1 {
227
258
  position?: string;
228
259
  language?: string;
229
260
  }
230
- /**
231
- *
232
- * Request model (no read-only fields).
233
- */
234
- interface CfgAccountsProfileAvatarCreateRequest$1 {
235
- /** Avatar image file (JPEG, PNG, GIF, WebP, max 5MB) */
236
- avatar: File | Blob;
237
- }
238
261
  /**
239
262
  * Nested serializer for Centrifugo WebSocket connection token.
240
263
  *
@@ -329,17 +352,6 @@ interface OTPRequestResponse$1 {
329
352
  /** Success message */
330
353
  message: string;
331
354
  }
332
- /**
333
- * Serializer for OTP request.
334
- *
335
- * Request model (no read-only fields).
336
- */
337
- interface OTPRequestRequest$1 {
338
- /** Email address for OTP delivery */
339
- identifier: string;
340
- /** Source URL for tracking registration (e.g., https://my.djangocfg.com) */
341
- source_url?: string;
342
- }
343
355
  /**
344
356
  * OTP verification response. When 2FA is required: - requires_2fa: True -
345
357
  * session_id: UUID of 2FA verification session - refresh/access/user: null
@@ -361,6 +373,17 @@ interface OTPVerifyResponse$1 {
361
373
  /** Whether user should be prompted to enable 2FA */
362
374
  should_prompt_2fa?: boolean;
363
375
  }
376
+ /**
377
+ * Serializer for OTP request.
378
+ *
379
+ * Request model (no read-only fields).
380
+ */
381
+ interface OTPRequestRequest$1 {
382
+ /** Email address for OTP delivery */
383
+ identifier: string;
384
+ /** Source URL for tracking registration (e.g., https://my.djangocfg.com) */
385
+ source_url?: string;
386
+ }
364
387
  /**
365
388
  * Serializer for user details.
366
389
  *
@@ -1068,7 +1091,7 @@ declare function useCreateAccountsTokenRefreshCreate(): (data: TokenRefreshReque
1068
1091
  * @method GET
1069
1092
  * @path /cfg/accounts/oauth/connections/
1070
1093
  */
1071
- declare function useAccountsOauthConnectionsList(client?: API): ReturnType<typeof useSWR<any>>;
1094
+ declare function useAccountsOauthConnectionsList(client?: API): ReturnType<typeof useSWR<OAuthConnection[]>>;
1072
1095
  /**
1073
1096
  * Disconnect OAuth provider
1074
1097
  *
package/dist/hooks.mjs CHANGED
@@ -305,6 +305,9 @@ var APIError = class extends Error {
305
305
  if (details.detail) {
306
306
  return Array.isArray(details.detail) ? details.detail.join(", ") : String(details.detail);
307
307
  }
308
+ if (details.error) {
309
+ return String(details.error);
310
+ }
308
311
  if (details.message) {
309
312
  return String(details.message);
310
313
  }
@@ -643,6 +646,12 @@ var APIClient = class {
643
646
  if (!options?.formData && !options?.binaryBody && !headers["Content-Type"]) {
644
647
  headers["Content-Type"] = "application/json";
645
648
  }
649
+ if (!headers["Authorization"]) {
650
+ const token = this.getToken();
651
+ if (token) {
652
+ headers["Authorization"] = `Bearer ${token}`;
653
+ }
654
+ }
646
655
  if (this.logger) {
647
656
  this.logger.logRequest({
648
657
  method,
@@ -1107,7 +1116,44 @@ import { consola as consola2 } from "consola";
1107
1116
  async function getAccountsOauthConnectionsList(client) {
1108
1117
  const api = client || getAPIInstance();
1109
1118
  const response = await api.oauth.accountsOauthConnectionsList();
1110
- return response;
1119
+ try {
1120
+ return OAuthConnectionSchema.array().parse(response);
1121
+ } catch (error) {
1122
+ consola2.error("\u274C Zod Validation Failed");
1123
+ consola2.box(`getAccountsOauthConnectionsList
1124
+ Path: /cfg/accounts/oauth/connections/
1125
+ Method: GET`);
1126
+ if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
1127
+ consola2.error("Validation Issues:");
1128
+ error.issues.forEach((issue, index) => {
1129
+ consola2.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
1130
+ consola2.error(` \u251C\u2500 Message: ${issue.message}`);
1131
+ if (issue.expected) consola2.error(` \u251C\u2500 Expected: ${issue.expected}`);
1132
+ if (issue.received) consola2.error(` \u2514\u2500 Received: ${issue.received}`);
1133
+ });
1134
+ }
1135
+ consola2.error("Response data:", response);
1136
+ if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
1137
+ try {
1138
+ const event = new CustomEvent("zod-validation-error", {
1139
+ detail: {
1140
+ operation: "getAccountsOauthConnectionsList",
1141
+ path: "/cfg/accounts/oauth/connections/",
1142
+ method: "GET",
1143
+ error,
1144
+ response,
1145
+ timestamp: /* @__PURE__ */ new Date()
1146
+ },
1147
+ bubbles: true,
1148
+ cancelable: false
1149
+ });
1150
+ window.dispatchEvent(event);
1151
+ } catch (eventError) {
1152
+ consola2.warn("Failed to dispatch validation error event:", eventError);
1153
+ }
1154
+ }
1155
+ throw error;
1156
+ }
1111
1157
  }
1112
1158
  __name(getAccountsOauthConnectionsList, "getAccountsOauthConnectionsList");
1113
1159
  async function createAccountsOauthDisconnectCreate(data, client) {