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
@@ -47,12 +47,12 @@ describe("Deep loading with depth arg", async () => {
|
|
47
47
|
if (!isControlledAccount(me)) {
|
48
48
|
throw "me is not a controlled account";
|
49
49
|
}
|
50
|
-
me.
|
50
|
+
me.$jazz.localNode.syncManager.addPeer(secondPeer);
|
51
51
|
const { account: meOnSecondPeer } =
|
52
52
|
await createJazzContextFromExistingCredentials({
|
53
53
|
credentials: {
|
54
|
-
accountID: me.id,
|
55
|
-
secret: me.
|
54
|
+
accountID: me.$jazz.id,
|
55
|
+
secret: me.$jazz.localNode.getCurrentAgent().agentSecret,
|
56
56
|
},
|
57
57
|
sessionProvider: randomSessionProvider,
|
58
58
|
peersToLoadFrom: [initialAsPeer],
|
@@ -81,7 +81,7 @@ describe("Deep loading with depth arg", async () => {
|
|
81
81
|
);
|
82
82
|
|
83
83
|
test("load without resolve", async () => {
|
84
|
-
const map1 = await TestMap.load(map.id, { loadAs: meOnSecondPeer });
|
84
|
+
const map1 = await TestMap.load(map.$jazz.id, { loadAs: meOnSecondPeer });
|
85
85
|
expectTypeOf(map1).branded.toEqualTypeOf<Loaded<typeof TestMap> | null>();
|
86
86
|
|
87
87
|
assert(map1, "map1 is null");
|
@@ -90,13 +90,13 @@ describe("Deep loading with depth arg", async () => {
|
|
90
90
|
});
|
91
91
|
|
92
92
|
test("load with resolve { list: true }", async () => {
|
93
|
-
const map2 = await TestMap.load(map.id, {
|
93
|
+
const map2 = await TestMap.load(map.$jazz.id, {
|
94
94
|
loadAs: meOnSecondPeer,
|
95
95
|
resolve: { list: true },
|
96
96
|
});
|
97
97
|
expectTypeOf(map2).branded.toEqualTypeOf<
|
98
98
|
| (Loaded<typeof TestMap> & {
|
99
|
-
list: Loaded<typeof TestList>;
|
99
|
+
readonly list: Loaded<typeof TestList>;
|
100
100
|
})
|
101
101
|
| null
|
102
102
|
>();
|
@@ -106,13 +106,14 @@ describe("Deep loading with depth arg", async () => {
|
|
106
106
|
});
|
107
107
|
|
108
108
|
test("load with resolve { list: { $each: true } }", async () => {
|
109
|
-
const map3 = await TestMap.load(map.id, {
|
109
|
+
const map3 = await TestMap.load(map.$jazz.id, {
|
110
110
|
loadAs: meOnSecondPeer,
|
111
111
|
resolve: { list: { $each: true } },
|
112
112
|
});
|
113
|
-
expectTypeOf(map3).
|
113
|
+
expectTypeOf(map3).toEqualTypeOf<
|
114
114
|
| (Loaded<typeof TestMap> & {
|
115
|
-
list: Loaded<typeof TestList> &
|
115
|
+
readonly list: Loaded<typeof TestList> &
|
116
|
+
ReadonlyArray<Loaded<typeof InnerMap>>;
|
116
117
|
})
|
117
118
|
| null
|
118
119
|
>();
|
@@ -122,13 +123,13 @@ describe("Deep loading with depth arg", async () => {
|
|
122
123
|
});
|
123
124
|
|
124
125
|
test("load with resolve { optionalRef: true }", async () => {
|
125
|
-
const map3a = await TestMap.load(map.id, {
|
126
|
+
const map3a = await TestMap.load(map.$jazz.id, {
|
126
127
|
loadAs: meOnSecondPeer,
|
127
128
|
resolve: { optionalRef: true } as const,
|
128
129
|
});
|
129
130
|
expectTypeOf(map3a).branded.toEqualTypeOf<
|
130
131
|
| (Loaded<typeof TestMap> & {
|
131
|
-
optionalRef: Loaded<typeof InnermostMap> | undefined;
|
132
|
+
readonly optionalRef: Loaded<typeof InnermostMap> | undefined;
|
132
133
|
})
|
133
134
|
| null
|
134
135
|
>();
|
@@ -137,50 +138,56 @@ describe("Deep loading with depth arg", async () => {
|
|
137
138
|
});
|
138
139
|
|
139
140
|
test("load with resolve { list: { $each: { stream: true } } }", async () => {
|
140
|
-
const map4 = await TestMap.load(map.id, {
|
141
|
+
const map4 = await TestMap.load(map.$jazz.id, {
|
141
142
|
loadAs: meOnSecondPeer,
|
142
143
|
resolve: { list: { $each: { stream: true } } },
|
143
144
|
});
|
144
|
-
expectTypeOf(map4).
|
145
|
+
expectTypeOf(map4).toEqualTypeOf<
|
145
146
|
| (Loaded<typeof TestMap> & {
|
146
|
-
list: Loaded<typeof TestList> &
|
147
|
-
|
147
|
+
readonly list: Loaded<typeof TestList> &
|
148
|
+
ReadonlyArray<
|
149
|
+
Loaded<typeof InnerMap> & {
|
150
|
+
readonly stream: Loaded<typeof TestFeed>;
|
151
|
+
}
|
152
|
+
>;
|
148
153
|
})
|
149
154
|
| null
|
150
155
|
>();
|
151
156
|
assert(map4, "map4 is null");
|
152
157
|
expect(map4.list[0]?.stream).toBeTruthy();
|
153
|
-
expect(map4.list[0]?.stream?.perAccount[me.id]).toBeTruthy();
|
158
|
+
expect(map4.list[0]?.stream?.perAccount[me.$jazz.id]).toBeTruthy();
|
154
159
|
expect(map4.list[0]?.stream?.byMe?.value).toBe(null);
|
155
160
|
});
|
156
161
|
|
157
162
|
test("load with resolve { list: { $each: { stream: { $each: true } } } }", async () => {
|
158
|
-
const map5 = await TestMap.load(map.id, {
|
163
|
+
const map5 = await TestMap.load(map.$jazz.id, {
|
159
164
|
loadAs: meOnSecondPeer,
|
160
165
|
resolve: { list: { $each: { stream: { $each: true } } } },
|
161
166
|
});
|
162
167
|
type ExpectedMap5 =
|
163
168
|
| (Loaded<typeof TestMap> & {
|
164
|
-
list: Loaded<typeof TestList> &
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
169
|
+
readonly list: Loaded<typeof TestList> &
|
170
|
+
ReadonlyArray<
|
171
|
+
Loaded<typeof InnerMap> & {
|
172
|
+
readonly stream: Loaded<typeof TestFeed> & {
|
173
|
+
byMe?: { value: Loaded<typeof InnermostMap> };
|
174
|
+
inCurrentSession?: { value: Loaded<typeof InnermostMap> };
|
175
|
+
perSession: {
|
176
|
+
[sessionID: SessionID]: {
|
177
|
+
value: Loaded<typeof InnermostMap>;
|
178
|
+
};
|
172
179
|
};
|
180
|
+
} & {
|
181
|
+
[key: ID<Account>]: { value: Loaded<typeof InnermostMap> };
|
173
182
|
};
|
174
|
-
}
|
175
|
-
|
176
|
-
};
|
177
|
-
})[];
|
183
|
+
}
|
184
|
+
>;
|
178
185
|
})
|
179
186
|
| null;
|
180
|
-
expectTypeOf(map5).
|
187
|
+
expectTypeOf(map5).toEqualTypeOf<ExpectedMap5>();
|
181
188
|
assert(map5, "map5 is null");
|
182
189
|
|
183
|
-
expect(map5.list[0]?.stream?.perAccount[me.id]?.value).toBeTruthy();
|
190
|
+
expect(map5.list[0]?.stream?.perAccount[me.$jazz.id]?.value).toBeTruthy();
|
184
191
|
expect(map5.list[0]?.stream?.byMe?.value).toBeTruthy();
|
185
192
|
});
|
186
193
|
});
|
@@ -197,21 +204,14 @@ const CustomAccount = co
|
|
197
204
|
})
|
198
205
|
.withMigration(async (account, creationProps) => {
|
199
206
|
if (creationProps) {
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
},
|
206
|
-
profileGroup,
|
207
|
-
);
|
208
|
-
account.root = TestMap.create(
|
209
|
-
{ list: TestList.create([], account) },
|
210
|
-
account,
|
211
|
-
);
|
207
|
+
account.$jazz.set("profile", {
|
208
|
+
name: creationProps.name,
|
209
|
+
stream: TestFeed.create([], account),
|
210
|
+
});
|
211
|
+
account.$jazz.set("root", { list: [] });
|
212
212
|
}
|
213
213
|
|
214
|
-
const accountLoaded = await account.ensureLoaded({
|
214
|
+
const accountLoaded = await account.$jazz.ensureLoaded({
|
215
215
|
resolve: {
|
216
216
|
profile: { stream: true },
|
217
217
|
root: { list: true },
|
@@ -237,7 +237,7 @@ test("Deep loading within account", async () => {
|
|
237
237
|
crypto: Crypto,
|
238
238
|
});
|
239
239
|
|
240
|
-
const meLoaded = await me.ensureLoaded({
|
240
|
+
const meLoaded = await me.$jazz.ensureLoaded({
|
241
241
|
resolve: {
|
242
242
|
profile: { stream: true },
|
243
243
|
root: { list: true },
|
@@ -277,12 +277,12 @@ test("Deep loading a record-like coMap", async () => {
|
|
277
277
|
throw "me is not a controlled account";
|
278
278
|
}
|
279
279
|
|
280
|
-
me.
|
280
|
+
me.$jazz.localNode.syncManager.addPeer(secondPeer);
|
281
281
|
const { account: meOnSecondPeer } =
|
282
282
|
await createJazzContextFromExistingCredentials({
|
283
283
|
credentials: {
|
284
|
-
accountID: me.id,
|
285
|
-
secret: me.
|
284
|
+
accountID: me.$jazz.id,
|
285
|
+
secret: me.$jazz.localNode.getCurrentAgent().agentSecret,
|
286
286
|
},
|
287
287
|
sessionProvider: randomSessionProvider,
|
288
288
|
peersToLoadFrom: [initialAsPeer],
|
@@ -303,7 +303,7 @@ test("Deep loading a record-like coMap", async () => {
|
|
303
303
|
{ owner: me },
|
304
304
|
);
|
305
305
|
|
306
|
-
const recordLoaded = await RecordLike.load(record.id, {
|
306
|
+
const recordLoaded = await RecordLike.load(record.$jazz.id, {
|
307
307
|
loadAs: meOnSecondPeer,
|
308
308
|
resolve: {
|
309
309
|
$each: { list: { $each: true } },
|
@@ -311,8 +311,9 @@ test("Deep loading a record-like coMap", async () => {
|
|
311
311
|
});
|
312
312
|
expectTypeOf(recordLoaded).toEqualTypeOf<
|
313
313
|
| (Loaded<typeof RecordLike> & {
|
314
|
-
[key: string]: Loaded<typeof TestMap> & {
|
315
|
-
list: Loaded<typeof TestList> &
|
314
|
+
readonly [key: string]: Loaded<typeof TestMap> & {
|
315
|
+
readonly list: Loaded<typeof TestList> &
|
316
|
+
ReadonlyArray<Loaded<typeof InnerMap>>;
|
316
317
|
};
|
317
318
|
})
|
318
319
|
| null
|
@@ -333,7 +334,7 @@ test("The resolve type doesn't accept extra keys", async () => {
|
|
333
334
|
});
|
334
335
|
|
335
336
|
try {
|
336
|
-
const meLoaded = await me.ensureLoaded({
|
337
|
+
const meLoaded = await me.$jazz.ensureLoaded({
|
337
338
|
resolve: {
|
338
339
|
// @ts-expect-error
|
339
340
|
profile: { stream: true, extraKey: true },
|
@@ -342,14 +343,14 @@ test("The resolve type doesn't accept extra keys", async () => {
|
|
342
343
|
},
|
343
344
|
});
|
344
345
|
|
345
|
-
await me.ensureLoaded({
|
346
|
+
await me.$jazz.ensureLoaded({
|
346
347
|
resolve: {
|
347
348
|
// @ts-expect-error
|
348
349
|
root: { list: { $each: true, extraKey: true } },
|
349
350
|
},
|
350
351
|
});
|
351
352
|
|
352
|
-
await me.ensureLoaded({
|
353
|
+
await me.$jazz.ensureLoaded({
|
353
354
|
resolve: {
|
354
355
|
root: { list: true },
|
355
356
|
// @ts-expect-error
|
@@ -389,7 +390,7 @@ test("The resolve type accepts keys from optional fields", async () => {
|
|
389
390
|
Dog.create({ type: "dog", owner: Person.create({ name: "Rex" }) }),
|
390
391
|
]);
|
391
392
|
|
392
|
-
await pets.ensureLoaded({
|
393
|
+
await pets.$jazz.ensureLoaded({
|
393
394
|
resolve: {
|
394
395
|
$each: { owner: true },
|
395
396
|
},
|
@@ -416,13 +417,13 @@ test("The resolve type doesn't accept keys from discriminated unions", async ()
|
|
416
417
|
Dog.create({ type: "dog", owner: Person.create({ name: "Rex" }) }),
|
417
418
|
]);
|
418
419
|
|
419
|
-
await pets.ensureLoaded({
|
420
|
+
await pets.$jazz.ensureLoaded({
|
420
421
|
resolve: {
|
421
422
|
$each: true,
|
422
423
|
},
|
423
424
|
});
|
424
425
|
|
425
|
-
await pets.ensureLoaded({
|
426
|
+
await pets.$jazz.ensureLoaded({
|
426
427
|
// @ts-expect-error cannot resolve owner
|
427
428
|
resolve: { $each: { owner: true } },
|
428
429
|
});
|
@@ -444,7 +445,7 @@ describe("Deep loading with unauthorized account", async () => {
|
|
444
445
|
|
445
446
|
linkAccounts(bob, alice);
|
446
447
|
|
447
|
-
await alice.waitForAllCoValuesSync();
|
448
|
+
await alice.$jazz.waitForAllCoValuesSync();
|
448
449
|
|
449
450
|
const onlyBob = bob;
|
450
451
|
const group = Group.create(bob);
|
@@ -456,12 +457,12 @@ describe("Deep loading with unauthorized account", async () => {
|
|
456
457
|
|
457
458
|
const map = TestMap.create({ list: TestList.create([], group) }, onlyBob);
|
458
459
|
|
459
|
-
const mapOnAlice = await TestMap.load(map.id, { loadAs: alice });
|
460
|
+
const mapOnAlice = await TestMap.load(map.$jazz.id, { loadAs: alice });
|
460
461
|
|
461
462
|
expect(mapOnAlice).toBe(null);
|
462
463
|
|
463
464
|
expect(errorSpy).toHaveBeenCalledWith(
|
464
|
-
`The current user (${alice.id}) is not authorized to access this value from ${map.id}`,
|
465
|
+
`The current user (${alice.$jazz.id}) is not authorized to access this value from ${map.$jazz.id}`,
|
465
466
|
);
|
466
467
|
|
467
468
|
errorSpy.mockReset();
|
@@ -472,10 +473,10 @@ describe("Deep loading with unauthorized account", async () => {
|
|
472
473
|
|
473
474
|
const map = TestMap.create({ list: TestList.create([], onlyBob) }, group);
|
474
475
|
|
475
|
-
const mapOnAlice = await TestMap.load(map.id, { loadAs: alice });
|
476
|
+
const mapOnAlice = await TestMap.load(map.$jazz.id, { loadAs: alice });
|
476
477
|
expect(mapOnAlice).toBeTruthy();
|
477
478
|
|
478
|
-
const mapWithListOnAlice = await TestMap.load(map.id, {
|
479
|
+
const mapWithListOnAlice = await TestMap.load(map.$jazz.id, {
|
479
480
|
resolve: { list: true },
|
480
481
|
loadAs: alice,
|
481
482
|
});
|
@@ -483,7 +484,7 @@ describe("Deep loading with unauthorized account", async () => {
|
|
483
484
|
expect(mapWithListOnAlice).toBe(null);
|
484
485
|
|
485
486
|
expect(errorSpy).toHaveBeenCalledWith(
|
486
|
-
`The current user (${alice.id}) is not authorized to access this value from ${map.id} on path list`,
|
487
|
+
`The current user (${alice.$jazz.id}) is not authorized to access this value from ${map.$jazz.id} on path list`,
|
487
488
|
);
|
488
489
|
|
489
490
|
errorSpy.mockReset();
|
@@ -509,7 +510,7 @@ describe("Deep loading with unauthorized account", async () => {
|
|
509
510
|
group,
|
510
511
|
);
|
511
512
|
|
512
|
-
const mapOnAlice = await TestMap.load(map.id, {
|
513
|
+
const mapOnAlice = await TestMap.load(map.$jazz.id, {
|
513
514
|
resolve: { list: { $each: true } },
|
514
515
|
loadAs: alice,
|
515
516
|
});
|
@@ -517,7 +518,7 @@ describe("Deep loading with unauthorized account", async () => {
|
|
517
518
|
expect(mapOnAlice).toBe(null);
|
518
519
|
|
519
520
|
expect(errorSpy).toHaveBeenCalledWith(
|
520
|
-
`The current user (${alice.id}) is not authorized to access this value from ${map.id} on path list.0`,
|
521
|
+
`The current user (${alice.$jazz.id}) is not authorized to access this value from ${map.$jazz.id} on path list.0`,
|
521
522
|
);
|
522
523
|
|
523
524
|
errorSpy.mockReset();
|
@@ -534,7 +535,7 @@ describe("Deep loading with unauthorized account", async () => {
|
|
534
535
|
group,
|
535
536
|
);
|
536
537
|
|
537
|
-
const mapOnAlice = await TestMap.load(map.id, {
|
538
|
+
const mapOnAlice = await TestMap.load(map.$jazz.id, {
|
538
539
|
loadAs: alice,
|
539
540
|
resolve: { optionalRef: true } as const,
|
540
541
|
});
|
@@ -544,7 +545,7 @@ describe("Deep loading with unauthorized account", async () => {
|
|
544
545
|
expect(mapOnAlice?.optionalRef?.value).toBe(undefined);
|
545
546
|
|
546
547
|
expect(errorSpy).toHaveBeenCalledWith(
|
547
|
-
`The current user (${alice.id}) is not authorized to access this value from ${map.id} on path optionalRef`,
|
548
|
+
`The current user (${alice.$jazz.id}) is not authorized to access this value from ${map.$jazz.id} on path optionalRef`,
|
548
549
|
);
|
549
550
|
|
550
551
|
errorSpy.mockReset();
|
@@ -559,7 +560,7 @@ describe("Deep loading with unauthorized account", async () => {
|
|
559
560
|
group,
|
560
561
|
);
|
561
562
|
|
562
|
-
const mapOnAlice = await TestMap.load(map.id, {
|
563
|
+
const mapOnAlice = await TestMap.load(map.$jazz.id, {
|
563
564
|
loadAs: alice,
|
564
565
|
resolve: { list: true } as const,
|
565
566
|
});
|
@@ -567,7 +568,7 @@ describe("Deep loading with unauthorized account", async () => {
|
|
567
568
|
assert(mapOnAlice, "Alice isn't able to load the map");
|
568
569
|
|
569
570
|
const result = await new Promise((resolve) => {
|
570
|
-
const unsub = mapOnAlice.subscribe((value) => {
|
571
|
+
const unsub = mapOnAlice.$jazz.subscribe((value) => {
|
571
572
|
resolve(value.optionalRef);
|
572
573
|
unsub();
|
573
574
|
});
|
@@ -595,7 +596,7 @@ describe("Deep loading with unauthorized account", async () => {
|
|
595
596
|
group,
|
596
597
|
);
|
597
598
|
|
598
|
-
const mapOnAlice = await TestMap.load(map.id, {
|
599
|
+
const mapOnAlice = await TestMap.load(map.$jazz.id, {
|
599
600
|
resolve: { list: { $each: { stream: true } } },
|
600
601
|
loadAs: alice,
|
601
602
|
});
|
@@ -603,7 +604,7 @@ describe("Deep loading with unauthorized account", async () => {
|
|
603
604
|
expect(mapOnAlice).toBe(null);
|
604
605
|
|
605
606
|
expect(errorSpy).toHaveBeenCalledWith(
|
606
|
-
`The current user (${alice.id}) is not authorized to access this value from ${map.id} on path list.0.stream`,
|
607
|
+
`The current user (${alice.$jazz.id}) is not authorized to access this value from ${map.$jazz.id} on path list.0.stream`,
|
607
608
|
);
|
608
609
|
|
609
610
|
errorSpy.mockReset();
|
@@ -631,7 +632,7 @@ describe("Deep loading with unauthorized account", async () => {
|
|
631
632
|
group,
|
632
633
|
);
|
633
634
|
|
634
|
-
const mapOnAlice = await TestMap.load(map.id, {
|
635
|
+
const mapOnAlice = await TestMap.load(map.$jazz.id, {
|
635
636
|
resolve: { list: { $each: { stream: { $each: true } } } },
|
636
637
|
loadAs: alice,
|
637
638
|
});
|
@@ -639,7 +640,7 @@ describe("Deep loading with unauthorized account", async () => {
|
|
639
640
|
expect(mapOnAlice).toBe(null);
|
640
641
|
|
641
642
|
expect(errorSpy).toHaveBeenCalledWith(
|
642
|
-
`The current user (${alice.id}) is not authorized to access this value from ${map.id} on path list.0.stream.${value.id}`,
|
643
|
+
`The current user (${alice.$jazz.id}) is not authorized to access this value from ${map.$jazz.id} on path list.0.stream.${value.$jazz.id}`,
|
643
644
|
);
|
644
645
|
|
645
646
|
errorSpy.mockReset();
|
@@ -663,14 +664,14 @@ describe("Deep loading with unauthorized account", async () => {
|
|
663
664
|
bob,
|
664
665
|
);
|
665
666
|
|
666
|
-
map.lv2
|
667
|
+
map.lv2!.$jazz.set("lv3", undefined);
|
667
668
|
|
668
|
-
const loadedMap = await Lv1.load(map.id, {
|
669
|
+
const loadedMap = await Lv1.load(map.$jazz.id, {
|
669
670
|
resolve: { lv2: { lv3: true } },
|
670
671
|
loadAs: bob,
|
671
672
|
});
|
672
673
|
|
673
|
-
expect(loadedMap
|
674
|
+
expect(loadedMap?.$jazz.id).toBe(map.$jazz.id);
|
674
675
|
});
|
675
676
|
|
676
677
|
test("unaccessible record element with $onError", async () => {
|
@@ -687,7 +688,7 @@ describe("Deep loading with unauthorized account", async () => {
|
|
687
688
|
group,
|
688
689
|
);
|
689
690
|
|
690
|
-
const friendsOnAlice = await Friends.load(map.id, {
|
691
|
+
const friendsOnAlice = await Friends.load(map.$jazz.id, {
|
691
692
|
resolve: { $each: { $onError: null } },
|
692
693
|
loadAs: alice,
|
693
694
|
});
|
@@ -723,7 +724,7 @@ describe("Deep loading with unauthorized account", async () => {
|
|
723
724
|
group,
|
724
725
|
);
|
725
726
|
|
726
|
-
const user = await User.load(map.id, {
|
727
|
+
const user = await User.load(map.$jazz.id, {
|
727
728
|
resolve: { friends: { $each: { $onError: null } } },
|
728
729
|
loadAs: alice,
|
729
730
|
});
|
@@ -774,7 +775,7 @@ describe("Deep loading with unauthorized account", async () => {
|
|
774
775
|
group,
|
775
776
|
);
|
776
777
|
|
777
|
-
const user = await User.load(map.id, {
|
778
|
+
const user = await User.load(map.$jazz.id, {
|
778
779
|
resolve: { friends: { $each: { dog: true, $onError: null } } },
|
779
780
|
loadAs: alice,
|
780
781
|
});
|
@@ -822,7 +823,7 @@ describe("Deep loading with unauthorized account", async () => {
|
|
822
823
|
|
823
824
|
// The error List -> Jane -> Bob should be propagated to the list element Jane
|
824
825
|
// and we should have [null, Alice]
|
825
|
-
const listOnAlice = await Friends.load(list.id, {
|
826
|
+
const listOnAlice = await Friends.load(list.$jazz.id, {
|
826
827
|
resolve: { $each: { friends: { $each: true }, $onError: null } },
|
827
828
|
loadAs: alice,
|
828
829
|
});
|
@@ -851,7 +852,7 @@ describe("Deep loading with unauthorized account", async () => {
|
|
851
852
|
group,
|
852
853
|
);
|
853
854
|
|
854
|
-
const friendsOnAlice = await Friend.load(map.id, {
|
855
|
+
const friendsOnAlice = await Friend.load(map.$jazz.id, {
|
855
856
|
resolve: { $each: { $onError: null } },
|
856
857
|
loadAs: alice,
|
857
858
|
});
|
@@ -902,7 +903,7 @@ describe("Deep loading with unauthorized account", async () => {
|
|
902
903
|
group,
|
903
904
|
);
|
904
905
|
|
905
|
-
const user = await User.load(map.id, {
|
906
|
+
const user = await User.load(map.$jazz.id, {
|
906
907
|
resolve: { friends: { $each: { dog: { $onError: null } } } },
|
907
908
|
loadAs: alice,
|
908
909
|
});
|
@@ -919,7 +920,7 @@ describe("Deep loading with unauthorized account", async () => {
|
|
919
920
|
});
|
920
921
|
|
921
922
|
const map = Person.create({ name: "John" }, onlyBob);
|
922
|
-
const user = await Person.load(map.id, {
|
923
|
+
const user = await Person.load(map.$jazz.id, {
|
923
924
|
resolve: { $onError: null },
|
924
925
|
loadAs: alice,
|
925
926
|
});
|
@@ -942,7 +943,7 @@ test("doesn't break on Map.Record key deletion when the key is referenced in the
|
|
942
943
|
});
|
943
944
|
|
944
945
|
const spy = vi.fn();
|
945
|
-
const unsub = snapStore.subscribe(
|
946
|
+
const unsub = snapStore.$jazz.subscribe(
|
946
947
|
{ resolve: { profile1: true, profile2: true } },
|
947
948
|
spy,
|
948
949
|
);
|
@@ -950,19 +951,19 @@ test("doesn't break on Map.Record key deletion when the key is referenced in the
|
|
950
951
|
await waitFor(() => expect(spy).toHaveBeenCalled());
|
951
952
|
|
952
953
|
spy.mockClear();
|
953
|
-
|
954
|
+
snapStore.$jazz.delete("profile1");
|
954
955
|
|
955
956
|
expect(Object.keys(snapStore)).toEqual(["profile2"]);
|
956
957
|
|
957
958
|
unsub();
|
958
959
|
|
959
960
|
await expect(
|
960
|
-
snapStore.ensureLoaded({
|
961
|
+
snapStore.$jazz.ensureLoaded({
|
961
962
|
resolve: {
|
962
963
|
profile1: true,
|
963
964
|
},
|
964
965
|
}),
|
965
|
-
).rejects.toThrow("Failed to deeply load CoValue " + snapStore.id);
|
966
|
+
).rejects.toThrow("Failed to deeply load CoValue " + snapStore.$jazz.id);
|
966
967
|
});
|
967
968
|
|
968
969
|
test("throw when calling ensureLoaded on a ref that's required but missing", async () => {
|
@@ -987,10 +988,10 @@ test("throw when calling ensureLoaded on a ref that's required but missing", asy
|
|
987
988
|
);
|
988
989
|
|
989
990
|
await expect(
|
990
|
-
root.ensureLoaded({
|
991
|
+
root.$jazz.ensureLoaded({
|
991
992
|
resolve: { profile: true },
|
992
993
|
}),
|
993
|
-
).rejects.toThrow("Failed to deeply load CoValue " + root.id);
|
994
|
+
).rejects.toThrow("Failed to deeply load CoValue " + root.$jazz.id);
|
994
995
|
});
|
995
996
|
|
996
997
|
test("throw when calling ensureLoaded on a ref that is not defined in the schema", async () => {
|
@@ -1004,11 +1005,11 @@ test("throw when calling ensureLoaded on a ref that is not defined in the schema
|
|
1004
1005
|
const root = JazzRoot.create({}, { owner: me });
|
1005
1006
|
|
1006
1007
|
await expect(
|
1007
|
-
root.ensureLoaded({
|
1008
|
+
root.$jazz.ensureLoaded({
|
1008
1009
|
// @ts-expect-error missing required ref
|
1009
1010
|
resolve: { profile: true },
|
1010
1011
|
}),
|
1011
|
-
).rejects.toThrow("Failed to deeply load CoValue " + root.id);
|
1012
|
+
).rejects.toThrow("Failed to deeply load CoValue " + root.$jazz.id);
|
1012
1013
|
});
|
1013
1014
|
|
1014
1015
|
test("should not throw when calling ensureLoaded a record with a deleted ref", async () => {
|
@@ -1032,20 +1033,20 @@ test("should not throw when calling ensureLoaded a record with a deleted ref", a
|
|
1032
1033
|
);
|
1033
1034
|
|
1034
1035
|
let value: any;
|
1035
|
-
let unsub = root.subscribe({ resolve: { $each: true } }, (v) => {
|
1036
|
+
let unsub = root.$jazz.subscribe({ resolve: { $each: true } }, (v) => {
|
1036
1037
|
value = v;
|
1037
1038
|
});
|
1038
1039
|
|
1039
1040
|
await waitFor(() => expect(value.profile).toBeDefined());
|
1040
1041
|
|
1041
|
-
|
1042
|
+
root.$jazz.delete("profile");
|
1042
1043
|
|
1043
1044
|
await waitFor(() => expect(value.profile).toBeUndefined());
|
1044
1045
|
|
1045
1046
|
unsub();
|
1046
1047
|
|
1047
1048
|
value = undefined;
|
1048
|
-
unsub = root.subscribe({ resolve: { $each: true } }, (v) => {
|
1049
|
+
unsub = root.$jazz.subscribe({ resolve: { $each: true } }, (v) => {
|
1049
1050
|
value = v;
|
1050
1051
|
});
|
1051
1052
|
|