@nymphjs/tilmeld 1.0.0-beta.6 → 1.0.0-beta.61

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.
Files changed (57) hide show
  1. package/CHANGELOG.md +284 -0
  2. package/README.md +14 -1
  3. package/dist/AbleObject.d.ts +15 -0
  4. package/dist/AbleObject.js +16 -1
  5. package/dist/AbleObject.js.map +1 -1
  6. package/dist/Group.d.ts +119 -8
  7. package/dist/Group.js +230 -97
  8. package/dist/Group.js.map +1 -1
  9. package/dist/Group.test.js +3 -2
  10. package/dist/Group.test.js.map +1 -1
  11. package/dist/Tilmeld.d.ts +237 -9
  12. package/dist/Tilmeld.js +559 -195
  13. package/dist/Tilmeld.js.map +1 -1
  14. package/dist/User.d.ts +333 -14
  15. package/dist/User.js +797 -204
  16. package/dist/User.js.map +1 -1
  17. package/dist/User.test.js +3 -2
  18. package/dist/User.test.js.map +1 -1
  19. package/dist/conf/d.d.ts +250 -3
  20. package/dist/conf/defaults.js +146 -98
  21. package/dist/conf/defaults.js.map +1 -1
  22. package/dist/enforceTilmeld.d.ts +3 -0
  23. package/dist/enforceTilmeld.js +22 -0
  24. package/dist/enforceTilmeld.js.map +1 -0
  25. package/dist/errors/AccessControlError.d.ts +2 -1
  26. package/dist/errors/AccessControlError.js +3 -2
  27. package/dist/errors/AccessControlError.js.map +1 -1
  28. package/dist/errors/BadDataError.d.ts +2 -1
  29. package/dist/errors/BadDataError.js +3 -2
  30. package/dist/errors/BadDataError.js.map +1 -1
  31. package/dist/errors/BadEmailError.d.ts +2 -1
  32. package/dist/errors/BadEmailError.js +3 -2
  33. package/dist/errors/BadEmailError.js.map +1 -1
  34. package/dist/errors/BadUsernameError.d.ts +2 -1
  35. package/dist/errors/BadUsernameError.js +3 -2
  36. package/dist/errors/BadUsernameError.js.map +1 -1
  37. package/dist/index.d.ts +1 -0
  38. package/dist/index.js +1 -0
  39. package/dist/index.js.map +1 -1
  40. package/package.json +30 -26
  41. package/src/AbleObject.ts +2 -2
  42. package/src/Group.test.ts +3 -3
  43. package/src/Group.ts +194 -143
  44. package/src/Tilmeld.ts +384 -249
  45. package/src/User.test.ts +3 -3
  46. package/src/User.ts +876 -266
  47. package/src/conf/d.ts +26 -13
  48. package/src/conf/defaults.ts +151 -104
  49. package/src/enforceTilmeld.ts +20 -0
  50. package/src/errors/AccessControlError.ts +4 -2
  51. package/src/errors/BadDataError.ts +4 -2
  52. package/src/errors/BadEmailError.ts +4 -2
  53. package/src/errors/BadUsernameError.ts +4 -2
  54. package/src/index.ts +2 -0
  55. package/src/tilmeldJoiProps.ts +9 -9
  56. package/tsconfig.json +1 -1
  57. package/typedoc.json +4 -0
