@haex-space/vault-sdk 2.0.0 → 2.2.1

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/index.mjs CHANGED
@@ -520,18 +520,27 @@ var DatabaseAPI = class {
520
520
  await this.execute(query);
521
521
  }
522
522
  /**
523
- * Registers extension migrations with HaexVault for CRDT synchronization
524
- * HaexVault will validate and execute these migrations, ensuring only
525
- * tables with the correct prefix are manipulated
523
+ * Registers and applies extension migrations with HaexVault
524
+ *
525
+ * HaexVault will:
526
+ * 1. Validate all SQL statements (ensure only extension's own tables are accessed)
527
+ * 2. Store migrations with applied_at = NULL
528
+ * 3. Query pending migrations sorted by name
529
+ * 4. Apply pending migrations and set up CRDT triggers
530
+ * 5. Mark successful migrations with applied_at timestamp
531
+ *
526
532
  * @param extensionVersion - The version of the extension
527
533
  * @param migrations - Array of migration objects with name and SQL content
528
- * @returns Promise that resolves when migrations are registered
534
+ * @returns Promise with migration result (applied count, already applied count, applied migration names)
529
535
  */
530
536
  async registerMigrationsAsync(extensionVersion, migrations) {
531
- await this.client.request(HAEXTENSION_METHODS.database.registerMigrations, {
532
- extensionVersion,
533
- migrations
534
- });
537
+ return this.client.request(
538
+ HAEXTENSION_METHODS.database.registerMigrations,
539
+ {
540
+ extensionVersion,
541
+ migrations
542
+ }
543
+ );
535
544
  }
536
545
  async insert(tableName, data) {
537
546
  const keys = Object.keys(data);
@@ -1020,11 +1029,18 @@ var HaexVaultClient = class {
1020
1029
  };
1021
1030
  }
1022
1031
  /**
1023
- * Registers extension migrations with HaexVault for CRDT synchronization
1024
- * HaexVault will validate and execute these migrations
1032
+ * Registers and applies extension migrations with HaexVault
1033
+ *
1034
+ * HaexVault will:
1035
+ * 1. Validate all SQL statements (ensure only extension's own tables are accessed)
1036
+ * 2. Store migrations with applied_at = NULL
1037
+ * 3. Query pending migrations sorted by name
1038
+ * 4. Apply pending migrations and set up CRDT triggers
1039
+ * 5. Mark successful migrations with applied_at timestamp
1040
+ *
1025
1041
  * @param extensionVersion - The version of the extension
1026
1042
  * @param migrations - Array of migration objects with name and SQL content
1027
- * @returns Promise that resolves when migrations are registered
1043
+ * @returns Promise with migration result (applied count, already applied count, applied migration names)
1028
1044
  */
1029
1045
  async registerMigrationsAsync(extensionVersion, migrations) {
1030
1046
  return this.database.registerMigrationsAsync(extensionVersion, migrations);
@@ -1144,6 +1160,11 @@ var HaexVaultClient = class {
1144
1160
  data: params.data,
1145
1161
  fileName: params.fileName
1146
1162
  });
1163
+ case HAEXTENSION_METHODS.database.registerMigrations:
1164
+ return invoke("webview_extension_db_register_migrations", {
1165
+ extensionVersion: params.extensionVersion,
1166
+ migrations: params.migrations
1167
+ });
1147
1168
  default:
1148
1169
  throw new HaexHubError(
1149
1170
  "METHOD_NOT_FOUND" /* METHOD_NOT_FOUND */,