@fire-spark/core 0.52.0 → 0.53.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 +31 -6
- package/dist/index.js +271 -1
- 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, isDeliveryFee, isRealPaymentMethod, orderRedeems } from "@fire-spark/payments";
|
|
2
|
-
import { AndConditions, ApplyFeesInput, ApplyFeesOrderScope, CheckoutMode, CheckoutResolved, CmsBlock, Condition, Customer, CustomerIdentifyInput, CustomerRegisterInput, CustomerUpdateInput, DeviceSecretStorage, DeviceSecretsConfigureOptions, DeviceSecretsConfigureOptions as DeviceSecretsConfigureOptions$1, DeviceSecretsPayload, DeviceSecretsPayload as DeviceSecretsPayload$1, Fee, Fulfillment, FulfillmentEligibilityInput, FulfillmentEligibilityInput as FulfillmentEligibilityInput$1, FulfillmentListInput, GroupDisplayType, KioskDeviceConfig, KioskDeviceConfigInput, KioskDeviceOverrides, KioskHealthBatchInput, KioskHealthBatchResult, KioskHeartbeatInput, KioskHeartbeatResult, KioskPickupNameRules, KioskRealtimeToken, LocalServerConfig, LocalServerConfig as LocalServerConfig$1, LocalServerHealthResult, LocalServerHealthResult as LocalServerHealthResult$1, 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, OrderAdvanceFulfillmentInput, OrderCancelInput, OrderCancelInput as OrderCancelInput$1, OrderCancelType, OrderCancelType as OrderCancelType$1, OrderDeviceListInput, OrderDeviceListResult, OrderFulfillment, OrderFulfillmentWorkflow, OrderFulfillmentWorkflowEdge, OrderFulfillmentWorkflowNode, OrderInsertInput, OrderLine, OrderListInput, OrderRateInput, OrderRating, OrderRecord, OrderRecordPaymentInput, OrderRedeem, OrderRedemptionStep, OrderReorderInput, OrderRouteKind, OrderRouteKind as OrderRouteKind$1, OrderRouteStatus, OrderRoutes, OrderRoutes as OrderRoutes$1, OrderSetCustomerInput, OrderTotals, OrderUpdateInput, OrderValidateInput, OrderValidateOutput, PaymentCollectAt as PaymentCollectAt$1, PaymentEligibilityInput, PaymentEligibilityInput as PaymentEligibilityInput$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, ProductRewardSavings, Recommendation, RecurringDateCronFormatter, RecurringDateCronResult, RecurringDateCronSummary, RecurringDateCronValues, RouteEligibility, RouteEligibility as RouteEligibility$1, RouteEligibilityDetail, RouteEligibilityFlags, RouteEligibilityReason, RouteFailureKind, RouteFailureKind as RouteFailureKind$1, RouteHealthEvent, RouteHealthEvent as RouteHealthEvent$1, RouteHealthListener, RouteHealthListener as RouteHealthListener$1, 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, SwitchCustomerOptions, SwitchCustomerOptions as SwitchCustomerOptions$1, SwitchCustomerResult, SwitchCustomerResult as SwitchCustomerResult$1, TenderRefundInput, TenderReplaceInput, TenderVoidInput, Variant, VariantGroup, WordFilterCheckInput, WordFilterCheckResult } from "@fire-spark/types";
|
|
2
|
+
import { AndConditions, ApplyFeesInput, ApplyFeesOrderScope, CheckoutMode, CheckoutResolved, CmsBlock, Condition, Customer, CustomerIdentifyInput, CustomerRegisterInput, CustomerUpdateInput, DeviceSecretStorage, DeviceSecretsConfigureOptions, DeviceSecretsConfigureOptions as DeviceSecretsConfigureOptions$1, DeviceSecretsPayload, DeviceSecretsPayload as DeviceSecretsPayload$1, Fee, Fulfillment, FulfillmentEligibilityInput, FulfillmentEligibilityInput as FulfillmentEligibilityInput$1, FulfillmentListInput, GroupDisplayType, InvoiceCountryCode, InvoiceCountryDescriptor, KioskDeviceConfig, KioskDeviceConfigInput, KioskDeviceOverrides, KioskHealthBatchInput, KioskHealthBatchResult, KioskHeartbeatInput, KioskHeartbeatResult, KioskPickupNameRules, KioskRealtimeToken, LocalServerConfig, LocalServerConfig as LocalServerConfig$1, LocalServerHealthResult, LocalServerHealthResult as LocalServerHealthResult$1, 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, OrderAdvanceFulfillmentInput, OrderCancelInput, OrderCancelInput as OrderCancelInput$1, OrderCancelType, OrderCancelType as OrderCancelType$1, OrderDeviceListInput, OrderDeviceListResult, OrderFulfillment, OrderFulfillmentWorkflow, OrderFulfillmentWorkflowEdge, OrderFulfillmentWorkflowNode, OrderInsertInput, OrderLine, OrderListInput, OrderRateInput, OrderRating, OrderRecord, OrderRecordPaymentInput, OrderRedeem, OrderRedemptionStep, OrderReorderInput, OrderRouteKind, OrderRouteKind as OrderRouteKind$1, OrderRouteStatus, OrderRoutes, OrderRoutes as OrderRoutes$1, OrderSetCustomerInput, OrderTotals, OrderUpdateInput, OrderValidateInput, OrderValidateOutput, PaymentCollectAt as PaymentCollectAt$1, PaymentEligibilityInput, PaymentEligibilityInput as PaymentEligibilityInput$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, ProductRewardSavings, Recommendation, RecurringDateCronFormatter, RecurringDateCronResult, RecurringDateCronSummary, RecurringDateCronValues, RouteEligibility, RouteEligibility as RouteEligibility$1, RouteEligibilityDetail, RouteEligibilityFlags, RouteEligibilityReason, RouteFailureKind, RouteFailureKind as RouteFailureKind$1, RouteHealthEvent, RouteHealthEvent as RouteHealthEvent$1, RouteHealthListener, RouteHealthListener as RouteHealthListener$1, 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, SwitchCustomerOptions, SwitchCustomerOptions as SwitchCustomerOptions$1, SwitchCustomerResult, SwitchCustomerResult as SwitchCustomerResult$1, TaxBreakdownItem, TaxCategory, TaxIdValidationResult, 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. */
|
|
@@ -1285,6 +1285,7 @@ declare const capRedeems: <T extends CapOrder>(order: T) => T & {
|
|
|
1285
1285
|
}[];
|
|
1286
1286
|
quantity: number;
|
|
1287
1287
|
tax_rate: number | null;
|
|
1288
|
+
tax_category?: "EXEMPT" | "NOT_SUBJECT" | "STANDARD" | "ZERO" | undefined;
|
|
1288
1289
|
discount_rate: number;
|
|
1289
1290
|
unit_subtotal: number;
|
|
1290
1291
|
unit_discount: number;
|
|
@@ -2890,7 +2891,7 @@ declare const outgoingEdges: (workflow: OrderFulfillmentWorkflow, nodeId: string
|
|
|
2890
2891
|
channel_id: string;
|
|
2891
2892
|
brand_id: string;
|
|
2892
2893
|
primitive: "boolean";
|
|
2893
|
-
type: "Customer is anonymous" | "Is anonymous order" | "Is running local" | "Is running offline" | "Order includes product with tag" | "Order is scheduled" | "Payment captured" | "Payment is mixed";
|
|
2894
|
+
type: "Buyer identified" | "Customer is anonymous" | "Is anonymous order" | "Is running local" | "Is running offline" | "Order includes product with tag" | "Order is scheduled" | "Payment captured" | "Payment is mixed";
|
|
2894
2895
|
operator: "is" | "is not";
|
|
2895
2896
|
value: boolean;
|
|
2896
2897
|
invalidMessage?: string | undefined;
|
|
@@ -2999,7 +3000,7 @@ declare const incomingEdges: (workflow: OrderFulfillmentWorkflow, nodeId: string
|
|
|
2999
3000
|
channel_id: string;
|
|
3000
3001
|
brand_id: string;
|
|
3001
3002
|
primitive: "boolean";
|
|
3002
|
-
type: "Customer is anonymous" | "Is anonymous order" | "Is running local" | "Is running offline" | "Order includes product with tag" | "Order is scheduled" | "Payment captured" | "Payment is mixed";
|
|
3003
|
+
type: "Buyer identified" | "Customer is anonymous" | "Is anonymous order" | "Is running local" | "Is running offline" | "Order includes product with tag" | "Order is scheduled" | "Payment captured" | "Payment is mixed";
|
|
3003
3004
|
operator: "is" | "is not";
|
|
3004
3005
|
value: boolean;
|
|
3005
3006
|
invalidMessage?: string | undefined;
|
|
@@ -3108,7 +3109,7 @@ declare const defaultOutgoingEdge: (workflow: OrderFulfillmentWorkflow, nodeId:
|
|
|
3108
3109
|
channel_id: string;
|
|
3109
3110
|
brand_id: string;
|
|
3110
3111
|
primitive: "boolean";
|
|
3111
|
-
type: "Customer is anonymous" | "Is anonymous order" | "Is running local" | "Is running offline" | "Order includes product with tag" | "Order is scheduled" | "Payment captured" | "Payment is mixed";
|
|
3112
|
+
type: "Buyer identified" | "Customer is anonymous" | "Is anonymous order" | "Is running local" | "Is running offline" | "Order includes product with tag" | "Order is scheduled" | "Payment captured" | "Payment is mixed";
|
|
3112
3113
|
operator: "is" | "is not";
|
|
3113
3114
|
value: boolean;
|
|
3114
3115
|
invalidMessage?: string | undefined;
|
|
@@ -3363,7 +3364,7 @@ declare const resolveFailureTerminalEdge: (input: {
|
|
|
3363
3364
|
channel_id: string;
|
|
3364
3365
|
brand_id: string;
|
|
3365
3366
|
primitive: "boolean";
|
|
3366
|
-
type: "Customer is anonymous" | "Is anonymous order" | "Is running local" | "Is running offline" | "Order includes product with tag" | "Order is scheduled" | "Payment captured" | "Payment is mixed";
|
|
3367
|
+
type: "Buyer identified" | "Customer is anonymous" | "Is anonymous order" | "Is running local" | "Is running offline" | "Order includes product with tag" | "Order is scheduled" | "Payment captured" | "Payment is mixed";
|
|
3367
3368
|
operator: "is" | "is not";
|
|
3368
3369
|
value: boolean;
|
|
3369
3370
|
invalidMessage?: string | undefined;
|
|
@@ -4366,4 +4367,28 @@ declare const hpkeSeal: (input: HpkeSealInput) => Promise<{
|
|
|
4366
4367
|
/** Opens a sealed message; throws when anything was altered. */
|
|
4367
4368
|
declare const hpkeOpen: (input: HpkeOpenInput) => Promise<Uint8Array<ArrayBuffer>>;
|
|
4368
4369
|
//#endregion
|
|
4369
|
-
export { type AdvanceAndEnterConfig, type AdvanceAndEnterResult, type ApplyRedeemInput, type AuthConfigureOptions, type BuildRouteHttpInput, type BuildScheduleSlotsConfig, CALLBACK_MISSING_LOCAL_URL, CANONICAL_MAX_DEPTH, CANONICAL_MAX_EXPONENT, CARD_BRANDS, CUSTOMER_INFO_PLACEHOLDERS, type CallbackMissingLocalUrlDetails, type CanonicalInput, type CanonicalizationError, type CanonicalizationErrorCode, 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 ComputeProductRewardSavingsInput, type CreateOrderOptions, type CreateSessionOptions, type CustomizationPath, type CustomizationSession, DEFAULT_LOCALE, DEFAULT_MAX_INCOMPLETE_MINUTES, DEFAULT_MAX_SNAPSHOT_AGE_MS, DEFAULT_RECOMMENDATION_TYPES, DEFAULT_ROUTE_COOLDOWN_MS, DEFAULT_WEBHOOK_TIMEOUT_S, DelegatedSessionExpiredError, type DeunaCallbackUrls, type DeunaOrderStatus, type DeviceSecretStorage, type DeviceSecretsConfigureOptions, type DeviceSecretsPayload, type DeviceSecretsStore, type DispatchWebhooksConfig, type EngineCallbackRun, type EngineCallbackRunError, type EngineExecutionContext, type EngineFlagReviewInput, type EngineFulfillmentPatch, type EngineOrder, type EngineOrderChangedEvent, type EngineOrderFulfillment, type EngineOrderStatus, type EngineOrderStatusPatch, type EngineScope, type EngineStepLog, type EngineStepLogEntry, type EngineStepsLogs, type EngineWebhookEnvelope, type EngineWebhookFailureEvent, type EngineWebhookNodeRun, type EngineWebhookTarget, type EnterAndPauseResult, type EnterRunResult, type ExchangeOptions, FULFILLMENT_WORKFLOW_TERMINAL_STATUSES, type FailedCharge, type FinalizePlaceOrderConfig, type FiresparkOrigin, type FlatMenuCategory, type FulfillmentEligibilityInput, type FulfillmentExecutionPort, type FulfillmentPorts, type FulfillmentRunStatus, type FulfillmentStepName, type FulfillmentStoragePort, type FulfillmentTerminalOrderStatus, type GenOrderIdOptions, type GetCmsBlockOptions, type GroupDisplayType, HPKE_ALG, type HpkeAead, type HpkeEnvelope, type HpkeOpenInput, type HpkePrivateJwk, type HpkePublicJwk, type HpkeSealInput, ID_HASH_FORMATS, type IdBuilder, type IdHashFormat, type InvokeCallbackAttemptConfig, type InvokeCallbackAttemptResult, type ListMenusStreamOptions, type ListPaymentsOptions, type LocalDeviceCredentials, type LocalRouteProbeResult, type LocalServerConfig, type LocalServerHealthResult, LosslessNumber, type LosslessNumberLike, MAX_MAX_INCOMPLETE_MINUTES, MAX_SUPPORTED_WORKFLOW_SCHEMA_VERSION, MIN_MAX_INCOMPLETE_MINUTES, MODE_HINT_HEADER, type MarkRouteDownInput, type Menu, type MenuCategoryNode, type MenuLookup, type MilestoneSteps, type MilestoneTrackItem, type ModifierControlType, type ModifierCtx, type ModifierGroupCtx, type NestedMenuCategory, OFFLINE_NO_LOCAL_URL, ORIGIN_HEADER, 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 OrderRouteKind, type OrderRouteStatus, OrderRouteUnavailableError, type OrderRoutes, type OrderScope, OrderSyncPendingError, OrderSyncRejectedError, OrderValidationError, type OrderValidationResult, type OriginListener, type OriginState, type PauseForAdvanceConfig, type PayIntentOptions, type PayIntentResult, type PayOptions, type PaymentCardBrand, type PaymentEligibilityInput, type PaymentProgressEvent, type PaymentProgressListener, type PaymentRunOptions, type PaymentSessionOptions, type PendingWebhooks, PickupNameIssue, type PinnedFetchFactory, type PinnedFetchOptions, type PosOrderHttpOptions, type PricingModifier, type ProbeLocalRouteHealthOptions, type ProcessStateNodeCallbackJob, type ProcessStateNodeConfig, type ProcessStateNodeResult, type Product, type ProductCtx, type QuantitiesByPath, RESERVED_FULFILLMENT_STATUSES, REWARD_SAVINGS_METADATA_KEY, type RecommendationType, RecurringDateCron, type RedeemPaymentRow, type RemoveRedeemInput, type ReorderOrderOptions, type ResetOptions, type ResolveRouteEligibilityInput, type ResolvedPaymentEligibility, type ResumeFromAdvanceConfig, type ReversalOutcome, type ReverseAllOptions, type RouteEligibility, type RouteEligibilityDetail, type RouteEligibilityFlags, type RouteEligibilityReason, type RouteFailureClassification, type RouteFailureKind, type RouteHealthEvent, type RouteHealthListener, type RouteHealthSnapshot, type RouteTenderCandidate, RulesEngine, type RunNodeCallbacksResult, SCHEDULED_AT_ERROR_CODES, SCHEDULED_ORDER_MAX_HORIZON_HOURS, SCHEDULED_ORDER_MAX_HORIZON_MINUTES, SCHEDULED_ORDER_MIN_LEAD_MINUTES, SCHEDULED_ORDER_SLOT_MINUTES, SCHEDULED_STATUS, SDK_PAYMENT_ELIGIBILITY_CEILINGS, STATE_ALGO, STATE_HASH_PREFIX, type ScheduleSlot, type ScheduleSlotCart, type ScheduleSlotCartLine, type ScheduleWindow, type ScheduledSuccessorConfig, type SdkPaymentEligibility, type SelectionStatus, type SelectionsByPath, type SerializedError, type ServiceHttpOptions, type SimpleTenderPayment, type Snapshot, type StateGoldenRootVector, type StateGoldenVector, type StateGoldenVectors, type StateManifest, type StateManifestSection, type StateRootInput, type StateScope, type StateVectorFailure, type StepOutcome, type StorefrontAccessToken, type StorefrontErrorDetails, StorefrontHttpError, type SwitchCustomerArg, type SwitchCustomerIdToken, type SwitchCustomerOptions, type SwitchCustomerResult, TLS_FINGERPRINT_RESPONSE_HEADER, TLS_PIN_HEADER, type TestLocalServerHealthOptions, TlsFingerprintMismatchError, TokenExchangeError, type TrackWorkflow, type ValidateOptions, type ValidateOrderAgainstMenuInput, type Variant, type VariantGroup, type VariantGroupCtx, type VariantOptionCtx, type VariantSelection, type VerifyWebhookSignatureInput, type VisitedState, WORKFLOW_SCHEMA_VERSION, WORKFLOW_TIMEOUT, WorkflowSchemaVersionError, type WorkflowTimeoutDetails, addLines, advanceAndEnter, appendEngineStepLog, appendNodeLog, applyCmsVisibility, applyFees, applyManualAdvanceNote, applyRewardSavingsToLines, assertSupportedWorkflowSchemaVersion, auth, autoEnterSuccessTerminal, base64UrlDecode, base64UrlEncode, beginEngineStepLog, buildCustomerSnapshot, buildEngineCallbackError, buildEngineCallbackRun, buildRouteHttpOptions, buildRulesEngineFromOrder, buildScheduleSlots, buildWorkflowTimeoutDetails, callbackIdsFromNode, canEnterJoin, canPauseNow, cancelTypeOf, canonicalNumber, canonicalString, canonicalize, canonicalizeJson, capRedeems, cappedRedeems, cardBrandSpec, cardDigits, cardNumberGaps, cardNumberMaxLength, cardPreviewGroups, caretAfterDigits, certFingerprintsMatch, certMatchesAnyPin, classifyRouteFailure, clearDeviceSecrets, clearEdgeTaken, clearNodeVisit, cmsVisibilityNeedsTimezone, collectCheckoutIssues, collectOrderLineDiffs, completeEngineStepLog, computeOrderExpiresAt, computeProductRewardSavings, computeStartingPrice, configureDeviceSecrets, configureLocalTlsPinning, countCartProducts, coveredAmount, createCanonicalizationError, createDeunaWidgetApi, createDeviceSecretsStore, createNodePinnedFetch, createSession, currentNodes, cvcMaxLength, defaultConditionError, defaultIsPaymentCaptured, defaultOutgoingEdge, defaultWebhookEventsForStatus, defaultWebhookRetryDelayMs, detectCardBrand, dispatchOrderWebhooks, dispatchPendingWebhooks, engineHmacSha256Hex, engineOrderStatusForFailedRun, engineWebhookDeliveryId, engineWebhookRunsForEnteredNodes, engineWebhookStatusKey, engineWebhookTransitionStates, enterAndPause, enterWorkflowNode, executeAdvance, executeScheduledWake, executeStart, failActiveEngineStepLog, finalizePlaceOrder, findFirstState, findLocaleKey, findMappedStatusNode, findNodeById, findShippingFeeLine, findStartNode, fitRedeems, flattenMenuCategories, flushLogs, formatCardNumber, formatCvc, formatExpiry, formatLocalServerUrl, formatRecurringDateCronSummary, fromOrderLines, fulfillmentStatusesEqual, genId, genOrderId, getLineRewardSavings, getLocalTlsPinning, getLogContext, getOrigin, getRouteHealth, getScheduleWindow, getSecret, hasInFlightPayment, hasLocalTlsPinning, hasSmartRouting, hpkeOpen, hpkeSeal, incomingEdges, indexMenu, indexOutgoingBySource, injectingMetadataFromCallback, invokeCallbackAttempt, isCanonicalizationError, isCardNumberComplete, isCardNumberDefinitelyInvalid, isCheckoutFieldFilled, isCustomerInfoFieldFilled, isCustomerInfoPlaceholder, isCustomerInfoValueValid, isCvcComplete, isDelegatedSessionExpiredError, isDeliveryFee, isDeviceCharged, isDeviceNotLinked, isExpiredFulfillment, isExpiryComplete, isGenId, isInterruptTerminalStatus, isKioskUnauthorized, isLocalOrderUnknown, isMilestoneStepDone, isNodeRuntime, isOnSchedule, isOrderNotOpenError, isOrderPaymentRequiredError, isOrderRouteUnavailableError, isOrderValidationError, isPosDeviceNotLinked, isPosUnauthorized, isRealPaymentMethod, isReservedFulfillmentStatus, isRouteCircuitOpen, isScheduleSlot, isScheduledAtError, isShippingFeeLine, isStateHash, isStorefrontNotFound, isSupportedWorkflowSchemaVersion, isTerminalFulfillmentStatus, isTerminalMappedStatus, isTlsFingerprintMismatchError, isVariantBase, lineCartValue, linePayableTotal, listMenusStream, listSecretKeys, localizePosError, log, logError, luhnCheck, markEdgeTaken, markNodeEntered, markNodeExited, markNodeSkipped, markNodesAdvance, markNodesReady, markRouteDown, markRouteHealthy, matchAbsoluteDateOperator, matchBooleanOperator, matchCurrencyOperator, matchEnumOperator, matchNumberOperator, matchRecurringDateOperator, matchRelativeDateOperator, matchStringOperator, matchingPrimaryOutgoing, milestoneSteps, milestoneTrack, nestMenuCategories, nextCurrentNodeIds, normalizeCardholderName, normalizeCertFingerprint, normalizeCustomerPhone, normalizeFulfillmentStatus, normalizeLocaleKey, normalizeMaxIncompleteMinutes, normalizePickupName, normalizeStateScope, onOriginChange, onRouteHealth, orderFactsFromOrder, orderFieldsFromNode, orderPayableTotal, orderRedeemedTotal, orderRedeems, orderStatusForFulfillmentStatus, outgoingEdges, parseExpiry, parseLosslessJson, pathKindForTargetNode, pauseForAdvance, paymentMatchesClientConditions, pendingWebhooksOf, pickAdvanceTarget, pickLocalizedText, pickMultiLanguageText, placeCartLines, probeLocalRouteHealth, processStateNode, rebuildOrderLinesWithFees, rebuildRootGroups, recomputeTotals, redeemedTotal, redeemsForPayment, redemptionCap, redemptionSteps, remainingAmount, removeLine, replaceLine, rescaleLineRewardSavings, resolveAdvanceEdge, resolveAdvanceEdges, resolveCallbackFailTerminal, resolveCheckout, resolveFailureTerminalEdge, resolveLocalPins, resolveLocalRouteUrl, resolveModifierImageUrl, resolveOrderRouteEligibility, resolvePaymentEligibility, resolveSchedulePrepMinutes, resolveSdkPaymentEligibilityCeiling, resolveSuccessTerminalEdges, resolveWebhookTargetUrl, resumeFromAdvance, reversePayment, reversedWhenCaptured, roundFeeAmount, runIsTerminal, runNodeCallbacks, runPaymentAttempt, runStateGoldenVectors, scheduledInstant, scheduledSuccessorStatus, selectMatchingFees, selectablePayments, serializeError, services, setLineQuantity, settleEnter, sha256Hex, sha256HexOfString, sittingWorkflowNode, stateRootHash, stateScopeKey, stateSectionHash, stateSectionHashOfJson, storefrontJson, stripFeeLines, stubUnsupportedFeeAmount, summarizeRecurringDateCron, syncDeviceSecrets, testLocalServerHealth, toOrderLines, toPaymentCardBrand, unusedOutgoing, utf8Encode, validateCardNumber, validateCardholderName, validateCvc, validateExpiry, validateOrderAgainstMenu, validatePickupName, verifyLocalRoutePin, verifyWebhookSignature, visitedStates, warnNoEdge, withLineRewardSavings, workflowSchemaVersionOf };
|
|
4370
|
+
//#region src/invoicing/countries.d.ts
|
|
4371
|
+
declare const INVOICE_COUNTRIES: Record<InvoiceCountryCode, InvoiceCountryDescriptor>;
|
|
4372
|
+
declare const getInvoiceCountry: (code: string) => InvoiceCountryDescriptor | undefined;
|
|
4373
|
+
//#endregion
|
|
4374
|
+
//#region src/invoicing/taxBreakdown.d.ts
|
|
4375
|
+
interface TaxBreakdownLineInput {
|
|
4376
|
+
parent_uid?: string | null;
|
|
4377
|
+
tax_category?: TaxCategory | null;
|
|
4378
|
+
tax_rate?: number | string | null;
|
|
4379
|
+
group_subtotal: number | string;
|
|
4380
|
+
group_discount?: number | string | null;
|
|
4381
|
+
group_tax_total: number | string;
|
|
4382
|
+
}
|
|
4383
|
+
/**
|
|
4384
|
+
* Compute per-(tax_category, tax_rate) breakdown using Big.js with no rounding.
|
|
4385
|
+
* Only root lines (parent_uid == null) are aggregated to avoid double-counting.
|
|
4386
|
+
*/
|
|
4387
|
+
declare const computeTaxBreakdown: (lines: TaxBreakdownLineInput[]) => TaxBreakdownItem[];
|
|
4388
|
+
//#endregion
|
|
4389
|
+
//#region src/invoicing/validateTaxId.d.ts
|
|
4390
|
+
declare const validateEcuadorCedula: (raw: string) => TaxIdValidationResult;
|
|
4391
|
+
declare const validateEcuadorRuc: (raw: string) => TaxIdValidationResult;
|
|
4392
|
+
declare const validateTaxId: (country: string, type: string, raw: string) => TaxIdValidationResult;
|
|
4393
|
+
//#endregion
|
|
4394
|
+
export { type AdvanceAndEnterConfig, type AdvanceAndEnterResult, type ApplyRedeemInput, type AuthConfigureOptions, type BuildRouteHttpInput, type BuildScheduleSlotsConfig, CALLBACK_MISSING_LOCAL_URL, CANONICAL_MAX_DEPTH, CANONICAL_MAX_EXPONENT, CARD_BRANDS, CUSTOMER_INFO_PLACEHOLDERS, type CallbackMissingLocalUrlDetails, type CanonicalInput, type CanonicalizationError, type CanonicalizationErrorCode, 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 ComputeProductRewardSavingsInput, type CreateOrderOptions, type CreateSessionOptions, type CustomizationPath, type CustomizationSession, DEFAULT_LOCALE, DEFAULT_MAX_INCOMPLETE_MINUTES, DEFAULT_MAX_SNAPSHOT_AGE_MS, DEFAULT_RECOMMENDATION_TYPES, DEFAULT_ROUTE_COOLDOWN_MS, DEFAULT_WEBHOOK_TIMEOUT_S, DelegatedSessionExpiredError, type DeunaCallbackUrls, type DeunaOrderStatus, type DeviceSecretStorage, type DeviceSecretsConfigureOptions, type DeviceSecretsPayload, type DeviceSecretsStore, type DispatchWebhooksConfig, type EngineCallbackRun, type EngineCallbackRunError, type EngineExecutionContext, type EngineFlagReviewInput, type EngineFulfillmentPatch, type EngineOrder, type EngineOrderChangedEvent, type EngineOrderFulfillment, type EngineOrderStatus, type EngineOrderStatusPatch, type EngineScope, type EngineStepLog, type EngineStepLogEntry, type EngineStepsLogs, type EngineWebhookEnvelope, type EngineWebhookFailureEvent, type EngineWebhookNodeRun, type EngineWebhookTarget, type EnterAndPauseResult, type EnterRunResult, type ExchangeOptions, FULFILLMENT_WORKFLOW_TERMINAL_STATUSES, type FailedCharge, type FinalizePlaceOrderConfig, type FiresparkOrigin, type FlatMenuCategory, type FulfillmentEligibilityInput, type FulfillmentExecutionPort, type FulfillmentPorts, type FulfillmentRunStatus, type FulfillmentStepName, type FulfillmentStoragePort, type FulfillmentTerminalOrderStatus, type GenOrderIdOptions, type GetCmsBlockOptions, type GroupDisplayType, HPKE_ALG, type HpkeAead, type HpkeEnvelope, type HpkeOpenInput, type HpkePrivateJwk, type HpkePublicJwk, type HpkeSealInput, ID_HASH_FORMATS, INVOICE_COUNTRIES, type IdBuilder, type IdHashFormat, type InvokeCallbackAttemptConfig, type InvokeCallbackAttemptResult, type ListMenusStreamOptions, type ListPaymentsOptions, type LocalDeviceCredentials, type LocalRouteProbeResult, type LocalServerConfig, type LocalServerHealthResult, LosslessNumber, type LosslessNumberLike, MAX_MAX_INCOMPLETE_MINUTES, MAX_SUPPORTED_WORKFLOW_SCHEMA_VERSION, MIN_MAX_INCOMPLETE_MINUTES, MODE_HINT_HEADER, type MarkRouteDownInput, type Menu, type MenuCategoryNode, type MenuLookup, type MilestoneSteps, type MilestoneTrackItem, type ModifierControlType, type ModifierCtx, type ModifierGroupCtx, type NestedMenuCategory, OFFLINE_NO_LOCAL_URL, ORIGIN_HEADER, 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 OrderRouteKind, type OrderRouteStatus, OrderRouteUnavailableError, type OrderRoutes, type OrderScope, OrderSyncPendingError, OrderSyncRejectedError, OrderValidationError, type OrderValidationResult, type OriginListener, type OriginState, type PauseForAdvanceConfig, type PayIntentOptions, type PayIntentResult, type PayOptions, type PaymentCardBrand, type PaymentEligibilityInput, type PaymentProgressEvent, type PaymentProgressListener, type PaymentRunOptions, type PaymentSessionOptions, type PendingWebhooks, PickupNameIssue, type PinnedFetchFactory, type PinnedFetchOptions, type PosOrderHttpOptions, type PricingModifier, type ProbeLocalRouteHealthOptions, type ProcessStateNodeCallbackJob, type ProcessStateNodeConfig, type ProcessStateNodeResult, type Product, type ProductCtx, type QuantitiesByPath, RESERVED_FULFILLMENT_STATUSES, REWARD_SAVINGS_METADATA_KEY, type RecommendationType, RecurringDateCron, type RedeemPaymentRow, type RemoveRedeemInput, type ReorderOrderOptions, type ResetOptions, type ResolveRouteEligibilityInput, type ResolvedPaymentEligibility, type ResumeFromAdvanceConfig, type ReversalOutcome, type ReverseAllOptions, type RouteEligibility, type RouteEligibilityDetail, type RouteEligibilityFlags, type RouteEligibilityReason, type RouteFailureClassification, type RouteFailureKind, type RouteHealthEvent, type RouteHealthListener, type RouteHealthSnapshot, type RouteTenderCandidate, RulesEngine, type RunNodeCallbacksResult, SCHEDULED_AT_ERROR_CODES, SCHEDULED_ORDER_MAX_HORIZON_HOURS, SCHEDULED_ORDER_MAX_HORIZON_MINUTES, SCHEDULED_ORDER_MIN_LEAD_MINUTES, SCHEDULED_ORDER_SLOT_MINUTES, SCHEDULED_STATUS, SDK_PAYMENT_ELIGIBILITY_CEILINGS, STATE_ALGO, STATE_HASH_PREFIX, type ScheduleSlot, type ScheduleSlotCart, type ScheduleSlotCartLine, type ScheduleWindow, type ScheduledSuccessorConfig, type SdkPaymentEligibility, type SelectionStatus, type SelectionsByPath, type SerializedError, type ServiceHttpOptions, type SimpleTenderPayment, type Snapshot, type StateGoldenRootVector, type StateGoldenVector, type StateGoldenVectors, type StateManifest, type StateManifestSection, type StateRootInput, type StateScope, type StateVectorFailure, type StepOutcome, type StorefrontAccessToken, type StorefrontErrorDetails, StorefrontHttpError, type SwitchCustomerArg, type SwitchCustomerIdToken, type SwitchCustomerOptions, type SwitchCustomerResult, TLS_FINGERPRINT_RESPONSE_HEADER, TLS_PIN_HEADER, type TaxBreakdownLineInput, type TestLocalServerHealthOptions, TlsFingerprintMismatchError, TokenExchangeError, type TrackWorkflow, type ValidateOptions, type ValidateOrderAgainstMenuInput, type Variant, type VariantGroup, type VariantGroupCtx, type VariantOptionCtx, type VariantSelection, type VerifyWebhookSignatureInput, type VisitedState, WORKFLOW_SCHEMA_VERSION, WORKFLOW_TIMEOUT, WorkflowSchemaVersionError, type WorkflowTimeoutDetails, addLines, advanceAndEnter, appendEngineStepLog, appendNodeLog, applyCmsVisibility, applyFees, applyManualAdvanceNote, applyRewardSavingsToLines, assertSupportedWorkflowSchemaVersion, auth, autoEnterSuccessTerminal, base64UrlDecode, base64UrlEncode, beginEngineStepLog, buildCustomerSnapshot, buildEngineCallbackError, buildEngineCallbackRun, buildRouteHttpOptions, buildRulesEngineFromOrder, buildScheduleSlots, buildWorkflowTimeoutDetails, callbackIdsFromNode, canEnterJoin, canPauseNow, cancelTypeOf, canonicalNumber, canonicalString, canonicalize, canonicalizeJson, capRedeems, cappedRedeems, cardBrandSpec, cardDigits, cardNumberGaps, cardNumberMaxLength, cardPreviewGroups, caretAfterDigits, certFingerprintsMatch, certMatchesAnyPin, classifyRouteFailure, clearDeviceSecrets, clearEdgeTaken, clearNodeVisit, cmsVisibilityNeedsTimezone, collectCheckoutIssues, collectOrderLineDiffs, completeEngineStepLog, computeOrderExpiresAt, computeProductRewardSavings, computeStartingPrice, computeTaxBreakdown, configureDeviceSecrets, configureLocalTlsPinning, countCartProducts, coveredAmount, createCanonicalizationError, createDeunaWidgetApi, createDeviceSecretsStore, createNodePinnedFetch, createSession, currentNodes, cvcMaxLength, defaultConditionError, defaultIsPaymentCaptured, defaultOutgoingEdge, defaultWebhookEventsForStatus, defaultWebhookRetryDelayMs, detectCardBrand, dispatchOrderWebhooks, dispatchPendingWebhooks, engineHmacSha256Hex, engineOrderStatusForFailedRun, engineWebhookDeliveryId, engineWebhookRunsForEnteredNodes, engineWebhookStatusKey, engineWebhookTransitionStates, enterAndPause, enterWorkflowNode, executeAdvance, executeScheduledWake, executeStart, failActiveEngineStepLog, finalizePlaceOrder, findFirstState, findLocaleKey, findMappedStatusNode, findNodeById, findShippingFeeLine, findStartNode, fitRedeems, flattenMenuCategories, flushLogs, formatCardNumber, formatCvc, formatExpiry, formatLocalServerUrl, formatRecurringDateCronSummary, fromOrderLines, fulfillmentStatusesEqual, genId, genOrderId, getInvoiceCountry, getLineRewardSavings, getLocalTlsPinning, getLogContext, getOrigin, getRouteHealth, getScheduleWindow, getSecret, hasInFlightPayment, hasLocalTlsPinning, hasSmartRouting, hpkeOpen, hpkeSeal, incomingEdges, indexMenu, indexOutgoingBySource, injectingMetadataFromCallback, invokeCallbackAttempt, isCanonicalizationError, isCardNumberComplete, isCardNumberDefinitelyInvalid, isCheckoutFieldFilled, isCustomerInfoFieldFilled, isCustomerInfoPlaceholder, isCustomerInfoValueValid, isCvcComplete, isDelegatedSessionExpiredError, isDeliveryFee, isDeviceCharged, isDeviceNotLinked, isExpiredFulfillment, isExpiryComplete, isGenId, isInterruptTerminalStatus, isKioskUnauthorized, isLocalOrderUnknown, isMilestoneStepDone, isNodeRuntime, isOnSchedule, isOrderNotOpenError, isOrderPaymentRequiredError, isOrderRouteUnavailableError, isOrderValidationError, isPosDeviceNotLinked, isPosUnauthorized, isRealPaymentMethod, isReservedFulfillmentStatus, isRouteCircuitOpen, isScheduleSlot, isScheduledAtError, isShippingFeeLine, isStateHash, isStorefrontNotFound, isSupportedWorkflowSchemaVersion, isTerminalFulfillmentStatus, isTerminalMappedStatus, isTlsFingerprintMismatchError, isVariantBase, lineCartValue, linePayableTotal, listMenusStream, listSecretKeys, localizePosError, log, logError, luhnCheck, markEdgeTaken, markNodeEntered, markNodeExited, markNodeSkipped, markNodesAdvance, markNodesReady, markRouteDown, markRouteHealthy, matchAbsoluteDateOperator, matchBooleanOperator, matchCurrencyOperator, matchEnumOperator, matchNumberOperator, matchRecurringDateOperator, matchRelativeDateOperator, matchStringOperator, matchingPrimaryOutgoing, milestoneSteps, milestoneTrack, nestMenuCategories, nextCurrentNodeIds, normalizeCardholderName, normalizeCertFingerprint, normalizeCustomerPhone, normalizeFulfillmentStatus, normalizeLocaleKey, normalizeMaxIncompleteMinutes, normalizePickupName, normalizeStateScope, onOriginChange, onRouteHealth, orderFactsFromOrder, orderFieldsFromNode, orderPayableTotal, orderRedeemedTotal, orderRedeems, orderStatusForFulfillmentStatus, outgoingEdges, parseExpiry, parseLosslessJson, pathKindForTargetNode, pauseForAdvance, paymentMatchesClientConditions, pendingWebhooksOf, pickAdvanceTarget, pickLocalizedText, pickMultiLanguageText, placeCartLines, probeLocalRouteHealth, processStateNode, rebuildOrderLinesWithFees, rebuildRootGroups, recomputeTotals, redeemedTotal, redeemsForPayment, redemptionCap, redemptionSteps, remainingAmount, removeLine, replaceLine, rescaleLineRewardSavings, resolveAdvanceEdge, resolveAdvanceEdges, resolveCallbackFailTerminal, resolveCheckout, resolveFailureTerminalEdge, resolveLocalPins, resolveLocalRouteUrl, resolveModifierImageUrl, resolveOrderRouteEligibility, resolvePaymentEligibility, resolveSchedulePrepMinutes, resolveSdkPaymentEligibilityCeiling, resolveSuccessTerminalEdges, resolveWebhookTargetUrl, resumeFromAdvance, reversePayment, reversedWhenCaptured, roundFeeAmount, runIsTerminal, runNodeCallbacks, runPaymentAttempt, runStateGoldenVectors, scheduledInstant, scheduledSuccessorStatus, selectMatchingFees, selectablePayments, serializeError, services, setLineQuantity, settleEnter, sha256Hex, sha256HexOfString, sittingWorkflowNode, stateRootHash, stateScopeKey, stateSectionHash, stateSectionHashOfJson, storefrontJson, stripFeeLines, stubUnsupportedFeeAmount, summarizeRecurringDateCron, syncDeviceSecrets, testLocalServerHealth, toOrderLines, toPaymentCardBrand, unusedOutgoing, utf8Encode, validateCardNumber, validateCardholderName, validateCvc, validateEcuadorCedula, validateEcuadorRuc, validateExpiry, validateOrderAgainstMenu, validatePickupName, validateTaxId, verifyLocalRoutePin, verifyWebhookSignature, visitedStates, warnNoEdge, withLineRewardSavings, workflowSchemaVersionOf };
|
package/dist/index.js
CHANGED
|
@@ -6392,6 +6392,14 @@ const isRunningOffline = (condition, isOffline) => {
|
|
|
6392
6392
|
assert(value != null, "Invalid value");
|
|
6393
6393
|
return matchBooleanOperator(condition, isOffline ?? false);
|
|
6394
6394
|
};
|
|
6395
|
+
const buyerIdentified = (condition, identified) => {
|
|
6396
|
+
const { type, primitive, value } = condition;
|
|
6397
|
+
const matcherType = "Buyer identified";
|
|
6398
|
+
assert(primitive === "boolean", primitiveError("boolean"));
|
|
6399
|
+
assert(type === matcherType, typeError(matcherType));
|
|
6400
|
+
assert(value != null, "Invalid value");
|
|
6401
|
+
return matchBooleanOperator(condition, identified ?? false);
|
|
6402
|
+
};
|
|
6395
6403
|
//#endregion
|
|
6396
6404
|
//#region src/rules/currencyMatcher.ts
|
|
6397
6405
|
const matchCurrencyOperator = (condition, matcher) => {
|
|
@@ -7210,6 +7218,10 @@ var RulesEngine = class {
|
|
|
7210
7218
|
const offline = this.execution?.is_offline;
|
|
7211
7219
|
return isRunningOffline(condition, offline);
|
|
7212
7220
|
}
|
|
7221
|
+
if (type === "Buyer identified") {
|
|
7222
|
+
const order = this.getDependency("order", type);
|
|
7223
|
+
return buyerIdentified(condition, order.buyer_identified);
|
|
7224
|
+
}
|
|
7213
7225
|
throw new Error(`Condition ${type} not supported in boolean matcher`);
|
|
7214
7226
|
};
|
|
7215
7227
|
assertCurrency = (condition) => {
|
|
@@ -18122,4 +18134,262 @@ const hpkeOpen = async (input) => {
|
|
|
18122
18134
|
return new Uint8Array(opened);
|
|
18123
18135
|
};
|
|
18124
18136
|
//#endregion
|
|
18125
|
-
|
|
18137
|
+
//#region src/invoicing/countries.ts
|
|
18138
|
+
const INVOICE_COUNTRIES = { EC: {
|
|
18139
|
+
code: "EC",
|
|
18140
|
+
name: "Ecuador",
|
|
18141
|
+
authority: "SRI",
|
|
18142
|
+
currency: "USD",
|
|
18143
|
+
tax_id_types: [
|
|
18144
|
+
{ code: "FINAL_CONSUMER" },
|
|
18145
|
+
{
|
|
18146
|
+
code: "CEDULA",
|
|
18147
|
+
min_length: 10,
|
|
18148
|
+
max_length: 10,
|
|
18149
|
+
numeric_only: true
|
|
18150
|
+
},
|
|
18151
|
+
{
|
|
18152
|
+
code: "RUC",
|
|
18153
|
+
min_length: 13,
|
|
18154
|
+
max_length: 13,
|
|
18155
|
+
numeric_only: true
|
|
18156
|
+
},
|
|
18157
|
+
{
|
|
18158
|
+
code: "PASSPORT",
|
|
18159
|
+
min_length: 3,
|
|
18160
|
+
max_length: 20,
|
|
18161
|
+
numeric_only: false
|
|
18162
|
+
}
|
|
18163
|
+
],
|
|
18164
|
+
final_consumer_id: "9999999999999",
|
|
18165
|
+
final_consumer_name: "CONSUMIDOR FINAL",
|
|
18166
|
+
default_buyer_threshold: "50.00",
|
|
18167
|
+
supported_regimes: [
|
|
18168
|
+
"GENERAL",
|
|
18169
|
+
"RIMPE_EMPRENDEDOR",
|
|
18170
|
+
"RIMPE_NEGOCIO_POPULAR"
|
|
18171
|
+
]
|
|
18172
|
+
} };
|
|
18173
|
+
const getInvoiceCountry = (code) => {
|
|
18174
|
+
const key = code.toUpperCase();
|
|
18175
|
+
return INVOICE_COUNTRIES[key];
|
|
18176
|
+
};
|
|
18177
|
+
//#endregion
|
|
18178
|
+
//#region src/invoicing/taxBreakdown.ts
|
|
18179
|
+
const inferTaxCategory = (line) => {
|
|
18180
|
+
if (line.tax_category) return line.tax_category;
|
|
18181
|
+
return new Big(line.tax_rate ?? 0).gt(0) ? "STANDARD" : "ZERO";
|
|
18182
|
+
};
|
|
18183
|
+
/**
|
|
18184
|
+
* Compute per-(tax_category, tax_rate) breakdown using Big.js with no rounding.
|
|
18185
|
+
* Only root lines (parent_uid == null) are aggregated to avoid double-counting.
|
|
18186
|
+
*/
|
|
18187
|
+
const computeTaxBreakdown = (lines) => {
|
|
18188
|
+
const buckets = /* @__PURE__ */ new Map();
|
|
18189
|
+
for (const line of lines) {
|
|
18190
|
+
if (line.parent_uid != null) continue;
|
|
18191
|
+
const category = inferTaxCategory(line);
|
|
18192
|
+
const rate = new Big(line.tax_rate ?? 0);
|
|
18193
|
+
const key = `${category}:${rate.toFixed()}`;
|
|
18194
|
+
const subtotal = new Big(line.group_subtotal);
|
|
18195
|
+
const discount = new Big(line.group_discount ?? 0);
|
|
18196
|
+
const base = subtotal.minus(discount);
|
|
18197
|
+
const tax = new Big(line.group_tax_total);
|
|
18198
|
+
const existing = buckets.get(key);
|
|
18199
|
+
if (existing) {
|
|
18200
|
+
existing.taxable_base = existing.taxable_base.plus(base);
|
|
18201
|
+
existing.tax_amount = existing.tax_amount.plus(tax);
|
|
18202
|
+
} else buckets.set(key, {
|
|
18203
|
+
tax_category: category,
|
|
18204
|
+
tax_rate: rate,
|
|
18205
|
+
taxable_base: base,
|
|
18206
|
+
tax_amount: tax
|
|
18207
|
+
});
|
|
18208
|
+
}
|
|
18209
|
+
return Array.from(buckets.values()).map((bucket) => {
|
|
18210
|
+
return {
|
|
18211
|
+
tax_category: bucket.tax_category,
|
|
18212
|
+
tax_rate: bucket.tax_rate.toFixed(),
|
|
18213
|
+
taxable_base: bucket.taxable_base.toFixed(),
|
|
18214
|
+
tax_amount: bucket.tax_amount.toFixed()
|
|
18215
|
+
};
|
|
18216
|
+
});
|
|
18217
|
+
};
|
|
18218
|
+
//#endregion
|
|
18219
|
+
//#region src/invoicing/validateTaxId.ts
|
|
18220
|
+
const DIGITS_ONLY = /^\d+$/;
|
|
18221
|
+
const PASSPORT_REGEX = /^[A-Za-z0-9-]{3,20}$/;
|
|
18222
|
+
const FINAL_CONSUMER_EC = "9999999999999";
|
|
18223
|
+
const CEDULA_COEFFS = [
|
|
18224
|
+
2,
|
|
18225
|
+
1,
|
|
18226
|
+
2,
|
|
18227
|
+
1,
|
|
18228
|
+
2,
|
|
18229
|
+
1,
|
|
18230
|
+
2,
|
|
18231
|
+
1,
|
|
18232
|
+
2
|
|
18233
|
+
];
|
|
18234
|
+
const PUBLIC_RUC_COEFFS = [
|
|
18235
|
+
3,
|
|
18236
|
+
2,
|
|
18237
|
+
7,
|
|
18238
|
+
6,
|
|
18239
|
+
5,
|
|
18240
|
+
4,
|
|
18241
|
+
3,
|
|
18242
|
+
2
|
|
18243
|
+
];
|
|
18244
|
+
const PRIVATE_RUC_COEFFS = [
|
|
18245
|
+
4,
|
|
18246
|
+
3,
|
|
18247
|
+
2,
|
|
18248
|
+
7,
|
|
18249
|
+
6,
|
|
18250
|
+
5,
|
|
18251
|
+
4,
|
|
18252
|
+
3,
|
|
18253
|
+
2
|
|
18254
|
+
];
|
|
18255
|
+
const isValidEcuadorProvince = (code) => {
|
|
18256
|
+
return code >= 1 && code <= 24 || code === 30;
|
|
18257
|
+
};
|
|
18258
|
+
const checkMod10 = (digits) => {
|
|
18259
|
+
let sum = 0;
|
|
18260
|
+
for (let i = 0; i < 9; i++) {
|
|
18261
|
+
let prod = Number(digits[i]) * (CEDULA_COEFFS[i] ?? 0);
|
|
18262
|
+
if (prod >= 10) prod -= 9;
|
|
18263
|
+
sum += prod;
|
|
18264
|
+
}
|
|
18265
|
+
const expected = (10 - sum % 10) % 10;
|
|
18266
|
+
return Number(digits[9]) === expected;
|
|
18267
|
+
};
|
|
18268
|
+
const checkMod11 = (digits, coeffs, checkIndex) => {
|
|
18269
|
+
let sum = 0;
|
|
18270
|
+
for (let i = 0; i < coeffs.length; i++) sum += Number(digits[i]) * (coeffs[i] ?? 0);
|
|
18271
|
+
const rem = sum % 11;
|
|
18272
|
+
const expected = rem === 0 ? 0 : 11 - rem;
|
|
18273
|
+
if (expected === 10) return false;
|
|
18274
|
+
return Number(digits[checkIndex]) === expected;
|
|
18275
|
+
};
|
|
18276
|
+
const validateEcuadorCedula = (raw) => {
|
|
18277
|
+
const value = raw.trim();
|
|
18278
|
+
if (!value) return {
|
|
18279
|
+
valid: false,
|
|
18280
|
+
reason: "EMPTY"
|
|
18281
|
+
};
|
|
18282
|
+
if (!DIGITS_ONLY.test(value)) return {
|
|
18283
|
+
valid: false,
|
|
18284
|
+
reason: "NON_NUMERIC"
|
|
18285
|
+
};
|
|
18286
|
+
if (value.length !== 10) return {
|
|
18287
|
+
valid: false,
|
|
18288
|
+
reason: "INVALID_LENGTH"
|
|
18289
|
+
};
|
|
18290
|
+
const province = Number(value.slice(0, 2));
|
|
18291
|
+
if (!isValidEcuadorProvince(province)) return {
|
|
18292
|
+
valid: false,
|
|
18293
|
+
reason: "INVALID_PROVINCE"
|
|
18294
|
+
};
|
|
18295
|
+
if (Number(value[2]) > 5) return {
|
|
18296
|
+
valid: false,
|
|
18297
|
+
reason: "INVALID_THIRD_DIGIT"
|
|
18298
|
+
};
|
|
18299
|
+
if (!checkMod10(value)) return {
|
|
18300
|
+
valid: false,
|
|
18301
|
+
reason: "INVALID_CHECK_DIGIT"
|
|
18302
|
+
};
|
|
18303
|
+
return { valid: true };
|
|
18304
|
+
};
|
|
18305
|
+
const validateEcuadorRuc = (raw) => {
|
|
18306
|
+
const value = raw.trim();
|
|
18307
|
+
if (!value) return {
|
|
18308
|
+
valid: false,
|
|
18309
|
+
reason: "EMPTY"
|
|
18310
|
+
};
|
|
18311
|
+
if (!DIGITS_ONLY.test(value)) return {
|
|
18312
|
+
valid: false,
|
|
18313
|
+
reason: "NON_NUMERIC"
|
|
18314
|
+
};
|
|
18315
|
+
if (value.length !== 13) return {
|
|
18316
|
+
valid: false,
|
|
18317
|
+
reason: "INVALID_LENGTH"
|
|
18318
|
+
};
|
|
18319
|
+
const province = Number(value.slice(0, 2));
|
|
18320
|
+
if (!isValidEcuadorProvince(province)) return {
|
|
18321
|
+
valid: false,
|
|
18322
|
+
reason: "INVALID_PROVINCE"
|
|
18323
|
+
};
|
|
18324
|
+
const third = Number(value[2]);
|
|
18325
|
+
if (third <= 5) {
|
|
18326
|
+
if (value.slice(10) === "000") return {
|
|
18327
|
+
valid: false,
|
|
18328
|
+
reason: "INVALID_ESTABLISHMENT"
|
|
18329
|
+
};
|
|
18330
|
+
if (!checkMod10(value.slice(0, 10))) return {
|
|
18331
|
+
valid: false,
|
|
18332
|
+
reason: "INVALID_CHECK_DIGIT"
|
|
18333
|
+
};
|
|
18334
|
+
return { valid: true };
|
|
18335
|
+
}
|
|
18336
|
+
if (third === 6) {
|
|
18337
|
+
if (value.slice(9) === "0000") return {
|
|
18338
|
+
valid: false,
|
|
18339
|
+
reason: "INVALID_ESTABLISHMENT"
|
|
18340
|
+
};
|
|
18341
|
+
if (!checkMod11(value, PUBLIC_RUC_COEFFS, 8)) return {
|
|
18342
|
+
valid: false,
|
|
18343
|
+
reason: "INVALID_CHECK_DIGIT"
|
|
18344
|
+
};
|
|
18345
|
+
return { valid: true };
|
|
18346
|
+
}
|
|
18347
|
+
if (third === 9) {
|
|
18348
|
+
if (value.slice(10) === "000") return {
|
|
18349
|
+
valid: false,
|
|
18350
|
+
reason: "INVALID_ESTABLISHMENT"
|
|
18351
|
+
};
|
|
18352
|
+
if (!checkMod11(value, PRIVATE_RUC_COEFFS, 9)) return {
|
|
18353
|
+
valid: false,
|
|
18354
|
+
reason: "INVALID_CHECK_DIGIT"
|
|
18355
|
+
};
|
|
18356
|
+
return { valid: true };
|
|
18357
|
+
}
|
|
18358
|
+
return {
|
|
18359
|
+
valid: false,
|
|
18360
|
+
reason: "INVALID_THIRD_DIGIT"
|
|
18361
|
+
};
|
|
18362
|
+
};
|
|
18363
|
+
const validateTaxId = (country, type, raw) => {
|
|
18364
|
+
const upperCountry = country.toUpperCase();
|
|
18365
|
+
const upperType = type.toUpperCase();
|
|
18366
|
+
const value = raw.trim();
|
|
18367
|
+
if (upperType === "FINAL_CONSUMER") {
|
|
18368
|
+
if (upperCountry === "EC") return value === FINAL_CONSUMER_EC ? { valid: true } : {
|
|
18369
|
+
valid: false,
|
|
18370
|
+
reason: "INVALID_FORMAT"
|
|
18371
|
+
};
|
|
18372
|
+
return value.length > 0 ? { valid: true } : {
|
|
18373
|
+
valid: false,
|
|
18374
|
+
reason: "EMPTY"
|
|
18375
|
+
};
|
|
18376
|
+
}
|
|
18377
|
+
if (!value) return {
|
|
18378
|
+
valid: false,
|
|
18379
|
+
reason: "EMPTY"
|
|
18380
|
+
};
|
|
18381
|
+
if (upperType === "PASSPORT") return PASSPORT_REGEX.test(value) ? { valid: true } : {
|
|
18382
|
+
valid: false,
|
|
18383
|
+
reason: "INVALID_FORMAT"
|
|
18384
|
+
};
|
|
18385
|
+
if (upperCountry === "EC") {
|
|
18386
|
+
if (upperType === "CEDULA") return validateEcuadorCedula(value);
|
|
18387
|
+
if (upperType === "RUC") return validateEcuadorRuc(value);
|
|
18388
|
+
}
|
|
18389
|
+
return {
|
|
18390
|
+
valid: false,
|
|
18391
|
+
reason: "INVALID_FORMAT"
|
|
18392
|
+
};
|
|
18393
|
+
};
|
|
18394
|
+
//#endregion
|
|
18395
|
+
export { CALLBACK_MISSING_LOCAL_URL, CANONICAL_MAX_DEPTH, CANONICAL_MAX_EXPONENT, CARD_BRANDS, CUSTOMER_INFO_PLACEHOLDERS, DEFAULT_LOCALE, DEFAULT_MAX_INCOMPLETE_MINUTES, DEFAULT_MAX_SNAPSHOT_AGE_MS, DEFAULT_RECOMMENDATION_TYPES, DEFAULT_ROUTE_COOLDOWN_MS, DEFAULT_WEBHOOK_TIMEOUT_S, DelegatedSessionExpiredError, FULFILLMENT_WORKFLOW_TERMINAL_STATUSES, HPKE_ALG, ID_HASH_FORMATS, INVOICE_COUNTRIES, LosslessNumber, MAX_MAX_INCOMPLETE_MINUTES, MAX_SUPPORTED_WORKFLOW_SCHEMA_VERSION, MIN_MAX_INCOMPLETE_MINUTES, MODE_HINT_HEADER, OFFLINE_NO_LOCAL_URL, ORIGIN_HEADER, Order, OrderAuthPinnedError, OrderNotOpenError, OrderPaymentRequiredError, OrderRouteUnavailableError, OrderSyncPendingError, OrderSyncRejectedError, OrderValidationError, RESERVED_FULFILLMENT_STATUSES, REWARD_SAVINGS_METADATA_KEY, 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, SCHEDULED_STATUS, SDK_PAYMENT_ELIGIBILITY_CEILINGS, STATE_ALGO, STATE_HASH_PREFIX, StorefrontHttpError, TLS_FINGERPRINT_RESPONSE_HEADER, TLS_PIN_HEADER, TlsFingerprintMismatchError, TokenExchangeError, WORKFLOW_SCHEMA_VERSION, WORKFLOW_TIMEOUT, WorkflowSchemaVersionError, addLines, advanceAndEnter, appendEngineStepLog, appendNodeLog, applyCmsVisibility, applyFees, applyManualAdvanceNote, applyRewardSavingsToLines, assertSupportedWorkflowSchemaVersion, auth, autoEnterSuccessTerminal, base64UrlDecode, base64UrlEncode, beginEngineStepLog, buildCustomerSnapshot, buildEngineCallbackError, buildEngineCallbackRun, buildRouteHttpOptions, buildRulesEngineFromOrder, buildScheduleSlots, buildWorkflowTimeoutDetails, callbackIdsFromNode, canEnterJoin, canPauseNow, cancelTypeOf, canonicalNumber, canonicalString, canonicalize, canonicalizeJson, capRedeems, cappedRedeems, cardBrandSpec, cardDigits, cardNumberGaps, cardNumberMaxLength, cardPreviewGroups, caretAfterDigits, certFingerprintsMatch, certMatchesAnyPin, classifyRouteFailure, clearDeviceSecrets, clearEdgeTaken, clearNodeVisit, cmsVisibilityNeedsTimezone, collectCheckoutIssues, collectOrderLineDiffs, completeEngineStepLog, computeOrderExpiresAt, computeProductRewardSavings, computeStartingPrice, computeTaxBreakdown, configureDeviceSecrets, configureLocalTlsPinning, countCartProducts, coveredAmount, createCanonicalizationError, createDeunaWidgetApi, createDeviceSecretsStore, createNodePinnedFetch, createSession, currentNodes, cvcMaxLength, defaultConditionError, defaultIsPaymentCaptured, defaultOutgoingEdge, defaultWebhookEventsForStatus, defaultWebhookRetryDelayMs, detectCardBrand, dispatchOrderWebhooks, dispatchPendingWebhooks, engineHmacSha256Hex, engineOrderStatusForFailedRun, engineWebhookDeliveryId, engineWebhookRunsForEnteredNodes, engineWebhookStatusKey, engineWebhookTransitionStates, enterAndPause, enterWorkflowNode, executeAdvance, executeScheduledWake, executeStart, failActiveEngineStepLog, finalizePlaceOrder, findFirstState, findLocaleKey, findMappedStatusNode, findNodeById, findShippingFeeLine, findStartNode, fitRedeems, flattenMenuCategories, flushLogs, formatCardNumber, formatCvc, formatExpiry, formatLocalServerUrl, formatRecurringDateCronSummary, fromOrderLines, fulfillmentStatusesEqual, genId, genOrderId, getInvoiceCountry, getLineRewardSavings, getLocalTlsPinning, getLogContext, getOrigin, getRouteHealth, getScheduleWindow, getSecret, hasInFlightPayment, hasLocalTlsPinning, hasSmartRouting, hpkeOpen, hpkeSeal, incomingEdges, indexMenu, indexOutgoingBySource, injectingMetadataFromCallback, invokeCallbackAttempt, isCanonicalizationError, isCardNumberComplete, isCardNumberDefinitelyInvalid, isCheckoutFieldFilled, isCustomerInfoFieldFilled, isCustomerInfoPlaceholder, isCustomerInfoValueValid, isCvcComplete, isDelegatedSessionExpiredError, isDeliveryFee, isDeviceCharged, isDeviceNotLinked, isExpiredFulfillment, isExpiryComplete, isGenId, isInterruptTerminalStatus, isKioskUnauthorized, isLocalOrderUnknown, isMilestoneStepDone, isNodeRuntime, isOnSchedule, isOrderNotOpenError, isOrderPaymentRequiredError, isOrderRouteUnavailableError, isOrderValidationError, isPosDeviceNotLinked, isPosUnauthorized, isRealPaymentMethod, isReservedFulfillmentStatus, isRouteCircuitOpen, isScheduleSlot, isScheduledAtError, isShippingFeeLine, isStateHash, isStorefrontNotFound, isSupportedWorkflowSchemaVersion, isTerminalFulfillmentStatus, isTerminalMappedStatus, isTlsFingerprintMismatchError, isVariantBase, lineCartValue, linePayableTotal, listMenusStream, listSecretKeys, localizePosError, log, logError, luhnCheck, markEdgeTaken, markNodeEntered, markNodeExited, markNodeSkipped, markNodesAdvance, markNodesReady, markRouteDown, markRouteHealthy, matchAbsoluteDateOperator, matchBooleanOperator, matchCurrencyOperator, matchEnumOperator, matchNumberOperator, matchRecurringDateOperator, matchRelativeDateOperator, matchStringOperator, matchingPrimaryOutgoing, milestoneSteps, milestoneTrack, nestMenuCategories, nextCurrentNodeIds, normalizeCardholderName, normalizeCertFingerprint, normalizeCustomerPhone, normalizeFulfillmentStatus, normalizeLocaleKey, normalizeMaxIncompleteMinutes, normalizePickupName, normalizeStateScope, onOriginChange, onRouteHealth, orderFactsFromOrder, orderFieldsFromNode, orderPayableTotal, orderRedeemedTotal, orderRedeems, orderStatusForFulfillmentStatus, outgoingEdges, parseExpiry, parseLosslessJson, pathKindForTargetNode, pauseForAdvance, paymentMatchesClientConditions, pendingWebhooksOf, pickAdvanceTarget, pickLocalizedText, pickMultiLanguageText, placeCartLines, probeLocalRouteHealth, processStateNode, rebuildOrderLinesWithFees, rebuildRootGroups, recomputeTotals, redeemedTotal, redeemsForPayment, redemptionCap, redemptionSteps, remainingAmount, removeLine, replaceLine, rescaleLineRewardSavings, resolveAdvanceEdge, resolveAdvanceEdges, resolveCallbackFailTerminal, resolveCheckout, resolveFailureTerminalEdge, resolveLocalPins, resolveLocalRouteUrl, resolveModifierImageUrl, resolveOrderRouteEligibility, resolvePaymentEligibility, resolveSchedulePrepMinutes, resolveSdkPaymentEligibilityCeiling, resolveSuccessTerminalEdges, resolveWebhookTargetUrl, resumeFromAdvance, reversePayment, reversedWhenCaptured, roundFeeAmount, runIsTerminal, runNodeCallbacks, runPaymentAttempt, runStateGoldenVectors, scheduledInstant, scheduledSuccessorStatus, selectMatchingFees, selectablePayments, serializeError, services, setLineQuantity, settleEnter, sha256Hex, sha256HexOfString, sittingWorkflowNode, stateRootHash, stateScopeKey, stateSectionHash, stateSectionHashOfJson, storefrontJson, stripFeeLines, stubUnsupportedFeeAmount, summarizeRecurringDateCron, syncDeviceSecrets, testLocalServerHealth, toOrderLines, toPaymentCardBrand, unusedOutgoing, utf8Encode, validateCardNumber, validateCardholderName, validateCvc, validateEcuadorCedula, validateEcuadorRuc, validateExpiry, validateOrderAgainstMenu, validatePickupName, validateTaxId, verifyLocalRoutePin, verifyWebhookSignature, visitedStates, warnNoEdge, withLineRewardSavings, workflowSchemaVersionOf };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fire-spark/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.53.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.53.0",
|
|
24
|
+
"@fire-spark/types": "^0.53.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"tsdown": "^0.22.14",
|