diff --git a/packages/core/src/schema/nodes/level.test.ts b/packages/core/src/schema/nodes/level.test.ts index 839be780..e9e0efa9 100644 --- a/packages/core/src/schema/nodes/level.test.ts +++ b/packages/core/src/schema/nodes/level.test.ts @@ -48,4 +48,12 @@ describe('LevelNode', () => { nodes.map((node) => node.id), ) }) + + test('accepts level child IDs minted by plugins', () => { + expect( + LevelNode.parse({ + children: ['tree_plugin-child', 'flower_plugin-child', 'grass_plugin-child'], + }).children, + ).toEqual(['tree_plugin-child', 'flower_plugin-child', 'grass_plugin-child']) + }) }) diff --git a/packages/core/src/schema/nodes/level.ts b/packages/core/src/schema/nodes/level.ts index ef4de43a..1055648b 100644 --- a/packages/core/src/schema/nodes/level.ts +++ b/packages/core/src/schema/nodes/level.ts @@ -1,62 +1,13 @@ import dedent from 'dedent' import { z } from 'zod' import { BaseNode, nodeType, objectId } from '../base' -import { CeilingNode } from './ceiling' -import { ColumnNode } from './column' -import { DuctFittingNode } from './duct-fitting' -import { DuctSegmentNode } from './duct-segment' -import { DuctTerminalNode } from './duct-terminal' -import { FenceNode } from './fence' -import { GuideNode } from './guide' -import { HvacEquipmentNode } from './hvac-equipment' -import { ItemNode } from './item' -import { LinesetNode } from './lineset' -import { LiquidLineNode } from './liquid-line' -import { MeasurementNode } from './measurement' -import { PipeFittingNode } from './pipe-fitting' -import { PipeSegmentNode } from './pipe-segment' -import { PipeTrapNode } from './pipe-trap' -import { RoofNode } from './roof' -import { ScanNode } from './scan' -import { ShelfNode } from './shelf' -import { SlabNode } from './slab' -import { SpawnNode } from './spawn' -import { StairNode } from './stair' -import { WallNode } from './wall' -import { ZoneNode } from './zone' export const LevelNode = BaseNode.extend({ id: objectId('level'), type: nodeType('level'), - children: z - .array( - z.union([ - WallNode.shape.id, - FenceNode.shape.id, - ColumnNode.shape.id, - ItemNode.shape.id, - ZoneNode.shape.id, - SlabNode.shape.id, - CeilingNode.shape.id, - RoofNode.shape.id, - StairNode.shape.id, - ScanNode.shape.id, - GuideNode.shape.id, - MeasurementNode.shape.id, - SpawnNode.shape.id, - ShelfNode.shape.id, - DuctSegmentNode.shape.id, - DuctFittingNode.shape.id, - DuctTerminalNode.shape.id, - HvacEquipmentNode.shape.id, - LinesetNode.shape.id, - LiquidLineNode.shape.id, - PipeSegmentNode.shape.id, - PipeFittingNode.shape.id, - PipeTrapNode.shape.id, - ]), - ) - .default([]), + // The node registry owns child-kind validity. Persisted level relationships + // must also admit IDs minted by plugins that core cannot enumerate. + children: z.array(z.string()).default([]), // Specific props level: z.number().default(0), }).describe(