@shopfront/bridge 2.0.0 → 2.0.1
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/.idea/codeStyles/Project.xml +10 -0
- package/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/git_toolbox_blame.xml +6 -0
- package/.idea/git_toolbox_prj.xml +15 -0
- package/.idea/inspectionProfiles/Project_Default.xml +5 -0
- package/.idea/jsLinters/eslint.xml +6 -0
- package/.idea/modules.xml +1 -1
- package/.idea/php.xml +15 -0
- package/lib/APIs/Database/BaseDatabase.d.ts +28 -0
- package/lib/APIs/Database/BaseDatabase.js +5 -0
- package/lib/APIs/Database/Database.d.ts +19 -7
- package/lib/APIs/Database/Database.js +22 -12
- package/lib/APIs/Database/types/BaseBarcodeTemplateRepository.d.ts +8 -0
- package/lib/APIs/Database/types/BaseBarcodeTemplateRepository.js +1 -0
- package/lib/APIs/Database/types/BaseClassificationRepository.d.ts +11 -0
- package/lib/APIs/Database/types/BaseClassificationRepository.js +1 -0
- package/lib/APIs/Database/types/BaseCustomerDisplayRepository.d.ts +10 -0
- package/lib/APIs/Database/types/BaseCustomerDisplayRepository.js +1 -0
- package/lib/APIs/Database/types/BaseCustomerGroupRepository.d.ts +24 -0
- package/lib/APIs/Database/types/BaseCustomerGroupRepository.js +1 -0
- package/lib/APIs/Database/types/BaseCustomerRepository.d.ts +76 -0
- package/lib/APIs/Database/types/BaseCustomerRepository.js +1 -0
- package/lib/APIs/Database/types/BaseEnterpriseRepository.d.ts +8 -0
- package/lib/APIs/Database/types/BaseEnterpriseRepository.js +1 -0
- package/lib/APIs/Database/types/BaseGiftCardRepository.d.ts +18 -0
- package/lib/APIs/Database/types/BaseGiftCardRepository.js +1 -0
- package/lib/APIs/Database/types/BaseKitchenOrderRepository.d.ts +41 -0
- package/lib/APIs/Database/types/BaseKitchenOrderRepository.js +1 -0
- package/lib/APIs/Database/types/BaseKitchenScreenRepository.d.ts +16 -0
- package/lib/APIs/Database/types/BaseKitchenScreenRepository.js +1 -0
- package/lib/APIs/Database/types/BaseLockedResourceRepository.d.ts +12 -0
- package/lib/APIs/Database/types/BaseLockedResourceRepository.js +1 -0
- package/lib/APIs/Database/types/BaseLoyaltyRepository.d.ts +16 -0
- package/lib/APIs/Database/types/BaseLoyaltyRepository.js +1 -0
- package/lib/APIs/Database/types/BaseMovementRepository.d.ts +16 -0
- package/lib/APIs/Database/types/BaseMovementRepository.js +1 -0
- package/lib/APIs/Database/types/BaseOutletRepository.d.ts +19 -0
- package/lib/APIs/Database/types/BaseOutletRepository.js +1 -0
- package/lib/APIs/Database/types/BasePaymentMethodRepository.d.ts +27 -0
- package/lib/APIs/Database/types/BasePaymentMethodRepository.js +1 -0
- package/lib/APIs/Database/types/BasePriceListRepository.d.ts +40 -0
- package/lib/APIs/Database/types/BasePriceListRepository.js +1 -0
- package/lib/APIs/Database/types/BasePriceSetRepository.d.ts +6 -0
- package/lib/APIs/Database/types/BasePriceSetRepository.js +1 -0
- package/lib/APIs/Database/types/BaseProductRepository.d.ts +160 -0
- package/lib/APIs/Database/types/BaseProductRepository.js +1 -0
- package/lib/APIs/Database/types/BasePromotionCategoryRepository.d.ts +10 -0
- package/lib/APIs/Database/types/BasePromotionCategoryRepository.js +1 -0
- package/lib/APIs/Database/types/BasePromotionRepository.d.ts +72 -0
- package/lib/APIs/Database/types/BasePromotionRepository.js +1 -0
- package/lib/APIs/Database/types/BaseReceiptRepository.d.ts +31 -0
- package/lib/APIs/Database/types/BaseReceiptRepository.js +1 -0
- package/lib/APIs/Database/types/BaseRegisterRepository.d.ts +56 -0
- package/lib/APIs/Database/types/BaseRegisterRepository.js +1 -0
- package/lib/APIs/Database/types/BaseRepository.d.ts +41 -0
- package/lib/APIs/Database/types/BaseRepository.js +1 -0
- package/lib/APIs/Database/types/BaseSalesKeyRepository.d.ts +37 -0
- package/lib/APIs/Database/types/BaseSalesKeyRepository.js +1 -0
- package/lib/APIs/Database/types/BaseSalesRepository.d.ts +123 -0
- package/lib/APIs/Database/types/BaseSalesRepository.js +1 -0
- package/lib/APIs/Database/types/BaseSearchableRepository.d.ts +8 -0
- package/lib/APIs/Database/types/BaseSearchableRepository.js +1 -0
- package/lib/APIs/Database/types/BaseStocktakeAccumulatedRepository.d.ts +16 -0
- package/lib/APIs/Database/types/BaseStocktakeAccumulatedRepository.js +1 -0
- package/lib/APIs/Database/types/BaseStocktakeRepository.d.ts +8 -0
- package/lib/APIs/Database/types/BaseStocktakeRepository.js +1 -0
- package/lib/APIs/Database/types/BaseStocktakeScannedRepository.d.ts +24 -0
- package/lib/APIs/Database/types/BaseStocktakeScannedRepository.js +1 -0
- package/lib/APIs/Database/types/BaseSupplierRepository.d.ts +35 -0
- package/lib/APIs/Database/types/BaseSupplierRepository.js +1 -0
- package/lib/APIs/Database/types/BaseTakingsRepository.d.ts +13 -0
- package/lib/APIs/Database/types/BaseTakingsRepository.js +1 -0
- package/lib/APIs/Database/types/BaseTaxRateRepository.d.ts +9 -0
- package/lib/APIs/Database/types/BaseTaxRateRepository.js +1 -0
- package/lib/APIs/Database/types/BaseTransfereeRepository.d.ts +12 -0
- package/lib/APIs/Database/types/BaseTransfereeRepository.js +1 -0
- package/lib/APIs/Database/types/BaseVendorConnectionRepository.d.ts +7 -0
- package/lib/APIs/Database/types/BaseVendorConnectionRepository.js +1 -0
- package/lib/APIs/Database/types/DataSourceTables.d.ts +61 -0
- package/lib/APIs/Database/types/DataSourceTables.js +1 -0
- package/lib/APIs/Fulfilment/FulfilmentTypes.d.ts +2 -2
- package/lib/APIs/Fulfilment/FulfilmentTypes.js +1 -2
- package/lib/APIs/InternalMessages/InternalMessageSource.d.ts +6 -3
- package/lib/APIs/InternalMessages/InternalMessageSource.js +6 -7
- package/lib/APIs/Sale/BaseCurrentSale.d.ts +83 -0
- package/lib/APIs/Sale/BaseCurrentSale.js +13 -0
- package/lib/APIs/Sale/BaseSale.d.ts +3 -38
- package/lib/APIs/Sale/BaseSale.js +1 -40
- package/lib/APIs/Sale/CurrentSale.d.ts +19 -84
- package/lib/APIs/Sale/CurrentSale.js +32 -102
- package/lib/APIs/Sale/Exceptions.d.ts +3 -0
- package/lib/APIs/Sale/Exceptions.js +7 -7
- package/lib/APIs/Sale/Sale.d.ts +39 -7
- package/lib/APIs/Sale/Sale.js +41 -13
- package/lib/APIs/Sale/SaleCustomer.d.ts +0 -2
- package/lib/APIs/Sale/SaleCustomer.js +1 -7
- package/lib/APIs/Sale/SalePayment.d.ts +3 -22
- package/lib/APIs/Sale/SalePayment.js +7 -33
- package/lib/APIs/Sale/SaleProduct.d.ts +6 -46
- package/lib/APIs/Sale/SaleProduct.js +6 -53
- package/lib/APIs/Sale/ShopfrontSaleState.d.ts +7 -9
- package/lib/APIs/Sale/ShopfrontSaleState.js +1 -2
- package/lib/APIs/Sale/index.d.ts +9 -9
- package/lib/APIs/Sale/index.js +7 -39
- package/lib/Actions/BaseAction.d.ts +21 -5
- package/lib/Actions/BaseAction.js +155 -97
- package/lib/Actions/Button.d.ts +2 -2
- package/lib/Actions/Button.js +3 -7
- package/lib/Actions/CustomerListOption.d.ts +2 -2
- package/lib/Actions/CustomerListOption.js +2 -6
- package/lib/Actions/Dialog.d.ts +4 -4
- package/lib/Actions/Dialog.js +2 -6
- package/lib/Actions/Redirect.d.ts +2 -2
- package/lib/Actions/Redirect.js +7 -9
- package/lib/Actions/SaleKey.d.ts +2 -2
- package/lib/Actions/SaleKey.js +3 -7
- package/lib/Actions/SaleUpdate.d.ts +3 -3
- package/lib/Actions/SaleUpdate.js +3 -7
- package/lib/Actions/Toast.d.ts +3 -3
- package/lib/Actions/Toast.js +2 -6
- package/lib/Application.d.ts +114 -78
- package/lib/Application.js +207 -160
- package/lib/ApplicationEvents.d.ts +66 -53
- package/lib/ApplicationEvents.js +10 -6
- package/lib/BaseApplication.d.ts +169 -0
- package/lib/BaseApplication.js +40 -0
- package/lib/BaseBridge.d.ts +33 -0
- package/lib/BaseBridge.js +16 -0
- package/lib/Bridge.d.ts +46 -9
- package/lib/Bridge.js +42 -54
- package/lib/Common/EventEmitter.d.ts +10 -1
- package/lib/Common/EventEmitter.js +10 -5
- package/lib/Common/Serializable.d.ts +8 -6
- package/lib/Common/Serializable.js +1 -2
- package/lib/EmitableEvents/BaseEmitableEvent.d.ts +7 -1
- package/lib/EmitableEvents/BaseEmitableEvent.js +7 -5
- package/lib/EmitableEvents/Fulfilment/Options.d.ts +1 -1
- package/lib/EmitableEvents/Fulfilment/Options.js +4 -8
- package/lib/EmitableEvents/Fulfilment/OrderCancel.d.ts +1 -1
- package/lib/EmitableEvents/Fulfilment/OrderCancel.js +4 -8
- package/lib/EmitableEvents/Fulfilment/OrderCreate.d.ts +2 -2
- package/lib/EmitableEvents/Fulfilment/OrderCreate.js +4 -8
- package/lib/EmitableEvents/Fulfilment/OrderUpdate.d.ts +2 -2
- package/lib/EmitableEvents/Fulfilment/OrderUpdate.js +4 -8
- package/lib/EmitableEvents/Fulfilment/OrdersSync.d.ts +2 -2
- package/lib/EmitableEvents/Fulfilment/OrdersSync.js +4 -8
- package/lib/EmitableEvents/Fulfilment/RegisterIntent.d.ts +2 -2
- package/lib/EmitableEvents/Fulfilment/RegisterIntent.js +4 -8
- package/lib/EmitableEvents/Fulfilment/index.d.ts +7 -7
- package/lib/EmitableEvents/Fulfilment/index.js +6 -15
- package/lib/EmitableEvents/InternalMessage.d.ts +2 -2
- package/lib/EmitableEvents/InternalMessage.js +4 -8
- package/lib/EmitableEvents/SellScreenOption.d.ts +2 -2
- package/lib/EmitableEvents/SellScreenOption.js +7 -11
- package/lib/EmitableEvents/SellScreenPromotionApplicable.d.ts +1 -1
- package/lib/EmitableEvents/SellScreenPromotionApplicable.js +4 -8
- package/lib/EmitableEvents/TableUpdate.d.ts +2 -2
- package/lib/EmitableEvents/TableUpdate.js +4 -8
- package/lib/Events/AudioPermissionChange.d.ts +5 -2
- package/lib/Events/AudioPermissionChange.js +6 -7
- package/lib/Events/AudioReady.d.ts +5 -2
- package/lib/Events/AudioReady.js +6 -7
- package/lib/Events/BaseEvent.d.ts +8 -3
- package/lib/Events/BaseEvent.js +1 -6
- package/lib/Events/Callback.d.ts +5 -2
- package/lib/Events/Callback.js +5 -6
- package/lib/Events/FormatIntegratedProduct.d.ts +27 -32
- package/lib/Events/FormatIntegratedProduct.js +12 -9
- package/lib/Events/FulfilmentCollectOrder.d.ts +5 -2
- package/lib/Events/FulfilmentCollectOrder.js +5 -6
- package/lib/Events/FulfilmentCompleteOrder.d.ts +5 -2
- package/lib/Events/FulfilmentCompleteOrder.js +5 -6
- package/lib/Events/FulfilmentGetOrder.d.ts +12 -6
- package/lib/Events/FulfilmentGetOrder.js +10 -8
- package/lib/Events/FulfilmentOrderApproval.d.ts +5 -2
- package/lib/Events/FulfilmentOrderApproval.js +5 -6
- package/lib/Events/FulfilmentProcessOrder.d.ts +12 -10
- package/lib/Events/FulfilmentProcessOrder.js +7 -8
- package/lib/Events/FulfilmentVoidOrder.d.ts +5 -2
- package/lib/Events/FulfilmentVoidOrder.js +5 -6
- package/lib/Events/GiftCardCodeCheck.d.ts +19 -0
- package/lib/Events/GiftCardCodeCheck.js +23 -0
- package/lib/Events/InternalPageMessage.d.ts +10 -4
- package/lib/Events/InternalPageMessage.js +12 -10
- package/lib/Events/PaymentMethodsEnabled.d.ts +16 -11
- package/lib/Events/PaymentMethodsEnabled.js +10 -8
- package/lib/Events/Ready.d.ts +12 -7
- package/lib/Events/Ready.js +5 -6
- package/lib/Events/RegisterChanged.d.ts +12 -6
- package/lib/Events/RegisterChanged.js +6 -7
- package/lib/Events/RequestButtons.d.ts +17 -12
- package/lib/Events/RequestButtons.js +13 -11
- package/lib/Events/RequestCustomerListOptions.d.ts +11 -5
- package/lib/Events/RequestCustomerListOptions.js +12 -11
- package/lib/Events/RequestSaleKeys.d.ts +12 -6
- package/lib/Events/RequestSaleKeys.js +13 -11
- package/lib/Events/RequestSellScreenOptions.d.ts +18 -5
- package/lib/Events/RequestSellScreenOptions.js +17 -9
- package/lib/Events/RequestSettings.d.ts +11 -5
- package/lib/Events/RequestSettings.js +12 -10
- package/lib/Events/RequestTableColumns.d.ts +16 -11
- package/lib/Events/RequestTableColumns.js +12 -9
- package/lib/Events/SaleComplete.d.ts +15 -18
- package/lib/Events/SaleComplete.js +6 -7
- package/lib/Events/UIPipeline.d.ts +17 -5
- package/lib/Events/UIPipeline.js +17 -10
- package/lib/Mocks/APIs/Sale/MockCurrentSale.d.ts +99 -0
- package/lib/Mocks/APIs/Sale/MockCurrentSale.js +326 -0
- package/lib/Mocks/Database/MockDatabase.d.ts +96 -0
- package/lib/Mocks/Database/MockDatabase.js +89 -0
- package/lib/Mocks/MockApplication.d.ts +154 -0
- package/lib/Mocks/MockApplication.js +482 -0
- package/lib/Mocks/MockBridge.d.ts +31 -0
- package/lib/Mocks/MockBridge.js +77 -0
- package/lib/Mocks/index.d.ts +7 -0
- package/lib/Mocks/index.js +15 -0
- package/lib/Utilities/ActionEventRegistrar.d.ts +19 -4
- package/lib/Utilities/ActionEventRegistrar.js +19 -3
- package/lib/Utilities/MiscTypes.d.ts +6 -4
- package/lib/Utilities/MiscTypes.js +1 -2
- package/lib/Utilities/SaleCreate.d.ts +6 -2
- package/lib/Utilities/SaleCreate.js +10 -6
- package/lib/Utilities/Static.d.ts +3 -0
- package/lib/Utilities/Static.js +5 -7
- package/lib/Utilities/UUID.d.ts +9 -3
- package/lib/Utilities/UUID.js +10 -7
- package/lib/index.d.ts +16 -14
- package/lib/index.js +14 -49
- package/package.json +3 -2
- package/lib/APIs/CurrentSale/Exceptions.d.ts +0 -6
- package/lib/APIs/CurrentSale/Exceptions.js +0 -15
- package/lib/APIs/CurrentSale/Sale.d.ts +0 -182
- package/lib/APIs/CurrentSale/Sale.js +0 -290
- package/lib/APIs/CurrentSale/SaleCustomer.d.ts +0 -10
- package/lib/APIs/CurrentSale/SaleCustomer.js +0 -17
- package/lib/APIs/CurrentSale/SalePayment.d.ts +0 -68
- package/lib/APIs/CurrentSale/SalePayment.js +0 -99
- package/lib/APIs/CurrentSale/SaleProduct.d.ts +0 -121
- package/lib/APIs/CurrentSale/SaleProduct.js +0 -167
- package/lib/APIs/CurrentSale/ShopfrontSaleState.d.ts +0 -53
- package/lib/APIs/CurrentSale/ShopfrontSaleState.js +0 -2
- package/lib/APIs/CurrentSale/index.d.ts +0 -6
- package/lib/APIs/CurrentSale/index.js +0 -37
- /package/.idea/{embedded-bridge.iml → shopfront-embedded-bridge.iml} +0 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import * as ApplicationEvents from "../ApplicationEvents.js";
|
|
2
|
+
import { BaseBridge } from "../BaseBridge.js";
|
|
3
|
+
export class MockBridge extends BaseBridge {
|
|
4
|
+
constructor(key, url) {
|
|
5
|
+
super(key, url);
|
|
6
|
+
this.isReady = false;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* @inheritDoc
|
|
10
|
+
*/
|
|
11
|
+
destroy() {
|
|
12
|
+
this.listeners = [];
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* @inheritDoc
|
|
16
|
+
*/
|
|
17
|
+
registerListeners() {
|
|
18
|
+
/* Do nothing */
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* @inheritDoc
|
|
22
|
+
*/
|
|
23
|
+
unregisterListeners() {
|
|
24
|
+
/* Do nothing */
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* @inheritDoc
|
|
28
|
+
*/
|
|
29
|
+
sendMessage(type, data, id) {
|
|
30
|
+
if (type === ApplicationEvents.ToShopfront.READY) {
|
|
31
|
+
if (typeof data !== "undefined") {
|
|
32
|
+
throw new TypeError("The `data` parameter must be undefined when requesting ready state");
|
|
33
|
+
}
|
|
34
|
+
if (this.isReady) {
|
|
35
|
+
throw new Error("Shopfront is already ready");
|
|
36
|
+
}
|
|
37
|
+
const listeners = this.listeners;
|
|
38
|
+
// We can fire off a READY event straight away
|
|
39
|
+
for (let i = 0, l = listeners.length; i < l; i++) {
|
|
40
|
+
listeners[i](type, {
|
|
41
|
+
key: "signing-key-uuid",
|
|
42
|
+
outlet: "outlet-uuid",
|
|
43
|
+
register: "register-uuid",
|
|
44
|
+
}, id);
|
|
45
|
+
}
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
// No need to do anything
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* @inheritDoc
|
|
52
|
+
*/
|
|
53
|
+
addEventListener(listener) {
|
|
54
|
+
if (this.listeners.includes(listener)) {
|
|
55
|
+
throw new Error("The listener provided is already registered");
|
|
56
|
+
}
|
|
57
|
+
this.listeners.push(listener);
|
|
58
|
+
// If this is a READY event listener, we can fire off a Ready event immediately
|
|
59
|
+
if (!this.hasListener) {
|
|
60
|
+
this.sendMessage(ApplicationEvents.ToShopfront.READY);
|
|
61
|
+
this.hasListener = true;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* @inheritDoc
|
|
66
|
+
*/
|
|
67
|
+
removeEventListener(listener) {
|
|
68
|
+
const index = this.listeners.indexOf(listener);
|
|
69
|
+
if (index === -1) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
this.listeners = [
|
|
73
|
+
...this.listeners.slice(0, index),
|
|
74
|
+
...this.listeners.slice(index + 1),
|
|
75
|
+
];
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { MockApplication } from "./MockApplication.js";
|
|
2
|
+
import { MockBridge } from "./MockBridge.js";
|
|
3
|
+
/**
|
|
4
|
+
* Creates a mocked instance of the Embedded Application
|
|
5
|
+
*/
|
|
6
|
+
declare function mockApplication(id: string, vendor: string): MockApplication;
|
|
7
|
+
export { MockApplication, mockApplication, MockBridge, };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { MockApplication } from "./MockApplication.js";
|
|
2
|
+
import { MockBridge } from "./MockBridge.js";
|
|
3
|
+
/**
|
|
4
|
+
* Creates a mocked instance of the Embedded Application
|
|
5
|
+
*/
|
|
6
|
+
function mockApplication(id, vendor) {
|
|
7
|
+
if (typeof id === "undefined") {
|
|
8
|
+
throw new TypeError("You must specify the ID for the application");
|
|
9
|
+
}
|
|
10
|
+
if (typeof vendor === "undefined") {
|
|
11
|
+
throw new TypeError("You must specify the Vendor for the application");
|
|
12
|
+
}
|
|
13
|
+
return new MockApplication(new MockBridge(id, vendor));
|
|
14
|
+
}
|
|
15
|
+
export { MockApplication, mockApplication, MockBridge, };
|
|
@@ -1,12 +1,27 @@
|
|
|
1
|
-
import { BaseAction } from "../Actions/BaseAction";
|
|
1
|
+
import { BaseAction } from "../Actions/BaseAction.js";
|
|
2
2
|
declare class ActionEventRegistrar {
|
|
3
|
-
events
|
|
4
|
-
[id: string]: BaseAction<undefined>;
|
|
5
|
-
};
|
|
3
|
+
private events;
|
|
6
4
|
constructor();
|
|
5
|
+
/**
|
|
6
|
+
* Registers an event action listener
|
|
7
|
+
* @param id
|
|
8
|
+
* @param action
|
|
9
|
+
*/
|
|
7
10
|
add(id: string, action: BaseAction<undefined>): void;
|
|
11
|
+
/**
|
|
12
|
+
* Removes an event action listener
|
|
13
|
+
* @param id
|
|
14
|
+
*/
|
|
8
15
|
remove(id: string): void;
|
|
16
|
+
/**
|
|
17
|
+
* Invokes the registered action event listener
|
|
18
|
+
* @param id
|
|
19
|
+
* @param data
|
|
20
|
+
*/
|
|
9
21
|
fire(id: string, data: unknown): void;
|
|
22
|
+
/**
|
|
23
|
+
* Clears all registered listeners
|
|
24
|
+
*/
|
|
10
25
|
clear(): void;
|
|
11
26
|
}
|
|
12
27
|
declare const _default: ActionEventRegistrar;
|
|
@@ -1,15 +1,28 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
1
|
class ActionEventRegistrar {
|
|
4
2
|
constructor() {
|
|
5
3
|
this.events = {};
|
|
6
4
|
}
|
|
5
|
+
/**
|
|
6
|
+
* Registers an event action listener
|
|
7
|
+
* @param id
|
|
8
|
+
* @param action
|
|
9
|
+
*/
|
|
7
10
|
add(id, action) {
|
|
8
11
|
this.events[id] = action;
|
|
9
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Removes an event action listener
|
|
15
|
+
* @param id
|
|
16
|
+
*/
|
|
10
17
|
remove(id) {
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
11
19
|
delete this.events[id];
|
|
12
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Invokes the registered action event listener
|
|
23
|
+
* @param id
|
|
24
|
+
* @param data
|
|
25
|
+
*/
|
|
13
26
|
fire(id, data) {
|
|
14
27
|
if (typeof this.events[id] === "undefined") {
|
|
15
28
|
// The event must have stopped listening
|
|
@@ -17,8 +30,11 @@ class ActionEventRegistrar {
|
|
|
17
30
|
}
|
|
18
31
|
this.events[id].handleRegistrarEvent(id, data);
|
|
19
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Clears all registered listeners
|
|
35
|
+
*/
|
|
20
36
|
clear() {
|
|
21
37
|
this.events = {};
|
|
22
38
|
}
|
|
23
39
|
}
|
|
24
|
-
|
|
40
|
+
export default new ActionEventRegistrar();
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A property which might be a promise or the promise's wrapped type
|
|
3
3
|
*/
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
export type MaybePromise<P> = P | Promise<P>;
|
|
5
|
+
export type ConstructorClass<T> = new (...args: Array<unknown>) => T;
|
|
6
|
+
/**
|
|
7
|
+
* A function that may or may not be asynchronous
|
|
8
|
+
*/
|
|
9
|
+
export type AnyFunction = (...args: Array<any>) => any;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { BaseSaleData } from "../APIs/Sale/BaseSale.js";
|
|
2
|
+
import { Sale, ShopfrontSalePaymentStatus } from "../APIs/Sale/index.js";
|
|
3
3
|
export interface SaleProductData {
|
|
4
4
|
uuid: string;
|
|
5
5
|
caseQuantity: number;
|
|
@@ -23,4 +23,8 @@ export interface SaleData extends BaseSaleData {
|
|
|
23
23
|
payments: Array<SalePaymentData>;
|
|
24
24
|
products: Array<SaleProductData>;
|
|
25
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Builds a Shopfront sale from the embedded sale data
|
|
28
|
+
* @param sale
|
|
29
|
+
*/
|
|
26
30
|
export declare function buildSaleData(sale: Sale): SaleData;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Builds a Shopfront sale product from the embedded product data
|
|
3
|
+
* @param product
|
|
4
|
+
*/
|
|
4
5
|
function buildSaleProductData(product) {
|
|
5
6
|
const price = product.getPrice();
|
|
6
7
|
if (typeof price !== "number") {
|
|
@@ -20,7 +21,11 @@ function buildSaleProductData(product) {
|
|
|
20
21
|
price,
|
|
21
22
|
};
|
|
22
23
|
}
|
|
23
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Builds a Shopfront sale from the embedded sale data
|
|
26
|
+
* @param sale
|
|
27
|
+
*/
|
|
28
|
+
export function buildSaleData(sale) {
|
|
24
29
|
const customer = sale.getCustomer();
|
|
25
30
|
return {
|
|
26
31
|
register: sale.getRegister(),
|
|
@@ -49,8 +54,7 @@ function buildSaleData(sale) {
|
|
|
49
54
|
status: payment.getStatus(),
|
|
50
55
|
rounding: payment.getRounding() || 0,
|
|
51
56
|
cashout: payment.getCashout() || 0,
|
|
52
|
-
metaData: payment.getMetaData()
|
|
57
|
+
metaData: payment.getMetaData(),
|
|
53
58
|
})),
|
|
54
59
|
};
|
|
55
60
|
}
|
|
56
|
-
exports.buildSaleData = buildSaleData;
|
package/lib/Utilities/Static.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function,@typescript-eslint/no-unused-vars
|
|
1
|
+
/**
|
|
2
|
+
* A decorator function that enforces static interface implementation for a class at compile time.
|
|
3
|
+
*/
|
|
4
|
+
export function staticImplements() {
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
7
6
|
return (constructor) => { };
|
|
8
7
|
}
|
|
9
|
-
exports.staticImplements = staticImplements;
|
package/lib/Utilities/UUID.d.ts
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Fast UUID generator, RFC4122 version 4 compliant.
|
|
3
3
|
* @author Jeff Ward (jcward.com).
|
|
4
|
-
* @license MIT
|
|
5
|
-
* @link http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/21963136#21963136
|
|
6
|
-
|
|
4
|
+
* @license MIT
|
|
5
|
+
* {@link http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/21963136#21963136}
|
|
6
|
+
*/
|
|
7
7
|
export default class UUID {
|
|
8
8
|
protected lut: Array<string>;
|
|
9
9
|
constructor();
|
|
10
|
+
/**
|
|
11
|
+
* Generates a UUID
|
|
12
|
+
*/
|
|
10
13
|
generate(): string;
|
|
14
|
+
/**
|
|
15
|
+
* Static method for generating a UUID
|
|
16
|
+
*/
|
|
11
17
|
static generate(): string;
|
|
12
18
|
}
|
package/lib/Utilities/UUID.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
1
|
/**
|
|
4
2
|
* Fast UUID generator, RFC4122 version 4 compliant.
|
|
5
3
|
* @author Jeff Ward (jcward.com).
|
|
6
|
-
* @license MIT
|
|
7
|
-
* @link http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/21963136#21963136
|
|
8
|
-
|
|
9
|
-
class UUID {
|
|
4
|
+
* @license MIT
|
|
5
|
+
* {@link http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/21963136#21963136}
|
|
6
|
+
*/
|
|
7
|
+
export default class UUID {
|
|
10
8
|
constructor() {
|
|
11
9
|
this.lut = [];
|
|
12
10
|
for (let i = 0; i < 256; i++) {
|
|
@@ -14,6 +12,9 @@ class UUID {
|
|
|
14
12
|
}
|
|
15
13
|
this.generate = this.generate.bind(this);
|
|
16
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Generates a UUID
|
|
17
|
+
*/
|
|
17
18
|
generate() {
|
|
18
19
|
const d0 = Math.random() * 0xffffffff | 0;
|
|
19
20
|
const d1 = Math.random() * 0xffffffff | 0;
|
|
@@ -36,6 +37,9 @@ class UUID {
|
|
|
36
37
|
this.lut[d3 >> 16 & 0xff] +
|
|
37
38
|
this.lut[d3 >> 24 & 0xff];
|
|
38
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Static method for generating a UUID
|
|
42
|
+
*/
|
|
39
43
|
static generate() {
|
|
40
44
|
if (typeof self?.crypto?.randomUUID === "function") {
|
|
41
45
|
return self.crypto.randomUUID();
|
|
@@ -43,4 +47,3 @@ class UUID {
|
|
|
43
47
|
return (new UUID()).generate();
|
|
44
48
|
}
|
|
45
49
|
}
|
|
46
|
-
exports.default = UUID;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export { Redirect } from "./Actions/Redirect";
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
10
|
-
export
|
|
11
|
-
export {
|
|
12
|
-
export {
|
|
13
|
-
export
|
|
14
|
-
export
|
|
1
|
+
export { Button } from "./Actions/Button.js";
|
|
2
|
+
export { Dialog } from "./Actions/Dialog.js";
|
|
3
|
+
export { Redirect } from "./Actions/Redirect.js";
|
|
4
|
+
export { SaleKey } from "./Actions/SaleKey.js";
|
|
5
|
+
export { Toast, type ToastType } from "./Actions/Toast.js";
|
|
6
|
+
export * as Sales from "./APIs/Sale/index.js";
|
|
7
|
+
export { Application } from "./Application.js";
|
|
8
|
+
export { type ShopfrontEmbeddedVerificationToken, ShopfrontTokenDecodingError } from "./BaseApplication.js";
|
|
9
|
+
export { Bridge } from "./Bridge.js";
|
|
10
|
+
export * as Fulfilment from "./EmitableEvents/Fulfilment/index.js";
|
|
11
|
+
export { SellScreenOption } from "./EmitableEvents/SellScreenOption.js";
|
|
12
|
+
export { SellScreenPromotionApplicable } from "./EmitableEvents/SellScreenPromotionApplicable.js";
|
|
13
|
+
export { TableUpdate } from "./EmitableEvents/TableUpdate.js";
|
|
14
|
+
export type { CompletedSale } from "./Events/SaleComplete.js";
|
|
15
|
+
export * from "./Mocks/index.js";
|
|
16
|
+
export type { SaleData as SaleCreateData, SalePaymentData as SaleCreatePaymentData, SaleProductData as SaleCreateProductData, } from "./Utilities/SaleCreate.js";
|
package/lib/index.js
CHANGED
|
@@ -1,49 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.Fulfilment = exports.Sales = exports.ShopfrontTokenDecodingError = exports.Application = exports.SellScreenPromotionApplicable = exports.TableUpdate = exports.SellScreenOption = exports.SaleKey = exports.Dialog = exports.Toast = exports.Redirect = exports.Button = exports.Bridge = void 0;
|
|
27
|
-
var Bridge_1 = require("./Bridge");
|
|
28
|
-
Object.defineProperty(exports, "Bridge", { enumerable: true, get: function () { return Bridge_1.Bridge; } });
|
|
29
|
-
var Button_1 = require("./Actions/Button");
|
|
30
|
-
Object.defineProperty(exports, "Button", { enumerable: true, get: function () { return Button_1.Button; } });
|
|
31
|
-
var Redirect_1 = require("./Actions/Redirect");
|
|
32
|
-
Object.defineProperty(exports, "Redirect", { enumerable: true, get: function () { return Redirect_1.Redirect; } });
|
|
33
|
-
var Toast_1 = require("./Actions/Toast");
|
|
34
|
-
Object.defineProperty(exports, "Toast", { enumerable: true, get: function () { return Toast_1.Toast; } });
|
|
35
|
-
var Dialog_1 = require("./Actions/Dialog");
|
|
36
|
-
Object.defineProperty(exports, "Dialog", { enumerable: true, get: function () { return Dialog_1.Dialog; } });
|
|
37
|
-
var SaleKey_1 = require("./Actions/SaleKey");
|
|
38
|
-
Object.defineProperty(exports, "SaleKey", { enumerable: true, get: function () { return SaleKey_1.SaleKey; } });
|
|
39
|
-
var SellScreenOption_1 = require("./EmitableEvents/SellScreenOption");
|
|
40
|
-
Object.defineProperty(exports, "SellScreenOption", { enumerable: true, get: function () { return SellScreenOption_1.SellScreenOption; } });
|
|
41
|
-
var TableUpdate_1 = require("./EmitableEvents/TableUpdate");
|
|
42
|
-
Object.defineProperty(exports, "TableUpdate", { enumerable: true, get: function () { return TableUpdate_1.TableUpdate; } });
|
|
43
|
-
var SellScreenPromotionApplicable_1 = require("./EmitableEvents/SellScreenPromotionApplicable");
|
|
44
|
-
Object.defineProperty(exports, "SellScreenPromotionApplicable", { enumerable: true, get: function () { return SellScreenPromotionApplicable_1.SellScreenPromotionApplicable; } });
|
|
45
|
-
var Application_1 = require("./Application");
|
|
46
|
-
Object.defineProperty(exports, "Application", { enumerable: true, get: function () { return Application_1.Application; } });
|
|
47
|
-
Object.defineProperty(exports, "ShopfrontTokenDecodingError", { enumerable: true, get: function () { return Application_1.ShopfrontTokenDecodingError; } });
|
|
48
|
-
exports.Sales = __importStar(require("./APIs/Sale/index"));
|
|
49
|
-
exports.Fulfilment = __importStar(require("./EmitableEvents/Fulfilment/index"));
|
|
1
|
+
export { Button } from "./Actions/Button.js";
|
|
2
|
+
export { Dialog } from "./Actions/Dialog.js";
|
|
3
|
+
export { Redirect } from "./Actions/Redirect.js";
|
|
4
|
+
export { SaleKey } from "./Actions/SaleKey.js";
|
|
5
|
+
export { Toast } from "./Actions/Toast.js";
|
|
6
|
+
export * as Sales from "./APIs/Sale/index.js";
|
|
7
|
+
export { Application } from "./Application.js";
|
|
8
|
+
export { ShopfrontTokenDecodingError } from "./BaseApplication.js";
|
|
9
|
+
export { Bridge } from "./Bridge.js";
|
|
10
|
+
export * as Fulfilment from "./EmitableEvents/Fulfilment/index.js";
|
|
11
|
+
export { SellScreenOption } from "./EmitableEvents/SellScreenOption.js";
|
|
12
|
+
export { SellScreenPromotionApplicable } from "./EmitableEvents/SellScreenPromotionApplicable.js";
|
|
13
|
+
export { TableUpdate } from "./EmitableEvents/TableUpdate.js";
|
|
14
|
+
export * from "./Mocks/index.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopfront/bridge",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"description": "The bridge used to embed your application within Shopfront",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"build": "tsc",
|
|
31
31
|
"watch": "tsc -w",
|
|
32
32
|
"lint": "eslint . --fix",
|
|
33
|
-
"test": "npx @onshopfront/core test"
|
|
33
|
+
"test": "npx @onshopfront/core test",
|
|
34
|
+
"prepublishOnly": "npm run build"
|
|
34
35
|
}
|
|
35
36
|
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.InvalidSaleDeviceError = exports.SaleCancelledError = void 0;
|
|
4
|
-
class SaleCancelledError extends Error {
|
|
5
|
-
constructor() {
|
|
6
|
-
super("The sale is no longer active.");
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
exports.SaleCancelledError = SaleCancelledError;
|
|
10
|
-
class InvalidSaleDeviceError extends Error {
|
|
11
|
-
constructor() {
|
|
12
|
-
super("This device is no longer a register able to perform a sale.");
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
exports.InvalidSaleDeviceError = InvalidSaleDeviceError;
|
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
import { Application } from "../../Application";
|
|
2
|
-
import { ShopfrontSaleState } from "./ShopfrontSaleState";
|
|
3
|
-
import { SaleUpdate, SaleUpdateChanges } from "../../Actions/SaleUpdate";
|
|
4
|
-
import { SaleProduct } from "./SaleProduct";
|
|
5
|
-
import { SalePayment } from "./SalePayment";
|
|
6
|
-
import { SaleCustomer } from "./SaleCustomer";
|
|
7
|
-
export declare class Sale {
|
|
8
|
-
protected application: Application;
|
|
9
|
-
protected sale: ShopfrontSaleState;
|
|
10
|
-
protected cancelled: boolean;
|
|
11
|
-
/**
|
|
12
|
-
* Create a sale from a sale state.
|
|
13
|
-
* It's highly recommend to not construct a sale manually, instead use application.getCurrentSale().
|
|
14
|
-
*
|
|
15
|
-
* @param {Application} application
|
|
16
|
-
* @param {ShopfrontSaleState} sale
|
|
17
|
-
*/
|
|
18
|
-
constructor(application: Application, sale: ShopfrontSaleState);
|
|
19
|
-
/**
|
|
20
|
-
* Get the raw state of the sale, it is highly recommend that you DO NOT use this method as the
|
|
21
|
-
* returned data may be quite volatile.
|
|
22
|
-
*
|
|
23
|
-
* @internal
|
|
24
|
-
* @returns {ShopfrontSaleState}
|
|
25
|
-
*/
|
|
26
|
-
getRawState(): ShopfrontSaleState;
|
|
27
|
-
/**
|
|
28
|
-
* Update the sale to be the latest sale that exists on the sell screen.
|
|
29
|
-
*
|
|
30
|
-
* @returns {Promise<void>}
|
|
31
|
-
*/
|
|
32
|
-
refreshSale(): Promise<void>;
|
|
33
|
-
/**
|
|
34
|
-
* Check if the sale has already been cancelled, if it has, throw a SaleCancelledError.
|
|
35
|
-
*
|
|
36
|
-
* @protected
|
|
37
|
-
*/
|
|
38
|
-
protected checkIfCancelled(): void;
|
|
39
|
-
/**
|
|
40
|
-
* Send a sale update to Shopfront.
|
|
41
|
-
*
|
|
42
|
-
* @protected
|
|
43
|
-
* @param {SaleUpdate} update
|
|
44
|
-
* @returns {Promise<void>}
|
|
45
|
-
*/
|
|
46
|
-
protected sendSaleUpdate(update: SaleUpdate<keyof SaleUpdateChanges>): Promise<void>;
|
|
47
|
-
/**
|
|
48
|
-
* Get the products that are currently on the sale.
|
|
49
|
-
*
|
|
50
|
-
* @returns {Array<SaleProduct>}
|
|
51
|
-
*/
|
|
52
|
-
getProducts(): Array<SaleProduct>;
|
|
53
|
-
/**
|
|
54
|
-
* Get the payments that are currently on the sale.
|
|
55
|
-
*
|
|
56
|
-
* @returns {Array<SalePayment>}
|
|
57
|
-
*/
|
|
58
|
-
getPayments(): Array<SalePayment>;
|
|
59
|
-
/**
|
|
60
|
-
* Get the current customer on the sale.
|
|
61
|
-
*
|
|
62
|
-
* @returns {SaleCustomer | null}
|
|
63
|
-
*/
|
|
64
|
-
getCustomer(): null | SaleCustomer;
|
|
65
|
-
/**
|
|
66
|
-
* Get the external sale note (visible to the customer).
|
|
67
|
-
*
|
|
68
|
-
* @returns {string}
|
|
69
|
-
*/
|
|
70
|
-
getExternalNote(): string;
|
|
71
|
-
/**
|
|
72
|
-
* Get the internal sale note.
|
|
73
|
-
*
|
|
74
|
-
* @returns {string}
|
|
75
|
-
*/
|
|
76
|
-
getInternalNote(): string;
|
|
77
|
-
/**
|
|
78
|
-
* Get the order reference (visible to the customer).
|
|
79
|
-
*
|
|
80
|
-
* @returns {string}
|
|
81
|
-
*/
|
|
82
|
-
getOrderReference(): string;
|
|
83
|
-
/**
|
|
84
|
-
* Get the current meta data for the sale
|
|
85
|
-
*
|
|
86
|
-
* @returns {Record<string, unknown>}
|
|
87
|
-
*/
|
|
88
|
-
getMetaData(): Record<string, unknown>;
|
|
89
|
-
/**
|
|
90
|
-
* Cancel the current sale in progress.
|
|
91
|
-
*
|
|
92
|
-
* @returns {Promise<void>}
|
|
93
|
-
*/
|
|
94
|
-
cancelSale(): Promise<void>;
|
|
95
|
-
/**
|
|
96
|
-
* Add a product to the sale.
|
|
97
|
-
*
|
|
98
|
-
* @param {SaleProduct} product
|
|
99
|
-
* @returns {Promise<void>}
|
|
100
|
-
*/
|
|
101
|
-
addProduct(product: SaleProduct): Promise<void>;
|
|
102
|
-
/**
|
|
103
|
-
* Remove a product from the sale.
|
|
104
|
-
* It's highly recommended that you pass in a product that has been retrieved using sale.getProducts().
|
|
105
|
-
*
|
|
106
|
-
* @param {SaleProduct} product
|
|
107
|
-
* @returns {Promise<void>}
|
|
108
|
-
*/
|
|
109
|
-
removeProduct(product: SaleProduct): Promise<void>;
|
|
110
|
-
/**
|
|
111
|
-
* Add a payment to the sell screen.
|
|
112
|
-
*
|
|
113
|
-
* If you specify a payment with a status, it will bypass the payment gateway (i.e. it won't request that the
|
|
114
|
-
* user takes money from the customer).
|
|
115
|
-
*
|
|
116
|
-
* If you don't specify a cashout amount, it will automatically determine if the payment method normally requests
|
|
117
|
-
* cashout (from the payment method settings).
|
|
118
|
-
*
|
|
119
|
-
* @param {SalePayment} payment
|
|
120
|
-
* @returns {Promise<void>}
|
|
121
|
-
*/
|
|
122
|
-
addPayment(payment: SalePayment): Promise<void>;
|
|
123
|
-
/**
|
|
124
|
-
* Reverse a payment on the sell screen.
|
|
125
|
-
*
|
|
126
|
-
* This is used to issue a refund to the customer. The sale payment amount should be positive.
|
|
127
|
-
*
|
|
128
|
-
* @param {SalePayment} payment
|
|
129
|
-
* @returns {Promise<void>}
|
|
130
|
-
*/
|
|
131
|
-
reversePayment(payment: SalePayment): Promise<void>;
|
|
132
|
-
/**
|
|
133
|
-
* Add a customer to the sale.
|
|
134
|
-
* If there is already a customer on the sale this will override that customer.
|
|
135
|
-
*
|
|
136
|
-
* @param {SaleCustomer} customer
|
|
137
|
-
* @returns {Promise<void>}
|
|
138
|
-
*/
|
|
139
|
-
addCustomer(customer: SaleCustomer): Promise<void>;
|
|
140
|
-
/**
|
|
141
|
-
* Remove the customer from the current sale.
|
|
142
|
-
* If there is no customer currently on the sale this will be ignored.
|
|
143
|
-
* If there are "on account" or loyalty payments still on the sale, this will be ignored.
|
|
144
|
-
*
|
|
145
|
-
* @returns {Promise<void>}
|
|
146
|
-
*/
|
|
147
|
-
removeCustomer(): Promise<void>;
|
|
148
|
-
/**
|
|
149
|
-
* Set the external note for the sale.
|
|
150
|
-
*
|
|
151
|
-
* @param {string} note The note to set.
|
|
152
|
-
* @param {boolean} append Whether to append the note to the current sale note.
|
|
153
|
-
* @returns {Promise<void>}
|
|
154
|
-
*/
|
|
155
|
-
setExternalNote(note: string, append?: boolean): Promise<void>;
|
|
156
|
-
/**
|
|
157
|
-
* Set the internal note for the sale.
|
|
158
|
-
*
|
|
159
|
-
* @param {string} note The note to set.
|
|
160
|
-
* @param {boolean} append Whether to append the note to the current sale note.
|
|
161
|
-
* @returns {Promise<void>}
|
|
162
|
-
*/
|
|
163
|
-
setInternalNote(note: string, append?: boolean): Promise<void>;
|
|
164
|
-
/**
|
|
165
|
-
* Set the order reference to the provided string.
|
|
166
|
-
*
|
|
167
|
-
* @param {string} reference
|
|
168
|
-
* @returns {Promise<void>}
|
|
169
|
-
*/
|
|
170
|
-
setOrderReference(reference: string): Promise<void>;
|
|
171
|
-
/**
|
|
172
|
-
* Set the meta data of the sale, this will override the previous meta data.
|
|
173
|
-
*
|
|
174
|
-
* @param metaData
|
|
175
|
-
*/
|
|
176
|
-
setMetaData(metaData: Record<string, unknown>): Promise<void>;
|
|
177
|
-
/**
|
|
178
|
-
* Update a product's details, currently this only updates the top-level meta data
|
|
179
|
-
* @param product
|
|
180
|
-
*/
|
|
181
|
-
updateProduct(product: SaleProduct): Promise<void>;
|
|
182
|
-
}
|