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

feat(rules): Client side information consequence in rules #729

Open
VladislavFitz opened this issue Dec 15, 2020 · 0 comments
Open

feat(rules): Client side information consequence in rules #729

VladislavFitz opened this issue Dec 15, 2020 · 0 comments

Comments

@VladislavFitz
Copy link

Summary

With the release of the merchandising UI, the need to control UI aspects using the QR is growing and the rules API needs to expose fields to store information to perform specific client side tasks in a structured way.

The new consequence consequence.renderingContent contains a json object where each top level attribute is restricted to known use cases. The currently identified use cases are:

  • Redirect
  • Facet merchandising / ordering
  • User defined data

Each top level excepted the userData one have a schema which is enforced and strict and customers can add metadata using the userData object:

{
    "condition": {
        "anchoring": "is",
        "pattern": "samsung"
    },
    "consequence": {
        "renderingContent": {
            "redirect": {
                "url": "https://algolia.com/samsung"       // required by the API
            },
            "facetMerchandising": {
                "order": [ "brand", "price"]                       // required by the API
            },
            "userData": {
                "callback": "displayBrand(samsung)"     // optional field defined by user
            }
        }
    }
}

This information will be returned in a structured way in the path rules.consequence of the search response:

{
  "hits": [...],
  [...],
  "query": "samsung",
  "rules": {
    "consequence": {
      "renderingContent": [    // Array containing the content of matching rules
        {
          "facetMerchandising": {
            "order": [
              "brand",
              "price"
            ]
          },
          "redirect": {
            "url": "https://algolia.com/samsung"
          },
          "userData": {
            "callback": "displayBrand(samsung)"
          }
        }
      ]
    }
  },
  "userData": [  // Legacy userData
    {
      "myUserData": {}
    }
  ]
}

Internal specs issue: #152

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 a pull request may close this issue.

1 participant