dt-common-device 3.0.13 → 3.1.1

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.
@@ -4,7 +4,7 @@ export interface ILogger {
4
4
  warn(message: string, ...args: any[]): void;
5
5
  error(message: string, ...args: any[]): void;
6
6
  }
7
- type AllowedSource = "ACCESS_SERVICE" | "ADMIN_SERVICE" | "ENERGY_SERVICE";
7
+ type AllowedSource = "ACCESS_SERVICE" | "ADMIN_SERVICE" | "ENERGY_SERVICE" | "REMOTE_SERVICE" | "SCHEDULE_SERVICE";
8
8
  export type IConfig = {
9
9
  SOURCE: AllowedSource;
10
10
  SQS_QUEUE_URL: string;
@@ -1,5 +1,6 @@
1
1
  export declare const CONNECTION_PROVIDERS: {
2
2
  readonly DEVICETHREAD: "Devicethread";
3
+ readonly CLOUDBEDS: "Cloudbeds";
3
4
  readonly SALTOKS: "SaltoKS";
4
5
  readonly SCHLAGE: "Schlage";
5
6
  readonly SENSIBO: "Sensibo";
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CONNECTION_PROVIDERS = void 0;
4
4
  exports.CONNECTION_PROVIDERS = {
5
5
  DEVICETHREAD: "Devicethread",
6
+ CLOUDBEDS: "Cloudbeds",
6
7
  SALTOKS: "SaltoKS",
7
8
  SCHLAGE: "Schlage",
8
9
  SENSIBO: "Sensibo",
@@ -4,6 +4,7 @@ export declare const SERVICE_NAMES: {
4
4
  readonly ENERGY: "smart-energy";
5
5
  readonly SCHEDULE: "smart-schedule";
6
6
  readonly DEVICE: "smart-device";
7
+ readonly ENTERTAINMENT: "smart-entertainment";
7
8
  };
8
9
  export type SERVICE_NAME = typeof SERVICE_NAMES[keyof typeof SERVICE_NAMES];
9
10
  export declare enum Source {
@@ -7,6 +7,7 @@ exports.SERVICE_NAMES = {
7
7
  ENERGY: "smart-energy",
8
8
  SCHEDULE: "smart-schedule",
9
9
  DEVICE: "smart-device",
10
+ ENTERTAINMENT: "smart-entertainment",
10
11
  };
11
12
  var Source;
12
13
  (function (Source) {
@@ -4,9 +4,6 @@ export declare enum InternalEventType {
4
4
  SCHEDULE_CREATE = "schedule.create",
5
5
  SCHEDULE_UPDATE = "schedule.update",
6
6
  SCHEDULE_DELETE = "schedule.delete",
7
- RESERVATION_CREATE = "reservation.create",
8
- RESERVATION_UPDATE = "reservation.update",
9
- RESERVATION_CANCEL = "reservation.cancel",
10
7
  SERVICE_DOWN = "service.down"
11
8
  }
12
9
  export declare class InternalEventSubscription {
@@ -10,9 +10,6 @@ var InternalEventType;
10
10
  InternalEventType["SCHEDULE_CREATE"] = "schedule.create";
11
11
  InternalEventType["SCHEDULE_UPDATE"] = "schedule.update";
12
12
  InternalEventType["SCHEDULE_DELETE"] = "schedule.delete";
13
- InternalEventType["RESERVATION_CREATE"] = "reservation.create";
14
- InternalEventType["RESERVATION_UPDATE"] = "reservation.update";
15
- InternalEventType["RESERVATION_CANCEL"] = "reservation.cancel";
16
13
  InternalEventType["SERVICE_DOWN"] = "service.down";
17
14
  })(InternalEventType || (exports.InternalEventType = InternalEventType = {}));
18
15
  class InternalEventSubscription {
@@ -28,7 +25,7 @@ class InternalEventSubscription {
28
25
  try {
29
26
  const eventType = message["detail-type"];
30
27
  const eventData = message.detail;
31
- this.logger.info("Received internal event", { eventType, eventData });
28
+ this.logger.info(`Received internal event: ${eventType} ${eventData}`);
32
29
  switch (eventType) {
33
30
  case InternalEventType.HEARTBEAT:
34
31
  await this.safeCallHandler(() => this.internalEventHandler.onHeartbeat(eventData));
@@ -46,7 +43,7 @@ class InternalEventSubscription {
46
43
  await this.safeCallHandler(() => this.internalEventHandler.onServiceDown(eventData));
47
44
  break;
48
45
  default:
49
- this.logger.warn("Unknown event type", { eventType, eventData });
46
+ this.logger.warn(`Unknown event type: ${eventType} ${eventData}`);
50
47
  break;
51
48
  }
52
49
  }
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export * from "./microservice";
1
2
  export * from "./constants";
2
3
  export { CloudDevice, CloudDeviceService, DeviceFactory, } from "./device/cloud/entities";
3
4
  export { LocalDeviceService, LocalHubService, LocalScheduleService, } from "./device/local/services";
package/dist/index.js CHANGED
@@ -16,6 +16,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  };
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.shutdown = exports.getConfig = exports.initialize = exports.LocalScheduleService = exports.LocalHubService = exports.LocalDeviceService = exports.DeviceFactory = exports.CloudDeviceService = exports.CloudDevice = void 0;
19
+ // MICROSERVICE EXPORTS
20
+ __exportStar(require("./microservice"), exports);
19
21
  // CONSTANTS EXPORTS
20
22
  __exportStar(require("./constants"), exports);
21
23
  // DEVICE EXPORTS
@@ -0,0 +1,9 @@
1
+ import { SERVICE_NAME } from "../constants";
2
+ import { DeviceType } from "../device/cloud/interfaces";
3
+ export declare class MicroServiceFactory {
4
+ private readonly deviceType;
5
+ private static instance;
6
+ constructor(deviceType: DeviceType);
7
+ getMicroService(): SERVICE_NAME;
8
+ static getInstance(deviceType: DeviceType): MicroServiceFactory;
9
+ }
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MicroServiceFactory = void 0;
4
+ const constants_1 = require("../constants");
5
+ const interfaces_1 = require("../device/cloud/interfaces");
6
+ class MicroServiceFactory {
7
+ constructor(deviceType) {
8
+ this.deviceType = deviceType;
9
+ }
10
+ getMicroService() {
11
+ switch (this.deviceType) {
12
+ case interfaces_1.DeviceType.HUB:
13
+ case interfaces_1.DeviceType.ELEVATOR_LOCK:
14
+ case interfaces_1.DeviceType.LOCK:
15
+ return constants_1.SERVICE_NAMES.ACCESS;
16
+ case interfaces_1.DeviceType.THERMOSTAT:
17
+ return constants_1.SERVICE_NAMES.ENERGY;
18
+ case interfaces_1.DeviceType.TV:
19
+ return constants_1.SERVICE_NAMES.ENTERTAINMENT;
20
+ default:
21
+ throw new Error(`Invalid device type: ${this.deviceType}`);
22
+ }
23
+ }
24
+ static getInstance(deviceType) {
25
+ if (!MicroServiceFactory.instance) {
26
+ MicroServiceFactory.instance = new MicroServiceFactory(deviceType);
27
+ }
28
+ return MicroServiceFactory.instance;
29
+ }
30
+ }
31
+ exports.MicroServiceFactory = MicroServiceFactory;
@@ -0,0 +1 @@
1
+ export * from "./MicroServiceFactory";
@@ -0,0 +1,17 @@
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("./MicroServiceFactory"), exports);
@@ -38,6 +38,11 @@ class RateLimitUtils {
38
38
  windowMs: 60000,
39
39
  provider: constants_1.CONNECTION_PROVIDERS.SENSIBO,
40
40
  });
41
+ configs.set(constants_1.CONNECTION_PROVIDERS.CLOUDBEDS, {
42
+ maxRequests: 10,
43
+ windowMs: 1000,
44
+ provider: constants_1.CONNECTION_PROVIDERS.CLOUDBEDS,
45
+ });
41
46
  configs.set(constants_1.CONNECTION_PROVIDERS.TTLOCK, {
42
47
  maxRequests: 5,
43
48
  windowMs: 60000,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dt-common-device",
3
- "version": "3.0.13",
3
+ "version": "3.1.1",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [