fix(core): allow plugin nodes under levels
This commit is contained in:
@@ -48,4 +48,12 @@ describe('LevelNode', () => {
|
|||||||
nodes.map((node) => node.id),
|
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'])
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,62 +1,13 @@
|
|||||||
import dedent from 'dedent'
|
import dedent from 'dedent'
|
||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
import { BaseNode, nodeType, objectId } from '../base'
|
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({
|
export const LevelNode = BaseNode.extend({
|
||||||
id: objectId('level'),
|
id: objectId('level'),
|
||||||
type: nodeType('level'),
|
type: nodeType('level'),
|
||||||
children: z
|
// The node registry owns child-kind validity. Persisted level relationships
|
||||||
.array(
|
// must also admit IDs minted by plugins that core cannot enumerate.
|
||||||
z.union([
|
children: z.array(z.string()).default([]),
|
||||||
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([]),
|
|
||||||
// Specific props
|
// Specific props
|
||||||
level: z.number().default(0),
|
level: z.number().default(0),
|
||||||
}).describe(
|
}).describe(
|
||||||
|
|||||||
Reference in New Issue
Block a user