@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.
@@ -1,6 +1,6 @@
1
1
  import * as nuxt_app from 'nuxt/app';
2
2
  import { ShallowRef } from 'vue';
3
- import { H as HaexVaultSdk } from '../client-DFGx115H.mjs';
3
+ import { H as HaexVaultSdk } from '../client-Dfy9UQeu.mjs';
4
4
  import { A as ApplicationContext } from '../types-gfc9eCL4.mjs';
5
5
  import 'drizzle-orm/sqlite-proxy';
6
6
 
@@ -1,6 +1,6 @@
1
1
  import * as nuxt_app from 'nuxt/app';
2
2
  import { ShallowRef } from 'vue';
3
- import { H as HaexVaultSdk } from '../client-8dlKVNDZ.js';
3
+ import { H as HaexVaultSdk } from '../client-Dhn288AJ.js';
4
4
  import { A as ApplicationContext } from '../types-gfc9eCL4.js';
5
5
  import 'drizzle-orm/sqlite-proxy';
6
6
 
@@ -232,6 +232,22 @@ var LOCALSEND_COMMANDS = {
232
232
  cancelSend: "localsend_cancel_send"
233
233
  };
234
234
 
235
+ // src/commands/spaces.ts
236
+ var SPACE_COMMANDS = {
237
+ /** Bulk assign rows to spaces */
238
+ assign: "extension_space_assign",
239
+ /** Bulk unassign rows from spaces */
240
+ unassign: "extension_space_unassign",
241
+ /** Get space assignments for a table */
242
+ getAssignments: "extension_space_get_assignments",
243
+ /** List all spaces the user is a member of (with decrypted names) */
244
+ list: "extension_space_list",
245
+ /** Create a new shared space */
246
+ create: "extension_space_create",
247
+ /** List available sync backends */
248
+ listBackends: "extension_space_list_backends"
249
+ };
250
+
235
251
  // src/api/storage.ts
236
252
  var StorageAPI = class {
237
253
  constructor(client) {
@@ -1040,6 +1056,112 @@ var LocalSendAPI = class {
1040
1056
  }
1041
1057
  };
1042
1058
 
1059
+ // src/api/spaces.ts
1060
+ var SpacesAPI = class {
1061
+ constructor(client) {
1062
+ this.client = client;
1063
+ }
1064
+ /**
1065
+ * Bulk assign rows to spaces.
1066
+ * @param assignments - Array of row-to-space mappings
1067
+ * @returns Number of assignments created
1068
+ */
1069
+ async assignAsync(assignments) {
1070
+ return this.client.request(SPACE_COMMANDS.assign, {
1071
+ assignments: assignments.map(toSnakeCase)
1072
+ });
1073
+ }
1074
+ /**
1075
+ * Bulk unassign rows from spaces.
1076
+ * @param assignments - Array of row-to-space mappings to remove
1077
+ * @returns Number of assignments removed
1078
+ */
1079
+ async unassignAsync(assignments) {
1080
+ return this.client.request(SPACE_COMMANDS.unassign, {
1081
+ assignments: assignments.map(toSnakeCase)
1082
+ });
1083
+ }
1084
+ /**
1085
+ * Get space assignments for a table, optionally filtered by row.
1086
+ * @param tableName - The table to query assignments for
1087
+ * @param rowPks - Optional row primary key(s) to filter by
1088
+ * @returns Array of space assignments
1089
+ */
1090
+ async getAssignmentsAsync(tableName, rowPks) {
1091
+ const result = await this.client.request(
1092
+ SPACE_COMMANDS.getAssignments,
1093
+ {
1094
+ table_name: tableName,
1095
+ row_pks: rowPks
1096
+ }
1097
+ );
1098
+ return result.map(fromSnakeCase);
1099
+ }
1100
+ /**
1101
+ * Convenience method to assign a single row to a space.
1102
+ * @param tableName - The table name
1103
+ * @param rowPks - The row primary key(s)
1104
+ * @param spaceId - The space ID to assign to
1105
+ * @returns Number of assignments created (0 or 1)
1106
+ */
1107
+ async assignRowAsync(tableName, rowPks, spaceId) {
1108
+ return this.assignAsync([{ tableName, rowPks, spaceId }]);
1109
+ }
1110
+ /**
1111
+ * Convenience method to unassign a single row from a space.
1112
+ * @param tableName - The table name
1113
+ * @param rowPks - The row primary key(s)
1114
+ * @param spaceId - The space ID to unassign from
1115
+ * @returns Number of assignments removed (0 or 1)
1116
+ */
1117
+ async unassignRowAsync(tableName, rowPks, spaceId) {
1118
+ return this.unassignAsync([{ tableName, rowPks, spaceId }]);
1119
+ }
1120
+ // ==========================================================================
1121
+ // Space Management
1122
+ // ==========================================================================
1123
+ /**
1124
+ * List all shared spaces the user is a member of.
1125
+ * Returns spaces with decrypted names (decryption happens vault-side).
1126
+ */
1127
+ async listSpacesAsync() {
1128
+ return this.client.request(SPACE_COMMANDS.list);
1129
+ }
1130
+ /**
1131
+ * Create a new shared space.
1132
+ * @param name - Human-readable space name
1133
+ * @param serverUrl - The sync server URL to create the space on
1134
+ * @returns The created space with decrypted name
1135
+ */
1136
+ async createSpaceAsync(name, serverUrl) {
1137
+ return this.client.request(SPACE_COMMANDS.create, {
1138
+ name,
1139
+ server_url: serverUrl
1140
+ });
1141
+ }
1142
+ /**
1143
+ * List available sync backends that can host shared spaces.
1144
+ * @returns Array of backend info with server URLs
1145
+ */
1146
+ async listSyncBackendsAsync() {
1147
+ return this.client.request(SPACE_COMMANDS.listBackends);
1148
+ }
1149
+ };
1150
+ function toSnakeCase(assignment) {
1151
+ return {
1152
+ table_name: assignment.tableName,
1153
+ row_pks: assignment.rowPks,
1154
+ space_id: assignment.spaceId
1155
+ };
1156
+ }
1157
+ function fromSnakeCase(assignment) {
1158
+ return {
1159
+ tableName: assignment.table_name,
1160
+ rowPks: assignment.row_pks,
1161
+ spaceId: assignment.space_id
1162
+ };
1163
+ }
1164
+
1043
1165
  // src/messages.ts
1044
1166
  var HAEXSPACE_MESSAGE_TYPES = {
1045
1167
  /** Debug message for development/troubleshooting */
@@ -1738,6 +1860,7 @@ var HaexVaultSdk = class {
1738
1860
  this.permissions = new PermissionsAPI(this);
1739
1861
  this.remoteStorage = new RemoteStorageAPI(this);
1740
1862
  this.localsend = new LocalSendAPI(this);
1863
+ this.spaces = new SpacesAPI(this);
1741
1864
  installConsoleForwarding(this.config.debug);
1742
1865
  this.readyPromise = new Promise((resolve) => {
1743
1866
  this.resolveReady = resolve;