dt-common-device 13.4.6 → 13.4.8
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/Integrations/twilio/twilio.service.d.ts +1 -2
- package/dist/Integrations/twilio/twilio.service.js +16 -20
- package/dist/config/config.d.ts +1 -0
- package/dist/config/config.js +9 -0
- package/dist/emails/emailService.js +0 -1
- package/dist/entities/admin/Admin.repository.d.ts +1 -2
- package/dist/entities/admin/Admin.repository.js +0 -10
- package/dist/entities/admin/Admin.service.d.ts +1 -2
- package/dist/entities/admin/Admin.service.js +0 -9
- package/dist/entities/admin/IAdmin.d.ts +0 -28
- package/dist/entities/notification/INotification.d.ts +37 -0
- package/dist/entities/notification/INotification.js +2 -0
- package/dist/entities/notification/Notification.repository.d.ts +5 -0
- package/dist/entities/notification/Notification.repository.js +82 -0
- package/dist/entities/notification/Notification.service.d.ts +7 -0
- package/dist/entities/notification/Notification.service.js +109 -0
- package/dist/entities/notification/index.d.ts +2 -0
- package/dist/entities/notification/index.js +18 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/utils/http.utils.d.ts +1 -0
- package/dist/utils/http.utils.js +8 -0
- package/package.json +1 -1
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ISendSMSRequest } from "./interface/twilioInterface";
|
|
2
2
|
export declare class TwilioService {
|
|
3
|
-
private readonly
|
|
4
|
-
private readonly propertyRepository;
|
|
3
|
+
private readonly notificationService;
|
|
5
4
|
constructor();
|
|
6
5
|
sendSMS(data: ISendSMSRequest): Promise<any>;
|
|
7
6
|
}
|
|
@@ -76,10 +76,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
76
76
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
77
77
|
exports.TwilioService = void 0;
|
|
78
78
|
const typedi_1 = __importStar(require("typedi"));
|
|
79
|
-
const
|
|
80
|
-
const IConnection_1 = require("../../entities/connection/IConnection");
|
|
79
|
+
const Notification_service_1 = require("../../entities/notification/Notification.service");
|
|
81
80
|
const twilio_1 = __importDefault(require("twilio"));
|
|
82
|
-
const Property_repository_1 = require("../../entities/property/Property.repository");
|
|
83
81
|
let TwilioService = (() => {
|
|
84
82
|
let _classDecorators = [(0, typedi_1.Service)()];
|
|
85
83
|
let _classDescriptor;
|
|
@@ -87,36 +85,34 @@ let TwilioService = (() => {
|
|
|
87
85
|
let _classThis;
|
|
88
86
|
var TwilioService = _classThis = class {
|
|
89
87
|
constructor() {
|
|
90
|
-
this.
|
|
91
|
-
this.propertyRepository = typedi_1.default.get(Property_repository_1.PropertyRepository);
|
|
88
|
+
this.notificationService = typedi_1.default.get(Notification_service_1.NotificationService);
|
|
92
89
|
}
|
|
93
90
|
// -----------------------------
|
|
94
91
|
// Send SMS
|
|
95
92
|
// -----------------------------
|
|
96
93
|
async sendSMS(data) {
|
|
97
94
|
const { propertyId, message, toNumber } = data;
|
|
95
|
+
if (!propertyId) {
|
|
96
|
+
throw new Error("Property ID is required for sending SMS");
|
|
97
|
+
}
|
|
98
98
|
if (!toNumber) {
|
|
99
99
|
throw new Error("To number is required for sending SMS");
|
|
100
100
|
}
|
|
101
|
-
|
|
102
|
-
const response = await this.connectionRepository.queryConnections({
|
|
101
|
+
const connection = await this.notificationService.queryConnections({
|
|
103
102
|
propertyId,
|
|
104
|
-
connectionProvider:
|
|
103
|
+
connectionProvider: "twilio",
|
|
104
|
+
isEnable: true,
|
|
105
105
|
});
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
const fromNumber = metaData?.fromNumber;
|
|
109
|
-
if (!fromNumber) {
|
|
110
|
-
throw new Error("From number not found");
|
|
106
|
+
if (!connection) {
|
|
107
|
+
throw new Error("Twilio connection not found for this property");
|
|
111
108
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
throw new Error("Property settings not found");
|
|
109
|
+
const { clientId, clientSecret, metaData } = connection;
|
|
110
|
+
if (!clientId || !clientSecret) {
|
|
111
|
+
throw new Error("Twilio credentials (clientId, clientSecret) not found");
|
|
116
112
|
}
|
|
117
|
-
const
|
|
118
|
-
if (!
|
|
119
|
-
throw new Error("
|
|
113
|
+
const fromNumber = metaData?.fromNumber;
|
|
114
|
+
if (!fromNumber || typeof fromNumber !== "string") {
|
|
115
|
+
throw new Error("From number not found");
|
|
120
116
|
}
|
|
121
117
|
//TODO: Need to do single tone pattern for the client
|
|
122
118
|
const client = (0, twilio_1.default)(clientId, clientSecret);
|
package/dist/config/config.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export declare function getConfig(): IConfig;
|
|
|
5
5
|
export declare function getDeviceServiceUrl(): string;
|
|
6
6
|
export declare function getAdminServiceUrl(): string;
|
|
7
7
|
export declare function getMonitoringServiceUrl(): string;
|
|
8
|
+
export declare function getNotificationServiceUrl(): string;
|
|
8
9
|
export declare function getSqsQueueUrl(): string;
|
|
9
10
|
export declare function getReservationSqsQueueUrl(): string;
|
|
10
11
|
export declare function getHeartbeatSqsQueueUrl(): string;
|
package/dist/config/config.js
CHANGED
|
@@ -41,6 +41,7 @@ exports.getConfig = getConfig;
|
|
|
41
41
|
exports.getDeviceServiceUrl = getDeviceServiceUrl;
|
|
42
42
|
exports.getAdminServiceUrl = getAdminServiceUrl;
|
|
43
43
|
exports.getMonitoringServiceUrl = getMonitoringServiceUrl;
|
|
44
|
+
exports.getNotificationServiceUrl = getNotificationServiceUrl;
|
|
44
45
|
exports.getSqsQueueUrl = getSqsQueueUrl;
|
|
45
46
|
exports.getReservationSqsQueueUrl = getReservationSqsQueueUrl;
|
|
46
47
|
exports.getHeartbeatSqsQueueUrl = getHeartbeatSqsQueueUrl;
|
|
@@ -194,6 +195,14 @@ function getMonitoringServiceUrl() {
|
|
|
194
195
|
}
|
|
195
196
|
return monitoringServiceUrl;
|
|
196
197
|
}
|
|
198
|
+
function getNotificationServiceUrl() {
|
|
199
|
+
const notificationServiceUrl = process.env.NOTIFICATION_SERVICE;
|
|
200
|
+
if (!notificationServiceUrl) {
|
|
201
|
+
getConfig().LOGGER.error("NOTIFICATION_SERVICE must be set in environment variables");
|
|
202
|
+
throw new Error("dt-common-device: NOTIFICATION_SERVICE must be set in environment variables");
|
|
203
|
+
}
|
|
204
|
+
return notificationServiceUrl;
|
|
205
|
+
}
|
|
197
206
|
function getSqsQueueUrl() {
|
|
198
207
|
if (constants_1.CONFIG_KEYS[sourceKey].env.includes("AWS_SQS_URL")) {
|
|
199
208
|
const sqsQueueUrl = process.env.AWS_SQS_URL;
|
|
@@ -285,7 +285,6 @@ let EmailService = (() => {
|
|
|
285
285
|
(0, config_1.getLogger)().info(`Sending email to: ${maskedEmailsList.join(", ")}`);
|
|
286
286
|
}
|
|
287
287
|
catch (error) {
|
|
288
|
-
console.log("sendMail: Error", JSON.stringify(error));
|
|
289
288
|
(0, config_1.getLogger)().error("sendMail: Error", JSON.stringify(error));
|
|
290
289
|
}
|
|
291
290
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IAccessGroup,
|
|
1
|
+
import { IAccessGroup, IUser, IZone, IZoneAccessGroup } from "./IAdmin";
|
|
2
2
|
export declare class AdminRepository {
|
|
3
3
|
private readonly deviceRepository;
|
|
4
4
|
private readonly postgres;
|
|
@@ -23,5 +23,4 @@ export declare class AdminRepository {
|
|
|
23
23
|
getChildCollectionsByParentIds(parentIds: string[]): Promise<any[]>;
|
|
24
24
|
deleteAllCollectionHierarchy(propertyId: string, source: string): Promise<void>;
|
|
25
25
|
getCollectionByName(name: string, propertyId: string): Promise<any | null>;
|
|
26
|
-
getNotificationTemplate(payload: INotificationTemplateResolve): Promise<INotificationTemplate | null>;
|
|
27
26
|
}
|
|
@@ -536,16 +536,6 @@ let AdminRepository = (() => {
|
|
|
536
536
|
return null;
|
|
537
537
|
}
|
|
538
538
|
}
|
|
539
|
-
async getNotificationTemplate(payload) {
|
|
540
|
-
if (!payload.propertyId ||
|
|
541
|
-
!payload.organizationId ||
|
|
542
|
-
!payload.eventName ||
|
|
543
|
-
!payload.channel) {
|
|
544
|
-
throw new Error("Property ID, Organization ID, Event Name, and Channel are required in payload");
|
|
545
|
-
}
|
|
546
|
-
const response = await (0, utils_1.getAdminServiceAxiosInstance)().post(`/notification-templates/resolve`, payload);
|
|
547
|
-
return response.data.data;
|
|
548
|
-
}
|
|
549
539
|
};
|
|
550
540
|
__setFunctionName(_classThis, "AdminRepository");
|
|
551
541
|
(() => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IAccessGroup,
|
|
1
|
+
import { IAccessGroup, IUser, IZone } from "./IAdmin";
|
|
2
2
|
export declare class AdminService {
|
|
3
3
|
private readonly adminRepository;
|
|
4
4
|
private readonly redisUtils;
|
|
@@ -17,5 +17,4 @@ export declare class AdminService {
|
|
|
17
17
|
deleteAllCollectionHierarchy(propertyId: string, source: string): Promise<void>;
|
|
18
18
|
getCollectionByName(name: string, propertyId: string): Promise<any | null>;
|
|
19
19
|
propertyHasSaltoConnection(propertyId: string): Promise<boolean>;
|
|
20
|
-
getNotificationTemplate(payload: INotificationTemplateResolve): Promise<INotificationTemplate | null>;
|
|
21
20
|
}
|
|
@@ -310,15 +310,6 @@ let AdminService = (() => {
|
|
|
310
310
|
return connections.every((connection) => connection.connectionProvider === connection_1.ConnectionProvider.SaltoKS ||
|
|
311
311
|
connection.connectionProvider === connection_1.ConnectionProvider.SaltoSpace);
|
|
312
312
|
}
|
|
313
|
-
async getNotificationTemplate(payload) {
|
|
314
|
-
if (!payload.propertyId ||
|
|
315
|
-
!payload.organizationId ||
|
|
316
|
-
!payload.eventName ||
|
|
317
|
-
!payload.channel) {
|
|
318
|
-
throw new Error("Property ID, Organization ID, Event Name, and Channel are required");
|
|
319
|
-
}
|
|
320
|
-
return await this.adminRepository.getNotificationTemplate(payload);
|
|
321
|
-
}
|
|
322
313
|
};
|
|
323
314
|
__setFunctionName(_classThis, "AdminService");
|
|
324
315
|
(() => {
|
|
@@ -48,31 +48,3 @@ export interface IUser {
|
|
|
48
48
|
deletedAt?: Date | null;
|
|
49
49
|
imageURL?: string | null;
|
|
50
50
|
}
|
|
51
|
-
export type NotificationChannel = "email" | "sms";
|
|
52
|
-
export type NotificationScope = "platform" | "organization" | "property";
|
|
53
|
-
export interface INotificationTemplate {
|
|
54
|
-
_id?: string;
|
|
55
|
-
id?: string;
|
|
56
|
-
eventName: string;
|
|
57
|
-
channel: NotificationChannel;
|
|
58
|
-
scope: NotificationScope;
|
|
59
|
-
organizationId: string | null;
|
|
60
|
-
propertyId: string | null;
|
|
61
|
-
subject?: string;
|
|
62
|
-
template: string;
|
|
63
|
-
variables: string[];
|
|
64
|
-
isActive: boolean;
|
|
65
|
-
isDeleted?: boolean;
|
|
66
|
-
createdBy?: string;
|
|
67
|
-
updatedBy?: string;
|
|
68
|
-
createdAt?: Date;
|
|
69
|
-
updatedAt?: Date;
|
|
70
|
-
deletedAt?: Date;
|
|
71
|
-
deletedBy?: string;
|
|
72
|
-
}
|
|
73
|
-
export interface INotificationTemplateResolve {
|
|
74
|
-
propertyId?: string;
|
|
75
|
-
organizationId?: string;
|
|
76
|
-
eventName?: string;
|
|
77
|
-
channel?: NotificationChannel;
|
|
78
|
-
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export type NotificationChannel = "email" | "sms";
|
|
2
|
+
export type NotificationScope = "platform" | "organization" | "property";
|
|
3
|
+
export interface INotificationQuery {
|
|
4
|
+
id?: string;
|
|
5
|
+
clientId?: string;
|
|
6
|
+
clientSecret?: string;
|
|
7
|
+
metaData?: Record<string, unknown>;
|
|
8
|
+
propertyId?: string;
|
|
9
|
+
connectionProvider?: string;
|
|
10
|
+
isEnable?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface INotificationTemplateResolve {
|
|
13
|
+
propertyId?: string;
|
|
14
|
+
organizationId?: string;
|
|
15
|
+
eventName?: string;
|
|
16
|
+
channel?: NotificationChannel;
|
|
17
|
+
}
|
|
18
|
+
export interface INotificationTemplate {
|
|
19
|
+
_id?: string;
|
|
20
|
+
id?: string;
|
|
21
|
+
eventName: string;
|
|
22
|
+
channel: NotificationChannel;
|
|
23
|
+
scope: NotificationScope;
|
|
24
|
+
organizationId: string | null;
|
|
25
|
+
propertyId: string | null;
|
|
26
|
+
subject?: string;
|
|
27
|
+
template: string;
|
|
28
|
+
variables: string[];
|
|
29
|
+
isActive: boolean;
|
|
30
|
+
isDeleted?: boolean;
|
|
31
|
+
createdBy?: string;
|
|
32
|
+
updatedBy?: string;
|
|
33
|
+
createdAt?: Date;
|
|
34
|
+
updatedAt?: Date;
|
|
35
|
+
deletedAt?: Date;
|
|
36
|
+
deletedBy?: string;
|
|
37
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { INotificationQuery, INotificationTemplate, INotificationTemplateResolve } from "./INotification";
|
|
2
|
+
export declare class NotificationRepository {
|
|
3
|
+
queryConnections(payload: INotificationQuery): Promise<any>;
|
|
4
|
+
getNotificationTemplate(payload: INotificationTemplateResolve): Promise<INotificationTemplate | null>;
|
|
5
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
3
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
4
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
5
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
6
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
7
|
+
var _, done = false;
|
|
8
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
9
|
+
var context = {};
|
|
10
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
11
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
12
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
13
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
14
|
+
if (kind === "accessor") {
|
|
15
|
+
if (result === void 0) continue;
|
|
16
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
17
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
18
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
19
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
20
|
+
}
|
|
21
|
+
else if (_ = accept(result)) {
|
|
22
|
+
if (kind === "field") initializers.unshift(_);
|
|
23
|
+
else descriptor[key] = _;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
27
|
+
done = true;
|
|
28
|
+
};
|
|
29
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
30
|
+
var useValue = arguments.length > 2;
|
|
31
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
32
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
33
|
+
}
|
|
34
|
+
return useValue ? value : void 0;
|
|
35
|
+
};
|
|
36
|
+
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
|
37
|
+
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
38
|
+
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
39
|
+
};
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
exports.NotificationRepository = void 0;
|
|
42
|
+
const typedi_1 = require("typedi");
|
|
43
|
+
const http_utils_1 = require("../../utils/http.utils");
|
|
44
|
+
let NotificationRepository = (() => {
|
|
45
|
+
let _classDecorators = [(0, typedi_1.Service)()];
|
|
46
|
+
let _classDescriptor;
|
|
47
|
+
let _classExtraInitializers = [];
|
|
48
|
+
let _classThis;
|
|
49
|
+
var NotificationRepository = _classThis = class {
|
|
50
|
+
async queryConnections(payload) {
|
|
51
|
+
if (!payload || Object.keys(payload).length === 0) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
const normalizedPayload = { ...payload };
|
|
55
|
+
const response = await (0, http_utils_1.getNotificationServiceAxiosInstance)().post(`/connections/query`, normalizedPayload);
|
|
56
|
+
if (!response.data?.success || !response.data?.data?.length) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
return response.data.data;
|
|
60
|
+
}
|
|
61
|
+
async getNotificationTemplate(payload) {
|
|
62
|
+
if (!payload.propertyId ||
|
|
63
|
+
!payload.organizationId ||
|
|
64
|
+
!payload.eventName ||
|
|
65
|
+
!payload.channel) {
|
|
66
|
+
throw new Error("Property ID, Organization ID, Event Name, and Channel are required in payload");
|
|
67
|
+
}
|
|
68
|
+
const response = await (0, http_utils_1.getNotificationServiceAxiosInstance)().post(`/notification-templates/resolve`, payload);
|
|
69
|
+
return response.data.data;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
__setFunctionName(_classThis, "NotificationRepository");
|
|
73
|
+
(() => {
|
|
74
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
75
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
76
|
+
NotificationRepository = _classThis = _classDescriptor.value;
|
|
77
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
78
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
79
|
+
})();
|
|
80
|
+
return NotificationRepository = _classThis;
|
|
81
|
+
})();
|
|
82
|
+
exports.NotificationRepository = NotificationRepository;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { INotificationQuery, INotificationTemplate, INotificationTemplateResolve } from "./INotification";
|
|
2
|
+
export declare class NotificationService {
|
|
3
|
+
private readonly notificationRepository;
|
|
4
|
+
constructor();
|
|
5
|
+
queryConnections(payload: INotificationQuery): Promise<any>;
|
|
6
|
+
getNotificationTemplate(payload: INotificationTemplateResolve): Promise<INotificationTemplate | null>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
19
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
20
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
21
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
22
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
23
|
+
var _, done = false;
|
|
24
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
25
|
+
var context = {};
|
|
26
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
27
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
28
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
29
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
30
|
+
if (kind === "accessor") {
|
|
31
|
+
if (result === void 0) continue;
|
|
32
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
33
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
34
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
35
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
36
|
+
}
|
|
37
|
+
else if (_ = accept(result)) {
|
|
38
|
+
if (kind === "field") initializers.unshift(_);
|
|
39
|
+
else descriptor[key] = _;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
43
|
+
done = true;
|
|
44
|
+
};
|
|
45
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
46
|
+
var useValue = arguments.length > 2;
|
|
47
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
48
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
49
|
+
}
|
|
50
|
+
return useValue ? value : void 0;
|
|
51
|
+
};
|
|
52
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
53
|
+
var ownKeys = function(o) {
|
|
54
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
55
|
+
var ar = [];
|
|
56
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
57
|
+
return ar;
|
|
58
|
+
};
|
|
59
|
+
return ownKeys(o);
|
|
60
|
+
};
|
|
61
|
+
return function (mod) {
|
|
62
|
+
if (mod && mod.__esModule) return mod;
|
|
63
|
+
var result = {};
|
|
64
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
65
|
+
__setModuleDefault(result, mod);
|
|
66
|
+
return result;
|
|
67
|
+
};
|
|
68
|
+
})();
|
|
69
|
+
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
|
70
|
+
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
71
|
+
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
72
|
+
};
|
|
73
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
74
|
+
exports.NotificationService = void 0;
|
|
75
|
+
const typedi_1 = __importStar(require("typedi"));
|
|
76
|
+
const Notification_repository_1 = require("./Notification.repository");
|
|
77
|
+
let NotificationService = (() => {
|
|
78
|
+
let _classDecorators = [(0, typedi_1.Service)()];
|
|
79
|
+
let _classDescriptor;
|
|
80
|
+
let _classExtraInitializers = [];
|
|
81
|
+
let _classThis;
|
|
82
|
+
var NotificationService = _classThis = class {
|
|
83
|
+
constructor() {
|
|
84
|
+
this.notificationRepository = typedi_1.default.get(Notification_repository_1.NotificationRepository);
|
|
85
|
+
}
|
|
86
|
+
async queryConnections(payload) {
|
|
87
|
+
return await this.notificationRepository.queryConnections(payload);
|
|
88
|
+
}
|
|
89
|
+
async getNotificationTemplate(payload) {
|
|
90
|
+
if (!payload.propertyId ||
|
|
91
|
+
!payload.organizationId ||
|
|
92
|
+
!payload.eventName ||
|
|
93
|
+
!payload.channel) {
|
|
94
|
+
throw new Error("Property ID, Organization ID, Event Name, and Channel are required");
|
|
95
|
+
}
|
|
96
|
+
return await this.notificationRepository.getNotificationTemplate(payload);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
__setFunctionName(_classThis, "NotificationService");
|
|
100
|
+
(() => {
|
|
101
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
102
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
103
|
+
NotificationService = _classThis = _classDescriptor.value;
|
|
104
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
105
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
106
|
+
})();
|
|
107
|
+
return NotificationService = _classThis;
|
|
108
|
+
})();
|
|
109
|
+
exports.NotificationService = NotificationService;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./Notification.service"), exports);
|
|
18
|
+
__exportStar(require("./INotification"), exports);
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -75,3 +75,5 @@ __exportStar(require("./Integrations"), exports);
|
|
|
75
75
|
__exportStar(require("./Integrations/twilio"), exports);
|
|
76
76
|
// Export Email Service
|
|
77
77
|
__exportStar(require("./emails/emailService"), exports);
|
|
78
|
+
// Export Notification Service
|
|
79
|
+
__exportStar(require("./entities/notification"), exports);
|
|
@@ -9,6 +9,7 @@ export declare function createAxiosInstance(baseURL?: string): import("axios").A
|
|
|
9
9
|
export declare function getDeviceServiceAxiosInstance(): any;
|
|
10
10
|
export declare function getAdminServiceAxiosInstance(): any;
|
|
11
11
|
export declare function getMonitoringServiceAxiosInstance(): any;
|
|
12
|
+
export declare function getNotificationServiceAxiosInstance(): any;
|
|
12
13
|
/**
|
|
13
14
|
* Retry function for failed HTTP requests
|
|
14
15
|
*/
|
package/dist/utils/http.utils.js
CHANGED
|
@@ -8,6 +8,7 @@ exports.createAxiosInstance = createAxiosInstance;
|
|
|
8
8
|
exports.getDeviceServiceAxiosInstance = getDeviceServiceAxiosInstance;
|
|
9
9
|
exports.getAdminServiceAxiosInstance = getAdminServiceAxiosInstance;
|
|
10
10
|
exports.getMonitoringServiceAxiosInstance = getMonitoringServiceAxiosInstance;
|
|
11
|
+
exports.getNotificationServiceAxiosInstance = getNotificationServiceAxiosInstance;
|
|
11
12
|
exports.retryRequest = retryRequest;
|
|
12
13
|
const config_1 = require("../config/config");
|
|
13
14
|
const axios_1 = __importDefault(require("axios"));
|
|
@@ -105,6 +106,13 @@ function getMonitoringServiceAxiosInstance() {
|
|
|
105
106
|
}
|
|
106
107
|
return deviceMonitoringServiceAxiosInstance;
|
|
107
108
|
}
|
|
109
|
+
let notificationServiceAxiosInstance = null;
|
|
110
|
+
function getNotificationServiceAxiosInstance() {
|
|
111
|
+
if (!notificationServiceAxiosInstance) {
|
|
112
|
+
notificationServiceAxiosInstance = createAxiosInstance((0, config_1.getNotificationServiceUrl)());
|
|
113
|
+
}
|
|
114
|
+
return notificationServiceAxiosInstance;
|
|
115
|
+
}
|
|
108
116
|
/**
|
|
109
117
|
* Retry function for failed HTTP requests
|
|
110
118
|
*/
|