Skip to content

Commit

Permalink
fix data does not have function getAttributes
Browse files Browse the repository at this point in the history
  • Loading branch information
VictorS67 committed Jul 1, 2024
1 parent 1976eb8 commit fbff238
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/core/src/studio/registration/nodes.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { load } from '../../load/index.js';
import { globalImportMap, globalSecretMap } from '../../load/registration.js';
import { type Serializable } from '../../load/serializable.js';
import { type NodeImpl } from '../nodes/base.js';
import { type SerializableNode } from '../nodes/index.js';
Expand Down Expand Up @@ -261,7 +263,7 @@ export class NodeRegistration<
* @returns A new node implementation instance.
* @throws an error if the node's type-subtype pair is unknown.
*/
createImpl<T extends Nodes>(node: T): NodeImpl<T> {
async createImpl<T extends Nodes>(node: T): Promise<NodeImpl<T>> {
const key = [node.type, node.subType].join('-');

const nodeImpl = this.info[key] as {
Expand All @@ -276,6 +278,9 @@ export class NodeRegistration<

const { impl: Impl } = nodeImpl;

const data = await load<Serializable>(JSON.stringify(node.data), globalSecretMap, globalImportMap);
node.data = data;

const newNodeImpl = new Impl(node as any) as unknown as NodeImpl<T>;

if (!newNodeImpl) {
Expand Down Expand Up @@ -340,7 +345,7 @@ export class NodeRegistration<
* @throws An error if no implementation is registered for the node's type and subtype.
* @returns An instance of `NodeImpl` for the given node, enabling further interaction and processing.
*/
createDynamicImpl(node: SerializableNode): NodeImpl<SerializableNode> {
async createDynamicImpl(node: SerializableNode): Promise<NodeImpl<SerializableNode>> {
const { type, subType } = node;
const implClass = this.dynamicImplsMap[`${type}-${subType}`];
if (!implClass) {
Expand All @@ -349,6 +354,9 @@ export class NodeRegistration<
);
}

const data = await load<Serializable>(JSON.stringify(node.data), globalSecretMap, globalImportMap);
node.data = data;

const newNodeImpl = new implClass.impl(node);
if (!newNodeImpl) {
throw new Error(
Expand Down

0 comments on commit fbff238

Please sign in to comment.