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/PLUGINS.md +3 -3
- package/dist/s3db.cjs.js +16 -19
- package/dist/s3db.cjs.min.js +1 -1
- package/dist/s3db.es.js +16 -19
- package/dist/s3db.es.min.js +1 -1
- package/dist/s3db.iife.js +16 -19
- package/dist/s3db.iife.min.js +1 -1
- package/mcp/server.js +1 -1
- package/package.json +1 -1
- package/src/plugins/cache.plugin.js +4 -4
- package/src/plugins/replicator.plugin.js +19 -19
package/dist/s3db.es.js
CHANGED
|
@@ -7606,11 +7606,11 @@ class CachePlugin extends plugin_class_default {
|
|
|
7606
7606
|
await super.setup(database);
|
|
7607
7607
|
}
|
|
7608
7608
|
async onSetup() {
|
|
7609
|
-
if (this.config.driver) {
|
|
7609
|
+
if (this.config.driver && typeof this.config.driver === "object") {
|
|
7610
7610
|
this.driver = this.config.driver;
|
|
7611
|
-
} else if (this.config.
|
|
7611
|
+
} else if (this.config.driver === "memory") {
|
|
7612
7612
|
this.driver = new memory_cache_class_default(this.config.memoryOptions || {});
|
|
7613
|
-
} else if (this.config.
|
|
7613
|
+
} else if (this.config.driver === "filesystem") {
|
|
7614
7614
|
if (this.config.partitionAware) {
|
|
7615
7615
|
this.driver = new PartitionAwareFilesystemCache({
|
|
7616
7616
|
partitionStrategy: this.config.partitionStrategy,
|
|
@@ -13326,7 +13326,7 @@ class Database extends EventEmitter {
|
|
|
13326
13326
|
super();
|
|
13327
13327
|
this.version = "1";
|
|
13328
13328
|
this.s3dbVersion = (() => {
|
|
13329
|
-
const [ok, err, version] = try_fn_default(() => true ? "7.
|
|
13329
|
+
const [ok, err, version] = try_fn_default(() => true ? "7.5.0" : "latest");
|
|
13330
13330
|
return ok ? version : "latest";
|
|
13331
13331
|
})();
|
|
13332
13332
|
this.resources = {};
|
|
@@ -14548,6 +14548,10 @@ class ReplicatorPlugin extends plugin_class_default {
|
|
|
14548
14548
|
}
|
|
14549
14549
|
return filtered;
|
|
14550
14550
|
}
|
|
14551
|
+
async getCompleteData(resource, data) {
|
|
14552
|
+
const [ok, err, completeRecord] = await try_fn_default(() => resource.get(data.id));
|
|
14553
|
+
return ok ? completeRecord : data;
|
|
14554
|
+
}
|
|
14551
14555
|
installEventListeners(resource, database, plugin) {
|
|
14552
14556
|
if (!resource || this.eventListenersInstalled.has(resource.name) || resource.name === this.config.replicatorLogResource) {
|
|
14553
14557
|
return;
|
|
@@ -14566,8 +14570,9 @@ class ReplicatorPlugin extends plugin_class_default {
|
|
|
14566
14570
|
});
|
|
14567
14571
|
resource.on("update", async (data, beforeData) => {
|
|
14568
14572
|
const [ok, error] = await try_fn_default(async () => {
|
|
14569
|
-
const completeData =
|
|
14570
|
-
|
|
14573
|
+
const completeData = await plugin.getCompleteData(resource, data);
|
|
14574
|
+
const dataWithTimestamp = { ...completeData, updatedAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
14575
|
+
await plugin.processReplicatorEvent("update", resource.name, completeData.id, dataWithTimestamp, beforeData);
|
|
14571
14576
|
});
|
|
14572
14577
|
if (!ok) {
|
|
14573
14578
|
if (this.config.verbose) {
|
|
@@ -14589,14 +14594,6 @@ class ReplicatorPlugin extends plugin_class_default {
|
|
|
14589
14594
|
});
|
|
14590
14595
|
this.eventListenersInstalled.add(resource.name);
|
|
14591
14596
|
}
|
|
14592
|
-
/**
|
|
14593
|
-
* Get complete data by always fetching the full record from the resource
|
|
14594
|
-
* This ensures we always have the complete data regardless of behavior or data size
|
|
14595
|
-
*/
|
|
14596
|
-
async getCompleteData(resource, data) {
|
|
14597
|
-
const [ok, err, completeRecord] = await try_fn_default(() => resource.get(data.id));
|
|
14598
|
-
return ok ? completeRecord : data;
|
|
14599
|
-
}
|
|
14600
14597
|
async setup(database) {
|
|
14601
14598
|
this.database = database;
|
|
14602
14599
|
const [initOk, initError] = await try_fn_default(async () => {
|
|
@@ -14610,7 +14607,7 @@ class ReplicatorPlugin extends plugin_class_default {
|
|
|
14610
14607
|
throw initError;
|
|
14611
14608
|
}
|
|
14612
14609
|
const [logOk, logError] = await try_fn_default(async () => {
|
|
14613
|
-
if (this.config.
|
|
14610
|
+
if (this.config.persistReplicatorLog) {
|
|
14614
14611
|
const logRes = await database.createResource({
|
|
14615
14612
|
name: this.config.replicatorLogResource,
|
|
14616
14613
|
behavior: "body-overflow",
|
|
@@ -14637,6 +14634,10 @@ class ReplicatorPlugin extends plugin_class_default {
|
|
|
14637
14634
|
});
|
|
14638
14635
|
}
|
|
14639
14636
|
await this.uploadMetadataFile(database);
|
|
14637
|
+
for (const resourceName in database.resources) {
|
|
14638
|
+
const resource = database.resources[resourceName];
|
|
14639
|
+
this.installEventListeners(resource, database, this);
|
|
14640
|
+
}
|
|
14640
14641
|
const originalCreateResource = database.createResource.bind(database);
|
|
14641
14642
|
database.createResource = async (config) => {
|
|
14642
14643
|
const resource = await originalCreateResource(config);
|
|
@@ -14645,10 +14646,6 @@ class ReplicatorPlugin extends plugin_class_default {
|
|
|
14645
14646
|
}
|
|
14646
14647
|
return resource;
|
|
14647
14648
|
};
|
|
14648
|
-
for (const resourceName in database.resources) {
|
|
14649
|
-
const resource = database.resources[resourceName];
|
|
14650
|
-
this.installEventListeners(resource, database, this);
|
|
14651
|
-
}
|
|
14652
14649
|
}
|
|
14653
14650
|
createReplicator(driver, config, resources, client) {
|
|
14654
14651
|
return createReplicator(driver, config, resources, client);
|