s3db.js 10.0.17 → 10.0.18

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.es.js CHANGED
@@ -4304,10 +4304,19 @@ const CostsPlugin = {
4304
4304
  };
4305
4305
 
4306
4306
  function createConfig(options, detectedTimezone) {
4307
+ const consolidation = options.consolidation || {};
4308
+ const locks = options.locks || {};
4309
+ const gc = options.garbageCollection || {};
4310
+ const analytics = options.analytics || {};
4311
+ const batch = options.batch || {};
4312
+ const lateArrivals = options.lateArrivals || {};
4313
+ const checkpoints = options.checkpoints || {};
4307
4314
  return {
4315
+ // Cohort (timezone)
4308
4316
  cohort: {
4309
4317
  timezone: options.cohort?.timezone || detectedTimezone
4310
4318
  },
4319
+ // Reducer function
4311
4320
  reducer: options.reducer || ((transactions) => {
4312
4321
  let baseValue = 0;
4313
4322
  for (const t of transactions) {
@@ -4321,38 +4330,39 @@ function createConfig(options, detectedTimezone) {
4321
4330
  }
4322
4331
  return baseValue;
4323
4332
  }),
4324
- consolidationInterval: options.consolidationInterval ?? 300,
4325
- consolidationConcurrency: options.consolidationConcurrency || 5,
4326
- consolidationWindow: options.consolidationWindow || 24,
4327
- autoConsolidate: options.autoConsolidate !== false,
4328
- lateArrivalStrategy: options.lateArrivalStrategy || "warn",
4329
- batchTransactions: options.batchTransactions || false,
4330
- batchSize: options.batchSize || 100,
4331
- mode: options.mode || "async",
4332
- lockTimeout: options.lockTimeout || 300,
4333
- transactionRetention: options.transactionRetention || 30,
4334
- gcInterval: options.gcInterval || 86400,
4335
- verbose: options.verbose || false,
4336
- enableAnalytics: options.enableAnalytics || false,
4333
+ // Consolidation settings
4334
+ consolidationInterval: consolidation.interval ?? 300,
4335
+ consolidationConcurrency: consolidation.concurrency ?? 5,
4336
+ consolidationWindow: consolidation.window ?? 24,
4337
+ autoConsolidate: consolidation.auto !== false,
4338
+ mode: consolidation.mode || "async",
4339
+ // Late arrivals
4340
+ lateArrivalStrategy: lateArrivals.strategy || "warn",
4341
+ // Batch transactions
4342
+ batchTransactions: batch.enabled || false,
4343
+ batchSize: batch.size || 100,
4344
+ // Locks
4345
+ lockTimeout: locks.timeout || 300,
4346
+ // Garbage collection
4347
+ transactionRetention: gc.retention ?? 30,
4348
+ gcInterval: gc.interval ?? 86400,
4349
+ // Analytics
4350
+ enableAnalytics: analytics.enabled || false,
4337
4351
  analyticsConfig: {
4338
- periods: options.analyticsConfig?.periods || ["hour", "day", "month"],
4339
- metrics: options.analyticsConfig?.metrics || ["count", "sum", "avg", "min", "max"],
4340
- rollupStrategy: options.analyticsConfig?.rollupStrategy || "incremental",
4341
- retentionDays: options.analyticsConfig?.retentionDays || 365
4352
+ periods: analytics.periods || ["hour", "day", "month"],
4353
+ metrics: analytics.metrics || ["count", "sum", "avg", "min", "max"],
4354
+ rollupStrategy: analytics.rollupStrategy || "incremental",
4355
+ retentionDays: analytics.retentionDays ?? 365
4342
4356
  },
4343
- // Checkpoint configuration for high-volume scenarios
4344
- enableCheckpoints: options.enableCheckpoints !== false,
4345
- // Default: true
4346
- checkpointStrategy: options.checkpointStrategy || "hourly",
4347
- // 'hourly', 'daily', 'manual', 'disabled'
4348
- checkpointRetention: options.checkpointRetention || 90,
4349
- // Days to keep checkpoints
4350
- checkpointThreshold: options.checkpointThreshold || 1e3,
4351
- // Min transactions before creating checkpoint
4352
- deleteConsolidatedTransactions: options.deleteConsolidatedTransactions !== false,
4353
- // Delete transactions after checkpoint
4354
- autoCheckpoint: options.autoCheckpoint !== false
4355
- // Auto-create checkpoints for old cohorts
4357
+ // Checkpoints
4358
+ enableCheckpoints: checkpoints.enabled !== false,
4359
+ checkpointStrategy: checkpoints.strategy || "hourly",
4360
+ checkpointRetention: checkpoints.retention ?? 90,
4361
+ checkpointThreshold: checkpoints.threshold ?? 1e3,
4362
+ deleteConsolidatedTransactions: checkpoints.deleteConsolidated !== false,
4363
+ autoCheckpoint: checkpoints.auto !== false,
4364
+ // Debug
4365
+ verbose: options.verbose || false
4356
4366
  };
4357
4367
  }
4358
4368
  function validateResourcesConfig(resources) {
@@ -4372,7 +4382,12 @@ function validateResourcesConfig(resources) {
4372
4382
  function logConfigWarnings(config) {
4373
4383
  if (config.batchTransactions && !config.verbose) {
4374
4384
  console.warn(
4375
- `[EventualConsistency] WARNING: batchTransactions is enabled. This stores transactions in memory and will lose data if container crashes. Not recommended for distributed/production environments.`
4385
+ `[EventualConsistency] WARNING: batch.enabled is true. This stores transactions in memory and will lose data if container crashes. Not recommended for distributed/production environments.`
4386
+ );
4387
+ }
4388
+ if (!config.enableCheckpoints && !config.verbose) {
4389
+ console.warn(
4390
+ `[EventualConsistency] INFO: checkpoints.enabled is false. Checkpoints improve performance in high-volume scenarios by creating snapshots. Consider enabling for production use.`
4376
4391
  );
4377
4392
  }
4378
4393
  }
@@ -4384,7 +4399,7 @@ function logInitialization(config, fieldHandlers, timezoneAutoDetected) {
4384
4399
  );
4385
4400
  if (timezoneAutoDetected) {
4386
4401
  console.log(
4387
- `[EventualConsistency] Auto-detected timezone: ${config.cohort.timezone} (from ${process.env.TZ ? "TZ env var" : "system Intl API"})`
4402
+ `[EventualConsistency] Using timezone: ${config.cohort.timezone} (${process.env.TZ ? "from TZ env var" : "default UTC"})`
4388
4403
  );
4389
4404
  }
4390
4405
  }
@@ -4393,13 +4408,6 @@ function detectTimezone() {
4393
4408
  if (process.env.TZ) {
4394
4409
  return process.env.TZ;
4395
4410
  }
4396
- try {
4397
- const systemTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
4398
- if (systemTimezone) {
4399
- return systemTimezone;
4400
- }
4401
- } catch (err) {
4402
- }
4403
4411
  return "UTC";
4404
4412
  }
4405
4413
  function getTimezoneOffset(timezone, verbose = false) {
@@ -12340,7 +12348,7 @@ class Database extends EventEmitter {
12340
12348
  this.id = idGenerator(7);
12341
12349
  this.version = "1";
12342
12350
  this.s3dbVersion = (() => {
12343
- const [ok, err, version] = tryFn(() => true ? "10.0.17" : "latest");
12351
+ const [ok, err, version] = tryFn(() => true ? "10.0.18" : "latest");
12344
12352
  return ok ? version : "latest";
12345
12353
  })();
12346
12354
  this.resources = {};