feeef 0.12.4 → 0.12.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -29,6 +29,17 @@ export interface ProductEntity {
29
29
  dislikes: number;
30
30
  variant?: ProductVariant | null;
31
31
  offers?: ProductOffer[] | null;
32
+ /**
33
+ * When true, the customer must keep an offer selected.
34
+ * If [defaultOfferCode] also resolves to a valid offer, that offer is locked
35
+ * (cannot switch or deselect). Independent of [defaultOfferCode] being set.
36
+ */
37
+ forceOffer?: boolean | null;
38
+ /**
39
+ * Offer code to preselect on the storefront. Cleared (synced to null) when the
40
+ * code is missing from [offers] — callers should treat a stale code as unset.
41
+ */
42
+ defaultOfferCode?: string | null;
32
43
  metadata: Record<string, any>;
33
44
  status: ProductStatus;
34
45
  type: ProductType;
@@ -55,6 +66,19 @@ export interface IntegrationsData {
55
66
  googleTagsData?: GoogleTagData | null;
56
67
  googleSheetsData?: GoogleSheetsData | null;
57
68
  paymentMethodData?: PaymentMethodData | null;
69
+ /** Merchant-only Ecotrack warehouse stock mapping — never public. */
70
+ ecotrackData?: EcotrackData | null;
71
+ }
72
+ /**
73
+ * Per-product Ecotrack stock mapping.
74
+ * When `stock: 1`, Ecotrack `produit` must be the warehouse product reference.
75
+ */
76
+ export interface EcotrackData {
77
+ enabled?: boolean | null;
78
+ /** Default Ecotrack stock product reference. */
79
+ produit?: string | null;
80
+ /** Feeef inventory SKU → Ecotrack stock `produit` reference. */
81
+ skuProduitMap?: Record<string, string> | null;
58
82
  }
59
83
  export declare enum MetaPixelEvent {
60
84
  none = "none",
@@ -149,6 +173,8 @@ export interface ProductAddon {
149
173
  photoUrl?: string;
150
174
  title: string;
151
175
  subtitle?: string;
176
+ /** Inventory bucket SKU (scoped under product root when inventory is enabled). */
177
+ sku?: string | null;
152
178
  stock?: number;
153
179
  price?: number;
154
180
  min?: number;
@@ -231,6 +257,10 @@ export interface ProductCreateInput {
231
257
  stock?: number;
232
258
  variant?: ProductVariant;
233
259
  offers?: ProductOffer[];
260
+ /** See [ProductEntity.forceOffer]. */
261
+ forceOffer?: boolean | null;
262
+ /** See [ProductEntity.defaultOfferCode]. */
263
+ defaultOfferCode?: string | null;
234
264
  addons?: ProductAddon[];
235
265
  metadata?: Record<string, any>;
236
266
  status?: ProductStatus;
@@ -260,6 +290,10 @@ export interface ProductUpdateInput {
260
290
  stock?: number;
261
291
  variant?: ProductVariant;
262
292
  offers?: ProductOffer[];
293
+ /** See [ProductEntity.forceOffer]. */
294
+ forceOffer?: boolean | null;
295
+ /** See [ProductEntity.defaultOfferCode]. */
296
+ defaultOfferCode?: string | null;
263
297
  addons?: ProductAddon[];
264
298
  metadata?: Record<string, any>;
265
299
  status?: ProductStatus;
@@ -0,0 +1,31 @@
1
+ import type { ProductEntity, ProductOffer } from './product.js';
2
+ /** Minimal product shape needed to resolve default / forced offer policy. */
3
+ export type ProductOfferPolicySource = Pick<ProductEntity, 'offers' | 'forceOffer' | 'defaultOfferCode'> & {
4
+ /** Defensive: some payloads / caches may still emit snake_case. */
5
+ force_offer?: boolean | null;
6
+ default_offer_code?: string | null;
7
+ };
8
+ /**
9
+ * Returns [defaultOfferCode] only when it exists in [offers]; otherwise null.
10
+ * Use whenever persisting or applying a default so stale codes never leak.
11
+ */
12
+ export declare function syncDefaultOfferCode(offers: ProductOffer[] | null | undefined, defaultOfferCode: string | null | undefined): string | null;
13
+ /**
14
+ * Offer that should be preselected for a product (if any).
15
+ * Respects synced [defaultOfferCode] only — does not invent a "first offer".
16
+ */
17
+ export declare function resolveInitialProductOffer(product: ProductOfferPolicySource): ProductOffer | undefined;
18
+ /**
19
+ * True when the product requires an offer to remain selected (cannot deselect).
20
+ * Independent of whether a specific default code is set.
21
+ */
22
+ export declare function isProductOfferRequired(product: ProductOfferPolicySource): boolean;
23
+ /**
24
+ * True when offer selection is locked to the synced default code
25
+ * (`forceOffer` + valid `defaultOfferCode`). Customer cannot switch offers.
26
+ */
27
+ export declare function isProductOfferLocked(product: ProductOfferPolicySource): boolean;
28
+ /**
29
+ * Offer that must be applied when locked; otherwise undefined.
30
+ */
31
+ export declare function resolveForcedProductOffer(product: ProductOfferPolicySource): ProductOffer | undefined;
@@ -77,9 +77,17 @@ export declare class CartService extends NotifiableService {
77
77
  private findItemIndex;
78
78
  /**
79
79
  * Sets the current item to be managed in the cart.
80
+ * Applies product [defaultOfferCode] when the item has no offer yet, and
81
+ * re-applies a forced offer when [forceOffer] locks selection.
80
82
  * @param item - The item to be set as current.
81
83
  */
82
84
  setCurrentItem(item: CartItem, notify?: boolean): void;
85
+ /**
86
+ * Hydrates / locks offer from product policy without mutating unrelated fields.
87
+ * - Default: preselect when item has no offer
88
+ * - Forced+default: always keep the forced offer
89
+ */
90
+ private applyProductOfferPolicy;
83
91
  /**
84
92
  * Clamps the quantity to be within the offer's min/max range
85
93
  * @param offer - The offer containing quantity constraints
@@ -198,6 +206,11 @@ export declare class CartService extends NotifiableService {
198
206
  * @param offer - The offer to apply, or undefined to remove the offer
199
207
  */
200
208
  updateCurrentItemOffer(offer?: ProductOffer): void;
209
+ /**
210
+ * Enforces product offer policy for a requested offer change.
211
+ * Returns `'blocked'` when the change is not allowed.
212
+ */
213
+ private resolveOfferUpdate;
201
214
  /**
202
215
  * Sets the shipping method.
203
216
  * @param method - Either a store or a shipping method.
@@ -5,6 +5,7 @@ export * from './delivery/delivery_carrier_client.js';
5
5
  export * from './core/entities/order.js';
6
6
  export * from './core/entities/store.js';
7
7
  export * from './core/entities/product.js';
8
+ export * from './core/entities/product_offer_policy.js';
8
9
  export * from './core/entities/product_landing_page.js';
9
10
  export * from './core/entities/product_landing_page_template.js';
10
11
  export * from './core/entities/attachment.js';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "feeef",
3
3
  "description": "feeef sdk for javascript",
4
- "version": "0.12.4",
4
+ "version": "0.12.6",
5
5
  "main": "build/index.js",
6
6
  "type": "module",
7
7
  "files": [