@fire-spark/core 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,11 +1,16 @@
1
- import { AndConditions, CheckoutMode, CheckoutResolved, Condition, CustomerIdentifyInput, CustomerRegisterInput, CustomerUpdateInput, FulfillmentListInput, GroupDisplayType, KioskDeviceConfig, KioskDeviceOverrides, KioskHealthBatchInput, KioskHealthBatchResult, KioskHeartbeatInput, KioskHeartbeatResult, KioskRealtimeToken, MatchResult, MatchableRule, Menu, Menu as Menu$1, MenuLookup, MenuLookup as MenuLookup$1, ModifierControlType, ModifierGroup, OrConditions, Order as Order$1, Order as Order$2, OrderInsertInput, OrderLine, OrderListInput, OrderRedeem, OrderRedemptionStep, OrderReorderInput, OrderTotals, OrderUpdateInput, OrderValidateInput, OrderValidateOutput, PaymentIntentInput, PaymentMethod, PaymentProvider, PricingModifier, Product, Product as Product$1, Recommendation, RecurringDateCronResult, RecurringDateCronValues, RulesEngineOrderLine, RulesEngineParams, RulesEngineRuntime, Schedule, StoreListInput, StoreNearbyInput, StorefrontAvailability, StorefrontMenuScope, StorefrontMenuStreamOptions, StorefrontPaymentsListInput } from "@fire-spark/types";
1
+ import { AndConditions, CheckoutMode, CheckoutResolved, Condition, CustomerIdentifyInput, CustomerRegisterInput, CustomerUpdateInput, FulfillmentListInput, GroupDisplayType, KioskDeviceConfig, KioskDeviceOverrides, KioskHealthBatchInput, KioskHealthBatchResult, KioskHeartbeatInput, KioskHeartbeatResult, KioskRealtimeToken, MatchResult, MatchableRule, Menu, Menu as Menu$1, MenuLookup, MenuLookup as MenuLookup$1, ModifierControlType, ModifierGroup, OrConditions, Order as Order$1, Order as Order$2, OrderInsertInput, OrderLine, OrderListInput, OrderRedeem, OrderRedemptionStep, OrderReorderInput, OrderTotals, OrderUpdateInput, OrderValidateInput, OrderValidateOutput, PaymentIntentInput, PaymentMethod, PaymentProvider, PricingModifier, Product, Product as Product$1, Recommendation, RecurringDateCronResult, RecurringDateCronValues, RulesEngineOrderLine, RulesEngineParams, RulesEngineRuntime, Schedule, StoreGetInput, StoreListInput, StoreNearbyInput, StorefrontAvailability, StorefrontMenuScope, StorefrontMenuStreamOptions, StorefrontPaymentsListInput, Variant, VariantGroup } from "@fire-spark/types";
2
+ import { Big } from "big.js";
2
3
  //#region src/productCustomization/types.d.ts
3
4
  type SelectionStatus = "IDLE" | "INCOMPLETE" | "VALID" | "INVALID";
5
+ type StartingPriceCache = Map<string, Big>;
4
6
  type CustomizationPath = string;
5
7
  type QuantitiesByPath = Record<CustomizationPath, number>;
8
+ type SelectionsByPath = Record<CustomizationPath, VariantSelection>;
6
9
  interface Snapshot {
7
10
  productId: string;
8
11
  quantities: QuantitiesByPath;
12
+ /** Variant picks of modifiers whose product is a variant base. */
13
+ variants?: SelectionsByPath;
9
14
  }
10
15
  interface CreateSessionOptions {
11
16
  initial?: QuantitiesByPath;
@@ -50,12 +55,40 @@ interface ModifierCtx {
50
55
  status: SelectionStatus;
51
56
  data: Product;
52
57
  type: ModifierControlType;
58
+ /** Nested customization; for a variant base, the resolved variant (or the
59
+ * base while options are pending). */
53
60
  product: ProductCtx | null;
61
+ /** Variant questions when `data` is a variant base; empty otherwise. */
62
+ variants: VariantGroupCtx[];
63
+ /** Product that is ordered: `data`, the resolved variant, or null while a
64
+ * variant base still has unanswered options. */
65
+ resolved: Product | null;
54
66
  onChange: (quantity: number) => void;
55
67
  linePrice: number;
56
68
  }
69
+ /** Variant group id → chosen variant (option) id. */
70
+ type VariantSelection = Record<string, string>;
71
+ interface VariantOptionCtx {
72
+ path: CustomizationPath;
73
+ data: Variant;
74
+ selected: boolean;
75
+ disabled: boolean;
76
+ select: () => void;
77
+ }
78
+ interface VariantGroupCtx {
79
+ path: CustomizationPath;
80
+ data: VariantGroup;
81
+ selectedId: string | null;
82
+ status: SelectionStatus;
83
+ options: VariantOptionCtx[];
84
+ }
57
85
  interface CustomizationSession {
86
+ /** Resolved product; the base selector until every variant group is chosen. */
58
87
  root: ProductCtx;
88
+ /** Product carrying variant_group_ids, or null for plain products. */
89
+ base: Product | null;
90
+ /** Rendered before modifier groups; empty for plain products. */
91
+ variants: VariantGroupCtx[];
59
92
  subscribe: (listener: () => void) => () => void;
60
93
  snapshot: () => Snapshot;
61
94
  totalPrice: () => number;
@@ -100,10 +133,18 @@ declare const fromOrderLines: (root: OrderLine, lines: OrderLine[], lookup: Menu
100
133
  //#region src/productCustomization/menu.d.ts
101
134
  declare const indexMenu: (menu: Menu$1) => MenuLookup$1;
102
135
  //#endregion
136
+ //#region src/productCustomization/startingPrice.d.ts
137
+ /** Lowest unit price reachable while satisfying every required modifier.
138
+ * For a variant base, the cheapest of its variant products. */
139
+ declare const computeStartingPrice: (lookup: MenuLookup$1, product: Product$1, cache?: StartingPriceCache) => number;
140
+ //#endregion
103
141
  //#region src/productCustomization/toOrderLines.d.ts
104
142
  /** Flatten a customized product tree into priced OrderLine rows. */
105
143
  declare const toOrderLines: (root: ProductCtx, locale: string) => OrderLine[];
106
144
  //#endregion
145
+ //#region src/productCustomization/variants.d.ts
146
+ declare const isVariantBase: (product: Product$1) => boolean;
147
+ //#endregion
107
148
  //#region src/shared/baseUrl.d.ts
108
149
  declare const resolveBaseUrl: (baseUrl?: string) => string;
109
150
  //#endregion
@@ -2016,7 +2057,7 @@ declare const milestoneTrack: (workflow: TrackWorkflow) => MilestoneTrackItem[];
2016
2057
  declare const milestoneSteps: (workflow: TrackWorkflow, currentNodeIds: string[]) => MilestoneSteps | null;
2017
2058
  //#endregion
2018
2059
  //#region src/order/validate.d.ts
2019
- type OrderLineIssueCode = "PRODUCT_NOT_FOUND" | "HIDDEN" | "OUT_OF_STOCK" | "OUTSIDE_HOURS" | "MODIFIER_NOT_FOUND" | "MODIFIER_RULES_INVALID" | "PRICE_MISMATCH" | "TAX_MISMATCH" | "DISCOUNT_MISMATCH" | "QUANTITY_MISMATCH" | "QUANTITY_BELOW_MINIMUM" | "QUANTITY_ABOVE_MAXIMUM" | "STRUCTURE_MISMATCH" | "FEE_MISMATCH" | "REDEEM_EXPIRED" | "REDEMPTION_STEPS_MISMATCH";
2060
+ type OrderLineIssueCode = "PRODUCT_NOT_FOUND" | "HIDDEN" | "OUT_OF_STOCK" | "OUTSIDE_HOURS" | "MODIFIER_NOT_FOUND" | "MODIFIER_RULES_INVALID" | "VARIANT_BASE_NOT_ORDERABLE" | "VARIANT_NOT_OFFERED" | "PRICE_MISMATCH" | "TAX_MISMATCH" | "DISCOUNT_MISMATCH" | "QUANTITY_MISMATCH" | "QUANTITY_BELOW_MINIMUM" | "QUANTITY_ABOVE_MAXIMUM" | "STRUCTURE_MISMATCH" | "FEE_MISMATCH" | "REDEEM_EXPIRED" | "REDEMPTION_STEPS_MISMATCH";
2020
2061
  type OrderIssueCode = "NO_MENU" | "MENU_CLOSED" | "SCOPE_INACTIVE" | "TOTALS_MISMATCH" | "REDEEM_EXPIRED" | "REDEMPTION_STEPS_MISMATCH" | "REDEMPTION_MISMATCH" | "EMPTY_ORDER" | "ITEMS_BELOW_MINIMUM" | "ITEMS_ABOVE_MAXIMUM" | "TOTAL_BELOW_MINIMUM" | "TOTAL_ABOVE_MAXIMUM" | "REDEEMS_ABOVE_MAXIMUM" | "REDEEMS_TOTAL_ABOVE_MAXIMUM" | "SHIPPING_REQUIRED" | "BILLING_REQUIRED" | "SHIPPING_FIELD_REQUIRED" | "BILLING_FIELD_REQUIRED";
2021
2062
  type OrderLineIssue = {
2022
2063
  code: OrderLineIssueCode;
@@ -2734,6 +2775,7 @@ declare const listMenus: (scope?: StorefrontMenuScope, options?: ServiceHttpOpti
2734
2775
  price: number;
2735
2776
  anchor_price?: number | undefined;
2736
2777
  anchor_price_percentage?: number | undefined;
2778
+ starting_price?: number | null | undefined;
2737
2779
  modifiers: {
2738
2780
  modifier_group_id: string;
2739
2781
  default_quantity: number;
@@ -2752,6 +2794,11 @@ declare const listMenus: (scope?: StorefrontMenuScope, options?: ServiceHttpOpti
2752
2794
  anchor_price_percentage?: number | undefined;
2753
2795
  }[];
2754
2796
  modifier_group_ids: string[];
2797
+ variants: {
2798
+ product_id: string;
2799
+ variant_group_option_ids: string[];
2800
+ }[];
2801
+ variant_group_ids: string[];
2755
2802
  recommendations: {
2756
2803
  recommendation_id: string;
2757
2804
  default_quantity: number;
@@ -2839,6 +2886,22 @@ declare const listMenus: (scope?: StorefrontMenuScope, options?: ServiceHttpOpti
2839
2886
  charge_above_quantity?: number | null | undefined;
2840
2887
  metadata: Record<string, unknown>;
2841
2888
  }[];
2889
+ variant_groups: {
2890
+ id: string;
2891
+ title: Record<string, string>;
2892
+ description?: Record<string, string> | null | undefined;
2893
+ display_type?: "GRID" | "LIST" | null | undefined;
2894
+ variants: {
2895
+ id: string;
2896
+ name: Record<string, string>;
2897
+ description?: Record<string, string> | null | undefined;
2898
+ image_url?: string | null | undefined;
2899
+ image_origin_url?: string | null | undefined;
2900
+ product_ids: string[];
2901
+ metadata: Record<string, unknown>;
2902
+ }[];
2903
+ metadata: Record<string, unknown>;
2904
+ }[];
2842
2905
  recommendations: ({
2843
2906
  id: string;
2844
2907
  title: Record<string, string>;
@@ -2929,6 +2992,7 @@ declare const listMenusStream: (scope?: StorefrontMenuScope, options?: ListMenus
2929
2992
  price: number;
2930
2993
  anchor_price?: number | undefined;
2931
2994
  anchor_price_percentage?: number | undefined;
2995
+ starting_price?: number | null | undefined;
2932
2996
  modifiers: {
2933
2997
  modifier_group_id: string;
2934
2998
  default_quantity: number;
@@ -2947,6 +3011,11 @@ declare const listMenusStream: (scope?: StorefrontMenuScope, options?: ListMenus
2947
3011
  anchor_price_percentage?: number | undefined;
2948
3012
  }[];
2949
3013
  modifier_group_ids: string[];
3014
+ variants: {
3015
+ product_id: string;
3016
+ variant_group_option_ids: string[];
3017
+ }[];
3018
+ variant_group_ids: string[];
2950
3019
  recommendations: {
2951
3020
  recommendation_id: string;
2952
3021
  default_quantity: number;
@@ -3034,6 +3103,22 @@ declare const listMenusStream: (scope?: StorefrontMenuScope, options?: ListMenus
3034
3103
  charge_above_quantity?: number | null | undefined;
3035
3104
  metadata: Record<string, unknown>;
3036
3105
  }[];
3106
+ variant_groups: {
3107
+ id: string;
3108
+ title: Record<string, string>;
3109
+ description?: Record<string, string> | null | undefined;
3110
+ display_type?: "GRID" | "LIST" | null | undefined;
3111
+ variants: {
3112
+ id: string;
3113
+ name: Record<string, string>;
3114
+ description?: Record<string, string> | null | undefined;
3115
+ image_url?: string | null | undefined;
3116
+ image_origin_url?: string | null | undefined;
3117
+ product_ids: string[];
3118
+ metadata: Record<string, unknown>;
3119
+ }[];
3120
+ metadata: Record<string, unknown>;
3121
+ }[];
3037
3122
  recommendations: ({
3038
3123
  id: string;
3039
3124
  title: Record<string, string>;
@@ -3305,6 +3390,8 @@ declare const listStores: (input?: StoreListInput, options?: ServiceHttpOptions)
3305
3390
  temporary_closed_until?: string | null | undefined;
3306
3391
  status: "CLOSED" | "OPEN" | "TEMPORARILY_CLOSED";
3307
3392
  };
3393
+ channel_ids: string[];
3394
+ fulfillment_ids: string[];
3308
3395
  tags: Record<string, string | number | boolean>;
3309
3396
  cms_template_id?: string | null | undefined;
3310
3397
  status: string;
@@ -3399,6 +3486,8 @@ declare const listNearbyStores: (input: StoreNearbyInput, options?: ServiceHttpO
3399
3486
  temporary_closed_until?: string | null | undefined;
3400
3487
  status: "CLOSED" | "OPEN" | "TEMPORARILY_CLOSED";
3401
3488
  };
3489
+ channel_ids: string[];
3490
+ fulfillment_ids: string[];
3402
3491
  tags: Record<string, string | number | boolean>;
3403
3492
  cms_template_id?: string | null | undefined;
3404
3493
  status: string;
@@ -3454,7 +3543,7 @@ declare const listNearbyStores: (input: StoreNearbyInput, options?: ServiceHttpO
3454
3543
  } | null | undefined;
3455
3544
  labels: string[];
3456
3545
  }[]>;
3457
- declare const getStore: (id: string, options?: ServiceHttpOptions) => Promise<{
3546
+ declare const getStore: (id: string, input?: StoreGetInput, options?: ServiceHttpOptions) => Promise<{
3458
3547
  id: string;
3459
3548
  uid: string;
3460
3549
  merchant_id: string;
@@ -3493,6 +3582,8 @@ declare const getStore: (id: string, options?: ServiceHttpOptions) => Promise<{
3493
3582
  temporary_closed_until?: string | null | undefined;
3494
3583
  status: "CLOSED" | "OPEN" | "TEMPORARILY_CLOSED";
3495
3584
  };
3585
+ channel_ids: string[];
3586
+ fulfillment_ids: string[];
3496
3587
  tags: Record<string, string | number | boolean>;
3497
3588
  cms_template_id?: string | null | undefined;
3498
3589
  status: string;
@@ -3766,4 +3857,4 @@ declare const paymentMatchesClientConditions: (conditions: OrConditions | null |
3766
3857
  now?: string;
3767
3858
  }) => boolean;
3768
3859
  //#endregion
3769
- export { type ApplyRedeemInput, type AuthConfigureOptions, type CreateOrderOptions, type CreateSessionOptions, type CustomizationPath, type CustomizationSession, DEFAULT_RECOMMENDATION_TYPES, type ExchangeOptions, type FlatMenuCategory, type GroupDisplayType, type IdBuilder, type ListMenusStreamOptions, type Menu, type MenuCategoryNode, type MenuLookup, type MilestoneSteps, type MilestoneTrackItem, type ModifierControlType, type ModifierCtx, type ModifierGroupCtx, type NestedMenuCategory, Order, type OrderCustomerSource, type OrderDraft, type OrderIssue, type OrderIssueCode, type OrderLineDiff, type OrderLineIssue, type OrderLineIssueCode, type OrderScope, OrderSyncPendingError, OrderValidationError, type OrderValidationResult, type PricingModifier, type Product, type ProductCtx, type QuantitiesByPath, type RecommendationType, RecurringDateCron, type RemoveRedeemInput, type ReorderOrderOptions, type ResetOptions, RulesEngine, type ScheduleWindow, type SelectionStatus, type ServiceHttpOptions, type Snapshot, type StorefrontAccessToken, StorefrontHttpError, type TrackWorkflow, type ValidateOptions, type ValidateOrderAgainstMenuInput, type VisitedState, addLines, auth, buildCustomerSnapshot, collectOrderLineDiffs, countCartProducts, createSession, currentNodes, defaultConditionError, flattenMenuCategories, fromOrderLines, genId, genOrderId, getScheduleWindow, indexMenu, isCheckoutFieldFilled, isDeviceNotLinked, isKioskUnauthorized, isMilestoneStepDone, isOnSchedule, isOrderValidationError, isStorefrontNotFound, listMenusStream, matchAbsoluteDateOperator, matchBooleanOperator, matchCurrencyOperator, matchEnumOperator, matchNumberOperator, matchRecurringDateOperator, matchRelativeDateOperator, matchStringOperator, milestoneSteps, milestoneTrack, nestMenuCategories, paymentMatchesClientConditions, recomputeRedemptions, recomputeTotals, resolveCheckout, services, storefrontJson, toOrderLines, validateOrderAgainstMenu, visitedStates };
3860
+ export { type ApplyRedeemInput, type AuthConfigureOptions, type CreateOrderOptions, type CreateSessionOptions, type CustomizationPath, type CustomizationSession, DEFAULT_RECOMMENDATION_TYPES, type ExchangeOptions, type FlatMenuCategory, type GroupDisplayType, type IdBuilder, type ListMenusStreamOptions, type Menu, type MenuCategoryNode, type MenuLookup, type MilestoneSteps, type MilestoneTrackItem, type ModifierControlType, type ModifierCtx, type ModifierGroupCtx, type NestedMenuCategory, Order, type OrderCustomerSource, type OrderDraft, type OrderIssue, type OrderIssueCode, type OrderLineDiff, type OrderLineIssue, type OrderLineIssueCode, type OrderScope, OrderSyncPendingError, OrderValidationError, type OrderValidationResult, type PricingModifier, type Product, type ProductCtx, type QuantitiesByPath, type RecommendationType, RecurringDateCron, type RemoveRedeemInput, type ReorderOrderOptions, type ResetOptions, RulesEngine, type ScheduleWindow, type SelectionStatus, type SelectionsByPath, type ServiceHttpOptions, type Snapshot, type StorefrontAccessToken, StorefrontHttpError, type TrackWorkflow, type ValidateOptions, type ValidateOrderAgainstMenuInput, type Variant, type VariantGroup, type VariantGroupCtx, type VariantOptionCtx, type VariantSelection, type VisitedState, addLines, auth, buildCustomerSnapshot, collectOrderLineDiffs, computeStartingPrice, countCartProducts, createSession, currentNodes, defaultConditionError, flattenMenuCategories, fromOrderLines, genId, genOrderId, getScheduleWindow, indexMenu, isCheckoutFieldFilled, isDeviceNotLinked, isKioskUnauthorized, isMilestoneStepDone, isOnSchedule, isOrderValidationError, isStorefrontNotFound, isVariantBase, listMenusStream, matchAbsoluteDateOperator, matchBooleanOperator, matchCurrencyOperator, matchEnumOperator, matchNumberOperator, matchRecurringDateOperator, matchRelativeDateOperator, matchStringOperator, milestoneSteps, milestoneTrack, nestMenuCategories, paymentMatchesClientConditions, recomputeRedemptions, recomputeTotals, resolveCheckout, services, storefrontJson, toOrderLines, validateOrderAgainstMenu, visitedStates };