@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.
Files changed (150) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +46 -10
  3. package/lib/index.d.ts +8 -8
  4. package/lib/index.d.ts.map +1 -1
  5. package/lib/index.js +10 -20
  6. package/lib/index.js.map +1 -0
  7. package/lib/index.ts +21 -0
  8. package/lib/repositories/BaseRepository.d.ts +84 -11
  9. package/lib/repositories/BaseRepository.d.ts.map +1 -1
  10. package/lib/repositories/BaseRepository.js +89 -21
  11. package/lib/repositories/BaseRepository.js.map +1 -0
  12. package/lib/repositories/BaseRepository.ts +339 -0
  13. package/lib/repositories/common/ApiKeyRepository.d.ts +2 -2
  14. package/lib/repositories/common/ApiKeyRepository.d.ts.map +1 -1
  15. package/lib/repositories/common/ApiKeyRepository.js +8 -13
  16. package/lib/repositories/common/ApiKeyRepository.js.map +1 -0
  17. package/lib/repositories/common/ApiKeyRepository.ts +55 -0
  18. package/lib/repositories/common/UserRepository.d.ts +1 -1
  19. package/lib/repositories/common/UserRepository.d.ts.map +1 -1
  20. package/lib/repositories/common/UserRepository.js +15 -20
  21. package/lib/repositories/common/UserRepository.js.map +1 -0
  22. package/lib/repositories/common/UserRepository.ts +65 -0
  23. package/lib/repositories/dashboard/DashboardBaseRepository.d.ts +2 -2
  24. package/lib/repositories/dashboard/DashboardBaseRepository.d.ts.map +1 -1
  25. package/lib/repositories/dashboard/DashboardBaseRepository.js +6 -11
  26. package/lib/repositories/dashboard/DashboardBaseRepository.js.map +1 -0
  27. package/lib/repositories/dashboard/DashboardBaseRepository.ts +31 -0
  28. package/lib/repositories/dashboard/DashboardNonogramKatanaItemRepository.d.ts +2 -2
  29. package/lib/repositories/dashboard/DashboardNonogramKatanaItemRepository.d.ts.map +1 -1
  30. package/lib/repositories/dashboard/DashboardNonogramKatanaItemRepository.js +7 -12
  31. package/lib/repositories/dashboard/DashboardNonogramKatanaItemRepository.js.map +1 -0
  32. package/lib/repositories/dashboard/DashboardNonogramKatanaItemRepository.ts +64 -0
  33. package/lib/repositories/dashboard/DashboardNonogramKatanaUpgradeRepository.d.ts +2 -2
  34. package/lib/repositories/dashboard/DashboardNonogramKatanaUpgradeRepository.d.ts.map +1 -1
  35. package/lib/repositories/dashboard/DashboardNonogramKatanaUpgradeRepository.js +7 -12
  36. package/lib/repositories/dashboard/DashboardNonogramKatanaUpgradeRepository.js.map +1 -0
  37. package/lib/repositories/dashboard/DashboardNonogramKatanaUpgradeRepository.ts +66 -0
  38. package/lib/repositories/dashboard/DashboardTaskRepository.d.ts +17 -4
  39. package/lib/repositories/dashboard/DashboardTaskRepository.d.ts.map +1 -1
  40. package/lib/repositories/dashboard/DashboardTaskRepository.js +26 -18
  41. package/lib/repositories/dashboard/DashboardTaskRepository.js.map +1 -0
  42. package/lib/repositories/dashboard/DashboardTaskRepository.ts +166 -0
  43. package/lib/repositories/dashboard/DashboardUserConfigRepository.d.ts +29 -5
  44. package/lib/repositories/dashboard/DashboardUserConfigRepository.d.ts.map +1 -1
  45. package/lib/repositories/dashboard/DashboardUserConfigRepository.js +38 -19
  46. package/lib/repositories/dashboard/DashboardUserConfigRepository.js.map +1 -0
  47. package/lib/repositories/dashboard/DashboardUserConfigRepository.ts +254 -0
  48. package/lib/services/MigrationService.d.ts.map +1 -1
  49. package/lib/services/MigrationService.js +10 -15
  50. package/lib/services/MigrationService.js.map +1 -0
  51. package/lib/services/MigrationService.ts +52 -0
  52. package/lib/services/RepoSubscriptionService.d.ts.map +1 -1
  53. package/lib/services/RepoSubscriptionService.js +2 -4
  54. package/lib/services/RepoSubscriptionService.js.map +1 -0
  55. package/lib/services/RepoSubscriptionService.ts +63 -0
  56. package/lib/tests/globalTestVariables.d.ts +5 -0
  57. package/lib/tests/globalTestVariables.d.ts.map +1 -0
  58. package/lib/tests/globalTestVariables.js +5 -0
  59. package/lib/tests/globalTestVariables.js.map +1 -0
  60. package/lib/tests/globalTestVariables.ts +4 -0
  61. package/lib/tests/repositories/BaseRepository.spec.ts +61 -0
  62. package/lib/tests/repositories/common/UserRepository.spec.ts +113 -0
  63. package/lib/tests/repositories/dashboard/NonogramKatanaItemRepository.spec.ts +55 -0
  64. package/lib/tests/repositories/dashboard/NonogramKatanaUpgradeRepository.spec.ts +14 -0
  65. package/lib/tests/repositories/dashboard/TaskRepository.spec.ts +101 -0
  66. package/lib/tests/repositories/dashboard/UserConfigRepository.spec.ts +155 -0
  67. package/lib/tests/testsUtil.d.ts +20 -4
  68. package/lib/tests/testsUtil.d.ts.map +1 -1
  69. package/lib/tests/testsUtil.js +29 -20
  70. package/lib/tests/testsUtil.js.map +1 -0
  71. package/lib/tests/testsUtil.ts +68 -0
  72. package/lib/util/DbSchemaUpdater.d.ts.map +1 -1
  73. package/lib/util/DbSchemaUpdater.js +10 -15
  74. package/lib/util/DbSchemaUpdater.js.map +1 -0
  75. package/lib/util/DbSchemaUpdater.ts +16 -0
  76. package/lib/util/DocumentCleaner.d.ts.map +1 -1
  77. package/lib/util/DocumentCleaner.js +2 -4
  78. package/lib/util/DocumentCleaner.js.map +1 -0
  79. package/lib/util/DocumentCleaner.ts +31 -0
  80. package/lib/util/DocumentDb.d.ts +4 -1
  81. package/lib/util/DocumentDb.d.ts.map +1 -1
  82. package/lib/util/DocumentDb.js +11 -10
  83. package/lib/util/DocumentDb.js.map +1 -0
  84. package/lib/util/DocumentDb.ts +47 -0
  85. package/lib/validators/BaseValidator.d.ts +11 -0
  86. package/lib/validators/BaseValidator.d.ts.map +1 -1
  87. package/lib/validators/BaseValidator.js +26 -18
  88. package/lib/validators/BaseValidator.js.map +1 -0
  89. package/lib/validators/BaseValidator.ts +150 -0
  90. package/lib/validators/common/ApiKeyValidator.d.ts +1 -1
  91. package/lib/validators/common/ApiKeyValidator.d.ts.map +1 -1
  92. package/lib/validators/common/ApiKeyValidator.js +16 -21
  93. package/lib/validators/common/ApiKeyValidator.js.map +1 -0
  94. package/lib/validators/common/ApiKeyValidator.ts +67 -0
  95. package/lib/validators/common/UserValidator.d.ts +14 -1
  96. package/lib/validators/common/UserValidator.d.ts.map +1 -1
  97. package/lib/validators/common/UserValidator.js +29 -21
  98. package/lib/validators/common/UserValidator.js.map +1 -0
  99. package/lib/validators/common/UserValidator.ts +98 -0
  100. package/lib/validators/dashboard/NonogramKatanaItemValidator.d.ts +1 -1
  101. package/lib/validators/dashboard/NonogramKatanaItemValidator.d.ts.map +1 -1
  102. package/lib/validators/dashboard/NonogramKatanaItemValidator.js +16 -21
  103. package/lib/validators/dashboard/NonogramKatanaItemValidator.js.map +1 -0
  104. package/lib/validators/dashboard/NonogramKatanaItemValidator.ts +78 -0
  105. package/lib/validators/dashboard/NonogramKatanaUpgradeValidator.d.ts +1 -1
  106. package/lib/validators/dashboard/NonogramKatanaUpgradeValidator.d.ts.map +1 -1
  107. package/lib/validators/dashboard/NonogramKatanaUpgradeValidator.js +16 -21
  108. package/lib/validators/dashboard/NonogramKatanaUpgradeValidator.js.map +1 -0
  109. package/lib/validators/dashboard/NonogramKatanaUpgradeValidator.ts +78 -0
  110. package/lib/validators/dashboard/TaskValidator.d.ts +1 -1
  111. package/lib/validators/dashboard/TaskValidator.d.ts.map +1 -1
  112. package/lib/validators/dashboard/TaskValidator.js +15 -20
  113. package/lib/validators/dashboard/TaskValidator.js.map +1 -0
  114. package/lib/validators/dashboard/TaskValidator.ts +105 -0
  115. package/lib/validators/dashboard/UserConfigValidator.d.ts +1 -1
  116. package/lib/validators/dashboard/UserConfigValidator.d.ts.map +1 -1
  117. package/lib/validators/dashboard/UserConfigValidator.js +19 -24
  118. package/lib/validators/dashboard/UserConfigValidator.js.map +1 -0
  119. package/lib/validators/dashboard/UserConfigValidator.ts +112 -0
  120. package/package.json +44 -38
  121. package/lib/scripts/migrate.d.ts +0 -2
  122. package/lib/scripts/migrate.d.ts.map +0 -1
  123. package/lib/scripts/migrate.js +0 -7
  124. package/lib/scripts/migrateDry.d.ts +0 -2
  125. package/lib/scripts/migrateDry.d.ts.map +0 -1
  126. package/lib/scripts/migrateDry.js +0 -7
  127. package/lib/scripts/validateSchema.d.ts +0 -2
  128. package/lib/scripts/validateSchema.d.ts.map +0 -1
  129. package/lib/scripts/validateSchema.js +0 -9
  130. package/lib/scripts/validateSchemaDryRun.d.ts +0 -2
  131. package/lib/scripts/validateSchemaDryRun.d.ts.map +0 -1
  132. package/lib/scripts/validateSchemaDryRun.js +0 -9
  133. package/lib/tests/repositories/BaseRepository.spec.d.ts +0 -2
  134. package/lib/tests/repositories/BaseRepository.spec.d.ts.map +0 -1
  135. package/lib/tests/repositories/BaseRepository.spec.js +0 -52
  136. package/lib/tests/repositories/common/UserRepository.spec.d.ts +0 -2
  137. package/lib/tests/repositories/common/UserRepository.spec.d.ts.map +0 -1
  138. package/lib/tests/repositories/common/UserRepository.spec.js +0 -108
  139. package/lib/tests/repositories/dashboard/NonogramKatanaItemRepository.spec.d.ts +0 -2
  140. package/lib/tests/repositories/dashboard/NonogramKatanaItemRepository.spec.d.ts.map +0 -1
  141. package/lib/tests/repositories/dashboard/NonogramKatanaItemRepository.spec.js +0 -39
  142. package/lib/tests/repositories/dashboard/NonogramKatanaUpgradeRepository.spec.d.ts +0 -2
  143. package/lib/tests/repositories/dashboard/NonogramKatanaUpgradeRepository.spec.d.ts.map +0 -1
  144. package/lib/tests/repositories/dashboard/NonogramKatanaUpgradeRepository.spec.js +0 -16
  145. package/lib/tests/repositories/dashboard/TaskRepository.spec.d.ts +0 -2
  146. package/lib/tests/repositories/dashboard/TaskRepository.spec.d.ts.map +0 -1
  147. package/lib/tests/repositories/dashboard/TaskRepository.spec.js +0 -84
  148. package/lib/tests/repositories/dashboard/UserConfigRepository.spec.d.ts +0 -2
  149. package/lib/tests/repositories/dashboard/UserConfigRepository.spec.d.ts.map +0 -1
  150. package/lib/tests/repositories/dashboard/UserConfigRepository.spec.js +0 -115
