@acorex/connectivity 21.0.0-next.3 → 21.0.0-next.33
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 +101 -185
- package/fesm2022/acorex-connectivity-api.mjs.map +1 -1
- package/fesm2022/acorex-connectivity-mock-acorex-connectivity-mock-BpUUTZOi.mjs +65873 -0
- package/fesm2022/acorex-connectivity-mock-acorex-connectivity-mock-BpUUTZOi.mjs.map +1 -0
- package/fesm2022/acorex-connectivity-mock-assign-to-manager.activity-DTPM1eU1.mjs +79 -0
- package/fesm2022/acorex-connectivity-mock-assign-to-manager.activity-DTPM1eU1.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-BA0r4IMn.mjs +114 -0
- package/fesm2022/acorex-connectivity-mock-chat-generate-image.command-BA0r4IMn.mjs.map +1 -0
- package/fesm2022/acorex-connectivity-mock-chat-synthesize-speech.command-B5-8a7SC.mjs +130 -0
- package/fesm2022/acorex-connectivity-mock-chat-synthesize-speech.command-B5-8a7SC.mjs.map +1 -0
- package/fesm2022/acorex-connectivity-mock-chat-transcribe-speech.command-BGzXvTnh.mjs +110 -0
- package/fesm2022/acorex-connectivity-mock-chat-transcribe-speech.command-BGzXvTnh.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-D0hyBha-.mjs +70 -0
- package/fesm2022/acorex-connectivity-mock-entity-update.activity-D0hyBha-.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-DwVuYuKx.mjs +115 -0
- 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-sFKYynZA.mjs +163 -0
- 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-C6S4ZJgp.mjs +35 -0
- package/fesm2022/acorex-connectivity-mock-get-current-session-user.activity-C6S4ZJgp.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-B06aC73T.mjs +251 -0
- package/fesm2022/acorex-connectivity-mock-get-product-list.query-B06aC73T.mjs.map +1 -0
- package/fesm2022/acorex-connectivity-mock-get-product-pdf-data.query-CM7bsjl7.mjs +192 -0
- package/fesm2022/acorex-connectivity-mock-get-product-pdf-data.query-CM7bsjl7.mjs.map +1 -0
- package/fesm2022/acorex-connectivity-mock-get-subscriptions-chart-data.query-BQT5a_hn.mjs +56 -0
- 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-D4qfDfeV.mjs +246 -0
- package/fesm2022/acorex-connectivity-mock-get-subscriptions-timeline.query-D4qfDfeV.mjs.map +1 -0
- package/fesm2022/acorex-connectivity-mock-get-tenant-application-access.query-n1_Azada.mjs +258 -0
- 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-Cg4ykZU2.mjs +56 -0
- 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-0sCBtdbp.mjs +294 -0
- 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-rD811gtM.mjs +212 -0
- 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-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-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 +1 -51504
- 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} +1 -59
- package/types/acorex-connectivity-mock.d.ts +3951 -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-sample.command-CkH5bmEs.mjs.map +0 -1
- package/mock/index.d.ts +0 -2775
- /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,246 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { inject, Injectable } from '@angular/core';
|
|
3
|
+
import { AXPEntityService } from '@acorex/platform/layout/entity';
|
|
4
|
+
import { AXPSystemStatusType } from '@acorex/platform/common';
|
|
5
|
+
import { RootConfig } from '@acorex/modules/subscription-management';
|
|
6
|
+
import { RootConfig as RootConfig$1 } from '@acorex/modules/tenant-management';
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
9
|
+
class GetSubscriptionsTimelineQuery {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.entityService = inject(AXPEntityService);
|
|
12
|
+
this.subscriptionService = this.entityService
|
|
13
|
+
.withEntity(`${RootConfig.module.name}.${RootConfig.entities.subscription.name}`)
|
|
14
|
+
.data();
|
|
15
|
+
this.tenantService = this.entityService
|
|
16
|
+
.withEntity(`${RootConfig$1.module.name}.${RootConfig$1.entities.tenant.name}`)
|
|
17
|
+
.data();
|
|
18
|
+
}
|
|
19
|
+
async fetch(input) {
|
|
20
|
+
// Extract filters from AXPFilterClause format
|
|
21
|
+
const extractedFilters = this.extractSubscriptionFilters(input.filters);
|
|
22
|
+
const filterLogic = input.filters?.logic || input.logic || 'and';
|
|
23
|
+
// Separate custom filters from entity filters
|
|
24
|
+
const entityFilters = [];
|
|
25
|
+
let dateRangeFilter;
|
|
26
|
+
if (extractedFilters && extractedFilters.length > 0) {
|
|
27
|
+
for (const filter of extractedFilters) {
|
|
28
|
+
if (filter.field === 'dateRange') {
|
|
29
|
+
dateRangeFilter = filter.value;
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
entityFilters.push(filter);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
// Get all subscriptions
|
|
37
|
+
const subscriptionsResult = await this.subscriptionService.query({
|
|
38
|
+
skip: 0,
|
|
39
|
+
take: 10000,
|
|
40
|
+
filter: entityFilters.length > 0
|
|
41
|
+
? {
|
|
42
|
+
logic: filterLogic,
|
|
43
|
+
filters: entityFilters,
|
|
44
|
+
}
|
|
45
|
+
: undefined,
|
|
46
|
+
});
|
|
47
|
+
let subscriptions = subscriptionsResult.items.filter((s) => s.subscriberType === 'Tenant');
|
|
48
|
+
// Get all tenants for lookup
|
|
49
|
+
const tenantsResult = await this.tenantService.query({
|
|
50
|
+
skip: 0,
|
|
51
|
+
take: 10000,
|
|
52
|
+
});
|
|
53
|
+
const tenants = tenantsResult.items;
|
|
54
|
+
const tenantMap = new Map(tenants.map((t) => [t.id, t]));
|
|
55
|
+
// Apply date range filter if provided
|
|
56
|
+
if (dateRangeFilter) {
|
|
57
|
+
subscriptions = this.applyDateRangeFilter(subscriptions, dateRangeFilter);
|
|
58
|
+
}
|
|
59
|
+
const now = new Date();
|
|
60
|
+
// Build results
|
|
61
|
+
const results = [];
|
|
62
|
+
for (const subscription of subscriptions) {
|
|
63
|
+
const startDate = new Date(subscription.startDate);
|
|
64
|
+
const endDate = subscription.endDate ? new Date(subscription.endDate) : undefined;
|
|
65
|
+
// Calculate duration in days
|
|
66
|
+
const durationDays = endDate
|
|
67
|
+
? Math.ceil((endDate.getTime() - startDate.getTime()) / (1000 * 60 * 60 * 24))
|
|
68
|
+
: Math.ceil((now.getTime() - startDate.getTime()) / (1000 * 60 * 60 * 24));
|
|
69
|
+
// Extract time period info from start date
|
|
70
|
+
const year = startDate.getFullYear();
|
|
71
|
+
const month = startDate.getMonth() + 1;
|
|
72
|
+
const monthName = startDate.toLocaleString('en-US', { month: 'long' });
|
|
73
|
+
const quarter = Math.ceil(month / 3);
|
|
74
|
+
const quarterName = `Q${quarter}`;
|
|
75
|
+
// Check if subscription is currently active
|
|
76
|
+
const isActive = subscription.statusId === AXPSystemStatusType.Active &&
|
|
77
|
+
startDate <= now &&
|
|
78
|
+
(!endDate || endDate >= now);
|
|
79
|
+
// Get tenant name
|
|
80
|
+
const tenant = tenantMap.get(subscription.subscriberId);
|
|
81
|
+
results.push({
|
|
82
|
+
subscriptionId: subscription.id,
|
|
83
|
+
subscriptionTitle: subscription.title || `${tenant?.title || 'Unknown'} - ${subscription.plan?.title || 'Unknown Plan'}`,
|
|
84
|
+
tenantId: subscription.subscriberId,
|
|
85
|
+
tenantName: tenant?.title || 'Unknown',
|
|
86
|
+
planId: subscription.planId,
|
|
87
|
+
planName: subscription.plan?.title || 'Unknown',
|
|
88
|
+
status: subscription.statusId || 'Unknown',
|
|
89
|
+
startDate: startDate,
|
|
90
|
+
startDateStr: startDate.toISOString(),
|
|
91
|
+
endDate: endDate,
|
|
92
|
+
endDateStr: endDate?.toISOString(),
|
|
93
|
+
durationDays: durationDays,
|
|
94
|
+
month: monthName,
|
|
95
|
+
monthNumber: month,
|
|
96
|
+
quarter: quarterName,
|
|
97
|
+
year: year,
|
|
98
|
+
isActive: isActive,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
// Apply sorting if provided
|
|
102
|
+
if (input.sort && input.sort.length > 0) {
|
|
103
|
+
results.sort((a, b) => {
|
|
104
|
+
for (const sortField of input.sort) {
|
|
105
|
+
const field = sortField.field;
|
|
106
|
+
const aValue = a[field];
|
|
107
|
+
const bValue = b[field];
|
|
108
|
+
const dir = sortField.dir === 'asc' ? 1 : -1;
|
|
109
|
+
if (aValue === undefined && bValue === undefined)
|
|
110
|
+
continue;
|
|
111
|
+
if (aValue === undefined)
|
|
112
|
+
return 1 * dir;
|
|
113
|
+
if (bValue === undefined)
|
|
114
|
+
return -1 * dir;
|
|
115
|
+
// Handle date comparison
|
|
116
|
+
if (field === 'startDate') {
|
|
117
|
+
const aDate = a.startDate.getTime();
|
|
118
|
+
const bDate = b.startDate.getTime();
|
|
119
|
+
if (aDate < bDate)
|
|
120
|
+
return -1 * dir;
|
|
121
|
+
if (aDate > bDate)
|
|
122
|
+
return 1 * dir;
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
if (aValue < bValue)
|
|
126
|
+
return -1 * dir;
|
|
127
|
+
if (aValue > bValue)
|
|
128
|
+
return 1 * dir;
|
|
129
|
+
}
|
|
130
|
+
return 0;
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
// Default sort by start date descending (newest first)
|
|
135
|
+
results.sort((a, b) => {
|
|
136
|
+
return b.startDate.getTime() - a.startDate.getTime();
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
// Apply pagination
|
|
140
|
+
const skip = input.skip || 0;
|
|
141
|
+
const take = input.take || 10;
|
|
142
|
+
const total = results.length;
|
|
143
|
+
const items = results.slice(skip, skip + take);
|
|
144
|
+
return {
|
|
145
|
+
items,
|
|
146
|
+
total,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
//#region ---- Filter Extraction ----
|
|
150
|
+
/**
|
|
151
|
+
* Extract subscription-specific filters from AXPFilterClause format
|
|
152
|
+
* Maps report parameter paths to subscription entity field names
|
|
153
|
+
*/
|
|
154
|
+
extractSubscriptionFilters(parameters) {
|
|
155
|
+
const filters = [];
|
|
156
|
+
const paramsAny = parameters;
|
|
157
|
+
if (!paramsAny?.filters || !Array.isArray(paramsAny.filters)) {
|
|
158
|
+
return filters;
|
|
159
|
+
}
|
|
160
|
+
for (const filter of paramsAny.filters) {
|
|
161
|
+
if (!filter?.field || filter?.value === undefined || filter?.value === null) {
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
const field = filter.field;
|
|
165
|
+
const value = filter.value;
|
|
166
|
+
const operator = filter.operator || { type: 'equal' };
|
|
167
|
+
// Handle subscription-specific field mappings
|
|
168
|
+
if (field === 'planId') {
|
|
169
|
+
// Plan ID filter - can be array of IDs or single ID
|
|
170
|
+
if (Array.isArray(value) && value.length > 0) {
|
|
171
|
+
filters.push({
|
|
172
|
+
field: 'planId',
|
|
173
|
+
operator: { type: 'in' },
|
|
174
|
+
value: value,
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
else if (value) {
|
|
178
|
+
filters.push({
|
|
179
|
+
field: 'planId',
|
|
180
|
+
operator: { type: 'equal' },
|
|
181
|
+
value: value,
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
else if (field === 'statusId') {
|
|
186
|
+
// Status filter - skip 'all' value
|
|
187
|
+
if (value && value !== 'all') {
|
|
188
|
+
filters.push({
|
|
189
|
+
field: 'statusId',
|
|
190
|
+
operator: { type: 'equal' },
|
|
191
|
+
value: value,
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
else if (field === 'dateRange') {
|
|
196
|
+
// Date range filter - custom logic handled in query
|
|
197
|
+
filters.push({
|
|
198
|
+
field: 'dateRange',
|
|
199
|
+
operator: { type: 'equal' },
|
|
200
|
+
value: value,
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
// Direct field mapping
|
|
205
|
+
filters.push({
|
|
206
|
+
field: field,
|
|
207
|
+
operator: operator,
|
|
208
|
+
value: value,
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
return filters;
|
|
213
|
+
}
|
|
214
|
+
//#endregion
|
|
215
|
+
//#region ---- Custom Filter Handlers ----
|
|
216
|
+
/**
|
|
217
|
+
* Apply date range filter to subscriptions
|
|
218
|
+
*/
|
|
219
|
+
applyDateRangeFilter(subscriptions, dateRange) {
|
|
220
|
+
if (!dateRange || !dateRange.start || !dateRange.end) {
|
|
221
|
+
return subscriptions;
|
|
222
|
+
}
|
|
223
|
+
const startDate = new Date(dateRange.start);
|
|
224
|
+
const endDate = new Date(dateRange.end);
|
|
225
|
+
endDate.setHours(23, 59, 59, 999);
|
|
226
|
+
return subscriptions.filter((subscription) => {
|
|
227
|
+
const subStartDate = new Date(subscription.startDate);
|
|
228
|
+
const subEndDate = subscription.endDate ? new Date(subscription.endDate) : null;
|
|
229
|
+
// Check if subscription overlaps with the date range
|
|
230
|
+
return ((subStartDate >= startDate && subStartDate <= endDate) ||
|
|
231
|
+
(subEndDate && subEndDate >= startDate && subEndDate <= endDate) ||
|
|
232
|
+
(subStartDate <= startDate && (!subEndDate || subEndDate >= endDate)));
|
|
233
|
+
});
|
|
234
|
+
}
|
|
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
|
+
}
|
|
238
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: GetSubscriptionsTimelineQuery, decorators: [{
|
|
239
|
+
type: Injectable,
|
|
240
|
+
args: [{
|
|
241
|
+
providedIn: 'root',
|
|
242
|
+
}]
|
|
243
|
+
}] });
|
|
244
|
+
|
|
245
|
+
export { GetSubscriptionsTimelineQuery };
|
|
246
|
+
//# sourceMappingURL=acorex-connectivity-mock-get-subscriptions-timeline.query-D4qfDfeV.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acorex-connectivity-mock-get-subscriptions-timeline.query-D4qfDfeV.mjs","sources":["../../../../libs/connectivity/mock/src/lib/tenant-management/reports/get-subscriptions-timeline.query.ts"],"sourcesContent":["import { inject, Injectable } from '@angular/core';\nimport { AXPQuery } from '@acorex/platform/runtime';\nimport { AXPEntityService } from '@acorex/platform/layout/entity';\nimport { AXMSubscriptionManagementSubscriptionEntityModel } from '@acorex/modules/subscription-management';\nimport { AXMTenantManagementTenantEntityModel } from '@acorex/modules/tenant-management';\nimport { AXPSystemStatusType } from '@acorex/platform/common';\nimport { RootConfig as SubscriptionRootConfig } from '@acorex/modules/subscription-management';\nimport { RootConfig as TenantRootConfig } from '@acorex/modules/tenant-management';\n\n//#region ---- Query Input/Output Types ----\n\nexport interface GetSubscriptionsTimelineQueryInput {\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 SubscriptionsTimelineResult {\n subscriptionId: string;\n subscriptionTitle: string;\n tenantId: string;\n tenantName: string;\n planId?: string;\n planName: string;\n status: string;\n startDate: Date;\n startDateStr: string;\n endDate?: Date;\n endDateStr?: string;\n durationDays: number;\n month: string;\n monthNumber: number;\n quarter: string;\n year: number;\n isActive: boolean;\n}\n\nexport interface GetSubscriptionsTimelineQueryResult {\n items: SubscriptionsTimelineResult[];\n total: number;\n}\n\n//#endregion\n\n@Injectable({\n providedIn: 'root',\n})\nexport class GetSubscriptionsTimelineQuery\n implements AXPQuery<GetSubscriptionsTimelineQueryInput, GetSubscriptionsTimelineQueryResult>\n{\n private readonly entityService = inject(AXPEntityService);\n private subscriptionService = this.entityService\n .withEntity(`${SubscriptionRootConfig.module.name}.${SubscriptionRootConfig.entities.subscription.name}`)\n .data<string, AXMSubscriptionManagementSubscriptionEntityModel>();\n private tenantService = this.entityService\n .withEntity(`${TenantRootConfig.module.name}.${TenantRootConfig.entities.tenant.name}`)\n .data<string, AXMTenantManagementTenantEntityModel>();\n\n async fetch(input: GetSubscriptionsTimelineQueryInput | any): Promise<GetSubscriptionsTimelineQueryResult> {\n // Extract filters from AXPFilterClause format\n const extractedFilters = this.extractSubscriptionFilters(input.filters);\n const filterLogic = (input.filters as any)?.logic || input.logic || 'and';\n\n // Separate custom filters from entity filters\n const entityFilters: GetSubscriptionsTimelineQueryInput['filters'] = [];\n let dateRangeFilter: any;\n\n if (extractedFilters && extractedFilters.length > 0) {\n for (const filter of extractedFilters) {\n if (filter.field === 'dateRange') {\n dateRangeFilter = filter.value;\n } else {\n entityFilters.push(filter);\n }\n }\n }\n\n // Get all subscriptions\n const subscriptionsResult = await this.subscriptionService.query({\n skip: 0,\n take: 10000,\n filter:\n entityFilters.length > 0\n ? ({\n logic: filterLogic,\n filters: entityFilters,\n } as any)\n : undefined,\n });\n\n let subscriptions = subscriptionsResult.items.filter((s) => s.subscriberType === 'Tenant');\n\n // Get all tenants for lookup\n const tenantsResult = await this.tenantService.query({\n skip: 0,\n take: 10000,\n });\n const tenants = tenantsResult.items;\n const tenantMap = new Map(tenants.map((t) => [t.id, t]));\n\n // Apply date range filter if provided\n if (dateRangeFilter) {\n subscriptions = this.applyDateRangeFilter(subscriptions, dateRangeFilter);\n }\n\n const now = new Date();\n\n // Build results\n const results: SubscriptionsTimelineResult[] = [];\n\n for (const subscription of subscriptions) {\n const startDate = new Date(subscription.startDate);\n const endDate = subscription.endDate ? new Date(subscription.endDate) : undefined;\n\n // Calculate duration in days\n const durationDays = endDate\n ? Math.ceil((endDate.getTime() - startDate.getTime()) / (1000 * 60 * 60 * 24))\n : Math.ceil((now.getTime() - startDate.getTime()) / (1000 * 60 * 60 * 24));\n\n // Extract time period info from start date\n const year = startDate.getFullYear();\n const month = startDate.getMonth() + 1;\n const monthName = startDate.toLocaleString('en-US', { month: 'long' });\n const quarter = Math.ceil(month / 3);\n const quarterName = `Q${quarter}`;\n\n // Check if subscription is currently active\n const isActive =\n subscription.statusId === AXPSystemStatusType.Active &&\n startDate <= now &&\n (!endDate || endDate >= now);\n\n // Get tenant name\n const tenant = tenantMap.get(subscription.subscriberId);\n\n results.push({\n subscriptionId: subscription.id,\n subscriptionTitle: subscription.title || `${tenant?.title || 'Unknown'} - ${subscription.plan?.title || 'Unknown Plan'}`,\n tenantId: subscription.subscriberId,\n tenantName: tenant?.title || 'Unknown',\n planId: subscription.planId,\n planName: subscription.plan?.title || 'Unknown',\n status: subscription.statusId || 'Unknown',\n startDate: startDate,\n startDateStr: startDate.toISOString(),\n endDate: endDate,\n endDateStr: endDate?.toISOString(),\n durationDays: durationDays,\n month: monthName,\n monthNumber: month,\n quarter: quarterName,\n year: year,\n isActive: isActive,\n });\n }\n\n // Apply sorting if provided\n if (input.sort && input.sort.length > 0) {\n results.sort((a, b) => {\n for (const sortField of input.sort!) {\n const field = sortField.field as keyof SubscriptionsTimelineResult;\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 // Handle date comparison\n if (field === 'startDate') {\n const aDate = a.startDate.getTime();\n const bDate = b.startDate.getTime();\n if (aDate < bDate) return -1 * dir;\n if (aDate > bDate) return 1 * dir;\n continue;\n }\n\n if (aValue < bValue) return -1 * dir;\n if (aValue > bValue) return 1 * dir;\n }\n return 0;\n });\n } else {\n // Default sort by start date descending (newest first)\n results.sort((a, b) => {\n return b.startDate.getTime() - a.startDate.getTime();\n });\n }\n\n // Apply pagination\n const skip = input.skip || 0;\n const take = input.take || 10;\n const total = results.length;\n const items = results.slice(skip, skip + take);\n\n return {\n items,\n total,\n };\n }\n\n //#region ---- Filter Extraction ----\n\n /**\n * Extract subscription-specific filters from AXPFilterClause format\n * Maps report parameter paths to subscription entity field names\n */\n private extractSubscriptionFilters(parameters: any): GetSubscriptionsTimelineQueryInput['filters'] {\n const filters: GetSubscriptionsTimelineQueryInput['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 subscription-specific field mappings\n if (field === 'planId') {\n // Plan ID filter - can be array of IDs or single ID\n if (Array.isArray(value) && value.length > 0) {\n filters.push({\n field: 'planId',\n operator: { type: 'in' },\n value: value,\n });\n } else if (value) {\n filters.push({\n field: 'planId',\n operator: { type: 'equal' },\n value: value,\n });\n }\n } else if (field === 'statusId') {\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 === 'dateRange') {\n // Date range filter - custom logic handled in query\n filters.push({\n field: 'dateRange',\n operator: { type: 'equal' },\n value: value,\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 //#region ---- Custom Filter Handlers ----\n\n /**\n * Apply date range filter to subscriptions\n */\n private applyDateRangeFilter(\n subscriptions: AXMSubscriptionManagementSubscriptionEntityModel[],\n dateRange: any\n ): AXMSubscriptionManagementSubscriptionEntityModel[] {\n if (!dateRange || !dateRange.start || !dateRange.end) {\n return subscriptions;\n }\n\n const startDate = new Date(dateRange.start);\n const endDate = new Date(dateRange.end);\n endDate.setHours(23, 59, 59, 999);\n\n return subscriptions.filter((subscription) => {\n const subStartDate = new Date(subscription.startDate);\n const subEndDate = subscription.endDate ? new Date(subscription.endDate) : null;\n\n // Check if subscription overlaps with the date range\n return (\n (subStartDate >= startDate && subStartDate <= endDate) ||\n (subEndDate && subEndDate >= startDate && subEndDate <= endDate) ||\n (subStartDate <= startDate && (!subEndDate || subEndDate >= endDate))\n );\n });\n }\n\n //#endregion\n}\n\n"],"names":["SubscriptionRootConfig","TenantRootConfig"],"mappings":";;;;;;;AAgDA;MAKa,6BAA6B,CAAA;AAH1C,IAAA,WAAA,GAAA;AAMmB,QAAA,IAAA,CAAA,aAAa,GAAG,MAAM,CAAC,gBAAgB,CAAC;QACjD,IAAA,CAAA,mBAAmB,GAAG,IAAI,CAAC;AAChC,aAAA,UAAU,CAAC,CAAA,EAAGA,UAAsB,CAAC,MAAM,CAAC,IAAI,CAAA,CAAA,EAAIA,UAAsB,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,EAAE;AACvG,aAAA,IAAI,EAA4D;QAC3D,IAAA,CAAA,aAAa,GAAG,IAAI,CAAC;AAC1B,aAAA,UAAU,CAAC,CAAA,EAAGC,YAAgB,CAAC,MAAM,CAAC,IAAI,CAAA,CAAA,EAAIA,YAAgB,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE;AACrF,aAAA,IAAI,EAAgD;AAuPxD,IAAA;IArPC,MAAM,KAAK,CAAC,KAA+C,EAAA;;QAEzD,MAAM,gBAAgB,GAAG,IAAI,CAAC,0BAA0B,CAAC,KAAK,CAAC,OAAO,CAAC;AACvE,QAAA,MAAM,WAAW,GAAI,KAAK,CAAC,OAAe,EAAE,KAAK,IAAI,KAAK,CAAC,KAAK,IAAI,KAAK;;QAGzE,MAAM,aAAa,GAAkD,EAAE;AACvE,QAAA,IAAI,eAAoB;QAExB,IAAI,gBAAgB,IAAI,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE;AACnD,YAAA,KAAK,MAAM,MAAM,IAAI,gBAAgB,EAAE;AACrC,gBAAA,IAAI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,IAAI,OAAO,CAAC;AAChE,iBAAC,YAAY,IAAI,SAAS,KAAK,CAAC,UAAU,IAAI,UAAU,IAAI,OAAO,CAAC,CAAC;AAEzE,QAAA,CAAC,CAAC;IACJ;8GA7PW,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,258 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { inject, Injectable } from '@angular/core';
|
|
3
|
+
import { AXPEntityService } from '@acorex/platform/layout/entity';
|
|
4
|
+
import { AXPSystemStatusType } from '@acorex/platform/common';
|
|
5
|
+
import { RootConfig } from '@acorex/modules/tenant-management';
|
|
6
|
+
import { RootConfig as RootConfig$1 } from '@acorex/modules/subscription-management';
|
|
7
|
+
import { RootConfig as RootConfig$2 } from '@acorex/modules/application-management';
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
class GetTenantApplicationAccessQuery {
|
|
11
|
+
constructor() {
|
|
12
|
+
this.entityService = inject(AXPEntityService);
|
|
13
|
+
this.tenantService = this.entityService
|
|
14
|
+
.withEntity(`${RootConfig.module.name}.${RootConfig.entities.tenant.name}`)
|
|
15
|
+
.data();
|
|
16
|
+
this.subscriptionService = this.entityService
|
|
17
|
+
.withEntity(`${RootConfig$1.module.name}.${RootConfig$1.entities.subscription.name}`)
|
|
18
|
+
.data();
|
|
19
|
+
this.planService = this.entityService
|
|
20
|
+
.withEntity(`${RootConfig$1.module.name}.${RootConfig$1.entities.subscriptionPlan.name}`)
|
|
21
|
+
.data();
|
|
22
|
+
this.planItemService = this.entityService
|
|
23
|
+
.withEntity(`${RootConfig$1.module.name}.${RootConfig$1.entities.subscriptionPlanItem.name}`)
|
|
24
|
+
.data();
|
|
25
|
+
this.applicationService = this.entityService
|
|
26
|
+
.withEntity(`${RootConfig$2.module.name}.${RootConfig$2.entities.application.name}`)
|
|
27
|
+
.data();
|
|
28
|
+
}
|
|
29
|
+
async fetch(input) {
|
|
30
|
+
// Extract filters from AXPFilterClause format
|
|
31
|
+
const extractedFilters = this.extractTenantFilters(input.filters);
|
|
32
|
+
const filterLogic = input.filters?.logic || input.logic || 'and';
|
|
33
|
+
// Separate custom filters from entity filters
|
|
34
|
+
const entityFilters = [];
|
|
35
|
+
let dateRangeFilter;
|
|
36
|
+
if (extractedFilters && extractedFilters.length > 0) {
|
|
37
|
+
for (const filter of extractedFilters) {
|
|
38
|
+
if (filter.field === 'dateRange') {
|
|
39
|
+
dateRangeFilter = filter.value;
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
entityFilters.push(filter);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
// Get all tenants
|
|
47
|
+
const tenantsResult = await this.tenantService.query({
|
|
48
|
+
skip: 0,
|
|
49
|
+
take: 10000,
|
|
50
|
+
filter: entityFilters.length > 0
|
|
51
|
+
? {
|
|
52
|
+
logic: filterLogic,
|
|
53
|
+
filters: entityFilters,
|
|
54
|
+
}
|
|
55
|
+
: undefined,
|
|
56
|
+
});
|
|
57
|
+
let tenants = tenantsResult.items;
|
|
58
|
+
// Apply date range filter if provided
|
|
59
|
+
if (dateRangeFilter) {
|
|
60
|
+
tenants = this.applyDateRangeFilter(tenants, dateRangeFilter);
|
|
61
|
+
}
|
|
62
|
+
// Get all subscriptions
|
|
63
|
+
const subscriptionsResult = await this.subscriptionService.query({
|
|
64
|
+
skip: 0,
|
|
65
|
+
take: 10000,
|
|
66
|
+
});
|
|
67
|
+
const subscriptions = subscriptionsResult.items.filter((s) => s.subscriberType === 'Tenant');
|
|
68
|
+
// Get all plans
|
|
69
|
+
const plansResult = await this.planService.query({
|
|
70
|
+
skip: 0,
|
|
71
|
+
take: 10000,
|
|
72
|
+
});
|
|
73
|
+
const plans = plansResult.items;
|
|
74
|
+
// Get all plan items
|
|
75
|
+
const planItemsResult = await this.planItemService.query({
|
|
76
|
+
skip: 0,
|
|
77
|
+
take: 10000,
|
|
78
|
+
});
|
|
79
|
+
const planItems = planItemsResult.items;
|
|
80
|
+
// Get all applications
|
|
81
|
+
const applicationsResult = await this.applicationService.query({
|
|
82
|
+
skip: 0,
|
|
83
|
+
take: 10000,
|
|
84
|
+
});
|
|
85
|
+
const applications = applicationsResult.items;
|
|
86
|
+
// Build results for each tenant
|
|
87
|
+
const results = [];
|
|
88
|
+
for (const tenant of tenants) {
|
|
89
|
+
// Get tenant's subscriptions
|
|
90
|
+
const tenantSubscriptions = subscriptions.filter((s) => s.subscriberId === tenant.id);
|
|
91
|
+
// Get unique applications through subscriptions → plans → plan items → editions → applications
|
|
92
|
+
const applicationSet = new Set();
|
|
93
|
+
const applicationNames = [];
|
|
94
|
+
for (const subscription of tenantSubscriptions) {
|
|
95
|
+
if (!subscription.planId)
|
|
96
|
+
continue;
|
|
97
|
+
// Get plan items for this plan
|
|
98
|
+
const planPlanItems = planItems.filter((pi) => pi.planId === subscription.planId);
|
|
99
|
+
for (const planItem of planPlanItems) {
|
|
100
|
+
if (!planItem.editionId)
|
|
101
|
+
continue;
|
|
102
|
+
// Find applications that have this edition
|
|
103
|
+
for (const application of applications) {
|
|
104
|
+
if (application.editionIds && application.editionIds.includes(planItem.editionId)) {
|
|
105
|
+
if (!applicationSet.has(application.id)) {
|
|
106
|
+
applicationSet.add(application.id);
|
|
107
|
+
applicationNames.push(application.title);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
// Count active subscriptions
|
|
114
|
+
const activeSubscriptions = tenantSubscriptions.filter((s) => s.statusId === AXPSystemStatusType.Active);
|
|
115
|
+
results.push({
|
|
116
|
+
tenantId: tenant.id,
|
|
117
|
+
tenantName: tenant.title,
|
|
118
|
+
tenantStatus: tenant.statusId || 'Unknown',
|
|
119
|
+
subscriptionCount: tenantSubscriptions.length,
|
|
120
|
+
applicationsCount: applicationSet.size,
|
|
121
|
+
applicationsList: applicationNames.join(', '),
|
|
122
|
+
activeSubscriptionsCount: activeSubscriptions.length,
|
|
123
|
+
registrationDate: tenant.registrationDate,
|
|
124
|
+
registrationDateStr: tenant.registrationDate?.toISOString(),
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
// Apply sorting if provided
|
|
128
|
+
if (input.sort && input.sort.length > 0) {
|
|
129
|
+
results.sort((a, b) => {
|
|
130
|
+
for (const sortField of input.sort) {
|
|
131
|
+
const field = sortField.field;
|
|
132
|
+
const aValue = a[field];
|
|
133
|
+
const bValue = b[field];
|
|
134
|
+
const dir = sortField.dir === 'asc' ? 1 : -1;
|
|
135
|
+
if (aValue === undefined && bValue === undefined)
|
|
136
|
+
continue;
|
|
137
|
+
if (aValue === undefined)
|
|
138
|
+
return 1 * dir;
|
|
139
|
+
if (bValue === undefined)
|
|
140
|
+
return -1 * dir;
|
|
141
|
+
if (aValue < bValue)
|
|
142
|
+
return -1 * dir;
|
|
143
|
+
if (aValue > bValue)
|
|
144
|
+
return 1 * dir;
|
|
145
|
+
}
|
|
146
|
+
return 0;
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
// Default sort by tenant name
|
|
151
|
+
results.sort((a, b) => a.tenantName.localeCompare(b.tenantName));
|
|
152
|
+
}
|
|
153
|
+
// Apply pagination
|
|
154
|
+
const skip = input.skip || 0;
|
|
155
|
+
const take = input.take || 10;
|
|
156
|
+
const total = results.length;
|
|
157
|
+
const items = results.slice(skip, skip + take);
|
|
158
|
+
return {
|
|
159
|
+
items,
|
|
160
|
+
total,
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
//#region ---- Filter Extraction ----
|
|
164
|
+
/**
|
|
165
|
+
* Extract tenant-specific filters from AXPFilterClause format
|
|
166
|
+
* Maps report parameter paths to tenant entity field names
|
|
167
|
+
*/
|
|
168
|
+
extractTenantFilters(parameters) {
|
|
169
|
+
const filters = [];
|
|
170
|
+
const paramsAny = parameters;
|
|
171
|
+
if (!paramsAny?.filters || !Array.isArray(paramsAny.filters)) {
|
|
172
|
+
return filters;
|
|
173
|
+
}
|
|
174
|
+
for (const filter of paramsAny.filters) {
|
|
175
|
+
if (!filter?.field || filter?.value === undefined || filter?.value === null) {
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
const field = filter.field;
|
|
179
|
+
const value = filter.value;
|
|
180
|
+
const operator = filter.operator || { type: 'equal' };
|
|
181
|
+
// Handle tenant-specific field mappings
|
|
182
|
+
if (field === 'tenantId') {
|
|
183
|
+
// Tenant ID filter - can be array of IDs or single ID
|
|
184
|
+
if (Array.isArray(value) && value.length > 0) {
|
|
185
|
+
filters.push({
|
|
186
|
+
field: 'id',
|
|
187
|
+
operator: { type: 'in' },
|
|
188
|
+
value: value,
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
else if (value) {
|
|
192
|
+
filters.push({
|
|
193
|
+
field: 'id',
|
|
194
|
+
operator: { type: 'equal' },
|
|
195
|
+
value: value,
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
else if (field === 'statusId') {
|
|
200
|
+
// Status filter - skip 'all' value
|
|
201
|
+
if (value && value !== 'all') {
|
|
202
|
+
filters.push({
|
|
203
|
+
field: 'statusId',
|
|
204
|
+
operator: { type: 'equal' },
|
|
205
|
+
value: value,
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
else if (field === 'dateRange') {
|
|
210
|
+
// Date range filter - custom logic handled in query
|
|
211
|
+
filters.push({
|
|
212
|
+
field: 'dateRange',
|
|
213
|
+
operator: { type: 'equal' },
|
|
214
|
+
value: value,
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
// Direct field mapping
|
|
219
|
+
filters.push({
|
|
220
|
+
field: field,
|
|
221
|
+
operator: operator,
|
|
222
|
+
value: value,
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return filters;
|
|
227
|
+
}
|
|
228
|
+
//#endregion
|
|
229
|
+
//#region ---- Custom Filter Handlers ----
|
|
230
|
+
/**
|
|
231
|
+
* Apply date range filter to tenants
|
|
232
|
+
*/
|
|
233
|
+
applyDateRangeFilter(tenants, dateRange) {
|
|
234
|
+
if (!dateRange || !dateRange.start || !dateRange.end) {
|
|
235
|
+
return tenants;
|
|
236
|
+
}
|
|
237
|
+
const startDate = new Date(dateRange.start);
|
|
238
|
+
const endDate = new Date(dateRange.end);
|
|
239
|
+
endDate.setHours(23, 59, 59, 999);
|
|
240
|
+
return tenants.filter((tenant) => {
|
|
241
|
+
if (!tenant.registrationDate)
|
|
242
|
+
return false;
|
|
243
|
+
const regDate = new Date(tenant.registrationDate);
|
|
244
|
+
return regDate >= startDate && regDate <= endDate;
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: GetTenantApplicationAccessQuery, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
248
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: GetTenantApplicationAccessQuery, providedIn: 'root' }); }
|
|
249
|
+
}
|
|
250
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: GetTenantApplicationAccessQuery, decorators: [{
|
|
251
|
+
type: Injectable,
|
|
252
|
+
args: [{
|
|
253
|
+
providedIn: 'root',
|
|
254
|
+
}]
|
|
255
|
+
}] });
|
|
256
|
+
|
|
257
|
+
export { GetTenantApplicationAccessQuery };
|
|
258
|
+
//# sourceMappingURL=acorex-connectivity-mock-get-tenant-application-access.query-n1_Azada.mjs.map
|
package/fesm2022/acorex-connectivity-mock-get-tenant-application-access.query-n1_Azada.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acorex-connectivity-mock-get-tenant-application-access.query-n1_Azada.mjs","sources":["../../../../libs/connectivity/mock/src/lib/tenant-management/reports/get-tenant-application-access.query.ts"],"sourcesContent":["import { inject, Injectable } from '@angular/core';\nimport { AXPQuery } from '@acorex/platform/runtime';\nimport { AXPEntityService } from '@acorex/platform/layout/entity';\nimport { AXMTenantManagementTenantEntityModel } from '@acorex/modules/tenant-management';\nimport { AXMSubscriptionManagementSubscriptionEntityModel } from '@acorex/modules/subscription-management';\nimport { AXMSubscriptionManagementSubscriptionPlanEntityModel } from '@acorex/modules/subscription-management';\nimport { AXMSubscriptionManagementSubscriptionPlanItemEntityModel } from '@acorex/modules/subscription-management';\nimport { AXMApplicationManagementApplicationEntityModel } from '@acorex/modules/application-management';\nimport { AXPSystemStatusType } from '@acorex/platform/common';\nimport { RootConfig as TenantRootConfig } from '@acorex/modules/tenant-management';\nimport { RootConfig as SubscriptionRootConfig } from '@acorex/modules/subscription-management';\nimport { RootConfig as ApplicationRootConfig } from '@acorex/modules/application-management';\n\n//#region ---- Query Input/Output Types ----\n\nexport interface GetTenantApplicationAccessQueryInput {\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 TenantApplicationAccessResult {\n tenantId: string;\n tenantName: string;\n tenantStatus: string;\n subscriptionCount: number;\n applicationsCount: number;\n applicationsList: string;\n activeSubscriptionsCount: number;\n registrationDate?: Date;\n registrationDateStr?: string;\n}\n\nexport interface GetTenantApplicationAccessQueryResult {\n items: TenantApplicationAccessResult[];\n total: number;\n}\n\n//#endregion\n\n@Injectable({\n providedIn: 'root',\n})\nexport class GetTenantApplicationAccessQuery\n implements AXPQuery<GetTenantApplicationAccessQueryInput, GetTenantApplicationAccessQueryResult> {\n private readonly entityService = inject(AXPEntityService);\n private tenantService = this.entityService\n .withEntity(`${TenantRootConfig.module.name}.${TenantRootConfig.entities.tenant.name}`)\n .data<string, AXMTenantManagementTenantEntityModel>();\n private subscriptionService = this.entityService\n .withEntity(`${SubscriptionRootConfig.module.name}.${SubscriptionRootConfig.entities.subscription.name}`)\n .data<string, AXMSubscriptionManagementSubscriptionEntityModel>();\n private planService = this.entityService\n .withEntity(`${SubscriptionRootConfig.module.name}.${SubscriptionRootConfig.entities.subscriptionPlan.name}`)\n .data<string, AXMSubscriptionManagementSubscriptionPlanEntityModel>();\n private planItemService = this.entityService\n .withEntity(`${SubscriptionRootConfig.module.name}.${SubscriptionRootConfig.entities.subscriptionPlanItem.name}`)\n .data<string, AXMSubscriptionManagementSubscriptionPlanItemEntityModel>();\n private applicationService = this.entityService\n .withEntity(`${ApplicationRootConfig.module.name}.${ApplicationRootConfig.entities.application.name}`)\n .data<string, AXMApplicationManagementApplicationEntityModel>();\n\n async fetch(input: GetTenantApplicationAccessQueryInput | any): Promise<GetTenantApplicationAccessQueryResult> {\n // Extract filters from AXPFilterClause format\n const extractedFilters = this.extractTenantFilters(input.filters);\n const filterLogic = (input.filters as any)?.logic || input.logic || 'and';\n\n // Separate custom filters from entity filters\n const entityFilters: GetTenantApplicationAccessQueryInput['filters'] = [];\n let dateRangeFilter: any;\n\n if (extractedFilters && extractedFilters.length > 0) {\n for (const filter of extractedFilters) {\n if (filter.field === 'dateRange') {\n dateRangeFilter = filter.value;\n } else {\n entityFilters.push(filter);\n }\n }\n }\n\n // Get all tenants\n const tenantsResult = await this.tenantService.query({\n skip: 0,\n take: 10000,\n filter:\n entityFilters.length > 0\n ? ({\n logic: filterLogic,\n filters: entityFilters,\n } as any)\n : undefined,\n });\n\n let tenants = tenantsResult.items;\n\n // Apply date range filter if provided\n if (dateRangeFilter) {\n tenants = this.applyDateRangeFilter(tenants, dateRangeFilter);\n }\n\n // Get all subscriptions\n const subscriptionsResult = await this.subscriptionService.query({\n skip: 0,\n take: 10000,\n });\n const subscriptions = subscriptionsResult.items.filter((s) => s.subscriberType === 'Tenant');\n\n // Get all plans\n const plansResult = await this.planService.query({\n skip: 0,\n take: 10000,\n });\n const plans = plansResult.items;\n\n // Get all plan items\n const planItemsResult = await this.planItemService.query({\n skip: 0,\n take: 10000,\n });\n const planItems = planItemsResult.items;\n\n // Get all applications\n const applicationsResult = await this.applicationService.query({\n skip: 0,\n take: 10000,\n });\n const applications = applicationsResult.items;\n\n // Build results for each tenant\n const results: TenantApplicationAccessResult[] = [];\n\n for (const tenant of tenants) {\n // Get tenant's subscriptions\n const tenantSubscriptions = subscriptions.filter((s) => s.subscriberId === tenant.id);\n\n // Get unique applications through subscriptions → plans → plan items → editions → applications\n const applicationSet = new Set<string>();\n const applicationNames: string[] = [];\n\n for (const subscription of tenantSubscriptions) {\n if (!subscription.planId) continue;\n\n // Get plan items for this plan\n const planPlanItems = planItems.filter((pi) => pi.planId === subscription.planId);\n\n for (const planItem of planPlanItems) {\n if (!planItem.editionId) continue;\n\n // Find applications that have this edition\n for (const application of applications) {\n if (application.editionIds && application.editionIds.includes(planItem.editionId)) {\n if (!applicationSet.has(application.id)) {\n applicationSet.add(application.id);\n applicationNames.push(application.title);\n }\n }\n }\n }\n }\n\n // Count active subscriptions\n const activeSubscriptions = tenantSubscriptions.filter(\n (s) => s.statusId === AXPSystemStatusType.Active\n );\n\n results.push({\n tenantId: tenant.id,\n tenantName: tenant.title,\n tenantStatus: tenant.statusId || 'Unknown',\n subscriptionCount: tenantSubscriptions.length,\n applicationsCount: applicationSet.size,\n applicationsList: applicationNames.join(', '),\n activeSubscriptionsCount: activeSubscriptions.length,\n registrationDate: tenant.registrationDate,\n registrationDateStr: tenant.registrationDate?.toISOString(),\n });\n }\n\n // Apply sorting if provided\n if (input.sort && input.sort.length > 0) {\n results.sort((a, b) => {\n for (const sortField of input.sort!) {\n const field = sortField.field as keyof TenantApplicationAccessResult;\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 } else {\n // Default sort by tenant name\n results.sort((a, b) => a.tenantName.localeCompare(b.tenantName));\n }\n\n // Apply pagination\n const skip = input.skip || 0;\n const take = input.take || 10;\n const total = results.length;\n const items = results.slice(skip, skip + take);\n\n return {\n items,\n total,\n };\n }\n\n //#region ---- Filter Extraction ----\n\n /**\n * Extract tenant-specific filters from AXPFilterClause format\n * Maps report parameter paths to tenant entity field names\n */\n private extractTenantFilters(parameters: any): GetTenantApplicationAccessQueryInput['filters'] {\n const filters: GetTenantApplicationAccessQueryInput['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 tenant-specific field mappings\n if (field === 'tenantId') {\n // Tenant ID filter - can be array of IDs or single ID\n if (Array.isArray(value) && value.length > 0) {\n filters.push({\n field: 'id',\n operator: { type: 'in' },\n value: value,\n });\n } else if (value) {\n filters.push({\n field: 'id',\n operator: { type: 'equal' },\n value: value,\n });\n }\n } else if (field === 'statusId') {\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 === 'dateRange') {\n // Date range filter - custom logic handled in query\n filters.push({\n field: 'dateRange',\n operator: { type: 'equal' },\n value: value,\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 //#region ---- Custom Filter Handlers ----\n\n /**\n * Apply date range filter to tenants\n */\n private applyDateRangeFilter(\n tenants: AXMTenantManagementTenantEntityModel[],\n dateRange: any\n ): AXMTenantManagementTenantEntityModel[] {\n if (!dateRange || !dateRange.start || !dateRange.end) {\n return tenants;\n }\n\n const startDate = new Date(dateRange.start);\n const endDate = new Date(dateRange.end);\n endDate.setHours(23, 59, 59, 999);\n\n return tenants.filter((tenant) => {\n if (!tenant.registrationDate) return false;\n const regDate = new Date(tenant.registrationDate);\n return regDate >= startDate && regDate <= endDate;\n });\n }\n\n //#endregion\n}\n\n"],"names":["TenantRootConfig","SubscriptionRootConfig","ApplicationRootConfig"],"mappings":";;;;;;;;AA4CA;MAKa,+BAA+B,CAAA;AAH5C,IAAA,WAAA,GAAA;AAKmB,QAAA,IAAA,CAAA,aAAa,GAAG,MAAM,CAAC,gBAAgB,CAAC;QACjD,IAAA,CAAA,aAAa,GAAG,IAAI,CAAC;AAC1B,aAAA,UAAU,CAAC,CAAA,EAAGA,UAAgB,CAAC,MAAM,CAAC,IAAI,CAAA,CAAA,EAAIA,UAAgB,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE;AACrF,aAAA,IAAI,EAAgD;QAC/C,IAAA,CAAA,mBAAmB,GAAG,IAAI,CAAC;AAChC,aAAA,UAAU,CAAC,CAAA,EAAGC,YAAsB,CAAC,MAAM,CAAC,IAAI,CAAA,CAAA,EAAIA,YAAsB,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,EAAE;AACvG,aAAA,IAAI,EAA4D;QAC3D,IAAA,CAAA,WAAW,GAAG,IAAI,CAAC;AACxB,aAAA,UAAU,CAAC,CAA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D,YAAA,OAAO,OAAO;QAChB;QAEA,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;QAC3C,MAAM,OAAO,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC;QACvC,OAAO,CAAC,QAAQ,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,CAAC;AAEjC,QAAA,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,KAAI;YAC/B,IAAI,CAAC,MAAM,CAAC,gBAAgB;AAAE,gBAAA,OAAO,KAAK;YAC1C,MAAM,OAAO,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC;AACjD,YAAA,OAAO,OAAO,IAAI,SAAS,IAAI,OAAO,IAAI,OAAO;AACnD,QAAA,CAAC,CAAC;IACJ;8GAvQW,+BAA+B,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAA/B,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,+BAA+B,cAF9B,MAAM,EAAA,CAAA,CAAA;;2FAEP,+BAA+B,EAAA,UAAA,EAAA,CAAA;kBAH3C,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE,MAAM;AACnB,iBAAA;;;;;"}
|
package/fesm2022/acorex-connectivity-mock-get-tenant-registration-chart-data.query-Cg4ykZU2.mjs
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { inject, Injectable } from '@angular/core';
|
|
3
|
+
import { GetTenantRegistrationTimelineQuery } from './acorex-connectivity-mock-get-tenant-registration-timeline.query-0sCBtdbp.mjs';
|
|
4
|
+
|
|
5
|
+
//#endregion
|
|
6
|
+
class GetTenantRegistrationChartDataQuery {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.tenantRegistrationTimelineQuery = inject(GetTenantRegistrationTimelineQuery);
|
|
9
|
+
}
|
|
10
|
+
async fetch(input) {
|
|
11
|
+
// Get all tenant registration timeline data (no pagination for charts)
|
|
12
|
+
const timelineResult = await this.tenantRegistrationTimelineQuery.fetch({
|
|
13
|
+
skip: 0,
|
|
14
|
+
take: 10000,
|
|
15
|
+
filters: input.filters,
|
|
16
|
+
logic: input.logic,
|
|
17
|
+
});
|
|
18
|
+
// Group by month
|
|
19
|
+
const monthGroups = new Map();
|
|
20
|
+
for (const item of timelineResult.items) {
|
|
21
|
+
const monthKey = `${item.year}-${String(item.monthNumber).padStart(2, '0')}`;
|
|
22
|
+
if (!monthGroups.has(monthKey)) {
|
|
23
|
+
monthGroups.set(monthKey, {
|
|
24
|
+
month: item.month,
|
|
25
|
+
year: item.year,
|
|
26
|
+
quarter: item.quarter,
|
|
27
|
+
tenantCount: 0,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
const group = monthGroups.get(monthKey);
|
|
31
|
+
group.tenantCount++;
|
|
32
|
+
}
|
|
33
|
+
// Convert to array and sort by date
|
|
34
|
+
const results = Array.from(monthGroups.values()).sort((a, b) => {
|
|
35
|
+
if (a.year !== b.year)
|
|
36
|
+
return a.year - b.year;
|
|
37
|
+
const monthA = new Date(`${a.month} 1, ${a.year}`).getMonth();
|
|
38
|
+
const monthB = new Date(`${b.month} 1, ${b.year}`).getMonth();
|
|
39
|
+
return monthA - monthB;
|
|
40
|
+
});
|
|
41
|
+
return {
|
|
42
|
+
items: results,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: GetTenantRegistrationChartDataQuery, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
46
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: GetTenantRegistrationChartDataQuery, providedIn: 'root' }); }
|
|
47
|
+
}
|
|
48
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: GetTenantRegistrationChartDataQuery, decorators: [{
|
|
49
|
+
type: Injectable,
|
|
50
|
+
args: [{
|
|
51
|
+
providedIn: 'root',
|
|
52
|
+
}]
|
|
53
|
+
}] });
|
|
54
|
+
|
|
55
|
+
export { GetTenantRegistrationChartDataQuery };
|
|
56
|
+
//# sourceMappingURL=acorex-connectivity-mock-get-tenant-registration-chart-data.query-Cg4ykZU2.mjs.map
|
package/fesm2022/acorex-connectivity-mock-get-tenant-registration-chart-data.query-Cg4ykZU2.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acorex-connectivity-mock-get-tenant-registration-chart-data.query-Cg4ykZU2.mjs","sources":["../../../../libs/connectivity/mock/src/lib/tenant-management/reports/get-tenant-registration-chart-data.query.ts"],"sourcesContent":["import { inject, Injectable } from '@angular/core';\nimport { AXPQuery } from '@acorex/platform/runtime';\nimport { GetTenantRegistrationTimelineQueryInput } from './get-tenant-registration-timeline.query';\nimport { GetTenantRegistrationTimelineQuery } from './get-tenant-registration-timeline.query';\n\n//#region ---- Query Input/Output Types ----\n\nexport interface GetTenantRegistrationChartDataQueryInput {\n filters?: Array<{\n field: string;\n operator: { type: string };\n value: any;\n }>;\n logic?: 'and' | 'or';\n}\n\nexport interface TenantRegistrationChartDataResult {\n month: string;\n year: number;\n quarter: string;\n tenantCount: number;\n}\n\nexport interface GetTenantRegistrationChartDataQueryResult {\n items: TenantRegistrationChartDataResult[];\n}\n\n//#endregion\n\n@Injectable({\n providedIn: 'root',\n})\nexport class GetTenantRegistrationChartDataQuery\n implements AXPQuery<GetTenantRegistrationChartDataQueryInput, GetTenantRegistrationChartDataQueryResult>\n{\n private readonly tenantRegistrationTimelineQuery = inject(GetTenantRegistrationTimelineQuery);\n\n async fetch(input: GetTenantRegistrationChartDataQueryInput | any): Promise<GetTenantRegistrationChartDataQueryResult> {\n // Get all tenant registration timeline data (no pagination for charts)\n const timelineResult = await this.tenantRegistrationTimelineQuery.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, TenantRegistrationChartDataResult>();\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 tenantCount: 0,\n });\n }\n\n const group = monthGroups.get(monthKey)!;\n group.tenantCount++;\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":";;;;AA2BA;MAKa,mCAAmC,CAAA;AAHhD,IAAA,WAAA,GAAA;AAMmB,QAAA,IAAA,CAAA,+BAA+B,GAAG,MAAM,CAAC,kCAAkC,CAAC;AA0C9F,IAAA;IAxCC,MAAM,KAAK,CAAC,KAAqD,EAAA;;QAE/D,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,+BAA+B,CAAC,KAAK,CAAC;AACtE,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,EAA6C;AAExE,QAAA,KAAK,MAAM,IAAI,IAAI,cAAc,CAAC,KAAK,EAAE;YACvC,MAAM,QAAQ,GAAG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