Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

propagate CompositionOptions to fetchAffordances and _getPartialTDs #57

Merged
merged 3 commits into from
Mar 17, 2025

Conversation

dvalnn
Copy link
Contributor

@dvalnn dvalnn commented Mar 10, 2025

Change ThingModelHelpers.fetchAffordances() to take CompositionOptions as input and propagate them to successive _getPartialTDs calls.

This allows for correct replacement of placeholders via the CompositionOptions map in Thing Models fetched via fetchAffordances.

Example use case:

Base thing model with placeholders

{
    "@context": [
        "https://www.w3.org/2022/wot/td/v1.1"
    ],
    "@type": "tm:ThingModel",
    "title": "base_thing",
    "version": {
        "model": "0.0.1"
    },
    "id": "urn:uuid:{{THING_UUID_V4}}",
    "description": "The most basic thing",
    "securityDefinitions": {
        "nosec_sc": {
            "scheme": "nosec"
        }
    }
}

Another thing model that extends the base thing model

{
    "@context": [
        "https://www.w3.org/2022/wot/td/v1.1"
    ],
    "@type": "tm:ThingModel",
    "title": "extended_thing",
    "version": {
        "model": "0.0.1"
    },
    "description": "Extends the base thing with some properties",
    "links": [{
        "rel": "tm:extends",
        "href": "file://./test/thing-model/tmodels/placeholderExtension/BaseThingWithPlaceholder.tm.jsonld",
        "type": "application/tm+json"
    }],
    "properties": {
        "some_property": {
            "type": "string",
            "description": "Some property",
            "forms": [{
                "href": "mqtt://{{MQTT_BROKER_ADDR}}",
                "mqv:topic": "{{THING_MODEL}}/{{THING_UUID_V4}}/properties/some_property",
                "op": "observeproperty",
                "mqv:qos": 1,
                "mqv:retain": false,
                "contentType": "application/json"
            }]
        }
    }
}

map:

const map = {
    THING_MODEL: "extended_thing",
     THING_UUID_V4: "bf2c24bc-9232-454d-ac17-90feb3647b71",
     MQTT_BROKER_ADDR: "example.org:1883"
 }

In this scenario, given a valid map, the current implementation will fail to correctly instantiate the partial Thing Description for the "extended_thing" model, as the composition options are not propagated by fetchAffordances() to the following _getPartialTDs() calls.

Copy link
Member

@relu91 relu91 left a comment

Choose a reason for hiding this comment

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

Thank you @dvalnn, changes look good. Just two things left:

@danielpeintner @egekorkan we should a Contributing.md file here too.

@dvalnn
Copy link
Contributor Author

dvalnn commented Mar 11, 2025

I have no problem signing the ECA, its just that Eclipse for some reason does not support "." in emails?
Seems like the sign-up page is broken at the moment...
image

@dvalnn dvalnn closed this Mar 11, 2025
@dvalnn dvalnn reopened this Mar 11, 2025
@dvalnn
Copy link
Contributor Author

dvalnn commented Mar 11, 2025

In the meantime, I squashed and reworded the commits so if everything looks good, I'll just wait for feedback regarding the ECA issue.

@relu91
Copy link
Member

relu91 commented Mar 11, 2025

Thank you! to be honest, this is the first time we see that. I have an email containing a "." too. Maybe, it is just some recent regression. We'll try to contact the webmaster. I'll let you know asap.

@relu91
Copy link
Member

relu91 commented Mar 13, 2025

@dvalnn I still have not received a response from the eclipse webmaster, but I tried to create a new account with [email protected], and it worked. Can you try again? maybe it was just some temporary issue...

@dvalnn
Copy link
Contributor Author

dvalnn commented Mar 15, 2025

I finally managed to sign the ECA (and create an account) by just suppressing the ".", from my email (which works the same as having the "." in it seems)
Just submitting my email address as normal was still throwing the same error for me.

@codecov-commenter
Copy link

codecov-commenter commented Mar 15, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.33%. Comparing base (a6943fa) to head (3490c5f).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #57      +/-   ##
==========================================
+ Coverage   65.23%   69.33%   +4.10%     
==========================================
  Files           1        1              
  Lines         558      300     -258     
  Branches      224       79     -145     
==========================================
- Hits          364      208     -156     
+ Misses        155       70      -85     
+ Partials       39       22      -17     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@relu91
Copy link
Member

relu91 commented Mar 16, 2025

Ok we are almost there, can you run priettier? Thanks!

Copy link
Member

@egekorkan egekorkan left a comment

Choose a reason for hiding this comment

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

Looks good! Should we bump the version already?

@relu91
Copy link
Member

relu91 commented Mar 17, 2025

we can do it later

@relu91 relu91 merged commit efda55c into eclipse-thingweb:main Mar 17, 2025
6 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.

4 participants