@flashbacktech/flashbackclient 0.1.24 → 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 +21 -10
- package/dist/api/client.js +96 -72
- package/dist/api/types/stats.d.ts +53 -0
- package/dist/api/types/storage.d.ts +3 -1
- package/package.json +1 -1
package/dist/api/client.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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 } from './types/storage';
|
|
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 {
|
|
@@ -55,12 +55,16 @@ export declare class ApiClient implements IApiClient {
|
|
|
55
55
|
getAvailableStorageBuckets: () => Promise<StorageBucket[]>;
|
|
56
56
|
getStorageBucketStatus: (bucketId: string) => Promise<StorageBucketStatusResponse>;
|
|
57
57
|
getBucketNodeStats: (bucketId: string, data: GetBucketNodeStatsRequest) => Promise<GetBucketNodeStatsResponse>;
|
|
58
|
-
createStorageRepo
|
|
58
|
+
createStorageRepo(data: CreateRepoRequest): Promise<CreateRepoResponse>;
|
|
59
|
+
createStorageRepo(data: CreateRepoWithBucketsRequest): Promise<CreateRepoResponse>;
|
|
59
60
|
getStorageRepos: () => Promise<GetReposResponse>;
|
|
60
|
-
updateStorageRepo
|
|
61
|
+
updateStorageRepo(repoId: string, data: UpdateRepoRequest): Promise<UpdateRepoResponse>;
|
|
62
|
+
updateStorageRepo(repoId: string, data: UpdateRepoWithBucketsRequest): Promise<UpdateRepoResponse>;
|
|
61
63
|
deleteStorageRepo: (repoId: string) => Promise<ActionResponse>;
|
|
62
|
-
validateNewRepoUnits
|
|
63
|
-
|
|
64
|
+
validateNewRepoUnits(data: ValidateRepoUnitsRequest): Promise<ValidateRepoUnitsResponse>;
|
|
65
|
+
validateNewRepoUnits(data: ValidateRepoBucketsRequest): Promise<ValidateRepoBucketsResponse>;
|
|
66
|
+
validateUpdateRepoUnits(data: ValidateRepoUnitsRequest): Promise<ValidateRepoUnitsResponse>;
|
|
67
|
+
validateUpdateRepoUnits(data: ValidateRepoBucketsRequest): Promise<ValidateRepoBucketsResponse>;
|
|
64
68
|
createRepoKey: (data: CreateRepoKeyRequest) => Promise<CreateRepoKeyResponse>;
|
|
65
69
|
getRepoKeys: (repoId: string) => Promise<GetRepoKeysResponse>;
|
|
66
70
|
updateRepoKey: (repoId: string, keyId: string, data: UpdateRepoKeyRequest) => Promise<UpdateRepoKeyResponse>;
|
|
@@ -76,16 +80,23 @@ export declare class ApiClient implements IApiClient {
|
|
|
76
80
|
requestPasswordReset: (email: string) => Promise<ActionResponse>;
|
|
77
81
|
resetPassword: (data: ResetPasswordBody) => Promise<ActionResponse>;
|
|
78
82
|
private validateDateRange;
|
|
79
|
-
getDailyStats
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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>;
|
|
83
91
|
getRepoStats: (params?: {
|
|
84
92
|
repoId?: string[];
|
|
85
93
|
}) => Promise<RepoStatsResponse>;
|
|
86
94
|
getUnitStats: (params?: {
|
|
87
95
|
unitId?: string[];
|
|
88
96
|
}) => Promise<UnitStatsResponse>;
|
|
97
|
+
getBucketStats: (params?: {
|
|
98
|
+
bucketId?: string[];
|
|
99
|
+
}) => Promise<BucketStatsResponse>;
|
|
89
100
|
getNodeInfo: () => Promise<NodeInfo[]>;
|
|
90
101
|
sendFeedbackEmail: (data: FormData) => Promise<ActionResponse>;
|
|
91
102
|
}
|
package/dist/api/client.js
CHANGED
|
@@ -199,25 +199,12 @@ class ApiClient {
|
|
|
199
199
|
this.getBucketNodeStats = async (bucketId, data) => {
|
|
200
200
|
return this.makeRequest(`bucket/${bucketId}/stats`, 'POST', data);
|
|
201
201
|
};
|
|
202
|
-
////// Repos API
|
|
203
|
-
this.createStorageRepo = async (data) => {
|
|
204
|
-
return this.makeRequest('repo', 'POST', data);
|
|
205
|
-
};
|
|
206
202
|
this.getStorageRepos = async () => {
|
|
207
203
|
return this.makeRequest('repo', 'GET', null);
|
|
208
204
|
};
|
|
209
|
-
this.updateStorageRepo = async (repoId, data) => {
|
|
210
|
-
return this.makeRequest(`repo/${repoId}`, 'PUT', data);
|
|
211
|
-
};
|
|
212
205
|
this.deleteStorageRepo = async (repoId) => {
|
|
213
206
|
return this.makeRequest(`repo/${repoId}`, 'DELETE', null);
|
|
214
207
|
};
|
|
215
|
-
this.validateNewRepoUnits = async (data) => {
|
|
216
|
-
return this.makeRequest('repo/validate', 'POST', data);
|
|
217
|
-
};
|
|
218
|
-
this.validateUpdateRepoUnits = async (data) => {
|
|
219
|
-
return this.makeRequest(`repo/${data.repoId}/validate`, 'POST', data);
|
|
220
|
-
};
|
|
221
208
|
////// Keys API
|
|
222
209
|
this.createRepoKey = async (data) => {
|
|
223
210
|
return this.makeRequest(`repo/${data.repoId}/apikey`, 'POST', data);
|
|
@@ -262,65 +249,6 @@ class ApiClient {
|
|
|
262
249
|
this.resetPassword = async (data) => {
|
|
263
250
|
return this.makeRequest('user/reset-password', 'POST', data);
|
|
264
251
|
};
|
|
265
|
-
this.getDailyStats = async (params) => {
|
|
266
|
-
this.validateDateRange(params.startDate, params.endDate);
|
|
267
|
-
const queryParams = new URLSearchParams();
|
|
268
|
-
if (params.startDate) {
|
|
269
|
-
queryParams.append('startDate', params.startDate.toISOString());
|
|
270
|
-
}
|
|
271
|
-
if (params.endDate) {
|
|
272
|
-
queryParams.append('endDate', params.endDate.toISOString());
|
|
273
|
-
}
|
|
274
|
-
if (params.repoId && params.repoId.length > 0)
|
|
275
|
-
queryParams.append('repoId', params.repoId.join(','));
|
|
276
|
-
if (params.unitId && params.unitId.length > 0)
|
|
277
|
-
queryParams.append('unitId', params.unitId.join(','));
|
|
278
|
-
return this.makeRequest(`stats/daily?${queryParams.toString()}`, 'GET', null);
|
|
279
|
-
};
|
|
280
|
-
this.getMinuteStats = async (params) => {
|
|
281
|
-
this.validateDateRange(params.startDate, params.endDate);
|
|
282
|
-
const queryParams = new URLSearchParams();
|
|
283
|
-
if (params.startDate) {
|
|
284
|
-
queryParams.append('startDate', params.startDate.toISOString());
|
|
285
|
-
}
|
|
286
|
-
if (params.endDate) {
|
|
287
|
-
queryParams.append('endDate', params.endDate.toISOString());
|
|
288
|
-
}
|
|
289
|
-
if (params.repoId && params.repoId.length > 0)
|
|
290
|
-
queryParams.append('repoId', params.repoId.join(','));
|
|
291
|
-
if (params.unitId && params.unitId.length > 0)
|
|
292
|
-
queryParams.append('unitId', params.unitId.join(','));
|
|
293
|
-
return this.makeRequest(`stats/minute?${queryParams.toString()}`, 'GET', null);
|
|
294
|
-
};
|
|
295
|
-
this.getNodeStatsMinute = async (params) => {
|
|
296
|
-
const queryParams = new URLSearchParams();
|
|
297
|
-
if (params.unitId.length > 0) {
|
|
298
|
-
queryParams.append('unitId', params.unitId.join(','));
|
|
299
|
-
}
|
|
300
|
-
const response = await this.makeRequest(`stats/nodes/minute?${queryParams.toString() ? `?${queryParams.toString()}` : ''}`, 'GET', null);
|
|
301
|
-
// Process the response to convert lastUpdated strings to Date objects
|
|
302
|
-
const processedData = response.data.map((item) => ({
|
|
303
|
-
...item,
|
|
304
|
-
lastUpdated: new Date(item.lastUpdated),
|
|
305
|
-
}));
|
|
306
|
-
return {
|
|
307
|
-
...response,
|
|
308
|
-
data: processedData,
|
|
309
|
-
};
|
|
310
|
-
};
|
|
311
|
-
this.getNodeStatsDaily = async (params) => {
|
|
312
|
-
const queryParams = new URLSearchParams();
|
|
313
|
-
if (params.unitId.length > 0) {
|
|
314
|
-
queryParams.append('unitId', params.unitId.join(','));
|
|
315
|
-
}
|
|
316
|
-
if (params.startDate) {
|
|
317
|
-
queryParams.append('startDate', params.startDate.toString());
|
|
318
|
-
}
|
|
319
|
-
if (params.endDate) {
|
|
320
|
-
queryParams.append('endDate', params.endDate.toString());
|
|
321
|
-
}
|
|
322
|
-
return this.makeRequest(`stats/nodes/daily${queryParams.toString() ? `?${queryParams.toString()}` : ''}`, 'GET', null);
|
|
323
|
-
};
|
|
324
252
|
this.getRepoStats = async (params) => {
|
|
325
253
|
const queryParams = new URLSearchParams();
|
|
326
254
|
if (params && params.repoId && params.repoId.length > 0) {
|
|
@@ -335,6 +263,13 @@ class ApiClient {
|
|
|
335
263
|
}
|
|
336
264
|
return this.makeRequest(`unit/stats${queryParams.toString() ? `?${queryParams.toString()}` : ''}`, 'GET', null);
|
|
337
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
|
+
};
|
|
338
273
|
this.getNodeInfo = async () => {
|
|
339
274
|
return this.makeRequest('node', 'GET', null);
|
|
340
275
|
};
|
|
@@ -345,6 +280,18 @@ class ApiClient {
|
|
|
345
280
|
this.headers = {};
|
|
346
281
|
this.debug = false;
|
|
347
282
|
}
|
|
283
|
+
async createStorageRepo(data) {
|
|
284
|
+
return this.makeRequest('repo', 'POST', data);
|
|
285
|
+
}
|
|
286
|
+
async updateStorageRepo(repoId, data) {
|
|
287
|
+
return this.makeRequest(`repo/${repoId}`, 'PUT', data);
|
|
288
|
+
}
|
|
289
|
+
async validateNewRepoUnits(data) {
|
|
290
|
+
return this.makeRequest('repo/validate', 'POST', data);
|
|
291
|
+
}
|
|
292
|
+
async validateUpdateRepoUnits(data) {
|
|
293
|
+
return this.makeRequest(`repo/${data.repoId}/validate`, 'POST', data);
|
|
294
|
+
}
|
|
348
295
|
////// Stats API
|
|
349
296
|
validateDateRange(startDate, endDate) {
|
|
350
297
|
if (startDate && endDate) {
|
|
@@ -353,5 +300,82 @@ class ApiClient {
|
|
|
353
300
|
}
|
|
354
301
|
}
|
|
355
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
|
+
}
|
|
356
380
|
}
|
|
357
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
|
+
}
|
|
@@ -189,7 +189,9 @@ export interface ValidateBucketResponse extends ValidateUnitResponse {
|
|
|
189
189
|
}
|
|
190
190
|
export interface StorageBucket extends StorageUnit {
|
|
191
191
|
}
|
|
192
|
-
export interface GetBucketsResponse
|
|
192
|
+
export interface GetBucketsResponse {
|
|
193
|
+
success: boolean;
|
|
194
|
+
buckets: StorageBucket[];
|
|
193
195
|
}
|
|
194
196
|
export interface CreateBucketResponse {
|
|
195
197
|
success: boolean;
|