@nymphjs/client 1.0.0-beta.12 → 1.0.0-beta.121

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 (71) hide show
  1. package/CHANGELOG.md +500 -0
  2. package/README.md +6 -6
  3. package/asyncitertest.js +53 -0
  4. package/dist/Entity.d.ts +156 -0
  5. package/{lib → dist}/Entity.js +202 -104
  6. package/dist/Entity.js.map +1 -0
  7. package/dist/Entity.types.d.ts +218 -0
  8. package/dist/Entity.types.js +2 -0
  9. package/{lib → dist}/EntityWeakCache.d.ts +1 -1
  10. package/{lib → dist}/EntityWeakCache.js +5 -9
  11. package/dist/EntityWeakCache.js.map +1 -0
  12. package/{lib → dist}/HttpRequester.d.ts +18 -4
  13. package/dist/HttpRequester.js +365 -0
  14. package/dist/HttpRequester.js.map +1 -0
  15. package/{lib → dist}/Nymph.d.ts +48 -11
  16. package/{lib → dist}/Nymph.js +167 -51
  17. package/dist/Nymph.js.map +1 -0
  18. package/dist/Nymph.types.d.ts +227 -0
  19. package/dist/Nymph.types.js +45 -0
  20. package/dist/Nymph.types.js.map +1 -0
  21. package/{lib → dist}/PubSub.d.ts +16 -10
  22. package/{lib → dist}/PubSub.js +208 -135
  23. package/dist/PubSub.js.map +1 -0
  24. package/{lib → dist}/PubSub.types.d.ts +19 -6
  25. package/dist/PubSub.types.js +2 -0
  26. package/{lib → dist}/entityRefresh.d.ts +1 -1
  27. package/{lib → dist}/entityRefresh.js +21 -13
  28. package/dist/entityRefresh.js.map +1 -0
  29. package/dist/index.d.ts +13 -0
  30. package/dist/index.js +13 -2
  31. package/dist/index.js.map +1 -1
  32. package/{lib → dist}/utils.d.ts +1 -1
  33. package/{lib → dist}/utils.js +28 -21
  34. package/dist/utils.js.map +1 -0
  35. package/jest.config.js +31 -5
  36. package/package.json +31 -30
  37. package/src/Entity.ts +174 -108
  38. package/src/Entity.types.ts +29 -47
  39. package/src/EntityWeakCache.ts +8 -6
  40. package/src/HttpRequester.ts +268 -31
  41. package/src/Nymph.ts +188 -88
  42. package/src/Nymph.types.ts +102 -2
  43. package/src/PubSub.ts +262 -179
  44. package/src/PubSub.types.ts +33 -19
  45. package/src/entityRefresh.ts +6 -6
  46. package/src/index.ts +10 -10
  47. package/src/utils.ts +12 -5
  48. package/tsconfig.json +7 -4
  49. package/typedoc.json +4 -0
  50. package/dist/index.js.LICENSE.txt +0 -8
  51. package/lib/Entity.d.ts +0 -51
  52. package/lib/Entity.js.map +0 -1
  53. package/lib/Entity.types.d.ts +0 -65
  54. package/lib/Entity.types.js +0 -3
  55. package/lib/EntityWeakCache.js.map +0 -1
  56. package/lib/HttpRequester.js +0 -190
  57. package/lib/HttpRequester.js.map +0 -1
  58. package/lib/Nymph.js.map +0 -1
  59. package/lib/Nymph.types.d.ts +0 -97
  60. package/lib/Nymph.types.js +0 -3
  61. package/lib/Nymph.types.js.map +0 -1
  62. package/lib/PubSub.js.map +0 -1
  63. package/lib/PubSub.types.js +0 -3
  64. package/lib/entityRefresh.js.map +0 -1
  65. package/lib/index.d.ts +0 -13
  66. package/lib/index.js +0 -34
  67. package/lib/index.js.map +0 -1
  68. package/lib/utils.js.map +0 -1
  69. package/webpack.config.js +0 -28
  70. /package/{lib → dist}/Entity.types.js.map +0 -0
  71. /package/{lib → dist}/PubSub.types.js.map +0 -0
@@ -1,4 +1,4 @@
1
- import { EntityConstructor, EntityInterface } from './Entity.types';
1
+ import { EntityConstructor, EntityInterface } from './Entity.types.js';
2
2
 
3
3
  export type NymphOptions = {
4
4
  /**
@@ -17,10 +17,18 @@ export type NymphOptions = {
17
17
  * A WebSocket implementation.
18
18
  */
19
19
  WebSocket?: typeof WebSocket;
20
+ /**
21
+ * Return `null` or empty array instead of error when entity/ies not found.
22
+ */
23
+ returnNullOnNotFound?: boolean;
20
24
  /**
21
25
  * Whether to not output status messages to the console.
22
26
  */
23
27
  noConsole?: boolean;
28
+ /**
29
+ * Don't automatically try to connect to PubSub server.
30
+ */
31
+ noAutoconnect?: boolean;
24
32
  /**
25
33
  * Use a WeakRef based cache of entities.
26
34
  *
@@ -40,6 +48,16 @@ export type NymphOptions = {
40
48
  * can help to synchronize them correctly and avoid data conflicts.
41
49
  */
42
50
  weakCache?: boolean;
51
+ /**
52
+ * Whether to renew tokens when a request is made.
53
+ *
54
+ * If you turn this off, the client will request that the server not renew an
55
+ * authentication token, even if it is within the renewal time of the
56
+ * expiration date.
57
+ *
58
+ * This defaults to true.
59
+ */
60
+ renewTokens?: boolean;
43
61
  };
