Skip to content

Conversation

@kinyoklion
Copy link
Member

This PR implements the evaluation of rules/clauses, prerequisites, and fallthrough.

It includes tests for rules/clauses, but does not include prerequisite tests. I will add those once there is support for the prerequisite events.

@shortcut-integration
Copy link

This pull request has been linked to Shortcut Story #155754: Implement Remaining Evaluation.

@kinyoklion kinyoklion changed the base branch from rlamb/sc-154361/target-evaluation to rlamb/sc-155755/implement-reviver-replacer June 8, 2022 22:52
@kinyoklion kinyoklion marked this pull request as ready for review June 8, 2022 22:54
@kinyoklion kinyoklion requested a review from keelerm84 June 8, 2022 22:54
@kinyoklion kinyoklion requested review from aengelberg and yusinto June 8, 2022 22:54
attribute: 'key',
op: 'in',
values: [user.key],
attributeReference: new AttributeReference('key'),
Copy link
Contributor

Choose a reason for hiding this comment

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

Since attributeReference is an implementation detail of the preprocessing logic, might it be better to expose the function for doing preprocessing on a Clause so that test code like this could just set the regular properties and then call that? That way, the only code that needs to know about the extra attributeReference property is 1. the code that does the preprocessing and 2. the evaluation logic, not random test helpers like this.

return this.detail.reason.kind === Reasons.Off.kind;
}

static ForError(errorKind: ErrorKinds, message?: string): EvalResult {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it normal in TS for methods like this to have an initial capital?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is probably an older C# static method naming convention bleeding in. I've always liked it, but I am not sure if it would be common or uncommon in TS generally speaking. Looks like there isn't a linting rule one way or the other, which is unexpected for the very opinionated linter.

Copy link
Member Author

Choose a reason for hiding this comment

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

I can change them though, I have absolute indifference.

Copy link
Contributor

Choose a reason for hiding this comment

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

All methods in C# are supposed to have an initial capital, no? Isn't that just a basic difference in naming conventions between C# and JavaScript, rather than anything specifically about it being static?

Copy link
Member Author

Choose a reason for hiding this comment

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

C# C++

Regardless they are not capitalized any longer.

*
* @internal
*/
export default function matchClause(clause: Clause, context: Context): boolean {
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be best to give this a slightly more specific name (as we've done in some other SDKs) to indicate that it doesn't implement the segmentMatch operator. Then matchClause could be defined to include the "do segment stuff if it is segmentMatch" behavior - we will want that to be reusable, because both flag rule clauses and segment rule clauses can reference segments.

Copy link
Member Author

Choose a reason for hiding this comment

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

Renamed.

Base automatically changed from rlamb/sc-155755/implement-reviver-replacer to main July 5, 2022 17:33
import * as http from 'http';
import * as https from 'https';

// No types for the event source.
Copy link
Member Author

Choose a reason for hiding this comment

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

These were not ready yet.

@kinyoklion kinyoklion merged commit 147fa91 into main Jul 5, 2022
@kinyoklion kinyoklion deleted the rlamb/sc-155754/implement-rules branch July 5, 2022 18:18
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.

4 participants