av6-core 1.1.13 → 1.2.0
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.js +27 -11
- package/dist/index.mjs +27 -11
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1873,6 +1873,10 @@ var NotificationService = class {
|
|
|
1873
1873
|
this.logger.info(`[NotificationService] No config for event=${evt.shortCode} service=${evt.service}`);
|
|
1874
1874
|
throw new this.helpers.ErrorHandler(400, this.helpers.generateErrorMessage("NOT_FOUND", evt.shortCode));
|
|
1875
1875
|
}
|
|
1876
|
+
if (!cfg.serviceEvent.id) {
|
|
1877
|
+
this.logger.info(`[NotificationService] No event found for event=${evt.shortCode} service=${evt.service}`);
|
|
1878
|
+
throw new this.helpers.ErrorHandler(400, this.helpers.generateErrorMessage("NOT_FOUND", evt.shortCode));
|
|
1879
|
+
}
|
|
1876
1880
|
this.logger.info(`[NotificationService] Loaded config: ${JSON.stringify(cfg)}`);
|
|
1877
1881
|
let emailTpl = null;
|
|
1878
1882
|
if (cfg.allowEmail && cfg.serviceEvent.allowEmail && cfg.emailTemplateId) {
|
|
@@ -1907,7 +1911,7 @@ var NotificationService = class {
|
|
|
1907
1911
|
const waProvider = new WhatsAppProvider(
|
|
1908
1912
|
{
|
|
1909
1913
|
apiUrl: cfg.serviceEvent.wpApiUrl,
|
|
1910
|
-
templateName: waTpl
|
|
1914
|
+
templateName: waTpl?.templateCode ?? "",
|
|
1911
1915
|
callbackData: "",
|
|
1912
1916
|
countryCode: cfg.serviceEvent.countryCode,
|
|
1913
1917
|
languageCode: "en",
|
|
@@ -1928,7 +1932,10 @@ var NotificationService = class {
|
|
|
1928
1932
|
providerType: "EMAIL" /* EMAIL */,
|
|
1929
1933
|
provider: emailProvider,
|
|
1930
1934
|
eventConfigId: cfg.id,
|
|
1931
|
-
evt
|
|
1935
|
+
evt: {
|
|
1936
|
+
...evt,
|
|
1937
|
+
eventId: cfg?.serviceEvent?.id
|
|
1938
|
+
},
|
|
1932
1939
|
subject: msg.subject,
|
|
1933
1940
|
body: msg.body,
|
|
1934
1941
|
priority: evt.priority
|
|
@@ -1942,7 +1949,10 @@ var NotificationService = class {
|
|
|
1942
1949
|
providerType: "SMS" /* SMS */,
|
|
1943
1950
|
provider: smsProvider,
|
|
1944
1951
|
eventConfigId: cfg.id,
|
|
1945
|
-
evt
|
|
1952
|
+
evt: {
|
|
1953
|
+
...evt,
|
|
1954
|
+
eventId: cfg?.serviceEvent?.id
|
|
1955
|
+
},
|
|
1946
1956
|
body: msg
|
|
1947
1957
|
})
|
|
1948
1958
|
);
|
|
@@ -1952,7 +1962,10 @@ var NotificationService = class {
|
|
|
1952
1962
|
this.sendWhatsAppMessage({
|
|
1953
1963
|
provider: waProvider,
|
|
1954
1964
|
eventConfigId: cfg.id,
|
|
1955
|
-
evt
|
|
1965
|
+
evt: {
|
|
1966
|
+
...evt,
|
|
1967
|
+
eventId: cfg?.serviceEvent?.id
|
|
1968
|
+
},
|
|
1956
1969
|
recipient: evt.recipient.whatsapp || "",
|
|
1957
1970
|
bodyValues: evt.dataWp
|
|
1958
1971
|
// You can enhance this to pass dynamic body values
|
|
@@ -1967,7 +1980,10 @@ var NotificationService = class {
|
|
|
1967
1980
|
providerType: "APP_NOTIFICATION" /* APP_NOTIFICATION */,
|
|
1968
1981
|
provider: appProvider,
|
|
1969
1982
|
eventConfigId: cfg.id,
|
|
1970
|
-
evt
|
|
1983
|
+
evt: {
|
|
1984
|
+
...evt,
|
|
1985
|
+
eventId: cfg?.serviceEvent?.id
|
|
1986
|
+
},
|
|
1971
1987
|
subject: subjectRendered,
|
|
1972
1988
|
body: bodyRendered
|
|
1973
1989
|
})
|
|
@@ -1989,8 +2005,8 @@ var NotificationService = class {
|
|
|
1989
2005
|
});
|
|
1990
2006
|
await this.prisma.eventNotificationAudit.create({
|
|
1991
2007
|
data: {
|
|
1992
|
-
eventId: args.evt.
|
|
1993
|
-
|
|
2008
|
+
eventId: args.evt.eventId,
|
|
2009
|
+
eventName: args.evt.shortCode,
|
|
1994
2010
|
eventConfigId: args.eventConfigId,
|
|
1995
2011
|
notificationType: args.providerType,
|
|
1996
2012
|
isSent: result.ok,
|
|
@@ -2003,8 +2019,8 @@ var NotificationService = class {
|
|
|
2003
2019
|
this.logger.error("[NotificationService] sendAndAudit failed", err);
|
|
2004
2020
|
await this.prisma.eventNotificationAudit.create({
|
|
2005
2021
|
data: {
|
|
2006
|
-
eventId: args.evt.
|
|
2007
|
-
|
|
2022
|
+
eventId: args.evt.eventId,
|
|
2023
|
+
eventName: args.evt.shortCode,
|
|
2008
2024
|
eventConfigId: args.eventConfigId,
|
|
2009
2025
|
notificationType: args.providerType,
|
|
2010
2026
|
isSent: false,
|
|
@@ -2021,8 +2037,8 @@ var NotificationService = class {
|
|
|
2021
2037
|
this.logger.info(`[NotificationService] WhatsApp send result: ${JSON.stringify(result)}`);
|
|
2022
2038
|
await this.prisma.eventNotificationAudit.create({
|
|
2023
2039
|
data: {
|
|
2024
|
-
eventId: args.evt.
|
|
2025
|
-
|
|
2040
|
+
eventId: args.evt.eventId,
|
|
2041
|
+
eventName: args.evt.shortCode,
|
|
2026
2042
|
eventConfigId: args.eventConfigId,
|
|
2027
2043
|
notificationType: "WHATSAPP" /* WHATSAPP */,
|
|
2028
2044
|
isSent: result.ok,
|
package/dist/index.mjs
CHANGED
|
@@ -1823,6 +1823,10 @@ var NotificationService = class {
|
|
|
1823
1823
|
this.logger.info(`[NotificationService] No config for event=${evt.shortCode} service=${evt.service}`);
|
|
1824
1824
|
throw new this.helpers.ErrorHandler(400, this.helpers.generateErrorMessage("NOT_FOUND", evt.shortCode));
|
|
1825
1825
|
}
|
|
1826
|
+
if (!cfg.serviceEvent.id) {
|
|
1827
|
+
this.logger.info(`[NotificationService] No event found for event=${evt.shortCode} service=${evt.service}`);
|
|
1828
|
+
throw new this.helpers.ErrorHandler(400, this.helpers.generateErrorMessage("NOT_FOUND", evt.shortCode));
|
|
1829
|
+
}
|
|
1826
1830
|
this.logger.info(`[NotificationService] Loaded config: ${JSON.stringify(cfg)}`);
|
|
1827
1831
|
let emailTpl = null;
|
|
1828
1832
|
if (cfg.allowEmail && cfg.serviceEvent.allowEmail && cfg.emailTemplateId) {
|
|
@@ -1857,7 +1861,7 @@ var NotificationService = class {
|
|
|
1857
1861
|
const waProvider = new WhatsAppProvider(
|
|
1858
1862
|
{
|
|
1859
1863
|
apiUrl: cfg.serviceEvent.wpApiUrl,
|
|
1860
|
-
templateName: waTpl
|
|
1864
|
+
templateName: waTpl?.templateCode ?? "",
|
|
1861
1865
|
callbackData: "",
|
|
1862
1866
|
countryCode: cfg.serviceEvent.countryCode,
|
|
1863
1867
|
languageCode: "en",
|
|
@@ -1878,7 +1882,10 @@ var NotificationService = class {
|
|
|
1878
1882
|
providerType: "EMAIL" /* EMAIL */,
|
|
1879
1883
|
provider: emailProvider,
|
|
1880
1884
|
eventConfigId: cfg.id,
|
|
1881
|
-
evt
|
|
1885
|
+
evt: {
|
|
1886
|
+
...evt,
|
|
1887
|
+
eventId: cfg?.serviceEvent?.id
|
|
1888
|
+
},
|
|
1882
1889
|
subject: msg.subject,
|
|
1883
1890
|
body: msg.body,
|
|
1884
1891
|
priority: evt.priority
|
|
@@ -1892,7 +1899,10 @@ var NotificationService = class {
|
|
|
1892
1899
|
providerType: "SMS" /* SMS */,
|
|
1893
1900
|
provider: smsProvider,
|
|
1894
1901
|
eventConfigId: cfg.id,
|
|
1895
|
-
evt
|
|
1902
|
+
evt: {
|
|
1903
|
+
...evt,
|
|
1904
|
+
eventId: cfg?.serviceEvent?.id
|
|
1905
|
+
},
|
|
1896
1906
|
body: msg
|
|
1897
1907
|
})
|
|
1898
1908
|
);
|
|
@@ -1902,7 +1912,10 @@ var NotificationService = class {
|
|
|
1902
1912
|
this.sendWhatsAppMessage({
|
|
1903
1913
|
provider: waProvider,
|
|
1904
1914
|
eventConfigId: cfg.id,
|
|
1905
|
-
evt
|
|
1915
|
+
evt: {
|
|
1916
|
+
...evt,
|
|
1917
|
+
eventId: cfg?.serviceEvent?.id
|
|
1918
|
+
},
|
|
1906
1919
|
recipient: evt.recipient.whatsapp || "",
|
|
1907
1920
|
bodyValues: evt.dataWp
|
|
1908
1921
|
// You can enhance this to pass dynamic body values
|
|
@@ -1917,7 +1930,10 @@ var NotificationService = class {
|
|
|
1917
1930
|
providerType: "APP_NOTIFICATION" /* APP_NOTIFICATION */,
|
|
1918
1931
|
provider: appProvider,
|
|
1919
1932
|
eventConfigId: cfg.id,
|
|
1920
|
-
evt
|
|
1933
|
+
evt: {
|
|
1934
|
+
...evt,
|
|
1935
|
+
eventId: cfg?.serviceEvent?.id
|
|
1936
|
+
},
|
|
1921
1937
|
subject: subjectRendered,
|
|
1922
1938
|
body: bodyRendered
|
|
1923
1939
|
})
|
|
@@ -1939,8 +1955,8 @@ var NotificationService = class {
|
|
|
1939
1955
|
});
|
|
1940
1956
|
await this.prisma.eventNotificationAudit.create({
|
|
1941
1957
|
data: {
|
|
1942
|
-
eventId: args.evt.
|
|
1943
|
-
|
|
1958
|
+
eventId: args.evt.eventId,
|
|
1959
|
+
eventName: args.evt.shortCode,
|
|
1944
1960
|
eventConfigId: args.eventConfigId,
|
|
1945
1961
|
notificationType: args.providerType,
|
|
1946
1962
|
isSent: result.ok,
|
|
@@ -1953,8 +1969,8 @@ var NotificationService = class {
|
|
|
1953
1969
|
this.logger.error("[NotificationService] sendAndAudit failed", err);
|
|
1954
1970
|
await this.prisma.eventNotificationAudit.create({
|
|
1955
1971
|
data: {
|
|
1956
|
-
eventId: args.evt.
|
|
1957
|
-
|
|
1972
|
+
eventId: args.evt.eventId,
|
|
1973
|
+
eventName: args.evt.shortCode,
|
|
1958
1974
|
eventConfigId: args.eventConfigId,
|
|
1959
1975
|
notificationType: args.providerType,
|
|
1960
1976
|
isSent: false,
|
|
@@ -1971,8 +1987,8 @@ var NotificationService = class {
|
|
|
1971
1987
|
this.logger.info(`[NotificationService] WhatsApp send result: ${JSON.stringify(result)}`);
|
|
1972
1988
|
await this.prisma.eventNotificationAudit.create({
|
|
1973
1989
|
data: {
|
|
1974
|
-
eventId: args.evt.
|
|
1975
|
-
|
|
1990
|
+
eventId: args.evt.eventId,
|
|
1991
|
+
eventName: args.evt.shortCode,
|
|
1976
1992
|
eventConfigId: args.eventConfigId,
|
|
1977
1993
|
notificationType: "WHATSAPP" /* WHATSAPP */,
|
|
1978
1994
|
isSent: result.ok,
|