@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
|
@@ -1,115 +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 userRepo = UserRepository_1.default.getRepo();
|
|
13
|
-
const configRepo = DashboardUserConfigRepository_1.default.getRepo();
|
|
14
|
-
describe('Create operations', () => {
|
|
15
|
-
it('can create a new user config', async () => {
|
|
16
|
-
// User configs are created automatically when a new user is created
|
|
17
|
-
const newUser = await createNewTestUser();
|
|
18
|
-
const newConfig = await configRepo.get({ userId: newUser._id });
|
|
19
|
-
expect(newConfig).toBeTruthy();
|
|
20
|
-
if (!newConfig) {
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
await (0, testsUtil_1.cleanupDoc)(userRepo, newUser);
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
describe('Update operations', () => {
|
|
27
|
-
it('can update an existing user config', async () => {
|
|
28
|
-
const newUser = await createNewTestUser();
|
|
29
|
-
const newConfig = await configRepo.get({ userId: newUser._id });
|
|
30
|
-
expect(newConfig).toBeTruthy();
|
|
31
|
-
if (!newConfig) {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
newConfig.enableDevMode = true;
|
|
35
|
-
await configRepo.update(newConfig);
|
|
36
|
-
const updatedConfig = await configRepo.get({ _id: newConfig._id });
|
|
37
|
-
expect(updatedConfig?.enableDevMode).toBe(true);
|
|
38
|
-
await (0, testsUtil_1.cleanupDoc)(userRepo, newUser);
|
|
39
|
-
});
|
|
40
|
-
it('can add collaborators to an existing user config', async () => {
|
|
41
|
-
const newUser = await createNewTestUser();
|
|
42
|
-
const newConfig = await configRepo.get({ userId: newUser._id });
|
|
43
|
-
expect(newConfig).toBeTruthy();
|
|
44
|
-
if (!newConfig) {
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
const newCollaborator = await createNewTestUser();
|
|
48
|
-
newConfig.collaborators.push(newCollaborator._id);
|
|
49
|
-
await configRepo.update(newConfig);
|
|
50
|
-
let updatedConfig = await configRepo.get({ _id: newConfig._id });
|
|
51
|
-
expect(updatedConfig?.collaborators).toContainEqual(newCollaborator._id);
|
|
52
|
-
await (0, testsUtil_1.cleanupDoc)(userRepo, newCollaborator);
|
|
53
|
-
// Ensure the collaborator is deleted automatically when the user is deleted
|
|
54
|
-
updatedConfig = await configRepo.get({ _id: newConfig._id });
|
|
55
|
-
expect(updatedConfig?.collaborators).not.toContainEqual(newCollaborator._id);
|
|
56
|
-
await (0, testsUtil_1.cleanupDoc)(userRepo, newUser);
|
|
57
|
-
});
|
|
58
|
-
/**
|
|
59
|
-
* Pretty huge test that ensures the full range of functionality is there
|
|
60
|
-
* for collaborators.
|
|
61
|
-
*/
|
|
62
|
-
it('correctly updates the collaborators for groups of users', async () => {
|
|
63
|
-
const newUser1 = await createNewTestUser();
|
|
64
|
-
const newConfig1 = await configRepo.get({ userId: newUser1._id });
|
|
65
|
-
expect(newConfig1).toBeTruthy();
|
|
66
|
-
if (!newConfig1) {
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
const newUser2 = await createNewTestUser();
|
|
70
|
-
const newConfig2 = await configRepo.get({ userId: newUser2._id });
|
|
71
|
-
expect(newConfig2).toBeTruthy();
|
|
72
|
-
if (!newConfig2) {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
const newUser3 = await createNewTestUser();
|
|
76
|
-
const newConfig3 = await configRepo.get({ userId: newUser3._id });
|
|
77
|
-
expect(newConfig3).toBeTruthy();
|
|
78
|
-
if (!newConfig3) {
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
newConfig1.collaborators.push(newUser2._id);
|
|
82
|
-
const updateResult1 = await configRepo.update(newConfig1);
|
|
83
|
-
expect(updateResult1).toBeTruthy();
|
|
84
|
-
let updatedConfig2 = await configRepo.get({ _id: newConfig2._id });
|
|
85
|
-
expect(updatedConfig2?.collaborators).toContainEqual(newUser1._id);
|
|
86
|
-
newConfig3.collaborators.push(newUser1._id, newUser2._id);
|
|
87
|
-
let updateResult3 = await configRepo.update(newConfig3);
|
|
88
|
-
expect(updateResult3).toBeTruthy();
|
|
89
|
-
let updatedConfig1 = await configRepo.get({ _id: newConfig1._id });
|
|
90
|
-
expect(updatedConfig1?.collaborators).toContainEqual(newUser3._id);
|
|
91
|
-
expect(updatedConfig1?.collaborators).toContainEqual(newUser2._id);
|
|
92
|
-
newConfig3.collaborators = [];
|
|
93
|
-
updateResult3 = await configRepo.update(newConfig3);
|
|
94
|
-
expect(updateResult3).toBeTruthy();
|
|
95
|
-
updatedConfig1 = await configRepo.get({ _id: newConfig1._id });
|
|
96
|
-
expect(updatedConfig1?.collaborators).toContainEqual(newUser2._id);
|
|
97
|
-
expect(updatedConfig1?.collaborators).not.toContainEqual(newUser3._id);
|
|
98
|
-
updatedConfig2 = await configRepo.get({ _id: newConfig2._id });
|
|
99
|
-
expect(updatedConfig2?.collaborators).toContainEqual(newUser1._id);
|
|
100
|
-
expect(updatedConfig2?.collaborators).not.toContainEqual(newUser3._id);
|
|
101
|
-
await (0, testsUtil_1.cleanupDoc)(userRepo, newUser1);
|
|
102
|
-
await (0, testsUtil_1.cleanupDoc)(userRepo, newUser2);
|
|
103
|
-
await (0, testsUtil_1.cleanupDoc)(userRepo, newUser3);
|
|
104
|
-
}, 10000);
|
|
105
|
-
});
|
|
106
|
-
afterAll(async () => {
|
|
107
|
-
return DocumentDb_1.default.closeDbConnection();
|
|
108
|
-
});
|
|
109
|
-
async function createNewTestUser() {
|
|
110
|
-
const newUser = new core_ts_db_lib_1.User((0, testsUtil_1.getTestUserName)(`${crypto_1.default.randomUUID()}userconfigtest`));
|
|
111
|
-
newUser.projectAccess.dashboard = true;
|
|
112
|
-
const insertResult = await userRepo.insertNew(newUser);
|
|
113
|
-
expect(insertResult).toBeTruthy();
|
|
114
|
-
return newUser;
|
|
115
|
-
}
|