@@ -0,0 +1,339 @@
1
+ import { BaseDocument } from '@aneuhold/core-ts-db-lib';
2
+ import { Document, ObjectId } from 'bson';
3
+ import {
4
+ AnyBulkWriteOperation,
5
+ BulkWriteResult,
6
+ Collection,
7
+ DeleteResult,
8
+ Filter,
9
+ OptionalUnlessRequiredId,
10
+ UpdateResult
11
+ } from 'mongodb';
12
+ import RepoSubscriptionService, {
13
+ RepoListeners,
14
+ RepoSubscribers
15
+ } from '../services/RepoSubscriptionService.js';
16
+ import DocumentCleaner from '../util/DocumentCleaner.js';
17
+ import DocumentDb from '../util/DocumentDb.js';
18
+ import IValidator from '../validators/BaseValidator.js';
19
+
20
+ /**
21
+ * Base repository class for handling common database operations.
22
+ *
23
+ * @template TBasetype - The type of the documents in the collection.
24
+ */
25
+ export default abstract class BaseRepository<TBasetype extends BaseDocument> {
26
+ protected collectionName: string;
27
+
28
+ private collection?: Collection<TBasetype>;
29
+
30
+ protected subscribers: RepoSubscribers<TBasetype> =
31
+ RepoSubscriptionService.getDefaultSubscribers<TBasetype>();
32
+
33
+ /**
34
+ * Constructs a new base repository.
35
+ *
36
+ * @param collectionName - The name of the collection.
37
+ * @param validator - The validator for the document type.
38
+ * @param defaultFilter - The default filter to apply to queries.
39
+ * @param defaultUpdateCleaner - A function to clean update objects before sending to the DB.
40
+ */
41
+ constructor(
42
+ collectionName: string,
43
+ private validator: IValidator<TBasetype>,
44
+ private defaultFilter?: Partial<TBasetype>,
45
+ private defaultUpdateCleaner?: (
46
+ doc: Partial<TBasetype>
47
+ ) => Partial<TBasetype>
48
+ ) {
49
+ this.collectionName = collectionName;
50
+ }
51
+
52
+ /**
53
+ * Gets the collection, initializing it if necessary.
54
+ *
55
+ * @returns The collection.
56
+ */
57
+ protected async getCollection(): Promise<Collection<TBasetype>> {
58
+ if (!this.collection) {
59
+ this.collection = await DocumentDb.getCollection(this.collectionName);
60
+ this.setupSubscribers();
61
+ }
62
+ return this.collection;
63
+ }
64
+
65
+ protected abstract setupSubscribers(): void;
66
+
67
+ /**
68
+ * Registers a set of functions that will be called when a change happens
69
+ * in this repository.
70
+ *
71
+ * @param listeners - The listeners to register.
72
+ */
73
+ subscribeToChanges(listeners: RepoListeners<TBasetype>) {
74
+ const { insertNew, updateOne, updateMany, deleteOne, deleteList } =
75
+ listeners;
76
+ if (insertNew) {
77
+ this.subscribers.insertNew.push(insertNew);
78
+ }
79
+ if (updateOne) {
80
+ this.subscribers.updateOne.push(updateOne);
81
+ }
82
+ if (updateMany) {
83
+ this.subscribers.updateMany.push(updateMany);
84
+ }
85
+ if (deleteOne) {
86
+ this.subscribers.deleteOne.push(deleteOne);
87
+ }
88
+ if (deleteList) {
89
+ this.subscribers.deleteList.push(deleteList);
90
+ }
91
+ }
92
+
93
+ /**
94
+ * Inserts a new document into the collection.
95
+ *
96
+ * @param newDoc - The new document to insert.
97
+ * @returns The inserted document or null if the insertion failed.
98
+ */
99
+ async insertNew(newDoc: TBasetype): Promise<TBasetype | null> {
100
+ const collection = await this.getCollection();
101
+ await this.validator.validateNewObject(newDoc);
102
+ const insertResult = await collection.insertOne(
103
+ newDoc as OptionalUnlessRequiredId<TBasetype>
104
+ );
105
+ if (!insertResult.acknowledged) {
106
+ return null;
107
+ }
108
+ await Promise.all(
109
+ this.subscribers.insertNew.map((subscriber) => subscriber(newDoc))
110
+ );
111
+ return newDoc;
112
+ }
113
+
114
+ /**
115
+ * Inserts multiple new documents into the collection.
116
+ *
117
+ * @param newDocs - The new documents to insert.
118
+ * @returns The inserted documents or an empty array if the insertion failed.
119
+ */
120
+ async insertMany(newDocs: TBasetype[]): Promise<TBasetype[]> {
121
+ const collection = await this.getCollection();
122
+ await Promise.all(
123
+ newDocs.map((doc) => this.validator.validateNewObject(doc))
124
+ );
125
+ const insertResult = await collection.insertMany(
126
+ newDocs as OptionalUnlessRequiredId<TBasetype>[]
127
+ );
128
+ if (!insertResult.acknowledged) {
129
+ return [];
130
+ }
131
+ await Promise.all(
132
+ this.subscribers.insertMany.map((subscriber) => subscriber(newDocs))
133
+ );
134
+ return newDocs;
135
+ }
136
+
137
+ /**
138
+ * Retrieves a document matching the given filter.
139
+ *
140
+ * @param filter - The filter to apply.
141
+ * @returns The matching document or null if no document was found.
142
+ */
143
+ async get(filter: Partial<TBasetype>): Promise<TBasetype | null> {
144
+ const collection = await this.getCollection();
145
+ const result = await collection.findOne(this.getFilterWithDefault(filter));
146
+ return result as TBasetype | null;
147
+ }
148
+
149
+ /**
150
+ * Retrieves all documents in the collection.
151
+ *
152
+ * @returns An array of all documents in the collection.
153
+ */
154
+ async getAll(): Promise<TBasetype[]> {
155
+ const collection = await this.getCollection();
156
+ const result = await collection.find(this.getFilterWithDefault()).toArray();
157
+ // Set to unknown first because of some weird type things.
158
+ return result as unknown as TBasetype[];
159
+ }
160
+
161
+ /**
162
+ * Gets all the IDs in the collection as a hash for performant lookups.
163
+ *
164
+ * @returns An object where the keys are document IDs and the values are true.
165
+ */
166
+ async getAllIdsAsHash(): Promise<{ [id: string]: boolean }> {
167
+ const allDocs = await this.getAll();
168
+ return allDocs.reduce<{ [id: string]: boolean }>((acc, doc) => {
169
+ acc[doc._id.toString()] = true;
170
+ return acc;
171
+ }, {});
172
+ }
173
+
174
+ /**
175
+ * Retrieves a list of documents matching the given IDs.
176
+ *
177
+ * @param docIds - The IDs of the documents to retrieve.
178
+ * @returns An array of matching documents.
179
+ */
180
+ async getList(docIds: ObjectId[]): Promise<TBasetype[]> {
181
+ const collection = await this.getCollection();
182
+ const result = await collection
183
+ .find(this.getFilterWithDefault({ _id: { $in: docIds } }))
184
+ .toArray();
185
+ return result as TBasetype[];
186
+ }
187
+
188
+ /**
189
+ * Deletes a document by its ID.
190
+ *
191
+ * @param docId - The ID of the document to delete.
192
+ * @returns The result of the delete operation.
193
+ */
194
+ async delete(docId: ObjectId): Promise<DeleteResult> {
195
+ const collection = await this.getCollection();
196
+ await Promise.all(
197
+ this.subscribers.deleteOne.map((subscriber) => subscriber(docId))
198
+ );
199
+ return collection.deleteOne({ _id: docId } as Filter<TBasetype>);
200
+ }
201
+
202
+ /**
203
+ * Deletes multiple documents by their IDs.
204
+ *
205
+ * @param docIds - The IDs of the documents to delete.
206
+ * @returns The result of the delete operation.
207
+ */
208
+ async deleteList(docIds: ObjectId[]): Promise<DeleteResult> {
209
+ const collection = await this.getCollection();
210
+ const deleteResult = collection.deleteMany({
211
+ _id: { $in: docIds }
212
+ } as Filter<TBasetype>);
213
+ await Promise.all(
214
+ this.subscribers.deleteList.map((subscriber) => subscriber(docIds))
215
+ );
216
+ return deleteResult;
217
+ }
218
+
219
+ /**
220
+ * This should not be used except for testing purposes
221
+ *
222
+ * @returns The result of the delete operation.
223
+ */
224
+ async deleteAll(): Promise<DeleteResult> {
225
+ const collection = await this.getCollection();
226
+ return collection.deleteMany(this.getFilterWithDefault());
227
+ }
228
+
229
+ /**
230
+ * Updates the provided document in the DB.
231
+ *
232
+ * This base method strips the `_id` before updating.
233
+ *
234
+ * @param updatedDoc - The document to update.
235
+ * @returns The result of the update operation.
236
+ */
237
+ async update(updatedDoc: Partial<TBasetype>): Promise<UpdateResult> {
238
+ const collection = await this.getCollection();
239
+ await this.validator.validateUpdateObject(updatedDoc);
240
+
241
+ const docId = updatedDoc._id;
242
+
243
+ const cleanedDoc = this.cleanUpdateObject(updatedDoc);
244
+
245
+ const result = collection.updateOne({ _id: docId } as Filter<TBasetype>, {
246
+ $set: cleanedDoc
247
+ });
248
+ await Promise.all(
249
+ this.subscribers.updateOne.map((subscriber) => subscriber(updatedDoc))
250
+ );
251
+ return result;
252
+ }
253
+
254
+ /**
255
+ * Updates the provided documents in the DB.
256
+ *
257
+ * This base method strips the `_id` before updating.
258
+ *
259
+ * @param updatedDocs - The documents to update.
260
+ * @returns The result of the bulk update operation.
261
+ */
262
+ async updateMany(
263
+ updatedDocs: Array<Partial<TBasetype>>
264
+ ): Promise<BulkWriteResult> {
265
+ const collection = await this.getCollection();
266
+ await Promise.all(
267
+ updatedDocs.map((doc) => this.validator.validateUpdateObject(doc))
268
+ );
269
+
270
+ const bulkOps = updatedDocs.map((doc) => {
271
+ const docId = doc._id;
272
+ const cleanedDoc = this.cleanUpdateObject(doc);
273
+ return {
274
+ updateOne: {
275
+ filter: { _id: docId },
276
+ update: { $set: cleanedDoc }
277
+ }
278
+ };
279
+ }) as AnyBulkWriteOperation<TBasetype>[];
280
+
281
+ await Promise.all(
282
+ this.subscribers.updateMany.map((subscriber) => subscriber(updatedDocs))
283
+ );
284
+
285
+ return collection.bulkWrite(bulkOps);
286
+ }
287
+
288
+ /**
289
+ * Gets the filter with the default filter applied if there is one.
290
+ *
291
+ * This is purposefully changing the type because of some weird restrictions
292
+ * with the `mongodb` package types.
293
+ *
294
+ * @param filter - The filter to apply.
295
+ * @returns The filter with the default filter applied.
296
+ */
297
+ protected getFilterWithDefault(
298
+ filter: Filter<Document> = {}
299
+ ): Filter<Document> {
300
+ if (!this.defaultFilter) {
301
+ return filter;
302
+ }
303
+ return { ...filter, ...this.defaultFilter };
304
+ }
305
+
306
+ /**
307
+ * Checks if two arrays of {@link ObjectId} are equal.
308
+ *
309
+ * @param array1 - The first array.
310
+ * @param array2 - The second array.
311
+ * @returns True if the arrays are equal, false otherwise.
312
+ */
313
+ protected objectIdArraysAreEqual(
314
+ array1: ObjectId[],
315
+ array2: ObjectId[]
316
+ ): boolean {
317
+ if (array1.length !== array2.length) {
318
+ return false;
319
+ }
320
+ return array1.every((id) => array2.includes(id));
321
+ }
322
+
323
+ /**
324
+ * Cleans the update object by removing the `_id` field and running the
325
+ * default update cleaner if there is one.
326
+ *
327
+ * Returns a shallow copy of the object.
328
+ *
329
+ * @param updatedDoc - The document to clean.
330
+ * @returns The cleaned document.
331
+ */
332
+ private cleanUpdateObject(
333
+ updatedDoc: Partial<TBasetype>
334
+ ): Partial<TBasetype> {
335
+ return this.defaultUpdateCleaner
336
+ ? this.defaultUpdateCleaner(DocumentCleaner.id(updatedDoc))
337
+ : DocumentCleaner.id(updatedDoc);
338
+ }
339
+ }
@@ -1,6 +1,6 @@
1
1
  import { ApiKey, User } from '@aneuhold/core-ts-db-lib';
