@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.
- package/dist/bundle/index.js +6 -6
- package/dist/bundle/index.js.map +4 -4
- package/dist/cjs/__tests__/fixtures/testStorage.d.ts +52 -105
- package/dist/cjs/__tests__/fixtures/testStorage.js +36 -65
- package/dist/cjs/__tests__/fixtures/testStorage.js.map +1 -1
- package/dist/cjs/entities/Entity.d.ts +2 -2
- package/dist/cjs/entities/Entity.js.map +1 -1
- package/dist/cjs/entities/types.d.ts +22 -3
- package/dist/cjs/sync/PresenceManager.d.ts +11 -1
- package/dist/cjs/sync/PresenceManager.js.map +1 -1
- package/dist/esm/__tests__/fixtures/testStorage.d.ts +52 -105
- package/dist/esm/__tests__/fixtures/testStorage.js +37 -66
- package/dist/esm/__tests__/fixtures/testStorage.js.map +1 -1
- package/dist/esm/entities/Entity.d.ts +2 -2
- package/dist/esm/entities/Entity.js.map +1 -1
- package/dist/esm/entities/types.d.ts +22 -3
- package/dist/esm/sync/PresenceManager.d.ts +11 -1
- package/dist/esm/sync/PresenceManager.js.map +1 -1
- package/dist/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/__tests__/fixtures/testStorage.ts +37 -66
- package/src/entities/Entity.ts +1 -1
- package/src/entities/EntityStore.ts +1 -1
- package/src/entities/types.ts +28 -8
- package/src/sync/PresenceManager.ts +11 -1
|
@@ -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];
|
package/src/entities/types.ts
CHANGED
|
@@ -72,13 +72,11 @@ export interface BaseEntity<
|
|
|
72
72
|
readonly uid: string;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
export type DeepPartial<T> =
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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?: {
|
|
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
|
-
|
|
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>>;
|