@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.
Files changed (244) hide show
  1. package/.idea/codeStyles/Project.xml +10 -0
  2. package/.idea/codeStyles/codeStyleConfig.xml +5 -0
  3. package/.idea/git_toolbox_blame.xml +6 -0
  4. package/.idea/git_toolbox_prj.xml +15 -0
  5. package/.idea/inspectionProfiles/Project_Default.xml +5 -0
  6. package/.idea/jsLinters/eslint.xml +6 -0
  7. package/.idea/modules.xml +1 -1
  8. package/.idea/php.xml +15 -0
  9. package/lib/APIs/Database/BaseDatabase.d.ts +28 -0
  10. package/lib/APIs/Database/BaseDatabase.js +5 -0
  11. package/lib/APIs/Database/Database.d.ts +19 -7
  12. package/lib/APIs/Database/Database.js +22 -12
  13. package/lib/APIs/Database/types/BaseBarcodeTemplateRepository.d.ts +8 -0
  14. package/lib/APIs/Database/types/BaseBarcodeTemplateRepository.js +1 -0
  15. package/lib/APIs/Database/types/BaseClassificationRepository.d.ts +11 -0
  16. package/lib/APIs/Database/types/BaseClassificationRepository.js +1 -0
  17. package/lib/APIs/Database/types/BaseCustomerDisplayRepository.d.ts +10 -0
  18. package/lib/APIs/Database/types/BaseCustomerDisplayRepository.js +1 -0
  19. package/lib/APIs/Database/types/BaseCustomerGroupRepository.d.ts +24 -0
  20. package/lib/APIs/Database/types/BaseCustomerGroupRepository.js +1 -0
  21. package/lib/APIs/Database/types/BaseCustomerRepository.d.ts +76 -0
  22. package/lib/APIs/Database/types/BaseCustomerRepository.js +1 -0
  23. package/lib/APIs/Database/types/BaseEnterpriseRepository.d.ts +8 -0
  24. package/lib/APIs/Database/types/BaseEnterpriseRepository.js +1 -0
  25. package/lib/APIs/Database/types/BaseGiftCardRepository.d.ts +18 -0
  26. package/lib/APIs/Database/types/BaseGiftCardRepository.js +1 -0
  27. package/lib/APIs/Database/types/BaseKitchenOrderRepository.d.ts +41 -0
  28. package/lib/APIs/Database/types/BaseKitchenOrderRepository.js +1 -0
  29. package/lib/APIs/Database/types/BaseKitchenScreenRepository.d.ts +16 -0
  30. package/lib/APIs/Database/types/BaseKitchenScreenRepository.js +1 -0
  31. package/lib/APIs/Database/types/BaseLockedResourceRepository.d.ts +12 -0
  32. package/lib/APIs/Database/types/BaseLockedResourceRepository.js +1 -0
  33. package/lib/APIs/Database/types/BaseLoyaltyRepository.d.ts +16 -0
  34. package/lib/APIs/Database/types/BaseLoyaltyRepository.js +1 -0
  35. package/lib/APIs/Database/types/BaseMovementRepository.d.ts +16 -0
  36. package/lib/APIs/Database/types/BaseMovementRepository.js +1 -0
  37. package/lib/APIs/Database/types/BaseOutletRepository.d.ts +19 -0
  38. package/lib/APIs/Database/types/BaseOutletRepository.js +1 -0
  39. package/lib/APIs/Database/types/BasePaymentMethodRepository.d.ts +27 -0
  40. package/lib/APIs/Database/types/BasePaymentMethodRepository.js +1 -0
  41. package/lib/APIs/Database/types/BasePriceListRepository.d.ts +40 -0
  42. package/lib/APIs/Database/types/BasePriceListRepository.js +1 -0
  43. package/lib/APIs/Database/types/BasePriceSetRepository.d.ts +6 -0
  44. package/lib/APIs/Database/types/BasePriceSetRepository.js +1 -0
  45. package/lib/APIs/Database/types/BaseProductRepository.d.ts +160 -0
  46. package/lib/APIs/Database/types/BaseProductRepository.js +1 -0
  47. package/lib/APIs/Database/types/BasePromotionCategoryRepository.d.ts +10 -0
  48. package/lib/APIs/Database/types/BasePromotionCategoryRepository.js +1 -0
  49. package/lib/APIs/Database/types/BasePromotionRepository.d.ts +72 -0
  50. package/lib/APIs/Database/types/BasePromotionRepository.js +1 -0
  51. package/lib/APIs/Database/types/BaseReceiptRepository.d.ts +31 -0
  52. package/lib/APIs/Database/types/BaseReceiptRepository.js +1 -0
  53. package/lib/APIs/Database/types/BaseRegisterRepository.d.ts +56 -0
  54. package/lib/APIs/Database/types/BaseRegisterRepository.js +1 -0
  55. package/lib/APIs/Database/types/BaseRepository.d.ts +41 -0
  56. package/lib/APIs/Database/types/BaseRepository.js +1 -0
  57. package/lib/APIs/Database/types/BaseSalesKeyRepository.d.ts +37 -0
  58. package/lib/APIs/Database/types/BaseSalesKeyRepository.js +1 -0
  59. package/lib/APIs/Database/types/BaseSalesRepository.d.ts +123 -0
  60. package/lib/APIs/Database/types/BaseSalesRepository.js +1 -0
  61. package/lib/APIs/Database/types/BaseSearchableRepository.d.ts +8 -0
  62. package/lib/APIs/Database/types/BaseSearchableRepository.js +1 -0
  63. package/lib/APIs/Database/types/BaseStocktakeAccumulatedRepository.d.ts +16 -0
  64. package/lib/APIs/Database/types/BaseStocktakeAccumulatedRepository.js +1 -0
  65. package/lib/APIs/Database/types/BaseStocktakeRepository.d.ts +8 -0
  66. package/lib/APIs/Database/types/BaseStocktakeRepository.js +1 -0
  67. package/lib/APIs/Database/types/BaseStocktakeScannedRepository.d.ts +24 -0
  68. package/lib/APIs/Database/types/BaseStocktakeScannedRepository.js +1 -0
  69. package/lib/APIs/Database/types/BaseSupplierRepository.d.ts +35 -0
  70. package/lib/APIs/Database/types/BaseSupplierRepository.js +1 -0
  71. package/lib/APIs/Database/types/BaseTakingsRepository.d.ts +13 -0
  72. package/lib/APIs/Database/types/BaseTakingsRepository.js +1 -0
  73. package/lib/APIs/Database/types/BaseTaxRateRepository.d.ts +9 -0
  74. package/lib/APIs/Database/types/BaseTaxRateRepository.js +1 -0
  75. package/lib/APIs/Database/types/BaseTransfereeRepository.d.ts +12 -0
  76. package/lib/APIs/Database/types/BaseTransfereeRepository.js +1 -0
  77. package/lib/APIs/Database/types/BaseVendorConnectionRepository.d.ts +7 -0
  78. package/lib/APIs/Database/types/BaseVendorConnectionRepository.js +1 -0
  79. package/lib/APIs/Database/types/DataSourceTables.d.ts +61 -0
  80. package/lib/APIs/Database/types/DataSourceTables.js +1 -0
  81. package/lib/APIs/Fulfilment/FulfilmentTypes.d.ts +2 -2
  82. package/lib/APIs/Fulfilment/FulfilmentTypes.js +1 -2
  83. package/lib/APIs/InternalMessages/InternalMessageSource.d.ts +6 -3
  84. package/lib/APIs/InternalMessages/InternalMessageSource.js +6 -7
  85. package/lib/APIs/Sale/BaseCurrentSale.d.ts +83 -0
  86. package/lib/APIs/Sale/BaseCurrentSale.js +13 -0
  87. package/lib/APIs/Sale/BaseSale.d.ts +3 -38
  88. package/lib/APIs/Sale/BaseSale.js +1 -40
  89. package/lib/APIs/Sale/CurrentSale.d.ts +19 -84
  90. package/lib/APIs/Sale/CurrentSale.js +32 -102
  91. package/lib/APIs/Sale/Exceptions.d.ts +3 -0
  92. package/lib/APIs/Sale/Exceptions.js +7 -7
  93. package/lib/APIs/Sale/Sale.d.ts +39 -7
  94. package/lib/APIs/Sale/Sale.js +41 -13
  95. package/lib/APIs/Sale/SaleCustomer.d.ts +0 -2
  96. package/lib/APIs/Sale/SaleCustomer.js +1 -7
  97. package/lib/APIs/Sale/SalePayment.d.ts +3 -22
  98. package/lib/APIs/Sale/SalePayment.js +7 -33
  99. package/lib/APIs/Sale/SaleProduct.d.ts +6 -46
  100. package/lib/APIs/Sale/SaleProduct.js +6 -53
  101. package/lib/APIs/Sale/ShopfrontSaleState.d.ts +7 -9
  102. package/lib/APIs/Sale/ShopfrontSaleState.js +1 -2
  103. package/lib/APIs/Sale/index.d.ts +9 -9
  104. package/lib/APIs/Sale/index.js +7 -39
  105. package/lib/Actions/BaseAction.d.ts +21 -5
  106. package/lib/Actions/BaseAction.js +155 -97
  107. package/lib/Actions/Button.d.ts +2 -2
  108. package/lib/Actions/Button.js +3 -7
  109. package/lib/Actions/CustomerListOption.d.ts +2 -2
  110. package/lib/Actions/CustomerListOption.js +2 -6
  111. package/lib/Actions/Dialog.d.ts +4 -4
  112. package/lib/Actions/Dialog.js +2 -6
  113. package/lib/Actions/Redirect.d.ts +2 -2
  114. package/lib/Actions/Redirect.js +7 -9
  115. package/lib/Actions/SaleKey.d.ts +2 -2
  116. package/lib/Actions/SaleKey.js +3 -7
  117. package/lib/Actions/SaleUpdate.d.ts +3 -3
  118. package/lib/Actions/SaleUpdate.js +3 -7
  119. package/lib/Actions/Toast.d.ts +3 -3
  120. package/lib/Actions/Toast.js +2 -6
  121. package/lib/Application.d.ts +114 -78
  122. package/lib/Application.js +207 -160
  123. package/lib/ApplicationEvents.d.ts +66 -53
  124. package/lib/ApplicationEvents.js +10 -6
  125. package/lib/BaseApplication.d.ts +169 -0
  126. package/lib/BaseApplication.js +40 -0
  127. package/lib/BaseBridge.d.ts +33 -0
  128. package/lib/BaseBridge.js +16 -0
  129. package/lib/Bridge.d.ts +46 -9
  130. package/lib/Bridge.js +42 -54
  131. package/lib/Common/EventEmitter.d.ts +10 -1
  132. package/lib/Common/EventEmitter.js +10 -5
  133. package/lib/Common/Serializable.d.ts +8 -6
  134. package/lib/Common/Serializable.js +1 -2
  135. package/lib/EmitableEvents/BaseEmitableEvent.d.ts +7 -1
  136. package/lib/EmitableEvents/BaseEmitableEvent.js +7 -5
  137. package/lib/EmitableEvents/Fulfilment/Options.d.ts +1 -1
  138. package/lib/EmitableEvents/Fulfilment/Options.js +4 -8
  139. package/lib/EmitableEvents/Fulfilment/OrderCancel.d.ts +1 -1
  140. package/lib/EmitableEvents/Fulfilment/OrderCancel.js +4 -8
  141. package/lib/EmitableEvents/Fulfilment/OrderCreate.d.ts +2 -2
  142. package/lib/EmitableEvents/Fulfilment/OrderCreate.js +4 -8
  143. package/lib/EmitableEvents/Fulfilment/OrderUpdate.d.ts +2 -2
  144. package/lib/EmitableEvents/Fulfilment/OrderUpdate.js +4 -8
  145. package/lib/EmitableEvents/Fulfilment/OrdersSync.d.ts +2 -2
  146. package/lib/EmitableEvents/Fulfilment/OrdersSync.js +4 -8
  147. package/lib/EmitableEvents/Fulfilment/RegisterIntent.d.ts +2 -2
  148. package/lib/EmitableEvents/Fulfilment/RegisterIntent.js +4 -8
  149. package/lib/EmitableEvents/Fulfilment/index.d.ts +7 -7
  150. package/lib/EmitableEvents/Fulfilment/index.js +6 -15
  151. package/lib/EmitableEvents/InternalMessage.d.ts +2 -2
  152. package/lib/EmitableEvents/InternalMessage.js +4 -8
  153. package/lib/EmitableEvents/SellScreenOption.d.ts +2 -2
  154. package/lib/EmitableEvents/SellScreenOption.js +7 -11
  155. package/lib/EmitableEvents/SellScreenPromotionApplicable.d.ts +1 -1
  156. package/lib/EmitableEvents/SellScreenPromotionApplicable.js +4 -8
  157. package/lib/EmitableEvents/TableUpdate.d.ts +2 -2
  158. package/lib/EmitableEvents/TableUpdate.js +4 -8
  159. package/lib/Events/AudioPermissionChange.d.ts +5 -2
  160. package/lib/Events/AudioPermissionChange.js +6 -7
  161. package/lib/Events/AudioReady.d.ts +5 -2
  162. package/lib/Events/AudioReady.js +6 -7
  163. package/lib/Events/BaseEvent.d.ts +8 -3
  164. package/lib/Events/BaseEvent.js +1 -6
  165. package/lib/Events/Callback.d.ts +5 -2
  166. package/lib/Events/Callback.js +5 -6
  167. package/lib/Events/FormatIntegratedProduct.d.ts +27 -32
  168. package/lib/Events/FormatIntegratedProduct.js +12 -9
  169. package/lib/Events/FulfilmentCollectOrder.d.ts +5 -2
  170. package/lib/Events/FulfilmentCollectOrder.js +5 -6
  171. package/lib/Events/FulfilmentCompleteOrder.d.ts +5 -2
  172. package/lib/Events/FulfilmentCompleteOrder.js +5 -6
  173. package/lib/Events/FulfilmentGetOrder.d.ts +12 -6
  174. package/lib/Events/FulfilmentGetOrder.js +10 -8
  175. package/lib/Events/FulfilmentOrderApproval.d.ts +5 -2
  176. package/lib/Events/FulfilmentOrderApproval.js +5 -6
  177. package/lib/Events/FulfilmentProcessOrder.d.ts +12 -10
  178. package/lib/Events/FulfilmentProcessOrder.js +7 -8
  179. package/lib/Events/FulfilmentVoidOrder.d.ts +5 -2
  180. package/lib/Events/FulfilmentVoidOrder.js +5 -6
  181. package/lib/Events/GiftCardCodeCheck.d.ts +19 -0
  182. package/lib/Events/GiftCardCodeCheck.js +23 -0
  183. package/lib/Events/InternalPageMessage.d.ts +10 -4
  184. package/lib/Events/InternalPageMessage.js +12 -10
  185. package/lib/Events/PaymentMethodsEnabled.d.ts +16 -11
  186. package/lib/Events/PaymentMethodsEnabled.js +10 -8
  187. package/lib/Events/Ready.d.ts +12 -7
  188. package/lib/Events/Ready.js +5 -6
  189. package/lib/Events/RegisterChanged.d.ts +12 -6
  190. package/lib/Events/RegisterChanged.js +6 -7
  191. package/lib/Events/RequestButtons.d.ts +17 -12
  192. package/lib/Events/RequestButtons.js +13 -11
  193. package/lib/Events/RequestCustomerListOptions.d.ts +11 -5
  194. package/lib/Events/RequestCustomerListOptions.js +12 -11
  195. package/lib/Events/RequestSaleKeys.d.ts +12 -6
  196. package/lib/Events/RequestSaleKeys.js +13 -11
  197. package/lib/Events/RequestSellScreenOptions.d.ts +18 -5
  198. package/lib/Events/RequestSellScreenOptions.js +17 -9
  199. package/lib/Events/RequestSettings.d.ts +11 -5
  200. package/lib/Events/RequestSettings.js +12 -10
  201. package/lib/Events/RequestTableColumns.d.ts +16 -11
  202. package/lib/Events/RequestTableColumns.js +12 -9
  203. package/lib/Events/SaleComplete.d.ts +15 -18
  204. package/lib/Events/SaleComplete.js +6 -7
  205. package/lib/Events/UIPipeline.d.ts +17 -5
  206. package/lib/Events/UIPipeline.js +17 -10
  207. package/lib/Mocks/APIs/Sale/MockCurrentSale.d.ts +99 -0
  208. package/lib/Mocks/APIs/Sale/MockCurrentSale.js +326 -0
  209. package/lib/Mocks/Database/MockDatabase.d.ts +96 -0
  210. package/lib/Mocks/Database/MockDatabase.js +89 -0
  211. package/lib/Mocks/MockApplication.d.ts +154 -0
  212. package/lib/Mocks/MockApplication.js +481 -0
  213. package/lib/Mocks/MockBridge.d.ts +31 -0
  214. package/lib/Mocks/MockBridge.js +77 -0
  215. package/lib/Mocks/index.d.ts +7 -0
  216. package/lib/Mocks/index.js +15 -0
  217. package/lib/Utilities/ActionEventRegistrar.d.ts +19 -4
  218. package/lib/Utilities/ActionEventRegistrar.js +19 -3
  219. package/lib/Utilities/MiscTypes.d.ts +6 -4
  220. package/lib/Utilities/MiscTypes.js +1 -2
  221. package/lib/Utilities/SaleCreate.d.ts +6 -2
  222. package/lib/Utilities/SaleCreate.js +10 -6
  223. package/lib/Utilities/Static.d.ts +3 -0
  224. package/lib/Utilities/Static.js +5 -7
  225. package/lib/Utilities/UUID.d.ts +9 -3
  226. package/lib/Utilities/UUID.js +10 -7
  227. package/lib/index.d.ts +16 -14
  228. package/lib/index.js +14 -49
  229. package/package.json +3 -2
  230. package/lib/APIs/CurrentSale/Exceptions.d.ts +0 -6
  231. package/lib/APIs/CurrentSale/Exceptions.js +0 -15
  232. package/lib/APIs/CurrentSale/Sale.d.ts +0 -182
  233. package/lib/APIs/CurrentSale/Sale.js +0 -290
  234. package/lib/APIs/CurrentSale/SaleCustomer.d.ts +0 -10
  235. package/lib/APIs/CurrentSale/SaleCustomer.js +0 -17
  236. package/lib/APIs/CurrentSale/SalePayment.d.ts +0 -68
  237. package/lib/APIs/CurrentSale/SalePayment.js +0 -99
  238. package/lib/APIs/CurrentSale/SaleProduct.d.ts +0 -121
  239. package/lib/APIs/CurrentSale/SaleProduct.js +0 -167
  240. package/lib/APIs/CurrentSale/ShopfrontSaleState.d.ts +0 -53
  241. package/lib/APIs/CurrentSale/ShopfrontSaleState.js +0 -2
  242. package/lib/APIs/CurrentSale/index.d.ts +0 -6
  243. package/lib/APIs/CurrentSale/index.js +0 -37
  244. /package/.idea/{embedded-bridge.iml → shopfront-embedded-bridge.iml} +0 -0
