<@U04UQ68083H> Should we be using <@ory/permission...
# ory-copilot
f
@chilly-king-10285 Should we be using @ory/permission-namespace-types or @ory/keto-namespace-types? Which npm package are they available in ?
c
A message from kapa.ai
Based on the knowledge sources provided, the correct import statement is
import { Namespace, Context } from "@ory/keto-namespace-types"
. This is used in the Ory Permission Language (OPL) to define namespaces and context for permissions. The OPL is a subset of TypeScript and is used to define permissions in Ory. However, the knowledge sources do not provide information on the specific npm package where
@ory/keto-namespace-types
is available. I recommend checking the official Ory documentation or the npm registry for more details. Here is an example of how
@ory/keto-namespace-types
is used in OPL:
Copy code
typescript import { Namespace, Context } from "@ory/keto-namespace-types"      class User implements Namespace {}      class Document implements Namespace {    // All relationships for a single document.    related: {    editors: User[]    viewers: User[]    }       // The permissions derived from the relationships and context.    permits = {    // A permission is a function that takes the context and returns a boolean. It can reference `this.related` and `this.permits`.    write: (ctx: Context): boolean => this.related.editors.includes(ctx.subject),    read: (ctx: Context): boolean => this.permits.write(ctx) || this.related.viewers.includes(ctx.subject),    }   }
Sources: - [Ory Permission Language](https://www.ory.sh/docs/keto#ory-permission-language) - [Namespaces in Ory](https://www.ory.sh/docs/keto/concepts/namespaces) - [Define permissions in the OPL](https://www.ory.sh/docs/keto/modeling/create-permission-model#define-permissions-in-the-opl)