@haex-space/vault-sdk 2.5.111 → 2.5.113
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/{client-DFGx115H.d.mts → client-Dfy9UQeu.d.mts} +161 -1
- package/dist/{client-8dlKVNDZ.d.ts → client-Dhn288AJ.d.ts} +161 -1
- package/dist/index.d.mts +49 -51
- package/dist/index.d.ts +49 -51
- package/dist/index.js +149 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +147 -2
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +123 -0
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +123 -0
- package/dist/react.mjs.map +1 -1
- package/dist/runtime/nuxt.plugin.client.d.mts +1 -1
- package/dist/runtime/nuxt.plugin.client.d.ts +1 -1
- package/dist/runtime/nuxt.plugin.client.js +123 -0
- package/dist/runtime/nuxt.plugin.client.js.map +1 -1
- package/dist/runtime/nuxt.plugin.client.mjs +123 -0
- package/dist/runtime/nuxt.plugin.client.mjs.map +1 -1
- package/dist/svelte.d.mts +1 -1
- package/dist/svelte.d.ts +1 -1
- package/dist/svelte.js +123 -0
- package/dist/svelte.js.map +1 -1
- package/dist/svelte.mjs +123 -0
- package/dist/svelte.mjs.map +1 -1
- package/dist/vue.d.mts +1 -1
- package/dist/vue.d.ts +1 -1
- package/dist/vue.js +123 -0
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs +123 -0
- package/dist/vue.mjs.map +1 -1
- package/package.json +1 -1
package/dist/svelte.mjs
CHANGED
|
@@ -555,6 +555,22 @@ var LOCALSEND_COMMANDS = {
|
|
|
555
555
|
cancelSend: "localsend_cancel_send"
|
|
556
556
|
};
|
|
557
557
|
|
|
558
|
+
// src/commands/spaces.ts
|
|
559
|
+
var SPACE_COMMANDS = {
|
|
560
|
+
/** Bulk assign rows to spaces */
|
|
561
|
+
assign: "extension_space_assign",
|
|
562
|
+
/** Bulk unassign rows from spaces */
|
|
563
|
+
unassign: "extension_space_unassign",
|
|
564
|
+
/** Get space assignments for a table */
|
|
565
|
+
getAssignments: "extension_space_get_assignments",
|
|
566
|
+
/** List all spaces the user is a member of (with decrypted names) */
|
|
567
|
+
list: "extension_space_list",
|
|
568
|
+
/** Create a new shared space */
|
|
569
|
+
create: "extension_space_create",
|
|
570
|
+
/** List available sync backends */
|
|
571
|
+
listBackends: "extension_space_list_backends"
|
|
572
|
+
};
|
|
573
|
+
|
|
558
574
|
// src/api/storage.ts
|
|
559
575
|
var StorageAPI = class {
|
|
560
576
|
constructor(client) {
|
|
@@ -1363,6 +1379,112 @@ var LocalSendAPI = class {
|
|
|
1363
1379
|
}
|
|
1364
1380
|
};
|
|
1365
1381
|
|
|
1382
|
+
// src/api/spaces.ts
|
|
1383
|
+
var SpacesAPI = class {
|
|
1384
|
+
constructor(client) {
|
|
1385
|
+
this.client = client;
|
|
1386
|
+
}
|
|
1387
|
+
/**
|
|
1388
|
+
* Bulk assign rows to spaces.
|
|
1389
|
+
* @param assignments - Array of row-to-space mappings
|
|
1390
|
+
* @returns Number of assignments created
|
|
1391
|
+
*/
|
|
1392
|
+
async assignAsync(assignments) {
|
|
1393
|
+
return this.client.request(SPACE_COMMANDS.assign, {
|
|
1394
|
+
assignments: assignments.map(toSnakeCase)
|
|
1395
|
+
});
|
|
1396
|
+
}
|
|
1397
|
+
/**
|
|
1398
|
+
* Bulk unassign rows from spaces.
|
|
1399
|
+
* @param assignments - Array of row-to-space mappings to remove
|
|
1400
|
+
* @returns Number of assignments removed
|
|
1401
|
+
*/
|
|
1402
|
+
async unassignAsync(assignments) {
|
|
1403
|
+
return this.client.request(SPACE_COMMANDS.unassign, {
|
|
1404
|
+
assignments: assignments.map(toSnakeCase)
|
|
1405
|
+
});
|
|
1406
|
+
}
|
|
1407
|
+
/**
|
|
1408
|
+
* Get space assignments for a table, optionally filtered by row.
|
|
1409
|
+
* @param tableName - The table to query assignments for
|
|
1410
|
+
* @param rowPks - Optional row primary key(s) to filter by
|
|
1411
|
+
* @returns Array of space assignments
|
|
1412
|
+
*/
|
|
1413
|
+
async getAssignmentsAsync(tableName, rowPks) {
|
|
1414
|
+
const result = await this.client.request(
|
|
1415
|
+
SPACE_COMMANDS.getAssignments,
|
|
1416
|
+
{
|
|
1417
|
+
table_name: tableName,
|
|
1418
|
+
row_pks: rowPks
|
|
1419
|
+
}
|
|
1420
|
+
);
|
|
1421
|
+
return result.map(fromSnakeCase);
|
|
1422
|
+
}
|
|
1423
|
+
/**
|
|
1424
|
+
* Convenience method to assign a single row to a space.
|
|
1425
|
+
* @param tableName - The table name
|
|
1426
|
+
* @param rowPks - The row primary key(s)
|
|
1427
|
+
* @param spaceId - The space ID to assign to
|
|
1428
|
+
* @returns Number of assignments created (0 or 1)
|
|
1429
|
+
*/
|
|
1430
|
+
async assignRowAsync(tableName, rowPks, spaceId) {
|
|
1431
|
+
return this.assignAsync([{ tableName, rowPks, spaceId }]);
|
|
1432
|
+
}
|
|
1433
|
+
/**
|
|
1434
|
+
* Convenience method to unassign a single row from a space.
|
|
1435
|
+
* @param tableName - The table name
|
|
1436
|
+
* @param rowPks - The row primary key(s)
|
|
1437
|
+
* @param spaceId - The space ID to unassign from
|
|
1438
|
+
* @returns Number of assignments removed (0 or 1)
|
|
1439
|
+
*/
|
|
1440
|
+
async unassignRowAsync(tableName, rowPks, spaceId) {
|
|
1441
|
+
return this.unassignAsync([{ tableName, rowPks, spaceId }]);
|
|
1442
|
+
}
|
|
1443
|
+
// ==========================================================================
|
|
1444
|
+
// Space Management
|
|
1445
|
+
// ==========================================================================
|
|
1446
|
+
/**
|
|
1447
|
+
* List all shared spaces the user is a member of.
|
|
1448
|
+
* Returns spaces with decrypted names (decryption happens vault-side).
|
|
1449
|
+
*/
|
|
1450
|
+
async listSpacesAsync() {
|
|
1451
|
+
return this.client.request(SPACE_COMMANDS.list);
|
|
1452
|
+
}
|
|
1453
|
+
/**
|
|
1454
|
+
* Create a new shared space.
|
|
1455
|
+
* @param name - Human-readable space name
|
|
1456
|
+
* @param serverUrl - The sync server URL to create the space on
|
|
1457
|
+
* @returns The created space with decrypted name
|
|
1458
|
+
*/
|
|
1459
|
+
async createSpaceAsync(name, serverUrl) {
|
|
1460
|
+
return this.client.request(SPACE_COMMANDS.create, {
|
|
1461
|
+
name,
|
|
1462
|
+
server_url: serverUrl
|
|
1463
|
+
});
|
|
1464
|
+
}
|
|
1465
|
+
/**
|
|
1466
|
+
* List available sync backends that can host shared spaces.
|
|
1467
|
+
* @returns Array of backend info with server URLs
|
|
1468
|
+
*/
|
|
1469
|
+
async listSyncBackendsAsync() {
|
|
1470
|
+
return this.client.request(SPACE_COMMANDS.listBackends);
|
|
1471
|
+
}
|
|
1472
|
+
};
|
|
1473
|
+
function toSnakeCase(assignment) {
|
|
1474
|
+
return {
|
|
1475
|
+
table_name: assignment.tableName,
|
|
1476
|
+
row_pks: assignment.rowPks,
|
|
1477
|
+
space_id: assignment.spaceId
|
|
1478
|
+
};
|
|
1479
|
+
}
|
|
1480
|
+
function fromSnakeCase(assignment) {
|
|
1481
|
+
return {
|
|
1482
|
+
tableName: assignment.table_name,
|
|
1483
|
+
rowPks: assignment.row_pks,
|
|
1484
|
+
spaceId: assignment.space_id
|
|
1485
|
+
};
|
|
1486
|
+
}
|
|
1487
|
+
|
|
1366
1488
|
// src/client/tableName.ts
|
|
1367
1489
|
function validatePublicKey(publicKey) {
|
|
1368
1490
|
if (!publicKey || typeof publicKey !== "string" || publicKey.trim() === "") {
|
|
@@ -1987,6 +2109,7 @@ var HaexVaultSdk = class {
|
|
|
1987
2109
|
this.permissions = new PermissionsAPI(this);
|
|
1988
2110
|
this.remoteStorage = new RemoteStorageAPI(this);
|
|
1989
2111
|
this.localsend = new LocalSendAPI(this);
|
|
2112
|
+
this.spaces = new SpacesAPI(this);
|
|
1990
2113
|
installConsoleForwarding(this.config.debug);
|
|
1991
2114
|
this.readyPromise = new Promise((resolve) => {
|
|
1992
2115
|
this.resolveReady = resolve;
|