@@ -1,132 +1,67 @@
1
- import { BaseSale } from "./BaseSale";
2
- import { ShopfrontSaleState } from "./ShopfrontSaleState";
3
- import { SalePayment } from "./SalePayment";
4
- import { SaleProduct } from "./SaleProduct";
5
- import { SaleCustomer } from "./SaleCustomer";
6
- import { Application } from "../../Application";
7
- import { SaleUpdate, SaleUpdateChanges } from "../../Actions/SaleUpdate";
8
- export declare class CurrentSale extends BaseSale {
9
- protected application: Application;
10
- protected cancelled: boolean;
1
+ import { SaleUpdate, SaleUpdateChanges } from "../../Actions/SaleUpdate.js";
2
+ import { BaseCurrentSale } from "./BaseCurrentSale.js";
3
+ import { SaleCustomer } from "./SaleCustomer.js";
4
+ import { SalePayment } from "./SalePayment.js";
5
+ import { SaleProduct } from "./SaleProduct.js";
6
+ export declare class CurrentSale extends BaseCurrentSale {
11
7
  /**
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} saleState
17
- */
18
- constructor(application: Application, saleState: ShopfrontSaleState);
19
- /**
20
- * Update the sale to be the latest sale that exists on the sell screen.
21
- *
22
- * @returns {Promise<void>}
8
+ * @inheritDoc
23
9
  */
24
10
  refreshSale(): Promise<void>;
25
11
  /**
26
12
  * Check if the sale has already been cancelled, if it has, throw a SaleCancelledError.
27
- *
28
- * @protected
29
13
  */
30
14
  protected checkIfCancelled(): void;
31
15
  /**
32
16
  * Send a sale update to Shopfront.
33
- *
34
- * @protected
35
- * @param {SaleUpdate} update
36
- * @returns {Promise<void>}
37
17
  */
38
18
  protected sendSaleUpdate(update: SaleUpdate<keyof SaleUpdateChanges>): Promise<void>;
39
19
  /**
40
- * Cancel the current sale in progress.
41
- *
42
- * @returns {Promise<void>}
20
+ * @inheritDoc
43
21
  */
44
22
  cancelSale(): Promise<void>;
45
23
  /**
46
- * Add a product to the sale.
47
- *
48
- * @param {SaleProduct} product
49
- * @returns {Promise<void>}
24
+ * @inheritDoc
50
25
  */
51
26
  addProduct(product: SaleProduct): Promise<void>;
52
27
  /**
53
- * Remove a product from the sale.
54
- * It's highly recommended that you pass in a product that has been retrieved using sale.getProducts().
55
- *
56
- * @param {SaleProduct} product
57
- * @returns {Promise<void>}
28
+ * @inheritDoc
58
29
  */
59
30
  removeProduct(product: SaleProduct): Promise<void>;
60
31
  /**
61
- * Add a payment to the sell screen.
62
- *
63
- * If you specify a payment with a status, it will bypass the payment gateway (i.e. it won't request that the
64
- * user takes money from the customer).
65
- *
66
- * If you don't specify a cashout amount, it will automatically determine if the payment method normally requests
67
- * cashout (from the payment method settings).
68
- *
69
- * @param {SalePayment} payment
70
- * @returns {Promise<void>}
32
+ * @inheritDoc
71
33
  */
72
34
  addPayment(payment: SalePayment): Promise<void>;
73
35
  /**
74
- * Reverse a payment on the sell screen.
75
- *
76
- * This is used to issue a refund to the customer. The sale payment amount should be positive.
77
- *
78
- * @param {SalePayment} payment
79
- * @returns {Promise<void>}
36
+ * @inheritDoc
80
37
  */
81
38
  reversePayment(payment: SalePayment): Promise<void>;
82
39
  /**
83
- * Add a customer to the sale.
84
- * If there is already a customer on the sale this will override that customer.
85
- *
86
- * @param {SaleCustomer} customer
87
- * @returns {Promise<void>}
40
+ * @inheritDoc
88
41
  */
89
42
  addCustomer(customer: SaleCustomer): Promise<void>;
90
43
  /**
91
- * Remove the customer from the current sale.
92
- * If there is no customer currently on the sale this will be ignored.
93
- * If there are "on account" or loyalty payments still on the sale, this will be ignored.
94
- *
95
- * @returns {Promise<void>}
44
+ * @inheritDoc
96
45
  */
97
46
  removeCustomer(): Promise<void>;
98
47
  /**
99
- * Set the external note for the sale.
100
- *
101
- * @param {string} note The note to set.
102
- * @param {boolean} append Whether to append the note to the current sale note.
103
- * @returns {Promise<void>}
48
+ * @inheritDoc
104
49
  */
105
50
  setExternalNote(note: string, append?: boolean): Promise<void>;
106
51
  /**
107
- * Set the internal note for the sale.
108
- *
109
- * @param {string} note The note to set.
110
- * @param {boolean} append Whether to append the note to the current sale note.
111
- * @returns {Promise<void>}
52
+ * @inheritDoc
112
53
  */
113
54
  setInternalNote(note: string, append?: boolean): Promise<void>;
114
55
  /**
115
- * Set the order reference to the provided string.
116
- *
117
- * @param {string} reference
118
- * @returns {Promise<void>}
56
+ * @inheritDoc
119
57
  */
120
58
  setOrderReference(reference: string): Promise<void>;
121
59
  /**
122
- * Set the meta data of the sale, this will override the previous meta data.
123
- *
124
- * @param metaData
60
+ * @inheritDoc
125
61
  */
126
62
  setMetaData(metaData: Record<string, unknown>): Promise<void>;
127
63
  /**
128
- * Update a product's details, currently this can update quantity, price and metadata
129
- * @param product
64
+ * @inheritDoc
130
65
  */
131
66
  updateProduct(product: SaleProduct): Promise<void>;
132
67
  }
@@ -1,52 +1,28 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CurrentSale = void 0;
4
- const BaseSale_1 = require("./BaseSale");
5
- const SaleUpdate_1 = require("../../Actions/SaleUpdate");
6
- const Exceptions_1 = require("./Exceptions");
7
- const Sale_1 = require("./Sale");
8
- class CurrentSale extends BaseSale_1.BaseSale {
1
+ import { SaleUpdate } from "../../Actions/SaleUpdate.js";
2
+ import { BaseCurrentSale } from "./BaseCurrentSale.js";
3
+ import { InvalidSaleDeviceError, SaleCancelledError } from "./Exceptions.js";
4
+ export class CurrentSale extends BaseCurrentSale {
9
5
  /**
10
- * Create a sale from a sale state.
11
- * It's highly recommend to not construct a sale manually, instead use application.getCurrentSale().
12
- *
13
- * @param {Application} application
14
- * @param {ShopfrontSaleState} saleState
15
- */
16
- constructor(application, saleState) {
17
- super(Sale_1.Sale.buildSaleData(saleState));
18
- this.application = application;
19
- this.cancelled = false;
20
- }
21
- /**
22
- * Update the sale to be the latest sale that exists on the sell screen.
23
- *
24
- * @returns {Promise<void>}
6
+ * @inheritDoc
25
7
  */
26
8
  async refreshSale() {
27
9
  this.checkIfCancelled();
28
10
  const newSale = await this.application.getCurrentSale();
29
11
  if (newSale === false) {
30
- throw new Exceptions_1.InvalidSaleDeviceError();
12
+ throw new InvalidSaleDeviceError();
31
13
  }
32
14
  this.hydrate(newSale);
33
15
  }
34
16
  /**
35
17
  * Check if the sale has already been cancelled, if it has, throw a SaleCancelledError.
36
- *
37
- * @protected
38
18
  */
39
19
  checkIfCancelled() {
40
20
  if (this.cancelled) {
41
- throw new Exceptions_1.SaleCancelledError();
21
+ throw new SaleCancelledError();
42
22
  }
43
23
  }
44
24
  /**
45
25
  * Send a sale update to Shopfront.
46
- *
47
- * @protected
48
- * @param {SaleUpdate} update
49
- * @returns {Promise<void>}
50
26
  */
51
27
  sendSaleUpdate(update) {
52
28
  this.checkIfCancelled();
@@ -54,22 +30,17 @@ class CurrentSale extends BaseSale_1.BaseSale {
54
30
  return this.refreshSale();
55
31
  }
56
32
  /**
57
- * Cancel the current sale in progress.
58
- *
59
- * @returns {Promise<void>}
33
+ * @inheritDoc
60
34
  */
61
35
  async cancelSale() {
62
- await this.sendSaleUpdate(new SaleUpdate_1.SaleUpdate("SALE_CANCEL", {}));
36
+ await this.sendSaleUpdate(new SaleUpdate("SALE_CANCEL", {}));
63
37
  this.cancelled = true;
64
38
  }
65
39
  /**
66
- * Add a product to the sale.
67
- *
68
- * @param {SaleProduct} product
69
- * @returns {Promise<void>}
40
+ * @inheritDoc
70
41
  */
71
42
  addProduct(product) {
72
- return this.sendSaleUpdate(new SaleUpdate_1.SaleUpdate("PRODUCT_ADD", {
43
+ return this.sendSaleUpdate(new SaleUpdate("PRODUCT_ADD", {
73
44
  id: product.getId(),
74
45
  quantity: product.getQuantity(),
75
46
  price: product.getPrice(),
@@ -78,32 +49,19 @@ class CurrentSale extends BaseSale_1.BaseSale {
78
49
  }));
79
50
  }
80
51
  /**
81
- * Remove a product from the sale.
82
- * It's highly recommended that you pass in a product that has been retrieved using sale.getProducts().
83
- *
84
- * @param {SaleProduct} product
85
- * @returns {Promise<void>}
52
+ * @inheritDoc
86
53
  */
87
54
  removeProduct(product) {
88
- return this.sendSaleUpdate(new SaleUpdate_1.SaleUpdate("PRODUCT_REMOVE", {
55
+ return this.sendSaleUpdate(new SaleUpdate("PRODUCT_REMOVE", {
89
56
  id: product.getId(),
90
57
  indexAddress: product.getIndexAddress(),
91
58
  }));
92
59
  }
93
60
  /**
94
- * Add a payment to the sell screen.
95
- *
96
- * If you specify a payment with a status, it will bypass the payment gateway (i.e. it won't request that the
97
- * user takes money from the customer).
98
- *
99
- * If you don't specify a cashout amount, it will automatically determine if the payment method normally requests
100
- * cashout (from the payment method settings).
101
- *
102
- * @param {SalePayment} payment
103
- * @returns {Promise<void>}
61
+ * @inheritDoc
104
62
  */
105
63
  addPayment(payment) {
106
- return this.sendSaleUpdate(new SaleUpdate_1.SaleUpdate("PAYMENT_ADD", {
64
+ return this.sendSaleUpdate(new SaleUpdate("PAYMENT_ADD", {
107
65
  id: payment.getId(),
108
66
  amount: payment.getAmount(),
109
67
  cashout: payment.getCashout(),
@@ -111,15 +69,10 @@ class CurrentSale extends BaseSale_1.BaseSale {
111
69
  }));
112
70
  }
113
71
  /**
114
- * Reverse a payment on the sell screen.
115
- *
116
- * This is used to issue a refund to the customer. The sale payment amount should be positive.
117
- *
118
- * @param {SalePayment} payment
119
- * @returns {Promise<void>}
72
+ * @inheritDoc
120
73
  */
121
74
  reversePayment(payment) {
122
- return this.sendSaleUpdate(new SaleUpdate_1.SaleUpdate("PAYMENT_REVERSE", {
75
+ return this.sendSaleUpdate(new SaleUpdate("PAYMENT_REVERSE", {
123
76
  id: payment.getId(),
124
77
  amount: payment.getAmount(),
125
78
  cashout: payment.getCashout(),
@@ -127,82 +80,60 @@ class CurrentSale extends BaseSale_1.BaseSale {
127
80
  }));
128
81
  }
129
82
  /**
130
- * Add a customer to the sale.
131
- * If there is already a customer on the sale this will override that customer.
132
- *
133
- * @param {SaleCustomer} customer
134
- * @returns {Promise<void>}
83
+ * @inheritDoc
135
84
  */
136
85
  addCustomer(customer) {
137
- return this.sendSaleUpdate(new SaleUpdate_1.SaleUpdate("CUSTOMER_ADD", {
86
+ return this.sendSaleUpdate(new SaleUpdate("CUSTOMER_ADD", {
138
87
  id: customer.getId(),
139
88
  }));
140
89
  }
141
90
  /**
142
- * Remove the customer from the current sale.
143
- * If there is no customer currently on the sale this will be ignored.
144
- * If there are "on account" or loyalty payments still on the sale, this will be ignored.
145
- *
146
- * @returns {Promise<void>}
91
+ * @inheritDoc
147
92
  */
148
93
  removeCustomer() {
149
- return this.sendSaleUpdate(new SaleUpdate_1.SaleUpdate("CUSTOMER_REMOVE", {}));
94
+ return this.sendSaleUpdate(new SaleUpdate("CUSTOMER_REMOVE", {}));
150
95
  }
151
96
  /**
152
- * Set the external note for the sale.
153
- *
154
- * @param {string} note The note to set.
155
- * @param {boolean} append Whether to append the note to the current sale note.
156
- * @returns {Promise<void>}
97
+ * @inheritDoc
157
98
  */
158
99
  setExternalNote(note, append = false) {
159
- return this.sendSaleUpdate(new SaleUpdate_1.SaleUpdate("SALE_EXTERNAL_NOTE", {
100
+ return this.sendSaleUpdate(new SaleUpdate("SALE_EXTERNAL_NOTE", {
160
101
  note,
161
102
  append,
162
103
  }));
163
104
  }
164
105
  /**
165
- * Set the internal note for the sale.
166
- *
167
- * @param {string} note The note to set.
168
- * @param {boolean} append Whether to append the note to the current sale note.
169
- * @returns {Promise<void>}
106
+ * @inheritDoc
170
107
  */
171
108
  setInternalNote(note, append = false) {
172
- return this.sendSaleUpdate(new SaleUpdate_1.SaleUpdate("SALE_INTERNAL_NOTE", {
109
+ return this.sendSaleUpdate(new SaleUpdate("SALE_INTERNAL_NOTE", {
173
110
  note,
174
111
  append,
175
112
  }));
176
113
  }
177
114
  /**
178
- * Set the order reference to the provided string.
179
- *
180
- * @param {string} reference
181
- * @returns {Promise<void>}
115
+ * @inheritDoc
182
116
  */
183
117
  setOrderReference(reference) {
184
- return this.sendSaleUpdate(new SaleUpdate_1.SaleUpdate("SALE_ORDER_REFERENCE", {
118
+ return this.sendSaleUpdate(new SaleUpdate("SALE_ORDER_REFERENCE", {
185
119
  reference,
186
120
  }));
187
121
  }
188
122
  /**
189
- * Set the meta data of the sale, this will override the previous meta data.
190
- *
191
- * @param metaData
123
+ * @inheritDoc
192
124
  */
193
125
  setMetaData(metaData) {
194
- return this.sendSaleUpdate(new SaleUpdate_1.SaleUpdate("SALE_META_DATA", {
126
+ return this.sendSaleUpdate(new SaleUpdate("SALE_META_DATA", {
195
127
  metaData,
196
128
  }));
197
129
  }
198
130
  /**
199
- * Update a product's details, currently this can update quantity, price and metadata
200
- * @param product
131
+ * @inheritDoc
201
132
  */
202
133
  updateProduct(product) {
203
134
  const updateData = {
204
135
  id: product.getId(),
205
- indexAddress: product.getIndexAddress()
136
+ indexAddress: product.getIndexAddress(),
206
137
  };
207
138
  if (product.wasQuantityModified()) {
208
139
  updateData.quantity = product.getQuantity();
@@ -214,7 +145,6 @@ class CurrentSale extends BaseSale_1.BaseSale {
214
145
  updateData.metaData = product.getMetaData();
215
146
  }
216
147
  product.clearModificationFlags();
217
- return this.sendSaleUpdate(new SaleUpdate_1.SaleUpdate("PRODUCT_UPDATE", updateData));
148
+ return this.sendSaleUpdate(new SaleUpdate("PRODUCT_UPDATE", updateData));
218
149
  }
219
150
  }
220
- exports.CurrentSale = CurrentSale;
@@ -4,3 +4,6 @@ export declare class SaleCancelledError extends Error {
4
4
  export declare class InvalidSaleDeviceError extends Error {
5
5
  constructor();
6
6
  }
7
+ export declare class ProductNotExistsError extends Error {
8
+ constructor();
9
+ }
@@ -1,15 +1,15 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InvalidSaleDeviceError = exports.SaleCancelledError = void 0;
4
- class SaleCancelledError extends Error {
1
+ export class SaleCancelledError extends Error {
5
2
  constructor() {
6
3
  super("The sale is no longer active.");
7
4
  }
8
5
  }
9
- exports.SaleCancelledError = SaleCancelledError;
10
- class InvalidSaleDeviceError extends Error {
6
+ export class InvalidSaleDeviceError extends Error {
11
7
  constructor() {
12
8
  super("This device is no longer a register able to perform a sale.");
13
9
  }
14
10
  }
15
- exports.InvalidSaleDeviceError = InvalidSaleDeviceError;
11
+ export class ProductNotExistsError extends Error {
12
+ constructor() {
13
+ super("Product does not exist in the sale");
14
+ }
15
+ }
@@ -1,23 +1,56 @@
1
- import { BaseSale, SaleData } from "./BaseSale";
2
- import { SaleCustomer } from "./SaleCustomer";
3
- import { SalePayment } from "./SalePayment";
4
- import { SaleProduct } from "./SaleProduct";
5
- import { Application } from "../../Application";
6
- import { ShopfrontSaleState } from "./ShopfrontSaleState";
1
+ import { Application } from "../../Application.js";
2
+ import { BaseSale, SaleData } from "./BaseSale.js";
3
+ import { SaleCustomer } from "./SaleCustomer.js";
4
+ import { SalePayment } from "./SalePayment.js";
5
+ import { SaleProduct } from "./SaleProduct.js";
6
+ import { ShopfrontSaleState } from "./ShopfrontSaleState.js";
7
7
  export declare class Sale extends BaseSale {
8
8
  protected created: boolean;
9
9
  protected creating: boolean;
10
10
  constructor(data: SaleData);
11
+ /**
12
+ * Add a customer to the sale
13
+ */
11
14
  addCustomer(customer: SaleCustomer): Promise<void>;
15
+ /**
16
+ * Add a payment to the sale
17
+ */
12
18
  addPayment(payment: SalePayment): Promise<void>;
19
+ /**
20
+ * Add a product to the sale
21
+ */
13
22
  addProduct(product: SaleProduct): Promise<void>;
23
+ /**
24
+ * Remove the customer from the sale
25
+ */
14
26
  removeCustomer(): Promise<void>;
27
+ /**
28
+ * Remove a product from the sale
29
+ */
15
30
  removeProduct(product: SaleProduct): Promise<void>;
31
+ /**
32
+ * Remove a payment from the sale
33
+ */
16
34
  removePayment(payment: SalePayment): Promise<void>;
35
+ /**
36
+ * Add / append an external note to the sale
37
+ */
17
38
  setExternalNote(note: string, append?: boolean): Promise<void>;
39
+ /**
40
+ * Add / append an internal note to the sale
41
+ */
18
42
  setInternalNote(note: string, append?: boolean): Promise<void>;
43
+ /**
44
+ * Set the sale's meta-data
45
+ */
19
46
  setMetaData(metaData: Record<string, unknown>): Promise<void>;
47
+ /**
48
+ * Set the sale's order reference
49
+ */
20
50
  setOrderReference(reference: string): Promise<void>;
51
+ /**
52
+ * Update a product in the sale
53
+ */
21
54
  updateProduct(product: SaleProduct): Promise<void>;
22
55
  /**
23
56
  * Create the sale on the server
@@ -28,7 +61,6 @@ export declare class Sale extends BaseSale {
28
61
  }>;
29
62
  /**
30
63
  * Converts the sale state to the sale data
31
- * @param saleState
32
64
  */
33
65
  static buildSaleData(saleState: ShopfrontSaleState): SaleData;
34
66
  }
@@ -1,34 +1,46 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Sale = void 0;
4
- const BaseSale_1 = require("./BaseSale");
5
- const SaleCustomer_1 = require("./SaleCustomer");
6
- const SalePayment_1 = require("./SalePayment");
7
- const SaleProduct_1 = require("./SaleProduct");
8
- class Sale extends BaseSale_1.BaseSale {
1
+ import { BaseSale } from "./BaseSale.js";
2
+ import { SaleCustomer } from "./SaleCustomer.js";
3
+ import { SalePayment } from "./SalePayment.js";
4
+ import { SaleProduct } from "./SaleProduct.js";
5
+ export class Sale extends BaseSale {
9
6
  constructor(data) {
10
7
  super(data);
11
8
  this.created = false;
12
9
  this.creating = false;
13
10
  }
11
+ /**
12
+ * Add a customer to the sale
13
+ */
14
14
  async addCustomer(customer) {
15
15
  this.customer = customer;
16
16
  }
17
+ /**
18
+ * Add a payment to the sale
19
+ */
17
20
  async addPayment(payment) {
18
21
  if (this.payments.find(p => p.internalId === payment.internalId)) {
19
22
  throw new TypeError("Payment has already been added to sale.");
20
23
  }
21
24
  this.payments.push(payment);
22
25
  }
26
+ /**
27
+ * Add a product to the sale
28
+ */
23
29
  async addProduct(product) {
24
30
  if (this.products.find(p => p.internalId === product.internalId)) {
25
31
  throw new TypeError("Product has already been added to sale.");
26
32
  }
27
33
  this.products.push(product);
28
34
  }
35
+ /**
36
+ * Remove the customer from the sale
37
+ */
29
38
  async removeCustomer() {
30
39
  this.customer = null;
31
40
  }
41
+ /**
42
+ * Remove a product from the sale
43
+ */
32
44
  async removeProduct(product) {
33
45
  const index = this.products.findIndex(p => p.internalId === product.internalId);
34
46
  if (index === -1) {
@@ -36,6 +48,9 @@ class Sale extends BaseSale_1.BaseSale {
36
48
  }
37
49
  this.products.splice(index, 1);
38
50
  }
51
+ /**
52
+ * Remove a payment from the sale
53
+ */
39
54
  async removePayment(payment) {
40
55
  const index = this.payments.findIndex(p => p.internalId === payment.internalId);
41
56
  if (index === -1) {
@@ -43,6 +58,9 @@ class Sale extends BaseSale_1.BaseSale {
43
58
  }
44
59
  this.payments.splice(index, 1);
45
60
  }
61
+ /**
62
+ * Add / append an external note to the sale
63
+ */
46
64
  async setExternalNote(note, append) {
47
65
  if (append) {
48
66
  this.sale.notes.sale += note;
@@ -51,6 +69,9 @@ class Sale extends BaseSale_1.BaseSale {
51
69
  this.sale.notes.sale = note;
52
70
  }
53
71
  }
72
+ /**
73
+ * Add / append an internal note to the sale
74
+ */
54
75
  async setInternalNote(note, append) {
55
76
  if (append) {
56
77
  this.sale.notes.internal += note;
@@ -59,12 +80,21 @@ class Sale extends BaseSale_1.BaseSale {
59
80
  this.sale.notes.internal = note;
60
81
  }
61
82
  }
83
+ /**
84
+ * Set the sale's meta-data
85
+ */
62
86
  async setMetaData(metaData) {
63
87
  this.sale.metaData = metaData;
64
88
  }
89
+ /**
90
+ * Set the sale's order reference
91
+ */
65
92
  async setOrderReference(reference) {
66
93
  this.sale.orderReference = reference;
67
94
  }
95
+ /**
96
+ * Update a product in the sale
97
+ */
68
98
  async updateProduct(product) {
69
99
  const index = this.products.findIndex(p => p.internalId === product.internalId);
70
100
  if (index === -1) {
@@ -92,7 +122,6 @@ class Sale extends BaseSale_1.BaseSale {
92
122
  }
93
123
  /**
94
124
  * Converts the sale state to the sale data
95
- * @param saleState
96
125
  */
97
126
  static buildSaleData(saleState) {
98
127
  return {
@@ -105,12 +134,11 @@ class Sale extends BaseSale_1.BaseSale {
105
134
  refundReason: saleState.refundReason,
106
135
  priceSet: saleState.priceSet,
107
136
  metaData: saleState.metaData,
108
- customer: saleState.customer ? new SaleCustomer_1.SaleCustomer(saleState.customer.uuid) : null,
109
- payments: saleState.payments.map(SalePayment_1.SalePayment.HydrateFromState),
137
+ customer: saleState.customer ? new SaleCustomer(saleState.customer.uuid) : null,
138
+ payments: saleState.payments.map(SalePayment.HydrateFromState),
110
139
  products: saleState.products.map((product, index) => {
111
- return SaleProduct_1.SaleProduct.HydrateFromState(product, [index]);
140
+ return SaleProduct.HydrateFromState(product, [index]);
112
141
  }),
113
142
  };
114
143
  }
115
144
  }
116
- exports.Sale = Sale;
@@ -3,8 +3,6 @@ export declare class SaleCustomer {
3
3
  constructor(id: string);
4
4
  /**
5
5
  * Get the ID of the customer.
6
- *
7
- * @returns {string}
8
6
  */
9
7
  getId(): string;
10
8
  }
@@ -1,17 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SaleCustomer = void 0;
4
- class SaleCustomer {
1
+ export class SaleCustomer {
5
2
  constructor(id) {
6
3
  this.id = id;
7
4
  }
8
5
  /**
9
6
  * Get the ID of the customer.
10
- *
11
- * @returns {string}
12
7
  */
13
8
  getId() {
14
9
  return this.id;
15
10
  }
16
11
  }
17
- exports.SaleCustomer = SaleCustomer;