@acorex-platform/module-report-management-server 0.0.15 → 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,135 @@
1
+ "use strict";
2
+ var QuerySnapshotMiddlewareService_1;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.QuerySnapshotMiddlewareService = 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 providers_1 = require("@acorex-platform/framework-server/domain/providers");
9
+ const security_1 = require("@acorex-platform/framework-server/security");
10
+ const query_snapshot_bypass_util_1 = require("./query-snapshot-bypass.util");
11
+ const query_snapshot_payload_util_1 = require("./query-snapshot-payload.util");
12
+ const query_snapshot_store_1 = require("./query-snapshot.store");
13
+ //#endregion
14
+ //#region ----- Query snapshot middleware -----
15
+ /**
16
+ * Server named-query middleware: serve / optionally ensure QuerySnapshot when a
17
+ * QuerySnapshotPolicy exists. Registers on {@link ServerQueryRegistry}.
18
+ *
19
+ * - `options.snapshot` omitted — transparent serve when ready+fresh; miss → live (no write)
20
+ * - `options.snapshot: true | { … }` — same, plus sync ensure on miss/stale
21
+ * - `options.snapshot: false` — force live
22
+ * - no policy — always live
23
+ */
24
+ let QuerySnapshotMiddlewareService = QuerySnapshotMiddlewareService_1 = class QuerySnapshotMiddlewareService {
25
+ constructor(store, queryRegistry) {
26
+ this.store = store;
27
+ this.queryRegistry = queryRegistry;
28
+ this.logger = new common_1.Logger(QuerySnapshotMiddlewareService_1.name);
29
+ }
30
+ onModuleInit() {
31
+ this.queryRegistry.use(this.createMiddleware());
32
+ }
33
+ createMiddleware() {
34
+ return (context, next) => this.resolve(context, next);
35
+ }
36
+ resolve(context, next) {
37
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
38
+ var _a, _b, _c, _d, _e;
39
+ if ((0, query_snapshot_bypass_util_1.isQuerySnapshotBypass)()) {
40
+ return next(context);
41
+ }
42
+ const snapshotOption = (_a = context.options) === null || _a === void 0 ? void 0 : _a.snapshot;
43
+ if (snapshotOption === false) {
44
+ return next(context);
45
+ }
46
+ const tenantId = (_c = (_b = readSessionScope()) === null || _b === void 0 ? void 0 : _b.tenantId) === null || _c === void 0 ? void 0 : _c.trim();
47
+ if (!tenantId) {
48
+ return next(context);
49
+ }
50
+ const key = context.key;
51
+ const policy = yield this.store.findEnabledPolicy(key);
52
+ if (!policy) {
53
+ return next(context);
54
+ }
55
+ const ensure = (0, query_snapshot_payload_util_1.isQuerySnapshotEnsureRequested)(snapshotOption);
56
+ const snapshot = yield this.store.findSnapshot(key, tenantId);
57
+ const canServe = !!snapshot &&
58
+ snapshot.status === 'ready' &&
59
+ !!((_d = snapshot.payload) === null || _d === void 0 ? void 0 : _d.success) &&
60
+ (0, query_snapshot_payload_util_1.isQuerySnapshotFreshForOption)(snapshot.calculatedAt, policy.staleAfterMs, snapshotOption);
61
+ if (canServe && snapshot.payload) {
62
+ const definition = yield this.store.getQueryDefinition(key);
63
+ if ((definition === null || definition === void 0 ? void 0 : definition.kind) && definition.kind !== snapshot.payload.kind) {
64
+ this.logger.debug(`Snapshot kind ${snapshot.payload.kind} does not match query ${key} kind ${definition.kind}`);
65
+ }
66
+ else {
67
+ const classification = (0, query_snapshot_payload_util_1.classifyQuerySnapshotInput)(context.input, snapshot.payload);
68
+ if (classification === 'compute') {
69
+ return next(context);
70
+ }
71
+ return (0, query_snapshot_payload_util_1.applyQuerySnapshotInput)(snapshot.payload, context.input);
72
+ }
73
+ }
74
+ if (!ensure) {
75
+ return next(context);
76
+ }
77
+ // Ensure only for canonical / known-sliceable inputs (never write on compute).
78
+ const hasFilters = (0, query_snapshot_payload_util_1.extractQuerySnapshotFilterClauses)(context.input).length > 0;
79
+ if (hasFilters) {
80
+ if (!((_e = snapshot === null || snapshot === void 0 ? void 0 : snapshot.payload) === null || _e === void 0 ? void 0 : _e.success)) {
81
+ return next(context);
82
+ }
83
+ if ((0, query_snapshot_payload_util_1.classifyQuerySnapshotInput)(context.input, snapshot.payload) === 'compute') {
84
+ return next(context);
85
+ }
86
+ }
87
+ const started = Date.now();
88
+ const liveResult = yield next(Object.assign(Object.assign({}, context), { input: {} }));
89
+ const payload = (0, query_snapshot_payload_util_1.toQuerySnapshotPayload)(liveResult);
90
+ const durationMs = Date.now() - started;
91
+ const session = readSessionScope();
92
+ if (!payload) {
93
+ yield this.store.markFailed({
94
+ key,
95
+ tenantId,
96
+ lastError: 'Query snapshot ensure failed',
97
+ durationMs,
98
+ });
99
+ return liveResult;
100
+ }
101
+ const definition = yield this.store.getQueryDefinition(key);
102
+ if ((definition === null || definition === void 0 ? void 0 : definition.kind) && definition.kind !== payload.kind) {
103
+ yield this.store.markFailed({
104
+ key,
105
+ tenantId,
106
+ lastError: `Snapshot kind ${payload.kind} does not match query kind ${definition.kind}`,
107
+ durationMs,
108
+ });
109
+ return liveResult;
110
+ }
111
+ yield this.store.upsertReady({
112
+ key,
113
+ tenantId,
114
+ applicationId: session === null || session === void 0 ? void 0 : session.applicationId,
115
+ payload,
116
+ durationMs,
117
+ calculatedAt: new Date().toISOString(),
118
+ });
119
+ return (0, query_snapshot_payload_util_1.applyQuerySnapshotInput)(payload, context.input);
120
+ });
121
+ }
122
+ };
123
+ exports.QuerySnapshotMiddlewareService = QuerySnapshotMiddlewareService;
124
+ exports.QuerySnapshotMiddlewareService = QuerySnapshotMiddlewareService = QuerySnapshotMiddlewareService_1 = tslib_1.__decorate([
125
+ (0, common_1.Injectable)(),
126
+ tslib_1.__metadata("design:paramtypes", [query_snapshot_store_1.QuerySnapshotStore,
127
+ providers_1.ServerQueryRegistry])
128
+ ], QuerySnapshotMiddlewareService);
129
+ function readSessionScope() {
130
+ var _a;
131
+ const request = (0, core_1.getEntityStorageRequest)();
132
+ return (_a = request === null || request === void 0 ? void 0 : request[security_1.CURRENT_SESSION_KEY]) !== null && _a !== void 0 ? _a : null;
133
+ }
134
+ //#endregion
135
+ //# sourceMappingURL=query-snapshot.middleware.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query-snapshot.middleware.js","sourceRoot":"","sources":["../../../../../../../libs/modules/report-management/server/src/lib/query-snapshots/query-snapshot.middleware.ts"],"names":[],"mappings":";;;;;AAAA,2CAAkE;AAClE,iEAAiF;AAC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AAU,CAAE,IAAI,KAAI,UAAU,CAAC,IAAI,KAAK,OAAO,CAAC,IAAI,EAAE,CAAC;gBACzD,MAAM,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC;oBAC1B,GAAG;oBACH,QAAQ;oBACR,SAAS,EAAE,iBAAiB,OAAO,CAAC,IAAI,8BAA8B,UAAU,CAAC,IAAI,EAAE;oBACvF,UAAU;iBACX,CAAC,CAAC;gBACH,OAAO,UAAU,CAAC;YACpB,CAAC;YAED,MAAM,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC;gBAC3B,GAAG;gBACH,QAAQ;gBACR,aAAa,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,aAAa;gBACrC,OAAO;gBACP,UAAU;gBACV,YAAY,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;aACvC,CAAC,CAAC;YAEH,OAAO,IAAA,qDAAuB,EAAC,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;QACzD,CAAC;KAAA;CACF,CAAA;AApHY,wEAA8B;yCAA9B,8BAA8B;IAD1C,IAAA,mBAAU,GAAE;6CAKe,yCAAkB;QACV,+BAAmB;GAL1C,8BAA8B,CAoH1C;AAED,SAAS,gBAAgB;;IACvB,MAAM,OAAO,GAAG,IAAA,8BAAuB,GAE1B,CAAC;IACd,OAAO,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAG,8BAAmB,CAAC,mCAAI,IAAI,CAAC;AAChD,CAAC;AAED,YAAY"}
@@ -0,0 +1,34 @@
1
+ import { EntityStorageMiddlewareService } from '@acorex-platform/framework-server/core';
2
+ import type { AXMQuerySnapshotEntityModel, AXMQuerySnapshotPayload, AXMQuerySnapshotPolicyEntityModel } from '@acorex-platform/module-report-management-client/contracts';
3
+ export type QuerySnapshotPolicyRow = AXMQuerySnapshotPolicyEntityModel;
4
+ export type QuerySnapshotRow = AXMQuerySnapshotEntityModel;
5
+ export type QueryDefinitionSnapshotMeta = {
6
+ name: string;
7
+ kind?: string;
8
+ executionMode?: string;
9
+ };
10
+ export declare class QuerySnapshotStore {
11
+ private readonly storage;
12
+ private policyCache?;
13
+ constructor(storage: EntityStorageMiddlewareService);
14
+ listEnabledPolicies(queryKeys?: string[]): Promise<QuerySnapshotPolicyRow[]>;
15
+ findEnabledPolicy(queryName: string): Promise<QuerySnapshotPolicyRow | null>;
16
+ findSnapshot(key: string, tenantId: string): Promise<QuerySnapshotRow | null>;
17
+ upsertReady(input: {
18
+ key: string;
19
+ tenantId: string;
20
+ applicationId?: string;
21
+ payload: AXMQuerySnapshotPayload;
22
+ durationMs: number;
23
+ calculatedAt: string;
24
+ }): Promise<void>;
25
+ markFailed(input: {
26
+ key: string;
27
+ tenantId: string;
28
+ lastError: string;
29
+ durationMs: number;
30
+ }): Promise<void>;
31
+ markStale(key: string, tenantId: string): Promise<void>;
32
+ getQueryDefinition(queryName: string): Promise<QueryDefinitionSnapshotMeta | null>;
33
+ private loadEnabledPolicies;
34
+ }
@@ -0,0 +1,137 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.QuerySnapshotStore = 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 abstract_1 = require("@acorex-platform/framework-server/jql/abstract");
8
+ const seed_1 = require("@acorex-platform/module-common-server/seed");
9
+ const query_snapshot_constants_1 = require("./query-snapshot.constants");
10
+ const query_snapshot_payload_util_1 = require("./query-snapshot-payload.util");
11
+ //#endregion
12
+ //#region ----- Query snapshot store -----
13
+ let QuerySnapshotStore = class QuerySnapshotStore {
14
+ constructor(storage) {
15
+ this.storage = storage;
16
+ }
17
+ listEnabledPolicies(queryKeys) {
18
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
19
+ const rows = yield this.loadEnabledPolicies();
20
+ if (!(queryKeys === null || queryKeys === void 0 ? void 0 : queryKeys.length)) {
21
+ return rows;
22
+ }
23
+ const allowed = new Set(queryKeys);
24
+ return rows.filter((row) => allowed.has(row.queryName));
25
+ });
26
+ }
27
+ findEnabledPolicy(queryName) {
28
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
29
+ var _a;
30
+ const rows = yield this.loadEnabledPolicies();
31
+ return (_a = rows.find((row) => row.queryName === queryName)) !== null && _a !== void 0 ? _a : null;
32
+ });
33
+ }
34
+ findSnapshot(key, tenantId) {
35
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
36
+ var _a;
37
+ const result = yield this.storage.queryAsEngine(query_snapshot_constants_1.QUERY_SNAPSHOT_ENTITY, (0, abstract_1.bypassAllEntityVisibilityFilters)({
38
+ skip: 0,
39
+ take: 1,
40
+ filter: {
41
+ field: null,
42
+ logic: 'and',
43
+ operator: null,
44
+ filters: [
45
+ { field: 'key', operator: { type: 'equal' }, value: key },
46
+ { field: 'scopeInfo.tenantId', operator: { type: 'equal' }, value: tenantId },
47
+ ],
48
+ },
49
+ }));
50
+ const row = ((_a = result.items) !== null && _a !== void 0 ? _a : [])[0];
51
+ return (row === null || row === void 0 ? void 0 : row.id) ? row : null;
52
+ });
53
+ }
54
+ upsertReady(input) {
55
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
56
+ const existing = yield this.findSnapshot(input.key, input.tenantId);
57
+ const scopeInfo = { tenantId: input.tenantId };
58
+ const patch = {
59
+ key: input.key,
60
+ status: 'ready',
61
+ calculatedAt: input.calculatedAt,
62
+ durationMs: input.durationMs,
63
+ lastError: '',
64
+ payload: input.payload,
65
+ scopeInfo,
66
+ };
67
+ if (existing === null || existing === void 0 ? void 0 : existing.id) {
68
+ yield this.storage.updateOneAsEngine(query_snapshot_constants_1.QUERY_SNAPSHOT_ENTITY, existing.id, patch);
69
+ return;
70
+ }
71
+ yield this.storage.insertOneAsEngine(query_snapshot_constants_1.QUERY_SNAPSHOT_ENTITY, Object.assign({ id: snapshotRowId(input.tenantId, input.key) }, patch));
72
+ });
73
+ }
74
+ markFailed(input) {
75
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
76
+ const existing = yield this.findSnapshot(input.key, input.tenantId);
77
+ if (!(existing === null || existing === void 0 ? void 0 : existing.id)) {
78
+ return;
79
+ }
80
+ yield this.storage.updateOneAsEngine(query_snapshot_constants_1.QUERY_SNAPSHOT_ENTITY, existing.id, {
81
+ status: 'failed',
82
+ lastError: input.lastError,
83
+ durationMs: input.durationMs,
84
+ });
85
+ });
86
+ }
87
+ markStale(key, tenantId) {
88
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
89
+ const existing = yield this.findSnapshot(key, tenantId);
90
+ if (!(existing === null || existing === void 0 ? void 0 : existing.id) || existing.status === 'failed') {
91
+ return;
92
+ }
93
+ yield this.storage.updateOneAsEngine(query_snapshot_constants_1.QUERY_SNAPSHOT_ENTITY, existing.id, { status: 'stale' });
94
+ });
95
+ }
96
+ getQueryDefinition(queryName) {
97
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
98
+ var _a;
99
+ const result = yield this.storage.queryAsEngine(query_snapshot_constants_1.QUERY_DEFINITION_ENTITY, (0, abstract_1.bypassAllEntityVisibilityFilters)({
100
+ skip: 0,
101
+ take: 1,
102
+ filter: { field: 'name', operator: { type: 'equal' }, value: queryName },
103
+ }));
104
+ const row = ((_a = result.items) !== null && _a !== void 0 ? _a : [])[0];
105
+ return (row === null || row === void 0 ? void 0 : row.name) ? row : null;
106
+ });
107
+ }
108
+ loadEnabledPolicies() {
109
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
110
+ var _a;
111
+ const now = Date.now();
112
+ if (this.policyCache && now - this.policyCache.at < query_snapshot_constants_1.QUERY_SNAPSHOT_POLICY_CACHE_MS) {
113
+ return this.policyCache.rows;
114
+ }
115
+ const result = yield this.storage.queryAsEngine(query_snapshot_constants_1.QUERY_SNAPSHOT_POLICY_ENTITY, (0, abstract_1.bypassAllEntityVisibilityFilters)({
116
+ skip: 0,
117
+ take: 500,
118
+ filter: { field: 'enabled', operator: { type: 'equal' }, value: true },
119
+ }));
120
+ const rows = ((_a = result.items) !== null && _a !== void 0 ? _a : [])
121
+ .filter((row) => typeof row.queryName === 'string' && row.queryName.trim().length > 0)
122
+ .map((row) => (Object.assign(Object.assign({}, row), { triggers: (0, query_snapshot_payload_util_1.normalizePolicyTriggers)(row.triggers) })));
123
+ this.policyCache = { at: now, rows };
124
+ return rows;
125
+ });
126
+ }
127
+ };
128
+ exports.QuerySnapshotStore = QuerySnapshotStore;
129
+ exports.QuerySnapshotStore = QuerySnapshotStore = tslib_1.__decorate([
130
+ (0, common_1.Injectable)(),
131
+ tslib_1.__metadata("design:paramtypes", [core_1.EntityStorageMiddlewareService])
132
+ ], QuerySnapshotStore);
133
+ function snapshotRowId(tenantId, queryName) {
134
+ return (0, seed_1.tenantMasterId)(query_snapshot_constants_1.QUERY_SNAPSHOT_ROW_NAMESPACE, tenantId, queryName);
135
+ }
136
+ //#endregion
137
+ //# sourceMappingURL=query-snapshot.store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query-snapshot.store.js","sourceRoot":"","sources":["../../../../../../../libs/modules/report-management/server/src/lib/query-snapshots/query-snapshot.store.ts"],"names":[],"mappings":";;;;AAAA,2CAA4C;AAC5C,iEAAwF;AACxF,6EAAkG;AAClG,qEAA4E;AAO5E,yEAMoC;AACpC,+EAAwE;AAaxE,YAAY;AAEZ,0CAA0C;AAGnC,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAG7B,YAA6B,OAAuC;QAAvC,YAAO,GAAP,OAAO,CAAgC;IAAG,CAAC;IAElE,mBAAmB,CAAC,SAAoB;;YAC5C,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,mBAAmB,EAAE,CAAC;YAC9C,IAAI,CAAC,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,MAAM,CAAA,EAAE,CAAC;gBACvB,OAAO,IAAI,CAAC;YACd,CAAC;YACD,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC;YAC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C,IAAI,CAAC;YAC/B,CAAC;YAED,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,aAAa,CAC7C,uDAA4B,EAC5B,IAAA,2CAAgC,EAAC;gBAC/B,IAAI,EAAE,CAAC;gBACP,IAAI,EAAE,GAAG;gBACT,MAAM,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE;aACvE,CAAC,CACH,CAAC;YAEF,MAAM,IAAI,GAAI,CAAC,MAAA,MAAM,CAAC,KAAK,mCAAI,EAAE,CAA8B;iBAC5D,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,GAAG,CAAC,SAAS,KAAK,QAAQ,IAAI,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC;iBACrF,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,iCACT,GAAG,KACN,QAAQ,EAAE,IAAA,qDAAuB,EAAC,GAAG,CAAC,QAAQ,CAAC,IAC/C,CAAC,CAAC;YAEN,IAAI,CAAC,WAAW,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;YACrC,OAAO,IAAI,CAAC;QACd,CAAC;KAAA;CACF,CAAA;AAtIY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,mBAAU,GAAE;6CAI2B,qCAA8B;GAHzD,kBAAkB,CAsI9B;AAED,SAAS,aAAa,CAAC,QAAgB,EAAE,SAAiB;IACxD,OAAO,IAAA,qBAAc,EAAC,uDAA4B,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;AAC3E,CAAC;AAED,YAAY"}
@@ -0,0 +1,8 @@
1
+ import type { AXPCommand, AXPCommandExecuteResultPromise } from '@acorex-platform/framework-shared/runtime';
2
+ import { type AXMRecalculateQuerySnapshotsInput } from '@acorex-platform/module-report-management-client/contracts';
3
+ import { QuerySnapshotRecalcService } from './query-snapshot-recalc.service';
4
+ export declare class RecalculateQuerySnapshotsCommand implements AXPCommand<AXMRecalculateQuerySnapshotsInput, Record<string, unknown>> {
5
+ private readonly recalc;
6
+ constructor(recalc: QuerySnapshotRecalcService);
7
+ execute(input?: AXMRecalculateQuerySnapshotsInput): AXPCommandExecuteResultPromise<Record<string, unknown>>;
8
+ }
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RecalculateQuerySnapshotsCommand = 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 abstract_1 = require("@acorex-platform/framework-server/domain/abstract");
8
+ const module_report_management_contracts_1 = require("@acorex-platform/module-report-management-client/contracts");
9
+ const query_snapshot_recalc_service_1 = require("./query-snapshot-recalc.service");
10
+ //#region ----- Recalculate command -----
11
+ let RecalculateQuerySnapshotsCommand = class RecalculateQuerySnapshotsCommand {
12
+ constructor(recalc) {
13
+ this.recalc = recalc;
14
+ }
15
+ execute() {
16
+ return tslib_1.__awaiter(this, arguments, void 0, function* (input = {}) {
17
+ var _a, _b, _c, _d;
18
+ const runtime = background_job_1.BackgroundJobRuntime.current();
19
+ const tenantId = ((_a = runtime === null || runtime === void 0 ? void 0 : runtime.tenantId) === null || _a === void 0 ? void 0 : _a.trim()) || ((_b = input.tenantId) === null || _b === void 0 ? void 0 : _b.trim());
20
+ if (!tenantId) {
21
+ return {
22
+ success: false,
23
+ message: { text: 'Tenant context is required to recalculate query snapshots.' },
24
+ };
25
+ }
26
+ const applicationId = ((_c = runtime === null || runtime === void 0 ? void 0 : runtime.applicationId) === null || _c === void 0 ? void 0 : _c.trim()) || ((_d = input.applicationId) === null || _d === void 0 ? void 0 : _d.trim()) || undefined;
27
+ const queryKeys = resolveQueryKeys(runtime === null || runtime === void 0 ? void 0 : runtime.payload, input);
28
+ const force = resolveForce(runtime === null || runtime === void 0 ? void 0 : runtime.payload, input);
29
+ yield (runtime === null || runtime === void 0 ? void 0 : runtime.reportProgress(10, 'Recalculating query snapshots'));
30
+ yield (runtime === null || runtime === void 0 ? void 0 : runtime.heartbeat());
31
+ const summary = yield this.recalc.run({ tenantId, applicationId, queryKeys, force });
32
+ const message = `Query snapshots: ${summary.ready} ready, ${summary.failed} failed, ${summary.skipped} skipped ` +
33
+ `(${summary.attempted} attempted).`;
34
+ yield (runtime === null || runtime === void 0 ? void 0 : runtime.reportProgress(100, message));
35
+ return {
36
+ success: true,
37
+ kind: 'object',
38
+ data: Object.assign({}, summary),
39
+ message: { text: message },
40
+ };
41
+ });
42
+ }
43
+ };
44
+ exports.RecalculateQuerySnapshotsCommand = RecalculateQuerySnapshotsCommand;
45
+ exports.RecalculateQuerySnapshotsCommand = RecalculateQuerySnapshotsCommand = tslib_1.__decorate([
46
+ (0, abstract_1.ServerHandler)({ key: module_report_management_contracts_1.AXM_RECALCULATE_QUERY_SNAPSHOTS_COMMAND_KEY }),
47
+ (0, common_1.Injectable)(),
48
+ tslib_1.__metadata("design:paramtypes", [query_snapshot_recalc_service_1.QuerySnapshotRecalcService])
49
+ ], RecalculateQuerySnapshotsCommand);
50
+ function resolveQueryKeys(payload, input) {
51
+ var _a;
52
+ if ((_a = input.queryKeys) === null || _a === void 0 ? void 0 : _a.length) {
53
+ return input.queryKeys;
54
+ }
55
+ if (payload && typeof payload === 'object') {
56
+ const keys = payload.queryKeys;
57
+ if (Array.isArray(keys)) {
58
+ const names = keys.filter((item) => typeof item === 'string' && item.trim().length > 0);
59
+ return names.length ? names : undefined;
60
+ }
61
+ }
62
+ return undefined;
63
+ }
64
+ function resolveForce(payload, input) {
65
+ if (input.force === true) {
66
+ return true;
67
+ }
68
+ if (payload && typeof payload === 'object' && payload.force === true) {
69
+ return true;
70
+ }
71
+ return false;
72
+ }
73
+ //#endregion
74
+ //# sourceMappingURL=recalculate-query-snapshots.command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recalculate-query-snapshots.command.js","sourceRoot":"","sources":["../../../../../../../libs/modules/report-management/server/src/lib/query-snapshots/recalculate-query-snapshots.command.ts"],"names":[],"mappings":";;;;AAAA,2CAA4C;AAC5C,qFAAwF;AACxF,gFAAkF;AAElF,4GAG6D;AAC7D,mFAA6E;AAE7E,yCAAyC;AAIlC,IAAM,gCAAgC,GAAtC,MAAM,gCAAgC;IAG3C,YAA6B,MAAkC;QAAlC,WAAM,GAAN,MAAM,CAA4B;IAAG,CAAC;IAE7D,OAAO;qEACX,QAA2C,EAAE;;YAE7C,MAAM,OAAO,GAAG,qCAAoB,CAAC,OAAO,EAAE,CAAC;YAC/C,MAAM,QAAQ,GAAG,CAAA,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,QAAQ,0CAAE,IAAI,EAAE,MAAI,MAAA,KAAK,CAAC,QAAQ,0CAAE,IAAI,EAAE,CAAA,CAAC;YACrE,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACd,OAAO;oBACL,OAAO,EAAE,KAAK;oBACd,OAAO,EAAE,EAAE,IAAI,EAAE,4DAA4D,EAAE;iBAChF,CAAC;YACJ,CAAC;YAED,MAAM,aAAa,GAAG,CAAA,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,aAAa,0CAAE,IAAI,EAAE,MAAI,MAAA,KAAK,CAAC,aAAa,0CAAE,IAAI,EAAE,CAAA,IAAI,SAAS,CAAC;YACjG,MAAM,SAAS,GAAG,gBAAgB,CAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,EAAE,KAAK,CAAC,CAAC;YAC5D,MAAM,KAAK,GAAG,YAAY,CAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,EAAE,KAAK,CAAC,CAAC;YAEpD,MAAM,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,cAAc,CAAC,EAAE,EAAE,+BAA+B,CAAC,CAAA,CAAC;YACnE,MAAM,CAAA,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AAI,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YACxG,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;QAC1C,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,YAAY,CAAC,OAAgB,EAAE,KAAwC;IAC9E,IAAI,KAAK,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAK,OAA+B,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;QAC9F,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,YAAY"}
@@ -0,0 +1,16 @@
1
+ import { BackendSessionService } from '@acorex-platform/framework-server/security';
2
+ import type { AXPCommand, AXPCommandExecuteResultPromise } from '@acorex-platform/framework-shared/runtime';
3
+ import { type AXMRefreshQuerySnapshotsInput } from '@acorex-platform/module-report-management-client/contracts';
4
+ import { QuerySnapshotEnqueueService } from './query-snapshot-enqueue.service';
5
+ export declare class RefreshQuerySnapshotsCommand implements AXPCommand<AXMRefreshQuerySnapshotsInput, {
6
+ jobId: string;
7
+ deduplicated?: boolean;
8
+ }> {
9
+ private readonly enqueue;
10
+ private readonly session;
11
+ constructor(enqueue: QuerySnapshotEnqueueService, session: BackendSessionService);
12
+ execute(input?: AXMRefreshQuerySnapshotsInput): AXPCommandExecuteResultPromise<{
13
+ jobId: string;
14
+ deduplicated?: boolean;
15
+ }>;
16
+ }
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RefreshQuerySnapshotsCommand = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const common_1 = require("@nestjs/common");
6
+ const abstract_1 = require("@acorex-platform/framework-server/domain/abstract");
7
+ const security_1 = require("@acorex-platform/framework-server/security");
8
+ const module_report_management_contracts_1 = require("@acorex-platform/module-report-management-client/contracts");
9
+ const query_snapshot_enqueue_service_1 = require("./query-snapshot-enqueue.service");
10
+ //#region ----- Manual refresh command -----
11
+ let RefreshQuerySnapshotsCommand = class RefreshQuerySnapshotsCommand {
12
+ constructor(enqueue, session) {
13
+ this.enqueue = enqueue;
14
+ this.session = session;
15
+ }
16
+ execute() {
17
+ return tslib_1.__awaiter(this, arguments, void 0, function* (input = {}) {
18
+ var _a, _b, _c;
19
+ const session = this.session.getSession();
20
+ const tenantId = (_a = session === null || session === void 0 ? void 0 : session.tenantId) === null || _a === void 0 ? void 0 : _a.trim();
21
+ if (!tenantId) {
22
+ return {
23
+ success: false,
24
+ message: { text: 'Tenant context is required to refresh query snapshots.' },
25
+ };
26
+ }
27
+ const result = yield this.enqueue.enqueue({
28
+ tenantId,
29
+ applicationId: ((_b = session === null || session === void 0 ? void 0 : session.applicationId) === null || _b === void 0 ? void 0 : _b.trim()) || undefined,
30
+ queryKeys: input.queryKeys,
31
+ force: !((_c = input.queryKeys) === null || _c === void 0 ? void 0 : _c.length),
32
+ trigger: 'manual',
33
+ userId: session === null || session === void 0 ? void 0 : session.userId,
34
+ });
35
+ return {
36
+ success: true,
37
+ kind: 'object',
38
+ data: result,
39
+ message: { text: 'Query snapshot refresh queued.' },
40
+ };
41
+ });
42
+ }
43
+ };
44
+ exports.RefreshQuerySnapshotsCommand = RefreshQuerySnapshotsCommand;
45
+ exports.RefreshQuerySnapshotsCommand = RefreshQuerySnapshotsCommand = tslib_1.__decorate([
46
+ (0, abstract_1.ServerHandler)({
47
+ key: module_report_management_contracts_1.AXM_REFRESH_QUERY_SNAPSHOTS_COMMAND_KEY,
48
+ auth: 'session',
49
+ permissions: [module_report_management_contracts_1.AXPInsightsReportingPermissionKeys.Access],
50
+ }),
51
+ (0, common_1.Injectable)(),
52
+ tslib_1.__metadata("design:paramtypes", [query_snapshot_enqueue_service_1.QuerySnapshotEnqueueService,
53
+ security_1.BackendSessionService])
54
+ ], RefreshQuerySnapshotsCommand);
55
+ //#endregion
56
+ //# sourceMappingURL=refresh-query-snapshots.command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refresh-query-snapshots.command.js","sourceRoot":"","sources":["../../../../../../../libs/modules/report-management/server/src/lib/query-snapshots/refresh-query-snapshots.command.ts"],"names":[],"mappings":";;;;AAAA,2CAA4C;AAC5C,gFAAkF;AAClF,yEAAmF;AAEnF,4GAI6D;AAC7D,qFAA+E;AAE/E,4CAA4C;AAQrC,IAAM,4BAA4B,GAAlC,MAAM,4BAA4B;IAGvC,YACmB,OAAoC,EACpC,OAA8B;QAD9B,YAAO,GAAP,OAAO,CAA6B;QACpC,YAAO,GAAP,OAAO,CAAuB;IAC9C,CAAC;IAEE,OAAO;qEACX,QAAuC,EAAE;;YAEzC,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;YAC1C,MAAM,QAAQ,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,QAAQ,0CAAE,IAAI,EAAE,CAAC;YAC3C,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACd,OAAO;oBACL,OAAO,EAAE,KAAK;oBACd,OAAO,EAAE,EAAE,IAAI,EAAE,wDAAwD,EAAE;iBAC5E,CAAC;YACJ,CAAC;YAED,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;gBACxC,QAAQ;gBACR,aAAa,EAAE,CAAA,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,aAAa,0CAAE,IAAI,EAAE,KAAI,SAAS;gBAC1D,SAAS,EAAE,KAAK,CAAC,SAAS;gBAC1B,KAAK,EAAE,CAAC,CAAA,MAAA,KAAK,CAAC,SAAS,0CAAE,MAAM,CAAA;gBAC/B,OAAO,EAAE,QAAQ;gBACjB,MAAM,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM;aACxB,CAAC,CAAC;YAEH,OAAO;gBACL,OAAO,EAAE,IAAI;gBACb,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,MAAM;gBACZ,OAAO,EAAE,EAAE,IAAI,EAAE,gCAAgC,EAAE;aACpD,CAAC;QACJ,CAAC;KAAA;CACF,CAAA;AApCY,oEAA4B;uCAA5B,4BAA4B;IANxC,IAAA,wBAAa,EAAC;QACb,GAAG,EAAE,4EAAuC;QAC5C,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,CAAC,uEAAkC,CAAC,MAAM,CAAC;KACzD,CAAC;IACD,IAAA,mBAAU,GAAE;6CAKiB,4DAA2B;QAC3B,gCAAqB;GALtC,4BAA4B,CAoCxC;AAED,YAAY"}
@@ -5,6 +5,7 @@ const tslib_1 = require("tslib");
5
5
  const common_1 = require("@nestjs/common");
