@shopfront/bridge 3.0.1 → 3.0.2

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/lib/index.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../src/Common/EventEmitter.ts","../src/Utilities/ActionEventRegistrar.ts","../src/Utilities/Static.ts","../src/Actions/BaseAction.ts","../src/Actions/Button.ts","../src/Actions/Dialog.ts","../src/Actions/Redirect.ts","../src/Actions/SaleKey.ts","../src/Actions/Toast.ts","../src/APIs/Sale/BaseSale.ts","../src/APIs/Sale/Exceptions.ts","../src/APIs/Sale/SaleCustomer.ts","../src/Utilities/UUID.ts","../src/APIs/Sale/SalePayment.ts","../src/APIs/Sale/SaleProduct.ts","../src/APIs/Sale/Sale.ts","../src/EmitableEvents/BaseEmitableEvent.ts","../src/EmitableEvents/InternalMessage.ts","../src/APIs/InternalMessages/InternalMessageSource.ts","../src/BaseBridge.ts","../src/Events/BaseEvent.ts","../src/Events/AudioPermissionChange.ts","../src/Events/AudioReady.ts","../src/Events/DirectEvents/BaseDirectEvent.ts","../src/Events/DirectEvents/SaleAddCustomer.ts","../src/Events/DirectEvents/SaleAddProduct.ts","../src/Events/DirectEvents/SaleChangeQuantity.ts","../src/Events/DirectEvents/SaleClear.ts","../src/Events/DirectEvents/SaleRemoveCustomer.ts","../src/Events/DirectEvents/SaleRemoveProduct.ts","../src/Events/DirectEvents/SaleUpdateProducts.ts","../src/Events/FormatIntegratedProduct.ts","../src/Events/FulfilmentCollectOrder.ts","../src/Events/FulfilmentCompleteOrder.ts","../src/Events/FulfilmentGetOrder.ts","../src/Events/FulfilmentOrderApproval.ts","../src/Events/FulfilmentProcessOrder.ts","../src/Events/FulfilmentVoidOrder.ts","../src/Events/GiftCardCodeCheck.ts","../src/Events/InternalPageMessage.ts","../src/Events/PaymentMethodsEnabled.ts","../src/Events/Ready.ts","../src/Events/RegisterChanged.ts","../src/Events/RequestButtons.ts","../src/Actions/CustomerListOption.ts","../src/Events/RequestCustomerListOptions.ts","../src/Events/RequestSaleKeys.ts","../src/Events/RequestSellScreenOptions.ts","../src/Events/RequestSettings.ts","../src/Events/RequestTableColumns.ts","../src/Events/SaleComplete.ts","../src/Bridge.ts","../src/Events/UIPipeline.ts","../src/ApplicationEvents.ts","../src/APIs/Database/BaseDatabase.ts","../src/APIs/Database/Database.ts","../src/Actions/SaleUpdate.ts","../src/APIs/Sale/BaseCurrentSale.ts","../src/APIs/Sale/CurrentSale.ts","../src/BaseApplication.ts","../src/Utilities/SaleCreate.ts","../src/Application.ts","../src/EmitableEvents/Fulfilment/Options.ts","../src/EmitableEvents/Fulfilment/OrderCancel.ts","../src/EmitableEvents/Fulfilment/OrderCreate.ts","../src/EmitableEvents/Fulfilment/OrdersSync.ts","../src/EmitableEvents/Fulfilment/OrderUpdate.ts","../src/EmitableEvents/Fulfilment/RegisterIntent.ts","../src/EmitableEvents/SellScreenOption.ts","../src/EmitableEvents/SellScreenPromotionApplicable.ts","../src/EmitableEvents/TableUpdate.ts","../src/Mocks/APIs/Sale/MockCurrentSale.ts","../src/Mocks/MockBridge.ts","../src/Mocks/Database/MockDatabase.ts","../src/Mocks/MockApplication.ts","../src/Mocks/index.ts"],"sourcesContent":["import { type MaybePromise } from \"../Utilities/MiscTypes.js\";\n\nexport class EventEmitter {\n protected supportedEvents: Array<string> = [];\n private listeners: Record<string, Array<(...args: Array<unknown>) => MaybePromise<unknown>>> = {};\n\n /**\n * Registers an event listener\n */\n public addEventListener(event: string, callback: (...args: Array<unknown>) => MaybePromise<unknown>): void {\n if(!this.supportedEvents.includes(event)) {\n throw new TypeError(`${event} is not a supported event`);\n }\n\n if(typeof this.listeners[event] === \"undefined\") {\n this.listeners[event] = [];\n }\n\n this.listeners[event].push(callback);\n }\n\n /**\n * Removes an event listener\n */\n public removeEventListener(event: string, callback: (...args: Array<unknown>) => MaybePromise<unknown>): void {\n if(!this.supportedEvents.includes(event)) {\n throw new TypeError(`${event} is not a supported event`);\n }\n\n if(typeof this.listeners[event] === \"undefined\") {\n return;\n }\n\n const index = this.listeners[event].indexOf(callback);\n\n if(index === -1) {\n return;\n }\n\n this.listeners[event] = [\n ...this.listeners[event].slice(0, index),\n ...this.listeners[event].slice(index + 1),\n ];\n }\n\n /**\n * Invokes all callbacks listening to the event\n */\n protected async emit(event: string, ...args: Array<unknown>): Promise<Array<unknown>> {\n if(typeof this.listeners[event] === \"undefined\") {\n return Promise.resolve([]);\n }\n\n const events: Array<MaybePromise<unknown>> = [];\n\n for(let i = 0, l = this.listeners[event].length; i < l; i++) {\n events.push(this.listeners[event][i](...args));\n }\n\n return Promise.all(events);\n }\n}\n","import { BaseAction } from \"../Actions/BaseAction.js\";\n\nclass ActionEventRegistrar {\n private events: Record<string, BaseAction<undefined>>;\n\n constructor() {\n this.events = {};\n }\n\n /**\n * Registers an event action listener\n */\n public add(id: string, action: BaseAction<undefined>): void {\n this.events[id] = action;\n }\n\n /**\n * Removes an event action listener\n */\n public remove(id: string) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete this.events[id];\n }\n\n /**\n * Invokes the registered action event listener\n */\n public fire(id: string, data: unknown) {\n if(typeof this.events[id] === \"undefined\") {\n // The event must have stopped listening\n return;\n }\n\n this.events[id].handleRegistrarEvent(id, data);\n }\n\n /**\n * Clears all registered listeners\n */\n public clear() {\n this.events = {};\n }\n}\n\nexport default new ActionEventRegistrar();\n","/**\n * A decorator function that enforces static interface implementation for a class at compile time.\n */\nexport function staticImplements<T>() {\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n return (constructor: T): void => {};\n}\n","import { EventEmitter } from \"../Common/EventEmitter.js\";\nimport type { Serializable, SerializableStatic, Serialized } from \"../Common/Serializable.js\";\nimport ActionEventRegistrar from \"../Utilities/ActionEventRegistrar.js\";\nimport { staticImplements } from \"../Utilities/Static.js\";\n\ninterface BaseActionConstructor<T> {\n new(...args: Array<never>): BaseAction<T>;\n new(serialized: Serialized<T>): BaseAction<T>;\n}\n\n@staticImplements<SerializableStatic>()\nexport class BaseAction<T> extends EventEmitter {\n protected target: string;\n protected events: Array<{\n callback: (...args: Array<unknown>) => void; type: string; id: string;\n }>;\n protected properties: Array<unknown>;\n\n public static serializedRegistry: Record<string, BaseActionConstructor<unknown>> = {};\n\n constructor(serialized: Serialized<T>, type: BaseActionConstructor<T>) {\n if(new.target === BaseAction) {\n throw new TypeError(\"You cannot construct BaseAction instances directly\");\n }\n\n super();\n\n this.target = serialized.type;\n this.events = [];\n this.properties = serialized.properties;\n\n // Ensure that we are registered in the registry\n BaseAction.serializedRegistry[this.target] = type;\n }\n\n /**\n * Serializes the registered action event data (excluding callbacks) and properties\n */\n public serialize(): Serialized<T> {\n const events: Record<string, Array<string>> = {};\n\n for(let i = 0, l = this.events.length; i < l; i++) {\n if(typeof events[this.events[i].type] === \"undefined\") {\n events[this.events[i].type] = [];\n }\n\n events[this.events[i].type].push(this.events[i].id);\n }\n\n return {\n properties: this.serializeProperties(this.properties),\n events : events,\n type : this.target,\n };\n }\n\n /**\n * Recursively serializes the action properties\n */\n protected serializeProperties(properties: Array<unknown>): Array<unknown> {\n const results: Array<unknown> = [];\n\n // Loop through current layer of properties\n for(let i = 0, l = properties.length; i < l; i++) {\n const property = properties[i];\n\n if(Array.isArray(property)) {\n // Prepare to recurse through next layer of properties\n results.push(this.serializeProperties(property));\n } else if(property instanceof BaseAction) {\n // Serialize property\n results.push(property.serialize());\n } else {\n // Assume that the property is already serializable\n results.push(property);\n }\n }\n\n return results;\n }\n\n /**\n * Deserializes the action data\n */\n public static deserialize<T extends Serializable<T>>(serialized: Serialized<T>): T {\n return new BaseAction.serializedRegistry[serialized.type](serialized) as unknown as T;\n }\n\n /**\n * Registers an action event listener\n */\n public addEventListener(event: string, callback: (...args: Array<unknown>) => void): void {\n super.addEventListener(event, callback);\n\n const id = `${Date.now()}-${event}-${Math.random()}`;\n\n ActionEventRegistrar.add(id, this);\n\n this.events.push({\n id,\n callback,\n type: event,\n });\n }\n\n /**\n * Unregisters an action event listener\n */\n public removeEventListener(event: string, callback: (...args: Array<unknown>) => void): void {\n super.removeEventListener(event, callback);\n\n for(let i = 0, l = this.events.length; i < l; i++) {\n if(this.events[i].type !== event) {\n continue;\n }\n\n if(this.events[i].callback !== callback) {\n continue;\n }\n\n const id = this.events[i].id;\n\n ActionEventRegistrar.remove(id);\n\n this.events = [\n ...this.events.slice(0, i),\n ...this.events.slice(i + 1),\n ];\n\n break;\n }\n }\n\n /**\n * Fires the callback for the registered action event\n */\n public handleRegistrarEvent(id: string, data: unknown): void {\n for(let i = 0, l = this.events.length; i < l; i++) {\n if(this.events[i].id !== id) {\n continue;\n }\n\n this.events[i].callback(data);\n\n break;\n }\n }\n}\n","import type { Serialized } from \"../Common/Serializable.js\";\nimport { BaseAction } from \"./BaseAction.js\";\n\nexport class Button extends BaseAction<Button> {\n protected supportedEvents = [ \"click\" ];\n\n protected label: string;\n protected icon: string;\n\n constructor(label: Serialized<Button> | string, icon?: string) {\n // https://github.com/Microsoft/TypeScript/issues/8277\n super((() => {\n if(typeof label === \"string\") {\n return {\n properties: [ label, icon ],\n events : {},\n type : \"Button\",\n };\n } else {\n return label;\n }\n })(), Button);\n\n if(typeof icon === \"undefined\" && typeof label !== \"string\") {\n this.label = label.properties[0] as string;\n this.icon = label.properties[1] as string;\n } else {\n this.label = label as string;\n\n if(typeof icon === \"undefined\") {\n this.icon = \"\";\n } else {\n this.icon = icon;\n }\n }\n }\n}\n","import type { Serialized } from \"../Common/Serializable.js\";\nimport { BaseAction } from \"./BaseAction.js\";\nimport { Button } from \"./Button.js\";\n\ntype DialogType = \"success\" | \"information\" | \"question\" | \"danger\" | \"warning\" | \"error\" | \"edit\" | \"frame\";\n\nexport class Dialog extends BaseAction<Dialog> {\n protected supportedEvents = [ \"close\" ];\n\n protected type: DialogType;\n protected closeable: boolean;\n protected header: string;\n protected content: string;\n protected buttons: Array<Button>;\n\n constructor(\n type: Serialized<Dialog> | DialogType,\n closeable?: boolean,\n header?: string,\n content?: string,\n buttons?: Array<Button>\n ) {\n // https://github.com/Microsoft/TypeScript/issues/8277\n super((() => {\n if(typeof type === \"string\") {\n return {\n properties: [ type, closeable, header, content, buttons ],\n events : {},\n type : \"Dialog\",\n };\n } else {\n return type;\n }\n })(), Dialog);\n\n if(typeof header === \"undefined\") {\n type = type as Serialized<Dialog>;\n this.type = type.properties[0] as DialogType;\n this.closeable = type.properties[1] as boolean;\n this.header = type.properties[2] as string;\n this.content = type.properties[3] as string;\n this.buttons = type.properties[4] as Array<Button>; // Note: This should be deserialized\n } else {\n this.type = type as DialogType;\n this.closeable = closeable as boolean;\n this.header = header as string;\n this.content = content as string;\n this.buttons = buttons as Array<Button>;\n }\n }\n}\n","import type { Serialized } from \"../Common/Serializable.js\";\nimport { BaseAction } from \"./BaseAction.js\";\n\nclass InternalRedirect extends BaseAction<InternalRedirect> {\n protected supportedEvents = [ \"click\" ];\n\n protected to: string;\n\n constructor(to: Serialized<InternalRedirect> | string) {\n // https://github.com/Microsoft/TypeScript/issues/8277\n super((() => {\n if(typeof to === \"string\") {\n return {\n properties: [ to ],\n events : {},\n type : \"InternalRedirect\",\n };\n } else {\n return to;\n }\n })(), InternalRedirect);\n\n if(typeof to !== \"string\") {\n this.to = to.properties[0] as string;\n } else {\n this.to = to;\n }\n }\n}\n\nclass ExternalRedirect extends BaseAction<ExternalRedirect> {\n protected supportedEvents = [ \"click\" ];\n\n protected to: URL;\n\n constructor(to: Serialized<ExternalRedirect> | URL) {\n // https://github.com/Microsoft/TypeScript/issues/8277\n super((() => {\n if(to instanceof URL) {\n return {\n properties: [ to.href ],\n events : {},\n type : \"ExternalRedirect\",\n };\n } else {\n return to;\n }\n })(), ExternalRedirect);\n\n if(to instanceof URL) {\n this.to = to;\n } else {\n this.to = new URL(to.properties[0] as string);\n }\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const Redirect = {\n InternalRedirect,\n ExternalRedirect,\n};\n","import type { Serialized } from \"../Common/Serializable.js\";\nimport { BaseAction } from \"./BaseAction.js\";\n\nexport class SaleKey extends BaseAction<SaleKey> {\n protected supportedEvents = [ \"click\" ];\n\n protected id: string;\n protected name: string;\n\n constructor(id: Serialized<SaleKey> | string, name?: string) {\n // https://github.com/Microsoft/TypeScript/issues/8277\n super((() => {\n if(typeof id === \"string\") {\n return {\n properties: [ id, name ],\n events : {},\n type : \"Button\",\n };\n } else {\n return id;\n }\n })(), SaleKey);\n\n if(typeof name === \"undefined\" && typeof id !== \"string\") {\n this.id = id.properties[0] as string;\n this.name = id.properties[1] as string;\n } else {\n this.id = id as string;\n\n if(typeof name === \"undefined\") {\n this.name = \"\";\n } else {\n this.name = name;\n }\n }\n }\n}\n","import type { Serialized } from \"../Common/Serializable.js\";\nimport { BaseAction } from \"./BaseAction.js\";\n\nexport type ToastType = \"success\" | \"error\" | \"information\" | \"warning\";\n\nexport class Toast extends BaseAction<Toast> {\n protected supportedEvents = [ \"hide\" ];\n\n protected type: ToastType;\n protected message: string;\n\n constructor(type: Serialized<Toast> | ToastType, message?: string) {\n // https://github.com/Microsoft/TypeScript/issues/8277\n super((() => {\n if(typeof type === \"string\") {\n return {\n properties: [ type, message ],\n events : {},\n type : \"Toast\",\n };\n } else {\n return type;\n }\n })(), Toast);\n\n if(typeof message === \"undefined\") {\n type = type as Serialized<Toast>;\n this.type = type.properties[0] as ToastType;\n this.message = type.properties[1] as string;\n } else {\n this.type = type as ToastType;\n this.message = message;\n }\n }\n}\n","import type { SaleCustomer } from \"./SaleCustomer.js\";\nimport type { SalePayment } from \"./SalePayment.js\";\nimport type { SaleProduct } from \"./SaleProduct.js\";\n\nexport interface BaseSaleData {\n register: string | undefined;\n clientId: string | undefined;\n notes: {\n internal: string;\n sale: string;\n };\n totals: {\n sale: number;\n paid: number;\n savings: number;\n discount: number;\n };\n linkedTo: string;\n orderReference: string;\n refundReason: string;\n priceSet: string | null;\n metaData: Record<string, unknown>;\n}\n\nexport interface SaleData extends BaseSaleData {\n customer: null | SaleCustomer;\n payments: Array<SalePayment>;\n products: Array<SaleProduct>;\n}\n\nexport abstract class BaseSale {\n protected sale: BaseSaleData;\n protected customer: null | SaleCustomer;\n protected payments: Array<SalePayment>;\n protected products: Array<SaleProduct>;\n\n protected constructor({ customer, payments, products, ...sale }: SaleData) {\n this.sale = sale;\n this.customer = customer;\n this.payments = payments;\n this.products = products;\n }\n\n /**\n * Updates the sale data to be inline with the new sale\n */\n protected hydrate(sale: BaseSale): void {\n this.sale = sale.sale;\n this.customer = sale.customer;\n this.payments = sale.payments;\n this.products = sale.products;\n }\n\n /**\n * Get the products that are currently on the sale.\n */\n public getProducts(): Array<SaleProduct> {\n return this.products;\n }\n\n /**\n * Get the payments that are currently on the sale.\n */\n public getPayments(): Array<SalePayment> {\n return this.payments;\n }\n\n /**\n * Get the current customer on the sale.\n */\n public getCustomer(): null | SaleCustomer {\n return this.customer;\n }\n\n /**\n * Get the register.\n */\n public getRegister(): string | undefined {\n return this.sale.register;\n }\n\n /**\n * Get the client id.\n */\n public getClientId(): string | undefined {\n return this.sale.clientId;\n }\n\n /**\n * Get the current sale total on the sale.\n */\n public getSaleTotal(): number {\n return this.sale.totals.sale;\n }\n\n /**\n * Get the current paid total on the sale.\n */\n public getPaidTotal(): number {\n return this.sale.totals.paid;\n }\n\n /**\n * Get the current savings total on the sale.\n */\n public getSavingsTotal(): number {\n return this.sale.totals.savings;\n }\n\n /**\n * Get the current discount total on the sale.\n */\n public getDiscountTotal(): number {\n return this.sale.totals.discount;\n }\n\n /**\n * Get the linked to value on the sale.\n */\n public getLinkedTo(): string {\n return this.sale.linkedTo;\n }\n\n /**\n * Get the refund reason on the sale.\n */\n public getRefundReason(): string {\n return this.sale.refundReason;\n }\n\n /**\n * Get the price set on the sale.\n */\n public getPriceSet(): string | null {\n return this.sale.priceSet;\n }\n\n /**\n * Get the external sale note (visible to the customer).\n */\n public getExternalNote(): string {\n return this.sale.notes.sale;\n }\n\n /**\n * Get the internal sale note.\n */\n public getInternalNote(): string {\n return this.sale.notes.internal;\n }\n\n /**\n * Get the order reference (visible to the customer).\n */\n public getOrderReference(): string {\n return this.sale.orderReference;\n }\n\n /**\n * Get the current meta data for the sale\n */\n public getMetaData(): Record<string, unknown> {\n return this.sale.metaData;\n }\n\n public abstract addProduct(product: SaleProduct): Promise<void>;\n public abstract removeProduct(product: SaleProduct): Promise<void>;\n public abstract addPayment(payment: SalePayment): Promise<void>;\n public abstract addCustomer(customer: SaleCustomer): Promise<void>;\n public abstract removeCustomer(): Promise<void>;\n public abstract setExternalNote(note: string, append?: boolean): Promise<void>;\n public abstract setInternalNote(note: string, append?: boolean): Promise<void>;\n public abstract setOrderReference(reference: string): Promise<void>;\n public abstract setMetaData(metaData: Record<string, unknown>): Promise<void>;\n public abstract updateProduct(product: SaleProduct): Promise<void>;\n}\n","export class SaleCancelledError extends Error {\n constructor() {\n super(\"The sale is no longer active.\");\n }\n}\n\nexport class InvalidSaleDeviceError extends Error {\n constructor() {\n super(\"This device is no longer a register able to perform a sale.\");\n }\n}\n\nexport class ProductNotExistsError extends Error {\n constructor() {\n super(\"Product does not exist in the sale\");\n }\n}\n","export class SaleCustomer {\n protected id: string;\n\n constructor(id: string) {\n this.id = id;\n }\n\n /**\n * Get the ID of the customer.\n */\n public getId(): string {\n return this.id;\n }\n}\n","/**\n * Fast UUID generator, RFC4122 version 4 compliant.\n * @author Jeff Ward (jcward.com).\n * @license MIT\n * {@link http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/21963136#21963136}\n */\nexport default class UUID {\n protected lut: Array<string>;\n\n constructor() {\n this.lut = [];\n\n for(let i = 0; i < 256; i++) {\n this.lut[i] = (i < 16 ? \"0\" : \"\") + (i).toString(16);\n }\n\n this.generate = this.generate.bind(this);\n }\n\n /**\n * Generates a UUID\n */\n public generate(): string {\n const d0 = Math.random() * 0xffffffff | 0;\n const d1 = Math.random() * 0xffffffff | 0;\n const d2 = Math.random() * 0xffffffff | 0;\n const d3 = Math.random() * 0xffffffff | 0;\n\n return this.lut[d0 & 0xff] +\n this.lut[d0 >> 8 & 0xff] +\n this.lut[d0 >> 16 & 0xff] +\n this.lut[d0 >> 24 & 0xff] + \"-\" +\n this.lut[d1 & 0xff] +\n this.lut[d1 >> 8 & 0xff] + \"-\" +\n this.lut[d1 >> 16 & 0x0f | 0x40] +\n this.lut[d1 >> 24 & 0xff] + \"-\" +\n this.lut[d2 & 0x3f | 0x80] +\n this.lut[d2 >> 8 & 0xff] + \"-\" +\n this.lut[d2 >> 16 & 0xff] +\n this.lut[d2 >> 24 & 0xff] +\n this.lut[d3 & 0xff] +\n this.lut[d3 >> 8 & 0xff] +\n this.lut[d3 >> 16 & 0xff] +\n this.lut[d3 >> 24 & 0xff];\n }\n\n /**\n * Static method for generating a UUID\n */\n public static generate(): string {\n if(typeof self?.crypto?.randomUUID === \"function\") {\n return self.crypto.randomUUID();\n }\n\n return (new UUID()).generate();\n }\n}\n","import UUID from \"../../Utilities/UUID.js\";\nimport { type ShopfrontSalePayment } from \"./ShopfrontSaleState.js\";\n\nexport enum SalePaymentStatus {\n APPROVED = \"completed\",\n DECLINED = \"failed\",\n CANCELLED = \"cancelled\",\n}\n\nexport class SalePayment {\n public readonly internalId: string;\n\n protected id: string;\n protected type?: string;\n protected status?: SalePaymentStatus;\n protected amount: number;\n protected cashout?: number;\n protected rounding?: number;\n protected metaData: Record<string, unknown> = {};\n\n constructor(id: string, amount: number, cashout?: number, status?: SalePaymentStatus) {\n this.internalId = UUID.generate();\n\n this.id = id;\n this.amount = amount;\n this.cashout = cashout;\n this.status = status;\n }\n\n /**\n * Hydrate a sale payment from the SaleState.\n * @internal\n */\n public static HydrateFromState(payment: ShopfrontSalePayment): SalePayment {\n let status = SalePaymentStatus.APPROVED;\n\n switch(payment.status) {\n case \"failed\":\n status = SalePaymentStatus.DECLINED;\n break;\n case \"cancelled\":\n status = SalePaymentStatus.CANCELLED;\n break;\n }\n\n const hydrated = new SalePayment(payment.method, payment.amount, payment.cashout, status);\n\n hydrated.setInternal(payment);\n\n return hydrated;\n }\n\n /**\n * Set the internal data for the payment.\n * This method is for hydration of the payment from Shopfront,\n * it's highly recommend that you DO NOT use this method.\n * @internal\n */\n public setInternal(data: ShopfrontSalePayment): void {\n this.type = data.type;\n this.rounding = data.rounding;\n this.metaData = JSON.parse(data.metadata);\n }\n\n /**\n * Get the ID of the sale payment method.\n */\n public getId(): string {\n return this.id;\n }\n\n /**\n * Get the type of payment method this is.\n */\n public getType(): string | undefined {\n return this.type;\n }\n\n /**\n * Get the status of this payment method.\n */\n public getStatus(): SalePaymentStatus | undefined {\n return this.status;\n }\n\n /**\n * Get the value of this payment method.\n */\n public getAmount(): number {\n return this.amount;\n }\n\n /**\n * Get the cashout amount paid for on this payment method.\n */\n public getCashout(): number | undefined {\n return this.cashout;\n }\n\n /**\n * Get the amount of rounding applied to this payment method.\n */\n public getRounding(): number | undefined {\n return this.rounding;\n }\n\n /**\n * Get the metadata attached to this payment method\n */\n public getMetaData(): Record<string, unknown> {\n return this.metaData;\n }\n}\n","import UUID from \"../../Utilities/UUID.js\";\nimport {\n type ShopfrontSaleProduct,\n type ShopfrontSaleProductPromotions,\n type ShopfrontSaleProductType,\n} from \"./ShopfrontSaleState.js\";\n\nexport class SaleProduct {\n public readonly internalId: string;\n\n protected id: string;\n protected quantity: number;\n protected price?: number;\n protected indexAddress: Array<number>;\n protected name?: string;\n protected type?: ShopfrontSaleProductType;\n protected taxRateAmount?: number;\n protected note: string;\n protected contains: Array<SaleProduct>;\n protected edited: boolean;\n protected caseQuantity?: number;\n protected promotions: ShopfrontSaleProductPromotions = {};\n protected metaData: Record<string, unknown> = {};\n protected mapped?: string;\n protected quantityModified: boolean;\n protected priceModified: boolean;\n protected metaDataModified: boolean;\n\n constructor(id: string, quantity: number, price?: number, indexAddress?: Array<number>) {\n this.internalId = UUID.generate();\n\n this.id = id;\n this.quantity = quantity;\n this.price = price;\n this.indexAddress = indexAddress || [];\n\n this.contains = [];\n this.edited = typeof price !== \"undefined\";\n this.note = \"\";\n\n this.quantityModified = false;\n this.priceModified = false;\n this.metaDataModified = false;\n }\n\n /**\n * Hydrate a sale product from the SaleState.\n * @internal\n */\n public static HydrateFromState(product: ShopfrontSaleProduct, indexAddress: Array<number>): SaleProduct {\n const hydrated = new SaleProduct(product.uuid, product.quantity, product.prices.price, indexAddress);\n\n hydrated.setInternal(product, indexAddress);\n\n return hydrated;\n }\n\n /**\n * Append a product to this product's list of contained products.\n */\n protected appendProduct(product: SaleProduct): void {\n this.contains.push(product);\n }\n\n /**\n * Set the internal data for the product.\n * This method is for hydration of the product from Shopfront,\n * it's highly recommend that you DO NOT use this method.\n * @internal\n */\n public setInternal(data: ShopfrontSaleProduct, indexAddress: Array<number>): void {\n this.name = data.name;\n this.type = data.type;\n this.taxRateAmount = data.tax?.amount || 0;\n this.note = data.note;\n this.edited = data.edited;\n this.caseQuantity = data.caseQuantity;\n this.promotions = data.promotions;\n this.metaData = data.metaData;\n this.mapped = data.mapped;\n\n for(let i = 0, l = data.products.length; i < l; i++) {\n this.appendProduct(SaleProduct.HydrateFromState(data.products[i], [\n ...indexAddress,\n i,\n ]));\n }\n }\n\n /**\n * Get the ID of the product.\n */\n public getId(): string {\n return this.id;\n }\n\n /**\n * Gets the mapped id for the product.\n * Used when the product goes through the fulfilment process mapping\n */\n public getMapped(): string | undefined {\n return this.mapped;\n }\n\n /**\n * Get the current sale quantity of the product.\n */\n public getQuantity(): number {\n return this.quantity;\n }\n\n /**\n * Sets the current sale quantity of the product\n */\n public setQuantity(quantity: number): void {\n this.quantity = quantity;\n this.quantityModified = true;\n }\n\n /**\n * Get the current price of the product.\n */\n public getPrice(): number | undefined {\n return this.price;\n }\n\n /**\n * Sets the current price of the product\n */\n public setPrice(price: number): void {\n this.price = price;\n this.priceModified = true;\n }\n\n /**\n * Get the index address of the product.\n * This is the internal address of where the product is in the sale.\n * (e.g. if the address is [1, 3] it's the fourth contained product in the second sale line).\n */\n public getIndexAddress(): Array<number> {\n return this.indexAddress;\n }\n\n /**\n * Get the name of the product.\n */\n public getName(): string | undefined {\n return this.name;\n }\n\n /**\n * Get the type of product this product is.\n */\n public getType(): ShopfrontSaleProductType | undefined {\n return this.type;\n }\n\n /**\n * Get the tax rate amount.\n * This is the rate of the tax rate (e.g. 10 is a tax rate of 10%).\n */\n public getTaxRateAmount(): number | undefined {\n return this.taxRateAmount;\n }\n\n /**\n * Get the sale note attached to this product.\n */\n public getNote(): string {\n return this.note;\n }\n\n /**\n * Get the products this product contains.\n */\n public getContains(): Array<SaleProduct> {\n return this.contains;\n }\n\n /**\n * Get whether this product has been \"edited\".\n * Typically, being edited just means that this product has been discounted.\n */\n public getEdited(): boolean {\n return this.edited;\n }\n\n /**\n * Get the case quantity for this product.\n */\n public getCaseQuantity(): number | undefined {\n return this.caseQuantity;\n }\n\n /**\n * Get the current active promotions for the product.\n */\n public getPromotions(): ShopfrontSaleProductPromotions {\n return this.promotions;\n }\n\n /**\n * Get the meta-data for the product.\n */\n public getMetaData(): Record<string, unknown> {\n return this.metaData;\n }\n\n /**\n * Set the metaData for a product\n */\n public setMetaData(key: string, value: unknown): void {\n this.metaData[key] = value;\n this.metaDataModified = true;\n }\n\n /**\n * Returns whether the product's quantity was modified externally\n * @internal\n */\n public wasQuantityModified(): boolean {\n return this.quantityModified;\n }\n\n /**\n * Returns whether the product's price was modified externally\n * @internal\n */\n public wasPriceModified(): boolean {\n return this.priceModified;\n }\n\n /**\n * Returns whether the product's metaData was modified externally\n * @internal\n */\n public wasMetaDataModified(): boolean {\n return this.metaDataModified;\n }\n\n /**\n * Sets a product's modification flags to false\n * @internal\n */\n public clearModificationFlags(): void {\n this.quantityModified = false;\n this.priceModified = false;\n this.metaDataModified = false;\n }\n}\n","import type { Application } from \"../../Application.js\";\nimport { BaseSale, type SaleData } from \"./BaseSale.js\";\nimport { SaleCustomer } from \"./SaleCustomer.js\";\nimport { SalePayment } from \"./SalePayment.js\";\nimport { SaleProduct } from \"./SaleProduct.js\";\nimport type { ShopfrontSaleState } from \"./ShopfrontSaleState.js\";\n\nexport class Sale extends BaseSale {\n protected created = false;\n protected creating = false;\n\n constructor(data: SaleData) {\n super(data);\n }\n\n /**\n * Add a customer to the sale\n */\n public async addCustomer(customer: SaleCustomer): Promise<void> {\n this.customer = customer;\n }\n\n /**\n * Add a payment to the sale\n */\n public async addPayment(payment: SalePayment): Promise<void> {\n if(this.payments.find(p => p.internalId === payment.internalId)) {\n throw new TypeError(\"Payment has already been added to sale.\");\n }\n\n this.payments.push(payment);\n }\n\n /**\n * Add a product to the sale\n */\n public async addProduct(product: SaleProduct): Promise<void> {\n if(this.products.find(p => p.internalId === product.internalId)) {\n throw new TypeError(\"Product has already been added to sale.\");\n }\n\n this.products.push(product);\n }\n\n /**\n * Remove the customer from the sale\n */\n public async removeCustomer(): Promise<void> {\n this.customer = null;\n }\n\n /**\n * Remove a product from the sale\n */\n public async removeProduct(product: SaleProduct): Promise<void> {\n const index = this.products.findIndex(p => p.internalId === product.internalId);\n\n if(index === -1) {\n throw new TypeError(\"Product could not be found in the sale.\");\n }\n\n this.products.splice(index, 1);\n }\n\n /**\n * Remove a payment from the sale\n */\n public async removePayment(payment: SalePayment): Promise<void> {\n const index = this.payments.findIndex(p => p.internalId === payment.internalId);\n\n if(index === -1) {\n throw new TypeError(\"Payment could not be found in the sale.\");\n }\n\n this.payments.splice(index, 1);\n }\n\n /**\n * Add / append an external note to the sale\n */\n public async setExternalNote(note: string, append?: boolean): Promise<void> {\n if(append) {\n this.sale.notes.sale += note;\n } else {\n this.sale.notes.sale = note;\n }\n }\n\n /**\n * Add / append an internal note to the sale\n */\n public async setInternalNote(note: string, append?: boolean): Promise<void> {\n if(append) {\n this.sale.notes.internal += note;\n } else {\n this.sale.notes.internal = note;\n }\n }\n\n /**\n * Set the sale's meta-data\n */\n public async setMetaData(metaData: Record<string, unknown>): Promise<void> {\n this.sale.metaData = metaData;\n }\n\n /**\n * Set the sale's order reference\n */\n public async setOrderReference(reference: string): Promise<void> {\n this.sale.orderReference = reference;\n }\n\n /**\n * Update a product in the sale\n */\n public async updateProduct(product: SaleProduct): Promise<void> {\n const index = this.products.findIndex(p => p.internalId === product.internalId);\n\n if(index === -1) {\n throw new TypeError(\"Product could not be found in the sale.\");\n }\n\n this.products[index] = product;\n }\n\n /**\n * Create the sale on the server\n */\n public async create(application: Application): Promise<{\n success: boolean;\n message?: string;\n }> {\n if(this.creating) {\n throw new TypeError(\"Create function is currently running\");\n }\n\n if(this.created) {\n throw new TypeError(\"Sale has already been created\");\n }\n\n this.creating = true;\n\n const results = await application.createSale(this);\n\n if(results.success) {\n this.created = true;\n }\n\n this.creating = false;\n\n return results;\n }\n\n /**\n * Converts the sale state to the sale data\n */\n public static buildSaleData(saleState: ShopfrontSaleState): SaleData {\n return {\n register : saleState.register,\n clientId : saleState.clientId,\n notes : saleState.notes,\n totals : saleState.totals,\n linkedTo : saleState.linkedTo,\n orderReference: saleState.orderReference,\n refundReason : saleState.refundReason,\n priceSet : saleState.priceSet,\n metaData : saleState.metaData,\n customer : saleState.customer ? new SaleCustomer(saleState.customer.uuid) : null,\n payments : saleState.payments.map(SalePayment.HydrateFromState),\n products : saleState.products.map((product, index) => {\n return SaleProduct.HydrateFromState(product, [ index ]);\n }),\n };\n }\n}\n","import { ToShopfront } from \"../ApplicationEvents.js\";\n\nexport class BaseEmitableEvent<T> {\n protected eventName: ToShopfront;\n protected eventData: T;\n\n constructor(shopfrontEventName: ToShopfront, data: T) {\n if(new.target === BaseEmitableEvent) {\n throw new TypeError(\"You cannot construct BaseEmitableEvent instances directly\");\n }\n\n this.eventName = shopfrontEventName;\n this.eventData = data;\n }\n\n /**\n * Returns the event name\n */\n public getEvent(): ToShopfront {\n return this.eventName;\n }\n\n /**\n * Returns the event data\n */\n public getData(): T {\n return this.eventData;\n }\n}\n","import { type InternalPageMessageMethod } from \"../APIs/InternalMessages/InternalMessageSource.js\";\nimport { ToShopfront } from \"../ApplicationEvents.js\";\nimport { BaseEmitableEvent } from \"./BaseEmitableEvent.js\";\n\nexport class InternalMessage<T> extends BaseEmitableEvent<{\n method: InternalPageMessageMethod;\n url: string;\n message: T;\n}> {\n constructor(method: InternalPageMessageMethod, destination: string, message: T) {\n super(ToShopfront.INTERNAL_PAGE_MESSAGE, {\n method,\n url: destination,\n message,\n });\n }\n}\n","import { Application } from \"../../Application.js\";\nimport { type FromShopfront } from \"../../ApplicationEvents.js\";\nimport { InternalMessage } from \"../../EmitableEvents/InternalMessage.js\";\n\nexport type InternalPageMessageMethod = keyof FromShopfront | \"EXTERNAL_APPLICATION\";\n\nexport class InternalMessageSource {\n protected application: Application;\n protected method: InternalPageMessageMethod;\n protected url: string;\n\n constructor(application: Application, method: InternalPageMessageMethod, url: string) {\n this.application = application;\n this.method = method;\n this.url = url;\n }\n\n /**\n * Sends an internal message to Shopfront\n */\n public send(message: unknown): void {\n this.application.send(new InternalMessage(this.method, this.url, message));\n }\n}\n","import * as ApplicationEvents from \"./ApplicationEvents.js\";\n\nexport type ApplicationEventListener = (\n event: keyof ApplicationEvents.FromShopfront | keyof ApplicationEvents.FromShopfrontInternal,\n data: Record<string, unknown>,\n id: string\n) => void;\n\nexport abstract class BaseBridge {\n public key: string;\n public url: URL;\n protected listeners: Array<ApplicationEventListener> = [];\n protected hasListener = false;\n protected target: Window | null = null;\n\n protected constructor(key: string, url: string | null) {\n this.key = key;\n\n if(!url) {\n this.url = new URL(\"communicator://javascript\"); // This isn't used in this scenario\n } else if(url.split(\".\").length === 1) {\n this.url = new URL(`https://${url}.onshopfront.com`);\n } else {\n this.url = new URL(url);\n }\n }\n\n /**\n * Destroys the Bridge by unregistering all listeners\n */\n public abstract destroy(): void;\n\n /**\n * Register the event listener for any window messages\n */\n protected abstract registerListeners(): void;\n\n /**\n * Removes the window message event listener\n */\n protected abstract unregisterListeners(): void;\n\n /**\n * Sends an event to Shopfront\n */\n public abstract sendMessage(type: ApplicationEvents.ToShopfront, data?: unknown, id?: string): void;\n\n /**\n * Adds a listener for a Shopfront event\n */\n public abstract addEventListener(listener: ApplicationEventListener): void;\n\n /**\n * Removes a listener for a Shopfront event\n */\n public abstract removeEventListener(listener: ApplicationEventListener): void;\n}\n","import { BaseBridge } from \"../BaseBridge.js\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype _Infer = any;\n\nexport abstract class BaseEvent<\n TData = _Infer,\n TCallbackReturn = void,\n TEmitReturn = _Infer,\n TCallbackData = TData,\n TCallbackContext = undefined\n> {\n protected callback: (data: TCallbackData, context: TCallbackContext) => TCallbackReturn;\n\n protected constructor(callback: (data: TCallbackData, context: TCallbackContext) => TCallbackReturn) {\n this.callback = callback;\n }\n\n /**\n * Invokes the registered callback\n */\n public abstract emit(data: TData, bridge?: BaseBridge): Promise<TEmitReturn>;\n}\n","import type { AudioPermissionChangeEvent, FromShopfrontCallbacks, FromShopfrontReturns } from \"../ApplicationEvents.js\";\nimport { BaseEvent } from \"./BaseEvent.js\";\n\nexport class AudioPermissionChange extends BaseEvent<AudioPermissionChangeEvent> {\n constructor(callback: FromShopfrontCallbacks[\"AUDIO_PERMISSION_CHANGE\"]) {\n super(callback);\n }\n\n /**\n * @inheritDoc\n */\n public async emit(data: AudioPermissionChangeEvent): Promise<FromShopfrontReturns[\"AUDIO_PERMISSION_CHANGE\"]> {\n return this.callback(data, undefined);\n }\n}\n","import { type FromShopfrontCallbacks, type FromShopfrontReturns } from \"../ApplicationEvents.js\";\nimport { BaseEvent } from \"./BaseEvent.js\";\n\nexport class AudioReady extends BaseEvent<undefined> {\n constructor(callback: FromShopfrontCallbacks[\"AUDIO_READY\"]) {\n super(callback);\n }\n\n /**\n * @inheritDoc\n */\n public async emit(): Promise<FromShopfrontReturns[\"AUDIO_READY\"]> {\n return this.callback(undefined, undefined);\n }\n}\n","import type {\n DirectShopfrontCallbacks,\n DirectShopfrontEvent,\n DirectShopfrontEventData,\n} from \"../../ApplicationEvents.js\";\n\nexport abstract class BaseDirectEvent<\n TEvent extends DirectShopfrontEvent,\n TData = DirectShopfrontEventData[TEvent],\n TCallback = DirectShopfrontCallbacks[TEvent],\n> {\n protected callback: TCallback;\n\n protected constructor(callback: TCallback) {\n this.callback = callback;\n }\n\n /**\n * Ensures the event data is formatted correctly\n */\n protected abstract isEventData(event: unknown): event is TData;\n\n /**\n * Invokes the registered callback\n */\n public abstract emit(event: unknown): Promise<void>;\n}\n","import { type DirectShopfrontCallbacks, type DirectShopfrontEventData } from \"../../ApplicationEvents.js\";\nimport { BaseDirectEvent } from \"./BaseDirectEvent.js\";\n\nexport class SaleAddCustomer extends BaseDirectEvent<\"SALE_ADD_CUSTOMER\"> {\n constructor(callback: DirectShopfrontCallbacks[\"SALE_ADD_CUSTOMER\"]) {\n super(callback);\n }\n\n /**\n * @inheritDoc\n */\n protected isEventData(event: unknown): event is DirectShopfrontEventData[\"SALE_ADD_CUSTOMER\"] {\n if(!event || typeof event !== \"object\") {\n return false;\n }\n\n return \"customer\" in event;\n }\n\n /**\n * @inheritDoc\n */\n public async emit(event: unknown): Promise<void> {\n if(!this.isEventData(event)) {\n return;\n }\n\n return this.callback(event);\n }\n}\n","import { type DirectShopfrontCallbacks, type DirectShopfrontEventData } from \"../../ApplicationEvents.js\";\nimport { BaseDirectEvent } from \"./BaseDirectEvent.js\";\n\nexport class SaleAddProduct extends BaseDirectEvent<\"SALE_ADD_PRODUCT\"> {\n constructor(callback: DirectShopfrontCallbacks[\"SALE_ADD_PRODUCT\"]) {\n super(callback);\n }\n\n /**\n * @inheritDoc\n */\n protected isEventData(event: unknown): event is DirectShopfrontEventData[\"SALE_ADD_PRODUCT\"] {\n if(!event || typeof event !== \"object\") {\n return false;\n }\n\n return \"product\" in event && \"indexAddress\" in event;\n }\n\n /**\n * @inheritDoc\n */\n public async emit(event: unknown): Promise<void> {\n if(!this.isEventData(event)) {\n return;\n }\n\n return this.callback(event);\n }\n}\n","import { type DirectShopfrontCallbacks, type DirectShopfrontEventData } from \"../../ApplicationEvents.js\";\nimport { BaseDirectEvent } from \"./BaseDirectEvent.js\";\n\nexport class SaleChangeQuantity extends BaseDirectEvent<\"SALE_CHANGE_QUANTITY\"> {\n constructor(callback: DirectShopfrontCallbacks[\"SALE_CHANGE_QUANTITY\"]) {\n super(callback);\n }\n\n /**\n * @inheritDoc\n */\n protected isEventData(event: unknown): event is DirectShopfrontEventData[\"SALE_CHANGE_QUANTITY\"] {\n if(!event || typeof event !== \"object\") {\n return false;\n }\n\n return \"indexAddress\" in event && \"amount\" in event && \"absolute\" in event;\n }\n\n /**\n * @inheritDoc\n */\n public async emit(event: unknown): Promise<void> {\n if(!this.isEventData(event)) {\n return;\n }\n\n return this.callback(event);\n }\n}\n","import { type DirectShopfrontCallbacks, type DirectShopfrontEventData } from \"../../ApplicationEvents.js\";\nimport { BaseDirectEvent } from \"./BaseDirectEvent.js\";\n\nexport class SaleClear extends BaseDirectEvent<\"SALE_CLEAR\"> {\n constructor(callback: DirectShopfrontCallbacks[\"SALE_CLEAR\"]) {\n super(callback);\n }\n\n /**\n * @inheritDoc\n */\n protected isEventData(event: unknown): event is DirectShopfrontEventData[\"SALE_CLEAR\"] {\n return true;\n }\n\n /**\n * @inheritDoc\n */\n public async emit(event: unknown): Promise<void> {\n if(!this.isEventData(event)) {\n return;\n }\n\n return this.callback();\n }\n}\n","import { type DirectShopfrontCallbacks, type DirectShopfrontEventData } from \"../../ApplicationEvents.js\";\nimport { BaseDirectEvent } from \"./BaseDirectEvent.js\";\n\nexport class SaleRemoveCustomer extends BaseDirectEvent<\"SALE_REMOVE_CUSTOMER\"> {\n constructor(callback: DirectShopfrontCallbacks[\"SALE_REMOVE_CUSTOMER\"]) {\n super(callback);\n }\n\n /**\n * @inheritDoc\n */\n protected isEventData(event: unknown): event is DirectShopfrontEventData[\"SALE_REMOVE_CUSTOMER\"] {\n return true;\n }\n\n /**\n * @inheritDoc\n */\n public async emit(event: unknown): Promise<void> {\n if(!this.isEventData(event)) {\n return;\n }\n\n return this.callback();\n }\n}\n","import { type DirectShopfrontCallbacks, type DirectShopfrontEventData } from \"../../ApplicationEvents.js\";\nimport { BaseDirectEvent } from \"./BaseDirectEvent.js\";\n\nexport class SaleRemoveProduct extends BaseDirectEvent<\"SALE_REMOVE_PRODUCT\"> {\n constructor(callback: DirectShopfrontCallbacks[\"SALE_REMOVE_PRODUCT\"]) {\n super(callback);\n }\n\n /**\n * @inheritDoc\n */\n protected isEventData(event: unknown): event is DirectShopfrontEventData[\"SALE_REMOVE_PRODUCT\"] {\n if(!event || typeof event !== \"object\") {\n return false;\n }\n\n return \"indexAddress\" in event;\n }\n\n /**\n * @inheritDoc\n */\n public async emit(event: unknown): Promise<void> {\n if(!this.isEventData(event)) {\n return;\n }\n\n return this.callback(event);\n }\n}\n","import { type DirectShopfrontCallbacks, type DirectShopfrontEventData } from \"../../ApplicationEvents.js\";\nimport { BaseDirectEvent } from \"./BaseDirectEvent.js\";\n\nexport class SaleUpdateProducts extends BaseDirectEvent<\"SALE_UPDATE_PRODUCTS\"> {\n constructor(callback: DirectShopfrontCallbacks[\"SALE_UPDATE_PRODUCTS\"]) {\n super(callback);\n }\n\n /**\n * @inheritDoc\n */\n protected isEventData(event: unknown): event is DirectShopfrontEventData[\"SALE_UPDATE_PRODUCTS\"] {\n if(!event || typeof event !== \"object\") {\n return false;\n }\n\n return \"products\" in event;\n }\n\n /**\n * @inheritDoc\n */\n public async emit(event: unknown): Promise<void> {\n if(!this.isEventData(event)) {\n return;\n }\n\n return this.callback(event);\n }\n}\n","import {\n type FromShopfrontCallbacks,\n type FromShopfrontReturns,\n ToShopfront,\n} from \"../ApplicationEvents.js\";\nimport { BaseBridge } from \"../BaseBridge.js\";\nimport { type MaybePromise } from \"../Utilities/MiscTypes.js\";\nimport { BaseEvent } from \"./BaseEvent.js\";\n\nexport type FormattedSaleProductType =\n \"Normal\" |\n \"Product\" |\n \"GiftCard\" |\n \"Voucher\" |\n \"Basket\" |\n \"Package\" |\n \"Component\" |\n \"Integrated\";\n\nexport interface SaleGiftCard {\n code: string;\n amount: number;\n expiry: string;\n}\n\nexport interface FormattedSaleProduct {\n uuid: string;\n type: FormattedSaleProductType;\n name: string;\n caseQuantity: number;\n isCase: boolean;\n quantity: number;\n loyalty: {\n earn: number;\n redeem: number;\n };\n prices: {\n price: number; // Will always be the correct price\n unlockedPrice: number; // The price if the product was unlocked\n normal: number; // The normal everyday price\n base: number; // The single price * the quantity\n addPrice: number; // The additional price to add to the product cost (for components)\n removePrice: number; // The additional price to remove from the product (for components)\n additionalPrice: number; // The additional price that has been applied to the product (for packages)\n };\n tax: {\n id: false | string;\n amount: number;\n };\n products: Array<FormattedSaleProduct>;\n defaultProducts: Array<FormattedSaleProduct>;\n special: boolean;\n edited: boolean;\n promotions: Record<string, {\n name: string;\n active: boolean;\n quantity: number;\n }>;\n rebates: Record<string, {\n amount: number;\n quantity: number;\n }>;\n giftCard: SaleGiftCard | null;\n note: string;\n userId: null | string;\n priceSet?: string;\n deleted?: boolean;\n initiallyDeleted?: boolean;\n familyId: string | null;\n canUnlock: boolean;\n discountReason?: string;\n requestPrice?: boolean;\n lockQuantity: boolean;\n metaData: Record<string, unknown>;\n}\n\ninterface FormattedIntegratedProductData {\n data: {\n product: FormattedSaleProduct;\n };\n context: Record<string, never>;\n}\n\nexport class FormatIntegratedProduct extends BaseEvent<\n FormattedIntegratedProductData,\n MaybePromise<FromShopfrontReturns[\"FORMAT_INTEGRATED_PRODUCT\"]>,\n FromShopfrontReturns[\"FORMAT_INTEGRATED_PRODUCT\"],\n FormattedIntegratedProductData[\"data\"],\n Record<string, never>\n> {\n\n constructor(callback: FromShopfrontCallbacks[\"FORMAT_INTEGRATED_PRODUCT\"]) {\n super(callback);\n }\n\n /**\n * @inheritDoc\n */\n public async emit(\n data: FormattedIntegratedProductData\n ): Promise<FromShopfrontReturns[\"FORMAT_INTEGRATED_PRODUCT\"]> {\n const result = await this.callback(data.data, data.context);\n\n if(typeof result !== \"object\" || result === null) {\n throw new TypeError(\"Callback must return an object\");\n }\n\n return result;\n }\n\n /**\n * Sends the response data to Shopfront\n */\n public static async respond(\n bridge: BaseBridge,\n data: Array<FromShopfrontReturns[\"FORMAT_INTEGRATED_PRODUCT\"]>,\n id: string\n ): Promise<void> {\n if(data.length > 1) {\n throw new Error(\n \"Multiple integrated product responses found, \" +\n \"please ensure you are only subscribed to FORMAT_INTEGRATED_PRODUCT once\"\n );\n }\n\n bridge.sendMessage(ToShopfront.RESPONSE_FORMAT_PRODUCT, data[0], id);\n }\n}\n","import { type FromShopfrontCallbacks, type FromShopfrontReturns } from \"../ApplicationEvents.js\";\nimport { BaseEvent } from \"./BaseEvent.js\";\n\nexport class FulfilmentCollectOrder extends BaseEvent {\n constructor(callback: FromShopfrontCallbacks[\"FULFILMENT_ORDER_COLLECTED\"]) {\n super(callback);\n }\n\n /**\n * @inheritDoc\n */\n public async emit(data: string): Promise<FromShopfrontReturns[\"FULFILMENT_ORDER_COLLECTED\"]> {\n return this.callback(data, undefined);\n }\n}\n","import { type FromShopfrontCallbacks, type FromShopfrontReturns } from \"../ApplicationEvents.js\";\nimport { BaseEvent } from \"./BaseEvent.js\";\n\nexport class FulfilmentCompleteOrder extends BaseEvent {\n constructor(callback: FromShopfrontCallbacks[\"FULFILMENT_ORDER_COMPLETED\"]) {\n super(callback);\n }\n\n /**\n * @inheritDoc\n */\n public async emit(data: string): Promise<FromShopfrontReturns[\"FULFILMENT_ORDER_COLLECTED\"]> {\n return this.callback(data, undefined);\n }\n}\n","import { type OrderDetails } from \"../APIs/Fulfilment/FulfilmentTypes.js\";\nimport { type FromShopfrontCallbacks, type FromShopfrontReturns, ToShopfront } from \"../ApplicationEvents.js\";\nimport { BaseBridge } from \"../BaseBridge.js\";\nimport { type MaybePromise } from \"../Utilities/MiscTypes.js\";\nimport { BaseEvent } from \"./BaseEvent.js\";\n\nexport class FulfilmentGetOrder extends BaseEvent<\n string,\n MaybePromise<FromShopfrontReturns[\"FULFILMENT_GET_ORDER\"]>,\n MaybePromise<FromShopfrontReturns[\"FULFILMENT_GET_ORDER\"]>\n> {\n constructor(callback: FromShopfrontCallbacks[\"FULFILMENT_GET_ORDER\"]) {\n super(callback);\n }\n\n /**\n * @inheritDoc\n */\n public async emit(data: string): Promise<FromShopfrontReturns[\"FULFILMENT_GET_ORDER\"]> {\n return this.callback(data, undefined);\n }\n\n /**\n * Sends the response data to Shopfront\n */\n public static async respond(bridge: BaseBridge, order: OrderDetails, id: string): Promise<void> {\n bridge.sendMessage(ToShopfront.FULFILMENT_GET_ORDER, order, id);\n }\n}\n","import {\n type FromShopfrontCallbacks,\n type FromShopfrontReturns,\n type FulfilmentApprovalEvent,\n} from \"../ApplicationEvents.js\";\nimport { BaseEvent } from \"./BaseEvent.js\";\n\nexport class FulfilmentOrderApproval extends BaseEvent<\n FulfilmentApprovalEvent,\n FromShopfrontReturns[\"FULFILMENT_ORDER_APPROVAL\"],\n FromShopfrontReturns[\"FULFILMENT_ORDER_APPROVAL\"]\n> {\n constructor(callback: FromShopfrontCallbacks[\"FULFILMENT_ORDER_APPROVAL\"]) {\n super(callback);\n }\n\n /**\n * @inheritDoc\n */\n public async emit(data: FulfilmentApprovalEvent): Promise<FromShopfrontReturns[\"FULFILMENT_ORDER_APPROVAL\"]> {\n return this.callback(data, undefined);\n }\n}\n","import { Sale, type ShopfrontSaleState } from \"../APIs/Sale/index.js\";\nimport type { FromShopfrontCallbacks, FromShopfrontReturns, FulfilmentProcessEvent } from \"../ApplicationEvents.js\";\nimport { type MaybePromise } from \"../Utilities/MiscTypes.js\";\nimport { BaseEvent } from \"./BaseEvent.js\";\n\ninterface FulfilmentProcessOrderData {\n id: string;\n sale: ShopfrontSaleState;\n}\n\nexport class FulfilmentProcessOrder extends BaseEvent<\n FulfilmentProcessOrderData,\n MaybePromise<FromShopfrontReturns[\"FULFILMENT_PROCESS_ORDER\"]>,\n MaybePromise<FromShopfrontReturns[\"FULFILMENT_PROCESS_ORDER\"]>,\n FulfilmentProcessEvent\n> {\n constructor(callback: FromShopfrontCallbacks[\"FULFILMENT_PROCESS_ORDER\"]) {\n super(callback);\n }\n\n /**\n * @inheritDoc\n */\n public async emit(\n data: FulfilmentProcessOrderData\n ): Promise<FromShopfrontReturns[\"FULFILMENT_PROCESS_ORDER\"]> {\n return this.callback({\n id : data.id,\n sale: new Sale(Sale.buildSaleData(data.sale)),\n }, undefined);\n }\n}\n","import { type FromShopfrontCallbacks, type FromShopfrontReturns } from \"../ApplicationEvents.js\";\nimport { BaseEvent } from \"./BaseEvent.js\";\n\nexport class FulfilmentVoidOrder extends BaseEvent {\n constructor(callback: FromShopfrontCallbacks[\"FULFILMENT_VOID_ORDER\"]) {\n super(callback);\n }\n\n /**\n * @inheritDoc\n */\n public async emit(data: string): Promise<FromShopfrontReturns[\"FULFILMENT_VOID_ORDER\"]> {\n return this.callback(data, undefined);\n }\n}\n","import {\n type FromShopfrontCallbacks,\n type FromShopfrontReturns,\n type GiftCardCodeCheckEvent,\n ToShopfront,\n} from \"../ApplicationEvents.js\";\nimport { BaseBridge } from \"../BaseBridge.js\";\nimport { type MaybePromise } from \"../Utilities/MiscTypes.js\";\nimport { BaseEvent } from \"./BaseEvent.js\";\n\ninterface GiftCardCodeCheckData {\n data: GiftCardCodeCheckEvent;\n}\n\nexport class GiftCardCodeCheck extends BaseEvent<\n GiftCardCodeCheckData,\n MaybePromise<FromShopfrontReturns[\"GIFT_CARD_CODE_CHECK\"]>,\n FromShopfrontReturns[\"GIFT_CARD_CODE_CHECK\"],\n GiftCardCodeCheckEvent\n> {\n constructor(callback: FromShopfrontCallbacks[\"GIFT_CARD_CODE_CHECK\"]) {\n super(callback);\n }\n\n /**\n * @inheritDoc\n */\n public async emit(\n data: GiftCardCodeCheckData\n ): Promise<FromShopfrontReturns[\"GIFT_CARD_CODE_CHECK\"]> {\n const result = await this.callback(data.data, undefined);\n\n if(typeof result !== \"object\") {\n throw new TypeError(\"Callback must return an object\");\n }\n\n return result;\n }\n\n /**\n * Sends the response data to Shopfront\n */\n public static async respond(\n bridge: BaseBridge,\n data: FromShopfrontReturns[\"GIFT_CARD_CODE_CHECK\"],\n id: string\n ): Promise<void> {\n bridge.sendMessage(ToShopfront.RESPONSE_GIFT_CARD_CODE_CHECK, data, id);\n }\n}\n","import { InternalMessageSource } from \"../APIs/InternalMessages/InternalMessageSource.js\";\nimport { Application } from \"../Application.js\";\nimport {\n type FromShopfront,\n type FromShopfrontCallbacks,\n type FromShopfrontReturns,\n type InternalPageMessageEvent,\n} from \"../ApplicationEvents.js\";\nimport { BaseEvent } from \"./BaseEvent.js\";\n\nexport class InternalPageMessage extends BaseEvent<InternalPageMessageEvent> {\n protected application: Application;\n\n constructor(callback: FromShopfrontCallbacks[\"INTERNAL_PAGE_MESSAGE\"], application: Application) {\n super(callback);\n\n this.application = application;\n }\n\n /**\n * Creates and returns a new internal message source\n */\n protected createReference(\n method: keyof FromShopfront | \"EXTERNAL_APPLICATION\",\n url: string\n ): InternalMessageSource {\n return new InternalMessageSource(\n this.application,\n method,\n url\n );\n }\n\n /**\n * @inheritDoc\n */\n public async emit(data: InternalPageMessageEvent): Promise<FromShopfrontReturns[\"INTERNAL_PAGE_MESSAGE\"]> {\n return this.callback({\n method : data.method,\n url : data.url,\n message : data.message,\n reference: this.createReference(data.method, data.url),\n }, undefined);\n }\n}\n","import {\n type FromShopfrontCallbacks,\n type FromShopfrontReturns,\n type PaymentMethodEnabledContext,\n type SellScreenPaymentMethod,\n ToShopfront,\n} from \"../ApplicationEvents.js\";\nimport { BaseBridge } from \"../BaseBridge.js\";\nimport { type MaybePromise } from \"../Utilities/MiscTypes.js\";\nimport { BaseEvent } from \"./BaseEvent.js\";\n\ninterface PaymentMethodsEnabledData {\n data: Array<SellScreenPaymentMethod>;\n context: PaymentMethodEnabledContext;\n}\n\nexport class PaymentMethodsEnabled extends BaseEvent<\n PaymentMethodsEnabledData,\n MaybePromise<FromShopfrontReturns[\"PAYMENT_METHODS_ENABLED\"]>,\n FromShopfrontReturns[\"PAYMENT_METHODS_ENABLED\"],\n Array<SellScreenPaymentMethod>,\n PaymentMethodEnabledContext\n> {\n constructor(callback: FromShopfrontCallbacks[\"PAYMENT_METHODS_ENABLED\"]) {\n super(callback);\n }\n\n /**\n * @inheritDoc\n */\n public async emit(data: PaymentMethodsEnabledData): Promise<FromShopfrontReturns[\"PAYMENT_METHODS_ENABLED\"]> {\n const result = await this.callback(data.data, data.context);\n\n if(typeof result !== \"object\" || result === null) {\n throw new TypeError(\"Callback must return an object\");\n }\n\n return result;\n }\n\n /**\n * Sends the response data to Shopfront\n */\n public static async respond(\n bridge: BaseBridge,\n data: FromShopfrontReturns[\"PAYMENT_METHODS_ENABLED\"],\n id: string\n ): Promise<void> {\n bridge.sendMessage(ToShopfront.RESPONSE_UI_PIPELINE, data, id);\n }\n}\n","import type { FromShopfrontCallbacks, FromShopfrontReturns, RegisterChangedEvent } from \"../ApplicationEvents.js\";\nimport { BaseEvent } from \"./BaseEvent.js\";\n\ninterface ReadyData {\n outlet: string | null;\n register: string | null;\n user: string | null;\n}\n\nexport class Ready extends BaseEvent<RegisterChangedEvent> {\n constructor(callback: FromShopfrontCallbacks[\"READY\"]) {\n super(callback);\n }\n\n /**\n * @inheritDoc\n */\n public async emit(data: ReadyData): Promise<FromShopfrontReturns[\"READY\"]> {\n return this.callback({\n outlet : data.outlet,\n register: data.register,\n user : data.user,\n }, undefined);\n }\n}\n","import { type FromShopfrontCallbacks, type FromShopfrontReturns } from \"../ApplicationEvents.js\";\nimport { BaseEvent } from \"./BaseEvent.js\";\n\ninterface RegisterChangedData {\n outlet: string | null;\n register: string | null;\n user: string | null;\n}\n\nexport class RegisterChanged extends BaseEvent {\n constructor(callback: FromShopfrontCallbacks[\"REGISTER_CHANGED\"]) {\n super(callback);\n }\n\n /**\n * @inheritDoc\n */\n public async emit(data: RegisterChangedData): Promise<FromShopfrontReturns[\"REGISTER_CHANGED\"]> {\n return this.callback(data, undefined);\n }\n}\n","import { Button } from \"../Actions/Button.js\";\nimport { type FromShopfrontCallbacks, type FromShopfrontReturns, ToShopfront } from \"../ApplicationEvents.js\";\nimport { BaseBridge } from \"../BaseBridge.js\";\nimport { type MaybePromise } from \"../Utilities/MiscTypes.js\";\nimport { BaseEvent } from \"./BaseEvent.js\";\n\ninterface RequestButtonsData {\n location: string;\n id: string;\n context: unknown;\n}\n\nexport class RequestButtons extends BaseEvent<\n RequestButtonsData,\n MaybePromise<FromShopfrontReturns[\"REQUEST_BUTTONS\"]>,\n MaybePromise<FromShopfrontReturns[\"REQUEST_BUTTONS\"]>,\n string,\n unknown\n> {\n constructor(callback: FromShopfrontCallbacks[\"REQUEST_BUTTONS\"]) {\n super(callback);\n }\n\n /**\n * @inheritDoc\n */\n public async emit(data: RequestButtonsData): Promise<FromShopfrontReturns[\"REQUEST_BUTTONS\"]> {\n let result = await this.callback(data.location, data.context);\n\n if(!Array.isArray(result)) {\n result = [ result ];\n }\n\n for(let i = 0, l = result.length; i < l; i++) {\n if(!(result[i] instanceof Button)) {\n throw new TypeError(\"You must return an instance of Button\");\n }\n }\n\n return result;\n }\n\n /**\n * Sends the response data to Shopfront\n */\n public static async respond(bridge: BaseBridge, buttons: Array<Button>, id: string): Promise<void> {\n const response = [];\n\n for(let i = 0, l = buttons.length; i < l; i++) {\n if(!(buttons[i] instanceof Button)) {\n throw new TypeError(\"Invalid response returned, expected button\");\n }\n\n response.push(buttons[i].serialize());\n }\n\n bridge.sendMessage(ToShopfront.RESPONSE_BUTTONS, response, id);\n }\n}\n","import type { Serialized } from \"../Common/Serializable.js\";\nimport { BaseAction } from \"./BaseAction.js\";\n\nexport class CustomerListOption extends BaseAction<CustomerListOption> {\n protected supportedEvents = [ \"click\" ];\n\n protected contents: string;\n\n constructor(contents: Serialized<CustomerListOption> | string) {\n super((() => {\n if(typeof contents === \"string\") {\n return {\n properties: [ contents ],\n events : {},\n type : \"CustomerListOption\",\n };\n }\n\n return contents;\n })(), CustomerListOption);\n\n if(typeof contents === \"string\") {\n this.contents = contents;\n } else {\n this.contents = contents.properties[0] as string;\n }\n }\n}\n","import { CustomerListOption } from \"../Actions/CustomerListOption.js\";\nimport { type FromShopfrontCallbacks, type FromShopfrontReturns, ToShopfront } from \"../ApplicationEvents.js\";\nimport { BaseBridge } from \"../BaseBridge.js\";\nimport { type MaybePromise } from \"../Utilities/MiscTypes.js\";\nimport { BaseEvent } from \"./BaseEvent.js\";\n\nexport interface SellScreenCustomerListOption {\n contents: string;\n onClick: () => void;\n}\n\nexport class RequestCustomerListOptions extends BaseEvent<\n Record<string, unknown>,\n MaybePromise<FromShopfrontReturns[\"REQUEST_CUSTOMER_LIST_OPTIONS\"]>,\n FromShopfrontReturns[\"REQUEST_CUSTOMER_LIST_OPTIONS\"],\n undefined\n> {\n constructor(callback: FromShopfrontCallbacks[\"REQUEST_CUSTOMER_LIST_OPTIONS\"]) {\n super(callback);\n }\n\n /**\n * @inheritDoc\n */\n public async emit(_: Record<string, unknown>): Promise<FromShopfrontReturns[\"REQUEST_CUSTOMER_LIST_OPTIONS\"]> {\n let result = await this.callback(undefined, undefined);\n\n if(!Array.isArray(result)) {\n result = [ result ];\n }\n\n for(let i = 0, l = result.length; i < l; i++) {\n if(!result[i].contents || !result[i].onClick) {\n throw new TypeError(\"You must specify both the contents and an onClick callback\");\n }\n }\n\n return result;\n }\n\n /**\n * Sends the response data to Shopfront\n */\n public static async respond(\n bridge: BaseBridge,\n options: Array<SellScreenCustomerListOption>,\n id: string\n ): Promise<void> {\n bridge.sendMessage(\n ToShopfront.RESPONSE_CUSTOMER_LIST_OPTIONS,\n options.map(option => {\n const o = new CustomerListOption(option.contents);\n\n o.addEventListener(\"click\", option.onClick);\n\n return o.serialize();\n }),\n id\n );\n }\n}\n","import { SaleKey } from \"../Actions/SaleKey.js\";\nimport { type FromShopfrontCallbacks, type FromShopfrontReturns, ToShopfront } from \"../ApplicationEvents.js\";\nimport { BaseBridge } from \"../BaseBridge.js\";\nimport { type MaybePromise } from \"../Utilities/MiscTypes.js\";\nimport { BaseEvent } from \"./BaseEvent.js\";\n\nexport class RequestSaleKeys extends BaseEvent<undefined, MaybePromise<Array<SaleKey>>, Array<SaleKey>> {\n constructor(callback: FromShopfrontCallbacks[\"REQUEST_SALE_KEYS\"]) {\n super(callback);\n }\n\n /**\n * @inheritDoc\n */\n public async emit(): Promise<FromShopfrontReturns[\"REQUEST_SALE_KEYS\"]> {\n let result = await this.callback(undefined, undefined);\n\n if(!Array.isArray(result)) {\n result = [ result ];\n }\n\n for(let i = 0, l = result.length; i < l; i++) {\n if(!(result[i] instanceof SaleKey)) {\n throw new TypeError(\"You must return an instance of SaleKey\");\n }\n }\n\n return result;\n }\n\n /**\n * Sends the response data to Shopfront\n */\n public static async respond(bridge: BaseBridge, keys: Array<SaleKey>, id: string): Promise<void> {\n const response = [];\n\n for(let i = 0, l = keys.length; i < l; i++) {\n if(!(keys[i] instanceof SaleKey)) {\n throw new TypeError(\"Invalid response returned, expected SaleKey\");\n }\n\n response.push(keys[i].serialize());\n }\n\n bridge.sendMessage(ToShopfront.RESPONSE_SALE_KEYS, response, id);\n }\n}\n","import { type FromShopfrontCallbacks, type FromShopfrontReturns, ToShopfront } from \"../ApplicationEvents.js\";\nimport { BaseBridge } from \"../BaseBridge.js\";\nimport { type MaybePromise } from \"../Utilities/MiscTypes.js\";\nimport { BaseEvent } from \"./BaseEvent.js\";\n\nexport interface SellScreenOption {\n url: string;\n title: string;\n id?: string;\n}\n\nexport class RequestSellScreenOptions extends BaseEvent<\n undefined,\n MaybePromise<FromShopfrontReturns[\"REQUEST_SELL_SCREEN_OPTIONS\"]>,\n FromShopfrontReturns[\"REQUEST_SELL_SCREEN_OPTIONS\"]\n> {\n constructor(callback: FromShopfrontCallbacks[\"REQUEST_SELL_SCREEN_OPTIONS\"]) {\n super(callback);\n }\n\n /**\n * Generates a unique identifier for a URL by encoding it to base64.\n * If the URL contains non-ASCII characters, it first URI-encodes the URL before converting to base64.\n */\n public static getOptionId(url: string): string {\n try {\n return btoa(url);\n } catch(e) {\n // Contains non-ASCII characters, convert and then encode\n return btoa(encodeURI(url));\n }\n }\n\n /**\n * Validates the URL by ensuring it follows the HTTPS protocol\n */\n public static validateURL(url: string): void {\n const urlObj = new URL(url);\n\n if(urlObj.protocol !== \"https:\") {\n throw new TypeError(`The URL \"${url}\" is invalid, please ensure that you're using the HTTPS protocol`);\n }\n }\n\n /**\n * @inheritDoc\n */\n public async emit(_: never): Promise<FromShopfrontReturns[\"REQUEST_SELL_SCREEN_OPTIONS\"]> {\n let result = await this.callback(undefined, undefined);\n\n if(!Array.isArray(result)) {\n result = [ result ];\n }\n\n for(let i = 0, l = result.length; i < l; i++) {\n if(!result[i].url || !result[i].title) {\n throw new TypeError(\"You must specify both a URL and a title\");\n }\n\n RequestSellScreenOptions.validateURL(result[i].url);\n\n result[i].id = RequestSellScreenOptions.getOptionId(result[i].url);\n }\n\n return result;\n }\n\n /**\n * Sends the response data to Shopfront\n */\n public static async respond(bridge: BaseBridge, options: Array<SellScreenOption>, id: string): Promise<void> {\n bridge.sendMessage(ToShopfront.RESPONSE_SELL_SCREEN_OPTIONS, options, id);\n }\n}\n","import { type FromShopfrontCallbacks, type FromShopfrontReturns, ToShopfront } from \"../ApplicationEvents.js\";\nimport { BaseBridge } from \"../BaseBridge.js\";\nimport { type MaybePromise } from \"../Utilities/MiscTypes.js\";\nimport { BaseEvent } from \"./BaseEvent.js\";\n\nexport class RequestSettings extends BaseEvent<\n undefined,\n MaybePromise<FromShopfrontReturns[\"REQUEST_SETTINGS\"]>,\n FromShopfrontReturns[\"REQUEST_SETTINGS\"]\n> {\n constructor(callback: FromShopfrontCallbacks[\"REQUEST_SETTINGS\"]) {\n super(callback);\n }\n\n /**\n * @inheritDoc\n */\n public async emit(_: never): Promise<FromShopfrontReturns[\"REQUEST_SETTINGS\"]> {\n const result = await this.callback(undefined, undefined);\n\n if(typeof result !== \"object\" || result === null) {\n throw new TypeError(\"Callback must return an object\");\n }\n\n return result;\n }\n\n /**\n * Sends the response data to Shopfront\n */\n public static async respond(\n bridge: BaseBridge,\n settings: Array<FromShopfrontReturns[\"REQUEST_SETTINGS\"]>,\n id: string\n ): Promise<void> {\n if(settings.length > 1) {\n throw new Error(\n \"Multiple settings responses found, \" +\n \"please ensure you are only subscribed to REQUEST_SETTINGS once\"\n );\n }\n\n bridge.sendMessage(ToShopfront.RESPONSE_SETTINGS, settings[0], id);\n }\n}\n","import { type FromShopfrontCallbacks, type FromShopfrontReturns, ToShopfront } from \"../ApplicationEvents.js\";\nimport { BaseBridge } from \"../BaseBridge.js\";\nimport { type MaybePromise } from \"../Utilities/MiscTypes.js\";\nimport { BaseEvent } from \"./BaseEvent.js\";\n\ninterface RequestTableColumnsData {\n location: string;\n context: unknown;\n}\n\nexport class RequestTableColumns extends BaseEvent<\n RequestTableColumnsData,\n MaybePromise<FromShopfrontReturns[\"REQUEST_TABLE_COLUMNS\"]>,\n FromShopfrontReturns[\"REQUEST_TABLE_COLUMNS\"],\n string,\n unknown\n> {\n constructor(callback: FromShopfrontCallbacks[\"REQUEST_TABLE_COLUMNS\"]) {\n super(callback);\n }\n\n /**\n * @inheritDoc\n */\n public async emit(data: RequestTableColumnsData): Promise<FromShopfrontReturns[\"REQUEST_TABLE_COLUMNS\"]> {\n const result = await this.callback(data.location, data.context);\n\n if(typeof result !== \"object\") {\n throw new TypeError(\"Callback must return an object\");\n }\n\n return result;\n }\n\n /**\n * Sends the response data to Shopfront\n */\n public static async respond(\n bridge: BaseBridge,\n columns: Array<FromShopfrontReturns[\"REQUEST_TABLE_COLUMNS\"]>,\n id: string\n ): Promise<void> {\n columns = columns.filter(column => column !== null);\n\n if(columns.length > 1) {\n throw new Error(\n \"Multiple table column responses found,\" +\n \"please ensure you are only subscribed to REQUEST_TABLE_COLUMNS once\"\n );\n }\n\n bridge.sendMessage(ToShopfront.RESPONSE_TABLE_COLUMNS, columns[0], id);\n }\n}\n","import { type FromShopfrontCallbacks, type FromShopfrontReturns } from \"../ApplicationEvents.js\";\nimport { BaseEvent } from \"./BaseEvent.js\";\n\ninterface CompletedSaleProduct {\n uuid: string;\n type: \"Normal\" |\n \"Product\" |\n \"GiftCard\" |\n \"Voucher\" |\n \"Basket\" |\n \"Package\" |\n \"Component\" |\n \"Integrated\";\n name: string;\n caseQuantity: number;\n isCase: boolean;\n quantity: number;\n loyalty: {\n earn: number;\n redeem: number;\n };\n prices: {\n price: number; // Will always be the correct price\n unlockedPrice: number; // The price if the product was unlocked\n normal: number; // The normal everyday price\n base: number; // The single price * the quantity\n addPrice: number; // The additional price to add to the product cost (for components)\n removePrice: number; // The additional price to remove from the product (for components)\n additionalPrice: number; // The additional price that has been applied to the product (for packages)\n };\n tax: {\n id: false | string;\n amount: number;\n };\n products: Array<CompletedSaleProduct>;\n defaultProducts: Array<CompletedSaleProduct>;\n special: boolean;\n edited: boolean;\n promotions: Record<string, {\n name: string;\n active: boolean;\n quantity: number;\n }>;\n rebates: Record<string, {\n amount: number;\n quantity: number;\n }>;\n giftCard: {\n code: string;\n amount: number;\n expiry: string;\n } | null;\n note: string;\n userId: null | string;\n priceSet?: string;\n deleted?: boolean;\n initiallyDeleted?: boolean;\n familyId: string | null;\n canUnlock: boolean;\n discountReason?: string;\n requestPrice?: boolean;\n lockQuantity: boolean;\n metaData: Record<string, unknown>;\n}\n\ninterface CompletedSalePayment {\n method: string;\n type: string;\n status: \"approved\" | \"cancelled\" | \"declined\" | \"completed\" | \"failed\";\n amount: number;\n cashout: number;\n rounding: number | undefined;\n metadata: string;\n registerId: string;\n userId?: string;\n processTime?: string;\n receipt?: string;\n reverted: boolean;\n uploaded?: boolean;\n voucherRefund?: boolean;\n}\n\nexport interface CompletedSale {\n products: Array<CompletedSaleProduct>;\n customer: false | {\n uuid: string;\n };\n payments: Array<CompletedSalePayment>;\n notes: {\n internal: string;\n sale: string;\n };\n totals: {\n sale: number;\n remaining: number;\n paid: number;\n savings: number;\n discount: number;\n change: number;\n cashout: number;\n rounding: number;\n };\n registerId: string;\n userId: string;\n orderReference: string;\n refundReason: string;\n status: \"COMPLETED\";\n id: string;\n invoiceId: string;\n createdAt: string;\n metaData: Record<string, unknown>;\n}\n\nexport class SaleComplete extends BaseEvent {\n constructor(callback: FromShopfrontCallbacks[\"SALE_COMPLETE\"]) {\n super(callback);\n }\n\n /**\n * @inheritDoc\n */\n public async emit(data: CompletedSale): Promise<FromShopfrontReturns[\"SALE_COMPLETE\"]> {\n return this.callback(data, undefined);\n }\n}\n","import { Application } from \"./Application.js\";\nimport * as ApplicationEvents from \"./ApplicationEvents.js\";\nimport { type ApplicationEventListener, BaseBridge } from \"./BaseBridge.js\";\n\ninterface FrameApplicationOptions {\n id: string; // The Client ID\n vendor: string; // The Vendor's URL\n communicator?: \"frame\";\n}\n\ninterface JavaScriptApplicationOptions {\n id: string; // The Client ID\n communicator: \"javascript\";\n}\n\ntype ApplicationOptions = FrameApplicationOptions | JavaScriptApplicationOptions;\n\ntype JavaScriptSendMessageCallback = (message: {\n key: string;\n type: string;\n data: unknown;\n id?: string;\n}) => void;\n\nexport type JavaScriptReceiveMessageCallback = (\n type: keyof ApplicationEvents.FromShopfront | keyof ApplicationEvents.FromShopfrontInternal,\n data: Record<string, unknown>,\n id: string\n) => void;\n\nexport interface JavaScriptCommunicatorExports {\n execute: () => void;\n registerSendMessage: (callback: JavaScriptSendMessageCallback) => void;\n onReceiveMessage: JavaScriptReceiveMessageCallback;\n}\n\nexport class Bridge extends BaseBridge {\n /**\n * A static method for instantiating an Application\n */\n public static createApplication(options: ApplicationOptions): Application {\n if(typeof options.id === \"undefined\") {\n throw new TypeError(\"You must specify the ID for the application\");\n }\n\n if(options.communicator !== \"javascript\" && typeof options.vendor === \"undefined\") {\n throw new TypeError(\"You must specify the Vendor for the application\");\n }\n\n return new Application(\n new Bridge(\n options.id,\n options.communicator === \"javascript\" ? null : options.vendor,\n options.communicator ?? \"frame\"\n )\n );\n }\n\n protected javascriptIsReady = false;\n protected javascriptSendMessageCallback?: JavaScriptSendMessageCallback;\n\n /**\n * The JavaScript communicator instance\n */\n public get communicator(): JavaScriptCommunicatorExports {\n if(this.communicateVia !== \"javascript\") {\n throw new Error(\"The communicator can only be accessed when communicating via JavaScript\");\n }\n\n return {\n /**\n * This is called when the application is ready to communicate, essentially this is the same as the READY\n * event when calling through the frame\n */\n execute: () => {\n // This is the equivalent of calling the ready event\n this.javascriptIsReady = true;\n this.sendMessageViaJavaScript(ApplicationEvents.ToShopfront.READY);\n },\n registerSendMessage: (callback) => {\n this.javascriptSendMessageCallback = callback;\n },\n onReceiveMessage: (type, data, id) => {\n this.emitToListeners(type, data, id);\n },\n };\n }\n\n constructor(key: string, url: string | null, protected communicateVia: \"frame\" | \"javascript\") {\n if(communicateVia === \"frame\" && window.parent === window) {\n throw new Error(\"The bridge has not been initialised within a frame\");\n }\n\n if(communicateVia === \"frame\" && url === null) {\n throw new Error(\"The subdomain of the vendor has not been specified\");\n }\n\n if(communicateVia === \"javascript\" && url !== null) {\n throw new Error(\"You cannot specify a subdomain when using the JavaScript communicator\");\n }\n\n super(key, url);\n\n this.registerListeners();\n this.sendMessage(ApplicationEvents.ToShopfront.READY);\n }\n\n /**\n * @inheritDoc\n */\n public destroy(): void {\n this.unregisterListeners();\n this.listeners = [];\n }\n\n /**\n * @inheritDoc\n */\n protected registerListeners(): void {\n if(this.communicateVia === \"javascript\") {\n return;\n }\n\n window.addEventListener(\"message\", this.handleMessageFromFrame, false);\n }\n\n /**\n * @inheritDoc\n */\n protected unregisterListeners(): void {\n if(this.communicateVia === \"javascript\") {\n return;\n }\n\n window.removeEventListener(\"message\", this.handleMessageFromFrame);\n }\n\n /**\n * Emit an event to the currently registered listeners\n */\n protected emitToListeners(\n type: keyof ApplicationEvents.FromShopfront | keyof ApplicationEvents.FromShopfrontInternal,\n data: Record<string, unknown>,\n id: string\n ): void {\n const listeners = this.listeners;\n\n for(let i = 0, l = listeners.length; i < l; i++) {\n listeners[i](type, data, id);\n }\n }\n\n /**\n * Receive a message from the application frame and distribute it to the correct listener\n */\n protected handleMessageFromFrame = (event: MessageEvent): void => {\n if(event.origin !== this.url.origin) {\n return;\n }\n\n if(typeof event.data !== \"object\" || event.data === null) {\n return;\n }\n\n if(typeof event.data.type !== \"string\") {\n return;\n }\n\n if(event.data.from !== \"ShopfrontApplicationAgent\") {\n return;\n }\n\n if(typeof event.data.origins === \"undefined\") {\n return;\n } else if(event.data.origins.from !== this.url.origin || event.data.origins.to !== window.location.origin) {\n return;\n }\n\n if(this.target === null) {\n if(event.data.type !== \"READY\") {\n return;\n }\n\n if(window.parent !== event.source) {\n // Not from the parent frame\n return;\n }\n\n this.target = event.source;\n } else {\n if(event.source !== this.target) {\n // Not from the source we want\n return;\n }\n }\n\n // Emit the event\n this.emitToListeners(event.data.type, event.data.data, event.data.id);\n };\n\n /**\n * Send a message via the JavaScript communicator\n */\n protected sendMessageViaJavaScript(type: ApplicationEvents.ToShopfront, data?: unknown, id?: string): void {\n if(!this.javascriptIsReady && type === ApplicationEvents.ToShopfront.READY) {\n // The ready event is automatically called due to the application frame needing it\n return;\n }\n\n if(!this.javascriptIsReady) {\n throw new Error(\"We haven't received notification from Shopfront that the application is ready yet\");\n }\n\n if(typeof this.javascriptSendMessageCallback === \"undefined\") {\n throw new Error(\"Attempting to send a message to Shopfront before the module has been imported\");\n }\n\n this.javascriptSendMessageCallback({\n key: this.key,\n type,\n data,\n id,\n });\n }\n\n /**\n * @inheritDoc\n */\n public sendMessage(type: ApplicationEvents.ToShopfront, data?: unknown, id?: string): void {\n if(this.communicateVia === \"javascript\") {\n return this.sendMessageViaJavaScript(type, data, id);\n }\n\n if(type === ApplicationEvents.ToShopfront.READY) {\n if(typeof data !== \"undefined\") {\n throw new TypeError(\"The `data` parameter must be undefined when requesting ready state\");\n }\n\n if(this.target !== null) {\n throw new Error(\"Shopfront is already ready\");\n }\n\n window.parent.postMessage({\n type,\n origins: {\n to : this.url.origin,\n from: window.location.origin,\n },\n key: this.key,\n }, /* can't use this because of sandbox: this.url.origin */ \"*\");\n\n return;\n }\n\n if(this.target === null) {\n throw new Error(\"Shopfront is not ready\");\n }\n\n this.target.parent.postMessage({\n type,\n origins: {\n to : this.url.origin,\n from: window.location.origin,\n },\n key: this.key,\n id,\n data,\n }, \"*\" /* can't use this because of sandbox: this.url.origin */);\n }\n\n /**\n * @inheritDoc\n */\n public addEventListener(listener: ApplicationEventListener): void {\n if(this.listeners.includes(listener)) {\n throw new Error(\"The listener provided is already registered\");\n }\n\n this.listeners.push(listener);\n\n if(!this.hasListener) {\n this.sendMessage(ApplicationEvents.ToShopfront.READY);\n this.hasListener = true;\n }\n }\n\n /**\n * @inheritDoc\n */\n public removeEventListener(listener: ApplicationEventListener): void {\n const index = this.listeners.indexOf(listener);\n\n if(index === -1) {\n return;\n }\n\n this.listeners = [\n ...this.listeners.slice(0, index),\n ...this.listeners.slice(index + 1),\n ];\n }\n}\n","import {\n type FromShopfrontCallbacks,\n type FromShopfrontReturns,\n ToShopfront,\n type UIPipelineBaseContext,\n type UIPipelineContext,\n type UIPipelineResponse,\n} from \"../ApplicationEvents.js\";\nimport { BaseBridge } from \"../BaseBridge.js\";\nimport { Bridge } from \"../Bridge.js\";\nimport { type MaybePromise } from \"../Utilities/MiscTypes.js\";\nimport { BaseEvent } from \"./BaseEvent.js\";\n\ninterface UIPPipelineIncomingData {\n data: Array<UIPipelineResponse>;\n context: UIPipelineBaseContext;\n pipelineId?: string;\n}\n\nexport class UIPipeline extends BaseEvent<\n UIPPipelineIncomingData,\n MaybePromise<FromShopfrontReturns[\"UI_PIPELINE\"]>,\n FromShopfrontReturns[\"UI_PIPELINE\"],\n Array<UIPipelineResponse>,\n UIPipelineContext\n> {\n constructor(callback: FromShopfrontCallbacks[\"UI_PIPELINE\"]) {\n super(callback);\n }\n\n /**\n * @inheritDoc\n */\n public async emit(\n data: UIPPipelineIncomingData,\n bridge: Bridge\n ): Promise<FromShopfrontReturns[\"UI_PIPELINE\"]> {\n const context: UIPipelineContext = {\n ...data.context,\n };\n\n if(typeof data.pipelineId === \"string\") {\n context.trigger = () => {\n bridge.sendMessage(ToShopfront.PIPELINE_TRIGGER, {\n id: data.pipelineId,\n });\n };\n }\n\n const result = await this.callback(data.data, context);\n\n if(typeof result !== \"object\" || result === null) {\n throw new TypeError(\"Callback must return an object\");\n }\n\n return result;\n }\n\n /**\n * Sends the response data to Shopfront\n */\n public static async respond(\n bridge: BaseBridge,\n data: FromShopfrontReturns[\"UI_PIPELINE\"],\n id: string\n ): Promise<void> {\n bridge.sendMessage(ToShopfront.RESPONSE_UI_PIPELINE, data, id);\n }\n}\n","/* eslint @typescript-eslint/no-invalid-void-type: 0 */\nimport { Button } from \"./Actions/Button.js\";\nimport { SaleKey } from \"./Actions/SaleKey.js\";\nimport { type OrderDetails } from \"./APIs/Fulfilment/FulfilmentTypes.js\";\nimport { InternalMessageSource } from \"./APIs/InternalMessages/InternalMessageSource.js\";\nimport { Sale, type ShopfrontSaleState } from \"./APIs/Sale/index.js\";\nimport { AudioPermissionChange } from \"./Events/AudioPermissionChange.js\";\nimport { AudioReady } from \"./Events/AudioReady.js\";\nimport { Callback } from \"./Events/Callback.js\";\nimport { SaleAddCustomer } from \"./Events/DirectEvents/SaleAddCustomer.js\";\nimport { SaleAddProduct } from \"./Events/DirectEvents/SaleAddProduct.js\";\nimport { SaleChangeQuantity } from \"./Events/DirectEvents/SaleChangeQuantity.js\";\nimport { SaleClear } from \"./Events/DirectEvents/SaleClear.js\";\nimport { SaleRemoveCustomer } from \"./Events/DirectEvents/SaleRemoveCustomer.js\";\nimport { SaleRemoveProduct } from \"./Events/DirectEvents/SaleRemoveProduct.js\";\nimport { SaleUpdateProducts } from \"./Events/DirectEvents/SaleUpdateProducts.js\";\nimport { type SaleEventProduct } from \"./Events/DirectEvents/types/SaleEventData.js\";\nimport { FormatIntegratedProduct, type FormattedSaleProduct } from \"./Events/FormatIntegratedProduct.js\";\nimport { FulfilmentCollectOrder } from \"./Events/FulfilmentCollectOrder.js\";\nimport { FulfilmentCompleteOrder } from \"./Events/FulfilmentCompleteOrder.js\";\nimport { FulfilmentGetOrder } from \"./Events/FulfilmentGetOrder.js\";\nimport { FulfilmentOrderApproval } from \"./Events/FulfilmentOrderApproval.js\";\nimport { FulfilmentProcessOrder } from \"./Events/FulfilmentProcessOrder.js\";\nimport { FulfilmentVoidOrder } from \"./Events/FulfilmentVoidOrder.js\";\nimport { GiftCardCodeCheck } from \"./Events/GiftCardCodeCheck.js\";\nimport { InternalPageMessage } from \"./Events/InternalPageMessage.js\";\nimport { PaymentMethodsEnabled } from \"./Events/PaymentMethodsEnabled.js\";\nimport { Ready } from \"./Events/Ready.js\";\nimport { RegisterChanged } from \"./Events/RegisterChanged.js\";\nimport { RequestButtons } from \"./Events/RequestButtons.js\";\nimport { RequestCustomerListOptions, type SellScreenCustomerListOption } from \"./Events/RequestCustomerListOptions.js\";\nimport { RequestSaleKeys } from \"./Events/RequestSaleKeys.js\";\nimport { RequestSellScreenOptions, type SellScreenOption } from \"./Events/RequestSellScreenOptions.js\";\nimport { RequestSettings } from \"./Events/RequestSettings.js\";\nimport { RequestTableColumns } from \"./Events/RequestTableColumns.js\";\nimport { type CompletedSale, SaleComplete } from \"./Events/SaleComplete.js\";\nimport { UIPipeline } from \"./Events/UIPipeline.js\";\nimport { type MaybePromise } from \"./Utilities/MiscTypes.js\";\n\nexport enum ToShopfront {\n READY = \"READY\",\n SERIALIZED = \"SERIALIZED\",\n RESPONSE_BUTTONS = \"RESPONSE_BUTTONS\",\n RESPONSE_SETTINGS = \"RESPONSE_SETTINGS\",\n RESPONSE_TABLE_COLUMNS = \"RESPONSE_TABLE_COLUMNS\",\n RESPONSE_SELL_SCREEN_OPTIONS = \"RESPONSE_SELL_SCREEN_OPTIONS\",\n DOWNLOAD = \"DOWNLOAD\",\n LOAD = \"LOAD\",\n REQUEST_CURRENT_SALE = \"REQUEST_CURRENT_SALE\",\n DATABASE_REQUEST = \"DATABASE_REQUEST\",\n UNSUPPORTED_EVENT = \"UNSUPPORTED_EVENT\",\n NOT_LISTENING_TO_EVENT = \"NOT_LISTENING_TO_EVENT\",\n REQUEST_LOCATION = \"REQUEST_LOCATION\",\n RESPONSE_FORMAT_PRODUCT = \"RESPONSE_FORMAT_PRODUCT\",\n RESPONSE_CUSTOMER_LIST_OPTIONS = \"RESPONSE_CUSTOMER_LIST_OPTIONS\",\n RESPONSE_SALE_KEYS = \"RESPONSE_SALE_KEYS\",\n PRINT_RECEIPT = \"PRINT_RECEIPT\",\n REDIRECT = \"REDIRECT\",\n GET_OPTION = \"GET_OPTION\",\n RESPONSE_UI_PIPELINE = \"RESPONSE_UI_PIPELINE\",\n RESPONSE_GIFT_CARD_CODE_CHECK = \"RESPONSE_GIFT_CARD_CODE_CHECK\",\n REQUEST_SECURE_KEY = \"REQUEST_SECURE_KEY\",\n ROTATE_SIGNING_KEY = \"ROTATE_SIGNING_KEY\",\n\n // Audio Events\n AUDIO_REQUEST_PERMISSION = \"AUDIO_REQUEST_PERMISSION\",\n AUDIO_PRELOAD = \"AUDIO_PRELOAD\",\n AUDIO_PLAY = \"AUDIO_PLAY\",\n\n // Sell Screen Events\n CHANGE_SELL_SCREEN_ACTION_MODE = \"CHANGE_SELL_SCREEN_ACTION_MODE\",\n CHANGE_SELL_SCREEN_SUMMARY_MODE = \"CHANGE_SELL_SCREEN_SUMMARY_MODE\",\n\n // Emitable Events\n SELL_SCREEN_OPTION_CHANGE = \"SELL_SCREEN_OPTION_CHANGE\",\n INTERNAL_PAGE_MESSAGE = \"INTERNAL_PAGE_MESSAGE\",\n TABLE_UPDATE = \"TABLE_UPDATE\",\n PIPELINE_TRIGGER = \"PIPELINE_TRIGGER\",\n SELL_SCREEN_PROMOTION_APPLICABLE = \"SELL_SCREEN_PROMOTION_APPLICABLE\",\n\n // Fulfilment Emitable Events\n FULFILMENT_OPT_IN = \"FULFILMENT_OPT_IN\",\n FULFILMENT_OPTIONS = \"FULFILMENT_OPTIONS\",\n FULFILMENT_ORDERS_SYNC = \"FULFILMENT_ORDERS_SYNC\",\n FULFILMENT_ORDERS_CREATE = \"FULFILMENT_ORDERS_CREATE\",\n FULFILMENT_ORDERS_UPDATE = \"FULFILMENT_ORDERS_UPDATE\",\n FULFILMENT_ORDERS_CANCEL = \"FULFILMENT_ORDERS_CANCEL\",\n\n // Sale API events\n CREATE_SALE = \"CREATE_SALE\",\n\n // Fulfilment Response Events\n FULFILMENT_GET_ORDER = \"FULFILMENT_GET_ORDER\",\n}\n\nexport type SoundEvents = ToShopfront.AUDIO_REQUEST_PERMISSION | ToShopfront.AUDIO_PRELOAD | ToShopfront.AUDIO_PLAY;\n\nexport interface FromShopfrontReturns {\n READY: unknown;\n REQUEST_SETTINGS: {\n logo: null | string;\n description: null | string;\n url: null | string;\n };\n REQUEST_BUTTONS: Array<Button>;\n REQUEST_TABLE_COLUMNS: null | {\n headers: Array<{\n label: string;\n key: string;\n weight: number;\n }>;\n body: Array<Record<string, string>>;\n footer: Record<string, string>;\n };\n REQUEST_SELL_SCREEN_OPTIONS: Array<SellScreenOption>;\n CALLBACK: unknown;\n RESPONSE_CURRENT_SALE: {\n requestId: string;\n saleState: ShopfrontSaleState;\n };\n INTERNAL_PAGE_MESSAGE: unknown;\n REGISTER_CHANGED: unknown;\n RESPONSE_LOCATION: {\n requestId: string;\n register: string | null;\n outlet: string | null;\n user: string | null;\n };\n RESPONSE_AUDIO_REQUEST: {\n requestId: string;\n success: boolean;\n message?: string;\n };\n FORMAT_INTEGRATED_PRODUCT: FormatIntegratedProductEvent;\n REQUEST_CUSTOMER_LIST_OPTIONS: Array<SellScreenCustomerListOption>;\n REQUEST_SALE_KEYS: Array<SaleKey>;\n SALE_COMPLETE: unknown;\n UI_PIPELINE: Array<UIPipelineResponse>;\n PAYMENT_METHODS_ENABLED: Array<SellScreenPaymentMethod>;\n AUDIO_READY: unknown;\n AUDIO_PERMISSION_CHANGE: unknown;\n FULFILMENT_GET_ORDER: OrderDetails;\n FULFILMENT_VOID_ORDER: unknown;\n FULFILMENT_PROCESS_ORDER: unknown;\n FULFILMENT_ORDER_APPROVAL: unknown;\n FULFILMENT_ORDER_COLLECTED: unknown;\n FULFILMENT_ORDER_COMPLETED: unknown;\n RESPONSE_CREATE_SALE: {\n requestId: string;\n success: boolean;\n message?: string;\n };\n GIFT_CARD_CODE_CHECK: {\n code: string;\n message: string | null;\n };\n}\n\nexport interface InternalPageMessageEvent {\n method: \"REQUEST_SETTINGS\" | \"REQUEST_SELL_SCREEN_OPTIONS\" | \"EXTERNAL_APPLICATION\";\n url: string;\n message: unknown;\n reference: InternalMessageSource;\n}\n\nexport interface RegisterChangedEvent {\n register: null | string;\n outlet: null | string;\n user: null | string;\n}\n\nexport interface GiftCardCodeCheckEvent {\n code: string;\n message: string | null;\n}\n\nexport interface FormatIntegratedProductEvent {\n product: FormattedSaleProduct;\n}\n\nexport interface SaleCompletedEvent {\n sale: CompletedSale;\n}\n\nexport interface AudioPermissionChangeEvent {\n permitted: boolean;\n}\n\nexport interface FulfilmentProcessEvent {\n id: string;\n sale: Sale;\n}\n\nexport interface FulfilmentApprovalEvent {\n id: string;\n approved: boolean;\n}\n\nexport interface UIPipelineResponse {\n name: string;\n content: string;\n}\n\nexport interface UIPipelineBaseContext {\n location: string;\n}\n\nexport interface UIPipelineContext extends UIPipelineBaseContext {\n trigger?: () => void;\n}\n\nexport interface SellScreenPaymentMethod {\n uuid: string;\n name: string;\n type:\n \"global\" |\n \"cash\" |\n \"eftpos\" |\n \"giftcard\" |\n \"voucher\" |\n \"cheque\" |\n \"pc-eftpos\" |\n \"linkly-vaa\" |\n \"direct-deposit\" |\n \"tyro\" |\n \"custom\";\n default_pay_exact: boolean;\n background_colour?: string;\n text_colour?: string;\n}\n\nexport interface PaymentMethodEnabledContext {\n register: string;\n customer: false | {\n uuid: string;\n };\n}\n\nexport interface FromShopfrontCallbacks {\n READY: (event: RegisterChangedEvent) => MaybePromise<FromShopfrontReturns[\"READY\"]>;\n REQUEST_SETTINGS: () => MaybePromise<FromShopfrontReturns[\"REQUEST_SETTINGS\"]>;\n REQUEST_BUTTONS: (location: string, context: unknown) => MaybePromise<FromShopfrontReturns[\"REQUEST_BUTTONS\"]>;\n REQUEST_TABLE_COLUMNS: (\n location: string,\n data: unknown\n ) => MaybePromise<FromShopfrontReturns[\"REQUEST_TABLE_COLUMNS\"]>;\n REQUEST_SELL_SCREEN_OPTIONS: () => MaybePromise<FromShopfrontReturns[\"REQUEST_SELL_SCREEN_OPTIONS\"]>;\n INTERNAL_PAGE_MESSAGE: (\n event: InternalPageMessageEvent\n ) => MaybePromise<FromShopfrontReturns[\"INTERNAL_PAGE_MESSAGE\"]>;\n REGISTER_CHANGED: (event: RegisterChangedEvent) => MaybePromise<FromShopfrontReturns[\"REGISTER_CHANGED\"]>;\n CALLBACK: () => MaybePromise<FromShopfrontReturns[\"CALLBACK\"]>;\n FORMAT_INTEGRATED_PRODUCT: (\n event: FormatIntegratedProductEvent\n ) => MaybePromise<FromShopfrontReturns[\"FORMAT_INTEGRATED_PRODUCT\"]>;\n REQUEST_CUSTOMER_LIST_OPTIONS: () => MaybePromise<FromShopfrontReturns[\"REQUEST_CUSTOMER_LIST_OPTIONS\"]>;\n REQUEST_SALE_KEYS: () => MaybePromise<FromShopfrontReturns[\"REQUEST_SALE_KEYS\"]>;\n SALE_COMPLETE: (event: SaleCompletedEvent) => MaybePromise<FromShopfrontReturns[\"SALE_COMPLETE\"]>;\n UI_PIPELINE: (\n event: Array<UIPipelineResponse>,\n context: UIPipelineContext\n ) => MaybePromise<FromShopfrontReturns[\"UI_PIPELINE\"]>;\n PAYMENT_METHODS_ENABLED: (\n event: Array<SellScreenPaymentMethod>,\n context: PaymentMethodEnabledContext\n ) => MaybePromise<FromShopfrontReturns[\"PAYMENT_METHODS_ENABLED\"]>;\n AUDIO_READY: () => MaybePromise<FromShopfrontReturns[\"AUDIO_READY\"]>;\n AUDIO_PERMISSION_CHANGE: (\n event: AudioPermissionChangeEvent\n ) => MaybePromise<FromShopfrontReturns[\"AUDIO_PERMISSION_CHANGE\"]>;\n FULFILMENT_GET_ORDER: (id: string) => MaybePromise<FromShopfrontReturns[\"FULFILMENT_GET_ORDER\"]>;\n FULFILMENT_VOID_ORDER: (id: string) => MaybePromise<FromShopfrontReturns[\"FULFILMENT_VOID_ORDER\"]>;\n FULFILMENT_PROCESS_ORDER: (\n event: FulfilmentProcessEvent\n ) => MaybePromise<FromShopfrontReturns[\"FULFILMENT_PROCESS_ORDER\"]>;\n FULFILMENT_ORDER_APPROVAL: (\n event: FulfilmentApprovalEvent\n ) => MaybePromise<FromShopfrontReturns[\"FULFILMENT_ORDER_APPROVAL\"]>;\n FULFILMENT_ORDER_COLLECTED: (id: string) => MaybePromise<FromShopfrontReturns[\"FULFILMENT_ORDER_COLLECTED\"]>;\n FULFILMENT_ORDER_COMPLETED: (id: string) => MaybePromise<FromShopfrontReturns[\"FULFILMENT_ORDER_COMPLETED\"]>;\n GIFT_CARD_CODE_CHECK: (\n event: GiftCardCodeCheckEvent,\n context: unknown\n ) => MaybePromise<FromShopfrontReturns[\"GIFT_CARD_CODE_CHECK\"]>;\n}\n\nexport interface FromShopfront {\n READY: Ready;\n REQUEST_SETTINGS: RequestSettings;\n REQUEST_BUTTONS: RequestButtons;\n REQUEST_TABLE_COLUMNS: RequestTableColumns;\n REQUEST_SELL_SCREEN_OPTIONS: RequestSellScreenOptions;\n CALLBACK: Callback;\n INTERNAL_PAGE_MESSAGE: InternalPageMessage;\n REGISTER_CHANGED: RegisterChanged;\n FORMAT_INTEGRATED_PRODUCT: FormatIntegratedProduct;\n REQUEST_CUSTOMER_LIST_OPTIONS: RequestCustomerListOptions;\n SALE_COMPLETE: SaleComplete;\n REQUEST_SALE_KEYS: RequestSaleKeys;\n UI_PIPELINE: UIPipeline;\n PAYMENT_METHODS_ENABLED: PaymentMethodsEnabled;\n AUDIO_READY: AudioReady;\n AUDIO_PERMISSION_CHANGE: AudioPermissionChange;\n FULFILMENT_GET_ORDER: FulfilmentGetOrder;\n FULFILMENT_VOID_ORDER: FulfilmentVoidOrder;\n FULFILMENT_PROCESS_ORDER: FulfilmentProcessOrder;\n FULFILMENT_ORDER_APPROVAL: FulfilmentOrderApproval;\n FULFILMENT_ORDER_COLLECTED: FulfilmentCollectOrder;\n FULFILMENT_ORDER_COMPLETED: FulfilmentCompleteOrder;\n GIFT_CARD_CODE_CHECK: GiftCardCodeCheck;\n}\n\nexport type ListenableFromShopfrontEvent = keyof Omit<FromShopfront, \"CALLBACK\">;\n\nexport interface DirectShopfrontEventData {\n SALE_ADD_PRODUCT: {\n product: SaleEventProduct;\n indexAddress: Array<number>;\n };\n SALE_REMOVE_PRODUCT: {\n indexAddress: Array<number>;\n };\n SALE_CHANGE_QUANTITY: {\n indexAddress: Array<number>;\n amount: number;\n absolute: boolean;\n };\n SALE_UPDATE_PRODUCTS: {\n products: Array<SaleEventProduct>;\n };\n SALE_ADD_CUSTOMER: {\n customer: {\n uuid: string;\n };\n };\n SALE_REMOVE_CUSTOMER: undefined;\n SALE_CLEAR: undefined;\n}\n\nexport interface DirectShopfrontCallbacks {\n SALE_ADD_PRODUCT: (event: DirectShopfrontEventData[\"SALE_ADD_PRODUCT\"]) => MaybePromise<void>;\n SALE_REMOVE_PRODUCT: (event: DirectShopfrontEventData[\"SALE_REMOVE_PRODUCT\"]) => MaybePromise<void>;\n SALE_CHANGE_QUANTITY: (event: DirectShopfrontEventData[\"SALE_CHANGE_QUANTITY\"]) => MaybePromise<void>;\n SALE_UPDATE_PRODUCTS: (event: DirectShopfrontEventData[\"SALE_UPDATE_PRODUCTS\"]) => MaybePromise<void>;\n SALE_ADD_CUSTOMER: (event: DirectShopfrontEventData[\"SALE_ADD_CUSTOMER\"]) => MaybePromise<void>;\n SALE_REMOVE_CUSTOMER: () => MaybePromise<void>;\n SALE_CLEAR: () => MaybePromise<void>;\n}\n\nexport interface DirectShopfront {\n SALE_ADD_PRODUCT: SaleAddProduct;\n SALE_REMOVE_PRODUCT: SaleRemoveProduct;\n SALE_CHANGE_QUANTITY: SaleChangeQuantity;\n SALE_UPDATE_PRODUCTS: SaleUpdateProducts;\n SALE_ADD_CUSTOMER: SaleAddCustomer;\n SALE_REMOVE_CUSTOMER: SaleRemoveCustomer;\n SALE_CLEAR: SaleClear;\n}\n\nexport type DirectShopfrontEvent = keyof DirectShopfront;\n\nexport const directShopfrontEvents: Array<DirectShopfrontEvent> = [\n \"SALE_ADD_PRODUCT\",\n \"SALE_REMOVE_PRODUCT\",\n \"SALE_UPDATE_PRODUCTS\",\n \"SALE_CHANGE_QUANTITY\",\n \"SALE_ADD_CUSTOMER\",\n \"SALE_REMOVE_CUSTOMER\",\n \"SALE_CLEAR\",\n] as const;\n\n/**\n * Checks whether the event is a direct Shopfront event\n */\nexport const isDirectShopfrontEvent = (\n event: DirectShopfrontEvent | ListenableFromShopfrontEvent\n): event is DirectShopfrontEvent => {\n return directShopfrontEvents.includes(event as DirectShopfrontEvent);\n};\n\nexport interface FromShopfrontInternal {\n CYCLE_KEY: \"CYCLE_KEY\";\n LOCATION_CHANGED: \"LOCATION_CHANGED\";\n RESPONSE_CURRENT_SALE: \"RESPONSE_CURRENT_SALE\";\n RESPONSE_DATABASE_REQUEST: \"RESPONSE_DATABASE_REQUEST\";\n RESPONSE_LOCATION: \"RESPONSE_LOCATION\";\n RESPONSE_OPTION: \"RESPONSE_OPTION\";\n RESPONSE_AUDIO_REQUEST: \"RESPONSE_AUDIO_REQUEST\";\n RESPONSE_SECURE_KEY: \"RESPONSE_SECURE_KEY\";\n RESPONSE_CREATE_SALE: \"RESPONSE_CREATE_SALE\";\n}\n\nexport type SellScreenActionMode =\n \"search\" |\n \"keys\" |\n \"held-sales\" |\n \"payment\" |\n \"customers\" |\n \"promotions\" |\n \"show-backorders\" |\n \"fulfilment-orders\";\n\nexport type SellScreenSummaryMode = \"transaction\" | \"payments\" | \"receipts\";\n","import type { BaseBridge } from \"../../BaseBridge.js\";\nimport type { AnyFunction } from \"../../Utilities/MiscTypes.js\";\nimport type { DataSourceTables } from \"./types/DataSourceTables.js\";\n\nexport type DatabaseTable = keyof DataSourceTables;\n\nexport type DatabaseMethodName<Table extends DatabaseTable> = {\n [K in keyof DataSourceTables[Table]]: DataSourceTables[Table][K] extends AnyFunction ?\n K :\n never\n};\n\nexport type DatabaseCallReturn<\n Table extends DatabaseTable,\n Method extends keyof DatabaseMethodName<Table>,\n> = ReturnType<Extract<DataSourceTables[Table][Method], AnyFunction>>;\n\nexport abstract class BaseDatabase<BridgeType extends BaseBridge = BaseBridge> {\n protected bridge: BridgeType;\n\n protected constructor(bridge: BridgeType) {\n this.bridge = bridge;\n }\n\n /**\n * Makes a request to the Shopfront local database\n */\n public abstract callMethod<\n Table extends DatabaseTable,\n Method extends keyof DatabaseMethodName<Table>,\n ExpectedResult extends DatabaseCallReturn<Table, Method>\n >(\n table: Table,\n method: Method,\n args: Array<unknown>\n ): Promise<ExpectedResult>;\n\n /**\n * Retrieves all items in the specified table\n */\n public abstract all<Table extends DatabaseTable>(table: Table): Promise<DatabaseCallReturn<Table, \"all\">>;\n\n /**\n * Retrieves all items that match the given ID in the specified table\n */\n public abstract get<Table extends DatabaseTable>(\n table: Table,\n id: string | number\n ): Promise<DatabaseCallReturn<Table, \"get\">>;\n\n /**\n * Returns the item count of the specified table\n */\n public abstract count(table: DatabaseTable): Promise<number>;\n}\n","import { type FromShopfront, type FromShopfrontInternal, ToShopfront } from \"../../ApplicationEvents.js\";\nimport type { Bridge } from \"../../Bridge.js\";\nimport {\n BaseDatabase,\n type DatabaseCallReturn,\n type DatabaseMethodName,\n type DatabaseTable,\n} from \"./BaseDatabase.js\";\n\nexport class Database extends BaseDatabase<Bridge> {\n\n constructor(bridge: Bridge) {\n super(bridge);\n }\n\n /**\n * @inheritDoc\n */\n public async callMethod<\n Table extends DatabaseTable,\n Method extends keyof DatabaseMethodName<Table>,\n ExpectedResult extends DatabaseCallReturn<Table, Method>\n >(\n table: Table,\n method: Method,\n args: Array<unknown>\n ): Promise<ExpectedResult> {\n const databaseRequest = `DatabaseRequest-${Math.random()}-${Date.now()}`;\n\n const promise = new Promise<ExpectedResult>((res, rej) => {\n const listener = (\n event: keyof FromShopfrontInternal | keyof FromShopfront,\n data: Record<string, unknown>\n ) => {\n if(\n event !== \"RESPONSE_DATABASE_REQUEST\"\n ) {\n return;\n }\n\n if(data.requestId !== databaseRequest) {\n return;\n }\n\n this.bridge.removeEventListener(listener);\n\n if(data.error) {\n rej(data.error);\n\n return;\n }\n\n res(data.results as ExpectedResult);\n };\n\n this.bridge.addEventListener(listener);\n });\n\n this.bridge.sendMessage(ToShopfront.DATABASE_REQUEST, {\n requestId: databaseRequest,\n table,\n method,\n args,\n });\n\n return promise;\n }\n\n /**\n * @inheritDoc\n */\n public async all<Table extends DatabaseTable>(table: Table): Promise<DatabaseCallReturn<Table, \"all\">> {\n return this.callMethod(table, \"all\", []);\n }\n\n /**\n * @inheritDoc\n */\n public async get<Table extends DatabaseTable>(\n table: Table,\n id: string | number\n ): Promise<DatabaseCallReturn<Table, \"get\">> {\n return this.callMethod(table, \"get\", [ id ]);\n }\n\n /**\n * @inheritDoc\n */\n public async count(table: DatabaseTable): Promise<number> {\n return this.callMethod(table, \"count\", []);\n }\n}\n","import type { ShopfrontSalePaymentStatus } from \"../APIs/Sale/index.js\";\nimport type { Serialized } from \"../Common/Serializable.js\";\nimport { BaseAction } from \"./BaseAction.js\";\n\nexport interface SaleUpdateChanges {\n PRODUCT_ADD: {\n id: string;\n quantity: number;\n price?: number;\n consolidate?: boolean;\n indexAddress?: Array<number>;\n metaData: Record<string, unknown>;\n };\n PRODUCT_REMOVE: {\n id: string;\n indexAddress: Array<number>;\n };\n PAYMENT_ADD: {\n id: string;\n amount: number;\n cashout?: number | boolean;\n status?: ShopfrontSalePaymentStatus;\n };\n PAYMENT_REVERSE: {\n id: string;\n amount: number;\n cashout?: number;\n status?: ShopfrontSalePaymentStatus;\n };\n SALE_CANCEL: Record<string, never>;\n CUSTOMER_ADD: {\n id: string;\n };\n CUSTOMER_REMOVE: Record<string, never>;\n SALE_EXTERNAL_NOTE: {\n note: string;\n append?: boolean;\n };\n SALE_INTERNAL_NOTE: {\n note: string;\n append?: boolean;\n };\n SALE_ORDER_REFERENCE: {\n reference: string;\n };\n SALE_META_DATA: {\n metaData: Record<string, unknown>;\n };\n PRODUCT_UPDATE: {\n id: string;\n indexAddress: Array<number>;\n quantity?: number;\n price?: number;\n metaData?: Record<string, unknown>;\n };\n}\n\nexport class SaleUpdate<K extends keyof SaleUpdateChanges> extends BaseAction<SaleUpdate<K>> {\n protected supportedEvents = [];\n\n protected type: K;\n protected data: SaleUpdateChanges[K];\n\n constructor(type: Serialized<SaleUpdate<K>> | K, data?: SaleUpdateChanges[K]) {\n // https://github.com/Microsoft/TypeScript/issues/8277\n super((() => {\n if(typeof type === \"string\") {\n return {\n properties: [ type, data ],\n events : {},\n type : \"SaleUpdate\",\n };\n } else {\n return type;\n }\n })(), SaleUpdate);\n\n if(typeof data === \"undefined\" && typeof type !== \"string\") {\n this.type = type.properties[0] as K;\n this.data = type.properties[1] as SaleUpdateChanges[K];\n } else {\n this.type = type as K;\n\n if(typeof data === \"undefined\") {\n throw new TypeError(\"Invalid sale update data specified\");\n } else {\n this.data = data;\n }\n }\n }\n}\n","import type { BaseApplication } from \"../../BaseApplication.js\";\nimport { BaseSale } from \"./BaseSale.js\";\nimport { Sale } from \"./Sale.js\";\nimport type { SaleCustomer } from \"./SaleCustomer.js\";\nimport type { SalePayment } from \"./SalePayment.js\";\nimport type { SaleProduct } from \"./SaleProduct.js\";\nimport type { ShopfrontSaleState } from \"./ShopfrontSaleState.js\";\n\nexport abstract class BaseCurrentSale extends BaseSale {\n protected application: BaseApplication;\n protected cancelled: boolean;\n\n /**\n * Create a sale from a sale state.\n * It's highly recommend to not construct a sale manually, instead use application.getCurrentSale().\n */\n constructor(application: BaseApplication, saleState: ShopfrontSaleState) {\n super(Sale.buildSaleData(saleState));\n\n this.application = application;\n this.cancelled = false;\n }\n\n /**\n * Update the sale to be the latest sale that exists on the sell screen.\n */\n public abstract refreshSale(): Promise<void>;\n\n /**\n * Cancel the current sale in progress.\n */\n public abstract cancelSale(): Promise<void>;\n\n /**\n * Add a product to the sale.\n */\n public abstract addProduct(product: SaleProduct): Promise<void>;\n\n /**\n * Remove a product from the sale.\n * It's highly recommended that you pass in a product that has been retrieved using sale.getProducts().\n */\n public abstract removeProduct(product: SaleProduct): Promise<void>;\n\n /**\n * Add a payment to the sell screen.\n *\n * If you specify a payment with a status, it will bypass the payment gateway (i.e. it won't request that the\n * user takes money from the customer).\n *\n * If you don't specify a cashout amount, it will automatically determine if the payment method normally requests\n * cashout (from the payment method settings).\n */\n public abstract addPayment(payment: SalePayment): Promise<void>;\n\n /**\n * Reverse a payment on the sell screen.\n *\n * This is used to issue a refund to the customer. The sale payment amount should be positive.\n */\n public abstract reversePayment(payment: SalePayment): Promise<void>;\n\n /**\n * Add a customer to the sale.\n * If there is already a customer on the sale this will override that customer.\n */\n public abstract addCustomer(customer: SaleCustomer): Promise<void>;\n\n /**\n * Remove the customer from the current sale.\n * If there is no customer currently on the sale this will be ignored.\n * If there are \"on account\" or loyalty payments still on the sale, this will be ignored.\n */\n public abstract removeCustomer(): Promise<void>;\n\n /**\n * Set the external note for the sale.\n * @param note The note to set.\n * @param append Whether to append the note to the current sale note.\n */\n public abstract setExternalNote(note: string, append?: boolean): Promise<void>;\n\n /**\n * Set the internal note for the sale.\n * @param note The note to set.\n * @param append Whether to append the note to the current sale note.\n */\n public abstract setInternalNote(note: string, append?: boolean): Promise<void>;\n\n /**\n * Set the order reference to the provided string.\n */\n public abstract setOrderReference(reference: string): Promise<void>;\n\n /**\n * Set the meta-data of the sale, this will override the previous meta data.\n */\n public abstract setMetaData(metaData: Record<string, unknown>): Promise<void>;\n\n /**\n * Update a product's details; currently this can update quantity, price and metadata\n */\n public abstract updateProduct(product: SaleProduct): Promise<void>;\n}\n","import { SaleUpdate, type SaleUpdateChanges } from \"../../Actions/SaleUpdate.js\";\nimport { BaseCurrentSale } from \"./BaseCurrentSale.js\";\nimport { InvalidSaleDeviceError, SaleCancelledError } from \"./Exceptions.js\";\nimport type { SaleCustomer } from \"./SaleCustomer.js\";\nimport type { SalePayment } from \"./SalePayment.js\";\nimport type { SaleProduct } from \"./SaleProduct.js\";\n\nexport class CurrentSale extends BaseCurrentSale {\n /**\n * @inheritDoc\n */\n public async refreshSale(): Promise<void> {\n this.checkIfCancelled();\n\n const newSale = await this.application.getCurrentSale();\n\n if(newSale === false) {\n throw new InvalidSaleDeviceError();\n }\n\n this.hydrate(newSale);\n }\n\n /**\n * Check if the sale has already been cancelled, if it has, throw a SaleCancelledError.\n */\n protected checkIfCancelled(): void {\n if(this.cancelled) {\n throw new SaleCancelledError();\n }\n }\n\n /**\n * Send a sale update to Shopfront.\n */\n protected sendSaleUpdate(update: SaleUpdate<keyof SaleUpdateChanges>): Promise<void> {\n this.checkIfCancelled();\n this.application.send(update);\n\n return this.refreshSale();\n }\n\n /**\n * @inheritDoc\n */\n public async cancelSale(): Promise<void> {\n await this.sendSaleUpdate(new SaleUpdate(\"SALE_CANCEL\", {}));\n this.cancelled = true;\n }\n\n /**\n * @inheritDoc\n */\n public addProduct(product: SaleProduct): Promise<void> {\n return this.sendSaleUpdate(new SaleUpdate(\"PRODUCT_ADD\", {\n id : product.getId(),\n quantity : product.getQuantity(),\n price : product.getPrice(),\n indexAddress: product.getIndexAddress(),\n metaData : product.getMetaData(),\n }));\n }\n\n /**\n * @inheritDoc\n */\n public removeProduct(product: SaleProduct): Promise<void> {\n return this.sendSaleUpdate(new SaleUpdate(\"PRODUCT_REMOVE\", {\n id : product.getId(),\n indexAddress: product.getIndexAddress(),\n }));\n }\n\n /**\n * @inheritDoc\n */\n public addPayment(payment: SalePayment): Promise<void> {\n return this.sendSaleUpdate(new SaleUpdate(\"PAYMENT_ADD\", {\n id : payment.getId(),\n amount : payment.getAmount(),\n cashout: payment.getCashout(),\n status : payment.getStatus(),\n }));\n }\n\n /**\n * @inheritDoc\n */\n public reversePayment(payment: SalePayment): Promise<void> {\n return this.sendSaleUpdate(new SaleUpdate(\"PAYMENT_REVERSE\", {\n id : payment.getId(),\n amount : payment.getAmount(),\n cashout: payment.getCashout(),\n status : payment.getStatus(),\n }));\n }\n\n /**\n * @inheritDoc\n */\n public addCustomer(customer: SaleCustomer): Promise<void> {\n return this.sendSaleUpdate(new SaleUpdate(\"CUSTOMER_ADD\", {\n id: customer.getId(),\n }));\n }\n\n /**\n * @inheritDoc\n */\n public removeCustomer(): Promise<void> {\n return this.sendSaleUpdate(new SaleUpdate(\"CUSTOMER_REMOVE\", {}));\n }\n\n /**\n * @inheritDoc\n */\n public setExternalNote(note: string, append = false): Promise<void> {\n return this.sendSaleUpdate(new SaleUpdate(\"SALE_EXTERNAL_NOTE\", {\n note,\n append,\n }));\n }\n\n /**\n * @inheritDoc\n */\n public setInternalNote(note: string, append = false): Promise<void> {\n return this.sendSaleUpdate(new SaleUpdate(\"SALE_INTERNAL_NOTE\", {\n note,\n append,\n }));\n }\n\n /**\n * @inheritDoc\n */\n public setOrderReference(reference: string): Promise<void> {\n return this.sendSaleUpdate(new SaleUpdate(\"SALE_ORDER_REFERENCE\", {\n reference,\n }));\n }\n\n /**\n * @inheritDoc\n */\n public setMetaData(metaData: Record<string, unknown>): Promise<void> {\n return this.sendSaleUpdate(new SaleUpdate(\"SALE_META_DATA\", {\n metaData,\n }));\n }\n\n /**\n * @inheritDoc\n */\n public updateProduct(product: SaleProduct): Promise<void> {\n const updateData: SaleUpdateChanges[\"PRODUCT_UPDATE\"] = {\n id : product.getId(),\n indexAddress: product.getIndexAddress(),\n };\n\n if(product.wasQuantityModified()) {\n updateData.quantity = product.getQuantity();\n }\n\n if(product.wasPriceModified()) {\n updateData.price = product.getPrice();\n }\n\n if(product.wasMetaDataModified()) {\n updateData.metaData = product.getMetaData();\n }\n\n product.clearModificationFlags();\n\n return this.sendSaleUpdate(new SaleUpdate(\"PRODUCT_UPDATE\", updateData));\n }\n}\n","import type { BaseDatabase } from \"./APIs/Database/BaseDatabase.js\";\nimport type { BaseCurrentSale } from \"./APIs/Sale/BaseCurrentSale.js\";\nimport type { Sale } from \"./APIs/Sale/index.js\";\nimport type { Application } from \"./Application.js\";\nimport {\n type DirectShopfront,\n type DirectShopfrontCallbacks,\n type DirectShopfrontEvent,\n type FromShopfront,\n type FromShopfrontCallbacks,\n type FromShopfrontInternal,\n isDirectShopfrontEvent,\n type ListenableFromShopfrontEvent,\n type RegisterChangedEvent,\n type SellScreenActionMode,\n type SellScreenSummaryMode,\n type SoundEvents,\n} from \"./ApplicationEvents.js\";\nimport type { BaseBridge } from \"./BaseBridge.js\";\nimport type { Serializable } from \"./Common/Serializable.js\";\nimport type { BaseEmitableEvent } from \"./EmitableEvents/BaseEmitableEvent.js\";\nimport { AudioPermissionChange } from \"./Events/AudioPermissionChange.js\";\nimport { AudioReady } from \"./Events/AudioReady.js\";\nimport type { BaseEvent } from \"./Events/BaseEvent.js\";\nimport { SaleAddCustomer } from \"./Events/DirectEvents/SaleAddCustomer.js\";\nimport { SaleAddProduct } from \"./Events/DirectEvents/SaleAddProduct.js\";\nimport { SaleChangeQuantity } from \"./Events/DirectEvents/SaleChangeQuantity.js\";\nimport { SaleClear } from \"./Events/DirectEvents/SaleClear.js\";\nimport { SaleRemoveCustomer } from \"./Events/DirectEvents/SaleRemoveCustomer.js\";\nimport { SaleRemoveProduct } from \"./Events/DirectEvents/SaleRemoveProduct.js\";\nimport { SaleUpdateProducts } from \"./Events/DirectEvents/SaleUpdateProducts.js\";\nimport { FormatIntegratedProduct } from \"./Events/FormatIntegratedProduct.js\";\nimport { FulfilmentCollectOrder } from \"./Events/FulfilmentCollectOrder.js\";\nimport { FulfilmentCompleteOrder } from \"./Events/FulfilmentCompleteOrder.js\";\nimport { FulfilmentGetOrder } from \"./Events/FulfilmentGetOrder.js\";\nimport { FulfilmentOrderApproval } from \"./Events/FulfilmentOrderApproval.js\";\nimport { FulfilmentProcessOrder } from \"./Events/FulfilmentProcessOrder.js\";\nimport { FulfilmentVoidOrder } from \"./Events/FulfilmentVoidOrder.js\";\nimport { GiftCardCodeCheck } from \"./Events/GiftCardCodeCheck.js\";\nimport { InternalPageMessage } from \"./Events/InternalPageMessage.js\";\nimport { PaymentMethodsEnabled } from \"./Events/PaymentMethodsEnabled.js\";\nimport { Ready } from \"./Events/Ready.js\";\nimport { RegisterChanged } from \"./Events/RegisterChanged.js\";\nimport { RequestButtons } from \"./Events/RequestButtons.js\";\nimport { RequestCustomerListOptions } from \"./Events/RequestCustomerListOptions.js\";\nimport { RequestSaleKeys } from \"./Events/RequestSaleKeys.js\";\nimport { RequestSellScreenOptions } from \"./Events/RequestSellScreenOptions.js\";\nimport { RequestSettings } from \"./Events/RequestSettings.js\";\nimport { RequestTableColumns } from \"./Events/RequestTableColumns.js\";\nimport { SaleComplete } from \"./Events/SaleComplete.js\";\nimport { UIPipeline } from \"./Events/UIPipeline.js\";\nimport type { AnyFunction, MaybePromise } from \"./Utilities/MiscTypes.js\";\n\nexport interface ShopfrontResponse {\n success: boolean;\n message?: string;\n}\n\nexport interface ShopfrontEmbeddedVerificationToken {\n auth: string;\n id: string;\n app: string;\n user: string;\n url: {\n raw: string;\n loaded: string;\n };\n}\n\nexport interface ShopfrontEmbeddedTokenError {\n error: boolean;\n type: string;\n}\n\nexport class ShopfrontTokenDecodingError extends Error {}\n\nexport class ShopfrontTokenRequestError extends Error {}\n\nexport abstract class BaseApplication {\n protected bridge: BaseBridge;\n protected isReady: boolean;\n protected key: string;\n protected register: string | null;\n protected outlet: string | null;\n protected user: string | null;\n protected signingKey: CryptoKeyPair | undefined;\n protected listeners: {\n [key in ListenableFromShopfrontEvent]: Map<\n AnyFunction,\n FromShopfront[key] & BaseEvent\n >;\n } = {\n READY : new Map(),\n REQUEST_SETTINGS : new Map(),\n REQUEST_BUTTONS : new Map(),\n REQUEST_TABLE_COLUMNS : new Map(),\n REQUEST_SELL_SCREEN_OPTIONS : new Map(),\n INTERNAL_PAGE_MESSAGE : new Map(),\n REGISTER_CHANGED : new Map(),\n FORMAT_INTEGRATED_PRODUCT : new Map(),\n REQUEST_CUSTOMER_LIST_OPTIONS: new Map(),\n REQUEST_SALE_KEYS : new Map(),\n SALE_COMPLETE : new Map(),\n UI_PIPELINE : new Map(),\n PAYMENT_METHODS_ENABLED : new Map(),\n AUDIO_PERMISSION_CHANGE : new Map(),\n AUDIO_READY : new Map(),\n FULFILMENT_GET_ORDER : new Map(),\n FULFILMENT_PROCESS_ORDER : new Map(),\n FULFILMENT_VOID_ORDER : new Map(),\n FULFILMENT_ORDER_APPROVAL : new Map(),\n FULFILMENT_ORDER_COLLECTED : new Map(),\n FULFILMENT_ORDER_COMPLETED : new Map(),\n GIFT_CARD_CODE_CHECK : new Map(),\n };\n protected directListeners: {\n [key in DirectShopfrontEvent]: Map<\n AnyFunction,\n DirectShopfront[key]\n >;\n } = {\n SALE_ADD_PRODUCT : new Map(),\n SALE_REMOVE_PRODUCT : new Map(),\n SALE_CHANGE_QUANTITY: new Map(),\n SALE_UPDATE_PRODUCTS: new Map(),\n SALE_ADD_CUSTOMER : new Map(),\n SALE_REMOVE_CUSTOMER: new Map(),\n SALE_CLEAR : new Map(),\n };\n public database: BaseDatabase;\n\n protected constructor(bridge: BaseBridge, database: BaseDatabase) {\n this.bridge = bridge;\n this.isReady = false;\n this.key = \"\";\n this.register = null;\n this.outlet = null;\n this.user = null;\n this.database = database;\n }\n\n /**\n * Destroy the bridge instance\n */\n public abstract destroy(): void;\n\n /**\n * Handles an application event\n */\n protected abstract handleEvent(\n event: keyof FromShopfront | keyof FromShopfrontInternal,\n data: Record<string, unknown>,\n id: string\n ): void;\n\n /**\n * Calls any registered listeners for the received event\n */\n protected abstract emit(\n event: ListenableFromShopfrontEvent | DirectShopfrontEvent,\n data: Record<string, unknown>,\n id: string\n ): MaybePromise<void>;\n\n /**\n * Register a listener for a Shopfront event\n */\n public addEventListener<E extends ListenableFromShopfrontEvent>(\n event: E,\n callback: FromShopfrontCallbacks[E]\n ): void;\n /**\n * Register a listener for a Shopfront event\n */\n public addEventListener<D extends DirectShopfrontEvent>(\n event: D,\n callback: DirectShopfrontCallbacks[D]\n ): void;\n /**\n * Register a listener for a Shopfront event\n */\n public addEventListener(\n event: ListenableFromShopfrontEvent | DirectShopfrontEvent,\n callback: AnyFunction\n ): void {\n if(isDirectShopfrontEvent(event)) {\n let c;\n\n switch(event) {\n case \"SALE_ADD_PRODUCT\":\n c = new SaleAddProduct(callback);\n this.directListeners[event].set(callback, c);\n\n break;\n case \"SALE_REMOVE_PRODUCT\":\n c = new SaleRemoveProduct(callback);\n this.directListeners[event].set(callback, c);\n\n break;\n case \"SALE_CHANGE_QUANTITY\":\n c = new SaleChangeQuantity(callback);\n this.directListeners[event].set(callback, c);\n\n break;\n case \"SALE_UPDATE_PRODUCTS\":\n c = new SaleUpdateProducts(callback);\n this.directListeners[event].set(callback, c);\n\n break;\n case \"SALE_ADD_CUSTOMER\":\n c = new SaleAddCustomer(callback);\n this.directListeners[event].set(callback, c);\n\n break;\n case \"SALE_REMOVE_CUSTOMER\":\n c = new SaleRemoveCustomer(callback);\n this.directListeners[event].set(callback, c);\n\n break;\n case \"SALE_CLEAR\":\n c = new SaleClear(callback);\n this.directListeners[event].set(callback, c);\n\n break;\n }\n\n if(typeof c === \"undefined\") {\n throw new TypeError(`${event} has not been defined`);\n }\n\n return;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let c: BaseEvent<any, any, any, any, any> | undefined;\n\n switch(event) {\n case \"READY\":\n c = new Ready(callback as FromShopfrontCallbacks[\"READY\"]);\n this.listeners[event].set(callback, c);\n break;\n case \"REQUEST_SETTINGS\":\n c = new RequestSettings(callback as FromShopfrontCallbacks[\"REQUEST_SETTINGS\"]);\n this.listeners[event].set(callback, c);\n break;\n case \"REQUEST_BUTTONS\":\n c = new RequestButtons(callback as FromShopfrontCallbacks[\"REQUEST_BUTTONS\"]);\n this.listeners[event].set(callback, c);\n break;\n case \"REQUEST_TABLE_COLUMNS\":\n c = new RequestTableColumns(callback as FromShopfrontCallbacks[\"REQUEST_TABLE_COLUMNS\"]);\n this.listeners[event].set(callback, c);\n break;\n case \"REQUEST_SELL_SCREEN_OPTIONS\":\n c = new RequestSellScreenOptions(callback as FromShopfrontCallbacks[\"REQUEST_SELL_SCREEN_OPTIONS\"]);\n this.listeners[event].set(callback, c);\n break;\n case \"INTERNAL_PAGE_MESSAGE\":\n c = new InternalPageMessage(\n callback as FromShopfrontCallbacks[\"INTERNAL_PAGE_MESSAGE\"],\n this as unknown as Application\n );\n this.listeners[event].set(callback, c as InternalPageMessage);\n break;\n case \"REGISTER_CHANGED\":\n c = new RegisterChanged(callback as FromShopfrontCallbacks[\"REGISTER_CHANGED\"]);\n this.listeners[event].set(callback, c);\n break;\n case \"REQUEST_CUSTOMER_LIST_OPTIONS\":\n c = new RequestCustomerListOptions(callback as FromShopfrontCallbacks[\"REQUEST_CUSTOMER_LIST_OPTIONS\"]);\n this.listeners[event].set(callback, c);\n break;\n case \"FORMAT_INTEGRATED_PRODUCT\":\n c = new FormatIntegratedProduct(callback as FromShopfrontCallbacks[\"FORMAT_INTEGRATED_PRODUCT\"]);\n this.listeners[event].set(callback, c);\n break;\n case \"REQUEST_SALE_KEYS\":\n c = new RequestSaleKeys(callback as FromShopfrontCallbacks[\"REQUEST_SALE_KEYS\"]);\n this.listeners[event].set(callback, c as RequestSaleKeys);\n break;\n case \"SALE_COMPLETE\":\n c = new SaleComplete(callback as FromShopfrontCallbacks[\"SALE_COMPLETE\"]);\n this.listeners[event].set(callback, c);\n break;\n case \"UI_PIPELINE\":\n c = new UIPipeline(callback as FromShopfrontCallbacks[\"UI_PIPELINE\"]);\n this.listeners[event].set(callback, c);\n break;\n case \"PAYMENT_METHODS_ENABLED\":\n c = new PaymentMethodsEnabled(callback as FromShopfrontCallbacks[\"PAYMENT_METHODS_ENABLED\"]);\n this.listeners[event].set(callback, c);\n break;\n case \"AUDIO_READY\":\n c = new AudioReady(callback as FromShopfrontCallbacks[\"AUDIO_READY\"]);\n this.listeners[event].set(callback, c as AudioReady);\n break;\n case \"AUDIO_PERMISSION_CHANGE\":\n c = new AudioPermissionChange(callback as FromShopfrontCallbacks[\"AUDIO_PERMISSION_CHANGE\"]);\n this.listeners[event].set(callback, c);\n break;\n case \"FULFILMENT_GET_ORDER\":\n if(this.listeners[event].size !== 0) {\n throw new TypeError(\"Application already has 'FULFILMENT_GET_ORDER' event listener registered.\");\n }\n\n c = new FulfilmentGetOrder(callback as FromShopfrontCallbacks[\"FULFILMENT_GET_ORDER\"]);\n this.listeners[event].set(callback, c);\n break;\n case \"FULFILMENT_VOID_ORDER\":\n c = new FulfilmentVoidOrder(callback as FromShopfrontCallbacks[\"FULFILMENT_VOID_ORDER\"]);\n this.listeners[event].set(callback, c);\n break;\n case \"FULFILMENT_PROCESS_ORDER\":\n c = new FulfilmentProcessOrder(callback as FromShopfrontCallbacks[\"FULFILMENT_PROCESS_ORDER\"]);\n this.listeners[event].set(callback, c);\n break;\n case \"FULFILMENT_ORDER_APPROVAL\":\n c = new FulfilmentOrderApproval(callback as FromShopfrontCallbacks[\"FULFILMENT_ORDER_APPROVAL\"]);\n this.listeners[event].set(callback, c);\n break;\n case \"FULFILMENT_ORDER_COLLECTED\":\n c = new FulfilmentCollectOrder(callback as FromShopfrontCallbacks[\"FULFILMENT_ORDER_COLLECTED\"]);\n this.listeners[event].set(callback, c);\n break;\n case \"FULFILMENT_ORDER_COMPLETED\":\n c = new FulfilmentCompleteOrder(callback as FromShopfrontCallbacks[\"FULFILMENT_ORDER_COMPLETED\"]);\n this.listeners[event].set(callback, c);\n break;\n case \"GIFT_CARD_CODE_CHECK\":\n c = new GiftCardCodeCheck(callback as FromShopfrontCallbacks[\"GIFT_CARD_CODE_CHECK\"]);\n this.listeners[event].set(callback, c);\n break;\n }\n\n if(typeof c === \"undefined\") {\n throw new TypeError(`${event} has not been defined`);\n }\n\n if(event === \"READY\" && this.isReady) {\n c = c as Ready;\n c.emit({\n outlet : this.outlet,\n register: this.register,\n user : this.user,\n });\n }\n }\n\n /**\n * Removed a registered listener for a Shopfront event\n */\n public removeEventListener<E extends ListenableFromShopfrontEvent>(\n event: E,\n callback: FromShopfrontCallbacks[E]\n ): void;\n /**\n * Removed a registered listener for a Shopfront event\n */\n public removeEventListener<D extends DirectShopfrontEvent>(\n event: D,\n callback: DirectShopfrontCallbacks[D]\n ): void;\n /**\n * Removed a registered listener for a Shopfront event\n */\n public removeEventListener(\n event: ListenableFromShopfrontEvent | DirectShopfrontEvent,\n callback: AnyFunction\n ): void {\n if(isDirectShopfrontEvent(event)) {\n this.directListeners[event].delete(callback);\n\n return;\n }\n\n this.listeners[event].delete(callback);\n }\n\n /**\n * Send data to Shopfront\n */\n public abstract send(item: BaseEmitableEvent<unknown> | Serializable<unknown>): void;\n\n /**\n * Requests permission from the user to download the specified file\n */\n public abstract download(file: string): void;\n\n /**\n * Redirects the user to the specified location.\n * If `externalRedirect` is `true`, the user is prompted to confirm the redirect.\n */\n public abstract redirect(toLocation: string, externalRedirect: boolean): void;\n\n /**\n * Shows a loading screen in Shopfront\n */\n public abstract load(): () => void;\n\n protected abstract handleEventCallback(data: { id?: string; data: unknown; }): void;\n\n protected abstract handleLocationChanged(data: RegisterChangedEvent): void;\n\n /**\n * Retrieves the cached authentication key\n */\n public abstract getAuthenticationKey(): string;\n\n /**\n * Get the current sale on the sell screen, if the current device is not a register\n * then this will return false.\n */\n public abstract getCurrentSale(): Promise<BaseCurrentSale | false>;\n\n /**\n * Send the sale to be created on shopfront.\n */\n public abstract createSale(sale: Sale): Promise<ShopfrontResponse>;\n\n /**\n * Retrieves the current location data from Shopfront\n */\n public abstract getLocation(): Promise<{\n register: string | null;\n outlet: string | null;\n user: string | null;\n }>;\n\n /**\n * Prints the provided content as a receipt\n */\n public abstract printReceipt(content: string): void;\n\n /**\n * Changes the display mode of the sell screen's `action` container\n */\n public abstract changeSellScreenActionMode(mode: SellScreenActionMode): void;\n\n /**\n * Changes the display mode of the sell screen's 'summary' container\n */\n public abstract changeSellScreenSummaryMode(mode: SellScreenSummaryMode): void;\n\n /**\n * Sends an audio request to Shopfront\n */\n protected abstract sendAudioRequest(type: SoundEvents, data?: unknown): Promise<ShopfrontResponse>;\n\n /**\n * Requests permission from the user to be able to play audio\n */\n public abstract requestAudioPermission(): Promise<ShopfrontResponse>;\n\n /**\n * Requests Shopfront to preload audio so that it can be pre-cached before being played\n */\n public abstract audioPreload(url: string): Promise<ShopfrontResponse>;\n\n /**\n * Attempts to play the provided audio in Shopfront\n */\n public abstract audioPlay(url: string): Promise<ShopfrontResponse>;\n\n /**\n * Retrieve the value of the specified option from Shopfront\n */\n public abstract getOption<TValueType>(option: string, defaultValue: TValueType): Promise<TValueType>;\n\n /**\n * Retrieves an embedded token from Shopfront that can be used to validate server requests\n */\n public abstract getToken(returnTokenObject: true): Promise<ShopfrontEmbeddedVerificationToken>;\n /**\n * Retrieves an embedded token from Shopfront that can be used to validate server requests\n */\n public abstract getToken(returnTokenObject?: false): Promise<string>;\n /**\n * Retrieves an embedded token from Shopfront that can be used to validate server requests\n */\n public abstract getToken(returnTokenObject?: boolean): Promise<string | ShopfrontEmbeddedVerificationToken>;\n}\n","import { type BaseSaleData } from \"../APIs/Sale/BaseSale.js\";\nimport { Sale, SaleProduct, type ShopfrontSalePaymentStatus } from \"../APIs/Sale/index.js\";\n\nexport interface SaleProductData {\n uuid: string;\n caseQuantity: number;\n quantity: number;\n price: number;\n metaData: Record<string, unknown>;\n products: Array<SaleProductData>;\n note: string;\n}\n\nexport interface SalePaymentData {\n method: string;\n type: undefined | string;\n amount: number;\n status: undefined | ShopfrontSalePaymentStatus;\n rounding: number;\n cashout: number;\n metaData: Record<string, unknown>;\n}\n\nexport interface SaleData extends BaseSaleData {\n customer: null | string;\n payments: Array<SalePaymentData>;\n products: Array<SaleProductData>;\n}\n\n/**\n * Builds a Shopfront sale product from the embedded product data\n */\nfunction buildSaleProductData(product: SaleProduct): SaleProductData {\n const price = product.getPrice();\n\n if(typeof price !== \"number\") {\n throw new TypeError(\"Sale Product must have price when creating the sale.\");\n }\n\n const caseQuantity = product.getCaseQuantity();\n\n if(typeof caseQuantity !== \"number\") {\n throw new TypeError(\"Sale Product must have case quantity when creating the sale.\");\n }\n\n return {\n uuid : product.getId(),\n quantity: product.getQuantity(),\n metaData: product.getMetaData(),\n products: product.getContains().map(buildSaleProductData),\n note : product.getNote(),\n caseQuantity,\n price,\n };\n}\n\n/**\n * Builds a Shopfront sale from the embedded sale data\n */\nexport function buildSaleData(sale: Sale): SaleData {\n const customer = sale.getCustomer();\n\n return {\n register: sale.getRegister(),\n clientId: sale.getClientId(),\n notes : {\n internal: sale.getInternalNote(),\n sale : sale.getExternalNote(),\n },\n totals: {\n sale : sale.getSaleTotal(),\n paid : sale.getPaidTotal(),\n savings : sale.getSavingsTotal(),\n discount: sale.getDiscountTotal(),\n },\n linkedTo : sale.getLinkedTo(),\n orderReference: sale.getOrderReference(),\n refundReason : sale.getRefundReason(),\n priceSet : sale.getPriceSet(),\n metaData : sale.getMetaData(),\n customer : customer ? customer.getId() : null,\n products : sale.getProducts().map(buildSaleProductData),\n payments : sale.getPayments().map(payment => ({\n method : payment.getId(),\n type : payment.getType(),\n amount : payment.getAmount(),\n status : payment.getStatus(),\n rounding: payment.getRounding() || 0,\n cashout : payment.getCashout() || 0,\n metaData: payment.getMetaData(),\n })),\n };\n}\n","import { Button } from \"./Actions/Button.js\";\nimport { Database } from \"./APIs/Database/Database.js\";\nimport { CurrentSale } from \"./APIs/Sale/CurrentSale.js\";\nimport { Sale, type ShopfrontSaleState } from \"./APIs/Sale/index.js\";\nimport {\n type DirectShopfrontEvent,\n type FromShopfront,\n type FromShopfrontInternal,\n type FromShopfrontReturns,\n isDirectShopfrontEvent,\n type ListenableFromShopfrontEvent,\n type RegisterChangedEvent,\n type SellScreenActionMode,\n type SellScreenSummaryMode,\n type SoundEvents,\n ToShopfront,\n} from \"./ApplicationEvents.js\";\nimport {\n BaseApplication,\n type ShopfrontEmbeddedTokenError,\n type ShopfrontEmbeddedVerificationToken,\n type ShopfrontResponse,\n ShopfrontTokenDecodingError,\n ShopfrontTokenRequestError,\n} from \"./BaseApplication.js\";\nimport { type ApplicationEventListener } from \"./BaseBridge.js\";\nimport { Bridge, type JavaScriptCommunicatorExports } from \"./Bridge.js\";\nimport { type Serializable } from \"./Common/Serializable.js\";\nimport { BaseEmitableEvent } from \"./EmitableEvents/BaseEmitableEvent.js\";\nimport { FormatIntegratedProduct } from \"./Events/FormatIntegratedProduct.js\";\nimport { FulfilmentGetOrder } from \"./Events/FulfilmentGetOrder.js\";\nimport { GiftCardCodeCheck } from \"./Events/GiftCardCodeCheck.js\";\nimport { PaymentMethodsEnabled } from \"./Events/PaymentMethodsEnabled.js\";\nimport { RequestButtons } from \"./Events/RequestButtons.js\";\nimport { RequestCustomerListOptions } from \"./Events/RequestCustomerListOptions.js\";\nimport { RequestSaleKeys } from \"./Events/RequestSaleKeys.js\";\nimport { RequestSellScreenOptions } from \"./Events/RequestSellScreenOptions.js\";\nimport { RequestSettings } from \"./Events/RequestSettings.js\";\nimport { RequestTableColumns } from \"./Events/RequestTableColumns.js\";\nimport { UIPipeline } from \"./Events/UIPipeline.js\";\nimport ActionEventRegistrar from \"./Utilities/ActionEventRegistrar.js\";\nimport { type MaybePromise } from \"./Utilities/MiscTypes.js\";\nimport { buildSaleData } from \"./Utilities/SaleCreate.js\";\n\nexport class Application extends BaseApplication {\n constructor(bridge: Bridge) {\n super(bridge, new Database(bridge));\n\n this.bridge.addEventListener(this.handleEvent);\n this.addEventListener(\"REGISTER_CHANGED\", this.handleLocationChanged);\n }\n\n /**\n * Get the communicator when using the JavaScript communication method\n */\n public get communicator(): JavaScriptCommunicatorExports {\n if(this.bridge instanceof Bridge) {\n return this.bridge.communicator;\n }\n\n throw new Error(\n \"The provided bridge for the application doesn't support the JavaScript communicator\"\n );\n }\n\n /**\n * @inheritDoc\n */\n public destroy(): void {\n this.bridge.destroy();\n }\n\n /**\n * Handles an application event\n */\n protected handleEvent = (\n event: keyof FromShopfront | keyof FromShopfrontInternal,\n data: Record<string, unknown>,\n id: string\n ): void => {\n if(event === \"READY\") {\n this.isReady = true;\n this.key = data.key as string;\n this.outlet = data.outlet as string;\n this.register = data.register as string;\n\n data = {\n outlet : data.outlet,\n register: data.register,\n };\n }\n\n if(event === \"CALLBACK\") {\n this.handleEventCallback(data as { id?: string; data: unknown; });\n\n return;\n }\n\n if(event === \"CYCLE_KEY\") {\n if(typeof data !== \"object\" || data === null) {\n return;\n }\n\n this.key = data.key as string;\n\n return;\n } else if(event === \"LOCATION_CHANGED\") {\n // Unregister all serialized listeners as they're no longer displayed\n ActionEventRegistrar.clear();\n\n return;\n } else if(\n event === \"RESPONSE_CURRENT_SALE\" ||\n event === \"RESPONSE_DATABASE_REQUEST\" ||\n event === \"RESPONSE_LOCATION\" ||\n event === \"RESPONSE_OPTION\" ||\n event === \"RESPONSE_AUDIO_REQUEST\" ||\n event === \"RESPONSE_SECURE_KEY\" ||\n event === \"RESPONSE_CREATE_SALE\"\n ) {\n // Handled elsewhere\n return;\n }\n\n this.emit(event, data, id);\n };\n\n /**\n * Calls any registered listeners for the received event\n */\n protected emit(\n event: ListenableFromShopfrontEvent | DirectShopfrontEvent,\n data: Record<string, unknown> = {},\n id: string\n ): MaybePromise<void> {\n if(isDirectShopfrontEvent(event)) {\n const listeners = this.directListeners[event];\n\n if(typeof listeners === \"undefined\") {\n return this.bridge.sendMessage(ToShopfront.NOT_LISTENING_TO_EVENT);\n }\n\n const results = [];\n\n for(const e of listeners.values()) {\n results.push(e.emit(data));\n }\n\n return Promise.all(results)\n .then(() => {\n // Ensure void is returned\n });\n }\n\n let results = [];\n\n if(typeof this.listeners[event] === \"undefined\") {\n return this.bridge.sendMessage(ToShopfront.UNSUPPORTED_EVENT, event, id);\n }\n\n if(this.listeners[event].size === 0) {\n return this.bridge.sendMessage(ToShopfront.NOT_LISTENING_TO_EVENT, event, id);\n }\n\n for(const e of this.listeners[event].values()) {\n results.push(e.emit(data, this.bridge) as Promise<FromShopfrontReturns[typeof event]>);\n }\n\n // Respond if necessary\n switch(event) {\n case \"REQUEST_BUTTONS\":\n results = results as Array<Promise<FromShopfrontReturns[\"REQUEST_BUTTONS\"]>>;\n\n return Promise.all(results)\n .then((res: Array<Array<Button>>) => {\n return RequestButtons.respond(this.bridge, res.flat(), id);\n });\n case \"REQUEST_SETTINGS\":\n results = results as Array<Promise<FromShopfrontReturns[\"REQUEST_SETTINGS\"]>>;\n\n return Promise.all(results)\n .then((res: Array<FromShopfrontReturns[\"REQUEST_SETTINGS\"]>) => {\n return RequestSettings.respond(this.bridge, res.flat(), id);\n });\n case \"REQUEST_TABLE_COLUMNS\":\n results = results as Array<Promise<FromShopfrontReturns[\"REQUEST_TABLE_COLUMNS\"]>>;\n\n return Promise.all(results)\n .then((res: Array<FromShopfrontReturns[\"REQUEST_TABLE_COLUMNS\"]>) => {\n return RequestTableColumns.respond(this.bridge, res.flat(), id);\n });\n case \"REQUEST_SELL_SCREEN_OPTIONS\":\n results = results as Array<Promise<FromShopfrontReturns[\"REQUEST_SELL_SCREEN_OPTIONS\"]>>;\n\n return Promise.all(results)\n .then((res: Array<FromShopfrontReturns[\"REQUEST_SELL_SCREEN_OPTIONS\"]>) => {\n return RequestSellScreenOptions.respond(this.bridge, res.flat(), id);\n });\n case \"FORMAT_INTEGRATED_PRODUCT\":\n results = results as Array<Promise<FromShopfrontReturns[\"FORMAT_INTEGRATED_PRODUCT\"]>>;\n\n return Promise.all(results)\n .then((res: Array<FromShopfrontReturns[\"FORMAT_INTEGRATED_PRODUCT\"]>) => {\n return FormatIntegratedProduct.respond(this.bridge, res.flat(), id);\n });\n case \"REQUEST_CUSTOMER_LIST_OPTIONS\":\n results = results as Array<Promise<FromShopfrontReturns[\"REQUEST_CUSTOMER_LIST_OPTIONS\"]>>;\n\n return Promise.all(results)\n .then(res => RequestCustomerListOptions.respond(this.bridge, res.flat(), id));\n case \"REQUEST_SALE_KEYS\":\n results = results as Array<Promise<FromShopfrontReturns[\"REQUEST_SALE_KEYS\"]>>;\n\n return Promise.all(results)\n .then(res => RequestSaleKeys.respond(this.bridge, res.flat(), id));\n case \"UI_PIPELINE\":\n results = results as Array<Promise<FromShopfrontReturns[\"UI_PIPELINE\"]>>;\n\n return Promise.all(results)\n .then(res => {\n return UIPipeline.respond(this.bridge, res.flat(), id);\n });\n case \"GIFT_CARD_CODE_CHECK\":\n results = results as Array<Promise<FromShopfrontReturns[\"GIFT_CARD_CODE_CHECK\"]>>;\n\n return Promise.all(results)\n .then(res => {\n return GiftCardCodeCheck.respond(this.bridge, res[0], id);\n });\n case \"PAYMENT_METHODS_ENABLED\":\n results = results as Array<Promise<FromShopfrontReturns[\"PAYMENT_METHODS_ENABLED\"]>>;\n\n return Promise.all(results)\n .then(res => {\n return PaymentMethodsEnabled.respond(this.bridge, res.flat(), id);\n });\n case \"FULFILMENT_GET_ORDER\":\n results = results as Array<Promise<FromShopfrontReturns[\"FULFILMENT_GET_ORDER\"]>>;\n\n return Promise.all(results)\n .then(res => {\n return FulfilmentGetOrder.respond(this.bridge, res[0], id);\n });\n }\n }\n\n /**\n * @inheritDoc\n */\n public send(item: BaseEmitableEvent<unknown> | Serializable<unknown>): void {\n if(item instanceof Button) {\n throw new TypeError(\"You cannot send Buttons to Shopfront without Shopfront requesting them\");\n }\n\n if(item instanceof BaseEmitableEvent) {\n this.bridge.sendMessage(item.getEvent(), item.getData());\n } else {\n const serialized = item.serialize();\n\n this.bridge.sendMessage(ToShopfront.SERIALIZED, serialized);\n }\n }\n\n /**\n * @inheritDoc\n */\n public download(file: string): void {\n this.bridge.sendMessage(ToShopfront.DOWNLOAD, file);\n }\n\n /**\n * @inheritDoc\n */\n public redirect(toLocation: string, externalRedirect = true): void {\n this.bridge.sendMessage(ToShopfront.REDIRECT, {\n to : toLocation,\n external: externalRedirect,\n });\n }\n\n /**\n * @inheritDoc\n */\n public load(): () => void {\n this.bridge.sendMessage(ToShopfront.LOAD, true);\n\n return () => this.bridge.sendMessage(ToShopfront.LOAD, false);\n }\n\n /**\n * Handles an event callback via the `ActionEventRegistrar`\n */\n protected handleEventCallback(data: { id?: string; data: unknown; }): void {\n if(typeof data.id === \"undefined\") {\n return;\n }\n\n const id = data.id;\n\n ActionEventRegistrar.fire(id, data.data);\n }\n\n /**\n * Updates the cached location data\n */\n protected handleLocationChanged(data: RegisterChangedEvent): undefined {\n this.register = data.register;\n this.outlet = data.outlet;\n this.user = data.user;\n }\n\n /**\n * @inheritDoc\n */\n public getAuthenticationKey(): string {\n return this.key;\n }\n\n /**\n * Checks whether `data` is formatted as a sale event\n */\n protected dataIsSaleEvent(data: Record<string, unknown>): data is {\n requestId: string;\n saleState: ShopfrontSaleState | false;\n } {\n return typeof data.requestId === \"string\" && (data.saleState === false || typeof data.saleState === \"object\");\n }\n\n /**\n * @inheritDoc\n */\n public async getCurrentSale(): Promise<CurrentSale | false> {\n const saleRequest = `SaleRequest-${Date.now().toString()}`;\n\n const promise = new Promise<ShopfrontSaleState | false>(res => {\n const listener = (\n event: keyof FromShopfrontInternal | keyof FromShopfront,\n data: Record<string, unknown>\n ) => {\n if(event !== \"RESPONSE_CURRENT_SALE\") {\n return;\n }\n\n if(!this.dataIsSaleEvent(data)) {\n return;\n }\n\n if(data.requestId !== saleRequest) {\n return;\n }\n\n this.bridge.removeEventListener(listener);\n res(data.saleState);\n };\n\n this.bridge.addEventListener(listener);\n });\n\n this.bridge.sendMessage(ToShopfront.REQUEST_CURRENT_SALE, {\n requestId: saleRequest,\n });\n\n const saleState = await promise;\n\n if(saleState === false) {\n return saleState;\n }\n\n return new CurrentSale(this, saleState);\n }\n\n /**\n * Checks whether `data` is formatted as response data from a 'create sale' request\n */\n protected dataIsCreateEvent(data: Record<string, unknown>): data is {\n requestId: string;\n success: boolean;\n message?: string;\n } {\n return typeof data.requestId === \"string\" &&\n typeof data.success === \"boolean\" &&\n (\n typeof data.message === \"undefined\" || typeof data.message === \"string\"\n );\n }\n\n /**\n * @inheritDoc\n */\n public async createSale(sale: Sale): Promise<{\n success: boolean;\n message?: string;\n }> {\n const createSaleRequest = `CreateSaleRequest-${Date.now().toString()}`;\n\n const promise = new Promise<{\n success: boolean;\n message?: string;\n }>(res => {\n const listener = (\n event: keyof FromShopfrontInternal | keyof FromShopfront,\n data: Record<string, unknown>\n ) => {\n if(event !== \"RESPONSE_CREATE_SALE\") {\n return;\n }\n\n if(!this.dataIsCreateEvent(data)) {\n return;\n }\n\n if(data.requestId !== createSaleRequest) {\n return;\n }\n\n this.bridge.removeEventListener(listener);\n res({\n success: data.success,\n message: data.message,\n });\n };\n\n this.bridge.addEventListener(listener);\n });\n\n this.bridge.sendMessage(ToShopfront.CREATE_SALE, {\n requestId: createSaleRequest,\n sale : buildSaleData(sale),\n });\n\n return promise;\n }\n\n /**\n * Checks whether `data` is formatted as location data\n */\n protected dataIsLocation(data: Record<string, unknown>): data is {\n requestId: string;\n register: string | null;\n outlet: string | null;\n user: string | null;\n } {\n return typeof data.requestId === \"string\" &&\n (typeof data.register === \"string\" || data.register === null) &&\n (typeof data.outlet === \"string\" || data.outlet === null) &&\n (typeof data.user === \"string\" || data.user === null);\n }\n\n /**\n * @inheritDoc\n */\n public async getLocation(): Promise<{\n register: string | null;\n outlet: string | null;\n user: string | null;\n }> {\n const locationRequest = `LocationRequest-${Date.now().toString()}`;\n\n const promise = new Promise<{\n register: string | null;\n outlet: string | null;\n user: string | null;\n }>(res => {\n const listener = (\n event: keyof FromShopfrontInternal | keyof FromShopfront,\n data: Record<string, unknown>\n ) => {\n if(event !== \"RESPONSE_LOCATION\") {\n return;\n }\n\n if(!this.dataIsLocation(data)) {\n return;\n }\n\n if(data.requestId !== locationRequest) {\n return;\n }\n\n this.bridge.removeEventListener(listener);\n res(data);\n };\n\n this.bridge.addEventListener(listener);\n });\n\n this.bridge.sendMessage(ToShopfront.REQUEST_LOCATION, {\n requestId: locationRequest,\n });\n\n const location = await promise;\n\n return {\n register: location.register,\n outlet : location.outlet,\n user : location.user,\n };\n }\n\n /**\n * @inheritDoc\n */\n public printReceipt(content: string): void {\n this.bridge.sendMessage(ToShopfront.PRINT_RECEIPT, {\n content,\n type: \"text\",\n });\n }\n\n /**\n * @inheritDoc\n */\n public changeSellScreenActionMode(mode: SellScreenActionMode): void {\n this.bridge.sendMessage(ToShopfront.CHANGE_SELL_SCREEN_ACTION_MODE, {\n mode,\n });\n }\n\n /**\n * @inheritDoc\n */\n public changeSellScreenSummaryMode(mode: SellScreenSummaryMode): void {\n this.bridge.sendMessage(ToShopfront.CHANGE_SELL_SCREEN_SUMMARY_MODE, {\n mode,\n });\n }\n\n /**\n * Checks whether `data` is formatted as an audio response\n */\n protected dataIsAudioResponse(data: Record<string, unknown>): data is {\n requestId: string;\n success: boolean;\n message?: string;\n } {\n return typeof data.requestId === \"string\" &&\n typeof data.success === \"boolean\" &&\n (\n typeof data.message === \"string\" ||\n typeof data.message === \"undefined\"\n );\n }\n\n /**\n * Sends an audio request to Shopfront\n */\n protected sendAudioRequest(type: SoundEvents, data?: unknown): Promise<ShopfrontResponse> {\n const request = `AudioRequest-${type}-${Date.now().toString()}`;\n\n const promise = new Promise<ShopfrontResponse>(res => {\n const listener = (\n event: keyof FromShopfrontInternal | keyof FromShopfront,\n data: Record<string, unknown>\n ) => {\n if(event !== \"RESPONSE_AUDIO_REQUEST\") {\n return;\n }\n\n if(!this.dataIsAudioResponse(data)) {\n return;\n }\n\n if(data.requestId !== request) {\n return;\n }\n\n this.bridge.removeEventListener(listener);\n\n res({\n success: data.success,\n message: data.message,\n });\n };\n\n this.bridge.addEventListener(listener);\n });\n\n this.bridge.sendMessage(type, {\n requestId: request,\n data,\n });\n\n return promise;\n }\n\n /**\n * @inheritDoc\n */\n public requestAudioPermission(): Promise<ShopfrontResponse> {\n return this.sendAudioRequest(ToShopfront.AUDIO_REQUEST_PERMISSION);\n }\n\n /**\n * @inheritDoc\n */\n public audioPreload(url: string): Promise<ShopfrontResponse> {\n return this.sendAudioRequest(\n ToShopfront.AUDIO_PRELOAD,\n {\n url,\n }\n );\n }\n\n /**\n * @inheritDoc\n */\n public audioPlay(url: string): Promise<ShopfrontResponse> {\n return this.sendAudioRequest(\n ToShopfront.AUDIO_PLAY,\n {\n url,\n }\n );\n }\n\n /**\n * Checks whether `data` is formatted as response data to a 'get option' request\n */\n protected dataIsOption<TValueType>(data: Record<string, unknown>): data is {\n requestId: string;\n option: string;\n value: TValueType | undefined;\n } {\n return typeof data.requestId === \"string\" && typeof data.option === \"string\";\n }\n\n /**\n * @inheritDoc\n */\n public async getOption<TValueType>(option: string, defaultValue: TValueType): Promise<TValueType> {\n const request = `OptionRequest-${Date.now().toString()}`;\n\n const promise = new Promise<TValueType | undefined>(res => {\n const listener = (\n event: keyof FromShopfrontInternal | keyof FromShopfront,\n data: Record<string, unknown>\n ) => {\n if(event !== \"RESPONSE_OPTION\") {\n return;\n }\n\n if(!this.dataIsOption<TValueType>(data)) {\n return;\n }\n\n if(data.requestId !== request) {\n return;\n }\n\n this.bridge.removeEventListener(listener);\n res(data.value);\n };\n\n this.bridge.addEventListener(listener);\n });\n\n this.bridge.sendMessage(ToShopfront.GET_OPTION, {\n requestId: request,\n option,\n });\n\n const optionValue = await promise;\n\n if(typeof optionValue === \"undefined\") {\n return defaultValue;\n }\n\n return optionValue;\n }\n\n /**\n * Checks whether `data` is formatted as response data to an embedded token request\n */\n protected dataIsEmbeddedToken(data: Record<string, unknown>): data is {\n requestId: string;\n data: BufferSource;\n signature: BufferSource;\n } {\n return typeof data.requestId === \"string\" && typeof data.data === \"object\" && data.data !== null;\n }\n\n /**\n * Generates a signing key and sends it to Shopfront\n */\n protected async generateSigningKey(): Promise<void> {\n if(typeof this.signingKey !== \"undefined\") {\n return;\n }\n\n this.signingKey = await crypto.subtle.generateKey({\n name : \"ECDSA\",\n namedCurve: \"P-384\",\n }, true, [ \"sign\", \"verify\" ]);\n\n this.bridge.sendMessage(ToShopfront.ROTATE_SIGNING_KEY, await crypto.subtle.exportKey(\n \"jwk\",\n this.signingKey.privateKey\n ));\n }\n\n /**\n * Decodes the embedded token response from Shopfront using the signing key\n */\n protected async decodeToken(\n signature: BufferSource,\n data: BufferSource,\n returnTokenObject?: boolean\n ): Promise<ShopfrontEmbeddedVerificationToken | string> {\n if(typeof this.signingKey === \"undefined\") {\n // Not possible to decode\n throw new Error(\"Unable to decode token due to a missing signing key\");\n }\n\n if(!(\n await crypto.subtle.verify({\n name: \"ECDSA\",\n hash: {\n name: \"SHA-384\",\n },\n }, this.signingKey.publicKey, signature, data)\n )) {\n throw new ShopfrontTokenDecodingError();\n }\n\n const decoded = JSON.parse(new TextDecoder().decode(data)) as ShopfrontEmbeddedVerificationToken;\n\n if(decoded.app !== this.bridge.key) {\n throw new ShopfrontTokenDecodingError();\n }\n\n if(decoded.url.loaded !== location.href) {\n throw new ShopfrontTokenDecodingError();\n }\n\n if(returnTokenObject) {\n return decoded;\n }\n\n return decoded.auth;\n }\n\n /**\n * Checks whether `data` is an error response from an embedded token request\n */\n protected tokenDataContainsErrors(data: unknown): data is ShopfrontEmbeddedTokenError {\n if(!data || typeof data !== \"object\") {\n return false;\n }\n\n return \"error\" in data && \"type\" in data;\n }\n\n /**\n * @inheritDoc\n */\n public getToken(returnTokenObject: true): Promise<ShopfrontEmbeddedVerificationToken>;\n /**\n * @inheritDoc\n */\n public getToken(returnTokenObject?: false): Promise<string>;\n /**\n * @inheritDoc\n */\n public async getToken(returnTokenObject?: boolean): Promise<string | ShopfrontEmbeddedVerificationToken> {\n await this.generateSigningKey();\n\n const request = `TokenRequest-${Date.now().toString()}`;\n const promise = new Promise<[BufferSource, BufferSource]>(res => {\n const listener: ApplicationEventListener = (event, data) => {\n if(event !== \"RESPONSE_SECURE_KEY\") {\n return;\n }\n\n if(!this.dataIsEmbeddedToken(data)) {\n return;\n }\n\n if(data.requestId !== request) {\n return;\n }\n\n this.bridge.removeEventListener(listener);\n res([ data.signature, data.data ]);\n };\n\n this.bridge.addEventListener(listener);\n });\n\n this.bridge.sendMessage(ToShopfront.REQUEST_SECURE_KEY, {\n requestId: request,\n });\n\n const [ signature, data ] = await promise;\n\n // Throw the error if there is one\n if(this.tokenDataContainsErrors(data)) {\n throw new ShopfrontTokenRequestError(data.type);\n }\n\n return this.decodeToken(signature, data, returnTokenObject);\n }\n}\n","import { ToShopfront } from \"../../ApplicationEvents.js\";\nimport { BaseEmitableEvent } from \"../BaseEmitableEvent.js\";\n\nexport interface FulfilmentOptions {\n requireApproval: boolean;\n}\n\nexport class Options extends BaseEmitableEvent<FulfilmentOptions> {\n constructor(options: FulfilmentOptions) {\n super(ToShopfront.FULFILMENT_OPTIONS, options);\n }\n}\n","import { ToShopfront } from \"../../ApplicationEvents.js\";\nimport { BaseEmitableEvent } from \"../BaseEmitableEvent.js\";\n\nexport class OrderCancel extends BaseEmitableEvent<{\n id: string;\n}> {\n constructor(id: string) {\n super(ToShopfront.FULFILMENT_ORDERS_CANCEL, {\n id,\n });\n }\n}\n","import { type OrderCreateDetails } from \"../../APIs/Fulfilment/FulfilmentTypes.js\";\nimport { ToShopfront } from \"../../ApplicationEvents.js\";\nimport { BaseEmitableEvent } from \"../BaseEmitableEvent.js\";\n\nexport class OrderCreate extends BaseEmitableEvent<{\n order: OrderCreateDetails;\n}> {\n constructor(order: OrderCreateDetails) {\n super(ToShopfront.FULFILMENT_ORDERS_CREATE, {\n order,\n });\n }\n}\n","import { type OrderCreateDetails } from \"../../APIs/Fulfilment/FulfilmentTypes.js\";\nimport { ToShopfront } from \"../../ApplicationEvents.js\";\nimport { BaseEmitableEvent } from \"../BaseEmitableEvent.js\";\n\nexport class OrdersSync extends BaseEmitableEvent<{\n orders: Array<OrderCreateDetails>;\n merge: boolean;\n}> {\n constructor(orders: Array<OrderCreateDetails>, merge: boolean) {\n super(ToShopfront.FULFILMENT_ORDERS_SYNC, {\n orders,\n merge,\n });\n }\n}\n","import { type OrderSummaryDetails } from \"../../APIs/Fulfilment/FulfilmentTypes.js\";\nimport { ToShopfront } from \"../../ApplicationEvents.js\";\nimport { BaseEmitableEvent } from \"../BaseEmitableEvent.js\";\n\nexport class OrderUpdate extends BaseEmitableEvent<{\n order: OrderSummaryDetails;\n}> {\n constructor(order: OrderSummaryDetails) {\n super(ToShopfront.FULFILMENT_ORDERS_UPDATE, {\n order,\n });\n }\n}\n","import { ToShopfront } from \"../../ApplicationEvents.js\";\nimport { BaseEmitableEvent } from \"../BaseEmitableEvent.js\";\nimport { type FulfilmentOptions } from \"./Options.js\";\n\n/**\n * Registers intent from the application to use the Fulfilment API\n * this event is not required but recommended to show the Fulfilment UI in shopfront sooner\n */\nexport class RegisterIntent extends BaseEmitableEvent<{\n options?: FulfilmentOptions;\n}> {\n constructor(options: FulfilmentOptions) {\n super(ToShopfront.FULFILMENT_OPT_IN, {\n options,\n });\n }\n}\n","import { ToShopfront } from \"../ApplicationEvents.js\";\nimport type { SellScreenOption as Option } from \"../Events/RequestSellScreenOptions.js\";\nimport { RequestSellScreenOptions } from \"../Events/RequestSellScreenOptions.js\";\nimport { BaseEmitableEvent } from \"./BaseEmitableEvent.js\";\n\nexport class SellScreenOption extends BaseEmitableEvent<Option> {\n constructor(url: string, title: string) {\n RequestSellScreenOptions.validateURL(url);\n\n super(ToShopfront.SELL_SCREEN_OPTION_CHANGE, {\n id: RequestSellScreenOptions.getOptionId(url),\n url,\n title,\n });\n }\n}\n","import { ToShopfront } from \"../ApplicationEvents.js\";\nimport { BaseEmitableEvent } from \"./BaseEmitableEvent.js\";\n\nexport interface PromotionApplicableData {\n enable: boolean;\n key: string;\n}\n\nexport class SellScreenPromotionApplicable extends BaseEmitableEvent<PromotionApplicableData> {\n /**\n * Enable or disable a set of already created \"applicable\" promotions\n * @param key {string} The key to enable or disable, this supports wildcards using an asterisk\n * @param enable {boolean} Whether the key should be enabled or disabled\n */\n constructor(key: string, enable: boolean) {\n super(ToShopfront.SELL_SCREEN_PROMOTION_APPLICABLE, {\n key,\n enable,\n });\n }\n}\n","import { type FromShopfrontReturns, ToShopfront } from \"../ApplicationEvents.js\";\nimport { BaseEmitableEvent } from \"./BaseEmitableEvent.js\";\n\nexport class TableUpdate extends BaseEmitableEvent<{\n location: string;\n data: Exclude<FromShopfrontReturns[\"REQUEST_TABLE_COLUMNS\"], null>;\n}> {\n constructor(location: string, columns: Exclude<FromShopfrontReturns[\"REQUEST_TABLE_COLUMNS\"], null>) {\n super(ToShopfront.TABLE_UPDATE, {\n location,\n data: columns,\n });\n }\n}\n","import { BaseCurrentSale } from \"../../../APIs/Sale/BaseCurrentSale.js\";\nimport { ProductNotExistsError, SaleCancelledError } from \"../../../APIs/Sale/Exceptions.js\";\nimport {\n SaleCustomer,\n SalePayment,\n SaleProduct,\n type ShopfrontSaleState,\n} from \"../../../APIs/Sale/index.js\";\nimport {\n type DirectShopfrontEvent,\n type DirectShopfrontEventData,\n} from \"../../../ApplicationEvents.js\";\nimport { type SaleEventProduct } from \"../../../Events/DirectEvents/types/SaleEventData.js\";\nimport { MockApplication } from \"../../MockApplication.js\";\n\nconst emptySaleState: ShopfrontSaleState = {\n clientId: undefined,\n register: undefined,\n products: [],\n customer: false,\n payments: [],\n notes : {\n sale : \"\",\n internal: \"\",\n },\n totals: {\n sale : 0,\n paid : 0,\n savings : 0,\n discount: 0,\n },\n linkedTo : \"\",\n orderReference: \"\",\n refundReason : \"\",\n priceSet : null,\n metaData : {},\n};\n\nexport class MockCurrentSale extends BaseCurrentSale {\n constructor(application: MockApplication, saleState?: ShopfrontSaleState) {\n super(application, saleState ?? emptySaleState);\n }\n\n /**\n * Fires the event trigger\n */\n protected async triggerEvent<Event extends DirectShopfrontEvent>(\n event: Event,\n data: DirectShopfrontEventData[Event]\n ): Promise<void> {\n if(this.application instanceof MockApplication) {\n switch(event) {\n case \"SALE_ADD_PRODUCT\":\n await this.application.fireEvent(\n \"SALE_ADD_PRODUCT\",\n data as DirectShopfrontEventData[\"SALE_ADD_PRODUCT\"]\n );\n\n break;\n case \"SALE_REMOVE_PRODUCT\":\n await this.application.fireEvent(\n \"SALE_REMOVE_PRODUCT\",\n data as DirectShopfrontEventData[\"SALE_REMOVE_PRODUCT\"]\n );\n\n break;\n case \"SALE_CHANGE_QUANTITY\":\n await this.application.fireEvent(\n \"SALE_CHANGE_QUANTITY\",\n data as DirectShopfrontEventData[\"SALE_CHANGE_QUANTITY\"]\n );\n\n break;\n case \"SALE_UPDATE_PRODUCTS\":\n await this.application.fireEvent(\n \"SALE_UPDATE_PRODUCTS\",\n data as DirectShopfrontEventData[\"SALE_UPDATE_PRODUCTS\"]\n );\n\n break;\n case \"SALE_ADD_CUSTOMER\":\n await this.application.fireEvent(\n \"SALE_ADD_CUSTOMER\",\n data as DirectShopfrontEventData[\"SALE_ADD_CUSTOMER\"]\n );\n\n break;\n case \"SALE_REMOVE_CUSTOMER\":\n await this.application.fireEvent(\"SALE_REMOVE_CUSTOMER\");\n\n break;\n case \"SALE_CLEAR\":\n await this.application.fireEvent(\"SALE_CLEAR\");\n\n break;\n }\n } else {\n throw new Error(\"Manually firing events is only supported in the `MockApplication`\");\n }\n }\n\n /**\n * Check if the sale has already been cancelled, if it has, throw a SaleCancelledError.\n */\n protected checkIfCancelled(): void {\n if(this.cancelled) {\n throw new SaleCancelledError();\n }\n }\n\n /**\n * @inheritDoc\n */\n public async refreshSale(): Promise<void> {\n /* Do nothing */\n }\n\n /**\n * @inheritDoc\n */\n public async cancelSale(): Promise<void> {\n this.clearSale();\n\n this.cancelled = true;\n }\n\n /**\n * Round the price to the specified decimal place\n */\n protected roundNumber(price: number, precision = 2): number {\n const multiplier = Math.pow(10, precision);\n\n return Math.round(price * multiplier) / multiplier;\n }\n\n /**\n * Updates the sale total by adding the specified `amount`\n */\n protected updateSaleTotal(amount: number): void {\n this.sale.totals.sale += amount;\n this.sale.totals.sale = this.roundNumber(this.sale.totals.sale);\n };\n\n /**\n * Updates the paid total by adding the specified `amount`\n */\n protected updatePaidTotal(amount: number): void {\n this.sale.totals.paid += amount;\n this.sale.totals.paid = this.roundNumber(this.sale.totals.paid);\n };\n\n /**\n * Updates the sale total when a product's price is changed\n */\n protected handleSaleProductPriceChange(index: number, currentPrice: number, newPrice: number): void {\n // Editing the property directly to avoid triggering the `wasPriceModified` flag\n this.products[index][\"price\"] = newPrice;\n\n const difference = newPrice - currentPrice;\n\n this.updateSaleTotal(difference);\n };\n\n /**\n * @inheritDoc\n */\n public async addProduct(product: SaleProduct): Promise<void> {\n this.checkIfCancelled();\n\n // Check if product already exists in the sale\n try {\n // If it does, update it\n const index = this.getIndexOfProduct(product);\n\n // TODO: Does not currently support not consolidating\n // If a product is added again with a different price, the new price is ignored\n // This behaviour was taken from the `addProductToSale` function in the POS\n\n const currentPrice = this.products[index].getPrice() || 0;\n\n const currentRate = currentPrice / this.products[index].getQuantity();\n\n // Editing the property directly to avoid triggering the `wasQuantityModified` flag\n this.products[index][\"quantity\"] += product.getQuantity();\n\n const newPrice = this.roundNumber(currentRate * this.products[index].getQuantity());\n\n this.handleSaleProductPriceChange(index, currentPrice, newPrice);\n\n await this.triggerEvent(\"SALE_UPDATE_PRODUCTS\", { products: [] });\n\n return;\n } catch(e) {\n // We want to throw the error unless it's because the product isn't in the sale\n if(!(e instanceof ProductNotExistsError)) {\n throw e;\n }\n }\n\n product[\"indexAddress\"] = this.products.length === 0 ? [ 0 ] : [ this.products.length ];\n product[\"edited\"] = false;\n\n this.products.push(this.cloneProduct(product));\n\n this.updateSaleTotal(product.getPrice() || 0);\n\n await this.triggerEvent(\"SALE_ADD_PRODUCT\", {\n product : this.generateSaleEventProduct(product),\n indexAddress: product.getIndexAddress(),\n });\n\n await this.triggerEvent(\"SALE_UPDATE_PRODUCTS\", {\n products: [ this.generateSaleEventProduct(product) ],\n });\n }\n\n /**\n * @inheritDoc\n */\n public async removeProduct(product: SaleProduct): Promise<void> {\n this.checkIfCancelled();\n\n if(this.products.length === 1 && this.sale.totals.paid !== 0) {\n throw new Error(\n \"Cannot remove the last product from the sale if the sale contains an outstanding balance\"\n );\n }\n\n const index = this.getIndexOfProduct(product);\n\n this.products.splice(index, 1);\n\n this.updateSaleTotal((product.getPrice() || 0) * -1);\n\n // Reshuffle the index addresses\n for(let i = 0, l = this.products.length; i < l; i++) {\n this.products[i][\"indexAddress\"] = [ i ];\n }\n\n await this.triggerEvent(\"SALE_REMOVE_PRODUCT\", {\n indexAddress: product.getIndexAddress(),\n });\n }\n\n /**\n * @inheritDoc\n */\n public async addPayment(payment: SalePayment): Promise<void> {\n this.checkIfCancelled();\n\n this.payments.push(this.clonePayment(payment));\n\n if(payment.getStatus() === \"cancelled\" || payment.getStatus() === \"failed\") {\n // No need to update any of the totals\n return;\n }\n\n this.updatePaidTotal(payment.getAmount() - (payment.getCashout() || 0));\n\n const remaining = this.roundNumber(this.sale.totals.sale - this.sale.totals.paid);\n\n if(remaining <= 0) {\n this.clearSale();\n\n await this.triggerEvent(\"SALE_CLEAR\", undefined);\n }\n }\n\n /**\n * @inheritDoc\n */\n public async reversePayment(payment: SalePayment): Promise<void> {\n this.checkIfCancelled();\n\n // Should not be reverse-able past 0\n if(this.sale.totals.paid - payment.getAmount() < 0) {\n throw new Error(\"The paid total cannot be less than 0\");\n }\n\n const reversed = this.clonePayment(payment, true);\n\n this.payments.push(reversed);\n\n if(payment.getStatus() === \"cancelled\" || payment.getStatus() === \"failed\") {\n // No need to update any of the totals\n return;\n }\n\n this.updatePaidTotal(reversed.getAmount());\n }\n\n /**\n * @inheritDoc\n */\n public async addCustomer(customer: SaleCustomer): Promise<void> {\n this.checkIfCancelled();\n\n this.customer = customer;\n\n await this.triggerEvent(\"SALE_ADD_CUSTOMER\", {\n customer: {\n uuid: customer.getId(),\n },\n });\n }\n\n /**\n * @inheritDoc\n */\n public async removeCustomer(): Promise<void> {\n this.checkIfCancelled();\n\n this.customer = null;\n\n await this.triggerEvent(\"SALE_REMOVE_CUSTOMER\", undefined);\n }\n\n /**\n * @inheritDoc\n */\n public async setExternalNote(note: string, append?: boolean): Promise<void> {\n this.checkIfCancelled();\n\n let toSet;\n\n if(append) {\n toSet = `${this.sale.notes.sale}${note}`;\n } else {\n toSet = note;\n }\n\n this.sale.notes.sale = toSet;\n }\n\n /**\n * @inheritDoc\n */\n public async setInternalNote(note: string, append?: boolean): Promise<void> {\n this.checkIfCancelled();\n\n let toSet;\n\n if(append) {\n toSet = `${this.sale.notes.internal}${note}`;\n } else {\n toSet = note;\n }\n\n this.sale.notes.internal = toSet;\n }\n\n /**\n * @inheritDoc\n */\n public async setOrderReference(reference: string): Promise<void> {\n this.checkIfCancelled();\n\n this.sale.orderReference = reference;\n }\n\n /**\n * @inheritDoc\n */\n public async setMetaData(metaData: Record<string, unknown>): Promise<void> {\n this.checkIfCancelled();\n\n this.sale.metaData = metaData;\n }\n\n /**\n * @inheritDoc\n */\n public async updateProduct(product: SaleProduct): Promise<void> {\n this.checkIfCancelled();\n\n const index = this.getIndexOfProduct(product);\n\n if(product.wasQuantityModified()) {\n const currentPrice = this.products[index].getPrice() || 0;\n const currentRate = this.roundNumber(currentPrice / this.products[index].getQuantity());\n\n this.products[index][\"quantity\"] = product.getQuantity();\n\n const newPrice = this.roundNumber(currentRate * product.getQuantity());\n\n this.handleSaleProductPriceChange(index, currentPrice, newPrice);\n }\n\n if(product.wasPriceModified()) {\n const currentPrice = this.products[index].getPrice() || 0;\n const newPrice = product.getPrice() || 0;\n\n this.handleSaleProductPriceChange(index, currentPrice, newPrice);\n }\n\n if(product.wasMetaDataModified()) {\n this.products[index][\"metaData\"] = product.getMetaData();\n }\n\n product.clearModificationFlags();\n\n await this.triggerEvent(\"SALE_UPDATE_PRODUCTS\", {\n products: [ this.generateSaleEventProduct(product) ],\n });\n }\n\n /**\n * Retrieves the index of a product in the sale\n */\n protected getIndexOfProduct(product: SaleProduct): number {\n const index = this.products.findIndex((p) => p.getId() === product.getId());\n\n if(index === -1) {\n throw new ProductNotExistsError();\n }\n\n return index;\n }\n\n /**\n * Clones a sale product so it can be added to the sale\n */\n protected cloneProduct(product: SaleProduct): SaleProduct {\n const clone = new SaleProduct(\n product.getId(),\n product.getQuantity(),\n product.getPrice(),\n product.getIndexAddress()\n );\n\n clone[\"note\"] = product[\"note\"];\n clone[\"contains\"] = product[\"contains\"];\n clone[\"edited\"] = product[\"edited\"];\n clone[\"promotions\"] = product[\"promotions\"];\n clone[\"metaData\"] = product[\"metaData\"];\n clone[\"quantityModified\"] = product[\"quantityModified\"];\n clone[\"priceModified\"] = product[\"priceModified\"];\n clone[\"metaDataModified\"] = product[\"metaDataModified\"];\n\n return clone;\n }\n\n /**\n * Clones a sale payment so it can be added to the sale\n */\n protected clonePayment(payment: SalePayment, reverse = false): SalePayment {\n const updatedAmount = reverse ? payment.getAmount() * -1 : payment.getAmount();\n\n const clone = new SalePayment(\n payment.getId(),\n updatedAmount,\n payment.getCashout(),\n payment.getStatus()\n );\n\n clone[\"metaData\"] = payment[\"metaData\"];\n\n return clone;\n }\n\n /**\n * Generates a SaleEventProduct from a SaleProduct\n */\n protected generateSaleEventProduct(product: SaleProduct): SaleEventProduct {\n return {\n uuid : product.getId(),\n type : product.getType() ?? \"Product\",\n name : product.getName() ?? \"Unknown Product\",\n caseQuantity: product.getCaseQuantity() ?? 1,\n isCase : (product.getCaseQuantity() ?? 1) / product.getQuantity() === 0,\n quantity : product.getQuantity(),\n loyalty : {\n earn : 0,\n redeem: 0,\n },\n prices: {\n price : 0,\n unlockedPrice : 0,\n normal : 0,\n base : 0,\n addPrice : 0,\n removePrice : 0,\n additionalPrice: 0,\n },\n tax: {\n id : \"tax-rate-id\",\n amount: 0,\n },\n surcharge : null,\n products : [],\n defaultProducts : [],\n preventManualDiscount: false,\n special : false,\n edited : false,\n promotions : {},\n rebates : {},\n giftCard : null,\n note : \"\",\n userId : null,\n familyId : null,\n categoryId : null,\n tags : [],\n canUnlock : false,\n lockQuantity : false,\n metaData : product.getMetaData(),\n lineId : \"\",\n priceList : false,\n };\n }\n\n /**\n * Clear the sale data\n */\n public clearSale(): void {\n this.products.length = 0;\n this.products.push(...[]);\n\n this.payments.length = 0;\n this.payments.push(...[]);\n\n this.customer = null;\n this.sale = {\n register: undefined,\n clientId: undefined,\n notes : {\n sale : \"\",\n internal: \"\",\n },\n totals: {\n sale : 0,\n paid : 0,\n savings : 0,\n discount: 0,\n },\n linkedTo : \"\",\n orderReference: \"\",\n refundReason : \"\",\n priceSet : null,\n metaData : {},\n };\n }\n}\n","import * as ApplicationEvents from \"../ApplicationEvents.js\";\nimport { type ApplicationEventListener, BaseBridge } from \"../BaseBridge.js\";\n\nexport class MockBridge extends BaseBridge {\n protected isReady = false;\n\n constructor(key: string, url: string) {\n super(key, url);\n\n this.registerListeners();\n this.sendMessage(ApplicationEvents.ToShopfront.READY);\n }\n\n /**\n * @inheritDoc\n */\n public destroy(): void {\n this.listeners = [];\n }\n\n /**\n * @inheritDoc\n */\n protected registerListeners(): void {\n /* Do nothing */\n }\n\n /**\n * @inheritDoc\n */\n protected unregisterListeners(): void {\n /* Do nothing */\n }\n\n /**\n * @inheritDoc\n */\n public async sendMessage(type: ApplicationEvents.ToShopfront, data?: unknown, id?: string): Promise<void> {\n if(type === ApplicationEvents.ToShopfront.READY) {\n if(typeof data !== \"undefined\") {\n throw new TypeError(\"The `data` parameter must be undefined when requesting ready state\");\n }\n\n if(this.isReady) {\n throw new Error(\"Shopfront is already ready\");\n }\n\n const listeners = this.listeners;\n\n // We can fire off a READY event straight away\n for(let i = 0, l = listeners.length; i < l; i++) {\n listeners[i](type, {\n key : \"signing-key-uuid\",\n outlet : \"outlet-uuid\",\n register: \"register-uuid\",\n }, id as string);\n }\n\n return;\n }\n\n // No need to do anything\n }\n\n /**\n * @inheritDoc\n */\n public addEventListener(listener: ApplicationEventListener): void {\n if(this.listeners.includes(listener)) {\n throw new Error(\"The listener provided is already registered\");\n }\n\n this.listeners.push(listener);\n\n // If this is a READY event listener, we can fire off a Ready event immediately\n if(!this.hasListener) {\n this.sendMessage(ApplicationEvents.ToShopfront.READY);\n this.hasListener = true;\n }\n }\n\n /**\n * @inheritDoc\n */\n public removeEventListener(listener: ApplicationEventListener): void {\n const index = this.listeners.indexOf(listener);\n\n if(index === -1) {\n return;\n }\n\n this.listeners = [\n ...this.listeners.slice(0, index),\n ...this.listeners.slice(index + 1),\n ];\n }\n}\n","import {\n BaseDatabase,\n type DatabaseCallReturn,\n type DatabaseMethodName,\n type DatabaseTable,\n} from \"../../APIs/Database/BaseDatabase.js\";\nimport type { LocalDatabaseBarcodeTemplate } from \"../../APIs/Database/types/BaseBarcodeTemplateRepository.js\";\nimport type { LocalDatabaseClassification } from \"../../APIs/Database/types/BaseClassificationRepository.js\";\nimport type { LocalDatabaseCustomerDisplay } from \"../../APIs/Database/types/BaseCustomerDisplayRepository.js\";\nimport type { LocalDatabaseCustomerGroup } from \"../../APIs/Database/types/BaseCustomerGroupRepository.js\";\nimport type { LocalDatabaseCustomer } from \"../../APIs/Database/types/BaseCustomerRepository.js\";\nimport type { LocalDatabaseEnterprise } from \"../../APIs/Database/types/BaseEnterpriseRepository.js\";\nimport type { LocalDatabaseGiftCard } from \"../../APIs/Database/types/BaseGiftCardRepository.js\";\nimport type { LocalDatabaseLoyalty } from \"../../APIs/Database/types/BaseLoyaltyRepository.js\";\nimport type { LocalDatabaseMovement } from \"../../APIs/Database/types/BaseMovementRepository.js\";\nimport type { LocalDatabaseOutlet } from \"../../APIs/Database/types/BaseOutletRepository.js\";\nimport type { LocalDatabasePaymentMethod } from \"../../APIs/Database/types/BasePaymentMethodRepository.js\";\nimport type { LocalDatabasePriceList } from \"../../APIs/Database/types/BasePriceListRepository.js\";\nimport type { LocalDatabasePriceSet } from \"../../APIs/Database/types/BasePriceSetRepository.js\";\nimport type { LocalDatabaseProduct } from \"../../APIs/Database/types/BaseProductRepository.js\";\nimport type { LocalDatabasePromotionCategory } from \"../../APIs/Database/types/BasePromotionCategoryRepository.js\";\nimport type { LocalDatabasePromotion } from \"../../APIs/Database/types/BasePromotionRepository.js\";\nimport type { LocalDatabaseReceipt } from \"../../APIs/Database/types/BaseReceiptRepository.js\";\nimport type { LocalDatabaseRegister } from \"../../APIs/Database/types/BaseRegisterRepository.js\";\nimport type { LocalDatabaseSaleKeys } from \"../../APIs/Database/types/BaseSalesKeyRepository.js\";\nimport type { LocalDatabaseSale } from \"../../APIs/Database/types/BaseSalesRepository.js\";\nimport type {\n LocalDatabaseStocktakeAccumulated,\n} from \"../../APIs/Database/types/BaseStocktakeAccumulatedRepository.js\";\nimport type { LocalDatabaseStocktake } from \"../../APIs/Database/types/BaseStocktakeRepository.js\";\nimport type { LocalDatabaseStocktakeScanned } from \"../../APIs/Database/types/BaseStocktakeScannedRepository.js\";\nimport type { LocalDatabaseSupplier } from \"../../APIs/Database/types/BaseSupplierRepository.js\";\nimport type { LocalDatabaseTakings } from \"../../APIs/Database/types/BaseTakingsRepository.js\";\nimport type { LocalDatabaseTaxRate } from \"../../APIs/Database/types/BaseTaxRateRepository.js\";\nimport type { LocalDatabaseTransferee } from \"../../APIs/Database/types/BaseTransfereeRepository.js\";\nimport type { LocalDatabaseVendorConnection } from \"../../APIs/Database/types/BaseVendorConnectionRepository.js\";\nimport { MockBridge } from \"../MockBridge.js\";\n\ninterface MockedDatabase {\n products: Array<LocalDatabaseProduct>;\n customers: Array<LocalDatabaseCustomer>;\n customerGroups: Array<LocalDatabaseCustomerGroup>;\n promotions: Array<LocalDatabasePromotion>;\n promotionCategories: Array<LocalDatabasePromotionCategory>;\n priceLists: Array<LocalDatabasePriceList>;\n paymentMethods: Array<LocalDatabasePaymentMethod>;\n salesKeys: Array<LocalDatabaseSaleKeys>;\n receipts: Array<LocalDatabaseReceipt>;\n giftCards: Array<LocalDatabaseGiftCard>;\n loyalty: Array<LocalDatabaseLoyalty>;\n customerDisplays: Array<LocalDatabaseCustomerDisplay>;\n sales: Array<LocalDatabaseSale>;\n brands: Array<LocalDatabaseClassification>;\n categories: Array<LocalDatabaseClassification>;\n families: Array<LocalDatabaseClassification>;\n tags: Array<LocalDatabaseClassification>;\n outlets: Array<LocalDatabaseOutlet>;\n registers: Array<LocalDatabaseRegister>;\n taxRates: Array<LocalDatabaseTaxRate>;\n takings: Array<LocalDatabaseTakings>;\n suppliers: Array<LocalDatabaseSupplier>;\n priceSets: Array<LocalDatabasePriceSet>;\n transferees: Array<LocalDatabaseTransferee>;\n movements: Array<LocalDatabaseMovement>;\n stocktakes: Array<LocalDatabaseStocktake>;\n stocktakeScanned: Array<LocalDatabaseStocktakeScanned>;\n stocktakeAccumulated: Array<LocalDatabaseStocktakeAccumulated>;\n barcodeTemplates: Array<LocalDatabaseBarcodeTemplate>;\n vendorConnections: Array<LocalDatabaseVendorConnection>;\n enterprises: Array<LocalDatabaseEnterprise>;\n}\n\nconst emptyDatabase: MockedDatabase = {\n products : [],\n customers : [],\n customerGroups : [],\n promotions : [],\n promotionCategories : [],\n priceLists : [],\n paymentMethods : [],\n salesKeys : [],\n receipts : [],\n giftCards : [],\n loyalty : [],\n customerDisplays : [],\n sales : [],\n brands : [],\n categories : [],\n families : [],\n tags : [],\n outlets : [],\n registers : [],\n taxRates : [],\n takings : [],\n suppliers : [],\n priceSets : [],\n transferees : [],\n movements : [],\n stocktakes : [],\n stocktakeScanned : [],\n stocktakeAccumulated: [],\n barcodeTemplates : [],\n vendorConnections : [],\n enterprises : [],\n};\n\nexport class MockDatabase extends BaseDatabase<MockBridge> {\n protected mockedDatabase: MockedDatabase = emptyDatabase;\n\n constructor(bridge: MockBridge) {\n super(bridge);\n }\n\n /**\n * @inheritDoc\n */\n public async callMethod<\n Table extends DatabaseTable,\n Method extends keyof DatabaseMethodName<Table>,\n ExpectedResult extends DatabaseCallReturn<Table, Method>\n >(\n table: Table,\n method: Method,\n args: Array<unknown>\n ): Promise<ExpectedResult> {\n return {} as ExpectedResult;\n }\n\n /**\n * @inheritDoc\n */\n public async all<Table extends DatabaseTable>(table: Table): Promise<DatabaseCallReturn<Table, \"all\">> {\n return [] as DatabaseCallReturn<Table, \"all\">;\n }\n\n /**\n * @inheritDoc\n */\n public async get<Table extends DatabaseTable>(\n table: Table,\n id: string | number\n ): Promise<DatabaseCallReturn<Table, \"get\">> {\n return {} as DatabaseCallReturn<Table, \"get\">;\n }\n\n /**\n * @inheritDoc\n */\n public async count(table: DatabaseTable): Promise<number> {\n return 0;\n }\n\n /**\n * Insert data into the mocked Database\n */\n public insertData<Table extends keyof MockedDatabase>(\n table: Table,\n rows: Array<MockedDatabase[Table]>\n ): void {\n if(typeof this.mockedDatabase[table] === \"undefined\") {\n throw new Error(`The table ${table} does not exist`);\n }\n\n // @ts-expect-error TypeScript resolves `MockedDatabase[Table]` as a union of arrays\n this.mockedDatabase[table].push(...rows);\n }\n\n /**\n * Clears all data from the mocked database\n */\n public clearDatabase(): void {\n this.mockedDatabase = emptyDatabase;\n }\n\n /**\n * Clears the data from a specified table\n */\n public clearTable<Table extends keyof MockedDatabase>(table: Table): void {\n if(typeof this.mockedDatabase[table] === \"undefined\") {\n throw new Error(`The table ${table} does not exist`);\n }\n\n this.mockedDatabase[table] = [];\n }\n}\n","import { Sale } from \"../APIs/Sale/index.js\";\nimport {\n type DirectShopfrontCallbacks,\n type DirectShopfrontEvent,\n type FromShopfront,\n type FromShopfrontInternal,\n type FromShopfrontReturns,\n isDirectShopfrontEvent,\n type ListenableFromShopfrontEvent,\n type RegisterChangedEvent,\n type SellScreenActionMode,\n type SellScreenSummaryMode,\n type SoundEvents,\n ToShopfront,\n} from \"../ApplicationEvents.js\";\nimport { BaseApplication, type ShopfrontEmbeddedVerificationToken } from \"../BaseApplication.js\";\nimport { Bridge } from \"../Bridge.js\";\nimport { type Serializable } from \"../Common/Serializable.js\";\nimport { BaseEmitableEvent } from \"../EmitableEvents/BaseEmitableEvent.js\";\nimport ActionEventRegistrar from \"../Utilities/ActionEventRegistrar.js\";\nimport { MockCurrentSale } from \"./APIs/Sale/MockCurrentSale.js\";\nimport { MockDatabase } from \"./Database/MockDatabase.js\";\nimport { MockBridge } from \"./MockBridge.js\";\n\ninterface AudioRequestOptions {\n hasPermission: boolean;\n forceError: boolean;\n}\n\nexport class MockApplication extends BaseApplication {\n protected currentSale: MockCurrentSale | false = false;\n\n constructor(bridge: MockBridge) {\n super(bridge, new MockDatabase(bridge));\n\n this.bridge.addEventListener(this.handleEvent);\n this.addEventListener(\"REGISTER_CHANGED\", this.handleLocationChanged);\n\n this.fireEvent.bind(this);\n\n // Fire a ready event immediately\n this.handleEvent(\"READY\", {\n key : \"embedded-key\",\n outlet : \"outlet-id\",\n register: \"register-id\",\n }, \"\");\n }\n\n /**\n * @inheritDoc\n */\n public destroy(): void {\n this.bridge.destroy();\n }\n\n /**\n * Handles an application event\n */\n protected handleEvent = async (\n event: keyof FromShopfront | keyof FromShopfrontInternal,\n data: Record<string, unknown>,\n id: string\n ): Promise<void> => {\n if(event === \"READY\") {\n this.isReady = true;\n this.key = data.key as string;\n this.outlet = data.outlet as string;\n this.register = data.register as string;\n\n data = {\n outlet : data.outlet,\n register: data.register,\n };\n }\n\n if(event === \"CALLBACK\") {\n // Actions aren't implemented\n return;\n }\n\n if(event === \"CYCLE_KEY\") {\n // Not needed\n return;\n } else if(event === \"LOCATION_CHANGED\") {\n // Unregister all serialized listeners as they're no longer displayed\n ActionEventRegistrar.clear();\n\n return;\n } else if(\n event === \"RESPONSE_CURRENT_SALE\" ||\n event === \"RESPONSE_DATABASE_REQUEST\" ||\n event === \"RESPONSE_LOCATION\" ||\n event === \"RESPONSE_OPTION\" ||\n event === \"RESPONSE_AUDIO_REQUEST\" ||\n event === \"RESPONSE_SECURE_KEY\" ||\n event === \"RESPONSE_CREATE_SALE\"\n ) {\n // Handled elsewhere\n return;\n }\n\n await this.emit(event, data, id);\n };\n\n /**\n * Calls any registered listeners for the received event\n */\n protected async emit(\n event: ListenableFromShopfrontEvent | DirectShopfrontEvent,\n data: Record<string, unknown> | string = {},\n id: string\n ): Promise<void> {\n if(isDirectShopfrontEvent(event)) {\n const listeners = this.directListeners[event];\n\n if(typeof listeners === \"undefined\") {\n return this.bridge.sendMessage(ToShopfront.NOT_LISTENING_TO_EVENT);\n }\n\n const results = [];\n\n for(const e of listeners.values()) {\n results.push(e.emit(data));\n }\n\n await Promise.all(results);\n\n return;\n }\n\n const results: Array<Promise<FromShopfrontReturns[typeof event]>> = [];\n\n if(typeof this.listeners[event] === \"undefined\") {\n // Don't need to do anything here\n return;\n }\n\n if(this.listeners[event].size === 0) {\n // Don't need to do anything here\n return;\n }\n\n const bridge = this.bridge as unknown as Bridge;\n\n for(const e of this.listeners[event].values()) {\n results.push(e.emit(data, bridge));\n }\n\n await Promise.allSettled(results);\n\n // The responses have been removed as we don't currently need them\n }\n\n /**\n * @inheritDoc\n */\n public send(item: BaseEmitableEvent<unknown> | Serializable<unknown>): void {\n /* empty */\n }\n\n /**\n * @inheritDoc\n */\n public download(file: string): void {\n /* empty */\n }\n\n /**\n * @inheritDoc\n */\n public redirect(toLocation: string, externalRedirect = true): void {\n /* empty */\n }\n\n /**\n * @inheritDoc\n */\n public load(): () => void {\n return () => undefined;\n }\n\n /**\n * @inheritDoc\n */\n protected handleEventCallback(data: { id?: string; data: unknown; }): void {\n /* empty */\n }\n\n /**\n * Updates the cached location data\n */\n protected handleLocationChanged = (data: RegisterChangedEvent): undefined => {\n this.register = data.register;\n this.outlet = data.outlet;\n this.user = data.user;\n };\n\n /**\n * @inheritDoc\n */\n public getAuthenticationKey(): string {\n return this.key;\n }\n\n /**\n * @inheritDoc\n */\n public async getCurrentSale(): Promise<MockCurrentSale | false> {\n if(!this.currentSale) {\n this.currentSale = new MockCurrentSale(this);\n }\n\n return this.currentSale;\n }\n\n /**\n * @inheritDoc\n */\n public async createSale(sale: Sale): Promise<{\n success: boolean;\n message?: string;\n }> {\n if(!sale.getRegister() && !this.register) {\n return {\n success: false,\n message: \"Sale has not provided a register and Shopfront currently doesn't have a register selected.\",\n };\n }\n\n if(!this.user) {\n return {\n success: false,\n message: \"A sale cannot be created when there is no user logged in to Shopfront.\",\n };\n }\n\n const payments = sale.getPayments();\n\n let totalPaid = 0;\n\n for(const payment of payments) {\n if(payment.getCashout()) {\n return {\n success: false,\n message: \"Sale payment with cash out is currently unsupported \" +\n \"through the Embedded Fulfilment API.\",\n };\n }\n\n if(payment.getRounding()) {\n return {\n success: false,\n message: \"Sale payment with rounding is currently unsupported \" +\n \"through the Embedded Fulfilment API.\",\n };\n }\n\n totalPaid += payment.getAmount();\n }\n\n // Round to 4 decimal places to keep consistent with POS\n const remaining = Math.round((sale.getSaleTotal() - totalPaid) * 1000) / 1000;\n\n if(remaining < 0) {\n return {\n success: false,\n message: \"Total paid is greater than sale total.\",\n };\n }\n\n return {\n success: true,\n };\n }\n\n /**\n * @inheritDoc\n */\n public async getLocation(options?: { globalMode: boolean; useRegister: boolean; }): Promise<{\n register: string | null;\n outlet: string | null;\n user: string | null;\n }> {\n if(options) {\n if(options.globalMode) {\n return {\n register: null,\n outlet : null,\n user : \"shopfront-user-id\",\n };\n } else if(!options.useRegister) {\n return {\n register: null,\n outlet : \"shopfront-outlet-id\",\n user : \"shopfront-user-id\",\n };\n }\n }\n\n return {\n register: \"shopfront-register-id\",\n outlet : \"shopfront-outlet-id\",\n user : \"shopfront-user-id\",\n };\n }\n\n /**\n * @inheritDoc\n */\n public printReceipt(content: string): void {\n /* empty */\n }\n\n /**\n * @inheritDoc\n */\n public changeSellScreenActionMode(mode: SellScreenActionMode): void {\n /* empty */\n }\n\n /**\n * @inheritDoc\n */\n public changeSellScreenSummaryMode(mode: SellScreenSummaryMode): void {\n /* empty */\n }\n\n /**\n * @inheritDoc\n */\n protected async sendAudioRequest(\n _type: SoundEvents,\n _data?: unknown,\n options?: AudioRequestOptions\n ): Promise<{ success: boolean; message?: string; }> {\n if(options) {\n if(!options.hasPermission) {\n return {\n success: false,\n message: \"You do not have permission to play audio\",\n };\n }\n\n if(options.forceError) {\n return {\n success: false,\n message: \"An error occurred whilst trying to play the audio\",\n };\n }\n }\n\n return {\n success: true,\n };\n }\n\n /**\n * @inheritDoc\n */\n public requestAudioPermission(options?: AudioRequestOptions): Promise<{ success: boolean; message?: string; }> {\n return this.sendAudioRequest(ToShopfront.AUDIO_REQUEST_PERMISSION, undefined, options);\n }\n\n /**\n * @inheritDoc\n */\n public audioPreload(url: string, options?: AudioRequestOptions): Promise<{ success: boolean; message?: string; }> {\n return this.sendAudioRequest(\n ToShopfront.AUDIO_PRELOAD,\n {\n url,\n },\n options\n );\n }\n\n /**\n * @inheritDoc\n */\n public audioPlay(url: string, options?: AudioRequestOptions): Promise<{ success: boolean; message?: string; }> {\n return this.sendAudioRequest(\n ToShopfront.AUDIO_PLAY,\n {\n url,\n },\n options\n );\n }\n\n /**\n * @inheritDoc\n */\n public async getOption<TValueType>(option: string, defaultValue: TValueType): Promise<TValueType> {\n return defaultValue;\n }\n\n /**\n * @inheritDoc\n */\n public getToken(returnTokenObject: true): Promise<ShopfrontEmbeddedVerificationToken>;\n /**\n * @inheritDoc\n */\n public getToken(returnTokenObject?: false): Promise<string>;\n /**\n * @inheritDoc\n */\n public async getToken(returnTokenObject?: boolean): Promise<string | ShopfrontEmbeddedVerificationToken> {\n if(returnTokenObject) {\n return {\n id : \"token-id\",\n app : \"app-id\",\n auth: \"embedded-token\",\n user: \"user-id\",\n url : {\n raw : \"https://testing.test\",\n loaded: \"https://frame.url\",\n },\n };\n }\n\n return \"embedded-token\";\n }\n\n /**\n * Mocks an event being fired from Shopfront\n */\n public async fireEvent<\n T extends ListenableFromShopfrontEvent,\n HasParams extends (Parameters<FromShopfront[T][\"emit\"]> extends [never] ? false : true),\n >(\n event: T,\n ...data: HasParams extends true ? Parameters<FromShopfront[T][\"emit\"]> : [undefined]\n ): Promise<void>;\n /**\n * Mocks an event being fired from Shopfront\n */\n public async fireEvent<\n D extends DirectShopfrontEvent,\n HasParams extends (Parameters<DirectShopfrontCallbacks[D]> extends [never] ? false : true),\n >(\n event: D,\n ...data: HasParams extends true ? Parameters<DirectShopfrontCallbacks[D]> : [undefined]\n ): Promise<void>;\n /**\n * Mocks an event being fired from Shopfront\n */\n public async fireEvent<\n T extends ListenableFromShopfrontEvent,\n D extends DirectShopfrontEvent,\n HasParams extends (D extends DirectShopfrontEvent ?\n Parameters<DirectShopfrontCallbacks[D]> extends [never] ? false : true :\n Parameters<FromShopfront[T][\"emit\"]> extends [never] ? false : true),\n >(\n event: T | D,\n ...data: HasParams extends true ?\n D extends DirectShopfrontEvent ?\n Parameters<DirectShopfrontCallbacks[D]> :\n Parameters<FromShopfront[T][\"emit\"]> :\n [undefined]\n ): Promise<void> {\n let params: Record<string, unknown> | string | undefined;\n\n if(data.length > 0) {\n if(typeof data[0] === \"object\") {\n params = {\n ...data[0],\n };\n } else {\n params = data[0];\n }\n // We don't care about the Bridge param in FromShopfront events, as that is passed in by the `emit` method\n // Direct events do not pass in a second parameter\n }\n\n await this.emit(event, params, \"\");\n };\n}\n","import { MockApplication } from \"./MockApplication.js\";\nimport { MockBridge } from \"./MockBridge.js\";\n\n/**\n * Creates a mocked instance of the Embedded Application\n */\nfunction mockApplication(id: string, vendor: string): MockApplication {\n if(typeof id === \"undefined\") {\n throw new TypeError(\"You must specify the ID for the application\");\n }\n\n if(typeof vendor === \"undefined\") {\n throw new TypeError(\"You must specify the Vendor for the application\");\n }\n\n return new MockApplication(new MockBridge(id, vendor));\n}\n\nexport {\n MockApplication,\n mockApplication,\n MockBridge,\n};\n"],"names":["EventEmitter","event","callback","index","args","events","l","ActionEventRegistrar","id","action","data","ActionEventRegistrar$1","staticImplements","constructor","BaseAction","serialized","type","i","properties","results","property","__publicField","__decorateClass","Button","label","icon","Dialog","closeable","header","content","buttons","InternalRedirect","to","ExternalRedirect","Redirect","SaleKey","name","Toast","message","BaseSale","customer","payments","products","sale","SaleCancelledError","InvalidSaleDeviceError","ProductNotExistsError","SaleCustomer","UUID","d0","d1","d2","d3","SalePaymentStatus","SalePayment","amount","cashout","status","payment","hydrated","SaleProduct","quantity","price","indexAddress","product","key","value","Sale","p","note","append","metaData","reference","application","saleState","BaseEmitableEvent","shopfrontEventName","InternalMessage","method","destination","ToShopfront","InternalMessageSource","url","BaseBridge","BaseEvent","AudioPermissionChange","AudioReady","BaseDirectEvent","SaleAddCustomer","SaleAddProduct","SaleChangeQuantity","SaleClear","SaleRemoveCustomer","SaleRemoveProduct","SaleUpdateProducts","FormatIntegratedProduct","result","bridge","FulfilmentCollectOrder","FulfilmentCompleteOrder","FulfilmentGetOrder","order","FulfilmentOrderApproval","FulfilmentProcessOrder","FulfilmentVoidOrder","GiftCardCodeCheck","InternalPageMessage","PaymentMethodsEnabled","Ready","RegisterChanged","RequestButtons","response","CustomerListOption","contents","RequestCustomerListOptions","_","options","option","o","RequestSaleKeys","keys","RequestSellScreenOptions","RequestSettings","settings","RequestTableColumns","columns","column","SaleComplete","Bridge","communicateVia","ApplicationEvents.ToShopfront","Application","listeners","listener","UIPipeline","context","directShopfrontEvents","isDirectShopfrontEvent","BaseDatabase","Database","table","databaseRequest","promise","res","rej","SaleUpdate","BaseCurrentSale","CurrentSale","newSale","update","updateData","ShopfrontTokenDecodingError","ShopfrontTokenRequestError","BaseApplication","database","c","buildSaleProductData","caseQuantity","buildSaleData","e","item","file","toLocation","externalRedirect","saleRequest","createSaleRequest","locationRequest","location","mode","request","defaultValue","optionValue","signature","returnTokenObject","decoded","Options","OrderCancel","OrderCreate","OrdersSync","orders","merge","OrderUpdate","RegisterIntent","SellScreenOption","title","SellScreenPromotionApplicable","enable","TableUpdate","emptySaleState","MockCurrentSale","MockApplication","precision","multiplier","currentPrice","newPrice","difference","currentRate","reversed","toSet","clone","reverse","updatedAmount","MockBridge","emptyDatabase","MockDatabase","rows","totalPaid","_type","_data","params","mockApplication","vendor"],"mappings":"AAEO,MAAMA,GAAa;AAAA,EACZ,kBAAiC,CAAA;AAAA,EACnC,YAAuF,CAAA;AAAA;AAAA;AAAA;AAAA,EAKxF,iBAAiBC,GAAeC,GAAoE;AACvG,QAAG,CAAC,KAAK,gBAAgB,SAASD,CAAK;AACnC,YAAM,IAAI,UAAU,GAAGA,CAAK,2BAA2B;AAG3D,IAAG,OAAO,KAAK,UAAUA,CAAK,IAAM,QAChC,KAAK,UAAUA,CAAK,IAAI,CAAA,IAG5B,KAAK,UAAU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KAAAE;AAAA,MAAA;AAAA,MAEJkC;AAAA,IAAA;AAAA,EAER;AAAA;AAAA;AAAA;AAAA,EAKO,UAAUlC,GAAakC,GAAiF;AAC3G,WAAO,KAAK;AAAA,MACRpC,EAAY;AAAA,MACZ;AAAA,QACI,KAAAE;AAAA,MAAA;AAAA,MAEJkC;AAAA,IAAA;AAAA,EAER;AAAA;AAAA;AAAA;AAAA,EAKA,MAAa,UAAsBC,GAAgBqD,GAA+C;AAC9F,WAAOA;AAAA,EACX;AAAA;AAAA;AAAA;AAAA,EAaA,MAAa,SAASG,GAAmF;AACrG,WAAGA,IACQ;AAAA,MACH,IAAM;AAAA,MACN,KAAM;AAAA,MACN,MAAM;AAAA,MACN,MAAM;AAAA,MACN,KAAM;AAAA,QACF,KAAQ;AAAA,QACR,QAAQ;AAAA,MAAA;AAAA,IACZ,IAID;AAAA,EACX;AAAA;AAAA;AAAA;AAAA,EAyBA,MAAa,UAOT5K,MACGS,GAKU;AACb,QAAIuM;AAEJ,IAAGvM,EAAK,SAAS,MACV,OAAOA,EAAK,CAAC,KAAM,WAClBuM,IAAS;AAAA,MACL,GAAGvM,EAAK,CAAC;AAAA,IAAA,IAGbuM,IAASvM,EAAK,CAAC,IAMvB,MAAM,KAAK,KAAKT,GAAOgN,GAAQ,EAAE;AAAA,EACrC;AACJ;ACvdA,SAASC,GAAgB1M,GAAY2M,GAAiC;AAClE,MAAG,OAAO3M,IAAO;AACb,UAAM,IAAI,UAAU,6CAA6C;AAGrE,MAAG,OAAO2M,IAAW;AACjB,UAAM,IAAI,UAAU,iDAAiD;AAGzE,SAAO,IAAIrB,GAAgB,IAAIY,GAAWlM,GAAI2M,CAAM,CAAC;AACzD;"}
1
+ {"version":3,"file":"index.mjs","sources":["../src/Common/EventEmitter.ts","../src/Utilities/ActionEventRegistrar.ts","../src/Utilities/Static.ts","../src/Actions/BaseAction.ts","../src/Actions/Button.ts","../src/Actions/Dialog.ts","../src/Actions/Redirect.ts","../src/Actions/SaleKey.ts","../src/Actions/Toast.ts","../src/APIs/Sale/BaseSale.ts","../src/APIs/Sale/Exceptions.ts","../src/APIs/Sale/SaleCustomer.ts","../src/Utilities/UUID.ts","../src/APIs/Sale/SalePayment.ts","../src/APIs/Sale/SaleProduct.ts","../src/APIs/Sale/Sale.ts","../src/EmitableEvents/BaseEmitableEvent.ts","../src/EmitableEvents/InternalMessage.ts","../src/APIs/InternalMessages/InternalMessageSource.ts","../src/BaseBridge.ts","../src/Events/BaseEvent.ts","../src/Events/AudioPermissionChange.ts","../src/Events/AudioReady.ts","../src/Events/DirectEvents/BaseDirectEvent.ts","../src/Events/DirectEvents/SaleAddCustomer.ts","../src/Events/DirectEvents/SaleAddProduct.ts","../src/Events/DirectEvents/SaleChangeQuantity.ts","../src/Events/DirectEvents/SaleClear.ts","../src/Events/DirectEvents/SaleRemoveCustomer.ts","../src/Events/DirectEvents/SaleRemoveProduct.ts","../src/Events/DirectEvents/SaleUpdateProducts.ts","../src/Events/FormatIntegratedProduct.ts","../src/Events/FulfilmentCollectOrder.ts","../src/Events/FulfilmentCompleteOrder.ts","../src/Events/FulfilmentGetOrder.ts","../src/Events/FulfilmentOrderApproval.ts","../src/Events/FulfilmentProcessOrder.ts","../src/Events/FulfilmentVoidOrder.ts","../src/Events/GiftCardCodeCheck.ts","../src/Events/InternalPageMessage.ts","../src/Events/PaymentMethodsEnabled.ts","../src/Events/Ready.ts","../src/Events/RegisterChanged.ts","../src/Events/RequestButtons.ts","../src/Actions/CustomerListOption.ts","../src/Events/RequestCustomerListOptions.ts","../src/Events/RequestSaleKeys.ts","../src/Events/RequestSellScreenOptions.ts","../src/Events/RequestSettings.ts","../src/Events/RequestTableColumns.ts","../src/Events/SaleComplete.ts","../src/Bridge.ts","../src/Events/UIPipeline.ts","../src/ApplicationEvents.ts","../src/APIs/Database/BaseDatabase.ts","../src/APIs/Database/Database.ts","../src/Actions/SaleUpdate.ts","../src/APIs/Sale/BaseCurrentSale.ts","../src/APIs/Sale/CurrentSale.ts","../src/BaseApplication.ts","../src/Utilities/SaleCreate.ts","../src/Application.ts","../src/EmitableEvents/Fulfilment/Options.ts","../src/EmitableEvents/Fulfilment/OrderCancel.ts","../src/EmitableEvents/Fulfilment/OrderCreate.ts","../src/EmitableEvents/Fulfilment/OrdersSync.ts","../src/EmitableEvents/Fulfilment/OrderUpdate.ts","../src/EmitableEvents/Fulfilment/RegisterIntent.ts","../src/EmitableEvents/SellScreenOption.ts","../src/EmitableEvents/SellScreenPromotionApplicable.ts","../src/EmitableEvents/TableUpdate.ts","../src/Mocks/APIs/Sale/MockCurrentSale.ts","../src/Mocks/MockBridge.ts","../src/Mocks/Database/MockDatabase.ts","../src/Mocks/MockApplication.ts","../src/Mocks/index.ts"],"sourcesContent":["import { type MaybePromise } from \"../Utilities/MiscTypes.js\";\n\nexport class EventEmitter {\n protected supportedEvents: Array<string> = [];\n private listeners: Record<string, Array<(...args: Array<unknown>) => MaybePromise<unknown>>> = {};\n\n /**\n * Registers an event listener\n */\n public addEventListener(event: string, callback: (...args: Array<unknown>) => MaybePromise<unknown>): void {\n if(!this.supportedEvents.includes(event)) {\n throw new TypeError(`${event} is not a supported event`);\n }\n\n if(typeof this.listeners[event] === \"undefined\") {\n this.listeners[event] = [];\n }\n\n this.listeners[event].push(callback);\n }\n\n /**\n * Removes an event listener\n */\n public removeEventListener(event: string, callback: (...args: Array<unknown>) => MaybePromise<unknown>): void {\n if(!this.supportedEvents.includes(event)) {\n throw new TypeError(`${event} is not a supported event`);\n }\n\n if(typeof this.listeners[event] === \"undefined\") {\n return;\n }\n\n const index = this.listeners[event].indexOf(callback);\n\n if(index === -1) {\n return;\n }\n\n this.listeners[event] = [\n ...this.listeners[event].slice(0, index),\n ...this.listeners[event].slice(index + 1),\n ];\n }\n\n /**\n * Invokes all callbacks listening to the event\n */\n protected async emit(event: string, ...args: Array<unknown>): Promise<Array<unknown>> {\n if(typeof this.listeners[event] === \"undefined\") {\n return Promise.resolve([]);\n }\n\n const events: Array<MaybePromise<unknown>> = [];\n\n for(let i = 0, l = this.listeners[event].length; i < l; i++) {\n events.push(this.listeners[event][i](...args));\n }\n\n return Promise.all(events);\n }\n}\n","import { BaseAction } from \"../Actions/BaseAction.js\";\n\nclass ActionEventRegistrar {\n private events: Record<string, BaseAction<undefined>>;\n\n constructor() {\n this.events = {};\n }\n\n /**\n * Registers an event action listener\n */\n public add(id: string, action: BaseAction<undefined>): void {\n this.events[id] = action;\n }\n\n /**\n * Removes an event action listener\n */\n public remove(id: string) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete this.events[id];\n }\n\n /**\n * Invokes the registered action event listener\n */\n public fire(id: string, data: unknown) {\n if(typeof this.events[id] === \"undefined\") {\n // The event must have stopped listening\n return;\n }\n\n this.events[id].handleRegistrarEvent(id, data);\n }\n\n /**\n * Clears all registered listeners\n */\n public clear() {\n this.events = {};\n }\n}\n\nexport default new ActionEventRegistrar();\n","/**\n * A decorator function that enforces static interface implementation for a class at compile time.\n */\nexport function staticImplements<T>() {\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n return (constructor: T): void => {};\n}\n","import { EventEmitter } from \"../Common/EventEmitter.js\";\nimport type { Serializable, SerializableStatic, Serialized } from \"../Common/Serializable.js\";\nimport ActionEventRegistrar from \"../Utilities/ActionEventRegistrar.js\";\nimport { staticImplements } from \"../Utilities/Static.js\";\n\ninterface BaseActionConstructor<T> {\n new(...args: Array<never>): BaseAction<T>;\n new(serialized: Serialized<T>): BaseAction<T>;\n}\n\n@staticImplements<SerializableStatic>()\nexport class BaseAction<T> extends EventEmitter {\n protected target: string;\n protected events: Array<{\n callback: (...args: Array<unknown>) => void; type: string; id: string;\n }>;\n protected properties: Array<unknown>;\n\n public static serializedRegistry: Record<string, BaseActionConstructor<unknown>> = {};\n\n constructor(serialized: Serialized<T>, type: BaseActionConstructor<T>) {\n if(new.target === BaseAction) {\n throw new TypeError(\"You cannot construct BaseAction instances directly\");\n }\n\n super();\n\n this.target = serialized.type;\n this.events = [];\n this.properties = serialized.properties;\n\n // Ensure that we are registered in the registry\n BaseAction.serializedRegistry[this.target] = type;\n }\n\n /**\n * Serializes the registered action event data (excluding callbacks) and properties\n */\n public serialize(): Serialized<T> {\n const events: Record<string, Array<string>> = {};\n\n for(let i = 0, l = this.events.length; i < l; i++) {\n if(typeof events[this.events[i].type] === \"undefined\") {\n events[this.events[i].type] = [];\n }\n\n events[this.events[i].type].push(this.events[i].id);\n }\n\n return {\n properties: this.serializeProperties(this.properties),\n events : events,\n type : this.target,\n };\n }\n\n /**\n * Recursively serializes the action properties\n */\n protected serializeProperties(properties: Array<unknown>): Array<unknown> {\n const results: Array<unknown> = [];\n\n // Loop through current layer of properties\n for(let i = 0, l = properties.length; i < l; i++) {\n const property = properties[i];\n\n if(Array.isArray(property)) {\n // Prepare to recurse through next layer of properties\n results.push(this.serializeProperties(property));\n } else if(property instanceof BaseAction) {\n // Serialize property\n results.push(property.serialize());\n } else {\n // Assume that the property is already serializable\n results.push(property);\n }\n }\n\n return results;\n }\n\n /**\n * Deserializes the action data\n */\n public static deserialize<T extends Serializable<T>>(serialized: Serialized<T>): T {\n return new BaseAction.serializedRegistry[serialized.type](serialized) as unknown as T;\n }\n\n /**\n * Registers an action event listener\n */\n public addEventListener(event: string, callback: (...args: Array<unknown>) => void): void {\n super.addEventListener(event, callback);\n\n const id = `${Date.now()}-${event}-${Math.random()}`;\n\n ActionEventRegistrar.add(id, this);\n\n this.events.push({\n id,\n callback,\n type: event,\n });\n }\n\n /**\n * Unregisters an action event listener\n */\n public removeEventListener(event: string, callback: (...args: Array<unknown>) => void): void {\n super.removeEventListener(event, callback);\n\n for(let i = 0, l = this.events.length; i < l; i++) {\n if(this.events[i].type !== event) {\n continue;\n }\n\n if(this.events[i].callback !== callback) {\n continue;\n }\n\n const id = this.events[i].id;\n\n ActionEventRegistrar.remove(id);\n\n this.events = [\n ...this.events.slice(0, i),\n ...this.events.slice(i + 1),\n ];\n\n break;\n }\n }\n\n /**\n * Fires the callback for the registered action event\n */\n public handleRegistrarEvent(id: string, data: unknown): void {\n for(let i = 0, l = this.events.length; i < l; i++) {\n if(this.events[i].id !== id) {\n continue;\n }\n\n this.events[i].callback(data);\n\n break;\n }\n }\n}\n","import type { Serialized } from \"../Common/Serializable.js\";\nimport { BaseAction } from \"./BaseAction.js\";\n\nexport class Button extends BaseAction<Button> {\n protected supportedEvents = [ \"click\" ];\n\n protected label: string;\n protected icon: string;\n\n constructor(label: Serialized<Button> | string, icon?: string) {\n // https://github.com/Microsoft/TypeScript/issues/8277\n super((() => {\n if(typeof label === \"string\") {\n return {\n properties: [ label, icon ],\n events : {},\n type : \"Button\",\n };\n } else {\n return label;\n }\n })(), Button);\n\n if(typeof icon === \"undefined\" && typeof label !== \"string\") {\n this.label = label.properties[0] as string;\n this.icon = label.properties[1] as string;\n } else {\n this.label = label as string;\n\n if(typeof icon === \"undefined\") {\n this.icon = \"\";\n } else {\n this.icon = icon;\n }\n }\n }\n}\n","import type { Serialized } from \"../Common/Serializable.js\";\nimport { BaseAction } from \"./BaseAction.js\";\nimport { Button } from \"./Button.js\";\n\ntype DialogType = \"success\" | \"information\" | \"question\" | \"danger\" | \"warning\" | \"error\" | \"edit\" | \"frame\";\n\nexport class Dialog extends BaseAction<Dialog> {\n protected supportedEvents = [ \"close\" ];\n\n protected type: DialogType;\n protected closeable: boolean;\n protected header: string;\n protected content: string;\n protected buttons: Array<Button>;\n\n constructor(\n type: Serialized<Dialog> | DialogType,\n closeable?: boolean,\n header?: string,\n content?: string,\n buttons?: Array<Button>\n ) {\n // https://github.com/Microsoft/TypeScript/issues/8277\n super((() => {\n if(typeof type === \"string\") {\n return {\n properties: [ type, closeable, header, content, buttons ],\n events : {},\n type : \"Dialog\",\n };\n } else {\n return type;\n }\n })(), Dialog);\n\n if(typeof header === \"undefined\") {\n type = type as Serialized<Dialog>;\n this.type = type.properties[0] as DialogType;\n this.closeable = type.properties[1] as boolean;\n this.header = type.properties[2] as string;\n this.content = type.properties[3] as string;\n this.buttons = type.properties[4] as Array<Button>; // Note: This should be deserialized\n } else {\n this.type = type as DialogType;\n this.closeable = closeable as boolean;\n this.header = header as string;\n this.content = content as string;\n this.buttons = buttons as Array<Button>;\n }\n }\n}\n","import type { Serialized } from \"../Common/Serializable.js\";\nimport { BaseAction } from \"./BaseAction.js\";\n\nclass InternalRedirect extends BaseAction<InternalRedirect> {\n protected supportedEvents = [ \"click\" ];\n\n protected to: string;\n\n constructor(to: Serialized<InternalRedirect> | string) {\n // https://github.com/Microsoft/TypeScript/issues/8277\n super((() => {\n if(typeof to === \"string\") {\n return {\n properties: [ to ],\n events : {},\n type : \"InternalRedirect\",\n };\n } else {\n return to;\n }\n })(), InternalRedirect);\n\n if(typeof to !== \"string\") {\n this.to = to.properties[0] as string;\n } else {\n this.to = to;\n }\n }\n}\n\nclass ExternalRedirect extends BaseAction<ExternalRedirect> {\n protected supportedEvents = [ \"click\" ];\n\n protected to: URL;\n\n constructor(to: Serialized<ExternalRedirect> | URL) {\n // https://github.com/Microsoft/TypeScript/issues/8277\n super((() => {\n if(to instanceof URL) {\n return {\n properties: [ to.href ],\n events : {},\n type : \"ExternalRedirect\",\n };\n } else {\n return to;\n }\n })(), ExternalRedirect);\n\n if(to instanceof URL) {\n this.to = to;\n } else {\n this.to = new URL(to.properties[0] as string);\n }\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const Redirect = {\n InternalRedirect,\n ExternalRedirect,\n};\n","import type { Serialized } from \"../Common/Serializable.js\";\nimport { BaseAction } from \"./BaseAction.js\";\n\nexport class SaleKey extends BaseAction<SaleKey> {\n protected supportedEvents = [ \"click\" ];\n\n protected id: string;\n protected name: string;\n\n constructor(id: Serialized<SaleKey> | string, name?: string) {\n // https://github.com/Microsoft/TypeScript/issues/8277\n super((() => {\n if(typeof id === \"string\") {\n return {\n properties: [ id, name ],\n events : {},\n type : \"Button\",\n };\n } else {\n return id;\n }\n })(), SaleKey);\n\n if(typeof name === \"undefined\" && typeof id !== \"string\") {\n this.id = id.properties[0] as string;\n this.name = id.properties[1] as string;\n } else {\n this.id = id as string;\n\n if(typeof name === \"undefined\") {\n this.name = \"\";\n } else {\n this.name = name;\n }\n }\n }\n}\n","import type { Serialized } from \"../Common/Serializable.js\";\nimport { BaseAction } from \"./BaseAction.js\";\n\nexport type ToastType = \"success\" | \"error\" | \"information\" | \"warning\";\n\nexport class Toast extends BaseAction<Toast> {\n protected supportedEvents = [ \"hide\" ];\n\n protected type: ToastType;\n protected message: string;\n\n constructor(type: Serialized<Toast> | ToastType, message?: string) {\n // https://github.com/Microsoft/TypeScript/issues/8277\n super((() => {\n if(typeof type === \"string\") {\n return {\n properties: [ type, message ],\n events : {},\n type : \"Toast\",\n };\n } else {\n return type;\n }\n })(), Toast);\n\n if(typeof message === \"undefined\") {\n type = type as Serialized<Toast>;\n this.type = type.properties[0] as ToastType;\n this.message = type.properties[1] as string;\n } else {\n this.type = type as ToastType;\n this.message = message;\n }\n }\n}\n","import type { SaleCustomer } from \"./SaleCustomer.js\";\nimport type { SalePayment } from \"./SalePayment.js\";\nimport type { SaleProduct } from \"./SaleProduct.js\";\n\nexport interface BaseSaleData {\n register: string | undefined;\n clientId: string | undefined;\n notes: {\n internal: string;\n sale: string;\n };\n totals: {\n sale: number;\n paid: number;\n savings: number;\n discount: number;\n };\n linkedTo: string;\n orderReference: string;\n refundReason: string;\n priceSet: string | null;\n metaData: Record<string, unknown>;\n}\n\nexport interface SaleData extends BaseSaleData {\n customer: null | SaleCustomer;\n payments: Array<SalePayment>;\n products: Array<SaleProduct>;\n}\n\nexport abstract class BaseSale {\n protected sale: BaseSaleData;\n protected customer: null | SaleCustomer;\n protected payments: Array<SalePayment>;\n protected products: Array<SaleProduct>;\n\n protected constructor({ customer, payments, products, ...sale }: SaleData) {\n this.sale = sale;\n this.customer = customer;\n this.payments = payments;\n this.products = products;\n }\n\n /**\n * Updates the sale data to be inline with the new sale\n */\n protected hydrate(sale: BaseSale): void {\n this.sale = sale.sale;\n this.customer = sale.customer;\n this.payments = sale.payments;\n this.products = sale.products;\n }\n\n /**\n * Get the products that are currently on the sale.\n */\n public getProducts(): Array<SaleProduct> {\n return this.products;\n }\n\n /**\n * Get the payments that are currently on the sale.\n */\n public getPayments(): Array<SalePayment> {\n return this.payments;\n }\n\n /**\n * Get the current customer on the sale.\n */\n public getCustomer(): null | SaleCustomer {\n return this.customer;\n }\n\n /**\n * Get the register.\n */\n public getRegister(): string | undefined {\n return this.sale.register;\n }\n\n /**\n * Get the client id.\n */\n public getClientId(): string | undefined {\n return this.sale.clientId;\n }\n\n /**\n * Get the current sale total on the sale.\n */\n public getSaleTotal(): number {\n return this.sale.totals.sale;\n }\n\n /**\n * Get the current paid total on the sale.\n */\n public getPaidTotal(): number {\n return this.sale.totals.paid;\n }\n\n /**\n * Get the current savings total on the sale.\n */\n public getSavingsTotal(): number {\n return this.sale.totals.savings;\n }\n\n /**\n * Get the current discount total on the sale.\n */\n public getDiscountTotal(): number {\n return this.sale.totals.discount;\n }\n\n /**\n * Get the linked to value on the sale.\n */\n public getLinkedTo(): string {\n return this.sale.linkedTo;\n }\n\n /**\n * Get the refund reason on the sale.\n */\n public getRefundReason(): string {\n return this.sale.refundReason;\n }\n\n /**\n * Get the price set on the sale.\n */\n public getPriceSet(): string | null {\n return this.sale.priceSet;\n }\n\n /**\n * Get the external sale note (visible to the customer).\n */\n public getExternalNote(): string {\n return this.sale.notes.sale;\n }\n\n /**\n * Get the internal sale note.\n */\n public getInternalNote(): string {\n return this.sale.notes.internal;\n }\n\n /**\n * Get the order reference (visible to the customer).\n */\n public getOrderReference(): string {\n return this.sale.orderReference;\n }\n\n /**\n * Get the current meta data for the sale\n */\n public getMetaData(): Record<string, unknown> {\n return this.sale.metaData;\n }\n\n public abstract addProduct(product: SaleProduct): Promise<void>;\n public abstract removeProduct(product: SaleProduct): Promise<void>;\n public abstract addPayment(payment: SalePayment): Promise<void>;\n public abstract addCustomer(customer: SaleCustomer): Promise<void>;\n public abstract removeCustomer(): Promise<void>;\n public abstract setExternalNote(note: string, append?: boolean): Promise<void>;\n public abstract setInternalNote(note: string, append?: boolean): Promise<void>;\n public abstract setOrderReference(reference: string): Promise<void>;\n public abstract setMetaData(metaData: Record<string, unknown>): Promise<void>;\n public abstract updateProduct(product: SaleProduct): Promise<void>;\n}\n","export class SaleCancelledError extends Error {\n constructor() {\n super(\"The sale is no longer active.\");\n }\n}\n\nexport class InvalidSaleDeviceError extends Error {\n constructor() {\n super(\"This device is no longer a register able to perform a sale.\");\n }\n}\n\nexport class ProductNotExistsError extends Error {\n constructor() {\n super(\"Product does not exist in the sale\");\n }\n}\n","export class SaleCustomer {\n protected id: string;\n\n constructor(id: string) {\n this.id = id;\n }\n\n /**\n * Get the ID of the customer.\n */\n public getId(): string {\n return this.id;\n }\n}\n","/**\n * Fast UUID generator, RFC4122 version 4 compliant.\n * @author Jeff Ward (jcward.com).\n * @license MIT\n * {@link http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/21963136#21963136}\n */\nexport default class UUID {\n protected lut: Array<string>;\n\n constructor() {\n this.lut = [];\n\n for(let i = 0; i < 256; i++) {\n this.lut[i] = (i < 16 ? \"0\" : \"\") + (i).toString(16);\n }\n\n this.generate = this.generate.bind(this);\n }\n\n /**\n * Generates a UUID\n */\n public generate(): string {\n const d0 = Math.random() * 0xffffffff | 0;\n const d1 = Math.random() * 0xffffffff | 0;\n const d2 = Math.random() * 0xffffffff | 0;\n const d3 = Math.random() * 0xffffffff | 0;\n\n return this.lut[d0 & 0xff] +\n this.lut[d0 >> 8 & 0xff] +\n this.lut[d0 >> 16 & 0xff] +\n this.lut[d0 >> 24 & 0xff] + \"-\" +\n this.lut[d1 & 0xff] +\n this.lut[d1 >> 8 & 0xff] + \"-\" +\n this.lut[d1 >> 16 & 0x0f | 0x40] +\n this.lut[d1 >> 24 & 0xff] + \"-\" +\n this.lut[d2 & 0x3f | 0x80] +\n this.lut[d2 >> 8 & 0xff] + \"-\" +\n this.lut[d2 >> 16 & 0xff] +\n this.lut[d2 >> 24 & 0xff] +\n this.lut[d3 & 0xff] +\n this.lut[d3 >> 8 & 0xff] +\n this.lut[d3 >> 16 & 0xff] +\n this.lut[d3 >> 24 & 0xff];\n }\n\n /**\n * Static method for generating a UUID\n */\n public static generate(): string {\n if(typeof self?.crypto?.randomUUID === \"function\") {\n return self.crypto.randomUUID();\n }\n\n return (new UUID()).generate();\n }\n}\n","import UUID from \"../../Utilities/UUID.js\";\nimport { type ShopfrontSalePayment } from \"./ShopfrontSaleState.js\";\n\nexport enum SalePaymentStatus {\n APPROVED = \"completed\",\n DECLINED = \"failed\",\n CANCELLED = \"cancelled\",\n}\n\nexport class SalePayment {\n public readonly internalId: string;\n\n protected id: string;\n protected type?: string;\n protected status?: SalePaymentStatus;\n protected amount: number;\n protected cashout?: number;\n protected rounding?: number;\n protected metaData: Record<string, unknown> = {};\n\n constructor(id: string, amount: number, cashout?: number, status?: SalePaymentStatus) {\n this.internalId = UUID.generate();\n\n this.id = id;\n this.amount = amount;\n this.cashout = cashout;\n this.status = status;\n }\n\n /**\n * Hydrate a sale payment from the SaleState.\n * @internal\n */\n public static HydrateFromState(payment: ShopfrontSalePayment): SalePayment {\n let status = SalePaymentStatus.APPROVED;\n\n switch(payment.status) {\n case \"failed\":\n status = SalePaymentStatus.DECLINED;\n break;\n case \"cancelled\":\n status = SalePaymentStatus.CANCELLED;\n break;\n }\n\n const hydrated = new SalePayment(payment.method, payment.amount, payment.cashout, status);\n\n hydrated.setInternal(payment);\n\n return hydrated;\n }\n\n /**\n * Set the internal data for the payment.\n * This method is for hydration of the payment from Shopfront,\n * it's highly recommend that you DO NOT use this method.\n * @internal\n */\n public setInternal(data: ShopfrontSalePayment): void {\n this.type = data.type;\n this.rounding = data.rounding;\n this.metaData = JSON.parse(data.metadata);\n }\n\n /**\n * Get the ID of the sale payment method.\n */\n public getId(): string {\n return this.id;\n }\n\n /**\n * Get the type of payment method this is.\n */\n public getType(): string | undefined {\n return this.type;\n }\n\n /**\n * Get the status of this payment method.\n */\n public getStatus(): SalePaymentStatus | undefined {\n return this.status;\n }\n\n /**\n * Get the value of this payment method.\n */\n public getAmount(): number {\n return this.amount;\n }\n\n /**\n * Get the cashout amount paid for on this payment method.\n */\n public getCashout(): number | undefined {\n return this.cashout;\n }\n\n /**\n * Get the amount of rounding applied to this payment method.\n */\n public getRounding(): number | undefined {\n return this.rounding;\n }\n\n /**\n * Get the metadata attached to this payment method\n */\n public getMetaData(): Record<string, unknown> {\n return this.metaData;\n }\n}\n","import UUID from \"../../Utilities/UUID.js\";\nimport {\n type ShopfrontSaleProduct,\n type ShopfrontSaleProductPromotions,\n type ShopfrontSaleProductType,\n} from \"./ShopfrontSaleState.js\";\n\nexport class SaleProduct {\n public readonly internalId: string;\n\n protected id: string;\n protected quantity: number;\n protected price?: number;\n protected indexAddress: Array<number>;\n protected name?: string;\n protected type?: ShopfrontSaleProductType;\n protected taxRateAmount?: number;\n protected note: string;\n protected contains: Array<SaleProduct>;\n protected edited: boolean;\n protected caseQuantity?: number;\n protected promotions: ShopfrontSaleProductPromotions = {};\n protected metaData: Record<string, unknown> = {};\n protected mapped?: string;\n protected quantityModified: boolean;\n protected priceModified: boolean;\n protected metaDataModified: boolean;\n\n constructor(id: string, quantity: number, price?: number, indexAddress?: Array<number>) {\n this.internalId = UUID.generate();\n\n this.id = id;\n this.quantity = quantity;\n this.price = price;\n this.indexAddress = indexAddress || [];\n\n this.contains = [];\n this.edited = typeof price !== \"undefined\";\n this.note = \"\";\n\n this.quantityModified = false;\n this.priceModified = false;\n this.metaDataModified = false;\n }\n\n /**\n * Hydrate a sale product from the SaleState.\n * @internal\n */\n public static HydrateFromState(product: ShopfrontSaleProduct, indexAddress: Array<number>): SaleProduct {\n const hydrated = new SaleProduct(product.uuid, product.quantity, product.prices.price, indexAddress);\n\n hydrated.setInternal(product, indexAddress);\n\n return hydrated;\n }\n\n /**\n * Append a product to this product's list of contained products.\n */\n protected appendProduct(product: SaleProduct): void {\n this.contains.push(product);\n }\n\n /**\n * Set the internal data for the product.\n * This method is for hydration of the product from Shopfront,\n * it's highly recommend that you DO NOT use this method.\n * @internal\n */\n public setInternal(data: ShopfrontSaleProduct, indexAddress: Array<number>): void {\n this.name = data.name;\n this.type = data.type;\n this.taxRateAmount = data.tax?.amount || 0;\n this.note = data.note;\n this.edited = data.edited;\n this.caseQuantity = data.caseQuantity;\n this.promotions = data.promotions;\n this.metaData = data.metaData;\n this.mapped = data.mapped;\n\n for(let i = 0, l = data.products.length; i < l; i++) {\n this.appendProduct(SaleProduct.HydrateFromState(data.products[i], [\n ...indexAddress,\n i,\n ]));\n }\n }\n\n /**\n * Get the ID of the product.\n */\n public getId(): string {\n return this.id;\n }\n\n /**\n * Gets the mapped id for the product.\n * Used when the product goes through the fulfilment process mapping\n */\n public getMapped(): string | undefined {\n return this.mapped;\n }\n\n /**\n * Get the current sale quantity of the product.\n */\n public getQuantity(): number {\n return this.quantity;\n }\n\n /**\n * Sets the current sale quantity of the product\n */\n public setQuantity(quantity: number): void {\n this.quantity = quantity;\n this.quantityModified = true;\n }\n\n /**\n * Get the current price of the product.\n */\n public getPrice(): number | undefined {\n return this.price;\n }\n\n /**\n * Sets the current price of the product\n */\n public setPrice(price: number): void {\n this.price = price;\n this.priceModified = true;\n }\n\n /**\n * Get the index address of the product.\n * This is the internal address of where the product is in the sale.\n * (e.g. if the address is [1, 3] it's the fourth contained product in the second sale line).\n */\n public getIndexAddress(): Array<number> {\n return this.indexAddress;\n }\n\n /**\n * Get the name of the product.\n */\n public getName(): string | undefined {\n return this.name;\n }\n\n /**\n * Get the type of product this product is.\n */\n public getType(): ShopfrontSaleProductType | undefined {\n return this.type;\n }\n\n /**\n * Get the tax rate amount.\n * This is the rate of the tax rate (e.g. 10 is a tax rate of 10%).\n */\n public getTaxRateAmount(): number | undefined {\n return this.taxRateAmount;\n }\n\n /**\n * Get the sale note attached to this product.\n */\n public getNote(): string {\n return this.note;\n }\n\n /**\n * Get the products this product contains.\n */\n public getContains(): Array<SaleProduct> {\n return this.contains;\n }\n\n /**\n * Get whether this product has been \"edited\".\n * Typically, being edited just means that this product has been discounted.\n */\n public getEdited(): boolean {\n return this.edited;\n }\n\n /**\n * Get the case quantity for this product.\n */\n public getCaseQuantity(): number | undefined {\n return this.caseQuantity;\n }\n\n /**\n * Get the current active promotions for the product.\n */\n public getPromotions(): ShopfrontSaleProductPromotions {\n return this.promotions;\n }\n\n /**\n * Get the meta-data for the product.\n */\n public getMetaData(): Record<string, unknown> {\n return this.metaData;\n }\n\n /**\n * Set the metaData for a product\n */\n public setMetaData(key: string, value: unknown): void {\n this.metaData[key] = value;\n this.metaDataModified = true;\n }\n\n /**\n * Returns whether the product's quantity was modified externally\n * @internal\n */\n public wasQuantityModified(): boolean {\n return this.quantityModified;\n }\n\n /**\n * Returns whether the product's price was modified externally\n * @internal\n */\n public wasPriceModified(): boolean {\n return this.priceModified;\n }\n\n /**\n * Returns whether the product's metaData was modified externally\n * @internal\n */\n public wasMetaDataModified(): boolean {\n return this.metaDataModified;\n }\n\n /**\n * Sets a product's modification flags to false\n * @internal\n */\n public clearModificationFlags(): void {\n this.quantityModified = false;\n this.priceModified = false;\n this.metaDataModified = false;\n }\n}\n","import type { Application } from \"../../Application.js\";\nimport { BaseSale, type SaleData } from \"./BaseSale.js\";\nimport { SaleCustomer } from \"./SaleCustomer.js\";\nimport { SalePayment } from \"./SalePayment.js\";\nimport { SaleProduct } from \"./SaleProduct.js\";\nimport type { ShopfrontSaleState } from \"./ShopfrontSaleState.js\";\n\nexport class Sale extends BaseSale {\n protected created = false;\n protected creating = false;\n\n constructor(data: SaleData) {\n super(data);\n }\n\n /**\n * Add a customer to the sale\n */\n public async addCustomer(customer: SaleCustomer): Promise<void> {\n this.customer = customer;\n }\n\n /**\n * Add a payment to the sale\n */\n public async addPayment(payment: SalePayment): Promise<void> {\n if(this.payments.find(p => p.internalId === payment.internalId)) {\n throw new TypeError(\"Payment has already been added to sale.\");\n }\n\n this.payments.push(payment);\n }\n\n /**\n * Add a product to the sale\n */\n public async addProduct(product: SaleProduct): Promise<void> {\n if(this.products.find(p => p.internalId === product.internalId)) {\n throw new TypeError(\"Product has already been added to sale.\");\n }\n\n this.products.push(product);\n }\n\n /**\n * Remove the customer from the sale\n */\n public async removeCustomer(): Promise<void> {\n this.customer = null;\n }\n\n /**\n * Remove a product from the sale\n */\n public async removeProduct(product: SaleProduct): Promise<void> {\n const index = this.products.findIndex(p => p.internalId === product.internalId);\n\n if(index === -1) {\n throw new TypeError(\"Product could not be found in the sale.\");\n }\n\n this.products.splice(index, 1);\n }\n\n /**\n * Remove a payment from the sale\n */\n public async removePayment(payment: SalePayment): Promise<void> {\n const index = this.payments.findIndex(p => p.internalId === payment.internalId);\n\n if(index === -1) {\n throw new TypeError(\"Payment could not be found in the sale.\");\n }\n\n this.payments.splice(index, 1);\n }\n\n /**\n * Add / append an external note to the sale\n */\n public async setExternalNote(note: string, append?: boolean): Promise<void> {\n if(append) {\n this.sale.notes.sale += note;\n } else {\n this.sale.notes.sale = note;\n }\n }\n\n /**\n * Add / append an internal note to the sale\n */\n public async setInternalNote(note: string, append?: boolean): Promise<void> {\n if(append) {\n this.sale.notes.internal += note;\n } else {\n this.sale.notes.internal = note;\n }\n }\n\n /**\n * Set the sale's meta-data\n */\n public async setMetaData(metaData: Record<string, unknown>): Promise<void> {\n this.sale.metaData = metaData;\n }\n\n /**\n * Set the sale's order reference\n */\n public async setOrderReference(reference: string): Promise<void> {\n this.sale.orderReference = reference;\n }\n\n /**\n * Update a product in the sale\n */\n public async updateProduct(product: SaleProduct): Promise<void> {\n const index = this.products.findIndex(p => p.internalId === product.internalId);\n\n if(index === -1) {\n throw new TypeError(\"Product could not be found in the sale.\");\n }\n\n this.products[index] = product;\n }\n\n /**\n * Create the sale on the server\n */\n public async create(application: Application): Promise<{\n success: boolean;\n message?: string;\n }> {\n if(this.creating) {\n throw new TypeError(\"Create function is currently running\");\n }\n\n if(this.created) {\n throw new TypeError(\"Sale has already been created\");\n }\n\n this.creating = true;\n\n const results = await application.createSale(this);\n\n if(results.success) {\n this.created = true;\n }\n\n this.creating = false;\n\n return results;\n }\n\n /**\n * Converts the sale state to the sale data\n */\n public static buildSaleData(saleState: ShopfrontSaleState): SaleData {\n return {\n register : saleState.register,\n clientId : saleState.clientId,\n notes : saleState.notes,\n totals : saleState.totals,\n linkedTo : saleState.linkedTo,\n orderReference: saleState.orderReference,\n refundReason : saleState.refundReason,\n priceSet : saleState.priceSet,\n metaData : saleState.metaData,\n customer : saleState.customer ? new SaleCustomer(saleState.customer.uuid) : null,\n payments : saleState.payments.map(SalePayment.HydrateFromState),\n products : saleState.products.map((product, index) => {\n return SaleProduct.HydrateFromState(product, [ index ]);\n }),\n };\n }\n}\n","import { ToShopfront } from \"../ApplicationEvents.js\";\n\nexport class BaseEmitableEvent<T> {\n protected eventName: ToShopfront;\n protected eventData: T;\n\n constructor(shopfrontEventName: ToShopfront, data: T) {\n if(new.target === BaseEmitableEvent) {\n throw new TypeError(\"You cannot construct BaseEmitableEvent instances directly\");\n }\n\n this.eventName = shopfrontEventName;\n this.eventData = data;\n }\n\n /**\n * Returns the event name\n */\n public getEvent(): ToShopfront {\n return this.eventName;\n }\n\n /**\n * Returns the event data\n */\n public getData(): T {\n return this.eventData;\n }\n}\n","import { type InternalPageMessageMethod } from \"../APIs/InternalMessages/InternalMessageSource.js\";\nimport { ToShopfront } from \"../ApplicationEvents.js\";\nimport { BaseEmitableEvent } from \"./BaseEmitableEvent.js\";\n\nexport class InternalMessage<T> extends BaseEmitableEvent<{\n method: InternalPageMessageMethod;\n url: string;\n message: T;\n}> {\n constructor(method: InternalPageMessageMethod, destination: string, message: T) {\n super(ToShopfront.INTERNAL_PAGE_MESSAGE, {\n method,\n url: destination,\n message,\n });\n }\n}\n","import { Application } from \"../../Application.js\";\nimport { type FromShopfront } from \"../../ApplicationEvents.js\";\nimport { InternalMessage } from \"../../EmitableEvents/InternalMessage.js\";\n\nexport type InternalPageMessageMethod = keyof FromShopfront | \"EXTERNAL_APPLICATION\";\n\nexport class InternalMessageSource {\n protected application: Application;\n protected method: InternalPageMessageMethod;\n protected url: string;\n\n constructor(application: Application, method: InternalPageMessageMethod, url: string) {\n this.application = application;\n this.method = method;\n this.url = url;\n }\n\n /**\n * Sends an internal message to Shopfront\n */\n public send(message: unknown): void {\n this.application.send(new InternalMessage(this.method, this.url, message));\n }\n}\n","import * as ApplicationEvents from \"./ApplicationEvents.js\";\n\nexport type ApplicationEventListener = (\n event: keyof ApplicationEvents.FromShopfront | keyof ApplicationEvents.FromShopfrontInternal,\n data: Record<string, unknown>,\n id: string\n) => void;\n\nexport abstract class BaseBridge {\n public key: string;\n public url: URL;\n protected listeners: Array<ApplicationEventListener> = [];\n protected hasListener = false;\n protected target: Window | null = null;\n\n protected constructor(key: string, url: string | null) {\n this.key = key;\n\n if(!url) {\n this.url = new URL(\"communicator://javascript\"); // This isn't used in this scenario\n } else if(url.split(\".\").length === 1) {\n this.url = new URL(`https://${url}.onshopfront.com`);\n } else {\n this.url = new URL(url);\n }\n }\n\n /**\n * Destroys the Bridge by unregistering all listeners\n */\n public abstract destroy(): void;\n\n /**\n * Register the event listener for any window messages\n */\n protected abstract registerListeners(): void;\n\n /**\n * Removes the window message event listener\n */\n protected abstract unregisterListeners(): void;\n\n /**\n * Sends an event to Shopfront\n */\n public abstract sendMessage(type: ApplicationEvents.ToShopfront, data?: unknown, id?: string): void;\n\n /**\n * Adds a listener for a Shopfront event\n */\n public abstract addEventListener(listener: ApplicationEventListener): void;\n\n /**\n * Removes a listener for a Shopfront event\n */\n public abstract removeEventListener(listener: ApplicationEventListener): void;\n}\n","import { BaseBridge } from \"../BaseBridge.js\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype _Infer = any;\n\nexport abstract class BaseEvent<\n TData = _Infer,\n TCallbackReturn = void,\n TEmitReturn = _Infer,\n TCallbackData = TData,\n TCallbackContext = undefined\n> {\n protected callback: (data: TCallbackData, context: TCallbackContext) => TCallbackReturn;\n\n protected constructor(callback: (data: TCallbackData, context: TCallbackContext) => TCallbackReturn) {\n this.callback = callback;\n }\n\n /**\n * Invokes the registered callback\n */\n public abstract emit(data: TData, bridge?: BaseBridge): Promise<TEmitReturn>;\n}\n","import type { AudioPermissionChangeEvent, FromShopfrontCallbacks, FromShopfrontReturns } from \"../ApplicationEvents.js\";\nimport { BaseEvent } from \"./BaseEvent.js\";\n\nexport class AudioPermissionChange extends BaseEvent<AudioPermissionChangeEvent> {\n constructor(callback: FromShopfrontCallbacks[\"AUDIO_PERMISSION_CHANGE\"]) {\n super(callback);\n }\n\n /**\n * @inheritDoc\n */\n public async emit(data: AudioPermissionChangeEvent): Promise<FromShopfrontReturns[\"AUDIO_PERMISSION_CHANGE\"]> {\n return this.callback(data, undefined);\n }\n}\n","import { type FromShopfrontCallbacks, type FromShopfrontReturns } from \"../ApplicationEvents.js\";\nimport { BaseEvent } from \"./BaseEvent.js\";\n\nexport class AudioReady extends BaseEvent<undefined> {\n constructor(callback: FromShopfrontCallbacks[\"AUDIO_READY\"]) {\n super(callback);\n }\n\n /**\n * @inheritDoc\n */\n public async emit(): Promise<FromShopfrontReturns[\"AUDIO_READY\"]> {\n return this.callback(undefined, undefined);\n }\n}\n","import type {\n DirectShopfrontCallbacks,\n DirectShopfrontEvent,\n DirectShopfrontEventData,\n} from \"../../ApplicationEvents.js\";\n\nexport abstract class BaseDirectEvent<\n TEvent extends DirectShopfrontEvent,\n TData = DirectShopfrontEventData[TEvent],\n TCallback = DirectShopfrontCallbacks[TEvent],\n> {\n protected callback: TCallback;\n\n protected constructor(callback: TCallback) {\n this.callback = callback;\n }\n\n /**\n * Ensures the event data is formatted correctly\n */\n protected abstract isEventData(event: unknown): event is TData;\n\n /**\n * Invokes the registered callback\n */\n public abstract emit(event: unknown): Promise<void>;\n}\n","import { type DirectShopfrontCallbacks, type DirectShopfrontEventData } from \"../../ApplicationEvents.js\";\nimport { BaseDirectEvent } from \"./BaseDirectEvent.js\";\n\nexport class SaleAddCustomer extends BaseDirectEvent<\"SALE_ADD_CUSTOMER\"> {\n constructor(callback: DirectShopfrontCallbacks[\"SALE_ADD_CUSTOMER\"]) {\n super(callback);\n }\n\n /**\n * @inheritDoc\n */\n protected isEventData(event: unknown): event is DirectShopfrontEventData[\"SALE_ADD_CUSTOMER\"] {\n if(!event || typeof event !== \"object\") {\n return false;\n }\n\n return \"customer\" in event;\n }\n\n /**\n * @inheritDoc\n */\n public async emit(event: unknown): Promise<void> {\n if(!this.isEventData(event)) {\n return;\n }\n\n return this.callback(event);\n }\n}\n","import { type DirectShopfrontCallbacks, type DirectShopfrontEventData } from \"../../ApplicationEvents.js\";\nimport { BaseDirectEvent } from \"./BaseDirectEvent.js\";\n\nexport class SaleAddProduct extends BaseDirectEvent<\"SALE_ADD_PRODUCT\"> {\n constructor(callback: DirectShopfrontCallbacks[\"SALE_ADD_PRODUCT\"]) {\n super(callback);\n }\n\n /**\n * @inheritDoc\n */\n protected isEventData(event: unknown): event is DirectShopfrontEventData[\"SALE_ADD_PRODUCT\"] {\n if(!event || typeof event !== \"object\") {\n return false;\n }\n\n return \"product\" in event && \"indexAddress\" in event;\n }\n\n /**\n * @inheritDoc\n */\n public async emit(event: unknown): Promise<void> {\n if(!this.isEventData(event)) {\n return;\n }\n\n return this.callback(event);\n }\n}\n","import { type DirectShopfrontCallbacks, type DirectShopfrontEventData } from \"../../ApplicationEvents.js\";\nimport { BaseDirectEvent } from \"./BaseDirectEvent.js\";\n\nexport class SaleChangeQuantity extends BaseDirectEvent<\"SALE_CHANGE_QUANTITY\"> {\n constructor(callback: DirectShopfrontCallbacks[\"SALE_CHANGE_QUANTITY\"]) {\n super(callback);\n }\n\n /**\n * @inheritDoc\n */\n protected isEventData(event: unknown): event is DirectShopfrontEventData[\"SALE_CHANGE_QUANTITY\"] {\n if(!event || typeof event !== \"object\") {\n return false;\n }\n\n return \"indexAddress\" in event && \"amount\" in event && \"absolute\" in event;\n }\n\n /**\n * @inheritDoc\n */\n public async emit(event: unknown): Promise<void> {\n if(!this.isEventData(event)) {\n return;\n }\n\n return this.callback(event);\n }\n}\n","import { type DirectShopfrontCallbacks, type DirectShopfrontEventData } from \"../../ApplicationEvents.js\";\nimport { BaseDirectEvent } from \"./BaseDirectEvent.js\";\n\nexport class SaleClear extends BaseDirectEvent<\"SALE_CLEAR\"> {\n constructor(callback: DirectShopfrontCallbacks[\"SALE_CLEAR\"]) {\n super(callback);\n }\n\n /**\n * @inheritDoc\n */\n protected isEventData(event: unknown): event is DirectShopfrontEventData[\"SALE_CLEAR\"] {\n return true;\n }\n\n /**\n * @inheritDoc\n */\n public async emit(event: unknown): Promise<void> {\n if(!this.isEventData(event)) {\n return;\n }\n\n return this.callback();\n }\n}\n","import { type DirectShopfrontCallbacks, type DirectShopfrontEventData } from \"../../ApplicationEvents.js\";\nimport { BaseDirectEvent } from \"./BaseDirectEvent.js\";\n\nexport class SaleRemoveCustomer extends BaseDirectEvent<\"SALE_REMOVE_CUSTOMER\"> {\n constructor(callback: DirectShopfrontCallbacks[\"SALE_REMOVE_CUSTOMER\"]) {\n super(callback);\n }\n\n /**\n * @inheritDoc\n */\n protected isEventData(event: unknown): event is DirectShopfrontEventData[\"SALE_REMOVE_CUSTOMER\"] {\n return true;\n }\n\n /**\n * @inheritDoc\n */\n public async emit(event: unknown): Promise<void> {\n if(!this.isEventData(event)) {\n return;\n }\n\n return this.callback();\n }\n}\n","import { type DirectShopfrontCallbacks, type DirectShopfrontEventData } from \"../../ApplicationEvents.js\";\nimport { BaseDirectEvent } from \"./BaseDirectEvent.js\";\n\nexport class SaleRemoveProduct extends BaseDirectEvent<\"SALE_REMOVE_PRODUCT\"> {\n constructor(callback: DirectShopfrontCallbacks[\"SALE_REMOVE_PRODUCT\"]) {\n super(callback);\n }\n\n /**\n * @inheritDoc\n */\n protected isEventData(event: unknown): event is DirectShopfrontEventData[\"SALE_REMOVE_PRODUCT\"] {\n if(!event || typeof event !== \"object\") {\n return false;\n }\n\n return \"indexAddress\" in event;\n }\n\n /**\n * @inheritDoc\n */\n public async emit(event: unknown): Promise<void> {\n if(!this.isEventData(event)) {\n return;\n }\n\n return this.callback(event);\n }\n}\n","import { type DirectShopfrontCallbacks, type DirectShopfrontEventData } from \"../../ApplicationEvents.js\";\nimport { BaseDirectEvent } from \"./BaseDirectEvent.js\";\n\nexport class SaleUpdateProducts extends BaseDirectEvent<\"SALE_UPDATE_PRODUCTS\"> {\n constructor(callback: DirectShopfrontCallbacks[\"SALE_UPDATE_PRODUCTS\"]) {\n super(callback);\n }\n\n /**\n * @inheritDoc\n */\n protected isEventData(event: unknown): event is DirectShopfrontEventData[\"SALE_UPDATE_PRODUCTS\"] {\n if(!event || typeof event !== \"object\") {\n return false;\n }\n\n return \"products\" in event;\n }\n\n /**\n * @inheritDoc\n */\n public async emit(event: unknown): Promise<void> {\n if(!this.isEventData(event)) {\n return;\n }\n\n return this.callback(event);\n }\n}\n","import {\n type FromShopfrontCallbacks,\n type FromShopfrontReturns,\n ToShopfront,\n} from \"../ApplicationEvents.js\";\nimport { BaseBridge } from \"../BaseBridge.js\";\nimport { type MaybePromise } from \"../Utilities/MiscTypes.js\";\nimport { BaseEvent } from \"./BaseEvent.js\";\n\nexport type FormattedSaleProductType =\n \"Normal\" |\n \"Product\" |\n \"GiftCard\" |\n \"Voucher\" |\n \"Basket\" |\n \"Package\" |\n \"Component\" |\n \"Integrated\";\n\nexport interface SaleGiftCard {\n code: string;\n amount: number;\n expiry: string;\n}\n\nexport interface FormattedSaleProduct {\n uuid: string;\n type: FormattedSaleProductType;\n name: string;\n caseQuantity: number;\n isCase: boolean;\n quantity: number;\n loyalty: {\n earn: number;\n redeem: number;\n };\n prices: {\n price: number; // Will always be the correct price\n unlockedPrice: number; // The price if the product was unlocked\n normal: number; // The normal everyday price\n base: number; // The single price * the quantity\n addPrice: number; // The additional price to add to the product cost (for components)\n removePrice: number; // The additional price to remove from the product (for components)\n additionalPrice: number; // The additional price that has been applied to the product (for packages)\n };\n tax: {\n id: false | string;\n amount: number;\n };\n products: Array<FormattedSaleProduct>;\n defaultProducts: Array<FormattedSaleProduct>;\n special: boolean;\n edited: boolean;\n promotions: Record<string, {\n name: string;\n active: boolean;\n quantity: number;\n }>;\n rebates: Record<string, {\n amount: number;\n quantity: number;\n }>;\n giftCard: SaleGiftCard | null;\n note: string;\n userId: null | string;\n priceSet?: string;\n deleted?: boolean;\n initiallyDeleted?: boolean;\n familyId: string | null;\n canUnlock: boolean;\n discountReason?: string;\n requestPrice?: boolean;\n lockQuantity: boolean;\n metaData: Record<string, unknown>;\n}\n\ninterface FormattedIntegratedProductData {\n data: {\n product: FormattedSaleProduct;\n };\n context: Record<string, never>;\n}\n\nexport class FormatIntegratedProduct extends BaseEvent<\n FormattedIntegratedProductData,\n MaybePromise<FromShopfrontReturns[\"FORMAT_INTEGRATED_PRODUCT\"]>,\n FromShopfrontReturns[\"FORMAT_INTEGRATED_PRODUCT\"],\n FormattedIntegratedProductData[\"data\"],\n Record<string, never>\n> {\n\n constructor(callback: FromShopfrontCallbacks[\"FORMAT_INTEGRATED_PRODUCT\"]) {\n super(callback);\n }\n\n /**\n * @inheritDoc\n */\n public async emit(\n data: FormattedIntegratedProductData\n ): Promise<FromShopfrontReturns[\"FORMAT_INTEGRATED_PRODUCT\"]> {\n const result = await this.callback(data.data, data.context);\n\n if(typeof result !== \"object\" || result === null) {\n throw new TypeError(\"Callback must return an object\");\n }\n\n return result;\n }\n\n /**\n * Sends the response data to Shopfront\n */\n public static async respond(\n bridge: BaseBridge,\n data: Array<FromShopfrontReturns[\"FORMAT_INTEGRATED_PRODUCT\"]>,\n id: string\n ): Promise<void> {\n if(data.length > 1) {\n throw new Error(\n \"Multiple integrated product responses found, \" +\n \"please ensure you are only subscribed to FORMAT_INTEGRATED_PRODUCT once\"\n );\n }\n\n bridge.sendMessage(ToShopfront.RESPONSE_FORMAT_PRODUCT, data[0], id);\n }\n}\n","import { type FromShopfrontCallbacks, type FromShopfrontReturns } from \"../ApplicationEvents.js\";\nimport { BaseEvent } from \"./BaseEvent.js\";\n\nexport class FulfilmentCollectOrder extends BaseEvent {\n constructor(callback: FromShopfrontCallbacks[\"FULFILMENT_ORDER_COLLECTED\"]) {\n super(callback);\n }\n\n /**\n * @inheritDoc\n */\n public async emit(data: string): Promise<FromShopfrontReturns[\"FULFILMENT_ORDER_COLLECTED\"]> {\n return this.callback(data, undefined);\n }\n}\n","import { type FromShopfrontCallbacks, type FromShopfrontReturns } from \"../ApplicationEvents.js\";\nimport { BaseEvent } from \"./BaseEvent.js\";\n\nexport class FulfilmentCompleteOrder extends BaseEvent {\n constructor(callback: FromShopfrontCallbacks[\"FULFILMENT_ORDER_COMPLETED\"]) {\n super(callback);\n }\n\n /**\n * @inheritDoc\n */\n public async emit(data: string): Promise<FromShopfrontReturns[\"FULFILMENT_ORDER_COLLECTED\"]> {\n return this.callback(data, undefined);\n }\n}\n","import { type OrderDetails } from \"../APIs/Fulfilment/FulfilmentTypes.js\";\nimport { type FromShopfrontCallbacks, type FromShopfrontReturns, ToShopfront } from \"../ApplicationEvents.js\";\nimport { BaseBridge } from \"../BaseBridge.js\";\nimport { type MaybePromise } from \"../Utilities/MiscTypes.js\";\nimport { BaseEvent } from \"./BaseEvent.js\";\n\nexport class FulfilmentGetOrder extends BaseEvent<\n string,\n MaybePromise<FromShopfrontReturns[\"FULFILMENT_GET_ORDER\"]>,\n MaybePromise<FromShopfrontReturns[\"FULFILMENT_GET_ORDER\"]>\n> {\n constructor(callback: FromShopfrontCallbacks[\"FULFILMENT_GET_ORDER\"]) {\n super(callback);\n }\n\n /**\n * @inheritDoc\n */\n public async emit(data: string): Promise<FromShopfrontReturns[\"FULFILMENT_GET_ORDER\"]> {\n return this.callback(data, undefined);\n }\n\n /**\n * Sends the response data to Shopfront\n */\n public static async respond(bridge: BaseBridge, order: OrderDetails, id: string): Promise<void> {\n bridge.sendMessage(ToShopfront.FULFILMENT_GET_ORDER, order, id);\n }\n}\n","import {\n type FromShopfrontCallbacks,\n type FromShopfrontReturns,\n type FulfilmentApprovalEvent,\n} from \"../ApplicationEvents.js\";\nimport { BaseEvent } from \"./BaseEvent.js\";\n\nexport class FulfilmentOrderApproval extends BaseEvent<\n FulfilmentApprovalEvent,\n FromShopfrontReturns[\"FULFILMENT_ORDER_APPROVAL\"],\n FromShopfrontReturns[\"FULFILMENT_ORDER_APPROVAL\"]\n> {\n constructor(callback: FromShopfrontCallbacks[\"FULFILMENT_ORDER_APPROVAL\"]) {\n super(callback);\n }\n\n /**\n * @inheritDoc\n */\n public async emit(data: FulfilmentApprovalEvent): Promise<FromShopfrontReturns[\"FULFILMENT_ORDER_APPROVAL\"]> {\n return this.callback(data, undefined);\n }\n}\n","import { Sale, type ShopfrontSaleState } from \"../APIs/Sale/index.js\";\nimport type { FromShopfrontCallbacks, FromShopfrontReturns, FulfilmentProcessEvent } from \"../ApplicationEvents.js\";\nimport { type MaybePromise } from \"../Utilities/MiscTypes.js\";\nimport { BaseEvent } from \"./BaseEvent.js\";\n\ninterface FulfilmentProcessOrderData {\n id: string;\n sale: ShopfrontSaleState;\n}\n\nexport class FulfilmentProcessOrder extends BaseEvent<\n FulfilmentProcessOrderData,\n MaybePromise<FromShopfrontReturns[\"FULFILMENT_PROCESS_ORDER\"]>,\n MaybePromise<FromShopfrontReturns[\"FULFILMENT_PROCESS_ORDER\"]>,\n FulfilmentProcessEvent\n> {\n constructor(callback: FromShopfrontCallbacks[\"FULFILMENT_PROCESS_ORDER\"]) {\n super(callback);\n }\n\n /**\n * @inheritDoc\n */\n public async emit(\n data: FulfilmentProcessOrderData\n ): Promise<FromShopfrontReturns[\"FULFILMENT_PROCESS_ORDER\"]> {\n return this.callback({\n id : data.id,\n sale: new Sale(Sale.buildSaleData(data.sale)),\n }, undefined);\n }\n}\n","import { type FromShopfrontCallbacks, type FromShopfrontReturns } from \"../ApplicationEvents.js\";\nimport { BaseEvent } from \"./BaseEvent.js\";\n\nexport class FulfilmentVoidOrder extends BaseEvent {\n constructor(callback: FromShopfrontCallbacks[\"FULFILMENT_VOID_ORDER\"]) {\n super(callback);\n }\n\n /**\n * @inheritDoc\n */\n public async emit(data: string): Promise<FromShopfrontReturns[\"FULFILMENT_VOID_ORDER\"]> {\n return this.callback(data, undefined);\n }\n}\n","import {\n type FromShopfrontCallbacks,\n type FromShopfrontReturns,\n type GiftCardCodeCheckEvent,\n ToShopfront,\n} from \"../ApplicationEvents.js\";\nimport { BaseBridge } from \"../BaseBridge.js\";\nimport { type MaybePromise } from \"../Utilities/MiscTypes.js\";\nimport { BaseEvent } from \"./BaseEvent.js\";\n\ninterface GiftCardCodeCheckData {\n data: GiftCardCodeCheckEvent;\n}\n\nexport class GiftCardCodeCheck extends BaseEvent<\n GiftCardCodeCheckData,\n MaybePromise<FromShopfrontReturns[\"GIFT_CARD_CODE_CHECK\"]>,\n FromShopfrontReturns[\"GIFT_CARD_CODE_CHECK\"],\n GiftCardCodeCheckEvent\n> {\n constructor(callback: FromShopfrontCallbacks[\"GIFT_CARD_CODE_CHECK\"]) {\n super(callback);\n }\n\n /**\n * @inheritDoc\n */\n public async emit(\n data: GiftCardCodeCheckData\n ): Promise<FromShopfrontReturns[\"GIFT_CARD_CODE_CHECK\"]> {\n const result = await this.callback(data.data, undefined);\n\n if(typeof result !== \"object\") {\n throw new TypeError(\"Callback must return an object\");\n }\n\n return result;\n }\n\n /**\n * Sends the response data to Shopfront\n */\n public static async respond(\n bridge: BaseBridge,\n data: FromShopfrontReturns[\"GIFT_CARD_CODE_CHECK\"],\n id: string\n ): Promise<void> {\n bridge.sendMessage(ToShopfront.RESPONSE_GIFT_CARD_CODE_CHECK, data, id);\n }\n}\n","import { InternalMessageSource } from \"../APIs/InternalMessages/InternalMessageSource.js\";\nimport { Application } from \"../Application.js\";\nimport {\n type FromShopfront,\n type FromShopfrontCallbacks,\n type FromShopfrontReturns,\n type InternalPageMessageEvent,\n} from \"../ApplicationEvents.js\";\nimport { BaseEvent } from \"./BaseEvent.js\";\n\nexport class InternalPageMessage extends BaseEvent<InternalPageMessageEvent> {\n protected application: Application;\n\n constructor(callback: FromShopfrontCallbacks[\"INTERNAL_PAGE_MESSAGE\"], application: Application) {\n super(callback);\n\n this.application = application;\n }\n\n /**\n * Creates and returns a new internal message source\n */\n protected createReference(\n method: keyof FromShopfront | \"EXTERNAL_APPLICATION\",\n url: string\n ): InternalMessageSource {\n return new InternalMessageSource(\n this.application,\n method,\n url\n );\n }\n\n /**\n * @inheritDoc\n */\n public async emit(data: InternalPageMessageEvent): Promise<FromShopfrontReturns[\"INTERNAL_PAGE_MESSAGE\"]> {\n return this.callback({\n method : data.method,\n url : data.url,\n message : data.message,\n reference: this.createReference(data.method, data.url),\n }, undefined);\n }\n}\n","import {\n type FromShopfrontCallbacks,\n type FromShopfrontReturns,\n type PaymentMethodEnabledContext,\n type SellScreenPaymentMethod,\n ToShopfront,\n} from \"../ApplicationEvents.js\";\nimport { BaseBridge } from \"../BaseBridge.js\";\nimport { type MaybePromise } from \"../Utilities/MiscTypes.js\";\nimport { BaseEvent } from \"./BaseEvent.js\";\n\ninterface PaymentMethodsEnabledData {\n data: Array<SellScreenPaymentMethod>;\n context: PaymentMethodEnabledContext;\n}\n\nexport class PaymentMethodsEnabled extends BaseEvent<\n PaymentMethodsEnabledData,\n MaybePromise<FromShopfrontReturns[\"PAYMENT_METHODS_ENABLED\"]>,\n FromShopfrontReturns[\"PAYMENT_METHODS_ENABLED\"],\n Array<SellScreenPaymentMethod>,\n PaymentMethodEnabledContext\n> {\n constructor(callback: FromShopfrontCallbacks[\"PAYMENT_METHODS_ENABLED\"]) {\n super(callback);\n }\n\n /**\n * @inheritDoc\n */\n public async emit(data: PaymentMethodsEnabledData): Promise<FromShopfrontReturns[\"PAYMENT_METHODS_ENABLED\"]> {\n const result = await this.callback(data.data, data.context);\n\n if(typeof result !== \"object\" || result === null) {\n throw new TypeError(\"Callback must return an object\");\n }\n\n return result;\n }\n\n /**\n * Sends the response data to Shopfront\n */\n public static async respond(\n bridge: BaseBridge,\n data: FromShopfrontReturns[\"PAYMENT_METHODS_ENABLED\"],\n id: string\n ): Promise<void> {\n bridge.sendMessage(ToShopfront.RESPONSE_UI_PIPELINE, data, id);\n }\n}\n","import type { FromShopfrontCallbacks, FromShopfrontReturns, RegisterChangedEvent } from \"../ApplicationEvents.js\";\nimport { BaseEvent } from \"./BaseEvent.js\";\n\ninterface ReadyData {\n outlet: string | null;\n register: string | null;\n user: string | null;\n}\n\nexport class Ready extends BaseEvent<RegisterChangedEvent> {\n constructor(callback: FromShopfrontCallbacks[\"READY\"]) {\n super(callback);\n }\n\n /**\n * @inheritDoc\n */\n public async emit(data: ReadyData): Promise<FromShopfrontReturns[\"READY\"]> {\n return this.callback({\n outlet : data.outlet,\n register: data.register,\n user : data.user,\n }, undefined);\n }\n}\n","import { type FromShopfrontCallbacks, type FromShopfrontReturns } from \"../ApplicationEvents.js\";\nimport { BaseEvent } from \"./BaseEvent.js\";\n\ninterface RegisterChangedData {\n outlet: string | null;\n register: string | null;\n user: string | null;\n}\n\nexport class RegisterChanged extends BaseEvent {\n constructor(callback: FromShopfrontCallbacks[\"REGISTER_CHANGED\"]) {\n super(callback);\n }\n\n /**\n * @inheritDoc\n */\n public async emit(data: RegisterChangedData): Promise<FromShopfrontReturns[\"REGISTER_CHANGED\"]> {\n return this.callback(data, undefined);\n }\n}\n","import { Button } from \"../Actions/Button.js\";\nimport { type FromShopfrontCallbacks, type FromShopfrontReturns, ToShopfront } from \"../ApplicationEvents.js\";\nimport { BaseBridge } from \"../BaseBridge.js\";\nimport { type MaybePromise } from \"../Utilities/MiscTypes.js\";\nimport { BaseEvent } from \"./BaseEvent.js\";\n\ninterface RequestButtonsData {\n location: string;\n id: string;\n context: unknown;\n}\n\nexport class RequestButtons extends BaseEvent<\n RequestButtonsData,\n MaybePromise<FromShopfrontReturns[\"REQUEST_BUTTONS\"]>,\n MaybePromise<FromShopfrontReturns[\"REQUEST_BUTTONS\"]>,\n string,\n unknown\n> {\n constructor(callback: FromShopfrontCallbacks[\"REQUEST_BUTTONS\"]) {\n super(callback);\n }\n\n /**\n * @inheritDoc\n */\n public async emit(data: RequestButtonsData): Promise<FromShopfrontReturns[\"REQUEST_BUTTONS\"]> {\n let result = await this.callback(data.location, data.context);\n\n if(!Array.isArray(result)) {\n result = [ result ];\n }\n\n for(let i = 0, l = result.length; i < l; i++) {\n if(!(result[i] instanceof Button)) {\n throw new TypeError(\"You must return an instance of Button\");\n }\n }\n\n return result;\n }\n\n /**\n * Sends the response data to Shopfront\n */\n public static async respond(bridge: BaseBridge, buttons: Array<Button>, id: string): Promise<void> {\n const response = [];\n\n for(let i = 0, l = buttons.length; i < l; i++) {\n if(!(buttons[i] instanceof Button)) {\n throw new TypeError(\"Invalid response returned, expected button\");\n }\n\n response.push(buttons[i].serialize());\n }\n\n bridge.sendMessage(ToShopfront.RESPONSE_BUTTONS, response, id);\n }\n}\n","import type { Serialized } from \"../Common/Serializable.js\";\nimport { BaseAction } from \"./BaseAction.js\";\n\nexport class CustomerListOption extends BaseAction<CustomerListOption> {\n protected supportedEvents = [ \"click\" ];\n\n protected contents: string;\n\n constructor(contents: Serialized<CustomerListOption> | string) {\n super((() => {\n if(typeof contents === \"string\") {\n return {\n properties: [ contents ],\n events : {},\n type : \"CustomerListOption\",\n };\n }\n\n return contents;\n })(), CustomerListOption);\n\n if(typeof contents === \"string\") {\n this.contents = contents;\n } else {\n this.contents = contents.properties[0] as string;\n }\n }\n}\n","import { CustomerListOption } from \"../Actions/CustomerListOption.js\";\nimport { type FromShopfrontCallbacks, type FromShopfrontReturns, ToShopfront } from \"../ApplicationEvents.js\";\nimport { BaseBridge } from \"../BaseBridge.js\";\nimport { type MaybePromise } from \"../Utilities/MiscTypes.js\";\nimport { BaseEvent } from \"./BaseEvent.js\";\n\nexport interface SellScreenCustomerListOption {\n contents: string;\n onClick: () => void;\n}\n\nexport class RequestCustomerListOptions extends BaseEvent<\n Record<string, unknown>,\n MaybePromise<FromShopfrontReturns[\"REQUEST_CUSTOMER_LIST_OPTIONS\"]>,\n FromShopfrontReturns[\"REQUEST_CUSTOMER_LIST_OPTIONS\"],\n undefined\n> {\n constructor(callback: FromShopfrontCallbacks[\"REQUEST_CUSTOMER_LIST_OPTIONS\"]) {\n super(callback);\n }\n\n /**\n * @inheritDoc\n */\n public async emit(_: Record<string, unknown>): Promise<FromShopfrontReturns[\"REQUEST_CUSTOMER_LIST_OPTIONS\"]> {\n let result = await this.callback(undefined, undefined);\n\n if(!Array.isArray(result)) {\n result = [ result ];\n }\n\n for(let i = 0, l = result.length; i < l; i++) {\n if(!result[i].contents || !result[i].onClick) {\n throw new TypeError(\"You must specify both the contents and an onClick callback\");\n }\n }\n\n return result;\n }\n\n /**\n * Sends the response data to Shopfront\n */\n public static async respond(\n bridge: BaseBridge,\n options: Array<SellScreenCustomerListOption>,\n id: string\n ): Promise<void> {\n bridge.sendMessage(\n ToShopfront.RESPONSE_CUSTOMER_LIST_OPTIONS,\n options.map(option => {\n const o = new CustomerListOption(option.contents);\n\n o.addEventListener(\"click\", option.onClick);\n\n return o.serialize();\n }),\n id\n );\n }\n}\n","import { SaleKey } from \"../Actions/SaleKey.js\";\nimport { type FromShopfrontCallbacks, type FromShopfrontReturns, ToShopfront } from \"../ApplicationEvents.js\";\nimport { BaseBridge } from \"../BaseBridge.js\";\nimport { type MaybePromise } from \"../Utilities/MiscTypes.js\";\nimport { BaseEvent } from \"./BaseEvent.js\";\n\nexport class RequestSaleKeys extends BaseEvent<undefined, MaybePromise<Array<SaleKey>>, Array<SaleKey>> {\n constructor(callback: FromShopfrontCallbacks[\"REQUEST_SALE_KEYS\"]) {\n super(callback);\n }\n\n /**\n * @inheritDoc\n */\n public async emit(): Promise<FromShopfrontReturns[\"REQUEST_SALE_KEYS\"]> {\n let result = await this.callback(undefined, undefined);\n\n if(!Array.isArray(result)) {\n result = [ result ];\n }\n\n for(let i = 0, l = result.length; i < l; i++) {\n if(!(result[i] instanceof SaleKey)) {\n throw new TypeError(\"You must return an instance of SaleKey\");\n }\n }\n\n return result;\n }\n\n /**\n * Sends the response data to Shopfront\n */\n public static async respond(bridge: BaseBridge, keys: Array<SaleKey>, id: string): Promise<void> {\n const response = [];\n\n for(let i = 0, l = keys.length; i < l; i++) {\n if(!(keys[i] instanceof SaleKey)) {\n throw new TypeError(\"Invalid response returned, expected SaleKey\");\n }\n\n response.push(keys[i].serialize());\n }\n\n bridge.sendMessage(ToShopfront.RESPONSE_SALE_KEYS, response, id);\n }\n}\n","import { type FromShopfrontCallbacks, type FromShopfrontReturns, ToShopfront } from \"../ApplicationEvents.js\";\nimport { BaseBridge } from \"../BaseBridge.js\";\nimport { type MaybePromise } from \"../Utilities/MiscTypes.js\";\nimport { BaseEvent } from \"./BaseEvent.js\";\n\nexport interface SellScreenOption {\n url: string;\n title: string;\n id?: string;\n}\n\nexport class RequestSellScreenOptions extends BaseEvent<\n undefined,\n MaybePromise<FromShopfrontReturns[\"REQUEST_SELL_SCREEN_OPTIONS\"]>,\n FromShopfrontReturns[\"REQUEST_SELL_SCREEN_OPTIONS\"]\n> {\n constructor(callback: FromShopfrontCallbacks[\"REQUEST_SELL_SCREEN_OPTIONS\"]) {\n super(callback);\n }\n\n /**\n * Generates a unique identifier for a URL by encoding it to base64.\n * If the URL contains non-ASCII characters, it first URI-encodes the URL before converting to base64.\n */\n public static getOptionId(url: string): string {\n try {\n return btoa(url);\n } catch(e) {\n // Contains non-ASCII characters, convert and then encode\n return btoa(encodeURI(url));\n }\n }\n\n /**\n * Validates the URL by ensuring it follows the HTTPS protocol\n */\n public static validateURL(url: string): void {\n const urlObj = new URL(url);\n\n if(urlObj.protocol !== \"https:\") {\n throw new TypeError(`The URL \"${url}\" is invalid, please ensure that you're using the HTTPS protocol`);\n }\n }\n\n /**\n * @inheritDoc\n */\n public async emit(_: never): Promise<FromShopfrontReturns[\"REQUEST_SELL_SCREEN_OPTIONS\"]> {\n let result = await this.callback(undefined, undefined);\n\n if(!Array.isArray(result)) {\n result = [ result ];\n }\n\n for(let i = 0, l = result.length; i < l; i++) {\n if(!result[i].url || !result[i].title) {\n throw new TypeError(\"You must specify both a URL and a title\");\n }\n\n RequestSellScreenOptions.validateURL(result[i].url);\n\n result[i].id = RequestSellScreenOptions.getOptionId(result[i].url);\n }\n\n return result;\n }\n\n /**\n * Sends the response data to Shopfront\n */\n public static async respond(bridge: BaseBridge, options: Array<SellScreenOption>, id: string): Promise<void> {\n bridge.sendMessage(ToShopfront.RESPONSE_SELL_SCREEN_OPTIONS, options, id);\n }\n}\n","import { type FromShopfrontCallbacks, type FromShopfrontReturns, ToShopfront } from \"../ApplicationEvents.js\";\nimport { BaseBridge } from \"../BaseBridge.js\";\nimport { type MaybePromise } from \"../Utilities/MiscTypes.js\";\nimport { BaseEvent } from \"./BaseEvent.js\";\n\nexport class RequestSettings extends BaseEvent<\n undefined,\n MaybePromise<FromShopfrontReturns[\"REQUEST_SETTINGS\"]>,\n FromShopfrontReturns[\"REQUEST_SETTINGS\"]\n> {\n constructor(callback: FromShopfrontCallbacks[\"REQUEST_SETTINGS\"]) {\n super(callback);\n }\n\n /**\n * @inheritDoc\n */\n public async emit(_: never): Promise<FromShopfrontReturns[\"REQUEST_SETTINGS\"]> {\n const result = await this.callback(undefined, undefined);\n\n if(typeof result !== \"object\" || result === null) {\n throw new TypeError(\"Callback must return an object\");\n }\n\n return result;\n }\n\n /**\n * Sends the response data to Shopfront\n */\n public static async respond(\n bridge: BaseBridge,\n settings: Array<FromShopfrontReturns[\"REQUEST_SETTINGS\"]>,\n id: string\n ): Promise<void> {\n if(settings.length > 1) {\n throw new Error(\n \"Multiple settings responses found, \" +\n \"please ensure you are only subscribed to REQUEST_SETTINGS once\"\n );\n }\n\n bridge.sendMessage(ToShopfront.RESPONSE_SETTINGS, settings[0], id);\n }\n}\n","import { type FromShopfrontCallbacks, type FromShopfrontReturns, ToShopfront } from \"../ApplicationEvents.js\";\nimport { BaseBridge } from \"../BaseBridge.js\";\nimport { type MaybePromise } from \"../Utilities/MiscTypes.js\";\nimport { BaseEvent } from \"./BaseEvent.js\";\n\ninterface RequestTableColumnsData {\n location: string;\n context: unknown;\n}\n\nexport class RequestTableColumns extends BaseEvent<\n RequestTableColumnsData,\n MaybePromise<FromShopfrontReturns[\"REQUEST_TABLE_COLUMNS\"]>,\n FromShopfrontReturns[\"REQUEST_TABLE_COLUMNS\"],\n string,\n unknown\n> {\n constructor(callback: FromShopfrontCallbacks[\"REQUEST_TABLE_COLUMNS\"]) {\n super(callback);\n }\n\n /**\n * @inheritDoc\n */\n public async emit(data: RequestTableColumnsData): Promise<FromShopfrontReturns[\"REQUEST_TABLE_COLUMNS\"]> {\n const result = await this.callback(data.location, data.context);\n\n if(typeof result !== \"object\") {\n throw new TypeError(\"Callback must return an object\");\n }\n\n return result;\n }\n\n /**\n * Sends the response data to Shopfront\n */\n public static async respond(\n bridge: BaseBridge,\n columns: Array<FromShopfrontReturns[\"REQUEST_TABLE_COLUMNS\"]>,\n id: string\n ): Promise<void> {\n columns = columns.filter(column => column !== null);\n\n if(columns.length > 1) {\n throw new Error(\n \"Multiple table column responses found,\" +\n \"please ensure you are only subscribed to REQUEST_TABLE_COLUMNS once\"\n );\n }\n\n bridge.sendMessage(ToShopfront.RESPONSE_TABLE_COLUMNS, columns[0], id);\n }\n}\n","import { type FromShopfrontCallbacks, type FromShopfrontReturns } from \"../ApplicationEvents.js\";\nimport { BaseEvent } from \"./BaseEvent.js\";\n\ninterface CompletedSaleProduct {\n uuid: string;\n type: \"Normal\" |\n \"Product\" |\n \"GiftCard\" |\n \"Voucher\" |\n \"Basket\" |\n \"Package\" |\n \"Component\" |\n \"Integrated\";\n name: string;\n caseQuantity: number;\n isCase: boolean;\n quantity: number;\n loyalty: {\n earn: number;\n redeem: number;\n };\n prices: {\n price: number; // Will always be the correct price\n unlockedPrice: number; // The price if the product was unlocked\n normal: number; // The normal everyday price\n base: number; // The single price * the quantity\n addPrice: number; // The additional price to add to the product cost (for components)\n removePrice: number; // The additional price to remove from the product (for components)\n additionalPrice: number; // The additional price that has been applied to the product (for packages)\n };\n tax: {\n id: false | string;\n amount: number;\n };\n products: Array<CompletedSaleProduct>;\n defaultProducts: Array<CompletedSaleProduct>;\n special: boolean;\n edited: boolean;\n promotions: Record<string, {\n name: string;\n active: boolean;\n quantity: number;\n }>;\n rebates: Record<string, {\n amount: number;\n quantity: number;\n }>;\n giftCard: {\n code: string;\n amount: number;\n expiry: string;\n } | null;\n note: string;\n userId: null | string;\n priceSet?: string;\n deleted?: boolean;\n initiallyDeleted?: boolean;\n familyId: string | null;\n canUnlock: boolean;\n discountReason?: string;\n requestPrice?: boolean;\n lockQuantity: boolean;\n metaData: Record<string, unknown>;\n}\n\ninterface CompletedSalePayment {\n method: string;\n type: string;\n status: \"approved\" | \"cancelled\" | \"declined\" | \"completed\" | \"failed\";\n amount: number;\n cashout: number;\n rounding: number | undefined;\n metadata: string;\n registerId: string;\n userId?: string;\n processTime?: string;\n receipt?: string;\n reverted: boolean;\n uploaded?: boolean;\n voucherRefund?: boolean;\n}\n\nexport interface CompletedSale {\n products: Array<CompletedSaleProduct>;\n customer: false | {\n uuid: string;\n };\n payments: Array<CompletedSalePayment>;\n notes: {\n internal: string;\n sale: string;\n };\n totals: {\n sale: number;\n remaining: number;\n paid: number;\n savings: number;\n discount: number;\n change: number;\n cashout: number;\n rounding: number;\n };\n registerId: string;\n userId: string;\n orderReference: string;\n refundReason: string;\n status: \"COMPLETED\";\n id: string;\n invoiceId: string;\n createdAt: string;\n metaData: Record<string, unknown>;\n}\n\nexport class SaleComplete extends BaseEvent {\n constructor(callback: FromShopfrontCallbacks[\"SALE_COMPLETE\"]) {\n super(callback);\n }\n\n /**\n * @inheritDoc\n */\n public async emit(data: CompletedSale): Promise<FromShopfrontReturns[\"SALE_COMPLETE\"]> {\n return this.callback(data, undefined);\n }\n}\n","import { Application } from \"./Application.js\";\nimport * as ApplicationEvents from \"./ApplicationEvents.js\";\nimport { type ApplicationEventListener, BaseBridge } from \"./BaseBridge.js\";\n\ninterface FrameApplicationOptions {\n id: string; // The Client ID\n vendor: string; // The Vendor's URL\n communicator?: \"frame\";\n}\n\ninterface JavaScriptApplicationOptions {\n id: string; // The Client ID\n communicator: \"javascript\";\n}\n\ntype ApplicationOptions = FrameApplicationOptions | JavaScriptApplicationOptions;\n\ntype JavaScriptSendMessageCallback = (message: {\n key: string;\n type: string;\n data: unknown;\n id?: string;\n}) => void;\n\nexport type JavaScriptReceiveMessageCallback = (\n type: keyof ApplicationEvents.FromShopfront | keyof ApplicationEvents.FromShopfrontInternal,\n data: Record<string, unknown>,\n id: string\n) => void;\n\nexport interface JavaScriptCommunicatorExports {\n execute: () => void;\n registerSendMessage: (callback: JavaScriptSendMessageCallback) => void;\n onReceiveMessage: JavaScriptReceiveMessageCallback;\n}\n\nexport class Bridge extends BaseBridge {\n /**\n * A static method for instantiating an Application\n */\n public static createApplication(options: ApplicationOptions): Application {\n if(typeof options.id === \"undefined\") {\n throw new TypeError(\"You must specify the ID for the application\");\n }\n\n if(options.communicator !== \"javascript\" && typeof options.vendor === \"undefined\") {\n throw new TypeError(\"You must specify the Vendor for the application\");\n }\n\n return new Application(\n new Bridge(\n options.id,\n options.communicator === \"javascript\" ? null : options.vendor,\n options.communicator ?? \"frame\"\n )\n );\n }\n\n protected javascriptIsReady = false;\n protected javascriptSendMessageCallback?: JavaScriptSendMessageCallback;\n\n /**\n * The JavaScript communicator instance\n */\n public get communicator(): JavaScriptCommunicatorExports {\n if(this.communicateVia !== \"javascript\") {\n throw new Error(\"The communicator can only be accessed when communicating via JavaScript\");\n }\n\n return {\n /**\n * This is called when the application is ready to communicate, essentially this is the same as the READY\n * event when calling through the frame\n */\n execute: () => {\n // This is the equivalent of calling the ready event\n this.javascriptIsReady = true;\n this.sendMessageViaJavaScript(ApplicationEvents.ToShopfront.READY);\n },\n registerSendMessage: (callback) => {\n this.javascriptSendMessageCallback = callback;\n },\n onReceiveMessage: (type, data, id) => {\n this.emitToListeners(type, data, id);\n },\n };\n }\n\n constructor(key: string, url: string | null, protected communicateVia: \"frame\" | \"javascript\") {\n if(communicateVia === \"frame\" && window.parent === window) {\n throw new Error(\"The bridge has not been initialised within a frame\");\n }\n\n if(communicateVia === \"frame\" && url === null) {\n throw new Error(\"The subdomain of the vendor has not been specified\");\n }\n\n if(communicateVia === \"javascript\" && url !== null) {\n throw new Error(\"You cannot specify a subdomain when using the JavaScript communicator\");\n }\n\n super(key, url);\n\n this.registerListeners();\n this.sendMessage(ApplicationEvents.ToShopfront.READY);\n }\n\n /**\n * @inheritDoc\n */\n public destroy(): void {\n this.unregisterListeners();\n this.listeners = [];\n }\n\n /**\n * @inheritDoc\n */\n protected registerListeners(): void {\n if(this.communicateVia === \"javascript\") {\n return;\n }\n\n window.addEventListener(\"message\", this.handleMessageFromFrame, false);\n }\n\n /**\n * @inheritDoc\n */\n protected unregisterListeners(): void {\n if(this.communicateVia === \"javascript\") {\n return;\n }\n\n window.removeEventListener(\"message\", this.handleMessageFromFrame);\n }\n\n /**\n * Emit an event to the currently registered listeners\n */\n protected emitToListeners(\n type: keyof ApplicationEvents.FromShopfront | keyof ApplicationEvents.FromShopfrontInternal,\n data: Record<string, unknown>,\n id: string\n ): void {\n const listeners = this.listeners;\n\n for(let i = 0, l = listeners.length; i < l; i++) {\n listeners[i](type, data, id);\n }\n }\n\n /**\n * Receive a message from the application frame and distribute it to the correct listener\n */\n protected handleMessageFromFrame = (event: MessageEvent): void => {\n if(event.origin !== this.url.origin) {\n return;\n }\n\n if(typeof event.data !== \"object\" || event.data === null) {\n return;\n }\n\n if(typeof event.data.type !== \"string\") {\n return;\n }\n\n if(event.data.from !== \"ShopfrontApplicationAgent\") {\n return;\n }\n\n if(typeof event.data.origins === \"undefined\") {\n return;\n } else if(event.data.origins.from !== this.url.origin || event.data.origins.to !== window.location.origin) {\n return;\n }\n\n if(this.target === null) {\n if(event.data.type !== \"READY\") {\n return;\n }\n\n if(window.parent !== event.source) {\n // Not from the parent frame\n return;\n }\n\n this.target = event.source;\n } else {\n if(event.source !== this.target) {\n // Not from the source we want\n return;\n }\n }\n\n // Emit the event\n this.emitToListeners(event.data.type, event.data.data, event.data.id);\n };\n\n /**\n * Send a message via the JavaScript communicator\n */\n protected sendMessageViaJavaScript(type: ApplicationEvents.ToShopfront, data?: unknown, id?: string): void {\n if(!this.javascriptIsReady && type === ApplicationEvents.ToShopfront.READY) {\n // The ready event is automatically called due to the application frame needing it\n return;\n }\n\n if(!this.javascriptIsReady) {\n throw new Error(\"We haven't received notification from Shopfront that the application is ready yet\");\n }\n\n if(typeof this.javascriptSendMessageCallback === \"undefined\") {\n throw new Error(\"Attempting to send a message to Shopfront before the module has been imported\");\n }\n\n this.javascriptSendMessageCallback({\n key: this.key,\n type,\n data,\n id,\n });\n }\n\n /**\n * @inheritDoc\n */\n public sendMessage(type: ApplicationEvents.ToShopfront, data?: unknown, id?: string): void {\n if(this.communicateVia === \"javascript\") {\n return this.sendMessageViaJavaScript(type, data, id);\n }\n\n if(type === ApplicationEvents.ToShopfront.READY) {\n if(typeof data !== \"undefined\") {\n throw new TypeError(\"The `data` parameter must be undefined when requesting ready state\");\n }\n\n if(this.target !== null) {\n throw new Error(\"Shopfront is already ready\");\n }\n\n window.parent.postMessage({\n type,\n origins: {\n to : this.url.origin,\n from: window.location.origin,\n },\n key: this.key,\n }, /* can't use this because of sandbox: this.url.origin */ \"*\");\n\n return;\n }\n\n if(this.target === null) {\n throw new Error(\"Shopfront is not ready\");\n }\n\n this.target.parent.postMessage({\n type,\n origins: {\n to : this.url.origin,\n from: window.location.origin,\n },\n key: this.key,\n id,\n data,\n }, \"*\" /* can't use this because of sandbox: this.url.origin */);\n }\n\n /**\n * @inheritDoc\n */\n public addEventListener(listener: ApplicationEventListener): void {\n if(this.listeners.includes(listener)) {\n throw new Error(\"The listener provided is already registered\");\n }\n\n this.listeners.push(listener);\n\n if(!this.hasListener) {\n this.sendMessage(ApplicationEvents.ToShopfront.READY);\n this.hasListener = true;\n }\n }\n\n /**\n * @inheritDoc\n */\n public removeEventListener(listener: ApplicationEventListener): void {\n const index = this.listeners.indexOf(listener);\n\n if(index === -1) {\n return;\n }\n\n this.listeners = [\n ...this.listeners.slice(0, index),\n ...this.listeners.slice(index + 1),\n ];\n }\n}\n","import {\n type FromShopfrontCallbacks,\n type FromShopfrontReturns,\n ToShopfront,\n type UIPipelineBaseContext,\n type UIPipelineContext,\n type UIPipelineResponse,\n} from \"../ApplicationEvents.js\";\nimport { BaseBridge } from \"../BaseBridge.js\";\nimport { Bridge } from \"../Bridge.js\";\nimport { type MaybePromise } from \"../Utilities/MiscTypes.js\";\nimport { BaseEvent } from \"./BaseEvent.js\";\n\ninterface UIPPipelineIncomingData {\n data: Array<UIPipelineResponse>;\n context: UIPipelineBaseContext;\n pipelineId?: string;\n}\n\nexport class UIPipeline extends BaseEvent<\n UIPPipelineIncomingData,\n MaybePromise<FromShopfrontReturns[\"UI_PIPELINE\"]>,\n FromShopfrontReturns[\"UI_PIPELINE\"],\n Array<UIPipelineResponse>,\n UIPipelineContext\n> {\n constructor(callback: FromShopfrontCallbacks[\"UI_PIPELINE\"]) {\n super(callback);\n }\n\n /**\n * @inheritDoc\n */\n public async emit(\n data: UIPPipelineIncomingData,\n bridge: Bridge\n ): Promise<FromShopfrontReturns[\"UI_PIPELINE\"]> {\n const context: UIPipelineContext = {\n ...data.context,\n };\n\n if(typeof data.pipelineId === \"string\") {\n context.trigger = () => {\n bridge.sendMessage(ToShopfront.PIPELINE_TRIGGER, {\n id: data.pipelineId,\n });\n };\n }\n\n const result = await this.callback(data.data, context);\n\n if(typeof result !== \"object\" || result === null) {\n throw new TypeError(\"Callback must return an object\");\n }\n\n return result;\n }\n\n /**\n * Sends the response data to Shopfront\n */\n public static async respond(\n bridge: BaseBridge,\n data: FromShopfrontReturns[\"UI_PIPELINE\"],\n id: string\n ): Promise<void> {\n bridge.sendMessage(ToShopfront.RESPONSE_UI_PIPELINE, data, id);\n }\n}\n","/* eslint @typescript-eslint/no-invalid-void-type: 0 */\nimport { Button } from \"./Actions/Button.js\";\nimport { SaleKey } from \"./Actions/SaleKey.js\";\nimport { type OrderDetails } from \"./APIs/Fulfilment/FulfilmentTypes.js\";\nimport { InternalMessageSource } from \"./APIs/InternalMessages/InternalMessageSource.js\";\nimport { Sale, type ShopfrontSaleState } from \"./APIs/Sale/index.js\";\nimport { AudioPermissionChange } from \"./Events/AudioPermissionChange.js\";\nimport { AudioReady } from \"./Events/AudioReady.js\";\nimport { Callback } from \"./Events/Callback.js\";\nimport { SaleAddCustomer } from \"./Events/DirectEvents/SaleAddCustomer.js\";\nimport { SaleAddProduct } from \"./Events/DirectEvents/SaleAddProduct.js\";\nimport { SaleChangeQuantity } from \"./Events/DirectEvents/SaleChangeQuantity.js\";\nimport { SaleClear } from \"./Events/DirectEvents/SaleClear.js\";\nimport { SaleRemoveCustomer } from \"./Events/DirectEvents/SaleRemoveCustomer.js\";\nimport { SaleRemoveProduct } from \"./Events/DirectEvents/SaleRemoveProduct.js\";\nimport { SaleUpdateProducts } from \"./Events/DirectEvents/SaleUpdateProducts.js\";\nimport { type SaleEventProduct } from \"./Events/DirectEvents/types/SaleEventData.js\";\nimport { FormatIntegratedProduct, type FormattedSaleProduct } from \"./Events/FormatIntegratedProduct.js\";\nimport { FulfilmentCollectOrder } from \"./Events/FulfilmentCollectOrder.js\";\nimport { FulfilmentCompleteOrder } from \"./Events/FulfilmentCompleteOrder.js\";\nimport { FulfilmentGetOrder } from \"./Events/FulfilmentGetOrder.js\";\nimport { FulfilmentOrderApproval } from \"./Events/FulfilmentOrderApproval.js\";\nimport { FulfilmentProcessOrder } from \"./Events/FulfilmentProcessOrder.js\";\nimport { FulfilmentVoidOrder } from \"./Events/FulfilmentVoidOrder.js\";\nimport { GiftCardCodeCheck } from \"./Events/GiftCardCodeCheck.js\";\nimport { InternalPageMessage } from \"./Events/InternalPageMessage.js\";\nimport { PaymentMethodsEnabled } from \"./Events/PaymentMethodsEnabled.js\";\nimport { Ready } from \"./Events/Ready.js\";\nimport { RegisterChanged } from \"./Events/RegisterChanged.js\";\nimport { RequestButtons } from \"./Events/RequestButtons.js\";\nimport { RequestCustomerListOptions, type SellScreenCustomerListOption } from \"./Events/RequestCustomerListOptions.js\";\nimport { RequestSaleKeys } from \"./Events/RequestSaleKeys.js\";\nimport { RequestSellScreenOptions, type SellScreenOption } from \"./Events/RequestSellScreenOptions.js\";\nimport { RequestSettings } from \"./Events/RequestSettings.js\";\nimport { RequestTableColumns } from \"./Events/RequestTableColumns.js\";\nimport { type CompletedSale, SaleComplete } from \"./Events/SaleComplete.js\";\nimport { UIPipeline } from \"./Events/UIPipeline.js\";\nimport { type MaybePromise } from \"./Utilities/MiscTypes.js\";\n\nexport enum ToShopfront {\n READY = \"READY\",\n SERIALIZED = \"SERIALIZED\",\n RESPONSE_BUTTONS = \"RESPONSE_BUTTONS\",\n RESPONSE_SETTINGS = \"RESPONSE_SETTINGS\",\n RESPONSE_TABLE_COLUMNS = \"RESPONSE_TABLE_COLUMNS\",\n RESPONSE_SELL_SCREEN_OPTIONS = \"RESPONSE_SELL_SCREEN_OPTIONS\",\n DOWNLOAD = \"DOWNLOAD\",\n LOAD = \"LOAD\",\n REQUEST_CURRENT_SALE = \"REQUEST_CURRENT_SALE\",\n DATABASE_REQUEST = \"DATABASE_REQUEST\",\n UNSUPPORTED_EVENT = \"UNSUPPORTED_EVENT\",\n NOT_LISTENING_TO_EVENT = \"NOT_LISTENING_TO_EVENT\",\n REQUEST_LOCATION = \"REQUEST_LOCATION\",\n RESPONSE_FORMAT_PRODUCT = \"RESPONSE_FORMAT_PRODUCT\",\n RESPONSE_CUSTOMER_LIST_OPTIONS = \"RESPONSE_CUSTOMER_LIST_OPTIONS\",\n RESPONSE_SALE_KEYS = \"RESPONSE_SALE_KEYS\",\n PRINT_RECEIPT = \"PRINT_RECEIPT\",\n REDIRECT = \"REDIRECT\",\n GET_OPTION = \"GET_OPTION\",\n RESPONSE_UI_PIPELINE = \"RESPONSE_UI_PIPELINE\",\n RESPONSE_GIFT_CARD_CODE_CHECK = \"RESPONSE_GIFT_CARD_CODE_CHECK\",\n REQUEST_SECURE_KEY = \"REQUEST_SECURE_KEY\",\n ROTATE_SIGNING_KEY = \"ROTATE_SIGNING_KEY\",\n\n // Audio Events\n AUDIO_REQUEST_PERMISSION = \"AUDIO_REQUEST_PERMISSION\",\n AUDIO_PRELOAD = \"AUDIO_PRELOAD\",\n AUDIO_PLAY = \"AUDIO_PLAY\",\n\n // Sell Screen Events\n CHANGE_SELL_SCREEN_ACTION_MODE = \"CHANGE_SELL_SCREEN_ACTION_MODE\",\n CHANGE_SELL_SCREEN_SUMMARY_MODE = \"CHANGE_SELL_SCREEN_SUMMARY_MODE\",\n\n // Emitable Events\n SELL_SCREEN_OPTION_CHANGE = \"SELL_SCREEN_OPTION_CHANGE\",\n INTERNAL_PAGE_MESSAGE = \"INTERNAL_PAGE_MESSAGE\",\n TABLE_UPDATE = \"TABLE_UPDATE\",\n PIPELINE_TRIGGER = \"PIPELINE_TRIGGER\",\n SELL_SCREEN_PROMOTION_APPLICABLE = \"SELL_SCREEN_PROMOTION_APPLICABLE\",\n\n // Fulfilment Emitable Events\n FULFILMENT_OPT_IN = \"FULFILMENT_OPT_IN\",\n FULFILMENT_OPTIONS = \"FULFILMENT_OPTIONS\",\n FULFILMENT_ORDERS_SYNC = \"FULFILMENT_ORDERS_SYNC\",\n FULFILMENT_ORDERS_CREATE = \"FULFILMENT_ORDERS_CREATE\",\n FULFILMENT_ORDERS_UPDATE = \"FULFILMENT_ORDERS_UPDATE\",\n FULFILMENT_ORDERS_CANCEL = \"FULFILMENT_ORDERS_CANCEL\",\n\n // Sale API events\n CREATE_SALE = \"CREATE_SALE\",\n\n // Fulfilment Response Events\n FULFILMENT_GET_ORDER = \"FULFILMENT_GET_ORDER\",\n}\n\nexport type SoundEvents = ToShopfront.AUDIO_REQUEST_PERMISSION | ToShopfront.AUDIO_PRELOAD | ToShopfront.AUDIO_PLAY;\n\nexport interface FromShopfrontReturns {\n READY: unknown;\n REQUEST_SETTINGS: {\n logo?: string;\n description?: string;\n url?: string;\n html?: string;\n };\n REQUEST_BUTTONS: Array<Button>;\n REQUEST_TABLE_COLUMNS: null | {\n headers: Array<{\n label: string;\n key: string;\n weight: number;\n }>;\n body: Array<Record<string, string>>;\n footer: Record<string, string>;\n };\n REQUEST_SELL_SCREEN_OPTIONS: Array<SellScreenOption>;\n CALLBACK: unknown;\n RESPONSE_CURRENT_SALE: {\n requestId: string;\n saleState: ShopfrontSaleState;\n };\n INTERNAL_PAGE_MESSAGE: unknown;\n REGISTER_CHANGED: unknown;\n RESPONSE_LOCATION: {\n requestId: string;\n register: string | null;\n outlet: string | null;\n user: string | null;\n };\n RESPONSE_AUDIO_REQUEST: {\n requestId: string;\n success: boolean;\n message?: string;\n };\n FORMAT_INTEGRATED_PRODUCT: FormatIntegratedProductEvent;\n REQUEST_CUSTOMER_LIST_OPTIONS: Array<SellScreenCustomerListOption>;\n REQUEST_SALE_KEYS: Array<SaleKey>;\n SALE_COMPLETE: unknown;\n UI_PIPELINE: Array<UIPipelineResponse>;\n PAYMENT_METHODS_ENABLED: Array<SellScreenPaymentMethod>;\n AUDIO_READY: unknown;\n AUDIO_PERMISSION_CHANGE: unknown;\n FULFILMENT_GET_ORDER: OrderDetails;\n FULFILMENT_VOID_ORDER: unknown;\n FULFILMENT_PROCESS_ORDER: unknown;\n FULFILMENT_ORDER_APPROVAL: unknown;\n FULFILMENT_ORDER_COLLECTED: unknown;\n FULFILMENT_ORDER_COMPLETED: unknown;\n RESPONSE_CREATE_SALE: {\n requestId: string;\n success: boolean;\n message?: string;\n };\n GIFT_CARD_CODE_CHECK: {\n code: string;\n message: string | null;\n };\n}\n\nexport interface InternalPageMessageEvent {\n method: \"REQUEST_SETTINGS\" | \"REQUEST_SELL_SCREEN_OPTIONS\" | \"EXTERNAL_APPLICATION\";\n url: string;\n message: unknown;\n reference: InternalMessageSource;\n}\n\nexport interface RegisterChangedEvent {\n register: null | string;\n outlet: null | string;\n user: null | string;\n}\n\nexport interface GiftCardCodeCheckEvent {\n code: string;\n message: string | null;\n}\n\nexport interface FormatIntegratedProductEvent {\n product: FormattedSaleProduct;\n}\n\nexport interface SaleCompletedEvent {\n sale: CompletedSale;\n}\n\nexport interface AudioPermissionChangeEvent {\n permitted: boolean;\n}\n\nexport interface FulfilmentProcessEvent {\n id: string;\n sale: Sale;\n}\n\nexport interface FulfilmentApprovalEvent {\n id: string;\n approved: boolean;\n}\n\nexport interface UIPipelineResponse {\n name: string;\n content: string;\n}\n\nexport interface UIPipelineBaseContext {\n location: string;\n}\n\nexport interface UIPipelineContext extends UIPipelineBaseContext {\n trigger?: () => void;\n}\n\nexport interface SellScreenPaymentMethod {\n uuid: string;\n name: string;\n type:\n \"global\" |\n \"cash\" |\n \"eftpos\" |\n \"giftcard\" |\n \"voucher\" |\n \"cheque\" |\n \"pc-eftpos\" |\n \"linkly-vaa\" |\n \"direct-deposit\" |\n \"tyro\" |\n \"custom\";\n default_pay_exact: boolean;\n background_colour?: string;\n text_colour?: string;\n}\n\nexport interface PaymentMethodEnabledContext {\n register: string;\n customer: false | {\n uuid: string;\n };\n}\n\nexport interface FromShopfrontCallbacks {\n READY: (event: RegisterChangedEvent) => MaybePromise<FromShopfrontReturns[\"READY\"]>;\n REQUEST_SETTINGS: () => MaybePromise<FromShopfrontReturns[\"REQUEST_SETTINGS\"]>;\n REQUEST_BUTTONS: (location: string, context: unknown) => MaybePromise<FromShopfrontReturns[\"REQUEST_BUTTONS\"]>;\n REQUEST_TABLE_COLUMNS: (\n location: string,\n data: unknown\n ) => MaybePromise<FromShopfrontReturns[\"REQUEST_TABLE_COLUMNS\"]>;\n REQUEST_SELL_SCREEN_OPTIONS: () => MaybePromise<FromShopfrontReturns[\"REQUEST_SELL_SCREEN_OPTIONS\"]>;\n INTERNAL_PAGE_MESSAGE: (\n event: InternalPageMessageEvent\n ) => MaybePromise<FromShopfrontReturns[\"INTERNAL_PAGE_MESSAGE\"]>;\n REGISTER_CHANGED: (event: RegisterChangedEvent) => MaybePromise<FromShopfrontReturns[\"REGISTER_CHANGED\"]>;\n CALLBACK: () => MaybePromise<FromShopfrontReturns[\"CALLBACK\"]>;\n FORMAT_INTEGRATED_PRODUCT: (\n event: FormatIntegratedProductEvent\n ) => MaybePromise<FromShopfrontReturns[\"FORMAT_INTEGRATED_PRODUCT\"]>;\n REQUEST_CUSTOMER_LIST_OPTIONS: () => MaybePromise<FromShopfrontReturns[\"REQUEST_CUSTOMER_LIST_OPTIONS\"]>;\n REQUEST_SALE_KEYS: () => MaybePromise<FromShopfrontReturns[\"REQUEST_SALE_KEYS\"]>;\n SALE_COMPLETE: (event: SaleCompletedEvent) => MaybePromise<FromShopfrontReturns[\"SALE_COMPLETE\"]>;\n UI_PIPELINE: (\n event: Array<UIPipelineResponse>,\n context: UIPipelineContext\n ) => MaybePromise<FromShopfrontReturns[\"UI_PIPELINE\"]>;\n PAYMENT_METHODS_ENABLED: (\n event: Array<SellScreenPaymentMethod>,\n context: PaymentMethodEnabledContext\n ) => MaybePromise<FromShopfrontReturns[\"PAYMENT_METHODS_ENABLED\"]>;\n AUDIO_READY: () => MaybePromise<FromShopfrontReturns[\"AUDIO_READY\"]>;\n AUDIO_PERMISSION_CHANGE: (\n event: AudioPermissionChangeEvent\n ) => MaybePromise<FromShopfrontReturns[\"AUDIO_PERMISSION_CHANGE\"]>;\n FULFILMENT_GET_ORDER: (id: string) => MaybePromise<FromShopfrontReturns[\"FULFILMENT_GET_ORDER\"]>;\n FULFILMENT_VOID_ORDER: (id: string) => MaybePromise<FromShopfrontReturns[\"FULFILMENT_VOID_ORDER\"]>;\n FULFILMENT_PROCESS_ORDER: (\n event: FulfilmentProcessEvent\n ) => MaybePromise<FromShopfrontReturns[\"FULFILMENT_PROCESS_ORDER\"]>;\n FULFILMENT_ORDER_APPROVAL: (\n event: FulfilmentApprovalEvent\n ) => MaybePromise<FromShopfrontReturns[\"FULFILMENT_ORDER_APPROVAL\"]>;\n FULFILMENT_ORDER_COLLECTED: (id: string) => MaybePromise<FromShopfrontReturns[\"FULFILMENT_ORDER_COLLECTED\"]>;\n FULFILMENT_ORDER_COMPLETED: (id: string) => MaybePromise<FromShopfrontReturns[\"FULFILMENT_ORDER_COMPLETED\"]>;\n GIFT_CARD_CODE_CHECK: (\n event: GiftCardCodeCheckEvent,\n context: unknown\n ) => MaybePromise<FromShopfrontReturns[\"GIFT_CARD_CODE_CHECK\"]>;\n}\n\nexport interface FromShopfront {\n READY: Ready;\n REQUEST_SETTINGS: RequestSettings;\n REQUEST_BUTTONS: RequestButtons;\n REQUEST_TABLE_COLUMNS: RequestTableColumns;\n REQUEST_SELL_SCREEN_OPTIONS: RequestSellScreenOptions;\n CALLBACK: Callback;\n INTERNAL_PAGE_MESSAGE: InternalPageMessage;\n REGISTER_CHANGED: RegisterChanged;\n FORMAT_INTEGRATED_PRODUCT: FormatIntegratedProduct;\n REQUEST_CUSTOMER_LIST_OPTIONS: RequestCustomerListOptions;\n SALE_COMPLETE: SaleComplete;\n REQUEST_SALE_KEYS: RequestSaleKeys;\n UI_PIPELINE: UIPipeline;\n PAYMENT_METHODS_ENABLED: PaymentMethodsEnabled;\n AUDIO_READY: AudioReady;\n AUDIO_PERMISSION_CHANGE: AudioPermissionChange;\n FULFILMENT_GET_ORDER: FulfilmentGetOrder;\n FULFILMENT_VOID_ORDER: FulfilmentVoidOrder;\n FULFILMENT_PROCESS_ORDER: FulfilmentProcessOrder;\n FULFILMENT_ORDER_APPROVAL: FulfilmentOrderApproval;\n FULFILMENT_ORDER_COLLECTED: FulfilmentCollectOrder;\n FULFILMENT_ORDER_COMPLETED: FulfilmentCompleteOrder;\n GIFT_CARD_CODE_CHECK: GiftCardCodeCheck;\n}\n\nexport type ListenableFromShopfrontEvent = keyof Omit<FromShopfront, \"CALLBACK\">;\n\nexport interface DirectShopfrontEventData {\n SALE_ADD_PRODUCT: {\n product: SaleEventProduct;\n indexAddress: Array<number>;\n };\n SALE_REMOVE_PRODUCT: {\n indexAddress: Array<number>;\n };\n SALE_CHANGE_QUANTITY: {\n indexAddress: Array<number>;\n amount: number;\n absolute: boolean;\n };\n SALE_UPDATE_PRODUCTS: {\n products: Array<SaleEventProduct>;\n };\n SALE_ADD_CUSTOMER: {\n customer: {\n uuid: string;\n };\n };\n SALE_REMOVE_CUSTOMER: undefined;\n SALE_CLEAR: undefined;\n}\n\nexport interface DirectShopfrontCallbacks {\n SALE_ADD_PRODUCT: (event: DirectShopfrontEventData[\"SALE_ADD_PRODUCT\"]) => MaybePromise<void>;\n SALE_REMOVE_PRODUCT: (event: DirectShopfrontEventData[\"SALE_REMOVE_PRODUCT\"]) => MaybePromise<void>;\n SALE_CHANGE_QUANTITY: (event: DirectShopfrontEventData[\"SALE_CHANGE_QUANTITY\"]) => MaybePromise<void>;\n SALE_UPDATE_PRODUCTS: (event: DirectShopfrontEventData[\"SALE_UPDATE_PRODUCTS\"]) => MaybePromise<void>;\n SALE_ADD_CUSTOMER: (event: DirectShopfrontEventData[\"SALE_ADD_CUSTOMER\"]) => MaybePromise<void>;\n SALE_REMOVE_CUSTOMER: () => MaybePromise<void>;\n SALE_CLEAR: () => MaybePromise<void>;\n}\n\nexport interface DirectShopfront {\n SALE_ADD_PRODUCT: SaleAddProduct;\n SALE_REMOVE_PRODUCT: SaleRemoveProduct;\n SALE_CHANGE_QUANTITY: SaleChangeQuantity;\n SALE_UPDATE_PRODUCTS: SaleUpdateProducts;\n SALE_ADD_CUSTOMER: SaleAddCustomer;\n SALE_REMOVE_CUSTOMER: SaleRemoveCustomer;\n SALE_CLEAR: SaleClear;\n}\n\nexport type DirectShopfrontEvent = keyof DirectShopfront;\n\nexport const directShopfrontEvents: Array<DirectShopfrontEvent> = [\n \"SALE_ADD_PRODUCT\",\n \"SALE_REMOVE_PRODUCT\",\n \"SALE_UPDATE_PRODUCTS\",\n \"SALE_CHANGE_QUANTITY\",\n \"SALE_ADD_CUSTOMER\",\n \"SALE_REMOVE_CUSTOMER\",\n \"SALE_CLEAR\",\n] as const;\n\n/**\n * Checks whether the event is a direct Shopfront event\n */\nexport const isDirectShopfrontEvent = (\n event: DirectShopfrontEvent | ListenableFromShopfrontEvent\n): event is DirectShopfrontEvent => {\n return directShopfrontEvents.includes(event as DirectShopfrontEvent);\n};\n\nexport interface FromShopfrontInternal {\n CYCLE_KEY: \"CYCLE_KEY\";\n LOCATION_CHANGED: \"LOCATION_CHANGED\";\n RESPONSE_CURRENT_SALE: \"RESPONSE_CURRENT_SALE\";\n RESPONSE_DATABASE_REQUEST: \"RESPONSE_DATABASE_REQUEST\";\n RESPONSE_LOCATION: \"RESPONSE_LOCATION\";\n RESPONSE_OPTION: \"RESPONSE_OPTION\";\n RESPONSE_AUDIO_REQUEST: \"RESPONSE_AUDIO_REQUEST\";\n RESPONSE_SECURE_KEY: \"RESPONSE_SECURE_KEY\";\n RESPONSE_CREATE_SALE: \"RESPONSE_CREATE_SALE\";\n}\n\nexport type SellScreenActionMode =\n \"search\" |\n \"keys\" |\n \"held-sales\" |\n \"payment\" |\n \"customers\" |\n \"promotions\" |\n \"show-backorders\" |\n \"fulfilment-orders\";\n\nexport type SellScreenSummaryMode = \"transaction\" | \"payments\" | \"receipts\";\n","import type { BaseBridge } from \"../../BaseBridge.js\";\nimport type { AnyFunction } from \"../../Utilities/MiscTypes.js\";\nimport type { DataSourceTables } from \"./types/DataSourceTables.js\";\n\nexport type DatabaseTable = keyof DataSourceTables;\n\nexport type DatabaseMethodName<Table extends DatabaseTable> = {\n [K in keyof DataSourceTables[Table]]: DataSourceTables[Table][K] extends AnyFunction ?\n K :\n never\n};\n\nexport type DatabaseCallReturn<\n Table extends DatabaseTable,\n Method extends keyof DatabaseMethodName<Table>,\n> = ReturnType<Extract<DataSourceTables[Table][Method], AnyFunction>>;\n\nexport abstract class BaseDatabase<BridgeType extends BaseBridge = BaseBridge> {\n protected bridge: BridgeType;\n\n protected constructor(bridge: BridgeType) {\n this.bridge = bridge;\n }\n\n /**\n * Makes a request to the Shopfront local database\n */\n public abstract callMethod<\n Table extends DatabaseTable,\n Method extends keyof DatabaseMethodName<Table>,\n ExpectedResult extends DatabaseCallReturn<Table, Method>\n >(\n table: Table,\n method: Method,\n args: Array<unknown>\n ): Promise<ExpectedResult>;\n\n /**\n * Retrieves all items in the specified table\n */\n public abstract all<Table extends DatabaseTable>(table: Table): Promise<DatabaseCallReturn<Table, \"all\">>;\n\n /**\n * Retrieves all items that match the given ID in the specified table\n */\n public abstract get<Table extends DatabaseTable>(\n table: Table,\n id: string | number\n ): Promise<DatabaseCallReturn<Table, \"get\">>;\n\n /**\n * Returns the item count of the specified table\n */\n public abstract count(table: DatabaseTable): Promise<number>;\n}\n","import { type FromShopfront, type FromShopfrontInternal, ToShopfront } from \"../../ApplicationEvents.js\";\nimport type { Bridge } from \"../../Bridge.js\";\nimport {\n BaseDatabase,\n type DatabaseCallReturn,\n type DatabaseMethodName,\n type DatabaseTable,\n} from \"./BaseDatabase.js\";\n\nexport class Database extends BaseDatabase<Bridge> {\n\n constructor(bridge: Bridge) {\n super(bridge);\n }\n\n /**\n * @inheritDoc\n */\n public async callMethod<\n Table extends DatabaseTable,\n Method extends keyof DatabaseMethodName<Table>,\n ExpectedResult extends DatabaseCallReturn<Table, Method>\n >(\n table: Table,\n method: Method,\n args: Array<unknown>\n ): Promise<ExpectedResult> {\n const databaseRequest = `DatabaseRequest-${Math.random()}-${Date.now()}`;\n\n const promise = new Promise<ExpectedResult>((res, rej) => {\n const listener = (\n event: keyof FromShopfrontInternal | keyof FromShopfront,\n data: Record<string, unknown>\n ) => {\n if(\n event !== \"RESPONSE_DATABASE_REQUEST\"\n ) {\n return;\n }\n\n if(data.requestId !== databaseRequest) {\n return;\n }\n\n this.bridge.removeEventListener(listener);\n\n if(data.error) {\n rej(data.error);\n\n return;\n }\n\n res(data.results as ExpectedResult);\n };\n\n this.bridge.addEventListener(listener);\n });\n\n this.bridge.sendMessage(ToShopfront.DATABASE_REQUEST, {\n requestId: databaseRequest,\n table,\n method,\n args,\n });\n\n return promise;\n }\n\n /**\n * @inheritDoc\n */\n public async all<Table extends DatabaseTable>(table: Table): Promise<DatabaseCallReturn<Table, \"all\">> {\n return this.callMethod(table, \"all\", []);\n }\n\n /**\n * @inheritDoc\n */\n public async get<Table extends DatabaseTable>(\n table: Table,\n id: string | number\n ): Promise<DatabaseCallReturn<Table, \"get\">> {\n return this.callMethod(table, \"get\", [ id ]);\n }\n\n /**\n * @inheritDoc\n */\n public async count(table: DatabaseTable): Promise<number> {\n return this.callMethod(table, \"count\", []);\n }\n}\n","import type { ShopfrontSalePaymentStatus } from \"../APIs/Sale/index.js\";\nimport type { Serialized } from \"../Common/Serializable.js\";\nimport { BaseAction } from \"./BaseAction.js\";\n\nexport interface SaleUpdateChanges {\n PRODUCT_ADD: {\n id: string;\n quantity: number;\n price?: number;\n consolidate?: boolean;\n indexAddress?: Array<number>;\n metaData: Record<string, unknown>;\n };\n PRODUCT_REMOVE: {\n id: string;\n indexAddress: Array<number>;\n };\n PAYMENT_ADD: {\n id: string;\n amount: number;\n cashout?: number | boolean;\n status?: ShopfrontSalePaymentStatus;\n };\n PAYMENT_REVERSE: {\n id: string;\n amount: number;\n cashout?: number;\n status?: ShopfrontSalePaymentStatus;\n };\n SALE_CANCEL: Record<string, never>;\n CUSTOMER_ADD: {\n id: string;\n };\n CUSTOMER_REMOVE: Record<string, never>;\n SALE_EXTERNAL_NOTE: {\n note: string;\n append?: boolean;\n };\n SALE_INTERNAL_NOTE: {\n note: string;\n append?: boolean;\n };\n SALE_ORDER_REFERENCE: {\n reference: string;\n };\n SALE_META_DATA: {\n metaData: Record<string, unknown>;\n };\n PRODUCT_UPDATE: {\n id: string;\n indexAddress: Array<number>;\n quantity?: number;\n price?: number;\n metaData?: Record<string, unknown>;\n };\n}\n\nexport class SaleUpdate<K extends keyof SaleUpdateChanges> extends BaseAction<SaleUpdate<K>> {\n protected supportedEvents = [];\n\n protected type: K;\n protected data: SaleUpdateChanges[K];\n\n constructor(type: Serialized<SaleUpdate<K>> | K, data?: SaleUpdateChanges[K]) {\n // https://github.com/Microsoft/TypeScript/issues/8277\n super((() => {\n if(typeof type === \"string\") {\n return {\n properties: [ type, data ],\n events : {},\n type : \"SaleUpdate\",\n };\n } else {\n return type;\n }\n })(), SaleUpdate);\n\n if(typeof data === \"undefined\" && typeof type !== \"string\") {\n this.type = type.properties[0] as K;\n this.data = type.properties[1] as SaleUpdateChanges[K];\n } else {\n this.type = type as K;\n\n if(typeof data === \"undefined\") {\n throw new TypeError(\"Invalid sale update data specified\");\n } else {\n this.data = data;\n }\n }\n }\n}\n","import type { BaseApplication } from \"../../BaseApplication.js\";\nimport { BaseSale } from \"./BaseSale.js\";\nimport { Sale } from \"./Sale.js\";\nimport type { SaleCustomer } from \"./SaleCustomer.js\";\nimport type { SalePayment } from \"./SalePayment.js\";\nimport type { SaleProduct } from \"./SaleProduct.js\";\nimport type { ShopfrontSaleState } from \"./ShopfrontSaleState.js\";\n\nexport abstract class BaseCurrentSale extends BaseSale {\n protected application: BaseApplication;\n protected cancelled: boolean;\n\n /**\n * Create a sale from a sale state.\n * It's highly recommend to not construct a sale manually, instead use application.getCurrentSale().\n */\n constructor(application: BaseApplication, saleState: ShopfrontSaleState) {\n super(Sale.buildSaleData(saleState));\n\n this.application = application;\n this.cancelled = false;\n }\n\n /**\n * Update the sale to be the latest sale that exists on the sell screen.\n */\n public abstract refreshSale(): Promise<void>;\n\n /**\n * Cancel the current sale in progress.\n */\n public abstract cancelSale(): Promise<void>;\n\n /**\n * Add a product to the sale.\n */\n public abstract addProduct(product: SaleProduct): Promise<void>;\n\n /**\n * Remove a product from the sale.\n * It's highly recommended that you pass in a product that has been retrieved using sale.getProducts().\n */\n public abstract removeProduct(product: SaleProduct): Promise<void>;\n\n /**\n * Add a payment to the sell screen.\n *\n * If you specify a payment with a status, it will bypass the payment gateway (i.e. it won't request that the\n * user takes money from the customer).\n *\n * If you don't specify a cashout amount, it will automatically determine if the payment method normally requests\n * cashout (from the payment method settings).\n */\n public abstract addPayment(payment: SalePayment): Promise<void>;\n\n /**\n * Reverse a payment on the sell screen.\n *\n * This is used to issue a refund to the customer. The sale payment amount should be positive.\n */\n public abstract reversePayment(payment: SalePayment): Promise<void>;\n\n /**\n * Add a customer to the sale.\n * If there is already a customer on the sale this will override that customer.\n */\n public abstract addCustomer(customer: SaleCustomer): Promise<void>;\n\n /**\n * Remove the customer from the current sale.\n * If there is no customer currently on the sale this will be ignored.\n * If there are \"on account\" or loyalty payments still on the sale, this will be ignored.\n */\n public abstract removeCustomer(): Promise<void>;\n\n /**\n * Set the external note for the sale.\n * @param note The note to set.\n * @param append Whether to append the note to the current sale note.\n */\n public abstract setExternalNote(note: string, append?: boolean): Promise<void>;\n\n /**\n * Set the internal note for the sale.\n * @param note The note to set.\n * @param append Whether to append the note to the current sale note.\n */\n public abstract setInternalNote(note: string, append?: boolean): Promise<void>;\n\n /**\n * Set the order reference to the provided string.\n */\n public abstract setOrderReference(reference: string): Promise<void>;\n\n /**\n * Set the meta-data of the sale, this will override the previous meta data.\n */\n public abstract setMetaData(metaData: Record<string, unknown>): Promise<void>;\n\n /**\n * Update a product's details; currently this can update quantity, price and metadata\n */\n public abstract updateProduct(product: SaleProduct): Promise<void>;\n}\n","import { SaleUpdate, type SaleUpdateChanges } from \"../../Actions/SaleUpdate.js\";\nimport { BaseCurrentSale } from \"./BaseCurrentSale.js\";\nimport { InvalidSaleDeviceError, SaleCancelledError } from \"./Exceptions.js\";\nimport type { SaleCustomer } from \"./SaleCustomer.js\";\nimport type { SalePayment } from \"./SalePayment.js\";\nimport type { SaleProduct } from \"./SaleProduct.js\";\n\nexport class CurrentSale extends BaseCurrentSale {\n /**\n * @inheritDoc\n */\n public async refreshSale(): Promise<void> {\n this.checkIfCancelled();\n\n const newSale = await this.application.getCurrentSale();\n\n if(newSale === false) {\n throw new InvalidSaleDeviceError();\n }\n\n this.hydrate(newSale);\n }\n\n /**\n * Check if the sale has already been cancelled, if it has, throw a SaleCancelledError.\n */\n protected checkIfCancelled(): void {\n if(this.cancelled) {\n throw new SaleCancelledError();\n }\n }\n\n /**\n * Send a sale update to Shopfront.\n */\n protected sendSaleUpdate(update: SaleUpdate<keyof SaleUpdateChanges>): Promise<void> {\n this.checkIfCancelled();\n this.application.send(update);\n\n return this.refreshSale();\n }\n\n /**\n * @inheritDoc\n */\n public async cancelSale(): Promise<void> {\n await this.sendSaleUpdate(new SaleUpdate(\"SALE_CANCEL\", {}));\n this.cancelled = true;\n }\n\n /**\n * @inheritDoc\n */\n public addProduct(product: SaleProduct): Promise<void> {\n return this.sendSaleUpdate(new SaleUpdate(\"PRODUCT_ADD\", {\n id : product.getId(),\n quantity : product.getQuantity(),\n price : product.getPrice(),\n indexAddress: product.getIndexAddress(),\n metaData : product.getMetaData(),\n }));\n }\n\n /**\n * @inheritDoc\n */\n public removeProduct(product: SaleProduct): Promise<void> {\n return this.sendSaleUpdate(new SaleUpdate(\"PRODUCT_REMOVE\", {\n id : product.getId(),\n indexAddress: product.getIndexAddress(),\n }));\n }\n\n /**\n * @inheritDoc\n */\n public addPayment(payment: SalePayment): Promise<void> {\n return this.sendSaleUpdate(new SaleUpdate(\"PAYMENT_ADD\", {\n id : payment.getId(),\n amount : payment.getAmount(),\n cashout: payment.getCashout(),\n status : payment.getStatus(),\n }));\n }\n\n /**\n * @inheritDoc\n */\n public reversePayment(payment: SalePayment): Promise<void> {\n return this.sendSaleUpdate(new SaleUpdate(\"PAYMENT_REVERSE\", {\n id : payment.getId(),\n amount : payment.getAmount(),\n cashout: payment.getCashout(),\n status : payment.getStatus(),\n }));\n }\n\n /**\n * @inheritDoc\n */\n public addCustomer(customer: SaleCustomer): Promise<void> {\n return this.sendSaleUpdate(new SaleUpdate(\"CUSTOMER_ADD\", {\n id: customer.getId(),\n }));\n }\n\n /**\n * @inheritDoc\n */\n public removeCustomer(): Promise<void> {\n return this.sendSaleUpdate(new SaleUpdate(\"CUSTOMER_REMOVE\", {}));\n }\n\n /**\n * @inheritDoc\n */\n public setExternalNote(note: string, append = false): Promise<void> {\n return this.sendSaleUpdate(new SaleUpdate(\"SALE_EXTERNAL_NOTE\", {\n note,\n append,\n }));\n }\n\n /**\n * @inheritDoc\n */\n public setInternalNote(note: string, append = false): Promise<void> {\n return this.sendSaleUpdate(new SaleUpdate(\"SALE_INTERNAL_NOTE\", {\n note,\n append,\n }));\n }\n\n /**\n * @inheritDoc\n */\n public setOrderReference(reference: string): Promise<void> {\n return this.sendSaleUpdate(new SaleUpdate(\"SALE_ORDER_REFERENCE\", {\n reference,\n }));\n }\n\n /**\n * @inheritDoc\n */\n public setMetaData(metaData: Record<string, unknown>): Promise<void> {\n return this.sendSaleUpdate(new SaleUpdate(\"SALE_META_DATA\", {\n metaData,\n }));\n }\n\n /**\n * @inheritDoc\n */\n public updateProduct(product: SaleProduct): Promise<void> {\n const updateData: SaleUpdateChanges[\"PRODUCT_UPDATE\"] = {\n id : product.getId(),\n indexAddress: product.getIndexAddress(),\n };\n\n if(product.wasQuantityModified()) {\n updateData.quantity = product.getQuantity();\n }\n\n if(product.wasPriceModified()) {\n updateData.price = product.getPrice();\n }\n\n if(product.wasMetaDataModified()) {\n updateData.metaData = product.getMetaData();\n }\n\n product.clearModificationFlags();\n\n return this.sendSaleUpdate(new SaleUpdate(\"PRODUCT_UPDATE\", updateData));\n }\n}\n","import type { BaseDatabase } from \"./APIs/Database/BaseDatabase.js\";\nimport type { BaseCurrentSale } from \"./APIs/Sale/BaseCurrentSale.js\";\nimport type { Sale } from \"./APIs/Sale/index.js\";\nimport type { Application } from \"./Application.js\";\nimport {\n type DirectShopfront,\n type DirectShopfrontCallbacks,\n type DirectShopfrontEvent,\n type FromShopfront,\n type FromShopfrontCallbacks,\n type FromShopfrontInternal,\n isDirectShopfrontEvent,\n type ListenableFromShopfrontEvent,\n type RegisterChangedEvent,\n type SellScreenActionMode,\n type SellScreenSummaryMode,\n type SoundEvents,\n} from \"./ApplicationEvents.js\";\nimport type { BaseBridge } from \"./BaseBridge.js\";\nimport type { Serializable } from \"./Common/Serializable.js\";\nimport type { BaseEmitableEvent } from \"./EmitableEvents/BaseEmitableEvent.js\";\nimport { AudioPermissionChange } from \"./Events/AudioPermissionChange.js\";\nimport { AudioReady } from \"./Events/AudioReady.js\";\nimport type { BaseEvent } from \"./Events/BaseEvent.js\";\nimport { SaleAddCustomer } from \"./Events/DirectEvents/SaleAddCustomer.js\";\nimport { SaleAddProduct } from \"./Events/DirectEvents/SaleAddProduct.js\";\nimport { SaleChangeQuantity } from \"./Events/DirectEvents/SaleChangeQuantity.js\";\nimport { SaleClear } from \"./Events/DirectEvents/SaleClear.js\";\nimport { SaleRemoveCustomer } from \"./Events/DirectEvents/SaleRemoveCustomer.js\";\nimport { SaleRemoveProduct } from \"./Events/DirectEvents/SaleRemoveProduct.js\";\nimport { SaleUpdateProducts } from \"./Events/DirectEvents/SaleUpdateProducts.js\";\nimport { FormatIntegratedProduct } from \"./Events/FormatIntegratedProduct.js\";\nimport { FulfilmentCollectOrder } from \"./Events/FulfilmentCollectOrder.js\";\nimport { FulfilmentCompleteOrder } from \"./Events/FulfilmentCompleteOrder.js\";\nimport { FulfilmentGetOrder } from \"./Events/FulfilmentGetOrder.js\";\nimport { FulfilmentOrderApproval } from \"./Events/FulfilmentOrderApproval.js\";\nimport { FulfilmentProcessOrder } from \"./Events/FulfilmentProcessOrder.js\";\nimport { FulfilmentVoidOrder } from \"./Events/FulfilmentVoidOrder.js\";\nimport { GiftCardCodeCheck } from \"./Events/GiftCardCodeCheck.js\";\nimport { InternalPageMessage } from \"./Events/InternalPageMessage.js\";\nimport { PaymentMethodsEnabled } from \"./Events/PaymentMethodsEnabled.js\";\nimport { Ready } from \"./Events/Ready.js\";\nimport { RegisterChanged } from \"./Events/RegisterChanged.js\";\nimport { RequestButtons } from \"./Events/RequestButtons.js\";\nimport { RequestCustomerListOptions } from \"./Events/RequestCustomerListOptions.js\";\nimport { RequestSaleKeys } from \"./Events/RequestSaleKeys.js\";\nimport { RequestSellScreenOptions } from \"./Events/RequestSellScreenOptions.js\";\nimport { RequestSettings } from \"./Events/RequestSettings.js\";\nimport { RequestTableColumns } from \"./Events/RequestTableColumns.js\";\nimport { SaleComplete } from \"./Events/SaleComplete.js\";\nimport { UIPipeline } from \"./Events/UIPipeline.js\";\nimport type { AnyFunction, MaybePromise } from \"./Utilities/MiscTypes.js\";\n\nexport interface ShopfrontResponse {\n success: boolean;\n message?: string;\n}\n\nexport interface ShopfrontEmbeddedVerificationToken {\n auth: string;\n id: string;\n app: string;\n user: string;\n url: {\n raw: string;\n loaded: string;\n };\n}\n\nexport interface ShopfrontEmbeddedTokenError {\n error: boolean;\n type: string;\n}\n\nexport class ShopfrontTokenDecodingError extends Error {}\n\nexport class ShopfrontTokenRequestError extends Error {}\n\nexport abstract class BaseApplication {\n protected bridge: BaseBridge;\n protected isReady: boolean;\n protected key: string;\n protected register: string | null;\n protected outlet: string | null;\n protected user: string | null;\n protected signingKey: CryptoKeyPair | undefined;\n protected listeners: {\n [key in ListenableFromShopfrontEvent]: Map<\n AnyFunction,\n FromShopfront[key] & BaseEvent\n >;\n } = {\n READY : new Map(),\n REQUEST_SETTINGS : new Map(),\n REQUEST_BUTTONS : new Map(),\n REQUEST_TABLE_COLUMNS : new Map(),\n REQUEST_SELL_SCREEN_OPTIONS : new Map(),\n INTERNAL_PAGE_MESSAGE : new Map(),\n REGISTER_CHANGED : new Map(),\n FORMAT_INTEGRATED_PRODUCT : new Map(),\n REQUEST_CUSTOMER_LIST_OPTIONS: new Map(),\n REQUEST_SALE_KEYS : new Map(),\n SALE_COMPLETE : new Map(),\n UI_PIPELINE : new Map(),\n PAYMENT_METHODS_ENABLED : new Map(),\n AUDIO_PERMISSION_CHANGE : new Map(),\n AUDIO_READY : new Map(),\n FULFILMENT_GET_ORDER : new Map(),\n FULFILMENT_PROCESS_ORDER : new Map(),\n FULFILMENT_VOID_ORDER : new Map(),\n FULFILMENT_ORDER_APPROVAL : new Map(),\n FULFILMENT_ORDER_COLLECTED : new Map(),\n FULFILMENT_ORDER_COMPLETED : new Map(),\n GIFT_CARD_CODE_CHECK : new Map(),\n };\n protected directListeners: {\n [key in DirectShopfrontEvent]: Map<\n AnyFunction,\n DirectShopfront[key]\n >;\n } = {\n SALE_ADD_PRODUCT : new Map(),\n SALE_REMOVE_PRODUCT : new Map(),\n SALE_CHANGE_QUANTITY: new Map(),\n SALE_UPDATE_PRODUCTS: new Map(),\n SALE_ADD_CUSTOMER : new Map(),\n SALE_REMOVE_CUSTOMER: new Map(),\n SALE_CLEAR : new Map(),\n };\n public database: BaseDatabase;\n\n protected constructor(bridge: BaseBridge, database: BaseDatabase) {\n this.bridge = bridge;\n this.isReady = false;\n this.key = \"\";\n this.register = null;\n this.outlet = null;\n this.user = null;\n this.database = database;\n }\n\n /**\n * Destroy the bridge instance\n */\n public abstract destroy(): void;\n\n /**\n * Handles an application event\n */\n protected abstract handleEvent(\n event: keyof FromShopfront | keyof FromShopfrontInternal,\n data: Record<string, unknown>,\n id: string\n ): void;\n\n /**\n * Calls any registered listeners for the received event\n */\n protected abstract emit(\n event: ListenableFromShopfrontEvent | DirectShopfrontEvent,\n data: Record<string, unknown>,\n id: string\n ): MaybePromise<void>;\n\n /**\n * Register a listener for a Shopfront event\n */\n public addEventListener<E extends ListenableFromShopfrontEvent>(\n event: E,\n callback: FromShopfrontCallbacks[E]\n ): void;\n /**\n * Register a listener for a Shopfront event\n */\n public addEventListener<D extends DirectShopfrontEvent>(\n event: D,\n callback: DirectShopfrontCallbacks[D]\n ): void;\n /**\n * Register a listener for a Shopfront event\n */\n public addEventListener(\n event: ListenableFromShopfrontEvent | DirectShopfrontEvent,\n callback: AnyFunction\n ): void {\n if(isDirectShopfrontEvent(event)) {\n let c;\n\n switch(event) {\n case \"SALE_ADD_PRODUCT\":\n c = new SaleAddProduct(callback);\n this.directListeners[event].set(callback, c);\n\n break;\n case \"SALE_REMOVE_PRODUCT\":\n c = new SaleRemoveProduct(callback);\n this.directListeners[event].set(callback, c);\n\n break;\n case \"SALE_CHANGE_QUANTITY\":\n c = new SaleChangeQuantity(callback);\n this.directListeners[event].set(callback, c);\n\n break;\n case \"SALE_UPDATE_PRODUCTS\":\n c = new SaleUpdateProducts(callback);\n this.directListeners[event].set(callback, c);\n\n break;\n case \"SALE_ADD_CUSTOMER\":\n c = new SaleAddCustomer(callback);\n this.directListeners[event].set(callback, c);\n\n break;\n case \"SALE_REMOVE_CUSTOMER\":\n c = new SaleRemoveCustomer(callback);\n this.directListeners[event].set(callback, c);\n\n break;\n case \"SALE_CLEAR\":\n c = new SaleClear(callback);\n this.directListeners[event].set(callback, c);\n\n break;\n }\n\n if(typeof c === \"undefined\") {\n throw new TypeError(`${event} has not been defined`);\n }\n\n return;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let c: BaseEvent<any, any, any, any, any> | undefined;\n\n switch(event) {\n case \"READY\":\n c = new Ready(callback as FromShopfrontCallbacks[\"READY\"]);\n this.listeners[event].set(callback, c);\n break;\n case \"REQUEST_SETTINGS\":\n c = new RequestSettings(callback as FromShopfrontCallbacks[\"REQUEST_SETTINGS\"]);\n this.listeners[event].set(callback, c);\n break;\n case \"REQUEST_BUTTONS\":\n c = new RequestButtons(callback as FromShopfrontCallbacks[\"REQUEST_BUTTONS\"]);\n this.listeners[event].set(callback, c);\n break;\n case \"REQUEST_TABLE_COLUMNS\":\n c = new RequestTableColumns(callback as FromShopfrontCallbacks[\"REQUEST_TABLE_COLUMNS\"]);\n this.listeners[event].set(callback, c);\n break;\n case \"REQUEST_SELL_SCREEN_OPTIONS\":\n c = new RequestSellScreenOptions(callback as FromShopfrontCallbacks[\"REQUEST_SELL_SCREEN_OPTIONS\"]);\n this.listeners[event].set(callback, c);\n break;\n case \"INTERNAL_PAGE_MESSAGE\":\n c = new InternalPageMessage(\n callback as FromShopfrontCallbacks[\"INTERNAL_PAGE_MESSAGE\"],\n this as unknown as Application\n );\n this.listeners[event].set(callback, c as InternalPageMessage);\n break;\n case \"REGISTER_CHANGED\":\n c = new RegisterChanged(callback as FromShopfrontCallbacks[\"REGISTER_CHANGED\"]);\n this.listeners[event].set(callback, c);\n break;\n case \"REQUEST_CUSTOMER_LIST_OPTIONS\":\n c = new RequestCustomerListOptions(callback as FromShopfrontCallbacks[\"REQUEST_CUSTOMER_LIST_OPTIONS\"]);\n this.listeners[event].set(callback, c);\n break;\n case \"FORMAT_INTEGRATED_PRODUCT\":\n c = new FormatIntegratedProduct(callback as FromShopfrontCallbacks[\"FORMAT_INTEGRATED_PRODUCT\"]);\n this.listeners[event].set(callback, c);\n break;\n case \"REQUEST_SALE_KEYS\":\n c = new RequestSaleKeys(callback as FromShopfrontCallbacks[\"REQUEST_SALE_KEYS\"]);\n this.listeners[event].set(callback, c as RequestSaleKeys);\n break;\n case \"SALE_COMPLETE\":\n c = new SaleComplete(callback as FromShopfrontCallbacks[\"SALE_COMPLETE\"]);\n this.listeners[event].set(callback, c);\n break;\n case \"UI_PIPELINE\":\n c = new UIPipeline(callback as FromShopfrontCallbacks[\"UI_PIPELINE\"]);\n this.listeners[event].set(callback, c);\n break;\n case \"PAYMENT_METHODS_ENABLED\":\n c = new PaymentMethodsEnabled(callback as FromShopfrontCallbacks[\"PAYMENT_METHODS_ENABLED\"]);\n this.listeners[event].set(callback, c);\n break;\n case \"AUDIO_READY\":\n c = new AudioReady(callback as FromShopfrontCallbacks[\"AUDIO_READY\"]);\n this.listeners[event].set(callback, c as AudioReady);\n break;\n case \"AUDIO_PERMISSION_CHANGE\":\n c = new AudioPermissionChange(callback as FromShopfrontCallbacks[\"AUDIO_PERMISSION_CHANGE\"]);\n this.listeners[event].set(callback, c);\n break;\n case \"FULFILMENT_GET_ORDER\":\n if(this.listeners[event].size !== 0) {\n throw new TypeError(\"Application already has 'FULFILMENT_GET_ORDER' event listener registered.\");\n }\n\n c = new FulfilmentGetOrder(callback as FromShopfrontCallbacks[\"FULFILMENT_GET_ORDER\"]);\n this.listeners[event].set(callback, c);\n break;\n case \"FULFILMENT_VOID_ORDER\":\n c = new FulfilmentVoidOrder(callback as FromShopfrontCallbacks[\"FULFILMENT_VOID_ORDER\"]);\n this.listeners[event].set(callback, c);\n break;\n case \"FULFILMENT_PROCESS_ORDER\":\n c = new FulfilmentProcessOrder(callback as FromShopfrontCallbacks[\"FULFILMENT_PROCESS_ORDER\"]);\n this.listeners[event].set(callback, c);\n break;\n case \"FULFILMENT_ORDER_APPROVAL\":\n c = new FulfilmentOrderApproval(callback as FromShopfrontCallbacks[\"FULFILMENT_ORDER_APPROVAL\"]);\n this.listeners[event].set(callback, c);\n break;\n case \"FULFILMENT_ORDER_COLLECTED\":\n c = new FulfilmentCollectOrder(callback as FromShopfrontCallbacks[\"FULFILMENT_ORDER_COLLECTED\"]);\n this.listeners[event].set(callback, c);\n break;\n case \"FULFILMENT_ORDER_COMPLETED\":\n c = new FulfilmentCompleteOrder(callback as FromShopfrontCallbacks[\"FULFILMENT_ORDER_COMPLETED\"]);\n this.listeners[event].set(callback, c);\n break;\n case \"GIFT_CARD_CODE_CHECK\":\n c = new GiftCardCodeCheck(callback as FromShopfrontCallbacks[\"GIFT_CARD_CODE_CHECK\"]);\n this.listeners[event].set(callback, c);\n break;\n }\n\n if(typeof c === \"undefined\") {\n throw new TypeError(`${event} has not been defined`);\n }\n\n if(event === \"READY\" && this.isReady) {\n c = c as Ready;\n c.emit({\n outlet : this.outlet,\n register: this.register,\n user : this.user,\n });\n }\n }\n\n /**\n * Removed a registered listener for a Shopfront event\n */\n public removeEventListener<E extends ListenableFromShopfrontEvent>(\n event: E,\n callback: FromShopfrontCallbacks[E]\n ): void;\n /**\n * Removed a registered listener for a Shopfront event\n */\n public removeEventListener<D extends DirectShopfrontEvent>(\n event: D,\n callback: DirectShopfrontCallbacks[D]\n ): void;\n /**\n * Removed a registered listener for a Shopfront event\n */\n public removeEventListener(\n event: ListenableFromShopfrontEvent | DirectShopfrontEvent,\n callback: AnyFunction\n ): void {\n if(isDirectShopfrontEvent(event)) {\n this.directListeners[event].delete(callback);\n\n return;\n }\n\n this.listeners[event].delete(callback);\n }\n\n /**\n * Send data to Shopfront\n */\n public abstract send(item: BaseEmitableEvent<unknown> | Serializable<unknown>): void;\n\n /**\n * Requests permission from the user to download the specified file\n */\n public abstract download(file: string): void;\n\n /**\n * Redirects the user to the specified location.\n * If `externalRedirect` is `true`, the user is prompted to confirm the redirect.\n */\n public abstract redirect(toLocation: string, externalRedirect: boolean): void;\n\n /**\n * Shows a loading screen in Shopfront\n */\n public abstract load(): () => void;\n\n protected abstract handleEventCallback(data: { id?: string; data: unknown; }): void;\n\n protected abstract handleLocationChanged(data: RegisterChangedEvent): void;\n\n /**\n * Retrieves the cached authentication key\n */\n public abstract getAuthenticationKey(): string;\n\n /**\n * Get the current sale on the sell screen, if the current device is not a register\n * then this will return false.\n */\n public abstract getCurrentSale(): Promise<BaseCurrentSale | false>;\n\n /**\n * Send the sale to be created on shopfront.\n */\n public abstract createSale(sale: Sale): Promise<ShopfrontResponse>;\n\n /**\n * Retrieves the current location data from Shopfront\n */\n public abstract getLocation(): Promise<{\n register: string | null;\n outlet: string | null;\n user: string | null;\n }>;\n\n /**\n * Prints the provided content as a receipt\n */\n public abstract printReceipt(content: string): void;\n\n /**\n * Changes the display mode of the sell screen's `action` container\n */\n public abstract changeSellScreenActionMode(mode: SellScreenActionMode): void;\n\n /**\n * Changes the display mode of the sell screen's 'summary' container\n */\n public abstract changeSellScreenSummaryMode(mode: SellScreenSummaryMode): void;\n\n /**\n * Sends an audio request to Shopfront\n */\n protected abstract sendAudioRequest(type: SoundEvents, data?: unknown): Promise<ShopfrontResponse>;\n\n /**\n * Requests permission from the user to be able to play audio\n */\n public abstract requestAudioPermission(): Promise<ShopfrontResponse>;\n\n /**\n * Requests Shopfront to preload audio so that it can be pre-cached before being played\n */\n public abstract audioPreload(url: string): Promise<ShopfrontResponse>;\n\n /**\n * Attempts to play the provided audio in Shopfront\n */\n public abstract audioPlay(url: string): Promise<ShopfrontResponse>;\n\n /**\n * Retrieve the value of the specified option from Shopfront\n */\n public abstract getOption<TValueType>(option: string, defaultValue: TValueType): Promise<TValueType>;\n\n /**\n * Retrieves an embedded token from Shopfront that can be used to validate server requests\n */\n public abstract getToken(returnTokenObject: true): Promise<ShopfrontEmbeddedVerificationToken>;\n /**\n * Retrieves an embedded token from Shopfront that can be used to validate server requests\n */\n public abstract getToken(returnTokenObject?: false): Promise<string>;\n /**\n * Retrieves an embedded token from Shopfront that can be used to validate server requests\n */\n public abstract getToken(returnTokenObject?: boolean): Promise<string | ShopfrontEmbeddedVerificationToken>;\n}\n","import { type BaseSaleData } from \"../APIs/Sale/BaseSale.js\";\nimport { Sale, SaleProduct, type ShopfrontSalePaymentStatus } from \"../APIs/Sale/index.js\";\n\nexport interface SaleProductData {\n uuid: string;\n caseQuantity: number;\n quantity: number;\n price: number;\n metaData: Record<string, unknown>;\n products: Array<SaleProductData>;\n note: string;\n}\n\nexport interface SalePaymentData {\n method: string;\n type: undefined | string;\n amount: number;\n status: undefined | ShopfrontSalePaymentStatus;\n rounding: number;\n cashout: number;\n metaData: Record<string, unknown>;\n}\n\nexport interface SaleData extends BaseSaleData {\n customer: null | string;\n payments: Array<SalePaymentData>;\n products: Array<SaleProductData>;\n}\n\n/**\n * Builds a Shopfront sale product from the embedded product data\n */\nfunction buildSaleProductData(product: SaleProduct): SaleProductData {\n const price = product.getPrice();\n\n if(typeof price !== \"number\") {\n throw new TypeError(\"Sale Product must have price when creating the sale.\");\n }\n\n const caseQuantity = product.getCaseQuantity();\n\n if(typeof caseQuantity !== \"number\") {\n throw new TypeError(\"Sale Product must have case quantity when creating the sale.\");\n }\n\n return {\n uuid : product.getId(),\n quantity: product.getQuantity(),\n metaData: product.getMetaData(),\n products: product.getContains().map(buildSaleProductData),\n note : product.getNote(),\n caseQuantity,\n price,\n };\n}\n\n/**\n * Builds a Shopfront sale from the embedded sale data\n */\nexport function buildSaleData(sale: Sale): SaleData {\n const customer = sale.getCustomer();\n\n return {\n register: sale.getRegister(),\n clientId: sale.getClientId(),\n notes : {\n internal: sale.getInternalNote(),\n sale : sale.getExternalNote(),\n },\n totals: {\n sale : sale.getSaleTotal(),\n paid : sale.getPaidTotal(),\n savings : sale.getSavingsTotal(),\n discount: sale.getDiscountTotal(),\n },\n linkedTo : sale.getLinkedTo(),\n orderReference: sale.getOrderReference(),\n refundReason : sale.getRefundReason(),\n priceSet : sale.getPriceSet(),\n metaData : sale.getMetaData(),\n customer : customer ? customer.getId() : null,\n products : sale.getProducts().map(buildSaleProductData),\n payments : sale.getPayments().map(payment => ({\n method : payment.getId(),\n type : payment.getType(),\n amount : payment.getAmount(),\n status : payment.getStatus(),\n rounding: payment.getRounding() || 0,\n cashout : payment.getCashout() || 0,\n metaData: payment.getMetaData(),\n })),\n };\n}\n","import { Button } from \"./Actions/Button.js\";\nimport { Database } from \"./APIs/Database/Database.js\";\nimport { CurrentSale } from \"./APIs/Sale/CurrentSale.js\";\nimport { Sale, type ShopfrontSaleState } from \"./APIs/Sale/index.js\";\nimport {\n type DirectShopfrontEvent,\n type FromShopfront,\n type FromShopfrontInternal,\n type FromShopfrontReturns,\n isDirectShopfrontEvent,\n type ListenableFromShopfrontEvent,\n type RegisterChangedEvent,\n type SellScreenActionMode,\n type SellScreenSummaryMode,\n type SoundEvents,\n ToShopfront,\n} from \"./ApplicationEvents.js\";\nimport {\n BaseApplication,\n type ShopfrontEmbeddedTokenError,\n type ShopfrontEmbeddedVerificationToken,\n type ShopfrontResponse,\n ShopfrontTokenDecodingError,\n ShopfrontTokenRequestError,\n} from \"./BaseApplication.js\";\nimport { type ApplicationEventListener } from \"./BaseBridge.js\";\nimport { Bridge, type JavaScriptCommunicatorExports } from \"./Bridge.js\";\nimport { type Serializable } from \"./Common/Serializable.js\";\nimport { BaseEmitableEvent } from \"./EmitableEvents/BaseEmitableEvent.js\";\nimport { FormatIntegratedProduct } from \"./Events/FormatIntegratedProduct.js\";\nimport { FulfilmentGetOrder } from \"./Events/FulfilmentGetOrder.js\";\nimport { GiftCardCodeCheck } from \"./Events/GiftCardCodeCheck.js\";\nimport { PaymentMethodsEnabled } from \"./Events/PaymentMethodsEnabled.js\";\nimport { RequestButtons } from \"./Events/RequestButtons.js\";\nimport { RequestCustomerListOptions } from \"./Events/RequestCustomerListOptions.js\";\nimport { RequestSaleKeys } from \"./Events/RequestSaleKeys.js\";\nimport { RequestSellScreenOptions } from \"./Events/RequestSellScreenOptions.js\";\nimport { RequestSettings } from \"./Events/RequestSettings.js\";\nimport { RequestTableColumns } from \"./Events/RequestTableColumns.js\";\nimport { UIPipeline } from \"./Events/UIPipeline.js\";\nimport ActionEventRegistrar from \"./Utilities/ActionEventRegistrar.js\";\nimport { type MaybePromise } from \"./Utilities/MiscTypes.js\";\nimport { buildSaleData } from \"./Utilities/SaleCreate.js\";\n\nexport class Application extends BaseApplication {\n constructor(bridge: Bridge) {\n super(bridge, new Database(bridge));\n\n this.bridge.addEventListener(this.handleEvent);\n this.addEventListener(\"REGISTER_CHANGED\", this.handleLocationChanged);\n }\n\n /**\n * Get the communicator when using the JavaScript communication method\n */\n public get communicator(): JavaScriptCommunicatorExports {\n if(this.bridge instanceof Bridge) {\n return this.bridge.communicator;\n }\n\n throw new Error(\n \"The provided bridge for the application doesn't support the JavaScript communicator\"\n );\n }\n\n /**\n * @inheritDoc\n */\n public destroy(): void {\n this.bridge.destroy();\n }\n\n /**\n * Handles an application event\n */\n protected handleEvent = (\n event: keyof FromShopfront | keyof FromShopfrontInternal,\n data: Record<string, unknown>,\n id: string\n ): void => {\n if(event === \"READY\") {\n this.isReady = true;\n this.key = data.key as string;\n this.outlet = data.outlet as string;\n this.register = data.register as string;\n\n data = {\n outlet : data.outlet,\n register: data.register,\n };\n }\n\n if(event === \"CALLBACK\") {\n this.handleEventCallback(data as { id?: string; data: unknown; });\n\n return;\n }\n\n if(event === \"CYCLE_KEY\") {\n if(typeof data !== \"object\" || data === null) {\n return;\n }\n\n this.key = data.key as string;\n\n return;\n } else if(event === \"LOCATION_CHANGED\") {\n // Unregister all serialized listeners as they're no longer displayed\n ActionEventRegistrar.clear();\n\n return;\n } else if(\n event === \"RESPONSE_CURRENT_SALE\" ||\n event === \"RESPONSE_DATABASE_REQUEST\" ||\n event === \"RESPONSE_LOCATION\" ||\n event === \"RESPONSE_OPTION\" ||\n event === \"RESPONSE_AUDIO_REQUEST\" ||\n event === \"RESPONSE_SECURE_KEY\" ||\n event === \"RESPONSE_CREATE_SALE\"\n ) {\n // Handled elsewhere\n return;\n }\n\n this.emit(event, data, id);\n };\n\n /**\n * Calls any registered listeners for the received event\n */\n protected emit(\n event: ListenableFromShopfrontEvent | DirectShopfrontEvent,\n data: Record<string, unknown> = {},\n id: string\n ): MaybePromise<void> {\n if(isDirectShopfrontEvent(event)) {\n const listeners = this.directListeners[event];\n\n if(typeof listeners === \"undefined\") {\n return this.bridge.sendMessage(ToShopfront.NOT_LISTENING_TO_EVENT);\n }\n\n const results = [];\n\n for(const e of listeners.values()) {\n results.push(e.emit(data));\n }\n\n return Promise.all(results)\n .then(() => {\n // Ensure void is returned\n });\n }\n\n let results = [];\n\n if(typeof this.listeners[event] === \"undefined\") {\n return this.bridge.sendMessage(ToShopfront.UNSUPPORTED_EVENT, event, id);\n }\n\n if(this.listeners[event].size === 0) {\n return this.bridge.sendMessage(ToShopfront.NOT_LISTENING_TO_EVENT, event, id);\n }\n\n for(const e of this.listeners[event].values()) {\n results.push(e.emit(data, this.bridge) as Promise<FromShopfrontReturns[typeof event]>);\n }\n\n // Respond if necessary\n switch(event) {\n case \"REQUEST_BUTTONS\":\n results = results as Array<Promise<FromShopfrontReturns[\"REQUEST_BUTTONS\"]>>;\n\n return Promise.all(results)\n .then((res: Array<Array<Button>>) => {\n return RequestButtons.respond(this.bridge, res.flat(), id);\n });\n case \"REQUEST_SETTINGS\":\n results = results as Array<Promise<FromShopfrontReturns[\"REQUEST_SETTINGS\"]>>;\n\n return Promise.all(results)\n .then((res: Array<FromShopfrontReturns[\"REQUEST_SETTINGS\"]>) => {\n return RequestSettings.respond(this.bridge, res.flat(), id);\n });\n case \"REQUEST_TABLE_COLUMNS\":\n results = results as Array<Promise<FromShopfrontReturns[\"REQUEST_TABLE_COLUMNS\"]>>;\n\n return Promise.all(results)\n .then((res: Array<FromShopfrontReturns[\"REQUEST_TABLE_COLUMNS\"]>) => {\n return RequestTableColumns.respond(this.bridge, res.flat(), id);\n });\n case \"REQUEST_SELL_SCREEN_OPTIONS\":\n results = results as Array<Promise<FromShopfrontReturns[\"REQUEST_SELL_SCREEN_OPTIONS\"]>>;\n\n return Promise.all(results)\n .then((res: Array<FromShopfrontReturns[\"REQUEST_SELL_SCREEN_OPTIONS\"]>) => {\n return RequestSellScreenOptions.respond(this.bridge, res.flat(), id);\n });\n case \"FORMAT_INTEGRATED_PRODUCT\":\n results = results as Array<Promise<FromShopfrontReturns[\"FORMAT_INTEGRATED_PRODUCT\"]>>;\n\n return Promise.all(results)\n .then((res: Array<FromShopfrontReturns[\"FORMAT_INTEGRATED_PRODUCT\"]>) => {\n return FormatIntegratedProduct.respond(this.bridge, res.flat(), id);\n });\n case \"REQUEST_CUSTOMER_LIST_OPTIONS\":\n results = results as Array<Promise<FromShopfrontReturns[\"REQUEST_CUSTOMER_LIST_OPTIONS\"]>>;\n\n return Promise.all(results)\n .then(res => RequestCustomerListOptions.respond(this.bridge, res.flat(), id));\n case \"REQUEST_SALE_KEYS\":\n results = results as Array<Promise<FromShopfrontReturns[\"REQUEST_SALE_KEYS\"]>>;\n\n return Promise.all(results)\n .then(res => RequestSaleKeys.respond(this.bridge, res.flat(), id));\n case \"UI_PIPELINE\":\n results = results as Array<Promise<FromShopfrontReturns[\"UI_PIPELINE\"]>>;\n\n return Promise.all(results)\n .then(res => {\n return UIPipeline.respond(this.bridge, res.flat(), id);\n });\n case \"GIFT_CARD_CODE_CHECK\":\n results = results as Array<Promise<FromShopfrontReturns[\"GIFT_CARD_CODE_CHECK\"]>>;\n\n return Promise.all(results)\n .then(res => {\n return GiftCardCodeCheck.respond(this.bridge, res[0], id);\n });\n case \"PAYMENT_METHODS_ENABLED\":\n results = results as Array<Promise<FromShopfrontReturns[\"PAYMENT_METHODS_ENABLED\"]>>;\n\n return Promise.all(results)\n .then(res => {\n return PaymentMethodsEnabled.respond(this.bridge, res.flat(), id);\n });\n case \"FULFILMENT_GET_ORDER\":\n results = results as Array<Promise<FromShopfrontReturns[\"FULFILMENT_GET_ORDER\"]>>;\n\n return Promise.all(results)\n .then(res => {\n return FulfilmentGetOrder.respond(this.bridge, res[0], id);\n });\n }\n }\n\n /**\n * @inheritDoc\n */\n public send(item: BaseEmitableEvent<unknown> | Serializable<unknown>): void {\n if(item instanceof Button) {\n throw new TypeError(\"You cannot send Buttons to Shopfront without Shopfront requesting them\");\n }\n\n if(item instanceof BaseEmitableEvent) {\n this.bridge.sendMessage(item.getEvent(), item.getData());\n } else {\n const serialized = item.serialize();\n\n this.bridge.sendMessage(ToShopfront.SERIALIZED, serialized);\n }\n }\n\n /**\n * @inheritDoc\n */\n public download(file: string): void {\n this.bridge.sendMessage(ToShopfront.DOWNLOAD, file);\n }\n\n /**\n * @inheritDoc\n */\n public redirect(toLocation: string, externalRedirect = true): void {\n this.bridge.sendMessage(ToShopfront.REDIRECT, {\n to : toLocation,\n external: externalRedirect,\n });\n }\n\n /**\n * @inheritDoc\n */\n public load(): () => void {\n this.bridge.sendMessage(ToShopfront.LOAD, true);\n\n return () => this.bridge.sendMessage(ToShopfront.LOAD, false);\n }\n\n /**\n * Handles an event callback via the `ActionEventRegistrar`\n */\n protected handleEventCallback(data: { id?: string; data: unknown; }): void {\n if(typeof data.id === \"undefined\") {\n return;\n }\n\n const id = data.id;\n\n ActionEventRegistrar.fire(id, data.data);\n }\n\n /**\n * Updates the cached location data\n */\n protected handleLocationChanged(data: RegisterChangedEvent): undefined {\n this.register = data.register;\n this.outlet = data.outlet;\n this.user = data.user;\n }\n\n /**\n * @inheritDoc\n */\n public getAuthenticationKey(): string {\n return this.key;\n }\n\n /**\n * Checks whether `data` is formatted as a sale event\n */\n protected dataIsSaleEvent(data: Record<string, unknown>): data is {\n requestId: string;\n saleState: ShopfrontSaleState | false;\n } {\n return typeof data.requestId === \"string\" && (data.saleState === false || typeof data.saleState === \"object\");\n }\n\n /**\n * @inheritDoc\n */\n public async getCurrentSale(): Promise<CurrentSale | false> {\n const saleRequest = `SaleRequest-${Date.now().toString()}`;\n\n const promise = new Promise<ShopfrontSaleState | false>(res => {\n const listener = (\n event: keyof FromShopfrontInternal | keyof FromShopfront,\n data: Record<string, unknown>\n ) => {\n if(event !== \"RESPONSE_CURRENT_SALE\") {\n return;\n }\n\n if(!this.dataIsSaleEvent(data)) {\n return;\n }\n\n if(data.requestId !== saleRequest) {\n return;\n }\n\n this.bridge.removeEventListener(listener);\n res(data.saleState);\n };\n\n this.bridge.addEventListener(listener);\n });\n\n this.bridge.sendMessage(ToShopfront.REQUEST_CURRENT_SALE, {\n requestId: saleRequest,\n });\n\n const saleState = await promise;\n\n if(saleState === false) {\n return saleState;\n }\n\n return new CurrentSale(this, saleState);\n }\n\n /**\n * Checks whether `data` is formatted as response data from a 'create sale' request\n */\n protected dataIsCreateEvent(data: Record<string, unknown>): data is {\n requestId: string;\n success: boolean;\n message?: string;\n } {\n return typeof data.requestId === \"string\" &&\n typeof data.success === \"boolean\" &&\n (\n typeof data.message === \"undefined\" || typeof data.message === \"string\"\n );\n }\n\n /**\n * @inheritDoc\n */\n public async createSale(sale: Sale): Promise<{\n success: boolean;\n message?: string;\n }> {\n const createSaleRequest = `CreateSaleRequest-${Date.now().toString()}`;\n\n const promise = new Promise<{\n success: boolean;\n message?: string;\n }>(res => {\n const listener = (\n event: keyof FromShopfrontInternal | keyof FromShopfront,\n data: Record<string, unknown>\n ) => {\n if(event !== \"RESPONSE_CREATE_SALE\") {\n return;\n }\n\n if(!this.dataIsCreateEvent(data)) {\n return;\n }\n\n if(data.requestId !== createSaleRequest) {\n return;\n }\n\n this.bridge.removeEventListener(listener);\n res({\n success: data.success,\n message: data.message,\n });\n };\n\n this.bridge.addEventListener(listener);\n });\n\n this.bridge.sendMessage(ToShopfront.CREATE_SALE, {\n requestId: createSaleRequest,\n sale : buildSaleData(sale),\n });\n\n return promise;\n }\n\n /**\n * Checks whether `data` is formatted as location data\n */\n protected dataIsLocation(data: Record<string, unknown>): data is {\n requestId: string;\n register: string | null;\n outlet: string | null;\n user: string | null;\n } {\n return typeof data.requestId === \"string\" &&\n (typeof data.register === \"string\" || data.register === null) &&\n (typeof data.outlet === \"string\" || data.outlet === null) &&\n (typeof data.user === \"string\" || data.user === null);\n }\n\n /**\n * @inheritDoc\n */\n public async getLocation(): Promise<{\n register: string | null;\n outlet: string | null;\n user: string | null;\n }> {\n const locationRequest = `LocationRequest-${Date.now().toString()}`;\n\n const promise = new Promise<{\n register: string | null;\n outlet: string | null;\n user: string | null;\n }>(res => {\n const listener = (\n event: keyof FromShopfrontInternal | keyof FromShopfront,\n data: Record<string, unknown>\n ) => {\n if(event !== \"RESPONSE_LOCATION\") {\n return;\n }\n\n if(!this.dataIsLocation(data)) {\n return;\n }\n\n if(data.requestId !== locationRequest) {\n return;\n }\n\n this.bridge.removeEventListener(listener);\n res(data);\n };\n\n this.bridge.addEventListener(listener);\n });\n\n this.bridge.sendMessage(ToShopfront.REQUEST_LOCATION, {\n requestId: locationRequest,\n });\n\n const location = await promise;\n\n return {\n register: location.register,\n outlet : location.outlet,\n user : location.user,\n };\n }\n\n /**\n * @inheritDoc\n */\n public printReceipt(content: string): void {\n this.bridge.sendMessage(ToShopfront.PRINT_RECEIPT, {\n content,\n type: \"text\",\n });\n }\n\n /**\n * @inheritDoc\n */\n public changeSellScreenActionMode(mode: SellScreenActionMode): void {\n this.bridge.sendMessage(ToShopfront.CHANGE_SELL_SCREEN_ACTION_MODE, {\n mode,\n });\n }\n\n /**\n * @inheritDoc\n */\n public changeSellScreenSummaryMode(mode: SellScreenSummaryMode): void {\n this.bridge.sendMessage(ToShopfront.CHANGE_SELL_SCREEN_SUMMARY_MODE, {\n mode,\n });\n }\n\n /**\n * Checks whether `data` is formatted as an audio response\n */\n protected dataIsAudioResponse(data: Record<string, unknown>): data is {\n requestId: string;\n success: boolean;\n message?: string;\n } {\n return typeof data.requestId === \"string\" &&\n typeof data.success === \"boolean\" &&\n (\n typeof data.message === \"string\" ||\n typeof data.message === \"undefined\"\n );\n }\n\n /**\n * Sends an audio request to Shopfront\n */\n protected sendAudioRequest(type: SoundEvents, data?: unknown): Promise<ShopfrontResponse> {\n const request = `AudioRequest-${type}-${Date.now().toString()}`;\n\n const promise = new Promise<ShopfrontResponse>(res => {\n const listener = (\n event: keyof FromShopfrontInternal | keyof FromShopfront,\n data: Record<string, unknown>\n ) => {\n if(event !== \"RESPONSE_AUDIO_REQUEST\") {\n return;\n }\n\n if(!this.dataIsAudioResponse(data)) {\n return;\n }\n\n if(data.requestId !== request) {\n return;\n }\n\n this.bridge.removeEventListener(listener);\n\n res({\n success: data.success,\n message: data.message,\n });\n };\n\n this.bridge.addEventListener(listener);\n });\n\n this.bridge.sendMessage(type, {\n requestId: request,\n data,\n });\n\n return promise;\n }\n\n /**\n * @inheritDoc\n */\n public requestAudioPermission(): Promise<ShopfrontResponse> {\n return this.sendAudioRequest(ToShopfront.AUDIO_REQUEST_PERMISSION);\n }\n\n /**\n * @inheritDoc\n */\n public audioPreload(url: string): Promise<ShopfrontResponse> {\n return this.sendAudioRequest(\n ToShopfront.AUDIO_PRELOAD,\n {\n url,\n }\n );\n }\n\n /**\n * @inheritDoc\n */\n public audioPlay(url: string): Promise<ShopfrontResponse> {\n return this.sendAudioRequest(\n ToShopfront.AUDIO_PLAY,\n {\n url,\n }\n );\n }\n\n /**\n * Checks whether `data` is formatted as response data to a 'get option' request\n */\n protected dataIsOption<TValueType>(data: Record<string, unknown>): data is {\n requestId: string;\n option: string;\n value: TValueType | undefined;\n } {\n return typeof data.requestId === \"string\" && typeof data.option === \"string\";\n }\n\n /**\n * @inheritDoc\n */\n public async getOption<TValueType>(option: string, defaultValue: TValueType): Promise<TValueType> {\n const request = `OptionRequest-${Date.now().toString()}`;\n\n const promise = new Promise<TValueType | undefined>(res => {\n const listener = (\n event: keyof FromShopfrontInternal | keyof FromShopfront,\n data: Record<string, unknown>\n ) => {\n if(event !== \"RESPONSE_OPTION\") {\n return;\n }\n\n if(!this.dataIsOption<TValueType>(data)) {\n return;\n }\n\n if(data.requestId !== request) {\n return;\n }\n\n this.bridge.removeEventListener(listener);\n res(data.value);\n };\n\n this.bridge.addEventListener(listener);\n });\n\n this.bridge.sendMessage(ToShopfront.GET_OPTION, {\n requestId: request,\n option,\n });\n\n const optionValue = await promise;\n\n if(typeof optionValue === \"undefined\") {\n return defaultValue;\n }\n\n return optionValue;\n }\n\n /**\n * Checks whether `data` is formatted as response data to an embedded token request\n */\n protected dataIsEmbeddedToken(data: Record<string, unknown>): data is {\n requestId: string;\n data: BufferSource;\n signature: BufferSource;\n } {\n return typeof data.requestId === \"string\" && typeof data.data === \"object\" && data.data !== null;\n }\n\n /**\n * Generates a signing key and sends it to Shopfront\n */\n protected async generateSigningKey(): Promise<void> {\n if(typeof this.signingKey !== \"undefined\") {\n return;\n }\n\n this.signingKey = await crypto.subtle.generateKey({\n name : \"ECDSA\",\n namedCurve: \"P-384\",\n }, true, [ \"sign\", \"verify\" ]);\n\n this.bridge.sendMessage(ToShopfront.ROTATE_SIGNING_KEY, await crypto.subtle.exportKey(\n \"jwk\",\n this.signingKey.privateKey\n ));\n }\n\n /**\n * Decodes the embedded token response from Shopfront using the signing key\n */\n protected async decodeToken(\n signature: BufferSource,\n data: BufferSource,\n returnTokenObject?: boolean\n ): Promise<ShopfrontEmbeddedVerificationToken | string> {\n if(typeof this.signingKey === \"undefined\") {\n // Not possible to decode\n throw new Error(\"Unable to decode token due to a missing signing key\");\n }\n\n if(!(\n await crypto.subtle.verify({\n name: \"ECDSA\",\n hash: {\n name: \"SHA-384\",\n },\n }, this.signingKey.publicKey, signature, data)\n )) {\n throw new ShopfrontTokenDecodingError();\n }\n\n const decoded = JSON.parse(new TextDecoder().decode(data)) as ShopfrontEmbeddedVerificationToken;\n\n if(decoded.app !== this.bridge.key) {\n throw new ShopfrontTokenDecodingError();\n }\n\n if(decoded.url.loaded !== location.href) {\n throw new ShopfrontTokenDecodingError();\n }\n\n if(returnTokenObject) {\n return decoded;\n }\n\n return decoded.auth;\n }\n\n /**\n * Checks whether `data` is an error response from an embedded token request\n */\n protected tokenDataContainsErrors(data: unknown): data is ShopfrontEmbeddedTokenError {\n if(!data || typeof data !== \"object\") {\n return false;\n }\n\n return \"error\" in data && \"type\" in data;\n }\n\n /**\n * @inheritDoc\n */\n public getToken(returnTokenObject: true): Promise<ShopfrontEmbeddedVerificationToken>;\n /**\n * @inheritDoc\n */\n public getToken(returnTokenObject?: false): Promise<string>;\n /**\n * @inheritDoc\n */\n public async getToken(returnTokenObject?: boolean): Promise<string | ShopfrontEmbeddedVerificationToken> {\n await this.generateSigningKey();\n\n const request = `TokenRequest-${Date.now().toString()}`;\n const promise = new Promise<[BufferSource, BufferSource]>(res => {\n const listener: ApplicationEventListener = (event, data) => {\n if(event !== \"RESPONSE_SECURE_KEY\") {\n return;\n }\n\n if(!this.dataIsEmbeddedToken(data)) {\n return;\n }\n\n if(data.requestId !== request) {\n return;\n }\n\n this.bridge.removeEventListener(listener);\n res([ data.signature, data.data ]);\n };\n\n this.bridge.addEventListener(listener);\n });\n\n this.bridge.sendMessage(ToShopfront.REQUEST_SECURE_KEY, {\n requestId: request,\n });\n\n const [ signature, data ] = await promise;\n\n // Throw the error if there is one\n if(this.tokenDataContainsErrors(data)) {\n throw new ShopfrontTokenRequestError(data.type);\n }\n\n return this.decodeToken(signature, data, returnTokenObject);\n }\n}\n","import { ToShopfront } from \"../../ApplicationEvents.js\";\nimport { BaseEmitableEvent } from \"../BaseEmitableEvent.js\";\n\nexport interface FulfilmentOptions {\n requireApproval: boolean;\n}\n\nexport class Options extends BaseEmitableEvent<FulfilmentOptions> {\n constructor(options: FulfilmentOptions) {\n super(ToShopfront.FULFILMENT_OPTIONS, options);\n }\n}\n","import { ToShopfront } from \"../../ApplicationEvents.js\";\nimport { BaseEmitableEvent } from \"../BaseEmitableEvent.js\";\n\nexport class OrderCancel extends BaseEmitableEvent<{\n id: string;\n}> {\n constructor(id: string) {\n super(ToShopfront.FULFILMENT_ORDERS_CANCEL, {\n id,\n });\n }\n}\n","import { type OrderCreateDetails } from \"../../APIs/Fulfilment/FulfilmentTypes.js\";\nimport { ToShopfront } from \"../../ApplicationEvents.js\";\nimport { BaseEmitableEvent } from \"../BaseEmitableEvent.js\";\n\nexport class OrderCreate extends BaseEmitableEvent<{\n order: OrderCreateDetails;\n}> {\n constructor(order: OrderCreateDetails) {\n super(ToShopfront.FULFILMENT_ORDERS_CREATE, {\n order,\n });\n }\n}\n","import { type OrderCreateDetails } from \"../../APIs/Fulfilment/FulfilmentTypes.js\";\nimport { ToShopfront } from \"../../ApplicationEvents.js\";\nimport { BaseEmitableEvent } from \"../BaseEmitableEvent.js\";\n\nexport class OrdersSync extends BaseEmitableEvent<{\n orders: Array<OrderCreateDetails>;\n merge: boolean;\n}> {\n constructor(orders: Array<OrderCreateDetails>, merge: boolean) {\n super(ToShopfront.FULFILMENT_ORDERS_SYNC, {\n orders,\n merge,\n });\n }\n}\n","import { type OrderSummaryDetails } from \"../../APIs/Fulfilment/FulfilmentTypes.js\";\nimport { ToShopfront } from \"../../ApplicationEvents.js\";\nimport { BaseEmitableEvent } from \"../BaseEmitableEvent.js\";\n\nexport class OrderUpdate extends BaseEmitableEvent<{\n order: OrderSummaryDetails;\n}> {\n constructor(order: OrderSummaryDetails) {\n super(ToShopfront.FULFILMENT_ORDERS_UPDATE, {\n order,\n });\n }\n}\n","import { ToShopfront } from \"../../ApplicationEvents.js\";\nimport { BaseEmitableEvent } from \"../BaseEmitableEvent.js\";\nimport { type FulfilmentOptions } from \"./Options.js\";\n\n/**\n * Registers intent from the application to use the Fulfilment API\n * this event is not required but recommended to show the Fulfilment UI in shopfront sooner\n */\nexport class RegisterIntent extends BaseEmitableEvent<{\n options?: FulfilmentOptions;\n}> {\n constructor(options: FulfilmentOptions) {\n super(ToShopfront.FULFILMENT_OPT_IN, {\n options,\n });\n }\n}\n","import { ToShopfront } from \"../ApplicationEvents.js\";\nimport type { SellScreenOption as Option } from \"../Events/RequestSellScreenOptions.js\";\nimport { RequestSellScreenOptions } from \"../Events/RequestSellScreenOptions.js\";\nimport { BaseEmitableEvent } from \"./BaseEmitableEvent.js\";\n\nexport class SellScreenOption extends BaseEmitableEvent<Option> {\n constructor(url: string, title: string) {\n RequestSellScreenOptions.validateURL(url);\n\n super(ToShopfront.SELL_SCREEN_OPTION_CHANGE, {\n id: RequestSellScreenOptions.getOptionId(url),\n url,\n title,\n });\n }\n}\n","import { ToShopfront } from \"../ApplicationEvents.js\";\nimport { BaseEmitableEvent } from \"./BaseEmitableEvent.js\";\n\nexport interface PromotionApplicableData {\n enable: boolean;\n key: string;\n}\n\nexport class SellScreenPromotionApplicable extends BaseEmitableEvent<PromotionApplicableData> {\n /**\n * Enable or disable a set of already created \"applicable\" promotions\n * @param key {string} The key to enable or disable, this supports wildcards using an asterisk\n * @param enable {boolean} Whether the key should be enabled or disabled\n */\n constructor(key: string, enable: boolean) {\n super(ToShopfront.SELL_SCREEN_PROMOTION_APPLICABLE, {\n key,\n enable,\n });\n }\n}\n","import { type FromShopfrontReturns, ToShopfront } from \"../ApplicationEvents.js\";\nimport { BaseEmitableEvent } from \"./BaseEmitableEvent.js\";\n\nexport class TableUpdate extends BaseEmitableEvent<{\n location: string;\n data: Exclude<FromShopfrontReturns[\"REQUEST_TABLE_COLUMNS\"], null>;\n}> {\n constructor(location: string, columns: Exclude<FromShopfrontReturns[\"REQUEST_TABLE_COLUMNS\"], null>) {\n super(ToShopfront.TABLE_UPDATE, {\n location,\n data: columns,\n });\n }\n}\n","import { BaseCurrentSale } from \"../../../APIs/Sale/BaseCurrentSale.js\";\nimport { ProductNotExistsError, SaleCancelledError } from \"../../../APIs/Sale/Exceptions.js\";\nimport {\n SaleCustomer,\n SalePayment,\n SaleProduct,\n type ShopfrontSaleState,\n} from \"../../../APIs/Sale/index.js\";\nimport {\n type DirectShopfrontEvent,\n type DirectShopfrontEventData,\n} from \"../../../ApplicationEvents.js\";\nimport { type SaleEventProduct } from \"../../../Events/DirectEvents/types/SaleEventData.js\";\nimport { MockApplication } from \"../../MockApplication.js\";\n\nconst emptySaleState: ShopfrontSaleState = {\n clientId: undefined,\n register: undefined,\n products: [],\n customer: false,\n payments: [],\n notes : {\n sale : \"\",\n internal: \"\",\n },\n totals: {\n sale : 0,\n paid : 0,\n savings : 0,\n discount: 0,\n },\n linkedTo : \"\",\n orderReference: \"\",\n refundReason : \"\",\n priceSet : null,\n metaData : {},\n};\n\nexport class MockCurrentSale extends BaseCurrentSale {\n constructor(application: MockApplication, saleState?: ShopfrontSaleState) {\n super(application, saleState ?? emptySaleState);\n }\n\n /**\n * Fires the event trigger\n */\n protected async triggerEvent<Event extends DirectShopfrontEvent>(\n event: Event,\n data: DirectShopfrontEventData[Event]\n ): Promise<void> {\n if(this.application instanceof MockApplication) {\n switch(event) {\n case \"SALE_ADD_PRODUCT\":\n await this.application.fireEvent(\n \"SALE_ADD_PRODUCT\",\n data as DirectShopfrontEventData[\"SALE_ADD_PRODUCT\"]\n );\n\n break;\n case \"SALE_REMOVE_PRODUCT\":\n await this.application.fireEvent(\n \"SALE_REMOVE_PRODUCT\",\n data as DirectShopfrontEventData[\"SALE_REMOVE_PRODUCT\"]\n );\n\n break;\n case \"SALE_CHANGE_QUANTITY\":\n await this.application.fireEvent(\n \"SALE_CHANGE_QUANTITY\",\n data as DirectShopfrontEventData[\"SALE_CHANGE_QUANTITY\"]\n );\n\n break;\n case \"SALE_UPDATE_PRODUCTS\":\n await this.application.fireEvent(\n \"SALE_UPDATE_PRODUCTS\",\n data as DirectShopfrontEventData[\"SALE_UPDATE_PRODUCTS\"]\n );\n\n break;\n case \"SALE_ADD_CUSTOMER\":\n await this.application.fireEvent(\n \"SALE_ADD_CUSTOMER\",\n data as DirectShopfrontEventData[\"SALE_ADD_CUSTOMER\"]\n );\n\n break;\n case \"SALE_REMOVE_CUSTOMER\":\n await this.application.fireEvent(\"SALE_REMOVE_CUSTOMER\");\n\n break;\n case \"SALE_CLEAR\":\n await this.application.fireEvent(\"SALE_CLEAR\");\n\n break;\n }\n } else {\n throw new Error(\"Manually firing events is only supported in the `MockApplication`\");\n }\n }\n\n /**\n * Check if the sale has already been cancelled, if it has, throw a SaleCancelledError.\n */\n protected checkIfCancelled(): void {\n if(this.cancelled) {\n throw new SaleCancelledError();\n }\n }\n\n /**\n * @inheritDoc\n */\n public async refreshSale(): Promise<void> {\n /* Do nothing */\n }\n\n /**\n * @inheritDoc\n */\n public async cancelSale(): Promise<void> {\n this.clearSale();\n\n this.cancelled = true;\n }\n\n /**\n * Round the price to the specified decimal place\n */\n protected roundNumber(price: number, precision = 2): number {\n const multiplier = Math.pow(10, precision);\n\n return Math.round(price * multiplier) / multiplier;\n }\n\n /**\n * Updates the sale total by adding the specified `amount`\n */\n protected updateSaleTotal(amount: number): void {\n this.sale.totals.sale += amount;\n this.sale.totals.sale = this.roundNumber(this.sale.totals.sale);\n };\n\n /**\n * Updates the paid total by adding the specified `amount`\n */\n protected updatePaidTotal(amount: number): void {\n this.sale.totals.paid += amount;\n this.sale.totals.paid = this.roundNumber(this.sale.totals.paid);\n };\n\n /**\n * Updates the sale total when a product's price is changed\n */\n protected handleSaleProductPriceChange(index: number, currentPrice: number, newPrice: number): void {\n // Editing the property directly to avoid triggering the `wasPriceModified` flag\n this.products[index][\"price\"] = newPrice;\n\n const difference = newPrice - currentPrice;\n\n this.updateSaleTotal(difference);\n };\n\n /**\n * @inheritDoc\n */\n public async addProduct(product: SaleProduct): Promise<void> {\n this.checkIfCancelled();\n\n // Check if product already exists in the sale\n try {\n // If it does, update it\n const index = this.getIndexOfProduct(product);\n\n // TODO: Does not currently support not consolidating\n // If a product is added again with a different price, the new price is ignored\n // This behaviour was taken from the `addProductToSale` function in the POS\n\n const currentPrice = this.products[index].getPrice() || 0;\n\n const currentRate = currentPrice / this.products[index].getQuantity();\n\n // Editing the property directly to avoid triggering the `wasQuantityModified` flag\n this.products[index][\"quantity\"] += product.getQuantity();\n\n const newPrice = this.roundNumber(currentRate * this.products[index].getQuantity());\n\n this.handleSaleProductPriceChange(index, currentPrice, newPrice);\n\n await this.triggerEvent(\"SALE_UPDATE_PRODUCTS\", { products: [] });\n\n return;\n } catch(e) {\n // We want to throw the error unless it's because the product isn't in the sale\n if(!(e instanceof ProductNotExistsError)) {\n throw e;\n }\n }\n\n product[\"indexAddress\"] = this.products.length === 0 ? [ 0 ] : [ this.products.length ];\n product[\"edited\"] = false;\n\n this.products.push(this.cloneProduct(product));\n\n this.updateSaleTotal(product.getPrice() || 0);\n\n await this.triggerEvent(\"SALE_ADD_PRODUCT\", {\n product : this.generateSaleEventProduct(product),\n indexAddress: product.getIndexAddress(),\n });\n\n await this.triggerEvent(\"SALE_UPDATE_PRODUCTS\", {\n products: [ this.generateSaleEventProduct(product) ],\n });\n }\n\n /**\n * @inheritDoc\n */\n public async removeProduct(product: SaleProduct): Promise<void> {\n this.checkIfCancelled();\n\n if(this.products.length === 1 && this.sale.totals.paid !== 0) {\n throw new Error(\n \"Cannot remove the last product from the sale if the sale contains an outstanding balance\"\n );\n }\n\n const index = this.getIndexOfProduct(product);\n\n this.products.splice(index, 1);\n\n this.updateSaleTotal((product.getPrice() || 0) * -1);\n\n // Reshuffle the index addresses\n for(let i = 0, l = this.products.length; i < l; i++) {\n this.products[i][\"indexAddress\"] = [ i ];\n }\n\n await this.triggerEvent(\"SALE_REMOVE_PRODUCT\", {\n indexAddress: product.getIndexAddress(),\n });\n }\n\n /**\n * @inheritDoc\n */\n public async addPayment(payment: SalePayment): Promise<void> {\n this.checkIfCancelled();\n\n this.payments.push(this.clonePayment(payment));\n\n if(payment.getStatus() === \"cancelled\" || payment.getStatus() === \"failed\") {\n // No need to update any of the totals\n return;\n }\n\n this.updatePaidTotal(payment.getAmount() - (payment.getCashout() || 0));\n\n const remaining = this.roundNumber(this.sale.totals.sale - this.sale.totals.paid);\n\n if(remaining <= 0) {\n this.clearSale();\n\n await this.triggerEvent(\"SALE_CLEAR\", undefined);\n }\n }\n\n /**\n * @inheritDoc\n */\n public async reversePayment(payment: SalePayment): Promise<void> {\n this.checkIfCancelled();\n\n // Should not be reverse-able past 0\n if(this.sale.totals.paid - payment.getAmount() < 0) {\n throw new Error(\"The paid total cannot be less than 0\");\n }\n\n const reversed = this.clonePayment(payment, true);\n\n this.payments.push(reversed);\n\n if(payment.getStatus() === \"cancelled\" || payment.getStatus() === \"failed\") {\n // No need to update any of the totals\n return;\n }\n\n this.updatePaidTotal(reversed.getAmount());\n }\n\n /**\n * @inheritDoc\n */\n public async addCustomer(customer: SaleCustomer): Promise<void> {\n this.checkIfCancelled();\n\n this.customer = customer;\n\n await this.triggerEvent(\"SALE_ADD_CUSTOMER\", {\n customer: {\n uuid: customer.getId(),\n },\n });\n }\n\n /**\n * @inheritDoc\n */\n public async removeCustomer(): Promise<void> {\n this.checkIfCancelled();\n\n this.customer = null;\n\n await this.triggerEvent(\"SALE_REMOVE_CUSTOMER\", undefined);\n }\n\n /**\n * @inheritDoc\n */\n public async setExternalNote(note: string, append?: boolean): Promise<void> {\n this.checkIfCancelled();\n\n let toSet;\n\n if(append) {\n toSet = `${this.sale.notes.sale}${note}`;\n } else {\n toSet = note;\n }\n\n this.sale.notes.sale = toSet;\n }\n\n /**\n * @inheritDoc\n */\n public async setInternalNote(note: string, append?: boolean): Promise<void> {\n this.checkIfCancelled();\n\n let toSet;\n\n if(append) {\n toSet = `${this.sale.notes.internal}${note}`;\n } else {\n toSet = note;\n }\n\n this.sale.notes.internal = toSet;\n }\n\n /**\n * @inheritDoc\n */\n public async setOrderReference(reference: string): Promise<void> {\n this.checkIfCancelled();\n\n this.sale.orderReference = reference;\n }\n\n /**\n * @inheritDoc\n */\n public async setMetaData(metaData: Record<string, unknown>): Promise<void> {\n this.checkIfCancelled();\n\n this.sale.metaData = metaData;\n }\n\n /**\n * @inheritDoc\n */\n public async updateProduct(product: SaleProduct): Promise<void> {\n this.checkIfCancelled();\n\n const index = this.getIndexOfProduct(product);\n\n if(product.wasQuantityModified()) {\n const currentPrice = this.products[index].getPrice() || 0;\n const currentRate = this.roundNumber(currentPrice / this.products[index].getQuantity());\n\n this.products[index][\"quantity\"] = product.getQuantity();\n\n const newPrice = this.roundNumber(currentRate * product.getQuantity());\n\n this.handleSaleProductPriceChange(index, currentPrice, newPrice);\n }\n\n if(product.wasPriceModified()) {\n const currentPrice = this.products[index].getPrice() || 0;\n const newPrice = product.getPrice() || 0;\n\n this.handleSaleProductPriceChange(index, currentPrice, newPrice);\n }\n\n if(product.wasMetaDataModified()) {\n this.products[index][\"metaData\"] = product.getMetaData();\n }\n\n product.clearModificationFlags();\n\n await this.triggerEvent(\"SALE_UPDATE_PRODUCTS\", {\n products: [ this.generateSaleEventProduct(product) ],\n });\n }\n\n /**\n * Retrieves the index of a product in the sale\n */\n protected getIndexOfProduct(product: SaleProduct): number {\n const index = this.products.findIndex((p) => p.getId() === product.getId());\n\n if(index === -1) {\n throw new ProductNotExistsError();\n }\n\n return index;\n }\n\n /**\n * Clones a sale product so it can be added to the sale\n */\n protected cloneProduct(product: SaleProduct): SaleProduct {\n const clone = new SaleProduct(\n product.getId(),\n product.getQuantity(),\n product.getPrice(),\n product.getIndexAddress()\n );\n\n clone[\"note\"] = product[\"note\"];\n clone[\"contains\"] = product[\"contains\"];\n clone[\"edited\"] = product[\"edited\"];\n clone[\"promotions\"] = product[\"promotions\"];\n clone[\"metaData\"] = product[\"metaData\"];\n clone[\"quantityModified\"] = product[\"quantityModified\"];\n clone[\"priceModified\"] = product[\"priceModified\"];\n clone[\"metaDataModified\"] = product[\"metaDataModified\"];\n\n return clone;\n }\n\n /**\n * Clones a sale payment so it can be added to the sale\n */\n protected clonePayment(payment: SalePayment, reverse = false): SalePayment {\n const updatedAmount = reverse ? payment.getAmount() * -1 : payment.getAmount();\n\n const clone = new SalePayment(\n payment.getId(),\n updatedAmount,\n payment.getCashout(),\n payment.getStatus()\n );\n\n clone[\"metaData\"] = payment[\"metaData\"];\n\n return clone;\n }\n\n /**\n * Generates a SaleEventProduct from a SaleProduct\n */\n protected generateSaleEventProduct(product: SaleProduct): SaleEventProduct {\n return {\n uuid : product.getId(),\n type : product.getType() ?? \"Product\",\n name : product.getName() ?? \"Unknown Product\",\n caseQuantity: product.getCaseQuantity() ?? 1,\n isCase : (product.getCaseQuantity() ?? 1) / product.getQuantity() === 0,\n quantity : product.getQuantity(),\n loyalty : {\n earn : 0,\n redeem: 0,\n },\n prices: {\n price : 0,\n unlockedPrice : 0,\n normal : 0,\n base : 0,\n addPrice : 0,\n removePrice : 0,\n additionalPrice: 0,\n },\n tax: {\n id : \"tax-rate-id\",\n amount: 0,\n },\n surcharge : null,\n products : [],\n defaultProducts : [],\n preventManualDiscount: false,\n special : false,\n edited : false,\n promotions : {},\n rebates : {},\n giftCard : null,\n note : \"\",\n userId : null,\n familyId : null,\n categoryId : null,\n tags : [],\n canUnlock : false,\n lockQuantity : false,\n metaData : product.getMetaData(),\n lineId : \"\",\n priceList : false,\n };\n }\n\n /**\n * Clear the sale data\n */\n public clearSale(): void {\n this.products.length = 0;\n this.products.push(...[]);\n\n this.payments.length = 0;\n this.payments.push(...[]);\n\n this.customer = null;\n this.sale = {\n register: undefined,\n clientId: undefined,\n notes : {\n sale : \"\",\n internal: \"\",\n },\n totals: {\n sale : 0,\n paid : 0,\n savings : 0,\n discount: 0,\n },\n linkedTo : \"\",\n orderReference: \"\",\n refundReason : \"\",\n priceSet : null,\n metaData : {},\n };\n }\n}\n","import * as ApplicationEvents from \"../ApplicationEvents.js\";\nimport { type ApplicationEventListener, BaseBridge } from \"../BaseBridge.js\";\n\nexport class MockBridge extends BaseBridge {\n protected isReady = false;\n\n constructor(key: string, url: string) {\n super(key, url);\n\n this.registerListeners();\n this.sendMessage(ApplicationEvents.ToShopfront.READY);\n }\n\n /**\n * @inheritDoc\n */\n public destroy(): void {\n this.listeners = [];\n }\n\n /**\n * @inheritDoc\n */\n protected registerListeners(): void {\n /* Do nothing */\n }\n\n /**\n * @inheritDoc\n */\n protected unregisterListeners(): void {\n /* Do nothing */\n }\n\n /**\n * @inheritDoc\n */\n public async sendMessage(type: ApplicationEvents.ToShopfront, data?: unknown, id?: string): Promise<void> {\n if(type === ApplicationEvents.ToShopfront.READY) {\n if(typeof data !== \"undefined\") {\n throw new TypeError(\"The `data` parameter must be undefined when requesting ready state\");\n }\n\n if(this.isReady) {\n throw new Error(\"Shopfront is already ready\");\n }\n\n const listeners = this.listeners;\n\n // We can fire off a READY event straight away\n for(let i = 0, l = listeners.length; i < l; i++) {\n listeners[i](type, {\n key : \"signing-key-uuid\",\n outlet : \"outlet-uuid\",\n register: \"register-uuid\",\n }, id as string);\n }\n\n return;\n }\n\n // No need to do anything\n }\n\n /**\n * @inheritDoc\n */\n public addEventListener(listener: ApplicationEventListener): void {\n if(this.listeners.includes(listener)) {\n throw new Error(\"The listener provided is already registered\");\n }\n\n this.listeners.push(listener);\n\n // If this is a READY event listener, we can fire off a Ready event immediately\n if(!this.hasListener) {\n this.sendMessage(ApplicationEvents.ToShopfront.READY);\n this.hasListener = true;\n }\n }\n\n /**\n * @inheritDoc\n */\n public removeEventListener(listener: ApplicationEventListener): void {\n const index = this.listeners.indexOf(listener);\n\n if(index === -1) {\n return;\n }\n\n this.listeners = [\n ...this.listeners.slice(0, index),\n ...this.listeners.slice(index + 1),\n ];\n }\n}\n","import {\n BaseDatabase,\n type DatabaseCallReturn,\n type DatabaseMethodName,\n type DatabaseTable,\n} from \"../../APIs/Database/BaseDatabase.js\";\nimport type { LocalDatabaseBarcodeTemplate } from \"../../APIs/Database/types/BaseBarcodeTemplateRepository.js\";\nimport type { LocalDatabaseClassification } from \"../../APIs/Database/types/BaseClassificationRepository.js\";\nimport type { LocalDatabaseCustomerDisplay } from \"../../APIs/Database/types/BaseCustomerDisplayRepository.js\";\nimport type { LocalDatabaseCustomerGroup } from \"../../APIs/Database/types/BaseCustomerGroupRepository.js\";\nimport type { LocalDatabaseCustomer } from \"../../APIs/Database/types/BaseCustomerRepository.js\";\nimport type { LocalDatabaseEnterprise } from \"../../APIs/Database/types/BaseEnterpriseRepository.js\";\nimport type { LocalDatabaseGiftCard } from \"../../APIs/Database/types/BaseGiftCardRepository.js\";\nimport type { LocalDatabaseLoyalty } from \"../../APIs/Database/types/BaseLoyaltyRepository.js\";\nimport type { LocalDatabaseMovement } from \"../../APIs/Database/types/BaseMovementRepository.js\";\nimport type { LocalDatabaseOutlet } from \"../../APIs/Database/types/BaseOutletRepository.js\";\nimport type { LocalDatabasePaymentMethod } from \"../../APIs/Database/types/BasePaymentMethodRepository.js\";\nimport type { LocalDatabasePriceList } from \"../../APIs/Database/types/BasePriceListRepository.js\";\nimport type { LocalDatabasePriceSet } from \"../../APIs/Database/types/BasePriceSetRepository.js\";\nimport type { LocalDatabaseProduct } from \"../../APIs/Database/types/BaseProductRepository.js\";\nimport type { LocalDatabasePromotionCategory } from \"../../APIs/Database/types/BasePromotionCategoryRepository.js\";\nimport type { LocalDatabasePromotion } from \"../../APIs/Database/types/BasePromotionRepository.js\";\nimport type { LocalDatabaseReceipt } from \"../../APIs/Database/types/BaseReceiptRepository.js\";\nimport type { LocalDatabaseRegister } from \"../../APIs/Database/types/BaseRegisterRepository.js\";\nimport type { LocalDatabaseSaleKeys } from \"../../APIs/Database/types/BaseSalesKeyRepository.js\";\nimport type { LocalDatabaseSale } from \"../../APIs/Database/types/BaseSalesRepository.js\";\nimport type {\n LocalDatabaseStocktakeAccumulated,\n} from \"../../APIs/Database/types/BaseStocktakeAccumulatedRepository.js\";\nimport type { LocalDatabaseStocktake } from \"../../APIs/Database/types/BaseStocktakeRepository.js\";\nimport type { LocalDatabaseStocktakeScanned } from \"../../APIs/Database/types/BaseStocktakeScannedRepository.js\";\nimport type { LocalDatabaseSupplier } from \"../../APIs/Database/types/BaseSupplierRepository.js\";\nimport type { LocalDatabaseTakings } from \"../../APIs/Database/types/BaseTakingsRepository.js\";\nimport type { LocalDatabaseTaxRate } from \"../../APIs/Database/types/BaseTaxRateRepository.js\";\nimport type { LocalDatabaseTransferee } from \"../../APIs/Database/types/BaseTransfereeRepository.js\";\nimport type { LocalDatabaseVendorConnection } from \"../../APIs/Database/types/BaseVendorConnectionRepository.js\";\nimport { MockBridge } from \"../MockBridge.js\";\n\ninterface MockedDatabase {\n products: Array<LocalDatabaseProduct>;\n customers: Array<LocalDatabaseCustomer>;\n customerGroups: Array<LocalDatabaseCustomerGroup>;\n promotions: Array<LocalDatabasePromotion>;\n promotionCategories: Array<LocalDatabasePromotionCategory>;\n priceLists: Array<LocalDatabasePriceList>;\n paymentMethods: Array<LocalDatabasePaymentMethod>;\n salesKeys: Array<LocalDatabaseSaleKeys>;\n receipts: Array<LocalDatabaseReceipt>;\n giftCards: Array<LocalDatabaseGiftCard>;\n loyalty: Array<LocalDatabaseLoyalty>;\n customerDisplays: Array<LocalDatabaseCustomerDisplay>;\n sales: Array<LocalDatabaseSale>;\n brands: Array<LocalDatabaseClassification>;\n categories: Array<LocalDatabaseClassification>;\n families: Array<LocalDatabaseClassification>;\n tags: Array<LocalDatabaseClassification>;\n outlets: Array<LocalDatabaseOutlet>;\n registers: Array<LocalDatabaseRegister>;\n taxRates: Array<LocalDatabaseTaxRate>;\n takings: Array<LocalDatabaseTakings>;\n suppliers: Array<LocalDatabaseSupplier>;\n priceSets: Array<LocalDatabasePriceSet>;\n transferees: Array<LocalDatabaseTransferee>;\n movements: Array<LocalDatabaseMovement>;\n stocktakes: Array<LocalDatabaseStocktake>;\n stocktakeScanned: Array<LocalDatabaseStocktakeScanned>;\n stocktakeAccumulated: Array<LocalDatabaseStocktakeAccumulated>;\n barcodeTemplates: Array<LocalDatabaseBarcodeTemplate>;\n vendorConnections: Array<LocalDatabaseVendorConnection>;\n enterprises: Array<LocalDatabaseEnterprise>;\n}\n\nconst emptyDatabase: MockedDatabase = {\n products : [],\n customers : [],\n customerGroups : [],\n promotions : [],\n promotionCategories : [],\n priceLists : [],\n paymentMethods : [],\n salesKeys : [],\n receipts : [],\n giftCards : [],\n loyalty : [],\n customerDisplays : [],\n sales : [],\n brands : [],\n categories : [],\n families : [],\n tags : [],\n outlets : [],\n registers : [],\n taxRates : [],\n takings : [],\n suppliers : [],\n priceSets : [],\n transferees : [],\n movements : [],\n stocktakes : [],\n stocktakeScanned : [],\n stocktakeAccumulated: [],\n barcodeTemplates : [],\n vendorConnections : [],\n enterprises : [],\n};\n\nexport class MockDatabase extends BaseDatabase<MockBridge> {\n protected mockedDatabase: MockedDatabase = emptyDatabase;\n\n constructor(bridge: MockBridge) {\n super(bridge);\n }\n\n /**\n * @inheritDoc\n */\n public async callMethod<\n Table extends DatabaseTable,\n Method extends keyof DatabaseMethodName<Table>,\n ExpectedResult extends DatabaseCallReturn<Table, Method>\n >(\n table: Table,\n method: Method,\n args: Array<unknown>\n ): Promise<ExpectedResult> {\n return {} as ExpectedResult;\n }\n\n /**\n * @inheritDoc\n */\n public async all<Table extends DatabaseTable>(table: Table): Promise<DatabaseCallReturn<Table, \"all\">> {\n return [] as DatabaseCallReturn<Table, \"all\">;\n }\n\n /**\n * @inheritDoc\n */\n public async get<Table extends DatabaseTable>(\n table: Table,\n id: string | number\n ): Promise<DatabaseCallReturn<Table, \"get\">> {\n return {} as DatabaseCallReturn<Table, \"get\">;\n }\n\n /**\n * @inheritDoc\n */\n public async count(table: DatabaseTable): Promise<number> {\n return 0;\n }\n\n /**\n * Insert data into the mocked Database\n */\n public insertData<Table extends keyof MockedDatabase>(\n table: Table,\n rows: Array<MockedDatabase[Table]>\n ): void {\n if(typeof this.mockedDatabase[table] === \"undefined\") {\n throw new Error(`The table ${table} does not exist`);\n }\n\n // @ts-expect-error TypeScript resolves `MockedDatabase[Table]` as a union of arrays\n this.mockedDatabase[table].push(...rows);\n }\n\n /**\n * Clears all data from the mocked database\n */\n public clearDatabase(): void {\n this.mockedDatabase = emptyDatabase;\n }\n\n /**\n * Clears the data from a specified table\n */\n public clearTable<Table extends keyof MockedDatabase>(table: Table): void {\n if(typeof this.mockedDatabase[table] === \"undefined\") {\n throw new Error(`The table ${table} does not exist`);\n }\n\n this.mockedDatabase[table] = [];\n }\n}\n","import { Sale } from \"../APIs/Sale/index.js\";\nimport {\n type DirectShopfrontCallbacks,\n type DirectShopfrontEvent,\n type FromShopfront,\n type FromShopfrontInternal,\n type FromShopfrontReturns,\n isDirectShopfrontEvent,\n type ListenableFromShopfrontEvent,\n type RegisterChangedEvent,\n type SellScreenActionMode,\n type SellScreenSummaryMode,\n type SoundEvents,\n ToShopfront,\n} from \"../ApplicationEvents.js\";\nimport { BaseApplication, type ShopfrontEmbeddedVerificationToken } from \"../BaseApplication.js\";\nimport { Bridge } from \"../Bridge.js\";\nimport { type Serializable } from \"../Common/Serializable.js\";\nimport { BaseEmitableEvent } from \"../EmitableEvents/BaseEmitableEvent.js\";\nimport ActionEventRegistrar from \"../Utilities/ActionEventRegistrar.js\";\nimport { MockCurrentSale } from \"./APIs/Sale/MockCurrentSale.js\";\nimport { MockDatabase } from \"./Database/MockDatabase.js\";\nimport { MockBridge } from \"./MockBridge.js\";\n\ninterface AudioRequestOptions {\n hasPermission: boolean;\n forceError: boolean;\n}\n\nexport class MockApplication extends BaseApplication {\n protected currentSale: MockCurrentSale | false = false;\n\n constructor(bridge: MockBridge) {\n super(bridge, new MockDatabase(bridge));\n\n this.bridge.addEventListener(this.handleEvent);\n this.addEventListener(\"REGISTER_CHANGED\", this.handleLocationChanged);\n\n this.fireEvent.bind(this);\n\n // Fire a ready event immediately\n this.handleEvent(\"READY\", {\n key : \"embedded-key\",\n outlet : \"outlet-id\",\n register: \"register-id\",\n }, \"\");\n }\n\n /**\n * @inheritDoc\n */\n public destroy(): void {\n this.bridge.destroy();\n }\n\n /**\n * Handles an application event\n */\n protected handleEvent = async (\n event: keyof FromShopfront | keyof FromShopfrontInternal,\n data: Record<string, unknown>,\n id: string\n ): Promise<void> => {\n if(event === \"READY\") {\n this.isReady = true;\n this.key = data.key as string;\n this.outlet = data.outlet as string;\n this.register = data.register as string;\n\n data = {\n outlet : data.outlet,\n register: data.register,\n };\n }\n\n if(event === \"CALLBACK\") {\n // Actions aren't implemented\n return;\n }\n\n if(event === \"CYCLE_KEY\") {\n // Not needed\n return;\n } else if(event === \"LOCATION_CHANGED\") {\n // Unregister all serialized listeners as they're no longer displayed\n ActionEventRegistrar.clear();\n\n return;\n } else if(\n event === \"RESPONSE_CURRENT_SALE\" ||\n event === \"RESPONSE_DATABASE_REQUEST\" ||\n event === \"RESPONSE_LOCATION\" ||\n event === \"RESPONSE_OPTION\" ||\n event === \"RESPONSE_AUDIO_REQUEST\" ||\n event === \"RESPONSE_SECURE_KEY\" ||\n event === \"RESPONSE_CREATE_SALE\"\n ) {\n // Handled elsewhere\n return;\n }\n\n await this.emit(event, data, id);\n };\n\n /**\n * Calls any registered listeners for the received event\n */\n protected async emit(\n event: ListenableFromShopfrontEvent | DirectShopfrontEvent,\n data: Record<string, unknown> | string = {},\n id: string\n ): Promise<void> {\n if(isDirectShopfrontEvent(event)) {\n const listeners = this.directListeners[event];\n\n if(typeof listeners === \"undefined\") {\n return this.bridge.sendMessage(ToShopfront.NOT_LISTENING_TO_EVENT);\n }\n\n const results = [];\n\n for(const e of listeners.values()) {\n results.push(e.emit(data));\n }\n\n await Promise.all(results);\n\n return;\n }\n\n const results: Array<Promise<FromShopfrontReturns[typeof event]>> = [];\n\n if(typeof this.listeners[event] === \"undefined\") {\n // Don't need to do anything here\n return;\n }\n\n if(this.listeners[event].size === 0) {\n // Don't need to do anything here\n return;\n }\n\n const bridge = this.bridge as unknown as Bridge;\n\n for(const e of this.listeners[event].values()) {\n results.push(e.emit(data, bridge));\n }\n\n await Promise.allSettled(results);\n\n // The responses have been removed as we don't currently need them\n }\n\n /**\n * @inheritDoc\n */\n public send(item: BaseEmitableEvent<unknown> | Serializable<unknown>): void {\n /* empty */\n }\n\n /**\n * @inheritDoc\n */\n public download(file: string): void {\n /* empty */\n }\n\n /**\n * @inheritDoc\n */\n public redirect(toLocation: string, externalRedirect = true): void {\n /* empty */\n }\n\n /**\n * @inheritDoc\n */\n public load(): () => void {\n return () => undefined;\n }\n\n /**\n * @inheritDoc\n */\n protected handleEventCallback(data: { id?: string; data: unknown; }): void {\n /* empty */\n }\n\n /**\n * Updates the cached location data\n */\n protected handleLocationChanged = (data: RegisterChangedEvent): undefined => {\n this.register = data.register;\n this.outlet = data.outlet;\n this.user = data.user;\n };\n\n /**\n * @inheritDoc\n */\n public getAuthenticationKey(): string {\n return this.key;\n }\n\n /**\n * @inheritDoc\n */\n public async getCurrentSale(): Promise<MockCurrentSale | false> {\n if(!this.currentSale) {\n this.currentSale = new MockCurrentSale(this);\n }\n\n return this.currentSale;\n }\n\n /**\n * @inheritDoc\n */\n public async createSale(sale: Sale): Promise<{\n success: boolean;\n message?: string;\n }> {\n if(!sale.getRegister() && !this.register) {\n return {\n success: false,\n message: \"Sale has not provided a register and Shopfront currently doesn't have a register selected.\",\n };\n }\n\n if(!this.user) {\n return {\n success: false,\n message: \"A sale cannot be created when there is no user logged in to Shopfront.\",\n };\n }\n\n const payments = sale.getPayments();\n\n let totalPaid = 0;\n\n for(const payment of payments) {\n if(payment.getCashout()) {\n return {\n success: false,\n message: \"Sale payment with cash out is currently unsupported \" +\n \"through the Embedded Fulfilment API.\",\n };\n }\n\n if(payment.getRounding()) {\n return {\n success: false,\n message: \"Sale payment with rounding is currently unsupported \" +\n \"through the Embedded Fulfilment API.\",\n };\n }\n\n totalPaid += payment.getAmount();\n }\n\n // Round to 4 decimal places to keep consistent with POS\n const remaining = Math.round((sale.getSaleTotal() - totalPaid) * 1000) / 1000;\n\n if(remaining < 0) {\n return {\n success: false,\n message: \"Total paid is greater than sale total.\",\n };\n }\n\n return {\n success: true,\n };\n }\n\n /**\n * @inheritDoc\n */\n public async getLocation(options?: { globalMode: boolean; useRegister: boolean; }): Promise<{\n register: string | null;\n outlet: string | null;\n user: string | null;\n }> {\n if(options) {\n if(options.globalMode) {\n return {\n register: null,\n outlet : null,\n user : \"shopfront-user-id\",\n };\n } else if(!options.useRegister) {\n return {\n register: null,\n outlet : \"shopfront-outlet-id\",\n user : \"shopfront-user-id\",\n };\n }\n }\n\n return {\n register: \"shopfront-register-id\",\n outlet : \"shopfront-outlet-id\",\n user : \"shopfront-user-id\",\n };\n }\n\n /**\n * @inheritDoc\n */\n public printReceipt(content: string): void {\n /* empty */\n }\n\n /**\n * @inheritDoc\n */\n public changeSellScreenActionMode(mode: SellScreenActionMode): void {\n /* empty */\n }\n\n /**\n * @inheritDoc\n */\n public changeSellScreenSummaryMode(mode: SellScreenSummaryMode): void {\n /* empty */\n }\n\n /**\n * @inheritDoc\n */\n protected async sendAudioRequest(\n _type: SoundEvents,\n _data?: unknown,\n options?: AudioRequestOptions\n ): Promise<{ success: boolean; message?: string; }> {\n if(options) {\n if(!options.hasPermission) {\n return {\n success: false,\n message: \"You do not have permission to play audio\",\n };\n }\n\n if(options.forceError) {\n return {\n success: false,\n message: \"An error occurred whilst trying to play the audio\",\n };\n }\n }\n\n return {\n success: true,\n };\n }\n\n /**\n * @inheritDoc\n */\n public requestAudioPermission(options?: AudioRequestOptions): Promise<{ success: boolean; message?: string; }> {\n return this.sendAudioRequest(ToShopfront.AUDIO_REQUEST_PERMISSION, undefined, options);\n }\n\n /**\n * @inheritDoc\n */\n public audioPreload(url: string, options?: AudioRequestOptions): Promise<{ success: boolean; message?: string; }> {\n return this.sendAudioRequest(\n ToShopfront.AUDIO_PRELOAD,\n {\n url,\n },\n options\n );\n }\n\n /**\n * @inheritDoc\n */\n public audioPlay(url: string, options?: AudioRequestOptions): Promise<{ success: boolean; message?: string; }> {\n return this.sendAudioRequest(\n ToShopfront.AUDIO_PLAY,\n {\n url,\n },\n options\n );\n }\n\n /**\n * @inheritDoc\n */\n public async getOption<TValueType>(option: string, defaultValue: TValueType): Promise<TValueType> {\n return defaultValue;\n }\n\n /**\n * @inheritDoc\n */\n public getToken(returnTokenObject: true): Promise<ShopfrontEmbeddedVerificationToken>;\n /**\n * @inheritDoc\n */\n public getToken(returnTokenObject?: false): Promise<string>;\n /**\n * @inheritDoc\n */\n public async getToken(returnTokenObject?: boolean): Promise<string | ShopfrontEmbeddedVerificationToken> {\n if(returnTokenObject) {\n return {\n id : \"token-id\",\n app : \"app-id\",\n auth: \"embedded-token\",\n user: \"user-id\",\n url : {\n raw : \"https://testing.test\",\n loaded: \"https://frame.url\",\n },\n };\n }\n\n return \"embedded-token\";\n }\n\n /**\n * Mocks an event being fired from Shopfront\n */\n public async fireEvent<\n T extends ListenableFromShopfrontEvent,\n HasParams extends (Parameters<FromShopfront[T][\"emit\"]> extends [never] ? false : true),\n >(\n event: T,\n ...data: HasParams extends true ? Parameters<FromShopfront[T][\"emit\"]> : [undefined]\n ): Promise<void>;\n /**\n * Mocks an event being fired from Shopfront\n */\n public async fireEvent<\n D extends DirectShopfrontEvent,\n HasParams extends (Parameters<DirectShopfrontCallbacks[D]> extends [never] ? false : true),\n >(\n event: D,\n ...data: HasParams extends true ? Parameters<DirectShopfrontCallbacks[D]> : [undefined]\n ): Promise<void>;\n /**\n * Mocks an event being fired from Shopfront\n */\n public async fireEvent<\n T extends ListenableFromShopfrontEvent,\n D extends DirectShopfrontEvent,\n HasParams extends (D extends DirectShopfrontEvent ?\n Parameters<DirectShopfrontCallbacks[D]> extends [never] ? false : true :\n Parameters<FromShopfront[T][\"emit\"]> extends [never] ? false : true),\n >(\n event: T | D,\n ...data: HasParams extends true ?\n D extends DirectShopfrontEvent ?\n Parameters<DirectShopfrontCallbacks[D]> :\n Parameters<FromShopfront[T][\"emit\"]> :\n [undefined]\n ): Promise<void> {\n let params: Record<string, unknown> | string | undefined;\n\n if(data.length > 0) {\n if(typeof data[0] === \"object\") {\n params = {\n ...data[0],\n };\n } else {\n params = data[0];\n }\n // We don't care about the Bridge param in FromShopfront events, as that is passed in by the `emit` method\n // Direct events do not pass in a second parameter\n }\n\n await this.emit(event, params, \"\");\n };\n}\n","import { MockApplication } from \"./MockApplication.js\";\nimport { MockBridge } from \"./MockBridge.js\";\n\n/**\n * Creates a mocked instance of the Embedded Application\n */\nfunction mockApplication(id: string, vendor: string): MockApplication {\n if(typeof id === \"undefined\") {\n throw new TypeError(\"You must specify the ID for the application\");\n }\n\n if(typeof vendor === \"undefined\") {\n throw new TypeError(\"You must specify the Vendor for the application\");\n }\n\n return new MockApplication(new MockBridge(id, vendor));\n}\n\nexport {\n MockApplication,\n mockApplication,\n MockBridge,\n};\n"],"names":["EventEmitter","event","callback","index","args","events","l","ActionEventRegistrar","id","action","data","ActionEventRegistrar$1","staticImplements","constructor","BaseAction","serialized","type","i","properties","results","property","__publicField","__decorateClass","Button","label","icon","Dialog","closeable","header","content","buttons","InternalRedirect","to","ExternalRedirect","Redirect","SaleKey","name","Toast","message","BaseSale","customer","payments","products","sale","SaleCancelledError","InvalidSaleDeviceError","ProductNotExistsError","SaleCustomer","UUID","d0","d1","d2","d3","SalePaymentStatus","SalePayment","amount","cashout","status","payment","hydrated","SaleProduct","quantity","price","indexAddress","product","key","value","Sale","p","note","append","metaData","reference","application","saleState","BaseEmitableEvent","shopfrontEventName","InternalMessage","method","destination","ToShopfront","InternalMessageSource","url","BaseBridge","BaseEvent","AudioPermissionChange","AudioReady","BaseDirectEvent","SaleAddCustomer","SaleAddProduct","SaleChangeQuantity","SaleClear","SaleRemoveCustomer","SaleRemoveProduct","SaleUpdateProducts","FormatIntegratedProduct","result","bridge","FulfilmentCollectOrder","FulfilmentCompleteOrder","FulfilmentGetOrder","order","FulfilmentOrderApproval","FulfilmentProcessOrder","FulfilmentVoidOrder","GiftCardCodeCheck","InternalPageMessage","PaymentMethodsEnabled","Ready","RegisterChanged","RequestButtons","response","CustomerListOption","contents","RequestCustomerListOptions","_","options","option","o","RequestSaleKeys","keys","RequestSellScreenOptions","RequestSettings","settings","RequestTableColumns","columns","column","SaleComplete","Bridge","communicateVia","ApplicationEvents.ToShopfront","Application","listeners","listener","UIPipeline","context","directShopfrontEvents","isDirectShopfrontEvent","BaseDatabase","Database","table","databaseRequest","promise","res","rej","SaleUpdate","BaseCurrentSale","CurrentSale","newSale","update","updateData","ShopfrontTokenDecodingError","ShopfrontTokenRequestError","BaseApplication","database","c","buildSaleProductData","caseQuantity","buildSaleData","e","item","file","toLocation","externalRedirect","saleRequest","createSaleRequest","locationRequest","location","mode","request","defaultValue","optionValue","signature","returnTokenObject","decoded","Options","OrderCancel","OrderCreate","OrdersSync","orders","merge","OrderUpdate","RegisterIntent","SellScreenOption","title","SellScreenPromotionApplicable","enable","TableUpdate","emptySaleState","MockCurrentSale","MockApplication","precision","multiplier","currentPrice","newPrice","difference","currentRate","reversed","toSet","clone","reverse","updatedAmount","MockBridge","emptyDatabase","MockDatabase","rows","totalPaid","_type","_data","params","mockApplication","vendor"],"mappings":"AAEO,MAAMA,GAAa;AAAA,EACZ,kBAAiC,CAAA;AAAA,EACnC,YAAuF,CAAA;AAAA;AAAA;AAAA;AAAA,EAKxF,iBAAiBC,GAAeC,GAAoE;AACvG,QAAG,CAAC,KAAK,gBAAgB,SAASD,CAAK;AACnC,YAAM,IAAI,UAAU,GAAGA,CAAK,2BAA2B;AAG3D,IAAG,OAAO,KAAK,UAAUA,CAAK,IAAM,QAChC,KAAK,UAAUA,CAAK,IAAI,CAAA,IAG5B,KAAK,UAAUA,CAAK,EAAE,KAAKC,CAAQ;AAAA,EACvC;AAAA;AAAA;AAAA;AAAA,EAKO,oBAAoBD,GAAeC,GAAoE;AAC1G,QAAG,CAAC,KAAK,gBAAgB,SAASD,CAAK;AACnC,YAAM,IAAI,UAAU,GAAGA,CAAK,2BAA2B;AAG3D,QAAG,OAAO,KAAK,UAAUA,CAAK,IAAM;AAChC;AAGJ,UAAME,IAAQ,KAAK,UAAUF,CAAK,EAAE,QAAQC,CAAQ;AAEpD,IAAGC,MAAU,OA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