@stackable-labs/sdk-extension-contracts 1.70.0 → 1.72.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
@@ -1,5 +1,5 @@
1
1
  import { ISOTimestamp, MarketplaceMetadata } from '@stackable-labs/lib-contracts';
2
- export { AppRegistryEntry, EXTENSION_CATEGORIES, EXTENSION_VISIBILITIES, ExtensionCategory, ExtensionVisibility, ISOTimestamp, MarketplaceMetadata, asISOTimestamp } from '@stackable-labs/lib-contracts';
2
+ export { AppRegistryEntry, ClerkOrgId, ClerkUserId, EXTENSION_CATEGORIES, EXTENSION_VISIBILITIES, ExtensionCategory, ExtensionVisibility, ISOTimestamp, MarketplaceMetadata, asClerkOrgId, asClerkUserId, asISOTimestamp } from '@stackable-labs/lib-contracts';
3
3
 
4
4
  /**
5
5
  * Shared primitive types used across contracts.
@@ -325,31 +325,13 @@ declare const tagToComponentName: (tag: UITag) => string;
325
325
  declare const ALLOWED_ICONS: readonly ["arrow-left", "calendar", "check-circle-2", "chevron-left", "chevron-right", "clock", "credit-card", "external-link", "help-circle", "info", "loader-2", "mail", "map-pin", "message-circle", "message-square", "package", "phone", "search", "shopping-bag", "sparkles", "truck", "user", "x-circle", "alert-circle", "book-open"];
326
326
  type AllowedIconName = (typeof ALLOWED_ICONS)[number];
327
327
 
328
- /**
329
- * Messaging Contract
330
- * Types for the messaging event system (postback buttons, etc.).
331
- */
332
-
333
- /** Messaging event subscription types — 'postback' for all, 'postback:<actionName>' for specific */
334
- type MessagingEventType = 'postback' | `postback:${string}`;
335
- /** Normalized postback event payload */
336
- interface MessagingPostbackEvent {
337
- type: 'postback';
338
- actionName: string;
339
- conversationId: string;
340
- timestamp: ISOTimestamp;
341
- }
342
- /** Union of all messaging events (extensible for future event types) */
343
- type MessagingEvent = MessagingPostbackEvent;
344
- /** Handler type for useMessagingEvent — use with useCallback for memoized handlers */
345
- type MessagingEventHandler = (event: MessagingEvent) => void;
346
-
347
328
  /**
348
329
  * Identity & Event Contract
349
- * Types for the identity/auth event system and cross-domain event declarations.
330
+ * Types for the identity/auth event system.
350
331
  */
351
332
 
