@flashbacktech/flashbackclient 0.2.45 → 0.2.47
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 +6 -1
- package/dist/api/client.js +92 -0
- package/dist/api/index.d.ts +2 -1
- package/dist/api/index.js +3 -1
- package/dist/api/types/ai/policy.d.ts +30 -0
- package/dist/api/types/ai/stats.d.ts +32 -0
- package/dist/api/types/ai/stats.js +2 -0
- package/dist/api/types/platform/roles.d.ts +1 -0
- package/package.json +1 -1
package/dist/api/client.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { CreateRepoRequest, CreateRepoResponse, CreateRepoKeyRequest, CreateRepo
|
|
|
2
2
|
import { IApiClient, ProviderType } from './interfaces';
|
|
3
3
|
import { ActivateUserRequest, ActivateUserResponse, DeactivateResponse, DemoRequestBody, DemoRequestResponse, LoginBody, LoginResponse, LogoutResponse, OAuth2ResponseDTO, RefreshTokenErrorResponse, RefreshTokenResponse, RegisterBody, RegisterResponse, ResendVerificationEmailResponse, ResetPasswordBody, Web3RegisterBody } from './types/platform/auth';
|
|
4
4
|
import { StatsQueryParams, StatsResponse, NodeStatsMinuteResponse, NodeStatsDailyResponse, NodeStatsQueryParams, UnitStatsResponse, RepoStatsResponse, NodeStatsDailyQueryParams, BucketStatsResponse, StatsQueryWithBucketParams, NodeStatsQueryWithBucketParams, NodeStatsDailyQueryWithBucketParams } from './types/storage/stats';
|
|
5
|
+
import { AiStatsQueryParams, AiStatsResponse } from './types/ai/stats';
|
|
5
6
|
import { NodeInfoResponse, RegisterRequest } from './types/storage/bridge';
|
|
6
7
|
import { GetOrganizationKeysResponse } from './types/storage/noderegistration';
|
|
7
8
|
import { QuotaResponse } from './types/platform/quota';
|
|
@@ -17,7 +18,7 @@ import { SystemEventQueryRequest, SystemEventQueryResponse } from './types/platf
|
|
|
17
18
|
import { PreVerifyEmailResponse, UserUpdateRequest, UserUpdateResponse } from './types/platform/user';
|
|
18
19
|
import { CreateRepoAiApiKeyRequest, CreateRepoAiApiKeyResponse, DeleteRepoAiApiKeyResponse, GetRepoAiApiKeysResponse, UpdateRepoAiApiKeyRequest, UpdateRepoAiApiKeyResponse } from './types/ai/aiapikey';
|
|
19
20
|
import { AiLlmStatsResponse, CreateAiLlmRequest, CreateAiLlmResponse, DeleteAiLlmResponse, GetAiLlmsResponse, UpdateAiLlmRequest, UpdateAiLlmResponse, ValidateAiLlmResponse } from './types/ai/aillm';
|
|
20
|
-
import { CreatePolicyRequest, GetPoliciesQuery, GetPolicyViolationsQuery, GetPolicyViolationsResponse, PolicyDTO, UpdatePolicyRequest, PolicyValidationRequest, PolicyValidationResponse, PolicyRecommendationRequest, PolicyRecommendationResponse } from './types/ai/policy';
|
|
21
|
+
import { CreatePolicyRequest, GetPoliciesQuery, GetPolicyViolationsQuery, GetPolicyViolationsResponse, GetPolicyAlertsQuery, GetPolicyAlertsResponse, PolicyDTO, UpdatePolicyRequest, PolicyValidationRequest, PolicyValidationResponse, PolicyRecommendationRequest, PolicyRecommendationResponse } from './types/ai/policy';
|
|
21
22
|
import { CreateConversationRequest, CreateConversationResponse, SendPromptRequest, SendPromptResponse, GetConversationsRequest, GetConversationsResponse, GetConversationMessagesResponse, GetConversationMessagesRequest, DeleteConversationRequest, DeleteConversationResponse } from './types/ai/conversation';
|
|
22
23
|
import { GetLinksRequest, GetLinksResponse, CreateLinkRequest, CreateLinkResponse, UpdateLinkRequest, UpdateLinkResponse, DeleteLinkResponse, GetLinkByTokenResponse } from './types/platform/links';
|
|
23
24
|
interface ErrorResponse {
|
|
@@ -114,6 +115,8 @@ export declare class ApiClient implements IApiClient {
|
|
|
114
115
|
getDailyStats(params: StatsQueryWithBucketParams): Promise<StatsResponse>;
|
|
115
116
|
getMinuteStats(params: StatsQueryParams): Promise<StatsResponse>;
|
|
116
117
|
getMinuteStats(params: StatsQueryWithBucketParams): Promise<StatsResponse>;
|
|
118
|
+
getAiStatsDaily(params: AiStatsQueryParams): Promise<AiStatsResponse>;
|
|
119
|
+
getAiStatsMinute(params: AiStatsQueryParams): Promise<AiStatsResponse>;
|
|
117
120
|
getNodeStatsMinute(params: NodeStatsQueryParams): Promise<NodeStatsMinuteResponse>;
|
|
118
121
|
getNodeStatsMinute(params: NodeStatsQueryWithBucketParams): Promise<NodeStatsMinuteResponse>;
|
|
119
122
|
getNodeStatsDaily(params: NodeStatsDailyQueryParams): Promise<NodeStatsDailyResponse>;
|
|
@@ -266,6 +269,8 @@ export declare class ApiClient implements IApiClient {
|
|
|
266
269
|
deletePolicy: (policyId: string) => Promise<ActionResponse>;
|
|
267
270
|
getPolicyViolations: (query: GetPolicyViolationsQuery) => Promise<GetPolicyViolationsResponse>;
|
|
268
271
|
getPolicyViolationsByPolicyId: (policyId: string, query: Omit<GetPolicyViolationsQuery, "policyId">) => Promise<GetPolicyViolationsResponse>;
|
|
272
|
+
getPolicyAlerts: (query: GetPolicyAlertsQuery) => Promise<GetPolicyAlertsResponse>;
|
|
273
|
+
getPolicyAlertsByPolicyId: (policyId: string, query: Omit<GetPolicyAlertsQuery, "policyId">) => Promise<GetPolicyAlertsResponse>;
|
|
269
274
|
validatePolicies: (data: PolicyValidationRequest) => Promise<PolicyValidationResponse>;
|
|
270
275
|
recommendPolicies: (data: PolicyRecommendationRequest) => Promise<PolicyRecommendationResponse>;
|
|
271
276
|
}
|
package/dist/api/client.js
CHANGED
|
@@ -722,6 +722,53 @@ class ApiClient {
|
|
|
722
722
|
}
|
|
723
723
|
return this.makeRequest(`policy/${policyId}/violations${queryParams.toString() ? `?${queryParams.toString()}` : ''}`, 'GET', null);
|
|
724
724
|
};
|
|
725
|
+
this.getPolicyAlerts = async (query) => {
|
|
726
|
+
const queryParams = new URLSearchParams();
|
|
727
|
+
if (query.workspaceId) {
|
|
728
|
+
queryParams.append('workspaceId', query.workspaceId);
|
|
729
|
+
}
|
|
730
|
+
if (query.repoId) {
|
|
731
|
+
queryParams.append('repoId', query.repoId);
|
|
732
|
+
}
|
|
733
|
+
if (query.policyId) {
|
|
734
|
+
queryParams.append('policyId', query.policyId);
|
|
735
|
+
}
|
|
736
|
+
if (query.from) {
|
|
737
|
+
queryParams.append('from', query.from);
|
|
738
|
+
}
|
|
739
|
+
if (query.to) {
|
|
740
|
+
queryParams.append('to', query.to);
|
|
741
|
+
}
|
|
742
|
+
if (query.take !== undefined) {
|
|
743
|
+
queryParams.append('take', query.take.toString());
|
|
744
|
+
}
|
|
745
|
+
if (query.skip !== undefined) {
|
|
746
|
+
queryParams.append('skip', query.skip.toString());
|
|
747
|
+
}
|
|
748
|
+
return this.makeRequest(`policy/alerts?${queryParams.toString()}`, 'GET', null);
|
|
749
|
+
};
|
|
750
|
+
this.getPolicyAlertsByPolicyId = async (policyId, query) => {
|
|
751
|
+
const queryParams = new URLSearchParams();
|
|
752
|
+
if (query.workspaceId) {
|
|
753
|
+
queryParams.append('workspaceId', query.workspaceId);
|
|
754
|
+
}
|
|
755
|
+
if (query.repoId) {
|
|
756
|
+
queryParams.append('repoId', query.repoId);
|
|
757
|
+
}
|
|
758
|
+
if (query.from) {
|
|
759
|
+
queryParams.append('from', query.from);
|
|
760
|
+
}
|
|
761
|
+
if (query.to) {
|
|
762
|
+
queryParams.append('to', query.to);
|
|
763
|
+
}
|
|
764
|
+
if (query.take !== undefined) {
|
|
765
|
+
queryParams.append('take', query.take.toString());
|
|
766
|
+
}
|
|
767
|
+
if (query.skip !== undefined) {
|
|
768
|
+
queryParams.append('skip', query.skip.toString());
|
|
769
|
+
}
|
|
770
|
+
return this.makeRequest(`policy/${policyId}/alerts${queryParams.toString() ? `?${queryParams.toString()}` : ''}`, 'GET', null);
|
|
771
|
+
};
|
|
725
772
|
this.validatePolicies = async (data) => {
|
|
726
773
|
return this.makeRequest('policy/validate', 'POST', data);
|
|
727
774
|
};
|
|
@@ -798,6 +845,51 @@ class ApiClient {
|
|
|
798
845
|
}
|
|
799
846
|
return this.makeRequest(`stats/minute?${queryParams.toString()}`, 'GET', null);
|
|
800
847
|
}
|
|
848
|
+
// AI Stats methods
|
|
849
|
+
async getAiStatsDaily(params) {
|
|
850
|
+
this.validateDateRange(params.startDate, params.endDate);
|
|
851
|
+
const queryParams = new URLSearchParams();
|
|
852
|
+
if (params.startDate) {
|
|
853
|
+
queryParams.append('startDate', params.startDate.toISOString());
|
|
854
|
+
}
|
|
855
|
+
if (params.endDate) {
|
|
856
|
+
queryParams.append('endDate', params.endDate.toISOString());
|
|
857
|
+
}
|
|
858
|
+
if (params.repoId && params.repoId.length > 0)
|
|
859
|
+
queryParams.append('repoId', params.repoId.join(','));
|
|
860
|
+
if (params.aiLlmId && params.aiLlmId.length > 0) {
|
|
861
|
+
queryParams.append('aiLlmId', params.aiLlmId.join(','));
|
|
862
|
+
}
|
|
863
|
+
if (params.repoAiApiKeyId && params.repoAiApiKeyId.length > 0) {
|
|
864
|
+
queryParams.append('repoAiApiKeyId', params.repoAiApiKeyId.join(','));
|
|
865
|
+
}
|
|
866
|
+
if (params.hosts && params.hosts.length > 0) {
|
|
867
|
+
queryParams.append('hosts', params.hosts.join(','));
|
|
868
|
+
}
|
|
869
|
+
return this.makeRequest(`aistats/daily?${queryParams.toString()}`, 'GET', null);
|
|
870
|
+
}
|
|
871
|
+
async getAiStatsMinute(params) {
|
|
872
|
+
this.validateDateRange(params.startDate, params.endDate);
|
|
873
|
+
const queryParams = new URLSearchParams();
|
|
874
|
+
if (params.startDate) {
|
|
875
|
+
queryParams.append('startDate', params.startDate.toISOString());
|
|
876
|
+
}
|
|
877
|
+
if (params.endDate) {
|
|
878
|
+
queryParams.append('endDate', params.endDate.toISOString());
|
|
879
|
+
}
|
|
880
|
+
if (params.repoId && params.repoId.length > 0)
|
|
881
|
+
queryParams.append('repoId', params.repoId.join(','));
|
|
882
|
+
if (params.aiLlmId && params.aiLlmId.length > 0) {
|
|
883
|
+
queryParams.append('aiLlmId', params.aiLlmId.join(','));
|
|
884
|
+
}
|
|
885
|
+
if (params.repoAiApiKeyId && params.repoAiApiKeyId.length > 0) {
|
|
886
|
+
queryParams.append('repoAiApiKeyId', params.repoAiApiKeyId.join(','));
|
|
887
|
+
}
|
|
888
|
+
if (params.hosts && params.hosts.length > 0) {
|
|
889
|
+
queryParams.append('hosts', params.hosts.join(','));
|
|
890
|
+
}
|
|
891
|
+
return this.makeRequest(`aistats/minute?${queryParams.toString()}`, 'GET', null);
|
|
892
|
+
}
|
|
801
893
|
async getNodeStatsMinute(params) {
|
|
802
894
|
const queryParams = new URLSearchParams();
|
|
803
895
|
// Handle both unitId and bucketId
|
package/dist/api/index.d.ts
CHANGED
|
@@ -20,5 +20,6 @@ import * as AiApiKeyTypes from './types/ai/aiapikey';
|
|
|
20
20
|
import * as AiLlmTypes from './types/ai/aillm';
|
|
21
21
|
import * as PolicyTypes from './types/ai/policy';
|
|
22
22
|
import * as ConversationTypes from './types/ai/conversation';
|
|
23
|
+
import * as AiStatsTypes from './types/ai/stats';
|
|
23
24
|
import * as LinksTypes from './types/platform/links';
|
|
24
|
-
export { ApiClient, ApiTypes, AuthTypes, StatsTypes, ApiInterfaces, HttpError, BridgeTypes, EmailTypes, QuotaTypes, SubscriptionTypes, DeviceTypes, MFATypes, SettingsTypes, RolesTypes, WorkspaceTypes, OrganizationTypes, NodeRegistrationTypes, SystemEventTypes, UserTypes, AiApiKeyTypes, AiLlmTypes, PolicyTypes, ConversationTypes, LinksTypes };
|
|
25
|
+
export { ApiClient, ApiTypes, AuthTypes, StatsTypes, ApiInterfaces, HttpError, BridgeTypes, EmailTypes, QuotaTypes, SubscriptionTypes, DeviceTypes, MFATypes, SettingsTypes, RolesTypes, WorkspaceTypes, OrganizationTypes, NodeRegistrationTypes, SystemEventTypes, UserTypes, AiApiKeyTypes, AiLlmTypes, PolicyTypes, ConversationTypes, AiStatsTypes, LinksTypes };
|
package/dist/api/index.js
CHANGED
|
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.LinksTypes = exports.ConversationTypes = exports.PolicyTypes = exports.AiLlmTypes = exports.AiApiKeyTypes = exports.UserTypes = exports.SystemEventTypes = exports.NodeRegistrationTypes = exports.OrganizationTypes = exports.WorkspaceTypes = exports.RolesTypes = exports.SettingsTypes = exports.MFATypes = exports.DeviceTypes = exports.SubscriptionTypes = exports.QuotaTypes = exports.EmailTypes = exports.BridgeTypes = exports.HttpError = exports.ApiInterfaces = exports.StatsTypes = exports.AuthTypes = exports.ApiTypes = exports.ApiClient = void 0;
|
|
36
|
+
exports.LinksTypes = exports.AiStatsTypes = exports.ConversationTypes = exports.PolicyTypes = exports.AiLlmTypes = exports.AiApiKeyTypes = exports.UserTypes = exports.SystemEventTypes = exports.NodeRegistrationTypes = exports.OrganizationTypes = exports.WorkspaceTypes = exports.RolesTypes = exports.SettingsTypes = exports.MFATypes = exports.DeviceTypes = exports.SubscriptionTypes = exports.QuotaTypes = exports.EmailTypes = exports.BridgeTypes = exports.HttpError = exports.ApiInterfaces = exports.StatsTypes = exports.AuthTypes = exports.ApiTypes = exports.ApiClient = void 0;
|
|
37
37
|
const client_1 = require("./client");
|
|
38
38
|
Object.defineProperty(exports, "ApiClient", { enumerable: true, get: function () { return client_1.ApiClient; } });
|
|
39
39
|
Object.defineProperty(exports, "HttpError", { enumerable: true, get: function () { return client_1.HttpError; } });
|
|
@@ -79,5 +79,7 @@ const PolicyTypes = __importStar(require("./types/ai/policy"));
|
|
|
79
79
|
exports.PolicyTypes = PolicyTypes;
|
|
80
80
|
const ConversationTypes = __importStar(require("./types/ai/conversation"));
|
|
81
81
|
exports.ConversationTypes = ConversationTypes;
|
|
82
|
+
const AiStatsTypes = __importStar(require("./types/ai/stats"));
|
|
83
|
+
exports.AiStatsTypes = AiStatsTypes;
|
|
82
84
|
const LinksTypes = __importStar(require("./types/platform/links"));
|
|
83
85
|
exports.LinksTypes = LinksTypes;
|
|
@@ -85,6 +85,36 @@ export interface GetPolicyViolationsResponse {
|
|
|
85
85
|
skip: number;
|
|
86
86
|
take: number;
|
|
87
87
|
}
|
|
88
|
+
export interface GetPolicyAlertsQuery {
|
|
89
|
+
workspaceId?: string;
|
|
90
|
+
repoId?: string;
|
|
91
|
+
policyId?: string;
|
|
92
|
+
from?: string;
|
|
93
|
+
to?: string;
|
|
94
|
+
take?: number;
|
|
95
|
+
skip?: number;
|
|
96
|
+
}
|
|
97
|
+
export interface PolicyAlertDTO {
|
|
98
|
+
id: string;
|
|
99
|
+
policyId: string;
|
|
100
|
+
policyName: string;
|
|
101
|
+
timestamp: Date;
|
|
102
|
+
message: string;
|
|
103
|
+
conversationId: string | null;
|
|
104
|
+
repoId: string;
|
|
105
|
+
repoName: string;
|
|
106
|
+
userId: string;
|
|
107
|
+
userName: string;
|
|
108
|
+
repoAiApiKeyId: string;
|
|
109
|
+
repoAiApiKeyName: string;
|
|
110
|
+
}
|
|
111
|
+
export interface GetPolicyAlertsResponse {
|
|
112
|
+
success: boolean;
|
|
113
|
+
alerts: PolicyAlertDTO[];
|
|
114
|
+
total: number;
|
|
115
|
+
skip: number;
|
|
116
|
+
take: number;
|
|
117
|
+
}
|
|
88
118
|
export interface PolicyToValidate {
|
|
89
119
|
policy_uuid: string;
|
|
90
120
|
content: string;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export interface AiStatsQueryParams {
|
|
2
|
+
startDate?: Date;
|
|
3
|
+
endDate?: Date;
|
|
4
|
+
repoId?: string[];
|
|
5
|
+
aiLlmId?: string[];
|
|
6
|
+
repoAiApiKeyId?: string[];
|
|
7
|
+
hosts?: string[];
|
|
8
|
+
}
|
|
9
|
+
export interface AiStatsResponse {
|
|
10
|
+
success: boolean;
|
|
11
|
+
data: AiStatsData[];
|
|
12
|
+
message?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface AiStatsData {
|
|
15
|
+
timestamp: number;
|
|
16
|
+
repoId: string;
|
|
17
|
+
aiLlmId: string;
|
|
18
|
+
repoAiApiKeyId: string;
|
|
19
|
+
tokensIn: bigint | string;
|
|
20
|
+
tokensOut: bigint | string;
|
|
21
|
+
llmTokensIn: bigint | string;
|
|
22
|
+
llmTokensOut: bigint | string;
|
|
23
|
+
activeConversations: number;
|
|
24
|
+
apiCalls: number;
|
|
25
|
+
policyViolations: number;
|
|
26
|
+
numAlerts: number;
|
|
27
|
+
numBlocks: number;
|
|
28
|
+
latency_ms: number;
|
|
29
|
+
llmType: string;
|
|
30
|
+
llmModel: string;
|
|
31
|
+
host: string;
|
|
32
|
+
}
|