├── .github ├── publish-ts-issue.md └── workflows │ └── sync.yml ├── .pr-preview.json ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE.md ├── README.md ├── applications ├── script-manager │ ├── ManagerThing1.uml │ ├── ManagerThing2.uml │ ├── README.md │ └── images │ │ ├── ManagerThing1.png │ │ ├── ManagerThing2.png │ │ ├── ManagerThing_Fig1.png │ │ └── ManagerThing_Fig2.png └── thing-directory │ ├── README.md │ ├── ReverseProxy3.uml │ ├── ReverseProxy5.uml │ └── images │ ├── ReverseProxy1.png │ ├── ReverseProxy2.png │ ├── ReverseProxy3.png │ ├── ReverseProxy4.png │ └── ReverseProxy5.png ├── images ├── scripting-action-data.png ├── scripting-action-data.svg ├── scripting-error-handling.png ├── scripting-error-handling.svg ├── scripting-read-data.png ├── scripting-read-data.svg ├── scripting-write-data.png └── scripting-write-data.svg ├── index.html ├── primer ├── README.md └── images │ ├── Fig1.png │ ├── Fig10.png │ ├── Fig11.png │ ├── Fig12.png │ ├── Fig13.png │ ├── Fig14.png │ ├── Fig15.png │ ├── Fig16.png │ ├── Fig17.png │ ├── Fig18.png │ ├── Fig2.png │ ├── Fig3.png │ ├── Fig4.png │ ├── Fig5.png │ ├── Fig6.png │ ├── Fig7.png │ ├── Fig8.png │ └── Fig9.png ├── rationale.md ├── releases ├── README.md ├── fix-id.pl ├── fpwd │ ├── Overview.html │ └── diff.html ├── note1 │ ├── images │ │ ├── scripting-action-data.png │ │ ├── scripting-action-data.svg │ │ ├── scripting-error-handling.png │ │ ├── scripting-error-handling.svg │ │ ├── scripting-read-data.png │ │ ├── scripting-read-data.svg │ │ ├── scripting-write-data.png │ │ └── scripting-write-data.svg │ ├── index.html │ ├── manifest.txt │ └── orig.html ├── note2 │ ├── Makefile │ ├── Overview.html │ ├── README.md │ ├── backup.html │ ├── fix-id.pl │ ├── images │ │ ├── scripting-action-data.png │ │ ├── scripting-action-data.svg │ │ ├── scripting-error-handling.png │ │ ├── scripting-error-handling.svg │ │ ├── scripting-read-data.png │ │ ├── scripting-read-data.svg │ │ ├── scripting-write-data.png │ │ └── scripting-write-data.svg │ ├── index.html │ └── static.html ├── wd2 │ ├── Overview.html │ └── diff.html ├── wd3 │ ├── Overview.html │ ├── diff.html │ └── manifest.txt └── wd4 │ ├── Overview.html │ ├── README.md │ ├── diff.html │ └── manifest.txt ├── typescript ├── .gitignore ├── README.md ├── package-lock.json ├── package.json ├── scripting-api │ ├── README.md │ ├── index.d.ts │ ├── package.json │ └── tsconfig.json ├── thing-description │ ├── README.md │ ├── package.json │ ├── schema │ │ └── td-json-schema-validation.json │ └── thing-description.d.ts └── thing-model │ ├── README.md │ ├── package.json │ ├── schema │ └── tm-json-schema-validation.json │ └── thing-model.d.ts └── w3c.json /.github/publish-ts-issue.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Publish {{ env.PACKAGE_NAME }} TypeScript package 3 | assignees: danielpeintner 4 | labels: enhancement 5 | --- 6 | 7 | Sync action has just updated the {{ env.PACKAGE_NAME }} definitions using a new jsonschema -------------------------------------------------------------------------------- /.github/workflows/sync.yml: -------------------------------------------------------------------------------- 1 | name: Sync json schema 2 | 3 | on: 4 | schedule: 5 | - cron: '00 00 * * *' 6 | workflow_dispatch: 7 | 8 | 9 | jobs: 10 | sync-td: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v2 14 | - uses: actions/setup-node@v2 15 | with: 16 | node-version: '16' 17 | - name: Download schema 18 | run: | 19 | # Retrieve json schema from td repository 20 | mkdir .temp && cd .temp 21 | git init 22 | git fetch https://github.com/w3c/wot-resources.git 23 | git checkout FETCH_HEAD -- td/v1.1/validation/td-json-schema-validation.json 24 | - name: Look for changes 25 | continue-on-error: true 26 | run: | 27 | git diff --no-index --quiet typescript/thing-description/schema/td-json-schema-validation.json .temp/td/v1.1/validation/td-json-schema-validation.json 28 | echo "::set-output name=changed::$?" 29 | id: diff 30 | - name: Sync file 31 | if: ${{ ! steps.diff.outputs.changed }} 32 | run: mv .temp/td/v1.1/validation/td-json-schema-validation.json typescript/thing-description/schema/td-json-schema-validation.json && rm -rf .temp 33 | - name: Generate types 34 | if: ${{ ! steps.diff.outputs.changed }} 35 | run: | 36 | cd typescript 37 | npm install 38 | npm run build --workspace=thing-description 39 | - name: Push changes 40 | if: ${{ ! steps.diff.outputs.changed }} 41 | uses: EndBug/add-and-commit@v7 42 | with: 43 | # focus only on the schema and the generated file just to be sure 44 | add: '["typescript/thing-description/schema","typescript/thing-description/thing-description.d.ts"]' 45 | author_name: action_sync 46 | message: 'chore(typescript): sync thing description json schema from wot-thing-description.git' 47 | pull: '--rebase --autostash' 48 | - uses: JasonEtco/create-an-issue@v2 49 | if: ${{ ! steps.diff.outputs.changed }} 50 | env: 51 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 52 | PACKAGE_NAME: thing-description 53 | with: 54 | filename: .github/publish-ts-issue.md 55 | sync-tm: 56 | runs-on: ubuntu-latest 57 | steps: 58 | - uses: actions/checkout@v2 59 | - uses: actions/setup-node@v2 60 | with: 61 | node-version: '16' 62 | - name: Download schema 63 | run: | 64 | # Retrieve json schema from td repository 65 | mkdir .temp && cd .temp 66 | git init 67 | git fetch https://github.com/w3c/wot-resources.git 68 | git checkout FETCH_HEAD -- td/v1.1/validation/tm-json-schema-validation.json 69 | - name: Look for changes 70 | continue-on-error: true 71 | run: | 72 | git diff --no-index --quiet typescript/thing-model/schema/tm-json-schema-validation.json .temp/td/v1.1/validation/tm-json-schema-validation.json 73 | echo "::set-output name=changed::$?" 74 | id: diff 75 | - name: Sync file 76 | if: ${{ ! steps.diff.outputs.changed }} 77 | run: mv .temp/td/v1.1/validation/tm-json-schema-validation.json typescript/thing-model/schema/tm-json-schema-validation.json && rm -rf .temp 78 | - name: Generate types 79 | if: ${{ ! steps.diff.outputs.changed }} 80 | run: | 81 | cd typescript 82 | npm install 83 | npm run build --workspace=thing-model 84 | - name: Push changes 85 | if: ${{ ! steps.diff.outputs.changed }} 86 | uses: EndBug/add-and-commit@v7 87 | with: 88 | # focus only on the schema and the generated file just to be sure 89 | add: '["typescript/thing-model/schema","typescript/thing-model/thing-model.d.ts"]' 90 | author_name: action_sync 91 | message: 'chore(typescript): sync thing model json schema from wot-thing-description.git' 92 | pull: '--rebase --autostash' 93 | - uses: JasonEtco/create-an-issue@v2 94 | if: ${{ ! steps.diff.outputs.changed }} 95 | env: 96 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 97 | PACKAGE_NAME: thing-model 98 | with: 99 | filename: .github/publish-ts-issue.md 100 | -------------------------------------------------------------------------------- /.pr-preview.json: -------------------------------------------------------------------------------- 1 | { 2 | "src_file": "index.html", 3 | "type": "respec" 4 | } 5 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Code of Conduct 2 | 3 | All documentation, code and communication under this repository are covered by the [W3C Code of Ethics and Professional Conduct](https://www.w3.org/Consortium/cepc/). 4 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Web of Things Working Group 2 | 3 | Contributions to this repository are intended to become part of Recommendation-track documents governed by the 4 | [W3C Patent Policy](http://www.w3.org/Consortium/Patent-Policy-20040205/) and 5 | [Software and Document License](http://www.w3.org/Consortium/Legal/copyright-software). To make substantive contributions to specifications, you must either participate 6 | in the relevant W3C Working Group or make a non-member patent licensing commitment. 7 | 8 | If you are not the sole contributor to a contribution (pull request), please identify all 9 | contributors in the pull request comment. 10 | 11 | To add a contributor (other than yourself, that's automatic), mark them one per line as follows: 12 | 13 | ``` 14 | +@github_username 15 | ``` 16 | 17 | If you added a contributor by mistake, you can remove them in a comment with: 18 | 19 | ``` 20 | -@github_username 21 | ``` 22 | 23 | If you are making a pull request on behalf of someone else but you had no part in designing the 24 | feature, you can remove yourself with the above syntax. 25 | 26 | For further guidelines, refer to [https://github.com/w3c/wotwg#contributing](https://github.com/w3c/wotwg#contributing). 27 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | All documents in this Repository are licensed by contributors 2 | under the 3 | [W3C Software and Document License](http://www.w3.org/Consortium/Legal/copyright-software). 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 | Web of Things Homepage 4 | 5 |

6 | 7 |

8 | 9 | Follow on Mastodon 10 | 11 | X (formerly Twitter) Follow 12 | 13 | Stack Exchange questions 14 |

15 | 16 |

17 | 18 | Latest Note 19 | 20 | Latest Editor's Draft 21 |

