Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4,018 changes: 2,230 additions & 1,788 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"@types/mocha": "^9.0.0",
"@types/node": "16.4.13",
"@types/readable-stream": "^2.3.13",
"@types/sinon": "^10.0.2",
"@types/sinon": "10.0.2",
"@typescript-eslint/eslint-plugin": "^4.30.0",
"@typescript-eslint/parser": "^4.30.0",
"c8": "^7.11.0",
Expand All @@ -69,7 +69,7 @@
"mocha": "^9.1.1",
"prettier": "^2.3.2",
"pretty-quick": "^3.1.1",
"sinon": "^11.1.1",
"sinon": "11.1.1",
"source-map-support": "^0.5.20",
"ts-loader": "8",
"ts-node": "10.1.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/binding-firestore/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@
"@testdeck/mocha": "^0.1.2",
"@types/chai": "^4.2.18",
"@types/chai-as-promised": "^7.1.4",
"@types/sinon": "^10.0.2",
"@types/sinon": "10.0.2",
"chai": "^4.3.4",
"chai-as-promised": "^7.1.1",
"firebase-admin": "^9.9.0",
"firebase-tools": "^9.17.0",
"kill-port": "^1.6.1",
"mocha": "^9.1.1",
"sinon": "^11.1.1",
"sinon": "11.1.1",
"ts-node": "10.1.0",
"typescript": "4.4.3",
"typescript-standard": "^0.3.36",
Expand Down
2 changes: 1 addition & 1 deletion packages/binding-http/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"query-string": "^7.1.1",
"rxjs": "5.5.11",
"slugify": "^1.4.5",
"wot-thing-description-types": "^1.1.0-20-July-2022"
"wot-thing-description-types": "^1.1.0-10-August-2022"
},
"scripts": {
"build": "tsc -b",
Expand Down
2 changes: 1 addition & 1 deletion packages/binding-mqtt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"aedes": "^0.46.2",
"mqtt": "^4.2.8",
"rxjs": "5.5.11",
"wot-thing-description-types": "^1.1.0-20-July-2022"
"wot-thing-description-types": "^1.1.0-10-August-2022"
},
"scripts": {
"build": "tsc -b",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"ts-node": "10.1.0",
"typescript": "4.4.3",
"typescript-standard": "^0.3.36",
"wot-thing-description-types": "^1.1.0-20-July-2022",
"wot-thing-description-types": "^1.1.0-10-August-2022",
"wot-typescript-definitions": "0.8.0-SNAPSHOT.23"
},
"optionalDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"ts-node": "10.1.0",
"typescript": "4.4.3",
"typescript-standard": "^0.3.36",
"wot-thing-description-types": "^1.1.0-20-July-2022",
"wot-thing-description-types": "^1.1.0-10-August-2022",
"wot-typescript-definitions": "^0.8.0-SNAPSHOT.23"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"ts-node": "10.1.0",
"typescript": "4.4.3",
"typescript-standard": "^0.3.36",
"wot-thing-description-types": "^1.1.0-20-July-2022",
"wot-thing-description-types": "^1.1.0-10-August-2022",
"wot-typescript-definitions": "0.8.0-SNAPSHOT.23"
},
"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/td-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
"is-absolute-url": "3.0.3",
"json-placeholder-replacer": "^1.0.35",
"url-toolkit": "2.1.6",
"wot-thing-description-types": "^1.1.0-20-July-2022",
"wot-thing-model-types": "^1.1.0-27-July-2022",
"wot-thing-description-types": "^1.1.0-10-August-2022",
"wot-thing-model-types": "^1.1.0-10-August-2022",
"wot-typescript-definitions": "0.8.0-SNAPSHOT.23"
},
"scripts": {
Expand Down
11 changes: 9 additions & 2 deletions packages/td-tools/src/thing-model-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,17 @@ export class ThingModelHelpers {
* @experimental
*/
public static getModelVersion(data: ThingModel): string | undefined {
if (!("version" in data) || !(data.version && "model" in data.version)) {
if (
"version" in data &&
data.version &&
typeof data.version === "object" &&
"model" in data.version &&
typeof data.version.model === "string"
) {
return data.version.model;
} else {
return undefined;
}
return data.version.model as string;
}

/**
Expand Down
40 changes: 20 additions & 20 deletions packages/td-tools/test/ThingModelHelperTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ThingModelHelperTest {

@test "should correctly validate tm schema with ThingModel in @type"() {
const model = {
"@context": ["http://www.w3.org/ns/td"],
"@context": ["https://www.w3.org/2022/wot/td/v1.1"],
title: "thingTest",
"@type": "tm:ThingModel",
properties: {
Expand All @@ -46,7 +46,7 @@ class ThingModelHelperTest {
@test "should correctly return the right links"() {
const thing = {
title: "thingTest",
"@context": ["http://www.w3.org/ns/td"],
"@context": ["https://www.w3.org/2022/wot/td/v1.1"],
"@type": "tm:ThingModel",
links: [
{
Expand All @@ -72,7 +72,7 @@ class ThingModelHelperTest {
@test "should correctly validate tm schema with ThingModel in @type array "() {
const model = {
title: "thingTest",
"@context": ["http://www.w3.org/ns/td"],
"@context": ["https://www.w3.org/2022/wot/td/v1.1"],
"@type": ["random:Type", "tm:ThingModel"],
properties: {
myProp: {
Expand All @@ -91,7 +91,7 @@ class ThingModelHelperTest {
@test "should reject schema on validation because missing ThingModel definition"() {
const model = {
title: "thingTest",
"@context": ["http://www.w3.org/ns/td"],
"@context": ["https://www.w3.org/2022/wot/td/v1.1"],
"@type": "random:Type",
links: [
{
Expand All @@ -115,7 +115,7 @@ class ThingModelHelperTest {
@test "should correctly return the model version"() {
let thing: ThingModel = {
title: "thingTest",
"@context": ["http://www.w3.org/ns/td"],
"@context": ["https://www.w3.org/2022/wot/td/v1.1"],
"@type": ["random:Type", "tm:ThingModel"],
version: { model: "0.0.1" }, // TODO: check is version is valid
};
Expand All @@ -126,7 +126,7 @@ class ThingModelHelperTest {

thing = {
title: "thingTest",
"@context": ["http://www.w3.org/ns/td"],
"@context": ["https://www.w3.org/2022/wot/td/v1.1"],
"@type": ["random:Type", "tm:ThingModel"],
version: {},
};
Expand All @@ -136,7 +136,7 @@ class ThingModelHelperTest {

thing = {
title: "thingTest",
"@context": ["http://www.w3.org/ns/td"],
"@context": ["https://www.w3.org/2022/wot/td/v1.1"],
"@type": ["random:Type", "tm:ThingModel"],
};

Expand All @@ -162,7 +162,7 @@ class ThingModelHelperTest {
const model = JSON.parse(modelJSON.toString()) as ThingModel;
const finalModel = {
"@type": "tm:ThingModel",
"@context": ["http://www.w3.org/ns/td"],
"@context": ["https://www.w3.org/2022/wot/td/v1.1"],
title: "Smart Lamp Control with Dimming",
links: [
{
Expand All @@ -187,7 +187,7 @@ class ThingModelHelperTest {
extends: [
{
"@type": "tm:ThingModel",
"@context": ["http://www.w3.org/ns/td"],
"@context": ["https://www.w3.org/2022/wot/td/v1.1"],
actions: {
toggle: { type: "boolean" },
},
Expand Down Expand Up @@ -216,7 +216,7 @@ class ThingModelHelperTest {
const thingModel: ThingModel = {
title: "thingTest",
"@type": ["random:Type", "tm:ThingModel"],
"@context": ["http://www.w3.org/ns/td"],
"@context": ["https://www.w3.org/2022/wot/td/v1.1"],
properties: {
timestamp1: {
"tm:ref": "file://./test/thing-model/tmodels/OnOff.jsonld#/properties/timestamp",
Expand All @@ -228,7 +228,7 @@ class ThingModelHelperTest {
const finalThingModel = {
title: "thingTest",
"@type": ["random:Type", "tm:ThingModel"],
"@context": ["http://www.w3.org/ns/td"],
"@context": ["https://www.w3.org/2022/wot/td/v1.1"],
properties: {
timestamp1: {
type: "number",
Expand All @@ -254,7 +254,7 @@ class ThingModelHelperTest {
@test async "should correctly import an action and add a field to the action"() {
const thingModel: ThingModel = {
title: "thingTest",
"@context": ["http://www.w3.org/ns/td"],
"@context": ["https://www.w3.org/2022/wot/td/v1.1"],
"@type": ["random:Type", "tm:ThingModel"],
actions: {
toggle1: {
Expand All @@ -274,7 +274,7 @@ class ThingModelHelperTest {

const finalThingModel = {
title: "thingTest",
"@context": ["http://www.w3.org/ns/td"],
"@context": ["https://www.w3.org/2022/wot/td/v1.1"],
"@type": ["random:Type", "tm:ThingModel"],
actions: {
toggle1: {
Expand All @@ -297,7 +297,7 @@ class ThingModelHelperTest {

@test async "should correctly fill placeholders"() {
const thing = {
"@context": ["http://www.w3.org/ns/td"],
"@context": ["https://www.w3.org/2022/wot/td/v1.1"],
"@type": "tm:ThingModel",
title: "Thermostate No. {{THERMOSTATE_NUMBER}}",
base: "mqtt://{{MQTT_BROKER_ADDRESS}}",
Expand All @@ -318,7 +318,7 @@ class ThingModelHelperTest {
THERMOSTATE_TEMPERATURE_OBSERVABLE: true,
};
const finalJSON = {
"@context": ["http://www.w3.org/ns/td"],
"@context": ["https://www.w3.org/2022/wot/td/v1.1"],
"@type": "Thing",
title: "Thermostate No. 4",
base: "mqtt://192.168.178.72:1883",
Expand Down Expand Up @@ -349,7 +349,7 @@ class ThingModelHelperTest {

@test async "should correctly fill placeholders with composed types"() {
const thing = {
"@context": ["http://www.w3.org/ns/td"],
"@context": ["https://www.w3.org/2022/wot/td/v1.1"],
"@type": "tm:ThingModel",
arrayField: "{{ARRAY}}",
title: "Thermostate No. 4",
Expand All @@ -360,7 +360,7 @@ class ThingModelHelperTest {
VERSION_INFO: { instance: "xyz", model: "ABC" },
};
const finalJSON = {
"@context": ["http://www.w3.org/ns/td"],
"@context": ["https://www.w3.org/2022/wot/td/v1.1"],
"@type": "Thing",
title: "Thermostate No. 4",
arrayField: ["random", "random1", "random2"],
Expand All @@ -383,7 +383,7 @@ class ThingModelHelperTest {

@test async "should correctly fill placeholders with composed types in strings"() {
const thing = {
"@context": ["http://www.w3.org/ns/td"],
"@context": ["https://www.w3.org/2022/wot/td/v1.1"],
"@type": "tm:ThingModel",
data: "data: {{ARRAY}}",
title: "Thermostate No. 4",
Expand All @@ -394,7 +394,7 @@ class ThingModelHelperTest {
VERSION_INFO: { instance: "xyz", model: "ABC" },
};
const finalJSON = {
"@context": ["http://www.w3.org/ns/td"],
"@context": ["https://www.w3.org/2022/wot/td/v1.1"],
"@type": "Thing",
title: "Thermostate No. 4",
data: "data: [1,2,3]",
Expand All @@ -417,7 +417,7 @@ class ThingModelHelperTest {

@test async "should reject fill placeholders because of missing fields in map"() {
const thing = {
"@context": ["http://www.w3.org/ns/td"],
"@context": ["https://www.w3.org/2022/wot/td/v1.1"],
"@type": "tm:ThingModel",
title: "Thermostate No. {{THERMOSTATE_NUMBER}}",
base: "mqtt://{{MQTT_BROKER_ADDRESS}}",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"@context": ["http://www.w3.org/ns/td"],
"@context": ["https://www.w3.org/2022/wot/td/v1.1"],
"@type": "tm:ThingModel",
"title": "Basic On/Off Thing Model",
"links": [],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"@context": ["http://www.w3.org/ns/td"],
"@context": ["https://www.w3.org/2022/wot/td/v1.1"],
"title": "Led Thing Model",
"@type": "tm:ThingModel",
"links": [
Expand Down Expand Up @@ -44,4 +44,4 @@
}
}
}
}
}
4 changes: 2 additions & 2 deletions packages/td-tools/test/thing-model/tmodels/Led.tm.jsonld
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"@context": ["http://www.w3.org/ns/td"],
"@context": ["https://www.w3.org/2022/wot/td/v1.1"],
"@type": "tm:ThingModel",
"title": "Led Thing Model",
"version": {
Expand Down Expand Up @@ -35,4 +35,4 @@
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"@context": ["http://www.w3.org/ns/td"],
"@context": ["https://www.w3.org/2022/wot/td/v1.1"],
"title": "Led Thing Model Extend",
"@type": "tm:ThingModel",
"links": [
Expand Down Expand Up @@ -56,4 +56,4 @@
"type": "boolean"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"@context": ["http://www.w3.org/ns/td"],
"@context": ["https://www.w3.org/2022/wot/td/v1.1"],
"@type": "tm:ThingModel",
"title": "Led Thing Model Extend",
"version": {
Expand Down Expand Up @@ -42,4 +42,4 @@
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"@context": ["http://www.w3.org/ns/td"],
"@context": ["https://www.w3.org/2022/wot/td/v1.1"],
"@type": "tm:ThingModel",
"title": "Led Thing Model Extend",
"version": {
Expand Down Expand Up @@ -42,4 +42,4 @@
}
}
}
}
}
2 changes: 1 addition & 1 deletion packages/td-tools/test/thing-model/tmodels/OnOff.jsonld
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"@context": ["http://www.w3.org/ns/td"],
"@context": ["https://www.w3.org/2022/wot/td/v1.1"],
"@type": "tm:ThingModel",
"title": "Basic On/Off Thing Model",
"properties": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"@type": "tm:ThingModel",
"@context": ["http://www.w3.org/ns/td"],
"@context": ["https://www.w3.org/2022/wot/td/v1.1"],
"title": "Smart Lamp Control with Dimming",
"links": [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"@context": ["http://www.w3.org/ns/td"],
"@context": ["https://www.w3.org/2022/wot/td/v1.1"],
"@type": "tm:ThingModel",
"title": "Smart Lamp Control with Dimming",
"links": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"@context": ["http://www.w3.org/ns/td"],
"@context": ["https://www.w3.org/2022/wot/td/v1.1"],
"@type" : "tm:ThingModel",
"title": "Smart Lamp Control",
"properties" : {
Expand Down
Loading