jazz-tools 0.17.13 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.svelte-kit/__package__/jazz.class.svelte.js +1 -1
- package/.svelte-kit/__package__/media/image.svelte +3 -9
- package/.svelte-kit/__package__/media/image.svelte.d.ts +1 -6
- package/.svelte-kit/__package__/media/image.svelte.d.ts.map +1 -1
- package/.svelte-kit/__package__/media/image.types.d.ts +7 -0
- package/.svelte-kit/__package__/media/image.types.d.ts.map +1 -0
- package/.svelte-kit/__package__/media/image.types.js +1 -0
- package/.svelte-kit/__package__/tests/media/image.svelte.test.js +31 -31
- package/.turbo/turbo-build.log +49 -49
- package/CHANGELOG.md +42 -0
- package/dist/browser/index.js +2 -2
- package/dist/browser/index.js.map +1 -1
- package/dist/{chunk-SFP5PBPX.js → chunk-HJ3GTGY7.js} +1325 -1001
- package/dist/chunk-HJ3GTGY7.js.map +1 -0
- package/dist/index.js +18 -18
- package/dist/index.js.map +1 -1
- package/dist/inspector/{custom-element-ZSNTCECD.js → custom-element-WCY6D3QJ.js} +3 -3
- package/dist/inspector/{custom-element-ZSNTCECD.js.map → custom-element-WCY6D3QJ.js.map} +1 -1
- package/dist/inspector/index.js +1 -1
- package/dist/inspector/index.js.map +1 -1
- package/dist/inspector/register-custom-element.js +1 -1
- package/dist/media/{chunk-E5J3WLQW.js → chunk-KR2V6X2N.js} +14 -9
- package/dist/media/chunk-KR2V6X2N.js.map +1 -0
- package/dist/media/create-image.d.ts +6 -6
- package/dist/media/index.browser.d.ts +6 -6
- package/dist/media/index.browser.js +1 -1
- package/dist/media/index.d.ts +1 -1
- package/dist/media/index.js +1 -1
- package/dist/media/index.native.d.ts +6 -6
- package/dist/media/index.native.js +1 -1
- package/dist/media/utils.d.ts.map +1 -1
- package/dist/prosemirror/index.js +2 -2
- package/dist/prosemirror/index.js.map +1 -1
- package/dist/react/index.js +7 -5
- package/dist/react/index.js.map +1 -1
- package/dist/react-core/hooks.d.ts.map +1 -1
- package/dist/react-core/index.js +4658 -23
- package/dist/react-core/index.js.map +1 -1
- package/dist/react-native-core/index.js +1 -1
- package/dist/react-native-core/index.js.map +1 -1
- package/dist/svelte/jazz.class.svelte.js +1 -1
- package/dist/svelte/media/image.svelte +3 -9
- package/dist/svelte/media/image.svelte.d.ts +1 -6
- package/dist/svelte/media/image.svelte.d.ts.map +1 -1
- package/dist/svelte/media/image.types.d.ts +7 -0
- package/dist/svelte/media/image.types.d.ts.map +1 -0
- package/dist/svelte/media/image.types.js +1 -0
- package/dist/svelte/tests/media/image.svelte.test.js +31 -31
- package/dist/testing.js +18 -14
- package/dist/testing.js.map +1 -1
- package/dist/tools/coValues/CoFieldInit.d.ts +13 -0
- package/dist/tools/coValues/CoFieldInit.d.ts.map +1 -0
- package/dist/tools/coValues/CoValueBase.d.ts +18 -15
- package/dist/tools/coValues/CoValueBase.d.ts.map +1 -1
- package/dist/tools/coValues/account.d.ts +100 -46
- package/dist/tools/coValues/account.d.ts.map +1 -1
- package/dist/tools/coValues/coFeed.d.ts +78 -62
- package/dist/tools/coValues/coFeed.d.ts.map +1 -1
- package/dist/tools/coValues/coList.d.ts +212 -99
- package/dist/tools/coValues/coList.d.ts.map +1 -1
- package/dist/tools/coValues/coMap.d.ts +200 -192
- package/dist/tools/coValues/coMap.d.ts.map +1 -1
- package/dist/tools/coValues/coPlainText.d.ts +30 -22
- package/dist/tools/coValues/coPlainText.d.ts.map +1 -1
- package/dist/tools/coValues/deepLoading.d.ts +13 -13
- package/dist/tools/coValues/deepLoading.d.ts.map +1 -1
- package/dist/tools/coValues/extensions/imageDef.d.ts +1 -1
- package/dist/tools/coValues/group.d.ts +32 -32
- package/dist/tools/coValues/group.d.ts.map +1 -1
- package/dist/tools/coValues/inbox.d.ts.map +1 -1
- package/dist/tools/coValues/interfaces.d.ts +18 -17
- package/dist/tools/coValues/interfaces.d.ts.map +1 -1
- package/dist/tools/coValues/profile.d.ts +6 -5
- package/dist/tools/coValues/profile.d.ts.map +1 -1
- package/dist/tools/coValues/schemaUnion.d.ts +3 -3
- package/dist/tools/coValues/schemaUnion.d.ts.map +1 -1
- package/dist/tools/exports.d.ts +1 -1
- package/dist/tools/exports.d.ts.map +1 -1
- package/dist/tools/implementation/anonymousJazzAgent.d.ts +2 -1
- package/dist/tools/implementation/anonymousJazzAgent.d.ts.map +1 -1
- package/dist/tools/implementation/schema.d.ts +5 -5
- package/dist/tools/implementation/schema.d.ts.map +1 -1
- package/dist/tools/implementation/symbols.d.ts +2 -0
- package/dist/tools/implementation/symbols.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/AccountSchema.d.ts +2 -2
- package/dist/tools/implementation/zodSchema/schemaTypes/AccountSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.d.ts +6 -2
- package/dist/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoListSchema.d.ts +8 -3
- package/dist/tools/implementation/zodSchema/schemaTypes/CoListSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoMapSchema.d.ts +12 -7
- package/dist/tools/implementation/zodSchema/schemaTypes/CoMapSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoRecordSchema.d.ts +13 -7
- package/dist/tools/implementation/zodSchema/schemaTypes/CoRecordSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/FileStreamSchema.d.ts +11 -2
- package/dist/tools/implementation/zodSchema/schemaTypes/FileStreamSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/PlainTextSchema.d.ts +4 -0
- package/dist/tools/implementation/zodSchema/schemaTypes/PlainTextSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/RichTextSchema.d.ts +4 -0
- package/dist/tools/implementation/zodSchema/schemaTypes/RichTextSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/typeConverters/{CoFieldInit.d.ts → CoFieldSchemaInit.d.ts} +7 -7
- package/dist/tools/implementation/zodSchema/typeConverters/CoFieldSchemaInit.d.ts.map +1 -0
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchema.d.ts +4 -4
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.d.ts +4 -4
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/zodCo.d.ts +2 -2
- package/dist/tools/implementation/zodSchema/zodCo.d.ts.map +1 -1
- package/dist/tools/internal.d.ts +2 -1
- package/dist/tools/internal.d.ts.map +1 -1
- package/dist/tools/lib/migration.d.ts +1 -1
- package/dist/tools/lib/migration.d.ts.map +1 -1
- package/dist/tools/subscribe/SubscriptionScope.d.ts.map +1 -1
- package/dist/tools/subscribe/index.d.ts +1 -1
- package/dist/tools/subscribe/index.d.ts.map +1 -1
- package/dist/tools/subscribe/utils.d.ts +2 -2
- package/dist/tools/subscribe/utils.d.ts.map +1 -1
- package/dist/tools/testing.d.ts.map +1 -1
- package/dist/tools/tests/utils.d.ts +2 -6
- package/dist/tools/tests/utils.d.ts.map +1 -1
- package/dist/worker/index.js +3 -3
- package/dist/worker/index.js.map +1 -1
- package/package.json +4 -4
- package/src/browser/auth/PasskeyAuth.ts +2 -2
- package/src/browser/createBrowserContext.ts +2 -2
- package/src/browser/tests/PasskeyAuth.test.ts +2 -2
- package/src/inspector/custom-element.tsx +2 -2
- package/src/inspector/viewer/new-app.tsx +1 -1
- package/src/media/create-image.test.ts +7 -7
- package/src/media/create-image.ts +5 -3
- package/src/media/index.ts +1 -1
- package/src/media/utils.test.ts +72 -66
- package/src/media/utils.ts +9 -6
- package/src/prosemirror/lib/plugin.ts +1 -1
- package/src/prosemirror/lib/sync.ts +1 -1
- package/src/prosemirror/tests/plugin.test.ts +4 -4
- package/src/react/media/image.tsx +2 -2
- package/src/react/tests/media/image.test.tsx +52 -32
- package/src/react-core/hooks.ts +11 -5
- package/src/react-core/tests/useAccount.test.ts +16 -22
- package/src/react-core/tests/useCoState.test.ts +19 -19
- package/src/react-core/tests/useInboxSender.test.ts +5 -2
- package/src/react-core/tests/usePassPhraseAuth.test.ts +6 -6
- package/src/react-native-core/media/image.tsx +1 -1
- package/src/svelte/jazz.class.svelte.ts +1 -1
- package/src/svelte/media/image.svelte +3 -9
- package/src/svelte/media/image.types.ts +7 -0
- package/src/svelte/tests/media/image.svelte.test.ts +34 -32
- package/src/tools/auth/DemoAuth.ts +2 -2
- package/src/tools/auth/PassphraseAuth.ts +2 -2
- package/src/tools/auth/clerk/index.ts +2 -2
- package/src/tools/auth/clerk/tests/JazzClerkAuth.test.ts +1 -1
- package/src/tools/coValues/CoFieldInit.ts +20 -0
- package/src/tools/coValues/CoValueBase.ts +40 -60
- package/src/tools/coValues/account.ts +306 -232
- package/src/tools/coValues/coFeed.ts +185 -153
- package/src/tools/coValues/coList.ts +507 -334
- package/src/tools/coValues/coMap.ts +420 -286
- package/src/tools/coValues/coPlainText.ts +94 -110
- package/src/tools/coValues/deepLoading.ts +13 -13
- package/src/tools/coValues/group.ts +100 -114
- package/src/tools/coValues/inbox.ts +16 -14
- package/src/tools/coValues/interfaces.ts +49 -31
- package/src/tools/coValues/profile.ts +8 -6
- package/src/tools/coValues/request.ts +9 -9
- package/src/tools/coValues/schemaUnion.ts +11 -5
- package/src/tools/exports.ts +1 -1
- package/src/tools/implementation/ContextManager.ts +4 -4
- package/src/tools/implementation/anonymousJazzAgent.ts +2 -1
- package/src/tools/implementation/createContext.ts +1 -1
- package/src/tools/implementation/devtoolsFormatters.ts +9 -9
- package/src/tools/implementation/invites.ts +2 -2
- package/src/tools/implementation/schema.ts +7 -7
- package/src/tools/implementation/symbols.ts +3 -0
- package/src/tools/implementation/zodSchema/schemaTypes/AccountSchema.ts +2 -2
- package/src/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.ts +11 -2
- package/src/tools/implementation/zodSchema/schemaTypes/CoListSchema.ts +18 -7
- package/src/tools/implementation/zodSchema/schemaTypes/CoMapSchema.ts +17 -7
- package/src/tools/implementation/zodSchema/schemaTypes/CoRecordSchema.ts +20 -11
- package/src/tools/implementation/zodSchema/schemaTypes/FileStreamSchema.ts +19 -2
- package/src/tools/implementation/zodSchema/schemaTypes/PlainTextSchema.ts +6 -0
- package/src/tools/implementation/zodSchema/schemaTypes/RichTextSchema.ts +6 -0
- package/src/tools/implementation/zodSchema/typeConverters/{CoFieldInit.ts → CoFieldSchemaInit.ts} +11 -11
- package/src/tools/implementation/zodSchema/typeConverters/InstanceOfSchema.ts +4 -4
- package/src/tools/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.ts +4 -4
- package/src/tools/implementation/zodSchema/zodCo.ts +47 -10
- package/src/tools/internal.ts +2 -1
- package/src/tools/lib/migration.ts +5 -5
- package/src/tools/subscribe/SubscriptionScope.ts +32 -24
- package/src/tools/subscribe/index.ts +4 -4
- package/src/tools/subscribe/utils.ts +11 -11
- package/src/tools/testing.ts +17 -13
- package/src/tools/tests/ContextManager.test.ts +68 -57
- package/src/tools/tests/PassphraseAuth.test.ts +2 -2
- package/src/tools/tests/account.test.ts +154 -74
- package/src/tools/tests/coDiscriminatedUnion.test-d.ts +12 -6
- package/src/tools/tests/coDiscriminatedUnion.test.ts +26 -17
- package/src/tools/tests/coFeed.test-d.ts +18 -17
- package/src/tools/tests/coFeed.test.ts +108 -97
- package/src/tools/tests/coList.test-d.ts +18 -23
- package/src/tools/tests/coList.test.ts +350 -165
- package/src/tools/tests/coMap.record.test-d.ts +9 -13
- package/src/tools/tests/coMap.record.test.ts +37 -23
- package/src/tools/tests/coMap.test-d.ts +43 -21
- package/src/tools/tests/coMap.test.ts +368 -182
- package/src/tools/tests/coOptional.test.ts +28 -13
- package/src/tools/tests/coPlainText.test.ts +15 -15
- package/src/tools/tests/createContext.test.ts +14 -14
- package/src/tools/tests/deepLoading.test.ts +95 -94
- package/src/tools/tests/exportImport.test.ts +61 -41
- package/src/tools/tests/groupsAndAccounts.test.ts +333 -116
- package/src/tools/tests/inbox.test.ts +22 -17
- package/src/tools/tests/interfaces.test.ts +12 -11
- package/src/tools/tests/invites.test.ts +6 -4
- package/src/tools/tests/load.test.ts +20 -18
- package/src/tools/tests/patterns/notifications.test.ts +6 -6
- package/src/tools/tests/patterns/quest.test.ts +3 -3
- package/src/tools/tests/patterns/requestToJoin.test.ts +22 -22
- package/src/tools/tests/request.test.ts +38 -39
- package/src/tools/tests/schemaUnion.test.ts +64 -10
- package/src/tools/tests/subscribe.test.ts +64 -64
- package/src/tools/tests/testing.test.ts +5 -9
- package/src/tools/tests/utils.ts +3 -3
- package/src/tools/tests/zod.test.ts +3 -3
- package/src/worker/index.ts +3 -3
- package/dist/chunk-SFP5PBPX.js.map +0 -1
- package/dist/media/chunk-E5J3WLQW.js.map +0 -1
- package/dist/tools/implementation/zodSchema/typeConverters/CoFieldInit.d.ts.map +0 -1
@@ -11,9 +11,12 @@ describe("Inbox", () => {
|
|
11
11
|
describe("Private profile", () => {
|
12
12
|
it("Should throw if the inbox owner profile is private", async () => {
|
13
13
|
const WorkerAccount = co.account().withMigration((account) => {
|
14
|
-
account.
|
15
|
-
|
16
|
-
|
14
|
+
account.$jazz.set(
|
15
|
+
"profile",
|
16
|
+
co
|
17
|
+
.profile()
|
18
|
+
.create({ name: "Worker" }, Group.create({ owner: account })),
|
19
|
+
);
|
17
20
|
});
|
18
21
|
|
19
22
|
const { clientAccount: sender, serverAccount: receiver } =
|
@@ -22,7 +25,9 @@ describe("Inbox", () => {
|
|
22
25
|
coValueClassFromCoValueClassOrSchema(WorkerAccount),
|
23
26
|
});
|
24
27
|
|
25
|
-
await expect(() =>
|
28
|
+
await expect(() =>
|
29
|
+
InboxSender.load(receiver.$jazz.id, sender),
|
30
|
+
).rejects.toThrow(
|
26
31
|
"Insufficient permissions to access the inbox, make sure its user profile is publicly readable.",
|
27
32
|
);
|
28
33
|
});
|
@@ -43,7 +48,7 @@ describe("Inbox", () => {
|
|
43
48
|
);
|
44
49
|
|
45
50
|
// Setup inbox sender
|
46
|
-
const inboxSender = await InboxSender.load(receiver.id, sender);
|
51
|
+
const inboxSender = await InboxSender.load(receiver.$jazz.id, sender);
|
47
52
|
inboxSender.sendMessage(message);
|
48
53
|
|
49
54
|
// Track received messages
|
@@ -64,7 +69,7 @@ describe("Inbox", () => {
|
|
64
69
|
|
65
70
|
expect(receivedMessages.length).toBe(1);
|
66
71
|
expect(receivedMessages[0]?.text).toBe("Hello");
|
67
|
-
expect(senderAccountID).toBe(sender.id);
|
72
|
+
expect(senderAccountID).toBe(sender.$jazz.id);
|
68
73
|
|
69
74
|
unsubscribe();
|
70
75
|
});
|
@@ -86,7 +91,7 @@ describe("Inbox", () => {
|
|
86
91
|
);
|
87
92
|
|
88
93
|
// Setup inbox sender
|
89
|
-
const inboxSender = await InboxSender.load(receiver.id, sender);
|
94
|
+
const inboxSender = await InboxSender.load(receiver.$jazz.id, sender);
|
90
95
|
inboxSender.sendMessage(message);
|
91
96
|
|
92
97
|
// Track received messages
|
@@ -106,8 +111,8 @@ describe("Inbox", () => {
|
|
106
111
|
await waitFor(() => receivedMessages.length === 1);
|
107
112
|
|
108
113
|
expect(receivedMessages.length).toBe(1);
|
109
|
-
expect(receivedMessages[0]
|
110
|
-
expect(senderAccountID).toBe(sender.id);
|
114
|
+
expect(receivedMessages[0]?.$jazz.id).toBe(message.$jazz.id);
|
115
|
+
expect(senderAccountID).toBe(sender.$jazz.id);
|
111
116
|
|
112
117
|
unsubscribe();
|
113
118
|
});
|
@@ -129,7 +134,7 @@ describe("Inbox", () => {
|
|
129
134
|
const unsubscribe = receiverInbox.subscribe(Message, async (message) => {
|
130
135
|
return Message.create(
|
131
136
|
{ text: "Responded from the inbox" },
|
132
|
-
{ owner: message.
|
137
|
+
{ owner: message.$jazz.owner },
|
133
138
|
);
|
134
139
|
});
|
135
140
|
|
@@ -137,7 +142,7 @@ describe("Inbox", () => {
|
|
137
142
|
const inboxSender = await InboxSender.load<
|
138
143
|
Loaded<typeof Message>,
|
139
144
|
Loaded<typeof Message>
|
140
|
-
>(receiver.id, sender);
|
145
|
+
>(receiver.$jazz.id, sender);
|
141
146
|
const resultId = await inboxSender.sendMessage(message);
|
142
147
|
|
143
148
|
const result = await Message.load(resultId, { loadAs: receiver });
|
@@ -164,7 +169,7 @@ describe("Inbox", () => {
|
|
164
169
|
|
165
170
|
// Setup inbox sender
|
166
171
|
const inboxSender = await InboxSender.load<Loaded<typeof Message>>(
|
167
|
-
receiver.id,
|
172
|
+
receiver.$jazz.id,
|
168
173
|
sender,
|
169
174
|
);
|
170
175
|
const result = await inboxSender.sendMessage(message);
|
@@ -196,7 +201,7 @@ describe("Inbox", () => {
|
|
196
201
|
|
197
202
|
// Setup inbox sender
|
198
203
|
const inboxSender = await InboxSender.load<Loaded<typeof Message>>(
|
199
|
-
receiver.id,
|
204
|
+
receiver.$jazz.id,
|
200
205
|
sender,
|
201
206
|
);
|
202
207
|
|
@@ -229,7 +234,7 @@ describe("Inbox", () => {
|
|
229
234
|
);
|
230
235
|
|
231
236
|
// Setup inbox sender
|
232
|
-
const inboxSender = await InboxSender.load(receiver.id, sender);
|
237
|
+
const inboxSender = await InboxSender.load(receiver.$jazz.id, sender);
|
233
238
|
inboxSender.sendMessage(message);
|
234
239
|
|
235
240
|
// Track received messages
|
@@ -269,7 +274,7 @@ describe("Inbox", () => {
|
|
269
274
|
);
|
270
275
|
|
271
276
|
// Setup inbox sender
|
272
|
-
const inboxSender = await InboxSender.load(receiver.id, sender);
|
277
|
+
const inboxSender = await InboxSender.load(receiver.$jazz.id, sender);
|
273
278
|
inboxSender.sendMessage(message);
|
274
279
|
|
275
280
|
// Track received messages
|
@@ -309,7 +314,7 @@ describe("Inbox", () => {
|
|
309
314
|
const errorLogSpy = vi.spyOn(console, "error").mockImplementation(() => {});
|
310
315
|
|
311
316
|
// Setup inbox sender
|
312
|
-
const inboxSender = await InboxSender.load(receiver.id, sender);
|
317
|
+
const inboxSender = await InboxSender.load(receiver.$jazz.id, sender);
|
313
318
|
const promise = inboxSender.sendMessage(message);
|
314
319
|
|
315
320
|
let failures = 0;
|
@@ -344,7 +349,7 @@ describe("Inbox", () => {
|
|
344
349
|
|
345
350
|
const receiverInbox = await Inbox.load(receiver);
|
346
351
|
|
347
|
-
const inboxSender = await InboxSender.load(receiver.id, sender);
|
352
|
+
const inboxSender = await InboxSender.load(receiver.$jazz.id, sender);
|
348
353
|
inboxSender.messages.push(`co_z123234` as any);
|
349
354
|
|
350
355
|
const spy = vi.fn();
|
@@ -4,6 +4,7 @@ import { Account } from "../exports";
|
|
4
4
|
import {
|
5
5
|
parseCoValueCreateOptions,
|
6
6
|
parseGroupCreateOptions,
|
7
|
+
TypeSym,
|
7
8
|
} from "../internal";
|
8
9
|
import { createJazzTestAccount } from "../testing";
|
9
10
|
|
@@ -16,17 +17,17 @@ beforeEach(async () => {
|
|
16
17
|
describe("parseCoValueCreateOptions", () => {
|
17
18
|
it("should create a new group when no options provided", () => {
|
18
19
|
const result = parseCoValueCreateOptions(undefined);
|
19
|
-
expect(result.owner
|
20
|
-
expect(
|
21
|
-
|
22
|
-
)
|
20
|
+
expect(result.owner[TypeSym]).toBe("Group");
|
21
|
+
expect(result.owner.$jazz.raw.roleOf(Account.getMe().$jazz.raw.id)).toBe(
|
22
|
+
"admin",
|
23
|
+
);
|
23
24
|
expect(result.uniqueness).toBeUndefined();
|
24
25
|
});
|
25
26
|
|
26
|
-
it("should
|
27
|
+
it("should create a group that wraps a RawAccount as the owner when passing an Account", async () => {
|
27
28
|
const account = await createJazzTestAccount();
|
28
29
|
const result = parseCoValueCreateOptions(account);
|
29
|
-
expect(result.owner).toBe(account);
|
30
|
+
expect(result.owner.$jazz.id).toBe(account.$jazz.raw.id);
|
30
31
|
expect(result.uniqueness).toBeUndefined();
|
31
32
|
});
|
32
33
|
|
@@ -34,9 +35,9 @@ describe("parseCoValueCreateOptions", () => {
|
|
34
35
|
const group = Group.create();
|
35
36
|
const result = parseCoValueCreateOptions(group);
|
36
37
|
expect(result.owner).toBe(group);
|
37
|
-
expect(
|
38
|
-
|
39
|
-
)
|
38
|
+
expect(result.owner.$jazz.raw.roleOf(Account.getMe().$jazz.raw.id)).toBe(
|
39
|
+
"admin",
|
40
|
+
);
|
40
41
|
expect(result.uniqueness).toBeUndefined();
|
41
42
|
});
|
42
43
|
|
@@ -50,13 +51,13 @@ describe("parseCoValueCreateOptions", () => {
|
|
50
51
|
expect(result.uniqueness?.uniqueness).toBe("per-group");
|
51
52
|
});
|
52
53
|
|
53
|
-
it("should
|
54
|
+
it("should create a group that wraps a RawAccount as the owner when passing an Account inside options", async () => {
|
54
55
|
const account = await createJazzTestAccount();
|
55
56
|
const result = parseCoValueCreateOptions({
|
56
57
|
owner: account,
|
57
58
|
unique: "per-group",
|
58
59
|
});
|
59
|
-
expect(result.owner).toBe(account);
|
60
|
+
expect(result.owner.$jazz.id).toBe(account.$jazz.raw.id);
|
60
61
|
expect(result.uniqueness?.uniqueness).toBe("per-group");
|
61
62
|
});
|
62
63
|
});
|
@@ -24,7 +24,7 @@ describe("Invite Links", () => {
|
|
24
24
|
const inviteLink = createInviteLink(group, "writer", baseURL);
|
25
25
|
|
26
26
|
expect(inviteLink).toMatch(
|
27
|
-
new RegExp(`^${baseURL}#/invite/${group.id}/[A-Za-z0-9_-]+$`),
|
27
|
+
new RegExp(`^${baseURL}#/invite/${group.$jazz.id}/[A-Za-z0-9_-]+$`),
|
28
28
|
);
|
29
29
|
});
|
30
30
|
|
@@ -32,7 +32,9 @@ describe("Invite Links", () => {
|
|
32
32
|
const inviteLink = createInviteLink(group, "writer", baseURL, "myGroup");
|
33
33
|
|
34
34
|
expect(inviteLink).toMatch(
|
35
|
-
new RegExp(
|
35
|
+
new RegExp(
|
36
|
+
`^${baseURL}#/invite/myGroup/${group.$jazz.id}/[A-Za-z0-9_-]+$`,
|
37
|
+
),
|
36
38
|
);
|
37
39
|
});
|
38
40
|
|
@@ -41,7 +43,7 @@ describe("Invite Links", () => {
|
|
41
43
|
const result = parseInviteLink(inviteLink);
|
42
44
|
|
43
45
|
expect(result).toBeDefined();
|
44
|
-
expect(result?.valueID).toBe(group.id);
|
46
|
+
expect(result?.valueID).toBe(group.$jazz.id);
|
45
47
|
expect(result?.valueHint).toBe("myGroup");
|
46
48
|
expect(result?.inviteSecret).toBeDefined();
|
47
49
|
});
|
@@ -65,7 +67,7 @@ describe("Invite Links", () => {
|
|
65
67
|
});
|
66
68
|
|
67
69
|
expect(result).toBeDefined();
|
68
|
-
expect(result?.valueID).toBe(group.id);
|
70
|
+
expect(result?.valueID).toBe(group.$jazz.id);
|
69
71
|
expect(result?.valueHint).toBe("myGroup");
|
70
72
|
});
|
71
73
|
|
@@ -28,7 +28,7 @@ test("load a value", async () => {
|
|
28
28
|
|
29
29
|
const alice = await createJazzTestAccount();
|
30
30
|
|
31
|
-
const john = await Person.load(map.id, { loadAs: alice });
|
31
|
+
const john = await Person.load(map.$jazz.id, { loadAs: alice });
|
32
32
|
expect(john).not.toBeNull();
|
33
33
|
expect(john?.name).toBe("John");
|
34
34
|
});
|
@@ -58,7 +58,7 @@ test("load a missing optional value (co.optional)", async () => {
|
|
58
58
|
|
59
59
|
const alice = await createJazzTestAccount();
|
60
60
|
|
61
|
-
const john = await Person.load(map.id, {
|
61
|
+
const john = await Person.load(map.$jazz.id, {
|
62
62
|
loadAs: alice,
|
63
63
|
resolve: { dog: true },
|
64
64
|
});
|
@@ -85,7 +85,7 @@ test("load a missing optional value (Schema.optional)", async () => {
|
|
85
85
|
|
86
86
|
const alice = await createJazzTestAccount();
|
87
87
|
|
88
|
-
const john = await Person.load(map.id, {
|
88
|
+
const john = await Person.load(map.$jazz.id, {
|
89
89
|
loadAs: alice,
|
90
90
|
resolve: { dog: true },
|
91
91
|
});
|
@@ -118,7 +118,7 @@ test("load a missing optional value (optional discrminatedUnion)", async () => {
|
|
118
118
|
|
119
119
|
const alice = await createJazzTestAccount();
|
120
120
|
|
121
|
-
const john = await Person.load(map.id, {
|
121
|
+
const john = await Person.load(map.$jazz.id, {
|
122
122
|
loadAs: alice,
|
123
123
|
resolve: { pet: true },
|
124
124
|
});
|
@@ -137,9 +137,11 @@ test("retry an unavailable value", async () => {
|
|
137
137
|
const currentAccount = Account.getMe();
|
138
138
|
|
139
139
|
// Disconnect the current account
|
140
|
-
currentAccount.
|
141
|
-
|
142
|
-
|
140
|
+
currentAccount.$jazz.localNode.syncManager
|
141
|
+
.getClientPeers()
|
142
|
+
.forEach((peer) => {
|
143
|
+
peer.gracefulShutdown();
|
144
|
+
});
|
143
145
|
|
144
146
|
const group = Group.create();
|
145
147
|
const map = Person.create({ name: "John" }, group);
|
@@ -147,12 +149,12 @@ test("retry an unavailable value", async () => {
|
|
147
149
|
|
148
150
|
const alice = await createJazzTestAccount();
|
149
151
|
|
150
|
-
const promise = Person.load(map.id, { loadAs: alice });
|
152
|
+
const promise = Person.load(map.$jazz.id, { loadAs: alice });
|
151
153
|
|
152
154
|
await new Promise((resolve) => setTimeout(resolve));
|
153
155
|
|
154
156
|
// Reconnect the current account
|
155
|
-
currentAccount.
|
157
|
+
currentAccount.$jazz.localNode.syncManager.addPeer(
|
156
158
|
getPeerConnectedToTestSyncServer(),
|
157
159
|
);
|
158
160
|
|
@@ -169,8 +171,8 @@ test("returns null if the value is unavailable after retries", async () => {
|
|
169
171
|
const currentAccount = Account.getMe();
|
170
172
|
|
171
173
|
// Disconnect the current account
|
172
|
-
currentAccount.
|
173
|
-
.getServerPeers(currentAccount.
|
174
|
+
currentAccount.$jazz.localNode.syncManager
|
175
|
+
.getServerPeers(currentAccount.$jazz.raw.id)
|
174
176
|
.forEach((peer) => {
|
175
177
|
peer.gracefulShutdown();
|
176
178
|
});
|
@@ -181,7 +183,7 @@ test("returns null if the value is unavailable after retries", async () => {
|
|
181
183
|
|
182
184
|
const alice = await createJazzTestAccount();
|
183
185
|
|
184
|
-
const john = await Person.load(map.id, { loadAs: alice });
|
186
|
+
const john = await Person.load(map.$jazz.id, { loadAs: alice });
|
185
187
|
|
186
188
|
expect(john).toBeNull();
|
187
189
|
});
|
@@ -199,7 +201,7 @@ test("load works even when the coValue access is granted after the creation", as
|
|
199
201
|
|
200
202
|
group.addMember("everyone", "reader");
|
201
203
|
|
202
|
-
const mapOnBob = await Person.load(map.id, { loadAs: bob });
|
204
|
+
const mapOnBob = await Person.load(map.$jazz.id, { loadAs: bob });
|
203
205
|
|
204
206
|
expect(mapOnBob).not.toBeNull();
|
205
207
|
expect(mapOnBob?.name).toBe("John");
|
@@ -240,16 +242,16 @@ test("load a large coValue", async () => {
|
|
240
242
|
const value = "x".repeat(chunkSize);
|
241
243
|
|
242
244
|
for (let i = 0; i < chunks; i++) {
|
243
|
-
largeMap.data.push(value);
|
245
|
+
largeMap.data.$jazz.push(value);
|
244
246
|
}
|
245
247
|
|
246
248
|
// Wait for the large coValue to be fully synced
|
247
|
-
await largeMap.data.
|
249
|
+
await largeMap.data.$jazz.raw.core.waitForSync();
|
248
250
|
|
249
251
|
const alice = await createJazzTestAccount();
|
250
252
|
|
251
253
|
// Test loading the large coValue
|
252
|
-
const loadedDataset = await LargeDataset.load(largeMap.id, {
|
254
|
+
const loadedDataset = await LargeDataset.load(largeMap.$jazz.id, {
|
253
255
|
loadAs: alice,
|
254
256
|
resolve: {
|
255
257
|
data: true,
|
@@ -264,7 +266,7 @@ test("load a large coValue", async () => {
|
|
264
266
|
);
|
265
267
|
|
266
268
|
expect(loadedDataset.data.length).toBe(chunks);
|
267
|
-
expect(loadedDataset.data.
|
268
|
-
largeMap.data.
|
269
|
+
expect(loadedDataset.data.$jazz.raw.core.knownState()).toEqual(
|
270
|
+
largeMap.data.$jazz.raw.core.knownState(),
|
269
271
|
);
|
270
272
|
});
|
@@ -18,8 +18,8 @@ const WorkerAccount = co
|
|
18
18
|
})
|
19
19
|
.withMigration((account) => {
|
20
20
|
if (account.root === undefined) {
|
21
|
-
account.root
|
22
|
-
notificationQueue:
|
21
|
+
account.$jazz.set("root", {
|
22
|
+
notificationQueue: [],
|
23
23
|
});
|
24
24
|
}
|
25
25
|
});
|
@@ -28,7 +28,7 @@ async function pushNotification(
|
|
28
28
|
worker: InstanceOfSchema<typeof WorkerAccount>,
|
29
29
|
content: string,
|
30
30
|
) {
|
31
|
-
const workerAccount = await worker.ensureLoaded({
|
31
|
+
const workerAccount = await worker.$jazz.ensureLoaded({
|
32
32
|
resolve: {
|
33
33
|
root: {
|
34
34
|
notificationQueue: {
|
@@ -43,7 +43,7 @@ async function pushNotification(
|
|
43
43
|
sent: false,
|
44
44
|
});
|
45
45
|
|
46
|
-
workerAccount.root.notificationQueue.push(notification);
|
46
|
+
workerAccount.root.notificationQueue.$jazz.push(notification);
|
47
47
|
|
48
48
|
return notification;
|
49
49
|
}
|
@@ -52,7 +52,7 @@ async function sendAllThePendingNotifications(
|
|
52
52
|
worker: InstanceOfSchema<typeof WorkerAccount>,
|
53
53
|
sender: (notification: Loaded<typeof QueuedNotification>) => Promise<void>,
|
54
54
|
) {
|
55
|
-
const workerAccount = await worker.ensureLoaded({
|
55
|
+
const workerAccount = await worker.$jazz.ensureLoaded({
|
56
56
|
resolve: {
|
57
57
|
root: {
|
58
58
|
notificationQueue: {
|
@@ -64,7 +64,7 @@ async function sendAllThePendingNotifications(
|
|
64
64
|
|
65
65
|
for (const notification of workerAccount.root.notificationQueue) {
|
66
66
|
if (!notification.sent) {
|
67
|
-
notification.sent
|
67
|
+
notification.$jazz.set("sent", true);
|
68
68
|
await sender(notification);
|
69
69
|
}
|
70
70
|
}
|
@@ -19,7 +19,7 @@ const QuestSchema = co
|
|
19
19
|
})
|
20
20
|
.withMigration((quest) => {
|
21
21
|
if (quest.categories === undefined) {
|
22
|
-
quest.categories
|
22
|
+
quest.$jazz.set("categories", [quest.category]);
|
23
23
|
}
|
24
24
|
});
|
25
25
|
|
@@ -50,7 +50,7 @@ describe("QuestSchema", () => {
|
|
50
50
|
expect(quest.categories).toBeUndefined();
|
51
51
|
|
52
52
|
// Load the quest to trigger the migration
|
53
|
-
const loadedQuest = await QuestSchema.load(quest.id);
|
53
|
+
const loadedQuest = await QuestSchema.load(quest.$jazz.id);
|
54
54
|
assert(loadedQuest);
|
55
55
|
|
56
56
|
// After loading, the migration should have run and filled categories
|
@@ -75,7 +75,7 @@ describe("QuestSchema", () => {
|
|
75
75
|
expect(quest.categories).toEqual(["combat", "boss-fight", "endgame"]);
|
76
76
|
|
77
77
|
// Load the quest to ensure migration doesn't change existing categories
|
78
|
-
const loadedQuest = await QuestSchema.load(quest.id);
|
78
|
+
const loadedQuest = await QuestSchema.load(quest.$jazz.id);
|
79
79
|
assert(loadedQuest);
|
80
80
|
|
81
81
|
// Categories should remain unchanged after migration
|
@@ -71,9 +71,9 @@ async function setup() {
|
|
71
71
|
publicGroup,
|
72
72
|
);
|
73
73
|
|
74
|
-
const organizationId = organization.id;
|
74
|
+
const organizationId = organization.$jazz.id;
|
75
75
|
|
76
|
-
await admin1.waitForAllCoValuesSync();
|
76
|
+
await admin1.$jazz.waitForAllCoValuesSync();
|
77
77
|
|
78
78
|
return {
|
79
79
|
admin1,
|
@@ -105,9 +105,9 @@ async function sendRequestToJoin(organizationId: string, account: Account) {
|
|
105
105
|
group,
|
106
106
|
);
|
107
107
|
|
108
|
-
organization.requests
|
108
|
+
organization.requests.$jazz.set(account.$jazz.id, request);
|
109
109
|
|
110
|
-
await account.waitForAllCoValuesSync();
|
110
|
+
await account.$jazz.waitForAllCoValuesSync();
|
111
111
|
|
112
112
|
return request;
|
113
113
|
}
|
@@ -126,11 +126,11 @@ async function approveRequest(
|
|
126
126
|
throw new Error("Organization not found");
|
127
127
|
}
|
128
128
|
|
129
|
-
const request = organization.requests[user.id];
|
129
|
+
const request = organization.requests[user.$jazz.id];
|
130
130
|
|
131
131
|
if (
|
132
|
-
organization.statuses[user.id] === "approved" ||
|
133
|
-
organization.statuses[user.id] === "rejected"
|
132
|
+
organization.statuses[user.$jazz.id] === "approved" ||
|
133
|
+
organization.statuses[user.$jazz.id] === "rejected"
|
134
134
|
) {
|
135
135
|
throw new Error("Request already processed");
|
136
136
|
}
|
@@ -139,12 +139,12 @@ async function approveRequest(
|
|
139
139
|
throw new Error("Request not found");
|
140
140
|
}
|
141
141
|
|
142
|
-
request.status
|
143
|
-
organization.statuses
|
142
|
+
request.$jazz.set("status", "approved");
|
143
|
+
organization.statuses.$jazz.set(user.$jazz.id, "approved");
|
144
144
|
|
145
145
|
organization.mainGroup.addMember(user, "writer");
|
146
146
|
|
147
|
-
await admin.waitForAllCoValuesSync();
|
147
|
+
await admin.$jazz.waitForAllCoValuesSync();
|
148
148
|
}
|
149
149
|
|
150
150
|
async function rejectRequest(
|
@@ -161,11 +161,11 @@ async function rejectRequest(
|
|
161
161
|
throw new Error("Organization not found");
|
162
162
|
}
|
163
163
|
|
164
|
-
const request = organization.requests[user.id];
|
164
|
+
const request = organization.requests[user.$jazz.id];
|
165
165
|
|
166
166
|
if (
|
167
|
-
organization.statuses[user.id] === "approved" ||
|
168
|
-
organization.statuses[user.id] === "rejected"
|
167
|
+
organization.statuses[user.$jazz.id] === "approved" ||
|
168
|
+
organization.statuses[user.$jazz.id] === "rejected"
|
169
169
|
) {
|
170
170
|
throw new Error("Request already processed");
|
171
171
|
}
|
@@ -174,10 +174,10 @@ async function rejectRequest(
|
|
174
174
|
throw new Error("Request not found");
|
175
175
|
}
|
176
176
|
|
177
|
-
request.status
|
178
|
-
organization.statuses
|
177
|
+
request.$jazz.set("status", "rejected");
|
178
|
+
organization.statuses.$jazz.set(user.$jazz.id, "rejected");
|
179
179
|
|
180
|
-
await admin.waitForAllCoValuesSync();
|
180
|
+
await admin.$jazz.waitForAllCoValuesSync();
|
181
181
|
}
|
182
182
|
|
183
183
|
describe("Request to join", () => {
|
@@ -201,13 +201,13 @@ describe("Request to join", () => {
|
|
201
201
|
|
202
202
|
const projectsOnUser = await co
|
203
203
|
.list(z.string())
|
204
|
-
.load(organization.projects.id, {
|
204
|
+
.load(organization.projects.$jazz.id, {
|
205
205
|
loadAs: user1,
|
206
206
|
});
|
207
207
|
|
208
208
|
assert(projectsOnUser);
|
209
209
|
|
210
|
-
projectsOnUser.push("project1");
|
210
|
+
projectsOnUser.$jazz.push("project1");
|
211
211
|
|
212
212
|
expect(projectsOnUser[0]).toBe("project1");
|
213
213
|
});
|
@@ -231,7 +231,7 @@ describe("Request to join", () => {
|
|
231
231
|
|
232
232
|
const projectsOnUser = await co
|
233
233
|
.list(z.string())
|
234
|
-
.load(organization.projects.id, {
|
234
|
+
.load(organization.projects.$jazz.id, {
|
235
235
|
loadAs: user1,
|
236
236
|
});
|
237
237
|
|
@@ -250,8 +250,8 @@ describe("Request to join", () => {
|
|
250
250
|
});
|
251
251
|
|
252
252
|
assert(organization);
|
253
|
-
expect(organization.statuses[user1.id]).toBe("approved");
|
254
|
-
const requestOnAdmin2 = await RequestToJoin.load(request.id, {
|
253
|
+
expect(organization.statuses[user1.$jazz.id]).toBe("approved");
|
254
|
+
const requestOnAdmin2 = await RequestToJoin.load(request.$jazz.id, {
|
255
255
|
loadAs: admin2,
|
256
256
|
});
|
257
257
|
assert(requestOnAdmin2);
|
@@ -263,7 +263,7 @@ describe("Request to join", () => {
|
|
263
263
|
|
264
264
|
const request = await sendRequestToJoin(organizationId, user1);
|
265
265
|
|
266
|
-
const requestOnUser2 = await RequestToJoin.load(request.id, {
|
266
|
+
const requestOnUser2 = await RequestToJoin.load(request.$jazz.id, {
|
267
267
|
loadAs: user2,
|
268
268
|
});
|
269
269
|
|