352
- type IdentityEventType = 'identity.login' | 'identity.logout' | 'identity.refresh' | 'identity.expired';
333
+ /** Domain-stripped identity event names. Hooks accept these directly (e.g., useIdentityEvent('login', ...)). */
334
+ type IdentityEventType = 'login' | 'logout' | 'refresh' | 'expired';
353
335
  interface UserIdentity {
354
336
  id: string;
355
337
  email?: string;
@@ -364,16 +346,12 @@ interface IdentityState {
364
346
  expiresAt?: ISOTimestamp;
365
347
  }
366
348
  interface IdentityEvent {
367
- type: IdentityEventType;
368
- state: IdentityState;
369
- timestamp: ISOTimestamp;
349
+ eventName: IdentityEventType;
350
+ data: {
351
+ state: IdentityState;
352
+ timestamp: ISOTimestamp;
353
+ };
370
354
  }
371
- /**
372
- * Union of all event types that can appear in the manifest events array.
373
- * Grows as new event domains are added.
374
- * Includes domain wildcards (e.g. 'identity' matches all identity.* events).
375
- */
376
- type EventType = IdentityEventType | 'identity' | MessagingEventType | 'messaging';
377
355
  /** Base claims sent to extend:identity handlers before JWT signing */
378
356
  interface IdentityBaseClaims {
379
357
  external_id: string;
@@ -483,6 +461,68 @@ type CapabilityCall = {
483
461
  };
484
462
  type CapabilityType = CapabilityCall['type'];
485
463
 
464
+ /**
465
+ * Messaging Contract
466
+ * Types for the messaging event system (postback buttons, etc.).
467
+ */
468
+
469
+ /** Messaging event subscription types — 'postback' for all, 'postback:<actionName>' for specific */
470
+ type MessagingEventType = 'postback' | `postback:${string}`;
471
+ /** Normalized postback event payload */
472
+ interface MessagingPostbackEvent {
473
+ eventName: 'postback';
474
+ data: {
475
+ /**
476
+ * The postback button's display text (Zendesk-specific).
477
+ * NOTE: This is NOT an event system field — `eventType` and `eventName` are our event system
478
+ * conventions. `actionName` is a domain-specific payload field identifying which button was
479
+ * clicked, and lives inside `data` alongside other Zendesk messaging fields.
480
+ */
481
+ actionName: string;
482
+ conversationId: string;
483
+ timestamp: ISOTimestamp;
484
+ };
485
+ }
486
+ /** Union of all messaging events (extensible for future event types) */
487
+ type MessagingEvent = MessagingPostbackEvent;
488
+ /** Handler type for useMessagingEvent — use with useCallback for memoized handlers */
489
+ type MessagingEventHandler = (event: MessagingEvent) => void;
490
+
491
+ /**
492
+ * Activity Event Contract
493
+ * Types for the activity event system (host-to-extension push events).
494
+ */
495
+ /** Well-known activity event names (aligned with GA conventions). Hosts can emit any custom string. */
496
+ type WellKnownActivityEvent = 'page_view' | 'click' | 'product_view' | 'add_to_cart' | 'purchase' | 'search' | 'form_submit';
497
+ /** Domain-stripped activity event names. Hooks accept these directly (e.g., useActivityEvent('product_view', ...)). */
498
+ type ActivityEventType = WellKnownActivityEvent | string;
499
+ /** Normalized activity event payload */
500
+ interface ActivityEvent {
501
+ eventName: ActivityEventType;
502
+ data: Record<string, unknown>;
503
+ }
504
+ /** Handler type for useActivityEvent — use with useCallback for memoized handlers */
505
+ type ActivityEventHandler = (event: ActivityEvent) => void;
506
+
507
+ /**
508
+ * Unified Event Type
509
+ * Shared union across all event domains. Used in manifest `events` array and the generic `useEvent` hook.
510
+ * Domain-specific hooks accept the un-prefixed types (e.g., 'login' not 'identity:login').
511
+ */
512
+
513
+ /** Known event domains. Used by window.stackable.emit() and broadcast routing. */
514
+ type EventDomain = 'activity' | 'identity' | 'messaging';
515
+ /** Domain-specific event type mapping. Maps each domain to its event name union. */
516
+ type EventTypeMap = {
517
+ activity: ActivityEventType;
518
+ identity: IdentityEventType;
519
+ messaging: MessagingEventType;
520
+ };
521
+ /** Fully-qualified event type: domain wildcard or domain:eventName. Used in manifest `events` array and `useEvent` hook. */
522
+ type EventType = EventDomain | {
523
+ [D in EventDomain]: `${D}:${EventTypeMap[D]}`;
524
+ }[EventDomain];
525
+
486
526
  /**
487
527
  * Instance Contract
488
528
  * Shared types for extension instances used by both host and admin.
@@ -509,7 +549,7 @@ interface InstanceOption {
509
549
  * Extensions declare required permissions in their manifest.
510
550
  * Host enforces: capability calls must be a subset of granted permissions.
511
551
  */
512
- declare const PERMISSIONS: readonly ["context:read", "data:query", "data:fetch", "actions:toast", "actions:invoke", "events:identity", "events:messaging", "extend:identity"];
552
+ declare const PERMISSIONS: readonly ["context:read", "data:query", "data:fetch", "actions:toast", "actions:invoke", "events:identity", "events:messaging", "events:activity", "extend:identity"];
513
553
  type Permission = (typeof PERMISSIONS)[number];
514
554
  /**
515
555
  * Maps capability types to the permission required to use them.
@@ -535,7 +575,7 @@ interface ExtensionManifest {
535
575
  targets: string[];
536
576
  /** Permissions required by this extension */
537
577
  permissions: Permission[];
538
- /** Specific events this extension listens for (e.g. ["identity.login", "postback:add_to_cart"]) */
578
+ /** Specific events this extension listens for (e.g. ["identity:login", "messaging:postback:add_to_cart"]) */
539
579
  events?: EventType[];
540
580
  /**
541
581
  * Hostnames this extension is permitted to reach via data.fetch.
@@ -887,4 +927,4 @@ interface Order {
887
927
  display_status?: OrderStatus;
888
928
  }
889
929
 
890
- 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 MessagingContext, 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, RESERVED_CONTEXT_KEYS, type ReservedContextKey, 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 };
930
+ export { ALLOWED_ICONS, type ActionInvokePayload, type ActivityEvent, type ActivityEventHandler, type ActivityEventType, 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 EventDomain, 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 MessagingContext, 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, RESERVED_CONTEXT_KEYS, type ReservedContextKey, 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 WellKnownActivityEvent, type WidgetAction, tagToComponentName };
package/dist/index.js CHANGED
@@ -1,5 +1,7 @@
1
1
  // ../../../lib/contracts/src/base.ts
2
2
  var asISOTimestamp = (value) => value;
3
+ var asClerkUserId = (value) => value;
4
+ var asClerkOrgId = (value) => value;
3
5
 
4
6
  // ../../../lib/contracts/src/permissions.ts
5
7
  var SUPER_ROLE = {
@@ -343,6 +345,7 @@ var PERMISSIONS = [
343
345
  "actions:invoke",
344
346
  "events:identity",
345
347
  "events:messaging",
348
+ "events:activity",
346
349
  "extend:identity"
347
350
  ];
348
351
  var CAPABILITY_PERMISSION_MAP = {
@@ -354,4 +357,4 @@ var CAPABILITY_PERMISSION_MAP = {
354
357
  "extend.identity": "extend:identity"
355
358
  };
356
359
 
357
- export { ALLOWED_ICONS, CAPABILITY_PERMISSION_MAP, EXTENSION_CATEGORIES, EXTENSION_VISIBILITIES, PERMISSIONS, RESERVED_CONTEXT_KEYS, UI_TAGS, UI_TAG_ATTRIBUTES, UI_TAG_ATTRIBUTE_VALUES, UI_TAG_CATEGORIES, UI_TAG_CHILDREN, UI_TAG_DEFINITIONS, asISOTimestamp, tagToComponentName };
360
+ export { ALLOWED_ICONS, CAPABILITY_PERMISSION_MAP, EXTENSION_CATEGORIES, EXTENSION_VISIBILITIES, PERMISSIONS, RESERVED_CONTEXT_KEYS, UI_TAGS, UI_TAG_ATTRIBUTES, UI_TAG_ATTRIBUTE_VALUES, UI_TAG_CATEGORIES, UI_TAG_CHILDREN, UI_TAG_DEFINITIONS, asClerkOrgId, asClerkUserId, asISOTimestamp, tagToComponentName };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackable-labs/sdk-extension-contracts",
3
- "version": "1.70.0",
3
+ "version": "1.72.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",