@rokt/dcui-orchestrator 1.2.1-rc.56 → 1.2.1-rc.57

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.
Files changed (22) hide show
  1. package/dist/index.cjs +30 -30
  2. package/dist/index.js +31 -31
  3. package/dist/libraries/module-connector/src/models/gateway.d.ts +5 -0
  4. package/dist/libraries/orchestrator/src/actions/global-offer-data-state.d.ts +11 -1
  5. package/dist/libraries/orchestrator/src/actions/index.d.ts +2 -0
  6. package/dist/libraries/orchestrator/src/actions/module.d.ts +9 -1
  7. package/dist/libraries/orchestrator/src/cart-listener-gateway.d.ts +7 -0
  8. package/dist/libraries/orchestrator/src/models/state/global-offer-data-state.d.ts +6 -0
  9. package/dist/libraries/orchestrator/src/models/state/module.d.ts +1 -0
  10. package/dist/libraries/orchestrator/src/sagas/partner-cart-sync/sagas.d.ts +2 -2
  11. package/dist/libraries/orchestrator/src/selectors/global-offer-data-state/selectors.d.ts +8 -1
  12. package/dist/libraries/saga-utils/src/utils/index.d.ts +1 -0
  13. package/dist/{modules/add-to-cart/src/utils/quantity-rules → libraries/saga-utils/src/utils}/quantity-rules.d.ts +11 -1
  14. package/dist/modules/add-to-cart/src/actions/cart.d.ts +7 -1
  15. package/dist/modules/add-to-cart/src/reducers/cart/reducer.d.ts +2 -1
  16. package/dist/modules/add-to-cart/src/sagas/index.d.ts +1 -1
  17. package/dist/modules/add-to-cart/src/sagas/update-cart-item/sagas.d.ts +4 -2
  18. package/dist/modules/add-to-cart/src/selectors/cart/selectors.d.ts +7 -8
  19. package/dist/modules/add-to-cart/src/selectors/catalogItems/selectors.d.ts +8 -0
  20. package/package.json +1 -1
  21. package/dist/modules/add-to-cart/src/utils/index.d.ts +0 -1
  22. package/dist/modules/add-to-cart/src/utils/quantity-rules/index.d.ts +0 -1
@@ -21,6 +21,11 @@ export type ModuleEventListener = {
21
21
  callback: (...data: Array<unknown>) => void;
22
22
  };
