Skip to content

feat: support nested userset rewrite operands in the DSL #16

Closed
@jon-whit

Description

@jon-whit

The DSL today does not support nested userset rewrite operands and/or compound expressions delineated by parenthetical expressions. The DSL language should be extended to support compound expressions with parenthetical expressions so that it supports the same expressiveness of the JSON support existing today.

Below are some examples of the unsupported functionality.

# sample1
type document
  relations
    define restricted as self
    define editor as self
    define viewer as editor or (self but not restricted)
# sample2
type document
  relations
    define restricted as self
    define parent as self
    define editor as self
    define (viewer but not restricted) or (editor and viewer from parent)

These same models are supported in the JSON structure today, for example:

# sample 1
{
  "type_definitions": [
    {
      "type": "document",
      "relations": {
        "restricted": { "this": {} },
        "editor": { "this": {} },
        "viewer": {
          "union": {
            "child": [
              { "computedUserset": { "object": "", "relation": "editor" } },
              {
                "union": {
                    "child": [
                        { "this": {} },
                        {
                            "difference": {
                                "base": {
                                    "this": {} 
                                },
                                "subtract": {
                                    "object": "",
                                    "relation": "restricted"
                                }
                            }
                        }
                    ]
                }
              }
            ]
          }
        }
      }
    }
  ]
}
# sample2
{
  "type_definitions": [
    {
      "type": "document",
      "relations": {
        "parent": { "this": {} },
        "restricted": { "this": {} },
        "editor": { "this": {} },
        "viewer": {
          "union": {
            "child": [
              {
                "difference": {
                    "base": {
                        "this": {} 
                    },
                    "subtract": {
                        "object": "",
                        "relation": "restricted"
                    }
                }
              },
              {
                "intersection": {
                    "child": [
                        {
                            "computedUserset": {
                                "object": "",
                                "relation": "editor"
                            }
                        },
                        {
                            "tupleToUserset": {
                                "tupleset": {
                                    "object": "",
                                    "relation": "parent"
                                },
                                "computedUserset": {
                                    "object": "",
                                    "relation": "viewer"
                                }
                            }
                        }
                    ]
                }
              }
            ]
          }
        }
      }
    }
  ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions