myio-js-library 0.1.40 → 0.1.41
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/dist/index.cjs +41 -24
- package/dist/index.js +41 -24
- package/dist/myio-js-library.umd.js +41 -24
- package/dist/myio-js-library.umd.min.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -6947,7 +6947,7 @@ var AllReportModal = class {
|
|
|
6947
6947
|
return maybe || null;
|
|
6948
6948
|
}
|
|
6949
6949
|
// Helper: pick a numeric consumption from an API item
|
|
6950
|
-
|
|
6950
|
+
pickConsumption(item) {
|
|
6951
6951
|
const fields = ["total_value", "totalValue", "consumption", "value", "total", "energy", "kwh"];
|
|
6952
6952
|
for (const f of fields) {
|
|
6953
6953
|
if (item?.[f] !== void 0 && item?.[f] !== null) {
|
|
@@ -7431,37 +7431,54 @@ var AllReportModal = class {
|
|
|
7431
7431
|
console.log("[AllReportModal] Customer totals response:", data);
|
|
7432
7432
|
return data;
|
|
7433
7433
|
}
|
|
7434
|
-
// Replace this whole method
|
|
7435
7434
|
mapCustomerTotalsResponse(apiResponse) {
|
|
7436
|
-
const
|
|
7437
|
-
if (!
|
|
7435
|
+
const apiArray = Array.isArray(apiResponse?.data) ? apiResponse.data : Array.isArray(apiResponse) ? apiResponse : [];
|
|
7436
|
+
if (!apiArray.length) {
|
|
7438
7437
|
console.warn("[AllReportModal] Empty/invalid API response:", apiResponse);
|
|
7439
7438
|
return [];
|
|
7440
7439
|
}
|
|
7441
|
-
const
|
|
7442
|
-
|
|
7443
|
-
|
|
7444
|
-
|
|
7445
|
-
|
|
7446
|
-
|
|
7447
|
-
|
|
7448
|
-
|
|
7449
|
-
|
|
7450
|
-
|
|
7451
|
-
|
|
7440
|
+
const sumByApiId = /* @__PURE__ */ new Map();
|
|
7441
|
+
let apiItemsWithoutId = 0;
|
|
7442
|
+
for (const item of apiArray) {
|
|
7443
|
+
const consumption = this.pickConsumption(item);
|
|
7444
|
+
if (item?.id) {
|
|
7445
|
+
const id = String(item.id);
|
|
7446
|
+
sumByApiId.set(id, (sumByApiId.get(id) || 0) + consumption);
|
|
7447
|
+
} else {
|
|
7448
|
+
apiItemsWithoutId++;
|
|
7449
|
+
}
|
|
7450
|
+
}
|
|
7451
|
+
let matchedById = 0, matchedBySubstring = 0;
|
|
7452
|
+
const rows = this.params.itemsList.map((listItem) => {
|
|
7453
|
+
let consumption = sumByApiId.get(listItem.id) ?? 0;
|
|
7454
|
+
if (consumption > 0) {
|
|
7455
|
+
matchedById++;
|
|
7456
|
+
} else {
|
|
7457
|
+
for (const apiItem of apiArray) {
|
|
7458
|
+
const assetName = apiItem?.assetName || "";
|
|
7459
|
+
const name = apiItem?.name || "";
|
|
7460
|
+
if (assetName.includes(listItem.identifier) || name.includes(listItem.identifier)) {
|
|
7461
|
+
consumption += this.pickConsumption(apiItem);
|
|
7462
|
+
}
|
|
7463
|
+
}
|
|
7464
|
+
if (consumption > 0) {
|
|
7465
|
+
matchedBySubstring++;
|
|
7466
|
+
}
|
|
7467
|
+
}
|
|
7452
7468
|
return {
|
|
7453
|
-
identifier:
|
|
7454
|
-
|
|
7455
|
-
|
|
7456
|
-
// friendly name from itemsList
|
|
7457
|
-
consumption: Math.round(c * 100) / 100
|
|
7469
|
+
identifier: listItem.identifier,
|
|
7470
|
+
name: listItem.label,
|
|
7471
|
+
consumption: Math.round(consumption * 100) / 100
|
|
7458
7472
|
};
|
|
7459
7473
|
});
|
|
7460
|
-
console.log("[AllReportModal] Mapping
|
|
7461
|
-
apiItems:
|
|
7462
|
-
|
|
7474
|
+
console.log("[AllReportModal] Mapping stats:", {
|
|
7475
|
+
apiItems: apiArray.length,
|
|
7476
|
+
uniqueApiIds: sumByApiId.size,
|
|
7463
7477
|
itemsInList: this.params.itemsList.length,
|
|
7464
|
-
|
|
7478
|
+
matchedById,
|
|
7479
|
+
matchedBySubstring,
|
|
7480
|
+
unmatched: this.params.itemsList.length - matchedById - matchedBySubstring,
|
|
7481
|
+
apiItemsWithoutId
|
|
7465
7482
|
});
|
|
7466
7483
|
return rows;
|
|
7467
7484
|
}
|
package/dist/index.js
CHANGED
|
@@ -6880,7 +6880,7 @@ var AllReportModal = class {
|
|
|
6880
6880
|
return maybe || null;
|
|
6881
6881
|
}
|
|
6882
6882
|
// Helper: pick a numeric consumption from an API item
|
|
6883
|
-
|
|
6883
|
+
pickConsumption(item) {
|
|
6884
6884
|
const fields = ["total_value", "totalValue", "consumption", "value", "total", "energy", "kwh"];
|
|
6885
6885
|
for (const f of fields) {
|
|
6886
6886
|
if (item?.[f] !== void 0 && item?.[f] !== null) {
|
|
@@ -7364,37 +7364,54 @@ var AllReportModal = class {
|
|
|
7364
7364
|
console.log("[AllReportModal] Customer totals response:", data);
|
|
7365
7365
|
return data;
|
|
7366
7366
|
}
|
|
7367
|
-
// Replace this whole method
|
|
7368
7367
|
mapCustomerTotalsResponse(apiResponse) {
|
|
7369
|
-
const
|
|
7370
|
-
if (!
|
|
7368
|
+
const apiArray = Array.isArray(apiResponse?.data) ? apiResponse.data : Array.isArray(apiResponse) ? apiResponse : [];
|
|
7369
|
+
if (!apiArray.length) {
|
|
7371
7370
|
console.warn("[AllReportModal] Empty/invalid API response:", apiResponse);
|
|
7372
7371
|
return [];
|
|
7373
7372
|
}
|
|
7374
|
-
const
|
|
7375
|
-
|
|
7376
|
-
|
|
7377
|
-
|
|
7378
|
-
|
|
7379
|
-
|
|
7380
|
-
|
|
7381
|
-
|
|
7382
|
-
|
|
7383
|
-
|
|
7384
|
-
|
|
7373
|
+
const sumByApiId = /* @__PURE__ */ new Map();
|
|
7374
|
+
let apiItemsWithoutId = 0;
|
|
7375
|
+
for (const item of apiArray) {
|
|
7376
|
+
const consumption = this.pickConsumption(item);
|
|
7377
|
+
if (item?.id) {
|
|
7378
|
+
const id = String(item.id);
|
|
7379
|
+
sumByApiId.set(id, (sumByApiId.get(id) || 0) + consumption);
|
|
7380
|
+
} else {
|
|
7381
|
+
apiItemsWithoutId++;
|
|
7382
|
+
}
|
|
7383
|
+
}
|
|
7384
|
+
let matchedById = 0, matchedBySubstring = 0;
|
|
7385
|
+
const rows = this.params.itemsList.map((listItem) => {
|
|
7386
|
+
let consumption = sumByApiId.get(listItem.id) ?? 0;
|
|
7387
|
+
if (consumption > 0) {
|
|
7388
|
+
matchedById++;
|
|
7389
|
+
} else {
|
|
7390
|
+
for (const apiItem of apiArray) {
|
|
7391
|
+
const assetName = apiItem?.assetName || "";
|
|
7392
|
+
const name = apiItem?.name || "";
|
|
7393
|
+
if (assetName.includes(listItem.identifier) || name.includes(listItem.identifier)) {
|
|
7394
|
+
consumption += this.pickConsumption(apiItem);
|
|
7395
|
+
}
|
|
7396
|
+
}
|
|
7397
|
+
if (consumption > 0) {
|
|
7398
|
+
matchedBySubstring++;
|
|
7399
|
+
}
|
|
7400
|
+
}
|
|
7385
7401
|
return {
|
|
7386
|
-
identifier:
|
|
7387
|
-
|
|
7388
|
-
|
|
7389
|
-
// friendly name from itemsList
|
|
7390
|
-
consumption: Math.round(c * 100) / 100
|
|
7402
|
+
identifier: listItem.identifier,
|
|
7403
|
+
name: listItem.label,
|
|
7404
|
+
consumption: Math.round(consumption * 100) / 100
|
|
7391
7405
|
};
|
|
7392
7406
|
});
|
|
7393
|
-
console.log("[AllReportModal] Mapping
|
|
7394
|
-
apiItems:
|
|
7395
|
-
|
|
7407
|
+
console.log("[AllReportModal] Mapping stats:", {
|
|
7408
|
+
apiItems: apiArray.length,
|
|
7409
|
+
uniqueApiIds: sumByApiId.size,
|
|
7396
7410
|
itemsInList: this.params.itemsList.length,
|
|
7397
|
-
|
|
7411
|
+
matchedById,
|
|
7412
|
+
matchedBySubstring,
|
|
7413
|
+
unmatched: this.params.itemsList.length - matchedById - matchedBySubstring,
|
|
7414
|
+
apiItemsWithoutId
|
|
7398
7415
|
});
|
|
7399
7416
|
return rows;
|
|
7400
7417
|
}
|
|
@@ -6869,7 +6869,7 @@
|
|
|
6869
6869
|
return maybe || null;
|
|
6870
6870
|
}
|
|
6871
6871
|
// Helper: pick a numeric consumption from an API item
|
|
6872
|
-
|
|
6872
|
+
pickConsumption(item) {
|
|
6873
6873
|
const fields = ["total_value", "totalValue", "consumption", "value", "total", "energy", "kwh"];
|
|
6874
6874
|
for (const f of fields) {
|
|
6875
6875
|
if (item?.[f] !== void 0 && item?.[f] !== null) {
|
|
@@ -7353,37 +7353,54 @@
|
|
|
7353
7353
|
console.log("[AllReportModal] Customer totals response:", data);
|
|
7354
7354
|
return data;
|
|
7355
7355
|
}
|
|
7356
|
-
// Replace this whole method
|
|
7357
7356
|
mapCustomerTotalsResponse(apiResponse) {
|
|
7358
|
-
const
|
|
7359
|
-
if (!
|
|
7357
|
+
const apiArray = Array.isArray(apiResponse?.data) ? apiResponse.data : Array.isArray(apiResponse) ? apiResponse : [];
|
|
7358
|
+
if (!apiArray.length) {
|
|
7360
7359
|
console.warn("[AllReportModal] Empty/invalid API response:", apiResponse);
|
|
7361
7360
|
return [];
|
|
7362
7361
|
}
|
|
7363
|
-
const
|
|
7364
|
-
|
|
7365
|
-
|
|
7366
|
-
|
|
7367
|
-
|
|
7368
|
-
|
|
7369
|
-
|
|
7370
|
-
|
|
7371
|
-
|
|
7372
|
-
|
|
7373
|
-
|
|
7362
|
+
const sumByApiId = /* @__PURE__ */ new Map();
|
|
7363
|
+
let apiItemsWithoutId = 0;
|
|
7364
|
+
for (const item of apiArray) {
|
|
7365
|
+
const consumption = this.pickConsumption(item);
|
|
7366
|
+
if (item?.id) {
|
|
7367
|
+
const id = String(item.id);
|
|
7368
|
+
sumByApiId.set(id, (sumByApiId.get(id) || 0) + consumption);
|
|
7369
|
+
} else {
|
|
7370
|
+
apiItemsWithoutId++;
|
|
7371
|
+
}
|
|
7372
|
+
}
|
|
7373
|
+
let matchedById = 0, matchedBySubstring = 0;
|
|
7374
|
+
const rows = this.params.itemsList.map((listItem) => {
|
|
7375
|
+
let consumption = sumByApiId.get(listItem.id) ?? 0;
|
|
7376
|
+
if (consumption > 0) {
|
|
7377
|
+
matchedById++;
|
|
7378
|
+
} else {
|
|
7379
|
+
for (const apiItem of apiArray) {
|
|
7380
|
+
const assetName = apiItem?.assetName || "";
|
|
7381
|
+
const name = apiItem?.name || "";
|
|
7382
|
+
if (assetName.includes(listItem.identifier) || name.includes(listItem.identifier)) {
|
|
7383
|
+
consumption += this.pickConsumption(apiItem);
|
|
7384
|
+
}
|
|
7385
|
+
}
|
|
7386
|
+
if (consumption > 0) {
|
|
7387
|
+
matchedBySubstring++;
|
|
7388
|
+
}
|
|
7389
|
+
}
|
|
7374
7390
|
return {
|
|
7375
|
-
identifier:
|
|
7376
|
-
|
|
7377
|
-
|
|
7378
|
-
// friendly name from itemsList
|
|
7379
|
-
consumption: Math.round(c * 100) / 100
|
|
7391
|
+
identifier: listItem.identifier,
|
|
7392
|
+
name: listItem.label,
|
|
7393
|
+
consumption: Math.round(consumption * 100) / 100
|
|
7380
7394
|
};
|
|
7381
7395
|
});
|
|
7382
|
-
console.log("[AllReportModal] Mapping
|
|
7383
|
-
apiItems:
|
|
7384
|
-
|
|
7396
|
+
console.log("[AllReportModal] Mapping stats:", {
|
|
7397
|
+
apiItems: apiArray.length,
|
|
7398
|
+
uniqueApiIds: sumByApiId.size,
|
|
7385
7399
|
itemsInList: this.params.itemsList.length,
|
|
7386
|
-
|
|
7400
|
+
matchedById,
|
|
7401
|
+
matchedBySubstring,
|
|
7402
|
+
unmatched: this.params.itemsList.length - matchedById - matchedBySubstring,
|
|
7403
|
+
apiItemsWithoutId
|
|
7387
7404
|
});
|
|
7388
7405
|
return rows;
|
|
7389
7406
|
}
|