Skip to content

Access

Defined in: src/core/Access.ts:25

Represents the inner Access class that helps build an access information to be granted or denied; and finally commits it to the underlying grants model. You can get a first instance of this class by calling AccessControl#grant() or AccessControl#deny() methods.

get denied(): boolean

Defined in: src/core/Access.ts:108

Specifies whether this access is initially denied.

boolean

role(value): Access

Defined in: src/core/Access.ts:121

A chainer method that sets the role(s) for this Access instance.

string | string[]

A single or array of roles.

Access

  • Self instance of Access.

resource(value): Access

Defined in: src/core/Access.ts:135

A chainer method that sets the resource for this Access instance.

string | string[]

Target resource for this Access instance.

Access

  • Self instance of Access.

attributes(value): Access

Defined in: src/core/Access.ts:147

Sets the array of allowed attributes for this Access instance.

string | string[]

Attributes to be set.

Access

  • Self instance of Access.

where(condition): Access

Defined in: src/core/Access.ts:166

Attaches a declarative condition to this grant — whether the grant applies at check time. Accepts the string-sugar form ('$.order.value > 100000') or canonical JSON ({ and|or|not } / [lhs, op, rhs]); it is compiled and validated when committed. Pairs with the attribute list (['*','!password']), which decides what fields return.

ConditionJSON

The condition (string sugar or canonical JSON).

Access

  • Self instance of Access.
ac.grant('manager')
.where('$.order.value > 100000')
.updateAny('order', ['*']);

during(expression): Access

Defined in: src/core/Access.ts:193

Attaches a temporal schedule to this grant: it applies only while the check instant — the reserved $.now (i.e. context.now, defaulting to the current time) — is covered by the given dtrexp expression. Shorthand for AND-ing ['$.now', 'during', expression] into this grant’s condition; composes with .where() regardless of call order. The timezone comes from the reserved context.tz (IANA name; defaults to the system zone). The expression is validated when the chain commits (on the action call): malformed or never-matching expressions throw.

Repeated calls AND together (all schedules must cover the instant); to express alternatives, use a union (|) inside a single expression.

string

A dtrexp date-time range / recurrence expression.

Access

  • Self instance of Access.
ac.grant('trader')
.where('$.order.value <= 100000')
.during('T0900:1800 E1:5') // Mon–Fri, 09:00–18:00
.updateAny('order', ['*']);

extend(roles): Access

Defined in: src/core/Access.ts:210

Sets the roles to be extended (inherited) for this Access instance.

string | string[]

A single or array of roles.

Access

  • Self instance of Access.
ac.grant('user').createAny('video')
.grant('admin').extend('user');
const permission = ac.can('admin').createAny('video');
console.log(permission.granted); // true

grant(roleOrInfo?): Access

Defined in: src/core/Access.ts:224

Shorthand to switch to a new Access instance with a different role within the method chain.

string | string[] | IAccessInfo

Either a single or an array of roles or an

Access

  • A new Access instance.
ac.grant('user').createOwn('video')
.grant('admin').updateAny('video');

deny(roleOrInfo?): Access

Defined in: src/core/Access.ts:237

Shorthand to switch to a new Access instance with a different (or same) role within the method chain.

string | string[] | IAccessInfo

Either a single or an array of roles or an

Access

  • A new Access instance.
ac.grant('admin').createAny('video')
.deny('user').deleteAny('video');

lock(): Access

Defined in: src/core/Access.ts:244

Chainable, convenience shortcut for AccessControl#lock().

Access


action(actionSpec, resource?, attributes?): Access

Defined in: src/core/Access.ts:263

Generic authoring entry for any action — CRUD or custom. The CRUD methods (createAny, updateOwn, …) are named sugar over this same commit path. actionSpec may carry possession via the :own/:any convention (omit ⇒ any).

string

Action name, optionally name:own/name:any.

string | string[]

Target resource(s).

string | string[]

Granted attributes (defaults per grant/deny).

Access

  • Self instance of Access.
ac.grant('editor').action('publish', 'article', ['*']); // publish:any
ac.grant('author').action('publish:own', 'article', ['*']); // ownership-gated

do(actionSpec, resource?, attributes?): Access

Defined in: src/core/Access.ts:277

The single sanctioned alias of Access#action — the one intentional exception to the v3 alias purge. Generic: CRUD and custom.

string

Action name, optionally name:own/name:any.

string | string[]

Target resource(s).

string | string[]

Granted attributes.

Access

  • Self instance of Access.

createOwn(resource?, attributes?): Access

Defined in: src/core/Access.ts:299

Sets the action to "create" and possession to "own" and commits the current access instance to the underlying grant model.

string | string[]

Defines the target resource this access is granted or denied for. This is only optional if the resource is previously defined. If not defined and omitted, this will throw.

