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 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(async () => {
5260
- const [ok2, err2] = await tryFn(
5261
- () => this.targetResource.update(originalId, {
5262
- [this.config.field]: consolidatedValue
5263
- })
5264
- );
5265
- if (ok2) {
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.log(
5271
- `[EventualConsistency] ${this.config.resource}.${this.config.field} - Record ${originalId} doesn't exist, attempting to create with ${this.config.field}=${consolidatedValue}`
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
- const [insertOk, insertErr] = await tryFn(
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.15" : "latest");
12138
+ const [ok, err, version] = tryFn(() => true ? "10.0.16" : "latest");
12164
12139
  return ok ? version : "latest";
12165
12140
  })();
12166
12141
  this.resources = {};