@prosopo/database 3.0.13 → 3.4.13

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/CHANGELOG.md CHANGED
@@ -1,5 +1,380 @@
1
1
  # @prosopo/database
2
2
 
3
+ ## 3.4.13
4
+ ### Patch Changes
5
+
6
+ - Updated dependencies [8f1773a]
7
+ - @prosopo/types@3.5.11
8
+ - @prosopo/types-database@3.3.13
9
+ - @prosopo/user-access-policy@3.5.27
10
+
11
+ ## 3.4.12
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies [cb8ab85]
15
+ - @prosopo/types-database@3.3.12
16
+ - @prosopo/types@3.5.10
17
+ - @prosopo/user-access-policy@3.5.26
18
+
19
+ ## 3.4.11
20
+ ### Patch Changes
21
+
22
+ - 43907e8: Convert timestamp fields from numbers to Date objects throughout codebase
23
+ - b4639ec: Merge frictionless tokens into sessions
24
+ - Updated dependencies [43907e8]
25
+ - Updated dependencies [b4639ec]
26
+ - Updated dependencies [005ce66]
27
+ - Updated dependencies [7101036]
28
+ - @prosopo/types-database@3.3.11
29
+ - @prosopo/types@3.5.9
30
+ - @prosopo/user-access-policy@3.5.25
31
+
32
+ ## 3.4.10
33
+ ### Patch Changes
34
+
35
+ - Updated dependencies [b10a65f]
36
+ - Updated dependencies [e5c259d]
37
+ - Updated dependencies [6420187]
38
+ - @prosopo/types-database@3.3.10
39
+ - @prosopo/types@3.5.8
40
+ - @prosopo/user-access-policy@3.5.24
41
+
42
+ ## 3.4.9
43
+ ### Patch Changes
44
+
45
+ - b8185a4: feat/uap-rules-syncer
46
+ - Updated dependencies [c9d8fdf]
47
+ - Updated dependencies [b8185a4]
48
+ - Updated dependencies [3a027ef]
49
+ - Updated dependencies [3a027ef]
50
+ - @prosopo/user-access-policy@3.5.23
51
+ - @prosopo/common@3.1.21
52
+ - @prosopo/config@3.1.21
53
+ - @prosopo/types-database@3.3.9
54
+ - @prosopo/redis-client@1.0.6
55
+ - @prosopo/locale@3.1.21
56
+ - @prosopo/types@3.5.7
57
+
58
+ ## 3.4.8
59
+ ### Patch Changes
60
+
61
+ - Updated dependencies [5d11a81]
62
+ - @prosopo/types@3.5.6
63
+ - @prosopo/types-database@3.3.8
64
+ - @prosopo/user-access-policy@3.5.22
65
+
66
+ ## 3.4.7
67
+ ### Patch Changes
68
+
69
+ - Updated dependencies [494c5a8]
70
+ - @prosopo/types-database@3.3.7
71
+ - @prosopo/types@3.5.5
72
+ - @prosopo/user-access-policy@3.5.21
73
+
74
+ ## 3.4.6
75
+ ### Patch Changes
76
+
77
+ - Updated dependencies [08ff50f]
78
+ - Updated dependencies [08ff50f]
79
+ - @prosopo/types-database@3.3.6
80
+ - @prosopo/types@3.5.4
81
+ - @prosopo/user-access-policy@3.5.20
82
+
83
+ ## 3.4.5
84
+ ### Patch Changes
85
+
86
+ - Updated dependencies [1e3a838]
87
+ - @prosopo/config@3.1.20
88
+ - @prosopo/common@3.1.20
89
+ - @prosopo/locale@3.1.20
90
+ - @prosopo/redis-client@1.0.5
91
+ - @prosopo/types@3.5.3
92
+ - @prosopo/types-database@3.3.5
93
+ - @prosopo/user-access-policy@3.5.19
94
+
95
+ ## 3.4.4
96
+ ### Patch Changes
97
+
98
+ - 5659b24: Release 3.4.4
99
+ - Updated dependencies [f912439]
100
+ - Updated dependencies [5659b24]
101
+ - @prosopo/common@3.1.19
102
+ - @prosopo/user-access-policy@3.5.18
103
+ - @prosopo/types-database@3.3.4
104
+ - @prosopo/redis-client@1.0.4
105
+ - @prosopo/locale@3.1.19
106
+ - @prosopo/types@3.5.2
107
+ - @prosopo/config@3.1.19
108
+
109
+ ## 3.4.3
110
+ ### Patch Changes
111
+
112
+ - c72ecbd: Reduce noisy logs
113
+ - 50c4120: Release 3.4.3
114
+ - Updated dependencies [52cd544]
115
+ - Updated dependencies [b117ba3]
116
+ - Updated dependencies [50c4120]
117
+ - @prosopo/types@3.5.1
118
+ - @prosopo/user-access-policy@3.5.17
119
+ - @prosopo/types-database@3.3.3
120
+ - @prosopo/redis-client@1.0.3
121
+ - @prosopo/common@3.1.18
122
+ - @prosopo/locale@3.1.18
123
+ - @prosopo/config@3.1.18
124
+
125
+ ## 3.4.2
126
+ ### Patch Changes
127
+
128
+ - 618703f: Release 3.4.2
129
+ - Updated dependencies [618703f]
130
+ - Updated dependencies [e20ad6b]
131
+ - @prosopo/user-access-policy@3.5.16
132
+ - @prosopo/types-database@3.3.2
133
+ - @prosopo/redis-client@1.0.2
134
+ - @prosopo/common@3.1.17
135
+ - @prosopo/locale@3.1.17
136
+ - @prosopo/types@3.5.0
137
+ - @prosopo/config@3.1.17
138
+
139
+ ## 3.4.1
140
+ ### Patch Changes
141
+
142
+ - 11303d9: feat/pluggable-redis
143
+ - 11303d9: Release 3.4.0
144
+ - 18cb28b: Release 3.4.1
145
+ - 11303d9: feat/pluggable-redis
146
+ - Updated dependencies [11303d9]
147
+ - Updated dependencies [b6794f8]
148
+ - Updated dependencies [11303d9]
149
+ - Updated dependencies [bac2d91]
150
+ - Updated dependencies [18cb28b]
151
+ - Updated dependencies [11303d9]
152
+ - @prosopo/user-access-policy@3.5.15
153
+ - @prosopo/redis-client@1.0.1
154
+ - @prosopo/types-database@3.3.1
155
+ - @prosopo/common@3.1.16
156
+ - @prosopo/locale@3.1.16
157
+ - @prosopo/types@3.4.1
158
+ - @prosopo/config@3.1.16
159
+
160
+ ## 3.4.0
161
+ ### Minor Changes
162
+
163
+ - 6768f14: Update salt
164
+
165
+ ### Patch Changes
166
+
167
+ - f3f7aec: Release 3.4.0
168
+ - Updated dependencies [f3f7aec]
169
+ - Updated dependencies [6768f14]
170
+ - @prosopo/user-access-policy@3.5.14
171
+ - @prosopo/types-database@3.3.0
172
+ - @prosopo/common@3.1.15
173
+ - @prosopo/locale@3.1.15
174
+ - @prosopo/types@3.4.0
175
+ - @prosopo/config@3.1.15
176
+
177
+ ## 3.3.2
178
+ ### Patch Changes
179
+
180
+ - Release 3.3.1
181
+ - 0824221: Release 3.2.4
182
+ - Updated dependencies [97edf3f]
183
+ - Updated dependencies
184
+ - Updated dependencies [0824221]
185
+ - @prosopo/types@3.3.0
186
+ - @prosopo/user-access-policy@3.5.13
187
+ - @prosopo/types-database@3.2.2
188
+ - @prosopo/common@3.1.14
189
+ - @prosopo/locale@3.1.14
190
+ - @prosopo/config@3.1.14
191
+
192
+ ## 3.3.1
193
+ ### Patch Changes
194
+
195
+ - 5137f01: Update pow record at verify
196
+ - 008d112: Release 3.3.0
197
+ - Updated dependencies [5137f01]
198
+ - Updated dependencies [0555cd8]
199
+ - Updated dependencies [509be28]
200
+ - Updated dependencies [008d112]
201
+ - @prosopo/types-database@3.2.1
202
+ - @prosopo/types@3.2.1
203
+ - @prosopo/user-access-policy@3.5.12
204
+ - @prosopo/common@3.1.13
205
+ - @prosopo/locale@3.1.13
206
+ - @prosopo/config@3.1.13
207
+
208
+ ## 3.3.0
209
+ ### Minor Changes
210
+
211
+ - cf48565: Store additional details. Remove duplicate indexes.
212
+ - 260de39: Fix indexes so that stuff properly expires
213
+
214
+ ### Patch Changes
215
+
216
+ - 0824221: Release 3.2.4
217
+ - Updated dependencies [cf48565]
218
+ - Updated dependencies [d644c04]
219
+ - Updated dependencies [0824221]
220
+ - Updated dependencies [260de39]
221
+ - @prosopo/types-database@3.2.0
222
+ - @prosopo/types@3.2.0
223
+ - @prosopo/user-access-policy@3.5.11
224
+ - @prosopo/common@3.1.12
225
+ - @prosopo/locale@3.1.12
226
+ - @prosopo/config@3.1.12
227
+
228
+ ## 3.2.4
229
+ ### Patch Changes
230
+
231
+ - 1a23649: Release 3.2.3
232
+ - Updated dependencies [0d1a33e]
233
+ - Updated dependencies [0d1a33e]
234
+ - Updated dependencies [1a23649]
235
+ - @prosopo/types-database@3.1.5
236
+ - @prosopo/locale@3.1.11
237
+ - @prosopo/types@3.1.4
238
+ - @prosopo/user-access-policy@3.5.10
239
+ - @prosopo/common@3.1.11
240
+ - @prosopo/config@3.1.11
241
+
242
+ ## 3.2.3
243
+ ### Patch Changes
244
+
245
+ - 657a827: Release 3.2.2
246
+ - Updated dependencies [a8a9251]
247
+ - Updated dependencies [657a827]
248
+ - @prosopo/types-database@3.1.4
249
+ - @prosopo/user-access-policy@3.5.9
250
+ - @prosopo/common@3.1.10
251
+ - @prosopo/locale@3.1.10
252
+ - @prosopo/types@3.1.3
253
+ - @prosopo/config@3.1.10
254
+
255
+ ## 3.2.2
256
+ ### Patch Changes
257
+
258
+ - 4440947: fix type-only tsc compilation
259
+ - 7bdaca6: Release 3.2.1
260
+ - 1249ce0: Be more lenient with random provider selection
261
+ - Updated dependencies [4440947]
262
+ - Updated dependencies [7bdaca6]
263
+ - Updated dependencies [809b984]
264
+ - Updated dependencies [1249ce0]
265
+ - Updated dependencies [809b984]
266
+ - @prosopo/user-access-policy@3.5.8
267
+ - @prosopo/types-database@3.1.3
268
+ - @prosopo/common@3.1.9
269
+ - @prosopo/locale@3.1.9
270
+ - @prosopo/types@3.1.2
271
+ - @prosopo/config@3.1.9
272
+
273
+ ## 3.2.1
274
+ ### Patch Changes
275
+
276
+ - 6fe8570: Release 3.2.0
277
+ - Updated dependencies [1f980c4]
278
+ - Updated dependencies [6fe8570]
279
+ - @prosopo/types@3.1.1
280
+ - @prosopo/user-access-policy@3.5.7
281
+ - @prosopo/types-database@3.1.2
282
+ - @prosopo/common@3.1.8
283
+ - @prosopo/locale@3.1.8
284
+ - @prosopo/config@3.1.8
285
+
286
+ ## 3.2.0
287
+ ### Minor Changes
288
+
289
+ - 8bdc7f0: Using detector to select provider
290
+
291
+ ### Patch Changes
292
+
293
+ - f304be9: Release 3.1.13
294
+ - Updated dependencies [f304be9]
295
+ - Updated dependencies [8bdc7f0]
296
+ - @prosopo/user-access-policy@3.5.6
297
+ - @prosopo/types-database@3.1.1
298
+ - @prosopo/common@3.1.7
299
+ - @prosopo/locale@3.1.7
300
+ - @prosopo/types@3.1.0
301
+ - @prosopo/config@3.1.7
302
+
303
+ ## 3.1.0
304
+ ### Minor Changes
305
+
306
+ - 9b92339: fix/ipv6-in-captcha-flow
307
+
308
+ ### Patch Changes
309
+
310
+ - a07db04: Release 3.1.12
311
+ - Updated dependencies [9b92339]
312
+ - Updated dependencies [9eed772]
313
+ - Updated dependencies [a07db04]
314
+ - @prosopo/types-database@3.1.0
315
+ - @prosopo/config@3.1.6
316
+ - @prosopo/user-access-policy@3.5.5
317
+ - @prosopo/common@3.1.6
318
+ - @prosopo/locale@3.1.6
319
+ - @prosopo/types@3.0.10
320
+
321
+ ## 3.0.19
322
+ ### Patch Changes
323
+
324
+ - e64160c: The way mongo memory server works has changed
325
+ - Updated dependencies [553025d]
326
+ - @prosopo/user-access-policy@3.5.4
327
+ - @prosopo/types-database@3.0.19
328
+
329
+ ## 3.0.18
330
+ ### Patch Changes
331
+
332
+ - 6960643: lint detect missing and unneccessary imports
333
+ - Updated dependencies [d8e855c]
334
+ - Updated dependencies [6960643]
335
+ - @prosopo/types-database@3.0.18
336
+ - @prosopo/locale@3.1.5
337
+ - @prosopo/user-access-policy@3.5.3
338
+ - @prosopo/common@3.1.5
339
+ - @prosopo/types@3.0.9
340
+
341
+ ## 3.0.17
342
+ ### Patch Changes
343
+
344
+ - Updated dependencies [30e7d4d]
345
+ - @prosopo/config@3.1.5
346
+ - @prosopo/common@3.1.4
347
+ - @prosopo/types@3.0.8
348
+ - @prosopo/types-database@3.0.17
349
+ - @prosopo/user-access-policy@3.5.2
350
+
351
+ ## 3.0.16
352
+ ### Patch Changes
353
+
354
+ - 1f3a02f: Release 3.1.8
355
+ - Updated dependencies [1f3a02f]
356
+ - @prosopo/user-access-policy@3.5.1
357
+ - @prosopo/types-database@3.0.16
358
+
359
+ ## 3.0.15
360
+ ### Patch Changes
361
+
362
+ - Updated dependencies [e0628d9]
363
+ - @prosopo/user-access-policy@3.5.0
364
+ - @prosopo/types-database@3.0.15
365
+
366
+ ## 3.0.14
367
+ ### Patch Changes
368
+
369
+ - Updated dependencies [44ffda2]
370
+ - Updated dependencies [a49b538]
371
+ - Updated dependencies [e090e2f]
372
+ - @prosopo/config@3.1.4
373
+ - @prosopo/user-access-policy@3.4.1
374
+ - @prosopo/common@3.1.3
375
+ - @prosopo/types@3.0.7
376
+ - @prosopo/types-database@3.0.14
377
+
3
378
  ## 3.0.13
