I feel I must be missing something obvious. I've got data in Azure CosmosDB that I want to query and process in a scheduled Workflow and put into Retool DB. I'm porting an existing CLI tool which has a CosmosClient class that encapsulates all the functionality required.
Some of the functionality in the class is also used for updating CosmosDB which I want to be able to call from an App that will query Retool DB.
Where can I put this common code so that it can be instantiated by either a Workflow or an App?
I appreciate the time you took for this but this doesn't address the issue. You are describing a simple use case of passing data between blocks. I'm asking about sharing complex code between Apps and Workflows.
From an architectural standpoint, it would likely make the most sense to instantiate CosmosClient in your app. This can be the source of truth and can be updated via queries to the Retool DB.
Then when you want to use data from that class in a workflow you can easily pass it out of the app to a workflow, and then from a workflow to an endpoint/Retool DB via a query in a workflow block.
This keeps the data moving in one 'downhill' direction, as it is more challenging to instantiate in a workflow and try to get that data out of a workflow into a Retool app.
For a very long time it was not possible to pass data into a Retool App from a Workflow, however, we now have the Response block, which will return some data as the response of the query called from an app to the workflow's endpoint (as @WidleStudioLLP pointed out).
For scheduling workflow events to use the CLI tool and then make updates to the Retool DB, this can all be done in a workflow and the app can query Retool DB. Just depends on what you need to do with the class in an app!