@flashbacktech/flashbackclient 0.0.55 → 0.0.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 +2 -1
- package/dist/api/client.js +10 -8
- package/dist/api/interfaces.d.ts +2 -1
- package/dist/api/types/storage.d.ts +10 -2
- package/package.json +1 -1
package/dist/api/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CreateUnitRequest, CreateUnitResponse, CreateRepoRequest, CreateRepoResponse, CreateRepoKeyRequest, CreateRepoKeyResponse, GetUnitsResponse, GetReposResponse, GetRepoKeysResponse, UpdateUnitRequest, UpdateUnitResponse, ActionResponse, UpdateRepoRequest, UpdateRepoResponse, UpdateRepoKeyRequest, UpdateRepoKeyResponse } from './types/storage';
|
|
1
|
+
import { CreateUnitRequest, CreateUnitResponse, CreateRepoRequest, CreateRepoResponse, CreateRepoKeyRequest, CreateRepoKeyResponse, GetUnitsResponse, GetReposResponse, GetRepoKeysResponse, UpdateUnitRequest, UpdateUnitResponse, ActionResponse, UpdateRepoRequest, UpdateRepoResponse, UpdateRepoKeyRequest, UpdateRepoKeyResponse, ValidateUnitRequest, ValidateUnitResponse } from './types/storage';
|
|
2
2
|
import { IApiClient, ProviderType } from './interfaces';
|
|
3
3
|
import { OAuth2ResponseDTO, RefreshTokenResponse } from './types/auth';
|
|
4
4
|
interface ErrorResponse {
|
|
@@ -37,6 +37,7 @@ export declare class ApiClient implements IApiClient {
|
|
|
37
37
|
private exchangeGoogleCode;
|
|
38
38
|
createStorageUnit: (data: CreateUnitRequest) => Promise<CreateUnitResponse>;
|
|
39
39
|
getStorageUnits: () => Promise<GetUnitsResponse>;
|
|
40
|
+
validateStorageUnit: (unitId: string, data: ValidateUnitRequest) => Promise<ValidateUnitResponse>;
|
|
40
41
|
updateStorageUnit: (unitId: string, data: UpdateUnitRequest) => Promise<UpdateUnitResponse>;
|
|
41
42
|
deleteStorageUnit: (unitId: string) => Promise<ActionResponse>;
|
|
42
43
|
createRepo: (data: CreateRepoRequest) => Promise<CreateRepoResponse>;
|
package/dist/api/client.js
CHANGED
|
@@ -24,11 +24,6 @@ class ApiClient {
|
|
|
24
24
|
Authorization: `Bearer ${token}`,
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
-
else {
|
|
28
|
-
this.headers = {
|
|
29
|
-
'Content-Type': 'application/json',
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
27
|
};
|
|
33
28
|
this.authenticate = async (token, provider) => {
|
|
34
29
|
this.setAuthToken(token);
|
|
@@ -87,6 +82,12 @@ class ApiClient {
|
|
|
87
82
|
headers: this.headers,
|
|
88
83
|
body: data ? JSON.stringify(data) : null,
|
|
89
84
|
};
|
|
85
|
+
if (data) {
|
|
86
|
+
options.headers = {
|
|
87
|
+
...options.headers,
|
|
88
|
+
'Content-Type': 'application/json',
|
|
89
|
+
};
|
|
90
|
+
}
|
|
90
91
|
const cleanPath = path.startsWith('/') ? path.substring(1) : path;
|
|
91
92
|
if (this.debug) {
|
|
92
93
|
console.log(`DEBUG: ${method} ${cleanPath} ${JSON.stringify(data)}`);
|
|
@@ -144,6 +145,9 @@ class ApiClient {
|
|
|
144
145
|
this.getStorageUnits = async () => {
|
|
145
146
|
return this.makeRequest('unit', 'GET', null);
|
|
146
147
|
};
|
|
148
|
+
this.validateStorageUnit = async (unitId, data) => {
|
|
149
|
+
return this.makeRequest(`unit/${unitId}/validate`, 'POST', data);
|
|
150
|
+
};
|
|
147
151
|
this.updateStorageUnit = async (unitId, data) => {
|
|
148
152
|
return this.makeRequest(`unit/${unitId}`, 'PUT', data);
|
|
149
153
|
};
|
|
@@ -177,9 +181,7 @@ class ApiClient {
|
|
|
177
181
|
return this.makeRequest(`repo/${repoId}/apikey/${keyId}`, 'DELETE', null);
|
|
178
182
|
};
|
|
179
183
|
this.baseURL = baseURL;
|
|
180
|
-
this.headers = {
|
|
181
|
-
'Content-Type': 'application/json',
|
|
182
|
-
};
|
|
184
|
+
this.headers = {};
|
|
183
185
|
this.debug = false;
|
|
184
186
|
}
|
|
185
187
|
}
|
package/dist/api/interfaces.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CreateUnitRequest, CreateUnitResponse, CreateRepoRequest, CreateRepoResponse, CreateRepoKeyRequest, CreateRepoKeyResponse, GetUnitsResponse, GetReposResponse, GetRepoKeysResponse, UpdateUnitRequest, UpdateUnitResponse, ActionResponse, UpdateRepoResponse, UpdateRepoRequest, UpdateRepoKeyRequest, UpdateRepoKeyResponse } from "./types/storage";
|
|
1
|
+
import { CreateUnitRequest, CreateUnitResponse, CreateRepoRequest, CreateRepoResponse, CreateRepoKeyRequest, CreateRepoKeyResponse, GetUnitsResponse, GetReposResponse, GetRepoKeysResponse, UpdateUnitRequest, UpdateUnitResponse, ActionResponse, UpdateRepoResponse, UpdateRepoRequest, UpdateRepoKeyRequest, UpdateRepoKeyResponse, ValidateUnitRequest, ValidateUnitResponse } from "./types/storage";
|
|
2
2
|
export declare enum ProviderType {
|
|
3
3
|
GOOGLE = "GOOGLE",
|
|
4
4
|
GITHUB = "GITHUB",
|
|
@@ -10,6 +10,7 @@ export interface IApiClient {
|
|
|
10
10
|
getStorageUnits(): Promise<GetUnitsResponse>;
|
|
11
11
|
updateStorageUnit(unitId: string, data: UpdateUnitRequest): Promise<UpdateUnitResponse>;
|
|
12
12
|
deleteStorageUnit(unitId: string): Promise<ActionResponse>;
|
|
13
|
+
validateStorageUnit(unitId: string, data: ValidateUnitRequest): Promise<ValidateUnitResponse>;
|
|
13
14
|
createRepo(data: CreateRepoRequest): Promise<CreateRepoResponse>;
|
|
14
15
|
getRepos(): Promise<GetReposResponse>;
|
|
15
16
|
updateRepo(repoId: string, data: UpdateRepoRequest): Promise<UpdateRepoResponse>;
|
|
@@ -87,9 +87,7 @@ export interface StorageUnit {
|
|
|
87
87
|
bucket: string;
|
|
88
88
|
storageType: StorageType;
|
|
89
89
|
key: string;
|
|
90
|
-
secret: string;
|
|
91
90
|
endpoint?: string;
|
|
92
|
-
regionId?: string;
|
|
93
91
|
}
|
|
94
92
|
export interface GetUnitsResponse {
|
|
95
93
|
success: boolean;
|
|
@@ -103,3 +101,13 @@ export interface GetRepoKeysResponse {
|
|
|
103
101
|
success: boolean;
|
|
104
102
|
keys: ApiKey[];
|
|
105
103
|
}
|
|
104
|
+
export interface ValidateUnitRequest {
|
|
105
|
+
key: string;
|
|
106
|
+
secret: string;
|
|
107
|
+
endpoint?: string;
|
|
108
|
+
bucket: string;
|
|
109
|
+
}
|
|
110
|
+
export interface ValidateUnitResponse {
|
|
111
|
+
success: boolean;
|
|
112
|
+
message?: string;
|
|
113
|
+
}
|