I am appreciating the conversation around this thread.
As we talk about an internal API that custom widgets can access, I agree especially with the concern about authentication. I donāt see any problem if a widget wants to make a call back to the API independently, but dealing with all the issues we discussed already - authentication and CORS being two - I think having an API object injected that uses the hosting web pageās credentials is still the right thing to do. That gets the widget out of having to store or even understand anything about authentication.
I have another suggestion as well. If weāre going to do this, the most important things a widget needs to be able to access are
- Any record placeholder belonging to the host step
- Tables
For table access, I had another thought. It would sure be nice to have some table related helper methods to be able to do things like refer to tables and columns using the column name in addition to by object ID. Maybe for columns itās less important because you can return that with the table query response metadata, but finding the right table by its name requires a piece of code I find myself replicating over and over.
I will say, though, the place to start isnāt tables, itās placeholders. An internal API might look like:
interface WidgetApi {
IQuery getQueryByName (name: str)
ITable getTableByName(name: str)
ITable getTableById(id: str)
/* ... more ... */
}
interface IQuery {
Field getField(name: str) /* get value of one field */
QueryRow[] getPlaceholder() /* get values of all fields */
bool setField(name: str, value: any) /* set one field's value */
bool setFields(newValue: QueryRow[]) /* set all fields in QueryRow */
}
interface QueryRow {
string getName()
string getId()
any getValue()
}
Excuse my typescript please
So the thought here is, when you create an IFrame, inject a reference to a WidgetApi into that iframe that the widget can just useā¦ for starters, to manipulate record placeholders, since I think that would be the most widely used, then from there, direct access to tables, then eventually machines and everything else.
In a way, I know that some of these APIs already exist. You can start a browser console and watch the āNetworkā tab and see how the step gets all its data. From what I have observed, though, I think containing that with a simpler facade would be wise.
Is this thread of conversation at all helpful?
āChris