Skip to content
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

Improve multi-executors RuleTypes flow #26

Merged
merged 8 commits into from
Oct 25, 2017
Merged

Improve multi-executors RuleTypes flow #26

merged 8 commits into from
Oct 25, 2017

Conversation

rafaelverger
Copy link
Contributor

This changes makes "how to pause executors" as explicit as possible.

Copy link
Owner

@andersonba andersonba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a nice feature!
👏

} catch (e) {
let expectedError = false;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[minor] renames to expectedReply


export function PauseRuleTypeExecutors(name: string) {
this.key = 'pauseRuleTypeExecutors';
this.message = `Rule "${name}" should pause exection`;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo

src/types.ts Outdated

export interface RuleTypeExecutor {
validators?: RuleValidator[];
transform?: (value: any, rule?: Rule, bot?: YveBot) => Promise<any>;
Copy link
Owner

@andersonba andersonba Oct 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

create a type RuleTypeTransform

src/core/bot.ts Outdated
@@ -121,3 +126,7 @@ export class YveBot {
YveBot.prototype.types = new Types;
YveBot.prototype.actions = new Actions;
YveBot.prototype.validators = new Validators;


YveBot.Exceptions = Exceptions;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use exceptions to keep the pattern
YveBot.exceptions.RuleNotFound

src/core/bot.ts Outdated


YveBot.Exceptions = Exceptions;
YveBot.WaitForUserInputExecutor = WaitForUserInput;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

YveBot.executors = new Executors
to be accessed by YveBot.executors.WaitForUserInput

import * as utils from './utils';

const types = {

export const WaitForUserInput: RuleTypeExecutor = {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move it to ./executors

src/core/bot.ts Outdated
@@ -23,6 +25,9 @@ function sanitizeRule(rule: Rule): Rule {
}

export class YveBot {
static Exceptions: any;
Copy link
Owner

@andersonba andersonba Oct 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exceptions instead of any

src/core/bot.ts Outdated
@@ -23,6 +25,9 @@ function sanitizeRule(rule: Rule): Rule {
}

export class YveBot {
static Exceptions: any;
static WaitForUserInputExecutor: typeof WaitForUserInput;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try without typeof

this.bot.store.unset(`executors.${rule.name}.currentIdx`);
}

async executeRuleTypeExecutors(rule: Rule, lastAnswer: Answer | Answer[]): Promise<any> {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Promise<Answer | Answer[]> breaks?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no guarantee that return will be answer... the return will be whatever transform + validators returns

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@andersonba andersonba merged commit 0bdcdc0 into andersonba:master Oct 25, 2017
@rafaelverger rafaelverger deleted the nunes/improve_multistep_execution branch October 25, 2017 22:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants