@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.
@@ -230,6 +230,16 @@ var LOCALSEND_COMMANDS = {
230
230
  cancelSend: "localsend_cancel_send"
231
231
  };
232
232
 
233
+ // src/commands/spaces.ts
234
+ var SPACE_COMMANDS = {
235
+ /** Bulk assign rows to spaces */
236
+ assign: "extension_space_assign",
237
+ /** Bulk unassign rows from spaces */
238
+ unassign: "extension_space_unassign",
239
+ /** Get space assignments for a table */
240
+ getAssignments: "extension_space_get_assignments"
241
+ };
242
+
233
243
  // src/api/storage.ts
234
244
  var StorageAPI = class {
235
245
  constructor(client) {
@@ -1038,6 +1048,83 @@ var LocalSendAPI = class {
1038
1048
  }
1039
1049
  };
1040
1050
 
1051
+ // src/api/spaces.ts
1052
+ var SpacesAPI = class {
1053
+ constructor(client) {
1054
+ this.client = client;
1055
+ }
1056
+ /**
1057
+ * Bulk assign rows to spaces.
1058
+ * @param assignments - Array of row-to-space mappings
1059
+ * @returns Number of assignments created
1060
+ */
1061
+ async assignAsync(assignments) {
1062
+ return this.client.request(SPACE_COMMANDS.assign, {
1063
+ assignments: assignments.map(toSnakeCase)
1064
+ });
1065
+ }
1066
+ /**
1067
+ * Bulk unassign rows from spaces.
1068
+ * @param assignments - Array of row-to-space mappings to remove
1069
+ * @returns Number of assignments removed
1070
+ */
1071
+ async unassignAsync(assignments) {
1072
+ return this.client.request(SPACE_COMMANDS.unassign, {
1073
+ assignments: assignments.map(toSnakeCase)
1074
+ });
1075
+ }
1076
+ /**
1077
+ * Get space assignments for a table, optionally filtered by row.
1078
+ * @param tableName - The table to query assignments for
1079
+ * @param rowPks - Optional row primary key(s) to filter by
1080
+ * @returns Array of space assignments
1081
+ */
1082
+ async getAssignmentsAsync(tableName, rowPks) {
1083
+ const result = await this.client.request(
1084
+ SPACE_COMMANDS.getAssignments,
1085
+ {
1086
+ table_name: tableName,
1087
+ row_pks: rowPks
1088
+ }
1089
+ );
1090
+ return result.map(fromSnakeCase);
1091
+ }
1092
+ /**
1093
+ * Convenience method to assign a single row to a space.
1094
+ * @param tableName - The table name
1095
+ * @param rowPks - The row primary key(s)
1096
+ * @param spaceId - The space ID to assign to
1097
+ * @returns Number of assignments created (0 or 1)
1098
+ */
1099
+ async assignRowAsync(tableName, rowPks, spaceId) {
1100
+ return this.assignAsync([{ tableName, rowPks, spaceId }]);
1101
+ }
1102
+ /**
1103
+ * Convenience method to unassign a single row from a space.
1104
+ * @param tableName - The table name
1105
+ * @param rowPks - The row primary key(s)
1106
+ * @param spaceId - The space ID to unassign from
1107
+ * @returns Number of assignments removed (0 or 1)
1108
+ */
1109
+ async unassignRowAsync(tableName, rowPks, spaceId) {
1110
+ return this.unassignAsync([{ tableName, rowPks, spaceId }]);
1111
+ }
1112
+ };
1113
+ function toSnakeCase(a) {
1114
+ return {
1115
+ table_name: a.tableName,
1116
+ row_pks: a.rowPks,
1117
+ space_id: a.spaceId
1118
+ };
1119
+ }
1120
+ function fromSnakeCase(a) {
1121
+ return {
1122
+ tableName: a.table_name,
1123
+ rowPks: a.row_pks,
1124
+ spaceId: a.space_id
1125
+ };
1126
+ }
1127
+
1041
1128
  // src/messages.ts
1042
1129
  var HAEXSPACE_MESSAGE_TYPES = {
1043
1130
  /** Debug message for development/troubleshooting */
@@ -1736,6 +1823,7 @@ var HaexVaultSdk = class {
1736
1823
  this.permissions = new PermissionsAPI(this);
1737
1824
  this.remoteStorage = new RemoteStorageAPI(this);
1738
1825
  this.localsend = new LocalSendAPI(this);
1826
+ this.spaces = new SpacesAPI(this);
1739
1827
  installConsoleForwarding(this.config.debug);
1740
1828
  this.readyPromise = new Promise((resolve) => {
1741
1829
  this.resolveReady = resolve;