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