entropic-bond 1.53.2 → 1.53.3
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.
|
@@ -33,6 +33,13 @@ export interface DocumentReference {
|
|
|
33
33
|
storedInCollection: string;
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
+
export interface DocumentChange {
|
|
37
|
+
before: Persistent | undefined;
|
|
38
|
+
after: Persistent;
|
|
39
|
+
params: {
|
|
40
|
+
[key: string]: any;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
36
43
|
type PersistentPropertyCollection = {
|
|
37
44
|
[className: string]: PersistentProperty[];
|
|
38
45
|
};
|
|
@@ -191,9 +198,17 @@ export declare class Persistent {
|
|
|
191
198
|
type CollectionPathCallback = (value: Persistent, prop: PersistentProperty) => string;
|
|
192
199
|
type ValidatorFunction<T extends Persistent, P extends ClassPropNames<T>> = (value: T[P], property: PersistentProperty, persistentInstance: T) => boolean;
|
|
193
200
|
export type OwnerCollectionResolver = (ownerClassName: string, params: {}) => string;
|
|
201
|
+
/**
|
|
202
|
+
* Cached properties configuration
|
|
203
|
+
* @param cachedProps an array of properties whose values should be stored in the reference object
|
|
204
|
+
* @param updater a function that is called when the referenced object is updated
|
|
205
|
+
* @param ownerCollectionResolver a function that returns the collection path where the reference is stored
|
|
206
|
+
* @see persistentReferenceWithCachedProps
|
|
207
|
+
* @see persistentPureReferenceWithCachedProps
|
|
208
|
+
*/
|
|
194
209
|
export type CachedPropsConfig<T extends Persistent> = {
|
|
195
210
|
cachedProps: ClassPropNamesOfType<T, Primitive>[];
|
|
196
|
-
updater?: (property: PersistentProperty) => Promise<void>;
|
|
211
|
+
updater?: (event: DocumentChange, property: PersistentProperty) => Promise<void>;
|
|
197
212
|
ownerCollectionResolver?: OwnerCollectionResolver;
|
|
198
213
|
};
|
|
199
214
|
export interface PersistentProperty {
|
|
@@ -231,8 +246,22 @@ export declare function persistentReference(target: Persistent, property: string
|
|
|
231
246
|
* Decorator to declare a persistent reference (see @persistentReference) that stores
|
|
232
247
|
* the values in cachedProps as values in the reference object. This is useful
|
|
233
248
|
* when you are not able to wait for population of referenced properties.
|
|
234
|
-
* @param
|
|
249
|
+
* @param cachedPropsConfig Pass an array of properties whose values should be stored in the reference object or an object
|
|
250
|
+
* with the cachedProps configuration.
|
|
235
251
|
* @param storedInCollection indicates the path of the collection where this reference is stored
|
|
252
|
+
* @param propTypeName the accepted type name or type names of the property
|
|
253
|
+
* @see persistentReference
|
|
254
|
+
* @see CachedPropsConfig
|
|
255
|
+
* @see persistentPureReferenceWithCachedProps
|
|
256
|
+
* @sample
|
|
257
|
+
* class UserGroup extends Persistent {
|
|
258
|
+
* @persistentReferenceWithCachedProps( ['name', 'email'], 'Customer/Clients', 'User' ) private _friend: User
|
|
259
|
+
* }
|
|
260
|
+
*
|
|
261
|
+
* class SpecialUserGroup extends Persistent {
|
|
262
|
+
* @persistentReferenceWithCachedProps( { cachedProps: ['name', 'email'], updater: async ( event, prop ) => {
|
|
263
|
+
* // do something when the referenced user is updated
|
|
264
|
+
* }}, undefined, [ 'SpecialUser', 'User' ] ) private _friend: User
|
|
236
265
|
*/
|
|
237
266
|
export declare function persistentReferenceWithCachedProps<T extends Persistent>(cachedPropsConfig: CachedPropsConfig<T> | ClassPropNamesOfType<T, Primitive>[], storeInCollection?: string | CollectionPathCallback, propTypeName?: string | string[]): (target: Persistent, property: string) => void;
|
|
238
267
|
/**
|
|
@@ -247,13 +276,23 @@ export declare function persistentPureReference(target: Persistent, property: st
|
|
|
247
276
|
* Decorator to declare a persistent property as a pure reference (see @persistentPureReference) that stores
|
|
248
277
|
* the values of the properties listed in cachedProps as values in the reference object. This is useful
|
|
249
278
|
* when you only need a few properties to be available without needing to populate the referenced property.
|
|
250
|
-
* @param
|
|
279
|
+
* @param cachedPropsConfig Pass an array of properties whose values should be stored in the reference object or an object
|
|
280
|
+
* with the cachedProps configuration.
|
|
251
281
|
* @param storedInCollection indicates the path of the collection where this reference is stored
|
|
282
|
+
* @param propTypeName the accepted type name or type names of the property
|
|
252
283
|
* @see persistentReferenceWithCachedProps
|
|
253
284
|
* @see persistentPureReference
|
|
285
|
+
* @see CachedPropsConfig
|
|
286
|
+
* @see persistentReferenceWithCachedProps
|
|
254
287
|
* @sample
|
|
255
|
-
* class
|
|
256
|
-
* @persistentPureReferenceWithCachedProps( ['name', 'email'] ) private _friend: User
|
|
288
|
+
* class UserGroup extends Persistent {
|
|
289
|
+
* @persistentPureReferenceWithCachedProps( ['name', 'email'], 'Customer/Clients', 'User' ) private _friend: User
|
|
290
|
+
* }
|
|
291
|
+
*
|
|
292
|
+
* class SpecialUserGroup extends Persistent {
|
|
293
|
+
* @persistentPureReferenceWithCachedProps( { cachedProps: ['name', 'email'], updater: async ( event, prop ) => {
|
|
294
|
+
* // do something when the referenced user is updated
|
|
295
|
+
* }}, undefined, [ 'SpecialUser', 'User' ] ) private _friend: User
|
|
257
296
|
* }
|
|
258
297
|
* // the reference object will contain the properties name and email of the referenced user
|
|
259
298
|
* // without having to populate the _friend property
|