@djangocfg/ext-knowbase 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 +3 -1
- package/dist/config.js +3 -1
- package/dist/hooks.cjs +71 -16
- package/dist/hooks.d.cts +6 -5
- package/dist/hooks.d.ts +6 -5
- package/dist/hooks.js +70 -16
- package/dist/index.cjs +67 -13
- package/dist/index.d.cts +81 -25
- package/dist/index.d.ts +81 -25
- package/dist/index.js +68 -15
- package/package.json +7 -5
- package/src/api/generated/ext_knowbase/CLAUDE.md +2 -9
- package/src/api/generated/ext_knowbase/_utils/fetchers/ext_knowbase__knowbase.ts +2 -1
- package/src/api/generated/ext_knowbase/_utils/hooks/ext_knowbase__knowbase.ts +2 -1
- package/src/api/generated/ext_knowbase/_utils/schemas/ArchiveSearchResult.schema.ts +3 -3
- package/src/api/generated/ext_knowbase/_utils/schemas/CfgKnowbaseSystemArchivesCreateRequest.schema.ts +20 -0
- package/src/api/generated/ext_knowbase/_utils/schemas/DocumentArchive.schema.ts +1 -1
- package/src/api/generated/ext_knowbase/_utils/schemas/DocumentArchiveDetail.schema.ts +1 -1
- package/src/api/generated/ext_knowbase/_utils/schemas/index.ts +1 -0
- package/src/api/generated/ext_knowbase/api-instance.ts +61 -13
- package/src/api/generated/ext_knowbase/client.ts +23 -2
- package/src/api/generated/ext_knowbase/ext_knowbase__knowbase/client.ts +9 -2
- package/src/api/generated/ext_knowbase/ext_knowbase__knowbase/models.ts +13 -0
- package/src/api/generated/ext_knowbase/http.ts +8 -2
- package/src/api/generated/ext_knowbase/index.ts +3 -1
- package/src/api/index.ts +6 -1
- package/src/components/Chat/ChatWidget.tsx +2 -1
- package/src/contexts/knowbase/DocumentsContext.tsx +4 -2
- package/src/contexts/knowbase/types.ts +1 -0
|
@@ -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
|
* Knowbase Extension API
|
|
@@ -6,7 +6,12 @@ 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_knowbase';
|
|
9
|
+
import { configureAPI } from './generated/ext_knowbase/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 apiKnowbase = createExtensionAPI(API);
|
|
11
16
|
|
|
12
17
|
// Export types, fetchers, and hooks
|
|
@@ -11,8 +11,9 @@ import React, { useCallback, useEffect, useState } from 'react';
|
|
|
11
11
|
import { createPortal } from 'react-dom';
|
|
12
12
|
|
|
13
13
|
import {
|
|
14
|
-
Button, Card, CardContent, CardHeader,
|
|
14
|
+
Button, Card, CardContent, CardHeader,
|
|
15
15
|
} from '@djangocfg/ui-nextjs';
|
|
16
|
+
import { useIsMobile, useLocalStorage } from '@djangocfg/ui-core/hooks';
|
|
16
17
|
|
|
17
18
|
import { useKnowbaseChatContext, useKnowbaseSessionsContext } from '../../contexts/knowbase';
|
|
18
19
|
import { chatLogger } from '../../utils/logger';
|
|
@@ -31,6 +31,7 @@ import type {
|
|
|
31
31
|
PaginatedDocumentArchiveListList,
|
|
32
32
|
DocumentArchive,
|
|
33
33
|
DocumentArchiveDetail,
|
|
34
|
+
ArchiveCreateRequest,
|
|
34
35
|
PatchedDocumentArchiveRequest,
|
|
35
36
|
ArchiveProcessingResult,
|
|
36
37
|
ArchiveStatistics,
|
|
@@ -66,7 +67,7 @@ export interface KnowbaseDocumentsContextValue {
|
|
|
66
67
|
// Archive operations
|
|
67
68
|
getArchive: (id: string) => Promise<DocumentArchiveDetail | undefined>;
|
|
68
69
|
getArchiveStatistics: () => Promise<ArchiveStatistics | undefined>;
|
|
69
|
-
createArchive: (data:
|
|
70
|
+
createArchive: (data: ArchiveCreateRequest) => Promise<ArchiveProcessingResult>;
|
|
70
71
|
updateArchive: (
|
|
71
72
|
id: string,
|
|
72
73
|
title: string,
|
|
@@ -196,7 +197,7 @@ export function KnowbaseDocumentsProvider({ children }: { children: ReactNode })
|
|
|
196
197
|
};
|
|
197
198
|
|
|
198
199
|
// Create archive
|
|
199
|
-
const createArchive = async (data:
|
|
200
|
+
const createArchive = async (data: ArchiveCreateRequest): Promise<ArchiveProcessingResult> => {
|
|
200
201
|
const result = await createArchiveMutation(data, apiKnowbase);
|
|
201
202
|
await refreshArchives();
|
|
202
203
|
return result as unknown as ArchiveProcessingResult;
|
|
@@ -293,6 +294,7 @@ export type {
|
|
|
293
294
|
PaginatedDocumentArchiveListList,
|
|
294
295
|
DocumentArchive,
|
|
295
296
|
DocumentArchiveDetail,
|
|
297
|
+
ArchiveCreateRequest,
|
|
296
298
|
PatchedDocumentArchiveRequest,
|
|
297
299
|
ArchiveProcessingResult,
|
|
298
300
|
ArchiveStatistics,
|
|
@@ -54,6 +54,7 @@ export type DocumentStats = NonNullable<Awaited<ReturnType<typeof useKnowbaseAdm
|
|
|
54
54
|
export type PaginatedDocumentArchiveListList = NonNullable<Awaited<ReturnType<typeof useKnowbaseSystemArchivesList>>['data']>;
|
|
55
55
|
export type DocumentArchive = NonNullable<Awaited<ReturnType<typeof useKnowbaseSystemArchivesRetrieve>>['data']>;
|
|
56
56
|
export type DocumentArchiveDetail = NonNullable<Awaited<ReturnType<typeof useKnowbaseSystemArchivesRetrieve>>['data']>;
|
|
57
|
+
export type ArchiveCreateRequest = Parameters<ReturnType<typeof useCreateKnowbaseSystemArchivesCreate>>[0];
|
|
57
58
|
export type PatchedDocumentArchiveRequest = Parameters<ReturnType<typeof usePartialUpdateKnowbaseSystemArchivesPartialUpdate>>[1];
|
|
58
59
|
export type ArchiveProcessingResult = Awaited<ReturnType<ReturnType<typeof useCreateKnowbaseSystemArchivesCreate>>>;
|
|
59
60
|
export type ArchiveStatistics = NonNullable<Awaited<ReturnType<typeof useKnowbaseSystemArchivesStatisticsRetrieve>>['data']>;
|