@flashbacktech/flashbackclient 0.2.55 → 0.2.57
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/api/client.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ import { DeleteSettingsRequest, GetSettingsResponse, PartialUpdateSettingsReques
|
|
|
14
14
|
import { UpdateUserRoleResponse, UserRoleResponse } from './types/platform/roles';
|
|
15
15
|
import { UserProfileResponse } from './types/platform/roles';
|
|
16
16
|
import { CreateOrgUserRequest, CreateOrgUserResponse, DeleteOrgUserResponse, GetOrganizationResponse, ListOrgUsersResponse, OrgUserResponse, UpdateOrganizationBody, UpdateOrganizationResponse, UpdateOrgUserRequest, UpdateOrgUserResponse } from './types/platform/organization';
|
|
17
|
-
import { SystemEventQueryRequest, SystemEventQueryResponse } from './types/platform/systemevent';
|
|
17
|
+
import { SystemEventQueryRequest, SystemEventQueryResponse, SystemEventReadStatusResponse } from './types/platform/systemevent';
|
|
18
18
|
import { PreVerifyEmailResponse, UserUpdateRequest, UserUpdateResponse } from './types/platform/user';
|
|
19
19
|
import { CreateRepoAiApiKeyRequest, CreateRepoAiApiKeyResponse, DeleteRepoAiApiKeyResponse, GetRepoAiApiKeysResponse, UpdateRepoAiApiKeyRequest, UpdateRepoAiApiKeyResponse } from './types/ai/aiapikey';
|
|
20
20
|
import { AiLlmStatsResponse, CreateAiLlmRequest, CreateAiLlmResponse, DeleteAiLlmResponse, GetAiLlmsResponse, UpdateAiLlmRequest, UpdateAiLlmResponse, ValidateAiLlmResponse, GetAiModelsRequest, GetAiModelsResponse } from './types/ai/aillm';
|
|
@@ -235,6 +235,8 @@ export declare class ApiClient implements IApiClient {
|
|
|
235
235
|
nodeRegister: (data: RegisterRequest) => Promise<RegisterResponse>;
|
|
236
236
|
nodeUnregister: (data: RegisterRequest) => Promise<RegisterResponse>;
|
|
237
237
|
getSystemEvents: (data: SystemEventQueryRequest) => Promise<SystemEventQueryResponse>;
|
|
238
|
+
markSystemEventAsRead: (systemEventLogId: number) => Promise<SystemEventReadStatusResponse>;
|
|
239
|
+
markSystemEventAsUnread: (systemEventLogId: number) => Promise<SystemEventReadStatusResponse>;
|
|
238
240
|
createAiLlm: (data: CreateAiLlmRequest) => Promise<CreateAiLlmResponse>;
|
|
239
241
|
getAiLlms: (workspaceId?: string) => Promise<GetAiLlmsResponse>;
|
|
240
242
|
getAiLlmStats: (aiLlmId?: string) => Promise<AiLlmStatsResponse>;
|
package/dist/api/client.js
CHANGED
|
@@ -79,18 +79,39 @@ class ApiClient {
|
|
|
79
79
|
};
|
|
80
80
|
this.makeRequest = async (path, method, data) => {
|
|
81
81
|
const isFormData = data instanceof FormData;
|
|
82
|
+
const isGetOrHead = method === 'GET' || method === 'HEAD';
|
|
83
|
+
// GET/HEAD cannot have a body: serialize plain objects as query string
|
|
84
|
+
let requestPath = path.startsWith('/') ? path.substring(1) : path;
|
|
85
|
+
let body = null;
|
|
86
|
+
if (data != null) {
|
|
87
|
+
if (isGetOrHead && !isFormData && typeof data === 'object' && data.constructor === Object) {
|
|
88
|
+
const params = new URLSearchParams();
|
|
89
|
+
for (const [k, v] of Object.entries(data)) {
|
|
90
|
+
if (v !== undefined && v !== null) {
|
|
91
|
+
params.set(k, String(v));
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
const qs = params.toString();
|
|
95
|
+
if (qs) {
|
|
96
|
+
requestPath += (requestPath.includes('?') ? '&' : '?') + qs;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
else if (!isGetOrHead) {
|
|
100
|
+
body = isFormData ? data : JSON.stringify(data);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
82
103
|
const options = {
|
|
83
104
|
method,
|
|
84
105
|
headers: this.headers,
|
|
85
|
-
body
|
|
106
|
+
body,
|
|
86
107
|
};
|
|
87
|
-
if (
|
|
108
|
+
if (body && !isFormData) {
|
|
88
109
|
options.headers = {
|
|
89
110
|
...options.headers,
|
|
90
111
|
'Content-Type': 'application/json',
|
|
91
112
|
};
|
|
92
113
|
}
|
|
93
|
-
const cleanPath =
|
|
114
|
+
const cleanPath = requestPath;
|
|
94
115
|
if (this.debug) {
|
|
95
116
|
console.log(`DEBUG: ${method} ${cleanPath} ${JSON.stringify(data)}`);
|
|
96
117
|
console.log(`DEBUG: ${JSON.stringify(this.headers)}`);
|
|
@@ -560,6 +581,12 @@ class ApiClient {
|
|
|
560
581
|
this.getSystemEvents = async (data) => {
|
|
561
582
|
return this.makeRequest('systemevent', 'POST', data);
|
|
562
583
|
};
|
|
584
|
+
this.markSystemEventAsRead = async (systemEventLogId) => {
|
|
585
|
+
return this.makeRequest(`systemevent/${systemEventLogId}/read`, 'POST', null);
|
|
586
|
+
};
|
|
587
|
+
this.markSystemEventAsUnread = async (systemEventLogId) => {
|
|
588
|
+
return this.makeRequest(`systemevent/${systemEventLogId}/read`, 'DELETE', null);
|
|
589
|
+
};
|
|
563
590
|
////// AI LLM API calls
|
|
564
591
|
this.createAiLlm = async (data) => {
|
|
565
592
|
return this.makeRequest('ai/llm', 'POST', data);
|
|
@@ -831,7 +858,8 @@ class ApiClient {
|
|
|
831
858
|
return this.makeRequest('credits/balance', 'GET', null);
|
|
832
859
|
};
|
|
833
860
|
this.getCreditsTransactions = async (query) => {
|
|
834
|
-
|
|
861
|
+
const result = await this.makeRequest('credits/transactions', 'GET', query);
|
|
862
|
+
return result;
|
|
835
863
|
};
|
|
836
864
|
/** Consumption = transactions with direction 'out' (backend uses same endpoint) */
|
|
837
865
|
this.getCreditsConsumption = async (query) => {
|
|
@@ -848,7 +876,8 @@ class ApiClient {
|
|
|
848
876
|
};
|
|
849
877
|
/** Get aggregated monthly credit stats for histogram (consumption, purchases, grants, balance) */
|
|
850
878
|
this.getCreditsMonthlyStats = async (query) => {
|
|
851
|
-
|
|
879
|
+
const result = await this.makeRequest('credits/stats/monthly', 'GET', query ?? null);
|
|
880
|
+
return result;
|
|
852
881
|
};
|
|
853
882
|
this.baseURL = baseURL;
|
|
854
883
|
this.headers = {};
|
|
@@ -6,6 +6,8 @@ export interface SystemEventQueryRequest {
|
|
|
6
6
|
event?: number;
|
|
7
7
|
userId?: string;
|
|
8
8
|
workspaceId?: string;
|
|
9
|
+
/** When true, only return events the current user has not read. */
|
|
10
|
+
showUnread?: boolean;
|
|
9
11
|
skip: number;
|
|
10
12
|
take: number;
|
|
11
13
|
}
|
|
@@ -21,6 +23,8 @@ export interface SystemEventResponse {
|
|
|
21
23
|
userEmail: string;
|
|
22
24
|
workspaceId: string | null;
|
|
23
25
|
jsonData: string | null;
|
|
26
|
+
/** True when the current user has not read this event. */
|
|
27
|
+
showUnread: boolean;
|
|
24
28
|
}
|
|
25
29
|
export interface SystemEventQueryResponse {
|
|
26
30
|
events: SystemEventResponse[];
|
|
@@ -28,6 +32,10 @@ export interface SystemEventQueryResponse {
|
|
|
28
32
|
skip: number;
|
|
29
33
|
take: number;
|
|
30
34
|
}
|
|
35
|
+
/** Response for mark-as-read / mark-as-unread. */
|
|
36
|
+
export interface SystemEventReadStatusResponse {
|
|
37
|
+
success: boolean;
|
|
38
|
+
}
|
|
31
39
|
export declare class ContextTypeHelper {
|
|
32
40
|
static readonly contextTypes: readonly ["workspace", "bucket", "repo", "user", "org", "workspaceuser", "apikey", "usersettings", "orgsettings", "flashbacknode", "orgkey", "aillm", "aillmapikey", "conversation"];
|
|
33
41
|
/**
|