Skip to content

Fix RemoveDataItem on nested paths without context and PostData for object types#625

Draft
Copilot wants to merge 2 commits intomasterfrom
copilot/feature-support-complex-nested-objects
Draft

Fix RemoveDataItem on nested paths without context and PostData for object types#625
Copilot wants to merge 2 commits intomasterfrom
copilot/feature-support-complex-nested-objects

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 4, 2026

Drapo's data manipulation functions broke down when used with complex nested objects as a single source of truth: RemoveDataItem silently failed on nested array paths without a d-for context, and PostData wrapped object-type data in {Entities: ...} instead of posting the raw object graph.

Changes

DrapoFunctionHandler.tsExecuteFunctionRemoveDataItem

  • When contextItem is null and the source is a nested mustache path (mustacheParts.length > 1, e.g. {{workflowprocess.Items}}), now resolves the item via ResolveItemDataPathObject and calls DeleteDataItem with the full path
  • Previously called DeleteDataItemArray unconditionally, which iterates dataItem.Data.lengthundefined for an object type — so the loop never ran and the deletion silently returned false
  • Flat-array removals without context (RemoveDataItem({{values}}, 4)) are unaffected

DrapoStorage.tsPostData

  • For non-UnitOfWork, non-array (object) data items, now posts dataItem.Data directly instead of {Entities: dataItem.Data}
  • Array data items continue to post {Entities: [...]} and UnitOfWork items post {Inserted/Updated/Deleted} as before
  • Aligns PostData with PostDataItem semantics for object types
// Previously failed silently — contextItem is null, DeleteDataItemArray can't navigate nested paths
await app.FunctionHandler.ResolveFunctionWithoutContext(
    sector, el,
    `RemoveDataItem({{workflowprocess.Items}}, {{selectedItem}})`
);

// PostData now sends the full nested graph directly, not wrapped in {Entities: ...}
await app.FunctionHandler.ResolveFunctionWithoutContext(sector, el, `PostData(workflowprocess)`);

Tests Added

  • FunctionRemoveDataItemMustacheWithoutContext — startup adds an item without cloning (preserving reference), button click removes it via nested path without context; validates [John, Mary, Thiago] after removal
  • FunctionPostDataObjectNested — round-trips a nested object (Code, Name, Items[]) through a new SetFunctionPostDataObjectNested endpoint; validates the server receives and mutates the raw object

Copilot AI changed the title [WIP] Add support for complex nested objects in data functions Fix RemoveDataItem on nested paths without context and PostData for object types Apr 5, 2026
Copilot AI requested a review from silvath April 5, 2026 00:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: PostData and data manipulation functions should support complex nested objects as the single source of truth

2 participants