@aneuhold/be-ts-db-lib 4.0.2 → 4.1.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/CHANGELOG.md +16 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -1
- package/lib/index.js.map +1 -1
- package/lib/index.ts +2 -0
- package/lib/repositories/BaseRepository.d.ts +33 -16
- package/lib/repositories/BaseRepository.d.ts.map +1 -1
- package/lib/repositories/BaseRepository.js +51 -13
- package/lib/repositories/BaseRepository.js.map +1 -1
- package/lib/repositories/BaseRepository.ts +88 -38
- package/lib/repositories/dashboard/DashboardBaseRepository.d.ts +12 -1
- package/lib/repositories/dashboard/DashboardBaseRepository.d.ts.map +1 -1
- package/lib/repositories/dashboard/DashboardBaseRepository.js +30 -1
- package/lib/repositories/dashboard/DashboardBaseRepository.js.map +1 -1
- package/lib/repositories/dashboard/DashboardBaseRepository.ts +52 -2
- package/lib/repositories/dashboard/DashboardBaseWithUserIdRepository.d.ts +25 -0
- package/lib/repositories/dashboard/DashboardBaseWithUserIdRepository.d.ts.map +1 -0
- package/lib/repositories/dashboard/DashboardBaseWithUserIdRepository.js +70 -0
- package/lib/repositories/dashboard/DashboardBaseWithUserIdRepository.js.map +1 -0
- package/lib/repositories/dashboard/DashboardBaseWithUserIdRepository.ts +101 -0
- package/lib/repositories/dashboard/DashboardNonogramKatanaItemRepository.d.ts +2 -9
- package/lib/repositories/dashboard/DashboardNonogramKatanaItemRepository.d.ts.map +1 -1
- package/lib/repositories/dashboard/DashboardNonogramKatanaItemRepository.js +9 -19
- package/lib/repositories/dashboard/DashboardNonogramKatanaItemRepository.js.map +1 -1
- package/lib/repositories/dashboard/DashboardNonogramKatanaItemRepository.ts +9 -25
- package/lib/repositories/dashboard/DashboardNonogramKatanaUpgradeRepository.d.ts +2 -9
- package/lib/repositories/dashboard/DashboardNonogramKatanaUpgradeRepository.d.ts.map +1 -1
- package/lib/repositories/dashboard/DashboardNonogramKatanaUpgradeRepository.js +9 -19
- package/lib/repositories/dashboard/DashboardNonogramKatanaUpgradeRepository.js.map +1 -1
- package/lib/repositories/dashboard/DashboardNonogramKatanaUpgradeRepository.ts +9 -25
- package/lib/repositories/dashboard/DashboardTaskRepository.d.ts +12 -5
- package/lib/repositories/dashboard/DashboardTaskRepository.d.ts.map +1 -1
- package/lib/repositories/dashboard/DashboardTaskRepository.js +77 -8
- package/lib/repositories/dashboard/DashboardTaskRepository.js.map +1 -1
- package/lib/repositories/dashboard/DashboardTaskRepository.ts +104 -10
- package/lib/repositories/dashboard/DashboardUserConfigRepository.d.ts +11 -6
- package/lib/repositories/dashboard/DashboardUserConfigRepository.d.ts.map +1 -1
- package/lib/repositories/dashboard/DashboardUserConfigRepository.js +24 -16
- package/lib/repositories/dashboard/DashboardUserConfigRepository.js.map +1 -1
- package/lib/repositories/dashboard/DashboardUserConfigRepository.ts +39 -16
- package/lib/services/RepoSubscriptionService.d.ts +7 -6
- package/lib/services/RepoSubscriptionService.d.ts.map +1 -1
- package/lib/services/RepoSubscriptionService.js.map +1 -1
- package/lib/services/RepoSubscriptionService.ts +13 -6
- package/lib/util/DbOperationMetaData.d.ts +47 -0
- package/lib/util/DbOperationMetaData.d.ts.map +1 -0
- package/lib/util/DbOperationMetaData.js +58 -0
- package/lib/util/DbOperationMetaData.js.map +1 -0
- package/lib/util/DbOperationMetaData.ts +65 -0
- package/package.json +11 -10
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { UUID } from 'crypto';
|
|
2
|
+
/**
|
|
3
|
+
* Tracks metadata about database operations during a single API request.
|
|
4
|
+
*
|
|
5
|
+
* This is intentionally **not** called "context" to avoid confusion with other libraries that
|
|
6
|
+
* use that term for different concepts.
|
|
7
|
+
*/
|
|
8
|
+
export default class DbOperationMetaData {
|
|
9
|
+
private readonly docTypesTouched;
|
|
10
|
+
private readonly affectedUserIds;
|
|
11
|
+
private readonly docCache;
|
|
12
|
+
/**
|
|
13
|
+
* Records that a doc type was touched by an operation during this request.
|
|
14
|
+
*
|
|
15
|
+
* @param docType - The doc type that was touched.
|
|
16
|
+
*/
|
|
17
|
+
recordDocTypeTouched(docType: string): void;
|
|
18
|
+
/**
|
|
19
|
+
* Records multiple user IDs as affected by an operation during this request.
|
|
20
|
+
*
|
|
21
|
+
* @param userIds - The user IDs to record as affected.
|
|
22
|
+
*/
|
|
23
|
+
addAffectedUserIds(userIds: UUID[]): void;
|
|
24
|
+
/**
|
|
25
|
+
* Gets all doc types that were touched during this request.
|
|
26
|
+
*/
|
|
27
|
+
getDocTypesTouched(): Set<string>;
|
|
28
|
+
/**
|
|
29
|
+
* Gets all user IDs recorded as affected during this request.
|
|
30
|
+
*/
|
|
31
|
+
getAffectedUserIds(): Set<UUID>;
|
|
32
|
+
/**
|
|
33
|
+
* Caches a document by its ID to prevent duplicate queries during this request.
|
|
34
|
+
*
|
|
35
|
+
* @param docId - The ID of the document to cache.
|
|
36
|
+
* @param doc - The document to cache.
|
|
37
|
+
*/
|
|
38
|
+
cacheDoc<T>(docId: UUID, doc: T): void;
|
|
39
|
+
/**
|
|
40
|
+
* Retrieves a cached document by its ID.
|
|
41
|
+
*
|
|
42
|
+
* @param docId - The ID of the document to retrieve.
|
|
43
|
+
* @returns The cached document, or undefined if not found.
|
|
44
|
+
*/
|
|
45
|
+
getCachedDoc<T>(docId: UUID): T | undefined;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=DbOperationMetaData.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DbOperationMetaData.d.ts","sourceRoot":"","sources":["../../src/util/DbOperationMetaData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAEnC;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,mBAAmB;IACtC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAqB;IACrD,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAmB;IACnD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA4B;IAErD;;;;OAIG;IACH,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAI3C;;;;OAIG;IACH,kBAAkB,CAAC,OAAO,EAAE,IAAI,EAAE,GAAG,IAAI;IAIzC;;OAEG;IACH,kBAAkB,IAAI,GAAG,CAAC,MAAM,CAAC;IAIjC;;OAEG;IACH,kBAAkB,IAAI,GAAG,CAAC,IAAI,CAAC;IAI/B;;;;;OAKG;IACH,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,GAAG,IAAI;IAItC;;;;;OAKG;IACH,YAAY,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,GAAG,CAAC,GAAG,SAAS;CAG5C"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tracks metadata about database operations during a single API request.
|
|
3
|
+
*
|
|
4
|
+
* This is intentionally **not** called "context" to avoid confusion with other libraries that
|
|
5
|
+
* use that term for different concepts.
|
|
6
|
+
*/
|
|
7
|
+
export default class DbOperationMetaData {
|
|
8
|
+
docTypesTouched = new Set();
|
|
9
|
+
affectedUserIds = new Set();
|
|
10
|
+
docCache = new Map();
|
|
11
|
+
/**
|
|
12
|
+
* Records that a doc type was touched by an operation during this request.
|
|
13
|
+
*
|
|
14
|
+
* @param docType - The doc type that was touched.
|
|
15
|
+
*/
|
|
16
|
+
recordDocTypeTouched(docType) {
|
|
17
|
+
this.docTypesTouched.add(docType);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Records multiple user IDs as affected by an operation during this request.
|
|
21
|
+
*
|
|
22
|
+
* @param userIds - The user IDs to record as affected.
|
|
23
|
+
*/
|
|
24
|
+
addAffectedUserIds(userIds) {
|
|
25
|
+
userIds.forEach((userId) => this.affectedUserIds.add(userId));
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Gets all doc types that were touched during this request.
|
|
29
|
+
*/
|
|
30
|
+
getDocTypesTouched() {
|
|
31
|
+
return this.docTypesTouched;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Gets all user IDs recorded as affected during this request.
|
|
35
|
+
*/
|
|
36
|
+
getAffectedUserIds() {
|
|
37
|
+
return this.affectedUserIds;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Caches a document by its ID to prevent duplicate queries during this request.
|
|
41
|
+
*
|
|
42
|
+
* @param docId - The ID of the document to cache.
|
|
43
|
+
* @param doc - The document to cache.
|
|
44
|
+
*/
|
|
45
|
+
cacheDoc(docId, doc) {
|
|
46
|
+
this.docCache.set(docId, doc);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Retrieves a cached document by its ID.
|
|
50
|
+
*
|
|
51
|
+
* @param docId - The ID of the document to retrieve.
|
|
52
|
+
* @returns The cached document, or undefined if not found.
|
|
53
|
+
*/
|
|
54
|
+
getCachedDoc(docId) {
|
|
55
|
+
return this.docCache.get(docId);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=DbOperationMetaData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DbOperationMetaData.js","sourceRoot":"","sources":["../../src/util/DbOperationMetaData.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,mBAAmB;IACrB,eAAe,GAAG,IAAI,GAAG,EAAU,CAAC;IACpC,eAAe,GAAG,IAAI,GAAG,EAAQ,CAAC;IAClC,QAAQ,GAAG,IAAI,GAAG,EAAiB,CAAC;IAErD;;;;OAIG;IACH,oBAAoB,CAAC,OAAe;QAClC,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;IAED;;;;OAIG;IACH,kBAAkB,CAAC,OAAe;QAChC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;IAChE,CAAC;IAED;;OAEG;IACH,kBAAkB;QAChB,OAAO,IAAI,CAAC,eAAe,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,kBAAkB;QAChB,OAAO,IAAI,CAAC,eAAe,CAAC;IAC9B,CAAC;IAED;;;;;OAKG;IACH,QAAQ,CAAI,KAAW,EAAE,GAAM;QAC7B,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAChC,CAAC;IAED;;;;;OAKG;IACH,YAAY,CAAI,KAAW;QACzB,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAkB,CAAC;IACnD,CAAC;CACF"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { UUID } from 'crypto';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Tracks metadata about database operations during a single API request.
|
|
5
|
+
*
|
|
6
|
+
* This is intentionally **not** called "context" to avoid confusion with other libraries that
|
|
7
|
+
* use that term for different concepts.
|
|
8
|
+
*/
|
|
9
|
+
export default class DbOperationMetaData {
|
|
10
|
+
private readonly docTypesTouched = new Set<string>();
|
|
11
|
+
private readonly affectedUserIds = new Set<UUID>();
|
|
12
|
+
private readonly docCache = new Map<UUID, unknown>();
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Records that a doc type was touched by an operation during this request.
|
|
16
|
+
*
|
|
17
|
+
* @param docType - The doc type that was touched.
|
|
18
|
+
*/
|
|
19
|
+
recordDocTypeTouched(docType: string): void {
|
|
20
|
+
this.docTypesTouched.add(docType);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Records multiple user IDs as affected by an operation during this request.
|
|
25
|
+
*
|
|
26
|
+
* @param userIds - The user IDs to record as affected.
|
|
27
|
+
*/
|
|
28
|
+
addAffectedUserIds(userIds: UUID[]): void {
|
|
29
|
+
userIds.forEach((userId) => this.affectedUserIds.add(userId));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Gets all doc types that were touched during this request.
|
|
34
|
+
*/
|
|
35
|
+
getDocTypesTouched(): Set<string> {
|
|
36
|
+
return this.docTypesTouched;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Gets all user IDs recorded as affected during this request.
|
|
41
|
+
*/
|
|
42
|
+
getAffectedUserIds(): Set<UUID> {
|
|
43
|
+
return this.affectedUserIds;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Caches a document by its ID to prevent duplicate queries during this request.
|
|
48
|
+
*
|
|
49
|
+
* @param docId - The ID of the document to cache.
|
|
50
|
+
* @param doc - The document to cache.
|
|
51
|
+
*/
|
|
52
|
+
cacheDoc<T>(docId: UUID, doc: T): void {
|
|
53
|
+
this.docCache.set(docId, doc);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Retrieves a cached document by its ID.
|
|
58
|
+
*
|
|
59
|
+
* @param docId - The ID of the document to retrieve.
|
|
60
|
+
* @returns The cached document, or undefined if not found.
|
|
61
|
+
*/
|
|
62
|
+
getCachedDoc<T>(docId: UUID): T | undefined {
|
|
63
|
+
return this.docCache.get(docId) as T | undefined;
|
|
64
|
+
}
|
|
65
|
+
}
|
package/package.json
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"name": "@aneuhold/be-ts-db-lib",
|
|
3
3
|
"author": "Anton G. Neuhold Jr.",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "4.0
|
|
5
|
+
"version": "4.1.0",
|
|
6
6
|
"description": "A backend database library meant to actually interact with various databases in personal projects",
|
|
7
|
-
"packageManager": "pnpm@10.
|
|
7
|
+
"packageManager": "pnpm@10.25.0",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"scripts": {
|
|
10
10
|
"build": "rimraf lib && pnpm build:withoutClean",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"watch": "nodemon --ignore lib/ -e ts --exec \"pnpm build:withoutClean && local-npm publish\"",
|
|
14
14
|
"unpub:local": "local-npm unpublish || true",
|
|
15
15
|
"lint": "eslint",
|
|
16
|
-
"test": "vitest run && pnpm validate:dry",
|
|
16
|
+
"test": "vitest run --coverage && pnpm validate:dry",
|
|
17
17
|
"preparePkg": "tb pkg prepare",
|
|
18
18
|
"validate": "tsx ./scripts/validateSchema.ts",
|
|
19
19
|
"validate:dry": "tsx ./scripts/validateSchemaDryRun.ts",
|
|
@@ -57,21 +57,22 @@
|
|
|
57
57
|
"MongoDB"
|
|
58
58
|
],
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@aneuhold/be-ts-lib": "^3.0.
|
|
61
|
-
"@aneuhold/core-ts-db-lib": "^4.0.
|
|
62
|
-
"@aneuhold/core-ts-lib": "^2.3.
|
|
60
|
+
"@aneuhold/be-ts-lib": "^3.0.7",
|
|
61
|
+
"@aneuhold/core-ts-db-lib": "^4.0.3",
|
|
62
|
+
"@aneuhold/core-ts-lib": "^2.3.15",
|
|
63
63
|
"bson": "^7.0.0",
|
|
64
64
|
"mongodb": "^7.0.0",
|
|
65
65
|
"uuid": "^13.0.0",
|
|
66
66
|
"zod": "^4.1.13"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
|
-
"@aneuhold/local-npm-registry": "^0.2.
|
|
69
|
+
"@aneuhold/local-npm-registry": "^0.2.22",
|
|
70
70
|
"@aneuhold/main-scripts": "^2.8.0",
|
|
71
|
-
"@types/node": "^
|
|
71
|
+
"@types/node": "^25.0.2",
|
|
72
72
|
"@types/node-fetch": "^2.6.13",
|
|
73
|
+
"@vitest/coverage-v8": "^4.0.15",
|
|
73
74
|
"dotenv": "^17.2.3",
|
|
74
|
-
"eslint": "^9.39.
|
|
75
|
+
"eslint": "^9.39.2",
|
|
75
76
|
"jsr": "^0.13.5",
|
|
76
77
|
"prettier": "^3.7.4",
|
|
77
78
|
"rimraf": "^6.1.2",
|
|
@@ -80,4 +81,4 @@
|
|
|
80
81
|
"typescript": "^5.9.3",
|
|
81
82
|
"vitest": "^4.0.15"
|
|
82
83
|
}
|
|
83
|
-
}
|
|
84
|
+
}
|