{"version":3,"file":"block_components.cjs","names":["z"],"sources":["../../src/block_meta/block_components.ts"],"sourcesContent":["import { z } from \"zod\";\n\n//\n// Workflow + BlockComponents canonical TS types.\n//\n\n/**\n * Wrapped workflow component, schema version 1. Currently the only workflow\n * schema; carries a single `main` entry pointing at the workflow source.\n */\nexport type WorkflowV1<Content> = {\n  type: \"workflow-v1\";\n  main: Content;\n};\n\n/**\n * Current workflow component shape. Alias to `WorkflowV1` while v1 is the\n * only version — future versions widen this to a discriminated union.\n */\nexport type Workflow<Content> = WorkflowV1<Content>;\n\n/**\n * Trio of artifacts every block ships: a workflow (Tengo source), a model\n * (compiled JS), and a UI (front-end bundle). `WMContent` carries\n * `workflow.main` and `model` together (they travel as files); `UIContent`\n * carries the UI bundle (a folder when resolved locally, a relative path in\n * manifest form). Parameterizing this lets the same shape express every\n * stage the description passes through: raw `package.json` input (bare\n * strings), manifest form (relative paths stored in the registry), resolved\n * absolute form (local file/folder paths), and the registry-reader output\n * (URLs into registry storage, produced by `blockComponentsManifestToAbsoluteUrl`).\n */\nexport type BlockComponents<WMContent, UIContent> = {\n  workflow: Workflow<WMContent>;\n  model: WMContent;\n  ui: UIContent;\n};\n\n/**\n * Builds the zod schema for a wrapped workflow component carrying `content`\n * as the `main` payload. Shared between the `package.json` boundary parser\n * (where `content` is `z.string()`) and the manifest schema (where `content`\n * is `ContentRelative`).\n */\nexport function WorkflowSchemaV1<C extends z.ZodTypeAny>(content: C) {\n  return z\n    .object({\n      type: z.literal(\"workflow-v1\"),\n      main: content,\n    })\n    .strict();\n}\n\n//\n// `package.json` boundary schema. The workflow field accepts either a bare\n// string (treated as `main`) or the wrapped object form; both normalize to\n// the canonical wrapped shape.\n//\n\nconst WorkflowDescriptionRaw = z.union([\n  z.string().transform<WorkflowV1<string>>((value) => ({\n    type: \"workflow-v1\",\n    main: value,\n  })),\n  WorkflowSchemaV1(z.string()),\n]) satisfies z.ZodType<Workflow<string>, z.ZodTypeDef, any>;\n\nexport type BlockComponentsDescriptionRaw = BlockComponents<string, string>;\n\nexport const BlockComponentsDescriptionRaw = z.object({\n  workflow: WorkflowDescriptionRaw,\n  model: z.string(),\n  ui: z.string(),\n}) satisfies z.ZodType<BlockComponentsDescriptionRaw, z.ZodTypeDef, any>;\n"],"mappings":";;;;;;;;AA4CA,SAAgB,iBAAyC,SAAY;CACnE,OAAOA,IAAAA,EACJ,OAAO;EACN,MAAMA,IAAAA,EAAE,QAAQ,aAAa;EAC7B,MAAM;CACR,CAAC,CAAC,CACD,OAAO;AACZ;AAQA,MAAM,yBAAyBA,IAAAA,EAAE,MAAM,CACrCA,IAAAA,EAAE,OAAO,CAAC,CAAC,WAA+B,WAAW;CACnD,MAAM;CACN,MAAM;AACR,EAAE,GACF,iBAAiBA,IAAAA,EAAE,OAAO,CAAC,CAC7B,CAAC;AAID,MAAa,gCAAgCA,IAAAA,EAAE,OAAO;CACpD,UAAU;CACV,OAAOA,IAAAA,EAAE,OAAO;CAChB,IAAIA,IAAAA,EAAE,OAAO;AACf,CAAC"}