GithubHelp home page GithubHelp logo

Comments (4)

bendoerr avatar bendoerr commented on August 16, 2024

Agree, I just ran into this as well.

from keto.

PrimeDominus avatar PrimeDominus commented on August 16, 2024

Would be useful to have this fixed to make things much less confusing.

from keto.

davidspek avatar davidspek commented on August 16, 2024

That error looks correct to me. Shouldn’t the config be owners: (User | SubjectSet<Group, "members">)[] and then the relation can simply be this.related.owners_user.includes(ctx.subject).

Unless I’m misunderstanding something here (since the Group namespace is undefined and relevant here), when you traverse the parent you can use permissions or relations defined on the parent.

from keto.

cmmoran avatar cmmoran commented on August 16, 2024

What if made a slight change to the OPL definition to include type intersections? It may sound silly at first, but this isn't real typescript; not really real typescript anyway. Something like this:

class File implements Namespace {
  related: {
    owners: (User & Group)[];
  }

  permits = {
    view: (ctx: Context): boolean =>
      this.related.owners.traverse((p) =>
        p.equals(ctx.subject) ||
        p.permits.view(ctx)
      )
  }
}

That would solve the visual aspect of the OPL showing an error where one does not necessarily exist. In order to get this to work under-the-hood, the parser would need to support it. But even before that a decision would need to be made:

  • Can type intersections and unions exist for a particular relation?

I feel that, while it would work and the parser could be updated to support this, it would get complicated very quickly. Every mixed type union/intersection would need some fairly complicated typechecking logic to properly check that the type(s) fulfill their end of the contract. The other option is to disallow it. Part of me feels like that wouldn't be right either as it would mean the parser would have to track another state for each namespace relation and if the relation is a type union or type intersection, mark the relation accordingly. Non union/intersection relations wouldn't be affected.

If type unions and type intersections are made mutually exclusive, the parser typechecks would also need to change. Right now, under the union model, a typecheck ensures that the relation exists on all namespaces for a type union. This is necessary since we can look at the type union as if it were "implementations of an interface"; all members of the type union must uphold the "contract". This would change for type intersections because only one of the namespaces of the type intersection would need to uphold the contract in order for the check to be resolved.

If type unions and type intersections can exist on a single relation, the typechecks would still need to change but it would be more complicated because the how of the relation checks would depend on which namespaces are part of a type intersection and which namespaces are part of the type union for every relation.

This leads to another question:

  • What are the side-effects of introducing this?

from keto.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.