@kohost/api-client 4.0.5 → 4.0.7

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.
@@ -32,13 +32,13 @@ __export(events_exports, {
32
32
  SystemMotionSensorUpdated: () => SystemMotionSensorUpdated,
33
33
  SystemOrganizationUpdated: () => SystemOrganizationUpdated,
34
34
  SystemProductUpdated: () => SystemProductUpdated,
35
- SystemPropertyUpdate: () => SystemPropertyUpdate,
36
- SystemReservationUpdate: () => SystemReservationUpdate,
35
+ SystemPropertyUpdated: () => SystemPropertyUpdated,
36
+ SystemReservationUpdated: () => SystemReservationUpdated,
37
37
  SystemSpaceUpdate: () => SystemSpaceUpdate,
38
- SystemSwitchUpdate: () => SystemSwitchUpdate,
39
- SystemThermostatUpdate: () => SystemThermostatUpdate,
40
- SystemUserUpdate: () => SystemUserUpdate,
41
- SystemWindowCoveringUpdate: () => SystemWindowCoveringUpdate
38
+ SystemSwitchUpdated: () => SystemSwitchUpdated,
39
+ SystemThermostatUpdated: () => SystemThermostatUpdated,
40
+ SystemUserUpdated: () => SystemUserUpdated,
41
+ SystemWindowCoveringUpdated: () => SystemWindowCoveringUpdated
42
42
  });
43
43
 
44
44
  // src/events/event.js
@@ -380,7 +380,7 @@ var SystemProductUpdated = class extends Event {
380
380
  };
381
381
 
382
382
  // src/events/systemPropertyUpdated.js
