@flashbacktech/flashbackclient 0.0.84 → 0.0.86
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
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CreateUnitRequest, CreateUnitResponse, CreateRepoRequest, CreateRepoResponse, StorageUnit, CreateRepoKeyRequest, CreateRepoKeyResponse, GetUnitsResponse, GetReposResponse, GetRepoKeysResponse, UpdateUnitRequest, UpdateUnitResponse, ActionResponse, UpdateRepoRequest, UpdateRepoResponse, UpdateRepoKeyRequest, UpdateRepoKeyResponse, ValidateUnitRequest, ValidateUnitResponse, ValidateRepoUnitsRequest, ValidateRepoUnitsResponse, StorageUnitStatusResponse } 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 } from './types/storage';
|
|
2
2
|
import { IApiClient, ProviderType } from './interfaces';
|
|
3
|
-
import { ActivateResponse, DeactivateResponse, LoginBody, LoginResponse, LogoutResponse, OAuth2ResponseDTO,
|
|
3
|
+
import { ActivateResponse, DeactivateResponse, LoginBody, LoginResponse, LogoutResponse, OAuth2ResponseDTO, RefreshTokenResponse, RegisterBody, RegisterResponse } from './types/auth';
|
|
4
4
|
interface ErrorResponse {
|
|
5
5
|
message?: string;
|
|
6
6
|
[key: string]: any;
|
|
@@ -42,6 +42,7 @@ export declare class ApiClient implements IApiClient {
|
|
|
42
42
|
deleteStorageUnit: (unitId: string) => Promise<ActionResponse>;
|
|
43
43
|
getAvailableStorageUnits: () => Promise<StorageUnit[]>;
|
|
44
44
|
getStorageUnitStatus: (unitId: string) => Promise<StorageUnitStatusResponse>;
|
|
45
|
+
getUnitNodeStats: (unitId: string, data: GetUnitNodeStatsRequest) => Promise<GetUnitNodeStatsResponse>;
|
|
45
46
|
createStorageRepo: (data: CreateRepoRequest) => Promise<CreateRepoResponse>;
|
|
46
47
|
getStorageRepos: () => Promise<GetReposResponse>;
|
|
47
48
|
updateStorageRepo: (repoId: string, data: UpdateRepoRequest) => Promise<UpdateRepoResponse>;
|
|
@@ -54,7 +55,7 @@ export declare class ApiClient implements IApiClient {
|
|
|
54
55
|
deleteRepoKey: (repoId: string, keyId: string) => Promise<ActionResponse>;
|
|
55
56
|
userRegister: (data: RegisterBody) => Promise<RegisterResponse>;
|
|
56
57
|
userLogin: (data: LoginBody) => Promise<LoginResponse>;
|
|
57
|
-
userRefresh: (refreshToken: string) => Promise<
|
|
58
|
+
userRefresh: (refreshToken: string) => Promise<RefreshTokenResponse>;
|
|
58
59
|
userLogout: (refreshToken: string) => Promise<LogoutResponse>;
|
|
59
60
|
userActivate: () => Promise<ActivateResponse>;
|
|
60
61
|
userDeactivate: () => Promise<DeactivateResponse>;
|
package/dist/api/client.js
CHANGED
|
@@ -34,6 +34,8 @@ class ApiClient {
|
|
|
34
34
|
return this.authenticateGithub(token);
|
|
35
35
|
case interfaces_1.ProviderType.WEB3_STELLAR:
|
|
36
36
|
return this.authenticateWeb3Stellar(token);
|
|
37
|
+
case interfaces_1.ProviderType.LOCAL:
|
|
38
|
+
throw new Error('Call userLogin for local authentication');
|
|
37
39
|
default:
|
|
38
40
|
throw new Error(`Unsupported provider: ${provider}`);
|
|
39
41
|
}
|
|
@@ -69,6 +71,8 @@ class ApiClient {
|
|
|
69
71
|
case interfaces_1.ProviderType.GITHUB:
|
|
70
72
|
// TODO: Implement refresh token for Github
|
|
71
73
|
throw new Error('Not implemented');
|
|
74
|
+
case interfaces_1.ProviderType.LOCAL:
|
|
75
|
+
return this.userRefresh(refreshToken);
|
|
72
76
|
default:
|
|
73
77
|
throw new Error(`Unsupported provider: ${provider}`);
|
|
74
78
|
}
|
|
@@ -160,6 +164,9 @@ class ApiClient {
|
|
|
160
164
|
this.getStorageUnitStatus = async (unitId) => {
|
|
161
165
|
return this.makeRequest(`unit/${unitId}/status`, 'GET', null);
|
|
162
166
|
};
|
|
167
|
+
this.getUnitNodeStats = async (unitId, data) => {
|
|
168
|
+
return this.makeRequest(`unit/${unitId}/stats`, 'GET', data);
|
|
169
|
+
};
|
|
163
170
|
////// Repos API
|
|
164
171
|
this.createStorageRepo = async (data) => {
|
|
165
172
|
return this.makeRequest('repo', 'POST', data);
|
package/dist/api/interfaces.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { StorageUnit, CreateUnitRequest, CreateUnitResponse, CreateRepoRequest, CreateRepoResponse, CreateRepoKeyRequest, CreateRepoKeyResponse, GetUnitsResponse, GetReposResponse, GetRepoKeysResponse, UpdateUnitRequest, UpdateUnitResponse, ActionResponse, UpdateRepoResponse, UpdateRepoRequest, UpdateRepoKeyRequest, UpdateRepoKeyResponse, ValidateUnitRequest, ValidateUnitResponse, ValidateRepoUnitsRequest, ValidateRepoUnitsResponse } from "./types/storage";
|
|
2
|
-
import { RegisterBody, LoginBody, RegisterResponse, LoginResponse,
|
|
1
|
+
import { StorageUnit, CreateUnitRequest, CreateUnitResponse, CreateRepoRequest, CreateRepoResponse, CreateRepoKeyRequest, CreateRepoKeyResponse, GetUnitsResponse, GetReposResponse, GetRepoKeysResponse, UpdateUnitRequest, UpdateUnitResponse, ActionResponse, UpdateRepoResponse, UpdateRepoRequest, UpdateRepoKeyRequest, UpdateRepoKeyResponse, ValidateUnitRequest, ValidateUnitResponse, ValidateRepoUnitsRequest, ValidateRepoUnitsResponse, GetUnitNodeStatsRequest, GetUnitNodeStatsResponse } from "./types/storage";
|
|
2
|
+
import { RegisterBody, LoginBody, RegisterResponse, LoginResponse, LogoutResponse, ActivateResponse, DeactivateResponse, RefreshTokenResponse } from "./types/auth";
|
|
3
3
|
export declare enum ProviderType {
|
|
4
4
|
GOOGLE = "GOOGLE",
|
|
5
5
|
GITHUB = "GITHUB",
|
|
6
|
-
WEB3_STELLAR = "WEB3_STELLAR"
|
|
6
|
+
WEB3_STELLAR = "WEB3_STELLAR",
|
|
7
|
+
LOCAL = "LOCAL"
|
|
7
8
|
}
|
|
8
9
|
export interface IApiClient {
|
|
9
10
|
authenticate(token: string, provider: ProviderType): Promise<any>;
|
|
@@ -13,6 +14,7 @@ export interface IApiClient {
|
|
|
13
14
|
deleteStorageUnit(unitId: string): Promise<ActionResponse>;
|
|
14
15
|
validateStorageUnit(unitId: string, data: ValidateUnitRequest): Promise<ValidateUnitResponse>;
|
|
15
16
|
getAvailableStorageUnits(): Promise<StorageUnit[]>;
|
|
17
|
+
getUnitNodeStats(unitId: string, data: GetUnitNodeStatsRequest): Promise<GetUnitNodeStatsResponse>;
|
|
16
18
|
createStorageRepo(data: CreateRepoRequest): Promise<CreateRepoResponse>;
|
|
17
19
|
getStorageRepos(): Promise<GetReposResponse>;
|
|
18
20
|
updateStorageRepo(repoId: string, data: UpdateRepoRequest): Promise<UpdateRepoResponse>;
|
|
@@ -25,7 +27,7 @@ export interface IApiClient {
|
|
|
25
27
|
validateUpdateRepoUnits(data: ValidateRepoUnitsRequest): Promise<ValidateRepoUnitsResponse>;
|
|
26
28
|
userRegister(registerBody: RegisterBody): Promise<RegisterResponse>;
|
|
27
29
|
userLogin(loginBody: LoginBody): Promise<LoginResponse>;
|
|
28
|
-
userRefresh(refreshToken: string): Promise<
|
|
30
|
+
userRefresh(refreshToken: string): Promise<RefreshTokenResponse>;
|
|
29
31
|
userLogout(refreshToken: string): Promise<LogoutResponse>;
|
|
30
32
|
userActivate(): Promise<ActivateResponse>;
|
|
31
33
|
userDeactivate(): Promise<DeactivateResponse>;
|
package/dist/api/interfaces.js
CHANGED
package/dist/api/types/auth.d.ts
CHANGED
|
@@ -59,18 +59,6 @@ export interface RegisterResponse {
|
|
|
59
59
|
}
|
|
60
60
|
export interface LoginResponse extends RegisterResponse {
|
|
61
61
|
}
|
|
62
|
-
export interface RefreshResponse {
|
|
63
|
-
success: boolean;
|
|
64
|
-
accessToken?: string;
|
|
65
|
-
user?: {
|
|
66
|
-
id: string;
|
|
67
|
-
email: string;
|
|
68
|
-
name: string;
|
|
69
|
-
orgId?: string;
|
|
70
|
-
};
|
|
71
|
-
error_code?: string;
|
|
72
|
-
message?: string;
|
|
73
|
-
}
|
|
74
62
|
export interface LogoutResponse {
|
|
75
63
|
success: boolean;
|
|
76
64
|
error_code?: string;
|
|
@@ -26,6 +26,19 @@ export interface CreateUnitRequest {
|
|
|
26
26
|
endpoint?: string;
|
|
27
27
|
region?: string;
|
|
28
28
|
}
|
|
29
|
+
export interface GetUnitNodeStatsRequest {
|
|
30
|
+
day: Date;
|
|
31
|
+
}
|
|
32
|
+
export interface GetUnitNodeStatsResponse {
|
|
33
|
+
success: boolean;
|
|
34
|
+
nodeStats: UnitNodeStatsDailyInfo[];
|
|
35
|
+
}
|
|
36
|
+
export interface UnitNodeStatsDailyInfo {
|
|
37
|
+
ip: string;
|
|
38
|
+
host: string;
|
|
39
|
+
perc_uptime: number;
|
|
40
|
+
avg_latency_ms: number;
|
|
41
|
+
}
|
|
29
42
|
export interface UpdateUnitRequest extends CreateUnitRequest {
|
|
30
43
|
}
|
|
31
44
|
export interface CreateUnitResponse {
|