23
23
  export interface IGateway<State extends object, Action extends object> {
24
+ /** Latest authoritative cart for this offer during the subscription handoff. */
25
+ getOfferCart?: () => Array<{
26
+ cartItemId: string;
27
+ quantity: number;
28
+ }>;
24
29
  onEvent(...moduleEventListeners: Array<ModuleEventListener>): () => void;
25
30
  onGlobalStateChange(callback: (globalState: State) => void): () => void;
26
31
  onInteractivityChange(callback: (interactivity: Interactivity) => void): () => void;
@@ -1,4 +1,5 @@
1
1
  export declare const SET_GLOBAL_OFFER_DATA_CART = "GLOBAL_OFFER_DATA_STATE/SET_CART";
2
+ export declare const RETAIN_PARTNER_CART_ITEM = "GLOBAL_OFFER_DATA_STATE/RETAIN_PARTNER_CART_ITEM";
2
3
  export interface SetGlobalOfferDataCart {
3
4
  type: typeof SET_GLOBAL_OFFER_DATA_CART;
4
5
  payload: SetGlobalOfferDataCartPayload;
@@ -10,4 +11,13 @@ export interface SetGlobalOfferDataCartPayload {
10
11
  quantity: number;
11
12
  }>;
12
13
  }
13
- export type GlobalOfferDataStateActions = SetGlobalOfferDataCart;
14
+ export interface RetainPartnerCartItem {
15
+ type: typeof RETAIN_PARTNER_CART_ITEM;
16
+ payload: RetainPartnerCartItemPayload;
17
+ }
18
+ export interface RetainPartnerCartItemPayload {
19
+ offerPositionIndex: number;
20
+ cartItemId: string;
21
+ quantity: number;
22
+ }
23
+ export type GlobalOfferDataStateActions = SetGlobalOfferDataCart | RetainPartnerCartItem;
@@ -29,8 +29,10 @@ export declare const stateActionTypes: {
29
29
  readonly UPDATE_GROUP_SIZE: "PROGRESSION/UPDATE_GROUP_SIZE";
30
30
  readonly SET_SLOTS: "SLOTS/SET";
31
31
  readonly ADD_LOADED_MODULE: "MODULE/ADD_LOADED";
32
+ readonly UPDATE_CART_LISTENER_COUNT: "MODULE/UPDATE_CART_LISTENER_COUNT";
32
33
  readonly SET_DOMAIN_STATE: "DOMAIN_STATES/SET";
33
34
  readonly SET_GLOBAL_OFFER_DATA_CART: "GLOBAL_OFFER_DATA_STATE/SET_CART";
35
+ readonly RETAIN_PARTNER_CART_ITEM: "GLOBAL_OFFER_DATA_STATE/RETAIN_PARTNER_CART_ITEM";
34
36
  readonly LAYOUT_UPDATE: "LAYOUT/UPDATE";
35
37
  readonly UPDATE_ACTIVE_BREAKPOINT: "BREAKPOINT/UPDATE_ACTIVE";
36
38
  readonly INITIALISE_BREAKPOINT: "BREAKPOINT/INITIALISE";
@@ -3,7 +3,15 @@ export type AddLoadedModuleAction = {
3
3
  type: typeof ADD_LOADED_MODULE;
4
4
  payload: string;
5
5
  };
6
- export type ModuleActions = AddLoadedModuleAction;
6
+ export declare const UPDATE_CART_LISTENER_COUNT = "MODULE/UPDATE_CART_LISTENER_COUNT";
7
+ export type UpdateCartListenerCount = {
8
+ type: typeof UPDATE_CART_LISTENER_COUNT;
9
+ payload: {
10
+ offerPositionIndex: number;
11
+ delta: 1 | -1;
12
+ };
13
+ };
14
+ export type ModuleActions = AddLoadedModuleAction | UpdateCartListenerCount;
7
15
  export declare const LOAD_MODULES = "MODULE/LOAD";
8
16
  export interface LoadModules {
9
17
  type: typeof LOAD_MODULES;
@@ -0,0 +1,7 @@
1
+ import { GlobalGatewayFactory } from '../../module-connector/src/main';
2
+ import { UpdateCartListenerCount } from './actions';
3
+ /** Track real subscriptions, which outlive DOM collapse, rather than visible slots. */
4
+ export declare function trackCartListeners(factory: GlobalGatewayFactory, dispatch: (action: UpdateCartListenerCount) => void, readCart?: (position: number) => Array<{
5
+ cartItemId: string;
6
+ quantity: number;
7
+ }>): GlobalGatewayFactory;
@@ -1,3 +1,9 @@
1
1
  export type GlobalOfferDataState = {
2
2
  [key: string]: unknown;
3
3
  };
4
+ export type OfferStateCartItem = {
5
+ cartItemId: string;
6
+ quantity: number;
7
+ };
8
+ export declare function offerStateKey(position: number): string;
9
+ export declare function readOfferStateCart(state: GlobalOfferDataState, position: number): Array<OfferStateCartItem>;
@@ -1,3 +1,4 @@
1
1
  export type ModuleState = {
2
2
  loadedModules: Array<string>;
3
+ cartListenerCounts: Record<number, number>;
3
4
  };
@@ -1,6 +1,6 @@
1
1
  import { CallEffect, ChannelTakeEffect, PutEffect, SelectEffect } from 'redux-saga/effects';
2
2
  import { Cart } from '@rokt/partner-integration';
3
3
  import { PartnerInteractionService } from '../../../../plugin-utils/src/index';
4
- import { SlotState } from '../../models';
5
- export declare function reconcilePartnerCartItem(message: Cart.V2.UpdateCartItemPartnerMessageBody): Generator<SelectEffect | PutEffect, void, SlotState>;
4
+ import { AppState } from '../../models';
5
+ export declare function reconcilePartnerCartItem(message: Cart.V2.UpdateCartItemPartnerMessageBody): Generator<SelectEffect | PutEffect, void, AppState>;
6
6
  export declare function listenForPartnerCartItemSync(partner: PartnerInteractionService): Generator<ChannelTakeEffect<Cart.V2.UpdateCartItemPartnerMessageBody> | CallEffect | PutEffect, void, Cart.V2.UpdateCartItemPartnerMessageBody>;
@@ -1,7 +1,14 @@
1
- import { GlobalOfferDataState } from '../../models';
1
+ import { GlobalOfferDataState, OfferStateCartItem } from '../../models';
2
2
  export declare function getTotalCartQty(state: {
3
3
  globalOfferDataState: GlobalOfferDataState;
4
4
  }): number;
5
5
  export declare function getOfferState(state: {
6
6
  globalOfferDataState: GlobalOfferDataState;
7
7
  }, position: number): unknown;
8
+ /**
9
+ * The cart held for one position: what its module last published, with
10
+ * the partner updates retained while it was unmounted.
11
+ */
12
+ export declare function getOfferStateCart(state: {
13
+ globalOfferDataState: GlobalOfferDataState;
14
+ }, position: number): Array<OfferStateCartItem>;
@@ -1,4 +1,5 @@
1
1
  export * from './catalog-translator';
2
+ export * from './quantity-rules';
2
3
  export * from './stringify';
3
4
  export * from './take-in-sequence';
4
5
  export * from './take-one';
@@ -1,4 +1,4 @@
1
- import { PluginCatalogItem } from '../../../../../libraries/domain/src/models';
1
+ import { PluginCatalogItem } from '../../../domain/src/models';
2
2
  /**
3
3
  * The keys under which the transport emits the quantity rules on a catalog
4
4
  * item's `copy` map, each mapped to the name the plugin uses for it. The
@@ -133,6 +133,16 @@ export declare function getOfferCap(caps: Pick<CapInputs, 'offerCap' | 'offerLim
133
133
  * there.
134
134
  */
135
135
  export declare function getApplicableCap(rules: QuantityRules, caps: CapInputs): number;
136
+ /**
137
+ * The cap the ordinary update keeps for an item's quantity: the smaller of
138
+ * the applicable cap (getApplicableCap) and the item's existing per-item cap,
139
+ * which the ordinary update keeps for an exact item too (the exact path
140
+ * alone bypasses it). A quantity at or below it can be held, and an increase
141
+ * above it is refused, wherever a partner update is applied to a cart: the
142
+ * module's own update and the hold the orchestrator keeps for a module that
143
+ * is not mounted read this one cap, so the two never disagree on a quantity.
144
+ */
145
+ export declare function getUpdateCap(rules: QuantityRules, caps: CapInputs): number;
136
146
  /**
137
147
  * The correction applied to a typed quantity when it is committed and to an
138
148
  * existing quantity on the first render. Zero and anything that is not a
@@ -1,4 +1,5 @@
1
1
  import { PluginCatalogItem } from '../../../../libraries/domain/src/models';
2
+ import { CartState } from '../models';
2
3
  export type UpdateCartPayload = {
3
4
  catalogItem: PluginCatalogItem;
4
5
  quantity: number;
@@ -8,4 +9,9 @@ export type UpdateCart = {
8
9
  type: typeof UPDATE_CART;
9
10
  payload: UpdateCartPayload;
10
11
  };
11
- export type CartActions = UpdateCart;
12
+ export declare const HYDRATE_RETAINED_CART = "CART/HYDRATE_RETAINED";
13
+ export type HydrateRetainedCart = {
14
+ type: typeof HYDRATE_RETAINED_CART;
15
+ payload: CartState;
16
+ };
17
+ export type CartActions = UpdateCart | HydrateRetainedCart;
@@ -1,4 +1,5 @@
1
1
  import { AnyAction } from '@reduxjs/toolkit';
2
2
  import { CartState, AppSettingsCartItemState } from '../../models';
3
- export declare function makeInitialCartState(cart: Array<AppSettingsCartItemState>): CartState;
3
+ import { PluginCatalogItem } from '../../../../../libraries/domain/src/models';
4
+ export declare function makeInitialCartState(cart: Array<AppSettingsCartItemState>, catalogItems?: Array<PluginCatalogItem>): CartState;
4
5
  export declare function cartReducer(state: CartState | undefined, action: AnyAction): CartState;
@@ -27,4 +27,4 @@ export declare const sagaActionTypes: {
27
27
  readonly VALIDATE_FORM_FIELDS: "GLOBAL/VALIDATE_FORM_FIELDS";
28
28
  readonly REPORT_ERROR: "ERROR/REPORT";
29
29
  };
30
- export declare function appSagas(gateway: GlobalGateway, logger: (log: Log) => void): Generator<import("redux-saga/effects").AllEffect<import("redux-saga/effects").ForkEffect<void>>, void, unknown>;
30
+ export declare function appSagas(gateway: GlobalGateway, logger: (log: Log) => void): Generator<import("redux-saga/effects").CallEffect<void> | import("redux-saga/effects").ForkEffect<never> | import("redux-saga/effects").AllEffect<import("redux-saga/effects").ForkEffect<void>>, void, unknown>;
@@ -1,4 +1,5 @@
1
- import { CallEffect, CancelledEffect, ChannelTakeEffect, PutEffect, SelectEffect, TakeEffect } from 'redux-saga/effects';
1
+ import { EventChannel } from 'redux-saga';
2
+ import { CallEffect, ChannelTakeEffect, PutEffect, SelectEffect, TakeEffect, FlushEffect, ForkEffect } from 'redux-saga/effects';
2
3
  import { GlobalActions } from '../../../../../libraries/domain/src/behaviors';
3
4
  import { Log, PluginCartItem, PluginCatalogItem } from '../../../../../libraries/domain/src/models';
4
5
  import { GlobalGateway } from '../../../../../libraries/module-connector/src/main';
@@ -7,5 +8,6 @@ import { CatalogItemExactResponse, CatalogItemResponse } from '../../actions';
7
8
  export declare function processPreselectedCatalogItems(logger: (log: Log) => void): Generator<SelectEffect | CallEffect | PutEffect, void, PluginCartItem | null | undefined>;
8
9
  export declare function processUpdateCartItem(gateway: GlobalGateway, logger: (log: Log) => void, action: CatalogItemResponse): Generator<SelectEffect | CallEffect | PutEffect, void, undefined | GlobalActions | string>;
9
10
  export declare function processSetExactCartItem(gateway: GlobalGateway, logger: (log: Log) => void, action: CatalogItemExactResponse): Generator<SelectEffect | CallEffect | PutEffect, void, unknown>;
10
- export declare function listenForUpdateCartItemPartnerMessage(gateway: GlobalGateway, logger: (log: Log) => void): Generator<TakeEffect | CallEffect | CancelledEffect | ChannelTakeEffect<Cart.V2.UpdateCartItemPartnerMessageBody>, void, Cart.V2.UpdateCartItemPartnerMessageBody>;
11
+ export declare function listenForUpdateCartItemPartnerMessage(gateway: GlobalGateway, logger: (log: Log) => void, preparedChannel?: EventChannel<Cart.V2.UpdateCartItemPartnerMessageBody>): Generator<TakeEffect | CallEffect | PutEffect | SelectEffect | ChannelTakeEffect<Cart.V2.UpdateCartItemPartnerMessageBody>, void, Cart.V2.UpdateCartItemPartnerMessageBody>;
12
+ export declare function initializePartnerCartSync(gateway: GlobalGateway, logger: (log: Log) => void): Generator<CallEffect | FlushEffect<Cart.V2.UpdateCartItemPartnerMessageBody> | ForkEffect, void, Array<Cart.V2.UpdateCartItemPartnerMessageBody>>;
11
13
  export declare function processPartnerUpdateCartItem(message: Cart.V2.UpdateCartItemPartnerMessageBody): Generator<SelectEffect | PutEffect, void, PluginCatalogItem | string | number | null | undefined>;
@@ -25,14 +25,13 @@ export declare function getOfferQuantityLimit(state: AppState, catalogItem?: Pic
25
25
  */
26
26
  export declare function getOfferTotalCap(state: AppState, catalogItem?: Pick<PluginCatalogItem, 'copy'>): number;
27
27
  /**
28
- * The quantity the ordinary update can still add to this item: the smaller
29
- * of the offer capacity left under the offer cap (getOfferTotalCap) and the
30
- * item's own cap less the quantity held. The own cap is the item's max,
31
- * where it sets one, beside its existing per-item cap (getItemCap). An item
32
- * with no max of its own keeps its existing cap alone, as before the rules.
33
- * An exact item's own rules do not cap it, so the ordinary update keeps its
34
- * existing cap alone for it, as before; the exact path bypasses that cap and
35
- * the offer capacity bounds it (getCartItemApplicableCap).
28
+ * The quantity the ordinary update can still add to this item: the cap the
29
+ * update keeps (getUpdateCap: the offer capacity left by the other items
30
+ * under the offer cap, the item's own cap and its existing per-item cap)
31
+ * less the quantity held. An exact item's own rules do not cap it, so the
32
+ * ordinary update keeps its existing cap alone for it, as before; the exact
33
+ * path bypasses that cap and the offer capacity bounds it
34
+ * (getCartItemApplicableCap).
36
35
  */
37
36
  export declare function getCartItemMaxAddableQuantity(state: AppState, catalogItem: PluginCatalogItem): number;
38
37
  /**
@@ -4,6 +4,14 @@ export declare function getCatalogItems(state: AppState): Array<PluginCatalogIte
4
4
  export declare function getCatalogItem(state: AppState, catalogItemId: string): PluginCatalogItem | null;
5
5
  export declare function getCatalogItemByCartItemId(state: AppState, cartItemId: string): PluginCatalogItem | null;
6
6
  export declare function getPreselectedCatalogItems(state: AppState): Array<PluginCatalogItem> | null;
7
+ /**
8
+ * The preselected catalog items the cart does not know yet. An id already in
9
+ * the cart, as an item or as a null, came from the orchestrator's copy of this
10
+ * position's cart at mount: what the module published before it was unmounted,
11
+ * or a partner update retained while it was. Both are newer than the payload,
12
+ * so the payload's preselection applies to the rest alone.
13
+ */
14
+ export declare function getPendingPreselectedCatalogItems(state: AppState): Array<PluginCatalogItem> | null;
7
15
  export declare function getTotalPreselectedQuantity(state: AppState): number;
8
16
  export declare function isCatalogItemForcedUpsell(state: AppState, catalogItemId: string): boolean;
9
17
  export declare function isDeliveryDetailsRequired(state: AppState, catalogItemId?: string): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rokt/dcui-orchestrator",
3
- "version": "1.2.1-rc.56",
3
+ "version": "1.2.1-rc.57",
4
4
  "description": "Rokt's DCUI rendering process",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",
@@ -1 +0,0 @@
1
- export * from './quantity-rules';
@@ -1 +0,0 @@
1
- export * from './quantity-rules';