@acorex-platform/module-report-management-server 0.0.18 → 2.0.0-next.42

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 (209) hide show
  1. package/contracts/src/commands.keys.d.ts +11 -0
  2. package/contracts/src/commands.keys.js +17 -0
  3. package/contracts/src/commands.keys.js.map +1 -0
  4. package/contracts/src/entities/index.d.ts +3 -0
  5. package/contracts/src/entities/index.js +3 -0
  6. package/contracts/src/entities/index.js.map +1 -1
  7. package/contracts/src/entities/query-snapshot/index.d.ts +1 -0
  8. package/contracts/src/entities/query-snapshot/index.js +5 -0
  9. package/contracts/src/entities/query-snapshot/index.js.map +1 -0
  10. package/contracts/src/entities/query-snapshot/query-snapshot.entity.d.ts +2 -0
  11. package/contracts/src/entities/query-snapshot/query-snapshot.entity.js +127 -0
  12. package/contracts/src/entities/query-snapshot/query-snapshot.entity.js.map +1 -0
  13. package/contracts/src/entities/query-snapshot/query-snapshot.types.d.ts +34 -0
  14. package/contracts/src/entities/query-snapshot/query-snapshot.types.js +5 -0
  15. package/contracts/src/entities/query-snapshot/query-snapshot.types.js.map +1 -0
  16. package/contracts/src/entities/query-snapshot-policy/index.d.ts +1 -0
  17. package/contracts/src/entities/query-snapshot-policy/index.js +5 -0
  18. package/contracts/src/entities/query-snapshot-policy/index.js.map +1 -0
  19. package/contracts/src/entities/query-snapshot-policy/query-snapshot-policy.entity.d.ts +2 -0
  20. package/contracts/src/entities/query-snapshot-policy/query-snapshot-policy.entity.js +100 -0
  21. package/contracts/src/entities/query-snapshot-policy/query-snapshot-policy.entity.js.map +1 -0
  22. package/contracts/src/entities/query-snapshot-policy/query-snapshot-policy.types.d.ts +14 -0
  23. package/contracts/src/entities/query-snapshot-policy/query-snapshot-policy.types.js +5 -0
  24. package/contracts/src/entities/query-snapshot-policy/query-snapshot-policy.types.js.map +1 -0
  25. package/contracts/src/entities/report/index.d.ts +1 -1
  26. package/contracts/src/entities/report/index.js +1 -1
  27. package/contracts/src/entities/report/index.js.map +1 -1
  28. package/contracts/src/entities/report/report.entity.js +51 -7
  29. package/contracts/src/entities/report/report.entity.js.map +1 -1
  30. package/contracts/src/entities/report-category/index.d.ts +1 -1
  31. package/contracts/src/entities/report-category/index.js +0 -2
  32. package/contracts/src/entities/report-category/index.js.map +1 -1
  33. package/contracts/src/entities/report-category/report-category.entity.js +14 -1
  34. package/contracts/src/entities/report-category/report-category.entity.js.map +1 -1
  35. package/contracts/src/entities/report-generation-request/index.d.ts +1 -0
  36. package/contracts/src/entities/report-generation-request/index.js +5 -0
  37. package/contracts/src/entities/report-generation-request/index.js.map +1 -0
  38. package/contracts/src/entities/report-generation-request/report-generation-request.entity.d.ts +2 -0
  39. package/contracts/src/entities/report-generation-request/report-generation-request.entity.js +208 -0
  40. package/contracts/src/entities/report-generation-request/report-generation-request.entity.js.map +1 -0
  41. package/contracts/src/entity-catalog.d.ts +7 -0
  42. package/contracts/src/entity-catalog.js +24 -0
  43. package/contracts/src/entity-catalog.js.map +1 -0
  44. package/contracts/src/entity-entry.query-snapshot-policy.d.ts +1 -0
  45. package/contracts/src/entity-entry.query-snapshot-policy.js +6 -0
  46. package/contracts/src/entity-entry.query-snapshot-policy.js.map +1 -0
  47. package/contracts/src/entity-entry.query-snapshot.d.ts +1 -0
  48. package/contracts/src/entity-entry.query-snapshot.js +6 -0
  49. package/contracts/src/entity-entry.query-snapshot.js.map +1 -0
  50. package/contracts/src/entity-entry.report-category.d.ts +1 -0
  51. package/contracts/src/entity-entry.report-category.js +6 -0
  52. package/contracts/src/entity-entry.report-category.js.map +1 -0
  53. package/contracts/src/entity-entry.report-generation-request.d.ts +1 -0
  54. package/contracts/src/entity-entry.report-generation-request.js +6 -0
  55. package/contracts/src/entity-entry.report-generation-request.js.map +1 -0
  56. package/contracts/src/entity-entry.report.d.ts +1 -0
  57. package/contracts/src/entity-entry.report.js +6 -0
  58. package/contracts/src/entity-entry.report.js.map +1 -0
  59. package/contracts/src/index.d.ts +5 -0
  60. package/contracts/src/index.js +5 -0
  61. package/contracts/src/index.js.map +1 -1
  62. package/contracts/src/manifest.d.ts +6 -0
  63. package/contracts/src/manifest.js +24 -0
  64. package/contracts/src/manifest.js.map +1 -0
  65. package/contracts/src/permission.keys.d.ts +30 -14
  66. package/contracts/src/permission.keys.js +28 -12
  67. package/contracts/src/permission.keys.js.map +1 -1
  68. package/contracts/src/report-generation.types.d.ts +97 -0
  69. package/contracts/src/report-generation.types.js +14 -0
  70. package/contracts/src/report-generation.types.js.map +1 -0
  71. package/contracts/src/report.types.d.ts +107 -107
  72. package/contracts/src/report.types.js.map +1 -1
  73. package/contracts/src/root-config.d.ts +23 -2
  74. package/contracts/src/root-config.js +23 -2
  75. package/contracts/src/root-config.js.map +1 -1
  76. package/contracts/src/runtime.keys.d.ts +14 -0
  77. package/contracts/src/runtime.keys.js +20 -0
  78. package/contracts/src/runtime.keys.js.map +1 -0
  79. package/contracts/src/settings.keys.d.ts +11 -0
  80. package/contracts/src/settings.keys.js +17 -0
  81. package/contracts/src/settings.keys.js.map +1 -0
  82. package/package.json +8 -8
  83. package/server/src/index.d.ts +2 -4
  84. package/server/src/index.js +5 -8
  85. package/server/src/index.js.map +1 -1
  86. package/server/src/lib/entities/index.d.ts +1 -0
  87. package/server/src/lib/entities/index.js +5 -0
  88. package/server/src/lib/entities/index.js.map +1 -0
  89. package/server/src/lib/entities/report-management.entity-catalog.d.ts +1 -0
  90. package/server/src/lib/entities/report-management.entity-catalog.js +12 -0
  91. package/server/src/lib/entities/report-management.entity-catalog.js.map +1 -0
  92. package/server/src/lib/query-snapshots/query-snapshot-bypass.util.d.ts +3 -0
  93. package/server/src/lib/query-snapshots/query-snapshot-bypass.util.js +16 -0
  94. package/server/src/lib/query-snapshots/query-snapshot-bypass.util.js.map +1 -0
  95. package/server/src/lib/query-snapshots/query-snapshot-debounce.service.d.ts +19 -0
  96. package/server/src/lib/query-snapshots/query-snapshot-debounce.service.js +118 -0
  97. package/server/src/lib/query-snapshots/query-snapshot-debounce.service.js.map +1 -0
  98. package/server/src/lib/query-snapshots/query-snapshot-enqueue.service.d.ts +24 -0
  99. package/server/src/lib/query-snapshots/query-snapshot-enqueue.service.js +61 -0
  100. package/server/src/lib/query-snapshots/query-snapshot-enqueue.service.js.map +1 -0
  101. package/server/src/lib/query-snapshots/query-snapshot-entity-change.middleware.d.ts +12 -0
  102. package/server/src/lib/query-snapshots/query-snapshot-entity-change.middleware.js +90 -0
  103. package/server/src/lib/query-snapshots/query-snapshot-entity-change.middleware.js.map +1 -0
  104. package/server/src/lib/query-snapshots/query-snapshot-entity-storage.bootstrap.d.ts +9 -0
  105. package/server/src/lib/query-snapshots/query-snapshot-entity-storage.bootstrap.js +25 -0
  106. package/server/src/lib/query-snapshots/query-snapshot-entity-storage.bootstrap.js.map +1 -0
  107. package/server/src/lib/query-snapshots/query-snapshot-payload.util.d.ts +22 -0
  108. package/server/src/lib/query-snapshots/query-snapshot-payload.util.js +282 -0
  109. package/server/src/lib/query-snapshots/query-snapshot-payload.util.js.map +1 -0
  110. package/server/src/lib/query-snapshots/query-snapshot-recalc.service.d.ts +23 -0
  111. package/server/src/lib/query-snapshots/query-snapshot-recalc.service.js +122 -0
  112. package/server/src/lib/query-snapshots/query-snapshot-recalc.service.js.map +1 -0
  113. package/server/src/lib/query-snapshots/query-snapshot-schedule.setup.d.ts +2 -0
  114. package/server/src/lib/query-snapshots/query-snapshot-schedule.setup.js +79 -0
  115. package/server/src/lib/query-snapshots/query-snapshot-schedule.setup.js.map +1 -0
  116. package/server/src/lib/query-snapshots/query-snapshot.constants.d.ts +17 -0
  117. package/server/src/lib/query-snapshots/query-snapshot.constants.js +46 -0
  118. package/server/src/lib/query-snapshots/query-snapshot.constants.js.map +1 -0
  119. package/server/src/lib/query-snapshots/query-snapshot.middleware.d.ts +21 -0
  120. package/server/src/lib/query-snapshots/query-snapshot.middleware.js +135 -0
  121. package/server/src/lib/query-snapshots/query-snapshot.middleware.js.map +1 -0
  122. package/server/src/lib/query-snapshots/query-snapshot.store.d.ts +34 -0
  123. package/server/src/lib/query-snapshots/query-snapshot.store.js +137 -0
  124. package/server/src/lib/query-snapshots/query-snapshot.store.js.map +1 -0
  125. package/server/src/lib/query-snapshots/recalculate-query-snapshots.command.d.ts +8 -0
  126. package/server/src/lib/query-snapshots/recalculate-query-snapshots.command.js +74 -0
  127. package/server/src/lib/query-snapshots/recalculate-query-snapshots.command.js.map +1 -0
  128. package/server/src/lib/query-snapshots/refresh-query-snapshots.command.d.ts +16 -0
  129. package/server/src/lib/query-snapshots/refresh-query-snapshots.command.js +56 -0
  130. package/server/src/lib/query-snapshots/refresh-query-snapshots.command.js.map +1 -0
  131. package/server/src/lib/report-browse.service.js +32 -13
  132. package/server/src/lib/report-browse.service.js.map +1 -1
  133. package/server/src/lib/report-browse.types.d.ts +27 -12
  134. package/server/src/lib/report-browse.types.js +0 -1
  135. package/server/src/lib/report-browse.types.js.map +1 -1
  136. package/server/src/lib/report-definition.seed-provider.d.ts +15 -0
  137. package/server/src/lib/report-definition.seed-provider.js +63 -0
  138. package/server/src/lib/report-definition.seed-provider.js.map +1 -0
  139. package/server/src/lib/report-generation/report-generation-create.command.d.ts +17 -0
  140. package/server/src/lib/report-generation/report-generation-create.command.js +177 -0
  141. package/server/src/lib/report-generation/report-generation-create.command.js.map +1 -0
  142. package/server/src/lib/report-generation/report-generation-enqueue.service.d.ts +21 -0
  143. package/server/src/lib/report-generation/report-generation-enqueue.service.js +58 -0
  144. package/server/src/lib/report-generation/report-generation-enqueue.service.js.map +1 -0
  145. package/server/src/lib/report-generation/report-generation-execute.command.d.ts +10 -0
  146. package/server/src/lib/report-generation/report-generation-execute.command.js +49 -0
  147. package/server/src/lib/report-generation/report-generation-execute.command.js.map +1 -0
  148. package/server/src/lib/report-generation/report-generation-execute.service.d.ts +23 -0
  149. package/server/src/lib/report-generation/report-generation-execute.service.js +225 -0
  150. package/server/src/lib/report-generation/report-generation-execute.service.js.map +1 -0
  151. package/server/src/lib/report-generation/report-generation-job-presentation.util.d.ts +8 -0
  152. package/server/src/lib/report-generation/report-generation-job-presentation.util.js +43 -0
  153. package/server/src/lib/report-generation/report-generation-job-presentation.util.js.map +1 -0
  154. package/server/src/lib/report-generation/report-generation-notify.service.d.ts +23 -0
  155. package/server/src/lib/report-generation/report-generation-notify.service.js +159 -0
  156. package/server/src/lib/report-generation/report-generation-notify.service.js.map +1 -0
  157. package/server/src/lib/report-generation/report-generation-policy.util.d.ts +39 -0
  158. package/server/src/lib/report-generation/report-generation-policy.util.js +95 -0
  159. package/server/src/lib/report-generation/report-generation-policy.util.js.map +1 -0
  160. package/server/src/lib/report-generation/report-generation-progress.util.d.ts +14 -0
  161. package/server/src/lib/report-generation/report-generation-progress.util.js +51 -0
  162. package/server/src/lib/report-generation/report-generation-progress.util.js.map +1 -0
  163. package/server/src/lib/report-generation/report-generation-release-inline-watch.command.d.ts +10 -0
  164. package/server/src/lib/report-generation/report-generation-release-inline-watch.command.js +55 -0
  165. package/server/src/lib/report-generation/report-generation-release-inline-watch.command.js.map +1 -0
  166. package/server/src/lib/report-generation/report-generation-runtime.handlers.d.ts +27 -0
  167. package/server/src/lib/report-generation/report-generation-runtime.handlers.js +136 -0
  168. package/server/src/lib/report-generation/report-generation-runtime.handlers.js.map +1 -0
  169. package/server/src/lib/report-generation/report-generation-settings.service.d.ts +12 -0
  170. package/server/src/lib/report-generation/report-generation-settings.service.js +49 -0
  171. package/server/src/lib/report-generation/report-generation-settings.service.js.map +1 -0
  172. package/server/src/lib/report-generation/report-generation.constants.d.ts +16 -0
  173. package/server/src/lib/report-generation/report-generation.constants.js +24 -0
  174. package/server/src/lib/report-generation/report-generation.constants.js.map +1 -0
  175. package/server/src/lib/report-generation/report-generation.store.d.ts +25 -0
  176. package/server/src/lib/report-generation/report-generation.store.js +145 -0
  177. package/server/src/lib/report-generation/report-generation.store.js.map +1 -0
  178. package/server/src/lib/report-generation/report-generation.util.d.ts +8 -0
  179. package/server/src/lib/report-generation/report-generation.util.js +131 -0
  180. package/server/src/lib/report-generation/report-generation.util.js.map +1 -0
  181. package/server/src/lib/report-management-runtime.handlers.d.ts +32 -0
  182. package/server/src/lib/report-management-runtime.handlers.js +78 -0
  183. package/server/src/lib/report-management-runtime.handlers.js.map +1 -0
  184. package/server/src/lib/report-management-server.module.js +64 -9
  185. package/server/src/lib/report-management-server.module.js.map +1 -1
  186. package/server/src/lib/report-management.controller.d.ts +1 -4
  187. package/server/src/lib/report-management.controller.js +2 -16
  188. package/server/src/lib/report-management.controller.js.map +1 -1
  189. package/server/src/lib/seed/index.d.ts +0 -19
  190. package/server/src/lib/seed/index.js +0 -21
  191. package/server/src/lib/seed/index.js.map +0 -1
  192. package/server/src/lib/seed/report-management-seed.provider.d.ts +0 -4
  193. package/server/src/lib/seed/report-management-seed.provider.js +0 -18
  194. package/server/src/lib/seed/report-management-seed.provider.js.map +0 -1
  195. package/server/src/lib/seed/report-management-seed.tokens.d.ts +0 -1
  196. package/server/src/lib/seed/report-management-seed.tokens.js +0 -7
  197. package/server/src/lib/seed/report-management-seed.tokens.js.map +0 -1
  198. package/server/src/lib/seed/report-management.seed-catalog.d.ts +0 -2
  199. package/server/src/lib/seed/report-management.seed-catalog.js +0 -10
  200. package/server/src/lib/seed/report-management.seed-catalog.js.map +0 -1
  201. package/server/src/lib/seed/samples/employee-report.mock.d.ts +0 -9
  202. package/server/src/lib/seed/samples/employee-report.mock.js +0 -322
  203. package/server/src/lib/seed/samples/employee-report.mock.js.map +0 -1
  204. package/server/src/lib/seed/samples/index.d.ts +0 -2
  205. package/server/src/lib/seed/samples/index.js +0 -6
  206. package/server/src/lib/seed/samples/index.js.map +0 -1
  207. package/server/src/lib/seed/samples/location-report.mock.d.ts +0 -9
  208. package/server/src/lib/seed/samples/location-report.mock.js +0 -339
  209. package/server/src/lib/seed/samples/location-report.mock.js.map +0 -1
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+ var QuerySnapshotDebounceService_1;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.QuerySnapshotDebounceService = void 0;
5
+ const tslib_1 = require("tslib");
6
+ const common_1 = require("@nestjs/common");
7
+ const query_snapshot_enqueue_service_1 = require("./query-snapshot-enqueue.service");
8
+ const query_snapshot_store_1 = require("./query-snapshot.store");
9
+ //#endregion
10
+ //#region ----- Entity-change debounce -----
11
+ let QuerySnapshotDebounceService = QuerySnapshotDebounceService_1 = class QuerySnapshotDebounceService {
12
+ constructor(store, enqueue) {
13
+ this.store = store;
14
+ this.enqueue = enqueue;
15
+ this.logger = new common_1.Logger(QuerySnapshotDebounceService_1.name);
16
+ this.pending = new Map();
17
+ }
18
+ onModuleDestroy() {
19
+ for (const entry of this.pending.values()) {
20
+ if (entry.timer) {
21
+ clearTimeout(entry.timer);
22
+ }
23
+ }
24
+ this.pending.clear();
25
+ }
26
+ onEntityWrite(input) {
27
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
28
+ const policies = yield this.store.listEnabledPolicies();
29
+ const matching = policies.filter((policy) => {
30
+ const triggers = policy.triggers;
31
+ return (triggers.entities.includes(input.entityName) &&
32
+ triggers.operations.includes(input.operation));
33
+ });
34
+ for (const policy of matching) {
35
+ yield this.store.markStale(policy.queryName, input.tenantId);
36
+ this.queue({
37
+ tenantId: input.tenantId,
38
+ applicationId: input.applicationId,
39
+ queryName: policy.queryName,
40
+ debounceMs: resolveEventDebounceMs(input.entityName, policy.triggers.debounceMs),
41
+ entityName: input.entityName,
42
+ operation: input.operation,
43
+ });
44
+ }
45
+ });
46
+ }
47
+ queue(input) {
48
+ const key = pendingKey(input.tenantId, input.queryName);
49
+ const waitMs = input.debounceMs > 0 ? input.debounceMs : 0;
50
+ let entry = this.pending.get(key);
51
+ if (!entry) {
52
+ entry = { debounceMs: waitMs, applicationId: input.applicationId };
53
+ this.pending.set(key, entry);
54
+ }
55
+ entry.debounceMs = waitMs;
56
+ if (input.applicationId) {
57
+ entry.applicationId = input.applicationId;
58
+ }
59
+ if (input.entityName) {
60
+ entry.entityName = input.entityName;
61
+ }
62
+ if (input.operation) {
63
+ entry.operation = input.operation;
64
+ }
65
+ if (entry.timer) {
66
+ clearTimeout(entry.timer);
67
+ }
68
+ entry.timer = setTimeout(() => {
69
+ void this.flush(input.tenantId, input.queryName);
70
+ }, waitMs);
71
+ }
72
+ flush(tenantId, queryName) {
73
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
74
+ const key = pendingKey(tenantId, queryName);
75
+ const entry = this.pending.get(key);
76
+ if (!entry) {
77
+ return;
78
+ }
79
+ const debounceMs = entry.debounceMs;
80
+ const applicationId = entry.applicationId;
81
+ const entityName = entry.entityName;
82
+ const operation = entry.operation;
83
+ this.pending.delete(key);
84
+ try {
85
+ const result = yield this.enqueue.enqueue(Object.assign({ tenantId,
86
+ applicationId, queryKeys: [queryName], trigger: 'event' }, (entityName && operation ? { eventSource: { entityName, operation } } : {})));
87
+ if (result.deduplicated) {
88
+ this.queue({ tenantId, applicationId, queryName, debounceMs, entityName, operation });
89
+ }
90
+ }
91
+ catch (error) {
92
+ this.logger.warn(`Failed to enqueue query snapshot recalc for ${queryName}: ${error instanceof Error ? error.message : String(error)}`);
93
+ this.queue({ tenantId, applicationId, queryName, debounceMs, entityName, operation });
94
+ }
95
+ });
96
+ }
97
+ };
98
+ exports.QuerySnapshotDebounceService = QuerySnapshotDebounceService;
99
+ exports.QuerySnapshotDebounceService = QuerySnapshotDebounceService = QuerySnapshotDebounceService_1 = tslib_1.__decorate([
100
+ (0, common_1.Injectable)(),
101
+ tslib_1.__metadata("design:paramtypes", [query_snapshot_store_1.QuerySnapshotStore,
102
+ query_snapshot_enqueue_service_1.QuerySnapshotEnqueueService])
103
+ ], QuerySnapshotDebounceService);
104
+ function pendingKey(tenantId, queryName) {
105
+ return `${tenantId}:${queryName}`;
106
+ }
107
+ /** Presence and device-session writes are bursty; don't wait the 30s seed default. */
108
+ const LIVE_ENTITY_DEBOUNCE_CAP_MS = 1000;
109
+ function resolveEventDebounceMs(entityName, policyDebounceMs) {
110
+ const waitMs = policyDebounceMs > 0 ? policyDebounceMs : 0;
111
+ if (entityName === 'PlatformManagement.UserPresenceSegment' ||
112
+ entityName === 'SecurityManagement.DeviceSessions') {
113
+ return waitMs === 0 ? 0 : Math.min(waitMs, LIVE_ENTITY_DEBOUNCE_CAP_MS);
114
+ }
115
+ return waitMs;
116
+ }
117
+ //#endregion
118
+ //# sourceMappingURL=query-snapshot-debounce.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query-snapshot-debounce.service.js","sourceRoot":"","sources":["../../../../../../../libs/modules/report-management/server/src/lib/query-snapshots/query-snapshot-debounce.service.ts"],"names":[],"mappings":";;;;;AAAA,2CAAqE;AACrE,qFAA+E;AAC/E,iEAA4D;AAY5D,YAAY;AAEZ,4CAA4C;AAGrC,IAAM,4BAA4B,oCAAlC,MAAM,4BAA4B;IAIvC,YACmB,KAAyB,EACzB,OAAoC;QADpC,UAAK,GAAL,KAAK,CAAoB;QACzB,YAAO,GAAP,OAAO,CAA6B;QALtC,WAAM,GAAG,IAAI,eAAM,CAAC,8BAA4B,CAAC,IAAI,CAAC,CAAC;QACvD,YAAO,GAAG,IAAI,GAAG,EAAyB,CAAC;IAKzD,CAAC;IAEJ,eAAe;QACb,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;YAC1C,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;gBAChB,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YAC5B,CAAC;QACH,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;IAEK,aAAa,CAAC,KAKnB;;YACC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,mBAAmB,EAAE,CAAC;YACxD,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE;gBAC1C,MAAM,QAAQ,GAAG,MAAM,C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;IAC3D,IACE,UAAU,KAAK,wCAAwC;QACvD,UAAU,KAAK,mCAAmC,EAClD,CAAC;QACD,OAAO,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,2BAA2B,CAAC,CAAC;IAC1E,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,YAAY"}
@@ -0,0 +1,24 @@
1
+ import { BackgroundJobService } from '@acorex-platform/framework-server/background-job';
2
+ import type { AXPBackgroundJobTrigger } from '@acorex-platform/framework-shared/background-job';
3
+ export type EnqueueQuerySnapshotRecalcInput = {
4
+ tenantId: string;
5
+ applicationId?: string;
6
+ queryKeys?: string[];
7
+ /** Full catch-up only: recalc every enabled policy (manual refresh all). */
8
+ force?: boolean;
9
+ trigger: Extract<AXPBackgroundJobTrigger, 'schedule' | 'event' | 'manual'>;
10
+ userId?: string;
11
+ /** Entity write that queued an event-triggered recalc. */
12
+ eventSource?: {
13
+ entityName: string;
14
+ operation: 'create' | 'update' | 'delete';
15
+ };
16
+ };
17
+ export declare class QuerySnapshotEnqueueService {
18
+ private readonly backgroundJobs;
19
+ constructor(backgroundJobs: BackgroundJobService);
20
+ enqueue(input: EnqueueQuerySnapshotRecalcInput): Promise<{
21
+ jobId: string;
22
+ deduplicated?: boolean;
23
+ }>;
24
+ }
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.QuerySnapshotEnqueueService = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const common_1 = require("@nestjs/common");
6
+ const background_job_1 = require("@acorex-platform/framework-server/background-job");
7
+ const module_report_management_contracts_1 = require("@acorex-platform/module-report-management-client/contracts");
8
+ const query_snapshot_constants_1 = require("./query-snapshot.constants");
9
+ //#endregion
10
+ //#region ----- Enqueue -----
11
+ let QuerySnapshotEnqueueService = class QuerySnapshotEnqueueService {
12
+ constructor(backgroundJobs) {
13
+ this.backgroundJobs = backgroundJobs;
14
+ }
15
+ enqueue(input) {
16
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
17
+ const queryKeys = normalizeQueryKeys(input.queryKeys);
18
+ if (input.trigger === 'event' && queryKeys.length !== 1) {
19
+ throw new Error('Event query snapshot recalc requires exactly one query key.');
20
+ }
21
+ const title = (0, query_snapshot_constants_1.querySnapshotJobTitle)(queryKeys.length ? queryKeys : undefined);
22
+ const idempotencyQuery = queryKeys.length === 1 ? queryKeys[0] : queryKeys.length > 1 ? queryKeys.join(',') : undefined;
23
+ const result = yield this.backgroundJobs.createJob({
24
+ command: {
25
+ key: module_report_management_contracts_1.AXM_RECALCULATE_QUERY_SNAPSHOTS_COMMAND_KEY,
26
+ title,
27
+ payload: Object.assign(Object.assign(Object.assign(Object.assign({ tenantId: input.tenantId }, (input.applicationId ? { applicationId: input.applicationId } : {})), (queryKeys.length ? { queryKeys } : {})), (input.force ? { force: true } : {})), (input.eventSource
28
+ ? {
29
+ eventSource: {
30
+ entityName: input.eventSource.entityName,
31
+ operation: input.eventSource.operation,
32
+ },
33
+ }
34
+ : {})),
35
+ },
36
+ providerKey: query_snapshot_constants_1.QUERY_SNAPSHOT_JOB_PROVIDER_KEY,
37
+ title,
38
+ trigger: input.trigger,
39
+ tenantId: input.tenantId,
40
+ applicationId: input.applicationId,
41
+ userId: input.userId,
42
+ idempotencyKey: (0, query_snapshot_constants_1.querySnapshotIdempotencyKey)(input.tenantId, idempotencyQuery),
43
+ visibility: input.trigger === 'manual' ? 'initiator' : 'silent',
44
+ });
45
+ return { jobId: result.jobId, deduplicated: result.deduplicated };
46
+ });
47
+ }
48
+ };
49
+ exports.QuerySnapshotEnqueueService = QuerySnapshotEnqueueService;
50
+ exports.QuerySnapshotEnqueueService = QuerySnapshotEnqueueService = tslib_1.__decorate([
51
+ (0, common_1.Injectable)(),
52
+ tslib_1.__metadata("design:paramtypes", [background_job_1.BackgroundJobService])
53
+ ], QuerySnapshotEnqueueService);
54
+ function normalizeQueryKeys(queryKeys) {
55
+ if (!(queryKeys === null || queryKeys === void 0 ? void 0 : queryKeys.length)) {
56
+ return [];
57
+ }
58
+ return [...new Set(queryKeys.map((key) => key.trim()).filter(Boolean))].sort();
59
+ }
60
+ //#endregion
61
+ //# sourceMappingURL=query-snapshot-enqueue.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query-snapshot-enqueue.service.js","sourceRoot":"","sources":["../../../../../../../libs/modules/report-management/server/src/lib/query-snapshots/query-snapshot-enqueue.service.ts"],"names":[],"mappings":";;;;AAAA,2CAA4C;AAC5C,qFAAwF;AAExF,4GAAkH;AAClH,yEAIoC;AAmBpC,YAAY;AAEZ,6BAA6B;AAGtB,IAAM,2BAA2B,GAAjC,MAAM,2BAA2B;IACtC,YAA6B,cAAoC;QAApC,mBAAc,GAAd,cAAc,CAAsB;IAAG,CAAC;IAE/D,OAAO,CAAC,KAAsC;;YAClD,MAAM,SAAS,GAAG,kBAAkB,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;YACtD,IAAI,KAAK,CAAC,OAAO,KAAK,OAAO,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACxD,MAAM,IAAI,KAAK,CAAC,6DAA6D,CAAC,CAAC;YACjF,CAAC;YAED,MAAM,KAAK,GAAG,IAAA,gDAAqB,EAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;YAC9E,MAAM,gBAAgB,GACpB,SAAS,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;YAEjG,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC;gBACjD,OAAO,EAAE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BAA2B,CA4CvC;AAED,SAAS,kBAAkB,CAAC,SAAoB;IAC9C,IAAI,CAAC,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,MAAM,CAAA,EAAE,CAAC;QACvB,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AACjF,CAAC;AAED,YAAY"}
@@ -0,0 +1,12 @@
1
+ import { type AXPEntityOp, type EntityStorageContext, type EntityStorageMiddleware } from '@acorex-platform/framework-server/core';
2
+ import { QuerySnapshotDebounceService } from './query-snapshot-debounce.service';
3
+ export declare class QuerySnapshotEntityChangeMiddleware implements EntityStorageMiddleware {
4
+ private readonly debounce;
5
+ readonly target: {
6
+ ops: AXPEntityOp[];
7
+ order: number;
8
+ };
9
+ private readonly logger;
10
+ constructor(debounce: QuerySnapshotDebounceService);
11
+ execute(ctx: EntityStorageContext, next: () => Promise<void>): Promise<void>;
12
+ }
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ var QuerySnapshotEntityChangeMiddleware_1;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.QuerySnapshotEntityChangeMiddleware = void 0;
5
+ const tslib_1 = require("tslib");
6
+ const common_1 = require("@nestjs/common");
7
+ const core_1 = require("@acorex-platform/framework-server/core");
8
+ const security_1 = require("@acorex-platform/framework-server/security");
9
+ const query_snapshot_constants_1 = require("./query-snapshot.constants");
10
+ const query_snapshot_debounce_service_1 = require("./query-snapshot-debounce.service");
11
+ //#region ----- Entity-change middleware -----
12
+ let QuerySnapshotEntityChangeMiddleware = QuerySnapshotEntityChangeMiddleware_1 = class QuerySnapshotEntityChangeMiddleware {
13
+ constructor(debounce) {
14
+ this.debounce = debounce;
15
+ this.target = {
16
+ ops: ['create', 'update', 'delete'],
17
+ order: 80,
18
+ };
19
+ this.logger = new common_1.Logger(QuerySnapshotEntityChangeMiddleware_1.name);
20
+ }
21
+ execute(ctx, next) {
22
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
23
+ yield next();
24
+ if (ctx.entityName === query_snapshot_constants_1.QUERY_SNAPSHOT_ENTITY || ctx.entityName === query_snapshot_constants_1.QUERY_SNAPSHOT_POLICY_ENTITY) {
25
+ return;
26
+ }
27
+ const operation = ctx.op;
28
+ if (operation !== 'create' && operation !== 'update' && operation !== 'delete') {
29
+ return;
30
+ }
31
+ const tenantId = resolveWriteTenantId(ctx);
32
+ if (!tenantId) {
33
+ return;
34
+ }
35
+ try {
36
+ yield this.debounce.onEntityWrite({
37
+ entityName: ctx.entityName,
38
+ operation,
39
+ tenantId,
40
+ applicationId: resolveWriteApplicationId(ctx),
41
+ });
42
+ }
43
+ catch (error) {
44
+ this.logger.warn(`Query snapshot trigger failed for ${ctx.entityName}: ${error instanceof Error ? error.message : String(error)}`);
45
+ }
46
+ });
47
+ }
48
+ };
49
+ exports.QuerySnapshotEntityChangeMiddleware = QuerySnapshotEntityChangeMiddleware;
50
+ exports.QuerySnapshotEntityChangeMiddleware = QuerySnapshotEntityChangeMiddleware = QuerySnapshotEntityChangeMiddleware_1 = tslib_1.__decorate([
51
+ (0, common_1.Injectable)(),
52
+ tslib_1.__metadata("design:paramtypes", [query_snapshot_debounce_service_1.QuerySnapshotDebounceService])
53
+ ], QuerySnapshotEntityChangeMiddleware);
54
+ function resolveWriteTenantId(ctx) {
55
+ var _a, _b, _c, _d;
56
+ const session = readSession();
57
+ if ((_a = session === null || session === void 0 ? void 0 : session.tenantId) === null || _a === void 0 ? void 0 : _a.trim()) {
58
+ return session.tenantId.trim();
59
+ }
60
+ return (_c = (_b = readScope(ctx.data)) === null || _b === void 0 ? void 0 : _b.tenantId) !== null && _c !== void 0 ? _c : (_d = readScope(ctx.previous)) === null || _d === void 0 ? void 0 : _d.tenantId;
61
+ }
62
+ function resolveWriteApplicationId(ctx) {
63
+ var _a, _b, _c, _d;
64
+ const session = readSession();
65
+ if ((_a = session === null || session === void 0 ? void 0 : session.applicationId) === null || _a === void 0 ? void 0 : _a.trim()) {
66
+ return session.applicationId.trim();
67
+ }
68
+ return (_c = (_b = readScope(ctx.data)) === null || _b === void 0 ? void 0 : _b.applicationId) !== null && _c !== void 0 ? _c : (_d = readScope(ctx.previous)) === null || _d === void 0 ? void 0 : _d.applicationId;
69
+ }
70
+ function readSession() {
71
+ var _a;
72
+ const request = (0, core_1.getEntityStorageRequest)();
73
+ return (_a = request === null || request === void 0 ? void 0 : request[security_1.CURRENT_SESSION_KEY]) !== null && _a !== void 0 ? _a : null;
74
+ }
75
+ function readScope(value) {
76
+ if (!value || typeof value !== 'object') {
77
+ return undefined;
78
+ }
79
+ const scope = value.scopeInfo;
80
+ if (!scope || typeof scope !== 'object') {
81
+ return undefined;
82
+ }
83
+ const record = scope;
84
+ return {
85
+ tenantId: typeof record.tenantId === 'string' ? record.tenantId : undefined,
86
+ applicationId: typeof record.applicationId === 'string' ? record.applicationId : undefined,
87
+ };
88
+ }
89
+ //#endregion
90
+ //# sourceMappingURL=query-snapshot-entity-change.middleware.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query-snapshot-entity-change.middleware.js","sourceRoot":"","sources":["../../../../../../../libs/modules/report-management/server/src/lib/query-snapshots/query-snapshot-entity-change.middleware.ts"],"names":[],"mappings":";;;;;AAAA,2CAAoD;AACpD,iEAKgD;AAChD,yEAAiF;AACjF,yEAAiG;AACjG,uFAAiF;AAEjF,8CAA8C;AAGvC,IAAM,mCAAmC,2CAAzC,MAAM,mCAAmC;IAQ9C,YAA6B,QAAsC;QAAtC,aAAQ,GAAR,QAAQ,CAA8B;QAP1D,WAAM,GAAG;YAChB,GAAG,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAkB;YACpD,KAAK,EAAE,EAAE;SACV,CAAC;QA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AAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS;QAC3E,aAAa,EAAE,OAAO,MAAM,CAAC,aAAa,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS;KAC3F,CAAC;AACJ,CAAC;AAED,YAAY"}
@@ -0,0 +1,9 @@
1
+ import { OnModuleInit } from '@nestjs/common';
2
+ import { EntityStorageMiddlewareService } from '@acorex-platform/framework-server/core';
3
+ import { QuerySnapshotEntityChangeMiddleware } from './query-snapshot-entity-change.middleware';
4
+ export declare class QuerySnapshotEntityStorageBootstrap implements OnModuleInit {
5
+ private readonly storage;
6
+ private readonly entityChangeMiddleware;
7
+ constructor(storage: EntityStorageMiddlewareService, entityChangeMiddleware: QuerySnapshotEntityChangeMiddleware);
8
+ onModuleInit(): void;
9
+ }
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.QuerySnapshotEntityStorageBootstrap = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const common_1 = require("@nestjs/common");
6
+ const core_1 = require("@acorex-platform/framework-server/core");
7
+ const query_snapshot_entity_change_middleware_1 = require("./query-snapshot-entity-change.middleware");
8
+ //#region ----- Entity storage bootstrap -----
9
+ let QuerySnapshotEntityStorageBootstrap = class QuerySnapshotEntityStorageBootstrap {
10
+ constructor(storage, entityChangeMiddleware) {
11
+ this.storage = storage;
12
+ this.entityChangeMiddleware = entityChangeMiddleware;
13
+ }
14
+ onModuleInit() {
15
+ this.storage.registerLateMiddleware(this.entityChangeMiddleware);
16
+ }
17
+ };
18
+ exports.QuerySnapshotEntityStorageBootstrap = QuerySnapshotEntityStorageBootstrap;
19
+ exports.QuerySnapshotEntityStorageBootstrap = QuerySnapshotEntityStorageBootstrap = tslib_1.__decorate([
20
+ (0, common_1.Injectable)(),
21
+ tslib_1.__metadata("design:paramtypes", [core_1.EntityStorageMiddlewareService,
22
+ query_snapshot_entity_change_middleware_1.QuerySnapshotEntityChangeMiddleware])
23
+ ], QuerySnapshotEntityStorageBootstrap);
24
+ //#endregion
25
+ //# sourceMappingURL=query-snapshot-entity-storage.bootstrap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query-snapshot-entity-storage.bootstrap.js","sourceRoot":"","sources":["../../../../../../../libs/modules/report-management/server/src/lib/query-snapshots/query-snapshot-entity-storage.bootstrap.ts"],"names":[],"mappings":";;;;AAAA,2CAA0D;AAC1D,iEAAwF;AACxF,uGAAgG;AAEhG,8CAA8C;AAGvC,IAAM,mCAAmC,GAAzC,MAAM,mCAAmC;IAC9C,YACmB,OAAuC,EACvC,sBAA2D;QAD3D,YAAO,GAAP,OAAO,CAAgC;QACvC,2BAAsB,GAAtB,sBAAsB,CAAqC;IAC3E,CAAC;IAEJ,YAAY;QACV,IAAI,CAAC,OAAO,CAAC,sBAAsB,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;IACnE,CAAC;CACF,CAAA;AATY,kFAAmC;8CAAnC,mCAAmC;IAD/C,IAAA,mBAAU,GAAE;6CAGiB,qCAA8B;QACf,6EAAmC;GAHnE,mCAAmC,CAS/C;AAED,YAAY"}
@@ -0,0 +1,22 @@
1
+ import type { AXPQuerySnapshotOption } from '@acorex-platform/framework-shared/runtime';
2
+ import type { AXMQuerySnapshotPayload, AXMQuerySnapshotPolicyTriggers } from '@acorex-platform/module-report-management-client/contracts';
3
+ export type QuerySnapshotFilterClause = {
4
+ field: string;
5
+ value: unknown;
6
+ operator: string;
7
+ };
8
+ export type QuerySnapshotInputClass = 'canonical' | 'sliceable' | 'compute';
9
+ export declare function toQuerySnapshotPayload(result: unknown): AXMQuerySnapshotPayload | null;
10
+ export declare function querySnapshotFailureMessage(result: unknown): string;
11
+ export declare function isQuerySnapshotFresh(calculatedAt: string | undefined, staleAfterMs: number | undefined, nowMs?: number): boolean;
12
+ /** Whether `options.snapshot` requests ensure-on-miss (true or freshness object). */
13
+ export declare function isQuerySnapshotEnsureRequested(snapshot: AXPQuerySnapshotOption | undefined): boolean;
14
+ /**
15
+ * Freshness for this call: optional `maxAgeMs` / `minCalculatedAt` from options,
16
+ * otherwise policy `staleAfterMs`.
17
+ */
18
+ export declare function isQuerySnapshotFreshForOption(calculatedAt: string | undefined, policyStaleAfterMs: number | undefined, snapshot: AXPQuerySnapshotOption | undefined, nowMs?: number): boolean;
19
+ export declare function extractQuerySnapshotFilterClauses(input: unknown): QuerySnapshotFilterClause[];
20
+ export declare function classifyQuerySnapshotInput(input: unknown, payload: AXMQuerySnapshotPayload): QuerySnapshotInputClass;
21
+ export declare function applyQuerySnapshotInput(payload: AXMQuerySnapshotPayload, input: unknown): AXMQuerySnapshotPayload;
22
+ export declare function normalizePolicyTriggers(value: unknown): AXMQuerySnapshotPolicyTriggers;