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