s3db.js 8.0.1 → 8.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.iife.js CHANGED
@@ -6613,8 +6613,8 @@ ${JSON.stringify(validation, null, 2)}`,
6613
6613
  super(config);
6614
6614
  this.cache = {};
6615
6615
  this.meta = {};
6616
- this.maxSize = config.maxSize || 0;
6617
- this.ttl = config.ttl || 0;
6616
+ this.maxSize = config.maxSize !== void 0 ? config.maxSize : 1e3;
6617
+ this.ttl = config.ttl !== void 0 ? config.ttl : 3e5;
6618
6618
  }
6619
6619
  async _set(key, data) {
6620
6620
  if (this.maxSize > 0 && Object.keys(this.cache).length >= this.maxSize) {
@@ -7472,37 +7472,81 @@ ${JSON.stringify(validation, null, 2)}`,
7472
7472
  class CachePlugin extends plugin_class_default {
7473
7473
  constructor(options = {}) {
7474
7474
  super(options);
7475
- this.driver = options.driver;
7476
- this.config = {
7477
- includePartitions: options.includePartitions !== false,
7478
- partitionStrategy: options.partitionStrategy || "hierarchical",
7479
- partitionAware: options.partitionAware !== false,
7480
- trackUsage: options.trackUsage !== false,
7481
- preloadRelated: options.preloadRelated !== false,
7482
- ...options
7475
+ this.driverName = options.driver || "s3";
7476
+ this.ttl = options.ttl;
7477
+ this.maxSize = options.maxSize;
7478
+ this.config = options.config || {};
7479
+ this.includePartitions = options.includePartitions !== false;
7480
+ this.partitionStrategy = options.partitionStrategy || "hierarchical";
7481
+ this.partitionAware = options.partitionAware !== false;
7482
+ this.trackUsage = options.trackUsage !== false;
7483
+ this.preloadRelated = options.preloadRelated !== false;
7484
+ this.legacyConfig = {
7485
+ memoryOptions: options.memoryOptions,
7486
+ filesystemOptions: options.filesystemOptions,
7487
+ s3Options: options.s3Options,
7488
+ driver: options.driver
7483
7489
  };
7484
7490
  }
7485
7491
  async setup(database) {
7486
7492
  await super.setup(database);
7487
7493
  }
7488
7494
  async onSetup() {
7489
- if (this.config.driver && typeof this.config.driver === "object") {
7490
- this.driver = this.config.driver;
7491
- } else if (this.config.driver === "memory") {
7492
- this.driver = new memory_cache_class_default(this.config.memoryOptions || {});
7493
- } else if (this.config.driver === "filesystem") {
7494
- if (this.config.partitionAware) {
7495
+ if (this.driverName && typeof this.driverName === "object") {
7496
+ this.driver = this.driverName;
7497
+ } else if (this.driverName === "memory") {
7498
+ const driverConfig = {
7499
+ ...this.legacyConfig.memoryOptions,
7500
+ // Legacy support (lowest priority)
7501
+ ...this.config
7502
+ // New config format (medium priority)
7503
+ };
7504
+ if (this.ttl !== void 0) {
7505
+ driverConfig.ttl = this.ttl;
7506
+ }
7507
+ if (this.maxSize !== void 0) {
7508
+ driverConfig.maxSize = this.maxSize;
7509
+ }
7510
+ this.driver = new memory_cache_class_default(driverConfig);
7511
+ } else if (this.driverName === "filesystem") {
7512
+ const driverConfig = {
7513
+ ...this.legacyConfig.filesystemOptions,
7514
+ // Legacy support (lowest priority)
7515
+ ...this.config
7516
+ // New config format (medium priority)
7517
+ };
7518
+ if (this.ttl !== void 0) {
7519
+ driverConfig.ttl = this.ttl;
7520
+ }
7521
+ if (this.maxSize !== void 0) {
7522
+ driverConfig.maxSize = this.maxSize;
7523
+ }
7524
+ if (this.partitionAware) {
7495
7525
  this.driver = new PartitionAwareFilesystemCache({
7496
- partitionStrategy: this.config.partitionStrategy,
7497
- trackUsage: this.config.trackUsage,
7498
- preloadRelated: this.config.preloadRelated,
7499
- ...this.config.filesystemOptions
7526
+ partitionStrategy: this.partitionStrategy,
7527
+ trackUsage: this.trackUsage,
7528
+ preloadRelated: this.preloadRelated,
7529
+ ...driverConfig
7500
7530
  });
7501
7531
  } else {
7502
- this.driver = new FilesystemCache(this.config.filesystemOptions || {});
7532
+ this.driver = new FilesystemCache(driverConfig);
7503
7533
  }
7504
7534
  } else {
7505
- this.driver = new s3_cache_class_default({ client: this.database.client, ...this.config.s3Options || {} });
7535
+ const driverConfig = {
7536
+ client: this.database.client,
7537
+ // Required for S3Cache
7538
+ ...this.legacyConfig.s3Options,
7539
+ // Legacy support (lowest priority)
7540
+ ...this.config
7541
+ // New config format (medium priority)
7542
+ };
7543
+ if (this.ttl !== void 0) {
7544
+ driverConfig.ttl = this.ttl;
7545
+ }
7546
+ if (this.maxSize !== void 0) {
7547
+ driverConfig.maxSize = this.maxSize;
7548
+ }
7549
+ this.driver = new s3_cache_class_default(driverConfig);
7506
7550
  }
7507
7551
  this.installDatabaseHooks();
7508
7552
  this.installResourceHooks();
@@ -13370,7 +13414,7 @@ ${JSON.stringify(validation, null, 2)}`,
13370
13414
  super();
13371
13415
  this.version = "1";
13372
13416
  this.s3dbVersion = (() => {
13373
- const [ok, err, version] = try_fn_default(() => true ? "8.0.0" : "latest");
13417
+ const [ok, err, version] = try_fn_default(() => true ? "8.0.2" : "latest");
13374
13418
  return ok ? version : "latest";
13375
13419
  })();
13376
13420
  this.resources = {};