@djangocfg/api 1.2.24 → 1.2.25

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 (76) hide show
  1. package/dist/index.cjs +1719 -23297
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +561 -19228
  4. package/dist/index.d.ts +561 -19228
  5. package/dist/index.mjs +1614 -23195
  6. package/dist/index.mjs.map +1 -1
  7. package/package.json +2 -2
  8. package/src/cfg/contexts/index.ts +0 -11
  9. package/src/cfg/generated/_utils/fetchers/cfg__centrifugo__centrifugo_auth.ts +48 -0
  10. package/src/cfg/generated/_utils/fetchers/cfg__centrifugo__centrifugo_testing.ts +0 -16
  11. package/src/cfg/generated/_utils/fetchers/cfg__grpc__grpc_monitoring.ts +5 -20
  12. package/src/cfg/generated/_utils/fetchers/cfg__grpc__grpc_services.ts +5 -4
  13. package/src/cfg/generated/_utils/fetchers/index.ts +1 -0
  14. package/src/cfg/generated/_utils/hooks/cfg__accounts.ts +0 -1
  15. package/src/cfg/generated/_utils/hooks/cfg__accounts__auth.ts +0 -1
  16. package/src/cfg/generated/_utils/hooks/cfg__centrifugo.ts +0 -1
  17. package/src/cfg/generated/_utils/hooks/cfg__centrifugo__centrifugo_admin_api.ts +0 -1
  18. package/src/cfg/generated/_utils/hooks/cfg__centrifugo__centrifugo_auth.ts +35 -0
  19. package/src/cfg/generated/_utils/hooks/cfg__centrifugo__centrifugo_monitoring.ts +0 -1
  20. package/src/cfg/generated/_utils/hooks/cfg__centrifugo__centrifugo_testing.ts +0 -21
  21. package/src/cfg/generated/_utils/hooks/cfg__dashboard__dashboard_activity.ts +0 -1
  22. package/src/cfg/generated/_utils/hooks/cfg__dashboard__dashboard_api_zones.ts +0 -1
  23. package/src/cfg/generated/_utils/hooks/cfg__dashboard__dashboard_charts.ts +0 -1
  24. package/src/cfg/generated/_utils/hooks/cfg__dashboard__dashboard_config.ts +0 -1
  25. package/src/cfg/generated/_utils/hooks/cfg__dashboard__dashboard_overview.ts +0 -1
  26. package/src/cfg/generated/_utils/hooks/cfg__dashboard__dashboard_statistics.ts +0 -1
  27. package/src/cfg/generated/_utils/hooks/cfg__dashboard__dashboard_system.ts +0 -1
  28. package/src/cfg/generated/_utils/hooks/cfg__endpoints.ts +0 -1
  29. package/src/cfg/generated/_utils/hooks/cfg__grpc__grpc_api_keys.ts +0 -1
  30. package/src/cfg/generated/_utils/hooks/cfg__grpc__grpc_charts.ts +0 -1
  31. package/src/cfg/generated/_utils/hooks/cfg__grpc__grpc_configuration.ts +0 -1
  32. package/src/cfg/generated/_utils/hooks/cfg__grpc__grpc_monitoring.ts +5 -21
  33. package/src/cfg/generated/_utils/hooks/cfg__grpc__grpc_services.ts +3 -3
  34. package/src/cfg/generated/_utils/hooks/cfg__health.ts +0 -1
  35. package/src/cfg/generated/_utils/hooks/cfg__leads__lead_submission.ts +0 -1
  36. package/src/cfg/generated/_utils/hooks/cfg__newsletter.ts +0 -1
  37. package/src/cfg/generated/_utils/hooks/cfg__newsletter__bulk_email.ts +0 -1
  38. package/src/cfg/generated/_utils/hooks/cfg__newsletter__logs.ts +0 -1
  39. package/src/cfg/generated/_utils/hooks/cfg__newsletter__newsletters.ts +0 -1
  40. package/src/cfg/generated/_utils/hooks/cfg__newsletter__testing.ts +0 -1
  41. package/src/cfg/generated/_utils/hooks/cfg__rq__rq_monitoring.ts +0 -1
  42. package/src/cfg/generated/_utils/hooks/cfg__rq__rq_workers.ts +0 -1
  43. package/src/cfg/generated/_utils/hooks/index.ts +1 -0
  44. package/src/cfg/generated/_utils/schemas/CentrifugoToken.schema.ts +22 -0
  45. package/src/cfg/generated/_utils/schemas/ConnectionTokenResponse.schema.ts +3 -2
  46. package/src/cfg/generated/_utils/schemas/GRPCOverviewStats.schema.ts +2 -0
  47. package/src/cfg/generated/_utils/schemas/GRPCRegisteredService.schema.ts +24 -0
  48. package/src/cfg/generated/_utils/schemas/GRPCServerConfig.schema.ts +1 -1
  49. package/src/cfg/generated/_utils/schemas/GRPCServerStatus.schema.ts +34 -0
  50. package/src/cfg/generated/_utils/schemas/PaginatedRecentRequestList.schema.ts +24 -0
  51. package/src/cfg/generated/_utils/schemas/PaginatedServiceSummaryList.schema.ts +24 -0
  52. package/src/cfg/generated/_utils/schemas/ServiceSummary.schema.ts +26 -0
  53. package/src/cfg/generated/_utils/schemas/User.schema.ts +2 -0
  54. package/src/cfg/generated/_utils/schemas/index.ts +6 -3
  55. package/src/cfg/generated/cfg__accounts/models.ts +17 -0
  56. package/src/cfg/generated/cfg__accounts__user_profile/models.ts +17 -0
  57. package/src/cfg/generated/cfg__centrifugo__centrifugo_auth/client.ts +26 -0
  58. package/src/cfg/generated/cfg__centrifugo__centrifugo_auth/index.ts +2 -0
  59. package/src/cfg/generated/cfg__centrifugo__centrifugo_auth/models.ts +16 -0
  60. package/src/cfg/generated/cfg__centrifugo__centrifugo_testing/client.ts +0 -10
  61. package/src/cfg/generated/cfg__centrifugo__centrifugo_testing/models.ts +0 -26
  62. package/src/cfg/generated/cfg__grpc__grpc_configuration/models.ts +2 -2
  63. package/src/cfg/generated/cfg__grpc__grpc_monitoring/client.ts +4 -25
  64. package/src/cfg/generated/cfg__grpc__grpc_monitoring/models.ts +99 -47
  65. package/src/cfg/generated/cfg__grpc__grpc_services/client.ts +6 -5
  66. package/src/cfg/generated/cfg__grpc__grpc_services/models.ts +49 -0
  67. package/src/cfg/generated/client.ts +3 -0
  68. package/src/cfg/generated/index.ts +17 -8
  69. package/src/cfg/generated/{schema.ts → schema.json} +19122 -18892
  70. package/src/index.ts +7 -2
  71. package/src/types/auth.ts +40 -0
  72. package/src/types/index.ts +7 -0
  73. package/src/cfg/contexts/AccountsContext.tsx +0 -205
  74. package/src/cfg/generated/_utils/schemas/ConnectionTokenRequestRequest.schema.ts +0 -20
  75. package/src/cfg/generated/_utils/schemas/MonitoringServiceStats.schema.ts +0 -24
  76. package/src/cfg/generated/_utils/schemas/ServiceList.schema.ts +0 -21
