feeef 0.12.3 → 0.12.5

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.
@@ -1,6 +1,6 @@
1
1
  import { EmbaddedCategory } from '../embadded/category.js';
2
2
  import { ShippingMethodEntity } from './shipping_method.js';
3
- import { GoogleSheetsColumn, StoreEntity } from './store.js';
3
+ import { GoogleSheetsColumn, PixelStatusRule, StoreEntity } from './store.js';
4
4
  import { CategoryEntity } from './category.js';
5
5
  export interface ProductEntity {
6
6
  id: string;
@@ -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;
@@ -65,9 +76,17 @@ export declare enum MetaPixelEvent {
65
76
  initiateCheckout = "InitiateCheckout"
66
77
  }
67
78
  export interface MetaPixelData {
79
+ /** When false, ignore product override and use store defaults. */
80
+ enabled?: boolean | null;
68
81
  ids: string[] | null;
69
82
  objective: MetaPixelEvent | null;
70
83
  draftObjective: MetaPixelEvent | null;
84
+ /**
85
+ * Optional product-level status transition rules (server CAPI).
86
+ * When non-empty on a single-product order, overrides store `statusRules`.
87
+ * Never exposed on public product JSON.
88
+ */
89
+ statusRules?: PixelStatusRule[] | null;
71
90
  }
72
91
  export declare enum TiktokPixelEvent {
73
92
  none = "none",
@@ -82,9 +101,17 @@ export declare enum TiktokPixelEvent {
82
101
  purchase = "Purchase"
83
102
  }
84
103
  export interface TiktokPixelData {
104
+ /** When false, ignore product override and use store defaults. */
105
+ enabled?: boolean | null;
85
106
  ids: string[] | null;
86
107
  objective: TiktokPixelEvent | null;
87
108
  draftObjective: TiktokPixelEvent | null;
109
+ /**
110
+ * Optional product-level status transition rules (server Events API).
111
+ * When non-empty on a single-product order, overrides store `statusRules`.
112
+ * Never exposed on public product JSON.
113
+ */
114
+ statusRules?: PixelStatusRule[] | null;
88
115
  }
89
116
  export interface GoogleAnalyticsData {
90
117
  }
@@ -215,6 +242,10 @@ export interface ProductCreateInput {
215
242
  stock?: number;
216
243
  variant?: ProductVariant;
217
244
  offers?: ProductOffer[];
245
+ /** See [ProductEntity.forceOffer]. */
246
+ forceOffer?: boolean | null;
247
+ /** See [ProductEntity.defaultOfferCode]. */
248
+ defaultOfferCode?: string | null;
218
249
  addons?: ProductAddon[];
219
250
  metadata?: Record<string, any>;
220
251
  status?: ProductStatus;
@@ -244,6 +275,10 @@ export interface ProductUpdateInput {
244
275
  stock?: number;
245
276
  variant?: ProductVariant;
246
277
  offers?: ProductOffer[];
278
+ /** See [ProductEntity.forceOffer]. */
279
+ forceOffer?: boolean | null;
280
+ /** See [ProductEntity.defaultOfferCode]. */
281
+ defaultOfferCode?: string | null;
247
282
  addons?: ProductAddon[];
248
283
  metadata?: Record<string, any>;
249
284
  status?: ProductStatus;
@@ -0,0 +1,27 @@
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
+ /**
5
+ * Returns [defaultOfferCode] only when it exists in [offers]; otherwise null.
6
+ * Use whenever persisting or applying a default so stale codes never leak.
7
+ */
8
+ export declare function syncDefaultOfferCode(offers: ProductOffer[] | null | undefined, defaultOfferCode: string | null | undefined): string | null;
9
+ /**
10
+ * Offer that should be preselected for a product (if any).
11
+ * Respects synced [defaultOfferCode] only — does not invent a "first offer".
12
+ */
13
+ export declare function resolveInitialProductOffer(product: ProductOfferPolicySource): ProductOffer | undefined;
14
+ /**
15
+ * True when the product requires an offer to remain selected (cannot deselect).
16
+ * Independent of whether a specific default code is set.
17
+ */
18
+ export declare function isProductOfferRequired(product: ProductOfferPolicySource): boolean;
19
+ /**
20
+ * True when offer selection is locked to the synced default code
21
+ * (`forceOffer` + valid `defaultOfferCode`). Customer cannot switch offers.
22
+ */
23
+ export declare function isProductOfferLocked(product: ProductOfferPolicySource): boolean;
24
+ /**
25
+ * Offer that must be applied when locked; otherwise undefined.
26
+ */
27
+ 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.3",
4
+ "version": "0.12.5",
5
5
  "main": "build/index.js",
6
6
  "type": "module",
7
7
  "files": [