Skip to content

feat: endpoints bdd#3276

Open
yenfryherrerafeliz wants to merge 7 commits intoaws:masterfrom
yenfryherrerafeliz:feat_endpoints_bdd
Open

feat: endpoints bdd#3276
yenfryherrerafeliz wants to merge 7 commits intoaws:masterfrom
yenfryherrerafeliz:feat_endpoints_bdd

Conversation

@yenfryherrerafeliz
Copy link
Copy Markdown
Contributor

Description of changes:

  • Add BDD-based endpoint resolution alongside the existing tree ruletset evaluator.
    • Introduce a Bdd package under EndpointV2 namespace containing utilities
      and components used for resolving an endpoint through BDDs.
    • Enhance the EndpointDefinitionProvider to resolve the endpoint rule definitions
      by giving preference to BDDs "endpoint-bdd-1.json" rules over tree based rules.
    • Enhance EndpointProviderV2 to support both, BDD endpoint resolver and Tree
      endpoint resolver by also giving preference to BDD resolution.
      How is this done:
      • The parameter $ruleset now supports instances of BddRuleset, besides of array to preserve existent
        behavior, and when an instance of BddReulset is present then a BDD evaluator is instantiated which
        later is used to resolve the endpoint.
      • Otherwise, if an array or a Ruleset is passed in then we resolve the endpoint
        with the tree based endpoint resolution, which is the current behavior.
    • Add a new method "getActiveParameters" in EndpointProviderV2 that is used by
      the EndpointV2Middleware to get the active parameters, which internally
      it just evaluates which rulset instance we should be getting the parameters from,
      either from $bddRuleset if not null or the tree ruleset $ruleset.
    • Enhance EndpointV2Middleware to consume the new getActiveParameters.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

- Add BDD-based endpoint resolution alongside the existing tree ruletset evaluator.
- Introduce a Bdd package under EndpointV2 namespace containing utilities
  and components used for resolving an endpoint through BDDs.
- Enhance the EndpointDefinitionProvider to resolve the endpoint rule definitions
  by giving preference to BDDs "endpoint-bdd-1.json" rules over tree based rules.
- Enhance EndpointProviderV2 to support both, BDD endpoint resolver and Tree
  endpoint resolver by also giving preference to BDD resolution.
  How is this done:
  - The parameter $ruleset now supports instances of BddRuleset, besides of array to preserve existent
    behavior, and when an instance of BddReulset is present then a BDD evaluator is instantiated which
    later is used to resolve the endpoint.
  - Otherwise, if an array or a Ruleset is passed in then we resolve the endpoint
    with the tree based endpoint resolution, which is the current behavior.
- Add a new method "getActiveParameters" in EndpointProviderV2 that is used by
  the EndpointV2Middleware to get the active parameters, which internally
  it just evaluates which rulset instance we should be getting the parameters from,
  either from $bddRuleset if not null or the tree ruleset $ruleset.
- Enhance EndpointV2Middleware to consume the new getActiveParameters.
@yenfryherrerafeliz yenfryherrerafeliz changed the title Feat endpoints bdd feat: endpoints bdd Apr 23, 2026
- Add support for templates with `_` and digits `0-9` so that isTemplate and
  resolveTemplateString works fine fine over templates with {Test_123}.
- Bdd evaluator coerced condition results with `(bool)`, which treats "" as false,
  while the tree evaluator only treats null or stric false as failure (per the rules-engine spec).
- Fix split to treat limit=0 as "unlimited" per the smithy standard library spec.
Copy link
Copy Markdown
Member

@stobrien89 stobrien89 left a comment

Choose a reason for hiding this comment

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

Looking good overall, just some comments on small stuff.

Comment thread src/EndpointV2/Bdd/BddResultResolver.php Outdated
Comment thread src/EndpointV2/EndpointProviderV2.php Outdated
Comment thread src/EndpointV2/Bdd/BddNodeDecoder.php
Comment thread src/EndpointV2/EndpointDefinitionProvider.php Outdated
Comment thread tests/EndpointV2/EndpointDefinitionProviderTest.php Outdated
Comment thread tests/EndpointV2/EndpointDefinitionProviderTest.php Outdated
Comment thread src/EndpointV2/Bdd/BddRuleset.php Outdated
Comment thread src/EndpointV2/EndpointProviderV2.php
- Remove unncessary check for nodesCount
- Remove unnecessary method `getEndpointDefinition` from EndpointDefinitionProvider
  since `getParsedRuleset` serves the same purpose.
- Remove extra semicolons.
- Remove unncessary tests.
- Enhanced test to make sure `endpoint-rule-set-1.json` is used when bdd file is not present.
-
- Add early string checks before regex in isTemplate() to avoid unnecessary pattern matching
- Replace call_user_func_array with direct switch statement in callFunction() for common functions
- Optimize parseArn() by using strncmp, removing intermediate variables, and simplifying empty checks
- Remove unnecessary whitespace in RulesetStandardLibrary

Co-authored-by: Michael Dowling
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