@vivoa/plugin-sdk 0.5.2 → 0.6.1
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 +107 -5
- package/dist/index.d.ts +107 -5
- package/dist/index.js +18 -1
- package/dist/index.mjs +15 -1
- package/package.json +8 -14
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
declare const PAYMENT_PLUGIN_TOKEN: "PAYMENT_PLUGINS";
|
|
2
2
|
declare const SHIPPING_PLUGIN_TOKEN: "SHIPPING_PLUGINS";
|
|
3
3
|
declare const SUPPLIERS_PLUGIN_TOKEN: "SUPPLIERS_PLUGINS";
|
|
4
|
+
declare const ANALYTICS_PLUGIN_TOKEN: "ANALYTICS_PLUGINS";
|
|
4
5
|
|
|
5
6
|
declare enum FieldType {
|
|
6
7
|
String = "string",
|
|
@@ -754,9 +755,20 @@ interface SupplierOrderAddressLevel {
|
|
|
754
755
|
interface SupplierShipTo {
|
|
755
756
|
address: string;
|
|
756
757
|
referencePoint?: string | null;
|
|
757
|
-
/**
|
|
758
|
-
|
|
759
|
-
|
|
758
|
+
/**
|
|
759
|
+
* Supplier-native geo ids. Optional: when the host cannot produce the
|
|
760
|
+
* supplier's own ids (the common case — the host only knows its own geo),
|
|
761
|
+
* it leaves these empty and passes the human-readable names below. The
|
|
762
|
+
* plugin resolves names → supplier ids against its own geo endpoints.
|
|
763
|
+
*/
|
|
764
|
+
stateId?: string;
|
|
765
|
+
cityId?: string;
|
|
766
|
+
/** ISO 3166-1 alpha-2 of the destination country (e.g. "GT", "SV"). */
|
|
767
|
+
countryCode?: string;
|
|
768
|
+
/** Human-readable admin-area (state/department) name for plugin-side resolution. */
|
|
769
|
+
stateName?: string;
|
|
770
|
+
/** Human-readable locality (city/municipality) name for plugin-side resolution. */
|
|
771
|
+
cityName?: string;
|
|
760
772
|
extraLevels?: SupplierOrderAddressLevel[];
|
|
761
773
|
latitude?: number;
|
|
762
774
|
longitude?: number;
|
|
@@ -826,11 +838,100 @@ interface ISuppliersPlugin extends IPlugin {
|
|
|
826
838
|
getListing(externalId: string, ctx: DispatchContext): Promise<SupplierListing>;
|
|
827
839
|
placeOrder(order: PlaceSupplierOrderInput, ctx: DispatchContext): Promise<SupplierOrderResult>;
|
|
828
840
|
getOrderStatus(externalOrderId: string, ctx: DispatchContext): Promise<SupplierOrderResult>;
|
|
841
|
+
cancelOrder?(externalOrderId: string, ctx: DispatchContext): Promise<SupplierOrderResult>;
|
|
829
842
|
syncStock?(externalIds: string[], ctx: DispatchContext): Promise<SupplierStock[]>;
|
|
830
843
|
parseWebhook?(body: unknown, headers: Record<string, string>, ctx: DispatchContext): SupplierFulfillmentEvent | null;
|
|
831
844
|
isConfigured?(ctx: DispatchContext): boolean;
|
|
832
845
|
}
|
|
833
846
|
|
|
847
|
+
declare enum AnalyticsFeature {
|
|
848
|
+
/** Ecommerce funnel events: view_item, add_to_cart, begin_checkout, purchase. */
|
|
849
|
+
Ecommerce = "ecommerce",
|
|
850
|
+
/** Generic page_view tracking. */
|
|
851
|
+
PageViews = "page-views"
|
|
852
|
+
}
|
|
853
|
+
/**
|
|
854
|
+
* ISO-4217 money in minor units — mirrors the store's Money VO so the host maps
|
|
855
|
+
* 1:1 without a currency guess. Kept local so the SDK stays dependency-free.
|
|
856
|
+
*/
|
|
857
|
+
interface AnalyticsMoney {
|
|
858
|
+
amountMinor: number;
|
|
859
|
+
currency: string;
|
|
860
|
+
}
|
|
861
|
+
/** A single line item attached to an ecommerce event. */
|
|
862
|
+
interface AnalyticsItem {
|
|
863
|
+
/** Product or variant id as the store knows it. */
|
|
864
|
+
id: string;
|
|
865
|
+
name?: string;
|
|
866
|
+
sku?: string | null;
|
|
867
|
+
quantity?: number;
|
|
868
|
+
price?: AnalyticsMoney;
|
|
869
|
+
category?: string | null;
|
|
870
|
+
}
|
|
871
|
+
/**
|
|
872
|
+
* Canonical, provider-agnostic event names the host emits. Closed set: the host
|
|
873
|
+
* only ever maps a domain event to one of these. An adapter that does not care
|
|
874
|
+
* about a given name simply ignores it.
|
|
875
|
+
*/
|
|
876
|
+
type AnalyticsEventName = 'page_view' | 'view_item' | 'add_to_cart' | 'remove_from_cart' | 'begin_checkout' | 'purchase';
|
|
877
|
+
/**
|
|
878
|
+
* Normalized analytics event. The host builds this from a DomainEvent and hands
|
|
879
|
+
* it to every active analytics adapter. The adapter translates it to its own
|
|
880
|
+
* wire format (GA4 event, Meta event, ...).
|
|
881
|
+
*/
|
|
882
|
+
interface AnalyticsEvent {
|
|
883
|
+
name: AnalyticsEventName;
|
|
884
|
+
/** ISO-8601 instant the underlying action happened. */
|
|
885
|
+
occurredAt: string;
|
|
886
|
+
/**
|
|
887
|
+
* Pseudonymous client identity for sessionization (maps to GA4 `client_id`
|
|
888
|
+
* / Meta `external_id`). Null when the host cannot resolve a stable id.
|
|
889
|
+
*/
|
|
890
|
+
clientId?: string | null;
|
|
891
|
+
sessionId?: string | null;
|
|
892
|
+
/** Monetary value for value-bearing events (purchase, begin_checkout). */
|
|
893
|
+
value?: AnalyticsMoney | null;
|
|
894
|
+
/** Order id for `purchase` — providers dedupe transactions on it. */
|
|
895
|
+
transactionId?: string | null;
|
|
896
|
+
items?: AnalyticsItem[];
|
|
897
|
+
/** Page context for `page_view`. */
|
|
898
|
+
pageLocation?: string | null;
|
|
899
|
+
pageTitle?: string | null;
|
|
900
|
+
/** Extra params forwarded verbatim as custom dimensions. */
|
|
901
|
+
params?: Record<string, unknown>;
|
|
902
|
+
}
|
|
903
|
+
interface AnalyticsPluginConfig {
|
|
904
|
+
supportedCapabilities: AnalyticsFeature[];
|
|
905
|
+
configSchema: PluginConfigField[];
|
|
906
|
+
/** GLOBAL-scope defaults merged under the tenant DB config by the host. */
|
|
907
|
+
defaultConfig?: Record<string, unknown>;
|
|
908
|
+
}
|
|
909
|
+
interface AnalyticsStaticConfig {
|
|
910
|
+
code: string;
|
|
911
|
+
displayName: string;
|
|
912
|
+
description: string;
|
|
913
|
+
iconUrl?: string;
|
|
914
|
+
supportedCapabilities: AnalyticsFeature[];
|
|
915
|
+
configSchema: PluginConfigField[];
|
|
916
|
+
}
|
|
917
|
+
interface IAnalyticsPlugin extends IPlugin {
|
|
918
|
+
readonly name: string;
|
|
919
|
+
readonly analyticsConfig: AnalyticsPluginConfig;
|
|
920
|
+
/**
|
|
921
|
+
* Forward one canonical event to the provider's ingestion API. Stateless: the
|
|
922
|
+
* tenant's resolved credentials arrive in `ctx.config` on every call.
|
|
923
|
+
*
|
|
924
|
+
* @rule BEST-EFFORT — never throw on a transport/provider error. Analytics is
|
|
925
|
+
* fire-and-forget and MUST NOT break the domain flow that triggered it.
|
|
926
|
+
*/
|
|
927
|
+
track(event: AnalyticsEvent, ctx: DispatchContext): Promise<void>;
|
|
928
|
+
/**
|
|
929
|
+
* Optional readiness probe. Availability = enabled AND isConfigured.
|
|
930
|
+
* @compat When omitted, the host assumes the adapter is ready.
|
|
931
|
+
*/
|
|
932
|
+
isConfigured?(ctx: DispatchContext): boolean;
|
|
933
|
+
}
|
|
934
|
+
|
|
834
935
|
/** A named unit of behaviour a plugin exposes to the host registry. */
|
|
835
936
|
interface Capability<T = unknown> {
|
|
836
937
|
kind: string;
|
|
@@ -852,6 +953,7 @@ declare function capability<T>(kind: string, impl: T): Capability<T>;
|
|
|
852
953
|
declare function paymentCapability(impl: IPaymentPlugin): Capability<IPaymentPlugin>;
|
|
853
954
|
declare function shippingCapability(impl: IShippingPlugin): Capability<IShippingPlugin>;
|
|
854
955
|
declare function suppliersCapability(impl: ISuppliersPlugin): Capability<ISuppliersPlugin>;
|
|
956
|
+
declare function analyticsCapability(impl: IAnalyticsPlugin): Capability<IAnalyticsPlugin>;
|
|
855
957
|
/**
|
|
856
958
|
* A constructed plugin. `capabilities` is the static declaration the host reads
|
|
857
959
|
* up front; `onActivate` runs when the host mounts the plugin for a tenant and
|
|
@@ -989,7 +1091,7 @@ declare function checkPermissions(required: string[], grantedRaw: string[]): Per
|
|
|
989
1091
|
* - MINOR: additive (new optional fields, new tokens) — backwards compatible.
|
|
990
1092
|
* - PATCH: docs/fixes with zero shape changes.
|
|
991
1093
|
*/
|
|
992
|
-
declare const SDK_VERSION = "0.
|
|
1094
|
+
declare const SDK_VERSION = "0.6.1";
|
|
993
1095
|
/**
|
|
994
1096
|
* True when a plugin built against `pluginSdkVersion` can run on a host that
|
|
995
1097
|
* ships `hostSdkVersion`. Rule: same major, host minor >= plugin minor.
|
|
@@ -998,4 +1100,4 @@ declare const SDK_VERSION = "0.5.2";
|
|
|
998
1100
|
*/
|
|
999
1101
|
declare function isSdkCompatible(pluginSdkVersion: string, hostSdkVersion: string): boolean;
|
|
1000
1102
|
|
|
1001
|
-
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 };
|
|
1103
|
+
export { ANALYTICS_PLUGIN_TOKEN, type AccordionBlock, type AccordionSection, type ActionBlock, ActionVariant, type AnalyticsEvent, type AnalyticsEventName, AnalyticsFeature, type AnalyticsItem, type AnalyticsMoney, type AnalyticsPluginConfig, type AnalyticsStaticConfig, 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 IAnalyticsPlugin, 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, analyticsCapability, capability, checkPermissions, createPluginConfig, crossValidateSetupLayout, definePlugin, field, isConfigurablePlugin, isPermissionGranted, isPluginFactory, isSdkCompatible, parsePermission, paymentCapability, shippingCapability, suppliersCapability, validateSetupLayout };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
declare const PAYMENT_PLUGIN_TOKEN: "PAYMENT_PLUGINS";
|
|
2
2
|
declare const SHIPPING_PLUGIN_TOKEN: "SHIPPING_PLUGINS";
|
|
3
3
|
declare const SUPPLIERS_PLUGIN_TOKEN: "SUPPLIERS_PLUGINS";
|
|
4
|
+
declare const ANALYTICS_PLUGIN_TOKEN: "ANALYTICS_PLUGINS";
|
|
4
5
|
|
|
5
6
|
declare enum FieldType {
|
|
6
7
|
String = "string",
|
|
@@ -754,9 +755,20 @@ interface SupplierOrderAddressLevel {
|
|
|
754
755
|
interface SupplierShipTo {
|
|
755
756
|
address: string;
|
|
756
757
|
referencePoint?: string | null;
|
|
757
|
-
/**
|
|
758
|
-
|
|
759
|
-
|
|
758
|
+
/**
|
|
759
|
+
* Supplier-native geo ids. Optional: when the host cannot produce the
|
|
760
|
+
* supplier's own ids (the common case — the host only knows its own geo),
|
|
761
|
+
* it leaves these empty and passes the human-readable names below. The
|
|
762
|
+
* plugin resolves names → supplier ids against its own geo endpoints.
|
|
763
|
+
*/
|
|
764
|
+
stateId?: string;
|
|
765
|
+
cityId?: string;
|
|
766
|
+
/** ISO 3166-1 alpha-2 of the destination country (e.g. "GT", "SV"). */
|
|
767
|
+
countryCode?: string;
|
|
768
|
+
/** Human-readable admin-area (state/department) name for plugin-side resolution. */
|
|
769
|
+
stateName?: string;
|
|
770
|
+
/** Human-readable locality (city/municipality) name for plugin-side resolution. */
|
|
771
|
+
cityName?: string;
|
|
760
772
|
extraLevels?: SupplierOrderAddressLevel[];
|
|
761
773
|
latitude?: number;
|
|
762
774
|
longitude?: number;
|
|
@@ -826,11 +838,100 @@ interface ISuppliersPlugin extends IPlugin {
|
|
|
826
838
|
getListing(externalId: string, ctx: DispatchContext): Promise<SupplierListing>;
|
|
827
839
|
placeOrder(order: PlaceSupplierOrderInput, ctx: DispatchContext): Promise<SupplierOrderResult>;
|
|
828
840
|
getOrderStatus(externalOrderId: string, ctx: DispatchContext): Promise<SupplierOrderResult>;
|
|
841
|
+
cancelOrder?(externalOrderId: string, ctx: DispatchContext): Promise<SupplierOrderResult>;
|
|
829
842
|
syncStock?(externalIds: string[], ctx: DispatchContext): Promise<SupplierStock[]>;
|
|
830
843
|
parseWebhook?(body: unknown, headers: Record<string, string>, ctx: DispatchContext): SupplierFulfillmentEvent | null;
|
|
831
844
|
isConfigured?(ctx: DispatchContext): boolean;
|
|
832
845
|
}
|
|
833
846
|
|
|
847
|
+
declare enum AnalyticsFeature {
|
|
848
|
+
/** Ecommerce funnel events: view_item, add_to_cart, begin_checkout, purchase. */
|
|
849
|
+
Ecommerce = "ecommerce",
|
|
850
|
+
/** Generic page_view tracking. */
|
|
851
|
+
PageViews = "page-views"
|
|
852
|
+
}
|
|
853
|
+
/**
|
|
854
|
+
* ISO-4217 money in minor units — mirrors the store's Money VO so the host maps
|
|
855
|
+
* 1:1 without a currency guess. Kept local so the SDK stays dependency-free.
|
|
856
|
+
*/
|
|
857
|
+
interface AnalyticsMoney {
|
|
858
|
+
amountMinor: number;
|
|
859
|
+
currency: string;
|
|
860
|
+
}
|
|
861
|
+
/** A single line item attached to an ecommerce event. */
|
|
862
|
+
interface AnalyticsItem {
|
|
863
|
+
/** Product or variant id as the store knows it. */
|
|
864
|
+
id: string;
|
|
865
|
+
name?: string;
|
|
866
|
+
sku?: string | null;
|
|
867
|
+
quantity?: number;
|
|
868
|
+
price?: AnalyticsMoney;
|
|
869
|
+
category?: string | null;
|
|
870
|
+
}
|
|
871
|
+
/**
|
|
872
|
+
* Canonical, provider-agnostic event names the host emits. Closed set: the host
|
|
873
|
+
* only ever maps a domain event to one of these. An adapter that does not care
|
|
874
|
+
* about a given name simply ignores it.
|
|
875
|
+
*/
|
|
876
|
+
type AnalyticsEventName = 'page_view' | 'view_item' | 'add_to_cart' | 'remove_from_cart' | 'begin_checkout' | 'purchase';
|
|
877
|
+
/**
|
|
878
|
+
* Normalized analytics event. The host builds this from a DomainEvent and hands
|
|
879
|
+
* it to every active analytics adapter. The adapter translates it to its own
|
|
880
|
+
* wire format (GA4 event, Meta event, ...).
|
|
881
|
+
*/
|
|
882
|
+
interface AnalyticsEvent {
|
|
883
|
+
name: AnalyticsEventName;
|
|
884
|
+
/** ISO-8601 instant the underlying action happened. */
|
|
885
|
+
occurredAt: string;
|
|
886
|
+
/**
|
|
887
|
+
* Pseudonymous client identity for sessionization (maps to GA4 `client_id`
|
|
888
|
+
* / Meta `external_id`). Null when the host cannot resolve a stable id.
|
|
889
|
+
*/
|
|
890
|
+
clientId?: string | null;
|
|
891
|
+
sessionId?: string | null;
|
|
892
|
+
/** Monetary value for value-bearing events (purchase, begin_checkout). */
|
|
893
|
+
value?: AnalyticsMoney | null;
|
|
894
|
+
/** Order id for `purchase` — providers dedupe transactions on it. */
|
|
895
|
+
transactionId?: string | null;
|
|
896
|
+
items?: AnalyticsItem[];
|
|
897
|
+
/** Page context for `page_view`. */
|
|
898
|
+
pageLocation?: string | null;
|
|
899
|
+
pageTitle?: string | null;
|
|
900
|
+
/** Extra params forwarded verbatim as custom dimensions. */
|
|
901
|
+
params?: Record<string, unknown>;
|
|
902
|
+
}
|
|
903
|
+
interface AnalyticsPluginConfig {
|
|
904
|
+
supportedCapabilities: AnalyticsFeature[];
|
|
905
|
+
configSchema: PluginConfigField[];
|
|
906
|
+
/** GLOBAL-scope defaults merged under the tenant DB config by the host. */
|
|
907
|
+
defaultConfig?: Record<string, unknown>;
|
|
908
|
+
}
|
|
909
|
+
interface AnalyticsStaticConfig {
|
|
910
|
+
code: string;
|
|
911
|
+
displayName: string;
|
|
912
|
+
description: string;
|
|
913
|
+
iconUrl?: string;
|
|
914
|
+
supportedCapabilities: AnalyticsFeature[];
|
|
915
|
+
configSchema: PluginConfigField[];
|
|
916
|
+
}
|
|
917
|
+
interface IAnalyticsPlugin extends IPlugin {
|
|
918
|
+
readonly name: string;
|
|
919
|
+
readonly analyticsConfig: AnalyticsPluginConfig;
|
|
920
|
+
/**
|
|
921
|
+
* Forward one canonical event to the provider's ingestion API. Stateless: the
|
|
922
|
+
* tenant's resolved credentials arrive in `ctx.config` on every call.
|
|
923
|
+
*
|
|
924
|
+
* @rule BEST-EFFORT — never throw on a transport/provider error. Analytics is
|
|
925
|
+
* fire-and-forget and MUST NOT break the domain flow that triggered it.
|
|
926
|
+
*/
|
|
927
|
+
track(event: AnalyticsEvent, ctx: DispatchContext): Promise<void>;
|
|
928
|
+
/**
|
|
929
|
+
* Optional readiness probe. Availability = enabled AND isConfigured.
|
|
930
|
+
* @compat When omitted, the host assumes the adapter is ready.
|
|
931
|
+
*/
|
|
932
|
+
isConfigured?(ctx: DispatchContext): boolean;
|
|
933
|
+
}
|
|
934
|
+
|
|
834
935
|
/** A named unit of behaviour a plugin exposes to the host registry. */
|
|
835
936
|
interface Capability<T = unknown> {
|
|
836
937
|
kind: string;
|
|
@@ -852,6 +953,7 @@ declare function capability<T>(kind: string, impl: T): Capability<T>;
|
|
|
852
953
|
declare function paymentCapability(impl: IPaymentPlugin): Capability<IPaymentPlugin>;
|
|
853
954
|
declare function shippingCapability(impl: IShippingPlugin): Capability<IShippingPlugin>;
|
|
854
955
|
declare function suppliersCapability(impl: ISuppliersPlugin): Capability<ISuppliersPlugin>;
|
|
956
|
+
declare function analyticsCapability(impl: IAnalyticsPlugin): Capability<IAnalyticsPlugin>;
|
|
855
957
|
/**
|
|
856
958
|
* A constructed plugin. `capabilities` is the static declaration the host reads
|
|
857
959
|
* up front; `onActivate` runs when the host mounts the plugin for a tenant and
|
|
@@ -989,7 +1091,7 @@ declare function checkPermissions(required: string[], grantedRaw: string[]): Per
|
|
|
989
1091
|
* - MINOR: additive (new optional fields, new tokens) — backwards compatible.
|
|
990
1092
|
* - PATCH: docs/fixes with zero shape changes.
|
|
991
1093
|
*/
|
|
992
|
-
declare const SDK_VERSION = "0.
|
|
1094
|
+
declare const SDK_VERSION = "0.6.1";
|
|
993
1095
|
/**
|
|
994
1096
|
* True when a plugin built against `pluginSdkVersion` can run on a host that
|
|
995
1097
|
* ships `hostSdkVersion`. Rule: same major, host minor >= plugin minor.
|
|
@@ -998,4 +1100,4 @@ declare const SDK_VERSION = "0.5.2";
|
|
|
998
1100
|
*/
|
|
999
1101
|
declare function isSdkCompatible(pluginSdkVersion: string, hostSdkVersion: string): boolean;
|
|
1000
1102
|
|
|
1001
|
-
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 };
|
|
1103
|
+
export { ANALYTICS_PLUGIN_TOKEN, type AccordionBlock, type AccordionSection, type ActionBlock, ActionVariant, type AnalyticsEvent, type AnalyticsEventName, AnalyticsFeature, type AnalyticsItem, type AnalyticsMoney, type AnalyticsPluginConfig, type AnalyticsStaticConfig, 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 IAnalyticsPlugin, 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, analyticsCapability, capability, checkPermissions, createPluginConfig, crossValidateSetupLayout, definePlugin, field, isConfigurablePlugin, isPermissionGranted, isPluginFactory, isSdkCompatible, parsePermission, paymentCapability, shippingCapability, suppliersCapability, validateSetupLayout };
|
package/dist/index.js
CHANGED
|
@@ -20,7 +20,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
+
ANALYTICS_PLUGIN_TOKEN: () => ANALYTICS_PLUGIN_TOKEN,
|
|
23
24
|
ActionVariant: () => ActionVariant,
|
|
25
|
+
AnalyticsFeature: () => AnalyticsFeature,
|
|
24
26
|
BlockType: () => BlockType,
|
|
25
27
|
CapabilityKind: () => CapabilityKind,
|
|
26
28
|
CodFeeType: () => CodFeeType,
|
|
@@ -40,6 +42,7 @@ __export(index_exports, {
|
|
|
40
42
|
StepStatusFrom: () => StepStatusFrom,
|
|
41
43
|
SuppliersFeature: () => SuppliersFeature,
|
|
42
44
|
TransactionStatus: () => TransactionStatus,
|
|
45
|
+
analyticsCapability: () => analyticsCapability,
|
|
43
46
|
capability: () => capability,
|
|
44
47
|
checkPermissions: () => checkPermissions,
|
|
45
48
|
createPluginConfig: () => createPluginConfig,
|
|
@@ -62,6 +65,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
62
65
|
var PAYMENT_PLUGIN_TOKEN = "PAYMENT_PLUGINS";
|
|
63
66
|
var SHIPPING_PLUGIN_TOKEN = "SHIPPING_PLUGINS";
|
|
64
67
|
var SUPPLIERS_PLUGIN_TOKEN = "SUPPLIERS_PLUGINS";
|
|
68
|
+
var ANALYTICS_PLUGIN_TOKEN = "ANALYTICS_PLUGINS";
|
|
65
69
|
|
|
66
70
|
// src/plugin.ts
|
|
67
71
|
var PluginType = /* @__PURE__ */ ((PluginType2) => {
|
|
@@ -200,6 +204,13 @@ var SuppliersFeature = /* @__PURE__ */ ((SuppliersFeature2) => {
|
|
|
200
204
|
return SuppliersFeature2;
|
|
201
205
|
})(SuppliersFeature || {});
|
|
202
206
|
|
|
207
|
+
// src/analytics.ts
|
|
208
|
+
var AnalyticsFeature = /* @__PURE__ */ ((AnalyticsFeature2) => {
|
|
209
|
+
AnalyticsFeature2["Ecommerce"] = "ecommerce";
|
|
210
|
+
AnalyticsFeature2["PageViews"] = "page-views";
|
|
211
|
+
return AnalyticsFeature2;
|
|
212
|
+
})(AnalyticsFeature || {});
|
|
213
|
+
|
|
203
214
|
// src/setup-layout.ts
|
|
204
215
|
var import_superstruct2 = require("superstruct");
|
|
205
216
|
var FieldVariant = /* @__PURE__ */ ((FieldVariant2) => {
|
|
@@ -485,6 +496,9 @@ function shippingCapability(impl) {
|
|
|
485
496
|
function suppliersCapability(impl) {
|
|
486
497
|
return { kind: CapabilityKind.Suppliers, impl };
|
|
487
498
|
}
|
|
499
|
+
function analyticsCapability(impl) {
|
|
500
|
+
return { kind: CapabilityKind.Analytics, impl };
|
|
501
|
+
}
|
|
488
502
|
var PLUGIN_FACTORY_BRAND = /* @__PURE__ */ Symbol.for("vivoa.plugin.factory");
|
|
489
503
|
function definePlugin(factory) {
|
|
490
504
|
Object.defineProperty(factory, PLUGIN_FACTORY_BRAND, {
|
|
@@ -530,7 +544,7 @@ function checkPermissions(required, grantedRaw) {
|
|
|
530
544
|
}
|
|
531
545
|
|
|
532
546
|
// src/version.ts
|
|
533
|
-
var SDK_VERSION = "0.
|
|
547
|
+
var SDK_VERSION = "0.6.1";
|
|
534
548
|
function isSdkCompatible(pluginSdkVersion, hostSdkVersion) {
|
|
535
549
|
const parse = (v) => {
|
|
536
550
|
const m = /^(\d+)\.(\d+)\.(\d+)/.exec(v);
|
|
@@ -547,7 +561,9 @@ function isSdkCompatible(pluginSdkVersion, hostSdkVersion) {
|
|
|
547
561
|
}
|
|
548
562
|
// Annotate the CommonJS export names for ESM import in node:
|
|
549
563
|
0 && (module.exports = {
|
|
564
|
+
ANALYTICS_PLUGIN_TOKEN,
|
|
550
565
|
ActionVariant,
|
|
566
|
+
AnalyticsFeature,
|
|
551
567
|
BlockType,
|
|
552
568
|
CapabilityKind,
|
|
553
569
|
CodFeeType,
|
|
@@ -567,6 +583,7 @@ function isSdkCompatible(pluginSdkVersion, hostSdkVersion) {
|
|
|
567
583
|
StepStatusFrom,
|
|
568
584
|
SuppliersFeature,
|
|
569
585
|
TransactionStatus,
|
|
586
|
+
analyticsCapability,
|
|
570
587
|
capability,
|
|
571
588
|
checkPermissions,
|
|
572
589
|
createPluginConfig,
|
package/dist/index.mjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
var PAYMENT_PLUGIN_TOKEN = "PAYMENT_PLUGINS";
|
|
3
3
|
var SHIPPING_PLUGIN_TOKEN = "SHIPPING_PLUGINS";
|
|
4
4
|
var SUPPLIERS_PLUGIN_TOKEN = "SUPPLIERS_PLUGINS";
|
|
5
|
+
var ANALYTICS_PLUGIN_TOKEN = "ANALYTICS_PLUGINS";
|
|
5
6
|
|
|
6
7
|
// src/plugin.ts
|
|
7
8
|
var PluginType = /* @__PURE__ */ ((PluginType2) => {
|
|
@@ -148,6 +149,13 @@ var SuppliersFeature = /* @__PURE__ */ ((SuppliersFeature2) => {
|
|
|
148
149
|
return SuppliersFeature2;
|
|
149
150
|
})(SuppliersFeature || {});
|
|
150
151
|
|
|
152
|
+
// src/analytics.ts
|
|
153
|
+
var AnalyticsFeature = /* @__PURE__ */ ((AnalyticsFeature2) => {
|
|
154
|
+
AnalyticsFeature2["Ecommerce"] = "ecommerce";
|
|
155
|
+
AnalyticsFeature2["PageViews"] = "page-views";
|
|
156
|
+
return AnalyticsFeature2;
|
|
157
|
+
})(AnalyticsFeature || {});
|
|
158
|
+
|
|
151
159
|
// src/setup-layout.ts
|
|
152
160
|
import {
|
|
153
161
|
array,
|
|
@@ -446,6 +454,9 @@ function shippingCapability(impl) {
|
|
|
446
454
|
function suppliersCapability(impl) {
|
|
447
455
|
return { kind: CapabilityKind.Suppliers, impl };
|
|
448
456
|
}
|
|
457
|
+
function analyticsCapability(impl) {
|
|
458
|
+
return { kind: CapabilityKind.Analytics, impl };
|
|
459
|
+
}
|
|
449
460
|
var PLUGIN_FACTORY_BRAND = /* @__PURE__ */ Symbol.for("vivoa.plugin.factory");
|
|
450
461
|
function definePlugin(factory) {
|
|
451
462
|
Object.defineProperty(factory, PLUGIN_FACTORY_BRAND, {
|
|
@@ -491,7 +502,7 @@ function checkPermissions(required, grantedRaw) {
|
|
|
491
502
|
}
|
|
492
503
|
|
|
493
504
|
// src/version.ts
|
|
494
|
-
var SDK_VERSION = "0.
|
|
505
|
+
var SDK_VERSION = "0.6.1";
|
|
495
506
|
function isSdkCompatible(pluginSdkVersion, hostSdkVersion) {
|
|
496
507
|
const parse = (v) => {
|
|
497
508
|
const m = /^(\d+)\.(\d+)\.(\d+)/.exec(v);
|
|
@@ -507,7 +518,9 @@ function isSdkCompatible(pluginSdkVersion, hostSdkVersion) {
|
|
|
507
518
|
return h[1] > p[1] || h[1] === p[1] && h[2] >= p[2];
|
|
508
519
|
}
|
|
509
520
|
export {
|
|
521
|
+
ANALYTICS_PLUGIN_TOKEN,
|
|
510
522
|
ActionVariant,
|
|
523
|
+
AnalyticsFeature,
|
|
511
524
|
BlockType,
|
|
512
525
|
CapabilityKind,
|
|
513
526
|
CodFeeType,
|
|
@@ -527,6 +540,7 @@ export {
|
|
|
527
540
|
StepStatusFrom,
|
|
528
541
|
SuppliersFeature,
|
|
529
542
|
TransactionStatus,
|
|
543
|
+
analyticsCapability,
|
|
530
544
|
capability,
|
|
531
545
|
checkPermissions,
|
|
532
546
|
createPluginConfig,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vivoa/plugin-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "Public contracts for Vivoa plugins (types, DI tokens, config + setup-layout validators)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Vivoa",
|
|
@@ -34,14 +34,6 @@
|
|
|
34
34
|
"registry": "https://registry.npmjs.org",
|
|
35
35
|
"access": "public"
|
|
36
36
|
},
|
|
37
|
-
"scripts": {
|
|
38
|
-
"build": "tsup src/index.ts --format cjs,esm --dts --clean --target node18",
|
|
39
|
-
"dev": "tsup src/index.ts --format cjs,esm --dts --watch --target node18",
|
|
40
|
-
"test": "vitest run",
|
|
41
|
-
"test:watch": "vitest",
|
|
42
|
-
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
43
|
-
"prepublishOnly": "pnpm run typecheck && pnpm run test && pnpm run build"
|
|
44
|
-
},
|
|
45
37
|
"dependencies": {
|
|
46
38
|
"superstruct": "^2.0.2"
|
|
47
39
|
},
|
|
@@ -51,9 +43,11 @@
|
|
|
51
43
|
"typescript": "^5.7.3",
|
|
52
44
|
"vitest": "^2.1.8"
|
|
53
45
|
},
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
|
|
57
|
-
|
|
46
|
+
"scripts": {
|
|
47
|
+
"build": "tsup src/index.ts --format cjs,esm --dts --clean --target node18",
|
|
48
|
+
"dev": "tsup src/index.ts --format cjs,esm --dts --watch --target node18",
|
|
49
|
+
"test": "vitest run",
|
|
50
|
+
"test:watch": "vitest",
|
|
51
|
+
"typecheck": "tsc --noEmit -p tsconfig.json"
|
|
58
52
|
}
|
|
59
|
-
}
|
|
53
|
+
}
|