@nymphjs/tilmeld 1.0.0-beta.14 → 1.0.0-beta.140
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +668 -0
- package/README.md +21 -5
- package/dist/AbleObject.d.ts +20 -2
- package/dist/AbleObject.js +25 -13
- package/dist/AbleObject.js.map +1 -1
- package/dist/Group.d.ts +190 -27
- package/dist/Group.js +827 -440
- package/dist/Group.js.map +1 -1
- package/dist/Group.testArtifacts.d.ts +3 -0
- package/dist/Group.testArtifacts.js +120 -0
- package/dist/Group.testArtifacts.js.map +1 -0
- package/dist/Tilmeld.d.ts +275 -14
- package/dist/Tilmeld.js +789 -310
- package/dist/Tilmeld.js.map +1 -1
- package/dist/Tilmeld.types.d.ts +9 -9
- package/dist/Tilmeld.types.js +1 -2
- package/dist/User.d.ts +410 -41
- package/dist/User.js +2042 -1057
- package/dist/User.js.map +1 -1
- package/dist/User.testArtifacts.d.ts +3 -0
- package/dist/User.testArtifacts.js +175 -0
- package/dist/User.testArtifacts.js.map +1 -0
- package/dist/conf/defaults.d.ts +1 -1
- package/dist/conf/defaults.js +215 -141
- package/dist/conf/defaults.js.map +1 -1
- package/dist/conf/index.d.ts +361 -2
- package/dist/conf/index.js +2 -8
- package/dist/conf/index.js.map +1 -1
- package/dist/decorators/index.d.ts +2 -0
- package/dist/decorators/index.js +3 -0
- package/dist/decorators/index.js.map +1 -0
- package/dist/decorators/requireAbility.d.ts +10 -0
- package/dist/decorators/requireAbility.js +21 -0
- package/dist/decorators/requireAbility.js.map +1 -0
- package/dist/decorators/requireAuthentication.d.ts +8 -0
- package/dist/decorators/requireAuthentication.js +16 -0
- package/dist/decorators/requireAuthentication.js.map +1 -0
- package/dist/enforceTilmeld.d.ts +3 -0
- package/dist/enforceTilmeld.js +18 -0
- package/dist/enforceTilmeld.js.map +1 -0
- package/dist/errors/AccessControlError.d.ts +2 -1
- package/dist/errors/AccessControlError.js +3 -6
- package/dist/errors/AccessControlError.js.map +1 -1
- package/dist/errors/BadDataError.d.ts +2 -1
- package/dist/errors/BadDataError.js +3 -6
- package/dist/errors/BadDataError.js.map +1 -1
- package/dist/errors/BadEmailError.d.ts +2 -1
- package/dist/errors/BadEmailError.js +3 -6
- package/dist/errors/BadEmailError.js.map +1 -1
- package/dist/errors/BadUsernameError.d.ts +2 -1
- package/dist/errors/BadUsernameError.js +3 -6
- package/dist/errors/BadUsernameError.js.map +1 -1
- package/dist/errors/CouldNotChangeDefaultPrimaryGroupError.js +1 -5
- package/dist/errors/CouldNotChangeDefaultPrimaryGroupError.js.map +1 -1
- package/dist/errors/EmailChangeRateLimitExceededError.js +1 -5
- package/dist/errors/EmailChangeRateLimitExceededError.js.map +1 -1
- package/dist/errors/index.d.ts +6 -6
- package/dist/errors/index.js +6 -22
- package/dist/errors/index.js.map +1 -1
- package/dist/index.d.ts +10 -14
- package/dist/index.js +11 -35
- package/dist/index.js.map +1 -1
- package/dist/testArtifacts.d.ts +26 -0
- package/dist/testArtifacts.js +1346 -0
- package/dist/testArtifacts.js.map +1 -0
- package/dist/tilmeldJoiProps.d.ts +4 -5
- package/dist/tilmeldJoiProps.js +13 -18
- package/dist/tilmeldJoiProps.js.map +1 -1
- package/jest.config.js +31 -5
- package/package.json +49 -36
- package/src/AbleObject.ts +17 -11
- package/src/Group.testArtifacts.ts +159 -0
- package/src/Group.ts +712 -299
- package/src/Tilmeld.ts +666 -344
- package/src/Tilmeld.types.ts +9 -9
- package/src/User.testArtifacts.ts +226 -0
- package/src/User.ts +1984 -879
- package/src/conf/defaults.ts +205 -109
- package/src/conf/index.ts +381 -2
- package/src/decorators/index.ts +2 -0
- package/src/decorators/requireAbility.ts +26 -0
- package/src/decorators/requireAuthentication.ts +19 -0
- package/src/enforceTilmeld.ts +20 -0
- package/src/errors/AccessControlError.ts +4 -2
- package/src/errors/BadDataError.ts +4 -2
- package/src/errors/BadEmailError.ts +4 -2
- package/src/errors/BadUsernameError.ts +4 -2
- package/src/errors/index.ts +6 -6
- package/src/index.ts +11 -14
- package/src/testArtifacts.ts +2148 -0
- package/src/tilmeldJoiProps.ts +9 -24
- package/tsconfig.json +6 -3
- package/typedoc.json +4 -0
- package/dist/Group.test.d.ts +0 -1
- package/dist/Group.test.js +0 -48
- package/dist/Group.test.js.map +0 -1
- package/dist/User.test.d.ts +0 -1
- package/dist/User.test.js +0 -51
- package/dist/User.test.js.map +0 -1
- package/dist/conf/d.d.ts +0 -55
- package/dist/conf/d.js +0 -3
- package/dist/conf/d.js.map +0 -1
- package/src/Group.test.ts +0 -58
- package/src/User.test.ts +0 -61
- package/src/conf/d.ts +0 -303
package/README.md
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
# Tilmeld - User/Group System for Nymph
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Application Data and Access Framework for Node.js and the browser.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
https://nymph.io/
|
|
6
|
+
|
|
7
|
+
Tilmeld (the d is silent) is a user and group management, access control, and authentication system for Nymph. It allows creation and management of users and groups, including the ability to manage multiple domains. It provides strict access controls to protect entities from unauthorized access/modification. It allows for granting and revoking ad hoc abilities to users and groups, then checking for those abilities. It provides authentication services and features protection against XSRF attacks.
|
|
6
8
|
|
|
7
9
|
## Installation
|
|
8
10
|
|
|
@@ -38,7 +40,7 @@ const nymph = new Nymph(
|
|
|
38
40
|
new SQLite3Driver({
|
|
39
41
|
filename: ':memory:',
|
|
40
42
|
}),
|
|
41
|
-
tilmeld
|
|
43
|
+
tilmeld,
|
|
42
44
|
);
|
|
43
45
|
|
|
44
46
|
// These are the classes specific to this instance of Tilmeld.
|
|
@@ -47,11 +49,25 @@ const { User, Group } = tilmeld;
|
|
|
47
49
|
|
|
48
50
|
## Options
|
|
49
51
|
|
|
50
|
-
See the [config declaration file](src/conf/
|
|
52
|
+
See the [config declaration file](src/conf/index.ts).
|
|
53
|
+
|
|
54
|
+
## Abilities
|
|
55
|
+
|
|
56
|
+
There are a few abilities that Tilmeld uses internally:
|
|
57
|
+
|
|
58
|
+
- `system/admin` - A user with this ability has **all** abilities.
|
|
59
|
+
- `tilmeld/admin` - Allow the user to manage and edit other user's account and group information and grant/revoke abilities.
|
|
60
|
+
- `tilmeld/switch` - Allow the user to switch to other users (log in as them without their password).
|
|
61
|
+
- `tilmeld/domain/[domain]/admin` - Allow a user to create and edit users in a domain.
|
|
62
|
+
- `uid/get/[name]` - Allow the user to read the named UID.
|
|
63
|
+
- `uid/new/[name]` - Allow the user to read, create, and increment the named UID.
|
|
64
|
+
- `uid/set/[name]` - Allow the user to read, create, increment, set, and delete the named UID.
|
|
65
|
+
|
|
66
|
+
The admin and switch abilities cannot be inherited from groups.
|
|
51
67
|
|
|
52
68
|
# License
|
|
53
69
|
|
|
54
|
-
Copyright 2021 SciActive Inc
|
|
70
|
+
Copyright 2021-2026 SciActive Inc
|
|
55
71
|
|
|
56
72
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
57
73
|
you may not use this file except in compliance with the License.
|
package/dist/AbleObject.d.ts
CHANGED
|
@@ -1,7 +1,25 @@
|
|
|
1
1
|
import { Entity } from '@nymphjs/nymph';
|
|
2
|
-
export
|
|
2
|
+
export interface AbleObjectData {
|
|
3
3
|
abilities?: string[];
|
|
4
|
-
}
|
|
4
|
+
}
|
|
5
|
+
export interface AbleObject<T extends {}> extends AbleObjectData {
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* AbleObject abstract class.
|
|
9
|
+
*
|
|
10
|
+
* Used in entities which support abilities, such as users and groups.
|
|
11
|
+
*/
|
|
12
|
+
export declare abstract class AbleObject<T extends {}> extends Entity<T & AbleObjectData> {
|
|
13
|
+
/**
|
|
14
|
+
* Grant an ability.
|
|
15
|
+
*
|
|
16
|
+
* @param ability The ability.
|
|
17
|
+
*/
|
|
5
18
|
$grant(ability: string): void;
|
|
19
|
+
/**
|
|
20
|
+
* Revoke an ability.
|
|
21
|
+
*
|
|
22
|
+
* @param ability The ability.
|
|
23
|
+
*/
|
|
6
24
|
$revoke(ability: string): void;
|
|
7
25
|
}
|
package/dist/AbleObject.js
CHANGED
|
@@ -1,27 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { Entity } from '@nymphjs/nymph';
|
|
2
|
+
/**
|
|
3
|
+
* AbleObject abstract class.
|
|
4
|
+
*
|
|
5
|
+
* Used in entities which support abilities, such as users and groups.
|
|
6
|
+
*/
|
|
7
|
+
export class AbleObject extends Entity {
|
|
8
|
+
/**
|
|
9
|
+
* Grant an ability.
|
|
10
|
+
*
|
|
11
|
+
* @param ability The ability.
|
|
12
|
+
*/
|
|
5
13
|
$grant(ability) {
|
|
6
|
-
if (!Array.isArray(this
|
|
7
|
-
this
|
|
14
|
+
if (!Array.isArray(this.abilities)) {
|
|
15
|
+
this.abilities = [];
|
|
8
16
|
}
|
|
9
|
-
if (this
|
|
10
|
-
this
|
|
17
|
+
if (!this.abilities.includes(ability)) {
|
|
18
|
+
this.abilities.push(ability);
|
|
11
19
|
}
|
|
12
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Revoke an ability.
|
|
23
|
+
*
|
|
24
|
+
* @param ability The ability.
|
|
25
|
+
*/
|
|
13
26
|
$revoke(ability) {
|
|
14
|
-
if (!Array.isArray(this
|
|
15
|
-
this
|
|
27
|
+
if (!Array.isArray(this.abilities)) {
|
|
28
|
+
this.abilities = [];
|
|
16
29
|
}
|
|
17
30
|
let idx;
|
|
18
31
|
do {
|
|
19
|
-
idx = this
|
|
32
|
+
idx = this.abilities.indexOf(ability);
|
|
20
33
|
if (idx !== -1) {
|
|
21
|
-
this
|
|
34
|
+
this.abilities.splice(idx, 1);
|
|
22
35
|
}
|
|
23
36
|
} while (idx !== -1);
|
|
24
37
|
}
|
|
25
38
|
}
|
|
26
|
-
exports.default = AbleObject;
|
|
27
39
|
//# sourceMappingURL=AbleObject.js.map
|
package/dist/AbleObject.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbleObject.js","sourceRoot":"","sources":["../src/AbleObject.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AbleObject.js","sourceRoot":"","sources":["../src/AbleObject.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAQxC;;;;GAIG;AACH,MAAM,OAAgB,UAAyB,SAAQ,MAEtD;IACC;;;;OAIG;IACI,MAAM,CAAC,OAAe;QAC3B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;YACnC,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;QACtB,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;YACtC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;IAED;;;;OAIG;IACI,OAAO,CAAC,OAAe;QAC5B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;YACnC,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;QACtB,CAAC;QACD,IAAI,GAAW,CAAC;QAChB,GAAG,CAAC;YACF,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YACtC,IAAI,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC;gBACf,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;YAChC,CAAC;QACH,CAAC,QAAQ,GAAG,KAAK,CAAC,CAAC,EAAE;IACvB,CAAC;CACF"}
|
package/dist/Group.d.ts
CHANGED
|
@@ -1,25 +1,109 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { type EntityJson, type EntityPatch, type Options, type Selector, type SerializedEntityData } from '@nymphjs/nymph';
|
|
2
|
+
import { AbleObject } from './AbleObject.js';
|
|
3
|
+
import { User as UserClass } from './User.js';
|
|
4
|
+
export type GroupEventType = 'checkGroupname' | 'beforeSave' | 'afterSave' | 'beforeDelete' | 'afterDelete';
|
|
5
|
+
/**
|
|
6
|
+
* This is run when the user has entered an otherwise valid groupname into the
|
|
7
|
+
* signup form. It should return a result, which when false will stop the
|
|
8
|
+
* process and return the included message, disallowing the groupname.
|
|
9
|
+
*/
|
|
10
|
+
export type TilmeldCheckGroupnameCallback = (group: Group, data: {
|
|
11
|
+
groupname: string;
|
|
12
|
+
}) => Promise<{
|
|
13
|
+
result: boolean;
|
|
14
|
+
message?: string;
|
|
15
|
+
}>;
|
|
16
|
+
/**
|
|
17
|
+
* This is run just before the group is saved, so all checks have passed.
|
|
18
|
+
*
|
|
19
|
+
* The transaction is available in `group.$nymph`.
|
|
20
|
+
*/
|
|
21
|
+
export type TilmeldBeforeGroupSaveCallback = (group: Group) => Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* This is run before the transaction is committed, and you can perform
|
|
24
|
+
* additional functions on the transaction, which is available in
|
|
25
|
+
* `group.$nymph`.
|
|
26
|
+
*/
|
|
27
|
+
export type TilmeldAfterGroupSaveCallback = (group: Group) => Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* The transaction is available in `group.$nymph`.
|
|
30
|
+
*/
|
|
31
|
+
export type TilmeldBeforeGroupDeleteCallback = (group: Group) => Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* This is run before the transaction is committed, and you can perform
|
|
34
|
+
* additional functions on the transaction, which is available in
|
|
35
|
+
* `group.$nymph`.
|
|
36
|
+
*/
|
|
37
|
+
export type TilmeldAfterGroupDeleteCallback = (group: Group) => Promise<void>;
|
|
38
|
+
export interface GroupData {
|
|
39
|
+
/**
|
|
40
|
+
* The abilities granted to the group.
|
|
41
|
+
*/
|
|
6
42
|
abilities?: string[];
|
|
43
|
+
/**
|
|
44
|
+
* The group's groupname.
|
|
45
|
+
*/
|
|
7
46
|
groupname?: string;
|
|
47
|
+
/**
|
|
48
|
+
* The group's name.
|
|
49
|
+
*/
|
|
8
50
|
name?: string;
|
|
51
|
+
/**
|
|
52
|
+
* The group's email address.
|
|
53
|
+
*/
|
|
9
54
|
email?: string;
|
|
55
|
+
/**
|
|
56
|
+
* The group's avatar URL. (Use getAvatar() to support Gravatar.)
|
|
57
|
+
*/
|
|
10
58
|
avatar?: string;
|
|
59
|
+
/**
|
|
60
|
+
* The group's telephone number.
|
|
61
|
+
*/
|
|
11
62
|
phone?: string;
|
|
12
|
-
|
|
13
|
-
|
|
63
|
+
/**
|
|
64
|
+
* The group's parent.
|
|
65
|
+
*/
|
|
66
|
+
parent?: Group;
|
|
67
|
+
/**
|
|
68
|
+
* If generatePrimary is on, this will be the user who generated this group.
|
|
69
|
+
*/
|
|
70
|
+
user?: UserClass | null;
|
|
71
|
+
/**
|
|
72
|
+
* Whether the group can be used.
|
|
73
|
+
*/
|
|
14
74
|
enabled?: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Whether this group is the default primary group for new users.
|
|
77
|
+
*/
|
|
15
78
|
defaultPrimary?: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Whether this group is a default secondary group for new users.
|
|
81
|
+
*/
|
|
16
82
|
defaultSecondary?: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Whether this group is a default secondary group for unverified users.
|
|
85
|
+
*/
|
|
17
86
|
unverifiedSecondary?: boolean;
|
|
18
|
-
}
|
|
19
|
-
export
|
|
20
|
-
|
|
87
|
+
}
|
|
88
|
+
export interface Group extends GroupData {
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* A user group data model.
|
|
92
|
+
*
|
|
93
|
+
* Written by Hunter Perrin for SciActive.
|
|
94
|
+
*
|
|
95
|
+
* @author Hunter Perrin <hperrin@port87.com>
|
|
96
|
+
* @copyright SciActive Inc
|
|
97
|
+
* @see http://nymph.io/
|
|
98
|
+
*/
|
|
99
|
+
export declare class Group extends AbleObject<GroupData> {
|
|
21
100
|
static ETYPE: string;
|
|
22
101
|
static class: string;
|
|
102
|
+
private static checkGroupnameCallbacks;
|
|
103
|
+
private static beforeSaveCallbacks;
|
|
104
|
+
private static afterSaveCallbacks;
|
|
105
|
+
private static beforeDeleteCallbacks;
|
|
106
|
+
private static afterDeleteCallbacks;
|
|
23
107
|
private static DEFAULT_PRIVATE_DATA;
|
|
24
108
|
private static DEFAULT_ALLOWLIST_DATA;
|
|
25
109
|
protected $tags: never[];
|
|
@@ -29,35 +113,114 @@ export default class Group extends AbleObject<GroupData> {
|
|
|
29
113
|
static searchRestrictedData: string[];
|
|
30
114
|
protected $allowlistData?: string[] | undefined;
|
|
31
115
|
protected $allowlistTags?: string[];
|
|
116
|
+
/**
|
|
117
|
+
* This should only be used by the backend.
|
|
118
|
+
*/
|
|
32
119
|
private $skipAcWhenSaving;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
120
|
+
/**
|
|
121
|
+
* This should only be used by the backend.
|
|
122
|
+
*/
|
|
123
|
+
private $skipAcWhenDeleting;
|
|
124
|
+
/**
|
|
125
|
+
* Used to save the current groupname for domain admin permissions.
|
|
126
|
+
*/
|
|
127
|
+
$originalGroupname?: string;
|
|
128
|
+
static getFTSText(name: string, value: any): string | null;
|
|
129
|
+
static factoryGroupname(groupname?: string): Promise<Group>;
|
|
130
|
+
/**
|
|
131
|
+
* Get all the groups that can be assigned as primary groups.
|
|
132
|
+
*
|
|
133
|
+
* @param options The options for an optional search query.
|
|
134
|
+
* @param selectors The selectors for an optional search query.
|
|
135
|
+
* @returns An array of the assignable primary groups.
|
|
136
|
+
*/
|
|
137
|
+
static getPrimaryGroups(options?: Options, selectors?: Selector[]): Promise<Group[]>;
|
|
138
|
+
/**
|
|
139
|
+
* Get all the groups that can be assigned as secondary groups.
|
|
140
|
+
*
|
|
141
|
+
* @param options The options for an optional search query.
|
|
142
|
+
* @param selectors The selectors for an optional search query.
|
|
143
|
+
* @returns An array of the assignable secondary groups.
|
|
144
|
+
*/
|
|
145
|
+
static getSecondaryGroups(options?: Options, selectors?: Selector[]): Promise<Group[]>;
|
|
39
146
|
private static getAssignableGroups;
|
|
147
|
+
constructor();
|
|
148
|
+
$getUniques(): Promise<string[]>;
|
|
40
149
|
$getAvatar(): string;
|
|
41
150
|
$jsonAcceptData(input: EntityJson, allowConflict?: boolean): void;
|
|
42
151
|
$jsonAcceptPatch(patch: EntityPatch, allowConflict?: boolean): void;
|
|
43
|
-
$
|
|
44
|
-
$
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
$
|
|
49
|
-
|
|
50
|
-
|
|
152
|
+
private $checkIncomingAbilities;
|
|
153
|
+
$putData(data: GroupData, sdata?: SerializedEntityData, source?: 'server'): void;
|
|
154
|
+
/**
|
|
155
|
+
* Update the data protection arrays for the current user.
|
|
156
|
+
*/
|
|
157
|
+
$updateDataProtection(): void;
|
|
158
|
+
/**
|
|
159
|
+
* Check whether the group is a descendant of the given group.
|
|
160
|
+
*
|
|
161
|
+
* @param group The group, or the group's GUID.
|
|
162
|
+
* @returns True or false.
|
|
163
|
+
*/
|
|
164
|
+
$isDescendant(givenGroup: Group | string): Promise<boolean>;
|
|
165
|
+
/**
|
|
166
|
+
* Gets an array of the group's child groups.
|
|
167
|
+
*
|
|
168
|
+
* @returns An array of groups.
|
|
169
|
+
*/
|
|
170
|
+
$getChildren(): Promise<Group[]>;
|
|
171
|
+
/**
|
|
172
|
+
* Gets an array of the group's descendant groups.
|
|
173
|
+
*
|
|
174
|
+
* @param andSelf Include this group in the returned array.
|
|
175
|
+
* @param andDisabled Include disabled groups.
|
|
176
|
+
* @returns An array of groups.
|
|
177
|
+
*/
|
|
178
|
+
$getDescendants(andSelf?: boolean, andDisabled?: boolean): Promise<Group[]>;
|
|
179
|
+
/**
|
|
180
|
+
* Get the number of parents the group has.
|
|
181
|
+
*
|
|
182
|
+
* If the group is a top level group, this will return 0. If it is a child of
|
|
183
|
+
* a top level group, this will return 1. If it is a grandchild of a top level
|
|
184
|
+
* group, this will return 2, and so on.
|
|
185
|
+
*
|
|
186
|
+
* Levels will max out at 1024 to avoid recursive loops.
|
|
187
|
+
*
|
|
188
|
+
* @returns The level of the group.
|
|
189
|
+
*/
|
|
190
|
+
$getLevel(): Promise<number>;
|
|
191
|
+
/**
|
|
192
|
+
* Gets an array of enabled users in the group.
|
|
193
|
+
*
|
|
194
|
+
* @param descendants Include users in all descendant groups too.
|
|
195
|
+
* @param limit The limit for the query.
|
|
196
|
+
* @param offset The offset for the query.
|
|
197
|
+
* @returns An array of users.
|
|
198
|
+
*/
|
|
199
|
+
$getUsers(descendants?: boolean, limit?: number, offset?: number): Promise<UserClass[]>;
|
|
200
|
+
/**
|
|
201
|
+
* Check that a groupname is valid.
|
|
202
|
+
*
|
|
203
|
+
* @returns An object with a boolean 'result' entry and a 'message' entry.
|
|
204
|
+
*/
|
|
51
205
|
$checkGroupname(): Promise<{
|
|
52
206
|
result: boolean;
|
|
53
207
|
message: string;
|
|
54
208
|
}>;
|
|
209
|
+
/**
|
|
210
|
+
* Check that an email is unique.
|
|
211
|
+
*
|
|
212
|
+
* @returns An object with a boolean 'result' entry and a 'message' entry.
|
|
213
|
+
*/
|
|
55
214
|
$checkEmail(): Promise<{
|
|
56
215
|
result: boolean;
|
|
57
216
|
message: string;
|
|
58
217
|
}>;
|
|
59
|
-
$save(): Promise<
|
|
60
|
-
$saveSkipAC(): Promise<
|
|
218
|
+
$save(): Promise<void>;
|
|
219
|
+
$saveSkipAC(): Promise<void>;
|
|
61
220
|
$tilmeldSaveSkipAC(): boolean;
|
|
62
|
-
$delete(): Promise<
|
|
221
|
+
$delete(): Promise<void>;
|
|
222
|
+
$deleteSkipAC(): Promise<void>;
|
|
223
|
+
$tilmeldDeleteSkipAC(): boolean;
|
|
224
|
+
static on<T extends GroupEventType>(event: T, callback: T extends 'checkGroupname' ? TilmeldCheckGroupnameCallback : T extends 'beforeSave' ? TilmeldBeforeGroupSaveCallback : T extends 'afterSave' ? TilmeldAfterGroupSaveCallback : T extends 'beforeDelete' ? TilmeldBeforeGroupDeleteCallback : T extends 'afterDelete' ? TilmeldAfterGroupDeleteCallback : never): () => boolean;
|
|
225
|
+
static off<T extends GroupEventType>(event: T, callback: T extends 'checkGroupname' ? TilmeldCheckGroupnameCallback : T extends 'beforeSave' ? TilmeldBeforeGroupSaveCallback : T extends 'afterSave' ? TilmeldAfterGroupSaveCallback : T extends 'beforeDelete' ? TilmeldBeforeGroupDeleteCallback : T extends 'afterDelete' ? TilmeldAfterGroupDeleteCallback : never): boolean;
|
|
63
226
|
}
|