-
Notifications
You must be signed in to change notification settings - Fork 2
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
[WIP] [Actions] Initial Action helper functions design #328
Conversation
Coverage report can be checked at https://chili-dev.azureedge.net/sdk/coverage/328/coverage.html |
I'll continue reviewing, but two initial points:
For clarity, instead of a single To gauge which approach is more intuitive, I'll consult non-programmers on their preference:
My inclination is they'll prefer the latter. Additionally, I'm interested in their expectations from I'm also curious about their expectations from To clarify, it's not strictly an either-or decision between these methodologies. We could potentially offer both. However, I suggest introducing more direct helper functions and not assuming everyone will be comfortable with object property retrieval. I will update this PR with the results of my non-programmer friends. |
Results@Matthiee I got my results, and as predicted the non-programmers assumed I explained that it returns a variable object, but they only kind of understood. They preferred For So we could keep these functions, but I wouldn't go deeply on making functions that return objects. ArgumentsBecareful to name arguments to help users, and are consistent. A lot of functions have short names like this one:
It should be
Further HelpI strongly suggest we make sure to add helper functions that would cover the use cases clients would want, and review from their perspective. If you would like, I can make a PR to this branch of things I would add or change. |
Great feedback @seancrowe. I will discuss this with the team and change the design where needed. If you have time for a PR with additional changes that would be very helpful. |
@Matthiee, in your comment this is indicated with a ❌: But this is valid, no? There's just an easier way to do it now with the new helper function? |
@jeroencosyn correct, that is valid right now. The main concern here is that when you do The suggestion I provided here is that the helper functions would allow the variable object returned by the |
There has been internal discussions about adding a bit more type safety, mostly to avoid unwanted behaviors and runtime errors. If we go with adding type safety to Helper Functions, we need to remove Quick note on passing in Variable instead of a name as string. If we consider Variable like putting in a wrong variable name, which I think is the same risk of the same runtime error, then it would be acceptable to pass in the "I don't know" Variable. The counterargument is that when you pass in a string, it is clear to the use that the "variable" may not exist while passing in Variable makes it appear as it does exist and is right - meaning you may forget that type error could happen. The idea would to add a type safe barrier to getting and setting variables by requiring users to define the variable type via helper functions. Getting and setting a boolean variable type signature
of if we allow Variable
If the user passes in the name of a missing variable or the value of a variable that is not a boolean, they get a helpful error message. All these functions should behave similar. For setting text variables, we can be more excepting because one would expect a number passed in to be turned into a string of that number
or if we allow Variable
For list, we already have a number of functions defined for list variables. For images, that is a problem. Right now, image variables return a Proxy, where from my testing only get works and set does not work. I currently cannot give advice because I don't know how image variables are supposed to behave in actions and how they will work with media connectors. That needs to be defined. What about copyVariableValue? The function I think would have the same type signature, the only difference here is that it will error out if the variable types are not compatible. We should be explicit about this in the documentation. We could potentially change the naming to be more explicit about the behavior, but I don't have any good ideas: What about This is where all this work comes feels like it comes to a crash because changedVariable really is of type Variable. There is no way around that without separated triggers types. The good news is that I think most users will trigger a specific variable (or variables). If an end user is using a trigger on any variable, they should already be above the beginner level action user. The only thing you can do is add helper functions for type checking. Maybe add a helper `isVariableOfType(name:string|Variable, variableType:VariableType)
You instead go the route of adding a checking function for each variable type:
However, again I suspect |
…to feature/EDT-977-action-helper-functions-demo
Status updateChanges
Todo
|
@Matthiee what is the status of this PR? |
@pkgacek I'm currently making some final changes in the scope of EDT-1155 to the Action Types and Helper functions (should be done today). After that, it depends on whether #351 was already merged, as the helper file in this PR is in the wrong place. Some changes might need to be made to this file regarding WRS-1343. |
…to feature/EDT-977-action-helper-functions-demo
Closing this PR as work for Action Helper Functions will continue in #354 |
Action Helper Functions
An initial design. We are looking for general feedback on this.
See ActionHelpers.ts for all the functions.
Goal
Compared to using the more verbose
studio.*
-methods, have easy-to-use functions insideActions
JS.VariableValue
considerationsThere are plenty of use cases where the value of a variable will be used as an argument for the next method. To make this easier you'll notice that
VariableValue
was added as an argument to almost all setter methods. This makes designing actions easier.Entities with a name can be used as name argument
In order to avoid having to use
entity.name
everywhere, you'll noticeIHasName
was added to the argument list.byName
is an auto-complete action, that already contains the name.Related tickets