UNPKG

@revenuecat/purchases-ui-js

Version:

Web components for Paywalls. Powered by RevenueCat

37 lines (36 loc) 1.67 kB
import type { WorkflowData, WorkflowScreen, WorkflowStep } from "./workflow"; /** * A self-contained multi-page workflow payload for use with the Workflow * component. This mirrors the shape of rc-workflows' WorkflowData but only * includes the fields needed for client-side page navigation. */ export interface WorkflowNavData { /** ID of the first page to display. Must be a key in `pages`. */ initial_page_id: string; /** * All pages in this workflow keyed by screen ID. * Workflow step actions resolve to these IDs via `steps[stepId].screen_id`. */ pages: Record<string, WorkflowScreen>; /** * All steps in this workflow keyed by step ID. * Used to resolve `workflow`-type button actions: the button's component ID * is looked up in the current step's `triggers` array to get an action_id, * which maps to a `trigger_actions` entry pointing to the next step_id, * whose screen_id is then used to navigate to the correct page. */ steps: Record<string, WorkflowStep>; /** The step ID of the first step, corresponding to `initial_page_id`. */ initial_step_id: string; } /** * Map a full `WorkflowData` SDK response to the `WorkflowNavData` shape * consumed by the `Workflow` component. * * - `pages` is taken directly from `WorkflowData.screens`, keyed by screen ID. * - `initial_page_id` is resolved by looking up the screen_id of the initial * step, since `initial_step_id` is a step ID, not a screen ID. * * Returns `null` if the initial step or its screen cannot be resolved. */ export declare function workflowDataToNavData(data: WorkflowData): WorkflowNavData | null;