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