dt-common-device 13.9.0 → 13.9.2

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.
@@ -1,8 +1,8 @@
1
1
  import { IInternalEvent } from "../events/interfaces/IInternalEvent";
2
2
  export interface ILogger {
3
- info(message: string, ...args: any[]): void;
4
- warn(message: string, ...args: any[]): void;
5
- error(message: string, ...args: any[]): void;
3
+ info(...args: any[]): void;
4
+ warn(...args: any[]): void;
5
+ error(...args: any[]): void;
6
6
  }
7
7
  type AllowedSource = "ACCESS_SERVICE" | "ADMIN_SERVICE" | "ENERGY_SERVICE" | "REMOTE_SERVICE" | "SCHEDULE_SERVICE" | "MIGRATION" | "OPERATION_NODE_SERVICE" | "NOTIFICATION_SERVICE";
8
8
  export type IConfig = {
package/dist/db/db.js CHANGED
@@ -21,7 +21,8 @@ function getPostgresClient() {
21
21
  connectionString: URI,
22
22
  connectionTimeoutMillis: 5000,
23
23
  idleTimeoutMillis: 30000,
24
- }));
24
+ }).on("error", (err) => (0, config_1.getLogger)().error(err, `[Postgres] Admin Pool connection error`)));
25
+ (0, config_1.getLogger)().info(`[Postgres] Admin Pool initialized`);
25
26
  return adminPool;
26
27
  }
27
28
  function getAccessPostgresClient() {
@@ -30,7 +31,8 @@ function getAccessPostgresClient() {
30
31
  connectionString: URI,
31
32
  connectionTimeoutMillis: 5000,
32
33
  idleTimeoutMillis: 30000,
33
- }));
34
+ }).on("error", (err) => (0, config_1.getLogger)().error(err, `[Postgres] Access Pool connection error`)));
35
+ (0, config_1.getLogger)().info(`[Postgres] Access Pool initialized`);
34
36
  return accessPool;
35
37
  }
36
38
  function getPmsPostgresClient() {
@@ -39,7 +41,8 @@ function getPmsPostgresClient() {
39
41
  connectionString: URI,
40
42
  connectionTimeoutMillis: 5000,
41
43
  idleTimeoutMillis: 30000,
42
- }));
44
+ }).on("error", (err) => (0, config_1.getLogger)().error(err, `[Postgres] PMS Pool connection error`)));
45
+ (0, config_1.getLogger)().info(`[Postgres] PMS Pool initialized`);
43
46
  return pmsPool;
44
47
  }
45
48
  function getWebhookPostgresClient() {
@@ -48,7 +51,8 @@ function getWebhookPostgresClient() {
48
51
  connectionString: URI,
49
52
  connectionTimeoutMillis: 5000,
50
53
  idleTimeoutMillis: 30000,
51
- }));
54
+ }).on("error", (err) => (0, config_1.getLogger)().error(err, `[Postgres] Webhook Pool connection error`)));
55
+ (0, config_1.getLogger)().info(`[Postgres] Webhook Pool initialized`);
52
56
  return webhookPool;
53
57
  }
54
58
  const connectDatabase = async () => {
@@ -316,7 +316,9 @@ let AdminService = (() => {
316
316
  }
317
317
  async propertyHasSaltoConnection(propertyId) {
318
318
  const connections = await typedi_1.default.get(connection_1.LocalConnectionService).getConnectionsByPropertyId(propertyId);
319
- return connections.every((connection) => connection.connectionProvider === connection_1.ConnectionProvider.SaltoKS ||
319
+ // using 'some' to check, because property may have TV, Thermostats connections as well,
320
+ // In that case 'every' will return false and that breaks the SaltoKS check implementation
321
+ return connections.some((connection) => connection.connectionProvider === connection_1.ConnectionProvider.SaltoKS ||
320
322
  connection.connectionProvider === connection_1.ConnectionProvider.SaltoSpace);
321
323
  }
322
324
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dt-common-device",
3
- "version": "13.9.0",
3
+ "version": "13.9.2",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [