@fire-spark/core 0.20.0 → 0.21.0
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 +79 -5
- package/dist/index.js +238 -66
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Money, PaymentAdapter, PaymentCollectAt, PaymentContext, PaymentResult, PaymentReversal, PaymentStorage, PaymentUI, RedeemLike, RedeemSource, isRealPaymentMethod, orderRedeems } from "@fire-spark/payments";
|
|
2
|
-
import { AndConditions, CheckoutMode, CheckoutResolved, CmsBlock, Condition, Customer, CustomerIdentifyInput, CustomerRegisterInput, CustomerUpdateInput, Fulfillment, FulfillmentListInput, GroupDisplayType, KioskDeviceConfig, KioskDeviceConfigInput, KioskDeviceOverrides, KioskHealthBatchInput, KioskHealthBatchResult, KioskHeartbeatInput, KioskHeartbeatResult, KioskPickupNameRules, KioskRealtimeToken, MasivoTotpCode, MasivoTotpCreateInput, MasivoTotpVerification, MasivoTotpVerifyInput, MatchResult, MatchableRule, Menu, Menu as Menu$1, MenuLookup, MenuLookup as MenuLookup$1, MerchantPayment, ModifierControlType, ModifierGroup, OrConditions, Order as Order$1, Order as Order$2, OrderCancelInput, OrderCancelInput as OrderCancelInput$1, OrderCancelType, OrderCancelType as OrderCancelType$1, OrderDeviceListInput, OrderDeviceListResult, OrderFulfillment, OrderInsertInput, OrderLine, OrderListInput, OrderRecordPaymentInput, OrderRedeem, OrderRedemptionStep, OrderReorderInput, OrderSetCustomerInput, OrderTotals, OrderUpdateInput, OrderValidateInput, OrderValidateOutput, PaymentCollectAt as PaymentCollectAt$1, PaymentIntentPutInput, PaymentMethod, PaymentProvider, PaymentTender, PaymentTenderInput, PlaceOrderResult, PosCatalog, PosFloorInput, PosFloorOccupancy, PosFloorPlan, PosFloorRealtimeToken, PosHealthBatchInput, PosHealthBatchResult, PosHeartbeatInput, PosHeartbeatResult, PosKioskOrder, PosKioskSettleInput, PosKioskSettleResult, PosOrderInput, PosOrderResult, PosTableAttachOrderInput, PosTableCloseInput, PosTableJoinInput, PosTableSeatInput, PosTableSeatReservationInput, PosTableSplitInput, PricingModifier, Product, Product as Product$1, Recommendation, RecurringDateCronResult, RecurringDateCronValues, RulesEngineOrder, RulesEngineOrderLine, RulesEngineParams, RulesEngineRuntime, Schedule, SdkLogContext, SdkLogErrorInfo, SdkLogLevel, SdkLogOptions, Store, StoreGetInput, StoreListInput, StoreNearbyInput, StorefrontAvailability, StorefrontMenu, StorefrontMenuScope, StorefrontMenuStreamOptions, StorefrontPaymentsListInput, StorefrontPreferences, SwitchCustomerArg, SwitchCustomerArg as SwitchCustomerArg$1, SwitchCustomerIdToken, SwitchCustomerResult, SwitchCustomerResult as SwitchCustomerResult$1, TenderRefundInput, TenderReplaceInput, TenderVoidInput, Variant, VariantGroup } from "@fire-spark/types";
|
|
2
|
+
import { AndConditions, CheckoutMode, CheckoutResolved, CmsBlock, Condition, Customer, CustomerIdentifyInput, CustomerRegisterInput, CustomerUpdateInput, Fulfillment, FulfillmentListInput, GroupDisplayType, KioskDeviceConfig, KioskDeviceConfigInput, KioskDeviceOverrides, KioskHealthBatchInput, KioskHealthBatchResult, KioskHeartbeatInput, KioskHeartbeatResult, KioskPickupNameRules, KioskRealtimeToken, MasivoTotpCode, MasivoTotpCreateInput, MasivoTotpVerification, MasivoTotpVerifyInput, MatchResult, MatchableRule, Menu, Menu as Menu$1, MenuLookup, MenuLookup as MenuLookup$1, MerchantPayment, ModifierControlType, ModifierGroup, OrConditions, Order as Order$1, Order as Order$2, OrderCancelInput, OrderCancelInput as OrderCancelInput$1, OrderCancelType, OrderCancelType as OrderCancelType$1, OrderDeviceListInput, OrderDeviceListResult, OrderFulfillment, OrderInsertInput, OrderLine, OrderListInput, OrderRecordPaymentInput, OrderRedeem, OrderRedemptionStep, OrderReorderInput, OrderSetCustomerInput, OrderTotals, OrderUpdateInput, OrderValidateInput, OrderValidateOutput, PaymentCollectAt as PaymentCollectAt$1, PaymentIntentPutInput, PaymentMethod, PaymentProvider, PaymentTender, PaymentTenderInput, PlaceOrderResult, PosCatalog, PosFloorInput, PosFloorOccupancy, PosFloorPlan, PosFloorRealtimeToken, PosHealthBatchInput, PosHealthBatchResult, PosHeartbeatInput, PosHeartbeatResult, PosKioskOrder, PosKioskSettleInput, PosKioskSettleResult, PosOrderInput, PosOrderResult, PosTableAttachOrderInput, PosTableCloseInput, PosTableJoinInput, PosTableSeatInput, PosTableSeatReservationInput, PosTableSplitInput, PricingModifier, Product, Product as Product$1, Recommendation, RecurringDateCronFormatter, RecurringDateCronResult, RecurringDateCronSummary, RecurringDateCronValues, RulesEngineOrder, RulesEngineOrderLine, RulesEngineParams, RulesEngineRuntime, Schedule, SdkLogContext, SdkLogErrorInfo, SdkLogLevel, SdkLogOptions, Store, StoreGetInput, StoreListInput, StoreNearbyInput, StorefrontAvailability, StorefrontMenu, StorefrontMenuScope, StorefrontMenuStreamOptions, StorefrontPaymentsListInput, StorefrontPreferences, SwitchCustomerArg, SwitchCustomerArg as SwitchCustomerArg$1, SwitchCustomerIdToken, SwitchCustomerResult, SwitchCustomerResult as SwitchCustomerResult$1, TenderRefundInput, TenderReplaceInput, TenderVoidInput, Variant, VariantGroup, WordFilterCheckInput, WordFilterCheckResult } from "@fire-spark/types";
|
|
3
3
|
import { Big } from "big.js";
|
|
4
4
|
//#region src/productCustomization/catalog.utils.d.ts
|
|
5
5
|
/** Image for a product inside one modifier group, else the product image. */
|
|
@@ -1194,11 +1194,37 @@ declare const setLineQuantity: (lines: OrderLine[], lineUid: string, quantity: n
|
|
|
1194
1194
|
/** Drop a root subtree, then add the replacement tree (may merge by fingerprint). */
|
|
1195
1195
|
declare const replaceLine: (lines: OrderLine[], lineUid: string, next: OrderLine | OrderLine[]) => OrderLine[];
|
|
1196
1196
|
//#endregion
|
|
1197
|
+
//#region src/order/placeCartLines.d.ts
|
|
1198
|
+
interface CartPlacement {
|
|
1199
|
+
/** Internal paths, including `/instance/N` for extra sibling lines. */
|
|
1200
|
+
paths: Record<string, number>;
|
|
1201
|
+
overCapacity: boolean;
|
|
1202
|
+
rulesBroken: boolean;
|
|
1203
|
+
lines: OrderLine[];
|
|
1204
|
+
}
|
|
1205
|
+
/** Place cart lines on menu slots and price them from the menu.
|
|
1206
|
+
* The tree is built from product id, parent, and quantity. A line's claimed
|
|
1207
|
+
* own price is read for one purpose: to rank which listed slots it may take
|
|
1208
|
+
* (see slotYieldsLine). The expected money is always the menu's for the
|
|
1209
|
+
* chosen slot, so a claim the menu cannot yield stays a mismatch.
|
|
1210
|
+
* A quantity above 1 stays one line. Extra sibling lines reuse a slot
|
|
1211
|
+
* only while its max still has room, at `/instance/2`, `/instance/3`, ….
|
|
1212
|
+
* Indices are assigned here. A forged index in the cart is not an input. */
|
|
1213
|
+
declare const placeCartLines: (root: OrderLine, lines: OrderLine[], lookup: MenuLookup$1, locale: string) => CartPlacement;
|
|
1214
|
+
//#endregion
|
|
1197
1215
|
//#region src/services/availability.d.ts
|
|
1198
1216
|
declare const getAvailability: (scope?: StorefrontMenuScope, options?: ServiceHttpOptions) => Promise<StorefrontAvailability>;
|
|
1199
1217
|
//#endregion
|
|
1200
1218
|
//#region src/services/cms.d.ts
|
|
1201
|
-
|
|
1219
|
+
/** Ids a block's visibility rules can match. A rule on an omitted id fails. */
|
|
1220
|
+
type CmsBlockScope = {
|
|
1221
|
+
store_id?: string;
|
|
1222
|
+
channel_id?: string;
|
|
1223
|
+
fulfillment_id?: string;
|
|
1224
|
+
brand_id?: string;
|
|
1225
|
+
};
|
|
1226
|
+
type GetCmsBlockOptions = ServiceHttpOptions & CmsBlockScope;
|
|
1227
|
+
declare const getCmsBlock: (name: string, options?: GetCmsBlockOptions) => Promise<CmsBlock>;
|
|
1202
1228
|
//#endregion
|
|
1203
1229
|
//#region src/services/customers.d.ts
|
|
1204
1230
|
declare const getCustomer: (id: string, options?: ServiceHttpOptions) => Promise<Customer>;
|
|
@@ -1418,6 +1444,9 @@ declare const listStores: (input?: StoreListInput, options?: ServiceHttpOptions)
|
|
|
1418
1444
|
declare const listNearbyStores: (input: StoreNearbyInput, options?: ServiceHttpOptions) => Promise<Store[]>;
|
|
1419
1445
|
declare const getStore: (id: string, input?: StoreGetInput, options?: ServiceHttpOptions) => Promise<Store>;
|
|
1420
1446
|
//#endregion
|
|
1447
|
+
//#region src/services/wordFilter.d.ts
|
|
1448
|
+
declare const checkWordFilter: (input: WordFilterCheckInput, options?: ServiceHttpOptions) => Promise<WordFilterCheckResult>;
|
|
1449
|
+
//#endregion
|
|
1421
1450
|
//#region src/services/index.d.ts
|
|
1422
1451
|
declare const services: {
|
|
1423
1452
|
preferences: {
|
|
@@ -1499,6 +1528,9 @@ declare const services: {
|
|
|
1499
1528
|
isDeviceNotLinked: typeof isDeviceNotLinked;
|
|
1500
1529
|
isKioskUnauthorized: typeof isKioskUnauthorized;
|
|
1501
1530
|
};
|
|
1531
|
+
wordFilter: {
|
|
1532
|
+
check: typeof checkWordFilter;
|
|
1533
|
+
};
|
|
1502
1534
|
pos: {
|
|
1503
1535
|
pair: typeof pairPosDevice;
|
|
1504
1536
|
relink: typeof relinkPosDevice;
|
|
@@ -1731,6 +1763,7 @@ declare class RulesEngine {
|
|
|
1731
1763
|
payment?: RulesEngineParams["payment"];
|
|
1732
1764
|
monitoring?: RulesEngineParams["monitoring"];
|
|
1733
1765
|
referenceDate?: string;
|
|
1766
|
+
timezone?: string;
|
|
1734
1767
|
runtime?: RulesEngineParams["runtime"];
|
|
1735
1768
|
constructor(params?: RulesEngineParams);
|
|
1736
1769
|
private getDependency;
|
|
@@ -1769,7 +1802,7 @@ declare const matchAbsoluteDateOperator: (condition: Condition, matcher: Date |
|
|
|
1769
1802
|
declare const matchRelativeDateOperator: (condition: Condition, matcher: string | undefined, referenceDate?: string) => boolean;
|
|
1770
1803
|
//#endregion
|
|
1771
1804
|
//#region src/rules/recurringDateMatcher.d.ts
|
|
1772
|
-
declare const matchRecurringDateOperator: (condition: Condition, matcher: string | undefined) => boolean;
|
|
1805
|
+
declare const matchRecurringDateOperator: (condition: Condition, matcher: string | undefined, timezone?: string) => boolean;
|
|
1773
1806
|
//#endregion
|
|
1774
1807
|
//#region src/rules/stringMatcher.d.ts
|
|
1775
1808
|
declare const matchStringOperator: (condition: Condition, matcher: string | undefined) => boolean;
|
|
@@ -1787,6 +1820,11 @@ declare const matchBooleanOperator: (condition: Condition, matcher: boolean | un
|
|
|
1787
1820
|
declare const matchEnumOperator: (condition: Condition, matcher: string | undefined) => boolean;
|
|
1788
1821
|
//#endregion
|
|
1789
1822
|
//#region src/rules/recurringDateCron.d.ts
|
|
1823
|
+
/**
|
|
1824
|
+
* Reads the calendar facts behind a recurring date (in `timezone`, or the
|
|
1825
|
+
* process zone when omitted) so any locale can write its own sentence.
|
|
1826
|
+
*/
|
|
1827
|
+
declare const summarizeRecurringDateCron: (values: RecurringDateCronValues, timezone?: string) => RecurringDateCronSummary;
|
|
1790
1828
|
declare class RecurringDateCron {
|
|
1791
1829
|
private startDate;
|
|
1792
1830
|
private endDate;
|
|
@@ -1795,11 +1833,23 @@ declare class RecurringDateCron {
|
|
|
1795
1833
|
constructor(values: RecurringDateCronValues, timezone?: string);
|
|
1796
1834
|
private day;
|
|
1797
1835
|
private getExpression;
|
|
1798
|
-
|
|
1836
|
+
get summary(): RecurringDateCronSummary;
|
|
1837
|
+
/**
|
|
1838
|
+
* Human sentence for this rule. Defaults to English (same text as
|
|
1839
|
+
* `result.description`); pass a formatter to localize it.
|
|
1840
|
+
*/
|
|
1841
|
+
describe: (format?: RecurringDateCronFormatter) => string;
|
|
1799
1842
|
get result(): RecurringDateCronResult;
|
|
1800
1843
|
match: (date: string) => boolean;
|
|
1801
1844
|
}
|
|
1802
1845
|
//#endregion
|
|
1846
|
+
//#region src/rules/recurringDateCronDescription.d.ts
|
|
1847
|
+
/**
|
|
1848
|
+
* English sentence used by `RecurringDateCron#result.description`, e.g.
|
|
1849
|
+
* "Weekly on Tuesdays from 15:00 to 19:00, starting on November 17th".
|
|
1850
|
+
*/
|
|
1851
|
+
declare const formatRecurringDateCronSummary: RecurringDateCronFormatter;
|
|
1852
|
+
//#endregion
|
|
1803
1853
|
//#region src/rules/checkout.d.ts
|
|
1804
1854
|
interface CheckoutRule extends MatchableRule {
|
|
1805
1855
|
fallback?: boolean;
|
|
@@ -1850,6 +1900,30 @@ declare const paymentMatchesClientConditions: (conditions: OrConditions | null |
|
|
|
1850
1900
|
now?: string;
|
|
1851
1901
|
}) => boolean;
|
|
1852
1902
|
//#endregion
|
|
1903
|
+
//#region src/rules/cmsVisibility.d.ts
|
|
1904
|
+
type CmsVisibilityRules = {
|
|
1905
|
+
conditions: OrConditions;
|
|
1906
|
+
};
|
|
1907
|
+
type CmsVisibilityBlock = CmsBlock & {
|
|
1908
|
+
visibility?: CmsVisibilityRules | null;
|
|
1909
|
+
};
|
|
1910
|
+
type CmsVisibilityContext = {
|
|
1911
|
+
now: Date;
|
|
1912
|
+
/** Resolved IANA zone. Only read when a Current date condition exists. */
|
|
1913
|
+
timezone: string | null;
|
|
1914
|
+
store_id: string | null;
|
|
1915
|
+
channel_id: string | null;
|
|
1916
|
+
fulfillment_id: string | null;
|
|
1917
|
+
brand_id: string | null;
|
|
1918
|
+
};
|
|
1919
|
+
/** True when evaluating the gate needs a timezone. */
|
|
1920
|
+
declare const cmsVisibilityNeedsTimezone: (visibility: CmsVisibilityRules | null | undefined) => boolean;
|
|
1921
|
+
/**
|
|
1922
|
+
* Storefront payload for one active block. A failed gate keeps the block's
|
|
1923
|
+
* identity and empties `items`. The rules never leave the server.
|
|
1924
|
+
*/
|
|
1925
|
+
declare const applyCmsVisibility: (block: CmsVisibilityBlock, ctx: CmsVisibilityContext) => CmsBlock;
|
|
1926
|
+
//#endregion
|
|
1853
1927
|
//#region src/card/card.types.d.ts
|
|
1854
1928
|
type CardBrand = "visa" | "mastercard" | "amex" | "diners" | "discover" | "jcb" | "unionpay" | "unknown";
|
|
1855
1929
|
/** Brands accepted by the customer `payments[].brand` contract. */
|
|
@@ -1930,4 +2004,4 @@ declare const normalizePickupName: (raw: string) => string;
|
|
|
1930
2004
|
/** `null` when the name is valid for the given rules. */
|
|
1931
2005
|
declare const validatePickupName: (raw: string, rules: KioskPickupNameRules) => PickupNameIssue | null;
|
|
1932
2006
|
//#endregion
|
|
1933
|
-
export { type ApplyRedeemInput, type AuthConfigureOptions, type BuildScheduleSlotsConfig, CARD_BRANDS, CUSTOMER_INFO_PLACEHOLDERS, type CardBrand, type CardBrandSpec, type CardCvcError, type CardExpiry, type CardExpiryError, type CardNumberError, type CardPreviewSlot, type CardholderNameError, type CreateOrderOptions, type CreateSessionOptions, type CustomizationPath, type CustomizationSession, DEFAULT_RECOMMENDATION_TYPES, DelegatedSessionExpiredError, type DeunaCallbackUrls, type DeunaOrderStatus, type ExchangeOptions, type FailedCharge, type FlatMenuCategory, type GenOrderIdOptions, type GroupDisplayType, ID_HASH_FORMATS, type IdBuilder, type IdHashFormat, type ListMenusStreamOptions, type ListPaymentsOptions, type Menu, type MenuCategoryNode, type MenuLookup, type MilestoneSteps, type MilestoneTrackItem, type ModifierControlType, type ModifierCtx, type ModifierGroupCtx, type NestedMenuCategory, Order, OrderAuthPinnedError, type OrderCancelInput, type OrderCancelOptions, type OrderCancelResult, type OrderCancelType, type OrderCustomerSource, type OrderDeviceCredential, type OrderDraft, type OrderIssue, type OrderIssueCode, type OrderLineDiff, type OrderLineIssue, type OrderLineIssueCode, OrderNotOpenError, OrderPaymentRequiredError, type OrderScope, OrderSyncPendingError, OrderSyncRejectedError, OrderValidationError, type OrderValidationResult, type PayIntentOptions, type PayIntentResult, type PayOptions, type PaymentCardBrand, type PaymentProgressEvent, type PaymentProgressListener, type PaymentRunOptions, type PaymentSessionOptions, PickupNameIssue, type PricingModifier, type Product, type ProductCtx, type QuantitiesByPath, type RecommendationType, RecurringDateCron, type RedeemPaymentRow, type RemoveRedeemInput, type ReorderOrderOptions, type ResetOptions, type ReversalOutcome, type ReverseAllOptions, RulesEngine, SCHEDULED_AT_ERROR_CODES, SCHEDULED_ORDER_MAX_HORIZON_HOURS, SCHEDULED_ORDER_MAX_HORIZON_MINUTES, SCHEDULED_ORDER_MIN_LEAD_MINUTES, SCHEDULED_ORDER_SLOT_MINUTES, type ScheduleSlot, type ScheduleSlotCart, type ScheduleSlotCartLine, type ScheduleWindow, type SelectionStatus, type SelectionsByPath, type SerializedError, type ServiceHttpOptions, type SimpleTenderPayment, type Snapshot, type StorefrontAccessToken, type StorefrontErrorDetails, StorefrontHttpError, type SwitchCustomerArg, type SwitchCustomerIdToken, type SwitchCustomerResult, type TrackWorkflow, type ValidateOptions, type ValidateOrderAgainstMenuInput, type Variant, type VariantGroup, type VariantGroupCtx, type VariantOptionCtx, type VariantSelection, type VerifyWebhookSignatureInput, type VisitedState, addLines, auth, buildCustomerSnapshot, buildScheduleSlots, cancelTypeOf, capRedeems, cappedRedeems, cardBrandSpec, cardDigits, cardNumberGaps, cardNumberMaxLength, cardPreviewGroups, caretAfterDigits, collectOrderLineDiffs, computeStartingPrice, countCartProducts, coveredAmount, createDeunaWidgetApi, createSession, currentNodes, cvcMaxLength, defaultConditionError, detectCardBrand, fitRedeems, flattenMenuCategories, flushLogs, formatCardNumber, formatCvc, formatExpiry, fromOrderLines, genId, genOrderId, getLogContext, getScheduleWindow, indexMenu, isCardNumberComplete, isCardNumberDefinitelyInvalid, isCheckoutFieldFilled, isCustomerInfoFieldFilled, isCustomerInfoPlaceholder, isCustomerInfoValueValid, isCvcComplete, isDelegatedSessionExpiredError, isDeviceCharged, isDeviceNotLinked, isExpiryComplete, isGenId, isKioskUnauthorized, isMilestoneStepDone, isOnSchedule, isOrderNotOpenError, isOrderPaymentRequiredError, isOrderValidationError, isPosDeviceNotLinked, isPosUnauthorized, isRealPaymentMethod, isScheduleSlot, isScheduledAtError, isStorefrontNotFound, isVariantBase, linePayableTotal, listMenusStream, localizePosError, log, logError, luhnCheck, matchAbsoluteDateOperator, matchBooleanOperator, matchCurrencyOperator, matchEnumOperator, matchNumberOperator, matchRecurringDateOperator, matchRelativeDateOperator, matchStringOperator, milestoneSteps, milestoneTrack, nestMenuCategories, normalizeCardholderName, normalizeCustomerPhone, normalizePickupName, orderPayableTotal, orderRedeemedTotal, orderRedeems, parseExpiry, paymentMatchesClientConditions, rebuildRootGroups, recomputeTotals, redeemedTotal, redeemsForPayment, redemptionCap, redemptionSteps, remainingAmount, removeLine, replaceLine, resolveCheckout, resolveModifierImageUrl, resolveSchedulePrepMinutes, reversePayment, runPaymentAttempt, scheduledInstant, selectablePayments, serializeError, services, setLineQuantity, storefrontJson, toOrderLines, toPaymentCardBrand, validateCardNumber, validateCardholderName, validateCvc, validateExpiry, validateOrderAgainstMenu, validatePickupName, verifyWebhookSignature, visitedStates };
|
|
2007
|
+
export { type ApplyRedeemInput, type AuthConfigureOptions, type BuildScheduleSlotsConfig, CARD_BRANDS, CUSTOMER_INFO_PLACEHOLDERS, type CardBrand, type CardBrandSpec, type CardCvcError, type CardExpiry, type CardExpiryError, type CardNumberError, type CardPreviewSlot, type CardholderNameError, type CmsBlockScope, type CmsVisibilityBlock, type CmsVisibilityContext, type CmsVisibilityRules, type CreateOrderOptions, type CreateSessionOptions, type CustomizationPath, type CustomizationSession, DEFAULT_RECOMMENDATION_TYPES, DelegatedSessionExpiredError, type DeunaCallbackUrls, type DeunaOrderStatus, type ExchangeOptions, type FailedCharge, type FlatMenuCategory, type GenOrderIdOptions, type GetCmsBlockOptions, type GroupDisplayType, ID_HASH_FORMATS, type IdBuilder, type IdHashFormat, type ListMenusStreamOptions, type ListPaymentsOptions, type Menu, type MenuCategoryNode, type MenuLookup, type MilestoneSteps, type MilestoneTrackItem, type ModifierControlType, type ModifierCtx, type ModifierGroupCtx, type NestedMenuCategory, Order, OrderAuthPinnedError, type OrderCancelInput, type OrderCancelOptions, type OrderCancelResult, type OrderCancelType, type OrderCustomerSource, type OrderDeviceCredential, type OrderDraft, type OrderIssue, type OrderIssueCode, type OrderLineDiff, type OrderLineIssue, type OrderLineIssueCode, OrderNotOpenError, OrderPaymentRequiredError, type OrderScope, OrderSyncPendingError, OrderSyncRejectedError, OrderValidationError, type OrderValidationResult, type PayIntentOptions, type PayIntentResult, type PayOptions, type PaymentCardBrand, type PaymentProgressEvent, type PaymentProgressListener, type PaymentRunOptions, type PaymentSessionOptions, PickupNameIssue, type PricingModifier, type Product, type ProductCtx, type QuantitiesByPath, type RecommendationType, RecurringDateCron, type RedeemPaymentRow, type RemoveRedeemInput, type ReorderOrderOptions, type ResetOptions, type ReversalOutcome, type ReverseAllOptions, RulesEngine, SCHEDULED_AT_ERROR_CODES, SCHEDULED_ORDER_MAX_HORIZON_HOURS, SCHEDULED_ORDER_MAX_HORIZON_MINUTES, SCHEDULED_ORDER_MIN_LEAD_MINUTES, SCHEDULED_ORDER_SLOT_MINUTES, type ScheduleSlot, type ScheduleSlotCart, type ScheduleSlotCartLine, type ScheduleWindow, type SelectionStatus, type SelectionsByPath, type SerializedError, type ServiceHttpOptions, type SimpleTenderPayment, type Snapshot, type StorefrontAccessToken, type StorefrontErrorDetails, StorefrontHttpError, type SwitchCustomerArg, type SwitchCustomerIdToken, type SwitchCustomerResult, type TrackWorkflow, type ValidateOptions, type ValidateOrderAgainstMenuInput, type Variant, type VariantGroup, type VariantGroupCtx, type VariantOptionCtx, type VariantSelection, type VerifyWebhookSignatureInput, type VisitedState, addLines, applyCmsVisibility, auth, buildCustomerSnapshot, buildScheduleSlots, cancelTypeOf, capRedeems, cappedRedeems, cardBrandSpec, cardDigits, cardNumberGaps, cardNumberMaxLength, cardPreviewGroups, caretAfterDigits, cmsVisibilityNeedsTimezone, collectOrderLineDiffs, computeStartingPrice, countCartProducts, coveredAmount, createDeunaWidgetApi, createSession, currentNodes, cvcMaxLength, defaultConditionError, detectCardBrand, fitRedeems, flattenMenuCategories, flushLogs, formatCardNumber, formatCvc, formatExpiry, formatRecurringDateCronSummary, fromOrderLines, genId, genOrderId, getLogContext, getScheduleWindow, indexMenu, isCardNumberComplete, isCardNumberDefinitelyInvalid, isCheckoutFieldFilled, isCustomerInfoFieldFilled, isCustomerInfoPlaceholder, isCustomerInfoValueValid, isCvcComplete, isDelegatedSessionExpiredError, isDeviceCharged, isDeviceNotLinked, isExpiryComplete, isGenId, isKioskUnauthorized, isMilestoneStepDone, isOnSchedule, isOrderNotOpenError, isOrderPaymentRequiredError, isOrderValidationError, isPosDeviceNotLinked, isPosUnauthorized, isRealPaymentMethod, isScheduleSlot, isScheduledAtError, isStorefrontNotFound, isVariantBase, linePayableTotal, listMenusStream, localizePosError, log, logError, luhnCheck, matchAbsoluteDateOperator, matchBooleanOperator, matchCurrencyOperator, matchEnumOperator, matchNumberOperator, matchRecurringDateOperator, matchRelativeDateOperator, matchStringOperator, milestoneSteps, milestoneTrack, nestMenuCategories, normalizeCardholderName, normalizeCustomerPhone, normalizePickupName, orderPayableTotal, orderRedeemedTotal, orderRedeems, parseExpiry, paymentMatchesClientConditions, placeCartLines, rebuildRootGroups, recomputeTotals, redeemedTotal, redeemsForPayment, redemptionCap, redemptionSteps, remainingAmount, removeLine, replaceLine, resolveCheckout, resolveModifierImageUrl, resolveSchedulePrepMinutes, reversePayment, runPaymentAttempt, scheduledInstant, selectablePayments, serializeError, services, setLineQuantity, storefrontJson, summarizeRecurringDateCron, toOrderLines, toPaymentCardBrand, validateCardNumber, validateCardholderName, validateCvc, validateExpiry, validateOrderAgainstMenu, validatePickupName, verifyWebhookSignature, visitedStates };
|
package/dist/index.js
CHANGED
|
@@ -2373,7 +2373,7 @@ const cleanId = (value) => {
|
|
|
2373
2373
|
if (!trimmed) return null;
|
|
2374
2374
|
return trimmed.slice(0, LOG_LIMITS.contextId);
|
|
2375
2375
|
};
|
|
2376
|
-
const SCOPE_KEYS = [
|
|
2376
|
+
const SCOPE_KEYS$1 = [
|
|
2377
2377
|
"channel_id",
|
|
2378
2378
|
"fulfillment_id",
|
|
2379
2379
|
"store_id",
|
|
@@ -2383,7 +2383,7 @@ const SCOPE_KEYS = [
|
|
|
2383
2383
|
const captureLogScope = (scope) => {
|
|
2384
2384
|
if (!scope) return;
|
|
2385
2385
|
const next = { ...context };
|
|
2386
|
-
for (const key of SCOPE_KEYS) {
|
|
2386
|
+
for (const key of SCOPE_KEYS$1) {
|
|
2387
2387
|
if (scope[key] === void 0) continue;
|
|
2388
2388
|
next[key] = cleanId(scope[key]);
|
|
2389
2389
|
}
|
|
@@ -2598,11 +2598,31 @@ const getAvailability = async (scope = {}, options) => {
|
|
|
2598
2598
|
};
|
|
2599
2599
|
//#endregion
|
|
2600
2600
|
//#region src/services/cms.ts
|
|
2601
|
-
const
|
|
2602
|
-
|
|
2601
|
+
const SCOPE_KEYS = [
|
|
2602
|
+
"store_id",
|
|
2603
|
+
"channel_id",
|
|
2604
|
+
"fulfillment_id",
|
|
2605
|
+
"brand_id"
|
|
2606
|
+
];
|
|
2607
|
+
const cmsBlockPath = (name, scope = {}) => {
|
|
2608
|
+
const path = `/api/storefront/v1/cms/blocks/${encodeURIComponent(name)}`;
|
|
2609
|
+
const params = new URLSearchParams();
|
|
2610
|
+
for (const key of SCOPE_KEYS) {
|
|
2611
|
+
const value = scope[key];
|
|
2612
|
+
if (value) params.set(key, value);
|
|
2613
|
+
}
|
|
2614
|
+
const query = params.toString();
|
|
2615
|
+
return query ? `${path}?${query}` : path;
|
|
2603
2616
|
};
|
|
2604
2617
|
const getCmsBlock = (name, options) => {
|
|
2605
|
-
|
|
2618
|
+
const { store_id, channel_id, ...rest } = options ?? {};
|
|
2619
|
+
const { fulfillment_id, brand_id, ...http } = rest;
|
|
2620
|
+
return storefrontJson(cmsBlockPath(name, {
|
|
2621
|
+
store_id,
|
|
2622
|
+
channel_id,
|
|
2623
|
+
fulfillment_id,
|
|
2624
|
+
brand_id
|
|
2625
|
+
}), {}, http);
|
|
2606
2626
|
};
|
|
2607
2627
|
//#endregion
|
|
2608
2628
|
//#region src/services/customers.ts
|
|
@@ -3505,6 +3525,14 @@ const getStore = (id, input = {}, options) => {
|
|
|
3505
3525
|
return storefrontJson(withQuery(storesPath(encodeURIComponent(id)), { ...input }), {}, options);
|
|
3506
3526
|
};
|
|
3507
3527
|
//#endregion
|
|
3528
|
+
//#region src/services/wordFilter.ts
|
|
3529
|
+
const checkWordFilter = (input, options) => {
|
|
3530
|
+
return storefrontJson("/api/storefront/v1/word-filter/check", {
|
|
3531
|
+
method: "POST",
|
|
3532
|
+
body: JSON.stringify({ text: input.text })
|
|
3533
|
+
}, options);
|
|
3534
|
+
};
|
|
3535
|
+
//#endregion
|
|
3508
3536
|
//#region src/services/index.ts
|
|
3509
3537
|
const services = {
|
|
3510
3538
|
preferences: { get: getPreferences },
|
|
@@ -3580,6 +3608,7 @@ const services = {
|
|
|
3580
3608
|
isDeviceNotLinked,
|
|
3581
3609
|
isKioskUnauthorized
|
|
3582
3610
|
},
|
|
3611
|
+
wordFilter: { check: checkWordFilter },
|
|
3583
3612
|
pos: {
|
|
3584
3613
|
pair: pairPosDevice,
|
|
3585
3614
|
relink: relinkPosDevice,
|
|
@@ -9491,6 +9520,84 @@ const windowMinutes = (condition) => {
|
|
|
9491
9520
|
return windowOf(condition);
|
|
9492
9521
|
};
|
|
9493
9522
|
//#endregion
|
|
9523
|
+
//#region src/rules/recurringDateCronDescription.ts
|
|
9524
|
+
const MONTHS = [
|
|
9525
|
+
"January",
|
|
9526
|
+
"February",
|
|
9527
|
+
"March",
|
|
9528
|
+
"April",
|
|
9529
|
+
"May",
|
|
9530
|
+
"June",
|
|
9531
|
+
"July",
|
|
9532
|
+
"August",
|
|
9533
|
+
"September",
|
|
9534
|
+
"October",
|
|
9535
|
+
"November",
|
|
9536
|
+
"December"
|
|
9537
|
+
];
|
|
9538
|
+
const WEEKDAYS$1 = [
|
|
9539
|
+
"Sunday",
|
|
9540
|
+
"Monday",
|
|
9541
|
+
"Tuesday",
|
|
9542
|
+
"Wednesday",
|
|
9543
|
+
"Thursday",
|
|
9544
|
+
"Friday",
|
|
9545
|
+
"Saturday"
|
|
9546
|
+
];
|
|
9547
|
+
const ordinal = (value) => {
|
|
9548
|
+
const lastTwo = value % 100;
|
|
9549
|
+
if (lastTwo >= 11 && lastTwo <= 13) return `${value}th`;
|
|
9550
|
+
const last = value % 10;
|
|
9551
|
+
if (last === 1) return `${value}st`;
|
|
9552
|
+
if (last === 2) return `${value}nd`;
|
|
9553
|
+
if (last === 3) return `${value}rd`;
|
|
9554
|
+
return `${value}th`;
|
|
9555
|
+
};
|
|
9556
|
+
const pad = (value) => String(value).padStart(2, "0");
|
|
9557
|
+
const formatDate = (parts) => {
|
|
9558
|
+
return `${MONTHS[parts.month - 1]} ${ordinal(parts.day)}`;
|
|
9559
|
+
};
|
|
9560
|
+
const formatTime = (parts) => {
|
|
9561
|
+
return `${pad(parts.hour)}:${pad(parts.minute)}`;
|
|
9562
|
+
};
|
|
9563
|
+
/**
|
|
9564
|
+
* English sentence used by `RecurringDateCron#result.description`, e.g.
|
|
9565
|
+
* "Weekly on Tuesdays from 15:00 to 19:00, starting on November 17th".
|
|
9566
|
+
*/
|
|
9567
|
+
const formatRecurringDateCronSummary = (summary) => {
|
|
9568
|
+
const { repeat, start, end, sameDay, allDay, weekOfMonth } = summary;
|
|
9569
|
+
const fromDate = formatDate(start);
|
|
9570
|
+
const toDate = formatDate(end);
|
|
9571
|
+
const fromTime = formatTime(start);
|
|
9572
|
+
const toTime = formatTime(end);
|
|
9573
|
+
const fromWeekday = WEEKDAYS$1[start.weekday];
|
|
9574
|
+
const toWeekday = WEEKDAYS$1[end.weekday];
|
|
9575
|
+
const fromDayOfMonth = ordinal(start.day);
|
|
9576
|
+
const toDayOfMonth = ordinal(end.day);
|
|
9577
|
+
const compoundFromToDate = `from ${fromDate} at ${fromTime} to ${toDate} at ${toTime}`;
|
|
9578
|
+
const singleFromToDate = `on ${fromDate} from ${fromTime} to ${toTime}`;
|
|
9579
|
+
let fromToDate = sameDay ? singleFromToDate : compoundFromToDate;
|
|
9580
|
+
if (allDay) fromToDate = `on ${fromDate}`;
|
|
9581
|
+
const fromToTime = allDay ? "" : ` from ${fromTime} to ${toTime}`;
|
|
9582
|
+
const weekdayRange = `${fromWeekday}s to ${toWeekday}s`;
|
|
9583
|
+
const dayOfWeek = sameDay ? `on ${fromWeekday}s` : weekdayRange;
|
|
9584
|
+
const dayOfMonthRange = `on the ${fromDayOfMonth} to ${toDayOfMonth}`;
|
|
9585
|
+
const dayOfMonth = sameDay ? `on the ${fromDayOfMonth}` : dayOfMonthRange;
|
|
9586
|
+
const startsOn = `, starting on ${fromDate}`;
|
|
9587
|
+
switch (repeat) {
|
|
9588
|
+
case "NONE": return `Once ${fromToDate}`;
|
|
9589
|
+
case "DAILY": return `Daily${fromToTime}${startsOn}`;
|
|
9590
|
+
case "WEEKDAYS": return `On weekdays${fromToTime}${startsOn}`;
|
|
9591
|
+
case "WEEKENDS": return `On weekends${fromToTime}${startsOn}`;
|
|
9592
|
+
case "WEEKLY": return `Weekly ${dayOfWeek}${fromToTime}${startsOn}`;
|
|
9593
|
+
case "FORTNIGHTLY": return `Fortnightly ${dayOfWeek}${fromToTime}${startsOn}`;
|
|
9594
|
+
case "MONTHLY": return `Monthly ${dayOfMonth}${fromToTime}${startsOn}`;
|
|
9595
|
+
case "LAST_DAY_OF_MONTH": return `Every Last day of the month${fromToTime}${startsOn}`;
|
|
9596
|
+
case "WEEK_OF_MONTH": return `Every ${ordinal(weekOfMonth)} ${fromWeekday} of the month${fromToTime}${startsOn}`;
|
|
9597
|
+
default: throw new Error(`Unsupported repeat value: ${repeat}`);
|
|
9598
|
+
}
|
|
9599
|
+
};
|
|
9600
|
+
//#endregion
|
|
9494
9601
|
//#region src/rules/recurringDateCron.ts
|
|
9495
9602
|
const ensureDayjsPlugin = (plugin, ready) => {
|
|
9496
9603
|
if (ready) return;
|
|
@@ -9510,6 +9617,40 @@ ensureDayjsPlugin(isBetween, hasBetween);
|
|
|
9510
9617
|
ensureDayjsPlugin(isSameOrAfter, hasSame);
|
|
9511
9618
|
ensureDayjsPlugin(weekOfYear, hasWeek);
|
|
9512
9619
|
ensureDayjsPlugin(advancedFormat, hasAdvanced);
|
|
9620
|
+
const toParts = (date) => {
|
|
9621
|
+
return {
|
|
9622
|
+
year: date.year(),
|
|
9623
|
+
month: date.month() + 1,
|
|
9624
|
+
day: date.date(),
|
|
9625
|
+
weekday: date.day(),
|
|
9626
|
+
hour: date.hour(),
|
|
9627
|
+
minute: date.minute()
|
|
9628
|
+
};
|
|
9629
|
+
};
|
|
9630
|
+
/**
|
|
9631
|
+
* Reads the calendar facts behind a recurring date (in `timezone`, or the
|
|
9632
|
+
* process zone when omitted) so any locale can write its own sentence.
|
|
9633
|
+
*/
|
|
9634
|
+
const summarizeRecurringDateCron = (values, timezone) => {
|
|
9635
|
+
const start = (0, import_dayjs_min.default)(values.startDate).tz(timezone);
|
|
9636
|
+
const end = (0, import_dayjs_min.default)(values.endDate).tz(timezone);
|
|
9637
|
+
const sameDay = start.isSame(end, "day");
|
|
9638
|
+
const isStartOfDay = start.isSame(start.clone().startOf("day"), "minutes");
|
|
9639
|
+
const isEndOfDay = end.isSame(end.clone().endOf("day"), "minutes");
|
|
9640
|
+
const allDay = isStartOfDay && isEndOfDay && sameDay;
|
|
9641
|
+
const startOfMonth = start.clone().startOf("month");
|
|
9642
|
+
const weeks = Math.ceil(Math.abs(start.diff(startOfMonth, "weeks", true)));
|
|
9643
|
+
const weekOfMonth = weeks >= 2 && weeks <= 5 ? weeks : 1;
|
|
9644
|
+
const { repeat } = values;
|
|
9645
|
+
return {
|
|
9646
|
+
repeat,
|
|
9647
|
+
start: toParts(start),
|
|
9648
|
+
end: toParts(end),
|
|
9649
|
+
sameDay,
|
|
9650
|
+
allDay,
|
|
9651
|
+
weekOfMonth
|
|
9652
|
+
};
|
|
9653
|
+
};
|
|
9513
9654
|
var RecurringDateCron = class {
|
|
9514
9655
|
startDate;
|
|
9515
9656
|
endDate;
|
|
@@ -9552,59 +9693,24 @@ var RecurringDateCron = class {
|
|
|
9552
9693
|
default: throw new Error(`Unsupported repeat value: ${this.repeat}`);
|
|
9553
9694
|
}
|
|
9554
9695
|
}
|
|
9555
|
-
|
|
9556
|
-
const
|
|
9557
|
-
|
|
9558
|
-
|
|
9559
|
-
|
|
9560
|
-
|
|
9561
|
-
|
|
9562
|
-
const toTime = end.format("HH:mm");
|
|
9563
|
-
const fromDayOfMonth = start.format("Do");
|
|
9564
|
-
const toDayOfMonth = end.format("Do");
|
|
9565
|
-
const isStartOfDay = start.isSame(start.clone().startOf("day"), "minutes");
|
|
9566
|
-
const isEndOfDay = end.isSame(end.clone().endOf("day"), "minutes");
|
|
9567
|
-
const isFullDay = isStartOfDay && isEndOfDay && isSameDay;
|
|
9568
|
-
assert(cron, "Invalid recurring date cron expression");
|
|
9569
|
-
const segments = cron.split(" ");
|
|
9570
|
-
const first = segments[0];
|
|
9571
|
-
const second = segments[1];
|
|
9572
|
-
assert(first && second, "Invalid recurring date cron expression");
|
|
9573
|
-
const compoundFromToDate = `from ${fromDate} at ${fromTime} to ${toDate} at ${toTime}`;
|
|
9574
|
-
const singleFromToDate = `on ${fromDate} from ${fromTime} to ${toTime}`;
|
|
9575
|
-
const fullDayFromToDay = `on ${fromDate}`;
|
|
9576
|
-
let fromToDate = isSameDay ? singleFromToDate : compoundFromToDate;
|
|
9577
|
-
if (isFullDay) fromToDate = fullDayFromToDay;
|
|
9578
|
-
const fromToTime = isFullDay ? "" : ` from ${fromTime} to ${toTime}`;
|
|
9579
|
-
const fromDayOfWeek = start.format("dddd");
|
|
9580
|
-
const fromToDayOfWeek = `${fromDayOfWeek}s to ${end.format("dddd")}s`;
|
|
9581
|
-
const dayOfWeek = isSameDay ? `on ${fromDayOfWeek}s` : fromToDayOfWeek;
|
|
9582
|
-
const singleDayOfMonth = `on the ${fromDayOfMonth}`;
|
|
9583
|
-
const fromToDayOfMonth = `on the ${fromDayOfMonth} to ${toDayOfMonth}`;
|
|
9584
|
-
const dayOfMonth = isSameDay ? singleDayOfMonth : fromToDayOfMonth;
|
|
9585
|
-
const weeks = Number(first.slice(0, -1));
|
|
9586
|
-
let weekOfMonth = "1st";
|
|
9587
|
-
if (weeks === 2) weekOfMonth = "2nd";
|
|
9588
|
-
if (weeks === 3) weekOfMonth = "3rd";
|
|
9589
|
-
if (weeks === 4) weekOfMonth = "4th";
|
|
9590
|
-
if (weeks === 5) weekOfMonth = "5th";
|
|
9591
|
-
const startsOn = `, starting on ${start.format("MMMM Do")}`;
|
|
9592
|
-
switch (this.repeat) {
|
|
9593
|
-
case "NONE": return `Once ${fromToDate}`;
|
|
9594
|
-
case "DAILY": return `Daily${fromToTime}${startsOn}`;
|
|
9595
|
-
case "WEEKDAYS": return `On weekdays${fromToTime}${startsOn}`;
|
|
9596
|
-
case "WEEKENDS": return `On weekends${fromToTime}${startsOn}`;
|
|
9597
|
-
case "WEEKLY": return `Weekly ${dayOfWeek}${fromToTime}${startsOn}`;
|
|
9598
|
-
case "FORTNIGHTLY": return `Fortnightly ${dayOfWeek}${fromToTime}${startsOn}`;
|
|
9599
|
-
case "MONTHLY": return `Monthly ${dayOfMonth}${fromToTime}${startsOn}`;
|
|
9600
|
-
case "LAST_DAY_OF_MONTH": return `Every Last day of the month${fromToTime}${startsOn}`;
|
|
9601
|
-
case "WEEK_OF_MONTH": return `Every ${weekOfMonth} ${fromDayOfWeek} of the month${fromToTime}${startsOn}`;
|
|
9602
|
-
default: throw new Error(`Unsupported repeat value: ${this.repeat}`);
|
|
9603
|
-
}
|
|
9696
|
+
get summary() {
|
|
9697
|
+
const { startDate, endDate, repeat } = this;
|
|
9698
|
+
return summarizeRecurringDateCron({
|
|
9699
|
+
startDate,
|
|
9700
|
+
endDate,
|
|
9701
|
+
repeat
|
|
9702
|
+
}, this.timezone);
|
|
9604
9703
|
}
|
|
9704
|
+
/**
|
|
9705
|
+
* Human sentence for this rule. Defaults to English (same text as
|
|
9706
|
+
* `result.description`); pass a formatter to localize it.
|
|
9707
|
+
*/
|
|
9708
|
+
describe = (format = formatRecurringDateCronSummary) => {
|
|
9709
|
+
return format(this.summary);
|
|
9710
|
+
};
|
|
9605
9711
|
get result() {
|
|
9606
9712
|
const expression = this.getExpression();
|
|
9607
|
-
const description = this.
|
|
9713
|
+
const description = this.describe();
|
|
9608
9714
|
return {
|
|
9609
9715
|
startDate: this.startDate,
|
|
9610
9716
|
endDate: this.endDate,
|
|
@@ -9621,12 +9727,14 @@ var RecurringDateCron = class {
|
|
|
9621
9727
|
const isWeekday = dateObj.day() >= 1 && dateObj.day() <= 5;
|
|
9622
9728
|
const isWeekend = dateObj.day() === 0 || dateObj.day() === 6;
|
|
9623
9729
|
const dayOfWeek = dateObj.day();
|
|
9624
|
-
const
|
|
9625
|
-
const
|
|
9730
|
+
const zonedStart = this.timezone ? this.day(this.startDate) : null;
|
|
9731
|
+
const zonedEnd = this.timezone ? this.day(this.endDate) : null;
|
|
9732
|
+
const firstDayOfWeek = zonedStart?.day() ?? this.startDate.getDay();
|
|
9733
|
+
const lastDayOfWeek = zonedEnd?.day() ?? this.endDate.getDay();
|
|
9626
9734
|
const isBetweenWeekDays = dayOfWeek >= firstDayOfWeek && dayOfWeek <= lastDayOfWeek;
|
|
9627
9735
|
const dayOfMonth = dateObj.date();
|
|
9628
|
-
const firstDayOfMonth = this.startDate.getDate();
|
|
9629
|
-
const lastDayOfMonth = this.endDate.getDate();
|
|
9736
|
+
const firstDayOfMonth = zonedStart?.date() ?? this.startDate.getDate();
|
|
9737
|
+
const lastDayOfMonth = zonedEnd?.date() ?? this.endDate.getDate();
|
|
9630
9738
|
const isBetweenDaysOfMonth = dayOfMonth >= firstDayOfMonth && dayOfMonth <= lastDayOfMonth;
|
|
9631
9739
|
let start = this.day(this.startDate);
|
|
9632
9740
|
start = start.year(dateObj.year());
|
|
@@ -9678,26 +9786,26 @@ var RecurringDateCron = class {
|
|
|
9678
9786
|
};
|
|
9679
9787
|
//#endregion
|
|
9680
9788
|
//#region src/rules/recurringDateMatcher.ts
|
|
9681
|
-
const matchRecurringDateOperator = (condition, matcher) => {
|
|
9789
|
+
const matchRecurringDateOperator = (condition, matcher, timezone) => {
|
|
9682
9790
|
const { primitive, operator } = condition;
|
|
9683
9791
|
assert(primitive === "recurring date", primitiveError("recurring date"));
|
|
9684
9792
|
if (typeof matcher === "undefined") return false;
|
|
9685
9793
|
switch (operator) {
|
|
9686
|
-
case "falls within period": return new RecurringDateCron(condition).match(matcher);
|
|
9794
|
+
case "falls within period": return new RecurringDateCron(condition, timezone).match(matcher);
|
|
9687
9795
|
default: {
|
|
9688
9796
|
const msg = `Operator ${operator} not supported in recurring date matcher`;
|
|
9689
9797
|
throw new Error(msg);
|
|
9690
9798
|
}
|
|
9691
9799
|
}
|
|
9692
9800
|
};
|
|
9693
|
-
const currentDate = (condition, referenceDate) => {
|
|
9801
|
+
const currentDate = (condition, referenceDate, timezone) => {
|
|
9694
9802
|
const { type, primitive, value } = condition;
|
|
9695
9803
|
const matcherType = "Current date";
|
|
9696
9804
|
assert(primitive === "recurring date", primitiveError("recurring date"));
|
|
9697
9805
|
assert(type === matcherType, typeError(matcherType));
|
|
9698
9806
|
assert(value != null, "Invalid value value");
|
|
9699
9807
|
const current = referenceDate ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
9700
|
-
return matchRecurringDateOperator(condition, current);
|
|
9808
|
+
return matchRecurringDateOperator(condition, current, timezone);
|
|
9701
9809
|
};
|
|
9702
9810
|
//#endregion
|
|
9703
9811
|
//#region src/rules/relativeDateMatcher.ts
|
|
@@ -9814,15 +9922,17 @@ var RulesEngine = class {
|
|
|
9814
9922
|
payment;
|
|
9815
9923
|
monitoring;
|
|
9816
9924
|
referenceDate;
|
|
9925
|
+
timezone;
|
|
9817
9926
|
runtime;
|
|
9818
9927
|
constructor(params = {}) {
|
|
9819
9928
|
const { order, customer, payment, monitoring, referenceDate } = params;
|
|
9820
|
-
const { runtime } = params;
|
|
9929
|
+
const { runtime, timezone } = params;
|
|
9821
9930
|
this.order = order;
|
|
9822
9931
|
this.customer = customer;
|
|
9823
9932
|
this.payment = payment;
|
|
9824
9933
|
this.monitoring = monitoring;
|
|
9825
9934
|
this.referenceDate = referenceDate;
|
|
9935
|
+
this.timezone = timezone;
|
|
9826
9936
|
this.runtime = runtime;
|
|
9827
9937
|
}
|
|
9828
9938
|
getDependency(prop, type) {
|
|
@@ -9995,7 +10105,14 @@ var RulesEngine = class {
|
|
|
9995
10105
|
assertRecurringDate = (condition) => {
|
|
9996
10106
|
const { primitive, type } = condition;
|
|
9997
10107
|
assert(primitive === "recurring date", primitiveError("recurring date"));
|
|
9998
|
-
if (type === "Current date")
|
|
10108
|
+
if (type === "Current date") {
|
|
10109
|
+
const p1 = [
|
|
10110
|
+
condition,
|
|
10111
|
+
this.referenceDate,
|
|
10112
|
+
this.timezone
|
|
10113
|
+
];
|
|
10114
|
+
return currentDate(...p1);
|
|
10115
|
+
}
|
|
9999
10116
|
const msg = `Condition ${type} not supported in recurring date matcher`;
|
|
10000
10117
|
throw new Error(msg);
|
|
10001
10118
|
};
|
|
@@ -10970,6 +11087,61 @@ const paymentMatchesClientConditions = (conditions, order, options) => {
|
|
|
10970
11087
|
return Boolean(engine.matchOrConditions(groups).match);
|
|
10971
11088
|
};
|
|
10972
11089
|
//#endregion
|
|
11090
|
+
//#region src/rules/cmsVisibility.ts
|
|
11091
|
+
const CURRENT_DATE = "Current date";
|
|
11092
|
+
/** True when evaluating the gate needs a timezone. */
|
|
11093
|
+
const cmsVisibilityNeedsTimezone = (visibility) => {
|
|
11094
|
+
return (visibility?.conditions ?? []).some((group) => {
|
|
11095
|
+
return group.some((condition) => condition.type === CURRENT_DATE);
|
|
11096
|
+
});
|
|
11097
|
+
};
|
|
11098
|
+
const passesGate = (conditions, ctx) => {
|
|
11099
|
+
if (conditions.length === 0) return true;
|
|
11100
|
+
const { store_id, channel_id, fulfillment_id, brand_id } = ctx;
|
|
11101
|
+
const b1 = { store_id: store_id ?? void 0 };
|
|
11102
|
+
const b2 = { channel_id: channel_id ?? void 0 };
|
|
11103
|
+
const b3 = { fulfillment_id: fulfillment_id ?? void 0 };
|
|
11104
|
+
const b4 = { brand_id: brand_id ?? void 0 };
|
|
11105
|
+
const order = {
|
|
11106
|
+
total: 0,
|
|
11107
|
+
is_anonymous: true,
|
|
11108
|
+
...b1,
|
|
11109
|
+
...b2,
|
|
11110
|
+
...b3,
|
|
11111
|
+
...b4
|
|
11112
|
+
};
|
|
11113
|
+
const referenceDate = ctx.now.toISOString();
|
|
11114
|
+
const timezone = ctx.timezone ?? "UTC";
|
|
11115
|
+
try {
|
|
11116
|
+
return new RulesEngine({
|
|
11117
|
+
order,
|
|
11118
|
+
referenceDate,
|
|
11119
|
+
timezone
|
|
11120
|
+
}).matchOrConditions(conditions).match != null;
|
|
11121
|
+
} catch {
|
|
11122
|
+
return false;
|
|
11123
|
+
}
|
|
11124
|
+
};
|
|
11125
|
+
/**
|
|
11126
|
+
* Storefront payload for one active block. A failed gate keeps the block's
|
|
11127
|
+
* identity and empties `items`. The rules never leave the server.
|
|
11128
|
+
*/
|
|
11129
|
+
const applyCmsVisibility = (block, ctx) => {
|
|
11130
|
+
const { id, name, status, items, visibility } = block;
|
|
11131
|
+
if (!visibility) return {
|
|
11132
|
+
id,
|
|
11133
|
+
name,
|
|
11134
|
+
status,
|
|
11135
|
+
items
|
|
11136
|
+
};
|
|
11137
|
+
return {
|
|
11138
|
+
id,
|
|
11139
|
+
name,
|
|
11140
|
+
status,
|
|
11141
|
+
items: passesGate(visibility.conditions ?? [], ctx) ? items : []
|
|
11142
|
+
};
|
|
11143
|
+
};
|
|
11144
|
+
//#endregion
|
|
10973
11145
|
//#region src/card/card.ts
|
|
10974
11146
|
const DEFAULT_GAPS = [
|
|
10975
11147
|
4,
|
|
@@ -11301,4 +11473,4 @@ const validatePickupName = (raw, rules) => {
|
|
|
11301
11473
|
return null;
|
|
11302
11474
|
};
|
|
11303
11475
|
//#endregion
|
|
11304
|
-
export { CARD_BRANDS, CUSTOMER_INFO_PLACEHOLDERS, DEFAULT_RECOMMENDATION_TYPES, DelegatedSessionExpiredError, ID_HASH_FORMATS, Order, OrderAuthPinnedError, OrderNotOpenError, OrderPaymentRequiredError, OrderSyncPendingError, OrderSyncRejectedError, OrderValidationError, RecurringDateCron, RulesEngine, SCHEDULED_AT_ERROR_CODES, SCHEDULED_ORDER_MAX_HORIZON_HOURS, SCHEDULED_ORDER_MAX_HORIZON_MINUTES, SCHEDULED_ORDER_MIN_LEAD_MINUTES, SCHEDULED_ORDER_SLOT_MINUTES, StorefrontHttpError, addLines, auth, buildCustomerSnapshot, buildScheduleSlots, cancelTypeOf, capRedeems, cappedRedeems, cardBrandSpec, cardDigits, cardNumberGaps, cardNumberMaxLength, cardPreviewGroups, caretAfterDigits, collectOrderLineDiffs, computeStartingPrice, countCartProducts, coveredAmount, createDeunaWidgetApi, createSession, currentNodes, cvcMaxLength, defaultConditionError, detectCardBrand, fitRedeems, flattenMenuCategories, flushLogs, formatCardNumber, formatCvc, formatExpiry, fromOrderLines, genId, genOrderId, getLogContext, getScheduleWindow, indexMenu, isCardNumberComplete, isCardNumberDefinitelyInvalid, isCheckoutFieldFilled, isCustomerInfoFieldFilled, isCustomerInfoPlaceholder, isCustomerInfoValueValid, isCvcComplete, isDelegatedSessionExpiredError, isDeviceCharged, isDeviceNotLinked, isExpiryComplete, isGenId, isKioskUnauthorized, isMilestoneStepDone, isOnSchedule, isOrderNotOpenError, isOrderPaymentRequiredError, isOrderValidationError, isPosDeviceNotLinked, isPosUnauthorized, isRealPaymentMethod, isScheduleSlot, isScheduledAtError, isStorefrontNotFound, isVariantBase, linePayableTotal, listMenusStream, localizePosError, log, logError, luhnCheck, matchAbsoluteDateOperator, matchBooleanOperator, matchCurrencyOperator, matchEnumOperator, matchNumberOperator, matchRecurringDateOperator, matchRelativeDateOperator, matchStringOperator, milestoneSteps, milestoneTrack, nestMenuCategories, normalizeCardholderName, normalizeCustomerPhone, normalizePickupName, orderPayableTotal, orderRedeemedTotal, orderRedeems, parseExpiry, paymentMatchesClientConditions, rebuildRootGroups, recomputeTotals, redeemedTotal, redeemsForPayment, redemptionCap, redemptionSteps, remainingAmount, removeLine, replaceLine, resolveCheckout, resolveModifierImageUrl, resolveSchedulePrepMinutes, reversePayment, runPaymentAttempt, scheduledInstant, selectablePayments, serializeError, services, setLineQuantity, storefrontJson, toOrderLines, toPaymentCardBrand, validateCardNumber, validateCardholderName, validateCvc, validateExpiry, validateOrderAgainstMenu, validatePickupName, verifyWebhookSignature, visitedStates };
|
|
11476
|
+
export { CARD_BRANDS, CUSTOMER_INFO_PLACEHOLDERS, DEFAULT_RECOMMENDATION_TYPES, DelegatedSessionExpiredError, ID_HASH_FORMATS, Order, OrderAuthPinnedError, OrderNotOpenError, OrderPaymentRequiredError, OrderSyncPendingError, OrderSyncRejectedError, OrderValidationError, RecurringDateCron, RulesEngine, SCHEDULED_AT_ERROR_CODES, SCHEDULED_ORDER_MAX_HORIZON_HOURS, SCHEDULED_ORDER_MAX_HORIZON_MINUTES, SCHEDULED_ORDER_MIN_LEAD_MINUTES, SCHEDULED_ORDER_SLOT_MINUTES, StorefrontHttpError, addLines, applyCmsVisibility, auth, buildCustomerSnapshot, buildScheduleSlots, cancelTypeOf, capRedeems, cappedRedeems, cardBrandSpec, cardDigits, cardNumberGaps, cardNumberMaxLength, cardPreviewGroups, caretAfterDigits, cmsVisibilityNeedsTimezone, collectOrderLineDiffs, computeStartingPrice, countCartProducts, coveredAmount, createDeunaWidgetApi, createSession, currentNodes, cvcMaxLength, defaultConditionError, detectCardBrand, fitRedeems, flattenMenuCategories, flushLogs, formatCardNumber, formatCvc, formatExpiry, formatRecurringDateCronSummary, fromOrderLines, genId, genOrderId, getLogContext, getScheduleWindow, indexMenu, isCardNumberComplete, isCardNumberDefinitelyInvalid, isCheckoutFieldFilled, isCustomerInfoFieldFilled, isCustomerInfoPlaceholder, isCustomerInfoValueValid, isCvcComplete, isDelegatedSessionExpiredError, isDeviceCharged, isDeviceNotLinked, isExpiryComplete, isGenId, isKioskUnauthorized, isMilestoneStepDone, isOnSchedule, isOrderNotOpenError, isOrderPaymentRequiredError, isOrderValidationError, isPosDeviceNotLinked, isPosUnauthorized, isRealPaymentMethod, isScheduleSlot, isScheduledAtError, isStorefrontNotFound, isVariantBase, linePayableTotal, listMenusStream, localizePosError, log, logError, luhnCheck, matchAbsoluteDateOperator, matchBooleanOperator, matchCurrencyOperator, matchEnumOperator, matchNumberOperator, matchRecurringDateOperator, matchRelativeDateOperator, matchStringOperator, milestoneSteps, milestoneTrack, nestMenuCategories, normalizeCardholderName, normalizeCustomerPhone, normalizePickupName, orderPayableTotal, orderRedeemedTotal, orderRedeems, parseExpiry, paymentMatchesClientConditions, placeCartLines, rebuildRootGroups, recomputeTotals, redeemedTotal, redeemsForPayment, redemptionCap, redemptionSteps, remainingAmount, removeLine, replaceLine, resolveCheckout, resolveModifierImageUrl, resolveSchedulePrepMinutes, reversePayment, runPaymentAttempt, scheduledInstant, selectablePayments, serializeError, services, setLineQuantity, storefrontJson, summarizeRecurringDateCron, toOrderLines, toPaymentCardBrand, validateCardNumber, validateCardholderName, validateCvc, validateExpiry, validateOrderAgainstMenu, validatePickupName, verifyWebhookSignature, visitedStates };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fire-spark/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"description": "Fire Spark headless SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"big.js": "6.2.1",
|
|
21
21
|
"dayjs": "1.11.9",
|
|
22
22
|
"@types/big.js": "6.2.2",
|
|
23
|
-
"@fire-spark/payments": "^0.
|
|
24
|
-
"@fire-spark/types": "^0.
|
|
23
|
+
"@fire-spark/payments": "^0.21.0",
|
|
24
|
+
"@fire-spark/types": "^0.21.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"tsdown": "^0.22.14",
|