@teincfood/core 0.1.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.
- package/README.md +44 -0
- package/dist/adapters/auth.d.ts +13 -0
- package/dist/adapters/auth.js +14 -0
- package/dist/adapters/business.d.ts +13 -0
- package/dist/adapters/business.js +14 -0
- package/dist/adapters/connectivity.d.ts +17 -0
- package/dist/adapters/connectivity.js +38 -0
- package/dist/adapters/devices.d.ts +5 -0
- package/dist/adapters/devices.js +14 -0
- package/dist/adapters/http.d.ts +30 -0
- package/dist/adapters/http.js +37 -0
- package/dist/adapters/image-cache.d.ts +8 -0
- package/dist/adapters/image-cache.js +12 -0
- package/dist/adapters/kv-types.d.ts +5 -0
- package/dist/adapters/kv-types.js +2 -0
- package/dist/adapters/kv.d.ts +20 -0
- package/dist/adapters/kv.js +81 -0
- package/dist/adapters/local-node.d.ts +34 -0
- package/dist/adapters/local-node.js +40 -0
- package/dist/adapters/pending-orders.d.ts +17 -0
- package/dist/adapters/pending-orders.js +31 -0
- package/dist/adapters/query-keys.d.ts +17 -0
- package/dist/adapters/query-keys.js +20 -0
- package/dist/adapters/services.d.ts +62 -0
- package/dist/adapters/services.js +95 -0
- package/dist/adapters/sqlite.d.ts +20 -0
- package/dist/adapters/sqlite.js +23 -0
- package/dist/db/connection.d.ts +8 -0
- package/dist/db/connection.js +87 -0
- package/dist/db/migrations.d.ts +9 -0
- package/dist/db/migrations.js +106 -0
- package/dist/db/operations.d.ts +45 -0
- package/dist/db/operations.js +192 -0
- package/dist/index.d.ts +50 -0
- package/dist/index.js +118 -0
- package/dist/reference/api.d.ts +10 -0
- package/dist/reference/api.js +24 -0
- package/dist/reference/events.d.ts +54 -0
- package/dist/reference/events.js +144 -0
- package/dist/reference/operations.d.ts +11 -0
- package/dist/reference/operations.js +46 -0
- package/dist/reference/service.d.ts +27 -0
- package/dist/reference/service.js +270 -0
- package/dist/reference/types.d.ts +47 -0
- package/dist/reference/types.js +12 -0
- package/dist/repositories/order.repository.d.ts +44 -0
- package/dist/repositories/order.repository.js +132 -0
- package/dist/repositories/pos.repository.d.ts +20 -0
- package/dist/repositories/pos.repository.js +28 -0
- package/dist/sync/command-builder.d.ts +17 -0
- package/dist/sync/command-builder.js +30 -0
- package/dist/sync/command-queue.service.d.ts +41 -0
- package/dist/sync/command-queue.service.js +253 -0
- package/dist/sync/engine.d.ts +53 -0
- package/dist/sync/engine.js +216 -0
- package/dist/sync/order-number.d.ts +20 -0
- package/dist/sync/order-number.js +58 -0
- package/dist/sync/order-snapshots.service.d.ts +46 -0
- package/dist/sync/order-snapshots.service.js +151 -0
- package/dist/sync/pending-orders.service.d.ts +45 -0
- package/dist/sync/pending-orders.service.js +163 -0
- package/dist/sync/transport-local-node.d.ts +14 -0
- package/dist/sync/transport-local-node.js +67 -0
- package/dist/sync/transport-rest.d.ts +17 -0
- package/dist/sync/transport-rest.js +112 -0
- package/dist/sync/types.d.ts +102 -0
- package/dist/sync/types.js +13 -0
- package/dist/sync/use-sync-reconciliation.d.ts +10 -0
- package/dist/sync/use-sync-reconciliation.js +106 -0
- package/dist/types/api/auth.api.d.ts +61 -0
- package/dist/types/api/auth.api.js +3 -0
- package/dist/types/api/business.api.d.ts +137 -0
- package/dist/types/api/business.api.js +3 -0
- package/dist/types/api/conversation.api.d.ts +46 -0
- package/dist/types/api/conversation.api.js +2 -0
- package/dist/types/api/error.api.d.ts +8 -0
- package/dist/types/api/error.api.js +2 -0
- package/dist/types/api/fleet.api.d.ts +98 -0
- package/dist/types/api/fleet.api.js +3 -0
- package/dist/types/api/index.d.ts +11 -0
- package/dist/types/api/index.js +27 -0
- package/dist/types/api/kiosk.api.d.ts +4 -0
- package/dist/types/api/kiosk.api.js +2 -0
- package/dist/types/api/menu.api.d.ts +90 -0
- package/dist/types/api/menu.api.js +2 -0
- package/dist/types/api/pagination.d.ts +10 -0
- package/dist/types/api/pagination.js +2 -0
- package/dist/types/api/rider.api.d.ts +179 -0
- package/dist/types/api/rider.api.js +2 -0
- package/dist/types/api/seller.api.d.ts +164 -0
- package/dist/types/api/seller.api.js +2 -0
- package/dist/types/api/wallet.api.d.ts +27 -0
- package/dist/types/api/wallet.api.js +2 -0
- package/dist/types/pos.types.d.ts +33 -0
- package/dist/types/pos.types.js +5 -0
- package/dist/utils/constants.d.ts +85 -0
- package/dist/utils/constants.js +72 -0
- package/dist/utils/copyToClipBoard.d.ts +5 -0
- package/dist/utils/copyToClipBoard.js +23 -0
- package/dist/utils/currency.d.ts +9 -0
- package/dist/utils/currency.js +37 -0
- package/dist/utils/error.d.ts +4 -0
- package/dist/utils/error.js +73 -0
- package/dist/utils/formatCurrency.d.ts +4 -0
- package/dist/utils/formatCurrency.js +16 -0
- package/dist/utils/formatDate.d.ts +8 -0
- package/dist/utils/formatDate.js +42 -0
- package/dist/utils/phone.d.ts +10 -0
- package/dist/utils/phone.js +71 -0
- package/dist/utils/responsive.d.ts +13 -0
- package/dist/utils/responsive.js +21 -0
- package/dist/utils/storage.d.ts +15 -0
- package/dist/utils/storage.js +60 -0
- package/dist/utils/sync-logger.d.ts +22 -0
- package/dist/utils/sync-logger.js +79 -0
- package/dist/utils/uuid.d.ts +7 -0
- package/dist/utils/uuid.js +47 -0
- package/dist/utils/validation.d.ts +31 -0
- package/dist/utils/validation.js +170 -0
- package/package.json +49 -0
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import type { PaginationMeta, PaginatedResponse } from './pagination';
|
|
2
|
+
export interface RiderProfileBusiness {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
business_number: string;
|
|
6
|
+
type: string;
|
|
7
|
+
status: string;
|
|
8
|
+
logo_url: string | null;
|
|
9
|
+
latitude: number | null;
|
|
10
|
+
longitude: number | null;
|
|
11
|
+
address: {
|
|
12
|
+
address_line: string;
|
|
13
|
+
city: string;
|
|
14
|
+
region: string;
|
|
15
|
+
latitude: number | null;
|
|
16
|
+
longitude: number | null;
|
|
17
|
+
} | null;
|
|
18
|
+
}
|
|
19
|
+
export interface RiderProfile {
|
|
20
|
+
id: string;
|
|
21
|
+
rider_number: string;
|
|
22
|
+
user_id: string;
|
|
23
|
+
status: string;
|
|
24
|
+
is_online: boolean;
|
|
25
|
+
is_fleet_managed: boolean;
|
|
26
|
+
is_active: boolean;
|
|
27
|
+
current_lat: number | null;
|
|
28
|
+
current_lng: number | null;
|
|
29
|
+
businesses: RiderProfileBusiness[];
|
|
30
|
+
phone: string;
|
|
31
|
+
license_number: string;
|
|
32
|
+
kyc_status: string;
|
|
33
|
+
vehicle_type: string | null;
|
|
34
|
+
inserted_at: string;
|
|
35
|
+
updated_at: string;
|
|
36
|
+
}
|
|
37
|
+
export interface RiderProfileResponse {
|
|
38
|
+
data: RiderProfile;
|
|
39
|
+
}
|
|
40
|
+
export interface RiderKycResponse {
|
|
41
|
+
data: {
|
|
42
|
+
kyc_status: string;
|
|
43
|
+
documents?: string[];
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
export interface RiderDelivery {
|
|
47
|
+
id: string;
|
|
48
|
+
order_id: string;
|
|
49
|
+
order_number: string | null;
|
|
50
|
+
status: string;
|
|
51
|
+
pickup_name: string | null;
|
|
52
|
+
pickup: string | null;
|
|
53
|
+
dropoff: string | null;
|
|
54
|
+
pickup_lat: number;
|
|
55
|
+
pickup_lng: number;
|
|
56
|
+
dropoff_lat: number;
|
|
57
|
+
dropoff_lng: number;
|
|
58
|
+
eta_minutes: number;
|
|
59
|
+
earnings_minor: number | null;
|
|
60
|
+
currency: string | null;
|
|
61
|
+
inserted_at: string;
|
|
62
|
+
updated_at: string;
|
|
63
|
+
}
|
|
64
|
+
export type RiderDeliveriesResponse = PaginatedResponse<RiderDelivery>;
|
|
65
|
+
export interface RiderEarningsResponse {
|
|
66
|
+
data: Record<string, unknown>[];
|
|
67
|
+
pagination: PaginationMeta;
|
|
68
|
+
total_earned_minor: number;
|
|
69
|
+
currency: string;
|
|
70
|
+
}
|
|
71
|
+
export interface RiderEarningsSummaryResponse {
|
|
72
|
+
data: {
|
|
73
|
+
total_earnings_minor: number;
|
|
74
|
+
total_deliveries: number;
|
|
75
|
+
currency: string;
|
|
76
|
+
period: string;
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
export interface RiderVehicle {
|
|
80
|
+
id: string;
|
|
81
|
+
rider_id: string;
|
|
82
|
+
plate_number: string;
|
|
83
|
+
type: string;
|
|
84
|
+
ownership: string;
|
|
85
|
+
brand: string | null;
|
|
86
|
+
model: string | null;
|
|
87
|
+
color: string | null;
|
|
88
|
+
year: number | null;
|
|
89
|
+
inserted_at: string;
|
|
90
|
+
}
|
|
91
|
+
export interface RiderVehicleRequest {
|
|
92
|
+
type: string;
|
|
93
|
+
plate_number: string;
|
|
94
|
+
brand: string;
|
|
95
|
+
model: string;
|
|
96
|
+
color: string;
|
|
97
|
+
year?: number;
|
|
98
|
+
ownership?: string;
|
|
99
|
+
}
|
|
100
|
+
export interface RiderVehicleResponse {
|
|
101
|
+
data: RiderVehicle | null;
|
|
102
|
+
}
|
|
103
|
+
export interface AvailableOrder {
|
|
104
|
+
order_id: string;
|
|
105
|
+
order_number: string;
|
|
106
|
+
total_minor: number;
|
|
107
|
+
currency: string;
|
|
108
|
+
payment_mode: string;
|
|
109
|
+
business_name: string;
|
|
110
|
+
business_address: string | null;
|
|
111
|
+
business_lat: number | null;
|
|
112
|
+
business_lng: number | null;
|
|
113
|
+
delivery_address: Record<string, unknown> | string | null;
|
|
114
|
+
delivery_lat: number | null;
|
|
115
|
+
delivery_lng: number | null;
|
|
116
|
+
inserted_at: string;
|
|
117
|
+
}
|
|
118
|
+
export interface AvailableOrdersResponse {
|
|
119
|
+
data: AvailableOrder[];
|
|
120
|
+
}
|
|
121
|
+
export interface RiderDashboard {
|
|
122
|
+
today_earnings_minor: number;
|
|
123
|
+
today_deliveries: number;
|
|
124
|
+
available_deliveries: number;
|
|
125
|
+
total_deliveries: number;
|
|
126
|
+
status: string;
|
|
127
|
+
}
|
|
128
|
+
export interface RiderDashboardResponse {
|
|
129
|
+
data: RiderDashboard;
|
|
130
|
+
}
|
|
131
|
+
export interface DeliveryCustomer {
|
|
132
|
+
name: string | null;
|
|
133
|
+
phone: string | null;
|
|
134
|
+
user_id: string | null;
|
|
135
|
+
}
|
|
136
|
+
export interface DeliveryPickupLocation {
|
|
137
|
+
name: string | null;
|
|
138
|
+
address: string | null;
|
|
139
|
+
phone: string | null;
|
|
140
|
+
lat: number | null;
|
|
141
|
+
lng: number | null;
|
|
142
|
+
}
|
|
143
|
+
export interface DeliveryDropoffLocation {
|
|
144
|
+
name: string | null;
|
|
145
|
+
address: string | null;
|
|
146
|
+
lat: number | null;
|
|
147
|
+
lng: number | null;
|
|
148
|
+
notes: string | null;
|
|
149
|
+
}
|
|
150
|
+
export interface DeliveryItem {
|
|
151
|
+
name: string | null;
|
|
152
|
+
quantity: number;
|
|
153
|
+
price: number;
|
|
154
|
+
}
|
|
155
|
+
export interface RiderDeliveryDetail {
|
|
156
|
+
id: string;
|
|
157
|
+
order_id: string;
|
|
158
|
+
order_number: string | null;
|
|
159
|
+
status: string;
|
|
160
|
+
pickup_lat: number | null;
|
|
161
|
+
pickup_lng: number | null;
|
|
162
|
+
dropoff_lat: number | null;
|
|
163
|
+
dropoff_lng: number | null;
|
|
164
|
+
eta_minutes: number | null;
|
|
165
|
+
rider_pickup_confirmed_at: string | null;
|
|
166
|
+
merchant_handover_confirmed_at: string | null;
|
|
167
|
+
inserted_at: string;
|
|
168
|
+
updated_at: string;
|
|
169
|
+
customer: DeliveryCustomer;
|
|
170
|
+
pickup: DeliveryPickupLocation;
|
|
171
|
+
dropoff: DeliveryDropoffLocation;
|
|
172
|
+
items: DeliveryItem[];
|
|
173
|
+
order_total_minor: number | null;
|
|
174
|
+
delivery_fee_minor: number | null;
|
|
175
|
+
currency: string | null;
|
|
176
|
+
}
|
|
177
|
+
export interface RiderDeliveryDetailResponse {
|
|
178
|
+
data: RiderDeliveryDetail;
|
|
179
|
+
}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import type { PaginatedResponse } from './pagination';
|
|
2
|
+
export interface OrderUser {
|
|
3
|
+
id: string;
|
|
4
|
+
full_name: string;
|
|
5
|
+
email: string;
|
|
6
|
+
phone: string;
|
|
7
|
+
avatar_url: string | null;
|
|
8
|
+
}
|
|
9
|
+
export interface OrderPayment {
|
|
10
|
+
is_paid: boolean;
|
|
11
|
+
reference: string | null;
|
|
12
|
+
amount_minor: number | null;
|
|
13
|
+
currency: string | null;
|
|
14
|
+
paid_at: string | null;
|
|
15
|
+
}
|
|
16
|
+
export interface OrderMenuItem {
|
|
17
|
+
id: string;
|
|
18
|
+
name: string;
|
|
19
|
+
}
|
|
20
|
+
export interface OrderItemAddon {
|
|
21
|
+
id: string;
|
|
22
|
+
price: number;
|
|
23
|
+
}
|
|
24
|
+
export interface OrderItem {
|
|
25
|
+
id: string;
|
|
26
|
+
menu_item: OrderMenuItem | null;
|
|
27
|
+
quantity: number;
|
|
28
|
+
unit_price: number;
|
|
29
|
+
subtotal: number;
|
|
30
|
+
addons?: OrderItemAddon[];
|
|
31
|
+
}
|
|
32
|
+
export interface OrderBusiness {
|
|
33
|
+
id: string;
|
|
34
|
+
name: string;
|
|
35
|
+
phone?: string;
|
|
36
|
+
latitude?: number;
|
|
37
|
+
longitude?: number;
|
|
38
|
+
estimated_delivery_time?: number;
|
|
39
|
+
}
|
|
40
|
+
export interface OrderDeliveryAddress {
|
|
41
|
+
apartment?: string;
|
|
42
|
+
city?: string;
|
|
43
|
+
full_address?: string;
|
|
44
|
+
id?: string;
|
|
45
|
+
label?: string;
|
|
46
|
+
place_id?: string;
|
|
47
|
+
street?: string;
|
|
48
|
+
latitude?: number;
|
|
49
|
+
longitude?: number;
|
|
50
|
+
}
|
|
51
|
+
export interface OrderTaxLine {
|
|
52
|
+
id: string | null;
|
|
53
|
+
business_tax_rule_id: string | null;
|
|
54
|
+
name: string | null;
|
|
55
|
+
code: string | null;
|
|
56
|
+
country_code: string | null;
|
|
57
|
+
rate_basis_points: number | null;
|
|
58
|
+
taxable_amount_minor: number | null;
|
|
59
|
+
tax_amount_minor: number | null;
|
|
60
|
+
applies_to: string | null;
|
|
61
|
+
is_inclusive: boolean | null;
|
|
62
|
+
}
|
|
63
|
+
export interface DeliveryPerson {
|
|
64
|
+
id: string;
|
|
65
|
+
name: string | null;
|
|
66
|
+
phone: string | null;
|
|
67
|
+
avatar_url: string | null;
|
|
68
|
+
current_latitude: number | null;
|
|
69
|
+
current_longitude: number | null;
|
|
70
|
+
rating: number | null;
|
|
71
|
+
vehicle_type: string | null;
|
|
72
|
+
}
|
|
73
|
+
export interface StatusHistoryEntry {
|
|
74
|
+
status: string;
|
|
75
|
+
inserted_at: string;
|
|
76
|
+
}
|
|
77
|
+
export interface SellerOrder {
|
|
78
|
+
id: string;
|
|
79
|
+
order_number: string;
|
|
80
|
+
callout_number: number | null;
|
|
81
|
+
order_type: string | null;
|
|
82
|
+
is_pos: boolean;
|
|
83
|
+
customer_name: string | null;
|
|
84
|
+
customer_phone: string | null;
|
|
85
|
+
pos_payment_method: string | null;
|
|
86
|
+
paid_at: string | null;
|
|
87
|
+
status: string;
|
|
88
|
+
delivery_id: string | null;
|
|
89
|
+
delivery_status: string | null;
|
|
90
|
+
is_paid: boolean;
|
|
91
|
+
payment: OrderPayment;
|
|
92
|
+
payment_mode: string;
|
|
93
|
+
total_minor: number;
|
|
94
|
+
subtotal_minor: number;
|
|
95
|
+
delivery_fee_minor: number;
|
|
96
|
+
tax_minor: number;
|
|
97
|
+
tip_minor: number | null;
|
|
98
|
+
discount_minor: number;
|
|
99
|
+
promo_code: string | null;
|
|
100
|
+
tax_lines: OrderTaxLine[];
|
|
101
|
+
currency: string;
|
|
102
|
+
currency_code: string;
|
|
103
|
+
business_id: string;
|
|
104
|
+
business: OrderBusiness | null;
|
|
105
|
+
delivery_address: OrderDeliveryAddress | null;
|
|
106
|
+
delivery_lat: number | null;
|
|
107
|
+
delivery_lng: number | null;
|
|
108
|
+
user: OrderUser | null;
|
|
109
|
+
items: OrderItem[];
|
|
110
|
+
inserted_at: string;
|
|
111
|
+
}
|
|
112
|
+
export interface SellerOrderDetail extends SellerOrder {
|
|
113
|
+
notes: string | null;
|
|
114
|
+
delivery_person: DeliveryPerson | null;
|
|
115
|
+
delivery_id: string | null;
|
|
116
|
+
delivery_status: string | null;
|
|
117
|
+
merchant_handover_confirmed_at: string | null;
|
|
118
|
+
rider_pickup_confirmed_at: string | null;
|
|
119
|
+
eta_minutes: number | null;
|
|
120
|
+
status_history: StatusHistoryEntry[];
|
|
121
|
+
business: OrderBusiness | null;
|
|
122
|
+
items: OrderItem[];
|
|
123
|
+
}
|
|
124
|
+
export type SellerOrdersResponse = PaginatedResponse<SellerOrder>;
|
|
125
|
+
export interface SellerOrderDetailResponse {
|
|
126
|
+
data: SellerOrderDetail;
|
|
127
|
+
}
|
|
128
|
+
export interface DeliveryOrderItem {
|
|
129
|
+
id: string;
|
|
130
|
+
menu_item: OrderMenuItem | null;
|
|
131
|
+
quantity: number;
|
|
132
|
+
unit_price: number;
|
|
133
|
+
subtotal: number;
|
|
134
|
+
}
|
|
135
|
+
export interface DeliveryRider {
|
|
136
|
+
id: string;
|
|
137
|
+
rider_number: string | null;
|
|
138
|
+
name: string | null;
|
|
139
|
+
phone: string | null;
|
|
140
|
+
avatar_url: string | null;
|
|
141
|
+
}
|
|
142
|
+
export interface BusinessDelivery {
|
|
143
|
+
id: string;
|
|
144
|
+
status: string;
|
|
145
|
+
rider_pickup_confirmed_at: string | null;
|
|
146
|
+
merchant_handover_confirmed_at: string | null;
|
|
147
|
+
inserted_at: string;
|
|
148
|
+
order: {
|
|
149
|
+
id: string;
|
|
150
|
+
order_number: string;
|
|
151
|
+
status: string;
|
|
152
|
+
customer_name: string | null;
|
|
153
|
+
customer_phone: string | null;
|
|
154
|
+
total_minor: number;
|
|
155
|
+
subtotal_minor: number;
|
|
156
|
+
delivery_fee_minor: number;
|
|
157
|
+
currency: string;
|
|
158
|
+
delivery_address: OrderDeliveryAddress | null;
|
|
159
|
+
user: OrderUser | null;
|
|
160
|
+
items: DeliveryOrderItem[];
|
|
161
|
+
} | null;
|
|
162
|
+
rider: DeliveryRider | null;
|
|
163
|
+
}
|
|
164
|
+
export type BusinessDeliveriesResponse = PaginatedResponse<BusinessDelivery>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { PaginationMeta } from './pagination';
|
|
2
|
+
export interface WalletBalanceItem {
|
|
3
|
+
type: 'buyer' | 'business' | 'rider';
|
|
4
|
+
amount_minor: number;
|
|
5
|
+
currency: string;
|
|
6
|
+
business_id?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface WalletBalanceResponse {
|
|
9
|
+
data: {
|
|
10
|
+
balances: WalletBalanceItem[];
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export interface WalletEntry {
|
|
14
|
+
id: string;
|
|
15
|
+
type: string;
|
|
16
|
+
amount_minor: number;
|
|
17
|
+
currency: string;
|
|
18
|
+
balance_after: number;
|
|
19
|
+
description: string | null;
|
|
20
|
+
inserted_at: string;
|
|
21
|
+
}
|
|
22
|
+
export interface WalletHistoryResponse {
|
|
23
|
+
data: {
|
|
24
|
+
entries: WalletEntry[];
|
|
25
|
+
};
|
|
26
|
+
pagination: PaginationMeta;
|
|
27
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* POS types — minimal shapes used by sync transports and repositories.
|
|
3
|
+
*/
|
|
4
|
+
export interface POSOrderItem {
|
|
5
|
+
menu_item_id: string;
|
|
6
|
+
quantity: number;
|
|
7
|
+
addons?: unknown[];
|
|
8
|
+
}
|
|
9
|
+
export interface POSOrderCreateRequest {
|
|
10
|
+
items: POSOrderItem[];
|
|
11
|
+
order_type?: string;
|
|
12
|
+
customer_name?: string | null;
|
|
13
|
+
customer_phone?: string | null;
|
|
14
|
+
pos_payment_method?: string;
|
|
15
|
+
total_minor?: number;
|
|
16
|
+
order_number?: string;
|
|
17
|
+
command_id?: string;
|
|
18
|
+
local_order_number?: string;
|
|
19
|
+
[key: string]: unknown;
|
|
20
|
+
}
|
|
21
|
+
export interface POSOrderPreviewRequest {
|
|
22
|
+
items: POSOrderItem[];
|
|
23
|
+
order_type: string;
|
|
24
|
+
customer_name?: string;
|
|
25
|
+
[key: string]: unknown;
|
|
26
|
+
}
|
|
27
|
+
export interface POSOrderPreviewResponse {
|
|
28
|
+
total_minor: number;
|
|
29
|
+
subtotal_minor: number;
|
|
30
|
+
tax_minor: number;
|
|
31
|
+
delivery_fee_minor: number;
|
|
32
|
+
[key: string]: unknown;
|
|
33
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Application-wide constants — plain config, no expo dependencies.
|
|
3
|
+
* Values can be overridden via createTeincCore config (future).
|
|
4
|
+
*/
|
|
5
|
+
/** Base URL for the API — will be swapped per environment */
|
|
6
|
+
export declare const API_BASE_URL: string;
|
|
7
|
+
/** WebSocket URL for Phoenix Channels */
|
|
8
|
+
export declare const WS_BASE_URL: string;
|
|
9
|
+
/** App metadata */
|
|
10
|
+
export declare const APP_NAME = "Teinc Food Business";
|
|
11
|
+
export declare const APP_VERSION = "1.0.0";
|
|
12
|
+
/** Async storage keys */
|
|
13
|
+
export declare const STORAGE_KEYS: {
|
|
14
|
+
readonly AUTH_TOKEN: "auth_token";
|
|
15
|
+
readonly REFRESH_TOKEN: "refresh_token";
|
|
16
|
+
readonly USER_PROFILE: "user_profile";
|
|
17
|
+
readonly HAS_SEEN_ONBOARDING: "has_seen_onboarding";
|
|
18
|
+
readonly THEME_PREFERENCE: "theme_preference";
|
|
19
|
+
readonly BUSINESS_DATA: "business_data";
|
|
20
|
+
readonly FLEET_DATA: "fleet_data";
|
|
21
|
+
readonly LOCAL_NODE_DATA: "local_node_data";
|
|
22
|
+
readonly PRINTER_SETTINGS: "printer_settings";
|
|
23
|
+
};
|
|
24
|
+
/** Chat storage keys */
|
|
25
|
+
export declare const CHAT_STORAGE_KEYS: {
|
|
26
|
+
readonly MESSAGES: "chat_messages";
|
|
27
|
+
readonly OUTBOX: "chat_outbox";
|
|
28
|
+
};
|
|
29
|
+
/** Chat configuration */
|
|
30
|
+
export declare const CHAT_CONFIG: {
|
|
31
|
+
readonly HEARTBEAT_INTERVAL_MS: 15000;
|
|
32
|
+
readonly HEARTBEAT_TIMEOUT_MS: 10000;
|
|
33
|
+
readonly RECONNECT_BASE_DELAY_MS: 1000;
|
|
34
|
+
readonly RECONNECT_MAX_DELAY_MS: 30000;
|
|
35
|
+
readonly RECONNECT_MAX_ATTEMPTS: 10;
|
|
36
|
+
readonly TYPING_TIMEOUT_MS: 3000;
|
|
37
|
+
readonly MESSAGE_PAGE_SIZE: 50;
|
|
38
|
+
};
|
|
39
|
+
/** OTP configuration */
|
|
40
|
+
export declare const OTP_LENGTH = 4;
|
|
41
|
+
export declare const OTP_RESEND_DELAY_SECONDS = 60;
|
|
42
|
+
/** Pagination defaults */
|
|
43
|
+
export declare const DEFAULT_PAGE_SIZE = 20;
|
|
44
|
+
/**
|
|
45
|
+
* Max time the Sync Engine waits for a cloud command before treating the cloud
|
|
46
|
+
* as unreachable and falling back to the Local Node or the offline outbox.
|
|
47
|
+
* Keeps the terminal responsive (fast) even when the internet is slow.
|
|
48
|
+
*/
|
|
49
|
+
export declare const CLOUD_COMMAND_TIMEOUT_MS = 2500;
|
|
50
|
+
export declare const appVersion = "1.0.0";
|
|
51
|
+
/** Default config bundle for createTeincCore overrides */
|
|
52
|
+
export declare const DEFAULTS: {
|
|
53
|
+
readonly API_BASE_URL: string;
|
|
54
|
+
readonly WS_BASE_URL: string;
|
|
55
|
+
readonly APP_NAME: "Teinc Food Business";
|
|
56
|
+
readonly APP_VERSION: "1.0.0";
|
|
57
|
+
readonly STORAGE_KEYS: {
|
|
58
|
+
readonly AUTH_TOKEN: "auth_token";
|
|
59
|
+
readonly REFRESH_TOKEN: "refresh_token";
|
|
60
|
+
readonly USER_PROFILE: "user_profile";
|
|
61
|
+
readonly HAS_SEEN_ONBOARDING: "has_seen_onboarding";
|
|
62
|
+
readonly THEME_PREFERENCE: "theme_preference";
|
|
63
|
+
readonly BUSINESS_DATA: "business_data";
|
|
64
|
+
readonly FLEET_DATA: "fleet_data";
|
|
65
|
+
readonly LOCAL_NODE_DATA: "local_node_data";
|
|
66
|
+
readonly PRINTER_SETTINGS: "printer_settings";
|
|
67
|
+
};
|
|
68
|
+
readonly CHAT_STORAGE_KEYS: {
|
|
69
|
+
readonly MESSAGES: "chat_messages";
|
|
70
|
+
readonly OUTBOX: "chat_outbox";
|
|
71
|
+
};
|
|
72
|
+
readonly CHAT_CONFIG: {
|
|
73
|
+
readonly HEARTBEAT_INTERVAL_MS: 15000;
|
|
74
|
+
readonly HEARTBEAT_TIMEOUT_MS: 10000;
|
|
75
|
+
readonly RECONNECT_BASE_DELAY_MS: 1000;
|
|
76
|
+
readonly RECONNECT_MAX_DELAY_MS: 30000;
|
|
77
|
+
readonly RECONNECT_MAX_ATTEMPTS: 10;
|
|
78
|
+
readonly TYPING_TIMEOUT_MS: 3000;
|
|
79
|
+
readonly MESSAGE_PAGE_SIZE: 50;
|
|
80
|
+
};
|
|
81
|
+
readonly OTP_LENGTH: 4;
|
|
82
|
+
readonly OTP_RESEND_DELAY_SECONDS: 60;
|
|
83
|
+
readonly DEFAULT_PAGE_SIZE: 20;
|
|
84
|
+
readonly CLOUD_COMMAND_TIMEOUT_MS: 2500;
|
|
85
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Application-wide constants — plain config, no expo dependencies.
|
|
4
|
+
* Values can be overridden via createTeincCore config (future).
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.DEFAULTS = exports.appVersion = exports.CLOUD_COMMAND_TIMEOUT_MS = exports.DEFAULT_PAGE_SIZE = exports.OTP_RESEND_DELAY_SECONDS = exports.OTP_LENGTH = exports.CHAT_CONFIG = exports.CHAT_STORAGE_KEYS = exports.STORAGE_KEYS = exports.APP_VERSION = exports.APP_NAME = exports.WS_BASE_URL = exports.API_BASE_URL = void 0;
|
|
8
|
+
/** Base URL for the API — will be swapped per environment */
|
|
9
|
+
exports.API_BASE_URL = process.env.EXPO_PUBLIC_API_URL ??
|
|
10
|
+
process.env.API_URL ??
|
|
11
|
+
"http://localhost:4000/api/v1";
|
|
12
|
+
/** WebSocket URL for Phoenix Channels */
|
|
13
|
+
exports.WS_BASE_URL = process.env.EXPO_PUBLIC_WS_URL ??
|
|
14
|
+
process.env.WS_URL ??
|
|
15
|
+
"ws://localhost:4000";
|
|
16
|
+
/** App metadata */
|
|
17
|
+
exports.APP_NAME = "Teinc Food Business";
|
|
18
|
+
exports.APP_VERSION = "1.0.0";
|
|
19
|
+
/** Async storage keys */
|
|
20
|
+
exports.STORAGE_KEYS = {
|
|
21
|
+
AUTH_TOKEN: "auth_token",
|
|
22
|
+
REFRESH_TOKEN: "refresh_token",
|
|
23
|
+
USER_PROFILE: "user_profile",
|
|
24
|
+
HAS_SEEN_ONBOARDING: "has_seen_onboarding",
|
|
25
|
+
THEME_PREFERENCE: "theme_preference",
|
|
26
|
+
BUSINESS_DATA: "business_data",
|
|
27
|
+
FLEET_DATA: "fleet_data",
|
|
28
|
+
LOCAL_NODE_DATA: "local_node_data",
|
|
29
|
+
PRINTER_SETTINGS: "printer_settings",
|
|
30
|
+
};
|
|
31
|
+
/** Chat storage keys */
|
|
32
|
+
exports.CHAT_STORAGE_KEYS = {
|
|
33
|
+
MESSAGES: "chat_messages",
|
|
34
|
+
OUTBOX: "chat_outbox",
|
|
35
|
+
};
|
|
36
|
+
/** Chat configuration */
|
|
37
|
+
exports.CHAT_CONFIG = {
|
|
38
|
+
HEARTBEAT_INTERVAL_MS: 15000,
|
|
39
|
+
HEARTBEAT_TIMEOUT_MS: 10000,
|
|
40
|
+
RECONNECT_BASE_DELAY_MS: 1000,
|
|
41
|
+
RECONNECT_MAX_DELAY_MS: 30000,
|
|
42
|
+
RECONNECT_MAX_ATTEMPTS: 10,
|
|
43
|
+
TYPING_TIMEOUT_MS: 3000,
|
|
44
|
+
MESSAGE_PAGE_SIZE: 50,
|
|
45
|
+
};
|
|
46
|
+
/** OTP configuration */
|
|
47
|
+
exports.OTP_LENGTH = 4;
|
|
48
|
+
exports.OTP_RESEND_DELAY_SECONDS = 60;
|
|
49
|
+
/** Pagination defaults */
|
|
50
|
+
exports.DEFAULT_PAGE_SIZE = 20;
|
|
51
|
+
/**
|
|
52
|
+
* Max time the Sync Engine waits for a cloud command before treating the cloud
|
|
53
|
+
* as unreachable and falling back to the Local Node or the offline outbox.
|
|
54
|
+
* Keeps the terminal responsive (fast) even when the internet is slow.
|
|
55
|
+
*/
|
|
56
|
+
exports.CLOUD_COMMAND_TIMEOUT_MS = 2500;
|
|
57
|
+
// Expo version removed; expose static version for now
|
|
58
|
+
exports.appVersion = exports.APP_VERSION;
|
|
59
|
+
/** Default config bundle for createTeincCore overrides */
|
|
60
|
+
exports.DEFAULTS = {
|
|
61
|
+
API_BASE_URL: exports.API_BASE_URL,
|
|
62
|
+
WS_BASE_URL: exports.WS_BASE_URL,
|
|
63
|
+
APP_NAME: exports.APP_NAME,
|
|
64
|
+
APP_VERSION: exports.APP_VERSION,
|
|
65
|
+
STORAGE_KEYS: exports.STORAGE_KEYS,
|
|
66
|
+
CHAT_STORAGE_KEYS: exports.CHAT_STORAGE_KEYS,
|
|
67
|
+
CHAT_CONFIG: exports.CHAT_CONFIG,
|
|
68
|
+
OTP_LENGTH: exports.OTP_LENGTH,
|
|
69
|
+
OTP_RESEND_DELAY_SECONDS: exports.OTP_RESEND_DELAY_SECONDS,
|
|
70
|
+
DEFAULT_PAGE_SIZE: exports.DEFAULT_PAGE_SIZE,
|
|
71
|
+
CLOUD_COMMAND_TIMEOUT_MS: exports.CLOUD_COMMAND_TIMEOUT_MS,
|
|
72
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Clipboard helper — no-op stub in core. Host apps inject real clipboard.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.copyToClipboard = void 0;
|
|
7
|
+
exports.setClipboardImpl = setClipboardImpl;
|
|
8
|
+
let clipboardImpl = null;
|
|
9
|
+
function setClipboardImpl(fn) {
|
|
10
|
+
clipboardImpl = fn;
|
|
11
|
+
}
|
|
12
|
+
const copyToClipboard = async (text) => {
|
|
13
|
+
if (clipboardImpl) {
|
|
14
|
+
await clipboardImpl(text);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if (typeof navigator !== "undefined" && navigator.clipboard) {
|
|
18
|
+
await navigator.clipboard.writeText(text);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
// fallback: no-op
|
|
22
|
+
};
|
|
23
|
+
exports.copyToClipboard = copyToClipboard;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Currency Utility — no RN/store dependencies.
|
|
3
|
+
*/
|
|
4
|
+
export declare const DEFAULT_CURRENCY = "GHS";
|
|
5
|
+
export declare function getCurrencySymbol(currency: string): string;
|
|
6
|
+
export declare function formatPrice(amount: number, currency?: string): string;
|
|
7
|
+
export declare function formatPriceFromMinor(amountMinor: number, currency?: string): string;
|
|
8
|
+
export declare function useCurrency(): string;
|
|
9
|
+
export declare function useCurrencySymbol(): string;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Currency Utility — no RN/store dependencies.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.DEFAULT_CURRENCY = void 0;
|
|
7
|
+
exports.getCurrencySymbol = getCurrencySymbol;
|
|
8
|
+
exports.formatPrice = formatPrice;
|
|
9
|
+
exports.formatPriceFromMinor = formatPriceFromMinor;
|
|
10
|
+
exports.useCurrency = useCurrency;
|
|
11
|
+
exports.useCurrencySymbol = useCurrencySymbol;
|
|
12
|
+
exports.DEFAULT_CURRENCY = "GHS";
|
|
13
|
+
const CURRENCY_SYMBOLS = {
|
|
14
|
+
GHS: "GH₵",
|
|
15
|
+
USD: "$",
|
|
16
|
+
NGN: "₦",
|
|
17
|
+
KES: "KSh",
|
|
18
|
+
EUR: "€",
|
|
19
|
+
GBP: "£",
|
|
20
|
+
};
|
|
21
|
+
function getCurrencySymbol(currency) {
|
|
22
|
+
return CURRENCY_SYMBOLS[currency] || currency;
|
|
23
|
+
}
|
|
24
|
+
function formatPrice(amount, currency = exports.DEFAULT_CURRENCY) {
|
|
25
|
+
return `${getCurrencySymbol(currency)}${amount.toFixed(2)}`;
|
|
26
|
+
}
|
|
27
|
+
function formatPriceFromMinor(amountMinor, currency = exports.DEFAULT_CURRENCY) {
|
|
28
|
+
const amount = amountMinor / 100;
|
|
29
|
+
return formatPrice(amount, currency);
|
|
30
|
+
}
|
|
31
|
+
// Compatibility hooks — return default when no location adapter injected
|
|
32
|
+
function useCurrency() {
|
|
33
|
+
return exports.DEFAULT_CURRENCY;
|
|
34
|
+
}
|
|
35
|
+
function useCurrencySymbol() {
|
|
36
|
+
return getCurrencySymbol(exports.DEFAULT_CURRENCY);
|
|
37
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function extractFromResponseBody(data: Record<string, unknown>): string | null;
|
|
2
|
+
export declare function extractApiErrorMessage(error: unknown): string;
|
|
3
|
+
export declare function extractApiErrorCode(error: unknown): string | undefined;
|
|
4
|
+
export { ApiError } from "../adapters/http";
|