22 | 23 | # Web of Things (WoT) Scripting API 24 | 25 | General information about the Web of Things can be found on https://www.w3.org/WoT/. 26 | 27 | --- 28 | The Web of Things (WoT) is made of entities (Things) that can describe their capabilities in a machine-interpretable Thing Description (TD) and expose these capabilities through the WoT Interface, that is, network interactions modeled as Properties (for reading, writing and observing values), Actions (to execute remote procedures with or without return values) and Events (for signaling notifications). 29 | 30 | Scripting API is an optional building block in WoT and it is typically used in gateways or browsers that can run a WoT Runtime and script management, providing a convenient way to use WoT concepts in high-level applications. 31 | 32 | This specification describes an application programming interface (API) representing the WoT Interface that allows scripts to discover Things, operate Things, and expose locally defined Things characterized by WoT Interactions. 33 | 34 | See the [rationale.md](./rationale.md) for an explanation of API design choices. 35 | 36 | ## Logistics 37 | 38 | - Call information: We use the W3C Calendar. You can find the next Scripting API call at https://www.w3.org/groups/wg/wot/calendar. 39 | - Wiki (contains agenda): https://www.w3.org/WoT/IG/wiki/WG_WoT_Scripting_API_WebConf 40 | - [Contribution rules](./CONTRIBUTING.md) 41 | - If you want to make a full-text review on the spec or other files, follow the steps outlined [here](https://github.com/w3c/wot-scripting-api/pull/248). 42 | 43 | ## Publications 44 | 45 | - [Latest Editor's Draft](https://w3c.github.io/wot-scripting-api/) 46 | - [Latest Group Note](https://www.w3.org/TR/wot-scripting-api/) 47 | - Releases for other [published versions](https://www.w3.org/TR/wot-scripting-api/) are found in [releases](./releases/). 48 | 49 | --- 50 | 51 | ## TypeScript Definitions 52 | 53 | The specification uses WebIDL definitions, but [TypeScript definitions](./typescript) are also available. 54 | We use [json-schema-to-typescript](https://www.npmjs.com/package/json-schema-to-typescript) to generate the TypeScript definitions for [wot-thing-description-types](https://github.com/w3c/wot-scripting-api/tree/main/typescript/thing-description) and [wot-thing-models-types](https://github.com/w3c/wot-scripting-api/tree/main/typescript/thing-model). 55 | 56 | ## Labelling conventions 57 | 58 | We use [labels](https://github.com/w3c/wot-scripting-api/labels) to categorize our work items. 59 | 60 | ## Versioning 61 | As discussed in the [27th February 2023](https://www.w3.org/2023/02/27-wot-script-minutes.html#t06) call, the task force decided to use a new versioning mechanism for the WoT Scripting API specification. In practice, we augment the current Typescript versioning with a more comprehensive tagging mechanism that takes into account also standard W3C process for publishing Notes. Each substantial change will trigger the creation of a git tag on the repository and when the Note is published it will trigger a full Github release. Substantial changes are anything that is not just an editorial or rephrasing of the current document content; examples of substantial changes are: 62 | - Fixing an algorithm 63 | - New function or change in the argument list of an existing function 64 | - Introducing a new type 65 | - Fixing WebIDL 66 | - etc. 67 | 68 | On the other hand, examples of non-substantial changes are: 69 | - Typos in the document 70 | - Introduce new examples or explanatory text 71 | - Improve readability or document structure 72 | 73 | In every circumstance, different substantial changes may be packed together in one single git tag if they are closely related or are merged in a short period (e.g. a day). Tags follow [semantic versioning](https://semver.org/) 74 | ``` 75 | major.minor.patch-[alpha].[id] 76 | ``` 77 | - `id` identifies the experimental revision of an ongoing `majory.minor.patch` version. 78 | 79 | Here is an example of the process we will use: 80 | * We publish the current document and tag it with 0.8.0 81 | * Then we make some relevant changes (e.g. a bug fix) 82 | * We tag version 0.8.1-alpha.1 83 | * We continue fixing stuff 84 | * Then we go for 0.8.1-alpha.2 85 | * If we change the API (adding a new function) we should go for 0.9.0-alpha.1 86 | * We can cycle in these changes as much as we want (e.g. 0.x.y-alpha.x) 87 | * When we want to publish the document again we remove the alpha (e.g. assuming we were at 0.9.1-alpha.10 we release 0.9.1) 88 | 89 | Since we are still in a exploratory phase, we will use the `major` number `0` until we reach a certain level of maturity. 90 | 91 | ## Editors Tools 92 | 93 | * [Search Cross References for ReSpec](https://respec.org/xref/) 94 | -------------------------------------------------------------------------------- /applications/script-manager/ManagerThing1.uml: -------------------------------------------------------------------------------- 1 | @startuml 2 | ManagerThing -> TD_repo: register TD for ManagerThing 3 | TD_repo <- ConsumedThing: get TD by Wot.discover 4 | TD_repo --> ConsumedThing: TD 5 | @enduml 6 | -------------------------------------------------------------------------------- /applications/script-manager/ManagerThing2.uml: -------------------------------------------------------------------------------- 1 | @startuml 2 | participant Script_repo 3 | participant ManagerThing 4 | participant Execution_area 5 | participant ConsumedThing 6 | 7 | ConsumedThing -> ManagerThing: invokeAction("install",... 8 | ManagerThing -> Script_repo: get script 9 | ManagerThing <-- Script_repo: script 10 | Execution_area <-- ManagerThing: install script 11 | 12 | ConsumedThing -> ManagerThing: invokeAction("run",... 13 | ManagerThing -> Execution_area: execute script 14 | 15 | ConsumedThing -> ManagerThing: invokeAction("stop",... 16 | ManagerThing -> Execution_area: stop executing script 17 | 18 | ConsumedThing -> ManagerThing: invokeAction("uninstall",... 19 | ManagerThing -> Execution_area: uninstall script 20 | @enduml 21 | -------------------------------------------------------------------------------- /applications/script-manager/README.md: -------------------------------------------------------------------------------- 1 | # WoT Script Manager Thing 2 | 3 | The purpose of this document is to explain ManagerThing that can deal remote Thing lifecycle management by co-working with ScriptingAPI. 4 | 5 | ### 1. ManagerThing 6 | 7 | ManagerThing is a capability in servient that provide management functionalities of servient and exposes management APIs to external clients.
8 | 9 | The managerThing takes advantage of [Thing Description(TD)](https://w3c.github.io/wot-thing-description/), [ScriptingAPI](https://w3c.github.io/wot-scripting-api/), and [wot security-privacy](https://github.com/w3c/wot/tree/master/security-privacy). 10 | 11 | TD for ManagerThing declares fixed management commands as actions that a servient supports.
12 | A Client that supports Scripting API(ConsumedThing) obtains the TD and knows what management capabilities are available. Then the Client issue commands to control the servient remotely.
13 | 14 | ### 2. Management commands 15 | ManagerThing provides the following managemet commands.
16 | 17 | The following commands deals life cycle of script. 18 | * install: install a script and return a handle (e.g. URI, UUID).
19 | * run: run a script by a handle.
20 | * stop: stop a running script by a handle.
21 | * uninstall: uninstall a script specified by a handle and discard the handle.
22 | 23 | The script may include Scripting API commands.
24 | 25 | ### 3. Thing Description for ManagerThing 26 | 27 | A sample TD for ManagerThing is as follows: 28 | 29 | ```rb 30 | { 31 | "@context": ["http://w3c.github.io/wot/w3c-wot-td-context.jsonld", 32 | { "manager": "http://w3c.github.io/wot/managerthing#" } 33 | ], 34 | "@type": ["ManagerThing"], 35 | "name": "ManagerThing", 36 | "interaction": [ 37 | { 38 | "@type": ["Action","manager:install"], 39 | "name": "install", 40 | "inputData": { "type": "string" }, 41 | "outputData": { "type": "string" }, 42 | "link": [{ 43 | "href" : "coap://mytemp.example.com:5683/install", 44 | "mediaType": "application/json" 45 | }] 46 | }, 47 | { 48 | "@type": ["Action","manager:run"], 49 | "name": "run", 50 | "inputData": { "type": "string" }, 51 | "link": [{ 52 | "href" : "coap://mytemp.example.com:5683/run", 53 | "mediaType": "application/json" 54 | }] 55 | }, 56 | { 57 | "@type": ["Action","manager:stop"], 58 | "name": "stop", 59 | "inputData": { "type": "string" }, 60 | "link": [{ 61 | "href" : "coap://mytemp.example.com:5683/stop", 62 | "mediaType": "application/json" 63 | }] 64 | }, 65 | { 66 | "@type": ["Action","manager:uninstall"], 67 | "name": "uninstall", 68 | "inputData": { "type": "string" }, 69 | "link": [{ 70 | "href" : "coap://mytemp.example.com:5683/uninstall", 71 | "mediaType": "application/json" 72 | }] 73 | } 74 | ] 75 | } 76 | ``` 77 | 78 | ### 4. WebIDL 79 | 80 | The ManagerThing can be described in WebIDL as follows. 81 | 82 | ```rb 83 | typedef ScriptID USVString; // e.g. UUID 84 | 85 | interface ScriptManagerThing { 86 | // main actions 87 | any run(USVString script); // run a serialized script and return the result or error 88 | ScriptID? install(USVString script, optional unsigned long bootSequence); // save 89 | bool uninstall(ScriptID handle); // uninstall a script by handle (stop, unmark, delete) 90 | bool stop(ScriptID handle); // stop a running script by handle 91 | }; 92 | ``` 93 | 94 | ### 5. Usage 95 | 96 | #### 5.1 Preparation for remote management 97 | Servient supports fixed management command that declared as TD for ManagerThing. The servient exposes API and is controlled by external client through the TD. Client has a program that issues WoT.discover() command to obtain the TD.
98 | 99 | Fig.1 100 | 101 | The following diagram depicts how ManagerThing preapard to use. 102 | 103 | Fig.2 104 | 105 | - ManagerThing registers a TD for ManagerThing to a TD repository. 106 | - ConsumedThing in an external client acquires the TD by WoT. discover command. 107 | - ConsumedThing receives the TD and understands the what management capabilities are supported in the ManagerThing. 108 | 109 | #### 5.2 Remote management of servient 110 | 111 | The external client manages a servient remotely using Scripting API(ConsumedThing).
112 | - Servient has a ManagerThing and the ManagerThing is accessed from the client remotely. 113 | - ManagerThing inherited the mechanism from ExposedThing and expose WoT API for ManagerThing. 114 | 115 | Fig.3 116 | 117 | The script of left hand side (Script#1) shows the part of ManagerThing program to manage servient and the APIs are exposed.
118 | 119 | The script of the middle (Script#2) shows a script from a Script repository.
120 | - For example, a script in Script repository may include e.g. Create a new exposed Thing from a Thing Description. 121 | 122 | The script of right hand side (Script#3) shows a sript for ConsumedThing to manage the servient remotely.
123 | - For example, when client invoke "install" and "run" commands, servient gets script and save, then execute the script. 124 | 125 | The following diagram depicts how ManagerThing works based on the usage of a script installation. 126 | Fig.4 127 | 128 | - Install:
129 | ConsumedThing in external client issues install command to ManagerThing by invokeAction.
130 | ManagerThing downloads a script from script repository and saves the script to file system in servient.
131 | - Run:
132 | ConsumedThing issues run command to ManagerThing by invokeAction.
133 | ManagerThing deploys the script to execution area in servient and run the script.
134 | - Stop:
135 | ConsumedThing issues stop command to ManagerThing by invokeAction.
136 | ManagerThing stop the execution of script in execution area.
137 | - Uninstall:
138 | ConsumedThing issues uninstall command to ManagerThing by invokeAction.
139 | ManagerThing uninstall and discard the script from execution area and servient.
140 | 141 | ### 6. Security consideration 142 | ... 143 | -------------------------------------------------------------------------------- /applications/script-manager/images/ManagerThing1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w3c/wot-scripting-api/ad351eb2f8928442c4bd433ad0a9b5dd797e37d8/applications/script-manager/images/ManagerThing1.png -------------------------------------------------------------------------------- /applications/script-manager/images/ManagerThing2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w3c/wot-scripting-api/ad351eb2f8928442c4bd433ad0a9b5dd797e37d8/applications/script-manager/images/ManagerThing2.png -------------------------------------------------------------------------------- /applications/script-manager/images/ManagerThing_Fig1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w3c/wot-scripting-api/ad351eb2f8928442c4bd433ad0a9b5dd797e37d8/applications/script-manager/images/ManagerThing_Fig1.png -------------------------------------------------------------------------------- /applications/script-manager/images/ManagerThing_Fig2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w3c/wot-scripting-api/ad351eb2f8928442c4bd433ad0a9b5dd797e37d8/applications/script-manager/images/ManagerThing_Fig2.png -------------------------------------------------------------------------------- /applications/thing-directory/README.md: -------------------------------------------------------------------------------- 1 | # WoT Thing Directory (reverse proxy) 2 | 3 | This document explains about reverse proxy that provides a mean for realizing proxy or agent of things that depicted in [Web of Things (WoT) Architecture](https://w3c.github.io/wot-architecture/) or [Primer for Scripting API](https://w3c.github.io/wot-scripting-api/primer) and how it realized using ScriptingAPI. 4 | 5 | ## 1. Reverse proxy 6 | 7 | WoT reverse proxy is a kind of servient that provides roles of reverse proxy to avoid direct access to another servient underneath to keep quality of service regardless of the network connection of device.
8 | 9 | The reverse proxy has two types: 10 | - reverse proxy without cache: When a servient (servient#1) for reverse proxy is called, it synchronously accesses to another servient (servient#2) and device underneath. 11 | - reverse proxy with cache: Caching the status of servient#1 and replicating on servient#2 even if servient#1 or device underneath loose the network connection. 12 | 13 | ## 2. Reverse proxy using TD and Scripting API 14 | 15 | One way to realize the reverse proxy is synchronization of [Thing Description(TD)](https://w3c.github.io/wot-thing-description/) using [Scripting API](https://w3c.github.io/wot-scripting-api/).
16 | 17 | Fig.1 18 | 19 | ### 2.1. Reverse proxy without cache 20 | 21 | #### Description 22 | - The state synchronization of servients can be achieved by observing servient#1. 23 | 24 | #### Setup 25 | - servient#1 registers a TD of connected devices to TD repository #1. 26 | - servient#2 has a script that transferring all of the accesses for the synchronization. servient#2 gets the TD by WoT.discover, parses the TD, then servient#2 exposes the same functions as the servient#1 and registers new TD to TD repository #2. The callback functions access the servient#1. 27 | 28 | ##### Script for reverse proxy 29 | The following is outline of a script to relize reverse proxy without cache. 30 | 31 | ```rb 32 | WoT.discover() 33 | .subscribe(function(cthing) { 34 | createLocalThing({name: cthing.name}) 35 | .then(function(ething) { 36 | …(code for transferring access of all interactions) … 37 | ething.onInvokeAction(function(request) { 38 | cthing.invokeAction(request.action.name, request.inputData) 39 | .then(function(response) {return response;} 40 | … 41 | ``` 42 | cthing: an instance of ConsumedThing in a servient
43 | ething: an instance of ExposedThing in the servient
44 | 45 | #### Usage 46 | - Client gets the TD from TD repository #2 by WoT.discover, and accesses the servient#1 via servient#2. 47 |
48 | 49 | Fig.2 50 | 51 | 52 | #### Flow 53 | Fig.3 54 | 55 | ##### TD synchronization 56 | When thing has changed e.g. network IP has changed, it is necessary to propagete to the corresponding servients. 57 | - servient#1 reflects the change to a TD for a thing and registers the TD to TD_repo1. 58 | - servient#2 issues WoT.discover(Discover2) command to get the TD.
59 | Note that the timeing of the issue depends on implementations. Discover2 might periodically issue Wot.discover(Discover2) or might receive a notification from servient#1. This is out of the scope of this document. 60 | - servient#2 receives the TD and exposes WoT API based on the TD using ScriptingAPI(ExposedThing). servient#2 setups callback for accesing the device as ConsumedThing(2) using ScriptingAPI. 61 | - servient#2 registers the TD to TD_repo2. 62 | - Client issues WoT.discver(Discover3) command to get the TD and receive the TD. 63 | - Client setups callback for accessing the device as ConsumeThing(3) using ScriptingAPI. 64 | 65 | ##### Device access 66 | - ConsumedThing(3) in Client issues comman to turn on the device. 67 | - ExposedThing(2) in servient#2 receives the command and the callback pass-throughs the command to servient#1 through ConsumedThing(2). 68 | - ExposedThing(1) in servient#1 receives the command and turn on the device. Then return an acknowledge. 69 | 70 | 71 | ### 2.2. Reverse proxy with cache 72 | 73 | #### Description 74 | - The state synchronization of servients can be achieved by observing servient#1. In addition, servient#2 holds the state and replicate the status even if servient#1 or device underneath looses the network connection for some reason. 75 | 76 | #### Setup 77 | - servient#1 registers a TD of connected devices to TD repoistory #1. 78 | - servient#2 has a script for the reverse proxy with cache that replicates on servient#2. servient#2 gets TD by WoT.discover, parses the TD, then servient#2 exposes the same functions with the servient#1 and registers new TD to TD repository #2. The callback functions access the servient#1. 79 | 80 | ##### Script for reverse proxy 81 | The following is outline of a script to relize reverse proxy with cache.
82 | Difference from the previous one is if an instance of consumedThing is not connected to network, replicate using cache. 83 | 84 | ```rb 85 | WoT.discover() 86 | .subscribe(function(cthing) { 87 | createLocalThing({name: cthing.name}) 88 | .then(function(ething) { 89 | …(code for transferring access of all interactions) … 90 | ething.onRetrieveProperty(function(request) { 91 | if (isConnected(cthing)) { 92 | cthing.getProperty(request.action.name) 93 | .then(function(response) {return response;} 94 | } else { 95 | return cache[request.action.name]; 96 | } 97 | ``` 98 | 99 | cthing: an instance of ConsumedThing in a servient
100 | ething: an instance of ExposedThing in the servient
101 | 102 | #### Usage 103 | - Client gets the TD from TD repo #2 by WoT.discover, accesses the servient#1 via servient#2 when servient#1 is accessible, and replicate the responses by accessing a cache in the servient#2 when servient#1 is not accessible. 104 |
105 | 106 | Fig.4 107 | 108 | #### Flow 109 | 110 | Fig.5 111 | 112 | ##### TD synchronization 113 | TD synchronization behaves same as the previous one. 114 | 115 | ##### Device access 116 | The cache holds the behavior of event, action, and propert. It might holds linked data from a sensor for event, holds command issueing or event watting for action, and holds status of thing or command issueing for property. 117 | 118 | In the above flow: 119 | - ConsumedThing(3) in Client issues comman to turn on the device. 120 | 121 | If device connected:
122 | - ExposedThing(2) in servient#2 receives the command and the callback forwards the command to servient#1 through ConsumedThing(2) if the device is connected.
123 | Note that how to detect the device connection is up to the implementation and out of the scope of this document.
124 | - ExposedThing(1) in servient#1 receives the command and turn on the device. Then return an acknowledge. 125 | 126 | If device disconnected: 127 | - ExposedThing(2) in servient#2 receives the command and return an acknowledgement to ConsumedThing(3) in Client. 128 | - The cache mechanizm of servient#2 holds the comman until the device connected to the network. 129 | - When it is connected, issues the commands to servient#1. 130 | -------------------------------------------------------------------------------- /applications/thing-directory/ReverseProxy3.uml: -------------------------------------------------------------------------------- 1 | @startuml 2 | participant ExposedThing1 3 | participant TD_repo1 4 | participant ConsumedThing2 5 | participant Discover2 6 | participant ExposedThing2 7 | participant TD_repo2 8 | participant ConsumedThing3 9 | participant Discover3 10 | 11 | == TD synchronization== 12 | ExposedThing1 -> ExposedThing1: TD change 13 | ExposedThing1 -> TD_repo1: register TD 14 | Discover2 -> TD_repo1: get TD by WoT.discover 15 | Discover2 <-- TD_repo1: TD 16 | 17 | create ExposedThing2 18 | Discover2 -> ExposedThing2: expose 19 | create ConsumedThing2 20 | Discover2 -> ConsumedThing2: callback 21 | 22 | ExposedThing2 -> TD_repo2: register TD 23 | Discover3 -> TD_repo2: get TD by WoT.discover 24 | Discover3 <-- TD_repo2: TD 25 | create ConsumedThing3 26 | ConsumedThing3 <-- Discover3: callback 27 | 28 | == device access == 29 | ConsumedThing3 -> ExposedThing2: turn on 30 | ExposedThing2 -> ConsumedThing2: turn on 31 | ConsumedThing2 -> ExposedThing1: turn on 32 | ConsumedThing2 <-- ExposedThing1: ok 33 | ExposedThing2 <-- ConsumedThing2: ok 34 | ConsumedThing3 <-- ExposedThing2: ok 35 | @enduml 36 | -------------------------------------------------------------------------------- /applications/thing-directory/ReverseProxy5.uml: -------------------------------------------------------------------------------- 1 | @startuml 2 | participant ExposedThing1 3 | participant TD_repo1 4 | participant ConsumedThing2 5 | participant Discover2 6 | participant ExposedThing2 7 | participant TD_repo2 8 | participant ConsumedThing3 9 | participant Discover3 10 | 11 | == TD synchronization== 12 | ExposedThing1 -> ExposedThing1: TD change 13 | ExposedThing1 -> TD_repo1: register TD 14 | Discover2 -> TD_repo1: get TD by WoT.discover 15 | Discover2 <-- TD_repo1: TD 16 | 17 | create ExposedThing2 18 | Discover2 -> ExposedThing2: expose 19 | create ConsumedThing2 20 | Discover2 -> ConsumedThing2: callback 21 | 22 | ExposedThing2 -> TD_repo2: register TD 23 | Discover3 -> TD_repo2: get TD by WoT.discover 24 | Discover3 <-- TD_repo2: TD 25 | create ConsumedThing3 26 | ConsumedThing3 <-- Discover3: callback 27 | 28 | == device access == 29 | 30 | ConsumedThing3 -> ExposedThing2: turn on 31 | alt device connected 32 | ExposedThing2 -> ConsumedThing2: turn on 33 | ConsumedThing2 -> ExposedThing1: turn on 34 | ConsumedThing2 <-- ExposedThing1: ok 35 | ConsumedThing2 --> ExposedThing2: ok 36 | ExposedThing2 --> ConsumedThing3: ok 37 | else device disconnected 38 | ExposedThing2 --> ConsumedThing2: turn on 39 | ConsumedThing2 --> ExposedThing2: ok 40 | ExposedThing2 --> ConsumedThing3: ok 41 | ConsumedThing2 -> ConsumedThing2: until connected 42 | ConsumedThing2 -> ExposedThing1: turn on 43 | ConsumedThing2 <-- ExposedThing1: ok 44 | ConsumedThing2 --> ExposedThing2: ok 45 | 46 | end 47 | 48 | 49 | @enduml 50 | -------------------------------------------------------------------------------- /applications/thing-directory/images/ReverseProxy1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w3c/wot-scripting-api/ad351eb2f8928442c4bd433ad0a9b5dd797e37d8/applications/thing-directory/images/ReverseProxy1.png -------------------------------------------------------------------------------- /applications/thing-directory/images/ReverseProxy2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w3c/wot-scripting-api/ad351eb2f8928442c4bd433ad0a9b5dd797e37d8/applications/thing-directory/images/ReverseProxy2.png -------------------------------------------------------------------------------- /applications/thing-directory/images/ReverseProxy3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w3c/wot-scripting-api/ad351eb2f8928442c4bd433ad0a9b5dd797e37d8/applications/thing-directory/images/ReverseProxy3.png -------------------------------------------------------------------------------- /applications/thing-directory/images/ReverseProxy4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w3c/wot-scripting-api/ad351eb2f8928442c4bd433ad0a9b5dd797e37d8/applications/thing-directory/images/ReverseProxy4.png -------------------------------------------------------------------------------- /applications/thing-directory/images/ReverseProxy5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w3c/wot-scripting-api/ad351eb2f8928442c4bd433ad0a9b5dd797e37d8/applications/thing-directory/images/ReverseProxy5.png -------------------------------------------------------------------------------- /images/scripting-action-data.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w3c/wot-scripting-api/ad351eb2f8928442c4bd433ad0a9b5dd797e37d8/images/scripting-action-data.png -------------------------------------------------------------------------------- /images/scripting-error-handling.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w3c/wot-scripting-api/ad351eb2f8928442c4bd433ad0a9b5dd797e37d8/images/scripting-error-handling.png -------------------------------------------------------------------------------- /images/scripting-read-data.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w3c/wot-scripting-api/ad351eb2f8928442c4bd433ad0a9b5dd797e37d8/images/scripting-read-data.png -------------------------------------------------------------------------------- /images/scripting-read-data.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 |
readProperty(
    string name,
    object options)
readProperty(...
ConsumedThing
ConsumedThing
 Request to read name with options via Protocol Binding 
 Request to read name with options via Protocol Binding 
WoT
implementation
WoT...
 Response (Body) 
 Response (Body) 
WoT
implementation
WoT...
read
value
read...
Promise<InteractionInput>
Promise<InteractionInput>
ExposedThing
ExposedThing
 return
value
return...
HAL
(sensors)
HAL...
PropertyReadHandler(
    string name,
    object options)
PropertyRe...
 Promise<InteractionOutput
Promise<I...
 Reading a Property
 Reading a Property
Viewer does not support full SVG 1.1
-------------------------------------------------------------------------------- /images/scripting-write-data.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w3c/wot-scripting-api/ad351eb2f8928442c4bd433ad0a9b5dd797e37d8/images/scripting-write-data.png -------------------------------------------------------------------------------- /images/scripting-write-data.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 |
writeProperty(
  string name,
  InteractionInput value,
  object options)
writeProperty(...
ConsumedThing
ConsumedThing
Request to write name with value and options via Protocol Binding 
Request to write name with value and options via Protocol Binding 
Promise<void>
Promise<void>
WoT
implementation
WoT...
  PropertyWriteHandler(
    string name,
    InteractionOutput value,
    object options)
  PropertyWriteHandler(    string name,    InteractionOutput value,    object options)
 Response 
 Response 
WoT
implementation
WoT...
write
value
write...
ExposedThing
ExposedThing
return
status
return...
HAL
(actuators)
HAL...
Promise<void>
Promise<void>
 Writing a Property
 Writing a Property
Viewer does not support full SVG 1.1
-------------------------------------------------------------------------------- /primer/README.md: -------------------------------------------------------------------------------- 1 | # Primer for Scripting API 2 | 3 | This document attempts to explain how [W3C WoT(Web of Things) Scripting API](https://w3c.github.io/wot-scripting-api/index.html) works. 4 | 5 | ## How Scripting API works? 6 | 7 | Scripting API is a building block to provide means for discovery, provisioning and control of thing that realizing [WoT Architecture](https://w3c.github.io/wot/architecture/wot-architecture.html). Scripting API consists of mainly two types of functions i.e. Expose Thing and Consumed Thing that are incorporated in WoT Server, WoT Client, or WoT Servient. The following sections attempt to explain how those work. 8 | 9 | ### 1\. ExposedThing in WoT Server 10 | 11 | ExposedThing controls building block of WoT and manages life cycle of WoT Server API. 12 | 13 | #### (A) Provisioning: Development and Setup 14 | 15 | Given a script that has ExposedThing command tied with device access function, ExposedThing generate a [WoT Thing Description 16 | (TD)](https://w3c.github.io/wot-thing-description/) and expose the server API. 17 | 18 | ![Fig.1](./images/Fig1.png) 19 | 20 | 21 | The followings shows the sequence of this figure. 22 | (1) In the development phase of WoT Server, Write a script uses ExposedThing with callback function that can accessing a thing.
23 | (2) In the setup phase, run the script and make each object.
24 | (3) When exposing WoTAPI, as an option, it would generate the TD and register to TD repository.
25 | (4) Invoking expose command, expose WoTAPI based on the object made by parsing the script. 26 | 27 | #### (B) Runtime: Control of thing 28 | 29 | At the runtime, when a WoTAPI is called,the callback is executed to control the Thing. 30 | 31 | ![Fig.2](./images/Fig2.png) 32 | 33 | #### (C) Runtime provisioning: add thing 34 | 35 | Given another script that has ExposedThing command tied with device access function, ExposedThing generate a TD and expose the server API. 36 | 37 | ![Fig.3](./images/Fig3.png) 38 | 39 | #### (D) Runtime: unregister thing 40 | 41 | A script that has an unregister thing can unregister the exposed thing, the callback function, and the TD. 42 | 43 | ![Fig.4](./images/Fig4.png) 44 | 45 | #### (E) Expose thing with semantics 46 | 47 | A script that comes with SemanticType generates a TD with semantic expression. It can be searched by accessing TD repository. 48 | 49 | ![Fig.5](./images/Fig5.png) 50 | 51 | #### (F) Runtime provisioning: Set permission to WoTAPI 52 | 53 | Generate a security token using e.g. IETF ACE and set permission to WoTAPI. Check the security token when WoTAPI is called. 54 | 55 | ![Fig.17](./images/Fig17.png) 56 | 57 | ### 1-1\. Using Expose Thing 58 | 59 | ExposedThing can be used in any layers i.e. Client, Cloud/Server, Gateway/Edge, and Device. 60 | 61 | ![Fig.6](./images/Fig6.png) 62 | 63 | ExposedThing in various layers and combinations. 64 | 65 | ![Fig.7](./images/Fig7.png) 66 | 67 | ### 2\. ConsumedThing in WoT Client 68 | 69 | ConsumedThing controls building blocks of WoT and manages life cycle of WoT Client API. 70 | 71 | #### (A) Runtime provisioning 72 | 73 | Search a device initiates a discovery and set up a ConsumedThing API to use. 74 | 75 | ![Fig.8](./images/Fig8.png) 76 | 77 | The followings shows the sequence of this figure. 78 | (a) Search a device from an application using discovery API.
79 | (i) Discovery function accesses to the TD repository.
80 | (ii) Download the TD.
81 | (iii) ConsumedThing parses the TD.
82 | (iv) ConsumedThing exposes client API.
83 | (a') Application receive the search result. 84 | 85 | #### (B) Runtime: Control of thing with abstracted manner 86 | 87 | Application access the device with method call. ConsumedThing interprit the access as WoTAPI call. 88 | 89 | ![Fig.9](./images/Fig9.png) 90 | 91 | #### (C) Runtime provisioning: search and use another thing 92 | 93 | Search another device initiates a discovery and set up the Thing API to use. The sequence is the same with (a). 94 | 95 | ![Fig.10](./images/Fig10.png) 96 | 97 | ### 2-1\. Using Consumed Thing 98 | 99 | ConsumedThing can be used in any layers. 100 | 101 | ![Fig.11](./images/Fig11.png) 102 | 103 | ConsumedThing in various layers and combinations. 104 | 105 | ![Fig.12](./images/Fig12.png) 106 | 107 | ### 2-2\. Example: WoT Server and WoT Client 108 | A use case that uses a WoT Server and a WoT Client is shown here i.e. An electronic appliance with WoT server is controlled by a remote controller with WoT client. 109 | 110 | ![Fig.13](./images/Fig13.png) 111 | 112 | The followings shows the sequence of this Figure. 113 | (1) Script has ExposedThing call with callback function that has access method to a LED lamp.
114 | (2) Run an script that has scripting API call.
115 | (3) ExposeThing generate a TD.
116 | (3') Register the TD to TD repository.
117 | (4) ExposeThing expose server API.
118 | (a) Application issues discovery command to search LED lamp.
119 | (i) ConsumedThing discover command to Discovery function.
120 | (ii) The discovery function queries TD repository to search LED lamp and receive the TD as the query result.
121 | (iii) ConsumedThing parses the TD.
122 | (iv) ConsumedThing expose client API.
123 | (a') Application receive result of the discovery.
124 | (b) Application for example issue a command for turn on the LED lamp. ConsumedThing interprit the command to WoTAPI command then access WoT server that manage the LED lamp. ExposedThing in the WoT server call callback function to turn on the LED lamp. 125 | 126 | ### 3\. ConsumedThing and ExposedThing in WoT Servient 127 | 128 | WoT servient consists of three part i.e. Server, Client, and Legacy communication. It deals ConsumedThing and ExposedThing methods described above. Application layer may have multiple scripts. 129 | 130 | ### 3-1\. Provisioning / Control of thing 131 | 132 | The followings shows the sequence of how WoT servient works for the provisioning and control of thing. 133 | 134 | (1) A script that has ExposedThing call with callback to control a LED lamp.
135 | (2) The script generates ExposedThing object.
136 | (3) ExposedThing generates a TD.
137 | (3') Register the TD to TD repository.
138 | (4) ExposedThing expose server API.
139 | (i) An application issues discover command to discovery function.
140 | (ii) The discovery function queries TD repository or uses local discovery to search LED lamp and receive the TD.
141 | (iii) ConsumedThing parses the TD.
142 | (iv) ConsumedThing expose Client API.
143 | (b) WoTAPI of Server receives a command for turn on. Then callback function registerd to ExposedThing is called. If the LED lamp is connected to Client, Protocol Binding interprit the command in the callback to appropriate WoTAPI command. If the LED lamp is connected to Legacy Communication, the callback function issues the legacy communication command to control the LED lamp. 144 | 145 | ![Fig.14](./images/Fig14.png) 146 | 147 | ### 3-2\. Event handling 148 | 149 | The followings shows the sequence of how WoT servient works for the events handling. 150 | (c) A WoT Servient that is connected to another WoT Servient , WoT Server, or a Legacy device receive an event from them. 151 | (d) A callback function described in script handles the event. For example: 152 | - (e) Access to underneath device: Issue action or property call described in TD#1 to the underneath device through ClientAPI. 153 | - (f) Proxy event: Transfer and issue same event to ExposedThing/WoTAPI. TD#1 and TD#2 have same definitions about the event. 154 | - (g) Generate another event: Transform the event and issue as another event through ExposedThing/WoTAPI. TD#1 has definition of the event defined by the device and TD#2 has definition of new event that is transformed from the original event. 155 | - (h) Make linked data: Save the event/events and allow to access by a property call through WoTAPI. TD#2 has a property definition that returns the event/events data based on an URI call. 156 | 157 | ![Fig.18](./images/Fig18.png) 158 | 159 | ### 3-3\. Example: Voting 160 | A use case that uses WoT Servients and a WoT Client is shown here. WoT servient #3 maybe on the cloud provide devices shadow and consolidate devices and expose a service. A script for Thing to Thing (T2T) service provides two functions: 161 | - Using heat sensor, automatically turn on air conditioner if getting cold. 162 | - Turn on/off air conditioner by voting "feel cold" or "feel hot" from WoT clients. Based on the consensus, T2T script issue on/off command of the air conditioner. 163 | 164 | Four types of scripts are placed in the application layers: 165 | - control script for a heat sensor to WoT Servient #1 166 | - control script for an air conditioner to WoT Servient #2 167 | - Thing to thing service to WoT Servient #3 168 | - Voting script to WoT Client 169 | 170 | ![Fig.15](./images/Fig15.png) 171 | 172 | The followings shows the sequence of the fugure. 173 | 174 | (1) 175 | 176 | - Develop a control script for a heat sensor that have callback function and upload to application layer in WoT Servient #1. 177 | - Develop a control script for an air conditioner that have callback function and upload to application layer in WoT Servient #2. 178 | - Develop a T2T service script that has ExposedThing command and calling method of things to application layer in WoT Servient #3. 179 | - Develop a Voting script that uses ConsumedThing command tha t is accesing to calling method of Thing to thing (T2T) service then download to WoT Client.
180 | 181 | (a) 182 | 183 | - A heat sensor script tries to discover heat sensor through discovery mechanism. 184 | - An air conditioner script tries to discover air conditioner through discovery mechanism. 185 | - A T2T service script tries to discover the heat sensor and the air conditioner through discovery mechanism that is query TD repository. 186 | 187 | (a') T2T service discovers things and gets TDs from TD repository.
188 | 189 | (iii) 190 | 191 | - ConsumedThing of WoT Servient #3 and WoT Client parse the TD . 192 | 193 | (iv) 194 | 195 | - ConsumedThing of WoT Servient #1 expose a client API for receiving periodical data from heat sensor. 196 | - ConsumedThing of WoT Servient #2 expose a client API for controlling an air conditioner. 197 | - ConsumedThing of WoT Servient #3 expose client APIs for receiving data from WoT Servient #1 and controlling an air conditioner to WoT Servient #2. 198 | - ConsumedThing of WoT Client expose a client API for voting. 199 | 200 | (2) 201 | 202 | - Control script for heat sensor registers a callback for event to ExposedThing. The callback calls the Client API that receive the data of heat sensor. 203 | - Control script for air conditioner registers a callback for action to ExposedThing. The callback calls the Client API that controls air conditioner. 204 | - T2T service script for voting registers a callback for action to ExposedThing. The callback calls the Client API that controls air conditioner of WoT Servient #2. 205 | 206 | (3) 207 | 208 | - ExposeThing of WoT Servient #1 generates a TD for receiving the sensor data. 209 | - ExposeThing of WoT Servient #2 generates a TD for controllig air conditioner. 210 | - ExposeThing of WoT Servient #3 generates a TD for voting. 211 | 212 | (3') ExposedThings register the TDs to TD repository.
213 | (4) ExposedThing expose the server APIs.
214 | 215 | At the runtime (b):
216 | Control route 1: T2T control 217 | 218 | - Heat sensor periodically generate heat values. 219 | - WoT Servient #1 receives the raw data and issues a callback in the object of ConsumedThing. Then the control script for heat sensor issues an event to T2T service in WoT Servient #3 that subscribe the event. 220 | - T2T service script check the value whether it surpass the threshold, if so, it calls turn on/off the air conditioner by issueing a WoTAPI command to WoT Servient #2\. When receiving the command, callback function in ExposedThing is called and control the air conditioner. 221 | 222 | Control route 2: Voting 223 | 224 | - Users can vote to express their preference by issueing too hot or too cold from a voting application that calls the object of ConsumedThing and ConsumedThing issues a voting command. The voting script issues a message to T2T service script. T2T service script counts the voting and if it surpass the threshold, issue command to control air conditioner by accessing Client API. 225 | - The object of ExposedThing receives voting from WoT API that connected to clients, the T2T service receives, counts voting, and if the count surpass the threshold, the T2T service calls callback function. 226 | - T2T service calls the control script for airconditioner, the control script issues command via the object of ConsumedThing to the air conditioner. 227 | 228 | ### 3-4\. Example: Layered structure 229 | 230 | WoT can provide layerd structure and following is an example. 231 | WoT Server are used in devices. 232 | WoT Servient are used in gateways / edges and on the Cloud service. 233 | WoT Client are used in clients. 234 | 235 | ![Fig.16](./images/Fig16.png) 236 | -------------------------------------------------------------------------------- /primer/images/Fig1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w3c/wot-scripting-api/ad351eb2f8928442c4bd433ad0a9b5dd797e37d8/primer/images/Fig1.png -------------------------------------------------------------------------------- /primer/images/Fig10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w3c/wot-scripting-api/ad351eb2f8928442c4bd433ad0a9b5dd797e37d8/primer/images/Fig10.png -------------------------------------------------------------------------------- /primer/images/Fig11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w3c/wot-scripting-api/ad351eb2f8928442c4bd433ad0a9b5dd797e37d8/primer/images/Fig11.png -------------------------------------------------------------------------------- /primer/images/Fig12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w3c/wot-scripting-api/ad351eb2f8928442c4bd433ad0a9b5dd797e37d8/primer/images/Fig12.png -------------------------------------------------------------------------------- /primer/images/Fig13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w3c/wot-scripting-api/ad351eb2f8928442c4bd433ad0a9b5dd797e37d8/primer/images/Fig13.png -------------------------------------------------------------------------------- /primer/images/Fig14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w3c/wot-scripting-api/ad351eb2f8928442c4bd433ad0a9b5dd797e37d8/primer/images/Fig14.png -------------------------------------------------------------------------------- /primer/images/Fig15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w3c/wot-scripting-api/ad351eb2f8928442c4bd433ad0a9b5dd797e37d8/primer/images/Fig15.png -------------------------------------------------------------------------------- /primer/images/Fig16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w3c/wot-scripting-api/ad351eb2f8928442c4bd433ad0a9b5dd797e37d8/primer/images/Fig16.png -------------------------------------------------------------------------------- /primer/images/Fig17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w3c/wot-scripting-api/ad351eb2f8928442c4bd433ad0a9b5dd797e37d8/primer/images/Fig17.png -------------------------------------------------------------------------------- /primer/images/Fig18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w3c/wot-scripting-api/ad351eb2f8928442c4bd433ad0a9b5dd797e37d8/primer/images/Fig18.png -------------------------------------------------------------------------------- /primer/images/Fig2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w3c/wot-scripting-api/ad351eb2f8928442c4bd433ad0a9b5dd797e37d8/primer/images/Fig2.png -------------------------------------------------------------------------------- /primer/images/Fig3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w3c/wot-scripting-api/ad351eb2f8928442c4bd433ad0a9b5dd797e37d8/primer/images/Fig3.png -------------------------------------------------------------------------------- /primer/images/Fig4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w3c/wot-scripting-api/ad351eb2f8928442c4bd433ad0a9b5dd797e37d8/primer/images/Fig4.png -------------------------------------------------------------------------------- /primer/images/Fig5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w3c/wot-scripting-api/ad351eb2f8928442c4bd433ad0a9b5dd797e37d8/primer/images/Fig5.png -------------------------------------------------------------------------------- /primer/images/Fig6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w3c/wot-scripting-api/ad351eb2f8928442c4bd433ad0a9b5dd797e37d8/primer/images/Fig6.png -------------------------------------------------------------------------------- /primer/images/Fig7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w3c/wot-scripting-api/ad351eb2f8928442c4bd433ad0a9b5dd797e37d8/primer/images/Fig7.png -------------------------------------------------------------------------------- /primer/images/Fig8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w3c/wot-scripting-api/ad351eb2f8928442c4bd433ad0a9b5dd797e37d8/primer/images/Fig8.png -------------------------------------------------------------------------------- /primer/images/Fig9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w3c/wot-scripting-api/ad351eb2f8928442c4bd433ad0a9b5dd797e37d8/primer/images/Fig9.png -------------------------------------------------------------------------------- /rationale.md: -------------------------------------------------------------------------------- 1 | # Rationale for Scripting API design 2 | 3 | This document attempts to explain why various decision for [W3C WoT(Web of Things) Scripting API](https://w3c.github.io/wot-scripting-api/index.html) were made the way they were. 4 | 5 | ## Using factories vs constructors 6 | As discussed in [issue 3](https://github.com/w3c/wot-scripting-api/issues/3), and as suggested [here](https://github.com/w3c/wot-scripting-api/issues/3#issuecomment-283746764), the guidelines are these: 7 | 8 | > The root WoT object should not be constructible. It represents the UA's magic ability to discover things, similar to how the Navigator object represents the UA's magic ability to do a bunch of stuff. A namespace might be a good replacement here, if it truly has no state. 9 | 10 | > Avoid constructor overloads. A true constructor should be something that directly copies the given essential data into internal fields. If there is a way to infer the essential data from some other data, then that should be a factory. So maybe ThingDescription is the essential data, and if we can infer that from a name or URL, then factory should be used (perhaps static factory, e.g. ExposedThing.fromName()). 11 | 12 | > The idea of using a builder pattern (first create an X, then call X.expose() on it to turn into another object, or X-with-UA-magic) is rather unidiomatic in JavaScript. The better way to represent something without UA magic is just a dictionary. Having the same class represent two very distinct things is not great. 13 | 14 | 15 | Resolutions: 16 | - The browser implementations of the WoT Scripting API uses a namespace object `wot` in the browser. 17 | - Non-browser implementations that use various runtimes may use either a namespace object `wot`, or an API object provided by the `require()` or `import()` or similar mechanisms. 18 | - The `ConsumedThing` and `ExposedThing` objects are expected to be created by factory methods, though constructors are defined. 19 | - Interaction data can be retrieved with an attempted conversion by implementation as convenience interface for most JavaScript types, or as streams the applications can interpret. 20 | - Errors during protocol operations are exposed to applications. 21 | 22 | ## Discovery API 23 | 24 | Represents the second stage of discovery in the [2-stage discovery process](https://github.com/w3c/wot-discovery/blob/master/proposals/directory.md), i.e. the 25 | operational stage when discovery is configured and discovery queries may be served. 26 | 27 | The discovery results may be filtered either at the source or at reception, by constraints made on the Thing Description. 28 | 29 | Based on [issue 16](https://github.com/w3c/wot-scripting-api/issues/16) there is a need to be able to tell the WoT Runtime to stop discovery (or in the case of open ended requests, suppress further discovery results). Therefore returning `Promise` was not an option any more, since cancellable `Promise`s were [dropped](https://github.com/tc39/proposal-cancelable-promises). 30 | 31 | Resolutions: 32 | - Use [Observables](https://github.com/tc39/proposal-observable) or similar pattern for controlling the discovery process (subscribe, unsubscribe, handle notifications). 33 | - Use a single filter definition that also contains a property for discovery type, defaulting to `"any"`. It is simpler and more intuitive to use than having a separate parameter for discovery type. Some of the discovery types, such as registry/directory based discovery also require another parameter for the address of the directory. This can be provided as a required property in the discovery filter, described in the discovery algorithm. 34 | 35 | ## Server API (`ExposedThing`) 36 | Scripts that define Exposed Things should ensure the following: 37 | 1. define properties, actions and events according to the Thing Description. 38 | 2. define request handler functions to implement the serving end for the Client API. 39 | 40 | ## Client API (`ConsumedThing`) 41 | Scripts that use the Client API are basically sending requests to servers in order to retrieve or update properties, invoke actions, and observe properties, actions and events. When the `ConsumedThing` is fetched, its Thing Description is also fetched, then client scripts can track changes by subscribing to events that signal TD changes. 42 | 43 | For browser compatibility of the Client API, events are used with the DOM convention: an Event (or Event sub-class) object is passed as an argument to the event listener, which contains a property with the event payload data, instead the Node.js convention where payload is directly passed to the event listener as arguments. 44 | 45 | There is no Client API for creating Things. ExposedThings can be created only locally through the Server API. However, a WoT Runtime may have a special management Thing exposed that would accept actions for installing, uninstalling, running and stopping scripts in that WoT Runtime. These scripts may create local ExposedThings, so the use case of remote Thing creation can be implemented. 46 | 47 | Write interactions only return success or error, not the written value as well. 48 | Based on [issue 193](https://github.com/w3c/wot-scripting-api/issues/193) and discussions during Scripting calls, TDs should fully capture the schema of the Property values, including precision and alternative formats, so that these should not be determined from analyzing the return value. If a return value is needed from an interaction, an 49 | Action should be used instead of a Property. 50 | 51 | -------------------------------------------------------------------------------- /releases/README.md: -------------------------------------------------------------------------------- 1 | # How to Edit the Draft for Publication 2 | 3 | In each sub directory, you can find the relevant files for the publication process. 4 | In general, you should always consult the W3C Guide page at . 5 | 6 | ## Checklist 7 | 8 | * Make sure that you update the recent specification changes 9 | 10 | ## Files 11 | 12 | * Overview.html - static HTML for publication 13 | * diff.html - diff between the previous published version and Overview.html 14 | * index.html - same as the index.html at ([or at the root of the repository](../index.html)), except for changing the respec option from ED to the version you are aiming at such as CR, WD, etc. 15 | * static.html - static HTML generated by ReSpec from the index.html above 16 | 17 | ## How to Generate Each File 18 | 19 | Overview.html is generated as follows: 20 | 21 | 1. Copy index.html from [the root of the repository](../index.html). 22 | 2. Change `specStatus` to `"NOTE"` from `"ED"` (or `"REC"`, `"PR"`, etc.). 23 | 3. Generate static.html by ReSpec from (click "ReSpec" top right and choose "Export" then export as "HTML"). Make sure that you disable browser extensions or open in private window. 24 | 4. Output Overview.html as a result of [HTML Tidy](https://www.html-tidy.org/). Use the following command (`tidy -ashtml -i static.html > Overview.html`). The `-ashtml` option is needed until [this issue](https://github.com/htacg/tidy-html5/issues/660) is resolved at HTML Tidy. 25 | 5. Fix duplicate IDs (see [fix-id.pl](fix-id.pl)) caused by ReSpec not supporting conformance classes 26 | * `cp Overview.html backup.html; ./fix-id.pl backup.html > Overview.html` 27 | 28 | ## How to Add your Edits based on the Pubrules Errors and Warnings 29 | 30 | After checking Overview.html using the [Pubrules checker](https://www.w3.org/pubrules/), we have to edit index.html and then 31 | regenerate the static HTML based on the procedure above to make it easier to generate a Pull Request to update the original 32 | at later. 33 | 34 | 1. Edit index.html, 35 | 2. Generate static.html by ReSpec from the index.html (click "ReSpec" top right and choose "Export" then export as "HTML", 36 | 3. copy static.html to Overview.html and tidy it up, 37 | 4. If there are any remaining errors/warnings with the Pubrules checker results, repeat the edit by going back to #1. 38 | 5. Generate diff.html via 39 | 40 | Note: You cannot use a tool like since they do not have static html as a resource that the pubrule 41 | checkers can use. 42 | 43 | ## Manual Link Corrections 44 | 45 | Some redirects come from [specref](https://www.specref.org/) not being up to date. In those cases, you need to manually update the final Overview.html. 46 | -------------------------------------------------------------------------------- /releases/fix-id.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | while (<>) { 4 | chomp; 5 | if (/id="webidl-([0-9]+)"/) { 6 | $num = $1; 7 | } elsif (/id="idl-def-wot"/) { 8 | s/id="idl-def-wot"/id="idl-def-wot-${num}"/; 9 | } 10 | print "$_\n"; 11 | } 12 | -------------------------------------------------------------------------------- /releases/note1/images/scripting-action-data.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w3c/wot-scripting-api/ad351eb2f8928442c4bd433ad0a9b5dd797e37d8/releases/note1/images/scripting-action-data.png -------------------------------------------------------------------------------- /releases/note1/images/scripting-error-handling.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w3c/wot-scripting-api/ad351eb2f8928442c4bd433ad0a9b5dd797e37d8/releases/note1/images/scripting-error-handling.png -------------------------------------------------------------------------------- /releases/note1/images/scripting-read-data.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w3c/wot-scripting-api/ad351eb2f8928442c4bd433ad0a9b5dd797e37d8/releases/note1/images/scripting-read-data.png -------------------------------------------------------------------------------- /releases/note1/images/scripting-read-data.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 |
readProperty(
    string name,
    object options)
readProperty(...
ConsumedThing
ConsumedThing
 Request to read name with options via Protocol Binding 
 Request to read name with options via Protocol Binding 
WoT
implementation
WoT...
 Response (Body) 
 Response (Body) 
WoT
implementation
WoT...
read
value
read...
Promise<InteractionInput>
Promise<InteractionInput>
ExposedThing
ExposedThing
 return
value
return...
HAL
(sensors)
HAL...
PropertyReadHandler(
    string name,
    object options)
PropertyRe...
 Promise<InteractionOutput
Promise<I...
 Reading a Property
 Reading a Property
Viewer does not support full SVG 1.1
-------------------------------------------------------------------------------- /releases/note1/images/scripting-write-data.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w3c/wot-scripting-api/ad351eb2f8928442c4bd433ad0a9b5dd797e37d8/releases/note1/images/scripting-write-data.png -------------------------------------------------------------------------------- /releases/note1/images/scripting-write-data.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 |
writeProperty(
  string name,
  InteractionInput value,
  object options)
writeProperty(...
ConsumedThing
ConsumedThing
Request to write name with value and options via Protocol Binding 
Request to write name with value and options via Protocol Binding 
Promise<void>
Promise<void>
WoT
implementation
WoT...
  PropertyWriteHandler(
    string name,
    InteractionOutput value,
    object options)
  PropertyWriteHandler(    string name,    InteractionOutput value,    object options)
 Response 
 Response 
WoT
implementation
WoT...
write
value
write...
ExposedThing
ExposedThing
return
status
return...
HAL
(actuators)
HAL...
Promise<void>
Promise<void>
 Writing a Property
 Writing a Property
Viewer does not support full SVG 1.1
-------------------------------------------------------------------------------- /releases/note1/manifest.txt: -------------------------------------------------------------------------------- 1 | index.html 2 | images/scripting-write-data.png 3 | images/scripting-read-data.svg 4 | images/scripting-action-data.svg 5 | images/scripting-action-data.png 6 | images/scripting-error-handling.png 7 | images/scripting-read-data.png 8 | images/scripting-error-handling.svg 9 | images/scripting-write-data.svg 10 | -------------------------------------------------------------------------------- /releases/note2/Makefile: -------------------------------------------------------------------------------- 1 | static = ~/Downloads/NOTE-wot-scripting-api-20230930.html 2 | 3 | ### 1. edit index.html 4 | ### 2. generate a static HTML (e.g., NOTE-wot-scripting-api-20230930.html) using ReSpec 5 | ### 3. then use the following "update target" (by "make update") to get static.html and Overview.html 6 | update: 7 | mv $(static) static.html 8 | cp static.html Overview.html; tidy -i -m Overview.html 9 | cp Overview.html backup.html; ./fix-id.pl backup.html > Overview.html 10 | -------------------------------------------------------------------------------- /releases/note2/README.md: -------------------------------------------------------------------------------- 1 | # How to edit the draft for publication 2 | 3 | * generate original html by ReSpec (click "ReSpec" top right and choose "Export" then export as "HTML") 4 | * copy output to index.html and use the [Pubrules checker](https://www.w3.org/pubrules/) 5 | -------------------------------------------------------------------------------- /releases/note2/fix-id.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | while (<>) { 4 | chomp; 5 | if (/id="webidl-([0-9]+)"/) { 6 | $num = $1; 7 | } elsif (/id="idl-def-wot"/) { 8 | s/id="idl-def-wot"/id="idl-def-wot-${num}"/; 9 | } 10 | print "$_\n"; 11 | } 12 | -------------------------------------------------------------------------------- /releases/note2/images/scripting-action-data.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w3c/wot-scripting-api/ad351eb2f8928442c4bd433ad0a9b5dd797e37d8/releases/note2/images/scripting-action-data.png -------------------------------------------------------------------------------- /releases/note2/images/scripting-error-handling.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w3c/wot-scripting-api/ad351eb2f8928442c4bd433ad0a9b5dd797e37d8/releases/note2/images/scripting-error-handling.png -------------------------------------------------------------------------------- /releases/note2/images/scripting-read-data.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w3c/wot-scripting-api/ad351eb2f8928442c4bd433ad0a9b5dd797e37d8/releases/note2/images/scripting-read-data.png -------------------------------------------------------------------------------- /releases/note2/images/scripting-read-data.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 |
readProperty(
    string name,
    object options)
readProperty(...
ConsumedThing
ConsumedThing
 Request to read name with options via Protocol Binding 
 Request to read name with options via Protocol Binding 
WoT
implementation
WoT...
 Response (Body) 
 Response (Body) 
WoT
implementation
WoT...
read
value
read...
Promise<InteractionInput>
Promise<InteractionInput>
ExposedThing
ExposedThing
 return
value
return...
HAL
(sensors)
HAL...
PropertyReadHandler(
    string name,
    object options)
PropertyRe...
 Promise<InteractionOutput
Promise<I...
 Reading a Property
 Reading a Property
Viewer does not support full SVG 1.1
-------------------------------------------------------------------------------- /releases/note2/images/scripting-write-data.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w3c/wot-scripting-api/ad351eb2f8928442c4bd433ad0a9b5dd797e37d8/releases/note2/images/scripting-write-data.png -------------------------------------------------------------------------------- /releases/note2/images/scripting-write-data.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 |
writeProperty(
  string name,
  InteractionInput value,
  object options)
writeProperty(...
ConsumedThing
ConsumedThing
Request to write name with value and options via Protocol Binding 
Request to write name with value and options via Protocol Binding 
Promise<void>
Promise<void>
WoT
implementation
WoT...
  PropertyWriteHandler(
    string name,
    InteractionOutput value,
    object options)
  PropertyWriteHandler(    string name,    InteractionOutput value,    object options)
 Response 
 Response 
WoT
implementation
WoT...
write
value
write...
ExposedThing
ExposedThing
return
status
return...
HAL
(actuators)
HAL...
Promise<void>
Promise<void>
 Writing a Property
 Writing a Property
Viewer does not support full SVG 1.1
-------------------------------------------------------------------------------- /releases/wd3/manifest.txt: -------------------------------------------------------------------------------- 1 | Overview.html 2 | diff.html 3 | -------------------------------------------------------------------------------- /releases/wd4/README.md: -------------------------------------------------------------------------------- 1 | # WoT Scripting API - Release Notes 2 | 3 | The changes compared to [previous version](https://www.w3.org/TR/2018/WD-wot-scripting-api-20181129/) are also enumerated in the 4 | [Changes](https://w3c.github.io/wot-scripting-api/#Changes) section of the spec. 5 | 6 | This version, introducing the following major changes: 7 | - Remove fetch() for fetching a TD (delegated to external API). 8 | - Remove Observer and use W3C TAG recommended design patterns. 9 | - Align the discovery API to other similar APIs (such as W3C Generic Sensor API). 10 | -Remove the large data definition API for constructing TDs and leverage using ThingDescription instead. 11 | - Add missing algorithms and rework most existing ones. 12 | - Allow constructors for ConsumedThing and ExposedThing. 13 | - Add API rationale as an appendix to this document. 14 | 15 | For a complete list of changes, see the [github change log](https://github.com/w3c/wot-scripting-api/commits/master). -------------------------------------------------------------------------------- /releases/wd4/manifest.txt: -------------------------------------------------------------------------------- 1 | Overview.html 2 | -------------------------------------------------------------------------------- /typescript/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ -------------------------------------------------------------------------------- /typescript/README.md: -------------------------------------------------------------------------------- 1 | # TypeScript definitions 2 | 3 | TypeScript definition files can be used by implementations such as [Eclipse Thingweb](https://projects.eclipse.org/projects/iot.thingweb). 4 | 5 | We currently provide the following TypeScript definition files: 6 | * [WoT Scripting API](./scripting-api) 7 | * [WoT Thing Description](./thing-description) 8 | * [WoT Thing Model](./thing-model) 9 | 10 | ## Notes on NPM publishing 11 | 12 | Run `npm publish --workspaces` in `typescript` folder. 13 | 14 | Note: to publish just a subfolder use `npm publish --workspaces -w ./` 15 | 16 | Requirement: npm version 7+ 17 | -------------------------------------------------------------------------------- /typescript/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "wot-typescript", 3 | "version": "0.0.1", 4 | "private": true, 5 | "description": "A collection of Web of Things utilities for typescript", 6 | "scripts": { 7 | }, 8 | "repository": { 9 | "type": "git", 10 | "url": "https://github.com/w3c/wot-scripting-api/tree/main/typescript" 11 | }, 12 | "keywords": [ 13 | "Web", 14 | "of", 15 | "Things", 16 | "WoT", 17 | "types", 18 | "type" 19 | ], 20 | "author": "W3C Web of Things Working Group", 21 | "license": "W3C-20150513", 22 | "workspaces": [ 23 | "thing-description", 24 | "thing-model", 25 | "scripting-api" 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /typescript/scripting-api/README.md: -------------------------------------------------------------------------------- 1 | # wot-typescript-definitions 2 | 3 | A TypeScript definition file for the WoT Scripting API to be used by implementations such as [Eclipse Thingweb](https://projects.eclipse.org/projects/iot.thingweb). 4 | 5 | ## Notes on usage 6 | 7 | These definitions are imported using npm. 8 | https://www.npmjs.com/package/wot-typescript-definitions 9 | -------------------------------------------------------------------------------- /typescript/scripting-api/index.d.ts: -------------------------------------------------------------------------------- 1 | type DeepPartial = T extends object ? { 2 | [P in keyof T]?: T[P] extends Array 3 | ? Array> 4 | : DeepPartial 5 | } : T; 6 | declare namespace WoT { 7 | 8 | /** 9 | * Starts the discovery process that will provide {@link ThingDescription} 10 | * objects for Thing Descriptions that match an optional {@link filter} 11 | * argument of type {@link ThingFilter}. 12 | * 13 | * @param filter represents the constraints for discovering Things as key-value pairs 14 | */ 15 | export function discover(filter?: ThingFilter): Promise; 16 | 17 | /** 18 | * Starts the discovery process that, given a TD Directory {@link url}, will 19 | * provide {@link ThingDescription} objects for Thing Descriptions that 20 | * match an optional {@link filter} argument of type {@link ThingFilter}. 21 | * 22 | * @param url URL pointing to a TD Directory. 23 | * @param filter represents the constraints for discovering Things as key-value pairs 24 | */ 25 | export function exploreDirectory(url: string, filter?: ThingFilter): Promise; 26 | 27 | /** 28 | * Requests a {@link ThingDescription} from the given {@link url}. 29 | * 30 | * @param url The URL to request the Thing Description from. 31 | */ 32 | export function requestThingDescription(url: string): Promise; 33 | 34 | /** 35 | * Accepts a ThingDescription and returns a ConsumedThing 36 | * @param td thing description 37 | */ 38 | export function consume(td: ThingDescription): Promise; 39 | 40 | /** 41 | * Accepts an init dictionary similar to a ThingDescription. 42 | * It returns a ExposedThing 43 | * 44 | * @param ptd Partial thing description 45 | */ 46 | export function produce(init: ExposedThingInit): Promise; 47 | 48 | 49 | /** 50 | * Dictionary that represents the constraints for discovering Things as key-value pairs. 51 | */ 52 | export interface ThingFilter { 53 | /** 54 | * The fragment field represents a template object used for matching against discovered Things. 55 | */ 56 | fragment?: object; 57 | } 58 | 59 | /** 60 | * The ThingDiscovery object is constructed given a filter and provides the properties and methods 61 | * controlling the discovery process. 62 | */ 63 | export interface ThingDiscoveryProcess extends AsyncIterable { 64 | filter?: ThingFilter; 65 | done: boolean; 66 | error?: Error; 67 | stop(): void; 68 | } 69 | 70 | 71 | /** 72 | * WoT provides a unified representation for data exchange between Things, standardized in the Wot Things Description specification. 73 | * In this version of the API, Thing Descriptions is expected to be a parsed JSON object. 74 | */ 75 | export type ThingDescription = import("wot-thing-description-types").ThingDescription; 76 | export type ExposedThingInit = DeepPartial; 77 | 78 | 79 | export type DataSchemaValue = (null | boolean | number | string | object | DataSchemaValue[]); 80 | export type InteractionInput = (ReadableStream | DataSchemaValue); 81 | 82 | export interface InteractionOutput { 83 | data?: ReadableStream; 84 | dataUsed: boolean; 85 | form?: Form; 86 | schema?: DataSchema; 87 | arrayBuffer(): Promise; 88 | value(): Promise; 89 | } 90 | 91 | export interface Subscription { 92 | active:boolean, 93 | stop(options?: InteractionOptions):Promise 94 | } 95 | 96 | /** 97 | * The ConsumedThing interface instance represents a client API to operate a Thing. 98 | */ 99 | export interface ConsumedThing { 100 | /** 101 | * Reads a Property value. 102 | * Takes as arguments propertyName and optionally options. 103 | * It returns a Promise that resolves with a Property value represented as an 104 | * InteractionOutput object or rejects on error. 105 | */ 106 | readProperty(propertyName: string, options?: InteractionOptions): Promise; 107 | 108 | /** 109 | * Reads all properties of the Thing with one or multiple requests. 110 | * Takes options as optional argument. 111 | * It returns a Promise that resolves with a PropertyMap object that 112 | * maps keys from Property names to values. 113 | */ 114 | readAllProperties(options?: InteractionOptions): Promise; 115 | 116 | /** 117 | * Reads multiple Property values with one or multiple requests. 118 | * Takes as arguments propertyNames and optionally options. 119 | * It returns a Promise that resolves with a PropertyMap object that 120 | * maps keys from propertyNames to values 121 | */ 122 | readMultipleProperties(propertyNames: string[], options?: InteractionOptions): Promise; 123 | 124 | /** 125 | * Writes a single Property. 126 | * Takes as arguments propertyName, value and optionally options. 127 | * It returns a Promise that resolves on success and rejects on failure. 128 | */ 129 | writeProperty(propertyName: string, value: InteractionInput, options?: InteractionOptions): Promise; 130 | 131 | /** 132 | * Writes a multiple Property values with one request. 133 | * Takes as arguments properties - as an object with keys being Property names 134 | * and values as Property values - and optionally options. 135 | * It returns a Promise that resolves on success and rejects on failure. 136 | */ 137 | writeMultipleProperties(valueMap: PropertyWriteMap, options?: InteractionOptions): Promise; 138 | 139 | /** 140 | * Makes a request for invoking an Action and return the result. 141 | * Takes as arguments actionName, optionally params and optionally options. 142 | * It returns a Promise that resolves with the result of the Action represented 143 | * as an InteractionOutput object, or rejects with an error. 144 | */ 145 | invokeAction(actionName: string, params?: InteractionInput, options?: InteractionOptions): Promise; 146 | 147 | /** 148 | * Makes a request for Property value change notifications. 149 | * Takes as arguments propertyName, listener and optionally options. 150 | * It returns a Promise that resolves on success and rejects on failure. 151 | */ 152 | observeProperty(name: string, listener: WotListener, errorListener?: ErrorListener, options?: InteractionOptions): Promise; 153 | 154 | /** 155 | * Makes a request for subscribing to Event notifications. 156 | * Takes as arguments eventName, listener and optionally options. 157 | * It returns a Promise to signal success or failure. 158 | */ 159 | subscribeEvent(name: string, listener: WotListener, errorListener?: ErrorListener, options?: InteractionOptions): Promise; 160 | 161 | /** 162 | * Returns the the object that represents the Thing Description. 163 | */ 164 | getThingDescription(): ThingDescription; 165 | } 166 | 167 | export interface InteractionOptions { 168 | formIndex?: number; 169 | uriVariables?: object; 170 | data?: any; 171 | } 172 | 173 | export type PropertyReadMap = Map; 174 | export type PropertyWriteMap = Map; 175 | 176 | export type WotListener = (data: InteractionOutput) => void; 177 | export type ErrorListener = (error: Error) => void; 178 | 179 | export interface InteractionData { 180 | data?: ReadableStream; 181 | dataUsed: boolean; 182 | form?: Form; 183 | schema?: DataSchema; 184 | arrayBuffer(): Promise; 185 | value(): Promise; 186 | } 187 | 188 | export type Form = { [key: string]: any; }; 189 | export type DataSchema = { [key: string]: any; }; 190 | 191 | /** 192 | * The ExposedThing interface is the server API to operate the Thing that allows defining request handlers, Property, Action, and Event interactions. 193 | **/ 194 | export interface ExposedThing { 195 | /** 196 | * Start serving external requests for the Thing, so that WoT Interactions using Properties, Actions and Events will be possible. 197 | */ 198 | expose(): Promise; 199 | 200 | /** 201 | * Stop serving external requests for the Thing and destroy the object. Note that eventual unregistering should be done before invoking this method. 202 | */ 203 | destroy(): Promise; 204 | 205 | /** 206 | * Takes name as string argument and handler as argument of type PropertyReadHandler. 207 | * Sets the handler function for reading the specified Property matched by name. 208 | * Throws on error. 209 | * Returns a reference to the same object for supporting chaining. 210 | */ 211 | setPropertyReadHandler(name: string, handler: PropertyReadHandler): ExposedThing; 212 | 213 | /** 214 | * Takes name as string argument and handler as argument of type PropertyWriteHandler. 215 | * Sets the handler function for writing the specified Property matched by name. 216 | * Throws on error. 217 | * Returns a reference to the same object for supporting chaining. 218 | */ 219 | setPropertyWriteHandler(name: string, handler: PropertyWriteHandler): ExposedThing; 220 | 221 | /** 222 | * Takes as arguments name and handler. 223 | * Sets the service handler that defines what to do when a request is received for 224 | * observing the specified Property matched by name. 225 | * Throws on error. 226 | * Returns a reference to the same object for supporting chaining. 227 | */ 228 | setPropertyObserveHandler(name: string, handler: PropertyReadHandler): ExposedThing; 229 | 230 | /** 231 | * Takes as arguments name and handler. 232 | * Sets the service handler that defines what to do when a request is received for 233 | * unobserving the specified Property matched by name. 234 | * Throws on error. 235 | * Returns a reference to the same object for supporting chaining. 236 | */ 237 | setPropertyUnobserveHandler(name: string, handler: PropertyReadHandler): ExposedThing; 238 | 239 | /** 240 | * Takes as arguments name denoting a Property name. 241 | * Triggers emitting a notification to all observers. 242 | */ 243 | emitPropertyChange(name: string): void; 244 | 245 | /** 246 | * Takes name as string argument and handler as argument of type ActionHandler. 247 | * Sets the handler function for the specified Action matched by name. 248 | * Throws on error. 249 | * Returns a reference to the same object for supporting chaining. 250 | */ 251 | setActionHandler(name: string, handler: ActionHandler): ExposedThing; 252 | 253 | /** 254 | * Takes as arguments name and handler. 255 | * Sets the handler function that defines what to do when a subscription request 256 | * is received for the specified Event matched by name. 257 | * Throws on error. 258 | * Returns a reference to the same object for supporting chaining. 259 | */ 260 | setEventSubscribeHandler(name: string, handler: EventSubscriptionHandler): ExposedThing; 261 | 262 | /** 263 | * Takes as arguments name and handler. 264 | * Sets the handler function that defines what to do when the specified Event 265 | * matched by name is unsubscribed from. 266 | * Throws on error. 267 | * Returns a reference to the same object for supporting chaining. 268 | */ 269 | setEventUnsubscribeHandler(name: string, handler: EventSubscriptionHandler): ExposedThing; 270 | 271 | /** 272 | * Takes as arguments name denoting an Event name and optionally data. 273 | * Triggers emitting the Event with optional data. 274 | */ 275 | emitEvent(name: string, data?: InteractionInput): void; 276 | 277 | /** 278 | * Returns the the object that represents the Thing Description. 279 | */ 280 | getThingDescription(): ThingDescription; 281 | } 282 | 283 | export type PropertyReadHandler = (options?: InteractionOptions) => Promise; 284 | 285 | export type PropertyWriteHandler = (value: InteractionOutput, options?: InteractionOptions) => Promise; 286 | 287 | export type ActionHandler = (params: InteractionOutput, options?: InteractionOptions) => Promise; 288 | 289 | export type EventSubscriptionHandler = (options?: InteractionOptions) => Promise; 290 | 291 | } 292 | 293 | declare module "wot-typescript-definitions" { 294 | export = WoT; 295 | } 296 | -------------------------------------------------------------------------------- /typescript/scripting-api/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "wot-typescript-definitions", 3 | "version": "0.8.0-SNAPSHOT.30", 4 | "description": "TypeScript definitions for the W3C WoT Scripting API", 5 | "author": "W3C Web of Things Working Group", 6 | "license": "W3C-20150513", 7 | "repository": { 8 | "type": "git", 9 | "url": "git+https://github.com/w3c/wot-scripting-api.git#master" 10 | }, 11 | "keywords": [ 12 | "Web", 13 | "W3C", 14 | "WoT", 15 | "IoT", 16 | "things", 17 | "scripting", 18 | "typescript", 19 | "types" 20 | ], 21 | "publishConfig": { 22 | "access": "public" 23 | }, 24 | "types": "index.d.ts", 25 | "dependencies": { 26 | "wot-thing-description-types": "1.1.0-12-March-2025" 27 | }, 28 | "scripts": { 29 | "build": "json2ts schema/td-json-schema-validation.json | sed -e 's/WoTTDSchema02June2021/ThingDescription/' > thing-description.d.ts" 30 | }, 31 | "devDependencies": { 32 | "json-schema-to-typescript": "^10.1.4" 33 | }, 34 | "bugs": { 35 | "url": "https://github.com/w3c/wot-scripting-api/issues" 36 | }, 37 | "homepage": "https://github.com/w3c/wot-scripting-api/tree/master#readme", 38 | "main": "index.js" 39 | } 40 | -------------------------------------------------------------------------------- /typescript/scripting-api/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "lib" : ["es2015","dom"], 5 | "module": "commonjs", 6 | "outDir": "dist", 7 | "sourceMap": true, 8 | "noImplicitAny": true, 9 | "removeComments": true, 10 | "noLib": false, 11 | "preserveConstEnums": true, 12 | "experimentalDecorators": true, 13 | "declaration": true 14 | }, 15 | "include": [ 16 | "src/**/*" 17 | ] 18 | } -------------------------------------------------------------------------------- /typescript/thing-description/README.md: -------------------------------------------------------------------------------- 1 | # wot-thing-description-types 2 | 3 | A TypeScript definition file for the WoT Thing Description to be used by implementations such as [Eclipse Thingweb](https://projects.eclipse.org/projects/iot.thingweb). 4 | 5 | ## Notes on usage 6 | 7 | These definitions are imported using npm. 8 | https://www.npmjs.com/package/wot-thing-description-types 9 | -------------------------------------------------------------------------------- /typescript/thing-description/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "wot-thing-description-types", 3 | "version": "1.1.0-12-March-2025", 4 | "description": "Official Typescript definition type for W3C Thing Description", 5 | "types": "thing-description.d.ts", 6 | "repository": { 7 | "type": "git", 8 | "url": "git+https://github.com/w3c/wot-scripting-api.git#main" 9 | }, 10 | "keywords": [ 11 | "WebOfThings", 12 | "InternetOfThings", 13 | "WoT", 14 | "IoT", 15 | "types" 16 | ], 17 | "author": "W3C Web of Things Working Group", 18 | "license": "W3C-20150513", 19 | "bugs": { 20 | "url": "https://github.com/w3c/wot-scripting-api/issues" 21 | }, 22 | "homepage": "https://github.com/w3c/wot-scripting-api#readme", 23 | "scripts": { 24 | "build": "json2ts --unreachableDefinitions --input schema/td-json-schema-validation.json --output thing-description.d.ts" 25 | }, 26 | "devDependencies": { 27 | "json-schema-to-typescript": "^10.1.4" 28 | }, 29 | "main": "index.js" 30 | } 31 | -------------------------------------------------------------------------------- /typescript/thing-description/thing-description.d.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable */ 2 | /** 3 | * This file was automatically generated by json-schema-to-typescript. 4 | * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, 5 | * and run json-schema-to-typescript to regenerate this file. 6 | */ 7 | 8 | /** 9 | * This interface was referenced by `ThingDescription`'s JSON-Schema 10 | * via the `definition` "title". 11 | */ 12 | export type Title = string; 13 | /** 14 | * This interface was referenced by `ThingDescription`'s JSON-Schema 15 | * via the `definition` "type_declaration". 16 | */ 17 | export type TypeDeclaration = string | string[]; 18 | /** 19 | * This interface was referenced by `ThingDescription`'s JSON-Schema 20 | * via the `definition` "description". 21 | */ 22 | export type Description = string; 23 | /** 24 | * This interface was referenced by `ThingDescription`'s JSON-Schema 25 | * via the `definition` "form_element_property". 26 | */ 27 | export type FormElementProperty = FormElementBase; 28 | /** 29 | * This interface was referenced by `ThingDescription`'s JSON-Schema 30 | * via the `definition` "anyUri". 31 | */ 32 | export type AnyUri = string; 33 | /** 34 | * This interface was referenced by `ThingDescription`'s JSON-Schema 35 | * via the `definition` "subprotocol". 36 | */ 37 | export type Subprotocol = string; 38 | /** 39 | * This interface was referenced by `ThingDescription`'s JSON-Schema 40 | * via the `definition` "security". 41 | */ 42 | export type Security = [string, ...string[]] | string; 43 | /** 44 | * This interface was referenced by `ThingDescription`'s JSON-Schema 45 | * via the `definition` "scopes". 46 | */ 47 | export type Scopes = string[] | string; 48 | /** 49 | * This interface was referenced by `ThingDescription`'s JSON-Schema 50 | * via the `definition` "additionalResponsesDefinition". 51 | */ 52 | export type AdditionalResponsesDefinition = { 53 | contentType?: string; 54 | schema?: string; 55 | success?: boolean; 56 | [k: string]: unknown; 57 | }[]; 58 | /** 59 | * This interface was referenced by `ThingDescription`'s JSON-Schema 60 | * via the `definition` "dataSchema-type". 61 | */ 62 | export type DataSchemaType = "boolean" | "integer" | "number" | "string" | "object" | "array" | "null"; 63 | /** 64 | * This interface was referenced by `ThingDescription`'s JSON-Schema 65 | * via the `definition` "multipleOfDefinition". 66 | */ 67 | export type MultipleOfDefinition = number; 68 | /** 69 | * This interface was referenced by `ThingDescription`'s JSON-Schema 70 | * via the `definition` "form_element_action". 71 | */ 72 | export type FormElementAction = FormElementBase; 73 | /** 74 | * This interface was referenced by `ThingDescription`'s JSON-Schema 75 | * via the `definition` "form_element_event". 76 | */ 77 | export type FormElementEvent = FormElementBase; 78 | /** 79 | * This interface was referenced by `ThingDescription`'s JSON-Schema 80 | * via the `definition` "link_element". 81 | */ 82 | export type LinkElement = BaseLinkElement & { 83 | [k: string]: unknown; 84 | }; 85 | /** 86 | * This interface was referenced by `ThingDescription`'s JSON-Schema 87 | * via the `definition` "bcp47_string". 88 | */ 89 | export type Bcp47String = string; 90 | /** 91 | * This interface was referenced by `ThingDescription`'s JSON-Schema 92 | * via the `definition` "icon_link_element". 93 | */ 94 | export type IconLinkElement = BaseLinkElement & { 95 | rel: "icon"; 96 | sizes?: string; 97 | [k: string]: unknown; 98 | }; 99 | /** 100 | * This interface was referenced by `ThingDescription`'s JSON-Schema 101 | * via the `definition` "form_element_root". 102 | */ 103 | export type FormElementRoot = FormElementBase; 104 | /** 105 | * This interface was referenced by `ThingDescription`'s JSON-Schema 106 | * via the `definition` "securityScheme". 107 | */ 108 | export type SecurityScheme = 109 | | NoSecurityScheme 110 | | AutoSecurityScheme 111 | | ComboSecurityScheme 112 | | BasicSecurityScheme 113 | | DigestSecurityScheme 114 | | ApiKeySecurityScheme 115 | | BearerSecurityScheme 116 | | PskSecurityScheme 117 | | OAuth2SecurityScheme 118 | | AdditionalSecurityScheme; 119 | /** 120 | * This interface was referenced by `ThingDescription`'s JSON-Schema 121 | * via the `definition` "comboSecurityScheme". 122 | */ 123 | export type ComboSecurityScheme = 124 | | { 125 | "@type"?: TypeDeclaration; 126 | description?: Description; 127 | descriptions?: Descriptions; 128 | proxy?: AnyUri; 129 | scheme: "combo"; 130 | oneOf: [string, string, ...string[]]; 131 | [k: string]: unknown; 132 | } 133 | | { 134 | "@type"?: TypeDeclaration; 135 | description?: Description; 136 | descriptions?: Descriptions; 137 | proxy?: AnyUri; 138 | scheme: "combo"; 139 | allOf: [string, string, ...string[]]; 140 | [k: string]: unknown; 141 | }; 142 | /** 143 | * This interface was referenced by `ThingDescription`'s JSON-Schema 144 | * via the `definition` "thing-context". 145 | */ 146 | export type ThingContext = 147 | | [] 148 | | [ 149 | ThingContextTdUriV11, 150 | ...( 151 | | AnyUri 152 | | { 153 | [k: string]: string; 154 | } 155 | )[] 156 | ] 157 | | "https://www.w3.org/2022/wot/td/v1.1" 158 | | [ 159 | ThingContextTdUriV1, 160 | ThingContextTdUriV11, 161 | ...( 162 | | AnyUri 163 | | { 164 | [k: string]: string; 165 | } 166 | )[] 167 | ] 168 | | [ 169 | ThingContextTdUriV1, 170 | ...( 171 | | AnyUri 172 | | { 173 | [k: string]: string; 174 | } 175 | )[] 176 | ] 177 | | "https://www.w3.org/2019/wot/td/v1"; 178 | /** 179 | * This interface was referenced by `ThingDescription`'s JSON-Schema 180 | * via the `definition` "thing-context-td-uri-v1.1". 181 | */ 182 | export type ThingContextTdUriV11 = "https://www.w3.org/2022/wot/td/v1.1"; 183 | /** 184 | * This interface was referenced by `ThingDescription`'s JSON-Schema 185 | * via the `definition` "thing-context-td-uri-v1". 186 | */ 187 | export type ThingContextTdUriV1 = "https://www.w3.org/2019/wot/td/v1"; 188 | /** 189 | * This interface was referenced by `ThingDescription`'s JSON-Schema 190 | * via the `definition` "thing-context-td-uri-temp". 191 | */ 192 | export type ThingContextTdUriTemp = "http://www.w3.org/ns/td"; 193 | /** 194 | * This interface was referenced by `ThingDescription`'s JSON-Schema 195 | * via the `definition` "form". 196 | */ 197 | export type Form = FormElementProperty | FormElementAction | FormElementEvent | FormElementRoot; 198 | 199 | /** 200 | * JSON Schema for validating TD instances against the TD information model. TD instances can be with or without terms that have default values 201 | */ 202 | export interface ThingDescription { 203 | id?: string; 204 | title: Title; 205 | titles?: Titles; 206 | properties?: { 207 | [k: string]: PropertyElement; 208 | }; 209 | actions?: { 210 | [k: string]: ActionElement; 211 | }; 212 | events?: { 213 | [k: string]: EventElement; 214 | }; 215 | description?: Description; 216 | descriptions?: Descriptions; 217 | version?: { 218 | instance: string; 219 | [k: string]: unknown; 220 | }; 221 | links?: (LinkElement | IconLinkElement)[]; 222 | forms?: [FormElementRoot, ...FormElementRoot[]]; 223 | base?: AnyUri; 224 | securityDefinitions: { 225 | [k: string]: SecurityScheme; 226 | }; 227 | schemaDefinitions?: { 228 | [k: string]: DataSchema; 229 | }; 230 | support?: AnyUri; 231 | created?: string; 232 | modified?: string; 233 | profile?: AnyUri | [AnyUri, ...AnyUri[]]; 234 | security: string | [string, ...string[]]; 235 | uriVariables?: { 236 | [k: string]: DataSchema; 237 | }; 238 | "@type"?: TypeDeclaration; 239 | "@context": ThingContext; 240 | [k: string]: unknown; 241 | } 242 | /** 243 | * This interface was referenced by `ThingDescription`'s JSON-Schema 244 | * via the `definition` "titles". 245 | */ 246 | export interface Titles { 247 | [k: string]: string; 248 | } 249 | /** 250 | * This interface was referenced by `ThingDescription`'s JSON-Schema 251 | * via the `definition` "property_element". 252 | */ 253 | export interface PropertyElement { 254 | "@type"?: TypeDeclaration; 255 | description?: Description; 256 | descriptions?: Descriptions; 257 | title?: Title; 258 | titles?: Titles; 259 | forms: [FormElementProperty, ...FormElementProperty[]]; 260 | uriVariables?: { 261 | [k: string]: DataSchema; 262 | }; 263 | observable?: boolean; 264 | writeOnly?: boolean; 265 | readOnly?: boolean; 266 | oneOf?: DataSchema[]; 267 | unit?: string; 268 | enum?: [unknown, ...unknown[]]; 269 | format?: string; 270 | const?: unknown; 271 | default?: unknown; 272 | type?: DataSchemaType; 273 | items?: DataSchema | DataSchema[]; 274 | maxItems?: number; 275 | minItems?: number; 276 | minimum?: number; 277 | maximum?: number; 278 | exclusiveMinimum?: number; 279 | exclusiveMaximum?: number; 280 | minLength?: number; 281 | maxLength?: number; 282 | multipleOf?: MultipleOfDefinition; 283 | properties?: { 284 | [k: string]: DataSchema; 285 | }; 286 | required?: string[]; 287 | [k: string]: unknown; 288 | } 289 | /** 290 | * This interface was referenced by `ThingDescription`'s JSON-Schema 291 | * via the `definition` "descriptions". 292 | */ 293 | export interface Descriptions { 294 | [k: string]: string; 295 | } 296 | /** 297 | * This interface was referenced by `ThingDescription`'s JSON-Schema 298 | * via the `definition` "form_element_base". 299 | */ 300 | export interface FormElementBase { 301 | op?: string | string[]; 302 | href: AnyUri; 303 | contentType?: string; 304 | contentCoding?: string; 305 | subprotocol?: Subprotocol; 306 | security?: Security; 307 | scopes?: Scopes; 308 | response?: ExpectedResponse; 309 | additionalResponses?: AdditionalResponsesDefinition; 310 | [k: string]: unknown; 311 | } 312 | /** 313 | * This interface was referenced by `ThingDescription`'s JSON-Schema 314 | * via the `definition` "expectedResponse". 315 | */ 316 | export interface ExpectedResponse { 317 | contentType: string; 318 | [k: string]: unknown; 319 | } 320 | /** 321 | * This interface was referenced by `ThingDescription`'s JSON-Schema 322 | * via the `definition` "dataSchema". 323 | */ 324 | export interface DataSchema { 325 | "@type"?: TypeDeclaration; 326 | description?: Description; 327 | title?: Title; 328 | descriptions?: Descriptions; 329 | titles?: Titles; 330 | writeOnly?: boolean; 331 | readOnly?: boolean; 332 | oneOf?: DataSchema[]; 333 | unit?: string; 334 | enum?: [unknown, ...unknown[]]; 335 | format?: string; 336 | const?: unknown; 337 | default?: unknown; 338 | contentEncoding?: string; 339 | contentMediaType?: string; 340 | type?: DataSchemaType; 341 | items?: DataSchema | DataSchema[]; 342 | maxItems?: number; 343 | minItems?: number; 344 | minimum?: number; 345 | maximum?: number; 346 | exclusiveMinimum?: number; 347 | exclusiveMaximum?: number; 348 | minLength?: number; 349 | maxLength?: number; 350 | multipleOf?: MultipleOfDefinition; 351 | properties?: { 352 | [k: string]: DataSchema; 353 | }; 354 | required?: string[]; 355 | [k: string]: unknown; 356 | } 357 | /** 358 | * This interface was referenced by `ThingDescription`'s JSON-Schema 359 | * via the `definition` "action_element". 360 | */ 361 | export interface ActionElement { 362 | "@type"?: TypeDeclaration; 363 | description?: Description; 364 | descriptions?: Descriptions; 365 | title?: Title; 366 | titles?: Titles; 367 | forms: [FormElementAction, ...FormElementAction[]]; 368 | uriVariables?: { 369 | [k: string]: DataSchema; 370 | }; 371 | input?: DataSchema; 372 | output?: DataSchema; 373 | safe?: boolean; 374 | idempotent?: boolean; 375 | synchronous?: boolean; 376 | [k: string]: unknown; 377 | } 378 | /** 379 | * This interface was referenced by `ThingDescription`'s JSON-Schema 380 | * via the `definition` "event_element". 381 | */ 382 | export interface EventElement { 383 | "@type"?: TypeDeclaration; 384 | description?: Description; 385 | descriptions?: Descriptions; 386 | title?: Title; 387 | titles?: Titles; 388 | forms: [FormElementEvent, ...FormElementEvent[]]; 389 | uriVariables?: { 390 | [k: string]: DataSchema; 391 | }; 392 | subscription?: DataSchema; 393 | data?: DataSchema; 394 | dataResponse?: DataSchema; 395 | cancellation?: DataSchema; 396 | [k: string]: unknown; 397 | } 398 | /** 399 | * This interface was referenced by `ThingDescription`'s JSON-Schema 400 | * via the `definition` "base_link_element". 401 | */ 402 | export interface BaseLinkElement { 403 | href: AnyUri; 404 | type?: string; 405 | rel?: string; 406 | anchor?: AnyUri; 407 | hreflang?: Bcp47String | Bcp47String[]; 408 | [k: string]: unknown; 409 | } 410 | /** 411 | * This interface was referenced by `ThingDescription`'s JSON-Schema 412 | * via the `definition` "noSecurityScheme". 413 | */ 414 | export interface NoSecurityScheme { 415 | "@type"?: TypeDeclaration; 416 | description?: Description; 417 | descriptions?: Descriptions; 418 | proxy?: AnyUri; 419 | scheme: "nosec"; 420 | [k: string]: unknown; 421 | } 422 | /** 423 | * This interface was referenced by `ThingDescription`'s JSON-Schema 424 | * via the `definition` "autoSecurityScheme". 425 | */ 426 | export interface AutoSecurityScheme { 427 | "@type"?: TypeDeclaration; 428 | description?: Description; 429 | descriptions?: Descriptions; 430 | proxy?: AnyUri; 431 | scheme: "auto"; 432 | [k: string]: unknown; 433 | } 434 | /** 435 | * This interface was referenced by `ThingDescription`'s JSON-Schema 436 | * via the `definition` "basicSecurityScheme". 437 | */ 438 | export interface BasicSecurityScheme { 439 | "@type"?: TypeDeclaration; 440 | description?: Description; 441 | descriptions?: Descriptions; 442 | proxy?: AnyUri; 443 | scheme: "basic"; 444 | in?: "header" | "query" | "body" | "cookie" | "auto"; 445 | name?: string; 446 | [k: string]: unknown; 447 | } 448 | /** 449 | * This interface was referenced by `ThingDescription`'s JSON-Schema 450 | * via the `definition` "digestSecurityScheme". 451 | */ 452 | export interface DigestSecurityScheme { 453 | "@type"?: TypeDeclaration; 454 | description?: Description; 455 | descriptions?: Descriptions; 456 | proxy?: AnyUri; 457 | scheme: "digest"; 458 | qop?: "auth" | "auth-int"; 459 | in?: "header" | "query" | "body" | "cookie" | "auto"; 460 | name?: string; 461 | [k: string]: unknown; 462 | } 463 | /** 464 | * This interface was referenced by `ThingDescription`'s JSON-Schema 465 | * via the `definition` "apiKeySecurityScheme". 466 | */ 467 | export interface ApiKeySecurityScheme { 468 | "@type"?: TypeDeclaration; 469 | description?: Description; 470 | descriptions?: Descriptions; 471 | proxy?: AnyUri; 472 | scheme: "apikey"; 473 | in?: "header" | "query" | "body" | "cookie" | "uri" | "auto"; 474 | name?: string; 475 | [k: string]: unknown; 476 | } 477 | /** 478 | * This interface was referenced by `ThingDescription`'s JSON-Schema 479 | * via the `definition` "bearerSecurityScheme". 480 | */ 481 | export interface BearerSecurityScheme { 482 | "@type"?: TypeDeclaration; 483 | description?: Description; 484 | descriptions?: Descriptions; 485 | proxy?: AnyUri; 486 | scheme: "bearer"; 487 | authorization?: AnyUri; 488 | alg?: string; 489 | format?: string; 490 | in?: "header" | "query" | "body" | "cookie" | "auto"; 491 | name?: string; 492 | [k: string]: unknown; 493 | } 494 | /** 495 | * This interface was referenced by `ThingDescription`'s JSON-Schema 496 | * via the `definition` "pskSecurityScheme". 497 | */ 498 | export interface PskSecurityScheme { 499 | "@type"?: TypeDeclaration; 500 | description?: Description; 501 | descriptions?: Descriptions; 502 | proxy?: AnyUri; 503 | scheme: "psk"; 504 | identity?: string; 505 | [k: string]: unknown; 506 | } 507 | /** 508 | * This interface was referenced by `ThingDescription`'s JSON-Schema 509 | * via the `definition` "oAuth2SecurityScheme". 510 | */ 511 | export interface OAuth2SecurityScheme { 512 | "@type"?: TypeDeclaration; 513 | description?: Description; 514 | descriptions?: Descriptions; 515 | proxy?: AnyUri; 516 | scheme: "oauth2"; 517 | authorization?: AnyUri; 518 | token?: AnyUri; 519 | refresh?: AnyUri; 520 | scopes?: string[] | string; 521 | flow?: string | ("code" | "client"); 522 | [k: string]: unknown; 523 | } 524 | /** 525 | * Applies to additional SecuritySchemes not defined in the WoT TD specification. 526 | * 527 | * This interface was referenced by `ThingDescription`'s JSON-Schema 528 | * via the `definition` "additionalSecurityScheme". 529 | */ 530 | export interface AdditionalSecurityScheme { 531 | "@type"?: TypeDeclaration; 532 | description?: Description; 533 | descriptions?: Descriptions; 534 | proxy?: AnyUri; 535 | scheme: string; 536 | [k: string]: unknown; 537 | } 538 | -------------------------------------------------------------------------------- /typescript/thing-model/README.md: -------------------------------------------------------------------------------- 1 | # wot-thing-models-types 2 | 3 | A TypeScript definition file for the WoT Thing Model to be used by implementations such as [Eclipse Thingweb](https://projects.eclipse.org/projects/iot.thingweb). 4 | Thing Models are description components that can be combined/extended/imported to create a Thing Description. This package gives the ability to use concepts from the WoT Thing Models 5 | inside a servient runtime to build more modular WoT applications. More information about the WoT Thing Model can be found [here](https://w3c.github.io/wot-thing-description/#thing-model ). See other WoT TypeScript defintions files [here](https://github.com/w3c/wot-scripting-api/tree/main/typescript). 6 | 7 | ## Notes on usage 8 | 9 | These definitions are imported using npm. 10 | https://www.npmjs.com/package/wot-thing-model-types 11 | -------------------------------------------------------------------------------- /typescript/thing-model/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "wot-thing-model-types", 3 | "version": "1.1.0-12-March-2025", 4 | "description": "Official Typescript definition type for W3C Thing Model Description", 5 | "types": "thing-model.d.ts", 6 | "repository": { 7 | "type": "git", 8 | "url": "git+https://github.com/w3c/wot-scripting-api.git#main" 9 | }, 10 | "keywords": [ 11 | "WebOfThings", 12 | "InternetOfThings", 13 | "WoT", 14 | "IoT", 15 | "types" 16 | ], 17 | "author": "W3C Web of Things Working Group", 18 | "license": "W3C-20150513", 19 | "bugs": { 20 | "url": "https://github.com/w3c/wot-scripting-api/issues" 21 | }, 22 | "homepage": "https://github.com/w3c/wot-scripting-api#readme", 23 | "scripts": { 24 | "build": "json2ts --unreachableDefinitions --input schema/tm-json-schema-validation.json --output thing-model.d.ts" 25 | }, 26 | "devDependencies": { 27 | "json-schema-to-typescript": "^10.1.4" 28 | }, 29 | "main": "index.js" 30 | } 31 | -------------------------------------------------------------------------------- /typescript/thing-model/thing-model.d.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable */ 2 | /** 3 | * This file was automatically generated by json-schema-to-typescript. 4 | * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, 5 | * and run json-schema-to-typescript to regenerate this file. 6 | */ 7 | 8 | /** 9 | * This interface was referenced by `ThingModel`'s JSON-Schema 10 | * via the `definition` "title". 11 | */ 12 | export type Title = string; 13 | /** 14 | * This interface was referenced by `ThingModel`'s JSON-Schema 15 | * via the `definition` "type_declaration". 16 | */ 17 | export type TypeDeclaration = string | string[]; 18 | /** 19 | * This interface was referenced by `ThingModel`'s JSON-Schema 20 | * via the `definition` "description". 21 | */ 22 | export type Description = string; 23 | /** 24 | * This interface was referenced by `ThingModel`'s JSON-Schema 25 | * via the `definition` "form_element_property". 26 | */ 27 | export type FormElementProperty = FormElementBase; 28 | /** 29 | * This interface was referenced by `ThingModel`'s JSON-Schema 30 | * via the `definition` "anyUri". 31 | */ 32 | export type AnyUri = string; 33 | /** 34 | * This interface was referenced by `ThingModel`'s JSON-Schema 35 | * via the `definition` "subprotocol". 36 | */ 37 | export type Subprotocol = string; 38 | /** 39 | * This interface was referenced by `ThingModel`'s JSON-Schema 40 | * via the `definition` "security". 41 | */ 42 | export type Security = string[] | string; 43 | /** 44 | * This interface was referenced by `ThingModel`'s JSON-Schema 45 | * via the `definition` "scopes". 46 | */ 47 | export type Scopes = string[] | string; 48 | /** 49 | * This interface was referenced by `ThingModel`'s JSON-Schema 50 | * via the `definition` "additionalResponsesDefinition". 51 | */ 52 | export type AdditionalResponsesDefinition = { 53 | contentType?: string; 54 | schema?: string; 55 | success?: boolean; 56 | [k: string]: unknown; 57 | }[]; 58 | /** 59 | * This interface was referenced by `ThingModel`'s JSON-Schema 60 | * via the `definition` "placeholder-pattern". 61 | */ 62 | export type PlaceholderPattern = string; 63 | export type DataSchemaType = 64 | | ("boolean" | "integer" | "number" | "string" | "object" | "array" | "null") 65 | | PlaceholderPattern; 66 | export type DataSchemaType1 = string; 67 | /** 68 | * This interface was referenced by `ThingModel`'s JSON-Schema 69 | * via the `definition` "multipleOfDefinition". 70 | */ 71 | export type MultipleOfDefinition = number | PlaceholderPattern; 72 | /** 73 | * This interface was referenced by `ThingModel`'s JSON-Schema 74 | * via the `definition` "tm_ref". 75 | */ 76 | export type TmRef = string; 77 | /** 78 | * This interface was referenced by `ThingModel`'s JSON-Schema 79 | * via the `definition` "form_element_action". 80 | */ 81 | export type FormElementAction = FormElementBase; 82 | /** 83 | * This interface was referenced by `ThingModel`'s JSON-Schema 84 | * via the `definition` "form_element_event". 85 | */ 86 | export type FormElementEvent = FormElementBase; 87 | /** 88 | * This interface was referenced by `ThingModel`'s JSON-Schema 89 | * via the `definition` "link_element". 90 | */ 91 | export type LinkElement = BaseLinkElement & { 92 | [k: string]: unknown; 93 | }; 94 | /** 95 | * This interface was referenced by `ThingModel`'s JSON-Schema 96 | * via the `definition` "bcp47_string". 97 | */ 98 | export type Bcp47String = string; 99 | /** 100 | * This interface was referenced by `ThingModel`'s JSON-Schema 101 | * via the `definition` "icon_link_element". 102 | */ 103 | export type IconLinkElement = BaseLinkElement & { 104 | rel: "icon"; 105 | sizes?: string; 106 | [k: string]: unknown; 107 | }; 108 | /** 109 | * This interface was referenced by `ThingModel`'s JSON-Schema 110 | * via the `definition` "form_element_root". 111 | */ 112 | export type FormElementRoot = FormElementBase; 113 | /** 114 | * This interface was referenced by `ThingModel`'s JSON-Schema 115 | * via the `definition` "securityScheme". 116 | */ 117 | export type SecurityScheme = 118 | | NoSecurityScheme 119 | | AutoSecurityScheme 120 | | ComboSecurityScheme 121 | | BasicSecurityScheme 122 | | DigestSecurityScheme 123 | | ApiKeySecurityScheme 124 | | BearerSecurityScheme 125 | | PskSecurityScheme 126 | | OAuth2SecurityScheme 127 | | AdditionalSecurityScheme; 128 | /** 129 | * This interface was referenced by `ThingModel`'s JSON-Schema 130 | * via the `definition` "comboSecurityScheme". 131 | */ 132 | export type ComboSecurityScheme = 133 | | { 134 | "@type"?: TypeDeclaration; 135 | description?: Description; 136 | descriptions?: Descriptions; 137 | proxy?: AnyUri; 138 | scheme?: ("combo" | PlaceholderPattern) & string; 139 | oneOf?: [string, string, ...string[]]; 140 | "tm:ref"?: TmRef; 141 | [k: string]: unknown; 142 | } 143 | | { 144 | "@type"?: TypeDeclaration; 145 | description?: Description; 146 | descriptions?: Descriptions; 147 | proxy?: AnyUri; 148 | scheme?: ("combo" | PlaceholderPattern) & string; 149 | allOf?: [string, string, ...string[]]; 150 | "tm:ref"?: TmRef; 151 | [k: string]: unknown; 152 | }; 153 | /** 154 | * This interface was referenced by `ThingModel`'s JSON-Schema 155 | * via the `definition` "tm_type_declaration". 156 | */ 157 | export type TmTypeDeclaration = "tm:ThingModel" | string[]; 158 | /** 159 | * This interface was referenced by `ThingModel`'s JSON-Schema 160 | * via the `definition` "thing-context". 161 | */ 162 | export type ThingContext = 163 | | [] 164 | | [ 165 | ThingContextTdUriV11, 166 | ...( 167 | | AnyUri 168 | | { 169 | [k: string]: string; 170 | } 171 | )[] 172 | ] 173 | | "https://www.w3.org/2022/wot/td/v1.1" 174 | | [ 175 | ThingContextTdUriV1, 176 | ThingContextTdUriV11, 177 | ...( 178 | | AnyUri 179 | | { 180 | [k: string]: string; 181 | } 182 | )[] 183 | ] 184 | | [ 185 | ThingContextTdUriV1, 186 | ...( 187 | | AnyUri 188 | | { 189 | [k: string]: string; 190 | } 191 | )[] 192 | ] 193 | | "https://www.w3.org/2019/wot/td/v1"; 194 | /** 195 | * This interface was referenced by `ThingModel`'s JSON-Schema 196 | * via the `definition` "thing-context-td-uri-v1.1". 197 | */ 198 | export type ThingContextTdUriV11 = "https://www.w3.org/2022/wot/td/v1.1"; 199 | /** 200 | * This interface was referenced by `ThingModel`'s JSON-Schema 201 | * via the `definition` "thing-context-td-uri-v1". 202 | */ 203 | export type ThingContextTdUriV1 = "https://www.w3.org/2019/wot/td/v1"; 204 | /** 205 | * This interface was referenced by `ThingModel`'s JSON-Schema 206 | * via the `definition` "tm_optional". 207 | */ 208 | export type TmOptional = (string & { 209 | [k: string]: unknown; 210 | })[]; 211 | /** 212 | * This interface was referenced by `ThingModel`'s JSON-Schema 213 | * via the `definition` "thing-context-td-uri-temp". 214 | */ 215 | export type ThingContextTdUriTemp = "http://www.w3.org/ns/td"; 216 | /** 217 | * This interface was referenced by `ThingModel`'s JSON-Schema 218 | * via the `definition` "form". 219 | */ 220 | export type Form = FormElementProperty | FormElementAction | FormElementEvent | FormElementRoot; 221 | 222 | /** 223 | * JSON Schema for validating Thing Models. This is automatically generated from the WoT TD Schema. 224 | */ 225 | export interface ThingModel { 226 | id?: string; 227 | title?: Title; 228 | titles?: Titles; 229 | properties?: { 230 | [k: string]: PropertyElement; 231 | }; 232 | actions?: { 233 | [k: string]: ActionElement; 234 | }; 235 | events?: { 236 | [k: string]: EventElement; 237 | }; 238 | description?: Description; 239 | descriptions?: Descriptions; 240 | version?: 241 | | { 242 | model?: string; 243 | [k: string]: unknown; 244 | } 245 | | PlaceholderPattern; 246 | links?: (LinkElement | IconLinkElement)[]; 247 | forms?: [FormElementRoot, ...FormElementRoot[]]; 248 | base?: AnyUri; 249 | securityDefinitions?: { 250 | [k: string]: SecurityScheme; 251 | }; 252 | schemaDefinitions?: { 253 | [k: string]: DataSchema; 254 | }; 255 | support?: AnyUri; 256 | created?: string; 257 | modified?: string; 258 | profile?: AnyUri | [AnyUri, ...AnyUri[]]; 259 | security?: string | [string, ...string[]]; 260 | uriVariables?: { 261 | [k: string]: DataSchema; 262 | }; 263 | "@type": TmTypeDeclaration; 264 | "@context": ThingContext; 265 | "tm:optional"?: TmOptional; 266 | [k: string]: unknown; 267 | } 268 | /** 269 | * This interface was referenced by `ThingModel`'s JSON-Schema 270 | * via the `definition` "titles". 271 | */ 272 | export interface Titles { 273 | [k: string]: string; 274 | } 275 | /** 276 | * This interface was referenced by `ThingModel`'s JSON-Schema 277 | * via the `definition` "property_element". 278 | */ 279 | export interface PropertyElement { 280 | "@type"?: TypeDeclaration; 281 | description?: Description; 282 | descriptions?: Descriptions; 283 | title?: Title; 284 | titles?: Titles; 285 | forms?: [FormElementProperty, ...FormElementProperty[]]; 286 | uriVariables?: { 287 | [k: string]: DataSchema; 288 | }; 289 | observable?: boolean | PlaceholderPattern; 290 | writeOnly?: boolean | PlaceholderPattern; 291 | readOnly?: boolean | PlaceholderPattern; 292 | oneOf?: DataSchema[]; 293 | unit?: string; 294 | enum?: [unknown, ...unknown[]] | PlaceholderPattern; 295 | format?: string; 296 | const?: unknown; 297 | default?: unknown; 298 | type?: DataSchemaType & DataSchemaType1; 299 | items?: DataSchema | DataSchema[]; 300 | maxItems?: number | PlaceholderPattern; 301 | minItems?: number | PlaceholderPattern; 302 | minimum?: number | PlaceholderPattern; 303 | maximum?: number | PlaceholderPattern; 304 | exclusiveMinimum?: number; 305 | exclusiveMaximum?: number; 306 | minLength?: number | PlaceholderPattern; 307 | maxLength?: number | PlaceholderPattern; 308 | multipleOf?: MultipleOfDefinition; 309 | properties?: { 310 | [k: string]: DataSchema; 311 | }; 312 | required?: string[] | PlaceholderPattern; 313 | "tm:ref"?: TmRef; 314 | [k: string]: unknown; 315 | } 316 | /** 317 | * This interface was referenced by `ThingModel`'s JSON-Schema 318 | * via the `definition` "descriptions". 319 | */ 320 | export interface Descriptions { 321 | [k: string]: string; 322 | } 323 | /** 324 | * This interface was referenced by `ThingModel`'s JSON-Schema 325 | * via the `definition` "form_element_base". 326 | */ 327 | export interface FormElementBase { 328 | op?: string | string[]; 329 | href?: AnyUri; 330 | contentType?: string; 331 | contentCoding?: string; 332 | subprotocol?: Subprotocol; 333 | security?: Security; 334 | scopes?: Scopes; 335 | response?: ExpectedResponse; 336 | additionalResponses?: AdditionalResponsesDefinition; 337 | [k: string]: unknown; 338 | } 339 | /** 340 | * This interface was referenced by `ThingModel`'s JSON-Schema 341 | * via the `definition` "expectedResponse". 342 | */ 343 | export interface ExpectedResponse { 344 | contentType?: string; 345 | [k: string]: unknown; 346 | } 347 | /** 348 | * This interface was referenced by `ThingModel`'s JSON-Schema 349 | * via the `definition` "dataSchema". 350 | */ 351 | export interface DataSchema { 352 | "@type"?: TypeDeclaration; 353 | description?: Description; 354 | title?: Title; 355 | descriptions?: Descriptions; 356 | titles?: Titles; 357 | writeOnly?: boolean | PlaceholderPattern; 358 | readOnly?: boolean | PlaceholderPattern; 359 | oneOf?: DataSchema[]; 360 | unit?: string; 361 | enum?: [unknown, ...unknown[]] | PlaceholderPattern; 362 | format?: string; 363 | const?: unknown; 364 | default?: unknown; 365 | contentEncoding?: string; 366 | contentMediaType?: string; 367 | type?: DataSchemaType & DataSchemaType1; 368 | items?: DataSchema | DataSchema[]; 369 | maxItems?: number | PlaceholderPattern; 370 | minItems?: number | PlaceholderPattern; 371 | minimum?: number | PlaceholderPattern; 372 | maximum?: number | PlaceholderPattern; 373 | exclusiveMinimum?: number; 374 | exclusiveMaximum?: number; 375 | minLength?: number | PlaceholderPattern; 376 | maxLength?: number | PlaceholderPattern; 377 | multipleOf?: MultipleOfDefinition; 378 | properties?: { 379 | [k: string]: DataSchema; 380 | }; 381 | required?: string[] | PlaceholderPattern; 382 | "tm:ref"?: TmRef; 383 | [k: string]: unknown; 384 | } 385 | /** 386 | * This interface was referenced by `ThingModel`'s JSON-Schema 387 | * via the `definition` "action_element". 388 | */ 389 | export interface ActionElement { 390 | "@type"?: TypeDeclaration; 391 | description?: Description; 392 | descriptions?: Descriptions; 393 | title?: Title; 394 | titles?: Titles; 395 | forms?: [FormElementAction, ...FormElementAction[]]; 396 | uriVariables?: { 397 | [k: string]: DataSchema; 398 | }; 399 | input?: DataSchema; 400 | output?: DataSchema; 401 | safe?: boolean | PlaceholderPattern; 402 | idempotent?: boolean | PlaceholderPattern; 403 | synchronous?: boolean | PlaceholderPattern; 404 | "tm:ref"?: TmRef; 405 | [k: string]: unknown; 406 | } 407 | /** 408 | * This interface was referenced by `ThingModel`'s JSON-Schema 409 | * via the `definition` "event_element". 410 | */ 411 | export interface EventElement { 412 | "@type"?: TypeDeclaration; 413 | description?: Description; 414 | descriptions?: Descriptions; 415 | title?: Title; 416 | titles?: Titles; 417 | forms?: [FormElementEvent, ...FormElementEvent[]]; 418 | uriVariables?: { 419 | [k: string]: DataSchema; 420 | }; 421 | subscription?: DataSchema; 422 | data?: DataSchema; 423 | dataResponse?: DataSchema; 424 | cancellation?: DataSchema; 425 | "tm:ref"?: TmRef; 426 | [k: string]: unknown; 427 | } 428 | /** 429 | * This interface was referenced by `ThingModel`'s JSON-Schema 430 | * via the `definition` "base_link_element". 431 | */ 432 | export interface BaseLinkElement { 433 | href?: AnyUri; 434 | type?: string; 435 | rel?: string; 436 | anchor?: AnyUri; 437 | hreflang?: Bcp47String | Bcp47String[]; 438 | instanceName?: string; 439 | [k: string]: unknown; 440 | } 441 | /** 442 | * This interface was referenced by `ThingModel`'s JSON-Schema 443 | * via the `definition` "noSecurityScheme". 444 | */ 445 | export interface NoSecurityScheme { 446 | "@type"?: TypeDeclaration; 447 | description?: Description; 448 | descriptions?: Descriptions; 449 | proxy?: AnyUri; 450 | scheme?: ("nosec" | PlaceholderPattern) & string; 451 | "tm:ref"?: TmRef; 452 | [k: string]: unknown; 453 | } 454 | /** 455 | * This interface was referenced by `ThingModel`'s JSON-Schema 456 | * via the `definition` "autoSecurityScheme". 457 | */ 458 | export interface AutoSecurityScheme { 459 | "@type"?: TypeDeclaration; 460 | description?: Description; 461 | descriptions?: Descriptions; 462 | proxy?: AnyUri; 463 | scheme?: ("auto" | PlaceholderPattern) & string; 464 | [k: string]: unknown; 465 | } 466 | /** 467 | * This interface was referenced by `ThingModel`'s JSON-Schema 468 | * via the `definition` "basicSecurityScheme". 469 | */ 470 | export interface BasicSecurityScheme { 471 | "@type"?: TypeDeclaration; 472 | description?: Description; 473 | descriptions?: Descriptions; 474 | proxy?: AnyUri; 475 | scheme?: ("basic" | PlaceholderPattern) & string; 476 | in?: (("header" | "query" | "body" | "cookie" | "auto") | PlaceholderPattern) & string; 477 | name?: string; 478 | "tm:ref"?: TmRef; 479 | [k: string]: unknown; 480 | } 481 | /** 482 | * This interface was referenced by `ThingModel`'s JSON-Schema 483 | * via the `definition` "digestSecurityScheme". 484 | */ 485 | export interface DigestSecurityScheme { 486 | "@type"?: TypeDeclaration; 487 | description?: Description; 488 | descriptions?: Descriptions; 489 | proxy?: AnyUri; 490 | scheme?: ("digest" | PlaceholderPattern) & string; 491 | qop?: (("auth" | "auth-int") | PlaceholderPattern) & string; 492 | in?: (("header" | "query" | "body" | "cookie" | "auto") | PlaceholderPattern) & string; 493 | name?: string; 494 | "tm:ref"?: TmRef; 495 | [k: string]: unknown; 496 | } 497 | /** 498 | * This interface was referenced by `ThingModel`'s JSON-Schema 499 | * via the `definition` "apiKeySecurityScheme". 500 | */ 501 | export interface ApiKeySecurityScheme { 502 | "@type"?: TypeDeclaration; 503 | description?: Description; 504 | descriptions?: Descriptions; 505 | proxy?: AnyUri; 506 | scheme?: ("apikey" | PlaceholderPattern) & string; 507 | in?: (("header" | "query" | "body" | "cookie" | "uri" | "auto") | PlaceholderPattern) & string; 508 | name?: string; 509 | "tm:ref"?: TmRef; 510 | [k: string]: unknown; 511 | } 512 | /** 513 | * This interface was referenced by `ThingModel`'s JSON-Schema 514 | * via the `definition` "bearerSecurityScheme". 515 | */ 516 | export interface BearerSecurityScheme { 517 | "@type"?: TypeDeclaration; 518 | description?: Description; 519 | descriptions?: Descriptions; 520 | proxy?: AnyUri; 521 | scheme?: ("bearer" | PlaceholderPattern) & string; 522 | authorization?: AnyUri; 523 | alg?: string; 524 | format?: string; 525 | in?: (("header" | "query" | "body" | "cookie" | "auto") | PlaceholderPattern) & string; 526 | name?: string; 527 | "tm:ref"?: TmRef; 528 | [k: string]: unknown; 529 | } 530 | /** 531 | * This interface was referenced by `ThingModel`'s JSON-Schema 532 | * via the `definition` "pskSecurityScheme". 533 | */ 534 | export interface PskSecurityScheme { 535 | "@type"?: TypeDeclaration; 536 | description?: Description; 537 | descriptions?: Descriptions; 538 | proxy?: AnyUri; 539 | scheme?: ("psk" | PlaceholderPattern) & string; 540 | identity?: string; 541 | "tm:ref"?: TmRef; 542 | [k: string]: unknown; 543 | } 544 | /** 545 | * This interface was referenced by `ThingModel`'s JSON-Schema 546 | * via the `definition` "oAuth2SecurityScheme". 547 | */ 548 | export interface OAuth2SecurityScheme { 549 | "@type"?: TypeDeclaration; 550 | description?: Description; 551 | descriptions?: Descriptions; 552 | proxy?: AnyUri; 553 | scheme?: ("oauth2" | PlaceholderPattern) & string; 554 | authorization?: AnyUri; 555 | token?: AnyUri; 556 | refresh?: AnyUri; 557 | scopes?: string[] | string; 558 | flow?: string | ((("code" | "client") | PlaceholderPattern) & string); 559 | "tm:ref"?: TmRef; 560 | [k: string]: unknown; 561 | } 562 | /** 563 | * Applies to additional SecuritySchemes not defined in the WoT TD specification. 564 | * 565 | * This interface was referenced by `ThingModel`'s JSON-Schema 566 | * via the `definition` "additionalSecurityScheme". 567 | */ 568 | export interface AdditionalSecurityScheme { 569 | "@type"?: TypeDeclaration; 570 | description?: Description; 571 | descriptions?: Descriptions; 572 | proxy?: AnyUri; 573 | scheme?: string; 574 | [k: string]: unknown; 575 | } 576 | -------------------------------------------------------------------------------- /w3c.json: -------------------------------------------------------------------------------- 1 | { 2 | "group": [ 3 | "95969" 4 | ], 5 | "contacts": [ 6 | "ashimura" 7 | ], 8 | "shortName": "wot-scripting-api", 9 | "repo-type": "note" 10 | } 11 | --------------------------------------------------------------------------------