@djangocfg/ext-support 1.0.24 → 1.0.26

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 (38) hide show
  1. package/dist/config.cjs +1 -1
  2. package/dist/config.js +1 -1
  3. package/dist/hooks.cjs +398 -334
  4. package/dist/hooks.d.cts +6 -2
  5. package/dist/hooks.d.ts +6 -2
  6. package/dist/hooks.js +356 -291
  7. package/dist/i18n.cjs +72 -72
  8. package/dist/i18n.js +73 -73
  9. package/dist/index-D-xo66K9.d.cts +862 -0
  10. package/dist/index-D-xo66K9.d.ts +863 -0
  11. package/dist/index-Dov7pn8Z.d.ts +2 -1
  12. package/dist/index-rR_XqXq1.d.cts +838 -0
  13. package/dist/index-rR_XqXq1.d.ts +838 -0
  14. package/dist/index.cjs +398 -334
  15. package/dist/index.d.cts +1 -1
  16. package/dist/index.d.ts +1 -1
  17. package/dist/index.js +356 -291
  18. package/package.json +8 -8
  19. package/src/adapters/api.ts +4 -5
  20. package/src/adapters/demo.ts +2 -1
  21. package/src/api/generated/ext_support/_utils/fetchers/ext_support__support.ts +4 -4
  22. package/src/api/generated/ext_support/_utils/hooks/ext_support__support.ts +2 -2
  23. package/src/api/generated/ext_support/_utils/schemas/Ticket.schema.ts +1 -1
  24. package/src/api/generated/ext_support/_utils/schemas/TicketRequest.schema.ts +1 -1
  25. package/src/api/generated/ext_support/enums.ts +0 -30
  26. package/src/api/generated/ext_support/ext_support__support/client.ts +6 -6
  27. package/src/api/generated/ext_support/ext_support__support/models.ts +2 -2
  28. package/src/api/generated/ext_support/schema.json +36 -0
  29. package/src/components/CreateTicketSheet.tsx +7 -12
  30. package/src/components/SupportHero.tsx +35 -47
  31. package/src/components/TicketItem.tsx +28 -74
  32. package/src/components/TicketList.tsx +30 -23
  33. package/src/components/TicketSheet.tsx +246 -162
  34. package/src/contexts/SupportExtensionProvider.tsx +4 -4
  35. package/src/contexts/types.ts +2 -2
  36. package/src/i18n/useSupportT.ts +3 -3
  37. package/src/utils/status.ts +44 -0
  38. package/src/utils/time.ts +88 -0
