@kohost/api-client 3.0.0-beta.60 → 3.0.0-beta.61

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 @@ class DiscoverRoomsCommand extends Command {
4
4
  constructor({
5
5
  id,
6
6
  types,
7
- spaceTypes,
7
+ categories,
8
8
  startDate,
9
9
  endDate,
10
10
  serviceStatus,
@@ -14,7 +14,7 @@ class DiscoverRoomsCommand extends Command {
14
14
  super({
15
15
  id,
16
16
  types,
17
- spaceTypes,
17
+ categories,
18
18
  startDate,
19
19
  endDate,
20
20
  serviceStatus,
@@ -0,0 +1,17 @@
1
+ const Event = require("./Event");
2
+
3
+ class SystemCategoryUpdatedEvent extends Event {
4
+ constructor(space) {
5
+ super(space);
6
+ }
7
+
8
+ get name() {
9
+ return "SystemCategoryUpdated";
10
+ }
11
+
12
+ get routingKey() {
13
+ return `category.${this.keyId}.updated`;
14
+ }
15
+ }
16
+
17
+ module.exports = SystemCategoryUpdatedEvent;
@@ -15,7 +15,7 @@ const SceneSetEvent = require("./SceneSetEvent");
15
15
 
16
16
  const SystemUserUpdatedEvent = require("./SystemUserUpdatedEvent");
17
17
  const SystemSpaceUpdatedEvent = require("./SystemSpaceUpdatedEvent");
18
- const SystemSpaceTypeUpdatedEvent = require("./SystemSpaceTypeUpdatedEvent");
18
+ const SystemCategoryUpdatedEvent = require("./SystemCategoryUpdatedEvent");
19
19
  const SystemProductUpdatedEvent = require("./SystemProductUpdatedEvent");
20
20
 
21
21
  const SystemReservationUpdatedEvent = require("./SystemReservationUpdatedEvent");
@@ -42,7 +42,7 @@ module.exports = {
42
42
  SystemCourtesyUpdatedEvent,
43
43
  SystemUserUpdatedEvent,
44
44
  SystemSpaceUpdatedEvent,
45
- SystemSpaceTypeUpdatedEvent,
45
+ SystemCategoryUpdatedEvent,
46
46
  SystemProductUpdatedEvent,
47
47
  SystemReservationUpdatedEvent,
48
48
  SceneSetEvent,
@@ -0,0 +1,36 @@
1
+ // Create the Category Model
2
+ // Originally used for hotel room category e.g. Double Queen
3
+ const schemas = require("../utils/schema");
4
+ const schema = require("../schemas/category.json");
5
+ const Kohost = require("./Kohost");
6
+
7
+ schemas.add(schema);
8
+ const validator = schemas.compile(schema);
9
+
10
+ class Category extends Kohost {
11
+ /**
12
+ * @typedef {import("../schemas/CategorySchema").Category} CategoryType
13
+ * Create a Category instance.
14
+ * @constructor
15
+ * @param {CategoryType} category - The category object of type SpaceType.
16
+ */
17
+ constructor(category) {
18
+ super(category);
19
+ }
20
+ }
21
+
22
+ Object.defineProperty(Category.prototype, "schema", {
23
+ value: schema,
24
+ });
25
+
26
+ Object.defineProperty(Category.prototype, "validator", {
27
+ get: function () {
28
+ return validator;
29
+ },
30
+ });
31
+
32
+ Object.defineProperty(Category, "validProperties", {
33
+ value: Object.keys(schema.properties),
34
+ });
35
+
36
+ module.exports = Category;
@@ -20,6 +20,7 @@ class MediaFile extends Kohost {
20
20
  createImageVariant(params) {
21
21
  if (this.mimeType != "image/*")
22
22
  throw new RequestError("Only dynamic images can have variants");
23
+ if (!this.url) throw new RequestError("MediaFile has no url");
23
24
  // convert params to "key=value" pairs
24
25
  const query = Object.keys(params)
25
26
  .map((key) => `${key}=${params[key]}`)
@@ -99,6 +99,7 @@ Object.defineProperty(Ticket.prototype, "lastResponder", {
99
99
 
100
100
  function mapConversationData(data) {
101
101
  const ticketData = cloneDeep(data);
102
+ if (!ticketData.conversation) ticketData.conversation = [];
102
103
  ticketData.conversation = ticketData.conversation.map((msg) => {
103
104
  if (msg.media) {
104
105
  msg.media = new MediaFile(msg.media);
@@ -16,7 +16,7 @@ const MediaSource = require("./MediaSource");
16
16
  const Room = require("./Room");
17
17
 
18
18
  const Space = require("./Space");
19
- const SpaceType = require("./SpaceType");
19
+ const Category = require("./Category");
20
20
 
21
21
  const Ticket = require("./Ticket");
22
22
  const Scene = require("./Scene");
@@ -56,7 +56,7 @@ module.exports = {
56
56
  SystemUser,
57
57
  Room,
58
58
  Space,
59
- SpaceType,
59
+ Category,
60
60
  Ticket,
61
61
  Scene,
62
62
  DiscoveredDevice,
@@ -11,9 +11,9 @@ export type Date =
11
11
  [k: string]: unknown;
12
12
  };
13
13
 
14
- export interface SpaceType {
14
+ export interface Category {
15
15
  id?: string;
16
- type?: string;
16
+ type: string;
17
17
  name?: string;
18
18
  driver?:
19
19
  | "aws-kinesis"
@@ -45,6 +45,7 @@ export interface SpaceType {
45
45
  description?: string;
46
46
  image?: MediaFile;
47
47
  rating?: number;
48
+ discriminator: "space" | "product";
48
49
  systemData?: SystemData;
49
50
  [k: string]: unknown;
50
51
  }
@@ -82,6 +82,7 @@ export interface Property {
82
82
  DigitalKey?: {
83
83
  system?: "salto";
84
84
  systemOnline?: boolean;
85
+ enableApp?: boolean;
85
86
  branding?: {
86
87
  logo?: string;
87
88
  /**
@@ -5,6 +5,12 @@
5
5
  * and run json-schema-to-typescript to regenerate this file.
6
6
  */
7
7
 
8
+ export type UpdatedAt =
9
+ | string
10
+ | {
11
+ [k: string]: unknown;
12
+ };
13
+
8
14
  export interface Reservation {
9
15
  id?: string;
10
16
  driver?:
@@ -37,7 +43,7 @@ export interface Reservation {
37
43
  primaryGuest?: string;
38
44
  type: string;
39
45
  sharedGuests?: string[];
40
- spaceType?: string;
46
+ spaceCategory?: string;
41
47
  space?: string;
42
48
  /**
43
49
  * reserved - confirmed by both parties, before check-in
@@ -71,6 +77,12 @@ export interface Reservation {
71
77
  };
72
78
  adultCount?: number;
73
79
  childCount?: number;
80
+ spaceCategoryAvailabilites?: {
81
+ id?: string;
82
+ price?: number;
83
+ unit?: "night" | "stay" | "hour";
84
+ [k: string]: unknown;
85
+ }[];
74
86
  revenue?: {
75
87
  date?: string;
76
88
  amount?: number;
@@ -85,6 +97,7 @@ export interface Reservation {
85
97
  metadata?: {
86
98
  [k: string]: unknown;
87
99
  };
100
+ updatedAt?: UpdatedAt;
88
101
  [k: string]: unknown;
89
102
  }
90
103
  export interface SystemData {
@@ -8,17 +8,8 @@
8
8
  export interface Space {
9
9
  id?: string;
10
10
  name?: string;
11
- type?:
12
- | "classRoom"
13
- | "hotelRoom"
14
- | "office"
15
- | "building"
16
- | "commonArea"
17
- | "conferenceRoom"
18
- | "lobby"
19
- | "gym"
20
- | "pool"
21
- | "restaurant";
11
+ type?: string;
12
+ discriminator?: "classRoom" | "hotelRoom" | "office" | "building" | "commonArea";
22
13
  driver?:
23
14
  | "aws-kinesis"
24
15
  | "butler"
@@ -46,7 +37,10 @@ export interface Space {
46
37
  | "cloudflare-images"
47
38
  | "cloudflare-stream"
48
39
  | "insperia-privacy";
49
- spaceType?: string;
40
+ /**
41
+ * This is the category id
42
+ */
43
+ category?: string;
50
44
  rooms?: string[];
51
45
  subGroups?: string[];
52
46
  occupied?: boolean;
@@ -17,7 +17,7 @@ export type Date =
17
17
  };
18
18
 
19
19
  /**
20
- * A ticket is a request for help from a user.
20
+ * A ticket is a request from a user.
21
21
  */
22
22
  export interface Ticket {
23
23
  id: string;
@@ -30,12 +30,27 @@ export interface Ticket {
30
30
  readBy?: string[];
31
31
  media?: MediaFile | null;
32
32
  }[];
33
- requester: string;
34
- assignedTo?: string | null;
33
+ requester: {
34
+ userId?: string;
35
+ userName?: string;
36
+ userPhoto?: MediaFile | null | string;
37
+ deviceId?: string;
38
+ roomId?: string;
39
+ spaceId?: string;
40
+ spaceName?: string;
41
+ [k: string]: unknown;
42
+ };
43
+ assignedTo?: {
44
+ userId?: string;
45
+ userName?: string;
46
+ userPhoto?: MediaFile | null | string;
47
+ [k: string]: unknown;
48
+ };
35
49
  status: "open" | "pending" | "solved" | "closed";
36
50
  tags: string[];
37
51
  rating?: number;
38
52
  ratingComment?: string;
53
+ tipAmount?: string;
39
54
  createdAt: Date;
40
55
  updatedAt: Date;
41
56
  solvedAt?: Date;
@@ -18,12 +18,12 @@ export type Identification2 =
18
18
  | {
19
19
  [k: string]: unknown;
20
20
  };
21
- export type CreatedAt =
21
+ export type UpdatedAt =
22
22
  | string
23
23
  | {
24
24
  [k: string]: unknown;
25
25
  };
26
- export type UpdatedAt =
26
+ export type CreatedAt =
27
27
  | string
28
28
  | {
29
29
  [k: string]: unknown;
@@ -210,7 +210,7 @@ export interface Reservation {
210
210
  primaryGuest?: string;
211
211
  type: string;
212
212
  sharedGuests?: string[];
213
- spaceType?: string;
213
+ spaceCategory?: string;
214
214
  space?: string;
215
215
  /**
216
216
  * reserved - confirmed by both parties, before check-in
@@ -244,6 +244,12 @@ export interface Reservation {
244
244
  };
245
245
  adultCount?: number;
246
246
  childCount?: number;
247
+ spaceCategoryAvailabilites?: {
248
+ id?: string;
249
+ price?: number;
250
+ unit?: "night" | "stay" | "hour";
251
+ [k: string]: unknown;
252
+ }[];
247
253
  revenue?: {
248
254
  date?: string;
249
255
  amount?: number;
@@ -258,5 +264,6 @@ export interface Reservation {
258
264
  metadata?: {
259
265
  [k: string]: unknown;
260
266
  };
267
+ updatedAt?: UpdatedAt;
261
268
  [k: string]: unknown;
262
269
  }
@@ -1,14 +1,16 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-07/schema",
3
- "$id": "spaceType.json",
4
- "title": "Space Type",
3
+ "$id": "category.json",
4
+ "title": "Category",
5
5
  "type": "object",
6
+ "required": ["type", "discriminator"],
6
7
  "properties": {
7
8
  "id": {
8
9
  "$ref": "definitions.json#/definitions/id"
9
10
  },
10
11
  "type": {
11
- "type": "string"
12
+ "type": "string",
13
+ "default": "category"
12
14
  },
13
15
  "name": {
14
16
  "type": "string",
@@ -29,6 +31,10 @@
29
31
  "maximum": 10,
30
32
  "default": 9
31
33
  },
34
+ "discriminator": {
35
+ "type": "string",
36
+ "enum": ["space", "product"]
37
+ },
32
38
  "systemData": {
33
39
  "$ref": "definitions.json#/definitions/systemData"
34
40
  }
@@ -9,7 +9,8 @@
9
9
  "$ref": "definitions.json#/definitions/id"
10
10
  },
11
11
  "type": {
12
- "type": "string"
12
+ "type": "string",
13
+ "default": "product"
13
14
  },
14
15
  "name": {
15
16
  "type": "string"
@@ -217,6 +217,9 @@
217
217
  "type": "boolean",
218
218
  "default": false
219
219
  },
220
+ "enableApp": {
221
+ "type": "boolean"
222
+ },
220
223
  "branding": {
221
224
  "type": "object",
222
225
  "properties": {
@@ -15,7 +15,8 @@
15
15
  "type": "string"
16
16
  },
17
17
  "type": {
18
- "type": "string"
18
+ "type": "string",
19
+ "default": "reservation"
19
20
  },
20
21
  "sharedGuests": {
21
22
  "type": "array",
@@ -23,7 +24,7 @@
23
24
  "type": "string"
24
25
  }
25
26
  },
26
- "spaceType": {
27
+ "spaceCategory": {
27
28
  "type": "string"
28
29
  },
29
30
  "space": {
@@ -77,6 +78,25 @@
77
78
  "type": "number",
78
79
  "default": 0
79
80
  },
81
+
82
+ "spaceCategoryAvailabilites": {
83
+ "type": "array",
84
+ "items": {
85
+ "type": "object",
86
+ "properties": {
87
+ "id": {
88
+ "type": "string"
89
+ },
90
+ "price": {
91
+ "type": "number"
92
+ },
93
+ "unit": {
94
+ "type": "string",
95
+ "enum": ["night", "stay", "hour"]
96
+ }
97
+ }
98
+ }
99
+ },
80
100
  "revenue": {
81
101
  "type": "array",
82
102
  "items": {
@@ -113,6 +133,9 @@
113
133
  },
114
134
  "metadata": {
115
135
  "ref": "definitions.json#/definitions/metadata"
136
+ },
137
+ "updatedAt": {
138
+ "$ref": "definitions.json#/definitions/updatedAt"
116
139
  }
117
140
  }
118
141
  }
@@ -12,25 +12,25 @@
12
12
  "minLength": 1
13
13
  },
14
14
  "type": {
15
- "type": ["string"],
15
+ "type": "string",
16
+ "default": "space"
17
+ },
18
+ "discriminator": {
19
+ "type": "string",
16
20
  "enum": [
17
21
  "classRoom",
18
22
  "hotelRoom",
19
23
  "office",
20
24
  "building",
21
- "commonArea",
22
- "conferenceRoom",
23
- "lobby",
24
- "gym",
25
- "pool",
26
- "restaurant"
25
+ "commonArea"
27
26
  ]
28
27
  },
29
28
  "driver": {
30
29
  "$ref": "definitions.json#/definitions/driver"
31
30
  },
32
- "spaceType": {
33
- "type": "string"
31
+ "category": {
32
+ "type": "string",
33
+ "description": "This is the category id"
34
34
  },
35
35
  "rooms": {
36
36
  "type": "array",
@@ -2,7 +2,7 @@
2
2
  "$schema": "http://json-schema.org/draft-07/schema",
3
3
  "$id": "ticket.json",
4
4
  "title": "Ticket",
5
- "description": "A ticket is a request for help from a user.",
5
+ "description": "A ticket is a request from a user.",
6
6
  "type": "object",
7
7
  "properties": {
8
8
  "id": {
@@ -45,10 +45,52 @@
45
45
  }
46
46
  },
47
47
  "requester": {
48
- "type": "string"
48
+ "type": "object",
49
+ "properties": {
50
+ "userId": {
51
+ "type": "string"
52
+ },
53
+ "userName": {
54
+ "type": "string"
55
+ },
56
+ "userPhoto": {
57
+ "anyOf": [
58
+ { "$ref": "mediaFile.json" },
59
+ { "type": "null" },
60
+ { "type": "string" }
61
+ ]
62
+ },
63
+ "deviceId": {
64
+ "type": "string"
65
+ },
66
+ "roomId": {
67
+ "type": "string"
68
+ },
69
+ "spaceId": {
70
+ "type": "string"
71
+ },
72
+ "spaceName": {
73
+ "type": "string"
74
+ }
75
+ }
49
76
  },
50
77
  "assignedTo": {
51
- "type": ["string", "null"]
78
+ "type": "object",
79
+ "properties": {
80
+ "userId": {
81
+ "type": "string"
82
+ },
83
+ "userName": {
84
+ "type": "string"
85
+ },
86
+ "userPhoto": {
87
+ "anyOf": [
88
+ { "$ref": "mediaFile.json" },
89
+ { "type": "null" },
90
+ { "type": "string" }
91
+ ]
92
+ }
93
+ }
52
94
  },
53
95
  "status": {
54
96
  "type": "string",
@@ -70,6 +112,9 @@
70
112
  "ratingComment": {
71
113
  "type": "string"
72
114
  },
115
+ "tipAmount": {
116
+ "type": "string"
117
+ },
73
118
  "createdAt": {
74
119
  "$ref": "definitions.json#/definitions/date"
75
120
  },
@@ -661,7 +661,7 @@ var require_DiscoverRoomsCommand = __commonJS({
661
661
  constructor({
662
662
  id,
663
663
  types,
664
- spaceTypes,
664
+ categories,
665
665
  startDate,
666
666
  endDate,
667
667
  serviceStatus,
@@ -671,7 +671,7 @@ var require_DiscoverRoomsCommand = __commonJS({
671
671
  super({
672
672
  id,
673
673
  types,
674
- spaceTypes,
674
+ categories,
675
675
  startDate,
676
676
  endDate,
677
677
  serviceStatus,