@aneuhold/be-ts-db-lib 1.0.83 → 1.0.85
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DashboardTaskRepository.d.ts","sourceRoot":"","sources":["../../../src/repositories/dashboard/DashboardTaskRepository.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EAEb,IAAI,EACL,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,uBAAuB,MAAM,2BAA2B,CAAC;AAEhE,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AAIvE;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,uBAAwB,SAAQ,uBAAuB,CAAC,aAAa,CAAC;IACzF,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAA0B;IAE3D,OAAO;IAaP;;;OAGG;IACH,MAAM,CAAC,uBAAuB,IAAI,aAAa,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"DashboardTaskRepository.d.ts","sourceRoot":"","sources":["../../../src/repositories/dashboard/DashboardTaskRepository.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EAEb,IAAI,EACL,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,uBAAuB,MAAM,2BAA2B,CAAC;AAEhE,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AAIvE;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,uBAAwB,SAAQ,uBAAuB,CAAC,aAAa,CAAC;IACzF,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAA0B;IAE3D,OAAO;IAaP;;;OAGG;IACH,MAAM,CAAC,uBAAuB,IAAI,aAAa,CAAC,IAAI,CAAC;IA4BrD,SAAS,CAAC,gBAAgB,IAAI,IAAI;IAElC;;OAEG;WACW,OAAO;IAOrB;;;;;OAKG;IACG,MAAM,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,YAAY,CAAC;IAMpD;;;;OAIG;IACG,UAAU,CAAC,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,YAAY,CAAC;IAM3D;;;;;;OAMG;IACG,aAAa,CAAC,MAAM,EAAE,QAAQ,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAyB/D;;;OAGG;YACW,qBAAqB;CAepC"}
|
|
@@ -29,12 +29,20 @@ class DashboardTaskRepository extends DashboardBaseRepository_1.default {
|
|
|
29
29
|
const taskRepo = DashboardTaskRepository.getRepo();
|
|
30
30
|
return {
|
|
31
31
|
deleteOne: async (userId) => {
|
|
32
|
-
|
|
32
|
+
const taskCollection = await taskRepo.getCollection();
|
|
33
|
+
// Remove all tasks for the user
|
|
34
|
+
await taskCollection.deleteMany({ userId });
|
|
35
|
+
// Remove all assignedTo references for the user
|
|
36
|
+
await taskCollection.updateMany({ assignedTo: userId }, { $set: { assignedTo: undefined } });
|
|
33
37
|
},
|
|
34
38
|
deleteList: async (userIds) => {
|
|
35
|
-
|
|
39
|
+
const taskCollection = await taskRepo.getCollection();
|
|
40
|
+
// Remove all tasks for the users
|
|
41
|
+
await taskCollection.deleteMany({
|
|
36
42
|
userId: { $in: userIds }
|
|
37
43
|
});
|
|
44
|
+
// Remove all assignedTo references for the users
|
|
45
|
+
await taskCollection.updateMany({ assignedTo: { $in: userIds } }, { $set: { assignedTo: undefined } });
|
|
38
46
|
}
|
|
39
47
|
};
|
|
40
48
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TaskValidator.d.ts","sourceRoot":"","sources":["../../../src/validators/dashboard/TaskValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAyB,MAAM,0BAA0B,CAAC;AAGhF,OAAO,UAAU,MAAM,kBAAkB,CAAC;AAI1C,MAAM,CAAC,OAAO,OAAO,sBAAuB,SAAQ,UAAU,CAAC,aAAa,CAAC;IACrE,iBAAiB,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAoBxD,oBAAoB,CACxB,WAAW,EAAE,OAAO,CAAC,aAAa,CAAC,GAClC,OAAO,CAAC,IAAI,CAAC;IAqBV,sBAAsB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"TaskValidator.d.ts","sourceRoot":"","sources":["../../../src/validators/dashboard/TaskValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAyB,MAAM,0BAA0B,CAAC;AAGhF,OAAO,UAAU,MAAM,kBAAkB,CAAC;AAI1C,MAAM,CAAC,OAAO,OAAO,sBAAuB,SAAQ,UAAU,CAAC,aAAa,CAAC;IACrE,iBAAiB,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAoBxD,oBAAoB,CACxB,WAAW,EAAE,OAAO,CAAC,aAAa,CAAC,GAClC,OAAO,CAAC,IAAI,CAAC;IAqBV,sBAAsB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAqD7D"}
|
|
@@ -59,6 +59,7 @@ class DashboardTaskValidator extends BaseValidator_1.default {
|
|
|
59
59
|
},
|
|
60
60
|
documentValidator: (task) => {
|
|
61
61
|
const { updatedDoc, errors } = (0, core_ts_db_lib_1.validateDashboardTask)(task);
|
|
62
|
+
// Check sharedWith
|
|
62
63
|
const sharedWithUserIds = [...task.sharedWith];
|
|
63
64
|
sharedWithUserIds.forEach((userId) => {
|
|
64
65
|
if (!allUserIds[userId.toString()]) {
|
|
@@ -66,6 +67,11 @@ class DashboardTaskValidator extends BaseValidator_1.default {
|
|
|
66
67
|
task.sharedWith = task.sharedWith.filter((id) => id.toString() !== userId.toString());
|
|
67
68
|
}
|
|
68
69
|
});
|
|
70
|
+
// Check assignedTo
|
|
71
|
+
if (task.assignedTo && !allUserIds[task.assignedTo.toString()]) {
|
|
72
|
+
errors.push(`User with ID: ${task.assignedTo.toString()} does not exist in assignedTo property of task with ID: ${task._id.toString()}.`);
|
|
73
|
+
updatedDoc.assignedTo = undefined;
|
|
74
|
+
}
|
|
69
75
|
return { updatedDoc, errors };
|
|
70
76
|
},
|
|
71
77
|
deletionFunction: async (docIdsToDelete) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aneuhold/be-ts-db-lib",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.85",
|
|
4
4
|
"description": "A backend database library meant to actually interact with various databases in personal projects",
|
|
5
5
|
"author": "Anton G Neuhold Jr <agneuhold@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"unlink:local": "cd lib && yarn unlink",
|
|
33
33
|
"unlink:coredb": "yarn unlink @aneuhold/core-ts-db-lib && yarn install --force",
|
|
34
34
|
"unlink:bets": "yarn unlink @aneuhold/be-ts-lib && yarn install --force",
|
|
35
|
-
"upgrade:all": "yarn
|
|
36
|
-
"upgrade:core": "yarn
|
|
35
|
+
"upgrade:all": "yarn up",
|
|
36
|
+
"upgrade:core": "yarn up '@aneuhold/*'",
|
|
37
37
|
"test": "jest && yarn validate:dry",
|
|
38
38
|
"validate": "ts-node ./src/scripts/validateSchema.ts",
|
|
39
39
|
"validate:dry": "ts-node ./src/scripts/validateSchemaDryRun.ts",
|
|
@@ -42,22 +42,22 @@
|
|
|
42
42
|
"lint": "eslint"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@aneuhold/be-ts-lib": "^1.0.
|
|
46
|
-
"@aneuhold/core-ts-db-lib": "^1.0.
|
|
47
|
-
"@aneuhold/core-ts-lib": "^1.1.
|
|
45
|
+
"@aneuhold/be-ts-lib": "^1.0.46",
|
|
46
|
+
"@aneuhold/core-ts-db-lib": "^1.0.97",
|
|
47
|
+
"@aneuhold/core-ts-lib": "^1.1.34",
|
|
48
48
|
"bson": "^6.2.0",
|
|
49
49
|
"mongodb": "^6.3.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@aneuhold/eslint-config": "^1.0.
|
|
52
|
+
"@aneuhold/eslint-config": "^1.0.22",
|
|
53
53
|
"@types/jest": "^29.5.12",
|
|
54
|
-
"@types/node": "^20.14.
|
|
54
|
+
"@types/node": "^20.14.11",
|
|
55
55
|
"@types/node-fetch": "^2.6.11",
|
|
56
56
|
"eslint": "^9.7.0",
|
|
57
57
|
"jest": "^29.7.0",
|
|
58
58
|
"prettier": "^3.3.3",
|
|
59
|
-
"ts-jest": "^29.
|
|
59
|
+
"ts-jest": "^29.2.3",
|
|
60
60
|
"ts-node": "^10.9.2",
|
|
61
|
-
"typescript": "^5.5.
|
|
61
|
+
"typescript": "^5.5.3"
|
|
62
62
|
}
|
|
63
63
|
}
|