package/CHANGELOG.md CHANGED
@@ -3,6 +3,290 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [1.0.0-beta.61](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.60...v1.0.0-beta.61) (2024-06-14)
7
+
8
+ **Note:** Version bump only for package @nymphjs/tilmeld
9
+
10
+ # [1.0.0-beta.60](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.59...v1.0.0-beta.60) (2024-06-14)
11
+
12
+ **Note:** Version bump only for package @nymphjs/tilmeld
13
+
14
+ # [1.0.0-beta.59](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.58...v1.0.0-beta.59) (2024-06-14)
15
+
16
+ ### Features
17
+
18
+ - add uniqueness constraint feature, refactor some types ([8133d32](https://github.com/sciactive/nymphjs/commit/8133d32b2c04907182dca2e9171b8217ed1b57e4))
19
+
20
+ # [1.0.0-beta.58](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.57...v1.0.0-beta.58) (2024-06-12)
21
+
22
+ **Note:** Version bump only for package @nymphjs/tilmeld
23
+
24
+ # [1.0.0-beta.57](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.56...v1.0.0-beta.57) (2024-06-12)
25
+
26
+ ### Features
27
+
28
+ - add debug logs to tilmeld ([52dfc26](https://github.com/sciactive/nymphjs/commit/52dfc26f41401b5fe17807158d79e8ccba3ed280))
29
+
30
+ # [1.0.0-beta.56](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.55...v1.0.0-beta.56) (2024-06-11)
31
+
32
+ ### Bug Fixes
33
+
34
+ - use HttpError in tilmeld ([13893d5](https://github.com/sciactive/nymphjs/commit/13893d5b27f8540c1ed6a8d75a39ce6e0c638b93))
35
+
36
+ ### Features
37
+
38
+ - allow connections where tokens are not renewed ([39071a5](https://github.com/sciactive/nymphjs/commit/39071a545644075190bd8213be25e0a0c46d2b5d))
39
+
40
+ # [1.0.0-beta.55](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.54...v1.0.0-beta.55) (2024-05-26)
41
+
42
+ **Note:** Version bump only for package @nymphjs/tilmeld
43
+
44
+ # [1.0.0-beta.54](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.53...v1.0.0-beta.54) (2024-05-26)
45
+
46
+ **Note:** Version bump only for package @nymphjs/tilmeld
47
+
48
+ # [1.0.0-beta.53](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.52...v1.0.0-beta.53) (2024-05-26)
49
+
50
+ **Note:** Version bump only for package @nymphjs/tilmeld
51
+
52
+ # [1.0.0-beta.52](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.51...v1.0.0-beta.52) (2024-05-25)
53
+
54
+ ### Bug Fixes
55
+
56
+ - support setup app and users and groups when userFields is limited ([20e25a2](https://github.com/sciactive/nymphjs/commit/20e25a2bcc35f96b3146fd9d973e34083a85f854))
57
+
58
+ # [1.0.0-beta.51](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.50...v1.0.0-beta.51) (2024-04-12)
59
+
60
+ **Note:** Version bump only for package @nymphjs/tilmeld
61
+
62
+ # [1.0.0-beta.50](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.49...v1.0.0-beta.50) (2024-04-08)
63
+
64
+ ### Bug Fixes
65
+
66
+ - run beforeRegister callbacks within the registration transaction ([0c50329](https://github.com/sciactive/nymphjs/commit/0c503299d8bee5bba323e23e34583b9b59823af5))
67
+
68
+ # [1.0.0-beta.49](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.48...v1.0.0-beta.49) (2024-03-04)
69
+
70
+ ### Bug Fixes
71
+
72
+ - change some jwt defaults and fix nbf date ([cff5f38](https://github.com/sciactive/nymphjs/commit/cff5f38da6c1624b3fc27655e3601f409f8b86c2))
73
+
74
+ # [1.0.0-beta.48](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.47...v1.0.0-beta.48) (2023-11-10)
75
+
76
+ ### Bug Fixes
77
+
78
+ - avoid trying to roll back a transaction twice ([e26ef31](https://github.com/sciactive/nymphjs/commit/e26ef312b617edcc715c81e7f92875dfaa7a904a))
79
+
80
+ # [1.0.0-beta.47](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.46...v1.0.0-beta.47) (2023-11-10)
81
+
82
+ **Note:** Version bump only for package @nymphjs/tilmeld
83
+
84
+ # [1.0.0-beta.46](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.45...v1.0.0-beta.46) (2023-08-29)
85
+
86
+ ### Bug Fixes
87
+
88
+ - secure cookies ([85d3ca4](https://github.com/sciactive/nymphjs/commit/85d3ca49f9ecdcdbaf68fee6639c3e77a4aeb109))
89
+
90
+ ### Features
91
+
92
+ - add minimum username length ([fcb317a](https://github.com/sciactive/nymphjs/commit/fcb317ad8f758a89b1b24f377b506e8a38f9ad41))
93
+ - enable tilmeld admins to remove totp secret from users ([18455b3](https://github.com/sciactive/nymphjs/commit/18455b3edbbfa1188f8cf317438bbfa028ba8f47))
94
+
95
+ # [1.0.0-beta.45](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.44...v1.0.0-beta.45) (2023-07-17)
96
+
97
+ **Note:** Version bump only for package @nymphjs/tilmeld
98
+
99
+ # [1.0.0-beta.44](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.43...v1.0.0-beta.44) (2023-07-13)
100
+
101
+ ### Bug Fixes
102
+
103
+ - wake before gatekeeper check ([1b7e985](https://github.com/sciactive/nymphjs/commit/1b7e985c41bd758c478503b9e51efcc2df5e6a91))
104
+
105
+ # [1.0.0-beta.43](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.42...v1.0.0-beta.43) (2023-07-12)
106
+
107
+ ### Bug Fixes
108
+
109
+ - update calls to gatekeeper to not use await ([ad36172](https://github.com/sciactive/nymphjs/commit/ad361725b67054aeb9e8e1c1a221c8e150a2c737))
110
+
111
+ # [1.0.0-beta.42](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.41...v1.0.0-beta.42) (2023-07-12)
112
+
113
+ ### Features
114
+
115
+ - make fillSession async so that gatekeeper can be sync ([fb6def4](https://github.com/sciactive/nymphjs/commit/fb6def45cd031516c9bcd3438f905e2ff881707b))
116
+
117
+ # [1.0.0-beta.41](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.40...v1.0.0-beta.41) (2023-07-12)
118
+
119
+ ### Features
120
+
121
+ - remove synchronous database queries ([b579fb2](https://github.com/sciactive/nymphjs/commit/b579fb2eacd96cdd1b386a62c5c00cdbb2438f6e))
122
+ - rewrite server side async api to match client side api ([9c537a8](https://github.com/sciactive/nymphjs/commit/9c537a8be49e9b989af0822a4c2236e8c2d20f87))
123
+
124
+ # [1.0.0-beta.40](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.39...v1.0.0-beta.40) (2023-07-10)
125
+
126
+ **Note:** Version bump only for package @nymphjs/tilmeld
127
+
128
+ # [1.0.0-beta.39](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.38...v1.0.0-beta.39) (2023-07-09)
129
+
130
+ **Note:** Version bump only for package @nymphjs/tilmeld
131
+
132
+ # [1.0.0-beta.38](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.37...v1.0.0-beta.38) (2023-07-09)
133
+
134
+ **Note:** Version bump only for package @nymphjs/tilmeld
135
+
136
+ # [1.0.0-beta.37](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.36...v1.0.0-beta.37) (2023-07-09)
137
+
138
+ **Note:** Version bump only for package @nymphjs/tilmeld
139
+
140
+ # [1.0.0-beta.36](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.35...v1.0.0-beta.36) (2023-07-09)
141
+
142
+ **Note:** Version bump only for package @nymphjs/tilmeld
143
+
144
+ # [1.0.0-beta.35](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.34...v1.0.0-beta.35) (2023-06-14)
145
+
146
+ **Note:** Version bump only for package @nymphjs/tilmeld
147
+
148
+ # [1.0.0-beta.34](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.33...v1.0.0-beta.34) (2023-05-13)
149
+
150
+ **Note:** Version bump only for package @nymphjs/tilmeld
151
+
152
+ # [1.0.0-beta.33](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.32...v1.0.0-beta.33) (2023-05-13)
153
+
154
+ **Note:** Version bump only for package @nymphjs/tilmeld
155
+
156
+ # [1.0.0-beta.32](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.31...v1.0.0-beta.32) (2023-05-13)
157
+
158
+ **Note:** Version bump only for package @nymphjs/tilmeld
159
+
160
+ # [1.0.0-beta.31](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.30...v1.0.0-beta.31) (2023-05-12)
161
+
162
+ **Note:** Version bump only for package @nymphjs/tilmeld
163
+
164
+ # [1.0.0-beta.30](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.29...v1.0.0-beta.30) (2023-05-12)
165
+
166
+ ### Features
167
+
168
+ - allow providing getEntityClass with a class instead of string ([ecd64c1](https://github.com/sciactive/nymphjs/commit/ecd64c1bf92e3657889613b76bcc46652f371ead))
169
+
170
+ # [1.0.0-beta.29](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.28...v1.0.0-beta.29) (2023-05-08)
171
+
172
+ **Note:** Version bump only for package @nymphjs/tilmeld
173
+
174
+ # [1.0.0-beta.28](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.27...v1.0.0-beta.28) (2023-05-05)
175
+
176
+ **Note:** Version bump only for package @nymphjs/tilmeld
177
+
178
+ # [1.0.0-beta.27](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.26...v1.0.0-beta.27) (2023-05-04)
179
+
180
+ **Note:** Version bump only for package @nymphjs/tilmeld
181
+
182
+ # [1.0.0-beta.26](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.25...v1.0.0-beta.26) (2023-05-04)
183
+
184
+ ### Features
185
+
186
+ - update packages and migrate to mysql2 ([72ad611](https://github.com/sciactive/nymphjs/commit/72ad611bd2bf7bf85c3ba8a3486503d9b50c49d6))
187
+
188
+ # [1.0.0-beta.25](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.24...v1.0.0-beta.25) (2023-05-04)
189
+
190
+ ### Bug Fixes
191
+
192
+ - tilmeld uses wrong class when cloned with user ([059c2ce](https://github.com/sciactive/nymphjs/commit/059c2cedf1b07b9681e87c240eb36723a4581918))
193
+
194
+ # [1.0.0-beta.24](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.23...v1.0.0-beta.24) (2023-05-02)
195
+
196
+ ### Bug Fixes
197
+
198
+ - fill session after setting current user clone ([7bae7cf](https://github.com/sciactive/nymphjs/commit/7bae7cf1bf236b8efc00cb7b5ed53cd21f1370c7))
199
+
200
+ # [1.0.0-beta.23](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.22...v1.0.0-beta.23) (2023-05-02)
201
+
202
+ ### Bug Fixes
203
+
204
+ - rare case where currentUser isn't corrent ([97f233a](https://github.com/sciactive/nymphjs/commit/97f233a5fcfd4b97dd282562b0c99097ac3ef41d))
205
+
206
+ # [1.0.0-beta.22](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.21...v1.0.0-beta.22) (2023-05-01)
207
+
208
+ **Note:** Version bump only for package @nymphjs/tilmeld
209
+
210
+ # [1.0.0-beta.21](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.20...v1.0.0-beta.21) (2023-05-01)
211
+
212
+ ### Features
213
+
214
+ - add totp two factor authentication ([cc9f8ed](https://github.com/sciactive/nymphjs/commit/cc9f8edb183271fa7f51e4b182b876efb8fa0f8d))
215
+
216
+ # [1.0.0-beta.20](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.19...v1.0.0-beta.20) (2023-04-30)
217
+
218
+ ### Features
219
+
220
+ - let the user revoke all current auth tokens ([63af3b9](https://github.com/sciactive/nymphjs/commit/63af3b9a31c6c221ab40c2c8a69231675f4634a2))
221
+
222
+ # [1.0.0-beta.19](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.18...v1.0.0-beta.19) (2023-04-29)
223
+
224
+ ### Bug Fixes
225
+
226
+ - some type issues ([ee69d5d](https://github.com/sciactive/nymphjs/commit/ee69d5d73361dacda5745d697df18fafd47810bc))
227
+
228
+ # [1.0.0-beta.18](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.17...v1.0.0-beta.18) (2023-04-27)
229
+
230
+ ### Bug Fixes
231
+
232
+ - small type issues ([b91579c](https://github.com/sciactive/nymphjs/commit/b91579c9c1e96500d903332648f5a93c9a7e7d9b))
233
+
234
+ ### Features
235
+
236
+ - add enforceTilmeld function ([130faf1](https://github.com/sciactive/nymphjs/commit/130faf151dcdfbfacd6814833868907dca037d24))
237
+ - add the ability to switch to a user without their password ([ca4466a](https://github.com/sciactive/nymphjs/commit/ca4466af1704d68905ac087350a8cf151c1072d9))
238
+ - forbid modifying ac props from client ([f9e896f](https://github.com/sciactive/nymphjs/commit/f9e896f6c57b08ae100bc50d33a0234b6a431333))
239
+ - remove access control bypass for sysadmins and ownerless entities, no longer needed ([345bbf4](https://github.com/sciactive/nymphjs/commit/345bbf4fd78a8f9d6d01fd0be8337854a1277ce6))
240
+
241
+ # [1.0.0-beta.17](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.16...v1.0.0-beta.17) (2023-04-24)
242
+
243
+ **Note:** Version bump only for package @nymphjs/tilmeld
244
+
245
+ # [1.0.0-beta.16](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.15...v1.0.0-beta.16) (2023-03-31)
246
+
247
+ ### Features
248
+
249
+ - add ability to tell tilmeld to log in a specific user during authentication ([922e145](https://github.com/sciactive/nymphjs/commit/922e1452adae44bed2aa9655be16e19796acb39b))
250
+ - username check callback ([372e95c](https://github.com/sciactive/nymphjs/commit/372e95c39664c0d718e497ec1b09426e7cfa8862))
251
+
252
+ # [1.0.0-beta.15](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.14...v1.0.0-beta.15) (2023-03-23)
253
+
254
+ **Note:** Version bump only for package @nymphjs/tilmeld
255
+
256
+ # [1.0.0-beta.14](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.13...v1.0.0-beta.14) (2023-03-17)
257
+
258
+ **Note:** Version bump only for package @nymphjs/tilmeld
259
+
260
+ # [1.0.0-beta.13](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.12...v1.0.0-beta.13) (2023-03-16)
261
+
262
+ **Note:** Version bump only for package @nymphjs/tilmeld
263
+
264
+ # [1.0.0-beta.12](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.11...v1.0.0-beta.12) (2023-03-04)
265
+
266
+ **Note:** Version bump only for package @nymphjs/tilmeld
267
+
268
+ # [1.0.0-beta.11](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.10...v1.0.0-beta.11) (2023-02-27)
269
+
270
+ **Note:** Version bump only for package @nymphjs/tilmeld
271
+
272
+ # [1.0.0-beta.10](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.9...v1.0.0-beta.10) (2023-01-19)
273
+
274
+ **Note:** Version bump only for package @nymphjs/tilmeld
275
+
276
+ # [1.0.0-beta.9](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.8...v1.0.0-beta.9) (2023-01-09)
277
+
278
+ **Note:** Version bump only for package @nymphjs/tilmeld
279
+
280
+ # [1.0.0-beta.8](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.7...v1.0.0-beta.8) (2023-01-09)
281
+
282
+ **Note:** Version bump only for package @nymphjs/tilmeld
283
+
284
+ # [1.0.0-beta.7](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.6...v1.0.0-beta.7) (2023-01-05)
285
+
286
+ ### Bug Fixes
287
+
288
+ - sqlite transaction returns wrong instance of nymph if it has been cloned ([b278c76](https://github.com/sciactive/nymphjs/commit/b278c7633722cb1cca7a941187ae2f1ff8ebdc7b))
289
+
6
290
  # [1.0.0-beta.6](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.5...v1.0.0-beta.6) (2023-01-05)
7
291
 
8
292
  ### Bug Fixes
package/README.md CHANGED
@@ -38,7 +38,7 @@ const nymph = new Nymph(
38
38
  new SQLite3Driver({
39
39
  filename: ':memory:',
40
40
  }),
41
- tilmeld
41
+ tilmeld,
42
42
  );
43
43
 
44
44
  // These are the classes specific to this instance of Tilmeld.
@@ -49,6 +49,19 @@ const { User, Group } = tilmeld;
49
49
 
50
50
  See the [config declaration file](src/conf/d.ts).
51
51
 
52
+ ## Abilities
53
+
54
+ There are a few abilities that Tilmeld uses internally:
55
+
56
+ - `system/admin` - A user with this ability has **all** abilities.
57
+ - `tilmeld/admin` - Allow the user to manage and edit other user's account and group information and grant/revoke abilities.
58
+ - `tilmeld/switch` - Allow the user to switch to other users (log in as them without their password).
59
+ - `uid/get/[name]` - Allow the user to read the named UID.
60
+ - `uid/new/[name]` - Allow the user to read, create, and increment the named UID.
61
+ - `uid/set/[name]` - Allow the user to read, create, increment, set, and delete the named UID.
62
+
63
+ The admin and switch abilities cannot be inherited from groups.
64
+
52
65
  # License
53
66
 
54
67
  Copyright 2021 SciActive Inc
@@ -1,7 +1,22 @@
1
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
+ */
2
7
  export default abstract class AbleObject<T extends {
3
8
  abilities?: string[];
4
9
  }> extends Entity<T> {
10
+ /**
11
+ * Grant an ability.
12
+ *
13
+ * @param ability The ability.
14
+ */
5
15
  $grant(ability: string): void;
16
+ /**
17
+ * Revoke an ability.
18
+ *
19
+ * @param ability The ability.
20
+ */
6
21
  $revoke(ability: string): void;
7
22
  }
@@ -1,15 +1,30 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const nymph_1 = require("@nymphjs/nymph");
4
+ /**
5
+ * AbleObject abstract class.
6
+ *
7
+ * Used in entities which support abilities, such as users and groups.
8
+ */
4
9
  class AbleObject extends nymph_1.Entity {
10
+ /**
11
+ * Grant an ability.
12
+ *
13
+ * @param ability The ability.
14
+ */
5
15
  $grant(ability) {
6
16
  if (!Array.isArray(this.$data.abilities)) {
7
17
  this.$data.abilities = [];
8
18
  }
9
- if (this.$data.abilities.indexOf(ability) === -1) {
19
+ if (!this.$data.abilities.includes(ability)) {
10
20
  this.$data.abilities.push(ability);
11
21
  }
12
22
  }
23
+ /**
24
+ * Revoke an ability.
25
+ *
26
+ * @param ability The ability.
27
+ */
13
28
  $revoke(ability) {
14
29
  if (!Array.isArray(this.$data.abilities)) {
15
30
  this.$data.abilities = [];
@@ -1 +1 @@
1
- {"version":3,"file":"AbleObject.js","sourceRoot":"","sources":["../src/AbleObject.ts"],"names":[],"mappings":";;AAAA,0CAAwC;AAOxC,MAA8B,UAE5B,SAAQ,cAAS;IAMV,MAAM,CAAC,OAAe;QAC3B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE;YACxC,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,EAAE,CAAC;SAC3B;QACD,IAAI,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE;YAChD,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;SACpC;IACH,CAAC;IAOM,OAAO,CAAC,OAAe;QAC5B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE;YACxC,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,EAAE,CAAC;SAC3B;QACD,IAAI,GAAW,CAAC;QAChB,GAAG;YACD,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YAC5C,IAAI,GAAG,KAAK,CAAC,CAAC,EAAE;gBACd,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;aACrC;SACF,QAAQ,GAAG,KAAK,CAAC,CAAC,EAAE;IACvB,CAAC;CACF;AAlCD,6BAkCC"}
1
+ {"version":3,"file":"AbleObject.js","sourceRoot":"","sources":["../src/AbleObject.ts"],"names":[],"mappings":";;AAAA,0CAAwC;AAExC;;;;GAIG;AACH,MAA8B,UAE5B,SAAQ,cAAS;IACjB;;;;OAIG;IACI,MAAM,CAAC,OAAe;QAC3B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC;YACzC,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,EAAE,CAAC;QAC5B,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;YAC5C,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;IAED;;;;OAIG;IACI,OAAO,CAAC,OAAe;QAC5B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC;YACzC,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,EAAE,CAAC;QAC5B,CAAC;QACD,IAAI,GAAW,CAAC;QAChB,GAAG,CAAC;YACF,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YAC5C,IAAI,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC;gBACf,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;YACtC,CAAC;QACH,CAAC,QAAQ,GAAG,KAAK,CAAC,CAAC,EAAE;IACvB,CAAC;CACF;AAlCD,6BAkCC"}
package/dist/Group.d.ts CHANGED
@@ -1,23 +1,69 @@
1
1
  import { EntityData, EntityJson, EntityPatch, Options, Selector, SerializedEntityData } from '@nymphjs/nymph';
2
- import type Tilmeld from './Tilmeld';
3
2
  import AbleObject from './AbleObject';
4
3
  import User, { UserData } from './User';
5
4
  export type GroupData = {
5
+ /**
6
+ * The abilities granted to the group.
7
+ */
6
8
  abilities?: string[];
9
+ /**
10
+ * The group's groupname.
11
+ */
7
12
  groupname?: string;
13
+ /**
14
+ * The group's name.
15
+ */
8
16
  name?: string;
17
+ /**
18
+ * The group's email address.
19
+ */
9
20
  email?: string;
21
+ /**
22
+ * The group's avatar URL. (Use getAvatar() to support Gravatar.)
23
+ */
10
24
  avatar?: string;
25
+ /**
26
+ * The group's telephone number.
27
+ */
11
28
  phone?: string;
29
+ /**
30
+ * The group's parent.
31
+ */
12
32
  parent?: Group & GroupData;
33
+ /**
34
+ * If generatePrimary is on, this will be the user who generated this group.
35
+ */
13
36
  user?: (User & UserData) | null;
37
+ /**
38
+ * Whether the group can be used.
39
+ */
14
40
  enabled?: boolean;
41
+ /**
42
+ * Whether this group is the default primary group for new users.
43
+ */
15
44
  defaultPrimary?: boolean;
45
+ /**
46
+ * Whether this group is a default secondary group for new users.
47
+ */
16
48
  defaultSecondary?: boolean;
49
+ /**
50
+ * Whether this group is a default secondary group for unverified users.
51
+ */
17
52
  unverifiedSecondary?: boolean;
18
53
  };
54
+ /**
55
+ * A user group data model.
56
+ *
57
+ * Written by Hunter Perrin for SciActive.
58
+ *
59
+ * @author Hunter Perrin <hperrin@gmail.com>
60
+ * @copyright SciActive Inc
61
+ * @see http://nymph.io/
62
+ */
19
63
  export default class Group extends AbleObject<GroupData> {
20
- static tilmeld: Tilmeld;
64
+ /**
65
+ * The instance of Tilmeld to use for queries.
66
+ */
21
67
  static ETYPE: string;
22
68
  static class: string;
23
69
  private static DEFAULT_PRIVATE_DATA;
@@ -29,29 +75,94 @@ export default class Group extends AbleObject<GroupData> {
29
75
  static searchRestrictedData: string[];
30
76
  protected $allowlistData?: string[] | undefined;
31
77
  protected $allowlistTags?: string[];
78
+ /**
79
+ * This is explicitly used only during the registration proccess.
80
+ */
32
81
  private $skipAcWhenSaving;
33
- static factory(guid?: string): Promise<Group & GroupData>;
34
82
  static factoryGroupname(groupname?: string): Promise<Group & GroupData>;
35
- static factorySync(guid?: string): Group & GroupData;
36
- constructor(guid?: string);
83
+ constructor();
84
+ /**
85
+ * Get all the groups that can be assigned as primary groups.
86
+ *
87
+ * @param options The options for an optional search query.
88
+ * @param selectors The selectors for an optional search query.
89
+ * @returns An array of the assignable primary groups.
90
+ */
37
91
  static getPrimaryGroups(options?: Options, selectors?: Selector[]): Promise<(Group & GroupData)[]>;
92
+ /**
93
+ * Get all the groups that can be assigned as secondary groups.
94
+ *
95
+ * @param options The options for an optional search query.
96
+ * @param selectors The selectors for an optional search query.
97
+ * @returns An array of the assignable secondary groups.
98
+ */
38
99
  static getSecondaryGroups(options?: Options, selectors?: Selector[]): Promise<(Group & GroupData)[]>;
39
100
  private static getAssignableGroups;
40
101
  $getAvatar(): string;
41
102
  $jsonAcceptData(input: EntityJson, allowConflict?: boolean): void;
42
103
  $jsonAcceptPatch(patch: EntityPatch, allowConflict?: boolean): void;
43
104
  $putData(data: EntityData, sdata?: SerializedEntityData): void;
105
+ /**
106
+ * Update the data protection arrays for a user.
107
+ *
108
+ * @param givenUser User to update protection for. If undefined, will use the currently logged in user.
109
+ */
44
110
  $updateDataProtection(givenUser?: User & UserData): void;
45
- $isDescendant(givenGroup: (Group & GroupData) | string): boolean;
111
+ /**
112
+ * Check whether the group is a descendant of a group.
113
+ *
114
+ * @param group The group, or the group's GUID.
115
+ * @returns True or false.
116
+ */
117
+ $isDescendant(givenGroup: (Group & GroupData) | string): Promise<boolean>;
118
+ /**
119
+ * Gets an array of the group's child groups.
120
+ *
121
+ * @returns An array of groups.
122
+ */
46
123
  $getChildren(): Promise<(Group & GroupData)[]>;
124
+ /**
125
+ * Gets an array of the group's descendant groups.
126
+ *
127
+ * @param andSelf Include this group in the returned array.
128
+ * @returns An array of groups.
129
+ */
47
130
  $getDescendants(andSelf?: boolean): Promise<(Group & GroupData)[]>;
48
- $getDescendantsSync(andSelf?: boolean): (Group & GroupData)[];
49
- $getLevel(): number;
131
+ /**
132
+ * Get the number of parents the group has.
133
+ *
134
+ * If the group is a top level group, this will return 0. If it is a child of
135
+ * a top level group, this will return 1. If it is a grandchild of a top level
136
+ * group, this will return 2, and so on.
137
+ *
138
+ * Levels will max out at 1024 to avoid recursive loops.
139
+ *
140
+ * @returns The level of the group.
141
+ */
142
+ $getLevel(): Promise<number>;
143
+ /**
144
+ * Gets an array of users in the group.
145
+ *
146
+ * @param descendants Include users in all descendant groups too.
147
+ * @param limit The limit for the query.
148
+ * @param offset The offset for the query.
149
+ * @returns An array of users.
150
+ */
50
151
  $getUsers(descendants?: boolean, limit?: number, offset?: number): Promise<(User & UserData)[]>;
152
+ /**
153
+ * Check that a groupname is valid.
154
+ *
155
+ * @returns An object with a boolean 'result' entry and a 'message' entry.
156
+ */
51
157
  $checkGroupname(): Promise<{
52
158
  result: boolean;
53
159
  message: string;
54
160
  }>;
161
+ /**
162
+ * Check that an email is unique.
163
+ *
164
+ * @returns An object with a boolean 'result' entry and a 'message' entry.
165
+ */
55
166
  $checkEmail(): Promise<{
56
167
  result: boolean;
57
168
  message: string;