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

Function applyActivities

packages/utils/src/schema.ts:126–160  ·  view source on GitHub ↗
(pivotSchema: IPublicTypeRootSchema, activities: any)

Source from the content-addressed store, hash-verified

124 * @deprecated
125 */
126export function applyActivities(pivotSchema: IPublicTypeRootSchema, activities: any): IPublicTypeRootSchema {
127 let schema = { ...pivotSchema };
128 if (!Array.isArray(activities)) {
129 activities = [activities];
130 }
131 return activities.reduce((accSchema: IPublicTypeRootSchema, activity: any) => {
132 if (activity.type === ActivityType.MODIFIED) {
133 const found = getNodeSchemaById(accSchema, activity.payload.schema.id);
134 if (!found) return accSchema;
135 Object.assign(found, activity.payload.schema);
136 } else if (activity.type === ActivityType.ADDED) {
137 const { payload } = activity;
138 const { location, schema } = payload;
139 const { parent } = location;
140 const found = getNodeSchemaById(accSchema, parent.nodeId);
141 if (found) {
142 if (Array.isArray(found.children)) {
143 found.children.splice(parent.index, 0, schema);
144 } else if (!found.children) {
145 found.children = [schema];
146 }
147 // TODO: 是 JSExpression / DOMText
148 }
149 } else if (activity.type === ActivityType.DELETED) {
150 const { payload } = activity;
151 const { location } = payload;
152 const { parent } = location;
153 const found = getNodeSchemaById(accSchema, parent.nodeId);
154 if (found && Array.isArray(found.children)) {
155 found.children.splice(parent.index, 1);
156 }
157 }
158 return accSchema;
159 }, schema);
160}

Callers 1

schema.test.tsFile · 0.90

Calls 3

getNodeSchemaByIdFunction · 0.85
reduceMethod · 0.65
spliceMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…