UNPKG

@revenuecat/purchases-ui-js

Version:

Web components for Paywalls. Powered by RevenueCat

77 lines (76 loc) 2.64 kB
import type { PaywallData } from "./paywall"; /** * Represents a screen/paywall configuration in a workflow. * Extends core PaywallData with workflow-specific metadata. */ export interface WorkflowScreen extends PaywallData { asset_base_url: string; config: Record<string, unknown>; localized_strings: Record<string, Record<string, string>>; localized_strings_by_tier: Record<string, Record<string, string>>; name: string; offering_id: string | null; revision: number; template_name: string; } /** * A trigger action that navigates directly to another step. */ export interface WorkflowStepTriggerAction { type: "step"; step_id: string; } /** * An entry in a step's `triggers` array that maps a component interaction * (e.g. button press) to a named action_id, which in turn maps to a * `trigger_actions` entry. */ export interface WorkflowStepTrigger { /** The action ID to look up in `trigger_actions`. */ action_id: string; /** The component (e.g. button) id that fires this trigger. */ component_id: string; /** The interaction type, e.g. "on_press". */ type: string; name?: string; } /** * A single step in a workflow, referencing a screen by ID. * Aligns with the SDK response shape from khepri. */ export interface WorkflowStep { id: string; screen_id?: string; type: string; param_values: Record<string, unknown>; /** * Maps action IDs (from `triggers[].action_id`) to the next step to navigate * to. Currently only `type: "step"` is supported for client-side resolution; * condition-based actions are ignored. */ trigger_actions: Record<string, WorkflowStepTriggerAction | Record<string, unknown>>; /** * Array of trigger entries mapping component interactions to action IDs. * Resolve a button press by matching its component `id` against * `component_id`, then use the entry's `action_id` to look up * `trigger_actions`. */ triggers: WorkflowStepTrigger[]; outputs: Record<string, unknown>; metadata: Record<string, unknown> | null; } /** * The full workflow payload returned by the RevenueCat SDK. * Aligns with rc-workflows' WorkflowData type — rc-workflows imports * WorkflowScreen from this package and can import WorkflowData here too. */ export interface WorkflowData { id: string; display_name: string; initial_step_id: string; steps: Record<string, WorkflowStep>; screens: Record<string, WorkflowScreen>; ui_config: Record<string, unknown>; content_max_width: number | null; metadata?: Record<string, unknown> | null; }