s3db.js 8.0.1 → 8.0.3

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();
@@ -9607,7 +9651,7 @@ ${JSON.stringify(validation, null, 2)}`,
9607
9651
  }) {
9608
9652
  super();
9609
9653
  this.verbose = verbose;
9610
- this.id = id ?? idGenerator();
9654
+ this.id = id ?? idGenerator(77);
9611
9655
  this.parallelism = parallelism;
9612
9656
  this.config = new ConnectionString(connectionString);
9613
9657
  this.httpClientOptions = {
@@ -11194,10 +11238,18 @@ ${JSON.stringify(validation, null, 2)}`,
11194
11238
  */
11195
11239
  constructor(config = {}) {
11196
11240
  super();
11197
- this._instanceId = Math.random().toString(36).slice(2, 8);
11241
+ this._instanceId = idGenerator(7);
11198
11242
  const validation = validateResourceConfig(config);
11199
11243
  if (!validation.isValid) {
11200
- throw new ResourceError(`Invalid Resource ${config.name} configuration`, { resourceName: config.name, validation: validation.errors, operation: "constructor", suggestion: "Check resource config and attributes." });
11244
+ const errorDetails = validation.errors.map((err) => ` \u2022 ${err}`).join("\n");
11245
+ throw new ResourceError(
11246
+ `Invalid Resource ${config.name || "[unnamed]"} configuration:
11247
+ ${errorDetails}`,
11248
+ {
11249
+ resourceName: config.name,
11250
+ validation: validation.errors
11251
+ }
11252
+ );
11201
11253
  }
11202
11254
  const {
11203
11255
  name,
@@ -13368,9 +13420,10 @@ ${JSON.stringify(validation, null, 2)}`,
13368
13420
  class Database extends EventEmitter {
13369
13421
  constructor(options) {
13370
13422
  super();
13423
+ this.id = idGenerator(7);
13371
13424
  this.version = "1";
13372
13425
  this.s3dbVersion = (() => {
13373
- const [ok, err, version] = try_fn_default(() => true ? "8.0.0" : "latest");
13426
+ const [ok, err, version] = try_fn_default(() => true ? "8.0.2" : "latest");
13374
13427
  return ok ? version : "latest";
13375
13428
  })();
13376
13429
  this.resources = {};