4
379
  ### Patch Changes
5
380
 
@@ -0,0 +1,3 @@
1
+ export * from "./mongo.js";
2
+ export * from "./mongoMemory.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/base/index.ts"],"names":[],"mappings":"AAaA,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/base/index.ts"],"names":[],"mappings":"AAaA,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { type Logger } from "@prosopo/common";
2
+ import type { IDatabase } from "@prosopo/types-database";
3
+ import mongoose, { type Connection } from "mongoose";
4
+ export declare class MongoDatabase implements IDatabase {
5
+ protected readonly _url: string;
6
+ safeURL: string;
7
+ dbname: string;
8
+ connection?: Connection;
9
+ logger: Logger;
10
+ connected: boolean;
11
+ private connecting?;
12
+ constructor(url: string, dbname?: string, authSource?: string, logger?: Logger);
13
+ get url(): string;
14
+ getConnection(): mongoose.Connection;
15
+ connect(): Promise<void>;
16
+ close(): Promise<void>;
17
+ }
18
+ //# sourceMappingURL=mongo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mongo.d.ts","sourceRoot":"","sources":["../../src/base/mongo.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,KAAK,MAAM,EAA6B,MAAM,iBAAiB,CAAC;AACzE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEzD,OAAO,QAAQ,EAAE,EAAE,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAarD,qBAAa,aAAc,YAAW,SAAS;IAC9C,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,UAAS;IAClB,OAAO,CAAC,UAAU,CAAC,CAAgB;gBAGlC,GAAG,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,MAAM,EACf,UAAU,CAAC,EAAE,MAAM,EACnB,MAAM,CAAC,EAAE,MAAM;IAgBhB,IAAI,GAAG,IAAI,MAAM,CAEhB;IAED,aAAa,IAAI,QAAQ,CAAC,UAAU;IAa9B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAsGxB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAO5B"}
@@ -35,20 +35,20 @@ class MongoDatabase {
35
35
  * @description Connect to the database and set the various tables
36
36
  */
37
37
  async connect() {
38
- this.logger.info(() => ({
38
+ this.logger.debug(() => ({
39
39
  data: { mongoUrl: this.safeURL },
40
40
  msg: "Connecting to database"
41
41
  }));
42
42
  try {
43
43
  if (this.connected) {
44
- this.logger.info(() => ({
44
+ this.logger.debug(() => ({
45
45
  data: { mongoUrl: this.safeURL },
46
46
  msg: "Database connection already open"
47
47
  }));
48
48
  return;
49
49
  }
50
50
  if (this.connecting) {
51
- this.logger.info(() => ({
51
+ this.logger.debug(() => ({
52
52
  data: { mongoUrl: this.safeURL },
53
53
  msg: "Database connection in progress, waiting for it to finish"
54
54
  }));
@@ -60,7 +60,7 @@ class MongoDatabase {
60
60
  serverApi: ServerApiVersion.v1
61
61
  });
62
62
  const onConnected = () => {
63
- this.logger.info(() => ({
63
+ this.logger.debug(() => ({
64
64
  data: { mongoUrl: this.safeURL },
65
65
  msg: "Database connection opened"
66
66
  }));
@@ -83,28 +83,28 @@ class MongoDatabase {
83
83
  connection.once("error", onError);
84
84
  connection.on("disconnected", () => {
85
85
  this.connected = false;
86
- this.logger.info(() => ({
86
+ this.logger.debug(() => ({
87
87
  data: { mongoUrl: this.safeURL },
88
88
  msg: "Database disconnected"
89
89
  }));
90
90
  });
91
91
  connection.on("reconnected", () => {
92
92
  this.connected = true;
93
- this.logger.info(() => ({
93
+ this.logger.debug(() => ({
94
94
  data: { mongoUrl: this.safeURL },
95
95
  msg: "Database reconnected"
96
96
  }));
97
97
  });
98
98
  connection.on("close", () => {
99
99
  this.connected = false;
100
- this.logger.info(() => ({
100
+ this.logger.debug(() => ({
101
101
  data: { mongoUrl: this.safeURL },
102
102
  msg: "Database connection closed"
103
103
  }));
104
104
  });
105
105
  connection.on("fullsetup", () => {
106
106
  this.connected = true;
107
- this.logger.info(() => ({
107
+ this.logger.debug(() => ({
108
108
  data: { mongoUrl: this.safeURL },
109
109
  msg: "Database connection is fully setup"
110
110
  }));
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mongo.js","sourceRoot":"","sources":["../../src/base/mongo.ts"],"names":[],"mappings":"AAaA,OAAO,EAAe,cAAc,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,QAA6B,MAAM,UAAU,CAAC;AAErD,QAAQ,CAAC,GAAG,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;AAGnC,MAAM,gBAAgB,GAAG,2BAA2B,CAAC;AAQrD,MAAM,OAAO,aAAa;IASzB,YACC,GAAW,EACX,MAAe,EACf,UAAmB,EACnB,MAAe;QAPhB,cAAS,GAAG,KAAK,CAAC;QASjB,MAAM,YAAY,GAAG,GAAG,IAAI,gBAAgB,CAAC;QAC7C,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,YAAY,CAAC,CAAC;QACxC,IAAI,MAAM,EAAE,CAAC;YACZ,SAAS,CAAC,QAAQ,GAAG,MAAM,CAAC;QAC7B,CAAC;QACD,IAAI,UAAU,EAAE,CAAC;YACh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AAE,GAAG,EAAE;oBAC/B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;oBACtB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;wBACxB,IAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,OAAO,EAAE;wBAChC,GAAG,EAAE,oCAAoC;qBACzC,CAAC,CAAC,CAAC;gBACL,CAAC,CAAC,CAAC;YACJ,CAAC,CAAC,CAAC;YAEH,OAAO,IAAI,CAAC,UAAU,CAAC;QACxB,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACZ,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;gBACxB,GAAG,EAAE,CAAC;gBACN,IAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,OAAO,EAAE;gBAChC,GAAG,EAAE,2BAA2B;aAChC,CAAC,CAAC,CAAC;YACJ,MAAM,CAAC,CAAC;QACT,CAAC;IACF,CAAC;IAGD,KAAK,CAAC,KAAK;QACV,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;YACxB,IAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,OAAO,EAAE;YAChC,GAAG,EAAE,oBAAoB;SACzB,CAAC,CAAC,CAAC;QACJ,MAAM,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,CAAC;IAChC,CAAC;CACD"}
@@ -0,0 +1,10 @@
1
+ import type { Logger } from "@prosopo/common";
2
+ import { MongoDatabase } from "./mongo.js";
3
+ export declare class MongoMemoryDatabase extends MongoDatabase {
4
+ protected _url: string;
5
+ private mongod;
6
+ constructor(_url: string, dbname: string, logger: Logger, authSource?: string);
7
+ connect(): Promise<void>;
8
+ close(): Promise<void>;
9
+ }
10
+ //# sourceMappingURL=mongoMemory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mongoMemory.d.ts","sourceRoot":"","sources":["../../src/base/mongoMemory.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAE9C,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,qBAAa,mBAAoB,SAAQ,aAAa;IACrD,UAAmB,IAAI,SAAM;IAC7B,OAAO,CAAC,MAAM,CAAgC;gBAG7C,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,UAAU,CAAC,EAAE,MAAM;IAKL,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAQxB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAKrC"}
@@ -1,26 +1,21 @@
1
1
  import { MongoMemoryServer } from "mongodb-memory-server";
2
2
  import { MongoDatabase } from "./mongo.js";
3
3
  class MongoMemoryDatabase extends MongoDatabase {
4
- constructor(url, dbname, logger, authSource) {
5
- const mongod = new MongoMemoryServer();
6
- const mongoMemoryURL = mongod.getUri();
7
- super(mongoMemoryURL, dbname, authSource, logger);
8
- this.running = false;
9
- this.mongod = mongod;
10
- this._url = mongoMemoryURL;
4
+ constructor(_url, dbname, logger, authSource) {
5
+ super("", dbname, authSource, logger);
6
+ this._url = "";
11
7
  }
12
- connect() {
13
- if (!this.running) {
14
- this.mongod?.start();
15
- this.running = true;
16
- } else {
8
+ async connect() {
9
+ if (!this.mongod) {
10
+ this.mongod = await MongoMemoryServer.create();
11
+ this._url = this.mongod.getUri();
17
12
  }
18
- return super.connect();
13
+ await super.connect();
19
14
  }
20
15
  async close() {
21
16
  await super.close();
22
17
  await this.mongod?.stop();
23
- this.running = false;
18
+ this.mongod = void 0;
24
19
  }
25
20
  }
26
21
  export {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mongoMemory.js","sourceRoot":"","sources":["../../src/base/mongoMemory.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,MAAM,OAAO,mBAAoB,SAAQ,aAAa;IAIrD,YACC,IAAY,EACZ,MAAc,EACd,MAAc,EACd,UAAmB;QAEnB,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC;QATpB,SAAI,GAAG,EAAE,CAAC;IAU7B,CAAC;IAEQ,KAAK,CAAC,OAAO;QACrB,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YAClB,IAAI,CAAC,MAAM,GAAG,MAAM,iBAAiB,CAAC,MAAM,EAAE,CAAC;YAC/C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QAClC,CAAC;QACD,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC;IACvB,CAAC;IAEQ,KAAK,CAAC,KAAK;QACnB,MAAM,KAAK,CAAC,KAAK,EAAE,CAAC;QACpB,MAAM,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC;QAC1B,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;IACzB,CAAC;CACD"}
@@ -3,6 +3,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const common = require("@prosopo/common");
4
4
  const mongodb = require("mongodb");
5
5
  const mongoose = require("mongoose");
6
+ var _documentCurrentScript = typeof document !== "undefined" ? document.currentScript : null;
6
7
  mongoose.set("strictQuery", false);
7
8
  const DEFAULT_ENDPOINT = "mongodb://127.0.0.1:27017";
8
9
  class MongoDatabase {
@@ -19,7 +20,7 @@ class MongoDatabase {
19
20
  this._url = parsedUrl.toString();
20
21
  this.safeURL = this.url.replace(/\w+:\w+/, "<Credentials>");
21
22
  this.dbname = dbname || parsedUrl.pathname.replace("/", "");
22
- this.logger = logger || common.getLogger("info", module);
23
+ this.logger = logger || common.getLogger("info", typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === "SCRIPT" && _documentCurrentScript.src || new URL("base/mongo.cjs", document.baseURI).href);
23
24
  }
24
25
  get url() {
25
26
  return this._url;
@@ -37,20 +38,20 @@ class MongoDatabase {
37
38
  * @description Connect to the database and set the various tables
38
39
  */
39
40
  async connect() {
40
- this.logger.info(() => ({
41
+ this.logger.debug(() => ({
41
42
  data: { mongoUrl: this.safeURL },
42
43
  msg: "Connecting to database"
43
44
  }));
44
45
  try {
45
46
  if (this.connected) {
46
- this.logger.info(() => ({
47
+ this.logger.debug(() => ({
47
48
  data: { mongoUrl: this.safeURL },
48
49
  msg: "Database connection already open"
49
50
  }));
50
51
  return;
51
52
  }
52
53
  if (this.connecting) {
53
- this.logger.info(() => ({
54
+ this.logger.debug(() => ({
54
55
  data: { mongoUrl: this.safeURL },
55
56
  msg: "Database connection in progress, waiting for it to finish"
56
57
  }));
@@ -62,7 +63,7 @@ class MongoDatabase {
62
63
  serverApi: mongodb.ServerApiVersion.v1
63
64
  });
64
65
  const onConnected = () => {
65
- this.logger.info(() => ({
66
+ this.logger.debug(() => ({
66
67
  data: { mongoUrl: this.safeURL },
67
68
  msg: "Database connection opened"
68
69
  }));
@@ -85,28 +86,28 @@ class MongoDatabase {
85
86
  connection.once("error", onError);
86
87
  connection.on("disconnected", () => {
87
88
  this.connected = false;
88
- this.logger.info(() => ({
89
+ this.logger.debug(() => ({
89
90
  data: { mongoUrl: this.safeURL },
90
91
  msg: "Database disconnected"
91
92
  }));
92
93
  });
93
94
  connection.on("reconnected", () => {
94
95
  this.connected = true;
95
- this.logger.info(() => ({
96
+ this.logger.debug(() => ({
96
97
  data: { mongoUrl: this.safeURL },
97
98
  msg: "Database reconnected"
98
99
  }));
99
100
  });
100
101
  connection.on("close", () => {
101
102
  this.connected = false;
102
- this.logger.info(() => ({
103
+ this.logger.debug(() => ({
103
104
  data: { mongoUrl: this.safeURL },
104
105
  msg: "Database connection closed"
105
106
  }));
106
107
  });
107
108
  connection.on("fullsetup", () => {
108
109
  this.connected = true;
109
- this.logger.info(() => ({
110
+ this.logger.debug(() => ({
110
111
  data: { mongoUrl: this.safeURL },
111
112
  msg: "Database connection is fully setup"
112
113
  }));
@@ -3,26 +3,21 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const mongodbMemoryServer = require("mongodb-memory-server");
4
4
  const mongo = require("./mongo.cjs");
5
5
  class MongoMemoryDatabase extends mongo.MongoDatabase {
6
- constructor(url, dbname, logger, authSource) {
7
- const mongod = new mongodbMemoryServer.MongoMemoryServer();
8
- const mongoMemoryURL = mongod.getUri();
9
- super(mongoMemoryURL, dbname, authSource, logger);
10
- this.running = false;
11
- this.mongod = mongod;
12
- this._url = mongoMemoryURL;
6
+ constructor(_url, dbname, logger, authSource) {
7
+ super("", dbname, authSource, logger);
8
+ this._url = "";
13
9
  }
14
- connect() {
15
- if (!this.running) {
16
- this.mongod?.start();
17
- this.running = true;
18
- } else {
10
+ async connect() {
11
+ if (!this.mongod) {
12
+ this.mongod = await mongodbMemoryServer.MongoMemoryServer.create();
13
+ this._url = this.mongod.getUri();
19
14
  }
20
- return super.connect();
15
+ await super.connect();
21
16
  }
22
17
  async close() {
23
18
  await super.close();
24
19
  await this.mongod?.stop();
25
- this.running = false;
20
+ this.mongod = void 0;
26
21
  }
27
22
  }
28
23
  exports.MongoMemoryDatabase = MongoMemoryDatabase;