@acorex/connectivity 21.0.0-next.5 → 21.0.0-next.51
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-SGNBLcOi.mjs → acorex-connectivity-api-execute.command-CiBl7z_H.mjs} +6 -6
- package/fesm2022/acorex-connectivity-api-execute.command-CiBl7z_H.mjs.map +1 -0
- package/fesm2022/acorex-connectivity-api.mjs +190 -188
- package/fesm2022/acorex-connectivity-api.mjs.map +1 -1
- package/fesm2022/acorex-connectivity-mock-acorex-connectivity-mock-D2T8rLl4.mjs +78673 -0
- package/fesm2022/acorex-connectivity-mock-acorex-connectivity-mock-D2T8rLl4.mjs.map +1 -0
- package/fesm2022/acorex-connectivity-mock-assign-to-manager.activity-DcsMxP4h.mjs +288 -0
- package/fesm2022/acorex-connectivity-mock-assign-to-manager.activity-DcsMxP4h.mjs.map +1 -0
- package/fesm2022/acorex-connectivity-mock-category-metadata-inheritance.query-CWRL1dTa.mjs +198 -0
- package/fesm2022/acorex-connectivity-mock-category-metadata-inheritance.query-CWRL1dTa.mjs.map +1 -0
- package/fesm2022/{acorex-connectivity-mock-category-with-items.query-Dsxj98tX.mjs → acorex-connectivity-mock-category-with-items.query-Cj6FWu7S.mjs} +4 -4
- package/fesm2022/acorex-connectivity-mock-category-with-items.query-Cj6FWu7S.mjs.map +1 -0
- package/fesm2022/acorex-connectivity-mock-chat-generate-image.command-ihYQR4Wt.mjs +108 -0
- package/fesm2022/acorex-connectivity-mock-chat-generate-image.command-ihYQR4Wt.mjs.map +1 -0
- package/fesm2022/acorex-connectivity-mock-chat-synthesize-speech.command-HWKR08gj.mjs +130 -0
- package/fesm2022/acorex-connectivity-mock-chat-synthesize-speech.command-HWKR08gj.mjs.map +1 -0
- package/fesm2022/acorex-connectivity-mock-chat-transcribe-speech.command-BrFX59uP.mjs +110 -0
- package/fesm2022/acorex-connectivity-mock-chat-transcribe-speech.command-BrFX59uP.mjs.map +1 -0
- package/fesm2022/acorex-connectivity-mock-check-permission.activity-vr3OHtjC.mjs +45 -0
- package/fesm2022/acorex-connectivity-mock-check-permission.activity-vr3OHtjC.mjs.map +1 -0
- package/fesm2022/acorex-connectivity-mock-complete-signature-process.activity-BO-IFsHT.mjs +56 -0
- package/fesm2022/acorex-connectivity-mock-complete-signature-process.activity-BO-IFsHT.mjs.map +1 -0
- package/fesm2022/acorex-connectivity-mock-contact-core.module-5TLCGWOR.mjs +968 -0
- package/fesm2022/acorex-connectivity-mock-contact-core.module-5TLCGWOR.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-DRiDwlqN.mjs → acorex-connectivity-mock-distribution-record.activity-DuNluOzA.mjs} +18 -6
- package/fesm2022/acorex-connectivity-mock-distribution-record.activity-DuNluOzA.mjs.map +1 -0
- package/fesm2022/acorex-connectivity-mock-entity-create.activity-Ca19tIj4.mjs +60 -0
- package/fesm2022/acorex-connectivity-mock-entity-create.activity-Ca19tIj4.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-C3eQfF0A.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-CLzDz9ob.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-DifHwuqH.mjs +213 -0
- package/fesm2022/acorex-connectivity-mock-get-employee-list.query-DifHwuqH.mjs.map +1 -0
- package/fesm2022/acorex-connectivity-mock-get-location-list.query-bMjkZnzq.mjs +209 -0
- package/fesm2022/acorex-connectivity-mock-get-location-list.query-bMjkZnzq.mjs.map +1 -0
- package/fesm2022/acorex-connectivity-mock-get-product-chart-data.query-D7DBzLT-.mjs +186 -0
- package/fesm2022/acorex-connectivity-mock-get-product-chart-data.query-D7DBzLT-.mjs.map +1 -0
- package/fesm2022/{acorex-connectivity-mock-get-product-list.query-ChtYlSTt.mjs → acorex-connectivity-mock-get-product-list.query-f-mTj4ah.mjs} +107 -11
- package/fesm2022/acorex-connectivity-mock-get-product-list.query-f-mTj4ah.mjs.map +1 -0
- package/fesm2022/acorex-connectivity-mock-get-product-pdf-data.query-Co1V52c4.mjs +192 -0
- package/fesm2022/acorex-connectivity-mock-get-product-pdf-data.query-Co1V52c4.mjs.map +1 -0
- package/fesm2022/{acorex-connectivity-mock-get-subscriptions-chart-data.query-HxX_bCT8.mjs → acorex-connectivity-mock-get-subscriptions-chart-data.query-BQT5a_hn.mjs} +5 -5
- package/fesm2022/acorex-connectivity-mock-get-subscriptions-chart-data.query-BQT5a_hn.mjs.map +1 -0
- package/fesm2022/{acorex-connectivity-mock-get-subscriptions-timeline.query-dp08JqLP.mjs → acorex-connectivity-mock-get-subscriptions-timeline.query-D4qfDfeV.mjs} +91 -13
- package/fesm2022/acorex-connectivity-mock-get-subscriptions-timeline.query-D4qfDfeV.mjs.map +1 -0
- package/fesm2022/{acorex-connectivity-mock-get-tenant-application-access.query-IATTXcAV.mjs → acorex-connectivity-mock-get-tenant-application-access.query-n1_Azada.mjs} +91 -13
- package/fesm2022/acorex-connectivity-mock-get-tenant-application-access.query-n1_Azada.mjs.map +1 -0
- package/fesm2022/{acorex-connectivity-mock-get-tenant-registration-chart-data.query-DlXi4Rcg.mjs → acorex-connectivity-mock-get-tenant-registration-chart-data.query-Cg4ykZU2.mjs} +5 -5
- package/fesm2022/acorex-connectivity-mock-get-tenant-registration-chart-data.query-Cg4ykZU2.mjs.map +1 -0
- package/fesm2022/{acorex-connectivity-mock-get-tenant-registration-timeline.query-hskw8Ioa.mjs → acorex-connectivity-mock-get-tenant-registration-timeline.query-0sCBtdbp.mjs} +91 -13
- package/fesm2022/acorex-connectivity-mock-get-tenant-registration-timeline.query-0sCBtdbp.mjs.map +1 -0
- package/fesm2022/{acorex-connectivity-mock-get-tenant-user-distribution.query-Bs5U5tze.mjs → acorex-connectivity-mock-get-tenant-user-distribution.query-rD811gtM.mjs} +91 -13
- package/fesm2022/acorex-connectivity-mock-get-tenant-user-distribution.query-rD811gtM.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-notification-management-email-send.command-DAQfIWoD.mjs +73 -0
- package/fesm2022/acorex-connectivity-mock-notification-management-email-send.command-DAQfIWoD.mjs.map +1 -0
- package/fesm2022/acorex-connectivity-mock-notify-signers.activity-Dg0sKGip.mjs +49 -0
- package/fesm2022/acorex-connectivity-mock-notify-signers.activity-Dg0sKGip.mjs.map +1 -0
- package/fesm2022/acorex-connectivity-mock-request-signature.activity-CoRT_H2u.mjs +60 -0
- package/fesm2022/acorex-connectivity-mock-request-signature.activity-CoRT_H2u.mjs.map +1 -0
- package/fesm2022/{acorex-connectivity-mock-sample.command-CkH5bmEs.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-Ch--rL7K.mjs +30 -0
- package/fesm2022/acorex-connectivity-mock-user-roles-for-list-column.query-Ch--rL7K.mjs.map +1 -0
- package/fesm2022/acorex-connectivity-mock-validate-all-signatures.activity-JuHjNFFS.mjs +61 -0
- package/fesm2022/acorex-connectivity-mock-validate-all-signatures.activity-JuHjNFFS.mjs.map +1 -0
- package/fesm2022/acorex-connectivity-mock.mjs +2 -49588
- 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} +13 -60
- package/types/acorex-connectivity-mock.d.ts +4133 -0
- package/fesm2022/acorex-connectivity-api-execute.command-SGNBLcOi.mjs.map +0 -1
- package/fesm2022/acorex-connectivity-mock-category-with-items.query-Dsxj98tX.mjs.map +0 -1
- package/fesm2022/acorex-connectivity-mock-distribution-record.command-DRiDwlqN.mjs.map +0 -1
- package/fesm2022/acorex-connectivity-mock-get-application-versions-chart-data.query-C3eQfF0A.mjs.map +0 -1
- package/fesm2022/acorex-connectivity-mock-get-application-versions-timeline.query-CLzDz9ob.mjs.map +0 -1
- package/fesm2022/acorex-connectivity-mock-get-product-chart-data.query-DDVVFeYN.mjs +0 -97
- package/fesm2022/acorex-connectivity-mock-get-product-chart-data.query-DDVVFeYN.mjs.map +0 -1
- package/fesm2022/acorex-connectivity-mock-get-product-list.query-ChtYlSTt.mjs.map +0 -1
- package/fesm2022/acorex-connectivity-mock-get-subscriptions-chart-data.query-HxX_bCT8.mjs.map +0 -1
- package/fesm2022/acorex-connectivity-mock-get-subscriptions-timeline.query-dp08JqLP.mjs.map +0 -1
- package/fesm2022/acorex-connectivity-mock-get-tenant-application-access.query-IATTXcAV.mjs.map +0 -1
- package/fesm2022/acorex-connectivity-mock-get-tenant-registration-chart-data.query-DlXi4Rcg.mjs.map +0 -1
- package/fesm2022/acorex-connectivity-mock-get-tenant-registration-timeline.query-hskw8Ioa.mjs.map +0 -1
- package/fesm2022/acorex-connectivity-mock-get-tenant-user-distribution.query-Bs5U5tze.mjs.map +0 -1
- package/fesm2022/acorex-connectivity-mock-sample.command-CkH5bmEs.mjs.map +0 -1
- package/mock/index.d.ts +0 -2557
- /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,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 { inject, Injectable } from '@angular/core';\nimport { AXPExecuteCommandResult } from '@acorex/platform/core';\nimport { AXPCommand } from '@acorex/platform/runtime';\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":";;;;;AAMA,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;;;;;"}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { inject, Injectable } from '@angular/core';
|
|
3
|
+
import { AXPEntityService } from '@acorex/platform/layout/entity';
|
|
4
|
+
import { RootConfig } from '@acorex/modules/human-capital-management';
|
|
5
|
+
|
|
6
|
+
//#endregion
|
|
7
|
+
class GetEmployeeListQuery {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.entityService = inject(AXPEntityService);
|
|
10
|
+
this.employeeService = this.entityService
|
|
11
|
+
.withEntity(`${RootConfig.module.name}.${RootConfig.entities.employee.name}`)
|
|
12
|
+
.data();
|
|
13
|
+
}
|
|
14
|
+
async fetch(input) {
|
|
15
|
+
// Extract employee-specific filters from AXPFilterClause format
|
|
16
|
+
const extractedFilters = this.extractEmployeeFilters(input.filters);
|
|
17
|
+
// Separate custom filters from entity filters
|
|
18
|
+
const entityFilters = [];
|
|
19
|
+
if (extractedFilters && extractedFilters.length > 0) {
|
|
20
|
+
for (const filter of extractedFilters) {
|
|
21
|
+
entityFilters.push(filter);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
// Get all employees from storage with entity filters
|
|
25
|
+
const allEmployeesResult = await this.employeeService.query({
|
|
26
|
+
skip: 0,
|
|
27
|
+
take: 10000, // Get all employees for aggregation
|
|
28
|
+
filter: entityFilters.length > 0
|
|
29
|
+
? {
|
|
30
|
+
logic: input.logic || 'and',
|
|
31
|
+
filters: entityFilters,
|
|
32
|
+
}
|
|
33
|
+
: undefined,
|
|
34
|
+
});
|
|
35
|
+
const allEmployees = allEmployeesResult.items;
|
|
36
|
+
// Group employees by department and team
|
|
37
|
+
const departmentGroups = new Map();
|
|
38
|
+
for (const employee of allEmployees) {
|
|
39
|
+
// Get department from position (assuming position has departmentId)
|
|
40
|
+
const departmentId = employee.position?.departmentId || employee.departmentId || 'unknown';
|
|
41
|
+
const departmentTitle = employee.position?.department?.title || 'Unknown Department';
|
|
42
|
+
// Get team from team memberships (assuming employee has teamId or teamMemberships)
|
|
43
|
+
const teamId = employee.teamId || employee.teamMemberships?.[0]?.teamId || undefined;
|
|
44
|
+
const teamTitle = employee.team?.title || employee.teamMemberships?.[0]?.team?.title || undefined;
|
|
45
|
+
const teamKey = teamId || 'no-team';
|
|
46
|
+
if (!departmentGroups.has(departmentId)) {
|
|
47
|
+
departmentGroups.set(departmentId, new Map());
|
|
48
|
+
}
|
|
49
|
+
const teamMap = departmentGroups.get(departmentId);
|
|
50
|
+
if (!teamMap.has(teamKey)) {
|
|
51
|
+
teamMap.set(teamKey, []);
|
|
52
|
+
}
|
|
53
|
+
teamMap.get(teamKey).push(employee);
|
|
54
|
+
}
|
|
55
|
+
// Aggregate data by department and team
|
|
56
|
+
const aggregatedResults = [];
|
|
57
|
+
for (const [departmentId, teamMap] of departmentGroups.entries()) {
|
|
58
|
+
const firstEmployee = Array.from(teamMap.values())[0]?.[0];
|
|
59
|
+
const departmentTitle = firstEmployee?.position?.department?.title || 'Unknown Department';
|
|
60
|
+
for (const [teamKey, employees] of teamMap.entries()) {
|
|
61
|
+
const teamId = teamKey !== 'no-team' ? teamKey : undefined;
|
|
62
|
+
const teamTitle = teamKey !== 'no-team' ? employees[0]?.team?.title || employees[0]?.teamMemberships?.[0]?.team?.title : undefined;
|
|
63
|
+
// Calculate average experience (years since hire date)
|
|
64
|
+
const now = new Date();
|
|
65
|
+
const experiences = employees
|
|
66
|
+
.map((emp) => {
|
|
67
|
+
if (!emp.hireDate)
|
|
68
|
+
return 0;
|
|
69
|
+
const hireDate = new Date(emp.hireDate);
|
|
70
|
+
const diffTime = Math.abs(now.getTime() - hireDate.getTime());
|
|
71
|
+
return diffTime / (1000 * 60 * 60 * 24 * 365.25); // Convert to years
|
|
72
|
+
})
|
|
73
|
+
.filter((exp) => exp > 0);
|
|
74
|
+
const averageExperience = experiences.length > 0 ? experiences.reduce((sum, exp) => sum + exp, 0) / experiences.length : 0;
|
|
75
|
+
// Get unique employment types
|
|
76
|
+
const employmentTypeSet = new Set();
|
|
77
|
+
for (const employee of employees) {
|
|
78
|
+
if (employee.employmentType?.title) {
|
|
79
|
+
employmentTypeSet.add(employee.employmentType.title);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const employmentTypes = Array.from(employmentTypeSet).join(', ') || 'N/A';
|
|
83
|
+
aggregatedResults.push({
|
|
84
|
+
departmentId,
|
|
85
|
+
departmentTitle,
|
|
86
|
+
teamId,
|
|
87
|
+
teamTitle,
|
|
88
|
+
employeeCount: employees.length,
|
|
89
|
+
employmentTypes,
|
|
90
|
+
averageExperience: Number(averageExperience.toFixed(2)),
|
|
91
|
+
totalEmployees: employees.length,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
// Apply sorting if provided
|
|
96
|
+
if (input.sort && input.sort.length > 0) {
|
|
97
|
+
aggregatedResults.sort((a, b) => {
|
|
98
|
+
for (const sortField of input.sort) {
|
|
99
|
+
const field = sortField.field;
|
|
100
|
+
const aValue = a[field];
|
|
101
|
+
const bValue = b[field];
|
|
102
|
+
const dir = sortField.dir === 'asc' ? 1 : -1;
|
|
103
|
+
// Handle undefined values
|
|
104
|
+
if (aValue === undefined && bValue === undefined)
|
|
105
|
+
continue;
|
|
106
|
+
if (aValue === undefined)
|
|
107
|
+
return 1 * dir;
|
|
108
|
+
if (bValue === undefined)
|
|
109
|
+
return -1 * dir;
|
|
110
|
+
if (aValue < bValue)
|
|
111
|
+
return -1 * dir;
|
|
112
|
+
if (aValue > bValue)
|
|
113
|
+
return 1 * dir;
|
|
114
|
+
}
|
|
115
|
+
return 0;
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
// Apply pagination
|
|
119
|
+
const skip = input.skip || 0;
|
|
120
|
+
const take = input.take || 10;
|
|
121
|
+
const total = aggregatedResults.length;
|
|
122
|
+
const items = aggregatedResults.slice(skip, skip + take);
|
|
123
|
+
return {
|
|
124
|
+
items,
|
|
125
|
+
total,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
//#region ---- Filter Extraction ----
|
|
129
|
+
/**
|
|
130
|
+
* Extract employee-specific filters from AXPFilterClause format
|
|
131
|
+
* Maps report parameter paths to employee entity field names
|
|
132
|
+
*/
|
|
133
|
+
extractEmployeeFilters(parameters) {
|
|
134
|
+
const filters = [];
|
|
135
|
+
const paramsAny = parameters;
|
|
136
|
+
if (!paramsAny?.filters || !Array.isArray(paramsAny.filters)) {
|
|
137
|
+
return filters;
|
|
138
|
+
}
|
|
139
|
+
for (const filter of paramsAny.filters) {
|
|
140
|
+
if (!filter?.field || filter?.value === undefined || filter?.value === null) {
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
const field = filter.field;
|
|
144
|
+
const value = filter.value;
|
|
145
|
+
const operator = filter.operator || { type: 'equal' };
|
|
146
|
+
// Handle employee-specific field mappings
|
|
147
|
+
if (field === 'department') {
|
|
148
|
+
// Department filter - can be array of IDs or single ID
|
|
149
|
+
if (Array.isArray(value) && value.length > 0) {
|
|
150
|
+
filters.push({
|
|
151
|
+
field: 'position.departmentId', // Assuming position has departmentId
|
|
152
|
+
operator: { type: 'in' },
|
|
153
|
+
value: value,
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
else if (value) {
|
|
157
|
+
filters.push({
|
|
158
|
+
field: 'position.departmentId',
|
|
159
|
+
operator: { type: 'equal' },
|
|
160
|
+
value: value,
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
else if (field === 'team') {
|
|
165
|
+
// Team filter - can be array of IDs or single ID
|
|
166
|
+
if (Array.isArray(value) && value.length > 0) {
|
|
167
|
+
filters.push({
|
|
168
|
+
field: 'teamId', // Assuming employee has teamId or teamMemberships
|
|
169
|
+
operator: { type: 'in' },
|
|
170
|
+
value: value,
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
else if (value) {
|
|
174
|
+
filters.push({
|
|
175
|
+
field: 'teamId',
|
|
176
|
+
operator: { type: 'equal' },
|
|
177
|
+
value: value,
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
else if (field === 'employmentType') {
|
|
182
|
+
// Employment type filter - skip 'all' value
|
|
183
|
+
if (value && value !== 'all') {
|
|
184
|
+
filters.push({
|
|
185
|
+
field: 'employmentTypeId',
|
|
186
|
+
operator: { type: 'equal' },
|
|
187
|
+
value: value,
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
// Direct field mapping
|
|
193
|
+
filters.push({
|
|
194
|
+
field: field,
|
|
195
|
+
operator: operator,
|
|
196
|
+
value: value,
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
return filters;
|
|
201
|
+
}
|
|
202
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: GetEmployeeListQuery, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
203
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: GetEmployeeListQuery, providedIn: 'root' }); }
|
|
204
|
+
}
|
|
205
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: GetEmployeeListQuery, decorators: [{
|
|
206
|
+
type: Injectable,
|
|
207
|
+
args: [{
|
|
208
|
+
providedIn: 'root',
|
|
209
|
+
}]
|
|
210
|
+
}] });
|
|
211
|
+
|
|
212
|
+
export { GetEmployeeListQuery };
|
|
213
|
+
//# sourceMappingURL=acorex-connectivity-mock-get-employee-list.query-DifHwuqH.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acorex-connectivity-mock-get-employee-list.query-DifHwuqH.mjs","sources":["../../../../libs/connectivity/mock/src/lib/report-management/samples/get-employee-list.query.ts"],"sourcesContent":["import { inject, Injectable } from '@angular/core';\nimport { AXPQuery } from '@acorex/platform/runtime';\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';\nimport { RootConfig as OrganizationRootConfig } from '@acorex/modules/organization-management';\n\n//#region ---- Query Input/Output Types ----\n\nexport interface GetEmployeeListQueryInput {\n skip?: number;\n take?: number;\n sort?: Array<{ field: string; dir: 'asc' | 'desc' }>;\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}\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.field as keyof EmployeeByDepartmentResult;\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 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":";;;;;AAqCA;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;AAqNhE,IAAA;IAnNC,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,Y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BAAA,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;8GAtNW,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;;;;;"}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { inject, Injectable } from '@angular/core';
|
|
3
|
+
import { AXPEntityService } from '@acorex/platform/layout/entity';
|
|
4
|
+
import { RootConfig } from '@acorex/modules/location-management';
|
|
5
|
+
|
|
6
|
+
//#endregion
|
|
7
|
+
class GetLocationListQuery {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.entityService = inject(AXPEntityService);
|
|
10
|
+
this.locationService = this.entityService
|
|
11
|
+
.withEntity(`${RootConfig.module.name}.${RootConfig.entities.location.name}`)
|
|
12
|
+
.data();
|
|
13
|
+
}
|
|
14
|
+
async fetch(input) {
|
|
15
|
+
// Extract location-specific filters from AXPFilterClause format
|
|
16
|
+
const extractedFilters = this.extractLocationFilters(input.filters);
|
|
17
|
+
// Separate custom filters from entity filters
|
|
18
|
+
const entityFilters = [];
|
|
19
|
+
if (extractedFilters && extractedFilters.length > 0) {
|
|
20
|
+
for (const filter of extractedFilters) {
|
|
21
|
+
entityFilters.push(filter);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
// Get all locations from storage with entity filters
|
|
25
|
+
const allLocationsResult = await this.locationService.query({
|
|
26
|
+
skip: 0,
|
|
27
|
+
take: 10000, // Get all locations for aggregation
|
|
28
|
+
filter: entityFilters.length > 0
|
|
29
|
+
? {
|
|
30
|
+
logic: input.logic || 'and',
|
|
31
|
+
filters: entityFilters,
|
|
32
|
+
}
|
|
33
|
+
: undefined,
|
|
34
|
+
});
|
|
35
|
+
const allLocations = allLocationsResult.items;
|
|
36
|
+
// Group locations by country, province, and city
|
|
37
|
+
const locationGroups = new Map();
|
|
38
|
+
for (const location of allLocations) {
|
|
39
|
+
// Get geographic information
|
|
40
|
+
const countryId = location.countryId || 'unknown';
|
|
41
|
+
const countryTitle = location.country?.title || 'Unknown Country';
|
|
42
|
+
const provinceId = location.stateId || 'unknown';
|
|
43
|
+
const provinceTitle = location.state?.title || 'Unknown Province';
|
|
44
|
+
const cityId = location.cityId || 'unknown';
|
|
45
|
+
const cityTitle = location.city?.title || 'Unknown City';
|
|
46
|
+
// Create nested map structure: country -> province -> city -> locations[]
|
|
47
|
+
if (!locationGroups.has(countryId)) {
|
|
48
|
+
locationGroups.set(countryId, new Map());
|
|
49
|
+
}
|
|
50
|
+
const provinceMap = locationGroups.get(countryId);
|
|
51
|
+
if (!provinceMap.has(provinceId)) {
|
|
52
|
+
provinceMap.set(provinceId, new Map());
|
|
53
|
+
}
|
|
54
|
+
const cityMap = provinceMap.get(provinceId);
|
|
55
|
+
if (!cityMap.has(cityId)) {
|
|
56
|
+
cityMap.set(cityId, []);
|
|
57
|
+
}
|
|
58
|
+
cityMap.get(cityId).push(location);
|
|
59
|
+
}
|
|
60
|
+
// Aggregate data by country, province, and city
|
|
61
|
+
const aggregatedResults = [];
|
|
62
|
+
for (const [countryId, provinceMap] of locationGroups.entries()) {
|
|
63
|
+
const firstLocation = Array.from(provinceMap.values())[0]?.values().next().value?.[0];
|
|
64
|
+
const countryTitle = firstLocation?.country?.title || 'Unknown Country';
|
|
65
|
+
for (const [provinceId, cityMap] of provinceMap.entries()) {
|
|
66
|
+
const firstLocationInProvince = cityMap.values().next().value?.[0];
|
|
67
|
+
const provinceTitle = firstLocationInProvince?.state?.title || 'Unknown Province';
|
|
68
|
+
for (const [cityId, locations] of cityMap.entries()) {
|
|
69
|
+
const cityTitle = locations[0]?.city?.title || 'Unknown City';
|
|
70
|
+
aggregatedResults.push({
|
|
71
|
+
countryId,
|
|
72
|
+
countryTitle,
|
|
73
|
+
provinceId,
|
|
74
|
+
provinceTitle,
|
|
75
|
+
cityId,
|
|
76
|
+
cityTitle,
|
|
77
|
+
locationCount: locations.length,
|
|
78
|
+
totalLocations: locations.length,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
// Apply sorting if provided
|
|
84
|
+
if (input.sort && input.sort.length > 0) {
|
|
85
|
+
aggregatedResults.sort((a, b) => {
|
|
86
|
+
for (const sortField of input.sort) {
|
|
87
|
+
const field = sortField.field;
|
|
88
|
+
const aValue = a[field];
|
|
89
|
+
const bValue = b[field];
|
|
90
|
+
const dir = sortField.dir === 'asc' ? 1 : -1;
|
|
91
|
+
// Handle undefined values
|
|
92
|
+
if (aValue === undefined && bValue === undefined)
|
|
93
|
+
continue;
|
|
94
|
+
if (aValue === undefined)
|
|
95
|
+
return 1 * dir;
|
|
96
|
+
if (bValue === undefined)
|
|
97
|
+
return -1 * dir;
|
|
98
|
+
if (aValue < bValue)
|
|
99
|
+
return -1 * dir;
|
|
100
|
+
if (aValue > bValue)
|
|
101
|
+
return 1 * dir;
|
|
102
|
+
}
|
|
103
|
+
return 0;
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
// Apply pagination
|
|
107
|
+
const skip = input.skip || 0;
|
|
108
|
+
const take = input.take || 10;
|
|
109
|
+
const total = aggregatedResults.length;
|
|
110
|
+
const items = aggregatedResults.slice(skip, skip + take);
|
|
111
|
+
return {
|
|
112
|
+
items,
|
|
113
|
+
total,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
//#region ---- Filter Extraction ----
|
|
117
|
+
/**
|
|
118
|
+
* Extract location-specific filters from AXPFilterClause format
|
|
119
|
+
* Maps report parameter paths to location entity field names
|
|
120
|
+
*/
|
|
121
|
+
extractLocationFilters(parameters) {
|
|
122
|
+
const filters = [];
|
|
123
|
+
const paramsAny = parameters;
|
|
124
|
+
if (!paramsAny?.filters || !Array.isArray(paramsAny.filters)) {
|
|
125
|
+
console.log('⚠️ [extractLocationFilters] No filters array found or not an array');
|
|
126
|
+
return filters;
|
|
127
|
+
}
|
|
128
|
+
for (const filter of paramsAny.filters) {
|
|
129
|
+
if (!filter?.field || filter?.value === undefined || filter?.value === null) {
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
const field = filter.field;
|
|
133
|
+
const value = filter.value;
|
|
134
|
+
const operator = filter.operator || { type: 'equal' };
|
|
135
|
+
// Handle location-specific field mappings
|
|
136
|
+
if (field === 'country') {
|
|
137
|
+
// Country filter
|
|
138
|
+
if (Array.isArray(value) && value.length > 0) {
|
|
139
|
+
filters.push({
|
|
140
|
+
field: 'countryId',
|
|
141
|
+
operator: { type: 'in' },
|
|
142
|
+
value: value,
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
else if (value) {
|
|
146
|
+
filters.push({
|
|
147
|
+
field: 'countryId',
|
|
148
|
+
operator: { type: 'equal' },
|
|
149
|
+
value: value,
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
else if (field === 'province') {
|
|
154
|
+
// Province/State filter
|
|
155
|
+
if (Array.isArray(value) && value.length > 0) {
|
|
156
|
+
filters.push({
|
|
157
|
+
field: 'stateId',
|
|
158
|
+
operator: { type: 'in' },
|
|
159
|
+
value: value,
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
else if (value) {
|
|
163
|
+
filters.push({
|
|
164
|
+
field: 'stateId',
|
|
165
|
+
operator: { type: 'equal' },
|
|
166
|
+
value: value,
|
|
167
|
+
});
|
|
168
|
+
console.log('✅ [extractLocationFilters] Added province filter (equal):', value);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
else if (field === 'city') {
|
|
172
|
+
if (Array.isArray(value) && value.length > 0) {
|
|
173
|
+
filters.push({
|
|
174
|
+
field: 'cityId',
|
|
175
|
+
operator: { type: 'in' },
|
|
176
|
+
value: value,
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
else if (value) {
|
|
180
|
+
filters.push({
|
|
181
|
+
field: 'cityId',
|
|
182
|
+
operator: { type: 'equal' },
|
|
183
|
+
value: value,
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
// Direct field mapping
|
|
189
|
+
filters.push({
|
|
190
|
+
field: field,
|
|
191
|
+
operator: operator,
|
|
192
|
+
value: value,
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
return filters;
|
|
197
|
+
}
|
|
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
|
+
}
|
|
201
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: GetLocationListQuery, decorators: [{
|
|
202
|
+
type: Injectable,
|
|
203
|
+
args: [{
|
|
204
|
+
providedIn: 'root',
|
|
205
|
+
}]
|
|
206
|
+
}] });
|
|
207
|
+
|
|
208
|
+
export { GetLocationListQuery };
|
|
209
|
+
//# sourceMappingURL=acorex-connectivity-mock-get-location-list.query-bMjkZnzq.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acorex-connectivity-mock-get-location-list.query-bMjkZnzq.mjs","sources":["../../../../libs/connectivity/mock/src/lib/report-management/samples/get-location-list.query.ts"],"sourcesContent":["import { inject, Injectable } from '@angular/core';\nimport { AXPQuery } from '@acorex/platform/runtime';\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?: Array<{ field: string; dir: 'asc' | 'desc' }>;\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.field 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\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":";;;;;AAoCA;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;AA8M5D,IAAA;IA5MC,MAAM,KAAK,CAAC,KAAsC,EAAA;;QAEhD,MAAM,gBAAgB,GAAG,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC,OAAO,CAAC;;QAEnE,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;;QAEA,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;AACD,oBAAA,KAAK,EAAE,KAAK,CAAC,KAAK,IAAI,KAAK;AAC3B,oBAAA,OAAO,EAAE,aAAa;AACf;AACT,kBAAE,SAAS;AAChB,SAAA,C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