6
6
  const core_1 = require("@acorex-platform/framework-server/core");
7
7
  const report_1 = require("@acorex-platform/framework-server/report");
8
+ const core_2 = require("@acorex-platform/framework-shared/core");
8
9
  //#region ---- Report browse service ----
9
10
  let ReportBrowseService = class ReportBrowseService {
10
11
  constructor(storage) {
@@ -32,7 +33,7 @@ let ReportBrowseService = class ReportBrowseService {
32
33
  }
33
34
  getReportDefinition(reportId) {
34
35
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
35
- const report = (yield this.storage.getOne(report_1.REPORT_ENTITY, reportId));
36
+ const report = yield (0, report_1.loadReportDefinitionById)(this.storage, reportId);
36
37
  if (!report) {
37
38
  throw new common_1.NotFoundException(`Report with ID ${reportId} not found`);
38
39
  }
@@ -44,11 +45,12 @@ let ReportBrowseService = class ReportBrowseService {
44
45
  var _a, _b;
45
46
  const [categoriesResult, reportsResult] = yield Promise.all([
46
47
  this.storage.query(report_1.REPORT_CATEGORY_ENTITY, { skip: 0, take: 10000 }),
47
- this.storage.query(report_1.REPORT_ENTITY, { skip: 0, take: 10000 })
48
+ this.storage.query(report_1.REPORT_ENTITY, { skip: 0, take: 10000 }),
48
49
  ]);
49
50
  return {
50
- categories: ((_a = categoriesResult.items) !== null && _a !== void 0 ? _a : []),
51
- reports: ((_b = reportsResult.items) !== null && _b !== void 0 ? _b : []),
51
+ // Defense: bootstrap used to insert duplicate business ids; keep one per id.
52
+ categories: dedupeById(((_a = categoriesResult.items) !== null && _a !== void 0 ? _a : [])),
53
+ reports: dedupeById(((_b = reportsResult.items) !== null && _b !== void 0 ? _b : [])),
52
54
  };
53
55
  });
54
56
  }
@@ -89,10 +91,11 @@ let ReportBrowseService = class ReportBrowseService {
89
91
  };
90
92
  }
