A user group data model.

Written by Hunter Perrin for SciActive.

Author

Hunter Perrin [email protected]

Copyright

SciActive Inc

See

http://nymph.io/

Hierarchy

Constructors

Properties

$allowlistData?: string[] = ...

If this is defined, then it lists the only properties that will be accepted from incoming JSON. Any other properties will be ignored.

If you use an allowlist, you don't need to use protectedData, since you can simply leave those entries out of allowlistData.

$allowlistTags?: string[] = []

If this is defined, then it lists the only tags that will be accepted from incoming JSON. Any other tags will be ignored.

$clientEnabledMethods: string[] = ...

The names of methods allowed to be called by the frontend with serverCall.

$data: GroupData

The data proxy object.

$dataHandler: Object

The data proxy handler.

$dataStore: GroupData

The actual data store.

$isASleepingReference: boolean

Whether this instance is a sleeping reference.

$nymph: Nymph

The instance of Nymph to use for queries.

$privateData: string[] = ...

Properties that will not be serialized into JSON with toJSON(). This can be considered a denylist, because these properties will not be set with incoming JSON.

Clients CAN still determine what is in these properties, unless they are also listed in searchRestrictedData.

$protectedData: string[]

Properties that can only be modified by server side code. They will still be visible on the frontend, unlike $privateData, but any changes to them that come from the frontend will be ignored.

In addition to what's listed here, all of the access control properties will be included when Tilmeld is being used. These are:

  • acUser
  • acGroup
  • acOther
  • acRead
  • acWrite
  • acFull
  • user
  • group

You should modify these through client enabled methods or the $save method instead, for safety.

$protectedTags: string[]

Tags that can only be added/removed by server side code. They will still be visible on the frontend, but any changes to them that come from the frontend will be ignored.

The actual sdata store.

$skipAcWhenSaving: boolean = false

This is explicitly used only during the registration proccess.

$sleepingReference: null | EntityReference

The reference to use to wake.

$tags: never[] = []
$wakePromise: null | Promise<Entity<GroupData>>

A promise that resolved when the entity's data is wake.

cdate: null | number

The creation date of the entity as a Unix timestamp in milliseconds.

guid: null | string

The entity's Globally Unique ID.

This is a 12 byte number represented as a lower case HEX string (24 characters).

mdate: null | number

The modified date of the entity as a Unix timestamp in milliseconds.

tags: string[]

Array of the entity's tags.

DEFAULT_ALLOWLIST_DATA: string[] = []
DEFAULT_PRIVATE_DATA: string[] = ...
ETYPE: string = 'tilmeld_group'

The instance of Tilmeld to use for queries.

class: string = 'Group'

The lookup name for this entity.

This is used for reference arrays (and sleeping references) and client requests.

clientEnabledStaticMethods: string[] = ...

The names of static methods allowed to be called by the frontend with serverCallStatic.

nymph: Nymph

The instance of Nymph to use for queries.

pubSubEnabled: boolean

Whether this entity should publish changes to PubSub servers.

restEnabled: boolean

Whether this entity should be accessible on the frontend through the REST server.

If this is false, any request from the client that attempts to use this entity will fail.

searchRestrictedData: string[] = ...

Properties that will not be searchable from the frontend. If the frontend includes any of these properties in any of their clauses, they will be filtered out before the search is executed.

