import { loadUser } from './api/user-api-service'; import { Account, Environment, Link, MarketplaceItem, MarketplaceService, Organization, PlanProvider, Registry, Tenant, tenantRole, User, Service, Notification, Resource } from "@kumori/aurora-interfaces"; import { EventNames } from "./event-names"; export interface RegistryUpdatePayload { tenant: Tenant; registry: Registry; } export class EventHelper { globalEventHandler: any; constructor(eventHandler: any) { this.globalEventHandler = eventHandler; } private createEvent(eventName: string) { if (!this.globalEventHandler) { console.error("globalEventHandler es undefined al crear el evento:", eventName); } return { publish: (data: T) => this.globalEventHandler.publish(eventName, data), subscribe: (callback: (payload: T) => void) => { if (!this.globalEventHandler.subscribe) { console.error("subscribe no existe para", eventName); } return this.globalEventHandler.subscribe(eventName, callback); }, unsubscribe: (callback: (payload: T) => void) => this.globalEventHandler.unsubscribe(eventName, callback), }; } // * Tenant get tenant() { return { publish: { creation: this.createEvent(EventNames.CreateTenant).publish, created: this.createEvent(EventNames.TenantCreated).publish, creationError: this.createEvent(EventNames.TenantCreationError).publish, update: this.createEvent(EventNames.UpdateTenant).publish, updated: this.createEvent(EventNames.TenantUpdated).publish, updateError: this.createEvent(EventNames.TenantUpdateError).publish, delete: this.createEvent(EventNames.DeleteTenant).publish, deleted: this.createEvent(EventNames.TenantDeleted).publish, deletionError: this.createEvent(EventNames.TenantDeletionError).publish, createRegistry: this.createEvent(EventNames.CreateRegistry).publish, registryCreated: this.createEvent(EventNames.RegistryCreated).publish, registryCreationError: this.createEvent(EventNames.RegistryCreationError).publish, updateRegistry: this.createEvent(EventNames.UpdateRegistry).publish, registryUpdated: this.createEvent(EventNames.RegistryUpdated).publish, registryUpdateError: this.createEvent(EventNames.RegistryUpdateError).publish, deleteRegistry: this.createEvent(EventNames.DeleteRegistry).publish, registryDeleted: this.createEvent(EventNames.RegistryDeleted).publish, registryDeletionError: this.createEvent(EventNames.RegistryDeletionError).publish, inviteUser: this.createEvent<{ tenant: string; user: string; role: tenantRole; }>(EventNames.InviteUser).publish, userInvited: this.createEvent<{ tenant: string; user: string; role: tenantRole; }>(EventNames.UserInvited).publish, inviteError: this.createEvent<{ tenant: string; user: string; role: tenantRole; }>(EventNames.UserInviteError).publish, removeUser: this.createEvent<{ user: string; tenant: string; }>(EventNames.RemoveUserFromTenant).publish, userRemoved: this.createEvent<{ user: string; tenant: string; }>(EventNames.UserRemovedFromTenant).publish, removeUserError: this.createEvent<{ user: string; tenant: string; }>(EventNames.UserRemovalFromTenantError).publish, acceptInvite: this.createEvent<{ tenant: string; }>(EventNames.AcceptInvite).publish, inviteAccepted: this.createEvent<{ user: string; tenant: string; }>(EventNames.InviteAccepted).publish, acceptInviteError: this.createEvent<{ tenant: string; }>(EventNames.InviteAcceptError).publish, updateInvite: this.createEvent<{ tenant: string; user: string; role: tenantRole; }>(EventNames.UpdateInvite).publish, inviteUpdated: this.createEvent<{ tenant: string; user: string; role: tenantRole; }>(EventNames.InviteUpdated).publish, inviteUpdateError: this.createEvent<{ tenant: string; user: string; role: tenantRole; }>(EventNames.InviteUpdateError).publish, rejectInvite: this.createEvent<{ tenant: string; leave: boolean }>(EventNames.RejectInvite).publish, inviteRejected: this.createEvent<{ user: string; tenant: string; }>(EventNames.InviteRejected).publish, inviteRejectError: this.createEvent<{ tenant: string; }>(EventNames.InviteRejectError).publish, createToken: this.createEvent<{ tenant: string; expiration: string; description: string }>(EventNames.CreateToken).publish, tokenCreated: this.createEvent<{ tenant: string; token: string; expiration: string; description: string }>(EventNames.TokenCreated).publish, tokenCreationError: this.createEvent<{ tenant: string; expiration: string; description: string }>(EventNames.TokenCreationError).publish, deleteToken: this.createEvent<{ tenant: string; token: string }>(EventNames.DeleteToken).publish, tokenDeleted: this.createEvent<{ tenant: string; token: string }>(EventNames.TokenDeleted).publish, tokenDeletionError: this.createEvent<{ tenant: string; token: string }>(EventNames.TokenDeletionError).publish, }, subscribe: { creation: this.createEvent(EventNames.CreateTenant).subscribe, created: this.createEvent(EventNames.TenantCreated).subscribe, creationError: this.createEvent(EventNames.TenantCreationError).subscribe, update: this.createEvent(EventNames.UpdateTenant).subscribe, updated: this.createEvent(EventNames.TenantUpdated).subscribe, updateError: this.createEvent(EventNames.TenantUpdateError).subscribe, delete: this.createEvent(EventNames.DeleteTenant).subscribe, deleted: this.createEvent(EventNames.TenantDeleted).subscribe, deletionError: this.createEvent(EventNames.TenantDeletionError).subscribe, createRegistry: this.createEvent(EventNames.CreateRegistry).subscribe, registryCreated: this.createEvent(EventNames.RegistryCreated).subscribe, registryCreationError: this.createEvent(EventNames.RegistryCreationError).subscribe, updateRegistry: this.createEvent(EventNames.UpdateRegistry).subscribe, registryUpdated: this.createEvent(EventNames.RegistryUpdated).subscribe, registryUpdateError: this.createEvent(EventNames.RegistryUpdateError).subscribe, deleteRegistry: this.createEvent(EventNames.DeleteRegistry).subscribe, registryDeleted: this.createEvent(EventNames.RegistryDeleted).subscribe, registryDeletionError: this.createEvent(EventNames.RegistryDeletionError).subscribe, inviteUser: this.createEvent<{ tenant: string; user: string; role: tenantRole; }>(EventNames.InviteUser).subscribe, userInvited: this.createEvent<{ tenant: string; user: string; role: tenantRole; }>(EventNames.UserInvited).subscribe, inviteError: this.createEvent<{ tenant: string; user: string; role: tenantRole; }>(EventNames.UserInviteError).subscribe, removeUser: this.createEvent<{ user: string; tenant: string; }>(EventNames.RemoveUserFromTenant).subscribe, userRemoved: this.createEvent<{ user: string; tenant: string; }>(EventNames.UserRemovedFromTenant).subscribe, removeUserError: this.createEvent<{ user: string; tenant: string; }>(EventNames.UserRemovalFromTenantError).subscribe, acceptInvite: this.createEvent<{ tenant: string; }>(EventNames.AcceptInvite).subscribe, inviteAccepted: this.createEvent<{ user: string; tenant: string; }>(EventNames.InviteAccepted).subscribe, acceptInviteError: this.createEvent<{ tenant: string; }>(EventNames.InviteAcceptError).subscribe, updateInvite: this.createEvent<{ tenant: string; user: string; role: tenantRole; }>(EventNames.UpdateInvite).subscribe, inviteUpdated: this.createEvent<{ tenant: string; user: string; role: tenantRole; }>(EventNames.InviteUpdated).subscribe, inviteUpdateError: this.createEvent<{ tenant: string; user: string; role: tenantRole; }>(EventNames.InviteUpdateError).subscribe, rejectInvite: this.createEvent<{ tenant: string; leave: boolean }>(EventNames.RejectInvite).subscribe, inviteRejected: this.createEvent<{ user: string; tenant: string; }>(EventNames.InviteRejected).subscribe, inviteRejectError: this.createEvent<{ tenant: string; }>(EventNames.InviteRejectError).subscribe, createToken: this.createEvent<{ tenant: string; expiration: string; description: string }>(EventNames.CreateToken).subscribe, tokenCreated: this.createEvent<{ tenant: string; token: string; expiration: string; description: string }>(EventNames.TokenCreated).subscribe, tokenCreationError: this.createEvent<{ tenant: string; expiration: string; description: string }>(EventNames.TokenCreationError).subscribe, deleteToken: this.createEvent<{ tenant: string; token: string }>(EventNames.DeleteToken).subscribe, tokenDeleted: this.createEvent<{ tenant: string; token: string }>(EventNames.TokenDeleted).subscribe, tokenDeletionError: this.createEvent<{ tenant: string; token: string }>(EventNames.TokenDeletionError).subscribe, }, unsubscribe: { creation: this.createEvent(EventNames.CreateTenant).unsubscribe, created: this.createEvent(EventNames.TenantCreated).unsubscribe, creationError: this.createEvent(EventNames.TenantCreationError).unsubscribe, update: this.createEvent(EventNames.UpdateTenant).unsubscribe, updated: this.createEvent(EventNames.TenantUpdated).unsubscribe, updateError: this.createEvent(EventNames.TenantUpdateError).unsubscribe, delete: this.createEvent(EventNames.DeleteTenant).unsubscribe, deleted: this.createEvent(EventNames.TenantDeleted).unsubscribe, deletionError: this.createEvent(EventNames.TenantDeletionError).unsubscribe, createRegistry: this.createEvent(EventNames.CreateRegistry).unsubscribe, registryCreated: this.createEvent(EventNames.RegistryCreated).unsubscribe, registryCreationError: this.createEvent(EventNames.RegistryCreationError).unsubscribe, updateRegistry: this.createEvent(EventNames.UpdateRegistry).unsubscribe, registryUpdated: this.createEvent(EventNames.RegistryUpdated).unsubscribe, registryUpdateError: this.createEvent(EventNames.RegistryUpdateError).unsubscribe, deleteRegistry: this.createEvent(EventNames.DeleteRegistry).unsubscribe, registryDeleted: this.createEvent(EventNames.RegistryDeleted).unsubscribe, registryDeletionError: this.createEvent(EventNames.RegistryDeletionError).unsubscribe, inviteUser: this.createEvent<{ tenant: string; user: string; role: tenantRole; }>(EventNames.InviteUser).unsubscribe, userInvited: this.createEvent<{tenant: string; user: string; role: tenantRole; }>(EventNames.UserInvited).unsubscribe, inviteError: this.createEvent<{ tenant: string; user: string; role: tenantRole; }>(EventNames.UserInviteError).unsubscribe, removeUser: this.createEvent<{ user: string; tenant: string; }>(EventNames.RemoveUserFromTenant).unsubscribe, userRemoved: this.createEvent<{ user: string; tenant: string; }>(EventNames.UserRemovedFromTenant).unsubscribe, removeUserError: this.createEvent<{ user: string; tenant: string; }>(EventNames.UserRemovalFromTenantError).unsubscribe, acceptInvite: this.createEvent<{ tenant: string; }>(EventNames.AcceptInvite).unsubscribe, inviteAccepted: this.createEvent<{ user: string; tenant: string; }>(EventNames.InviteAccepted).unsubscribe, acceptInviteError: this.createEvent<{ tenant: string; }>(EventNames.InviteAcceptError).unsubscribe, updateInvite: this.createEvent<{ tenant: string; user: string; role: tenantRole; }>(EventNames.UpdateInvite).unsubscribe, inviteUpdated: this.createEvent<{ tenant: string; user: string; role: tenantRole; }>(EventNames.InviteUpdated).unsubscribe, inviteUpdateError: this.createEvent<{ tenant: string; user: string; role: tenantRole; }>(EventNames.InviteUpdateError).unsubscribe, rejectInvite: this.createEvent<{ tenant: string; leave: boolean }>(EventNames.RejectInvite).unsubscribe, inviteRejected: this.createEvent<{ user: string; tenant: string; }>(EventNames.InviteRejected).unsubscribe, inviteRejectError: this.createEvent<{ tenant: string; }>(EventNames.InviteRejectError).unsubscribe, createToken: this.createEvent<{ tenant: string; expiration: string; description: string }>(EventNames.CreateToken).unsubscribe, tokenCreated: this.createEvent<{ tenant: string; token: string; expiration: string; description: string }>(EventNames.TokenCreated).unsubscribe, tokenCreationError: this.createEvent<{ tenant: string; expiration: string; description: string }>(EventNames.TokenCreationError).unsubscribe, deleteToken: this.createEvent<{ tenant: string; token: string }>(EventNames.DeleteToken).unsubscribe, tokenDeleted: this.createEvent<{ tenant: string; token: string }>(EventNames.TokenDeleted).unsubscribe, tokenDeletionError: this.createEvent<{ tenant: string; token: string }>(EventNames.TokenDeletionError).unsubscribe, }, }; } // * User get user() { return { publish: { creation: this.createEvent(EventNames.CreateUser).publish, created: this.createEvent(EventNames.UserCreated).publish, creationError: this.createEvent(EventNames.UserCreationError).publish, update: this.createEvent(EventNames.UpdateUser).publish, updated: this.createEvent(EventNames.UserUpdated).publish, updateError: this.createEvent(EventNames.UserUpdateError).publish, load: this.createEvent(EventNames.LoadUser).publish, loaded: this.createEvent(EventNames.UserLoaded).publish, loadError: this.createEvent(EventNames.UserLoadError).publish, delete: this.createEvent(EventNames.DeleteUser).publish, deleted: this.createEvent(EventNames.UserDeleted).publish, deletionError: this.createEvent(EventNames.UserDeletionError).publish, authError: this.createEvent(EventNames.AuthError).publish, }, subscribe: { creation: this.createEvent(EventNames.CreateUser).subscribe, created: this.createEvent(EventNames.UserCreated).subscribe, creationError: this.createEvent(EventNames.UserCreationError).subscribe, update: this.createEvent(EventNames.UpdateUser).subscribe, updated: this.createEvent(EventNames.UserUpdated).subscribe, updateError: this.createEvent(EventNames.UserUpdateError).subscribe, load: this.createEvent(EventNames.LoadUser).subscribe, loaded: this.createEvent(EventNames.UserLoaded).subscribe, loadError: this.createEvent(EventNames.UserLoadError).subscribe, delete: this.createEvent(EventNames.DeleteUser).subscribe, deleted: this.createEvent(EventNames.UserDeleted).subscribe, deletionError: this.createEvent(EventNames.UserDeletionError).subscribe, authError: this.createEvent(EventNames.AuthError).subscribe, }, unsubscribe: { creation: this.createEvent(EventNames.CreateUser).unsubscribe, created: this.createEvent(EventNames.UserCreated).unsubscribe, creationError: this.createEvent(EventNames.UserCreationError).unsubscribe, update: this.createEvent(EventNames.UpdateUser).unsubscribe, updated: this.createEvent(EventNames.UserUpdated).unsubscribe, updateError: this.createEvent(EventNames.UserUpdateError).unsubscribe, load: this.createEvent(EventNames.LoadUser).unsubscribe, loaded: this.createEvent(EventNames.UserLoaded).unsubscribe, loadError: this.createEvent(EventNames.UserLoadError).unsubscribe, delete: this.createEvent(EventNames.DeleteUser).unsubscribe, deleted: this.createEvent(EventNames.UserDeleted).unsubscribe, deletionError: this.createEvent(EventNames.UserDeletionError).unsubscribe, authError: this.createEvent(EventNames.AuthError).unsubscribe, }, }; } // * Account get account() { return { publish: { creation: this.createEvent(EventNames.CreateAccount).publish, created: this.createEvent(EventNames.AccountCreated).publish, creationError: this.createEvent(EventNames.AccountCreationError).publish, update: this.createEvent(EventNames.UpdateAccount).publish, updated: this.createEvent(EventNames.AccountUpdated).publish, updateError: this.createEvent(EventNames.AccountUpdateError).publish, delete: this.createEvent(EventNames.DeleteAccount).publish, deleted: this.createEvent(EventNames.AccountDeleted).publish, deletionError: this.createEvent(EventNames.AccountDeletionError).publish, clean: this.createEvent(EventNames.CleanAccount).publish, cleaned: this.createEvent(EventNames.AccountCleaned).publish, cleanError: this.createEvent(EventNames.AccountCleanError).publish, }, subscribe: { creation: this.createEvent(EventNames.CreateAccount).subscribe, created: this.createEvent(EventNames.AccountCreated).subscribe, creationError: this.createEvent(EventNames.AccountCreationError).subscribe, update: this.createEvent(EventNames.UpdateAccount).subscribe, updated: this.createEvent(EventNames.AccountUpdated).subscribe, updateError: this.createEvent(EventNames.AccountUpdateError).subscribe, delete: this.createEvent(EventNames.DeleteAccount).subscribe, deleted: this.createEvent(EventNames.AccountDeleted).subscribe, deletionError: this.createEvent(EventNames.AccountDeletionError).subscribe, clean: this.createEvent(EventNames.CleanAccount).subscribe, cleaned: this.createEvent(EventNames.AccountCleaned).subscribe, cleanError: this.createEvent(EventNames.AccountCleanError).subscribe, }, unsubscribe: { creation: this.createEvent(EventNames.CreateAccount).unsubscribe, created: this.createEvent(EventNames.AccountCreated).unsubscribe, creationError: this.createEvent(EventNames.AccountCreationError).unsubscribe, update: this.createEvent(EventNames.UpdateAccount).unsubscribe, updated: this.createEvent(EventNames.AccountUpdated).unsubscribe, updateError: this.createEvent(EventNames.AccountUpdateError).unsubscribe, delete: this.createEvent(EventNames.DeleteAccount).unsubscribe, deleted: this.createEvent(EventNames.AccountDeleted).unsubscribe, deletionError: this.createEvent(EventNames.AccountDeletionError).unsubscribe, clean: this.createEvent(EventNames.CleanAccount).unsubscribe, cleaned: this.createEvent(EventNames.AccountCleaned).unsubscribe, cleanError: this.createEvent(EventNames.AccountCleanError).unsubscribe, }, }; } // * Environment get environment() { return { publish: { creation: this.createEvent(EventNames.CreateEnvironment).publish, created: this.createEvent(EventNames.EnvironmentCreated).publish, creationError: this.createEvent(EventNames.EnvironmentCreationError).publish, update: this.createEvent(EventNames.UpdateEnvironment).publish, updated: this.createEvent(EventNames.EnvironmentUpdated).publish, updateError: this.createEvent(EventNames.EnvironmentUpdateError).publish, delete: this.createEvent(EventNames.DeleteEnvironment).publish, deleted: this.createEvent(EventNames.EnvironmentDeleted).publish, deletionError: this.createEvent(EventNames.EvironmentDeletionError).publish, clean: this.createEvent(EventNames.CleanEnvironment).publish, cleaned: this.createEvent(EventNames.EnvironmentCleaned).publish, cleanError: this.createEvent(EventNames.EnvironmentCleanError).publish, scale: this.createEvent(EventNames.ScaleEnvironment).publish, scaled: this.createEvent(EventNames.EnvironmentScaled).publish, scaleError: this.createEvent(EventNames.EnvironmentScaleError).publish, }, subscribe: { creation: this.createEvent(EventNames.CreateEnvironment).subscribe, created: this.createEvent(EventNames.EnvironmentCreated).subscribe, creationError: this.createEvent(EventNames.EnvironmentCreationError).subscribe, update: this.createEvent(EventNames.UpdateEnvironment).subscribe, updated: this.createEvent(EventNames.EnvironmentUpdated).subscribe, updateError: this.createEvent(EventNames.EnvironmentUpdateError).subscribe, delete: this.createEvent(EventNames.DeleteEnvironment).subscribe, deleted: this.createEvent(EventNames.EnvironmentDeleted).subscribe, deletionError: this.createEvent(EventNames.EvironmentDeletionError).subscribe, clean: this.createEvent(EventNames.CleanEnvironment).subscribe, cleaned: this.createEvent(EventNames.EnvironmentCleaned).subscribe, cleanError: this.createEvent(EventNames.EnvironmentCleanError).subscribe, scale: this.createEvent(EventNames.ScaleEnvironment).subscribe, scaled: this.createEvent(EventNames.EnvironmentScaled).subscribe, scaleError: this.createEvent(EventNames.EnvironmentScaleError).subscribe, }, unsubscribe: { creation: this.createEvent(EventNames.CreateEnvironment).unsubscribe, created: this.createEvent(EventNames.EnvironmentCreated).unsubscribe, creationError: this.createEvent(EventNames.EnvironmentCreationError).unsubscribe, update: this.createEvent(EventNames.UpdateEnvironment).unsubscribe, updated: this.createEvent(EventNames.EnvironmentUpdated).unsubscribe, updateError: this.createEvent(EventNames.EnvironmentUpdateError).unsubscribe, delete: this.createEvent(EventNames.DeleteEnvironment).unsubscribe, deleted: this.createEvent(EventNames.EnvironmentDeleted).unsubscribe, deletionError: this.createEvent(EventNames.EvironmentDeletionError).unsubscribe, clean: this.createEvent(EventNames.CleanEnvironment).unsubscribe, cleaned: this.createEvent(EventNames.EnvironmentCleaned).unsubscribe, cleanError: this.createEvent(EventNames.EnvironmentCleanError).unsubscribe, scale: this.createEvent(EventNames.ScaleEnvironment).unsubscribe, scaled: this.createEvent(EventNames.EnvironmentScaled).unsubscribe, scaleError: this.createEvent(EventNames.EnvironmentScaleError).unsubscribe, }, }; } // * Service get service() { return { publish: { deploy: this.createEvent(EventNames.DeployService).publish, deployed: this.createEvent(EventNames.ServiceDeployed).publish, deploymentError: this.createEvent(EventNames.ServiceDeploymentError).publish, update: this.createEvent(EventNames.UpdateService).publish, updated: this.createEvent(EventNames.ServiceUpdated).publish, updateError: this.createEvent(EventNames.ServiceUpdateError).publish, delete: this.createEvent(EventNames.DeleteService).publish, deleted: this.createEvent(EventNames.ServiceDeleted).publish, deletionError: this.createEvent(EventNames.ServiceDeletionError).publish, requestLogs: this.createEvent(EventNames.RequestLogs).publish, restart: this.createEvent(EventNames.RestartService).publish, restarted: this.createEvent(EventNames.ServiceRestarted).publish, restartError: this.createEvent(EventNames.ServiceRestartError).publish, requestRevisionData : this.createEvent(EventNames.RequestRevisionData).publish, updateServiceLinks : this.createEvent(EventNames.updateServiceLinks).publish, changeRevision: this.createEvent(EventNames.ChangeRevision).publish, revisionChanged: this.createEvent(EventNames.RevisionChanged).publish, revisionChangeError: this.createEvent(EventNames.RevisionChangeError).publish, restartInstance: this.createEvent<{ service: Service; roleId: string; instanceId: string }>(EventNames.RestartInstance).publish, instanceRestarted: this.createEvent<{ service: Service; roleId: string; instanceId: string }>(EventNames.InstanceRestarted).publish, instanceRestartError: this.createEvent<{ service: Service; roleId: string; instanceId: string }>(EventNames.InstanceRestartError).publish, }, subscribe: { deploy: this.createEvent(EventNames.DeployService).subscribe, deployed: this.createEvent(EventNames.ServiceDeployed).subscribe, deploymentError: this.createEvent(EventNames.ServiceDeploymentError).subscribe, update: this.createEvent(EventNames.UpdateService).subscribe, updated: this.createEvent(EventNames.ServiceUpdated).subscribe, updateError: this.createEvent(EventNames.ServiceUpdateError).subscribe, delete: this.createEvent(EventNames.DeleteService).subscribe, deleted: this.createEvent(EventNames.ServiceDeleted).subscribe, deletionError: this.createEvent(EventNames.ServiceDeletionError).subscribe, requestLogs: this.createEvent(EventNames.RequestLogs).subscribe, restart: this.createEvent(EventNames.RestartService).subscribe, restarted: this.createEvent(EventNames.ServiceRestarted).subscribe, restartError: this.createEvent(EventNames.ServiceRestartError).subscribe, requestRevisionData : this.createEvent(EventNames.RequestRevisionData).subscribe, updateServiceLinks : this.createEvent(EventNames.updateServiceLinks).subscribe, changeRevision: this.createEvent(EventNames.ChangeRevision).subscribe, revisionChanged: this.createEvent(EventNames.RevisionChanged).subscribe, revisionChangeError: this.createEvent(EventNames.RevisionChangeError).subscribe, restartInstance: this.createEvent<{ service: Service; roleId: string; instanceId: string }>(EventNames.RestartInstance).subscribe, instanceRestarted: this.createEvent<{ service: Service; roleId: string; instanceId: string }>(EventNames.InstanceRestarted).subscribe, instanceRestartError: this.createEvent<{ service: Service; roleId: string; instanceId: string }>(EventNames.InstanceRestartError).subscribe, }, unsubscribe: { deploy: this.createEvent(EventNames.DeployService).unsubscribe, deployed: this.createEvent(EventNames.ServiceDeployed).unsubscribe, deploymentError: this.createEvent(EventNames.ServiceDeploymentError).unsubscribe, update: this.createEvent(EventNames.UpdateService).unsubscribe, updated: this.createEvent(EventNames.ServiceUpdated).unsubscribe, updateError: this.createEvent(EventNames.ServiceUpdateError).unsubscribe, delete: this.createEvent(EventNames.DeleteService).unsubscribe, deleted: this.createEvent(EventNames.ServiceDeleted).unsubscribe, deletionError: this.createEvent(EventNames.ServiceDeletionError).unsubscribe, requestLogs: this.createEvent(EventNames.RequestLogs).unsubscribe, restart: this.createEvent(EventNames.RestartService).unsubscribe, restarted: this.createEvent(EventNames.ServiceRestarted).unsubscribe, restartError: this.createEvent(EventNames.ServiceRestartError).unsubscribe, requestRevisionData : this.createEvent(EventNames.RequestRevisionData).unsubscribe, updateServiceLinks : this.createEvent(EventNames.updateServiceLinks).unsubscribe, changeRevision: this.createEvent(EventNames.ChangeRevision).unsubscribe, revisionChanged: this.createEvent(EventNames.RevisionChanged).unsubscribe, revisionChangeError: this.createEvent(EventNames.RevisionChangeError).unsubscribe, restartInstance: this.createEvent<{ service: Service; roleId: string; instanceId: string }>(EventNames.RestartInstance).unsubscribe, instanceRestarted: this.createEvent<{ service: Service; roleId: string; instanceId: string }>(EventNames.InstanceRestarted).unsubscribe, instanceRestartError: this.createEvent<{ service: Service; roleId: string; instanceId: string }>(EventNames.InstanceRestartError).unsubscribe, }, }; } // * Marketplace get marketplace() { return { publish: { deployItem: this.createEvent(EventNames.DeployMarketplaceItem).publish, itemDeployed: this.createEvent(EventNames.MarketplaceItemDeployed).publish, deploymentError: this.createEvent(EventNames.MarketplaceItemDeploymentError).publish, updateItem: this.createEvent(EventNames.UpdateMarketplaceItem).publish, itemUpdated: this.createEvent(EventNames.MarketplaceItemUpdated).publish, updateError: this.createEvent(EventNames.MarketplaceItemUpdateError).publish, deleteItem: this.createEvent(EventNames.DeleteMarketplaceItem).publish, itemDeleted: this.createEvent(EventNames.MarketplaceItemDeleted).publish, deletionError: this.createEvent(EventNames.MarketplaceItemDeletionError).publish, loadItems: this.createEvent(EventNames.LoadMarketplaceItems).publish, itemsLoaded: this.createEvent(EventNames.MarketplaceItemsLoaded).publish, loadSchema: this.createEvent(EventNames.LoadMarketplaceSchema).publish, schemaLoaded: this.createEvent(EventNames.MarketplaceSchemaLoaded).publish, schemaLoadError: this.createEvent(EventNames.MarketplaceSchemaLoadError).publish, }, subscribe: { deployItem: this.createEvent(EventNames.DeployMarketplaceItem).subscribe, itemDeployed: this.createEvent(EventNames.MarketplaceItemDeployed).subscribe, deploymentError: this.createEvent(EventNames.MarketplaceItemDeploymentError).subscribe, updateItem: this.createEvent(EventNames.UpdateMarketplaceItem).subscribe, itemUpdated: this.createEvent(EventNames.MarketplaceItemUpdated).subscribe, updateError: this.createEvent(EventNames.MarketplaceItemUpdateError).subscribe, deleteItem: this.createEvent(EventNames.DeleteMarketplaceItem).subscribe, itemDeleted: this.createEvent(EventNames.MarketplaceItemDeleted).subscribe, deletionError: this.createEvent(EventNames.MarketplaceItemDeletionError).subscribe, loadItems: this.createEvent(EventNames.LoadMarketplaceItems).subscribe, itemsLoaded: this.createEvent(EventNames.MarketplaceItemsLoaded).subscribe, loadSchema: this.createEvent(EventNames.LoadMarketplaceSchema).subscribe, schemaLoaded: this.createEvent(EventNames.MarketplaceSchemaLoaded).subscribe, schemaLoadError: this.createEvent(EventNames.MarketplaceSchemaLoadError).subscribe, }, unsubscribe: { deployItem: this.createEvent(EventNames.DeployMarketplaceItem).unsubscribe, itemDeployed: this.createEvent(EventNames.MarketplaceItemDeployed).unsubscribe, deploymentError: this.createEvent(EventNames.MarketplaceItemDeploymentError).unsubscribe, updateItem: this.createEvent(EventNames.UpdateMarketplaceItem).unsubscribe, itemUpdated: this.createEvent(EventNames.MarketplaceItemUpdated).unsubscribe, updateError: this.createEvent(EventNames.MarketplaceItemUpdateError).unsubscribe, deleteItem: this.createEvent(EventNames.DeleteMarketplaceItem).unsubscribe, itemDeleted: this.createEvent(EventNames.MarketplaceItemDeleted).unsubscribe, deletionError: this.createEvent(EventNames.MarketplaceItemDeletionError).unsubscribe, loadItems: this.createEvent(EventNames.LoadMarketplaceItems).unsubscribe, itemsLoaded: this.createEvent(EventNames.MarketplaceItemsLoaded).unsubscribe, loadSchema: this.createEvent(EventNames.LoadMarketplaceSchema).unsubscribe, schemaLoaded: this.createEvent(EventNames.MarketplaceSchemaLoaded).unsubscribe, schemaLoadError: this.createEvent(EventNames.MarketplaceSchemaLoadError).unsubscribe, }, }; } // * Resource get resource() { return { publish: { creation: this.createEvent(EventNames.CreateResource).publish, created: this.createEvent(EventNames.ResourceCreated).publish, creationError: this.createEvent(EventNames.ResourceCreationError).publish, update: this.createEvent(EventNames.UpdateResource).publish, updated: this.createEvent(EventNames.ResourceUpdated).publish, updateError: this.createEvent(EventNames.ResourceUpdateError).publish, delete: this.createEvent(EventNames.DeleteResource).publish, deleted: this.createEvent(EventNames.ResourceDeleted).publish, deletionError: this.createEvent(EventNames.ResourceDeletionError).publish, }, subscribe: { creation: this.createEvent(EventNames.CreateResource).subscribe, created: this.createEvent(EventNames.ResourceCreated).subscribe, creationError: this.createEvent(EventNames.ResourceCreationError).subscribe, update: this.createEvent(EventNames.UpdateResource).subscribe, updated: this.createEvent(EventNames.ResourceUpdated).subscribe, updateError: this.createEvent(EventNames.ResourceUpdateError).subscribe, delete: this.createEvent(EventNames.DeleteResource).subscribe, deleted: this.createEvent(EventNames.ResourceDeleted).subscribe, deletionError: this.createEvent(EventNames.ResourceDeletionError).subscribe, }, unsubscribe: { creation: this.createEvent(EventNames.CreateResource).unsubscribe, created: this.createEvent(EventNames.ResourceCreated).unsubscribe, creationError: this.createEvent(EventNames.ResourceCreationError).unsubscribe, update: this.createEvent(EventNames.UpdateResource).unsubscribe, updated: this.createEvent(EventNames.ResourceUpdated).unsubscribe, updateError: this.createEvent(EventNames.ResourceUpdateError).unsubscribe, delete: this.createEvent(EventNames.DeleteResource).unsubscribe, deleted: this.createEvent(EventNames.ResourceDeleted).unsubscribe, deletionError: this.createEvent(EventNames.ResourceDeletionError).unsubscribe, }, }; } // * Plan (payload tipo string) get plan() { return { publish: { upgrade: this.createEvent(EventNames.UpdatePlan).publish, upgraded: this.createEvent(EventNames.PlanUpdated).publish, upgradeError: this.createEvent(EventNames.PlanUpdateError).publish, downgrade: this.createEvent(EventNames.DowngradePlan).publish, downgraded: this.createEvent(EventNames.PlanDowngraded).publish, downgradeError: this.createEvent(EventNames.PlanDowngradeError).publish, }, subscribe: { upgrade: this.createEvent(EventNames.UpdatePlan).subscribe, upgraded: this.createEvent(EventNames.PlanUpdated).subscribe, upgradeError: this.createEvent(EventNames.PlanUpdateError).subscribe, downgrade: this.createEvent(EventNames.DowngradePlan).subscribe, downgraded: this.createEvent(EventNames.PlanDowngraded).subscribe, downgradeError: this.createEvent(EventNames.PlanDowngradeError).subscribe, }, unsubscribe: { upgrade: this.createEvent(EventNames.UpdatePlan).unsubscribe, upgraded: this.createEvent(EventNames.PlanUpdated).unsubscribe, upgradeError: this.createEvent(EventNames.PlanUpdateError).unsubscribe, downgrade: this.createEvent(EventNames.DowngradePlan).unsubscribe, downgraded: this.createEvent(EventNames.PlanDowngraded).unsubscribe, downgradeError: this.createEvent(EventNames.PlanDowngradeError).unsubscribe, }, }; } // * Organization get organization() { return { publish: { creation: this.createEvent(EventNames.CreateOrganization).publish, created: this.createEvent(EventNames.OrganizationCreated).publish, creationError: this.createEvent(EventNames.OrganizationCreationError).publish, update: this.createEvent(EventNames.UpdateOrganization).publish, updated: this.createEvent(EventNames.OrganizationUpdated).publish, updateError: this.createEvent(EventNames.OrganizationUpdateError).publish, delete: this.createEvent(EventNames.DeleteOrganization).publish, deleted: this.createEvent(EventNames.OrganizationDeleted).publish, deletionError: this.createEvent(EventNames.OrganizationDeletionError).publish, }, subscribe: { creation: this.createEvent(EventNames.CreateOrganization).subscribe, created: this.createEvent(EventNames.OrganizationCreated).subscribe, creationError: this.createEvent(EventNames.OrganizationCreationError).subscribe, update: this.createEvent(EventNames.UpdateOrganization).subscribe, updated: this.createEvent(EventNames.OrganizationUpdated).subscribe, updateError: this.createEvent(EventNames.OrganizationUpdateError).subscribe, delete: this.createEvent(EventNames.DeleteOrganization).subscribe, deleted: this.createEvent(EventNames.OrganizationDeleted).subscribe, deletionError: this.createEvent(EventNames.OrganizationDeletionError).subscribe, }, unsubscribe: { creation: this.createEvent(EventNames.CreateOrganization).unsubscribe, created: this.createEvent(EventNames.OrganizationCreated).unsubscribe, creationError: this.createEvent(EventNames.OrganizationCreationError).unsubscribe, update: this.createEvent(EventNames.UpdateOrganization).unsubscribe, updated: this.createEvent(EventNames.OrganizationUpdated).unsubscribe, updateError: this.createEvent(EventNames.OrganizationUpdateError).unsubscribe, delete: this.createEvent(EventNames.DeleteOrganization).unsubscribe, deleted: this.createEvent(EventNames.OrganizationDeleted).unsubscribe, deletionError: this.createEvent(EventNames.OrganizationDeletionError).unsubscribe, }, }; } // * Notification get notification(){ return{ publish: { creation: this.createEvent(EventNames.CreateNotification).publish, deletion: this.createEvent(EventNames.DeleteNotification).publish, read: this.createEvent(EventNames.NotificationRead).publish }, subscribe: { creation: this.createEvent(EventNames.CreateNotification).subscribe, deletion: this.createEvent(EventNames.DeleteNotification).subscribe, read: this.createEvent(EventNames.NotificationRead).subscribe }, unsubscribe: { creation: this.createEvent(EventNames.CreateNotification).unsubscribe, deletion: this.createEvent(EventNames.DeleteNotification).unsubscribe, read: this.createEvent(EventNames.NotificationRead).unsubscribe } } } get planProviders() { return { publish: { loadPlans: this.createEvent(EventNames.LoadPlanProviders).publish, plansLoaded: this.createEvent(EventNames.PlanProvidersLoaded).publish, loadError: this.createEvent(EventNames.PlanProvidersLoadError).publish }, subscribe: { loadPlans: this.createEvent(EventNames.LoadPlanProviders).subscribe, plansLoaded: this.createEvent(EventNames.PlanProvidersLoaded).subscribe, loadError: this.createEvent(EventNames.PlanProvidersLoadError).subscribe }, unsubscribe: { loadPlans: this.createEvent(EventNames.LoadPlanProviders).unsubscribe, plansLoaded: this.createEvent(EventNames.PlanProvidersLoaded).unsubscribe, loadError: this.createEvent(EventNames.PlanProvidersLoadError).unsubscribe }, }; } } export default EventHelper;