s3db.js 8.0.0 → 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/PLUGINS.md +114 -39
- package/README.md +227 -0
- package/dist/s3db.cjs.js +77 -31
- package/dist/s3db.cjs.min.js +1 -1
- package/dist/s3db.d.ts +5 -0
- package/dist/s3db.es.js +77 -31
- package/dist/s3db.es.min.js +1 -1
- package/dist/s3db.iife.js +77 -31
- package/dist/s3db.iife.min.js +1 -1
- package/mcp/server.js +0 -0
- package/package.json +25 -25
- package/src/client.class.js +5 -4
- package/src/plugins/cache/memory-cache.class.js +2 -2
- package/src/plugins/cache.plugin.js +75 -21
- package/src/s3db.d.ts +5 -0
- package/mcp/README.md +0 -1062
package/dist/s3db.d.ts
CHANGED
|
@@ -8,10 +8,15 @@ declare module 's3db.js' {
|
|
|
8
8
|
|
|
9
9
|
/** HTTP Client configuration for keep-alive and connection pooling */
|
|
10
10
|
export interface HttpClientOptions {
|
|
11
|
+
/** Enable keep-alive for better performance (default: true) */
|
|
11
12
|
keepAlive?: boolean;
|
|
13
|
+
/** Keep-alive duration in milliseconds (default: 1000) */
|
|
12
14
|
keepAliveMsecs?: number;
|
|
15
|
+
/** Maximum number of sockets (default: 50) */
|
|
13
16
|
maxSockets?: number;
|
|
17
|
+
/** Maximum number of free sockets in pool (default: 10) */
|
|
14
18
|
maxFreeSockets?: number;
|
|
19
|
+
/** Request timeout in milliseconds (default: 60000) */
|
|
15
20
|
timeout?: number;
|
|
16
21
|
}
|
|
17
22
|
|
package/dist/s3db.es.js
CHANGED
|
@@ -6623,8 +6623,8 @@ class MemoryCache extends Cache {
|
|
|
6623
6623
|
super(config);
|
|
6624
6624
|
this.cache = {};
|
|
6625
6625
|
this.meta = {};
|
|
6626
|
-
this.maxSize = config.maxSize
|
|
6627
|
-
this.ttl = config.ttl
|
|
6626
|
+
this.maxSize = config.maxSize !== void 0 ? config.maxSize : 1e3;
|
|
6627
|
+
this.ttl = config.ttl !== void 0 ? config.ttl : 3e5;
|
|
6628
6628
|
}
|
|
6629
6629
|
async _set(key, data) {
|
|
6630
6630
|
if (this.maxSize > 0 && Object.keys(this.cache).length >= this.maxSize) {
|
|
@@ -7482,37 +7482,81 @@ class PartitionAwareFilesystemCache extends FilesystemCache {
|
|
|
7482
7482
|
class CachePlugin extends plugin_class_default {
|
|
7483
7483
|
constructor(options = {}) {
|
|
7484
7484
|
super(options);
|
|
7485
|
-
this.
|
|
7486
|
-
this.
|
|
7487
|
-
|
|
7488
|
-
|
|
7489
|
-
|
|
7490
|
-
|
|
7491
|
-
|
|
7492
|
-
|
|
7485
|
+
this.driverName = options.driver || "s3";
|
|
7486
|
+
this.ttl = options.ttl;
|
|
7487
|
+
this.maxSize = options.maxSize;
|
|
7488
|
+
this.config = options.config || {};
|
|
7489
|
+
this.includePartitions = options.includePartitions !== false;
|
|
7490
|
+
this.partitionStrategy = options.partitionStrategy || "hierarchical";
|
|
7491
|
+
this.partitionAware = options.partitionAware !== false;
|
|
7492
|
+
this.trackUsage = options.trackUsage !== false;
|
|
7493
|
+
this.preloadRelated = options.preloadRelated !== false;
|
|
7494
|
+
this.legacyConfig = {
|
|
7495
|
+
memoryOptions: options.memoryOptions,
|
|
7496
|
+
filesystemOptions: options.filesystemOptions,
|
|
7497
|
+
s3Options: options.s3Options,
|
|
7498
|
+
driver: options.driver
|
|
7493
7499
|
};
|
|
7494
7500
|
}
|
|
7495
7501
|
async setup(database) {
|
|
7496
7502
|
await super.setup(database);
|
|
7497
7503
|
}
|
|
7498
7504
|
async onSetup() {
|
|
7499
|
-
if (this.
|
|
7500
|
-
this.driver = this.
|
|
7501
|
-
} else if (this.
|
|
7502
|
-
|
|
7503
|
-
|
|
7504
|
-
|
|
7505
|
+
if (this.driverName && typeof this.driverName === "object") {
|
|
7506
|
+
this.driver = this.driverName;
|
|
7507
|
+
} else if (this.driverName === "memory") {
|
|
7508
|
+
const driverConfig = {
|
|
7509
|
+
...this.legacyConfig.memoryOptions,
|
|
7510
|
+
// Legacy support (lowest priority)
|
|
7511
|
+
...this.config
|
|
7512
|
+
// New config format (medium priority)
|
|
7513
|
+
};
|
|
7514
|
+
if (this.ttl !== void 0) {
|
|
7515
|
+
driverConfig.ttl = this.ttl;
|
|
7516
|
+
}
|
|
7517
|
+
if (this.maxSize !== void 0) {
|
|
7518
|
+
driverConfig.maxSize = this.maxSize;
|
|
7519
|
+
}
|
|
7520
|
+
this.driver = new memory_cache_class_default(driverConfig);
|
|
7521
|
+
} else if (this.driverName === "filesystem") {
|
|
7522
|
+
const driverConfig = {
|
|
7523
|
+
...this.legacyConfig.filesystemOptions,
|
|
7524
|
+
// Legacy support (lowest priority)
|
|
7525
|
+
...this.config
|
|
7526
|
+
// New config format (medium priority)
|
|
7527
|
+
};
|
|
7528
|
+
if (this.ttl !== void 0) {
|
|
7529
|
+
driverConfig.ttl = this.ttl;
|
|
7530
|
+
}
|
|
7531
|
+
if (this.maxSize !== void 0) {
|
|
7532
|
+
driverConfig.maxSize = this.maxSize;
|
|
7533
|
+
}
|
|
7534
|
+
if (this.partitionAware) {
|
|
7505
7535
|
this.driver = new PartitionAwareFilesystemCache({
|
|
7506
|
-
partitionStrategy: this.
|
|
7507
|
-
trackUsage: this.
|
|
7508
|
-
preloadRelated: this.
|
|
7509
|
-
...
|
|
7536
|
+
partitionStrategy: this.partitionStrategy,
|
|
7537
|
+
trackUsage: this.trackUsage,
|
|
7538
|
+
preloadRelated: this.preloadRelated,
|
|
7539
|
+
...driverConfig
|
|
7510
7540
|
});
|
|
7511
7541
|
} else {
|
|
7512
|
-
this.driver = new FilesystemCache(
|
|
7542
|
+
this.driver = new FilesystemCache(driverConfig);
|
|
7513
7543
|
}
|
|
7514
7544
|
} else {
|
|
7515
|
-
|
|
7545
|
+
const driverConfig = {
|
|
7546
|
+
client: this.database.client,
|
|
7547
|
+
// Required for S3Cache
|
|
7548
|
+
...this.legacyConfig.s3Options,
|
|
7549
|
+
// Legacy support (lowest priority)
|
|
7550
|
+
...this.config
|
|
7551
|
+
// New config format (medium priority)
|
|
7552
|
+
};
|
|
7553
|
+
if (this.ttl !== void 0) {
|
|
7554
|
+
driverConfig.ttl = this.ttl;
|
|
7555
|
+
}
|
|
7556
|
+
if (this.maxSize !== void 0) {
|
|
7557
|
+
driverConfig.maxSize = this.maxSize;
|
|
7558
|
+
}
|
|
7559
|
+
this.driver = new s3_cache_class_default(driverConfig);
|
|
7516
7560
|
}
|
|
7517
7561
|
this.installDatabaseHooks();
|
|
7518
7562
|
this.installResourceHooks();
|
|
@@ -9621,14 +9665,16 @@ class Client extends EventEmitter {
|
|
|
9621
9665
|
this.parallelism = parallelism;
|
|
9622
9666
|
this.config = new ConnectionString(connectionString);
|
|
9623
9667
|
this.httpClientOptions = {
|
|
9624
|
-
keepAlive:
|
|
9625
|
-
//
|
|
9626
|
-
|
|
9627
|
-
//
|
|
9628
|
-
|
|
9629
|
-
//
|
|
9630
|
-
|
|
9631
|
-
//
|
|
9668
|
+
keepAlive: true,
|
|
9669
|
+
// Enabled for better performance
|
|
9670
|
+
keepAliveMsecs: 1e3,
|
|
9671
|
+
// 1 second keep-alive
|
|
9672
|
+
maxSockets: 50,
|
|
9673
|
+
// Balanced for most applications
|
|
9674
|
+
maxFreeSockets: 10,
|
|
9675
|
+
// Good connection reuse
|
|
9676
|
+
timeout: 6e4,
|
|
9677
|
+
// 60 second timeout
|
|
9632
9678
|
...httpClientOptions
|
|
9633
9679
|
};
|
|
9634
9680
|
this.client = AwsS3Client || this.createClient();
|
|
@@ -13378,7 +13424,7 @@ class Database extends EventEmitter {
|
|
|
13378
13424
|
super();
|
|
13379
13425
|
this.version = "1";
|
|
13380
13426
|
this.s3dbVersion = (() => {
|
|
13381
|
-
const [ok, err, version] = try_fn_default(() => true ? "
|
|
13427
|
+
const [ok, err, version] = try_fn_default(() => true ? "8.0.2" : "latest");
|
|
13382
13428
|
return ok ? version : "latest";
|
|
13383
13429
|
})();
|
|
13384
13430
|
this.resources = {};
|