jazz-tools 0.17.14 → 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 +50 -50
- package/CHANGELOG.md +31 -0
- package/dist/browser/index.js +2 -2
- package/dist/browser/index.js.map +1 -1
- package/dist/{chunk-LZOF6WP5.js → chunk-HJ3GTGY7.js} +1320 -1018
- 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 +2 -2
- 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 +139 -69
- 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 +360 -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-LZOF6WP5.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
@@ -18,58 +18,48 @@ import {
|
|
18
18
|
} from "../index.js";
|
19
19
|
import { createJazzTestAccount, setupJazzTestSync } from "../testing.js";
|
20
20
|
import { setupTwoNodes } from "./utils.js";
|
21
|
+
import { CoFeed, ControlledAccount, TypeSym } from "../internal.js";
|
21
22
|
|
22
23
|
const Crypto = await WasmCrypto.create();
|
23
24
|
|
24
|
-
let me
|
25
|
-
creationProps: { name: "Hermes Puggington" },
|
26
|
-
crypto: Crypto,
|
27
|
-
});
|
25
|
+
let me: ControlledAccount;
|
28
26
|
|
29
27
|
beforeEach(async () => {
|
30
28
|
await setupJazzTestSync();
|
31
|
-
|
32
|
-
me = await createJazzTestAccount({
|
29
|
+
const account = await createJazzTestAccount({
|
33
30
|
isCurrentActiveAccount: true,
|
34
31
|
creationProps: { name: "Hermes Puggington" },
|
35
32
|
});
|
33
|
+
if (!isControlledAccount(account)) {
|
34
|
+
throw new Error("account is not a controlled account");
|
35
|
+
}
|
36
|
+
me = account;
|
36
37
|
});
|
37
38
|
|
38
39
|
describe("Simple CoFeed operations", async () => {
|
39
|
-
|
40
|
-
|
41
|
-
crypto: Crypto,
|
42
|
-
});
|
43
|
-
if (!isControlledAccount(me)) {
|
44
|
-
throw "me is not a controlled account";
|
45
|
-
}
|
46
|
-
const TestStream = co.feed(z.string());
|
40
|
+
let TestStream: co.Feed<z.z.ZodString>;
|
41
|
+
let stream: CoFeed<string>;
|
47
42
|
|
48
|
-
|
43
|
+
beforeEach(async () => {
|
44
|
+
TestStream = co.feed(z.string());
|
45
|
+
stream = TestStream.create(["milk"], { owner: me });
|
46
|
+
});
|
49
47
|
|
50
48
|
test("Construction", () => {
|
51
|
-
expect(stream.perAccount[me.id]?.value).toEqual("milk");
|
52
|
-
expect(stream.perSession[me.sessionID]?.value).toEqual("milk");
|
49
|
+
expect(stream.perAccount[me.$jazz.id]?.value).toEqual("milk");
|
50
|
+
expect(stream.perSession[me.$jazz.sessionID]?.value).toEqual("milk");
|
53
51
|
});
|
54
52
|
|
55
53
|
describe("Create CoFeed with a reference", () => {
|
56
|
-
let me: Account;
|
57
|
-
|
58
|
-
beforeEach(async () => {
|
59
|
-
await setupJazzTestSync();
|
60
|
-
me = await createJazzTestAccount({
|
61
|
-
isCurrentActiveAccount: true,
|
62
|
-
creationProps: { name: "Hermes Puggington" },
|
63
|
-
});
|
64
|
-
});
|
65
|
-
|
66
54
|
test("using a CoValue", () => {
|
67
55
|
const Text = co.plainText();
|
68
56
|
const TextStream = co.feed(Text);
|
69
57
|
|
70
|
-
const stream = TextStream.create([Text.create("milk")], {
|
58
|
+
const stream = TextStream.create([Text.create("milk")], {
|
59
|
+
owner: me,
|
60
|
+
});
|
71
61
|
|
72
|
-
const coValue = stream.perAccount[me.id]?.value;
|
62
|
+
const coValue = stream.perAccount[me.$jazz.id]?.value;
|
73
63
|
expect(coValue?.toString()).toEqual("milk");
|
74
64
|
});
|
75
65
|
|
@@ -80,14 +70,14 @@ describe("Simple CoFeed operations", async () => {
|
|
80
70
|
|
81
71
|
const stream = TextStream.create(["milk"], { owner: me });
|
82
72
|
|
83
|
-
const coValue = stream.perAccount[me.id]?.value;
|
73
|
+
const coValue = stream.perAccount[me.$jazz.id]?.value;
|
84
74
|
expect(coValue?.toString()).toEqual("milk");
|
85
75
|
});
|
86
76
|
|
87
77
|
test("can create a coPlainText from an empty string", () => {
|
88
78
|
const Schema = co.feed(co.plainText());
|
89
79
|
const feed = Schema.create([""]);
|
90
|
-
expect(feed.perAccount[me.id]?.value?.toString()).toBe("");
|
80
|
+
expect(feed.perAccount[me.$jazz.id]?.value?.toString()).toBe("");
|
91
81
|
});
|
92
82
|
});
|
93
83
|
});
|
@@ -96,34 +86,58 @@ describe("Simple CoFeed operations", async () => {
|
|
96
86
|
const NullableTestStream = co.feed(z.string().nullable());
|
97
87
|
const stream = NullableTestStream.create(["milk", null], { owner: me });
|
98
88
|
|
99
|
-
expect(stream.perAccount[me.id]?.value).toEqual(null);
|
100
|
-
expect(stream.perSession[me.sessionID]?.value).toEqual(null);
|
89
|
+
expect(stream.perAccount[me.$jazz.id]?.value).toEqual(null);
|
90
|
+
expect(stream.perSession[me.$jazz.sessionID]?.value).toEqual(null);
|
101
91
|
});
|
102
92
|
|
103
93
|
test("Construction with an Account", () => {
|
104
94
|
const stream = TestStream.create(["milk"], me);
|
105
95
|
|
106
|
-
expect(stream.perAccount[me.id]?.value).toEqual("milk");
|
107
|
-
expect(stream.perSession[me.sessionID]?.value).toEqual("milk");
|
96
|
+
expect(stream.perAccount[me.$jazz.id]?.value).toEqual("milk");
|
97
|
+
expect(stream.perSession[me.$jazz.sessionID]?.value).toEqual("milk");
|
108
98
|
});
|
109
99
|
|
110
100
|
test("Construction with a Group", () => {
|
111
101
|
const group = Group.create(me);
|
112
102
|
const stream = TestStream.create(["milk"], group);
|
113
103
|
|
114
|
-
expect(stream.perAccount[me.id]?.value).toEqual("milk");
|
115
|
-
expect(stream.perSession[me.sessionID]?.value).toEqual("milk");
|
104
|
+
expect(stream.perAccount[me.$jazz.id]?.value).toEqual("milk");
|
105
|
+
expect(stream.perSession[me.$jazz.sessionID]?.value).toEqual("milk");
|
116
106
|
});
|
117
107
|
|
118
108
|
describe("Mutation", () => {
|
119
|
-
test("
|
120
|
-
stream.push("bread");
|
121
|
-
expect(stream.perAccount[me.id]?.value).toEqual("bread");
|
122
|
-
expect(stream.perSession[me.sessionID]?.value).toEqual("bread");
|
109
|
+
test("push element into CoFeed of non-collaborative values", () => {
|
110
|
+
stream.$jazz.push("bread");
|
111
|
+
expect(stream.perAccount[me.$jazz.id]?.value).toEqual("bread");
|
112
|
+
expect(stream.perSession[me.$jazz.sessionID]?.value).toEqual("bread");
|
113
|
+
|
114
|
+
stream.$jazz.push("butter");
|
115
|
+
expect(stream.perAccount[me.$jazz.id]?.value).toEqual("butter");
|
116
|
+
expect(stream.perSession[me.$jazz.sessionID]?.value).toEqual("butter");
|
117
|
+
});
|
118
|
+
|
119
|
+
test("push CoValue into CoFeed of CoValues", () => {
|
120
|
+
const Schema = co.feed(co.plainText());
|
121
|
+
const stream = Schema.create(["milk"]);
|
122
|
+
stream.$jazz.push(Schema.element.create("bread"));
|
123
|
+
expect(stream.perAccount[me.$jazz.id]?.value?.toString()).toEqual(
|
124
|
+
"bread",
|
125
|
+
);
|
126
|
+
expect(stream.perSession[me.$jazz.sessionID]?.value?.toString()).toEqual(
|
127
|
+
"bread",
|
128
|
+
);
|
129
|
+
});
|
123
130
|
|
124
|
-
|
125
|
-
|
126
|
-
|
131
|
+
test("push JSON into CoFeed of CoValues", () => {
|
132
|
+
const Schema = co.feed(co.plainText());
|
133
|
+
const stream = Schema.create(["milk"]);
|
134
|
+
stream.$jazz.push("bread");
|
135
|
+
expect(stream.perAccount[me.$jazz.id]?.value?.toString()).toEqual(
|
136
|
+
"bread",
|
137
|
+
);
|
138
|
+
expect(stream.perSession[me.$jazz.sessionID]?.value?.toString()).toEqual(
|
139
|
+
"bread",
|
140
|
+
);
|
127
141
|
});
|
128
142
|
});
|
129
143
|
});
|
@@ -160,9 +174,8 @@ describe("CoFeed resolution", async () => {
|
|
160
174
|
// expectTypeOf(stream[me.id]).not.toBeAny();
|
161
175
|
|
162
176
|
expect(
|
163
|
-
stream.perAccount[me.id]?.value?.perAccount[me.id]?.value
|
164
|
-
me.id
|
165
|
-
]?.value,
|
177
|
+
stream.perAccount[me.$jazz.id]?.value?.perAccount[me.$jazz.id]?.value
|
178
|
+
?.perAccount[me.$jazz.id]?.value,
|
166
179
|
).toEqual("milk");
|
167
180
|
});
|
168
181
|
|
@@ -171,13 +184,13 @@ describe("CoFeed resolution", async () => {
|
|
171
184
|
|
172
185
|
const anotherAccount = await createJazzTestAccount();
|
173
186
|
|
174
|
-
const loadedStream = await TestStream.load(stream.id, {
|
187
|
+
const loadedStream = await TestStream.load(stream.$jazz.id, {
|
175
188
|
loadAs: anotherAccount,
|
176
189
|
});
|
177
190
|
|
178
191
|
assert(loadedStream);
|
179
192
|
|
180
|
-
const myStream = loadedStream.perAccount[me.id];
|
193
|
+
const myStream = loadedStream.perAccount[me.$jazz.id];
|
181
194
|
|
182
195
|
assert(myStream);
|
183
196
|
|
@@ -185,7 +198,7 @@ describe("CoFeed resolution", async () => {
|
|
185
198
|
|
186
199
|
assert(myStream.value);
|
187
200
|
|
188
|
-
const loadedNestedStreamByMe = myStream.value.perAccount[me.id];
|
201
|
+
const loadedNestedStreamByMe = myStream.value.perAccount[me.$jazz.id];
|
189
202
|
|
190
203
|
assert(loadedNestedStreamByMe);
|
191
204
|
|
@@ -194,7 +207,7 @@ describe("CoFeed resolution", async () => {
|
|
194
207
|
assert(loadedNestedStreamByMe.value);
|
195
208
|
|
196
209
|
const loadedTwiceNestedStreamByMe =
|
197
|
-
loadedNestedStreamByMe.value.perAccount[me.id];
|
210
|
+
loadedNestedStreamByMe.value.perAccount[me.$jazz.id];
|
198
211
|
|
199
212
|
assert(loadedTwiceNestedStreamByMe);
|
200
213
|
|
@@ -205,13 +218,14 @@ describe("CoFeed resolution", async () => {
|
|
205
218
|
|
206
219
|
test("Subscription & auto-resolution", async () => {
|
207
220
|
const { me, stream } = await initNodeAndStream();
|
221
|
+
const accountId = me.$jazz.id;
|
208
222
|
|
209
223
|
const anotherAccount = await createJazzTestAccount();
|
210
224
|
|
211
225
|
const queue = new Channel();
|
212
226
|
|
213
227
|
TestStream.subscribe(
|
214
|
-
stream.id,
|
228
|
+
stream.$jazz.id,
|
215
229
|
{ loadAs: anotherAccount },
|
216
230
|
(subscribedStream) => {
|
217
231
|
void queue.push(subscribedStream);
|
@@ -220,36 +234,33 @@ describe("CoFeed resolution", async () => {
|
|
220
234
|
|
221
235
|
const update1 = (await queue.next()).value;
|
222
236
|
expect(
|
223
|
-
update1.perAccount[
|
224
|
-
|
225
|
-
]?.value,
|
237
|
+
update1.perAccount[accountId]?.value?.perAccount[accountId]?.value
|
238
|
+
?.perAccount[accountId]?.value,
|
226
239
|
).toBe("milk");
|
227
240
|
|
228
241
|
// When assigning a new nested stream, we get an update
|
229
242
|
const newTwiceNested = TwiceNestedStream.create(["butter"], {
|
230
|
-
owner: stream.
|
243
|
+
owner: stream.$jazz.owner,
|
231
244
|
});
|
232
245
|
|
233
246
|
const newNested = NestedStream.create([newTwiceNested], {
|
234
|
-
owner: stream.
|
247
|
+
owner: stream.$jazz.owner,
|
235
248
|
});
|
236
249
|
|
237
|
-
stream.push(newNested);
|
250
|
+
stream.$jazz.push(newNested);
|
238
251
|
|
239
252
|
const update2 = (await queue.next()).value;
|
240
253
|
expect(
|
241
|
-
update2.perAccount[me.id]?.value?.perAccount[me.id]?.value
|
242
|
-
me.id
|
243
|
-
]?.value,
|
254
|
+
update2.perAccount[me.$jazz.id]?.value?.perAccount[me.$jazz.id]?.value
|
255
|
+
?.perAccount[me.$jazz.id]?.value,
|
244
256
|
).toBe("butter");
|
245
257
|
|
246
258
|
// we get updates when the new nested stream changes
|
247
|
-
newTwiceNested.push("jam");
|
259
|
+
newTwiceNested.$jazz.push("jam");
|
248
260
|
const update3 = (await queue.next()).value;
|
249
261
|
expect(
|
250
|
-
update3.perAccount[me.id]?.value?.perAccount[me.id]?.value
|
251
|
-
me.id
|
252
|
-
]?.value,
|
262
|
+
update3.perAccount[me.$jazz.id]?.value?.perAccount[me.$jazz.id]?.value
|
263
|
+
?.perAccount[me.$jazz.id]?.value,
|
253
264
|
).toBe("jam");
|
254
265
|
});
|
255
266
|
|
@@ -258,24 +269,24 @@ describe("CoFeed resolution", async () => {
|
|
258
269
|
|
259
270
|
const queue = new Channel();
|
260
271
|
|
261
|
-
TestStream.subscribe(stream.id, (subscribedStream) => {
|
272
|
+
TestStream.subscribe(stream.$jazz.id, (subscribedStream) => {
|
262
273
|
void queue.push(subscribedStream);
|
263
274
|
});
|
264
275
|
|
265
276
|
const update1 = (await queue.next()).value;
|
266
277
|
expect(
|
267
|
-
update1.perAccount[me.id]?.value?.perAccount[me.id]?.value
|
268
|
-
me.id
|
269
|
-
]?.value,
|
278
|
+
update1.perAccount[me.$jazz.id]?.value?.perAccount[me.$jazz.id]?.value
|
279
|
+
?.perAccount[me.$jazz.id]?.value,
|
270
280
|
).toBe("milk");
|
271
281
|
|
272
|
-
stream.perAccount[me.id]!.value!.perAccount[
|
282
|
+
stream.perAccount[me.$jazz.id]!.value!.perAccount[
|
283
|
+
me.$jazz.id
|
284
|
+
]!.value!.$jazz.push("bread");
|
273
285
|
|
274
286
|
const update2 = (await queue.next()).value;
|
275
287
|
expect(
|
276
|
-
update2.perAccount[me.id]?.value?.perAccount[me.id]?.value
|
277
|
-
me.id
|
278
|
-
]?.value,
|
288
|
+
update2.perAccount[me.$jazz.id]?.value?.perAccount[me.$jazz.id]?.value
|
289
|
+
?.perAccount[me.$jazz.id]?.value,
|
279
290
|
).toBe("bread");
|
280
291
|
});
|
281
292
|
});
|
@@ -366,7 +377,7 @@ describe("FileStream loading & Subscription", async () => {
|
|
366
377
|
const { stream } = await initNodeAndStream();
|
367
378
|
const anotherAccount = await createJazzTestAccount();
|
368
379
|
|
369
|
-
const loadedStream = await FileStream.load(stream.id, {
|
380
|
+
const loadedStream = await FileStream.load(stream.$jazz.id, {
|
370
381
|
loadAs: anotherAccount,
|
371
382
|
});
|
372
383
|
|
@@ -388,7 +399,7 @@ describe("FileStream loading & Subscription", async () => {
|
|
388
399
|
const queue = new Channel();
|
389
400
|
|
390
401
|
FileStream.subscribe(
|
391
|
-
stream.id,
|
402
|
+
stream.$jazz.id,
|
392
403
|
{ loadAs: anotherAccount },
|
393
404
|
(subscribedStream) => {
|
394
405
|
void queue.push(subscribedStream);
|
@@ -451,7 +462,7 @@ describe("FileStream loading & Subscription", async () => {
|
|
451
462
|
|
452
463
|
const queue = new Channel();
|
453
464
|
|
454
|
-
FileStream.subscribe(stream.id, (subscribedStream) => {
|
465
|
+
FileStream.subscribe(stream.$jazz.id, (subscribedStream) => {
|
455
466
|
void queue.push(subscribedStream);
|
456
467
|
});
|
457
468
|
|
@@ -503,7 +514,7 @@ describe("FileStream.load", async () => {
|
|
503
514
|
const { stream, me } = await setup();
|
504
515
|
stream.push(new Uint8Array([1]));
|
505
516
|
|
506
|
-
const promise = FileStream.load(stream.id, { loadAs: me });
|
517
|
+
const promise = FileStream.load(stream.$jazz.id, { loadAs: me });
|
507
518
|
|
508
519
|
stream.push(new Uint8Array([2]));
|
509
520
|
stream.end();
|
@@ -519,7 +530,7 @@ describe("FileStream.load", async () => {
|
|
519
530
|
const { stream, me } = await setup();
|
520
531
|
stream.push(new Uint8Array([1]));
|
521
532
|
|
522
|
-
const promise = FileStream.load(stream.id, {
|
533
|
+
const promise = FileStream.load(stream.$jazz.id, {
|
523
534
|
loadAs: me,
|
524
535
|
allowUnfinished: true,
|
525
536
|
});
|
@@ -552,7 +563,7 @@ describe("FileStream.loadAsBlob", async () => {
|
|
552
563
|
const { stream, me } = await setup();
|
553
564
|
stream.push(new Uint8Array([1]));
|
554
565
|
|
555
|
-
const promise = FileStream.loadAsBlob(stream.id, { loadAs: me });
|
566
|
+
const promise = FileStream.loadAsBlob(stream.$jazz.id, { loadAs: me });
|
556
567
|
|
557
568
|
stream.push(new Uint8Array([2]));
|
558
569
|
stream.end();
|
@@ -568,7 +579,7 @@ describe("FileStream.loadAsBlob", async () => {
|
|
568
579
|
const { stream, me } = await setup();
|
569
580
|
stream.push(new Uint8Array([1]));
|
570
581
|
|
571
|
-
const promise = FileStream.loadAsBlob(stream.id, {
|
582
|
+
const promise = FileStream.loadAsBlob(stream.$jazz.id, {
|
572
583
|
loadAs: me,
|
573
584
|
allowUnfinished: true,
|
574
585
|
});
|
@@ -602,7 +613,7 @@ describe("FileStream.loadAsBase64", async () => {
|
|
602
613
|
const { stream, me } = await setup();
|
603
614
|
stream.push(new Uint8Array([1]));
|
604
615
|
|
605
|
-
const promise = FileStream.loadAsBase64(stream.id, { loadAs: me });
|
616
|
+
const promise = FileStream.loadAsBase64(stream.$jazz.id, { loadAs: me });
|
606
617
|
|
607
618
|
stream.push(new Uint8Array([2]));
|
608
619
|
stream.end();
|
@@ -618,7 +629,7 @@ describe("FileStream.loadAsBase64", async () => {
|
|
618
629
|
const { stream, me } = await setup();
|
619
630
|
stream.push(new Uint8Array([1]));
|
620
631
|
|
621
|
-
const promise = FileStream.loadAsBase64(stream.id, {
|
632
|
+
const promise = FileStream.loadAsBase64(stream.$jazz.id, {
|
622
633
|
loadAs: me,
|
623
634
|
dataURL: true,
|
624
635
|
});
|
@@ -637,7 +648,7 @@ describe("FileStream.loadAsBase64", async () => {
|
|
637
648
|
const { stream, me } = await setup();
|
638
649
|
stream.push(new Uint8Array([1]));
|
639
650
|
|
640
|
-
const promise = FileStream.loadAsBase64(stream.id, {
|
651
|
+
const promise = FileStream.loadAsBase64(stream.$jazz.id, {
|
641
652
|
loadAs: me,
|
642
653
|
allowUnfinished: true,
|
643
654
|
});
|
@@ -712,12 +723,12 @@ describe("FileStream large file loading", async () => {
|
|
712
723
|
largeStream.end();
|
713
724
|
|
714
725
|
// Wait for the large FileStream to be fully synced
|
715
|
-
await largeStream.waitForSync();
|
726
|
+
await largeStream.$jazz.waitForSync();
|
716
727
|
|
717
728
|
const alice = await createJazzTestAccount();
|
718
729
|
|
719
730
|
// Test loading the large FileStream
|
720
|
-
const loadedStream = await FileStream.load(largeStream.id, {
|
731
|
+
const loadedStream = await FileStream.load(largeStream.$jazz.id, {
|
721
732
|
loadAs: alice,
|
722
733
|
allowUnfinished: true,
|
723
734
|
});
|
@@ -728,8 +739,8 @@ describe("FileStream large file loading", async () => {
|
|
728
739
|
expect(loadedChunks).not.toBeNull();
|
729
740
|
expect(loadedChunks?.finished).toBe(undefined);
|
730
741
|
|
731
|
-
expect(loadedStream.
|
732
|
-
largeStream.
|
742
|
+
expect(loadedStream.$jazz.raw.core.knownState()).not.toEqual(
|
743
|
+
largeStream.$jazz.raw.core.knownState(),
|
733
744
|
);
|
734
745
|
});
|
735
746
|
|
@@ -759,12 +770,12 @@ describe("FileStream large file loading", async () => {
|
|
759
770
|
largeStream.end();
|
760
771
|
|
761
772
|
// Wait for the large FileStream to be fully synced
|
762
|
-
await largeStream.waitForSync();
|
773
|
+
await largeStream.$jazz.waitForSync();
|
763
774
|
|
764
775
|
const alice = await createJazzTestAccount();
|
765
776
|
|
766
777
|
// Test loading the large FileStream
|
767
|
-
const loadedStream = await FileStream.load(largeStream.id, {
|
778
|
+
const loadedStream = await FileStream.load(largeStream.$jazz.id, {
|
768
779
|
loadAs: alice,
|
769
780
|
allowUnfinished: false,
|
770
781
|
});
|
@@ -776,8 +787,8 @@ describe("FileStream large file loading", async () => {
|
|
776
787
|
expect(loadedChunks?.finished).toBe(true);
|
777
788
|
expect(loadedChunks?.chunks).toHaveLength(numChunks); // 100 chunks of 1KB each
|
778
789
|
|
779
|
-
expect(loadedStream.
|
780
|
-
largeStream.
|
790
|
+
expect(loadedStream.$jazz.raw.core.knownState()).toEqual(
|
791
|
+
largeStream.$jazz.raw.core.knownState(),
|
781
792
|
);
|
782
793
|
});
|
783
794
|
});
|
@@ -790,12 +801,12 @@ describe("waitForSync", async () => {
|
|
790
801
|
|
791
802
|
const stream = TestStream.create(["1", "2", "3"], { owner: clientAccount });
|
792
803
|
|
793
|
-
await stream.waitForSync({ timeout: 1000 });
|
804
|
+
await stream.$jazz.waitForSync({ timeout: 1000 });
|
794
805
|
|
795
806
|
// Killing the client node so the serverNode can't load the map from it
|
796
807
|
clientNode.gracefulShutdown();
|
797
808
|
|
798
|
-
const loadedStream = await serverNode.load(stream.
|
809
|
+
const loadedStream = await serverNode.load(stream.$jazz.raw.id);
|
799
810
|
|
800
811
|
expect(loadedStream).not.toBe("unavailable");
|
801
812
|
});
|
@@ -809,12 +820,12 @@ describe("waitForSync", async () => {
|
|
809
820
|
stream.push(new Uint8Array([2]));
|
810
821
|
stream.end();
|
811
822
|
|
812
|
-
await stream.waitForSync({ timeout: 1000 });
|
823
|
+
await stream.$jazz.waitForSync({ timeout: 1000 });
|
813
824
|
|
814
825
|
// Killing the client node so the serverNode can't load the map from it
|
815
826
|
clientNode.gracefulShutdown();
|
816
827
|
|
817
|
-
const loadedStream = await serverNode.load(stream.
|
828
|
+
const loadedStream = await serverNode.load(stream.$jazz.raw.id);
|
818
829
|
|
819
830
|
expect(loadedStream).not.toBe("unavailable");
|
820
831
|
});
|
@@ -825,8 +836,8 @@ describe("waitForSync", async () => {
|
|
825
836
|
});
|
826
837
|
|
827
838
|
const stream = FileStream.create();
|
828
|
-
expect(stream.
|
829
|
-
expect(stream.
|
839
|
+
expect(stream.$jazz.owner[TypeSym]).toEqual("Group");
|
840
|
+
expect(stream.$jazz.owner.$jazz.raw.roleOf(account.$jazz.raw.id)).toEqual(
|
830
841
|
"admin",
|
831
842
|
);
|
832
843
|
});
|
@@ -10,7 +10,7 @@ describe("CoList", () => {
|
|
10
10
|
|
11
11
|
const list = StringList.create(["a", "b", "c"]);
|
12
12
|
|
13
|
-
type ExpectedType = string
|
13
|
+
type ExpectedType = ReadonlyArray<string>;
|
14
14
|
|
15
15
|
function matches(value: ExpectedType) {
|
16
16
|
return value;
|
@@ -19,12 +19,12 @@ describe("CoList", () => {
|
|
19
19
|
matches(list);
|
20
20
|
});
|
21
21
|
|
22
|
-
test("has the
|
22
|
+
test("has the owner property", () => {
|
23
23
|
const StringList = co.list(z.string());
|
24
24
|
|
25
25
|
const list = StringList.create(["a", "b", "c"], Account.getMe());
|
26
26
|
|
27
|
-
expectTypeOf(list.
|
27
|
+
expectTypeOf(list.$jazz.owner).toEqualTypeOf<Group>();
|
28
28
|
});
|
29
29
|
|
30
30
|
test("CoList with reference", () => {
|
@@ -42,7 +42,7 @@ describe("CoList", () => {
|
|
42
42
|
undefined,
|
43
43
|
]);
|
44
44
|
|
45
|
-
type ExpectedType = Loaded<typeof Dog
|
45
|
+
type ExpectedType = ReadonlyArray<Loaded<typeof Dog>>;
|
46
46
|
|
47
47
|
function matches(value: ExpectedType) {
|
48
48
|
return value;
|
@@ -64,7 +64,7 @@ describe("CoList", () => {
|
|
64
64
|
undefined,
|
65
65
|
]);
|
66
66
|
|
67
|
-
type ExpectedType =
|
67
|
+
type ExpectedType = ReadonlyArray<Loaded<typeof Dog> | undefined>;
|
68
68
|
|
69
69
|
function matches(value: ExpectedType) {
|
70
70
|
return value;
|
@@ -93,7 +93,7 @@ describe("CoList", () => {
|
|
93
93
|
|
94
94
|
const list = DogList.create([dog, undefined]);
|
95
95
|
|
96
|
-
type ExpectedType =
|
96
|
+
type ExpectedType = ReadonlyArray<Loaded<typeof Dog> | undefined>;
|
97
97
|
|
98
98
|
function matches(value: ExpectedType) {
|
99
99
|
return value;
|
@@ -121,7 +121,7 @@ describe("CoList", () => {
|
|
121
121
|
|
122
122
|
const list = DogList.create([rex]);
|
123
123
|
|
124
|
-
type ExpectedType = Loaded<typeof Dog
|
124
|
+
type ExpectedType = ReadonlyArray<Loaded<typeof Dog>>;
|
125
125
|
|
126
126
|
function matches(value: ExpectedType) {
|
127
127
|
return value;
|
@@ -138,7 +138,7 @@ describe("CoList", () => {
|
|
138
138
|
co.list(z.string()).create(["c", "d"]),
|
139
139
|
]);
|
140
140
|
|
141
|
-
type ExpectedType = string
|
141
|
+
type ExpectedType = ReadonlyArray<ReadonlyArray<string>>;
|
142
142
|
|
143
143
|
function matches(value: ExpectedType) {
|
144
144
|
return value;
|
@@ -152,7 +152,7 @@ describe("CoList", () => {
|
|
152
152
|
|
153
153
|
const list = EnumList.create(["a", "b", "c"]);
|
154
154
|
|
155
|
-
type ExpectedType =
|
155
|
+
type ExpectedType = ReadonlyArray<"a" | "b" | "c">;
|
156
156
|
|
157
157
|
function matches(value: ExpectedType) {
|
158
158
|
return value;
|
@@ -176,13 +176,13 @@ describe("CoList", () => {
|
|
176
176
|
Dog.create({ name: "Fido", breed: "Poodle" }),
|
177
177
|
]);
|
178
178
|
|
179
|
-
const loadedList = await DogList.load(list.id, {
|
179
|
+
const loadedList = await DogList.load(list.$jazz.id, {
|
180
180
|
resolve: {
|
181
181
|
$each: true,
|
182
182
|
},
|
183
183
|
});
|
184
184
|
|
185
|
-
type ExpectedType = Loaded<typeof Dog
|
185
|
+
type ExpectedType = ReadonlyArray<Loaded<typeof Dog>> | null;
|
186
186
|
|
187
187
|
function matches(value: ExpectedType) {
|
188
188
|
return value;
|
@@ -209,20 +209,13 @@ describe("CoList", () => {
|
|
209
209
|
Dog.create({ name: "Fido", breed: "Poodle" }),
|
210
210
|
]);
|
211
211
|
|
212
|
-
const loadedList = await DogList.load(list.id, {
|
212
|
+
const loadedList = await DogList.load(list.$jazz.id, {
|
213
213
|
resolve: {
|
214
214
|
$each: { $onError: null },
|
215
215
|
},
|
216
216
|
});
|
217
217
|
|
218
|
-
type ExpectedType =
|
219
|
-
| (
|
220
|
-
| (Loaded<typeof Dog> & {
|
221
|
-
$onError: never;
|
222
|
-
})
|
223
|
-
| null
|
224
|
-
)[]
|
225
|
-
| null;
|
218
|
+
type ExpectedType = ReadonlyArray<Loaded<typeof Dog> | null> | null;
|
226
219
|
|
227
220
|
function matches(value: ExpectedType) {
|
228
221
|
return value;
|
@@ -247,7 +240,7 @@ describe("CoList", () => {
|
|
247
240
|
]),
|
248
241
|
]);
|
249
242
|
|
250
|
-
const loadedList = await NestedList.load(list.id, {
|
243
|
+
const loadedList = await NestedList.load(list.$jazz.id, {
|
251
244
|
resolve: {
|
252
245
|
$each: {
|
253
246
|
$each: true,
|
@@ -255,7 +248,9 @@ describe("CoList", () => {
|
|
255
248
|
},
|
256
249
|
});
|
257
250
|
|
258
|
-
type ExpectedType =
|
251
|
+
type ExpectedType = ReadonlyArray<
|
252
|
+
ReadonlyArray<Loaded<typeof Dog>>
|
253
|
+
> | null;
|
259
254
|
|
260
255
|
function matches(value: ExpectedType) {
|
261
256
|
return value;
|
@@ -292,7 +287,7 @@ describe("CoList", () => {
|
|
292
287
|
],
|
293
288
|
});
|
294
289
|
|
295
|
-
const loadedPerson = await Person.load(person.id, {
|
290
|
+
const loadedPerson = await Person.load(person.$jazz.id, {
|
296
291
|
resolve: { dogs: { $onError: null } },
|
297
292
|
});
|
298
293
|
|