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

"links" si no more allowed as PropertyMetadata #147

Open
cescobaz opened this issue Sep 3, 2021 · 1 comment
Open

"links" si no more allowed as PropertyMetadata #147

cescobaz opened this issue Sep 3, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@cescobaz
Copy link

cescobaz commented Sep 3, 2021

Hello,

I created some Things for my Raspberry and every was working fine with version 0.13.0.
I just updated to 0.15.0 and I get the following:

/home/pi/webthing-home/node_modules/ajv/dist/compile/index.js:119
        throw e;
        ^

Error: strict mode: unknown keyword: "links"
    at Object.checkStrictMode (/home/pi/webthing-home/node_modules/ajv/dist/compile/validate/index.js:183:15)
    at Object.checkUnknownRules (/home/pi/webthing-home/node_modules/ajv/dist/compile/util.js:32:24)
    at checkKeywords (/home/pi/webthing-home/node_modules/ajv/dist/compile/validate/index.js:118:12)
    at Object.validateFunctionCode (/home/pi/webthing-home/node_modules/ajv/dist/compile/validate/index.js:14:9)
    at Ajv.compileSchema (/home/pi/webthing-home/node_modules/ajv/dist/compile/index.js:79:20)
    at Ajv._compileSchemaEnv (/home/pi/webthing-home/node_modules/ajv/dist/core.js:446:37)
    at Ajv.compile (/home/pi/webthing-home/node_modules/ajv/dist/core.js:141:38)
    at new Property (/home/pi/webthing-home/node_modules/webthing/lib/property.js:30:29)
    at makeVideoCameraHLS (/home/pi/webthing-home/src/lib/video-camera.js:78:5)
    at createServer (/home/pi/webthing-home/src/raspi-1-server.js:19:39)

The code that raises the error is the following:

  const imageValue = new Value(null)
  thing.addProperty(
    new Property(thing, 'image', imageValue, {
      '@type': 'ImageProperty',
      title: 'Snapshot',
      links: [{ rel: 'alternate', mediaType: 'image/jpeg', href: `/media/${imageFilename}` }],
      readOnly: true
    }))

I read the lib code and I notice that there is a ajv validation of metadata ( https://github.com/WebThingsIO/webthing-node/blob/master/lib/property.ts#L55 ) and some attributes are deleted and never read ( https://github.com/WebThingsIO/webthing-node/blob/master/lib/property.ts#L54 ), why?

I can't understand: PropertyMetadata interface let you write links field ( https://github.com/WebThingsIO/webthing-node/blob/master/lib/property.ts#L172 ).
Metadata must be a JSONSchema or a PropertyMetadata object? How can I set links property for my Raspberry camera?

( My complete code here https://github.com/cescobaz/webthing-home )

Many thanks

@0815fox
Copy link

0815fox commented Oct 8, 2021

Action metadata seems to be incomplete too. At least unit and properties (for objects) are missing on ActionMetadata.input. At least https://webthings.io/api/#example-action-object suggests, that those should exist.

@benfrancis benfrancis added the bug Something isn't working label Oct 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants