@fire-spark/core 0.4.0 → 0.5.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 +214 -65
- package/dist/index.js +965 -925
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PaymentAdapter, PaymentCollectAt, PaymentContext, PaymentResult, PaymentStorage, PaymentUI, isRealPaymentMethod,
|
|
1
|
+
import { Money, PaymentAdapter, PaymentCollectAt, PaymentContext, PaymentResult, PaymentStorage, PaymentUI, RedeemLike, RedeemSource, isRealPaymentMethod, orderRedeems } from "@fire-spark/payments";
|
|
2
2
|
import { AndConditions, CheckoutMode, CheckoutResolved, CmsBlock, Condition, Customer, CustomerIdentifyInput, CustomerRegisterInput, CustomerUpdateInput, Fulfillment, FulfillmentListInput, GroupDisplayType, KioskDeviceConfig, KioskDeviceOverrides, KioskHealthBatchInput, KioskHealthBatchResult, KioskHeartbeatInput, KioskHeartbeatResult, KioskRealtimeToken, MatchResult, MatchableRule, Menu, Menu as Menu$1, MenuLookup, MenuLookup as MenuLookup$1, MerchantPayment, ModifierControlType, ModifierGroup, OrConditions, Order as Order$1, Order as Order$2, OrderFulfillment, OrderInsertInput, OrderLine, OrderListInput, OrderRecordPaymentInput, OrderRedeem, OrderRedemptionStep, OrderReorderInput, OrderTotals, OrderUpdateInput, OrderValidateInput, OrderValidateOutput, PaymentCollectAt as PaymentCollectAt$1, PaymentIntentPutInput, PaymentMethod, PaymentProvider, PaymentTender, PaymentTenderInput, PlaceOrderResult, PosCatalog, PosHealthBatchInput, PosHealthBatchResult, PosHeartbeatInput, PosHeartbeatResult, PosKioskOrder, PosKioskSettleInput, PosKioskSettleResult, PosOrderInput, PosOrderResult, PricingModifier, Product, Product as Product$1, Recommendation, RecurringDateCronResult, RecurringDateCronValues, RulesEngineOrderLine, RulesEngineParams, RulesEngineRuntime, Schedule, SdkLogContext, SdkLogErrorInfo, SdkLogLevel, SdkLogOptions, Store, StoreGetInput, StoreListInput, StoreNearbyInput, StorefrontAvailability, StorefrontMenu, StorefrontMenuScope, StorefrontMenuStreamOptions, StorefrontPaymentsListInput, StorefrontPreferences, TenderRefundInput, TenderReplaceInput, TenderVoidInput, Variant, VariantGroup } from "@fire-spark/types";
|
|
3
3
|
import { Big } from "big.js";
|
|
4
4
|
//#region src/productCustomization/types.d.ts
|
|
@@ -407,33 +407,29 @@ type OrderDraft = Order$2;
|
|
|
407
407
|
type ApplyRedeemInput = {
|
|
408
408
|
reward_id: string;
|
|
409
409
|
/**
|
|
410
|
-
* Reward units to redeem (integer ≥ 1)
|
|
411
|
-
*
|
|
410
|
+
* Reward units to redeem (integer ≥ 1); informational: `amount` already
|
|
411
|
+
* covers every unit.
|
|
412
412
|
*/
|
|
413
413
|
quantity: number;
|
|
414
|
-
/** 0–1, compounded per unit over the remaining value. */
|
|
415
|
-
discount_rate?: number;
|
|
416
|
-
/** > 0, per unit; caps the rate discount when both are set. */
|
|
417
|
-
discount_amount?: number;
|
|
418
414
|
/**
|
|
419
|
-
* Default `true`:
|
|
420
|
-
*
|
|
415
|
+
* Default `true`: the redeem covers at most the pre-tax value of its
|
|
416
|
+
* target (line or order); taxes stay for the customer's method.
|
|
417
|
+
* `false`: it may also cover taxes, up to the full total.
|
|
421
418
|
*/
|
|
422
419
|
before_taxes?: boolean;
|
|
423
|
-
/** Root line
|
|
420
|
+
/** Root line the redeem is for; omit to apply it to the whole order. */
|
|
424
421
|
line_uid?: string;
|
|
425
422
|
/**
|
|
426
|
-
*
|
|
427
|
-
*
|
|
428
|
-
* Redeems with the same `payment_id` share one tender
|
|
429
|
-
* (`details.rewards[]`).
|
|
423
|
+
* Required: the active merchant `REDEMPTION` payment whose tender covers
|
|
424
|
+
* `amount`. Redeems with the same `payment_id` share one tender.
|
|
430
425
|
*/
|
|
431
|
-
payment_id
|
|
426
|
+
payment_id: string;
|
|
432
427
|
/**
|
|
433
|
-
*
|
|
434
|
-
*
|
|
428
|
+
* Required, > 0: money the redeem covers for the whole entry (every
|
|
429
|
+
* `quantity` unit). Shown as the line or order discount; trimmed to the
|
|
430
|
+
* `before_taxes` cap and to total − tip − delivery.
|
|
435
431
|
*/
|
|
436
|
-
amount
|
|
432
|
+
amount: number;
|
|
437
433
|
/** Provider of the REDEMPTION payment (default `firespark`). */
|
|
438
434
|
provider?: PaymentProvider;
|
|
439
435
|
/** ISO datetime with offset; validation fails once it has passed. */
|
|
@@ -514,20 +510,21 @@ declare class Order {
|
|
|
514
510
|
replaceLine(lineUid: string, lines: OrderLine | OrderLine[]): void;
|
|
515
511
|
emptyOrder(): void;
|
|
516
512
|
/**
|
|
517
|
-
*
|
|
518
|
-
*
|
|
519
|
-
*
|
|
520
|
-
*
|
|
521
|
-
*
|
|
522
|
-
*
|
|
523
|
-
*
|
|
513
|
+
* Applies a redeem (points, voucher, free product…) to `line_uid` (root
|
|
514
|
+
* product line) or to the order. `payment_id` and `amount` are required:
|
|
515
|
+
* `amount` is what the redeem covers for the whole entry and is shown as
|
|
516
|
+
* the line / order discount, while line and order totals keep their full
|
|
517
|
+
* value. The REDEMPTION tender of `payment_id` pays `amount`; the
|
|
518
|
+
* customer's method pays the rest (the taxes when `before_taxes`, the
|
|
519
|
+
* default, keeps them out of the redeem). Redeems with the same
|
|
520
|
+
* `payment_id` share one tender (D15, D18, D19).
|
|
524
521
|
*/
|
|
525
522
|
applyRedeem(input: ApplyRedeemInput): void;
|
|
526
523
|
/**
|
|
527
524
|
* Removes `quantity` units of `reward_id` from `line_uid` or the order,
|
|
528
525
|
* latest applied first. Removing more units than applied clears them all
|
|
529
|
-
* (and
|
|
530
|
-
*
|
|
526
|
+
* (and their REDEMPTION tender). A redeem that keeps some units keeps
|
|
527
|
+
* their share of its `amount`.
|
|
531
528
|
*/
|
|
532
529
|
removeRedeem(input: RemoveRedeemInput): void;
|
|
533
530
|
private rememberLogScope;
|
|
@@ -553,9 +550,10 @@ declare class Order {
|
|
|
553
550
|
refundOrder(): Promise<void>;
|
|
554
551
|
validateOrder(): Promise<void>;
|
|
555
552
|
/**
|
|
556
|
-
* Tenders of the next intent:
|
|
557
|
-
*
|
|
558
|
-
* cover the total, only
|
|
553
|
+
* Tenders of the next intent: one REDEMPTION per redeem `payment_id`
|
|
554
|
+
* (order and lines, capped) plus the customer's method for the rest,
|
|
555
|
+
* e.g. the taxes. When the redeems cover the whole total, only
|
|
556
|
+
* REDEMPTION tenders.
|
|
559
557
|
*/
|
|
560
558
|
getTenders(payment?: PlaceOrderInput["payment"]): PaymentTenderInput[];
|
|
561
559
|
/**
|
|
@@ -566,6 +564,7 @@ declare class Order {
|
|
|
566
564
|
setTenders(tenders: PaymentTenderInput[]): Promise<Order$1>;
|
|
567
565
|
/** Drops the chosen tenders and discards the DRAFT intent. */
|
|
568
566
|
clearTenders(): Promise<Order$1>;
|
|
567
|
+
private assertPayable;
|
|
569
568
|
private syncPaymentIntent;
|
|
570
569
|
private applyServerOrder;
|
|
571
570
|
/** Keeps the applied redeems while the server holds the same capped ones. */
|
|
@@ -575,6 +574,9 @@ declare class Order {
|
|
|
575
574
|
* Places the order with a DRAFT intent: `intent_id` as is, else the
|
|
576
575
|
* tenders of `getTenders(input.payment)` saved first (simple flow: one
|
|
577
576
|
* real tender plus REDEMPTION). The intent is `LOCKED` afterwards (D25).
|
|
577
|
+
* A rejected order sync is rethrown and nothing is placed; with no real
|
|
578
|
+
* tender and redeems short of the total it throws
|
|
579
|
+
* `OrderPaymentRequiredError` instead of placing.
|
|
578
580
|
*/
|
|
579
581
|
placeOrder(input?: PlaceOrderInput): Promise<void>;
|
|
580
582
|
/** Installed `@fire-spark/payments-*` adapters (provider + method). */
|
|
@@ -619,7 +621,10 @@ declare class Order {
|
|
|
619
621
|
reversePayments(options?: ReverseAllOptions): Promise<ReversalOutcome[]>;
|
|
620
622
|
/** Terminal admin operation (init, test, closeBatch, status, extra). */
|
|
621
623
|
runPaymentTerminal(payment: MerchantPayment, key: string): Promise<import("@fire-spark/payments").TerminalResult>;
|
|
622
|
-
/**
|
|
624
|
+
/**
|
|
625
|
+
* Applies lines/redeem, recomputes totals (redeems never change them),
|
|
626
|
+
* trims every redeem to its `before_taxes` cap and rebuilds the steps.
|
|
627
|
+
*/
|
|
623
628
|
private commitLines;
|
|
624
629
|
private scheduleAfterMutate;
|
|
625
630
|
private notify;
|
|
@@ -629,6 +634,14 @@ declare class Order {
|
|
|
629
634
|
declare class OrderSyncPendingError extends Error {
|
|
630
635
|
constructor();
|
|
631
636
|
}
|
|
637
|
+
/**
|
|
638
|
+
* The server rejected an order write (POST/PATCH) and the draft was rolled
|
|
639
|
+
* back to the last synced order. Keeps the API `status`, `code` and
|
|
640
|
+
* `details`, so code checks on `StorefrontHttpError` still match.
|
|
641
|
+
*/
|
|
642
|
+
declare class OrderSyncRejectedError extends StorefrontHttpError {
|
|
643
|
+
constructor(error: StorefrontHttpError);
|
|
644
|
+
}
|
|
632
645
|
//#endregion
|
|
633
646
|
//#region src/order/fulfillmentTrack.d.ts
|
|
634
647
|
type TrackWorkflowNode = {
|
|
@@ -684,9 +697,21 @@ declare const milestoneTrack: (workflow: TrackWorkflow) => MilestoneTrackItem[];
|
|
|
684
697
|
/** Ordered milestones + current index from `current_node_ids` (dashboard algo). */
|
|
685
698
|
declare const milestoneSteps: (workflow: TrackWorkflow, currentNodeIds: string[]) => MilestoneSteps | null;
|
|
686
699
|
//#endregion
|
|
700
|
+
//#region src/order/OrderPaymentRequiredError.d.ts
|
|
701
|
+
/**
|
|
702
|
+
* `placeOrder` has no real tender (no `payment`, no `setTenders`, no
|
|
703
|
+
* `intent_id`) and the redeems do not cover the total. Same code as the
|
|
704
|
+
* API's 422, so callers map both the same way.
|
|
705
|
+
*/
|
|
706
|
+
declare class OrderPaymentRequiredError extends Error {
|
|
707
|
+
readonly code = "PAYMENT_REQUIRED";
|
|
708
|
+
constructor();
|
|
709
|
+
}
|
|
710
|
+
declare const isOrderPaymentRequiredError: (error: unknown) => error is OrderPaymentRequiredError;
|
|
711
|
+
//#endregion
|
|
687
712
|
//#region src/order/validate.d.ts
|
|
688
|
-
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" |
|
|
689
|
-
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" | "DAILY_ORDER_LIMIT_REACHED";
|
|
713
|
+
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" | RedeemIssueCode;
|
|
714
|
+
type OrderIssueCode = "NO_MENU" | "MENU_CLOSED" | "SCOPE_INACTIVE" | "TOTALS_MISMATCH" | "REDEEM_EXPIRED" | RedeemIssueCode | "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" | "DAILY_ORDER_LIMIT_REACHED";
|
|
690
715
|
type OrderLineIssue = {
|
|
691
716
|
code: OrderLineIssueCode;
|
|
692
717
|
field?: string;
|
|
@@ -714,10 +739,28 @@ type ValidateOrderAgainstMenuInput = {
|
|
|
714
739
|
locale?: string;
|
|
715
740
|
expectedFeeLines?: OrderLine[];
|
|
716
741
|
redeem?: OrderRedeem[];
|
|
742
|
+
/**
|
|
743
|
+
* Merchant payments in scope. When set, every redeem's `payment_id`
|
|
744
|
+
* must be one of them, active, with the REDEMPTION method.
|
|
745
|
+
*/
|
|
746
|
+
payments?: readonly RedeemPaymentRow[];
|
|
747
|
+
/**
|
|
748
|
+
* Steps the client computed. When set, they must equal the steps of
|
|
749
|
+
* `redemptionSteps` for these lines, totals and redeems.
|
|
750
|
+
*/
|
|
717
751
|
redemptionSteps?: OrderRedemptionStep[];
|
|
718
752
|
/** Epoch ms used for `expires_at` checks. */
|
|
719
753
|
now?: number;
|
|
720
754
|
};
|
|
755
|
+
/** Payment a redeem references, as listed for the merchant. */
|
|
756
|
+
type RedeemPaymentRow = {
|
|
757
|
+
id: string;
|
|
758
|
+
status?: string | null;
|
|
759
|
+
method: {
|
|
760
|
+
method: string;
|
|
761
|
+
};
|
|
762
|
+
};
|
|
763
|
+
type RedeemIssueCode = "REDEEM_PAYMENT_REQUIRED" | "REDEEM_PAYMENT_METHOD_NOT_CONFIGURED" | "REDEEM_AMOUNT_MISMATCH";
|
|
721
764
|
/** Compare cart lines/totals against a fresh menu (exact Big.js equality). */
|
|
722
765
|
declare const validateOrderAgainstMenu: (input: ValidateOrderAgainstMenuInput) => OrderValidationResult;
|
|
723
766
|
type OrderLineDiff = {
|
|
@@ -742,23 +785,145 @@ declare class OrderValidationError extends Error {
|
|
|
742
785
|
}
|
|
743
786
|
declare const isOrderValidationError: (error: unknown) => error is OrderValidationError;
|
|
744
787
|
//#endregion
|
|
745
|
-
//#region src/order/
|
|
788
|
+
//#region src/order/tenders.d.ts
|
|
789
|
+
type CapOrder = Pick<Order$1, "lines" | "totals"> & {
|
|
790
|
+
redeem?: readonly OrderRedeem[] | null;
|
|
791
|
+
};
|
|
746
792
|
/**
|
|
747
|
-
*
|
|
748
|
-
*
|
|
793
|
+
* Digital tender the SDK charges (`DEVICE`, §7.3). `KIOSK`, `COUNTER`,
|
|
794
|
+
* `DOOR` and `OTHER` are in person: the POS, an operator or the courier
|
|
795
|
+
* collects them (§12).
|
|
749
796
|
*/
|
|
750
|
-
declare const
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
797
|
+
declare const isDeviceCharged: (tender: {
|
|
798
|
+
collect_at: string;
|
|
799
|
+
}) => boolean;
|
|
800
|
+
/**
|
|
801
|
+
* Most the redeems can cover (D18): order total − tip − delivery. With
|
|
802
|
+
* `beforeTaxes`, the taxes of the other roots are excluded too, so they
|
|
803
|
+
* stay for the customer's method.
|
|
804
|
+
*/
|
|
805
|
+
declare const redemptionCap: (order: Pick<Order$1, "lines" | "totals">, beforeTaxes?: boolean) => number;
|
|
806
|
+
/**
|
|
807
|
+
* What each redeem may cover, index-aligned with `order.redeem` and every
|
|
808
|
+
* line's `redeem` (0 = dropped or without `payment_id`). Line redeems go
|
|
809
|
+
* first, then order ones, each in application order. `before_taxes`
|
|
810
|
+
* (default true) limits a redeem to the pre-tax value of its target, so
|
|
811
|
+
* taxes stay for the customer's method; `false` lets it cover taxes too,
|
|
812
|
+
* up to the full total.
|
|
813
|
+
*/
|
|
814
|
+
type FittedRedeems = {
|
|
815
|
+
lines: Money[][];
|
|
816
|
+
redeem: Money[];
|
|
817
|
+
};
|
|
818
|
+
declare const fitRedeems: (order: CapOrder) => FittedRedeems;
|
|
819
|
+
/**
|
|
820
|
+
* Trims every redeem to what `fitRedeems` lets it cover; redeems with no
|
|
821
|
+
* room left are dropped. Line and order money is never changed: the
|
|
822
|
+
* REDEMPTION tender pays the kept `amount`.
|
|
823
|
+
*/
|
|
824
|
+
declare const capRedeems: <T extends CapOrder>(order: T) => T & {
|
|
825
|
+
lines: {
|
|
826
|
+
type: "FEE" | "PRODUCT";
|
|
827
|
+
uid: string;
|
|
828
|
+
id: string;
|
|
829
|
+
parent_uid: string | null;
|
|
830
|
+
parent_id: string | null;
|
|
831
|
+
name: string;
|
|
832
|
+
image_url?: string | undefined;
|
|
833
|
+
menu_id?: string | undefined;
|
|
834
|
+
internal_attribution_source?: string | undefined;
|
|
835
|
+
internal_attribution_id?: string | undefined;
|
|
836
|
+
metadata: Record<string, unknown>;
|
|
837
|
+
bundled_items: {
|
|
838
|
+
id: string;
|
|
839
|
+
refund_price: number;
|
|
840
|
+
included_quantity: number;
|
|
841
|
+
}[];
|
|
842
|
+
redeem: {
|
|
843
|
+
reward_id: string;
|
|
844
|
+
quantity: number;
|
|
845
|
+
before_taxes?: boolean | undefined;
|
|
846
|
+
expires_at?: string | undefined;
|
|
847
|
+
payment_id: string;
|
|
848
|
+
amount: number;
|
|
849
|
+
}[];
|
|
850
|
+
quantity: number;
|
|
851
|
+
tax_rate: number | null;
|
|
852
|
+
discount_rate: number;
|
|
853
|
+
unit_subtotal: number;
|
|
854
|
+
unit_discount: number;
|
|
855
|
+
unit_tax_total: number;
|
|
856
|
+
unit_total: number;
|
|
857
|
+
subtotal: number;
|
|
858
|
+
discount_total: number;
|
|
859
|
+
tax_total: number;
|
|
860
|
+
total: number;
|
|
861
|
+
unit_group_subtotal: number;
|
|
862
|
+
unit_group_discount: number;
|
|
863
|
+
unit_group_tax_total: number;
|
|
864
|
+
unit_group_total: number;
|
|
865
|
+
group_subtotal: number;
|
|
866
|
+
group_discount: number;
|
|
867
|
+
group_tax_total: number;
|
|
868
|
+
group_total: number;
|
|
869
|
+
}[];
|
|
754
870
|
redeem: OrderRedeem[];
|
|
755
|
-
redemption_steps: OrderRedemptionStep[];
|
|
756
|
-
currency: string;
|
|
757
|
-
}) => {
|
|
758
|
-
lines: OrderLine[];
|
|
759
|
-
redemption_steps: OrderRedemptionStep[];
|
|
760
|
-
totals: import("@fire-spark/types").OrderTotals;
|
|
761
871
|
};
|
|
872
|
+
/** Every redeem of the order after `capRedeems`, ready for tenders. */
|
|
873
|
+
declare const cappedRedeems: (order: CapOrder) => {
|
|
874
|
+
reward_id: string;
|
|
875
|
+
quantity: number;
|
|
876
|
+
before_taxes?: boolean | undefined;
|
|
877
|
+
expires_at?: string | undefined;
|
|
878
|
+
payment_id: string;
|
|
879
|
+
amount: number;
|
|
880
|
+
}[];
|
|
881
|
+
type SimpleTenderPayment = {
|
|
882
|
+
id?: string;
|
|
883
|
+
type?: PaymentTenderInput["method"];
|
|
884
|
+
provider?: PaymentProvider;
|
|
885
|
+
collect_at?: PaymentCollectAt$1;
|
|
886
|
+
};
|
|
887
|
+
//#endregion
|
|
888
|
+
//#region src/order/redemptions.d.ts
|
|
889
|
+
/**
|
|
890
|
+
* Money the redeems cover (Σ `amount`): the discount the customer sees.
|
|
891
|
+
* It is paid by REDEMPTION tenders, so it is never subtracted from line
|
|
892
|
+
* or order totals.
|
|
893
|
+
*/
|
|
894
|
+
declare const redeemedTotal: (redeem?: readonly RedeemLike[] | null) => number;
|
|
895
|
+
/** Redeemed money of every redeem of the order (order + root lines). */
|
|
896
|
+
declare const orderRedeemedTotal: (order: RedeemSource<RedeemLike>) => number;
|
|
897
|
+
/**
|
|
898
|
+
* What the customer pays with another method:
|
|
899
|
+
* `totals.total − Σ redeem amounts` (order + root lines), never below 0.
|
|
900
|
+
*/
|
|
901
|
+
declare const orderPayableTotal: (order: RedeemSource<RedeemLike> & {
|
|
902
|
+
totals: {
|
|
903
|
+
total: number;
|
|
904
|
+
};
|
|
905
|
+
}) => number;
|
|
906
|
+
/**
|
|
907
|
+
* What the customer pays for a root line with another method:
|
|
908
|
+
* `group_total − Σ line.redeem[].amount`, never below 0.
|
|
909
|
+
*/
|
|
910
|
+
declare const linePayableTotal: (line: OrderLine) => number;
|
|
911
|
+
/**
|
|
912
|
+
* Root group money rebuilt from the line itself plus its children. Legacy
|
|
913
|
+
* orders carried their redeems in the root's group money; rebuilding drops
|
|
914
|
+
* it so line money stays full.
|
|
915
|
+
*/
|
|
916
|
+
declare const rebuildRootGroups: (lines: OrderLine[]) => OrderLine[];
|
|
917
|
+
type StepOrder = Parameters<typeof fitRedeems>[0];
|
|
918
|
+
/**
|
|
919
|
+
* One step per redeem with a `payment_id`, in the order `fitRedeems`
|
|
920
|
+
* applies them: root-line redeems in line order, then order redeems.
|
|
921
|
+
* `discount_amount` is the capped `amount`, so the steps of a `payment_id`
|
|
922
|
+
* add up to its REDEMPTION tender and the line steps to the discount shown
|
|
923
|
+
* on the line. Lines, taxes and totals keep their full value; `value` is
|
|
924
|
+
* what the customer's method still pays.
|
|
925
|
+
*/
|
|
926
|
+
declare const redemptionSteps: (order: StepOrder) => OrderRedemptionStep[];
|
|
762
927
|
//#endregion
|
|
763
928
|
//#region src/order/totals.d.ts
|
|
764
929
|
/** Sum root line group totals into order totals (Big.js). */
|
|
@@ -772,24 +937,6 @@ declare const setLineQuantity: (lines: OrderLine[], lineUid: string, quantity: n
|
|
|
772
937
|
/** Drop a root subtree, then add the replacement tree (may merge by fingerprint). */
|
|
773
938
|
declare const replaceLine: (lines: OrderLine[], lineUid: string, next: OrderLine | OrderLine[]) => OrderLine[];
|
|
774
939
|
//#endregion
|
|
775
|
-
//#region src/order/tenders.d.ts
|
|
776
|
-
/**
|
|
777
|
-
* Digital tender the SDK charges (`DEVICE`, §7.3). `KIOSK`, `COUNTER`,
|
|
778
|
-
* `DOOR` and `OTHER` are in person: the POS, an operator or the courier
|
|
779
|
-
* collects them (§12).
|
|
780
|
-
*/
|
|
781
|
-
declare const isDeviceCharged: (tender: {
|
|
782
|
-
collect_at: string;
|
|
783
|
-
}) => boolean;
|
|
784
|
-
/** Most a REDEMPTION can cover: order total − tip − delivery (D18). */
|
|
785
|
-
declare const redemptionCap: (order: Pick<Order$1, "lines" | "totals">) => number;
|
|
786
|
-
type SimpleTenderPayment = {
|
|
787
|
-
id?: string;
|
|
788
|
-
type?: PaymentTenderInput["method"];
|
|
789
|
-
provider?: PaymentProvider;
|
|
790
|
-
collect_at?: PaymentCollectAt$1;
|
|
791
|
-
};
|
|
792
|
-
//#endregion
|
|
793
940
|
//#region src/services/availability.d.ts
|
|
794
941
|
declare const getAvailability: (scope?: StorefrontMenuScope, options?: ServiceHttpOptions) => Promise<StorefrontAvailability>;
|
|
795
942
|
//#endregion
|
|
@@ -1142,6 +1289,8 @@ declare class RulesEngine {
|
|
|
1142
1289
|
private assertBoolean;
|
|
1143
1290
|
private assertCurrency;
|
|
1144
1291
|
private assertEnum;
|
|
1292
|
+
private customerAge;
|
|
1293
|
+
private customerDate;
|
|
1145
1294
|
private assertAbsoluteDate;
|
|
1146
1295
|
private assertRelativeDate;
|
|
1147
1296
|
private assertRecurringDate;
|
|
@@ -1316,4 +1465,4 @@ declare const validateCardholderName: (value: string) => CardholderNameError | n
|
|
|
1316
1465
|
*/
|
|
1317
1466
|
declare const cardPreviewGroups: (value: string) => CardPreviewSlot[][];
|
|
1318
1467
|
//#endregion
|
|
1319
|
-
export { type ApplyRedeemInput, type AuthConfigureOptions, CARD_BRANDS, 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, type ExchangeOptions, type FailedCharge, type FlatMenuCategory, type GroupDisplayType, type IdBuilder, type ListMenusStreamOptions, type ListPaymentsOptions, 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 PayIntentOptions, type PayIntentResult, type PayOptions, type PaymentCardBrand, type PaymentProgressEvent, type PaymentProgressListener, type PaymentRunOptions, type PaymentSessionOptions, type PricingModifier, type Product, type ProductCtx, type QuantitiesByPath, type RecommendationType, RecurringDateCron, type RemoveRedeemInput, type ReorderOrderOptions, type ResetOptions, type ReversalOutcome, type ReverseAllOptions, RulesEngine, type ScheduleWindow, type SelectionStatus, type SelectionsByPath, type SerializedError, type ServiceHttpOptions, type SimpleTenderPayment, type Snapshot, type StorefrontAccessToken, type StorefrontErrorDetails, StorefrontHttpError, type TrackWorkflow, type ValidateOptions, type ValidateOrderAgainstMenuInput, type Variant, type VariantGroup, type VariantGroupCtx, type VariantOptionCtx, type VariantSelection, type VerifyWebhookSignatureInput, type VisitedState, addLines, auth, buildCustomerSnapshot, cardBrandSpec, cardDigits, cardNumberGaps, cardNumberMaxLength, cardPreviewGroups, caretAfterDigits, collectOrderLineDiffs, computeStartingPrice, countCartProducts, coveredAmount, createSession, currentNodes, cvcMaxLength, defaultConditionError, detectCardBrand, flattenMenuCategories, flushLogs, formatCardNumber, formatCvc, formatExpiry, fromOrderLines, genId, genOrderId, getLogContext, getScheduleWindow, indexMenu, isCardNumberComplete, isCardNumberDefinitelyInvalid, isCheckoutFieldFilled, isCvcComplete, isDeviceCharged, isDeviceNotLinked, isExpiryComplete, isKioskUnauthorized, isMilestoneStepDone, isOnSchedule, isOrderValidationError, isPosDeviceNotLinked, isPosUnauthorized, isRealPaymentMethod, isStorefrontNotFound, isVariantBase, listMenusStream, localizePosError, log, logError, luhnCheck, matchAbsoluteDateOperator, matchBooleanOperator, matchCurrencyOperator, matchEnumOperator, matchNumberOperator, matchRecurringDateOperator, matchRelativeDateOperator, matchStringOperator, milestoneSteps, milestoneTrack, nestMenuCategories, normalizeCardholderName,
|
|
1468
|
+
export { type ApplyRedeemInput, type AuthConfigureOptions, CARD_BRANDS, 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, type ExchangeOptions, type FailedCharge, type FlatMenuCategory, type GroupDisplayType, type IdBuilder, type ListMenusStreamOptions, type ListPaymentsOptions, 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, OrderPaymentRequiredError, type OrderScope, OrderSyncPendingError, OrderSyncRejectedError, OrderValidationError, type OrderValidationResult, type PayIntentOptions, type PayIntentResult, type PayOptions, type PaymentCardBrand, type PaymentProgressEvent, type PaymentProgressListener, type PaymentRunOptions, type PaymentSessionOptions, type PricingModifier, type Product, type ProductCtx, type QuantitiesByPath, type RecommendationType, RecurringDateCron, type RedeemPaymentRow, type RemoveRedeemInput, type ReorderOrderOptions, type ResetOptions, type ReversalOutcome, type ReverseAllOptions, RulesEngine, type ScheduleWindow, type SelectionStatus, type SelectionsByPath, type SerializedError, type ServiceHttpOptions, type SimpleTenderPayment, type Snapshot, type StorefrontAccessToken, type StorefrontErrorDetails, StorefrontHttpError, type TrackWorkflow, type ValidateOptions, type ValidateOrderAgainstMenuInput, type Variant, type VariantGroup, type VariantGroupCtx, type VariantOptionCtx, type VariantSelection, type VerifyWebhookSignatureInput, type VisitedState, addLines, auth, buildCustomerSnapshot, capRedeems, cappedRedeems, cardBrandSpec, cardDigits, cardNumberGaps, cardNumberMaxLength, cardPreviewGroups, caretAfterDigits, collectOrderLineDiffs, computeStartingPrice, countCartProducts, coveredAmount, createSession, currentNodes, cvcMaxLength, defaultConditionError, detectCardBrand, fitRedeems, flattenMenuCategories, flushLogs, formatCardNumber, formatCvc, formatExpiry, fromOrderLines, genId, genOrderId, getLogContext, getScheduleWindow, indexMenu, isCardNumberComplete, isCardNumberDefinitelyInvalid, isCheckoutFieldFilled, isCvcComplete, isDeviceCharged, isDeviceNotLinked, isExpiryComplete, isKioskUnauthorized, isMilestoneStepDone, isOnSchedule, isOrderPaymentRequiredError, isOrderValidationError, isPosDeviceNotLinked, isPosUnauthorized, isRealPaymentMethod, isStorefrontNotFound, isVariantBase, linePayableTotal, listMenusStream, localizePosError, log, logError, luhnCheck, matchAbsoluteDateOperator, matchBooleanOperator, matchCurrencyOperator, matchEnumOperator, matchNumberOperator, matchRecurringDateOperator, matchRelativeDateOperator, matchStringOperator, milestoneSteps, milestoneTrack, nestMenuCategories, normalizeCardholderName, orderPayableTotal, orderRedeemedTotal, orderRedeems, parseExpiry, paymentMatchesClientConditions, rebuildRootGroups, recomputeTotals, redeemedTotal, redemptionCap, redemptionSteps, remainingAmount, removeLine, replaceLine, resolveCheckout, reversePayment, runPaymentAttempt, selectablePayments, serializeError, services, setLineQuantity, storefrontJson, toOrderLines, toPaymentCardBrand, validateCardNumber, validateCardholderName, validateCvc, validateExpiry, validateOrderAgainstMenu, verifyWebhookSignature, visitedStates };
|