@aneuhold/be-ts-db-lib 4.0.2 → 4.1.1

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.
Files changed (51) hide show
  1. package/CHANGELOG.md +22 -1
  2. package/lib/index.d.ts +2 -1
  3. package/lib/index.d.ts.map +1 -1
  4. package/lib/index.js +2 -1
  5. package/lib/index.js.map +1 -1
  6. package/lib/index.ts +2 -0
  7. package/lib/repositories/BaseRepository.d.ts +33 -16
  8. package/lib/repositories/BaseRepository.d.ts.map +1 -1
  9. package/lib/repositories/BaseRepository.js +51 -13
  10. package/lib/repositories/BaseRepository.js.map +1 -1
  11. package/lib/repositories/BaseRepository.ts +88 -38
  12. package/lib/repositories/dashboard/DashboardBaseRepository.d.ts +12 -1
  13. package/lib/repositories/dashboard/DashboardBaseRepository.d.ts.map +1 -1
  14. package/lib/repositories/dashboard/DashboardBaseRepository.js +30 -1
  15. package/lib/repositories/dashboard/DashboardBaseRepository.js.map +1 -1
  16. package/lib/repositories/dashboard/DashboardBaseRepository.ts +52 -2
  17. package/lib/repositories/dashboard/DashboardBaseWithUserIdRepository.d.ts +25 -0
  18. package/lib/repositories/dashboard/DashboardBaseWithUserIdRepository.d.ts.map +1 -0
  19. package/lib/repositories/dashboard/DashboardBaseWithUserIdRepository.js +70 -0
  20. package/lib/repositories/dashboard/DashboardBaseWithUserIdRepository.js.map +1 -0
  21. package/lib/repositories/dashboard/DashboardBaseWithUserIdRepository.ts +101 -0
  22. package/lib/repositories/dashboard/DashboardNonogramKatanaItemRepository.d.ts +2 -9
  23. package/lib/repositories/dashboard/DashboardNonogramKatanaItemRepository.d.ts.map +1 -1
  24. package/lib/repositories/dashboard/DashboardNonogramKatanaItemRepository.js +9 -19
  25. package/lib/repositories/dashboard/DashboardNonogramKatanaItemRepository.js.map +1 -1
  26. package/lib/repositories/dashboard/DashboardNonogramKatanaItemRepository.ts +9 -25
  27. package/lib/repositories/dashboard/DashboardNonogramKatanaUpgradeRepository.d.ts +2 -9
  28. package/lib/repositories/dashboard/DashboardNonogramKatanaUpgradeRepository.d.ts.map +1 -1
  29. package/lib/repositories/dashboard/DashboardNonogramKatanaUpgradeRepository.js +9 -19
  30. package/lib/repositories/dashboard/DashboardNonogramKatanaUpgradeRepository.js.map +1 -1
  31. package/lib/repositories/dashboard/DashboardNonogramKatanaUpgradeRepository.ts +9 -25
  32. package/lib/repositories/dashboard/DashboardTaskRepository.d.ts +12 -5
  33. package/lib/repositories/dashboard/DashboardTaskRepository.d.ts.map +1 -1
  34. package/lib/repositories/dashboard/DashboardTaskRepository.js +77 -8
  35. package/lib/repositories/dashboard/DashboardTaskRepository.js.map +1 -1
  36. package/lib/repositories/dashboard/DashboardTaskRepository.ts +104 -10
  37. package/lib/repositories/dashboard/DashboardUserConfigRepository.d.ts +11 -6
  38. package/lib/repositories/dashboard/DashboardUserConfigRepository.d.ts.map +1 -1
  39. package/lib/repositories/dashboard/DashboardUserConfigRepository.js +24 -16
  40. package/lib/repositories/dashboard/DashboardUserConfigRepository.js.map +1 -1
  41. package/lib/repositories/dashboard/DashboardUserConfigRepository.ts +39 -16
  42. package/lib/services/RepoSubscriptionService.d.ts +7 -6
  43. package/lib/services/RepoSubscriptionService.d.ts.map +1 -1
  44. package/lib/services/RepoSubscriptionService.js.map +1 -1
  45. package/lib/services/RepoSubscriptionService.ts +13 -6
  46. package/lib/util/DbOperationMetaData.d.ts +47 -0
  47. package/lib/util/DbOperationMetaData.d.ts.map +1 -0
  48. package/lib/util/DbOperationMetaData.js +58 -0
  49. package/lib/util/DbOperationMetaData.js.map +1 -0
  50. package/lib/util/DbOperationMetaData.ts +65 -0
  51. package/package.json +10 -9
