@use-stall/types 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,241 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ export interface UnifiedOrderType {
3
+ id: string;
4
+ location_id: string;
5
+ organization_id: string;
6
+ device_id: string;
7
+ staff_id: string;
8
+ order_number: string;
9
+ status:
10
+ | "pending"
11
+ | "processing"
12
+ | "completed"
13
+ | "cancelled"
14
+ | "failed"
15
+ | "on-hold"
16
+ | "refunded"
17
+ | "partially refunded"
18
+ | "trash";
19
+ created_at: string;
20
+ updated_at: string;
21
+ origin: { name: string; id: string; version: string; [key: string]: string };
22
+ checkout_token: string;
23
+ customer_id: string;
24
+ customer_note: string;
25
+ billing: UnifiedAddressType;
26
+ shipping_address: UnifiedAddressType;
27
+ line_items: UnifiedLineItemType[]; // Array of purchased items (products/variants)
28
+ currency: string; // Currency of the order
29
+ payment: UnifiedOrderPaymentDetailsType;
30
+ subtotal: number | string; // Subtotal price for this item (price * quantity) before tax and discount
31
+ total: number | string; // Total price for this item (price * quantity)
32
+ tax: number | string; // Tax for this item
33
+ tax_lines: UnifiedTaxLineType[]; // Array of applied taxes
34
+ discount: number | string; // Discount for this item
35
+ discounts: UnifiedDiscountType[];
36
+ fulfillment: UnifiedFulfillmentType;
37
+ refunds: {
38
+ id: string;
39
+ reason: string;
40
+ amount: string;
41
+ date: string;
42
+ }[];
43
+ stall_offline_id: string;
44
+ stall_offline_created_at: string;
45
+ stall_offline_updated_at: string;
46
+ stall_offline_deleted_at: string;
47
+ metadata: { [key: string]: any }; // Custom metadata
48
+ }
49
+
50
+ export interface UnifiedLineItemType {
51
+ id: string; // Unique ID for the line item product/variant id
52
+ product_id: string; // Linked product ID
53
+ variant_id: string; // Optional if a product variant was selected
54
+ sku: string;
55
+ title: string;
56
+ thumbnail: string;
57
+ quantity: number | string;
58
+ price: number | string; // Price per item
59
+ original_price: number | string; // Original price useful if oroduct is on sale
60
+ on_sale: boolean; // If the product is on sale
61
+ original_total: number | string; // Original price * quantity before sale
62
+ subtotal: number | string; // Subtotal price for this item (price * quantity) before tax and discount
63
+ total: number | string; // Total price for this item (price * quantity)
64
+ tax: number | string; // Tax for this item
65
+ tax_lines: UnifiedTaxLineType[]; // Array of applied taxes
66
+ discount: number | string; // Discount for this item
67
+ discounts: UnifiedDiscountType[];
68
+ weight: string; // Weight of the product/variant
69
+ metadata: Record<string, any>; // Optional custom fields
70
+ }
71
+
72
+ export interface UnifiedAddressType {
73
+ first_name: string;
74
+ last_name: string;
75
+ company: string;
76
+ address_1: string;
77
+ address_2: string;
78
+ city: string;
79
+ state: string;
80
+ postcode: string;
81
+ country: string;
82
+ email: string;
83
+ phone: string;
84
+ }
85
+
86
+ export interface UnifiedTaxLineType {
87
+ id: string;
88
+ name: string;
89
+ rate: number | string;
90
+ amount: number | string; // Calculated tax amount
91
+ }
92
+
93
+ export interface UnifiedDiscountType {
94
+ code: string;
95
+ amount: number | string; // Discount amount applied
96
+ type: "percentage" | "fixed" | "code";
97
+ name: string;
98
+ metadata: Record<string, any>;
99
+ }
100
+
101
+ export interface UnifiedOrderPaymentDetailsType {
102
+ total_amount: number;
103
+ overcharge_amount: number;
104
+ currency: string;
105
+ date: number; // Timestamp in milliseconds
106
+ timestamp: string; // ISO string format
107
+ payments: UnifiedOrderPaymentType[];
108
+ status:
109
+ | "pending"
110
+ | "processing"
111
+ | "paid"
112
+ | "partially_paid"
113
+ | "failed"
114
+ | "refunded";
115
+ payment_plan: {
116
+ plan: "full" | "partial" | "layaway" | "installment";
117
+ details?: {
118
+ required_deposit: number;
119
+ interval:
120
+ | "daily"
121
+ | "weekly"
122
+ | "bi-weekly"
123
+ | "monthly"
124
+ | "quarterly"
125
+ | "semi-annually"
126
+ | "annually";
127
+ intervals: number;
128
+ flexible: boolean;
129
+ start_date: number;
130
+ end_date: number;
131
+ };
132
+ };
133
+ misc: {
134
+ split: {
135
+ is_split: boolean;
136
+ split_count: number;
137
+ };
138
+ tip: number;
139
+ };
140
+ metadata?: Record<string, any>;
141
+ }
142
+
143
+ export interface UnifiedOrderPaymentType {
144
+ id: string;
145
+ index?: number;
146
+ stall_id: string;
147
+ created_at: number;
148
+ updated_at: number;
149
+ completed_at: number;
150
+ method_id: string; // Reference to UnifiedPaymentMethodType
151
+ method_name: string;
152
+ amount: number;
153
+ currency: string;
154
+ transaction_id: string;
155
+ status:
156
+ | "pending"
157
+ | "processing"
158
+ | "successful"
159
+ | "failed"
160
+ | "voided"
161
+ | "refunded";
162
+ refunded_amount?: number;
163
+ tendered_amount: number;
164
+ change_due: number;
165
+ metadata?: Record<string, any>;
166
+ }
167
+
168
+ export interface UnifiedFulfillmentType {
169
+ id: string;
170
+ status:
171
+ | "pending"
172
+ | "fulfilled"
173
+ | "dispatched"
174
+ | "cancelled"
175
+ | "failed"
176
+ | "on-hold"
177
+ | "refunded"
178
+ | string;
179
+ fulfillment_method: "in-store" | "pick-up" | "delivery" | "shipment";
180
+ fulfillment_date: string; // Date when the order was fulfilled (ISO format)
181
+ dispatch_date?: string; // Date when the order was dispatched (ISO format)
182
+ order_id: string; // Unique ID for the order being fulfilled
183
+ items: UnifiedFulfilledItemType[]; // List of items being fulfilled
184
+ tracking_id: string; // Optional tracking number for shipments
185
+ fulfillment_provider: { id: string; name: string }; // Provider handling the fulfillment
186
+ assigned_to?: string; // Staff or employee handling fulfillment
187
+ cost?: number | string; // Cost of shipping (if applicable)
188
+ notes?: string; // Any notes related to the fulfillment process
189
+ }
190
+
191
+ export interface UnifiedFulfilledItemType {
192
+ item_id: string; // Unique ID for the product or variant being fulfilled
193
+ quantity: number; // Quantity of the product being fulfilled
194
+ fulfilled_quantity: number; // How many were fulfilled (if partial fulfillment allowed)
195
+ }
196
+
197
+ export interface LocalSplitPaymentType {
198
+ split_count: number;
199
+ split_type: "equal" | "custom";
200
+ split_amounts: LocalSplitAmountsType[];
201
+ has_pending: boolean;
202
+ pending_index: number;
203
+ }
204
+
205
+ export interface LocalSplitAmountsType {
206
+ index: number;
207
+ amount: number;
208
+ paid: false;
209
+ }
210
+
211
+ export interface UnifiedOrderRefundType {
212
+ id: string;
213
+ amount: string | number;
214
+ reason: string;
215
+ date: string;
216
+ status: "pending" | "processing" | "completed" | "cancelled" | "failed";
217
+ restock: boolean;
218
+ refund_type: "amount" | "line_items";
219
+ metadata: Record<string, any>;
220
+ line_items: {
221
+ id: string;
222
+ quantity: number;
223
+ name: string;
224
+ cost_per_item: number;
225
+ }[];
226
+ refund_method: {
227
+ id: string;
228
+ name: string;
229
+ status: string;
230
+ transaction_id: string;
231
+ refunded_amount: string | number;
232
+ };
233
+ staff_id: string;
234
+ device_id: string;
235
+ location_id: string;
236
+ organization_id: string;
237
+ stall_offline_id: string;
238
+ stall_offline_created_at: string;
239
+ stall_offline_updated_at: string;
240
+ stall_offline_deleted_at: string;
241
+ }
@@ -0,0 +1,67 @@
1
+ export interface OrganizationType {
2
+ business_type: string;
3
+ organization_name: string;
4
+ organization_size: number | string;
5
+ base_currency: string;
6
+ business_address: string;
7
+ owner: string;
8
+ locations: string[]; // redudant field, Maximum is 30
9
+ id: string;
10
+ created_at: number;
11
+ updated_at?: number;
12
+ active: boolean;
13
+ subscription?: {
14
+ last_payment_id: string;
15
+ metadata: {
16
+ date: string;
17
+ org_id: string;
18
+ owner: string;
19
+ price: string;
20
+ };
21
+ product: string;
22
+ subscription: string;
23
+ };
24
+ logo?: string;
25
+ connector?: { id: string; config: { [key: string]: string } };
26
+ receipt_config?: ReceiptType;
27
+ taxes?: {
28
+ default_tax_region: UnifiedTaxRegionType;
29
+ };
30
+ stall_modules?: OrganizationStallModulesType;
31
+ }
32
+
33
+ export interface OrganizationStallModulesType {
34
+ locations: boolean;
35
+ collections: boolean;
36
+ suppliers: boolean;
37
+ purchase_orders: boolean;
38
+ discounts: boolean;
39
+ taxes: boolean;
40
+ chart_of_accounts: boolean;
41
+ transactions: boolean;
42
+ invoices: boolean;
43
+ bills: boolean;
44
+ }
45
+
46
+ export interface ReceiptType {
47
+ logo: string;
48
+ showStoreLocation: boolean;
49
+ showStorePhone: boolean;
50
+ header: string;
51
+ footer: string;
52
+ headerText: string;
53
+ footerText: string;
54
+ headerColor: string;
55
+ footerColor: string;
56
+ headerFontSize: string;
57
+ footerFontSize: string;
58
+ headerFontFamily: string;
59
+ footerFontFamily: string;
60
+ headerAlignment: string;
61
+ footerAlignment: string;
62
+ includeQR: boolean;
63
+ includeBarcode: boolean;
64
+ qrValue: string;
65
+ barcodeValue: string;
66
+ receipt_size: number;
67
+ }
@@ -0,0 +1,55 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ export interface UnifiedPaymentMethodType {
3
+ id: string;
4
+ external_id: string;
5
+ name: string;
6
+ description: string;
7
+ processing_type: "online" | "manual" | "hardware";
8
+ provider_id: string;
9
+ provider_name: string;
10
+ icon: string;
11
+ enabled: boolean;
12
+ editable: boolean;
13
+ sort_order: number;
14
+ supported_options: UnifiedPaymentMethodSupportedOptionsType;
15
+ supported_currencies: string[]; // Supported currencies (e.g., ["USD", "EUR"])
16
+ payment_plan: {
17
+ default: "full" | "partial" | "layaway" | "installment";
18
+ options: Array<"full" | "partial" | "layaway" | "installment">;
19
+ };
20
+ config?: UnifiedPaymentMethodConfigType;
21
+ rules: UnifiedPaymentMethodRulesType;
22
+ metadata?: Record<string, any>;
23
+ }
24
+
25
+ export interface UnifiedPaymentMethodSupportedOptionsType {
26
+ refunds: boolean;
27
+ void: boolean;
28
+ tipping: boolean;
29
+ split: boolean;
30
+ offline: boolean;
31
+ register: boolean; // Track register sessions
32
+ }
33
+
34
+ export interface UnifiedPaymentMethodConfigType {
35
+ auth_type: "none" | "basic" | "bearer" | "apikey";
36
+ headers: Record<string, any>;
37
+ params: Record<string, any>;
38
+ body: Record<string, any>;
39
+ method: "GET" | "POST" | "PUT" | "PATCH";
40
+ endpoint: string;
41
+ callback_url: string;
42
+ webhook_url: string;
43
+ redirect: boolean;
44
+ redirect_url: string;
45
+ }
46
+
47
+ interface UnifiedPaymentMethodRulesType {
48
+ minimum_amount: number;
49
+ maximum_amount: number;
50
+ requires_approval: boolean;
51
+ marks_as_paid: boolean;
52
+ marks_as_fulfilled: boolean;
53
+ open_drawer: boolean;
54
+ has_tendered_amount: boolean;
55
+ }
package/src/pos.d.ts ADDED
@@ -0,0 +1,82 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ export interface PosTileType {
3
+ position: number;
4
+ type: "product" | "category" | "collection" | "action" | "custom";
5
+ label: string;
6
+ image: {
7
+ type: "icon" | "image";
8
+ src: string;
9
+ };
10
+ color: string;
11
+ action_id: string;
12
+ author: "system" | "external";
13
+ id: string;
14
+ metadata: Record<string, any>;
15
+ live?: {
16
+ live: boolean;
17
+ method_id: string;
18
+ order_key: string;
19
+ };
20
+ }
21
+
22
+ export interface PosTilesPageType {
23
+ page_index: number;
24
+ title: string;
25
+ locked: boolean;
26
+ limit: number | "unlimited";
27
+ tiles: PosTileType[];
28
+ }
29
+
30
+ export interface ActivePosTileTabType
31
+ extends Pick<PosTilesPageType, "page_index" | "title" | "limit" | "locked"> {
32
+ tiles_count: number;
33
+ }
34
+
35
+ export interface PosTilesProfileType {
36
+ access: {
37
+ type: "global" | "custom";
38
+ user_id: string;
39
+ };
40
+ pages: PosTilesPageType[];
41
+ type: "retail" | "restaurant";
42
+ id: string;
43
+ }
44
+
45
+ export interface PosTileSlotType {
46
+ index: number;
47
+ tile: PosTileType | null;
48
+ }
49
+
50
+ export interface ShortcutType {
51
+ id: string;
52
+ position: number;
53
+ author: "system" | "external";
54
+ icon: {
55
+ type: "local" | "external";
56
+ src: string;
57
+ };
58
+ action_id: string;
59
+ title: string;
60
+ component?: React.ComponentType<any>;
61
+ }
62
+
63
+ export interface ShortcutActionType {
64
+ id: string;
65
+ description: string;
66
+ author: string;
67
+ action: (...args: any[]) => void;
68
+ }
69
+
70
+ export interface LocalTilesPagesConfigType {
71
+ view: "grid" | "list";
72
+ locked: boolean;
73
+ }
74
+
75
+ export interface ActionsEntryType {
76
+ [key: string]: ActionEntryType;
77
+ }
78
+
79
+ export interface ActionEntryType {
80
+ action: React.ComponentType<any>;
81
+ props: Record<string, any>;
82
+ }
@@ -0,0 +1,232 @@
1
+ export interface UnifiedProductType {
2
+ id: string;
3
+ sku: string;
4
+ barcode: string;
5
+ title: string;
6
+ handle: string;
7
+ description: string;
8
+ body_html: string;
9
+ created_at: string;
10
+ updated_at: string;
11
+ deleted_at: string;
12
+ status: "draft" | "private" | "publish" | "pending";
13
+ type: "simple" | "variable" | "grouped";
14
+ thumbnail: string;
15
+ images: UnifiedProductImagesType[];
16
+ brand: string;
17
+ tags: string[];
18
+ categories: string[];
19
+ attributes: UnifiedAttributeType[];
20
+ collections: string[];
21
+ variants: string[];
22
+ price: number | string;
23
+ sale_price: number | string;
24
+ price_currency: string;
25
+ cost_price: number | string;
26
+ taxable: boolean;
27
+ tax_class: string;
28
+ on_sale: boolean;
29
+ track_inventory: boolean;
30
+ unavailable?: number | string; // Items not available for sale (e.g., damaged, expired)
31
+ committed?: number | string; // Items reserved for existing orders but not yet shipped
32
+ in_stock: number | string; // Items available for new orders (In Stock)
33
+ on_hand?: number | string; // Total items physically present at the location
34
+ low_stock_threshold: number | string; // Low stock threshold specific to the location'
35
+ locations: string[];
36
+ weight: string;
37
+ metadata: { [key: string]: string }; // add date in milliseconds
38
+ }
39
+
40
+ export interface AttributeType {
41
+ id: string;
42
+ position: number;
43
+ name: string;
44
+ options: string[];
45
+ }
46
+
47
+ export interface VariantsType {
48
+ id: string;
49
+ sku: string;
50
+ barcode: string;
51
+ product_id: string;
52
+ date: string;
53
+ title: string;
54
+ description: string;
55
+ price: number | string;
56
+ cost_price: number | string;
57
+ sale_price: number | string;
58
+ on_sale: boolean;
59
+ status: "draft" | "private" | "publish" | "pending";
60
+ track_inventory: boolean;
61
+ unavailable: number | string; // Items not available for sale (e.g., damaged, expired)
62
+ committed: number | string; // Items reserved for existing orders but not yet shipped
63
+ in_stock: number | string; // Items available for new orders (In Stock)
64
+ on_hand: number | string; // Total items physically present at the location
65
+ low_stock_threshold: number | string; // Low stock threshold specific to the location
66
+ weight: string;
67
+ thumbnail: string;
68
+ attributes: VariantsAttributeType[];
69
+ metadata: { [key: string]: string };
70
+ }
71
+
72
+ export interface VariantsAttributeType {
73
+ id: string;
74
+ name: string;
75
+ option: string;
76
+ }
77
+
78
+ export interface LocationStockType {
79
+ location_id: string;
80
+ unavailable: number | string; // Items not available for sale (e.g., damaged, expired)
81
+ committed: number | string; // Items reserved for existing orders but not yet shipped
82
+ in_stock: number | string; // Items available for new orders (In Stock)
83
+ on_hand: number | string; // Total items physically present at the location
84
+ low_stock_threshold: number | string; // Low stock threshold specific to the location
85
+ }
86
+
87
+ export interface LocationInventoryItemType {
88
+ id: string;
89
+ location_id: string;
90
+ product_id: string;
91
+ variant_id: string;
92
+ unavailable: number | string; // Items not available for sale (e.g., damaged, expired)
93
+ committed: number | string; // Items reserved for existing orders but not yet shipped
94
+ in_stock: number | string; // Items available for new orders (In Stock)
95
+ on_hand: number | string; // Total items physically present at the location
96
+ low_stock_threshold: number | string; // Low stock threshold specific to the location
97
+ last_updated_at: string;
98
+ created_at: string;
99
+ }
100
+
101
+ export interface CategoryType {
102
+ id: string;
103
+ name: string;
104
+ description: string;
105
+ thumbnail: string;
106
+ metadata: { [key: string]: string };
107
+ date: string;
108
+ count: number;
109
+ parent_id: string;
110
+ }
111
+
112
+ export interface CollectionType {
113
+ id: string;
114
+ name: string;
115
+ description: string;
116
+ thumbnail: string;
117
+ items: {
118
+ type: "product" | "category";
119
+ id: string;
120
+ }[];
121
+ metadata: { [key: string]: string };
122
+ }
123
+
124
+ export interface BrandType {
125
+ id: string;
126
+ name: string;
127
+ description: string;
128
+ logo: string;
129
+ metadata: { [key: string]: string };
130
+ }
131
+
132
+ export interface ProductImagesType {
133
+ index: number;
134
+ id: number;
135
+ src: string;
136
+ name: string;
137
+ alt: string;
138
+ date: string;
139
+ }
140
+
141
+ export interface UnifiedAttributeType {
142
+ id: string;
143
+ position: number;
144
+ name: string;
145
+ options: string[];
146
+ }
147
+
148
+ export interface UnifiedVariantsType {
149
+ id: string;
150
+ sku: string;
151
+ barcode: string;
152
+ product_id: string;
153
+ date: string;
154
+ title: string;
155
+ description: string;
156
+ price: number | string;
157
+ cost_price: number | string;
158
+ sale_price: number | string;
159
+ on_sale: boolean;
160
+ status: "draft" | "private" | "publish" | "pending";
161
+ tax_class: string;
162
+ track_inventory: boolean;
163
+ unavailable?: number | string; // Items not available for sale (e.g., damaged, expired)
164
+ committed?: number | string; // Items reserved for existing orders but not yet shipped
165
+ in_stock: number | string; // Items available for new orders (In Stock)
166
+ on_hand?: number | string; // Total items physically present at the location
167
+ low_stock_threshold: number | string; // Low stock threshold specific to the location
168
+ weight: string;
169
+ thumbnail: string;
170
+ attributes: UnifiedVariantsAttributeType[];
171
+ metadata: { [key: string]: string };
172
+ }
173
+
174
+ export interface UnifiedVariantsAttributeType {
175
+ id: string;
176
+ name: string;
177
+ option: string;
178
+ }
179
+
180
+ export interface UnifiedLocationStockType {
181
+ id: string;
182
+ location_id: string;
183
+ product_id: string;
184
+ variant_id: string;
185
+ unavailable: number | string; // Items not available for sale (e.g., damaged, expired)
186
+ committed: number | string; // Items reserved for existing orders but not yet shipped
187
+ in_stock: number | string; // Items available for new orders (In Stock)
188
+ on_hand: number | string; // Total items physically present at the location
189
+ low_stock_threshold: number | string; // Low stock threshold specific to the location
190
+ last_updatedAt: string;
191
+ created_at: string;
192
+ }
193
+
194
+ export interface UnifiedCategoryType {
195
+ id: string;
196
+ name: string;
197
+ description: string;
198
+ thumbnail: string;
199
+ metadata: { [key: string]: string };
200
+ date: string;
201
+ count: number;
202
+ parent_id: string;
203
+ }
204
+
205
+ export interface UnifiedCollectionType {
206
+ id: string;
207
+ name: string;
208
+ description: string;
209
+ thumbnail: string;
210
+ metadata: { [key: string]: string };
211
+ linked_products: string[];
212
+ linked_categories: string[];
213
+ createAt: string;
214
+ lastUpdatedAt: string;
215
+ }
216
+
217
+ export interface UnifiedBrandType {
218
+ id: string;
219
+ name: string;
220
+ description: string;
221
+ logo: string;
222
+ metadata: { [key: string]: string };
223
+ }
224
+
225
+ export interface UnifiedProductImagesType {
226
+ index: number;
227
+ id: number;
228
+ src: string;
229
+ name: string;
230
+ alt: string;
231
+ date: string;
232
+ }