@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.
- package/contracts/src/commands.keys.d.ts +11 -0
- package/contracts/src/commands.keys.js +17 -0
- package/contracts/src/commands.keys.js.map +1 -0
- package/contracts/src/entities/index.d.ts +3 -0
- package/contracts/src/entities/index.js +3 -0
- package/contracts/src/entities/index.js.map +1 -1
- package/contracts/src/entities/query-snapshot/index.d.ts +1 -0
- package/contracts/src/entities/query-snapshot/index.js +5 -0
- package/contracts/src/entities/query-snapshot/index.js.map +1 -0
- package/contracts/src/entities/query-snapshot/query-snapshot.entity.d.ts +2 -0
- package/contracts/src/entities/query-snapshot/query-snapshot.entity.js +127 -0
- package/contracts/src/entities/query-snapshot/query-snapshot.entity.js.map +1 -0
- package/contracts/src/entities/query-snapshot/query-snapshot.types.d.ts +34 -0
- package/contracts/src/entities/query-snapshot/query-snapshot.types.js +5 -0
- package/contracts/src/entities/query-snapshot/query-snapshot.types.js.map +1 -0
- package/contracts/src/entities/query-snapshot-policy/index.d.ts +1 -0
- package/contracts/src/entities/query-snapshot-policy/index.js +5 -0
- package/contracts/src/entities/query-snapshot-policy/index.js.map +1 -0
- package/contracts/src/entities/query-snapshot-policy/query-snapshot-policy.entity.d.ts +2 -0
- package/contracts/src/entities/query-snapshot-policy/query-snapshot-policy.entity.js +100 -0
- package/contracts/src/entities/query-snapshot-policy/query-snapshot-policy.entity.js.map +1 -0
- package/contracts/src/entities/query-snapshot-policy/query-snapshot-policy.types.d.ts +14 -0
- package/contracts/src/entities/query-snapshot-policy/query-snapshot-policy.types.js +5 -0
- package/contracts/src/entities/query-snapshot-policy/query-snapshot-policy.types.js.map +1 -0
- package/contracts/src/entities/report/index.d.ts +1 -1
- package/contracts/src/entities/report/index.js +1 -1
- package/contracts/src/entities/report/index.js.map +1 -1
- package/contracts/src/entities/report/report.entity.js +51 -7
- package/contracts/src/entities/report/report.entity.js.map +1 -1
- package/contracts/src/entities/report-category/index.d.ts +1 -1
- package/contracts/src/entities/report-category/index.js +0 -2
- package/contracts/src/entities/report-category/index.js.map +1 -1
- package/contracts/src/entities/report-category/report-category.entity.js +14 -1
- package/contracts/src/entities/report-category/report-category.entity.js.map +1 -1
- package/contracts/src/entities/report-generation-request/index.d.ts +1 -0
- package/contracts/src/entities/report-generation-request/index.js +5 -0
- package/contracts/src/entities/report-generation-request/index.js.map +1 -0
- package/contracts/src/entities/report-generation-request/report-generation-request.entity.d.ts +2 -0
- package/contracts/src/entities/report-generation-request/report-generation-request.entity.js +208 -0
- package/contracts/src/entities/report-generation-request/report-generation-request.entity.js.map +1 -0
- package/contracts/src/entity-catalog.d.ts +7 -0
- package/contracts/src/entity-catalog.js +24 -0
- package/contracts/src/entity-catalog.js.map +1 -0
- package/contracts/src/entity-entry.query-snapshot-policy.d.ts +1 -0
- package/contracts/src/entity-entry.query-snapshot-policy.js +6 -0
- package/contracts/src/entity-entry.query-snapshot-policy.js.map +1 -0
- package/contracts/src/entity-entry.query-snapshot.d.ts +1 -0
- package/contracts/src/entity-entry.query-snapshot.js +6 -0
- package/contracts/src/entity-entry.query-snapshot.js.map +1 -0
- package/contracts/src/entity-entry.report-category.d.ts +1 -0
- package/contracts/src/entity-entry.report-category.js +6 -0
- package/contracts/src/entity-entry.report-category.js.map +1 -0
- package/contracts/src/entity-entry.report-generation-request.d.ts +1 -0
- package/contracts/src/entity-entry.report-generation-request.js +6 -0
- package/contracts/src/entity-entry.report-generation-request.js.map +1 -0
- package/contracts/src/entity-entry.report.d.ts +1 -0
- package/contracts/src/entity-entry.report.js +6 -0
- package/contracts/src/entity-entry.report.js.map +1 -0
- package/contracts/src/index.d.ts +5 -0
- package/contracts/src/index.js +5 -0
- package/contracts/src/index.js.map +1 -1
- package/contracts/src/manifest.d.ts +6 -0
- package/contracts/src/manifest.js +24 -0
- package/contracts/src/manifest.js.map +1 -0
- package/contracts/src/permission.keys.d.ts +30 -14
- package/contracts/src/permission.keys.js +28 -12
- package/contracts/src/permission.keys.js.map +1 -1
- package/contracts/src/report-generation.types.d.ts +97 -0
- package/contracts/src/report-generation.types.js +14 -0
- package/contracts/src/report-generation.types.js.map +1 -0
- package/contracts/src/report.types.d.ts +107 -107
- package/contracts/src/report.types.js.map +1 -1
- package/contracts/src/root-config.d.ts +23 -2
- package/contracts/src/root-config.js +23 -2
- package/contracts/src/root-config.js.map +1 -1
- package/contracts/src/runtime.keys.d.ts +14 -0
- package/contracts/src/runtime.keys.js +20 -0
- package/contracts/src/runtime.keys.js.map +1 -0
- package/contracts/src/settings.keys.d.ts +11 -0
- package/contracts/src/settings.keys.js +17 -0
- package/contracts/src/settings.keys.js.map +1 -0
- package/package.json +8 -8
- package/server/src/index.d.ts +2 -4
- package/server/src/index.js +5 -8
- package/server/src/index.js.map +1 -1
- package/server/src/lib/entities/index.d.ts +1 -0
- package/server/src/lib/entities/index.js +5 -0
- package/server/src/lib/entities/index.js.map +1 -0
- package/server/src/lib/entities/report-management.entity-catalog.d.ts +1 -0
- package/server/src/lib/entities/report-management.entity-catalog.js +12 -0
- package/server/src/lib/entities/report-management.entity-catalog.js.map +1 -0
- package/server/src/lib/query-snapshots/query-snapshot-bypass.util.d.ts +3 -0
- package/server/src/lib/query-snapshots/query-snapshot-bypass.util.js +16 -0
- package/server/src/lib/query-snapshots/query-snapshot-bypass.util.js.map +1 -0
- package/server/src/lib/query-snapshots/query-snapshot-debounce.service.d.ts +19 -0
- package/server/src/lib/query-snapshots/query-snapshot-debounce.service.js +118 -0
- package/server/src/lib/query-snapshots/query-snapshot-debounce.service.js.map +1 -0
- package/server/src/lib/query-snapshots/query-snapshot-enqueue.service.d.ts +24 -0
- package/server/src/lib/query-snapshots/query-snapshot-enqueue.service.js +61 -0
- package/server/src/lib/query-snapshots/query-snapshot-enqueue.service.js.map +1 -0
- package/server/src/lib/query-snapshots/query-snapshot-entity-change.middleware.d.ts +12 -0
- package/server/src/lib/query-snapshots/query-snapshot-entity-change.middleware.js +90 -0
- package/server/src/lib/query-snapshots/query-snapshot-entity-change.middleware.js.map +1 -0
- package/server/src/lib/query-snapshots/query-snapshot-entity-storage.bootstrap.d.ts +9 -0
- package/server/src/lib/query-snapshots/query-snapshot-entity-storage.bootstrap.js +25 -0
- package/server/src/lib/query-snapshots/query-snapshot-entity-storage.bootstrap.js.map +1 -0
- package/server/src/lib/query-snapshots/query-snapshot-payload.util.d.ts +22 -0
- package/server/src/lib/query-snapshots/query-snapshot-payload.util.js +282 -0
- package/server/src/lib/query-snapshots/query-snapshot-payload.util.js.map +1 -0
- package/server/src/lib/query-snapshots/query-snapshot-recalc.service.d.ts +23 -0
- package/server/src/lib/query-snapshots/query-snapshot-recalc.service.js +122 -0
- package/server/src/lib/query-snapshots/query-snapshot-recalc.service.js.map +1 -0
- package/server/src/lib/query-snapshots/query-snapshot-schedule.setup.d.ts +2 -0
- package/server/src/lib/query-snapshots/query-snapshot-schedule.setup.js +79 -0
- package/server/src/lib/query-snapshots/query-snapshot-schedule.setup.js.map +1 -0
- package/server/src/lib/query-snapshots/query-snapshot.constants.d.ts +17 -0
- package/server/src/lib/query-snapshots/query-snapshot.constants.js +46 -0
- package/server/src/lib/query-snapshots/query-snapshot.constants.js.map +1 -0
- package/server/src/lib/query-snapshots/query-snapshot.middleware.d.ts +21 -0
- package/server/src/lib/query-snapshots/query-snapshot.middleware.js +135 -0
- package/server/src/lib/query-snapshots/query-snapshot.middleware.js.map +1 -0
- package/server/src/lib/query-snapshots/query-snapshot.store.d.ts +34 -0
- package/server/src/lib/query-snapshots/query-snapshot.store.js +137 -0
- package/server/src/lib/query-snapshots/query-snapshot.store.js.map +1 -0
- package/server/src/lib/query-snapshots/recalculate-query-snapshots.command.d.ts +8 -0
- package/server/src/lib/query-snapshots/recalculate-query-snapshots.command.js +74 -0
- package/server/src/lib/query-snapshots/recalculate-query-snapshots.command.js.map +1 -0
- package/server/src/lib/query-snapshots/refresh-query-snapshots.command.d.ts +16 -0
- package/server/src/lib/query-snapshots/refresh-query-snapshots.command.js +56 -0
- package/server/src/lib/query-snapshots/refresh-query-snapshots.command.js.map +1 -0
- package/server/src/lib/report-browse.service.js +32 -13
- package/server/src/lib/report-browse.service.js.map +1 -1
- package/server/src/lib/report-browse.types.d.ts +27 -12
- package/server/src/lib/report-browse.types.js +0 -1
- package/server/src/lib/report-browse.types.js.map +1 -1
- package/server/src/lib/report-definition.seed-provider.d.ts +15 -0
- package/server/src/lib/report-definition.seed-provider.js +63 -0
- package/server/src/lib/report-definition.seed-provider.js.map +1 -0
- package/server/src/lib/report-generation/report-generation-create.command.d.ts +17 -0
- package/server/src/lib/report-generation/report-generation-create.command.js +177 -0
- package/server/src/lib/report-generation/report-generation-create.command.js.map +1 -0
- package/server/src/lib/report-generation/report-generation-enqueue.service.d.ts +21 -0
- package/server/src/lib/report-generation/report-generation-enqueue.service.js +58 -0
- package/server/src/lib/report-generation/report-generation-enqueue.service.js.map +1 -0
- package/server/src/lib/report-generation/report-generation-execute.command.d.ts +10 -0
- package/server/src/lib/report-generation/report-generation-execute.command.js +49 -0
- package/server/src/lib/report-generation/report-generation-execute.command.js.map +1 -0
- package/server/src/lib/report-generation/report-generation-execute.service.d.ts +23 -0
- package/server/src/lib/report-generation/report-generation-execute.service.js +225 -0
- package/server/src/lib/report-generation/report-generation-execute.service.js.map +1 -0
- package/server/src/lib/report-generation/report-generation-job-presentation.util.d.ts +8 -0
- package/server/src/lib/report-generation/report-generation-job-presentation.util.js +43 -0
- package/server/src/lib/report-generation/report-generation-job-presentation.util.js.map +1 -0
- package/server/src/lib/report-generation/report-generation-notify.service.d.ts +23 -0
- package/server/src/lib/report-generation/report-generation-notify.service.js +159 -0
- package/server/src/lib/report-generation/report-generation-notify.service.js.map +1 -0
- package/server/src/lib/report-generation/report-generation-policy.util.d.ts +39 -0
- package/server/src/lib/report-generation/report-generation-policy.util.js +95 -0
- package/server/src/lib/report-generation/report-generation-policy.util.js.map +1 -0
- package/server/src/lib/report-generation/report-generation-progress.util.d.ts +14 -0
- package/server/src/lib/report-generation/report-generation-progress.util.js +51 -0
- package/server/src/lib/report-generation/report-generation-progress.util.js.map +1 -0
- package/server/src/lib/report-generation/report-generation-release-inline-watch.command.d.ts +10 -0
- package/server/src/lib/report-generation/report-generation-release-inline-watch.command.js +55 -0
- package/server/src/lib/report-generation/report-generation-release-inline-watch.command.js.map +1 -0
- package/server/src/lib/report-generation/report-generation-runtime.handlers.d.ts +27 -0
- package/server/src/lib/report-generation/report-generation-runtime.handlers.js +136 -0
- package/server/src/lib/report-generation/report-generation-runtime.handlers.js.map +1 -0
- package/server/src/lib/report-generation/report-generation-settings.service.d.ts +12 -0
- package/server/src/lib/report-generation/report-generation-settings.service.js +49 -0
- package/server/src/lib/report-generation/report-generation-settings.service.js.map +1 -0
- package/server/src/lib/report-generation/report-generation.constants.d.ts +16 -0
- package/server/src/lib/report-generation/report-generation.constants.js +24 -0
- package/server/src/lib/report-generation/report-generation.constants.js.map +1 -0
- package/server/src/lib/report-generation/report-generation.store.d.ts +25 -0
- package/server/src/lib/report-generation/report-generation.store.js +145 -0
- package/server/src/lib/report-generation/report-generation.store.js.map +1 -0
- package/server/src/lib/report-generation/report-generation.util.d.ts +8 -0
- package/server/src/lib/report-generation/report-generation.util.js +131 -0
- package/server/src/lib/report-generation/report-generation.util.js.map +1 -0
- package/server/src/lib/report-management-runtime.handlers.d.ts +32 -0
- package/server/src/lib/report-management-runtime.handlers.js +78 -0
- package/server/src/lib/report-management-runtime.handlers.js.map +1 -0
- package/server/src/lib/report-management-server.module.js +64 -9
- package/server/src/lib/report-management-server.module.js.map +1 -1
- package/server/src/lib/report-management.controller.d.ts +1 -4
- package/server/src/lib/report-management.controller.js +2 -16
- package/server/src/lib/report-management.controller.js.map +1 -1
- package/server/src/lib/seed/index.d.ts +0 -19
- package/server/src/lib/seed/index.js +0 -21
- package/server/src/lib/seed/index.js.map +0 -1
- package/server/src/lib/seed/report-management-seed.provider.d.ts +0 -4
- package/server/src/lib/seed/report-management-seed.provider.js +0 -18
- package/server/src/lib/seed/report-management-seed.provider.js.map +0 -1
- package/server/src/lib/seed/report-management-seed.tokens.d.ts +0 -1
- package/server/src/lib/seed/report-management-seed.tokens.js +0 -7
- package/server/src/lib/seed/report-management-seed.tokens.js.map +0 -1
- package/server/src/lib/seed/report-management.seed-catalog.d.ts +0 -2
- package/server/src/lib/seed/report-management.seed-catalog.js +0 -10
- package/server/src/lib/seed/report-management.seed-catalog.js.map +0 -1
- package/server/src/lib/seed/samples/employee-report.mock.d.ts +0 -9
- package/server/src/lib/seed/samples/employee-report.mock.js +0 -322
- package/server/src/lib/seed/samples/employee-report.mock.js.map +0 -1
- package/server/src/lib/seed/samples/index.d.ts +0 -2
- package/server/src/lib/seed/samples/index.js +0 -6
- package/server/src/lib/seed/samples/index.js.map +0 -1
- package/server/src/lib/seed/samples/location-report.mock.d.ts +0 -9
- package/server/src/lib/seed/samples/location-report.mock.js +0 -339
- package/server/src/lib/seed/samples/location-report.mock.js.map +0 -1
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var ReportGenerationExecuteService_1;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.ReportGenerationExecuteService = void 0;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const common_1 = require("@nestjs/common");
|
|
7
|
+
const http_1 = require("@acorex-platform/framework-server/file-storage/http");
|
|
8
|
+
const providers_1 = require("@acorex-platform/framework-server/domain/providers");
|
|
9
|
+
const report_1 = require("@acorex-platform/framework-server/report");
|
|
10
|
+
const core_1 = require("@acorex-platform/framework-server/core");
|
|
11
|
+
const core_2 = require("@acorex-platform/framework-shared/core");
|
|
12
|
+
const report_generation_constants_1 = require("./report-generation.constants");
|
|
13
|
+
const report_generation_notify_service_1 = require("./report-generation-notify.service");
|
|
14
|
+
const report_generation_store_1 = require("./report-generation.store");
|
|
15
|
+
const report_generation_util_1 = require("./report-generation.util");
|
|
16
|
+
const report_generation_progress_util_1 = require("./report-generation-progress.util");
|
|
17
|
+
//#region ----- Execute -----
|
|
18
|
+
let ReportGenerationExecuteService = ReportGenerationExecuteService_1 = class ReportGenerationExecuteService {
|
|
19
|
+
constructor(store, storage, queryRegistry, fileStorage, notify) {
|
|
20
|
+
this.store = store;
|
|
21
|
+
this.storage = storage;
|
|
22
|
+
this.queryRegistry = queryRegistry;
|
|
23
|
+
this.fileStorage = fileStorage;
|
|
24
|
+
this.notify = notify;
|
|
25
|
+
this.logger = new common_1.Logger(ReportGenerationExecuteService_1.name);
|
|
26
|
+
}
|
|
27
|
+
/** Reads the latest inline-watch flag so a mid-run ReleaseInlineWatch is honored. */
|
|
28
|
+
resolveSuppressNotificationOnComplete(request) {
|
|
29
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
const latest = yield this.store.getById(request.id);
|
|
31
|
+
if (!latest) {
|
|
32
|
+
return request.suppressNotificationOnComplete;
|
|
33
|
+
}
|
|
34
|
+
return latest.suppressNotificationOnComplete;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
run(request, progress) {
|
|
38
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
40
|
+
const startedAt = new Date();
|
|
41
|
+
yield (progress === null || progress === void 0 ? void 0 : progress.reportProgress(5, '@report-management:report-generation.tray.progress.starting'));
|
|
42
|
+
yield ((_a = progress === null || progress === void 0 ? void 0 : progress.heartbeat) === null || _a === void 0 ? void 0 : _a.call(progress));
|
|
43
|
+
yield this.store.patchAsEngine(request.id, {
|
|
44
|
+
status: 'running',
|
|
45
|
+
startedAt: startedAt.toISOString(),
|
|
46
|
+
lastError: undefined,
|
|
47
|
+
});
|
|
48
|
+
const report = yield this.loadReport(request.reportId);
|
|
49
|
+
if (!report) {
|
|
50
|
+
yield this.fail(request, report, startedAt, report_generation_constants_1.REPORT_GENERATION_REPORT_NOT_FOUND_ERROR);
|
|
51
|
+
throw new Error(report_generation_constants_1.REPORT_GENERATION_REPORT_NOT_FOUND_ERROR);
|
|
52
|
+
}
|
|
53
|
+
yield (progress === null || progress === void 0 ? void 0 : progress.reportProgress(15, '@report-management:report-generation.tray.progress.loading-data'));
|
|
54
|
+
yield ((_b = progress === null || progress === void 0 ? void 0 : progress.heartbeat) === null || _b === void 0 ? void 0 : _b.call(progress));
|
|
55
|
+
const generation = (0, report_generation_util_1.resolveGenerationOptions)(report.generation);
|
|
56
|
+
const delayMs = (_c = generation.simulateDelayMs) !== null && _c !== void 0 ? _c : 0;
|
|
57
|
+
const usesSimulatedDelay = delayMs > 0;
|
|
58
|
+
if (usesSimulatedDelay) {
|
|
59
|
+
yield (0, report_generation_progress_util_1.simulateReportGenerationProgressDelay)(progress, delayMs, {
|
|
60
|
+
fromProgress: 15,
|
|
61
|
+
toProgress: 70,
|
|
62
|
+
statusText: '@report-management:report-generation.tray.progress.loading-data',
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
const layouts = this.resolveFreezeLayouts(report, request.layoutId, request.layoutIds, generation.freezeLayouts);
|
|
66
|
+
const dataSources = [];
|
|
67
|
+
let rowCount = 0;
|
|
68
|
+
const layoutCount = Math.max(layouts.length, 1);
|
|
69
|
+
for (let index = 0; index < layouts.length; index++) {
|
|
70
|
+
const layout = layouts[index];
|
|
71
|
+
const layoutTitle = (0, report_1.resolveDisplayTitle)(layout.title).trim() || layout.id;
|
|
72
|
+
const layoutSpan = usesSimulatedDelay ? 14 : 55;
|
|
73
|
+
const layoutStart = usesSimulatedDelay ? 70 : 20;
|
|
74
|
+
const progressValue = layoutStart + Math.round((layoutSpan * (index + 0.5)) / layoutCount);
|
|
75
|
+
yield (progress === null || progress === void 0 ? void 0 : progress.reportProgress(progressValue, '@report-management:report-generation.tray.progress.layout', layoutTitle));
|
|
76
|
+
yield ((_d = progress === null || progress === void 0 ? void 0 : progress.heartbeat) === null || _d === void 0 ? void 0 : _d.call(progress));
|
|
77
|
+
const dataSource = layout.dataSource;
|
|
78
|
+
if (!dataSource) {
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
if (dataSource.type !== 'query' || !dataSource.name) {
|
|
82
|
+
yield this.fail(request, report, startedAt, report_generation_constants_1.REPORT_GENERATION_UNSUPPORTED_SOURCE_ERROR);
|
|
83
|
+
throw new Error(report_generation_constants_1.REPORT_GENERATION_UNSUPPORTED_SOURCE_ERROR);
|
|
84
|
+
}
|
|
85
|
+
const filter = (0, report_generation_util_1.convertParametersToFilterClause)(request.parameters);
|
|
86
|
+
const queryResult = (yield this.queryRegistry.execute(dataSource.name, {
|
|
87
|
+
skip: 0,
|
|
88
|
+
take: report_generation_constants_1.REPORT_GENERATION_FREEZE_TAKE,
|
|
89
|
+
filter,
|
|
90
|
+
}));
|
|
91
|
+
if (!(queryResult === null || queryResult === void 0 ? void 0 : queryResult.success)) {
|
|
92
|
+
yield this.fail(request, report, startedAt, report_generation_constants_1.REPORT_GENERATION_QUERY_FAILED_ERROR);
|
|
93
|
+
throw new Error(report_generation_constants_1.REPORT_GENERATION_QUERY_FAILED_ERROR);
|
|
94
|
+
}
|
|
95
|
+
const collection = (0, core_2.runtimeQueryCollectionData)(queryResult);
|
|
96
|
+
if (collection) {
|
|
97
|
+
rowCount += (_g = (_e = collection.total) !== null && _e !== void 0 ? _e : (_f = collection.items) === null || _f === void 0 ? void 0 : _f.length) !== null && _g !== void 0 ? _g : 0;
|
|
98
|
+
}
|
|
99
|
+
dataSources.push({
|
|
100
|
+
layoutId: layout.id,
|
|
101
|
+
queryName: dataSource.name,
|
|
102
|
+
result: queryResult,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
const generatedAt = new Date();
|
|
106
|
+
const freeze = {
|
|
107
|
+
version: 1,
|
|
108
|
+
reportId: report.id,
|
|
109
|
+
generatedAt: generatedAt.toISOString(),
|
|
110
|
+
parameters: (_h = request.parameters) !== null && _h !== void 0 ? _h : {},
|
|
111
|
+
dataSources,
|
|
112
|
+
};
|
|
113
|
+
if (generation.pinDefinition) {
|
|
114
|
+
freeze.definition = {
|
|
115
|
+
title: (0, core_2.coerceUnknownToMultiLanguageString)(report.title),
|
|
116
|
+
defaultLayoutId: ((_j = request.layoutIds) === null || _j === void 0 ? void 0 : _j[0]) || request.layoutId || report.defaultLayoutId,
|
|
117
|
+
layouts: report.layouts,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
yield (progress === null || progress === void 0 ? void 0 : progress.reportProgress(85, '@report-management:report-generation.tray.progress.saving'));
|
|
121
|
+
yield ((_k = progress === null || progress === void 0 ? void 0 : progress.heartbeat) === null || _k === void 0 ? void 0 : _k.call(progress));
|
|
122
|
+
const fileName = (0, report_generation_util_1.slugFileName)((0, report_1.resolveDisplayTitle)(report.title), '.json');
|
|
123
|
+
const buffer = Buffer.from(JSON.stringify(freeze), 'utf8');
|
|
124
|
+
const saved = yield this.fileStorage.save({
|
|
125
|
+
buffer,
|
|
126
|
+
originalName: fileName,
|
|
127
|
+
mimeType: 'application/json',
|
|
128
|
+
name: fileName,
|
|
129
|
+
refId: request.id,
|
|
130
|
+
refType: report_generation_constants_1.REPORT_GENERATION_FILE_REF_TYPE,
|
|
131
|
+
category: report_generation_constants_1.REPORT_GENERATION_FILE_CATEGORY,
|
|
132
|
+
status: core_2.AXPFileStorageStatus.Temporary,
|
|
133
|
+
metadata: { reportRequestId: request.id, kind: 'viewer' },
|
|
134
|
+
});
|
|
135
|
+
const fileId = (_l = saved.fileId) === null || _l === void 0 ? void 0 : _l.trim();
|
|
136
|
+
if (!fileId) {
|
|
137
|
+
yield this.fail(request, report, startedAt, report_generation_constants_1.REPORT_GENERATION_QUERY_FAILED_ERROR);
|
|
138
|
+
throw new Error(report_generation_constants_1.REPORT_GENERATION_QUERY_FAILED_ERROR);
|
|
139
|
+
}
|
|
140
|
+
yield this.fileStorage.commit(fileId);
|
|
141
|
+
const suppressNotificationOnComplete = yield this.resolveSuppressNotificationOnComplete(request);
|
|
142
|
+
const completed = Object.assign(Object.assign({}, request), { status: 'completed', startedAt: startedAt.toISOString(), completedAt: generatedAt.toISOString(), durationMs: generatedAt.getTime() - startedAt.getTime(), expiresAt: (0, report_generation_util_1.computeExpiresAt)(generation.retentionDays, generatedAt), lastError: undefined, suppressNotificationOnComplete, artifacts: [
|
|
143
|
+
{
|
|
144
|
+
kind: 'viewer',
|
|
145
|
+
fileId,
|
|
146
|
+
contentType: 'application/json',
|
|
147
|
+
fileName,
|
|
148
|
+
rowCount,
|
|
149
|
+
byteLength: buffer.byteLength,
|
|
150
|
+
},
|
|
151
|
+
] });
|
|
152
|
+
yield this.store.patchAsEngine(request.id, completed);
|
|
153
|
+
yield (progress === null || progress === void 0 ? void 0 : progress.reportProgress(100, '@report-management:report-generation.tray.progress.ready'));
|
|
154
|
+
yield this.notify.notifyComplete({
|
|
155
|
+
request: Object.assign(Object.assign({}, completed), { id: request.id }),
|
|
156
|
+
reportTitle: report.title,
|
|
157
|
+
recipientUserId: request.requestedBy,
|
|
158
|
+
});
|
|
159
|
+
return {
|
|
160
|
+
reportRequestId: request.id,
|
|
161
|
+
fileIds: [fileId],
|
|
162
|
+
rowCount,
|
|
163
|
+
};
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
loadReport(reportId) {
|
|
167
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
168
|
+
const row = yield (0, report_1.loadReportDefinitionById)(this.storage, reportId);
|
|
169
|
+
if (!row) {
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
return row;
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
resolveFreezeLayouts(report, layoutId, layoutIds, freezeLayouts) {
|
|
176
|
+
var _a, _b, _c;
|
|
177
|
+
if (layoutIds === null || layoutIds === void 0 ? void 0 : layoutIds.length) {
|
|
178
|
+
const selected = new Set(layoutIds);
|
|
179
|
+
const filtered = ((_a = report.layouts) !== null && _a !== void 0 ? _a : []).filter((layout) => selected.has(layout.id));
|
|
180
|
+
return filtered.length ? filtered : ((_b = report.layouts) !== null && _b !== void 0 ? _b : []);
|
|
181
|
+
}
|
|
182
|
+
if (freezeLayouts === 'current' && layoutId) {
|
|
183
|
+
const current = report.layouts.find((layout) => layout.id === layoutId);
|
|
184
|
+
return current ? [current] : report.layouts;
|
|
185
|
+
}
|
|
186
|
+
return (_c = report.layouts) !== null && _c !== void 0 ? _c : [];
|
|
187
|
+
}
|
|
188
|
+
fail(request, report, startedAt, lastError) {
|
|
189
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
190
|
+
const completedAt = new Date();
|
|
191
|
+
const suppressNotificationOnComplete = yield this.resolveSuppressNotificationOnComplete(request);
|
|
192
|
+
const failed = {
|
|
193
|
+
status: 'failed',
|
|
194
|
+
startedAt: startedAt.toISOString(),
|
|
195
|
+
completedAt: completedAt.toISOString(),
|
|
196
|
+
durationMs: completedAt.getTime() - startedAt.getTime(),
|
|
197
|
+
lastError,
|
|
198
|
+
expiresAt: (0, report_generation_util_1.computeExpiresAt)(report_generation_constants_1.REPORT_GENERATION_DEFAULT_RETENTION_DAYS, completedAt),
|
|
199
|
+
suppressNotificationOnComplete,
|
|
200
|
+
};
|
|
201
|
+
yield this.store.patchAsEngine(request.id, failed);
|
|
202
|
+
try {
|
|
203
|
+
yield this.notify.notifyFailed({
|
|
204
|
+
request: Object.assign(Object.assign(Object.assign({}, request), failed), { suppressNotificationOnComplete }),
|
|
205
|
+
reportTitle: report === null || report === void 0 ? void 0 : report.title,
|
|
206
|
+
recipientUserId: request.requestedBy,
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
catch (error) {
|
|
210
|
+
this.logger.warn(`Failed notification after generation error: ${String(error)}`);
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
exports.ReportGenerationExecuteService = ReportGenerationExecuteService;
|
|
216
|
+
exports.ReportGenerationExecuteService = ReportGenerationExecuteService = ReportGenerationExecuteService_1 = tslib_1.__decorate([
|
|
217
|
+
(0, common_1.Injectable)(),
|
|
218
|
+
tslib_1.__metadata("design:paramtypes", [report_generation_store_1.ReportGenerationStore,
|
|
219
|
+
core_1.EntityStorageMiddlewareService,
|
|
220
|
+
providers_1.ServerQueryRegistry,
|
|
221
|
+
http_1.FileStorageFacadeService,
|
|
222
|
+
report_generation_notify_service_1.ReportGenerationNotifyService])
|
|
223
|
+
], ReportGenerationExecuteService);
|
|
224
|
+
//#endregion
|
|
225
|
+
//# sourceMappingURL=report-generation-execute.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report-generation-execute.service.js","sourceRoot":"","sources":["../../../../../../../libs/modules/report-management/server/src/lib/report-generation/report-generation-execute.service.ts"],"names":[],"mappings":";;;;;AAAA,2CAAoD;AACpD,8EAA+F;AAC/F,kFAAyF;AACzF,qEAGkD;AAClD,iEAAwF;AACxF,iEAKgD;AAOhD,+EAQuC;AACvC,yFAAmF;AACnF,uEAAkE;AAElE,qEAKkC;AAClC,uFAA0F;AAK1F,6BAA6B;AAGtB,IAAM,8BAA8B,sCAApC,MAAM,8BAA8B;IAGzC,YACmB,KAA4B,EAC5B,OAAuC,EACvC,aAAkC,EAClC,WAAqC,EACrC,MAAqC;QAJrC,UAAK,GAAL,KAAK,CAAuB;QAC5B,YAAO,GAAP,OAAO,CAAgC;QACvC,kBAAa,GAAb,aAAa,CAAqB;QAClC,gBAAW,GAAX,WAAW,CAA0B;QACrC,WAAM,GAAN,MAAM,CAA+B;QAPvC,WAAM,GAAG,IAAI,eAAM,CAAC,gCAA8B,CAAC,IAAI,CAAC,CAAC;IAQvE,CAAC;IAEJ,qFAAqF;IACvE,qCAAqC,CACjD,OAAmC;;YAEnC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YACpD,IAAI,CAAC,MAAM,EAAE,CAAC;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AC,WAAW;iBACrC,CAAC,CAAC;YACL,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,+CAA+C,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YACnF,CAAC;QACH,CAAC;KAAA;CACF,CAAA;AAhPY,wEAA8B;yCAA9B,8BAA8B;IAD1C,IAAA,mBAAU,GAAE;6CAKe,+CAAqB;QACnB,qCAA8B;QACxB,+BAAmB;QACrB,+BAAwB;QAC7B,gEAA6B;GAR7C,8BAA8B,CAgP1C;AAED,YAAY"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AXPReportDefinition } from '@acorex-platform/module-report-management-client/contracts';
|
|
2
|
+
export interface ReportGenerationJobPresentation {
|
|
3
|
+
title: string;
|
|
4
|
+
statusText: string;
|
|
5
|
+
currentStep?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function buildReportGenerationJobTitle(report: AXPReportDefinition): string;
|
|
8
|
+
export declare function buildReportGenerationJobPresentation(report: AXPReportDefinition, layoutId?: string, layoutIds?: string[]): ReportGenerationJobPresentation;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildReportGenerationJobTitle = buildReportGenerationJobTitle;
|
|
4
|
+
exports.buildReportGenerationJobPresentation = buildReportGenerationJobPresentation;
|
|
5
|
+
const report_1 = require("@acorex-platform/framework-server/report");
|
|
6
|
+
//#endregion
|
|
7
|
+
//#region ----- Job tray presentation -----
|
|
8
|
+
function buildReportGenerationJobTitle(report) {
|
|
9
|
+
const title = (0, report_1.resolveDisplayTitle)(report.title).trim();
|
|
10
|
+
return title || 'Report';
|
|
11
|
+
}
|
|
12
|
+
function buildReportGenerationJobPresentation(report, layoutId, layoutIds) {
|
|
13
|
+
var _a;
|
|
14
|
+
const title = buildReportGenerationJobTitle(report);
|
|
15
|
+
const layouts = (_a = report.layouts) !== null && _a !== void 0 ? _a : [];
|
|
16
|
+
const selectedIds = (layoutIds === null || layoutIds === void 0 ? void 0 : layoutIds.length) ? layoutIds : layoutId ? [layoutId] : [];
|
|
17
|
+
const selected = selectedIds.length
|
|
18
|
+
? layouts.filter((layout) => selectedIds.includes(layout.id))
|
|
19
|
+
: layouts;
|
|
20
|
+
if (selected.length === 1) {
|
|
21
|
+
const layoutTitle = (0, report_1.resolveDisplayTitle)(selected[0].title).trim();
|
|
22
|
+
if (layoutTitle) {
|
|
23
|
+
return {
|
|
24
|
+
title,
|
|
25
|
+
statusText: '@report-management:report-generation.tray.layout-line-single',
|
|
26
|
+
currentStep: layoutTitle,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
if (selected.length > 1) {
|
|
31
|
+
return {
|
|
32
|
+
title,
|
|
33
|
+
statusText: '@report-management:report-generation.tray.layout-line-multiple',
|
|
34
|
+
currentStep: String(selected.length),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
title,
|
|
39
|
+
statusText: '@report-management:report-generation.tray.queued',
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
43
|
+
//# sourceMappingURL=report-generation-job-presentation.util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report-generation-job-presentation.util.js","sourceRoot":"","sources":["../../../../../../../libs/modules/report-management/server/src/lib/report-generation/report-generation-job-presentation.util.ts"],"names":[],"mappings":";;AAeA,sEAGC;AAED,oFAmCC;AAvDD,qEAA+E;AAW/E,YAAY;AAEZ,2CAA2C;AAE3C,SAAgB,6BAA6B,CAAC,MAA2B;IACvE,MAAM,KAAK,GAAG,IAAA,4BAAmB,EAAC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC;IACvD,OAAO,KAAK,IAAI,QAAQ,CAAC;AAC3B,CAAC;AAED,SAAgB,oCAAoC,CAClD,MAA2B,EAC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Request } from '@acorex-platform/module-report-management-client/contracts';
|
|
3
|
+
import { ReportGenerationStore } from './report-generation.store';
|
|
4
|
+
export declare class ReportGenerationNotifyService {
|
|
5
|
+
private readonly commandExecutor;
|
|
6
|
+
private readonly store;
|
|
7
|
+
private readonly logger;
|
|
8
|
+
constructor(commandExecutor: ServerCommandExecutorService, store: ReportGenerationStore);
|
|
9
|
+
private shouldSuppressNotification;
|
|
10
|
+
notifyComplete(input: {
|
|
11
|
+
request: AXMReportGenerationRequest;
|
|
12
|
+
reportTitle: unknown;
|
|
13
|
+
recipientUserId?: string;
|
|
14
|
+
}): Promise<void>;
|
|
15
|
+
notifyFailed(input: {
|
|
16
|
+
request: AXMReportGenerationRequest;
|
|
17
|
+
reportTitle: unknown;
|
|
18
|
+
recipientUserId?: string;
|
|
19
|
+
}): Promise<void>;
|
|
20
|
+
private buildCompleteRequest;
|
|
21
|
+
private buildFailedRequest;
|
|
22
|
+
private deliverInbox;
|
|
23
|
+
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var ReportGenerationNotifyService_1;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.ReportGenerationNotifyService = void 0;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const common_1 = require("@nestjs/common");
|
|
7
|
+
const providers_1 = require("@acorex-platform/framework-server/domain/providers");
|
|
8
|
+
const core_1 = require("@acorex-platform/framework-shared/core");
|
|
9
|
+
const module_communication_management_contracts_1 = require("@acorex-platform/module-communication-management-client/contracts");
|
|
10
|
+
const report_generation_constants_1 = require("./report-generation.constants");
|
|
11
|
+
const report_generation_store_1 = require("./report-generation.store");
|
|
12
|
+
//#region ----- Notify -----
|
|
13
|
+
let ReportGenerationNotifyService = ReportGenerationNotifyService_1 = class ReportGenerationNotifyService {
|
|
14
|
+
constructor(commandExecutor, store) {
|
|
15
|
+
this.commandExecutor = commandExecutor;
|
|
16
|
+
this.store = store;
|
|
17
|
+
this.logger = new common_1.Logger(ReportGenerationNotifyService_1.name);
|
|
18
|
+
}
|
|
19
|
+
shouldSuppressNotification(request) {
|
|
20
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
const latest = yield this.store.getById(request.id);
|
|
22
|
+
const row = latest !== null && latest !== void 0 ? latest : request;
|
|
23
|
+
return row.suppressNotificationOnComplete === true;
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
notifyComplete(input) {
|
|
27
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
var _a, _b;
|
|
29
|
+
if (yield this.shouldSuppressNotification(input.request)) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const recipientUserId = ((_a = input.recipientUserId) === null || _a === void 0 ? void 0 : _a.trim()) || ((_b = input.request.requestedBy) === null || _b === void 0 ? void 0 : _b.trim());
|
|
33
|
+
if (!recipientUserId) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const title = (0, core_1.resolveMultiLanguageString)((0, core_1.coerceUnknownToMultiLanguageString)(input.reportTitle), 'en-US');
|
|
37
|
+
const notification = this.buildCompleteRequest({
|
|
38
|
+
request: input.request,
|
|
39
|
+
recipientUserId,
|
|
40
|
+
title,
|
|
41
|
+
});
|
|
42
|
+
yield this.deliverInbox(notification);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
notifyFailed(input) {
|
|
46
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
var _a, _b;
|
|
48
|
+
if (yield this.shouldSuppressNotification(input.request)) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const recipientUserId = ((_a = input.recipientUserId) === null || _a === void 0 ? void 0 : _a.trim()) || ((_b = input.request.requestedBy) === null || _b === void 0 ? void 0 : _b.trim());
|
|
52
|
+
if (!recipientUserId) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const title = (0, core_1.resolveMultiLanguageString)((0, core_1.coerceUnknownToMultiLanguageString)(input.reportTitle), 'en-US');
|
|
56
|
+
const notification = this.buildFailedRequest({
|
|
57
|
+
request: input.request,
|
|
58
|
+
recipientUserId,
|
|
59
|
+
title,
|
|
60
|
+
});
|
|
61
|
+
yield this.deliverInbox(notification);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
//#region ----- Helpers -----
|
|
65
|
+
buildCompleteRequest(input) {
|
|
66
|
+
return {
|
|
67
|
+
correlationId: `report-generation:${input.request.id}`,
|
|
68
|
+
idempotencyKey: `report-generation-complete:${input.request.id}`,
|
|
69
|
+
title: input.title || '@report-management:report-generation.notifications.complete.title',
|
|
70
|
+
body: '@report-management:report-generation.notifications.complete.body',
|
|
71
|
+
recipientUserId: input.recipientUserId,
|
|
72
|
+
delivery: {
|
|
73
|
+
inbox: {
|
|
74
|
+
definitionKey: report_generation_constants_1.REPORT_GENERATION_NOTIFICATION_DEFINITION_KEY,
|
|
75
|
+
priority: 'Notice',
|
|
76
|
+
actions: [
|
|
77
|
+
{
|
|
78
|
+
title: '@report-management:report-generation.notifications.actions.open-viewer',
|
|
79
|
+
command: {
|
|
80
|
+
name: report_generation_constants_1.REPORT_GENERATION_OPEN_FROZEN_COMMAND,
|
|
81
|
+
options: {
|
|
82
|
+
reportId: input.request.reportId,
|
|
83
|
+
runId: input.request.id,
|
|
84
|
+
title: input.title || undefined,
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
],
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
buildFailedRequest(input) {
|
|
94
|
+
return {
|
|
95
|
+
correlationId: `report-generation-failed:${input.request.id}`,
|
|
96
|
+
idempotencyKey: `report-generation-failed:${input.request.id}`,
|
|
97
|
+
title: input.title || '@report-management:report-generation.notifications.failed.title',
|
|
98
|
+
body: input.request.lastError || '@report-management:report-generation.notifications.failed.body',
|
|
99
|
+
recipientUserId: input.recipientUserId,
|
|
100
|
+
delivery: {
|
|
101
|
+
inbox: {
|
|
102
|
+
definitionKey: report_generation_constants_1.REPORT_GENERATION_NOTIFICATION_DEFINITION_KEY,
|
|
103
|
+
priority: 'Warning',
|
|
104
|
+
actions: [
|
|
105
|
+
{
|
|
106
|
+
title: '@report-management:report-generation.notifications.actions.open-viewer',
|
|
107
|
+
command: {
|
|
108
|
+
name: report_generation_constants_1.REPORT_GENERATION_OPEN_FROZEN_COMMAND,
|
|
109
|
+
options: {
|
|
110
|
+
reportId: input.request.reportId,
|
|
111
|
+
runId: input.request.id,
|
|
112
|
+
title: input.title || undefined,
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
],
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
deliverInbox(request) {
|
|
122
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
123
|
+
var _a, _b;
|
|
124
|
+
if (!(0, core_1.axpShouldDeliverUserNotificationInbox)(request.delivery)) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
const inbox = (0, core_1.axpResolveUserNotificationDelivery)(request.delivery).inbox;
|
|
128
|
+
const recipientUserId = (_a = request.recipientUserId) === null || _a === void 0 ? void 0 : _a.trim();
|
|
129
|
+
if (!recipientUserId) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
const result = yield this.commandExecutor.execute(module_communication_management_contracts_1.AXMCommunicationManagementServerCommands.Send, {
|
|
133
|
+
title: request.title,
|
|
134
|
+
message: {
|
|
135
|
+
subject: request.title,
|
|
136
|
+
body: request.body,
|
|
137
|
+
},
|
|
138
|
+
channel: 'in-app',
|
|
139
|
+
recipientUserId,
|
|
140
|
+
definitionKey: inbox.definitionKey,
|
|
141
|
+
correlationId: request.correlationId,
|
|
142
|
+
idempotencyKey: request.idempotencyKey,
|
|
143
|
+
priority: (_b = inbox.priority) !== null && _b !== void 0 ? _b : 'Notice',
|
|
144
|
+
actions: inbox.actions,
|
|
145
|
+
});
|
|
146
|
+
if (!(result === null || result === void 0 ? void 0 : result.success)) {
|
|
147
|
+
this.logger.warn(`Failed to send report-generation inbox notification for ${request.correlationId}`);
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
exports.ReportGenerationNotifyService = ReportGenerationNotifyService;
|
|
153
|
+
exports.ReportGenerationNotifyService = ReportGenerationNotifyService = ReportGenerationNotifyService_1 = tslib_1.__decorate([
|
|
154
|
+
(0, common_1.Injectable)(),
|
|
155
|
+
tslib_1.__metadata("design:paramtypes", [providers_1.ServerCommandExecutorService,
|
|
156
|
+
report_generation_store_1.ReportGenerationStore])
|
|
157
|
+
], ReportGenerationNotifyService);
|
|
158
|
+
//#endregion
|
|
159
|
+
//# sourceMappingURL=report-generation-notify.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report-generation-notify.service.js","sourceRoot":"","sources":["../../../../../../../libs/modules/report-management/server/src/lib/report-generation/report-generation-notify.service.ts"],"names":[],"mappings":";;;;;AAAA,2CAAoD;AACpD,kFAAkG;AAClG,iEAOgD;AAChD,0HAAsH;AAEtH,+EAGuC;AACvC,uEAAkE;AAElE,4BAA4B;AAGrB,IAAM,6BAA6B,qCAAnC,MAAM,6BAA6B;IAGxC,YACmB,eAA6C,EAC7C,KAA4B;QAD5B,oBAAe,GAAf,eAAe,CAA8B;QAC7C,UAAK,GAAL,KAAK,CAAuB;QAJ9B,WAAM,GAAG,IAAI,eAAM,CAAC,+BAA6B,CAAC,IAAI,CAAC,CAAC;IAKtE,CAAC;IAEU,0BAA0B,CAAC,OAAmC;;YAC1E,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YACpD,MAAM,GAAG,GAAG,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,OAAO,CAAC;YAC9B,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AM,uBAAN,MAAM,CAAE,OAAO,CAAA,EAAE,CAAC;gBACrB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,2DAA2D,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;YACvG,CAAC;QACH,CAAC;KAAA;CAGF,CAAA;AAlKY,sEAA6B;wCAA7B,6BAA6B;IADzC,IAAA,mBAAU,GAAE;6CAKyB,wCAA4B;QACtC,+CAAqB;GALpC,6BAA6B,CAkKzC;AAED,YAAY"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { AXPReportGenerationDedupeOptions, AXPReportGenerationDedupePolicy } from '@acorex-platform/module-report-management-client/contracts';
|
|
2
|
+
import type { ReportGenerationPlatformSettings } from './report-generation-settings.service';
|
|
3
|
+
export interface EffectiveReportGenerationDedupe {
|
|
4
|
+
policy: AXPReportGenerationDedupePolicy;
|
|
5
|
+
cooldownMs: number;
|
|
6
|
+
}
|
|
7
|
+
export declare function resolveEffectiveDedupe(reportDedupe: AXPReportGenerationDedupeOptions | undefined, platform: Pick<ReportGenerationPlatformSettings, 'dedupePolicy' | 'dedupeCooldownMs'>): EffectiveReportGenerationDedupe;
|
|
8
|
+
export declare function isDedupePolicyActive(dedupe: EffectiveReportGenerationDedupe, trigger: 'manual' | 'schedule' | 'export'): boolean;
|
|
9
|
+
export declare function buildReportGenerationFingerprint(input: {
|
|
10
|
+
reportId: string;
|
|
11
|
+
layoutIds?: string[];
|
|
12
|
+
layoutId?: string;
|
|
13
|
+
parameters?: Record<string, unknown>;
|
|
14
|
+
}): string;
|
|
15
|
+
export declare function matchesReportGenerationFingerprint(candidate: {
|
|
16
|
+
reportId: string;
|
|
17
|
+
layoutIds?: string[];
|
|
18
|
+
layoutId?: string;
|
|
19
|
+
parameters?: Record<string, unknown>;
|
|
20
|
+
}, fingerprint: string): boolean;
|
|
21
|
+
export declare function findDedupeMatch(input: {
|
|
22
|
+
fingerprint: string;
|
|
23
|
+
dedupe: EffectiveReportGenerationDedupe;
|
|
24
|
+
candidates: Array<{
|
|
25
|
+
id: string;
|
|
26
|
+
jobId?: string;
|
|
27
|
+
status: string;
|
|
28
|
+
reportId: string;
|
|
29
|
+
layoutIds?: string[];
|
|
30
|
+
layoutId?: string;
|
|
31
|
+
parameters?: Record<string, unknown>;
|
|
32
|
+
completedAt?: string;
|
|
33
|
+
}>;
|
|
34
|
+
now?: Date;
|
|
35
|
+
}): {
|
|
36
|
+
id: string;
|
|
37
|
+
jobId?: string;
|
|
38
|
+
status: string;
|
|
39
|
+
} | null;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveEffectiveDedupe = resolveEffectiveDedupe;
|
|
4
|
+
exports.isDedupePolicyActive = isDedupePolicyActive;
|
|
5
|
+
exports.buildReportGenerationFingerprint = buildReportGenerationFingerprint;
|
|
6
|
+
exports.matchesReportGenerationFingerprint = matchesReportGenerationFingerprint;
|
|
7
|
+
exports.findDedupeMatch = findDedupeMatch;
|
|
8
|
+
const node_crypto_1 = require("node:crypto");
|
|
9
|
+
const report_generation_util_1 = require("./report-generation.util");
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region ----- Policy resolution -----
|
|
12
|
+
function resolveEffectiveDedupe(reportDedupe, platform) {
|
|
13
|
+
var _a, _b;
|
|
14
|
+
return {
|
|
15
|
+
policy: (_a = reportDedupe === null || reportDedupe === void 0 ? void 0 : reportDedupe.policy) !== null && _a !== void 0 ? _a : platform.dedupePolicy,
|
|
16
|
+
cooldownMs: (_b = reportDedupe === null || reportDedupe === void 0 ? void 0 : reportDedupe.cooldownMs) !== null && _b !== void 0 ? _b : platform.dedupeCooldownMs,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function isDedupePolicyActive(dedupe, trigger) {
|
|
20
|
+
if (trigger === 'schedule') {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
return dedupe.policy !== 'none';
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region ----- Fingerprint -----
|
|
27
|
+
function buildReportGenerationFingerprint(input) {
|
|
28
|
+
var _a;
|
|
29
|
+
const layoutIds = normalizeLayoutIds(input.layoutIds, input.layoutId);
|
|
30
|
+
const parameters = stableJson((0, report_generation_util_1.convertParametersToFilterClause)((_a = input.parameters) !== null && _a !== void 0 ? _a : {}));
|
|
31
|
+
const payload = stableJson({
|
|
32
|
+
reportId: input.reportId.trim(),
|
|
33
|
+
layoutIds,
|
|
34
|
+
parameters,
|
|
35
|
+
});
|
|
36
|
+
return (0, node_crypto_1.createHash)('sha256').update(payload).digest('hex');
|
|
37
|
+
}
|
|
38
|
+
function normalizeLayoutIds(layoutIds, layoutId) {
|
|
39
|
+
const ids = (layoutIds === null || layoutIds === void 0 ? void 0 : layoutIds.length) ? layoutIds : layoutId ? [layoutId] : [];
|
|
40
|
+
return ids.map((id) => id.trim()).filter(Boolean).sort();
|
|
41
|
+
}
|
|
42
|
+
function stableJson(value) {
|
|
43
|
+
return JSON.stringify(sortValue(value));
|
|
44
|
+
}
|
|
45
|
+
function sortValue(value) {
|
|
46
|
+
if (Array.isArray(value)) {
|
|
47
|
+
return value.map((item) => sortValue(item));
|
|
48
|
+
}
|
|
49
|
+
if (value && typeof value === 'object') {
|
|
50
|
+
const record = value;
|
|
51
|
+
const sorted = {};
|
|
52
|
+
for (const key of Object.keys(record).sort()) {
|
|
53
|
+
sorted[key] = sortValue(record[key]);
|
|
54
|
+
}
|
|
55
|
+
return sorted;
|
|
56
|
+
}
|
|
57
|
+
return value;
|
|
58
|
+
}
|
|
59
|
+
function matchesReportGenerationFingerprint(candidate, fingerprint) {
|
|
60
|
+
return buildReportGenerationFingerprint(candidate) === fingerprint;
|
|
61
|
+
}
|
|
62
|
+
//#endregion
|
|
63
|
+
//#region ----- Dedupe matching -----
|
|
64
|
+
function findDedupeMatch(input) {
|
|
65
|
+
var _a;
|
|
66
|
+
const now = (_a = input.now) !== null && _a !== void 0 ? _a : new Date();
|
|
67
|
+
const activeStatuses = new Set(['queued', 'running']);
|
|
68
|
+
for (const candidate of input.candidates) {
|
|
69
|
+
if (!matchesReportGenerationFingerprint(candidate, input.fingerprint)) {
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
if (activeStatuses.has(candidate.status)) {
|
|
73
|
+
if (input.dedupe.policy === 'in-flight' || input.dedupe.policy === 'in-flight-or-cooldown') {
|
|
74
|
+
return { id: candidate.id, jobId: candidate.jobId, status: candidate.status };
|
|
75
|
+
}
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
if (input.dedupe.policy !== 'in-flight-or-cooldown' || input.dedupe.cooldownMs <= 0) {
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
if (candidate.status !== 'completed' || !candidate.completedAt) {
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
const completedAt = Date.parse(candidate.completedAt);
|
|
85
|
+
if (!Number.isFinite(completedAt)) {
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
if (now.getTime() - completedAt <= input.dedupe.cooldownMs) {
|
|
89
|
+
return { id: candidate.id, jobId: candidate.jobId, status: candidate.status };
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
//#endregion
|
|
95
|
+
//# sourceMappingURL=report-generation-policy.util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report-generation-policy.util.js","sourceRoot":"","sources":["../../../../../../../libs/modules/report-management/server/src/lib/report-generation/report-generation-policy.util.ts"],"names":[],"mappings":";;AAoBA,wDAQC;AAED,oDAQC;AAMD,4EAcC;AA0BD,gFAUC;AAMD,0CAiDC;AArJD,6CAAyC;AAOzC,qEAA2E;AAS3E,YAAY;AAEZ,uCAAuC;AAEvC,SAAgB,sBAAsB,CACpC,YAA0D,EAC1D,QAAqF;;IAErF,OAAO;QACL,MAAM,EAAE,MAAA,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