@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/react.mjs CHANGED
@@ -459,18 +459,27 @@ var DatabaseAPI = class {
459
459
  await this.execute(query);
460
460
  }
461
461
  /**
462
- * Registers extension migrations with HaexVault for CRDT synchronization
463
- * HaexVault will validate and execute these migrations, ensuring only
464
- * tables with the correct prefix are manipulated
462
+ * Registers and applies extension migrations with HaexVault
463
+ *
464
+ * HaexVault will:
465
+ * 1. Validate all SQL statements (ensure only extension's own tables are accessed)
466
+ * 2. Store migrations with applied_at = NULL
467
+ * 3. Query pending migrations sorted by name
468
+ * 4. Apply pending migrations and set up CRDT triggers
469
+ * 5. Mark successful migrations with applied_at timestamp
470
+ *
465
471
  * @param extensionVersion - The version of the extension
466
472
  * @param migrations - Array of migration objects with name and SQL content
467
- * @returns Promise that resolves when migrations are registered
473
+ * @returns Promise with migration result (applied count, already applied count, applied migration names)
468
474
  */
469
475
  async registerMigrationsAsync(extensionVersion, migrations) {
470
- await this.client.request(HAEXTENSION_METHODS.database.registerMigrations, {
471
- extensionVersion,
472
- migrations
473
- });
476
+ return this.client.request(
477
+ HAEXTENSION_METHODS.database.registerMigrations,
478
+ {
479
+ extensionVersion,
480
+ migrations
481
+ }
482
+ );
474
483
  }
475
484
  async insert(tableName, data) {
476
485
  const keys = Object.keys(data);
@@ -959,11 +968,18 @@ var HaexVaultClient = class {
959
968
  };
960
969
  }
961
970
  /**
962
- * Registers extension migrations with HaexVault for CRDT synchronization
963
- * HaexVault will validate and execute these migrations
971
+ * Registers and applies extension migrations with HaexVault
972
+ *
973
+ * HaexVault will:
974
+ * 1. Validate all SQL statements (ensure only extension's own tables are accessed)
975
+ * 2. Store migrations with applied_at = NULL
976
+ * 3. Query pending migrations sorted by name
977
+ * 4. Apply pending migrations and set up CRDT triggers
978
+ * 5. Mark successful migrations with applied_at timestamp
979
+ *
964
980
  * @param extensionVersion - The version of the extension
965
981
  * @param migrations - Array of migration objects with name and SQL content
966
- * @returns Promise that resolves when migrations are registered
982
+ * @returns Promise with migration result (applied count, already applied count, applied migration names)
967
983
  */
968
984
  async registerMigrationsAsync(extensionVersion, migrations) {
969
985
  return this.database.registerMigrationsAsync(extensionVersion, migrations);
@@ -1083,6 +1099,11 @@ var HaexVaultClient = class {
1083
1099
  data: params.data,
1084
1100
  fileName: params.fileName
1085
1101
  });
1102
+ case HAEXTENSION_METHODS.database.registerMigrations:
1103
+ return invoke("webview_extension_db_register_migrations", {
1104
+ extensionVersion: params.extensionVersion,
1105
+ migrations: params.migrations
1106
+ });
1086
1107
  default:
1087
1108
  throw new HaexHubError(
1088
1109
  "METHOD_NOT_FOUND" /* METHOD_NOT_FOUND */,