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. 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: TString;
		}>
	>;
	multi: 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.String({
				description: "HTML fragment; scripts are allowed.",
			}),
		}),
		{
			minItems: 1,
			maxItems: 4,
		},
	),
	multi: Type.Optional(
		Type.Boolean({
			default: false,
			description: "Allow selecting multiple options.",
		}),
	),
});