@shopfront/types 0.0.1-alpha.8 → 0.0.1-alpha.9

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.
@@ -0,0 +1,2061 @@
1
+ // This file is automatically generated by publish-types.mjs
2
+ // Merged for alias: database
3
+
4
+ // External symbols resolved from imports
5
+ export interface KitchenShopfrontSale {
6
+ id: string;
7
+ status: "COMPLETED" | "INCOMPLETE" | "PARKED";
8
+ register: {
9
+ id: string;
10
+ outlet: {
11
+ id: string;
12
+ };
13
+ };
14
+ invoiceId: string;
15
+ note: string;
16
+ internalNote: string;
17
+ createdAt: string;
18
+ customer: null | {
19
+ firstName: string;
20
+ lastName: string;
21
+ };
22
+ items: Array<KitchenShopfrontItem>;
23
+ }
24
+
25
+ export interface KitchenShopfrontItem<
26
+ TItem extends KitchenSellableItem | KitchenShopfrontProduct = KitchenSellableItem | KitchenShopfrontProduct
27
+ > {
28
+ id: string;
29
+ quantity: number;
30
+ note: string;
31
+ kitchenReadyAt: null | string;
32
+ contains: Array<KitchenShopfrontItemContents>;
33
+ item: TItem;
34
+ }
35
+
36
+ export interface KitchenSellableItem {
37
+ id: string;
38
+ }
39
+
40
+ export interface KitchenShopfrontProduct {
41
+ id: string;
42
+ name: string;
43
+ category: null | {
44
+ id: string;
45
+ };
46
+ tags: Array<{
47
+ id: string;
48
+ }>;
49
+ }
50
+
51
+ export interface KitchenShopfrontItemContents {
52
+ id: string;
53
+ parentId: string | null;
54
+ quantity: number;
55
+ item: KitchenShopfrontProduct;
56
+ }
57
+
58
+ export enum UPLOAD_TYPES {
59
+ SALE = "sale",
60
+ UPDATE_SALE = "update-sale",
61
+ BARCODE = "barcode",
62
+ OPEN_REGISTER = "open-register",
63
+ CUSTOMER = "customer",
64
+ UPDATE_CUSTOMER = "update-customer",
65
+ EMAIL_RECEIPT = "email-receipt",
66
+ ACTION = "action",
67
+ TAKINGS = "takings",
68
+ VOID_SALE = "void-sale",
69
+ UNPARK_SALE = "unpark-sale",
70
+ CUSTOMER_PAYMENT = "customer-payment",
71
+ EMAIL_COMPONENT = "email-component",
72
+ CLOSE_REGISTER = "close-register",
73
+ STOCKTAKE_COUNT = "stocktake-count",
74
+ ERROR = "error",
75
+ SECURITY_EVENT = "security-event",
76
+ KITCHEN_ORDER = "kitchen-order",
77
+ }
78
+
79
+ /* eslint-disable */
80
+ // This file is automatically generated from Shopfront (generate:types). Manual changes will be overwritten.
81
+ export interface Options {
82
+ use_quantity_rate: boolean;
83
+ promotion_display_products: boolean;
84
+ promotion_display_categories: boolean;
85
+ promotion_display_brands: boolean;
86
+ promotion_display_families: boolean;
87
+ promotion_display_tags: boolean;
88
+ product_single_text: string;
89
+ product_case_text: string;
90
+ sell_cases: boolean;
91
+ find_on_lookup: boolean;
92
+ register_default_payment_method: string | null;
93
+ round_to: number;
94
+ prevent_blur: boolean;
95
+ register_offline_invoice_suffix: string;
96
+ invoice_width: number;
97
+ register_current_invoice_number: number;
98
+ team_message: string;
99
+ discount_require_reason: boolean;
100
+ default_sale_keys: string | null;
101
+ outlet_default_sale_keys: string | null;
102
+ register_default_sale_keys: string | null;
103
+ user_default_sale_keys: string | null;
104
+ register_default_receipt_template: string | null;
105
+ allow_cashout_without_sale: boolean;
106
+ sign_in_type: "type" | "click";
107
+ sign_in_require_password: boolean;
108
+ register_login_after_sale: boolean;
109
+ view_receipt_timeout: number;
110
+ outlet_enable_gift_cards: boolean;
111
+ outlet_gift_card_expiry_amount: number;
112
+ outlet_gift_card_expiry_period: "days" | "weeks" | "months" | "years";
113
+ outlet_gift_card_expiry_change: boolean;
114
+ share_gift_cards: boolean;
115
+ share_held_sales: boolean;
116
+ display_details_on_customer_add: boolean;
117
+ register_customer_display_left: number;
118
+ register_customer_display_top: number;
119
+ register_never_open_cash_drawer: boolean;
120
+ use_average_cost: boolean;
121
+ has_weighable_products: boolean;
122
+ register_training_sales_mode_enabled: boolean;
123
+ sign_in_mask_username: boolean;
124
+ timezone: string;
125
+ register_current_invoice_max: number | null;
126
+ outlet_accounts_flow_key: string;
127
+ register_customer_display: string;
128
+ keep_select_product_on_screen: boolean;
129
+ display_select_product_paginated: boolean;
130
+ outlet_email_receipt_template: string | null;
131
+ register_default_price_set: string | null;
132
+ outlet_use_global_cost: boolean;
133
+ register_safe_drop_amount: number;
134
+ register_print_receipt_on_refund: boolean;
135
+ integrate_liquid_mix: boolean;
136
+ register_integrated_receipts: boolean;
137
+ cross_promotion_count: boolean;
138
+ weight_price_labels: boolean;
139
+ note_on_held_sale: boolean;
140
+ use_components_and_packages: boolean;
141
+ outlet_update_last_cost_from_transfer: boolean;
142
+ outlet_update_average_cost_from_transfer: boolean;
143
+ outlet_send_transfers_using_average_cost: boolean;
144
+ outlet_default_statement: string;
145
+ price_change_notifications: boolean;
146
+ outlet_outlet_email: string;
147
+ cost_calculation_method: "last" | "mixed" | "average";
148
+ statement_reply_email: string;
149
+ register_next_invoice_batch: number | null;
150
+ family_distribution: "match_price_points" | "evenly";
151
+ date_format: string;
152
+ time_format: string;
153
+ start_of_week: "monday" | "tuesday" | "wednesday" | "thursday" | "friday" | "saturday" | "sunday";
154
+ profitability_display: "profit-percentage" | "markup";
155
+ register_consolidate_sale_lines: boolean;
156
+ future_price_time: number;
157
+ auto_logout_time: number;
158
+ auto_logout_during_sale: boolean;
159
+ register_open_display_on_open_register: boolean;
160
+ currency_code: string;
161
+ number_locale: string;
162
+ require_refund_reason: boolean;
163
+ use_barcode_templates: boolean;
164
+ show_order_prices_using_average_cost: boolean;
165
+ register_note_on_closure_discrepancy: boolean;
166
+ register_dark_mode: "light" | "dark" | "auto";
167
+ register_dedicated_promotion_worker: boolean;
168
+ sale_keys_position: "left" | "right" | "default";
169
+ outlet_sale_keys_position: "left" | "right" | "default";
170
+ register_sale_keys_position: "left" | "right" | "default";
171
+ user_sale_keys_position: "left" | "right" | "default";
172
+ enable_metcash_host_integration: boolean;
173
+ "outlet_metcash_credentials.customer_id": string;
174
+ "outlet_metcash_credentials.state_code": string;
175
+ "outlet_metcash_credentials.pillar_id": string;
176
+ "outlet_metcash_credentials.import_promotions": boolean;
177
+ "outlet_metcash_credentials.b2b_account": string;
178
+ "outlet_metcash_credentials.password": string;
179
+ "outlet_metcash_credentials.import_buying_periods": boolean;
180
+ rounding_mode: "redistribute" | "round";
181
+ search_customers_memory_level: "full" | "english" | "strict" | "offload";
182
+ search_products_memory_level: "full" | "english" | "strict" | "offload";
183
+ ui_logging_level: "essential" | "normal" | "verbose";
184
+ register_customer_display_mode: "presentation" | "popup";
185
+ require_cash_drawer_reason: boolean;
186
+ search_save_location: "indexeddb" | "none";
187
+ outlet_discount_below_cost_behaviour: "ignore" | "warn" | "prevent";
188
+ predefined_discount_reasons: Array<string>;
189
+ user_override_dark_mode: "default" | "light" | "dark" | "auto";
190
+ outlet_default_order_reviewers: Array<string>;
191
+ outlet_review_before_sending_order: boolean;
192
+ outlet_review_before_receiving_order: boolean;
193
+ outlet_review_before_sending_return: boolean;
194
+ outlet_review_before_sending_transfer: boolean;
195
+ outlet_review_before_receiving_transfer: boolean;
196
+ outlet_review_before_sending_credit_note: boolean;
197
+ outlet_review_receiving_quantity_discrepancy: boolean;
198
+ outlet_review_receiving_total_discrepancy: boolean;
199
+ outlet_review_receiving_cost_discrepancy: boolean;
200
+ outlet_minimum_order_review_approvals: number;
201
+ predefined_cash_drawer_reasons: Array<string>;
202
+ predefined_cash_out_reasons: Array<string>;
203
+ predefined_cash_in_reasons: Array<string>;
204
+ set_prices_based_on: "cost_calculation_method" | "last_cost" | "highest_cost";
205
+ sign_in_password_first_login: boolean;
206
+ register_invoice_number_mode: "incremental" | "random_string" | "random_number";
207
+ new_user_default_reporting_all_access: boolean;
208
+ flag_force_product_redesign: boolean;
209
+ "flag:use_css_tickets": boolean;
210
+ "flag:view_host_file": boolean;
211
+ }
212
+
213
+ export type OptionValue = string
214
+ | boolean
215
+ | number
216
+ | Record<string, unknown>
217
+ | undefined
218
+ | null
219
+ | Array<unknown>;
220
+
221
+ export const defaultOptions: Options = {
222
+ use_quantity_rate: false,
223
+ promotion_display_products: true,
224
+ promotion_display_categories: true,
225
+ promotion_display_brands: true,
226
+ promotion_display_families: true,
227
+ promotion_display_tags: true,
228
+ product_single_text: "Item",
229
+ product_case_text: "Case",
230
+ sell_cases: true,
231
+ find_on_lookup: false,
232
+ register_default_payment_method: null,
233
+ round_to: 0.05,
234
+ prevent_blur: true,
235
+ register_offline_invoice_suffix: "",
236
+ invoice_width: 0,
237
+ register_current_invoice_number: 1000,
238
+ team_message: "Need assistance? <a href=\"https://support.onshopfront.com\">Check out our help center</a>.",
239
+ discount_require_reason: false,
240
+ default_sale_keys: null,
241
+ outlet_default_sale_keys: "default",
242
+ register_default_sale_keys: "default",
243
+ user_default_sale_keys: "default",
244
+ register_default_receipt_template: null,
245
+ allow_cashout_without_sale: true,
246
+ sign_in_type: "click",
247
+ sign_in_require_password: true,
248
+ register_login_after_sale: false,
249
+ view_receipt_timeout: 10000,
250
+ outlet_enable_gift_cards: true,
251
+ outlet_gift_card_expiry_amount: 3,
252
+ outlet_gift_card_expiry_period: "years",
253
+ outlet_gift_card_expiry_change: true,
254
+ share_gift_cards: true,
255
+ share_held_sales: true,
256
+ display_details_on_customer_add: false,
257
+ register_customer_display_left: 0,
258
+ register_customer_display_top: 0,
259
+ register_never_open_cash_drawer: true,
260
+ use_average_cost: true,
261
+ has_weighable_products: false,
262
+ register_training_sales_mode_enabled: false,
263
+ sign_in_mask_username: false,
264
+ timezone: "Australia/Melbourne",
265
+ register_current_invoice_max: null,
266
+ outlet_accounts_flow_key: "",
267
+ register_customer_display: "",
268
+ keep_select_product_on_screen: false,
269
+ display_select_product_paginated: false,
270
+ outlet_email_receipt_template: null,
271
+ register_default_price_set: "default",
272
+ outlet_use_global_cost: true,
273
+ register_safe_drop_amount: Infinity,
274
+ register_print_receipt_on_refund: false,
275
+ integrate_liquid_mix: false,
276
+ register_integrated_receipts: true,
277
+ cross_promotion_count: true,
278
+ weight_price_labels: false,
279
+ note_on_held_sale: false,
280
+ use_components_and_packages: false,
281
+ outlet_update_last_cost_from_transfer: true,
282
+ outlet_update_average_cost_from_transfer: true,
283
+ outlet_send_transfers_using_average_cost: true,
284
+ outlet_default_statement: "",
285
+ price_change_notifications: false,
286
+ outlet_outlet_email: "noreply@onshopfront.com",
287
+ cost_calculation_method: "mixed",
288
+ statement_reply_email: "",
289
+ register_next_invoice_batch: null,
290
+ family_distribution: "match_price_points",
291
+ date_format: "DD/MM/YYYY",
292
+ time_format: "HH:mm:ss",
293
+ start_of_week: "monday",
294
+ profitability_display: "profit-percentage",
295
+ register_consolidate_sale_lines: true,
296
+ future_price_time: 0,
297
+ auto_logout_time: 0,
298
+ auto_logout_during_sale: false,
299
+ register_open_display_on_open_register: false,
300
+ currency_code: "AUD",
301
+ number_locale: "en-AU",
302
+ require_refund_reason: true,
303
+ use_barcode_templates: false,
304
+ show_order_prices_using_average_cost: false,
305
+ register_note_on_closure_discrepancy: false,
306
+ register_dark_mode: "light",
307
+ register_dedicated_promotion_worker: true,
308
+ sale_keys_position: "left",
309
+ outlet_sale_keys_position: "default",
310
+ register_sale_keys_position: "default",
311
+ user_sale_keys_position: "default",
312
+ enable_metcash_host_integration: false,
313
+ "outlet_metcash_credentials.customer_id": "",
314
+ "outlet_metcash_credentials.state_code": "",
315
+ "outlet_metcash_credentials.pillar_id": "",
316
+ "outlet_metcash_credentials.import_promotions": false,
317
+ "outlet_metcash_credentials.b2b_account": "",
318
+ "outlet_metcash_credentials.password": "",
319
+ "outlet_metcash_credentials.import_buying_periods": false,
320
+ rounding_mode: "redistribute",
321
+ search_customers_memory_level: "full",
322
+ search_products_memory_level: "full",
323
+ ui_logging_level: "essential",
324
+ register_customer_display_mode: "popup",
325
+ require_cash_drawer_reason: false,
326
+ search_save_location: "indexeddb",
327
+ outlet_discount_below_cost_behaviour: "ignore",
328
+ predefined_discount_reasons: [],
329
+ user_override_dark_mode: "default",
330
+ outlet_default_order_reviewers: [],
331
+ outlet_review_before_sending_order: false,
332
+ outlet_review_before_receiving_order: false,
333
+ outlet_review_before_sending_return: false,
334
+ outlet_review_before_sending_transfer: false,
335
+ outlet_review_before_receiving_transfer: false,
336
+ outlet_review_before_sending_credit_note: false,
337
+ outlet_review_receiving_quantity_discrepancy: false,
338
+ outlet_review_receiving_total_discrepancy: false,
339
+ outlet_review_receiving_cost_discrepancy: false,
340
+ outlet_minimum_order_review_approvals: 0,
341
+ predefined_cash_drawer_reasons: [],
342
+ predefined_cash_out_reasons: [],
343
+ predefined_cash_in_reasons: [],
344
+ set_prices_based_on: "cost_calculation_method",
345
+ sign_in_password_first_login: false,
346
+ register_invoice_number_mode: "incremental",
347
+ new_user_default_reporting_all_access: true,
348
+ flag_force_product_redesign: true,
349
+ "flag:use_css_tickets": false,
350
+ "flag:view_host_file": false,
351
+ };
352
+
353
+ /* eslint-disable */
354
+ // This file is automatically generated from Shopfront (generate:types). Manual changes will be overwritten.
355
+ export interface LocalDatabaseBrand {
356
+ mdb_id: number | null;
357
+ name: string;
358
+ uuid: string;
359
+ }
360
+
361
+ export interface LocalDatabaseCategory {
362
+ mdb_id: number | null;
363
+ name: string;
364
+ uuid: string;
365
+ metcash_msc: string | null;
366
+ }
367
+
368
+ export interface LocalDatabaseContact {
369
+ address_city: string;
370
+ address_country: string;
371
+ address_postcode: string;
372
+ address_state: string;
373
+ address_street_1: string;
374
+ address_street_2: string;
375
+ address_suburb: string;
376
+ email: string;
377
+ facebook: string;
378
+ fax: string;
379
+ mobile: string;
380
+ phone: string;
381
+ twitter: string;
382
+ uuid: string;
383
+ website: string;
384
+ }
385
+
386
+ export interface LocalDatabaseCustomer {
387
+ uuid: string;
388
+ account_limit: number | null;
389
+ account_receipt: string | null;
390
+ allow_account_sales: boolean;
391
+ autoprint_account_receipt: boolean;
392
+ autoprint_receipt: boolean;
393
+ autoprint_parked_receipt: boolean;
394
+ billing: LocalDatabaseContact;
395
+ billing_contact_id: string;
396
+ birthday: string | null;
397
+ business_number: string;
398
+ client_id: string;
399
+ code: string;
400
+ comments: string;
401
+ company: string;
402
+ current_owing: number;
403
+ customer_group_id: string | null;
404
+ delivery: LocalDatabaseContact;
405
+ delivery_contact_id: string;
406
+ disable_promotions: boolean;
407
+ email: string;
408
+ first_name: string;
409
+ gender: string;
410
+ invoice_message: string;
411
+ last_name: string;
412
+ loyalty: boolean;
413
+ loyalty_points: number;
414
+ loyalty_rate: number | null;
415
+ merged_into: string | null;
416
+ override_customer_group: boolean;
417
+ pricelist_id: string | null;
418
+ receipt: string | null;
419
+ require_order_reference: boolean;
420
+ full_name: string;
421
+ name_index: Array<string>;
422
+ phones: Array<string>;
423
+ }
424
+
425
+ export interface LocalDatabaseCustomerDisplay {
426
+ idle_display: string;
427
+ main_colour: string;
428
+ name: string;
429
+ sale_display: string;
430
+ text_colour: string;
431
+ uuid: string;
432
+ }
433
+
434
+ export interface LocalDatabaseCustomerGroup {
435
+ account_limit: number | null;
436
+ account_receipt_id: string | null;
437
+ allow_account_sales: boolean;
438
+ auto_email_receipt: boolean;
439
+ autoprint_account_receipt: boolean;
440
+ autoprint_receipt: boolean;
441
+ autoprint_parked_receipt: boolean;
442
+ credit_terms: Array<string> | null;
443
+ disable_promotions: boolean;
444
+ email_receipt_id: string | null;
445
+ loyalty: boolean;
446
+ loyalty_rate: number | null;
447
+ name: string;
448
+ pricelist_id: string | null;
449
+ statement_template_id: string | null;
450
+ require_order_reference: boolean;
451
+ uuid: string;
452
+ }
453
+
454
+ export interface LocalDatabaseFamily {
455
+ mdb_id: number | null;
456
+ name: string;
457
+ uuid: string;
458
+ }
459
+
460
+ export interface LocalDatabaseGiftCard {
461
+ client_id: string;
462
+ code: string;
463
+ current_amount: number;
464
+ expiry: string;
465
+ original_amount: number;
466
+ outlet_id: string;
467
+ status: "active" | "cancelled" | "pending";
468
+ uuid: string;
469
+ }
470
+
471
+ export interface LocalDatabaseKitchenScreen {
472
+ uuid: string;
473
+ name: string;
474
+ rules: {
475
+ ready: "NOT_DONE"
476
+ | "NOT_STARTED"
477
+ | "STARTED"
478
+ | "DONE",
479
+ categories: Array<string>,
480
+ tags: Array<string>,
481
+ registers: Array<string>,
482
+ outlets: Array<string>,
483
+ };
484
+ }
485
+
486
+ export interface LocalDatabaseOutlet {
487
+ uuid: string;
488
+ loyalty_enabled: boolean;
489
+ loyalty_name: string;
490
+ has_kitchen_screen: boolean;
491
+ name: string;
492
+ business_number: string;
493
+ contact: LocalDatabaseContact | null;
494
+ logo: string | null;
495
+ settings: Record<string, OptionValue>;
496
+ ticketing_price_set_id: string | null;
497
+ }
498
+
499
+ export interface LocalDatabasePageRule {
500
+ type: "PRODUCT_WIZARD" | "CUSTOMER_WIZARD" | "PROMOTION_WIZARD";
501
+ rule: string;
502
+ }
503
+
504
+ export interface LocalDatabasePaymentMethod {
505
+ actual_denominations: string;
506
+ allow_cash_out: boolean;
507
+ always_open_drawer: boolean;
508
+ always_print: boolean;
509
+ background_colour: string;
510
+ cashout_method_id: string | null;
511
+ dark_mode_background_colour: string;
512
+ dark_mode_text_colour: string;
513
+ default_pay_exact: boolean;
514
+ gateway_url: string;
515
+ name: string;
516
+ surcharge: number;
517
+ text_colour: string;
518
+ action: string;
519
+ type: "global"
520
+ | "cash"
521
+ | "eftpos"
522
+ | "giftcard"
523
+ | "voucher"
524
+ | "cheque"
525
+ | "pc-eftpos"
526
+ | "linkly-vaa"
527
+ | "direct-deposit"
528
+ | "tyro"
529
+ | "custom";
530
+ use_rounding: boolean;
531
+ uuid: string;
532
+ }
533
+
534
+ export interface LocalDatabasePriceSet {
535
+ name: string;
536
+ uuid: string;
537
+ parent_id: string | null;
538
+ }
539
+
540
+ export interface LocalDatabaseSyncablePriceListExclude {
541
+ brands: Array<string>;
542
+ categories: Array<string>;
543
+ families: Array<string>;
544
+ products: Array<string>;
545
+ tags: Array<string>;
546
+ }
547
+
548
+ export interface LocalDatabasePriceList {
549
+ active: boolean;
550
+ allow_higher_price: boolean;
551
+ allow_discounting_promotions: boolean;
552
+ brands: Array<{
553
+ min_rule: "no-minimum"
554
+ | "discount-percentage"
555
+ | "discount-amount"
556
+ | "discount-item-amount"
557
+ | "cost-percentage"
558
+ | "cost-amount"
559
+ | "last-cost-percentage"
560
+ | "last-cost-amount",
561
+ min_rule_amount: number,
562
+ rule: "discount-percentage"
563
+ | "discount-amount"
564
+ | "discount-item-amount"
565
+ | "cost-percentage"
566
+ | "cost-amount"
567
+ | "last-cost-percentage"
568
+ | "last-cost-amount",
569
+ rule_amount: number,
570
+ uuid: string,
571
+ }>;
572
+ categories: Array<{
573
+ min_rule: "no-minimum"
574
+ | "discount-percentage"
575
+ | "discount-amount"
576
+ | "discount-item-amount"
577
+ | "cost-percentage"
578
+ | "cost-amount"
579
+ | "last-cost-percentage"
580
+ | "last-cost-amount",
581
+ min_rule_amount: number,
582
+ rule: "discount-percentage"
583
+ | "discount-amount"
584
+ | "discount-item-amount"
585
+ | "cost-percentage"
586
+ | "cost-amount"
587
+ | "last-cost-percentage"
588
+ | "last-cost-amount",
589
+ rule_amount: number,
590
+ uuid: string,
591
+ }>;
592
+ excludes: LocalDatabaseSyncablePriceListExclude;
593
+ fallback_rule: {
594
+ min_rule: "no-minimum"
595
+ | "discount-percentage"
596
+ | "discount-amount"
597
+ | "discount-item-amount"
598
+ | "cost-percentage"
599
+ | "cost-amount"
600
+ | "last-cost-percentage"
601
+ | "last-cost-amount",
602
+ min_rule_amount: number,
603
+ rule: "discount-percentage"
604
+ | "discount-amount"
605
+ | "discount-item-amount"
606
+ | "cost-percentage"
607
+ | "cost-amount"
608
+ | "last-cost-percentage"
609
+ | "last-cost-amount",
610
+ rule_amount: number,
611
+ } | null;
612
+ families: Array<{
613
+ min_rule: "no-minimum"
614
+ | "discount-percentage"
615
+ | "discount-amount"
616
+ | "discount-item-amount"
617
+ | "cost-percentage"
618
+ | "cost-amount"
619
+ | "last-cost-percentage"
620
+ | "last-cost-amount"
621
+ | "override",
622
+ min_rule_amount: number,
623
+ rule: "discount-percentage"
624
+ | "discount-amount"
625
+ | "discount-item-amount"
626
+ | "cost-percentage"
627
+ | "cost-amount"
628
+ | "last-cost-percentage"
629
+ | "last-cost-amount"
630
+ | "override",
631
+ rule_amount: number,
632
+ min_prices: Array<{
633
+ quantity: number,
634
+ price: number,
635
+ }>,
636
+ prices: Array<{
637
+ quantity: number,
638
+ price: number,
639
+ }>,
640
+ uuid: string,
641
+ }>;
642
+ name: string;
643
+ products: Array<{
644
+ min_rule: "no-minimum"
645
+ | "discount-percentage"
646
+ | "discount-amount"
647
+ | "discount-item-amount"
648
+ | "cost-percentage"
649
+ | "cost-amount"
650
+ | "last-cost-percentage"
651
+ | "last-cost-amount"
652
+ | "override",
653
+ min_rule_amount: number,
654
+ rule: "discount-percentage"
655
+ | "discount-amount"
656
+ | "discount-item-amount"
657
+ | "cost-percentage"
658
+ | "cost-amount"
659
+ | "last-cost-percentage"
660
+ | "last-cost-amount"
661
+ | "override",
662
+ rule_amount: number,
663
+ min_prices: Array<{
664
+ quantity: number,
665
+ price: number,
666
+ }>,
667
+ prices: Array<{
668
+ quantity: number,
669
+ price: number,
670
+ }>,
671
+ uuid: string,
672
+ }>;
673
+ tags: Array<{
674
+ min_rule: "no-minimum"
675
+ | "discount-percentage"
676
+ | "discount-amount"
677
+ | "discount-item-amount"
678
+ | "cost-percentage"
679
+ | "cost-amount"
680
+ | "last-cost-percentage"
681
+ | "last-cost-amount",
682
+ min_rule_amount: number,
683
+ rule: "discount-percentage"
684
+ | "discount-amount"
685
+ | "discount-item-amount"
686
+ | "cost-percentage"
687
+ | "cost-amount"
688
+ | "last-cost-percentage"
689
+ | "last-cost-amount",
690
+ rule_amount: number,
691
+ uuid: string,
692
+ }>;
693
+ uuid: string;
694
+ }
695
+
696
+ export interface LocalDatabaseBarcode {
697
+ code: string;
698
+ quantity: string;
699
+ template: string | null;
700
+ }
701
+
702
+ export interface LocalDatabaseInventory {
703
+ outlet_id: string;
704
+ single_level: number;
705
+ case_level: number;
706
+ single_reorder_level: number;
707
+ case_reorder_level: number;
708
+ single_reorder_amount: number;
709
+ case_reorder_amount: number;
710
+ single_reorder_limit: number | null;
711
+ case_reorder_limit: number | null;
712
+ single_max_quantity: number | null;
713
+ case_max_quantity: number | null;
714
+ reorder_rounding: "none"
715
+ | "ceiling"
716
+ | "floor"
717
+ | "natural";
718
+ }
719
+
720
+ export interface LocalDatabaseLoyalty {
721
+ classification_id: string;
722
+ classification_type: string;
723
+ loyalty_value: number;
724
+ outlet_id: string;
725
+ quantity: number;
726
+ redeem_value: number | null;
727
+ }
728
+
729
+ export interface LocalDatabasePrice {
730
+ price: number;
731
+ price_set_id: string | null;
732
+ quantity: number;
733
+ }
734
+
735
+ export interface LocalDatabaseProduct {
736
+ additional: Record<string, string>;
737
+ average_cost: string;
738
+ alternate_names: Array<{
739
+ host_connection_id: string,
740
+ quantity: number | null,
741
+ name: string,
742
+ }>;
743
+ barcodes: Array<LocalDatabaseBarcode>;
744
+ brand_id: string | null;
745
+ case_quantity: number;
746
+ category_id: string | null;
747
+ components: Array<{
748
+ add_price: number,
749
+ quantity: number,
750
+ remove_price: number,
751
+ uuid: string,
752
+ }>;
753
+ core_supplier_id: string | null;
754
+ cost: string;
755
+ cost_percentage: boolean;
756
+ costs: Array<{
757
+ outlet_id: string,
758
+ average_cost: string,
759
+ last_cost: string,
760
+ }>;
761
+ description: string;
762
+ family_id: string | null;
763
+ image: string | null;
764
+ inventory: Array<LocalDatabaseInventory>;
765
+ last_cost: string;
766
+ last_supplier_id: string | null;
767
+ loyalty_rates: Array<LocalDatabaseLoyalty>;
768
+ mdb_id: number | null;
769
+ name: string;
770
+ order_notes: string;
771
+ invoice_notes: string;
772
+ parents: Array<string>;
773
+ prices: Array<LocalDatabasePrice>;
774
+ request_price: boolean;
775
+ request_quantity: boolean;
776
+ prevent_manual_discounts: boolean;
777
+ ignore_price_host_changes: boolean;
778
+ ignore_barcode_host_changes: boolean;
779
+ status: "active"
780
+ | "inactive"
781
+ | "not-selling"
782
+ | "not-purchasing";
783
+ suppliers: Array<{
784
+ minimum_order_quantity: number,
785
+ supplier_code: string,
786
+ uuid: string,
787
+ }>;
788
+ tags: Array<string>;
789
+ tax_rate: {
790
+ uuid: string,
791
+ amount: number,
792
+ } | null;
793
+ cost_tax_rate: {
794
+ amount: number,
795
+ uuid: string,
796
+ } | null;
797
+ track_inventory: boolean;
798
+ type: "normal"
799
+ | "basket"
800
+ | "voucher"
801
+ | "package"
802
+ | "component"
803
+ | "integrated";
804
+ use_barcode_templates: boolean;
805
+ use_scales: boolean;
806
+ uuid: string;
807
+ name_index: Array<string>;
808
+ supplier_ids: Array<string>;
809
+ supplier_codes: Array<string>;
810
+ code_index: Array<string>;
811
+ }
812
+
813
+ export interface LocalDatabaseSyncablePromotionCriteriaItem {
814
+ id: string;
815
+ type: string;
816
+ rebate: number;
817
+ exclude: boolean;
818
+ }
819
+
820
+ export interface LocalDatabasePromotionCriteria {
821
+ type: "sell-item"
822
+ | "sell-total"
823
+ | "discount-item-amount"
824
+ | "discount-total-amount"
825
+ | "discount-percentage"
826
+ | "sell-rate"
827
+ | "quantity-only";
828
+ quantity_type: "exact" | "more";
829
+ buy_amount_type: "quantity" | "amount";
830
+ buy_amount: number;
831
+ buy_amount_max: number | null;
832
+ discount_amount: number;
833
+ min_quantity: number | null;
834
+ optional: boolean;
835
+ mixed_only: boolean;
836
+ exclude_price_points: boolean;
837
+ discount_everyday_promotions: boolean;
838
+ exclude_count_quantity: boolean;
839
+ items: Array<LocalDatabaseSyncablePromotionCriteriaItem>;
840
+ products: Array<{ uuid: string; rebate: number; }>;
841
+ brands: Array<{ uuid: string; rebate: number; }>;
842
+ categories: Array<{ uuid: string; rebate: number; }>;
843
+ families: Array<{ uuid: string; rebate: number; }>;
844
+ tags: Array<{ uuid: string; rebate: number; }>;
845
+ allItems: null | number;
846
+ excludes: {
847
+ products: Array<string>;
848
+ categories: Array<string>;
849
+ brands: Array<string>;
850
+ families: Array<string>;
851
+ tags: Array<string>;
852
+ };
853
+ }
854
+
855
+ export interface LocalDatabasePromotion {
856
+ uuid: string;
857
+ name: string;
858
+ mdb_id: number | null;
859
+ express: boolean;
860
+ promotion_category_id: string | null;
861
+ active: boolean;
862
+ start: string | null;
863
+ end: string | null;
864
+ available_to: Array<string> | null;
865
+ mix_criteria: boolean;
866
+ sale_max_application_count: number | null;
867
+ criteria: Array<LocalDatabasePromotionCriteria>;
868
+ outlets: Array<string>;
869
+ has_schedule: boolean;
870
+ activated_by: string | null;
871
+ }
872
+
873
+ export interface LocalDatabasePromotionCategory {
874
+ name: string;
875
+ uuid: string;
876
+ show_on_order: boolean;
877
+ source: string | null;
878
+ }
879
+
880
+ export interface LocalDatabaseReceipt {
881
+ accountReceipt: boolean;
882
+ components: string;
883
+ padding: {
884
+ top: number | null,
885
+ left: number | null,
886
+ right: number | null,
887
+ bottom: number | null,
888
+ } | null;
889
+ name: string;
890
+ receiptWidth: number;
891
+ type: "receipt-text"
892
+ | "receipt-full"
893
+ | "a4"
894
+ | "email";
895
+ uuid: string;
896
+ attachments: Array<{
897
+ name: string,
898
+ receipt: string,
899
+ }> | null;
900
+ }
901
+
902
+ export interface LocalDatabaseSyncableRegisterSurcharge {
903
+ id: number;
904
+ type: "PERCENTAGE" | "FIXED";
905
+ amount: number;
906
+ taxRate: string | null;
907
+ day: "MONDAY"
908
+ | "TUESDAY"
909
+ | "WEDNESDAY"
910
+ | "THURSDAY"
911
+ | "FRIDAY"
912
+ | "SATURDAY"
913
+ | "SUNDAY";
914
+ start: string;
915
+ end: string;
916
+ name: string;
917
+ appliesTo: Array<{
918
+ id: string,
919
+ type: "Category" | "Tag",
920
+ }> | null;
921
+ }
922
+
923
+ export interface LocalDatabaseRegister {
924
+ uuid: string;
925
+ closure_print_settings: {
926
+ account: "table" | "total" | "none",
927
+ account_payments: "table" | "total" | "none",
928
+ discounts: "table" | "total" | "none",
929
+ gift_cards_redeemed: "table" | "total" | "none",
930
+ gift_cards_sold: "table" | "total" | "none",
931
+ movements: "table" | "total" | "none",
932
+ payments: "table" | "total" | "none",
933
+ refunds: "table" | "total" | "none",
934
+ tax: "table" | "total" | "none",
935
+ loyalty: "table" | "total" | "none",
936
+ notes: boolean,
937
+ tags: boolean,
938
+ payment_subtypes: boolean,
939
+ statistics: boolean,
940
+ };
941
+ close_register_tags: Array<string>;
942
+ float: {
943
+ monday: number,
944
+ tuesday: number,
945
+ wednesday: number,
946
+ thursday: number,
947
+ friday: number,
948
+ saturday: number,
949
+ sunday: number,
950
+ };
951
+ surcharges: Array<LocalDatabaseSyncableRegisterSurcharge> | null;
952
+ surcharging_enabled: boolean;
953
+ name: string;
954
+ outlet_id: string;
955
+ payment_methods: Array<string>;
956
+ settings: Record<string, OptionValue>;
957
+ }
958
+
959
+ export interface LocalDatabaseSaleKey {
960
+ uuid: string;
961
+ name: string;
962
+ keys: Record<string, any>;
963
+ }
964
+
965
+ export interface LocalDatabaseSupplier {
966
+ uuid: string;
967
+ account_number: string;
968
+ business_number: string;
969
+ comments: string;
970
+ contact: LocalDatabaseContact;
971
+ default_order_tax: "inc_tax" | "ex_tax" | "ex_wet";
972
+ distribute_fees: "proportionally" | "evenly";
973
+ distribute_freight: "items" | "cases" | "mixed";
974
+ email_format: "inline" | "csv" | "pdf";
975
+ fee_amount: number;
976
+ mdb_id: number | null;
977
+ name: string;
978
+ order_automatic_email: boolean;
979
+ allow_order_below_minimum: boolean;
980
+ order_notes: string;
981
+ order_internal_notes: string;
982
+ freight_included_on_invoices: boolean;
983
+ freight_tax_id: string | null;
984
+ fees_tax_id: string | null;
985
+ minimum_order_value: number | null;
986
+ maximum_order_value: number | null;
987
+ status: "ACTIVE" | "INACTIVE";
988
+ default_days_until_due: number | null;
989
+ freight_fixed_cost_per_case: number | null;
990
+ }
991
+
992
+ export interface LocalDatabaseTag {
993
+ mdb_id: number | null;
994
+ name: string;
995
+ uuid: string;
996
+ }
997
+
998
+ export interface LocalDatabaseTaxRate {
999
+ amount: number;
1000
+ mdbId: number | null;
1001
+ name: string;
1002
+ uuid: string;
1003
+ }
1004
+
1005
+ export interface LocalDatabaseTransferee {
1006
+ uuid: string;
1007
+ name: string;
1008
+ email_format: "inline" | "csv" | "pdf";
1009
+ order_automatic_email: boolean;
1010
+ contact: LocalDatabaseContact;
1011
+ }
1012
+
1013
+ export interface LocalDatabaseUser {
1014
+ dashboard: string;
1015
+ email: string;
1016
+ image: string;
1017
+ is_api_user: boolean;
1018
+ last_login_at: string | null;
1019
+ name: string;
1020
+ permissions: Record<string, number> | null;
1021
+ scope: Record<string, number>;
1022
+ phone: string;
1023
+ quick_menu: Array<{
1024
+ external: boolean,
1025
+ id: number,
1026
+ name: string,
1027
+ url: string,
1028
+ }>;
1029
+ role_id: string | null;
1030
+ sale_keys: string;
1031
+ sale_keys_position: "default" | "left" | "right";
1032
+ dark_mode: "default"
1033
+ | "dark"
1034
+ | "light"
1035
+ | "auto";
1036
+ favourite_fields: Record<"product", Array<string>>;
1037
+ username: string;
1038
+ uuid: string;
1039
+ }
1040
+
1041
+ export abstract class BaseRepository<DataType extends object = object, IdType = string> {
1042
+ public abstract all(orderBy?: string): Promise<Array<DataType>>;
1043
+ public abstract get(uuid: IdType): Promise<DataType>;
1044
+ public abstract put(item: Array<DataType> | DataType): Promise<IdType>;
1045
+ public abstract update(uuid: IdType, changes: Partial<DataType>): Promise<void>;
1046
+ public abstract count(): Promise<number>;
1047
+ public abstract empty(): Promise<void>;
1048
+ public abstract delete(items: IdType | Array<IdType>): Promise<void>;
1049
+ public abstract each(callback: (item: DataType) => void): Promise<void>;
1050
+
1051
+ /**
1052
+ * Access the source data directly, ensure instanceof is used.
1053
+ * TODO: Remove this.
1054
+ */
1055
+ public abstract raw(): any;
1056
+ }
1057
+
1058
+
1059
+ export interface BaseSearchableRepository<DataType extends object, SearchOptions = undefined> {
1060
+ search(needle: string, options?: Partial<SearchOptions>): Promise<Array<DataType>>;
1061
+ }
1062
+
1063
+
1064
+ export interface LocalDatabaseApplication {
1065
+ auth: string;
1066
+ embedded: string;
1067
+ id: string;
1068
+ name: string;
1069
+ logo: string;
1070
+ expiryDate: string;
1071
+ }
1072
+
1073
+ export type BaseApplicationRepository =
1074
+ BaseRepository<LocalDatabaseApplication> &
1075
+ BaseSearchableRepository<LocalDatabaseApplication>;
1076
+
1077
+
1078
+ export interface LocalDatabaseBarcodeTemplate {
1079
+ id: number;
1080
+ name: string;
1081
+ recalculate_quantity: boolean;
1082
+ template: string;
1083
+ }
1084
+
1085
+ export type BaseBarcodeTemplateRepository = BaseRepository<LocalDatabaseBarcodeTemplate, number>;
1086
+
1087
+
1088
+ export type BaseCategoryRepository =
1089
+ BaseRepository<LocalDatabaseCategory> &
1090
+ BaseSearchableRepository<LocalDatabaseCategory>;
1091
+
1092
+
1093
+ export interface LocalDatabaseClassification {
1094
+ name: string;
1095
+ uuid: string;
1096
+ mdb_id: number | null;
1097
+ }
1098
+
1099
+ export type BaseClassificationRepository =
1100
+ BaseRepository<LocalDatabaseClassification> &
1101
+ BaseSearchableRepository<LocalDatabaseClassification>;
1102
+
1103
+
1104
+ export type BaseCustomerDisplayRepository = BaseRepository<LocalDatabaseCustomerDisplay>;
1105
+
1106
+
1107
+ export type BaseCustomerGroupRepository =
1108
+ BaseRepository<LocalDatabaseCustomerGroup> &
1109
+ BaseSearchableRepository<LocalDatabaseCustomerGroup>;
1110
+
1111
+
1112
+ export interface CustomerRepositorySearchOptions {
1113
+ name: boolean;
1114
+ code: boolean;
1115
+ email: boolean;
1116
+ phone: boolean;
1117
+ company: boolean;
1118
+ customerGroups: Array<string>;
1119
+ exactMatch: boolean;
1120
+ sort: boolean;
1121
+ limit: number;
1122
+ filter: ((customer: LocalDatabaseCustomer) => boolean) | undefined;
1123
+ }
1124
+
1125
+ export interface BaseCustomerRepository extends
1126
+ BaseRepository<LocalDatabaseCustomer>,
1127
+ BaseSearchableRepository<
1128
+ LocalDatabaseCustomer,
1129
+ CustomerRepositorySearchOptions
1130
+ >
1131
+ {
1132
+ getByCustomerGroup(customerGroupId: string): Promise<Array<LocalDatabaseCustomer>>;
1133
+ getByPriceList(priceListId: string): Promise<Array<LocalDatabaseCustomer>>;
1134
+ }
1135
+
1136
+
1137
+ export abstract class BaseDataSource implements DataSourceTables {
1138
+ // Tables
1139
+ public products!: BaseProductRepository;
1140
+ public customers!: BaseCustomerRepository;
1141
+ public customerGroups!: BaseCustomerGroupRepository;
1142
+ public promotions!: BasePromotionRepository;
1143
+ public promotionCategories!: BasePromotionCategoryRepository;
1144
+ public users!: BaseUserRepository;
1145
+ public priceLists!: BasePriceListRepository;
1146
+ public paymentMethods!: BasePaymentMethodRepository;
1147
+ public salesKeys!: BaseSalesKeyRepository;
1148
+ public receipts!: BaseReceiptRepository;
1149
+ public giftCards!: BaseGiftCardRepository;
1150
+ public loyalty!: BaseLoyaltyRepository;
1151
+ public customerDisplays!: BaseCustomerDisplayRepository;
1152
+ public sales!: BaseSalesRepository;
1153
+ public brands!: BaseClassificationRepository;
1154
+ public categories!: BaseCategoryRepository;
1155
+ public families!: BaseClassificationRepository;
1156
+ public tags!: BaseClassificationRepository;
1157
+ public outlets!: BaseOutletRepository;
1158
+ public registers!: BaseRegisterRepository;
1159
+ public uploads!: BaseUploadRepository;
1160
+ public taxRates!: BaseTaxRateRepository;
1161
+ public takings!: BaseTakingsRepository;
1162
+ public pageRules!: BasePageRuleRepository;
1163
+ public suppliers!: BaseSupplierRepository;
1164
+ public priceSets!: BasePriceSetRepository;
1165
+ public transferees!: BaseTransfereeRepository;
1166
+ public movements!: BaseMovementRepository;
1167
+ public stocktakes!: BaseStocktakeRepository;
1168
+ public stocktakeScanned!: BaseStocktakeScannedRepository;
1169
+ public stocktakeAccumulated!: BaseStocktakeAccumulatedRepository;
1170
+ public applications!: BaseApplicationRepository;
1171
+ public barcodeTemplates!: BaseBarcodeTemplateRepository;
1172
+ public vendorConnections!: BaseVendorConnectionRepository;
1173
+ public lockedResources!: BaseLockedResourceRepository;
1174
+ public system!: BaseSystemRepository;
1175
+ public enterprises!: BaseEnterpriseRepository;
1176
+ public kitchenOrders!: BaseKitchenOrderRepository;
1177
+ public kitchenScreens!: BaseKitchenScreenRepository;
1178
+
1179
+ // Methods
1180
+ public abstract transaction(table: Array<keyof DataSourceTables>, callback: () => Promise<void>): Promise<void>;
1181
+ public abstract clearDatabase(): Promise<void>;
1182
+ public abstract getVersion(): Promise<number | undefined>;
1183
+ }
1184
+
1185
+
1186
+ export interface LocalDatabaseEnterprise {
1187
+ auth: string;
1188
+ id: string;
1189
+ name: string;
1190
+ }
1191
+
1192
+ export type BaseEnterpriseRepository =
1193
+ BaseRepository<LocalDatabaseEnterprise> &
1194
+ BaseSearchableRepository<LocalDatabaseEnterprise>;
1195
+
1196
+
1197
+
1198
+
1199
+ export interface BaseGiftCardRepository extends BaseRepository<LocalDatabaseGiftCard> {
1200
+ getByCode(code: string): Promise<Array<LocalDatabaseGiftCard>>;
1201
+ }
1202
+
1203
+
1204
+ export interface KitchenOrderItemComponent {
1205
+ id: string;
1206
+ name: string;
1207
+ quantity: number;
1208
+ components: Array<KitchenOrderItemComponent>;
1209
+ }
1210
+
1211
+ export interface KitchenOrderItem {
1212
+ id: string; // This is a unique ID for the item on the order
1213
+ product: string; // The general ID of the item
1214
+ ready: boolean;
1215
+ category: string;
1216
+ tags: Array<string>;
1217
+ name: string;
1218
+ quantity: number;
1219
+ note: string;
1220
+ components: Array<KitchenOrderItemComponent>;
1221
+ }
1222
+
1223
+ export interface KitchenOrder {
1224
+ id: string; // This is a unique ID for the order, not necessarily the sale ID
1225
+ register: string;
1226
+ outlet: string;
1227
+ invoiceId: string;
1228
+ note: string;
1229
+ internalNote: string;
1230
+ saleTime: string;
1231
+ customerName: null | string;
1232
+ items: Array<KitchenOrderItem>;
1233
+ }
1234
+
1235
+ export interface LocalKitchenOrder {
1236
+ version: number;
1237
+ id: string;
1238
+ order: KitchenOrder;
1239
+ }
1240
+
1241
+ export interface BaseKitchenOrderRepository extends BaseRepository<LocalKitchenOrder> {
1242
+ removeVersionsBefore(version: number): Promise<void>;
1243
+ }
1244
+
1245
+
1246
+ export type KitchenDisplayRuleReady = "NOT_DONE" | "NOT_STARTED" | "STARTED" | "DONE";
1247
+
1248
+ export interface KitchenDisplayFilterRules {
1249
+ ready: KitchenDisplayRuleReady;
1250
+ categories: Array<string>;
1251
+ tags: Array<string>;
1252
+ registers: Array<string>;
1253
+ outlets: Array<string>;
1254
+ }
1255
+
1256
+ export interface LocalKitchenScreen {
1257
+ uuid: string;
1258
+ name: string;
1259
+ rules: KitchenDisplayFilterRules;
1260
+ }
1261
+
1262
+ export interface BaseKitchenScreenRepository extends BaseRepository<LocalKitchenScreen> {}
1263
+
1264
+
1265
+ export interface LocalDatabaseLockedResource {
1266
+ type: string;
1267
+ uuid: string;
1268
+ resource: string;
1269
+ }
1270
+
1271
+ export interface BaseLockedResourceRepository extends BaseRepository<
1272
+ LocalDatabaseLockedResource
1273
+ > {
1274
+ getByResource(resource: string): Promise<LocalDatabaseLockedResource>;
1275
+ }
1276
+
1277
+
1278
+ export type LoyaltyUnion = "brand" | "category" | "family" | "tag" | "product";
1279
+
1280
+ export interface LocalDatabaseOutletLoyalty {
1281
+ id: number;
1282
+ loyalty_value: null | string; // TODO: Make a number
1283
+ quantity: string; // TODO: Make a number
1284
+ redeem_value: null | string; // TODO: Make a number
1285
+ type: LoyaltyUnion;
1286
+ uuid: string; // The ID of the classification
1287
+ }
1288
+
1289
+ export interface BaseLoyaltyRepository extends BaseRepository<LocalDatabaseOutletLoyalty, number> {
1290
+ getByType(id: string, type: LoyaltyUnion): Promise<Array<LocalDatabaseOutletLoyalty>>;
1291
+ }
1292
+
1293
+
1294
+ export interface LocalDatabaseMovement {
1295
+ amount: string; // TODO: Make a number
1296
+ denominations: Array<{
1297
+ direction: "IN" | "OUT";
1298
+ denomination: number;
1299
+ amount: number;
1300
+ }>;
1301
+ paymentMethod: string;
1302
+ reason: string;
1303
+ register: string;
1304
+ timestamp: string;
1305
+ user: string;
1306
+ uuid: string;
1307
+ }
1308
+
1309
+ export type BaseMovementRepository = BaseRepository<LocalDatabaseMovement>;
1310
+
1311
+
1312
+ export interface BaseOutletRepository extends BaseRepository<LocalDatabaseOutlet> {
1313
+ update(id: string, changes: Partial<LocalDatabaseOutlet>): Promise<void>;
1314
+ }
1315
+
1316
+
1317
+ export abstract class BasePageRuleRepository extends BaseRepository<LocalDatabasePageRule> {}
1318
+
1319
+
1320
+ export type PaymentMethodTypeUnion = LocalDatabasePaymentMethod["type"];
1321
+
1322
+ export interface BasePaymentMethodRepository extends BaseRepository<LocalDatabasePaymentMethod> {
1323
+ getByType(type: PaymentMethodTypeUnion | Array<PaymentMethodTypeUnion>): Promise<Array<LocalDatabasePaymentMethod>>;
1324
+ }
1325
+
1326
+
1327
+ export type PriceListRuleUnion = LocalDatabasePriceList["products"][number]["rule"];
1328
+ export type PriceListRuleBaseUnion = Omit<PriceListRuleUnion, "override">;
1329
+
1330
+ export type LocalDatabasePriceListFallback = LocalDatabasePriceList["fallback_rule"];
1331
+
1332
+ export type LocalDatabasePriceListRule = LocalDatabasePriceListFallback & {
1333
+ uuid: string;
1334
+ };
1335
+
1336
+ export type LocalDatabasePriceListWithPricesRule = LocalDatabasePriceList["products"][number];
1337
+
1338
+ export type PriceListItemTypeUnion = keyof LocalDatabaseSyncablePriceListExclude;
1339
+
1340
+ export interface BasePriceListRepository extends
1341
+ BaseRepository<LocalDatabasePriceList>,
1342
+ BaseSearchableRepository<LocalDatabasePriceList>
1343
+ {}
1344
+
1345
+
1346
+ export type BasePriceSetRepository = BaseRepository<LocalDatabasePriceSet>;
1347
+
1348
+
1349
+ export type LocalDatabaseCost = LocalDatabaseProduct["costs"][number];
1350
+ export type ProductTypeUnion = LocalDatabaseProduct["type"];
1351
+ export type ProductStatusUnion = LocalDatabaseProduct["status"];
1352
+
1353
+ export type ProductRepositorySearchOptions = {
1354
+ name: boolean;
1355
+ barcode: boolean | string;
1356
+ exactMatch: boolean; // TODO: Remove
1357
+ quantityCheck: boolean;
1358
+ quantityCount: number;
1359
+ sort: boolean;
1360
+ filter: undefined | ((product: LocalDatabaseProduct) => boolean);
1361
+ exact: boolean;
1362
+ limit: number;
1363
+ };
1364
+
1365
+ export interface ProductSearchDataType {
1366
+ quantity?: number;
1367
+ kind?: "product";
1368
+ searchBarcode?: string;
1369
+ }
1370
+
1371
+ export type ProductSearchResultType = LocalDatabaseProduct & ProductSearchDataType;
1372
+
1373
+ export type ProductClassificationUnion = "category" |
1374
+ "brand" |
1375
+ "family" |
1376
+ "tag" |
1377
+ "supplier" |
1378
+ "supplier_code";
1379
+
1380
+ export interface BaseProductRepository extends
1381
+ BaseRepository<LocalDatabaseProduct>,
1382
+ BaseSearchableRepository<
1383
+ ProductSearchResultType,
1384
+ ProductRepositorySearchOptions
1385
+ >
1386
+ {
1387
+ getFromClassification(
1388
+ classificationType: ProductClassificationUnion,
1389
+ uuid: string
1390
+ ): Promise<Array<LocalDatabaseProduct>>;
1391
+ getByStatus(status: ProductStatusUnion | Array<ProductStatusUnion>): Promise<Array<LocalDatabaseProduct>>;
1392
+ getByType(type: ProductTypeUnion | Array<ProductTypeUnion>): Promise<Array<LocalDatabaseProduct>>;
1393
+ getBulk(ids: Array<string>): Promise<Array<LocalDatabaseProduct>>;
1394
+ getByMDBId(mdbId: number): Promise<Array<LocalDatabaseProduct>>;
1395
+ getBySupplierCodes(supplierCodes: Array<string>): Promise<Array<LocalDatabaseProduct>>;
1396
+ update(id: string, changes: Partial<LocalDatabaseProduct>): Promise<void>;
1397
+ clearCache(): void;
1398
+ }
1399
+
1400
+
1401
+ export type BasePromotionCategoryRepository =
1402
+ BaseRepository<LocalDatabasePromotionCategory> &
1403
+ BaseSearchableRepository<LocalDatabasePromotionCategory>;
1404
+
1405
+
1406
+ export type LocalDatabaseCriteriaTypeUnion = LocalDatabasePromotionCriteria["type"];
1407
+
1408
+ export type PromotionClassificationUnion = "categories" |
1409
+ "brands" |
1410
+ "families" |
1411
+ "tags";
1412
+
1413
+ export interface BasePromotionRepository extends BaseRepository<
1414
+ LocalDatabasePromotion
1415
+ >, BaseSearchableRepository<LocalDatabasePromotion> {
1416
+ update(id: string, update: Partial<LocalDatabasePromotion>): Promise<void>;
1417
+ getPromotionsForProduct(product: string): Promise<Array<string>>;
1418
+ getByCategory(id: string): Promise<Array<LocalDatabasePromotion>>;
1419
+ getByClassification(type: PromotionClassificationUnion, id: string): Array<string>;
1420
+ filter(filter: (promotion: LocalDatabasePromotion) => boolean): Promise<Array<LocalDatabasePromotion>>;
1421
+ simulate(originalId: null | string, promotion: null | LocalDatabasePromotion): Promise<void>;
1422
+ getBulk(ids: Array<string>): Promise<Array<LocalDatabasePromotion>>;
1423
+ mapToCache(): Promise<void>;
1424
+ }
1425
+
1426
+
1427
+ export type ReceiptTypeUnion = LocalDatabaseReceipt["type"];
1428
+ export type ReceiptServerTypeUnion = "NORMAL" | "TEXT_ONLY" | "A4" | "EMAIL";
1429
+
1430
+ export const ReceiptServerToLocalMap: Record<ReceiptServerTypeUnion, ReceiptTypeUnion> = {
1431
+ NORMAL : "receipt-full",
1432
+ TEXT_ONLY: "receipt-text",
1433
+ A4 : "a4",
1434
+ EMAIL : "email",
1435
+ };
1436
+
1437
+ export const ReceiptLocalToServerMap: Record<ReceiptTypeUnion, ReceiptServerTypeUnion> = {
1438
+ "receipt-full": "NORMAL",
1439
+ "receipt-text": "TEXT_ONLY",
1440
+ "a4" : "A4",
1441
+ "email" : "EMAIL",
1442
+ };
1443
+
1444
+ export type ReceiptPaddingType = Exclude<LocalDatabaseReceipt["padding"], null>;
1445
+
1446
+ export interface BaseReceiptRepository extends BaseRepository<LocalDatabaseReceipt> {
1447
+ filter(filter: (item: LocalDatabaseReceipt) => boolean): Promise<Array<LocalDatabaseReceipt>>;
1448
+ getByType(type: ReceiptTypeUnion): Promise<Array<LocalDatabaseReceipt>>;
1449
+ }
1450
+
1451
+
1452
+ export type DayOfWeek =
1453
+ "monday" |
1454
+ "tuesday" |
1455
+ "wednesday" |
1456
+ "thursday" |
1457
+ "friday" |
1458
+ "saturday" |
1459
+ "sunday";
1460
+
1461
+ export type ShouldPrintOptions = LocalDatabaseRegister["closure_print_settings"]["account"];
1462
+
1463
+ export interface BaseRegisterRepository extends BaseRepository<LocalDatabaseRegister> {
1464
+ update(id: string, changes: Partial<LocalDatabaseRegister>): Promise<void>;
1465
+ }
1466
+
1467
+
1468
+ export type SaleKeyActionType =
1469
+ "add-single" |
1470
+ "add-case" |
1471
+ "add-giftcard" |
1472
+ "product-details" |
1473
+ "case" |
1474
+ "open-drawer" |
1475
+ "add-note" |
1476
+ "create-customer" |
1477
+ "return-item" |
1478
+ "flip-sale" |
1479
+ "pay-exact" |
1480
+ "pay-amount" |
1481
+ "view-promotions" |
1482
+ "sale-search" |
1483
+ "cancel-sale" |
1484
+ "add-product" |
1485
+ "subtract-product" |
1486
+ "add-product-barcode" |
1487
+ "subtract-product-barcode" |
1488
+ "open-folder" |
1489
+ "previous-folder" |
1490
+ "display-classification" |
1491
+ "keyboard" |
1492
+ "reweigh" |
1493
+ "customer-list" |
1494
+ "live-profit" |
1495
+ "current-time" |
1496
+ "previous-date" |
1497
+ "add-component" |
1498
+ "remove-component" |
1499
+ "display-classification-case" |
1500
+ "change-price-set" |
1501
+ "add-customer" |
1502
+ "make-customer-payment" |
1503
+ "apply-discount" |
1504
+ "add-component-to-current" |
1505
+ "remove-component-from-current" |
1506
+ "add-order-reference" |
1507
+ "search-additional" |
1508
+ "show-backorders" |
1509
+ "pay-loyalty";
1510
+
1511
+ // Note: Actions connected to the Embedded API are the reason for the string union
1512
+ export type SaleKeyActionUnion = SaleKeyActionType | "noop" | string;
1513
+
1514
+ export interface SaleKeyType {
1515
+ action: SaleKeyActionUnion;
1516
+ actionargs: Record<string, unknown>;
1517
+ background: string;
1518
+ backgroundhover: string;
1519
+ bordercolour: string;
1520
+ constrainheight: boolean;
1521
+ constrainwidth: boolean;
1522
+ disabled: boolean;
1523
+ fill: boolean;
1524
+ hover: boolean;
1525
+ hoveranimation: boolean;
1526
+ image: string | null;
1527
+ imagehover: string | null;
1528
+ preventdisable: boolean;
1529
+ text: string;
1530
+ textcolour: string;
1531
+ texthover: string;
1532
+ texthovercolour: string;
1533
+ top: number;
1534
+ left: number;
1535
+ width: number;
1536
+ height: number;
1537
+ fontSize?: number;
1538
+ bold?: boolean;
1539
+ italic?: boolean;
1540
+ underline?: boolean;
1541
+ }
1542
+
1543
+ export interface LocalDatabaseSaleKeys {
1544
+ keys: Array<SaleKeyType>;
1545
+ name: string;
1546
+ uuid: string;
1547
+ }
1548
+
1549
+ export type BaseSalesKeyRepository = BaseRepository<LocalDatabaseSaleKeys>;
1550
+
1551
+
1552
+ export type SaleActionType =
1553
+ // If changing, modify SaleActionEnum.php
1554
+ "PRODUCT_SCAN" |
1555
+ "PRODUCT_SEARCH_ADD" |
1556
+ "PRODUCT_KEY_ADD" |
1557
+ "QUANTITY_OVERRIDE" |
1558
+ "INCREMENT" |
1559
+ "DECREMENT" |
1560
+ "REMOVE_PRODUCT" |
1561
+ "CUSTOMER_SCAN" |
1562
+ "CUSTOMER_SEARCH_ADD" |
1563
+ "CUSTOMER_KEY_ADD" |
1564
+ "REMOVE_CUSTOMER" |
1565
+ "ADD_PAYMENT" |
1566
+ "REMOVE_PAYMENT";
1567
+
1568
+ export interface SaleAction {
1569
+ timestamp: string;
1570
+ action: SaleActionType;
1571
+ // for product / customer scan this is the barcode,
1572
+ // for product / customer search add this is the search string
1573
+ // for product / customer key add this is the key's rules
1574
+ // for quantity override this is the new quantity,
1575
+ // for increment / decrement it is the amount incremented
1576
+ // for remove product this is "keyboard" or "trash"
1577
+ // for remove customer this is blank
1578
+ // for add / remove payment this is the internal id of the payment
1579
+ value: string;
1580
+ affecting: string; // The ID of the item this is affecting, e.g. product, customer, payment method
1581
+ user: string; // The ID of the user
1582
+ }
1583
+
1584
+ export type LocalDatabaseSalePaymentStatus = "cancelled" | "completed" | "failed";
1585
+
1586
+ type SaleStatus = "COMPLETED" | "CANCELLED" | "PARKED" | "INCOMPLETE" | "UNPARKED";
1587
+ export type ServerSaleStatus = "COMPLETED" | "CANCELLED" | "PARKED" | "INCOMPLETE";
1588
+
1589
+ export interface LocalDatabaseSaleItemTypeProduct {
1590
+ id: string;
1591
+ type: "Product";
1592
+ name: string;
1593
+ }
1594
+
1595
+ export interface LocalDatabaseSaleItemTypeGiftCard {
1596
+ type: "GiftCard";
1597
+ id: string;
1598
+ name: string;
1599
+ code: string;
1600
+ expiry: string;
1601
+ source: string;
1602
+ }
1603
+
1604
+ export interface LocalDatabaseSaleItemTypeSurcharge {
1605
+ type: "Surcharge";
1606
+ }
1607
+
1608
+ export type LocalDatabaseSaleItemType =
1609
+ LocalDatabaseSaleItemTypeProduct |
1610
+ LocalDatabaseSaleItemTypeGiftCard |
1611
+ LocalDatabaseSaleItemTypeSurcharge;
1612
+
1613
+ export interface LocalDatabaseSaleItemPromotion {
1614
+ promotion: string;
1615
+ rebateAmount: number;
1616
+ rebateQuantity: number;
1617
+ savings: number;
1618
+ quantity: number;
1619
+ }
1620
+
1621
+ export interface LocalDatabaseSaleItem {
1622
+ basePrice: number;
1623
+ caseQuantity: number;
1624
+ cost?: number;
1625
+ discount: {
1626
+ amount: string; // TODO: Make a number
1627
+ reason: string;
1628
+ };
1629
+ item: LocalDatabaseSaleItemType;
1630
+ loyaltyValue: number;
1631
+ note: string;
1632
+ products: Array<LocalDatabaseSaleItem>;
1633
+ promotions: Array<LocalDatabaseSaleItemPromotion>;
1634
+ quantity: number;
1635
+ savings: number;
1636
+ tax: number;
1637
+ taxRate: string | null;
1638
+ totalPrice: number;
1639
+ priceList: boolean;
1640
+ metaData: Record<string, unknown>;
1641
+ }
1642
+
1643
+ export interface LocalDatabaseSalePayment {
1644
+ amount: number;
1645
+ metaData?: Record<string, any>;
1646
+ metadata?: unknown; // Deprecated
1647
+ cashout: number;
1648
+ rounding: number;
1649
+ paymentMethodId: string;
1650
+ registerId: string;
1651
+ status: LocalDatabaseSalePaymentStatus;
1652
+ processTime: string;
1653
+ receipt: string | null;
1654
+ subtype: null | string;
1655
+ cancelledAt?: string | null;
1656
+ }
1657
+
1658
+ export interface LocalDatabaseSale {
1659
+ cashout: number;
1660
+ clientId?: string;
1661
+ createdAt: string;
1662
+ customerId: null | string;
1663
+ discount: {
1664
+ amount: string; // TODO: Make a number
1665
+ reason: string;
1666
+ };
1667
+ id: string;
1668
+ invoiceId: string;
1669
+ items: Array<LocalDatabaseSaleItem>;
1670
+ linkedTo: null | string;
1671
+ loyaltyValue: number;
1672
+ notes: {
1673
+ internal: string;
1674
+ sale: string;
1675
+ };
1676
+ orderReference: string;
1677
+ payments: Array<LocalDatabaseSalePayment>;
1678
+ refundReason: null | string;
1679
+ registerId: string;
1680
+ status: SaleStatus;
1681
+ totalBase: number;
1682
+ totalChange: number;
1683
+ totalCost: number;
1684
+ totalPrice: number;
1685
+ totalQuantity: number;
1686
+ totalRounding: number;
1687
+ totalTax: number;
1688
+ updatedAt: string;
1689
+ uploaded: boolean;
1690
+ userId: string;
1691
+ actions: Array<SaleAction>;
1692
+ metaData: Record<string, unknown>;
1693
+ isCancellable?: boolean;
1694
+ }
1695
+
1696
+ export interface BaseSalesRepository extends BaseRepository<LocalDatabaseSale> {
1697
+ parked(): Promise<Array<LocalDatabaseSale>>;
1698
+ getByClientId(id: string): Promise<Array<LocalDatabaseSale>>;
1699
+ search(invoiceId: string): Promise<Array<LocalDatabaseSale>>;
1700
+ filter(callback: (sale: LocalDatabaseSale) => boolean): Promise<Array<LocalDatabaseSale>>;
1701
+ }
1702
+
1703
+
1704
+ export interface LocalDatabaseStocktakeAccumulated {
1705
+ accumulated: number;
1706
+ stocktake_id: string;
1707
+ uuid: string;
1708
+ }
1709
+
1710
+ export interface BaseStocktakeAccumulatedRepository extends BaseRepository<
1711
+ LocalDatabaseStocktakeAccumulated
1712
+ > {
1713
+ getByStocktake(stocktake: string): Promise<Array<LocalDatabaseStocktakeAccumulated>>;
1714
+ update(uuid: string, changes: Partial<LocalDatabaseStocktakeAccumulated>): Promise<void>;
1715
+ }
1716
+
1717
+
1718
+ export interface LocalDatabaseStocktake {
1719
+ display_expected: boolean;
1720
+ name: string;
1721
+ outlet_id: string;
1722
+ uuid: string;
1723
+ }
1724
+
1725
+ export type BaseStocktakeRepository = BaseRepository<LocalDatabaseStocktake>;
1726
+
1727
+
1728
+ export interface LocalDatabaseStocktakeScanned {
1729
+ id?: number;
1730
+ accumulated: number;
1731
+ linked_to: null | number;
1732
+ product_id: string;
1733
+ quantity: number;
1734
+ removed: boolean;
1735
+ stocktake_id: string;
1736
+ timestamp: string;
1737
+ user_id: null | string;
1738
+ barcode: string | undefined;
1739
+ client_id: string;
1740
+ }
1741
+
1742
+ export interface BaseStocktakeScannedRepository extends BaseRepository<
1743
+ LocalDatabaseStocktakeScanned,
1744
+ number
1745
+ > {
1746
+ getByStocktake(stocktake: string): Promise<Array<LocalDatabaseStocktakeScanned>>;
1747
+ update(id: number, changes: Partial<LocalDatabaseStocktakeScanned>): Promise<void>;
1748
+ }
1749
+
1750
+
1751
+ export type BaseSupplierRepository =
1752
+ BaseRepository<LocalDatabaseSupplier> &
1753
+ BaseSearchableRepository<LocalDatabaseSupplier>;
1754
+
1755
+
1756
+ export interface LocalDatabaseSystem<TValue> {
1757
+ key: string;
1758
+ value: TValue;
1759
+ }
1760
+
1761
+ export abstract class BaseSystemRepository extends BaseRepository<LocalDatabaseSystem<unknown>> {
1762
+ public abstract get<TValue>(key: string): Promise<TValue>;
1763
+ }
1764
+
1765
+
1766
+ export interface LocalDatabaseTakings {
1767
+ amount: number;
1768
+ type: PaymentMethodTypeUnion;
1769
+ uuid: string;
1770
+ }
1771
+
1772
+ export interface BaseTakingsRepository extends BaseRepository<LocalDatabaseTakings> {
1773
+ getByType(type: PaymentMethodTypeUnion): Promise<Array<LocalDatabaseTakings>>;
1774
+ }
1775
+
1776
+
1777
+ export type BaseTaxRateRepository = BaseRepository<LocalDatabaseTaxRate> &
1778
+ BaseSearchableRepository<LocalDatabaseTaxRate>;
1779
+
1780
+
1781
+ export type LocalEmailFormatUnion = LocalDatabaseTransferee["email_format"];
1782
+
1783
+ export type BaseTransfereeRepository =
1784
+ BaseRepository<LocalDatabaseTransferee> &
1785
+ BaseSearchableRepository<LocalDatabaseTransferee>;
1786
+
1787
+
1788
+ export interface QueuedItem<Type extends UPLOAD_TYPES> {
1789
+ id?: number;
1790
+ attempts?: number;
1791
+ status?: "queued" | "failed";
1792
+ requestId?: string;
1793
+ type?: UPLOAD_TYPES;
1794
+ dismissed?: boolean;
1795
+ data: QueuedItemData[Type];
1796
+ createdAt?: string;
1797
+ }
1798
+
1799
+ export interface QueuedItemData {
1800
+ [UPLOAD_TYPES.SALE]: string;
1801
+ [UPLOAD_TYPES.UPDATE_SALE]: UpdateSaleQueuedDate;
1802
+ [UPLOAD_TYPES.BARCODE]: BarcodeQueuedData;
1803
+ [UPLOAD_TYPES.OPEN_REGISTER]: RegisterOpenQueuedData;
1804
+ [UPLOAD_TYPES.CUSTOMER]: string;
1805
+ [UPLOAD_TYPES.UPDATE_CUSTOMER]: UpdateCustomerQueuedData;
1806
+ [UPLOAD_TYPES.EMAIL_RECEIPT]: EmailReceiptQueuedData;
1807
+ [UPLOAD_TYPES.ACTION]: ActionQueuedData;
1808
+ [UPLOAD_TYPES.TAKINGS]: TakingQueuedData;
1809
+ [UPLOAD_TYPES.VOID_SALE]: string;
1810
+ [UPLOAD_TYPES.UNPARK_SALE]: string | UnparkSaleQueuedData;
1811
+ [UPLOAD_TYPES.CUSTOMER_PAYMENT]: CustomerPaymentQueuedData;
1812
+ [UPLOAD_TYPES.EMAIL_COMPONENT]: EmailComponentQueuedData;
1813
+ [UPLOAD_TYPES.CLOSE_REGISTER]: RegisterClosureQueuedData;
1814
+ [UPLOAD_TYPES.STOCKTAKE_COUNT]: StocktakeCountQueuedData;
1815
+ [UPLOAD_TYPES.ERROR]: ErrorQueuedData;
1816
+ [UPLOAD_TYPES.SECURITY_EVENT]: SecurityEventQueuedData;
1817
+ [UPLOAD_TYPES.KITCHEN_ORDER]: KitchenOrderQueuedData;
1818
+ }
1819
+
1820
+ export interface UpdateSaleQueuedDate {
1821
+ clientId: string;
1822
+ invoiceId: string | undefined;
1823
+ customer?: string;
1824
+ saleTime?: string;
1825
+ user?: string;
1826
+ note?: string;
1827
+ internalNote?: string;
1828
+ }
1829
+
1830
+ export interface BarcodeQueuedData {
1831
+ productId: string;
1832
+ barcode: string;
1833
+ quantity: number;
1834
+ }
1835
+
1836
+ export interface RegisterOpenQueuedData {
1837
+ time: string;
1838
+ id: string;
1839
+ }
1840
+
1841
+ export interface UpdateCustomerQueuedData {
1842
+ customerId: string;
1843
+ email: string;
1844
+ }
1845
+
1846
+ export interface EmailReceiptQueuedData {
1847
+ to: string;
1848
+ register: string | false;
1849
+ receipt: string;
1850
+ status: ServerSaleStatus | undefined;
1851
+ invoiceNo: string | undefined;
1852
+ attachments: Array<{
1853
+ name: string;
1854
+ data: string;
1855
+ }>;
1856
+ }
1857
+
1858
+ export interface ActionQueuedData {
1859
+ user: string;
1860
+ affectingType: string;
1861
+ affectingId: string;
1862
+ action: string;
1863
+ additional: string | null;
1864
+ createdAt?: string;
1865
+ }
1866
+
1867
+ export interface TakingQueuedData extends Omit<LocalDatabaseMovement, "denominations"> {
1868
+ denominations: {
1869
+ in?: Array<{
1870
+ denomination: number;
1871
+ amount: number;
1872
+ }>;
1873
+ out?: Array<{
1874
+ denomination: number;
1875
+ amount: number;
1876
+ }>;
1877
+ };
1878
+ }
1879
+
1880
+ export interface UnparkSaleQueuedData {
1881
+ id: string;
1882
+ time: string | null;
1883
+ register: string | null;
1884
+ }
1885
+
1886
+ export interface CustomerPaymentQueuedData {
1887
+ customer: string;
1888
+ paymentMethod: string;
1889
+ paymentMethodSubtype: string | undefined;
1890
+ user: string | false;
1891
+ register: string | null;
1892
+ reference: string;
1893
+ amount: number;
1894
+ timestamp: string;
1895
+ invoices: Array<{
1896
+ id: string;
1897
+ amount: number;
1898
+ }>;
1899
+ }
1900
+
1901
+ export interface EmailComponentQueuedData {
1902
+ to: string | Array<string>;
1903
+ subject: string;
1904
+ attachments?: Array<{
1905
+ data: string;
1906
+ name: string;
1907
+ mime: string;
1908
+ }>;
1909
+ cc?: Array<string>;
1910
+ body: string;
1911
+ replyTo?: [string, string] | string | null;
1912
+ width?: number;
1913
+ }
1914
+
1915
+ export interface RegisterClosureQueuedData {
1916
+ user: string;
1917
+ register: string;
1918
+ paymentMethods: Array<{
1919
+ id: string;
1920
+ expected: number;
1921
+ received: number;
1922
+ additional: unknown;
1923
+ }>;
1924
+ openTime: string;
1925
+ closeTime: string;
1926
+ note: string;
1927
+ }
1928
+
1929
+ export interface StocktakeCountQueuedData {
1930
+ stocktake: string;
1931
+ items: Array<number>;
1932
+ }
1933
+
1934
+ export interface ErrorQueuedData {
1935
+ subject: string;
1936
+ body: string;
1937
+ }
1938
+
1939
+ export interface SecurityEventQueuedData {
1940
+ user: string | null;
1941
+ register: string | null;
1942
+ outlet: string | null;
1943
+ event: string;
1944
+ metaData: string;
1945
+ timestamp: string;
1946
+ }
1947
+
1948
+ export interface KitchenOrderQueuedData {
1949
+ version: number;
1950
+ sale: string;
1951
+ ready: boolean;
1952
+ items: Array<string>;
1953
+ }
1954
+
1955
+ export interface QueuedReturn {
1956
+ [UPLOAD_TYPES.SALE]: boolean;
1957
+ [UPLOAD_TYPES.UPDATE_SALE]: void;
1958
+ [UPLOAD_TYPES.BARCODE]: void;
1959
+ [UPLOAD_TYPES.OPEN_REGISTER]: {
1960
+ openTime: string;
1961
+ };
1962
+ [UPLOAD_TYPES.CUSTOMER]: string;
1963
+ [UPLOAD_TYPES.UPDATE_CUSTOMER]: void;
1964
+ [UPLOAD_TYPES.EMAIL_RECEIPT]: void;
1965
+ [UPLOAD_TYPES.ACTION]: void;
1966
+ [UPLOAD_TYPES.TAKINGS]: void;
1967
+ [UPLOAD_TYPES.VOID_SALE]: void;
1968
+ [UPLOAD_TYPES.UNPARK_SALE]: boolean;
1969
+ [UPLOAD_TYPES.CUSTOMER_PAYMENT]: void;
1970
+ [UPLOAD_TYPES.EMAIL_COMPONENT]: void;
1971
+ [UPLOAD_TYPES.CLOSE_REGISTER]: undefined | {
1972
+ data: {
1973
+ closeRegister: {
1974
+ id: string;
1975
+ };
1976
+ };
1977
+ };
1978
+ [UPLOAD_TYPES.STOCKTAKE_COUNT]: void;
1979
+ [UPLOAD_TYPES.ERROR]: void;
1980
+ [UPLOAD_TYPES.SECURITY_EVENT]: void;
1981
+ [UPLOAD_TYPES.KITCHEN_ORDER]: undefined | {
1982
+ data: {
1983
+ changeSaleItemReadyStatus: KitchenShopfrontSale;
1984
+ };
1985
+ };
1986
+ }
1987
+
1988
+ export interface BaseUploadRepository extends BaseRepository<QueuedItem<UPLOAD_TYPES>, number> {
1989
+ getFailedUploads(retryLimit: number): Promise<Array<QueuedItem<UPLOAD_TYPES>>>;
1990
+ dismissErrors(ids: Array<number>): Promise<void>;
1991
+ getQueue(retryLimit: null | number): Promise<Array<QueuedItem<UPLOAD_TYPES>>>;
1992
+ resetIdempotence(): Promise<void>;
1993
+ resetAttempts(): Promise<void>;
1994
+ }
1995
+
1996
+
1997
+ export type SaleKeysPosition = LocalDatabaseUser["sale_keys_position"];
1998
+ export type DarkModeOverride = LocalDatabaseUser["dark_mode"];
1999
+
2000
+ // If more pages are added they need to be added in UpdateUserFormFavourites.php, UserTypes.tsx and
2001
+ // TrashedItemsRestore.ts
2002
+ export type FavouriteFormPages = "product";
2003
+
2004
+ export interface BaseUserRepository extends BaseRepository<
2005
+ LocalDatabaseUser
2006
+ >, BaseSearchableRepository<LocalDatabaseUser> {
2007
+ getUserByUsername(username: string): Promise<LocalDatabaseUser>;
2008
+ update(id: string, updates: Partial<LocalDatabaseUser>): Promise<void>;
2009
+ }
2010
+
2011
+
2012
+ export interface LocalDatabaseVendorConnection {
2013
+ uuid: string;
2014
+ name: string;
2015
+ }
2016
+
2017
+ export type BaseVendorConnectionRepository =
2018
+ BaseRepository<LocalDatabaseVendorConnection> &
2019
+ BaseSearchableRepository<LocalDatabaseVendorConnection>;
2020
+
2021
+
2022
+ export interface DataSourceTables {
2023
+ products: BaseProductRepository;
2024
+ customers: BaseCustomerRepository;
2025
+ customerGroups: BaseCustomerGroupRepository;
2026
+ promotions: BasePromotionRepository;
2027
+ promotionCategories: BasePromotionCategoryRepository;
2028
+ users: BaseUserRepository;
2029
+ priceLists: BasePriceListRepository;
2030
+ paymentMethods: BasePaymentMethodRepository;
2031
+ salesKeys: BaseSalesKeyRepository;
2032
+ receipts: BaseReceiptRepository;
2033
+ giftCards: BaseGiftCardRepository;
2034
+ loyalty: BaseLoyaltyRepository;
2035
+ customerDisplays: BaseCustomerDisplayRepository;
2036
+ sales: BaseSalesRepository;
2037
+ brands: BaseClassificationRepository;
2038
+ categories: BaseClassificationRepository;
2039
+ families: BaseClassificationRepository;
2040
+ tags: BaseClassificationRepository;
2041
+ outlets: BaseOutletRepository;
2042
+ registers: BaseRegisterRepository;
2043
+ uploads: BaseUploadRepository;
2044
+ taxRates: BaseTaxRateRepository;
2045
+ takings: BaseTakingsRepository;
2046
+ pageRules: BasePageRuleRepository;
2047
+ suppliers: BaseSupplierRepository;
2048
+ priceSets: BasePriceSetRepository;
2049
+ transferees: BaseTransfereeRepository;
2050
+ movements: BaseMovementRepository;
2051
+ stocktakes: BaseStocktakeRepository;
2052
+ stocktakeScanned: BaseStocktakeScannedRepository;
2053
+ stocktakeAccumulated: BaseStocktakeAccumulatedRepository;
2054
+ applications: BaseApplicationRepository;
2055
+ barcodeTemplates: BaseBarcodeTemplateRepository;
2056
+ vendorConnections: BaseVendorConnectionRepository;
2057
+ system: BaseSystemRepository;
2058
+ enterprises: BaseEnterpriseRepository;
2059
+ }
2060
+
2061
+