@shopfront/types 0.0.1 → 0.0.3-alpha.0

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