@growupsell/commerce 1.0.0-alpha.1 → 1.0.0-alpha.3
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/dist/checkout-DDNMdKbR.d.ts +584 -0
- package/dist/{chunk-YZJTPFCH.js → chunk-BORVKACK.js} +160 -59
- package/dist/chunk-BORVKACK.js.map +1 -0
- package/dist/chunk-HGCKDE7D.js +2988 -0
- package/dist/chunk-HGCKDE7D.js.map +1 -0
- package/dist/chunk-JBOZQJ4X.js +472 -0
- package/dist/chunk-JBOZQJ4X.js.map +1 -0
- package/dist/chunk-NNKXIBK4.js +1 -0
- package/dist/chunk-NNKXIBK4.js.map +1 -0
- package/dist/chunk-W2CJSBV4.js +329 -0
- package/dist/chunk-W2CJSBV4.js.map +1 -0
- package/dist/{index-tlJ3s67B.d.ts → client-RzekAHeO.d.ts} +73 -287
- package/dist/http/index.d.ts +32 -2
- package/dist/http/index.js +2 -1
- package/dist/index.d.ts +6 -3
- package/dist/index.js +123 -4
- package/dist/rules/index.d.ts +462 -78
- package/dist/rules/index.js +103 -3
- package/dist/sku-ViHXTvEw.d.ts +168 -0
- package/dist/stores/index.d.ts +843 -1
- package/dist/stores/index.js +22 -0
- package/package.json +1 -1
- package/dist/chunk-4PHF3WVQ.js +0 -76
- package/dist/chunk-4PHF3WVQ.js.map +0 -1
- package/dist/chunk-YZJTPFCH.js.map +0 -1
- package/dist/promotions-Ck9FZD7h.d.ts +0 -298
|
@@ -0,0 +1,584 @@
|
|
|
1
|
+
/** Cart domain types. The backend calculates every total; the library only converts them. */
|
|
2
|
+
/** `delivery` (paid online) or `cod` (cash on delivery). */
|
|
3
|
+
type OrderType = 'delivery' | 'cod';
|
|
4
|
+
/** How the business charges delivery: fixed thresholds, or a delivery partner's quote. */
|
|
5
|
+
type DeliveryChargeType = 'fixed' | 'as_per_delivery_partner';
|
|
6
|
+
/** `none` for stocked goods; others are made to order. Open string: the backend may add modes. */
|
|
7
|
+
type FulfillmentMode = 'none' | 'made_to_order_advance' | 'custom_fixed_price' | (string & {});
|
|
8
|
+
interface CartLine {
|
|
9
|
+
id: number;
|
|
10
|
+
/** null for lines without a SKU (made by the merchant). */
|
|
11
|
+
skuId: number | null;
|
|
12
|
+
productId: number | null;
|
|
13
|
+
/** Product name with its variants, e.g. "Iphone 15 (128 GB, Blue)". */
|
|
14
|
+
name: string;
|
|
15
|
+
photo: string | null;
|
|
16
|
+
/** The price when the line was added. */
|
|
17
|
+
unitPrice: number;
|
|
18
|
+
/** null when the SKU has no MRP (an MRP of 0 means "not set"), or without a SKU. */
|
|
19
|
+
mrp: number | null;
|
|
20
|
+
quantity: number;
|
|
21
|
+
lineTotal: number;
|
|
22
|
+
/** Product, category or brand offer amount on this line; 0 otherwise. */
|
|
23
|
+
offerDiscount: number;
|
|
24
|
+
taxPercent: number | null;
|
|
25
|
+
/** min(stock, per-customer limit); null without a SKU. */
|
|
26
|
+
maxQuantity: number | null;
|
|
27
|
+
isDigital: boolean;
|
|
28
|
+
fulfillmentMode: FulfillmentMode;
|
|
29
|
+
customData: Record<string, unknown> | null;
|
|
30
|
+
variantIds: number[];
|
|
31
|
+
}
|
|
32
|
+
interface AppliedOffer {
|
|
33
|
+
id: number;
|
|
34
|
+
name: string;
|
|
35
|
+
couponCode: string | null;
|
|
36
|
+
}
|
|
37
|
+
interface AppliedPromoCode {
|
|
38
|
+
id: number;
|
|
39
|
+
code: string;
|
|
40
|
+
type: 'percentage' | 'net';
|
|
41
|
+
value: number;
|
|
42
|
+
}
|
|
43
|
+
interface Cart {
|
|
44
|
+
id: number;
|
|
45
|
+
type: OrderType;
|
|
46
|
+
lines: CartLine[];
|
|
47
|
+
subtotal: number;
|
|
48
|
+
/** The order-level offer amount, or the sum of the line-level offer amounts. */
|
|
49
|
+
offerDiscount: number;
|
|
50
|
+
promoDiscount: number;
|
|
51
|
+
deliveryCharge: number;
|
|
52
|
+
payable: number;
|
|
53
|
+
deliveryChargeType: DeliveryChargeType | null;
|
|
54
|
+
offer: AppliedOffer | null;
|
|
55
|
+
promoCode: AppliedPromoCode | null;
|
|
56
|
+
shippingAddressId: number | null;
|
|
57
|
+
billingAddressId: number | null;
|
|
58
|
+
/** Made-to-order advance carts: the advance due now. */
|
|
59
|
+
advanceAmount: number | null;
|
|
60
|
+
}
|
|
61
|
+
/** The totals the backend sends back after the order type changes. */
|
|
62
|
+
interface CartTotals {
|
|
63
|
+
subtotal: number;
|
|
64
|
+
deliveryCharge: number;
|
|
65
|
+
payable: number;
|
|
66
|
+
}
|
|
67
|
+
/** Business tax details for the invoice (legal name and GSTIN). */
|
|
68
|
+
interface TaxDetails {
|
|
69
|
+
legalName: string;
|
|
70
|
+
taxNumber: string;
|
|
71
|
+
}
|
|
72
|
+
/** A delivery partner's quote for the cart. */
|
|
73
|
+
interface DeliveryEstimate {
|
|
74
|
+
deliveryCharge: number;
|
|
75
|
+
payable: number;
|
|
76
|
+
/** As the partner sends it (e.g. "Nov 05, 2026"), or null. */
|
|
77
|
+
estimatedDelivery: string | null;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Catalog domain types: categories, brands and the business's catalog settings.
|
|
82
|
+
* Built from wire responses in http/catalog.ts.
|
|
83
|
+
*/
|
|
84
|
+
interface Category {
|
|
85
|
+
id: number;
|
|
86
|
+
name: string;
|
|
87
|
+
description: string | null;
|
|
88
|
+
photo: string | null;
|
|
89
|
+
parentId: number | null;
|
|
90
|
+
/** Products in this category and all its sub-categories. */
|
|
91
|
+
productCount: number;
|
|
92
|
+
}
|
|
93
|
+
/** A category with its sub-categories, as returned by `catalog.categories()`. */
|
|
94
|
+
interface CategoryTree extends Category {
|
|
95
|
+
/** Newest first. */
|
|
96
|
+
children: CategoryTree[];
|
|
97
|
+
}
|
|
98
|
+
interface Brand {
|
|
99
|
+
id: number;
|
|
100
|
+
name: string;
|
|
101
|
+
description: string | null;
|
|
102
|
+
photo: string | null;
|
|
103
|
+
productCount: number;
|
|
104
|
+
}
|
|
105
|
+
/** Which catalog features the merchant has switched on. Use them to show or hide UI. */
|
|
106
|
+
interface CatalogSettings {
|
|
107
|
+
reviews: boolean;
|
|
108
|
+
brands: boolean;
|
|
109
|
+
categories: boolean;
|
|
110
|
+
subscriptions: boolean;
|
|
111
|
+
digitalDelivery: boolean;
|
|
112
|
+
variants: boolean;
|
|
113
|
+
specifications: boolean;
|
|
114
|
+
unitTracking: boolean;
|
|
115
|
+
manufactureAndExpiryDates: boolean;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Merchant-built product-page content. Built from wire responses in http/productPage.ts.
|
|
120
|
+
*
|
|
121
|
+
* Two kinds, both edited by the merchant from the storefront in theme-edit mode:
|
|
122
|
+
* - **Sections**: titled tabs under the product (e.g. "Description", "FAQs"), each with items.
|
|
123
|
+
* An item's `data` holds the components the storefront renders (description, FAQs, features,
|
|
124
|
+
* video slider…).
|
|
125
|
+
* - **Blocks**: one-off content keyed by a slug, e.g. `hero` (the detail layout) and
|
|
126
|
+
* `showcase` (vertical video cards).
|
|
127
|
+
*
|
|
128
|
+
* `data` is free-form JSON the backend stores as given (apart from the checks listed on
|
|
129
|
+
* `ProductBlock`), so it is `unknown`: check its shape before use.
|
|
130
|
+
*/
|
|
131
|
+
/**
|
|
132
|
+
* Which shoppers see a section item:
|
|
133
|
+
* - `'all'`: every variant.
|
|
134
|
+
* - `{ skuId, variantIds }`: only this SKU. `variantIds` are its variant options; null when the
|
|
135
|
+
* backend did not send them (create and update responses) or the SKU has none.
|
|
136
|
+
* - `{ variantId }`: every SKU with this variant option, e.g. all "Blue" phones.
|
|
137
|
+
*/
|
|
138
|
+
type ProductSectionItemTarget = 'all' | {
|
|
139
|
+
skuId: number;
|
|
140
|
+
variantIds: number[] | null;
|
|
141
|
+
} | {
|
|
142
|
+
variantId: number;
|
|
143
|
+
};
|
|
144
|
+
/** One item of a section: storefront components, possibly limited to a SKU or variant. */
|
|
145
|
+
interface ProductSectionItem {
|
|
146
|
+
id: number;
|
|
147
|
+
sectionId: number;
|
|
148
|
+
/** As saved by the merchant. The storefront saves a list of `{ slug, … }` components. */
|
|
149
|
+
data: unknown;
|
|
150
|
+
/** Position within the section, from 1. */
|
|
151
|
+
order: number;
|
|
152
|
+
target: ProductSectionItemTarget;
|
|
153
|
+
}
|
|
154
|
+
/** A titled section of the product page, with its items in display order. */
|
|
155
|
+
interface ProductSection {
|
|
156
|
+
id: number;
|
|
157
|
+
productId: number;
|
|
158
|
+
title: string;
|
|
159
|
+
items: ProductSectionItem[];
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* A slug-keyed content block of a product. The backend checks two slugs:
|
|
163
|
+
* - `hero`: at most one per product; `data` must be `{ layout: 'default' | 'fullscreen' }`.
|
|
164
|
+
* - `showcase`: at most one per product; `data` is `{ items: [{ source: 'youtube' | 'upload',
|
|
165
|
+
* url, … }] }` with a non-empty url (a valid YouTube link for `youtube`).
|
|
166
|
+
* Any other slug is stored without checks.
|
|
167
|
+
*/
|
|
168
|
+
interface ProductBlock {
|
|
169
|
+
id: number;
|
|
170
|
+
productId: number;
|
|
171
|
+
slug: string;
|
|
172
|
+
data: unknown;
|
|
173
|
+
/** Position among the product's blocks with the same slug, from 1. */
|
|
174
|
+
order: number;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Product domain types. Built from wire responses in http/products.ts.
|
|
179
|
+
* Prices are numbers (the backend sends decimal strings such as "58999.00"). Discounts are not
|
|
180
|
+
* stored here: compute them with `discountPercent()` from `@growupsell/commerce/rules`, so
|
|
181
|
+
* every app uses the same rule.
|
|
182
|
+
*/
|
|
183
|
+
|
|
184
|
+
/** One option of a variant group, e.g. "128 GB" in "Storage". */
|
|
185
|
+
interface VariantOption {
|
|
186
|
+
id: number;
|
|
187
|
+
label: string;
|
|
188
|
+
/** False when no SKU with this option can be bought. */
|
|
189
|
+
available: boolean;
|
|
190
|
+
}
|
|
191
|
+
/** A variant dimension of a product, e.g. Storage or Color. */
|
|
192
|
+
interface VariantGroup {
|
|
193
|
+
id: number;
|
|
194
|
+
name: string;
|
|
195
|
+
options: VariantOption[];
|
|
196
|
+
}
|
|
197
|
+
/** A sellable unit: one combination of variant options, or the product's base SKU. */
|
|
198
|
+
interface ProductSku {
|
|
199
|
+
id: number;
|
|
200
|
+
code: string;
|
|
201
|
+
slug: string;
|
|
202
|
+
price: number;
|
|
203
|
+
/** Maximum retail price; null when the merchant did not set one. */
|
|
204
|
+
mrp: number | null;
|
|
205
|
+
stockQty: number;
|
|
206
|
+
active: boolean;
|
|
207
|
+
/**
|
|
208
|
+
* The variant options this SKU is made of. Empty for the base SKU, which a product with
|
|
209
|
+
* variants also has: never offer that one when variants exist.
|
|
210
|
+
*/
|
|
211
|
+
variantIds: number[];
|
|
212
|
+
}
|
|
213
|
+
/** A row of the product listing: one SKU, with its product's variant groups. */
|
|
214
|
+
interface ProductListItem {
|
|
215
|
+
skuId: number;
|
|
216
|
+
productId: number;
|
|
217
|
+
/** Product name with the SKU's variants, e.g. "Iphone 15 (128 GB, Blue)". */
|
|
218
|
+
name: string;
|
|
219
|
+
slug: string;
|
|
220
|
+
skuCode: string;
|
|
221
|
+
photos: string[];
|
|
222
|
+
price: number;
|
|
223
|
+
mrp: number | null;
|
|
224
|
+
stockQty: number;
|
|
225
|
+
taxPercent: number | null;
|
|
226
|
+
unit: string | null;
|
|
227
|
+
variantGroups: VariantGroup[];
|
|
228
|
+
selectedVariantIds: number[];
|
|
229
|
+
/** The product's description (HTML), for list views; null when empty. */
|
|
230
|
+
description: string | null;
|
|
231
|
+
/** `none` for stocked goods; custom modes are made to order. */
|
|
232
|
+
fulfillmentMode: FulfillmentMode;
|
|
233
|
+
hasDigitalDelivery: boolean;
|
|
234
|
+
/** Advance payment required for made-to-order products. */
|
|
235
|
+
advanceAmount: number | null;
|
|
236
|
+
}
|
|
237
|
+
interface ProductImage {
|
|
238
|
+
id: number;
|
|
239
|
+
url: string;
|
|
240
|
+
/** Full-resolution original, when kept. */
|
|
241
|
+
originalUrl: string | null;
|
|
242
|
+
/** The variant option this image shows (e.g. the Blue photos), or null for all. */
|
|
243
|
+
variantId: number | null;
|
|
244
|
+
/** The exact SKU this image shows, or null. Use `imagesFor()` to pick a selection's images. */
|
|
245
|
+
skuId: number | null;
|
|
246
|
+
/**
|
|
247
|
+
* A video link (e.g. YouTube) to play instead of the photo, or null. Play it through an
|
|
248
|
+
* embed URL, never as a raw iframe source (YouTube refuses `watch` URLs in frames).
|
|
249
|
+
*/
|
|
250
|
+
videoUrl: string | null;
|
|
251
|
+
order: number;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Who a specification row applies to. The backend stores rows for every variant, for one
|
|
255
|
+
* variant option (e.g. "Color = Blue") or for one exact SKU (e.g. a model number). Use
|
|
256
|
+
* `specificationsFor()` from `@growupsell/commerce/rules` to show the right ones.
|
|
257
|
+
*/
|
|
258
|
+
type SpecificationScope = {
|
|
259
|
+
type: 'all';
|
|
260
|
+
} | {
|
|
261
|
+
type: 'variant';
|
|
262
|
+
variantId: number;
|
|
263
|
+
} | {
|
|
264
|
+
type: 'sku';
|
|
265
|
+
skuId: number;
|
|
266
|
+
};
|
|
267
|
+
interface ProductSpecificationGroup {
|
|
268
|
+
/** e.g. "General", "Display Feature"; null for ungrouped specifications. */
|
|
269
|
+
name: string | null;
|
|
270
|
+
items: Array<{
|
|
271
|
+
key: string;
|
|
272
|
+
value: string;
|
|
273
|
+
appliesTo: SpecificationScope;
|
|
274
|
+
}>;
|
|
275
|
+
}
|
|
276
|
+
interface ProductPolicies {
|
|
277
|
+
returnDays: number;
|
|
278
|
+
replacementDays: number;
|
|
279
|
+
exchangeDays: number;
|
|
280
|
+
exchangeEnabled: boolean;
|
|
281
|
+
warrantyMonths: number;
|
|
282
|
+
guaranteeMonths: number;
|
|
283
|
+
}
|
|
284
|
+
/** A product with everything the product page needs. */
|
|
285
|
+
interface ProductDetail {
|
|
286
|
+
id: number;
|
|
287
|
+
name: string;
|
|
288
|
+
slug: string;
|
|
289
|
+
description: string | null;
|
|
290
|
+
/** Editor the description was written with, e.g. `ReactQuill`: tells apps how to render it. */
|
|
291
|
+
descriptionFormat: string | null;
|
|
292
|
+
categoryId: number | null;
|
|
293
|
+
categoryName: string | null;
|
|
294
|
+
brandId: number | null;
|
|
295
|
+
taxPercent: number | null;
|
|
296
|
+
rating: number;
|
|
297
|
+
reviewCount: number;
|
|
298
|
+
hasVariants: boolean;
|
|
299
|
+
images: ProductImage[];
|
|
300
|
+
variantGroups: VariantGroup[];
|
|
301
|
+
skus: ProductSku[];
|
|
302
|
+
specifications: ProductSpecificationGroup[];
|
|
303
|
+
policies: ProductPolicies | null;
|
|
304
|
+
availableForSubscription: boolean;
|
|
305
|
+
hasDigitalDelivery: boolean;
|
|
306
|
+
fulfillmentMode: FulfillmentMode;
|
|
307
|
+
advanceAmount: number | null;
|
|
308
|
+
}
|
|
309
|
+
/** A product as listed by `products.list()` (home sliders, product pickers). */
|
|
310
|
+
interface ProductOverview {
|
|
311
|
+
id: number;
|
|
312
|
+
name: string;
|
|
313
|
+
slug: string;
|
|
314
|
+
/** HTML, written with the editor the product detail's `descriptionFormat` names; null when empty. */
|
|
315
|
+
description: string | null;
|
|
316
|
+
/**
|
|
317
|
+
* `none` for stocked goods; custom modes are made to order and never out of stock (pass it to
|
|
318
|
+
* `purchaseLimit()` with a SKU's `stockQty` for the stock badge).
|
|
319
|
+
*/
|
|
320
|
+
fulfillmentMode: FulfillmentMode;
|
|
321
|
+
categoryName: string | null;
|
|
322
|
+
images: ProductImage[];
|
|
323
|
+
variantGroups: VariantGroup[];
|
|
324
|
+
skus: ProductSku[];
|
|
325
|
+
/** Lowest SKU price. */
|
|
326
|
+
priceFrom: number | null;
|
|
327
|
+
unit: string | null;
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Order of `products.list()`. The backend orders this list by id only (no creation date), so
|
|
331
|
+
* `newest` is the highest id first. Without `sort` the backend's default applies: `oldest`.
|
|
332
|
+
*/
|
|
333
|
+
type ProductListSort = 'newest' | 'oldest' | 'name-a-z' | 'name-z-a';
|
|
334
|
+
interface ProductListOptions {
|
|
335
|
+
ids?: readonly number[];
|
|
336
|
+
/** Includes sub-categories. */
|
|
337
|
+
categoryIds?: readonly number[];
|
|
338
|
+
sort?: ProductListSort;
|
|
339
|
+
/** Default 20. */
|
|
340
|
+
limit?: number;
|
|
341
|
+
offset?: number;
|
|
342
|
+
}
|
|
343
|
+
interface ProductFilterConfig {
|
|
344
|
+
/** Price range across the business's products. */
|
|
345
|
+
price: {
|
|
346
|
+
min: number;
|
|
347
|
+
max: number;
|
|
348
|
+
};
|
|
349
|
+
/** Specification filters; pass selections back as `specifications` to `products.search()`. */
|
|
350
|
+
specifications: Array<{
|
|
351
|
+
id: number;
|
|
352
|
+
name: string;
|
|
353
|
+
type: string;
|
|
354
|
+
options: string[];
|
|
355
|
+
}>;
|
|
356
|
+
}
|
|
357
|
+
/** A quick-search suggestion: a product or a category. */
|
|
358
|
+
type SearchSuggestion = {
|
|
359
|
+
type: 'product';
|
|
360
|
+
id: number;
|
|
361
|
+
name: string;
|
|
362
|
+
categoryName: string | null;
|
|
363
|
+
image: string | null;
|
|
364
|
+
} | {
|
|
365
|
+
type: 'category';
|
|
366
|
+
id: number;
|
|
367
|
+
name: string;
|
|
368
|
+
};
|
|
369
|
+
/** One page of a list. */
|
|
370
|
+
interface Page<T> {
|
|
371
|
+
items: T[];
|
|
372
|
+
/** Total across all pages. */
|
|
373
|
+
total: number;
|
|
374
|
+
offset: number;
|
|
375
|
+
limit: number;
|
|
376
|
+
}
|
|
377
|
+
/** Listing order. `newest` is the default. */
|
|
378
|
+
type ProductSort = 'price-low-to-high' | 'price-high-to-low' | 'newest' | 'popularity' | 'category';
|
|
379
|
+
interface ProductSearchOptions {
|
|
380
|
+
/** Free-text search over name and related fields. */
|
|
381
|
+
search?: string;
|
|
382
|
+
/** Includes sub-categories. */
|
|
383
|
+
categoryIds?: readonly number[];
|
|
384
|
+
brandIds?: readonly number[];
|
|
385
|
+
/** Variant option labels, e.g. ["Blue", "128 GB"]. */
|
|
386
|
+
variantLabels?: readonly string[];
|
|
387
|
+
/** Specification filters from `filterConfig()`: AND across ids, OR within one id's values. */
|
|
388
|
+
specifications?: ReadonlyArray<{
|
|
389
|
+
id: number;
|
|
390
|
+
values: readonly string[];
|
|
391
|
+
}>;
|
|
392
|
+
minPrice?: number;
|
|
393
|
+
maxPrice?: number;
|
|
394
|
+
minDiscountPercent?: number;
|
|
395
|
+
minRating?: number;
|
|
396
|
+
sortBy?: ProductSort;
|
|
397
|
+
/** Default 20. */
|
|
398
|
+
limit?: number;
|
|
399
|
+
offset?: number;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
/** Offers, promo codes, gift cards and reward points. */
|
|
403
|
+
/** What an offer applies to: the whole order, or matching products, categories or brands. */
|
|
404
|
+
type OfferScope = 'order' | 'product' | 'category' | 'brand';
|
|
405
|
+
interface Offer {
|
|
406
|
+
id: number;
|
|
407
|
+
name: string;
|
|
408
|
+
description: string | null;
|
|
409
|
+
image: string | null;
|
|
410
|
+
type: 'percentage' | 'net';
|
|
411
|
+
/** Percent off, for `percentage` offers. */
|
|
412
|
+
percentOff: number;
|
|
413
|
+
/** The fixed amount off, for `net` offers. */
|
|
414
|
+
amountOff: number;
|
|
415
|
+
minOrderAmount: number;
|
|
416
|
+
startsAt: string;
|
|
417
|
+
endsAt: string;
|
|
418
|
+
couponCode: string | null;
|
|
419
|
+
scope: OfferScope;
|
|
420
|
+
isActive: boolean;
|
|
421
|
+
}
|
|
422
|
+
interface PromoCode {
|
|
423
|
+
id: number;
|
|
424
|
+
code: string;
|
|
425
|
+
description: string | null;
|
|
426
|
+
type: 'percentage' | 'net';
|
|
427
|
+
value: number;
|
|
428
|
+
expiresAt: string;
|
|
429
|
+
status: 'active' | 'expired' | 'redeemed';
|
|
430
|
+
}
|
|
431
|
+
/** The PIN is never kept: the backend returns it unmasked, the library drops it. */
|
|
432
|
+
interface GiftCard {
|
|
433
|
+
id: number;
|
|
434
|
+
code: string;
|
|
435
|
+
amount: number;
|
|
436
|
+
usedAmount: number;
|
|
437
|
+
issuedAt: string;
|
|
438
|
+
}
|
|
439
|
+
interface RewardPointSettings {
|
|
440
|
+
/** Reward points are switched on, for orders too. */
|
|
441
|
+
enabled: boolean;
|
|
442
|
+
/** Points earned per currency unit paid. */
|
|
443
|
+
pointsPerCurrencyUnit: number;
|
|
444
|
+
/** The value of one point when spent. */
|
|
445
|
+
currencyPerPoint: number;
|
|
446
|
+
/** Points given on sign-up. */
|
|
447
|
+
signupPoints: number;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* Product review domain types. Built from wire responses in http/reviews.ts.
|
|
452
|
+
* Ratings are numbers from 1 to 5 in steps of 0.5 (the backend stores one decimal and sends it
|
|
453
|
+
* as a string such as "4.5").
|
|
454
|
+
*/
|
|
455
|
+
/** A review as the backend stores it: what `create()` and `update()` return. */
|
|
456
|
+
interface Review {
|
|
457
|
+
id: number;
|
|
458
|
+
productId: number;
|
|
459
|
+
/** The customer who wrote it: compare with the logged-in customer to offer edit and delete. */
|
|
460
|
+
customerId: number;
|
|
461
|
+
title: string;
|
|
462
|
+
message: string | null;
|
|
463
|
+
/** URL of the photo attached to the review. */
|
|
464
|
+
photo: string | null;
|
|
465
|
+
/** Null for old reviews saved without a rating. */
|
|
466
|
+
rating: number | null;
|
|
467
|
+
/** ISO 8601 timestamp. */
|
|
468
|
+
createdAt: string;
|
|
469
|
+
}
|
|
470
|
+
/** The business's reply to a review. */
|
|
471
|
+
interface ReviewReply {
|
|
472
|
+
id: number;
|
|
473
|
+
message: string;
|
|
474
|
+
/** Name of the staff member who replied. */
|
|
475
|
+
authorName: string | null;
|
|
476
|
+
authorPhoto: string | null;
|
|
477
|
+
}
|
|
478
|
+
/** A published review, as listed on product pages and the home page. */
|
|
479
|
+
interface ReviewListItem extends Review {
|
|
480
|
+
productName: string;
|
|
481
|
+
/** Full name, or the company name for business customers. */
|
|
482
|
+
customerName: string | null;
|
|
483
|
+
customerPhoto: string | null;
|
|
484
|
+
reply: ReviewReply | null;
|
|
485
|
+
}
|
|
486
|
+
/** Rating summary of one product. */
|
|
487
|
+
interface ReviewSummary {
|
|
488
|
+
reviewCount: number;
|
|
489
|
+
/** Average of all ratings, rounded to one decimal; 0 without reviews. */
|
|
490
|
+
averageRating: number;
|
|
491
|
+
/**
|
|
492
|
+
* Number of reviews per whole star. Half-star ratings (e.g. 4.5) are counted in no bucket by
|
|
493
|
+
* the backend, so these may add up to less than `reviewCount`.
|
|
494
|
+
*/
|
|
495
|
+
starCounts: {
|
|
496
|
+
1: number;
|
|
497
|
+
2: number;
|
|
498
|
+
3: number;
|
|
499
|
+
4: number;
|
|
500
|
+
5: number;
|
|
501
|
+
};
|
|
502
|
+
}
|
|
503
|
+
/** Whether the logged-in customer may review a product. */
|
|
504
|
+
type ReviewEligibility = {
|
|
505
|
+
canReview: true;
|
|
506
|
+
/** The ordered item the review is for: pass it to `reviews.create()`. */
|
|
507
|
+
orderProductId: number;
|
|
508
|
+
} | {
|
|
509
|
+
canReview: false;
|
|
510
|
+
orderProductId: null;
|
|
511
|
+
};
|
|
512
|
+
|
|
513
|
+
/** Customer domain types. Built from wire responses in http/auth.ts and http/customer.ts. */
|
|
514
|
+
/** The logged-in customer's own profile. */
|
|
515
|
+
interface CustomerProfile {
|
|
516
|
+
id: number;
|
|
517
|
+
type: 'individual' | 'business';
|
|
518
|
+
firstName: string | null;
|
|
519
|
+
lastName: string | null;
|
|
520
|
+
email: string | null;
|
|
521
|
+
/** E.164, e.g. "+919876543210". */
|
|
522
|
+
phone: string | null;
|
|
523
|
+
businessName: string | null;
|
|
524
|
+
taxNumber: string | null;
|
|
525
|
+
/** Profile photo URL. */
|
|
526
|
+
photo: string | null;
|
|
527
|
+
isActive: boolean;
|
|
528
|
+
emailVerified: boolean;
|
|
529
|
+
phoneVerified: boolean;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
/** The business's order settings: what checkout may offer. */
|
|
533
|
+
interface CheckoutSettings {
|
|
534
|
+
allowCashOnDelivery: boolean;
|
|
535
|
+
/** Customers may cancel their own orders. */
|
|
536
|
+
allowCancellation: boolean;
|
|
537
|
+
/** New orders are accepted without the merchant confirming them. */
|
|
538
|
+
autoAccept: boolean;
|
|
539
|
+
onlineOrdersEnabled: boolean;
|
|
540
|
+
deliveryChargeEnabled: boolean;
|
|
541
|
+
/** Most units of one SKU an individual customer may order. */
|
|
542
|
+
maxQuantityIndividual: number;
|
|
543
|
+
/** Most units of one SKU a business customer may order. */
|
|
544
|
+
maxQuantityBusiness: number;
|
|
545
|
+
}
|
|
546
|
+
/** How a payment is made. Open string: the backend may add methods. */
|
|
547
|
+
type PaymentMethodType = 'razorpay' | 'stripe' | 'phonepe' | 'direct-transfer' | 'cashfree' | 'paytm' | 'upi' | 'cash' | 'swipe-machine' | (string & {});
|
|
548
|
+
/**
|
|
549
|
+
* What is still to pay after placing an order. `method` says which payment SDK the app runs;
|
|
550
|
+
* then it confirms through `client.payments`.
|
|
551
|
+
*/
|
|
552
|
+
interface PendingPayment {
|
|
553
|
+
/** Pass this to `client.payments.*`. */
|
|
554
|
+
id: number;
|
|
555
|
+
amount: number;
|
|
556
|
+
method: PaymentMethodType | null;
|
|
557
|
+
/** The provider's public key: Razorpay key id, Stripe publishable key. */
|
|
558
|
+
publicKey: string | null;
|
|
559
|
+
/** The provider's order: Razorpay order id, Stripe PaymentIntent id. */
|
|
560
|
+
providerOrderId: string | null;
|
|
561
|
+
/** Stripe only: the PaymentIntent's client secret for Stripe Elements. */
|
|
562
|
+
clientSecret: string | null;
|
|
563
|
+
/** PhonePe only: the page to send the shopper to. */
|
|
564
|
+
redirectUrl: string | null;
|
|
565
|
+
}
|
|
566
|
+
/**
|
|
567
|
+
* The result of placing an order. `placed` also covers cash on delivery and orders fully paid
|
|
568
|
+
* by gift cards or reward points.
|
|
569
|
+
*/
|
|
570
|
+
type PlaceOrderResult = {
|
|
571
|
+
status: 'placed';
|
|
572
|
+
orderId: number;
|
|
573
|
+
} | {
|
|
574
|
+
status: 'payment-required';
|
|
575
|
+
orderId: number;
|
|
576
|
+
payment: PendingPayment;
|
|
577
|
+
};
|
|
578
|
+
/** A made-to-order product's new order and the advance to pay now. */
|
|
579
|
+
interface AdvanceOrder {
|
|
580
|
+
orderId: number;
|
|
581
|
+
payment: PendingPayment;
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
export type { AdvanceOrder as A, Brand as B, Cart as C, DeliveryChargeType as D, ProductSectionItem as E, FulfillmentMode as F, GiftCard as G, ProductSectionItemTarget as H, ProductSku as I, ProductSort as J, ProductSpecificationGroup as K, PromoCode as L, ReviewEligibility as M, ReviewListItem as N, Offer as O, Page as P, ReviewReply as Q, Review as R, ReviewSummary as S, RewardPointSettings as T, SearchSuggestion as U, SpecificationScope as V, TaxDetails as W, VariantGroup as X, VariantOption as Y, AppliedOffer as a, AppliedPromoCode as b, CartLine as c, CartTotals as d, CatalogSettings as e, Category as f, CategoryTree as g, CheckoutSettings as h, CustomerProfile as i, DeliveryEstimate as j, OfferScope as k, OrderType as l, PaymentMethodType as m, PendingPayment as n, PlaceOrderResult as o, ProductBlock as p, ProductDetail as q, ProductFilterConfig as r, ProductImage as s, ProductListItem as t, ProductListOptions as u, ProductListSort as v, ProductOverview as w, ProductPolicies as x, ProductSearchOptions as y, ProductSection as z };
|