jazz-tools 0.7.3 → 0.7.6
Sign up to get free protection for your applications and to get access to all the features.
- package/.turbo/turbo-build.log +2 -17
- package/CHANGELOG.md +6 -0
- package/dist/coValues/account.js +11 -1
- package/dist/coValues/account.js.map +1 -1
- package/dist/coValues/coList.js +156 -9
- package/dist/coValues/coList.js.map +1 -1
- package/dist/coValues/coMap.js +122 -10
- package/dist/coValues/coMap.js.map +1 -1
- package/dist/coValues/group.js +1 -1
- package/dist/coValues/group.js.map +1 -1
- package/dist/coValues/interfaces.js.map +1 -1
- package/package.json +1 -1
- package/src/coValues/account.ts +24 -1
- package/src/coValues/coList.ts +163 -15
- package/src/coValues/coMap.ts +122 -10
- package/src/coValues/group.ts +1 -1
- package/src/coValues/interfaces.ts +1 -0
package/.turbo/turbo-build.log
CHANGED
@@ -1,23 +1,8 @@
|
|
1
1
|
|
2
|
-
> jazz-tools@0.7.
|
2
|
+
> jazz-tools@0.7.3 build /Users/anselm/jazz/jazz/packages/jazz-tools
|
3
3
|
> npm run lint && rm -rf ./dist && tsc --sourceMap --outDir dist
|
4
4
|
|
5
5
|
|
6
|
-
> jazz-tools@0.7.
|
6
|
+
> jazz-tools@0.7.3 lint
|
7
7
|
> eslint . --ext ts,tsx
|
8
8
|
|
9
|
-
|
10
|
-
/Users/anselm/jazz/jazz/packages/jazz-tools/src/coValues/coStream.ts
|
11
|
-
671:9 error 'Cl' is defined but never used. Allowed unused vars must match /^_/u @typescript-eslint/no-unused-vars
|
12
|
-
686:9 error 'Cl' is defined but never used. Allowed unused vars must match /^_/u @typescript-eslint/no-unused-vars
|
13
|
-
|
14
|
-
/Users/anselm/jazz/jazz/packages/jazz-tools/src/coValues/interfaces.ts
|
15
|
-
56:12 error Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
16
|
-
|
17
|
-
✖ 3 problems (3 errors, 0 warnings)
|
18
|
-
|
19
|
-
npm ERR! Lifecycle script `lint` failed with error:
|
20
|
-
npm ERR! Error: command failed
|
21
|
-
npm ERR! in workspace: jazz-tools@0.7.1
|
22
|
-
npm ERR! at location: /Users/anselm/jazz/jazz/packages/jazz-tools
|
23
|
-
ELIFECYCLE Command failed with exit code 1.
|
package/CHANGELOG.md
CHANGED
package/dist/coValues/account.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
var _a;
|
2
|
-
import { LocalNode } from "cojson";
|
2
|
+
import { LocalNode, cojsonInternals } from "cojson";
|
3
3
|
import { Context } from "effect";
|
4
4
|
import { Group, CoValueBase, MembersSym, Profile, Ref, SchemaInit, inspect, subscriptionsScopes, loadCoValue, loadCoValueEf, subscribeToCoValue, subscribeToCoValueEf, ensureCoValueLoaded, subscribeToExistingCoValue, } from "../internal.js";
|
5
5
|
/** @category Identity & Permissions */
|
@@ -83,6 +83,16 @@ export class Account extends CoValueBase {
|
|
83
83
|
});
|
84
84
|
return this.fromNode(node);
|
85
85
|
}
|
86
|
+
static createAs(as, options) {
|
87
|
+
// TODO: is there a cleaner way to do this?
|
88
|
+
const connectedPeers = cojsonInternals.connectedPeers("creatingAccount", "createdAccount", { peer1role: "server", peer2role: "client" });
|
89
|
+
as._raw.core.node.syncManager.addPeer(connectedPeers[1]);
|
90
|
+
return this.create({
|
91
|
+
creationProps: options.creationProps,
|
92
|
+
crypto: as._raw.core.node.crypto,
|
93
|
+
peersToLoadFrom: [connectedPeers[0]],
|
94
|
+
});
|
95
|
+
}
|
86
96
|
static fromNode(node) {
|
87
97
|
return new this({
|
88
98
|
fromRaw: node.account,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"account.js","sourceRoot":"","sources":["../../src/coValues/account.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;
|
1
|
+
{"version":3,"file":"account.js","sourceRoot":"","sources":["../../src/coValues/account.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAapD,OAAO,EAAE,OAAO,EAAkB,MAAM,QAAQ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;iBACd,GAAG,CAAC,QAAQ,CAAC;gBACd,EAAE,kBAAkB,CAAC,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC;YAC9C,OAAO,IAAI,CAAC;QAChB,CAAC;aAAM,CAAC;YACJ,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;QACrD,CAAC;IACL,CAAC;IACD,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE,UAAU;;QAClC,IACI,CAAC,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,MAAM,IAAI,GAAG,KAAK,UAAU,CAAC;YAC3D,OAAO,UAAU,CAAC,KAAK,KAAK,QAAQ;YACpC,UAAU,IAAI,UAAU,CAAC,KAAK,EAChC,CAAC;YACC,MAAC,MAAM,CAAC,WAA4B,EAAC,OAAO,QAAP,OAAO,GAAK,EAAE,EAAC;YACnD,MAAM,CAAC,WAA4B,CAAC,OAAO,CAAC,GAAG,CAAC;gBAC7C,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;YACjC,OAAO,IAAI,CAAC;QAChB,CAAC;aAAM,CAAC;YACJ,OAAO,OAAO,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC;QAC3D,CAAC;IACL,CAAC;CACJ,CAAC;AAEF,uCAAuC;AACvC,MAAM,OAAO,UAAW,SAAQ,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,EAAuB;CAAG;AAEhF,uCAAuC;AACvC,MAAM,UAAU,mBAAmB,CAAC,OAAgB;IAKhD,OAAO,OAAO,CAAC,IAAI,CAAC;AACxB,CAAC"}
|
package/dist/coValues/coList.js
CHANGED
@@ -2,9 +2,40 @@ var _a;
|
|
2
2
|
import { RawAccount } from "cojson";
|
3
3
|
import { Account, Group, InitValues, ItemsSym, Ref, SchemaInit, co, ensureCoValueLoaded, inspect, isRefEncoded, loadCoValue, loadCoValueEf, makeRefs, subscribeToCoValue, subscribeToCoValueEf, subscribeToExistingCoValue, } from "../internal.js";
|
4
4
|
import { encodeSync, decodeSync } from "@effect/schema/Schema";
|
5
|
-
/**
|
5
|
+
/**
|
6
|
+
* CoLists are collaborative versions of plain arrays.
|
7
|
+
*
|
8
|
+
* * @categoryDescription Content
|
9
|
+
* You can access items on a `CoList` as if they were normal items on a plain array, using `[]` notation, etc.
|
10
|
+
*
|
11
|
+
* Since `CoList` is a subclass of `Array`, you can use all the normal array methods like `push`, `pop`, `splice`, etc.
|
12
|
+
*
|
13
|
+
* ```ts
|
14
|
+
* colorList[0];
|
15
|
+
* colorList[3] = "yellow";
|
16
|
+
* colorList.push("Kawazaki Green");
|
17
|
+
* colorList.splice(1, 1);
|
18
|
+
* ```
|
19
|
+
*
|
20
|
+
* @category CoValues
|
21
|
+
*/
|
6
22
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
7
23
|
export class CoList extends Array {
|
24
|
+
/**
|
25
|
+
* Declare a `CoList` by subclassing `CoList.Of(...)` and passing the item schema using `co`.
|
26
|
+
*
|
27
|
+
* @example
|
28
|
+
* ```ts
|
29
|
+
* class ColorList extends CoList.Of(
|
30
|
+
* co.string
|
31
|
+
* ) {}
|
32
|
+
* class AnimalList extends CoList.Of(
|
33
|
+
* co.ref(Animal)
|
34
|
+
* ) {}
|
35
|
+
* ```
|
36
|
+
*
|
37
|
+
* @category Declaration
|
38
|
+
*/
|
8
39
|
static Of(item) {
|
9
40
|
var _b, _c;
|
10
41
|
// TODO: cache superclass for item class
|
@@ -17,19 +48,38 @@ export class CoList extends Array {
|
|
17
48
|
_b = co.items,
|
18
49
|
_c;
|
19
50
|
}
|
20
|
-
/**
|
51
|
+
/**
|
52
|
+
* @ignore
|
53
|
+
* @deprecated Use UPPERCASE `CoList.Of` instead! */
|
21
54
|
static of(..._args) {
|
22
55
|
throw new Error("Can't use Array.of with CoLists");
|
23
56
|
}
|
57
|
+
/** @internal */
|
24
58
|
get _schema() {
|
25
59
|
return this.constructor._schema;
|
26
60
|
}
|
61
|
+
/** @category Collaboration */
|
27
62
|
get _owner() {
|
28
63
|
return this._raw.group instanceof RawAccount
|
29
64
|
? Account.fromRaw(this._raw.group)
|
30
65
|
: Group.fromRaw(this._raw.group);
|
31
66
|
}
|
32
|
-
/**
|
67
|
+
/**
|
68
|
+
* If a `CoList`'s items are a `co.ref(...)`, you can use `coList._refs[i]` to access
|
69
|
+
* the `Ref` instead of the potentially loaded/null value.
|
70
|
+
*
|
71
|
+
* This allows you to always get the ID or load the value manually.
|
72
|
+
*
|
73
|
+
* @example
|
74
|
+
* ```ts
|
75
|
+
* animals._refs[0].id; // => ID<Animal>
|
76
|
+
* animals._refs[0].value;
|
77
|
+
* // => Animal | null
|
78
|
+
* const animal = await animals._refs[0].load();
|
79
|
+
* ```
|
80
|
+
*
|
81
|
+
* @category Content
|
82
|
+
**/
|
33
83
|
get _refs() {
|
34
84
|
return makeRefs((idx) => this._raw.get(idx), () => Array.from({ length: this._raw.entries().length }, (_, idx) => idx), this._loadedAs, (_idx) => this._schema[ItemsSym]);
|
35
85
|
}
|
@@ -65,6 +115,27 @@ export class CoList extends Array {
|
|
65
115
|
}
|
66
116
|
return new Proxy(this, CoListProxyHandler);
|
67
117
|
}
|
118
|
+
/**
|
119
|
+
* Create a new CoList with the given initial values and owner.
|
120
|
+
*
|
121
|
+
* The owner (a Group or Account) determines access rights to the CoMap.
|
122
|
+
*
|
123
|
+
* The CoList will immediately be persisted and synced to connected peers.
|
124
|
+
*
|
125
|
+
* @example
|
126
|
+
* ```ts
|
127
|
+
* const colours = ColorList.create(
|
128
|
+
* ["red", "green", "blue"],
|
129
|
+
* { owner: me }
|
130
|
+
* );
|
131
|
+
* const animals = AnimalList.create(
|
132
|
+
* [cat, dog, fish],
|
133
|
+
* { owner: me }
|
134
|
+
* );
|
135
|
+
* ```
|
136
|
+
*
|
137
|
+
* @category Creation
|
138
|
+
**/
|
68
139
|
static create(items, options) {
|
69
140
|
return new this({ init: items, owner: options.owner });
|
70
141
|
}
|
@@ -123,34 +194,110 @@ export class CoList extends Array {
|
|
123
194
|
[inspect]() {
|
124
195
|
return this.toJSON();
|
125
196
|
}
|
197
|
+
/** @category Internals */
|
126
198
|
static fromRaw(raw) {
|
127
199
|
return new this({ fromRaw: raw });
|
128
200
|
}
|
201
|
+
/** @internal */
|
129
202
|
static schema(def) {
|
130
203
|
this._schema || (this._schema = {});
|
131
204
|
Object.assign(this._schema, def);
|
132
205
|
}
|
133
|
-
/**
|
206
|
+
/**
|
207
|
+
* Load a `CoList` with a given ID, as a given account.
|
208
|
+
*
|
209
|
+
* `depth` specifies if item CoValue references should be loaded as well before resolving.
|
210
|
+
* The `DeeplyLoaded` return type guarantees that corresponding referenced CoValues are loaded to the specified depth.
|
211
|
+
*
|
212
|
+
* You can pass `[]` or for shallowly loading only this CoList, or `[itemDepth]` for recursively loading referenced CoValues.
|
213
|
+
*
|
214
|
+
* Check out the `load` methods on `CoMap`/`CoList`/`CoStream`/`Group`/`Account` to see which depth structures are valid to nest.
|
215
|
+
*
|
216
|
+
* @example
|
217
|
+
* ```ts
|
218
|
+
* const animalsWithVets =
|
219
|
+
* await ListOfAnimals.load(
|
220
|
+
* "co_zdsMhHtfG6VNKt7RqPUPvUtN2Ax",
|
221
|
+
* me,
|
222
|
+
* [{ vet: {} }]
|
223
|
+
* );
|
224
|
+
* ```
|
225
|
+
*
|
226
|
+
* @category Subscription & Loading
|
227
|
+
*/
|
134
228
|
static load(id, as, depth) {
|
135
229
|
return loadCoValue(this, id, as, depth);
|
136
230
|
}
|
137
|
-
/**
|
231
|
+
/**
|
232
|
+
* Effectful version of `CoList.load()`.
|
233
|
+
*
|
234
|
+
* Needs to be run inside an `AccountCtx` context.
|
235
|
+
*
|
236
|
+
* @category Subscription & Loading
|
237
|
+
*/
|
138
238
|
static loadEf(id, depth) {
|
139
239
|
return loadCoValueEf(this, id, depth);
|
140
240
|
}
|
141
|
-
/**
|
241
|
+
/**
|
242
|
+
* Load and subscribe to a `CoList` with a given ID, as a given account.
|
243
|
+
*
|
244
|
+
* Automatically also subscribes to updates to all referenced/nested CoValues as soon as they are accessed in the listener.
|
245
|
+
*
|
246
|
+
* `depth` specifies if item CoValue references should be loaded as well before calling `listener` for the first time.
|
247
|
+
* The `DeeplyLoaded` return type guarantees that corresponding referenced CoValues are loaded to the specified depth.
|
248
|
+
*
|
249
|
+
* You can pass `[]` or for shallowly loading only this CoList, or `[itemDepth]` for recursively loading referenced CoValues.
|
250
|
+
*
|
251
|
+
* Check out the `load` methods on `CoMap`/`CoList`/`CoStream`/`Group`/`Account` to see which depth structures are valid to nest.
|
252
|
+
*
|
253
|
+
* Returns an unsubscribe function that you should call when you no longer need updates.
|
254
|
+
*
|
255
|
+
* Also see the `useCoState` hook to reactively subscribe to a CoValue in a React component.
|
256
|
+
*
|
257
|
+
* @example
|
258
|
+
* ```ts
|
259
|
+
* const unsub = ListOfAnimals.subscribe(
|
260
|
+
* "co_zdsMhHtfG6VNKt7RqPUPvUtN2Ax",
|
261
|
+
* me,
|
262
|
+
* { vet: {} },
|
263
|
+
* (animalsWithVets) => console.log(animalsWithVets)
|
264
|
+
* );
|
265
|
+
* ```
|
266
|
+
*
|
267
|
+
* @category Subscription & Loading
|
268
|
+
*/
|
142
269
|
static subscribe(id, as, depth, listener) {
|
143
270
|
return subscribeToCoValue(this, id, as, depth, listener);
|
144
271
|
}
|
145
|
-
/**
|
272
|
+
/**
|
273
|
+
* Effectful version of `CoList.subscribe()` that returns a stream of updates.
|
274
|
+
*
|
275
|
+
* Needs to be run inside an `AccountCtx` context.
|
276
|
+
*
|
277
|
+
* @category Subscription & Loading
|
278
|
+
*/
|
146
279
|
static subscribeEf(id, depth) {
|
147
280
|
return subscribeToCoValueEf(this, id, depth);
|
148
281
|
}
|
149
|
-
/**
|
282
|
+
/**
|
283
|
+
* Given an already loaded `CoList`, ensure that items are loaded to the specified depth.
|
284
|
+
*
|
285
|
+
* Works like `CoList.load()`, but you don't need to pass the ID or the account to load as again.
|
286
|
+
*
|
287
|
+
* @category Subscription & Loading
|
288
|
+
*/
|
150
289
|
ensureLoaded(depth) {
|
151
290
|
return ensureCoValueLoaded(this, depth);
|
152
291
|
}
|
153
|
-
/**
|
292
|
+
/**
|
293
|
+
* Given an already loaded `CoList`, subscribe to updates to the `CoList` and ensure that items are loaded to the specified depth.
|
294
|
+
*
|
295
|
+
* Works like `CoList.subscribe()`, but you don't need to pass the ID or the account to load as again.
|
296
|
+
*
|
297
|
+
* Returns an unsubscribe function that you should call when you no longer need updates.
|
298
|
+
*
|
299
|
+
* @category Subscription & Loading
|
300
|
+
**/
|
154
301
|
subscribe(depth, listener) {
|
155
302
|
return subscribeToExistingCoValue(this, depth, listener);
|
156
303
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"coList.js","sourceRoot":"","sources":["../../src/coValues/coList.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAepC,OAAO,EACH,OAAO,EACP,KAAK,EACL,UAAU,EACV,QAAQ,EACR,GAAG,EACH,UAAU,EACV,EAAE,EACF,mBAAmB,EACnB,OAAO,EACP,YAAY,EACZ,WAAW,EACX,aAAa,EACb,QAAQ,EACR,kBAAkB,EAClB,oBAAoB,EACpB,0BAA0B,GAC7B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAG/D
|
1
|
+
{"version":3,"file":"coList.js","sourceRoot":"","sources":["../../src/coValues/coList.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAepC,OAAO,EACH,OAAO,EACP,KAAK,EACL,UAAU,EACV,QAAQ,EACR,GAAG,EACH,UAAU,EACV,EAAE,EACF,mBAAmB,EACnB,OAAO,EACP,YAAY,EACZ,WAAW,EACX,aAAa,EACb,QAAQ,EACR,kBAAkB,EAClB,oBAAoB,EACpB,0BAA0B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,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;QACrD,CAAC;IACL,CAAC;IACD,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE,UAAU;;QAClC,IACI,UAAU,CAAC,KAAK;YAChB,GAAG,KAAK,QAAQ;YAChB,OAAO,UAAU,CAAC,KAAK,KAAK,QAAQ;YACpC,UAAU,IAAI,UAAU,CAAC,KAAK,EAChC,CAAC;YACC,MAAC,MAAM,CAAC,WAA6B,EAAC,OAAO,QAAP,OAAO,GAAK,EAAE,EAAC;YACpD,MAAM,CAAC,WAA6B,CAAC,OAAO,CAAC,QAAQ,CAAC;gBACnD,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;YACjC,IAAI,CAAC,MAAM,CAAC,CAAC;YACb,OAAO,IAAI,CAAC;QAChB,CAAC;aAAM,CAAC;YACJ,OAAO,OAAO,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC;QAC3D,CAAC;IACL,CAAC;IACD,GAAG,CAAC,MAAM,EAAE,GAAG;QACX,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;YAC1C,OAAO,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,MAAM,CAAC;QACtD,CAAC;aAAM,CAAC;YACJ,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QACpC,CAAC;IACL,CAAC;CACJ,CAAC"}
|
package/dist/coValues/coMap.js
CHANGED
@@ -7,6 +7,8 @@ import { Account, CoValueBase, Ref, SchemaInit, inspect, makeRefs, subscriptions
|
|
7
7
|
* @categoryDescription Declaration
|
8
8
|
* Declare your own CoMap schemas by subclassing `CoMap` and assigning field schemas with `co`.
|
9
9
|
*
|
10
|
+
* Optional `co.ref(...)` fields must be marked with `{ optional: true }`.
|
11
|
+
*
|
10
12
|
* ```ts
|
11
13
|
* import { co, CoMap } from "jazz-tools";
|
12
14
|
*
|
@@ -14,6 +16,7 @@ import { Account, CoValueBase, Ref, SchemaInit, inspect, makeRefs, subscriptions
|
|
14
16
|
* name = co.string;
|
15
17
|
* age = co.number;
|
16
18
|
* pet = co.ref(Animal);
|
19
|
+
* car = co.ref(Car, { optional: true });
|
17
20
|
* }
|
18
21
|
* ```
|
19
22
|
*
|
@@ -39,17 +42,19 @@ export class CoMap extends CoValueBase {
|
|
39
42
|
/**
|
40
43
|
* If property `prop` is a `co.ref(...)`, you can use `coMaps._refs.prop` to access
|
41
44
|
* the `Ref` instead of the potentially loaded/null value.
|
45
|
+
*
|
42
46
|
* This allows you to always get the ID or load the value manually.
|
43
47
|
*
|
44
48
|
* @example
|
45
49
|
* ```ts
|
46
50
|
* person._refs.pet.id; // => ID<Animal>
|
47
51
|
* person._refs.pet.value;
|
48
|
-
* // => Animal |
|
52
|
+
* // => Animal | null
|
49
53
|
* const pet = await person._refs.pet.load();
|
50
54
|
* ```
|
51
55
|
*
|
52
|
-
* @category Content
|
56
|
+
* @category Content
|
57
|
+
**/
|
53
58
|
get _refs() {
|
54
59
|
return makeRefs((key) => this._raw.get(key), () => {
|
55
60
|
const keys = this._raw.keys().filter((key) => {
|
@@ -117,7 +122,24 @@ export class CoMap extends CoValueBase {
|
|
117
122
|
}
|
118
123
|
return new Proxy(this, CoMapProxyHandler);
|
119
124
|
}
|
120
|
-
/**
|
125
|
+
/**
|
126
|
+
* Create a new CoMap with the given initial values and owner.
|
127
|
+
*
|
128
|
+
* The owner (a Group or Account) determines access rights to the CoMap.
|
129
|
+
*
|
130
|
+
* The CoMap will immediately be persisted and synced to connected peers.
|
131
|
+
*
|
132
|
+
* @example
|
133
|
+
* ```ts
|
134
|
+
* const person = Person.create({
|
135
|
+
* name: "Alice",
|
136
|
+
* age: 42,
|
137
|
+
* pet: cat,
|
138
|
+
* }, { owner: friendGroup });
|
139
|
+
* ```
|
140
|
+
*
|
141
|
+
* @category Creation
|
142
|
+
**/
|
121
143
|
static create(init, options) {
|
122
144
|
return new this({ init, owner: options.owner });
|
123
145
|
}
|
@@ -172,7 +194,24 @@ export class CoMap extends CoValueBase {
|
|
172
194
|
}
|
173
195
|
return rawOwner.createMap(rawInit);
|
174
196
|
}
|
175
|
-
/**
|
197
|
+
/**
|
198
|
+
* Declare a Record-like CoMap schema, by extending `CoMap.Record(...)` and passing the value schema using `co`. Keys are always `string`.
|
199
|
+
*
|
200
|
+
* @example
|
201
|
+
* ```ts
|
202
|
+
* import { co, CoMap } from "jazz-tools";
|
203
|
+
*
|
204
|
+
* class ColorToFruitMap extends CoMap.Record(
|
205
|
+
* co.ref(Fruit)
|
206
|
+
* ) {}
|
207
|
+
*
|
208
|
+
* // assume we have map: ColorToFruitMap
|
209
|
+
* // and strawberry: Fruit
|
210
|
+
* map["red"] = strawberry;
|
211
|
+
* ```
|
212
|
+
*
|
213
|
+
* @category Declaration
|
214
|
+
*/
|
176
215
|
static Record(value) {
|
177
216
|
var _b;
|
178
217
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
|
@@ -185,27 +224,100 @@ export class CoMap extends CoValueBase {
|
|
185
224
|
_b = ItemsSym;
|
186
225
|
return RecordLikeCoMap;
|
187
226
|
}
|
188
|
-
/**
|
227
|
+
/**
|
228
|
+
* Load a `CoMap` with a given ID, as a given account.
|
229
|
+
*
|
230
|
+
* `depth` specifies which (if any) fields that reference other CoValues to load as well before resolving.
|
231
|
+
* The `DeeplyLoaded` return type guarantees that corresponding referenced CoValues are loaded to the specified depth.
|
232
|
+
*
|
233
|
+
* You can pass `[]` or `{}` for shallowly loading only this CoMap, or `{ fieldA: depthA, fieldB: depthB }` for recursively loading referenced CoValues.
|
234
|
+
*
|
235
|
+
* Check out the `load` methods on `CoMap`/`CoList`/`CoStream`/`Group`/`Account` to see which depth structures are valid to nest.
|
236
|
+
*
|
237
|
+
* @example
|
238
|
+
* ```ts
|
239
|
+
* const person = await Person.load(
|
240
|
+
* "co_zdsMhHtfG6VNKt7RqPUPvUtN2Ax",
|
241
|
+
* me,
|
242
|
+
* { pet: {} }
|
243
|
+
* );
|
244
|
+
* ```
|
245
|
+
*
|
246
|
+
* @category Subscription & Loading
|
247
|
+
*/
|
189
248
|
static load(id, as, depth) {
|
190
249
|
return loadCoValue(this, id, as, depth);
|
191
250
|
}
|
192
|
-
/**
|
251
|
+
/**
|
252
|
+
* Effectful version of `CoMap.load()`.
|
253
|
+
*
|
254
|
+
* Needs to be run inside an `AccountCtx` context.
|
255
|
+
*
|
256
|
+
* @category Subscription & Loading
|
257
|
+
*/
|
193
258
|
static loadEf(id, depth) {
|
194
259
|
return loadCoValueEf(this, id, depth);
|
195
260
|
}
|
196
|
-
/**
|
261
|
+
/**
|
262
|
+
* Load and subscribe to a `CoMap` with a given ID, as a given account.
|
263
|
+
*
|
264
|
+
* Automatically also subscribes to updates to all referenced/nested CoValues as soon as they are accessed in the listener.
|
265
|
+
*
|
266
|
+
* `depth` specifies which (if any) fields that reference other CoValues to load as well before calling `listener` for the first time.
|
267
|
+
* The `DeeplyLoaded` return type guarantees that corresponding referenced CoValues are loaded to the specified depth.
|
268
|
+
*
|
269
|
+
* You can pass `[]` or `{}` for shallowly loading only this CoMap, or `{ fieldA: depthA, fieldB: depthB }` for recursively loading referenced CoValues.
|
270
|
+
*
|
271
|
+
* Check out the `load` methods on `CoMap`/`CoList`/`CoStream`/`Group`/`Account` to see which depth structures are valid to nest.
|
272
|
+
*
|
273
|
+
* Returns an unsubscribe function that you should call when you no longer need updates.
|
274
|
+
*
|
275
|
+
* Also see the `useCoState` hook to reactively subscribe to a CoValue in a React component.
|
276
|
+
*
|
277
|
+
* @example
|
278
|
+
* ```ts
|
279
|
+
* const unsub = Person.subscribe(
|
280
|
+
* "co_zdsMhHtfG6VNKt7RqPUPvUtN2Ax",
|
281
|
+
* me,
|
282
|
+
* { pet: {} },
|
283
|
+
* (person) => console.log(person)
|
284
|
+
* );
|
285
|
+
* ```
|
286
|
+
*
|
287
|
+
* @category Subscription & Loading
|
288
|
+
*/
|
197
289
|
static subscribe(id, as, depth, listener) {
|
198
290
|
return subscribeToCoValue(this, id, as, depth, listener);
|
199
291
|
}
|
200
|
-
/**
|
292
|
+
/**
|
293
|
+
* Effectful version of `CoMap.subscribe()` that returns a stream of updates.
|
294
|
+
*
|
295
|
+
* Needs to be run inside an `AccountCtx` context.
|
296
|
+
*
|
297
|
+
* @category Subscription & Loading
|
298
|
+
*/
|
201
299
|
static subscribeEf(id, depth) {
|
202
300
|
return subscribeToCoValueEf(this, id, depth);
|
203
301
|
}
|
204
|
-
/**
|
302
|
+
/**
|
303
|
+
* Given an already loaded `CoMap`, ensure that the specified fields are loaded to the specified depth.
|
304
|
+
*
|
305
|
+
* Works like `CoMap.load()`, but you don't need to pass the ID or the account to load as again.
|
306
|
+
*
|
307
|
+
* @category Subscription & Loading
|
308
|
+
*/
|
205
309
|
ensureLoaded(depth) {
|
206
310
|
return ensureCoValueLoaded(this, depth);
|
207
311
|
}
|
208
|
-
/**
|
312
|
+
/**
|
313
|
+
* Given an already loaded `CoMap`, subscribe to updates to the `CoMap` and ensure that the specified fields are loaded to the specified depth.
|
314
|
+
*
|
315
|
+
* Works like `CoMap.subscribe()`, but you don't need to pass the ID or the account to load as again.
|
316
|
+
*
|
317
|
+
* Returns an unsubscribe function that you should call when you no longer need updates.
|
318
|
+
*
|
319
|
+
* @category Subscription & Loading
|
320
|
+
**/
|
209
321
|
subscribe(depth, listener) {
|
210
322
|
return subscribeToExistingCoValue(this, depth, listener);
|
211
323
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"coMap.js","sourceRoot":"","sources":["../../src/coValues/coMap.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAe/D,OAAO,EACH,OAAO,EACP,WAAW,EACX,GAAG,EACH,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AAC;QACxC,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,UAAU,EAAE,CAAC;YACxC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACxB,OAAO,IAAI,CAAC;QAChB,CAAC;aAAM,CAAC;YACJ,OAAO,OAAO,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAC/C,CAAC;IACL,CAAC;CACJ,CAAC"}
|
package/dist/coValues/group.js
CHANGED
@@ -33,7 +33,7 @@ export class Group extends CoValueBase {
|
|
33
33
|
const initOwner = options.owner;
|
34
34
|
if (!initOwner)
|
35
35
|
throw new Error("No owner provided");
|
36
|
-
if (initOwner
|
36
|
+
if (initOwner._type === "Account" &&
|
37
37
|
isControlledAccount(initOwner)) {
|
38
38
|
const rawOwner = initOwner._raw;
|
39
39
|
raw = rawOwner.createGroup();
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"group.js","sourceRoot":"","sources":["../../src/coValues/group.ts"],"names":[],"mappings":";AAYA,OAAO,EACH,OAAO,EACP,KAAK,EACL,WAAW,EACX,GAAG,EACH,EAAE,EACF,mBAAmB,EACnB,2BAA2B,EAC3B,UAAU,EACV,WAAW,EACX,aAAa,EACb,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,EACnB,0BAA0B,GAC7B,MAAM,gBAAgB,CAAC;AAGxB,uCAAuC;AACvC,MAAM,OAAO,OAAQ,SAAQ,KAAK;IAAlC;;QACI,SAAI,GAAG,EAAE,CAAC,MAAM,CAAC;IACrB,CAAC;CAAA;AAED,uCAAuC;AACvC,MAAM,OAAO,KAAM,SAAQ,WAAW;IAUlC,IAAI,OAAO;QAKP,OAAQ,IAAI,CAAC,WAA4B,CAAC,OAAO,CAAC;IACtD,CAAC;IAoBD,IAAI,KAAK;QACL,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,CAE1B,CAAC;QAChB,MAAM,MAAM,GAAG,IAAI,C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;QAC/B,8DAA8D;KAC1D,CAAC;IACT,MAAM,CAAC,cAAc,CAAC,GAAK,SAAS,EAAE,SAAS,EAAE;QAC7C,GAAG,EAAE,GAAG,EAAE,CAAC,GAAK,OAAO;KAC1B,CAAC,CAAC;AACP,CAAC,GAAA,CAAA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/coValues/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEtD,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC,OAAO,EACH,OAAO,EACP,UAAU,EACV,KAAK,EACL,iBAAiB,EACjB,GAAG,EACH,OAAO,EACP,mBAAmB,GACtB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAmCjD,8DAA8D;AAC9D,MAAM,UAAU,SAAS,CAAC,KAAU;IAChC,OAAO,KAAK,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS,CAAC;AAC9C,CAAC;AAED,MAAM,UAAU,cAAc;AAC1B,8DAA8D;AAC9D,KAAU;IAEV,OAAO,OAAO,KAAK,KAAK,UAAU,IAAI,KAAK,CAAC,OAAO,KAAK,SAAS,CAAC;AACtE,CAAC;AAOD,gBAAgB;AAChB,MAAM,OAAO,WAAW;
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/coValues/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEtD,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC,OAAO,EACH,OAAO,EACP,UAAU,EACV,KAAK,EACL,iBAAiB,EACjB,GAAG,EACH,OAAO,EACP,mBAAmB,GACtB,MAAM,gBAAgB,CA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AC7C,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;QACnB,MAAM,YAAY,GAAG,IAAI,iBAAiB,CACtC,KAAK,EACL,GAA0C,EAC1C,CAAC,MAAM,EAAE,EAAE,CAAC,KAAK,IAAI,CAAC,MAAM,CAAC,MAAW,CAAC,CAC5C,CAAC;QAEF,KAAK,CAAC,CAAC,CAAC,CACJ,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,CACrB,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,cAAc,EAAE,CAAC,CACnD,CACJ,CAAC;IACN,CAAC,CAAC,CACL,CACJ,EACD,MAAM,CAAC,SAAS,CAAC,CAAC,MAAS,EAAE,EAAE,CAC3B,MAAM,CAAC,YAAY,CACf,aAAa,CAAC,KAAK,EAAE,MAAM,CAAC;QACxB,CAAC,CAAE,MAAiC;QACpC,CAAC,CAAC,SAAS,CAClB,CACJ,CACJ,CAAC;AACN,CAAC"}
|
package/package.json
CHANGED
package/src/coValues/account.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { LocalNode } from "cojson";
|
1
|
+
import { LocalNode, cojsonInternals } from "cojson";
|
2
2
|
import type {
|
3
3
|
AgentSecret,
|
4
4
|
CoID,
|
@@ -214,6 +214,29 @@ export class Account extends CoValueBase implements CoValue {
|
|
214
214
|
return this.fromNode(node) as A;
|
215
215
|
}
|
216
216
|
|
217
|
+
static createAs<A extends Account>(
|
218
|
+
this: CoValueClass<A> & typeof Account,
|
219
|
+
as: Account,
|
220
|
+
options: {
|
221
|
+
creationProps: { name: string };
|
222
|
+
},
|
223
|
+
) {
|
224
|
+
// TODO: is there a cleaner way to do this?
|
225
|
+
const connectedPeers = cojsonInternals.connectedPeers(
|
226
|
+
"creatingAccount",
|
227
|
+
"createdAccount",
|
228
|
+
{ peer1role: "server", peer2role: "client" },
|
229
|
+
);
|
230
|
+
|
231
|
+
as._raw.core.node.syncManager.addPeer(connectedPeers[1]);
|
232
|
+
|
233
|
+
return this.create<A>({
|
234
|
+
creationProps: options.creationProps,
|
235
|
+
crypto: as._raw.core.node.crypto,
|
236
|
+
peersToLoadFrom: [connectedPeers[0]],
|
237
|
+
});
|
238
|
+
}
|
239
|
+
|
217
240
|
static fromNode<A extends Account>(
|
218
241
|
this: CoValueClass<A>,
|
219
242
|
node: LocalNode,
|
package/src/coValues/coList.ts
CHANGED
@@ -35,9 +35,40 @@ import {
|
|
35
35
|
import { encodeSync, decodeSync } from "@effect/schema/Schema";
|
36
36
|
import { Effect, Stream } from "effect";
|
37
37
|
|
38
|
-
/**
|
38
|
+
/**
|
39
|
+
* CoLists are collaborative versions of plain arrays.
|
40
|
+
*
|
41
|
+
* * @categoryDescription Content
|
42
|
+
* You can access items on a `CoList` as if they were normal items on a plain array, using `[]` notation, etc.
|
43
|
+
*
|
44
|
+
* Since `CoList` is a subclass of `Array`, you can use all the normal array methods like `push`, `pop`, `splice`, etc.
|
45
|
+
*
|
46
|
+
* ```ts
|
47
|
+
* colorList[0];
|
48
|
+
* colorList[3] = "yellow";
|
49
|
+
* colorList.push("Kawazaki Green");
|
50
|
+
* colorList.splice(1, 1);
|
51
|
+
* ```
|
52
|
+
*
|
53
|
+
* @category CoValues
|
54
|
+
*/
|
39
55
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
40
56
|
export class CoList<Item = any> extends Array<Item> implements CoValue {
|
57
|
+
/**
|
58
|
+
* Declare a `CoList` by subclassing `CoList.Of(...)` and passing the item schema using `co`.
|
59
|
+
*
|
60
|
+
* @example
|
61
|
+
* ```ts
|
62
|
+
* class ColorList extends CoList.Of(
|
63
|
+
* co.string
|
64
|
+
* ) {}
|
65
|
+
* class AnimalList extends CoList.Of(
|
66
|
+
* co.ref(Animal)
|
67
|
+
* ) {}
|
68
|
+
* ```
|
69
|
+
*
|
70
|
+
* @category Declaration
|
71
|
+
*/
|
41
72
|
static Of<Item>(item: Item): typeof CoList<Item> {
|
42
73
|
// TODO: cache superclass for item class
|
43
74
|
return class CoListOf extends CoList<Item> {
|
@@ -45,36 +76,62 @@ export class CoList<Item = any> extends Array<Item> implements CoValue {
|
|
45
76
|
};
|
46
77
|
}
|
47
78
|
|
48
|
-
/**
|
79
|
+
/**
|
80
|
+
* @ignore
|
81
|
+
* @deprecated Use UPPERCASE `CoList.Of` instead! */
|
49
82
|
static of(..._args: never): never {
|
50
83
|
throw new Error("Can't use Array.of with CoLists");
|
51
84
|
}
|
52
85
|
|
86
|
+
/**
|
87
|
+
* The ID of this `CoList`
|
88
|
+
* @category Content */
|
53
89
|
id!: ID<this>;
|
90
|
+
/** @category Type Helpers */
|
54
91
|
_type!: "CoList";
|
55
92
|
static {
|
56
93
|
this.prototype._type = "CoList";
|
57
94
|
}
|
95
|
+
/** @category Internals */
|
58
96
|
_raw!: RawCoList;
|
97
|
+
/** @category Internals */
|
59
98
|
_instanceID!: string;
|
60
99
|
|
61
100
|
/** @internal This is only a marker type and doesn't exist at runtime */
|
62
101
|
[ItemsSym]!: Item;
|
102
|
+
/** @internal */
|
63
103
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
64
104
|
static _schema: any;
|
105
|
+
/** @internal */
|
65
106
|
get _schema(): {
|
66
107
|
[ItemsSym]: SchemaFor<Item>;
|
67
108
|
} {
|
68
109
|
return (this.constructor as typeof CoList)._schema;
|
69
110
|
}
|
70
111
|
|
112
|
+
/** @category Collaboration */
|
71
113
|
get _owner(): Account | Group {
|
72
114
|
return this._raw.group instanceof RawAccount
|
73
115
|
? Account.fromRaw(this._raw.group)
|
74
116
|
: Group.fromRaw(this._raw.group);
|
75
117
|
}
|
76
118
|
|
77
|
-
/**
|
119
|
+
/**
|
120
|
+
* If a `CoList`'s items are a `co.ref(...)`, you can use `coList._refs[i]` to access
|
121
|
+
* the `Ref` instead of the potentially loaded/null value.
|
122
|
+
*
|
123
|
+
* This allows you to always get the ID or load the value manually.
|
124
|
+
*
|
125
|
+
* @example
|
126
|
+
* ```ts
|
127
|
+
* animals._refs[0].id; // => ID<Animal>
|
128
|
+
* animals._refs[0].value;
|
129
|
+
* // => Animal | null
|
130
|
+
* const animal = await animals._refs[0].load();
|
131
|
+
* ```
|
132
|
+
*
|
133
|
+
* @category Content
|
134
|
+
**/
|
78
135
|
get _refs(): {
|
79
136
|
[idx: number]: Exclude<Item, null> extends CoValue
|
80
137
|
? Ref<UnCo<Exclude<Item, null>>>
|
@@ -152,6 +209,27 @@ export class CoList<Item = any> extends Array<Item> implements CoValue {
|
|
152
209
|
return new Proxy(this, CoListProxyHandler as ProxyHandler<this>);
|
153
210
|
}
|
154
211
|
|
212
|
+
/**
|
213
|
+
* Create a new CoList with the given initial values and owner.
|
214
|
+
*
|
215
|
+
* The owner (a Group or Account) determines access rights to the CoMap.
|
216
|
+
*
|
217
|
+
* The CoList will immediately be persisted and synced to connected peers.
|
218
|
+
*
|
219
|
+
* @example
|
220
|
+
* ```ts
|
221
|
+
* const colours = ColorList.create(
|
222
|
+
* ["red", "green", "blue"],
|
223
|
+
* { owner: me }
|
224
|
+
* );
|
225
|
+
* const animals = AnimalList.create(
|
226
|
+
* [cat, dog, fish],
|
227
|
+
* { owner: me }
|
228
|
+
* );
|
229
|
+
* ```
|
230
|
+
*
|
231
|
+
* @category Creation
|
232
|
+
**/
|
155
233
|
static create<L extends CoList>(
|
156
234
|
this: CoValueClass<L>,
|
157
235
|
items: UnCo<L[number]>[],
|
@@ -160,9 +238,6 @@ export class CoList<Item = any> extends Array<Item> implements CoValue {
|
|
160
238
|
return new this({ init: items, owner: options.owner });
|
161
239
|
}
|
162
240
|
|
163
|
-
push(...items: Item[]): number;
|
164
|
-
/** @private For exact type compatibility with Array superclass */
|
165
|
-
push(...items: Item[]): number;
|
166
241
|
push(...items: Item[]): number {
|
167
242
|
for (const item of toRawItems(
|
168
243
|
items as Item[],
|
@@ -174,9 +249,6 @@ export class CoList<Item = any> extends Array<Item> implements CoValue {
|
|
174
249
|
return this._raw.entries().length;
|
175
250
|
}
|
176
251
|
|
177
|
-
unshift(...items: Item[]): number;
|
178
|
-
/** @private For exact type compatibility with Array superclass */
|
179
|
-
unshift(...items: Item[]): number;
|
180
252
|
unshift(...items: Item[]): number {
|
181
253
|
for (const item of toRawItems(
|
182
254
|
items as Item[],
|
@@ -247,6 +319,7 @@ export class CoList<Item = any> extends Array<Item> implements CoValue {
|
|
247
319
|
return this.toJSON();
|
248
320
|
}
|
249
321
|
|
322
|
+
/** @category Internals */
|
250
323
|
static fromRaw<V extends CoList>(
|
251
324
|
this: CoValueClass<V> & typeof CoList,
|
252
325
|
raw: RawCoList,
|
@@ -254,6 +327,7 @@ export class CoList<Item = any> extends Array<Item> implements CoValue {
|
|
254
327
|
return new this({ fromRaw: raw });
|
255
328
|
}
|
256
329
|
|
330
|
+
/** @internal */
|
257
331
|
static schema<V extends CoList>(
|
258
332
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
259
333
|
this: { new (...args: any): V } & typeof CoList,
|
@@ -263,7 +337,28 @@ export class CoList<Item = any> extends Array<Item> implements CoValue {
|
|
263
337
|
Object.assign(this._schema, def);
|
264
338
|
}
|
265
339
|
|
266
|
-
/**
|
340
|
+
/**
|
341
|
+
* Load a `CoList` with a given ID, as a given account.
|
342
|
+
*
|
343
|
+
* `depth` specifies if item CoValue references should be loaded as well before resolving.
|
344
|
+
* The `DeeplyLoaded` return type guarantees that corresponding referenced CoValues are loaded to the specified depth.
|
345
|
+
*
|
346
|
+
* You can pass `[]` or for shallowly loading only this CoList, or `[itemDepth]` for recursively loading referenced CoValues.
|
347
|
+
*
|
348
|
+
* Check out the `load` methods on `CoMap`/`CoList`/`CoStream`/`Group`/`Account` to see which depth structures are valid to nest.
|
349
|
+
*
|
350
|
+
* @example
|
351
|
+
* ```ts
|
352
|
+
* const animalsWithVets =
|
353
|
+
* await ListOfAnimals.load(
|
354
|
+
* "co_zdsMhHtfG6VNKt7RqPUPvUtN2Ax",
|
355
|
+
* me,
|
356
|
+
* [{ vet: {} }]
|
357
|
+
* );
|
358
|
+
* ```
|
359
|
+
*
|
360
|
+
* @category Subscription & Loading
|
361
|
+
*/
|
267
362
|
static load<L extends CoList, Depth>(
|
268
363
|
this: CoValueClass<L>,
|
269
364
|
id: ID<L>,
|
@@ -273,7 +368,13 @@ export class CoList<Item = any> extends Array<Item> implements CoValue {
|
|
273
368
|
return loadCoValue(this, id, as, depth);
|
274
369
|
}
|
275
370
|
|
276
|
-
/**
|
371
|
+
/**
|
372
|
+
* Effectful version of `CoList.load()`.
|
373
|
+
*
|
374
|
+
* Needs to be run inside an `AccountCtx` context.
|
375
|
+
*
|
376
|
+
* @category Subscription & Loading
|
377
|
+
*/
|
277
378
|
static loadEf<L extends CoList, Depth>(
|
278
379
|
this: CoValueClass<L>,
|
279
380
|
id: ID<L>,
|
@@ -282,7 +383,34 @@ export class CoList<Item = any> extends Array<Item> implements CoValue {
|
|
282
383
|
return loadCoValueEf<L, Depth>(this, id, depth);
|
283
384
|
}
|
284
385
|
|
285
|
-
/**
|
386
|
+
/**
|
387
|
+
* Load and subscribe to a `CoList` with a given ID, as a given account.
|
388
|
+
*
|
389
|
+
* Automatically also subscribes to updates to all referenced/nested CoValues as soon as they are accessed in the listener.
|
390
|
+
*
|
391
|
+
* `depth` specifies if item CoValue references should be loaded as well before calling `listener` for the first time.
|
392
|
+
* The `DeeplyLoaded` return type guarantees that corresponding referenced CoValues are loaded to the specified depth.
|
393
|
+
*
|
394
|
+
* You can pass `[]` or for shallowly loading only this CoList, or `[itemDepth]` for recursively loading referenced CoValues.
|
395
|
+
*
|
396
|
+
* Check out the `load` methods on `CoMap`/`CoList`/`CoStream`/`Group`/`Account` to see which depth structures are valid to nest.
|
397
|
+
*
|
398
|
+
* Returns an unsubscribe function that you should call when you no longer need updates.
|
399
|
+
*
|
400
|
+
* Also see the `useCoState` hook to reactively subscribe to a CoValue in a React component.
|
401
|
+
*
|
402
|
+
* @example
|
403
|
+
* ```ts
|
404
|
+
* const unsub = ListOfAnimals.subscribe(
|
405
|
+
* "co_zdsMhHtfG6VNKt7RqPUPvUtN2Ax",
|
406
|
+
* me,
|
407
|
+
* { vet: {} },
|
408
|
+
* (animalsWithVets) => console.log(animalsWithVets)
|
409
|
+
* );
|
410
|
+
* ```
|
411
|
+
*
|
412
|
+
* @category Subscription & Loading
|
413
|
+
*/
|
286
414
|
static subscribe<L extends CoList, Depth>(
|
287
415
|
this: CoValueClass<L>,
|
288
416
|
id: ID<L>,
|
@@ -293,7 +421,13 @@ export class CoList<Item = any> extends Array<Item> implements CoValue {
|
|
293
421
|
return subscribeToCoValue<L, Depth>(this, id, as, depth, listener);
|
294
422
|
}
|
295
423
|
|
296
|
-
/**
|
424
|
+
/**
|
425
|
+
* Effectful version of `CoList.subscribe()` that returns a stream of updates.
|
426
|
+
*
|
427
|
+
* Needs to be run inside an `AccountCtx` context.
|
428
|
+
*
|
429
|
+
* @category Subscription & Loading
|
430
|
+
*/
|
297
431
|
static subscribeEf<L extends CoList, Depth>(
|
298
432
|
this: CoValueClass<L>,
|
299
433
|
id: ID<L>,
|
@@ -302,7 +436,13 @@ export class CoList<Item = any> extends Array<Item> implements CoValue {
|
|
302
436
|
return subscribeToCoValueEf<L, Depth>(this, id, depth);
|
303
437
|
}
|
304
438
|
|
305
|
-
/**
|
439
|
+
/**
|
440
|
+
* Given an already loaded `CoList`, ensure that items are loaded to the specified depth.
|
441
|
+
*
|
442
|
+
* Works like `CoList.load()`, but you don't need to pass the ID or the account to load as again.
|
443
|
+
*
|
444
|
+
* @category Subscription & Loading
|
445
|
+
*/
|
306
446
|
ensureLoaded<L extends CoList, Depth>(
|
307
447
|
this: L,
|
308
448
|
depth: Depth & DepthsIn<L>,
|
@@ -310,7 +450,15 @@ export class CoList<Item = any> extends Array<Item> implements CoValue {
|
|
310
450
|
return ensureCoValueLoaded(this, depth);
|
311
451
|
}
|
312
452
|
|
313
|
-
/**
|
453
|
+
/**
|
454
|
+
* Given an already loaded `CoList`, subscribe to updates to the `CoList` and ensure that items are loaded to the specified depth.
|
455
|
+
*
|
456
|
+
* Works like `CoList.subscribe()`, but you don't need to pass the ID or the account to load as again.
|
457
|
+
*
|
458
|
+
* Returns an unsubscribe function that you should call when you no longer need updates.
|
459
|
+
*
|
460
|
+
* @category Subscription & Loading
|
461
|
+
**/
|
314
462
|
subscribe<L extends CoList, Depth>(
|
315
463
|
this: L,
|
316
464
|
depth: Depth & DepthsIn<L>,
|
package/src/coValues/coMap.ts
CHANGED
@@ -53,6 +53,8 @@ type InitValuesFor<C extends CoMap> = {
|
|
53
53
|
* @categoryDescription Declaration
|
54
54
|
* Declare your own CoMap schemas by subclassing `CoMap` and assigning field schemas with `co`.
|
55
55
|
*
|
56
|
+
* Optional `co.ref(...)` fields must be marked with `{ optional: true }`.
|
57
|
+
*
|
56
58
|
* ```ts
|
57
59
|
* import { co, CoMap } from "jazz-tools";
|
58
60
|
*
|
@@ -60,6 +62,7 @@ type InitValuesFor<C extends CoMap> = {
|
|
60
62
|
* name = co.string;
|
61
63
|
* age = co.number;
|
62
64
|
* pet = co.ref(Animal);
|
65
|
+
* car = co.ref(Car, { optional: true });
|
63
66
|
* }
|
64
67
|
* ```
|
65
68
|
*
|
@@ -103,17 +106,19 @@ export class CoMap extends CoValueBase implements CoValue {
|
|
103
106
|
/**
|
104
107
|
* If property `prop` is a `co.ref(...)`, you can use `coMaps._refs.prop` to access
|
105
108
|
* the `Ref` instead of the potentially loaded/null value.
|
109
|
+
*
|
106
110
|
* This allows you to always get the ID or load the value manually.
|
107
111
|
*
|
108
112
|
* @example
|
109
113
|
* ```ts
|
110
114
|
* person._refs.pet.id; // => ID<Animal>
|
111
115
|
* person._refs.pet.value;
|
112
|
-
* // => Animal |
|
116
|
+
* // => Animal | null
|
113
117
|
* const pet = await person._refs.pet.load();
|
114
118
|
* ```
|
115
119
|
*
|
116
|
-
* @category Content
|
120
|
+
* @category Content
|
121
|
+
**/
|
117
122
|
get _refs(): {
|
118
123
|
[Key in CoKeys<this>]: IfCo<this[Key], RefIfCoValue<this[Key]>>;
|
119
124
|
} {
|
@@ -227,7 +232,24 @@ export class CoMap extends CoValueBase implements CoValue {
|
|
227
232
|
return new Proxy(this, CoMapProxyHandler as ProxyHandler<this>);
|
228
233
|
}
|
229
234
|
|
230
|
-
/**
|
235
|
+
/**
|
236
|
+
* Create a new CoMap with the given initial values and owner.
|
237
|
+
*
|
238
|
+
* The owner (a Group or Account) determines access rights to the CoMap.
|
239
|
+
*
|
240
|
+
* The CoMap will immediately be persisted and synced to connected peers.
|
241
|
+
*
|
242
|
+
* @example
|
243
|
+
* ```ts
|
244
|
+
* const person = Person.create({
|
245
|
+
* name: "Alice",
|
246
|
+
* age: 42,
|
247
|
+
* pet: cat,
|
248
|
+
* }, { owner: friendGroup });
|
249
|
+
* ```
|
250
|
+
*
|
251
|
+
* @category Creation
|
252
|
+
**/
|
231
253
|
static create<M extends CoMap>(
|
232
254
|
this: CoValueClass<M>,
|
233
255
|
init: Simplify<CoMapInit<M>>,
|
@@ -301,7 +323,24 @@ export class CoMap extends CoValueBase implements CoValue {
|
|
301
323
|
return rawOwner.createMap(rawInit);
|
302
324
|
}
|
303
325
|
|
304
|
-
/**
|
326
|
+
/**
|
327
|
+
* Declare a Record-like CoMap schema, by extending `CoMap.Record(...)` and passing the value schema using `co`. Keys are always `string`.
|
328
|
+
*
|
329
|
+
* @example
|
330
|
+
* ```ts
|
331
|
+
* import { co, CoMap } from "jazz-tools";
|
332
|
+
*
|
333
|
+
* class ColorToFruitMap extends CoMap.Record(
|
334
|
+
* co.ref(Fruit)
|
335
|
+
* ) {}
|
336
|
+
*
|
337
|
+
* // assume we have map: ColorToFruitMap
|
338
|
+
* // and strawberry: Fruit
|
339
|
+
* map["red"] = strawberry;
|
340
|
+
* ```
|
341
|
+
*
|
342
|
+
* @category Declaration
|
343
|
+
*/
|
305
344
|
static Record<Value>(value: IfCo<Value, Value>) {
|
306
345
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
|
307
346
|
class RecordLikeCoMap extends CoMap {
|
@@ -313,7 +352,27 @@ export class CoMap extends CoValueBase implements CoValue {
|
|
313
352
|
return RecordLikeCoMap;
|
314
353
|
}
|
315
354
|
|
316
|
-
/**
|
355
|
+
/**
|
356
|
+
* Load a `CoMap` with a given ID, as a given account.
|
357
|
+
*
|
358
|
+
* `depth` specifies which (if any) fields that reference other CoValues to load as well before resolving.
|
359
|
+
* The `DeeplyLoaded` return type guarantees that corresponding referenced CoValues are loaded to the specified depth.
|
360
|
+
*
|
361
|
+
* You can pass `[]` or `{}` for shallowly loading only this CoMap, or `{ fieldA: depthA, fieldB: depthB }` for recursively loading referenced CoValues.
|
362
|
+
*
|
363
|
+
* Check out the `load` methods on `CoMap`/`CoList`/`CoStream`/`Group`/`Account` to see which depth structures are valid to nest.
|
364
|
+
*
|
365
|
+
* @example
|
366
|
+
* ```ts
|
367
|
+
* const person = await Person.load(
|
368
|
+
* "co_zdsMhHtfG6VNKt7RqPUPvUtN2Ax",
|
369
|
+
* me,
|
370
|
+
* { pet: {} }
|
371
|
+
* );
|
372
|
+
* ```
|
373
|
+
*
|
374
|
+
* @category Subscription & Loading
|
375
|
+
*/
|
317
376
|
static load<M extends CoMap, Depth>(
|
318
377
|
this: CoValueClass<M>,
|
319
378
|
id: ID<M>,
|
@@ -323,7 +382,13 @@ export class CoMap extends CoValueBase implements CoValue {
|
|
323
382
|
return loadCoValue(this, id, as, depth);
|
324
383
|
}
|
325
384
|
|
326
|
-
/**
|
385
|
+
/**
|
386
|
+
* Effectful version of `CoMap.load()`.
|
387
|
+
*
|
388
|
+
* Needs to be run inside an `AccountCtx` context.
|
389
|
+
*
|
390
|
+
* @category Subscription & Loading
|
391
|
+
*/
|
327
392
|
static loadEf<M extends CoMap, Depth>(
|
328
393
|
this: CoValueClass<M>,
|
329
394
|
id: ID<M>,
|
@@ -332,7 +397,34 @@ export class CoMap extends CoValueBase implements CoValue {
|
|
332
397
|
return loadCoValueEf<M, Depth>(this, id, depth);
|
333
398
|
}
|
334
399
|
|
335
|
-
/**
|
400
|
+
/**
|
401
|
+
* Load and subscribe to a `CoMap` with a given ID, as a given account.
|
402
|
+
*
|
403
|
+
* Automatically also subscribes to updates to all referenced/nested CoValues as soon as they are accessed in the listener.
|
404
|
+
*
|
405
|
+
* `depth` specifies which (if any) fields that reference other CoValues to load as well before calling `listener` for the first time.
|
406
|
+
* The `DeeplyLoaded` return type guarantees that corresponding referenced CoValues are loaded to the specified depth.
|
407
|
+
*
|
408
|
+
* You can pass `[]` or `{}` for shallowly loading only this CoMap, or `{ fieldA: depthA, fieldB: depthB }` for recursively loading referenced CoValues.
|
409
|
+
*
|
410
|
+
* Check out the `load` methods on `CoMap`/`CoList`/`CoStream`/`Group`/`Account` to see which depth structures are valid to nest.
|
411
|
+
*
|
412
|
+
* Returns an unsubscribe function that you should call when you no longer need updates.
|
413
|
+
*
|
414
|
+
* Also see the `useCoState` hook to reactively subscribe to a CoValue in a React component.
|
415
|
+
*
|
416
|
+
* @example
|
417
|
+
* ```ts
|
418
|
+
* const unsub = Person.subscribe(
|
419
|
+
* "co_zdsMhHtfG6VNKt7RqPUPvUtN2Ax",
|
420
|
+
* me,
|
421
|
+
* { pet: {} },
|
422
|
+
* (person) => console.log(person)
|
423
|
+
* );
|
424
|
+
* ```
|
425
|
+
*
|
426
|
+
* @category Subscription & Loading
|
427
|
+
*/
|
336
428
|
static subscribe<M extends CoMap, Depth>(
|
337
429
|
this: CoValueClass<M>,
|
338
430
|
id: ID<M>,
|
@@ -343,7 +435,13 @@ export class CoMap extends CoValueBase implements CoValue {
|
|
343
435
|
return subscribeToCoValue<M, Depth>(this, id, as, depth, listener);
|
344
436
|
}
|
345
437
|
|
346
|
-
/**
|
438
|
+
/**
|
439
|
+
* Effectful version of `CoMap.subscribe()` that returns a stream of updates.
|
440
|
+
*
|
441
|
+
* Needs to be run inside an `AccountCtx` context.
|
442
|
+
*
|
443
|
+
* @category Subscription & Loading
|
444
|
+
*/
|
347
445
|
static subscribeEf<M extends CoMap, Depth>(
|
348
446
|
this: CoValueClass<M>,
|
349
447
|
id: ID<M>,
|
@@ -352,7 +450,13 @@ export class CoMap extends CoValueBase implements CoValue {
|
|
352
450
|
return subscribeToCoValueEf<M, Depth>(this, id, depth);
|
353
451
|
}
|
354
452
|
|
355
|
-
/**
|
453
|
+
/**
|
454
|
+
* Given an already loaded `CoMap`, ensure that the specified fields are loaded to the specified depth.
|
455
|
+
*
|
456
|
+
* Works like `CoMap.load()`, but you don't need to pass the ID or the account to load as again.
|
457
|
+
*
|
458
|
+
* @category Subscription & Loading
|
459
|
+
*/
|
356
460
|
ensureLoaded<M extends CoMap, Depth>(
|
357
461
|
this: M,
|
358
462
|
depth: Depth & DepthsIn<M>,
|
@@ -360,7 +464,15 @@ export class CoMap extends CoValueBase implements CoValue {
|
|
360
464
|
return ensureCoValueLoaded(this, depth);
|
361
465
|
}
|
362
466
|
|
363
|
-
/**
|
467
|
+
/**
|
468
|
+
* Given an already loaded `CoMap`, subscribe to updates to the `CoMap` and ensure that the specified fields are loaded to the specified depth.
|
469
|
+
*
|
470
|
+
* Works like `CoMap.subscribe()`, but you don't need to pass the ID or the account to load as again.
|
471
|
+
*
|
472
|
+
* Returns an unsubscribe function that you should call when you no longer need updates.
|
473
|
+
*
|
474
|
+
* @category Subscription & Loading
|
475
|
+
**/
|
364
476
|
subscribe<M extends CoMap, Depth>(
|
365
477
|
this: M,
|
366
478
|
depth: Depth & DepthsIn<M>,
|
package/src/coValues/group.ts
CHANGED
@@ -114,7 +114,7 @@ export class Group extends CoValueBase implements CoValue {
|
|
114
114
|
const initOwner = options.owner;
|
115
115
|
if (!initOwner) throw new Error("No owner provided");
|
116
116
|
if (
|
117
|
-
initOwner
|
117
|
+
initOwner._type === "Account" &&
|
118
118
|
isControlledAccount(initOwner)
|
119
119
|
) {
|
120
120
|
const rawOwner = initOwner._raw;
|