@staticbackend/backend 1.4.3 → 1.5.0-alpha.0

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 CHANGED
@@ -101,10 +101,18 @@ export declare class Backend {
101
101
  ok: boolean;
102
102
  content: any;
103
103
  }>;
104
+ deleteBulk(token: string, repo: string, filters: any): Promise<{
105
+ ok: boolean;
106
+ content: any;
107
+ }>;
104
108
  count(token: string, repo: string, filters: any): Promise<{
105
109
  ok: boolean;
106
110
  content: any;
107
111
  }>;
112
+ search(token: string, repo: string, keywords: string): Promise<{
113
+ ok: boolean;
114
+ content: any;
115
+ }>;
108
116
  sudoList(rootToken: string, repo: string, param?: ListParam): Promise<{
109
117
  ok: boolean;
110
118
  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) {
@@ -161,11 +161,23 @@ class Backend {
161
161
  return yield this.req(token, "DELETE", `/db/${repo}/${id}`);
162
162
  });
163
163
  }
164
+ deleteBulk(token, repo, filters) {
165
+ return __awaiter(this, void 0, void 0, function* () {
166
+ const x = Buffer.from(JSON.stringify(filters)).toString("base64");
167
+ return yield this.req(token, "DELETE", `/db/${repo}?bulk=1&x=${x}`);
168
+ });
169
+ }
164
170
  count(token, repo, filters) {
165
171
  return __awaiter(this, void 0, void 0, function* () {
166
172
  return yield this.req(token, "POST", `/db/count/${repo}`, filters);
167
173
  });
168
174
  }
175
+ search(token, repo, keywords) {
176
+ return __awaiter(this, void 0, void 0, function* () {
177
+ const data = { col: repo, keywords: keywords };
178
+ return yield this.req(token, "POST", "/search", data);
179
+ });
180
+ }
169
181
  sudoList(rootToken, repo, param) {
170
182
  return __awaiter(this, void 0, void 0, function* () {
171
183
  const qs = this.listParamToQuerystring(param);
@@ -205,7 +217,7 @@ class Backend {
205
217
  let fd = new formData();
206
218
  fd.append("file", buf, {
207
219
  contentType: "application/octect-stream",
208
- filename: "file-upload"
220
+ filename: "file-upload",
209
221
  });
210
222
  const ct = `multipart/form-data; boundary=${fd.getBoundary()}`;
211
223
  return yield this.rawreq(ct, token, "POST", "/storage/upload", fd);
@@ -226,7 +238,7 @@ class Backend {
226
238
  let fd = new formData();
227
239
  fd.append("file", buf, {
228
240
  contentType: "application/octect-stream",
229
- filename: "file-upload"
241
+ filename: "file-upload",
230
242
  });
231
243
  fd.append("width", maxWidth);
232
244
  const ct = `multipart/form-data; boundary=${fd.getBoundary()}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@staticbackend/backend",
3
- "version": "1.4.3",
3
+ "version": "1.5.0-alpha.0",
4
4
  "description": "Client library for StaticBackend API",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {