@backwrite/sdk 0.2.2 → 0.3.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/README.md +49 -23
- package/dist/agents.d.ts +207 -0
- package/dist/agents.d.ts.map +1 -0
- package/dist/agents.js +340 -0
- package/dist/agents.js.map +1 -0
- package/dist/client.d.ts +4 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +43 -3
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/services.d.ts +9 -8
- package/dist/services.d.ts.map +1 -1
- package/dist/services.js +28 -29
- package/dist/services.js.map +1 -1
- package/package.json +20 -2
- package/src/agents.ts +476 -0
- package/src/client.ts +47 -3
- package/src/index.ts +1 -0
- package/src/services.ts +28 -29
package/src/services.ts
CHANGED
|
@@ -240,22 +240,19 @@ export class BranchesService {
|
|
|
240
240
|
});
|
|
241
241
|
}
|
|
242
242
|
|
|
243
|
-
delete(branchId: string,
|
|
244
|
-
|
|
245
|
-
return this.client.request("DELETE", `/v1/projects/${pid}/branches/${encodeURIComponent(branchId)}`);
|
|
243
|
+
delete(branchId: string, _projectId?: string): Promise<unknown> {
|
|
244
|
+
return this.client.request("DELETE", `/v1/branches/${encodeURIComponent(branchId)}`, { body: {} });
|
|
246
245
|
}
|
|
247
246
|
|
|
248
247
|
listSnapshots(scope: ScopeOptions = {}): Promise<unknown> {
|
|
249
|
-
const pid = requireId(scope.projectId ?? this.client.projectId, "projectId");
|
|
250
248
|
const bid = requireId(scope.branchId ?? this.client.branchId, "branchId");
|
|
251
|
-
return this.client.request("GET", `/v1/
|
|
249
|
+
return this.client.request("GET", `/v1/branches/${bid}/snapshots`);
|
|
252
250
|
}
|
|
253
251
|
|
|
254
|
-
createSnapshot(
|
|
255
|
-
const pid = requireId(scope.projectId ?? this.client.projectId, "projectId");
|
|
252
|
+
createSnapshot(kind = "manual", scope: ScopeOptions = {}): Promise<unknown> {
|
|
256
253
|
const bid = requireId(scope.branchId ?? this.client.branchId, "branchId");
|
|
257
|
-
return this.client.request("POST", `/v1/
|
|
258
|
-
body: {
|
|
254
|
+
return this.client.request("POST", `/v1/branches/${bid}/snapshot`, {
|
|
255
|
+
body: { kind },
|
|
259
256
|
});
|
|
260
257
|
}
|
|
261
258
|
}
|
|
@@ -275,28 +272,28 @@ export class StorageService {
|
|
|
275
272
|
});
|
|
276
273
|
}
|
|
277
274
|
|
|
278
|
-
upload(
|
|
275
|
+
upload(_bucket: string, key: string, data: Uint8Array | ArrayBuffer | string, branchId?: string): Promise<unknown> {
|
|
279
276
|
const bid = requireId(branchId ?? this.client.branchId, "branchId");
|
|
280
277
|
return this.client.request(
|
|
281
278
|
"PUT",
|
|
282
|
-
`/v1/storage/${bid}/${
|
|
279
|
+
`/v1/storage/${bid}/objects/${key.replace(/^\/+/, "")}`,
|
|
283
280
|
{ body: data },
|
|
284
281
|
);
|
|
285
282
|
}
|
|
286
283
|
|
|
287
|
-
download(
|
|
284
|
+
download(_bucket: string, key: string, branchId?: string): Promise<unknown> {
|
|
288
285
|
const bid = requireId(branchId ?? this.client.branchId, "branchId");
|
|
289
286
|
return this.client.request(
|
|
290
287
|
"GET",
|
|
291
|
-
`/v1/storage/${bid}/${
|
|
288
|
+
`/v1/storage/${bid}/objects/${key.replace(/^\/+/, "")}`,
|
|
292
289
|
);
|
|
293
290
|
}
|
|
294
291
|
|
|
295
|
-
deleteObject(
|
|
292
|
+
deleteObject(_bucket: string, key: string, branchId?: string): Promise<unknown> {
|
|
296
293
|
const bid = requireId(branchId ?? this.client.branchId, "branchId");
|
|
297
294
|
return this.client.request(
|
|
298
295
|
"DELETE",
|
|
299
|
-
`/v1/storage/${bid}/${
|
|
296
|
+
`/v1/storage/${bid}/objects/${key.replace(/^\/+/, "")}`,
|
|
300
297
|
);
|
|
301
298
|
}
|
|
302
299
|
}
|
|
@@ -306,19 +303,20 @@ export class CacheService {
|
|
|
306
303
|
|
|
307
304
|
get(key: string, branchId?: string): Promise<unknown> {
|
|
308
305
|
const bid = requireId(branchId ?? this.client.branchId, "branchId");
|
|
309
|
-
return this.client.request("GET", `/v1/cache/${bid}/
|
|
306
|
+
return this.client.request("GET", `/v1/cache/${bid}/entries/${encodeURIComponent(key)}`);
|
|
310
307
|
}
|
|
311
308
|
|
|
312
309
|
set(key: string, value: unknown, ttlSeconds?: number, branchId?: string): Promise<unknown> {
|
|
313
310
|
const bid = requireId(branchId ?? this.client.branchId, "branchId");
|
|
314
|
-
return this.client.request("PUT", `/v1/cache/${bid}/
|
|
315
|
-
|
|
311
|
+
return this.client.request("PUT", `/v1/cache/${bid}/entries/${encodeURIComponent(key)}`, {
|
|
312
|
+
query: ttlSeconds !== undefined ? { ttl: ttlSeconds } : undefined,
|
|
313
|
+
body: { value },
|
|
316
314
|
});
|
|
317
315
|
}
|
|
318
316
|
|
|
319
317
|
del(key: string, branchId?: string): Promise<unknown> {
|
|
320
318
|
const bid = requireId(branchId ?? this.client.branchId, "branchId");
|
|
321
|
-
return this.client.request("DELETE", `/v1/cache/${bid}/
|
|
319
|
+
return this.client.request("DELETE", `/v1/cache/${bid}/entries/${encodeURIComponent(key)}`);
|
|
322
320
|
}
|
|
323
321
|
}
|
|
324
322
|
|
|
@@ -327,14 +325,14 @@ export class QueuesService {
|
|
|
327
325
|
|
|
328
326
|
publish(queue: string, payload: unknown, branchId?: string): Promise<unknown> {
|
|
329
327
|
const bid = requireId(branchId ?? this.client.branchId, "branchId");
|
|
330
|
-
return this.client.request("POST", `/v1/queues/${bid}/${encodeURIComponent(queue)}
|
|
328
|
+
return this.client.request("POST", `/v1/queues/${bid}/${encodeURIComponent(queue)}`, {
|
|
331
329
|
body: { payload },
|
|
332
330
|
});
|
|
333
331
|
}
|
|
334
332
|
|
|
335
333
|
pull(queue: string, batch = 1, branchId?: string): Promise<unknown> {
|
|
336
334
|
const bid = requireId(branchId ?? this.client.branchId, "branchId");
|
|
337
|
-
return this.client.request("POST", `/v1/queues/${bid}/${encodeURIComponent(queue)}/
|
|
335
|
+
return this.client.request("POST", `/v1/queues/${bid}/${encodeURIComponent(queue)}/fetch`, {
|
|
338
336
|
body: { batch },
|
|
339
337
|
});
|
|
340
338
|
}
|
|
@@ -346,9 +344,9 @@ export class QueuesService {
|
|
|
346
344
|
});
|
|
347
345
|
}
|
|
348
346
|
|
|
349
|
-
stats(queue = "default",
|
|
350
|
-
const
|
|
351
|
-
return this.client.request("GET", `/v1/
|
|
347
|
+
stats(queue = "default", branchId?: string): Promise<unknown> {
|
|
348
|
+
const bid = requireId(branchId ?? this.client.branchId, "branchId");
|
|
349
|
+
return this.client.request("GET", `/v1/queues/${bid}/${encodeURIComponent(queue)}/stats`);
|
|
352
350
|
}
|
|
353
351
|
}
|
|
354
352
|
|
|
@@ -403,17 +401,18 @@ export class SecretsService {
|
|
|
403
401
|
|
|
404
402
|
list(projectId?: string): Promise<unknown> {
|
|
405
403
|
const pid = requireId(projectId ?? this.client.projectId, "projectId");
|
|
406
|
-
return this.client.request("GET", `/v1/projects/${pid}/
|
|
404
|
+
return this.client.request("GET", `/v1/projects/${pid}/secrets`);
|
|
407
405
|
}
|
|
408
406
|
|
|
409
|
-
set(
|
|
407
|
+
set(name: string, value: string, projectId?: string, environment = "production"): Promise<unknown> {
|
|
410
408
|
const pid = requireId(projectId ?? this.client.projectId, "projectId");
|
|
411
|
-
return this.client.request("POST", `/v1/projects/${pid}/
|
|
409
|
+
return this.client.request("POST", `/v1/projects/${pid}/secrets`, { body: { name, value, environment } });
|
|
412
410
|
}
|
|
413
411
|
|
|
414
|
-
|
|
412
|
+
/** Delete by secret id (`sec_…`). */
|
|
413
|
+
delete(secretId: string, projectId?: string): Promise<unknown> {
|
|
415
414
|
const pid = requireId(projectId ?? this.client.projectId, "projectId");
|
|
416
|
-
return this.client.request("DELETE", `/v1/projects/${pid}/
|
|
415
|
+
return this.client.request("DELETE", `/v1/projects/${pid}/secrets/${encodeURIComponent(secretId)}`);
|
|
417
416
|
}
|
|
418
417
|
}
|
|
419
418
|
|