@haex-space/vault-sdk 2.5.110 → 2.5.112

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/react.mjs CHANGED
@@ -555,6 +555,16 @@ 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
+ };
567
+
558
568
  // src/api/storage.ts
559
569
  var StorageAPI = class {
560
570
  constructor(client) {
@@ -1363,6 +1373,83 @@ var LocalSendAPI = class {
1363
1373
  }
1364
1374
  };
1365
1375
 
1376
+ // src/api/spaces.ts
1377
+ var SpacesAPI = class {
1378
+ constructor(client) {
1379
+ this.client = client;
1380
+ }
1381
+ /**
1382
+ * Bulk assign rows to spaces.
1383
+ * @param assignments - Array of row-to-space mappings
1384
+ * @returns Number of assignments created
1385
+ */
1386
+ async assignAsync(assignments) {
1387
+ return this.client.request(SPACE_COMMANDS.assign, {
1388
+ assignments: assignments.map(toSnakeCase)
1389
+ });
1390
+ }
1391
+ /**
1392
+ * Bulk unassign rows from spaces.
1393
+ * @param assignments - Array of row-to-space mappings to remove
1394
+ * @returns Number of assignments removed
1395
+ */
1396
+ async unassignAsync(assignments) {
1397
+ return this.client.request(SPACE_COMMANDS.unassign, {
1398
+ assignments: assignments.map(toSnakeCase)
1399
+ });
1400
+ }
1401
+ /**
1402
+ * Get space assignments for a table, optionally filtered by row.
1403
+ * @param tableName - The table to query assignments for
1404
+ * @param rowPks - Optional row primary key(s) to filter by
1405
+ * @returns Array of space assignments
1406
+ */
1407
+ async getAssignmentsAsync(tableName, rowPks) {
1408
+ const result = await this.client.request(
1409
+ SPACE_COMMANDS.getAssignments,
1410
+ {
1411
+ table_name: tableName,
1412
+ row_pks: rowPks
1413
+ }
1414
+ );
1415
+ return result.map(fromSnakeCase);
1416
+ }
1417
+ /**
1418
+ * Convenience method to assign a single row to a space.
1419
+ * @param tableName - The table name
1420
+ * @param rowPks - The row primary key(s)
1421
+ * @param spaceId - The space ID to assign to
1422
+ * @returns Number of assignments created (0 or 1)
1423
+ */
1424
+ async assignRowAsync(tableName, rowPks, spaceId) {
1425
+ return this.assignAsync([{ tableName, rowPks, spaceId }]);
1426
+ }
1427
+ /**
1428
+ * Convenience method to unassign a single row from a space.
1429
+ * @param tableName - The table name
1430
+ * @param rowPks - The row primary key(s)
1431
+ * @param spaceId - The space ID to unassign from
1432
+ * @returns Number of assignments removed (0 or 1)
1433
+ */
1434
+ async unassignRowAsync(tableName, rowPks, spaceId) {
1435
+ return this.unassignAsync([{ tableName, rowPks, spaceId }]);
1436
+ }
1437
+ };
1438
+ function toSnakeCase(a) {
1439
+ return {
1440
+ table_name: a.tableName,
1441
+ row_pks: a.rowPks,
1442
+ space_id: a.spaceId
1443
+ };
1444
+ }
1445
+ function fromSnakeCase(a) {
1446
+ return {
1447
+ tableName: a.table_name,
1448
+ rowPks: a.row_pks,
1449
+ spaceId: a.space_id
1450
+ };
1451
+ }
1452
+
1366
1453
  // src/client/tableName.ts
1367
1454
  function validatePublicKey(publicKey) {
1368
1455
  if (!publicKey || typeof publicKey !== "string" || publicKey.trim() === "") {
@@ -1987,6 +2074,7 @@ var HaexVaultSdk = class {
1987
2074
  this.permissions = new PermissionsAPI(this);
1988
2075
  this.remoteStorage = new RemoteStorageAPI(this);
1989
2076
  this.localsend = new LocalSendAPI(this);
2077
+ this.spaces = new SpacesAPI(this);
1990
2078
  installConsoleForwarding(this.config.debug);
1991
2079
  this.readyPromise = new Promise((resolve) => {
1992
2080
  this.resolveReady = resolve;