jazz-tools 0.8.2 → 0.8.3
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +7 -0
- package/dist/native/coValues/account.js.map +1 -0
- package/dist/native/coValues/coList.js.map +1 -0
- package/dist/native/coValues/coMap.js.map +1 -0
- package/dist/{coValues → native/coValues}/coStream.js +1 -0
- package/dist/native/coValues/coStream.js.map +1 -0
- package/dist/native/coValues/deepLoading.js.map +1 -0
- package/dist/native/coValues/extensions/imageDef.js.map +1 -0
- package/dist/native/coValues/group.js.map +1 -0
- package/dist/native/coValues/interfaces.js.map +1 -0
- package/dist/{implementation → native/implementation}/createContext.js +8 -1
- package/dist/native/implementation/createContext.js.map +1 -0
- package/dist/native/implementation/devtoolsFormatters.js.map +1 -0
- package/dist/{implementation → native/implementation}/errors.js.map +1 -1
- package/dist/native/implementation/inspect.js.map +1 -0
- package/dist/native/implementation/refs.js.map +1 -0
- package/dist/native/implementation/schema.js.map +1 -0
- package/dist/native/implementation/subscriptionScope.js.map +1 -0
- package/dist/native/implementation/symbols.js.map +1 -0
- package/dist/native/index.native.js +12 -0
- package/dist/native/index.native.js.map +1 -0
- package/dist/native/internal.js.map +1 -0
- package/dist/web/coValues/account.js +208 -0
- package/dist/web/coValues/account.js.map +1 -0
- package/dist/web/coValues/coList.js +395 -0
- package/dist/web/coValues/coList.js.map +1 -0
- package/dist/web/coValues/coMap.js +501 -0
- package/dist/web/coValues/coMap.js.map +1 -0
- package/dist/web/coValues/coStream.js +413 -0
- package/dist/web/coValues/coStream.js.map +1 -0
- package/dist/web/coValues/deepLoading.js +60 -0
- package/dist/web/coValues/deepLoading.js.map +1 -0
- package/dist/web/coValues/extensions/imageDef.js +37 -0
- package/dist/web/coValues/extensions/imageDef.js.map +1 -0
- package/dist/web/coValues/group.js +120 -0
- package/dist/web/coValues/group.js.map +1 -0
- package/dist/web/coValues/interfaces.js +109 -0
- package/dist/web/coValues/interfaces.js.map +1 -0
- package/dist/web/implementation/createContext.js +151 -0
- package/dist/web/implementation/createContext.js.map +1 -0
- package/dist/web/implementation/devtoolsFormatters.js +115 -0
- package/dist/web/implementation/devtoolsFormatters.js.map +1 -0
- package/dist/web/implementation/errors.js +2 -0
- package/dist/web/implementation/errors.js.map +1 -0
- package/dist/web/implementation/inspect.js +2 -0
- package/dist/web/implementation/inspect.js.map +1 -0
- package/dist/web/implementation/refs.js +127 -0
- package/dist/web/implementation/refs.js.map +1 -0
- package/dist/web/implementation/schema.js +91 -0
- package/dist/web/implementation/schema.js.map +1 -0
- package/dist/web/implementation/subscriptionScope.js +97 -0
- package/dist/web/implementation/subscriptionScope.js.map +1 -0
- package/dist/web/implementation/symbols.js +4 -0
- package/dist/web/implementation/symbols.js.map +1 -0
- package/dist/{index.js → web/index.web.js} +3 -3
- package/dist/{index.js.map → web/index.web.js.map} +1 -1
- package/dist/web/internal.js +17 -0
- package/dist/web/internal.js.map +1 -0
- package/package.json +25 -7
- package/src/coValues/account.ts +4 -1
- package/src/coValues/coStream.ts +26 -4
- package/src/coValues/group.ts +4 -1
- package/src/implementation/createContext.ts +12 -10
- package/src/{index.ts → index.native.ts} +2 -3
- package/src/index.web.ts +36 -0
- package/src/tests/coList.test.ts +2 -2
- package/src/tests/coMap.test.ts +11 -9
- package/src/tests/coStream.test.ts +2 -2
- package/src/tests/deepLoading.test.ts +2 -2
- package/src/tests/groupsAndAccounts.test.ts +1 -1
- package/tsconfig.json +5 -4
- package/tsconfig.native.json +11 -0
- package/tsconfig.web.json +11 -0
- package/dist/coValues/account.js.map +0 -1
- package/dist/coValues/coList.js.map +0 -1
- package/dist/coValues/coMap.js.map +0 -1
- package/dist/coValues/coStream.js.map +0 -1
- package/dist/coValues/deepLoading.js.map +0 -1
- package/dist/coValues/extensions/imageDef.js.map +0 -1
- package/dist/coValues/group.js.map +0 -1
- package/dist/coValues/interfaces.js.map +0 -1
- package/dist/implementation/createContext.js.map +0 -1
- package/dist/implementation/devtoolsFormatters.js.map +0 -1
- package/dist/implementation/inspect.js.map +0 -1
- package/dist/implementation/refs.js.map +0 -1
- package/dist/implementation/schema.js.map +0 -1
- package/dist/implementation/subscriptionScope.js.map +0 -1
- package/dist/implementation/symbols.js.map +0 -1
- package/dist/internal.js.map +0 -1
- package/dist/tests/coList.test.js +0 -221
- package/dist/tests/coList.test.js.map +0 -1
- package/dist/tests/coMap.test.js +0 -615
- package/dist/tests/coMap.test.js.map +0 -1
- package/dist/tests/coStream.test.js +0 -324
- package/dist/tests/coStream.test.js.map +0 -1
- package/dist/tests/deepLoading.test.js +0 -175
- package/dist/tests/deepLoading.test.js.map +0 -1
- package/dist/tests/groupsAndAccounts.test.js +0 -69
- package/dist/tests/groupsAndAccounts.test.js.map +0 -1
- /package/dist/{coValues → native/coValues}/account.js +0 -0
- /package/dist/{coValues → native/coValues}/coList.js +0 -0
- /package/dist/{coValues → native/coValues}/coMap.js +0 -0
- /package/dist/{coValues → native/coValues}/deepLoading.js +0 -0
- /package/dist/{coValues → native/coValues}/extensions/imageDef.js +0 -0
- /package/dist/{coValues → native/coValues}/group.js +0 -0
- /package/dist/{coValues → native/coValues}/interfaces.js +0 -0
- /package/dist/{implementation → native/implementation}/devtoolsFormatters.js +0 -0
- /package/dist/{implementation → native/implementation}/errors.js +0 -0
- /package/dist/{implementation → native/implementation}/inspect.js +0 -0
- /package/dist/{implementation → native/implementation}/refs.js +0 -0
- /package/dist/{implementation → native/implementation}/schema.js +0 -0
- /package/dist/{implementation → native/implementation}/subscriptionScope.js +0 -0
- /package/dist/{implementation → native/implementation}/symbols.js +0 -0
- /package/dist/{internal.js → native/internal.js} +0 -0
@@ -1,324 +0,0 @@
|
|
1
|
-
import { expect, describe, test } from "vitest";
|
2
|
-
import { connectedPeers } from "cojson/src/streamUtils.js";
|
3
|
-
import { BinaryCoStream, Account, CoStream, co, WasmCrypto, isControlledAccount, cojsonInternals, createJazzContext, fixedCredentialsAuth, } from "../index.js";
|
4
|
-
import { randomSessionProvider } from "../internal.js";
|
5
|
-
const Crypto = await WasmCrypto.create();
|
6
|
-
describe("Simple CoStream operations", async () => {
|
7
|
-
const me = await Account.create({
|
8
|
-
creationProps: { name: "Hermes Puggington" },
|
9
|
-
crypto: Crypto,
|
10
|
-
});
|
11
|
-
if (!isControlledAccount(me)) {
|
12
|
-
throw "me is not a controlled account";
|
13
|
-
}
|
14
|
-
class TestStream extends CoStream.Of(co.string) {
|
15
|
-
}
|
16
|
-
const stream = TestStream.create(["milk"], { owner: me });
|
17
|
-
test("Construction", () => {
|
18
|
-
expect(stream[me.id]?.value).toEqual("milk");
|
19
|
-
expect(stream.perSession[me.sessionID]?.value).toEqual("milk");
|
20
|
-
});
|
21
|
-
describe("Mutation", () => {
|
22
|
-
test("pushing", () => {
|
23
|
-
stream.push("bread");
|
24
|
-
expect(stream[me.id]?.value).toEqual("bread");
|
25
|
-
expect(stream.perSession[me.sessionID]?.value).toEqual("bread");
|
26
|
-
stream.push("butter");
|
27
|
-
expect(stream[me.id]?.value).toEqual("butter");
|
28
|
-
expect(stream.perSession[me.sessionID]?.value).toEqual("butter");
|
29
|
-
});
|
30
|
-
});
|
31
|
-
});
|
32
|
-
describe("CoStream resolution", async () => {
|
33
|
-
class TwiceNestedStream extends CoStream.Of(co.string) {
|
34
|
-
fancyValueOf(account) {
|
35
|
-
return "Sir " + this[account]?.value;
|
36
|
-
}
|
37
|
-
}
|
38
|
-
class NestedStream extends CoStream.Of(co.ref(TwiceNestedStream)) {
|
39
|
-
}
|
40
|
-
class TestStream extends CoStream.Of(co.ref(NestedStream)) {
|
41
|
-
}
|
42
|
-
const initNodeAndStream = async () => {
|
43
|
-
const me = await Account.create({
|
44
|
-
creationProps: { name: "Hermes Puggington" },
|
45
|
-
crypto: Crypto,
|
46
|
-
});
|
47
|
-
const stream = TestStream.create([
|
48
|
-
NestedStream.create([TwiceNestedStream.create(["milk"], { owner: me })], { owner: me }),
|
49
|
-
], { owner: me });
|
50
|
-
return { me, stream };
|
51
|
-
};
|
52
|
-
test("Construction", async () => {
|
53
|
-
const { me, stream } = await initNodeAndStream();
|
54
|
-
expect(stream[me.id]?.value?.[me.id]?.value?.[me.id]?.value).toEqual("milk");
|
55
|
-
});
|
56
|
-
test("Loading and availability", async () => {
|
57
|
-
const { me, stream } = await initNodeAndStream();
|
58
|
-
const [initialAsPeer, secondPeer] = connectedPeers("initial", "second", {
|
59
|
-
peer1role: "server",
|
60
|
-
peer2role: "client",
|
61
|
-
});
|
62
|
-
if (!isControlledAccount(me)) {
|
63
|
-
throw "me is not a controlled account";
|
64
|
-
}
|
65
|
-
me._raw.core.node.syncManager.addPeer(secondPeer);
|
66
|
-
const { account: meOnSecondPeer } = await createJazzContext({
|
67
|
-
auth: fixedCredentialsAuth({
|
68
|
-
accountID: me.id,
|
69
|
-
secret: me._raw.agentSecret,
|
70
|
-
}),
|
71
|
-
sessionProvider: randomSessionProvider,
|
72
|
-
peersToLoadFrom: [initialAsPeer],
|
73
|
-
crypto: Crypto,
|
74
|
-
});
|
75
|
-
const loadedStream = await TestStream.load(stream.id, meOnSecondPeer, []);
|
76
|
-
expect(loadedStream?.[me.id]?.value).toEqual(null);
|
77
|
-
expect(loadedStream?.[me.id]?.ref?.id).toEqual(stream[me.id]?.value?.id);
|
78
|
-
const loadedNestedStream = await NestedStream.load(stream[me.id].value.id, meOnSecondPeer, []);
|
79
|
-
// expect(loadedStream?.[me.id]?.value).toEqual(loadedNestedStream);
|
80
|
-
expect(loadedStream?.[me.id]?.value?.id).toEqual(loadedNestedStream?.id);
|
81
|
-
expect(loadedStream?.[me.id]?.value?.[me.id]?.value).toEqual(null);
|
82
|
-
// expect(loadedStream?.[me.id]?.ref?.value).toEqual(loadedNestedStream);
|
83
|
-
expect(loadedStream?.[me.id]?.ref?.value?.id).toEqual(loadedNestedStream?.id);
|
84
|
-
expect(loadedStream?.[me.id]?.value?.[me.id]?.ref?.id).toEqual(stream[me.id]?.value?.[me.id]?.value?.id);
|
85
|
-
const loadedTwiceNestedStream = await TwiceNestedStream.load(stream[me.id].value[me.id].value.id, meOnSecondPeer, []);
|
86
|
-
// expect(loadedStream?.[me.id]?.value?.[me.id]?.value).toEqual(
|
87
|
-
// loadedTwiceNestedStream
|
88
|
-
// );
|
89
|
-
expect(loadedStream?.[me.id]?.value?.[me.id]?.value?.id).toEqual(loadedTwiceNestedStream?.id);
|
90
|
-
expect(loadedStream?.[me.id]?.value?.[me.id]?.value?.fancyValueOf(me.id)).toEqual("Sir milk");
|
91
|
-
// expect(loadedStream?.[me.id]?.ref?.value).toEqual(loadedNestedStream);
|
92
|
-
expect(loadedStream?.[me.id]?.ref?.value?.id).toEqual(loadedNestedStream?.id);
|
93
|
-
expect(loadedStream?.[me.id]?.value?.[me.id]?.ref?.value?.id).toEqual(loadedTwiceNestedStream?.id);
|
94
|
-
const otherNestedStream = NestedStream.create([TwiceNestedStream.create(["butter"], { owner: meOnSecondPeer })], { owner: meOnSecondPeer });
|
95
|
-
loadedStream?.push(otherNestedStream);
|
96
|
-
// expect(loadedStream?.[me.id]?.value).toEqual(otherNestedStream);
|
97
|
-
expect(loadedStream?.[me.id]?.value?.id).toEqual(otherNestedStream?.id);
|
98
|
-
expect(loadedStream?.[me.id]?.ref?.value?.id).toEqual(otherNestedStream?.id);
|
99
|
-
expect(loadedStream?.[me.id]?.value?.[me.id]?.value?.id).toEqual(otherNestedStream[me.id]?.value?.id);
|
100
|
-
expect(loadedStream?.[me.id]?.value?.[me.id]?.value?.fancyValueOf(me.id)).toEqual("Sir butter");
|
101
|
-
});
|
102
|
-
test("Subscription & auto-resolution", async () => {
|
103
|
-
const { me, stream } = await initNodeAndStream();
|
104
|
-
const [initialAsPeer, secondAsPeer] = connectedPeers("initial", "second", {
|
105
|
-
peer1role: "server",
|
106
|
-
peer2role: "client",
|
107
|
-
});
|
108
|
-
me._raw.core.node.syncManager.addPeer(secondAsPeer);
|
109
|
-
if (!isControlledAccount(me)) {
|
110
|
-
throw "me is not a controlled account";
|
111
|
-
}
|
112
|
-
const { account: meOnSecondPeer } = await createJazzContext({
|
113
|
-
auth: fixedCredentialsAuth({
|
114
|
-
accountID: me.id,
|
115
|
-
secret: me._raw.agentSecret,
|
116
|
-
}),
|
117
|
-
sessionProvider: randomSessionProvider,
|
118
|
-
peersToLoadFrom: [initialAsPeer],
|
119
|
-
crypto: Crypto,
|
120
|
-
});
|
121
|
-
const queue = new cojsonInternals.Channel();
|
122
|
-
TestStream.subscribe(stream.id, meOnSecondPeer, [], (subscribedStream) => {
|
123
|
-
console.log("subscribedStream[me.id]", subscribedStream[me.id]);
|
124
|
-
console.log("subscribedStream[me.id]?.value?.[me.id]?.value", subscribedStream[me.id]?.value?.[me.id]?.value);
|
125
|
-
console.log("subscribedStream[me.id]?.value?.[me.id]?.value?.[me.id]?.value", subscribedStream[me.id]?.value?.[me.id]?.value?.[me.id]
|
126
|
-
?.value);
|
127
|
-
void queue.push(subscribedStream);
|
128
|
-
});
|
129
|
-
const update1 = (await queue.next()).value;
|
130
|
-
expect(update1[me.id]?.value).toEqual(null);
|
131
|
-
const update2 = (await queue.next()).value;
|
132
|
-
expect(update2[me.id]?.value).toBeDefined();
|
133
|
-
expect(update2[me.id]?.value?.[me.id]?.value).toBe(null);
|
134
|
-
const update3 = (await queue.next()).value;
|
135
|
-
expect(update3[me.id]?.value?.[me.id]?.value).toBeDefined();
|
136
|
-
expect(update3[me.id]?.value?.[me.id]?.value?.[me.id]?.value).toBe("milk");
|
137
|
-
update3[me.id].value[me.id].value.push("bread");
|
138
|
-
const update4 = (await queue.next()).value;
|
139
|
-
expect(update4[me.id]?.value?.[me.id]?.value?.[me.id]?.value).toBe("bread");
|
140
|
-
// When assigning a new nested stream, we get an update
|
141
|
-
const newTwiceNested = TwiceNestedStream.create(["butter"], {
|
142
|
-
owner: meOnSecondPeer,
|
143
|
-
});
|
144
|
-
const newNested = NestedStream.create([newTwiceNested], {
|
145
|
-
owner: meOnSecondPeer,
|
146
|
-
});
|
147
|
-
update4.push(newNested);
|
148
|
-
const update5 = (await queue.next()).value;
|
149
|
-
expect(update5[me.id]?.value?.[me.id]?.value?.[me.id]?.value).toBe("butter");
|
150
|
-
// we get updates when the new nested stream changes
|
151
|
-
newTwiceNested.push("jam");
|
152
|
-
const update6 = (await queue.next()).value;
|
153
|
-
expect(update6[me.id]?.value?.[me.id]?.value?.[me.id]?.value).toBe("jam");
|
154
|
-
});
|
155
|
-
});
|
156
|
-
describe("Simple BinaryCoStream operations", async () => {
|
157
|
-
const me = await Account.create({
|
158
|
-
creationProps: { name: "Hermes Puggington" },
|
159
|
-
crypto: Crypto,
|
160
|
-
});
|
161
|
-
const stream = BinaryCoStream.create({ owner: me });
|
162
|
-
test("Construction", () => {
|
163
|
-
expect(stream.getChunks()).toBe(undefined);
|
164
|
-
});
|
165
|
-
test("Mutation", () => {
|
166
|
-
stream.start({ mimeType: "text/plain" });
|
167
|
-
stream.push(new Uint8Array([1, 2, 3]));
|
168
|
-
stream.push(new Uint8Array([4, 5, 6]));
|
169
|
-
stream.end();
|
170
|
-
const chunks = stream.getChunks();
|
171
|
-
expect(chunks?.mimeType).toBe("text/plain");
|
172
|
-
expect(chunks?.chunks).toEqual([
|
173
|
-
new Uint8Array([1, 2, 3]),
|
174
|
-
new Uint8Array([4, 5, 6]),
|
175
|
-
]);
|
176
|
-
expect(chunks?.finished).toBe(true);
|
177
|
-
});
|
178
|
-
});
|
179
|
-
describe("BinaryCoStream loading & Subscription", async () => {
|
180
|
-
const initNodeAndStream = async () => {
|
181
|
-
const me = await Account.create({
|
182
|
-
creationProps: { name: "Hermes Puggington" },
|
183
|
-
crypto: Crypto,
|
184
|
-
});
|
185
|
-
const stream = BinaryCoStream.create({ owner: me });
|
186
|
-
stream.start({ mimeType: "text/plain" });
|
187
|
-
stream.push(new Uint8Array([1, 2, 3]));
|
188
|
-
stream.push(new Uint8Array([4, 5, 6]));
|
189
|
-
stream.end();
|
190
|
-
return { me, stream };
|
191
|
-
};
|
192
|
-
test("Construction", async () => {
|
193
|
-
const { stream } = await initNodeAndStream();
|
194
|
-
expect(stream.getChunks()).toEqual({
|
195
|
-
mimeType: "text/plain",
|
196
|
-
chunks: [new Uint8Array([1, 2, 3]), new Uint8Array([4, 5, 6])],
|
197
|
-
finished: true,
|
198
|
-
});
|
199
|
-
});
|
200
|
-
test("Loading and availability", async () => {
|
201
|
-
const { me, stream } = await initNodeAndStream();
|
202
|
-
const [initialAsPeer, secondAsPeer] = connectedPeers("initial", "second", {
|
203
|
-
peer1role: "server",
|
204
|
-
peer2role: "client",
|
205
|
-
});
|
206
|
-
if (!isControlledAccount(me)) {
|
207
|
-
throw "me is not a controlled account";
|
208
|
-
}
|
209
|
-
me._raw.core.node.syncManager.addPeer(secondAsPeer);
|
210
|
-
const { account: meOnSecondPeer } = await createJazzContext({
|
211
|
-
auth: fixedCredentialsAuth({
|
212
|
-
accountID: me.id,
|
213
|
-
secret: me._raw.agentSecret,
|
214
|
-
}),
|
215
|
-
sessionProvider: randomSessionProvider,
|
216
|
-
peersToLoadFrom: [initialAsPeer],
|
217
|
-
crypto: Crypto,
|
218
|
-
});
|
219
|
-
const loadedStream = await BinaryCoStream.load(stream.id, meOnSecondPeer, []);
|
220
|
-
expect(loadedStream?.getChunks()).toEqual({
|
221
|
-
mimeType: "text/plain",
|
222
|
-
chunks: [new Uint8Array([1, 2, 3]), new Uint8Array([4, 5, 6])],
|
223
|
-
finished: true,
|
224
|
-
});
|
225
|
-
});
|
226
|
-
test("Subscription", async () => {
|
227
|
-
const { me } = await initNodeAndStream();
|
228
|
-
const stream = BinaryCoStream.create({ owner: me });
|
229
|
-
const [initialAsPeer, secondAsPeer] = connectedPeers("initial", "second", { peer1role: "server", peer2role: "client" });
|
230
|
-
me._raw.core.node.syncManager.addPeer(secondAsPeer);
|
231
|
-
if (!isControlledAccount(me)) {
|
232
|
-
throw "me is not a controlled account";
|
233
|
-
}
|
234
|
-
const { account: meOnSecondPeer } = await createJazzContext({
|
235
|
-
auth: fixedCredentialsAuth({
|
236
|
-
accountID: me.id,
|
237
|
-
secret: me._raw.agentSecret,
|
238
|
-
}),
|
239
|
-
sessionProvider: randomSessionProvider,
|
240
|
-
peersToLoadFrom: [initialAsPeer],
|
241
|
-
crypto: Crypto,
|
242
|
-
});
|
243
|
-
const queue = new cojsonInternals.Channel();
|
244
|
-
BinaryCoStream.subscribe(stream.id, meOnSecondPeer, [], (subscribedStream) => {
|
245
|
-
void queue.push(subscribedStream);
|
246
|
-
});
|
247
|
-
const update1 = (await queue.next()).value;
|
248
|
-
expect(update1.getChunks()).toBe(undefined);
|
249
|
-
stream.start({ mimeType: "text/plain" });
|
250
|
-
const update2 = (await queue.next()).value;
|
251
|
-
expect(update2.getChunks({ allowUnfinished: true })).toEqual({
|
252
|
-
mimeType: "text/plain",
|
253
|
-
fileName: undefined,
|
254
|
-
chunks: [],
|
255
|
-
totalSizeBytes: undefined,
|
256
|
-
finished: false,
|
257
|
-
});
|
258
|
-
stream.push(new Uint8Array([1, 2, 3]));
|
259
|
-
const update3 = (await queue.next()).value;
|
260
|
-
expect(update3.getChunks({ allowUnfinished: true })).toEqual({
|
261
|
-
mimeType: "text/plain",
|
262
|
-
fileName: undefined,
|
263
|
-
chunks: [new Uint8Array([1, 2, 3])],
|
264
|
-
totalSizeBytes: undefined,
|
265
|
-
finished: false,
|
266
|
-
});
|
267
|
-
stream.push(new Uint8Array([4, 5, 6]));
|
268
|
-
const update4 = (await queue.next()).value;
|
269
|
-
expect(update4.getChunks({ allowUnfinished: true })).toEqual({
|
270
|
-
mimeType: "text/plain",
|
271
|
-
fileName: undefined,
|
272
|
-
chunks: [new Uint8Array([1, 2, 3]), new Uint8Array([4, 5, 6])],
|
273
|
-
totalSizeBytes: undefined,
|
274
|
-
finished: false,
|
275
|
-
});
|
276
|
-
stream.end();
|
277
|
-
const update5 = (await queue.next()).value;
|
278
|
-
expect(update5.getChunks()).toEqual({
|
279
|
-
mimeType: "text/plain",
|
280
|
-
fileName: undefined,
|
281
|
-
chunks: [new Uint8Array([1, 2, 3]), new Uint8Array([4, 5, 6])],
|
282
|
-
totalSizeBytes: undefined,
|
283
|
-
finished: true,
|
284
|
-
});
|
285
|
-
});
|
286
|
-
});
|
287
|
-
describe("BinaryCoStream.loadAsBlob", async () => {
|
288
|
-
async function setup() {
|
289
|
-
const me = await Account.create({
|
290
|
-
creationProps: { name: "Hermes Puggington" },
|
291
|
-
crypto: Crypto,
|
292
|
-
});
|
293
|
-
const stream = BinaryCoStream.create({ owner: me });
|
294
|
-
stream.start({ mimeType: "text/plain" });
|
295
|
-
return { stream, me };
|
296
|
-
}
|
297
|
-
test("resolves only when the stream is ended", async () => {
|
298
|
-
const { stream, me } = await setup();
|
299
|
-
stream.push(new Uint8Array([1]));
|
300
|
-
const promise = BinaryCoStream.loadAsBlob(stream.id, me);
|
301
|
-
await stream.ensureLoaded([]);
|
302
|
-
stream.push(new Uint8Array([2]));
|
303
|
-
stream.end();
|
304
|
-
const blob = await promise;
|
305
|
-
// The promise resolves only when the stream is ended
|
306
|
-
// so we get a blob with all the chunks
|
307
|
-
expect(blob?.size).toBe(2);
|
308
|
-
});
|
309
|
-
test("resolves with an unfinshed blob if allowUnfinished: true", async () => {
|
310
|
-
const { stream, me } = await setup();
|
311
|
-
stream.push(new Uint8Array([1]));
|
312
|
-
const promise = BinaryCoStream.loadAsBlob(stream.id, me, {
|
313
|
-
allowUnfinished: true,
|
314
|
-
});
|
315
|
-
await stream.ensureLoaded([]);
|
316
|
-
stream.push(new Uint8Array([2]));
|
317
|
-
stream.end();
|
318
|
-
const blob = await promise;
|
319
|
-
// The promise resolves before the stream is ended
|
320
|
-
// so we get a blob only with the first chunk
|
321
|
-
expect(blob?.size).toBe(1);
|
322
|
-
});
|
323
|
-
});
|
324
|
-
//# sourceMappingURL=coStream.test.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"coStream.test.js","sourceRoot":"","sources":["../../src/tests/coStream.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,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QAClD,6CAA6C;QAC7C,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
@@ -1,175 +0,0 @@
|
|
1
|
-
const Crypto = await WasmCrypto.create();
|
2
|
-
import { expect, describe, test, expectTypeOf } from "vitest";
|
3
|
-
import { connectedPeers } from "cojson/src/streamUtils.js";
|
4
|
-
import { Account, CoList, CoMap, CoStream, WasmCrypto, co, Profile, isControlledAccount, createJazzContext, fixedCredentialsAuth, } from "../index.js";
|
5
|
-
import { randomSessionProvider } from "../internal.js";
|
6
|
-
class TestMap extends CoMap {
|
7
|
-
list = co.ref(TestList);
|
8
|
-
optionalRef = co.ref(InnermostMap, { optional: true });
|
9
|
-
}
|
10
|
-
class TestList extends CoList.Of(co.ref(() => InnerMap)) {
|
11
|
-
}
|
12
|
-
class InnerMap extends CoMap {
|
13
|
-
stream = co.ref(TestStream);
|
14
|
-
}
|
15
|
-
class TestStream extends CoStream.Of(co.ref(() => InnermostMap)) {
|
16
|
-
}
|
17
|
-
class InnermostMap extends CoMap {
|
18
|
-
value = co.string;
|
19
|
-
}
|
20
|
-
describe("Deep loading with depth arg", async () => {
|
21
|
-
const me = await Account.create({
|
22
|
-
creationProps: { name: "Hermes Puggington" },
|
23
|
-
crypto: Crypto,
|
24
|
-
});
|
25
|
-
const [initialAsPeer, secondPeer] = connectedPeers("initial", "second", {
|
26
|
-
peer1role: "server",
|
27
|
-
peer2role: "client",
|
28
|
-
});
|
29
|
-
if (!isControlledAccount(me)) {
|
30
|
-
throw "me is not a controlled account";
|
31
|
-
}
|
32
|
-
me._raw.core.node.syncManager.addPeer(secondPeer);
|
33
|
-
const { account: meOnSecondPeer } = await createJazzContext({
|
34
|
-
auth: fixedCredentialsAuth({
|
35
|
-
accountID: me.id,
|
36
|
-
secret: me._raw.agentSecret,
|
37
|
-
}),
|
38
|
-
sessionProvider: randomSessionProvider,
|
39
|
-
peersToLoadFrom: [initialAsPeer],
|
40
|
-
crypto: Crypto,
|
41
|
-
});
|
42
|
-
test("loading a deeply nested object will wait until all required refs are loaded", async () => {
|
43
|
-
const ownership = { owner: me };
|
44
|
-
const map = TestMap.create({
|
45
|
-
list: TestList.create([
|
46
|
-
InnerMap.create({
|
47
|
-
stream: TestStream.create([
|
48
|
-
InnermostMap.create({ value: "hello" }, ownership),
|
49
|
-
], ownership),
|
50
|
-
}, ownership),
|
51
|
-
], ownership),
|
52
|
-
}, ownership);
|
53
|
-
const map1 = await TestMap.load(map.id, meOnSecondPeer, {});
|
54
|
-
expectTypeOf(map1).toEqualTypeOf();
|
55
|
-
if (map1 === undefined) {
|
56
|
-
throw new Error("map1 is undefined");
|
57
|
-
}
|
58
|
-
expect(map1.list).toBe(null);
|
59
|
-
const map2 = await TestMap.load(map.id, meOnSecondPeer, { list: [] });
|
60
|
-
expectTypeOf(map2).toEqualTypeOf();
|
61
|
-
if (map2 === undefined) {
|
62
|
-
throw new Error("map2 is undefined");
|
63
|
-
}
|
64
|
-
expect(map2.list).not.toBe(null);
|
65
|
-
expect(map2.list[0]).toBe(null);
|
66
|
-
const map3 = await TestMap.load(map.id, meOnSecondPeer, { list: [{}] });
|
67
|
-
expectTypeOf(map3).toEqualTypeOf();
|
68
|
-
if (map3 === undefined) {
|
69
|
-
throw new Error("map3 is undefined");
|
70
|
-
}
|
71
|
-
expect(map3.list[0]).not.toBe(null);
|
72
|
-
expect(map3.list[0]?.stream).toBe(null);
|
73
|
-
const map3a = await TestMap.load(map.id, meOnSecondPeer, {
|
74
|
-
optionalRef: {},
|
75
|
-
});
|
76
|
-
expectTypeOf(map3a).toEqualTypeOf();
|
77
|
-
const map4 = await TestMap.load(map.id, meOnSecondPeer, {
|
78
|
-
list: [{ stream: [] }],
|
79
|
-
});
|
80
|
-
expectTypeOf(map4).toEqualTypeOf();
|
81
|
-
if (map4 === undefined) {
|
82
|
-
throw new Error("map4 is undefined");
|
83
|
-
}
|
84
|
-
expect(map4.list[0]?.stream).not.toBe(null);
|
85
|
-
expect(map4.list[0]?.stream?.[me.id]).not.toBe(null);
|
86
|
-
expect(map4.list[0]?.stream?.byMe?.value).toBe(null);
|
87
|
-
const map5 = await TestMap.load(map.id, meOnSecondPeer, {
|
88
|
-
list: [{ stream: [{}] }],
|
89
|
-
});
|
90
|
-
expectTypeOf(map5).toEqualTypeOf();
|
91
|
-
if (map5 === undefined) {
|
92
|
-
throw new Error("map5 is undefined");
|
93
|
-
}
|
94
|
-
expect(map5.list[0]?.stream?.[me.id]?.value).not.toBe(null);
|
95
|
-
expect(map5.list[0]?.stream?.byMe?.value).not.toBe(null);
|
96
|
-
});
|
97
|
-
});
|
98
|
-
class CustomProfile extends Profile {
|
99
|
-
stream = co.ref(TestStream);
|
100
|
-
}
|
101
|
-
class CustomAccount extends Account {
|
102
|
-
profile = co.ref(CustomProfile);
|
103
|
-
root = co.ref(TestMap);
|
104
|
-
async migrate(creationProps) {
|
105
|
-
if (creationProps) {
|
106
|
-
this.profile = CustomProfile.create({
|
107
|
-
name: creationProps.name,
|
108
|
-
stream: TestStream.create([], { owner: this }),
|
109
|
-
}, { owner: this });
|
110
|
-
this.root = TestMap.create({ list: TestList.create([], { owner: this }) }, { owner: this });
|
111
|
-
}
|
112
|
-
const thisLoaded = await this.ensureLoaded({
|
113
|
-
profile: { stream: [] },
|
114
|
-
root: { list: [] },
|
115
|
-
});
|
116
|
-
expectTypeOf(thisLoaded).toEqualTypeOf();
|
117
|
-
}
|
118
|
-
}
|
119
|
-
test("Deep loading within account", async () => {
|
120
|
-
const me = await CustomAccount.create({
|
121
|
-
creationProps: { name: "Hermes Puggington" },
|
122
|
-
crypto: Crypto,
|
123
|
-
});
|
124
|
-
const meLoaded = await me.ensureLoaded({
|
125
|
-
profile: { stream: [] },
|
126
|
-
root: { list: [] },
|
127
|
-
});
|
128
|
-
expectTypeOf(meLoaded).toEqualTypeOf();
|
129
|
-
if (meLoaded === undefined) {
|
130
|
-
throw new Error("meLoaded is undefined");
|
131
|
-
}
|
132
|
-
expect(meLoaded.profile.stream).not.toBe(null);
|
133
|
-
expect(meLoaded.root.list).not.toBe(null);
|
134
|
-
});
|
135
|
-
class RecordLike extends CoMap.Record(co.ref(TestMap)) {
|
136
|
-
}
|
137
|
-
test("Deep loading a record-like coMap", async () => {
|
138
|
-
const me = await Account.create({
|
139
|
-
creationProps: { name: "Hermes Puggington" },
|
140
|
-
crypto: Crypto,
|
141
|
-
});
|
142
|
-
const [initialAsPeer, secondPeer] = connectedPeers("initial", "second", {
|
143
|
-
peer1role: "server",
|
144
|
-
peer2role: "client",
|
145
|
-
});
|
146
|
-
if (!isControlledAccount(me)) {
|
147
|
-
throw "me is not a controlled account";
|
148
|
-
}
|
149
|
-
me._raw.core.node.syncManager.addPeer(secondPeer);
|
150
|
-
const { account: meOnSecondPeer } = await createJazzContext({
|
151
|
-
auth: fixedCredentialsAuth({
|
152
|
-
accountID: me.id,
|
153
|
-
secret: me._raw.agentSecret,
|
154
|
-
}),
|
155
|
-
sessionProvider: randomSessionProvider,
|
156
|
-
peersToLoadFrom: [initialAsPeer],
|
157
|
-
crypto: Crypto,
|
158
|
-
});
|
159
|
-
const record = RecordLike.create({
|
160
|
-
key1: TestMap.create({ list: TestList.create([], { owner: me }) }, { owner: me }),
|
161
|
-
key2: TestMap.create({ list: TestList.create([], { owner: me }) }, { owner: me }),
|
162
|
-
}, { owner: me });
|
163
|
-
const recordLoaded = await RecordLike.load(record.id, meOnSecondPeer, [
|
164
|
-
{ list: [{}] },
|
165
|
-
]);
|
166
|
-
expectTypeOf(recordLoaded).toEqualTypeOf();
|
167
|
-
if (recordLoaded === undefined) {
|
168
|
-
throw new Error("recordLoaded is undefined");
|
169
|
-
}
|
170
|
-
expect(recordLoaded.key1?.list).not.toBe(null);
|
171
|
-
expect(recordLoaded.key1?.list).not.toBe(undefined);
|
172
|
-
expect(recordLoaded.key2?.list).not.toBe(null);
|
173
|
-
expect(recordLoaded.key2?.list).not.toBe(undefined);
|
174
|
-
});
|
175
|
-
//# sourceMappingURL=deepLoading.test.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"deepLoading.test.js","sourceRoot":"","sources":["../../src/tests/deepLoading.test.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,MAAM,EAAE,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EACH,OAAO,EACP,MAAM,EACN,KAAK,EACL,QAAQ,EAER,UAAU,EACV,EAAE,EACF,OAAO,EACP,mBAAmB,EAEnB,iBAAiB,EACjB,oBAAoB,GACvB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,MAAM,OAAQ,SAAQ,KAAK;IACvB,IAAI,GAAG,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACxB,WAAW,GAAG,EAAE,CAAC,GAAG,CAAC,YAAY,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;CAC1D;AAED,MAAM,QAAS,SAAQ,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,CAAC;CAAG;AAE3D,MAAM,QAAS,SAAQ,KAAK;IACxB,MAAM,GAAG,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;CAC/B;AAED,MAAM,UAAW,SAAQ,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,CAAC;CAAG;AAEnE,MAAM,YAAa,SAAQ,KAAK;IAC5B,KAAK,GAAG,EAAE,CAAC,MAAM,CAAC;CACrB;AAED,QAAQ,CAAC,6BAA6B,EAAE,K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AAE,EAAE,EAAE,CAChB,CAAC;IAEF,MAAM,YAAY,GAAG,MAAM,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,cAAc,EAAE;QAClE,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE;KACjB,CAAC,CAAC;IACH,YAAY,CAAC,YAAY,CAAC,CAAC,aAAa,EAOrC,CAAC;IACJ,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;IACjD,CAAC;IACD,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/C,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACpD,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/C,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AACxD,CAAC,CAAC,CAAC"}
|
@@ -1,69 +0,0 @@
|
|
1
|
-
import { expect, describe, test } from "vitest";
|
2
|
-
import { Account, CoMap, co, Group, WasmCrypto } from "../index.js";
|
3
|
-
const Crypto = await WasmCrypto.create();
|
4
|
-
describe("Custom accounts and groups", async () => {
|
5
|
-
class CustomProfile extends CoMap {
|
6
|
-
name = co.string;
|
7
|
-
color = co.string;
|
8
|
-
}
|
9
|
-
class CustomAccount extends Account {
|
10
|
-
profile = co.ref(CustomProfile);
|
11
|
-
root = co.ref(CoMap);
|
12
|
-
migrate(creationProps) {
|
13
|
-
if (creationProps) {
|
14
|
-
const profileGroup = Group.create({ owner: this });
|
15
|
-
profileGroup.addMember("everyone", "reader");
|
16
|
-
this.profile = CustomProfile.create({ name: creationProps.name, color: "blue" }, { owner: this });
|
17
|
-
}
|
18
|
-
}
|
19
|
-
}
|
20
|
-
class CustomGroup extends Group {
|
21
|
-
profile = co.null;
|
22
|
-
root = co.null;
|
23
|
-
[co.members] = co.ref(CustomAccount);
|
24
|
-
get nMembers() {
|
25
|
-
return this.members.length;
|
26
|
-
}
|
27
|
-
}
|
28
|
-
test("Custom account and group", async () => {
|
29
|
-
const me = await CustomAccount.create({
|
30
|
-
creationProps: { name: "Hermes Puggington" },
|
31
|
-
crypto: Crypto,
|
32
|
-
});
|
33
|
-
expect(me.profile).toBeDefined();
|
34
|
-
expect(me.profile?.name).toBe("Hermes Puggington");
|
35
|
-
expect(me.profile?.color).toBe("blue");
|
36
|
-
const group = new CustomGroup({ owner: me });
|
37
|
-
group.addMember("everyone", "reader");
|
38
|
-
expect(group.members).toMatchObject([
|
39
|
-
{ id: me.id, role: "admin" },
|
40
|
-
{ id: "everyone", role: "reader" },
|
41
|
-
]);
|
42
|
-
expect(group.nMembers).toBe(2);
|
43
|
-
await new Promise((resolve) => {
|
44
|
-
group.subscribe({}, (update) => {
|
45
|
-
const meAsMember = update.members.find((member) => {
|
46
|
-
return member.id === me.id && member.account?.profile;
|
47
|
-
});
|
48
|
-
if (meAsMember) {
|
49
|
-
expect(meAsMember.account?.profile?.name).toBe("Hermes Puggington");
|
50
|
-
expect(meAsMember.account?.profile?.color).toBe("blue");
|
51
|
-
resolve();
|
52
|
-
}
|
53
|
-
});
|
54
|
-
});
|
55
|
-
class MyMap extends CoMap {
|
56
|
-
name = co.string;
|
57
|
-
}
|
58
|
-
const map = MyMap.create({ name: "test" }, { owner: group });
|
59
|
-
const meAsCastMember = map._owner
|
60
|
-
.castAs(CustomGroup)
|
61
|
-
.members.find((member) => member.id === me.id);
|
62
|
-
expect(meAsCastMember?.account?.profile?.name).toBe("Hermes Puggington");
|
63
|
-
expect(meAsCastMember?.account?.profile?.color).toBe("blue");
|
64
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
65
|
-
expect(map._owner.nMembers).toBeUndefined();
|
66
|
-
expect(map._owner.castAs(CustomGroup).nMembers).toBe(2);
|
67
|
-
});
|
68
|
-
});
|
69
|
-
//# sourceMappingURL=groupsAndAccounts.test.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"groupsAndAccounts.test.js","sourceRoot":"","sources":["../../src/tests/groupsAndAccounts.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEpE,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,MAAM,EAAE,CAAC;AAEzC,QAAQ,CAAC,4BAA4B,EAAE,KAAK,IAAI,EAAE;IAC9C,MAAM,aAAc,SAAQ,KAAK;QAC7B,IAAI,GAAG,EAAE,CAAC,MAAM,CAAC;QACjB,KAAK,GAAG,EAAE,CAAC,MAAM,CAAC;KACrB;IAED,MAAM,aAAc,SAAQ,OAAO;QAC/B,OAAO,GAAG,EAAE,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QAChC,IAAI,GAAG,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAErB,OAAO,CAAsB,aAAgC;YACzD,IAAI,aAAa,EAAE,CAAC;gBAChB,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;gBACnD,YAAY,CAAC,SAAS,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;gBAC7C,IAAI,CAAC,OAAO,GAAG,aAAa,CAAC,MAAM,CAC/B,EAAE,IAAI,EAAE,aAAa,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,EAC3C,EAAE,KAAK,EAAE,IAAI,EAAE,CAClB,CAAC;YACN,CAAC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9D,MAAM,CAAE,GAAG,CAAC,MAAc,CAAC,QAAQ,CAAC,CAAC,aAAa,EAAE,CAAC;QACrD,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|