@aneuhold/be-ts-db-lib 4.2.28 → 4.2.30
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 +20 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/index.ts +1 -1
- package/lib/repositories/BaseRepository.d.ts +2 -12
- package/lib/repositories/BaseRepository.d.ts.map +1 -1
- package/lib/repositories/BaseRepository.js +8 -8
- package/lib/repositories/BaseRepository.js.map +1 -1
- package/lib/repositories/BaseRepository.ts +9 -9
- package/lib/repositories/common/UserRepository.d.ts +1 -2
- package/lib/repositories/common/UserRepository.d.ts.map +1 -1
- package/lib/repositories/common/UserRepository.js +6 -6
- package/lib/repositories/common/UserRepository.js.map +1 -1
- package/lib/repositories/common/UserRepository.ts +6 -6
- package/lib/repositories/dashboard/DashboardBaseRepository.d.ts +1 -1
- package/lib/repositories/dashboard/DashboardBaseRepository.d.ts.map +1 -1
- package/lib/repositories/dashboard/DashboardBaseRepository.js +2 -2
- package/lib/repositories/dashboard/DashboardBaseRepository.js.map +1 -1
- package/lib/repositories/dashboard/DashboardBaseRepository.ts +2 -2
- package/lib/repositories/dashboard/DashboardNonogramKatanaItemRepository.d.ts +2 -2
- package/lib/repositories/dashboard/DashboardNonogramKatanaItemRepository.d.ts.map +1 -1
- package/lib/repositories/dashboard/DashboardNonogramKatanaItemRepository.js +4 -4
- package/lib/repositories/dashboard/DashboardNonogramKatanaItemRepository.js.map +1 -1
- package/lib/repositories/dashboard/DashboardNonogramKatanaItemRepository.ts +5 -5
- package/lib/repositories/dashboard/DashboardNonogramKatanaUpgradeRepository.d.ts +2 -2
- package/lib/repositories/dashboard/DashboardNonogramKatanaUpgradeRepository.d.ts.map +1 -1
- package/lib/repositories/dashboard/DashboardNonogramKatanaUpgradeRepository.js +4 -4
- package/lib/repositories/dashboard/DashboardNonogramKatanaUpgradeRepository.js.map +1 -1
- package/lib/repositories/dashboard/DashboardNonogramKatanaUpgradeRepository.ts +5 -5
- package/lib/repositories/dashboard/DashboardTaskRepository.d.ts +2 -10
- package/lib/repositories/dashboard/DashboardTaskRepository.d.ts.map +1 -1
- package/lib/repositories/dashboard/DashboardTaskRepository.js +7 -7
- package/lib/repositories/dashboard/DashboardTaskRepository.js.map +1 -1
- package/lib/repositories/dashboard/DashboardTaskRepository.ts +8 -8
- package/lib/repositories/dashboard/DashboardUserConfigRepository.d.ts +2 -15
- package/lib/repositories/dashboard/DashboardUserConfigRepository.d.ts.map +1 -1
- package/lib/repositories/dashboard/DashboardUserConfigRepository.js +9 -9
- package/lib/repositories/dashboard/DashboardUserConfigRepository.js.map +1 -1
- package/lib/repositories/dashboard/DashboardUserConfigRepository.ts +10 -10
- package/lib/repositories/workout/WorkoutBaseRepository.d.ts +1 -1
- package/lib/repositories/workout/WorkoutBaseRepository.d.ts.map +1 -1
- package/lib/repositories/workout/WorkoutBaseRepository.js +2 -2
- package/lib/repositories/workout/WorkoutBaseRepository.js.map +1 -1
- package/lib/repositories/workout/WorkoutBaseRepository.ts +2 -2
- package/lib/repositories/workout/WorkoutEquipmentTypeRepository.d.ts +2 -2
- package/lib/repositories/workout/WorkoutEquipmentTypeRepository.d.ts.map +1 -1
- package/lib/repositories/workout/WorkoutEquipmentTypeRepository.js +4 -4
- package/lib/repositories/workout/WorkoutEquipmentTypeRepository.js.map +1 -1
- package/lib/repositories/workout/WorkoutEquipmentTypeRepository.ts +5 -5
- package/lib/repositories/workout/WorkoutExerciseCalibrationRepository.d.ts +2 -2
- package/lib/repositories/workout/WorkoutExerciseCalibrationRepository.d.ts.map +1 -1
- package/lib/repositories/workout/WorkoutExerciseCalibrationRepository.js +4 -4
- package/lib/repositories/workout/WorkoutExerciseCalibrationRepository.js.map +1 -1
- package/lib/repositories/workout/WorkoutExerciseCalibrationRepository.ts +5 -5
- package/lib/repositories/workout/WorkoutExerciseRepository.d.ts +2 -2
- package/lib/repositories/workout/WorkoutExerciseRepository.d.ts.map +1 -1
- package/lib/repositories/workout/WorkoutExerciseRepository.js +4 -4
- package/lib/repositories/workout/WorkoutExerciseRepository.js.map +1 -1
- package/lib/repositories/workout/WorkoutExerciseRepository.ts +5 -5
- package/lib/repositories/workout/WorkoutMesocycleRepository.d.ts +2 -2
- package/lib/repositories/workout/WorkoutMesocycleRepository.d.ts.map +1 -1
- package/lib/repositories/workout/WorkoutMesocycleRepository.js +4 -4
- package/lib/repositories/workout/WorkoutMesocycleRepository.js.map +1 -1
- package/lib/repositories/workout/WorkoutMesocycleRepository.ts +5 -5
- package/lib/repositories/workout/WorkoutMicrocycleRepository.d.ts +2 -2
- package/lib/repositories/workout/WorkoutMicrocycleRepository.d.ts.map +1 -1
- package/lib/repositories/workout/WorkoutMicrocycleRepository.js +4 -4
- package/lib/repositories/workout/WorkoutMicrocycleRepository.js.map +1 -1
- package/lib/repositories/workout/WorkoutMicrocycleRepository.ts +5 -5
- package/lib/repositories/workout/WorkoutMuscleGroupRepository.d.ts +2 -2
- package/lib/repositories/workout/WorkoutMuscleGroupRepository.d.ts.map +1 -1
- package/lib/repositories/workout/WorkoutMuscleGroupRepository.js +8 -11
- package/lib/repositories/workout/WorkoutMuscleGroupRepository.js.map +1 -1
- package/lib/repositories/workout/WorkoutMuscleGroupRepository.ts +9 -12
- package/lib/repositories/workout/WorkoutSessionExerciseRepository.d.ts +2 -2
- package/lib/repositories/workout/WorkoutSessionExerciseRepository.d.ts.map +1 -1
- package/lib/repositories/workout/WorkoutSessionExerciseRepository.js +4 -4
- package/lib/repositories/workout/WorkoutSessionExerciseRepository.js.map +1 -1
- package/lib/repositories/workout/WorkoutSessionExerciseRepository.ts +5 -5
- package/lib/repositories/workout/WorkoutSessionRepository.d.ts +2 -2
- package/lib/repositories/workout/WorkoutSessionRepository.d.ts.map +1 -1
- package/lib/repositories/workout/WorkoutSessionRepository.js +4 -4
- package/lib/repositories/workout/WorkoutSessionRepository.js.map +1 -1
- package/lib/repositories/workout/WorkoutSessionRepository.ts +5 -5
- package/lib/repositories/workout/WorkoutSetRepository.d.ts +2 -2
- package/lib/repositories/workout/WorkoutSetRepository.d.ts.map +1 -1
- package/lib/repositories/workout/WorkoutSetRepository.js +4 -4
- package/lib/repositories/workout/WorkoutSetRepository.js.map +1 -1
- package/lib/repositories/workout/WorkoutSetRepository.ts +5 -5
- package/lib/services/DemoAccountsService/DashboardDemoAccounts.service.d.ts +21 -0
- package/lib/services/DemoAccountsService/DashboardDemoAccounts.service.d.ts.map +1 -0
- package/lib/services/DemoAccountsService/{DashboardDemoAccountsService.js → DashboardDemoAccounts.service.js} +28 -28
- package/lib/services/DemoAccountsService/DashboardDemoAccounts.service.js.map +1 -0
- package/lib/services/DemoAccountsService/{DashboardDemoAccountsService.ts → DashboardDemoAccounts.service.ts} +27 -27
- package/lib/services/DemoAccountsService/{DemoAccountsService.d.ts → DemoAccounts.service.d.ts} +1 -1
- package/lib/services/DemoAccountsService/DemoAccounts.service.d.ts.map +1 -0
- package/lib/services/DemoAccountsService/{DemoAccountsService.js → DemoAccounts.service.js} +2 -2
- package/lib/services/DemoAccountsService/DemoAccounts.service.js.map +1 -0
- package/lib/services/DemoAccountsService/{DemoAccountsService.ts → DemoAccounts.service.ts} +1 -1
- package/lib/services/DemoAccountsService/index.d.ts +1 -1
- package/lib/services/DemoAccountsService/index.d.ts.map +1 -1
- package/lib/services/DemoAccountsService/index.js +1 -1
- package/lib/services/DemoAccountsService/index.js.map +1 -1
- package/lib/services/DemoAccountsService/index.ts +1 -1
- package/lib/services/{GoogleAuthService.d.ts → GoogleAuth.service.d.ts} +2 -8
- package/lib/services/GoogleAuth.service.d.ts.map +1 -0
- package/lib/services/{GoogleAuthService.js → GoogleAuth.service.js} +6 -6
- package/lib/services/GoogleAuth.service.js.map +1 -0
- package/lib/services/{GoogleAuthService.ts → GoogleAuth.service.ts} +5 -5
- package/lib/services/{MigrationService.d.ts → Migration.service.d.ts} +1 -1
- package/lib/services/Migration.service.d.ts.map +1 -0
- package/lib/services/{MigrationService.js → Migration.service.js} +1 -1
- package/lib/services/Migration.service.js.map +1 -0
- package/lib/services/{RepoSubscriptionService.d.ts → RepoSubscription.service.d.ts} +1 -1
- package/lib/services/RepoSubscription.service.d.ts.map +1 -0
- package/lib/services/{RepoSubscriptionService.js → RepoSubscription.service.js} +1 -1
- package/lib/services/RepoSubscription.service.js.map +1 -0
- package/lib/util/DbOperationMetaData.d.ts +1 -4
- package/lib/util/DbOperationMetaData.d.ts.map +1 -1
- package/lib/util/DbOperationMetaData.js +12 -12
- package/lib/util/DbOperationMetaData.js.map +1 -1
- package/lib/util/DbOperationMetaData.ts +12 -12
- package/lib/util/DocumentDb.d.ts +1 -9
- package/lib/util/DocumentDb.d.ts.map +1 -1
- package/lib/util/DocumentDb.js +14 -14
- package/lib/util/DocumentDb.js.map +1 -1
- package/lib/util/DocumentDb.ts +14 -14
- package/lib/validators/common/UserValidator.d.ts +1 -8
- package/lib/validators/common/UserValidator.d.ts.map +1 -1
- package/lib/validators/common/UserValidator.js +3 -3
- package/lib/validators/common/UserValidator.js.map +1 -1
- package/lib/validators/common/UserValidator.ts +3 -3
- package/package.json +9 -7
- package/lib/services/DemoAccountsService/DashboardDemoAccountsService.d.ts +0 -72
- package/lib/services/DemoAccountsService/DashboardDemoAccountsService.d.ts.map +0 -1
- package/lib/services/DemoAccountsService/DashboardDemoAccountsService.js.map +0 -1
- package/lib/services/DemoAccountsService/DemoAccountsService.d.ts.map +0 -1
- package/lib/services/DemoAccountsService/DemoAccountsService.js.map +0 -1
- package/lib/services/GoogleAuthService.d.ts.map +0 -1
- package/lib/services/GoogleAuthService.js.map +0 -1
- package/lib/services/MigrationService.d.ts.map +0 -1
- package/lib/services/MigrationService.js.map +0 -1
- package/lib/services/RepoSubscriptionService.d.ts.map +0 -1
- package/lib/services/RepoSubscriptionService.js.map +0 -1
- /package/lib/services/{MigrationService.ts → Migration.service.ts} +0 -0
- /package/lib/services/{RepoSubscriptionService.ts → RepoSubscription.service.ts} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default as DemoAccountsService } from './
|
|
1
|
+
export { default as DemoAccountsService } from './DemoAccounts.service.js';
|
|
@@ -5,7 +5,7 @@ import type { User } from '@aneuhold/core-ts-db-lib';
|
|
|
5
5
|
* Google ID.
|
|
6
6
|
*/
|
|
7
7
|
export default class GoogleAuthService {
|
|
8
|
-
private
|
|
8
|
+
#private;
|
|
9
9
|
/**
|
|
10
10
|
* Verifies a Google ID token and finds the associated user. Returns
|
|
11
11
|
* `null` if no matching user exists (does **not** create one).
|
|
@@ -23,11 +23,5 @@ export default class GoogleAuthService {
|
|
|
23
23
|
static verifyAndFindOrCreateUser(googleCredentialToken: string): Promise<{
|
|
24
24
|
user: User;
|
|
25
25
|
}>;
|
|
26
|
-
/**
|
|
27
|
-
* Verifies a Google ID token and returns the Google ID and email.
|
|
28
|
-
*
|
|
29
|
-
* @param googleCredentialToken - The Google ID token string from the client.
|
|
30
|
-
*/
|
|
31
|
-
private static verifyToken;
|
|
32
26
|
}
|
|
33
|
-
//# sourceMappingURL=
|
|
27
|
+
//# sourceMappingURL=GoogleAuth.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GoogleAuth.service.d.ts","sourceRoot":"","sources":["../../src/services/GoogleAuth.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAKrD;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,iBAAiB;;IAGpC;;;;;OAKG;WACU,iBAAiB,CAAC,qBAAqB,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,IAAI,CAAA;KAAE,GAAG,IAAI,CAAC;IAyB7F;;;;OAIG;WACU,yBAAyB,CAAC,qBAAqB,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,IAAI,CAAA;KAAE,CAAC;CAgD/F"}
|
|
@@ -7,7 +7,7 @@ import UserRepository from '../repositories/common/UserRepository.js';
|
|
|
7
7
|
* Google ID.
|
|
8
8
|
*/
|
|
9
9
|
export default class GoogleAuthService {
|
|
10
|
-
static client = new OAuth2Client(GOOGLE_CLIENT_ID);
|
|
10
|
+
static #client = new OAuth2Client(GOOGLE_CLIENT_ID);
|
|
11
11
|
/**
|
|
12
12
|
* Verifies a Google ID token and finds the associated user. Returns
|
|
13
13
|
* `null` if no matching user exists (does **not** create one).
|
|
@@ -15,7 +15,7 @@ export default class GoogleAuthService {
|
|
|
15
15
|
* @param googleCredentialToken - The Google ID token string from the client.
|
|
16
16
|
*/
|
|
17
17
|
static async verifyAndFindUser(googleCredentialToken) {
|
|
18
|
-
const { googleId, email } = await this
|
|
18
|
+
const { googleId, email } = await this.#verifyToken(googleCredentialToken);
|
|
19
19
|
const userRepo = UserRepository.getRepo();
|
|
20
20
|
// 1. Look up by googleId
|
|
21
21
|
let user = await userRepo.get({ auth: { googleId } });
|
|
@@ -44,7 +44,7 @@ export default class GoogleAuthService {
|
|
|
44
44
|
return result;
|
|
45
45
|
}
|
|
46
46
|
// Create new user.
|
|
47
|
-
const { googleId, email } = await this
|
|
47
|
+
const { googleId, email } = await this.#verifyToken(googleCredentialToken);
|
|
48
48
|
const userRepo = UserRepository.getRepo();
|
|
49
49
|
const newUser = UserSchema.parse({
|
|
50
50
|
userName: email,
|
|
@@ -63,8 +63,8 @@ export default class GoogleAuthService {
|
|
|
63
63
|
*
|
|
64
64
|
* @param googleCredentialToken - The Google ID token string from the client.
|
|
65
65
|
*/
|
|
66
|
-
static async verifyToken(googleCredentialToken) {
|
|
67
|
-
const ticket = await this
|
|
66
|
+
static async #verifyToken(googleCredentialToken) {
|
|
67
|
+
const ticket = await this.#client.verifyIdToken({
|
|
68
68
|
idToken: googleCredentialToken,
|
|
69
69
|
audience: GOOGLE_CLIENT_ID
|
|
70
70
|
});
|
|
@@ -79,4 +79,4 @@ export default class GoogleAuthService {
|
|
|
79
79
|
return { googleId, email };
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
-
//# sourceMappingURL=
|
|
82
|
+
//# sourceMappingURL=GoogleAuth.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GoogleAuth.service.js","sourceRoot":"","sources":["../../src/services/GoogleAuth.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACrF,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,cAAc,MAAM,0CAA0C,CAAC;AAEtE;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,iBAAiB;IACpC,MAAM,CAAU,OAAO,GAAG,IAAI,YAAY,CAAC,gBAAgB,CAAC,CAAC;IAE7D;;;;;OAKG;IACH,MAAM,CAAC,KAAK,CAAC,iBAAiB,CAAC,qBAA6B;QAC1D,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,qBAAqB,CAAC,CAAC;QAE3E,MAAM,QAAQ,GAAG,cAAc,CAAC,OAAO,EAAE,CAAC;QAE1C,yBAAyB;QACzB,IAAI,IAAI,GAAG,MAAM,QAAQ,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC;QAEtD,iDAAiD;QACjD,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,IAAI,GAAG,MAAM,QAAQ,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;YACrC,IAAI,IAAI,EAAE,CAAC;gBACT,qCAAqC;gBACrC,MAAM,QAAQ,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,GAAG,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC;gBAC3E,IAAI,CAAC,IAAI,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C3B,CAAC,CAAC;QACH,MAAM,OAAO,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC;QACpC,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;QAClD,CAAC;QAED,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;QACzC,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;QACjD,CAAC;QAED,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;IAC7B,CAAC"}
|
|
@@ -9,7 +9,7 @@ import UserRepository from '../repositories/common/UserRepository.js';
|
|
|
9
9
|
* Google ID.
|
|
10
10
|
*/
|
|
11
11
|
export default class GoogleAuthService {
|
|
12
|
-
|
|
12
|
+
static readonly #client = new OAuth2Client(GOOGLE_CLIENT_ID);
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Verifies a Google ID token and finds the associated user. Returns
|
|
@@ -18,7 +18,7 @@ export default class GoogleAuthService {
|
|
|
18
18
|
* @param googleCredentialToken - The Google ID token string from the client.
|
|
19
19
|
*/
|
|
20
20
|
static async verifyAndFindUser(googleCredentialToken: string): Promise<{ user: User } | null> {
|
|
21
|
-
const { googleId, email } = await this
|
|
21
|
+
const { googleId, email } = await this.#verifyToken(googleCredentialToken);
|
|
22
22
|
|
|
23
23
|
const userRepo = UserRepository.getRepo();
|
|
24
24
|
|
|
@@ -54,7 +54,7 @@ export default class GoogleAuthService {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
// Create new user.
|
|
57
|
-
const { googleId, email } = await this
|
|
57
|
+
const { googleId, email } = await this.#verifyToken(googleCredentialToken);
|
|
58
58
|
const userRepo = UserRepository.getRepo();
|
|
59
59
|
|
|
60
60
|
const newUser = UserSchema.parse({
|
|
@@ -76,10 +76,10 @@ export default class GoogleAuthService {
|
|
|
76
76
|
*
|
|
77
77
|
* @param googleCredentialToken - The Google ID token string from the client.
|
|
78
78
|
*/
|
|
79
|
-
|
|
79
|
+
static async #verifyToken(
|
|
80
80
|
googleCredentialToken: string
|
|
81
81
|
): Promise<{ googleId: string; email: string }> {
|
|
82
|
-
const ticket = await this
|
|
82
|
+
const ticket = await this.#client.verifyIdToken({
|
|
83
83
|
idToken: googleCredentialToken,
|
|
84
84
|
audience: GOOGLE_CLIENT_ID
|
|
85
85
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Migration.service.d.ts","sourceRoot":"","sources":["../../src/services/Migration.service.ts"],"names":[],"mappings":"AAoBA;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,OAAO,gBAAgB;IACnC;;;;;;;;OAQG;WACU,SAAS,CAAC,MAAM,UAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAQrD;;;OAGG;mBACkB,kBAAkB;CAwExC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Migration.service.js","sourceRoot":"","sources":["../../src/services/Migration.service.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,cAAc;AACd,OAAO,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAC3C,OAAO,cAAc,MAAM,0CAA0C,CAAC;AACtE,OAAO,6BAA6B,MAAM,4DAA4D,CAAC;AAEvG;;;GAGG;AACH,MAAM,yBAAyB,GAAG;IAChC,WAAW,EAAE,KAAK;IAClB,cAAc,EAAE,KAAK;IACrB,iBAAiB,EAAE,KAAK;IACxB,aAAa,EAAE,KAAK;IACpB,mBAAmB,EAAE,KAAK;IAC1B,kBAAkB,EAAE,KAAK;IACzB,SAAS,EAAE,KAAK;CACjB,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,OAAO,gBAAgB;IACnC;;;;;;;;OAQG;IACH,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,GAAG,KAAK;QACnC,EAAE,CAAC,MAAM,CA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service.ts"],"names":[],"mappings":"AA8CA;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,uBAAuB;IAC1C;;;OAGG;IACH,MAAM,CAAC,qBAAqB;QAC1B,OAAO;YACL,SAAS,EAAE,EAAE;YACb,UAAU,EAAE,EAAE;YACd,SAAS,EAAE,EAAE;YACb,UAAU,EAAE,EAAE;YACd,SAAS,EAAE,EAAE;YACb,UAAU,EAAE,EAAE;SACf,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -7,10 +7,7 @@ import type { UUID } from 'crypto';
|
|
|
7
7
|
* use that term for different concepts.
|
|
8
8
|
*/
|
|
9
9
|
export default class DbOperationMetaData {
|
|
10
|
-
private
|
|
11
|
-
private readonly affectedUserIds;
|
|
12
|
-
private readonly docCache;
|
|
13
|
-
private readonly pendingDocsToCreate;
|
|
10
|
+
#private;
|
|
14
11
|
/**
|
|
15
12
|
* Records that a doc type was touched by an operation during this request.
|
|
16
13
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DbOperationMetaData.d.ts","sourceRoot":"","sources":["../../src/util/DbOperationMetaData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAEnC;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,mBAAmB
|
|
1
|
+
{"version":3,"file":"DbOperationMetaData.d.ts","sourceRoot":"","sources":["../../src/util/DbOperationMetaData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAEnC;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,mBAAmB;;IAMtC;;;;OAIG;IACH,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAI3C;;;;OAIG;IACH,kBAAkB,CAAC,OAAO,EAAE,IAAI,EAAE,GAAG,IAAI;IAIzC;;OAEG;IACH,kBAAkB,IAAI,GAAG,CAAC,MAAM,CAAC;IAIjC;;OAEG;IACH,kBAAkB,IAAI,GAAG,CAAC,IAAI,CAAC;IAI/B;;;;;OAKG;IACH,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,GAAG,IAAI;IAItC;;;;;OAKG;IACH,YAAY,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,GAAG,CAAC,GAAG,SAAS;IAK3C;;;;OAIG;IACH,kBAAkB,CAAC,CAAC,SAAS,YAAY,EAAE,GAAG,EAAE,CAAC,GAAG,IAAI;IAIxD;;;;OAIG;IACH,mBAAmB,CAAC,CAAC,SAAS,YAAY,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,IAAI;IAM5D;;;;;OAKG;IACH,aAAa,CAAC,KAAK,EAAE,IAAI,GAAG,OAAO;CAGpC"}
|
|
@@ -5,17 +5,17 @@
|
|
|
5
5
|
* use that term for different concepts.
|
|
6
6
|
*/
|
|
7
7
|
export default class DbOperationMetaData {
|
|
8
|
-
docTypesTouched = new Set();
|
|
9
|
-
affectedUserIds = new Set();
|
|
10
|
-
docCache = new Map();
|
|
11
|
-
pendingDocsToCreate = new Map();
|
|
8
|
+
#docTypesTouched = new Set();
|
|
9
|
+
#affectedUserIds = new Set();
|
|
10
|
+
#docCache = new Map();
|
|
11
|
+
#pendingDocsToCreate = new Map();
|
|
12
12
|
/**
|
|
13
13
|
* Records that a doc type was touched by an operation during this request.
|
|
14
14
|
*
|
|
15
15
|
* @param docType - The doc type that was touched.
|
|
16
16
|
*/
|
|
17
17
|
recordDocTypeTouched(docType) {
|
|
18
|
-
this
|
|
18
|
+
this.#docTypesTouched.add(docType);
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
21
|
* Records multiple user IDs as affected by an operation during this request.
|
|
@@ -23,19 +23,19 @@ export default class DbOperationMetaData {
|
|
|
23
23
|
* @param userIds - The user IDs to record as affected.
|
|
24
24
|
*/
|
|
25
25
|
addAffectedUserIds(userIds) {
|
|
26
|
-
userIds.forEach((userId) => this
|
|
26
|
+
userIds.forEach((userId) => this.#affectedUserIds.add(userId));
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
29
|
* Gets all doc types that were touched during this request.
|
|
30
30
|
*/
|
|
31
31
|
getDocTypesTouched() {
|
|
32
|
-
return this
|
|
32
|
+
return this.#docTypesTouched;
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
35
|
* Gets all user IDs recorded as affected during this request.
|
|
36
36
|
*/
|
|
37
37
|
getAffectedUserIds() {
|
|
38
|
-
return this
|
|
38
|
+
return this.#affectedUserIds;
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
41
|
* Caches a document by its ID to prevent duplicate queries during this request.
|
|
@@ -44,7 +44,7 @@ export default class DbOperationMetaData {
|
|
|
44
44
|
* @param doc - The document to cache.
|
|
45
45
|
*/
|
|
46
46
|
cacheDoc(docId, doc) {
|
|
47
|
-
this
|
|
47
|
+
this.#docCache.set(docId, doc);
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
50
|
* Retrieves a cached document by its ID.
|
|
@@ -54,7 +54,7 @@ export default class DbOperationMetaData {
|
|
|
54
54
|
*/
|
|
55
55
|
getCachedDoc(docId) {
|
|
56
56
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
57
|
-
return this
|
|
57
|
+
return this.#docCache.get(docId);
|
|
58
58
|
}
|
|
59
59
|
/**
|
|
60
60
|
* Registers a document that will be created during this request.
|
|
@@ -62,7 +62,7 @@ export default class DbOperationMetaData {
|
|
|
62
62
|
* @param doc - The document to register.
|
|
63
63
|
*/
|
|
64
64
|
registerPendingDoc(doc) {
|
|
65
|
-
this
|
|
65
|
+
this.#pendingDocsToCreate.set(doc._id, doc);
|
|
66
66
|
}
|
|
67
67
|
/**
|
|
68
68
|
* Registers multiple documents that will be created during this request.
|
|
@@ -81,7 +81,7 @@ export default class DbOperationMetaData {
|
|
|
81
81
|
* @returns True if the document is pending creation, false otherwise.
|
|
82
82
|
*/
|
|
83
83
|
hasPendingDoc(docId) {
|
|
84
|
-
return this
|
|
84
|
+
return this.#pendingDocsToCreate.has(docId);
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
//# sourceMappingURL=DbOperationMetaData.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DbOperationMetaData.js","sourceRoot":"","sources":["../../src/util/DbOperationMetaData.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,mBAAmB;
|
|
1
|
+
{"version":3,"file":"DbOperationMetaData.js","sourceRoot":"","sources":["../../src/util/DbOperationMetaData.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,mBAAmB;IAC7B,gBAAgB,GAAG,IAAI,GAAG,EAAU,CAAC;IACrC,gBAAgB,GAAG,IAAI,GAAG,EAAQ,CAAC;IACnC,SAAS,GAAG,IAAI,GAAG,EAAiB,CAAC;IACrC,oBAAoB,GAAG,IAAI,GAAG,EAAsB,CAAC;IAE9D;;;;OAIG;IACH,oBAAoB,CAAC,OAAe;QAClC,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC;IAED;;;;OAIG;IACH,kBAAkB,CAAC,OAAe;QAChC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;IACjE,CAAC;IAED;;OAEG;IACH,kBAAkB;QAChB,OAAO,IAAI,CAAC,gBAAgB,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,kBAAkB;QAChB,OAAO,IAAI,CAAC,gBAAgB,CAAC;IAC/B,CAAC;IAED;;;;;OAKG;IACH,QAAQ,CAAI,KAAW,EAAE,GAAM;QAC7B,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACjC,CAAC;IAED;;;;;OAKG;IACH,YAAY,CAAI,KAAW;QACzB,yEAAyE;QACzE,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAkB,CAAC;IACpD,CAAC;IAED;;;;OAIG;IACH,kBAAkB,CAAyB,GAAM;QAC/C,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAC9C,CAAC;IAED;;;;OAIG;IACH,mBAAmB,CAAyB,IAAS;QACnD,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YACnB,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC;QAC/B,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACH,aAAa,CAAC,KAAW;QACvB,OAAO,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC9C,CAAC;CACF"}
|
|
@@ -8,10 +8,10 @@ import type { UUID } from 'crypto';
|
|
|
8
8
|
* use that term for different concepts.
|
|
9
9
|
*/
|
|
10
10
|
export default class DbOperationMetaData {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
readonly #docTypesTouched = new Set<string>();
|
|
12
|
+
readonly #affectedUserIds = new Set<UUID>();
|
|
13
|
+
readonly #docCache = new Map<UUID, unknown>();
|
|
14
|
+
readonly #pendingDocsToCreate = new Map<UUID, BaseDocument>();
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Records that a doc type was touched by an operation during this request.
|
|
@@ -19,7 +19,7 @@ export default class DbOperationMetaData {
|
|
|
19
19
|
* @param docType - The doc type that was touched.
|
|
20
20
|
*/
|
|
21
21
|
recordDocTypeTouched(docType: string): void {
|
|
22
|
-
this
|
|
22
|
+
this.#docTypesTouched.add(docType);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
/**
|
|
@@ -28,21 +28,21 @@ export default class DbOperationMetaData {
|
|
|
28
28
|
* @param userIds - The user IDs to record as affected.
|
|
29
29
|
*/
|
|
30
30
|
addAffectedUserIds(userIds: UUID[]): void {
|
|
31
|
-
userIds.forEach((userId) => this
|
|
31
|
+
userIds.forEach((userId) => this.#affectedUserIds.add(userId));
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
35
|
* Gets all doc types that were touched during this request.
|
|
36
36
|
*/
|
|
37
37
|
getDocTypesTouched(): Set<string> {
|
|
38
|
-
return this
|
|
38
|
+
return this.#docTypesTouched;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
42
|
* Gets all user IDs recorded as affected during this request.
|
|
43
43
|
*/
|
|
44
44
|
getAffectedUserIds(): Set<UUID> {
|
|
45
|
-
return this
|
|
45
|
+
return this.#affectedUserIds;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
/**
|
|
@@ -52,7 +52,7 @@ export default class DbOperationMetaData {
|
|
|
52
52
|
* @param doc - The document to cache.
|
|
53
53
|
*/
|
|
54
54
|
cacheDoc<T>(docId: UUID, doc: T): void {
|
|
55
|
-
this
|
|
55
|
+
this.#docCache.set(docId, doc);
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
/**
|
|
@@ -63,7 +63,7 @@ export default class DbOperationMetaData {
|
|
|
63
63
|
*/
|
|
64
64
|
getCachedDoc<T>(docId: UUID): T | undefined {
|
|
65
65
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
66
|
-
return this
|
|
66
|
+
return this.#docCache.get(docId) as T | undefined;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
/**
|
|
@@ -72,7 +72,7 @@ export default class DbOperationMetaData {
|
|
|
72
72
|
* @param doc - The document to register.
|
|
73
73
|
*/
|
|
74
74
|
registerPendingDoc<T extends BaseDocument>(doc: T): void {
|
|
75
|
-
this
|
|
75
|
+
this.#pendingDocsToCreate.set(doc._id, doc);
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
/**
|
|
@@ -93,6 +93,6 @@ export default class DbOperationMetaData {
|
|
|
93
93
|
* @returns True if the document is pending creation, false otherwise.
|
|
94
94
|
*/
|
|
95
95
|
hasPendingDoc(docId: UUID): boolean {
|
|
96
|
-
return this
|
|
96
|
+
return this.#pendingDocsToCreate.has(docId);
|
|
97
97
|
}
|
|
98
98
|
}
|
package/lib/util/DocumentDb.d.ts
CHANGED
|
@@ -4,15 +4,7 @@ import { Collection } from 'mongodb';
|
|
|
4
4
|
* A utility class for interacting with a MongoDB database.
|
|
5
5
|
*/
|
|
6
6
|
export default class DocumentDb {
|
|
7
|
-
private
|
|
8
|
-
private static mongoClient;
|
|
9
|
-
private static db;
|
|
10
|
-
/**
|
|
11
|
-
* Gets or creates the MongoDB client instance.
|
|
12
|
-
*
|
|
13
|
-
* @returns A promise that resolves to the MongoDB client.
|
|
14
|
-
*/
|
|
15
|
-
private static getClient;
|
|
7
|
+
#private;
|
|
16
8
|
/**
|
|
17
9
|
* Gets a MongoDB collection with the specified type.
|
|
18
10
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DocumentDb.d.ts","sourceRoot":"","sources":["../../src/util/DocumentDb.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,UAAU,EAAmB,MAAM,SAAS,CAAC;AAEtD;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,UAAU
|
|
1
|
+
{"version":3,"file":"DocumentDb.d.ts","sourceRoot":"","sources":["../../src/util/DocumentDb.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,UAAU,EAAmB,MAAM,SAAS,CAAC;AAEtD;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,UAAU;;IA6B7B;;;;;OAKG;WACU,aAAa,CAAC,QAAQ,SAAS,QAAQ,EAClD,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IAQhC;;;;OAIG;WACU,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;CAKhD"}
|
package/lib/util/DocumentDb.js
CHANGED
|
@@ -4,29 +4,29 @@ import { Collection, Db, MongoClient } from 'mongodb';
|
|
|
4
4
|
* A utility class for interacting with a MongoDB database.
|
|
5
5
|
*/
|
|
6
6
|
export default class DocumentDb {
|
|
7
|
-
static DB_NAME = 'default';
|
|
8
|
-
static mongoClient;
|
|
9
|
-
static db;
|
|
7
|
+
static #DB_NAME = 'default';
|
|
8
|
+
static #mongoClient;
|
|
9
|
+
static #db;
|
|
10
10
|
/**
|
|
11
11
|
* Gets or creates the MongoDB client instance.
|
|
12
12
|
*
|
|
13
13
|
* @returns A promise that resolves to the MongoDB client.
|
|
14
14
|
*/
|
|
15
|
-
static async getClient() {
|
|
15
|
+
static async #getClient() {
|
|
16
16
|
if (!ConfigService.isInitialized) {
|
|
17
17
|
// Hard-coded local for now until there are move envs.
|
|
18
18
|
await ConfigService.useConfig('local');
|
|
19
19
|
}
|
|
20
20
|
const { config } = ConfigService;
|
|
21
|
-
if (!this
|
|
21
|
+
if (!this.#mongoClient) {
|
|
22
22
|
const mongoDbConnectionString = `mongodb+srv://${config.mongoRootUsername}:${config.mongoRootPassword}@${config.mongoUrl}/?retryWrites=true&w=majority`;
|
|
23
|
-
this
|
|
23
|
+
this.#mongoClient = new MongoClient(mongoDbConnectionString);
|
|
24
24
|
}
|
|
25
25
|
// Connecting every time is evidently the correct way to do it. This is
|
|
26
26
|
// because it will not do anything and just return if it is already
|
|
27
27
|
// connected.
|
|
28
|
-
await this
|
|
29
|
-
return this
|
|
28
|
+
await this.#mongoClient.connect();
|
|
29
|
+
return this.#mongoClient;
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
32
|
* Gets a MongoDB collection with the specified type.
|
|
@@ -35,11 +35,11 @@ export default class DocumentDb {
|
|
|
35
35
|
* @returns A promise that resolves to the typed MongoDB collection.
|
|
36
36
|
*/
|
|
37
37
|
static async getCollection(collectionName) {
|
|
38
|
-
const client = await this
|
|
39
|
-
if (!DocumentDb
|
|
40
|
-
DocumentDb
|
|
38
|
+
const client = await this.#getClient();
|
|
39
|
+
if (!DocumentDb.#db) {
|
|
40
|
+
DocumentDb.#db = client.db(DocumentDb.#DB_NAME);
|
|
41
41
|
}
|
|
42
|
-
return DocumentDb
|
|
42
|
+
return DocumentDb.#db.collection(collectionName);
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
45
45
|
* Closes the active MongoDB connection.
|
|
@@ -47,8 +47,8 @@ export default class DocumentDb {
|
|
|
47
47
|
* @returns A promise that resolves when the connection is closed.
|
|
48
48
|
*/
|
|
49
49
|
static async closeDbConnection() {
|
|
50
|
-
if (DocumentDb
|
|
51
|
-
await DocumentDb
|
|
50
|
+
if (DocumentDb.#mongoClient) {
|
|
51
|
+
await DocumentDb.#mongoClient.close();
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DocumentDb.js","sourceRoot":"","sources":["../../src/util/DocumentDb.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,UAAU,EAAE,EAAE,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtD;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,UAAU;
|
|
1
|
+
{"version":3,"file":"DocumentDb.js","sourceRoot":"","sources":["../../src/util/DocumentDb.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,UAAU,EAAE,EAAE,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtD;;GAEG;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AC,YAAY,CAAC,KAAK,EAAE,CAAC;QACxC,CAAC;IACH,CAAC"}
|
package/lib/util/DocumentDb.ts
CHANGED
|
@@ -6,32 +6,32 @@ import { Collection, Db, MongoClient } from 'mongodb';
|
|
|
6
6
|
* A utility class for interacting with a MongoDB database.
|
|
7
7
|
*/
|
|
8
8
|
export default class DocumentDb {
|
|
9
|
-
|
|
9
|
+
static #DB_NAME = 'default';
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
static #mongoClient: MongoClient | undefined;
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
static #db: Db | undefined;
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Gets or creates the MongoDB client instance.
|
|
17
17
|
*
|
|
18
18
|
* @returns A promise that resolves to the MongoDB client.
|
|
19
19
|
*/
|
|
20
|
-
|
|
20
|
+
static async #getClient(): Promise<MongoClient> {
|
|
21
21
|
if (!ConfigService.isInitialized) {
|
|
22
22
|
// Hard-coded local for now until there are move envs.
|
|
23
23
|
await ConfigService.useConfig('local');
|
|
24
24
|
}
|
|
25
25
|
const { config } = ConfigService;
|
|
26
|
-
if (!this
|
|
26
|
+
if (!this.#mongoClient) {
|
|
27
27
|
const mongoDbConnectionString = `mongodb+srv://${config.mongoRootUsername}:${config.mongoRootPassword}@${config.mongoUrl}/?retryWrites=true&w=majority`;
|
|
28
|
-
this
|
|
28
|
+
this.#mongoClient = new MongoClient(mongoDbConnectionString);
|
|
29
29
|
}
|
|
30
30
|
// Connecting every time is evidently the correct way to do it. This is
|
|
31
31
|
// because it will not do anything and just return if it is already
|
|
32
32
|
// connected.
|
|
33
|
-
await this
|
|
34
|
-
return this
|
|
33
|
+
await this.#mongoClient.connect();
|
|
34
|
+
return this.#mongoClient;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
/**
|
|
@@ -43,11 +43,11 @@ export default class DocumentDb {
|
|
|
43
43
|
static async getCollection<TDocType extends Document>(
|
|
44
44
|
collectionName: string
|
|
45
45
|
): Promise<Collection<TDocType>> {
|
|
46
|
-
const client = await this
|
|
47
|
-
if (!DocumentDb
|
|
48
|
-
DocumentDb
|
|
46
|
+
const client = await this.#getClient();
|
|
47
|
+
if (!DocumentDb.#db) {
|
|
48
|
+
DocumentDb.#db = client.db(DocumentDb.#DB_NAME);
|
|
49
49
|
}
|
|
50
|
-
return DocumentDb
|
|
50
|
+
return DocumentDb.#db.collection<TDocType>(collectionName);
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
/**
|
|
@@ -56,8 +56,8 @@ export default class DocumentDb {
|
|
|
56
56
|
* @returns A promise that resolves when the connection is closed.
|
|
57
57
|
*/
|
|
58
58
|
static async closeDbConnection(): Promise<void> {
|
|
59
|
-
if (DocumentDb
|
|
60
|
-
await DocumentDb
|
|
59
|
+
if (DocumentDb.#mongoClient) {
|
|
60
|
+
await DocumentDb.#mongoClient.close();
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
}
|
|
@@ -4,6 +4,7 @@ import IValidator from '../BaseValidator.js';
|
|
|
4
4
|
* Validator for the User class.
|
|
5
5
|
*/
|
|
6
6
|
export default class UserValidator extends IValidator<User> {
|
|
7
|
+
#private;
|
|
7
8
|
constructor();
|
|
8
9
|
protected validateNewObjectBusinessLogic(newUser: User): Promise<void>;
|
|
9
10
|
/**
|
|
@@ -13,13 +14,5 @@ export default class UserValidator extends IValidator<User> {
|
|
|
13
14
|
*/
|
|
14
15
|
protected validateUpdateObjectBusinessLogic(userToUpdate: Partial<User>): Promise<void>;
|
|
15
16
|
validateRepositoryInDb(dryRun: boolean): Promise<void>;
|
|
16
|
-
/**
|
|
17
|
-
* Checks if the username exists already and throws an error if it does.
|
|
18
|
-
*
|
|
19
|
-
* @param userRepo - The user repository
|
|
20
|
-
* @param userName - The username to check
|
|
21
|
-
* @throws {Error} An error if the username already exists
|
|
22
|
-
*/
|
|
23
|
-
private checkIfUserNameExists;
|
|
24
17
|
}
|
|
25
18
|
//# sourceMappingURL=UserValidator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserValidator.d.ts","sourceRoot":"","sources":["../../../src/validators/common/UserValidator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAMrD,OAAO,UAAU,MAAM,qBAAqB,CAAC;AAE7C;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,UAAU,CAAC,IAAI,CAAC
|
|
1
|
+
{"version":3,"file":"UserValidator.d.ts","sourceRoot":"","sources":["../../../src/validators/common/UserValidator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAMrD,OAAO,UAAU,MAAM,qBAAqB,CAAC;AAE7C;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,UAAU,CAAC,IAAI,CAAC;;;cAKzC,8BAA8B,CAAC,OAAO,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAM5E;;;;OAIG;cACa,iCAAiC,CAAC,YAAY,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAwBvF,sBAAsB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAwC7D"}
|
|
@@ -13,7 +13,7 @@ export default class UserValidator extends IValidator {
|
|
|
13
13
|
async validateNewObjectBusinessLogic(newUser) {
|
|
14
14
|
// Check if the username already exists
|
|
15
15
|
const userRepo = UserRepository.getRepo();
|
|
16
|
-
await this
|
|
16
|
+
await this.#checkIfUserNameExists(userRepo, newUser.userName);
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
19
|
* Validates the object to be updated.
|
|
@@ -35,7 +35,7 @@ export default class UserValidator extends IValidator {
|
|
|
35
35
|
// Check if the username is being updated and, if it is, if it already
|
|
36
36
|
// exists
|
|
37
37
|
if (userToUpdate.userName && userInDb.userName !== userToUpdate.userName) {
|
|
38
|
-
await this
|
|
38
|
+
await this.#checkIfUserNameExists(userRepo, userToUpdate.userName);
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
async validateRepositoryInDb(dryRun) {
|
|
@@ -67,7 +67,7 @@ export default class UserValidator extends IValidator {
|
|
|
67
67
|
* @param userName - The username to check
|
|
68
68
|
* @throws {Error} An error if the username already exists
|
|
69
69
|
*/
|
|
70
|
-
async checkIfUserNameExists(userRepo, userName) {
|
|
70
|
+
async #checkIfUserNameExists(userRepo, userName) {
|
|
71
71
|
const userNameSearchResult = await userRepo.get({
|
|
72
72
|
userName
|
|
73
73
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserValidator.js","sourceRoot":"","sources":["../../../src/validators/common/UserValidator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,cAAc,MAAM,6CAA6C,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,UAAU,MAAM,qBAAqB,CAAC;AAE7C;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,UAAgB;IACzD;QACE,KAAK,CAAC,UAAU,EAAE,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC;IAC1C,CAAC;IAES,KAAK,CAAC,8BAA8B,CAAC,OAAa;QAC1D,uCAAuC;QACvC,MAAM,QAAQ,GAAG,cAAc,CAAC,OAAO,EAAE,CAAC;QAC1C,MAAM,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"UserValidator.js","sourceRoot":"","sources":["../../../src/validators/common/UserValidator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,cAAc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ser: User): Promise<void> {
|
|
18
18
|
// Check if the username already exists
|
|
19
19
|
const userRepo = UserRepository.getRepo();
|
|
20
|
-
await this
|
|
20
|
+
await this.#checkIfUserNameExists(userRepo, newUser.userName);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
/**
|
|
@@ -45,7 +45,7 @@ export default class UserValidator extends IValidator<User> {
|
|
|
45
45
|
// Check if the username is being updated and, if it is, if it already
|
|
46
46
|
// exists
|
|
47
47
|
if (userToUpdate.userName && userInDb.userName !== userToUpdate.userName) {
|
|
48
|
-
await this
|
|
48
|
+
await this.#checkIfUserNameExists(userRepo, userToUpdate.userName);
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
|
|
@@ -80,7 +80,7 @@ export default class UserValidator extends IValidator<User> {
|
|
|
80
80
|
* @param userName - The username to check
|
|
81
81
|
* @throws {Error} An error if the username already exists
|
|
82
82
|
*/
|
|
83
|
-
|
|
83
|
+
async #checkIfUserNameExists(userRepo: UserRepository, userName: string) {
|
|
84
84
|
const userNameSearchResult = await userRepo.get({
|
|
85
85
|
userName
|
|
86
86
|
});
|