Methods

  • Add one or more tags.

    Parameters

    • Rest ...tags: string[]

      List of tags.

    Returns void

  • Search the array for this object and return the corresponding index.

    If strict is false, is() is used to compare. If strict is true, equals() is used.

    Parameters

    • array: any[]

      The array to search.

    • Optional strict: boolean

      Whether to use stronger comparison.

    Returns number

    The index if the object is in the array, -1 if it isn't.

  • Check if this is a sleeping reference.

    Returns boolean

  • Check if this is a sleeping reference and throw an error if so.

    Returns void

  • Check that an email is unique.

    Returns Promise<{
        message: string;
        result: boolean;
    }>

    An object with a boolean 'result' entry and a 'message' entry.

  • Check that a groupname is valid.

    Returns Promise<{
        message: string;
        result: boolean;
    }>

    An object with a boolean 'result' entry and a 'message' entry.

  • Replace any referenced entities in the data with sleeping references.

    Calling this function ensures that the next time a referenced entity is accessed, it will be retrieved from the DB (unless it is in Nymph's cache).

    Returns void

  • Perform a more strict comparison of this object to another.

    Parameters

    • object: any

      The object to compare.

    Returns boolean

    True or false.

  • Returns null | (null | string)[]

  • Returns null | string

  • Returns null | (null | string)[]

  • Returns null | string

  • Returns null | (null | string)[]

  • Get the client enabled methods.

    Returns string[]

    The names of methods allowed to be called by the frontend with serverCall.

  • Used to retrieve the data object.

    This should only be used by Nymph to save the data into storage.

    Parameters

    • Optional includeSData: boolean

      Whether to include the serialized data as well.

    Returns any

    The entity's data object.

  • Get the number of parents the group has.

    If the group is a top level group, this will return 0. If it is a child of a top level group, this will return 1. If it is a grandchild of a top level group, this will return 2, and so on.

    Levels will max out at 1024 to avoid recursive loops.

    Returns Promise<number>

    The level of the group.

  • Used to retrieve the serialized data object.

    This should only be used by Nymph to save the data object into storage.

    This method is used by Nymph to avoid unserializing data that hasn't been requested yet.

    It should always be called after getData().

    Returns SerializedEntityData

    The entity's serialized data object.

  • Get the entity's tags.

    Using this instead of accessing the tags prop directly will wake sleeping references.

    Returns string[]

    The entity's tags.

  • Get an array of strings that must be unique across the current etype.

    When you try to save another entity with any of the same unique strings, Nymph will throw an error.

    The default implementation of this method returns an empty array, meaning there are no uniqueness constraints applied to its etype.

    Returns Promise<string[]>

    Resolves to an array of entity's unique constraint strings.

  • Gets an array of users in the group.

    Parameters

    • descendants: boolean = false

      Include users in all descendant groups too.

    • Optional limit: number

      The limit for the query.

    • Optional offset: number

      The offset for the query.

    Returns Promise<(User & UserData)[]>

    An array of users.

  • Get an object that holds the same data as the entity.

    This provides an object that can be validated.

    Returns any

    A pure object representation of the entity.

  • Check that the entity has all of the given tags.

    Parameters

    • Rest ...tags: string[]

      List of tags.

    Returns boolean

    True or false.

  • Check whether this object is in an array.

    If strict is false, is() is used to compare. If strict is true, equals() is used.

    Parameters

    • array: any[]

      The array to search.

    • Optional strict: boolean

      Whether to use stronger comparison.

    Returns boolean

    True if the object is in the array, false if it isn't.

  • Perform a less strict comparison of this object to another.

    Parameters

    • object: any

      The object to compare.

    Returns boolean

    True or false.

  • Accept JSON data from the client.

    This function uses the security protection lists:

    • $protectedTags
    • $protectedData
    • $allowlistTags
    • $allowlistData

    Parameters

    • input: EntityJson

      The input data. Please note, this will be modified (destroyed).

    • allowConflict: boolean = false

      Allow to accept data that is older than the current data.

    Returns void

  • Accept JSON patch from the client.

    This function uses the security protection lists:

    • $protectedTags
    • $protectedData
    • $allowlistTags
    • $allowlistData

    Parameters

    • patch: EntityPatch

      The patch data. Please note, this will be modified (destroyed).

    • allowConflict: boolean = false

      Allow to accept data that is older than the current data.

    Returns void

  • Refresh the object from storage. (Bypasses Nymph's cache.)

    If the object has been deleted from storage, the database cannot be reached, or a database error occurs, refresh() will return 0.

    Returns Promise<boolean | 0>

    False if the data has not been saved, 0 if it can't be refreshed, true on success.

  • Remove one or more tags.

    Parameters

    • Rest ...tags: string[]

      List of tags.

    Returns void

  • Return a Nymph Entity Reference for this entity.

    If the entity hasn't been saved yet (and has no GUID), it will be returned instead.

    Returns Group | EntityReference

    A Nymph Entity Reference array as an unsaved entity.

  • Update the data protection arrays for a user.

    Parameters

    • Optional givenUser: User & UserData

      User to update protection for. If undefined, will use the currently logged in user.

    Returns void

  • Set whether to use "skipAc" when accessing entity references.

    Parameters

    • skipAc: boolean

      True or false, whether to use it.

    Returns void

  • Alter the options for a query for this entity.

    Type Parameters

    Parameters

    • options: T

      The current options.

    Returns T

    The altered options.

  • Create or retrieve a new entity instance.

    Note that this will always return an entity, even if the GUID is not found.

    Type Parameters

    Parameters

    • this: (new () => E)
        • new (): E
        • Returns E

    • Optional guid: string

      An optional GUID to retrieve.

    Returns Promise<E & EntityDataType<E>>

  • Create a new sleeping reference instance.

    Sleeping references won't retrieve their data from the database until they are readied with $wake() or a parent's $wakeAll().

    Type Parameters

    Parameters

    • this: (new () => E)
        • new (): E
        • Returns E

    • reference: EntityReference

      The Nymph Entity Reference to use to wake.

    Returns E & EntityDataType<E>

    The new instance.

  • Get all the groups that can be assigned as primary groups.

    Parameters

    • Optional options: Options

      The options for an optional search query.

    • Optional selectors: Selector[]

      The selectors for an optional search query.

    Returns Promise<(Group & GroupData)[]>

    An array of the assignable primary groups.

  • Get all the groups that can be assigned as secondary groups.

    Parameters

    • Optional options: Options

      The options for an optional search query.

    • Optional selectors: Selector[]

      The selectors for an optional search query.

    Returns Promise<(Group & GroupData)[]>

    An array of the assignable secondary groups.

  • Get an array of strings that must be unique across the current etype.

    When you try to save another entity with any of the same unique strings, Nymph will throw an error.

    The default implementation of this static method instantiates the entity, assigns all of the given data, then calls $getUniques and returns its output. This can have a performance impact if a lot of extra processing happens during any of these steps. You can override this method to calculate the unique strings faster, but you must return the same strings that would be returned by $getUniques.

    Parameters

    • __namedParameters: {
          cdate?: number;
          data: EntityData;
          guid?: string;
          mdate?: number;
          sdata?: SerializedEntityData;
          tags: string[];
      }

    Returns Promise<string[]>

    Resolves to an array of entity's unique constraint strings.

Generated using TypeDoc