@kohost/api-client 4.0.12 → 4.0.13
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.
- package/dist/{chunk-WASFYCMJ.js → chunk-JHS663AH.js} +1 -1
- package/dist/{chunk-WASFYCMJ.js.map → chunk-JHS663AH.js.map} +1 -1
- package/dist/client.cjs +1 -1
- package/dist/client.cjs.map +1 -1
- package/dist/client.js +1 -1
- package/dist/client.js.map +1 -1
- package/dist/commands.cjs.map +1 -1
- package/dist/errors.cjs.map +1 -1
- package/dist/events.cjs.map +1 -1
- package/dist/events.js +1 -1
- package/dist/index.cjs +2 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -8
- package/dist/index.js.map +1 -1
- package/dist/models.cjs.map +1 -1
- package/dist/useCases.cjs.map +1 -1
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{amqpExchanges}from"./chunk-KNSZIQXT.js";import{__export}from"./chunk-HKJ2B2AA.js";var events_exports={};__export(events_exports,{ApplicationInUse:()=>ApplicationInUse,ApplicationOutOfUse:()=>ApplicationOutOfUse,EmailEvent:()=>EmailEvent,Event:()=>Event,ReservationCheckedIn:()=>ReservationCheckedIn,ReservationCheckedOut:()=>ReservationCheckedOut,ReservationSpaceChanged:()=>ReservationSpaceChanged,SMSEvent:()=>SMSEvent,SceneSet:()=>SceneSet,ShortLinkCreated:()=>ShortLinkCreated,SystemAlarmUpdated:()=>SystemAlarmUpdated,SystemCameraUpdated:()=>SystemCameraUpdated,SystemCategoryUpdated:()=>SystemCategoryUpdated,SystemCourtesyUpdated:()=>SystemCourtesyUpdated,SystemCredentialUpdated:()=>SystemCredentialUpdated,SystemDimmerUpdated:()=>SystemDimmerUpdated,SystemEntityDeleted:()=>SystemEntityDeleted,SystemGatewayUpdated:()=>SystemGatewayUpdated,SystemLockUpdated:()=>SystemLockUpdated,SystemMediaSourceUpdated:()=>SystemMediaSourceUpdated,SystemMotionSensorUpdated:()=>SystemMotionSensorUpdated,SystemOrganizationUpdated:()=>SystemOrganizationUpdated,SystemProductUpdated:()=>SystemProductUpdated,SystemPropertyUpdated:()=>SystemPropertyUpdated,SystemReservationUpdated:()=>SystemReservationUpdated,SystemSpaceUpdate:()=>SystemSpaceUpdate,SystemSwitchUpdated:()=>SystemSwitchUpdated,SystemThermostatUpdated:()=>SystemThermostatUpdated,SystemUserUpdated:()=>SystemUserUpdated,SystemWindowCoveringUpdated:()=>SystemWindowCoveringUpdated});var Event=class{constructor(data,context={}){if(this.data=[],this.context=context,!data)throw new Error("Event data is required");if("object"!=typeof data&&!Array.isArray(data))throw new Error("Event data must be an object or array");Array.isArray(data)?this.data=data:this.data=[data]}get organizationId(){return this.context.organizationId||"*"}get propertyId(){return this.context.propertyId||"*"}static get type(){return"Event"}static get exchange(){return amqpExchanges.DriverEvents.name}static get entity(){return""}build(){return{data:{...this.data}}}get routingKey(){return`${this.organizationId}.${this.propertyId}.${this.constructor.entity}.${this.constructor.name}`}},ApplicationInUse=class extends Event{constructor(data={},context){super(data,context)}static get name(){return"ApplicationInUse"}static get entity(){return"app"}static get exchange(){return amqpExchanges.AppEvents.name}},ApplicationOutOfUse=class extends Event{constructor(data={},context={}){super(data,context)}static get name(){return"ApplicationOutOfUse"}static get entity(){return"app"}static get exchange(){return amqpExchanges.AppEvents.name}},EmailEvent=class extends Event{constructor(email,context){super(email,context)}static get name(){return"EmailEvent"}static get entity(){return"emailMessage"}},ReservationCheckedIn=class extends Event{constructor(reservation,context){super(reservation,context)}static get name(){return"ReservationCheckedIn"}static get entity(){return"reservation"}static get exchange(){return amqpExchanges.AppEvents.name}},ReservationCheckedOut=class extends Event{constructor(reservation,context){super(reservation,context)}static get name(){return"ReservationCheckedOut"}static get entity(){return"reservation"}static get exchange(){return amqpExchanges.AppEvents.name}},ReservationSpaceChanged=class extends Event{constructor(reservation,context){super(reservation,context)}static get name(){return"ReservationSpaceChanged"}static get entity(){return"reservation"}static get exchange(){return amqpExchanges.AppEvents.name}},SceneSet=class extends Event{constructor(scene,context){super(scene,context)}static get name(){return"SceneSet"}static get entity(){return"scene"}},ShortLinkCreated=class extends Event{constructor(shortLink,context){super(shortLink,context)}static get name(){return"ShortLinkCreated"}static get entity(){return"shortLink"}},SMSEvent=class extends Event{constructor(sms,context){super(sms,context)}static get name(){return"SMSEvent"}static get entity(){return"smsMessage"}},SystemAlarmUpdated=class extends Event{constructor(alarm,context){super(alarm,context)}static get name(){return"SystemAlarmUpdated"}static get entity(){return"alarm"}},SystemCameraUpdated=class extends Event{constructor(camera,context){super(camera,context)}static get name(){return"SystemCameraUpdated"}static get entity(){return"camera"}},SystemCategoryUpdated=class extends Event{constructor(category,context){super(category,context)}static get name(){return"SystemCategoryUpdated"}static get entity(){return"category"}},SystemCourtesyUpdated=class extends Event{constructor(courtesy,context){super(courtesy,context)}static get name(){return"SystemCourtesyUpdated"}static get entity(){return"courtesy"}},SystemCredentialUpdated=class extends Event{constructor(cred,context){super(cred,context)}static get name(){return"SystemCredentialUpdated"}static get entity(){return"credential"}},SystemDimmerUpdated=class extends Event{constructor(dimmer,context){super(dimmer,context)}static get name(){return"SystemDimmerUpdated"}static get entity(){return"dimmer"}},SystemEntityDeleted=class extends Event{constructor(data,context){super(data,context)}static get name(){return"SystemEntityDeleted"}static get entity(){return"entity"}},SystemGatewayUpdated=class extends Event{constructor(gateway,context){super(gateway,context)}static get name(){return"SystemGatewayUpdated"}static get entity(){return"gateway"}},SystemLockUpdated=class extends Event{constructor(lock,context){super(lock,context)}static get name(){return"SystemLockUpdated"}static get entity(){return"lock"}},SystemMediaSourceUpdated=class extends Event{constructor(mediaSource,context){super(mediaSource,context)}static get name(){return"SystemMediaSourceUpdated"}static get entity(){return"mediaSource"}},SystemMotionSensorUpdated=class extends Event{constructor(motion,context){super(motion,context)}static get name(){return"SystemMotionSensorUpdated"}static get entity(){return"motionSensor"}},SystemOrganizationUpdated=class extends Event{constructor(organization,context){super(organization,context)}static get name(){return"SystemOrganizationUpdated"}static get entity(){return"organization"}},SystemProductUpdated=class extends Event{constructor(product,context){super(product,context)}static get name(){return"SystemProductUpdated"}static get entity(){return"product"}},SystemPropertyUpdated=class extends Event{constructor(property,context){super(property,context)}static get name(){return"SystemPropertyUpdated"}static get entity(){return"property"}},SystemReservationUpdated=class extends Event{constructor(reservation,context){super(reservation,context)}static get name(){return"SystemReservationUpdated"}static get entity(){return"reservation"}},SystemSpaceUpdate=class extends Event{constructor(space,context){super(space,context)}static get name(){return"SystemSpaceUpdated"}static get entity(){return"space"}},SystemSwitchUpdated=class extends Event{constructor(_switch,context){super(_switch,context)}static get name(){return"SystemSwitchUpdated"}static get entity(){return"switch"}},SystemThermostatUpdated=class extends Event{constructor(thermostat,context){super(thermostat,context)}static get name(){return"SystemThermostatUpdated"}static get entity(){return"thermostat"}},SystemUserUpdated=class extends Event{constructor(user,context){super(user,context)}static get name(){return"SystemUserUpdated"}static get entity(){return"user"}},SystemWindowCoveringUpdated=class extends Event{constructor(wc,context){super(wc,context)}static get name(){return"SystemWindowCoveringUpdated"}static get entity(){return"windowCovering"}};export{Event,ApplicationInUse,ApplicationOutOfUse,EmailEvent,ReservationCheckedIn,ReservationCheckedOut,ReservationSpaceChanged,SceneSet,ShortLinkCreated,SMSEvent,SystemAlarmUpdated,SystemCameraUpdated,SystemCategoryUpdated,SystemCourtesyUpdated,SystemCredentialUpdated,SystemDimmerUpdated,SystemEntityDeleted,SystemGatewayUpdated,SystemLockUpdated,SystemMediaSourceUpdated,SystemMotionSensorUpdated,SystemOrganizationUpdated,SystemProductUpdated,SystemPropertyUpdated,SystemReservationUpdated,SystemSpaceUpdate,SystemSwitchUpdated,SystemThermostatUpdated,SystemUserUpdated,SystemWindowCoveringUpdated,events_exports};//# sourceMappingURL=chunk-
|
|
1
|
+
import{amqpExchanges}from"./chunk-KNSZIQXT.js";import{__export}from"./chunk-HKJ2B2AA.js";var events_exports={};__export(events_exports,{ApplicationInUse:()=>ApplicationInUse,ApplicationOutOfUse:()=>ApplicationOutOfUse,EmailEvent:()=>EmailEvent,Event:()=>Event,ReservationCheckedIn:()=>ReservationCheckedIn,ReservationCheckedOut:()=>ReservationCheckedOut,ReservationSpaceChanged:()=>ReservationSpaceChanged,SMSEvent:()=>SMSEvent,SceneSet:()=>SceneSet,ShortLinkCreated:()=>ShortLinkCreated,SystemAlarmUpdated:()=>SystemAlarmUpdated,SystemCameraUpdated:()=>SystemCameraUpdated,SystemCategoryUpdated:()=>SystemCategoryUpdated,SystemCourtesyUpdated:()=>SystemCourtesyUpdated,SystemCredentialUpdated:()=>SystemCredentialUpdated,SystemDimmerUpdated:()=>SystemDimmerUpdated,SystemEntityDeleted:()=>SystemEntityDeleted,SystemGatewayUpdated:()=>SystemGatewayUpdated,SystemLockUpdated:()=>SystemLockUpdated,SystemMediaSourceUpdated:()=>SystemMediaSourceUpdated,SystemMotionSensorUpdated:()=>SystemMotionSensorUpdated,SystemOrganizationUpdated:()=>SystemOrganizationUpdated,SystemProductUpdated:()=>SystemProductUpdated,SystemPropertyUpdated:()=>SystemPropertyUpdated,SystemReservationUpdated:()=>SystemReservationUpdated,SystemSpaceUpdate:()=>SystemSpaceUpdate,SystemSwitchUpdated:()=>SystemSwitchUpdated,SystemThermostatUpdated:()=>SystemThermostatUpdated,SystemUserUpdated:()=>SystemUserUpdated,SystemWindowCoveringUpdated:()=>SystemWindowCoveringUpdated});var Event=class{constructor(data,context={}){if(this.data=[],this.context=context,!data)throw new Error("Event data is required");if("object"!=typeof data&&!Array.isArray(data))throw new Error("Event data must be an object or array");Array.isArray(data)?this.data=data:this.data=[data]}get organizationId(){return this.context.organizationId||"*"}get propertyId(){return this.context.propertyId||"*"}static get type(){return"Event"}static get exchange(){return amqpExchanges.DriverEvents.name}static get entity(){return""}build(){return{data:{...this.data}}}get routingKey(){return`${this.organizationId}.${this.propertyId}.${this.constructor.entity}.${this.constructor.name}`}},ApplicationInUse=class extends Event{constructor(data={},context){super(data,context)}static get name(){return"ApplicationInUse"}static get entity(){return"app"}static get exchange(){return amqpExchanges.AppEvents.name}},ApplicationOutOfUse=class extends Event{constructor(data={},context={}){super(data,context)}static get name(){return"ApplicationOutOfUse"}static get entity(){return"app"}static get exchange(){return amqpExchanges.AppEvents.name}},EmailEvent=class extends Event{constructor(email,context){super(email,context)}static get name(){return"EmailEvent"}static get entity(){return"emailMessage"}},ReservationCheckedIn=class extends Event{constructor(reservation,context){super(reservation,context)}static get name(){return"ReservationCheckedIn"}static get entity(){return"reservation"}static get exchange(){return amqpExchanges.AppEvents.name}},ReservationCheckedOut=class extends Event{constructor(reservation,context){super(reservation,context)}static get name(){return"ReservationCheckedOut"}static get entity(){return"reservation"}static get exchange(){return amqpExchanges.AppEvents.name}},ReservationSpaceChanged=class extends Event{constructor(reservation,context){super(reservation,context)}static get name(){return"ReservationSpaceChanged"}static get entity(){return"reservation"}static get exchange(){return amqpExchanges.AppEvents.name}},SceneSet=class extends Event{constructor(scene,context){super(scene,context)}static get name(){return"SceneSet"}static get entity(){return"scene"}},ShortLinkCreated=class extends Event{constructor(shortLink,context){super(shortLink,context)}static get name(){return"ShortLinkCreated"}static get entity(){return"shortLink"}},SMSEvent=class extends Event{constructor(sms,context){super(sms,context)}static get name(){return"SMSEvent"}static get entity(){return"smsMessage"}},SystemAlarmUpdated=class extends Event{constructor(alarm,context){super(alarm,context)}static get name(){return"SystemAlarmUpdated"}static get entity(){return"alarm"}},SystemCameraUpdated=class extends Event{constructor(camera,context){super(camera,context)}static get name(){return"SystemCameraUpdated"}static get entity(){return"camera"}},SystemCategoryUpdated=class extends Event{constructor(category,context){super(category,context)}static get name(){return"SystemCategoryUpdated"}static get entity(){return"category"}},SystemCourtesyUpdated=class extends Event{constructor(courtesy,context){super(courtesy,context)}static get name(){return"SystemCourtesyUpdated"}static get entity(){return"courtesy"}},SystemCredentialUpdated=class extends Event{constructor(cred,context){super(cred,context)}static get name(){return"SystemCredentialUpdated"}static get entity(){return"credential"}},SystemDimmerUpdated=class extends Event{constructor(dimmer,context){super(dimmer,context)}static get name(){return"SystemDimmerUpdated"}static get entity(){return"dimmer"}},SystemEntityDeleted=class extends Event{constructor(data,context){super(data,context)}static get name(){return"SystemEntityDeleted"}static get entity(){return"entity"}},SystemGatewayUpdated=class extends Event{constructor(gateway,context){super(gateway,context)}static get name(){return"SystemGatewayUpdated"}static get entity(){return"gateway"}},SystemLockUpdated=class extends Event{constructor(lock,context){super(lock,context)}static get name(){return"SystemLockUpdated"}static get entity(){return"lock"}},SystemMediaSourceUpdated=class extends Event{constructor(mediaSource,context){super(mediaSource,context)}static get name(){return"SystemMediaSourceUpdated"}static get entity(){return"mediaSource"}},SystemMotionSensorUpdated=class extends Event{constructor(motion,context){super(motion,context)}static get name(){return"SystemMotionSensorUpdated"}static get entity(){return"motionSensor"}},SystemOrganizationUpdated=class extends Event{constructor(organization,context){super(organization,context)}static get name(){return"SystemOrganizationUpdated"}static get entity(){return"organization"}},SystemProductUpdated=class extends Event{constructor(product,context){super(product,context)}static get name(){return"SystemProductUpdated"}static get entity(){return"product"}},SystemPropertyUpdated=class extends Event{constructor(property,context){super(property,context)}static get name(){return"SystemPropertyUpdated"}static get entity(){return"property"}},SystemReservationUpdated=class extends Event{constructor(reservation,context){super(reservation,context)}static get name(){return"SystemReservationUpdated"}static get entity(){return"reservation"}},SystemSpaceUpdate=class extends Event{constructor(space,context){super(space,context)}static get name(){return"SystemSpaceUpdated"}static get entity(){return"space"}},SystemSwitchUpdated=class extends Event{constructor(_switch,context){super(_switch,context)}static get name(){return"SystemSwitchUpdated"}static get entity(){return"switch"}},SystemThermostatUpdated=class extends Event{constructor(thermostat,context){super(thermostat,context)}static get name(){return"SystemThermostatUpdated"}static get entity(){return"thermostat"}},SystemUserUpdated=class extends Event{constructor(user,context){super(user,context)}static get name(){return"SystemUserUpdated"}static get entity(){return"user"}},SystemWindowCoveringUpdated=class extends Event{constructor(wc,context){super(wc,context)}static get name(){return"SystemWindowCoveringUpdated"}static get entity(){return"windowCovering"}};export{Event,ApplicationInUse,ApplicationOutOfUse,EmailEvent,ReservationCheckedIn,ReservationCheckedOut,ReservationSpaceChanged,SceneSet,ShortLinkCreated,SMSEvent,SystemAlarmUpdated,SystemCameraUpdated,SystemCategoryUpdated,SystemCourtesyUpdated,SystemCredentialUpdated,SystemDimmerUpdated,SystemEntityDeleted,SystemGatewayUpdated,SystemLockUpdated,SystemMediaSourceUpdated,SystemMotionSensorUpdated,SystemOrganizationUpdated,SystemProductUpdated,SystemPropertyUpdated,SystemReservationUpdated,SystemSpaceUpdate,SystemSwitchUpdated,SystemThermostatUpdated,SystemUserUpdated,SystemWindowCoveringUpdated,events_exports};//# sourceMappingURL=chunk-JHS663AH.js.map
|
|
@@ -1 +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-23T15:31:20.558Z\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;A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AAA,EAEA,WAAW,OAAO;AAChB,WAAO;AAAA,EACT;AAAA,EAEA,WAAW,SAAS;AAClB,WAAO;AAAA,EACT;AACF;;;ACZO,IAAM,sBAAN,cAAkC,MAAM;AAAA,EAC7C,YAAY,SAAS,SAAS;AAC5B,UAAM,SAAS,OAAO;AAAA,EACxB;AAAA,EAEA,WAAW,OAAO;AAChB,WAAO;AAAA,EACT;AAAA,EAEA,WAAW,SAAS;AAClB,WAAO;AAAA,EACT;AACF;;;ACZO,IAAM,0BAAN,cAAsC,MAAM;AAAA,EACjD,YAAY,YAAY,SAAS;AAC/B,UAAM,YAAY,OAAO;AAAA,EAC3B;AAAA,EAEA,WAAW,OAAO;AAChB,WAAO;AAAA,EACT;AAAA,EAEA,WAAW,SAAS;AAClB,WAAO;AAAA,EACT;AACF;;;ACZO,IAAM,oBAAN,cAAgC,MAAM;AAAA,EAC3C,YAAY,MAAM,SAAS;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":[]}
|
|
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-24T01:35:50.212Z\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,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,WAAW;AACpB,WAAO,cAAc,aAAa;AAAA,EACpC;AAAA,EAEA,WAAW,SAAS;AAClB,WAAO;AAAA,EACT;AAAA,EAEA,QAAQ;AACN,WAAO,EAAE,MAAM,EAAE,GAAG,KAAK,KAAK,EAAE;AAAA,EAClC;AAAA,EAEA,IAAI,aAAa;AACf,WAAO,GAAG,KAAK,cAAc,IAAI,KAA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;AAAA,EAEA,WAAW,OAAO;AAChB,WAAO;AAAA,EACT;AAAA,EAEA,WAAW,SAAS;AAClB,WAAO;AAAA,EACT;AACF;","names":[]}
|
package/dist/client.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var mod,__defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,httpClient_exports={};((target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})})(httpClient_exports,{KohostHTTPClient:()=>KohostHTTPClient}),module.exports=(mod=httpClient_exports,((to,from,except,desc)=>{if(from&&"object"==typeof from||"function"==typeof from)for(let key of __getOwnPropNames(from))__hasOwnProp.call(to,key)||key===except||__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to})(__defProp({},"__esModule",{value:!0}),mod));var RefreshTokenCommand=class _RefreshTokenCommand{constructor(commandConfig,options={}){const pathParams=_RefreshTokenCommand.params;let{data:data,query:query,headers:headers}=commandConfig??{};void 0===data&&(data=null),void 0===query&&(query=null),void 0===headers&&(headers=null);let url=_RefreshTokenCommand.url;if(pathParams&&data)for(const param of pathParams){const urlParam=":"+param;url=url.replace(urlParam,data[param])}if(url.match(/:[a-zA-Z0-9]+/g)){const missingParams=url.match(/:[a-zA-Z0-9]+/g);if(missingParams){const missing=missingParams.map((param=>param.replace(":","")));throw new Error("Missing parameters: "+missing.join(", "))}}this.url=url,this.data=data,this.query=query,this.headers=headers,this.config={method:_RefreshTokenCommand.method,url:url,data:data,params:query,headers:headers,...options}}static params=[];static url="/auth/refresh";static method="post"},KohostHTTPClient=class _KohostHTTPClient{#onSuccess;#onError;constructor(options={url:"",propertyId:"",organizationId:"",apiKey:"",headers:new Headers({}),onSuccess:response=>response,onError:error=>error}){if(!options.url)throw new Error("options.url is required");this.options=options,this.isAuthTokenRenewalActive=!1,this.baseUrl=new URL(options.url),this.headers=new Headers({"Content-Type":"application/json",Accept:"application/json",...options.headers}),options.apiKey&&this.headers.set(_KohostHTTPClient.defs.apiKeyHeader,options.apiKey),options.propertyId&&(this.propertyId=options.propertyId),options.organizationId&&(this.organizationId=options.organizationId),this.#onSuccess=options.onSuccess?options.onSuccess:response=>response,this.#onError=options.onError?options.onError:error=>error,this.callbacks={}}on(event,callback){if("function"!=typeof callback)throw new Error("Callback must be a function");this.callbacks[event]||(this.callbacks[event]=[]),this.callbacks[event].push(callback)}emit(event,...args){this.callbacks[event]&&this.callbacks[event].forEach((callback=>callback(...args)))}set organizationId(orgId){const key=_KohostHTTPClient.defs.organizationHeader;this.headers.set(key,orgId)}get organizationId(){const key=_KohostHTTPClient.defs.organizationHeader;return this.headers.get(key)}set propertyId(propertyId){const key=_KohostHTTPClient.defs.propertyHeader;this.headers.set(key,propertyId)}get propertyId(){const key=_KohostHTTPClient.defs.propertyHeader;return this.headers.get(key)}static get defs(){return{apiKeyHeader:"X-Api-Key",propertyHeader:"X-Property-Id",organizationHeader:"X-Organization-Id"}}async send(command){const commandConfig=command.config,request=this.createRequest(commandConfig),response=await fetch(request),responseData=response.headers.get("Content-Type")?.includes("application/json")||!1?await response.json():response.body;if(!response.ok){let error=responseData?.error||new Error(response.statusText);const status=response.status,errorType=responseData.error?.type,errorMessage=responseData?.error?.message;try{const expectedError=status>=400&&status<500,newTokensNeeded=expectedError&&"TokenExpiredError"===errorType;if(expectedError&&"Phone Verification is required"===errorMessage)return this.#onPhoneVerificationRequired(),Promise.reject(error);if(expectedError&&"Login Required"===errorMessage)return this.#onLoginRequired(),Promise.reject(error);if(expectedError&&"No auth header or cookie provided"===errorMessage)return this.#onLoginRequired(),Promise.reject(error);if(expectedError&&newTokensNeeded)for(;!this.isAuthTokenRenewalActive;)return this.isAuthTokenRenewalActive=!0,this.send(new RefreshTokenCommand({
|
|
1
|
+
var mod,__defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,httpClient_exports={};((target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})})(httpClient_exports,{KohostHTTPClient:()=>KohostHTTPClient}),module.exports=(mod=httpClient_exports,((to,from,except,desc)=>{if(from&&"object"==typeof from||"function"==typeof from)for(let key of __getOwnPropNames(from))__hasOwnProp.call(to,key)||key===except||__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to})(__defProp({},"__esModule",{value:!0}),mod));var RefreshTokenCommand=class _RefreshTokenCommand{constructor(commandConfig,options={}){const pathParams=_RefreshTokenCommand.params;let{data:data,query:query,headers:headers}=commandConfig??{};void 0===data&&(data=null),void 0===query&&(query=null),void 0===headers&&(headers=null);let url=_RefreshTokenCommand.url;if(pathParams&&data)for(const param of pathParams){const urlParam=":"+param;url=url.replace(urlParam,data[param])}if(url.match(/:[a-zA-Z0-9]+/g)){const missingParams=url.match(/:[a-zA-Z0-9]+/g);if(missingParams){const missing=missingParams.map((param=>param.replace(":","")));throw new Error("Missing parameters: "+missing.join(", "))}}this.url=url,this.data=data,this.query=query,this.headers=headers,this.config={method:_RefreshTokenCommand.method,url:url,data:data,params:query,headers:headers,...options}}static params=[];static url="/auth/refresh";static method="post"},KohostHTTPClient=class _KohostHTTPClient{#onSuccess;#onError;constructor(options={url:"",propertyId:"",organizationId:"",apiKey:"",headers:new Headers({}),onSuccess:response=>response,onError:error=>error}){if(!options.url)throw new Error("options.url is required");this.options=options,this.isAuthTokenRenewalActive=!1,this.baseUrl=new URL(options.url),this.headers=new Headers({"Content-Type":"application/json",Accept:"application/json",...options.headers}),options.apiKey&&this.headers.set(_KohostHTTPClient.defs.apiKeyHeader,options.apiKey),options.propertyId&&(this.propertyId=options.propertyId),options.organizationId&&(this.organizationId=options.organizationId),this.#onSuccess=options.onSuccess?options.onSuccess:response=>response,this.#onError=options.onError?options.onError:error=>error,this.callbacks={}}on(event,callback){if("function"!=typeof callback)throw new Error("Callback must be a function");this.callbacks[event]||(this.callbacks[event]=[]),this.callbacks[event].push(callback)}emit(event,...args){this.callbacks[event]&&this.callbacks[event].forEach((callback=>callback(...args)))}set organizationId(orgId){const key=_KohostHTTPClient.defs.organizationHeader;this.headers.set(key,orgId)}get organizationId(){const key=_KohostHTTPClient.defs.organizationHeader;return this.headers.get(key)}set propertyId(propertyId){const key=_KohostHTTPClient.defs.propertyHeader;this.headers.set(key,propertyId)}get propertyId(){const key=_KohostHTTPClient.defs.propertyHeader;return this.headers.get(key)}static get defs(){return{apiKeyHeader:"X-Api-Key",propertyHeader:"X-Property-Id",organizationHeader:"X-Organization-Id"}}async send(command){const commandConfig=command.config,request=this.createRequest(commandConfig),response=await fetch(request),responseData=response.headers.get("Content-Type")?.includes("application/json")||!1?await response.json():response.body;if(!response.ok){let error=responseData?.error||new Error(response.statusText);const status=response.status,errorType=responseData.error?.type,errorMessage=responseData?.error?.message;try{const expectedError=status>=400&&status<500,newTokensNeeded=expectedError&&"TokenExpiredError"===errorType;if(expectedError&&"Phone Verification is required"===errorMessage)return this.#onPhoneVerificationRequired(),Promise.reject(error);if(expectedError&&"Login Required"===errorMessage)return this.#onLoginRequired(),Promise.reject(error);if(expectedError&&"No auth header or cookie provided"===errorMessage)return this.#onLoginRequired(),Promise.reject(error);if(expectedError&&newTokensNeeded)for(;!this.isAuthTokenRenewalActive;)return this.isAuthTokenRenewalActive=!0,this.send(new RefreshTokenCommand({})).then((()=>(this.isAuthTokenRenewalActive=!1,this.send(command)))).catch((err=>(this.isAuthTokenRenewalActive=!1,Promise.reject(err))))}catch(error2){console.error(error2)}return error=this.#onError(error),Promise.reject(error)}return this.#onSuccess(responseData)}#onLoginRequired(){this.emit("LoginRequired")}#onPhoneVerificationRequired(){this.emit("PhoneVerificationRequired")}createRequest(config){"object"!=typeof config.headers&&(config.headers={});let apiPath=config.url;apiPath.startsWith("/")&&(apiPath=`.${apiPath}`);const url=new URL(apiPath,this.baseUrl),method=config.method.toUpperCase()||"GET";config.params&&"object"==typeof config.params&&Object.entries(config.params).forEach((([key,value])=>{Array.isArray(value)?value.forEach((item=>{"object"==typeof item&&null!==item?Object.entries(item).forEach((([itemKey,itemValue])=>{url.searchParams.append(`${key}[][${itemKey}]`,itemValue)})):url.searchParams.append(`${key}[]`,item)})):null==value?url.searchParams.append(key,""):"object"==typeof value?Object.entries(value).forEach((([nestedKey,nestedValue])=>{Array.isArray(nestedValue)?nestedValue.forEach((item=>{url.searchParams.append(`${key}[${nestedKey}][]`,item)})):url.searchParams.append(`${key}[${nestedKey}]`,nestedValue)})):url.searchParams.append(key,value)}));const headers=new Headers(this.headers);config.headers&&Object.keys(config.headers).forEach((key=>{headers.set(key,config.headers[key])}));const body=null!==config.data&&["POST","PUT","PATCH"].includes(method)?"application/json"===headers.get("Content-Type")?JSON.stringify(config.data):config.data:void 0;return new Request(url,{method:method,headers:headers,credentials:"include",body:body})}};//# sourceMappingURL=client.cjs.map
|
package/dist/client.cjs.map
CHANGED
|
@@ -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 =\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;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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AC,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
|
+
{"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(new RefreshTokenCommand({}))\n .then(() => {\n // retry the original request with the new token\n this.isAuthTokenRenewalActive = false;\n return this.send(command);\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;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,CAAC;AAAA,MACzC;AAAA,IACF;AAGA,QAAI,IAAI,MAAM,gBAAgB,GAAG;AAC/B,YAAM,gBAAgB,IAAI,MAAM,gBAAgB;AAEhD,UAAI,eAAe;AAEjB,cAAM,UAAU,cAAc,IAAI,C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C,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,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"]}
|
package/dist/client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{RefreshTokenCommand}from"./chunk-W2G36LNI.js";import"./chunk-HKJ2B2AA.js";var KohostHTTPClient=class _KohostHTTPClient{#onSuccess;#onError;constructor(options={url:"",propertyId:"",organizationId:"",apiKey:"",headers:new Headers({}),onSuccess:response=>response,onError:error=>error}){if(!options.url)throw new Error("options.url is required");this.options=options,this.isAuthTokenRenewalActive=!1,this.baseUrl=new URL(options.url),this.headers=new Headers({"Content-Type":"application/json",Accept:"application/json",...options.headers}),options.apiKey&&this.headers.set(_KohostHTTPClient.defs.apiKeyHeader,options.apiKey),options.propertyId&&(this.propertyId=options.propertyId),options.organizationId&&(this.organizationId=options.organizationId),this.#onSuccess=options.onSuccess?options.onSuccess:response=>response,this.#onError=options.onError?options.onError:error=>error,this.callbacks={}}on(event,callback){if("function"!=typeof callback)throw new Error("Callback must be a function");this.callbacks[event]||(this.callbacks[event]=[]),this.callbacks[event].push(callback)}emit(event,...args){this.callbacks[event]&&this.callbacks[event].forEach((callback=>callback(...args)))}set organizationId(orgId){const key=_KohostHTTPClient.defs.organizationHeader;this.headers.set(key,orgId)}get organizationId(){const key=_KohostHTTPClient.defs.organizationHeader;return this.headers.get(key)}set propertyId(propertyId){const key=_KohostHTTPClient.defs.propertyHeader;this.headers.set(key,propertyId)}get propertyId(){const key=_KohostHTTPClient.defs.propertyHeader;return this.headers.get(key)}static get defs(){return{apiKeyHeader:"X-Api-Key",propertyHeader:"X-Property-Id",organizationHeader:"X-Organization-Id"}}async send(command){const commandConfig=command.config,request=this.createRequest(commandConfig),response=await fetch(request),responseData=response.headers.get("Content-Type")?.includes("application/json")||!1?await response.json():response.body;if(!response.ok){let error=responseData?.error||new Error(response.statusText);const status=response.status,errorType=responseData.error?.type,errorMessage=responseData?.error?.message;try{const expectedError=status>=400&&status<500,newTokensNeeded=expectedError&&"TokenExpiredError"===errorType;if(expectedError&&"Phone Verification is required"===errorMessage)return this.#onPhoneVerificationRequired(),Promise.reject(error);if(expectedError&&"Login Required"===errorMessage)return this.#onLoginRequired(),Promise.reject(error);if(expectedError&&"No auth header or cookie provided"===errorMessage)return this.#onLoginRequired(),Promise.reject(error);if(expectedError&&newTokensNeeded)for(;!this.isAuthTokenRenewalActive;)return this.isAuthTokenRenewalActive=!0,this.send(new RefreshTokenCommand({
|
|
1
|
+
import{RefreshTokenCommand}from"./chunk-W2G36LNI.js";import"./chunk-HKJ2B2AA.js";var KohostHTTPClient=class _KohostHTTPClient{#onSuccess;#onError;constructor(options={url:"",propertyId:"",organizationId:"",apiKey:"",headers:new Headers({}),onSuccess:response=>response,onError:error=>error}){if(!options.url)throw new Error("options.url is required");this.options=options,this.isAuthTokenRenewalActive=!1,this.baseUrl=new URL(options.url),this.headers=new Headers({"Content-Type":"application/json",Accept:"application/json",...options.headers}),options.apiKey&&this.headers.set(_KohostHTTPClient.defs.apiKeyHeader,options.apiKey),options.propertyId&&(this.propertyId=options.propertyId),options.organizationId&&(this.organizationId=options.organizationId),this.#onSuccess=options.onSuccess?options.onSuccess:response=>response,this.#onError=options.onError?options.onError:error=>error,this.callbacks={}}on(event,callback){if("function"!=typeof callback)throw new Error("Callback must be a function");this.callbacks[event]||(this.callbacks[event]=[]),this.callbacks[event].push(callback)}emit(event,...args){this.callbacks[event]&&this.callbacks[event].forEach((callback=>callback(...args)))}set organizationId(orgId){const key=_KohostHTTPClient.defs.organizationHeader;this.headers.set(key,orgId)}get organizationId(){const key=_KohostHTTPClient.defs.organizationHeader;return this.headers.get(key)}set propertyId(propertyId){const key=_KohostHTTPClient.defs.propertyHeader;this.headers.set(key,propertyId)}get propertyId(){const key=_KohostHTTPClient.defs.propertyHeader;return this.headers.get(key)}static get defs(){return{apiKeyHeader:"X-Api-Key",propertyHeader:"X-Property-Id",organizationHeader:"X-Organization-Id"}}async send(command){const commandConfig=command.config,request=this.createRequest(commandConfig),response=await fetch(request),responseData=response.headers.get("Content-Type")?.includes("application/json")||!1?await response.json():response.body;if(!response.ok){let error=responseData?.error||new Error(response.statusText);const status=response.status,errorType=responseData.error?.type,errorMessage=responseData?.error?.message;try{const expectedError=status>=400&&status<500,newTokensNeeded=expectedError&&"TokenExpiredError"===errorType;if(expectedError&&"Phone Verification is required"===errorMessage)return this.#onPhoneVerificationRequired(),Promise.reject(error);if(expectedError&&"Login Required"===errorMessage)return this.#onLoginRequired(),Promise.reject(error);if(expectedError&&"No auth header or cookie provided"===errorMessage)return this.#onLoginRequired(),Promise.reject(error);if(expectedError&&newTokensNeeded)for(;!this.isAuthTokenRenewalActive;)return this.isAuthTokenRenewalActive=!0,this.send(new RefreshTokenCommand({})).then((()=>(this.isAuthTokenRenewalActive=!1,this.send(command)))).catch((err=>(this.isAuthTokenRenewalActive=!1,Promise.reject(err))))}catch(error2){console.error(error2)}return error=this.#onError(error),Promise.reject(error)}return this.#onSuccess(responseData)}#onLoginRequired(){this.emit("LoginRequired")}#onPhoneVerificationRequired(){this.emit("PhoneVerificationRequired")}createRequest(config){"object"!=typeof config.headers&&(config.headers={});let apiPath=config.url;apiPath.startsWith("/")&&(apiPath=`.${apiPath}`);const url=new URL(apiPath,this.baseUrl),method=config.method.toUpperCase()||"GET";config.params&&"object"==typeof config.params&&Object.entries(config.params).forEach((([key,value])=>{Array.isArray(value)?value.forEach((item=>{"object"==typeof item&&null!==item?Object.entries(item).forEach((([itemKey,itemValue])=>{url.searchParams.append(`${key}[][${itemKey}]`,itemValue)})):url.searchParams.append(`${key}[]`,item)})):null==value?url.searchParams.append(key,""):"object"==typeof value?Object.entries(value).forEach((([nestedKey,nestedValue])=>{Array.isArray(nestedValue)?nestedValue.forEach((item=>{url.searchParams.append(`${key}[${nestedKey}][]`,item)})):url.searchParams.append(`${key}[${nestedKey}]`,nestedValue)})):url.searchParams.append(key,value)}));const headers=new Headers(this.headers);config.headers&&Object.keys(config.headers).forEach((key=>{headers.set(key,config.headers[key])}));const body=null!==config.data&&["POST","PUT","PATCH"].includes(method)?"application/json"===headers.get("Content-Type")?JSON.stringify(config.data):config.data:void 0;return new Request(url,{method:method,headers:headers,credentials:"include",body:body})}};export{KohostHTTPClient};//# sourceMappingURL=client.js.map
|
package/dist/client.js.map
CHANGED
|
@@ -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 =\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":";;;;;;AAE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AAK;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
|
+
{"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(new RefreshTokenCommand({}))\n .then(() => {\n // retry the original request with the new token\n this.isAuthTokenRenewalActive = false;\n return this.send(command);\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,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,CAAC,aAAa;AAAA,IACzB,SAAS,CAAC,UAAU;AAAA,EACtB,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,Q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MAAM,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,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"]}
|
package/dist/commands.cjs.map
CHANGED
|
@@ -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-23T15:31:20.560Z\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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I,OAAO;AACT,WAAO;AAAA,EACT;AACF;;;ACRO,IAAM,oBAAN,cAAgC,QAAQ;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,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,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-24T01:35:50.213Z\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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;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,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":[]}
|
package/dist/errors.cjs.map
CHANGED
|
@@ -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-
|
|
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-24T01:35:50.212Z\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,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,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