Skip to content

Commit a56e526

Browse files
committed
filter out nodeinfo properties that are used for configuration in the serialize cleanup method
1 parent 997224d commit a56e526

File tree

2 files changed

+50
-13
lines changed

2 files changed

+50
-13
lines changed

libs/visual-programming-system/src/types/base-node-info.ts

Lines changed: 45 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,37 +69,70 @@ export interface INodeDecorator {
6969
};
7070
}
7171

72-
export interface BaseNodeInfo {
73-
taskType?: string;
74-
type?: string;
75-
compositionId?: string;
76-
isComposition?: boolean;
72+
// These also contain properties from NodeInfo (which is a superset of BaseNodeInfo)..
73+
// TODO : move that and have some sort of registration construction so that it can be
74+
// used dynamically by the serialization proces
75+
export interface BaseSettingsNodeInfo {
7776
useInCompositionOnly?: boolean;
7877
nodeCannotBeReplaced?: boolean;
7978
isAnnotation?: boolean;
8079
canBeStartedByTrigger?: boolean;
8180
readPropertyFromNodeInfoForInitialTrigger?: string;
8281
keepPopupOpenAfterUpdate?: boolean;
8382
supportsPreview?: boolean;
83+
showFormOnlyInPopup?: boolean;
84+
isSettingsPopup?: boolean;
85+
hasNoFormPopup?: boolean;
86+
meta?: AllMetaFieldTypes[];
87+
metaInputs?: AllMetaFieldTypes[];
88+
canvasAppInstance?: IFlowCanvasBase<BaseNodeInfo>;
89+
initializeOnStartFlow?: boolean;
90+
isVariable?: boolean;
91+
isUINode?: boolean;
92+
supportsDecorators?: boolean;
93+
}
94+
const baseSettingsNodeInfoSchema: Record<keyof BaseSettingsNodeInfo, boolean> =
95+
{
96+
useInCompositionOnly: true,
97+
nodeCannotBeReplaced: true,
98+
isAnnotation: true,
99+
canBeStartedByTrigger: true,
100+
readPropertyFromNodeInfoForInitialTrigger: true,
101+
keepPopupOpenAfterUpdate: true,
102+
supportsPreview: true,
103+
showFormOnlyInPopup: true,
104+
isSettingsPopup: true,
105+
hasNoFormPopup: true,
106+
meta: true,
107+
metaInputs: true,
108+
canvasAppInstance: true,
109+
initializeOnStartFlow: true,
110+
isVariable: true,
111+
isUINode: true,
112+
supportsDecorators: true,
113+
};
114+
115+
export const baseSettingsNodeInfoProperties = Object.keys(
116+
baseSettingsNodeInfoSchema
117+
) as (keyof BaseSettingsNodeInfo)[];
118+
119+
export interface BaseNodeInfo extends BaseSettingsNodeInfo {
120+
taskType?: string;
121+
type?: string;
122+
compositionId?: string;
123+
isComposition?: boolean;
84124
cancelPreview?: () => void;
85125
outputConnectionInfo?: {
86126
text: string;
87127
fieldName: string;
88128
form?: any[];
89129
onChanged?: (connection: IConnectionNodeComponent<BaseNodeInfo>) => void;
90130
};
91-
canvasAppInstance?: IFlowCanvasBase<BaseNodeInfo>;
92131

93132
initializeCompute?: () => void;
94-
showFormOnlyInPopup?: boolean;
95-
isSettingsPopup?: boolean;
96-
hasNoFormPopup?: boolean;
97133
formElements?: any[];
98134
delete?: () => void;
99135
formValues?: any;
100136
decorators?: INodeDecorator[];
101137
update?: () => void;
102-
103-
meta?: AllMetaFieldTypes[];
104-
metaInputs?: AllMetaFieldTypes[];
105138
}

libs/visual-programming-system/src/utils/serialize.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ import {
33
IConnectionNodeComponent,
44
IRectNodeComponent,
55
} from '../interfaces';
6-
import { BaseNodeInfo } from '../types/base-node-info';
6+
import {
7+
BaseNodeInfo,
8+
baseSettingsNodeInfoProperties,
9+
} from '../types/base-node-info';
710

811
export const cleanupNodeInfoForSerializing = <T extends BaseNodeInfo>(
912
nodeInfo: T | undefined
@@ -12,6 +15,7 @@ export const cleanupNodeInfoForSerializing = <T extends BaseNodeInfo>(
1215
if (nodeInfo) {
1316
for (const key in nodeInfo) {
1417
if (
18+
!baseSettingsNodeInfoProperties.find((item) => item === key) &&
1519
typeof (nodeInfo as any)[key] !== 'function' &&
1620
key !== 'formElements' &&
1721
key !== 'canvasAppInstance' &&

0 commit comments

Comments
 (0)