s3db.js 10.0.17 → 10.0.19

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