import * as z from "zod/mini"; const versionIdSchema = z.string().check(z.trim(), z.minLength(1)); export const FLOW_VERSION_PAYLOAD_GENERATION = "4"; /** * @deprecated Compatibility identifier for immutable generation-3 clients. * New clients must request `FLOW_VERSION_PAYLOAD_GENERATION`. */ export const PAGE_ONLY_FLOW_VERSION_PAYLOAD_GENERATION = "3"; // TODO(migration): Remove generation 3 from fetch and submission admission // only after immutable generation-3 widgets have expired, widget analytics // stays quiet for the agreed period, and // `public_flow_version_payload_origin_served` plus a communicated deprecation // window show that custom clients can be retired. // [from=generation-three-flow-payload] [to=current-flow-payload-generation] [scope=slice] [priority=medium] [impact=medium] [risk=medium] export const FLOW_VERSION_PAYLOAD_GENERATIONS = [ PAGE_ONLY_FLOW_VERSION_PAYLOAD_GENERATION, FLOW_VERSION_PAYLOAD_GENERATION, ] as const; export type FlowVersionPayloadGeneration = (typeof FLOW_VERSION_PAYLOAD_GENERATIONS)[number]; export const isFlowVersionPayloadGeneration = ( value: string, ): value is FlowVersionPayloadGeneration => (FLOW_VERSION_PAYLOAD_GENERATIONS as readonly string[]).includes(value); export const ACCEPTED_SUBMISSION_FLOW_VERSION_PAYLOAD_GENERATIONS = [ ...FLOW_VERSION_PAYLOAD_GENERATIONS, ] as const; export type AcceptedSubmissionFlowVersionPayloadGeneration = (typeof ACCEPTED_SUBMISSION_FLOW_VERSION_PAYLOAD_GENERATIONS)[number]; // Cached generation-2 clients omitted this metadata entirely. The optional // submission field remains their compatibility corridor until those immutable // clients expire; explicit generation-2 metadata was never emitted by Core. export const flowVersionResolutionSchema = z.object({ flowVersionId: versionIdSchema, }); export const themeVersionResolutionSchema = z.object({ themeRuntimeArtifactId: versionIdSchema, themeVersionId: versionIdSchema, }); export type FlowVersionResolution = z.output< typeof flowVersionResolutionSchema >; export type ThemeVersionResolution = z.output< typeof themeVersionResolutionSchema >;