@stackable-labs/sdk-extension-contracts 1.64.0 → 1.66.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -325,9 +325,28 @@ declare const ALLOWED_ICONS: readonly ["arrow-left", "calendar", "check-circle-2
325
325
  type AllowedIconName = (typeof ALLOWED_ICONS)[number];
326
326
 
327
327
  /**
328
- * Identity Contract
329
- * Types for the identity/auth event system.
328
+ * Messaging Contract
329
+ * Types for the messaging event system (postback buttons, etc.).
330
330
  */
331
+ /** Messaging event subscription types — 'postback' for all, 'postback:<actionName>' for specific */
332
+ type MessagingEventType = 'postback' | `postback:${string}`;
333
+ /** Normalized postback event payload */
334
+ interface MessagingPostbackEvent {
335
+ type: 'postback';
336
+ actionName: string;
337
+ conversationId: string;
338
+ timestamp: string;
339
+ }
340
+ /** Union of all messaging events (extensible for future event types) */
341
+ type MessagingEvent = MessagingPostbackEvent;
342
+ /** Handler type for useMessagingEvent — use with useCallback for memoized handlers */
343
+ type MessagingEventHandler = (event: MessagingEvent) => void;
344
+
345
+ /**
346
+ * Identity & Event Contract
347
+ * Types for the identity/auth event system and cross-domain event declarations.
348
+ */
349
+
331
350
  type IdentityEventType = 'identity.login' | 'identity.logout' | 'identity.refresh' | 'identity.expired';
332
351
  interface UserIdentity {
333
352
  id: string;
@@ -347,6 +366,12 @@ interface IdentityEvent {
347
366
  state: IdentityState;
348
367
  timestamp: string;
349
368
  }
369
+ /**
370
+ * Union of all event types that can appear in the manifest events array.
371
+ * Grows as new event domains are added.
372
+ * Includes domain wildcards (e.g. 'identity' matches all identity.* events).
373
+ */
374
+ type EventType = IdentityEventType | 'identity' | MessagingEventType | 'messaging';
350
375
  /** Base claims sent to extend:identity handlers before JWT signing */
351
376
  interface IdentityBaseClaims {
352
377
  external_id: string;
@@ -354,6 +379,8 @@ interface IdentityBaseClaims {
354
379
  name?: string;
355
380
  [key: string]: unknown;
356
381
  }
382
+ /** Handler type for useExtendIdentity — use with useCallback for memoized handlers */
383
+ type ExtendIdentityHandler = (claims: IdentityBaseClaims) => Record<string, unknown> | Promise<Record<string, unknown>>;
357
384
 
358
385
  /**
359
386
  * Capabilities Contract
@@ -469,7 +496,7 @@ interface InstanceOption {
469
496
  * Extensions declare required permissions in their manifest.
470
497
  * Host enforces: capability calls must be a subset of granted permissions.
471
498
  */
472
- declare const PERMISSIONS: readonly ["context:read", "data:query", "data:fetch", "actions:toast", "actions:invoke", "events:identity", "extend:identity"];
499
+ declare const PERMISSIONS: readonly ["context:read", "data:query", "data:fetch", "actions:toast", "actions:invoke", "events:identity", "events:messaging", "extend:identity"];
473
500
  type Permission = (typeof PERMISSIONS)[number];
474
501
  /**
475
502
  * Maps capability types to the permission required to use them.
@@ -496,7 +523,7 @@ interface ExtensionManifest {
496
523
  /** Permissions required by this extension */
497
524
  permissions: Permission[];
498
525
  /** Specific events this extension listens for (e.g. ["identity.login", "postback:add_to_cart"]) */
499
- events?: string[];
526
+ events?: EventType[];
500
527
  /**
501
528
  * Hostnames this extension is permitted to reach via data.fetch.
502
529
  * Example: ["api.myservice.com", "cdn.myservice.com"]
@@ -838,4 +865,4 @@ interface Order {
838
865
  display_status?: OrderStatus;
839
866
  }
840
867
 
841
- export { ALLOWED_ICONS, type ActionInvokePayload, type Address, type AllowedIconName, type ApiError, type ApiRequest, type ApiResponse, CAPABILITY_PERMISSION_MAP, type CapabilityCall, type CapabilityRequest, type CapabilityResponse, type CapabilityType, type ContextData, type Customer, type DataField, type DataFieldType, type EncryptedPayload, type ExtendIdentityRequest, type ExtendIdentityResponse, type ExtensionManifest, type ExtensionRegistryEntry, type FetchRequest, type FetchRequestInit, type FetchResponse, type HostToSandboxMessage, type IdentityBaseClaims, type IdentityEvent, type IdentityEventType, type IdentityState, type InstanceConfig, type InstanceOption, type InvokeAction, type MarketplaceExtension, type MessengerCommand, type NamedEntity, type Order, type OrderAction, type OrderItem, type OrderStatus, type OrderStatuses, PERMISSIONS, type Permission, type Price, type SandboxToHostMessage, type Shipment, type SurfaceContext, type SurfaceLifecycleMessage, type Target, type Theme, type ToastPayload, type UITag, type UITagCategory, UI_TAGS, UI_TAG_ATTRIBUTES, UI_TAG_ATTRIBUTE_VALUES, UI_TAG_CATEGORIES, UI_TAG_CHILDREN, UI_TAG_DEFINITIONS, type UserIdentity, type WidgetAction, tagToComponentName };
868
+ export { ALLOWED_ICONS, type ActionInvokePayload, type Address, type AllowedIconName, type ApiError, type ApiRequest, type ApiResponse, CAPABILITY_PERMISSION_MAP, type CapabilityCall, type CapabilityRequest, type CapabilityResponse, type CapabilityType, type ContextData, type Customer, type DataField, type DataFieldType, type EncryptedPayload, type EventType, type ExtendIdentityHandler, type ExtendIdentityRequest, type ExtendIdentityResponse, type ExtensionManifest, type ExtensionRegistryEntry, type FetchRequest, type FetchRequestInit, type FetchResponse, type HostToSandboxMessage, type IdentityBaseClaims, type IdentityEvent, type IdentityEventType, type IdentityState, type InstanceConfig, type InstanceOption, type InvokeAction, type MarketplaceExtension, type MessagingEvent, type MessagingEventHandler, type MessagingEventType, type MessagingPostbackEvent, type MessengerCommand, type NamedEntity, type Order, type OrderAction, type OrderItem, type OrderStatus, type OrderStatuses, PERMISSIONS, type Permission, type Price, type SandboxToHostMessage, type Shipment, type SurfaceContext, type SurfaceLifecycleMessage, type Target, type Theme, type ToastPayload, type UITag, type UITagCategory, UI_TAGS, UI_TAG_ATTRIBUTES, UI_TAG_ATTRIBUTE_VALUES, UI_TAG_CATEGORIES, UI_TAG_CHILDREN, UI_TAG_DEFINITIONS, type UserIdentity, type WidgetAction, tagToComponentName };
package/dist/index.js CHANGED
@@ -308,6 +308,7 @@ var PERMISSIONS = [
308
308
  "actions:toast",
309
309
  "actions:invoke",
310
310
  "events:identity",
311
+ "events:messaging",
311
312
  "extend:identity"
312
313
  ];
313
314
  var CAPABILITY_PERMISSION_MAP = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackable-labs/sdk-extension-contracts",
3
- "version": "1.64.0",
3
+ "version": "1.66.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",