string | string[]

Defines the resource attributes for which the access is granted or denied. Omitted, it defaults to ["*"]: every attribute, granted or denied. An explicit [] is kept: a grant of no attributes, or a deny of none.

Access

  • Self instance of Access so that you can chain and define another access instance to be committed.
  • If the access instance to be committed has any invalid data.

createAny(resource?, attributes?): Access

Defined in: src/core/Access.ts:321

Sets the action to "create" and possession to "any" and commits the current access instance to the underlying grant model.

string | string[]

Defines the target resource this access is granted or denied for. This is only optional if the resource is previously defined. If not defined and omitted, this will throw.

string | string[]

Defines the resource attributes for which the access is granted or denied. Omitted, it defaults to ["*"]: every attribute, granted or denied. An explicit [] is kept: a grant of no attributes, or a deny of none.

Access

  • Self instance of Access so that you can chain and define another access instance to be committed.
  • If the access instance to be committed has any invalid data.

readOwn(resource?, attributes?): Access

Defined in: src/core/Access.ts:350

Sets the action to "read" and possession to "own" and commits the current access instance to the underlying grant model.

string | string[]

Defines the target resource this access is granted or denied for. This is only optional if the resource is previously defined. If not defined and omitted, this will throw.

string | string[]

Defines the resource attributes for which the access is granted or denied. Omitted, it defaults to ["*"]: every attribute, granted or denied. An explicit [] is kept: a grant of no attributes, or a deny of none.

Access

  • Self instance of Access so that you can chain and define another access instance to be committed.
  • If the access instance to be committed has any invalid data.

readAny(resource?, attributes?): Access

Defined in: src/core/Access.ts:372

Sets the action to "read" and possession to "any" and commits the current access instance to the underlying grant model.

string | string[]

Defines the target resource this access is granted or denied for. This is only optional if the resource is previously defined. If not defined and omitted, this will throw.

string | string[]

Defines the resource attributes for which the access is granted or denied. Omitted, it defaults to ["*"]: every attribute, granted or denied. An explicit [] is kept: a grant of no attributes, or a deny of none.

Access

  • Self instance of Access so that you can chain and define another access instance to be committed.
  • If the access instance to be committed has any invalid data.

updateOwn(resource?, attributes?): Access

Defined in: src/core/Access.ts:401

Sets the action to "update" and possession to "own" and commits the current access instance to the underlying grant model.

string | string[]

Defines the target resource this access is granted or denied for. This is only optional if the resource is previously defined. If not defined and omitted, this will throw.

string | string[]

Defines the resource attributes for which the access is granted or denied. Omitted, it defaults to ["*"]: every attribute, granted or denied. An explicit [] is kept: a grant of no attributes, or a deny of none.

Access

  • Self instance of Access so that you can chain and define another access instance to be committed.
  • If the access instance to be committed has any invalid data.

updateAny(resource?, attributes?): Access

Defined in: src/core/Access.ts:423

Sets the action to "update" and possession to "any" and commits the current access instance to the underlying grant model.

string | string[]

Defines the target resource this access is granted or denied for. This is only optional if the resource is previously defined. If not defined and omitted, this will throw.

string | string[]

Defines the resource attributes for which the access is granted or denied. Omitted, it defaults to ["*"]: every attribute, granted or denied. An explicit [] is kept: a grant of no attributes, or a deny of none.

Access

  • Self instance of Access so that you can chain and define another access instance to be committed.
  • If the access instance to be committed has any invalid data.

deleteOwn(resource?, attributes?): Access

Defined in: src/core/Access.ts:452

Sets the action to "delete" and possession to "own" and commits the current access instance to the underlying grant model.

string | string[]

Defines the target resource this access is granted or denied for. This is only optional if the resource is previously defined. If not defined and omitted, this will throw.

string | string[]

Defines the resource attributes for which the access is granted or denied. Omitted, it defaults to ["*"]: every attribute, granted or denied. An explicit [] is kept: a grant of no attributes, or a deny of none.

Access

  • Self instance of Access so that you can chain and define another access instance to be committed.
  • If the access instance to be committed has any invalid data.

deleteAny(resource?, attributes?): Access

Defined in: src/core/Access.ts:474

Sets the action to "delete" and possession to "any" and commits the current access instance to the underlying grant model.

string | string[]

Defines the target resource this access is granted or denied for. This is only optional if the resource is previously defined. If not defined and omitted, this will throw.

string | string[]

Defines the resource attributes for which the access is granted or denied. Omitted, it defaults to ["*"]: every attribute, granted or denied. An explicit [] is kept: a grant of no attributes, or a deny of none.

Access

  • Self instance of Access so that you can chain and define another access instance to be committed.
  • If the access instance to be committed has any invalid data.