@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.
@@ -7403,6 +7403,10 @@ var require_common = __commonJS({
7403
7403
  type: "object",
7404
7404
  default: {}
7405
7405
  },
7406
+ date: {
7407
+ type: ["string", "object"],
7408
+ format: "date-time"
7409
+ },
7406
7410
  createdAt: {
7407
7411
  type: ["string", "object"],
7408
7412
  format: "date-time"
@@ -7474,6 +7478,7 @@ var require_common = __commonJS({
7474
7478
  "lg",
7475
7479
  "lirc",
7476
7480
  "mews",
7481
+ "paxton",
7477
7482
  "pelican-wireless",
7478
7483
  "rebrandly",
7479
7484
  "salto",
@@ -7481,7 +7486,9 @@ var require_common = __commonJS({
7481
7486
  "se",
7482
7487
  "sendgrid",
7483
7488
  "stay-n-touch",
7484
- "twilio"
7489
+ "twilio",
7490
+ "cloudflare-images",
7491
+ "cloudflare-stream"
7485
7492
  ]
7486
7493
  }
7487
7494
  }
@@ -8264,6 +8271,9 @@ var require_lock = __commonJS({
8264
8271
  type: {
8265
8272
  $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/type"
8266
8273
  },
8274
+ offline: {
8275
+ type: "boolean"
8276
+ },
8267
8277
  supportedNotifications: {
8268
8278
  $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/supportedNotifications"
8269
8279
  },
@@ -9312,6 +9322,9 @@ var require_camera = __commonJS({
9312
9322
  }
9313
9323
  }
9314
9324
  },
9325
+ previewImage: {
9326
+ type: "string"
9327
+ },
9315
9328
  systemData: {
9316
9329
  $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/systemData"
9317
9330
  },
@@ -9446,6 +9459,9 @@ var require_mediaSource = __commonJS({
9446
9459
  "uncontrolledDevice"
9447
9460
  ]
9448
9461
  },
9462
+ name: {
9463
+ $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/name"
9464
+ },
9449
9465
  driver: {
9450
9466
  $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/driver"
9451
9467
  },
@@ -10903,13 +10919,14 @@ var require_reservation = __commonJS({
10903
10919
  properties: {
10904
10920
  date: {
10905
10921
  type: "string",
10906
- format: "date"
10922
+ format: "date-time"
10907
10923
  },
10908
10924
  amount: {
10909
10925
  type: "number"
10910
10926
  },
10911
10927
  type: {
10912
- type: "string"
10928
+ type: "string",
10929
+ enum: ["service", "product"]
10913
10930
  }
10914
10931
  }
10915
10932
  }
@@ -11291,6 +11308,112 @@ var require_spaceType2 = __commonJS({
11291
11308
  }
11292
11309
  });
11293
11310
 
11311
+ // src/schemas/mediaFile.json
11312
+ var require_mediaFile = __commonJS({
11313
+ "src/schemas/mediaFile.json"(exports, module) {
11314
+ module.exports = {
11315
+ $schema: "http://json-schema.org/draft-07/schema",
11316
+ $id: "https://api.kohost.io/schemas/v3/mediaFile.json",
11317
+ title: "Media File",
11318
+ description: "Any media file",
11319
+ type: "object",
11320
+ properties: {
11321
+ id: {
11322
+ $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
11323
+ },
11324
+ type: {
11325
+ type: "string",
11326
+ default: "mediaFile"
11327
+ },
11328
+ fileHash: {
11329
+ type: "string"
11330
+ },
11331
+ mimeType: {
11332
+ type: "string",
11333
+ enum: [
11334
+ "image/*",
11335
+ "image/jpeg",
11336
+ "image/png",
11337
+ "image/gif",
11338
+ "image/webp",
11339
+ "image/avif",
11340
+ "image/svg+xml",
11341
+ "application/pdf"
11342
+ ]
11343
+ },
11344
+ url: {
11345
+ type: "string",
11346
+ format: "uri"
11347
+ },
11348
+ width: {
11349
+ type: "integer",
11350
+ minimum: 0
11351
+ },
11352
+ height: {
11353
+ type: "integer",
11354
+ minimum: 0
11355
+ },
11356
+ size: {
11357
+ type: "integer",
11358
+ minimum: 0,
11359
+ description: "Size in bytes"
11360
+ },
11361
+ uploadUrl: {
11362
+ type: "string",
11363
+ format: "uri"
11364
+ },
11365
+ uploadUrlExpires: {
11366
+ $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/date"
11367
+ },
11368
+ createdBy: {
11369
+ type: "string"
11370
+ },
11371
+ systemData: {
11372
+ $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/systemData"
11373
+ }
11374
+ },
11375
+ additionalProperties: false,
11376
+ required: ["id", "type"]
11377
+ };
11378
+ }
11379
+ });
11380
+
11381
+ // src/Models/mediaFile.js
11382
+ var require_mediaFile2 = __commonJS({
11383
+ "src/Models/mediaFile.js"(exports, module) {
11384
+ var schemas = require_schema();
11385
+ var schema = require_mediaFile();
11386
+ var Kohost = require_kohost();
11387
+ var { RequestError } = require_Errors();
11388
+ schemas.add(schema);
11389
+ var validator = schemas.compile(schema);
11390
+ var MediaFile = class extends Kohost {
11391
+ constructor(data) {
11392
+ super(data);
11393
+ }
11394
+ createImageVariant(params) {
11395
+ if (this.mimeType != "image/*")
11396
+ throw new RequestError("Only dynamic images can have variants");
11397
+ const query = Object.keys(params).map((key) => `${key}=${params[key]}`).join(",");
11398
+ return this.url.replace(/\/public$/, `/${query}`);
11399
+ }
11400
+ };
11401
+ __name(MediaFile, "MediaFile");
11402
+ Object.defineProperty(MediaFile.prototype, "schema", {
11403
+ value: schema
11404
+ });
11405
+ Object.defineProperty(MediaFile.prototype, "validator", {
11406
+ get: function() {
11407
+ return validator;
11408
+ }
11409
+ });
11410
+ Object.defineProperty(MediaFile, "validProperties", {
11411
+ value: Object.keys(schema.properties)
11412
+ });
11413
+ module.exports = MediaFile;
11414
+ }
11415
+ });
11416
+
11294
11417
  // src/schemas/ticket.json
11295
11418
  var require_ticket = __commonJS({
11296
11419
  "src/schemas/ticket.json"(exports, module) {
@@ -11332,6 +11455,9 @@ var require_ticket = __commonJS({
11332
11455
  items: {
11333
11456
  type: "string"
11334
11457
  }
11458
+ },
11459
+ media: {
11460
+ $ref: "https://api.kohost.io/schemas/v3/mediaFile.json"
11335
11461
  }
11336
11462
  },
11337
11463
  required: ["userId", "id", "timestamp", "body"]
@@ -11355,17 +11481,25 @@ var require_ticket = __commonJS({
11355
11481
  type: "string"
11356
11482
  }
11357
11483
  },
11484
+ rating: {
11485
+ type: "number",
11486
+ minimum: 0,
11487
+ maximum: 5
11488
+ },
11489
+ ratingComment: {
11490
+ type: "string"
11491
+ },
11358
11492
  createdAt: {
11359
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/createdAt"
11493
+ $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/date"
11360
11494
  },
11361
11495
  updatedAt: {
11362
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/createdAt"
11496
+ $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/date"
11363
11497
  },
11364
11498
  solvedAt: {
11365
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/createdAt"
11499
+ $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/date"
11366
11500
  },
11367
11501
  closedAt: {
11368
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/createdAt"
11502
+ $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/date"
11369
11503
  }
11370
11504
  },
11371
11505
  required: [
@@ -13452,14 +13586,17 @@ var require_ticket2 = __commonJS({
13452
13586
  var schemas = require_schema();
13453
13587
  var schema = require_ticket();
13454
13588
  var Kohost = require_kohost();
13589
+ var MediaFile = require_mediaFile2();
13455
13590
  var sortBy = require_lodash2();
13456
13591
  var findLast = require_lodash3();
13457
13592
  var { nanoid: nanoid3 } = (init_index_browser(), __toCommonJS(index_browser_exports));
13593
+ var cloneDeep = require_lodash();
13458
13594
  schemas.add(schema);
13459
13595
  var validator = schemas.compile(schema);
13460
13596
  var Ticket = class extends Kohost {
13461
13597
  constructor(data) {
13462
- super(data);
13598
+ const ticketData = mapConversationData(data);
13599
+ super(ticketData);
13463
13600
  }
13464
13601
  static generateMessageId(len = 16) {
13465
13602
  return nanoid3(len);
@@ -13522,6 +13659,17 @@ var require_ticket2 = __commonJS({
13522
13659
  return lastFromNonRequester.userId;
13523
13660
  }
13524
13661
  });
13662
+ function mapConversationData(data) {
13663
+ const ticketData = cloneDeep(data);
13664
+ ticketData.conversation = ticketData.conversation.map((msg) => {
13665
+ if (msg.media) {
13666
+ msg.media = new MediaFile(msg.media);
13667
+ }
13668
+ return msg;
13669
+ });
13670
+ return ticketData;
13671
+ }
13672
+ __name(mapConversationData, "mapConversationData");
13525
13673
  module.exports = Ticket;
13526
13674
  }
13527
13675
  });
@@ -13604,7 +13752,7 @@ var require_product = __commonJS({
13604
13752
  $id: "https://api.kohost.io/schemas/v3/product.json",
13605
13753
  title: "Product",
13606
13754
  type: "object",
13607
- required: ["name", "price", "currency", "driver"],
13755
+ required: ["name", "price", "driver"],
13608
13756
  properties: {
13609
13757
  id: {
13610
13758
  $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
@@ -13624,15 +13772,12 @@ var require_product = __commonJS({
13624
13772
  price: {
13625
13773
  type: "number"
13626
13774
  },
13627
- currency: {
13628
- type: "string",
13629
- description: "ISO 4217 format",
13630
- minLength: 3,
13631
- maxLength: 3
13632
- },
13633
13775
  image: {
13634
13776
  $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/file"
13635
13777
  },
13778
+ category: {
13779
+ type: "string"
13780
+ },
13636
13781
  imageUrl: {
13637
13782
  format: "uri",
13638
13783
  pattern: "^https?://"
@@ -14102,6 +14247,208 @@ var require_energyReport2 = __commonJS({
14102
14247
  }
14103
14248
  });
14104
14249
 
14250
+ // src/schemas/smsMessage.json
14251
+ var require_smsMessage = __commonJS({
14252
+ "src/schemas/smsMessage.json"(exports, module) {
14253
+ module.exports = {
14254
+ $schema: "http://json-schema.org/draft-07/schema",
14255
+ $id: "https://api.kohost.io/schemas/v3/smsMessage.json",
14256
+ title: "SMS Message",
14257
+ type: "object",
14258
+ required: ["to", "from", "body", "status"],
14259
+ properties: {
14260
+ id: {
14261
+ $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
14262
+ },
14263
+ type: {
14264
+ type: "string",
14265
+ default: "smsMessage"
14266
+ },
14267
+ to: {
14268
+ type: "string",
14269
+ pattern: "^\\+[0-9]{1,14}$"
14270
+ },
14271
+ from: {
14272
+ type: "string",
14273
+ pattern: "^\\+[0-9]{1,14}$"
14274
+ },
14275
+ media: {
14276
+ type: "string",
14277
+ format: "uri"
14278
+ },
14279
+ status: {
14280
+ type: "string",
14281
+ enum: [
14282
+ "queued",
14283
+ "accepted",
14284
+ "sending",
14285
+ "sent",
14286
+ "failed",
14287
+ "delivered",
14288
+ "undelivered",
14289
+ "receiving",
14290
+ "received",
14291
+ "read"
14292
+ ]
14293
+ },
14294
+ body: {
14295
+ type: "string"
14296
+ },
14297
+ driver: {
14298
+ type: "string"
14299
+ },
14300
+ appData: {
14301
+ type: "object"
14302
+ },
14303
+ createdAt: {
14304
+ $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/date"
14305
+ },
14306
+ updatedAt: {
14307
+ $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/date"
14308
+ },
14309
+ systemData: {
14310
+ $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/systemData"
14311
+ }
14312
+ }
14313
+ };
14314
+ }
14315
+ });
14316
+
14317
+ // src/Models/smsMessage.js
14318
+ var require_smsMessage2 = __commonJS({
14319
+ "src/Models/smsMessage.js"(exports, module) {
14320
+ var schemas = require_schema();
14321
+ var schema = require_smsMessage();
14322
+ var Kohost = require_kohost();
14323
+ schemas.add(schema);
14324
+ var validator = schemas.compile(schema);
14325
+ var SMSMessage = class extends Kohost {
14326
+ constructor(data) {
14327
+ super(data);
14328
+ }
14329
+ };
14330
+ __name(SMSMessage, "SMSMessage");
14331
+ Object.defineProperty(SMSMessage.prototype, "schema", {
14332
+ value: schema
14333
+ });
14334
+ Object.defineProperty(SMSMessage.prototype, "validator", {
14335
+ get: function() {
14336
+ return validator;
14337
+ }
14338
+ });
14339
+ Object.defineProperty(SMSMessage, "validProperties", {
14340
+ value: Object.keys(schema.properties)
14341
+ });
14342
+ module.exports = SMSMessage;
14343
+ }
14344
+ });
14345
+
14346
+ // src/schemas/emailMessage.json
14347
+ var require_emailMessage = __commonJS({
14348
+ "src/schemas/emailMessage.json"(exports, module) {
14349
+ module.exports = {
14350
+ $schema: "http://json-schema.org/draft-07/schema",
14351
+ $id: "https://api.kohost.io/schemas/v3/emailMessage.json",
14352
+ title: "Email Message",
14353
+ type: "object",
14354
+ required: ["to", "from", "status", "subject"],
14355
+ properties: {
14356
+ id: {
14357
+ $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
14358
+ },
14359
+ type: {
14360
+ type: "string",
14361
+ default: "emailMessage"
14362
+ },
14363
+ to: {
14364
+ type: "string",
14365
+ pattern: "^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\\.[a-zA-Z0-9-.]+$"
14366
+ },
14367
+ from: {
14368
+ type: "string",
14369
+ pattern: ".*<[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\\.[a-zA-Z0-9-.]+>.*",
14370
+ description: "Must be in the format of 'Sender <email@example.com>"
14371
+ },
14372
+ subject: {
14373
+ type: "string"
14374
+ },
14375
+ status: {
14376
+ type: "string",
14377
+ enum: [
14378
+ "queued",
14379
+ "sending",
14380
+ "sent",
14381
+ "deferred",
14382
+ "delivered",
14383
+ "undelivered",
14384
+ "bounced",
14385
+ "blocked",
14386
+ "receiving",
14387
+ "received",
14388
+ "opened",
14389
+ "clicked",
14390
+ "unsubscribed",
14391
+ "spamReport"
14392
+ ]
14393
+ },
14394
+ statusMessage: {
14395
+ type: "string"
14396
+ },
14397
+ html: {
14398
+ type: "string"
14399
+ },
14400
+ text: {
14401
+ type: "string"
14402
+ },
14403
+ driver: {
14404
+ type: "string"
14405
+ },
14406
+ appData: {
14407
+ type: "object"
14408
+ },
14409
+ createdAt: {
14410
+ $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/date"
14411
+ },
14412
+ updatedAt: {
14413
+ $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/date"
14414
+ },
14415
+ systemData: {
14416
+ $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/systemData"
14417
+ }
14418
+ }
14419
+ };
14420
+ }
14421
+ });
14422
+
14423
+ // src/Models/emailMessage.js
14424
+ var require_emailMessage2 = __commonJS({
14425
+ "src/Models/emailMessage.js"(exports, module) {
14426
+ var schemas = require_schema();
14427
+ var schema = require_emailMessage();
14428
+ var Kohost = require_kohost();
14429
+ schemas.add(schema);
14430
+ var validator = schemas.compile(schema);
14431
+ var EmailMessage = class extends Kohost {
14432
+ constructor(data) {
14433
+ super(data);
14434
+ }
14435
+ };
14436
+ __name(EmailMessage, "EmailMessage");
14437
+ Object.defineProperty(EmailMessage.prototype, "schema", {
14438
+ value: schema
14439
+ });
14440
+ Object.defineProperty(EmailMessage.prototype, "validator", {
14441
+ get: function() {
14442
+ return validator;
14443
+ }
14444
+ });
14445
+ Object.defineProperty(EmailMessage, "validProperties", {
14446
+ value: Object.keys(schema.properties)
14447
+ });
14448
+ module.exports = EmailMessage;
14449
+ }
14450
+ });
14451
+
14105
14452
  // src/schemas/property.json
14106
14453
  var require_property = __commonJS({
14107
14454
  "src/schemas/property.json"(exports, module) {
@@ -14271,7 +14618,21 @@ var require_property = __commonJS({
14271
14618
  type: "object",
14272
14619
  properties: {
14273
14620
  RoomControl: {},
14274
- CheckIn: {},
14621
+ CheckIn: {
14622
+ properties: {
14623
+ payment: {},
14624
+ identification: {},
14625
+ earlyCheckIn: {
14626
+ properties: {
14627
+ dynamic: {
14628
+ type: "boolean",
14629
+ default: false
14630
+ }
14631
+ }
14632
+ },
14633
+ roomUpgrades: {}
14634
+ }
14635
+ },
14275
14636
  CheckOut: {},
14276
14637
  Concierge: {},
14277
14638
  DigitalKey: {
@@ -14447,6 +14808,7 @@ var require_Models = __commonJS({
14447
14808
  var Reservation = require_reservation2();
14448
14809
  var Space = require_space2();
14449
14810
  var SpaceType = require_spaceType2();
14811
+ var MediaFile = require_mediaFile2();
14450
14812
  var Ticket = require_ticket2();
14451
14813
  var Scene = require_scene2();
14452
14814
  var Gateway = require_gateway2();
@@ -14456,6 +14818,8 @@ var require_Models = __commonJS({
14456
14818
  var ShortLink = require_shortLink2();
14457
14819
  var EnergyReportShard = require_energyReportShard2();
14458
14820
  var EnergyReport = require_energyReport2();
14821
+ var SMSMessage = require_smsMessage2();
14822
+ var EmailMessage = require_emailMessage2();
14459
14823
  var Property = require_property2();
14460
14824
  var Organization = require_organization2();
14461
14825
  module.exports = {
@@ -14486,7 +14850,10 @@ var require_Models = __commonJS({
14486
14850
  Credential,
14487
14851
  ShortLink,
14488
14852
  EnergyReportShard,
14489
- EnergyReport
14853
+ EnergyReport,
14854
+ SMSMessage,
14855
+ EmailMessage,
14856
+ MediaFile
14490
14857
  };
14491
14858
  }
14492
14859
  });