ChainGraph API Documentation / @badaitech/chaingraph-types / ObjectSchemaCopyTo
Function: ObjectSchemaCopyTo()
ObjectSchemaCopyTo(
predicate,config):PropertyDecorator
Defined in: packages/chaingraph-types/src/decorator/object-schema-copy-to.decorator.ts:102
Decorator for automatically copying object schema to target ports
This decorator simplifies the common pattern of copying an object port's schema to another object port when the source port is updated. It internally uses the
Parameters
predicate
Function to identify target port(s) for schema copying
config
Optional configuration for schema copying behavior
Returns
PropertyDecorator
On Port Update
decorator to handle port update events.
Example usage:
typescript
class MyNode extends BaseNode {
@Passthrough()
@PortObject({
title: 'Schema',
schema: { properties: {} },
isSchemaMutable: true,
})
@ObjectSchemaCopyTo(
(port) => port.getConfig().key === 'output' && !port.getConfig().parentId
)
schema: Record<string, any> = {}
@Output()
@PortObject({
title: 'Output',
schema: { properties: {} },
})
output: Record<string, any> = {}
}