ory/keto

Ory Permission Language: support `;` in types

nidomiro opened this issue · 0 comments

Preflight checklist

Describe the bug

; are not allowed in type-definitions: expected identifier or '}', got ";"

using a , instead of ; works

Reproducing the bug

paste the following into Permission Rules at Ory Network:

import { Namespace, SubjectSet, Context } from '@ory/keto-namespace-types';

class User implements Namespace {
  related: {
    manager: User[];
  };
}

class Group implements Namespace {
  related: {
    members: (User | Group)[];
  };
}

class Folder implements Namespace {
  related: {
    parents: Folder[];
    viewers: SubjectSet<Group, 'members'>[];
  };

  permits = {
    view: (ctx: Context): boolean =>
      this.related.viewers.includes(ctx.subject) ||
      this.related.parents.traverse((p) => p.permits.view(ctx)),
  };
}

class File implements Namespace {
  related: {
    parents: Folder[];
    viewers: (User | SubjectSet<Group, 'members'>)[];
    owners: (User | SubjectSet<Group, 'members'>)[];
  };

  // Some comment
  permits = {
    view: (ctx: Context): boolean =>
      this.related.parents.traverse((p) => p.permits.view(ctx)) ||
      this.related.viewers.includes(ctx.subject) ||
      this.related.owners.includes(ctx.subject),

    edit: (ctx: Context) => this.related.owners.includes(ctx.subject),
  };
}

The ts-file is formatted with prettier (with single-quote option)

Relevant log output

expected identifier or '}', got ";"

Relevant configuration

No response

Version

Ory Network (15.11.2022)

On which operating system are you observing this issue?

Ory Network

In which environment are you deploying?

Ory Network

Additional Context

No response