s3db.js 7.4.2 → 7.5.0

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/s3db.iife.js CHANGED
@@ -7597,11 +7597,11 @@ ${JSON.stringify(validation, null, 2)}`,
7597
7597
  await super.setup(database);
7598
7598
  }
7599
7599
  async onSetup() {
7600
- if (this.config.driver) {
7600
+ if (this.config.driver && typeof this.config.driver === "object") {
7601
7601
  this.driver = this.config.driver;
7602
- } else if (this.config.driverType === "memory") {
7602
+ } else if (this.config.driver === "memory") {
7603
7603
  this.driver = new memory_cache_class_default(this.config.memoryOptions || {});
7604
- } else if (this.config.driverType === "filesystem") {
7604
+ } else if (this.config.driver === "filesystem") {
7605
7605
  if (this.config.partitionAware) {
7606
7606
  this.driver = new PartitionAwareFilesystemCache({
7607
7607
  partitionStrategy: this.config.partitionStrategy,
@@ -13317,7 +13317,7 @@ ${JSON.stringify(validation, null, 2)}`,
13317
13317
  super();
13318
13318
  this.version = "1";
13319
13319
  this.s3dbVersion = (() => {
13320
- const [ok, err, version] = try_fn_default(() => true ? "7.4.1" : "latest");
13320
+ const [ok, err, version] = try_fn_default(() => true ? "7.5.0" : "latest");
13321
13321
  return ok ? version : "latest";
13322
13322
  })();
13323
13323
  this.resources = {};
@@ -14539,6 +14539,10 @@ ${JSON.stringify(validation, null, 2)}`,
14539
14539
  }
14540
14540
  return filtered;
14541
14541
  }
14542
+ async getCompleteData(resource, data) {
14543
+ const [ok, err, completeRecord] = await try_fn_default(() => resource.get(data.id));
14544
+ return ok ? completeRecord : data;
14545
+ }
14542
14546
  installEventListeners(resource, database, plugin) {
14543
14547
  if (!resource || this.eventListenersInstalled.has(resource.name) || resource.name === this.config.replicatorLogResource) {
14544
14548
  return;
@@ -14557,8 +14561,9 @@ ${JSON.stringify(validation, null, 2)}`,
14557
14561
  });
14558
14562
  resource.on("update", async (data, beforeData) => {
14559
14563
  const [ok, error] = await try_fn_default(async () => {
14560
- const completeData = { ...data, updatedAt: (/* @__PURE__ */ new Date()).toISOString() };
14561
- await plugin.processReplicatorEvent("update", resource.name, completeData.id, completeData, beforeData);
14564
+ const completeData = await plugin.getCompleteData(resource, data);
14565
+ const dataWithTimestamp = { ...completeData, updatedAt: (/* @__PURE__ */ new Date()).toISOString() };
14566
+ await plugin.processReplicatorEvent("update", resource.name, completeData.id, dataWithTimestamp, beforeData);
14562
14567
  });
14563
14568
  if (!ok) {
14564
14569
  if (this.config.verbose) {
@@ -14580,14 +14585,6 @@ ${JSON.stringify(validation, null, 2)}`,
14580
14585
  });
14581
14586
  this.eventListenersInstalled.add(resource.name);
14582
14587
  }
14583
- /**
14584
- * Get complete data by always fetching the full record from the resource
14585
- * This ensures we always have the complete data regardless of behavior or data size
14586
- */
14587
- async getCompleteData(resource, data) {
14588
- const [ok, err, completeRecord] = await try_fn_default(() => resource.get(data.id));
14589
- return ok ? completeRecord : data;
14590
- }
14591
14588
  async setup(database) {
14592
14589
  this.database = database;
14593
14590
  const [initOk, initError] = await try_fn_default(async () => {
@@ -14601,7 +14598,7 @@ ${JSON.stringify(validation, null, 2)}`,
14601
14598
  throw initError;
14602
14599
  }
14603
14600
  const [logOk, logError] = await try_fn_default(async () => {
14604
- if (this.config.replicatorLogResource) {
14601
+ if (this.config.persistReplicatorLog) {
14605
14602
  const logRes = await database.createResource({
14606
14603
  name: this.config.replicatorLogResource,
14607
14604
  behavior: "body-overflow",
@@ -14628,6 +14625,10 @@ ${JSON.stringify(validation, null, 2)}`,
14628
14625
  });
14629
14626
  }
14630
14627
  await this.uploadMetadataFile(database);
14628
+ for (const resourceName in database.resources) {
14629
+ const resource = database.resources[resourceName];
14630
+ this.installEventListeners(resource, database, this);
14631
+ }
14631
14632
  const originalCreateResource = database.createResource.bind(database);
14632
14633
  database.createResource = async (config) => {
14633
14634
  const resource = await originalCreateResource(config);
@@ -14636,10 +14637,6 @@ ${JSON.stringify(validation, null, 2)}`,
14636
14637
  }
14637
14638
  return resource;
14638
14639
  };
14639
- for (const resourceName in database.resources) {
14640
- const resource = database.resources[resourceName];
14641
- this.installEventListeners(resource, database, this);
14642
- }
14643
14640
  }
14644
14641
  createReplicator(driver, config, resources, client) {
14645
14642
  return createReplicator(driver, config, resources, client);