package/src/index.ts CHANGED
@@ -29,11 +29,13 @@ export * from './cfg/generated';
29
29
 
30
30
  // Export API instance (advanced usage)
31
31
  export { api } from './cfg/BaseClient';
32
- export { api as default } from './cfg/BaseClient';
33
32
 
34
33
  // Export all contexts (React contexts for data management)
35
34
  export * from './cfg/contexts';
36
35
 
36
+ // Export centralized types
37
+ export * from './types';
38
+
37
39
  // Re-export all types and fetchers for convenience
38
40
  // Usage: import { Schemas, Fetchers } from '@djangocfg/api'
39
41
  export { Schemas, Fetchers } from './cfg/generated';
@@ -46,4 +48,7 @@ export type {
46
48
  OTPVerifyResponse,
47
49
  User,
48
50
  // Add more types as needed
49
- } from './cfg/generated/_utils/schemas';
51
+ } from './cfg/generated/_utils/schemas';
52
+
53
+ // Export API class type
54
+ export type { API } from './cfg/generated';
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Auth Types
3
+ *
4
+ * Centralized type exports for authentication and API schemas
5
+ */
6
+
7
+ // Export type definitions
8
+ export type {
9
+ User,
10
+ OTPRequestResponse,
11
+ OTPVerifyResponse,
12
+ TokenRefresh,
13
+ UserProfileUpdateRequest,
14
+ PatchedUserProfileUpdateRequest,
15
+ OTPRequestRequest,
16
+ OTPVerifyRequest,
17
+ } from '../cfg/generated/_utils/schemas';
18
+
19
+ // Export schema validators
20
+ export { PatchedUserProfileUpdateRequestSchema } from '../cfg/generated/_utils/schemas/PatchedUserProfileUpdateRequest.schema';
21
+
22
+ // Export API instance
23
+ export { api } from '../cfg/BaseClient';
24
+
25
+ // Re-export hooks
26
+ export {
27
+ usePartialUpdateAccountsProfilePartialUpdate,
28
+ useUpdateAccountsProfileUpdateUpdate,
29
+ useCreateAccountsProfileAvatarCreate,
30
+ } from '../cfg/generated/_utils/hooks/cfg__accounts__user_profile';
31
+
32
+ export {
33
+ useCreateAccountsOtpRequestCreate,
34
+ useCreateAccountsOtpVerifyCreate,
35
+ } from '../cfg/generated/_utils/hooks/cfg__accounts';
36
+
37
+ export { useCreateAccountsTokenRefreshCreate } from '../cfg/generated/_utils/hooks/cfg__accounts__auth';
38
+
39
+ // Re-export fetchers
40
+ export { getAccountsProfileRetrieve } from '../cfg/generated/_utils/fetchers/cfg__accounts__user_profile';
@@ -0,0 +1,7 @@
1
+ /**
2
+ * API Types
3
+ *
4
+ * Centralized exports for all API-related types
5
+ */
6
+
7
+ export * from './auth';
@@ -1,205 +0,0 @@
1
- /**
2
- * Accounts Context
3
- *
4
- * Manages user authentication and profile operations using generated SWR hooks
5
- *
6
- * Features:
7
- * - OTP-based authentication
8
- * - User profile management
9
- * - Avatar upload
10
- * - Profile updates
11
- */
12
-
13
- "use client";
14
-
15
- import { createContext, useContext, ReactNode } from 'react';
16
- import { SWRConfig, useSWRConfig } from 'swr';
17
- import { api } from '../BaseClient';
18
- import {
19
- useAccountsProfileRetrieve,
20
- usePartialUpdateAccountsProfilePartialUpdate,
21
- useUpdateAccountsProfileUpdateUpdate,
22
- useCreateAccountsProfileAvatarCreate,
23
- useCreateAccountsOtpRequestCreate,
24
- useCreateAccountsOtpVerifyCreate,
25
- useCreateAccountsTokenRefreshCreate,
26
- } from '../generated/_utils/hooks';
27
- import type { API } from '../generated';
28
- import type {
29
- User,
30
- UserProfileUpdateRequest,
31
- PatchedUserProfileUpdateRequest,
32
- OTPRequestRequest,
33
- OTPVerifyRequest,
34
- OTPRequestResponse,
35
- OTPVerifyResponse,
36
- TokenRefresh,
37
- } from '../generated/_utils/schemas';
38
-
39
- // Re-export schemas for external use
40
- export { PatchedUserProfileUpdateRequestSchema } from '../generated/_utils/schemas/PatchedUserProfileUpdateRequest.schema';
41
- export type { PatchedUserProfileUpdateRequest };
42
-
43
- // ─────────────────────────────────────────────────────────────────────────
44
- // Context Type
45
- // ─────────────────────────────────────────────────────────────────────────
46
-
47
- export interface AccountsContextValue {
48
- // Current user profile
49
- profile?: User;
50
- isLoadingProfile: boolean;
51
- profileError: Error | null;
52
-
53
- // Profile operations
54
- updateProfile: (data: UserProfileUpdateRequest) => Promise<User>;
55
- partialUpdateProfile: (data: PatchedUserProfileUpdateRequest) => Promise<User>;
56
- uploadAvatar: (formData: FormData) => Promise<User>;
57
- refreshProfile: () => Promise<User | undefined>;
58
-
59
- // Authentication
60
- requestOTP: (data: OTPRequestRequest) => Promise<OTPRequestResponse>;
61
- verifyOTP: (data: OTPVerifyRequest) => Promise<OTPVerifyResponse>;
62
- refreshToken: (refresh: string) => Promise<TokenRefresh>;
63
- logout: () => void;
64
- }
65
-
66
- // ─────────────────────────────────────────────────────────────────────────
67
- // Context
68
- // ─────────────────────────────────────────────────────────────────────────
69
-
70
- const AccountsContext = createContext<AccountsContextValue | undefined>(undefined);
71
-
72
- // ─────────────────────────────────────────────────────────────────────────
73
- // Provider Component
74
- // ─────────────────────────────────────────────────────────────────────────
75
-
76
- interface AccountsProviderProps {
77
- children: ReactNode;
78
- }
79
-
80
- export function AccountsProvider({ children }: AccountsProviderProps) {
81
- const { mutate } = useSWRConfig();
82
-
83
- // SWR config - disable auto-revalidation
84
- const swrConfig = {
85
- revalidateOnFocus: false,
86
- revalidateOnReconnect: false,
87
- revalidateIfStale: false,
88
- };
89
-
90
- // Get current user profile
91
- const {
92
- data: profile,
93
- error: profileError,
94
- isLoading: isLoadingProfile,
95
- mutate: mutateProfile,
96
- } = useAccountsProfileRetrieve(api as unknown as API);
97
-
98
- // Mutation hooks
99
- const updateMutation = useUpdateAccountsProfileUpdateUpdate();
100
- const partialUpdateMutation = usePartialUpdateAccountsProfilePartialUpdate();
101
- const avatarMutation = useCreateAccountsProfileAvatarCreate();
102
- const otpRequestMutation = useCreateAccountsOtpRequestCreate();
103
- const otpVerifyMutation = useCreateAccountsOtpVerifyCreate();
104
- const tokenRefreshMutation = useCreateAccountsTokenRefreshCreate();
105
-
106
- // Refresh profile
107
- const refreshProfile = async (): Promise<User | undefined> => {
108
- return await mutateProfile();
109
- };
110
-
111
- // Update profile (full)
112
- const updateProfile = async (data: UserProfileUpdateRequest): Promise<User> => {
113
- const result = await updateMutation(data, api as unknown as API);
114
- await refreshProfile();
115
- return result as User;
116
- };
117
-
118
- // Partial update profile
119
- const partialUpdateProfile = async (data: PatchedUserProfileUpdateRequest): Promise<User> => {
120
- const result = await partialUpdateMutation(data, api as unknown as API);
121
- await refreshProfile();
122
- return result as User;
123
- };
124
-
125
- // Upload avatar
126
- const uploadAvatar = async (formData: FormData): Promise<User> => {
127
- const result = await avatarMutation(formData, api as unknown as API);
128
- await refreshProfile();
129
- return result as User;
130
- };
131
-
132
- // Request OTP
133
- const requestOTP = async (data: OTPRequestRequest): Promise<OTPRequestResponse> => {
134
- const result = await otpRequestMutation(data, api as unknown as API);
135
- return result as OTPRequestResponse;
136
- };
137
-
138
- // Verify OTP
139
- const verifyOTP = async (data: OTPVerifyRequest): Promise<OTPVerifyResponse> => {
140
- const result = await otpVerifyMutation(data, api as unknown as API);
141
-
142
- // Automatically save tokens after successful verification
143
- if (result.access && result.refresh) {
144
- api.setToken(result.access, result.refresh);
145
- // Refresh profile to load user data with new token
146
- await refreshProfile();
147
- }
148
-
149
- return result as OTPVerifyResponse;
150
- };
151
-
152
- // Refresh token
153
- const refreshToken = async (refresh: string): Promise<TokenRefresh> => {
154
- const result = await tokenRefreshMutation({ refresh }, api as unknown as API);
155
-
156
- // Automatically save new access token
157
- if (result.access) {
158
- api.setToken(result.access, refresh);
159
- }
160
-
161
- return result as TokenRefresh;
162
- };
163
-
164
- // Logout - clear tokens and invalidate profile cache
165
- const logout = () => {
166
- api.clearTokens();
167
- // Invalidate profile cache to trigger re-fetch (which will fail and clear profile state)
168
- mutateProfile(undefined, false);
169
- };
170
-
171
- const value: AccountsContextValue = {
172
- profile,
173
- isLoadingProfile,
174
- profileError,
175
- updateProfile,
176
- partialUpdateProfile,
177
- uploadAvatar,
178
- refreshProfile,
179
- requestOTP,
180
- verifyOTP,
181
- refreshToken,
182
- logout,
183
- };
184
-
185
- return (
186
- <SWRConfig value={swrConfig}>
187
- <AccountsContext.Provider value={value}>
188
- {children}
189
- </AccountsContext.Provider>
190
- </SWRConfig>
191
- );
192
- }
193
-
194
- // ─────────────────────────────────────────────────────────────────────────
195
- // Hook
196
- // ─────────────────────────────────────────────────────────────────────────
197
-
198
- export function useAccountsContext(): AccountsContextValue {
199
- const context = useContext(AccountsContext);
200
- if (!context) {
201
- throw new Error('useAccountsContext must be used within AccountsProvider');
202
- }
203
- return context;
204
- }
205
-
@@ -1,20 +0,0 @@
1
- /**
2
- * Zod schema for ConnectionTokenRequestRequest
3
- *
4
- * This schema provides runtime validation and type inference.
5
- * * Request model for connection token generation.
6
- * */
7
- import { z } from 'zod'
8
-
9
- /**
10
- * Request model for connection token generation.
11
- */
12
- export const ConnectionTokenRequestRequestSchema = z.object({
13
- user_id: z.string(),
14
- channels: z.array(z.string()).optional(),
15
- })
16
-
17
- /**
18
- * Infer TypeScript type from Zod schema
19
- */
20
- export type ConnectionTokenRequestRequest = z.infer<typeof ConnectionTokenRequestRequestSchema>
@@ -1,24 +0,0 @@
1
- /**
2
- * Zod schema for MonitoringServiceStats
3
- *
4
- * This schema provides runtime validation and type inference.
5
- * * Statistics for a single gRPC service (monitoring endpoint).
6
- * */
7
- import { z } from 'zod'
8
-
9
- /**
10
- * Statistics for a single gRPC service (monitoring endpoint).
11
- */
12
- export const MonitoringServiceStatsSchema = z.object({
13
- service_name: z.string(),
14
- total: z.int(),
15
- successful: z.int(),
16
- errors: z.int(),
17
- avg_duration_ms: z.number(),
18
- last_activity_at: z.string().nullable(),
19
- })
20
-
21
- /**
22
- * Infer TypeScript type from Zod schema
23
- */
24
- export type MonitoringServiceStats = z.infer<typeof MonitoringServiceStatsSchema>
@@ -1,21 +0,0 @@
1
- /**
2
- * Zod schema for ServiceList
3
- *
4
- * This schema provides runtime validation and type inference.
5
- * * List of gRPC services with statistics.
6
- * */
7
- import { z } from 'zod'
8
- import { MonitoringServiceStatsSchema } from './MonitoringServiceStats.schema'
9
-
10
- /**
11
- * List of gRPC services with statistics.
12
- */
13
- export const ServiceListSchema = z.object({
14
- services: z.array(MonitoringServiceStatsSchema),
15
- total_services: z.int(),
16
- })
17
-
18
- /**
19
- * Infer TypeScript type from Zod schema
20
- */
21
- export type ServiceList = z.infer<typeof ServiceListSchema>