Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable local data during dev #99

Open
4 tasks
elliotBraem opened this issue May 16, 2024 · 1 comment
Open
4 tasks

Enable local data during dev #99

elliotBraem opened this issue May 16, 2024 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@elliotBraem
Copy link
Contributor

This used to be a feature of bos-workspace 0.0.1, but was only partially carried over from the refactor.

We're able to use local widgets, but what if I want to reference local data when I do bos-workspace dev?

For example, I have a Social.get(${config_account}/project/nested.projectId) in my code to reference the JSON I have stored at project/nested/projectId in my workspace?

The prior implementation of this can be found HERE, feel free to use it as a reference. In short, it loops through all the files in designated directories and builds a large data.json.

I think in the new implementation, we should do the same, but associate it with a configuration in the bos.config.json that designates which directories should be uploaded. For example:

bos.config.json

{
    "account": "sample.near",
    "data": { 
      "include": ["type", "thing", "project"]
    }
  }

Where the strings in "include" are references to the directory names in same level as the bos.config.json. An example of a repository that would use this feature is hyperfiles.

This data should be exposed through the dev server so it is used during RPC proxy, see in lib/server. It could use the same devJson, just save outside of "components".

Acceptance criteria

  • Local data can be referenced in workspace code
  • Throws error if an "included" directory does not exist
  • Should watch for changes in included directories
  • Test coverage
@elliotBraem elliotBraem added the enhancement New feature or request label May 16, 2024
@joshuanazareth97
Copy link
Collaborator

@elliotBraem I'll close this implementation within the next couple of days. Just laying out my plan here so you can correct me if needed:

  • I will extend the devJson object to have a field alongside components called data.
  • This will be an object with data populated from the folders provided in config.
  • It'll be nested based on folder structure, and we will parse txt and json files
  • Leaf nodes within the data object will represent files with the following shape: {<filename>: <stringified contents>}
  • Set up file watchers for each directory provided in the config, which will patch the devJson.data object with the updated data whenever a file changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: In Progress
Development

No branches or pull requests

2 participants