@djangocfg/ext-support 1.0.8 → 1.0.10
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 +2 -2
- package/dist/config.js +2 -2
- package/dist/hooks.cjs +91 -62
- package/dist/hooks.js +49 -20
- package/dist/index.cjs +91 -62
- package/dist/index.d.cts +35 -12
- package/dist/index.d.ts +35 -12
- package/dist/index.js +49 -20
- package/package.json +6 -6
- package/src/api/generated/ext_support/CLAUDE.md +1 -8
- package/src/api/generated/ext_support/api-instance.ts +61 -13
- package/src/api/generated/ext_support/client.ts +23 -2
- package/src/api/generated/ext_support/http.ts +8 -2
- package/src/api/generated/ext_support/index.ts +3 -1
- package/src/api/index.ts +6 -1
- package/src/contexts/SupportContext.tsx +3 -0
- package/src/layouts/SupportLayout/SupportLayout.tsx +1 -1
- package/src/layouts/SupportLayout/components/CreateTicketDialog.tsx +3 -10
- package/src/layouts/SupportLayout/components/MessageInput.tsx +2 -1
- package/src/layouts/SupportLayout/components/MessageList.tsx +1 -1
- package/src/layouts/SupportLayout/components/TicketCard.tsx +1 -1
- package/src/layouts/SupportLayout/components/TicketList.tsx +1 -1
|
@@ -14,6 +14,8 @@ export interface HttpRequest {
|
|
|
14
14
|
params?: Record<string, any>;
|
|
15
15
|
/** FormData for file uploads (multipart/form-data) */
|
|
16
16
|
formData?: FormData;
|
|
17
|
+
/** Binary data for octet-stream uploads */
|
|
18
|
+
binaryBody?: Blob | ArrayBuffer;
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
export interface HttpResponse<T = any> {
|
|
@@ -37,7 +39,7 @@ export interface HttpClientAdapter {
|
|
|
37
39
|
*/
|
|
38
40
|
export class FetchAdapter implements HttpClientAdapter {
|
|
39
41
|
async request<T = any>(request: HttpRequest): Promise<HttpResponse<T>> {
|
|
40
|
-
const { method, url, headers, body, params, formData } = request;
|
|
42
|
+
const { method, url, headers, body, params, formData, binaryBody } = request;
|
|
41
43
|
|
|
42
44
|
// Build URL with query params
|
|
43
45
|
let finalUrl = url;
|
|
@@ -58,12 +60,16 @@ export class FetchAdapter implements HttpClientAdapter {
|
|
|
58
60
|
const finalHeaders: Record<string, string> = { ...headers };
|
|
59
61
|
|
|
60
62
|
// Determine body and content-type
|
|
61
|
-
let requestBody: string | FormData | undefined;
|
|
63
|
+
let requestBody: string | FormData | Blob | ArrayBuffer | undefined;
|
|
62
64
|
|
|
63
65
|
if (formData) {
|
|
64
66
|
// For multipart/form-data, let browser set Content-Type with boundary
|
|
65
67
|
requestBody = formData;
|
|
66
68
|
// Don't set Content-Type - browser will set it with boundary
|
|
69
|
+
} else if (binaryBody) {
|
|
70
|
+
// Binary upload (application/octet-stream)
|
|
71
|
+
finalHeaders['Content-Type'] = 'application/octet-stream';
|
|
72
|
+
requestBody = binaryBody;
|
|
67
73
|
} else if (body) {
|
|
68
74
|
// JSON request
|
|
69
75
|
finalHeaders['Content-Type'] = 'application/json';
|
|
@@ -133,10 +133,11 @@ export class API {
|
|
|
133
133
|
|
|
134
134
|
this._loadTokensFromStorage();
|
|
135
135
|
|
|
136
|
-
// Initialize APIClient
|
|
136
|
+
// Initialize APIClient with token getter for URL authentication
|
|
137
137
|
this._client = new APIClient(this.baseUrl, {
|
|
138
138
|
retryConfig: this.options?.retryConfig,
|
|
139
139
|
loggerConfig: this.options?.loggerConfig,
|
|
140
|
+
tokenGetter: () => this.getToken(),
|
|
140
141
|
});
|
|
141
142
|
|
|
142
143
|
// Always inject auth header wrapper (reads token dynamically from storage)
|
|
@@ -155,6 +156,7 @@ export class API {
|
|
|
155
156
|
this._client = new APIClient(this.baseUrl, {
|
|
156
157
|
retryConfig: this.options?.retryConfig,
|
|
157
158
|
loggerConfig: this.options?.loggerConfig,
|
|
159
|
+
tokenGetter: () => this.getToken(),
|
|
158
160
|
});
|
|
159
161
|
|
|
160
162
|
// Always inject auth header wrapper (reads token dynamically from storage)
|
package/src/api/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createExtensionAPI } from '@djangocfg/ext-base/api';
|
|
1
|
+
import { createExtensionAPI, initializeExtensionAPI } from '@djangocfg/ext-base/api';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Support Extension API
|
|
@@ -6,5 +6,10 @@ import { createExtensionAPI } from '@djangocfg/ext-base/api';
|
|
|
6
6
|
* Pre-configured API instance with shared authentication
|
|
7
7
|
*/
|
|
8
8
|
import { API } from './generated/ext_support';
|
|
9
|
+
import { configureAPI } from './generated/ext_support/api-instance';
|
|
9
10
|
|
|
11
|
+
// Initialize global API singleton for hooks and fetchers
|
|
12
|
+
initializeExtensionAPI(configureAPI);
|
|
13
|
+
|
|
14
|
+
// Create instance for direct usage
|
|
10
15
|
export const apiSupport = createExtensionAPI(API);
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
import React, { createContext, ReactNode, useContext } from 'react';
|
|
4
4
|
|
|
5
|
+
// Initialize API before using hooks
|
|
6
|
+
import '../api';
|
|
7
|
+
|
|
5
8
|
import {
|
|
6
9
|
useCreateSupportTicketsCreate, useCreateSupportTicketsMessagesCreate,
|
|
7
10
|
useDeleteSupportTicketsDestroy, useDeleteSupportTicketsMessagesDestroy,
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import { ArrowLeft, LifeBuoy, Plus } from 'lucide-react';
|
|
10
10
|
import React from 'react';
|
|
11
11
|
|
|
12
|
-
import { Button, ResizableHandle, ResizablePanel, ResizablePanelGroup } from '@djangocfg/ui-
|
|
12
|
+
import { Button, ResizableHandle, ResizablePanel, ResizablePanelGroup } from '@djangocfg/ui-core';
|
|
13
13
|
|
|
14
14
|
import { SupportProvider } from '../../contexts/SupportContext';
|
|
15
15
|
import { CreateTicketDialog, MessageInput, MessageList, TicketList } from './components';
|
|
@@ -14,7 +14,7 @@ import { z } from 'zod';
|
|
|
14
14
|
import {
|
|
15
15
|
Button, Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, Form, FormControl,
|
|
16
16
|
FormField, FormItem, FormLabel, FormMessage, Input, Textarea, useToast
|
|
17
|
-
} from '@djangocfg/ui-
|
|
17
|
+
} from '@djangocfg/ui-core';
|
|
18
18
|
import { zodResolver } from '@hookform/resolvers/zod';
|
|
19
19
|
|
|
20
20
|
import { supportLogger } from '../../../utils/logger';
|
|
@@ -45,17 +45,10 @@ export const CreateTicketDialog: React.FC = () => {
|
|
|
45
45
|
try {
|
|
46
46
|
await createTicket(data);
|
|
47
47
|
form.reset();
|
|
48
|
-
toast(
|
|
49
|
-
title: 'Success',
|
|
50
|
-
description: 'Support ticket created successfully',
|
|
51
|
-
});
|
|
48
|
+
toast.success('Support ticket created successfully');
|
|
52
49
|
} catch (error) {
|
|
53
50
|
supportLogger.error('Failed to create ticket:', error);
|
|
54
|
-
toast(
|
|
55
|
-
title: 'Error',
|
|
56
|
-
description: 'Failed to create ticket. Please try again.',
|
|
57
|
-
variant: 'destructive',
|
|
58
|
-
});
|
|
51
|
+
toast.error('Failed to create ticket. Please try again.');
|
|
59
52
|
} finally {
|
|
60
53
|
setIsSubmitting(false);
|
|
61
54
|
}
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
import { Send } from 'lucide-react';
|
|
9
9
|
import React, { useState } from 'react';
|
|
10
10
|
|
|
11
|
-
import { Button, Textarea
|
|
11
|
+
import { Button, Textarea } from '@djangocfg/ui-core';
|
|
12
|
+
import { useToast } from '@djangocfg/ui-core/hooks';
|
|
12
13
|
|
|
13
14
|
import { supportLogger } from '../../../utils/logger';
|
|
14
15
|
import { useSupportLayoutContext } from '../context';
|
|
@@ -12,7 +12,7 @@ import React, { useCallback, useEffect, useRef } from 'react';
|
|
|
12
12
|
import { useAuth } from '@djangocfg/api/auth';
|
|
13
13
|
import {
|
|
14
14
|
Avatar, AvatarFallback, AvatarImage, Button, Card, CardContent, ScrollArea, Skeleton
|
|
15
|
-
} from '@djangocfg/ui-
|
|
15
|
+
} from '@djangocfg/ui-core';
|
|
16
16
|
|
|
17
17
|
import { useSupportLayoutContext } from '../context';
|
|
18
18
|
import { useInfiniteMessages } from '../hooks';
|
|
@@ -9,7 +9,7 @@ import { Clock, MessageSquare } from 'lucide-react';
|
|
|
9
9
|
import moment from 'moment';
|
|
10
10
|
import React from 'react';
|
|
11
11
|
|
|
12
|
-
import { Badge, Card, CardContent } from '@djangocfg/ui-
|
|
12
|
+
import { Badge, Card, CardContent } from '@djangocfg/ui-core';
|
|
13
13
|
import { cn } from '@djangocfg/ui-core/lib';
|
|
14
14
|
|
|
15
15
|
import type { Ticket } from '../../../api/generated/ext_support/_utils/schemas';
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import { Loader2, MessageSquare } from 'lucide-react';
|
|
9
9
|
import React, { useEffect, useRef } from 'react';
|
|
10
10
|
|
|
11
|
-
import { Button, ScrollArea, Skeleton } from '@djangocfg/ui-
|
|
11
|
+
import { Button, ScrollArea, Skeleton } from '@djangocfg/ui-core';
|
|
12
12
|
|
|
13
13
|
import { useSupportLayoutContext } from '../context';
|
|
14
14
|
import { SUPPORT_LAYOUT_EVENTS } from '../events';
|