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

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"
@@ -11291,6 +11295,112 @@ var require_spaceType2 = __commonJS({
11291
11295
  }
11292
11296
  });
11293
11297
 
11298
+ // src/schemas/mediaFile.json
11299
+ var require_mediaFile = __commonJS({
11300
+ "src/schemas/mediaFile.json"(exports, module) {
11301
+ module.exports = {
11302
+ $schema: "http://json-schema.org/draft-07/schema",
11303
+ $id: "https://api.kohost.io/schemas/v3/mediaFile.json",
11304
+ title: "Media File",
11305
+ description: "Any media file",
11306
+ type: "object",
11307
+ properties: {
11308
+ id: {
11309
+ $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
11310
+ },
11311
+ type: {
11312
+ type: "string",
11313
+ default: "mediaFile"
11314
+ },
11315
+ fileHash: {
11316
+ type: "string"
11317
+ },
11318
+ mimeType: {
11319
+ type: "string",
11320
+ enum: [
11321
+ "image/*",
11322
+ "image/jpeg",
11323
+ "image/png",
11324
+ "image/gif",
11325
+ "image/webp",
11326
+ "image/avif",
11327
+ "image/svg+xml",
11328
+ "application/pdf"
11329
+ ]
11330
+ },
11331
+ url: {
11332
+ type: "string",
11333
+ format: "uri"
11334
+ },
11335
+ width: {
11336
+ type: "integer",
11337
+ minimum: 0
11338
+ },
11339
+ height: {
11340
+ type: "integer",
11341
+ minimum: 0
11342
+ },
11343
+ size: {
11344
+ type: "integer",
11345
+ minimum: 0,
11346
+ description: "Size in bytes"
11347
+ },
11348
+ uploadUrl: {
11349
+ type: "string",
11350
+ format: "uri"
11351
+ },
11352
+ uploadUrlExpires: {
11353
+ $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/date"
11354
+ },
11355
+ createdBy: {
11356
+ type: "string"
11357
+ },
11358
+ systemData: {
11359
+ $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/systemData"
11360
+ }
11361
+ },
11362
+ additionalProperties: false,
11363
+ required: ["id", "type"]
11364
+ };
11365
+ }
11366
+ });
11367
+
11368
+ // src/Models/mediaFile.js
11369
+ var require_mediaFile2 = __commonJS({
11370
+ "src/Models/mediaFile.js"(exports, module) {
11371
+ var schemas = require_schema();
11372
+ var schema = require_mediaFile();
11373
+ var Kohost = require_kohost();
11374
+ var { RequestError } = require_Errors();
11375
+ schemas.add(schema);
11376
+ var validator = schemas.compile(schema);
11377
+ var MediaFile = class extends Kohost {
11378
+ constructor(data) {
11379
+ super(data);
11380
+ }
11381
+ createImageVariant(params) {
11382
+ if (this.mimeType != "image/*")
11383
+ throw new RequestError("Only dynamic images can have variants");
11384
+ const query = Object.keys(params).map((key) => `${key}=${params[key]}`).join(",");
11385
+ return this.url.replace(/\/public$/, `/${query}`);
11386
+ }
11387
+ };
11388
+ __name(MediaFile, "MediaFile");
11389
+ Object.defineProperty(MediaFile.prototype, "schema", {
11390
+ value: schema
11391
+ });
11392
+ Object.defineProperty(MediaFile.prototype, "validator", {
11393
+ get: function() {
11394
+ return validator;
11395
+ }
11396
+ });
11397
+ Object.defineProperty(MediaFile, "validProperties", {
11398
+ value: Object.keys(schema.properties)
11399
+ });
11400
+ module.exports = MediaFile;
11401
+ }
11402
+ });
11403
+
11294
11404
  // src/schemas/ticket.json
