@aneuhold/be-ts-db-lib 1.0.115 → 2.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/LICENSE +21 -0
- package/README.md +46 -10
- package/lib/index.d.ts +8 -8
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +10 -20
- package/lib/index.js.map +1 -0
- package/lib/index.ts +21 -0
- package/lib/repositories/BaseRepository.d.ts +84 -11
- package/lib/repositories/BaseRepository.d.ts.map +1 -1
- package/lib/repositories/BaseRepository.js +89 -21
- package/lib/repositories/BaseRepository.js.map +1 -0
- package/lib/repositories/BaseRepository.ts +339 -0
- package/lib/repositories/common/ApiKeyRepository.d.ts +2 -2
- package/lib/repositories/common/ApiKeyRepository.d.ts.map +1 -1
- package/lib/repositories/common/ApiKeyRepository.js +8 -13
- package/lib/repositories/common/ApiKeyRepository.js.map +1 -0
- package/lib/repositories/common/ApiKeyRepository.ts +55 -0
- package/lib/repositories/common/UserRepository.d.ts +1 -1
- package/lib/repositories/common/UserRepository.d.ts.map +1 -1
- package/lib/repositories/common/UserRepository.js +15 -20
- package/lib/repositories/common/UserRepository.js.map +1 -0
- package/lib/repositories/common/UserRepository.ts +65 -0
- package/lib/repositories/dashboard/DashboardBaseRepository.d.ts +2 -2
- package/lib/repositories/dashboard/DashboardBaseRepository.d.ts.map +1 -1
- package/lib/repositories/dashboard/DashboardBaseRepository.js +6 -11
- package/lib/repositories/dashboard/DashboardBaseRepository.js.map +1 -0
- package/lib/repositories/dashboard/DashboardBaseRepository.ts +31 -0
- 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 +7 -12
- package/lib/repositories/dashboard/DashboardNonogramKatanaItemRepository.js.map +1 -0
- package/lib/repositories/dashboard/DashboardNonogramKatanaItemRepository.ts +64 -0
- 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 +7 -12
- package/lib/repositories/dashboard/DashboardNonogramKatanaUpgradeRepository.js.map +1 -0
- package/lib/repositories/dashboard/DashboardNonogramKatanaUpgradeRepository.ts +66 -0
- package/lib/repositories/dashboard/DashboardTaskRepository.d.ts +17 -4
- package/lib/repositories/dashboard/DashboardTaskRepository.d.ts.map +1 -1
- package/lib/repositories/dashboard/DashboardTaskRepository.js +26 -18
- package/lib/repositories/dashboard/DashboardTaskRepository.js.map +1 -0
- package/lib/repositories/dashboard/DashboardTaskRepository.ts +166 -0
- package/lib/repositories/dashboard/DashboardUserConfigRepository.d.ts +29 -5
- package/lib/repositories/dashboard/DashboardUserConfigRepository.d.ts.map +1 -1
- package/lib/repositories/dashboard/DashboardUserConfigRepository.js +38 -19
- package/lib/repositories/dashboard/DashboardUserConfigRepository.js.map +1 -0
- package/lib/repositories/dashboard/DashboardUserConfigRepository.ts +254 -0
- package/lib/services/MigrationService.d.ts.map +1 -1
- package/lib/services/MigrationService.js +10 -15
- package/lib/services/MigrationService.js.map +1 -0
- package/lib/services/MigrationService.ts +52 -0
- package/lib/services/RepoSubscriptionService.d.ts.map +1 -1
- package/lib/services/RepoSubscriptionService.js +2 -4
- package/lib/services/RepoSubscriptionService.js.map +1 -0
- package/lib/services/RepoSubscriptionService.ts +63 -0
- package/lib/tests/globalTestVariables.d.ts +5 -0
- package/lib/tests/globalTestVariables.d.ts.map +1 -0
- package/lib/tests/globalTestVariables.js +5 -0
- package/lib/tests/globalTestVariables.js.map +1 -0
- package/lib/tests/globalTestVariables.ts +4 -0
- package/lib/tests/repositories/BaseRepository.spec.ts +61 -0
- package/lib/tests/repositories/common/UserRepository.spec.ts +113 -0
- package/lib/tests/repositories/dashboard/NonogramKatanaItemRepository.spec.ts +55 -0
- package/lib/tests/repositories/dashboard/NonogramKatanaUpgradeRepository.spec.ts +14 -0
- package/lib/tests/repositories/dashboard/TaskRepository.spec.ts +101 -0
- package/lib/tests/repositories/dashboard/UserConfigRepository.spec.ts +155 -0
- package/lib/tests/testsUtil.d.ts +20 -4
- package/lib/tests/testsUtil.d.ts.map +1 -1
- package/lib/tests/testsUtil.js +29 -20
- package/lib/tests/testsUtil.js.map +1 -0
- package/lib/tests/testsUtil.ts +68 -0
- package/lib/util/DbSchemaUpdater.d.ts.map +1 -1
- package/lib/util/DbSchemaUpdater.js +10 -15
- package/lib/util/DbSchemaUpdater.js.map +1 -0
- package/lib/util/DbSchemaUpdater.ts +16 -0
- package/lib/util/DocumentCleaner.d.ts.map +1 -1
- package/lib/util/DocumentCleaner.js +2 -4
- package/lib/util/DocumentCleaner.js.map +1 -0
- package/lib/util/DocumentCleaner.ts +31 -0
- package/lib/util/DocumentDb.d.ts +4 -1
- package/lib/util/DocumentDb.d.ts.map +1 -1
- package/lib/util/DocumentDb.js +11 -10
- package/lib/util/DocumentDb.js.map +1 -0
- package/lib/util/DocumentDb.ts +47 -0
- package/lib/validators/BaseValidator.d.ts +11 -0
- package/lib/validators/BaseValidator.d.ts.map +1 -1
- package/lib/validators/BaseValidator.js +26 -18
- package/lib/validators/BaseValidator.js.map +1 -0
- package/lib/validators/BaseValidator.ts +150 -0
- package/lib/validators/common/ApiKeyValidator.d.ts +1 -1
- package/lib/validators/common/ApiKeyValidator.d.ts.map +1 -1
- package/lib/validators/common/ApiKeyValidator.js +16 -21
- package/lib/validators/common/ApiKeyValidator.js.map +1 -0
- package/lib/validators/common/ApiKeyValidator.ts +67 -0
- package/lib/validators/common/UserValidator.d.ts +14 -1
- package/lib/validators/common/UserValidator.d.ts.map +1 -1
- package/lib/validators/common/UserValidator.js +29 -21
- package/lib/validators/common/UserValidator.js.map +1 -0
- package/lib/validators/common/UserValidator.ts +98 -0
- package/lib/validators/dashboard/NonogramKatanaItemValidator.d.ts +1 -1
- package/lib/validators/dashboard/NonogramKatanaItemValidator.d.ts.map +1 -1
- package/lib/validators/dashboard/NonogramKatanaItemValidator.js +16 -21
- package/lib/validators/dashboard/NonogramKatanaItemValidator.js.map +1 -0
- package/lib/validators/dashboard/NonogramKatanaItemValidator.ts +78 -0
- package/lib/validators/dashboard/NonogramKatanaUpgradeValidator.d.ts +1 -1
- package/lib/validators/dashboard/NonogramKatanaUpgradeValidator.d.ts.map +1 -1
- package/lib/validators/dashboard/NonogramKatanaUpgradeValidator.js +16 -21
- package/lib/validators/dashboard/NonogramKatanaUpgradeValidator.js.map +1 -0
- package/lib/validators/dashboard/NonogramKatanaUpgradeValidator.ts +78 -0
- package/lib/validators/dashboard/TaskValidator.d.ts +1 -1
- package/lib/validators/dashboard/TaskValidator.d.ts.map +1 -1
- package/lib/validators/dashboard/TaskValidator.js +15 -20
- package/lib/validators/dashboard/TaskValidator.js.map +1 -0
- package/lib/validators/dashboard/TaskValidator.ts +105 -0
- package/lib/validators/dashboard/UserConfigValidator.d.ts +1 -1
- package/lib/validators/dashboard/UserConfigValidator.d.ts.map +1 -1
- package/lib/validators/dashboard/UserConfigValidator.js +19 -24
- package/lib/validators/dashboard/UserConfigValidator.js.map +1 -0
- package/lib/validators/dashboard/UserConfigValidator.ts +112 -0
- package/package.json +44 -38
- package/lib/scripts/migrate.d.ts +0 -2
- package/lib/scripts/migrate.d.ts.map +0 -1
- package/lib/scripts/migrate.js +0 -7
- package/lib/scripts/migrateDry.d.ts +0 -2
- package/lib/scripts/migrateDry.d.ts.map +0 -1
- package/lib/scripts/migrateDry.js +0 -7
- package/lib/scripts/validateSchema.d.ts +0 -2
- package/lib/scripts/validateSchema.d.ts.map +0 -1
- package/lib/scripts/validateSchema.js +0 -9
- package/lib/scripts/validateSchemaDryRun.d.ts +0 -2
- package/lib/scripts/validateSchemaDryRun.d.ts.map +0 -1
- package/lib/scripts/validateSchemaDryRun.js +0 -9
- package/lib/tests/repositories/BaseRepository.spec.d.ts +0 -2
- package/lib/tests/repositories/BaseRepository.spec.d.ts.map +0 -1
- package/lib/tests/repositories/BaseRepository.spec.js +0 -52
- package/lib/tests/repositories/common/UserRepository.spec.d.ts +0 -2
- package/lib/tests/repositories/common/UserRepository.spec.d.ts.map +0 -1
- package/lib/tests/repositories/common/UserRepository.spec.js +0 -108
- package/lib/tests/repositories/dashboard/NonogramKatanaItemRepository.spec.d.ts +0 -2
- package/lib/tests/repositories/dashboard/NonogramKatanaItemRepository.spec.d.ts.map +0 -1
- package/lib/tests/repositories/dashboard/NonogramKatanaItemRepository.spec.js +0 -39
- package/lib/tests/repositories/dashboard/NonogramKatanaUpgradeRepository.spec.d.ts +0 -2
- package/lib/tests/repositories/dashboard/NonogramKatanaUpgradeRepository.spec.d.ts.map +0 -1
- package/lib/tests/repositories/dashboard/NonogramKatanaUpgradeRepository.spec.js +0 -16
- package/lib/tests/repositories/dashboard/TaskRepository.spec.d.ts +0 -2
- package/lib/tests/repositories/dashboard/TaskRepository.spec.d.ts.map +0 -1
- package/lib/tests/repositories/dashboard/TaskRepository.spec.js +0 -84
- package/lib/tests/repositories/dashboard/UserConfigRepository.spec.d.ts +0 -2
- package/lib/tests/repositories/dashboard/UserConfigRepository.spec.d.ts.map +0 -1
- package/lib/tests/repositories/dashboard/UserConfigRepository.spec.js +0 -115
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DashboardUserConfig,
|
|
3
|
+
validateDashboardUserConfig
|
|
4
|
+
} from '@aneuhold/core-ts-db-lib';
|
|
5
|
+
import { ErrorUtils, Logger } from '@aneuhold/core-ts-lib';
|
|
6
|
+
import { ObjectId } from 'bson';
|
|
7
|
+
import UserRepository from '../../repositories/common/UserRepository.js';
|
|
8
|
+
import DashboardUserConfigRepository from '../../repositories/dashboard/DashboardUserConfigRepository.js';
|
|
9
|
+
import IValidator from '../BaseValidator.js';
|
|
10
|
+
|
|
11
|
+
export default class DashboardUserConfigValidator extends IValidator<DashboardUserConfig> {
|
|
12
|
+
async validateNewObject(newUserConfig: DashboardUserConfig): Promise<void> {
|
|
13
|
+
// Check if the config already exists for the user
|
|
14
|
+
const configRepo = DashboardUserConfigRepository.getRepo();
|
|
15
|
+
const existingConfig = await configRepo.get({
|
|
16
|
+
userId: newUserConfig.userId
|
|
17
|
+
});
|
|
18
|
+
if (existingConfig) {
|
|
19
|
+
ErrorUtils.throwError(
|
|
20
|
+
`Config already exists for user: ${newUserConfig.userId.toString()}`,
|
|
21
|
+
newUserConfig
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
const userRepo = UserRepository.getRepo();
|
|
25
|
+
const user = await userRepo.get({ _id: newUserConfig.userId });
|
|
26
|
+
if (!user) {
|
|
27
|
+
ErrorUtils.throwError(
|
|
28
|
+
`User does not exist: ${newUserConfig.userId.toString()}`,
|
|
29
|
+
newUserConfig
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
if (newUserConfig.collaborators.length > 0) {
|
|
33
|
+
const collaborators = await userRepo.getList(newUserConfig.collaborators);
|
|
34
|
+
if (collaborators.length !== newUserConfig.collaborators.length) {
|
|
35
|
+
ErrorUtils.throwError(
|
|
36
|
+
`Some collaborators not found. Expected ${newUserConfig.collaborators.length}, found ${collaborators.length}`,
|
|
37
|
+
newUserConfig
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async validateUpdateObject(
|
|
44
|
+
updatedUserConfig: Partial<DashboardUserConfig>
|
|
45
|
+
): Promise<void> {
|
|
46
|
+
// Check if an id is defined
|
|
47
|
+
if (!updatedUserConfig._id) {
|
|
48
|
+
ErrorUtils.throwError(
|
|
49
|
+
`No _id defined for DashboardUserConfig update.`,
|
|
50
|
+
updatedUserConfig
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
if (
|
|
54
|
+
updatedUserConfig.collaborators &&
|
|
55
|
+
updatedUserConfig.collaborators.length > 0
|
|
56
|
+
) {
|
|
57
|
+
const userRepo = UserRepository.getRepo();
|
|
58
|
+
const collaborators = await userRepo.getList(
|
|
59
|
+
updatedUserConfig.collaborators
|
|
60
|
+
);
|
|
61
|
+
if (collaborators.length !== updatedUserConfig.collaborators.length) {
|
|
62
|
+
ErrorUtils.throwError(
|
|
63
|
+
`Some collaborators not found. Expected ${updatedUserConfig.collaborators.length}, found ${collaborators.length}`,
|
|
64
|
+
updatedUserConfig
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
async validateRepositoryInDb(dryRun: boolean): Promise<void> {
|
|
71
|
+
const userConfigRepo = DashboardUserConfigRepository.getRepo();
|
|
72
|
+
const allUserConfigs = await userConfigRepo.getAll();
|
|
73
|
+
const allUserIds = await UserRepository.getRepo().getAllIdsAsHash();
|
|
74
|
+
|
|
75
|
+
await this.runStandardValidationForRepository({
|
|
76
|
+
dryRun,
|
|
77
|
+
docName: 'Dashboard User Config',
|
|
78
|
+
allDocs: allUserConfigs,
|
|
79
|
+
shouldDelete: (userConfig: DashboardUserConfig) => {
|
|
80
|
+
if (!allUserIds[userConfig.userId.toString()]) {
|
|
81
|
+
Logger.error(
|
|
82
|
+
`Dashboard User Config with ID: ${userConfig._id.toString()} has no valid associated user.`
|
|
83
|
+
);
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
return false;
|
|
87
|
+
},
|
|
88
|
+
documentValidator: (userConfig) => {
|
|
89
|
+
const { updatedDoc, errors } = validateDashboardUserConfig(userConfig);
|
|
90
|
+
const collaboratorIds = [...userConfig.collaborators];
|
|
91
|
+
collaboratorIds.forEach((userId) => {
|
|
92
|
+
if (!allUserIds[userId.toString()]) {
|
|
93
|
+
errors.push(
|
|
94
|
+
`User with ID: ${userId.toString()} does not exist in collaborators property of Dashboard User Config with ID: ${userConfig._id.toString()}.`
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
updatedDoc.collaborators = updatedDoc.collaborators.filter(
|
|
98
|
+
(id) => id.toString() !== userId.toString()
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
return { updatedDoc, errors };
|
|
103
|
+
},
|
|
104
|
+
deletionFunction: async (docIdsToDelete: ObjectId[]) => {
|
|
105
|
+
await userConfigRepo.deleteList(docIdsToDelete);
|
|
106
|
+
},
|
|
107
|
+
updateFunction: async (docsToUpdate: DashboardUserConfig[]) => {
|
|
108
|
+
await userConfigRepo.updateMany(docsToUpdate);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,37 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aneuhold/be-ts-db-lib",
|
|
3
|
-
"
|
|
4
|
-
"description": "A backend database library meant to actually interact with various databases in personal projects",
|
|
5
|
-
"author": "Anton G Neuhold Jr <agneuhold@gmail.com>",
|
|
3
|
+
"author": "Anton G. Neuhold Jr.",
|
|
6
4
|
"license": "MIT",
|
|
5
|
+
"version": "2.0.0",
|
|
6
|
+
"description": "A backend database library meant to actually interact with various databases in personal projects",
|
|
7
|
+
"packageManager": "yarn@4.5.1",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "rimraf lib && tsc --project tsconfig.build.json && tsx ./scripts/copyTsFiles.ts",
|
|
11
|
+
"lint": "eslint",
|
|
12
|
+
"test": "vitest run && yarn validate:dry",
|
|
13
|
+
"validate": "tsx ./scripts/validateSchema.ts",
|
|
14
|
+
"validate:dry": "tsx ./scripts/validateSchemaDryRun.ts",
|
|
15
|
+
"jsr:validate": "tb pkg validateJsr",
|
|
16
|
+
"checkAll": "yarn build && yarn lint && yarn test && yarn jsr:validate",
|
|
17
|
+
"jsr:publish": "tb pkg publishJsr",
|
|
18
|
+
"upgrade:core": "yarn up '@aneuhold/*'",
|
|
19
|
+
"upgrade:all": "yarn up",
|
|
20
|
+
"migrate": "tsx ./scripts/migrate.ts",
|
|
21
|
+
"migrate:dry": "tsx ./scripts/migrateDry.ts"
|
|
22
|
+
},
|
|
7
23
|
"main": "lib/index.js",
|
|
24
|
+
"module": "lib/index.js",
|
|
8
25
|
"types": "lib/index.d.ts",
|
|
9
|
-
"
|
|
26
|
+
"files": [
|
|
27
|
+
"lib/**/*"
|
|
28
|
+
],
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"types": "./lib/index.d.ts",
|
|
32
|
+
"import": "./lib/index.js"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
10
35
|
"repository": {
|
|
11
36
|
"type": "git",
|
|
12
37
|
"url": "git+https://github.com/aneuhold/be-ts-db-lib.git"
|
|
@@ -15,49 +40,30 @@
|
|
|
15
40
|
"url": "https://github.com/aneuhold/be-ts-db-lib/issues"
|
|
16
41
|
},
|
|
17
42
|
"homepage": "https://github.com/aneuhold/be-ts-db-lib#readme",
|
|
18
|
-
"files": [
|
|
19
|
-
"lib/**/*"
|
|
20
|
-
],
|
|
21
43
|
"keywords": [
|
|
22
|
-
"
|
|
23
|
-
"Node.js"
|
|
44
|
+
"Database",
|
|
45
|
+
"Node.js",
|
|
46
|
+
"TypeScript",
|
|
47
|
+
"MongoDB"
|
|
24
48
|
],
|
|
25
|
-
"scripts": {
|
|
26
|
-
"pushpub": "yarn build && npm version patch && git push",
|
|
27
|
-
"build": "tsc",
|
|
28
|
-
"watch": "tsc -w",
|
|
29
|
-
"link:local": "cd lib && yarn link",
|
|
30
|
-
"link:coredb": "yarn link @aneuhold/core-ts-db-lib",
|
|
31
|
-
"link:bets": "yarn link @aneuhold/be-ts-lib",
|
|
32
|
-
"unlink:local": "cd lib && yarn unlink",
|
|
33
|
-
"unlink:coredb": "yarn unlink @aneuhold/core-ts-db-lib && yarn install --force",
|
|
34
|
-
"unlink:bets": "yarn unlink @aneuhold/be-ts-lib && yarn install --force",
|
|
35
|
-
"upgrade:all": "yarn up",
|
|
36
|
-
"upgrade:core": "yarn up '@aneuhold/*'",
|
|
37
|
-
"test": "jest && yarn validate:dry",
|
|
38
|
-
"validate": "ts-node ./src/scripts/validateSchema.ts",
|
|
39
|
-
"validate:dry": "ts-node ./src/scripts/validateSchemaDryRun.ts",
|
|
40
|
-
"migrate": "ts-node ./src/scripts/migrate.ts",
|
|
41
|
-
"migrate:dry": "ts-node ./src/scripts/migrateDry.ts",
|
|
42
|
-
"lint": "eslint"
|
|
43
|
-
},
|
|
44
49
|
"dependencies": {
|
|
45
|
-
"@aneuhold/be-ts-lib": "^
|
|
46
|
-
"@aneuhold/core-ts-db-lib": "^
|
|
47
|
-
"@aneuhold/core-ts-lib": "^
|
|
50
|
+
"@aneuhold/be-ts-lib": "^2.0.0",
|
|
51
|
+
"@aneuhold/core-ts-db-lib": "^2.0.4",
|
|
52
|
+
"@aneuhold/core-ts-lib": "^2.0.6",
|
|
48
53
|
"bson": "^6.2.0",
|
|
49
54
|
"mongodb": "^6.3.0"
|
|
50
55
|
},
|
|
51
56
|
"devDependencies": {
|
|
52
|
-
"@aneuhold/eslint-config": "^1.0.
|
|
53
|
-
"@
|
|
54
|
-
"@types/node": "^20.
|
|
57
|
+
"@aneuhold/eslint-config": "^1.0.40",
|
|
58
|
+
"@aneuhold/main-scripts": "^2.0.6",
|
|
59
|
+
"@types/node": "^20.17.1",
|
|
55
60
|
"@types/node-fetch": "^2.6.11",
|
|
56
61
|
"eslint": "^9.13.0",
|
|
57
|
-
"
|
|
62
|
+
"jsr": "^0.13.2",
|
|
58
63
|
"prettier": "^3.3.3",
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"typescript": "^5.6.
|
|
64
|
+
"rimraf": "^6.0.1",
|
|
65
|
+
"tsx": "^4.19.1",
|
|
66
|
+
"typescript": "^5.6.3",
|
|
67
|
+
"vitest": "^2.1.3"
|
|
62
68
|
}
|
|
63
69
|
}
|
package/lib/scripts/migrate.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../../src/scripts/migrate.ts"],"names":[],"mappings":""}
|
package/lib/scripts/migrate.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const MigrationService_1 = __importDefault(require("../services/MigrationService"));
|
|
7
|
-
void MigrationService_1.default.migrateDb().then(() => process.exit(0));
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"migrateDry.d.ts","sourceRoot":"","sources":["../../src/scripts/migrateDry.ts"],"names":[],"mappings":""}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const MigrationService_1 = __importDefault(require("../services/MigrationService"));
|
|
7
|
-
void MigrationService_1.default.migrateDb(true).then(() => process.exit(0));
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validateSchema.d.ts","sourceRoot":"","sources":["../../src/scripts/validateSchema.ts"],"names":[],"mappings":""}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const DbSchemaUpdater_1 = __importDefault(require("../util/DbSchemaUpdater"));
|
|
7
|
-
void DbSchemaUpdater_1.default.updateSchemaForAllRepos().then(() => {
|
|
8
|
-
process.exit(0);
|
|
9
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validateSchemaDryRun.d.ts","sourceRoot":"","sources":["../../src/scripts/validateSchemaDryRun.ts"],"names":[],"mappings":""}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const DbSchemaUpdater_1 = __importDefault(require("../util/DbSchemaUpdater"));
|
|
7
|
-
void DbSchemaUpdater_1.default.updateSchemaForAllRepos(true).then(() => {
|
|
8
|
-
process.exit(0);
|
|
9
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BaseRepository.spec.d.ts","sourceRoot":"","sources":["../../../src/tests/repositories/BaseRepository.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const crypto_1 = __importDefault(require("crypto"));
|
|
7
|
-
const core_ts_db_lib_1 = require("@aneuhold/core-ts-db-lib");
|
|
8
|
-
const UserRepository_1 = __importDefault(require("../../repositories/common/UserRepository"));
|
|
9
|
-
const testsUtil_1 = require("../testsUtil");
|
|
10
|
-
const DocumentDb_1 = __importDefault(require("../../util/DocumentDb"));
|
|
11
|
-
const DashboardUserConfigRepository_1 = __importDefault(require("../../repositories/dashboard/DashboardUserConfigRepository"));
|
|
12
|
-
const DashboardTaskRepository_1 = __importDefault(require("../../repositories/dashboard/DashboardTaskRepository"));
|
|
13
|
-
it('can create a new document and delete it', async () => {
|
|
14
|
-
const userRepository = UserRepository_1.default.getRepo();
|
|
15
|
-
const newUser = new core_ts_db_lib_1.User((0, testsUtil_1.getTestUserName)());
|
|
16
|
-
const createResult = await userRepository.insertNew(newUser);
|
|
17
|
-
expect(createResult).toBeTruthy();
|
|
18
|
-
await (0, testsUtil_1.cleanupDoc)(userRepository, newUser);
|
|
19
|
-
}, 10000);
|
|
20
|
-
// -- Manual Database Operations Section -- //
|
|
21
|
-
it.skip('can add a new test user', async () => {
|
|
22
|
-
const userRepository = UserRepository_1.default.getRepo();
|
|
23
|
-
const newUser = new core_ts_db_lib_1.User('someUser');
|
|
24
|
-
newUser.auth.password = crypto_1.default.randomUUID();
|
|
25
|
-
const createResult = await userRepository.insertNew(newUser);
|
|
26
|
-
expect(createResult).toBeTruthy();
|
|
27
|
-
});
|
|
28
|
-
it.skip('can create a dashboard config for a user', async () => {
|
|
29
|
-
const userRepo = UserRepository_1.default.getRepo();
|
|
30
|
-
const user = await userRepo.get({ userName: 'usernameHere' });
|
|
31
|
-
expect(user).toBeTruthy();
|
|
32
|
-
if (user) {
|
|
33
|
-
const configRepo = DashboardUserConfigRepository_1.default.getRepo();
|
|
34
|
-
const newConfig = new core_ts_db_lib_1.DashboardUserConfig(user._id);
|
|
35
|
-
newConfig.enableDevMode = true;
|
|
36
|
-
await configRepo.insertNew(newConfig);
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
it.skip(`can create a new task for a user`, async () => {
|
|
40
|
-
const userRepo = UserRepository_1.default.getRepo();
|
|
41
|
-
const user = await userRepo.get({ userName: 'usernameHere' });
|
|
42
|
-
expect(user).toBeTruthy();
|
|
43
|
-
if (user) {
|
|
44
|
-
const taskRepo = DashboardTaskRepository_1.default.getRepo();
|
|
45
|
-
const newTask = new core_ts_db_lib_1.DashboardTask(user._id);
|
|
46
|
-
newTask.title = 'Test Task';
|
|
47
|
-
await taskRepo.insertNew(newTask);
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
afterAll(async () => {
|
|
51
|
-
return DocumentDb_1.default.closeDbConnection();
|
|
52
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UserRepository.spec.d.ts","sourceRoot":"","sources":["../../../../src/tests/repositories/common/UserRepository.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const core_ts_db_lib_1 = require("@aneuhold/core-ts-db-lib");
|
|
7
|
-
const UserRepository_1 = __importDefault(require("../../../repositories/common/UserRepository"));
|
|
8
|
-
const testsUtil_1 = require("../../testsUtil");
|
|
9
|
-
const ApiKeyRepository_1 = __importDefault(require("../../../repositories/common/ApiKeyRepository"));
|
|
10
|
-
const DocumentDb_1 = __importDefault(require("../../../util/DocumentDb"));
|
|
11
|
-
const userRepo = UserRepository_1.default.getRepo();
|
|
12
|
-
describe('Create operations', () => {
|
|
13
|
-
it('can create a new user', async () => {
|
|
14
|
-
const newUser = new core_ts_db_lib_1.User((0, testsUtil_1.getTestUserName)());
|
|
15
|
-
const insertResult = await userRepo.insertNew(newUser);
|
|
16
|
-
expect(insertResult).toBeTruthy();
|
|
17
|
-
await (0, testsUtil_1.cleanupDoc)(userRepo, newUser);
|
|
18
|
-
});
|
|
19
|
-
it('can create a new user and the new user gets an API key', async () => {
|
|
20
|
-
const newUser = new core_ts_db_lib_1.User((0, testsUtil_1.getTestUserName)());
|
|
21
|
-
const insertResult = await userRepo.insertNew(newUser);
|
|
22
|
-
expect(insertResult).toBeTruthy();
|
|
23
|
-
const apiKey = await ApiKeyRepository_1.default.getRepo().get({
|
|
24
|
-
userId: newUser._id
|
|
25
|
-
});
|
|
26
|
-
expect(apiKey).toBeTruthy();
|
|
27
|
-
await (0, testsUtil_1.cleanupDoc)(userRepo, newUser);
|
|
28
|
-
const apiKeyThatShouldNotExist = await ApiKeyRepository_1.default.getRepo().get({
|
|
29
|
-
userId: newUser._id
|
|
30
|
-
});
|
|
31
|
-
expect(apiKeyThatShouldNotExist).toBeFalsy();
|
|
32
|
-
});
|
|
33
|
-
it('throws if the username is a duplicate username', async () => {
|
|
34
|
-
const duplicateUserName = (0, testsUtil_1.getTestUserName)();
|
|
35
|
-
const newUser1 = new core_ts_db_lib_1.User(duplicateUserName);
|
|
36
|
-
const newUser2 = new core_ts_db_lib_1.User(duplicateUserName);
|
|
37
|
-
const insertResult = await userRepo.insertNew(newUser1);
|
|
38
|
-
expect(insertResult).toBeTruthy();
|
|
39
|
-
await (0, testsUtil_1.expectToThrow)(async () => {
|
|
40
|
-
await userRepo.insertNew(newUser2);
|
|
41
|
-
});
|
|
42
|
-
await (0, testsUtil_1.cleanupDoc)(userRepo, newUser1);
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
describe('Update operations', () => {
|
|
46
|
-
it('succeeds in updating the username if the username doesnt already exist', async () => {
|
|
47
|
-
const userName1 = (0, testsUtil_1.getTestUserName)();
|
|
48
|
-
const userName2 = (0, testsUtil_1.getTestUserName)();
|
|
49
|
-
const newUser = new core_ts_db_lib_1.User(userName1);
|
|
50
|
-
// Insert the user
|
|
51
|
-
const insertResult = await userRepo.insertNew(newUser);
|
|
52
|
-
expect(insertResult).toBeTruthy();
|
|
53
|
-
// Try to update the user
|
|
54
|
-
newUser.userName = userName2;
|
|
55
|
-
const updateResult = await userRepo.update(newUser);
|
|
56
|
-
expect(updateResult.acknowledged).toBeTruthy();
|
|
57
|
-
await (0, testsUtil_1.cleanupDoc)(userRepo, newUser);
|
|
58
|
-
});
|
|
59
|
-
it('throws if no id is defined', async () => {
|
|
60
|
-
const newUser = new core_ts_db_lib_1.User((0, testsUtil_1.getTestUserName)());
|
|
61
|
-
delete newUser._id;
|
|
62
|
-
await (0, testsUtil_1.expectToThrow)(async () => {
|
|
63
|
-
await userRepo.update(newUser);
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
it('throws if the username is updated and already exists', async () => {
|
|
67
|
-
const userName1 = (0, testsUtil_1.getTestUserName)();
|
|
68
|
-
const userName2 = (0, testsUtil_1.getTestUserName)();
|
|
69
|
-
const newUser = new core_ts_db_lib_1.User(userName1);
|
|
70
|
-
const userWithOtherUserName = new core_ts_db_lib_1.User(userName2);
|
|
71
|
-
// Insert the users
|
|
72
|
-
const insertResult1 = await userRepo.insertNew(newUser);
|
|
73
|
-
expect(insertResult1).toBeTruthy();
|
|
74
|
-
const insertResult2 = await userRepo.insertNew(userWithOtherUserName);
|
|
75
|
-
expect(insertResult2).toBeTruthy();
|
|
76
|
-
// Try to update the first user
|
|
77
|
-
newUser.userName = userName2;
|
|
78
|
-
await (0, testsUtil_1.expectToThrow)(async () => {
|
|
79
|
-
await userRepo.update(newUser);
|
|
80
|
-
});
|
|
81
|
-
await Promise.all([
|
|
82
|
-
(0, testsUtil_1.cleanupDoc)(userRepo, newUser),
|
|
83
|
-
(0, testsUtil_1.cleanupDoc)(userRepo, userWithOtherUserName)
|
|
84
|
-
]);
|
|
85
|
-
});
|
|
86
|
-
it('throws if the user doesnt exist', async () => {
|
|
87
|
-
const newUser = new core_ts_db_lib_1.User((0, testsUtil_1.getTestUserName)());
|
|
88
|
-
// Try to update the user
|
|
89
|
-
await (0, testsUtil_1.expectToThrow)(async () => {
|
|
90
|
-
await userRepo.update(newUser);
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
/**
|
|
95
|
-
* Deletes all users!
|
|
96
|
-
*
|
|
97
|
-
* Make sure that the local DB you are working on doesn't have important
|
|
98
|
-
* state before turning skip off on this one.
|
|
99
|
-
*
|
|
100
|
-
* To just do a cleanup, put `only` after `it`. So `it.only('can delete all users'`
|
|
101
|
-
*/
|
|
102
|
-
it.skip('can delete all users', async () => {
|
|
103
|
-
const result = await userRepo.deleteAll();
|
|
104
|
-
expect(result.acknowledged).toBeTruthy();
|
|
105
|
-
});
|
|
106
|
-
afterAll(async () => {
|
|
107
|
-
await DocumentDb_1.default.closeDbConnection();
|
|
108
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NonogramKatanaItemRepository.spec.d.ts","sourceRoot":"","sources":["../../../../src/tests/repositories/dashboard/NonogramKatanaItemRepository.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const core_ts_db_lib_1 = require("@aneuhold/core-ts-db-lib");
|
|
7
|
-
const crypto_1 = __importDefault(require("crypto"));
|
|
8
|
-
const UserRepository_1 = __importDefault(require("../../../repositories/common/UserRepository"));
|
|
9
|
-
const DashboardNonogramKatanaItemRepository_1 = __importDefault(require("../../../repositories/dashboard/DashboardNonogramKatanaItemRepository"));
|
|
10
|
-
const testsUtil_1 = require("../../testsUtil");
|
|
11
|
-
const userRepo = UserRepository_1.default.getRepo();
|
|
12
|
-
const itemRepo = DashboardNonogramKatanaItemRepository_1.default.getRepo();
|
|
13
|
-
describe('Create operations', () => {
|
|
14
|
-
it('can create a new nonogram katana item', async () => {
|
|
15
|
-
const newUser = await createNewTestUser();
|
|
16
|
-
const newItem = new core_ts_db_lib_1.NonogramKatanaItem(newUser._id, core_ts_db_lib_1.NonogramKatanaItemName.Anchor);
|
|
17
|
-
const insertResult = await itemRepo.insertNew(newItem);
|
|
18
|
-
expect(insertResult).toBeTruthy();
|
|
19
|
-
const newItemFromDb = await itemRepo.get({ _id: newItem._id });
|
|
20
|
-
expect(newItemFromDb).toBeTruthy();
|
|
21
|
-
await (0, testsUtil_1.cleanupDoc)(userRepo, newUser);
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
/**
|
|
25
|
-
* Deletes all Nonogram Katana Items!
|
|
26
|
-
*
|
|
27
|
-
* To just do a cleanup, put `only` after `it`. So `it.only('can delete all items'`
|
|
28
|
-
*/
|
|
29
|
-
it.skip('can delete all items', async () => {
|
|
30
|
-
const result = await itemRepo.deleteAll();
|
|
31
|
-
expect(result.acknowledged).toBeTruthy();
|
|
32
|
-
});
|
|
33
|
-
async function createNewTestUser() {
|
|
34
|
-
const newUser = new core_ts_db_lib_1.User((0, testsUtil_1.getTestUserName)(`${crypto_1.default.randomUUID()}nonogramKatanaItemTest`));
|
|
35
|
-
newUser.projectAccess.dashboard = true;
|
|
36
|
-
const insertResult = await userRepo.insertNew(newUser);
|
|
37
|
-
expect(insertResult).toBeTruthy();
|
|
38
|
-
return newUser;
|
|
39
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NonogramKatanaUpgradeRepository.spec.d.ts","sourceRoot":"","sources":["../../../../src/tests/repositories/dashboard/NonogramKatanaUpgradeRepository.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const DashboardNonogramKatanaUpgradeRepository_1 = __importDefault(require("../../../repositories/dashboard/DashboardNonogramKatanaUpgradeRepository"));
|
|
7
|
-
const upgradeRepo = DashboardNonogramKatanaUpgradeRepository_1.default.getRepo();
|
|
8
|
-
/**
|
|
9
|
-
* Deletes all Nonogram Katana Upgrades!
|
|
10
|
-
*
|
|
11
|
-
* To just do a cleanup, put `only` after `it`. So `it.only('can delete all upgrades'`
|
|
12
|
-
*/
|
|
13
|
-
it.skip('can delete all upgrades', async () => {
|
|
14
|
-
const result = await upgradeRepo.deleteAll();
|
|
15
|
-
expect(result.acknowledged).toBeTruthy();
|
|
16
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TaskRepository.spec.d.ts","sourceRoot":"","sources":["../../../../src/tests/repositories/dashboard/TaskRepository.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const crypto_1 = __importDefault(require("crypto"));
|
|
7
|
-
const core_ts_db_lib_1 = require("@aneuhold/core-ts-db-lib");
|
|
8
|
-
const UserRepository_1 = __importDefault(require("../../../repositories/common/UserRepository"));
|
|
9
|
-
const testsUtil_1 = require("../../testsUtil");
|
|
10
|
-
const DocumentDb_1 = __importDefault(require("../../../util/DocumentDb"));
|
|
11
|
-
const DashboardTaskRepository_1 = __importDefault(require("../../../repositories/dashboard/DashboardTaskRepository"));
|
|
12
|
-
const DashboardUserConfigRepository_1 = __importDefault(require("../../../repositories/dashboard/DashboardUserConfigRepository"));
|
|
13
|
-
const userRepo = UserRepository_1.default.getRepo();
|
|
14
|
-
const taskRepo = DashboardTaskRepository_1.default.getRepo();
|
|
15
|
-
describe('Create operations', () => {
|
|
16
|
-
it('can create a new task', async () => {
|
|
17
|
-
const newUser = await createNewTestUser();
|
|
18
|
-
const newTask = new core_ts_db_lib_1.DashboardTask(newUser._id);
|
|
19
|
-
const insertResult = await taskRepo.insertNew(newTask);
|
|
20
|
-
expect(insertResult).toBeTruthy();
|
|
21
|
-
const insertedTask = await taskRepo.get({ _id: newTask._id });
|
|
22
|
-
expect(insertedTask).toBeTruthy();
|
|
23
|
-
expect(typeof insertedTask?.createdDate).toBe('object');
|
|
24
|
-
if (!insertedTask) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
await (0, testsUtil_1.cleanupDoc)(userRepo, newUser);
|
|
28
|
-
// Task should be deleted
|
|
29
|
-
const deletedTask = await taskRepo.get({ _id: newTask._id });
|
|
30
|
-
expect(deletedTask).toBeFalsy();
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
describe('Get operations', () => {
|
|
34
|
-
it('can get a set of tasks for a user, without any tasks from other users', async () => {
|
|
35
|
-
const newUser = await createNewTestUser();
|
|
36
|
-
const newTask = new core_ts_db_lib_1.DashboardTask(newUser._id);
|
|
37
|
-
const insertResult = await taskRepo.insertNew(newTask);
|
|
38
|
-
expect(insertResult).toBeTruthy();
|
|
39
|
-
const otherUser = await createNewTestUser();
|
|
40
|
-
const otherUserTask = new core_ts_db_lib_1.DashboardTask(otherUser._id);
|
|
41
|
-
const insertResult2 = await taskRepo.insertNew(otherUserTask);
|
|
42
|
-
expect(insertResult2).toBeTruthy();
|
|
43
|
-
const tasks = await taskRepo.getAllForUser(newUser._id);
|
|
44
|
-
expect(tasks.length).toBe(1);
|
|
45
|
-
expect(tasks[0]._id).toEqual(newTask._id);
|
|
46
|
-
await (0, testsUtil_1.cleanupDoc)(userRepo, newUser);
|
|
47
|
-
await (0, testsUtil_1.cleanupDoc)(userRepo, otherUser);
|
|
48
|
-
});
|
|
49
|
-
it('can get a set of tasks for a user, including tasks shared with that user', async () => {
|
|
50
|
-
const configRepo = DashboardUserConfigRepository_1.default.getRepo();
|
|
51
|
-
const newUser = await createNewTestUser();
|
|
52
|
-
const newTask = new core_ts_db_lib_1.DashboardTask(newUser._id);
|
|
53
|
-
const insertResult = await taskRepo.insertNew(newTask);
|
|
54
|
-
expect(insertResult).toBeTruthy();
|
|
55
|
-
const otherUser = await createNewTestUser();
|
|
56
|
-
const otherUserTask = new core_ts_db_lib_1.DashboardTask(otherUser._id);
|
|
57
|
-
// Add other user as collaborator
|
|
58
|
-
const otherUserConfig = await configRepo.get({ userId: otherUser._id });
|
|
59
|
-
expect(otherUserConfig).toBeTruthy();
|
|
60
|
-
if (!otherUserConfig) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
otherUserConfig.collaborators.push(newUser._id);
|
|
64
|
-
await configRepo.update(otherUserConfig);
|
|
65
|
-
otherUserTask.sharedWith.push(newUser._id);
|
|
66
|
-
const insertResult2 = await taskRepo.insertNew(otherUserTask);
|
|
67
|
-
expect(insertResult2).toBeTruthy();
|
|
68
|
-
const tasks = await taskRepo.getAllForUser(newUser._id);
|
|
69
|
-
expect(tasks.length).toBe(2);
|
|
70
|
-
expect(tasks[0]._id).toEqual(newTask._id);
|
|
71
|
-
expect(tasks[1]._id).toEqual(otherUserTask._id);
|
|
72
|
-
await (0, testsUtil_1.cleanupDoc)(userRepo, newUser);
|
|
73
|
-
await (0, testsUtil_1.cleanupDoc)(userRepo, otherUser);
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
afterAll(async () => {
|
|
77
|
-
return DocumentDb_1.default.closeDbConnection();
|
|
78
|
-
});
|
|
79
|
-
async function createNewTestUser() {
|
|
80
|
-
const newUser = new core_ts_db_lib_1.User((0, testsUtil_1.getTestUserName)(`${crypto_1.default.randomUUID()}dashboardTaskTest`));
|
|
81
|
-
const insertResult = await userRepo.insertNew(newUser);
|
|
82
|
-
expect(insertResult).toBeTruthy();
|
|
83
|
-
return newUser;
|
|
84
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UserConfigRepository.spec.d.ts","sourceRoot":"","sources":["../../../../src/tests/repositories/dashboard/UserConfigRepository.spec.ts"],"names":[],"mappings":""}
|