Rocket.Chat.Apps-engine icon indicating copy to clipboard operation
Rocket.Chat.Apps-engine copied to clipboard

Allow Apps to read their own files

Open cuonghuunguyen opened this issue 3 years ago • 7 comments

Apps may need to read their own files. It allows the apps to have more assets and abilities. Some possible use cases:

  • Storing text asset files
  • Storing image/video files
  • Storing template file (message template, response template)

cuonghuunguyen avatar Dec 01 '21 02:12 cuonghuunguyen

So, how would you propose packaging these files up and enabling Apps to access them? What sort of API are you thinking? If you can do pseudo code or even come up with an example, that would be great and helpful!

graywolf336 avatar Dec 01 '21 03:12 graywolf336

for the moment I am thinking of the AppStorageBridge. We already had the AppSourceStorage, we just need to expose the possibility to read the app's file via IRead accessor.

cuonghuunguyen avatar Dec 01 '21 07:12 cuonghuunguyen

Okay, so the compiler currently does not compile images except for the logo in the zip file. This was done intentionally since the Apps Engine does not currently support this feature.

How would you recommend the compiler (CLI and compiler) to know which images/assets to include? Do we add an assets property to the app.json file so the developer tells the compiler which folder to include?

graywolf336 avatar Dec 01 '21 13:12 graywolf336

Yes, assets prop is ideal. I have my own apps cli and it is using the same method to include assets

cuonghuunguyen avatar Dec 01 '21 14:12 cuonghuunguyen

Hint, mine uses assets as an array of glob strings

cuonghuunguyen avatar Dec 01 '21 14:12 cuonghuunguyen

Okay, so interesting enough there's already the concept of Assets in the Apps Engine...but I fail to see where Apps can access the assets declared.

Here's it in the app.json schema https://github.com/RocketChat/Rocket.Chat.Apps-engine/blob/b57424880a765db657b2130076289901806935f7/src/definition/app-schema.json#L69-L72

And here it is in the definition https://github.com/RocketChat/Rocket.Chat.Apps-engine/blob/b57424880a765db657b2130076289901806935f7/src/definition/assets/index.ts#L1-L4

From the commit messages, I am realizing that these are left over from the initial concept phase of the entire Apps system (https://github.com/RocketChat/Rocket.Chat.Apps-ts-definition/commits/master/src/assets). They were never actually implemented 😬

graywolf336 avatar Dec 01 '21 15:12 graywolf336

oh, cool. I've never seen it. So there's could be a chance to have it implemented

cuonghuunguyen avatar Dec 02 '21 02:12 cuonghuunguyen