import { APPS_RESERVED_RESOURCE_ID_PREFIX, type Parent } from "./intents.js"; /** Validate parent references. Reserved Apps IDs are allowed as parents. */ export function assertParent(parent: Parent): void { if (parent.type !== "resourceId") { throw new Error("Notion-as-Code parents must reference a resourceId"); } if (parent.resourceId.length === 0) { throw new Error("Notion-as-Code resourceId must be a non-empty string"); } } /** Reject empty or runtime-reserved IDs for created resources. */ export function assertUserResourceId(resourceId: string): void { if (resourceId.length === 0) { throw new Error("Notion-as-Code resourceId must be a non-empty string"); } if (resourceId.startsWith(APPS_RESERVED_RESOURCE_ID_PREFIX)) { throw new Error(`Resource ID "${resourceId}" uses the reserved Apps prefix`); } }