@@ -0,0 +1,862 @@
1
+ import { ConsolaInstance } from 'consola';
2
+ import * as react_jsx_runtime from 'react/jsx-runtime';
3
+ import { z } from 'zod';
4
+ import { ReactNode } from 'react';
5
+ import * as _djangocfg_ext_base from '@djangocfg/ext-base';
6
+
7
+ /**
8
+ * * `open` - Open
9
+ * * `waiting_for_user` - Waiting for User
10
+ * * `waiting_for_admin` - Waiting for Admin
11
+ * * `resolved` - Resolved
12
+ * * `closed` - Closed
13
+ */
14
+ declare enum PatchedTicketRequestStatus {
15
+ OPEN = "open",
16
+ WAITING_FOR_USER = "waiting_for_user",
17
+ WAITING_FOR_ADMIN = "waiting_for_admin",
18
+ RESOLVED = "resolved",
19
+ CLOSED = "closed"
20
+ }
21
+ /**
22
+ * * `open` - Open
23
+ * * `waiting_for_user` - Waiting for User
24
+ * * `waiting_for_admin` - Waiting for Admin
25
+ * * `resolved` - Resolved
26
+ * * `closed` - Closed
27
+ */
28
+ declare enum TicketStatus {
29
+ OPEN = "open",
30
+ WAITING_FOR_USER = "waiting_for_user",
31
+ WAITING_FOR_ADMIN = "waiting_for_admin",
32
+ RESOLVED = "resolved",
33
+ CLOSED = "closed"
34
+ }
35
+ /**
36
+ * * `open` - Open
37
+ * * `waiting_for_user` - Waiting for User
38
+ * * `waiting_for_admin` - Waiting for Admin
39
+ * * `resolved` - Resolved
40
+ * * `closed` - Closed
41
+ */
42
+ declare enum TicketRequestStatus {
43
+ OPEN = "open",
44
+ WAITING_FOR_USER = "waiting_for_user",
45
+ WAITING_FOR_ADMIN = "waiting_for_admin",
46
+ RESOLVED = "resolved",
47
+ CLOSED = "closed"
48
+ }
49
+
50
+ /**
51
+ *
52
+ * Response model (includes read-only fields).
53
+ */
54
+ interface PaginatedTicketList$1 {
55
+ /** Total number of items across all pages */
56
+ count: number;
57
+ /** Current page number (1-based) */
58
+ page: number;
59
+ /** Total number of pages */
60
+ pages: number;
61
+ /** Number of items per page */
62
+ page_size: number;
63
+ /** Whether there is a next page */
64
+ has_next: boolean;
65
+ /** Whether there is a previous page */
66
+ has_previous: boolean;
67
+ /** Next page number (null if no next page) */
68
+ next_page?: number | null;
69
+ /** Previous page number (null if no previous page) */
70
+ previous_page?: number | null;
71
+ /** Array of items for current page */
72
+ results: Array<Ticket$1>;
73
+ }
74
+ /**
75
+ *
76
+ * Request model (no read-only fields).
77
+ */
78
+ interface TicketRequest$1 {
79
+ user: number;
80
+ subject: string;
81
+ /** * `open` - Open
82
+ * `waiting_for_user` - Waiting for User
83
+ * `waiting_for_admin` - Waiting for Admin
84
+ * `resolved` - Resolved
85
+ * `closed` - Closed */
86
+ status?: TicketRequestStatus;
87
+ }
88
+ /**
89
+ *
90
+ * Response model (includes read-only fields).
91
+ */
92
+ interface Ticket$1 {
93
+ uuid: string;
94
+ user: number;
95
+ subject: string;
96
+ /** * `open` - Open
97
+ * `waiting_for_user` - Waiting for User
98
+ * `waiting_for_admin` - Waiting for Admin
99
+ * `resolved` - Resolved
100
+ * `closed` - Closed */
101
+ status?: TicketStatus;
102
+ created_at: string;
103
+ /** Get count of unanswered messages for this specific ticket. */
104
+ unanswered_messages_count: number;
105
+ }
106
+ /**
107
+ *
108
+ * Response model (includes read-only fields).
109
+ */
110
+ interface PaginatedMessageList$1 {
111
+ /** Total number of items across all pages */
112
+ count: number;
113
+ /** Current page number (1-based) */
114
+ page: number;
115
+ /** Total number of pages */
116
+ pages: number;
117
+ /** Number of items per page */
118
+ page_size: number;
119
+ /** Whether there is a next page */
120
+ has_next: boolean;
121
+ /** Whether there is a previous page */
122
+ has_previous: boolean;
123
+ /** Next page number (null if no next page) */
124
+ next_page?: number | null;
125
+ /** Previous page number (null if no previous page) */
126
+ previous_page?: number | null;
127
+ /** Array of items for current page */
128
+ results: Array<Message$1>;
129
+ }
130
+ /**
131
+ *
132
+ * Request model (no read-only fields).
133
+ */
134
+ interface MessageCreateRequest$1 {
135
+ text: string;
136
+ }
137
+ /**
138
+ *
139
+ * Response model (includes read-only fields).
140
+ */
141
+ interface MessageCreate {
142
+ text: string;
143
+ }
144
+ /**
145
+ *
146
+ * Response model (includes read-only fields).
147
+ */
148
+ interface Message$1 {
149
+ uuid: string;
150
+ ticket: string;
151
+ sender: Sender;
152
+ /** Check if this message is from the ticket author. */
153
+ is_from_author: boolean;
154
+ text: string;
155
+ created_at: string;
156
+ }
157
+ /**
158
+ *
159
+ * Request model (no read-only fields).
160
+ */
161
+ interface MessageRequest$1 {
162
+ text: string;
163
+ }
164
+ /**
165
+ *
166
+ * Request model (no read-only fields).
167
+ */
168
+ interface PatchedMessageRequest$1 {
169
+ text?: string;
170
+ }
171
+ /**
172
+ *
173
+ * Request model (no read-only fields).
174
+ */
175
+ interface PatchedTicketRequest$1 {
176
+ user?: number;
177
+ subject?: string;
178
+ /** * `open` - Open
179
+ * `waiting_for_user` - Waiting for User
180
+ * `waiting_for_admin` - Waiting for Admin
181
+ * `resolved` - Resolved
182
+ * `closed` - Closed */
183
+ status?: PatchedTicketRequestStatus;
184
+ }
185
+ /**
186
+ *
187
+ * Response model (includes read-only fields).
188
+ */
189
+ interface Sender {
190
+ id: number;
191
+ /** Get formatted username for display. */
192
+ display_username: string;
193
+ email: string;
194
+ avatar?: string | null;
195
+ /** Get user's initials for avatar fallback. */
196
+ initials: string;
197
+ /** Designates whether the user can log into this admin site. */
198
+ is_staff: boolean;
199
+ /** Designates that this user has all permissions without explicitly assigning them. */
200
+ is_superuser: boolean;
201
+ }
202
+
203
+ /**
204
+ * API endpoints for Support.
205
+ */
206
+ declare class ExtSupportSupport {
207
+ private client;
208
+ constructor(client: any);
209
+ ticketsList(page?: number, page_size?: number): Promise<PaginatedTicketList$1>;
210
+ ticketsList(params?: {
211
+ page?: number;
212
+ page_size?: number;
213
+ }): Promise<PaginatedTicketList$1>;
214
+ /**
215
+ * ViewSet for managing support tickets. Requires authenticated user (JWT
216
+ * or Session). Staff users can see all tickets, regular users see only
217
+ * their own.
218
+ */
219
+ ticketsCreate(data: TicketRequest$1): Promise<Ticket$1>;
220
+ ticketsMessagesList(ticket_uuid: string, page?: number, page_size?: number): Promise<PaginatedMessageList$1>;
221
+ ticketsMessagesList(ticket_uuid: string, params?: {
222
+ page?: number;
223
+ page_size?: number;
224
+ }): Promise<PaginatedMessageList$1>;
225
+ /**
226
+ * ViewSet for managing support messages. Requires authenticated user (JWT
227
+ * or Session). Users can only access messages for their own tickets.
228
+ */
229
+ ticketsMessagesCreate(ticket_uuid: string, data: MessageCreateRequest$1): Promise<MessageCreate>;
230
+ /**
231
+ * ViewSet for managing support messages. Requires authenticated user (JWT
232
+ * or Session). Users can only access messages for their own tickets.
233
+ */
234
+ ticketsMessagesRetrieve(ticket_uuid: string, uuid: string): Promise<Message$1>;
235
+ /**
236
+ * ViewSet for managing support messages. Requires authenticated user (JWT
237
+ * or Session). Users can only access messages for their own tickets.
238
+ */
239
+ ticketsMessagesUpdate(ticket_uuid: string, uuid: string, data: MessageRequest$1): Promise<Message$1>;
240
+ /**
241
+ * ViewSet for managing support messages. Requires authenticated user (JWT
242
+ * or Session). Users can only access messages for their own tickets.
243
+ */
244
+ ticketsMessagesPartialUpdate(ticket_uuid: string, uuid: string, data?: PatchedMessageRequest$1): Promise<Message$1>;
245
+ /**
246
+ * ViewSet for managing support messages. Requires authenticated user (JWT
247
+ * or Session). Users can only access messages for their own tickets.
248
+ */
249
+ ticketsMessagesDestroy(ticket_uuid: string, uuid: string): Promise<void>;
250
+ /**
251
+ * ViewSet for managing support tickets. Requires authenticated user (JWT
252
+ * or Session). Staff users can see all tickets, regular users see only
253
+ * their own.
254
+ */
255
+ ticketsRetrieve(uuid: string): Promise<Ticket$1>;
256
+ /**
257
+ * ViewSet for managing support tickets. Requires authenticated user (JWT
258
+ * or Session). Staff users can see all tickets, regular users see only
259
+ * their own.
260
+ */
261
+ ticketsUpdate(uuid: string, data: TicketRequest$1): Promise<Ticket$1>;
262
+ /**
263
+ * ViewSet for managing support tickets. Requires authenticated user (JWT
264
+ * or Session). Staff users can see all tickets, regular users see only
265
+ * their own.
266
+ */
267
+ ticketsPartialUpdate(uuid: string, data?: PatchedTicketRequest$1): Promise<Ticket$1>;
268
+ /**
269
+ * ViewSet for managing support tickets. Requires authenticated user (JWT
270
+ * or Session). Staff users can see all tickets, regular users see only
271
+ * their own.
272
+ */
273
+ ticketsDestroy(uuid: string): Promise<void>;
274
+ }
275
+
276
+ /**
277
+ * API Logger with Consola
278
+ * Beautiful console logging for API requests and responses
279
+ *
280
+ * Installation:
281
+ * npm install consola
282
+ */
283
+
284
+ /**
285
+ * Logger configuration
286
+ */
287
+ interface LoggerConfig {
288
+ /** Enable logging */
289
+ enabled: boolean;
290
+ /** Log requests */
291
+ logRequests: boolean;
292
+ /** Log responses */
293
+ logResponses: boolean;
294
+ /** Log errors */
295
+ logErrors: boolean;
296
+ /** Log request/response bodies */
297
+ logBodies: boolean;
298
+ /** Log headers (excluding sensitive ones) */
299
+ logHeaders: boolean;
300
+ /** Custom consola instance */
301
+ consola?: ConsolaInstance;
302
+ }
303
+
304
+ /**
305
+ * Retry Configuration and Utilities
306
+ *
307
+ * Provides automatic retry logic for failed HTTP requests using p-retry.
308
+ * Retries only on network errors and server errors (5xx), not client errors (4xx).
309
+ */
310
+ /**
311
+ * Information about a failed retry attempt.
312
+ */
313
+ interface FailedAttemptInfo {
314
+ /** The error that caused the failure */
315
+ error: Error;
316
+ /** The attempt number (1-indexed) */
317
+ attemptNumber: number;
318
+ /** Number of retries left */
319
+ retriesLeft: number;
320
+ }
321
+ /**
322
+ * Retry configuration options.
323
+ *
324
+ * Uses exponential backoff with jitter by default to avoid thundering herd.
325
+ */
326
+ interface RetryConfig {
327
+ /**
328
+ * Maximum number of retry attempts.
329
+ * @default 3
330
+ */
331
+ retries?: number;
332
+ /**
333
+ * Exponential backoff factor.
334
+ * @default 2
335
+ */
336
+ factor?: number;
337
+ /**
338
+ * Minimum wait time between retries (ms).
339
+ * @default 1000
340
+ */
341
+ minTimeout?: number;
342
+ /**
343
+ * Maximum wait time between retries (ms).
344
+ * @default 60000
345
+ */
346
+ maxTimeout?: number;
347
+ /**
348
+ * Add randomness to wait times (jitter).
349
+ * Helps avoid thundering herd problem.
350
+ * @default true
351
+ */
352
+ randomize?: boolean;
353
+ /**
354
+ * Callback called on each failed attempt.
355
+ */
356
+ onFailedAttempt?: (info: FailedAttemptInfo) => void;
357
+ }
358
+
359
+ /**
360
+ * Storage adapters for cross-platform token storage.
361
+ *
362
+ * Supports:
363
+ * - LocalStorage (browser)
364
+ * - Cookies (SSR/browser)
365
+ * - Memory (Node.js/Electron/testing)
366
+ */
367
+
368
+ /**
369
+ * Storage adapter interface for cross-platform token storage.
370
+ */
371
+ interface StorageAdapter {
372
+ getItem(key: string): string | null;
373
+ setItem(key: string, value: string): void;
374
+ removeItem(key: string): void;
375
+ }
376
+
377
+ /**
378
+ * Zod schema for Message
379
+ *
380
+ * This schema provides runtime validation and type inference.
381
+ * */
382
+
383
+ declare const MessageSchema: z.ZodObject<{
384
+ uuid: z.ZodString;
385
+ ticket: z.ZodString;
386
+ sender: z.ZodObject<{
387
+ id: z.ZodInt;
388
+ display_username: z.ZodString;
389
+ email: z.ZodEmail;
390
+ avatar: z.ZodNullable<z.ZodString>;
391
+ initials: z.ZodString;
392
+ is_staff: z.ZodBoolean;
393
+ is_superuser: z.ZodBoolean;
394
+ }, z.core.$strip>;
395
+ is_from_author: z.ZodBoolean;
396
+ text: z.ZodString;
397
+ created_at: z.ZodString;
398
+ }, z.core.$strip>;
399
+ /**
400
+ * Infer TypeScript type from Zod schema
401
+ */
402
+ type Message = z.infer<typeof MessageSchema>;
403
+
404
+ /**
405
+ * Zod schema for MessageCreateRequest
406
+ *
407
+ * This schema provides runtime validation and type inference.
408
+ * */
409
+
410
+ declare const MessageCreateRequestSchema: z.ZodObject<{
411
+ text: z.ZodString;
412
+ }, z.core.$strip>;
413
+ /**
414
+ * Infer TypeScript type from Zod schema
415
+ */
416
+ type MessageCreateRequest = z.infer<typeof MessageCreateRequestSchema>;
417
+
418
+ /**
419
+ * Zod schema for MessageRequest
420
+ *
421
+ * This schema provides runtime validation and type inference.
422
+ * */
423
+
424
+ declare const MessageRequestSchema: z.ZodObject<{
425
+ text: z.ZodString;
426
+ }, z.core.$strip>;
427
+ /**
428
+ * Infer TypeScript type from Zod schema
429
+ */
430
+ type MessageRequest = z.infer<typeof MessageRequestSchema>;
431
+
432
+ /**
433
+ * Zod schema for PaginatedMessageList
434
+ *
435
+ * This schema provides runtime validation and type inference.
436
+ * */
437
+
438
+ declare const PaginatedMessageListSchema: z.ZodObject<{
439
+ count: z.ZodInt;
440
+ page: z.ZodInt;
441
+ pages: z.ZodInt;
442
+ page_size: z.ZodInt;
443
+ has_next: z.ZodBoolean;
444
+ has_previous: z.ZodBoolean;
445
+ next_page: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
446
+ previous_page: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
447
+ results: z.ZodArray<z.ZodObject<{
448
+ uuid: z.ZodString;
449
+ ticket: z.ZodString;
450
+ sender: z.ZodObject<{
451
+ id: z.ZodInt;
452
+ display_username: z.ZodString;
453
+ email: z.ZodEmail;
454
+ avatar: z.ZodNullable<z.ZodString>;
455
+ initials: z.ZodString;
456
+ is_staff: z.ZodBoolean;
457
+ is_superuser: z.ZodBoolean;
458
+ }, z.core.$strip>;
459
+ is_from_author: z.ZodBoolean;
460
+ text: z.ZodString;
461
+ created_at: z.ZodString;
462
+ }, z.core.$strip>>;
463
+ }, z.core.$strip>;
464
+ /**
465
+ * Infer TypeScript type from Zod schema
466
+ */
467
+ type PaginatedMessageList = z.infer<typeof PaginatedMessageListSchema>;
468
+
469
+ declare const PaginatedTicketListSchema: z.ZodObject<{
470
+ count: z.ZodInt;
471
+ page: z.ZodInt;
472
+ pages: z.ZodInt;
473
+ page_size: z.ZodInt;
474
+ has_next: z.ZodBoolean;
475
+ has_previous: z.ZodBoolean;
476
+ next_page: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
477
+ previous_page: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
478
+ results: z.ZodArray<z.ZodObject<{
479
+ uuid: z.ZodString;
480
+ user: z.ZodInt;
481
+ subject: z.ZodString;
482
+ status: z.ZodOptional<z.ZodEnum<typeof TicketStatus>>;
483
+ created_at: z.ZodString;
484
+ unanswered_messages_count: z.ZodInt;
485
+ }, z.core.$strip>>;
486
+ }, z.core.$strip>;
487
+ /**
488
+ * Infer TypeScript type from Zod schema
489
+ */
490
+ type PaginatedTicketList = z.infer<typeof PaginatedTicketListSchema>;
491
+
492
+ /**
493
+ * Zod schema for PatchedMessageRequest
494
+ *
495
+ * This schema provides runtime validation and type inference.
496
+ * */
497
+
498
+ declare const PatchedMessageRequestSchema: z.ZodObject<{
499
+ text: z.ZodOptional<z.ZodString>;
500
+ }, z.core.$strip>;
501
+ /**
502
+ * Infer TypeScript type from Zod schema
503
+ */
504
+ type PatchedMessageRequest = z.infer<typeof PatchedMessageRequestSchema>;
505
+
506
+ /**
507
+ * Zod schema for PatchedTicketRequest
508
+ *
509
+ * This schema provides runtime validation and type inference.
510
+ * */
511
+
512
+ declare const PatchedTicketRequestSchema: z.ZodObject<{
513
+ user: z.ZodOptional<z.ZodInt>;
514
+ subject: z.ZodOptional<z.ZodString>;
515
+ status: z.ZodOptional<z.ZodEnum<typeof PatchedTicketRequestStatus>>;
516
+ }, z.core.$strip>;
517
+ /**
518
+ * Infer TypeScript type from Zod schema
519
+ */
520
+ type PatchedTicketRequest = z.infer<typeof PatchedTicketRequestSchema>;
521
+
522
+ /**
523
+ * Zod schema for Ticket
524
+ *
525
+ * This schema provides runtime validation and type inference.
526
+ * */
527
+
528
+ declare const TicketSchema: z.ZodObject<{
529
+ uuid: z.ZodString;
530
+ user: z.ZodInt;
531
+ subject: z.ZodString;
532
+ status: z.ZodOptional<z.ZodEnum<typeof TicketStatus>>;
533
+ created_at: z.ZodString;
534
+ unanswered_messages_count: z.ZodInt;
535
+ }, z.core.$strip>;
536
+ /**
537
+ * Infer TypeScript type from Zod schema
538
+ */
539
+ type Ticket = z.infer<typeof TicketSchema>;
540
+
541
+ /**
542
+ * Zod schema for TicketRequest
543
+ *
544
+ * This schema provides runtime validation and type inference.
545
+ * */
546
+
547
+ declare const TicketRequestSchema: z.ZodObject<{
548
+ user: z.ZodInt;
549
+ subject: z.ZodString;
550
+ status: z.ZodOptional<z.ZodEnum<typeof TicketRequestStatus>>;
551
+ }, z.core.$strip>;
552
+ /**
553
+ * Infer TypeScript type from Zod schema
554
+ */
555
+ type TicketRequest = z.infer<typeof TicketRequestSchema>;
556
+
557
+ /**
558
+ * Django CFG API - API Client with JWT Management
559
+ *
560
+ * Usage:
561
+ * ```typescript
562
+ * import { API } from './api';
563
+ *
564
+ * const api = new API('https://api.example.com');
565
+ *
566
+ * // Set JWT token
567
+ * api.setToken('your-jwt-token', 'refresh-token');
568
+ *
569
+ * // Use API
570
+ * const posts = await api.posts.list();
571
+ * const user = await api.users.retrieve(1);
572
+ *
573
+ * // Check authentication
574
+ * if (api.isAuthenticated()) {
575
+ * // ...
576
+ * }
577
+ *
578
+ * // Custom storage with logging (for Electron/Node.js)
579
+ * import { MemoryStorageAdapter, APILogger } from './storage';
580
+ * const logger = new APILogger({ enabled: true, logLevel: 'debug' });
581
+ * const api = new API('https://api.example.com', {
582
+ * storage: new MemoryStorageAdapter(logger),
583
+ * loggerConfig: { enabled: true, logLevel: 'debug' }
584
+ * });
585
+ *
586
+ * // Get OpenAPI schema
587
+ * const schema = api.getSchema();
588
+ * ```
589
+ */
590
+
591
+ interface APIOptions {
592
+ /** Custom storage adapter (defaults to LocalStorageAdapter) */
593
+ storage?: StorageAdapter;
594
+ /** Retry configuration for failed requests */
595
+ retryConfig?: RetryConfig;
596
+ /** Logger configuration */
597
+ loggerConfig?: Partial<LoggerConfig>;
598
+ }
599
+ declare class API {
600
+ private baseUrl;
601
+ private _client;
602
+ private _token;
603
+ private _refreshToken;
604
+ private storage;
605
+ private options?;
606
+ ext_support_support: ExtSupportSupport;
607
+ constructor(baseUrl: string, options?: APIOptions);
608
+ private _loadTokensFromStorage;
609
+ private _reinitClients;
610
+ private _injectAuthHeader;
611
+ /**
612
+ * Get current JWT token
613
+ */
614
+ getToken(): string | null;
615
+ /**
616
+ * Get current refresh token
617
+ */
618
+ getRefreshToken(): string | null;
619
+ /**
620
+ * Set JWT token and refresh token
621
+ * @param token - JWT access token
622
+ * @param refreshToken - JWT refresh token (optional)
623
+ */
624
+ setToken(token: string, refreshToken?: string): void;
625
+ /**
626
+ * Clear all tokens
627
+ */
628
+ clearTokens(): void;
629
+ /**
630
+ * Check if user is authenticated
631
+ */
632
+ isAuthenticated(): boolean;
633
+ /**
634
+ * Update base URL and reinitialize clients
635
+ * @param url - New base URL
636
+ */
637
+ setBaseUrl(url: string): void;
638
+ /**
639
+ * Get current base URL
640
+ */
641
+ getBaseUrl(): string;
642
+ /**
643
+ * Get OpenAPI schema path
644
+ * @returns Path to the OpenAPI schema JSON file
645
+ *
646
+ * Note: The OpenAPI schema is available in the schema.json file.
647
+ * You can load it dynamically using:
648
+ * ```typescript
649
+ * const schema = await fetch('./schema.json').then(r => r.json());
650
+ * // or using fs in Node.js:
651
+ * // const schema = JSON.parse(fs.readFileSync('./schema.json', 'utf-8'));
652
+ * ```
653
+ */
654
+ getSchemaPath(): string;
655
+ }
656
+
657
+ /**
658
+ * Support Extension API
659
+ *
660
+ * Pre-configured API instance with shared authentication
661
+ */
662
+
663
+ declare const apiSupport: API;
664
+
665
+ /**
666
+ * Support Page Component (Apple-style)
667
+ *
668
+ * Single page with support hero + ticket list.
669
+ * Uses adapter pattern - works with any SupportAdapter (API or Demo).
670
+ *
671
+ * Usage:
672
+ * // Production (with API)
673
+ * <SupportPage />
674
+ *
675
+ * // Demo (with mocks, no backend needed)
676
+ * <SupportPage isDemo />
677
+ */
678
+ declare const SupportContent: () => react_jsx_runtime.JSX.Element;
679
+ interface SupportPageProps {
680
+ /** Use demo adapter with mock data (no backend required) */
681
+ isDemo?: boolean;
682
+ }
683
+ /**
684
+ * Support Page - automatically selects adapter based on isDemo prop.
685
+ *
686
+ * @example
687
+ * // Production (with API)
688
+ * <SupportPage />
689
+ *
690
+ * @example
691
+ * // Demo (with mocks)
692
+ * <SupportPage isDemo />
693
+ */
694
+ declare function SupportPage({ isDemo }: SupportPageProps): react_jsx_runtime.JSX.Element;
695
+
696
+ /**
697
+ * Support Hero (Apple HIG)
698
+ *
699
+ * Clean header with stats pills and create action
700
+ */
701
+ interface SupportHeroProps {
702
+ onCreateTicket?: () => void;
703
+ className?: string;
704
+ }
705
+ declare function SupportHero({ onCreateTicket, className }: SupportHeroProps): react_jsx_runtime.JSX.Element;
706
+
707
+ /**
708
+ * Support Model Types
709
+ *
710
+ * Defines the abstract interface for support operations.
711
+ * Adapters (API, Demo) implement this interface.
712
+ */
713
+
714
+ interface CreateTicketInput {
715
+ subject: string;
716
+ message: string;
717
+ }
718
+ interface SendMessageInput {
719
+ ticketUuid: string;
720
+ text: string;
721
+ }
722
+ interface TicketsResult {
723
+ tickets: Ticket[];
724
+ isLoading: boolean;
725
+ isLoadingMore: boolean;
726
+ hasMore: boolean;
727
+ totalCount: number;
728
+ loadMore: () => void;
729
+ refresh: () => Promise<void>;
730
+ }
731
+ interface MessagesResult {
732
+ messages: Message[];
733
+ isLoading: boolean;
734
+ isLoadingMore: boolean;
735
+ hasMore: boolean;
736
+ totalCount: number;
737
+ loadMore: () => void;
738
+ refresh: () => Promise<void>;
739
+ addOptimistic: (message: Message) => void;
740
+ }
741
+ interface SupportModel {
742
+ useTickets: () => TicketsResult;
743
+ useMessages: (ticketUuid: string | null) => MessagesResult;
744
+ createTicket: (input: CreateTicketInput) => Promise<Ticket>;
745
+ sendMessage: (input: SendMessageInput) => Promise<Message>;
746
+ getUnreadCount: (tickets: Ticket[]) => number;
747
+ }
748
+ type SupportAdapter = SupportModel;
749
+
750
+ interface SupportContextValue {
751
+ adapter: SupportAdapter;
752
+ }
753
+ interface SupportProviderProps {
754
+ children: ReactNode;
755
+ adapter: SupportAdapter;
756
+ }
757
+ declare function SupportProvider({ children, adapter }: SupportProviderProps): react_jsx_runtime.JSX.Element;
758
+ /**
759
+ * Hook for tickets list with pagination
760
+ */
761
+ declare function useTickets(): TicketsResult;
762
+ /**
763
+ * Hook for messages of a specific ticket
764
+ */
765
+ declare function useMessages(ticketUuid: string | null): MessagesResult;
766
+ /**
767
+ * Hook for support operations (create ticket, send message)
768
+ */
769
+ declare function useSupport(): {
770
+ tickets: {
771
+ uuid: string;
772
+ user: number;
773
+ subject: string;
774
+ created_at: string;
775
+ unanswered_messages_count: number;
776
+ status?: TicketStatus;
777
+ }[];
778
+ isLoadingTickets: boolean;
779
+ refreshTickets: () => Promise<void>;
780
+ createTicket: (input: CreateTicketInput) => Promise<Ticket>;
781
+ sendMessage: (input: SendMessageInput) => Promise<Message>;
782
+ unreadCount: number;
783
+ };
784
+ /**
785
+ * Legacy hook - returns everything (for backwards compatibility)
786
+ * @deprecated Use useTickets, useMessages, useSupport separately
787
+ */
788
+ declare function useSupportAll(): {
789
+ createTicket: (input: CreateTicketInput) => Promise<Ticket>;
790
+ sendMessage: (input: SendMessageInput) => Promise<Message>;
791
+ unreadCount: number;
792
+ isLoading: boolean;
793
+ tickets: Ticket[];
794
+ isLoadingMore: boolean;
795
+ hasMore: boolean;
796
+ totalCount: number;
797
+ loadMore: () => void;
798
+ refresh: () => Promise<void>;
799
+ };
800
+
801
+ interface TicketListProps {
802
+ onTicketClick?: (ticket: Ticket) => void;
803
+ className?: string;
804
+ }
805
+ declare function TicketList({ onTicketClick, className }: TicketListProps): react_jsx_runtime.JSX.Element;
806
+
807
+ interface TicketItemProps {
808
+ ticket: Ticket;
809
+ onClick?: () => void;
810
+ }
811
+ declare function TicketItem({ ticket, onClick }: TicketItemProps): react_jsx_runtime.JSX.Element;
812
+
813
+ interface TicketSheetProps {
814
+ ticket: Ticket | null;
815
+ open: boolean;
816
+ onOpenChange: (open: boolean) => void;
817
+ }
818
+ declare function TicketSheet({ ticket, open, onOpenChange }: TicketSheetProps): react_jsx_runtime.JSX.Element;
819
+
820
+ interface CreateTicketSheetProps {
821
+ open: boolean;
822
+ onOpenChange: (open: boolean) => void;
823
+ onSuccess?: (ticket: Ticket) => void;
824
+ }
825
+ declare function CreateTicketSheet({ open, onOpenChange, onSuccess }: CreateTicketSheetProps): react_jsx_runtime.JSX.Element;
826
+
827
+ /**
828
+ * API Adapter
829
+ *
830
+ * Implements SupportModel using real API calls.
831
+ * This is the production adapter.
832
+ */
833
+
834
+ declare const apiAdapter: SupportAdapter;
835
+ /**
836
+ * Creates API adapter instance
837
+ * Note: Operations (createTicket, sendMessage) need hooks, so they're
838
+ * provided through the context layer
839
+ */
840
+ declare function createApiAdapter(): SupportAdapter;
841
+ /**
842
+ * Hook to get full API adapter with operations
843
+ * Must be used inside a component
844
+ */
845
+ declare function useApiAdapter(): SupportAdapter;
846
+
847
+ /**
848
+ * Demo Adapter
849
+ *
850
+ * Implements SupportModel using mock data.
851
+ * Used for demos without backend.
852
+ */
853
+
854
+ declare function createDemoAdapter(): SupportAdapter;
855
+ declare function resetDemoData(): void;
856
+
857
+ /**
858
+ * Support extension configuration
859
+ */
860
+ declare const extensionConfig: _djangocfg_ext_base.ExtensionMetadata;
861
+
862
+ export { API as A, apiAdapter as B, CreateTicketSheet as C, createDemoAdapter as D, resetDemoData as E, type PaginatedTicketList as F, type PaginatedMessageList as G, extensionConfig as H, type MessageCreateRequest as M, type PatchedMessageRequest as P, SupportProvider as S, type TicketRequest as T, type Ticket as a, type MessageRequest as b, type Message as c, type PatchedTicketRequest as d, useTickets as e, useMessages as f, apiSupport as g, SupportPage as h, SupportContent as i, type SupportPageProps as j, SupportHero as k, TicketList as l, TicketItem as m, TicketSheet as n, useSupportAll as o, type SupportContextValue as p, type SupportProviderProps as q, type SupportModel as r, type SupportAdapter as s, type CreateTicketInput as t, useSupport as u, type SendMessageInput as v, type TicketsResult as w, type MessagesResult as x, createApiAdapter as y, useApiAdapter as z };