@kohost/api-client 3.0.0-beta.40 → 3.0.0-beta.42

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.
@@ -26,6 +26,10 @@ var require_common = __commonJS({
26
26
  type: "object",
27
27
  default: {}
28
28
  },
29
+ date: {
30
+ type: ["string", "object"],
31
+ format: "date-time"
32
+ },
29
33
  createdAt: {
30
34
  type: ["string", "object"],
31
35
  format: "date-time"
@@ -97,6 +101,7 @@ var require_common = __commonJS({
97
101
  "lg",
98
102
  "lirc",
99
103
  "mews",
104
+ "paxton",
100
105
  "pelican-wireless",
101
106
  "rebrandly",
102
107
  "salto",
@@ -104,7 +109,9 @@ var require_common = __commonJS({
104
109
  "se",
105
110
  "sendgrid",
106
111
  "stay-n-touch",
107
- "twilio"
112
+ "twilio",
113
+ "cloudflare-images",
114
+ "cloudflare-stream"
108
115
  ]
109
116
  }
110
117
  }
@@ -832,6 +839,9 @@ var require_lock = __commonJS({
832
839
  type: {
833
840
  $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/type"
834
841
  },
842
+ offline: {
843
+ type: "boolean"
844
+ },
835
845
  supportedNotifications: {
836
846
  $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/supportedNotifications"
837
847
  },
@@ -1833,6 +1843,9 @@ var require_camera = __commonJS({
1833
1843
  }
1834
1844
  }
1835
1845
  },
1846
+ previewImage: {
1847
+ type: "string"
1848
+ },
1836
1849
  systemData: {
1837
1850
  $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/systemData"
1838
1851
  },
@@ -1967,6 +1980,9 @@ var require_mediaSource = __commonJS({
1967
1980
  "uncontrolledDevice"
1968
1981
  ]
1969
1982
  },
1983
+ name: {
1984
+ $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/name"
1985
+ },
1970
1986
  driver: {
1971
1987
  $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/driver"
1972
1988
  },
@@ -2723,13 +2739,14 @@ var require_reservation = __commonJS({
2723
2739
  properties: {
2724
2740
  date: {
2725
2741
  type: "string",
2726
- format: "date"
2742
+ format: "date-time"
2727
2743
  },
2728
2744
  amount: {
2729
2745
  type: "number"
2730
2746
  },
2731
2747
  type: {
2732
- type: "string"
2748
+ type: "string",
2749
+ enum: ["service", "product"]
2733
2750
  }
2734
2751
  }
2735
2752
  }
@@ -3111,6 +3128,112 @@ var require_spaceType2 = __commonJS({
3111
3128
  }
3112
3129
  });
3113
3130
 
3131
+ // src/schemas/mediaFile.json
3132
+ var require_mediaFile = __commonJS({
3133
+ "src/schemas/mediaFile.json"(exports2, module2) {
3134
+ module2.exports = {
3135
+ $schema: "http://json-schema.org/draft-07/schema",
3136
+ $id: "https://api.kohost.io/schemas/v3/mediaFile.json",
3137
+ title: "Media File",
3138
+ description: "Any media file",
3139
+ type: "object",
3140
+ properties: {
3141
+ id: {
3142
+ $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
3143
+ },
3144
+ type: {
3145
+ type: "string",
3146
+ default: "mediaFile"
3147
+ },
3148
+ fileHash: {
3149
+ type: "string"
3150
+ },
3151
+ mimeType: {
3152
+ type: "string",
3153
+ enum: [
3154
+ "image/*",
3155
+ "image/jpeg",
3156
+ "image/png",
3157
+ "image/gif",
3158
+ "image/webp",
3159
+ "image/avif",
3160
+ "image/svg+xml",
3161
+ "application/pdf"
3162
+ ]
3163
+ },
3164
+ url: {
3165
+ type: "string",
3166
+ format: "uri"
3167
+ },
3168
+ width: {
3169
+ type: "integer",
3170
+ minimum: 0
3171
+ },
3172
+ height: {
3173
+ type: "integer",
3174
+ minimum: 0
3175
+ },
3176
+ size: {
3177
+ type: "integer",
3178
+ minimum: 0,
3179
+ description: "Size in bytes"
3180
+ },
3181
+ uploadUrl: {
3182
+ type: "string",
3183
+ format: "uri"
3184
+ },
3185
+ uploadUrlExpires: {
3186
+ $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/date"
3187
+ },
3188
+ createdBy: {
3189
+ type: "string"
3190
+ },
3191
+ systemData: {
3192
+ $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/systemData"
3193
+ }
3194
+ },
3195
+ additionalProperties: false,
3196
+ required: ["id", "type"]
3197
+ };
3198
+ }
3199
+ });
3200
+
3201
+ // src/Models/mediaFile.js
3202
+ var require_mediaFile2 = __commonJS({
3203
+ "src/Models/mediaFile.js"(exports2, module2) {
3204
+ var schemas = require_schema();
3205
+ var schema = require_mediaFile();
3206
+ var Kohost = require_kohost();
3207
+ var { RequestError } = require_Errors();
3208
+ schemas.add(schema);
3209
+ var validator = schemas.compile(schema);
3210
+ var MediaFile2 = class extends Kohost {
3211
+ constructor(data) {
3212
+ super(data);
3213
+ }
3214
+ createImageVariant(params) {
3215
+ if (this.mimeType != "image/*")
3216
+ throw new RequestError("Only dynamic images can have variants");
3217
+ const query = Object.keys(params).map((key) => `${key}=${params[key]}`).join(",");
3218
+ return this.url.replace(/\/public$/, `/${query}`);
3219
+ }
3220
+ };
3221
+ __name(MediaFile2, "MediaFile");
3222
+ Object.defineProperty(MediaFile2.prototype, "schema", {
3223
+ value: schema
3224
+ });
3225
+ Object.defineProperty(MediaFile2.prototype, "validator", {
3226
+ get: function() {
3227
+ return validator;
3228
+ }
3229
+ });
3230
+ Object.defineProperty(MediaFile2, "validProperties", {
3231
+ value: Object.keys(schema.properties)
3232
+ });
3233
+ module2.exports = MediaFile2;
3234
+ }
3235
+ });
3236
+
3114
3237
  // src/schemas/ticket.json
3115
3238
  var require_ticket = __commonJS({
3116
3239
  "src/schemas/ticket.json"(exports2, module2) {
@@ -3152,6 +3275,9 @@ var require_ticket = __commonJS({
3152
3275
  items: {
3153
3276
  type: "string"
3154
3277
  }
3278
+ },
3279
+ media: {
3280
+ $ref: "https://api.kohost.io/schemas/v3/mediaFile.json"
3155
3281
  }
3156
3282
  },
3157
3283
  required: ["userId", "id", "timestamp", "body"]
@@ -3175,17 +3301,25 @@ var require_ticket = __commonJS({
3175
3301
  type: "string"
3176
3302
  }
3177
3303
  },
3304
+ rating: {
3305
+ type: "number",
3306
+ minimum: 0,
3307
+ maximum: 5
3308
+ },
3309
+ ratingComment: {
3310
+ type: "string"
3311
+ },
3178
3312
  createdAt: {
3179
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/createdAt"
3313
+ $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/date"
3180
3314
  },
3181
3315
  updatedAt: {
3182
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/createdAt"
3316
+ $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/date"
3183
3317
  },
3184
3318
  solvedAt: {
3185
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/createdAt"
3319
+ $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/date"
3186
3320
  },
3187
3321
  closedAt: {
3188
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/createdAt"
3322
+ $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/date"
3189
3323
  }
3190
3324
  },
3191
3325
  required: [
@@ -3208,14 +3342,17 @@ var require_ticket2 = __commonJS({
3208
3342
  var schemas = require_schema();
3209
3343
  var schema = require_ticket();
3210
3344
  var Kohost = require_kohost();
3345
+ var MediaFile2 = require_mediaFile2();
3211
3346
  var sortBy = require("lodash.sortby");
3212
3347
  var findLast = require("lodash.findlast");
3213
3348
  var { nanoid } = require("nanoid");
3349
+ var cloneDeep = require("lodash.clonedeep");
3214
3350
  schemas.add(schema);
3215
3351
  var validator = schemas.compile(schema);
3216
3352
  var Ticket2 = class extends Kohost {
3217
3353
  constructor(data) {
3218
- super(data);
3354
+ const ticketData = mapConversationData(data);
3355
+ super(ticketData);
3219
3356
  }
3220
3357
  static generateMessageId(len = 16) {
3221
3358
  return nanoid(len);
@@ -3278,6 +3415,17 @@ var require_ticket2 = __commonJS({
3278
3415
  return lastFromNonRequester.userId;
3279
3416
  }
3280
3417
  });
3418
+ function mapConversationData(data) {
3419
+ const ticketData = cloneDeep(data);
3420
+ ticketData.conversation = ticketData.conversation.map((msg) => {
3421
+ if (msg.media) {
3422
+ msg.media = new MediaFile2(msg.media);
3423
+ }
3424
+ return msg;
3425
+ });
3426
+ return ticketData;
3427
+ }
3428
+ __name(mapConversationData, "mapConversationData");
3281
3429
  module2.exports = Ticket2;
3282
3430
  }
3283
3431
  });
@@ -3360,7 +3508,7 @@ var require_product = __commonJS({
3360
3508
  $id: "https://api.kohost.io/schemas/v3/product.json",
3361
3509
  title: "Product",
3362
3510
  type: "object",
3363
- required: ["name", "price", "currency", "driver"],
3511
+ required: ["name", "price", "driver"],
3364
3512
  properties: {
3365
3513
  id: {
3366
3514
  $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
@@ -3380,15 +3528,12 @@ var require_product = __commonJS({
3380
3528
  price: {
3381
3529
  type: "number"
3382
3530
  },
3383
- currency: {
3384
- type: "string",
3385
- description: "ISO 4217 format",
3386
- minLength: 3,
3387
- maxLength: 3
3388
- },
3389
3531
  image: {
3390
3532
  $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/file"
3391
3533
  },
3534
+ category: {
3535
+ type: "string"
3536
+ },
3392
3537
  imageUrl: {
3393
3538
  format: "uri",
3394
3539
  pattern: "^https?://"
@@ -3858,6 +4003,208 @@ var require_energyReport2 = __commonJS({
3858
4003
  }
3859
4004
  });
3860
4005
 
4006
+ // src/schemas/smsMessage.json
4007
+ var require_smsMessage = __commonJS({
4008
+ "src/schemas/smsMessage.json"(exports2, module2) {
4009
+ module2.exports = {
4010
+ $schema: "http://json-schema.org/draft-07/schema",
4011
+ $id: "https://api.kohost.io/schemas/v3/smsMessage.json",
4012
+ title: "SMS Message",
4013
+ type: "object",
4014
+ required: ["to", "from", "body", "status"],
4015
+ properties: {
4016
+ id: {
4017
+ $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
4018
+ },
4019
+ type: {
4020
+ type: "string",
4021
+ default: "smsMessage"
4022
+ },
4023
+ to: {
4024
+ type: "string",
4025
+ pattern: "^\\+[0-9]{1,14}$"
4026
+ },
4027
+ from: {
4028
+ type: "string",
4029
+ pattern: "^\\+[0-9]{1,14}$"
4030
+ },
4031
+ media: {
4032
+ type: "string",
4033
+ format: "uri"
4034
+ },
4035
+ status: {
4036
+ type: "string",
4037
+ enum: [
4038
+ "queued",
4039
+ "accepted",
4040
+ "sending",
4041
+ "sent",
4042
+ "failed",
4043
+ "delivered",
4044
+ "undelivered",
4045
+ "receiving",
4046
+ "received",
4047
+ "read"
4048
+ ]
4049
+ },
4050
+ body: {
4051
+ type: "string"
4052
+ },
4053
+ driver: {
4054
+ type: "string"
4055
+ },
4056
+ appData: {
4057
+ type: "object"
4058
+ },
4059
+ createdAt: {
4060
+ $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/date"
4061
+ },
4062
+ updatedAt: {
4063
+ $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/date"
4064
+ },
4065
+ systemData: {
4066
+ $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/systemData"
4067
+ }
4068
+ }
4069
+ };
4070
+ }
4071
+ });
4072
+
4073
+ // src/Models/smsMessage.js
4074
+ var require_smsMessage2 = __commonJS({
4075
+ "src/Models/smsMessage.js"(exports2, module2) {
4076
+ var schemas = require_schema();
4077
+ var schema = require_smsMessage();
4078
+ var Kohost = require_kohost();
4079
+ schemas.add(schema);
4080
+ var validator = schemas.compile(schema);
4081
+ var SMSMessage2 = class extends Kohost {
4082
+ constructor(data) {
4083
+ super(data);
4084
+ }
4085
+ };
4086
+ __name(SMSMessage2, "SMSMessage");
4087
+ Object.defineProperty(SMSMessage2.prototype, "schema", {
4088
+ value: schema
4089
+ });
4090
+ Object.defineProperty(SMSMessage2.prototype, "validator", {
4091
+ get: function() {
4092
+ return validator;
4093
+ }
4094
+ });
4095
+ Object.defineProperty(SMSMessage2, "validProperties", {
4096
+ value: Object.keys(schema.properties)
4097
+ });
4098
+ module2.exports = SMSMessage2;
4099
+ }
4100
+ });
4101
+
4102
+ // src/schemas/emailMessage.json
4103
+ var require_emailMessage = __commonJS({
4104
+ "src/schemas/emailMessage.json"(exports2, module2) {
4105
+ module2.exports = {
4106
+ $schema: "http://json-schema.org/draft-07/schema",
4107
+ $id: "https://api.kohost.io/schemas/v3/emailMessage.json",
4108
+ title: "Email Message",
4109
+ type: "object",
4110
+ required: ["to", "from", "status", "subject"],
4111
+ properties: {
4112
+ id: {
4113
+ $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
4114
+ },
4115
+ type: {
4116
+ type: "string",
4117
+ default: "emailMessage"
4118
+ },
4119
+ to: {
4120
+ type: "string",
4121
+ pattern: "^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\\.[a-zA-Z0-9-.]+$"
4122
+ },
4123
+ from: {
4124
+ type: "string",
4125
+ pattern: ".*<[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\\.[a-zA-Z0-9-.]+>.*",
4126
+ description: "Must be in the format of 'Sender <email@example.com>"
4127
+ },
4128
+ subject: {
4129
+ type: "string"
4130
+ },
4131
+ status: {
4132
+ type: "string",
4133
+ enum: [
4134
+ "queued",
4135
+ "sending",
4136
+ "sent",
4137
+ "deferred",
4138
+ "delivered",
4139
+ "undelivered",
4140
+ "bounced",
4141
+ "blocked",
4142
+ "receiving",
4143
+ "received",
4144
+ "opened",
4145
+ "clicked",
4146
+ "unsubscribed",
4147
+ "spamReport"
4148
+ ]
4149
+ },
4150
+ statusMessage: {
4151
+ type: "string"
4152
+ },
4153
+ html: {
4154
+ type: "string"
4155
+ },
4156
+ text: {
4157
+ type: "string"
4158
+ },
4159
+ driver: {
4160
+ type: "string"
4161
+ },
4162
+ appData: {
4163
+ type: "object"
4164
+ },
4165
+ createdAt: {
4166
+ $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/date"
4167
+ },
4168
+ updatedAt: {
4169
+ $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/date"
4170
+ },
4171
+ systemData: {
4172
+ $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/systemData"
4173
+ }
4174
+ }
4175
+ };
4176
+ }
4177
+ });
4178
+
4179
+ // src/Models/emailMessage.js
4180
+ var require_emailMessage2 = __commonJS({
4181
+ "src/Models/emailMessage.js"(exports2, module2) {
4182
+ var schemas = require_schema();
4183
+ var schema = require_emailMessage();
4184
+ var Kohost = require_kohost();
4185
+ schemas.add(schema);
4186
+ var validator = schemas.compile(schema);
4187
+ var EmailMessage2 = class extends Kohost {
4188
+ constructor(data) {
4189
+ super(data);
4190
+ }
4191
+ };
4192
+ __name(EmailMessage2, "EmailMessage");
4193
+ Object.defineProperty(EmailMessage2.prototype, "schema", {
4194
+ value: schema
4195
+ });
4196
+ Object.defineProperty(EmailMessage2.prototype, "validator", {
4197
+ get: function() {
4198
+ return validator;
4199
+ }
4200
+ });
4201
+ Object.defineProperty(EmailMessage2, "validProperties", {
4202
+ value: Object.keys(schema.properties)
4203
+ });
4204
+ module2.exports = EmailMessage2;
4205
+ }
4206
+ });
4207
+
3861
4208
  // src/schemas/property.json
3862
4209
  var require_property = __commonJS({
3863
4210
  "src/schemas/property.json"(exports2, module2) {
@@ -4027,7 +4374,21 @@ var require_property = __commonJS({
4027
4374
  type: "object",
4028
4375
  properties: {
4029
4376
  RoomControl: {},
4030
- CheckIn: {},
4377
+ CheckIn: {
4378
+ properties: {
4379
+ payment: {},
4380
+ identification: {},
4381
+ earlyCheckIn: {
4382
+ properties: {
4383
+ dynamic: {
4384
+ type: "boolean",
4385
+ default: false
4386
+ }
4387
+ }
4388
+ },
4389
+ roomUpgrades: {}
4390
+ }
4391
+ },
4031
4392
  CheckOut: {},
4032
4393
  Concierge: {},
4033
4394
  DigitalKey: {
@@ -4201,6 +4562,7 @@ var Room = require_room2();
4201
4562
  var Reservation = require_reservation2();
4202
4563
  var Space = require_space2();
4203
4564
  var SpaceType = require_spaceType2();
4565
+ var MediaFile = require_mediaFile2();
4204
4566
  var Ticket = require_ticket2();
4205
4567
  var Scene = require_scene2();
4206
4568
  var Gateway = require_gateway2();
@@ -4210,6 +4572,8 @@ var Credential = require_credential2();
4210
4572
  var ShortLink = require_shortLink2();
4211
4573
  var EnergyReportShard = require_energyReportShard2();
4212
4574
  var EnergyReport = require_energyReport2();
4575
+ var SMSMessage = require_smsMessage2();
4576
+ var EmailMessage = require_emailMessage2();
4213
4577
  var Property = require_property2();
4214
4578
  var Organization = require_organization2();
4215
4579
  module.exports = {
@@ -4240,5 +4604,8 @@ module.exports = {
4240
4604
  Credential,
4241
4605
  ShortLink,
4242
4606
  EnergyReportShard,
4243
- EnergyReport
4607
+ EnergyReport,
4608
+ SMSMessage,
4609
+ EmailMessage,
4610
+ MediaFile
4244
4611
  };
package/dist/cjs/utils.js CHANGED
@@ -69,6 +69,10 @@ var require_common = __commonJS({
69
69
  type: "object",
70
70
  default: {}
71
71
  },
72
+ date: {
73
+ type: ["string", "object"],
74
+ format: "date-time"
75
+ },
72
76
  createdAt: {
73
77
  type: ["string", "object"],
74
78
  format: "date-time"
@@ -140,6 +144,7 @@ var require_common = __commonJS({
140
144
  "lg",
141
145
  "lirc",
142
146
  "mews",
147
+ "paxton",
143
148
  "pelican-wireless",
144
149
  "rebrandly",
145
150
  "salto",
@@ -147,7 +152,9 @@ var require_common = __commonJS({
147
152
  "se",
148
153
  "sendgrid",
149
154
  "stay-n-touch",
150
- "twilio"
155
+ "twilio",
156
+ "cloudflare-images",
157
+ "cloudflare-stream"
151
158
  ]
152
159
  }
153
160
  }