@abraca/dabra 1.0.0 → 1.0.2
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/abracadabra-provider.cjs +53 -0
- package/dist/abracadabra-provider.cjs.map +1 -1
- package/dist/abracadabra-provider.esm.js +53 -0
- package/dist/abracadabra-provider.esm.js.map +1 -1
- package/dist/index.d.ts +35 -1
- package/package.json +1 -1
- package/src/AbracadabraClient.ts +49 -0
- package/src/FileBlobStore.ts +36 -0
- package/src/types.ts +14 -0
|
@@ -3295,6 +3295,35 @@ var AbracadabraClient = class {
|
|
|
3295
3295
|
async redeemInvite(code) {
|
|
3296
3296
|
await this.request("POST", "/invites/redeem", { body: { code } });
|
|
3297
3297
|
}
|
|
3298
|
+
/** List spaces visible to the caller. No auth required for public spaces. */
|
|
3299
|
+
async listSpaces() {
|
|
3300
|
+
return (await this.request("GET", "/spaces", { auth: false })).spaces;
|
|
3301
|
+
}
|
|
3302
|
+
/** Get a single space by ID. */
|
|
3303
|
+
async getSpace(spaceId) {
|
|
3304
|
+
return this.request("GET", `/spaces/${encodeURIComponent(spaceId)}`, { auth: false });
|
|
3305
|
+
}
|
|
3306
|
+
/** Get the hub space, or null if none is configured. */
|
|
3307
|
+
async getHubSpace() {
|
|
3308
|
+
try {
|
|
3309
|
+
return await this.request("GET", "/spaces/hub", { auth: false });
|
|
3310
|
+
} catch (e) {
|
|
3311
|
+
if (typeof e === "object" && e !== null && "status" in e && e.status === 404) return null;
|
|
3312
|
+
throw e;
|
|
3313
|
+
}
|
|
3314
|
+
}
|
|
3315
|
+
/** Create a new space (auth required). */
|
|
3316
|
+
async createSpace(opts) {
|
|
3317
|
+
return this.request("POST", "/spaces", { body: opts });
|
|
3318
|
+
}
|
|
3319
|
+
/** Update an existing space (Owner or admin required). */
|
|
3320
|
+
async updateSpace(spaceId, opts) {
|
|
3321
|
+
return this.request("PATCH", `/spaces/${encodeURIComponent(spaceId)}`, { body: opts });
|
|
3322
|
+
}
|
|
3323
|
+
/** Delete a space and its root document (Owner or admin required). */
|
|
3324
|
+
async deleteSpace(spaceId) {
|
|
3325
|
+
await this.request("DELETE", `/spaces/${encodeURIComponent(spaceId)}`);
|
|
3326
|
+
}
|
|
3298
3327
|
/** Health check — no auth required. */
|
|
3299
3328
|
async health() {
|
|
3300
3329
|
return this.request("GET", "/health", { auth: false });
|
|
@@ -7471,6 +7500,30 @@ var FileBlobStore = class extends EventEmitter {
|
|
|
7471
7500
|
this.objectUrls.set(key, url);
|
|
7472
7501
|
return url;
|
|
7473
7502
|
}
|
|
7503
|
+
/**
|
|
7504
|
+
* Store a blob directly into the cache under the given (docId, uploadId) key
|
|
7505
|
+
* and return its object URL. Use this to pre-populate the cache for files
|
|
7506
|
+
* that haven't been uploaded to the server yet (e.g. offline upload queue).
|
|
7507
|
+
*/
|
|
7508
|
+
async putBlob(docId, uploadId, blob, filename) {
|
|
7509
|
+
if (typeof window === "undefined") return URL.createObjectURL(blob);
|
|
7510
|
+
const key = this.blobKey(docId, uploadId);
|
|
7511
|
+
const existing = this.objectUrls.get(key);
|
|
7512
|
+
if (existing) return existing;
|
|
7513
|
+
const db = await this.getDb();
|
|
7514
|
+
if (db) {
|
|
7515
|
+
const entry = {
|
|
7516
|
+
blob,
|
|
7517
|
+
mime_type: blob.type || "application/octet-stream",
|
|
7518
|
+
filename,
|
|
7519
|
+
cachedAt: Date.now()
|
|
7520
|
+
};
|
|
7521
|
+
db.transaction("blobs", "readwrite").objectStore("blobs").put(entry, key);
|
|
7522
|
+
}
|
|
7523
|
+
const url = URL.createObjectURL(blob);
|
|
7524
|
+
this.objectUrls.set(key, url);
|
|
7525
|
+
return url;
|
|
7526
|
+
}
|
|
7474
7527
|
/** Revoke the object URL and remove the blob from cache. */
|
|
7475
7528
|
async evictBlob(docId, uploadId) {
|
|
7476
7529
|
const key = this.blobKey(docId, uploadId);
|