@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.
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 +482 -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
@@ -0,0 +1,10 @@
1
+ <component name="ProjectCodeStyleConfiguration">
2
+ <code_scheme name="Project" version="173">
3
+ <JSCodeStyleSettings version="0">
4
+ <option name="FORCE_SEMICOLON_STYLE" value="true" />
5
+ </JSCodeStyleSettings>
6
+ <TypeScriptCodeStyleSettings version="0">
7
+ <option name="FORCE_SEMICOLON_STYLE" value="true" />
8
+ </TypeScriptCodeStyleSettings>
9
+ </code_scheme>
10
+ </component>
@@ -0,0 +1,5 @@
1
+ <component name="ProjectCodeStyleConfiguration">
2
+ <state>
3
+ <option name="USE_PER_PROJECT_SETTINGS" value="true" />
4
+ </state>
5
+ </component>
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="GitToolBoxBlameSettings">
4
+ <option name="version" value="2" />
5
+ </component>
6
+ </project>
@@ -0,0 +1,15 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="GitToolBoxProjectSettings">
4
+ <option name="commitMessageIssueKeyValidationOverride">
5
+ <BoolValueOverride>
6
+ <option name="enabled" value="true" />
7
+ </BoolValueOverride>
8
+ </option>
9
+ <option name="commitMessageValidationEnabledOverride">
10
+ <BoolValueOverride>
11
+ <option name="enabled" value="true" />
12
+ </BoolValueOverride>
13
+ </option>
14
+ </component>
15
+ </project>
@@ -2,5 +2,10 @@
2
2
  <profile version="1.0">
3
3
  <option name="myName" value="Project Default" />
4
4
  <inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
5
+ <inspection_tool class="ImplicitTypeConversion" enabled="true" level="WARNING" enabled_by_default="true">
6
+ <option name="BITS" value="1720" />
7
+ <option name="FLAG_EXPLICIT_CONVERSION" value="true" />
8
+ <option name="IGNORE_NODESET_TO_BOOLEAN_VIA_STRING" value="true" />
9
+ </inspection_tool>
5
10
  </profile>
6
11
  </component>
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="EslintConfiguration">
4
+ <option name="fix-on-save" value="true" />
5
+ </component>
6
+ </project>
package/.idea/modules.xml CHANGED
@@ -2,7 +2,7 @@
2
2
  <project version="4">
3
3
  <component name="ProjectModuleManager">
4
4
  <modules>
5
- <module fileurl="file://$PROJECT_DIR$/.idea/embedded-bridge.iml" filepath="$PROJECT_DIR$/.idea/embedded-bridge.iml" />
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/shopfront-embedded-bridge.iml" filepath="$PROJECT_DIR$/.idea/shopfront-embedded-bridge.iml" />
6
6
  </modules>
7
7
  </component>
8
8
  </project>
package/.idea/php.xml CHANGED
@@ -9,9 +9,24 @@
9
9
  <component name="PHPCodeSnifferOptionsConfiguration">
10
10
  <option name="transferred" value="true" />
11
11
  </component>
12
+ <component name="PhpCodeSniffer">
13
+ <phpcs_settings>
14
+ <phpcs_by_interpreter asDefaultInterpreter="true" interpreter_id="bb870563-23b2-4cfc-9ac5-70a3316d78e5" timeout="30000" />
15
+ </phpcs_settings>
16
+ </component>
17
+ <component name="PhpStan">
18
+ <PhpStan_settings>
19
+ <phpstan_by_interpreter asDefaultInterpreter="true" interpreter_id="bb870563-23b2-4cfc-9ac5-70a3316d78e5" timeout="60000" />
20
+ </PhpStan_settings>
21
+ </component>
12
22
  <component name="PhpStanOptionsConfiguration">
13
23
  <option name="transferred" value="true" />
14
24
  </component>
25
+ <component name="Psalm">
26
+ <Psalm_settings>
27
+ <psalm_fixer_by_interpreter asDefaultInterpreter="true" interpreter_id="bb870563-23b2-4cfc-9ac5-70a3316d78e5" timeout="60000" />
28
+ </Psalm_settings>
29
+ </component>
15
30
  <component name="PsalmOptionsConfiguration">
16
31
  <option name="transferred" value="true" />
17
32
  </component>
