@djangocfg/api 2.1.139 → 2.1.140

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 (48) hide show
  1. package/dist/auth-server.cjs +2 -199
  2. package/dist/auth-server.cjs.map +1 -1
  3. package/dist/auth-server.mjs +2 -199
  4. package/dist/auth-server.mjs.map +1 -1
  5. package/dist/auth.cjs +11 -836
  6. package/dist/auth.cjs.map +1 -1
  7. package/dist/auth.mjs +11 -836
  8. package/dist/auth.mjs.map +1 -1
  9. package/dist/clients.cjs +40 -1077
  10. package/dist/clients.cjs.map +1 -1
  11. package/dist/clients.d.cts +209 -754
  12. package/dist/clients.d.ts +209 -754
  13. package/dist/clients.mjs +40 -1077
  14. package/dist/clients.mjs.map +1 -1
  15. package/dist/index.cjs +0 -1198
  16. package/dist/index.cjs.map +1 -1
  17. package/dist/index.d.cts +229 -1211
  18. package/dist/index.d.ts +229 -1211
  19. package/dist/index.mjs +0 -1198
  20. package/dist/index.mjs.map +1 -1
  21. package/package.json +2 -2
  22. package/src/clients.ts +2 -12
  23. package/src/index.ts +0 -6
  24. package/src/generated/cfg_webpush/CLAUDE.md +0 -63
  25. package/src/generated/cfg_webpush/_utils/fetchers/index.ts +0 -29
  26. package/src/generated/cfg_webpush/_utils/fetchers/webpush__web_push.ts +0 -211
  27. package/src/generated/cfg_webpush/_utils/hooks/index.ts +0 -29
  28. package/src/generated/cfg_webpush/_utils/hooks/webpush__web_push.ts +0 -79
  29. package/src/generated/cfg_webpush/_utils/schemas/SendPushRequestRequest.schema.ts +0 -22
  30. package/src/generated/cfg_webpush/_utils/schemas/SendPushResponse.schema.ts +0 -20
  31. package/src/generated/cfg_webpush/_utils/schemas/SubscribeRequestRequest.schema.ts +0 -20
  32. package/src/generated/cfg_webpush/_utils/schemas/SubscribeResponse.schema.ts +0 -21
  33. package/src/generated/cfg_webpush/_utils/schemas/VapidPublicKeyResponse.schema.ts +0 -19
  34. package/src/generated/cfg_webpush/_utils/schemas/index.ts +0 -24
  35. package/src/generated/cfg_webpush/api-instance.ts +0 -180
  36. package/src/generated/cfg_webpush/client.ts +0 -322
  37. package/src/generated/cfg_webpush/errors.ts +0 -117
  38. package/src/generated/cfg_webpush/http.ts +0 -110
  39. package/src/generated/cfg_webpush/index.ts +0 -275
  40. package/src/generated/cfg_webpush/logger.ts +0 -260
  41. package/src/generated/cfg_webpush/retry.ts +0 -176
  42. package/src/generated/cfg_webpush/schema.json +0 -302
  43. package/src/generated/cfg_webpush/storage.ts +0 -162
  44. package/src/generated/cfg_webpush/validation-events.ts +0 -134
  45. package/src/generated/cfg_webpush/webpush__web_push/client.ts +0 -45
  46. package/src/generated/cfg_webpush/webpush__web_push/index.ts +0 -3
  47. package/src/generated/cfg_webpush/webpush__web_push/models.ts +0 -65
  48. package/src/hooks/webpush.ts +0 -12
