@verdant-web/store 3.0.5 → 3.0.7

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.
@@ -397,7 +397,7 @@ export class EntityStore extends Disposable {
397
397
  private getCollectionSchema = (
398
398
  collectionName: string,
399
399
  ): {
400
- schema: StorageObjectFieldSchema | null;
400
+ schema: StorageObjectFieldSchema<any> | null;
401
401
  readonlyKeys: string[];
402
402
  } => {
403
403
  const schema = this.ctx.schema.collections[collectionName];
@@ -72,13 +72,11 @@ export interface BaseEntity<
72
72
  readonly uid: string;
73
73
  }
74
74
 
75
- export type DeepPartial<T> = {
76
- [P in keyof T]?: T[P] extends Array<infer U>
77
- ? Array<DeepPartial<U>>
78
- : T[P] extends ReadonlyArray<infer U>
79
- ? ReadonlyArray<DeepPartial<U>>
80
- : DeepPartial<T[P]>;
81
- };
75
+ export type DeepPartial<T> = T extends object
76
+ ? {
77
+ [P in keyof T]?: DeepPartial<T[P]>;
78
+ }
79
+ : T;
82
80
 
83
81
  export interface ObjectEntity<
84
82
  Init,
@@ -92,7 +90,29 @@ export interface ObjectEntity<
92
90
  delete(key: DeletableKeys<Value>): void;
93
91
  update(
94
92
  value: DeepPartial<Init>,
95
- options?: { replaceSubObjects?: boolean; merge?: boolean },
93
+ options?: {
94
+ /**
95
+ * Forces the replacement of sub-objects in the update payload - rather than
96
+ * Verdant keeping their identities intact and merging changes, your update
97
+ * will replace these objects entirely, overwriting any other changes from other
98
+ * sources.
99
+ *
100
+ * Useful when the update you're making is logically replacing sub-objects, rather
101
+ * than simply modifying them.
102
+ *
103
+ * Default: false
104
+ */
105
+ replaceSubObjects?: boolean;
106
+ /**
107
+ * If set to false, this will drop any keys in the object which were
108
+ * not provided in your update payload, while also merging the ones that
109
+ * were. This option only works for `map` and `any` type fields; you cannot
110
+ * use it with defined `object` type fields.
111
+ *
112
+ * Default: true
113
+ */
114
+ merge?: boolean;
115
+ },
96
116
  ): void;
97
117
  readonly isList: false;
98
118
  }
@@ -13,10 +13,20 @@ export class PresenceManager<
13
13
  Profile = any,
14
14
  Presence = any,
15
15
  > extends EventSubscriber<{
16
+ /**
17
+ * Fired when a particular peer's presence changes
18
+ */
16
19
  peerChanged: (userId: string, presence: UserInfo<Profile, Presence>) => void;
20
+ /**
21
+ * Fired immediately when a change to local presence is made. This change may not
22
+ * yet have been sent to the server (see: "update" event)
23
+ */
17
24
  selfChanged: (presence: UserInfo<Profile, Presence>) => void;
18
- peersChanged: (peers: Record<string, any>) => void;
25
+ /** Fired when any number of peer presences have changed */
26
+ peersChanged: (peers: Record<string, UserInfo<Profile, Presence>>) => void;
27
+ /** Fired when a peer presence goes offline */
19
28
  peerLeft: (userId: string, lastPresence: UserInfo<Profile, Presence>) => void;
29
+ /** Fired after local presence changes are flushed to the server. */
20
30
  update: (presence: Partial<Presence>) => void;
21
31
  }> {
22
32
  private _peers = {} as Record<string, UserInfo<Profile, Presence>>;