s3db.js 11.0.1 → 11.0.2
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 +10 -12
- package/dist/s3db.cjs.js.map +1 -1
- package/dist/s3db.es.js +10 -12
- package/dist/s3db.es.js.map +1 -1
- package/package.json +1 -1
- package/src/plugins/eventual-consistency/analytics.js +5 -5
- package/src/plugins/eventual-consistency/config.js +1 -2
- package/src/plugins/eventual-consistency/consolidation.js +3 -3
- package/dist/s3db-cli.js +0 -54741
package/dist/s3db.cjs.js
CHANGED
|
@@ -4864,9 +4864,7 @@ function createConfig(options, detectedTimezone) {
|
|
|
4864
4864
|
deleteConsolidatedTransactions: checkpoints.deleteConsolidated !== false,
|
|
4865
4865
|
autoCheckpoint: checkpoints.auto !== false,
|
|
4866
4866
|
// Debug
|
|
4867
|
-
verbose: options.verbose
|
|
4868
|
-
// Default: true (can disable with verbose: false)
|
|
4869
|
-
debug: options.debug || false
|
|
4867
|
+
verbose: options.verbose || false
|
|
4870
4868
|
};
|
|
4871
4869
|
}
|
|
4872
4870
|
function validateResourcesConfig(resources) {
|
|
@@ -5405,7 +5403,7 @@ async function consolidateRecord(originalId, transactionResource, targetResource
|
|
|
5405
5403
|
`[EventualConsistency] ${config.resource}.${config.field} - ${originalId}: ${currentValue} \u2192 ${consolidatedValue} (${consolidatedValue > currentValue ? "+" : ""}${consolidatedValue - currentValue})`
|
|
5406
5404
|
);
|
|
5407
5405
|
}
|
|
5408
|
-
if (config.
|
|
5406
|
+
if (config.verbose) {
|
|
5409
5407
|
console.log(
|
|
5410
5408
|
`\u{1F525} [DEBUG] BEFORE targetResource.update() {
|
|
5411
5409
|
originalId: '${originalId}',
|
|
@@ -5420,7 +5418,7 @@ async function consolidateRecord(originalId, transactionResource, targetResource
|
|
|
5420
5418
|
[config.field]: consolidatedValue
|
|
5421
5419
|
})
|
|
5422
5420
|
);
|
|
5423
|
-
if (config.
|
|
5421
|
+
if (config.verbose) {
|
|
5424
5422
|
console.log(
|
|
5425
5423
|
`\u{1F525} [DEBUG] AFTER targetResource.update() {
|
|
5426
5424
|
updateOk: ${updateOk},
|
|
@@ -5430,7 +5428,7 @@ async function consolidateRecord(originalId, transactionResource, targetResource
|
|
|
5430
5428
|
}`
|
|
5431
5429
|
);
|
|
5432
5430
|
}
|
|
5433
|
-
if (updateOk &&
|
|
5431
|
+
if (updateOk && config.verbose) {
|
|
5434
5432
|
const [verifyOk, verifyErr, verifiedRecord] = await tryFn(
|
|
5435
5433
|
() => targetResource.get(originalId, { skipCache: true })
|
|
5436
5434
|
);
|
|
@@ -5764,12 +5762,12 @@ async function updateAnalytics(transactions, analyticsResource, config) {
|
|
|
5764
5762
|
throw new Error(
|
|
5765
5763
|
`[EventualConsistency] CRITICAL BUG: config.field is undefined in updateAnalytics()!
|
|
5766
5764
|
This indicates a race condition in the plugin where multiple handlers are sharing the same config object.
|
|
5767
|
-
Config: ${JSON.stringify({ resource: config.resource, field: config.field
|
|
5765
|
+
Config: ${JSON.stringify({ resource: config.resource, field: config.field })}
|
|
5768
5766
|
Transactions count: ${transactions.length}
|
|
5769
5767
|
AnalyticsResource: ${analyticsResource?.name || "unknown"}`
|
|
5770
5768
|
);
|
|
5771
5769
|
}
|
|
5772
|
-
if (config.verbose
|
|
5770
|
+
if (config.verbose) {
|
|
5773
5771
|
console.log(
|
|
5774
5772
|
`[EventualConsistency] ${config.resource}.${config.field} - Updating analytics for ${transactions.length} transactions...`
|
|
5775
5773
|
);
|
|
@@ -5777,7 +5775,7 @@ AnalyticsResource: ${analyticsResource?.name || "unknown"}`
|
|
|
5777
5775
|
try {
|
|
5778
5776
|
const byHour = groupByCohort(transactions, "cohortHour");
|
|
5779
5777
|
const cohortCount = Object.keys(byHour).length;
|
|
5780
|
-
if (config.verbose
|
|
5778
|
+
if (config.verbose) {
|
|
5781
5779
|
console.log(
|
|
5782
5780
|
`[EventualConsistency] ${config.resource}.${config.field} - Updating ${cohortCount} hourly analytics cohorts...`
|
|
5783
5781
|
);
|
|
@@ -5787,7 +5785,7 @@ AnalyticsResource: ${analyticsResource?.name || "unknown"}`
|
|
|
5787
5785
|
}
|
|
5788
5786
|
if (config.analyticsConfig.rollupStrategy === "incremental") {
|
|
5789
5787
|
const uniqueHours = Object.keys(byHour);
|
|
5790
|
-
if (config.verbose
|
|
5788
|
+
if (config.verbose) {
|
|
5791
5789
|
console.log(
|
|
5792
5790
|
`[EventualConsistency] ${config.resource}.${config.field} - Rolling up ${uniqueHours.length} hours to daily/monthly analytics...`
|
|
5793
5791
|
);
|
|
@@ -5796,7 +5794,7 @@ AnalyticsResource: ${analyticsResource?.name || "unknown"}`
|
|
|
5796
5794
|
await rollupAnalytics(cohortHour, analyticsResource, config);
|
|
5797
5795
|
}
|
|
5798
5796
|
}
|
|
5799
|
-
if (config.verbose
|
|
5797
|
+
if (config.verbose) {
|
|
5800
5798
|
console.log(
|
|
5801
5799
|
`[EventualConsistency] ${config.resource}.${config.field} - Analytics update complete for ${cohortCount} cohorts`
|
|
5802
5800
|
);
|
|
@@ -12788,7 +12786,7 @@ class Database extends EventEmitter {
|
|
|
12788
12786
|
this.id = idGenerator(7);
|
|
12789
12787
|
this.version = "1";
|
|
12790
12788
|
this.s3dbVersion = (() => {
|
|
12791
|
-
const [ok, err, version] = tryFn(() => true ? "11.0.
|
|
12789
|
+
const [ok, err, version] = tryFn(() => true ? "11.0.2" : "latest");
|
|
12792
12790
|
return ok ? version : "latest";
|
|
12793
12791
|
})();
|
|
12794
12792
|
this.resources = {};
|