@aneuhold/be-ts-db-lib 2.0.85 → 3.0.0
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 +10 -0
- package/lib/repositories/BaseRepository.d.ts +10 -11
- package/lib/repositories/BaseRepository.d.ts.map +1 -1
- package/lib/repositories/BaseRepository.js +6 -7
- package/lib/repositories/BaseRepository.js.map +1 -1
- package/lib/repositories/BaseRepository.ts +13 -14
- package/lib/repositories/common/UserRepository.d.ts +2 -2
- package/lib/repositories/common/UserRepository.d.ts.map +1 -1
- package/lib/repositories/common/UserRepository.js +0 -1
- package/lib/repositories/common/UserRepository.js.map +1 -1
- package/lib/repositories/common/UserRepository.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 +0 -1
- package/lib/repositories/dashboard/DashboardNonogramKatanaItemRepository.js.map +1 -1
- package/lib/repositories/dashboard/DashboardNonogramKatanaItemRepository.ts +2 -2
- 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 +0 -1
- package/lib/repositories/dashboard/DashboardNonogramKatanaUpgradeRepository.js.map +1 -1
- package/lib/repositories/dashboard/DashboardNonogramKatanaUpgradeRepository.ts +2 -2
- package/lib/repositories/dashboard/DashboardTaskRepository.d.ts +4 -4
- package/lib/repositories/dashboard/DashboardTaskRepository.d.ts.map +1 -1
- package/lib/repositories/dashboard/DashboardTaskRepository.js +0 -1
- package/lib/repositories/dashboard/DashboardTaskRepository.js.map +1 -1
- package/lib/repositories/dashboard/DashboardTaskRepository.ts +5 -5
- package/lib/repositories/dashboard/DashboardUserConfigRepository.d.ts +2 -2
- package/lib/repositories/dashboard/DashboardUserConfigRepository.d.ts.map +1 -1
- package/lib/repositories/dashboard/DashboardUserConfigRepository.js +1 -2
- package/lib/repositories/dashboard/DashboardUserConfigRepository.js.map +1 -1
- package/lib/repositories/dashboard/DashboardUserConfigRepository.ts +4 -4
- package/lib/services/DemoAccountsService/DashboardDemoAccountsService.d.ts +2 -2
- package/lib/services/DemoAccountsService/DashboardDemoAccountsService.d.ts.map +1 -1
- package/lib/services/DemoAccountsService/DashboardDemoAccountsService.js +2 -3
- package/lib/services/DemoAccountsService/DashboardDemoAccountsService.js.map +1 -1
- package/lib/services/DemoAccountsService/DashboardDemoAccountsService.ts +13 -13
- package/lib/services/DemoAccountsService/DemoAccountsService.d.ts +2 -2
- package/lib/services/DemoAccountsService/DemoAccountsService.d.ts.map +1 -1
- package/lib/services/DemoAccountsService/DemoAccountsService.js +0 -1
- package/lib/services/DemoAccountsService/DemoAccountsService.js.map +1 -1
- package/lib/services/DemoAccountsService/DemoAccountsService.ts +2 -5
- package/lib/services/MigrationService.d.ts.map +1 -1
- package/lib/services/MigrationService.js +151 -19
- package/lib/services/MigrationService.js.map +1 -1
- package/lib/services/MigrationService.ts +178 -21
- package/lib/services/RepoSubscriptionService.d.ts +3 -3
- package/lib/services/RepoSubscriptionService.d.ts.map +1 -1
- package/lib/services/RepoSubscriptionService.js +0 -1
- package/lib/services/RepoSubscriptionService.js.map +1 -1
- package/lib/services/RepoSubscriptionService.ts +3 -3
- package/lib/validators/BaseValidator.d.ts +2 -2
- package/lib/validators/BaseValidator.d.ts.map +1 -1
- package/lib/validators/BaseValidator.js +1 -2
- package/lib/validators/BaseValidator.js.map +1 -1
- package/lib/validators/BaseValidator.ts +4 -4
- package/lib/validators/common/ApiKeyValidator.d.ts.map +1 -1
- package/lib/validators/common/ApiKeyValidator.js +6 -7
- package/lib/validators/common/ApiKeyValidator.js.map +1 -1
- package/lib/validators/common/ApiKeyValidator.ts +8 -15
- package/lib/validators/common/UserValidator.d.ts.map +1 -1
- package/lib/validators/common/UserValidator.js +2 -3
- package/lib/validators/common/UserValidator.js.map +1 -1
- package/lib/validators/common/UserValidator.ts +4 -6
- package/lib/validators/dashboard/NonogramKatanaItemValidator.js +4 -5
- package/lib/validators/dashboard/NonogramKatanaItemValidator.js.map +1 -1
- package/lib/validators/dashboard/NonogramKatanaItemValidator.ts +6 -6
- package/lib/validators/dashboard/NonogramKatanaUpgradeValidator.js +4 -5
- package/lib/validators/dashboard/NonogramKatanaUpgradeValidator.js.map +1 -1
- package/lib/validators/dashboard/NonogramKatanaUpgradeValidator.ts +6 -6
- package/lib/validators/dashboard/TaskValidator.js +8 -9
- package/lib/validators/dashboard/TaskValidator.js.map +1 -1
- package/lib/validators/dashboard/TaskValidator.ts +10 -10
- package/lib/validators/dashboard/UserConfigValidator.d.ts.map +1 -1
- package/lib/validators/dashboard/UserConfigValidator.js +9 -10
- package/lib/validators/dashboard/UserConfigValidator.js.map +1 -1
- package/lib/validators/dashboard/UserConfigValidator.ts +11 -16
- package/package.json +10 -7
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NonogramKatanaItem, validateNonogramKatanaItem } from '@aneuhold/core-ts-db-lib';
|
|
2
2
|
import { DR, ErrorUtils } from '@aneuhold/core-ts-lib';
|
|
3
|
-
import {
|
|
3
|
+
import type { UUID } from 'crypto';
|
|
4
4
|
import UserRepository from '../../repositories/common/UserRepository.js';
|
|
5
5
|
import DashboardNonogramKatanaItemRepository from '../../repositories/dashboard/DashboardNonogramKatanaItemRepository.js';
|
|
6
6
|
import IValidator from '../BaseValidator.js';
|
|
@@ -15,14 +15,14 @@ export default class DashboardNonogramKatanaItemValidator extends IValidator<Non
|
|
|
15
15
|
});
|
|
16
16
|
if (existingItem) {
|
|
17
17
|
ErrorUtils.throwError(
|
|
18
|
-
`Nonogram Katana item already exists for user: ${newItem.userId
|
|
18
|
+
`Nonogram Katana item already exists for user: ${newItem.userId}`,
|
|
19
19
|
newItem
|
|
20
20
|
);
|
|
21
21
|
}
|
|
22
22
|
const userRepo = UserRepository.getRepo();
|
|
23
23
|
const user = await userRepo.get({ _id: newItem.userId });
|
|
24
24
|
if (!user) {
|
|
25
|
-
ErrorUtils.throwError(`User does not exist: ${newItem.userId
|
|
25
|
+
ErrorUtils.throwError(`User does not exist: ${newItem.userId}`, newItem);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
|
|
@@ -44,9 +44,9 @@ export default class DashboardNonogramKatanaItemValidator extends IValidator<Non
|
|
|
44
44
|
docName: 'Nonogram Katana Item',
|
|
45
45
|
allDocs: allItems,
|
|
46
46
|
shouldDelete: (item: NonogramKatanaItem) => {
|
|
47
|
-
if (!allUserIds[item.userId
|
|
47
|
+
if (!allUserIds[item.userId]) {
|
|
48
48
|
DR.logger.error(
|
|
49
|
-
`Nonogram Katana Item with ID: ${item._id
|
|
49
|
+
`Nonogram Katana Item with ID: ${item._id} has no valid associated user.`
|
|
50
50
|
);
|
|
51
51
|
return true;
|
|
52
52
|
}
|
|
@@ -56,7 +56,7 @@ export default class DashboardNonogramKatanaItemValidator extends IValidator<Non
|
|
|
56
56
|
const { updatedDoc, errors } = validateNonogramKatanaItem(item);
|
|
57
57
|
return { updatedDoc, errors };
|
|
58
58
|
},
|
|
59
|
-
deletionFunction: async (docIdsToDelete:
|
|
59
|
+
deletionFunction: async (docIdsToDelete: UUID[]) => {
|
|
60
60
|
await itemRepo.deleteList(docIdsToDelete);
|
|
61
61
|
},
|
|
62
62
|
updateFunction: async (docsToUpdate: NonogramKatanaItem[]) => {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { NonogramKatanaUpgrade, validateNonogramKatanaUpgrade } from '@aneuhold/core-ts-db-lib';
|
|
2
2
|
import { DR, ErrorUtils } from '@aneuhold/core-ts-lib';
|
|
3
|
-
import { ObjectId } from 'bson';
|
|
4
3
|
import UserRepository from '../../repositories/common/UserRepository.js';
|
|
5
4
|
import DashboardNonogramKatanaUpgradeRepository from '../../repositories/dashboard/DashboardNonogramKatanaUpgradeRepository.js';
|
|
6
5
|
import IValidator from '../BaseValidator.js';
|
|
@@ -13,12 +12,12 @@ export default class DashboardNonogramKatanaUpgradeValidator extends IValidator
|
|
|
13
12
|
upgradeName: newUpgrade.upgradeName
|
|
14
13
|
});
|
|
15
14
|
if (existingItem) {
|
|
16
|
-
ErrorUtils.throwError(`Nonogram Katana upgrade already exists for user: ${newUpgrade.userId
|
|
15
|
+
ErrorUtils.throwError(`Nonogram Katana upgrade already exists for user: ${newUpgrade.userId}`, newUpgrade);
|
|
17
16
|
}
|
|
18
17
|
const userRepo = UserRepository.getRepo();
|
|
19
18
|
const user = await userRepo.get({ _id: newUpgrade.userId });
|
|
20
19
|
if (!user) {
|
|
21
|
-
ErrorUtils.throwError(`User does not exist: ${newUpgrade.userId
|
|
20
|
+
ErrorUtils.throwError(`User does not exist: ${newUpgrade.userId}`, newUpgrade);
|
|
22
21
|
}
|
|
23
22
|
}
|
|
24
23
|
// eslint-disable-next-line @typescript-eslint/require-await
|
|
@@ -37,8 +36,8 @@ export default class DashboardNonogramKatanaUpgradeValidator extends IValidator
|
|
|
37
36
|
docName: 'Nonogram Katana Upgrade',
|
|
38
37
|
allDocs: allUpgrades,
|
|
39
38
|
shouldDelete: (upgrade) => {
|
|
40
|
-
if (!allUserIds[upgrade.userId
|
|
41
|
-
DR.logger.error(`Nonogram Katana Upgrade with ID: ${upgrade._id
|
|
39
|
+
if (!allUserIds[upgrade.userId]) {
|
|
40
|
+
DR.logger.error(`Nonogram Katana Upgrade with ID: ${upgrade._id} has no valid associated user.`);
|
|
42
41
|
return true;
|
|
43
42
|
}
|
|
44
43
|
return false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NonogramKatanaUpgradeValidator.js","sourceRoot":"","sources":["../../../src/validators/dashboard/NonogramKatanaUpgradeValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,6BAA6B,EAAE,MAAM,0BAA0B,CAAC;AAChG,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"NonogramKatanaUpgradeValidator.js","sourceRoot":"","sources":["../../../src/validators/dashboard/NonogramKatanaUpgradeValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,6BAA6B,EAAE,MAAM,0BAA0B,CAAC;AAChG,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,cAAc,MAAM,6CAA6C,CAAC;AACzE,OAAO,wCAAwC,MAAM,0EAA0E,CAAC;AAChI,OAAO,UAAU,MAAM,qBAAqB,CAAC;AAE7C,MAAM,CAAC,OAAO,OAAO,uCAAwC,SAAQ,UAAiC;IACpG,KAAK,CAAC,iBAAiB,CAAC,UAAiC;QACvD,gDAAgD;QAChD,MAAM,WAAW,GAAG,wCAAwC,CAAC,OAAO,EAAE,CAAC;QACvE,MAAM,YAAY,GAAG,MAAM,WAAW,CAAC,GAAG,CAAC;YACzC,MAAM,EAAE,UAAU,CAAC,MAAM;YACzB,WAAW,EAAE,UAAU,CAAC,WAAW;SACpC,CAAC,CAAC;QACH,IAAI,YAAY,EAAE,CAAC;YACjB,UAAU,CAAC,UAAU,CACnB,oDAAoD,UAAU,CAAC,MAAM,EAAE,EACvE,UAAU,CACX,CAAC;QACJ,CAAC;QACD,MAAM,QAAQ,GAAG,cAAc,CAAC,OAAO,EAAE,CAAC;QAC1C,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC;QAC5D,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,UAAU,CAAC,UAAU,CAAC,wBAAwB,UAAU,CAAC,MAAM,EAAE,EAAE,UAAU,CAAC,CAAC;QACjF,CAAC;IACH,CAAC;IAED,4DAA4D;IAC5D,KAAK,CAAC,oBAAoB,CAAC,cA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-1,6 +1,6 @@
|
|
|
1
1
|
import { NonogramKatanaUpgrade, validateNonogramKatanaUpgrade } from '@aneuhold/core-ts-db-lib';
|
|
2
2
|
import { DR, ErrorUtils } from '@aneuhold/core-ts-lib';
|
|
3
|
-
import {
|
|
3
|
+
import type { UUID } from 'crypto';
|
|
4
4
|
import UserRepository from '../../repositories/common/UserRepository.js';
|
|
5
5
|
import DashboardNonogramKatanaUpgradeRepository from '../../repositories/dashboard/DashboardNonogramKatanaUpgradeRepository.js';
|
|
6
6
|
import IValidator from '../BaseValidator.js';
|
|
@@ -15,14 +15,14 @@ export default class DashboardNonogramKatanaUpgradeValidator extends IValidator<
|
|
|
15
15
|
});
|
|
16
16
|
if (existingItem) {
|
|
17
17
|
ErrorUtils.throwError(
|
|
18
|
-
`Nonogram Katana upgrade already exists for user: ${newUpgrade.userId
|
|
18
|
+
`Nonogram Katana upgrade already exists for user: ${newUpgrade.userId}`,
|
|
19
19
|
newUpgrade
|
|
20
20
|
);
|
|
21
21
|
}
|
|
22
22
|
const userRepo = UserRepository.getRepo();
|
|
23
23
|
const user = await userRepo.get({ _id: newUpgrade.userId });
|
|
24
24
|
if (!user) {
|
|
25
|
-
ErrorUtils.throwError(`User does not exist: ${newUpgrade.userId
|
|
25
|
+
ErrorUtils.throwError(`User does not exist: ${newUpgrade.userId}`, newUpgrade);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
|
|
@@ -44,9 +44,9 @@ export default class DashboardNonogramKatanaUpgradeValidator extends IValidator<
|
|
|
44
44
|
docName: 'Nonogram Katana Upgrade',
|
|
45
45
|
allDocs: allUpgrades,
|
|
46
46
|
shouldDelete: (upgrade: NonogramKatanaUpgrade) => {
|
|
47
|
-
if (!allUserIds[upgrade.userId
|
|
47
|
+
if (!allUserIds[upgrade.userId]) {
|
|
48
48
|
DR.logger.error(
|
|
49
|
-
`Nonogram Katana Upgrade with ID: ${upgrade._id
|
|
49
|
+
`Nonogram Katana Upgrade with ID: ${upgrade._id} has no valid associated user.`
|
|
50
50
|
);
|
|
51
51
|
return true;
|
|
52
52
|
}
|
|
@@ -56,7 +56,7 @@ export default class DashboardNonogramKatanaUpgradeValidator extends IValidator<
|
|
|
56
56
|
const { updatedDoc, errors } = validateNonogramKatanaUpgrade(upgrade);
|
|
57
57
|
return { updatedDoc, errors };
|
|
58
58
|
},
|
|
59
|
-
deletionFunction: async (docIdsToDelete:
|
|
59
|
+
deletionFunction: async (docIdsToDelete: UUID[]) => {
|
|
60
60
|
await upgradeRepo.deleteList(docIdsToDelete);
|
|
61
61
|
},
|
|
62
62
|
updateFunction: async (docsToUpdate: NonogramKatanaUpgrade[]) => {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { DashboardTask, validateDashboardTask } from '@aneuhold/core-ts-db-lib';
|
|
2
2
|
import { DR, ErrorUtils } from '@aneuhold/core-ts-lib';
|
|
3
|
-
import { ObjectId } from 'bson';
|
|
4
3
|
import UserRepository from '../../repositories/common/UserRepository.js';
|
|
5
4
|
import DashboardTaskRepository from '../../repositories/dashboard/DashboardTaskRepository.js';
|
|
6
5
|
import IValidator from '../BaseValidator.js';
|
|
@@ -31,7 +30,7 @@ export default class DashboardTaskValidator extends IValidator {
|
|
|
31
30
|
_id: updatedTask.parentTaskId
|
|
32
31
|
});
|
|
33
32
|
if (!parentTask) {
|
|
34
|
-
errors.push(`Parent task with ID: ${updatedTask.parentTaskId
|
|
33
|
+
errors.push(`Parent task with ID: ${updatedTask.parentTaskId} does not exist.`);
|
|
35
34
|
}
|
|
36
35
|
}
|
|
37
36
|
if (errors.length > 0) {
|
|
@@ -47,8 +46,8 @@ export default class DashboardTaskValidator extends IValidator {
|
|
|
47
46
|
docName: 'Dashboard Task',
|
|
48
47
|
allDocs: allTasks,
|
|
49
48
|
shouldDelete: (task) => {
|
|
50
|
-
if (!allUserIds[task.userId
|
|
51
|
-
DR.logger.error(`Dashboard Task with ID: ${task._id
|
|
49
|
+
if (!allUserIds[task.userId]) {
|
|
50
|
+
DR.logger.error(`Dashboard Task with ID: ${task._id} has no valid associated owner (user).`);
|
|
52
51
|
return true;
|
|
53
52
|
}
|
|
54
53
|
return false;
|
|
@@ -58,14 +57,14 @@ export default class DashboardTaskValidator extends IValidator {
|
|
|
58
57
|
// Check sharedWith
|
|
59
58
|
const sharedWithUserIds = [...task.sharedWith];
|
|
60
59
|
sharedWithUserIds.forEach((userId) => {
|
|
61
|
-
if (!allUserIds[userId
|
|
62
|
-
errors.push(`User with ID: ${userId
|
|
63
|
-
task.sharedWith = task.sharedWith.filter((id) => id
|
|
60
|
+
if (!allUserIds[userId]) {
|
|
61
|
+
errors.push(`User with ID: ${userId} does not exist in sharedWith property of task with ID: ${task._id}.`);
|
|
62
|
+
task.sharedWith = task.sharedWith.filter((id) => id !== userId);
|
|
64
63
|
}
|
|
65
64
|
});
|
|
66
65
|
// Check assignedTo
|
|
67
|
-
if (task.assignedTo && !allUserIds[task.assignedTo
|
|
68
|
-
errors.push(`User with ID: ${task.assignedTo
|
|
66
|
+
if (task.assignedTo && !allUserIds[task.assignedTo]) {
|
|
67
|
+
errors.push(`User with ID: ${task.assignedTo} does not exist in assignedTo property of task with ID: ${task._id}.`);
|
|
69
68
|
updatedDoc.assignedTo = undefined;
|
|
70
69
|
}
|
|
71
70
|
return { updatedDoc, errors };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TaskValidator.js","sourceRoot":"","sources":["../../../src/validators/dashboard/TaskValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAChF,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"TaskValidator.js","sourceRoot":"","sources":["../../../src/validators/dashboard/TaskValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAChF,OAAO,EAAE,EAAE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CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;wBACxB,MAAM,CAAC,IAAI,CACT,iBAAiB,MAAM,2DAA2D,IAAI,CAAC,GAAG,GAAG,CAC9F,CAAC;wBAEF,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,MAAM,CAAC,CAAC;oBAClE,CAAC;gBACH,CAAC,CAAC,CAAC;gBAEH,mBAAmB;gBACnB,IAAI,IAAI,CAAC,UAAU,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;oBACpD,MAAM,CAAC,IAAI,CACT,iBAAiB,IAAI,CAAC,UAAU,2DAA2D,IAAI,CAAC,GAAG,GAAG,CACvG,CAAC;oBACF,UAAU,CAAC,UAAU,GAAG,SAAS,CAAC;gBACpC,CAAC;gBAED,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC;YAChC,CAAC;YACD,gBAAgB,EAAE,KAAK,EAAE,cAAsB,EAAE,EAAE;gBACjD,MAAM,QAAQ,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;YAC5C,CAAC;YACD,cAAc,EAAE,KAAK,EAAE,YAA6B,EAAE,EAAE;gBACtD,MAAM,QAAQ,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;YAC1C,CAAC;SACF,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DashboardTask, validateDashboardTask } from '@aneuhold/core-ts-db-lib';
|
|
2
2
|
import { DR, ErrorUtils } from '@aneuhold/core-ts-lib';
|
|
3
|
-
import {
|
|
3
|
+
import type { UUID } from 'crypto';
|
|
4
4
|
import UserRepository from '../../repositories/common/UserRepository.js';
|
|
5
5
|
import DashboardTaskRepository from '../../repositories/dashboard/DashboardTaskRepository.js';
|
|
6
6
|
import IValidator from '../BaseValidator.js';
|
|
@@ -37,7 +37,7 @@ export default class DashboardTaskValidator extends IValidator<DashboardTask> {
|
|
|
37
37
|
_id: updatedTask.parentTaskId
|
|
38
38
|
});
|
|
39
39
|
if (!parentTask) {
|
|
40
|
-
errors.push(`Parent task with ID: ${updatedTask.parentTaskId
|
|
40
|
+
errors.push(`Parent task with ID: ${updatedTask.parentTaskId} does not exist.`);
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
if (errors.length > 0) {
|
|
@@ -55,9 +55,9 @@ export default class DashboardTaskValidator extends IValidator<DashboardTask> {
|
|
|
55
55
|
docName: 'Dashboard Task',
|
|
56
56
|
allDocs: allTasks,
|
|
57
57
|
shouldDelete: (task: DashboardTask) => {
|
|
58
|
-
if (!allUserIds[task.userId
|
|
58
|
+
if (!allUserIds[task.userId]) {
|
|
59
59
|
DR.logger.error(
|
|
60
|
-
`Dashboard Task with ID: ${task._id
|
|
60
|
+
`Dashboard Task with ID: ${task._id} has no valid associated owner (user).`
|
|
61
61
|
);
|
|
62
62
|
return true;
|
|
63
63
|
}
|
|
@@ -69,26 +69,26 @@ export default class DashboardTaskValidator extends IValidator<DashboardTask> {
|
|
|
69
69
|
// Check sharedWith
|
|
70
70
|
const sharedWithUserIds = [...task.sharedWith];
|
|
71
71
|
sharedWithUserIds.forEach((userId) => {
|
|
72
|
-
if (!allUserIds[userId
|
|
72
|
+
if (!allUserIds[userId]) {
|
|
73
73
|
errors.push(
|
|
74
|
-
`User with ID: ${userId
|
|
74
|
+
`User with ID: ${userId} does not exist in sharedWith property of task with ID: ${task._id}.`
|
|
75
75
|
);
|
|
76
76
|
|
|
77
|
-
task.sharedWith = task.sharedWith.filter((id) => id
|
|
77
|
+
task.sharedWith = task.sharedWith.filter((id) => id !== userId);
|
|
78
78
|
}
|
|
79
79
|
});
|
|
80
80
|
|
|
81
81
|
// Check assignedTo
|
|
82
|
-
if (task.assignedTo && !allUserIds[task.assignedTo
|
|
82
|
+
if (task.assignedTo && !allUserIds[task.assignedTo]) {
|
|
83
83
|
errors.push(
|
|
84
|
-
`User with ID: ${task.assignedTo
|
|
84
|
+
`User with ID: ${task.assignedTo} does not exist in assignedTo property of task with ID: ${task._id}.`
|
|
85
85
|
);
|
|
86
86
|
updatedDoc.assignedTo = undefined;
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
return { updatedDoc, errors };
|
|
90
90
|
},
|
|
91
|
-
deletionFunction: async (docIdsToDelete:
|
|
91
|
+
deletionFunction: async (docIdsToDelete: UUID[]) => {
|
|
92
92
|
await taskRepo.deleteList(docIdsToDelete);
|
|
93
93
|
},
|
|
94
94
|
updateFunction: async (docsToUpdate: DashboardTask[]) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserConfigValidator.d.ts","sourceRoot":"","sources":["../../../src/validators/dashboard/UserConfigValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAA+B,MAAM,0BAA0B,CAAC;AAK5F,OAAO,UAAU,MAAM,qBAAqB,CAAC;AAE7C,MAAM,CAAC,OAAO,OAAO,4BAA6B,SAAQ,UAAU,CAAC,mBAAmB,CAAC;IACjF,iBAAiB,CAAC,aAAa,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"UserConfigValidator.d.ts","sourceRoot":"","sources":["../../../src/validators/dashboard/UserConfigValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAA+B,MAAM,0BAA0B,CAAC;AAK5F,OAAO,UAAU,MAAM,qBAAqB,CAAC;AAE7C,MAAM,CAAC,OAAO,OAAO,4BAA6B,SAAQ,UAAU,CAAC,mBAAmB,CAAC;IACjF,iBAAiB,CAAC,aAAa,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IAiCpE,oBAAoB,CAAC,iBAAiB,EAAE,OAAO,CAAC,mBAAmB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAqBpF,sBAAsB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAwC7D"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { DashboardUserConfig, validateDashboardUserConfig } from '@aneuhold/core-ts-db-lib';
|
|
2
2
|
import { DR, ErrorUtils } from '@aneuhold/core-ts-lib';
|
|
3
|
-
import { ObjectId } from 'bson';
|
|
4
3
|
import UserRepository from '../../repositories/common/UserRepository.js';
|
|
5
4
|
import DashboardUserConfigRepository from '../../repositories/dashboard/DashboardUserConfigRepository.js';
|
|
6
5
|
import IValidator from '../BaseValidator.js';
|
|
@@ -12,14 +11,14 @@ export default class DashboardUserConfigValidator extends IValidator {
|
|
|
12
11
|
userId: newUserConfig.userId
|
|
13
12
|
});
|
|
14
13
|
if (existingConfig) {
|
|
15
|
-
DR.logger.error(`Config already exists for user: ${newUserConfig.userId
|
|
16
|
-
ErrorUtils.throwError(`Config already exists for user: ${newUserConfig.userId
|
|
14
|
+
DR.logger.error(`Config already exists for user: ${newUserConfig.userId}`);
|
|
15
|
+
ErrorUtils.throwError(`Config already exists for user: ${newUserConfig.userId}`, newUserConfig);
|
|
17
16
|
}
|
|
18
17
|
const userRepo = UserRepository.getRepo();
|
|
19
18
|
const user = await userRepo.get({ _id: newUserConfig.userId });
|
|
20
19
|
if (!user) {
|
|
21
|
-
DR.logger.error(`User does not exist: ${newUserConfig.userId
|
|
22
|
-
ErrorUtils.throwError(`User does not exist: ${newUserConfig.userId
|
|
20
|
+
DR.logger.error(`User does not exist: ${newUserConfig.userId}`);
|
|
21
|
+
ErrorUtils.throwError(`User does not exist: ${newUserConfig.userId}`, newUserConfig);
|
|
23
22
|
}
|
|
24
23
|
if (newUserConfig.collaborators.length > 0) {
|
|
25
24
|
const collaborators = await userRepo.getList(newUserConfig.collaborators);
|
|
@@ -53,8 +52,8 @@ export default class DashboardUserConfigValidator extends IValidator {
|
|
|
53
52
|
docName: 'Dashboard User Config',
|
|
54
53
|
allDocs: allUserConfigs,
|
|
55
54
|
shouldDelete: (userConfig) => {
|
|
56
|
-
if (!allUserIds[userConfig.userId
|
|
57
|
-
DR.logger.error(`Dashboard User Config with ID: ${userConfig._id
|
|
55
|
+
if (!allUserIds[userConfig.userId]) {
|
|
56
|
+
DR.logger.error(`Dashboard User Config with ID: ${userConfig._id} has no valid associated user.`);
|
|
58
57
|
return true;
|
|
59
58
|
}
|
|
60
59
|
return false;
|
|
@@ -63,9 +62,9 @@ export default class DashboardUserConfigValidator extends IValidator {
|
|
|
63
62
|
const { updatedDoc, errors } = validateDashboardUserConfig(userConfig);
|
|
64
63
|
const collaboratorIds = [...userConfig.collaborators];
|
|
65
64
|
collaboratorIds.forEach((userId) => {
|
|
66
|
-
if (!allUserIds[userId
|
|
67
|
-
errors.push(`User with ID: ${userId
|
|
68
|
-
updatedDoc.collaborators = updatedDoc.collaborators.filter((id) => id
|
|
65
|
+
if (!allUserIds[userId]) {
|
|
66
|
+
errors.push(`User with ID: ${userId} does not exist in collaborators property of Dashboard User Config with ID: ${userConfig._id}.`);
|
|
67
|
+
updatedDoc.collaborators = updatedDoc.collaborators.filter((id) => id !== userId);
|
|
69
68
|
}
|
|
70
69
|
});
|
|
71
70
|
return { updatedDoc, errors };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserConfigValidator.js","sourceRoot":"","sources":["../../../src/validators/dashboard/UserConfigValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAC5F,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"UserConfigValidator.js","sourceRoot":"","sources":["../../../src/validators/dashboard/UserConfigValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAC5F,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,cAAc,MAAM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E,KAAK,EAAE,YAAmC,EAAE,EAAE;gBAC5D,MAAM,cAAc,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;YAChD,CAAC;SACF,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DashboardUserConfig, validateDashboardUserConfig } from '@aneuhold/core-ts-db-lib';
|
|
2
2
|
import { DR, ErrorUtils } from '@aneuhold/core-ts-lib';
|
|
3
|
-
import {
|
|
3
|
+
import type { UUID } from 'crypto';
|
|
4
4
|
import UserRepository from '../../repositories/common/UserRepository.js';
|
|
5
5
|
import DashboardUserConfigRepository from '../../repositories/dashboard/DashboardUserConfigRepository.js';
|
|
6
6
|
import IValidator from '../BaseValidator.js';
|
|
@@ -13,20 +13,17 @@ export default class DashboardUserConfigValidator extends IValidator<DashboardUs
|
|
|
13
13
|
userId: newUserConfig.userId
|
|
14
14
|
});
|
|
15
15
|
if (existingConfig) {
|
|
16
|
-
DR.logger.error(`Config already exists for user: ${newUserConfig.userId
|
|
16
|
+
DR.logger.error(`Config already exists for user: ${newUserConfig.userId}`);
|
|
17
17
|
ErrorUtils.throwError(
|
|
18
|
-
`Config already exists for user: ${newUserConfig.userId
|
|
18
|
+
`Config already exists for user: ${newUserConfig.userId}`,
|
|
19
19
|
newUserConfig
|
|
20
20
|
);
|
|
21
21
|
}
|
|
22
22
|
const userRepo = UserRepository.getRepo();
|
|
23
23
|
const user = await userRepo.get({ _id: newUserConfig.userId });
|
|
24
24
|
if (!user) {
|
|
25
|
-
DR.logger.error(`User does not exist: ${newUserConfig.userId
|
|
26
|
-
ErrorUtils.throwError(
|
|
27
|
-
`User does not exist: ${newUserConfig.userId.toString()}`,
|
|
28
|
-
newUserConfig
|
|
29
|
-
);
|
|
25
|
+
DR.logger.error(`User does not exist: ${newUserConfig.userId}`);
|
|
26
|
+
ErrorUtils.throwError(`User does not exist: ${newUserConfig.userId}`, newUserConfig);
|
|
30
27
|
}
|
|
31
28
|
if (newUserConfig.collaborators.length > 0) {
|
|
32
29
|
const collaborators = await userRepo.getList(newUserConfig.collaborators);
|
|
@@ -73,9 +70,9 @@ export default class DashboardUserConfigValidator extends IValidator<DashboardUs
|
|
|
73
70
|
docName: 'Dashboard User Config',
|
|
74
71
|
allDocs: allUserConfigs,
|
|
75
72
|
shouldDelete: (userConfig: DashboardUserConfig) => {
|
|
76
|
-
if (!allUserIds[userConfig.userId
|
|
73
|
+
if (!allUserIds[userConfig.userId]) {
|
|
77
74
|
DR.logger.error(
|
|
78
|
-
`Dashboard User Config with ID: ${userConfig._id
|
|
75
|
+
`Dashboard User Config with ID: ${userConfig._id} has no valid associated user.`
|
|
79
76
|
);
|
|
80
77
|
return true;
|
|
81
78
|
}
|
|
@@ -85,19 +82,17 @@ export default class DashboardUserConfigValidator extends IValidator<DashboardUs
|
|
|
85
82
|
const { updatedDoc, errors } = validateDashboardUserConfig(userConfig);
|
|
86
83
|
const collaboratorIds = [...userConfig.collaborators];
|
|
87
84
|
collaboratorIds.forEach((userId) => {
|
|
88
|
-
if (!allUserIds[userId
|
|
85
|
+
if (!allUserIds[userId]) {
|
|
89
86
|
errors.push(
|
|
90
|
-
`User with ID: ${userId
|
|
87
|
+
`User with ID: ${userId} does not exist in collaborators property of Dashboard User Config with ID: ${userConfig._id}.`
|
|
91
88
|
);
|
|
92
89
|
|
|
93
|
-
updatedDoc.collaborators = updatedDoc.collaborators.filter(
|
|
94
|
-
(id) => id.toString() !== userId.toString()
|
|
95
|
-
);
|
|
90
|
+
updatedDoc.collaborators = updatedDoc.collaborators.filter((id) => id !== userId);
|
|
96
91
|
}
|
|
97
92
|
});
|
|
98
93
|
return { updatedDoc, errors };
|
|
99
94
|
},
|
|
100
|
-
deletionFunction: async (docIdsToDelete:
|
|
95
|
+
deletionFunction: async (docIdsToDelete: UUID[]) => {
|
|
101
96
|
await userConfigRepo.deleteList(docIdsToDelete);
|
|
102
97
|
},
|
|
103
98
|
updateFunction: async (docsToUpdate: DashboardUserConfig[]) => {
|
package/package.json
CHANGED
|
@@ -2,13 +2,15 @@
|
|
|
2
2
|
"name": "@aneuhold/be-ts-db-lib",
|
|
3
3
|
"author": "Anton G. Neuhold Jr.",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "
|
|
5
|
+
"version": "3.0.0",
|
|
6
6
|
"description": "A backend database library meant to actually interact with various databases in personal projects",
|
|
7
7
|
"packageManager": "pnpm@10.12.1",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"scripts": {
|
|
10
|
-
"build": "rimraf lib &&
|
|
11
|
-
"
|
|
10
|
+
"build": "rimraf lib && pnpm build:withoutClean",
|
|
11
|
+
"build:withoutClean": "tsc --project tsconfig.build.json && tsx ./scripts/copyTsFiles.ts && pnpm propagateVersion",
|
|
12
|
+
"propagateVersion": "tsx ../../scripts/propagateVersion.ts",
|
|
13
|
+
"watch": "nodemon --ignore lib/ -e ts --exec \"pnpm build:withoutClean && local-npm publish\"",
|
|
12
14
|
"unpub:local": "local-npm unpublish || true",
|
|
13
15
|
"lint": "eslint",
|
|
14
16
|
"test": "vitest run && pnpm validate:dry",
|
|
@@ -17,6 +19,7 @@
|
|
|
17
19
|
"validate:dry": "tsx ./scripts/validateSchemaDryRun.ts",
|
|
18
20
|
"jsr:validate": "tb pkg validateJsr",
|
|
19
21
|
"npm:validate": "tb pkg validateNpm",
|
|
22
|
+
"versionPropagation:validate": "tsx ../../scripts/validatePackageVersions.ts",
|
|
20
23
|
"checkAll": "pnpm build && pnpm lint && pnpm test && pnpm jsr:validate",
|
|
21
24
|
"jsr:publish": "tb pkg publishJsr",
|
|
22
25
|
"npm:publish": "tb pkg publishNpm",
|
|
@@ -54,14 +57,14 @@
|
|
|
54
57
|
"MongoDB"
|
|
55
58
|
],
|
|
56
59
|
"dependencies": {
|
|
57
|
-
"@aneuhold/be-ts-lib": "
|
|
58
|
-
"@aneuhold/core-ts-db-lib": "
|
|
59
|
-
"@aneuhold/core-ts-lib": "
|
|
60
|
+
"@aneuhold/be-ts-lib": "^3.0.0",
|
|
61
|
+
"@aneuhold/core-ts-db-lib": "^3.0.0",
|
|
62
|
+
"@aneuhold/core-ts-lib": "^2.3.11",
|
|
60
63
|
"bson": "^7.0.0",
|
|
61
64
|
"mongodb": "^7.0.0"
|
|
62
65
|
},
|
|
63
66
|
"devDependencies": {
|
|
64
|
-
"@aneuhold/local-npm-registry": "
|
|
67
|
+
"@aneuhold/local-npm-registry": "^0.2.17",
|
|
65
68
|
"@aneuhold/main-scripts": "^2.7.2",
|
|
66
69
|
"@types/node": "^24.10.0",
|
|
67
70
|
"@types/node-fetch": "^2.6.13",
|