@tokens-studio/graph-engine
Version:
An execution engine to handle Token Studios generators and resolvers
32 lines • 1.12 kB
JavaScript
import { Node } from '../../programmatic/node.js';
import { ObjectSchema } from '../../schemas/index.js';
import { annotatedDynamicInputs } from '../../annotations/index.js';
export default class NodeDefinition extends Node {
static title = 'Objectify';
static type = 'studio.tokens.generic.objectify';
static description = 'Objectify node allows you to convert multiple inputs to an object.';
constructor(props) {
super(props);
this.annotations[annotatedDynamicInputs] = true;
//Purely runtime inputs
this.addOutput('value', {
type: ObjectSchema
});
}
execute() {
const finalType = {
...ObjectSchema,
properties: {}
};
const { value, schema } = Object.entries(this.inputs).reduce((acc, [key, input]) => {
acc.value[key] = input.value;
acc.schema.properties[key] = input.type;
return acc;
}, {
value: {},
schema: finalType
});
this.outputs.value.set(value, schema);
}
}
//# sourceMappingURL=objectify.js.map