@flashbacktech/flashbackclient 0.0.45 → 0.0.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 +8 -1
- package/dist/api/client.js +35 -52
- package/dist/api/interfaces.d.ts +7 -1
- package/dist/api/types/auth.d.ts +3 -2
- package/dist/api/types/storage.d.ts +16 -0
- 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 } from './types/storage';
|
|
1
|
+
import { CreateUnitRequest, CreateUnitResponse, CreateRepoRequest, CreateRepoResponse, CreateRepoKeyRequest, CreateRepoKeyResponse, GetUnitsResponse, GetReposResponse, GetRepoKeysResponse, UpdateUnitRequest, UpdateUnitResponse, ActionResponse, UpdateRepoRequest, UpdateRepoResponse, UpdateRepoKeyRequest, UpdateRepoKeyResponse } from './types/storage';
|
|
2
2
|
import { IApiClient, ProviderType } from './interfaces';
|
|
3
3
|
export declare class ApiClient implements IApiClient {
|
|
4
4
|
private baseURL;
|
|
@@ -21,10 +21,17 @@ export declare class ApiClient implements IApiClient {
|
|
|
21
21
|
private authenticateGoogle;
|
|
22
22
|
private authenticateGithub;
|
|
23
23
|
private refreshTokenGoogle;
|
|
24
|
+
private makeRequest;
|
|
24
25
|
createStorageUnit: (data: CreateUnitRequest) => Promise<CreateUnitResponse>;
|
|
25
26
|
getStorageUnits: () => Promise<GetUnitsResponse>;
|
|
27
|
+
updateStorageUnit: (unitId: string, data: UpdateUnitRequest) => Promise<UpdateUnitResponse>;
|
|
28
|
+
deleteStorageUnit: (unitId: string) => Promise<ActionResponse>;
|
|
26
29
|
createRepo: (data: CreateRepoRequest) => Promise<CreateRepoResponse>;
|
|
27
30
|
getRepos: () => Promise<GetReposResponse>;
|
|
31
|
+
updateRepo: (repoId: string, data: UpdateRepoRequest) => Promise<UpdateRepoResponse>;
|
|
32
|
+
deleteRepo: (repoId: string) => Promise<ActionResponse>;
|
|
28
33
|
createRepoKey: (data: CreateRepoKeyRequest) => Promise<CreateRepoKeyResponse>;
|
|
29
34
|
getRepoKeys: (repoId: string) => Promise<GetRepoKeysResponse>;
|
|
35
|
+
updateRepoKey: (repoId: string, data: UpdateRepoKeyRequest) => Promise<UpdateRepoKeyResponse>;
|
|
36
|
+
deleteRepoKey: (repoId: string, keyId: string) => Promise<ActionResponse>;
|
|
30
37
|
}
|
package/dist/api/client.js
CHANGED
|
@@ -118,74 +118,57 @@ class ApiClient {
|
|
|
118
118
|
const ret = await response.json();
|
|
119
119
|
return ret;
|
|
120
120
|
};
|
|
121
|
-
this.
|
|
122
|
-
const
|
|
123
|
-
method
|
|
121
|
+
this.makeRequest = async (path, method, data) => {
|
|
122
|
+
const options = {
|
|
123
|
+
method,
|
|
124
124
|
headers: this.headers,
|
|
125
|
-
body: JSON.stringify(data),
|
|
126
|
-
}
|
|
125
|
+
body: data ? JSON.stringify(data) : null,
|
|
126
|
+
};
|
|
127
|
+
const response = await fetch(`${this.baseURL}/${path}`, options);
|
|
127
128
|
if (!response.ok) {
|
|
128
129
|
throw new Error(`HTTP error! status: ${response.status}`);
|
|
129
130
|
}
|
|
130
131
|
const ret = await response.json();
|
|
131
132
|
return ret;
|
|
132
133
|
};
|
|
134
|
+
////// Units API
|
|
135
|
+
this.createStorageUnit = async (data) => {
|
|
136
|
+
return this.makeRequest('unit', 'POST', data);
|
|
137
|
+
};
|
|
133
138
|
this.getStorageUnits = async () => {
|
|
134
|
-
|
|
135
|
-
method: 'GET',
|
|
136
|
-
headers: this.headers,
|
|
137
|
-
});
|
|
138
|
-
if (!response.ok) {
|
|
139
|
-
throw new Error(`HTTP error! status: ${response.status}`);
|
|
140
|
-
}
|
|
141
|
-
const ret = await response.json();
|
|
142
|
-
return ret;
|
|
139
|
+
return this.makeRequest('unit', 'GET', {});
|
|
143
140
|
};
|
|
141
|
+
this.updateStorageUnit = async (unitId, data) => {
|
|
142
|
+
return this.makeRequest(`unit/${unitId}`, 'PUT', data);
|
|
143
|
+
};
|
|
144
|
+
this.deleteStorageUnit = async (unitId) => {
|
|
145
|
+
return this.makeRequest(`unit/${unitId}`, 'DELETE', {});
|
|
146
|
+
};
|
|
147
|
+
////// Repos API
|
|
144
148
|
this.createRepo = async (data) => {
|
|
145
|
-
|
|
146
|
-
method: 'POST',
|
|
147
|
-
headers: this.headers,
|
|
148
|
-
body: JSON.stringify(data),
|
|
149
|
-
});
|
|
150
|
-
if (!response.ok) {
|
|
151
|
-
throw new Error(`HTTP error! status: ${response.status}`);
|
|
152
|
-
}
|
|
153
|
-
const ret = await response.json();
|
|
154
|
-
return ret;
|
|
149
|
+
return this.makeRequest('repo', 'POST', data);
|
|
155
150
|
};
|
|
156
151
|
this.getRepos = async () => {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
});
|
|
161
|
-
if (!response.ok) {
|
|
162
|
-
throw new Error(`HTTP error! status: ${response.status}`);
|
|
163
|
-
}
|
|
164
|
-
const ret = await response.json();
|
|
165
|
-
return ret;
|
|
152
|
+
return this.makeRequest('repo', 'GET', {});
|
|
153
|
+
};
|
|
154
|
+
this.updateRepo = async (repoId, data) => {
|
|
155
|
+
return this.makeRequest(`repo/${repoId}`, 'PUT', data);
|
|
166
156
|
};
|
|
157
|
+
this.deleteRepo = async (repoId) => {
|
|
158
|
+
return this.makeRequest(`repo/${repoId}`, 'DELETE', {});
|
|
159
|
+
};
|
|
160
|
+
////// Keys API
|
|
167
161
|
this.createRepoKey = async (data) => {
|
|
168
|
-
|
|
169
|
-
method: 'POST',
|
|
170
|
-
headers: this.headers,
|
|
171
|
-
body: JSON.stringify(data),
|
|
172
|
-
});
|
|
173
|
-
if (!response.ok) {
|
|
174
|
-
throw new Error(`HTTP error! status: ${response.status}`);
|
|
175
|
-
}
|
|
176
|
-
const ret = await response.json();
|
|
177
|
-
return ret;
|
|
162
|
+
return this.makeRequest(`repo/${data.repoId}/apikey`, 'POST', data);
|
|
178
163
|
};
|
|
179
164
|
this.getRepoKeys = async (repoId) => {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
}
|
|
187
|
-
const ret = await response.json();
|
|
188
|
-
return ret;
|
|
165
|
+
return this.makeRequest(`repo/${repoId}/apikey`, 'GET', {});
|
|
166
|
+
};
|
|
167
|
+
this.updateRepoKey = async (repoId, data) => {
|
|
168
|
+
return this.makeRequest(`repo/${repoId}/apikey`, 'PUT', data);
|
|
169
|
+
};
|
|
170
|
+
this.deleteRepoKey = async (repoId, keyId) => {
|
|
171
|
+
return this.makeRequest(`repo/${repoId}/apikey/${keyId}`, 'DELETE', {});
|
|
189
172
|
};
|
|
190
173
|
this.baseURL = baseURL;
|
|
191
174
|
this.headers = {
|
package/dist/api/interfaces.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CreateUnitRequest, CreateUnitResponse, CreateRepoRequest, CreateRepoResponse, CreateRepoKeyRequest, CreateRepoKeyResponse, GetUnitsResponse, GetReposResponse, GetRepoKeysResponse } from "./types/storage";
|
|
1
|
+
import { CreateUnitRequest, CreateUnitResponse, CreateRepoRequest, CreateRepoResponse, CreateRepoKeyRequest, CreateRepoKeyResponse, GetUnitsResponse, GetReposResponse, GetRepoKeysResponse, UpdateUnitRequest, UpdateUnitResponse, ActionResponse, UpdateRepoResponse, UpdateRepoRequest, UpdateRepoKeyRequest, UpdateRepoKeyResponse } from "./types/storage";
|
|
2
2
|
export declare enum ProviderType {
|
|
3
3
|
GOOGLE = "GOOGLE",
|
|
4
4
|
GITHUB = "GITHUB",
|
|
@@ -8,8 +8,14 @@ export interface IApiClient {
|
|
|
8
8
|
authenticate(token: string, provider: ProviderType): Promise<any>;
|
|
9
9
|
createStorageUnit(data: CreateUnitRequest): Promise<CreateUnitResponse>;
|
|
10
10
|
getStorageUnits(): Promise<GetUnitsResponse>;
|
|
11
|
+
updateStorageUnit(unitId: string, data: UpdateUnitRequest): Promise<UpdateUnitResponse>;
|
|
12
|
+
deleteStorageUnit(unitId: string): Promise<ActionResponse>;
|
|
11
13
|
createRepo(data: CreateRepoRequest): Promise<CreateRepoResponse>;
|
|
12
14
|
getRepos(): Promise<GetReposResponse>;
|
|
15
|
+
updateRepo(repoId: string, data: UpdateRepoRequest): Promise<UpdateRepoResponse>;
|
|
16
|
+
deleteRepo(repoId: string): Promise<ActionResponse>;
|
|
13
17
|
createRepoKey(data: CreateRepoKeyRequest): Promise<CreateRepoKeyResponse>;
|
|
14
18
|
getRepoKeys(repoId: string): Promise<GetRepoKeysResponse>;
|
|
19
|
+
updateRepoKey(repoId: string, data: UpdateRepoKeyRequest): Promise<UpdateRepoKeyResponse>;
|
|
20
|
+
deleteRepoKey(repoId: string, keyId: string): Promise<ActionResponse>;
|
|
15
21
|
}
|
package/dist/api/types/auth.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ProviderType } from "../interfaces";
|
|
1
2
|
export interface AuthState {
|
|
2
3
|
user: {
|
|
3
4
|
email: string;
|
|
@@ -8,14 +9,14 @@ export interface AuthState {
|
|
|
8
9
|
accessToken: string | null;
|
|
9
10
|
refreshToken?: string | null;
|
|
10
11
|
expiresAt?: number | null;
|
|
11
|
-
provider?:
|
|
12
|
+
provider?: ProviderType;
|
|
12
13
|
}
|
|
13
14
|
export interface OAuth2ResponseDTO {
|
|
14
15
|
success: boolean;
|
|
15
16
|
authState: AuthState;
|
|
16
17
|
}
|
|
17
18
|
export interface RefreshTokenResponse {
|
|
18
|
-
|
|
19
|
+
success: boolean;
|
|
19
20
|
accessToken: string;
|
|
20
21
|
refreshToken: string;
|
|
21
22
|
expiresAt: number;
|
|
@@ -12,6 +12,10 @@ export declare enum ModeType {
|
|
|
12
12
|
NORMAL = "NORMAL",
|
|
13
13
|
MIRROR = "MIRROR"
|
|
14
14
|
}
|
|
15
|
+
export interface ActionResponse {
|
|
16
|
+
success: boolean;
|
|
17
|
+
message?: string;
|
|
18
|
+
}
|
|
15
19
|
export interface CreateUnitRequest {
|
|
16
20
|
name: string;
|
|
17
21
|
bucket: string;
|
|
@@ -21,10 +25,14 @@ export interface CreateUnitRequest {
|
|
|
21
25
|
endpoint?: string;
|
|
22
26
|
regionId?: string;
|
|
23
27
|
}
|
|
28
|
+
export interface UpdateUnitRequest extends CreateUnitRequest {
|
|
29
|
+
}
|
|
24
30
|
export interface CreateUnitResponse {
|
|
25
31
|
success: boolean;
|
|
26
32
|
unitId: string;
|
|
27
33
|
}
|
|
34
|
+
export interface UpdateUnitResponse extends CreateUnitResponse {
|
|
35
|
+
}
|
|
28
36
|
export interface RepoUnitInfo {
|
|
29
37
|
id: string;
|
|
30
38
|
folder: string;
|
|
@@ -39,6 +47,10 @@ export interface CreateRepoResponse {
|
|
|
39
47
|
success: boolean;
|
|
40
48
|
repoId: string;
|
|
41
49
|
}
|
|
50
|
+
export interface UpdateRepoRequest extends CreateRepoRequest {
|
|
51
|
+
}
|
|
52
|
+
export interface UpdateRepoResponse extends CreateRepoResponse {
|
|
53
|
+
}
|
|
42
54
|
export interface CreateRepoKeyRequest {
|
|
43
55
|
repoId: string;
|
|
44
56
|
name: string;
|
|
@@ -50,6 +62,10 @@ export interface CreateRepoKeyResponse {
|
|
|
50
62
|
key: string;
|
|
51
63
|
secret: string;
|
|
52
64
|
}
|
|
65
|
+
export interface UpdateRepoKeyRequest extends CreateRepoKeyRequest {
|
|
66
|
+
}
|
|
67
|
+
export interface UpdateRepoKeyResponse extends CreateRepoKeyResponse {
|
|
68
|
+
}
|
|
53
69
|
export interface StorageRepo {
|
|
54
70
|
id: string;
|
|
55
71
|
name: string;
|