@@ -0,0 +1,28 @@
1
+ import { BaseBridge } from "../../BaseBridge.js";
2
+ import { AnyFunction } from "../../Utilities/MiscTypes.js";
3
+ import { DataSourceTables } from "./types/DataSourceTables.js";
4
+ export type DatabaseTable = keyof DataSourceTables;
5
+ export type DatabaseMethodName<Table extends DatabaseTable> = {
6
+ [K in keyof DataSourceTables[Table]]: DataSourceTables[Table][K] extends AnyFunction ? K : never;
7
+ };
8
+ export type DatabaseCallReturn<Table extends DatabaseTable, Method extends keyof DatabaseMethodName<Table>> = ReturnType<Extract<DataSourceTables[Table][Method], AnyFunction>>;
9
+ export declare abstract class BaseDatabase<BridgeType extends BaseBridge = BaseBridge> {
10
+ protected bridge: BridgeType;
11
+ protected constructor(bridge: BridgeType);
12
+ /**
13
+ * Makes a request to the Shopfront local database
14
+ */
15
+ abstract callMethod<Table extends DatabaseTable, Method extends keyof DatabaseMethodName<Table>, ExpectedResult extends DatabaseCallReturn<Table, Method>>(table: Table, method: Method, args: Array<unknown>): Promise<ExpectedResult>;
16
+ /**
17
+ * Retrieves all items in the specified table
18
+ */
19
+ abstract all<Table extends DatabaseTable>(table: Table): Promise<DatabaseCallReturn<Table, "all">>;
20
+ /**
21
+ * Retrieves all items that match the given ID in the specified table
22
+ */
23
+ abstract get<Table extends DatabaseTable>(table: Table, id: string | number): Promise<DatabaseCallReturn<Table, "get">>;
24
+ /**
25
+ * Returns the item count of the specified table
26
+ */
27
+ abstract count(table: DatabaseTable): Promise<number>;
28
+ }
@@ -0,0 +1,5 @@
1
+ export class BaseDatabase {
2
+ constructor(bridge) {
3
+ this.bridge = bridge;
4
+ }
5
+ }
@@ -1,9 +1,21 @@
1
- import { Bridge } from "../../Bridge";
2
- export declare class Database {
3
- protected bridge: Bridge;
1
+ import { Bridge } from "../../Bridge.js";
2
+ import { BaseDatabase, DatabaseCallReturn, DatabaseMethodName, DatabaseTable } from "./BaseDatabase.js";
3
+ export declare class Database extends BaseDatabase<Bridge> {
4
4
  constructor(bridge: Bridge);
5
- callMethod<ExpectedResult>(table: string, method: string, args: Array<unknown>): Promise<ExpectedResult>;
6
- all<Item>(table: string): Promise<Array<Item>>;
7
- get<Item>(table: string, id: string | number): Promise<Item>;
8
- count(table: string): Promise<number>;
5
+ /**
6
+ * @inheritDoc
7
+ */
8
+ callMethod<Table extends DatabaseTable, Method extends keyof DatabaseMethodName<Table>, ExpectedResult extends DatabaseCallReturn<Table, Method>>(table: Table, method: Method, args: Array<unknown>): Promise<ExpectedResult>;
9
+ /**
10
+ * @inheritDoc
11
+ */
12
+ all<Table extends DatabaseTable>(table: Table): Promise<DatabaseCallReturn<Table, "all">>;
13
+ /**
14
+ * @inheritDoc
15
+ */
16
+ get<Table extends DatabaseTable>(table: Table, id: string | number): Promise<DatabaseCallReturn<Table, "get">>;
17
+ /**
18
+ * @inheritDoc
19
+ */
20
+ count(table: DatabaseTable): Promise<number>;
9
21
  }
@@ -1,14 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Database = void 0;
4
- const ApplicationEvents_1 = require("../../ApplicationEvents");
5
- class Database {
1
+ import { ToShopfront } from "../../ApplicationEvents.js";
2
+ import { BaseDatabase, } from "./BaseDatabase.js";
3
+ export class Database extends BaseDatabase {
6
4
  constructor(bridge) {
7
- this.bridge = bridge;
5
+ super(bridge);
8
6
  }
9
- callMethod(table, method, args) {
7
+ /**
8
+ * @inheritDoc
9
+ */
10
+ async callMethod(table, method, args) {
10
11
  const databaseRequest = `DatabaseRequest-${Math.random()}-${Date.now()}`;
11
12
  const promise = new Promise((res, rej) => {
13
+ // eslint-disable-next-line jsdoc/require-jsdoc
12
14
  const listener = (event, data) => {
13
15
  if (event !== "RESPONSE_DATABASE_REQUEST") {
14
16
  return;
@@ -25,7 +27,7 @@ class Database {
25
27
  };
26
28
  this.bridge.addEventListener(listener);
27
29
  });
28
- this.bridge.sendMessage(ApplicationEvents_1.ToShopfront.DATABASE_REQUEST, {
30
+ this.bridge.sendMessage(ToShopfront.DATABASE_REQUEST, {
29
31
  requestId: databaseRequest,
30
32
  table,
31
33
  method,
@@ -33,14 +35,22 @@ class Database {
33
35
  });
34
36
  return promise;
35
37
  }
36
- all(table) {
38
+ /**
39
+ * @inheritDoc
40
+ */
41
+ async all(table) {
37
42
  return this.callMethod(table, "all", []);
38
43
  }
39
- get(table, id) {
44
+ /**
45
+ * @inheritDoc
46
+ */
47
+ async get(table, id) {
40
48
  return this.callMethod(table, "get", [id]);
41
49
  }
42
- count(table) {
50
+ /**
51
+ * @inheritDoc
52
+ */
53
+ async count(table) {
43
54
  return this.callMethod(table, "count", []);
44
55
  }
45
56
  }
46
- exports.Database = Database;
@@ -0,0 +1,8 @@
1
+ import BaseRepository from "./BaseRepository.js";
2
+ export interface LocalDatabaseBarcodeTemplate {
3
+ id: number;
4
+ name: string;
5
+ recalculate_quantity: boolean;
6
+ template: string;
7
+ }
8
+ export type BaseBarcodeTemplateRepository = BaseRepository<LocalDatabaseBarcodeTemplate, number>;
@@ -0,0 +1,11 @@
1
+ import BaseRepository from "./BaseRepository.js";
2
+ import { BaseSearchableRepository } from "./BaseSearchableRepository.js";
3
+ export interface LocalDatabaseClassification {
4
+ name: string;
5
+ uuid: string;
6
+ mdb_id: number | undefined;
7
+ }
8
+ export interface LocalDatabaseCategory extends LocalDatabaseClassification {
9
+ metcash_msc: string | undefined;
10
+ }
11
+ export type BaseClassificationRepository = BaseRepository<LocalDatabaseClassification> & BaseSearchableRepository<LocalDatabaseClassification>;
@@ -0,0 +1,10 @@
1
+ import BaseRepository from "./BaseRepository.js";
2
+ export interface LocalDatabaseCustomerDisplay {
3
+ idle_display: string;
4
+ main_colour: string;
5
+ name: string;
6
+ sale_display: string;
7
+ text_colour: string;
8
+ uuid: string;
9
+ }
10
+ export type BaseCustomerDisplayRepository = BaseRepository<LocalDatabaseCustomerDisplay>;
@@ -0,0 +1,24 @@
1
+ import BaseRepository from "./BaseRepository.js";
2
+ import { BaseSearchableRepository } from "./BaseSearchableRepository.js";
3
+ export interface LocalDatabaseCustomerGroup {
4
+ account_limit: number | null;
5
+ account_receipt_id: string | null;
6
+ allow_account_sales: boolean;
7
+ auto_email_receipt: boolean;
8
+ autoprint_account_receipt: boolean;
9
+ autoprint_receipt: boolean;
10
+ autoprint_parked_receipt: boolean;
11
+ credit_terms: null | Array<string>;
12
+ disable_promotions: boolean;
13
+ email_receipt_id: null | string;
14
+ loyalty: boolean;
15
+ loyalty_rate: number | null;
16
+ name: string;
17
+ pricelist_id: null | string;
18
+ receipt_id: null | string;
19
+ statement_template_id: null | string;
20
+ require_order_reference: 0 | 1;
21
+ updated_at: string;
22
+ uuid: string;
23
+ }
24
+ export type BaseCustomerGroupRepository = BaseRepository<LocalDatabaseCustomerGroup> & BaseSearchableRepository<LocalDatabaseCustomerGroup>;
@@ -0,0 +1,76 @@
1
+ import BaseRepository from "./BaseRepository.js";
2
+ import { BaseSearchableRepository } from "./BaseSearchableRepository.js";
3
+ export interface CustomerRepositorySearchOptions {
4
+ name: boolean;
5
+ code: boolean;
6
+ email: boolean;
7
+ phone: boolean;
8
+ company: boolean;
9
+ customerGroups: Array<string>;
10
+ exactMatch: boolean;
11
+ sort: boolean;
12
+ limit: number;
13
+ filter: ((customer: LocalDatabaseCustomer) => boolean) | undefined;
14
+ }
15
+ export interface LocalDatabaseContact {
16
+ address_city: string;
17
+ address_country: string;
18
+ address_postcode: string;
19
+ address_state: string;
20
+ address_street_1: string;
21
+ address_street_2: string;
22
+ address_suburb: string;
23
+ email: string;
24
+ facebook: string;
25
+ fax: string;
26
+ mobile: string;
27
+ phone: string;
28
+ twitter: string;
29
+ website: string;
30
+ }
31
+ export interface LocalDatabaseCustomer {
32
+ account_limit: null | number;
33
+ account_receipt: null | string;
34
+ allow_account_sales: boolean;
35
+ autoprint_account_receipt: boolean;
36
+ autoprint_receipt: boolean;
37
+ autoprint_parked_receipt: boolean;
38
+ billing: LocalDatabaseContact;
39
+ birthday: null | string;
40
+ business_number: string;
41
+ client_id: string;
42
+ code: string;
43
+ comments: string;
44
+ company: string;
45
+ current_owing: number;
46
+ customer_group_id: null | string;
47
+ delivery: LocalDatabaseContact;
48
+ disable_promotions: boolean;
49
+ email: string;
50
+ first_name: string;
51
+ full_name: string;
52
+ gender: string;
53
+ invoice_message: string;
54
+ last_name: string;
55
+ loyalty: boolean;
56
+ loyalty_points: number;
57
+ loyalty_rate: number | null;
58
+ override_customer_group: boolean;
59
+ phones: Array<string>;
60
+ pricelist_id: null | string;
61
+ receipt: null | string;
62
+ require_order_reference: 0 | 1;
63
+ uuid: string;
64
+ }
65
+ export interface BaseCustomerRepository extends BaseRepository<LocalDatabaseCustomer>, BaseSearchableRepository<LocalDatabaseCustomer, CustomerRepositorySearchOptions> {
66
+ /**
67
+ * Retrieve all customers with the specified customer group ID
68
+ * @param customerGroupId
69
+ */
70
+ getByCustomerGroup(customerGroupId: string): Promise<Array<LocalDatabaseCustomer>>;
71
+ /**
72
+ * Retrieve all customers with the specified price list ID
73
+ * @param priceListId
74
+ */
75
+ getByPriceList(priceListId: string): Promise<Array<LocalDatabaseCustomer>>;
76
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ import BaseRepository from "./BaseRepository.js";
2
+ import { BaseSearchableRepository } from "./BaseSearchableRepository.js";
3
+ export interface LocalDatabaseEnterprise {
4
+ auth: string;
5
+ id: string;
6
+ name: string;
7
+ }
8
+ export type BaseEnterpriseRepository = BaseRepository<LocalDatabaseEnterprise> & BaseSearchableRepository<LocalDatabaseEnterprise>;
@@ -0,0 +1,18 @@
1
+ import BaseRepository from "./BaseRepository.js";
2
+ export interface LocalDatabaseGiftCard {
3
+ client_id: string;
4
+ code: string;
5
+ current_amount: string;
6
+ expiry: string;
7
+ original_amount: string;
8
+ outlet_id: string;
9
+ status: "active" | "cancelled" | "pending";
10
+ updated_at: string;
11
+ uuid: string;
12
+ }
13
+ export interface BaseGiftCardRepository extends BaseRepository<LocalDatabaseGiftCard> {
14
+ /**
15
+ * Retrieve all gift cards with the specified code
16
+ */
17
+ code(code: string): Promise<Array<LocalDatabaseGiftCard>>;
18
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,41 @@
1
+ import BaseRepository from "./BaseRepository.js";
2
+ interface KitchenOrderItemComponent {
3
+ id: string;
4
+ name: string;
5
+ quantity: number;
6
+ components: Array<KitchenOrderItemComponent>;
7
+ }
8
+ interface KitchenOrderItem {
9
+ id: string;
10
+ product: string;
11
+ ready: boolean;
12
+ category: string;
13
+ tags: Array<string>;
14
+ name: string;
15
+ quantity: number;
16
+ note: string;
17
+ components: Array<KitchenOrderItemComponent>;
18
+ }
19
+ interface KitchenOrder {
20
+ id: string;
21
+ register: string;
22
+ outlet: string;
23
+ invoiceId: string;
24
+ note: string;
25
+ internalNote: string;
26
+ saleTime: string;
27
+ customerName: null | string;
28
+ items: Array<KitchenOrderItem>;
29
+ }
30
+ export interface LocalKitchenOrder {
31
+ version: number;
32
+ id: string;
33
+ order: KitchenOrder;
34
+ }
35
+ export interface BaseKitchenOrderRepository extends BaseRepository<LocalKitchenOrder> {
36
+ /**
37
+ * Delete any orders below the specified version
38
+ */
39
+ removeVersionsBefore(version: number): Promise<void>;
40
+ }
41
+ export {};
@@ -0,0 +1,16 @@
1
+ import BaseRepository from "./BaseRepository.js";
2
+ export type KitchenDisplayRuleReady = "NOT_DONE" | "NOT_STARTED" | "STARTED" | "DONE";
3
+ export interface KitchenDisplayFilterRules {
4
+ ready: KitchenDisplayRuleReady;
5
+ categories: Array<string>;
6
+ tags: Array<string>;
7
+ registers: Array<string>;
8
+ outlets: Array<string>;
9
+ }
10
+ export interface LocalKitchenScreen {
11
+ uuid: string;
12
+ name: string;
13
+ rules: KitchenDisplayFilterRules;
14
+ }
15
+ export interface BaseKitchenScreenRepository extends BaseRepository<LocalKitchenScreen> {
16
+ }
@@ -0,0 +1,12 @@
1
+ import BaseRepository from "./BaseRepository.js";
2
+ export interface LocalDatabaseLockedResource {
3
+ type: string;
4
+ uuid: string;
5
+ resource: string;
6
+ }
7
+ export interface BaseLockedResourceRepository extends BaseRepository<LocalDatabaseLockedResource> {
8
+ /**
9
+ * Retrieve all locked resources with the specified resource
10
+ */
11
+ getByResource(resource: string): Promise<LocalDatabaseLockedResource>;
12
+ }
@@ -0,0 +1,16 @@
1
+ import BaseRepository from "./BaseRepository.js";
2
+ export type LoyaltyUnion = "brand" | "category" | "family" | "tag" | "product";
3
+ export interface LocalDatabaseLoyalty {
4
+ id: number;
5
+ loyalty_value: null | string;
6
+ quantity: string;
7
+ redeem_value: null | string;
8
+ type: LoyaltyUnion;
9
+ uuid: string;
10
+ }
11
+ export interface BaseLoyaltyRepository extends BaseRepository<LocalDatabaseLoyalty, number> {
12
+ /**
13
+ * Retrieve all loyalty rates with the specified ID and type
14
+ */
15
+ getByType(id: string, type: LoyaltyUnion): Promise<Array<LocalDatabaseLoyalty>>;
16
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,16 @@
1
+ import BaseRepository from "./BaseRepository.js";
2
+ export interface LocalDatabaseMovement {
3
+ amount: string;
4
+ denominations: Array<{
5
+ direction: "IN" | "OUT";
6
+ denomination: number;
7
+ amount: number;
8
+ }>;
9
+ paymentMethod: string;
10
+ reason: string;
11
+ register: string;
12
+ timestamp: string;
13
+ user: string;
14
+ uuid: string;
15
+ }
16
+ export type BaseMovementRepository = BaseRepository<LocalDatabaseMovement>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,19 @@
1
+ import { LocalDatabaseContact } from "./BaseCustomerRepository.js";
2
+ import BaseRepository from "./BaseRepository.js";
3
+ export interface LocalDatabaseOutlet {
4
+ loyalty_enabled: boolean;
5
+ loyalty_name: string;
6
+ has_kitchen_screen: boolean;
7
+ name: string;
8
+ business_number: string;
9
+ contact: LocalDatabaseContact | null;
10
+ logo: string | null;
11
+ settings: Record<string, unknown>;
12
+ uuid: string;
13
+ }
14
+ export interface BaseOutletRepository extends BaseRepository<LocalDatabaseOutlet> {
15
+ /**
16
+ * Update the outlet data
17
+ */
18
+ update(id: string, changes: Partial<LocalDatabaseOutlet>): Promise<void>;
19
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,27 @@
1
+ import BaseRepository from "./BaseRepository.js";
2
+ export type PaymentMethodTypeUnion = "global" | "cash" | "eftpos" | "giftcard" | "voucher" | "cheque" | "pc-eftpos" | "linkly-vaa" | "direct-deposit" | "tyro" | "custom";
3
+ export interface LocalDatabasePaymentMethod {
4
+ action: string;
5
+ actual_denominations: string;
6
+ allow_cash_out: boolean;
7
+ always_open_drawer: boolean;
8
+ always_print: boolean;
9
+ background_colour: string;
10
+ cashout_method_id: null | string;
11
+ default_pay_exact: boolean;
12
+ denominations: string;
13
+ gateway_url: string;
14
+ name: string;
15
+ surcharge: string;
16
+ text_colour: string;
17
+ type: PaymentMethodTypeUnion;
18
+ updated_at: string;
19
+ use_rounding: boolean;
20
+ uuid: string;
21
+ }
22
+ export interface BasePaymentMethodRepository extends BaseRepository<LocalDatabasePaymentMethod> {
23
+ /**
24
+ * Retrieve all payment methods with the specified type
25
+ */
26
+ getByType(type: PaymentMethodTypeUnion | Array<PaymentMethodTypeUnion>): Promise<Array<LocalDatabasePaymentMethod>>;
27
+ }
@@ -0,0 +1,40 @@
1
+ import BaseRepository from "./BaseRepository.js";
2
+ import { BaseSearchableRepository } from "./BaseSearchableRepository.js";
3
+ type Override<Original, ToOverride> = Omit<Original, keyof ToOverride> & ToOverride;
4
+ export type PriceListRuleBaseUnion = "discount-percentage" | "discount-amount" | "discount-item-amount" | "cost-percentage" | "cost-amount" | "last-cost-percentage" | "last-cost-amount";
5
+ export type PriceListRuleUnion = PriceListRuleBaseUnion | "override";
6
+ export interface PriceListRulePrice {
7
+ quantity: string;
8
+ price: string;
9
+ }
10
+ export interface LocalDatabasePriceListFallback {
11
+ min_rule: "no-minimum" | PriceListRuleBaseUnion;
12
+ min_rule_amount: string;
13
+ rule: PriceListRuleBaseUnion;
14
+ rule_amount: string;
15
+ }
16
+ export interface LocalDatabasePriceListRule extends LocalDatabasePriceListFallback {
17
+ uuid: string;
18
+ }
19
+ export type LocalDatabasePriceListWithPricesRule = Override<LocalDatabasePriceListRule, {
20
+ min_rule: "no-minimum" | PriceListRuleUnion;
21
+ rule: PriceListRuleUnion;
22
+ min_prices: Array<PriceListRulePrice>;
23
+ prices: Array<PriceListRulePrice>;
24
+ }>;
25
+ export type PriceListItemTypeUnion = "products" | "categories" | "brands" | "families" | "tags";
26
+ export interface LocalDatabasePriceList {
27
+ active: boolean;
28
+ allow_higher_price: boolean;
29
+ brands: Array<LocalDatabasePriceListRule>;
30
+ categories: Array<LocalDatabasePriceListRule>;
31
+ families: Array<LocalDatabasePriceListWithPricesRule>;
32
+ tags: Array<LocalDatabasePriceListRule>;
33
+ excludes: Record<PriceListItemTypeUnion, Array<string>>;
34
+ fallback_rule: null | LocalDatabasePriceListFallback;
35
+ name: string;
36
+ products: Array<LocalDatabasePriceListWithPricesRule>;
37
+ uuid: string;
38
+ }
39
+ export type BasePriceListRepository = BaseRepository<LocalDatabasePriceList> & BaseSearchableRepository<LocalDatabasePriceList>;
40
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ import BaseRepository from "./BaseRepository.js";
2
+ export interface LocalDatabasePriceSet {
3
+ name: string;
4
+ uuid: string;
5
+ }
6
+ export type BasePriceSetRepository = BaseRepository<LocalDatabasePriceSet>;
@@ -0,0 +1 @@
1
+ export {};