@acorex/connectivity 21.0.0-next.3 → 21.0.0-next.31
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-G8Opk5JU.mjs +65509 -0
- package/fesm2022/acorex-connectivity-mock-acorex-connectivity-mock-G8Opk5JU.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-CPGQNlRz.mjs +114 -0
- package/fesm2022/acorex-connectivity-mock-chat-generate-image.command-CPGQNlRz.mjs.map +1 -0
- package/fesm2022/acorex-connectivity-mock-chat-synthesize-speech.command-BXem7bHF.mjs +130 -0
- package/fesm2022/acorex-connectivity-mock-chat-synthesize-speech.command-BXem7bHF.mjs.map +1 -0
- package/fesm2022/acorex-connectivity-mock-chat-transcribe-speech.command-TP4dUKlp.mjs +110 -0
- package/fesm2022/acorex-connectivity-mock-chat-transcribe-speech.command-TP4dUKlp.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 +3909 -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,251 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { inject, Injectable } from '@angular/core';
|
|
3
|
+
import { resolveMultiLanguageString } from '@acorex/platform/core';
|
|
4
|
+
import { AXPEntityService } from '@acorex/platform/layout/entity';
|
|
5
|
+
import { RootConfig } from '@acorex/modules/product-catalog';
|
|
6
|
+
|
|
7
|
+
//#endregion
|
|
8
|
+
class GetProductListQuery {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.entityService = inject(AXPEntityService);
|
|
11
|
+
this.productService = this.entityService.withEntity(`${RootConfig.module.name}.${RootConfig.entities.product.name}`).data();
|
|
12
|
+
}
|
|
13
|
+
async fetch(input) {
|
|
14
|
+
// Extract product-specific filters from AXPFilterClause format
|
|
15
|
+
const extractedFilters = this.extractProductFilters(input.filters);
|
|
16
|
+
// Separate custom filters from entity filters
|
|
17
|
+
const entityFilters = [];
|
|
18
|
+
let priceRangeFilter;
|
|
19
|
+
if (extractedFilters && extractedFilters.length > 0) {
|
|
20
|
+
for (const filter of extractedFilters) {
|
|
21
|
+
if (filter.field === 'priceRange') {
|
|
22
|
+
priceRangeFilter = filter.value;
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
entityFilters.push(filter);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
// Get all products from storage with entity filters
|
|
30
|
+
const allProductsResult = await this.productService.query({
|
|
31
|
+
skip: 0,
|
|
32
|
+
take: 10000, // Get all products for aggregation
|
|
33
|
+
filter: entityFilters.length > 0
|
|
34
|
+
? {
|
|
35
|
+
logic: input.logic || 'and',
|
|
36
|
+
filters: entityFilters,
|
|
37
|
+
}
|
|
38
|
+
: undefined,
|
|
39
|
+
});
|
|
40
|
+
let allProducts = allProductsResult.items;
|
|
41
|
+
// Apply custom price range filter after fetching
|
|
42
|
+
if (priceRangeFilter && priceRangeFilter !== 'all') {
|
|
43
|
+
allProducts = this.applyPriceRangeFilter(allProducts, priceRangeFilter);
|
|
44
|
+
}
|
|
45
|
+
// Group products by brand
|
|
46
|
+
const brandGroups = new Map();
|
|
47
|
+
for (const product of allProducts) {
|
|
48
|
+
const brandKey = product.brand?.title || product.brandId || 'Unknown';
|
|
49
|
+
if (!brandGroups.has(brandKey)) {
|
|
50
|
+
brandGroups.set(brandKey, []);
|
|
51
|
+
}
|
|
52
|
+
brandGroups.get(brandKey).push(product);
|
|
53
|
+
}
|
|
54
|
+
// Aggregate data by brand
|
|
55
|
+
const aggregatedResults = [];
|
|
56
|
+
for (const [brandName, products] of brandGroups.entries()) {
|
|
57
|
+
const prices = products.map((p) => p.basePrice || 0).filter((p) => p > 0);
|
|
58
|
+
const totalValue = prices.reduce((sum, price) => sum + price, 0);
|
|
59
|
+
const productCount = products.length;
|
|
60
|
+
const averagePrice = productCount > 0 ? totalValue / productCount : 0;
|
|
61
|
+
const minPrice = prices.length > 0 ? Math.min(...prices) : 0;
|
|
62
|
+
const maxPrice = prices.length > 0 ? Math.max(...prices) : 0;
|
|
63
|
+
// Get unique categories
|
|
64
|
+
const categorySet = new Set();
|
|
65
|
+
for (const product of products) {
|
|
66
|
+
if (product.categories && Array.isArray(product.categories)) {
|
|
67
|
+
for (const cat of product.categories) {
|
|
68
|
+
if (cat.title) {
|
|
69
|
+
categorySet.add(resolveMultiLanguageString(cat.title, 'en-US'));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
const categories = Array.from(categorySet).join(', ');
|
|
75
|
+
// Get brand ID from first product
|
|
76
|
+
const brandId = products[0]?.brandId || products[0]?.brand?.id;
|
|
77
|
+
// Get manufacturer from first product (assuming all products in a brand have same manufacturer)
|
|
78
|
+
const manufacturerName = (products[0]?.manufacturer?.title != null
|
|
79
|
+
? resolveMultiLanguageString(products[0].manufacturer.title, 'en-US')
|
|
80
|
+
: '') ||
|
|
81
|
+
products[0]?.manufacturerId ||
|
|
82
|
+
'Unknown';
|
|
83
|
+
const manufacturerId = products[0]?.manufacturerId || products[0]?.manufacturer?.id;
|
|
84
|
+
aggregatedResults.push({
|
|
85
|
+
brand: brandName,
|
|
86
|
+
brandId,
|
|
87
|
+
manufacturer: manufacturerName,
|
|
88
|
+
manufacturerId,
|
|
89
|
+
productCount,
|
|
90
|
+
totalValue: Number(totalValue.toFixed(2)),
|
|
91
|
+
averagePrice: Number(averagePrice.toFixed(2)),
|
|
92
|
+
minPrice: Number(minPrice.toFixed(2)),
|
|
93
|
+
maxPrice: Number(maxPrice.toFixed(2)),
|
|
94
|
+
categories,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
// Apply sorting if provided
|
|
98
|
+
if (input.sort && input.sort.length > 0) {
|
|
99
|
+
aggregatedResults.sort((a, b) => {
|
|
100
|
+
for (const sortField of input.sort) {
|
|
101
|
+
const field = sortField.field;
|
|
102
|
+
const aValue = a[field];
|
|
103
|
+
const bValue = b[field];
|
|
104
|
+
const dir = sortField.dir === 'asc' ? 1 : -1;
|
|
105
|
+
// Handle undefined values
|
|
106
|
+
if (aValue === undefined && bValue === undefined)
|
|
107
|
+
continue;
|
|
108
|
+
if (aValue === undefined)
|
|
109
|
+
return 1 * dir;
|
|
110
|
+
if (bValue === undefined)
|
|
111
|
+
return -1 * dir;
|
|
112
|
+
if (aValue < bValue)
|
|
113
|
+
return -1 * dir;
|
|
114
|
+
if (aValue > bValue)
|
|
115
|
+
return 1 * dir;
|
|
116
|
+
}
|
|
117
|
+
return 0;
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
// Apply pagination
|
|
121
|
+
const skip = input.skip || 0;
|
|
122
|
+
const take = input.take || 10;
|
|
123
|
+
const total = aggregatedResults.length;
|
|
124
|
+
const items = aggregatedResults.slice(skip, skip + take);
|
|
125
|
+
return {
|
|
126
|
+
items,
|
|
127
|
+
total,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
//#region ---- Filter Extraction ----
|
|
131
|
+
/**
|
|
132
|
+
* Extract product-specific filters from AXPFilterClause format
|
|
133
|
+
* Maps report parameter paths to product entity field names
|
|
134
|
+
*/
|
|
135
|
+
extractProductFilters(parameters) {
|
|
136
|
+
const filters = [];
|
|
137
|
+
const paramsAny = parameters;
|
|
138
|
+
if (!paramsAny?.filters || !Array.isArray(paramsAny.filters)) {
|
|
139
|
+
return filters;
|
|
140
|
+
}
|
|
141
|
+
for (const filter of paramsAny.filters) {
|
|
142
|
+
if (!filter?.field || filter?.value === undefined || filter?.value === null) {
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
const field = filter.field;
|
|
146
|
+
const value = filter.value;
|
|
147
|
+
const operator = filter.operator || { type: 'equal' };
|
|
148
|
+
// Handle product-specific field mappings
|
|
149
|
+
if (field === 'brand') {
|
|
150
|
+
// Brand filter - can be array of IDs or single ID
|
|
151
|
+
if (Array.isArray(value) && value.length > 0) {
|
|
152
|
+
filters.push({
|
|
153
|
+
field: 'brandId',
|
|
154
|
+
operator: { type: 'in' },
|
|
155
|
+
value: value,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
else if (value) {
|
|
159
|
+
filters.push({
|
|
160
|
+
field: 'brandId',
|
|
161
|
+
operator: { type: 'equal' },
|
|
162
|
+
value: value,
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
else if (field === 'category') {
|
|
167
|
+
// Category filter - can be array of IDs or single ID
|
|
168
|
+
if (Array.isArray(value) && value.length > 0) {
|
|
169
|
+
filters.push({
|
|
170
|
+
field: 'categoryIds',
|
|
171
|
+
operator: { type: 'contains' },
|
|
172
|
+
value: value[0], // Use first category for contains check
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
else if (value) {
|
|
176
|
+
filters.push({
|
|
177
|
+
field: 'categoryIds',
|
|
178
|
+
operator: { type: 'contains' },
|
|
179
|
+
value: value,
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
else if (field === 'status') {
|
|
184
|
+
// Status filter - skip 'all' value
|
|
185
|
+
if (value && value !== 'all') {
|
|
186
|
+
filters.push({
|
|
187
|
+
field: 'statusId',
|
|
188
|
+
operator: { type: 'equal' },
|
|
189
|
+
value: value,
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
else if (field === 'priceRange') {
|
|
194
|
+
// Price range filter - custom logic handled in query
|
|
195
|
+
filters.push({
|
|
196
|
+
field: 'priceRange',
|
|
197
|
+
operator: { type: 'equal' },
|
|
198
|
+
value: value,
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
else if (field === 'startDate' || field === 'endDate') {
|
|
202
|
+
// Date filters - can be handled if needed
|
|
203
|
+
// For now, skip as they might not be directly on product entity
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
// Direct field mapping
|
|
207
|
+
filters.push({
|
|
208
|
+
field: field,
|
|
209
|
+
operator: operator,
|
|
210
|
+
value: value,
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return filters;
|
|
215
|
+
}
|
|
216
|
+
//#endregion
|
|
217
|
+
//#region ---- Custom Filter Handlers ----
|
|
218
|
+
/**
|
|
219
|
+
* Apply custom price range filter to products
|
|
220
|
+
*/
|
|
221
|
+
applyPriceRangeFilter(products, priceRange) {
|
|
222
|
+
return products.filter((product) => {
|
|
223
|
+
const price = product.basePrice || 0;
|
|
224
|
+
switch (priceRange) {
|
|
225
|
+
case 'under-50':
|
|
226
|
+
return price < 50;
|
|
227
|
+
case '50-100':
|
|
228
|
+
return price >= 50 && price < 100;
|
|
229
|
+
case '100-500':
|
|
230
|
+
return price >= 100 && price < 500;
|
|
231
|
+
case '500-1000':
|
|
232
|
+
return price >= 500 && price < 1000;
|
|
233
|
+
case 'over-1000':
|
|
234
|
+
return price >= 1000;
|
|
235
|
+
default:
|
|
236
|
+
return true;
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: GetProductListQuery, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
241
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: GetProductListQuery, providedIn: 'root' }); }
|
|
242
|
+
}
|
|
243
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: GetProductListQuery, decorators: [{
|
|
244
|
+
type: Injectable,
|
|
245
|
+
args: [{
|
|
246
|
+
providedIn: 'root',
|
|
247
|
+
}]
|
|
248
|
+
}] });
|
|
249
|
+
|
|
250
|
+
export { GetProductListQuery };
|
|
251
|
+
//# sourceMappingURL=acorex-connectivity-mock-get-product-list.query-B06aC73T.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acorex-connectivity-mock-get-product-list.query-B06aC73T.mjs","sources":["../../../../libs/connectivity/mock/src/lib/product-catalog/reports/get-product-list.query.ts"],"sourcesContent":["import { inject, Injectable } from '@angular/core';\nimport { resolveMultiLanguageString } from '@acorex/platform/core';\nimport { AXPEntityService } from '@acorex/platform/layout/entity';\nimport { AXPQuery } from '@acorex/platform/runtime';\nimport { AXMProductCatalogProductEntityModel } from '@acorex/modules/product-catalog';\nimport { RootConfig } from '@acorex/modules/product-catalog';\n\n//#region ---- Query Input/Output Types ----\n\nexport interface GetProductListQueryInput {\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 ProductByBrandResult {\n brand: string;\n brandId?: string;\n manufacturer: string;\n manufacturerId?: string;\n productCount: number;\n totalValue: number;\n averagePrice: number;\n minPrice: number;\n maxPrice: number;\n categories: string;\n}\n\nexport interface GetProductListQueryResult {\n items: ProductByBrandResult[];\n total: number;\n}\n\n//#endregion\n\n@Injectable({\n providedIn: 'root',\n})\nexport class GetProductListQuery implements AXPQuery<GetProductListQueryInput, GetProductListQueryResult> {\n private readonly entityService = inject(AXPEntityService);\n private productService = this.entityService.withEntity(`${RootConfig.module.name}.${RootConfig.entities.product.name}`).data<string, AXMProductCatalogProductEntityModel>();\n\n async fetch(input: GetProductListQueryInput | any): Promise<GetProductListQueryResult> {\n // Extract product-specific filters from AXPFilterClause format\n const extractedFilters = this.extractProductFilters(input.filters);\n\n // Separate custom filters from entity filters\n const entityFilters: GetProductListQueryInput['filters'] = [];\n let priceRangeFilter: string | undefined;\n\n if (extractedFilters && extractedFilters.length > 0) {\n for (const filter of extractedFilters) {\n if (filter.field === 'priceRange') {\n priceRangeFilter = filter.value;\n } else {\n entityFilters.push(filter);\n }\n }\n }\n\n // Get all products from storage with entity filters\n const allProductsResult = await this.productService.query({\n skip: 0,\n take: 10000, // Get all products for aggregation\n filter:\n entityFilters.length > 0\n ? ({\n logic: input.logic || 'and',\n filters: entityFilters,\n } as any)\n : undefined,\n });\n\n let allProducts = allProductsResult.items;\n\n // Apply custom price range filter after fetching\n if (priceRangeFilter && priceRangeFilter !== 'all') {\n allProducts = this.applyPriceRangeFilter(allProducts, priceRangeFilter);\n }\n\n // Group products by brand\n const brandGroups = new Map<string, AXMProductCatalogProductEntityModel[]>();\n\n for (const product of allProducts) {\n const brandKey = product.brand?.title || product.brandId || 'Unknown';\n\n if (!brandGroups.has(brandKey)) {\n brandGroups.set(brandKey, []);\n }\n\n brandGroups.get(brandKey)!.push(product);\n }\n\n // Aggregate data by brand\n const aggregatedResults: ProductByBrandResult[] = [];\n\n for (const [brandName, products] of brandGroups.entries()) {\n const prices = products.map((p) => p.basePrice || 0).filter((p) => p > 0);\n const totalValue = prices.reduce((sum, price) => sum + price, 0);\n const productCount = products.length;\n const averagePrice = productCount > 0 ? totalValue / productCount : 0;\n const minPrice = prices.length > 0 ? Math.min(...prices) : 0;\n const maxPrice = prices.length > 0 ? Math.max(...prices) : 0;\n\n // Get unique categories\n const categorySet = new Set<string>();\n for (const product of products) {\n if (product.categories && Array.isArray(product.categories)) {\n for (const cat of product.categories) {\n if (cat.title) {\n categorySet.add(resolveMultiLanguageString(cat.title, 'en-US'));\n }\n }\n }\n }\n const categories = Array.from(categorySet).join(', ');\n\n // Get brand ID from first product\n const brandId = products[0]?.brandId || products[0]?.brand?.id;\n\n // Get manufacturer from first product (assuming all products in a brand have same manufacturer)\n const manufacturerName =\n (products[0]?.manufacturer?.title != null\n ? resolveMultiLanguageString(products[0].manufacturer!.title, 'en-US')\n : '') ||\n products[0]?.manufacturerId ||\n 'Unknown';\n const manufacturerId = products[0]?.manufacturerId || products[0]?.manufacturer?.id;\n\n aggregatedResults.push({\n brand: brandName,\n brandId,\n manufacturer: manufacturerName,\n manufacturerId,\n productCount,\n totalValue: Number(totalValue.toFixed(2)),\n averagePrice: Number(averagePrice.toFixed(2)),\n minPrice: Number(minPrice.toFixed(2)),\n maxPrice: Number(maxPrice.toFixed(2)),\n categories,\n });\n }\n\n // Apply sorting if provided\n if (input.sort && input.sort.length > 0) {\n aggregatedResults.sort((a, b) => {\n for (const sortField of input.sort!) {\n const field = sortField.field as keyof ProductByBrandResult;\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 product-specific filters from AXPFilterClause format\n * Maps report parameter paths to product entity field names\n */\n private extractProductFilters(parameters: any): GetProductListQueryInput['filters'] {\n const filters: GetProductListQueryInput['filters'] = [];\n const paramsAny = parameters as any;\n\n if (!paramsAny?.filters || !Array.isArray(paramsAny.filters)) {\n return filters;\n }\n\n for (const filter of paramsAny.filters) {\n if (!filter?.field || filter?.value === undefined || filter?.value === null) {\n continue;\n }\n\n const field = filter.field;\n const value = filter.value;\n const operator = filter.operator || { type: 'equal' };\n\n // Handle product-specific field mappings\n if (field === 'brand') {\n // Brand filter - can be array of IDs or single ID\n if (Array.isArray(value) && value.length > 0) {\n filters.push({\n field: 'brandId',\n operator: { type: 'in' },\n value: value,\n });\n } else if (value) {\n filters.push({\n field: 'brandId',\n operator: { type: 'equal' },\n value: value,\n });\n }\n } else if (field === 'category') {\n // Category filter - can be array of IDs or single ID\n if (Array.isArray(value) && value.length > 0) {\n filters.push({\n field: 'categoryIds',\n operator: { type: 'contains' },\n value: value[0], // Use first category for contains check\n });\n } else if (value) {\n filters.push({\n field: 'categoryIds',\n operator: { type: 'contains' },\n value: value,\n });\n }\n } else if (field === 'status') {\n // Status filter - skip 'all' value\n if (value && value !== 'all') {\n filters.push({\n field: 'statusId',\n operator: { type: 'equal' },\n value: value,\n });\n }\n } else if (field === 'priceRange') {\n // Price range filter - custom logic handled in query\n filters.push({\n field: 'priceRange',\n operator: { type: 'equal' },\n value: value,\n });\n } else if (field === 'startDate' || field === 'endDate') {\n // Date filters - can be handled if needed\n // For now, skip as they might not be directly on product entity\n } else {\n // Direct field mapping\n filters.push({\n field: field,\n operator: operator,\n value: value,\n });\n }\n }\n\n return filters;\n }\n\n //#endregion\n\n //#region ---- Custom Filter Handlers ----\n\n /**\n * Apply custom price range filter to products\n */\n private applyPriceRangeFilter(\n products: AXMProductCatalogProductEntityModel[],\n priceRange: string\n ): AXMProductCatalogProductEntityModel[] {\n return products.filter((product) => {\n const price = product.basePrice || 0;\n\n switch (priceRange) {\n case 'under-50':\n return price < 50;\n case '50-100':\n return price >= 50 && price < 100;\n case '100-500':\n return price >= 100 && price < 500;\n case '500-1000':\n return price >= 500 && price < 1000;\n case 'over-1000':\n return price >= 1000;\n default:\n return true;\n }\n });\n }\n\n //#endregion\n}\n\n"],"names":[],"mappings":";;;;;;AAuCA;MAKa,mBAAmB,CAAA;AAHhC,IAAA,WAAA,GAAA;AAImB,QAAA,IAAA,CAAA,aAAa,GAAG,MAAM,CAAC,gBAAgB,CAAC;QACjD,IAAA,CAAA,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,CAAA,EAAG,UAAU,CAAC,MAAM,CAAC,IAAI,IAAI,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAA,CAAE,CAAC,CAAC,IAAI,EAA+C;AA8P5K,IAAA;IA5PC,MAAM,KAAK,CAAC,KAAqC,EAAA;;QAE/C,MAAM,gBAAgB,GAAG,IAAI,CAAC,qBAAqB,CAAC,KAA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,CAAC,SAAS,IAAI,CAAC;YAEpC,QAAQ,UAAU;AAChB,gBAAA,KAAK,UAAU;oBACb,OAAO,KAAK,GAAG,EAAE;AACnB,gBAAA,KAAK,QAAQ;AACX,oBAAA,OAAO,KAAK,IAAI,EAAE,IAAI,KAAK,GAAG,GAAG;AACnC,gBAAA,KAAK,SAAS;AACZ,oBAAA,OAAO,KAAK,IAAI,GAAG,IAAI,KAAK,GAAG,GAAG;AACpC,gBAAA,KAAK,UAAU;AACb,oBAAA,OAAO,KAAK,IAAI,GAAG,IAAI,KAAK,GAAG,IAAI;AACrC,gBAAA,KAAK,WAAW;oBACd,OAAO,KAAK,IAAI,IAAI;AACtB,gBAAA;AACE,oBAAA,OAAO,IAAI;;AAEjB,QAAA,CAAC,CAAC;IACJ;8GA7PW,mBAAmB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAAnB,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,mBAAmB,cAFlB,MAAM,EAAA,CAAA,CAAA;;2FAEP,mBAAmB,EAAA,UAAA,EAAA,CAAA;kBAH/B,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE,MAAM;AACnB,iBAAA;;;;;"}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { inject, Injectable } from '@angular/core';
|
|
3
|
+
import { GetProductListQuery } from './acorex-connectivity-mock-get-product-list.query-B06aC73T.mjs';
|
|
4
|
+
|
|
5
|
+
//#endregion
|
|
6
|
+
class GetProductPdfDataQuery {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.productListQuery = inject(GetProductListQuery);
|
|
9
|
+
}
|
|
10
|
+
async fetch(input) {
|
|
11
|
+
// Extract product-specific filters from AXPFilterClause format
|
|
12
|
+
const extractedFilters = this.extractProductFilters(input.filters);
|
|
13
|
+
// Get the product list data to generate PDF content
|
|
14
|
+
const productListInput = {
|
|
15
|
+
skip: 0,
|
|
16
|
+
take: 10000, // Get all products for PDF
|
|
17
|
+
filters: extractedFilters,
|
|
18
|
+
logic: input.logic,
|
|
19
|
+
};
|
|
20
|
+
const productData = await this.productListQuery.fetch(productListInput);
|
|
21
|
+
// Generate a mock PDF base64 string
|
|
22
|
+
// In production, this would call an actual PDF generation service
|
|
23
|
+
const pdfBase64 = this.generateMockPdfBase64(productData);
|
|
24
|
+
return {
|
|
25
|
+
base64: pdfBase64,
|
|
26
|
+
filename: `Product_Report_${new Date().toISOString().split('T')[0]}.pdf`,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
//#region ---- Filter Extraction ----
|
|
30
|
+
/**
|
|
31
|
+
* Extract product-specific filters from AXPFilterClause format
|
|
32
|
+
* Maps report parameter paths to product entity field names
|
|
33
|
+
*/
|
|
34
|
+
extractProductFilters(parameters) {
|
|
35
|
+
const filters = [];
|
|
36
|
+
const paramsAny = parameters;
|
|
37
|
+
if (!paramsAny?.filters || !Array.isArray(paramsAny.filters)) {
|
|
38
|
+
return filters;
|
|
39
|
+
}
|
|
40
|
+
for (const filter of paramsAny.filters) {
|
|
41
|
+
if (!filter?.field || filter?.value === undefined || filter?.value === null) {
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
const field = filter.field;
|
|
45
|
+
const value = filter.value;
|
|
46
|
+
const operator = filter.operator || { type: 'equal' };
|
|
47
|
+
// Handle product-specific field mappings
|
|
48
|
+
if (field === 'brand') {
|
|
49
|
+
// Brand filter - can be array of IDs or single ID
|
|
50
|
+
if (Array.isArray(value) && value.length > 0) {
|
|
51
|
+
filters.push({
|
|
52
|
+
field: 'brandId',
|
|
53
|
+
operator: { type: 'in' },
|
|
54
|
+
value: value,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
else if (value) {
|
|
58
|
+
filters.push({
|
|
59
|
+
field: 'brandId',
|
|
60
|
+
operator: { type: 'equal' },
|
|
61
|
+
value: value,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
else if (field === 'category') {
|
|
66
|
+
// Category filter - can be array of IDs or single ID
|
|
67
|
+
if (Array.isArray(value) && value.length > 0) {
|
|
68
|
+
filters.push({
|
|
69
|
+
field: 'categoryIds',
|
|
70
|
+
operator: { type: 'contains' },
|
|
71
|
+
value: value[0], // Use first category for contains check
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
else if (value) {
|
|
75
|
+
filters.push({
|
|
76
|
+
field: 'categoryIds',
|
|
77
|
+
operator: { type: 'contains' },
|
|
78
|
+
value: value,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
else if (field === 'status') {
|
|
83
|
+
// Status filter - skip 'all' value
|
|
84
|
+
if (value && value !== 'all') {
|
|
85
|
+
filters.push({
|
|
86
|
+
field: 'statusId',
|
|
87
|
+
operator: { type: 'equal' },
|
|
88
|
+
value: value,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
else if (field === 'priceRange') {
|
|
93
|
+
// Price range filter - custom logic handled in query
|
|
94
|
+
filters.push({
|
|
95
|
+
field: 'priceRange',
|
|
96
|
+
operator: { type: 'equal' },
|
|
97
|
+
value: value,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
else if (field === 'startDate' || field === 'endDate') {
|
|
101
|
+
// Date filters - can be handled if needed
|
|
102
|
+
// For now, skip as they might not be directly on product entity
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
// Direct field mapping
|
|
106
|
+
filters.push({
|
|
107
|
+
field: field,
|
|
108
|
+
operator: operator,
|
|
109
|
+
value: value,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return filters;
|
|
114
|
+
}
|
|
115
|
+
//#endregion
|
|
116
|
+
//#region ---- PDF Generation Helpers ----
|
|
117
|
+
/**
|
|
118
|
+
* Generate a mock PDF base64 string
|
|
119
|
+
* In production, this would call an actual PDF generation service
|
|
120
|
+
*/
|
|
121
|
+
generateMockPdfBase64(productData) {
|
|
122
|
+
// Create a minimal valid PDF with some content
|
|
123
|
+
// This is a very basic PDF structure for demonstration
|
|
124
|
+
// In production, use a proper PDF library like jsPDF or call a backend service
|
|
125
|
+
const pdfContent = this.createSimplePdf(productData);
|
|
126
|
+
// Convert to base64
|
|
127
|
+
const base64 = btoa(pdfContent);
|
|
128
|
+
return base64;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Create a simple PDF document structure
|
|
132
|
+
* This is a minimal valid PDF for demonstration - in production use a proper PDF library
|
|
133
|
+
*/
|
|
134
|
+
createSimplePdf(productData) {
|
|
135
|
+
// Use a minimal valid PDF structure that browsers can render
|
|
136
|
+
// This is a very basic single-page PDF
|
|
137
|
+
const pdf = `%PDF-1.4
|
|
138
|
+
1 0 obj
|
|
139
|
+
<< /Type /Catalog /Pages 2 0 R >>
|
|
140
|
+
endobj
|
|
141
|
+
2 0 obj
|
|
142
|
+
<< /Type /Pages /Kids [3 0 R] /Count 1 >>
|
|
143
|
+
endobj
|
|
144
|
+
3 0 obj
|
|
145
|
+
<< /Type /Page /Parent 2 0 R /MediaBox [0 0 612 792] /Contents 4 0 R /Resources << /Font << /F1 5 0 R >> >> >>
|
|
146
|
+
endobj
|
|
147
|
+
4 0 obj
|
|
148
|
+
<< /Length 200 >>
|
|
149
|
+
stream
|
|
150
|
+
BT
|
|
151
|
+
/F1 12 Tf
|
|
152
|
+
100 700 Td
|
|
153
|
+
(Product Report) Tj
|
|
154
|
+
0 -20 Td
|
|
155
|
+
(Total Brands: ${productData.total}) Tj
|
|
156
|
+
0 -20 Td
|
|
157
|
+
(Generated: ${new Date().toLocaleDateString()}) Tj
|
|
158
|
+
0 -20 Td
|
|
159
|
+
(Items: ${productData.items.length}) Tj
|
|
160
|
+
ET
|
|
161
|
+
endstream
|
|
162
|
+
endobj
|
|
163
|
+
5 0 obj
|
|
164
|
+
<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>
|
|
165
|
+
endobj
|
|
166
|
+
xref
|
|
167
|
+
0 6
|
|
168
|
+
0000000000 65535 f
|
|
169
|
+
0000000009 00000 n
|
|
170
|
+
0000000058 00000 n
|
|
171
|
+
0000000115 00000 n
|
|
172
|
+
0000000317 00000 n
|
|
173
|
+
0000000444 00000 n
|
|
174
|
+
trailer
|
|
175
|
+
<< /Size 6 /Root 1 0 R >>
|
|
176
|
+
startxref
|
|
177
|
+
527
|
|
178
|
+
%%EOF`;
|
|
179
|
+
return pdf;
|
|
180
|
+
}
|
|
181
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: GetProductPdfDataQuery, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
182
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: GetProductPdfDataQuery, providedIn: 'root' }); }
|
|
183
|
+
}
|
|
184
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: GetProductPdfDataQuery, decorators: [{
|
|
185
|
+
type: Injectable,
|
|
186
|
+
args: [{
|
|
187
|
+
providedIn: 'root',
|
|
188
|
+
}]
|
|
189
|
+
}] });
|
|
190
|
+
|
|
191
|
+
export { GetProductPdfDataQuery };
|
|
192
|
+
//# sourceMappingURL=acorex-connectivity-mock-get-product-pdf-data.query-CM7bsjl7.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acorex-connectivity-mock-get-product-pdf-data.query-CM7bsjl7.mjs","sources":["../../../../libs/connectivity/mock/src/lib/product-catalog/reports/get-product-pdf-data.query.ts"],"sourcesContent":["import { inject, Injectable } from '@angular/core';\nimport { AXPQuery } from '@acorex/platform/runtime';\nimport { GetProductListQueryInput, GetProductListQueryResult } from './get-product-list.query';\nimport { GetProductListQuery } from './get-product-list.query';\n\n//#region ---- Query Input/Output Types ----\n\nexport interface GetProductPdfDataQueryInput {\n filters?: Array<{\n field: string;\n operator: { type: string };\n value: any;\n }>;\n logic?: 'and' | 'or';\n}\n\nexport interface GetProductPdfDataQueryResult {\n url?: string;\n base64?: string;\n blob?: Blob;\n filename?: string;\n}\n\n//#endregion\n\n@Injectable({\n providedIn: 'root',\n})\nexport class GetProductPdfDataQuery implements AXPQuery<GetProductPdfDataQueryInput, GetProductPdfDataQueryResult> {\n private readonly productListQuery = inject(GetProductListQuery);\n\n async fetch(input: GetProductPdfDataQueryInput | any): Promise<GetProductPdfDataQueryResult> {\n // Extract product-specific filters from AXPFilterClause format\n const extractedFilters = this.extractProductFilters(input.filters);\n\n // Get the product list data to generate PDF content\n const productListInput: GetProductListQueryInput = {\n skip: 0,\n take: 10000, // Get all products for PDF\n filters: extractedFilters,\n logic: input.logic,\n };\n\n const productData = await this.productListQuery.fetch(productListInput);\n\n // Generate a mock PDF base64 string\n // In production, this would call an actual PDF generation service\n const pdfBase64 = this.generateMockPdfBase64(productData);\n\n return {\n base64: pdfBase64,\n filename: `Product_Report_${new Date().toISOString().split('T')[0]}.pdf`,\n };\n }\n\n //#region ---- Filter Extraction ----\n\n /**\n * Extract product-specific filters from AXPFilterClause format\n * Maps report parameter paths to product entity field names\n */\n private extractProductFilters(parameters: any): GetProductListQueryInput['filters'] {\n const filters: GetProductListQueryInput['filters'] = [];\n const paramsAny = parameters as any;\n\n if (!paramsAny?.filters || !Array.isArray(paramsAny.filters)) {\n return filters;\n }\n\n for (const filter of paramsAny.filters) {\n if (!filter?.field || filter?.value === undefined || filter?.value === null) {\n continue;\n }\n\n const field = filter.field;\n const value = filter.value;\n const operator = filter.operator || { type: 'equal' };\n\n // Handle product-specific field mappings\n if (field === 'brand') {\n // Brand filter - can be array of IDs or single ID\n if (Array.isArray(value) && value.length > 0) {\n filters.push({\n field: 'brandId',\n operator: { type: 'in' },\n value: value,\n });\n } else if (value) {\n filters.push({\n field: 'brandId',\n operator: { type: 'equal' },\n value: value,\n });\n }\n } else if (field === 'category') {\n // Category filter - can be array of IDs or single ID\n if (Array.isArray(value) && value.length > 0) {\n filters.push({\n field: 'categoryIds',\n operator: { type: 'contains' },\n value: value[0], // Use first category for contains check\n });\n } else if (value) {\n filters.push({\n field: 'categoryIds',\n operator: { type: 'contains' },\n value: value,\n });\n }\n } else if (field === 'status') {\n // Status filter - skip 'all' value\n if (value && value !== 'all') {\n filters.push({\n field: 'statusId',\n operator: { type: 'equal' },\n value: value,\n });\n }\n } else if (field === 'priceRange') {\n // Price range filter - custom logic handled in query\n filters.push({\n field: 'priceRange',\n operator: { type: 'equal' },\n value: value,\n });\n } else if (field === 'startDate' || field === 'endDate') {\n // Date filters - can be handled if needed\n // For now, skip as they might not be directly on product entity\n } else {\n // Direct field mapping\n filters.push({\n field: field,\n operator: operator,\n value: value,\n });\n }\n }\n\n return filters;\n }\n\n //#endregion\n\n //#region ---- PDF Generation Helpers ----\n\n /**\n * Generate a mock PDF base64 string\n * In production, this would call an actual PDF generation service\n */\n private generateMockPdfBase64(productData: GetProductListQueryResult): string {\n // Create a minimal valid PDF with some content\n // This is a very basic PDF structure for demonstration\n // In production, use a proper PDF library like jsPDF or call a backend service\n\n const pdfContent = this.createSimplePdf(productData);\n\n // Convert to base64\n const base64 = btoa(pdfContent);\n\n return base64;\n }\n\n /**\n * Create a simple PDF document structure\n * This is a minimal valid PDF for demonstration - in production use a proper PDF library\n */\n private createSimplePdf(productData: GetProductListQueryResult): string {\n // Use a minimal valid PDF structure that browsers can render\n // This is a very basic single-page PDF\n const pdf = `%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nendobj\n3 0 obj\n<< /Type /Page /Parent 2 0 R /MediaBox [0 0 612 792] /Contents 4 0 R /Resources << /Font << /F1 5 0 R >> >> >>\nendobj\n4 0 obj\n<< /Length 200 >>\nstream\nBT\n/F1 12 Tf\n100 700 Td\n(Product Report) Tj\n0 -20 Td\n(Total Brands: ${productData.total}) Tj\n0 -20 Td\n(Generated: ${new Date().toLocaleDateString()}) Tj\n0 -20 Td\n(Items: ${productData.items.length}) Tj\nET\nendstream\nendobj\n5 0 obj\n<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>\nendobj\nxref\n0 6\n0000000000 65535 f \n0000000009 00000 n \n0000000058 00000 n \n0000000115 00000 n \n0000000317 00000 n \n0000000444 00000 n \ntrailer\n<< /Size 6 /Root 1 0 R >>\nstartxref\n527\n%%EOF`;\n\n return pdf;\n }\n\n //#endregion\n}\n\n"],"names":[],"mappings":";;;;AAuBA;MAKa,sBAAsB,CAAA;AAHnC,IAAA,WAAA,GAAA;AAIqB,QAAA,IAAA,CAAA,gBAAgB,GAAG,MAAM,CAAC,mBAAmB,CAAC;AA2LlE,IAAA;IAzLG,MAAM,KAAK,CAAC,KAAwC,EAAA;;QAEhD,MAAM,gBAAgB,GAAG,IAAI,CAAC,qBAAqB,CAAC,KAAK,CAAC,OAAO,CAAC;;AAGlE,QAAA,MAAM,gBAAgB,GAA6B;AAC/C,YAAA,IAAI,EAAE,CAAC;YACP,IAAI,EAAE,KAAK;AACX,YAAA,OAAO,EAAE,gBAAgB;YACzB,KAAK,EAAE,KAAK,CAAC,KAAK;SACrB;QAED,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,gBAAgB,CAAC;;;QAIvE,MAAM,SAAS,GAAG,IAAI,CAAC,qBAAqB,CAAC,WAAW,CAAC;QAEzD,OAAO;AACH,YAAA,MAAM,EAAE,SAAS;AACjB,YAAA,QAAQ,EAAE,CAAA,eAAA,EAAkB,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,KAAK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,KAAK;AACf,iBAAA,CAAC;YACN;QACJ;AAEA,QAAA,OAAO,OAAO;IAClB;;;AAMA;;;AAGG;AACK,IAAA,qBAAqB,CAAC,WAAsC,EAAA;;;;QAKhE,MAAM,UAAU,GAAG,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC;;AAGpD,QAAA,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC;AAE/B,QAAA,OAAO,MAAM;IACjB;AAEA;;;AAGG;AACK,IAAA,eAAe,CAAC,WAAsC,EAAA;;;AAG1D,QAAA,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;AAkBH,eAAA,EAAA,WAAW,CAAC,KAAK,CAAA;;AAEpB,YAAA,EAAA,IAAI,IAAI,EAAE,CAAC,kBAAkB,EAAE,CAAA;;UAEnC,WAAW,CAAC,KAAK,CAAC,MAAM,CAAA;;;;;;;;;;;;;;;;;;;MAmB5B;AAEE,QAAA,OAAO,GAAG;IACd;8GAzLS,sBAAsB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAAtB,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,sBAAsB,cAFnB,MAAM,EAAA,CAAA,CAAA;;2FAET,sBAAsB,EAAA,UAAA,EAAA,CAAA;kBAHlC,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,UAAU,EAAE,MAAM;AACrB,iBAAA;;;;;"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { inject, Injectable } from '@angular/core';
|
|
3
|
+
import { GetSubscriptionsTimelineQuery } from './acorex-connectivity-mock-get-subscriptions-timeline.query-D4qfDfeV.mjs';
|
|
4
|
+
|
|
5
|
+
//#endregion
|
|
6
|
+
class GetSubscriptionsChartDataQuery {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.subscriptionsTimelineQuery = inject(GetSubscriptionsTimelineQuery);
|
|
9
|
+
}
|
|
10
|
+
async fetch(input) {
|
|
11
|
+
// Get all subscription timeline data (no pagination for charts)
|
|
12
|
+
const timelineResult = await this.subscriptionsTimelineQuery.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
|
+
subscriptionCount: 0,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
const group = monthGroups.get(monthKey);
|
|
31
|
+
group.subscriptionCount++;
|
|
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: GetSubscriptionsChartDataQuery, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
46
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: GetSubscriptionsChartDataQuery, providedIn: 'root' }); }
|
|
47
|
+
}
|
|
48
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: GetSubscriptionsChartDataQuery, decorators: [{
|
|
49
|
+
type: Injectable,
|
|
50
|
+
args: [{
|
|
51
|
+
providedIn: 'root',
|
|
52
|
+
}]
|
|
53
|
+
}] });
|
|
54
|
+
|
|
55
|
+
export { GetSubscriptionsChartDataQuery };
|
|
56
|
+
//# sourceMappingURL=acorex-connectivity-mock-get-subscriptions-chart-data.query-BQT5a_hn.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acorex-connectivity-mock-get-subscriptions-chart-data.query-BQT5a_hn.mjs","sources":["../../../../libs/connectivity/mock/src/lib/tenant-management/reports/get-subscriptions-chart-data.query.ts"],"sourcesContent":["import { inject, Injectable } from '@angular/core';\nimport { AXPQuery } from '@acorex/platform/runtime';\nimport { GetSubscriptionsTimelineQueryInput } from './get-subscriptions-timeline.query';\nimport { GetSubscriptionsTimelineQuery } from './get-subscriptions-timeline.query';\n\n//#region ---- Query Input/Output Types ----\n\nexport interface GetSubscriptionsChartDataQueryInput {\n filters?: Array<{\n field: string;\n operator: { type: string };\n value: any;\n }>;\n logic?: 'and' | 'or';\n}\n\nexport interface SubscriptionsChartDataResult {\n month: string;\n year: number;\n quarter: string;\n subscriptionCount: number;\n}\n\nexport interface GetSubscriptionsChartDataQueryResult {\n items: SubscriptionsChartDataResult[];\n}\n\n//#endregion\n\n@Injectable({\n providedIn: 'root',\n})\nexport class GetSubscriptionsChartDataQuery\n implements AXPQuery<GetSubscriptionsChartDataQueryInput, GetSubscriptionsChartDataQueryResult>\n{\n private readonly subscriptionsTimelineQuery = inject(GetSubscriptionsTimelineQuery);\n\n async fetch(input: GetSubscriptionsChartDataQueryInput | any): Promise<GetSubscriptionsChartDataQueryResult> {\n // Get all subscription timeline data (no pagination for charts)\n const timelineResult = await this.subscriptionsTimelineQuery.fetch({\n skip: 0,\n take: 10000,\n filters: input.filters,\n logic: input.logic,\n });\n\n // Group by month\n const monthGroups = new Map<string, SubscriptionsChartDataResult>();\n\n for (const item of timelineResult.items) {\n const monthKey = `${item.year}-${String(item.monthNumber).padStart(2, '0')}`;\n\n if (!monthGroups.has(monthKey)) {\n monthGroups.set(monthKey, {\n month: item.month,\n year: item.year,\n quarter: item.quarter,\n subscriptionCount: 0,\n });\n }\n\n const group = monthGroups.get(monthKey)!;\n group.subscriptionCount++;\n }\n\n // Convert to array and sort by date\n const results = Array.from(monthGroups.values()).sort((a, b) => {\n if (a.year !== b.year) return a.year - b.year;\n const monthA = new Date(`${a.month} 1, ${a.year}`).getMonth();\n const monthB = new Date(`${b.month} 1, ${b.year}`).getMonth();\n return monthA - monthB;\n });\n\n return {\n items: results,\n };\n }\n}\n\n"],"names":[],"mappings":";;;;AA2BA;MAKa,8BAA8B,CAAA;AAH3C,IAAA,WAAA,GAAA;AAMmB,QAAA,IAAA,CAAA,0BAA0B,GAAG,MAAM,CAAC,6BAA6B,CAAC;AA0CpF,IAAA;IAxCC,MAAM,KAAK,CAAC,KAAgD,EAAA;;QAE1D,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,0BAA0B,CAAC,KAAK,CAAC;AACjE,YAAA,IAAI,EAAE,CAAC;AACP,YAAA,IAAI,EAAE,KAAK;YACX,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,KAAK,EAAE,KAAK,CAAC,KAAK;AACnB,SAAA,CAAC;;AAGF,QAAA,MAAM,WAAW,GAAG,IAAI,GAAG,EAAwC;AAEnE,QAAA,KAAK,MAAM,IAAI,IAAI,cAAc,CAAC,KAAK,EAAE;YACvC,MAAM,QAAQ,GAAG,CAAA,EAAG,IAAI,CAAC,IAAI,CAAA,CAAA,EAAI,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,QAAQ,C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