@staticbackend/backend 1.4.3 → 1.5.0-alpha.3
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/backend.d.ts +20 -0
- package/dist/backend.js +32 -4
- package/package.json +1 -1
package/dist/backend.d.ts
CHANGED
|
@@ -61,6 +61,18 @@ export declare class Backend {
|
|
|
61
61
|
ok: boolean;
|
|
62
62
|
content: any;
|
|
63
63
|
}>;
|
|
64
|
+
addUser(token: string, email: string, password: string): Promise<{
|
|
65
|
+
ok: boolean;
|
|
66
|
+
content: any;
|
|
67
|
+
}>;
|
|
68
|
+
removeUser(token: string, userId: string): Promise<{
|
|
69
|
+
ok: boolean;
|
|
70
|
+
content: any;
|
|
71
|
+
}>;
|
|
72
|
+
users(token: string): Promise<{
|
|
73
|
+
ok: boolean;
|
|
74
|
+
content: any;
|
|
75
|
+
}>;
|
|
64
76
|
cacheGet(rootToken: string, key: string): Promise<{
|
|
65
77
|
ok: boolean;
|
|
66
78
|
content: any;
|
|
@@ -101,10 +113,18 @@ export declare class Backend {
|
|
|
101
113
|
ok: boolean;
|
|
102
114
|
content: any;
|
|
103
115
|
}>;
|
|
116
|
+
deleteBulk(token: string, repo: string, filters: any): Promise<{
|
|
117
|
+
ok: boolean;
|
|
118
|
+
content: any;
|
|
119
|
+
}>;
|
|
104
120
|
count(token: string, repo: string, filters: any): Promise<{
|
|
105
121
|
ok: boolean;
|
|
106
122
|
content: any;
|
|
107
123
|
}>;
|
|
124
|
+
search(token: string, repo: string, keywords: string): Promise<{
|
|
125
|
+
ok: boolean;
|
|
126
|
+
content: any;
|
|
127
|
+
}>;
|
|
108
128
|
sudoList(rootToken: string, repo: string, param?: ListParam): Promise<{
|
|
109
129
|
ok: boolean;
|
|
110
130
|
content: any;
|
package/dist/backend.js
CHANGED
|
@@ -39,7 +39,7 @@ class Backend {
|
|
|
39
39
|
}
|
|
40
40
|
let headers = {
|
|
41
41
|
"Content-Type": ct,
|
|
42
|
-
"SB-PUBLIC-KEY": this.pubKey
|
|
42
|
+
"SB-PUBLIC-KEY": this.pubKey,
|
|
43
43
|
};
|
|
44
44
|
if (token) {
|
|
45
45
|
headers["Authorization"] = `Bearer ${token}`;
|
|
@@ -47,7 +47,7 @@ class Backend {
|
|
|
47
47
|
const resp = yield fetch(`${this.baseURL}${path}`, {
|
|
48
48
|
method: method,
|
|
49
49
|
headers: headers,
|
|
50
|
-
body: rawBody
|
|
50
|
+
body: rawBody,
|
|
51
51
|
});
|
|
52
52
|
var content = null;
|
|
53
53
|
if (resp.status > 299) {
|
|
@@ -108,6 +108,22 @@ class Backend {
|
|
|
108
108
|
return yield this.req(token, "GET", "/me");
|
|
109
109
|
});
|
|
110
110
|
}
|
|
111
|
+
addUser(token, email, password) {
|
|
112
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
113
|
+
const body = { email: email, password: password };
|
|
114
|
+
return yield this.req(token, "POST", "/account/users", body);
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
removeUser(token, userId) {
|
|
118
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
119
|
+
return yield this.req(token, "DELETE", `/account/users/${userId}`);
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
users(token) {
|
|
123
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
124
|
+
return yield this.req(token, "GET", "/account/users");
|
|
125
|
+
});
|
|
126
|
+
}
|
|
111
127
|
cacheGet(rootToken, key) {
|
|
112
128
|
return __awaiter(this, void 0, void 0, function* () {
|
|
113
129
|
return yield this.req(rootToken, "GET", `/sudo/cache?key=${key}`);
|
|
@@ -161,11 +177,23 @@ class Backend {
|
|
|
161
177
|
return yield this.req(token, "DELETE", `/db/${repo}/${id}`);
|
|
162
178
|
});
|
|
163
179
|
}
|
|
180
|
+
deleteBulk(token, repo, filters) {
|
|
181
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
182
|
+
const x = Buffer.from(JSON.stringify(filters)).toString("base64");
|
|
183
|
+
return yield this.req(token, "DELETE", `/db/${repo}?bulk=1&x=${x}`);
|
|
184
|
+
});
|
|
185
|
+
}
|
|
164
186
|
count(token, repo, filters) {
|
|
165
187
|
return __awaiter(this, void 0, void 0, function* () {
|
|
166
188
|
return yield this.req(token, "POST", `/db/count/${repo}`, filters);
|
|
167
189
|
});
|
|
168
190
|
}
|
|
191
|
+
search(token, repo, keywords) {
|
|
192
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
193
|
+
const data = { col: repo, keywords: keywords };
|
|
194
|
+
return yield this.req(token, "POST", "/search", data);
|
|
195
|
+
});
|
|
196
|
+
}
|
|
169
197
|
sudoList(rootToken, repo, param) {
|
|
170
198
|
return __awaiter(this, void 0, void 0, function* () {
|
|
171
199
|
const qs = this.listParamToQuerystring(param);
|
|
@@ -205,7 +233,7 @@ class Backend {
|
|
|
205
233
|
let fd = new formData();
|
|
206
234
|
fd.append("file", buf, {
|
|
207
235
|
contentType: "application/octect-stream",
|
|
208
|
-
filename: "file-upload"
|
|
236
|
+
filename: "file-upload",
|
|
209
237
|
});
|
|
210
238
|
const ct = `multipart/form-data; boundary=${fd.getBoundary()}`;
|
|
211
239
|
return yield this.rawreq(ct, token, "POST", "/storage/upload", fd);
|
|
@@ -226,7 +254,7 @@ class Backend {
|
|
|
226
254
|
let fd = new formData();
|
|
227
255
|
fd.append("file", buf, {
|
|
228
256
|
contentType: "application/octect-stream",
|
|
229
|
-
filename: "file-upload"
|
|
257
|
+
filename: "file-upload",
|
|
230
258
|
});
|
|
231
259
|
fd.append("width", maxWidth);
|
|
232
260
|
const ct = `multipart/form-data; boundary=${fd.getBoundary()}`;
|