openhab / openhab-vscode

VS Code extension for openHAB configuration files
https://marketplace.visualstudio.com/items?itemName=openhab.openhab
Eclipse Public License 2.0
159 stars 47 forks source link

Experimental FileSystemProvider for API objects #257

Open ghys opened 3 years ago

ghys commented 3 years ago

This is a proof-of-concept of an implementation of #248 providing a file system able to abstract items and rules (only for now) in YAML files.

The items & things "files" can be opened from the Items Explorer resp. Things Explorer in a new "Open in YAML" context menu entry.

It also showcases how the YAML extension can be supplied schemas with this API: https://github.com/redhat-developer/vscode-yaml/wiki/Extension-API

The schema for the thing YAML is dynamic and queries the thing type API to retrieve the config parameter descriptions.

Only simple read operations for items & things have been implemented as a PoC but listing "directories", writing "files" (deserializing the YAML and updating objects with the REST API), and other operations like renaming (changing the UID) can also be envisioned.

This would make VS Code a good alternative code-based UI to edit objects in an instance (with additional comfort vs. the main UI for heavy editing, like tabs etc.) while retaining the benefits of the JSON DB.

Signed-off-by: Yannick Schaus github@schaus.net

ghys commented 3 years ago

Example: opening items & things from the explorer panes:

image

image

image

image

image

image

Example of generated schema from a thing type (incomplete):

image

Confectrician commented 3 years ago

Did you make a global npm update? Just wondering where the large package lock diff for the server package part is coming from. Seems you didn't touch anything there.

ghys commented 3 years ago

For the server-side JS, I believe my version of npm has transformed the server side package-lock.json from version 1 to version 2. However, I seem not to have added dependencies so it could easily be kept as is. For the client I added the yaml library as a dependency so there might be changes in the lock file, although they seem significant as well. But this PR is in the pre-alpha stage anyway so there's time to adjust.