Skip to content

Commit

Permalink
Merge pull request #461 from thingweb/UI-fixes
Browse files Browse the repository at this point in the history
New TD and TM examples for the new UI
  • Loading branch information
egekorkan committed Apr 5, 2023
2 parents cf05bb9 + 1f8264b commit fc0900e
Show file tree
Hide file tree
Showing 112 changed files with 4,046 additions and 29 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/ci-cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ jobs:
- name: Test
run: lerna run test --no-bail --stream

- name: TD test
run: node packages/cli/index.js -i examples/td/*/*.jsonld

- name: TM test
run: node packages/cli/index.js -t TM -i examples/tm/*/*.jsonld

deploy-via-ssh:

runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions examples/td/1-simple-default/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This Folder contains multiple simple/basic examples of Thing Description as well as its most basic components.
32 changes: 32 additions & 0 deletions examples/td/1-simple-default/basic-td.td.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"@context": "https://www.w3.org/2022/wot/td/v1.1",
"id": "urn:uuid:0804d572-cce8-422a-bb7c-4412fcd56f06",
"title": "MyLampThing",
"$title": "Basic TD Example",
"description": "Thing Description for a Lamp thing",
"$description": "This is an example of the most basic form of a td",
"securityDefinitions": {
"basic_sc": {"scheme": "basic", "in": "header"}
},
"security": "basic_sc",
"properties": {
"status": {
"type": "string",
"forms": [{"href": "https://mylamp.example.com/status"}]
}
},
"actions": {
"toggle": {
"forms": [{"href": "https://mylamp.example.com/toggle"}]
}
},
"events": {
"overheating": {
"data": {"type": "string"},
"forms": [{
"href": "https://mylamp.example.com/oh",
"subprotocol": "longpoll"
}]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

{
"@context": "https://www.w3.org/2022/wot/td/v1.1",
"id": "urn:uuid:014139c9-b267-4db5-9c61-cc2d2bfc217d",
"title": "MyCameraThing",
"$title": "contentMedia and contentEncoding TD Example",
"description": "Thing description for a camera thing",
"$description": "In some cases binary data is embedded in text-based values, e.g., a JSON string-based value embeds a base64 encoded image. The terms contentMediaType and contentEncoding can be used to clarify the context and encoding format of such name-value pairs.",
"securityDefinitions": {
"basic_sc": {"scheme": "basic", "in": "header"}
},
"security": "basic_sc",
"properties": {
"image": {
"description": "Provides latest image",
"type": "string",
"contentMediaType": "image/png",
"contentEncoding": "base64",
"forms": [{
"op": "readproperty",
"href": "http://camera.example.com/lastPicture",
"cov:methodName": "GET",
"contentType": "application/json"
}]
}
},
"actions": {
"takePhoto": {
"forms": [{
"op": "invokeaction",
"href": "http://camera.example.com/snapshot",
"contentType": "application/json"
}]
}
},
"events": {
"lowMemory": {
"data": {"type": "string"},
"forms": [{
"href": "https://mycamera.example.com/oh",
"contentType": "text/plain",
"subprotocol": "longpoll"
}]
}
}
}
42 changes: 42 additions & 0 deletions examples/td/1-simple-default/contentType.td.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"@context": "https://www.w3.org/2022/wot/td/v1.1",
"id": "urn:uuid:014139c9-b267-4db5-9c61-cc2d2bfc217d",
"title": "MyCameraThing",
"$title": "contentType TD Example",
"description": "Thing description for a camera thing",
"$description": "The contentType member is used to assign a media type [RFC2046] including media type parameters as attribute-value pairs separated by a ; character.",
"securityDefinitions": {
"basic_sc": {"scheme": "basic", "in": "header"}
},
"security": "basic_sc",
"properties": {
"status": {
"type": "string",
"forms": [{
"href": "https://mycamera.example.com/status",
"contentType": "application/json"
}]
}
},
"actions": {
"takePhoto": {
"forms": [{
"op": "invokeaction",
"href": "http://camera.example.com/snapshot",
"contentType": "application/json"
}]
}
},
"events": {
"lowMemory": {
"data": {"type": "string"},
"forms": [{
"href": "https://mycamera.example.com/oh",
"contentType": "text/plain",
"subprotocol": "longpoll"
}]
}
}
}


57 changes: 57 additions & 0 deletions examples/td/1-simple-default/defaults.td.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"@context": "https://www.w3.org/2022/wot/td/v1.1",
"id": "urn:uuid:014139c9-b267-4db5-9c61-cc2d2bfc217d",
"title": "MyLampThing",
"$title": "All Default Values TD Example",
"description": "TD for a lamp thing",
"$description": "A basic TD with all default values",
"securityDefinitions": {
"basic_sc": {
"scheme": "basic",
"in": "header"
}
},
"security": "basic_sc",
"properties": {
"status": {
"type": "string",
"readOnly": false,
"writeOnly": false,
"observable": false,
"forms": [{
"op": [
"readproperty",
"writeproperty"
],
"href": "https://mylamp.example.com/status",
"contentType": "application/json"
}]
}
},
"actions": {
"toggle": {
"safe": false,
"idempotent": false,
"forms": [{
"op": "invokeaction",
"href": "https://mylamp.example.com/toggle",
"contentType": "application/json"
}]
}
},
"events": {
"overheating": {
"data": {
"type": "string",
"readOnly": false,
"writeOnly": false
},
"forms": [{
"op": "subscribeevent",
"href": "https://mylamp.example.com/oh",
"contentType": "application/json",
"subprotocol": "longpoll"
}]
}
}
}
50 changes: 50 additions & 0 deletions examples/td/1-simple-default/form-serialization.td.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"@context": "https://www.w3.org/2022/wot/td/v1.1",
"id": "urn:uuid:0804d572-cce8-422a-bb7c-4412fcd56f06",
"title": "MyLampThing",
"$title": "Form Serialization TD Example",
"description": "TD for a lamp thing",
"$description": "This is an example for proper form serialization",
"securityDefinitions": {
"basic_sc": {"scheme": "basic", "in": "header"}
},
"security": "basic_sc",
"properties": {
"brightness": {
"readOnly": true,
"writeOnly": false,
"observable": false,
"forms": [
{
"href": "https://mylamp.example.com/brightness",
"contentType": "application/json",
"op": "readproperty"
}
]
}
},
"actions": {
"toggle": {
"forms": [
{
"href": "https://mylamp.example.com/toggle",
"op": "invokeaction",
"contentType": "application/json"
}
]
}
},
"events": {
"overheating": {
"data": {"type": "string"},
"forms": [
{
"href": "https://mylamp.example.com/oh",
"subprotocol": "longpoll",
"op": "subscribeevent",
"contentType": "application/json"
}
]
}
}
}
32 changes: 32 additions & 0 deletions examples/td/1-simple-default/simple-context.td.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"@context": "https://www.w3.org/2022/wot/td/v1.1",
"id": "urn:uuid:0804d572-cce8-422a-bb7c-4412fcd56f06",
"title": "MyLampThing",
"$title": "@context TD Example",
"description": "TD for a lamp thing",
"$description": "A member with the name @context and a value of type string is generally used to identify the TD representation format version defined by this specification.",
"securityDefinitions": {
"basic_sc": {"scheme": "basic", "in": "header"}
},
"security": "basic_sc",
"properties": {
"status": {
"type": "string",
"forms": [{"href": "https://mylamp.example.com/status"}]
}
},
"actions": {
"toggle": {
"forms": [{"href": "https://mylamp.example.com/toggle"}]
}
},
"events": {
"overheating": {
"data": {"type": "string"},
"forms": [{
"href": "https://mylamp.example.com/oh",
"subprotocol": "longpoll"
}]
}
}
}
1 change: 1 addition & 0 deletions examples/td/10-response-and-additional-response/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This folder contains examples that show how an interaction affordance can provide additonal metadata as a response.
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"@context": "https://www.w3.org/2022/wot/td/v1.1",
"id": "urn:uuid:0804d572-cce8-422a-bb7c-4412fcd56f06",
"title": "MyCarThing",
"$title": "Additional Responses TD Example",
"description": "TD for a Car Thing",
"$description": "The message received from the Thing as part of an Interaction Affordance can differ due to different reasons. Such reasons could be error cases or alternative responses for a valid response. In these cases, additionalResponses terms can be used to describe this behavior.",
"securityDefinitions": {
"basic_sc": {"scheme": "basic", "in": "header"}
},
"security": "basic_sc",
"schemaDefinitions": {
"actionErrorPayload": {
"type": "object",
"properties": {
"reason": {
"type": "string",
"enum": ["cold","hot","maintenance"]
},
"timeStamp": {
"description": "UNIX time in numbers indicating when the error happened",
"type": "number"
}
}
}
},
"properties": {
"status": {
"type": "string",
"forms": [{"href": "https://mycar.example.com/api/status"}]
}
},
"actions": {
"startEngine": {
"output": {
"type": "string"
},
"forms": [{
"op": "invokeaction",
"href": "http://mycar.example.com/api/engine",
"contentType": "application/json",
"additionalResponses": [{
"success": false,
"contentType": "application/json",
"schema": "actionErrorPayload"
}]
}]
}
},
"events": {
"overheating": {
"data": {"type": "string"},
"forms": [{
"href": "https://mycar.example.com/api/oh",
"subprotocol": "longpoll"
}]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"@context": "https://www.w3.org/2022/wot/td/v1.1",
"id": "urn:uuid:014139c9-b267-4db5-9c61-cc2d2bfc217d",
"title": "MyCameraThing",
"$title": "Simple Response TD Example",
"description": "TD for a Camera Thing",
"$description": "The Interaction Affordance not only describes the request, but also provides metadata for the expected response. In such cases, the response member is used to indicate the representation format of the response payload. therefore no output schema is required, as the content type fully specifies the representation format.",
"securityDefinitions": {
"basic_sc": {"scheme": "basic", "in": "header"}
},
"security": "basic_sc",
"properties": {
"status": {
"type": "string",
"forms": [{"href": "https://mycamera.example.com/status"}]
}
},
"actions": {
"takePhoto": {
"forms": [{
"op": "invokeaction",
"href": "http://camera.example.com/api/snapshot",
"contentType": "application/json",
"response": {
"contentType": "image/jpeg"
}
}]
}
},
"events": {
"lowMemory": {
"data": {"type": "string"},
"forms": [{
"href": "https://mycamera.example.com/oh",
"subprotocol": "longpoll"
}]
}
}
}
1 change: 1 addition & 0 deletions examples/td/11-multilanguage/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This folder contains examples on how multiple languages as well as reading directions can be implemented on a Thing Description.

0 comments on commit fc0900e

Please sign in to comment.