91
93
  mapReportToApiResponse(report) {
92
- var _a, _b, _c, _d, _e, _f, _g;
93
- const title = String((_a = report['title']) !== null && _a !== void 0 ? _a : '');
94
- const parameterGroups = (_b = report['parameterGroups']) !== null && _b !== void 0 ? _b : [];
95
- const layouts = ((_c = report['layouts']) !== null && _c !== void 0 ? _c : []).map((layout) => (Object.assign(Object.assign({}, layout), { dataSource: layout.dataSource
94
+ var _a, _b, _c, _d, _e, _f;
95
+ const title = asCatalogText(report['title']);
96
+ const description = asCatalogText(report['description']);
97
+ const parameterGroups = (_a = report['parameterGroups']) !== null && _a !== void 0 ? _a : [];
98
+ const layouts = ((_b = report['layouts']) !== null && _b !== void 0 ? _b : []).map((layout) => (Object.assign(Object.assign({}, layout), { dataSource: layout.dataSource
96
99
  ? {
97
100
  type: layout.dataSource.type,
98
101
  name: layout.dataSource.name,
@@ -102,14 +105,15 @@ let ReportBrowseService = class ReportBrowseService {
102
105
  }
103
106
  : undefined })));
104
107
  return {
105
- id: String((_d = report['id']) !== null && _d !== void 0 ? _d : ''),
108
+ id: String((_c = report['id']) !== null && _c !== void 0 ? _c : ''),
106
109
  name: toApiName(title),
107
110
  title,
108
- description: (_e = report['description']) !== null && _e !== void 0 ? _e : null,
109
- categoryIds: (_f = report['categoryIds']) !== null && _f !== void 0 ? _f : [],
111
+ description: description === '' ? null : description,
112
+ categoryIds: (_d = report['categoryIds']) !== null && _d !== void 0 ? _d : [],
110
113
  parameterGroups,
111
114
  layouts,
112
- defaultLayoutId: String((_g = report['defaultLayoutId']) !== null && _g !== void 0 ? _g : ''),
115
+ defaultLayoutId: String((_e = report['defaultLayoutId']) !== null && _e !== void 0 ? _e : ''),
116
+ generation: (_f = report['generation']) !== null && _f !== void 0 ? _f : undefined,
113
117
  };
114
118
  }
115
119
  };
@@ -118,11 +122,26 @@ exports.ReportBrowseService = ReportBrowseService = tslib_1.__decorate([
118
122
  (0, common_1.Injectable)(),
119
123
  tslib_1.__metadata("design:paramtypes", [core_1.EntityStorageMiddlewareService])
120
124
  ], ReportBrowseService);
125
+ function asCatalogText(value) {
126
+ return (0, core_2.coerceUnknownToMultiLanguageString)(value);
127
+ }
121
128
  function toApiName(title) {
122
- return title
129
+ return (0, report_1.resolveDisplayTitle)(title)
123
130
  .toLowerCase()
124
131
  .replace(/[^a-z0-9]+/g, '_')
125
132
  .replace(/^_|_$/g, '');
126
133
  }
134
+ function dedupeById(items) {
135
+ const seen = new Set();
136
+ const result = [];
137
+ for (const item of items) {
138
+ if (!(item === null || item === void 0 ? void 0 : item.id) || seen.has(item.id)) {
139
+ continue;
140
+ }
141
+ seen.add(item.id);
142
+ result.push(item);
143
+ }
144
+ return result;
145
+ }
127
146
  //#endregion
128
147
  //# sourceMappingURL=report-browse.service.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"report-browse.service.js","sourceRoot":"","sources":["../../../../../../libs/modules/report-management/server/src/lib/report-browse.service.ts"],"names":[],"mappings":";;;;AAAA,2CAA+D;AAC/D,iEAAwF;AACxF,qEAAiG;AAUjG,yCAAyC;AAGlC,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAC9B,YAA6B,OAAuC;QAAvC,YAAO,GAAP,OAAO,CAAgC;IAAG,CAAC;IAElE,kBAAkB;qEAAC,IAAI,GAAG,CAAC,EAAE,IAAI,GAAG,IAAI;YAC5C,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,MAAM,IAAI,CAA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C,aAAa,EAAE,GAAG,CAAC;SAC3B,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;AAC3B,CAAC;AAED,YAAY"}
1
+ {"version":3,"file":"report-browse.service.js","sourceRoot":"","sources":["../../../../../../libs/modules/report-management/server/src/lib/report-browse.service.ts"],"names":[],"mappings":";;;;AAAA,2CAA+D;AAC/D,iEAAwF;AACxF,qEAKkD;AAClD,iEAGgD;AAUhD,yCAAyC;AAGlC,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAC9B,YAA6B,OAAuC;QAAvC,YAAO,GAAP,OAAO,CAAgC;IAAG,CAAC;IAElE,kBAAkB;qEAAC,IAAI,GAAG,CAAC,EAAE,IAAI,GAAG,IAAI;YAC5C,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;YACrD,MAAM,KAAK,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;YACpD,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC,CAAC;YAE7C,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CACnC,IAAI,CAAC,oBAAoB,CAAC,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE,eAAe,EAAE,KAAK,EAAE,CAAC,CACrF,CAAC;YAEF,OAAO,EAAE,UAAU,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC;QAC7C,CAAC;KAAA;IAEK,eAAe,CAAC,UAAkB;;YACtC,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;YACrD,MAAM,QAAQ,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EA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