dt-common-device 1.2.2 → 1.2.3

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.
@@ -12,6 +12,7 @@ export interface IConnection {
12
12
  propertyId: string;
13
13
  connectionProvider: ConnectionProvider;
14
14
  accessToken?: string;
15
+ refreshToken?: string;
15
16
  clientId?: string;
16
17
  clientSecret: string;
17
18
  isActive?: boolean;
@@ -22,3 +22,8 @@ export interface IProperty {
22
22
  updatedAt: string;
23
23
  propertyBillingId?: string;
24
24
  }
25
+ export interface IPropertySettings {
26
+ id: string;
27
+ propertyId: string;
28
+ settings: Record<string, any>;
29
+ }
@@ -1,11 +1,7 @@
1
- import { IProperty } from "../interfaces/IProperty";
1
+ import { IProperty, IPropertySettings } from "../interfaces/IProperty";
2
2
  export declare class PropertyRepository {
3
3
  private readonly postgres;
4
4
  constructor();
5
- getPropertyPreferences(propertyId: string): Promise<{
6
- id: string;
7
- propertyId: string;
8
- settings: string;
9
- } | null>;
5
+ getPropertyPreferences(propertyId: string): Promise<IPropertySettings | null>;
10
6
  getProperty(propertyId: string): Promise<IProperty | null>;
11
7
  }
@@ -54,11 +54,7 @@ let PropertyRepository = (() => {
54
54
  try {
55
55
  const propertyPreferences = await this.postgres.query("SELECT * FROM dt_property_settings WHERE propertyId = $1", [propertyId]);
56
56
  if (propertyPreferences.rows.length > 0) {
57
- return {
58
- id: propertyPreferences.rows[0].id,
59
- propertyId: propertyPreferences.rows[0].propertyId,
60
- settings: JSON.parse(propertyPreferences.rows[0].settings),
61
- };
57
+ return propertyPreferences.rows[0];
62
58
  }
63
59
  return null;
64
60
  }
@@ -1,11 +1,7 @@
1
1
  export declare class LocalPropertyService {
2
2
  private readonly propertyRepository;
3
3
  constructor();
4
- getPropertyPreferences(propertyId: string): Promise<{
5
- id: string;
6
- propertyId: string;
7
- settings: string;
8
- } | null>;
4
+ getPropertyPreferences(propertyId: string): Promise<import("../interfaces/IProperty").IPropertySettings | null>;
9
5
  getProperty(propertyId: string): Promise<import("../interfaces/IProperty").IProperty | null>;
10
6
  getPropertyTimeZone(propertyId: string): Promise<string>;
11
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dt-common-device",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "scripts": {
@@ -14,6 +14,7 @@ export interface IConnection {
14
14
  propertyId: string;
15
15
  connectionProvider: ConnectionProvider;
16
16
  accessToken?: string;
17
+ refreshToken?: string;
17
18
  clientId?: string;
18
19
  clientSecret: string;
19
20
  isActive?: boolean;
@@ -22,3 +22,9 @@ export interface IProperty {
22
22
  updatedAt: string;
23
23
  propertyBillingId?: string;
24
24
  }
25
+
26
+ export interface IPropertySettings {
27
+ id: string;
28
+ propertyId: string;
29
+ settings: Record<string, any>;
30
+ }
@@ -1,6 +1,6 @@
1
1
  import { getPostgresClient } from "../../../db";
2
2
  import { Service } from "typedi";
3
- import { IProperty } from "../interfaces/IProperty";
3
+ import { IProperty, IPropertySettings } from "../interfaces/IProperty";
4
4
 
5
5
  @Service()
6
6
  export class PropertyRepository {
@@ -11,18 +11,14 @@ export class PropertyRepository {
11
11
 
12
12
  async getPropertyPreferences(
13
13
  propertyId: string
14
- ): Promise<{ id: string; propertyId: string; settings: string } | null> {
14
+ ): Promise<IPropertySettings | null> {
15
15
  try {
16
16
  const propertyPreferences = await this.postgres.query(
17
17
  "SELECT * FROM dt_property_settings WHERE propertyId = $1",
18
18
  [propertyId]
19
19
  );
20
20
  if (propertyPreferences.rows.length > 0) {
21
- return {
22
- id: propertyPreferences.rows[0].id,
23
- propertyId: propertyPreferences.rows[0].propertyId,
24
- settings: JSON.parse(propertyPreferences.rows[0].settings),
25
- };
21
+ return propertyPreferences.rows[0];
26
22
  }
27
23
  return null;
28
24
  } catch (error) {