@fire-spark/core 0.12.5 → 0.13.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 +32 -2
- package/dist/index.js +129 -10
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -216,8 +216,32 @@ type OrderCustomerSource = {
|
|
|
216
216
|
email?: string | null;
|
|
217
217
|
phone?: string | null;
|
|
218
218
|
};
|
|
219
|
+
/**
|
|
220
|
+
* Stand-ins the order schema needs while a guest's contact data is unknown.
|
|
221
|
+
* Only valid when the merchant's `anonymous_customer` field is optional or
|
|
222
|
+
* hidden; the API rejects them on required fields (`CUSTOMER_FIELD_REQUIRED`).
|
|
223
|
+
*/
|
|
224
|
+
declare const CUSTOMER_INFO_PLACEHOLDERS: {
|
|
225
|
+
readonly email: "unknown@example.com";
|
|
226
|
+
readonly phone: "+10000000000";
|
|
227
|
+
};
|
|
219
228
|
/** Builds the order `customer` snapshot sent on create/update. */
|
|
220
229
|
declare const buildCustomerSnapshot: (source: OrderCustomerSource) => Order$1["customer"];
|
|
230
|
+
/**
|
|
231
|
+
* True when `value` is a stand-in, not data the guest typed: the
|
|
232
|
+
* placeholders above, or a name equal to the anonymous customer id.
|
|
233
|
+
*/
|
|
234
|
+
declare const isCustomerInfoPlaceholder: (key: string, value: unknown, customerId?: string | null) => boolean;
|
|
235
|
+
/** A `customer_info` field holds real (non-placeholder) guest data. */
|
|
236
|
+
declare const isCustomerInfoFieldFilled: (info: Record<string, unknown> | null | undefined, key: string, customerId?: string | null) => boolean;
|
|
237
|
+
/** Strips spaces, dashes, dots and parentheses: "+593 99-123" → "+59399123". */
|
|
238
|
+
declare const normalizeCustomerPhone: (value: string) => string;
|
|
239
|
+
/**
|
|
240
|
+
* Format check the order schema enforces on `customer_info`: email shape and
|
|
241
|
+
* E.164 phone (`+593991234567`). Empty values are valid (presence is checked
|
|
242
|
+
* against the merchant's `anonymous_customer` modes instead).
|
|
243
|
+
*/
|
|
244
|
+
declare const isCustomerInfoValueValid: (key: string, value: string) => boolean;
|
|
221
245
|
//#endregion
|
|
222
246
|
//#region src/services/http.d.ts
|
|
223
247
|
type ServiceHttpOptions = {
|
|
@@ -620,6 +644,8 @@ declare class Order {
|
|
|
620
644
|
setCustomerDetails(details: {
|
|
621
645
|
address_info?: Order$1["customer"]["address_info"];
|
|
622
646
|
billing_info?: Order$1["customer"]["billing_info"];
|
|
647
|
+
/** Guest contact data (anonymous checkout); blanks keep the snapshot. */
|
|
648
|
+
customer_info?: Partial<Order$1["customer"]["customer_info"]>;
|
|
623
649
|
}): void;
|
|
624
650
|
cancelOrder(): Promise<void>;
|
|
625
651
|
/**
|
|
@@ -824,7 +850,7 @@ declare const isOrderPaymentRequiredError: (error: unknown) => error is OrderPay
|
|
|
824
850
|
//#endregion
|
|
825
851
|
//#region src/order/validate.d.ts
|
|
826
852
|
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;
|
|
827
|
-
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";
|
|
853
|
+
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" | "CUSTOMER_FIELD_REQUIRED" | "DAILY_ORDER_LIMIT_REACHED";
|
|
828
854
|
type OrderLineIssue = {
|
|
829
855
|
code: OrderLineIssueCode;
|
|
830
856
|
field?: string;
|
|
@@ -1571,6 +1597,10 @@ interface CheckoutSection {
|
|
|
1571
1597
|
interface CheckoutPreferences {
|
|
1572
1598
|
shipping: CheckoutSection;
|
|
1573
1599
|
billing: CheckoutSection;
|
|
1600
|
+
/** Missing on orders stamped before the setting existed → defaults. */
|
|
1601
|
+
anonymous_customer?: {
|
|
1602
|
+
fields: Record<string, CheckoutMode>;
|
|
1603
|
+
};
|
|
1574
1604
|
}
|
|
1575
1605
|
declare const isCheckoutFieldFilled: (info: Record<string, unknown> | null | undefined, key: string) => boolean;
|
|
1576
1606
|
interface CheckoutOrderInput {
|
|
@@ -1675,4 +1705,4 @@ declare const validateCardholderName: (value: string) => CardholderNameError | n
|
|
|
1675
1705
|
*/
|
|
1676
1706
|
declare const cardPreviewGroups: (value: string) => CardPreviewSlot[][];
|
|
1677
1707
|
//#endregion
|
|
1678
|
-
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 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, type OrderCancelInput, type OrderCancelOptions, type OrderCancelResult, type OrderCancelType, type OrderCustomerSource, type OrderDeviceCredential, 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, 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, isCvcComplete, isDeviceCharged, isDeviceNotLinked, isExpiryComplete, isGenId, 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, resolveModifierImageUrl, reversePayment, runPaymentAttempt, selectablePayments, serializeError, services, setLineQuantity, storefrontJson, toOrderLines, toPaymentCardBrand, validateCardNumber, validateCardholderName, validateCvc, validateExpiry, validateOrderAgainstMenu, verifyWebhookSignature, visitedStates };
|
|
1708
|
+
export { type ApplyRedeemInput, type AuthConfigureOptions, 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, 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, type OrderCancelInput, type OrderCancelOptions, type OrderCancelResult, type OrderCancelType, type OrderCustomerSource, type OrderDeviceCredential, 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, 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, isDeviceCharged, isDeviceNotLinked, isExpiryComplete, isGenId, 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, normalizeCustomerPhone, orderPayableTotal, orderRedeemedTotal, orderRedeems, parseExpiry, paymentMatchesClientConditions, rebuildRootGroups, recomputeTotals, redeemedTotal, redemptionCap, redemptionSteps, remainingAmount, removeLine, replaceLine, resolveCheckout, resolveModifierImageUrl, reversePayment, runPaymentAttempt, selectablePayments, serializeError, services, setLineQuantity, storefrontJson, toOrderLines, toPaymentCardBrand, validateCardNumber, validateCardholderName, validateCvc, validateExpiry, validateOrderAgainstMenu, verifyWebhookSignature, visitedStates };
|
package/dist/index.js
CHANGED
|
@@ -1965,6 +1965,15 @@ const auth = {
|
|
|
1965
1965
|
};
|
|
1966
1966
|
//#endregion
|
|
1967
1967
|
//#region src/order/customer.ts
|
|
1968
|
+
/**
|
|
1969
|
+
* Stand-ins the order schema needs while a guest's contact data is unknown.
|
|
1970
|
+
* Only valid when the merchant's `anonymous_customer` field is optional or
|
|
1971
|
+
* hidden; the API rejects them on required fields (`CUSTOMER_FIELD_REQUIRED`).
|
|
1972
|
+
*/
|
|
1973
|
+
const CUSTOMER_INFO_PLACEHOLDERS = {
|
|
1974
|
+
email: "unknown@example.com",
|
|
1975
|
+
phone: "+10000000000"
|
|
1976
|
+
};
|
|
1968
1977
|
const splitName = (name) => {
|
|
1969
1978
|
const parts = name.trim().split(/\s+/).filter(Boolean);
|
|
1970
1979
|
const first_name = parts[0] ?? name;
|
|
@@ -1977,14 +1986,108 @@ const splitName = (name) => {
|
|
|
1977
1986
|
/** Builds the order `customer` snapshot sent on create/update. */
|
|
1978
1987
|
const buildCustomerSnapshot = (source) => {
|
|
1979
1988
|
const names = splitName(source.name);
|
|
1989
|
+
const email = source.email || CUSTOMER_INFO_PLACEHOLDERS.email;
|
|
1990
|
+
const phone = source.phone || CUSTOMER_INFO_PLACEHOLDERS.phone;
|
|
1980
1991
|
return { customer_info: {
|
|
1981
1992
|
display_name: names.display_name,
|
|
1982
1993
|
first_name: names.first_name,
|
|
1983
1994
|
last_name: names.last_name,
|
|
1984
|
-
email
|
|
1985
|
-
phone
|
|
1995
|
+
email,
|
|
1996
|
+
phone
|
|
1986
1997
|
} };
|
|
1987
1998
|
};
|
|
1999
|
+
/**
|
|
2000
|
+
* True when `value` is a stand-in, not data the guest typed: the
|
|
2001
|
+
* placeholders above, or a name equal to the anonymous customer id.
|
|
2002
|
+
*/
|
|
2003
|
+
const isCustomerInfoPlaceholder = (key, value, customerId) => {
|
|
2004
|
+
if (typeof value !== "string") return false;
|
|
2005
|
+
const text = value.trim();
|
|
2006
|
+
if (key === "email") return text === CUSTOMER_INFO_PLACEHOLDERS.email;
|
|
2007
|
+
if (key === "phone") return text === CUSTOMER_INFO_PLACEHOLDERS.phone;
|
|
2008
|
+
if ((key === "first_name" || key === "last_name") && customerId) return text === customerId;
|
|
2009
|
+
return false;
|
|
2010
|
+
};
|
|
2011
|
+
/** A `customer_info` field holds real (non-placeholder) guest data. */
|
|
2012
|
+
const isCustomerInfoFieldFilled = (info, key, customerId) => {
|
|
2013
|
+
let value = info?.[key];
|
|
2014
|
+
const metadata = info?.metadata;
|
|
2015
|
+
if (value == null && metadata && typeof metadata === "object" && !Array.isArray(metadata)) value = metadata[key];
|
|
2016
|
+
if (value == null) return false;
|
|
2017
|
+
if (typeof value === "string" && !value.trim()) return false;
|
|
2018
|
+
return !isCustomerInfoPlaceholder(key, value, customerId);
|
|
2019
|
+
};
|
|
2020
|
+
const EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
2021
|
+
const PHONE_RE = /^\+[1-9]\d{1,14}$/;
|
|
2022
|
+
/** Strips spaces, dashes, dots and parentheses: "+593 99-123" → "+59399123". */
|
|
2023
|
+
const normalizeCustomerPhone = (value) => {
|
|
2024
|
+
return value.trim().replace(/[\s\-().]/g, "");
|
|
2025
|
+
};
|
|
2026
|
+
/**
|
|
2027
|
+
* Format check the order schema enforces on `customer_info`: email shape and
|
|
2028
|
+
* E.164 phone (`+593991234567`). Empty values are valid (presence is checked
|
|
2029
|
+
* against the merchant's `anonymous_customer` modes instead).
|
|
2030
|
+
*/
|
|
2031
|
+
const isCustomerInfoValueValid = (key, value) => {
|
|
2032
|
+
const text = value.trim();
|
|
2033
|
+
if (!text) return true;
|
|
2034
|
+
if (key === "email") return EMAIL_RE.test(text);
|
|
2035
|
+
if (key === "phone") return PHONE_RE.test(normalizeCustomerPhone(text));
|
|
2036
|
+
return text.length <= 100;
|
|
2037
|
+
};
|
|
2038
|
+
/**
|
|
2039
|
+
* Merges guest contact data into `customer_info`; empty or malformed values
|
|
2040
|
+
* fall back to the current snapshot (placeholders for optional/hidden fields)
|
|
2041
|
+
* so a half-typed field never breaks the order sync.
|
|
2042
|
+
*/
|
|
2043
|
+
const mergeCustomerInfo = (current, patch) => {
|
|
2044
|
+
const clean = (value, key = "") => {
|
|
2045
|
+
let text = value?.trim();
|
|
2046
|
+
if (text && key === "phone") text = normalizeCustomerPhone(text);
|
|
2047
|
+
if (!text || !isCustomerInfoValueValid(key, text)) return void 0;
|
|
2048
|
+
return text;
|
|
2049
|
+
};
|
|
2050
|
+
const first_name = clean(patch.first_name) ?? current.first_name;
|
|
2051
|
+
const last_name = clean(patch.last_name) ?? current.last_name;
|
|
2052
|
+
const email = clean(patch.email, "email") ?? current.email;
|
|
2053
|
+
const phone = clean(patch.phone, "phone") ?? current.phone;
|
|
2054
|
+
const typedName = clean(patch.first_name) || clean(patch.last_name);
|
|
2055
|
+
let display_name = current.display_name;
|
|
2056
|
+
if (typedName) display_name = `${first_name} ${last_name}`.trim();
|
|
2057
|
+
const b1 = {
|
|
2058
|
+
display_name,
|
|
2059
|
+
first_name,
|
|
2060
|
+
last_name,
|
|
2061
|
+
email,
|
|
2062
|
+
phone
|
|
2063
|
+
};
|
|
2064
|
+
if (!patch.metadata) return {
|
|
2065
|
+
...current,
|
|
2066
|
+
...b1
|
|
2067
|
+
};
|
|
2068
|
+
const metadata = mergeCustomMetadata(current.metadata, patch.metadata);
|
|
2069
|
+
const { metadata: _drop, ...rest } = current;
|
|
2070
|
+
if (metadata === void 0) return {
|
|
2071
|
+
...rest,
|
|
2072
|
+
...b1
|
|
2073
|
+
};
|
|
2074
|
+
return {
|
|
2075
|
+
...rest,
|
|
2076
|
+
...b1,
|
|
2077
|
+
metadata
|
|
2078
|
+
};
|
|
2079
|
+
};
|
|
2080
|
+
/** Custom guest fields: non-empty text is set, blanks remove the key. */
|
|
2081
|
+
const mergeCustomMetadata = (current, patch) => {
|
|
2082
|
+
const next = { ...current };
|
|
2083
|
+
for (const [key, value] of Object.entries(patch)) {
|
|
2084
|
+
const text = typeof value === "string" ? value.trim() : value;
|
|
2085
|
+
const valid = typeof text !== "string" || isCustomerInfoValueValid(key, text);
|
|
2086
|
+
if (text == null || text === "" || !valid) delete next[key];
|
|
2087
|
+
else next[key] = text;
|
|
2088
|
+
}
|
|
2089
|
+
return Object.keys(next).length > 0 ? next : void 0;
|
|
2090
|
+
};
|
|
1988
2091
|
//#endregion
|
|
1989
2092
|
//#region src/logs/limits.ts
|
|
1990
2093
|
/** Mirrors the API limits so oversized logs are trimmed, not rejected. */
|
|
@@ -6011,15 +6114,21 @@ var Order = class Order {
|
|
|
6011
6114
|
}
|
|
6012
6115
|
setCustomerDetails(details) {
|
|
6013
6116
|
if (this.deleted) return;
|
|
6117
|
+
let customer_info = this.draft.customer.customer_info;
|
|
6118
|
+
if (details.customer_info) customer_info = mergeCustomerInfo(customer_info, details.customer_info);
|
|
6014
6119
|
const hasAddressInfo = details.address_info !== void 0;
|
|
6015
6120
|
const hasBillingInfo = details.billing_info !== void 0;
|
|
6016
6121
|
const address_info = !hasAddressInfo ? this.draft.customer.address_info : details.address_info;
|
|
6017
6122
|
const billing_info = !hasBillingInfo ? this.draft.customer.billing_info : details.billing_info;
|
|
6018
|
-
const
|
|
6019
|
-
|
|
6123
|
+
const c1 = {
|
|
6124
|
+
customer_info,
|
|
6020
6125
|
address_info,
|
|
6021
6126
|
billing_info
|
|
6022
6127
|
};
|
|
6128
|
+
const customer = {
|
|
6129
|
+
...this.draft.customer,
|
|
6130
|
+
...c1
|
|
6131
|
+
};
|
|
6023
6132
|
this.draft = {
|
|
6024
6133
|
...this.draft,
|
|
6025
6134
|
customer
|
|
@@ -9532,6 +9641,13 @@ const DEFAULT_BILLING_FIELDS = {
|
|
|
9532
9641
|
tax_id: "required",
|
|
9533
9642
|
tax_id_type: "required"
|
|
9534
9643
|
};
|
|
9644
|
+
/** Guest contact fields → `customer.customer_info` (anonymous orders). */
|
|
9645
|
+
const DEFAULT_CUSTOMER_FIELDS = {
|
|
9646
|
+
email: "required",
|
|
9647
|
+
first_name: "required",
|
|
9648
|
+
last_name: "required",
|
|
9649
|
+
phone: "required"
|
|
9650
|
+
};
|
|
9535
9651
|
const getCheckoutFieldValue = (info, key) => {
|
|
9536
9652
|
if (!info) return void 0;
|
|
9537
9653
|
const top = info[key];
|
|
@@ -9561,7 +9677,8 @@ const defaultCheckoutPreferences = {
|
|
|
9561
9677
|
billing: {
|
|
9562
9678
|
fields: DEFAULT_BILLING_FIELDS,
|
|
9563
9679
|
rules: [fallbackRequired]
|
|
9564
|
-
}
|
|
9680
|
+
},
|
|
9681
|
+
anonymous_customer: { fields: DEFAULT_CUSTOMER_FIELDS }
|
|
9565
9682
|
};
|
|
9566
9683
|
const factsFromOrder = (order) => {
|
|
9567
9684
|
const brand_id = order.brand_id ?? void 0;
|
|
@@ -9616,13 +9733,15 @@ const resolveCheckout = (order, options) => {
|
|
|
9616
9733
|
let shipping = "hidden";
|
|
9617
9734
|
if (ships) shipping = resolveSection(checkout.shipping, engine);
|
|
9618
9735
|
const billing = resolveSection(checkout.billing, engine);
|
|
9619
|
-
const
|
|
9620
|
-
|
|
9736
|
+
const f1 = {
|
|
9737
|
+
shippingFields: checkout.shipping.fields ?? DEFAULT_SHIPPING_FIELDS,
|
|
9738
|
+
billingFields: checkout.billing.fields ?? DEFAULT_BILLING_FIELDS,
|
|
9739
|
+
customerFields: checkout.anonymous_customer?.fields ?? DEFAULT_CUSTOMER_FIELDS
|
|
9740
|
+
};
|
|
9621
9741
|
return {
|
|
9622
9742
|
shipping,
|
|
9623
9743
|
billing,
|
|
9624
|
-
|
|
9625
|
-
billingFields
|
|
9744
|
+
...f1
|
|
9626
9745
|
};
|
|
9627
9746
|
};
|
|
9628
9747
|
//#endregion
|
|
@@ -9961,4 +10080,4 @@ const cardPreviewGroups = (value) => {
|
|
|
9961
10080
|
return groups;
|
|
9962
10081
|
};
|
|
9963
10082
|
//#endregion
|
|
9964
|
-
export { CARD_BRANDS, DEFAULT_RECOMMENDATION_TYPES, ID_HASH_FORMATS, Order, OrderPaymentRequiredError, OrderSyncPendingError, OrderSyncRejectedError, OrderValidationError, RecurringDateCron, RulesEngine, StorefrontHttpError, addLines, auth, buildCustomerSnapshot, 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, isCvcComplete, isDeviceCharged, isDeviceNotLinked, isExpiryComplete, isGenId, 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, resolveModifierImageUrl, reversePayment, runPaymentAttempt, selectablePayments, serializeError, services, setLineQuantity, storefrontJson, toOrderLines, toPaymentCardBrand, validateCardNumber, validateCardholderName, validateCvc, validateExpiry, validateOrderAgainstMenu, verifyWebhookSignature, visitedStates };
|
|
10083
|
+
export { CARD_BRANDS, CUSTOMER_INFO_PLACEHOLDERS, DEFAULT_RECOMMENDATION_TYPES, ID_HASH_FORMATS, Order, OrderPaymentRequiredError, OrderSyncPendingError, OrderSyncRejectedError, OrderValidationError, RecurringDateCron, RulesEngine, StorefrontHttpError, addLines, auth, buildCustomerSnapshot, 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, isDeviceCharged, isDeviceNotLinked, isExpiryComplete, isGenId, 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, normalizeCustomerPhone, orderPayableTotal, orderRedeemedTotal, orderRedeems, parseExpiry, paymentMatchesClientConditions, rebuildRootGroups, recomputeTotals, redeemedTotal, redemptionCap, redemptionSteps, remainingAmount, removeLine, replaceLine, resolveCheckout, resolveModifierImageUrl, reversePayment, runPaymentAttempt, selectablePayments, serializeError, services, setLineQuantity, storefrontJson, toOrderLines, toPaymentCardBrand, validateCardNumber, validateCardholderName, validateCvc, validateExpiry, validateOrderAgainstMenu, verifyWebhookSignature, visitedStates };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fire-spark/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.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.13.0",
|
|
24
|
+
"@fire-spark/types": "^0.13.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"tsdown": "^0.22.14",
|