@kohost/api-client 3.0.0-beta.11 → 3.0.0-beta.12

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.
@@ -10,26 +10,39 @@ var require_Event = __commonJS({
10
10
  "src/Events/Event.js"(exports2, module2) {
11
11
  var Event = class {
12
12
  constructor(data, context) {
13
- this.data = {};
13
+ this.data = [];
14
14
  this.context = {};
15
15
  if (!data)
16
16
  throw new Error("Event data is required");
17
- if (typeof data !== "object")
18
- throw new Error("Event data must be an object");
19
- for (const key in data) {
20
- this.data[key] = data[key];
21
- }
17
+ if (typeof data !== "object" && !Array.isArray(data))
18
+ throw new Error("Event data must be an object or array");
19
+ if (!Array.isArray(data))
20
+ this.data = [data];
21
+ else
22
+ this.data = data;
23
+ this.data = this.data.map((d) => {
24
+ if (d.eventData) {
25
+ if (!d.eventData.timestamp)
26
+ d.eventData.timestamp = /* @__PURE__ */ new Date();
27
+ if (!d.eventData.name)
28
+ d.eventData.name = this.name;
29
+ if (!d.eventData.type)
30
+ d.eventData.type = this.type;
31
+ }
32
+ return d;
33
+ });
22
34
  if (context) {
23
35
  for (const key in context) {
24
36
  this.context[key] = context[key];
25
37
  }
26
38
  }
27
- if (this.data.eventData && !this.data.eventData.timestamp)
28
- this.data.eventData.timestamp = /* @__PURE__ */ new Date();
29
- if (this.data.eventData && !this.data.eventData.name)
30
- this.data.eventData.name = this.name;
31
- if (this.data.eventData && !this.data.eventData.type)
32
- this.data.eventData.type = this.type;
39
+ }
40
+ get keyId() {
41
+ if (Array.isArray(this.data))
42
+ return "batch";
43
+ if (this.data.id)
44
+ return this.data.id;
45
+ return "unknown";
33
46
  }
34
47
  get name() {
35
48
  throw new Error("Event name is required");
@@ -64,7 +77,7 @@ var require_SystemThermostatUpdatedEvent = __commonJS({
64
77
  return "SystemThermostatUpdated";
65
78
  }
66
79
  get routingKey() {
67
- return `thermostat.${this.data.id}.updated`;
80
+ return `thermostat.${this.keyId}.updated`;
68
81
  }
69
82
  };
70
83
  __name(SystemThermostatUpdatedEvent2, "SystemThermostatUpdatedEvent");
@@ -84,7 +97,7 @@ var require_SystemDimmerUpdatedEvent = __commonJS({
84
97
  return "SystemDimmerUpdated";
85
98
  }
86
99
  get routingKey() {
87
- return `dimmer.${this.data.id}.updated`;
100
+ return `dimmer.${this.keyId}.updated`;
88
101
  }
89
102
  };
90
103
  __name(SystemDimmerUpdatedEvent2, "SystemDimmerUpdatedEvent");
@@ -104,7 +117,7 @@ var require_SystemSwitchUpdatedEvent = __commonJS({
104
117
  return "SystemSwitchUpdated";
105
118
  }
106
119
  get routingKey() {
107
- return `switch.${this.data.id}.updated`;
120
+ return `switch.${this.keyId}.updated`;
108
121
  }
109
122
  };
110
123
  __name(SystemSwitchUpdatedEvent2, "SystemSwitchUpdatedEvent");
@@ -124,7 +137,7 @@ var require_SystemLockUpdatedEvent = __commonJS({
124
137
  return "SystemLockUpdated";
125
138
  }
126
139
  get routingKey() {
127
- return `lock.${this.data.id}.updated`;
140
+ return `lock.${this.keyId}.updated`;
128
141
  }
129
142
  };
130
143
  __name(SystemLockUpdatedEvent2, "SystemLockUpdatedEvent");
@@ -144,7 +157,7 @@ var require_SystemCameraUpdatedEvent = __commonJS({
144
157
  return "SystemCameraUpdated";
145
158
  }
146
159
  get routingKey() {
147
- return `camera.${this.data.id}.updated`;
160
+ return `camera.${this.keyId}.updated`;
148
161
  }
149
162
  };
150
163
  __name(SystemCameraUpdatedEvent2, "SystemCameraUpdatedEvent");
@@ -164,7 +177,7 @@ var require_SystemSceneControllerUpdatedEvent = __commonJS({
164
177
  return "SystemSceneControllerUpdated";
165
178
  }
166
179
  get routingKey() {
167
- return `sceneController.${this.data.id}.updated`;
180
+ return `sceneController.${this.keyId}.updated`;
168
181
  }
169
182
  };
170
183
  __name(SystemSceneControllerUpdatedEvent2, "SystemSceneControllerUpdatedEvent");
@@ -184,7 +197,7 @@ var require_SystemWindowCoveringUpdatedEvent = __commonJS({
184
197
  return "SystemWindowCoveringUpdated";
185
198
  }
186
199
  get routingKey() {
187
- return `windowCovering.${this.data.id}.updated`;
200
+ return `windowCovering.${this.keyId}.updated`;
188
201
  }
189
202
  };
190
203
  __name(SystemWindowCoveringUpdatedEvent2, "SystemWindowCoveringUpdatedEvent");
@@ -204,7 +217,7 @@ var require_SystemSourceUpdatedEvent = __commonJS({
204
217
  return "SystemSourceUpdated";
205
218
  }
206
219
  get routingKey() {
207
- return `source.${this.data.id}.updated`;
220
+ return `source.${this.keyId}.updated`;
208
221
  }
209
222
  };
210
223
  __name(SystemSourceUpdatedEvent2, "SystemSourceUpdatedEvent");
@@ -224,7 +237,7 @@ var require_SystemCourtesyUpdatedEvent = __commonJS({
224
237
  return "SystemCourtesyUpdated";
225
238
  }
226
239
  get routingKey() {
227
- return `courtesy.${this.data.id}.updated`;
240
+ return `courtesy.${this.keyId}.updated`;
228
241
  }
229
242
  };
230
243
  __name(SystemCourtesyUpdatedEvent2, "SystemCourtesyUpdatedEvent");
@@ -244,7 +257,7 @@ var require_SystemUserUpdatedEvent = __commonJS({
244
257
  return "SystemUserUpdated";
245
258
  }
246
259
  get routingKey() {
247
- return `user.${this.data.id}.updated`;
260
+ return `user.${this.keyId}.updated`;
248
261
  }
249
262
  };
250
263
  __name(SystemUserUpdatedEvent2, "SystemUserUpdatedEvent");
@@ -264,7 +277,7 @@ var require_SystemSpaceUpdatedEvent = __commonJS({
264
277
  return "SystemSpaceUpdated";
265
278
  }
266
279
  get routingKey() {
267
- return `space.${this.data.id}.updated`;
280
+ return `space.${this.keyId}.updated`;
268
281
  }
269
282
  };
270
283
  __name(SystemSpaceUpdatedEvent2, "SystemSpaceUpdatedEvent");
@@ -272,6 +285,26 @@ var require_SystemSpaceUpdatedEvent = __commonJS({
272
285
  }
273
286
  });
274
287
 
288
+ // src/Events/SystemSpaceTypeUpdatedEvent.js
289
+ var require_SystemSpaceTypeUpdatedEvent = __commonJS({
290
+ "src/Events/SystemSpaceTypeUpdatedEvent.js"(exports2, module2) {
291
+ var Event = require_Event();
292
+ var SystemSpaceTypeUpdatedEvent2 = class extends Event {
293
+ constructor(space) {
294
+ super(space);
295
+ }
296
+ get name() {
297
+ return "SystemSpaceTypeUpdated";
298
+ }
299
+ get routingKey() {
300
+ return `spaceType.${this.keyId}.updated`;
301
+ }
302
+ };
303
+ __name(SystemSpaceTypeUpdatedEvent2, "SystemSpaceTypeUpdatedEvent");
304
+ module2.exports = SystemSpaceTypeUpdatedEvent2;
305
+ }
306
+ });
307
+
275
308
  // src/Events/SystemReservationUpdatedEvent.js
276
309
  var require_SystemReservationUpdatedEvent = __commonJS({
277
310
  "src/Events/SystemReservationUpdatedEvent.js"(exports2, module2) {
@@ -284,7 +317,7 @@ var require_SystemReservationUpdatedEvent = __commonJS({
284
317
  return "SystemReservationUpdated";
285
318
  }
286
319
  get routingKey() {
287
- return `reservation.${this.data.id}.updated`;
320
+ return `reservation.${this.keyId}.updated`;
288
321
  }
289
322
  };
290
323
  __name(SystemReservationUpdatedEvent2, "SystemReservationUpdatedEvent");
@@ -344,7 +377,7 @@ var require_ShortLinkCreatedEvent = __commonJS({
344
377
  return "ShortLinkCreated";
345
378
  }
346
379
  get routingKey() {
347
- return `shortlink.${this.data.id}.created`;
380
+ return `shortlink.${this.keyId}.created`;
348
381
  }
349
382
  };
350
383
  __name(ShortLinkCreatedEvent2, "ShortLinkCreatedEvent");
@@ -364,6 +397,7 @@ var SystemSourceUpdatedEvent = require_SystemSourceUpdatedEvent();
364
397
  var SystemCourtesyUpdatedEvent = require_SystemCourtesyUpdatedEvent();
365
398
  var SystemUserUpdatedEvent = require_SystemUserUpdatedEvent();
366
399
  var SystemSpaceUpdatedEvent = require_SystemSpaceUpdatedEvent();
400
+ var SystemSpaceTypeUpdatedEvent = require_SystemSpaceTypeUpdatedEvent();
367
401
  var SystemReservationUpdatedEvent = require_SystemReservationUpdatedEvent();
368
402
  var SMSSentEvent = require_SMSSentEvent();
369
403
  var EmailSentEvent = require_EmailSentEvent();
@@ -380,6 +414,7 @@ module.exports = {
380
414
  SystemCourtesyUpdatedEvent,
381
415
  SystemUserUpdatedEvent,
382
416
  SystemSpaceUpdatedEvent,
417
+ SystemSpaceTypeUpdatedEvent,
383
418
  SystemReservationUpdatedEvent,
384
419
  SMSSentEvent,
385
420
  EmailSentEvent,
@@ -209,6 +209,9 @@ var require_switch = __commonJS({
209
209
  id: {
210
210
  $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/id"
211
211
  },
212
+ name: {
213
+ type: "string"
214
+ },
212
215
  type: {
213
216
  $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/type"
214
217
  },
@@ -668,6 +671,9 @@ var require_dimmer = __commonJS({
668
671
  id: {
669
672
  $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/id"
670
673
  },
674
+ name: {
675
+ type: "string"
676
+ },
671
677
  type: {
672
678
  $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/type"
673
679
  },
@@ -1048,6 +1054,9 @@ var require_windowCovering = __commonJS({
1048
1054
  id: {
1049
1055
  $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/id"
1050
1056
  },
1057
+ name: {
1058
+ type: "string"
1059
+ },
1051
1060
  type: {
1052
1061
  $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/type"
1053
1062
  },
@@ -1497,6 +1506,9 @@ var require_courtesy = __commonJS({
1497
1506
  id: {
1498
1507
  $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/id"
1499
1508
  },
1509
+ name: {
1510
+ type: "string"
1511
+ },
1500
1512
  type: {
1501
1513
  $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/type"
1502
1514
  },
@@ -2377,14 +2389,40 @@ var require_reservation = __commonJS({
2377
2389
  type: "string"
2378
2390
  }
2379
2391
  },
2392
+ spaceType: {
2393
+ type: "string"
2394
+ },
2380
2395
  space: {
2381
2396
  type: "string"
2382
2397
  },
2383
2398
  status: {
2384
2399
  type: "string",
2385
- enum: ["reserved", "checkedIn", "checkedOut", "cancelled", "noShow", "enquired", "requested", "optional"],
2400
+ enum: [
2401
+ "reserved",
2402
+ "checkedIn",
2403
+ "checkedOut",
2404
+ "cancelled",
2405
+ "noShow",
2406
+ "enquired",
2407
+ "requested",
2408
+ "optional"
2409
+ ],
2386
2410
  description: " reserved - confirmed by both parties, before check-in\n checkedIn - checked in\n checkedOut - checked out\n cancelled - Cancelled\n noShow - No show\n enquired - Confirmed neither by the customer nor enterprise\n requested - Confirmed by the customer but not the enterprise (waitlist)\n optional - Confirmed by the enterprise but not the customer (holding)"
2387
2411
  },
2412
+ mobileCheckInStatus: {
2413
+ type: "string",
2414
+ enum: [
2415
+ "ready",
2416
+ "blocked",
2417
+ "preArrivalStepsRequired",
2418
+ "spaceNotAssigned",
2419
+ "spaceNotReady",
2420
+ "checkInTimeNotStarted"
2421
+ ]
2422
+ },
2423
+ mobileCheckInStatusMessage: {
2424
+ type: "string"
2425
+ },
2388
2426
  confirmationNumber: {
2389
2427
  type: "string"
2390
2428
  },
@@ -2405,6 +2443,24 @@ var require_reservation = __commonJS({
2405
2443
  type: "number",
2406
2444
  default: 0
2407
2445
  },
2446
+ revenue: {
2447
+ type: "array",
2448
+ items: {
2449
+ type: "object",
2450
+ properties: {
2451
+ date: {
2452
+ type: "string",
2453
+ format: "date"
2454
+ },
2455
+ amount: {
2456
+ type: "number"
2457
+ },
2458
+ type: {
2459
+ type: "string"
2460
+ }
2461
+ }
2462
+ }
2463
+ },
2408
2464
  rateSuppressed: {
2409
2465
  type: "boolean"
2410
2466
  },
@@ -2450,6 +2506,15 @@ var require_reservation2 = __commonJS({
2450
2506
  range(tz) {
2451
2507
  const start = new Date(this.checkInDateTime);
2452
2508
  const end = new Date(this.checkOutDateTime);
2509
+ if (start.getDate() === end.getDate() && start.getMonth() === end.getMonth() && start.getFullYear() === end.getFullYear()) {
2510
+ return `${start.toLocaleString("default", {
2511
+ month: "short",
2512
+ timeZone: tz
2513
+ })} ${start.toLocaleString("default", {
2514
+ timeZone: tz,
2515
+ day: "numeric"
2516
+ })}`;
2517
+ }
2453
2518
  if (start.getMonth() === end.getMonth() && start.getFullYear() === end.getFullYear()) {
2454
2519
  return `${start.toLocaleString("default", {
2455
2520
  month: "short",
@@ -2587,6 +2652,9 @@ var require_space = __commonJS({
2587
2652
  "other"
2588
2653
  ]
2589
2654
  },
2655
+ subType: {
2656
+ type: "string"
2657
+ },
2590
2658
  rooms: {
2591
2659
  type: "array",
2592
2660
  items: {
@@ -2718,9 +2786,6 @@ var require_space2 = __commonJS({
2718
2786
  get hasCourtesy() {
2719
2787
  return this.rooms.some((room) => room.hasCourtesy);
2720
2788
  }
2721
- get hasSceneController() {
2722
- return this.rooms.some((room) => room.hasSceneController);
2723
- }
2724
2789
  get hasCamera() {
2725
2790
  return this.rooms.some((room) => room.hasCamera);
2726
2791
  }
@@ -2765,6 +2830,69 @@ var require_space2 = __commonJS({
2765
2830
  }
2766
2831
  });
2767
2832
 
2833
+ // src/schemas/spaceType.json
2834
+ var require_spaceType = __commonJS({
2835
+ "src/schemas/spaceType.json"(exports2, module2) {
2836
+ module2.exports = {
2837
+ $schema: "http://json-schema.org/draft-07/schema",
2838
+ $id: "https://api.kohost.app/schemas/v3/spaceType.json",
2839
+ title: "Space Type",
2840
+ type: "object",
2841
+ properties: {
2842
+ id: {
2843
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/id"
2844
+ },
2845
+ type: {
2846
+ type: "string"
2847
+ },
2848
+ name: {
2849
+ type: "string",
2850
+ minLength: 1
2851
+ },
2852
+ description: {
2853
+ type: "string"
2854
+ },
2855
+ imageUrl: {
2856
+ format: "uri",
2857
+ pattern: "^https?://"
2858
+ },
2859
+ systemData: {
2860
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/systemData"
2861
+ }
2862
+ }
2863
+ };
2864
+ }
2865
+ });
2866
+
2867
+ // src/Models/spaceType.js
2868
+ var require_spaceType2 = __commonJS({
2869
+ "src/Models/spaceType.js"(exports2, module2) {
2870
+ var schemas = require_schema();
2871
+ var schema = require_spaceType();
2872
+ var Kohost = require_kohost();
2873
+ schemas.add(schema);
2874
+ var validator = schemas.compile(schema);
2875
+ var SpaceType2 = class extends Kohost {
2876
+ constructor(data) {
2877
+ super(data);
2878
+ }
2879
+ };
2880
+ __name(SpaceType2, "SpaceType");
2881
+ Object.defineProperty(SpaceType2.prototype, "schema", {
2882
+ value: schema
2883
+ });
2884
+ Object.defineProperty(SpaceType2.prototype, "validator", {
2885
+ get: function() {
2886
+ return validator;
2887
+ }
2888
+ });
2889
+ Object.defineProperty(SpaceType2, "validProperties", {
2890
+ value: Object.keys(schema.properties)
2891
+ });
2892
+ module2.exports = SpaceType2;
2893
+ }
2894
+ });
2895
+
2768
2896
  // src/schemas/ticket.json
2769
2897
  var require_ticket = __commonJS({
2770
2898
  "src/schemas/ticket.json"(exports2, module2) {
@@ -3572,6 +3700,7 @@ var Room = require_room2();
3572
3700
  var Reservation = require_reservation2();
3573
3701
  var Application = require_application2();
3574
3702
  var Space = require_space2();
3703
+ var SpaceType = require_spaceType2();
3575
3704
  var Ticket = require_ticket2();
3576
3705
  var Scene = require_scene2();
3577
3706
  var Gateway = require_gateway2();
@@ -3603,6 +3732,7 @@ module.exports = {
3603
3732
  Room,
3604
3733
  Application,
3605
3734
  Space,
3735
+ SpaceType,
3606
3736
  Ticket,
3607
3737
  Scene,
3608
3738
  DiscoveredDevice,
package/dist/cjs/defs.js CHANGED
@@ -120,6 +120,10 @@ var require_Client = __commonJS({
120
120
  try {
121
121
  const expectedError = status >= 400 && status < 500;
122
122
  const newTokensNeeded = expectedError && errorType === "TokenExpiredError";
123
+ if (expectedError && errorMessage === "Phone Verification is required") {
124
+ this._onPhoneVerificationRequired();
125
+ return Promise.reject(error);
126
+ }
123
127
  if (expectedError && errorMessage === "Login Required") {
124
128
  this._onLoginRequired();
125
129
  return Promise.reject(error);
@@ -160,6 +164,9 @@ var require_Client = __commonJS({
160
164
  _onLoginRequired() {
161
165
  this.emit("LoginRequired");
162
166
  }
167
+ _onPhoneVerificationRequired() {
168
+ this.emit("PhoneVerificationRequired");
169
+ }
163
170
  };
164
171
  __name(KohostApiClient, "KohostApiClient");
165
172
  module2.exports = KohostApiClient;