import { FxError } from "@microsoft/teamsfx-api"; import { Result } from "neverthrow"; import { ConditionNode, EvalValue, Scope } from "../expression/evaluateExpression"; import { Answers } from "../model/dataModel"; /** Identity-only option; computed values flow through provider `derived.*`. */ export interface OptionItem { id: string; label?: string; description?: string; detail?: string; groupName?: string; iconPath?: string; condition?: ConditionNode; keyPrefix?: string; } export interface InputBoxConfig { name: string; title?: string; placeholder?: string; prompt?: string; default?: string; step?: number; keyPrefix?: string; validation?: string | ValidationSpec; } /** Native question kinds the surface-neutral driver renders. */ export type QuestionType = "singleSelect" | "multiSelect" | "text" | "confirm" | "singleFile" | "folder" | "singleFileOrText"; /** A validator reference: the registry name, or `{ use, params }`. */ export interface ValidationSpec { use: string; params?: Record; } /** One authored question. Only one option source may be present. */ export interface QuestionSpec { name: string; type: QuestionType; title?: string; cliDescription?: string; cliShortName?: string; placeholder?: string; prompt?: string; default?: string | string[]; password?: boolean; filters?: Record; inputOptionItem?: OptionItem; inputBoxConfig?: InputBoxConfig; validation?: string | ValidationSpec; staticOptions?: OptionItem[]; optionsFrom?: string; optionsFromParams?: Record; skipSingleOption?: boolean; optional?: boolean; condition?: ConditionNode; keyPrefix?: string; } /** The Q2 options JSON Schema; only its identifier domain is read here. */ export interface OptionsSchema { properties?: Record; } /** What an `optionsFrom` provider yields. */ export interface ResolvedOptions { options: OptionItem[]; derived?: Record; } export type OptionsSource = OptionItem[] | (() => Promise); /** Engine-registered `optionsFrom` provider. */ export interface OptionsProvider { derivedSchema?: string[]; fetch(params: Record): Promise | ResolvedOptions; } /** Engine-registered validator: an error message, or `undefined` when valid. */ export type Validator = (value: string, answers: Answers) => string | undefined | Promise; export type PromptValidation = (value: string) => string | undefined | Promise; /** One prompt's outcome: a chosen value, a surface auto-skip, or the host's `back` request. */ export type Asked = { kind: "value"; value: T; } | { kind: "skip"; value: T; } | { kind: "back"; }; /** One resumable walk's history entry (opaque to cross-phase callers). */ export interface WalkHistoryEntry { pos: number; answers: Answers; } /** The resumable walk's outcome: a completed answer set, or a `back` handed to the caller. */ export type WalkOutcome = { kind: "done"; answers: Answers; history: WalkHistoryEntry[]; promptCount: number; } | { kind: "back"; history: WalkHistoryEntry[]; promptCount: number; }; /** Options for the resumable walk (the cross-phase back primitive; see collect-inputs INV-9). */ export interface WalkOptions { /** Added to the 1-based shown step so a later phase continues an earlier phase's numbering. */ baseStep?: number; /** Resume a prior walk by re-entering its last prompted question via `back`. */ resume?: { history: WalkHistoryEntry[]; }; /** When true, a `back` past the first prompt returns `{ kind: "back" }` instead of cancelling. */ backable?: boolean; } /** Surface-neutral prompt driver. */ export interface PromptUI { /** Render one scalar question. */ ask(question: QuestionSpec, options: OptionsSource | undefined, step?: number, validation?: PromptValidation, inputBoxValidation?: PromptValidation): Promise, FxError>>; /** Render one multi-pick question without collapsing selected ids to a scalar. */ askMulti(question: QuestionSpec, options: OptionsSource | undefined, step?: number): Promise, FxError>>; } /** Narrow input-collection port: prompt UI, registries, and shared evaluator. */ export interface CollectInputsPort { ui: PromptUI; optionsProvider(providerId: string): OptionsProvider | undefined; validator(name: string): Validator | undefined; evaluate(node: ConditionNode, scope: Scope): Result; } /** `SystemError` names for engine-side input collection breaks. */ export declare const INPUT_BOTH_OPTION_SOURCES = "InputBothOptionSources"; export declare const INPUT_UNKNOWN_PROVIDER = "InputUnknownProvider"; export declare const INPUT_UNKNOWN_VALIDATOR = "InputUnknownValidator"; export declare const INPUT_FORWARD_DERIVED_REFERENCE = "InputForwardDerivedReference"; export declare const INPUT_PROVIDER_FAILED = "InputProviderFailed"; export declare const INPUT_PROVIDER_DERIVED_SCHEMA_VIOLATION = "InputProviderDerivedSchemaViolation"; /** `UserError` name for input validation failures. */ export declare const INPUT_VALIDATION_FAILED = "InputValidationFailed"; /** `UserError` name for cancelling the walk from the first prompt. */ export declare const INPUT_WALK_CANCELLED = "InputWalkCancelled"; /** * Walk one phase's questions into a resumable outcome — the shared cross-phase * back primitive (collect-inputs INV-9). `baseStep` offsets the shown step so a * later phase continues an earlier phase's numbering; `backable` turns a `back` * past the first prompt into a `{ kind: "back" }` outcome instead of cancelling; * `resume` re-enters a prior walk's history at its last prompted question. */ export declare function walkInputs(questions: QuestionSpec[], optionsSchema: OptionsSchema, entryParams: Answers, port: CollectInputsPort, walkOptions?: WalkOptions): Promise>; /** * Walk one template's questions into the resolved answer object — the stable * non-resumable entry over {@link walkInputs} (no step offset, no resume, * `backable` off), so a `back` past the first prompt cancels (INPUT-18) and the * result is the plain answer object. Preserves the pre-cross-phase contract. */ export declare function collectInputs(questions: QuestionSpec[], optionsSchema: OptionsSchema, entryParams: Answers, port: CollectInputsPort): Promise>; //# sourceMappingURL=collectInputs.d.ts.map