{"version":3,"sources":["../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/types/src/index.ts"],"sourcesContent":["/**\n * An asset is the smallest unit of user interaction in a player view\n */\nexport interface Asset<T extends string = string> {\n  /** Each asset requires a unique id per view */\n  id: string;\n\n  /** The asset type determines the semantics of how a user interacts with a page */\n  type: T;\n\n  [key: string]: unknown;\n}\n/**\n * An asset that contains a Binding.\n */\nexport interface AssetBinding extends Asset {\n  /** A binding that points to somewhere in the data model */\n  binding: Binding;\n}\n\n/** A single case statement to use in a switch */\nexport interface SwitchCase<T extends Asset = Asset> {\n  /** The Asset to use if this case is applicable */\n  asset: T;\n\n  /** An expression to execute to determine if this case applies */\n  case: Expression | true;\n}\n\n/** A switch can replace an asset with the applicable case on first render */\nexport type Switch<T extends Asset = Asset> = SwitchCase<T>[];\n\n/** An object that contains an asset */\nexport type AssetWrapper<T extends Asset = Asset> = {\n  /** An asset instance */\n  asset: T;\n\n  [key: string]: unknown;\n};\n\nexport type AssetWrapperOrSwitch<T extends Asset = Asset> =\n  | (AssetWrapper<T> & {\n      /** The dynamicSwitch property can't exist at the same time as 'asset' */\n      dynamicSwitch?: never;\n\n      /** The staticSwitch property can't exist at the same time as 'asset' */\n      staticSwitch?: never;\n    })\n  | (StaticSwitch<T> & {\n      /** The staticSwitch property can't exist at the same time as 'asset' */\n      asset?: never;\n\n      /** The staticSwitch property can't exist at the same time as 'dynamicSwitch' */\n      dynamicSwitch?: never;\n    })\n  | (DynamicSwitch<T> & {\n      /** The dynamicSwitch property can't exist at the same time as 'asset' */\n      asset?: never;\n\n      /** The dynamicSwitch property can't exist at the same time as 'staticSwitch' */\n      staticSwitch?: never;\n    });\n\nexport type AssetSwitch<T extends Asset = Asset> =\n  | StaticSwitch<T>\n  | DynamicSwitch<T>;\n\nexport interface StaticSwitch<T extends Asset = Asset> {\n  /** A static switch only evaluates the applicable base on first render of the view */\n  staticSwitch: Switch<T>;\n}\n\nexport interface DynamicSwitch<T extends Asset = Asset> {\n  /** A dynamic switch re-evaluates the applicable case as data changes */\n  dynamicSwitch: Switch<T>;\n}\n\n/**\n * Expressions are a specialized way of executing code.\n * If the expression is a composite, the last expression executed is the return value\n */\nexport type Expression = string | string[];\nexport type ExpressionRef = `@[${string}]@`;\n\n/**\n * Bindings describe locations in the data model.\n */\nexport type Binding = string;\nexport type BindingRef = `{{${Binding}}}`;\n\n/**\n * The data-model is the location that all user data is stored\n */\nexport type DataModel = Record<any, unknown>;\n\n/** The navigation section of the flow describes a State Machine for the user. */\nexport type Navigation = {\n  /** The name of the Flow to begin on */\n  BEGIN: string;\n} & Record<string, string | NavigationFlow>;\n\n/** An object with an expression in it */\nexport interface ExpressionObject {\n  /** The expression to run */\n  exp?: Expression;\n}\n\n/** A state machine in the navigation */\nexport interface NavigationFlow {\n  /** The first state to kick off the state machine */\n  startState: string;\n\n  /** An optional expression to run when this Flow starts */\n  onStart?: Expression | ExpressionObject;\n\n  /** An optional expression to run when this Flow ends */\n  onEnd?: Expression | ExpressionObject;\n\n  [key: string]:\n    | undefined\n    | string\n    | Expression\n    | ExpressionObject\n    | NavigationFlowState;\n}\n\nexport type NavigationFlowTransition = Record<string, string>;\n\ninterface CommentBase {\n  /** Add comments that will not be processing, but are useful for code explanation */\n  _comment?: string;\n}\n\n/** The base representation of a state within a Flow */\nexport interface NavigationBaseState<T extends string> extends CommentBase {\n  /** A property to determine the type of state this is */\n  state_type: T;\n\n  /** An optional expression to run when this view renders */\n  onStart?: Expression | ExpressionObject;\n\n  /** An optional expression to run before view transition */\n  onEnd?: Expression | ExpressionObject;\n\n  /**\n   * TS gets really confused with both the ActionState and the onStart state both declaring the `exp` property\n   * So this explicity says there should never be an exp prop on a state node that's not of type 'ACTION'\n   */\n  exp?: T extends \"ACTION\" | \"ASYNC_ACTION\" ? Expression : never;\n}\n\n/** A generic state that can transition to another state */\nexport interface NavigationFlowTransitionableState<\n  T extends string,\n> extends NavigationBaseState<T> {\n  /** A mapping of transition-name to FlowState name */\n  transitions: NavigationFlowTransition;\n}\n\n/** A state representing a view  */\nexport interface NavigationFlowViewState extends NavigationFlowTransitionableState<\"VIEW\"> {\n  /** An id corresponding to a view from the 'views' array */\n  ref: string;\n\n  /** View meta-properties */\n  attributes?: {\n    [key: string]: any;\n  };\n\n  /** Any additional properties are forwarded as options, like param */\n  [key: string]: unknown;\n}\n\n/**\n * An END state of the flow.\n */\nexport interface NavigationFlowEndState extends NavigationBaseState<\"END\"> {\n  /**\n   * A description of _how_ the flow ended.\n   * If this is a flow started from another flow, the outcome determines the flow transition\n   */\n  outcome: string;\n\n  /** Any additional properties are forwarded as options, like param */\n  [key: string]: unknown;\n}\n\n/** Action states execute an expression to determine the next state to transition to */\nexport interface NavigationFlowActionState extends NavigationFlowTransitionableState<\"ACTION\"> {\n  /**\n   * An expression to execute.\n   * The return value determines the transition to take\n   */\n  exp: Expression;\n}\n\n/** Action states execute an expression to determine the next state to transition to */\nexport interface NavigationFlowAsyncActionState extends NavigationFlowTransitionableState<\"ASYNC_ACTION\"> {\n  /**\n   * An expression to execute.\n   * The return value determines the transition to take\n   */\n  exp: Expression;\n\n  /** Whether the expression(s) should be awaited before transitioning */\n  await: boolean;\n}\n\n/**\n * External Flow states represent states in the FSM that can't be resolved internally in Player.\n * The flow will wait for the embedded application to manage moving to the next state via a transition\n */\nexport interface NavigationFlowExternalState extends NavigationFlowTransitionableState<\"EXTERNAL\"> {\n  /** A reference for this external state */\n  ref: string;\n  /** Any additional properties are forwarded as options */\n  [key: string]: unknown;\n}\n\nexport interface NavigationFlowFlowState extends NavigationFlowTransitionableState<\"FLOW\"> {\n  /** A reference to a FLOW id state to run */\n  ref: string;\n}\n\nexport type NavigationFlowState =\n  | NavigationFlowViewState\n  | NavigationFlowEndState\n  | NavigationFlowFlowState\n  | NavigationFlowActionState\n  | NavigationFlowAsyncActionState\n  | NavigationFlowExternalState;\n\n/** The data at the end of a flow */\nexport interface FlowResult {\n  /** The outcome describes _how_ the flow ended (forwards, backwards, etc) */\n  endState: NavigationFlowEndState;\n\n  /** The serialized data-model */\n  data?: any;\n}\n\n/** Any object that contains 1 or more templates */\nexport interface Templatable {\n  /** A list of templates to process for this node */\n  template?: Template[];\n}\n\n/** A template describes a mapping from a data array -> array of objects */\nexport interface Template<ValueType = unknown, Key extends string = string> {\n  /** A pointer to the data-model containing an array of elements to map over */\n  data: Binding;\n\n  /**\n   * The template to iterate over using each value in the supplied template data.\n   * Any reference to _index_ is replaced with the current iteration index.\n   */\n  value: ValueType;\n\n  /** should the template be recomputed when data changes */\n  dynamic?: boolean;\n\n  /**\n   * A property on the parent object to store the new map under.\n   * If it already exists, values are appended to the end.\n   */\n  output: Key;\n\n  /** Specifies the template placement in relation to existing elements*/\n  placement?: \"prepend\" | \"append\";\n}\n\n/**\n * The Schema organizes all content related to Data and it's types\n */\nexport declare namespace Schema {\n  /** The authored schema object in the JSON payload */\n  export interface Schema {\n    /** The ROOT object is the top level object to use */\n    ROOT: Node;\n\n    /** Any additional keys are properties of the ROOT object */\n    [key: string]: Node;\n  }\n\n  /** A Node describes a specific object in the tree */\n  export interface Node {\n    /** Each property describes a property of the object */\n    [key: string]: DataTypes;\n  }\n\n  export type DataTypes = DataType | RecordType | ArrayType;\n\n  /** Each prop in the object can have a specific DataType */\n  export interface DataType<T = unknown> {\n    /** The reference of the base type to use */\n    type: string;\n\n    /**\n     * Any additional validations that are associated with this property\n     * These will add to any base validations associated with the \"type\"\n     */\n    validation?: Validation.Reference[];\n\n    /**\n     * A reference to a specific data format to use.\n     * If none is specified, will fallback to that of the base type\n     */\n    format?: Formatting.Reference;\n\n    /**\n     * A default value for this property.\n     * Any reads for this property will result in this default value being written to the model.\n     */\n    default?: T;\n\n    /** Any additional options */\n    [key: string]: unknown;\n  }\n  /** Determines if the Datatype is a record object */\n  export interface RecordType extends DataType {\n    /** boolean to define if its a record */\n    isRecord: boolean;\n\n    /** This property is mutually exclusive with RecordType and can not be used with ArrayType */\n    isArray?: never;\n  }\n\n  /** Determines if the DataType is an Array Object */\n  export interface ArrayType extends DataType {\n    /** boolean to define if its an array */\n    isArray: boolean;\n\n    /** This property is mutually exclusive with ArrayType and can not be used with RecordType */\n    isRecord?: never;\n  }\n}\n\n/** Namespace to wrap up core functionality to be used by the Language Service */\nexport declare namespace Language {\n  /**\n   * Helper to compliment `Schema.DataType` to provide a way to export a reference to a data type instead of the whole object\n   */\n  export interface DataTypeRef {\n    /** Name of the type in Player Core */\n    type: string;\n  }\n}\n\n/** A spot for formatting */\nexport declare namespace Formatting {\n  /** A reference to a specific formatter */\n  export interface Reference {\n    /** The name of the formatter (and de-formatter) to use */\n    type: string;\n\n    /** Any additional properties will be passed as options to the formatter function */\n    [key: string]: unknown;\n  }\n}\n\n/** A space for all thing validation */\nexport declare namespace Validation {\n  /**\n   * How serious are you about this error?\n   * Warning validations are reserved for errors that could be ignored by the user without consequence\n   * Errors must be fixed before proceeding\n   */\n  export type Severity = \"error\" | \"warning\";\n\n  /**\n   * When to _first_ start caring about a validation of a data-val.\n   *\n   * load - only check once the first time the binding appears on screen\n   * change - check anytime the data changes\n   * navigation - check once the user attempts to navigate away from a view\n   */\n  export type Trigger = \"navigation\" | \"change\" | \"load\";\n\n  /**\n   * Where the error/warning should be displayed.\n   * - `field` is the default display target. This renders the error/warning directly underneath the field.\n   * - `section` is used to display a message at a parent node that is designated as a \"section\"\n   * - `page` a special section used to display a message at the top of the page.\n   */\n  export type DisplayTarget = \"page\" | \"section\" | \"field\";\n\n  /** A reference to a validation object */\n  export interface Reference {\n    /**\n     * The name of the referenced validation type\n     * This will be used to lookup the proper handler\n     */\n    type: string;\n\n    /** An optional means of overriding the default message if the validation is triggered */\n    message?: string;\n\n    /** An optional means of overriding the default severity of the validation if triggered */\n    severity?: Severity;\n\n    /** When to run this particular validation */\n    trigger?: Trigger;\n\n    /**\n     * Each validation is passed the value of the data to run it's validation against.\n     * By default, this is the value stored in the data-model (deformatted).\n     * In the off chance you'd like this validator to run against the formatted value (the one the user sees), set this option\n     */\n    dataTarget?: \"formatted\" | \"deformatted\";\n\n    /** Where the error should be displayed */\n    displayTarget?: DisplayTarget;\n\n    /**\n     * If the validation blocks navigation\n     * true/false - always/never block navigation\n     * once - only block navigation if the validation has not been triggered before\n     *\n     * @default - true for errors, 'once' for warnings\n     */\n    blocking?: boolean | \"once\";\n\n    /** Additional props to send down to a Validator */\n    [key: string]: unknown;\n  }\n\n  export interface CrossfieldReference extends Reference {\n    /** The binding to associate this validation with */\n    ref?: Binding;\n\n    /** Cross-field references and validation must run against the default (deformatted) value */\n    dataTarget?: never;\n  }\n}\n\nexport type View<T extends Asset = Asset> = unknown extends T[\"validation\"]\n  ? T & {\n      /** Each view can optionally supply a list of validations to run against a particular view */\n      validation?: Array<Validation.CrossfieldReference>;\n    }\n  : T;\n\n/**\n * The JSON payload for running Player\n */\nexport interface Flow<T extends Asset = Asset> {\n  /** A unique identifier for the flow  */\n  id: string;\n\n  /** A list of views (each with an ID) that can be shown to a user */\n  views?: Array<View<T>>;\n\n  /**\n   * The schema for the supplied (or referenced data).\n   * This is used for validation, formatting, etc\n   */\n  schema?: Schema.Schema;\n\n  /** Any initial data that the flow can use */\n  data?: DataModel;\n\n  /** A state machine to drive a user through the experience */\n  navigation: Navigation;\n\n  /** Other keys can be present. We just don't know what they are */\n  [key: string]: unknown;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}