Type resource edit payloads for editResourceData#11
Conversation
editResourceData (core, window.TagoIO, useEditResourceData) now takes TResourceEditInput, the device/user/entity shapes the platform accepts, instead of the data-record TDataRecordInput, which required `variable` and never matched the resource endpoint. Wire format is unchanged. Adds the edit-resource.tsx example with editable-column inline editing and documents the three payload shapes.
|
Companion host fix: tago-io/admin#5014 (edit-resource key echo + isEntity routing). |
|
Approve In this PRImprovements
Praise
Risk (CIA)Likelihood: 🟢 Low | Impact: 🟢 Low | Exposure: 🟢 Low. |
view/editable address tag and parameter columns as `tags.<key>` /
`param.<key>`, but rows carry `tags`/`params` as arrays of key-value
pairs, so those columns never matched row keys and no editable cell
rendered. Derive columns from view/editable too, resolve their values
from the arrays, and send edits with the dotted key. Adds
TResourceEntityListEdit ({ entity, ...fields }) since entity_list rows
are entities themselves, guards editing when the row identity is
missing, and hoists refresh out of the per-cell hook.
|
Approve In this PRPayload comparison against the Admin native widgets (source of truth on
Questions
Improvements
Praise
Risk (CIA)Likelihood: 🟢 Low | Impact: 🟢 Low | Exposure: 🟢 Low. |
Entity_list rows have no edit support on the platform, so remove the TResourceEntityListEdit shape and block editing those rows in the example instead of sending a payload the backend rejects.
Entity Management keeps numbers for numeric columns, so the edit example now coerces the draft back to a number when the current cell holds one, instead of always sending strings. Device and user values stay strings, matching the native widgets.
|
Approve Praise
Risk (CIA)Likelihood: 🟢 Low | Impact: 🟢 Low | Exposure: 🟢 Low. |
Summary
editResourceDataexisted end to end but was typed asTDataRecordInput, a data-point shape that requiresvariableand cannot express what the resource endpoint accepts. This types the edit payloads asTResourceEditInput—{ device, ...fields },{ user, ...fields }, and{ id, entity, ...fields }for entity data rows — across core,window.TagoIO, anduseEditResourceData, adds anedit-resource.tsxexample with inline editing driven by the resource'seditablecolumns, and documents the shapes. Tag and parameter columns (tags.<key>/param.<key>inview/editable) are resolved from the row'stags/paramsarrays and edited with the dotted key, matching how native widgets address them. Entity_list rows have no platform edit support, so the example blocks editing them. Compile-time-only change; the wire format is unchanged.Test plan
vp run build,vp run check:types,vp checkall greenvp test: 167 pass, including new payload assertions per shape inpackages/core/tests/store/widget-store.test.ts, avariablesassertion inpackages/react/tests/hooks/use-mutation-hooks.test.tsx, and a neweditResourceDatadescribe inpackages/js/src/custom-widget.test.tsproving verbatim pass-through with autoFill enabledview/editable) — edited a devicename, a devicetags.device_type, a userphone, and an entitystatus; promises settled via the echoedkey, edits persisted acrossrefreshResources(), and entity_list cells render read-onlyBreaking changes
None at runtime. TypeScript consumers passing the old (incorrect)
TDataRecordInputshape will get compile errors; that shape was never accepted by the resource endpoint.Risk (CIA)
Likelihood: 🟢 Low | Impact: 🟢 Low | Exposure: 🟢 Low
Related
Companion host fix so the edit-resource response settles the SDK promise and entity edits route to the entity endpoint: tago-io/admin#5014