@prosopo/database 3.15.19 → 3.15.21
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/.turbo/turbo-build$colon$cjs.log +20 -17
- package/.turbo/turbo-build$colon$tsc.log +16 -16
- package/.turbo/turbo-build.log +21 -18
- package/CHANGELOG.md +24 -0
- package/dist/_virtual/_rolldown/runtime.js +3 -0
- package/dist/base/index.js +1 -4
- package/dist/base/mongo.js +133 -137
- package/dist/base/mongoMemory.js +21 -21
- package/dist/cjs/_virtual/_rolldown/runtime.cjs +23 -0
- package/dist/cjs/base/index.cjs +4 -6
- package/dist/cjs/base/mongo.cjs +140 -143
- package/dist/cjs/base/mongoMemory.cjs +22 -22
- package/dist/cjs/databases/captcha.cjs +220 -256
- package/dist/cjs/databases/centralDbStreamer.cjs +148 -170
- package/dist/cjs/databases/client.cjs +46 -62
- package/dist/cjs/databases/index.cjs +19 -19
- package/dist/cjs/databases/provider.cjs +1827 -2251
- package/dist/cjs/index.cjs +25 -23
- package/dist/cjs/mongooseOptions.cjs +59 -58
- package/dist/cjs/redisCache.cjs +432 -474
- package/dist/databases/captcha.d.ts.map +1 -1
- package/dist/databases/captcha.js +217 -253
- package/dist/databases/captcha.js.map +1 -1
- package/dist/databases/centralDbStreamer.js +147 -169
- package/dist/databases/client.js +44 -60
- package/dist/databases/index.js +10 -14
- package/dist/databases/provider.d.ts +4 -4
- package/dist/databases/provider.d.ts.map +1 -1
- package/dist/databases/provider.js +1823 -2247
- package/dist/databases/provider.js.map +1 -1
- package/dist/index.js +9 -18
- package/dist/mongooseOptions.js +59 -59
- package/dist/redisCache.js +432 -474
- package/dist/tests/integration/saveCaptchasSessionUpsert.integration.test.d.ts +2 -0
- package/dist/tests/integration/saveCaptchasSessionUpsert.integration.test.d.ts.map +1 -0
- package/dist/tests/integration/saveCaptchasSessionUpsert.integration.test.js +64 -0
- package/dist/tests/integration/saveCaptchasSessionUpsert.integration.test.js.map +1 -0
- package/package.json +14 -14
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const
|
|
4
|
-
require("./
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
exports.
|
|
19
|
-
exports.
|
|
20
|
-
exports.
|
|
21
|
-
exports.
|
|
22
|
-
exports.
|
|
23
|
-
exports.
|
|
24
|
-
exports.
|
|
2
|
+
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
|
|
3
|
+
const require_mongooseOptions = require("./mongooseOptions.cjs");
|
|
4
|
+
const require_mongo = require("./base/mongo.cjs");
|
|
5
|
+
const require_mongoMemory = require("./base/mongoMemory.cjs");
|
|
6
|
+
const require_captcha = require("./databases/captcha.cjs");
|
|
7
|
+
const require_client = require("./databases/client.cjs");
|
|
8
|
+
const require_provider = require("./databases/provider.cjs");
|
|
9
|
+
const require_centralDbStreamer = require("./databases/centralDbStreamer.cjs");
|
|
10
|
+
const require_index = require("./databases/index.cjs");
|
|
11
|
+
const require_redisCache = require("./redisCache.cjs");
|
|
12
|
+
let make_dir = require("make-dir");
|
|
13
|
+
make_dir = require_runtime.__toESM(make_dir, 1);
|
|
14
|
+
//#region src/index.ts
|
|
15
|
+
console.debug(make_dir.default);
|
|
16
|
+
//#endregion
|
|
17
|
+
exports.CaptchaDatabase = require_captcha.CaptchaDatabase;
|
|
18
|
+
exports.CentralDbStreamer = require_centralDbStreamer.CentralDbStreamer;
|
|
19
|
+
exports.ClientDatabase = require_client.ClientDatabase;
|
|
20
|
+
exports.Databases = require_index.Databases;
|
|
21
|
+
exports.MongoDatabase = require_mongo.MongoDatabase;
|
|
22
|
+
exports.MongoMemoryDatabase = require_mongoMemory.MongoMemoryDatabase;
|
|
23
|
+
exports.ProviderDatabase = require_provider.ProviderDatabase;
|
|
24
|
+
exports.RedisWriteQueue = require_redisCache.RedisWriteQueue;
|
|
25
|
+
exports.getMongoCompressors = require_mongooseOptions.getMongoCompressors;
|
|
26
|
+
exports.getMongoConnectionOptions = require_mongooseOptions.getMongoConnectionOptions;
|
|
@@ -1,62 +1,63 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
let mongodb = require("mongodb");
|
|
2
|
+
//#region src/mongooseOptions.ts
|
|
3
|
+
var DEFAULT_COMPRESSORS = [];
|
|
4
|
+
/**
|
|
5
|
+
* Determines MongoDB compression settings based on whether the connection points
|
|
6
|
+
* at a remote host. Compression is enabled for domains (e.g. abc.com) and for
|
|
7
|
+
* IPv4/IPv6 hosts (anything whose hostname contains a "." or ":"), and disabled
|
|
8
|
+
* for localhost and bare single-label hosts (container/service names like
|
|
9
|
+
* "database", "db", "mongo") or when no host is present.
|
|
10
|
+
*
|
|
11
|
+
* @param url - The MongoDB connection URL string
|
|
12
|
+
* @param compressors - Optional array of compressor strings. Defaults to [] (no compression)
|
|
13
|
+
* @returns A new array of compressor strings when compression is enabled, empty array otherwise
|
|
14
|
+
*/
|
|
15
|
+
var getMongoCompressors = (url, compressors = DEFAULT_COMPRESSORS) => {
|
|
16
|
+
try {
|
|
17
|
+
const protocolIndex = url.indexOf("://");
|
|
18
|
+
const urlWithoutProtocol = protocolIndex !== -1 ? url.slice(protocolIndex + 3) : url;
|
|
19
|
+
if (urlWithoutProtocol.trim() === "") return [];
|
|
20
|
+
const hostname = new URL(`mongodb://${urlWithoutProtocol}`).hostname;
|
|
21
|
+
if (hostname === "localhost" || hostname === "127.0.0.1" || hostname === "[::1]" || hostname === "::1") return [];
|
|
22
|
+
return hostname.includes(".") || hostname.includes(":") ? [...compressors] : [];
|
|
23
|
+
} catch {
|
|
24
|
+
return [...compressors];
|
|
25
|
+
}
|
|
22
26
|
};
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
if (dbName) {
|
|
57
|
-
connectionOptions.dbName = dbName;
|
|
58
|
-
}
|
|
59
|
-
return connectionOptions;
|
|
27
|
+
/**
|
|
28
|
+
* Returns default mongoose connection options with the ability to override specific values.
|
|
29
|
+
*
|
|
30
|
+
* @param options - Configuration options
|
|
31
|
+
* @param options.url - MongoDB connection URL string
|
|
32
|
+
* @param options.appName - Application name (typically from fileURLToPath(require('url').pathToFileURL(__filename).href))
|
|
33
|
+
* @param options.maxPoolSize - Maximum pool size (default: 10)
|
|
34
|
+
* @param options.minPoolSize - Minimum pool size (default: 0)
|
|
35
|
+
* @param options.dbName - Optional database name
|
|
36
|
+
* @returns Mongoose connection options object
|
|
37
|
+
*/
|
|
38
|
+
var getMongoConnectionOptions = (options) => {
|
|
39
|
+
const { url, appName, maxPoolSize = 10, minPoolSize = 0, dbName } = options;
|
|
40
|
+
if (!url || url.trim() === "") throw new Error("MongoDB connection URL is required and cannot be empty or whitespace-only");
|
|
41
|
+
const compressors = getMongoCompressors(url);
|
|
42
|
+
const connectionOptions = {
|
|
43
|
+
serverApi: {
|
|
44
|
+
version: mongodb.ServerApiVersion.v1,
|
|
45
|
+
strict: false,
|
|
46
|
+
deprecationErrors: false
|
|
47
|
+
},
|
|
48
|
+
maxPoolSize,
|
|
49
|
+
minPoolSize,
|
|
50
|
+
maxConnecting: 2,
|
|
51
|
+
connectTimeoutMS: 1e4,
|
|
52
|
+
socketTimeoutMS: 3e4,
|
|
53
|
+
maxIdleTimeMS: 3e5,
|
|
54
|
+
appName,
|
|
55
|
+
serverSelectionTimeoutMS: 2e4,
|
|
56
|
+
compressors
|
|
57
|
+
};
|
|
58
|
+
if (dbName) connectionOptions.dbName = dbName;
|
|
59
|
+
return connectionOptions;
|
|
60
60
|
};
|
|
61
|
+
//#endregion
|
|
61
62
|
exports.getMongoCompressors = getMongoCompressors;
|
|
62
63
|
exports.getMongoConnectionOptions = getMongoConnectionOptions;
|