Zwing Docs

Task tree

Parent-child event tasks, validation, sync linearity, ACS tree builder, and DIP import/export

Data model

Event tasks (EventTaskModel) belong to exactly one connector–event mapping via connectorEventMappingId. The tree is encoded with:

  • parentId — null for the root task; otherwise references another task’s _id in the same mapping.
  • type — pipeline step kind (enrich, transform, filter, mapping, dispatch, extract, http); see Task types reference.
  • config — type-specific JSON payload.
  • continueOnFailure — whether downstream steps still run after a failure.

The mapping document stores an ordered list of tasks (ObjectId references) for quick access; the authoritative structure is the parentId graph on the task documents.

Validation rules (TaskTreeValidator in @libs/dip-v2)

RuleMeaning
Single rootExactly one task with parentId null/undefined.
No orphansEvery non-null parentId must point to another task in the same mapping set.
No cyclesFollowing parent pointers must not loop (detectCycles).

ACS uses an additional helper CycleDetector when mutating parent links to reject edits that would introduce a cycle before persistence.

Sync API: linear chain only

POST /ingress/sync enforces stricter rules than async ingress:

  • At most one connector–event mapping may apply to the inbound event; otherwise the request fails with a clear error (request-handler.ts).
  • Tasks must pass validateLinearTaskChainForSync: after standard tree validation, each parent may have at most one child (no branching). If the tree forks, sync responds with an error such as Sync API can't be used where task structure is not linear.

Async POST /ingress can process multiple mappings and branched trees, subject to egress execution capabilities.

Building a tree in the DIP UI

  1. Create or edit a connector–event mapping and open the task editor (task list + graph).
  2. Add the root task first (parentId empty).
  3. Add children pointing to their parent task id; the graph (TaskGraph) reflects parent/child edges.
  4. Save through ACS so server-side validation runs.

Maximum depth can be reasoned about with TaskTreeBuilder.calculateMaxDepth (used for limits or diagnostics where implemented).

ACS TaskTreeBuilder

Server-side utility that turns a flat EventTaskDocument[] into a nested TaskTreeNode (single root with children[]). It assumes a valid tree; if multiple roots exist, the builder overwrites rootNode and the last root wins—rely on TaskTreeValidator.validate before persisting, not on the builder, to catch invalid shapes.

Import and export (task-tree-import-export.ts)

The console can export a JSON envelope:

  • format: g1-dip-task-tree
  • version: 1
  • exportedAt: ISO timestamp
  • tasks: array of task form rows (including _id, parentId, type, config, optional layout position)

Import validates basic shape (_id, name, type), normalizes parentId, and runs the same parent-id checks as create flows (validateTasksHaveParentIds, validateAllTasksHaveValidData from utility/connectors.ts).

Use this to clone pipelines across environments or mappings without manual re-entry.

Edit on GitHub