11295
11405
  var require_ticket = __commonJS({
11296
11406
  "src/schemas/ticket.json"(exports, module) {
@@ -11332,6 +11442,9 @@ var require_ticket = __commonJS({
11332
11442
  items: {
11333
11443
  type: "string"
11334
11444
  }
11445
+ },
11446
+ media: {
11447
+ $ref: "https://api.kohost.io/schemas/v3/mediaFile.json"
11335
11448
  }
11336
11449
  },
11337
11450
  required: ["userId", "id", "timestamp", "body"]
@@ -11355,17 +11468,25 @@ var require_ticket = __commonJS({
11355
11468
  type: "string"
11356
11469
  }
11357
11470
  },
11471
+ rating: {
11472
+ type: "number",
11473
+ minimum: 0,
11474
+ maximum: 5
11475
+ },
11476
+ ratingComment: {
11477
+ type: "string"
11478
+ },
11358
11479
  createdAt: {
11359
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/createdAt"
11480
+ $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/date"
11360
11481
  },
11361
11482
  updatedAt: {
11362
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/createdAt"
11483
+ $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/date"
11363
11484
  },
11364
11485
  solvedAt: {
11365
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/createdAt"
11486
+ $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/date"
11366
11487
  },
11367
11488
  closedAt: {
11368
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/createdAt"
11489
+ $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/date"
11369
11490
  }
11370
11491
  },
11371
11492
  required: [
@@ -13452,14 +13573,17 @@ var require_ticket2 = __commonJS({
13452
13573
  var schemas = require_schema();
13453
13574
  var schema = require_ticket();
13454
13575
  var Kohost = require_kohost();
13576
+ var MediaFile = require_mediaFile2();
13455
13577
  var sortBy = require_lodash2();
13456
13578
  var findLast = require_lodash3();
13457
13579
  var { nanoid: nanoid3 } = (init_index_browser(), __toCommonJS(index_browser_exports));
13580
+ var cloneDeep = require_lodash();
13458
13581
  schemas.add(schema);
13459
13582
  var validator = schemas.compile(schema);
13460
13583
  var Ticket = class extends Kohost {
13461
13584
  constructor(data) {
13462
- super(data);
13585
+ const ticketData = mapConversationData(data);
13586
+ super(ticketData);
13463
13587
  }
13464
13588
  static generateMessageId(len = 16) {
13465
13589
  return nanoid3(len);
@@ -13522,6 +13646,17 @@ var require_ticket2 = __commonJS({
13522
13646
  return lastFromNonRequester.userId;
13523
13647
  }
13524
13648
  });
13649
+ function mapConversationData(data) {
13650
+ const ticketData = cloneDeep(data);
13651
+ ticketData.conversation = ticketData.conversation.map((msg) => {
13652
+ if (msg.media) {
13653
+ msg.media = new MediaFile(msg.media);
13654
+ }
13655
+ return msg;
13656
+ });
13657
+ return ticketData;
13658
+ }
13659
+ __name(mapConversationData, "mapConversationData");
13525
13660
  module.exports = Ticket;
13526
13661
  }
13527
13662
  });
@@ -14102,6 +14237,99 @@ var require_energyReport2 = __commonJS({
14102
14237
  }
14103
14238
  });
14104
14239
 
14240
+ // src/schemas/smsMessage.json
14241
+ var require_smsMessage = __commonJS({
14242
+ "src/schemas/smsMessage.json"(exports, module) {
14243
+ module.exports = {
14244
+ $schema: "http://json-schema.org/draft-07/schema",
14245
+ $id: "https://api.kohost.io/schemas/v3/smsMessage.json",
14246
+ title: "SMS Message",
14247
+ type: "object",
14248
+ required: ["to", "from", "body", "status"],
14249
+ properties: {
14250
+ id: {
14251
+ $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
14252
+ },
14253
+ type: {
14254
+ type: "string",
14255
+ default: "smsMessage"
14256
+ },
14257
+ to: {
14258
+ type: "string",
14259
+ pattern: "^\\+[0-9]{1,14}$"
14260
+ },
14261
+ from: {
14262
+ type: "string",
14263
+ pattern: "^\\+[0-9]{1,14}$"
14264
+ },
14265
+ media: {
14266
+ type: "string",
14267
+ format: "uri"
14268
+ },
14269
+ status: {
14270
+ type: "string",
14271
+ enum: [
14272
+ "queued",
14273
+ "accepted",
14274
+ "sending",
14275
+ "sent",
14276
+ "failed",
14277
+ "delivered",
14278
+ "undelivered",
14279
+ "receiving",
14280
+ "received",
14281
+ "read"
14282
+ ]
14283
+ },
14284
+ body: {
14285
+ type: "string"
14286
+ },
14287
+ driver: {
14288
+ type: "string"
14289
+ },
14290
+ createdAt: {
14291
+ $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/date"
14292
+ },
14293
+ updatedAt: {
14294
+ $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/date"
14295
+ },
14296
+ systemData: {
14297
+ $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/systemData"
14298
+ }
14299
+ }
14300
+ };
14301
+ }
14302
+ });
14303
+
14304
+ // src/Models/smsMessage.js
14305
+ var require_smsMessage2 = __commonJS({
14306
+ "src/Models/smsMessage.js"(exports, module) {
14307
+ var schemas = require_schema();
14308
+ var schema = require_smsMessage();
14309
+ var Kohost = require_kohost();
14310
+ schemas.add(schema);
14311
+ var validator = schemas.compile(schema);
14312
+ var SMSMessage = class extends Kohost {
14313
+ constructor(data) {
14314
+ super(data);
14315
+ }
14316
+ };
14317
+ __name(SMSMessage, "SMSMessage");
14318
+ Object.defineProperty(SMSMessage.prototype, "schema", {
14319
+ value: schema
14320
+ });
14321
+ Object.defineProperty(SMSMessage.prototype, "validator", {
14322
+ get: function() {
14323
+ return validator;
14324
+ }
14325
+ });
14326
+ Object.defineProperty(SMSMessage, "validProperties", {
14327
+ value: Object.keys(schema.properties)
14328
+ });
14329
+ module.exports = SMSMessage;
14330
+ }
14331
+ });
14332
+
14105
14333
  // src/schemas/property.json
14106
14334
  var require_property = __commonJS({
14107
14335
  "src/schemas/property.json"(exports, module) {
@@ -14447,6 +14675,7 @@ var require_Models = __commonJS({
14447
14675
  var Reservation = require_reservation2();
14448
14676
  var Space = require_space2();
14449
14677
  var SpaceType = require_spaceType2();
14678
+ var MediaFile = require_mediaFile2();
14450
14679
  var Ticket = require_ticket2();
14451
14680
  var Scene = require_scene2();
14452
14681
  var Gateway = require_gateway2();
@@ -14456,6 +14685,7 @@ var require_Models = __commonJS({
14456
14685
  var ShortLink = require_shortLink2();
14457
14686
  var EnergyReportShard = require_energyReportShard2();
14458
14687
  var EnergyReport = require_energyReport2();
14688
+ var SMSMessage = require_smsMessage2();
14459
14689
  var Property = require_property2();
14460
14690
  var Organization = require_organization2();
14461
14691
  module.exports = {
@@ -14486,7 +14716,9 @@ var require_Models = __commonJS({
14486
14716
  Credential,
14487
14717
  ShortLink,
14488
14718
  EnergyReportShard,
14489
- EnergyReport
14719
+ EnergyReport,
14720
+ SMSMessage,
14721
+ MediaFile
14490
14722
  };
14491
14723
  }
14492
14724
  });