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