s3db.js 7.3.4 → 7.3.5
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 +26 -36
- package/dist/s3db.cjs.min.js +1 -1
- package/dist/s3db.es.js +26 -36
- package/dist/s3db.es.min.js +1 -1
- package/dist/s3db.iife.js +27 -37
- package/dist/s3db.iife.min.js +1 -1
- package/package.json +24 -24
- package/src/database.class.js +10 -8
- package/src/plugins/metrics.plugin.js +18 -8
- package/src/plugins/replicator.plugin.js +0 -26
- package/src/plugins/replicators/s3db-replicator.class.js +3 -3
package/dist/s3db.iife.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var S3DB = (function (exports, nanoid, zlib, promisePool, web, promises,
|
|
1
|
+
var S3DB = (function (exports, nanoid, zlib, promisePool, web, promises, crypto, lodashEs, jsonStableStringify, clientS3, flat, FastestValidator) {
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
const alphabet = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
@@ -8340,7 +8340,7 @@ ${JSON.stringify(validation, null, 2)}`,
|
|
|
8340
8340
|
}
|
|
8341
8341
|
async setup(database) {
|
|
8342
8342
|
this.database = database;
|
|
8343
|
-
if (process.env.NODE_ENV === "test") return;
|
|
8343
|
+
if (typeof process !== "undefined" && process.env.NODE_ENV === "test") return;
|
|
8344
8344
|
const [ok, err] = await try_fn_default(async () => {
|
|
8345
8345
|
const [ok1, err1, metricsResource] = await try_fn_default(() => database.createResource({
|
|
8346
8346
|
name: "metrics",
|
|
@@ -8390,7 +8390,7 @@ ${JSON.stringify(validation, null, 2)}`,
|
|
|
8390
8390
|
this.performanceResource = database.resources.performance_logs;
|
|
8391
8391
|
}
|
|
8392
8392
|
this.installMetricsHooks();
|
|
8393
|
-
if (process.env.NODE_ENV !== "test") {
|
|
8393
|
+
if (typeof process !== "undefined" && process.env.NODE_ENV !== "test") {
|
|
8394
8394
|
this.startFlushTimer();
|
|
8395
8395
|
}
|
|
8396
8396
|
}
|
|
@@ -8401,7 +8401,7 @@ ${JSON.stringify(validation, null, 2)}`,
|
|
|
8401
8401
|
clearInterval(this.flushTimer);
|
|
8402
8402
|
this.flushTimer = null;
|
|
8403
8403
|
}
|
|
8404
|
-
if (process.env.NODE_ENV !== "test") {
|
|
8404
|
+
if (typeof process !== "undefined" && process.env.NODE_ENV !== "test") {
|
|
8405
8405
|
await this.flushMetrics();
|
|
8406
8406
|
}
|
|
8407
8407
|
}
|
|
@@ -8580,10 +8580,18 @@ ${JSON.stringify(validation, null, 2)}`,
|
|
|
8580
8580
|
async flushMetrics() {
|
|
8581
8581
|
if (!this.metricsResource) return;
|
|
8582
8582
|
const [ok, err] = await try_fn_default(async () => {
|
|
8583
|
-
|
|
8584
|
-
|
|
8585
|
-
|
|
8586
|
-
|
|
8583
|
+
let metadata, perfMetadata, errorMetadata, resourceMetadata;
|
|
8584
|
+
if (typeof process !== "undefined" && process.env.NODE_ENV === "test") {
|
|
8585
|
+
metadata = {};
|
|
8586
|
+
perfMetadata = {};
|
|
8587
|
+
errorMetadata = {};
|
|
8588
|
+
resourceMetadata = {};
|
|
8589
|
+
} else {
|
|
8590
|
+
metadata = { global: "true" };
|
|
8591
|
+
perfMetadata = { perf: "true" };
|
|
8592
|
+
errorMetadata = { error: "true" };
|
|
8593
|
+
resourceMetadata = { resource: "true" };
|
|
8594
|
+
}
|
|
8587
8595
|
for (const [operation, data] of Object.entries(this.metrics.operations)) {
|
|
8588
8596
|
if (data.count > 0) {
|
|
8589
8597
|
await this.metricsResource.insert({
|
|
@@ -13159,14 +13167,16 @@ ${JSON.stringify(validation, null, 2)}`,
|
|
|
13159
13167
|
this.keyPrefix = this.client.keyPrefix;
|
|
13160
13168
|
if (!this._exitListenerRegistered) {
|
|
13161
13169
|
this._exitListenerRegistered = true;
|
|
13162
|
-
process
|
|
13163
|
-
|
|
13164
|
-
|
|
13165
|
-
|
|
13166
|
-
|
|
13170
|
+
if (typeof process !== "undefined") {
|
|
13171
|
+
process.on("exit", async () => {
|
|
13172
|
+
if (this.isConnected()) {
|
|
13173
|
+
try {
|
|
13174
|
+
await this.disconnect();
|
|
13175
|
+
} catch (err) {
|
|
13176
|
+
}
|
|
13167
13177
|
}
|
|
13168
|
-
}
|
|
13169
|
-
}
|
|
13178
|
+
});
|
|
13179
|
+
}
|
|
13170
13180
|
}
|
|
13171
13181
|
}
|
|
13172
13182
|
async connect() {
|
|
@@ -13749,7 +13759,7 @@ ${JSON.stringify(validation, null, 2)}`,
|
|
|
13749
13759
|
if (typeof entry[0] === "function") return resource;
|
|
13750
13760
|
}
|
|
13751
13761
|
if (typeof entry === "string") return entry;
|
|
13752
|
-
if (
|
|
13762
|
+
if (typeof entry === "function") return resource;
|
|
13753
13763
|
if (typeof entry === "object" && entry.resource) return entry.resource;
|
|
13754
13764
|
return resource;
|
|
13755
13765
|
}
|
|
@@ -14298,31 +14308,11 @@ ${JSON.stringify(validation, null, 2)}`,
|
|
|
14298
14308
|
}
|
|
14299
14309
|
async stop() {
|
|
14300
14310
|
}
|
|
14301
|
-
filterInternalFields(data) {
|
|
14302
|
-
if (!data || typeof data !== "object") return data;
|
|
14303
|
-
const filtered = {};
|
|
14304
|
-
for (const [key, value] of Object.entries(data)) {
|
|
14305
|
-
if (!key.startsWith("_") && !key.startsWith("$")) {
|
|
14306
|
-
filtered[key] = value;
|
|
14307
|
-
}
|
|
14308
|
-
}
|
|
14309
|
-
return filtered;
|
|
14310
|
-
}
|
|
14311
14311
|
async uploadMetadataFile(database) {
|
|
14312
14312
|
if (typeof database.uploadMetadataFile === "function") {
|
|
14313
14313
|
await database.uploadMetadataFile();
|
|
14314
14314
|
}
|
|
14315
14315
|
}
|
|
14316
|
-
async getCompleteData(resource, data) {
|
|
14317
|
-
try {
|
|
14318
|
-
const [ok, err, record] = await try_fn_default(() => resource.get(data.id));
|
|
14319
|
-
if (ok && record) {
|
|
14320
|
-
return record;
|
|
14321
|
-
}
|
|
14322
|
-
} catch (error) {
|
|
14323
|
-
}
|
|
14324
|
-
return data;
|
|
14325
|
-
}
|
|
14326
14316
|
async retryWithBackoff(operation, maxRetries = 3) {
|
|
14327
14317
|
let lastError;
|
|
14328
14318
|
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
@@ -14666,4 +14656,4 @@ ${JSON.stringify(validation, null, 2)}`,
|
|
|
14666
14656
|
|
|
14667
14657
|
return exports;
|
|
14668
14658
|
|
|
14669
|
-
})({}, nanoid, zlib, PromisePool, streams, promises,
|
|
14659
|
+
})({}, nanoid, zlib, PromisePool, streams, promises, crypto, _, stringify, AWS, flat, FastestValidator);
|