383
- var SystemPropertyUpdate = class extends Event {
383
+ var SystemPropertyUpdated = class extends Event {
384
384
  constructor(property, context) {
385
385
  super(property, context);
386
386
  }
@@ -393,7 +393,7 @@ var SystemPropertyUpdate = class extends Event {
393
393
  };
394
394
 
395
395
  // src/events/systemReservationUpdated.js
396
- var SystemReservationUpdate = class extends Event {
396
+ var SystemReservationUpdated = class extends Event {
397
397
  constructor(reservation, context) {
398
398
  super(reservation, context);
399
399
  }
@@ -419,7 +419,7 @@ var SystemSpaceUpdate = class extends Event {
419
419
  };
420
420
 
421
421
  // src/events/systemSwitchUpdated.js
422
- var SystemSwitchUpdate = class extends Event {
422
+ var SystemSwitchUpdated = class extends Event {
423
423
  constructor(_switch, context) {
424
424
  super(_switch, context);
425
425
  }
@@ -432,7 +432,7 @@ var SystemSwitchUpdate = class extends Event {
432
432
  };
433
433
 
434
434
  // src/events/systemThermostatUpdated.js
435
- var SystemThermostatUpdate = class extends Event {
435
+ var SystemThermostatUpdated = class extends Event {
436
436
  constructor(thermostat, context) {
437
437
  super(thermostat, context);
438
438
  }
@@ -445,7 +445,7 @@ var SystemThermostatUpdate = class extends Event {
445
445
  };
446
446
 
447
447
  // src/events/systemUserUpdated.js
448
- var SystemUserUpdate = class extends Event {
448
+ var SystemUserUpdated = class extends Event {
449
449
  constructor(user, context) {
450
450
  super(user, context);
451
451
  }
@@ -458,7 +458,7 @@ var SystemUserUpdate = class extends Event {
458
458
  };
459
459
 
460
460
  // src/events/systemWindowCoveringUpdated.js
461
- var SystemWindowCoveringUpdate = class extends Event {
461
+ var SystemWindowCoveringUpdated = class extends Event {
462
462
  constructor(wc, context) {
463
463
  super(wc, context);
464
464
  }
@@ -494,13 +494,13 @@ export {
494
494
  SystemMotionSensorUpdated,
495
495
  SystemOrganizationUpdated,
496
496
  SystemProductUpdated,
497
- SystemPropertyUpdate,
498
- SystemReservationUpdate,
497
+ SystemPropertyUpdated,
498
+ SystemReservationUpdated,
499
499
  SystemSpaceUpdate,
500
- SystemSwitchUpdate,
501
- SystemThermostatUpdate,
502
- SystemUserUpdate,
503
- SystemWindowCoveringUpdate,
500
+ SystemSwitchUpdated,
501
+ SystemThermostatUpdated,
502
+ SystemUserUpdated,
503
+ SystemWindowCoveringUpdated,
504
504
  events_exports
505
505
  };
506
- //# sourceMappingURL=chunk-SHLRCTB4.js.map
506
+ //# sourceMappingURL=chunk-6Y5F4SJH.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/events/index.js","../src/events/event.js","../src/events/applicationInUse.js","../src/events/applicationOutOfUse.js","../src/events/emailEvent.js","../src/events/reservationCheckedIn.js","../src/events/reservationCheckedOut.js","../src/events/reservationSpaceChanged.js","../src/events/sceneSet.js","../src/events/shortLinkCreated.js","../src/events/smsEvent.js","../src/events/systemAlarmUpdated.js","../src/events/systemCameraUpdated.js","../src/events/systemCategoryUpdated.js","../src/events/systemCourtesyUpdated.js","../src/events/systemCredentialUpdated.js","../src/events/systemDimmerUpdated.js","../src/events/systemEntityDeleted.js","../src/events/systemGatewayUpdated.js","../src/events/systemLockUpdated.js","../src/events/systemMediaSourceUpdated.js","../src/events/systemMotionSensorUpdated.js","../src/events/systemOrganizationUpdated.js","../src/events/systemProductUpdated.js","../src/events/systemPropertyUpdated.js","../src/events/systemReservationUpdated.js","../src/events/systemSpaceUpdated.js","../src/events/systemSwitchUpdated.js","../src/events/systemThermostatUpdated.js","../src/events/systemUserUpdated.js","../src/events/systemWindowCoveringUpdated.js"],"sourcesContent":["// This file is auto-generated. Do not edit this file manually.\n// Generated on: 2025-01-10T20:53:11.168Z\n\nexport { ApplicationInUse } from \"./applicationInUse\";\nexport { ApplicationOutOfUse } from \"./applicationOutOfUse\";\nexport { EmailEvent } from \"./emailEvent\";\nexport { Event } from \"./event\";\nexport { ReservationCheckedIn } from \"./reservationCheckedIn\";\nexport { ReservationCheckedOut } from \"./reservationCheckedOut\";\nexport { ReservationSpaceChanged } from \"./reservationSpaceChanged\";\nexport { SceneSet } from \"./sceneSet\";\nexport { ShortLinkCreated } from \"./shortLinkCreated\";\nexport { SMSEvent } from \"./smsEvent\";\nexport { SystemAlarmUpdated } from \"./systemAlarmUpdated\";\nexport { SystemCameraUpdated } from \"./systemCameraUpdated\";\nexport { SystemCategoryUpdated } from \"./systemCategoryUpdated\";\nexport { SystemCourtesyUpdated } from \"./systemCourtesyUpdated\";\nexport { SystemCredentialUpdated } from \"./systemCredentialUpdated\";\nexport { SystemDimmerUpdated } from \"./systemDimmerUpdated\";\nexport { SystemEntityDeleted } from \"./systemEntityDeleted\";\nexport { SystemGatewayUpdated } from \"./systemGatewayUpdated\";\nexport { SystemLockUpdated } from \"./systemLockUpdated\";\nexport { SystemMediaSourceUpdated } from \"./systemMediaSourceUpdated\";\nexport { SystemMotionSensorUpdated } from \"./systemMotionSensorUpdated\";\nexport { SystemOrganizationUpdated } from \"./systemOrganizationUpdated\";\nexport { SystemProductUpdated } from \"./systemProductUpdated\";\nexport { SystemPropertyUpdated } from \"./systemPropertyUpdated\";\nexport { SystemReservationUpdated } from \"./systemReservationUpdated\";\nexport { SystemSpaceUpdate } from \"./systemSpaceUpdated\";\nexport { SystemSwitchUpdated } from \"./systemSwitchUpdated\";\nexport { SystemThermostatUpdated } from \"./systemThermostatUpdated\";\nexport { SystemUserUpdated } from \"./systemUserUpdated\";\nexport { SystemWindowCoveringUpdated } from \"./systemWindowCoveringUpdated\";","import { amqpExchanges } from \"../defs\";\n\nexport class Event {\n constructor(data, context = {}) {\n this.data = [];\n this.context = context;\n if (!data) throw new Error(\"Event data is required\");\n if (typeof data !== \"object\" && !Array.isArray(data))\n throw new Error(\"Event data must be an object or array\");\n\n if (!Array.isArray(data)) this.data = [data];\n else this.data = data;\n }\n\n get organizationId() {\n return this.context.organizationId || \"*\";\n }\n\n get propertyId() {\n return this.context.propertyId || \"*\";\n }\n\n static get type() {\n return \"Event\";\n }\n\n static get exchange() {\n return amqpExchanges.DriverEvents.name;\n }\n\n static get entity() {\n return \"\";\n }\n\n build() {\n return { data: { ...this.data } };\n }\n\n get routingKey() {\n return `${this.organizationId}.${this.propertyId}.${this.constructor.entity}.${this.constructor.name}`;\n }\n}\n","import { amqpExchanges } from \"../defs\";\nimport { Event } from \"./event\";\n\nexport class ApplicationInUse extends Event {\n constructor(data = {}, context) {\n super(data, context);\n }\n\n static get name() {\n return \"ApplicationInUse\";\n }\n\n static get entity() {\n return \"app\";\n }\n\n static get exchange() {\n return amqpExchanges.AppEvents.name;\n }\n}\n","import { amqpExchanges } from \"../defs\";\nimport { Event } from \"./event\";\n\nexport class ApplicationOutOfUse extends Event {\n constructor(data = {}, context = {}) {\n super(data, context);\n }\n\n static get name() {\n return \"ApplicationOutOfUse\";\n }\n\n static get entity() {\n return \"app\";\n }\n\n static get exchange() {\n return amqpExchanges.AppEvents.name;\n }\n}\n","import { Event } from \"./event\";\n\nexport class EmailEvent extends Event {\n constructor(email, context) {\n super(email, context);\n }\n\n static get name() {\n return \"EmailEvent\";\n }\n\n static get entity() {\n return \"emailMessage\";\n }\n}\n","import { amqpExchanges } from \"../defs\";\nimport { Event } from \"./event\";\n\nexport class ReservationCheckedIn extends Event {\n constructor(reservation, context) {\n super(reservation, context);\n }\n\n static get name() {\n return \"ReservationCheckedIn\";\n }\n\n static get entity() {\n return \"reservation\";\n }\n\n static get exchange() {\n return amqpExchanges.AppEvents.name;\n }\n}\n","import { amqpExchanges } from \"../defs\";\nimport { Event } from \"./event\";\n\nexport class ReservationCheckedOut extends Event {\n constructor(reservation, context) {\n super(reservation, context);\n }\n\n static get name() {\n return \"ReservationCheckedOut\";\n }\n\n static get entity() {\n return \"reservation\";\n }\n\n static get exchange() {\n return amqpExchanges.AppEvents.name;\n }\n}\n","import { amqpExchanges } from \"../defs\";\nimport { Event } from \"./event\";\n\nexport class ReservationSpaceChanged extends Event {\n constructor(reservation, context) {\n super(reservation, context);\n }\n\n static get name() {\n return \"ReservationSpaceChanged\";\n }\n\n static get entity() {\n return \"reservation\";\n }\n\n static get exchange() {\n return amqpExchanges.AppEvents.name;\n }\n}\n","import { Event } from \"./event\";\n\nexport class SceneSet extends Event {\n constructor(scene, context) {\n super(scene, context);\n }\n\n static get name() {\n return \"SceneSet\";\n }\n\n static get entity() {\n return \"scene\";\n }\n}\n","import { Event } from \"./event\";\n\nexport class ShortLinkCreated extends Event {\n constructor(shortLink, context) {\n super(shortLink, context);\n }\n\n static get name() {\n return \"ShortLinkCreated\";\n }\n\n static get entity() {\n return \"shortLink\";\n }\n}\n","import { Event } from \"./event\";\n\nexport class SMSEvent extends Event {\n constructor(sms, context) {\n super(sms, context);\n }\n\n static get name() {\n return \"SMSEvent\";\n }\n\n static get entity() {\n return \"smsMessage\";\n }\n}\n","import { Event } from \"./event\";\n\nexport class SystemAlarmUpdated extends Event {\n constructor(alarm, context) {\n super(alarm, context);\n }\n\n static get name() {\n return \"SystemAlarmUpdated\";\n }\n\n static get entity() {\n return \"alarm\";\n }\n}\n","import { Event } from \"./event\";\n\nexport class SystemCameraUpdated extends Event {\n constructor(camera, context) {\n super(camera, context);\n }\n\n static get name() {\n return \"SystemCameraUpdated\";\n }\n\n static get entity() {\n return \"camera\";\n }\n}\n","import { Event } from \"./event\";\n\nexport class SystemCategoryUpdated extends Event {\n constructor(category, context) {\n super(category, context);\n }\n\n static get name() {\n return \"SystemCategoryUpdated\";\n }\n\n static get entity() {\n return \"category\";\n }\n}\n","import { Event } from \"./event\";\n\nexport class SystemCourtesyUpdated extends Event {\n constructor(courtesy, context) {\n super(courtesy, context);\n }\n\n static get name() {\n return \"SystemCourtesyUpdated\";\n }\n\n static get entity() {\n return \"courtesy\";\n }\n}\n","import { Event } from \"./event\";\n\nexport class SystemCredentialUpdated extends Event {\n constructor(cred, context) {\n super(cred, context);\n }\n\n static get name() {\n return \"SystemCredentialUpdated\";\n }\n\n static get entity() {\n return \"credential\";\n }\n}\n","import { Event } from \"./event\";\n\nexport class SystemDimmerUpdated extends Event {\n constructor(dimmer, context) {\n super(dimmer, context);\n }\n\n static get name() {\n return \"SystemDimmerUpdated\";\n }\n\n static get entity() {\n return \"dimmer\";\n }\n}\n","import { Event } from \"./event\";\n\nexport class SystemEntityDeleted extends Event {\n constructor(data, context) {\n super(data, context);\n }\n\n static get name() {\n return \"SystemEntityDeleted\";\n }\n\n static get entity() {\n return \"entity\";\n }\n}\n","import { Event } from \"./event\";\n\nexport class SystemGatewayUpdated extends Event {\n constructor(gateway, context) {\n super(gateway, context);\n }\n\n static get name() {\n return \"SystemGatewayUpdated\";\n }\n\n static get entity() {\n return \"gateway\";\n }\n}\n","import { Event } from \"./event\";\n\nexport class SystemLockUpdated extends Event {\n constructor(lock, context) {\n super(lock, context);\n }\n\n static get name() {\n return \"SystemLockUpdated\";\n }\n\n static get entity() {\n return \"lock\";\n }\n}\n","import { Event } from \"./event\";\n\nexport class SystemMediaSourceUpdated extends Event {\n constructor(mediaSource, context) {\n super(mediaSource, context);\n }\n\n static get name() {\n return \"SystemMediaSourceUpdated\";\n }\n\n static get entity() {\n return \"mediaSource\";\n }\n}\n","import { Event } from \"./event\";\n\nexport class SystemMotionSensorUpdated extends Event {\n constructor(motion, context) {\n super(motion, context);\n }\n\n static get name() {\n return \"SystemMotionSensorUpdated\";\n }\n\n static get entity() {\n return \"motionSensor\";\n }\n}\n","import { Event } from \"./event\";\n\nexport class SystemOrganizationUpdated extends Event {\n constructor(organization, context) {\n super(organization, context);\n }\n\n static get name() {\n return \"SystemOrganizationUpdated\";\n }\n\n static get entity() {\n return \"organization\";\n }\n}\n","import { Event } from \"./event\";\n\nexport class SystemProductUpdated extends Event {\n constructor(product, context) {\n super(product, context);\n }\n\n static get name() {\n return \"SystemProductUpdated\";\n }\n\n static get entity() {\n return \"product\";\n }\n}\n","import { Event } from \"./event\";\n\nexport class SystemPropertyUpdated extends Event {\n constructor(property, context) {\n super(property, context);\n }\n\n static get name() {\n return \"SystemPropertyUpdated\";\n }\n\n static get entity() {\n return \"property\";\n }\n}\n","import { Event } from \"./event\";\n\nexport class SystemReservationUpdated extends Event {\n constructor(reservation, context) {\n super(reservation, context);\n }\n\n static get name() {\n return \"SystemReservationUpdated\";\n }\n\n static get entity() {\n return \"reservation\";\n }\n}\n","import { Event } from \"./event\";\n\nexport class SystemSpaceUpdate extends Event {\n constructor(space, context) {\n super(space, context);\n }\n\n static get name() {\n return \"SystemSpaceUpdated\";\n }\n\n static get entity() {\n return \"space\";\n }\n}\n","import { Event } from \"./event\";\n\nexport class SystemSwitchUpdated extends Event {\n constructor(_switch, context) {\n super(_switch, context);\n }\n\n static get name() {\n return \"SystemSwitchUpdated\";\n }\n\n static get entity() {\n return \"switch\";\n }\n}\n","import { Event } from \"./event\";\n\nexport class SystemThermostatUpdated extends Event {\n constructor(thermostat, context) {\n super(thermostat, context);\n }\n\n static get name() {\n return \"SystemThermostatUpdated\";\n }\n\n static get entity() {\n return \"thermostat\";\n }\n}\n","import { Event } from \"./event\";\n\nexport class SystemUserUpdated extends Event {\n constructor(user, context) {\n super(user, context);\n }\n\n static get name() {\n return \"SystemUserUpdated\";\n }\n\n static get entity() {\n return \"user\";\n }\n}\n","import { Event } from \"./event\";\n\nexport class SystemWindowCoveringUpdated extends Event {\n constructor(wc, context) {\n super(wc, context);\n }\n\n static get name() {\n return \"SystemWindowCoveringUpdated\";\n }\n\n static get entity() {\n return \"windowCovering\";\n }\n}\n"],"mappings":";;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEO,IAAM,QAAN,MAAY;AAAA,EAFnB,OAEmB;AAAA;AAAA;AAAA,EACjB,YAAY,MAAM,UAAU,CAAC,GAAG;AAC9B,SAAK,OAAO,CAAC;AACb,SAAK,UAAU;AACf,QAAI,CAAC,KAAM,OAAM,IAAI,MAAM,wBAAwB;AACnD,QAAI,OAAO,SAAS,YAAY,CAAC,MAAM,QAAQ,IAAI;AACjD,YAAM,IAAI,MAAM,uCAAuC;AAEzD,QAAI,CAAC,MAAM,QAAQ,IAAI,EAAG,MAAK,OAAO,CAAC,IAAI;AAAA,QACtC,MAAK,OAAO;AAAA,EACnB;AAAA,EAEA,IAAI,iBAAiB;AACnB,WAAO,KAAK,QAAQ,kBAAkB;AAAA,EACxC;AAAA,EAEA,IAAI,aAAa;AACf,WAAO,KAAK,QAAQ,cAAc;AAAA,EACpC;AAAA,EAEA,WAAW,OAAO;AAChB,WAAO;AAAA,EACT;AAAA,EAEA,WAAW,W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AACzB,UAAM,MAAM,OAAO;AAAA,EACrB;AAAA,EAEA,WAAW,OAAO;AAChB,WAAO;AAAA,EACT;AAAA,EAEA,WAAW,SAAS;AAClB,WAAO;AAAA,EACT;AACF;;;ACZO,IAAM,8BAAN,cAA0C,MAAM;AAAA,EACrD,YAAY,IAAI,SAAS;AACvB,UAAM,IAAI,OAAO;AAAA,EACnB;AAAA,EAEA,WAAW,OAAO;AAChB,WAAO;AAAA,EACT;AAAA,EAEA,WAAW,SAAS;AAClB,WAAO;AAAA,EACT;AACF;","names":[]}
package/dist/client.cjs CHANGED
@@ -307,7 +307,7 @@ var KohostHTTPClient = class _KohostHTTPClient {
307
307
  headers.set(key, config.headers[key]);
308
308
  });
309
309
  }
310
- const body = ["POST", "PUT", "PATCH"].includes(method) ? headers.get("Content-Type") === "application/json" ? JSON.stringify(config.data) : config.data : void 0;
310
+ const body = config.data !== null && ["POST", "PUT", "PATCH"].includes(method) ? headers.get("Content-Type") === "application/json" ? JSON.stringify(config.data) : config.data : void 0;
311
311
  const request = new Request(url, {
312
312
  method,
313
313
  headers,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/httpClient.js","../src/useCases/refreshToken.js"],"sourcesContent":["import { RefreshTokenCommand } from \"./useCases/refreshToken\";\n\nexport class KohostHTTPClient {\n #onSuccess;\n #onError;\n\n /** \n @param {Object} options - The options to create the client\n @param {String} options.organizationId - The organization ID\n @param {String} options.propertyId - The property ID\n @param {String | URL} options.url - The base URL for the API endpint\n @param {String} options.apiKey - The API key to use for requests\n @param {Headers} options.headers - Additional headers to send with each request\n @param {Function} options.onSuccess - A callback to handle successful responses\n @param {Function} options.onError - A callback to handle errors\n */\n constructor(\n options = {\n url: \"\",\n propertyId: \"\",\n organizationId: \"\",\n apiKey: \"\",\n headers: new Headers({}),\n onSuccess: (response) => response,\n onError: (error) => error,\n },\n ) {\n if (!options.url) throw new Error(\"options.url is required\");\n this.options = options;\n\n this.isAuthTokenRenewalActive = false;\n\n this.baseUrl = new URL(options.url);\n this.headers = new Headers({\n \"Content-Type\": \"application/json\",\n Accept: \"application/json\",\n ...options.headers,\n });\n\n if (options.apiKey) {\n this.headers.set(KohostHTTPClient.defs.apiKeyHeader, options.apiKey);\n }\n\n if (options.propertyId) {\n this.propertyId = options.propertyId;\n }\n\n if (options.organizationId) {\n this.organizationId = options.organizationId;\n }\n\n this.#onSuccess = options.onSuccess\n ? options.onSuccess\n : (response) => response;\n\n this.#onError = options.onError ? options.onError : (error) => error;\n\n this.callbacks = {};\n }\n\n /**\n *\n * @param {\"LoginRequired\" | \"PhoneVerificationRequired\"} event\n * @param {Function} callback\n */\n on(event, callback) {\n if (typeof callback !== \"function\") {\n throw new Error(\"Callback must be a function\");\n }\n if (!this.callbacks[event]) {\n this.callbacks[event] = [];\n }\n this.callbacks[event].push(callback);\n }\n\n emit(event, ...args) {\n if (this.callbacks[event]) {\n this.callbacks[event].forEach((callback) => callback(...args));\n }\n }\n\n /**\n * @param {string} orgId\n * @returns {void}\n * @memberof KohostApiClient\n * @example\n * client.organizationId = \"1234\";\n */\n set organizationId(orgId) {\n const key = KohostHTTPClient.defs.organizationHeader;\n this.headers.set(key, orgId);\n }\n\n get organizationId() {\n const key = KohostHTTPClient.defs.organizationHeader;\n return this.headers.get(key);\n }\n\n /**\n * @param {string} propertyId\n * @returns {void}\n * @memberof KohostApiClient\n * @example\n * client.propertyId = \"1234\";\n */\n\n set propertyId(propertyId) {\n const key = KohostHTTPClient.defs.propertyHeader;\n this.headers.set(key, propertyId);\n }\n\n get propertyId() {\n const key = KohostHTTPClient.defs.propertyHeader;\n return this.headers.get(key);\n }\n\n static get defs() {\n return {\n apiKeyHeader: \"X-Api-Key\",\n propertyHeader: \"X-Property-Id\",\n organizationHeader: \"X-Organization-Id\",\n };\n }\n\n /**\n * @typedef {keyof typeof import('./useCases')} CommandName\n * @typedef {import('./useCases')[CommandName]} Command\n *\n * @param {Command} command\n */\n async send(command) {\n const commandConfig = command.config;\n const request = this.createRequest(commandConfig);\n const response = await fetch(request);\n\n const isJsonResponse =\n response.headers.get(\"Content-Type\")?.includes(\"application/json\") ||\n false;\n\n const responseData = isJsonResponse ? await response.json() : response.body;\n\n if (!response.ok) {\n let error = responseData?.error || new Error(response.statusText);\n\n const status = response.status;\n const errorType = responseData.error?.type;\n const errorMessage = responseData?.error?.message;\n\n try {\n const expectedError = status >= 400 && status < 500;\n const newTokensNeeded =\n expectedError && errorType === \"TokenExpiredError\";\n\n if (\n expectedError &&\n errorMessage === \"Phone Verification is required\"\n ) {\n this.#onPhoneVerificationRequired();\n return Promise.reject(error);\n }\n\n if (expectedError && errorMessage === \"Login Required\") {\n this.#onLoginRequired();\n return Promise.reject(error);\n }\n\n if (\n expectedError &&\n errorMessage === \"No auth header or cookie provided\"\n ) {\n this.#onLoginRequired();\n return Promise.reject(error);\n }\n\n if (expectedError && newTokensNeeded) {\n while (!this.isAuthTokenRenewalActive) {\n this.isAuthTokenRenewalActive = true;\n return this.send(\n new RefreshTokenCommand({\n data: commandConfig.data,\n query: commandConfig.params,\n headers: commandConfig.headers,\n }),\n )\n .then(() => {\n // retry the original request with the new token\n this.isAuthTokenRenewalActive = false;\n return fetch(request.clone());\n })\n .catch((err) => {\n this.isAuthTokenRenewalActive = false;\n return Promise.reject(err);\n });\n }\n }\n } catch (error) {\n console.error(error);\n }\n\n error = this.#onError(error);\n\n return Promise.reject(error);\n }\n\n return this.#onSuccess(responseData);\n }\n\n #onLoginRequired() {\n this.emit(\"LoginRequired\");\n }\n\n #onPhoneVerificationRequired() {\n this.emit(\"PhoneVerificationRequired\");\n }\n\n /**\n * @param {Command} config\n * @returns {Request}\n */\n createRequest(config) {\n if (typeof config.headers !== \"object\") {\n config.headers = {};\n }\n\n let apiPath = config.url;\n\n if (apiPath.startsWith(\"/\")) {\n apiPath = `.${apiPath}`;\n }\n const url = new URL(apiPath, this.baseUrl);\n const method = config.method.toUpperCase() || \"GET\";\n\n // Add parameters to URL if they exist\n if (config.params && typeof config.params === \"object\") {\n Object.entries(config.params).forEach(([key, value]) => {\n // Handle array values\n if (Array.isArray(value)) {\n value.forEach((item) => {\n if (typeof item === \"object\" && item !== null) {\n Object.entries(item).forEach(([itemKey, itemValue]) => {\n url.searchParams.append(`${key}[][${itemKey}]`, itemValue);\n });\n } else {\n url.searchParams.append(`${key}[]`, item);\n }\n });\n }\n // Handle null/undefined\n else if (value === null || value === undefined) {\n url.searchParams.append(key, \"\");\n }\n // Handle nested objects\n else if (typeof value === \"object\") {\n Object.entries(value).forEach(([nestedKey, nestedValue]) => {\n if (Array.isArray(nestedValue)) {\n nestedValue.forEach((item) => {\n url.searchParams.append(`${key}[${nestedKey}][]`, item);\n });\n } else {\n url.searchParams.append(`${key}[${nestedKey}]`, nestedValue);\n }\n });\n }\n // Handle primitive values\n else {\n url.searchParams.append(key, value);\n }\n });\n }\n\n const headers = new Headers(this.headers);\n // Add any additional headers\n if (config.headers) {\n Object.keys(config.headers).forEach((key) => {\n headers.set(key, config.headers[key]);\n });\n }\n\n const body = [\"POST\", \"PUT\", \"PATCH\"].includes(method)\n ? headers.get(\"Content-Type\") === \"application/json\"\n ? JSON.stringify(config.data)\n : config.data\n : undefined;\n\n const request = new Request(url, {\n method: method,\n headers: headers,\n credentials: \"include\",\n body: body,\n });\n\n return request;\n }\n}\n","/* @ts-nocheck */\n/* This file is automatically generated. Do not modify it manually. */\n\nexport class RefreshTokenCommand {\n /**\n * @description\n * @constructor\n * @typedef {object} RefreshTokenCommandConfig\n * @property {{[key: string]: any}} data - The body to include in the command\n * @property {{[key:string]: any} | null} [headers] - The headers to include in the command\n * @property {{[key:string]: any} | null} [query] - The query parameters to include in the command\n *\n * @param {RefreshTokenCommandConfig} commandConfig - The options to include in the command\n * @param {Object} options - The options to include in the command\n */\n constructor(commandConfig, options = {}) {\n // get parameters from path\n const pathParams = RefreshTokenCommand.params;\n\n let { data, query, headers } = commandConfig ?? {};\n\n if (typeof data === \"undefined\") data = null;\n if (typeof query === \"undefined\") query = null;\n if (typeof headers === \"undefined\") headers = null;\n\n // replace path parameters with values from params\n let url = RefreshTokenCommand.url;\n\n if (pathParams && data) {\n for (const param of pathParams) {\n const urlParam = \":\" + param;\n url = url.replace(urlParam, data[param]);\n }\n }\n\n // make sure all parameters have been replaced\n if (url.match(/:[a-zA-Z0-9]+/g)) {\n const missingParams = url.match(/:[a-zA-Z0-9]+/g);\n\n if (missingParams) {\n // remove the colon from the parameter name\n const missing = missingParams.map((param) => param.replace(\":\", \"\"));\n throw new Error(\"Missing parameters: \" + missing.join(\", \"));\n }\n }\n\n /**\n * The full URL for the use case\n * @type {string}\n * @public\n */\n this.url = url;\n /**\n * The data to send with the use case\n * @type {RefreshTokenCommandConfig[\"data\"]}\n * @public\n */\n this.data = data;\n /**\n * The query parameters for the use case\n * @type {RefreshTokenCommandConfig[\"query\"]}\n * @public\n */\n this.query = query;\n /**\n * The headers for the use case\n * @type {RefreshTokenCommandConfig[\"headers\"]}\n * @public\n */\n this.headers = headers;\n\n /**\n * The configuration for the use case command\n * @type {{ url: string, method: \"post\" , data: RefreshTokenCommandConfig[\"data\"] , params: RefreshTokenCommandConfig[\"query\"], headers: RefreshTokenCommandConfig[\"headers\"] }}\n * @public\n */\n this.config = {\n method: RefreshTokenCommand.method,\n url: url,\n data: data,\n params: query,\n headers: headers,\n ...options,\n };\n }\n\n /**\n * The required parameters for the use case\n * @type {string[]}\n */\n static params = [];\n\n /**\n * The URL for the use case, with path parameters\n * @type {string}\n */\n static url = \"/auth/refresh\";\n\n /**\n * The HTTP method for the use case\n * @type {\"post\"}\n */\n static method = \"post\";\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACGO,IAAM,sBAAN,MAAM,qBAAoB;AAAA,EAHjC,OAGiC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAY/B,YAAY,eAAe,UAAU,CAAC,GAAG;AAEvC,UAAM,a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,OAAO,QAAQ,GAAG,CAAC;AAAA,MACtC,CAAC;AAAA,IACH;AAEA,UAAM,OAAO,CAAC,QAAQ,OAAO,OAAO,EAAE,SAAS,MAAM,IACjD,QAAQ,IAAI,cAAc,MAAM,qBAC9B,KAAK,UAAU,OAAO,IAAI,IAC1B,OAAO,OACT;AAEJ,UAAM,UAAU,IAAI,QAAQ,KAAK;AAAA,MAC/B;AAAA,MACA;AAAA,MACA,aAAa;AAAA,MACb;AAAA,IACF,CAAC;AAED,WAAO;AAAA,EACT;AACF;","names":["error"]}
1
+ {"version":3,"sources":["../src/httpClient.js","../src/useCases/refreshToken.js"],"sourcesContent":["import { RefreshTokenCommand } from \"./useCases/refreshToken\";\n\nexport class KohostHTTPClient {\n #onSuccess;\n #onError;\n\n /** \n @param {Object} options - The options to create the client\n @param {String} options.organizationId - The organization ID\n @param {String} options.propertyId - The property ID\n @param {String | URL} options.url - The base URL for the API endpint\n @param {String} options.apiKey - The API key to use for requests\n @param {Headers} options.headers - Additional headers to send with each request\n @param {Function} options.onSuccess - A callback to handle successful responses\n @param {Function} options.onError - A callback to handle errors\n */\n constructor(\n options = {\n url: \"\",\n propertyId: \"\",\n organizationId: \"\",\n apiKey: \"\",\n headers: new Headers({}),\n onSuccess: (response) => response,\n onError: (error) => error,\n },\n ) {\n if (!options.url) throw new Error(\"options.url is required\");\n this.options = options;\n\n this.isAuthTokenRenewalActive = false;\n\n this.baseUrl = new URL(options.url);\n this.headers = new Headers({\n \"Content-Type\": \"application/json\",\n Accept: \"application/json\",\n ...options.headers,\n });\n\n if (options.apiKey) {\n this.headers.set(KohostHTTPClient.defs.apiKeyHeader, options.apiKey);\n }\n\n if (options.propertyId) {\n this.propertyId = options.propertyId;\n }\n\n if (options.organizationId) {\n this.organizationId = options.organizationId;\n }\n\n this.#onSuccess = options.onSuccess\n ? options.onSuccess\n : (response) => response;\n\n this.#onError = options.onError ? options.onError : (error) => error;\n\n this.callbacks = {};\n }\n\n /**\n *\n * @param {\"LoginRequired\" | \"PhoneVerificationRequired\"} event\n * @param {Function} callback\n */\n on(event, callback) {\n if (typeof callback !== \"function\") {\n throw new Error(\"Callback must be a function\");\n }\n if (!this.callbacks[event]) {\n this.callbacks[event] = [];\n }\n this.callbacks[event].push(callback);\n }\n\n emit(event, ...args) {\n if (this.callbacks[event]) {\n this.callbacks[event].forEach((callback) => callback(...args));\n }\n }\n\n /**\n * @param {string} orgId\n * @returns {void}\n * @memberof KohostApiClient\n * @example\n * client.organizationId = \"1234\";\n */\n set organizationId(orgId) {\n const key = KohostHTTPClient.defs.organizationHeader;\n this.headers.set(key, orgId);\n }\n\n get organizationId() {\n const key = KohostHTTPClient.defs.organizationHeader;\n return this.headers.get(key);\n }\n\n /**\n * @param {string} propertyId\n * @returns {void}\n * @memberof KohostApiClient\n * @example\n * client.propertyId = \"1234\";\n */\n\n set propertyId(propertyId) {\n const key = KohostHTTPClient.defs.propertyHeader;\n this.headers.set(key, propertyId);\n }\n\n get propertyId() {\n const key = KohostHTTPClient.defs.propertyHeader;\n return this.headers.get(key);\n }\n\n static get defs() {\n return {\n apiKeyHeader: \"X-Api-Key\",\n propertyHeader: \"X-Property-Id\",\n organizationHeader: \"X-Organization-Id\",\n };\n }\n\n /**\n * @typedef {keyof typeof import('./useCases')} CommandName\n * @typedef {import('./useCases')[CommandName]} Command\n *\n * @param {Command} command\n */\n async send(command) {\n const commandConfig = command.config;\n const request = this.createRequest(commandConfig);\n const response = await fetch(request);\n\n const isJsonResponse =\n response.headers.get(\"Content-Type\")?.includes(\"application/json\") ||\n false;\n\n const responseData = isJsonResponse ? await response.json() : response.body;\n\n if (!response.ok) {\n let error = responseData?.error || new Error(response.statusText);\n\n const status = response.status;\n const errorType = responseData.error?.type;\n const errorMessage = responseData?.error?.message;\n\n try {\n const expectedError = status >= 400 && status < 500;\n const newTokensNeeded =\n expectedError && errorType === \"TokenExpiredError\";\n\n if (\n expectedError &&\n errorMessage === \"Phone Verification is required\"\n ) {\n this.#onPhoneVerificationRequired();\n return Promise.reject(error);\n }\n\n if (expectedError && errorMessage === \"Login Required\") {\n this.#onLoginRequired();\n return Promise.reject(error);\n }\n\n if (\n expectedError &&\n errorMessage === \"No auth header or cookie provided\"\n ) {\n this.#onLoginRequired();\n return Promise.reject(error);\n }\n\n if (expectedError && newTokensNeeded) {\n while (!this.isAuthTokenRenewalActive) {\n this.isAuthTokenRenewalActive = true;\n return this.send(\n new RefreshTokenCommand({\n data: commandConfig.data,\n query: commandConfig.params,\n headers: commandConfig.headers,\n }),\n )\n .then(() => {\n // retry the original request with the new token\n this.isAuthTokenRenewalActive = false;\n return fetch(request.clone());\n })\n .catch((err) => {\n this.isAuthTokenRenewalActive = false;\n return Promise.reject(err);\n });\n }\n }\n } catch (error) {\n console.error(error);\n }\n\n error = this.#onError(error);\n\n return Promise.reject(error);\n }\n\n return this.#onSuccess(responseData);\n }\n\n #onLoginRequired() {\n this.emit(\"LoginRequired\");\n }\n\n #onPhoneVerificationRequired() {\n this.emit(\"PhoneVerificationRequired\");\n }\n\n /**\n * @param {Command} config\n * @returns {Request}\n */\n createRequest(config) {\n if (typeof config.headers !== \"object\") {\n config.headers = {};\n }\n\n let apiPath = config.url;\n\n if (apiPath.startsWith(\"/\")) {\n apiPath = `.${apiPath}`;\n }\n const url = new URL(apiPath, this.baseUrl);\n const method = config.method.toUpperCase() || \"GET\";\n\n // Add parameters to URL if they exist\n if (config.params && typeof config.params === \"object\") {\n Object.entries(config.params).forEach(([key, value]) => {\n // Handle array values\n if (Array.isArray(value)) {\n value.forEach((item) => {\n if (typeof item === \"object\" && item !== null) {\n Object.entries(item).forEach(([itemKey, itemValue]) => {\n url.searchParams.append(`${key}[][${itemKey}]`, itemValue);\n });\n } else {\n url.searchParams.append(`${key}[]`, item);\n }\n });\n }\n // Handle null/undefined\n else if (value === null || value === undefined) {\n url.searchParams.append(key, \"\");\n }\n // Handle nested objects\n else if (typeof value === \"object\") {\n Object.entries(value).forEach(([nestedKey, nestedValue]) => {\n if (Array.isArray(nestedValue)) {\n nestedValue.forEach((item) => {\n url.searchParams.append(`${key}[${nestedKey}][]`, item);\n });\n } else {\n url.searchParams.append(`${key}[${nestedKey}]`, nestedValue);\n }\n });\n }\n // Handle primitive values\n else {\n url.searchParams.append(key, value);\n }\n });\n }\n\n const headers = new Headers(this.headers);\n // Add any additional headers\n if (config.headers) {\n Object.keys(config.headers).forEach((key) => {\n headers.set(key, config.headers[key]);\n });\n }\n\n const body =\n config.data !== null && [\"POST\", \"PUT\", \"PATCH\"].includes(method)\n ? headers.get(\"Content-Type\") === \"application/json\"\n ? JSON.stringify(config.data)\n : config.data\n : undefined;\n\n const request = new Request(url, {\n method: method,\n headers: headers,\n credentials: \"include\",\n body: body,\n });\n\n return request;\n }\n}\n","/* @ts-nocheck */\n/* This file is automatically generated. Do not modify it manually. */\n\nexport class RefreshTokenCommand {\n /**\n * @description\n * @constructor\n * @typedef {object} RefreshTokenCommandConfig\n * @property {{[key: string]: any}} data - The body to include in the command\n * @property {{[key:string]: any} | null} [headers] - The headers to include in the command\n * @property {{[key:string]: any} | null} [query] - The query parameters to include in the command\n *\n * @param {RefreshTokenCommandConfig} commandConfig - The options to include in the command\n * @param {Object} options - The options to include in the command\n */\n constructor(commandConfig, options = {}) {\n // get parameters from path\n const pathParams = RefreshTokenCommand.params;\n\n let { data, query, headers } = commandConfig ?? {};\n\n if (typeof data === \"undefined\") data = null;\n if (typeof query === \"undefined\") query = null;\n if (typeof headers === \"undefined\") headers = null;\n\n // replace path parameters with values from params\n let url = RefreshTokenCommand.url;\n\n if (pathParams && data) {\n for (const param of pathParams) {\n const urlParam = \":\" + param;\n url = url.replace(urlParam, data[param]);\n }\n }\n\n // make sure all parameters have been replaced\n if (url.match(/:[a-zA-Z0-9]+/g)) {\n const missingParams = url.match(/:[a-zA-Z0-9]+/g);\n\n if (missingParams) {\n // remove the colon from the parameter name\n const missing = missingParams.map((param) => param.replace(\":\", \"\"));\n throw new Error(\"Missing parameters: \" + missing.join(\", \"));\n }\n }\n\n /**\n * The full URL for the use case\n * @type {string}\n * @public\n */\n this.url = url;\n /**\n * The data to send with the use case\n * @type {RefreshTokenCommandConfig[\"data\"]}\n * @public\n */\n this.data = data;\n /**\n * The query parameters for the use case\n * @type {RefreshTokenCommandConfig[\"query\"]}\n * @public\n */\n this.query = query;\n /**\n * The headers for the use case\n * @type {RefreshTokenCommandConfig[\"headers\"]}\n * @public\n */\n this.headers = headers;\n\n /**\n * The configuration for the use case command\n * @type {{ url: string, method: \"post\" , data: RefreshTokenCommandConfig[\"data\"] , params: RefreshTokenCommandConfig[\"query\"], headers: RefreshTokenCommandConfig[\"headers\"] }}\n * @public\n */\n this.config = {\n method: RefreshTokenCommand.method,\n url: url,\n data: data,\n params: query,\n headers: headers,\n ...options,\n };\n }\n\n /**\n * The required parameters for the use case\n * @type {string[]}\n */\n static params = [];\n\n /**\n * The URL for the use case, with path parameters\n * @type {string}\n */\n static url = \"/auth/refresh\";\n\n /**\n * The HTTP method for the use case\n * @type {\"post\"}\n */\n static method = \"post\";\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACGO,IAAM,sBAAN,MAAM,qBAAoB;AAAA,EAHjC,OAGiC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAY/B,YAAY,eAAe,UAAU,CAAC,GAAG;AAEvC,UAAM,aAAa,qBAAoB;AAEvC,QAAI,EAAE,MAAM,OAAO,QAAQ,IAAI,iBAAiB,CAAC;AAEjD,QAAI,OAAO,SAAS,YAAa,QAAO;AACxC,QAAI,OAAO,UAAU,YAAa,SAAQ;AAC1C,QAAI,OAAO,YAAY,YAAa,WAAU;AAG9C,QAAI,MAAM,qBAAoB;AAE9B,QAAI,cAAc,MAAM;AACtB,iBAAW,SAAS,YAAY;AAC9B,cAAM,WAAW,MAAM;AACvB,cAAM,IAAI,QAAQ,UAAU,KAAK,KAAK,C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AO;AAAA,EACT;AACF;","names":["error"]}
package/dist/client.js CHANGED
@@ -222,7 +222,7 @@ var KohostHTTPClient = class _KohostHTTPClient {
222
222
  headers.set(key, config.headers[key]);
223
223
  });
224
224
  }
225
- const body = ["POST", "PUT", "PATCH"].includes(method) ? headers.get("Content-Type") === "application/json" ? JSON.stringify(config.data) : config.data : void 0;
225
+ const body = config.data !== null && ["POST", "PUT", "PATCH"].includes(method) ? headers.get("Content-Type") === "application/json" ? JSON.stringify(config.data) : config.data : void 0;
226
226
  const request = new Request(url, {
227
227
  method,
228
228
  headers,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/httpClient.js"],"sourcesContent":["import { RefreshTokenCommand } from \"./useCases/refreshToken\";\n\nexport class KohostHTTPClient {\n #onSuccess;\n #onError;\n\n /** \n @param {Object} options - The options to create the client\n @param {String} options.organizationId - The organization ID\n @param {String} options.propertyId - The property ID\n @param {String | URL} options.url - The base URL for the API endpint\n @param {String} options.apiKey - The API key to use for requests\n @param {Headers} options.headers - Additional headers to send with each request\n @param {Function} options.onSuccess - A callback to handle successful responses\n @param {Function} options.onError - A callback to handle errors\n */\n constructor(\n options = {\n url: \"\",\n propertyId: \"\",\n organizationId: \"\",\n apiKey: \"\",\n headers: new Headers({}),\n onSuccess: (response) => response,\n onError: (error) => error,\n },\n ) {\n if (!options.url) throw new Error(\"options.url is required\");\n this.options = options;\n\n this.isAuthTokenRenewalActive = false;\n\n this.baseUrl = new URL(options.url);\n this.headers = new Headers({\n \"Content-Type\": \"application/json\",\n Accept: \"application/json\",\n ...options.headers,\n });\n\n if (options.apiKey) {\n this.headers.set(KohostHTTPClient.defs.apiKeyHeader, options.apiKey);\n }\n\n if (options.propertyId) {\n this.propertyId = options.propertyId;\n }\n\n if (options.organizationId) {\n this.organizationId = options.organizationId;\n }\n\n this.#onSuccess = options.onSuccess\n ? options.onSuccess\n : (response) => response;\n\n this.#onError = options.onError ? options.onError : (error) => error;\n\n this.callbacks = {};\n }\n\n /**\n *\n * @param {\"LoginRequired\" | \"PhoneVerificationRequired\"} event\n * @param {Function} callback\n */\n on(event, callback) {\n if (typeof callback !== \"function\") {\n throw new Error(\"Callback must be a function\");\n }\n if (!this.callbacks[event]) {\n this.callbacks[event] = [];\n }\n this.callbacks[event].push(callback);\n }\n\n emit(event, ...args) {\n if (this.callbacks[event]) {\n this.callbacks[event].forEach((callback) => callback(...args));\n }\n }\n\n /**\n * @param {string} orgId\n * @returns {void}\n * @memberof KohostApiClient\n * @example\n * client.organizationId = \"1234\";\n */\n set organizationId(orgId) {\n const key = KohostHTTPClient.defs.organizationHeader;\n this.headers.set(key, orgId);\n }\n\n get organizationId() {\n const key = KohostHTTPClient.defs.organizationHeader;\n return this.headers.get(key);\n }\n\n /**\n * @param {string} propertyId\n * @returns {void}\n * @memberof KohostApiClient\n * @example\n * client.propertyId = \"1234\";\n */\n\n set propertyId(propertyId) {\n const key = KohostHTTPClient.defs.propertyHeader;\n this.headers.set(key, propertyId);\n }\n\n get propertyId() {\n const key = KohostHTTPClient.defs.propertyHeader;\n return this.headers.get(key);\n }\n\n static get defs() {\n return {\n apiKeyHeader: \"X-Api-Key\",\n propertyHeader: \"X-Property-Id\",\n organizationHeader: \"X-Organization-Id\",\n };\n }\n\n /**\n * @typedef {keyof typeof import('./useCases')} CommandName\n * @typedef {import('./useCases')[CommandName]} Command\n *\n * @param {Command} command\n */\n async send(command) {\n const commandConfig = command.config;\n const request = this.createRequest(commandConfig);\n const response = await fetch(request);\n\n const isJsonResponse =\n response.headers.get(\"Content-Type\")?.includes(\"application/json\") ||\n false;\n\n const responseData = isJsonResponse ? await response.json() : response.body;\n\n if (!response.ok) {\n let error = responseData?.error || new Error(response.statusText);\n\n const status = response.status;\n const errorType = responseData.error?.type;\n const errorMessage = responseData?.error?.message;\n\n try {\n const expectedError = status >= 400 && status < 500;\n const newTokensNeeded =\n expectedError && errorType === \"TokenExpiredError\";\n\n if (\n expectedError &&\n errorMessage === \"Phone Verification is required\"\n ) {\n this.#onPhoneVerificationRequired();\n return Promise.reject(error);\n }\n\n if (expectedError && errorMessage === \"Login Required\") {\n this.#onLoginRequired();\n return Promise.reject(error);\n }\n\n if (\n expectedError &&\n errorMessage === \"No auth header or cookie provided\"\n ) {\n this.#onLoginRequired();\n return Promise.reject(error);\n }\n\n if (expectedError && newTokensNeeded) {\n while (!this.isAuthTokenRenewalActive) {\n this.isAuthTokenRenewalActive = true;\n return this.send(\n new RefreshTokenCommand({\n data: commandConfig.data,\n query: commandConfig.params,\n headers: commandConfig.headers,\n }),\n )\n .then(() => {\n // retry the original request with the new token\n this.isAuthTokenRenewalActive = false;\n return fetch(request.clone());\n })\n .catch((err) => {\n this.isAuthTokenRenewalActive = false;\n return Promise.reject(err);\n });\n }\n }\n } catch (error) {\n console.error(error);\n }\n\n error = this.#onError(error);\n\n return Promise.reject(error);\n }\n\n return this.#onSuccess(responseData);\n }\n\n #onLoginRequired() {\n this.emit(\"LoginRequired\");\n }\n\n #onPhoneVerificationRequired() {\n this.emit(\"PhoneVerificationRequired\");\n }\n\n /**\n * @param {Command} config\n * @returns {Request}\n */\n createRequest(config) {\n if (typeof config.headers !== \"object\") {\n config.headers = {};\n }\n\n let apiPath = config.url;\n\n if (apiPath.startsWith(\"/\")) {\n apiPath = `.${apiPath}`;\n }\n const url = new URL(apiPath, this.baseUrl);\n const method = config.method.toUpperCase() || \"GET\";\n\n // Add parameters to URL if they exist\n if (config.params && typeof config.params === \"object\") {\n Object.entries(config.params).forEach(([key, value]) => {\n // Handle array values\n if (Array.isArray(value)) {\n value.forEach((item) => {\n if (typeof item === \"object\" && item !== null) {\n Object.entries(item).forEach(([itemKey, itemValue]) => {\n url.searchParams.append(`${key}[][${itemKey}]`, itemValue);\n });\n } else {\n url.searchParams.append(`${key}[]`, item);\n }\n });\n }\n // Handle null/undefined\n else if (value === null || value === undefined) {\n url.searchParams.append(key, \"\");\n }\n // Handle nested objects\n else if (typeof value === \"object\") {\n Object.entries(value).forEach(([nestedKey, nestedValue]) => {\n if (Array.isArray(nestedValue)) {\n nestedValue.forEach((item) => {\n url.searchParams.append(`${key}[${nestedKey}][]`, item);\n });\n } else {\n url.searchParams.append(`${key}[${nestedKey}]`, nestedValue);\n }\n });\n }\n // Handle primitive values\n else {\n url.searchParams.append(key, value);\n }\n });\n }\n\n const headers = new Headers(this.headers);\n // Add any additional headers\n if (config.headers) {\n Object.keys(config.headers).forEach((key) => {\n headers.set(key, config.headers[key]);\n });\n }\n\n const body = [\"POST\", \"PUT\", \"PATCH\"].includes(method)\n ? headers.get(\"Content-Type\") === \"application/json\"\n ? JSON.stringify(config.data)\n : config.data\n : undefined;\n\n const request = new Request(url, {\n method: method,\n headers: headers,\n credentials: \"include\",\n body: body,\n });\n\n return request;\n }\n}\n"],"mappings":";;;;;;;;AAEO,IAAM,mBAAN,MAAM,kBAAiB;AAAA,EAF9B,OAE8B;AAAA;AAAA;AAAA,EAC5B;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYA,YACE,UAAU;AAAA,IACR,KAAK;AAAA,IACL,YAAY;AAAA,IACZ,gBAAgB;AAAA,IAChB,QAAQ;AAAA,IACR,SAAS,IAAI,QAAQ,CAAC,CAAC;AAAA,IACvB,WAAW,wBAAC,aAAa,UAAd;AAAA,IACX,SAAS,wBAAC,UAAU,OAAX;AAAA,EACX,GACA;AACA,QAAI,CAAC,QAAQ,IAAK,OAAM,IAAI,MAAM,yBAAyB;AAC3D,SAAK,UAAU;AAEf,SAAK,2BAA2B;AAEhC,SAAK,UAAU,IAAI,IAAI,QAAQ,GAAG;AAClC,SAAK,UAAU,IAAI,QAAQ;AAAA,MACzB,gBAAgB;AAAA,MAChB,QAAQ;AAAA,MACR,GAAG,QAAQ;AAAA,IACb,CAAC;AAED,QAAI,QAAQ,QAAQ;AAClB,WAAK,QAAQ,IAAI,kBAAiB,KAAK,cAAc,QAAQ,MAAM;AAAA,IACrE;AAEA,QAAI,QAAQ,YAA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AM,IAAI;AAAA,YAC1C;AAAA,UACF,CAAC;AAAA,QACH,WAES,UAAU,QAAQ,UAAU,QAAW;AAC9C,cAAI,aAAa,OAAO,KAAK,EAAE;AAAA,QACjC,WAES,OAAO,UAAU,UAAU;AAClC,iBAAO,QAAQ,KAAK,EAAE,QAAQ,CAAC,CAAC,WAAW,WAAW,MAAM;AAC1D,gBAAI,MAAM,QAAQ,WAAW,GAAG;AAC9B,0BAAY,QAAQ,CAAC,SAAS;AAC5B,oBAAI,aAAa,OAAO,GAAG,GAAG,IAAI,SAAS,OAAO,IAAI;AAAA,cACxD,CAAC;AAAA,YACH,OAAO;AACL,kBAAI,aAAa,OAAO,GAAG,GAAG,IAAI,SAAS,KAAK,WAAW;AAAA,YAC7D;AAAA,UACF,CAAC;AAAA,QACH,OAEK;AACH,cAAI,aAAa,OAAO,KAAK,KAAK;AAAA,QACpC;AAAA,MACF,CAAC;AAAA,IACH;AAEA,UAAM,UAAU,IAAI,QAAQ,KAAK,OAAO;AAExC,QAAI,OAAO,SAAS;AAClB,aAAO,KAAK,OAAO,OAAO,EAAE,QAAQ,CAAC,QAAQ;AAC3C,gBAAQ,IAAI,KAAK,OAAO,QAAQ,GAAG,CAAC;AAAA,MACtC,CAAC;AAAA,IACH;AAEA,UAAM,OAAO,CAAC,QAAQ,OAAO,OAAO,EAAE,SAAS,MAAM,IACjD,QAAQ,IAAI,cAAc,MAAM,qBAC9B,KAAK,UAAU,OAAO,IAAI,IAC1B,OAAO,OACT;AAEJ,UAAM,UAAU,IAAI,QAAQ,KAAK;AAAA,MAC/B;AAAA,MACA;AAAA,MACA,aAAa;AAAA,MACb;AAAA,IACF,CAAC;AAED,WAAO;AAAA,EACT;AACF;","names":["error"]}
1
+ {"version":3,"sources":["../src/httpClient.js"],"sourcesContent":["import { RefreshTokenCommand } from \"./useCases/refreshToken\";\n\nexport class KohostHTTPClient {\n #onSuccess;\n #onError;\n\n /** \n @param {Object} options - The options to create the client\n @param {String} options.organizationId - The organization ID\n @param {String} options.propertyId - The property ID\n @param {String | URL} options.url - The base URL for the API endpint\n @param {String} options.apiKey - The API key to use for requests\n @param {Headers} options.headers - Additional headers to send with each request\n @param {Function} options.onSuccess - A callback to handle successful responses\n @param {Function} options.onError - A callback to handle errors\n */\n constructor(\n options = {\n url: \"\",\n propertyId: \"\",\n organizationId: \"\",\n apiKey: \"\",\n headers: new Headers({}),\n onSuccess: (response) => response,\n onError: (error) => error,\n },\n ) {\n if (!options.url) throw new Error(\"options.url is required\");\n this.options = options;\n\n this.isAuthTokenRenewalActive = false;\n\n this.baseUrl = new URL(options.url);\n this.headers = new Headers({\n \"Content-Type\": \"application/json\",\n Accept: \"application/json\",\n ...options.headers,\n });\n\n if (options.apiKey) {\n this.headers.set(KohostHTTPClient.defs.apiKeyHeader, options.apiKey);\n }\n\n if (options.propertyId) {\n this.propertyId = options.propertyId;\n }\n\n if (options.organizationId) {\n this.organizationId = options.organizationId;\n }\n\n this.#onSuccess = options.onSuccess\n ? options.onSuccess\n : (response) => response;\n\n this.#onError = options.onError ? options.onError : (error) => error;\n\n this.callbacks = {};\n }\n\n /**\n *\n * @param {\"LoginRequired\" | \"PhoneVerificationRequired\"} event\n * @param {Function} callback\n */\n on(event, callback) {\n if (typeof callback !== \"function\") {\n throw new Error(\"Callback must be a function\");\n }\n if (!this.callbacks[event]) {\n this.callbacks[event] = [];\n }\n this.callbacks[event].push(callback);\n }\n\n emit(event, ...args) {\n if (this.callbacks[event]) {\n this.callbacks[event].forEach((callback) => callback(...args));\n }\n }\n\n /**\n * @param {string} orgId\n * @returns {void}\n * @memberof KohostApiClient\n * @example\n * client.organizationId = \"1234\";\n */\n set organizationId(orgId) {\n const key = KohostHTTPClient.defs.organizationHeader;\n this.headers.set(key, orgId);\n }\n\n get organizationId() {\n const key = KohostHTTPClient.defs.organizationHeader;\n return this.headers.get(key);\n }\n\n /**\n * @param {string} propertyId\n * @returns {void}\n * @memberof KohostApiClient\n * @example\n * client.propertyId = \"1234\";\n */\n\n set propertyId(propertyId) {\n const key = KohostHTTPClient.defs.propertyHeader;\n this.headers.set(key, propertyId);\n }\n\n get propertyId() {\n const key = KohostHTTPClient.defs.propertyHeader;\n return this.headers.get(key);\n }\n\n static get defs() {\n return {\n apiKeyHeader: \"X-Api-Key\",\n propertyHeader: \"X-Property-Id\",\n organizationHeader: \"X-Organization-Id\",\n };\n }\n\n /**\n * @typedef {keyof typeof import('./useCases')} CommandName\n * @typedef {import('./useCases')[CommandName]} Command\n *\n * @param {Command} command\n */\n async send(command) {\n const commandConfig = command.config;\n const request = this.createRequest(commandConfig);\n const response = await fetch(request);\n\n const isJsonResponse =\n response.headers.get(\"Content-Type\")?.includes(\"application/json\") ||\n false;\n\n const responseData = isJsonResponse ? await response.json() : response.body;\n\n if (!response.ok) {\n let error = responseData?.error || new Error(response.statusText);\n\n const status = response.status;\n const errorType = responseData.error?.type;\n const errorMessage = responseData?.error?.message;\n\n try {\n const expectedError = status >= 400 && status < 500;\n const newTokensNeeded =\n expectedError && errorType === \"TokenExpiredError\";\n\n if (\n expectedError &&\n errorMessage === \"Phone Verification is required\"\n ) {\n this.#onPhoneVerificationRequired();\n return Promise.reject(error);\n }\n\n if (expectedError && errorMessage === \"Login Required\") {\n this.#onLoginRequired();\n return Promise.reject(error);\n }\n\n if (\n expectedError &&\n errorMessage === \"No auth header or cookie provided\"\n ) {\n this.#onLoginRequired();\n return Promise.reject(error);\n }\n\n if (expectedError && newTokensNeeded) {\n while (!this.isAuthTokenRenewalActive) {\n this.isAuthTokenRenewalActive = true;\n return this.send(\n new RefreshTokenCommand({\n data: commandConfig.data,\n query: commandConfig.params,\n headers: commandConfig.headers,\n }),\n )\n .then(() => {\n // retry the original request with the new token\n this.isAuthTokenRenewalActive = false;\n return fetch(request.clone());\n })\n .catch((err) => {\n this.isAuthTokenRenewalActive = false;\n return Promise.reject(err);\n });\n }\n }\n } catch (error) {\n console.error(error);\n }\n\n error = this.#onError(error);\n\n return Promise.reject(error);\n }\n\n return this.#onSuccess(responseData);\n }\n\n #onLoginRequired() {\n this.emit(\"LoginRequired\");\n }\n\n #onPhoneVerificationRequired() {\n this.emit(\"PhoneVerificationRequired\");\n }\n\n /**\n * @param {Command} config\n * @returns {Request}\n */\n createRequest(config) {\n if (typeof config.headers !== \"object\") {\n config.headers = {};\n }\n\n let apiPath = config.url;\n\n if (apiPath.startsWith(\"/\")) {\n apiPath = `.${apiPath}`;\n }\n const url = new URL(apiPath, this.baseUrl);\n const method = config.method.toUpperCase() || \"GET\";\n\n // Add parameters to URL if they exist\n if (config.params && typeof config.params === \"object\") {\n Object.entries(config.params).forEach(([key, value]) => {\n // Handle array values\n if (Array.isArray(value)) {\n value.forEach((item) => {\n if (typeof item === \"object\" && item !== null) {\n Object.entries(item).forEach(([itemKey, itemValue]) => {\n url.searchParams.append(`${key}[][${itemKey}]`, itemValue);\n });\n } else {\n url.searchParams.append(`${key}[]`, item);\n }\n });\n }\n // Handle null/undefined\n else if (value === null || value === undefined) {\n url.searchParams.append(key, \"\");\n }\n // Handle nested objects\n else if (typeof value === \"object\") {\n Object.entries(value).forEach(([nestedKey, nestedValue]) => {\n if (Array.isArray(nestedValue)) {\n nestedValue.forEach((item) => {\n url.searchParams.append(`${key}[${nestedKey}][]`, item);\n });\n } else {\n url.searchParams.append(`${key}[${nestedKey}]`, nestedValue);\n }\n });\n }\n // Handle primitive values\n else {\n url.searchParams.append(key, value);\n }\n });\n }\n\n const headers = new Headers(this.headers);\n // Add any additional headers\n if (config.headers) {\n Object.keys(config.headers).forEach((key) => {\n headers.set(key, config.headers[key]);\n });\n }\n\n const body =\n config.data !== null && [\"POST\", \"PUT\", \"PATCH\"].includes(method)\n ? headers.get(\"Content-Type\") === \"application/json\"\n ? JSON.stringify(config.data)\n : config.data\n : undefined;\n\n const request = new Request(url, {\n method: method,\n headers: headers,\n credentials: \"include\",\n body: body,\n });\n\n return request;\n }\n}\n"],"mappings":";;;;;;;;AAEO,IAAM,mBAAN,MAAM,kBAAiB;AAAA,E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KAAK,KAAK;AAAA,QACpC;AAAA,MACF,CAAC;AAAA,IACH;AAEA,UAAM,UAAU,IAAI,QAAQ,KAAK,OAAO;AAExC,QAAI,OAAO,SAAS;AAClB,aAAO,KAAK,OAAO,OAAO,EAAE,QAAQ,CAAC,QAAQ;AAC3C,gBAAQ,IAAI,KAAK,OAAO,QAAQ,GAAG,CAAC;AAAA,MACtC,CAAC;AAAA,IACH;AAEA,UAAM,OACJ,OAAO,SAAS,QAAQ,CAAC,QAAQ,OAAO,OAAO,EAAE,SAAS,MAAM,IAC5D,QAAQ,IAAI,cAAc,MAAM,qBAC9B,KAAK,UAAU,OAAO,IAAI,IAC1B,OAAO,OACT;AAEN,UAAM,UAAU,IAAI,QAAQ,KAAK;AAAA,MAC/B;AAAA,MACA;AAAA,MACA,aAAa;AAAA,MACb;AAAA,IACF,CAAC;AAED,WAAO;AAAA,EACT;AACF;","names":["error"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/commands/index.js","../src/defs.js","../src/commands/command.js","../src/commands/checkInReservation.js","../src/commands/checkOutReservation.js","../src/commands/createImageUploadEndpoint.js","../src/commands/createShortLink.js","../src/commands/getCategories.js","../src/commands/getMobileKey.js","../src/commands/getProducts.js","../src/commands/getReservationSpaceCategoryAvailabilities.js","../src/commands/getReservations.js","../src/commands/getRooms.js","../src/commands/getUsers.js","../src/commands/ocrDocument.js","../src/commands/sellProducts.js","../src/commands/sendEmail.js","../src/commands/sendSMS.js","../src/commands/setAlarm.js","../src/commands/setCourtesy.js","../src/commands/setDimmer.js","../src/commands/setLock.js","../src/commands/setMedia.js","../src/commands/setScene.js","../src/commands/setSwitch.js","../src/commands/setThermostat.js","../src/commands/setWindowCovering.js","../src/commands/updateReservation.js","../src/commands/updateUser.js","../src/commands/uploadImage.js"],"sourcesContent":["// This file is auto-generated. Do not edit this file manually.\n// Generated on: 2025-01-08T00:43:35.863Z\n\nexport { CheckInReservation } from \"./checkInReservation\";\nexport { CheckOutReservation } from \"./checkOutReservation\";\nexport { Command } from \"./command\";\nexport { CreateImageUploadEndpoint } from \"./createImageUploadEndpoint\";\nexport { CreateShortLink } from \"./createShortLink\";\nexport { GetCategories } from \"./getCategories\";\nexport { GetMobileKey } from \"./getMobileKey\";\nexport { GetProducts } from \"./getProducts\";\nexport { GetReservationSpaceCategoryAvailabilities } from \"./getReservationSpaceCategoryAvailabilities\";\nexport { GetReservations } from \"./getReservations\";\nexport { GetRooms } from \"./getRooms\";\nexport { GetUsers } from \"./getUsers\";\nexport { OCRDocument } from \"./ocrDocument\";\nexport { SellProducts } from \"./sellProducts\";\nexport { SendEmail } from \"./sendEmail\";\nexport { SendSMS } from \"./sendSMS\";\nexport { SetAlarm } from \"./setAlarm\";\nexport { SetCourtesy } from \"./setCourtesy\";\nexport { SetDimmer } from \"./setDimmer\";\nexport { SetLock } from \"./setLock\";\nexport { SetMedia } from \"./setMedia\";\nexport { SetScene } from \"./setScene\";\nexport { SetSwitch } from \"./setSwitch\";\nexport { SetThermostat } from \"./setThermostat\";\nexport { SetWindowCovering } from \"./setWindowCovering\";\nexport { UpdateReservation } from \"./updateReservation\";\nexport { UpdateUser } from \"./updateUser\";\nexport { UploadImage } from \"./uploadImage\";","export const amqpExchanges = {\n // routes commands based on `command-name` header and in many cases `property-id` header\n Commands: {\n name: \"kohost.commands\",\n type: \"headers\",\n options: {\n durable: true,\n },\n },\n CommandResponses: {\n name: \"kohost.commandResponses\",\n type: \"topic\",\n options: {\n durable: true,\n },\n },\n // routes events based on routing keys\n DriverEvents: {\n name: \"kohost.events.drivers\",\n type: \"topic\",\n options: {\n durable: true,\n },\n },\n AppEvents: {\n name: \"kohost.events.app\",\n type: \"topic\",\n options: {\n durable: true,\n },\n },\n Direct: {\n name: \"kohost.direct\",\n type: \"direct\",\n options: {\n durable: true,\n },\n },\n // dead letter exchange\n dlx: {\n name: \"kohost.dlx\",\n type: \"direct\",\n },\n};\n\nexport const deviceTypes = [\n \"dimmer\",\n \"switch\",\n \"thermostat\",\n \"lock\",\n \"windowCovering\",\n \"courtesy\",\n \"alarm\",\n \"camera\",\n \"mediaSource\",\n \"motionSensor\",\n \"gateway\",\n];\n","import { amqpExchanges } from \"../defs\";\n\nconst Commands = amqpExchanges.Commands;\n\nexport class Command {\n constructor(data) {\n this.data = {};\n if (!data) throw new Error(\"Command data is required\");\n if (typeof data !== \"object\")\n throw new Error(\"Command data must be an object\");\n\n for (const key in data) {\n this.data[key] = data[key];\n }\n }\n\n get name() {\n throw new Error(\"Command name is required\");\n }\n\n static get type() {\n return \"Command\";\n }\n\n static get exchange() {\n return Commands.name;\n }\n\n build() {\n return { data: { ...this.data } };\n }\n}\n","import { Command } from \"./command\";\n\nexport class CheckInReservation extends Command {\n constructor({ id, ...rest }) {\n super({ id, ...rest });\n }\n\n get name() {\n return \"CheckInReservation\";\n }\n}\n","import { Command } from \"./command\";\n\nexport class CheckOutReservation extends Command {\n constructor({ reservationId, userId, ...rest }) {\n super({ reservationId, userId, ...rest });\n }\n\n get name() {\n return \"CheckOutReservation\";\n }\n}\n","import { Command } from \"./command\";\n\nexport class CreateImageUploadEndpoint extends Command {\n constructor({ id, expires, ...rest }) {\n super({ id, expires, ...rest });\n }\n\n get name() {\n return \"CreateImageUploadEndpoint\";\n }\n}\n","import { Command } from \"./command\";\n\nexport class CreateShortLink extends Command {\n constructor({ title, destination, ...rest }) {\n super({ title, destination, ...rest });\n }\n\n get name() {\n return \"CreateShortLink\";\n }\n}\n","import { Command } from \"./command\";\n\nexport class GetCategories extends Command {\n constructor({ id, ...rest }) {\n super({ id, ...rest });\n }\n\n get name() {\n return \"GetCategories\";\n }\n}\n","import { Command } from \"./command\";\n\nexport class GetMobileKey extends Command {\n constructor({\n id,\n phone,\n beginDateTime,\n endDateTime,\n keyToReplace,\n ...rest\n }) {\n super({ id, phone, beginDateTime, endDateTime, keyToReplace, ...rest });\n }\n\n get name() {\n return \"GetMobileKey\";\n }\n}\n","import { Command } from \"./command\";\n\nexport class GetProducts extends Command {\n constructor({ id, externalSystemId, ...rest }) {\n super({ id, externalSystemId, ...rest });\n }\n\n get name() {\n return \"GetProducts\";\n }\n}\n","import { Command } from \"./command\";\n\nexport class GetReservationSpaceCategoryAvailabilities extends Command {\n constructor(options) {\n const { id, ...rest } = options;\n super({ id, ...rest });\n }\n\n get name() {\n return \"GetReservationSpaceCategoryAvailabilities\";\n }\n}\n","import { Command } from \"./command\";\n\nexport class GetReservations extends Command {\n constructor(options) {\n const { id, startDate, endDate, status, ...rest } = options;\n super({ id, startDate, endDate, status, ...rest });\n }\n\n get name() {\n return \"GetReservations\";\n }\n}\n","import { Command } from \"./command\";\n\nexport class GetRooms extends Command {\n constructor({\n id,\n types,\n categories,\n startDate,\n endDate,\n serviceStatus,\n housekeepingStatus,\n ...rest\n }) {\n super({\n id,\n types,\n categories,\n startDate,\n endDate,\n serviceStatus,\n housekeepingStatus,\n ...rest,\n });\n }\n\n get name() {\n return \"GetRooms\";\n }\n}\n","import { Command } from \"./command\";\n\nexport class GetUsers extends Command {\n constructor({ id, ...rest }) {\n super({ id, ...rest });\n }\n\n get name() {\n return \"GetUsers\";\n }\n}\n","import { Command } from \"./command\";\n\nexport class OCRDocument extends Command {\n constructor({ type, image, ...rest }) {\n super({ type, image, ...rest });\n }\n\n get name() {\n return \"OCRDocument\";\n }\n}\n","import { Command } from \"./command\";\n\nexport class SellProducts extends Command {\n constructor({ reservationId, userId, products, ...rest }) {\n super({ reservationId, userId, products, ...rest });\n }\n\n get name() {\n return \"SellProducts\";\n }\n}\n","import { Command } from \"./command\";\n\nexport class SendEmail extends Command {\n constructor({ text, html, to, from, subject, ...rest }) {\n super({ text, html, to, from, subject, ...rest });\n }\n\n get name() {\n return \"SendEmail\";\n }\n}\n","import { Command } from \"./command\";\n\nexport class SendSMS extends Command {\n constructor({ id, body, to, from, media, ...rest }) {\n super({ id, body, to, from, media, ...rest });\n }\n\n get name() {\n return \"SendSMS\";\n }\n}\n","import { Command } from \"./command\";\n\nexport class SetAlarm extends Command {\n constructor({ id, zones, areas, code, ...rest }) {\n super({ id, zones, areas, code, ...rest });\n }\n\n get name() {\n return \"SetAlarm\";\n }\n}\n","import { Command } from \"./command\";\n\nexport class SetCourtesy extends Command {\n constructor({ id, state, ...rest }) {\n super({ id, state, ...rest });\n }\n\n get name() {\n return \"SetCourtesy\";\n }\n}\n","import { Command } from \"./command\";\n\nexport class SetDimmer extends Command {\n constructor({ id, level, ...rest }) {\n super({ id, level, ...rest });\n }\n\n get name() {\n return \"SetDimmer\";\n }\n}\n","import { Command } from \"./command\";\n\nexport class SetLock extends Command {\n constructor({ id, state, ...rest }) {\n super({ id, state, ...rest });\n }\n\n get name() {\n return \"SetLock\";\n }\n}\n","import { Command } from \"./command\";\n\nexport class SetMedia extends Command {\n constructor({ id, command, ...rest }) {\n super({ id, command, ...rest });\n }\n\n get name() {\n return \"SetMedia\";\n }\n}\n","import { Command } from \"./command\";\n\nexport class SetScene extends Command {\n constructor({ id, devices, ...rest }) {\n super({ id, devices, ...rest });\n }\n\n get name() {\n return \"SetScene\";\n }\n}\n","import { Command } from \"./command\";\n\nexport class SetSwitch extends Command {\n constructor({ id, state, ...rest }) {\n super({ id, state, ...rest });\n }\n\n get name() {\n return \"SetSwitch\";\n }\n}\n","import { Command } from \"./command\";\n\nexport class SetThermostat extends Command {\n constructor({ id, setpoints, hvacMode, fanMode, ...rest }) {\n super({ id, setpoints, hvacMode, fanMode, ...rest });\n }\n\n get name() {\n return \"SetThermostat\";\n }\n}\n","import { Command } from \"./command\";\n\nexport class SetWindowCovering extends Command {\n constructor({ id, position, ...rest }) {\n super({ id, position, ...rest });\n }\n\n get name() {\n return \"SetWindowCovering\";\n }\n}\n","import { Command } from \"./command\";\n\nexport class UpdateReservation extends Command {\n constructor({ id, ...rest }) {\n super({ id, ...rest });\n }\n\n get name() {\n return \"UpdateReservation\";\n }\n}\n","import { Command } from \"./command\";\n\nexport class UpdateUser extends Command {\n constructor({\n id,\n email,\n phone,\n identification,\n address,\n note,\n nationality,\n file,\n payment,\n ...rest\n }) {\n super({\n id,\n email,\n phone,\n identification,\n address,\n note,\n nationality,\n file,\n payment,\n ...rest,\n });\n }\n\n get name() {\n return \"UpdateUser\";\n }\n}\n","import { Command } from \"./command\";\n\nexport class UploadImage extends Command {\n constructor({ id, url, file, ...rest }) {\n super({ id, url, file, ...rest });\n }\n\n get name() {\n return \"UploadImage\";\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,gBAAgB;AAAA;AAAA,EAE3B,UAAU;AAAA,IACR,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,MACP,SAAS;AAAA,IACX;AAAA,EACF;AAAA,EACA,kBAAkB;AAAA,IAChB,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,MACP,SAAS;AAAA,IACX;AAAA,EACF;AAAA;AAAA,EAEA,cAAc;AAAA,IACZ,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,MACP,SAAS;AAAA,IACX;AAAA,EACF;AAAA,EACA,WAAW;AAAA,IACT,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,MACP,SAAS;AAAA,IACX;AAAA,EACF;AAAA,EACA,QAAQ;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,MACP,SAAS;AAAA,IACX;AAAA,EACF;AAAA;AAAA,EAEA,KAAK;AAAA,IACH,MAAM;AAAA,IACN,MAAM;AAAA,EACR;AACF;;;ACzCA,IAAM,WAAW,cAAc;AAExB,IAAM,UAAN,MAAc;AAAA,EAJrB,OAIqB;AAAA;AAAA;AAAA,EACnB,YAAY,MAAM;AAChB,SAAK,OAA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AA,EAEA,IAAI,OAAO;AACT,WAAO;AAAA,EACT;AACF;;;ACRO,IAAM,oBAAN,cAAgC,QAAQ;AAAA,EAF/C,OAE+C;AAAA;AAAA;AAAA,EAC7C,YAAY,EAAE,IAAI,UAAU,GAAG,KAAK,GAAG;AACrC,UAAM,EAAE,IAAI,UAAU,GAAG,KAAK,CAAC;AAAA,EACjC;AAAA,EAEA,IAAI,OAAO;AACT,WAAO;AAAA,EACT;AACF;;;ACRO,IAAM,oBAAN,cAAgC,QAAQ;AAAA,EAF/C,OAE+C;AAAA;AAAA;AAAA,EAC7C,YAAY,EAAE,IAAI,GAAG,KAAK,GAAG;AAC3B,UAAM,EAAE,IAAI,GAAG,KAAK,CAAC;AAAA,EACvB;AAAA,EAEA,IAAI,OAAO;AACT,WAAO;AAAA,EACT;AACF;;;ACRO,IAAM,aAAN,cAAyB,QAAQ;AAAA,EAFxC,OAEwC;AAAA;AAAA;AAAA,EACtC,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,GAAG;AACD,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AAAA,EAEA,IAAI,OAAO;AACT,WAAO;AAAA,EACT;AACF;;;AC9BO,IAAM,cAAN,cAA0B,QAAQ;AAAA,EAFzC,OAEyC;AAAA;AAAA;AAAA,EACvC,YAAY,EAAE,IAAI,KAAK,MAAM,GAAG,KAAK,GAAG;AACtC,UAAM,EAAE,IAAI,KAAK,MAAM,GAAG,KAAK,CAAC;AAAA,EAClC;AAAA,EAEA,IAAI,OAAO;AACT,WAAO;AAAA,EACT;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/commands/index.js","../src/defs.js","../src/commands/command.js","../src/commands/checkInReservation.js","../src/commands/checkOutReservation.js","../src/commands/createImageUploadEndpoint.js","../src/commands/createShortLink.js","../src/commands/getCategories.js","../src/commands/getMobileKey.js","../src/commands/getProducts.js","../src/commands/getReservationSpaceCategoryAvailabilities.js","../src/commands/getReservations.js","../src/commands/getRooms.js","../src/commands/getUsers.js","../src/commands/ocrDocument.js","../src/commands/sellProducts.js","../src/commands/sendEmail.js","../src/commands/sendSMS.js","../src/commands/setAlarm.js","../src/commands/setCourtesy.js","../src/commands/setDimmer.js","../src/commands/setLock.js","../src/commands/setMedia.js","../src/commands/setScene.js","../src/commands/setSwitch.js","../src/commands/setThermostat.js","../src/commands/setWindowCovering.js","../src/commands/updateReservation.js","../src/commands/updateUser.js","../src/commands/uploadImage.js"],"sourcesContent":["// This file is auto-generated. Do not edit this file manually.\n// Generated on: 2025-01-10T20:53:11.170Z\n\nexport { CheckInReservation } from \"./checkInReservation\";\nexport { CheckOutReservation } from \"./checkOutReservation\";\nexport { Command } from \"./command\";\nexport { CreateImageUploadEndpoint } from \"./createImageUploadEndpoint\";\nexport { CreateShortLink } from \"./createShortLink\";\nexport { GetCategories } from \"./getCategories\";\nexport { GetMobileKey } from \"./getMobileKey\";\nexport { GetProducts } from \"./getProducts\";\nexport { GetReservationSpaceCategoryAvailabilities } from \"./getReservationSpaceCategoryAvailabilities\";\nexport { GetReservations } from \"./getReservations\";\nexport { GetRooms } from \"./getRooms\";\nexport { GetUsers } from \"./getUsers\";\nexport { OCRDocument } from \"./ocrDocument\";\nexport { SellProducts } from \"./sellProducts\";\nexport { SendEmail } from \"./sendEmail\";\nexport { SendSMS } from \"./sendSMS\";\nexport { SetAlarm } from \"./setAlarm\";\nexport { SetCourtesy } from \"./setCourtesy\";\nexport { SetDimmer } from \"./setDimmer\";\nexport { SetLock } from \"./setLock\";\nexport { SetMedia } from \"./setMedia\";\nexport { SetScene } from \"./setScene\";\nexport { SetSwitch } from \"./setSwitch\";\nexport { SetThermostat } from \"./setThermostat\";\nexport { SetWindowCovering } from \"./setWindowCovering\";\nexport { UpdateReservation } from \"./updateReservation\";\nexport { UpdateUser } from \"./updateUser\";\nexport { UploadImage } from \"./uploadImage\";","export const amqpExchanges = {\n // routes commands based on `command-name` header and in many cases `property-id` header\n Commands: {\n name: \"kohost.commands\",\n type: \"headers\",\n options: {\n durable: true,\n },\n },\n CommandResponses: {\n name: \"kohost.commandResponses\",\n type: \"topic\",\n options: {\n durable: true,\n },\n },\n // routes events based on routing keys\n DriverEvents: {\n name: \"kohost.events.drivers\",\n type: \"topic\",\n options: {\n durable: true,\n },\n },\n AppEvents: {\n name: \"kohost.events.app\",\n type: \"topic\",\n options: {\n durable: true,\n },\n },\n Direct: {\n name: \"kohost.direct\",\n type: \"direct\",\n options: {\n durable: true,\n },\n },\n // dead letter exchange\n dlx: {\n name: \"kohost.dlx\",\n type: \"direct\",\n },\n};\n\nexport const deviceTypes = [\n \"dimmer\",\n \"switch\",\n \"thermostat\",\n \"lock\",\n \"windowCovering\",\n \"courtesy\",\n \"alarm\",\n \"camera\",\n \"mediaSource\",\n \"motionSensor\",\n \"gateway\",\n];\n","import { amqpExchanges } from \"../defs\";\n\nconst Commands = amqpExchanges.Commands;\n\nexport class Command {\n constructor(data) {\n this.data = {};\n if (!data) throw new Error(\"Command data is required\");\n if (typeof data !== \"object\")\n throw new Error(\"Command data must be an object\");\n\n for (const key in data) {\n this.data[key] = data[key];\n }\n }\n\n get name() {\n throw new Error(\"Command name is required\");\n }\n\n static get type() {\n return \"Command\";\n }\n\n static get exchange() {\n return Commands.name;\n }\n\n build() {\n return { data: { ...this.data } };\n }\n}\n","import { Command } from \"./command\";\n\nexport class CheckInReservation extends Command {\n constructor({ id, ...rest }) {\n super({ id, ...rest });\n }\n\n get name() {\n return \"CheckInReservation\";\n }\n}\n","import { Command } from \"./command\";\n\nexport class CheckOutReservation extends Command {\n constructor({ reservationId, userId, ...rest }) {\n super({ reservationId, userId, ...rest });\n }\n\n get name() {\n return \"CheckOutReservation\";\n }\n}\n","import { Command } from \"./command\";\n\nexport class CreateImageUploadEndpoint extends Command {\n constructor({ id, expires, ...rest }) {\n super({ id, expires, ...rest });\n }\n\n get name() {\n return \"CreateImageUploadEndpoint\";\n }\n}\n","import { Command } from \"./command\";\n\nexport class CreateShortLink extends Command {\n constructor({ title, destination, ...rest }) {\n super({ title, destination, ...rest });\n }\n\n get name() {\n return \"CreateShortLink\";\n }\n}\n","import { Command } from \"./command\";\n\nexport class GetCategories extends Command {\n constructor({ id, ...rest }) {\n super({ id, ...rest });\n }\n\n get name() {\n return \"GetCategories\";\n }\n}\n","import { Command } from \"./command\";\n\nexport class GetMobileKey extends Command {\n constructor({\n id,\n phone,\n beginDateTime,\n endDateTime,\n keyToReplace,\n ...rest\n }) {\n super({ id, phone, beginDateTime, endDateTime, keyToReplace, ...rest });\n }\n\n get name() {\n return \"GetMobileKey\";\n }\n}\n","import { Command } from \"./command\";\n\nexport class GetProducts extends Command {\n constructor({ id, externalSystemId, ...rest }) {\n super({ id, externalSystemId, ...rest });\n }\n\n get name() {\n return \"GetProducts\";\n }\n}\n","import { Command } from \"./command\";\n\nexport class GetReservationSpaceCategoryAvailabilities extends Command {\n constructor(options) {\n const { id, ...rest } = options;\n super({ id, ...rest });\n }\n\n get name() {\n return \"GetReservationSpaceCategoryAvailabilities\";\n }\n}\n","import { Command } from \"./command\";\n\nexport class GetReservations extends Command {\n constructor(options) {\n const { id, startDate, endDate, status, ...rest } = options;\n super({ id, startDate, endDate, status, ...rest });\n }\n\n get name() {\n return \"GetReservations\";\n }\n}\n","import { Command } from \"./command\";\n\nexport class GetRooms extends Command {\n constructor({\n id,\n types,\n categories,\n startDate,\n endDate,\n serviceStatus,\n housekeepingStatus,\n ...rest\n }) {\n super({\n id,\n types,\n categories,\n startDate,\n endDate,\n serviceStatus,\n housekeepingStatus,\n ...rest,\n });\n }\n\n get name() {\n return \"GetRooms\";\n }\n}\n","import { Command } from \"./command\";\n\nexport class GetUsers extends Command {\n constructor({ id, ...rest }) {\n super({ id, ...rest });\n }\n\n get name() {\n return \"GetUsers\";\n }\n}\n","import { Command } from \"./command\";\n\nexport class OCRDocument extends Command {\n constructor({ type, image, ...rest }) {\n super({ type, image, ...rest });\n }\n\n get name() {\n return \"OCRDocument\";\n }\n}\n","import { Command } from \"./command\";\n\nexport class SellProducts extends Command {\n constructor({ reservationId, userId, products, ...rest }) {\n super({ reservationId, userId, products, ...rest });\n }\n\n get name() {\n return \"SellProducts\";\n }\n}\n","import { Command } from \"./command\";\n\nexport class SendEmail extends Command {\n constructor({ text, html, to, from, subject, ...rest }) {\n super({ text, html, to, from, subject, ...rest });\n }\n\n get name() {\n return \"SendEmail\";\n }\n}\n","import { Command } from \"./command\";\n\nexport class SendSMS extends Command {\n constructor({ id, body, to, from, media, ...rest }) {\n super({ id, body, to, from, media, ...rest });\n }\n\n get name() {\n return \"SendSMS\";\n }\n}\n","import { Command } from \"./command\";\n\nexport class SetAlarm extends Command {\n constructor({ id, zones, areas, code, ...rest }) {\n super({ id, zones, areas, code, ...rest });\n }\n\n get name() {\n return \"SetAlarm\";\n }\n}\n","import { Command } from \"./command\";\n\nexport class SetCourtesy extends Command {\n constructor({ id, state, ...rest }) {\n super({ id, state, ...rest });\n }\n\n get name() {\n return \"SetCourtesy\";\n }\n}\n","import { Command } from \"./command\";\n\nexport class SetDimmer extends Command {\n constructor({ id, level, ...rest }) {\n super({ id, level, ...rest });\n }\n\n get name() {\n return \"SetDimmer\";\n }\n}\n","import { Command } from \"./command\";\n\nexport class SetLock extends Command {\n constructor({ id, state, ...rest }) {\n super({ id, state, ...rest });\n }\n\n get name() {\n return \"SetLock\";\n }\n}\n","import { Command } from \"./command\";\n\nexport class SetMedia extends Command {\n constructor({ id, command, ...rest }) {\n super({ id, command, ...rest });\n }\n\n get name() {\n return \"SetMedia\";\n }\n}\n","import { Command } from \"./command\";\n\nexport class SetScene extends Command {\n constructor({ id, devices, ...rest }) {\n super({ id, devices, ...rest });\n }\n\n get name() {\n return \"SetScene\";\n }\n}\n","import { Command } from \"./command\";\n\nexport class SetSwitch extends Command {\n constructor({ id, state, ...rest }) {\n super({ id, state, ...rest });\n }\n\n get name() {\n return \"SetSwitch\";\n }\n}\n","import { Command } from \"./command\";\n\nexport class SetThermostat extends Command {\n constructor({ id, setpoints, hvacMode, fanMode, ...rest }) {\n super({ id, setpoints, hvacMode, fanMode, ...rest });\n }\n\n get name() {\n return \"SetThermostat\";\n }\n}\n","import { Command } from \"./command\";\n\nexport class SetWindowCovering extends Command {\n constructor({ id, position, ...rest }) {\n super({ id, position, ...rest });\n }\n\n get name() {\n return \"SetWindowCovering\";\n }\n}\n","import { Command } from \"./command\";\n\nexport class UpdateReservation extends Command {\n constructor({ id, ...rest }) {\n super({ id, ...rest });\n }\n\n get name() {\n return \"UpdateReservation\";\n }\n}\n","import { Command } from \"./command\";\n\nexport class UpdateUser extends Command {\n constructor({\n id,\n email,\n phone,\n identification,\n address,\n note,\n nationality,\n file,\n payment,\n ...rest\n }) {\n super({\n id,\n email,\n phone,\n identification,\n address,\n note,\n nationality,\n file,\n payment,\n ...rest,\n });\n }\n\n get name() {\n return \"UpdateUser\";\n }\n}\n","import { Command } from \"./command\";\n\nexport class UploadImage extends Command {\n constructor({ id, url, file, ...rest }) {\n super({ id, url, file, ...rest });\n }\n\n get name() {\n return \"UploadImage\";\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,gBAAgB;AAAA;AAAA,EAE3B,UAAU;AAAA,IACR,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,MACP,SAAS;AAAA,IACX;AAAA,EACF;AAAA,EACA,kBAAkB;AAAA,IAChB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A,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,GAAG;AACD,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AAAA,EAEA,IAAI,OAAO;AACT,WAAO;AAAA,EACT;AACF;;;AC9BO,IAAM,cAAN,cAA0B,QAAQ;AAAA,EAFzC,OAEyC;AAAA;AAAA;AAAA,EACvC,YAAY,EAAE,IAAI,KAAK,MAAM,GAAG,KAAK,GAAG;AACtC,UAAM,EAAE,IAAI,KAAK,MAAM,GAAG,KAAK,CAAC;AAAA,EAClC;AAAA,EAEA,IAAI,OAAO;AACT,WAAO;AAAA,EACT;AACF;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/errors/index.js","../src/errors/appError.js","../src/errors/authenticationError.js","../src/errors/authorizationError.js","../src/errors/conflictError.js","../src/errors/deviceCommError.js","../src/errors/loginError.js","../src/errors/notFoundError.js","../src/errors/requestError.js","../src/errors/systemCommError.js","../src/errors/tokenExpiredError.js","../src/errors/unprocessableRequestError.js","../src/errors/validationError.js"],"sourcesContent":["// This file is auto-generated. Do not edit this file manually.\n// Generated on: 2025-01-08T00:43:35.862Z\n\nexport { AppError } from \"./appError\";\nexport { AuthenticationError } from \"./authenticationError\";\nexport { AuthorizationError } from \"./authorizationError\";\nexport { ConflictError } from \"./conflictError\";\nexport { DeviceCommError } from \"./deviceCommError\";\nexport { LoginError } from \"./loginError\";\nexport { NotFoundError } from \"./notFoundError\";\nexport { RequestError } from \"./requestError\";\nexport { SystemCommError } from \"./systemCommError\";\nexport { TokenExpiredError } from \"./tokenExpiredError\";\nexport { UnprocessableRequestError } from \"./unprocessableRequestError\";\nexport { ValidationError } from \"./validationError\";","export class AppError extends Error {\n constructor(message = \"Internal Server Error\", options) {\n super(message, options);\n this.type = this.constructor.name;\n this.statusCode = 500;\n this.name = \"AppError\";\n Object.setPrototypeOf(this, AppError.prototype);\n }\n}\n","import { AppError } from \"./appError\";\n\nexport class AuthenticationError extends AppError {\n constructor(message = \"Authentication Error\", options = {}) {\n super(message, options);\n this.statusCode = 401;\n this.name = \"AuthenticationError\";\n Object.setPrototypeOf(this, AuthenticationError.prototype);\n }\n}\n","import { AppError } from \"./appError\";\n\nexport class AuthorizationError extends AppError {\n constructor(message = \"Authorization Error\", options = {}) {\n super(message, options);\n this.statusCode = 403;\n this.name = \"AuthorizationError\";\n Object.setPrototypeOf(this, AuthorizationError.prototype);\n }\n}\n","import { AppError } from \"./appError\";\n\nexport class ConflictError extends AppError {\n constructor(message = \"Bad Request\", options = {}) {\n super(message, options);\n this.statusCode = 409;\n this.name = \"ConflictError\";\n Object.setPrototypeOf(this, ConflictError.prototype);\n }\n}\n","import { AppError } from \"./appError\";\n\nexport class DeviceCommError extends AppError {\n constructor(message = \"Device Communication Error\", options = {}) {\n super(message, options);\n this.statusCode = 503;\n this.name = \"DeviceCommError\";\n Object.setPrototypeOf(this, DeviceCommError.prototype);\n }\n}\n","import { AppError } from \"./appError\";\n\nexport class LoginError extends AppError {\n constructor(message = \"Invalid Login information provided\", options = {}) {\n super(message, options);\n this.statusCode = 401;\n this.name = \"LoginError\";\n Object.setPrototypeOf(this, LoginError.prototype);\n }\n}\n","import { AppError } from \"./appError\";\n\nexport class NotFoundError extends AppError {\n constructor(message = \"Resource Not Found\", options = {}) {\n super(message, options);\n this.statusCode = 404;\n this.name = \"NotFoundError\";\n Object.setPrototypeOf(this, NotFoundError.prototype);\n }\n}\n","import { AppError } from \"./appError\";\n\nexport class RequestError extends AppError {\n constructor(message = \"Bad Request\", options = {}) {\n super(message, options);\n this.statusCode = 400;\n this.name = \"RequestError\";\n Object.setPrototypeOf(this, RequestError.prototype);\n }\n}\n","import { AppError } from \"./appError\";\n\nexport class SystemCommError extends AppError {\n constructor(message = \"System Communication Error\", options = {}) {\n super(message, options);\n this.statusCode = 503;\n this.name = \"SystemCommError\";\n Object.setPrototypeOf(this, SystemCommError.prototype);\n }\n}\n","import { AppError } from \"./appError\";\n\nexport class TokenExpiredError extends AppError {\n constructor(message = \"Token Expired\", options = {}) {\n super(message, options);\n this.statusCode = 401;\n this.name = \"TokenExpiredError\";\n Object.setPrototypeOf(this, TokenExpiredError.prototype);\n }\n}\n","import { AppError } from \"./appError\";\n\nexport class UnprocessableRequestError extends AppError {\n constructor(message = \"Unprocessable Request Error\", options = {}) {\n super(message, options);\n this.statusCode = 422;\n this.name = \"UnprocessableRequestError\";\n Object.setPrototypeOf(this, UnprocessableRequestError.prototype);\n }\n}\n","import { AppError } from \"./appError\";\n\nexport class ValidationError extends AppError {\n constructor(message = \"Validation Error\", options = {}) {\n super(message, options);\n this.statusCode = 400;\n this.name = \"ValidationError\";\n Object.setPrototypeOf(this, ValidationError.prototype);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,WAAN,MAAM,kBAAiB,MAAM;AAAA,EAApC,OAAoC;AAAA;AAAA;AAAA,EAClC,YAAY,UAAU,yBAAyB,SAAS;AACtD,UAAM,SAAS,OAAO;AACtB,SAAK,OAAO,KAAK,YAAY;AAC7B,SAAK,aAAa;AAClB,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,UAAS,SAAS;AAAA,EAChD;AACF;;;ACNO,IAAM,sBAAN,MAAM,6BAA4B,SAAS;AAAA,EAFlD,OAEkD;AAAA;AAAA;AAAA,EAChD,YAAY,UAAU,wBAAwB,UAAU,CAAC,GAAG;AAC1D,UAAM,SAAS,OAAO;AACtB,SAAK,aAAa;AAClB,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,qBAAoB,SAAS;AAAA,EAC3D;AACF;;;ACPO,IAAM,q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F3C,OAE2C;AAAA;AAAA;AAAA,EACzC,YAAY,UAAU,eAAe,UAAU,CAAC,GAAG;AACjD,UAAM,SAAS,OAAO;AACtB,SAAK,aAAa;AAClB,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,cAAa,SAAS;AAAA,EACpD;AACF;;;ACPO,IAAM,kBAAN,MAAM,yBAAwB,SAAS;AAAA,EAF9C,OAE8C;AAAA;AAAA;AAAA,EAC5C,YAAY,UAAU,8BAA8B,UAAU,CAAC,GAAG;AAChE,UAAM,SAAS,OAAO;AACtB,SAAK,aAAa;AAClB,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,iBAAgB,SAAS;AAAA,EACvD;AACF;;;ACPO,IAAM,oBAAN,MAAM,2BAA0B,SAAS;AAAA,EAFhD,OAEgD;AAAA;AAAA;AAAA,EAC9C,YAAY,UAAU,iBAAiB,UAAU,CAAC,GAAG;AACnD,UAAM,SAAS,OAAO;AACtB,SAAK,aAAa;AAClB,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,mBAAkB,SAAS;AAAA,EACzD;AACF;;;ACPO,IAAM,4BAAN,MAAM,mCAAkC,SAAS;AAAA,EAFxD,OAEwD;AAAA;AAAA;AAAA,EACtD,YAAY,UAAU,+BAA+B,UAAU,CAAC,GAAG;AACjE,UAAM,SAAS,OAAO;AACtB,SAAK,aAAa;AAClB,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,2BAA0B,SAAS;AAAA,EACjE;AACF;;;ACPO,IAAM,kBAAN,MAAM,yBAAwB,SAAS;AAAA,EAF9C,OAE8C;AAAA;AAAA;AAAA,EAC5C,YAAY,UAAU,oBAAoB,UAAU,CAAC,GAAG;AACtD,UAAM,SAAS,OAAO;AACtB,SAAK,aAAa;AAClB,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,iBAAgB,SAAS;AAAA,EACvD;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/errors/index.js","../src/errors/appError.js","../src/errors/authenticationError.js","../src/errors/authorizationError.js","../src/errors/conflictError.js","../src/errors/deviceCommError.js","../src/errors/loginError.js","../src/errors/notFoundError.js","../src/errors/requestError.js","../src/errors/systemCommError.js","../src/errors/tokenExpiredError.js","../src/errors/unprocessableRequestError.js","../src/errors/validationError.js"],"sourcesContent":["// This file is auto-generated. Do not edit this file manually.\n// Generated on: 2025-01-10T20:53:11.169Z\n\nexport { AppError } from \"./appError\";\nexport { AuthenticationError } from \"./authenticationError\";\nexport { AuthorizationError } from \"./authorizationError\";\nexport { ConflictError } from \"./conflictError\";\nexport { DeviceCommError } from \"./deviceCommError\";\nexport { LoginError } from \"./loginError\";\nexport { NotFoundError } from \"./notFoundError\";\nexport { RequestError } from \"./requestError\";\nexport { SystemCommError } from \"./systemCommError\";\nexport { TokenExpiredError } from \"./tokenExpiredError\";\nexport { UnprocessableRequestError } from \"./unprocessableRequestError\";\nexport { ValidationError } from \"./validationError\";","export class AppError extends Error {\n constructor(message = \"Internal Server Error\", options) {\n super(message, options);\n this.type = this.constructor.name;\n this.statusCode = 500;\n this.name = \"AppError\";\n Object.setPrototypeOf(this, AppError.prototype);\n }\n}\n","import { AppError } from \"./appError\";\n\nexport class AuthenticationError extends AppError {\n constructor(message = \"Authentication Error\", options = {}) {\n super(message, options);\n this.statusCode = 401;\n this.name = \"AuthenticationError\";\n Object.setPrototypeOf(this, AuthenticationError.prototype);\n }\n}\n","import { AppError } from \"./appError\";\n\nexport class AuthorizationError extends AppError {\n constructor(message = \"Authorization Error\", options = {}) {\n super(message, options);\n this.statusCode = 403;\n this.name = \"AuthorizationError\";\n Object.setPrototypeOf(this, AuthorizationError.prototype);\n }\n}\n","import { AppError } from \"./appError\";\n\nexport class ConflictError extends AppError {\n constructor(message = \"Bad Request\", options = {}) {\n super(message, options);\n this.statusCode = 409;\n this.name = \"ConflictError\";\n Object.setPrototypeOf(this, ConflictError.prototype);\n }\n}\n","import { AppError } from \"./appError\";\n\nexport class DeviceCommError extends AppError {\n constructor(message = \"Device Communication Error\", options = {}) {\n super(message, options);\n this.statusCode = 503;\n this.name = \"DeviceCommError\";\n Object.setPrototypeOf(this, DeviceCommError.prototype);\n }\n}\n","import { AppError } from \"./appError\";\n\nexport class LoginError extends AppError {\n constructor(message = \"Invalid Login information provided\", options = {}) {\n super(message, options);\n this.statusCode = 401;\n this.name = \"LoginError\";\n Object.setPrototypeOf(this, LoginError.prototype);\n }\n}\n","import { AppError } from \"./appError\";\n\nexport class NotFoundError extends AppError {\n constructor(message = \"Resource Not Found\", options = {}) {\n super(message, options);\n this.statusCode = 404;\n this.name = \"NotFoundError\";\n Object.setPrototypeOf(this, NotFoundError.prototype);\n }\n}\n","import { AppError } from \"./appError\";\n\nexport class RequestError extends AppError {\n constructor(message = \"Bad Request\", options = {}) {\n super(message, options);\n this.statusCode = 400;\n this.name = \"RequestError\";\n Object.setPrototypeOf(this, RequestError.prototype);\n }\n}\n","import { AppError } from \"./appError\";\n\nexport class SystemCommError extends AppError {\n constructor(message = \"System Communication Error\", options = {}) {\n super(message, options);\n this.statusCode = 503;\n this.name = \"SystemCommError\";\n Object.setPrototypeOf(this, SystemCommError.prototype);\n }\n}\n","import { AppError } from \"./appError\";\n\nexport class TokenExpiredError extends AppError {\n constructor(message = \"Token Expired\", options = {}) {\n super(message, options);\n this.statusCode = 401;\n this.name = \"TokenExpiredError\";\n Object.setPrototypeOf(this, TokenExpiredError.prototype);\n }\n}\n","import { AppError } from \"./appError\";\n\nexport class UnprocessableRequestError extends AppError {\n constructor(message = \"Unprocessable Request Error\", options = {}) {\n super(message, options);\n this.statusCode = 422;\n this.name = \"UnprocessableRequestError\";\n Object.setPrototypeOf(this, UnprocessableRequestError.prototype);\n }\n}\n","import { AppError } from \"./appError\";\n\nexport class ValidationError extends AppError {\n constructor(message = \"Validation Error\", options = {}) {\n super(message, options);\n this.statusCode = 400;\n this.name = \"ValidationError\";\n Object.setPrototypeOf(this, ValidationError.prototype);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA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BAAkB,SAAS;AAAA,EACzD;AACF;;;ACPO,IAAM,4BAAN,MAAM,mCAAkC,SAAS;AAAA,EAFxD,OAEwD;AAAA;AAAA;AAAA,EACtD,YAAY,UAAU,+BAA+B,UAAU,CAAC,GAAG;AACjE,UAAM,SAAS,OAAO;AACtB,SAAK,aAAa;AAClB,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,2BAA0B,SAAS;AAAA,EACjE;AACF;;;ACPO,IAAM,kBAAN,MAAM,yBAAwB,SAAS;AAAA,EAF9C,OAE8C;AAAA;AAAA;AAAA,EAC5C,YAAY,UAAU,oBAAoB,UAAU,CAAC,GAAG;AACtD,UAAM,SAAS,OAAO;AACtB,SAAK,aAAa;AAClB,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,iBAAgB,SAAS;AAAA,EACvD;AACF;","names":[]}
package/dist/events.cjs CHANGED
@@ -43,13 +43,13 @@ __export(events_exports, {
43
43
  SystemMotionSensorUpdated: () => SystemMotionSensorUpdated,
44
44
  SystemOrganizationUpdated: () => SystemOrganizationUpdated,
45
45
  SystemProductUpdated: () => SystemProductUpdated,
46
- SystemPropertyUpdate: () => SystemPropertyUpdate,
47
- SystemReservationUpdate: () => SystemReservationUpdate,
46
+ SystemPropertyUpdated: () => SystemPropertyUpdated,
47
+ SystemReservationUpdated: () => SystemReservationUpdated,
48
48
  SystemSpaceUpdate: () => SystemSpaceUpdate,
49
- SystemSwitchUpdate: () => SystemSwitchUpdate,
50
- SystemThermostatUpdate: () => SystemThermostatUpdate,
51
- SystemUserUpdate: () => SystemUserUpdate,
52
- SystemWindowCoveringUpdate: () => SystemWindowCoveringUpdate
49
+ SystemSwitchUpdated: () => SystemSwitchUpdated,
50
+ SystemThermostatUpdated: () => SystemThermostatUpdated,
51
+ SystemUserUpdated: () => SystemUserUpdated,
52
+ SystemWindowCoveringUpdated: () => SystemWindowCoveringUpdated
53
53
  });
54
54
  module.exports = __toCommonJS(events_exports);
55
55
 
@@ -438,7 +438,7 @@ var SystemProductUpdated = class extends Event {
438
438
  };
439
439
 
440
440
  // src/events/systemPropertyUpdated.js
441
- var SystemPropertyUpdate = class extends Event {
441
+ var SystemPropertyUpdated = class extends Event {
442
442
  constructor(property, context) {
443
443
  super(property, context);
444
444
  }
@@ -451,7 +451,7 @@ var SystemPropertyUpdate = class extends Event {
451
451
  };
452
452
 
453
453
  // src/events/systemReservationUpdated.js
454
- var SystemReservationUpdate = class extends Event {
454
+ var SystemReservationUpdated = class extends Event {
455
455
  constructor(reservation, context) {
456
456
  super(reservation, context);
457
457
  }
@@ -477,7 +477,7 @@ var SystemSpaceUpdate = class extends Event {
477
477
  };
478
478
 
479
479
  // src/events/systemSwitchUpdated.js
480
- var SystemSwitchUpdate = class extends Event {
480
+ var SystemSwitchUpdated = class extends Event {
481
481
  constructor(_switch, context) {
482
482
  super(_switch, context);
483
483
  }
@@ -490,7 +490,7 @@ var SystemSwitchUpdate = class extends Event {
490
490
  };
491
491
 
492
492
  // src/events/systemThermostatUpdated.js
493
- var SystemThermostatUpdate = class extends Event {
493
+ var SystemThermostatUpdated = class extends Event {
494
494
  constructor(thermostat, context) {
495
495
  super(thermostat, context);
496
496
  }
@@ -503,7 +503,7 @@ var SystemThermostatUpdate = class extends Event {
503
503
  };
504
504
 
505
505
  // src/events/systemUserUpdated.js
506
- var SystemUserUpdate = class extends Event {
506
+ var SystemUserUpdated = class extends Event {
507
507
  constructor(user, context) {
508
508
  super(user, context);
509
509
  }
@@ -516,7 +516,7 @@ var SystemUserUpdate = class extends Event {
516
516
  };
517
517
 
518
518
  // src/events/systemWindowCoveringUpdated.js
519
- var SystemWindowCoveringUpdate = class extends Event {
519
+ var SystemWindowCoveringUpdated = class extends Event {
520
520
  constructor(wc, context) {
521
521
  super(wc, context);
522
522
  }