import { IHubJoinRequestBase } from './hubs'; /** * The client app hub join request * * @export * @interface IHubClientAppJoinRequest */ export interface IHubClientAppJoinRequest extends IHubJoinRequestBase { app: IClientApp; registeredCallback?: (appRegistered: IHubEventClientAppRegistered) => void; unregisteredCallback?: (appUnregistered: IHubEventClientAppRegistered) => void; messageReceivedCallback?: (appMessage: IHubEventClientAppMessage) => void; joinChannelCallback?: (joinEvent: IHubEventJoinedChannelMessage) => void; leaveChannelCallback?: (leaveEvent: IHubEventLeftChannelMessage) => void; } export declare type TClientAppActions = 'cfd:confirmUserDetails' | 'cfd:confirmUserDetailsResponse' | 'cfd:idle' | 'cfd:orderUpdate' | 'cfd:pickDiscountProductResponse' | 'cfd:userForm' | 'cfd:userFormResponse' | 'client:ping' | 'client:status' | 'notification' | 'scanBarcode' | 'setOrder' | 'setUser' | 'transferOrder'; /** * The client application details * * @export * @interface IClientApp */ export interface IClientApp { /** * Unique uuid v4 to identify the ClientApp instance * * @type {string} */ UUID: string; /** * The EVA user agent. Will be retrieved from the core settings if not provided * * @type {string} */ UserAgent?: string; /** * Optional user friendly display name of the application * * @type {string} */ DisplayName?: string; /** * The current user for the App * * @type {number} */ UserID?: number; /** * The current user type for the App * * @type {EVA.Core.UserTypes} */ UserType?: EVA.Core.UserTypes; } /** * The registration client message * * @export * @interface IClientAppRegister */ export interface IClientAppRegister { App: IClientApp; } /** * The unregister client message * * @export * @interface IClientAppUnregister */ export interface IClientAppUnregister { App: IClientApp; } /** * The join channel message * * By default POS/Companion app will join a channel for the current stations * ProxyID. If no ProxyID is available it will join `ST:${StationID}` * * @export * @interface IClientAppJoinChannel */ export interface IClientAppJoinChannel { ChannelID: string; } /** * The leave channel message * * @export * @interface IClientAppLeaveChannel */ export interface IClientAppLeaveChannel { ChannelID: string; } /** * The message format to send to all the client apps in a channel * * @export * @interface IClientAppMessage */ export interface IClientAppMessage { /** The channel the message is to be sent to */ ChannelID: string; /** Message data */ Message: IClientAppMessagePayload; UUID?: string; } /** * A message to request all clients on a hub to acknowledge their presence * This will include the client requesting the ping as well * * @export * @interface IClientAppPing */ export interface IClientAppPing { /** * The client application requesting the ping */ App: IClientApp; /** * Used to ping a specific client application * * @type {string} */ TargetUUID?: string; } /** * The generic variant that any message should extend from * * @export * @interface IClientAppMessagePayload */ export interface IClientAppMessagePayload { Action: TClientAppActions; Data: any; } /** * The set current order message payload * * @export * @interface IClientAppSetOrderPayload * @extends {IClientAppMessagePayload} */ export interface IClientAppSetOrderPayload extends IClientAppMessagePayload { Action: 'setOrder'; Data: { OrderID: number; }; } /** * The set current user message payload * Can optionally also supply a target OrderID to combine the setOrder behavior * The LanguageID can optionally be used to change the language of the receiving app * * @export * @interface IClientAppSetUserPayload * @extends {IClientAppMessagePayload} */ export interface IClientAppSetUserPayload extends IClientAppMessagePayload { Action: 'setUser'; Data: { UserToken: string; OrderID?: number; LanguageID?: string; }; } /** * A generic text message payload which can be used for chat or notifications * * @export * @interface IClientAppNotificationPayload * @extends {IClientAppMessagePayload} */ export interface IClientAppNotificationPayload extends IClientAppMessagePayload { Action: 'notification'; Data: { Message: string; }; } /** * This message is used to transfer orders between EVA applications. * The payload for this message starts with a call to EVA.Core.GenerateSessionBarcode. * The app that is offering the order to another app joins a channel with the response barcode. * where the token comes from the GenerateSessionBarcode response. * This barcode is presented to another app who will join the same channel. * When the received app successfully makes the order its current order it can * send this message to signal success (ACCEPTED) or failure (DECLINED). * The sender can then send the RELEASED message as a final cleanup. * Apps should leave the transfer channel when this exchange has completed. * * @export * @interface IClientAppTransferOrderPayload * @extends {IClientAppMessagePayload} */ export interface IClientAppTransferOrderPayload extends IClientAppMessagePayload { Action: 'transferOrder'; Data: { OrderID: number; UserID: number; Token: string; Status: 'AVAILABLE' | 'ACCEPTED' | 'DECLINED' | 'RELEASED'; }; } /** * This message is used to send a barcode scan event to another application. * Can be used to use another application as a remote barcode scanner. * * @export * @interface IClientAppScanBarcodePayload * @extends {IClientAppMessagePayload} */ export interface IClientAppScanBarcodePayload extends IClientAppMessagePayload { Action: 'scanBarcode'; Data: { Barcode: string; }; } /** * The order update payload for the CFD to display * * @export * @interface IClientAppCFDOrderUpdatePayload * @extends {IClientAppMessagePayload} */ export interface IClientAppCFDOrderUpdatePayload extends IClientAppMessagePayload { Action: 'cfd:orderUpdate'; Data: { /** * The current order details * * @type {EVA.Core.OrderDto} */ Order: EVA.Core.OrderDto; /** * The current order amounts data: (sub)totals, discounts, taxes, etc * * @type {EVA.Core.OpenOrderAmounts} */ Amounts: EVA.Core.OpenOrderAmounts; /** * The details of the payment that was started or finished * * @type {{ * Method: string; * ChangeAmount?: number; * Success?: boolean; * Status?: 'started'|'stopped'|'completed'; * }} */ Payment?: { Method: string; ChangeAmount?: number; Success?: boolean; Status?: 'started' | 'stopped' | 'completed'; }; /** * Potential discount details for display purposes. Always sent if available * * @type {EVA.Core.PrefigureDiscountsResponse} */ PrefigureDiscounts?: EVA.Core.PrefigureDiscountsResponse; /** * Potential discount products for display purposes. Always sent if available * * @type {EVA.Core.GetProductsResponse} */ DiscountProducts?: EVA.Core.GetProductsResponse; /** * Potential gift product choices for display purposes. Always sent if available * * @type {EVA.Core.GetPickProductDiscountOptionsForOrderResponse} */ PickProductDiscountsForOrder?: EVA.Core.GetPickProductDiscountOptionsForOrderResponse; /** * The status of the checkout in the POS. Defaults to 'stopped' * * @type {('started'|'stopped'|'completed')} */ CheckoutStatus: 'started' | 'stopped' | 'completed'; /** * Optional additional content * * @type {{ * QrCode?: string; * QrTitle?: string; * }} */ AdditionalContent?: { QrCode?: string; QrTitle?: string; QrSubTitle?: string; }; }; } /** * The pick discount production selection response from CFD to POS * * @export * @interface IClientAppCFDPickDiscountProductResponsePayload * @extends {IClientAppMessagePayload} */ export interface IClientAppCFDPickDiscountProductResponsePayload extends IClientAppMessagePayload { Action: 'cfd:pickDiscountProductResponse'; Data: EVA.Core.SetPickProductDiscountOptionsForOrderLine; } /** * The user details confirmation feedback event payload. * User will be presented their details and an opt-in for the newsletter to confirm * * @export * @interface IConfirmUserDetails */ export interface IConfirmUserDetails { /** * A UUID v4 to identify which user details confirm request answer is received * * @type {string} */ RequestID: string; /** * The identifier of the user * * @type {number} */ UserID: number; /** * The email address of the user * * @type {string} */ Email: string; /** * The phone number of the user * * @type {string} */ PhoneNumber?: string; /** * Optional opt-in choice for a newsletter subscription * * @type {boolean} */ SubscribeToNewsletter: boolean; /** * Can be used to indicate the user cancelled the details confirm * * @type {boolean} */ Cancelled?: boolean; } /** * The user details confirmation request payload from POS to CFD * * @export * @interface IClientAppCFDConfirmUserDetailsPayload * @extends {IClientAppMessagePayload} */ export interface IClientAppCFDConfirmUserDetailsPayload extends IClientAppMessagePayload { Action: 'cfd:confirmUserDetails'; Data: IConfirmUserDetails; } /** * The user details confirmation response payload from CFD to POS * * @export * @interface IClientAppCFDConfirmUserDetailsResponsePayload * @extends {IClientAppMessagePayload} */ export interface IClientAppCFDConfirmUserDetailsResponsePayload extends IClientAppMessagePayload { Action: 'cfd:confirmUserDetailsResponse'; Data: IConfirmUserDetails; } /** * A message to indicate the CFD can go idle * * @export * @interface IClientAppCFDIdlePayload * @extends {IClientAppMessagePayload} */ export interface IClientAppCFDIdlePayload extends IClientAppMessagePayload { Action: 'cfd:idle'; } /** * A user form button * * @export * @interface ICFDUserFormButton */ export interface ICFDUserFormButton { title: string; action: string; role?: string; } export declare type TCFDUserFormFieldType = 'text' | 'email' | 'number' | 'date' | 'address' | 'enum' | 'boolean' | 'phone' | 'signature'; /** * A field for a user form * * @export * @interface ICFDUserFormField */ export interface ICFDUserFormField { addressRequirements?: { countryId: string; requirements: EVA.Core.GetAddressRequirementsResponse['AddressRequirements']; }; description?: string; disabled?: boolean; enumOptions?: { key: string; value: string; }[]; id: string; isArray?: boolean; maxLength?: number; minLength?: number; placeholder?: string; remarks?: string; required?: boolean; sectionData?: { id: number; name: string; }; title: string; type: TCFDUserFormFieldType; valid?: boolean; validationDetailsMessage?: { maxLength?: string; minLength?: string; addressFields?: { [key: string]: string; }; }; validationMessage?: string; value?: string | number | boolean | EVA.Core.AddressDataDto | string[]; } /** * A user form * * @export * @interface ICFDUserForm */ export interface ICFDUserForm { title: string; fields: ICFDUserFormField[]; buttons: ICFDUserFormButton[]; /** * The user form type indicates the purpose of the form and may * trigger specific views in the CFD * * - onboarding: 1st time customer signup * - orderUser: customer initiated (on CFD) sign up * - email: request an email address for customer lookup * - signature: get a signature from the customer * * email form expects at least one field of type email * signature form expects at least one field of type signature * * @type {('onboarding'|'orderUser'|'email'|'signature')} */ type: 'onboarding' | 'orderUser' | 'email' | 'signature'; content?: { qrCode?: string; }; } /** * A user form request message * * @export * @interface IClientAppCFDUserFormPayload * @extends {IClientAppMessagePayload} */ export interface IClientAppCFDUserFormPayload extends IClientAppMessagePayload { Action: 'cfd:userForm'; Data: { form: ICFDUserForm; }; } /** * A user form response message * * @export * @interface IClientAppCFDUserFormResponsePayload * @extends {IClientAppMessagePayload} */ export interface IClientAppCFDUserFormResponsePayload extends IClientAppMessagePayload { Action: 'cfd:userFormResponse'; Data: { form: ICFDUserForm; buttonAction: string; }; } /** * A message received from another client (application) on a channel * * @export * @interface IHubEventClientAppMessage */ export interface IHubEventClientAppMessage { /** The channel the message was sent to */ ChannelID: string; /** Message data */ Message: IClientAppMessagePayload; /** The client app that sent the message */ App: IClientApp; } /** * A client registration event response * * @export * @interface IHubEventClientAppRegistered */ export interface IHubEventClientAppRegistered { App: IClientApp; } /** * A client unregister event response * * @export * @interface IHubEventClientAppUnregistered */ export interface IHubEventClientAppUnregistered { App: IClientApp; } /** * A join channel event response * * @export * @interface IHubEventJoinedChannelMessage */ export interface IHubEventJoinedChannelMessage { App: IClientApp; ChannelID: string; } /** * A leave channel event response * * @export * @interface IHubEventLeftChannelMessage */ export interface IHubEventLeftChannelMessage { App: IClientApp; ChannelID: string; Disconnected?: boolean; } export declare type TClientAppStatus = 'disconnected' | 'connected' | 'active' | 'idle'; /** * A request for a specific client to send its current status * * @export * @interface IClientAppClientPingPayload * @extends {IClientAppMessagePayload} */ export interface IClientAppClientPingPayload extends IClientAppMessagePayload { Action: 'client:ping'; Data: { UUID: string; }; } /** * The client status payload sent when other clients join a channel or when requested * with a ping * * @export * @interface IClientAppClientStatusPayload * @extends {IClientAppMessagePayload} */ export interface IClientAppClientStatusPayload extends IClientAppMessagePayload { Action: 'client:status'; Data: { Channels: string[]; Peers: { [UUID: string]: Date; }; Status: TClientAppStatus; }; }