@shopfront/bridge 2.0.0 → 2.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/.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 +481 -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
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
1
|
+
import { Button } from "./Actions/Button.js";
|
|
2
|
+
import { SaleKey } from "./Actions/SaleKey.js";
|
|
3
|
+
import { OrderDetails } from "./APIs/Fulfilment/FulfilmentTypes.js";
|
|
4
|
+
import { InternalMessageSource } from "./APIs/InternalMessages/InternalMessageSource.js";
|
|
5
|
+
import { Sale, ShopfrontSaleState } from "./APIs/Sale/index.js";
|
|
6
|
+
import { AudioPermissionChange } from "./Events/AudioPermissionChange.js";
|
|
7
|
+
import { AudioReady } from "./Events/AudioReady.js";
|
|
8
|
+
import { Callback } from "./Events/Callback.js";
|
|
9
|
+
import { FormatIntegratedProduct, FormattedSaleProduct } from "./Events/FormatIntegratedProduct.js";
|
|
10
|
+
import { FulfilmentCollectOrder } from "./Events/FulfilmentCollectOrder.js";
|
|
11
|
+
import { FulfilmentCompleteOrder } from "./Events/FulfilmentCompleteOrder.js";
|
|
12
|
+
import { FulfilmentGetOrder } from "./Events/FulfilmentGetOrder.js";
|
|
13
|
+
import { FulfilmentOrderApproval } from "./Events/FulfilmentOrderApproval.js";
|
|
14
|
+
import { FulfilmentProcessOrder } from "./Events/FulfilmentProcessOrder.js";
|
|
15
|
+
import { FulfilmentVoidOrder } from "./Events/FulfilmentVoidOrder.js";
|
|
16
|
+
import { GiftCardCodeCheck } from "./Events/GiftCardCodeCheck.js";
|
|
17
|
+
import { InternalPageMessage } from "./Events/InternalPageMessage.js";
|
|
18
|
+
import { PaymentMethodsEnabled } from "./Events/PaymentMethodsEnabled.js";
|
|
19
|
+
import { Ready } from "./Events/Ready.js";
|
|
20
|
+
import { RegisterChanged } from "./Events/RegisterChanged.js";
|
|
21
|
+
import { RequestButtons } from "./Events/RequestButtons.js";
|
|
22
|
+
import { RequestCustomerListOptions, SellScreenCustomerListOption } from "./Events/RequestCustomerListOptions.js";
|
|
23
|
+
import { RequestSaleKeys } from "./Events/RequestSaleKeys.js";
|
|
24
|
+
import { RequestSellScreenOptions, SellScreenOption } from "./Events/RequestSellScreenOptions.js";
|
|
25
|
+
import { RequestSettings } from "./Events/RequestSettings.js";
|
|
26
|
+
import { RequestTableColumns } from "./Events/RequestTableColumns.js";
|
|
27
|
+
import { CompletedSale, SaleComplete } from "./Events/SaleComplete.js";
|
|
28
|
+
import { UIPipeline } from "./Events/UIPipeline.js";
|
|
29
|
+
import { MaybePromise } from "./Utilities/MiscTypes.js";
|
|
30
30
|
export declare enum ToShopfront {
|
|
31
31
|
READY = "READY",
|
|
32
32
|
SERIALIZED = "SERIALIZED",
|
|
@@ -48,6 +48,7 @@ export declare enum ToShopfront {
|
|
|
48
48
|
REDIRECT = "REDIRECT",
|
|
49
49
|
GET_OPTION = "GET_OPTION",
|
|
50
50
|
RESPONSE_UI_PIPELINE = "RESPONSE_UI_PIPELINE",
|
|
51
|
+
RESPONSE_GIFT_CARD_CODE_CHECK = "RESPONSE_GIFT_CARD_CODE_CHECK",
|
|
51
52
|
REQUEST_SECURE_KEY = "REQUEST_SECURE_KEY",
|
|
52
53
|
ROTATE_SIGNING_KEY = "ROTATE_SIGNING_KEY",
|
|
53
54
|
AUDIO_REQUEST_PERMISSION = "AUDIO_REQUEST_PERMISSION",
|
|
@@ -69,9 +70,9 @@ export declare enum ToShopfront {
|
|
|
69
70
|
CREATE_SALE = "CREATE_SALE",
|
|
70
71
|
FULFILMENT_GET_ORDER = "FULFILMENT_GET_ORDER"
|
|
71
72
|
}
|
|
72
|
-
export
|
|
73
|
+
export type SoundEvents = ToShopfront.AUDIO_REQUEST_PERMISSION | ToShopfront.AUDIO_PRELOAD | ToShopfront.AUDIO_PLAY;
|
|
73
74
|
export interface FromShopfrontReturns {
|
|
74
|
-
READY:
|
|
75
|
+
READY: unknown;
|
|
75
76
|
REQUEST_SETTINGS: {
|
|
76
77
|
logo: null | string;
|
|
77
78
|
description: null | string;
|
|
@@ -84,21 +85,17 @@ export interface FromShopfrontReturns {
|
|
|
84
85
|
key: string;
|
|
85
86
|
weight: number;
|
|
86
87
|
}>;
|
|
87
|
-
body: Array<
|
|
88
|
-
|
|
89
|
-
}>;
|
|
90
|
-
footer: {
|
|
91
|
-
[key: string]: string;
|
|
92
|
-
};
|
|
88
|
+
body: Array<Record<string, string>>;
|
|
89
|
+
footer: Record<string, string>;
|
|
93
90
|
};
|
|
94
91
|
REQUEST_SELL_SCREEN_OPTIONS: Array<SellScreenOption>;
|
|
95
|
-
CALLBACK:
|
|
92
|
+
CALLBACK: unknown;
|
|
96
93
|
RESPONSE_CURRENT_SALE: {
|
|
97
94
|
requestId: string;
|
|
98
95
|
saleState: ShopfrontSaleState;
|
|
99
96
|
};
|
|
100
|
-
INTERNAL_PAGE_MESSAGE:
|
|
101
|
-
REGISTER_CHANGED:
|
|
97
|
+
INTERNAL_PAGE_MESSAGE: unknown;
|
|
98
|
+
REGISTER_CHANGED: unknown;
|
|
102
99
|
RESPONSE_LOCATION: {
|
|
103
100
|
requestId: string;
|
|
104
101
|
register: string | null;
|
|
@@ -113,22 +110,26 @@ export interface FromShopfrontReturns {
|
|
|
113
110
|
FORMAT_INTEGRATED_PRODUCT: FormatIntegratedProductEvent;
|
|
114
111
|
REQUEST_CUSTOMER_LIST_OPTIONS: Array<SellScreenCustomerListOption>;
|
|
115
112
|
REQUEST_SALE_KEYS: Array<SaleKey>;
|
|
116
|
-
SALE_COMPLETE:
|
|
113
|
+
SALE_COMPLETE: unknown;
|
|
117
114
|
UI_PIPELINE: Array<UIPipelineResponse>;
|
|
118
115
|
PAYMENT_METHODS_ENABLED: Array<SellScreenPaymentMethod>;
|
|
119
|
-
AUDIO_READY:
|
|
120
|
-
AUDIO_PERMISSION_CHANGE:
|
|
116
|
+
AUDIO_READY: unknown;
|
|
117
|
+
AUDIO_PERMISSION_CHANGE: unknown;
|
|
121
118
|
FULFILMENT_GET_ORDER: OrderDetails;
|
|
122
|
-
FULFILMENT_VOID_ORDER:
|
|
123
|
-
FULFILMENT_PROCESS_ORDER:
|
|
124
|
-
FULFILMENT_ORDER_APPROVAL:
|
|
125
|
-
FULFILMENT_ORDER_COLLECTED:
|
|
126
|
-
FULFILMENT_ORDER_COMPLETED:
|
|
119
|
+
FULFILMENT_VOID_ORDER: unknown;
|
|
120
|
+
FULFILMENT_PROCESS_ORDER: unknown;
|
|
121
|
+
FULFILMENT_ORDER_APPROVAL: unknown;
|
|
122
|
+
FULFILMENT_ORDER_COLLECTED: unknown;
|
|
123
|
+
FULFILMENT_ORDER_COMPLETED: unknown;
|
|
127
124
|
RESPONSE_CREATE_SALE: {
|
|
128
125
|
requestId: string;
|
|
129
126
|
success: boolean;
|
|
130
127
|
message?: string;
|
|
131
128
|
};
|
|
129
|
+
GIFT_CARD_CODE_CHECK: {
|
|
130
|
+
code: string;
|
|
131
|
+
message: string | null;
|
|
132
|
+
};
|
|
132
133
|
}
|
|
133
134
|
export interface InternalPageMessageEvent {
|
|
134
135
|
method: "REQUEST_SETTINGS" | "REQUEST_SELL_SCREEN_OPTIONS" | "EXTERNAL_APPLICATION";
|
|
@@ -141,6 +142,10 @@ export interface RegisterChangedEvent {
|
|
|
141
142
|
outlet: null | string;
|
|
142
143
|
user: null | string;
|
|
143
144
|
}
|
|
145
|
+
export interface GiftCardCodeCheckEvent {
|
|
146
|
+
code: string;
|
|
147
|
+
message: string | null;
|
|
148
|
+
}
|
|
144
149
|
export interface FormatIntegratedProductEvent {
|
|
145
150
|
product: FormattedSaleProduct;
|
|
146
151
|
}
|
|
@@ -158,10 +163,10 @@ export interface FulfilmentApprovalEvent {
|
|
|
158
163
|
id: string;
|
|
159
164
|
approved: boolean;
|
|
160
165
|
}
|
|
161
|
-
export
|
|
166
|
+
export interface UIPipelineResponse {
|
|
162
167
|
name: string;
|
|
163
168
|
content: string;
|
|
164
|
-
}
|
|
169
|
+
}
|
|
165
170
|
export interface UIPipelineBaseContext {
|
|
166
171
|
location: string;
|
|
167
172
|
}
|
|
@@ -205,6 +210,7 @@ export interface FromShopfrontCallbacks {
|
|
|
205
210
|
FULFILMENT_ORDER_APPROVAL: (event: FulfilmentApprovalEvent) => MaybePromise<FromShopfrontReturns["FULFILMENT_ORDER_APPROVAL"]>;
|
|
206
211
|
FULFILMENT_ORDER_COLLECTED: (id: string) => MaybePromise<FromShopfrontReturns["FULFILMENT_ORDER_COLLECTED"]>;
|
|
207
212
|
FULFILMENT_ORDER_COMPLETED: (id: string) => MaybePromise<FromShopfrontReturns["FULFILMENT_ORDER_COMPLETED"]>;
|
|
213
|
+
GIFT_CARD_CODE_CHECK: (event: GiftCardCodeCheckEvent, context: unknown) => MaybePromise<FromShopfrontReturns["GIFT_CARD_CODE_CHECK"]>;
|
|
208
214
|
}
|
|
209
215
|
export interface FromShopfront {
|
|
210
216
|
READY: Ready;
|
|
@@ -229,9 +235,16 @@ export interface FromShopfront {
|
|
|
229
235
|
FULFILMENT_ORDER_APPROVAL: FulfilmentOrderApproval;
|
|
230
236
|
FULFILMENT_ORDER_COLLECTED: FulfilmentCollectOrder;
|
|
231
237
|
FULFILMENT_ORDER_COMPLETED: FulfilmentCompleteOrder;
|
|
238
|
+
GIFT_CARD_CODE_CHECK: GiftCardCodeCheck;
|
|
232
239
|
}
|
|
240
|
+
export type ListenableFromShopfrontEvents = keyof Omit<FromShopfront, "CALLBACK">;
|
|
233
241
|
export declare const directShopfrontEvents: readonly ["SALE_ADD_PRODUCT", "SALE_REMOVE_PRODUCT", "SALE_UPDATE_PRODUCTS", "SALE_CHANGE_QUANTITY", "SALE_ADD_CUSTOMER", "SALE_REMOVE_CUSTOMER", "SALE_CLEAR"];
|
|
234
|
-
|
|
242
|
+
/**
|
|
243
|
+
* Checks whether the event is a direct Shopfront event
|
|
244
|
+
*/
|
|
245
|
+
export declare const isDirectShopfrontEvent: (event: DirectShopfrontEvent | ListenableFromShopfrontEvents) => event is DirectShopfrontEvent;
|
|
246
|
+
export type DirectShopfrontEvent = typeof directShopfrontEvents[number];
|
|
247
|
+
export type DirectShopfrontEventCallback = () => void | Promise<void>;
|
|
235
248
|
export interface FromShopfrontInternal {
|
|
236
249
|
CYCLE_KEY: "CYCLE_KEY";
|
|
237
250
|
LOCATION_CHANGED: "LOCATION_CHANGED";
|
|
@@ -243,5 +256,5 @@ export interface FromShopfrontInternal {
|
|
|
243
256
|
RESPONSE_SECURE_KEY: "RESPONSE_SECURE_KEY";
|
|
244
257
|
RESPONSE_CREATE_SALE: "RESPONSE_CREATE_SALE";
|
|
245
258
|
}
|
|
246
|
-
export
|
|
247
|
-
export
|
|
259
|
+
export type SellScreenActionMode = "search" | "keys" | "held-sales" | "payment" | "customers" | "promotions" | "show-backorders" | "fulfilment-orders";
|
|
260
|
+
export type SellScreenSummaryMode = "transaction" | "payments" | "receipts";
|
package/lib/ApplicationEvents.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.directShopfrontEvents = exports.ToShopfront = void 0;
|
|
4
|
-
var ToShopfront;
|
|
1
|
+
export var ToShopfront;
|
|
5
2
|
(function (ToShopfront) {
|
|
6
3
|
ToShopfront["READY"] = "READY";
|
|
7
4
|
ToShopfront["SERIALIZED"] = "SERIALIZED";
|
|
@@ -23,6 +20,7 @@ var ToShopfront;
|
|
|
23
20
|
ToShopfront["REDIRECT"] = "REDIRECT";
|
|
24
21
|
ToShopfront["GET_OPTION"] = "GET_OPTION";
|
|
25
22
|
ToShopfront["RESPONSE_UI_PIPELINE"] = "RESPONSE_UI_PIPELINE";
|
|
23
|
+
ToShopfront["RESPONSE_GIFT_CARD_CODE_CHECK"] = "RESPONSE_GIFT_CARD_CODE_CHECK";
|
|
26
24
|
ToShopfront["REQUEST_SECURE_KEY"] = "REQUEST_SECURE_KEY";
|
|
27
25
|
ToShopfront["ROTATE_SIGNING_KEY"] = "ROTATE_SIGNING_KEY";
|
|
28
26
|
// Audio Events
|
|
@@ -49,8 +47,8 @@ var ToShopfront;
|
|
|
49
47
|
ToShopfront["CREATE_SALE"] = "CREATE_SALE";
|
|
50
48
|
// Fulfilment Response Events
|
|
51
49
|
ToShopfront["FULFILMENT_GET_ORDER"] = "FULFILMENT_GET_ORDER";
|
|
52
|
-
})(ToShopfront
|
|
53
|
-
|
|
50
|
+
})(ToShopfront || (ToShopfront = {}));
|
|
51
|
+
export const directShopfrontEvents = [
|
|
54
52
|
"SALE_ADD_PRODUCT",
|
|
55
53
|
"SALE_REMOVE_PRODUCT",
|
|
56
54
|
"SALE_UPDATE_PRODUCTS",
|
|
@@ -59,3 +57,9 @@ exports.directShopfrontEvents = [
|
|
|
59
57
|
"SALE_REMOVE_CUSTOMER",
|
|
60
58
|
"SALE_CLEAR",
|
|
61
59
|
];
|
|
60
|
+
/**
|
|
61
|
+
* Checks whether the event is a direct Shopfront event
|
|
62
|
+
*/
|
|
63
|
+
export const isDirectShopfrontEvent = (event) => {
|
|
64
|
+
return directShopfrontEvents.includes(event);
|
|
65
|
+
};
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { BaseDatabase } from "./APIs/Database/BaseDatabase.js";
|
|
2
|
+
import { BaseCurrentSale } from "./APIs/Sale/BaseCurrentSale.js";
|
|
3
|
+
import { Sale } from "./APIs/Sale/index.js";
|
|
4
|
+
import { DirectShopfrontEvent, DirectShopfrontEventCallback, FromShopfront, FromShopfrontCallbacks, FromShopfrontInternal, ListenableFromShopfrontEvents, RegisterChangedEvent, SellScreenActionMode, SellScreenSummaryMode, SoundEvents } from "./ApplicationEvents.js";
|
|
5
|
+
import { BaseBridge } from "./BaseBridge.js";
|
|
6
|
+
import { Serializable } from "./Common/Serializable.js";
|
|
7
|
+
import { BaseEmitableEvent } from "./EmitableEvents/BaseEmitableEvent.js";
|
|
8
|
+
import { BaseEvent } from "./Events/BaseEvent.js";
|
|
9
|
+
import { MaybePromise } from "./Utilities/MiscTypes.js";
|
|
10
|
+
export interface ShopfrontResponse {
|
|
11
|
+
success: boolean;
|
|
12
|
+
message?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface ShopfrontEmbeddedVerificationToken {
|
|
15
|
+
auth: string;
|
|
16
|
+
id: string;
|
|
17
|
+
app: string;
|
|
18
|
+
user: string;
|
|
19
|
+
url: {
|
|
20
|
+
raw: string;
|
|
21
|
+
loaded: string;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export interface ShopfrontEmbeddedTokenError {
|
|
25
|
+
error: boolean;
|
|
26
|
+
type: string;
|
|
27
|
+
}
|
|
28
|
+
export declare class ShopfrontTokenDecodingError extends Error {
|
|
29
|
+
}
|
|
30
|
+
export declare class ShopfrontTokenRequestError extends Error {
|
|
31
|
+
}
|
|
32
|
+
export declare abstract class BaseApplication {
|
|
33
|
+
protected bridge: BaseBridge;
|
|
34
|
+
protected isReady: boolean;
|
|
35
|
+
protected key: string;
|
|
36
|
+
protected register: string | null;
|
|
37
|
+
protected outlet: string | null;
|
|
38
|
+
protected user: string | null;
|
|
39
|
+
protected signingKey: CryptoKeyPair | undefined;
|
|
40
|
+
protected listeners: {
|
|
41
|
+
[key in ListenableFromShopfrontEvents]: Map<(...args: Array<unknown>) => void, FromShopfront[key] & BaseEvent>;
|
|
42
|
+
};
|
|
43
|
+
protected directListeners: Partial<Record<DirectShopfrontEvent, Set<DirectShopfrontEventCallback>>>;
|
|
44
|
+
database: BaseDatabase;
|
|
45
|
+
protected constructor(bridge: BaseBridge, database: BaseDatabase);
|
|
46
|
+
/**
|
|
47
|
+
* Destroy the bridge instance
|
|
48
|
+
*/
|
|
49
|
+
abstract destroy(): void;
|
|
50
|
+
/**
|
|
51
|
+
* Handles an application event
|
|
52
|
+
*/
|
|
53
|
+
protected abstract handleEvent(event: keyof FromShopfront | keyof FromShopfrontInternal, data: Record<string, unknown>, id: string): void;
|
|
54
|
+
/**
|
|
55
|
+
* Calls any registered listeners for the received event
|
|
56
|
+
*/
|
|
57
|
+
protected abstract emit(event: ListenableFromShopfrontEvents | DirectShopfrontEvent, data: Record<string, unknown>, id: string): MaybePromise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Register a listener for a Shopfront event
|
|
60
|
+
*/
|
|
61
|
+
abstract addEventListener<E extends ListenableFromShopfrontEvents>(event: E, callback: FromShopfrontCallbacks[E]): void;
|
|
62
|
+
/**
|
|
63
|
+
* Register a listener for a Shopfront event
|
|
64
|
+
*/
|
|
65
|
+
abstract addEventListener(event: DirectShopfrontEvent, callback: DirectShopfrontEventCallback): void;
|
|
66
|
+
/**
|
|
67
|
+
* Register a listener for a Shopfront event
|
|
68
|
+
*/
|
|
69
|
+
abstract addEventListener(event: ListenableFromShopfrontEvents | DirectShopfrontEvent, callback: (...args: Array<unknown>) => void): void;
|
|
70
|
+
/**
|
|
71
|
+
* Removed a registered listener for a Shopfront event
|
|
72
|
+
*/
|
|
73
|
+
abstract removeEventListener<E extends keyof FromShopfrontCallbacks>(event: E, callback: FromShopfrontCallbacks[E]): void;
|
|
74
|
+
/**
|
|
75
|
+
* Removed a registered listener for a Shopfront event
|
|
76
|
+
*/
|
|
77
|
+
abstract removeEventListener<D>(event: DirectShopfrontEvent, callback: (event: D) => MaybePromise<void>): void;
|
|
78
|
+
/**
|
|
79
|
+
* Removed a registered listener for a Shopfront event
|
|
80
|
+
*/
|
|
81
|
+
abstract removeEventListener(event: ListenableFromShopfrontEvents | DirectShopfrontEvent, callback: (...args: Array<unknown>) => MaybePromise<void>): void;
|
|
82
|
+
/**
|
|
83
|
+
* Send data to Shopfront
|
|
84
|
+
*/
|
|
85
|
+
abstract send(item: BaseEmitableEvent<unknown> | Serializable<unknown>): void;
|
|
86
|
+
/**
|
|
87
|
+
* Requests permission from the user to download the specified file
|
|
88
|
+
*/
|
|
89
|
+
abstract download(file: string): void;
|
|
90
|
+
/**
|
|
91
|
+
* Redirects the user to the specified location.
|
|
92
|
+
* If `externalRedirect` is `true`, the user is prompted to confirm the redirect.
|
|
93
|
+
*/
|
|
94
|
+
abstract redirect(toLocation: string, externalRedirect: boolean): void;
|
|
95
|
+
/**
|
|
96
|
+
* Shows a loading screen in Shopfront
|
|
97
|
+
*/
|
|
98
|
+
abstract load(): void;
|
|
99
|
+
protected abstract handleEventCallback(data: {
|
|
100
|
+
id?: string;
|
|
101
|
+
data: unknown;
|
|
102
|
+
}): void;
|
|
103
|
+
protected abstract handleLocationChanged(data: RegisterChangedEvent): void;
|
|
104
|
+
/**
|
|
105
|
+
* Retrieves the cached authentication key
|
|
106
|
+
*/
|
|
107
|
+
abstract getAuthenticationKey(): string;
|
|
108
|
+
/**
|
|
109
|
+
* Get the current sale on the sell screen, if the current device is not a register
|
|
110
|
+
* then this will return false.
|
|
111
|
+
*/
|
|
112
|
+
abstract getCurrentSale(): Promise<BaseCurrentSale | false>;
|
|
113
|
+
/**
|
|
114
|
+
* Send the sale to be created on shopfront.
|
|
115
|
+
*/
|
|
116
|
+
abstract createSale(sale: Sale): Promise<ShopfrontResponse>;
|
|
117
|
+
/**
|
|
118
|
+
* Retrieves the current location data from Shopfront
|
|
119
|
+
*/
|
|
120
|
+
abstract getLocation(): Promise<{
|
|
121
|
+
register: string | null;
|
|
122
|
+
outlet: string | null;
|
|
123
|
+
user: string | null;
|
|
124
|
+
}>;
|
|
125
|
+
/**
|
|
126
|
+
* Prints the provided content as a receipt
|
|
127
|
+
*/
|
|
128
|
+
abstract printReceipt(content: string): void;
|
|
129
|
+
/**
|
|
130
|
+
* Changes the display mode of the sell screen's `action` container
|
|
131
|
+
*/
|
|
132
|
+
abstract changeSellScreenActionMode(mode: SellScreenActionMode): void;
|
|
133
|
+
/**
|
|
134
|
+
* Changes the display mode of the sell screen's 'summary' container
|
|
135
|
+
*/
|
|
136
|
+
abstract changeSellScreenSummaryMode(mode: SellScreenSummaryMode): void;
|
|
137
|
+
/**
|
|
138
|
+
* Sends an audio request to Shopfront
|
|
139
|
+
*/
|
|
140
|
+
protected abstract sendAudioRequest(type: SoundEvents, data?: unknown): Promise<ShopfrontResponse>;
|
|
141
|
+
/**
|
|
142
|
+
* Requests permission from the user to be able to play audio
|
|
143
|
+
*/
|
|
144
|
+
abstract requestAudioPermission(): Promise<ShopfrontResponse>;
|
|
145
|
+
/**
|
|
146
|
+
* Requests Shopfront to preload audio so that it can be pre-cached before being played
|
|
147
|
+
*/
|
|
148
|
+
abstract audioPreload(url: string): Promise<ShopfrontResponse>;
|
|
149
|
+
/**
|
|
150
|
+
* Attempts to play the provided audio in Shopfront
|
|
151
|
+
*/
|
|
152
|
+
abstract audioPlay(url: string): Promise<ShopfrontResponse>;
|
|
153
|
+
/**
|
|
154
|
+
* Retrieve the value of the specified option from Shopfront
|
|
155
|
+
*/
|
|
156
|
+
abstract getOption<TValueType>(option: string, defaultValue: TValueType): Promise<TValueType>;
|
|
157
|
+
/**
|
|
158
|
+
* Retrieves an embedded token from Shopfront that can be used to validate server requests
|
|
159
|
+
*/
|
|
160
|
+
abstract getToken(returnTokenObject: true): Promise<ShopfrontEmbeddedVerificationToken>;
|
|
161
|
+
/**
|
|
162
|
+
* Retrieves an embedded token from Shopfront that can be used to validate server requests
|
|
163
|
+
*/
|
|
164
|
+
abstract getToken(returnTokenObject?: false): Promise<string>;
|
|
165
|
+
/**
|
|
166
|
+
* Retrieves an embedded token from Shopfront that can be used to validate server requests
|
|
167
|
+
*/
|
|
168
|
+
abstract getToken(returnTokenObject?: boolean): Promise<string | ShopfrontEmbeddedVerificationToken>;
|
|
169
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export class ShopfrontTokenDecodingError extends Error {
|
|
2
|
+
}
|
|
3
|
+
export class ShopfrontTokenRequestError extends Error {
|
|
4
|
+
}
|
|
5
|
+
export class BaseApplication {
|
|
6
|
+
constructor(bridge, database) {
|
|
7
|
+
this.listeners = {
|
|
8
|
+
READY: new Map(),
|
|
9
|
+
REQUEST_SETTINGS: new Map(),
|
|
10
|
+
REQUEST_BUTTONS: new Map(),
|
|
11
|
+
REQUEST_TABLE_COLUMNS: new Map(),
|
|
12
|
+
REQUEST_SELL_SCREEN_OPTIONS: new Map(),
|
|
13
|
+
INTERNAL_PAGE_MESSAGE: new Map(),
|
|
14
|
+
REGISTER_CHANGED: new Map(),
|
|
15
|
+
FORMAT_INTEGRATED_PRODUCT: new Map(),
|
|
16
|
+
REQUEST_CUSTOMER_LIST_OPTIONS: new Map(),
|
|
17
|
+
REQUEST_SALE_KEYS: new Map(),
|
|
18
|
+
SALE_COMPLETE: new Map(),
|
|
19
|
+
UI_PIPELINE: new Map(),
|
|
20
|
+
PAYMENT_METHODS_ENABLED: new Map(),
|
|
21
|
+
AUDIO_PERMISSION_CHANGE: new Map(),
|
|
22
|
+
AUDIO_READY: new Map(),
|
|
23
|
+
FULFILMENT_GET_ORDER: new Map(),
|
|
24
|
+
FULFILMENT_PROCESS_ORDER: new Map(),
|
|
25
|
+
FULFILMENT_VOID_ORDER: new Map(),
|
|
26
|
+
FULFILMENT_ORDER_APPROVAL: new Map(),
|
|
27
|
+
FULFILMENT_ORDER_COLLECTED: new Map(),
|
|
28
|
+
FULFILMENT_ORDER_COMPLETED: new Map(),
|
|
29
|
+
GIFT_CARD_CODE_CHECK: new Map(),
|
|
30
|
+
};
|
|
31
|
+
this.directListeners = {};
|
|
32
|
+
this.bridge = bridge;
|
|
33
|
+
this.isReady = false;
|
|
34
|
+
this.key = "";
|
|
35
|
+
this.register = null;
|
|
36
|
+
this.outlet = null;
|
|
37
|
+
this.user = null;
|
|
38
|
+
this.database = database;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as ApplicationEvents from "./ApplicationEvents.js";
|
|
2
|
+
import { ApplicationEventListener } from "./Bridge.js";
|
|
3
|
+
export declare abstract class BaseBridge {
|
|
4
|
+
key: string;
|
|
5
|
+
url: URL;
|
|
6
|
+
protected listeners: Array<ApplicationEventListener>;
|
|
7
|
+
protected hasListener: boolean;
|
|
8
|
+
protected constructor(key: string, url: string);
|
|
9
|
+
/**
|
|
10
|
+
* Destroys the Bridge by unregistering all listeners
|
|
11
|
+
*/
|
|
12
|
+
abstract destroy(): void;
|
|
13
|
+
/**
|
|
14
|
+
* Register the event listener for any window messages
|
|
15
|
+
*/
|
|
16
|
+
protected abstract registerListeners(): void;
|
|
17
|
+
/**
|
|
18
|
+
* Removes the window message event listener
|
|
19
|
+
*/
|
|
20
|
+
protected abstract unregisterListeners(): void;
|
|
21
|
+
/**
|
|
22
|
+
* Sends an event to Shopfront
|
|
23
|
+
*/
|
|
24
|
+
abstract sendMessage(type: ApplicationEvents.ToShopfront, data?: unknown, id?: string): void;
|
|
25
|
+
/**
|
|
26
|
+
* Adds a listener for a Shopfront event
|
|
27
|
+
*/
|
|
28
|
+
abstract addEventListener(listener: ApplicationEventListener): void;
|
|
29
|
+
/**
|
|
30
|
+
* Removes a listener for a Shopfront event
|
|
31
|
+
*/
|
|
32
|
+
abstract removeEventListener(listener: ApplicationEventListener): void;
|
|
33
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as ApplicationEvents from "./ApplicationEvents.js";
|
|
2
|
+
export class BaseBridge {
|
|
3
|
+
constructor(key, url) {
|
|
4
|
+
this.listeners = [];
|
|
5
|
+
this.hasListener = false;
|
|
6
|
+
this.key = key;
|
|
7
|
+
if (url.split(".").length === 1) {
|
|
8
|
+
this.url = new URL(`https://${url}.onshopfront.com`);
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
this.url = new URL(url);
|
|
12
|
+
}
|
|
13
|
+
this.registerListeners();
|
|
14
|
+
this.sendMessage(ApplicationEvents.ToShopfront.READY);
|
|
15
|
+
}
|
|
16
|
+
}
|
package/lib/Bridge.d.ts
CHANGED
|
@@ -1,26 +1,63 @@
|
|
|
1
|
-
import { Application } from "./Application";
|
|
2
|
-
import * as ApplicationEvents from "./ApplicationEvents";
|
|
1
|
+
import { Application } from "./Application.js";
|
|
2
|
+
import * as ApplicationEvents from "./ApplicationEvents.js";
|
|
3
|
+
import { BaseBridge } from "./BaseBridge.js";
|
|
3
4
|
interface ApplicationOptions {
|
|
4
5
|
id: string;
|
|
5
6
|
vendor: string;
|
|
6
7
|
}
|
|
7
|
-
export
|
|
8
|
-
|
|
8
|
+
export type ApplicationEventListener = (event: keyof ApplicationEvents.FromShopfront | keyof ApplicationEvents.FromShopfrontInternal, data: Record<string, unknown>, id: string) => void;
|
|
9
|
+
export interface BridgeInterface {
|
|
10
|
+
/**
|
|
11
|
+
* Destroys the Bridge by unregistering all listeners
|
|
12
|
+
*/
|
|
13
|
+
destroy(): void;
|
|
14
|
+
/**
|
|
15
|
+
* Sends an event to Shopfront
|
|
16
|
+
*/
|
|
17
|
+
sendMessage(type: ApplicationEvents.ToShopfront, data?: unknown, id?: string): void;
|
|
18
|
+
/**
|
|
19
|
+
* Adds a listener for a Shopfront event
|
|
20
|
+
*/
|
|
21
|
+
addEventListener(listener: ApplicationEventListener): void;
|
|
22
|
+
/**
|
|
23
|
+
* Removes a listener for a Shopfront event
|
|
24
|
+
*/
|
|
25
|
+
removeEventListener(listener: ApplicationEventListener): void;
|
|
9
26
|
}
|
|
10
|
-
export declare class Bridge {
|
|
27
|
+
export declare class Bridge extends BaseBridge {
|
|
28
|
+
/**
|
|
29
|
+
* A static method for instantiating an Application
|
|
30
|
+
*/
|
|
11
31
|
static createApplication(options: ApplicationOptions): Application;
|
|
12
|
-
key: string;
|
|
13
|
-
url: URL;
|
|
14
|
-
protected listeners: Array<ApplicationEventListener>;
|
|
15
|
-
protected hasListener: boolean;
|
|
16
32
|
protected target: Window | null;
|
|
17
33
|
constructor(key: string, url: string);
|
|
34
|
+
/**
|
|
35
|
+
* @inheritDoc
|
|
36
|
+
*/
|
|
18
37
|
destroy(): void;
|
|
38
|
+
/**
|
|
39
|
+
* @inheritDoc
|
|
40
|
+
*/
|
|
19
41
|
protected registerListeners(): void;
|
|
42
|
+
/**
|
|
43
|
+
* @inheritDoc
|
|
44
|
+
*/
|
|
20
45
|
protected unregisterListeners(): void;
|
|
46
|
+
/**
|
|
47
|
+
* @inheritDoc
|
|
48
|
+
*/
|
|
21
49
|
protected handleMessage: (event: MessageEvent) => void;
|
|
50
|
+
/**
|
|
51
|
+
* @inheritDoc
|
|
52
|
+
*/
|
|
22
53
|
sendMessage(type: ApplicationEvents.ToShopfront, data?: unknown, id?: string): void;
|
|
54
|
+
/**
|
|
55
|
+
* @inheritDoc
|
|
56
|
+
*/
|
|
23
57
|
addEventListener(listener: ApplicationEventListener): void;
|
|
58
|
+
/**
|
|
59
|
+
* @inheritDoc
|
|
60
|
+
*/
|
|
24
61
|
removeEventListener(listener: ApplicationEventListener): void;
|
|
25
62
|
}
|
|
26
63
|
export {};
|