# Class LayerDefinition

A Layer definition. Describes a layer and its permissions. To create a layer the corresponding layer definition must exist.

#### Hierarchy (View Summary)

- Permissions
  - LayerDefinition

##### Index

### Constructors

constructor

### Properties

id
mask
notFound

### Accessors

exists

### Methods

hasAll
hasAny
toJson
toString
copyToRef
fromJsonObject
join
toString

## Constructors

### constructor

- new LayerDefinition(id: string, ...permissions: Permission[]): LayerDefinition

  #### Parameters

  - id: string
  - ...permissions: Permission[]

  #### Returns LayerDefinition

  Overrides Permissions.constructor

## Properties

### `Readonly` id

id: string

### `Readonly` mask

mask: bigint = permissionMask.none

Permission bitmask. Since permissions are Uint64 bitmasks it must be represented as a bigint. Watch out for `number` type coercion if reading this property directly. While it is possible to use bitwise operations on the mask, to determine the permissions, it is better to use the provided methods such as hasAny and hasAll.

Inherited from Permissions.mask

### `Static` `Readonly` notFound

notFound: Readonly<LayerDefinition> = ...

Used to represent a layer definition that does not exist.

## Accessors

### exists

- get exists(): boolean

  `true` if the layer definition exists, `false` otherwise.

  #### Returns boolean

## Methods

### hasAll

- hasAll(...permissions: Permission[]): boolean

  Checks if mask has all of the specified permissions.

  #### Parameters

  - ...permissions: Permission[]

    Permissions to compare with mask.

  #### Returns boolean

  `true` if mask holds all of the specified permissions.

  Inherited from Permissions.hasAll

### hasAny

- hasAny(...permissions: Permission[]): boolean

  Checks if mask has any of the specified permissions.

  #### Parameters

  - ...permissions: Permission[]

    Permissions to compare with mask.

  #### Returns boolean

  `true` if mask holds any of the specified permissions.

  Inherited from Permissions.hasAny

### toJson

- toJson(): string

  Converts the Permission object to a JSON representation.

  #### Returns string

  The JSON representation of the Permission object.

  Inherited from Permissions.toJson

### toString

- toString(): string

  Converts to a human readable string.

  #### Returns string

  Human readable string.

  Inherited from Permissions.toString

### `Static` copyToRef

- copyToRef<T extends Pick<BimChangeBase, "permissions">>(
  permissions: Permission | Permissions | { json: string },
  dst: T,
  ): T

  Copies the permissions defined by `permissions` to the `dst`.permissions property.

  #### Type Parameters

  - T extends Pick<BimChangeBase, "permissions">

  #### Parameters

  - permissions: Permission | Permissions | { json: string }

    Permission to copy to `dst`.permissions property.

  - dst: T

    Change to use.

  #### Returns T

  Reference to `dst`.

  Inherited from Permissions.copyToRef

### `Static` fromJsonObject

- fromJsonObject(permission: string): Permissions

  Create a Permissions instance from a permission mask represented as a bigint string. This is how permissions are represented in JSON as it is not possible to send 64bit integers in JSON.

  #### Parameters

  - permission: string

    If a real bigint string then it is converted to a Permissions instance. If it is a `falsy` returns a Permissions instance without any permissions. If it is a `truthy` but not a bigint string then a exception is generated.

  #### Returns Permissions

  Permissions instance.

  Inherited from Permissions.fromJsonObject

### `Static` join

- join(...permissions: (Permission | Permission[])[]): bigint

  Join one or more permissions into a single numeric permission mask. Permissions are bitwise OR:ed together.

  #### Parameters

  - ...permissions: (Permission | Permission[])[]

    Permissions to join.

  #### Returns bigint

  Numeric permission mask. Can be compared directly with mask. Can also be used in constructor of Permissions.

  Inherited from Permissions.join

### `Static` toString

- toString(...permissions: Permission[]): string

  Converts a number of Permission instances into a human readable string.

  #### Parameters

  - ...permissions: Permission[]

    Permissions to convert.

  #### Returns string

  Human readable string.

  Inherited from Permissions.toString