MCPcopy Index your code
hub / github.com/alibaba/lowcode-engine / export

Method export

packages/designer/src/document/node/node.ts:947–994  ·  view source on GitHub ↗

* 导出 schema

(stage: IPublicEnumTransformStage = IPublicEnumTransformStage.Save, options: any = {})

Source from the content-addressed store, hash-verified

945 * 导出 schema
946 */
947 export<T = IPublicTypeNodeSchema>(stage: IPublicEnumTransformStage = IPublicEnumTransformStage.Save, options: any = {}): T {
948 stage = compatStage(stage);
949 const baseSchema: any = {
950 componentName: this.componentName,
951 };
952
953 if (stage !== IPublicEnumTransformStage.Clone) {
954 baseSchema.id = this.id;
955 }
956 if (stage === IPublicEnumTransformStage.Render) {
957 baseSchema.docId = this.document.id;
958 }
959
960 if (this.isLeaf()) {
961 if (!options.bypassChildren) {
962 baseSchema.children = this.props.get('children')?.export(stage);
963 }
964 return baseSchema;
965 }
966
967 const { props = {}, extras } = this.props.export(stage) || {};
968 const _extras_: { [key: string]: any } = {
969 ...extras,
970 };
971 /* istanbul ignore next */
972 Object.keys(this._addons).forEach((key) => {
973 const addon = this._addons[key];
974 if (addon) {
975 if (addon.isProp) {
976 (props as any)[getConvertedExtraKey(key)] = addon.exportData();
977 } else {
978 _extras_[key] = addon.exportData();
979 }
980 }
981 });
982
983 const schema: any = {
984 ...baseSchema,
985 props: this.document.designer.transformProps(props, this, stage),
986 ...this.document.designer.transformProps(_extras_, this, stage),
987 };
988
989 if (this.isParental() && this.children && this.children.size > 0 && !options.bypassChildren) {
990 schema.children = this.children.export(stage);
991 }
992
993 return schema;
994 }
995
996 /**
997 * 判断是否包含特定节点

Callers 4

wrapWithMethod · 0.95
replaceWithMethod · 0.95
schemaMethod · 0.95
toDataMethod · 0.95

Calls 8

isLeafMethod · 0.95
isParentalMethod · 0.95
getConvertedExtraKeyFunction · 0.90
compatStageFunction · 0.85
exportMethod · 0.65
getMethod · 0.65
forEachMethod · 0.65
transformPropsMethod · 0.65

Tested by

no test coverage detected