Luigit
repositories / pi-ext

pi-ext

bugabingas pi extensions

owned by admin

extensions/mockup/contract.ts

Raw
import type { TArray, TBoolean, TObject, TOptional, TString } from "typebox";
import { Type } from "typebox";

export const MOCKUP_DESCRIPTION: string =
	"Open HTML-fragment mockups in an interactive browser review, or render a headless preview so you can inspect your own rendering without asking the human to open a browser. Each option is one single screen (html) or a navigable multipage flow (pages). Reviews return accept or iterate, selected option IDs, notes, and annotations.";

export const mockupParameters: TObject<{
	title: TString;
	question: TString;
	options: TArray<
		TObject<{
			id: TString;
			label: TString;
			description: TOptional<TString>;
			html: TOptional<TString>;
			pages: TOptional<
				TArray<
					TObject<{
						id: TString;
						label: TOptional<TString>;
						html: TString;
					}>
				>
			>;
		}>
	>;
	multi: TOptional<TBoolean>;
	preview: TOptional<TBoolean>;
}> = Type.Object({
	title: Type.String({
		description: "Short browser page title for this visual decision.",
	}),
	question: Type.String({
		description: "The exact visual question the human should answer.",
	}),
	options: Type.Array(
		Type.Object({
			id: Type.String({
				description:
					"Stable option id. Letters, numbers, dot, underscore, dash only.",
			}),
			label: Type.String({ description: "Human-visible option label." }),
			description: Type.Optional(
				Type.String({
					description: "One short sentence explaining the option.",
				}),
			),
			html: Type.Optional(
				Type.String({
					description:
						"HTML fragment for a single screen. Omit when the option provides pages.",
				}),
			),
			pages: Type.Optional(
				Type.Array(
					Type.Object({
						id: Type.String({
							description:
								"Stable page id, unique within the option. Letters, numbers, dot, underscore, dash only.",
						}),
						label: Type.Optional(
							Type.String({
								description:
									"Human-visible page tab label; defaults to the page id.",
							}),
						),
						html: Type.String({
							description: "HTML fragment for this page of the flow.",
						}),
					}),
					{
						minItems: 2,
						maxItems: 12,
						description:
							"Ordered pages of one navigable flow. The review frame renders tabs, prev/next buttons, keyboard navigation, and a pagechange event; write only the page fragments.",
					},
				),
			),
		}),
		{
			minItems: 1,
			maxItems: 4,
		},
	),
	multi: Type.Optional(
		Type.Boolean({
			default: false,
			description: "Allow selecting multiple options.",
		}),
	),
	preview: Type.Optional(
		Type.Boolean({
			default: false,
			description:
				"Render every option headlessly and return screenshots to you instead of opening the interactive review. Use it to self-check rendering and refine HTML before asking the human to review.",
		}),
	),
});