dt-common-device 13.4.4 → 13.4.6

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.
@@ -85,6 +85,7 @@ exports.CONFIG_KEYS = {
85
85
  "ADMIN_DB_URI",
86
86
  "ACCESS_DB_URI",
87
87
  "AWS_SQS_URL",
88
+ "ADMIN_SERVICE",
88
89
  "HEARTBEAT_SQS_URL",
89
90
  "CRONICLE_ENDPOINT",
90
91
  "CRONICLE_API_KEY",
@@ -285,7 +285,8 @@ let EmailService = (() => {
285
285
  (0, config_1.getLogger)().info(`Sending email to: ${maskedEmailsList.join(", ")}`);
286
286
  }
287
287
  catch (error) {
288
- (0, config_1.getLogger)().error("sendMail: Error", error);
288
+ console.log("sendMail: Error", JSON.stringify(error));
289
+ (0, config_1.getLogger)().error("sendMail: Error", JSON.stringify(error));
289
290
  }
290
291
  }
291
292
  };
@@ -1,4 +1,4 @@
1
- import { IAccessGroup, IUser, IZone, IZoneAccessGroup } from "./IAdmin";
1
+ import { IAccessGroup, INotificationTemplate, INotificationTemplateResolve, IUser, IZone, IZoneAccessGroup } from "./IAdmin";
2
2
  export declare class AdminRepository {
3
3
  private readonly deviceRepository;
4
4
  private readonly postgres;
@@ -23,4 +23,5 @@ 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>;
26
27
  }
@@ -536,6 +536,16 @@ 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
+ }
539
549
  };
540
550
  __setFunctionName(_classThis, "AdminRepository");
541
551
  (() => {
@@ -1,4 +1,4 @@
1
- import { IAccessGroup, IUser, IZone } from "./IAdmin";
1
+ import { IAccessGroup, INotificationTemplate, INotificationTemplateResolve, IUser, IZone } from "./IAdmin";
2
2
  export declare class AdminService {
3
3
  private readonly adminRepository;
4
4
  private readonly redisUtils;
@@ -17,4 +17,5 @@ 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>;
20
21
  }
@@ -310,6 +310,15 @@ 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
+ }
313
322
  };
314
323
  __setFunctionName(_classThis, "AdminService");
315
324
  (() => {
@@ -48,3 +48,31 @@ 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
+ }
@@ -4,5 +4,6 @@ export declare class PropertyRepository {
4
4
  constructor();
5
5
  getPropertyPreferences(propertyId: string, keys?: string[]): Promise<IPropertySettings | null>;
6
6
  getProperty(propertyId: string): Promise<IProperty | null>;
7
+ getOrganizationByPropertyId(propertyId: string): Promise<any | null>;
7
8
  getAllProperties(): Promise<any[]>;
8
9
  }
@@ -41,6 +41,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
41
41
  exports.PropertyRepository = void 0;
42
42
  const db_1 = require("../../db");
43
43
  const typedi_1 = require("typedi");
44
+ const utils_1 = require("../../utils");
44
45
  let PropertyRepository = (() => {
45
46
  let _classDecorators = [(0, typedi_1.Service)()];
46
47
  let _classDescriptor;
@@ -84,6 +85,10 @@ let PropertyRepository = (() => {
84
85
  }
85
86
  return null;
86
87
  }
88
+ async getOrganizationByPropertyId(propertyId) {
89
+ const organization = await (0, utils_1.getAdminServiceAxiosInstance)().get(`/properties/${propertyId}/organizations`);
90
+ return organization.data.data;
91
+ }
87
92
  async getAllProperties() {
88
93
  try {
89
94
  //Retrieve all the properties ids from the database where isDeleted is false
@@ -5,4 +5,5 @@ export declare class LocalPropertyService {
5
5
  getProperty(propertyId: string): Promise<import("./IProperty").IProperty | null>;
6
6
  getPropertyTimeZone(propertyId: string): Promise<string>;
7
7
  getAllProperties(): Promise<any[]>;
8
+ getOrganizationByPropertyId(propertyId: string): Promise<any>;
8
9
  }
@@ -110,6 +110,12 @@ let LocalPropertyService = (() => {
110
110
  const properties = await this.propertyRepository.getAllProperties();
111
111
  return properties;
112
112
  }
113
+ async getOrganizationByPropertyId(propertyId) {
114
+ if (!propertyId) {
115
+ throw new Error("Property ID is required");
116
+ }
117
+ return await this.propertyRepository.getOrganizationByPropertyId(propertyId);
118
+ }
113
119
  };
114
120
  __setFunctionName(_classThis, "LocalPropertyService");
115
121
  (() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dt-common-device",
3
- "version": "13.4.4",
3
+ "version": "13.4.6",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [