@etainabl/nodejs-sdk 1.3.181 → 1.3.184
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/esm/index.js +240 -97
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.cts +177 -104
- package/dist/index.d.ts +177 -104
- package/dist/index.js +253 -111
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1445,10 +1445,10 @@ var init_ChecksumStream = __esm({
|
|
|
1445
1445
|
}
|
|
1446
1446
|
_read(size) {
|
|
1447
1447
|
}
|
|
1448
|
-
_write(
|
|
1448
|
+
_write(chunk3, encoding, callback) {
|
|
1449
1449
|
try {
|
|
1450
|
-
this.checksum.update(
|
|
1451
|
-
this.push(
|
|
1450
|
+
this.checksum.update(chunk3);
|
|
1451
|
+
this.push(chunk3);
|
|
1452
1452
|
} catch (e7) {
|
|
1453
1453
|
return callback(e7);
|
|
1454
1454
|
}
|
|
@@ -1514,9 +1514,9 @@ var init_createChecksumStream_browser = __esm({
|
|
|
1514
1514
|
const transform = new TransformStream({
|
|
1515
1515
|
start() {
|
|
1516
1516
|
},
|
|
1517
|
-
async transform(
|
|
1518
|
-
checksum.update(
|
|
1519
|
-
controller.enqueue(
|
|
1517
|
+
async transform(chunk3, controller) {
|
|
1518
|
+
checksum.update(chunk3);
|
|
1519
|
+
controller.enqueue(chunk3);
|
|
1520
1520
|
},
|
|
1521
1521
|
async flush(controller) {
|
|
1522
1522
|
const digest = await checksum.digest();
|
|
@@ -1602,7 +1602,7 @@ function createBufferedReadableStream(upstream, size, logger2) {
|
|
|
1602
1602
|
let mode = -1;
|
|
1603
1603
|
const pull = async (controller) => {
|
|
1604
1604
|
const { value, done } = await reader.read();
|
|
1605
|
-
const
|
|
1605
|
+
const chunk3 = value;
|
|
1606
1606
|
if (done) {
|
|
1607
1607
|
if (mode !== -1) {
|
|
1608
1608
|
const remainder = flush(buffers, mode);
|
|
@@ -1612,7 +1612,7 @@ function createBufferedReadableStream(upstream, size, logger2) {
|
|
|
1612
1612
|
}
|
|
1613
1613
|
controller.close();
|
|
1614
1614
|
} else {
|
|
1615
|
-
const chunkMode = modeOf(
|
|
1615
|
+
const chunkMode = modeOf(chunk3, false);
|
|
1616
1616
|
if (mode !== chunkMode) {
|
|
1617
1617
|
if (mode >= 0) {
|
|
1618
1618
|
controller.enqueue(flush(buffers, mode));
|
|
@@ -1620,16 +1620,16 @@ function createBufferedReadableStream(upstream, size, logger2) {
|
|
|
1620
1620
|
mode = chunkMode;
|
|
1621
1621
|
}
|
|
1622
1622
|
if (mode === -1) {
|
|
1623
|
-
controller.enqueue(
|
|
1623
|
+
controller.enqueue(chunk3);
|
|
1624
1624
|
return;
|
|
1625
1625
|
}
|
|
1626
|
-
const chunkSize = sizeOf(
|
|
1626
|
+
const chunkSize = sizeOf(chunk3);
|
|
1627
1627
|
bytesSeen += chunkSize;
|
|
1628
1628
|
const bufferSize = sizeOf(buffers[mode]);
|
|
1629
1629
|
if (chunkSize >= size && bufferSize === 0) {
|
|
1630
|
-
controller.enqueue(
|
|
1630
|
+
controller.enqueue(chunk3);
|
|
1631
1631
|
} else {
|
|
1632
|
-
const newSize = merge(buffers, mode,
|
|
1632
|
+
const newSize = merge(buffers, mode, chunk3);
|
|
1633
1633
|
if (!streamBufferingLoggedWarning && bytesSeen > size * 2) {
|
|
1634
1634
|
streamBufferingLoggedWarning = true;
|
|
1635
1635
|
logger2?.warn(`@smithy/util-stream - stream chunk size ${chunkSize} is below threshold of ${size}, automatically buffering.`);
|
|
@@ -1646,14 +1646,14 @@ function createBufferedReadableStream(upstream, size, logger2) {
|
|
|
1646
1646
|
pull
|
|
1647
1647
|
});
|
|
1648
1648
|
}
|
|
1649
|
-
function merge(buffers, mode,
|
|
1649
|
+
function merge(buffers, mode, chunk3) {
|
|
1650
1650
|
switch (mode) {
|
|
1651
1651
|
case 0:
|
|
1652
|
-
buffers[0] +=
|
|
1652
|
+
buffers[0] += chunk3;
|
|
1653
1653
|
return sizeOf(buffers[0]);
|
|
1654
1654
|
case 1:
|
|
1655
1655
|
case 2:
|
|
1656
|
-
buffers[mode].push(
|
|
1656
|
+
buffers[mode].push(chunk3);
|
|
1657
1657
|
return sizeOf(buffers[mode]);
|
|
1658
1658
|
}
|
|
1659
1659
|
}
|
|
@@ -1669,17 +1669,17 @@ function flush(buffers, mode) {
|
|
|
1669
1669
|
}
|
|
1670
1670
|
throw new Error(`@smithy/util-stream - invalid index ${mode} given to flush()`);
|
|
1671
1671
|
}
|
|
1672
|
-
function sizeOf(
|
|
1673
|
-
return
|
|
1672
|
+
function sizeOf(chunk3) {
|
|
1673
|
+
return chunk3?.byteLength ?? chunk3?.length ?? 0;
|
|
1674
1674
|
}
|
|
1675
|
-
function modeOf(
|
|
1676
|
-
if (allowBuffer && typeof Buffer !== "undefined" &&
|
|
1675
|
+
function modeOf(chunk3, allowBuffer = true) {
|
|
1676
|
+
if (allowBuffer && typeof Buffer !== "undefined" && chunk3 instanceof Buffer) {
|
|
1677
1677
|
return 2;
|
|
1678
1678
|
}
|
|
1679
|
-
if (
|
|
1679
|
+
if (chunk3 instanceof Uint8Array) {
|
|
1680
1680
|
return 1;
|
|
1681
1681
|
}
|
|
1682
|
-
if (typeof
|
|
1682
|
+
if (typeof chunk3 === "string") {
|
|
1683
1683
|
return 0;
|
|
1684
1684
|
}
|
|
1685
1685
|
return -1;
|
|
@@ -1706,8 +1706,8 @@ function createBufferedReadable(upstream, size, logger2) {
|
|
|
1706
1706
|
new ByteArrayCollector((size2) => Buffer.from(new Uint8Array(size2)))
|
|
1707
1707
|
];
|
|
1708
1708
|
let mode = -1;
|
|
1709
|
-
upstream.on("data", (
|
|
1710
|
-
const chunkMode = modeOf(
|
|
1709
|
+
upstream.on("data", (chunk3) => {
|
|
1710
|
+
const chunkMode = modeOf(chunk3, true);
|
|
1711
1711
|
if (mode !== chunkMode) {
|
|
1712
1712
|
if (mode >= 0) {
|
|
1713
1713
|
downstream.push(flush(buffers, mode));
|
|
@@ -1715,16 +1715,16 @@ function createBufferedReadable(upstream, size, logger2) {
|
|
|
1715
1715
|
mode = chunkMode;
|
|
1716
1716
|
}
|
|
1717
1717
|
if (mode === -1) {
|
|
1718
|
-
downstream.push(
|
|
1718
|
+
downstream.push(chunk3);
|
|
1719
1719
|
return;
|
|
1720
1720
|
}
|
|
1721
|
-
const chunkSize = sizeOf(
|
|
1721
|
+
const chunkSize = sizeOf(chunk3);
|
|
1722
1722
|
bytesSeen += chunkSize;
|
|
1723
1723
|
const bufferSize = sizeOf(buffers[mode]);
|
|
1724
1724
|
if (chunkSize >= size && bufferSize === 0) {
|
|
1725
|
-
downstream.push(
|
|
1725
|
+
downstream.push(chunk3);
|
|
1726
1726
|
} else {
|
|
1727
|
-
const newSize = merge(buffers, mode,
|
|
1727
|
+
const newSize = merge(buffers, mode, chunk3);
|
|
1728
1728
|
if (!streamBufferingLoggedWarning && bytesSeen > size * 2) {
|
|
1729
1729
|
streamBufferingLoggedWarning = true;
|
|
1730
1730
|
logger2?.warn(`@smithy/util-stream - stream chunk size ${chunkSize} is below threshold of ${size}, automatically buffering.`);
|
|
@@ -1812,14 +1812,14 @@ async function headStream(stream, bytes) {
|
|
|
1812
1812
|
reader.releaseLock();
|
|
1813
1813
|
const collected = new Uint8Array(Math.min(bytes, byteLengthCounter));
|
|
1814
1814
|
let offset = 0;
|
|
1815
|
-
for (const
|
|
1816
|
-
if (
|
|
1817
|
-
collected.set(
|
|
1815
|
+
for (const chunk3 of chunks) {
|
|
1816
|
+
if (chunk3.byteLength > collected.byteLength - offset) {
|
|
1817
|
+
collected.set(chunk3.subarray(0, collected.byteLength - offset), offset);
|
|
1818
1818
|
break;
|
|
1819
1819
|
} else {
|
|
1820
|
-
collected.set(
|
|
1820
|
+
collected.set(chunk3, offset);
|
|
1821
1821
|
}
|
|
1822
|
-
offset +=
|
|
1822
|
+
offset += chunk3.length;
|
|
1823
1823
|
}
|
|
1824
1824
|
return collected;
|
|
1825
1825
|
}
|
|
@@ -1860,9 +1860,9 @@ var init_headStream = __esm({
|
|
|
1860
1860
|
buffers = [];
|
|
1861
1861
|
limit = Infinity;
|
|
1862
1862
|
bytesBuffered = 0;
|
|
1863
|
-
_write(
|
|
1864
|
-
this.buffers.push(
|
|
1865
|
-
this.bytesBuffered +=
|
|
1863
|
+
_write(chunk3, encoding, callback) {
|
|
1864
|
+
this.buffers.push(chunk3);
|
|
1865
|
+
this.bytesBuffered += chunk3.byteLength ?? 0;
|
|
1866
1866
|
if (this.bytesBuffered >= this.limit) {
|
|
1867
1867
|
const excess = this.bytesBuffered - this.limit;
|
|
1868
1868
|
const tailBuffer = this.buffers[this.buffers.length - 1];
|
|
@@ -2395,8 +2395,8 @@ var init_collector = __esm({
|
|
|
2395
2395
|
import_stream5 = require("stream");
|
|
2396
2396
|
Collector2 = class extends import_stream5.Writable {
|
|
2397
2397
|
bufferedBytes = [];
|
|
2398
|
-
_write(
|
|
2399
|
-
this.bufferedBytes.push(
|
|
2398
|
+
_write(chunk3, encoding, callback) {
|
|
2399
|
+
this.bufferedBytes.push(chunk3);
|
|
2400
2400
|
callback();
|
|
2401
2401
|
}
|
|
2402
2402
|
};
|
|
@@ -2419,9 +2419,9 @@ async function collectReadableStream(stream) {
|
|
|
2419
2419
|
}
|
|
2420
2420
|
const collected = new Uint8Array(length);
|
|
2421
2421
|
let offset = 0;
|
|
2422
|
-
for (const
|
|
2423
|
-
collected.set(
|
|
2424
|
-
offset +=
|
|
2422
|
+
for (const chunk3 of chunks) {
|
|
2423
|
+
collected.set(chunk3, offset);
|
|
2424
|
+
offset += chunk3.length;
|
|
2425
2425
|
}
|
|
2426
2426
|
return collected;
|
|
2427
2427
|
}
|
|
@@ -2490,9 +2490,9 @@ async function collectStream(stream) {
|
|
|
2490
2490
|
}
|
|
2491
2491
|
const collected = new Uint8Array(length);
|
|
2492
2492
|
let offset = 0;
|
|
2493
|
-
for (const
|
|
2494
|
-
collected.set(
|
|
2495
|
-
offset +=
|
|
2493
|
+
for (const chunk3 of chunks) {
|
|
2494
|
+
collected.set(chunk3, offset);
|
|
2495
|
+
offset += chunk3.length;
|
|
2496
2496
|
}
|
|
2497
2497
|
return collected;
|
|
2498
2498
|
}
|
|
@@ -7137,9 +7137,9 @@ var init_HeaderFormatter = __esm({
|
|
|
7137
7137
|
}
|
|
7138
7138
|
const out = new Uint8Array(chunks.reduce((carry, bytes) => carry + bytes.byteLength, 0));
|
|
7139
7139
|
let position = 0;
|
|
7140
|
-
for (const
|
|
7141
|
-
out.set(
|
|
7142
|
-
position +=
|
|
7140
|
+
for (const chunk3 of chunks) {
|
|
7141
|
+
out.set(chunk3, position);
|
|
7142
|
+
position += chunk3.byteLength;
|
|
7143
7143
|
}
|
|
7144
7144
|
return out;
|
|
7145
7145
|
}
|
|
@@ -11519,8 +11519,8 @@ function httpRequest(options) {
|
|
|
11519
11519
|
req.destroy();
|
|
11520
11520
|
}
|
|
11521
11521
|
const chunks = [];
|
|
11522
|
-
res.on("data", (
|
|
11523
|
-
chunks.push(
|
|
11522
|
+
res.on("data", (chunk3) => {
|
|
11523
|
+
chunks.push(chunk3);
|
|
11524
11524
|
});
|
|
11525
11525
|
res.on("end", () => {
|
|
11526
11526
|
resolve(import_buffer2.Buffer.concat(chunks));
|
|
@@ -19822,7 +19822,7 @@ var require_lodash = __commonJS({
|
|
|
19822
19822
|
result2.__values__ = wrapper.__values__;
|
|
19823
19823
|
return result2;
|
|
19824
19824
|
}
|
|
19825
|
-
function
|
|
19825
|
+
function chunk3(array, size2, guard) {
|
|
19826
19826
|
if (guard ? isIterateeCall(array, size2, guard) : size2 === undefined2) {
|
|
19827
19827
|
size2 = 1;
|
|
19828
19828
|
} else {
|
|
@@ -21694,7 +21694,7 @@ var require_lodash = __commonJS({
|
|
|
21694
21694
|
lodash.bindKey = bindKey;
|
|
21695
21695
|
lodash.castArray = castArray;
|
|
21696
21696
|
lodash.chain = chain2;
|
|
21697
|
-
lodash.chunk =
|
|
21697
|
+
lodash.chunk = chunk3;
|
|
21698
21698
|
lodash.compact = compact;
|
|
21699
21699
|
lodash.concat = concat;
|
|
21700
21700
|
lodash.cond = cond;
|
|
@@ -22178,7 +22178,6 @@ __export(index_exports, {
|
|
|
22178
22178
|
EventNamesByCategory: () => EventNamesByCategory,
|
|
22179
22179
|
NotificationCategoryList: () => NotificationCategoryList,
|
|
22180
22180
|
NotificationDefaultChannels: () => NotificationDefaultChannels,
|
|
22181
|
-
NotificationTemplateCategories: () => NotificationTemplateCategories,
|
|
22182
22181
|
ObjectId: () => import_mongodb2.ObjectId,
|
|
22183
22182
|
api: () => api_default,
|
|
22184
22183
|
consumption: () => consumption_exports,
|
|
@@ -22449,19 +22448,6 @@ var api_default = (auth, instanceOptions = {}) => {
|
|
|
22449
22448
|
removeAccount: factory.remove(etainablApi, "accounts"),
|
|
22450
22449
|
getAccountSchema: factory.get(etainablApi, "accounts", "schema"),
|
|
22451
22450
|
invalidateAccountCache: factory.customWithId(etainablApi, "put", "accounts", "invalidate-cache"),
|
|
22452
|
-
// alert triggers
|
|
22453
|
-
getAlertTrigger: factory.getWithId(etainablApi, "alert-triggers"),
|
|
22454
|
-
listAlertTriggers: factory.list(etainablApi, "alert-triggers"),
|
|
22455
|
-
updateAlertTrigger: factory.update(etainablApi, "alert-triggers"),
|
|
22456
|
-
createAlertTrigger: factory.create(etainablApi, "alert-triggers"),
|
|
22457
|
-
removeAlertTrigger: factory.remove(etainablApi, "alert-triggers"),
|
|
22458
|
-
bulkUpdateAlertTriggers: factory.create(
|
|
22459
|
-
etainablApi,
|
|
22460
|
-
"alert-triggers",
|
|
22461
|
-
"bulk-update"
|
|
22462
|
-
),
|
|
22463
|
-
retryAlertTrigger: factory.customWithId(etainablApi, "post", "alert-triggers", "retry"),
|
|
22464
|
-
cancelAlertTrigger: factory.customWithId(etainablApi, "post", "alert-triggers", "cancel"),
|
|
22465
22451
|
// custom alert triggers
|
|
22466
22452
|
getCustomAlertTrigger: factory.getWithId(etainablApi, "custom-alert-triggers"),
|
|
22467
22453
|
listCustomAlertTriggers: factory.list(etainablApi, "custom-alert-triggers"),
|
|
@@ -22860,28 +22846,28 @@ var emailTemplate_default = (options) => {
|
|
|
22860
22846
|
var import_mjml = __toESM(require("mjml"), 1);
|
|
22861
22847
|
var severityConfig = {
|
|
22862
22848
|
error: {
|
|
22863
|
-
color: "#
|
|
22864
|
-
bgColor: "#
|
|
22849
|
+
color: "#FFFFFF",
|
|
22850
|
+
bgColor: "#e04f1a",
|
|
22865
22851
|
label: "ERROR"
|
|
22866
22852
|
},
|
|
22867
22853
|
success: {
|
|
22868
|
-
color: "#
|
|
22869
|
-
bgColor: "#
|
|
22854
|
+
color: "#FFFFFF",
|
|
22855
|
+
bgColor: "#82b54b",
|
|
22870
22856
|
label: "SUCCESS"
|
|
22871
22857
|
},
|
|
22872
22858
|
warning: {
|
|
22873
|
-
color: "#
|
|
22874
|
-
bgColor: "#
|
|
22859
|
+
color: "#FFFFFF",
|
|
22860
|
+
bgColor: "#ff9f43",
|
|
22875
22861
|
label: "WARNING"
|
|
22876
22862
|
},
|
|
22877
22863
|
tip: {
|
|
22878
|
-
color: "#
|
|
22879
|
-
bgColor: "#
|
|
22864
|
+
color: "#FFFFFF",
|
|
22865
|
+
bgColor: "#00bad1",
|
|
22880
22866
|
label: "TIP"
|
|
22881
22867
|
},
|
|
22882
22868
|
info: {
|
|
22883
|
-
color: "#
|
|
22884
|
-
bgColor: "#
|
|
22869
|
+
color: "#FFFFFF",
|
|
22870
|
+
bgColor: "#5ECFB1",
|
|
22885
22871
|
label: "INFO"
|
|
22886
22872
|
}
|
|
22887
22873
|
};
|
|
@@ -22889,13 +22875,17 @@ function generateNotificationEmail(options) {
|
|
|
22889
22875
|
if (!process.env.ETAINABL_UI_URL) {
|
|
22890
22876
|
throw new Error("ETAINABL_UI_URL environment variable is not set");
|
|
22891
22877
|
}
|
|
22892
|
-
const { title, message, severity = "info", category = "Notification", actions = [], metadata = {} } = options;
|
|
22878
|
+
const { title, message, severity = "info", category = "Notification", actions = [], metadata = {}, items = [] } = options;
|
|
22893
22879
|
const config = severityConfig[severity];
|
|
22880
|
+
const isSingleItem = items.length === 1;
|
|
22881
|
+
const hasMultipleItems = items.length > 1;
|
|
22882
|
+
const mainTitle = isSingleItem && items[0]?.message ? items[0].message : message;
|
|
22883
|
+
const subtitle = isSingleItem ? message : title;
|
|
22894
22884
|
const mjmlTemplate = `
|
|
22895
22885
|
<mjml>
|
|
22896
22886
|
<mj-head>
|
|
22897
|
-
<mj-title>${
|
|
22898
|
-
<mj-preview>${
|
|
22887
|
+
<mj-title>${mainTitle}</mj-title>
|
|
22888
|
+
<mj-preview>${subtitle}</mj-preview>
|
|
22899
22889
|
|
|
22900
22890
|
<mj-attributes>
|
|
22901
22891
|
<mj-all font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif" />
|
|
@@ -22906,9 +22896,9 @@ function generateNotificationEmail(options) {
|
|
|
22906
22896
|
<mj-style inline="inline">
|
|
22907
22897
|
.severity-badge {
|
|
22908
22898
|
display: inline-block;
|
|
22909
|
-
padding:
|
|
22910
|
-
border-radius:
|
|
22911
|
-
font-size:
|
|
22899
|
+
padding: 2px 6px;
|
|
22900
|
+
border-radius: 6px;
|
|
22901
|
+
font-size: 9px;
|
|
22912
22902
|
font-weight: 600;
|
|
22913
22903
|
letter-spacing: 0.5px;
|
|
22914
22904
|
background-color: ${config.bgColor};
|
|
@@ -22950,7 +22940,7 @@ function generateNotificationEmail(options) {
|
|
|
22950
22940
|
</mj-section>
|
|
22951
22941
|
|
|
22952
22942
|
<!-- Spacer -->
|
|
22953
|
-
<mj-section background-color="#F3F4F6" padding="
|
|
22943
|
+
<mj-section background-color="#F3F4F6" padding="6px 0">
|
|
22954
22944
|
<mj-column>
|
|
22955
22945
|
<mj-text></mj-text>
|
|
22956
22946
|
</mj-column>
|
|
@@ -22973,23 +22963,60 @@ function generateNotificationEmail(options) {
|
|
|
22973
22963
|
</mj-column>
|
|
22974
22964
|
</mj-section>
|
|
22975
22965
|
|
|
22976
|
-
<!--
|
|
22966
|
+
<!-- Main Title -->
|
|
22977
22967
|
<mj-section padding="0 32px 8px 32px">
|
|
22978
22968
|
<mj-column>
|
|
22979
22969
|
<mj-text font-size="24px" font-weight="600" color="#1F2937" line-height="1.3" padding="0">
|
|
22980
|
-
${
|
|
22970
|
+
${mainTitle}
|
|
22981
22971
|
</mj-text>
|
|
22982
22972
|
</mj-column>
|
|
22983
22973
|
</mj-section>
|
|
22984
22974
|
|
|
22985
|
-
<!--
|
|
22975
|
+
<!-- Subtitle -->
|
|
22986
22976
|
<mj-section padding="0 32px 24px 32px">
|
|
22987
22977
|
<mj-column>
|
|
22988
22978
|
<mj-text font-size="14px" color="#6B7280" padding="0">
|
|
22989
|
-
${
|
|
22979
|
+
${subtitle}
|
|
22980
|
+
</mj-text>
|
|
22981
|
+
</mj-column>
|
|
22982
|
+
</mj-section>
|
|
22983
|
+
|
|
22984
|
+
${hasMultipleItems ? (() => {
|
|
22985
|
+
const maxItems = 3;
|
|
22986
|
+
const displayItems = items.slice(0, maxItems);
|
|
22987
|
+
const remainingCount = items.length - maxItems;
|
|
22988
|
+
return `
|
|
22989
|
+
<!-- Items List -->
|
|
22990
|
+
<mj-section padding="0 32px 24px 32px">
|
|
22991
|
+
<mj-column>
|
|
22992
|
+
<mj-text padding="0">
|
|
22993
|
+
<table style="width: 100%; border-collapse: collapse;">
|
|
22994
|
+
${displayItems.map(
|
|
22995
|
+
(item) => `
|
|
22996
|
+
<tr>
|
|
22997
|
+
<td style="padding: 0 0 8px 0;">
|
|
22998
|
+
<table style="width: 100%; border-collapse: collapse; background-color: #F9FAFB; border-radius: 6px; overflow: hidden;">
|
|
22999
|
+
<tr>
|
|
23000
|
+
<td style="width: 6px; background-color: #5ECFB1; border-radius: 10px;"></td>
|
|
23001
|
+
<td style="padding: 16px;">
|
|
23002
|
+
<span style="color: #1F2937; font-size: 14px; line-height: 1.5;">${item.message}</span>
|
|
23003
|
+
</td>
|
|
23004
|
+
</tr>
|
|
23005
|
+
</table>
|
|
23006
|
+
</td>
|
|
23007
|
+
</tr>`
|
|
23008
|
+
).join("")}${remainingCount > 0 ? `
|
|
23009
|
+
<tr>
|
|
23010
|
+
<td style="padding: 8px 0 0 0;">
|
|
23011
|
+
<span style="color: #6B7280; font-size: 13px; font-style: italic;">and ${remainingCount} more item${remainingCount === 1 ? "" : "s"}...</span>
|
|
23012
|
+
</td>
|
|
23013
|
+
</tr>` : ""}
|
|
23014
|
+
</table>
|
|
22990
23015
|
</mj-text>
|
|
22991
23016
|
</mj-column>
|
|
22992
23017
|
</mj-section>
|
|
23018
|
+
`;
|
|
23019
|
+
})() : ""}
|
|
22993
23020
|
|
|
22994
23021
|
${Object.keys(metadata).length > 0 ? `
|
|
22995
23022
|
<!-- Metadata Section -->
|
|
@@ -23042,7 +23069,7 @@ function generateNotificationEmail(options) {
|
|
|
23042
23069
|
<mj-section padding="0 32px 24px 32px">
|
|
23043
23070
|
<mj-column>
|
|
23044
23071
|
<mj-button
|
|
23045
|
-
background-color="#
|
|
23072
|
+
background-color="#65c198"
|
|
23046
23073
|
color="#FFFFFF"
|
|
23047
23074
|
border-radius="6px"
|
|
23048
23075
|
font-weight="600"
|
|
@@ -23087,7 +23114,7 @@ function generateNotificationEmail(options) {
|
|
|
23087
23114
|
<a href="${process.env.ETAINABL_UI_URL}/messages/notifications" style="color: #5ECFB1; text-decoration: none;">Manage notification preferences</a>
|
|
23088
23115
|
</mj-text>
|
|
23089
23116
|
<mj-text align="center" font-size="11px" color="#9CA3AF" padding-top="16px">
|
|
23090
|
-
\xA9 ${(/* @__PURE__ */ new Date()).getFullYear()} Etainabl. All rights reserved.
|
|
23117
|
+
\xA9 ${(/* @__PURE__ */ new Date()).getFullYear()} Etainabl Ltd. All rights reserved.
|
|
23091
23118
|
</mj-text>
|
|
23092
23119
|
</mj-column>
|
|
23093
23120
|
</mj-section>
|
|
@@ -24773,9 +24800,7 @@ async function sendNotificationMessageBatch({
|
|
|
24773
24800
|
const results = await import_bluebird.default.mapSeries(chunks, async (batch) => {
|
|
24774
24801
|
const entries = batch.map((msg, index) => ({
|
|
24775
24802
|
Id: `msg-${index}`,
|
|
24776
|
-
MessageBody: JSON.stringify(
|
|
24777
|
-
createNotificationMessage(msg.eventName, msg.context, msg.input)
|
|
24778
|
-
)
|
|
24803
|
+
MessageBody: JSON.stringify(createNotificationMessage(msg.eventName, msg.context, msg.input))
|
|
24779
24804
|
}));
|
|
24780
24805
|
const command = new SendMessageBatchCommand({
|
|
24781
24806
|
QueueUrl: queueUrl,
|
|
@@ -25077,7 +25102,10 @@ __export(utils_exports, {
|
|
|
25077
25102
|
automationSources: () => automationSources,
|
|
25078
25103
|
getMeterPointNumberBottomLine: () => getMeterPointNumberBottomLine,
|
|
25079
25104
|
isTransientError: () => isTransientError2,
|
|
25105
|
+
paginatedFetch: () => paginatedFetch,
|
|
25106
|
+
sendToSqsBatched: () => sendToSqsBatched,
|
|
25080
25107
|
units: () => units,
|
|
25108
|
+
updateBatchJobStatus: () => updateBatchJobStatus,
|
|
25081
25109
|
utilityTypes: () => utilityTypes,
|
|
25082
25110
|
wasteCategories: () => wasteCategories
|
|
25083
25111
|
});
|
|
@@ -25384,6 +25412,63 @@ var getMeterPointNumberBottomLine = (meterPointNumber) => {
|
|
|
25384
25412
|
return "";
|
|
25385
25413
|
};
|
|
25386
25414
|
|
|
25415
|
+
// src/utils/job.ts
|
|
25416
|
+
async function updateBatchJobStatus({
|
|
25417
|
+
etnApi,
|
|
25418
|
+
automationRun,
|
|
25419
|
+
accountKey,
|
|
25420
|
+
status,
|
|
25421
|
+
errorMessage
|
|
25422
|
+
}) {
|
|
25423
|
+
if (!automationRun) return;
|
|
25424
|
+
const jobKey = automationRun.jobId;
|
|
25425
|
+
const resolvedAccountKey = accountKey ?? automationRun.accountResults?.[0]?.id?.toString();
|
|
25426
|
+
if (!jobKey || !resolvedAccountKey) return;
|
|
25427
|
+
let jobEntry;
|
|
25428
|
+
try {
|
|
25429
|
+
jobEntry = await etnApi.getJob(jobKey);
|
|
25430
|
+
} catch (error) {
|
|
25431
|
+
console.error("Failed to fetch job for status update", {
|
|
25432
|
+
jobKey,
|
|
25433
|
+
accountKey: resolvedAccountKey,
|
|
25434
|
+
error
|
|
25435
|
+
});
|
|
25436
|
+
return;
|
|
25437
|
+
}
|
|
25438
|
+
if (!jobEntry || jobEntry.status === "completed" || jobEntry.status === "failed") return;
|
|
25439
|
+
const metadata = jobEntry.metadata ?? {};
|
|
25440
|
+
const completedAccountKeys = new Set(metadata.completedAccountKeys ?? []);
|
|
25441
|
+
const failedAccountKeys = new Set(metadata.failedAccountKeys ?? []);
|
|
25442
|
+
const { accountCount } = metadata;
|
|
25443
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
25444
|
+
if (status === "failed") {
|
|
25445
|
+
failedAccountKeys.add(resolvedAccountKey);
|
|
25446
|
+
} else {
|
|
25447
|
+
completedAccountKeys.add(resolvedAccountKey);
|
|
25448
|
+
}
|
|
25449
|
+
const updatePayload = {
|
|
25450
|
+
metadata: {
|
|
25451
|
+
...metadata,
|
|
25452
|
+
completedAccountKeys: Array.from(completedAccountKeys),
|
|
25453
|
+
failedAccountKeys: Array.from(failedAccountKeys),
|
|
25454
|
+
completedCount: completedAccountKeys.size,
|
|
25455
|
+
failedCount: failedAccountKeys.size
|
|
25456
|
+
}
|
|
25457
|
+
};
|
|
25458
|
+
const totalProcessed = completedAccountKeys.size + failedAccountKeys.size;
|
|
25459
|
+
const hasFailures = failedAccountKeys.size > 0;
|
|
25460
|
+
if (status === "failed") {
|
|
25461
|
+
updatePayload.metadata = { ...updatePayload.metadata, result: "failed" };
|
|
25462
|
+
updatePayload.error = errorMessage || "Automation run failed";
|
|
25463
|
+
}
|
|
25464
|
+
if (accountCount && totalProcessed >= accountCount) {
|
|
25465
|
+
updatePayload.status = "completed";
|
|
25466
|
+
updatePayload.completedAt = now;
|
|
25467
|
+
updatePayload.metadata = { ...updatePayload.metadata, result: hasFailures ? "failed" : "success" };
|
|
25468
|
+
}
|
|
25469
|
+
await etnApi.updateJob(jobEntry._id, updatePayload);
|
|
25470
|
+
}
|
|
25471
|
+
|
|
25387
25472
|
// node_modules/@aws-sdk/middleware-expect-continue/dist-es/index.js
|
|
25388
25473
|
init_dist_es2();
|
|
25389
25474
|
function addExpectContinueMiddleware(options) {
|
|
@@ -28766,9 +28851,9 @@ var HeaderMarshaller = class {
|
|
|
28766
28851
|
}
|
|
28767
28852
|
const out = new Uint8Array(chunks.reduce((carry, bytes) => carry + bytes.byteLength, 0));
|
|
28768
28853
|
let position = 0;
|
|
28769
|
-
for (const
|
|
28770
|
-
out.set(
|
|
28771
|
-
position +=
|
|
28854
|
+
for (const chunk3 of chunks) {
|
|
28855
|
+
out.set(chunk3, position);
|
|
28856
|
+
position += chunk3.byteLength;
|
|
28772
28857
|
}
|
|
28773
28858
|
return out;
|
|
28774
28859
|
}
|
|
@@ -29088,8 +29173,8 @@ var SmithyMessageEncoderStream = class {
|
|
|
29088
29173
|
return this.asyncIterator();
|
|
29089
29174
|
}
|
|
29090
29175
|
async *asyncIterator() {
|
|
29091
|
-
for await (const
|
|
29092
|
-
const payloadBuf = this.options.serializer(
|
|
29176
|
+
for await (const chunk3 of this.options.inputStream) {
|
|
29177
|
+
const payloadBuf = this.options.serializer(chunk3);
|
|
29093
29178
|
yield payloadBuf;
|
|
29094
29179
|
}
|
|
29095
29180
|
}
|
|
@@ -29277,9 +29362,9 @@ var HashCalculator = class extends import_stream10.Writable {
|
|
|
29277
29362
|
super(options);
|
|
29278
29363
|
this.hash = hash;
|
|
29279
29364
|
}
|
|
29280
|
-
_write(
|
|
29365
|
+
_write(chunk3, encoding, callback) {
|
|
29281
29366
|
try {
|
|
29282
|
-
this.hash.update(toUint8Array(
|
|
29367
|
+
this.hash.update(toUint8Array(chunk3));
|
|
29283
29368
|
} catch (err) {
|
|
29284
29369
|
return callback(err);
|
|
29285
29370
|
}
|
|
@@ -29901,6 +29986,54 @@ function isTransientError2(error) {
|
|
|
29901
29986
|
return false;
|
|
29902
29987
|
}
|
|
29903
29988
|
|
|
29989
|
+
// src/utils/pagination.ts
|
|
29990
|
+
var paginatedFetch = async (fetchPage, options = {}) => {
|
|
29991
|
+
const { pageSize = 100 } = options;
|
|
29992
|
+
const fetchAllPages = async (skip, accumulated) => {
|
|
29993
|
+
const response = await fetchPage({ $limit: pageSize, $skip: skip });
|
|
29994
|
+
accumulated.push(...response.data);
|
|
29995
|
+
return response.data.length < pageSize ? accumulated : fetchAllPages(skip + pageSize, accumulated);
|
|
29996
|
+
};
|
|
29997
|
+
return fetchAllPages(0, []);
|
|
29998
|
+
};
|
|
29999
|
+
|
|
30000
|
+
// src/utils/sqs.ts
|
|
30001
|
+
var import_bluebird2 = __toESM(require("bluebird"), 1);
|
|
30002
|
+
var import_lodash2 = __toESM(require_lodash(), 1);
|
|
30003
|
+
var sendToSqsBatched = async (messages, options) => {
|
|
30004
|
+
const { queueUrl, concurrency = 5, batchSize = 10 } = options;
|
|
30005
|
+
const sqsClient = options.sqsClient ?? new SQSClient({ region: "eu-west-1" });
|
|
30006
|
+
if (messages.length === 0) {
|
|
30007
|
+
return { successful: 0, failed: 0 };
|
|
30008
|
+
}
|
|
30009
|
+
const batches = (0, import_lodash2.chunk)(messages, batchSize);
|
|
30010
|
+
let successful = 0;
|
|
30011
|
+
let failed = 0;
|
|
30012
|
+
await import_bluebird2.default.map(
|
|
30013
|
+
batches,
|
|
30014
|
+
async (batch, batchIndex) => {
|
|
30015
|
+
const entries = batch.map((message, index) => ({
|
|
30016
|
+
Id: message.id ?? `msg_${batchIndex}_${index}`,
|
|
30017
|
+
MessageBody: JSON.stringify(message.body),
|
|
30018
|
+
...message.attributes && { MessageAttributes: message.attributes }
|
|
30019
|
+
}));
|
|
30020
|
+
const response = await sqsClient.send(
|
|
30021
|
+
new SendMessageBatchCommand({
|
|
30022
|
+
QueueUrl: queueUrl,
|
|
30023
|
+
Entries: entries
|
|
30024
|
+
})
|
|
30025
|
+
);
|
|
30026
|
+
successful += response.Successful?.length ?? 0;
|
|
30027
|
+
if (response.Failed && response.Failed.length > 0) {
|
|
30028
|
+
failed += response.Failed.length;
|
|
30029
|
+
throw new Error(`Failed to send ${response.Failed.length} SQS messages in batch ${batchIndex}`);
|
|
30030
|
+
}
|
|
30031
|
+
},
|
|
30032
|
+
{ concurrency }
|
|
30033
|
+
);
|
|
30034
|
+
return { successful, failed };
|
|
30035
|
+
};
|
|
30036
|
+
|
|
29904
30037
|
// src/openai/index.ts
|
|
29905
30038
|
var openai_exports = {};
|
|
29906
30039
|
__export(openai_exports, {
|
|
@@ -32056,7 +32189,16 @@ var errorCodeMap = {
|
|
|
32056
32189
|
unique: true
|
|
32057
32190
|
}
|
|
32058
32191
|
};
|
|
32059
|
-
var dataFetchersIds = [
|
|
32192
|
+
var dataFetchersIds = [
|
|
32193
|
+
"bacnet",
|
|
32194
|
+
"solis",
|
|
32195
|
+
"solarman",
|
|
32196
|
+
"gridfetch",
|
|
32197
|
+
"smartflow",
|
|
32198
|
+
"smartvatten",
|
|
32199
|
+
"beringar",
|
|
32200
|
+
"4dmonitoring"
|
|
32201
|
+
];
|
|
32060
32202
|
function sendEmail(lambdaSource, context, error, destinations) {
|
|
32061
32203
|
const sesClient = new SESClient({ region: "eu-west-1" });
|
|
32062
32204
|
const template = emailTemplate_default({
|
|
@@ -32185,6 +32327,15 @@ async function handleError({ context, etnApi, automationRun, error, lambdaSource
|
|
|
32185
32327
|
if (automationRun.category === "account" && accountId) {
|
|
32186
32328
|
await etnApi.updateAccountStatusForAutomation(automation._id, accountId, { status: "error", error: error.message });
|
|
32187
32329
|
}
|
|
32330
|
+
if (automation.category === "account") {
|
|
32331
|
+
await updateBatchJobStatus({
|
|
32332
|
+
etnApi,
|
|
32333
|
+
automationRun,
|
|
32334
|
+
accountKey: accountId,
|
|
32335
|
+
status: "failed",
|
|
32336
|
+
errorMessage: error.message
|
|
32337
|
+
});
|
|
32338
|
+
}
|
|
32188
32339
|
}
|
|
32189
32340
|
async function deleteMessage(queueUrl, receiptHandle, sqsClient) {
|
|
32190
32341
|
if (!queueUrl || !receiptHandle) {
|
|
@@ -32223,28 +32374,19 @@ var NotificationDefaultChannels = {
|
|
|
32223
32374
|
};
|
|
32224
32375
|
|
|
32225
32376
|
// src/types/notificationTemplate.ts
|
|
32226
|
-
var NotificationTemplateCategories = [
|
|
32227
|
-
"automation",
|
|
32228
|
-
"report",
|
|
32229
|
-
"team",
|
|
32230
|
-
"dataQuality",
|
|
32231
|
-
"discussion",
|
|
32232
|
-
"scraper"
|
|
32233
|
-
];
|
|
32234
32377
|
var EventNamesByCategory = {
|
|
32235
|
-
automation: ["automationFailed", "
|
|
32378
|
+
automation: ["automationFailed", "automationCompleted", "automationOverdue", "automationExtractorOverdue"],
|
|
32236
32379
|
report: ["reportSuccess", "reportFailed"],
|
|
32237
32380
|
team: ["newUserSignIn"],
|
|
32238
|
-
dataQuality: ["
|
|
32239
|
-
discussion: ["
|
|
32240
|
-
scraper: ["scraperLoginError", "
|
|
32381
|
+
dataQuality: ["invoiceOverdue", "contractOverdue", "contractDueSoon", "readingOverdue", "readingDueSoon"],
|
|
32382
|
+
discussion: ["newDiscussionReply", "userAssignedToDiscussion", "discussionMessageDue"],
|
|
32383
|
+
scraper: ["scraperLoginError", "scraperHasNotRun", "scraperRunCompleted"]
|
|
32241
32384
|
};
|
|
32242
32385
|
// Annotate the CommonJS export names for ESM import in node:
|
|
32243
32386
|
0 && (module.exports = {
|
|
32244
32387
|
EventNamesByCategory,
|
|
32245
32388
|
NotificationCategoryList,
|
|
32246
32389
|
NotificationDefaultChannels,
|
|
32247
|
-
NotificationTemplateCategories,
|
|
32248
32390
|
ObjectId,
|
|
32249
32391
|
api,
|
|
32250
32392
|
consumption,
|