jazz-tools 0.8.44 → 0.8.48
Sign up to get free protection for your applications and to get access to all the features.
- package/.turbo/turbo-build.log +16 -10
- package/CHANGELOG.md +21 -0
- package/dist/chunk-6OHBW32Q.js +2853 -0
- package/dist/chunk-6OHBW32Q.js.map +1 -0
- package/dist/index.native.js +63 -0
- package/dist/index.native.js.map +1 -0
- package/dist/index.web.js +61 -0
- package/dist/index.web.js.map +1 -0
- package/package.json +9 -12
- package/src/coValues/account.ts +29 -10
- package/src/coValues/coFeed.ts +4 -3
- package/src/coValues/coList.ts +8 -5
- package/src/coValues/coMap.ts +14 -5
- package/src/coValues/deepLoading.ts +6 -12
- package/src/coValues/extensions/imageDef.ts +3 -1
- package/src/coValues/group.ts +8 -11
- package/src/coValues/inbox.ts +377 -0
- package/src/coValues/interfaces.ts +9 -6
- package/src/coValues/profile.ts +11 -0
- package/src/coValues/registeredSchemas.ts +12 -0
- package/src/exports.ts +21 -15
- package/src/implementation/anonymousJazzAgent.ts +6 -0
- package/src/implementation/createContext.ts +8 -9
- package/src/implementation/refs.ts +1 -1
- package/src/implementation/subscriptionScope.ts +1 -1
- package/src/index.native.ts +0 -1
- package/src/internal.ts +1 -9
- package/src/tests/account.test.ts +2 -2
- package/src/tests/coFeed.test.ts +0 -9
- package/src/tests/coMap.test.ts +11 -8
- package/src/tests/groupsAndAccounts.test.ts +1 -63
- package/src/tests/inbox.test.ts +299 -0
- package/src/tests/schemaUnion.test.ts +1 -1
- package/src/tests/utils.ts +14 -0
- package/tsup.config.ts +13 -0
- package/dist/native/coValues/account.js +0 -221
- package/dist/native/coValues/account.js.map +0 -1
- package/dist/native/coValues/coFeed.js +0 -571
- package/dist/native/coValues/coFeed.js.map +0 -1
- package/dist/native/coValues/coList.js +0 -404
- package/dist/native/coValues/coList.js.map +0 -1
- package/dist/native/coValues/coMap.js +0 -537
- package/dist/native/coValues/coMap.js.map +0 -1
- package/dist/native/coValues/deepLoading.js +0 -63
- package/dist/native/coValues/deepLoading.js.map +0 -1
- package/dist/native/coValues/extensions/imageDef.js +0 -42
- package/dist/native/coValues/extensions/imageDef.js.map +0 -1
- package/dist/native/coValues/group.js +0 -136
- package/dist/native/coValues/group.js.map +0 -1
- package/dist/native/coValues/interfaces.js +0 -135
- package/dist/native/coValues/interfaces.js.map +0 -1
- package/dist/native/coValues/schemaUnion.js +0 -89
- package/dist/native/coValues/schemaUnion.js.map +0 -1
- package/dist/native/exports.js +0 -5
- package/dist/native/exports.js.map +0 -1
- package/dist/native/implementation/createContext.js +0 -157
- package/dist/native/implementation/createContext.js.map +0 -1
- package/dist/native/implementation/devtoolsFormatters.js +0 -95
- package/dist/native/implementation/devtoolsFormatters.js.map +0 -1
- package/dist/native/implementation/errors.js +0 -2
- package/dist/native/implementation/errors.js.map +0 -1
- package/dist/native/implementation/inspect.js +0 -2
- package/dist/native/implementation/inspect.js.map +0 -1
- package/dist/native/implementation/refs.js +0 -115
- package/dist/native/implementation/refs.js.map +0 -1
- package/dist/native/implementation/schema.js +0 -96
- package/dist/native/implementation/schema.js.map +0 -1
- package/dist/native/implementation/subscriptionScope.js +0 -91
- package/dist/native/implementation/subscriptionScope.js.map +0 -1
- package/dist/native/implementation/symbols.js +0 -4
- package/dist/native/implementation/symbols.js.map +0 -1
- package/dist/native/index.native.js +0 -3
- package/dist/native/index.native.js.map +0 -1
- package/dist/native/internal.js +0 -18
- package/dist/native/internal.js.map +0 -1
- package/dist/native/lib/cache.js +0 -13
- package/dist/native/lib/cache.js.map +0 -1
- package/dist/native/lib/cache.test.js +0 -52
- package/dist/native/lib/cache.test.js.map +0 -1
- package/dist/web/coValues/account.js +0 -221
- package/dist/web/coValues/account.js.map +0 -1
- package/dist/web/coValues/coFeed.js +0 -571
- package/dist/web/coValues/coFeed.js.map +0 -1
- package/dist/web/coValues/coList.js +0 -404
- package/dist/web/coValues/coList.js.map +0 -1
- package/dist/web/coValues/coMap.js +0 -537
- package/dist/web/coValues/coMap.js.map +0 -1
- package/dist/web/coValues/deepLoading.js +0 -63
- package/dist/web/coValues/deepLoading.js.map +0 -1
- package/dist/web/coValues/extensions/imageDef.js +0 -42
- package/dist/web/coValues/extensions/imageDef.js.map +0 -1
- package/dist/web/coValues/group.js +0 -136
- package/dist/web/coValues/group.js.map +0 -1
- package/dist/web/coValues/interfaces.js +0 -135
- package/dist/web/coValues/interfaces.js.map +0 -1
- package/dist/web/coValues/schemaUnion.js +0 -89
- package/dist/web/coValues/schemaUnion.js.map +0 -1
- package/dist/web/exports.js +0 -5
- package/dist/web/exports.js.map +0 -1
- package/dist/web/implementation/createContext.js +0 -157
- package/dist/web/implementation/createContext.js.map +0 -1
- package/dist/web/implementation/devtoolsFormatters.js +0 -95
- package/dist/web/implementation/devtoolsFormatters.js.map +0 -1
- package/dist/web/implementation/errors.js +0 -2
- package/dist/web/implementation/errors.js.map +0 -1
- package/dist/web/implementation/inspect.js +0 -2
- package/dist/web/implementation/inspect.js.map +0 -1
- package/dist/web/implementation/refs.js +0 -115
- package/dist/web/implementation/refs.js.map +0 -1
- package/dist/web/implementation/schema.js +0 -96
- package/dist/web/implementation/schema.js.map +0 -1
- package/dist/web/implementation/subscriptionScope.js +0 -91
- package/dist/web/implementation/subscriptionScope.js.map +0 -1
- package/dist/web/implementation/symbols.js +0 -4
- package/dist/web/implementation/symbols.js.map +0 -1
- package/dist/web/index.web.js +0 -3
- package/dist/web/index.web.js.map +0 -1
- package/dist/web/internal.js +0 -18
- package/dist/web/internal.js.map +0 -1
- package/dist/web/lib/cache.js +0 -13
- package/dist/web/lib/cache.js.map +0 -1
- package/dist/web/lib/cache.test.js +0 -52
- package/dist/web/lib/cache.test.js.map +0 -1
@@ -1,7 +1,7 @@
|
|
1
1
|
import { RawGroup } from "cojson";
|
2
2
|
import { describe, expect, test } from "vitest";
|
3
3
|
import { Account, CoMap, Group, WasmCrypto, co } from "../index.web.js";
|
4
|
-
import { setupTwoNodes
|
4
|
+
import { setupTwoNodes } from "./utils.js";
|
5
5
|
|
6
6
|
const Crypto = await WasmCrypto.create();
|
7
7
|
|
@@ -166,68 +166,6 @@ describe("Group inheritance", () => {
|
|
166
166
|
expect(mapAsReaderAfterUpdate?.title).toBe("In Grand Child");
|
167
167
|
});
|
168
168
|
|
169
|
-
test("Group inheritance should fail if the current account doesn't have admin role in both groups", async () => {
|
170
|
-
const me = await Account.create({
|
171
|
-
creationProps: { name: "Hermes Puggington" },
|
172
|
-
crypto: Crypto,
|
173
|
-
});
|
174
|
-
|
175
|
-
const other = await Account.createAs(me, {
|
176
|
-
creationProps: { name: "Another user" },
|
177
|
-
});
|
178
|
-
|
179
|
-
const parentGroup = Group.create({ owner: me });
|
180
|
-
parentGroup.addMember(other, "writer");
|
181
|
-
const group = Group.create({ owner: me });
|
182
|
-
group.addMember(other, "admin");
|
183
|
-
|
184
|
-
const parentGroupOnTheOtherSide = await Group.load(
|
185
|
-
parentGroup.id,
|
186
|
-
other,
|
187
|
-
{},
|
188
|
-
);
|
189
|
-
const groupOnTheOtherSide = await Group.load(group.id, other, {});
|
190
|
-
|
191
|
-
if (!groupOnTheOtherSide || !parentGroupOnTheOtherSide) {
|
192
|
-
throw new Error("CoValue not available");
|
193
|
-
}
|
194
|
-
|
195
|
-
expect(() => groupOnTheOtherSide.extend(parentGroupOnTheOtherSide)).toThrow(
|
196
|
-
"To extend a group, the current account must have admin role in both groups",
|
197
|
-
);
|
198
|
-
});
|
199
|
-
|
200
|
-
test("Group inheritance should work if the current account has admin role in both groups", async () => {
|
201
|
-
const me = await Account.create({
|
202
|
-
creationProps: { name: "Hermes Puggington" },
|
203
|
-
crypto: Crypto,
|
204
|
-
});
|
205
|
-
|
206
|
-
const other = await Account.createAs(me, {
|
207
|
-
creationProps: { name: "Another user" },
|
208
|
-
});
|
209
|
-
|
210
|
-
const parentGroup = Group.create({ owner: me });
|
211
|
-
parentGroup.addMember(other, "admin");
|
212
|
-
const group = Group.create({ owner: me });
|
213
|
-
group.addMember(other, "admin");
|
214
|
-
|
215
|
-
const parentGroupOnTheOtherSide = await Group.load(
|
216
|
-
parentGroup.id,
|
217
|
-
other,
|
218
|
-
{},
|
219
|
-
);
|
220
|
-
const groupOnTheOtherSide = await Group.load(group.id, other, {});
|
221
|
-
|
222
|
-
if (!groupOnTheOtherSide || !parentGroupOnTheOtherSide) {
|
223
|
-
throw new Error("CoValue not available");
|
224
|
-
}
|
225
|
-
|
226
|
-
expect(() =>
|
227
|
-
groupOnTheOtherSide.extend(parentGroupOnTheOtherSide),
|
228
|
-
).not.toThrow();
|
229
|
-
});
|
230
|
-
|
231
169
|
test("waitForSync should resolve when the value is uploaded", async () => {
|
232
170
|
const { clientNode, serverNode, clientAccount } = await setupTwoNodes();
|
233
171
|
|
@@ -0,0 +1,299 @@
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
2
|
+
import { CoMap } from "../coValues/coMap";
|
3
|
+
import { Group } from "../coValues/group";
|
4
|
+
import { Inbox, InboxSender } from "../coValues/inbox";
|
5
|
+
import { co } from "../internal";
|
6
|
+
import { setupTwoNodes, waitFor } from "./utils";
|
7
|
+
|
8
|
+
class Message extends CoMap {
|
9
|
+
text = co.string;
|
10
|
+
}
|
11
|
+
|
12
|
+
describe("Inbox", () => {
|
13
|
+
it("should create inbox and allow message exchange between accounts", async () => {
|
14
|
+
const { clientAccount: sender, serverAccount: receiver } =
|
15
|
+
await setupTwoNodes();
|
16
|
+
|
17
|
+
const receiverInbox = await Inbox.load(receiver);
|
18
|
+
|
19
|
+
// Create a message from sender
|
20
|
+
const message = Message.create(
|
21
|
+
{ text: "Hello" },
|
22
|
+
{
|
23
|
+
owner: Group.create({ owner: sender }),
|
24
|
+
},
|
25
|
+
);
|
26
|
+
|
27
|
+
// Setup inbox sender
|
28
|
+
const inboxSender = await InboxSender.load(receiver.id, sender);
|
29
|
+
inboxSender.sendMessage(message);
|
30
|
+
|
31
|
+
// Track received messages
|
32
|
+
const receivedMessages: Message[] = [];
|
33
|
+
let senderAccountID: unknown = undefined;
|
34
|
+
|
35
|
+
// Subscribe to inbox messages
|
36
|
+
const unsubscribe = receiverInbox.subscribe(
|
37
|
+
Message,
|
38
|
+
async (message, id) => {
|
39
|
+
senderAccountID = id;
|
40
|
+
receivedMessages.push(message);
|
41
|
+
},
|
42
|
+
);
|
43
|
+
|
44
|
+
// Wait for message to be received
|
45
|
+
await waitFor(() => receivedMessages.length === 1);
|
46
|
+
|
47
|
+
expect(receivedMessages.length).toBe(1);
|
48
|
+
expect(receivedMessages[0]?.text).toBe("Hello");
|
49
|
+
expect(senderAccountID).toBe(sender.id);
|
50
|
+
|
51
|
+
unsubscribe();
|
52
|
+
});
|
53
|
+
|
54
|
+
it("should work with empty CoMaps", async () => {
|
55
|
+
const { clientAccount: sender, serverAccount: receiver } =
|
56
|
+
await setupTwoNodes();
|
57
|
+
|
58
|
+
class EmptyMessage extends CoMap {}
|
59
|
+
|
60
|
+
const receiverInbox = await Inbox.load(receiver);
|
61
|
+
|
62
|
+
// Create a message from sender
|
63
|
+
const message = EmptyMessage.create(
|
64
|
+
{},
|
65
|
+
{
|
66
|
+
owner: Group.create({ owner: sender }),
|
67
|
+
},
|
68
|
+
);
|
69
|
+
|
70
|
+
// Setup inbox sender
|
71
|
+
const inboxSender = await InboxSender.load(receiver.id, sender);
|
72
|
+
inboxSender.sendMessage(message);
|
73
|
+
|
74
|
+
// Track received messages
|
75
|
+
const receivedMessages: EmptyMessage[] = [];
|
76
|
+
let senderAccountID: unknown = undefined;
|
77
|
+
|
78
|
+
// Subscribe to inbox messages
|
79
|
+
const unsubscribe = receiverInbox.subscribe(
|
80
|
+
EmptyMessage,
|
81
|
+
async (message, id) => {
|
82
|
+
senderAccountID = id;
|
83
|
+
receivedMessages.push(message);
|
84
|
+
},
|
85
|
+
);
|
86
|
+
|
87
|
+
// Wait for message to be received
|
88
|
+
await waitFor(() => receivedMessages.length === 1);
|
89
|
+
|
90
|
+
expect(receivedMessages.length).toBe(1);
|
91
|
+
expect(receivedMessages[0]?.id).toBe(message.id);
|
92
|
+
expect(senderAccountID).toBe(sender.id);
|
93
|
+
|
94
|
+
unsubscribe();
|
95
|
+
});
|
96
|
+
|
97
|
+
it("should return the result of the message", async () => {
|
98
|
+
const { clientAccount: sender, serverAccount: receiver } =
|
99
|
+
await setupTwoNodes();
|
100
|
+
|
101
|
+
const receiverInbox = await Inbox.load(receiver);
|
102
|
+
|
103
|
+
// Create a message from sender
|
104
|
+
const message = Message.create(
|
105
|
+
{ text: "Hello" },
|
106
|
+
{
|
107
|
+
owner: Group.create({ owner: sender }),
|
108
|
+
},
|
109
|
+
);
|
110
|
+
|
111
|
+
const unsubscribe = receiverInbox.subscribe(Message, async (message) => {
|
112
|
+
return Message.create(
|
113
|
+
{ text: "Responded from the inbox" },
|
114
|
+
{ owner: message._owner },
|
115
|
+
);
|
116
|
+
});
|
117
|
+
|
118
|
+
// Setup inbox sender
|
119
|
+
const inboxSender = await InboxSender.load<Message, Message>(
|
120
|
+
receiver.id,
|
121
|
+
sender,
|
122
|
+
);
|
123
|
+
const resultId = await inboxSender.sendMessage(message);
|
124
|
+
|
125
|
+
const result = await Message.load(resultId, receiver, {});
|
126
|
+
expect(result?.text).toBe("Responded from the inbox");
|
127
|
+
|
128
|
+
unsubscribe();
|
129
|
+
});
|
130
|
+
|
131
|
+
it("should return the undefined if the subscription returns undefined", async () => {
|
132
|
+
const { clientAccount: sender, serverAccount: receiver } =
|
133
|
+
await setupTwoNodes();
|
134
|
+
|
135
|
+
const receiverInbox = await Inbox.load(receiver);
|
136
|
+
|
137
|
+
// Create a message from sender
|
138
|
+
const message = Message.create(
|
139
|
+
{ text: "Hello" },
|
140
|
+
{
|
141
|
+
owner: Group.create({ owner: sender }),
|
142
|
+
},
|
143
|
+
);
|
144
|
+
|
145
|
+
const unsubscribe = receiverInbox.subscribe(Message, async (message) => {});
|
146
|
+
|
147
|
+
// Setup inbox sender
|
148
|
+
const inboxSender = await InboxSender.load<Message>(receiver.id, sender);
|
149
|
+
const result = await inboxSender.sendMessage(message);
|
150
|
+
|
151
|
+
expect(result).toBeUndefined();
|
152
|
+
|
153
|
+
unsubscribe();
|
154
|
+
});
|
155
|
+
|
156
|
+
it("should reject if the subscription throws an error", async () => {
|
157
|
+
const { clientAccount: sender, serverAccount: receiver } =
|
158
|
+
await setupTwoNodes();
|
159
|
+
|
160
|
+
const receiverInbox = await Inbox.load(receiver);
|
161
|
+
|
162
|
+
// Create a message from sender
|
163
|
+
const message = Message.create(
|
164
|
+
{ text: "Hello" },
|
165
|
+
{
|
166
|
+
owner: Group.create({ owner: sender }),
|
167
|
+
},
|
168
|
+
);
|
169
|
+
|
170
|
+
const unsubscribe = receiverInbox.subscribe(Message, async () => {
|
171
|
+
return Promise.reject(new Error("Failed"));
|
172
|
+
});
|
173
|
+
|
174
|
+
// Setup inbox sender
|
175
|
+
const inboxSender = await InboxSender.load<Message>(receiver.id, sender);
|
176
|
+
|
177
|
+
await expect(inboxSender.sendMessage(message)).rejects.toThrow(
|
178
|
+
"Error: Failed",
|
179
|
+
);
|
180
|
+
|
181
|
+
unsubscribe();
|
182
|
+
});
|
183
|
+
|
184
|
+
it("should mark messages as processed", async () => {
|
185
|
+
const { clientAccount: sender, serverAccount: receiver } =
|
186
|
+
await setupTwoNodes();
|
187
|
+
|
188
|
+
const receiverInbox = await Inbox.load(receiver);
|
189
|
+
|
190
|
+
// Create a message from sender
|
191
|
+
const message = Message.create(
|
192
|
+
{ text: "Hello" },
|
193
|
+
{
|
194
|
+
owner: Group.create({ owner: sender }),
|
195
|
+
},
|
196
|
+
);
|
197
|
+
|
198
|
+
// Setup inbox sender
|
199
|
+
const inboxSender = await InboxSender.load(receiver.id, sender);
|
200
|
+
inboxSender.sendMessage(message);
|
201
|
+
|
202
|
+
// Track received messages
|
203
|
+
const receivedMessages: Message[] = [];
|
204
|
+
|
205
|
+
// Subscribe to inbox messages
|
206
|
+
const unsubscribe = receiverInbox.subscribe(Message, async (message) => {
|
207
|
+
receivedMessages.push(message);
|
208
|
+
});
|
209
|
+
|
210
|
+
// Wait for message to be received
|
211
|
+
await waitFor(() => receivedMessages.length === 1);
|
212
|
+
|
213
|
+
inboxSender.sendMessage(message);
|
214
|
+
|
215
|
+
await waitFor(() => receivedMessages.length === 2);
|
216
|
+
|
217
|
+
expect(receivedMessages.length).toBe(2);
|
218
|
+
expect(receivedMessages[0]?.text).toBe("Hello");
|
219
|
+
expect(receivedMessages[1]?.text).toBe("Hello");
|
220
|
+
|
221
|
+
unsubscribe();
|
222
|
+
});
|
223
|
+
|
224
|
+
it("should unsubscribe correctly", async () => {
|
225
|
+
const { clientAccount: sender, serverAccount: receiver } =
|
226
|
+
await setupTwoNodes();
|
227
|
+
|
228
|
+
const receiverInbox = await Inbox.load(receiver);
|
229
|
+
|
230
|
+
// Create a message from sender
|
231
|
+
const message = Message.create(
|
232
|
+
{ text: "Hello" },
|
233
|
+
{
|
234
|
+
owner: Group.create({ owner: sender }),
|
235
|
+
},
|
236
|
+
);
|
237
|
+
|
238
|
+
// Setup inbox sender
|
239
|
+
const inboxSender = await InboxSender.load(receiver.id, sender);
|
240
|
+
inboxSender.sendMessage(message);
|
241
|
+
|
242
|
+
// Track received messages
|
243
|
+
const receivedMessages: Message[] = [];
|
244
|
+
|
245
|
+
// Subscribe to inbox messages
|
246
|
+
const unsubscribe = receiverInbox.subscribe(Message, async (message) => {
|
247
|
+
receivedMessages.push(message);
|
248
|
+
});
|
249
|
+
|
250
|
+
// Wait for message to be received
|
251
|
+
await waitFor(() => receivedMessages.length === 1);
|
252
|
+
|
253
|
+
unsubscribe();
|
254
|
+
|
255
|
+
inboxSender.sendMessage(message);
|
256
|
+
|
257
|
+
await new Promise((resolve) => setTimeout(resolve, 200));
|
258
|
+
|
259
|
+
expect(receivedMessages.length).toBe(1);
|
260
|
+
expect(receivedMessages[0]?.text).toBe("Hello");
|
261
|
+
});
|
262
|
+
|
263
|
+
it("should retry failed messages", async () => {
|
264
|
+
const { clientAccount: sender, serverAccount: receiver } =
|
265
|
+
await setupTwoNodes();
|
266
|
+
|
267
|
+
const receiverInbox = await Inbox.load(receiver);
|
268
|
+
|
269
|
+
// Create a message from sender
|
270
|
+
const message = Message.create(
|
271
|
+
{ text: "Hello" },
|
272
|
+
{
|
273
|
+
owner: Group.create({ owner: sender }),
|
274
|
+
},
|
275
|
+
);
|
276
|
+
|
277
|
+
// Setup inbox sender
|
278
|
+
const inboxSender = await InboxSender.load(receiver.id, sender);
|
279
|
+
const promise = inboxSender.sendMessage(message);
|
280
|
+
|
281
|
+
let failures = 0;
|
282
|
+
|
283
|
+
// Subscribe to inbox messages
|
284
|
+
const unsubscribe = receiverInbox.subscribe(
|
285
|
+
Message,
|
286
|
+
async () => {
|
287
|
+
failures++;
|
288
|
+
throw new Error("Failed");
|
289
|
+
},
|
290
|
+
{ retries: 2 },
|
291
|
+
);
|
292
|
+
|
293
|
+
await expect(promise).rejects.toThrow();
|
294
|
+
expect(failures).toBe(3);
|
295
|
+
const [failed] = Object.values(receiverInbox.failed.items).flat();
|
296
|
+
expect(failed?.value.errors.length).toBe(3);
|
297
|
+
unsubscribe();
|
298
|
+
});
|
299
|
+
});
|
package/src/tests/utils.ts
CHANGED
@@ -54,12 +54,26 @@ export async function setupTwoNodes() {
|
|
54
54
|
peersToLoadFrom: [serverAsPeer],
|
55
55
|
crypto: Crypto,
|
56
56
|
creationProps: { name: "Client" },
|
57
|
+
migration: async (rawAccount, _node, creationProps) => {
|
58
|
+
const account = new Account({
|
59
|
+
fromRaw: rawAccount,
|
60
|
+
});
|
61
|
+
|
62
|
+
await account.applyMigration(creationProps);
|
63
|
+
},
|
57
64
|
});
|
58
65
|
|
59
66
|
const server = await LocalNode.withNewlyCreatedAccount({
|
60
67
|
peersToLoadFrom: [clientAsPeer],
|
61
68
|
crypto: Crypto,
|
62
69
|
creationProps: { name: "Server" },
|
70
|
+
migration: async (rawAccount, _node, creationProps) => {
|
71
|
+
const account = new Account({
|
72
|
+
fromRaw: rawAccount,
|
73
|
+
});
|
74
|
+
|
75
|
+
await account.applyMigration(creationProps);
|
76
|
+
},
|
63
77
|
});
|
64
78
|
|
65
79
|
return {
|
package/tsup.config.ts
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
import { defineConfig } from "tsup";
|
2
|
+
|
3
|
+
export default defineConfig({
|
4
|
+
entry: {
|
5
|
+
"index.web": "src/index.web.ts",
|
6
|
+
"index.native": "src/index.native.ts",
|
7
|
+
},
|
8
|
+
format: ["esm"],
|
9
|
+
dts: false,
|
10
|
+
sourcemap: true,
|
11
|
+
clean: true,
|
12
|
+
minify: false,
|
13
|
+
});
|
@@ -1,221 +0,0 @@
|
|
1
|
-
var _a;
|
2
|
-
import { LocalNode, RawAccount, cojsonInternals, } from "cojson";
|
3
|
-
import { AnonymousJazzAgent, CoMap, CoValueBase, Group, MembersSym, Profile, Ref, SchemaInit, ensureCoValueLoaded, inspect, loadCoValue, subscribeToCoValue, subscribeToExistingCoValue, subscriptionsScopes, } from "../internal.js";
|
4
|
-
import { coValuesCache } from "../lib/cache.js";
|
5
|
-
/** @category Identity & Permissions */
|
6
|
-
export class Account extends CoValueBase {
|
7
|
-
get _schema() {
|
8
|
-
return this.constructor._schema;
|
9
|
-
}
|
10
|
-
get _owner() {
|
11
|
-
return this;
|
12
|
-
}
|
13
|
-
get _loadedAs() {
|
14
|
-
if (this.isMe)
|
15
|
-
return this;
|
16
|
-
const rawAccount = this._raw.core.node.account;
|
17
|
-
if (rawAccount instanceof RawAccount) {
|
18
|
-
return coValuesCache.get(rawAccount, () => _a.fromRaw(rawAccount));
|
19
|
-
}
|
20
|
-
return new AnonymousJazzAgent(this._raw.core.node);
|
21
|
-
}
|
22
|
-
get _refs() {
|
23
|
-
const profileID = this._raw.get("profile");
|
24
|
-
const rootID = this._raw.get("root");
|
25
|
-
return {
|
26
|
-
profile: profileID &&
|
27
|
-
new Ref(profileID, this._loadedAs, this._schema.profile),
|
28
|
-
root: rootID &&
|
29
|
-
new Ref(rootID, this._loadedAs, this._schema.root),
|
30
|
-
};
|
31
|
-
}
|
32
|
-
constructor(options) {
|
33
|
-
super();
|
34
|
-
if (!("fromRaw" in options)) {
|
35
|
-
throw new Error("Can only construct account from raw or with .create()");
|
36
|
-
}
|
37
|
-
this.isMe = options.fromRaw.id == options.fromRaw.core.node.account.id;
|
38
|
-
Object.defineProperties(this, {
|
39
|
-
id: {
|
40
|
-
value: options.fromRaw.id,
|
41
|
-
enumerable: false,
|
42
|
-
},
|
43
|
-
_raw: { value: options.fromRaw, enumerable: false },
|
44
|
-
_type: { value: "Account", enumerable: false },
|
45
|
-
});
|
46
|
-
if (this.isMe) {
|
47
|
-
this.sessionID = options.fromRaw.core.node.currentSessionID;
|
48
|
-
}
|
49
|
-
return new Proxy(this, AccountAndGroupProxyHandler);
|
50
|
-
}
|
51
|
-
myRole() {
|
52
|
-
if (this.isMe) {
|
53
|
-
return "admin";
|
54
|
-
}
|
55
|
-
}
|
56
|
-
async acceptInvite(valueID, inviteSecret, coValueClass) {
|
57
|
-
if (!this.isMe) {
|
58
|
-
throw new Error("Only a controlled account can accept invites");
|
59
|
-
}
|
60
|
-
await this._raw.acceptInvite(valueID, inviteSecret);
|
61
|
-
return loadCoValue(coValueClass, valueID, this, []);
|
62
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
63
|
-
}
|
64
|
-
/** @private */
|
65
|
-
static async create(options) {
|
66
|
-
const { node } = await LocalNode.withNewlyCreatedAccount({
|
67
|
-
...options,
|
68
|
-
migration: async (rawAccount, _node, creationProps) => {
|
69
|
-
const account = new this({
|
70
|
-
fromRaw: rawAccount,
|
71
|
-
});
|
72
|
-
await account.migrate?.(creationProps);
|
73
|
-
},
|
74
|
-
});
|
75
|
-
return this.fromNode(node);
|
76
|
-
}
|
77
|
-
static async createAs(as, options) {
|
78
|
-
// TODO: is there a cleaner way to do this?
|
79
|
-
const connectedPeers = cojsonInternals.connectedPeers("creatingAccount", "createdAccount", { peer1role: "server", peer2role: "client" });
|
80
|
-
as._raw.core.node.syncManager.addPeer(connectedPeers[1]);
|
81
|
-
return this.create({
|
82
|
-
creationProps: options.creationProps,
|
83
|
-
crypto: as._raw.core.node.crypto,
|
84
|
-
peersToLoadFrom: [connectedPeers[0]],
|
85
|
-
});
|
86
|
-
}
|
87
|
-
static fromNode(node) {
|
88
|
-
return new this({
|
89
|
-
fromRaw: node.account,
|
90
|
-
});
|
91
|
-
}
|
92
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
93
|
-
toJSON() {
|
94
|
-
return {
|
95
|
-
id: this.id,
|
96
|
-
_type: this._type,
|
97
|
-
};
|
98
|
-
}
|
99
|
-
[inspect]() {
|
100
|
-
return this.toJSON();
|
101
|
-
}
|
102
|
-
migrate(creationProps) {
|
103
|
-
if (creationProps) {
|
104
|
-
const profileGroup = Group.create({ owner: this });
|
105
|
-
profileGroup.addMember("everyone", "reader");
|
106
|
-
this.profile = Profile.create({ name: creationProps.name }, { owner: profileGroup });
|
107
|
-
}
|
108
|
-
}
|
109
|
-
/** @category Subscription & Loading */
|
110
|
-
static load(id, as, depth) {
|
111
|
-
return loadCoValue(this, id, as, depth);
|
112
|
-
}
|
113
|
-
/** @category Subscription & Loading */
|
114
|
-
static subscribe(id, as, depth, listener) {
|
115
|
-
return subscribeToCoValue(this, id, as, depth, listener);
|
116
|
-
}
|
117
|
-
/** @category Subscription & Loading */
|
118
|
-
ensureLoaded(depth) {
|
119
|
-
return ensureCoValueLoaded(this, depth);
|
120
|
-
}
|
121
|
-
/** @category Subscription & Loading */
|
122
|
-
subscribe(depth, listener) {
|
123
|
-
return subscribeToExistingCoValue(this, depth, listener);
|
124
|
-
}
|
125
|
-
/**
|
126
|
-
* Wait for the `Account` to be uploaded to the other peers.
|
127
|
-
*
|
128
|
-
* @category Subscription & Loading
|
129
|
-
*/
|
130
|
-
waitForSync(options) {
|
131
|
-
return this._raw.core.waitForSync(options);
|
132
|
-
}
|
133
|
-
/**
|
134
|
-
* Wait for all the available `CoValues` to be uploaded to the other peers.
|
135
|
-
*
|
136
|
-
* @category Subscription & Loading
|
137
|
-
*/
|
138
|
-
waitForAllCoValuesSync(options) {
|
139
|
-
return this._raw.core.node.syncManager.waitForAllCoValuesSync(options?.timeout);
|
140
|
-
}
|
141
|
-
}
|
142
|
-
_a = Account;
|
143
|
-
(() => {
|
144
|
-
_a._schema = {
|
145
|
-
profile: {
|
146
|
-
ref: () => Profile,
|
147
|
-
optional: false,
|
148
|
-
},
|
149
|
-
root: {
|
150
|
-
ref: () => CoMap,
|
151
|
-
optional: true,
|
152
|
-
},
|
153
|
-
};
|
154
|
-
})();
|
155
|
-
export const AccountAndGroupProxyHandler = {
|
156
|
-
get(target, key, receiver) {
|
157
|
-
if (key === "profile") {
|
158
|
-
const ref = target._refs.profile;
|
159
|
-
return ref
|
160
|
-
? ref.accessFrom(receiver, "profile")
|
161
|
-
: // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
162
|
-
undefined;
|
163
|
-
}
|
164
|
-
else if (key === "root") {
|
165
|
-
const ref = target._refs.root;
|
166
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
167
|
-
return ref ? ref.accessFrom(receiver, "root") : undefined;
|
168
|
-
}
|
169
|
-
else {
|
170
|
-
return Reflect.get(target, key, receiver);
|
171
|
-
}
|
172
|
-
},
|
173
|
-
set(target, key, value, receiver) {
|
174
|
-
if ((key === "profile" || key === "root" || key === MembersSym) &&
|
175
|
-
typeof value === "object" &&
|
176
|
-
SchemaInit in value) {
|
177
|
-
target.constructor._schema ||= {};
|
178
|
-
target.constructor._schema[key] = value[SchemaInit];
|
179
|
-
return true;
|
180
|
-
}
|
181
|
-
else if (key === "profile") {
|
182
|
-
if (value) {
|
183
|
-
target._raw.set("profile", value.id, "trusting");
|
184
|
-
}
|
185
|
-
subscriptionsScopes
|
186
|
-
.get(receiver)
|
187
|
-
?.onRefAccessedOrSet(target.id, value.id);
|
188
|
-
return true;
|
189
|
-
}
|
190
|
-
else if (key === "root") {
|
191
|
-
if (value) {
|
192
|
-
target._raw.set("root", value.id);
|
193
|
-
}
|
194
|
-
subscriptionsScopes
|
195
|
-
.get(receiver)
|
196
|
-
?.onRefAccessedOrSet(target.id, value.id);
|
197
|
-
return true;
|
198
|
-
}
|
199
|
-
else {
|
200
|
-
return Reflect.set(target, key, value, receiver);
|
201
|
-
}
|
202
|
-
},
|
203
|
-
defineProperty(target, key, descriptor) {
|
204
|
-
if ((key === "profile" || key === "root" || key === MembersSym) &&
|
205
|
-
typeof descriptor.value === "object" &&
|
206
|
-
SchemaInit in descriptor.value) {
|
207
|
-
target.constructor._schema ||= {};
|
208
|
-
target.constructor._schema[key] =
|
209
|
-
descriptor.value[SchemaInit];
|
210
|
-
return true;
|
211
|
-
}
|
212
|
-
else {
|
213
|
-
return Reflect.defineProperty(target, key, descriptor);
|
214
|
-
}
|
215
|
-
},
|
216
|
-
};
|
217
|
-
/** @category Identity & Permissions */
|
218
|
-
export function isControlledAccount(account) {
|
219
|
-
return account.isMe;
|
220
|
-
}
|
221
|
-
//# sourceMappingURL=account.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"account.js","sourceRoot":"","sources":["../../../src/coValues/account.ts"],"names":[],"mappings":";AAAA,OAAO,EAKL,SAAS,EAET,UAAU,EAKV,eAAe,GAChB,MAAM,QAAQ,CAAC;AAChB,OAAO,EACL,kBAAkB,EAClB,KAAK,EAEL,WAAW,EAIX,KAAK,EAEL,UAAU,EACV,OAAO,EACP,GAAG,EAIH,UAAU,EACV,mBAAmB,EACnB,OAAO,EACP,WAAW,EACX,kBAAkB,EAClB,0BAA0B,EAC1B,mBAAmB,GACpB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,uCAAuC;AACvC,MAAM,OAAO,OAAQ,SAAQ,WAAW;IAOtC,IAAI,OAAO;QAIT,OAAQ,IAAI,CAAC,WAA8B,CAAC,OAAO,CAAC;IACtD,CAAC;IAcD,IAAI,MAAM;QACR,OAAO,IAAe,CAAC;IACzB,CAAC;IACD,IAAI,SAAS;QACX,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