-
-
Notifications
You must be signed in to change notification settings - Fork 262
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
Type Props for actions and tasks #1400
Comments
This is blocked by #1408 |
The path might involve building a pseudo-class in the ActionProcessor that extends the types of the Action, perhaps an "Intersection type" (more her: https://www.typescriptlang.org/docs/handbook/advanced-types.html) |
Is it acceptable to expect this.inputs = {
/* ... things here that I will think of and suggest soon ... */
} as const; Or does it have to work without (if |
I think |
Ping! @papb is there anything I can help with? I'm really excited for typed Action inputs! |
Pong! Sorry for the delay, I have been quite busy, but hopefully next week I will be able to help you. Sorry!! |
https://github.com/sindresorhus/type-fest/blob/master/source/entries.d.ts looks relevant to our interests! |
How do I declare a Action Template variable
Initializer middleware code contains data.actionTemplate.authenticate ie.
Thanks |
@krlicmuhamed in your case, you want to make a new class that extends import { Action } from "actionhero";
export abstract class AuthenticatedAction extends Action {
authenticate: boolean;
constructor() {
super();
this.middleware = ["authenticated-action"];
}
} And then use your new class rather than Action itself in your Actions: export default class Status extends AuthenticatedAction {
constructor() {
super();
this.name = "status";
this.description = "I will return some basic information about the API";
this.outputExample = {
id: "192.168.2.11",
actionheroVersion: "9.4.1",
uptime: 10469,
};
this.authenticate = true;
} We do this in Grouparoo: |
@evantahler hi, I tried this approach but I get
|
@krlicmuhamed Can you share example code to reproduce the error? |
Here you go https://github.com/krlicmuhamed/apiauth
|
Ah ha! Move that class out of the ‘actions’ folder. We look through that folder and try to load anything that extends Action... but that class isn’t a real action. Can you open a new issue about this please? |
I'll bet we can use
inputs
to learn the types ofparams
for actions and tasks, and that would really help the developer experience!Ideally:
The text was updated successfully, but these errors were encountered: