@use-stall/types 0.2.4 → 0.2.6

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/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@use-stall/types",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "description": "Type declarations for Stall SDKs",
5
5
  "types": "index.d.ts",
6
6
  "type": "module",
7
7
  "main": "index.js",
8
8
  "module": "index.js",
9
9
  "unpkg": "index.js",
10
- "private": false
10
+ "private":false
11
11
  }
@@ -1,4 +1,4 @@
1
- type ModuleKey =
1
+ export type ConnectorModuleKey =
2
2
  | "products"
3
3
  | "variants"
4
4
  | "collections"
@@ -24,7 +24,7 @@ type ModuleKey =
24
24
  | "fulfillments"; // Individual fulfillment instances for an order
25
25
 
26
26
  export interface ConnectorModulesType {
27
- [key in ModuleKey]: {
27
+ [key in ConnectorModuleKey]: {
28
28
  supported: boolean;
29
29
  actions: {
30
30
  create: boolean;
@@ -1,5 +1,5 @@
1
1
  import type { UnifiedCustomerAddressType } from "./customers";
2
- export type FulfillmentMethods =
2
+ export type UnifiedFulfillmentMethods =
3
3
  | "shipment" // via carrier / courier to an address
4
4
  | "local_delivery" // delivered by merchant or local fleet
5
5
  | "pickup" // customer picks up at a physical location / collection
@@ -7,25 +7,25 @@ export type FulfillmentMethods =
7
7
  | "digital" // purely digital delivery (email, download, etc.)
8
8
  | "service"; // in-person or remote service fulfillment
9
9
 
10
- export interface FulfillmentProvider {
10
+ export interface UnifiedFulfillmentProvider {
11
11
  id: string;
12
12
  title: string;
13
13
  description: string;
14
14
  logo: string;
15
- supported_methods: FulfillmentMethodType[];
15
+ supported_methods: UnifiedFulfillmentMethodType[];
16
16
  supported_countries: string[];
17
17
  integration_url: string;
18
18
  integration_docs: string;
19
19
  active: boolean;
20
20
  }
21
21
 
22
- export interface FulfillmentMethodType {
23
- type: FulfillmentMethods;
22
+ export interface UnifiedFulfillmentMethodType {
23
+ type: UnifiedFulfillmentMethods;
24
24
  offline_support: boolean;
25
25
  instant: boolean; // whether the fulfillment is done instantly like collection/pickup
26
26
  }
27
27
 
28
- export interface FulfillmentProviderConfigType {
28
+ export interface UnifiedFulfillmentProviderConfigType {
29
29
  id: string;
30
30
  provider: string; // provider id
31
31
  mode: "live" | "test";
@@ -36,7 +36,7 @@ export interface FulfillmentProviderConfigType {
36
36
  updated_at: string;
37
37
  }
38
38
 
39
- export type FulFillmentStatus =
39
+ export type UnifiedFulfillmentStatus =
40
40
  | "pending"
41
41
  | "packing"
42
42
  | "dispatched"
@@ -45,7 +45,7 @@ export type FulFillmentStatus =
45
45
  | "cancelled"
46
46
  | "returned";
47
47
 
48
- export interface FulFillmentLineItem {
48
+ export interface UnifiedFulfillmentLineItem {
49
49
  id: string;
50
50
  sku: string;
51
51
  name: string;
@@ -59,7 +59,7 @@ export interface FulFillmentLineItem {
59
59
  amount: number;
60
60
  }
61
61
 
62
- export interface OrderFulfillment {
62
+ export interface UnifiedFulfillmentType {
63
63
  id: string;
64
64
  order_id: string;
65
65
  tracking_number: string;
package/src/orders.d.ts CHANGED
@@ -1,23 +1,28 @@
1
1
  import type { UnifiedCustomerAddressType } from "./customers";
2
+ import type { UnifiedFulfillmentStatus, UnifiedFulfillmentType } from "./fulfillment";
3
+ import type { UnifiedPaymentCollectionType } from "./payments";
4
+
5
+ export type UnifiedOrderStatuses =
6
+ | "pending"
7
+ | "processing"
8
+ | "completed"
9
+ | "cancelled"
10
+ | "failed"
11
+ | "on-hold"
12
+ | "refunded"
13
+ | "partially refunded"
14
+ | "trash";
2
15
 
3
16
  /* eslint-disable @typescript-eslint/no-explicit-any */
4
17
  export interface UnifiedOrderType {
5
18
  id: string;
6
19
  location_id: string;
7
20
  organization_id: string;
21
+ channel_id: string;
8
22
  device_id: string;
9
23
  staff_id: string;
10
24
  order_number: string;
11
- status:
12
- | "pending"
13
- | "processing"
14
- | "completed"
15
- | "cancelled"
16
- | "failed"
17
- | "on-hold"
18
- | "refunded"
19
- | "partially refunded"
20
- | "trash";
25
+ status: UnifiedOrderStatuses;
21
26
  created_at: string;
22
27
  updated_at: string;
23
28
  origin: { name: string; id: string; version: string; [key: string]: string };
@@ -35,7 +40,10 @@ export interface UnifiedOrderType {
35
40
  tax_lines: UnifiedTaxLineType[]; // Array of applied taxes
36
41
  discount: number | string; // Discount for this item
37
42
  discounts: UnifiedDiscountType[];
38
- fulfillment: UnifiedFulfillmentType;
43
+ fulfillment: {
44
+ status: UnifiedFulfillmentStatus;
45
+ fulfillments: UnifiedFulfillmentType;
46
+ };
39
47
  refunds: {
40
48
  id: string;
41
49
  reason: string;
@@ -88,100 +96,16 @@ export interface UnifiedDiscountType {
88
96
 
89
97
  export interface UnifiedOrderPaymentDetailsType {
90
98
  total_amount: number;
99
+ tip_amount: number;
91
100
  overcharge_amount: number;
92
101
  currency: string;
93
102
  date: number; // Timestamp in milliseconds
94
103
  timestamp: string; // ISO string format
95
- payments: UnifiedOrderPaymentType[];
96
- status:
97
- | "pending"
98
- | "processing"
99
- | "paid"
100
- | "partially_paid"
101
- | "failed"
102
- | "refunded";
103
- payment_plan: {
104
- plan: "full" | "partial" | "layaway" | "installment";
105
- details?: {
106
- required_deposit: number;
107
- interval:
108
- | "daily"
109
- | "weekly"
110
- | "bi-weekly"
111
- | "monthly"
112
- | "quarterly"
113
- | "semi-annually"
114
- | "annually";
115
- intervals: number;
116
- flexible: boolean;
117
- start_date: number;
118
- end_date: number;
119
- };
120
- };
121
- misc: {
122
- split: {
123
- is_split: boolean;
124
- split_count: number;
125
- };
126
- tip: number;
127
- };
128
- metadata?: Record<string, any>;
129
- }
130
-
131
- export interface UnifiedOrderPaymentType {
132
- id: string;
133
- index?: number;
134
- stall_id: string;
135
- created_at: number;
136
- updated_at: number;
137
- completed_at: number;
138
- method_id: string; // Reference to UnifiedPaymentMethodType
139
- method_name: string;
140
- amount: number;
141
- currency: string;
142
- transaction_id: string;
143
- status:
144
- | "pending"
145
- | "processing"
146
- | "successful"
147
- | "failed"
148
- | "voided"
149
- | "refunded";
150
- refunded_amount?: number;
151
- tendered_amount: number;
152
- change_due: number;
104
+ payments: UnifiedPaymentCollectionType[];
105
+ status: "pending" | "processing" | "paid" | "partially_paid";
153
106
  metadata?: Record<string, any>;
154
107
  }
155
108
 
156
- export interface UnifiedFulfillmentType {
157
- id: string;
158
- status:
159
- | "pending"
160
- | "fulfilled"
161
- | "dispatched"
162
- | "cancelled"
163
- | "failed"
164
- | "on-hold"
165
- | "refunded"
166
- | string;
167
- fulfillment_method: "in-store" | "pick-up" | "delivery" | "shipment";
168
- fulfillment_date: string; // Date when the order was fulfilled (ISO format)
169
- dispatch_date?: string; // Date when the order was dispatched (ISO format)
170
- order_id: string; // Unique ID for the order being fulfilled
171
- items: UnifiedFulfilledItemType[]; // List of items being fulfilled
172
- tracking_id: string; // Optional tracking number for shipments
173
- fulfillment_provider: { id: string; name: string }; // Provider handling the fulfillment
174
- assigned_to?: string; // Staff or employee handling fulfillment
175
- cost?: number | string; // Cost of shipping (if applicable)
176
- notes?: string; // Any notes related to the fulfillment process
177
- }
178
-
179
- export interface UnifiedFulfilledItemType {
180
- item_id: string; // Unique ID for the product or variant being fulfilled
181
- quantity: number; // Quantity of the product being fulfilled
182
- fulfilled_quantity: number; // How many were fulfilled (if partial fulfillment allowed)
183
- }
184
-
185
109
  export interface LocalSplitPaymentType {
186
110
  split_count: number;
187
111
  split_type: "equal" | "custom";
@@ -211,13 +135,7 @@ export interface UnifiedOrderRefundType {
211
135
  name: string;
212
136
  cost_per_item: number;
213
137
  }[];
214
- refund_method: {
215
- id: string;
216
- name: string;
217
- status: string;
218
- transaction_id: string;
219
- refunded_amount: string | number;
220
- };
138
+ payments: UnifiedPaymentCollectionType[];
221
139
  staff_id: string;
222
140
  device_id: string;
223
141
  location_id: string;
@@ -25,6 +25,9 @@ export interface OrganizationType {
25
25
  created_at: number;
26
26
  updated_at: number;
27
27
  connector?: ConnectorConfigurationType;
28
+ timezone: string;
29
+ onboarded: boolean;
30
+ country: string;
28
31
  }
29
32
 
30
33
  export interface ReceiptType {
package/src/payments.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export type MethodsType =
1
+ export type UnifiedMethodsType =
2
2
  | "terminal"
3
3
  | "soft_pos" // mobile tap to pay on android and ios
4
4
  | "online_checkout"
@@ -8,25 +8,25 @@ export type MethodsType =
8
8
  | "cash"
9
9
  | "manual";
10
10
 
11
- export interface PaymentProviderType {
11
+ export interface UnifiedPaymentProviderType {
12
12
  id: string;
13
13
  title: string;
14
14
  description: string;
15
15
  logo: string;
16
- supported_methods: PaymentMethodType[];
16
+ supported_methods: UnifiedPaymentMethodType[];
17
17
  supported_countries: string[];
18
18
  integration_url: string;
19
19
  integration_docs: string;
20
20
  active: boolean;
21
21
  }
22
22
 
23
- export interface PaymentMethodType {
24
- type: MethodsType;
23
+ export interface UnifiedPaymentMethodType {
24
+ type: UnifiedMethodsType;
25
25
  offline_support: boolean;
26
26
  instant_clear: boolean; // whether the payment is cleared instantly like cash or custom
27
27
  }
28
28
 
29
- export interface PaymentProviderConfigType {
29
+ export interface UnifiedPaymentProviderConfigType {
30
30
  id: string;
31
31
  provider: string; // provider id
32
32
  mode: "live" | "test";
@@ -38,28 +38,127 @@ export interface PaymentProviderConfigType {
38
38
  updated_at: string;
39
39
  }
40
40
 
41
- export type PaymentCollectionStatus =
41
+ export type UnifiedPaymentCollectionStatus =
42
42
  | "pending"
43
43
  | "processing"
44
44
  | "completed"
45
45
  | "failed"
46
- | "cancelled"
47
- | "refunded"
48
- | "partially_refunded";
46
+ | "cancelled";
49
47
 
50
- export interface PaymentCollectionType {
48
+ export type UnifiedPaymentCollectionTransactionType =
49
+ | "sale"
50
+ | "return"
51
+ | "refund"
52
+ | "void"
53
+ | "pay-out"
54
+ | "pay-in";
55
+
56
+ export interface UnifiedPaymentCollectionType {
51
57
  id: string;
58
+ order_id: string;
59
+ user_id: string;
60
+ session_id: string;
52
61
  organization: string;
53
62
  location: string;
54
63
  created_at: string;
55
64
  updated_at: string;
56
- status: PaymentCollectionStatus;
65
+ status: UnifiedPaymentCollectionStatus;
66
+ type: UnifiedPaymentCollectionTransactionType;
57
67
  amount: {
58
68
  currency: string;
59
69
  value: number;
60
70
  };
61
71
  provider_id: string;
62
- payment_method: PaymentMethodType;
72
+ payment_method: UnifiedPaymentMethodType;
63
73
  note: string;
64
74
  metadata: Record<string, any>;
65
75
  }
76
+
77
+ export const medusa = {
78
+ "product": {
79
+ "variants": [
80
+ {
81
+ "prices": [
82
+ {
83
+ "id": "string",
84
+ "title": "string",
85
+ "currency_code": "usd",
86
+ "amount": 0,
87
+ "raw_amount": {},
88
+ "min_quantity": 0,
89
+ "max_quantity": 0,
90
+ "price_set_id": "string",
91
+ "created_at": "2019-08-24T14:15:22Z",
92
+ "updated_at": "2019-08-24T14:15:22Z",
93
+ "deleted_at": "2019-08-24T14:15:22Z"
94
+ }
95
+ ],
96
+ "id": "string",
97
+ "title": "string",
98
+ "sku": "string",
99
+ "barcode": "string",
100
+ "ean": "string",
101
+ "upc": "string",
102
+ "allow_backorder": true,
103
+ "manage_inventory": true,
104
+ "hs_code": "string",
105
+ "origin_country": "string",
106
+ "mid_code": "string",
107
+ "material": "string",
108
+ "weight": 0,
109
+ "length": 0,
110
+ "height": 0,
111
+ "width": 0,
112
+ "options": [
113
+ {"id": "string", "value": "string"}
114
+ ],
115
+ "created_at": "2019-08-24T14:15:22Z",
116
+ "updated_at": "2019-08-24T14:15:22Z",
117
+ "deleted_at": "2019-08-24T14:15:22Z",
118
+ "images": [
119
+ {
120
+ "id": "string",
121
+ "url": "string",
122
+ "rank": 0
123
+ }
124
+ ],
125
+ "thumbnail": "string"
126
+ }
127
+ ],
128
+ "type": {
129
+ "id": "string",
130
+ "value": "string",
131
+ "created_at": "2019-08-24T14:15:22Z",
132
+ "updated_at": "2019-08-24T14:15:22Z"
133
+ },
134
+ "length": 0,
135
+ "title": "string",
136
+ "status": "draft",
137
+ "options": [
138
+ {"id": "string", "title": "string"}
139
+ ],
140
+ "description": "string",
141
+ "id": "string",
142
+ "created_at": "2019-08-24T14:15:22Z",
143
+ "updated_at": "2019-08-24T14:15:22Z",
144
+ "handle": "string",
145
+ "subtitle": "string",
146
+ "is_giftcard": true,
147
+ "thumbnail": "string",
148
+ "width": 0,
149
+ "weight": 0,
150
+ "height": 0,
151
+ "origin_country": "string",
152
+ "hs_code": "string",
153
+ "mid_code": "string",
154
+ "material": "string",
155
+ "collection_id": "string",
156
+ "type_id": "string",
157
+ "images": [
158
+ {"id": "string", "url": "string", "rank": 0}
159
+ ],
160
+ "discountable": true,
161
+ "external_id": "string",
162
+ "deleted_at": "2019-08-24T14:15:22Z"
163
+ }
164
+ }
package/src/product.d.ts CHANGED
@@ -9,6 +9,7 @@ export interface UnifiedProductType {
9
9
  created_at: string;
10
10
  updated_at: string;
11
11
  deleted_at: string;
12
+ channels: string[]; // Channel ids of where this product is available
12
13
  status: "draft" | "private" | "publish" | "pending";
13
14
  type: "simple" | "variable" | "grouped";
14
15
  thumbnail: string;
@@ -24,118 +25,27 @@ export interface UnifiedProductType {
24
25
  price_currency: string;
25
26
  cost_price: number | string;
26
27
  taxable: boolean;
27
- tax_class: string;
28
28
  on_sale: boolean;
29
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
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
32
  in_stock: number | string; // Items available for new orders (In Stock)
33
- on_hand?: number | string; // Total items physically present at the location
33
+ on_hand: number | string; // Total items physically present at the location
34
34
  low_stock_threshold: number | string; // Low stock threshold specific to the location'
35
35
  locations: string[];
36
36
  weight: string;
37
37
  metadata: { [key: string]: string }; // add date in milliseconds
38
38
  }
39
39
 
40
- export interface AttributeType {
40
+ export interface UnifiedProductPriceType {
41
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
42
  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;
43
+ currency_code: string;
44
+ amount: number;
98
45
  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;
46
+ updated_at: string;
47
+ deleted_at: string;
48
+ channel_id: string;
139
49
  }
140
50
 
141
51
  export interface UnifiedAttributeType {