@aneuhold/be-ts-db-lib 4.2.21 → 4.2.22

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 CHANGED
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## 🔖 [4.2.22] (2026-03-26)
9
+
10
+ ### 🏗️ Changed
11
+
12
+ - Refactored `MigrationService` to migrate `DashboardUserConfig` records instead of `User.projectAccess` fields; now backfills `enableAdminPage` and `enabledFeatures.adminPage` with safe defaults.
13
+ - Updated dependencies on `@aneuhold/be-ts-lib` to `^3.1.9` and `@aneuhold/core-ts-db-lib` to `^5.0.4`.
14
+
8
15
  ## 🔖 [4.2.21] (2026-03-20)
9
16
 
10
17
  ### 🏗️ Changed
@@ -371,7 +378,7 @@ Updated dependencies: now requires `@aneuhold/core-ts-db-lib@^3.0.0`, `@aneuhold
371
378
  - Updated workflow permissions to allow repository write access
372
379
 
373
380
  <!-- Link References -->
374
-
381
+ [4.2.22]: https://github.com/aneuhold/ts-libs/compare/be-ts-db-lib-v4.2.21...be-ts-db-lib-v4.2.22
375
382
  [4.2.21]: https://github.com/aneuhold/ts-libs/compare/be-ts-db-lib-v4.2.20...be-ts-db-lib-v4.2.21
376
383
  [4.2.20]: https://github.com/aneuhold/ts-libs/compare/be-ts-db-lib-v4.2.19...be-ts-db-lib-v4.2.20
377
384
  [4.2.19]: https://github.com/aneuhold/ts-libs/compare/be-ts-db-lib-v4.2.18...be-ts-db-lib-v4.2.19
@@ -16,5 +16,10 @@ export default class MigrationService {
16
16
  * @param dryRun Whether or not to actually make the changes or just log them.
17
17
  */
18
18
  static migrateDb(dryRun?: boolean): Promise<void>;
19
+ /**
20
+ * Migrates dashboard user configs that are missing enableAdminPage
21
+ * or the adminPage feature flag.
22
+ */
23
+ private static migrateUserConfigs;
19
24
  }
20
25
  //# sourceMappingURL=MigrationService.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MigrationService.d.ts","sourceRoot":"","sources":["../../src/services/MigrationService.ts"],"names":[],"mappings":"AAeA;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,OAAO,gBAAgB;IACnC;;;;;;;;OAQG;WACU,SAAS,CAAC,MAAM,UAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;CAkDtD"}
1
+ {"version":3,"file":"MigrationService.d.ts","sourceRoot":"","sources":["../../src/services/MigrationService.ts"],"names":[],"mappings":"AAoBA;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,OAAO,gBAAgB;IACnC;;;;;;;;OAQG;WACU,SAAS,CAAC,MAAM,UAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAQrD;;;OAGG;mBACkB,kBAAkB;CAwExC"}
@@ -2,14 +2,19 @@
2
2
  // @ts-nocheck
3
3
  import { DR } from '@aneuhold/core-ts-lib';
4
4
  import UserRepository from '../repositories/common/UserRepository.js';
5
+ import DashboardUserConfigRepository from '../repositories/dashboard/DashboardUserConfigRepository.js';
5
6
  /**
6
- * The default values for each project access field. New fields should be
7
- * added here and defaulted to `false` so existing users don't gain access
8
- * automatically.
7
+ * The default values for enabledFeatures. New feature flags should be
8
+ * added here and defaulted to `false`.
9
9
  */
10
- const PROJECT_ACCESS_DEFAULTS = {
11
- dashboard: false,
12
- workout: false
10
+ const ENABLED_FEATURES_DEFAULTS = {
11
+ financePage: false,
12
+ automationPage: false,
13
+ entertainmentPage: false,
14
+ homePageLinks: false,
15
+ useConfettiForTasks: false,
16
+ catImageOnHomePage: false,
17
+ adminPage: false
13
18
  };
14
19
  /**
15
20
  * A service for migrating the DB to a new state after an existing document
@@ -29,40 +34,63 @@ export default class MigrationService {
29
34
  * @param dryRun Whether or not to actually make the changes or just log them.
30
35
  */
31
36
  static async migrateDb(dryRun = false) {
32
- DR.logger.info('Starting migration...');
37
+ DR.logger.info(`Starting migration... (dryRun=${dryRun})`);
38
+ await this.migrateUserConfigs(dryRun);
39
+ DR.logger.success('Migration complete.');
40
+ }
41
+ /**
42
+ * Migrates dashboard user configs that are missing enableAdminPage
43
+ * or the adminPage feature flag.
44
+ */
45
+ static async migrateUserConfigs(dryRun) {
46
+ const configRepo = DashboardUserConfigRepository.getRepo();
47
+ const allConfigs = await configRepo.getAll();
48
+ // Build a userId -> userName lookup
33
49
  const userRepo = UserRepository.getRepo();
34
- const users = await userRepo.getAll();
35
- // Find users that are missing projectAccess entirely or are missing
36
- // any of the expected fields.
37
- const usersToUpdate = users.filter((user) => {
38
- if (!user.projectAccess)
39
- return true;
40
- return Object.keys(PROJECT_ACCESS_DEFAULTS).some((key) => user.projectAccess[key] === undefined);
41
- });
42
- DR.logger.info(`Found ${usersToUpdate.length} of ${users.length} users with missing projectAccess fields.`);
43
- if (usersToUpdate.length === 0) {
44
- DR.logger.success('No migration needed.');
50
+ const allUsers = await userRepo.getAll();
51
+ const userNameMap = new Map(allUsers.map((u) => [u._id, u.userName]));
52
+ // Build all updates in memory first, tracking only changed fields
53
+ const updates = [];
54
+ for (const config of allConfigs) {
55
+ const changes = [];
56
+ const updateDoc = { _id: config._id };
57
+ if (config.enableAdminPage === undefined) {
58
+ changes.push('enableAdminPage: undefined false');
59
+ updateDoc.enableAdminPage = false;
60
+ }
61
+ const existingFeatures = config.enabledFeatures ?? {};
62
+ if (!existingFeatures || existingFeatures.adminPage === undefined) {
63
+ changes.push('enabledFeatures.adminPage: undefined → false');
64
+ updateDoc.enabledFeatures = { ...ENABLED_FEATURES_DEFAULTS, ...existingFeatures };
65
+ }
66
+ if (changes.length === 0) {
67
+ continue;
68
+ }
69
+ const userName = userNameMap.get(config.userId) ?? 'unknown';
70
+ updates.push({ configId: config._id, userName, changes, updateDoc });
71
+ }
72
+ DR.logger.info(`Found ${updates.length} of ${allConfigs.length} user configs needing admin page fields.`);
73
+ if (updates.length === 0) {
74
+ DR.logger.success('No user config migration needed.');
45
75
  return;
46
76
  }
77
+ // Log exactly what will change
78
+ for (const update of updates) {
79
+ DR.logger.info(` ${update.userName} (${update.configId}):`);
80
+ for (const change of update.changes) {
81
+ DR.logger.info(` ${change}`);
82
+ }
83
+ }
47
84
  if (dryRun) {
48
- DR.logger.info('Dry run: Would update the following users:');
49
- usersToUpdate.forEach((user) => {
50
- const existing = user.projectAccess ?? {};
51
- const merged = { ...PROJECT_ACCESS_DEFAULTS, ...existing };
52
- DR.logger.info(` - ${user.userName} (${user._id}): ${JSON.stringify(existing)} → ${JSON.stringify(merged)}`);
53
- });
85
+ DR.logger.info(`Dry run complete. ${updates.length} configs would be updated.`);
54
86
  return;
55
87
  }
56
- for (const user of usersToUpdate) {
57
- const existing = user.projectAccess ?? {};
58
- const merged = { ...PROJECT_ACCESS_DEFAULTS, ...existing };
59
- await userRepo.update({
60
- _id: user._id,
61
- projectAccess: merged
62
- });
63
- DR.logger.info(`Updated user ${user.userName} (${user._id}): ${JSON.stringify(existing)} → ${JSON.stringify(merged)}`);
88
+ // Execute updates
89
+ for (const update of updates) {
90
+ await configRepo.update(update.updateDoc);
91
+ DR.logger.info(`Updated config for ${update.userName} (${update.configId})`);
64
92
  }
65
- DR.logger.success(`Migration complete. Updated ${usersToUpdate.length} users.`);
93
+ DR.logger.success(`User config migration complete. Updated ${updates.length} configs.`);
66
94
  }
67
95
  }
68
96
  //# sourceMappingURL=MigrationService.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MigrationService.js","sourceRoot":"","sources":["../../src/services/MigrationService.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,cAAc;AACd,OAAO,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAC3C,OAAO,cAAc,MAAM,0CAA0C,CAAC;AAEtE;;;;GAIG;AACH,MAAM,uBAAuB,GAAG;IAC9B,SAAS,EAAE,KAAK;IAChB,OAAO,EAAE,KAAK;CACf,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CA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C,IAAI,CAAC,qBAAqB,OAAO,CAAC,MAAM,4BAA4B,CAAC,CAAC;YAChF,OAAO;QACT,CAAC;QAED,kBAAkB;QAClB,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC7B,MAAM,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;YAC1C,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,sBAAsB,MAAM,CAAC,QAAQ,KAAK,MAAM,CAAC,QAAQ,GAAG,CAAC,CAAC;QAC/E,CAAC;QAED,EAAE,CAAC,MAAM,CAAC,OAAO,CACf,2CAA2C,OAAO,CAAC,MAAM,WAAW,CACrE,CAAC;IACJ,CAAC;CACF"}
@@ -2,15 +2,20 @@
2
2
  // @ts-nocheck
3
3
  import { DR } from '@aneuhold/core-ts-lib';
4
4
  import UserRepository from '../repositories/common/UserRepository.js';
5
+ import DashboardUserConfigRepository from '../repositories/dashboard/DashboardUserConfigRepository.js';
5
6
 
6
7
  /**
7
- * The default values for each project access field. New fields should be
8
- * added here and defaulted to `false` so existing users don't gain access
9
- * automatically.
8
+ * The default values for enabledFeatures. New feature flags should be
9
+ * added here and defaulted to `false`.
10
10
  */
11
- const PROJECT_ACCESS_DEFAULTS = {
12
- dashboard: false,
13
- workout: false
11
+ const ENABLED_FEATURES_DEFAULTS = {
12
+ financePage: false,
13
+ automationPage: false,
14
+ entertainmentPage: false,
15
+ homePageLinks: false,
16
+ useConfettiForTasks: false,
17
+ catImageOnHomePage: false,
18
+ adminPage: false
14
19
  };
15
20
 
16
21
  /**
@@ -31,53 +36,87 @@ export default class MigrationService {
31
36
  * @param dryRun Whether or not to actually make the changes or just log them.
32
37
  */
33
38
  static async migrateDb(dryRun = false): Promise<void> {
34
- DR.logger.info('Starting migration...');
39
+ DR.logger.info(`Starting migration... (dryRun=${dryRun})`);
35
40
 
41
+ await this.migrateUserConfigs(dryRun);
42
+
43
+ DR.logger.success('Migration complete.');
44
+ }
45
+
46
+ /**
47
+ * Migrates dashboard user configs that are missing enableAdminPage
48
+ * or the adminPage feature flag.
49
+ */
50
+ private static async migrateUserConfigs(dryRun: boolean): Promise<void> {
51
+ const configRepo = DashboardUserConfigRepository.getRepo();
52
+ const allConfigs = await configRepo.getAll();
53
+
54
+ // Build a userId -> userName lookup
36
55
  const userRepo = UserRepository.getRepo();
37
- const users = await userRepo.getAll();
56
+ const allUsers = await userRepo.getAll();
57
+ const userNameMap = new Map(allUsers.map((u) => [u._id, u.userName]));
58
+
59
+ // Build all updates in memory first, tracking only changed fields
60
+ const updates: Array<{
61
+ configId: string;
62
+ userName: string;
63
+ changes: string[];
64
+ updateDoc: Record<string, unknown>;
65
+ }> = [];
66
+
67
+ for (const config of allConfigs) {
68
+ const changes: string[] = [];
69
+ const updateDoc: Record<string, unknown> = { _id: config._id };
38
70
 
39
- // Find users that are missing projectAccess entirely or are missing
40
- // any of the expected fields.
41
- const usersToUpdate = users.filter((user) => {
42
- if (!user.projectAccess) return true;
43
- return Object.keys(PROJECT_ACCESS_DEFAULTS).some(
44
- (key) => user.projectAccess[key] === undefined
45
- );
46
- });
71
+ if (config.enableAdminPage === undefined) {
72
+ changes.push('enableAdminPage: undefined false');
73
+ updateDoc.enableAdminPage = false;
74
+ }
75
+
76
+ const existingFeatures = config.enabledFeatures ?? {};
77
+ if (!existingFeatures || existingFeatures.adminPage === undefined) {
78
+ changes.push('enabledFeatures.adminPage: undefined → false');
79
+ updateDoc.enabledFeatures = { ...ENABLED_FEATURES_DEFAULTS, ...existingFeatures };
80
+ }
81
+
82
+ if (changes.length === 0) {
83
+ continue;
84
+ }
85
+
86
+ const userName = userNameMap.get(config.userId) ?? 'unknown';
87
+ updates.push({ configId: config._id, userName, changes, updateDoc });
88
+ }
47
89
 
48
90
  DR.logger.info(
49
- `Found ${usersToUpdate.length} of ${users.length} users with missing projectAccess fields.`
91
+ `Found ${updates.length} of ${allConfigs.length} user configs needing admin page fields.`
50
92
  );
51
93
 
52
- if (usersToUpdate.length === 0) {
53
- DR.logger.success('No migration needed.');
94
+ if (updates.length === 0) {
95
+ DR.logger.success('No user config migration needed.');
54
96
  return;
55
97
  }
56
98
 
99
+ // Log exactly what will change
100
+ for (const update of updates) {
101
+ DR.logger.info(` ${update.userName} (${update.configId}):`);
102
+ for (const change of update.changes) {
103
+ DR.logger.info(` ${change}`);
104
+ }
105
+ }
106
+
57
107
  if (dryRun) {
58
- DR.logger.info('Dry run: Would update the following users:');
59
- usersToUpdate.forEach((user) => {
60
- const existing = user.projectAccess ?? {};
61
- const merged = { ...PROJECT_ACCESS_DEFAULTS, ...existing };
62
- DR.logger.info(
63
- ` - ${user.userName} (${user._id}): ${JSON.stringify(existing)} → ${JSON.stringify(merged)}`
64
- );
65
- });
108
+ DR.logger.info(`Dry run complete. ${updates.length} configs would be updated.`);
66
109
  return;
67
110
  }
68
111
 
69
- for (const user of usersToUpdate) {
70
- const existing = user.projectAccess ?? {};
71
- const merged = { ...PROJECT_ACCESS_DEFAULTS, ...existing };
72
- await userRepo.update({
73
- _id: user._id,
74
- projectAccess: merged
75
- });
76
- DR.logger.info(
77
- `Updated user ${user.userName} (${user._id}): ${JSON.stringify(existing)} → ${JSON.stringify(merged)}`
78
- );
112
+ // Execute updates
113
+ for (const update of updates) {
114
+ await configRepo.update(update.updateDoc);
115
+ DR.logger.info(`Updated config for ${update.userName} (${update.configId})`);
79
116
  }
80
117
 
81
- DR.logger.success(`Migration complete. Updated ${usersToUpdate.length} users.`);
118
+ DR.logger.success(
119
+ `User config migration complete. Updated ${updates.length} configs.`
120
+ );
82
121
  }
83
122
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@aneuhold/be-ts-db-lib",
3
3
  "author": "Anton G. Neuhold Jr.",
4
4
  "license": "MIT",
5
- "version": "4.2.21",
5
+ "version": "4.2.22",
6
6
  "description": "A backend database library meant to actually interact with various databases in personal projects",
7
7
  "packageManager": "pnpm@10.25.0",
8
8
  "type": "module",
@@ -58,8 +58,8 @@
58
58
  "MongoDB"
59
59
  ],
60
60
  "dependencies": {
61
- "@aneuhold/be-ts-lib": "^3.1.8",
62
- "@aneuhold/core-ts-db-lib": "^5.0.3",
61
+ "@aneuhold/be-ts-lib": "^3.1.9",
62
+ "@aneuhold/core-ts-db-lib": "^5.0.4",
63
63
  "@aneuhold/core-ts-lib": "^2.4.3",
64
64
  "bson": "^7.0.0",
65
65
  "google-auth-library": "^10.6.1",