@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.
Files changed (38) hide show
  1. package/.turbo/turbo-build$colon$cjs.log +20 -17
  2. package/.turbo/turbo-build$colon$tsc.log +16 -16
  3. package/.turbo/turbo-build.log +21 -18
  4. package/CHANGELOG.md +24 -0
  5. package/dist/_virtual/_rolldown/runtime.js +3 -0
  6. package/dist/base/index.js +1 -4
  7. package/dist/base/mongo.js +133 -137
  8. package/dist/base/mongoMemory.js +21 -21
  9. package/dist/cjs/_virtual/_rolldown/runtime.cjs +23 -0
  10. package/dist/cjs/base/index.cjs +4 -6
  11. package/dist/cjs/base/mongo.cjs +140 -143
  12. package/dist/cjs/base/mongoMemory.cjs +22 -22
  13. package/dist/cjs/databases/captcha.cjs +220 -256
  14. package/dist/cjs/databases/centralDbStreamer.cjs +148 -170
  15. package/dist/cjs/databases/client.cjs +46 -62
  16. package/dist/cjs/databases/index.cjs +19 -19
  17. package/dist/cjs/databases/provider.cjs +1827 -2251
  18. package/dist/cjs/index.cjs +25 -23
  19. package/dist/cjs/mongooseOptions.cjs +59 -58
  20. package/dist/cjs/redisCache.cjs +432 -474
  21. package/dist/databases/captcha.d.ts.map +1 -1
  22. package/dist/databases/captcha.js +217 -253
  23. package/dist/databases/captcha.js.map +1 -1
  24. package/dist/databases/centralDbStreamer.js +147 -169
  25. package/dist/databases/client.js +44 -60
  26. package/dist/databases/index.js +10 -14
  27. package/dist/databases/provider.d.ts +4 -4
  28. package/dist/databases/provider.d.ts.map +1 -1
  29. package/dist/databases/provider.js +1823 -2247
  30. package/dist/databases/provider.js.map +1 -1
  31. package/dist/index.js +9 -18
  32. package/dist/mongooseOptions.js +59 -59
  33. package/dist/redisCache.js +432 -474
  34. package/dist/tests/integration/saveCaptchasSessionUpsert.integration.test.d.ts +2 -0
  35. package/dist/tests/integration/saveCaptchasSessionUpsert.integration.test.d.ts.map +1 -0
  36. package/dist/tests/integration/saveCaptchasSessionUpsert.integration.test.js +64 -0
  37. package/dist/tests/integration/saveCaptchasSessionUpsert.integration.test.js.map +1 -0
  38. package/package.json +14 -14
@@ -1,24 +1,26 @@
1
- "use strict";
2
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const makeDir = require("make-dir");
4
- require("./base/index.cjs");
5
- const index = require("./databases/index.cjs");
6
- const mongooseOptions = require("./mongooseOptions.cjs");
7
- const redisCache = require("./redisCache.cjs");
8
- const mongo = require("./base/mongo.cjs");
9
- const mongoMemory = require("./base/mongoMemory.cjs");
10
- const provider = require("./databases/provider.cjs");
11
- const captcha = require("./databases/captcha.cjs");
12
- const centralDbStreamer = require("./databases/centralDbStreamer.cjs");
13
- const client = require("./databases/client.cjs");
14
- console.debug(makeDir);
15
- exports.Databases = index.Databases;
16
- exports.getMongoCompressors = mongooseOptions.getMongoCompressors;
17
- exports.getMongoConnectionOptions = mongooseOptions.getMongoConnectionOptions;
18
- exports.RedisWriteQueue = redisCache.RedisWriteQueue;
19
- exports.MongoDatabase = mongo.MongoDatabase;
20
- exports.MongoMemoryDatabase = mongoMemory.MongoMemoryDatabase;
21
- exports.ProviderDatabase = provider.ProviderDatabase;
22
- exports.CaptchaDatabase = captcha.CaptchaDatabase;
23
- exports.CentralDbStreamer = centralDbStreamer.CentralDbStreamer;
24
- exports.ClientDatabase = client.ClientDatabase;
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
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const mongodb = require("mongodb");
4
- const DEFAULT_COMPRESSORS = [];
5
- const getMongoCompressors = (url, compressors = DEFAULT_COMPRESSORS) => {
6
- try {
7
- const protocolIndex = url.indexOf("://");
8
- const urlWithoutProtocol = protocolIndex !== -1 ? url.slice(protocolIndex + 3) : url;
9
- if (urlWithoutProtocol.trim() === "") {
10
- return [];
11
- }
12
- const parsedUrl = new URL(`mongodb://${urlWithoutProtocol}`);
13
- const hostname = parsedUrl.hostname;
14
- const isLocalhost = hostname === "localhost" || hostname === "127.0.0.1" || hostname === "[::1]" || hostname === "::1";
15
- if (isLocalhost) {
16
- return [];
17
- }
18
- return hostname.includes(".") || hostname.includes(":") ? [...compressors] : [];
19
- } catch {
20
- return [...compressors];
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
- const getMongoConnectionOptions = (options) => {
24
- const { url, appName, maxPoolSize = 10, minPoolSize = 0, dbName } = options;
25
- if (!url || url.trim() === "") {
26
- throw new Error(
27
- "MongoDB connection URL is required and cannot be empty or whitespace-only"
28
- );
29
- }
30
- const compressors = getMongoCompressors(url);
31
- const connectionOptions = {
32
- serverApi: {
33
- version: mongodb.ServerApiVersion.v1,
34
- // strict mode rejects any command outside the Stable API; leave it
35
- // off so non-stable operations (index/admin commands etc.) keep working.
36
- strict: false,
37
- deprecationErrors: false
38
- },
39
- maxPoolSize,
40
- // allow up to N connections at any given time. >1 connection allows parallel db operations
41
- minPoolSize,
42
- // pool may close idle connections down to this amount (0 = close all idle past maxIdleTimeMS)
43
- maxConnecting: 2,
44
- // maximum number of concurrent connection attempts
45
- connectTimeoutMS: 1e4,
46
- // max time to connect to the database
47
- socketTimeoutMS: 3e4,
48
- // max time to wait for a response from the database when doing an operation
49
- maxIdleTimeMS: 3e5,
50
- // max time spent idle before closing the connection
51
- appName,
52
- serverSelectionTimeoutMS: 2e4,
53
- // max time to wait for a response from the database
54
- compressors
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;