brainerce 1.22.0 → 1.23.12
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 +4662 -4525
- package/dist/index.d.mts +1005 -51
- package/dist/index.d.ts +1005 -51
- package/dist/index.js +562 -30
- package/dist/index.mjs +560 -30
- package/package.json +76 -76
package/dist/index.d.mts
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
interface BrainerceClientOptions {
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
* This is the simplest way to connect - just use your Connection ID!
|
|
3
|
+
* Sales Channel ID (starts with "vc_") — the simplest way to connect.
|
|
5
4
|
* Safe to use in frontend applications.
|
|
6
5
|
*
|
|
7
6
|
* @example
|
|
8
7
|
* ```typescript
|
|
9
|
-
* // Vibe-coded site usage - simplest option!
|
|
10
8
|
* const client = new BrainerceClient({
|
|
11
|
-
*
|
|
9
|
+
* salesChannelId: 'vc_abc123xyz...',
|
|
12
10
|
* });
|
|
13
11
|
* const products = await client.getProducts();
|
|
14
12
|
* ```
|
|
15
13
|
*/
|
|
14
|
+
salesChannelId?: string;
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated Use `salesChannelId` instead. `connectionId` is kept as a
|
|
17
|
+
* backwards-compatible alias and will be removed in SDK 2.0.
|
|
18
|
+
*/
|
|
16
19
|
connectionId?: string;
|
|
17
20
|
/**
|
|
18
21
|
* Store ID for public storefront access (no API key needed).
|
|
@@ -115,17 +118,21 @@ interface StoreInfo {
|
|
|
115
118
|
name: string;
|
|
116
119
|
currency: string;
|
|
117
120
|
language: string;
|
|
118
|
-
/**
|
|
121
|
+
/** Sales Channel ID (sales-channel mode only) */
|
|
122
|
+
salesChannelId?: string;
|
|
123
|
+
/** @deprecated alias of `salesChannelId` — will be removed in SDK 2.0 */
|
|
119
124
|
connectionId?: string;
|
|
120
|
-
/** Store name (
|
|
125
|
+
/** Store name (sales-channel mode only - same as name) */
|
|
121
126
|
storeName?: string;
|
|
122
|
-
/**
|
|
127
|
+
/** Sales channel status (sales-channel mode only) */
|
|
128
|
+
salesChannelStatus?: string;
|
|
129
|
+
/** @deprecated alias of `salesChannelStatus` — will be removed in SDK 2.0 */
|
|
123
130
|
status?: string;
|
|
124
|
-
/** Allowed API scopes (
|
|
131
|
+
/** Allowed API scopes (sales-channel mode only) */
|
|
125
132
|
allowedScopes?: string[];
|
|
126
|
-
/** Whether orders can be created (
|
|
133
|
+
/** Whether orders can be created (sales-channel mode only) */
|
|
127
134
|
ordersWriteEnabled?: boolean;
|
|
128
|
-
/** Whether guest checkout is tracked (
|
|
135
|
+
/** Whether guest checkout is tracked (sales-channel mode only) */
|
|
129
136
|
guestCheckoutTracking?: boolean;
|
|
130
137
|
/**
|
|
131
138
|
* Whether new customer registrations require email verification.
|
|
@@ -272,18 +279,44 @@ interface Product {
|
|
|
272
279
|
translations?: Record<string, Record<string, string>> | null;
|
|
273
280
|
} | null;
|
|
274
281
|
}>;
|
|
275
|
-
/**
|
|
282
|
+
/** Sales channels this product is published to (admin mode only) */
|
|
283
|
+
channelPublishes?: Array<{
|
|
284
|
+
salesChannel: {
|
|
285
|
+
id: string;
|
|
286
|
+
name: string;
|
|
287
|
+
connectionId: string;
|
|
288
|
+
};
|
|
289
|
+
/** @deprecated alias of `salesChannel` — will be removed in SDK 2.0 */
|
|
290
|
+
connection?: {
|
|
291
|
+
id: string;
|
|
292
|
+
name: string;
|
|
293
|
+
connectionId: string;
|
|
294
|
+
};
|
|
295
|
+
}>;
|
|
296
|
+
/** @deprecated alias of `channelPublishes` — will be removed in SDK 2.0 */
|
|
276
297
|
vibeCodedPublishes?: Array<{
|
|
277
|
-
|
|
298
|
+
salesChannel: {
|
|
299
|
+
id: string;
|
|
300
|
+
name: string;
|
|
301
|
+
connectionId: string;
|
|
302
|
+
};
|
|
303
|
+
connection?: {
|
|
278
304
|
id: string;
|
|
279
305
|
name: string;
|
|
280
306
|
connectionId: string;
|
|
281
307
|
};
|
|
282
308
|
}>;
|
|
283
|
-
/** Discount info from matching discount rules (storefront/
|
|
309
|
+
/** Discount info from matching discount rules (storefront/sales-channel mode only) */
|
|
284
310
|
discount?: ProductDiscount | null;
|
|
285
311
|
/** Recommendations (upsells, cross-sells, related) — included in storefront/VC getProductBySlug response */
|
|
286
312
|
recommendations?: ProductRecommendationsResponse;
|
|
313
|
+
/**
|
|
314
|
+
* Modifier groups attached to this product (toppings, sauce, bread type, …).
|
|
315
|
+
* Effective values (`min`, `max`, `freeQuantity`, etc.) already reflect any
|
|
316
|
+
* per-attachment overrides. Only present on single-product fetches
|
|
317
|
+
* (`getProductBySlug`, `getProductById`); omitted from list responses.
|
|
318
|
+
*/
|
|
319
|
+
modifierGroups?: ModifierGroup[];
|
|
287
320
|
createdAt: string;
|
|
288
321
|
updatedAt: string;
|
|
289
322
|
}
|
|
@@ -730,6 +763,21 @@ interface ProductQueryParams {
|
|
|
730
763
|
minPrice?: number;
|
|
731
764
|
/** Maximum price filter */
|
|
732
765
|
maxPrice?: number;
|
|
766
|
+
/**
|
|
767
|
+
* Filter by custom-field (metafield) values. Keys are metafield definition
|
|
768
|
+
* keys (e.g. "color", "in_stock"); each value is one or more accepted values.
|
|
769
|
+
* Only definitions with `filterable: true` and a supported type
|
|
770
|
+
* (SELECT / MULTI_SELECT / BOOLEAN) are honored — others are ignored
|
|
771
|
+
* server-side.
|
|
772
|
+
*
|
|
773
|
+
* @example
|
|
774
|
+
* ```typescript
|
|
775
|
+
* client.getProducts({
|
|
776
|
+
* metafields: { color: ['red', 'blue'], in_stock: ['true'] },
|
|
777
|
+
* });
|
|
778
|
+
* ```
|
|
779
|
+
*/
|
|
780
|
+
metafields?: Record<string, string | string[]>;
|
|
733
781
|
/** Sort by field (default: menuOrder) */
|
|
734
782
|
sortBy?: 'name' | 'price' | 'createdAt';
|
|
735
783
|
sortOrder?: 'asc' | 'desc';
|
|
@@ -1093,6 +1141,33 @@ interface Coupon {
|
|
|
1093
1141
|
lastSyncedAt?: string | null;
|
|
1094
1142
|
/** Per-platform channel overrides */
|
|
1095
1143
|
channels?: Record<string, Record<string, unknown>> | null;
|
|
1144
|
+
/** Sales channels this coupon is explicitly published to (admin response only). */
|
|
1145
|
+
channelPublishes?: Array<{
|
|
1146
|
+
salesChannel: {
|
|
1147
|
+
id: string;
|
|
1148
|
+
name: string;
|
|
1149
|
+
connectionId: string;
|
|
1150
|
+
};
|
|
1151
|
+
/** @deprecated alias of `salesChannel` — will be removed in SDK 2.0 */
|
|
1152
|
+
connection?: {
|
|
1153
|
+
id: string;
|
|
1154
|
+
name: string;
|
|
1155
|
+
connectionId: string;
|
|
1156
|
+
};
|
|
1157
|
+
}>;
|
|
1158
|
+
/** @deprecated alias of `channelPublishes` — will be removed in SDK 2.0 */
|
|
1159
|
+
vibeCodedPublishes?: Array<{
|
|
1160
|
+
salesChannel: {
|
|
1161
|
+
id: string;
|
|
1162
|
+
name: string;
|
|
1163
|
+
connectionId: string;
|
|
1164
|
+
};
|
|
1165
|
+
connection?: {
|
|
1166
|
+
id: string;
|
|
1167
|
+
name: string;
|
|
1168
|
+
connectionId: string;
|
|
1169
|
+
};
|
|
1170
|
+
}>;
|
|
1096
1171
|
createdAt: string;
|
|
1097
1172
|
updatedAt: string;
|
|
1098
1173
|
}
|
|
@@ -1216,6 +1291,34 @@ interface Customer {
|
|
|
1216
1291
|
createdAt: string;
|
|
1217
1292
|
updatedAt: string;
|
|
1218
1293
|
}
|
|
1294
|
+
/**
|
|
1295
|
+
* Display-only summary of a vaulted payment method.
|
|
1296
|
+
*
|
|
1297
|
+
* The underlying provider token is encrypted at rest in the platform
|
|
1298
|
+
* DB and NEVER exposed through any public API. Use the fields below
|
|
1299
|
+
* for UI ("Visa ending in 4242, exp 03/26").
|
|
1300
|
+
*/
|
|
1301
|
+
interface SavedPaymentMethodSummary {
|
|
1302
|
+
id: string;
|
|
1303
|
+
customerId: string;
|
|
1304
|
+
appInstallationId: string;
|
|
1305
|
+
/** 'credit_card' | 'paypal' | 'bank_account'. Provider-controlled. */
|
|
1306
|
+
paymentMethod: string;
|
|
1307
|
+
/** Card brand (Visa, Mastercard, etc.). May be null for non-card methods. */
|
|
1308
|
+
brand: string | null;
|
|
1309
|
+
/** Last 4 digits. May be null for non-card methods. */
|
|
1310
|
+
last4: string | null;
|
|
1311
|
+
expMonth: number | null;
|
|
1312
|
+
expYear: number | null;
|
|
1313
|
+
isDefault: boolean;
|
|
1314
|
+
/** 'active' | 'expired' | 'invalid'. */
|
|
1315
|
+
status: string;
|
|
1316
|
+
failureReason: string | null;
|
|
1317
|
+
lastUsedAt: string | null;
|
|
1318
|
+
expiresAt: string | null;
|
|
1319
|
+
createdAt: string;
|
|
1320
|
+
updatedAt: string;
|
|
1321
|
+
}
|
|
1219
1322
|
interface CustomerAddress {
|
|
1220
1323
|
id: string;
|
|
1221
1324
|
label?: string;
|
|
@@ -1414,6 +1517,10 @@ type CartStatus = 'ACTIVE' | 'MERGED' | 'CONVERTED' | 'ABANDONED';
|
|
|
1414
1517
|
* @see Cart
|
|
1415
1518
|
* @see LocalCartItem for client-side cart items
|
|
1416
1519
|
*/
|
|
1520
|
+
/**
|
|
1521
|
+
* Why a cart item is currently not purchasable. `null` means available.
|
|
1522
|
+
*/
|
|
1523
|
+
type CartItemUnavailableReason = 'PRODUCT_DRAFT' | 'PRODUCT_ARCHIVED' | 'VARIANT_DRAFT' | 'VARIANT_DELETED' | 'INVENTORY_DISABLED' | 'OUT_OF_STOCK';
|
|
1417
1524
|
interface CartItem {
|
|
1418
1525
|
/** Unique identifier for this cart line item */
|
|
1419
1526
|
id: string;
|
|
@@ -1424,10 +1531,26 @@ interface CartItem {
|
|
|
1424
1531
|
/** Quantity of this item in the cart */
|
|
1425
1532
|
quantity: number;
|
|
1426
1533
|
/**
|
|
1427
|
-
*
|
|
1428
|
-
* Use parseFloat() for
|
|
1534
|
+
* Snapshot price captured at add-to-cart time as a string (e.g., "29.99").
|
|
1535
|
+
* Stable until the customer accepts a price refresh. Use parseFloat() for
|
|
1536
|
+
* calculations.
|
|
1429
1537
|
*/
|
|
1430
1538
|
unitPrice: string;
|
|
1539
|
+
/**
|
|
1540
|
+
* Live unit price resolved from the current product/variant. Differs from
|
|
1541
|
+
* `unitPrice` if the merchant changed the price after the item was added.
|
|
1542
|
+
* Display this if you want the customer to see the latest price.
|
|
1543
|
+
*/
|
|
1544
|
+
currentUnitPrice: string;
|
|
1545
|
+
/** True iff `currentUnitPrice !== unitPrice`. */
|
|
1546
|
+
priceChanged: boolean;
|
|
1547
|
+
/** `currentUnitPrice - unitPrice` as a Decimal string (negative = cheaper now). */
|
|
1548
|
+
priceDelta: string;
|
|
1549
|
+
priceDirection: 'increased' | 'decreased' | 'unchanged';
|
|
1550
|
+
/** False if the item cannot be purchased right now. Block checkout / show banner. */
|
|
1551
|
+
isAvailable: boolean;
|
|
1552
|
+
/** Why the item is unavailable. `null` when `isAvailable === true`. */
|
|
1553
|
+
unavailableReason: CartItemUnavailableReason | null;
|
|
1431
1554
|
/**
|
|
1432
1555
|
* Discount amount applied to this item as a string (from discount rules).
|
|
1433
1556
|
* Use parseFloat() for calculations.
|
|
@@ -1446,6 +1569,27 @@ interface CartItem {
|
|
|
1446
1569
|
notes?: string | null;
|
|
1447
1570
|
/** Optional metadata for this line item */
|
|
1448
1571
|
metadata?: Record<string, unknown> | null;
|
|
1572
|
+
/**
|
|
1573
|
+
* Per-line modifier breakdown — present when the line was added with
|
|
1574
|
+
* modifier `selections`. Snapshot taken at add-time; immutable to catalog
|
|
1575
|
+
* edits afterward (PRD §5.6.4).
|
|
1576
|
+
*/
|
|
1577
|
+
modifiers?: CartItemModifierLine[];
|
|
1578
|
+
/**
|
|
1579
|
+
* Decimal-string total of the modifier deltas applied to this line
|
|
1580
|
+
* (after free-allocation). Present when `modifiers` is non-empty.
|
|
1581
|
+
*/
|
|
1582
|
+
modifiersTotal?: string;
|
|
1583
|
+
/**
|
|
1584
|
+
* PRD §15 Q5 — when this cart line is a child of a nested-combo parent
|
|
1585
|
+
* (e.g. the burger inside a "Build Your Combo"), `parentCartItemId`
|
|
1586
|
+
* points at the parent CartItem.id. Absent / null for top-level lines.
|
|
1587
|
+
*
|
|
1588
|
+
* Storefronts can group children visually under their parent in the
|
|
1589
|
+
* cart drawer; the cart subtotal already includes every line in the
|
|
1590
|
+
* tree, so children should NOT be summed twice.
|
|
1591
|
+
*/
|
|
1592
|
+
parentCartItemId?: string | null;
|
|
1449
1593
|
/**
|
|
1450
1594
|
* Nested product information.
|
|
1451
1595
|
* Access product details via this object (e.g., item.product.name).
|
|
@@ -1539,6 +1683,15 @@ interface Cart {
|
|
|
1539
1683
|
items: CartItem[];
|
|
1540
1684
|
/** Total number of items (sum of quantities) */
|
|
1541
1685
|
itemCount: number;
|
|
1686
|
+
/**
|
|
1687
|
+
* True if any item has `priceChanged === true`. Use as a single signal to
|
|
1688
|
+
* show a "prices have changed" banner without iterating items.
|
|
1689
|
+
*/
|
|
1690
|
+
hasPriceChanges: boolean;
|
|
1691
|
+
/** True if any item has `isAvailable === false`. */
|
|
1692
|
+
hasUnavailableItems: boolean;
|
|
1693
|
+
/** Convenience list of unavailable `CartItem.id`s. */
|
|
1694
|
+
unavailableItemIds: string[];
|
|
1542
1695
|
/** ISO timestamp when cart expires */
|
|
1543
1696
|
expiresAt?: string | null;
|
|
1544
1697
|
/** ISO timestamp when cart was created */
|
|
@@ -1558,6 +1711,19 @@ interface AddToCartDto {
|
|
|
1558
1711
|
quantity: number;
|
|
1559
1712
|
notes?: string;
|
|
1560
1713
|
metadata?: Record<string, unknown>;
|
|
1714
|
+
/**
|
|
1715
|
+
* Modifier-group selections for restaurant / customizable products
|
|
1716
|
+
* (e.g., toppings, sauces, sides). The server validates against effective
|
|
1717
|
+
* group rules and rejects invalid payloads with a `MODIFIER_VALIDATION_FAILED`
|
|
1718
|
+
* envelope (`BrainerceError.errorData`).
|
|
1719
|
+
*/
|
|
1720
|
+
selections?: ModifierSelection[];
|
|
1721
|
+
/**
|
|
1722
|
+
* Nested-combo selections keyed by parent `modifierId` — only required when
|
|
1723
|
+
* a picked modifier carries `referencedProductId` and that referenced product
|
|
1724
|
+
* itself has modifier groups. Server enforces depth ≤ 3.
|
|
1725
|
+
*/
|
|
1726
|
+
nestedByModifierId?: Record<string, ModifierSelection[]>;
|
|
1561
1727
|
/**
|
|
1562
1728
|
* Optional product info for local cart (guest mode).
|
|
1563
1729
|
* If provided, SDK uses this directly without fetching from API.
|
|
@@ -1572,6 +1738,14 @@ interface AddToCartDto {
|
|
|
1572
1738
|
}
|
|
1573
1739
|
interface UpdateCartItemDto {
|
|
1574
1740
|
quantity: number;
|
|
1741
|
+
/**
|
|
1742
|
+
* Replace the line's modifier selections. Idempotent: server deletes
|
|
1743
|
+
* existing `CartItemModifier` rows and recreates them inside the same
|
|
1744
|
+
* transaction (PRD §7.2.3).
|
|
1745
|
+
*/
|
|
1746
|
+
selections?: ModifierSelection[];
|
|
1747
|
+
/** Nested-combo selections (see `AddToCartDto.nestedByModifierId`). */
|
|
1748
|
+
nestedByModifierId?: Record<string, ModifierSelection[]>;
|
|
1575
1749
|
}
|
|
1576
1750
|
interface ApplyCouponDto {
|
|
1577
1751
|
code: string;
|
|
@@ -2848,6 +3022,33 @@ interface Category {
|
|
|
2848
3022
|
name: string;
|
|
2849
3023
|
sku?: string;
|
|
2850
3024
|
}>;
|
|
3025
|
+
/** Sales channels this category is explicitly published to (admin response only). */
|
|
3026
|
+
channelPublishes?: Array<{
|
|
3027
|
+
salesChannel: {
|
|
3028
|
+
id: string;
|
|
3029
|
+
name: string;
|
|
3030
|
+
connectionId: string;
|
|
3031
|
+
};
|
|
3032
|
+
/** @deprecated alias of `salesChannel` — will be removed in SDK 2.0 */
|
|
3033
|
+
connection?: {
|
|
3034
|
+
id: string;
|
|
3035
|
+
name: string;
|
|
3036
|
+
connectionId: string;
|
|
3037
|
+
};
|
|
3038
|
+
}>;
|
|
3039
|
+
/** @deprecated alias of `channelPublishes` — will be removed in SDK 2.0 */
|
|
3040
|
+
vibeCodedPublishes?: Array<{
|
|
3041
|
+
salesChannel: {
|
|
3042
|
+
id: string;
|
|
3043
|
+
name: string;
|
|
3044
|
+
connectionId: string;
|
|
3045
|
+
};
|
|
3046
|
+
connection?: {
|
|
3047
|
+
id: string;
|
|
3048
|
+
name: string;
|
|
3049
|
+
connectionId: string;
|
|
3050
|
+
};
|
|
3051
|
+
}>;
|
|
2851
3052
|
createdAt: string;
|
|
2852
3053
|
updatedAt: string;
|
|
2853
3054
|
}
|
|
@@ -2893,6 +3094,33 @@ interface Brand {
|
|
|
2893
3094
|
name: string;
|
|
2894
3095
|
sku?: string;
|
|
2895
3096
|
}>;
|
|
3097
|
+
/** Sales channels this brand is explicitly published to (admin response only). */
|
|
3098
|
+
channelPublishes?: Array<{
|
|
3099
|
+
salesChannel: {
|
|
3100
|
+
id: string;
|
|
3101
|
+
name: string;
|
|
3102
|
+
connectionId: string;
|
|
3103
|
+
};
|
|
3104
|
+
/** @deprecated alias of `salesChannel` — will be removed in SDK 2.0 */
|
|
3105
|
+
connection?: {
|
|
3106
|
+
id: string;
|
|
3107
|
+
name: string;
|
|
3108
|
+
connectionId: string;
|
|
3109
|
+
};
|
|
3110
|
+
}>;
|
|
3111
|
+
/** @deprecated alias of `channelPublishes` — will be removed in SDK 2.0 */
|
|
3112
|
+
vibeCodedPublishes?: Array<{
|
|
3113
|
+
salesChannel: {
|
|
3114
|
+
id: string;
|
|
3115
|
+
name: string;
|
|
3116
|
+
connectionId: string;
|
|
3117
|
+
};
|
|
3118
|
+
connection?: {
|
|
3119
|
+
id: string;
|
|
3120
|
+
name: string;
|
|
3121
|
+
connectionId: string;
|
|
3122
|
+
};
|
|
3123
|
+
}>;
|
|
2896
3124
|
createdAt: string;
|
|
2897
3125
|
updatedAt: string;
|
|
2898
3126
|
}
|
|
@@ -2922,6 +3150,8 @@ interface Tag {
|
|
|
2922
3150
|
platformIds?: Record<string, string> | null;
|
|
2923
3151
|
/** Platforms this tag is published on */
|
|
2924
3152
|
publishedOn: string[];
|
|
3153
|
+
/** Per-platform mapping config (parity with Category/Brand/MetafieldDefinition). */
|
|
3154
|
+
platformMetadata?: Record<string, Record<string, unknown>> | null;
|
|
2925
3155
|
isActive: boolean;
|
|
2926
3156
|
productCount?: number;
|
|
2927
3157
|
products?: Array<{
|
|
@@ -2929,6 +3159,33 @@ interface Tag {
|
|
|
2929
3159
|
name: string;
|
|
2930
3160
|
sku?: string;
|
|
2931
3161
|
}>;
|
|
3162
|
+
/** Sales channels this tag is explicitly published to (admin response only). */
|
|
3163
|
+
channelPublishes?: Array<{
|
|
3164
|
+
salesChannel: {
|
|
3165
|
+
id: string;
|
|
3166
|
+
name: string;
|
|
3167
|
+
connectionId: string;
|
|
3168
|
+
};
|
|
3169
|
+
/** @deprecated alias of `salesChannel` — will be removed in SDK 2.0 */
|
|
3170
|
+
connection?: {
|
|
3171
|
+
id: string;
|
|
3172
|
+
name: string;
|
|
3173
|
+
connectionId: string;
|
|
3174
|
+
};
|
|
3175
|
+
}>;
|
|
3176
|
+
/** @deprecated alias of `channelPublishes` — will be removed in SDK 2.0 */
|
|
3177
|
+
vibeCodedPublishes?: Array<{
|
|
3178
|
+
salesChannel: {
|
|
3179
|
+
id: string;
|
|
3180
|
+
name: string;
|
|
3181
|
+
connectionId: string;
|
|
3182
|
+
};
|
|
3183
|
+
connection?: {
|
|
3184
|
+
id: string;
|
|
3185
|
+
name: string;
|
|
3186
|
+
connectionId: string;
|
|
3187
|
+
};
|
|
3188
|
+
}>;
|
|
2932
3189
|
createdAt: string;
|
|
2933
3190
|
updatedAt: string;
|
|
2934
3191
|
}
|
|
@@ -3193,11 +3450,21 @@ interface UpdateTaxRateDto {
|
|
|
3193
3450
|
*/
|
|
3194
3451
|
type MetafieldType = 'TEXT' | 'TEXTAREA' | 'NUMBER' | 'BOOLEAN' | 'DATE' | 'DATETIME' | 'URL' | 'COLOR' | 'DIMENSION' | 'WEIGHT' | 'JSON' | 'IMAGE' | 'GALLERY' | 'SELECT' | 'MULTI_SELECT';
|
|
3195
3452
|
/**
|
|
3196
|
-
* Metafield definition - schema for product metafields
|
|
3453
|
+
* Metafield definition - schema for product metafields.
|
|
3454
|
+
*
|
|
3455
|
+
* Definitions are scoped either to a single store (`storeId` set) or to
|
|
3456
|
+
* the entire account (`storeId === null`). Listing from a store route
|
|
3457
|
+
* returns both — store-scoped first, then account-wide.
|
|
3458
|
+
*
|
|
3459
|
+
* Platform sync state is stored inline (`publishedOn`, `platformMetadata`,
|
|
3460
|
+
* etc.) — same shape as Category / Tag / Brand. The `MetafieldPlatformMapping`
|
|
3461
|
+
* junction was dropped on 2026-04-30.
|
|
3197
3462
|
*/
|
|
3198
3463
|
interface MetafieldDefinition {
|
|
3199
3464
|
id: string;
|
|
3200
3465
|
accountId: string;
|
|
3466
|
+
/** When null, the definition is shared across the account; otherwise it belongs to this store. */
|
|
3467
|
+
storeId: string | null;
|
|
3201
3468
|
name: string;
|
|
3202
3469
|
key: string;
|
|
3203
3470
|
description?: string | null;
|
|
@@ -3210,6 +3477,12 @@ interface MetafieldDefinition {
|
|
|
3210
3477
|
* individual `ProductCustomizationField` rows when this is set.
|
|
3211
3478
|
*/
|
|
3212
3479
|
appliesToAllProducts?: boolean;
|
|
3480
|
+
/**
|
|
3481
|
+
* When `true`, the field is exposed in storefront facet filters. Only
|
|
3482
|
+
* meaningful for SELECT / MULTI_SELECT / BOOLEAN types — the backend
|
|
3483
|
+
* rejects setting this on other types.
|
|
3484
|
+
*/
|
|
3485
|
+
filterable?: boolean;
|
|
3213
3486
|
minLength?: number | null;
|
|
3214
3487
|
maxLength?: number | null;
|
|
3215
3488
|
minValue?: number | null;
|
|
@@ -3218,15 +3491,64 @@ interface MetafieldDefinition {
|
|
|
3218
3491
|
defaultValue?: string | null;
|
|
3219
3492
|
position: number;
|
|
3220
3493
|
isActive: boolean;
|
|
3221
|
-
|
|
3494
|
+
/** Sales channels / platforms where this field is published. */
|
|
3495
|
+
publishedOn: string[];
|
|
3496
|
+
/** External IDs of the metafield definition on each platform. */
|
|
3497
|
+
platformIds?: Record<string, string> | null;
|
|
3498
|
+
/** Per-platform mapping config required for sync. */
|
|
3499
|
+
platformMetadata?: PlatformMetafieldMetadata | null;
|
|
3500
|
+
/** Sync state per platform. */
|
|
3501
|
+
syncStatus?: Record<string, string> | null;
|
|
3502
|
+
/** Last sync timestamp per platform (ISO strings). */
|
|
3503
|
+
lastSyncedAt?: Record<string, string> | null;
|
|
3504
|
+
/** Origin of the definition (e.g. "LOCAL", "SHOPIFY"). */
|
|
3505
|
+
source: string;
|
|
3222
3506
|
/** Products this definition is explicitly attached to (customer-input only). */
|
|
3223
3507
|
products?: Array<{
|
|
3224
3508
|
id: string;
|
|
3225
3509
|
name: string;
|
|
3226
3510
|
}>;
|
|
3511
|
+
/** Sales channels this definition is explicitly published to (admin response only). */
|
|
3512
|
+
channelPublishes?: Array<{
|
|
3513
|
+
salesChannel: {
|
|
3514
|
+
id: string;
|
|
3515
|
+
name: string;
|
|
3516
|
+
connectionId: string;
|
|
3517
|
+
};
|
|
3518
|
+
/** @deprecated alias of `salesChannel` — will be removed in SDK 2.0 */
|
|
3519
|
+
connection?: {
|
|
3520
|
+
id: string;
|
|
3521
|
+
name: string;
|
|
3522
|
+
connectionId: string;
|
|
3523
|
+
};
|
|
3524
|
+
}>;
|
|
3525
|
+
/** @deprecated alias of `channelPublishes` — will be removed in SDK 2.0 */
|
|
3526
|
+
vibeCodedPublishes?: Array<{
|
|
3527
|
+
salesChannel: {
|
|
3528
|
+
id: string;
|
|
3529
|
+
name: string;
|
|
3530
|
+
connectionId: string;
|
|
3531
|
+
};
|
|
3532
|
+
connection?: {
|
|
3533
|
+
id: string;
|
|
3534
|
+
name: string;
|
|
3535
|
+
connectionId: string;
|
|
3536
|
+
};
|
|
3537
|
+
}>;
|
|
3227
3538
|
createdAt: string;
|
|
3228
3539
|
updatedAt: string;
|
|
3229
3540
|
}
|
|
3541
|
+
/**
|
|
3542
|
+
* Per-platform mapping configuration. Required entry per platform listed in
|
|
3543
|
+
* `publishedOn` for the platform to actually sync.
|
|
3544
|
+
*
|
|
3545
|
+
* Shape per platform:
|
|
3546
|
+
* - `SHOPIFY`: `{ namespace: string; key: string; type?: string }`
|
|
3547
|
+
* - `WOOCOMMERCE`: `{ key: string }`
|
|
3548
|
+
* - `TIKTOK`: `{ attributeName: string }`
|
|
3549
|
+
* - `META`: `{ field: 'custom_label_0' | … | 'custom_label_4' }`
|
|
3550
|
+
*/
|
|
3551
|
+
type PlatformMetafieldMetadata = Record<string, Record<string, unknown>>;
|
|
3230
3552
|
/**
|
|
3231
3553
|
* Public subset of MetafieldDefinition for storefront/vibe-coded use.
|
|
3232
3554
|
* Does not include admin-only validation fields.
|
|
@@ -3244,6 +3566,11 @@ interface PublicMetafieldDefinition {
|
|
|
3244
3566
|
* including ones created after the flag was set.
|
|
3245
3567
|
*/
|
|
3246
3568
|
appliesToAllProducts?: boolean;
|
|
3569
|
+
/**
|
|
3570
|
+
* When true, the storefront should expose this field as a facet filter.
|
|
3571
|
+
* Pair with `getProducts({ metafields: { [key]: [...] } })`.
|
|
3572
|
+
*/
|
|
3573
|
+
filterable?: boolean;
|
|
3247
3574
|
enumValues?: string[];
|
|
3248
3575
|
minLength?: number | null;
|
|
3249
3576
|
maxLength?: number | null;
|
|
@@ -3271,19 +3598,6 @@ interface ProductCustomizationField {
|
|
|
3271
3598
|
defaultValue?: string | null;
|
|
3272
3599
|
position: number;
|
|
3273
3600
|
}
|
|
3274
|
-
/**
|
|
3275
|
-
* Platform mapping for metafield syncing
|
|
3276
|
-
*/
|
|
3277
|
-
interface MetafieldPlatformMapping {
|
|
3278
|
-
id: string;
|
|
3279
|
-
definitionId: string;
|
|
3280
|
-
platform: ConnectorPlatform;
|
|
3281
|
-
namespace: string;
|
|
3282
|
-
key: string;
|
|
3283
|
-
isEnabled: boolean;
|
|
3284
|
-
createdAt: string;
|
|
3285
|
-
updatedAt: string;
|
|
3286
|
-
}
|
|
3287
3601
|
interface CreateMetafieldDefinitionDto {
|
|
3288
3602
|
name: string;
|
|
3289
3603
|
key: string;
|
|
@@ -3293,6 +3607,11 @@ interface CreateMetafieldDefinitionDto {
|
|
|
3293
3607
|
isCustomerInput?: boolean;
|
|
3294
3608
|
/** When true the field applies to every product in the account. */
|
|
3295
3609
|
appliesToAllProducts?: boolean;
|
|
3610
|
+
/**
|
|
3611
|
+
* When true, the field is exposed as a storefront facet filter. Backend
|
|
3612
|
+
* rejects this for types other than SELECT / MULTI_SELECT / BOOLEAN.
|
|
3613
|
+
*/
|
|
3614
|
+
filterable?: boolean;
|
|
3296
3615
|
/**
|
|
3297
3616
|
* Assign the new (customer-input) definition to specific products atomically
|
|
3298
3617
|
* in the same create call. Only valid when `isCustomerInput` is true.
|
|
@@ -3305,6 +3624,33 @@ interface CreateMetafieldDefinitionDto {
|
|
|
3305
3624
|
enumValues?: string[];
|
|
3306
3625
|
defaultValue?: string;
|
|
3307
3626
|
position?: number;
|
|
3627
|
+
/**
|
|
3628
|
+
* When `true`, create the definition account-wide (`storeId = null`).
|
|
3629
|
+
* Defaults to false — the definition belongs to the store named in the
|
|
3630
|
+
* route's `:storeId` parameter.
|
|
3631
|
+
*/
|
|
3632
|
+
accountWide?: boolean;
|
|
3633
|
+
/** Sales channels / platforms where this field is published. */
|
|
3634
|
+
publishedOn?: string[];
|
|
3635
|
+
/**
|
|
3636
|
+
* Per-platform sync configuration. Must contain a key for every platform
|
|
3637
|
+
* listed in `publishedOn`.
|
|
3638
|
+
*/
|
|
3639
|
+
platformMetadata?: PlatformMetafieldMetadata;
|
|
3640
|
+
/** Origin of the definition (defaults to "LOCAL"). */
|
|
3641
|
+
source?: string;
|
|
3642
|
+
}
|
|
3643
|
+
/**
|
|
3644
|
+
* Replace the platform publishing configuration on a definition.
|
|
3645
|
+
* Updates `publishedOn` + `platformMetadata` atomically.
|
|
3646
|
+
*/
|
|
3647
|
+
interface SetMetafieldPlatformsDto {
|
|
3648
|
+
publishedOn: string[];
|
|
3649
|
+
/**
|
|
3650
|
+
* Per-platform mapping config keyed by platform. Must contain a key for
|
|
3651
|
+
* every platform listed in `publishedOn`. Pass `null` to clear all metadata.
|
|
3652
|
+
*/
|
|
3653
|
+
platformMetadata?: PlatformMetafieldMetadata | null;
|
|
3308
3654
|
}
|
|
3309
3655
|
interface UpdateMetafieldDefinitionDto {
|
|
3310
3656
|
name?: string;
|
|
@@ -3313,6 +3659,8 @@ interface UpdateMetafieldDefinitionDto {
|
|
|
3313
3659
|
required?: boolean;
|
|
3314
3660
|
isCustomerInput?: boolean;
|
|
3315
3661
|
appliesToAllProducts?: boolean;
|
|
3662
|
+
/** Toggle storefront filter exposure. See CreateMetafieldDefinitionDto.filterable. */
|
|
3663
|
+
filterable?: boolean;
|
|
3316
3664
|
minLength?: number | null;
|
|
3317
3665
|
maxLength?: number | null;
|
|
3318
3666
|
minValue?: number | null;
|
|
@@ -3352,10 +3700,10 @@ interface UpsertProductMetafieldDto {
|
|
|
3352
3700
|
variantId?: string;
|
|
3353
3701
|
}
|
|
3354
3702
|
/**
|
|
3355
|
-
* @deprecated Use StoreRole instead. Account-level team management is
|
|
3356
|
-
*
|
|
3703
|
+
* @deprecated Use StoreRole instead. Account-level team management is reserved
|
|
3704
|
+
* for billing/account-owner operations only.
|
|
3357
3705
|
*/
|
|
3358
|
-
type TeamRole = 'ACCOUNT_OWNER'
|
|
3706
|
+
type TeamRole = 'ACCOUNT_OWNER';
|
|
3359
3707
|
/**
|
|
3360
3708
|
* @deprecated Use StoreMember instead.
|
|
3361
3709
|
*/
|
|
@@ -3413,7 +3761,7 @@ interface UpdateMemberRoleDto {
|
|
|
3413
3761
|
/** Store-level team member role */
|
|
3414
3762
|
type StoreRole = 'OWNER' | 'MANAGER' | 'STAFF' | 'VIEWER';
|
|
3415
3763
|
/** Granular store permission */
|
|
3416
|
-
type StorePermission = 'VIEW_PRODUCTS' | 'CREATE_PRODUCTS' | 'EDIT_PRODUCTS' | 'DELETE_PRODUCTS' | 'MANAGE_PRODUCT_CATEGORIES' | 'VIEW_ORDERS' | 'UPDATE_ORDER_STATUS' | 'FULFILL_ORDERS' | 'CANCEL_ORDERS' | 'REFUND_ORDERS' | 'VIEW_INVENTORY' | 'UPDATE_INVENTORY' | 'VIEW_CUSTOMERS' | 'EDIT_CUSTOMERS' | '
|
|
3764
|
+
type StorePermission = 'VIEW_PRODUCTS' | 'CREATE_PRODUCTS' | 'EDIT_PRODUCTS' | 'DELETE_PRODUCTS' | 'MANAGE_PRODUCT_CATEGORIES' | 'VIEW_ORDERS' | 'UPDATE_ORDER_STATUS' | 'FULFILL_ORDERS' | 'CANCEL_ORDERS' | 'REFUND_ORDERS' | 'VIEW_INVENTORY' | 'UPDATE_INVENTORY' | 'VIEW_CUSTOMERS' | 'EDIT_CUSTOMERS' | 'VIEW_ANALYTICS' | 'MANAGE_STORE_SETTINGS' | 'MANAGE_INTEGRATIONS' | 'MANAGE_TEAM' | 'MANAGE_BILLING';
|
|
3417
3765
|
/** Store team member info */
|
|
3418
3766
|
interface StoreMember {
|
|
3419
3767
|
id: string;
|
|
@@ -3748,19 +4096,39 @@ interface LockedVariant {
|
|
|
3748
4096
|
name?: string | null;
|
|
3749
4097
|
attributes?: Record<string, string> | null;
|
|
3750
4098
|
}
|
|
4099
|
+
interface CartBundleOfferOfferedProduct {
|
|
4100
|
+
id: string;
|
|
4101
|
+
name: string;
|
|
4102
|
+
slug: string | null;
|
|
4103
|
+
basePrice: string;
|
|
4104
|
+
salePrice: string | null;
|
|
4105
|
+
images: Array<{
|
|
4106
|
+
url: string;
|
|
4107
|
+
}>;
|
|
4108
|
+
type: string;
|
|
4109
|
+
originalPrice: string;
|
|
4110
|
+
discountedPrice: string;
|
|
4111
|
+
}
|
|
3751
4112
|
interface CartBundleOffer {
|
|
3752
4113
|
id: string;
|
|
3753
4114
|
name: string;
|
|
3754
4115
|
description: string | null;
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
|
|
4116
|
+
/** First product in productIds — must be in cart for the bundle to surface. */
|
|
4117
|
+
triggerProductId: string;
|
|
4118
|
+
/**
|
|
4119
|
+
* Full product list for the bundle. Index 0 is the trigger; indices 1..n
|
|
4120
|
+
* are offered together at the discount.
|
|
4121
|
+
*/
|
|
4122
|
+
productIds: string[];
|
|
4123
|
+
/**
|
|
4124
|
+
* Products being offered to the customer (productIds[1..] minus those
|
|
4125
|
+
* already in cart). Each item carries the discounted price.
|
|
4126
|
+
*/
|
|
4127
|
+
offeredProducts: CartBundleOfferOfferedProduct[];
|
|
3760
4128
|
discountType: 'PERCENTAGE' | 'FIXED_AMOUNT';
|
|
3761
4129
|
discountValue: string;
|
|
3762
|
-
|
|
3763
|
-
|
|
4130
|
+
totalOriginalPrice: string;
|
|
4131
|
+
totalDiscountedPrice: string;
|
|
3764
4132
|
}
|
|
3765
4133
|
interface CartBundlesResponse {
|
|
3766
4134
|
bundles: CartBundleOffer[];
|
|
@@ -3925,6 +4293,8 @@ interface ContactFormPublicField {
|
|
|
3925
4293
|
}>;
|
|
3926
4294
|
validation?: ContactFormFieldValidation;
|
|
3927
4295
|
defaultValue?: string;
|
|
4296
|
+
/** Layout width hint. Render in a CSS grid: FULL = full row, HALF = half row, THIRD = one-third. */
|
|
4297
|
+
width?: 'FULL' | 'HALF' | 'THIRD';
|
|
3928
4298
|
}
|
|
3929
4299
|
interface ContactFormPublic {
|
|
3930
4300
|
id: string;
|
|
@@ -3940,6 +4310,268 @@ interface ContactFormSummary {
|
|
|
3940
4310
|
name: string;
|
|
3941
4311
|
isDefault: boolean;
|
|
3942
4312
|
}
|
|
4313
|
+
/**
|
|
4314
|
+
* How many modifiers a customer can pick from a group.
|
|
4315
|
+
*
|
|
4316
|
+
* - `SINGLE`: radio behavior, max 1.
|
|
4317
|
+
* - `MULTIPLE`: checkbox behavior, bounded by `min`/`max`.
|
|
4318
|
+
*/
|
|
4319
|
+
type ModifierSelectionType = 'SINGLE' | 'MULTIPLE';
|
|
4320
|
+
/**
|
|
4321
|
+
* Tie-break rule for which selected modifiers consume the group's free quantity.
|
|
4322
|
+
*
|
|
4323
|
+
* - `EXPENSIVE_FREE`: the priciest picks become free (best for the customer).
|
|
4324
|
+
* - `CHEAPEST_FREE`: the cheapest picks become free (best for the merchant).
|
|
4325
|
+
* - `SELECTION_ORDER`: free is granted by click-order (first-N rule).
|
|
4326
|
+
*
|
|
4327
|
+
* Negative `priceDelta` modifiers never consume free slots regardless of policy.
|
|
4328
|
+
*/
|
|
4329
|
+
type FreeAllocationPolicy = 'EXPENSIVE_FREE' | 'CHEAPEST_FREE' | 'SELECTION_ORDER';
|
|
4330
|
+
/**
|
|
4331
|
+
* A single picker option inside a `ModifierGroup` (e.g., "Olives", "Thick crust").
|
|
4332
|
+
*
|
|
4333
|
+
* **Money fields are strings**: `priceDelta` is a decimal string like `"5.00"`
|
|
4334
|
+
* (negative values such as `"-2.00"` are valid for downsell modifiers, e.g.,
|
|
4335
|
+
* "no bread −2₪"). Use `parseFloat()` for client-side arithmetic.
|
|
4336
|
+
*/
|
|
4337
|
+
interface Modifier {
|
|
4338
|
+
id: string;
|
|
4339
|
+
name: string;
|
|
4340
|
+
description?: string;
|
|
4341
|
+
/**
|
|
4342
|
+
* Decimal string — `"5.00"`, `"-2.00"`. Never a JSON number.
|
|
4343
|
+
* Per the platform's Decimal-on-the-wire contract (PRD §6.4.1).
|
|
4344
|
+
*/
|
|
4345
|
+
priceDelta: string;
|
|
4346
|
+
sku?: string;
|
|
4347
|
+
image?: {
|
|
4348
|
+
url: string;
|
|
4349
|
+
thumbnailUrl?: string;
|
|
4350
|
+
alt?: string;
|
|
4351
|
+
};
|
|
4352
|
+
position: number;
|
|
4353
|
+
/** Pre-checked in the UI on first render. */
|
|
4354
|
+
isDefault: boolean;
|
|
4355
|
+
/** Sold-out toggle: `false` = out of stock, hidden as selectable in storefronts. */
|
|
4356
|
+
available: boolean;
|
|
4357
|
+
/**
|
|
4358
|
+
* Nested-combo target. When present, picking this modifier opens the
|
|
4359
|
+
* referenced product's own modifier groups (depth ≤ 3).
|
|
4360
|
+
*/
|
|
4361
|
+
referencedProductId?: string;
|
|
4362
|
+
translations?: Record<string, {
|
|
4363
|
+
name?: string;
|
|
4364
|
+
description?: string;
|
|
4365
|
+
}>;
|
|
4366
|
+
status?: 'active' | 'archived';
|
|
4367
|
+
createdAt?: string;
|
|
4368
|
+
updatedAt?: string;
|
|
4369
|
+
}
|
|
4370
|
+
/**
|
|
4371
|
+
* A modifier group — the customer-facing block of related options
|
|
4372
|
+
* (e.g., "Toppings", "Bread type"). Effective fields (`min`, `max`,
|
|
4373
|
+
* `freeQuantity`, `required`, `freeAllocationPolicy`, `defaultModifierIds`)
|
|
4374
|
+
* already reflect any per-attachment or per-variant overrides when fetched
|
|
4375
|
+
* via a product context (`GET /products/:id`).
|
|
4376
|
+
*
|
|
4377
|
+
* `internalName` is admin-only and is stripped from public storefront responses
|
|
4378
|
+
* (PRD §5.2 invariant). It surfaces only when fetched with a Clerk JWT or API key.
|
|
4379
|
+
*/
|
|
4380
|
+
interface ModifierGroup {
|
|
4381
|
+
id: string;
|
|
4382
|
+
/**
|
|
4383
|
+
* Set when fetched in a product context — the `ProductModifierGroup` row id.
|
|
4384
|
+
* Use this to update or detach the attachment without reattaching the group.
|
|
4385
|
+
*/
|
|
4386
|
+
attachmentId?: string;
|
|
4387
|
+
/** Customer-facing canonical name. */
|
|
4388
|
+
name: string;
|
|
4389
|
+
/** Admin-only disambiguator; never returned on public storefront responses. */
|
|
4390
|
+
internalName?: string;
|
|
4391
|
+
description?: string;
|
|
4392
|
+
selectionType: ModifierSelectionType;
|
|
4393
|
+
/** Effective minimum after any overrides. */
|
|
4394
|
+
min: number;
|
|
4395
|
+
/** Effective maximum after any overrides; `null` = unlimited. */
|
|
4396
|
+
max?: number | null;
|
|
4397
|
+
/** Effective free quantity. */
|
|
4398
|
+
freeQuantity: number;
|
|
4399
|
+
/** Effective required flag. */
|
|
4400
|
+
required: boolean;
|
|
4401
|
+
freeAllocationPolicy: FreeAllocationPolicy;
|
|
4402
|
+
modifiers: Modifier[];
|
|
4403
|
+
/** Effective default selections. */
|
|
4404
|
+
defaultModifierIds: string[];
|
|
4405
|
+
/**
|
|
4406
|
+
* When fetched in a product context with admin scope: the per-variant overrides
|
|
4407
|
+
* applied to this group on this product. Each entry shadows the group's default
|
|
4408
|
+
* scalar fields when present.
|
|
4409
|
+
*/
|
|
4410
|
+
variantOverrides?: Record<string, Partial<{
|
|
4411
|
+
min: number;
|
|
4412
|
+
max: number;
|
|
4413
|
+
freeQuantity: number;
|
|
4414
|
+
required: boolean;
|
|
4415
|
+
defaultModifierIds: string[];
|
|
4416
|
+
freeAllocationPolicy: FreeAllocationPolicy;
|
|
4417
|
+
}>>;
|
|
4418
|
+
translations?: Record<string, {
|
|
4419
|
+
name?: string;
|
|
4420
|
+
description?: string;
|
|
4421
|
+
}>;
|
|
4422
|
+
status?: 'active' | 'archived';
|
|
4423
|
+
position?: number;
|
|
4424
|
+
createdAt?: string;
|
|
4425
|
+
updatedAt?: string;
|
|
4426
|
+
}
|
|
4427
|
+
/**
|
|
4428
|
+
* Join row connecting a `ModifierGroup` to a `Product` (with optional per-variant overrides).
|
|
4429
|
+
*
|
|
4430
|
+
* Three patterns (PRD §5.4):
|
|
4431
|
+
* - `variantId` omitted → default attach (applies to all variants).
|
|
4432
|
+
* - `variantId` set + matching default attach exists → variant override row.
|
|
4433
|
+
* - `variantId` set + no default attach → variant-only group.
|
|
4434
|
+
*
|
|
4435
|
+
* `null` overrides inherit; any non-null value (including `0` or `false`) wins.
|
|
4436
|
+
*/
|
|
4437
|
+
interface ProductModifierGroupAttachment {
|
|
4438
|
+
id: string;
|
|
4439
|
+
productId: string;
|
|
4440
|
+
modifierGroupId: string;
|
|
4441
|
+
variantId?: string | null;
|
|
4442
|
+
position: number;
|
|
4443
|
+
minOverride?: number | null;
|
|
4444
|
+
maxOverride?: number | null;
|
|
4445
|
+
freeQuantityOverride?: number | null;
|
|
4446
|
+
requiredOverride?: boolean | null;
|
|
4447
|
+
freeAllocationPolicyOverride?: FreeAllocationPolicy | null;
|
|
4448
|
+
/** Empty array = inherit (PRD rule E); non-empty = override. */
|
|
4449
|
+
defaultModifierIds?: string[];
|
|
4450
|
+
createdAt?: string;
|
|
4451
|
+
updatedAt?: string;
|
|
4452
|
+
}
|
|
4453
|
+
/**
|
|
4454
|
+
* Customer-side selection payload for cart add/update.
|
|
4455
|
+
* `modifierIds` is in click-order — the resolver may use this for
|
|
4456
|
+
* `SELECTION_ORDER` free-allocation policy.
|
|
4457
|
+
*/
|
|
4458
|
+
interface ModifierSelection {
|
|
4459
|
+
modifierGroupId: string;
|
|
4460
|
+
modifierIds: string[];
|
|
4461
|
+
}
|
|
4462
|
+
/**
|
|
4463
|
+
* Per-line modifier breakdown surfaced on `CartItem` and `OrderItem`
|
|
4464
|
+
* once the cart line includes selections.
|
|
4465
|
+
*/
|
|
4466
|
+
interface CartItemModifierLine {
|
|
4467
|
+
modifierId: string;
|
|
4468
|
+
/** Snapshot of the modifier name at the time the line was added. */
|
|
4469
|
+
name: string;
|
|
4470
|
+
/** Decimal string snapshot of the priceDelta at the time the line was added. */
|
|
4471
|
+
priceDelta: string;
|
|
4472
|
+
/** True if this modifier consumed one of the group's free slots. */
|
|
4473
|
+
freeApplied: boolean;
|
|
4474
|
+
}
|
|
4475
|
+
/** Query parameters for `listModifierGroups`. */
|
|
4476
|
+
interface ListModifierGroupsParams {
|
|
4477
|
+
[key: string]: string | number | undefined;
|
|
4478
|
+
page?: number;
|
|
4479
|
+
limit?: number;
|
|
4480
|
+
/** Substring match against `name` and `internalName`. */
|
|
4481
|
+
search?: string;
|
|
4482
|
+
status?: 'active' | 'archived';
|
|
4483
|
+
}
|
|
4484
|
+
interface CreateModifierGroupInput {
|
|
4485
|
+
name: string;
|
|
4486
|
+
internalName?: string;
|
|
4487
|
+
description?: string;
|
|
4488
|
+
translations?: Record<string, {
|
|
4489
|
+
name?: string;
|
|
4490
|
+
description?: string;
|
|
4491
|
+
}>;
|
|
4492
|
+
selectionType?: ModifierSelectionType;
|
|
4493
|
+
minSelections?: number;
|
|
4494
|
+
/** `null` = unlimited. */
|
|
4495
|
+
maxSelections?: number | null;
|
|
4496
|
+
freeQuantity?: number;
|
|
4497
|
+
required?: boolean;
|
|
4498
|
+
freeAllocationPolicy?: FreeAllocationPolicy;
|
|
4499
|
+
/** Default position hint for new product attachments. Per-attach value always wins. */
|
|
4500
|
+
position?: number;
|
|
4501
|
+
}
|
|
4502
|
+
interface UpdateModifierGroupInput extends Partial<CreateModifierGroupInput> {
|
|
4503
|
+
status?: 'active' | 'archived';
|
|
4504
|
+
}
|
|
4505
|
+
interface CreateModifierInput {
|
|
4506
|
+
name: string;
|
|
4507
|
+
description?: string;
|
|
4508
|
+
translations?: Record<string, {
|
|
4509
|
+
name?: string;
|
|
4510
|
+
description?: string;
|
|
4511
|
+
}>;
|
|
4512
|
+
/**
|
|
4513
|
+
* Decimal string. Negative values are accepted for downsell modifiers
|
|
4514
|
+
* (e.g., `"-2.00"`); the server still enforces a `unitPrice >= 0` floor and
|
|
4515
|
+
* rejects negative deltas combined with `referencedProductId`.
|
|
4516
|
+
*/
|
|
4517
|
+
priceDelta: string;
|
|
4518
|
+
sku?: string;
|
|
4519
|
+
image?: {
|
|
4520
|
+
url: string;
|
|
4521
|
+
thumbnailUrl?: string;
|
|
4522
|
+
alt?: string;
|
|
4523
|
+
};
|
|
4524
|
+
position?: number;
|
|
4525
|
+
isDefault?: boolean;
|
|
4526
|
+
available?: boolean;
|
|
4527
|
+
referencedProductId?: string;
|
|
4528
|
+
}
|
|
4529
|
+
interface UpdateModifierInput extends Partial<CreateModifierInput> {
|
|
4530
|
+
status?: 'active' | 'archived';
|
|
4531
|
+
}
|
|
4532
|
+
interface AttachModifierGroupInput {
|
|
4533
|
+
modifierGroupId: string;
|
|
4534
|
+
/** Specific variant for a per-variant override. Omit for a default attach. */
|
|
4535
|
+
variantId?: string;
|
|
4536
|
+
position?: number;
|
|
4537
|
+
/** `null` = inherit; any value (incl. `0`) overrides. */
|
|
4538
|
+
minOverride?: number | null;
|
|
4539
|
+
maxOverride?: number | null;
|
|
4540
|
+
freeQuantityOverride?: number | null;
|
|
4541
|
+
/** `null` = inherit; any value (incl. `false`) overrides. */
|
|
4542
|
+
requiredOverride?: boolean | null;
|
|
4543
|
+
freeAllocationPolicyOverride?: FreeAllocationPolicy | null;
|
|
4544
|
+
/** Empty array = inherit (PRD rule E); non-empty array = override. */
|
|
4545
|
+
defaultModifierIds?: string[];
|
|
4546
|
+
}
|
|
4547
|
+
/**
|
|
4548
|
+
* Update DTO for an existing attachment.
|
|
4549
|
+
*
|
|
4550
|
+
* `modifierGroupId` and `variantId` are immutable — they form the attachment's
|
|
4551
|
+
* identity (PRD §5.4 partial unique index). To swap a group on a product, detach
|
|
4552
|
+
* and re-attach.
|
|
4553
|
+
*/
|
|
4554
|
+
type UpdateAttachmentInput = Partial<Omit<AttachModifierGroupInput, 'modifierGroupId' | 'variantId'>>;
|
|
4555
|
+
/**
|
|
4556
|
+
* Stable error codes returned in the structured `MODIFIER_VALIDATION_FAILED`
|
|
4557
|
+
* envelope when a cart add/update payload fails server-side validation.
|
|
4558
|
+
*
|
|
4559
|
+
* `MODIFIER_PRICE_FLOOR_VIOLATED` is also wrapped in this envelope (Phase 1.5
|
|
4560
|
+
* Slice C) — it fires when modifier downsells push the unit price below `0`.
|
|
4561
|
+
*/
|
|
4562
|
+
type ModifierValidationCode = 'REQUIRED_GROUP_MISSING' | 'MIN_SELECTIONS_NOT_MET' | 'MAX_SELECTIONS_EXCEEDED' | 'SINGLE_GROUP_MULTIPLE_PICKS' | 'UNKNOWN_MODIFIER' | 'UNKNOWN_GROUP' | 'MODIFIER_DISABLED_FOR_VARIANT' | 'MODIFIER_NOT_AVAILABLE' | 'NESTED_DEPTH_EXCEEDED' | 'NESTED_REQUIRES_PRODUCT_REF' | 'INVALID_PRICE_DELTA' | 'MODIFIER_PRICE_FLOOR_VIOLATED';
|
|
4563
|
+
/**
|
|
4564
|
+
* Single validation issue inside the `MODIFIER_VALIDATION_FAILED` envelope.
|
|
4565
|
+
*/
|
|
4566
|
+
interface ModifierValidationError {
|
|
4567
|
+
code: ModifierValidationCode;
|
|
4568
|
+
/** Human-readable message — safe to show users. */
|
|
4569
|
+
message: string;
|
|
4570
|
+
/** Group the error belongs to (when applicable). */
|
|
4571
|
+
modifierGroupId?: string;
|
|
4572
|
+
/** Modifier the error belongs to (when applicable). */
|
|
4573
|
+
modifierId?: string;
|
|
4574
|
+
}
|
|
3943
4575
|
interface BrainerceApiError {
|
|
3944
4576
|
statusCode: number;
|
|
3945
4577
|
message: string;
|
|
@@ -4035,7 +4667,11 @@ declare class BrainerceClient {
|
|
|
4035
4667
|
*/
|
|
4036
4668
|
private withPaginatedGuards;
|
|
4037
4669
|
/**
|
|
4038
|
-
* Check if client is in
|
|
4670
|
+
* Check if client is in sales-channel mode (using salesChannelId / legacy connectionId).
|
|
4671
|
+
*/
|
|
4672
|
+
isSalesChannelMode(): boolean;
|
|
4673
|
+
/**
|
|
4674
|
+
* @deprecated Use `isSalesChannelMode()` instead. Kept as a backwards-compatible alias.
|
|
4039
4675
|
*/
|
|
4040
4676
|
isVibeCodedMode(): boolean;
|
|
4041
4677
|
/**
|
|
@@ -4770,6 +5406,50 @@ declare class BrainerceClient {
|
|
|
4770
5406
|
* Get a customer by email
|
|
4771
5407
|
*/
|
|
4772
5408
|
getCustomerByEmail(email: string): Promise<Customer | null>;
|
|
5409
|
+
/**
|
|
5410
|
+
* List a customer's saved payment methods (vaulted cards).
|
|
5411
|
+
*
|
|
5412
|
+
* Returns display-only metadata — last4, brand, expiry, default flag,
|
|
5413
|
+
* status. The underlying provider token is encrypted at rest and
|
|
5414
|
+
* NEVER returned through this API.
|
|
5415
|
+
*
|
|
5416
|
+
* Apps mode requires `customers:read` and `payments:read` scopes.
|
|
5417
|
+
*
|
|
5418
|
+
* @param storeId - The store this customer belongs to
|
|
5419
|
+
* @param customerId - The customer's ID
|
|
5420
|
+
* @returns Array of saved payment methods
|
|
5421
|
+
*
|
|
5422
|
+
* @example
|
|
5423
|
+
* ```typescript
|
|
5424
|
+
* const methods = await client.listSavedPaymentMethods(storeId, customerId);
|
|
5425
|
+
* methods.forEach((m) => {
|
|
5426
|
+
* console.log(`${m.brand} ending in ${m.last4} (expires ${m.expMonth}/${m.expYear})`);
|
|
5427
|
+
* });
|
|
5428
|
+
* ```
|
|
5429
|
+
*/
|
|
5430
|
+
listSavedPaymentMethods(storeId: string, customerId: string): Promise<SavedPaymentMethodSummary[]>;
|
|
5431
|
+
/**
|
|
5432
|
+
* Remove a customer's saved payment method.
|
|
5433
|
+
*
|
|
5434
|
+
* Hard-deletes the row. The provider may still hold the underlying
|
|
5435
|
+
* token internally — we don't issue a delete-at-provider call because
|
|
5436
|
+
* not every provider supports it. From the platform's perspective the
|
|
5437
|
+
* token is gone; subsequent charges will fail.
|
|
5438
|
+
*
|
|
5439
|
+
* Apps mode requires `customers:write` scope.
|
|
5440
|
+
*
|
|
5441
|
+
* @param storeId - The store this customer belongs to
|
|
5442
|
+
* @param customerId - The customer's ID
|
|
5443
|
+
* @param paymentMethodId - The saved payment method ID to remove
|
|
5444
|
+
*
|
|
5445
|
+
* @example
|
|
5446
|
+
* ```typescript
|
|
5447
|
+
* await client.removeSavedPaymentMethod(storeId, customerId, methodId);
|
|
5448
|
+
* ```
|
|
5449
|
+
*/
|
|
5450
|
+
removeSavedPaymentMethod(storeId: string, customerId: string, paymentMethodId: string): Promise<{
|
|
5451
|
+
success: true;
|
|
5452
|
+
}>;
|
|
4773
5453
|
/**
|
|
4774
5454
|
* Login an existing customer (returns JWT token)
|
|
4775
5455
|
* Works in vibe-coded, storefront, and admin mode
|
|
@@ -5249,6 +5929,42 @@ declare class BrainerceClient {
|
|
|
5249
5929
|
* ```
|
|
5250
5930
|
*/
|
|
5251
5931
|
removeCoupon(cartId: string): Promise<Cart>;
|
|
5932
|
+
/**
|
|
5933
|
+
* Recalculate cart totals against current product/variant prices and
|
|
5934
|
+
* discount rules. Idempotent — does NOT mutate the per-item snapshot
|
|
5935
|
+
* `unitPrice`. The returned cart's `hasPriceChanges` / `hasUnavailableItems`
|
|
5936
|
+
* flags reflect the live state. Call this on cart load if you want to
|
|
5937
|
+
* surface drift to the customer before they reach checkout.
|
|
5938
|
+
*
|
|
5939
|
+
* @example
|
|
5940
|
+
* ```typescript
|
|
5941
|
+
* const cart = await client.recalculateCart('cart_123');
|
|
5942
|
+
* if (cart.hasPriceChanges) {
|
|
5943
|
+
* // show "prices have changed" banner
|
|
5944
|
+
* }
|
|
5945
|
+
* ```
|
|
5946
|
+
*/
|
|
5947
|
+
recalculateCart(cartId: string): Promise<Cart>;
|
|
5948
|
+
/**
|
|
5949
|
+
* Refresh per-item `unitPrice` snapshots to current live prices. Use this
|
|
5950
|
+
* after the customer accepts new prices in the drift-reconfirm flow. The
|
|
5951
|
+
* subsequent `createCheckout` call will then succeed (it would otherwise
|
|
5952
|
+
* throw `PRICE_DRIFT`).
|
|
5953
|
+
*
|
|
5954
|
+
* @example
|
|
5955
|
+
* ```typescript
|
|
5956
|
+
* try {
|
|
5957
|
+
* await client.createCheckout(cartId);
|
|
5958
|
+
* } catch (err) {
|
|
5959
|
+
* if (err.code === 'PRICE_DRIFT') {
|
|
5960
|
+
* // ask user to confirm new prices, then:
|
|
5961
|
+
* await client.refreshCartSnapshots(cartId);
|
|
5962
|
+
* await client.createCheckout(cartId);
|
|
5963
|
+
* }
|
|
5964
|
+
* }
|
|
5965
|
+
* ```
|
|
5966
|
+
*/
|
|
5967
|
+
refreshCartSnapshots(cartId: string): Promise<Cart>;
|
|
5252
5968
|
/**
|
|
5253
5969
|
* Link a cart to the currently logged-in customer.
|
|
5254
5970
|
* Use this after customer logs in to associate their guest cart with their account.
|
|
@@ -5383,7 +6099,8 @@ declare class BrainerceClient {
|
|
|
5383
6099
|
* ```typescript
|
|
5384
6100
|
* const { bundles } = await client.getCartBundles('cart_123');
|
|
5385
6101
|
* bundles.forEach(b => {
|
|
5386
|
-
*
|
|
6102
|
+
* const names = b.offeredProducts.map(p => p.name).join(', ');
|
|
6103
|
+
* console.log(`Add ${names} and save! Was ${b.totalOriginalPrice}, now ${b.totalDiscountedPrice}`);
|
|
5387
6104
|
* });
|
|
5388
6105
|
* ```
|
|
5389
6106
|
*/
|
|
@@ -5413,23 +6130,27 @@ declare class BrainerceClient {
|
|
|
5413
6130
|
*/
|
|
5414
6131
|
removeOrderBump(cartId: string, bumpConfigId: string): Promise<Cart>;
|
|
5415
6132
|
/**
|
|
5416
|
-
*
|
|
6133
|
+
* Accept an N-product bundle offer: every offered product not yet in cart
|
|
6134
|
+
* is added with the bundle discount applied.
|
|
5417
6135
|
*
|
|
5418
6136
|
* @param cartId - Cart ID
|
|
5419
6137
|
* @param bundleOfferId - Bundle offer ID
|
|
5420
|
-
* @param
|
|
6138
|
+
* @param variantSelections - Optional map of `productId → variantId` for offered products with variants
|
|
5421
6139
|
* @returns Updated cart
|
|
5422
6140
|
*
|
|
5423
6141
|
* @example
|
|
5424
6142
|
* ```typescript
|
|
5425
6143
|
* const { bundles } = await client.getCartBundles('cart_123');
|
|
5426
|
-
*
|
|
5427
|
-
*
|
|
5428
|
-
*
|
|
5429
|
-
*
|
|
6144
|
+
* const bundle = bundles[0];
|
|
6145
|
+
* // Simple products only:
|
|
6146
|
+
* await client.addBundleToCart('cart_123', bundle.id);
|
|
6147
|
+
* // Some offered products have variants:
|
|
6148
|
+
* await client.addBundleToCart('cart_123', bundle.id, {
|
|
6149
|
+
* [variantProductId]: selectedVariantId,
|
|
6150
|
+
* });
|
|
5430
6151
|
* ```
|
|
5431
6152
|
*/
|
|
5432
|
-
addBundleToCart(cartId: string, bundleOfferId: string,
|
|
6153
|
+
addBundleToCart(cartId: string, bundleOfferId: string, variantSelections?: Record<string, string>): Promise<Cart>;
|
|
5433
6154
|
/**
|
|
5434
6155
|
* Remove a bundle offer product from the cart.
|
|
5435
6156
|
*
|
|
@@ -5541,6 +6262,10 @@ declare class BrainerceClient {
|
|
|
5541
6262
|
variantId?: string;
|
|
5542
6263
|
quantity: number;
|
|
5543
6264
|
metadata?: Record<string, unknown>;
|
|
6265
|
+
/** Modifier-group selections (PRD §7.3 / §8.4). */
|
|
6266
|
+
selections?: ModifierSelection[];
|
|
6267
|
+
/** Nested-combo selections keyed by parent modifierId. */
|
|
6268
|
+
nestedByModifierId?: Record<string, ModifierSelection[]>;
|
|
5544
6269
|
}): Promise<Cart>;
|
|
5545
6270
|
/**
|
|
5546
6271
|
* Smart get cart - returns the current cart (server-side for both guests and logged-in users)
|
|
@@ -5963,6 +6688,21 @@ declare class BrainerceClient {
|
|
|
5963
6688
|
createPaymentIntent(checkoutId: string, options?: {
|
|
5964
6689
|
successUrl?: string;
|
|
5965
6690
|
cancelUrl?: string;
|
|
6691
|
+
/**
|
|
6692
|
+
* Per-checkout opt-in to vault the card for off-session reuse.
|
|
6693
|
+
* Set to `true` when the customer ticked a "save card for next
|
|
6694
|
+
* time" checkbox. Only honored when the checkout has a known
|
|
6695
|
+
* `customerId` (logged-in customers, not guests). The platform
|
|
6696
|
+
* forwards this to the underlying payment provider; providers
|
|
6697
|
+
* that don't support tokenization (e.g. Grow today) silently
|
|
6698
|
+
* ignore it.
|
|
6699
|
+
*
|
|
6700
|
+
* After a successful charge with `saveCard: true`, the saved
|
|
6701
|
+
* card appears in `customers.listSavedPaymentMethods()` and can
|
|
6702
|
+
* be charged off-session via the dashboard / future
|
|
6703
|
+
* subscription features.
|
|
6704
|
+
*/
|
|
6705
|
+
saveCard?: boolean;
|
|
5966
6706
|
}): Promise<PaymentIntent>;
|
|
5967
6707
|
/**
|
|
5968
6708
|
* Get payment status for a checkout.
|
|
@@ -6778,6 +7518,133 @@ declare class BrainerceClient {
|
|
|
6778
7518
|
* Requires Admin mode (apiKey)
|
|
6779
7519
|
*/
|
|
6780
7520
|
deleteAttributeOption(attributeId: string, optionId: string): Promise<void>;
|
|
7521
|
+
/**
|
|
7522
|
+
* List modifier groups in a store, paginated.
|
|
7523
|
+
* Requires Admin mode (apiKey).
|
|
7524
|
+
*
|
|
7525
|
+
* @example
|
|
7526
|
+
* ```typescript
|
|
7527
|
+
* const groups = await client.listModifierGroups('store_123', {
|
|
7528
|
+
* page: 1,
|
|
7529
|
+
* limit: 20,
|
|
7530
|
+
* search: 'pizza',
|
|
7531
|
+
* status: 'active',
|
|
7532
|
+
* });
|
|
7533
|
+
* ```
|
|
7534
|
+
*/
|
|
7535
|
+
listModifierGroups(storeId: string, params?: ListModifierGroupsParams): Promise<PaginatedResponse<ModifierGroup>>;
|
|
7536
|
+
/**
|
|
7537
|
+
* Fetch a single modifier group (with its modifiers).
|
|
7538
|
+
* Requires Admin mode (apiKey).
|
|
7539
|
+
*
|
|
7540
|
+
* Admin fetches include `internalName`; storefront responses strip it
|
|
7541
|
+
* (PRD §5.2 invariant).
|
|
7542
|
+
*/
|
|
7543
|
+
getModifierGroup(storeId: string, groupId: string): Promise<ModifierGroup>;
|
|
7544
|
+
/**
|
|
7545
|
+
* Create a modifier group. Modifiers themselves are created separately via
|
|
7546
|
+
* `createModifier(storeId, groupId, …)`.
|
|
7547
|
+
* Requires Admin mode (apiKey).
|
|
7548
|
+
*
|
|
7549
|
+
* @example
|
|
7550
|
+
* ```typescript
|
|
7551
|
+
* const group = await client.createModifierGroup('store_123', {
|
|
7552
|
+
* name: 'Toppings',
|
|
7553
|
+
* internalName: 'Pizza toppings',
|
|
7554
|
+
* selectionType: 'MULTIPLE',
|
|
7555
|
+
* minSelections: 0,
|
|
7556
|
+
* maxSelections: 8,
|
|
7557
|
+
* freeQuantity: 3,
|
|
7558
|
+
* freeAllocationPolicy: 'EXPENSIVE_FREE',
|
|
7559
|
+
* });
|
|
7560
|
+
* ```
|
|
7561
|
+
*/
|
|
7562
|
+
createModifierGroup(storeId: string, data: CreateModifierGroupInput): Promise<ModifierGroup>;
|
|
7563
|
+
/**
|
|
7564
|
+
* Update a modifier group's metadata or selection rules. Pass `status: 'archived'`
|
|
7565
|
+
* to soft-delete (the group becomes hidden from product attachments).
|
|
7566
|
+
* Requires Admin mode (apiKey).
|
|
7567
|
+
*/
|
|
7568
|
+
updateModifierGroup(storeId: string, groupId: string, data: UpdateModifierGroupInput): Promise<ModifierGroup>;
|
|
7569
|
+
/**
|
|
7570
|
+
* Hard-delete a modifier group. Server rejects deletion when the group is
|
|
7571
|
+
* still attached to any product (detach the attachments first, or use
|
|
7572
|
+
* `updateModifierGroup(..., { status: 'archived' })` to keep the row).
|
|
7573
|
+
* Requires Admin mode (apiKey).
|
|
7574
|
+
*/
|
|
7575
|
+
deleteModifierGroup(storeId: string, groupId: string): Promise<void>;
|
|
7576
|
+
/**
|
|
7577
|
+
* Create a modifier inside a group (e.g., "Olives" inside the "Toppings" group).
|
|
7578
|
+
* Requires Admin mode (apiKey).
|
|
7579
|
+
*
|
|
7580
|
+
* `priceDelta` is a decimal string. Negatives are accepted for downsell
|
|
7581
|
+
* modifiers (e.g., `"-2.00"` for "no bread"); the server still enforces
|
|
7582
|
+
* `unitPrice >= 0` at cart-line resolution and rejects negative deltas
|
|
7583
|
+
* combined with a `referencedProductId`.
|
|
7584
|
+
*
|
|
7585
|
+
* @example
|
|
7586
|
+
* ```typescript
|
|
7587
|
+
* const olives = await client.createModifier('store_123', 'mg_toppings', {
|
|
7588
|
+
* name: 'Olives',
|
|
7589
|
+
* priceDelta: '5.00',
|
|
7590
|
+
* isDefault: false,
|
|
7591
|
+
* available: true,
|
|
7592
|
+
* });
|
|
7593
|
+
* ```
|
|
7594
|
+
*/
|
|
7595
|
+
createModifier(storeId: string, groupId: string, data: CreateModifierInput): Promise<Modifier>;
|
|
7596
|
+
/**
|
|
7597
|
+
* Update a modifier. Pass `status: 'archived'` to soft-delete.
|
|
7598
|
+
* Requires Admin mode (apiKey).
|
|
7599
|
+
*/
|
|
7600
|
+
updateModifier(storeId: string, groupId: string, modifierId: string, data: UpdateModifierInput): Promise<Modifier>;
|
|
7601
|
+
/**
|
|
7602
|
+
* Hard-delete a modifier. Use `updateModifier(..., { status: 'archived' })`
|
|
7603
|
+
* if existing line items / order snapshots reference it.
|
|
7604
|
+
* Requires Admin mode (apiKey).
|
|
7605
|
+
*/
|
|
7606
|
+
deleteModifier(storeId: string, groupId: string, modifierId: string): Promise<void>;
|
|
7607
|
+
/**
|
|
7608
|
+
* Flip the sold-out toggle on a modifier. Operational endpoint kept separate
|
|
7609
|
+
* from `updateModifier` because the daily ops bar is intentionally lower
|
|
7610
|
+
* (PRD §7.1 — STAFF role once the granular `TOGGLE_MODIFIER_AVAILABILITY`
|
|
7611
|
+
* permission ships).
|
|
7612
|
+
* Requires Admin mode (apiKey).
|
|
7613
|
+
*
|
|
7614
|
+
* @example
|
|
7615
|
+
* ```typescript
|
|
7616
|
+
* // Mark the egg modifier as out of stock during a busy lunch service
|
|
7617
|
+
* await client.toggleModifierAvailability('store_123', 'mg_toppings', 'm_egg', false);
|
|
7618
|
+
* ```
|
|
7619
|
+
*/
|
|
7620
|
+
toggleModifierAvailability(storeId: string, groupId: string, modifierId: string, available: boolean): Promise<Modifier>;
|
|
7621
|
+
/**
|
|
7622
|
+
* Attach a modifier group to a product. Three patterns (PRD §5.4):
|
|
7623
|
+
*
|
|
7624
|
+
* - `variantId` omitted → default attach (applies to all variants).
|
|
7625
|
+
* - `variantId` set + matching default attach already exists → variant override row.
|
|
7626
|
+
* - `variantId` set + no default attach → variant-only group.
|
|
7627
|
+
*
|
|
7628
|
+
* Override fields use `null` to mean inherit; any non-null value (including
|
|
7629
|
+
* `0` or `false`) wins. The disable-for-variant convention is `maxOverride: 0` —
|
|
7630
|
+
* the resolver returns the group with `effectiveMax=0` and the validator
|
|
7631
|
+
* silently skips it on cart add.
|
|
7632
|
+
*
|
|
7633
|
+
* Requires Admin mode (apiKey).
|
|
7634
|
+
*/
|
|
7635
|
+
attachModifierGroup(storeId: string, productId: string, data: AttachModifierGroupInput): Promise<ProductModifierGroupAttachment>;
|
|
7636
|
+
/**
|
|
7637
|
+
* Update an existing attachment's overrides or position. The `modifierGroupId`
|
|
7638
|
+
* and `variantId` are immutable — to swap groups or move between default /
|
|
7639
|
+
* per-variant rows, detach and re-attach.
|
|
7640
|
+
* Requires Admin mode (apiKey).
|
|
7641
|
+
*/
|
|
7642
|
+
updateAttachment(storeId: string, productId: string, attachmentId: string, data: UpdateAttachmentInput): Promise<ProductModifierGroupAttachment>;
|
|
7643
|
+
/**
|
|
7644
|
+
* Detach a modifier group from a product (or remove a per-variant override row).
|
|
7645
|
+
* Requires Admin mode (apiKey).
|
|
7646
|
+
*/
|
|
7647
|
+
detachModifierGroup(storeId: string, productId: string, attachmentId: string): Promise<void>;
|
|
6781
7648
|
/**
|
|
6782
7649
|
* List all shipping zones for the store with pagination
|
|
6783
7650
|
* Requires Admin mode (apiKey)
|
|
@@ -6922,6 +7789,64 @@ declare class BrainerceClient {
|
|
|
6922
7789
|
* Requires Admin mode (apiKey)
|
|
6923
7790
|
*/
|
|
6924
7791
|
deleteMetafieldDefinition(definitionId: string): Promise<void>;
|
|
7792
|
+
/**
|
|
7793
|
+
* Replace the platform publishing configuration on a metafield definition.
|
|
7794
|
+
* `publishedOn` is the source of truth for which sales channels the field
|
|
7795
|
+
* appears on; `platformMetadata` carries the per-platform mapping config
|
|
7796
|
+
* required for sync.
|
|
7797
|
+
*
|
|
7798
|
+
* Requires Admin mode (apiKey).
|
|
7799
|
+
*
|
|
7800
|
+
* @example
|
|
7801
|
+
* ```typescript
|
|
7802
|
+
* await client.setMetafieldPlatforms('def_123', {
|
|
7803
|
+
* publishedOn: ['SHOPIFY', 'WOOCOMMERCE'],
|
|
7804
|
+
* platformMetadata: {
|
|
7805
|
+
* SHOPIFY: { namespace: 'custom', key: 'warranty' },
|
|
7806
|
+
* WOOCOMMERCE: { key: '_warranty_info' },
|
|
7807
|
+
* },
|
|
7808
|
+
* });
|
|
7809
|
+
* ```
|
|
7810
|
+
*/
|
|
7811
|
+
setMetafieldPlatforms(definitionId: string, data: SetMetafieldPlatformsDto): Promise<MetafieldDefinition>;
|
|
7812
|
+
/**
|
|
7813
|
+
* Publish a metafield definition to a vibe-coded site (admin mode).
|
|
7814
|
+
* @example
|
|
7815
|
+
* ```typescript
|
|
7816
|
+
* await client.publishMetafieldDefinitionToVibeCodedSite('def_123', 'conn_456');
|
|
7817
|
+
* ```
|
|
7818
|
+
*/
|
|
7819
|
+
publishMetafieldDefinitionToVibeCodedSite(definitionId: string, vibeCodedConnectionId: string): Promise<{
|
|
7820
|
+
success: boolean;
|
|
7821
|
+
}>;
|
|
7822
|
+
/** Unpublish a metafield definition from a vibe-coded site (admin mode). */
|
|
7823
|
+
unpublishMetafieldDefinitionFromVibeCodedSite(definitionId: string, vibeCodedConnectionId: string): Promise<{
|
|
7824
|
+
success: boolean;
|
|
7825
|
+
}>;
|
|
7826
|
+
/** Publish a category to a vibe-coded site (admin mode). */
|
|
7827
|
+
publishCategoryToVibeCodedSite(categoryId: string, vibeCodedConnectionId: string): Promise<{
|
|
7828
|
+
success: boolean;
|
|
7829
|
+
}>;
|
|
7830
|
+
/** Unpublish a category from a vibe-coded site (admin mode). */
|
|
7831
|
+
unpublishCategoryFromVibeCodedSite(categoryId: string, vibeCodedConnectionId: string): Promise<{
|
|
7832
|
+
success: boolean;
|
|
7833
|
+
}>;
|
|
7834
|
+
/** Publish a tag to a vibe-coded site (admin mode). */
|
|
7835
|
+
publishTagToVibeCodedSite(tagId: string, vibeCodedConnectionId: string): Promise<{
|
|
7836
|
+
success: boolean;
|
|
7837
|
+
}>;
|
|
7838
|
+
/** Unpublish a tag from a vibe-coded site (admin mode). */
|
|
7839
|
+
unpublishTagFromVibeCodedSite(tagId: string, vibeCodedConnectionId: string): Promise<{
|
|
7840
|
+
success: boolean;
|
|
7841
|
+
}>;
|
|
7842
|
+
/** Publish a brand to a vibe-coded site (admin mode). */
|
|
7843
|
+
publishBrandToVibeCodedSite(brandId: string, vibeCodedConnectionId: string): Promise<{
|
|
7844
|
+
success: boolean;
|
|
7845
|
+
}>;
|
|
7846
|
+
/** Unpublish a brand from a vibe-coded site (admin mode). */
|
|
7847
|
+
unpublishBrandFromVibeCodedSite(brandId: string, vibeCodedConnectionId: string): Promise<{
|
|
7848
|
+
success: boolean;
|
|
7849
|
+
}>;
|
|
6925
7850
|
/**
|
|
6926
7851
|
* Replace the list of products a (customer-input) metafield definition is
|
|
6927
7852
|
* attached to. Diff-scoped: only rows for this definition are touched, so
|
|
@@ -7331,4 +8256,33 @@ declare function enableDevGuards(options?: {
|
|
|
7331
8256
|
force?: boolean;
|
|
7332
8257
|
}): void;
|
|
7333
8258
|
|
|
7334
|
-
|
|
8259
|
+
interface PaymentUrlOptions {
|
|
8260
|
+
/**
|
|
8261
|
+
* Additional hostnames to allow (matches `host` exactly OR
|
|
8262
|
+
* `*.host`). Use for custom self-hosted payment providers.
|
|
8263
|
+
* Cannot remove entries from the platform default list.
|
|
8264
|
+
*/
|
|
8265
|
+
extraHosts?: readonly string[];
|
|
8266
|
+
/**
|
|
8267
|
+
* Allow `http://localhost` and `http://127.0.0.1` so a local dev
|
|
8268
|
+
* storefront can iframe a local backend embed proxy. Off by default —
|
|
8269
|
+
* callers running in a known dev context should pass `true` explicitly.
|
|
8270
|
+
*/
|
|
8271
|
+
allowLocalhost?: boolean;
|
|
8272
|
+
}
|
|
8273
|
+
/**
|
|
8274
|
+
* Validate that a URL points to a known payment-provider host (or
|
|
8275
|
+
* platform-hosted embed). Returns `false` for any malformed input,
|
|
8276
|
+
* non-https URL (except localhost when explicitly allowed), or unknown host.
|
|
8277
|
+
*/
|
|
8278
|
+
declare function isAllowedPaymentUrl(url: string, options?: PaymentUrlOptions): boolean;
|
|
8279
|
+
/**
|
|
8280
|
+
* Navigate the browser to a payment URL after validating it against the
|
|
8281
|
+
* allowlist. Throws synchronously on a disallowed URL so the caller can
|
|
8282
|
+
* surface a localized error instead of leaking the raw URL.
|
|
8283
|
+
*
|
|
8284
|
+
* No-op outside a browser environment.
|
|
8285
|
+
*/
|
|
8286
|
+
declare function safePaymentRedirect(url: string, options?: PaymentUrlOptions): void;
|
|
8287
|
+
|
|
8288
|
+
export { type AddToCartDto, type AppliedDiscount, type ApplyCouponDto, type AttachModifierGroupInput, type Attribute, type AttributeOption, type AttributeSource, type BrainerceApiError, BrainerceClient, type BrainerceClientOptions, BrainerceError, type Brand, type BulkInventoryResponse, type BulkSaveVariantsDto, type BulkSaveVariantsResponse, type BulkVariantInput, type Cart, type CartAppliedDiscount, type CartBundleOffer, type CartBundlesResponse, type CartIncludeOption, type CartIncludeOptions, type CartItem, type CartItemModifierLine, type CartNudge, type CartRecommendationsResponse, type CartStatus, type CartUpgradeSuggestion, type CartUpgradesResponse, type CartWithIncludes, type Category, type CategoryNode, type CategorySuggestion, type Checkout, type CheckoutAddress, type CheckoutBumpsResponse, type CheckoutCustomFieldDefinition, type CheckoutFieldPricing, type CheckoutFieldVisibility, type CheckoutLineItem, type CheckoutPrefillData, type CheckoutStatus, type CompleteCheckoutResponse, type CompleteDraftDto, type ConfigureOAuthProviderDto as ConfigureOAuthProviderInput, type ConflictStatus, type ConnectorPlatform, type ContactFormFieldType, type ContactFormFieldValidation, type ContactFormPublic, type ContactFormPublicField, type ContactFormSummary, type Coupon, type CouponCreateResponse, type CouponQueryParams, type CouponStatus, type CouponType, type CouponValidationWarning, type CreateAddressDto, type CreateAttributeDto as CreateAttributeInput, type CreateAttributeOptionDto as CreateAttributeOptionInput, type CreateBrandDto as CreateBrandInput, type CreateCategoryDto as CreateCategoryInput, type CreateCheckoutDto, type CreateCouponDto, type CreateCustomApiDto, type CreateCustomerDto, type CreateEmailTemplateDto as CreateEmailTemplateInput, type CreateGuestOrderDto, type CreateInquiryInput, type CreateInquiryResponse, type CreateMetafieldDefinitionDto as CreateMetafieldDefinitionInput, type CreateModifierGroupInput, type CreateModifierInput, type CreateOrderDto, type CreateProductDto, type CreateRefundDto, type CreateShippingRateDto as CreateShippingRateInput, type CreateShippingZoneDto as CreateShippingZoneInput, type CreateTagDto as CreateTagInput, type CreateTaxRateDto as CreateTaxRateInput, type CreateVariantDto, type CustomApiAuthType, type CustomApiConnectionStatus, type CustomApiCredentials, type CustomApiIntegration, type CustomApiSyncConfig, type CustomApiSyncDirection, type CustomApiTestResult, type Customer, type CustomerAddress, type CustomerAuthResponse, type CustomerOAuthProvider, type CustomerProfile, type CustomerQueryParams, type DeleteProductResponse, type DiscountBanner, type DiscountRuleType, type DownloadFile, type DraftLineItem, type EditInventoryDto, type EmailDomain, type EmailEventSettings, type EmailEventType, type EmailSettings, type EmailTemplate, type EmailTemplatePreview, type EmailTemplatesResponse, type EmailVerificationResponse, type ExtendReservationResponse, type FormatPriceOptions, type FreeAllocationPolicy, type FulfillOrderDto, type GuestCheckoutStartResponse, type GuestOrderResponse, type InsufficientStockError, type InventoryInfo, type InventoryReservationStrategy, type InventorySyncStatus, type InventoryTrackingMode, type InvitationStatus, type InviteMemberDto as InviteMemberInput, type InviteStoreMemberDto as InviteStoreMemberInput, type ListModifierGroupsParams, type LocalCart, type LocalCartItem, type LockedVariant, type MergeCartsDto, type MetafieldConflict, type MetafieldConflictResolution, type MetafieldDefinition, type MetafieldType, type Modifier, type ModifierGroup, type ModifierSelection, type ModifierSelectionType, type ModifierValidationCode, type ModifierValidationError, type OAuthAuthorizeResponse, type OAuthCallbackResponse, type OAuthConnection, type OAuthConnectionsResponse, type OAuthProviderConfig, type OAuthProviderType, type OAuthProvidersResponse, type Order, type OrderAddress, type OrderBump, type OrderCustomer, type OrderDownloadLink, type OrderItem, type OrderQueryParams, type OrderStatus, type OrderStatusChange, type PaginatedResponse, type PaymentClientSdk, type PaymentConfig, type PaymentIntent, type PaymentProvider, type PaymentProviderConfig, type PaymentProvidersConfig, type PaymentStatus, type PaymentUrlOptions, type PickupLocation, type PlatformCouponCapabilities, type PlatformMetafieldMetadata, type PreviewEmailTemplateDto as PreviewEmailTemplateInput, type Product, type ProductAttributeInput, type ProductAvailability, type ProductCustomizationField, type ProductDiscount, type ProductDiscountBadge, type ProductImage, type ProductMetafield, type ProductMetafieldValue, type ProductModifierGroupAttachment, type ProductQueryParams, type ProductRecommendation, type ProductRecommendationsResponse, type ProductRelationType, type ProductSuggestion, type ProductVariant, type PublicMetafieldDefinition, type PublishProductResponse, type RecommendationVariant, type ReconcileInventoryResponse, type Refund, type RefundLineItem, type RefundLineItemResponse, type RefundType, type RegisterCustomerDto, type ReservationInfo, type ResolveMetafieldConflictDto as ResolveMetafieldConflictInput, type ResolveSyncConflictDto as ResolveSyncConflictInput, SDK_VERSION, type SearchSuggestions, type SelectPickupLocationDto, type SelectShippingMethodDto, type SendInvoiceDto, type SessionCartRef, type SetBillingAddressDto, type SetCheckoutCustomFieldsDto, type SetCheckoutCustomerDto, type SetDefinitionProductsDto as SetDefinitionProductsInput, type SetMetafieldPlatformsDto as SetMetafieldPlatformsInput, type SetShippingAddressDto, type SetShippingAddressResponse, type ShippingDestinations, type ShippingLine, type ShippingRate, type ShippingRateConfig, type ShippingRateType, type ShippingZone, type ShippingZoneQueryParams, type StockAvailabilityRequest, type StockAvailabilityResponse, type StockAvailabilityResult, type StoreInfo, type StoreInvitation, type StoreInvitationDetails, type StoreMember, type StorePermission, type StoreRole, type StoreTeamResponse, type SyncConflict, type SyncConflictResolution, type SyncJob, type Tag, type TaxBreakdown, type TaxBreakdownItem, type TaxRate, type TaxonomyQueryParams, type TeamInvitation, type TeamInvitationsResponse, type TeamMember, type TeamMembersResponse, type TeamRole, type UpdateAddressDto, type UpdateAttachmentInput, type UpdateAttributeDto as UpdateAttributeInput, type UpdateAttributeOptionDto as UpdateAttributeOptionInput, type UpdateBrandDto as UpdateBrandInput, type UpdateCartItemDto, type UpdateCategoryDto as UpdateCategoryInput, type UpdateCouponDto, type UpdateCustomApiDto, type UpdateCustomerDto, type UpdateDraftDto, type UpdateEmailSettingsDto as UpdateEmailSettingsInput, type UpdateEmailTemplateDto as UpdateEmailTemplateInput, type UpdateInventoryDto, type UpdateMemberRoleDto as UpdateMemberRoleInput, type UpdateMetafieldDefinitionDto as UpdateMetafieldDefinitionInput, type UpdateModifierGroupInput, type UpdateModifierInput, type UpdateOAuthProviderDto as UpdateOAuthProviderInput, type UpdateOrderDto, type UpdateOrderShippingDto, type UpdateProductDto, type UpdateShippingRateDto as UpdateShippingRateInput, type UpdateShippingZoneDto as UpdateShippingZoneInput, type UpdateStoreMemberDto as UpdateStoreMemberInput, type UpdateTagDto as UpdateTagInput, type UpdateTaxRateDto as UpdateTaxRateInput, type UpdateVariantDto, type UpdateVariantInventoryDto, type UpsertProductMetafieldDto as UpsertProductMetafieldInput, type UserStore, type UserStorePermissions, type VariantInventoryResponse, type VariantPlatformOverlay, type VariantStatus, type WaitForOrderOptions, type WaitForOrderResult, type WebhookEvent, type WebhookEventType, createWebhookHandler, enableDevGuards, formatPrice, getCartItemImage, getCartItemName, getCartTotals, getDescriptionContent, formatPrice as getPriceDisplay, getProductCustomizationFields, getProductMetafield, getProductMetafieldValue, getProductMetafieldsByType, getProductPrice, getProductPriceInfo, getProductSwatches, getStockStatus, getVariantOptions, getVariantPrice, isAllowedPaymentUrl, isCouponApplicableToProduct, isHtmlDescription, isWebhookEventType, parseWebhookEvent, safePaymentRedirect, verifyWebhook };
|