s3db.js 10.0.15 → 10.0.16
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.cjs.js +11 -36
- package/dist/s3db.cjs.js.map +1 -1
- package/dist/s3db.es.js +11 -36
- package/dist/s3db.es.js.map +1 -1
- package/package.json +1 -1
- package/src/plugins/eventual-consistency.plugin.js +21 -50
package/dist/s3db.cjs.js
CHANGED
|
@@ -5256,45 +5256,20 @@ class EventualConsistencyPlugin extends Plugin {
|
|
|
5256
5256
|
`[EventualConsistency] ${this.config.resource}.${this.config.field} - ${originalId}: ${currentValue} \u2192 ${consolidatedValue} (${consolidatedValue > currentValue ? "+" : ""}${consolidatedValue - currentValue})`
|
|
5257
5257
|
);
|
|
5258
5258
|
}
|
|
5259
|
-
const [updateOk, updateErr] = await tryFn(
|
|
5260
|
-
|
|
5261
|
-
|
|
5262
|
-
|
|
5263
|
-
|
|
5264
|
-
|
|
5265
|
-
if (
|
|
5266
|
-
return ok2;
|
|
5267
|
-
}
|
|
5268
|
-
if (err2?.message?.includes("does not exist")) {
|
|
5259
|
+
const [updateOk, updateErr] = await tryFn(
|
|
5260
|
+
() => this.targetResource.update(originalId, {
|
|
5261
|
+
[this.config.field]: consolidatedValue
|
|
5262
|
+
})
|
|
5263
|
+
);
|
|
5264
|
+
if (!updateOk) {
|
|
5265
|
+
if (updateErr?.message?.includes("does not exist")) {
|
|
5269
5266
|
if (this.config.verbose) {
|
|
5270
|
-
console.
|
|
5271
|
-
`[EventualConsistency] ${this.config.resource}.${this.config.field} - Record ${originalId} doesn't exist
|
|
5267
|
+
console.warn(
|
|
5268
|
+
`[EventualConsistency] ${this.config.resource}.${this.config.field} - Record ${originalId} doesn't exist. Skipping consolidation. ${transactions.length} transactions will remain pending until record is created.`
|
|
5272
5269
|
);
|
|
5273
5270
|
}
|
|
5274
|
-
|
|
5275
|
-
() => this.targetResource.insert({
|
|
5276
|
-
id: originalId,
|
|
5277
|
-
[this.config.field]: consolidatedValue
|
|
5278
|
-
})
|
|
5279
|
-
);
|
|
5280
|
-
if (insertOk) {
|
|
5281
|
-
return insertOk;
|
|
5282
|
-
}
|
|
5283
|
-
if (insertErr?.message?.includes("already exists")) {
|
|
5284
|
-
if (this.config.verbose) {
|
|
5285
|
-
console.log(
|
|
5286
|
-
`[EventualConsistency] ${this.config.resource}.${this.config.field} - Record ${originalId} was created by another consolidation during retry, updating instead`
|
|
5287
|
-
);
|
|
5288
|
-
}
|
|
5289
|
-
return await this.targetResource.update(originalId, {
|
|
5290
|
-
[this.config.field]: consolidatedValue
|
|
5291
|
-
});
|
|
5292
|
-
}
|
|
5293
|
-
throw insertErr;
|
|
5271
|
+
return consolidatedValue;
|
|
5294
5272
|
}
|
|
5295
|
-
throw err2;
|
|
5296
|
-
});
|
|
5297
|
-
if (!updateOk) {
|
|
5298
5273
|
console.error(
|
|
5299
5274
|
`[EventualConsistency] ${this.config.resource}.${this.config.field} - FAILED to update ${originalId}: ${updateErr?.message || updateErr}`,
|
|
5300
5275
|
{ error: updateErr, consolidatedValue, currentValue }
|
|
@@ -12160,7 +12135,7 @@ class Database extends EventEmitter {
|
|
|
12160
12135
|
this.id = idGenerator(7);
|
|
12161
12136
|
this.version = "1";
|
|
12162
12137
|
this.s3dbVersion = (() => {
|
|
12163
|
-
const [ok, err, version] = tryFn(() => true ? "10.0.
|
|
12138
|
+
const [ok, err, version] = tryFn(() => true ? "10.0.16" : "latest");
|
|
12164
12139
|
return ok ? version : "latest";
|
|
12165
12140
|
})();
|
|
12166
12141
|
this.resources = {};
|