@@ -1,134 +0,0 @@
1
- // Auto-generated by DjangoCFG - see CLAUDE.md
2
- /**
3
- * Zod Validation Events - Browser CustomEvent integration
4
- *
5
- * Dispatches browser CustomEvents when Zod validation fails, allowing
6
- * React/frontend apps to listen and handle validation errors globally.
7
- *
8
- * @example
9
- * ```typescript
10
- * // In your React app
11
- * window.addEventListener('zod-validation-error', (event) => {
12
- * const { operation, path, method, error, response } = event.detail;
13
- * console.error(`Validation failed for ${method} ${path}`, error);
14
- * // Show toast notification, log to Sentry, etc.
15
- * });
16
- * ```
17
- */
18
-
19
- import type { ZodError } from 'zod'
20
-
21
- /**
22
- * Validation error event detail
23
- */
24
- export interface ValidationErrorDetail {
25
- /** Operation/function name that failed validation */
26
- operation: string
27
- /** API endpoint path */
28
- path: string
29
- /** HTTP method */
30
- method: string
31
- /** Zod validation error */
32
- error: ZodError
33
- /** Raw response data that failed validation */
34
- response: any
35
- /** Timestamp of the error */
36
- timestamp: Date
37
- }
38
-
39
- /**
40
- * Custom event type for Zod validation errors
41
- */
42
- export type ValidationErrorEvent = CustomEvent<ValidationErrorDetail>
43
-
44
- /**
45
- * Dispatch a Zod validation error event.
46
- *
47
- * Only dispatches in browser environment (when window is defined).
48
- * Safe to call in Node.js/SSR - will be a no-op.
49
- *
50
- * @param detail - Validation error details
51
- */
52
- export function dispatchValidationError(detail: ValidationErrorDetail): void {
53
- // Check if running in browser
54
- if (typeof window === 'undefined') {
55
- return
56
- }
57
-
58
- try {
59
- const event = new CustomEvent<ValidationErrorDetail>('zod-validation-error', {
60
- detail,
61
- bubbles: true,
62
- cancelable: false,
63
- })
64
-
65
- window.dispatchEvent(event)
66
- } catch (error) {
67
- // Silently fail - validation event dispatch should never crash the app
68
- console.warn('Failed to dispatch validation error event:', error)
69
- }
70
- }
71
-
72
- /**
73
- * Add a global listener for Zod validation errors.
74
- *
75
- * @param callback - Function to call when validation error occurs
76
- * @returns Cleanup function to remove the listener
77
- *
78
- * @example
79
- * ```typescript
80
- * const cleanup = onValidationError(({ operation, error }) => {
81
- * toast.error(`Validation failed in ${operation}`);
82
- * logToSentry(error);
83
- * });
84
- *
85
- * // Later, remove listener
86
- * cleanup();
87
- * ```
88
- */
89
- export function onValidationError(
90
- callback: (detail: ValidationErrorDetail) => void
91
- ): () => void {
92
- if (typeof window === 'undefined') {
93
- // Return no-op cleanup function for SSR
94
- return () => {}
95
- }
96
-
97
- const handler = (event: Event) => {
98
- if (event instanceof CustomEvent) {
99
- callback(event.detail)
100
- }
101
- }
102
-
103
- window.addEventListener('zod-validation-error', handler)
104
-
105
- // Return cleanup function
106
- return () => {
107
- window.removeEventListener('zod-validation-error', handler)
108
- }
109
- }
110
-
111
- /**
112
- * Format Zod error for logging/display.
113
- *
114
- * @param error - Zod validation error
115
- * @returns Formatted error message
116
- */
117
- export function formatZodError(error: ZodError): string {
118
- const issues = error.issues.map((issue, index) => {
119
- const path = issue.path.join('.') || 'root'
120
- const parts = [`${index + 1}. ${path}: ${issue.message}`]
121
-
122
- if ('expected' in issue && issue.expected) {
123
- parts.push(` Expected: ${issue.expected}`)
124
- }
125
-
126
- if ('received' in issue && issue.received) {
127
- parts.push(` Received: ${issue.received}`)
128
- }
129
-
130
- return parts.join('\n')
131
- })
132
-
133
- return issues.join('\n')
134
- }
@@ -1,45 +0,0 @@
1
- import * as Models from "./models";
2
-
3
-
4
- /**
5
- * API endpoints for Web Push.
6
- */
7
- export class WebPush {
8
- private client: any;
9
-
10
- constructor(client: any) {
11
- this.client = client;
12
- }
13
-
14
- /**
15
- * Send push notification
16
- *
17
- * Send push notification to all active subscriptions for the authenticated
18
- * user.
19
- */
20
- async webpushSendCreate(data: Models.SendPushRequestRequest): Promise<Models.SendPushResponse> {
21
- const response = await this.client.request('POST', "/cfg/webpush/send/", { body: data });
22
- return response;
23
- }
24
-
25
- /**
26
- * Subscribe to push notifications
27
- *
28
- * Save push subscription from browser for the authenticated user.
29
- */
30
- async webpushSubscribeCreate(data: Models.SubscribeRequestRequest): Promise<Models.SubscribeResponse> {
31
- const response = await this.client.request('POST', "/cfg/webpush/subscribe/", { body: data });
32
- return response;
33
- }
34
-
35
- /**
36
- * Get VAPID public key
37
- *
38
- * Get VAPID public key for client subscription.
39
- */
40
- async webpushVapidRetrieve(): Promise<Models.VapidPublicKeyResponse> {
41
- const response = await this.client.request('GET', "/cfg/webpush/vapid/");
42
- return response;
43
- }
44
-
45
- }
@@ -1,3 +0,0 @@
1
- // Auto-generated by DjangoCFG - see CLAUDE.md
2
- export * from "./client";
3
- export * as Models from "./models";
@@ -1,65 +0,0 @@
1
- // Auto-generated by DjangoCFG - see CLAUDE.md
2
- /**
3
- * Request serializer for sending push notifications.
4
- *
5
- * Request model (no read-only fields).
6
- */
7
- export interface SendPushRequestRequest {
8
- /** Notification title */
9
- title: string;
10
- /** Notification body */
11
- body: string;
12
- /** Notification icon URL */
13
- icon?: string | null;
14
- /** URL to open on click */
15
- url?: string | null;
16
- }
17
-
18
- /**
19
- * Response serializer for send push endpoint.
20
- *
21
- * Response model (includes read-only fields).
22
- */
23
- export interface SendPushResponse {
24
- /** Whether send was successful */
25
- success: boolean;
26
- /** Number of devices notification was sent to */
27
- sent_to: number;
28
- }
29
-
30
- /**
31
- * Request serializer for subscribing to push notifications.
32
- *
33
- * Request model (no read-only fields).
34
- */
35
- export interface SubscribeRequestRequest {
36
- /** Push service endpoint URL from browser */
37
- endpoint: string;
38
- /** Encryption keys (p256dh and auth) */
39
- keys: Record<string, any>;
40
- }
41
-
42
- /**
43
- * Response serializer for subscription endpoint.
44
- *
45
- * Response model (includes read-only fields).
46
- */
47
- export interface SubscribeResponse {
48
- /** Whether subscription was successful */
49
- success: boolean;
50
- /** ID of the subscription */
51
- subscription_id: number;
52
- /** Whether subscription was newly created */
53
- created: boolean;
54
- }
55
-
56
- /**
57
- * Response serializer for VAPID public key endpoint.
58
- *
59
- * Response model (includes read-only fields).
60
- */
61
- export interface VapidPublicKeyResponse {
62
- /** VAPID public key for client subscription */
63
- publicKey: string;
64
- }
65
-
@@ -1,12 +0,0 @@
1
- /**
2
- * @djangocfg/api - Web Push hooks
3
- *
4
- * Push notifications subscription and management hooks.
5
- * Note: cfg_webpush contains the same hooks as cfg_accounts.
6
- * Keep this file for future webpush-specific hooks.
7
- */
8
- 'use client';
9
-
10
- // Currently cfg_webpush doesn't have webpush-specific endpoints
11
- // All hooks are re-exported from accounts.ts to avoid duplicates
12
- // export * from '../generated/cfg_webpush/_utils/hooks';