@etainabl/nodejs-sdk 1.3.184 → 1.3.186
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 +83 -24
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.cts +77 -70
- package/dist/index.d.ts +77 -70
- package/dist/index.js +83 -24
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -8901,6 +8901,7 @@ __export(utils_exports, {
|
|
|
8901
8901
|
getMeterPointNumberBottomLine: () => getMeterPointNumberBottomLine,
|
|
8902
8902
|
isTransientError: () => isTransientError,
|
|
8903
8903
|
paginatedFetch: () => paginatedFetch,
|
|
8904
|
+
resolveNotificationPreferences: () => resolveNotificationPreferences,
|
|
8904
8905
|
sendToSqsBatched: () => sendToSqsBatched,
|
|
8905
8906
|
units: () => units,
|
|
8906
8907
|
updateBatchJobStatus: () => updateBatchJobStatus,
|
|
@@ -9219,6 +9220,7 @@ async function updateBatchJobStatus({
|
|
|
9219
9220
|
errorMessage
|
|
9220
9221
|
}) {
|
|
9221
9222
|
if (!automationRun) return;
|
|
9223
|
+
if (automationRun.category !== "account") return;
|
|
9222
9224
|
const jobKey = automationRun.jobId;
|
|
9223
9225
|
const resolvedAccountKey = accountKey ?? automationRun.accountResults?.[0]?.id?.toString();
|
|
9224
9226
|
if (!jobKey || !resolvedAccountKey) return;
|
|
@@ -13710,6 +13712,80 @@ var sendToSqsBatched = async (messages, options) => {
|
|
|
13710
13712
|
return { successful, failed };
|
|
13711
13713
|
};
|
|
13712
13714
|
|
|
13715
|
+
// src/types/notification.ts
|
|
13716
|
+
var NotificationCategoryList = [
|
|
13717
|
+
"automation",
|
|
13718
|
+
"report",
|
|
13719
|
+
"team",
|
|
13720
|
+
"dataQuality",
|
|
13721
|
+
"discussion",
|
|
13722
|
+
"scraper"
|
|
13723
|
+
];
|
|
13724
|
+
var NotificationDefaultChannels = {
|
|
13725
|
+
inApp: true,
|
|
13726
|
+
email: false,
|
|
13727
|
+
sms: false
|
|
13728
|
+
};
|
|
13729
|
+
|
|
13730
|
+
// src/utils/notification.ts
|
|
13731
|
+
function extractTemplates(source) {
|
|
13732
|
+
if (!source) return {};
|
|
13733
|
+
const templates = source.templates !== void 0 ? source.templates : source;
|
|
13734
|
+
if (templates && typeof templates === "object" && !Array.isArray(templates)) {
|
|
13735
|
+
return { ...templates };
|
|
13736
|
+
}
|
|
13737
|
+
return {};
|
|
13738
|
+
}
|
|
13739
|
+
function resolveNotificationPreferences(userPreferences, systemTemplates) {
|
|
13740
|
+
const prefs = userPreferences || {};
|
|
13741
|
+
const userCategories = prefs.categories || {};
|
|
13742
|
+
const userChannels = prefs.channels || {};
|
|
13743
|
+
const globalChannels = {
|
|
13744
|
+
inApp: userChannels.inApp !== void 0 ? userChannels.inApp : NotificationDefaultChannels.inApp,
|
|
13745
|
+
sms: userChannels.sms !== void 0 ? userChannels.sms : NotificationDefaultChannels.sms,
|
|
13746
|
+
email: userChannels.email !== void 0 ? userChannels.email : NotificationDefaultChannels.email
|
|
13747
|
+
};
|
|
13748
|
+
const convertTemplateToStringId = (template) => ({
|
|
13749
|
+
...template,
|
|
13750
|
+
_id: template._id.toString()
|
|
13751
|
+
});
|
|
13752
|
+
const templatesByCategory = systemTemplates.reduce(
|
|
13753
|
+
(acc, template) => {
|
|
13754
|
+
const cat = template.category || "uncategorised";
|
|
13755
|
+
if (!acc[cat]) acc[cat] = [];
|
|
13756
|
+
acc[cat].push(convertTemplateToStringId(template));
|
|
13757
|
+
return acc;
|
|
13758
|
+
},
|
|
13759
|
+
{}
|
|
13760
|
+
);
|
|
13761
|
+
const categories = NotificationCategoryList.reduce(
|
|
13762
|
+
(acc, category) => {
|
|
13763
|
+
const userCategory = userCategories[category] || {};
|
|
13764
|
+
const userCategoryChannels = userCategory.channels || {};
|
|
13765
|
+
const userTemplates = extractTemplates(userCategory);
|
|
13766
|
+
const templateList = templatesByCategory[category] || [];
|
|
13767
|
+
acc[category] = {
|
|
13768
|
+
channels: {
|
|
13769
|
+
inApp: userCategoryChannels.inApp !== void 0 ? userCategoryChannels.inApp : NotificationDefaultChannels.inApp,
|
|
13770
|
+
sms: userCategoryChannels.sms !== void 0 ? userCategoryChannels.sms : NotificationDefaultChannels.sms,
|
|
13771
|
+
email: userCategoryChannels.email !== void 0 ? userCategoryChannels.email : NotificationDefaultChannels.email
|
|
13772
|
+
},
|
|
13773
|
+
templates: templateList.map((template) => ({
|
|
13774
|
+
_id: template._id,
|
|
13775
|
+
name: template.name,
|
|
13776
|
+
description: template.description,
|
|
13777
|
+
category: template.category,
|
|
13778
|
+
severity: template.severity,
|
|
13779
|
+
enabled: userTemplates[template._id] !== void 0 ? userTemplates[template._id] : template.enabledByDefault ?? true
|
|
13780
|
+
}))
|
|
13781
|
+
};
|
|
13782
|
+
return acc;
|
|
13783
|
+
},
|
|
13784
|
+
{}
|
|
13785
|
+
);
|
|
13786
|
+
return { channels: globalChannels, categories };
|
|
13787
|
+
}
|
|
13788
|
+
|
|
13713
13789
|
// src/openai/index.ts
|
|
13714
13790
|
var openai_exports = {};
|
|
13715
13791
|
__export(openai_exports, {
|
|
@@ -15950,15 +16026,13 @@ async function handleError({ context, etnApi, automationRun, error, lambdaSource
|
|
|
15950
16026
|
if (automationRun.category === "account" && accountId) {
|
|
15951
16027
|
await etnApi.updateAccountStatusForAutomation(automation._id, accountId, { status: "error", error: error.message });
|
|
15952
16028
|
}
|
|
15953
|
-
|
|
15954
|
-
|
|
15955
|
-
|
|
15956
|
-
|
|
15957
|
-
|
|
15958
|
-
|
|
15959
|
-
|
|
15960
|
-
});
|
|
15961
|
-
}
|
|
16029
|
+
await updateBatchJobStatus({
|
|
16030
|
+
etnApi,
|
|
16031
|
+
automationRun,
|
|
16032
|
+
accountKey: accountId,
|
|
16033
|
+
status: "failed",
|
|
16034
|
+
errorMessage: error.message
|
|
16035
|
+
});
|
|
15962
16036
|
}
|
|
15963
16037
|
async function deleteMessage(queueUrl, receiptHandle, sqsClient) {
|
|
15964
16038
|
if (!queueUrl || !receiptHandle) {
|
|
@@ -15981,21 +16055,6 @@ var scrapers_exports = {};
|
|
|
15981
16055
|
// src/types/index.ts
|
|
15982
16056
|
import { ObjectId } from "mongodb";
|
|
15983
16057
|
|
|
15984
|
-
// src/types/notification.ts
|
|
15985
|
-
var NotificationCategoryList = [
|
|
15986
|
-
"automation",
|
|
15987
|
-
"report",
|
|
15988
|
-
"team",
|
|
15989
|
-
"dataQuality",
|
|
15990
|
-
"discussion",
|
|
15991
|
-
"scraper"
|
|
15992
|
-
];
|
|
15993
|
-
var NotificationDefaultChannels = {
|
|
15994
|
-
inApp: true,
|
|
15995
|
-
email: false,
|
|
15996
|
-
sms: false
|
|
15997
|
-
};
|
|
15998
|
-
|
|
15999
16058
|
// src/types/notificationTemplate.ts
|
|
16000
16059
|
var EventNamesByCategory = {
|
|
16001
16060
|
automation: ["automationFailed", "automationCompleted", "automationOverdue", "automationExtractorOverdue"],
|