import * as v from "valibot" import { notionPropertyTypeSchema } from "./dataSources/propertySchema.js" /** * User-authored manifest declaring the data sources the custom block expects. * Lives at `custom_blocks.json` in the project root and is forwarded to the host with * the bridge `ready` message so the host can pre-bind data sources, surface * configuration UI, etc. The `notionCustomBlock` Vite plugin from * `ncblock/vite` wires the JSON file into the dev server and * the build output. */ /** * Decorative icon attached to a manifest data source. Mirrors the * `emoji` / `external` icon variants the public Notion API uses, so the host * can render a recognizable affordance next to the slot in setup UI. */ export const manifestIconSchema = v.variant("type", [ v.object({ type: v.literal("emoji"), emoji: v.string(), }), v.object({ type: v.literal("external"), url: v.string(), }), ]) export type ManifestIcon = v.InferOutput export const manifestPropertySchema = v.object({ name: v.string(), description: v.optional(v.string()), type: notionPropertyTypeSchema, }) export type ManifestProperty = v.InferOutput export const manifestDataSourceSchema = v.object({ name: v.string(), description: v.optional(v.string()), icon: v.optional(manifestIconSchema), properties: v.optional(v.record(v.string(), manifestPropertySchema), {}), }) export type ManifestDataSource = v.InferOutput export const manifestSchema = v.object({ version: v.literal(1), dataSources: v.record(v.string(), manifestDataSourceSchema), }) export type CustomBlockManifest = v.InferOutput