@vivoa/plugin-sdk 0.5.1 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,5 +1,6 @@
1
1
  declare const PAYMENT_PLUGIN_TOKEN: "PAYMENT_PLUGINS";
2
2
  declare const SHIPPING_PLUGIN_TOKEN: "SHIPPING_PLUGINS";
3
+ declare const SUPPLIERS_PLUGIN_TOKEN: "SUPPLIERS_PLUGINS";
3
4
 
4
5
  declare enum FieldType {
5
6
  String = "string",
@@ -646,6 +647,202 @@ interface IShippingPlugin extends IPlugin {
646
647
  isConfigured?(ctx: DispatchContext): boolean;
647
648
  }
648
649
 
650
+ declare enum SuppliersFeature {
651
+ /** Browse/search the supplier catalog. */
652
+ CatalogSearch = "catalog-search",
653
+ /** Pull a full listing snapshot to seed a native product. */
654
+ CatalogImport = "catalog-import",
655
+ /** Place + track orders against the supplier. */
656
+ Orders = "orders",
657
+ /** Supplier pushes order status to a registered webhook. */
658
+ FulfillmentSync = "fulfillment-sync",
659
+ /**
660
+ * Poll the supplier for stock levels. SoyDrop has no inventory webhook, so
661
+ * stock is reconciled by polling rather than push.
662
+ */
663
+ StockSync = "stock-sync"
664
+ }
665
+ /**
666
+ * ISO-4217 money in minor units — mirrors the store's Money VO
667
+ * (`core/source/contracts/source-dtos.ts`) so the host maps 1:1 without a
668
+ * currency guess. Kept local so the SDK stays dependency-free.
669
+ */
670
+ interface SupplierMoney {
671
+ amountMinor: number;
672
+ currency: string;
673
+ }
674
+ interface SuppliersDefaultConfig {
675
+ global?: Record<string, unknown>;
676
+ countries?: Record<string, Record<string, unknown>>;
677
+ }
678
+ interface SuppliersPluginConfig {
679
+ supportedCountries: string[];
680
+ supportedCapabilities: SuppliersFeature[];
681
+ configSchema: PluginConfigField[];
682
+ defaultConfig?: SuppliersDefaultConfig;
683
+ }
684
+ interface SuppliersStaticConfig {
685
+ code: string;
686
+ displayName: string;
687
+ description: string;
688
+ iconUrl?: string;
689
+ supportedCountries: string[];
690
+ supportedCapabilities: SuppliersFeature[];
691
+ configSchema: PluginConfigField[];
692
+ }
693
+ interface SupplierCatalogQuery {
694
+ text?: string;
695
+ country?: string;
696
+ cursor?: string;
697
+ limit?: number;
698
+ }
699
+ interface SupplierListingVariant {
700
+ externalVariantId: string;
701
+ sku?: string | null;
702
+ title: string;
703
+ wholesalePrice: SupplierMoney;
704
+ options?: Record<string, string>;
705
+ imageUrl?: string | null;
706
+ available?: boolean;
707
+ }
708
+ interface SupplierListingAttribute {
709
+ name: string;
710
+ value: string;
711
+ }
712
+ interface SupplierStock {
713
+ externalId: string;
714
+ quantity: number;
715
+ inStock: boolean;
716
+ }
717
+ interface SupplierListing {
718
+ /** Native id in the supplier catalog (product or catalog-item id). */
719
+ externalId: string;
720
+ title: string;
721
+ description?: string | null;
722
+ sku?: string | null;
723
+ /** ABSOLUTE image URLs. `imageUrl` is the primary; `images` the gallery. */
724
+ imageUrl?: string | null;
725
+ images?: string[];
726
+ /** Wholesale cost the merchant pays the supplier (per unit). */
727
+ wholesalePrice: SupplierMoney;
728
+ /** Supplier's suggested retail, when provided. */
729
+ suggestedPrice?: SupplierMoney | null;
730
+ stock: SupplierStock;
731
+ categories?: string[];
732
+ attributes?: SupplierListingAttribute[];
733
+ hasVariants: boolean;
734
+ variants?: SupplierListingVariant[];
735
+ moq?: number | null;
736
+ /** Untouched supplier payload, for diagnostics. Never trusted for control flow. */
737
+ raw?: unknown;
738
+ }
739
+ interface SupplierListingPage {
740
+ items: SupplierListing[];
741
+ nextCursor?: string | null;
742
+ }
743
+ interface SupplierOrderCustomer {
744
+ name: string;
745
+ lastName?: string | null;
746
+ phoneAreaCode: string;
747
+ phone: string;
748
+ email?: string | null;
749
+ }
750
+ interface SupplierOrderAddressLevel {
751
+ levelKey: string;
752
+ valueId: string;
753
+ }
754
+ interface SupplierShipTo {
755
+ address: string;
756
+ referencePoint?: string | null;
757
+ /**
758
+ * Supplier-native geo ids. Optional: when the host cannot produce the
759
+ * supplier's own ids (the common case — the host only knows its own geo),
760
+ * it leaves these empty and passes the human-readable names below. The
761
+ * plugin resolves names → supplier ids against its own geo endpoints.
762
+ */
763
+ stateId?: string;
764
+ cityId?: string;
765
+ /** ISO 3166-1 alpha-2 of the destination country (e.g. "GT", "SV"). */
766
+ countryCode?: string;
767
+ /** Human-readable admin-area (state/department) name for plugin-side resolution. */
768
+ stateName?: string;
769
+ /** Human-readable locality (city/municipality) name for plugin-side resolution. */
770
+ cityName?: string;
771
+ extraLevels?: SupplierOrderAddressLevel[];
772
+ latitude?: number;
773
+ longitude?: number;
774
+ instructions?: string | null;
775
+ }
776
+ interface SupplierOrderLine {
777
+ /** Supplier catalog/variant id to order. */
778
+ externalListingId: string;
779
+ quantity: number;
780
+ /** Optional price override; omit to use the supplier's catalog price. */
781
+ unitPrice?: SupplierMoney | null;
782
+ }
783
+ interface PlaceSupplierOrderInput {
784
+ /** Host order id — the idempotency key the supplier dedupes on. */
785
+ externalOrderId: string;
786
+ customer: SupplierOrderCustomer;
787
+ shipTo: SupplierShipTo;
788
+ lines: SupplierOrderLine[];
789
+ cod: boolean;
790
+ /** Exact amount to collect on COD; defaults to the line total. */
791
+ codAmount?: SupplierMoney | null;
792
+ /** Optional carrier choice; the supplier picks a default when omitted. */
793
+ courierId?: string | null;
794
+ note?: string | null;
795
+ }
796
+ /**
797
+ * Normalized supplier-order status. `unknown` is a first-class value for
798
+ * supplier states the adapter does not map — the host treats it as a no-op.
799
+ */
800
+ type SupplierOrderStatus = 'pending' | 'accepted' | 'in_transit' | 'shipped' | 'delivered' | 'cancelled' | 'rejected' | 'unknown';
801
+ interface SupplierOrderResult {
802
+ /** Supplier-side order id. */
803
+ externalId: string;
804
+ orderNumber?: string | null;
805
+ /** The host order id echoed back, when the supplier stores it. */
806
+ externalOrderId?: string | null;
807
+ status: SupplierOrderStatus;
808
+ statusLabel?: string | null;
809
+ trackingCode?: string | null;
810
+ trackingUrl?: string | null;
811
+ carrier?: string | null;
812
+ shippingCost?: SupplierMoney | null;
813
+ codAmount?: SupplierMoney | null;
814
+ raw?: unknown;
815
+ }
816
+ /**
817
+ * Normalized, supplier-agnostic fulfillment event produced by
818
+ * {@link ISuppliersPlugin.parseWebhook}. The host matches `externalOrderId`
819
+ * against its stored SupplierOrder to resolve the local order, so the adapter
820
+ * never needs host identifiers.
821
+ */
822
+ interface SupplierFulfillmentEvent {
823
+ externalOrderId: string;
824
+ status: SupplierOrderStatus;
825
+ trackingCode?: string | null;
826
+ carrier?: string | null;
827
+ /** ISO-8601 instant the supplier reported the change, when available. */
828
+ occurredAt?: string;
829
+ statusDescription?: string;
830
+ /** Untouched supplier payload, for diagnostics. */
831
+ raw?: unknown;
832
+ }
833
+ interface ISuppliersPlugin extends IPlugin {
834
+ readonly name: string;
835
+ readonly suppliersConfig: SuppliersPluginConfig;
836
+ searchCatalog(query: SupplierCatalogQuery, ctx: DispatchContext): Promise<SupplierListingPage>;
837
+ getListing(externalId: string, ctx: DispatchContext): Promise<SupplierListing>;
838
+ placeOrder(order: PlaceSupplierOrderInput, ctx: DispatchContext): Promise<SupplierOrderResult>;
839
+ getOrderStatus(externalOrderId: string, ctx: DispatchContext): Promise<SupplierOrderResult>;
840
+ cancelOrder?(externalOrderId: string, ctx: DispatchContext): Promise<SupplierOrderResult>;
841
+ syncStock?(externalIds: string[], ctx: DispatchContext): Promise<SupplierStock[]>;
842
+ parseWebhook?(body: unknown, headers: Record<string, string>, ctx: DispatchContext): SupplierFulfillmentEvent | null;
843
+ isConfigured?(ctx: DispatchContext): boolean;
844
+ }
845
+
649
846
  /** A named unit of behaviour a plugin exposes to the host registry. */
650
847
  interface Capability<T = unknown> {
651
848
  kind: string;
@@ -659,12 +856,14 @@ interface Capability<T = unknown> {
659
856
  declare const CapabilityKind: {
660
857
  readonly Payment: "payment";
661
858
  readonly Shipping: "shipping";
859
+ readonly Suppliers: "suppliers";
662
860
  readonly Analytics: "analytics";
663
861
  };
664
862
  type CapabilityKind = (typeof CapabilityKind)[keyof typeof CapabilityKind];
665
863
  declare function capability<T>(kind: string, impl: T): Capability<T>;
666
864
  declare function paymentCapability(impl: IPaymentPlugin): Capability<IPaymentPlugin>;
667
865
  declare function shippingCapability(impl: IShippingPlugin): Capability<IShippingPlugin>;
866
+ declare function suppliersCapability(impl: ISuppliersPlugin): Capability<ISuppliersPlugin>;
668
867
  /**
669
868
  * A constructed plugin. `capabilities` is the static declaration the host reads
670
869
  * up front; `onActivate` runs when the host mounts the plugin for a tenant and
@@ -802,7 +1001,7 @@ declare function checkPermissions(required: string[], grantedRaw: string[]): Per
802
1001
  * - MINOR: additive (new optional fields, new tokens) — backwards compatible.
803
1002
  * - PATCH: docs/fixes with zero shape changes.
804
1003
  */
805
- declare const SDK_VERSION = "0.5.1";
1004
+ declare const SDK_VERSION = "0.6.0";
806
1005
  /**
807
1006
  * True when a plugin built against `pluginSdkVersion` can run on a host that
808
1007
  * ships `hostSdkVersion`. Rule: same major, host minor >= plugin minor.
@@ -811,4 +1010,4 @@ declare const SDK_VERSION = "0.5.1";
811
1010
  */
812
1011
  declare function isSdkCompatible(pluginSdkVersion: string, hostSdkVersion: string): boolean;
813
1012
 
814
- export { type AccordionBlock, type AccordionSection, type ActionBlock, ActionVariant, type BannerBlock, type Block, type BlockBase, BlockType, type CalloutBlock, type Capability, CapabilityKind, type CardBlock, type CodConfig, type CodFeeConfig, CodFeeType, type ConditionalBlock, type ConditionalEquals, type ConditionalWhen, ConfigScope, type ConfigurablePlugin, type CopyFieldBlock, type CreateShipmentParams, type DispatchContext, type DividerBlock, type DomainEventHandler, type DomainEventName, type FieldBlock, type FieldDefinition, type FieldDependsOn, type FieldMap, type FieldOption, FieldType, FieldVariant, GatewayEnvironment, type GatewayStaticConfig, type GroupBlock, type HostApi, type HttpClient, type HttpRequest, type HttpResponse, type IPaymentPlugin, type IPlugin, type IShippingPlugin, type InlineRowBlock, type KeyValueBlock, type KeyValueRow, LayoutMode, type Logger, type MarkdownBlock, MessageVariant, PAYMENT_PLUGIN_TOKEN, type PaymentCard, type PaymentCustomer, type PaymentGatewayCode, type PaymentPayload, type PaymentPluginConfig, type PaymentResult, type PaymentVerifyPayload, type Permission, type PermissionCheck, type Plugin, type PluginActionContext, type PluginActionResult, type PluginConfigField, type PluginConfigFieldDependency, type PluginConfigResult, type PluginConfigValidation, type PluginFactory, type PluginManifest, PluginType, type RepeaterBlock, RepeaterSource, SDK_VERSION, SHIPPING_PLUGIN_TOKEN, type SecretStore, type SelectOption, type SequenceStore, type SetupAction, type SetupLayout, type SetupLayoutValidation, type SetupStep, type ShipmentAddress, type ShipmentParcel, type ShipmentResult, type ShippingDefaultConfig, ShippingFeature, type ShippingPluginConfig, type ShippingQuote, type ShippingQuoteParams, type ShippingStaticConfig, StepStatusFrom, type StepStatusFromAction, type StepStatusFromFields, type StepStatusSource, type StorageBroker, type TabItem, type TabsBlock, type ToggleBlock, type TrackingEvent, TransactionStatus, type WebhookSignatureResult, capability, checkPermissions, createPluginConfig, crossValidateSetupLayout, definePlugin, field, isConfigurablePlugin, isPermissionGranted, isPluginFactory, isSdkCompatible, parsePermission, paymentCapability, shippingCapability, validateSetupLayout };
1013
+ export { type AccordionBlock, type AccordionSection, type ActionBlock, ActionVariant, type BannerBlock, type Block, type BlockBase, BlockType, type CalloutBlock, type Capability, CapabilityKind, type CardBlock, type CodConfig, type CodFeeConfig, CodFeeType, type ConditionalBlock, type ConditionalEquals, type ConditionalWhen, ConfigScope, type ConfigurablePlugin, type CopyFieldBlock, type CreateShipmentParams, type DispatchContext, type DividerBlock, type DomainEventHandler, type DomainEventName, type FieldBlock, type FieldDefinition, type FieldDependsOn, type FieldMap, type FieldOption, FieldType, FieldVariant, GatewayEnvironment, type GatewayStaticConfig, type GroupBlock, type HostApi, type HttpClient, type HttpRequest, type HttpResponse, type IPaymentPlugin, type IPlugin, type IShippingPlugin, type ISuppliersPlugin, type InlineRowBlock, type KeyValueBlock, type KeyValueRow, LayoutMode, type Logger, type MarkdownBlock, MessageVariant, PAYMENT_PLUGIN_TOKEN, type PaymentCard, type PaymentCustomer, type PaymentGatewayCode, type PaymentPayload, type PaymentPluginConfig, type PaymentResult, type PaymentVerifyPayload, type Permission, type PermissionCheck, type PlaceSupplierOrderInput, type Plugin, type PluginActionContext, type PluginActionResult, type PluginConfigField, type PluginConfigFieldDependency, type PluginConfigResult, type PluginConfigValidation, type PluginFactory, type PluginManifest, PluginType, type RepeaterBlock, RepeaterSource, SDK_VERSION, SHIPPING_PLUGIN_TOKEN, SUPPLIERS_PLUGIN_TOKEN, type SecretStore, type SelectOption, type SequenceStore, type SetupAction, type SetupLayout, type SetupLayoutValidation, type SetupStep, type ShipmentAddress, type ShipmentParcel, type ShipmentResult, type ShippingDefaultConfig, ShippingFeature, type ShippingPluginConfig, type ShippingQuote, type ShippingQuoteParams, type ShippingStaticConfig, StepStatusFrom, type StepStatusFromAction, type StepStatusFromFields, type StepStatusSource, type StorageBroker, type SupplierCatalogQuery, type SupplierFulfillmentEvent, type SupplierListing, type SupplierListingAttribute, type SupplierListingPage, type SupplierListingVariant, type SupplierMoney, type SupplierOrderAddressLevel, type SupplierOrderCustomer, type SupplierOrderLine, type SupplierOrderResult, type SupplierOrderStatus, type SupplierShipTo, type SupplierStock, type SuppliersDefaultConfig, SuppliersFeature, type SuppliersPluginConfig, type SuppliersStaticConfig, type TabItem, type TabsBlock, type ToggleBlock, type TrackingEvent, TransactionStatus, type WebhookSignatureResult, capability, checkPermissions, createPluginConfig, crossValidateSetupLayout, definePlugin, field, isConfigurablePlugin, isPermissionGranted, isPluginFactory, isSdkCompatible, parsePermission, paymentCapability, shippingCapability, suppliersCapability, validateSetupLayout };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  declare const PAYMENT_PLUGIN_TOKEN: "PAYMENT_PLUGINS";
2
2
  declare const SHIPPING_PLUGIN_TOKEN: "SHIPPING_PLUGINS";
3
+ declare const SUPPLIERS_PLUGIN_TOKEN: "SUPPLIERS_PLUGINS";
3
4
 
4
5
  declare enum FieldType {
5
6
  String = "string",
@@ -646,6 +647,202 @@ interface IShippingPlugin extends IPlugin {
646
647
  isConfigured?(ctx: DispatchContext): boolean;
647
648
  }
648
649
 
650
+ declare enum SuppliersFeature {
651
+ /** Browse/search the supplier catalog. */
652
+ CatalogSearch = "catalog-search",
653
+ /** Pull a full listing snapshot to seed a native product. */
654
+ CatalogImport = "catalog-import",
655
+ /** Place + track orders against the supplier. */
656
+ Orders = "orders",
657
+ /** Supplier pushes order status to a registered webhook. */
658
+ FulfillmentSync = "fulfillment-sync",
659
+ /**
660
+ * Poll the supplier for stock levels. SoyDrop has no inventory webhook, so
661
+ * stock is reconciled by polling rather than push.
662
+ */
663
+ StockSync = "stock-sync"
664
+ }
665
+ /**
666
+ * ISO-4217 money in minor units — mirrors the store's Money VO
667
+ * (`core/source/contracts/source-dtos.ts`) so the host maps 1:1 without a
668
+ * currency guess. Kept local so the SDK stays dependency-free.
669
+ */
670
+ interface SupplierMoney {
671
+ amountMinor: number;
672
+ currency: string;
673
+ }
674
+ interface SuppliersDefaultConfig {
675
+ global?: Record<string, unknown>;
676
+ countries?: Record<string, Record<string, unknown>>;
677
+ }
678
+ interface SuppliersPluginConfig {
679
+ supportedCountries: string[];
680
+ supportedCapabilities: SuppliersFeature[];
681
+ configSchema: PluginConfigField[];
682
+ defaultConfig?: SuppliersDefaultConfig;
683
+ }
684
+ interface SuppliersStaticConfig {
685
+ code: string;
686
+ displayName: string;
687
+ description: string;
688
+ iconUrl?: string;
689
+ supportedCountries: string[];
690
+ supportedCapabilities: SuppliersFeature[];
691
+ configSchema: PluginConfigField[];
692
+ }
693
+ interface SupplierCatalogQuery {
694
+ text?: string;
695
+ country?: string;
696
+ cursor?: string;
697
+ limit?: number;
698
+ }
699
+ interface SupplierListingVariant {
700
+ externalVariantId: string;
701
+ sku?: string | null;
702
+ title: string;
703
+ wholesalePrice: SupplierMoney;
704
+ options?: Record<string, string>;
705
+ imageUrl?: string | null;
706
+ available?: boolean;
707
+ }
708
+ interface SupplierListingAttribute {
709
+ name: string;
710
+ value: string;
711
+ }
712
+ interface SupplierStock {
713
+ externalId: string;
714
+ quantity: number;
715
+ inStock: boolean;
716
+ }
717
+ interface SupplierListing {
718
+ /** Native id in the supplier catalog (product or catalog-item id). */
719
+ externalId: string;
720
+ title: string;
721
+ description?: string | null;
722
+ sku?: string | null;
723
+ /** ABSOLUTE image URLs. `imageUrl` is the primary; `images` the gallery. */
724
+ imageUrl?: string | null;
725
+ images?: string[];
726
+ /** Wholesale cost the merchant pays the supplier (per unit). */
727
+ wholesalePrice: SupplierMoney;
728
+ /** Supplier's suggested retail, when provided. */
729
+ suggestedPrice?: SupplierMoney | null;
730
+ stock: SupplierStock;
731
+ categories?: string[];
732
+ attributes?: SupplierListingAttribute[];
733
+ hasVariants: boolean;
734
+ variants?: SupplierListingVariant[];
735
+ moq?: number | null;
736
+ /** Untouched supplier payload, for diagnostics. Never trusted for control flow. */
737
+ raw?: unknown;
738
+ }
739
+ interface SupplierListingPage {
740
+ items: SupplierListing[];
741
+ nextCursor?: string | null;
742
+ }
743
+ interface SupplierOrderCustomer {
744
+ name: string;
745
+ lastName?: string | null;
746
+ phoneAreaCode: string;
747
+ phone: string;
748
+ email?: string | null;
749
+ }
750
+ interface SupplierOrderAddressLevel {
751
+ levelKey: string;
752
+ valueId: string;
753
+ }
754
+ interface SupplierShipTo {
755
+ address: string;
756
+ referencePoint?: string | null;
757
+ /**
758
+ * Supplier-native geo ids. Optional: when the host cannot produce the
759
+ * supplier's own ids (the common case — the host only knows its own geo),
760
+ * it leaves these empty and passes the human-readable names below. The
761
+ * plugin resolves names → supplier ids against its own geo endpoints.
762
+ */
763
+ stateId?: string;
764
+ cityId?: string;
765
+ /** ISO 3166-1 alpha-2 of the destination country (e.g. "GT", "SV"). */
766
+ countryCode?: string;
767
+ /** Human-readable admin-area (state/department) name for plugin-side resolution. */
768
+ stateName?: string;
769
+ /** Human-readable locality (city/municipality) name for plugin-side resolution. */
770
+ cityName?: string;
771
+ extraLevels?: SupplierOrderAddressLevel[];
772
+ latitude?: number;
773
+ longitude?: number;
774
+ instructions?: string | null;
775
+ }
776
+ interface SupplierOrderLine {
777
+ /** Supplier catalog/variant id to order. */
778
+ externalListingId: string;
779
+ quantity: number;
780
+ /** Optional price override; omit to use the supplier's catalog price. */
781
+ unitPrice?: SupplierMoney | null;
782
+ }
783
+ interface PlaceSupplierOrderInput {
784
+ /** Host order id — the idempotency key the supplier dedupes on. */
785
+ externalOrderId: string;
786
+ customer: SupplierOrderCustomer;
787
+ shipTo: SupplierShipTo;
788
+ lines: SupplierOrderLine[];
789
+ cod: boolean;
790
+ /** Exact amount to collect on COD; defaults to the line total. */
791
+ codAmount?: SupplierMoney | null;
792
+ /** Optional carrier choice; the supplier picks a default when omitted. */
793
+ courierId?: string | null;
794
+ note?: string | null;
795
+ }
796
+ /**
797
+ * Normalized supplier-order status. `unknown` is a first-class value for
798
+ * supplier states the adapter does not map — the host treats it as a no-op.
799
+ */
800
+ type SupplierOrderStatus = 'pending' | 'accepted' | 'in_transit' | 'shipped' | 'delivered' | 'cancelled' | 'rejected' | 'unknown';
801
+ interface SupplierOrderResult {
802
+ /** Supplier-side order id. */
803
+ externalId: string;
804
+ orderNumber?: string | null;
805
+ /** The host order id echoed back, when the supplier stores it. */
806
+ externalOrderId?: string | null;
807
+ status: SupplierOrderStatus;
808
+ statusLabel?: string | null;
809
+ trackingCode?: string | null;
810
+ trackingUrl?: string | null;
811
+ carrier?: string | null;
812
+ shippingCost?: SupplierMoney | null;
813
+ codAmount?: SupplierMoney | null;
814
+ raw?: unknown;
815
+ }
816
+ /**
817
+ * Normalized, supplier-agnostic fulfillment event produced by
818
+ * {@link ISuppliersPlugin.parseWebhook}. The host matches `externalOrderId`
819
+ * against its stored SupplierOrder to resolve the local order, so the adapter
820
+ * never needs host identifiers.
821
+ */
822
+ interface SupplierFulfillmentEvent {
823
+ externalOrderId: string;
824
+ status: SupplierOrderStatus;
825
+ trackingCode?: string | null;
826
+ carrier?: string | null;
827
+ /** ISO-8601 instant the supplier reported the change, when available. */
828
+ occurredAt?: string;
829
+ statusDescription?: string;
830
+ /** Untouched supplier payload, for diagnostics. */
831
+ raw?: unknown;
832
+ }
833
+ interface ISuppliersPlugin extends IPlugin {
834
+ readonly name: string;
835
+ readonly suppliersConfig: SuppliersPluginConfig;
836
+ searchCatalog(query: SupplierCatalogQuery, ctx: DispatchContext): Promise<SupplierListingPage>;
837
+ getListing(externalId: string, ctx: DispatchContext): Promise<SupplierListing>;
838
+ placeOrder(order: PlaceSupplierOrderInput, ctx: DispatchContext): Promise<SupplierOrderResult>;
839
+ getOrderStatus(externalOrderId: string, ctx: DispatchContext): Promise<SupplierOrderResult>;
840
+ cancelOrder?(externalOrderId: string, ctx: DispatchContext): Promise<SupplierOrderResult>;
841
+ syncStock?(externalIds: string[], ctx: DispatchContext): Promise<SupplierStock[]>;
842
+ parseWebhook?(body: unknown, headers: Record<string, string>, ctx: DispatchContext): SupplierFulfillmentEvent | null;
843
+ isConfigured?(ctx: DispatchContext): boolean;
844
+ }
845
+
649
846
  /** A named unit of behaviour a plugin exposes to the host registry. */
650
847
  interface Capability<T = unknown> {
651
848
  kind: string;
@@ -659,12 +856,14 @@ interface Capability<T = unknown> {
659
856
  declare const CapabilityKind: {
660
857
  readonly Payment: "payment";
661
858
  readonly Shipping: "shipping";
859
+ readonly Suppliers: "suppliers";
662
860
  readonly Analytics: "analytics";
663
861
  };
664
862
  type CapabilityKind = (typeof CapabilityKind)[keyof typeof CapabilityKind];
665
863
  declare function capability<T>(kind: string, impl: T): Capability<T>;
666
864
  declare function paymentCapability(impl: IPaymentPlugin): Capability<IPaymentPlugin>;
667
865
  declare function shippingCapability(impl: IShippingPlugin): Capability<IShippingPlugin>;
866
+ declare function suppliersCapability(impl: ISuppliersPlugin): Capability<ISuppliersPlugin>;
668
867
  /**
669
868
  * A constructed plugin. `capabilities` is the static declaration the host reads
670
869
  * up front; `onActivate` runs when the host mounts the plugin for a tenant and
@@ -802,7 +1001,7 @@ declare function checkPermissions(required: string[], grantedRaw: string[]): Per
802
1001
  * - MINOR: additive (new optional fields, new tokens) — backwards compatible.
803
1002
  * - PATCH: docs/fixes with zero shape changes.
804
1003
  */
805
- declare const SDK_VERSION = "0.5.1";
1004
+ declare const SDK_VERSION = "0.6.0";
806
1005
  /**
807
1006
  * True when a plugin built against `pluginSdkVersion` can run on a host that
808
1007
  * ships `hostSdkVersion`. Rule: same major, host minor >= plugin minor.
@@ -811,4 +1010,4 @@ declare const SDK_VERSION = "0.5.1";
811
1010
  */
812
1011
  declare function isSdkCompatible(pluginSdkVersion: string, hostSdkVersion: string): boolean;
813
1012
 
814
- export { type AccordionBlock, type AccordionSection, type ActionBlock, ActionVariant, type BannerBlock, type Block, type BlockBase, BlockType, type CalloutBlock, type Capability, CapabilityKind, type CardBlock, type CodConfig, type CodFeeConfig, CodFeeType, type ConditionalBlock, type ConditionalEquals, type ConditionalWhen, ConfigScope, type ConfigurablePlugin, type CopyFieldBlock, type CreateShipmentParams, type DispatchContext, type DividerBlock, type DomainEventHandler, type DomainEventName, type FieldBlock, type FieldDefinition, type FieldDependsOn, type FieldMap, type FieldOption, FieldType, FieldVariant, GatewayEnvironment, type GatewayStaticConfig, type GroupBlock, type HostApi, type HttpClient, type HttpRequest, type HttpResponse, type IPaymentPlugin, type IPlugin, type IShippingPlugin, type InlineRowBlock, type KeyValueBlock, type KeyValueRow, LayoutMode, type Logger, type MarkdownBlock, MessageVariant, PAYMENT_PLUGIN_TOKEN, type PaymentCard, type PaymentCustomer, type PaymentGatewayCode, type PaymentPayload, type PaymentPluginConfig, type PaymentResult, type PaymentVerifyPayload, type Permission, type PermissionCheck, type Plugin, type PluginActionContext, type PluginActionResult, type PluginConfigField, type PluginConfigFieldDependency, type PluginConfigResult, type PluginConfigValidation, type PluginFactory, type PluginManifest, PluginType, type RepeaterBlock, RepeaterSource, SDK_VERSION, SHIPPING_PLUGIN_TOKEN, type SecretStore, type SelectOption, type SequenceStore, type SetupAction, type SetupLayout, type SetupLayoutValidation, type SetupStep, type ShipmentAddress, type ShipmentParcel, type ShipmentResult, type ShippingDefaultConfig, ShippingFeature, type ShippingPluginConfig, type ShippingQuote, type ShippingQuoteParams, type ShippingStaticConfig, StepStatusFrom, type StepStatusFromAction, type StepStatusFromFields, type StepStatusSource, type StorageBroker, type TabItem, type TabsBlock, type ToggleBlock, type TrackingEvent, TransactionStatus, type WebhookSignatureResult, capability, checkPermissions, createPluginConfig, crossValidateSetupLayout, definePlugin, field, isConfigurablePlugin, isPermissionGranted, isPluginFactory, isSdkCompatible, parsePermission, paymentCapability, shippingCapability, validateSetupLayout };
1013
+ export { type AccordionBlock, type AccordionSection, type ActionBlock, ActionVariant, type BannerBlock, type Block, type BlockBase, BlockType, type CalloutBlock, type Capability, CapabilityKind, type CardBlock, type CodConfig, type CodFeeConfig, CodFeeType, type ConditionalBlock, type ConditionalEquals, type ConditionalWhen, ConfigScope, type ConfigurablePlugin, type CopyFieldBlock, type CreateShipmentParams, type DispatchContext, type DividerBlock, type DomainEventHandler, type DomainEventName, type FieldBlock, type FieldDefinition, type FieldDependsOn, type FieldMap, type FieldOption, FieldType, FieldVariant, GatewayEnvironment, type GatewayStaticConfig, type GroupBlock, type HostApi, type HttpClient, type HttpRequest, type HttpResponse, type IPaymentPlugin, type IPlugin, type IShippingPlugin, type ISuppliersPlugin, type InlineRowBlock, type KeyValueBlock, type KeyValueRow, LayoutMode, type Logger, type MarkdownBlock, MessageVariant, PAYMENT_PLUGIN_TOKEN, type PaymentCard, type PaymentCustomer, type PaymentGatewayCode, type PaymentPayload, type PaymentPluginConfig, type PaymentResult, type PaymentVerifyPayload, type Permission, type PermissionCheck, type PlaceSupplierOrderInput, type Plugin, type PluginActionContext, type PluginActionResult, type PluginConfigField, type PluginConfigFieldDependency, type PluginConfigResult, type PluginConfigValidation, type PluginFactory, type PluginManifest, PluginType, type RepeaterBlock, RepeaterSource, SDK_VERSION, SHIPPING_PLUGIN_TOKEN, SUPPLIERS_PLUGIN_TOKEN, type SecretStore, type SelectOption, type SequenceStore, type SetupAction, type SetupLayout, type SetupLayoutValidation, type SetupStep, type ShipmentAddress, type ShipmentParcel, type ShipmentResult, type ShippingDefaultConfig, ShippingFeature, type ShippingPluginConfig, type ShippingQuote, type ShippingQuoteParams, type ShippingStaticConfig, StepStatusFrom, type StepStatusFromAction, type StepStatusFromFields, type StepStatusSource, type StorageBroker, type SupplierCatalogQuery, type SupplierFulfillmentEvent, type SupplierListing, type SupplierListingAttribute, type SupplierListingPage, type SupplierListingVariant, type SupplierMoney, type SupplierOrderAddressLevel, type SupplierOrderCustomer, type SupplierOrderLine, type SupplierOrderResult, type SupplierOrderStatus, type SupplierShipTo, type SupplierStock, type SuppliersDefaultConfig, SuppliersFeature, type SuppliersPluginConfig, type SuppliersStaticConfig, type TabItem, type TabsBlock, type ToggleBlock, type TrackingEvent, TransactionStatus, type WebhookSignatureResult, capability, checkPermissions, createPluginConfig, crossValidateSetupLayout, definePlugin, field, isConfigurablePlugin, isPermissionGranted, isPluginFactory, isSdkCompatible, parsePermission, paymentCapability, shippingCapability, suppliersCapability, validateSetupLayout };
package/dist/index.js CHANGED
@@ -35,8 +35,10 @@ __export(index_exports, {
35
35
  RepeaterSource: () => RepeaterSource,
36
36
  SDK_VERSION: () => SDK_VERSION,
37
37
  SHIPPING_PLUGIN_TOKEN: () => SHIPPING_PLUGIN_TOKEN,
38
+ SUPPLIERS_PLUGIN_TOKEN: () => SUPPLIERS_PLUGIN_TOKEN,
38
39
  ShippingFeature: () => ShippingFeature,
39
40
  StepStatusFrom: () => StepStatusFrom,
41
+ SuppliersFeature: () => SuppliersFeature,
40
42
  TransactionStatus: () => TransactionStatus,
41
43
  capability: () => capability,
42
44
  checkPermissions: () => checkPermissions,
@@ -51,6 +53,7 @@ __export(index_exports, {
51
53
  parsePermission: () => parsePermission,
52
54
  paymentCapability: () => paymentCapability,
53
55
  shippingCapability: () => shippingCapability,
56
+ suppliersCapability: () => suppliersCapability,
54
57
  validateSetupLayout: () => validateSetupLayout
55
58
  });
56
59
  module.exports = __toCommonJS(index_exports);
@@ -58,6 +61,7 @@ module.exports = __toCommonJS(index_exports);
58
61
  // src/tokens.ts
59
62
  var PAYMENT_PLUGIN_TOKEN = "PAYMENT_PLUGINS";
60
63
  var SHIPPING_PLUGIN_TOKEN = "SHIPPING_PLUGINS";
64
+ var SUPPLIERS_PLUGIN_TOKEN = "SUPPLIERS_PLUGINS";
61
65
 
62
66
  // src/plugin.ts
63
67
  var PluginType = /* @__PURE__ */ ((PluginType2) => {
@@ -186,6 +190,16 @@ var CodFeeType = /* @__PURE__ */ ((CodFeeType2) => {
186
190
  return CodFeeType2;
187
191
  })(CodFeeType || {});
188
192
 
193
+ // src/suppliers.ts
194
+ var SuppliersFeature = /* @__PURE__ */ ((SuppliersFeature2) => {
195
+ SuppliersFeature2["CatalogSearch"] = "catalog-search";
196
+ SuppliersFeature2["CatalogImport"] = "catalog-import";
197
+ SuppliersFeature2["Orders"] = "orders";
198
+ SuppliersFeature2["FulfillmentSync"] = "fulfillment-sync";
199
+ SuppliersFeature2["StockSync"] = "stock-sync";
200
+ return SuppliersFeature2;
201
+ })(SuppliersFeature || {});
202
+
189
203
  // src/setup-layout.ts
190
204
  var import_superstruct2 = require("superstruct");
191
205
  var FieldVariant = /* @__PURE__ */ ((FieldVariant2) => {
@@ -456,6 +470,7 @@ function crossValidateSetupLayout(layout, configSchema) {
456
470
  var CapabilityKind = {
457
471
  Payment: "payment",
458
472
  Shipping: "shipping",
473
+ Suppliers: "suppliers",
459
474
  Analytics: "analytics"
460
475
  };
461
476
  function capability(kind, impl) {
@@ -467,6 +482,9 @@ function paymentCapability(impl) {
467
482
  function shippingCapability(impl) {
468
483
  return { kind: CapabilityKind.Shipping, impl };
469
484
  }
485
+ function suppliersCapability(impl) {
486
+ return { kind: CapabilityKind.Suppliers, impl };
487
+ }
470
488
  var PLUGIN_FACTORY_BRAND = /* @__PURE__ */ Symbol.for("vivoa.plugin.factory");
471
489
  function definePlugin(factory) {
472
490
  Object.defineProperty(factory, PLUGIN_FACTORY_BRAND, {
@@ -512,7 +530,7 @@ function checkPermissions(required, grantedRaw) {
512
530
  }
513
531
 
514
532
  // src/version.ts
515
- var SDK_VERSION = "0.5.1";
533
+ var SDK_VERSION = "0.6.0";
516
534
  function isSdkCompatible(pluginSdkVersion, hostSdkVersion) {
517
535
  const parse = (v) => {
518
536
  const m = /^(\d+)\.(\d+)\.(\d+)/.exec(v);
@@ -544,8 +562,10 @@ function isSdkCompatible(pluginSdkVersion, hostSdkVersion) {
544
562
  RepeaterSource,
545
563
  SDK_VERSION,
546
564
  SHIPPING_PLUGIN_TOKEN,
565
+ SUPPLIERS_PLUGIN_TOKEN,
547
566
  ShippingFeature,
548
567
  StepStatusFrom,
568
+ SuppliersFeature,
549
569
  TransactionStatus,
550
570
  capability,
551
571
  checkPermissions,
@@ -560,5 +580,6 @@ function isSdkCompatible(pluginSdkVersion, hostSdkVersion) {
560
580
  parsePermission,
561
581
  paymentCapability,
562
582
  shippingCapability,
583
+ suppliersCapability,
563
584
  validateSetupLayout
564
585
  });
package/dist/index.mjs CHANGED
@@ -1,6 +1,7 @@
1
1
  // src/tokens.ts
2
2
  var PAYMENT_PLUGIN_TOKEN = "PAYMENT_PLUGINS";
3
3
  var SHIPPING_PLUGIN_TOKEN = "SHIPPING_PLUGINS";
4
+ var SUPPLIERS_PLUGIN_TOKEN = "SUPPLIERS_PLUGINS";
4
5
 
5
6
  // src/plugin.ts
6
7
  var PluginType = /* @__PURE__ */ ((PluginType2) => {
@@ -137,6 +138,16 @@ var CodFeeType = /* @__PURE__ */ ((CodFeeType2) => {
137
138
  return CodFeeType2;
138
139
  })(CodFeeType || {});
139
140
 
141
+ // src/suppliers.ts
142
+ var SuppliersFeature = /* @__PURE__ */ ((SuppliersFeature2) => {
143
+ SuppliersFeature2["CatalogSearch"] = "catalog-search";
144
+ SuppliersFeature2["CatalogImport"] = "catalog-import";
145
+ SuppliersFeature2["Orders"] = "orders";
146
+ SuppliersFeature2["FulfillmentSync"] = "fulfillment-sync";
147
+ SuppliersFeature2["StockSync"] = "stock-sync";
148
+ return SuppliersFeature2;
149
+ })(SuppliersFeature || {});
150
+
140
151
  // src/setup-layout.ts
141
152
  import {
142
153
  array,
@@ -420,6 +431,7 @@ function crossValidateSetupLayout(layout, configSchema) {
420
431
  var CapabilityKind = {
421
432
  Payment: "payment",
422
433
  Shipping: "shipping",
434
+ Suppliers: "suppliers",
423
435
  Analytics: "analytics"
424
436
  };
425
437
  function capability(kind, impl) {
@@ -431,6 +443,9 @@ function paymentCapability(impl) {
431
443
  function shippingCapability(impl) {
432
444
  return { kind: CapabilityKind.Shipping, impl };
433
445
  }
446
+ function suppliersCapability(impl) {
447
+ return { kind: CapabilityKind.Suppliers, impl };
448
+ }
434
449
  var PLUGIN_FACTORY_BRAND = /* @__PURE__ */ Symbol.for("vivoa.plugin.factory");
435
450
  function definePlugin(factory) {
436
451
  Object.defineProperty(factory, PLUGIN_FACTORY_BRAND, {
@@ -476,7 +491,7 @@ function checkPermissions(required, grantedRaw) {
476
491
  }
477
492
 
478
493
  // src/version.ts
479
- var SDK_VERSION = "0.5.1";
494
+ var SDK_VERSION = "0.6.0";
480
495
  function isSdkCompatible(pluginSdkVersion, hostSdkVersion) {
481
496
  const parse = (v) => {
482
497
  const m = /^(\d+)\.(\d+)\.(\d+)/.exec(v);
@@ -507,8 +522,10 @@ export {
507
522
  RepeaterSource,
508
523
  SDK_VERSION,
509
524
  SHIPPING_PLUGIN_TOKEN,
525
+ SUPPLIERS_PLUGIN_TOKEN,
510
526
  ShippingFeature,
511
527
  StepStatusFrom,
528
+ SuppliersFeature,
512
529
  TransactionStatus,
513
530
  capability,
514
531
  checkPermissions,
@@ -523,5 +540,6 @@ export {
523
540
  parsePermission,
524
541
  paymentCapability,
525
542
  shippingCapability,
543
+ suppliersCapability,
526
544
  validateSetupLayout
527
545
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vivoa/plugin-sdk",
3
- "version": "0.5.1",
3
+ "version": "0.6.0",
4
4
  "description": "Public contracts for Vivoa plugins (types, DI tokens, config + setup-layout validators)",
5
5
  "license": "MIT",
6
6
  "author": "Vivoa",
@@ -56,4 +56,4 @@
56
56
  "esbuild"
57
57
  ]
58
58
  }
59
- }
59
+ }