openhab-vscode icon indicating copy to clipboard operation
openhab-vscode copied to clipboard

Experimental FileSystemProvider for API objects

Open ghys opened this issue 4 years ago • 3 comments

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 [email protected]

ghys avatar Apr 02 '21 18:04 ghys

Example: opening items & things from the explorer panes:

image

image

image

image

image

image

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

image

ghys avatar Apr 02 '21 18:04 ghys

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.

Confectrician avatar Apr 03 '21 06:04 Confectrician

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.

ghys avatar Apr 03 '21 09:04 ghys