@flashbacktech/flashbackclient 0.0.34 → 0.0.36
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.js +30 -15
- package/dist/api/types.d.ts +0 -2
- package/package.json +1 -1
package/dist/api/client.js
CHANGED
|
@@ -40,9 +40,11 @@ class ApiClient {
|
|
|
40
40
|
headers: this.headers,
|
|
41
41
|
body: JSON.stringify({ token }),
|
|
42
42
|
});
|
|
43
|
-
if (!response.ok)
|
|
43
|
+
if (!response.ok) {
|
|
44
44
|
throw new Error(`HTTP error! status: ${response.status}`);
|
|
45
|
-
|
|
45
|
+
}
|
|
46
|
+
const ret = await response.json();
|
|
47
|
+
return ret;
|
|
46
48
|
};
|
|
47
49
|
this.authenticateGithub = async (code) => {
|
|
48
50
|
this.setAuthToken(code);
|
|
@@ -51,9 +53,11 @@ class ApiClient {
|
|
|
51
53
|
headers: this.headers,
|
|
52
54
|
body: JSON.stringify({ code }),
|
|
53
55
|
});
|
|
54
|
-
if (!response.ok)
|
|
56
|
+
if (!response.ok) {
|
|
55
57
|
throw new Error(`HTTP error! status: ${response.status}`);
|
|
56
|
-
|
|
58
|
+
}
|
|
59
|
+
const ret = await response.json();
|
|
60
|
+
return ret;
|
|
57
61
|
};
|
|
58
62
|
this.createStorageUnit = async (data) => {
|
|
59
63
|
const response = await fetch(`${this.baseURL}/unit`, {
|
|
@@ -61,9 +65,11 @@ class ApiClient {
|
|
|
61
65
|
headers: this.headers,
|
|
62
66
|
body: JSON.stringify(data),
|
|
63
67
|
});
|
|
64
|
-
if (!response.ok)
|
|
68
|
+
if (!response.ok) {
|
|
65
69
|
throw new Error(`HTTP error! status: ${response.status}`);
|
|
66
|
-
|
|
70
|
+
}
|
|
71
|
+
const ret = await response.json();
|
|
72
|
+
return ret;
|
|
67
73
|
};
|
|
68
74
|
this.getStorageUnits = async () => {
|
|
69
75
|
const response = await fetch(`${this.baseURL}/unit`, {
|
|
@@ -73,7 +79,8 @@ class ApiClient {
|
|
|
73
79
|
if (!response.ok) {
|
|
74
80
|
throw new Error(`HTTP error! status: ${response.status}`);
|
|
75
81
|
}
|
|
76
|
-
|
|
82
|
+
const ret = await response.json();
|
|
83
|
+
return ret;
|
|
77
84
|
};
|
|
78
85
|
this.createRepo = async (data) => {
|
|
79
86
|
const response = await fetch(`${this.baseURL}/repo`, {
|
|
@@ -81,18 +88,22 @@ class ApiClient {
|
|
|
81
88
|
headers: this.headers,
|
|
82
89
|
body: JSON.stringify(data),
|
|
83
90
|
});
|
|
84
|
-
if (!response.ok)
|
|
91
|
+
if (!response.ok) {
|
|
85
92
|
throw new Error(`HTTP error! status: ${response.status}`);
|
|
86
|
-
|
|
93
|
+
}
|
|
94
|
+
const ret = await response.json();
|
|
95
|
+
return ret;
|
|
87
96
|
};
|
|
88
97
|
this.getRepos = async () => {
|
|
89
98
|
const response = await fetch(`${this.baseURL}/repo`, {
|
|
90
99
|
method: 'GET',
|
|
91
100
|
headers: this.headers,
|
|
92
101
|
});
|
|
93
|
-
if (!response.ok)
|
|
102
|
+
if (!response.ok) {
|
|
94
103
|
throw new Error(`HTTP error! status: ${response.status}`);
|
|
95
|
-
|
|
104
|
+
}
|
|
105
|
+
const ret = await response.json();
|
|
106
|
+
return ret;
|
|
96
107
|
};
|
|
97
108
|
this.createRepoKey = async (data) => {
|
|
98
109
|
const response = await fetch(`${this.baseURL}/repo/${data.repoId}/apikey`, {
|
|
@@ -100,18 +111,22 @@ class ApiClient {
|
|
|
100
111
|
headers: this.headers,
|
|
101
112
|
body: JSON.stringify(data),
|
|
102
113
|
});
|
|
103
|
-
if (!response.ok)
|
|
114
|
+
if (!response.ok) {
|
|
104
115
|
throw new Error(`HTTP error! status: ${response.status}`);
|
|
105
|
-
|
|
116
|
+
}
|
|
117
|
+
const ret = await response.json();
|
|
118
|
+
return ret;
|
|
106
119
|
};
|
|
107
120
|
this.getRepoKeys = async (repoId) => {
|
|
108
121
|
const response = await fetch(`${this.baseURL}/repo/${repoId}/apikey`, {
|
|
109
122
|
method: 'GET',
|
|
110
123
|
headers: this.headers,
|
|
111
124
|
});
|
|
112
|
-
if (!response.ok)
|
|
125
|
+
if (!response.ok) {
|
|
113
126
|
throw new Error(`HTTP error! status: ${response.status}`);
|
|
114
|
-
|
|
127
|
+
}
|
|
128
|
+
const ret = await response.json();
|
|
129
|
+
return ret;
|
|
115
130
|
};
|
|
116
131
|
this.baseURL = baseURL;
|
|
117
132
|
this.headers = {
|
package/dist/api/types.d.ts
CHANGED
|
@@ -15,7 +15,6 @@ export declare enum ModeType {
|
|
|
15
15
|
export interface CreateUnitRequest {
|
|
16
16
|
name: string;
|
|
17
17
|
bucket: string;
|
|
18
|
-
storageTypeId: string;
|
|
19
18
|
storageType: StorageType;
|
|
20
19
|
key: string;
|
|
21
20
|
secret: string;
|
|
@@ -70,7 +69,6 @@ export interface StorageUnit {
|
|
|
70
69
|
id: string;
|
|
71
70
|
name: string;
|
|
72
71
|
bucket: string;
|
|
73
|
-
storageTypeId: string;
|
|
74
72
|
storageType: StorageType;
|
|
75
73
|
key: string;
|
|
76
74
|
secret: string;
|