2
- import BaseRepository from '../BaseRepository';
3
- import { RepoListeners } from '../../services/RepoSubscriptionService';
2
+ import { RepoListeners } from '../../services/RepoSubscriptionService.js';
3
+ import BaseRepository from '../BaseRepository.js';
4
4
  /**
5
5
  * The repository that contains {@link ApiKey} documents.
6
6
  */
@@ -1 +1 @@
1
- {"version":3,"file":"ApiKeyRepository.d.ts","sourceRoot":"","sources":["../../../src/repositories/common/ApiKeyRepository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AAEvE;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,cAAc,CAAC,MAAM,CAAC;IAClE,OAAO,CAAC,MAAM,CAAC,eAAe,CAAa;IAE3C,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAA+B;IAE/D,MAAM,CAAC,uBAAuB,IAAI,aAAa,CAAC,IAAI,CAAC;IA0BrD,OAAO;IAIP,SAAS,CAAC,gBAAgB,IAAI,IAAI;IAElC;;OAEG;WACW,OAAO;CAMtB"}
1
+ {"version":3,"file":"ApiKeyRepository.d.ts","sourceRoot":"./src/","sources":["repositories/common/ApiKeyRepository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAC;AAE1E,OAAO,cAAc,MAAM,sBAAsB,CAAC;AAElD;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,cAAc,CAAC,MAAM,CAAC;IAClE,OAAO,CAAC,MAAM,CAAC,eAAe,CAAa;IAE3C,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAA+B;IAE/D,MAAM,CAAC,uBAAuB,IAAI,aAAa,CAAC,IAAI,CAAC;IA0BrD,OAAO;IAIP,SAAS,CAAC,gBAAgB,IAAI,IAAI;IAElC;;OAEG;WACW,OAAO,IAAI,gBAAgB;CAM1C"}
@@ -1,15 +1,10 @@
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 BaseRepository_1 = __importDefault(require("../BaseRepository"));
8
- const ApiKeyValidator_1 = __importDefault(require("../../validators/common/ApiKeyValidator"));
1
+ import { ApiKey } from '@aneuhold/core-ts-db-lib';
2
+ import ApiKeyValidator from '../../validators/common/ApiKeyValidator.js';
3
+ import BaseRepository from '../BaseRepository.js';
9
4
  /**
10
5
  * The repository that contains {@link ApiKey} documents.
11
6
  */
12
- class ApiKeyRepository extends BaseRepository_1.default {
7
+ export default class ApiKeyRepository extends BaseRepository {
13
8
  static COLLECTION_NAME = 'apiKeys';
14
9
  static singletonInstance;
15
10
  static getListenersForUserRepo() {
@@ -26,15 +21,15 @@ class ApiKeyRepository extends BaseRepository_1.default {
26
21
  });
27
22
  },
28
23
  insertNew: async (user) => {
29
- await apiKeyRepo.insertNew(new core_ts_db_lib_1.ApiKey(user._id));
24
+ await apiKeyRepo.insertNew(new ApiKey(user._id));
30
25
  },
31
26
  insertMany: async (users) => {
32
- await apiKeyRepo.insertMany(users.map((user) => new core_ts_db_lib_1.ApiKey(user._id)));
27
+ await apiKeyRepo.insertMany(users.map((user) => new ApiKey(user._id)));
33
28
  }
34
29
  };
35
30
  }
36
31
  constructor() {
37
- super(ApiKeyRepository.COLLECTION_NAME, new ApiKeyValidator_1.default());
32
+ super(ApiKeyRepository.COLLECTION_NAME, new ApiKeyValidator());
38
33
  }
39
34
  setupSubscribers() { }
40
35
  /**
@@ -47,4 +42,4 @@ class ApiKeyRepository extends BaseRepository_1.default {
47
42
  return ApiKeyRepository.singletonInstance;
48
43
  }
49
44
  }
50
- exports.default = ApiKeyRepository;
45
+ //# sourceMappingURL=ApiKeyRepository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApiKeyRepository.js","sourceRoot":"./src/","sources":["repositories/common/ApiKeyRepository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAQ,MAAM,0BAA0B,CAAC;AAExD,OAAO,eAAe,MAAM,4CAA4C,CAAC;AACzE,OAAO,cAAc,MAAM,sBAAsB,CAAC;AAElD;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,cAAsB;IAC1D,MAAM,CAAC,eAAe,GAAG,SAAS,CAAC;IAEnC,MAAM,CAAC,iBAAiB,CAA+B;IAE/D,MAAM,CAAC,uBAAuB;QAC5B,MAAM,UAAU,GAAG,gBAAgB,CAAC,OAAO,EAAE,CAAC;QAC9C,OAAO;YACL,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;gBAC1B,MAAM,CACJ,MAAM,UAAU,CAAC,aAAa,EAAE,CACjC,CAAC,SAAS,CAAC;oBACV,MAAM;iBACP,CAAC,CAAC;YACL,CAAC;YACD,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;gBAC5B,MAAM,CACJ,MAAM,UAAU,CAAC,aAAa,EAAE,CACjC,CAAC,UAAU,CAAC;oBACX,MAAM,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE;iBACzB,CAAC,CAAC;YACL,CAAC;YACD,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;gBACxB,MAAM,UAAU,CAAC,SAAS,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;YACnD,CAAC;YACD,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;gBAC1B,MAAM,UAAU,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YACzE,CAAC;SACF,CAAC;IACJ,CAAC;IAED;QACE,KAAK,CAAC,gBAAgB,CAAC,eAAe,EAAE,IAAI,eAAe,EAAE,CAAC,CAAC;IACjE,CAAC;IAES,gBAAgB,KAAU,CAAC;IAErC;;OAEG;IACI,MAAM,CAAC,OAAO;QACnB,IAAI,CAAC,gBAAgB,CAAC,iBAAiB,EAAE,CAAC;YACxC,gBAAgB,CAAC,iBAAiB,GAAG,IAAI,gBAAgB,EAAE,CAAC;QAC9D,CAAC;QACD,OAAO,gBAAgB,CAAC,iBAAiB,CAAC;IAC5C,CAAC"}
@@ -0,0 +1,55 @@
1
+ import { ApiKey, User } from '@aneuhold/core-ts-db-lib';
2
+ import { RepoListeners } from '../../services/RepoSubscriptionService.js';
3
+ import ApiKeyValidator from '../../validators/common/ApiKeyValidator.js';
4
+ import BaseRepository from '../BaseRepository.js';
5
+
6
+ /**
7
+ * The repository that contains {@link ApiKey} documents.
8
+ */
9
+ export default class ApiKeyRepository extends BaseRepository<ApiKey> {
10
+ private static COLLECTION_NAME = 'apiKeys';
11
+
12
+ private static singletonInstance: ApiKeyRepository | undefined;
13
+
14
+ static getListenersForUserRepo(): RepoListeners<User> {
15
+ const apiKeyRepo = ApiKeyRepository.getRepo();
16
+ return {
17
+ deleteOne: async (userId) => {
18
+ await (
19
+ await apiKeyRepo.getCollection()
20
+ ).deleteOne({
21
+ userId
22
+ });
23
+ },
24
+ deleteList: async (userIds) => {
25
+ await (
26
+ await apiKeyRepo.getCollection()
27
+ ).deleteMany({
28
+ userId: { $in: userIds }
29
+ });
30
+ },
31
+ insertNew: async (user) => {
32
+ await apiKeyRepo.insertNew(new ApiKey(user._id));
33
+ },
34
+ insertMany: async (users) => {
35
+ await apiKeyRepo.insertMany(users.map((user) => new ApiKey(user._id)));
36
+ }
37
+ };
38
+ }
39
+
40
+ private constructor() {
41
+ super(ApiKeyRepository.COLLECTION_NAME, new ApiKeyValidator());
42
+ }
43
+
44
+ protected setupSubscribers(): void {}
45
+
46
+ /**
47
+ * Gets the singleton instance of the {@link ApiKeyRepository}.
48
+ */
49
+ public static getRepo(): ApiKeyRepository {
50
+ if (!ApiKeyRepository.singletonInstance) {
51
+ ApiKeyRepository.singletonInstance = new ApiKeyRepository();
52
+ }
53
+ return ApiKeyRepository.singletonInstance;
54
+ }
55
+ }
@@ -1,6 +1,6 @@
1
1
  import { User, UserCTO } from '@aneuhold/core-ts-db-lib';
2
2
  import { ObjectId } from 'bson';
3
- import BaseRepository from '../BaseRepository';
3
+ import BaseRepository from '../BaseRepository.js';
4
4
  /**
5
5
  * The repository that contains {@link User} documents.
6
6
  */
@@ -1 +1 @@
1
- {"version":3,"file":"UserRepository.d.ts","sourceRoot":"","sources":["../../../src/repositories/common/UserRepository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAChC,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAQ/C;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,cAAc,CAAC,IAAI,CAAC;IAC9D,OAAO,CAAC,MAAM,CAAC,eAAe,CAAW;IAEzC,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAA6B;IAE7D,OAAO;IAIP,SAAS,CAAC,gBAAgB,IAAI,IAAI;IAclC;;OAEG;IACH,MAAM,CAAC,OAAO;IAOR,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;IAW/D,gBAAgB,CAAC,OAAO,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;CAOhE"}
1
+ {"version":3,"file":"UserRepository.d.ts","sourceRoot":"./src/","sources":["repositories/common/UserRepository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAEhC,OAAO,cAAc,MAAM,sBAAsB,CAAC;AAOlD;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,cAAc,CAAC,IAAI,CAAC;IAC9D,OAAO,CAAC,MAAM,CAAC,eAAe,CAAW;IAEzC,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAA6B;IAE7D,OAAO;IAIP,SAAS,CAAC,gBAAgB,IAAI,IAAI;IAclC;;OAEG;IACH,MAAM,CAAC,OAAO,IAAI,cAAc;IAO1B,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;IAW/D,gBAAgB,CAAC,OAAO,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;CAOhE"}
@@ -1,30 +1,25 @@
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 BaseRepository_1 = __importDefault(require("../BaseRepository"));
7
- const UserValidator_1 = __importDefault(require("../../validators/common/UserValidator"));
8
- const ApiKeyRepository_1 = __importDefault(require("./ApiKeyRepository"));
9
- const DashboardUserConfigRepository_1 = __importDefault(require("../dashboard/DashboardUserConfigRepository"));
10
- const DashboardTaskRepository_1 = __importDefault(require("../dashboard/DashboardTaskRepository"));
11
- const DashboardNonogramKatanaItemRepository_1 = __importDefault(require("../dashboard/DashboardNonogramKatanaItemRepository"));
12
- const DashboardNonogramKatanaUpgradeRepository_1 = __importDefault(require("../dashboard/DashboardNonogramKatanaUpgradeRepository"));
1
+ import UserValidator from '../../validators/common/UserValidator.js';
2
+ import BaseRepository from '../BaseRepository.js';
3
+ import DashboardNonogramKatanaItemRepository from '../dashboard/DashboardNonogramKatanaItemRepository.js';
4
+ import DashboardNonogramKatanaUpgradeRepository from '../dashboard/DashboardNonogramKatanaUpgradeRepository.js';
5
+ import DashboardTaskRepository from '../dashboard/DashboardTaskRepository.js';
6
+ import DashboardUserConfigRepository from '../dashboard/DashboardUserConfigRepository.js';
7
+ import ApiKeyRepository from './ApiKeyRepository.js';
13
8
  /**
14
9
  * The repository that contains {@link User} documents.
15
10
  */
16
- class UserRepository extends BaseRepository_1.default {
11
+ export default class UserRepository extends BaseRepository {
17
12
  static COLLECTION_NAME = 'users';
18
13
  static singletonInstance;
19
14
  constructor() {
20
- super(UserRepository.COLLECTION_NAME, new UserValidator_1.default());
15
+ super(UserRepository.COLLECTION_NAME, new UserValidator());
21
16
  }
22
17
  setupSubscribers() {
23
- this.subscribeToChanges(ApiKeyRepository_1.default.getListenersForUserRepo());
24
- this.subscribeToChanges(DashboardUserConfigRepository_1.default.getListenersForUserRepo());
25
- this.subscribeToChanges(DashboardTaskRepository_1.default.getListenersForUserRepo());
26
- this.subscribeToChanges(DashboardNonogramKatanaItemRepository_1.default.getListenersForUserRepo());
27
- this.subscribeToChanges(DashboardNonogramKatanaUpgradeRepository_1.default.getListenersForUserRepo());
18
+ this.subscribeToChanges(ApiKeyRepository.getListenersForUserRepo());
19
+ this.subscribeToChanges(DashboardUserConfigRepository.getListenersForUserRepo());
20
+ this.subscribeToChanges(DashboardTaskRepository.getListenersForUserRepo());
21
+ this.subscribeToChanges(DashboardNonogramKatanaItemRepository.getListenersForUserRepo());
22
+ this.subscribeToChanges(DashboardNonogramKatanaUpgradeRepository.getListenersForUserRepo());
28
23
  }
29
24
  /**
30
25
  * Gets the singleton instance of the {@link UserRepository}.
@@ -53,4 +48,4 @@ class UserRepository extends BaseRepository_1.default {
53
48
  }));
54
49
  }
55
50
  }
56
- exports.default = UserRepository;
51
+ //# sourceMappingURL=UserRepository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UserRepository.js","sourceRoot":"./src/","sources":["repositories/common/UserRepository.ts"],"names":[],"mappings":"AAEA,OAAO,aAAa,MAAM,0CAA0C,CAAC;AACrE,OAAO,cAAc,MAAM,sBAAsB,CAAC;AAClD,OAAO,qCAAqC,MAAM,uDAAuD,CAAC;AAC1G,OAAO,wCAAwC,MAAM,0DAA0D,CAAC;AAChH,OAAO,uBAAuB,MAAM,yCAAyC,CAAC;AAC9E,OAAO,6BAA6B,MAAM,+CAA+C,CAAC;AAC1F,OAAO,gBAAgB,MAAM,uBAAuB,CAAC;AAErD;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,cAAoB;IACtD,MAAM,CAAC,eAAe,GAAG,OAAO,CAAC;IAEjC,MAAM,CAAC,iBAAiB,CAA6B;IAE7D;QACE,KAAK,CAAC,cAAc,CAAC,eAAe,EAAE,IAAI,aAAa,EAAE,CAAC,CAAC;IAC7D,CAAC;IAES,gBAAgB;QACxB,IAAI,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,uBAAuB,EAAE,CAAC,CAAC;QACpE,IAAI,CAAC,kBAAkB,CACrB,6BAA6B,CAAC,uBAAuB,EAAE,CACxD,CAAC;QACF,IAAI,CAAC,kBAAkB,CAAC,uBAAuB,CAAC,uBAAuB,EAAE,CAAC,CAAC;QAC3E,IAAI,CAAC,kBAAkB,CACrB,qCAAqC,CAAC,uBAAuB,EAAE,CAChE,CAAC;QACF,IAAI,CAAC,kBAAkB,CACrB,wCAAwC,CAAC,uBAAuB,EAAE,CACnE,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,OAAO;QACZ,IAAI,CAAC,cAAc,CAAC,iBAAiB,EAAE,CAAC;YACtC,cAAc,CAAC,iBAAiB,GAAG,IAAI,cAAc,EAAE,CAAC;QAC1D,CAAC;QACD,OAAO,cAAc,CAAC,iBAAiB,CAAC;IAC1C,CAAC;IAED,KAAK,CAAC,oBAAoB,CAAC,QAAgB;QACzC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC1C,IAAI,IAAI,EAAE,CAAC;YACT,OAAO;gBACL,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,GAAG,EAAE,IAAI,CAAC,GAAG;aACd,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,OAAmB;QACxC,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAC1C,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YAC1B,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,GAAG,EAAE,IAAI,CAAC,GAAG;SACd,CAAC,CAAC,CAAC;IACN,CAAC"}
@@ -0,0 +1,65 @@
1
+ import { User, UserCTO } from '@aneuhold/core-ts-db-lib';
2
+ import { ObjectId } from 'bson';
3
+ import UserValidator from '../../validators/common/UserValidator.js';
4
+ import BaseRepository from '../BaseRepository.js';
5
+ import DashboardNonogramKatanaItemRepository from '../dashboard/DashboardNonogramKatanaItemRepository.js';
6
+ import DashboardNonogramKatanaUpgradeRepository from '../dashboard/DashboardNonogramKatanaUpgradeRepository.js';
7
+ import DashboardTaskRepository from '../dashboard/DashboardTaskRepository.js';
8
+ import DashboardUserConfigRepository from '../dashboard/DashboardUserConfigRepository.js';
9
+ import ApiKeyRepository from './ApiKeyRepository.js';
10
+
11
+ /**
12
+ * The repository that contains {@link User} documents.
13
+ */
14
+ export default class UserRepository extends BaseRepository<User> {
15
+ private static COLLECTION_NAME = 'users';
16
+
17
+ private static singletonInstance: UserRepository | undefined;
18
+
19
+ private constructor() {
20
+ super(UserRepository.COLLECTION_NAME, new UserValidator());
21
+ }
22
+
23
+ protected setupSubscribers(): void {
24
+ this.subscribeToChanges(ApiKeyRepository.getListenersForUserRepo());
25
+ this.subscribeToChanges(
26
+ DashboardUserConfigRepository.getListenersForUserRepo()
27
+ );
28
+ this.subscribeToChanges(DashboardTaskRepository.getListenersForUserRepo());
29
+ this.subscribeToChanges(
30
+ DashboardNonogramKatanaItemRepository.getListenersForUserRepo()
31
+ );
32
+ this.subscribeToChanges(
33
+ DashboardNonogramKatanaUpgradeRepository.getListenersForUserRepo()
34
+ );
35
+ }
36
+
37
+ /**
38
+ * Gets the singleton instance of the {@link UserRepository}.
39
+ */
40
+ static getRepo(): UserRepository {
41
+ if (!UserRepository.singletonInstance) {
42
+ UserRepository.singletonInstance = new UserRepository();
43
+ }
44
+ return UserRepository.singletonInstance;
45
+ }
46
+
47
+ async getUserCTOByUsername(userName: string): Promise<UserCTO | null> {
48
+ const user = await this.get({ userName });
49
+ if (user) {
50
+ return {
51
+ userName: user.userName,
52
+ _id: user._id
53
+ };
54
+ }
55
+ return null;
56
+ }
57
+
58
+ async getUserCTOsByIds(userIds: ObjectId[]): Promise<UserCTO[]> {
59
+ const users = await this.getList(userIds);
60
+ return users.map((user) => ({
61
+ userName: user.userName,
62
+ _id: user._id
63
+ }));
64
+ }
65
+ }
@@ -1,6 +1,6 @@
1
1
  import { BaseDocumentWithType } from '@aneuhold/core-ts-db-lib';
2
- import BaseRepository from '../BaseRepository';
3
- import IValidator from '../../validators/BaseValidator';
2
+ import IValidator from '../../validators/BaseValidator.js';
3
+ import BaseRepository from '../BaseRepository.js';
4
4
  /**
5
5
  * A base repository for the `dashboard` collection.
6
6
  */
@@ -1 +1 @@
1
- {"version":3,"file":"DashboardBaseRepository.d.ts","sourceRoot":"","sources":["../../../src/repositories/dashboard/DashboardBaseRepository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAC/C,OAAO,UAAU,MAAM,gCAAgC,CAAC;AAGxD;;GAEG;AACH,MAAM,CAAC,OAAO,CAAC,QAAQ,OAAO,uBAAuB,CACnD,SAAS,SAAS,oBAAoB,CACtC,SAAQ,cAAc,CAAC,SAAS,CAAC;IACjC,OAAO,CAAC,MAAM,CAAC,eAAe,CAAe;gBAG3C,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,UAAU,CAAC,SAAS,CAAC,EAChC,aAAa,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,CAAC,SAAS,CAAC,KAAK,OAAO,CAAC,SAAS,CAAC;CAclE"}
1
+ {"version":3,"file":"DashboardBaseRepository.d.ts","sourceRoot":"./src/","sources":["repositories/dashboard/DashboardBaseRepository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAEhE,OAAO,UAAU,MAAM,mCAAmC,CAAC;AAC3D,OAAO,cAAc,MAAM,sBAAsB,CAAC;AAElD;;GAEG;AACH,MAAM,CAAC,OAAO,CAAC,QAAQ,OAAO,uBAAuB,CACnD,SAAS,SAAS,oBAAoB,CACtC,SAAQ,cAAc,CAAC,SAAS,CAAC;IACjC,OAAO,CAAC,MAAM,CAAC,eAAe,CAAe;gBAG3C,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,UAAU,CAAC,SAAS,CAAC,EAChC,aAAa,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,CAAC,SAAS,CAAC,KAAK,OAAO,CAAC,SAAS,CAAC;CAclE"}
@@ -1,21 +1,16 @@
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 BaseRepository_1 = __importDefault(require("../BaseRepository"));
7
- const DocumentCleaner_1 = __importDefault(require("../../util/DocumentCleaner"));
1
+ import CleanDocument from '../../util/DocumentCleaner.js';
2
+ import BaseRepository from '../BaseRepository.js';
8
3
  /**
9
4
  * A base repository for the `dashboard` collection.
10
5
  */
11
- class DashboardBaseRepository extends BaseRepository_1.default {
6
+ export default class DashboardBaseRepository extends BaseRepository {
12
7
  static COLLECTION_NAME = 'dashboard';
13
8
  constructor(docType, validator, updateCleaner) {
14
9
  const defaultUpdateCleaner = (updatedDoc) => updateCleaner
15
- ? updateCleaner(DocumentCleaner_1.default.docType(updatedDoc))
16
- : DocumentCleaner_1.default.docType(updatedDoc);
10
+ ? updateCleaner(CleanDocument.docType(updatedDoc))
11
+ : CleanDocument.docType(updatedDoc);
17
12
  const defaultFilter = { docType };
18
13
  super(DashboardBaseRepository.COLLECTION_NAME, validator, defaultFilter, defaultUpdateCleaner);
19
14
  }
20
15
  }
21
- exports.default = DashboardBaseRepository;
16
+ //# sourceMappingURL=DashboardBaseRepository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DashboardBaseRepository.js","sourceRoot":"./src/","sources":["repositories/dashboard/DashboardBaseRepository.ts"],"names":[],"mappings":"AACA,OAAO,aAAa,MAAM,+BAA+B,CAAC;AAE1D,OAAO,cAAc,MAAM,sBAAsB,CAAC;AAElD;;GAEG;AACH,MAAM,CAAC,OAAO,OAAgB,uBAE5B,SAAQ,cAAyB;IACzB,MAAM,CAAC,eAAe,GAAG,WAAW,CAAC;IAE7C,YACE,OAAe,EACf,SAAgC,EAChC,aAA+D;QAE/D,MAAM,oBAAoB,GAAG,CAAC,UAA8B,EAAE,EAAE,CAC9D,aAAa;YACX,CAAC,CAAC,aAAa,CAAC,aAAa,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;YAClD,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QACxC,MAAM,aAAa,GAAG,EAAE,OAAO,EAAwB,CAAC;QACxD,KAAK,CACH,uBAAuB,CAAC,eAAe,EACvC,SAAS,EACT,aAAa,EACb,oBAAoB,CACrB,CAAC;IACJ,CAAC"}