import type { ResourceId } from "./intents.js"; import { recordIntent } from "./recorder.js"; import { assertUserResourceId } from "./resource.js"; import type { ViewSchema } from "./views.js"; /** Declare a view attached to a database resource. */ export type ViewArgs = ViewSchema & { databaseResourceId: ResourceId; }; export type ViewHandle = { readonly resourceId: string; }; /** Record a database view for provisioning without making a Notion API request. */ export function view(args: ViewArgs): ViewHandle { assertUserResourceId(args.resourceId); assertUserResourceId(args.databaseResourceId); assertUserResourceId(args.dataSourceResourceId); const { databaseResourceId, ...schema } = args; recordIntent({ type: "view", databaseResourceId, view: schema }); return { resourceId: args.resourceId }; }