@acorex/connectivity 20.8.23 → 20.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/{acorex-connectivity-api-execute.command-D2Q0ahw4.mjs → acorex-connectivity-api-execute.command-CjCFEav4.mjs} +16 -6
- package/fesm2022/acorex-connectivity-api-execute.command-CjCFEav4.mjs.map +1 -0
- package/fesm2022/acorex-connectivity-api.mjs +202 -47
- package/fesm2022/acorex-connectivity-api.mjs.map +1 -1
- package/fesm2022/acorex-connectivity-mock-acorex-connectivity-mock-g0RVU1Og.mjs +90679 -0
- package/fesm2022/acorex-connectivity-mock-acorex-connectivity-mock-g0RVU1Og.mjs.map +1 -0
- package/fesm2022/acorex-connectivity-mock-assign-to-manager.activity-CTrrsAvF.mjs +288 -0
- package/fesm2022/acorex-connectivity-mock-assign-to-manager.activity-CTrrsAvF.mjs.map +1 -0
- package/fesm2022/acorex-connectivity-mock-category-metadata-inheritance.query-CIof4zTg.mjs +200 -0
- package/fesm2022/acorex-connectivity-mock-category-metadata-inheritance.query-CIof4zTg.mjs.map +1 -0
- package/fesm2022/{acorex-connectivity-mock-category-with-items.query-DWW7t6nc.mjs → acorex-connectivity-mock-category-with-items.query-DAKUJIIt.mjs} +18 -17
- package/fesm2022/acorex-connectivity-mock-category-with-items.query-DAKUJIIt.mjs.map +1 -0
- package/fesm2022/acorex-connectivity-mock-chat-generate-image.command-CSbgiZEm.mjs +110 -0
- package/fesm2022/acorex-connectivity-mock-chat-generate-image.command-CSbgiZEm.mjs.map +1 -0
- package/fesm2022/acorex-connectivity-mock-chat-synthesize-speech.command-CjdySQzM.mjs +120 -0
- package/fesm2022/acorex-connectivity-mock-chat-synthesize-speech.command-CjdySQzM.mjs.map +1 -0
- package/fesm2022/acorex-connectivity-mock-chat-transcribe-speech.command-Wm1Ao81s.mjs +120 -0
- package/fesm2022/acorex-connectivity-mock-chat-transcribe-speech.command-Wm1Ao81s.mjs.map +1 -0
- package/fesm2022/{acorex-connectivity-mock-check-permission.command-DFcxfjxp.mjs → acorex-connectivity-mock-check-permission.activity-vr3OHtjC.mjs} +8 -16
- package/fesm2022/acorex-connectivity-mock-check-permission.activity-vr3OHtjC.mjs.map +1 -0
- package/fesm2022/acorex-connectivity-mock-content-management.module-GQdqKsPB.mjs +16 -0
- package/fesm2022/acorex-connectivity-mock-content-management.module-GQdqKsPB.mjs.map +1 -0
- package/fesm2022/{acorex-connectivity-mock-distribution-record.command-BopU0LyU.mjs → acorex-connectivity-mock-distribution-record.activity-a1_k9Czb.mjs} +29 -14
- package/fesm2022/acorex-connectivity-mock-distribution-record.activity-a1_k9Czb.mjs.map +1 -0
- package/fesm2022/acorex-connectivity-mock-entity-create.activity-CdoUzUvF.mjs +67 -0
- package/fesm2022/acorex-connectivity-mock-entity-create.activity-CdoUzUvF.mjs.map +1 -0
- package/fesm2022/acorex-connectivity-mock-entity-delete.activity-ErEN1c24.mjs +60 -0
- package/fesm2022/acorex-connectivity-mock-entity-delete.activity-ErEN1c24.mjs.map +1 -0
- package/fesm2022/acorex-connectivity-mock-entity-read.activity-1fJW8gVe.mjs +67 -0
- package/fesm2022/acorex-connectivity-mock-entity-read.activity-1fJW8gVe.mjs.map +1 -0
- package/fesm2022/acorex-connectivity-mock-entity-update.activity-06HTKiQQ.mjs +68 -0
- package/fesm2022/acorex-connectivity-mock-entity-update.activity-06HTKiQQ.mjs.map +1 -0
- package/fesm2022/acorex-connectivity-mock-extract-document-text.command-nGfUTSf6.mjs +64 -0
- package/fesm2022/acorex-connectivity-mock-extract-document-text.command-nGfUTSf6.mjs.map +1 -0
- package/fesm2022/{acorex-connectivity-mock-get-application-versions-chart-data.query-uwDUrbFJ.mjs → acorex-connectivity-mock-get-application-versions-chart-data.query-DwVuYuKx.mjs} +4 -4
- package/fesm2022/acorex-connectivity-mock-get-application-versions-chart-data.query-DwVuYuKx.mjs.map +1 -0
- package/fesm2022/{acorex-connectivity-mock-get-application-versions-timeline.query-BHjQYTyZ.mjs → acorex-connectivity-mock-get-application-versions-timeline.query-sFKYynZA.mjs} +4 -4
- package/fesm2022/acorex-connectivity-mock-get-application-versions-timeline.query-sFKYynZA.mjs.map +1 -0
- package/fesm2022/acorex-connectivity-mock-get-current-session-user.activity-CsmxwXsM.mjs +39 -0
- package/fesm2022/acorex-connectivity-mock-get-current-session-user.activity-CsmxwXsM.mjs.map +1 -0
- package/fesm2022/acorex-connectivity-mock-get-current-user-manager.activity-C1mj2bgB.mjs +69 -0
- package/fesm2022/acorex-connectivity-mock-get-current-user-manager.activity-C1mj2bgB.mjs.map +1 -0
- package/fesm2022/{acorex-connectivity-mock-get-employee-list.query-Ch-Vh5GE.mjs → acorex-connectivity-mock-get-employee-list.query-BWbZj3tp.mjs} +8 -7
- package/fesm2022/acorex-connectivity-mock-get-employee-list.query-BWbZj3tp.mjs.map +1 -0
- package/fesm2022/{acorex-connectivity-mock-get-location-list.query-Xbc6d8kb.mjs → acorex-connectivity-mock-get-location-list.query-CQ2rFDUM.mjs} +5 -5
- package/fesm2022/acorex-connectivity-mock-get-location-list.query-CQ2rFDUM.mjs.map +1 -0
- package/fesm2022/{acorex-connectivity-mock-get-product-chart-data.query-m8_ME45B.mjs → acorex-connectivity-mock-get-product-chart-data.query-D7DBzLT-.mjs} +4 -4
- package/fesm2022/acorex-connectivity-mock-get-product-chart-data.query-D7DBzLT-.mjs.map +1 -0
- package/fesm2022/{acorex-connectivity-mock-get-product-list.query-DzkssYRw.mjs → acorex-connectivity-mock-get-product-list.query-o9TcY_RC.mjs} +20 -12
- package/fesm2022/acorex-connectivity-mock-get-product-list.query-o9TcY_RC.mjs.map +1 -0
- package/fesm2022/{acorex-connectivity-mock-get-product-pdf-data.query-wMD65pwR.mjs → acorex-connectivity-mock-get-product-pdf-data.query-DUZvwsmY.mjs} +5 -5
- package/fesm2022/acorex-connectivity-mock-get-product-pdf-data.query-DUZvwsmY.mjs.map +1 -0
- package/fesm2022/{acorex-connectivity-mock-get-subscriptions-chart-data.query-DBOT_0IN.mjs → acorex-connectivity-mock-get-subscriptions-chart-data.query-BXDzY2Sd.mjs} +5 -5
- package/fesm2022/acorex-connectivity-mock-get-subscriptions-chart-data.query-BXDzY2Sd.mjs.map +1 -0
- package/fesm2022/{acorex-connectivity-mock-get-subscriptions-timeline.query-DBEEbeiS.mjs → acorex-connectivity-mock-get-subscriptions-timeline.query-D_jVT-7a.mjs} +6 -6
- package/fesm2022/acorex-connectivity-mock-get-subscriptions-timeline.query-D_jVT-7a.mjs.map +1 -0
- package/fesm2022/{acorex-connectivity-mock-get-tenant-application-access.query-BM9toJ45.mjs → acorex-connectivity-mock-get-tenant-application-access.query-BG6t0137.mjs} +6 -6
- package/fesm2022/acorex-connectivity-mock-get-tenant-application-access.query-BG6t0137.mjs.map +1 -0
- package/fesm2022/{acorex-connectivity-mock-get-tenant-registration-chart-data.query-CACCBXn-.mjs → acorex-connectivity-mock-get-tenant-registration-chart-data.query-CgMZxfzh.mjs} +5 -5
- package/fesm2022/acorex-connectivity-mock-get-tenant-registration-chart-data.query-CgMZxfzh.mjs.map +1 -0
- package/fesm2022/{acorex-connectivity-mock-get-tenant-registration-timeline.query-CfDjhtaC.mjs → acorex-connectivity-mock-get-tenant-registration-timeline.query-COmTsDCV.mjs} +5 -5
- package/fesm2022/acorex-connectivity-mock-get-tenant-registration-timeline.query-COmTsDCV.mjs.map +1 -0
- package/fesm2022/{acorex-connectivity-mock-get-tenant-user-distribution.query-CZXvavUh.mjs → acorex-connectivity-mock-get-tenant-user-distribution.query-gqSqvIaa.mjs} +6 -6
- package/fesm2022/acorex-connectivity-mock-get-tenant-user-distribution.query-gqSqvIaa.mjs.map +1 -0
- package/fesm2022/acorex-connectivity-mock-if.activity-DvzuhItL.mjs +35 -0
- package/fesm2022/acorex-connectivity-mock-if.activity-DvzuhItL.mjs.map +1 -0
- package/fesm2022/acorex-connectivity-mock-index-D0jdkk2E.mjs +99 -0
- package/fesm2022/acorex-connectivity-mock-index-D0jdkk2E.mjs.map +1 -0
- package/fesm2022/acorex-connectivity-mock-jira-instance-sync.command-CaOd4PJa.mjs +474 -0
- package/fesm2022/acorex-connectivity-mock-jira-instance-sync.command-CaOd4PJa.mjs.map +1 -0
- package/fesm2022/acorex-connectivity-mock-notification-management-email-send.command-BuH_Lm6V.mjs +72 -0
- package/fesm2022/acorex-connectivity-mock-notification-management-email-send.command-BuH_Lm6V.mjs.map +1 -0
- package/fesm2022/acorex-connectivity-mock-report-summary.util-CGOhHIZr.mjs +56 -0
- package/fesm2022/acorex-connectivity-mock-report-summary.util-CGOhHIZr.mjs.map +1 -0
- package/fesm2022/{acorex-connectivity-mock-sample.command-CXz1poTn.mjs → acorex-connectivity-mock-sample.command-CJmDL4pL.mjs} +4 -4
- package/fesm2022/acorex-connectivity-mock-sample.command-CJmDL4pL.mjs.map +1 -0
- package/fesm2022/acorex-connectivity-mock-structured-text-completion.command-l31pjl9-.mjs +38 -0
- package/fesm2022/acorex-connectivity-mock-structured-text-completion.command-l31pjl9-.mjs.map +1 -0
- package/fesm2022/acorex-connectivity-mock-user-roles-for-list-column.query-wRFHOp-X.mjs +30 -0
- package/fesm2022/acorex-connectivity-mock-user-roles-for-list-column.query-wRFHOp-X.mjs.map +1 -0
- package/fesm2022/acorex-connectivity-mock.mjs +2 -51673
- package/fesm2022/acorex-connectivity-mock.mjs.map +1 -1
- package/fesm2022/acorex-connectivity-utils.mjs +7 -7
- package/fesm2022/acorex-connectivity-utils.mjs.map +1 -1
- package/fesm2022/acorex-connectivity.mjs.map +1 -1
- package/package.json +8 -7
- package/{api/index.d.ts → types/acorex-connectivity-api.d.ts} +21 -2
- package/types/acorex-connectivity-mock.d.ts +4136 -0
- package/fesm2022/acorex-connectivity-api-execute.command-D2Q0ahw4.mjs.map +0 -1
- package/fesm2022/acorex-connectivity-mock-assign-to-manager.command-CzzTHBVX.mjs +0 -66
- package/fesm2022/acorex-connectivity-mock-assign-to-manager.command-CzzTHBVX.mjs.map +0 -1
- package/fesm2022/acorex-connectivity-mock-category-with-items.query-DWW7t6nc.mjs.map +0 -1
- package/fesm2022/acorex-connectivity-mock-check-permission.command-DFcxfjxp.mjs.map +0 -1
- package/fesm2022/acorex-connectivity-mock-complete-signature-process.command-BG_rxbUl.mjs +0 -80
- package/fesm2022/acorex-connectivity-mock-complete-signature-process.command-BG_rxbUl.mjs.map +0 -1
- package/fesm2022/acorex-connectivity-mock-distribution-record.command-BopU0LyU.mjs.map +0 -1
- package/fesm2022/acorex-connectivity-mock-get-application-versions-chart-data.query-uwDUrbFJ.mjs.map +0 -1
- package/fesm2022/acorex-connectivity-mock-get-application-versions-timeline.query-BHjQYTyZ.mjs.map +0 -1
- package/fesm2022/acorex-connectivity-mock-get-employee-list.query-Ch-Vh5GE.mjs.map +0 -1
- package/fesm2022/acorex-connectivity-mock-get-location-list.query-Xbc6d8kb.mjs.map +0 -1
- package/fesm2022/acorex-connectivity-mock-get-product-chart-data.query-m8_ME45B.mjs.map +0 -1
- package/fesm2022/acorex-connectivity-mock-get-product-list.query-DzkssYRw.mjs.map +0 -1
- package/fesm2022/acorex-connectivity-mock-get-product-pdf-data.query-wMD65pwR.mjs.map +0 -1
- package/fesm2022/acorex-connectivity-mock-get-subscriptions-chart-data.query-DBOT_0IN.mjs.map +0 -1
- package/fesm2022/acorex-connectivity-mock-get-subscriptions-timeline.query-DBEEbeiS.mjs.map +0 -1
- package/fesm2022/acorex-connectivity-mock-get-tenant-application-access.query-BM9toJ45.mjs.map +0 -1
- package/fesm2022/acorex-connectivity-mock-get-tenant-registration-chart-data.query-CACCBXn-.mjs.map +0 -1
- package/fesm2022/acorex-connectivity-mock-get-tenant-registration-timeline.query-CfDjhtaC.mjs.map +0 -1
- package/fesm2022/acorex-connectivity-mock-get-tenant-user-distribution.query-CZXvavUh.mjs.map +0 -1
- package/fesm2022/acorex-connectivity-mock-notify-signers.command-BV-b8NBg.mjs +0 -69
- package/fesm2022/acorex-connectivity-mock-notify-signers.command-BV-b8NBg.mjs.map +0 -1
- package/fesm2022/acorex-connectivity-mock-request-signature.command-DZyVnhAp.mjs +0 -72
- package/fesm2022/acorex-connectivity-mock-request-signature.command-DZyVnhAp.mjs.map +0 -1
- package/fesm2022/acorex-connectivity-mock-sample.command-CXz1poTn.mjs.map +0 -1
- package/fesm2022/acorex-connectivity-mock-validate-all-signatures.command-leYngRtS.mjs +0 -81
- package/fesm2022/acorex-connectivity-mock-validate-all-signatures.command-leYngRtS.mjs.map +0 -1
- package/mock/index.d.ts +0 -3022
- /package/{utils/index.d.ts → types/acorex-connectivity-utils.d.ts} +0 -0
- /package/{index.d.ts → types/acorex-connectivity.d.ts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acorex-connectivity-mock-get-current-session-user.activity-CsmxwXsM.mjs","sources":["../../../../libs/connectivity/mock/src/lib/workflow-management/activities/get-current-session-user.activity.ts"],"sourcesContent":["import { AXPCommand } from '@acorex/platform/runtime-contracts';\nimport { inject, Injectable } from '@angular/core';\nimport { AXPExecuteCommandResult } from '@acorex/platform/contracts';\n\nimport { AXPSessionService } from '@acorex/platform/auth';\n\nexport interface GetCurrentSessionUserOutput {\n userId: string | null;\n}\n\n/**\n * Returns the platform user id of the current session (workflow initiator when run in UI).\n *\n * Activity Type: workflow-activity:get-current-session-user\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class GetCurrentSessionUserActivity\n implements AXPCommand<Record<string, never>, GetCurrentSessionUserOutput>\n{\n private readonly sessionService = inject(AXPSessionService);\n\n async execute(): Promise<AXPExecuteCommandResult<GetCurrentSessionUserOutput>> {\n const userId = this.sessionService.user?.id ?? null;\n console.log('[WFM-LifecycleTaskTrace] get-current-session-user', {\n userId,\n hasSession: !!this.sessionService.user,\n });\n return {\n success: true,\n data: { userId },\n metadata: {\n outcome: 'Done',\n },\n };\n }\n}\n"],"names":[],"mappings":";;;;AAUA;;;;AAIG;MAIU,6BAA6B,CAAA;AAH1C,IAAA,WAAA,GAAA;AAMmB,QAAA,IAAA,CAAA,cAAc,GAAG,MAAM,CAAC,iBAAiB,CAAC;AAgB5D,IAAA;AAdC,IAAA,MAAM,OAAO,GAAA;QACX,MAAM,MAAM,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE,EAAE,IAAI,IAAI;AACnD,QAAA,OAAO,CAAC,GAAG,CAAC,mDAAmD,EAAE;YAC/D,MAAM;AACN,YAAA,UAAU,EAAE,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI;AACvC,SAAA,CAAC;QACF,OAAO;AACL,YAAA,OAAO,EAAE,IAAI;YACb,IAAI,EAAE,EAAE,MAAM,EAAE;AAChB,YAAA,QAAQ,EAAE;AACR,gBAAA,OAAO,EAAE,MAAM;AAChB,aAAA;SACF;IACH;8GAlBW,6BAA6B,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAA7B,IAAA,SAAA,IAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,6BAA6B,cAF5B,MAAM,EAAA,CAAA,CAAA;;2FAEP,6BAA6B,EAAA,UAAA,EAAA,CAAA;kBAHzC,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE,MAAM;AACnB,iBAAA;;;;;"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { inject, Injectable } from '@angular/core';
|
|
3
|
+
import { AXPEntityStorageService } from '@acorex/platform/layout/entity';
|
|
4
|
+
import { AXPSessionService } from '@acorex/platform/auth';
|
|
5
|
+
|
|
6
|
+
const EMPLOYEE_ENTITY = 'HumanCapitalManagement.Employee';
|
|
7
|
+
/**
|
|
8
|
+
* Get Current User Manager Activity (Backend - Mock)
|
|
9
|
+
*
|
|
10
|
+
* Resolves the manager of the current user (Employee → managerId → manager's userId).
|
|
11
|
+
* Use when assigning a review task to the current user's manager (e.g. questionnaire review)
|
|
12
|
+
* without a leave request or other ref entity.
|
|
13
|
+
*
|
|
14
|
+
* Execution Mode: backend
|
|
15
|
+
* Activity Type: workflow-activity:get-current-user-manager
|
|
16
|
+
*/
|
|
17
|
+
class GetCurrentUserManagerActivity {
|
|
18
|
+
constructor() {
|
|
19
|
+
this.entityStorage = inject(AXPEntityStorageService);
|
|
20
|
+
this.sessionService = inject(AXPSessionService);
|
|
21
|
+
}
|
|
22
|
+
async execute() {
|
|
23
|
+
let managerId = null;
|
|
24
|
+
const userId = this.sessionService.user?.id;
|
|
25
|
+
if (userId) {
|
|
26
|
+
try {
|
|
27
|
+
const result = await this.entityStorage.query(EMPLOYEE_ENTITY, {
|
|
28
|
+
skip: 0,
|
|
29
|
+
take: 1,
|
|
30
|
+
filter: {
|
|
31
|
+
field: 'userId',
|
|
32
|
+
operator: { type: 'equal' },
|
|
33
|
+
value: userId,
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
const employees = result.items;
|
|
37
|
+
const employee = employees?.[0];
|
|
38
|
+
const managerEmployeeId = employee?.managerId;
|
|
39
|
+
if (managerEmployeeId) {
|
|
40
|
+
const managerEmp = (await this.entityStorage.getOne(EMPLOYEE_ENTITY, managerEmployeeId));
|
|
41
|
+
managerId = managerEmp?.userId ?? managerEmployeeId;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
// keep managerId null
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
success: true,
|
|
50
|
+
data: {
|
|
51
|
+
managerId,
|
|
52
|
+
},
|
|
53
|
+
metadata: {
|
|
54
|
+
outcome: 'Done',
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: GetCurrentUserManagerActivity, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
59
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: GetCurrentUserManagerActivity, providedIn: 'root' }); }
|
|
60
|
+
}
|
|
61
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: GetCurrentUserManagerActivity, decorators: [{
|
|
62
|
+
type: Injectable,
|
|
63
|
+
args: [{
|
|
64
|
+
providedIn: 'root',
|
|
65
|
+
}]
|
|
66
|
+
}] });
|
|
67
|
+
|
|
68
|
+
export { GetCurrentUserManagerActivity };
|
|
69
|
+
//# sourceMappingURL=acorex-connectivity-mock-get-current-user-manager.activity-C1mj2bgB.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acorex-connectivity-mock-get-current-user-manager.activity-C1mj2bgB.mjs","sources":["../../../../libs/connectivity/mock/src/lib/workflow-management/activities/get-current-user-manager.activity.ts"],"sourcesContent":["import { AXPCommand } from '@acorex/platform/runtime-contracts';\nimport { inject, Injectable } from '@angular/core';\nimport { AXPExecuteCommandResult } from '@acorex/platform/contracts';\n\nimport { AXPEntityStorageService } from '@acorex/platform/layout/entity';\nimport { AXPSessionService } from '@acorex/platform/auth';\n\nconst EMPLOYEE_ENTITY = 'HumanCapitalManagement.Employee';\n\nexport interface GetCurrentUserManagerOutput {\n managerId: string | null;\n}\n\n/**\n * Get Current User Manager Activity (Backend - Mock)\n *\n * Resolves the manager of the current user (Employee → managerId → manager's userId).\n * Use when assigning a review task to the current user's manager (e.g. questionnaire review)\n * without a leave request or other ref entity.\n *\n * Execution Mode: backend\n * Activity Type: workflow-activity:get-current-user-manager\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class GetCurrentUserManagerActivity implements AXPCommand<Record<string, never>, GetCurrentUserManagerOutput> {\n private readonly entityStorage = inject(AXPEntityStorageService);\n private readonly sessionService = inject(AXPSessionService);\n\n async execute(): Promise<AXPExecuteCommandResult<GetCurrentUserManagerOutput>> {\n let managerId: string | null = null;\n const userId = this.sessionService.user?.id;\n\n if (userId) {\n try {\n const result = await this.entityStorage.query(EMPLOYEE_ENTITY, {\n skip: 0,\n take: 1,\n filter: {\n field: 'userId',\n operator: { type: 'equal' },\n value: userId,\n },\n });\n const employees = result.items as { id: string; managerId?: string | null }[] | undefined;\n const employee = employees?.[0];\n const managerEmployeeId = employee?.managerId;\n\n if (managerEmployeeId) {\n const managerEmp = (await this.entityStorage.getOne(EMPLOYEE_ENTITY, managerEmployeeId)) as {\n userId?: string;\n } | null;\n managerId = managerEmp?.userId ?? managerEmployeeId;\n }\n } catch {\n // keep managerId null\n }\n }\n\n return {\n success: true,\n data: {\n managerId,\n },\n metadata: {\n outcome: 'Done',\n },\n };\n }\n}\n"],"names":[],"mappings":";;;;;AAOA,MAAM,eAAe,GAAG,iCAAiC;AAMzD;;;;;;;;;AASG;MAIU,6BAA6B,CAAA;AAH1C,IAAA,WAAA,GAAA;AAImB,QAAA,IAAA,CAAA,aAAa,GAAG,MAAM,CAAC,uBAAuB,CAAC;AAC/C,QAAA,IAAA,CAAA,cAAc,GAAG,MAAM,CAAC,iBAAiB,CAAC;AA0C5D,IAAA;AAxCC,IAAA,MAAM,OAAO,GAAA;QACX,IAAI,SAAS,GAAkB,IAAI;QACnC,MAAM,MAAM,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE,EAAE;QAE3C,IAAI,MAAM,EAAE;AACV,YAAA,IAAI;gBACF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,eAAe,EAAE;AAC7D,oBAAA,IAAI,EAAE,CAAC;AACP,oBAAA,IAAI,EAAE,CAAC;AACP,oBAAA,MAAM,EAAE;AACN,wBAAA,KAAK,EAAE,QAAQ;AACf,wBAAA,QAAQ,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE;AAC3B,wBAAA,KAAK,EAAE,MAAM;AACd,qBAAA;AACF,iBAAA,CAAC;AACF,gBAAA,MAAM,SAAS,GAAG,MAAM,CAAC,KAAgE;AACzF,gBAAA,MAAM,QAAQ,GAAG,SAAS,GAAG,CAAC,CAAC;AAC/B,gBAAA,MAAM,iBAAiB,GAAG,QAAQ,EAAE,SAAS;gBAE7C,IAAI,iBAAiB,EAAE;AACrB,oBAAA,MAAM,UAAU,IAAI,MAAM,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,eAAe,EAAE,iBAAiB,CAAC,CAE/E;AACR,oBAAA,SAAS,GAAG,UAAU,EAAE,MAAM,IAAI,iBAAiB;gBACrD;YACF;AAAE,YAAA,MAAM;;YAER;QACF;QAEA,OAAO;AACL,YAAA,OAAO,EAAE,IAAI;AACb,YAAA,IAAI,EAAE;gBACJ,SAAS;AACV,aAAA;AACD,YAAA,QAAQ,EAAE;AACR,gBAAA,OAAO,EAAE,MAAM;AAChB,aAAA;SACF;IACH;8GA3CW,6BAA6B,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAA7B,IAAA,SAAA,IAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,6BAA6B,cAF5B,MAAM,EAAA,CAAA,CAAA;;2FAEP,6BAA6B,EAAA,UAAA,EAAA,CAAA;kBAHzC,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE,MAAM;AACnB,iBAAA;;;;;"}
|
|
@@ -2,6 +2,7 @@ import * as i0 from '@angular/core';
|
|
|
2
2
|
import { inject, Injectable } from '@angular/core';
|
|
3
3
|
import { AXPEntityService } from '@acorex/platform/layout/entity';
|
|
4
4
|
import { RootConfig } from '@acorex/modules/human-capital-management';
|
|
5
|
+
import { c as computeReportFooterSummary } from './acorex-connectivity-mock-report-summary.util-CGOhHIZr.mjs';
|
|
5
6
|
|
|
6
7
|
//#endregion
|
|
7
8
|
class GetEmployeeListQuery {
|
|
@@ -96,11 +97,10 @@ class GetEmployeeListQuery {
|
|
|
96
97
|
if (input.sort && input.sort.length > 0) {
|
|
97
98
|
aggregatedResults.sort((a, b) => {
|
|
98
99
|
for (const sortField of input.sort) {
|
|
99
|
-
const field = sortField.
|
|
100
|
+
const field = sortField.name;
|
|
100
101
|
const aValue = a[field];
|
|
101
102
|
const bValue = b[field];
|
|
102
103
|
const dir = sortField.dir === 'asc' ? 1 : -1;
|
|
103
|
-
// Handle undefined values
|
|
104
104
|
if (aValue === undefined && bValue === undefined)
|
|
105
105
|
continue;
|
|
106
106
|
if (aValue === undefined)
|
|
@@ -115,7 +115,7 @@ class GetEmployeeListQuery {
|
|
|
115
115
|
return 0;
|
|
116
116
|
});
|
|
117
117
|
}
|
|
118
|
-
|
|
118
|
+
const summary = computeReportFooterSummary(aggregatedResults, input.summary);
|
|
119
119
|
const skip = input.skip || 0;
|
|
120
120
|
const take = input.take || 10;
|
|
121
121
|
const total = aggregatedResults.length;
|
|
@@ -123,6 +123,7 @@ class GetEmployeeListQuery {
|
|
|
123
123
|
return {
|
|
124
124
|
items,
|
|
125
125
|
total,
|
|
126
|
+
summary,
|
|
126
127
|
};
|
|
127
128
|
}
|
|
128
129
|
//#region ---- Filter Extraction ----
|
|
@@ -199,10 +200,10 @@ class GetEmployeeListQuery {
|
|
|
199
200
|
}
|
|
200
201
|
return filters;
|
|
201
202
|
}
|
|
202
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
203
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
203
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: GetEmployeeListQuery, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
204
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: GetEmployeeListQuery, providedIn: 'root' }); }
|
|
204
205
|
}
|
|
205
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
206
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: GetEmployeeListQuery, decorators: [{
|
|
206
207
|
type: Injectable,
|
|
207
208
|
args: [{
|
|
208
209
|
providedIn: 'root',
|
|
@@ -210,4 +211,4 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImpo
|
|
|
210
211
|
}] });
|
|
211
212
|
|
|
212
213
|
export { GetEmployeeListQuery };
|
|
213
|
-
//# sourceMappingURL=acorex-connectivity-mock-get-employee-list.query-
|
|
214
|
+
//# sourceMappingURL=acorex-connectivity-mock-get-employee-list.query-BWbZj3tp.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acorex-connectivity-mock-get-employee-list.query-BWbZj3tp.mjs","sources":["../../../../libs/connectivity/mock/src/lib/report-management/samples/get-employee-list.query.ts"],"sourcesContent":["import { AXPQuery } from '@acorex/platform/runtime-contracts';\nimport { AXPQuerySort } from '@acorex/platform/layout/entity-contracts';\nimport { inject, Injectable } from '@angular/core';\n\nimport { AXPEntityService } from '@acorex/platform/layout/entity';\nimport { AXMHumanCapitalManagementEmployeeEntityModel } from '@acorex/modules/human-capital-management';\nimport { RootConfig as HumanCapitalRootConfig } from '@acorex/modules/human-capital-management';\n\nimport { AXPReportSummaryOptions } from '@acorex/modules/report-management';\nimport { computeReportFooterSummary } from '../report-summary.util';\n\n//#region ---- Query Input/Output Types ----\n\nexport interface GetEmployeeListQueryInput {\n skip?: number;\n take?: number;\n sort?: AXPQuerySort[];\n summary?: AXPReportSummaryOptions[];\n filters?: Array<{\n field: string;\n operator: { type: string };\n value: any;\n }>;\n logic?: 'and' | 'or';\n}\n\nexport interface EmployeeByDepartmentResult {\n departmentId: string;\n departmentTitle: string;\n teamId?: string;\n teamTitle?: string;\n employeeCount: number;\n employmentTypes: string;\n averageExperience: number;\n totalEmployees: number;\n}\n\nexport interface GetEmployeeListQueryResult {\n items: EmployeeByDepartmentResult[];\n total: number;\n summary?: Record<string, number | null>;\n}\n\n//#endregion\n\n@Injectable({\n providedIn: 'root',\n})\nexport class GetEmployeeListQuery implements AXPQuery<GetEmployeeListQueryInput, GetEmployeeListQueryResult> {\n private readonly entityService = inject(AXPEntityService);\n private employeeService = this.entityService\n .withEntity(`${HumanCapitalRootConfig.module.name}.${HumanCapitalRootConfig.entities.employee.name}`)\n .data<string, AXMHumanCapitalManagementEmployeeEntityModel>();\n\n async fetch(input: GetEmployeeListQueryInput | any): Promise<GetEmployeeListQueryResult> {\n // Extract employee-specific filters from AXPFilterClause format\n const extractedFilters = this.extractEmployeeFilters(input.filters);\n\n // Separate custom filters from entity filters\n const entityFilters: GetEmployeeListQueryInput['filters'] = [];\n\n if (extractedFilters && extractedFilters.length > 0) {\n for (const filter of extractedFilters) {\n entityFilters.push(filter);\n }\n }\n\n // Get all employees from storage with entity filters\n const allEmployeesResult = await this.employeeService.query({\n skip: 0,\n take: 10000, // Get all employees for aggregation\n filter:\n entityFilters.length > 0\n ? ({\n logic: input.logic || 'and',\n filters: entityFilters,\n } as any)\n : undefined,\n });\n\n const allEmployees = allEmployeesResult.items;\n\n // Group employees by department and team\n const departmentGroups = new Map<string, Map<string, AXMHumanCapitalManagementEmployeeEntityModel[]>>();\n\n for (const employee of allEmployees) {\n // Get department from position (assuming position has departmentId)\n const departmentId = (employee as any).position?.departmentId || (employee as any).departmentId || 'unknown';\n const departmentTitle = (employee as any).position?.department?.title || 'Unknown Department';\n\n // Get team from team memberships (assuming employee has teamId or teamMemberships)\n const teamId = (employee as any).teamId || (employee as any).teamMemberships?.[0]?.teamId || undefined;\n const teamTitle = (employee as any).team?.title || (employee as any).teamMemberships?.[0]?.team?.title || undefined;\n\n const teamKey = teamId || 'no-team';\n\n if (!departmentGroups.has(departmentId)) {\n departmentGroups.set(departmentId, new Map());\n }\n\n const teamMap = departmentGroups.get(departmentId)!;\n if (!teamMap.has(teamKey)) {\n teamMap.set(teamKey, []);\n }\n\n teamMap.get(teamKey)!.push(employee);\n }\n\n // Aggregate data by department and team\n const aggregatedResults: EmployeeByDepartmentResult[] = [];\n\n for (const [departmentId, teamMap] of departmentGroups.entries()) {\n const firstEmployee = Array.from(teamMap.values())[0]?.[0];\n const departmentTitle = (firstEmployee as any)?.position?.department?.title || 'Unknown Department';\n\n for (const [teamKey, employees] of teamMap.entries()) {\n const teamId = teamKey !== 'no-team' ? teamKey : undefined;\n const teamTitle =\n teamKey !== 'no-team' ? (employees[0] as any)?.team?.title || (employees[0] as any)?.teamMemberships?.[0]?.team?.title : undefined;\n\n // Calculate average experience (years since hire date)\n const now = new Date();\n const experiences = employees\n .map((emp) => {\n if (!emp.hireDate) return 0;\n const hireDate = new Date(emp.hireDate);\n const diffTime = Math.abs(now.getTime() - hireDate.getTime());\n return diffTime / (1000 * 60 * 60 * 24 * 365.25); // Convert to years\n })\n .filter((exp) => exp > 0);\n\n const averageExperience = experiences.length > 0 ? experiences.reduce((sum, exp) => sum + exp, 0) / experiences.length : 0;\n\n // Get unique employment types\n const employmentTypeSet = new Set<string>();\n for (const employee of employees) {\n if ((employee as any).employmentType?.title) {\n employmentTypeSet.add((employee as any).employmentType.title);\n }\n }\n const employmentTypes = Array.from(employmentTypeSet).join(', ') || 'N/A';\n\n aggregatedResults.push({\n departmentId,\n departmentTitle,\n teamId,\n teamTitle,\n employeeCount: employees.length,\n employmentTypes,\n averageExperience: Number(averageExperience.toFixed(2)),\n totalEmployees: employees.length,\n });\n }\n }\n\n // Apply sorting if provided\n if (input.sort && input.sort.length > 0) {\n aggregatedResults.sort((a, b) => {\n for (const sortField of input.sort!) {\n const field = sortField.name as keyof EmployeeByDepartmentResult;\n const aValue = a[field];\n const bValue = b[field];\n const dir = sortField.dir === 'asc' ? 1 : -1;\n\n if (aValue === undefined && bValue === undefined) continue;\n if (aValue === undefined) return 1 * dir;\n if (bValue === undefined) return -1 * dir;\n\n if (aValue < bValue) return -1 * dir;\n if (aValue > bValue) return 1 * dir;\n }\n return 0;\n });\n }\n\n const summary = computeReportFooterSummary(\n aggregatedResults as unknown as Record<string, unknown>[],\n input.summary,\n );\n\n const skip = input.skip || 0;\n const take = input.take || 10;\n const total = aggregatedResults.length;\n const items = aggregatedResults.slice(skip, skip + take);\n\n return {\n items,\n total,\n summary,\n };\n }\n\n //#region ---- Filter Extraction ----\n\n /**\n * Extract employee-specific filters from AXPFilterClause format\n * Maps report parameter paths to employee entity field names\n */\n private extractEmployeeFilters(parameters: any): GetEmployeeListQueryInput['filters'] {\n const filters: GetEmployeeListQueryInput['filters'] = [];\n const paramsAny = parameters as any;\n\n if (!paramsAny?.filters || !Array.isArray(paramsAny.filters)) {\n return filters;\n }\n\n for (const filter of paramsAny.filters) {\n if (!filter?.field || filter?.value === undefined || filter?.value === null) {\n continue;\n }\n\n const field = filter.field;\n const value = filter.value;\n const operator = filter.operator || { type: 'equal' };\n\n // Handle employee-specific field mappings\n if (field === 'department') {\n // Department filter - can be array of IDs or single ID\n if (Array.isArray(value) && value.length > 0) {\n filters.push({\n field: 'position.departmentId', // Assuming position has departmentId\n operator: { type: 'in' },\n value: value,\n });\n } else if (value) {\n filters.push({\n field: 'position.departmentId',\n operator: { type: 'equal' },\n value: value,\n });\n }\n } else if (field === 'team') {\n // Team filter - can be array of IDs or single ID\n if (Array.isArray(value) && value.length > 0) {\n filters.push({\n field: 'teamId', // Assuming employee has teamId or teamMemberships\n operator: { type: 'in' },\n value: value,\n });\n } else if (value) {\n filters.push({\n field: 'teamId',\n operator: { type: 'equal' },\n value: value,\n });\n }\n } else if (field === 'employmentType') {\n // Employment type filter - skip 'all' value\n if (value && value !== 'all') {\n filters.push({\n field: 'employmentTypeId',\n operator: { type: 'equal' },\n value: value,\n });\n }\n } else {\n // Direct field mapping\n filters.push({\n field: field,\n operator: operator,\n value: value,\n });\n }\n }\n\n return filters;\n }\n\n //#endregion\n}\n"],"names":["HumanCapitalRootConfig"],"mappings":";;;;;;AA2CA;MAKa,oBAAoB,CAAA;AAHjC,IAAA,WAAA,GAAA;AAImB,QAAA,IAAA,CAAA,aAAa,GAAG,MAAM,CAAC,gBAAgB,CAAC;QACjD,IAAA,CAAA,eAAe,GAAG,IAAI,CAAC;AAC5B,aAAA,UAAU,CAAC,CAAA,EAAGA,UAAsB,CAAC,MAAM,CAAC,IAAI,CAAA,CAAA,EAAIA,UAAsB,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE;AACnG,aAAA,IAAI,EAAwD;AAyNhE,IAAA;IAvNC,MAAM,KAAK,CAAC,KAAsC,EAAA;;QAEhD,MAAM,gBAAgB,GAAG,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC,OAAO,CAAC;;QAGnE,MAAM,aAAa,GAAyC,EAAE;QAE9D,IAAI,gBAAgB,IAAI,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE;AACnD,YAAA,KAAK,MAAM,MAAM,IAAI,gBAAgB,EAAE;AACrC,gBAAA,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC;YAC5B;QACF;;QAGA,MAAM,kBAAkB,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC;AAC1D,YAAA,IAAI,EAAE,CAAC;YACP,IAAI,EAAE,KAAK;AACX,YAAA,MAAM,EACJ,aAAa,CAAC,MAAM,GAAG;AACrB,kBAAG;AACC,oBAAA,KAAK,EAAE,KAAK,CAAC,KAAK,IAAI,KAAK;AAC3B,oBAAA,OAAO,EAAE,aAAa;AACf;AACX,kBAAE,SAAS;AAChB,SAAA,CAAC;AAEF,QAAA,MAAM,YAAY,GAAG,kBAAkB,CAAC,KAAK;;AAG7C,QAAA,MAAM,gBAAgB,GAAG,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,kBAAkB;AACzB,wBAAA,QAAQ,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE;AAC3B,wBAAA,KAAK,EAAE,KAAK;AACb,qBAAA,CAAC;gBACJ;YACF;iBAAO;;gBAEL,OAAO,CAAC,IAAI,CAAC;AACX,oBAAA,KAAK,EAAE,KAAK;AACZ,oBAAA,QAAQ,EAAE,QAAQ;AAClB,oBAAA,KAAK,EAAE,KAAK;AACb,iBAAA,CAAC;YACJ;QACF;AAEA,QAAA,OAAO,OAAO;IAChB;8GA1NW,oBAAoB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAApB,IAAA,SAAA,IAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,oBAAoB,cAFnB,MAAM,EAAA,CAAA,CAAA;;2FAEP,oBAAoB,EAAA,UAAA,EAAA,CAAA;kBAHhC,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE,MAAM;AACnB,iBAAA;;;;;"}
|
|
@@ -84,7 +84,7 @@ class GetLocationListQuery {
|
|
|
84
84
|
if (input.sort && input.sort.length > 0) {
|
|
85
85
|
aggregatedResults.sort((a, b) => {
|
|
86
86
|
for (const sortField of input.sort) {
|
|
87
|
-
const field = sortField.
|
|
87
|
+
const field = sortField.name;
|
|
88
88
|
const aValue = a[field];
|
|
89
89
|
const bValue = b[field];
|
|
90
90
|
const dir = sortField.dir === 'asc' ? 1 : -1;
|
|
@@ -195,10 +195,10 @@ class GetLocationListQuery {
|
|
|
195
195
|
}
|
|
196
196
|
return filters;
|
|
197
197
|
}
|
|
198
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
199
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
198
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: GetLocationListQuery, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
199
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: GetLocationListQuery, providedIn: 'root' }); }
|
|
200
200
|
}
|
|
201
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
201
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: GetLocationListQuery, decorators: [{
|
|
202
202
|
type: Injectable,
|
|
203
203
|
args: [{
|
|
204
204
|
providedIn: 'root',
|
|
@@ -206,4 +206,4 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImpo
|
|
|
206
206
|
}] });
|
|
207
207
|
|
|
208
208
|
export { GetLocationListQuery };
|
|
209
|
-
//# sourceMappingURL=acorex-connectivity-mock-get-location-list.query-
|
|
209
|
+
//# sourceMappingURL=acorex-connectivity-mock-get-location-list.query-CQ2rFDUM.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acorex-connectivity-mock-get-location-list.query-CQ2rFDUM.mjs","sources":["../../../../libs/connectivity/mock/src/lib/report-management/samples/get-location-list.query.ts"],"sourcesContent":["import { AXPQuery } from '@acorex/platform/runtime-contracts';\nimport { AXPQuerySort } from '@acorex/platform/layout/entity-contracts';\nimport { inject, Injectable } from '@angular/core';\n\nimport { AXPEntityService } from '@acorex/platform/layout/entity';\nimport { AXMLocationManagementLocationEntityModel } from '@acorex/modules/location-management';\nimport { RootConfig as LocationRootConfig } from '@acorex/modules/location-management';\n\n//#region ---- Query Input/Output Types ----\n\nexport interface GetLocationListQueryInput {\n skip?: number;\n take?: number;\n sort?: AXPQuerySort[];\n filters?: Array<{\n field: string;\n operator: { type: string };\n value: any;\n }>;\n logic?: 'and' | 'or';\n}\n\nexport interface LocationByCityResult {\n countryId?: string;\n countryTitle?: string;\n provinceId?: string;\n provinceTitle?: string;\n cityId?: string;\n cityTitle?: string;\n locationCount: number;\n totalLocations: number;\n}\n\nexport interface GetLocationListQueryResult {\n items: LocationByCityResult[];\n total: number;\n}\n\n//#endregion\n\n@Injectable({\n providedIn: 'root',\n})\nexport class GetLocationListQuery implements AXPQuery<GetLocationListQueryInput, GetLocationListQueryResult> {\n private readonly entityService = inject(AXPEntityService);\n private locationService = this.entityService\n .withEntity(`${LocationRootConfig.module.name}.${LocationRootConfig.entities.location.name}`)\n .data<string, AXMLocationManagementLocationEntityModel>();\n\n async fetch(input: GetLocationListQueryInput | any): Promise<GetLocationListQueryResult> {\n // Extract location-specific filters from AXPFilterClause format\n const extractedFilters = this.extractLocationFilters(input.filters);\n // Separate custom filters from entity filters\n const entityFilters: GetLocationListQueryInput['filters'] = [];\n\n if (extractedFilters && extractedFilters.length > 0) {\n for (const filter of extractedFilters) {\n entityFilters.push(filter);\n }\n }\n // Get all locations from storage with entity filters\n const allLocationsResult = await this.locationService.query({\n skip: 0,\n take: 10000, // Get all locations for aggregation\n filter:\n entityFilters.length > 0\n ? ({\n logic: input.logic || 'and',\n filters: entityFilters,\n } as any)\n : undefined,\n });\n\n const allLocations = allLocationsResult.items;\n\n // Group locations by country, province, and city\n const locationGroups = new Map<string, Map<string, Map<string, AXMLocationManagementLocationEntityModel[]>>>();\n\n for (const location of allLocations) {\n // Get geographic information\n const countryId = (location as any).countryId || 'unknown';\n const countryTitle = (location as any).country?.title || 'Unknown Country';\n\n const provinceId = (location as any).stateId || 'unknown';\n const provinceTitle = (location as any).state?.title || 'Unknown Province';\n\n const cityId = (location as any).cityId || 'unknown';\n const cityTitle = (location as any).city?.title || 'Unknown City';\n\n // Create nested map structure: country -> province -> city -> locations[]\n if (!locationGroups.has(countryId)) {\n locationGroups.set(countryId, new Map());\n }\n\n const provinceMap = locationGroups.get(countryId)!;\n if (!provinceMap.has(provinceId)) {\n provinceMap.set(provinceId, new Map());\n }\n\n const cityMap = provinceMap.get(provinceId)!;\n if (!cityMap.has(cityId)) {\n cityMap.set(cityId, []);\n }\n\n cityMap.get(cityId)!.push(location);\n }\n\n // Aggregate data by country, province, and city\n const aggregatedResults: LocationByCityResult[] = [];\n\n for (const [countryId, provinceMap] of locationGroups.entries()) {\n const firstLocation = Array.from(provinceMap.values())[0]?.values().next().value?.[0];\n const countryTitle = (firstLocation as any)?.country?.title || 'Unknown Country';\n\n for (const [provinceId, cityMap] of provinceMap.entries()) {\n const firstLocationInProvince = cityMap.values().next().value?.[0];\n const provinceTitle = (firstLocationInProvince as any)?.state?.title || 'Unknown Province';\n\n for (const [cityId, locations] of cityMap.entries()) {\n const cityTitle = (locations[0] as any)?.city?.title || 'Unknown City';\n\n aggregatedResults.push({\n countryId,\n countryTitle,\n provinceId,\n provinceTitle,\n cityId,\n cityTitle,\n locationCount: locations.length,\n totalLocations: locations.length,\n });\n }\n }\n }\n\n // Apply sorting if provided\n if (input.sort && input.sort.length > 0) {\n aggregatedResults.sort((a, b) => {\n for (const sortField of input.sort!) {\n const field = sortField.name as keyof LocationByCityResult;\n const aValue = a[field];\n const bValue = b[field];\n const dir = sortField.dir === 'asc' ? 1 : -1;\n\n // Handle undefined values\n if (aValue === undefined && bValue === undefined) continue;\n if (aValue === undefined) return 1 * dir;\n if (bValue === undefined) return -1 * dir;\n\n if (aValue < bValue) return -1 * dir;\n if (aValue > bValue) return 1 * dir;\n }\n return 0;\n });\n }\n\n // Apply pagination\n const skip = input.skip || 0;\n const take = input.take || 10;\n const total = aggregatedResults.length;\n const items = aggregatedResults.slice(skip, skip + take);\n\n return {\n items,\n total,\n };\n }\n\n //#region ---- Filter Extraction ----\n\n /**\n * Extract location-specific filters from AXPFilterClause format\n * Maps report parameter paths to location entity field names\n */\n private extractLocationFilters(parameters: any): GetLocationListQueryInput['filters'] {\n const filters: GetLocationListQueryInput['filters'] = [];\n const paramsAny = parameters as any;\n\n if (!paramsAny?.filters || !Array.isArray(paramsAny.filters)) {\n console.log('⚠️ [extractLocationFilters] No filters array found or not an array');\n return filters;\n }\n\n for (const filter of paramsAny.filters) {\n if (!filter?.field || filter?.value === undefined || filter?.value === null) {\n continue;\n }\n\n const field = filter.field;\n const value = filter.value;\n const operator = filter.operator || { type: 'equal' };\n\n // Handle location-specific field mappings\n if (field === 'country') {\n // Country filter\n if (Array.isArray(value) && value.length > 0) {\n filters.push({\n field: 'countryId',\n operator: { type: 'in' },\n value: value,\n });\n } else if (value) {\n filters.push({\n field: 'countryId',\n operator: { type: 'equal' },\n value: value,\n });\n }\n } else if (field === 'province') {\n // Province/State filter\n if (Array.isArray(value) && value.length > 0) {\n filters.push({\n field: 'stateId',\n operator: { type: 'in' },\n value: value,\n });\n } else if (value) {\n filters.push({\n field: 'stateId',\n operator: { type: 'equal' },\n value: value,\n });\n console.log('✅ [extractLocationFilters] Added province filter (equal):', value);\n }\n } else if (field === 'city') {\n if (Array.isArray(value) && value.length > 0) {\n filters.push({\n field: 'cityId',\n operator: { type: 'in' },\n value: value,\n });\n } else if (value) {\n filters.push({\n field: 'cityId',\n operator: { type: 'equal' },\n value: value,\n });\n }\n } else {\n // Direct field mapping\n filters.push({\n field: field,\n operator: operator,\n value: value,\n });\n }\n }\n\n return filters;\n }\n\n //#endregion\n}\n"],"names":["LocationRootConfig"],"mappings":";;;;;AAsCA;MAKa,oBAAoB,CAAA;AAHjC,IAAA,WAAA,GAAA;AAImB,QAAA,IAAA,CAAA,aAAa,GAAG,MAAM,CAAC,gBAAgB,CAAC;QACjD,IAAA,CAAA,eAAe,GAAG,IAAI,CAAC;AAC5B,aAAA,UAAU,CAAC,CAAA,EAAGA,UAAkB,CAAC,MAAM,CAAC,IAAI,CAAA,CAAA,EAAIA,UAAkB,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE;AAC3F,aAAA,IAAI,EAAoD;AA6M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AChB,OAAO,CAAC,IAAI,CAAC;AACX,wBAAA,KAAK,EAAE,QAAQ;AACf,wBAAA,QAAQ,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE;AAC3B,wBAAA,KAAK,EAAE,KAAK;AACb,qBAAA,CAAC;gBACJ;YACF;iBAAO;;gBAEL,OAAO,CAAC,IAAI,CAAC;AACX,oBAAA,KAAK,EAAE,KAAK;AACZ,oBAAA,QAAQ,EAAE,QAAQ;AAClB,oBAAA,KAAK,EAAE,KAAK;AACb,iBAAA,CAAC;YACJ;QACF;AAEA,QAAA,OAAO,OAAO;IAChB;8GA9MW,oBAAoB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAApB,IAAA,SAAA,IAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,oBAAoB,cAFnB,MAAM,EAAA,CAAA,CAAA;;2FAEP,oBAAoB,EAAA,UAAA,EAAA,CAAA;kBAHhC,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE,MAAM;AACnB,iBAAA;;;;;"}
|
|
@@ -172,10 +172,10 @@ class GetProductChartDataQuery {
|
|
|
172
172
|
}
|
|
173
173
|
});
|
|
174
174
|
}
|
|
175
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
176
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
175
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: GetProductChartDataQuery, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
176
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: GetProductChartDataQuery, providedIn: 'root' }); }
|
|
177
177
|
}
|
|
178
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
178
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: GetProductChartDataQuery, decorators: [{
|
|
179
179
|
type: Injectable,
|
|
180
180
|
args: [{
|
|
181
181
|
providedIn: 'root',
|
|
@@ -183,4 +183,4 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImpo
|
|
|
183
183
|
}] });
|
|
184
184
|
|
|
185
185
|
export { GetProductChartDataQuery };
|
|
186
|
-
//# sourceMappingURL=acorex-connectivity-mock-get-product-chart-data.query-
|
|
186
|
+
//# sourceMappingURL=acorex-connectivity-mock-get-product-chart-data.query-D7DBzLT-.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acorex-connectivity-mock-get-product-chart-data.query-D7DBzLT-.mjs","sources":["../../../../libs/connectivity/mock/src/lib/product-catalog/reports/get-product-chart-data.query.ts"],"sourcesContent":["import { AXPQuery } from '@acorex/platform/runtime-contracts';\nimport { inject, Injectable } from '@angular/core';\n\nimport { AXPEntityService } from '@acorex/platform/layout/entity';\nimport { AXMProductCatalogProductEntityModel } from '@acorex/modules/product-catalog';\nimport { RootConfig } from '@acorex/modules/product-catalog';\n\n//#region ---- Query Input/Output Types ----\n\nexport interface GetProductChartDataQueryInput {\n filters?: Array<{\n field: string;\n operator: { type: string };\n value: any;\n }>;\n logic?: 'and' | 'or';\n}\n\nexport interface ProductChartDataResult {\n brand: string;\n productCount: number;\n}\n\nexport interface GetProductChartDataQueryResult {\n items: ProductChartDataResult[];\n}\n\n//#endregion\n\n@Injectable({\n providedIn: 'root',\n})\nexport class GetProductChartDataQuery implements AXPQuery<GetProductChartDataQueryInput, GetProductChartDataQueryResult> {\n private readonly entityService = inject(AXPEntityService);\n private productService = this.entityService.withEntity(`${RootConfig.module.name}.${RootConfig.entities.product.name}`).data<string, AXMProductCatalogProductEntityModel>();\n\n async fetch(input: GetProductChartDataQueryInput | any): Promise<GetProductChartDataQueryResult> {\n // Extract product-specific filters from AXPFilterClause format\n const extractedFilters = this.extractProductFilters(input.filters);\n\n // Separate custom filters from entity filters\n const entityFilters: GetProductChartDataQueryInput['filters'] = [];\n let priceRangeFilter: string | undefined;\n\n if (extractedFilters && extractedFilters.length > 0) {\n for (const filter of extractedFilters) {\n if (filter.field === 'priceRange') {\n priceRangeFilter = filter.value;\n } else {\n entityFilters.push(filter);\n }\n }\n }\n\n // Get all products from storage with entity filters (no pagination for charts)\n const allProductsResult = await this.productService.query({\n skip: 0,\n take: 10000, // Get all products for aggregation\n filter:\n entityFilters.length > 0\n ? ({\n logic: input.logic || 'and',\n filters: entityFilters,\n } as any)\n : undefined,\n });\n\n let allProducts = allProductsResult.items;\n\n // Apply custom price range filter after fetching\n if (priceRangeFilter && priceRangeFilter !== 'all') {\n allProducts = this.applyPriceRangeFilter(allProducts, priceRangeFilter);\n }\n\n // Group products by brand\n const brandGroups = new Map<string, AXMProductCatalogProductEntityModel[]>();\n\n for (const product of allProducts) {\n const brandKey = product.brand?.title || product.brandId || 'Unknown';\n\n if (!brandGroups.has(brandKey)) {\n brandGroups.set(brandKey, []);\n }\n\n brandGroups.get(brandKey)!.push(product);\n }\n\n // Aggregate data by brand for chart\n const chartResults: ProductChartDataResult[] = [];\n\n for (const [brandName, products] of brandGroups.entries()) {\n chartResults.push({\n brand: brandName,\n productCount: products.length,\n });\n }\n\n return {\n items: chartResults,\n };\n }\n\n //#region ---- Filter Extraction ----\n\n /**\n * Extract product-specific filters from AXPFilterClause format\n * Maps report parameter paths to product entity field names\n */\n private extractProductFilters(parameters: any): GetProductChartDataQueryInput['filters'] {\n const filters: GetProductChartDataQueryInput['filters'] = [];\n const paramsAny = parameters as any;\n\n if (!paramsAny?.filters || !Array.isArray(paramsAny.filters)) {\n return filters;\n }\n\n for (const filter of paramsAny.filters) {\n if (!filter?.field || filter?.value === undefined || filter?.value === null) {\n continue;\n }\n\n const field = filter.field;\n const value = filter.value;\n const operator = filter.operator || { type: 'equal' };\n\n // Handle product-specific field mappings\n if (field === 'brand') {\n // Brand filter - can be array of IDs or single ID\n if (Array.isArray(value) && value.length > 0) {\n filters.push({\n field: 'brandId',\n operator: { type: 'in' },\n value: value,\n });\n } else if (value) {\n filters.push({\n field: 'brandId',\n operator: { type: 'equal' },\n value: value,\n });\n }\n } else if (field === 'category') {\n // Category filter - can be array of IDs or single ID\n if (Array.isArray(value) && value.length > 0) {\n filters.push({\n field: 'categoryIds',\n operator: { type: 'contains' },\n value: value[0], // Use first category for contains check\n });\n } else if (value) {\n filters.push({\n field: 'categoryIds',\n operator: { type: 'contains' },\n value: value,\n });\n }\n } else if (field === 'status') {\n // Status filter - skip 'all' value\n if (value && value !== 'all') {\n filters.push({\n field: 'statusId',\n operator: { type: 'equal' },\n value: value,\n });\n }\n } else if (field === 'priceRange') {\n // Price range filter - custom logic handled in query\n filters.push({\n field: 'priceRange',\n operator: { type: 'equal' },\n value: value,\n });\n } else if (field === 'startDate' || field === 'endDate') {\n // Date filters - can be handled if needed\n // For now, skip as they might not be directly on product entity\n } else {\n // Direct field mapping\n filters.push({\n field: field,\n operator: operator,\n value: value,\n });\n }\n }\n\n return filters;\n }\n\n //#endregion\n\n //#region ---- Custom Filter Handlers ----\n\n /**\n * Apply custom price range filter to products\n */\n private applyPriceRangeFilter(\n products: AXMProductCatalogProductEntityModel[],\n priceRange: string\n ): AXMProductCatalogProductEntityModel[] {\n return products.filter((product) => {\n const price = product.basePrice || 0;\n\n switch (priceRange) {\n case 'under-50':\n return price < 50;\n case '50-100':\n return price >= 50 && price < 100;\n case '100-500':\n return price >= 100 && price < 500;\n case '500-1000':\n return price >= 500 && price < 1000;\n case 'over-1000':\n return price >= 1000;\n default:\n return true;\n }\n });\n }\n\n //#endregion\n}\n\n"],"names":[],"mappings":";;;;;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,KAAK,UAAU;AACb,oBAAA,OAAO,KAAK,IAAI,GAAG,IAAI,KAAK,GAAG,IAAI;AACrC,gBAAA,KAAK,WAAW;oBACd,OAAO,KAAK,IAAI,IAAI;AACtB,gBAAA;AACE,oBAAA,OAAO,IAAI;;AAEjB,QAAA,CAAC,CAAC;IACJ;8GAzLW,wBAAwB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAAxB,IAAA,SAAA,IAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,wBAAwB,cAFvB,MAAM,EAAA,CAAA,CAAA;;2FAEP,wBAAwB,EAAA,UAAA,EAAA,CAAA;kBAHpC,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE,MAAM;AACnB,iBAAA;;;;;"}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
+
import { resolveMultiLanguageString } from '@acorex/platform/contracts';
|
|
2
|
+
import { RootConfig } from '@acorex/modules/product-catalog';
|
|
3
|
+
import { AXPEntityService } from '@acorex/platform/layout/entity';
|
|
1
4
|
import * as i0 from '@angular/core';
|
|
2
5
|
import { inject, Injectable } from '@angular/core';
|
|
3
|
-
import {
|
|
4
|
-
import { RootConfig } from '@acorex/modules/product-catalog';
|
|
6
|
+
import { c as computeReportFooterSummary } from './acorex-connectivity-mock-report-summary.util-CGOhHIZr.mjs';
|
|
5
7
|
|
|
6
8
|
//#endregion
|
|
7
9
|
class GetProductListQuery {
|
|
8
10
|
constructor() {
|
|
9
11
|
this.entityService = inject(AXPEntityService);
|
|
10
|
-
this.productService = this.entityService
|
|
12
|
+
this.productService = this.entityService
|
|
13
|
+
.withEntity(`${RootConfig.module.name}.${RootConfig.entities.product.name}`)
|
|
14
|
+
.data();
|
|
11
15
|
}
|
|
12
16
|
async fetch(input) {
|
|
13
17
|
// Extract product-specific filters from AXPFilterClause format
|
|
@@ -65,7 +69,7 @@ class GetProductListQuery {
|
|
|
65
69
|
if (product.categories && Array.isArray(product.categories)) {
|
|
66
70
|
for (const cat of product.categories) {
|
|
67
71
|
if (cat.title) {
|
|
68
|
-
categorySet.add(cat.title);
|
|
72
|
+
categorySet.add(resolveMultiLanguageString(cat.title, 'en-US'));
|
|
69
73
|
}
|
|
70
74
|
}
|
|
71
75
|
}
|
|
@@ -74,7 +78,11 @@ class GetProductListQuery {
|
|
|
74
78
|
// Get brand ID from first product
|
|
75
79
|
const brandId = products[0]?.brandId || products[0]?.brand?.id;
|
|
76
80
|
// Get manufacturer from first product (assuming all products in a brand have same manufacturer)
|
|
77
|
-
const manufacturerName = products[0]?.manufacturer?.title
|
|
81
|
+
const manufacturerName = (products[0]?.manufacturer?.title != null
|
|
82
|
+
? resolveMultiLanguageString(products[0].manufacturer.title, 'en-US')
|
|
83
|
+
: '') ||
|
|
84
|
+
products[0]?.manufacturerId ||
|
|
85
|
+
'Unknown';
|
|
78
86
|
const manufacturerId = products[0]?.manufacturerId || products[0]?.manufacturer?.id;
|
|
79
87
|
aggregatedResults.push({
|
|
80
88
|
brand: brandName,
|
|
@@ -93,11 +101,10 @@ class GetProductListQuery {
|
|
|
93
101
|
if (input.sort && input.sort.length > 0) {
|
|
94
102
|
aggregatedResults.sort((a, b) => {
|
|
95
103
|
for (const sortField of input.sort) {
|
|
96
|
-
const field = sortField.
|
|
104
|
+
const field = sortField.name;
|
|
97
105
|
const aValue = a[field];
|
|
98
106
|
const bValue = b[field];
|
|
99
107
|
const dir = sortField.dir === 'asc' ? 1 : -1;
|
|
100
|
-
// Handle undefined values
|
|
101
108
|
if (aValue === undefined && bValue === undefined)
|
|
102
109
|
continue;
|
|
103
110
|
if (aValue === undefined)
|
|
@@ -112,7 +119,7 @@ class GetProductListQuery {
|
|
|
112
119
|
return 0;
|
|
113
120
|
});
|
|
114
121
|
}
|
|
115
|
-
|
|
122
|
+
const summary = computeReportFooterSummary(aggregatedResults, input.summary);
|
|
116
123
|
const skip = input.skip || 0;
|
|
117
124
|
const take = input.take || 10;
|
|
118
125
|
const total = aggregatedResults.length;
|
|
@@ -120,6 +127,7 @@ class GetProductListQuery {
|
|
|
120
127
|
return {
|
|
121
128
|
items,
|
|
122
129
|
total,
|
|
130
|
+
summary,
|
|
123
131
|
};
|
|
124
132
|
}
|
|
125
133
|
//#region ---- Filter Extraction ----
|
|
@@ -232,10 +240,10 @@ class GetProductListQuery {
|
|
|
232
240
|
}
|
|
233
241
|
});
|
|
234
242
|
}
|
|
235
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
236
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
243
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: GetProductListQuery, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
244
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: GetProductListQuery, providedIn: 'root' }); }
|
|
237
245
|
}
|
|
238
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
246
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: GetProductListQuery, decorators: [{
|
|
239
247
|
type: Injectable,
|
|
240
248
|
args: [{
|
|
241
249
|
providedIn: 'root',
|
|
@@ -243,4 +251,4 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImpo
|
|
|
243
251
|
}] });
|
|
244
252
|
|
|
245
253
|
export { GetProductListQuery };
|
|
246
|
-
//# sourceMappingURL=acorex-connectivity-mock-get-product-list.query-
|
|
254
|
+
//# sourceMappingURL=acorex-connectivity-mock-get-product-list.query-o9TcY_RC.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acorex-connectivity-mock-get-product-list.query-o9TcY_RC.mjs","sources":["../../../../libs/connectivity/mock/src/lib/product-catalog/reports/get-product-list.query.ts"],"sourcesContent":["import { AXPQuery } from '@acorex/platform/runtime-contracts';\nimport { AXPQuerySort } from '@acorex/platform/layout/entity-contracts';\nimport { resolveMultiLanguageString } from '@acorex/platform/contracts';\n\nimport { AXPReportSummaryOptions } from '@acorex/modules/report-management';\nimport { AXMProductCatalogProductEntityModel, RootConfig } from '@acorex/modules/product-catalog';\n\nimport { AXPEntityService } from '@acorex/platform/layout/entity';\n\nimport { inject, Injectable } from '@angular/core';\nimport { computeReportFooterSummary } from '../../report-management/report-summary.util';\n\n//#region ---- Query Input/Output Types ----\n\nexport interface GetProductListQueryInput {\n skip?: number;\n take?: number;\n sort?: AXPQuerySort[];\n summary?: AXPReportSummaryOptions[];\n filters?: Array<{\n field: string;\n operator: { type: string };\n value: any;\n }>;\n logic?: 'and' | 'or';\n}\n\nexport interface ProductByBrandResult {\n brand: string;\n brandId?: string;\n manufacturer: string;\n manufacturerId?: string;\n productCount: number;\n totalValue: number;\n averagePrice: number;\n minPrice: number;\n maxPrice: number;\n categories: string;\n}\n\nexport interface GetProductListQueryResult {\n items: ProductByBrandResult[];\n total: number;\n summary?: Record<string, number | null>;\n}\n\n//#endregion\n\n@Injectable({\n providedIn: 'root',\n})\nexport class GetProductListQuery implements AXPQuery<GetProductListQueryInput, GetProductListQueryResult> {\n private readonly entityService = inject(AXPEntityService);\n private productService = this.entityService\n .withEntity(`${RootConfig.module.name}.${RootConfig.entities.product.name}`)\n .data<string, AXMProductCatalogProductEntityModel>();\n\n async fetch(input: GetProductListQueryInput | any): Promise<GetProductListQueryResult> {\n // Extract product-specific filters from AXPFilterClause format\n const extractedFilters = this.extractProductFilters(input.filters);\n\n // Separate custom filters from entity filters\n const entityFilters: GetProductListQueryInput['filters'] = [];\n let priceRangeFilter: string | undefined;\n\n if (extractedFilters && extractedFilters.length > 0) {\n for (const filter of extractedFilters) {\n if (filter.field === 'priceRange') {\n priceRangeFilter = filter.value;\n } else {\n entityFilters.push(filter);\n }\n }\n }\n\n // Get all products from storage with entity filters\n const allProductsResult = await this.productService.query({\n skip: 0,\n take: 10000, // Get all products for aggregation\n filter:\n entityFilters.length > 0\n ? ({\n logic: input.logic || 'and',\n filters: entityFilters,\n } as any)\n : undefined,\n });\n\n let allProducts = allProductsResult.items;\n\n // Apply custom price range filter after fetching\n if (priceRangeFilter && priceRangeFilter !== 'all') {\n allProducts = this.applyPriceRangeFilter(allProducts, priceRangeFilter);\n }\n\n // Group products by brand\n const brandGroups = new Map<string, AXMProductCatalogProductEntityModel[]>();\n\n for (const product of allProducts) {\n const brandKey = product.brand?.title || product.brandId || 'Unknown';\n\n if (!brandGroups.has(brandKey)) {\n brandGroups.set(brandKey, []);\n }\n\n brandGroups.get(brandKey)!.push(product);\n }\n\n // Aggregate data by brand\n const aggregatedResults: ProductByBrandResult[] = [];\n\n for (const [brandName, products] of brandGroups.entries()) {\n const prices = products.map((p) => p.basePrice || 0).filter((p) => p > 0);\n const totalValue = prices.reduce((sum, price) => sum + price, 0);\n const productCount = products.length;\n const averagePrice = productCount > 0 ? totalValue / productCount : 0;\n const minPrice = prices.length > 0 ? Math.min(...prices) : 0;\n const maxPrice = prices.length > 0 ? Math.max(...prices) : 0;\n\n // Get unique categories\n const categorySet = new Set<string>();\n for (const product of products) {\n if (product.categories && Array.isArray(product.categories)) {\n for (const cat of product.categories) {\n if (cat.title) {\n categorySet.add(resolveMultiLanguageString(cat.title, 'en-US'));\n }\n }\n }\n }\n const categories = Array.from(categorySet).join(', ');\n\n // Get brand ID from first product\n const brandId = products[0]?.brandId || products[0]?.brand?.id;\n\n // Get manufacturer from first product (assuming all products in a brand have same manufacturer)\n const manufacturerName =\n (products[0]?.manufacturer?.title != null\n ? resolveMultiLanguageString(products[0].manufacturer!.title, 'en-US')\n : '') ||\n products[0]?.manufacturerId ||\n 'Unknown';\n const manufacturerId = products[0]?.manufacturerId || products[0]?.manufacturer?.id;\n\n aggregatedResults.push({\n brand: brandName,\n brandId,\n manufacturer: manufacturerName,\n manufacturerId,\n productCount,\n totalValue: Number(totalValue.toFixed(2)),\n averagePrice: Number(averagePrice.toFixed(2)),\n minPrice: Number(minPrice.toFixed(2)),\n maxPrice: Number(maxPrice.toFixed(2)),\n categories,\n });\n }\n\n // Apply sorting if provided\n if (input.sort && input.sort.length > 0) {\n aggregatedResults.sort((a, b) => {\n for (const sortField of input.sort!) {\n const field = sortField.name as keyof ProductByBrandResult;\n const aValue = a[field];\n const bValue = b[field];\n const dir = sortField.dir === 'asc' ? 1 : -1;\n\n if (aValue === undefined && bValue === undefined) continue;\n if (aValue === undefined) return 1 * dir;\n if (bValue === undefined) return -1 * dir;\n\n if (aValue < bValue) return -1 * dir;\n if (aValue > bValue) return 1 * dir;\n }\n return 0;\n });\n }\n\n const summary = computeReportFooterSummary(\n aggregatedResults as unknown as Record<string, unknown>[],\n input.summary,\n );\n\n const skip = input.skip || 0;\n const take = input.take || 10;\n const total = aggregatedResults.length;\n const items = aggregatedResults.slice(skip, skip + take);\n\n return {\n items,\n total,\n summary,\n };\n }\n\n //#region ---- Filter Extraction ----\n\n /**\n * Extract product-specific filters from AXPFilterClause format\n * Maps report parameter paths to product entity field names\n */\n private extractProductFilters(parameters: any): GetProductListQueryInput['filters'] {\n const filters: GetProductListQueryInput['filters'] = [];\n const paramsAny = parameters as any;\n\n if (!paramsAny?.filters || !Array.isArray(paramsAny.filters)) {\n return filters;\n }\n\n for (const filter of paramsAny.filters) {\n if (!filter?.field || filter?.value === undefined || filter?.value === null) {\n continue;\n }\n\n const field = filter.field;\n const value = filter.value;\n const operator = filter.operator || { type: 'equal' };\n\n // Handle product-specific field mappings\n if (field === 'brand') {\n // Brand filter - can be array of IDs or single ID\n if (Array.isArray(value) && value.length > 0) {\n filters.push({\n field: 'brandId',\n operator: { type: 'in' },\n value: value,\n });\n } else if (value) {\n filters.push({\n field: 'brandId',\n operator: { type: 'equal' },\n value: value,\n });\n }\n } else if (field === 'category') {\n // Category filter - can be array of IDs or single ID\n if (Array.isArray(value) && value.length > 0) {\n filters.push({\n field: 'categoryIds',\n operator: { type: 'contains' },\n value: value[0], // Use first category for contains check\n });\n } else if (value) {\n filters.push({\n field: 'categoryIds',\n operator: { type: 'contains' },\n value: value,\n });\n }\n } else if (field === 'status') {\n // Status filter - skip 'all' value\n if (value && value !== 'all') {\n filters.push({\n field: 'statusId',\n operator: { type: 'equal' },\n value: value,\n });\n }\n } else if (field === 'priceRange') {\n // Price range filter - custom logic handled in query\n filters.push({\n field: 'priceRange',\n operator: { type: 'equal' },\n value: value,\n });\n } else if (field === 'startDate' || field === 'endDate') {\n // Date filters - can be handled if needed\n // For now, skip as they might not be directly on product entity\n } else {\n // Direct field mapping\n filters.push({\n field: field,\n operator: operator,\n value: value,\n });\n }\n }\n\n return filters;\n }\n\n //#endregion\n\n //#region ---- Custom Filter Handlers ----\n\n /**\n * Apply custom price range filter to products\n */\n private applyPriceRangeFilter(\n products: AXMProductCatalogProductEntityModel[],\n priceRange: string,\n ): AXMProductCatalogProductEntityModel[] {\n return products.filter((product) => {\n const price = product.basePrice || 0;\n\n switch (priceRange) {\n case 'under-50':\n return price < 50;\n case '50-100':\n return price >= 50 && price < 100;\n case '100-500':\n return price >= 100 && price < 500;\n case '500-1000':\n return price >= 500 && price < 1000;\n case 'over-1000':\n return price >= 1000;\n default:\n return true;\n }\n });\n }\n\n //#endregion\n}\n"],"names":[],"mappings":";;;;;;;AA8CA;MAKa,mBAAmB,CAAA;AAHhC,IAAA,WAAA,GAAA;AAImB,QAAA,IAAA,CAAA,aAAa,GAAG,MAAM,CAAC,gBAAgB,CAAC;QACjD,IAAA,CAAA,cAAc,GAAG,IAAI,CAAC;AAC3B,aAAA,UAAU,CAAC,CAAA,EAAG,UAAU,CAAC,MAAM,CAAC,IAAI,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1,6 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { inject, Injectable } from '@angular/core';
|
|
3
|
-
import { GetProductListQuery } from './acorex-connectivity-mock-get-product-list.query-
|
|
3
|
+
import { GetProductListQuery } from './acorex-connectivity-mock-get-product-list.query-o9TcY_RC.mjs';
|
|
4
4
|
|
|
5
5
|
//#endregion
|
|
6
6
|
class GetProductPdfDataQuery {
|
|
@@ -178,10 +178,10 @@ startxref
|
|
|
178
178
|
%%EOF`;
|
|
179
179
|
return pdf;
|
|
180
180
|
}
|
|
181
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
182
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
181
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: GetProductPdfDataQuery, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
182
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: GetProductPdfDataQuery, providedIn: 'root' }); }
|
|
183
183
|
}
|
|
184
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
184
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: GetProductPdfDataQuery, decorators: [{
|
|
185
185
|
type: Injectable,
|
|
186
186
|
args: [{
|
|
187
187
|
providedIn: 'root',
|
|
@@ -189,4 +189,4 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImpo
|
|
|
189
189
|
}] });
|
|
190
190
|
|
|
191
191
|
export { GetProductPdfDataQuery };
|
|
192
|
-
//# sourceMappingURL=acorex-connectivity-mock-get-product-pdf-data.query-
|
|
192
|
+
//# sourceMappingURL=acorex-connectivity-mock-get-product-pdf-data.query-DUZvwsmY.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acorex-connectivity-mock-get-product-pdf-data.query-DUZvwsmY.mjs","sources":["../../../../libs/connectivity/mock/src/lib/product-catalog/reports/get-product-pdf-data.query.ts"],"sourcesContent":["import { AXPQuery } from '@acorex/platform/runtime-contracts';\nimport { inject, Injectable } from '@angular/core';\n\nimport { GetProductListQueryInput, GetProductListQueryResult } from './get-product-list.query';\nimport { GetProductListQuery } from './get-product-list.query';\n\n//#region ---- Query Input/Output Types ----\n\nexport interface GetProductPdfDataQueryInput {\n filters?: Array<{\n field: string;\n operator: { type: string };\n value: any;\n }>;\n logic?: 'and' | 'or';\n}\n\nexport interface GetProductPdfDataQueryResult {\n url?: string;\n base64?: string;\n blob?: Blob;\n filename?: string;\n}\n\n//#endregion\n\n@Injectable({\n providedIn: 'root',\n})\nexport class GetProductPdfDataQuery implements AXPQuery<GetProductPdfDataQueryInput, GetProductPdfDataQueryResult> {\n private readonly productListQuery = inject(GetProductListQuery);\n\n async fetch(input: GetProductPdfDataQueryInput | any): Promise<GetProductPdfDataQueryResult> {\n // Extract product-specific filters from AXPFilterClause format\n const extractedFilters = this.extractProductFilters(input.filters);\n\n // Get the product list data to generate PDF content\n const productListInput: GetProductListQueryInput = {\n skip: 0,\n take: 10000, // Get all products for PDF\n filters: extractedFilters,\n logic: input.logic,\n };\n\n const productData = await this.productListQuery.fetch(productListInput);\n\n // Generate a mock PDF base64 string\n // In production, this would call an actual PDF generation service\n const pdfBase64 = this.generateMockPdfBase64(productData);\n\n return {\n base64: pdfBase64,\n filename: `Product_Report_${new Date().toISOString().split('T')[0]}.pdf`,\n };\n }\n\n //#region ---- Filter Extraction ----\n\n /**\n * Extract product-specific filters from AXPFilterClause format\n * Maps report parameter paths to product entity field names\n */\n private extractProductFilters(parameters: any): GetProductListQueryInput['filters'] {\n const filters: GetProductListQueryInput['filters'] = [];\n const paramsAny = parameters as any;\n\n if (!paramsAny?.filters || !Array.isArray(paramsAny.filters)) {\n return filters;\n }\n\n for (const filter of paramsAny.filters) {\n if (!filter?.field || filter?.value === undefined || filter?.value === null) {\n continue;\n }\n\n const field = filter.field;\n const value = filter.value;\n const operator = filter.operator || { type: 'equal' };\n\n // Handle product-specific field mappings\n if (field === 'brand') {\n // Brand filter - can be array of IDs or single ID\n if (Array.isArray(value) && value.length > 0) {\n filters.push({\n field: 'brandId',\n operator: { type: 'in' },\n value: value,\n });\n } else if (value) {\n filters.push({\n field: 'brandId',\n operator: { type: 'equal' },\n value: value,\n });\n }\n } else if (field === 'category') {\n // Category filter - can be array of IDs or single ID\n if (Array.isArray(value) && value.length > 0) {\n filters.push({\n field: 'categoryIds',\n operator: { type: 'contains' },\n value: value[0], // Use first category for contains check\n });\n } else if (value) {\n filters.push({\n field: 'categoryIds',\n operator: { type: 'contains' },\n value: value,\n });\n }\n } else if (field === 'status') {\n // Status filter - skip 'all' value\n if (value && value !== 'all') {\n filters.push({\n field: 'statusId',\n operator: { type: 'equal' },\n value: value,\n });\n }\n } else if (field === 'priceRange') {\n // Price range filter - custom logic handled in query\n filters.push({\n field: 'priceRange',\n operator: { type: 'equal' },\n value: value,\n });\n } else if (field === 'startDate' || field === 'endDate') {\n // Date filters - can be handled if needed\n // For now, skip as they might not be directly on product entity\n } else {\n // Direct field mapping\n filters.push({\n field: field,\n operator: operator,\n value: value,\n });\n }\n }\n\n return filters;\n }\n\n //#endregion\n\n //#region ---- PDF Generation Helpers ----\n\n /**\n * Generate a mock PDF base64 string\n * In production, this would call an actual PDF generation service\n */\n private generateMockPdfBase64(productData: GetProductListQueryResult): string {\n // Create a minimal valid PDF with some content\n // This is a very basic PDF structure for demonstration\n // In production, use a proper PDF library like jsPDF or call a backend service\n\n const pdfContent = this.createSimplePdf(productData);\n\n // Convert to base64\n const base64 = btoa(pdfContent);\n\n return base64;\n }\n\n /**\n * Create a simple PDF document structure\n * This is a minimal valid PDF for demonstration - in production use a proper PDF library\n */\n private createSimplePdf(productData: GetProductListQueryResult): string {\n // Use a minimal valid PDF structure that browsers can render\n // This is a very basic single-page PDF\n const pdf = `%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nendobj\n3 0 obj\n<< /Type /Page /Parent 2 0 R /MediaBox [0 0 612 792] /Contents 4 0 R /Resources << /Font << /F1 5 0 R >> >> >>\nendobj\n4 0 obj\n<< /Length 200 >>\nstream\nBT\n/F1 12 Tf\n100 700 Td\n(Product Report) Tj\n0 -20 Td\n(Total Brands: ${productData.total}) Tj\n0 -20 Td\n(Generated: ${new Date().toLocaleDateString()}) Tj\n0 -20 Td\n(Items: ${productData.items.length}) Tj\nET\nendstream\nendobj\n5 0 obj\n<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>\nendobj\nxref\n0 6\n0000000000 65535 f \n0000000009 00000 n \n0000000058 00000 n \n0000000115 00000 n \n0000000317 00000 n \n0000000444 00000 n \ntrailer\n<< /Size 6 /Root 1 0 R >>\nstartxref\n527\n%%EOF`;\n\n return pdf;\n }\n\n //#endregion\n}\n\n"],"names":[],"mappings":";;;;AAwBA;MAKa,sBAAsB,CAAA;AAHnC,IAAA,WAAA,GAAA;AAIqB,QAAA,IAAA,CAAA,gBAAgB,GAAG,MAAM,CAAC,mBAAmB,CAAC;AA2LlE,IAAA;IAzLG,MAAM,KAAK,CAAC,KAAwC,EAAA;;QAEhD,MAAM,gBAAgB,GAAG,IAAI,CAAC,qBAAqB,CAAC,KAAK,CAAC,OAAO,CAAC;;AAGlE,QAAA,MAAM,gBAAgB,GAA6B;AAC/C,YAAA,IAAI,EAAE,CAAC;YACP,IAAI,EAAE,KAAK;AACX,YAAA,OAAO,EAAE,gBAAgB;YACzB,KAAK,EAAE,KAAK,CAAC,KAAK;SACrB;QAED,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,gBAAgB,CAAC;;;QAIvE,MAAM,SAAS,GAAG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@@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { inject, Injectable } from '@angular/core';
|
|
3
|
-
import { GetSubscriptionsTimelineQuery } from './acorex-connectivity-mock-get-subscriptions-timeline.query-
|
|
3
|
+
import { GetSubscriptionsTimelineQuery } from './acorex-connectivity-mock-get-subscriptions-timeline.query-D_jVT-7a.mjs';
|
|
4
4
|
|
|
5
5
|
//#endregion
|
|
6
6
|
class GetSubscriptionsChartDataQuery {
|
|
@@ -42,10 +42,10 @@ class GetSubscriptionsChartDataQuery {
|
|
|
42
42
|
items: results,
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
46
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
45
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: GetSubscriptionsChartDataQuery, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
46
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: GetSubscriptionsChartDataQuery, providedIn: 'root' }); }
|
|
47
47
|
}
|
|
48
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
48
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: GetSubscriptionsChartDataQuery, decorators: [{
|
|
49
49
|
type: Injectable,
|
|
50
50
|
args: [{
|
|
51
51
|
providedIn: 'root',
|
|
@@ -53,4 +53,4 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImpo
|
|
|
53
53
|
}] });
|
|
54
54
|
|
|
55
55
|
export { GetSubscriptionsChartDataQuery };
|
|
56
|
-
//# sourceMappingURL=acorex-connectivity-mock-get-subscriptions-chart-data.query-
|
|
56
|
+
//# sourceMappingURL=acorex-connectivity-mock-get-subscriptions-chart-data.query-BXDzY2Sd.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acorex-connectivity-mock-get-subscriptions-chart-data.query-BXDzY2Sd.mjs","sources":["../../../../libs/connectivity/mock/src/lib/tenant-management/reports/get-subscriptions-chart-data.query.ts"],"sourcesContent":["import { AXPQuery } from '@acorex/platform/runtime-contracts';\nimport { inject, Injectable } from '@angular/core';\n\nimport { GetSubscriptionsTimelineQueryInput } from './get-subscriptions-timeline.query';\nimport { GetSubscriptionsTimelineQuery } from './get-subscriptions-timeline.query';\n\n//#region ---- Query Input/Output Types ----\n\nexport interface GetSubscriptionsChartDataQueryInput {\n filters?: Array<{\n field: string;\n operator: { type: string };\n value: any;\n }>;\n logic?: 'and' | 'or';\n}\n\nexport interface SubscriptionsChartDataResult {\n month: string;\n year: number;\n quarter: string;\n subscriptionCount: number;\n}\n\nexport interface GetSubscriptionsChartDataQueryResult {\n items: SubscriptionsChartDataResult[];\n}\n\n//#endregion\n\n@Injectable({\n providedIn: 'root',\n})\nexport class GetSubscriptionsChartDataQuery\n implements AXPQuery<GetSubscriptionsChartDataQueryInput, GetSubscriptionsChartDataQueryResult>\n{\n private readonly subscriptionsTimelineQuery = inject(GetSubscriptionsTimelineQuery);\n\n async fetch(input: GetSubscriptionsChartDataQueryInput | any): Promise<GetSubscriptionsChartDataQueryResult> {\n // Get all subscription timeline data (no pagination for charts)\n const timelineResult = await this.subscriptionsTimelineQuery.fetch({\n skip: 0,\n take: 10000,\n filters: input.filters,\n logic: input.logic,\n });\n\n // Group by month\n const monthGroups = new Map<string, SubscriptionsChartDataResult>();\n\n for (const item of timelineResult.items) {\n const monthKey = `${item.year}-${String(item.monthNumber).padStart(2, '0')}`;\n\n if (!monthGroups.has(monthKey)) {\n monthGroups.set(monthKey, {\n month: item.month,\n year: item.year,\n quarter: item.quarter,\n subscriptionCount: 0,\n });\n }\n\n const group = monthGroups.get(monthKey)!;\n group.subscriptionCount++;\n }\n\n // Convert to array and sort by date\n const results = Array.from(monthGroups.values()).sort((a, b) => {\n if (a.year !== b.year) return a.year - b.year;\n const monthA = new Date(`${a.month} 1, ${a.year}`).getMonth();\n const monthB = new Date(`${b.month} 1, ${b.year}`).getMonth();\n return monthA - monthB;\n });\n\n return {\n items: results,\n };\n }\n}\n\n"],"names":[],"mappings":";;;;AA4BA;MAKa,8BAA8B,CAAA;AAH3C,IAAA,WAAA,GAAA;AAMmB,QAAA,IAAA,CAAA,0BAA0B,GAAG,MAAM,CAAC,6BAA6B,CAAC;AA0CpF,IAAA;IAxCC,MAAM,KAAK,CAAC,KAAgD,EAAA;;QAE1D,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,0BAA0B,CAAC,KAAK,CAAC;AACjE,YAAA,IAAI,EAAE,CAAC;AACP,YAAA,IAAI,EAAE,KAAK;YACX,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,KAAK,EAAE,KAAK,CAAC,KAAK;AACnB,SAAA,CAAC;;AAGF,QAAA,MAAM,WAAW,GAAG,IAAI,GAAG,EAAwC;AAEnE,QAAA,KAAK,MAAM,IAAI,IAAI,cAAc,CAAC,KAAK,EAAE;YACvC,MAAM,QAAQ,GAAG,CAAA,EAAG,IAAI,CAAC,IAAI,CAAA,CAAA,EAAI,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA,CAAE;YAE5E,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;AAC9B,gBAAA,WAAW,CAAC,GAAG,CAAC,QAAQ,EAAE;oBACxB,KAAK,EAAE,IAAI,CAAC,KAAK;oBACjB,IAAI,EAAE,IAAI,CAAC,IAAI;oBACf,OAAO,EAAE,IAAI,CAAC,OAAO;AACrB,oBAAA,iBAAiB,EAAE,CAAC;AACrB,iBAAA,CAAC;YACJ;YAEA,MAAM,KAAK,GAAG,W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ystemStatusType } from '@acorex/platform/contracts';
|
|
1
2
|
import * as i0 from '@angular/core';
|
|
2
3
|
import { inject, Injectable } from '@angular/core';
|
|
3
4
|
import { AXPEntityService } from '@acorex/platform/layout/entity';
|
|
4
|
-
import { AXPSystemStatusType } from '@acorex/platform/common';
|
|
5
5
|
import { RootConfig } from '@acorex/modules/subscription-management';
|
|
6
6
|
import { RootConfig as RootConfig$1 } from '@acorex/modules/tenant-management';
|
|
7
7
|
|
|
@@ -102,7 +102,7 @@ class GetSubscriptionsTimelineQuery {
|
|
|
102
102
|
if (input.sort && input.sort.length > 0) {
|
|
103
103
|
results.sort((a, b) => {
|
|
104
104
|
for (const sortField of input.sort) {
|
|
105
|
-
const field = sortField.
|
|
105
|
+
const field = sortField.name;
|
|
106
106
|
const aValue = a[field];
|
|
107
107
|
const bValue = b[field];
|
|
108
108
|
const dir = sortField.dir === 'asc' ? 1 : -1;
|
|
@@ -232,10 +232,10 @@ class GetSubscriptionsTimelineQuery {
|
|
|
232
232
|
(subStartDate <= startDate && (!subEndDate || subEndDate >= endDate)));
|
|
233
233
|
});
|
|
234
234
|
}
|
|
235
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
236
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
235
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: GetSubscriptionsTimelineQuery, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
236
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: GetSubscriptionsTimelineQuery, providedIn: 'root' }); }
|
|
237
237
|
}
|
|
238
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
238
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: GetSubscriptionsTimelineQuery, decorators: [{
|
|
239
239
|
type: Injectable,
|
|
240
240
|
args: [{
|
|
241
241
|
providedIn: 'root',
|
|
@@ -243,4 +243,4 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImpo
|
|
|
243
243
|
}] });
|
|
244
244
|
|
|
245
245
|
export { GetSubscriptionsTimelineQuery };
|
|
246
|
-
//# sourceMappingURL=acorex-connectivity-mock-get-subscriptions-timeline.query-
|
|
246
|
+
//# sourceMappingURL=acorex-connectivity-mock-get-subscriptions-timeline.query-D_jVT-7a.mjs.map
|