44
62
 
45
63
  export type EventType = 'request' | 'response';
@@ -49,13 +67,45 @@ export type RequestCallback = (url: string, options: RequestInit) => void;
49
67
  export type ResponseCallback = (response: Response, text: string) => void;
50
68
 
51
69
  export type Options<T extends EntityConstructor = EntityConstructor> = {
70
+ /**
71
+ * The Entity class to query.
72
+ */
52
73
  class: T;
74
+ /**
75
+ * The limit of entities to be returned. Not needed when using `getEntity`, as
76
+ * it always returns only one.
77
+ */
53
78
  limit?: number;
79
+ /**
80
+ * The offset from the first matching entity, in order, to start retrieving.
81
+ */
54
82
  offset?: number;
83
+ /**
84
+ * If true, entities will be retrieved from newest to oldest/largest to
85
+ * smallest (with regard to `sort`).
86
+ */
55
87
  reverse?: boolean;
56
- sort?: 'cdate' | 'mdate';
88
+ /**
89
+ * How to sort the entities. Should be "cdate", "mdate", the name of a
90
+ * property, or null.
91
+ */
92
+ sort?: 'cdate' | 'mdate' | string | null;
93
+ /**
94
+ * What to return, the entities with their data, just the GUIDs, or just a
95
+ * count.
96
+ */
57
97
  return?: 'entity' | 'guid' | 'count';
98
+ /**
99
+ * If true, Nymph will skip the cache and retrieve the entity from the DB.
100
+ */
58
101
  skipCache?: boolean;
102
+ /**
103
+ * The level(s) of access control requested.
104
+ *
105
+ * Limiting the access control can significantly improve the performance of
106
+ * the query.
107
+ */
108
+ acRequest?: TilmeldAccessRequest;
59
109
  };
60
110
 
61
111
  export type Clause<C> = C | Exclude<C, undefined>[];
@@ -81,6 +131,9 @@ type PrimitiveSelector = {
81
131
  contain?: [string, any];
82
132
  '!contain'?: PrimitiveSelector['contain'];
83
133
 
134
+ search?: [string, string];
135
+ '!search'?: PrimitiveSelector['search'];
136
+
84
137
  match?: [string, string];
85
138
  '!match'?: PrimitiveSelector['match'];
86
139
 
@@ -136,6 +189,9 @@ export type Selector = {
136
189
  contain?: Clause<OrWithTime<PrimitiveSelector['contain']>>;
137
190
  '!contain'?: Clause<OrWithTime<PrimitiveSelector['contain']>>;
138
191
 
192
+ search?: Clause<PrimitiveSelector['search']>;
193
+ '!search'?: Clause<PrimitiveSelector['search']>;
194
+
139
195
  match?: Clause<PrimitiveSelector['match']>;
140
196
  '!match'?: Clause<PrimitiveSelector['match']>;
141
197
 
@@ -169,3 +225,47 @@ export type Selector = {
169
225
  selector?: Clause<Selector>;
170
226
  '!selector'?: Selector['selector'];
171
227
  };
228
+
229
+ export enum TilmeldAccessRequest {
230
+ /**
231
+ * The default level, any possible entity readable by the user.
232
+ *
233
+ * This is the same as or-ing together all of the levels listed below.
234
+ */
235
+ ALL_LEVELS = 0,
236
+ /**
237
+ * Owned by and accessible to the user.
238
+ *
239
+ * This is always enabled, so not including it has no effect. It's here to
240
+ * allow the selection of _only_ user owned entities.
241
+ */
242
+ USER_OWNED = 1,
243
+ /**
244
+ * Owned by and accessible to the user's primary group.
245
+ */
246
+ PRIMARY_GROUP_OWNED = 2,
247
+ /**
248
+ * Owned by and accessible to one of the user's secondary groups.
249
+ */
250
+ SECONDARY_GROUP_OWNED = 4,
251
+ /**
252
+ * The user is listed in an access control list.
253
+ */
254
+ USER_ACCESSIBLE = 8,
255
+ /**
256
+ * The user's primary group is listed in an access control list.
257
+ */
258
+ PRIMARY_GROUP_ACCESSIBLE = 16,
259
+ /**
260
+ * One of the user's secondary groups is listed in an access control list.
261
+ */
262
+ SECONDARY_GROUP_ACCESSIBLE = 32,
263
+ /**
264
+ * The entity is accessible to any user.
265
+ */
266
+ OTHER_ACCESSIBLE = 64,
267
+ /**
268
+ * The entity is not owned by anyone.
269
+ */
270
+ UNOWNED = 128,
271
+ }