@flashbacktech/flashbackclient 0.1.25 → 0.1.26
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 +12 -5
- package/dist/api/client.js +84 -59
- package/dist/api/types/stats.d.ts +53 -0
- package/package.json +1 -1
package/dist/api/client.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CreateUnitRequest, CreateUnitResponse, CreateRepoRequest, CreateRepoResponse, StorageUnit, CreateRepoKeyRequest, CreateRepoKeyResponse, GetUnitsResponse, GetReposResponse, GetRepoKeysResponse, UpdateUnitRequest, UpdateUnitResponse, ActionResponse, UpdateRepoRequest, UpdateRepoResponse, UpdateRepoKeyRequest, UpdateRepoKeyResponse, ValidateUnitRequest, ValidateUnitResponse, ValidateRepoUnitsRequest, ValidateRepoUnitsResponse, StorageUnitStatusResponse, GetUnitNodeStatsResponse, GetUnitNodeStatsRequest, CreateBucketRequest, CreateBucketResponse, UpdateBucketRequest, UpdateBucketResponse, ValidateBucketRequest, ValidateBucketResponse, StorageBucket, GetBucketsResponse, StorageBucketStatusResponse, GetBucketNodeStatsRequest, GetBucketNodeStatsResponse, CreateRepoWithBucketsRequest, UpdateRepoWithBucketsRequest, ValidateRepoBucketsRequest, ValidateRepoBucketsResponse } from './types/storage';
|
|
2
2
|
import { IApiClient, ProviderType } from './interfaces';
|
|
3
3
|
import { ActivateResponse, DeactivateResponse, LoginBody, LoginResponse, LogoutResponse, OAuth2ResponseDTO, RefreshTokenErrorResponse, RefreshTokenResponse, RegisterBody, RegisterResponse, ResetPasswordBody } from './types/auth';
|
|
4
|
-
import { StatsQueryParams, StatsResponse, NodeStatsMinuteResponse, NodeStatsDailyResponse, NodeStatsQueryParams, UnitStatsResponse, RepoStatsResponse, NodeStatsDailyQueryParams } from './types/stats';
|
|
4
|
+
import { StatsQueryParams, StatsResponse, NodeStatsMinuteResponse, NodeStatsDailyResponse, NodeStatsQueryParams, UnitStatsResponse, RepoStatsResponse, NodeStatsDailyQueryParams, BucketStatsResponse, StatsQueryWithBucketParams, NodeStatsQueryWithBucketParams, NodeStatsDailyQueryWithBucketParams } from './types/stats';
|
|
5
5
|
import { NodeInfo } from './types/bridge';
|
|
6
6
|
import { QuotaResponse } from './types/quota';
|
|
7
7
|
interface ErrorResponse {
|
|
@@ -80,16 +80,23 @@ export declare class ApiClient implements IApiClient {
|
|
|
80
80
|
requestPasswordReset: (email: string) => Promise<ActionResponse>;
|
|
81
81
|
resetPassword: (data: ResetPasswordBody) => Promise<ActionResponse>;
|
|
82
82
|
private validateDateRange;
|
|
83
|
-
getDailyStats
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
83
|
+
getDailyStats(params: StatsQueryParams): Promise<StatsResponse>;
|
|
84
|
+
getDailyStats(params: StatsQueryWithBucketParams): Promise<StatsResponse>;
|
|
85
|
+
getMinuteStats(params: StatsQueryParams): Promise<StatsResponse>;
|
|
86
|
+
getMinuteStats(params: StatsQueryWithBucketParams): Promise<StatsResponse>;
|
|
87
|
+
getNodeStatsMinute(params: NodeStatsQueryParams): Promise<NodeStatsMinuteResponse>;
|
|
88
|
+
getNodeStatsMinute(params: NodeStatsQueryWithBucketParams): Promise<NodeStatsMinuteResponse>;
|
|
89
|
+
getNodeStatsDaily(params: NodeStatsDailyQueryParams): Promise<NodeStatsDailyResponse>;
|
|
90
|
+
getNodeStatsDaily(params: NodeStatsDailyQueryWithBucketParams): Promise<NodeStatsDailyResponse>;
|
|
87
91
|
getRepoStats: (params?: {
|
|
88
92
|
repoId?: string[];
|
|
89
93
|
}) => Promise<RepoStatsResponse>;
|
|
90
94
|
getUnitStats: (params?: {
|
|
91
95
|
unitId?: string[];
|
|
92
96
|
}) => Promise<UnitStatsResponse>;
|
|
97
|
+
getBucketStats: (params?: {
|
|
98
|
+
bucketId?: string[];
|
|
99
|
+
}) => Promise<BucketStatsResponse>;
|
|
93
100
|
getNodeInfo: () => Promise<NodeInfo[]>;
|
|
94
101
|
sendFeedbackEmail: (data: FormData) => Promise<ActionResponse>;
|
|
95
102
|
}
|
package/dist/api/client.js
CHANGED
|
@@ -249,65 +249,6 @@ class ApiClient {
|
|
|
249
249
|
this.resetPassword = async (data) => {
|
|
250
250
|
return this.makeRequest('user/reset-password', 'POST', data);
|
|
251
251
|
};
|
|
252
|
-
this.getDailyStats = async (params) => {
|
|
253
|
-
this.validateDateRange(params.startDate, params.endDate);
|
|
254
|
-
const queryParams = new URLSearchParams();
|
|
255
|
-
if (params.startDate) {
|
|
256
|
-
queryParams.append('startDate', params.startDate.toISOString());
|
|
257
|
-
}
|
|
258
|
-
if (params.endDate) {
|
|
259
|
-
queryParams.append('endDate', params.endDate.toISOString());
|
|
260
|
-
}
|
|
261
|
-
if (params.repoId && params.repoId.length > 0)
|
|
262
|
-
queryParams.append('repoId', params.repoId.join(','));
|
|
263
|
-
if (params.unitId && params.unitId.length > 0)
|
|
264
|
-
queryParams.append('unitId', params.unitId.join(','));
|
|
265
|
-
return this.makeRequest(`stats/daily?${queryParams.toString()}`, 'GET', null);
|
|
266
|
-
};
|
|
267
|
-
this.getMinuteStats = async (params) => {
|
|
268
|
-
this.validateDateRange(params.startDate, params.endDate);
|
|
269
|
-
const queryParams = new URLSearchParams();
|
|
270
|
-
if (params.startDate) {
|
|
271
|
-
queryParams.append('startDate', params.startDate.toISOString());
|
|
272
|
-
}
|
|
273
|
-
if (params.endDate) {
|
|
274
|
-
queryParams.append('endDate', params.endDate.toISOString());
|
|
275
|
-
}
|
|
276
|
-
if (params.repoId && params.repoId.length > 0)
|
|
277
|
-
queryParams.append('repoId', params.repoId.join(','));
|
|
278
|
-
if (params.unitId && params.unitId.length > 0)
|
|
279
|
-
queryParams.append('unitId', params.unitId.join(','));
|
|
280
|
-
return this.makeRequest(`stats/minute?${queryParams.toString()}`, 'GET', null);
|
|
281
|
-
};
|
|
282
|
-
this.getNodeStatsMinute = async (params) => {
|
|
283
|
-
const queryParams = new URLSearchParams();
|
|
284
|
-
if (params.unitId.length > 0) {
|
|
285
|
-
queryParams.append('unitId', params.unitId.join(','));
|
|
286
|
-
}
|
|
287
|
-
const response = await this.makeRequest(`stats/nodes/minute?${queryParams.toString() ? `?${queryParams.toString()}` : ''}`, 'GET', null);
|
|
288
|
-
// Process the response to convert lastUpdated strings to Date objects
|
|
289
|
-
const processedData = response.data.map((item) => ({
|
|
290
|
-
...item,
|
|
291
|
-
lastUpdated: new Date(item.lastUpdated),
|
|
292
|
-
}));
|
|
293
|
-
return {
|
|
294
|
-
...response,
|
|
295
|
-
data: processedData,
|
|
296
|
-
};
|
|
297
|
-
};
|
|
298
|
-
this.getNodeStatsDaily = async (params) => {
|
|
299
|
-
const queryParams = new URLSearchParams();
|
|
300
|
-
if (params.unitId.length > 0) {
|
|
301
|
-
queryParams.append('unitId', params.unitId.join(','));
|
|
302
|
-
}
|
|
303
|
-
if (params.startDate) {
|
|
304
|
-
queryParams.append('startDate', params.startDate.toString());
|
|
305
|
-
}
|
|
306
|
-
if (params.endDate) {
|
|
307
|
-
queryParams.append('endDate', params.endDate.toString());
|
|
308
|
-
}
|
|
309
|
-
return this.makeRequest(`stats/nodes/daily${queryParams.toString() ? `?${queryParams.toString()}` : ''}`, 'GET', null);
|
|
310
|
-
};
|
|
311
252
|
this.getRepoStats = async (params) => {
|
|
312
253
|
const queryParams = new URLSearchParams();
|
|
313
254
|
if (params && params.repoId && params.repoId.length > 0) {
|
|
@@ -322,6 +263,13 @@ class ApiClient {
|
|
|
322
263
|
}
|
|
323
264
|
return this.makeRequest(`unit/stats${queryParams.toString() ? `?${queryParams.toString()}` : ''}`, 'GET', null);
|
|
324
265
|
};
|
|
266
|
+
this.getBucketStats = async (params) => {
|
|
267
|
+
const queryParams = new URLSearchParams();
|
|
268
|
+
if (params && params.bucketId && params.bucketId.length > 0) {
|
|
269
|
+
queryParams.append('bucketId', params.bucketId.join(','));
|
|
270
|
+
}
|
|
271
|
+
return this.makeRequest(`bucket/stats${queryParams.toString() ? `?${queryParams.toString()}` : ''}`, 'GET', null);
|
|
272
|
+
};
|
|
325
273
|
this.getNodeInfo = async () => {
|
|
326
274
|
return this.makeRequest('node', 'GET', null);
|
|
327
275
|
};
|
|
@@ -352,5 +300,82 @@ class ApiClient {
|
|
|
352
300
|
}
|
|
353
301
|
}
|
|
354
302
|
}
|
|
303
|
+
async getDailyStats(params) {
|
|
304
|
+
this.validateDateRange(params.startDate, params.endDate);
|
|
305
|
+
const queryParams = new URLSearchParams();
|
|
306
|
+
if (params.startDate) {
|
|
307
|
+
queryParams.append('startDate', params.startDate.toISOString());
|
|
308
|
+
}
|
|
309
|
+
if (params.endDate) {
|
|
310
|
+
queryParams.append('endDate', params.endDate.toISOString());
|
|
311
|
+
}
|
|
312
|
+
if (params.repoId && params.repoId.length > 0)
|
|
313
|
+
queryParams.append('repoId', params.repoId.join(','));
|
|
314
|
+
// Handle both unitId and bucketId
|
|
315
|
+
if ('unitId' in params && params.unitId && params.unitId.length > 0) {
|
|
316
|
+
queryParams.append('unitId', params.unitId.join(','));
|
|
317
|
+
}
|
|
318
|
+
else if ('bucketId' in params && params.bucketId && params.bucketId.length > 0) {
|
|
319
|
+
queryParams.append('bucketId', params.bucketId.join(','));
|
|
320
|
+
}
|
|
321
|
+
return this.makeRequest(`stats/daily?${queryParams.toString()}`, 'GET', null);
|
|
322
|
+
}
|
|
323
|
+
async getMinuteStats(params) {
|
|
324
|
+
this.validateDateRange(params.startDate, params.endDate);
|
|
325
|
+
const queryParams = new URLSearchParams();
|
|
326
|
+
if (params.startDate) {
|
|
327
|
+
queryParams.append('startDate', params.startDate.toISOString());
|
|
328
|
+
}
|
|
329
|
+
if (params.endDate) {
|
|
330
|
+
queryParams.append('endDate', params.endDate.toISOString());
|
|
331
|
+
}
|
|
332
|
+
if (params.repoId && params.repoId.length > 0)
|
|
333
|
+
queryParams.append('repoId', params.repoId.join(','));
|
|
334
|
+
// Handle both unitId and bucketId
|
|
335
|
+
if ('unitId' in params && params.unitId && params.unitId.length > 0) {
|
|
336
|
+
queryParams.append('unitId', params.unitId.join(','));
|
|
337
|
+
}
|
|
338
|
+
else if ('bucketId' in params && params.bucketId && params.bucketId.length > 0) {
|
|
339
|
+
queryParams.append('bucketId', params.bucketId.join(','));
|
|
340
|
+
}
|
|
341
|
+
return this.makeRequest(`stats/minute?${queryParams.toString()}`, 'GET', null);
|
|
342
|
+
}
|
|
343
|
+
async getNodeStatsMinute(params) {
|
|
344
|
+
const queryParams = new URLSearchParams();
|
|
345
|
+
// Handle both unitId and bucketId
|
|
346
|
+
if ('unitId' in params && params.unitId.length > 0) {
|
|
347
|
+
queryParams.append('unitId', params.unitId.join(','));
|
|
348
|
+
}
|
|
349
|
+
else if ('bucketId' in params && params.bucketId.length > 0) {
|
|
350
|
+
queryParams.append('bucketId', params.bucketId.join(','));
|
|
351
|
+
}
|
|
352
|
+
const response = await this.makeRequest(`stats/nodes/minute?${queryParams.toString() ? `?${queryParams.toString()}` : ''}`, 'GET', null);
|
|
353
|
+
// Process the response to convert lastUpdated strings to Date objects
|
|
354
|
+
const processedData = response.data.map((item) => ({
|
|
355
|
+
...item,
|
|
356
|
+
lastUpdated: new Date(item.lastUpdated),
|
|
357
|
+
}));
|
|
358
|
+
return {
|
|
359
|
+
...response,
|
|
360
|
+
data: processedData,
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
async getNodeStatsDaily(params) {
|
|
364
|
+
const queryParams = new URLSearchParams();
|
|
365
|
+
// Handle both unitId and bucketId
|
|
366
|
+
if ('unitId' in params && params.unitId.length > 0) {
|
|
367
|
+
queryParams.append('unitId', params.unitId.join(','));
|
|
368
|
+
}
|
|
369
|
+
else if ('bucketId' in params && params.bucketId.length > 0) {
|
|
370
|
+
queryParams.append('bucketId', params.bucketId.join(','));
|
|
371
|
+
}
|
|
372
|
+
if (params.startDate) {
|
|
373
|
+
queryParams.append('startDate', params.startDate.toString());
|
|
374
|
+
}
|
|
375
|
+
if (params.endDate) {
|
|
376
|
+
queryParams.append('endDate', params.endDate.toString());
|
|
377
|
+
}
|
|
378
|
+
return this.makeRequest(`stats/nodes/daily${queryParams.toString() ? `?${queryParams.toString()}` : ''}`, 'GET', null);
|
|
379
|
+
}
|
|
355
380
|
}
|
|
356
381
|
exports.ApiClient = ApiClient;
|
|
@@ -75,3 +75,56 @@ export interface UnitStatsResponse {
|
|
|
75
75
|
totalSizeChange: string;
|
|
76
76
|
}[];
|
|
77
77
|
}
|
|
78
|
+
export interface BucketStatsResponse {
|
|
79
|
+
success: boolean;
|
|
80
|
+
stats: {
|
|
81
|
+
bucketId: string;
|
|
82
|
+
totalCount: string;
|
|
83
|
+
totalUploadBytes: string;
|
|
84
|
+
totalDownloadBytes: string;
|
|
85
|
+
totalSizeChange: string;
|
|
86
|
+
}[];
|
|
87
|
+
}
|
|
88
|
+
export interface StatsQueryWithBucketParams {
|
|
89
|
+
startDate?: Date;
|
|
90
|
+
endDate?: Date;
|
|
91
|
+
repoId?: string[];
|
|
92
|
+
bucketId?: string[];
|
|
93
|
+
}
|
|
94
|
+
export interface StatsDataWithBucket {
|
|
95
|
+
timestamp: number;
|
|
96
|
+
repoId: string;
|
|
97
|
+
bucketId: string;
|
|
98
|
+
upl_bytes: bigint;
|
|
99
|
+
dwl_bytes: bigint;
|
|
100
|
+
size_change: bigint;
|
|
101
|
+
latency_ms: number;
|
|
102
|
+
}
|
|
103
|
+
export interface NodeStatsMinuteDataWithBucket {
|
|
104
|
+
nodeId: string;
|
|
105
|
+
bucketId: string;
|
|
106
|
+
nodeStatus: string;
|
|
107
|
+
lastUpdated: Date;
|
|
108
|
+
latency_ms: number;
|
|
109
|
+
}
|
|
110
|
+
export interface NodeStatsDailyDataWithBucket {
|
|
111
|
+
nodeId: string;
|
|
112
|
+
bucketId: string;
|
|
113
|
+
day: number;
|
|
114
|
+
online: number;
|
|
115
|
+
latency_ms: number;
|
|
116
|
+
endpoint: string;
|
|
117
|
+
region: string;
|
|
118
|
+
storageType: string;
|
|
119
|
+
provider: string;
|
|
120
|
+
status: string;
|
|
121
|
+
version: string;
|
|
122
|
+
}
|
|
123
|
+
export interface NodeStatsQueryWithBucketParams {
|
|
124
|
+
bucketId: string[];
|
|
125
|
+
}
|
|
126
|
+
export interface NodeStatsDailyQueryWithBucketParams {
|
|
127
|
+
bucketId: string[];
|
|
128
|
+
startDate?: number;
|
|
129
|
+
endDate?: number;
|
|
130
|
+
}
|