package/CHANGELOG.md CHANGED
@@ -5,6 +5,26 @@ 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.1.1] (2025-12-14)
9
+
10
+ ### 🏗️ Changed
11
+ - Updated dependencies: now requires `@aneuhold/be-ts-lib@^3.0.8`, `@aneuhold/core-ts-db-lib@^4.0.4`, `@aneuhold/core-ts-lib@^2.3.16`, and `@aneuhold/local-npm-registry@^0.2.23`.
12
+
13
+ ## 🔖 [4.1.0] (2025-12-14)
14
+
15
+ ### ✅ Added
16
+ - Added doc caching and retrieval strategy to repositories
17
+ - Created base user ID repository for dashboard
18
+
19
+ ### 🏗️ Changed
20
+ - Updated test scripts to include coverage
21
+ - Updated dependencies for compatibility
22
+
23
+ ### 🩹 Fixed
24
+ - Fixed import paths in dashboard repositories
25
+
26
+
27
+
8
28
  ## 🔖 [4.0.2] (2025-12-13)
9
29
 
10
30
  ### 🏗️ Changed
@@ -163,7 +183,8 @@ Updated dependencies: now requires `@aneuhold/core-ts-db-lib@^3.0.0`, `@aneuhold
163
183
  - Updated workflow permissions to allow repository write access
164
184
 
165
185
  <!-- Link References -->
166
-
186
+ [4.1.1]: https://github.com/aneuhold/ts-libs/compare/be-ts-db-lib-v4.1.0...be-ts-db-lib-v4.1.1
187
+ [4.1.0]: https://github.com/aneuhold/ts-libs/compare/be-ts-db-lib-v4.0.2...be-ts-db-lib-v4.1.0
167
188
  [4.0.2]: https://github.com/aneuhold/ts-libs/compare/be-ts-db-lib-v4.0.1...be-ts-db-lib-v4.0.2
168
189
  [4.0.1]: https://github.com/aneuhold/ts-libs/compare/be-ts-db-lib-v4.0.0...be-ts-db-lib-v4.0.1
169
190
  [4.0.0]: https://github.com/aneuhold/ts-libs/compare/be-ts-db-lib-v3.0.4...be-ts-db-lib-v4.0.0
package/lib/index.d.ts CHANGED
@@ -4,7 +4,8 @@ import DashboardNonogramKatanaItemRepository from './repositories/dashboard/Dash
4
4
  import DashboardNonogramKatanaUpgradeRepository from './repositories/dashboard/DashboardNonogramKatanaUpgradeRepository.js';
5
5
  import DashboardTaskRepository from './repositories/dashboard/DashboardTaskRepository.js';
6
6
  import DashboardUserConfigRepository from './repositories/dashboard/DashboardUserConfigRepository.js';
7
+ import DbOperationMetaData from './util/DbOperationMetaData.js';
7
8
  import DocumentDb from './util/DocumentDb.js';
8
- export { ApiKeyRepository, DashboardNonogramKatanaItemRepository, DashboardNonogramKatanaUpgradeRepository, DashboardTaskRepository, DashboardUserConfigRepository, DocumentDb, UserRepository };
9
+ export { ApiKeyRepository, DashboardNonogramKatanaItemRepository, DashboardNonogramKatanaUpgradeRepository, DashboardTaskRepository, DashboardUserConfigRepository, DbOperationMetaData, DocumentDb, UserRepository };
9
10
  export type {};
10
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,MAAM,2CAA2C,CAAC;AACzE,OAAO,cAAc,MAAM,yCAAyC,CAAC;AACrE,OAAO,qCAAqC,MAAM,mEAAmE,CAAC;AACtH,OAAO,wCAAwC,MAAM,sEAAsE,CAAC;AAC5H,OAAO,uBAAuB,MAAM,qDAAqD,CAAC;AAC1F,OAAO,6BAA6B,MAAM,2DAA2D,CAAC;AACtG,OAAO,UAAU,MAAM,sBAAsB,CAAC;AAG9C,OAAO,EACL,gBAAgB,EAChB,qCAAqC,EACrC,wCAAwC,EACxC,uBAAuB,EACvB,6BAA6B,EAC7B,UAAU,EACV,cAAc,EACf,CAAC;AAGF,YAAY,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,MAAM,2CAA2C,CAAC;AACzE,OAAO,cAAc,MAAM,yCAAyC,CAAC;AACrE,OAAO,qCAAqC,MAAM,mEAAmE,CAAC;AACtH,OAAO,wCAAwC,MAAM,sEAAsE,CAAC;AAC5H,OAAO,uBAAuB,MAAM,qDAAqD,CAAC;AAC1F,OAAO,6BAA6B,MAAM,2DAA2D,CAAC;AACtG,OAAO,mBAAmB,MAAM,+BAA+B,CAAC;AAChE,OAAO,UAAU,MAAM,sBAAsB,CAAC;AAG9C,OAAO,EACL,gBAAgB,EAChB,qCAAqC,EACrC,wCAAwC,EACxC,uBAAuB,EACvB,6BAA6B,EAC7B,mBAAmB,EACnB,UAAU,EACV,cAAc,EACf,CAAC;AAGF,YAAY,EAAE,CAAC"}
package/lib/index.js CHANGED
@@ -4,7 +4,8 @@ import DashboardNonogramKatanaItemRepository from './repositories/dashboard/Dash
4
4
  import DashboardNonogramKatanaUpgradeRepository from './repositories/dashboard/DashboardNonogramKatanaUpgradeRepository.js';
5
5
  import DashboardTaskRepository from './repositories/dashboard/DashboardTaskRepository.js';
6
6
  import DashboardUserConfigRepository from './repositories/dashboard/DashboardUserConfigRepository.js';
7
+ import DbOperationMetaData from './util/DbOperationMetaData.js';
7
8
  import DocumentDb from './util/DocumentDb.js';
8
9
  // Export all the functions and classes from this library
9
- export { ApiKeyRepository, DashboardNonogramKatanaItemRepository, DashboardNonogramKatanaUpgradeRepository, DashboardTaskRepository, DashboardUserConfigRepository, DocumentDb, UserRepository };
10
+ export { ApiKeyRepository, DashboardNonogramKatanaItemRepository, DashboardNonogramKatanaUpgradeRepository, DashboardTaskRepository, DashboardUserConfigRepository, DbOperationMetaData, DocumentDb, UserRepository };
10
11
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,MAAM,2CAA2C,CAAC;AACzE,OAAO,cAAc,MAAM,yCAAyC,CAAC;AACrE,OAAO,qCAAqC,MAAM,mEAAmE,CAAC;AACtH,OAAO,wCAAwC,MAAM,sEAAsE,CAAC;AAC5H,OAAO,uBAAuB,MAAM,qDAAqD,CAAC;AAC1F,OAAO,6BAA6B,MAAM,2DAA2D,CAAC;AACtG,OAAO,UAAU,MAAM,sBAAsB,CAAC;AAE9C,yDAAyD;AACzD,OAAO,EACL,gBAAgB,EAChB,qCAAqC,EACrC,wCAAwC,EACxC,uBAAuB,EACvB,6BAA6B,EAC7B,UAAU,EACV,cAAc,EACf,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,MAAM,2CAA2C,CAAC;AACzE,OAAO,cAAc,MAAM,yCAAyC,CAAC;AACrE,OAAO,qCAAqC,MAAM,mEAAmE,CAAC;AACtH,OAAO,wCAAwC,MAAM,sEAAsE,CAAC;AAC5H,OAAO,uBAAuB,MAAM,qDAAqD,CAAC;AAC1F,OAAO,6BAA6B,MAAM,2DAA2D,CAAC;AACtG,OAAO,mBAAmB,MAAM,+BAA+B,CAAC;AAChE,OAAO,UAAU,MAAM,sBAAsB,CAAC;AAE9C,yDAAyD;AACzD,OAAO,EACL,gBAAgB,EAChB,qCAAqC,EACrC,wCAAwC,EACxC,uBAAuB,EACvB,6BAA6B,EAC7B,mBAAmB,EACnB,UAAU,EACV,cAAc,EACf,CAAC"}
package/lib/index.ts CHANGED
@@ -4,6 +4,7 @@ import DashboardNonogramKatanaItemRepository from './repositories/dashboard/Dash
4
4
  import DashboardNonogramKatanaUpgradeRepository from './repositories/dashboard/DashboardNonogramKatanaUpgradeRepository.js';
5
5
  import DashboardTaskRepository from './repositories/dashboard/DashboardTaskRepository.js';
6
6
  import DashboardUserConfigRepository from './repositories/dashboard/DashboardUserConfigRepository.js';
7
+ import DbOperationMetaData from './util/DbOperationMetaData.js';
7
8
  import DocumentDb from './util/DocumentDb.js';
8
9
 
9
10
  // Export all the functions and classes from this library
@@ -13,6 +14,7 @@ export {
13
14
  DashboardNonogramKatanaUpgradeRepository,
14
15
  DashboardTaskRepository,
15
16
  DashboardUserConfigRepository,
17
+ DbOperationMetaData,
16
18
  DocumentDb,
17
19
  UserRepository
18
20
  };
@@ -2,6 +2,7 @@ import type { BaseDocument } from '@aneuhold/core-ts-db-lib';
2
2
  import type { UUID } from 'crypto';
3
3
  import type { BulkWriteResult, Collection, DeleteResult, Filter, UpdateResult } from 'mongodb';
4
4
  import type { RepoListeners, RepoSubscribers } from '../services/RepoSubscriptionService.js';
5
+ import type DbOperationMetaData from '../util/DbOperationMetaData.js';
5
6
  import type IValidator from '../validators/BaseValidator.js';
6
7
  /**
7
8
  * Base repository class for handling common database operations.
@@ -9,15 +10,15 @@ import type IValidator from '../validators/BaseValidator.js';
9
10
  * Implementation note: I have tried to do the types correctly here, but kept struggling with
10
11
  * MongoDB's types around Filter<T> and _id fields.
11
12
  *
12
- * @template TBasetype - The type of the documents in the collection.
13
+ * @template TBaseType - The type of the documents in the collection.
13
14
  */
14
- export default abstract class BaseRepository<TBasetype extends BaseDocument> {
15
+ export default abstract class BaseRepository<TBaseType extends BaseDocument> {
15
16
  private validator;
16
17
  private defaultFilter?;
17
18
  private defaultUpdateCleaner?;
18
19
  protected collectionName: string;
19
20
  private collection?;
20
- protected subscribers: RepoSubscribers<TBasetype>;
21
+ protected subscribers: RepoSubscribers<TBaseType>;
21
22
  /**
22
23
  * Constructs a new base repository.
23
24
  *
@@ -26,13 +27,13 @@ export default abstract class BaseRepository<TBasetype extends BaseDocument> {
26
27
  * @param defaultFilter - The default filter to apply to queries.
27
28
  * @param defaultUpdateCleaner - A function to clean update objects before sending to the DB.
28
29
  */
29
- constructor(collectionName: string, validator: IValidator<TBasetype>, defaultFilter?: Partial<TBasetype> | undefined, defaultUpdateCleaner?: ((doc: Partial<TBasetype>) => Partial<TBasetype>) | undefined);
30
+ constructor(collectionName: string, validator: IValidator<TBaseType>, defaultFilter?: Partial<TBaseType> | undefined, defaultUpdateCleaner?: ((doc: Partial<TBaseType>) => Partial<TBaseType>) | undefined);
30
31
  /**
31
32
  * Gets the collection, initializing it if necessary.
32
33
  *
33
34
  * @returns The collection.
34
35
  */
35
- protected getCollection(): Promise<Collection<TBasetype>>;
36
+ protected getCollection(): Promise<Collection<TBaseType>>;
36
37
  protected abstract setupSubscribers(): void;
37
38
  /**
38
39
  * Registers a set of functions that will be called when a change happens
@@ -40,34 +41,36 @@ export default abstract class BaseRepository<TBasetype extends BaseDocument> {
40
41
  *
41
42
  * @param listeners - The listeners to register.
42
43
  */
43
- subscribeToChanges(listeners: RepoListeners<TBasetype>): void;
44
+ subscribeToChanges(listeners: RepoListeners<TBaseType>): void;
44
45
  /**
45
46
  * Inserts a new document into the collection.
46
47
  *
47
48
  * @param newDoc - The new document to insert.
49
+ * @param meta - Tracks database operation metadata for a single request.
48
50
  * @returns The inserted document or null if the insertion failed.
49
51
  */
50
- insertNew(newDoc: TBasetype): Promise<TBasetype | null>;
52
+ insertNew(newDoc: TBaseType, meta?: DbOperationMetaData): Promise<TBaseType | null>;
51
53
  /**
52
54
  * Inserts multiple new documents into the collection.
53
55
  *
54
56
  * @param newDocs - The new documents to insert.
57
+ * @param meta - Tracks database operation metadata for a single request.
55
58
  * @returns The inserted documents or an empty array if the insertion failed.
56
59
  */
57
- insertMany(newDocs: TBasetype[]): Promise<TBasetype[]>;
60
+ insertMany(newDocs: TBaseType[], meta?: DbOperationMetaData): Promise<TBaseType[]>;
58
61
  /**
59
62
  * Retrieves a document matching the given filter.
60
63
  *
61
64
  * @param filter - The filter to apply.
62
65
  * @returns The matching document or null if no document was found.
63
66
  */
64
- get(filter: Partial<TBasetype>): Promise<TBasetype | null>;
67
+ get(filter: Partial<TBaseType>): Promise<TBaseType | null>;
65
68
  /**
66
69
  * Retrieves all documents in the collection.
67
70
  *
68
71
  * @returns An array of all documents in the collection.
69
72
  */
70
- getAll(): Promise<TBasetype[]>;
73
+ getAll(): Promise<TBaseType[]>;
71
74
  /**
72
75
  * Gets all the IDs in the collection as a hash for performant lookups.
73
76
  *
@@ -82,21 +85,23 @@ export default abstract class BaseRepository<TBasetype extends BaseDocument> {
82
85
  * @param docIds - The IDs of the documents to retrieve.
83
86
  * @returns An array of matching documents.
84
87
  */
85
- getList(docIds: UUID[]): Promise<TBasetype[]>;
88
+ getList(docIds: UUID[]): Promise<TBaseType[]>;
86
89
  /**
87
90
  * Deletes a document by its ID.
88
91
  *
89
92
  * @param docId - The ID of the document to delete.
93
+ * @param meta - Tracks database operation metadata for a single request.
90
94
  * @returns The result of the delete operation.
91
95
  */
92
- delete(docId: UUID): Promise<DeleteResult>;
96
+ delete(docId: UUID, meta?: DbOperationMetaData): Promise<DeleteResult>;
93
97
  /**
94
98
  * Deletes multiple documents by their IDs.
95
99
  *
96
100
  * @param docIds - The IDs of the documents to delete.
101
+ * @param meta - Tracks database operation metadata for a single request.
97
102
  * @returns The result of the delete operation.
98
103
  */
99
- deleteList(docIds: UUID[]): Promise<DeleteResult>;
104
+ deleteList(docIds: UUID[], meta?: DbOperationMetaData): Promise<DeleteResult>;
100
105
  /**
101
106
  * This should not be used except for testing purposes
102
107
  *
@@ -109,25 +114,37 @@ export default abstract class BaseRepository<TBasetype extends BaseDocument> {
109
114
  * This base method strips the `_id` before updating.
110
115
  *
111
116
  * @param updatedDoc - The document to update.
117
+ * @param meta - Tracks database operation metadata for a single request.
112
118
  * @returns The result of the update operation.
113
119
  */
114
- update(updatedDoc: Partial<TBasetype>): Promise<UpdateResult>;
120
+ update(updatedDoc: Partial<TBaseType>, meta?: DbOperationMetaData): Promise<UpdateResult>;
115
121
  /**
116
122
  * Updates the provided documents in the DB.
117
123
  *
118
124
  * This base method strips the `_id` before updating.
119
125
  *
120
126
  * @param updatedDocs - The documents to update.
127
+ * @param meta - Tracks database operation metadata for a single request.
121
128
  * @returns The result of the bulk update operation.
122
129
  */
123
- updateMany(updatedDocs: Array<Partial<TBasetype>>): Promise<BulkWriteResult>;
130
+ updateMany(updatedDocs: Array<Partial<TBaseType>>, meta?: DbOperationMetaData): Promise<BulkWriteResult>;
131
+ /**
132
+ * Fetches and caches multiple documents, returning only those not already cached.
133
+ * This method checks the cache in the provided metadata object first, then fetches
134
+ * any missing documents from the database and caches them.
135
+ *
136
+ * @param docIds - The IDs of the documents to fetch.
137
+ * @param meta - The metadata object containing the cache.
138
+ * @returns An array of all documents (from cache and newly fetched).
139
+ */
140
+ protected fetchAndCacheDocsForMeta(docIds: UUID[], meta: DbOperationMetaData): Promise<TBaseType[]>;
124
141
  /**
125
142
  * Gets the filter with the default filter applied if there is one.
126
143
  *
127
144
  * @param filter - The filter to apply.
128
145
  * @returns The filter with the default filter applied.
129
146
  */
130
- protected getFilterWithDefault(filter?: Filter<TBasetype>): Filter<TBasetype>;
147
+ protected getFilterWithDefault(filter?: Filter<TBaseType>): Filter<TBaseType>;
131
148
  /**
132
149
  * Checks if two arrays of {@link UUID} are equal.
133
150
  *
@@ -1 +1 @@
1
- {"version":3,"file":"BaseRepository.d.ts","sourceRoot":"","sources":["../../src/repositories/BaseRepository.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,KAAK,EAEV,eAAe,EACf,UAAU,EACV,YAAY,EACZ,MAAM,EAEN,YAAY,EACb,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AAI7F,OAAO,KAAK,UAAU,MAAM,gCAAgC,CAAC;AAE7D;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,CAAC,QAAQ,OAAO,cAAc,CAAC,SAAS,SAAS,YAAY;IAkBvE,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,aAAa,CAAC;IACtB,OAAO,CAAC,oBAAoB,CAAC;IAnB/B,SAAS,CAAC,cAAc,EAAE,MAAM,CAAC;IAEjC,OAAO,CAAC,UAAU,CAAC,CAAwB;IAE3C,SAAS,CAAC,WAAW,EAAE,eAAe,CAAC,SAAS,CAAC,CACY;IAE7D;;;;;;;OAOG;gBAED,cAAc,EAAE,MAAM,EACd,SAAS,EAAE,UAAU,CAAC,SAAS,CAAC,EAChC,aAAa,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,YAAA,EA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G,OAAO,CAAC,YAAY,CAAC;IASnF;;;;OAIG;IACG,SAAS,IAAI,OAAO,CAAC,YAAY,CAAC;IAKxC;;;;;;;;OAQG;IACG,MAAM,CAAC,UAAU,EAAE,OAAO,CAAC,SAAS,CAAC,EAAE,IAAI,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,YAAY,CAAC;IAe/F;;;;;;;;OAQG;IACG,UAAU,CACd,WAAW,EAAE,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,EACtC,IAAI,CAAC,EAAE,mBAAmB,GACzB,OAAO,CAAC,eAAe,CAAC;IAsB3B;;;;;;;;OAQG;cACa,wBAAwB,CACtC,MAAM,EAAE,IAAI,EAAE,EACd,IAAI,EAAE,mBAAmB,GACxB,OAAO,CAAC,SAAS,EAAE,CAAC;IA0BvB;;;;;OAKG;IACH,SAAS,CAAC,oBAAoB,CAAC,MAAM,GAAE,MAAM,CAAC,SAAS,CAAM,GAAG,MAAM,CAAC,SAAS,CAAC;IAOjF;;;;;;OAMG;IACH,SAAS,CAAC,kBAAkB,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO;IAOrE;;;;;;;;OAQG;IACH,OAAO,CAAC,iBAAiB;CAK1B"}
@@ -7,7 +7,7 @@ import DocumentDb from '../util/DocumentDb.js';
7
7
  * Implementation note: I have tried to do the types correctly here, but kept struggling with
8
8
  * MongoDB's types around Filter<T> and _id fields.
9
9
  *
10
- * @template TBasetype - The type of the documents in the collection.
10
+ * @template TBaseType - The type of the documents in the collection.
11
11
  */
12
12
  export default class BaseRepository {
13
13
  validator;
@@ -70,32 +70,34 @@ export default class BaseRepository {
70
70
  * Inserts a new document into the collection.
71
71
  *
72
72
  * @param newDoc - The new document to insert.
73
+ * @param meta - Tracks database operation metadata for a single request.
73
74
  * @returns The inserted document or null if the insertion failed.
74
75
  */
75
- async insertNew(newDoc) {
76
+ async insertNew(newDoc, meta) {
76
77
  const collection = await this.getCollection();
77
78
  await this.validator.validateNewObject(newDoc);
78
79
  const insertResult = await collection.insertOne(newDoc);
79
80
  if (!insertResult.acknowledged) {
80
81
  return null;
81
82
  }
82
- await Promise.all(this.subscribers.insertNew.map((subscriber) => subscriber(newDoc)));
83
+ await Promise.all(this.subscribers.insertNew.map((subscriber) => subscriber(newDoc, meta)));
83
84
  return newDoc;
84
85
  }
85
86
  /**
86
87
  * Inserts multiple new documents into the collection.
87
88
  *
88
89
  * @param newDocs - The new documents to insert.
90
+ * @param meta - Tracks database operation metadata for a single request.
89
91
  * @returns The inserted documents or an empty array if the insertion failed.
90
92
  */
91
- async insertMany(newDocs) {
93
+ async insertMany(newDocs, meta) {
92
94
  const collection = await this.getCollection();
93
95
  await Promise.all(newDocs.map((doc) => this.validator.validateNewObject(doc)));
94
96
  const insertResult = await collection.insertMany(newDocs);
95
97
  if (!insertResult.acknowledged) {
96
98
  return [];
97
99
  }
98
- await Promise.all(this.subscribers.insertMany.map((subscriber) => subscriber(newDocs)));
100
+ await Promise.all(this.subscribers.insertMany.map((subscriber) => subscriber(newDocs, meta)));
99
101
  return newDocs;
100
102
  }
101
103
  /**
@@ -149,25 +151,27 @@ export default class BaseRepository {
149
151
  * Deletes a document by its ID.
150
152
  *
151
153
  * @param docId - The ID of the document to delete.
154
+ * @param meta - Tracks database operation metadata for a single request.
152
155
  * @returns The result of the delete operation.
153
156
  */
154
- async delete(docId) {
157
+ async delete(docId, meta) {
155
158
  const collection = await this.getCollection();
156
- await Promise.all(this.subscribers.deleteOne.map((subscriber) => subscriber(docId)));
159
+ await Promise.all(this.subscribers.deleteOne.map((subscriber) => subscriber(docId, meta)));
157
160
  return collection.deleteOne({ _id: docId });
158
161
  }
159
162
  /**
160
163
  * Deletes multiple documents by their IDs.
161
164
  *
162
165
  * @param docIds - The IDs of the documents to delete.
166
+ * @param meta - Tracks database operation metadata for a single request.
163
167
  * @returns The result of the delete operation.
164
168
  */
165
- async deleteList(docIds) {
169
+ async deleteList(docIds, meta) {
166
170
  const collection = await this.getCollection();
167
171
  const deleteResult = collection.deleteMany({
168
172
  _id: { $in: docIds }
169
173
  });
170
- await Promise.all(this.subscribers.deleteList.map((subscriber) => subscriber(docIds)));
174
+ await Promise.all(this.subscribers.deleteList.map((subscriber) => subscriber(docIds, meta)));
171
175
  return deleteResult;
172
176
  }
173
177
  /**
@@ -185,9 +189,10 @@ export default class BaseRepository {
185
189
  * This base method strips the `_id` before updating.
186
190
  *
187
191
  * @param updatedDoc - The document to update.
192
+ * @param meta - Tracks database operation metadata for a single request.
188
193
  * @returns The result of the update operation.
189
194
  */
190
- async update(updatedDoc) {
195
+ async update(updatedDoc, meta) {
191
196
  const collection = await this.getCollection();
192
197
  await this.validator.validateUpdateObject(updatedDoc);
193
198
  const docId = updatedDoc._id;
@@ -195,7 +200,7 @@ export default class BaseRepository {
195
200
  const result = collection.updateOne({ _id: docId }, {
196
201
  $set: cleanedDoc
197
202
  });
198
- await Promise.all(this.subscribers.updateOne.map((subscriber) => subscriber(updatedDoc)));
203
+ await Promise.all(this.subscribers.updateOne.map((subscriber) => subscriber(updatedDoc, meta)));
199
204
  return result;
200
205
  }
201
206
  /**
@@ -204,9 +209,10 @@ export default class BaseRepository {
204
209
  * This base method strips the `_id` before updating.
205
210
  *
206
211
  * @param updatedDocs - The documents to update.
212
+ * @param meta - Tracks database operation metadata for a single request.
207
213
  * @returns The result of the bulk update operation.
208
214
  */
209
- async updateMany(updatedDocs) {
215
+ async updateMany(updatedDocs, meta) {
210
216
  const collection = await this.getCollection();
211
217
  await Promise.all(updatedDocs.map((doc) => this.validator.validateUpdateObject(doc)));
212
218
  const bulkOps = updatedDocs.map((doc) => {
@@ -219,9 +225,41 @@ export default class BaseRepository {
219
225
  }
220
226
  };
221
227
  });
222
- await Promise.all(this.subscribers.updateMany.map((subscriber) => subscriber(updatedDocs)));
228
+ await Promise.all(this.subscribers.updateMany.map((subscriber) => subscriber(updatedDocs, meta)));
223
229
  return collection.bulkWrite(bulkOps);
224
230
  }
231
+ /**
232
+ * Fetches and caches multiple documents, returning only those not already cached.
233
+ * This method checks the cache in the provided metadata object first, then fetches
234
+ * any missing documents from the database and caches them.
235
+ *
236
+ * @param docIds - The IDs of the documents to fetch.
237
+ * @param meta - The metadata object containing the cache.
238
+ * @returns An array of all documents (from cache and newly fetched).
239
+ */
240
+ async fetchAndCacheDocsForMeta(docIds, meta) {
241
+ const docIdsToFetch = [];
242
+ const cachedDocs = [];
243
+ // Check cache first
244
+ for (const docId of docIds) {
245
+ const cached = meta.getCachedDoc(docId);
246
+ if (cached) {
247
+ cachedDocs.push(cached);
248
+ }
249
+ else {
250
+ docIdsToFetch.push(docId);
251
+ }
252
+ }
253
+ // Fetch uncached docs
254
+ if (docIdsToFetch.length > 0) {
255
+ const fetchedDocs = await this.getList(docIdsToFetch);
256
+ fetchedDocs.forEach((doc) => {
257
+ meta.cacheDoc(doc._id, doc);
258
+ cachedDocs.push(doc);
259
+ });
260
+ }
261
+ return cachedDocs;
262
+ }
225
263
  /**
226
264
  * Gets the filter with the default filter applied if there is one.
227
265
  *
@@ -1 +1 @@
1
- {"version":3,"file":"BaseRepository.js","sourceRoot":"","sources":["../../src/repositories/BaseRepository.ts"],"names":[],"mappings":"AAYA,OAAO,uBAAuB,MAAM,wCAAwC,CAAC;AAC7E,OAAO,eAAe,MAAM,4BAA4B,CAAC;AACzD,OAAO,UAAU,MAAM,uBAAuB,CAAC;AAG/C;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,OAAgB,cAAc;IAkBhC;IACA;IACA;IAnBA,cAAc,CAAS;IAEzB,UAAU,CAAyB;IAEjC,WAAW,GACnB,uBAAuB,CAAC,qBAAqB,EAAa,CAAC;IAE7D;;;;;;;OAOG;IACH,YACE,cAAsB,EACd,SAAgC,EAChC,aAAkC,EAClC,oBAAsE;QAFtE,cAAS,GAAT,SAAS,CAAuB;QAChC,kBAAa,GAAb,aAAa,CAAqB;QAClC,yBAAoB,GAApB,oBAAoB,CAAkD;QAE9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