@djangocfg/layouts 2.1.10 → 2.1.15
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/README.md +53 -161
- package/package.json +6 -6
- package/src/components/RedirectPage/RedirectPage.tsx +1 -1
- package/src/index.ts +0 -6
- package/src/layouts/AppLayout/AppLayout.tsx +1 -1
- package/src/layouts/AppLayout/BaseApp.tsx +1 -1
- package/src/layouts/AuthLayout/AuthContext.tsx +1 -1
- package/src/layouts/AuthLayout/OAuthCallback.tsx +1 -1
- package/src/layouts/AuthLayout/OAuthProviders.tsx +1 -1
- package/src/layouts/PrivateLayout/PrivateLayout.tsx +1 -1
- package/src/layouts/PrivateLayout/components/PrivateHeader.tsx +1 -1
- package/src/layouts/ProfileLayout/ProfileLayout.tsx +2 -2
- package/src/layouts/ProfileLayout/components/AvatarSection.tsx +2 -2
- package/src/layouts/ProfileLayout/components/ProfileForm.tsx +2 -2
- package/src/layouts/PublicLayout/components/PublicMobileDrawer.tsx +1 -1
- package/src/layouts/PublicLayout/components/PublicNavigation.tsx +1 -1
- package/src/layouts/_components/UserMenu.tsx +1 -1
- package/src/layouts/index.ts +0 -2
- package/src/snippets/Analytics/useAnalytics.ts +1 -1
- package/src/snippets/index.ts +0 -3
- package/src/auth/README.md +0 -962
- package/src/auth/context/AccountsContext.tsx +0 -240
- package/src/auth/context/AuthContext.tsx +0 -604
- package/src/auth/context/index.ts +0 -4
- package/src/auth/context/types.ts +0 -68
- package/src/auth/hooks/index.ts +0 -17
- package/src/auth/hooks/useAuthForm.ts +0 -332
- package/src/auth/hooks/useAuthGuard.ts +0 -25
- package/src/auth/hooks/useAuthRedirect.ts +0 -51
- package/src/auth/hooks/useAutoAuth.ts +0 -49
- package/src/auth/hooks/useGithubAuth.ts +0 -184
- package/src/auth/hooks/useLocalStorage.ts +0 -214
- package/src/auth/hooks/useProfileCache.ts +0 -146
- package/src/auth/hooks/useSessionStorage.ts +0 -189
- package/src/auth/index.ts +0 -10
- package/src/auth/middlewares/index.ts +0 -1
- package/src/auth/middlewares/proxy.ts +0 -32
- package/src/auth/server.ts +0 -6
- package/src/auth/utils/errors.ts +0 -34
- package/src/auth/utils/index.ts +0 -2
- package/src/auth/utils/validation.ts +0 -14
- package/src/contexts/LeadsContext.tsx +0 -156
- package/src/contexts/NewsletterContext.tsx +0 -263
- package/src/contexts/SupportContext.tsx +0 -256
- package/src/contexts/index.ts +0 -59
- package/src/contexts/knowbase/ChatContext.tsx +0 -174
- package/src/contexts/knowbase/DocumentsContext.tsx +0 -304
- package/src/contexts/knowbase/SessionsContext.tsx +0 -174
- package/src/contexts/knowbase/index.ts +0 -61
- package/src/contexts/payments/BalancesContext.tsx +0 -65
- package/src/contexts/payments/CurrenciesContext.tsx +0 -66
- package/src/contexts/payments/OverviewContext.tsx +0 -174
- package/src/contexts/payments/PaymentsContext.tsx +0 -132
- package/src/contexts/payments/README.md +0 -201
- package/src/contexts/payments/RootPaymentsContext.tsx +0 -68
- package/src/contexts/payments/index.ts +0 -50
- package/src/layouts/PaymentsLayout/PaymentsLayout.tsx +0 -92
- package/src/layouts/PaymentsLayout/components/CreatePaymentDialog.tsx +0 -291
- package/src/layouts/PaymentsLayout/components/PaymentDetailsDialog.tsx +0 -290
- package/src/layouts/PaymentsLayout/components/index.ts +0 -2
- package/src/layouts/PaymentsLayout/events.ts +0 -47
- package/src/layouts/PaymentsLayout/index.ts +0 -16
- package/src/layouts/PaymentsLayout/types.ts +0 -6
- package/src/layouts/PaymentsLayout/views/overview/components/BalanceCard.tsx +0 -128
- package/src/layouts/PaymentsLayout/views/overview/components/RecentPayments.tsx +0 -142
- package/src/layouts/PaymentsLayout/views/overview/components/index.ts +0 -2
- package/src/layouts/PaymentsLayout/views/overview/index.tsx +0 -20
- package/src/layouts/PaymentsLayout/views/payments/components/PaymentsList.tsx +0 -276
- package/src/layouts/PaymentsLayout/views/payments/components/index.ts +0 -1
- package/src/layouts/PaymentsLayout/views/payments/index.tsx +0 -17
- package/src/layouts/PaymentsLayout/views/transactions/components/TransactionsList.tsx +0 -273
- package/src/layouts/PaymentsLayout/views/transactions/components/index.ts +0 -1
- package/src/layouts/PaymentsLayout/views/transactions/index.tsx +0 -17
- package/src/layouts/SupportLayout/README.md +0 -91
- package/src/layouts/SupportLayout/SupportLayout.tsx +0 -179
- package/src/layouts/SupportLayout/components/CreateTicketDialog.tsx +0 -155
- package/src/layouts/SupportLayout/components/MessageInput.tsx +0 -92
- package/src/layouts/SupportLayout/components/MessageList.tsx +0 -314
- package/src/layouts/SupportLayout/components/TicketCard.tsx +0 -96
- package/src/layouts/SupportLayout/components/TicketList.tsx +0 -153
- package/src/layouts/SupportLayout/components/index.ts +0 -6
- package/src/layouts/SupportLayout/context/SupportLayoutContext.tsx +0 -263
- package/src/layouts/SupportLayout/context/index.ts +0 -2
- package/src/layouts/SupportLayout/events.ts +0 -33
- package/src/layouts/SupportLayout/hooks/index.ts +0 -2
- package/src/layouts/SupportLayout/hooks/useInfiniteMessages.ts +0 -119
- package/src/layouts/SupportLayout/hooks/useInfiniteTickets.ts +0 -92
- package/src/layouts/SupportLayout/index.ts +0 -8
- package/src/layouts/SupportLayout/types.ts +0 -21
- package/src/snippets/Chat/ChatUIContext.tsx +0 -110
- package/src/snippets/Chat/ChatWidget.tsx +0 -476
- package/src/snippets/Chat/README.md +0 -122
- package/src/snippets/Chat/components/MessageInput.tsx +0 -124
- package/src/snippets/Chat/components/MessageList.tsx +0 -169
- package/src/snippets/Chat/components/SessionList.tsx +0 -192
- package/src/snippets/Chat/components/index.ts +0 -9
- package/src/snippets/Chat/hooks/index.ts +0 -6
- package/src/snippets/Chat/hooks/useInfiniteSessions.ts +0 -82
- package/src/snippets/Chat/index.tsx +0 -45
- package/src/snippets/Chat/types.ts +0 -80
- package/src/snippets/ContactForm/ContactForm.tsx +0 -346
- package/src/snippets/ContactForm/ContactFormProvider.tsx +0 -153
- package/src/snippets/ContactForm/ContactInfo.tsx +0 -114
- package/src/snippets/ContactForm/ContactPage.tsx +0 -131
- package/src/snippets/ContactForm/dynamic.tsx +0 -55
- package/src/snippets/ContactForm/index.ts +0 -34
- package/src/snippets/ContactForm/types.ts +0 -110
package/src/contexts/index.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CFG API Contexts
|
|
3
|
-
*
|
|
4
|
-
* Centralized React contexts for all CFG API modules
|
|
5
|
-
* Uses generated SWR hooks for optimal data fetching and caching
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
'use client';
|
|
9
|
-
|
|
10
|
-
// Newsletter (Campaigns & Subscriptions)
|
|
11
|
-
export { NewsletterProvider, useNewsletterContext } from './NewsletterContext';
|
|
12
|
-
export type {
|
|
13
|
-
NewsletterContextValue,
|
|
14
|
-
NewsletterCampaign,
|
|
15
|
-
NewsletterCampaignRequest,
|
|
16
|
-
PatchedNewsletterCampaignRequest,
|
|
17
|
-
NewsletterSubscription,
|
|
18
|
-
PaginatedNewsletterCampaignList,
|
|
19
|
-
PaginatedNewsletterSubscriptionList,
|
|
20
|
-
SubscribeRequest,
|
|
21
|
-
SubscribeResponse,
|
|
22
|
-
UnsubscribeRequest,
|
|
23
|
-
SuccessResponse,
|
|
24
|
-
SendCampaignRequest,
|
|
25
|
-
SendCampaignResponse,
|
|
26
|
-
} from './NewsletterContext';
|
|
27
|
-
|
|
28
|
-
// Leads (Lead Submissions)
|
|
29
|
-
export { LeadsProvider, useLeadsContext } from './LeadsContext';
|
|
30
|
-
export type {
|
|
31
|
-
LeadsContextValue,
|
|
32
|
-
LeadSubmission,
|
|
33
|
-
LeadSubmissionRequest,
|
|
34
|
-
PatchedLeadSubmissionRequest,
|
|
35
|
-
PaginatedLeadSubmissionList,
|
|
36
|
-
} from './LeadsContext';
|
|
37
|
-
|
|
38
|
-
// Support (Tickets & Messages)
|
|
39
|
-
export {
|
|
40
|
-
SupportProvider,
|
|
41
|
-
useSupportContext
|
|
42
|
-
} from './SupportContext';
|
|
43
|
-
export type {
|
|
44
|
-
SupportContextValue,
|
|
45
|
-
Ticket,
|
|
46
|
-
TicketRequest,
|
|
47
|
-
PatchedTicketRequest,
|
|
48
|
-
Message,
|
|
49
|
-
MessageRequest,
|
|
50
|
-
MessageCreateRequest,
|
|
51
|
-
PatchedMessageRequest,
|
|
52
|
-
} from './SupportContext';
|
|
53
|
-
|
|
54
|
-
// Payments (Payments, Balances, Currencies, API Keys, Overview)
|
|
55
|
-
export * from './payments';
|
|
56
|
-
|
|
57
|
-
// Knowbase (Chat, Documents, Sessions)
|
|
58
|
-
export * from './knowbase';
|
|
59
|
-
|
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Knowbase Chat Context
|
|
3
|
-
* Context for RAG-powered chat functionality
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
'use client';
|
|
7
|
-
|
|
8
|
-
import React, { createContext, useContext, type ReactNode } from 'react';
|
|
9
|
-
import { api } from '@djangocfg/api';
|
|
10
|
-
import {
|
|
11
|
-
useKnowbaseAdminChatList,
|
|
12
|
-
useKnowbaseAdminChatRetrieve,
|
|
13
|
-
useCreateKnowbaseAdminChatCreate,
|
|
14
|
-
useUpdateKnowbaseAdminChatUpdate,
|
|
15
|
-
usePartialUpdateKnowbaseAdminChatPartialUpdate,
|
|
16
|
-
useDeleteKnowbaseAdminChatDestroy,
|
|
17
|
-
useKnowbaseAdminChatHistoryRetrieve,
|
|
18
|
-
useCreateKnowbaseAdminChatQueryCreate,
|
|
19
|
-
} from '@djangocfg/api';
|
|
20
|
-
import type { API } from '@djangocfg/api';
|
|
21
|
-
import type {
|
|
22
|
-
PaginatedChatResponseList,
|
|
23
|
-
ChatResponse,
|
|
24
|
-
ChatResponseRequest,
|
|
25
|
-
PatchedChatResponseRequest,
|
|
26
|
-
ChatHistory,
|
|
27
|
-
ChatQueryRequest,
|
|
28
|
-
} from '@djangocfg/api';
|
|
29
|
-
|
|
30
|
-
// ─────────────────────────────────────────────────────────────────────────
|
|
31
|
-
// Context Type
|
|
32
|
-
// ─────────────────────────────────────────────────────────────────────────
|
|
33
|
-
|
|
34
|
-
export interface KnowbaseChatContextValue {
|
|
35
|
-
// Chat list
|
|
36
|
-
chats: PaginatedChatResponseList | undefined;
|
|
37
|
-
isLoadingChats: boolean;
|
|
38
|
-
chatsError: Error | undefined;
|
|
39
|
-
refreshChats: () => Promise<void>;
|
|
40
|
-
|
|
41
|
-
// Chat operations
|
|
42
|
-
getChat: (id: string) => Promise<ChatResponse | undefined>;
|
|
43
|
-
getChatHistory: (id: string) => Promise<ChatHistory | undefined>;
|
|
44
|
-
createChat: (data: ChatResponseRequest) => Promise<ChatResponse>;
|
|
45
|
-
updateChat: (id: string, data: ChatResponseRequest) => Promise<ChatResponse>;
|
|
46
|
-
partialUpdateChat: (id: string, data: PatchedChatResponseRequest) => Promise<ChatResponse>;
|
|
47
|
-
deleteChat: (id: string) => Promise<void>;
|
|
48
|
-
|
|
49
|
-
// RAG Query
|
|
50
|
-
sendQuery: (data: ChatQueryRequest) => Promise<ChatResponse>;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// ─────────────────────────────────────────────────────────────────────────
|
|
54
|
-
// Context
|
|
55
|
-
// ─────────────────────────────────────────────────────────────────────────
|
|
56
|
-
|
|
57
|
-
const KnowbaseChatContext = createContext<KnowbaseChatContextValue | undefined>(undefined);
|
|
58
|
-
|
|
59
|
-
// ─────────────────────────────────────────────────────────────────────────
|
|
60
|
-
// Provider
|
|
61
|
-
// ─────────────────────────────────────────────────────────────────────────
|
|
62
|
-
|
|
63
|
-
export function KnowbaseChatProvider({ children }: { children: ReactNode }) {
|
|
64
|
-
// List chats
|
|
65
|
-
const {
|
|
66
|
-
data: chats,
|
|
67
|
-
error: chatsError,
|
|
68
|
-
isLoading: isLoadingChats,
|
|
69
|
-
mutate: mutateChats,
|
|
70
|
-
} = useKnowbaseAdminChatList({}, api as unknown as API);
|
|
71
|
-
|
|
72
|
-
const refreshChats = async () => {
|
|
73
|
-
await mutateChats();
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
// Mutations
|
|
77
|
-
const createChatMutation = useCreateKnowbaseAdminChatCreate();
|
|
78
|
-
const updateChatMutation = useUpdateKnowbaseAdminChatUpdate();
|
|
79
|
-
const partialUpdateChatMutation = usePartialUpdateKnowbaseAdminChatPartialUpdate();
|
|
80
|
-
const deleteChatMutation = useDeleteKnowbaseAdminChatDestroy();
|
|
81
|
-
const sendQueryMutation = useCreateKnowbaseAdminChatQueryCreate();
|
|
82
|
-
|
|
83
|
-
// Get single chat
|
|
84
|
-
const getChat = async (id: string): Promise<ChatResponse | undefined> => {
|
|
85
|
-
const { data } = useKnowbaseAdminChatRetrieve(id, api as unknown as API);
|
|
86
|
-
return data;
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
// Get chat history
|
|
90
|
-
const getChatHistory = async (id: string): Promise<ChatHistory | undefined> => {
|
|
91
|
-
const { data } = useKnowbaseAdminChatHistoryRetrieve(id, api as unknown as API);
|
|
92
|
-
return data;
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
// Create chat
|
|
96
|
-
const createChat = async (data: ChatResponseRequest): Promise<ChatResponse> => {
|
|
97
|
-
const result = await createChatMutation(data, api as unknown as API);
|
|
98
|
-
await refreshChats();
|
|
99
|
-
return result as ChatResponse;
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
// Update chat
|
|
103
|
-
const updateChat = async (id: string, data: ChatResponseRequest): Promise<ChatResponse> => {
|
|
104
|
-
const result = await updateChatMutation(id, data, api as unknown as API);
|
|
105
|
-
await refreshChats();
|
|
106
|
-
return result as ChatResponse;
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
// Partial update chat
|
|
110
|
-
const partialUpdateChat = async (
|
|
111
|
-
id: string,
|
|
112
|
-
data: PatchedChatResponseRequest
|
|
113
|
-
): Promise<ChatResponse> => {
|
|
114
|
-
const result = await partialUpdateChatMutation(id, data, api as unknown as API);
|
|
115
|
-
await refreshChats();
|
|
116
|
-
return result as ChatResponse;
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
// Delete chat
|
|
120
|
-
const deleteChat = async (id: string): Promise<void> => {
|
|
121
|
-
await deleteChatMutation(id, api as unknown as API);
|
|
122
|
-
await refreshChats();
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
// Send RAG query
|
|
126
|
-
const sendQuery = async (data: ChatQueryRequest): Promise<ChatResponse> => {
|
|
127
|
-
const result = await sendQueryMutation(data, api as unknown as API);
|
|
128
|
-
await refreshChats();
|
|
129
|
-
return result as ChatResponse;
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
const value: KnowbaseChatContextValue = {
|
|
133
|
-
chats,
|
|
134
|
-
isLoadingChats,
|
|
135
|
-
chatsError,
|
|
136
|
-
refreshChats,
|
|
137
|
-
getChat,
|
|
138
|
-
getChatHistory,
|
|
139
|
-
createChat,
|
|
140
|
-
updateChat,
|
|
141
|
-
partialUpdateChat,
|
|
142
|
-
deleteChat,
|
|
143
|
-
sendQuery,
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
return <KnowbaseChatContext.Provider value={value}>{children}</KnowbaseChatContext.Provider>;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
// ─────────────────────────────────────────────────────────────────────────
|
|
150
|
-
// Hook
|
|
151
|
-
// ─────────────────────────────────────────────────────────────────────────
|
|
152
|
-
|
|
153
|
-
export function useKnowbaseChatContext(): KnowbaseChatContextValue {
|
|
154
|
-
const context = useContext(KnowbaseChatContext);
|
|
155
|
-
if (!context) {
|
|
156
|
-
throw new Error('useKnowbaseChatContext must be used within KnowbaseChatProvider');
|
|
157
|
-
}
|
|
158
|
-
return context;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
// ─────────────────────────────────────────────────────────────────────────
|
|
162
|
-
// Re-export types for external use
|
|
163
|
-
// ─────────────────────────────────────────────────────────────────────────
|
|
164
|
-
|
|
165
|
-
export type {
|
|
166
|
-
ChatResponse,
|
|
167
|
-
ChatResponseRequest,
|
|
168
|
-
PatchedChatResponseRequest,
|
|
169
|
-
ChatHistory,
|
|
170
|
-
ChatQueryRequest,
|
|
171
|
-
ChatMessage,
|
|
172
|
-
ChatSource,
|
|
173
|
-
} from '@djangocfg/api';
|
|
174
|
-
|
|
@@ -1,304 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Knowbase Documents Context
|
|
3
|
-
* Context for managing documents and archives
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
'use client';
|
|
7
|
-
|
|
8
|
-
import React, { createContext, useContext, type ReactNode } from 'react';
|
|
9
|
-
import { api } from '@djangocfg/api';
|
|
10
|
-
import {
|
|
11
|
-
useKnowbaseAdminDocumentsList,
|
|
12
|
-
useKnowbaseAdminDocumentsRetrieve,
|
|
13
|
-
useCreateKnowbaseAdminDocumentsCreate,
|
|
14
|
-
useUpdateKnowbaseAdminDocumentsUpdate,
|
|
15
|
-
usePartialUpdateKnowbaseAdminDocumentsPartialUpdate,
|
|
16
|
-
useDeleteKnowbaseAdminDocumentsDestroy,
|
|
17
|
-
useCreateKnowbaseAdminDocumentsReprocessCreate,
|
|
18
|
-
useKnowbaseAdminDocumentsStatusRetrieve,
|
|
19
|
-
useKnowbaseAdminDocumentsStatsRetrieve,
|
|
20
|
-
useKnowbaseSystemArchivesList,
|
|
21
|
-
useKnowbaseSystemArchivesRetrieve,
|
|
22
|
-
useCreateKnowbaseSystemArchivesCreate,
|
|
23
|
-
useUpdateKnowbaseSystemArchivesUpdate,
|
|
24
|
-
usePartialUpdateKnowbaseSystemArchivesPartialUpdate,
|
|
25
|
-
useDeleteKnowbaseSystemArchivesDestroy,
|
|
26
|
-
useKnowbaseSystemArchivesStatisticsRetrieve,
|
|
27
|
-
} from '@djangocfg/api';
|
|
28
|
-
import type { API } from '@djangocfg/api';
|
|
29
|
-
import type {
|
|
30
|
-
PaginatedDocumentList,
|
|
31
|
-
Document,
|
|
32
|
-
DocumentCreateRequest,
|
|
33
|
-
DocumentRequest,
|
|
34
|
-
PatchedDocumentRequest,
|
|
35
|
-
DocumentProcessingStatus,
|
|
36
|
-
DocumentStats,
|
|
37
|
-
PaginatedDocumentArchiveListList,
|
|
38
|
-
DocumentArchive,
|
|
39
|
-
DocumentArchiveDetail,
|
|
40
|
-
PatchedDocumentArchiveRequest,
|
|
41
|
-
ArchiveProcessingResult,
|
|
42
|
-
ArchiveStatistics,
|
|
43
|
-
} from '@djangocfg/api';
|
|
44
|
-
|
|
45
|
-
// ─────────────────────────────────────────────────────────────────────────
|
|
46
|
-
// Context Type
|
|
47
|
-
// ─────────────────────────────────────────────────────────────────────────
|
|
48
|
-
|
|
49
|
-
export interface KnowbaseDocumentsContextValue {
|
|
50
|
-
// Documents list
|
|
51
|
-
documents: PaginatedDocumentList | undefined;
|
|
52
|
-
isLoadingDocuments: boolean;
|
|
53
|
-
documentsError: Error | undefined;
|
|
54
|
-
refreshDocuments: () => Promise<void>;
|
|
55
|
-
|
|
56
|
-
// Document operations
|
|
57
|
-
getDocument: (id: string) => Promise<Document | undefined>;
|
|
58
|
-
getDocumentStatus: (id: string) => Promise<DocumentProcessingStatus | undefined>;
|
|
59
|
-
getDocumentStats: () => Promise<DocumentStats | undefined>;
|
|
60
|
-
createDocument: (data: DocumentCreateRequest) => Promise<Document>;
|
|
61
|
-
updateDocument: (id: string, data: DocumentRequest) => Promise<Document>;
|
|
62
|
-
partialUpdateDocument: (id: string, data: PatchedDocumentRequest) => Promise<Document>;
|
|
63
|
-
deleteDocument: (id: string) => Promise<void>;
|
|
64
|
-
reprocessDocument: (id: string, data: DocumentRequest) => Promise<Document>;
|
|
65
|
-
|
|
66
|
-
// Archives list
|
|
67
|
-
archives: PaginatedDocumentArchiveListList | undefined;
|
|
68
|
-
isLoadingArchives: boolean;
|
|
69
|
-
archivesError: Error | undefined;
|
|
70
|
-
refreshArchives: () => Promise<void>;
|
|
71
|
-
|
|
72
|
-
// Archive operations
|
|
73
|
-
getArchive: (id: string) => Promise<DocumentArchiveDetail | undefined>;
|
|
74
|
-
getArchiveStatistics: () => Promise<ArchiveStatistics | undefined>;
|
|
75
|
-
createArchive: (data: FormData) => Promise<ArchiveProcessingResult>;
|
|
76
|
-
updateArchive: (
|
|
77
|
-
id: string,
|
|
78
|
-
title: string,
|
|
79
|
-
archive_file: File | Blob,
|
|
80
|
-
description?: string,
|
|
81
|
-
is_public?: boolean
|
|
82
|
-
) => Promise<DocumentArchive>;
|
|
83
|
-
partialUpdateArchive: (id: string, data: PatchedDocumentArchiveRequest) => Promise<DocumentArchive>;
|
|
84
|
-
deleteArchive: (id: string) => Promise<void>;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// ─────────────────────────────────────────────────────────────────────────
|
|
88
|
-
// Context
|
|
89
|
-
// ─────────────────────────────────────────────────────────────────────────
|
|
90
|
-
|
|
91
|
-
const KnowbaseDocumentsContext = createContext<KnowbaseDocumentsContextValue | undefined>(
|
|
92
|
-
undefined
|
|
93
|
-
);
|
|
94
|
-
|
|
95
|
-
// ─────────────────────────────────────────────────────────────────────────
|
|
96
|
-
// Provider
|
|
97
|
-
// ─────────────────────────────────────────────────────────────────────────
|
|
98
|
-
|
|
99
|
-
export function KnowbaseDocumentsProvider({ children }: { children: ReactNode }) {
|
|
100
|
-
// Documents list (first page only for count)
|
|
101
|
-
const {
|
|
102
|
-
data: documents,
|
|
103
|
-
error: documentsError,
|
|
104
|
-
isLoading: isLoadingDocuments,
|
|
105
|
-
mutate: mutateDocuments,
|
|
106
|
-
} = useKnowbaseAdminDocumentsList({ page: 1, page_size: 1 }, api as unknown as API);
|
|
107
|
-
|
|
108
|
-
const refreshDocuments = async () => {
|
|
109
|
-
await mutateDocuments();
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
// Archives list (first page only for count)
|
|
113
|
-
const {
|
|
114
|
-
data: archives,
|
|
115
|
-
error: archivesError,
|
|
116
|
-
isLoading: isLoadingArchives,
|
|
117
|
-
mutate: mutateArchives,
|
|
118
|
-
} = useKnowbaseSystemArchivesList({ page: 1, page_size: 1 }, api as unknown as API);
|
|
119
|
-
|
|
120
|
-
const refreshArchives = async () => {
|
|
121
|
-
await mutateArchives();
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
// Document mutations
|
|
125
|
-
const createDocumentMutation = useCreateKnowbaseAdminDocumentsCreate();
|
|
126
|
-
const updateDocumentMutation = useUpdateKnowbaseAdminDocumentsUpdate();
|
|
127
|
-
const partialUpdateDocumentMutation = usePartialUpdateKnowbaseAdminDocumentsPartialUpdate();
|
|
128
|
-
const deleteDocumentMutation = useDeleteKnowbaseAdminDocumentsDestroy();
|
|
129
|
-
const reprocessDocumentMutation = useCreateKnowbaseAdminDocumentsReprocessCreate();
|
|
130
|
-
|
|
131
|
-
// Archive mutations
|
|
132
|
-
const createArchiveMutation = useCreateKnowbaseSystemArchivesCreate();
|
|
133
|
-
const updateArchiveMutation = useUpdateKnowbaseSystemArchivesUpdate();
|
|
134
|
-
const partialUpdateArchiveMutation = usePartialUpdateKnowbaseSystemArchivesPartialUpdate();
|
|
135
|
-
const deleteArchiveMutation = useDeleteKnowbaseSystemArchivesDestroy();
|
|
136
|
-
|
|
137
|
-
// Get single document
|
|
138
|
-
const getDocument = async (id: string): Promise<Document | undefined> => {
|
|
139
|
-
const { data } = useKnowbaseAdminDocumentsRetrieve(id, api as unknown as API);
|
|
140
|
-
return data;
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
// Get document status
|
|
144
|
-
const getDocumentStatus = async (id: string): Promise<DocumentProcessingStatus | undefined> => {
|
|
145
|
-
const { data } = useKnowbaseAdminDocumentsStatusRetrieve(id, api as unknown as API);
|
|
146
|
-
return data;
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
// Get document stats
|
|
150
|
-
const getDocumentStats = async (): Promise<DocumentStats | undefined> => {
|
|
151
|
-
const { data } = useKnowbaseAdminDocumentsStatsRetrieve(api as unknown as API);
|
|
152
|
-
return data;
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
// Create document
|
|
156
|
-
const createDocument = async (data: DocumentCreateRequest): Promise<Document> => {
|
|
157
|
-
const result = await createDocumentMutation(data, api as unknown as API);
|
|
158
|
-
await refreshDocuments();
|
|
159
|
-
return result as Document;
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
// Update document
|
|
163
|
-
const updateDocument = async (id: string, data: DocumentRequest): Promise<Document> => {
|
|
164
|
-
const result = await updateDocumentMutation(id, data, api as unknown as API);
|
|
165
|
-
await refreshDocuments();
|
|
166
|
-
return result as Document;
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
// Partial update document
|
|
170
|
-
const partialUpdateDocument = async (
|
|
171
|
-
id: string,
|
|
172
|
-
data: PatchedDocumentRequest
|
|
173
|
-
): Promise<Document> => {
|
|
174
|
-
const result = await partialUpdateDocumentMutation(id, data, api as unknown as API);
|
|
175
|
-
await refreshDocuments();
|
|
176
|
-
return result as Document;
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
// Delete document
|
|
180
|
-
const deleteDocument = async (id: string): Promise<void> => {
|
|
181
|
-
await deleteDocumentMutation(id, api as unknown as API);
|
|
182
|
-
await refreshDocuments();
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
// Reprocess document
|
|
186
|
-
const reprocessDocument = async (id: string, data: DocumentRequest): Promise<Document> => {
|
|
187
|
-
const result = await reprocessDocumentMutation(id, data, api as unknown as API);
|
|
188
|
-
await refreshDocuments();
|
|
189
|
-
return result as Document;
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
// Get single archive
|
|
193
|
-
const getArchive = async (id: string): Promise<DocumentArchiveDetail | undefined> => {
|
|
194
|
-
const { data } = useKnowbaseSystemArchivesRetrieve(id, api as unknown as API);
|
|
195
|
-
return data as DocumentArchiveDetail | undefined;
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
// Get archive statistics
|
|
199
|
-
const getArchiveStatistics = async (): Promise<ArchiveStatistics | undefined> => {
|
|
200
|
-
const { data } = useKnowbaseSystemArchivesStatisticsRetrieve(api as unknown as API);
|
|
201
|
-
return data;
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
// Create archive
|
|
205
|
-
const createArchive = async (data: FormData): Promise<ArchiveProcessingResult> => {
|
|
206
|
-
const result = await createArchiveMutation(data, api as unknown as API);
|
|
207
|
-
await refreshArchives();
|
|
208
|
-
return result as ArchiveProcessingResult;
|
|
209
|
-
};
|
|
210
|
-
|
|
211
|
-
// Update archive
|
|
212
|
-
const updateArchive = async (
|
|
213
|
-
id: string,
|
|
214
|
-
title: string,
|
|
215
|
-
archive_file: File | Blob,
|
|
216
|
-
description?: string,
|
|
217
|
-
is_public?: boolean
|
|
218
|
-
): Promise<DocumentArchive> => {
|
|
219
|
-
// Note: The hook expects DocumentArchiveRequest, but the client method has different signature
|
|
220
|
-
// This is a type mismatch in the generated code
|
|
221
|
-
const data = { title, archive_file, description, is_public } as any;
|
|
222
|
-
const result = await updateArchiveMutation(id, data, api as unknown as API);
|
|
223
|
-
await refreshArchives();
|
|
224
|
-
return result as DocumentArchive;
|
|
225
|
-
};
|
|
226
|
-
|
|
227
|
-
// Partial update archive
|
|
228
|
-
const partialUpdateArchive = async (
|
|
229
|
-
id: string,
|
|
230
|
-
data: PatchedDocumentArchiveRequest
|
|
231
|
-
): Promise<DocumentArchive> => {
|
|
232
|
-
const result = await partialUpdateArchiveMutation(id, data, api as unknown as API);
|
|
233
|
-
await refreshArchives();
|
|
234
|
-
return result as DocumentArchive;
|
|
235
|
-
};
|
|
236
|
-
|
|
237
|
-
// Delete archive
|
|
238
|
-
const deleteArchive = async (id: string): Promise<void> => {
|
|
239
|
-
await deleteArchiveMutation(id, api as unknown as API);
|
|
240
|
-
await refreshArchives();
|
|
241
|
-
};
|
|
242
|
-
|
|
243
|
-
const value: KnowbaseDocumentsContextValue = {
|
|
244
|
-
documents,
|
|
245
|
-
isLoadingDocuments,
|
|
246
|
-
documentsError,
|
|
247
|
-
refreshDocuments,
|
|
248
|
-
getDocument,
|
|
249
|
-
getDocumentStatus,
|
|
250
|
-
getDocumentStats,
|
|
251
|
-
createDocument,
|
|
252
|
-
updateDocument,
|
|
253
|
-
partialUpdateDocument,
|
|
254
|
-
deleteDocument,
|
|
255
|
-
reprocessDocument,
|
|
256
|
-
archives: archives as PaginatedDocumentArchiveListList | undefined,
|
|
257
|
-
isLoadingArchives,
|
|
258
|
-
archivesError,
|
|
259
|
-
refreshArchives,
|
|
260
|
-
getArchive,
|
|
261
|
-
getArchiveStatistics,
|
|
262
|
-
createArchive,
|
|
263
|
-
updateArchive,
|
|
264
|
-
partialUpdateArchive,
|
|
265
|
-
deleteArchive,
|
|
266
|
-
};
|
|
267
|
-
|
|
268
|
-
return (
|
|
269
|
-
<KnowbaseDocumentsContext.Provider value={value}>
|
|
270
|
-
{children}
|
|
271
|
-
</KnowbaseDocumentsContext.Provider>
|
|
272
|
-
);
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
// ─────────────────────────────────────────────────────────────────────────
|
|
276
|
-
// Hook
|
|
277
|
-
// ─────────────────────────────────────────────────────────────────────────
|
|
278
|
-
|
|
279
|
-
export function useKnowbaseDocumentsContext(): KnowbaseDocumentsContextValue {
|
|
280
|
-
const context = useContext(KnowbaseDocumentsContext);
|
|
281
|
-
if (!context) {
|
|
282
|
-
throw new Error('useKnowbaseDocumentsContext must be used within KnowbaseDocumentsProvider');
|
|
283
|
-
}
|
|
284
|
-
return context;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
// ─────────────────────────────────────────────────────────────────────────
|
|
288
|
-
// Re-export types for external use
|
|
289
|
-
// ─────────────────────────────────────────────────────────────────────────
|
|
290
|
-
|
|
291
|
-
export type {
|
|
292
|
-
Document,
|
|
293
|
-
DocumentCreateRequest,
|
|
294
|
-
DocumentRequest,
|
|
295
|
-
PatchedDocumentRequest,
|
|
296
|
-
DocumentProcessingStatus,
|
|
297
|
-
DocumentStats,
|
|
298
|
-
DocumentArchive,
|
|
299
|
-
DocumentArchiveDetail,
|
|
300
|
-
PatchedDocumentArchiveRequest,
|
|
301
|
-
ArchiveProcessingResult,
|
|
302
|
-
ArchiveStatistics,
|
|
303
|
-
} from '@djangocfg/api';
|
|
304
|
-
|