@vivoa/plugin-sdk 0.6.8 → 0.6.11
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/{host-api-BbIT_sLc.d.mts → host-api-BnIwti1y.d.mts} +218 -4
- package/dist/{host-api-BbIT_sLc.d.ts → host-api-BnIwti1y.d.ts} +218 -4
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +28 -1
- package/dist/index.mjs +25 -1
- package/dist/testing/index.d.mts +1 -1
- package/dist/testing/index.d.ts +1 -1
- package/package.json +11 -11
|
@@ -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
|
|
@@ -758,7 +893,12 @@ declare enum SuppliersFeature {
|
|
|
758
893
|
* Poll the supplier for stock levels. SoyDrop has no inventory webhook, so
|
|
759
894
|
* stock is reconciled by polling rather than push.
|
|
760
895
|
*/
|
|
761
|
-
StockSync = "stock-sync"
|
|
896
|
+
StockSync = "stock-sync",
|
|
897
|
+
/**
|
|
898
|
+
* Quote the supplier's own delivery for a cart. The supplier ships, so it —
|
|
899
|
+
* not the store's carriers — prices the trip the shopper pays at checkout.
|
|
900
|
+
*/
|
|
901
|
+
ShippingQuotes = "shipping-quotes"
|
|
762
902
|
}
|
|
763
903
|
/**
|
|
764
904
|
* ISO-4217 money in minor units — mirrors the store's Money VO
|
|
@@ -792,9 +932,16 @@ interface SuppliersStaticConfig {
|
|
|
792
932
|
}
|
|
793
933
|
interface SupplierCatalogQuery {
|
|
794
934
|
text?: string;
|
|
935
|
+
/** ISO-3166-1 alpha-2. A driver that cannot serve it returns an empty page. */
|
|
795
936
|
country?: string;
|
|
796
937
|
cursor?: string;
|
|
797
938
|
limit?: number;
|
|
939
|
+
/** Wholesale price floor, minor units (inclusive). */
|
|
940
|
+
minPriceMinor?: number;
|
|
941
|
+
/** Wholesale price ceiling, minor units (inclusive). */
|
|
942
|
+
maxPriceMinor?: number;
|
|
943
|
+
/** Only listings the supplier reports as in stock. */
|
|
944
|
+
inStockOnly?: boolean;
|
|
798
945
|
}
|
|
799
946
|
interface SupplierListingVariant {
|
|
800
947
|
externalVariantId: string;
|
|
@@ -833,12 +980,16 @@ interface SupplierListing {
|
|
|
833
980
|
hasVariants: boolean;
|
|
834
981
|
variants?: SupplierListingVariant[];
|
|
835
982
|
moq?: number | null;
|
|
983
|
+
/** Display name of the vendor behind the listing (a marketplace may host many). */
|
|
984
|
+
vendorName?: string | null;
|
|
836
985
|
/** Untouched supplier payload, for diagnostics. Never trusted for control flow. */
|
|
837
986
|
raw?: unknown;
|
|
838
987
|
}
|
|
839
988
|
interface SupplierListingPage {
|
|
840
989
|
items: SupplierListing[];
|
|
841
990
|
nextCursor?: string | null;
|
|
991
|
+
/** Total listings matching the query across all pages, when the supplier reports it. */
|
|
992
|
+
total?: number | null;
|
|
842
993
|
}
|
|
843
994
|
interface SupplierOrderCustomer {
|
|
844
995
|
name: string;
|
|
@@ -879,6 +1030,10 @@ interface SupplierOrderLine {
|
|
|
879
1030
|
quantity: number;
|
|
880
1031
|
/** Optional price override; omit to use the supplier's catalog price. */
|
|
881
1032
|
unitPrice?: SupplierMoney | null;
|
|
1033
|
+
/** SKU of the variant the shopper chose; the plugin maps it to the supplier's. */
|
|
1034
|
+
variantSku?: string | null;
|
|
1035
|
+
/** Variant name, for products imported without a SKU. */
|
|
1036
|
+
variantName?: string | null;
|
|
882
1037
|
}
|
|
883
1038
|
interface PlaceSupplierOrderInput {
|
|
884
1039
|
/** Host order id — the idempotency key the supplier dedupes on. */
|
|
@@ -893,6 +1048,34 @@ interface PlaceSupplierOrderInput {
|
|
|
893
1048
|
courierId?: string | null;
|
|
894
1049
|
note?: string | null;
|
|
895
1050
|
}
|
|
1051
|
+
/** What the host asks the supplier to price: these lines, to this address. */
|
|
1052
|
+
interface SupplierShippingQuoteInput {
|
|
1053
|
+
lines: Array<Pick<SupplierOrderLine, 'externalListingId' | 'quantity'>>;
|
|
1054
|
+
/** Same shape (and same name → id resolution) as {@link PlaceSupplierOrderInput.shipTo}. */
|
|
1055
|
+
shipTo: SupplierShipTo;
|
|
1056
|
+
/** The shopper pays on delivery: only couriers that collect make sense. */
|
|
1057
|
+
cod: boolean;
|
|
1058
|
+
}
|
|
1059
|
+
/**
|
|
1060
|
+
* One courier the supplier would ship the order with. Amounts are plain
|
|
1061
|
+
* numbers in the currency of the supplier account that ships to the
|
|
1062
|
+
* destination country (one account = one country).
|
|
1063
|
+
*/
|
|
1064
|
+
interface SupplierShippingQuote {
|
|
1065
|
+
/** Goes back as {@link PlaceSupplierOrderInput.courierId} when the shopper picks it. */
|
|
1066
|
+
courierId: string;
|
|
1067
|
+
courierName: string;
|
|
1068
|
+
logo: string | null;
|
|
1069
|
+
/** Supplier service level (e.g. Drop `SAME_DAY` / `NEXT_DAY`). */
|
|
1070
|
+
serviceLevel: string | null;
|
|
1071
|
+
/** What the supplier charges the merchant to ship this order. */
|
|
1072
|
+
price: number;
|
|
1073
|
+
/** COD commission over the whole collected amount, as a percentage (4 = 4%). */
|
|
1074
|
+
codCommissionPercent: number;
|
|
1075
|
+
/** Per-order floor of that commission, when the supplier has one. */
|
|
1076
|
+
codMinimumCommission?: number;
|
|
1077
|
+
supportsCod: boolean;
|
|
1078
|
+
}
|
|
896
1079
|
/**
|
|
897
1080
|
* Normalized supplier-order status. `unknown` is a first-class value for
|
|
898
1081
|
* supplier states the adapter does not map — the host treats it as a no-op.
|
|
@@ -939,6 +1122,7 @@ interface ISuppliersPlugin extends IPlugin {
|
|
|
939
1122
|
getOrderStatus(externalOrderId: string, ctx: DispatchContext): Promise<SupplierOrderResult>;
|
|
940
1123
|
cancelOrder?(externalOrderId: string, ctx: DispatchContext): Promise<SupplierOrderResult>;
|
|
941
1124
|
syncStock?(externalIds: string[], ctx: DispatchContext): Promise<SupplierStock[]>;
|
|
1125
|
+
quoteShipping?(input: SupplierShippingQuoteInput, ctx: DispatchContext): Promise<SupplierShippingQuote[]>;
|
|
942
1126
|
parseWebhook?(body: unknown, headers: Record<string, string>, ctx: DispatchContext): SupplierFulfillmentEvent | null;
|
|
943
1127
|
isConfigured?(ctx: DispatchContext): boolean;
|
|
944
1128
|
}
|
|
@@ -952,11 +1136,19 @@ declare enum AnalyticsFeature {
|
|
|
952
1136
|
/**
|
|
953
1137
|
* ISO-4217 money in minor units — mirrors the store's Money VO so the host maps
|
|
954
1138
|
* 1:1 without a currency guess. Kept local so the SDK stays dependency-free.
|
|
1139
|
+
* The exponent is the currency's own (USD 2, CLP/JPY 0, KWD 3): encode with
|
|
1140
|
+
* {@link toMinorUnits}, decode with {@link toMajorUnits}, never a fixed ×100.
|
|
955
1141
|
*/
|
|
956
1142
|
interface AnalyticsMoney {
|
|
957
1143
|
amountMinor: number;
|
|
958
1144
|
currency: string;
|
|
959
1145
|
}
|
|
1146
|
+
/** ISO-4217 minor-unit exponent (USD 2, JPY 0, KWD 3); unknown → 2. */
|
|
1147
|
+
declare function minorUnitDigits(currency: string): number;
|
|
1148
|
+
/** A major-unit amount (e.g. `25.5` USD) as {@link AnalyticsMoney}. */
|
|
1149
|
+
declare function toMinorUnits(major: number, currency: string): AnalyticsMoney;
|
|
1150
|
+
/** The major-unit decimal of {@link AnalyticsMoney} (e.g. `2550` USD → `25.5`). */
|
|
1151
|
+
declare function toMajorUnits(money: AnalyticsMoney): number;
|
|
960
1152
|
/** A single line item attached to an ecommerce event. */
|
|
961
1153
|
interface AnalyticsItem {
|
|
962
1154
|
/** Product id as the store knows it (Meta `content_ids`, GA4 `item_id`). */
|
|
@@ -976,7 +1168,25 @@ interface AnalyticsItem {
|
|
|
976
1168
|
* only ever maps a domain event to one of these. An adapter that does not care
|
|
977
1169
|
* about a given name simply ignores it.
|
|
978
1170
|
*/
|
|
979
|
-
type AnalyticsEventName = 'page_view' | 'view_item' | 'add_to_cart' | 'remove_from_cart' | 'begin_checkout' | 'purchase';
|
|
1171
|
+
type AnalyticsEventName = 'page_view' | 'view_item' | 'add_to_cart' | 'remove_from_cart' | 'begin_checkout' | 'purchase' | 'order_placed';
|
|
1172
|
+
/**
|
|
1173
|
+
* When a cash-on-delivery order counts as a `purchase` for an adapter:
|
|
1174
|
+
* - `collected` — when the cash is collected (carrier delivery or staff
|
|
1175
|
+
* marking it paid). Highest signal quality; the default.
|
|
1176
|
+
* - `confirmed` — when staff confirms the order (e.g. after a confirmation
|
|
1177
|
+
* call). Faster learning and inside the ad platform's dedup/attribution
|
|
1178
|
+
* windows, at the cost of counting confirmed orders the shopper refuses.
|
|
1179
|
+
* Prepaid orders always convert when the gateway approves the payment.
|
|
1180
|
+
*/
|
|
1181
|
+
type CodPurchaseTrigger = 'collected' | 'confirmed';
|
|
1182
|
+
/**
|
|
1183
|
+
* Per-store settlement policy the HOST reads from an analytics adapter's own
|
|
1184
|
+
* config (`DispatchContext.config`). An adapter opts in by declaring a config
|
|
1185
|
+
* field with this exact key; one that declares none gets the defaults.
|
|
1186
|
+
*/
|
|
1187
|
+
interface AnalyticsPurchasePolicy {
|
|
1188
|
+
codPurchaseTrigger?: CodPurchaseTrigger;
|
|
1189
|
+
}
|
|
980
1190
|
/**
|
|
981
1191
|
* Where the action physically happened. Maps to Meta `action_source`; other
|
|
982
1192
|
* providers ignore it. Defaults to `website` when the host omits it.
|
|
@@ -1004,7 +1214,11 @@ interface AnalyticsUserData {
|
|
|
1004
1214
|
genderSha256?: string | null;
|
|
1005
1215
|
/** Date of birth, YYYYMMDD normalized then SHA256. */
|
|
1006
1216
|
dobSha256?: string | null;
|
|
1007
|
-
/**
|
|
1217
|
+
/**
|
|
1218
|
+
* Pseudonymous shopper id (user, else guest) — Meta `external_id`. Arrives
|
|
1219
|
+
* PLAIN: it is not PII. An adapter whose provider wants it hashed (Meta, to
|
|
1220
|
+
* meet the browser pixel) hashes it itself.
|
|
1221
|
+
*/
|
|
1008
1222
|
externalId?: string | null;
|
|
1009
1223
|
/** Plain IPv4/IPv6 — never hashed (geo match). */
|
|
1010
1224
|
clientIpAddress?: string | null;
|
|
@@ -1566,4 +1780,4 @@ interface HostApi {
|
|
|
1566
1780
|
registerCapability<T = unknown>(cap: Capability<T>): void;
|
|
1567
1781
|
}
|
|
1568
1782
|
|
|
1569
|
-
export {
|
|
1783
|
+
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 TabItem as bA, type TabsBlock as bB, type ToggleBlock as bC, type TrackingEvent as bD, TransactionStatus as bE, type UiContribution as bF, type UiContributionsValidation as bG, type VoidInvoiceInput as bH, type WebhookSignatureResult as bI, analyticsCapability as bJ, capability as bK, crossValidateSetupLayout as bL, definePlugin as bM, invoicingCapability as bN, isConfigurablePlugin as bO, isPluginFactory as bP, minorUnitDigits as bQ, paymentCapability as bR, shippingCapability as bS, suppliersCapability as bT, toMajorUnits as bU, toMinorUnits as bV, uiCapability as bW, validatePluginAuthor as bX, validateSetupLayout as bY, validateUiContributions as bZ, 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 SupplierShippingQuote as bt, type SupplierShippingQuoteInput as bu, type SupplierStock as bv, type SuppliersDefaultConfig as bw, SuppliersFeature as bx, type SuppliersPluginConfig as by, type SuppliersStaticConfig 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
|
|
@@ -758,7 +893,12 @@ declare enum SuppliersFeature {
|
|
|
758
893
|
* Poll the supplier for stock levels. SoyDrop has no inventory webhook, so
|
|
759
894
|
* stock is reconciled by polling rather than push.
|
|
760
895
|
*/
|
|
761
|
-
StockSync = "stock-sync"
|
|
896
|
+
StockSync = "stock-sync",
|
|
897
|
+
/**
|
|
898
|
+
* Quote the supplier's own delivery for a cart. The supplier ships, so it —
|
|
899
|
+
* not the store's carriers — prices the trip the shopper pays at checkout.
|
|
900
|
+
*/
|
|
901
|
+
ShippingQuotes = "shipping-quotes"
|
|
762
902
|
}
|
|
763
903
|
/**
|
|
764
904
|
* ISO-4217 money in minor units — mirrors the store's Money VO
|
|
@@ -792,9 +932,16 @@ interface SuppliersStaticConfig {
|
|
|
792
932
|
}
|
|
793
933
|
interface SupplierCatalogQuery {
|
|
794
934
|
text?: string;
|
|
935
|
+
/** ISO-3166-1 alpha-2. A driver that cannot serve it returns an empty page. */
|
|
795
936
|
country?: string;
|
|
796
937
|
cursor?: string;
|
|
797
938
|
limit?: number;
|
|
939
|
+
/** Wholesale price floor, minor units (inclusive). */
|
|
940
|
+
minPriceMinor?: number;
|
|
941
|
+
/** Wholesale price ceiling, minor units (inclusive). */
|
|
942
|
+
maxPriceMinor?: number;
|
|
943
|
+
/** Only listings the supplier reports as in stock. */
|
|
944
|
+
inStockOnly?: boolean;
|
|
798
945
|
}
|
|
799
946
|
interface SupplierListingVariant {
|
|
800
947
|
externalVariantId: string;
|
|
@@ -833,12 +980,16 @@ interface SupplierListing {
|
|
|
833
980
|
hasVariants: boolean;
|
|
834
981
|
variants?: SupplierListingVariant[];
|
|
835
982
|
moq?: number | null;
|
|
983
|
+
/** Display name of the vendor behind the listing (a marketplace may host many). */
|
|
984
|
+
vendorName?: string | null;
|
|
836
985
|
/** Untouched supplier payload, for diagnostics. Never trusted for control flow. */
|
|
837
986
|
raw?: unknown;
|
|
838
987
|
}
|
|
839
988
|
interface SupplierListingPage {
|
|
840
989
|
items: SupplierListing[];
|
|
841
990
|
nextCursor?: string | null;
|
|
991
|
+
/** Total listings matching the query across all pages, when the supplier reports it. */
|
|
992
|
+
total?: number | null;
|
|
842
993
|
}
|
|
843
994
|
interface SupplierOrderCustomer {
|
|
844
995
|
name: string;
|
|
@@ -879,6 +1030,10 @@ interface SupplierOrderLine {
|
|
|
879
1030
|
quantity: number;
|
|
880
1031
|
/** Optional price override; omit to use the supplier's catalog price. */
|
|
881
1032
|
unitPrice?: SupplierMoney | null;
|
|
1033
|
+
/** SKU of the variant the shopper chose; the plugin maps it to the supplier's. */
|
|
1034
|
+
variantSku?: string | null;
|
|
1035
|
+
/** Variant name, for products imported without a SKU. */
|
|
1036
|
+
variantName?: string | null;
|
|
882
1037
|
}
|
|
883
1038
|
interface PlaceSupplierOrderInput {
|
|
884
1039
|
/** Host order id — the idempotency key the supplier dedupes on. */
|
|
@@ -893,6 +1048,34 @@ interface PlaceSupplierOrderInput {
|
|
|
893
1048
|
courierId?: string | null;
|
|
894
1049
|
note?: string | null;
|
|
895
1050
|
}
|
|
1051
|
+
/** What the host asks the supplier to price: these lines, to this address. */
|
|
1052
|
+
interface SupplierShippingQuoteInput {
|
|
1053
|
+
lines: Array<Pick<SupplierOrderLine, 'externalListingId' | 'quantity'>>;
|
|
1054
|
+
/** Same shape (and same name → id resolution) as {@link PlaceSupplierOrderInput.shipTo}. */
|
|
1055
|
+
shipTo: SupplierShipTo;
|
|
1056
|
+
/** The shopper pays on delivery: only couriers that collect make sense. */
|
|
1057
|
+
cod: boolean;
|
|
1058
|
+
}
|
|
1059
|
+
/**
|
|
1060
|
+
* One courier the supplier would ship the order with. Amounts are plain
|
|
1061
|
+
* numbers in the currency of the supplier account that ships to the
|
|
1062
|
+
* destination country (one account = one country).
|
|
1063
|
+
*/
|
|
1064
|
+
interface SupplierShippingQuote {
|
|
1065
|
+
/** Goes back as {@link PlaceSupplierOrderInput.courierId} when the shopper picks it. */
|
|
1066
|
+
courierId: string;
|
|
1067
|
+
courierName: string;
|
|
1068
|
+
logo: string | null;
|
|
1069
|
+
/** Supplier service level (e.g. Drop `SAME_DAY` / `NEXT_DAY`). */
|
|
1070
|
+
serviceLevel: string | null;
|
|
1071
|
+
/** What the supplier charges the merchant to ship this order. */
|
|
1072
|
+
price: number;
|
|
1073
|
+
/** COD commission over the whole collected amount, as a percentage (4 = 4%). */
|
|
1074
|
+
codCommissionPercent: number;
|
|
1075
|
+
/** Per-order floor of that commission, when the supplier has one. */
|
|
1076
|
+
codMinimumCommission?: number;
|
|
1077
|
+
supportsCod: boolean;
|
|
1078
|
+
}
|
|
896
1079
|
/**
|
|
897
1080
|
* Normalized supplier-order status. `unknown` is a first-class value for
|
|
898
1081
|
* supplier states the adapter does not map — the host treats it as a no-op.
|
|
@@ -939,6 +1122,7 @@ interface ISuppliersPlugin extends IPlugin {
|
|
|
939
1122
|
getOrderStatus(externalOrderId: string, ctx: DispatchContext): Promise<SupplierOrderResult>;
|
|
940
1123
|
cancelOrder?(externalOrderId: string, ctx: DispatchContext): Promise<SupplierOrderResult>;
|
|
941
1124
|
syncStock?(externalIds: string[], ctx: DispatchContext): Promise<SupplierStock[]>;
|
|
1125
|
+
quoteShipping?(input: SupplierShippingQuoteInput, ctx: DispatchContext): Promise<SupplierShippingQuote[]>;
|
|
942
1126
|
parseWebhook?(body: unknown, headers: Record<string, string>, ctx: DispatchContext): SupplierFulfillmentEvent | null;
|
|
943
1127
|
isConfigured?(ctx: DispatchContext): boolean;
|
|
944
1128
|
}
|
|
@@ -952,11 +1136,19 @@ declare enum AnalyticsFeature {
|
|
|
952
1136
|
/**
|
|
953
1137
|
* ISO-4217 money in minor units — mirrors the store's Money VO so the host maps
|
|
954
1138
|
* 1:1 without a currency guess. Kept local so the SDK stays dependency-free.
|
|
1139
|
+
* The exponent is the currency's own (USD 2, CLP/JPY 0, KWD 3): encode with
|
|
1140
|
+
* {@link toMinorUnits}, decode with {@link toMajorUnits}, never a fixed ×100.
|
|
955
1141
|
*/
|
|
956
1142
|
interface AnalyticsMoney {
|
|
957
1143
|
amountMinor: number;
|
|
958
1144
|
currency: string;
|
|
959
1145
|
}
|
|
1146
|
+
/** ISO-4217 minor-unit exponent (USD 2, JPY 0, KWD 3); unknown → 2. */
|
|
1147
|
+
declare function minorUnitDigits(currency: string): number;
|
|
1148
|
+
/** A major-unit amount (e.g. `25.5` USD) as {@link AnalyticsMoney}. */
|
|
1149
|
+
declare function toMinorUnits(major: number, currency: string): AnalyticsMoney;
|
|
1150
|
+
/** The major-unit decimal of {@link AnalyticsMoney} (e.g. `2550` USD → `25.5`). */
|
|
1151
|
+
declare function toMajorUnits(money: AnalyticsMoney): number;
|
|
960
1152
|
/** A single line item attached to an ecommerce event. */
|
|
961
1153
|
interface AnalyticsItem {
|
|
962
1154
|
/** Product id as the store knows it (Meta `content_ids`, GA4 `item_id`). */
|
|
@@ -976,7 +1168,25 @@ interface AnalyticsItem {
|
|
|
976
1168
|
* only ever maps a domain event to one of these. An adapter that does not care
|
|
977
1169
|
* about a given name simply ignores it.
|
|
978
1170
|
*/
|
|
979
|
-
type AnalyticsEventName = 'page_view' | 'view_item' | 'add_to_cart' | 'remove_from_cart' | 'begin_checkout' | 'purchase';
|
|
1171
|
+
type AnalyticsEventName = 'page_view' | 'view_item' | 'add_to_cart' | 'remove_from_cart' | 'begin_checkout' | 'purchase' | 'order_placed';
|
|
1172
|
+
/**
|
|
1173
|
+
* When a cash-on-delivery order counts as a `purchase` for an adapter:
|
|
1174
|
+
* - `collected` — when the cash is collected (carrier delivery or staff
|
|
1175
|
+
* marking it paid). Highest signal quality; the default.
|
|
1176
|
+
* - `confirmed` — when staff confirms the order (e.g. after a confirmation
|
|
1177
|
+
* call). Faster learning and inside the ad platform's dedup/attribution
|
|
1178
|
+
* windows, at the cost of counting confirmed orders the shopper refuses.
|
|
1179
|
+
* Prepaid orders always convert when the gateway approves the payment.
|
|
1180
|
+
*/
|
|
1181
|
+
type CodPurchaseTrigger = 'collected' | 'confirmed';
|
|
1182
|
+
/**
|
|
1183
|
+
* Per-store settlement policy the HOST reads from an analytics adapter's own
|
|
1184
|
+
* config (`DispatchContext.config`). An adapter opts in by declaring a config
|
|
1185
|
+
* field with this exact key; one that declares none gets the defaults.
|
|
1186
|
+
*/
|
|
1187
|
+
interface AnalyticsPurchasePolicy {
|
|
1188
|
+
codPurchaseTrigger?: CodPurchaseTrigger;
|
|
1189
|
+
}
|
|
980
1190
|
/**
|
|
981
1191
|
* Where the action physically happened. Maps to Meta `action_source`; other
|
|
982
1192
|
* providers ignore it. Defaults to `website` when the host omits it.
|
|
@@ -1004,7 +1214,11 @@ interface AnalyticsUserData {
|
|
|
1004
1214
|
genderSha256?: string | null;
|
|
1005
1215
|
/** Date of birth, YYYYMMDD normalized then SHA256. */
|
|
1006
1216
|
dobSha256?: string | null;
|
|
1007
|
-
/**
|
|
1217
|
+
/**
|
|
1218
|
+
* Pseudonymous shopper id (user, else guest) — Meta `external_id`. Arrives
|
|
1219
|
+
* PLAIN: it is not PII. An adapter whose provider wants it hashed (Meta, to
|
|
1220
|
+
* meet the browser pixel) hashes it itself.
|
|
1221
|
+
*/
|
|
1008
1222
|
externalId?: string | null;
|
|
1009
1223
|
/** Plain IPv4/IPv6 — never hashed (geo match). */
|
|
1010
1224
|
clientIpAddress?: string | null;
|
|
@@ -1566,4 +1780,4 @@ interface HostApi {
|
|
|
1566
1780
|
registerCapability<T = unknown>(cap: Capability<T>): void;
|
|
1567
1781
|
}
|
|
1568
1782
|
|
|
1569
|
-
export {
|
|
1783
|
+
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 TabItem as bA, type TabsBlock as bB, type ToggleBlock as bC, type TrackingEvent as bD, TransactionStatus as bE, type UiContribution as bF, type UiContributionsValidation as bG, type VoidInvoiceInput as bH, type WebhookSignatureResult as bI, analyticsCapability as bJ, capability as bK, crossValidateSetupLayout as bL, definePlugin as bM, invoicingCapability as bN, isConfigurablePlugin as bO, isPluginFactory as bP, minorUnitDigits as bQ, paymentCapability as bR, shippingCapability as bS, suppliersCapability as bT, toMajorUnits as bU, toMinorUnits as bV, uiCapability as bW, validatePluginAuthor as bX, validateSetupLayout as bY, validateUiContributions as bZ, 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 SupplierShippingQuote as bt, type SupplierShippingQuoteInput as bu, type SupplierStock as bv, type SuppliersDefaultConfig as bw, SuppliersFeature as bx, type SuppliersPluginConfig as by, type SuppliersStaticConfig 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-
|
|
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
|
|
1
|
+
import { F as FieldType, C as ConfigScope, S as SelectOption, P as PluginConfigField } from './host-api-BnIwti1y.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 SupplierShippingQuote, bu as SupplierShippingQuoteInput, bv as SupplierStock, bw as SuppliersDefaultConfig, bx as SuppliersFeature, by as SuppliersPluginConfig, bz as SuppliersStaticConfig, bA as TabItem, bB as TabsBlock, bC as ToggleBlock, bD as TrackingEvent, bE as TransactionStatus, bF as UiContribution, bG as UiContributionsValidation, bH as VoidInvoiceInput, bI as WebhookSignatureResult, bJ as analyticsCapability, bK as capability, bL as crossValidateSetupLayout, bM as definePlugin, bN as invoicingCapability, bO as isConfigurablePlugin, bP as isPluginFactory, bQ as minorUnitDigits, bR as paymentCapability, bS as shippingCapability, bT as suppliersCapability, bU as toMajorUnits, bV as toMinorUnits, bW as uiCapability, bX as validatePluginAuthor, bY as validateSetupLayout, bZ as validateUiContributions } from './host-api-BnIwti1y.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.
|
|
77
|
+
declare const SDK_VERSION = "0.6.11";
|
|
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-
|
|
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
|
|
1
|
+
import { F as FieldType, C as ConfigScope, S as SelectOption, P as PluginConfigField } from './host-api-BnIwti1y.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 SupplierShippingQuote, bu as SupplierShippingQuoteInput, bv as SupplierStock, bw as SuppliersDefaultConfig, bx as SuppliersFeature, by as SuppliersPluginConfig, bz as SuppliersStaticConfig, bA as TabItem, bB as TabsBlock, bC as ToggleBlock, bD as TrackingEvent, bE as TransactionStatus, bF as UiContribution, bG as UiContributionsValidation, bH as VoidInvoiceInput, bI as WebhookSignatureResult, bJ as analyticsCapability, bK as capability, bL as crossValidateSetupLayout, bM as definePlugin, bN as invoicingCapability, bO as isConfigurablePlugin, bP as isPluginFactory, bQ as minorUnitDigits, bR as paymentCapability, bS as shippingCapability, bT as suppliersCapability, bU as toMajorUnits, bV as toMinorUnits, bW as uiCapability, bX as validatePluginAuthor, bY as validateSetupLayout, bZ as validateUiContributions } from './host-api-BnIwti1y.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.
|
|
77
|
+
declare const SDK_VERSION = "0.6.11";
|
|
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,
|
|
@@ -205,6 +208,7 @@ var SuppliersFeature = /* @__PURE__ */ ((SuppliersFeature2) => {
|
|
|
205
208
|
SuppliersFeature2["Orders"] = "orders";
|
|
206
209
|
SuppliersFeature2["FulfillmentSync"] = "fulfillment-sync";
|
|
207
210
|
SuppliersFeature2["StockSync"] = "stock-sync";
|
|
211
|
+
SuppliersFeature2["ShippingQuotes"] = "shipping-quotes";
|
|
208
212
|
return SuppliersFeature2;
|
|
209
213
|
})(SuppliersFeature || {});
|
|
210
214
|
|
|
@@ -214,6 +218,26 @@ var AnalyticsFeature = /* @__PURE__ */ ((AnalyticsFeature2) => {
|
|
|
214
218
|
AnalyticsFeature2["PageViews"] = "page-views";
|
|
215
219
|
return AnalyticsFeature2;
|
|
216
220
|
})(AnalyticsFeature || {});
|
|
221
|
+
function minorUnitDigits(currency) {
|
|
222
|
+
try {
|
|
223
|
+
return new Intl.NumberFormat("en", {
|
|
224
|
+
style: "currency",
|
|
225
|
+
currency: currency.toUpperCase()
|
|
226
|
+
}).resolvedOptions().maximumFractionDigits;
|
|
227
|
+
} catch {
|
|
228
|
+
return 2;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
function toMinorUnits(major, currency) {
|
|
232
|
+
return {
|
|
233
|
+
amountMinor: Math.round(major * 10 ** minorUnitDigits(currency)),
|
|
234
|
+
currency
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
function toMajorUnits(money) {
|
|
238
|
+
const digits = minorUnitDigits(money.currency);
|
|
239
|
+
return Number((money.amountMinor / 10 ** digits).toFixed(digits));
|
|
240
|
+
}
|
|
217
241
|
|
|
218
242
|
// src/invoicing.ts
|
|
219
243
|
var InvoicingFeature = /* @__PURE__ */ ((InvoicingFeature2) => {
|
|
@@ -717,7 +741,7 @@ function checkPermissions(required, grantedRaw) {
|
|
|
717
741
|
}
|
|
718
742
|
|
|
719
743
|
// src/version.ts
|
|
720
|
-
var SDK_VERSION = "0.6.
|
|
744
|
+
var SDK_VERSION = "0.6.11";
|
|
721
745
|
function isSdkCompatible(pluginSdkVersion, hostSdkVersion) {
|
|
722
746
|
const parse = (v) => {
|
|
723
747
|
const m = /^(\d+)\.(\d+)\.(\d+)/.exec(v);
|
|
@@ -774,10 +798,13 @@ function isSdkCompatible(pluginSdkVersion, hostSdkVersion) {
|
|
|
774
798
|
isPermissionGranted,
|
|
775
799
|
isPluginFactory,
|
|
776
800
|
isSdkCompatible,
|
|
801
|
+
minorUnitDigits,
|
|
777
802
|
parsePermission,
|
|
778
803
|
paymentCapability,
|
|
779
804
|
shippingCapability,
|
|
780
805
|
suppliersCapability,
|
|
806
|
+
toMajorUnits,
|
|
807
|
+
toMinorUnits,
|
|
781
808
|
uiCapability,
|
|
782
809
|
validatePluginAuthor,
|
|
783
810
|
validateSetupLayout,
|
package/dist/index.mjs
CHANGED
|
@@ -146,6 +146,7 @@ var SuppliersFeature = /* @__PURE__ */ ((SuppliersFeature2) => {
|
|
|
146
146
|
SuppliersFeature2["Orders"] = "orders";
|
|
147
147
|
SuppliersFeature2["FulfillmentSync"] = "fulfillment-sync";
|
|
148
148
|
SuppliersFeature2["StockSync"] = "stock-sync";
|
|
149
|
+
SuppliersFeature2["ShippingQuotes"] = "shipping-quotes";
|
|
149
150
|
return SuppliersFeature2;
|
|
150
151
|
})(SuppliersFeature || {});
|
|
151
152
|
|
|
@@ -155,6 +156,26 @@ var AnalyticsFeature = /* @__PURE__ */ ((AnalyticsFeature2) => {
|
|
|
155
156
|
AnalyticsFeature2["PageViews"] = "page-views";
|
|
156
157
|
return AnalyticsFeature2;
|
|
157
158
|
})(AnalyticsFeature || {});
|
|
159
|
+
function minorUnitDigits(currency) {
|
|
160
|
+
try {
|
|
161
|
+
return new Intl.NumberFormat("en", {
|
|
162
|
+
style: "currency",
|
|
163
|
+
currency: currency.toUpperCase()
|
|
164
|
+
}).resolvedOptions().maximumFractionDigits;
|
|
165
|
+
} catch {
|
|
166
|
+
return 2;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
function toMinorUnits(major, currency) {
|
|
170
|
+
return {
|
|
171
|
+
amountMinor: Math.round(major * 10 ** minorUnitDigits(currency)),
|
|
172
|
+
currency
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
function toMajorUnits(money) {
|
|
176
|
+
const digits = minorUnitDigits(money.currency);
|
|
177
|
+
return Number((money.amountMinor / 10 ** digits).toFixed(digits));
|
|
178
|
+
}
|
|
158
179
|
|
|
159
180
|
// src/invoicing.ts
|
|
160
181
|
var InvoicingFeature = /* @__PURE__ */ ((InvoicingFeature2) => {
|
|
@@ -651,7 +672,7 @@ function isPluginFactory(value) {
|
|
|
651
672
|
}
|
|
652
673
|
|
|
653
674
|
// src/version.ts
|
|
654
|
-
var SDK_VERSION = "0.6.
|
|
675
|
+
var SDK_VERSION = "0.6.11";
|
|
655
676
|
function isSdkCompatible(pluginSdkVersion, hostSdkVersion) {
|
|
656
677
|
const parse = (v) => {
|
|
657
678
|
const m = /^(\d+)\.(\d+)\.(\d+)/.exec(v);
|
|
@@ -707,10 +728,13 @@ export {
|
|
|
707
728
|
isPermissionGranted,
|
|
708
729
|
isPluginFactory,
|
|
709
730
|
isSdkCompatible,
|
|
731
|
+
minorUnitDigits,
|
|
710
732
|
parsePermission,
|
|
711
733
|
paymentCapability,
|
|
712
734
|
shippingCapability,
|
|
713
735
|
suppliersCapability,
|
|
736
|
+
toMajorUnits,
|
|
737
|
+
toMinorUnits,
|
|
714
738
|
uiCapability,
|
|
715
739
|
validatePluginAuthor,
|
|
716
740
|
validateSetupLayout,
|
package/dist/testing/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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-BnIwti1y.mjs';
|
|
2
2
|
|
|
3
3
|
/** Every recorded interaction, keyed by `"port.method"`. */
|
|
4
4
|
interface MockHostCalls {
|
package/dist/testing/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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-BnIwti1y.js';
|
|
2
2
|
|
|
3
3
|
/** Every recorded interaction, keyed by `"port.method"`. */
|
|
4
4
|
interface MockHostCalls {
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vivoa/plugin-sdk",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.11",
|
|
4
4
|
"description": "Public contracts for Vivoa plugins (types, DI tokens, config + setup-layout validators)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Vivoa",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "https://github.com/VivoaPlatform/vivoa-
|
|
9
|
+
"url": "https://github.com/VivoaPlatform/vivoa-stores.git",
|
|
10
|
+
"directory": "packages/plugin-sdk"
|
|
10
11
|
},
|
|
11
12
|
"keywords": [
|
|
12
13
|
"vivoa",
|
|
@@ -39,14 +40,6 @@
|
|
|
39
40
|
"registry": "https://registry.npmjs.org",
|
|
40
41
|
"access": "public"
|
|
41
42
|
},
|
|
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
43
|
"dependencies": {
|
|
51
44
|
"superstruct": "^2.0.2"
|
|
52
45
|
},
|
|
@@ -55,5 +48,12 @@
|
|
|
55
48
|
"tsup": "^8.3.5",
|
|
56
49
|
"typescript": "^5.7.3",
|
|
57
50
|
"vitest": "^2.1.8"
|
|
51
|
+
},
|
|
52
|
+
"scripts": {
|
|
53
|
+
"build": "tsup src/index.ts src/testing/index.ts --format cjs,esm --dts --clean --target node18",
|
|
54
|
+
"dev": "tsup src/index.ts src/testing/index.ts --format cjs,esm --dts --watch --target node18",
|
|
55
|
+
"test": "vitest run",
|
|
56
|
+
"test:watch": "vitest",
|
|
57
|
+
"typecheck": "tsc --noEmit -p tsconfig.json"
|
|
58
58
|
}
|
|
59
|
-
}
|
|
59
|
+
}
|