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