
Product
Socket Firewall Now Blocks Malicious VS Code and Open VSX Extensions
Socket Firewall blocks malicious VS Code and Open VSX extensions before install, protecting developers from compromised editor marketplaces.
@thing-description-playground/cli
Advanced tools
Provides a Command Line Interface for the Web of Things - Thing Description Playground.
This package provides a Command Line Interface (CLI) for the Web of Things Playground. You can find more information about the Thingweb-Playground here.
You can validate whether one, or several given TDs are valid.
Furthermore you can generate an assertion test report (-a) to see which assertions are implemented in your TD.
For more information on the usage of the CLI, please use --help parameter or look at the last section of this readme. Most parameters can be mixed (e.g.
-a -c -n) will output an Assertion report, in json and not csv and seperately for every given TD not merged.
But keep in mind, that assertion parameters won't have any effect on the normal validation.
Licensed under the MIT license, see License.
This is a Node.js based tool.
core package as an API to validate TDs in your own packages.assertion package to integrate assertion testing via an API in your own packages.web package to host/adapt your own browser version of the WoT playground.node index.js "./node_modules/@thing-description-playground/core/examples/tds/valid/actionReponse.json" to validate a Thing Description found at './node_modules/@thing-description-playground/core/examples/tds/valid/actionReponse.json'. You can replace this with a TD you want to validate.297 out of 349 assertions of the TD specification can be tested with this tool.
This tool checks which assertions are satisfied by a given Thing Description(s). The assertions are modeled as JSON Schema or as scripts. 'assertions/assertions' has the JSON Schema assertions. To use this tool (node index.js can be replaced by npm start):
npm install @thing-description-playground/cli (or clone repo and install the package with npm install)cli directorynode index.js -i ./node_modules/@thing-description-playground/core/examples/tds/valid/JsonLdThing.json -a
node index.js -i inputTD.json -o outputResult -anode index.js -i inputTD.json secondTD.json tdFolder/node index.js -i ./node_modules/@thing-description-playground/core/examples/tds/valid/--assertion-no-merge parameter -n is set, then a report for every Td is created)
_ before the last word. This means that this assertion is a sub assertion of a parent assertion. For example, td-actions assertion required the existence of action interaction in the TD and also the uniqueness of the names of actions. Because of this, there will be two assertions generated in the results with following names: td-actions_existence and td-actions_uniqueness.node index.js ./out/result-urn:another.csv ./out/result-urn:dev:wot:com:example:servient:lamp.csv -a
node index.js and before -anode index.js ./out/ -anode index.js results.csv -a which will output a list to the std output indicating how many assertions passed, failed or not implementedWARNING: If you see an error like ajv.errors[0].params.allowedValue this very probably means that your TD is not valid at a specific point. Scroll up to see the precise error message
node index.js and give a folder as input, e.g., ./myDirvalid directory should be validinvalid directory should be invalid, giving an error in at least one checkwarning directory should give at least one warning in a check but should be valid at the same time./myDir foldernode index.js -i inputTD.json secondTD.json tdFolder/
Even though it is not recommended, mixing TDs located directly in the directory and subdirectories of the above structure, is possible.The core validation report is an object, which contains three objects (as you can see in the example report):
{
report: {
json: "passed",
schema: "passed",
defaults: "warning",
jsonld: null,
additional: "failed"
},
details: {
enumConst: "passed",
propItems: "warning",
security: "passed",
propUniqueness: "passed",
multiLangConsistency: "failed"
},
detailComments: {
enumConst: "Checking whether a data schema has enum and const at the same time.",
propItems: "Checking whether a data schema has an object but not properties or array but no items.",
security: "Check if used Security definitions are properly defined previously.",
propUniqueness: "Checking whether in one interaction pattern there are duplicate names, e.g. two properties called temp.",
multiLangConsistency: "Checks whether all titles and descriptions have the same language fields."
}
}
report object contains the results of the default validation. It is structure with a keyword and the value null, "passed", "warning" or "failed". Where null is used if the test was not executed, which can happen either because it was opted out or a previous check failed. The keywords are:
details object contains the results of the additional checks. The keywords can have the same values as in report.detailComments explains the meaning of every additional check.'--help -h': { /* Display the output specified by this object */
type: 'string',
description: 'For TD Playground core validation you can call the playground validation with no input (example folder will be taken), \n'+
'a Thing Description (.json file), a folder with multiple Thing Descriptions, \n' +
'or a Folder with "valid", "invalid" and "warning" subfolder, where all included TDs \n' +
'will be checked whether they produce the expected validation result.' +
'Multiple inputs can also be provided after using the input flag' +
'Use the -a parameter for assertions testing.'
},
'--type -t *': {
type: 'string',
choices: ['TD', 'TM', 'AUTO'],
description: 'Type of document to take as input. AUTO not implemented yet'
},
'--input -i *': {
type: 'string',
description: 'The file or the folder containing the files, which will be validated. Multiple inputs can be provided.'
},
'--nojsonld -j': {
type: 'boolean',
description: 'Turn off the JSON-LD validation (for example because internet connection is not available).'
},
'--nodefaults -d': {
type: 'boolean',
description: 'Turn off the Full JSON Schema validation, which checks e.g. for default values being explicitly set.'
},
'--assertions -a': {
type: 'boolean',
description: 'Call the assertion report instead of the core validation, \n' +
'if files with .csv ending are given as input merging assertion reports is done.'
},
'--assertion-out -o': {
type: 'string',
description: 'Path and filename of the generated assertions report (defaults to ./out/[.]assertionsTest[_$input]). \n' +
'Please notice that the folders you specify as target already have to exist.'
},
'--assertion-nomerge -n': {
type: 'boolean',
description: 'if multiple files where given as input, don\'t create a merged report, but one for each'
},
'--assertion-tostd -s': {
type: 'boolean',
description: 'output the report(s) as stdout and don\'t write them to a file'
},
'--assertion-nocsv -c': {
type: 'boolean',
description: 'return assertion report(s) in json format instead of csv'
},
'--assertion-manual -m': {
type: 'string',
description: 'path and filename to manual.csv file'
},
'--open-api -p': {
type: 'boolean',
description: 'Call the openAPI instance generation instead of validation/assertions.'
},
'--oap-yaml -y': {
type: 'string',
description: 'Whether openAPI should be written as YAML instead of json.'
},
'--default-add': {
type: 'boolean',
description: 'Whether the input TD should be extended by default values.'
},
'--default-rem': {
type: 'boolean',
description: 'Whether the input TD should be reduced by default values.'
}
FAQs
Provides a Command Line Interface for the Web of Things - Thing Description Playground.
The npm package @thing-description-playground/cli receives a total of 8 weekly downloads. As such, @thing-description-playground/cli popularity was classified as not popular.
We found that @thing-description-playground/cli demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket Firewall blocks malicious VS Code and Open VSX extensions before install, protecting developers from compromised editor marketplaces.

Research
More than 140 Mastra npm packages were compromised in a supply chain attack that used a typosquatted dependency to deliver a cross-platform infostealer during installation.

Research
/Security News
A new npm package tests AI malware scanners with prompt injection, safety-triggering comments, context flooding, and obfuscated JavaScript.