@vivoa/plugin-sdk 0.6.8 → 0.6.9

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.
@@ -442,6 +442,8 @@ interface PaymentCard {
442
442
  interface PaymentCustomer {
443
443
  email: string;
444
444
  phone: string;
445
+ /** OPTIONAL full name of the payer, for gateways that display or require it. */
446
+ name?: string;
445
447
  address?: string;
446
448
  city?: string;
447
449
  state?: string;
@@ -478,6 +480,23 @@ interface PaymentResult {
478
480
  * - `embed` gateway-owned iframe initialised via `createPaymentSession`.
479
481
  */
480
482
  type PaymentRenderMode = 'card-in' | 'offsite-redirect' | 'embed';
483
+ /**
484
+ * Fee model a gateway charges the MERCHANT, declared statically so the host can
485
+ * project the fee before any charge exists (checkout preview, settlement
486
+ * breakdown). The fee is computed on the GROSS amount charged to the shopper.
487
+ */
488
+ interface GatewayFeeConfig {
489
+ /** Default merchant rate as a FRACTION of the gross (0.038 === 3.8%). */
490
+ defaultRate: number;
491
+ /** True when the rate already includes tax (IVA): no tax is added on top. */
492
+ ivaInclusive: boolean;
493
+ /**
494
+ * Where the rate comes from. `reported`: the gateway reports the effective
495
+ * rate per charge (webhook / pricing endpoint), so `defaultRate` is only a
496
+ * fallback. `contract`: a fixed contractual rate the gateway never reports.
497
+ */
498
+ source: 'reported' | 'contract';
499
+ }
481
500
  interface GatewayStaticConfig {
482
501
  code: PaymentGatewayCode;
483
502
  displayName: string;
@@ -490,6 +509,16 @@ interface GatewayStaticConfig {
490
509
  * Back-compat: existing card-in plugins (Wompi/Serfinsa) omit this field.
491
510
  */
492
511
  renderMode?: PaymentRenderMode;
512
+ /**
513
+ * OPTIONAL merchant fee model (see {@link GatewayFeeConfig}). Absent ⇒ the host
514
+ * assumes the gateway fee is unknown and shows no fee projection.
515
+ */
516
+ fees?: GatewayFeeConfig;
517
+ /**
518
+ * OPTIONAL ISO-4217 currencies the gateway can charge. Absent ⇒ the host does
519
+ * not restrict by currency.
520
+ */
521
+ supportedCurrencies?: string[];
493
522
  }
494
523
  /**
495
524
  * Cardless payload for creating a gateway-hosted payment session (INV-1).
@@ -532,6 +561,70 @@ interface PaymentSessionResult {
532
561
  renderMode: PaymentRenderMode;
533
562
  embedInit?: EmbedInit;
534
563
  redirectUrl?: string;
564
+ /**
565
+ * OPTIONAL merchant-fee PREVIEW the gateway computed when sealing the
566
+ * session. Informational: the settled fee arrives with the webhook
567
+ * ({@link PaymentWebhookSettlement.fees}).
568
+ */
569
+ fees?: PaymentSessionFees;
570
+ }
571
+ /**
572
+ * Merchant-fee preview attached to a created payment session. Amounts are in
573
+ * DECIMAL major units of `currency`; `rate` is a FRACTION.
574
+ */
575
+ interface PaymentSessionFees {
576
+ rate: number;
577
+ /** Free-form origin of the rate (e.g. `merchant`, `default`). */
578
+ rateSource?: string;
579
+ feeAmount: number;
580
+ netAmount: number;
581
+ currency: string;
582
+ }
583
+ /**
584
+ * Fee breakdown a gateway reports for a SETTLED charge. `feeAmount` is taken on
585
+ * the gross `amount`; `netAmount = amount - feeAmount`. Amounts are DECIMAL
586
+ * major units of `currency`; `rate` is a FRACTION.
587
+ */
588
+ interface PaymentSettlementFees {
589
+ feeAmount: number;
590
+ rate: number;
591
+ netAmount: number;
592
+ /** True when `feeAmount` already includes tax (IVA). */
593
+ ivaIncluded: boolean;
594
+ currency: string;
595
+ }
596
+ /**
597
+ * Final outcome of a charge as read from a gateway webhook, normalised by the
598
+ * plugin so the host settles every gateway through one path. Only terminal
599
+ * outcomes are expressed: intermediate events are not settlements.
600
+ */
601
+ interface PaymentWebhookSettlement {
602
+ /** Merchant reference the charge was created with (host correlation key). */
603
+ reference: string;
604
+ status: 'approved' | 'declined';
605
+ /** Gross amount charged, DECIMAL major units of `currency`. */
606
+ amount: number;
607
+ currency: string;
608
+ gatewayTransactionId: string;
609
+ /** Gateway-side transaction id, when distinct from `gatewayTransactionId`. */
610
+ transactionId?: string;
611
+ /** Gateway event id, stable across redeliveries (idempotency key). */
612
+ eventId?: string;
613
+ authorizationCode?: string;
614
+ /** Merchant fee breakdown, only when the gateway reports it. */
615
+ fees?: PaymentSettlementFees;
616
+ }
617
+ /**
618
+ * Merchant-specific pricing a gateway exposes, so the host can refresh its
619
+ * cached fee projection. `rate` is a FRACTION of the gross charged.
620
+ */
621
+ interface PaymentMerchantPricing {
622
+ rate: number;
623
+ /** Free-form origin of the rate (e.g. `merchant`, `default`). */
624
+ rateSource: string;
625
+ /** Free-form fee model identifier (e.g. `flat_gross_iva_included`). */
626
+ model: string;
627
+ currency: string;
535
628
  }
536
629
  interface PaymentPluginConfig {
537
630
  configSchema: PluginConfigField[];
@@ -582,6 +675,20 @@ interface IPaymentPlugin extends IPlugin {
582
675
  verifyTransaction?(payload: PaymentVerifyPayload, ctx: DispatchContext): Promise<PaymentResult>;
583
676
  validateWebhookSignature?(rawBody: string | Buffer, headers: Record<string, string>, ctx: DispatchContext): WebhookSignatureResult;
584
677
  processWebhook?(payload: unknown, ctx: DispatchContext): Promise<void>;
678
+ /**
679
+ * Normalise a webhook payload into a {@link PaymentWebhookSettlement}.
680
+ * OPTIONAL — a plugin that omits it keeps the host's legacy webhook parsing.
681
+ * Called by the host only AFTER `validateWebhookSignature` passed. PURE and
682
+ * synchronous: no I/O, no state. Throw on a payload that cannot be read as a
683
+ * terminal charge outcome; the host validates whatever it returns.
684
+ */
685
+ parseWebhookSettlement?(payload: unknown, ctx: DispatchContext): PaymentWebhookSettlement;
686
+ /**
687
+ * Merchant-specific pricing for the account in `ctx.config`. OPTIONAL — used
688
+ * by the host to refresh its cached fee projection. Resolve `null` when the
689
+ * gateway exposes no per-merchant pricing or it is unavailable right now.
690
+ */
691
+ getMerchantPricing?(ctx: DispatchContext): Promise<PaymentMerchantPricing | null>;
585
692
  /**
586
693
  * Query the gateway for the current status of a previously attempted charge.
587
694
  * Called by the host when `processPayment` returns `status: Error` with a
@@ -706,6 +813,32 @@ interface CreateShipmentParams {
706
813
  courierId?: string;
707
814
  serviceLevelToken?: string;
708
815
  }
816
+ /**
817
+ * How the carrier moves money on a shipment:
818
+ * - `normal` → nothing collected; the merchant is billed the shipping.
819
+ * - `cod` → the carrier collects from the recipient and settles to the merchant.
820
+ * - `collect` → the recipient pays only the shipping; nothing settles to the merchant.
821
+ */
822
+ type CarrierServiceMode = 'normal' | 'cod' | 'collect';
823
+ /**
824
+ * What the carrier ACTUALLY settles for a shipment, in the order currency —
825
+ * the carrier's truth, which the host shows next to what it quoted. Each
826
+ * shipping plugin translates its own provider fields into this; the host never
827
+ * reads `rawResponse`.
828
+ */
829
+ interface CarrierSettlement {
830
+ mode: CarrierServiceMode;
831
+ /** Cash the carrier collects from the recipient. */
832
+ collected: number;
833
+ /** Commission the carrier charges the merchant for collecting. */
834
+ commission: number;
835
+ /** That commission as a percent of `collected` (3 = 3%), when known. */
836
+ commissionRate?: number;
837
+ /** Shipping deducted from the settlement (0 when billed apart). */
838
+ shippingDeducted: number;
839
+ /** What the merchant receives for this shipment. */
840
+ merchantNet: number;
841
+ }
709
842
  interface ShipmentResult {
710
843
  externalId: string;
711
844
  trackingNumber: string;
@@ -715,6 +848,8 @@ interface ShipmentResult {
715
848
  courierName: string;
716
849
  status: string;
717
850
  rawResponse?: Record<string, unknown>;
851
+ /** The carrier's settlement, when the provider reports it at creation. */
852
+ settlement?: CarrierSettlement;
718
853
  }
719
854
  /**
720
855
  * Normalized, carrier-agnostic shipment status event produced by
@@ -792,9 +927,16 @@ interface SuppliersStaticConfig {
792
927
  }
793
928
  interface SupplierCatalogQuery {
794
929
  text?: string;
930
+ /** ISO-3166-1 alpha-2. A driver that cannot serve it returns an empty page. */
795
931
  country?: string;
796
932
  cursor?: string;
797
933
  limit?: number;
934
+ /** Wholesale price floor, minor units (inclusive). */
935
+ minPriceMinor?: number;
936
+ /** Wholesale price ceiling, minor units (inclusive). */
937
+ maxPriceMinor?: number;
938
+ /** Only listings the supplier reports as in stock. */
939
+ inStockOnly?: boolean;
798
940
  }
799
941
  interface SupplierListingVariant {
800
942
  externalVariantId: string;
@@ -833,12 +975,16 @@ interface SupplierListing {
833
975
  hasVariants: boolean;
834
976
  variants?: SupplierListingVariant[];
835
977
  moq?: number | null;
978
+ /** Display name of the vendor behind the listing (a marketplace may host many). */
979
+ vendorName?: string | null;
836
980
  /** Untouched supplier payload, for diagnostics. Never trusted for control flow. */
837
981
  raw?: unknown;
838
982
  }
839
983
  interface SupplierListingPage {
840
984
  items: SupplierListing[];
841
985
  nextCursor?: string | null;
986
+ /** Total listings matching the query across all pages, when the supplier reports it. */
987
+ total?: number | null;
842
988
  }
843
989
  interface SupplierOrderCustomer {
844
990
  name: string;
@@ -952,11 +1098,19 @@ declare enum AnalyticsFeature {
952
1098
  /**
953
1099
  * ISO-4217 money in minor units — mirrors the store's Money VO so the host maps
954
1100
  * 1:1 without a currency guess. Kept local so the SDK stays dependency-free.
1101
+ * The exponent is the currency's own (USD 2, CLP/JPY 0, KWD 3): encode with
1102
+ * {@link toMinorUnits}, decode with {@link toMajorUnits}, never a fixed ×100.
955
1103
  */
956
1104
  interface AnalyticsMoney {
957
1105
  amountMinor: number;
958
1106
  currency: string;
959
1107
  }
1108
+ /** ISO-4217 minor-unit exponent (USD 2, JPY 0, KWD 3); unknown → 2. */
1109
+ declare function minorUnitDigits(currency: string): number;
1110
+ /** A major-unit amount (e.g. `25.5` USD) as {@link AnalyticsMoney}. */
1111
+ declare function toMinorUnits(major: number, currency: string): AnalyticsMoney;
1112
+ /** The major-unit decimal of {@link AnalyticsMoney} (e.g. `2550` USD → `25.5`). */
1113
+ declare function toMajorUnits(money: AnalyticsMoney): number;
960
1114
  /** A single line item attached to an ecommerce event. */
961
1115
  interface AnalyticsItem {
962
1116
  /** Product id as the store knows it (Meta `content_ids`, GA4 `item_id`). */
@@ -976,7 +1130,25 @@ interface AnalyticsItem {
976
1130
  * only ever maps a domain event to one of these. An adapter that does not care
977
1131
  * about a given name simply ignores it.
978
1132
  */
979
- type AnalyticsEventName = 'page_view' | 'view_item' | 'add_to_cart' | 'remove_from_cart' | 'begin_checkout' | 'purchase';
1133
+ type AnalyticsEventName = 'page_view' | 'view_item' | 'add_to_cart' | 'remove_from_cart' | 'begin_checkout' | 'purchase' | 'order_placed';
1134
+ /**
1135
+ * When a cash-on-delivery order counts as a `purchase` for an adapter:
1136
+ * - `collected` — when the cash is collected (carrier delivery or staff
1137
+ * marking it paid). Highest signal quality; the default.
1138
+ * - `confirmed` — when staff confirms the order (e.g. after a confirmation
1139
+ * call). Faster learning and inside the ad platform's dedup/attribution
1140
+ * windows, at the cost of counting confirmed orders the shopper refuses.
1141
+ * Prepaid orders always convert when the gateway approves the payment.
1142
+ */
1143
+ type CodPurchaseTrigger = 'collected' | 'confirmed';
1144
+ /**
1145
+ * Per-store settlement policy the HOST reads from an analytics adapter's own
1146
+ * config (`DispatchContext.config`). An adapter opts in by declaring a config
1147
+ * field with this exact key; one that declares none gets the defaults.
1148
+ */
1149
+ interface AnalyticsPurchasePolicy {
1150
+ codPurchaseTrigger?: CodPurchaseTrigger;
1151
+ }
980
1152
  /**
981
1153
  * Where the action physically happened. Maps to Meta `action_source`; other
982
1154
  * providers ignore it. Defaults to `website` when the host omits it.
@@ -1004,7 +1176,11 @@ interface AnalyticsUserData {
1004
1176
  genderSha256?: string | null;
1005
1177
  /** Date of birth, YYYYMMDD normalized then SHA256. */
1006
1178
  dobSha256?: string | null;
1007
- /** Store customer/user id — Meta `external_id` (not hashed by spec). */
1179
+ /**
1180
+ * Pseudonymous shopper id (user, else guest) — Meta `external_id`. Arrives
1181
+ * PLAIN: it is not PII. An adapter whose provider wants it hashed (Meta, to
1182
+ * meet the browser pixel) hashes it itself.
1183
+ */
1008
1184
  externalId?: string | null;
1009
1185
  /** Plain IPv4/IPv6 — never hashed (geo match). */
1010
1186
  clientIpAddress?: string | null;
@@ -1566,4 +1742,4 @@ interface HostApi {
1566
1742
  registerCapability<T = unknown>(cap: Capability<T>): void;
1567
1743
  }
1568
1744
 
1569
- export { type HttpClient as $, AUTHOR_HANDLE_RE as A, type BannerBlock$1 as B, ConfigScope as C, type ConditionalBlock as D, type ConditionalEquals as E, FieldType as F, type ConditionalWhen as G, type ConfigurablePlugin as H, ContentActionVariant as I, type ContentBlock as J, ContentBlockType as K, type CopyFieldBlock$1 as L, type CreateShipmentParams as M, type DispatchContext as N, type DividerBlock$1 as O, type PluginConfigField as P, type DomainEventHandler as Q, type DomainEventName as R, type SelectOption as S, type EmbedInit as T, type FieldBlock as U, type FieldOption as V, FieldVariant as W, GatewayEnvironment as X, type GatewayStaticConfig as Y, type GroupBlock as Z, type HostApi as _, type AccordionBlock as a, type ShippingQuote as a$, type HttpRequest as a0, type HttpResponse as a1, type IAnalyticsPlugin as a2, type IInvoicingPlugin as a3, type IPaymentPlugin as a4, type IPlugin as a5, type IShippingPlugin as a6, type ISuppliersPlugin as a7, type IUiPlugin as a8, type InlineRowBlock as a9, type PaymentRenderMode as aA, type PaymentResult as aB, type PaymentSessionPayload as aC, type PaymentSessionResult as aD, type PaymentVerifyPayload as aE, type PlaceSupplierOrderInput as aF, type Plugin as aG, type PluginActionContext as aH, type PluginActionResult as aI, type PluginAuthor as aJ, type PluginConfigFieldDependency as aK, type PluginFactory as aL, type PluginManifest as aM, type RepeaterBlock as aN, RepeaterSource as aO, type SecretStore as aP, type SequenceStore as aQ, type SetupAction as aR, type SetupLayout as aS, type SetupLayoutValidation as aT, type SetupStep as aU, type ShipmentAddress as aV, type ShipmentParcel as aW, type ShipmentResult as aX, type ShippingDefaultConfig as aY, ShippingFeature as aZ, type ShippingPluginConfig as a_, InvoiceDocumentType as aa, type InvoiceLine as ab, type InvoiceMoney as ac, type InvoiceParty as ad, type InvoiceRequest as ae, type InvoiceResult as af, InvoiceStatus as ag, type InvoiceTax as ah, type InvoicingDefaultConfig as ai, InvoicingFeature as aj, type InvoicingPluginConfig as ak, type InvoicingStaticConfig as al, type KeyValueBlock$1 as am, type KeyValueRow$1 as an, LayoutMode as ao, type Logger as ap, type MarkdownBlock as aq, MessageVariant as ar, type PaymentCard as as, type PaymentConnect as at, type PaymentConnectExchange as au, type PaymentConnectParams as av, type PaymentCustomer as aw, type PaymentGatewayCode as ax, type PaymentPayload as ay, type PaymentPluginConfig as az, type AccordionSection as b, type ShippingQuoteParams as b0, type ShippingStaticConfig as b1, StepStatusFrom as b2, type StepStatusFromAction as b3, type StepStatusFromFields as b4, type StepStatusSource as b5, type StorageBroker as b6, type SupplierCatalogQuery as b7, type SupplierFulfillmentEvent as b8, type SupplierListing as b9, crossValidateSetupLayout as bA, definePlugin as bB, invoicingCapability as bC, isConfigurablePlugin as bD, isPluginFactory as bE, paymentCapability as bF, shippingCapability as bG, suppliersCapability as bH, uiCapability as bI, validatePluginAuthor as bJ, validateSetupLayout as bK, validateUiContributions as bL, type SupplierListingAttribute as ba, type SupplierListingPage as bb, type SupplierListingVariant as bc, type SupplierMoney as bd, type SupplierOrderAddressLevel as be, type SupplierOrderCustomer as bf, type SupplierOrderLine as bg, type SupplierOrderResult as bh, type SupplierOrderStatus as bi, type SupplierShipTo as bj, type SupplierStock as bk, type SuppliersDefaultConfig as bl, SuppliersFeature as bm, type SuppliersPluginConfig as bn, type SuppliersStaticConfig as bo, type TabItem as bp, type TabsBlock as bq, type ToggleBlock as br, type TrackingEvent as bs, TransactionStatus as bt, type UiContribution as bu, type UiContributionsValidation as bv, type VoidInvoiceInput as bw, type WebhookSignatureResult as bx, analyticsCapability as by, capability as bz, type ActionBlock$1 as c, ActionVariant as d, type AnalyticsActionSource as e, type AnalyticsConsent as f, type AnalyticsEvent as g, type AnalyticsEventName as h, AnalyticsFeature as i, type AnalyticsItem as j, type AnalyticsMoney as k, type AnalyticsPluginConfig as l, type AnalyticsStaticConfig as m, type AnalyticsUserData as n, type AnalyticsUtm as o, type AuthorValidation as p, type Block as q, type BlockBase as r, BlockType as s, type CalloutBlock as t, type Capability as u, CapabilityKind as v, type CardBlock$1 as w, type CodConfig as x, type CodFeeConfig as y, CodFeeType as z };
1745
+ export { GatewayEnvironment as $, AUTHOR_HANDLE_RE as A, type BannerBlock$1 as B, ConfigScope as C, type CodConfig as D, type CodFeeConfig as E, FieldType as F, CodFeeType as G, type CodPurchaseTrigger as H, type ConditionalBlock as I, type ConditionalEquals as J, type ConditionalWhen as K, type ConfigurablePlugin as L, ContentActionVariant as M, type ContentBlock as N, ContentBlockType as O, type PluginConfigField as P, type CopyFieldBlock$1 as Q, type CreateShipmentParams as R, type SelectOption as S, type DispatchContext as T, type DividerBlock$1 as U, type DomainEventHandler as V, type DomainEventName as W, type EmbedInit as X, type FieldBlock as Y, type FieldOption as Z, FieldVariant as _, type AccordionBlock as a, type SetupLayout as a$, type GatewayFeeConfig as a0, type GatewayStaticConfig as a1, type GroupBlock as a2, type HostApi as a3, type HttpClient as a4, type HttpRequest as a5, type HttpResponse as a6, type IAnalyticsPlugin as a7, type IInvoicingPlugin as a8, type IPaymentPlugin as a9, type PaymentConnectParams as aA, type PaymentCustomer as aB, type PaymentGatewayCode as aC, type PaymentMerchantPricing as aD, type PaymentPayload as aE, type PaymentPluginConfig as aF, type PaymentRenderMode as aG, type PaymentResult as aH, type PaymentSessionFees as aI, type PaymentSessionPayload as aJ, type PaymentSessionResult as aK, type PaymentSettlementFees as aL, type PaymentVerifyPayload as aM, type PaymentWebhookSettlement as aN, type PlaceSupplierOrderInput as aO, type Plugin as aP, type PluginActionContext as aQ, type PluginActionResult as aR, type PluginAuthor as aS, type PluginConfigFieldDependency as aT, type PluginFactory as aU, type PluginManifest as aV, type RepeaterBlock as aW, RepeaterSource as aX, type SecretStore as aY, type SequenceStore as aZ, type SetupAction as a_, type IPlugin as aa, type IShippingPlugin as ab, type ISuppliersPlugin as ac, type IUiPlugin as ad, type InlineRowBlock as ae, InvoiceDocumentType as af, type InvoiceLine as ag, type InvoiceMoney as ah, type InvoiceParty as ai, type InvoiceRequest as aj, type InvoiceResult as ak, InvoiceStatus as al, type InvoiceTax as am, type InvoicingDefaultConfig as an, InvoicingFeature as ao, type InvoicingPluginConfig as ap, type InvoicingStaticConfig as aq, type KeyValueBlock$1 as ar, type KeyValueRow$1 as as, LayoutMode as at, type Logger as au, type MarkdownBlock as av, MessageVariant as aw, type PaymentCard as ax, type PaymentConnect as ay, type PaymentConnectExchange as az, type AccordionSection as b, type SetupLayoutValidation as b0, type SetupStep as b1, type ShipmentAddress as b2, type ShipmentParcel as b3, type ShipmentResult as b4, type ShippingDefaultConfig as b5, ShippingFeature as b6, type ShippingPluginConfig as b7, type ShippingQuote as b8, type ShippingQuoteParams as b9, type ToggleBlock as bA, type TrackingEvent as bB, TransactionStatus as bC, type UiContribution as bD, type UiContributionsValidation as bE, type VoidInvoiceInput as bF, type WebhookSignatureResult as bG, analyticsCapability as bH, capability as bI, crossValidateSetupLayout as bJ, definePlugin as bK, invoicingCapability as bL, isConfigurablePlugin as bM, isPluginFactory as bN, minorUnitDigits as bO, paymentCapability as bP, shippingCapability as bQ, suppliersCapability as bR, toMajorUnits as bS, toMinorUnits as bT, uiCapability as bU, validatePluginAuthor as bV, validateSetupLayout as bW, validateUiContributions as bX, type ShippingStaticConfig as ba, StepStatusFrom as bb, type StepStatusFromAction as bc, type StepStatusFromFields as bd, type StepStatusSource as be, type StorageBroker as bf, type SupplierCatalogQuery as bg, type SupplierFulfillmentEvent as bh, type SupplierListing as bi, type SupplierListingAttribute as bj, type SupplierListingPage as bk, type SupplierListingVariant as bl, type SupplierMoney as bm, type SupplierOrderAddressLevel as bn, type SupplierOrderCustomer as bo, type SupplierOrderLine as bp, type SupplierOrderResult as bq, type SupplierOrderStatus as br, type SupplierShipTo as bs, type SupplierStock as bt, type SuppliersDefaultConfig as bu, SuppliersFeature as bv, type SuppliersPluginConfig as bw, type SuppliersStaticConfig as bx, type TabItem as by, type TabsBlock as bz, type ActionBlock$1 as c, ActionVariant as d, type AnalyticsActionSource as e, type AnalyticsConsent as f, type AnalyticsEvent as g, type AnalyticsEventName as h, AnalyticsFeature as i, type AnalyticsItem as j, type AnalyticsMoney as k, type AnalyticsPluginConfig as l, type AnalyticsPurchasePolicy as m, type AnalyticsStaticConfig as n, type AnalyticsUserData as o, type AnalyticsUtm as p, type AuthorValidation as q, type Block as r, type BlockBase as s, BlockType as t, type CalloutBlock as u, type Capability as v, CapabilityKind as w, type CardBlock$1 as x, type CarrierServiceMode as y, type CarrierSettlement as z };
@@ -442,6 +442,8 @@ interface PaymentCard {
442
442
  interface PaymentCustomer {
443
443
  email: string;
444
444
  phone: string;
445
+ /** OPTIONAL full name of the payer, for gateways that display or require it. */
446
+ name?: string;
445
447
  address?: string;
446
448
  city?: string;
447
449
  state?: string;
@@ -478,6 +480,23 @@ interface PaymentResult {
478
480
  * - `embed` gateway-owned iframe initialised via `createPaymentSession`.
479
481
  */
480
482
  type PaymentRenderMode = 'card-in' | 'offsite-redirect' | 'embed';
483
+ /**
484
+ * Fee model a gateway charges the MERCHANT, declared statically so the host can
485
+ * project the fee before any charge exists (checkout preview, settlement
486
+ * breakdown). The fee is computed on the GROSS amount charged to the shopper.
487
+ */
488
+ interface GatewayFeeConfig {
489
+ /** Default merchant rate as a FRACTION of the gross (0.038 === 3.8%). */
490
+ defaultRate: number;
491
+ /** True when the rate already includes tax (IVA): no tax is added on top. */
492
+ ivaInclusive: boolean;
493
+ /**
494
+ * Where the rate comes from. `reported`: the gateway reports the effective
495
+ * rate per charge (webhook / pricing endpoint), so `defaultRate` is only a
496
+ * fallback. `contract`: a fixed contractual rate the gateway never reports.
497
+ */
498
+ source: 'reported' | 'contract';
499
+ }
481
500
  interface GatewayStaticConfig {
482
501
  code: PaymentGatewayCode;
483
502
  displayName: string;
@@ -490,6 +509,16 @@ interface GatewayStaticConfig {
490
509
  * Back-compat: existing card-in plugins (Wompi/Serfinsa) omit this field.
491
510
  */
492
511
  renderMode?: PaymentRenderMode;
512
+ /**
513
+ * OPTIONAL merchant fee model (see {@link GatewayFeeConfig}). Absent ⇒ the host
514
+ * assumes the gateway fee is unknown and shows no fee projection.
515
+ */
516
+ fees?: GatewayFeeConfig;
517
+ /**
518
+ * OPTIONAL ISO-4217 currencies the gateway can charge. Absent ⇒ the host does
519
+ * not restrict by currency.
520
+ */
521
+ supportedCurrencies?: string[];
493
522
  }
494
523
  /**
495
524
  * Cardless payload for creating a gateway-hosted payment session (INV-1).
@@ -532,6 +561,70 @@ interface PaymentSessionResult {
532
561
  renderMode: PaymentRenderMode;
533
562
  embedInit?: EmbedInit;
534
563
  redirectUrl?: string;
564
+ /**
565
+ * OPTIONAL merchant-fee PREVIEW the gateway computed when sealing the
566
+ * session. Informational: the settled fee arrives with the webhook
567
+ * ({@link PaymentWebhookSettlement.fees}).
568
+ */
569
+ fees?: PaymentSessionFees;
570
+ }
571
+ /**
572
+ * Merchant-fee preview attached to a created payment session. Amounts are in
573
+ * DECIMAL major units of `currency`; `rate` is a FRACTION.
574
+ */
575
+ interface PaymentSessionFees {
576
+ rate: number;
577
+ /** Free-form origin of the rate (e.g. `merchant`, `default`). */
578
+ rateSource?: string;
579
+ feeAmount: number;
580
+ netAmount: number;
581
+ currency: string;
582
+ }
583
+ /**
584
+ * Fee breakdown a gateway reports for a SETTLED charge. `feeAmount` is taken on
585
+ * the gross `amount`; `netAmount = amount - feeAmount`. Amounts are DECIMAL
586
+ * major units of `currency`; `rate` is a FRACTION.
587
+ */
588
+ interface PaymentSettlementFees {
589
+ feeAmount: number;
590
+ rate: number;
591
+ netAmount: number;
592
+ /** True when `feeAmount` already includes tax (IVA). */
593
+ ivaIncluded: boolean;
594
+ currency: string;
595
+ }
596
+ /**
597
+ * Final outcome of a charge as read from a gateway webhook, normalised by the
598
+ * plugin so the host settles every gateway through one path. Only terminal
599
+ * outcomes are expressed: intermediate events are not settlements.
600
+ */
601
+ interface PaymentWebhookSettlement {
602
+ /** Merchant reference the charge was created with (host correlation key). */
603
+ reference: string;
604
+ status: 'approved' | 'declined';
605
+ /** Gross amount charged, DECIMAL major units of `currency`. */
606
+ amount: number;
607
+ currency: string;
608
+ gatewayTransactionId: string;
609
+ /** Gateway-side transaction id, when distinct from `gatewayTransactionId`. */
610
+ transactionId?: string;
611
+ /** Gateway event id, stable across redeliveries (idempotency key). */
612
+ eventId?: string;
613
+ authorizationCode?: string;
614
+ /** Merchant fee breakdown, only when the gateway reports it. */
615
+ fees?: PaymentSettlementFees;
616
+ }
617
+ /**
618
+ * Merchant-specific pricing a gateway exposes, so the host can refresh its
619
+ * cached fee projection. `rate` is a FRACTION of the gross charged.
620
+ */
621
+ interface PaymentMerchantPricing {
622
+ rate: number;
623
+ /** Free-form origin of the rate (e.g. `merchant`, `default`). */
624
+ rateSource: string;
625
+ /** Free-form fee model identifier (e.g. `flat_gross_iva_included`). */
626
+ model: string;
627
+ currency: string;
535
628
  }
536
629
  interface PaymentPluginConfig {
537
630
  configSchema: PluginConfigField[];
@@ -582,6 +675,20 @@ interface IPaymentPlugin extends IPlugin {
582
675
  verifyTransaction?(payload: PaymentVerifyPayload, ctx: DispatchContext): Promise<PaymentResult>;
583
676
  validateWebhookSignature?(rawBody: string | Buffer, headers: Record<string, string>, ctx: DispatchContext): WebhookSignatureResult;
584
677
  processWebhook?(payload: unknown, ctx: DispatchContext): Promise<void>;
678
+ /**
679
+ * Normalise a webhook payload into a {@link PaymentWebhookSettlement}.
680
+ * OPTIONAL — a plugin that omits it keeps the host's legacy webhook parsing.
681
+ * Called by the host only AFTER `validateWebhookSignature` passed. PURE and
682
+ * synchronous: no I/O, no state. Throw on a payload that cannot be read as a
683
+ * terminal charge outcome; the host validates whatever it returns.
684
+ */
685
+ parseWebhookSettlement?(payload: unknown, ctx: DispatchContext): PaymentWebhookSettlement;
686
+ /**
687
+ * Merchant-specific pricing for the account in `ctx.config`. OPTIONAL — used
688
+ * by the host to refresh its cached fee projection. Resolve `null` when the
689
+ * gateway exposes no per-merchant pricing or it is unavailable right now.
690
+ */
691
+ getMerchantPricing?(ctx: DispatchContext): Promise<PaymentMerchantPricing | null>;
585
692
  /**
586
693
  * Query the gateway for the current status of a previously attempted charge.
587
694
  * Called by the host when `processPayment` returns `status: Error` with a
@@ -706,6 +813,32 @@ interface CreateShipmentParams {
706
813
  courierId?: string;
707
814
  serviceLevelToken?: string;
708
815
  }
816
+ /**
817
+ * How the carrier moves money on a shipment:
818
+ * - `normal` → nothing collected; the merchant is billed the shipping.
819
+ * - `cod` → the carrier collects from the recipient and settles to the merchant.
820
+ * - `collect` → the recipient pays only the shipping; nothing settles to the merchant.
821
+ */
822
+ type CarrierServiceMode = 'normal' | 'cod' | 'collect';
823
+ /**
824
+ * What the carrier ACTUALLY settles for a shipment, in the order currency —
825
+ * the carrier's truth, which the host shows next to what it quoted. Each
826
+ * shipping plugin translates its own provider fields into this; the host never
827
+ * reads `rawResponse`.
828
+ */
829
+ interface CarrierSettlement {
830
+ mode: CarrierServiceMode;
831
+ /** Cash the carrier collects from the recipient. */
832
+ collected: number;
833
+ /** Commission the carrier charges the merchant for collecting. */
834
+ commission: number;
835
+ /** That commission as a percent of `collected` (3 = 3%), when known. */
836
+ commissionRate?: number;
837
+ /** Shipping deducted from the settlement (0 when billed apart). */
838
+ shippingDeducted: number;
839
+ /** What the merchant receives for this shipment. */
840
+ merchantNet: number;
841
+ }
709
842
  interface ShipmentResult {
710
843
  externalId: string;
711
844
  trackingNumber: string;
@@ -715,6 +848,8 @@ interface ShipmentResult {
715
848
  courierName: string;
716
849
  status: string;
717
850
  rawResponse?: Record<string, unknown>;
851
+ /** The carrier's settlement, when the provider reports it at creation. */
852
+ settlement?: CarrierSettlement;
718
853
  }
719
854
  /**
720
855
  * Normalized, carrier-agnostic shipment status event produced by
@@ -792,9 +927,16 @@ interface SuppliersStaticConfig {
792
927
  }
793
928
  interface SupplierCatalogQuery {
794
929
  text?: string;
930
+ /** ISO-3166-1 alpha-2. A driver that cannot serve it returns an empty page. */
795
931
  country?: string;
796
932
  cursor?: string;
797
933
  limit?: number;
934
+ /** Wholesale price floor, minor units (inclusive). */
935
+ minPriceMinor?: number;
936
+ /** Wholesale price ceiling, minor units (inclusive). */
937
+ maxPriceMinor?: number;
938
+ /** Only listings the supplier reports as in stock. */
939
+ inStockOnly?: boolean;
798
940
  }
799
941
  interface SupplierListingVariant {
800
942
  externalVariantId: string;
@@ -833,12 +975,16 @@ interface SupplierListing {
833
975
  hasVariants: boolean;
834
976
  variants?: SupplierListingVariant[];
835
977
  moq?: number | null;
978
+ /** Display name of the vendor behind the listing (a marketplace may host many). */
979
+ vendorName?: string | null;
836
980
  /** Untouched supplier payload, for diagnostics. Never trusted for control flow. */
837
981
  raw?: unknown;
838
982
  }
839
983
  interface SupplierListingPage {
840
984
  items: SupplierListing[];
841
985
  nextCursor?: string | null;
986
+ /** Total listings matching the query across all pages, when the supplier reports it. */
987
+ total?: number | null;
842
988
  }
843
989
  interface SupplierOrderCustomer {
844
990
  name: string;
@@ -952,11 +1098,19 @@ declare enum AnalyticsFeature {
952
1098
  /**
953
1099
  * ISO-4217 money in minor units — mirrors the store's Money VO so the host maps
954
1100
  * 1:1 without a currency guess. Kept local so the SDK stays dependency-free.
1101
+ * The exponent is the currency's own (USD 2, CLP/JPY 0, KWD 3): encode with
1102
+ * {@link toMinorUnits}, decode with {@link toMajorUnits}, never a fixed ×100.
955
1103
  */
956
1104
  interface AnalyticsMoney {
957
1105
  amountMinor: number;
958
1106
  currency: string;
959
1107
  }
1108
+ /** ISO-4217 minor-unit exponent (USD 2, JPY 0, KWD 3); unknown → 2. */
1109
+ declare function minorUnitDigits(currency: string): number;
1110
+ /** A major-unit amount (e.g. `25.5` USD) as {@link AnalyticsMoney}. */
1111
+ declare function toMinorUnits(major: number, currency: string): AnalyticsMoney;
1112
+ /** The major-unit decimal of {@link AnalyticsMoney} (e.g. `2550` USD → `25.5`). */
1113
+ declare function toMajorUnits(money: AnalyticsMoney): number;
960
1114
  /** A single line item attached to an ecommerce event. */
961
1115
  interface AnalyticsItem {
962
1116
  /** Product id as the store knows it (Meta `content_ids`, GA4 `item_id`). */
@@ -976,7 +1130,25 @@ interface AnalyticsItem {
976
1130
  * only ever maps a domain event to one of these. An adapter that does not care
977
1131
  * about a given name simply ignores it.
978
1132
  */
979
- type AnalyticsEventName = 'page_view' | 'view_item' | 'add_to_cart' | 'remove_from_cart' | 'begin_checkout' | 'purchase';
1133
+ type AnalyticsEventName = 'page_view' | 'view_item' | 'add_to_cart' | 'remove_from_cart' | 'begin_checkout' | 'purchase' | 'order_placed';
1134
+ /**
1135
+ * When a cash-on-delivery order counts as a `purchase` for an adapter:
1136
+ * - `collected` — when the cash is collected (carrier delivery or staff
1137
+ * marking it paid). Highest signal quality; the default.
1138
+ * - `confirmed` — when staff confirms the order (e.g. after a confirmation
1139
+ * call). Faster learning and inside the ad platform's dedup/attribution
1140
+ * windows, at the cost of counting confirmed orders the shopper refuses.
1141
+ * Prepaid orders always convert when the gateway approves the payment.
1142
+ */
1143
+ type CodPurchaseTrigger = 'collected' | 'confirmed';
1144
+ /**
1145
+ * Per-store settlement policy the HOST reads from an analytics adapter's own
1146
+ * config (`DispatchContext.config`). An adapter opts in by declaring a config
1147
+ * field with this exact key; one that declares none gets the defaults.
1148
+ */
1149
+ interface AnalyticsPurchasePolicy {
1150
+ codPurchaseTrigger?: CodPurchaseTrigger;
1151
+ }
980
1152
  /**
981
1153
  * Where the action physically happened. Maps to Meta `action_source`; other
982
1154
  * providers ignore it. Defaults to `website` when the host omits it.
@@ -1004,7 +1176,11 @@ interface AnalyticsUserData {
1004
1176
  genderSha256?: string | null;
1005
1177
  /** Date of birth, YYYYMMDD normalized then SHA256. */
1006
1178
  dobSha256?: string | null;
1007
- /** Store customer/user id — Meta `external_id` (not hashed by spec). */
1179
+ /**
1180
+ * Pseudonymous shopper id (user, else guest) — Meta `external_id`. Arrives
1181
+ * PLAIN: it is not PII. An adapter whose provider wants it hashed (Meta, to
1182
+ * meet the browser pixel) hashes it itself.
1183
+ */
1008
1184
  externalId?: string | null;
1009
1185
  /** Plain IPv4/IPv6 — never hashed (geo match). */
1010
1186
  clientIpAddress?: string | null;
@@ -1566,4 +1742,4 @@ interface HostApi {
1566
1742
  registerCapability<T = unknown>(cap: Capability<T>): void;
1567
1743
  }
1568
1744
 
1569
- export { type HttpClient as $, AUTHOR_HANDLE_RE as A, type BannerBlock$1 as B, ConfigScope as C, type ConditionalBlock as D, type ConditionalEquals as E, FieldType as F, type ConditionalWhen as G, type ConfigurablePlugin as H, ContentActionVariant as I, type ContentBlock as J, ContentBlockType as K, type CopyFieldBlock$1 as L, type CreateShipmentParams as M, type DispatchContext as N, type DividerBlock$1 as O, type PluginConfigField as P, type DomainEventHandler as Q, type DomainEventName as R, type SelectOption as S, type EmbedInit as T, type FieldBlock as U, type FieldOption as V, FieldVariant as W, GatewayEnvironment as X, type GatewayStaticConfig as Y, type GroupBlock as Z, type HostApi as _, type AccordionBlock as a, type ShippingQuote as a$, type HttpRequest as a0, type HttpResponse as a1, type IAnalyticsPlugin as a2, type IInvoicingPlugin as a3, type IPaymentPlugin as a4, type IPlugin as a5, type IShippingPlugin as a6, type ISuppliersPlugin as a7, type IUiPlugin as a8, type InlineRowBlock as a9, type PaymentRenderMode as aA, type PaymentResult as aB, type PaymentSessionPayload as aC, type PaymentSessionResult as aD, type PaymentVerifyPayload as aE, type PlaceSupplierOrderInput as aF, type Plugin as aG, type PluginActionContext as aH, type PluginActionResult as aI, type PluginAuthor as aJ, type PluginConfigFieldDependency as aK, type PluginFactory as aL, type PluginManifest as aM, type RepeaterBlock as aN, RepeaterSource as aO, type SecretStore as aP, type SequenceStore as aQ, type SetupAction as aR, type SetupLayout as aS, type SetupLayoutValidation as aT, type SetupStep as aU, type ShipmentAddress as aV, type ShipmentParcel as aW, type ShipmentResult as aX, type ShippingDefaultConfig as aY, ShippingFeature as aZ, type ShippingPluginConfig as a_, InvoiceDocumentType as aa, type InvoiceLine as ab, type InvoiceMoney as ac, type InvoiceParty as ad, type InvoiceRequest as ae, type InvoiceResult as af, InvoiceStatus as ag, type InvoiceTax as ah, type InvoicingDefaultConfig as ai, InvoicingFeature as aj, type InvoicingPluginConfig as ak, type InvoicingStaticConfig as al, type KeyValueBlock$1 as am, type KeyValueRow$1 as an, LayoutMode as ao, type Logger as ap, type MarkdownBlock as aq, MessageVariant as ar, type PaymentCard as as, type PaymentConnect as at, type PaymentConnectExchange as au, type PaymentConnectParams as av, type PaymentCustomer as aw, type PaymentGatewayCode as ax, type PaymentPayload as ay, type PaymentPluginConfig as az, type AccordionSection as b, type ShippingQuoteParams as b0, type ShippingStaticConfig as b1, StepStatusFrom as b2, type StepStatusFromAction as b3, type StepStatusFromFields as b4, type StepStatusSource as b5, type StorageBroker as b6, type SupplierCatalogQuery as b7, type SupplierFulfillmentEvent as b8, type SupplierListing as b9, crossValidateSetupLayout as bA, definePlugin as bB, invoicingCapability as bC, isConfigurablePlugin as bD, isPluginFactory as bE, paymentCapability as bF, shippingCapability as bG, suppliersCapability as bH, uiCapability as bI, validatePluginAuthor as bJ, validateSetupLayout as bK, validateUiContributions as bL, type SupplierListingAttribute as ba, type SupplierListingPage as bb, type SupplierListingVariant as bc, type SupplierMoney as bd, type SupplierOrderAddressLevel as be, type SupplierOrderCustomer as bf, type SupplierOrderLine as bg, type SupplierOrderResult as bh, type SupplierOrderStatus as bi, type SupplierShipTo as bj, type SupplierStock as bk, type SuppliersDefaultConfig as bl, SuppliersFeature as bm, type SuppliersPluginConfig as bn, type SuppliersStaticConfig as bo, type TabItem as bp, type TabsBlock as bq, type ToggleBlock as br, type TrackingEvent as bs, TransactionStatus as bt, type UiContribution as bu, type UiContributionsValidation as bv, type VoidInvoiceInput as bw, type WebhookSignatureResult as bx, analyticsCapability as by, capability as bz, type ActionBlock$1 as c, ActionVariant as d, type AnalyticsActionSource as e, type AnalyticsConsent as f, type AnalyticsEvent as g, type AnalyticsEventName as h, AnalyticsFeature as i, type AnalyticsItem as j, type AnalyticsMoney as k, type AnalyticsPluginConfig as l, type AnalyticsStaticConfig as m, type AnalyticsUserData as n, type AnalyticsUtm as o, type AuthorValidation as p, type Block as q, type BlockBase as r, BlockType as s, type CalloutBlock as t, type Capability as u, CapabilityKind as v, type CardBlock$1 as w, type CodConfig as x, type CodFeeConfig as y, CodFeeType as z };
1745
+ export { GatewayEnvironment as $, AUTHOR_HANDLE_RE as A, type BannerBlock$1 as B, ConfigScope as C, type CodConfig as D, type CodFeeConfig as E, FieldType as F, CodFeeType as G, type CodPurchaseTrigger as H, type ConditionalBlock as I, type ConditionalEquals as J, type ConditionalWhen as K, type ConfigurablePlugin as L, ContentActionVariant as M, type ContentBlock as N, ContentBlockType as O, type PluginConfigField as P, type CopyFieldBlock$1 as Q, type CreateShipmentParams as R, type SelectOption as S, type DispatchContext as T, type DividerBlock$1 as U, type DomainEventHandler as V, type DomainEventName as W, type EmbedInit as X, type FieldBlock as Y, type FieldOption as Z, FieldVariant as _, type AccordionBlock as a, type SetupLayout as a$, type GatewayFeeConfig as a0, type GatewayStaticConfig as a1, type GroupBlock as a2, type HostApi as a3, type HttpClient as a4, type HttpRequest as a5, type HttpResponse as a6, type IAnalyticsPlugin as a7, type IInvoicingPlugin as a8, type IPaymentPlugin as a9, type PaymentConnectParams as aA, type PaymentCustomer as aB, type PaymentGatewayCode as aC, type PaymentMerchantPricing as aD, type PaymentPayload as aE, type PaymentPluginConfig as aF, type PaymentRenderMode as aG, type PaymentResult as aH, type PaymentSessionFees as aI, type PaymentSessionPayload as aJ, type PaymentSessionResult as aK, type PaymentSettlementFees as aL, type PaymentVerifyPayload as aM, type PaymentWebhookSettlement as aN, type PlaceSupplierOrderInput as aO, type Plugin as aP, type PluginActionContext as aQ, type PluginActionResult as aR, type PluginAuthor as aS, type PluginConfigFieldDependency as aT, type PluginFactory as aU, type PluginManifest as aV, type RepeaterBlock as aW, RepeaterSource as aX, type SecretStore as aY, type SequenceStore as aZ, type SetupAction as a_, type IPlugin as aa, type IShippingPlugin as ab, type ISuppliersPlugin as ac, type IUiPlugin as ad, type InlineRowBlock as ae, InvoiceDocumentType as af, type InvoiceLine as ag, type InvoiceMoney as ah, type InvoiceParty as ai, type InvoiceRequest as aj, type InvoiceResult as ak, InvoiceStatus as al, type InvoiceTax as am, type InvoicingDefaultConfig as an, InvoicingFeature as ao, type InvoicingPluginConfig as ap, type InvoicingStaticConfig as aq, type KeyValueBlock$1 as ar, type KeyValueRow$1 as as, LayoutMode as at, type Logger as au, type MarkdownBlock as av, MessageVariant as aw, type PaymentCard as ax, type PaymentConnect as ay, type PaymentConnectExchange as az, type AccordionSection as b, type SetupLayoutValidation as b0, type SetupStep as b1, type ShipmentAddress as b2, type ShipmentParcel as b3, type ShipmentResult as b4, type ShippingDefaultConfig as b5, ShippingFeature as b6, type ShippingPluginConfig as b7, type ShippingQuote as b8, type ShippingQuoteParams as b9, type ToggleBlock as bA, type TrackingEvent as bB, TransactionStatus as bC, type UiContribution as bD, type UiContributionsValidation as bE, type VoidInvoiceInput as bF, type WebhookSignatureResult as bG, analyticsCapability as bH, capability as bI, crossValidateSetupLayout as bJ, definePlugin as bK, invoicingCapability as bL, isConfigurablePlugin as bM, isPluginFactory as bN, minorUnitDigits as bO, paymentCapability as bP, shippingCapability as bQ, suppliersCapability as bR, toMajorUnits as bS, toMinorUnits as bT, uiCapability as bU, validatePluginAuthor as bV, validateSetupLayout as bW, validateUiContributions as bX, type ShippingStaticConfig as ba, StepStatusFrom as bb, type StepStatusFromAction as bc, type StepStatusFromFields as bd, type StepStatusSource as be, type StorageBroker as bf, type SupplierCatalogQuery as bg, type SupplierFulfillmentEvent as bh, type SupplierListing as bi, type SupplierListingAttribute as bj, type SupplierListingPage as bk, type SupplierListingVariant as bl, type SupplierMoney as bm, type SupplierOrderAddressLevel as bn, type SupplierOrderCustomer as bo, type SupplierOrderLine as bp, type SupplierOrderResult as bq, type SupplierOrderStatus as br, type SupplierShipTo as bs, type SupplierStock as bt, type SuppliersDefaultConfig as bu, SuppliersFeature as bv, type SuppliersPluginConfig as bw, type SuppliersStaticConfig as bx, type TabItem as by, type TabsBlock as bz, type ActionBlock$1 as c, ActionVariant as d, type AnalyticsActionSource as e, type AnalyticsConsent as f, type AnalyticsEvent as g, type AnalyticsEventName as h, AnalyticsFeature as i, type AnalyticsItem as j, type AnalyticsMoney as k, type AnalyticsPluginConfig as l, type AnalyticsPurchasePolicy as m, type AnalyticsStaticConfig as n, type AnalyticsUserData as o, type AnalyticsUtm as p, type AuthorValidation as q, type Block as r, type BlockBase as s, BlockType as t, type CalloutBlock as u, type Capability as v, CapabilityKind as w, type CardBlock$1 as x, type CarrierServiceMode as y, type CarrierSettlement as z };
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { F as FieldType, C as ConfigScope, S as SelectOption, P as PluginConfigField } from './host-api-BbIT_sLc.mjs';
2
- export { A as AUTHOR_HANDLE_RE, a as AccordionBlock, b as AccordionSection, c as ActionBlock, d as ActionVariant, e as AnalyticsActionSource, f as AnalyticsConsent, g as AnalyticsEvent, h as AnalyticsEventName, i as AnalyticsFeature, j as AnalyticsItem, k as AnalyticsMoney, l as AnalyticsPluginConfig, m as AnalyticsStaticConfig, n as AnalyticsUserData, o as AnalyticsUtm, p as AuthorValidation, B as BannerBlock, q as Block, r as BlockBase, s as BlockType, t as CalloutBlock, u as Capability, v as CapabilityKind, w as CardBlock, x as CodConfig, y as CodFeeConfig, z as CodFeeType, D as ConditionalBlock, E as ConditionalEquals, G as ConditionalWhen, H as ConfigurablePlugin, I as ContentActionVariant, J as ContentBlock, K as ContentBlockType, L as CopyFieldBlock, M as CreateShipmentParams, N as DispatchContext, O as DividerBlock, Q as DomainEventHandler, R as DomainEventName, T as EmbedInit, U as FieldBlock, V as FieldOption, W as FieldVariant, X as GatewayEnvironment, Y as GatewayStaticConfig, Z as GroupBlock, _ as HostApi, $ as HttpClient, a0 as HttpRequest, a1 as HttpResponse, a2 as IAnalyticsPlugin, a3 as IInvoicingPlugin, a4 as IPaymentPlugin, a5 as IPlugin, a6 as IShippingPlugin, a7 as ISuppliersPlugin, a8 as IUiPlugin, a9 as InlineRowBlock, aa as InvoiceDocumentType, ab as InvoiceLine, ac as InvoiceMoney, ad as InvoiceParty, ae as InvoiceRequest, af as InvoiceResult, ag as InvoiceStatus, ah as InvoiceTax, ai as InvoicingDefaultConfig, aj as InvoicingFeature, ak as InvoicingPluginConfig, al as InvoicingStaticConfig, am as KeyValueBlock, an as KeyValueRow, ao as LayoutMode, ap as Logger, aq as MarkdownBlock, ar as MessageVariant, as as PaymentCard, at as PaymentConnect, au as PaymentConnectExchange, av as PaymentConnectParams, aw as PaymentCustomer, ax as PaymentGatewayCode, ay as PaymentPayload, az as PaymentPluginConfig, aA as PaymentRenderMode, aB as PaymentResult, aC as PaymentSessionPayload, aD as PaymentSessionResult, aE as PaymentVerifyPayload, aF as PlaceSupplierOrderInput, aG as Plugin, aH as PluginActionContext, aI as PluginActionResult, aJ as PluginAuthor, aK as PluginConfigFieldDependency, aL as PluginFactory, aM as PluginManifest, aN as RepeaterBlock, aO as RepeaterSource, aP as SecretStore, aQ as SequenceStore, aR as SetupAction, aS as SetupLayout, aT as SetupLayoutValidation, aU as SetupStep, aV as ShipmentAddress, aW as ShipmentParcel, aX as ShipmentResult, aY as ShippingDefaultConfig, aZ as ShippingFeature, a_ as ShippingPluginConfig, a$ as ShippingQuote, b0 as ShippingQuoteParams, b1 as ShippingStaticConfig, b2 as StepStatusFrom, b3 as StepStatusFromAction, b4 as StepStatusFromFields, b5 as StepStatusSource, b6 as StorageBroker, b7 as SupplierCatalogQuery, b8 as SupplierFulfillmentEvent, b9 as SupplierListing, ba as SupplierListingAttribute, bb as SupplierListingPage, bc as SupplierListingVariant, bd as SupplierMoney, be as SupplierOrderAddressLevel, bf as SupplierOrderCustomer, bg as SupplierOrderLine, bh as SupplierOrderResult, bi as SupplierOrderStatus, bj as SupplierShipTo, bk as SupplierStock, bl as SuppliersDefaultConfig, bm as SuppliersFeature, bn as SuppliersPluginConfig, bo as SuppliersStaticConfig, bp as TabItem, bq as TabsBlock, br as ToggleBlock, bs as TrackingEvent, bt as TransactionStatus, bu as UiContribution, bv as UiContributionsValidation, bw as VoidInvoiceInput, bx as WebhookSignatureResult, by as analyticsCapability, bz as capability, bA as crossValidateSetupLayout, bB as definePlugin, bC as invoicingCapability, bD as isConfigurablePlugin, bE as isPluginFactory, bF as paymentCapability, bG as shippingCapability, bH as suppliersCapability, bI as uiCapability, bJ as validatePluginAuthor, bK as validateSetupLayout, bL as validateUiContributions } from './host-api-BbIT_sLc.mjs';
1
+ import { F as FieldType, C as ConfigScope, S as SelectOption, P as PluginConfigField } from './host-api-Eeb42fR2.mjs';
2
+ export { A as AUTHOR_HANDLE_RE, a as AccordionBlock, b as AccordionSection, c as ActionBlock, d as ActionVariant, e as AnalyticsActionSource, f as AnalyticsConsent, g as AnalyticsEvent, h as AnalyticsEventName, i as AnalyticsFeature, j as AnalyticsItem, k as AnalyticsMoney, l as AnalyticsPluginConfig, m as AnalyticsPurchasePolicy, n as AnalyticsStaticConfig, o as AnalyticsUserData, p as AnalyticsUtm, q as AuthorValidation, B as BannerBlock, r as Block, s as BlockBase, t as BlockType, u as CalloutBlock, v as Capability, w as CapabilityKind, x as CardBlock, y as CarrierServiceMode, z as CarrierSettlement, D as CodConfig, E as CodFeeConfig, G as CodFeeType, H as CodPurchaseTrigger, I as ConditionalBlock, J as ConditionalEquals, K as ConditionalWhen, L as ConfigurablePlugin, M as ContentActionVariant, N as ContentBlock, O as ContentBlockType, Q as CopyFieldBlock, R as CreateShipmentParams, T as DispatchContext, U as DividerBlock, V as DomainEventHandler, W as DomainEventName, X as EmbedInit, Y as FieldBlock, Z as FieldOption, _ as FieldVariant, $ as GatewayEnvironment, a0 as GatewayFeeConfig, a1 as GatewayStaticConfig, a2 as GroupBlock, a3 as HostApi, a4 as HttpClient, a5 as HttpRequest, a6 as HttpResponse, a7 as IAnalyticsPlugin, a8 as IInvoicingPlugin, a9 as IPaymentPlugin, aa as IPlugin, ab as IShippingPlugin, ac as ISuppliersPlugin, ad as IUiPlugin, ae as InlineRowBlock, af as InvoiceDocumentType, ag as InvoiceLine, ah as InvoiceMoney, ai as InvoiceParty, aj as InvoiceRequest, ak as InvoiceResult, al as InvoiceStatus, am as InvoiceTax, an as InvoicingDefaultConfig, ao as InvoicingFeature, ap as InvoicingPluginConfig, aq as InvoicingStaticConfig, ar as KeyValueBlock, as as KeyValueRow, at as LayoutMode, au as Logger, av as MarkdownBlock, aw as MessageVariant, ax as PaymentCard, ay as PaymentConnect, az as PaymentConnectExchange, aA as PaymentConnectParams, aB as PaymentCustomer, aC as PaymentGatewayCode, aD as PaymentMerchantPricing, aE as PaymentPayload, aF as PaymentPluginConfig, aG as PaymentRenderMode, aH as PaymentResult, aI as PaymentSessionFees, aJ as PaymentSessionPayload, aK as PaymentSessionResult, aL as PaymentSettlementFees, aM as PaymentVerifyPayload, aN as PaymentWebhookSettlement, aO as PlaceSupplierOrderInput, aP as Plugin, aQ as PluginActionContext, aR as PluginActionResult, aS as PluginAuthor, aT as PluginConfigFieldDependency, aU as PluginFactory, aV as PluginManifest, aW as RepeaterBlock, aX as RepeaterSource, aY as SecretStore, aZ as SequenceStore, a_ as SetupAction, a$ as SetupLayout, b0 as SetupLayoutValidation, b1 as SetupStep, b2 as ShipmentAddress, b3 as ShipmentParcel, b4 as ShipmentResult, b5 as ShippingDefaultConfig, b6 as ShippingFeature, b7 as ShippingPluginConfig, b8 as ShippingQuote, b9 as ShippingQuoteParams, ba as ShippingStaticConfig, bb as StepStatusFrom, bc as StepStatusFromAction, bd as StepStatusFromFields, be as StepStatusSource, bf as StorageBroker, bg as SupplierCatalogQuery, bh as SupplierFulfillmentEvent, bi as SupplierListing, bj as SupplierListingAttribute, bk as SupplierListingPage, bl as SupplierListingVariant, bm as SupplierMoney, bn as SupplierOrderAddressLevel, bo as SupplierOrderCustomer, bp as SupplierOrderLine, bq as SupplierOrderResult, br as SupplierOrderStatus, bs as SupplierShipTo, bt as SupplierStock, bu as SuppliersDefaultConfig, bv as SuppliersFeature, bw as SuppliersPluginConfig, bx as SuppliersStaticConfig, by as TabItem, bz as TabsBlock, bA as ToggleBlock, bB as TrackingEvent, bC as TransactionStatus, bD as UiContribution, bE as UiContributionsValidation, bF as VoidInvoiceInput, bG as WebhookSignatureResult, bH as analyticsCapability, bI as capability, bJ as crossValidateSetupLayout, bK as definePlugin, bL as invoicingCapability, bM as isConfigurablePlugin, bN as isPluginFactory, bO as minorUnitDigits, bP as paymentCapability, bQ as shippingCapability, bR as suppliersCapability, bS as toMajorUnits, bT as toMinorUnits, bU as uiCapability, bV as validatePluginAuthor, bW as validateSetupLayout, bX as validateUiContributions } from './host-api-Eeb42fR2.mjs';
3
3
 
4
4
  declare const PAYMENT_PLUGIN_TOKEN: "PAYMENT_PLUGINS";
5
5
  declare const SHIPPING_PLUGIN_TOKEN: "SHIPPING_PLUGINS";
@@ -74,7 +74,7 @@ declare function checkPermissions(required: string[], grantedRaw: string[]): Per
74
74
  * - MINOR: additive (new optional fields, new tokens) — backwards compatible.
75
75
  * - PATCH: docs/fixes with zero shape changes.
76
76
  */
77
- declare const SDK_VERSION = "0.6.8";
77
+ declare const SDK_VERSION = "0.6.9";
78
78
  /**
79
79
  * True when a plugin built against `pluginSdkVersion` can run on a host that
80
80
  * ships `hostSdkVersion`. Rule: same major, host minor >= plugin minor.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { F as FieldType, C as ConfigScope, S as SelectOption, P as PluginConfigField } from './host-api-BbIT_sLc.js';
2
- export { A as AUTHOR_HANDLE_RE, a as AccordionBlock, b as AccordionSection, c as ActionBlock, d as ActionVariant, e as AnalyticsActionSource, f as AnalyticsConsent, g as AnalyticsEvent, h as AnalyticsEventName, i as AnalyticsFeature, j as AnalyticsItem, k as AnalyticsMoney, l as AnalyticsPluginConfig, m as AnalyticsStaticConfig, n as AnalyticsUserData, o as AnalyticsUtm, p as AuthorValidation, B as BannerBlock, q as Block, r as BlockBase, s as BlockType, t as CalloutBlock, u as Capability, v as CapabilityKind, w as CardBlock, x as CodConfig, y as CodFeeConfig, z as CodFeeType, D as ConditionalBlock, E as ConditionalEquals, G as ConditionalWhen, H as ConfigurablePlugin, I as ContentActionVariant, J as ContentBlock, K as ContentBlockType, L as CopyFieldBlock, M as CreateShipmentParams, N as DispatchContext, O as DividerBlock, Q as DomainEventHandler, R as DomainEventName, T as EmbedInit, U as FieldBlock, V as FieldOption, W as FieldVariant, X as GatewayEnvironment, Y as GatewayStaticConfig, Z as GroupBlock, _ as HostApi, $ as HttpClient, a0 as HttpRequest, a1 as HttpResponse, a2 as IAnalyticsPlugin, a3 as IInvoicingPlugin, a4 as IPaymentPlugin, a5 as IPlugin, a6 as IShippingPlugin, a7 as ISuppliersPlugin, a8 as IUiPlugin, a9 as InlineRowBlock, aa as InvoiceDocumentType, ab as InvoiceLine, ac as InvoiceMoney, ad as InvoiceParty, ae as InvoiceRequest, af as InvoiceResult, ag as InvoiceStatus, ah as InvoiceTax, ai as InvoicingDefaultConfig, aj as InvoicingFeature, ak as InvoicingPluginConfig, al as InvoicingStaticConfig, am as KeyValueBlock, an as KeyValueRow, ao as LayoutMode, ap as Logger, aq as MarkdownBlock, ar as MessageVariant, as as PaymentCard, at as PaymentConnect, au as PaymentConnectExchange, av as PaymentConnectParams, aw as PaymentCustomer, ax as PaymentGatewayCode, ay as PaymentPayload, az as PaymentPluginConfig, aA as PaymentRenderMode, aB as PaymentResult, aC as PaymentSessionPayload, aD as PaymentSessionResult, aE as PaymentVerifyPayload, aF as PlaceSupplierOrderInput, aG as Plugin, aH as PluginActionContext, aI as PluginActionResult, aJ as PluginAuthor, aK as PluginConfigFieldDependency, aL as PluginFactory, aM as PluginManifest, aN as RepeaterBlock, aO as RepeaterSource, aP as SecretStore, aQ as SequenceStore, aR as SetupAction, aS as SetupLayout, aT as SetupLayoutValidation, aU as SetupStep, aV as ShipmentAddress, aW as ShipmentParcel, aX as ShipmentResult, aY as ShippingDefaultConfig, aZ as ShippingFeature, a_ as ShippingPluginConfig, a$ as ShippingQuote, b0 as ShippingQuoteParams, b1 as ShippingStaticConfig, b2 as StepStatusFrom, b3 as StepStatusFromAction, b4 as StepStatusFromFields, b5 as StepStatusSource, b6 as StorageBroker, b7 as SupplierCatalogQuery, b8 as SupplierFulfillmentEvent, b9 as SupplierListing, ba as SupplierListingAttribute, bb as SupplierListingPage, bc as SupplierListingVariant, bd as SupplierMoney, be as SupplierOrderAddressLevel, bf as SupplierOrderCustomer, bg as SupplierOrderLine, bh as SupplierOrderResult, bi as SupplierOrderStatus, bj as SupplierShipTo, bk as SupplierStock, bl as SuppliersDefaultConfig, bm as SuppliersFeature, bn as SuppliersPluginConfig, bo as SuppliersStaticConfig, bp as TabItem, bq as TabsBlock, br as ToggleBlock, bs as TrackingEvent, bt as TransactionStatus, bu as UiContribution, bv as UiContributionsValidation, bw as VoidInvoiceInput, bx as WebhookSignatureResult, by as analyticsCapability, bz as capability, bA as crossValidateSetupLayout, bB as definePlugin, bC as invoicingCapability, bD as isConfigurablePlugin, bE as isPluginFactory, bF as paymentCapability, bG as shippingCapability, bH as suppliersCapability, bI as uiCapability, bJ as validatePluginAuthor, bK as validateSetupLayout, bL as validateUiContributions } from './host-api-BbIT_sLc.js';
1
+ import { F as FieldType, C as ConfigScope, S as SelectOption, P as PluginConfigField } from './host-api-Eeb42fR2.js';
2
+ export { A as AUTHOR_HANDLE_RE, a as AccordionBlock, b as AccordionSection, c as ActionBlock, d as ActionVariant, e as AnalyticsActionSource, f as AnalyticsConsent, g as AnalyticsEvent, h as AnalyticsEventName, i as AnalyticsFeature, j as AnalyticsItem, k as AnalyticsMoney, l as AnalyticsPluginConfig, m as AnalyticsPurchasePolicy, n as AnalyticsStaticConfig, o as AnalyticsUserData, p as AnalyticsUtm, q as AuthorValidation, B as BannerBlock, r as Block, s as BlockBase, t as BlockType, u as CalloutBlock, v as Capability, w as CapabilityKind, x as CardBlock, y as CarrierServiceMode, z as CarrierSettlement, D as CodConfig, E as CodFeeConfig, G as CodFeeType, H as CodPurchaseTrigger, I as ConditionalBlock, J as ConditionalEquals, K as ConditionalWhen, L as ConfigurablePlugin, M as ContentActionVariant, N as ContentBlock, O as ContentBlockType, Q as CopyFieldBlock, R as CreateShipmentParams, T as DispatchContext, U as DividerBlock, V as DomainEventHandler, W as DomainEventName, X as EmbedInit, Y as FieldBlock, Z as FieldOption, _ as FieldVariant, $ as GatewayEnvironment, a0 as GatewayFeeConfig, a1 as GatewayStaticConfig, a2 as GroupBlock, a3 as HostApi, a4 as HttpClient, a5 as HttpRequest, a6 as HttpResponse, a7 as IAnalyticsPlugin, a8 as IInvoicingPlugin, a9 as IPaymentPlugin, aa as IPlugin, ab as IShippingPlugin, ac as ISuppliersPlugin, ad as IUiPlugin, ae as InlineRowBlock, af as InvoiceDocumentType, ag as InvoiceLine, ah as InvoiceMoney, ai as InvoiceParty, aj as InvoiceRequest, ak as InvoiceResult, al as InvoiceStatus, am as InvoiceTax, an as InvoicingDefaultConfig, ao as InvoicingFeature, ap as InvoicingPluginConfig, aq as InvoicingStaticConfig, ar as KeyValueBlock, as as KeyValueRow, at as LayoutMode, au as Logger, av as MarkdownBlock, aw as MessageVariant, ax as PaymentCard, ay as PaymentConnect, az as PaymentConnectExchange, aA as PaymentConnectParams, aB as PaymentCustomer, aC as PaymentGatewayCode, aD as PaymentMerchantPricing, aE as PaymentPayload, aF as PaymentPluginConfig, aG as PaymentRenderMode, aH as PaymentResult, aI as PaymentSessionFees, aJ as PaymentSessionPayload, aK as PaymentSessionResult, aL as PaymentSettlementFees, aM as PaymentVerifyPayload, aN as PaymentWebhookSettlement, aO as PlaceSupplierOrderInput, aP as Plugin, aQ as PluginActionContext, aR as PluginActionResult, aS as PluginAuthor, aT as PluginConfigFieldDependency, aU as PluginFactory, aV as PluginManifest, aW as RepeaterBlock, aX as RepeaterSource, aY as SecretStore, aZ as SequenceStore, a_ as SetupAction, a$ as SetupLayout, b0 as SetupLayoutValidation, b1 as SetupStep, b2 as ShipmentAddress, b3 as ShipmentParcel, b4 as ShipmentResult, b5 as ShippingDefaultConfig, b6 as ShippingFeature, b7 as ShippingPluginConfig, b8 as ShippingQuote, b9 as ShippingQuoteParams, ba as ShippingStaticConfig, bb as StepStatusFrom, bc as StepStatusFromAction, bd as StepStatusFromFields, be as StepStatusSource, bf as StorageBroker, bg as SupplierCatalogQuery, bh as SupplierFulfillmentEvent, bi as SupplierListing, bj as SupplierListingAttribute, bk as SupplierListingPage, bl as SupplierListingVariant, bm as SupplierMoney, bn as SupplierOrderAddressLevel, bo as SupplierOrderCustomer, bp as SupplierOrderLine, bq as SupplierOrderResult, br as SupplierOrderStatus, bs as SupplierShipTo, bt as SupplierStock, bu as SuppliersDefaultConfig, bv as SuppliersFeature, bw as SuppliersPluginConfig, bx as SuppliersStaticConfig, by as TabItem, bz as TabsBlock, bA as ToggleBlock, bB as TrackingEvent, bC as TransactionStatus, bD as UiContribution, bE as UiContributionsValidation, bF as VoidInvoiceInput, bG as WebhookSignatureResult, bH as analyticsCapability, bI as capability, bJ as crossValidateSetupLayout, bK as definePlugin, bL as invoicingCapability, bM as isConfigurablePlugin, bN as isPluginFactory, bO as minorUnitDigits, bP as paymentCapability, bQ as shippingCapability, bR as suppliersCapability, bS as toMajorUnits, bT as toMinorUnits, bU as uiCapability, bV as validatePluginAuthor, bW as validateSetupLayout, bX as validateUiContributions } from './host-api-Eeb42fR2.js';
3
3
 
4
4
  declare const PAYMENT_PLUGIN_TOKEN: "PAYMENT_PLUGINS";
5
5
  declare const SHIPPING_PLUGIN_TOKEN: "SHIPPING_PLUGINS";
@@ -74,7 +74,7 @@ declare function checkPermissions(required: string[], grantedRaw: string[]): Per
74
74
  * - MINOR: additive (new optional fields, new tokens) — backwards compatible.
75
75
  * - PATCH: docs/fixes with zero shape changes.
76
76
  */
77
- declare const SDK_VERSION = "0.6.8";
77
+ declare const SDK_VERSION = "0.6.9";
78
78
  /**
79
79
  * True when a plugin built against `pluginSdkVersion` can run on a host that
80
80
  * ships `hostSdkVersion`. Rule: same major, host minor >= plugin minor.
package/dist/index.js CHANGED
@@ -60,10 +60,13 @@ __export(index_exports, {
60
60
  isPermissionGranted: () => isPermissionGranted,
61
61
  isPluginFactory: () => isPluginFactory,
62
62
  isSdkCompatible: () => isSdkCompatible,
63
+ minorUnitDigits: () => minorUnitDigits,
63
64
  parsePermission: () => parsePermission,
64
65
  paymentCapability: () => paymentCapability,
65
66
  shippingCapability: () => shippingCapability,
66
67
  suppliersCapability: () => suppliersCapability,
68
+ toMajorUnits: () => toMajorUnits,
69
+ toMinorUnits: () => toMinorUnits,
67
70
  uiCapability: () => uiCapability,
68
71
  validatePluginAuthor: () => validatePluginAuthor,
69
72
  validateSetupLayout: () => validateSetupLayout,
@@ -214,6 +217,26 @@ var AnalyticsFeature = /* @__PURE__ */ ((AnalyticsFeature2) => {
214
217
  AnalyticsFeature2["PageViews"] = "page-views";
215
218
  return AnalyticsFeature2;
216
219
  })(AnalyticsFeature || {});
220
+ function minorUnitDigits(currency) {
221
+ try {
222
+ return new Intl.NumberFormat("en", {
223
+ style: "currency",
224
+ currency: currency.toUpperCase()
225
+ }).resolvedOptions().maximumFractionDigits;
226
+ } catch {
227
+ return 2;
228
+ }
229
+ }
230
+ function toMinorUnits(major, currency) {
231
+ return {
232
+ amountMinor: Math.round(major * 10 ** minorUnitDigits(currency)),
233
+ currency
234
+ };
235
+ }
236
+ function toMajorUnits(money) {
237
+ const digits = minorUnitDigits(money.currency);
238
+ return Number((money.amountMinor / 10 ** digits).toFixed(digits));
239
+ }
217
240
 
218
241
  // src/invoicing.ts
219
242
  var InvoicingFeature = /* @__PURE__ */ ((InvoicingFeature2) => {
@@ -717,7 +740,7 @@ function checkPermissions(required, grantedRaw) {
717
740
  }
718
741
 
719
742
  // src/version.ts
720
- var SDK_VERSION = "0.6.8";
743
+ var SDK_VERSION = "0.6.9";
721
744
  function isSdkCompatible(pluginSdkVersion, hostSdkVersion) {
722
745
  const parse = (v) => {
723
746
  const m = /^(\d+)\.(\d+)\.(\d+)/.exec(v);
@@ -774,10 +797,13 @@ function isSdkCompatible(pluginSdkVersion, hostSdkVersion) {
774
797
  isPermissionGranted,
775
798
  isPluginFactory,
776
799
  isSdkCompatible,
800
+ minorUnitDigits,
777
801
  parsePermission,
778
802
  paymentCapability,
779
803
  shippingCapability,
780
804
  suppliersCapability,
805
+ toMajorUnits,
806
+ toMinorUnits,
781
807
  uiCapability,
782
808
  validatePluginAuthor,
783
809
  validateSetupLayout,
package/dist/index.mjs CHANGED
@@ -155,6 +155,26 @@ var AnalyticsFeature = /* @__PURE__ */ ((AnalyticsFeature2) => {
155
155
  AnalyticsFeature2["PageViews"] = "page-views";
156
156
  return AnalyticsFeature2;
157
157
  })(AnalyticsFeature || {});
158
+ function minorUnitDigits(currency) {
159
+ try {
160
+ return new Intl.NumberFormat("en", {
161
+ style: "currency",
162
+ currency: currency.toUpperCase()
163
+ }).resolvedOptions().maximumFractionDigits;
164
+ } catch {
165
+ return 2;
166
+ }
167
+ }
168
+ function toMinorUnits(major, currency) {
169
+ return {
170
+ amountMinor: Math.round(major * 10 ** minorUnitDigits(currency)),
171
+ currency
172
+ };
173
+ }
174
+ function toMajorUnits(money) {
175
+ const digits = minorUnitDigits(money.currency);
176
+ return Number((money.amountMinor / 10 ** digits).toFixed(digits));
177
+ }
158
178
 
159
179
  // src/invoicing.ts
160
180
  var InvoicingFeature = /* @__PURE__ */ ((InvoicingFeature2) => {
@@ -651,7 +671,7 @@ function isPluginFactory(value) {
651
671
  }
652
672
 
653
673
  // src/version.ts
654
- var SDK_VERSION = "0.6.8";
674
+ var SDK_VERSION = "0.6.9";
655
675
  function isSdkCompatible(pluginSdkVersion, hostSdkVersion) {
656
676
  const parse = (v) => {
657
677
  const m = /^(\d+)\.(\d+)\.(\d+)/.exec(v);
@@ -707,10 +727,13 @@ export {
707
727
  isPermissionGranted,
708
728
  isPluginFactory,
709
729
  isSdkCompatible,
730
+ minorUnitDigits,
710
731
  parsePermission,
711
732
  paymentCapability,
712
733
  shippingCapability,
713
734
  suppliersCapability,
735
+ toMajorUnits,
736
+ toMinorUnits,
714
737
  uiCapability,
715
738
  validatePluginAuthor,
716
739
  validateSetupLayout,
@@ -1,4 +1,4 @@
1
- import { _ as HostApi, a0 as HttpRequest, R as DomainEventName, u as Capability, Q as DomainEventHandler, a1 as HttpResponse, N as DispatchContext } from '../host-api-BbIT_sLc.mjs';
1
+ import { a3 as HostApi, a5 as HttpRequest, W as DomainEventName, v as Capability, V as DomainEventHandler, a6 as HttpResponse, T as DispatchContext } from '../host-api-Eeb42fR2.mjs';
2
2
 
3
3
  /** Every recorded interaction, keyed by `"port.method"`. */
4
4
  interface MockHostCalls {
@@ -1,4 +1,4 @@
1
- import { _ as HostApi, a0 as HttpRequest, R as DomainEventName, u as Capability, Q as DomainEventHandler, a1 as HttpResponse, N as DispatchContext } from '../host-api-BbIT_sLc.js';
1
+ import { a3 as HostApi, a5 as HttpRequest, W as DomainEventName, v as Capability, V as DomainEventHandler, a6 as HttpResponse, T as DispatchContext } from '../host-api-Eeb42fR2.js';
2
2
 
3
3
  /** Every recorded interaction, keyed by `"port.method"`. */
4
4
  interface MockHostCalls {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vivoa/plugin-sdk",
3
- "version": "0.6.8",
3
+ "version": "0.6.9",
4
4
  "description": "Public contracts for Vivoa plugins (types, DI tokens, config + setup-layout validators)",
5
5
  "license": "MIT",
6
6
  "author": "Vivoa",
@@ -39,14 +39,6 @@
39
39
  "registry": "https://registry.npmjs.org",
40
40
  "access": "public"
41
41
  },
42
- "scripts": {
43
- "build": "tsup src/index.ts src/testing/index.ts --format cjs,esm --dts --clean --target node18",
44
- "dev": "tsup src/index.ts src/testing/index.ts --format cjs,esm --dts --watch --target node18",
45
- "test": "vitest run",
46
- "test:watch": "vitest",
47
- "typecheck": "tsc --noEmit -p tsconfig.json",
48
- "prepublishOnly": "pnpm run typecheck && pnpm run test && pnpm run build"
49
- },
50
42
  "dependencies": {
51
43
  "superstruct": "^2.0.2"
52
44
  },
@@ -55,5 +47,12 @@
55
47
  "tsup": "^8.3.5",
56
48
  "typescript": "^5.7.3",
57
49
  "vitest": "^2.1.8"
50
+ },
51
+ "scripts": {
52
+ "build": "tsup src/index.ts src/testing/index.ts --format cjs,esm --dts --clean --target node18",
53
+ "dev": "tsup src/index.ts src/testing/index.ts --format cjs,esm --dts --watch --target node18",
54
+ "test": "vitest run",
55
+ "test:watch": "vitest",
56
+ "typecheck": "tsc --noEmit -p tsconfig.json"
58
57
  }
59
- }
58
+ }