Skip to content

feat(core): implement Thing-level data schema mapping extraction#1499

Merged
danielpeintner merged 14 commits intoeclipse-thingweb:masterfrom
siddharthbaleja7:feat/data-schema-mapping
Mar 5, 2026
Merged

feat(core): implement Thing-level data schema mapping extraction#1499
danielpeintner merged 14 commits intoeclipse-thingweb:masterfrom
siddharthbaleja7:feat/data-schema-mapping

Conversation

@siddharthbaleja7
Copy link
Contributor

@siddharthbaleja7 siddharthbaleja7 commented Feb 23, 2026

Fixes #1411

This PR implements the experimental nw:dataSchemaMapping feature at the Thing-level, allowing developers to extract specific nested values from Thing responses using dot-notation or JSON pointers.

As discussed with the maintainers, this feature strictly targets Thing responses (readProperty, invokeAction outputs, and subscribeEvent emissions). Input payloads are unaffected.

Key Implementation Details:

  • Order of Operations: Extraction occurs after content deserialization but before JSON Schema validation inside interaction-output.ts.
  • Servient-Level Injection: Added dataSchemaMapping to the Servient configuration. If a consumed/produced Thing Description lacks a mapping, the Servient's default mapping is automatically injected.
  • Typings: Added @experimental tags to all nw: prefixed types in thing-description.ts.
  • Zero Dependencies: Parsing logic is isolated inside helpers.ts without relying on external libraries.
  • Strict Typing: All type casting is safely handled natively without relying on eslint-disable any casting.

Testing

  • Added 20+ Unit Tests in server-test.ts and client-test.ts verifying extraction logic, overriding precedence, and error handling.
  • Ran and passed all 136 core tests (npm run test -w packages/core).
  • Passed extreme strict verification (npm run lint --workspaces and npm run test:browser locally).

Documentation

  • Added an "Experimental Features: Data Mapping per Thing" section to the main README.md.

Copy link
Member

@danielpeintner danielpeintner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have some minor comments/suggestions.
Please let me know whether they make sense..

Comment on lines +167 to +168
synchronous?: boolean,
mapping?: DataSchemaMapping
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: I wonder whether we should keep the order of the arguments more consistent..
In handleActionInteractionOutput(...) we used to have synchronous after mapping. We could do the same here

relu91 and others added 2 commits March 3, 2026 15:24
Co-authored-by: danielpeintner <daniel.peintner@gmail.com>
@relu91
Copy link
Member

relu91 commented Mar 3, 2026

@danielpeintner done, if everything looks good, please go ahead and merge this.

@danielpeintner
Copy link
Member

Thanks @siddharthbaleja7 @relu91

@danielpeintner danielpeintner merged commit 45d3cfb into eclipse-thingweb:master Mar 5, 2026
14 checks passed
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.

Adding Data Mapping per Thing

3 participants