jazz-tools 0.15.15 → 0.16.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.d.ts +2 -2
- package/.svelte-kit/__package__/jazz.class.svelte.d.ts.map +1 -1
- package/.svelte-kit/__package__/jazz.class.svelte.js +5 -5
- package/.svelte-kit/__package__/jazz.svelte.d.ts +2 -2
- package/.svelte-kit/__package__/jazz.svelte.d.ts.map +1 -1
- package/.turbo/turbo-build.log +46 -50
- package/CHANGELOG.md +35 -0
- package/dist/browser/index.d.ts +2 -2
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/index.js.map +1 -1
- package/dist/browser-media-images/index.d.ts +3 -1
- package/dist/browser-media-images/index.d.ts.map +1 -1
- package/dist/browser-media-images/index.js.map +1 -1
- package/dist/{chunk-4CFNXQE7.js → chunk-MLCNE3TL.js} +791 -698
- package/dist/chunk-MLCNE3TL.js.map +1 -0
- package/dist/index.js +363 -11
- package/dist/index.js.map +1 -1
- package/dist/react/hooks.d.ts +2 -2
- package/dist/react/hooks.d.ts.map +1 -1
- package/dist/react/index.js +2 -0
- package/dist/react/index.js.map +1 -1
- package/dist/react/testing.js +3 -1
- package/dist/react/testing.js.map +1 -1
- package/dist/react-core/hooks.d.ts +2 -2
- package/dist/react-core/hooks.d.ts.map +1 -1
- package/dist/react-core/index.js +3 -3
- package/dist/react-core/index.js.map +1 -1
- package/dist/react-native-core/hooks.d.ts +2 -2
- package/dist/react-native-core/hooks.d.ts.map +1 -1
- package/dist/react-native-core/index.js.map +1 -1
- package/dist/svelte/jazz.class.svelte.d.ts +2 -2
- package/dist/svelte/jazz.class.svelte.d.ts.map +1 -1
- package/dist/svelte/jazz.class.svelte.js +5 -5
- package/dist/svelte/jazz.svelte.d.ts +2 -2
- package/dist/svelte/jazz.svelte.d.ts.map +1 -1
- package/dist/testing.js +3 -3
- package/dist/testing.js.map +1 -1
- package/dist/tools/coValues/CoValueBase.d.ts +3 -13
- package/dist/tools/coValues/CoValueBase.d.ts.map +1 -1
- package/dist/tools/coValues/account.d.ts +2 -2
- package/dist/tools/coValues/account.d.ts.map +1 -1
- package/dist/tools/coValues/coFeed.d.ts.map +1 -1
- package/dist/tools/coValues/coList.d.ts.map +1 -1
- package/dist/tools/coValues/coMap.d.ts +5 -18
- package/dist/tools/coValues/coMap.d.ts.map +1 -1
- package/dist/tools/coValues/deepLoading.d.ts +4 -1
- package/dist/tools/coValues/deepLoading.d.ts.map +1 -1
- package/dist/tools/coValues/extensions/imageDef.d.ts +4 -7
- package/dist/tools/coValues/extensions/imageDef.d.ts.map +1 -1
- package/dist/tools/coValues/group.d.ts +1 -0
- package/dist/tools/coValues/group.d.ts.map +1 -1
- package/dist/tools/coValues/inbox.d.ts +2 -2
- package/dist/tools/coValues/inbox.d.ts.map +1 -1
- package/dist/tools/coValues/interfaces.d.ts +58 -17
- package/dist/tools/coValues/interfaces.d.ts.map +1 -1
- package/dist/tools/coValues/request.d.ts +82 -0
- package/dist/tools/coValues/request.d.ts.map +1 -0
- package/dist/tools/coValues/schemaUnion.d.ts +5 -1
- package/dist/tools/coValues/schemaUnion.d.ts.map +1 -1
- package/dist/tools/exports.d.ts +4 -3
- package/dist/tools/exports.d.ts.map +1 -1
- package/dist/tools/implementation/createContext.d.ts +4 -4
- package/dist/tools/implementation/createContext.d.ts.map +1 -1
- package/dist/tools/implementation/invites.d.ts +2 -2
- package/dist/tools/implementation/invites.d.ts.map +1 -1
- package/dist/tools/implementation/schemaUtils.d.ts +8 -0
- package/dist/tools/implementation/schemaUtils.d.ts.map +1 -0
- package/dist/tools/implementation/zodSchema/coExport.d.ts +11 -1
- package/dist/tools/implementation/zodSchema/coExport.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/runtimeConverters/coValueSchemaTransformation.d.ts +22 -0
- package/dist/tools/implementation/zodSchema/runtimeConverters/coValueSchemaTransformation.d.ts.map +1 -0
- package/dist/tools/implementation/zodSchema/runtimeConverters/schemaFieldToCoFieldDef.d.ts +10 -0
- package/dist/tools/implementation/zodSchema/runtimeConverters/schemaFieldToCoFieldDef.d.ts.map +1 -0
- package/dist/tools/implementation/zodSchema/schemaTypes/AccountSchema.d.ts +11 -11
- package/dist/tools/implementation/zodSchema/schemaTypes/AccountSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoDiscriminatedUnionSchema.d.ts +34 -24
- package/dist/tools/implementation/zodSchema/schemaTypes/CoDiscriminatedUnionSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.d.ts +16 -14
- package/dist/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoListSchema.d.ts +23 -17
- package/dist/tools/implementation/zodSchema/schemaTypes/CoListSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoMapSchema.d.ts +24 -16
- package/dist/tools/implementation/zodSchema/schemaTypes/CoMapSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoOptionalSchema.d.ts +20 -9
- package/dist/tools/implementation/zodSchema/schemaTypes/CoOptionalSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoRecordSchema.d.ts +18 -12
- package/dist/tools/implementation/zodSchema/schemaTypes/CoRecordSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoValueSchema.d.ts +18 -0
- package/dist/tools/implementation/zodSchema/schemaTypes/CoValueSchema.d.ts.map +1 -0
- package/dist/tools/implementation/zodSchema/schemaTypes/FileStreamSchema.d.ts +14 -9
- package/dist/tools/implementation/zodSchema/schemaTypes/FileStreamSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/PlainTextSchema.d.ts +14 -9
- package/dist/tools/implementation/zodSchema/schemaTypes/PlainTextSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/RichTextSchema.d.ts +14 -9
- package/dist/tools/implementation/zodSchema/schemaTypes/RichTextSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchema.d.ts +15 -13
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.d.ts +12 -15
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchema.d.ts +17 -20
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchemaCoValuesNullable.d.ts +17 -20
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchemaCoValuesNullable.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/unionUtils.d.ts +3 -5
- package/dist/tools/implementation/zodSchema/unionUtils.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/zodCo.d.ts +10 -8
- package/dist/tools/implementation/zodSchema/zodCo.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/zodReExport.d.ts +4 -8
- package/dist/tools/implementation/zodSchema/zodReExport.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/zodSchema.d.ts +21 -30
- package/dist/tools/implementation/zodSchema/zodSchema.d.ts.map +1 -1
- package/dist/tools/internal.d.ts +3 -2
- package/dist/tools/internal.d.ts.map +1 -1
- package/dist/tools/lib/id.d.ts +2 -0
- package/dist/tools/lib/id.d.ts.map +1 -0
- package/dist/tools/lib/utilityTypes.d.ts +10 -0
- package/dist/tools/lib/utilityTypes.d.ts.map +1 -0
- package/dist/tools/subscribe/SubscriptionScope.d.ts +3 -2
- package/dist/tools/subscribe/SubscriptionScope.d.ts.map +1 -1
- package/dist/tools/subscribe/utils.d.ts.map +1 -1
- package/dist/tools/testing.d.ts +2 -2
- package/dist/tools/testing.d.ts.map +1 -1
- package/dist/tools/tests/exportImport.test.d.ts +2 -0
- package/dist/tools/tests/exportImport.test.d.ts.map +1 -0
- package/dist/tools/tests/request.test.d.ts +2 -0
- package/dist/tools/tests/request.test.d.ts.map +1 -0
- package/dist/worker/index.d.ts.map +1 -1
- package/dist/worker/index.js +2 -2
- package/dist/worker/index.js.map +1 -1
- package/package.json +7 -6
- package/src/browser/index.ts +2 -4
- package/src/browser-media-images/index.ts +1 -1
- package/src/react/hooks.tsx +2 -2
- package/src/react-core/hooks.ts +6 -6
- package/src/react-core/tests/useAccount.test.ts +2 -2
- package/src/react-core/tests/useCoState.test.ts +3 -2
- package/src/react-native-core/hooks.tsx +2 -2
- package/src/svelte/jazz.class.svelte.ts +10 -7
- package/src/svelte/jazz.svelte.ts +2 -2
- package/src/tools/coValues/CoValueBase.ts +8 -20
- package/src/tools/coValues/account.ts +18 -14
- package/src/tools/coValues/coFeed.ts +0 -4
- package/src/tools/coValues/coList.ts +7 -9
- package/src/tools/coValues/coMap.ts +1 -6
- package/src/tools/coValues/coPlainText.ts +4 -4
- package/src/tools/coValues/deepLoading.ts +4 -1
- package/src/tools/coValues/extensions/imageDef.ts +3 -3
- package/src/tools/coValues/group.ts +1 -0
- package/src/tools/coValues/inbox.ts +8 -7
- package/src/tools/coValues/interfaces.ts +177 -69
- package/src/tools/coValues/request.ts +633 -0
- package/src/tools/coValues/schemaUnion.ts +8 -4
- package/src/tools/exports.ts +11 -14
- package/src/tools/implementation/createContext.ts +9 -9
- package/src/tools/implementation/invites.ts +2 -2
- package/src/tools/implementation/schemaUtils.ts +18 -0
- package/src/tools/implementation/zodSchema/coExport.ts +14 -0
- package/src/tools/implementation/zodSchema/runtimeConverters/coValueSchemaTransformation.ts +156 -0
- package/src/tools/implementation/zodSchema/runtimeConverters/schemaFieldToCoFieldDef.ts +133 -0
- package/src/tools/implementation/zodSchema/schemaTypes/AccountSchema.ts +36 -17
- package/src/tools/implementation/zodSchema/schemaTypes/CoDiscriminatedUnionSchema.ts +101 -52
- package/src/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.ts +54 -50
- package/src/tools/implementation/zodSchema/schemaTypes/CoListSchema.ts +54 -46
- package/src/tools/implementation/zodSchema/schemaTypes/CoMapSchema.ts +187 -137
- package/src/tools/implementation/zodSchema/schemaTypes/CoOptionalSchema.ts +29 -27
- package/src/tools/implementation/zodSchema/schemaTypes/CoRecordSchema.ts +28 -18
- package/src/tools/implementation/zodSchema/schemaTypes/CoValueSchema.ts +18 -0
- package/src/tools/implementation/zodSchema/schemaTypes/FileStreamSchema.ts +45 -36
- package/src/tools/implementation/zodSchema/schemaTypes/PlainTextSchema.ts +47 -35
- package/src/tools/implementation/zodSchema/schemaTypes/RichTextSchema.ts +43 -30
- package/src/tools/implementation/zodSchema/typeConverters/InstanceOfSchema.ts +28 -23
- package/src/tools/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.ts +28 -25
- package/src/tools/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchema.ts +86 -78
- package/src/tools/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchemaCoValuesNullable.ts +91 -82
- package/src/tools/implementation/zodSchema/unionUtils.ts +47 -51
- package/src/tools/implementation/zodSchema/zodCo.ts +42 -75
- package/src/tools/implementation/zodSchema/zodReExport.ts +44 -24
- package/src/tools/implementation/zodSchema/zodSchema.ts +64 -102
- package/src/tools/internal.ts +3 -2
- package/src/tools/lib/id.ts +3 -0
- package/src/tools/lib/utilityTypes.ts +7 -0
- package/src/tools/subscribe/SubscriptionScope.ts +10 -1
- package/src/tools/subscribe/utils.ts +4 -2
- package/src/tools/testing.ts +4 -4
- package/src/tools/tests/ContextManager.test.ts +8 -9
- package/src/tools/tests/account.test.ts +65 -3
- package/src/tools/tests/coDiscriminatedUnion.test-d.ts +38 -0
- package/src/tools/tests/coDiscriminatedUnion.test.ts +219 -1
- package/src/tools/tests/coFeed.test-d.ts +4 -3
- package/src/tools/tests/coList.test-d.ts +32 -3
- package/src/tools/tests/coList.test.ts +20 -2
- package/src/tools/tests/coMap.record.test-d.ts +31 -3
- package/src/tools/tests/coMap.record.test.ts +9 -9
- package/src/tools/tests/coMap.test-d.ts +8 -8
- package/src/tools/tests/coMap.test.ts +19 -5
- package/src/tools/tests/coOptional.test.ts +63 -1
- package/src/tools/tests/createContext.test.ts +7 -9
- package/src/tools/tests/deepLoading.test.ts +4 -10
- package/src/tools/tests/exportImport.test.ts +526 -0
- package/src/tools/tests/groupsAndAccounts.test.ts +5 -4
- package/src/tools/tests/inbox.test.ts +3 -2
- package/src/tools/tests/load.test.ts +3 -29
- package/src/tools/tests/request.test.ts +951 -0
- package/src/tools/tests/schemaUnion.test.ts +2 -2
- package/src/tools/tests/subscribe.test.ts +22 -114
- package/src/tools/tests/testing.test.ts +6 -6
- package/src/tools/tests/zod.test-d.ts +27 -0
- package/src/tools/tests/zod.test.ts +50 -45
- package/src/worker/index.ts +0 -1
- package/tsup.config.ts +0 -2
- package/dist/chunk-4CFNXQE7.js.map +0 -1
- package/dist/tools/implementation/zodSchema/runtimeConverters/zodFieldToCoFieldDef.d.ts +0 -12
- package/dist/tools/implementation/zodSchema/runtimeConverters/zodFieldToCoFieldDef.d.ts.map +0 -1
- package/dist/tools/implementation/zodSchema/runtimeConverters/zodSchemaToCoSchema.d.ts +0 -9
- package/dist/tools/implementation/zodSchema/runtimeConverters/zodSchemaToCoSchema.d.ts.map +0 -1
- package/src/tools/implementation/zodSchema/runtimeConverters/zodFieldToCoFieldDef.ts +0 -172
- package/src/tools/implementation/zodSchema/runtimeConverters/zodSchemaToCoSchema.ts +0 -218
package/package.json
CHANGED
@@ -139,7 +139,7 @@
|
|
139
139
|
},
|
140
140
|
"type": "module",
|
141
141
|
"license": "MIT",
|
142
|
-
"version": "0.
|
142
|
+
"version": "0.16.0",
|
143
143
|
"dependencies": {
|
144
144
|
"@manuscripts/prosemirror-recreate-steps": "^0.1.4",
|
145
145
|
"@scure/base": "1.2.1",
|
@@ -157,10 +157,10 @@
|
|
157
157
|
"prosemirror-schema-basic": "^1.2.2",
|
158
158
|
"prosemirror-state": "^1.4.3",
|
159
159
|
"prosemirror-transform": "^1.9.0",
|
160
|
-
"zod": "3.25.
|
161
|
-
"cojson": "0.
|
162
|
-
"cojson-storage-indexeddb": "0.
|
163
|
-
"cojson-transport-ws": "0.
|
160
|
+
"zod": "3.25.76",
|
161
|
+
"cojson": "0.16.0",
|
162
|
+
"cojson-storage-indexeddb": "0.16.0",
|
163
|
+
"cojson-transport-ws": "0.16.0"
|
164
164
|
},
|
165
165
|
"devDependencies": {
|
166
166
|
"@scure/bip39": "^1.3.0",
|
@@ -171,8 +171,9 @@
|
|
171
171
|
"@types/react": "19.1.0",
|
172
172
|
"@types/react-dom": "19.1.0",
|
173
173
|
"@vitest/browser": "^3.2.4",
|
174
|
-
"
|
174
|
+
"msw": "^2.10.3",
|
175
175
|
"playwright": "^1.50.1",
|
176
|
+
"queueueue": "^4.1.2",
|
176
177
|
"tsup": "8.5.0",
|
177
178
|
"typescript": "5.6.2",
|
178
179
|
"vitest": "3.2.4",
|
package/src/browser/index.ts
CHANGED
@@ -1,9 +1,7 @@
|
|
1
1
|
import {
|
2
2
|
Account,
|
3
3
|
CoValue,
|
4
|
-
|
5
|
-
CoValueOrZodSchema,
|
6
|
-
ID,
|
4
|
+
CoValueClassOrSchema,
|
7
5
|
InviteSecret,
|
8
6
|
createInviteLink as baseCreateInviteLink,
|
9
7
|
consumeInviteLink,
|
@@ -36,7 +34,7 @@ export { parseInviteLink } from "jazz-tools";
|
|
36
34
|
|
37
35
|
/** @category Invite Links */
|
38
36
|
export async function consumeInviteLinkFromWindowLocation<
|
39
|
-
S extends
|
37
|
+
S extends CoValueClassOrSchema,
|
40
38
|
>({
|
41
39
|
as,
|
42
40
|
forValueHint,
|
@@ -17,7 +17,7 @@ export async function createImage(
|
|
17
17
|
owner?: Group | Account;
|
18
18
|
maxSize?: 256 | 1024 | 2048;
|
19
19
|
},
|
20
|
-
): Promise<Loaded<typeof ImageDefinition>> {
|
20
|
+
): Promise<Loaded<typeof ImageDefinition, { $each: true }>> {
|
21
21
|
// Get the original size of the image
|
22
22
|
const { width: originalWidth, height: originalHeight } =
|
23
23
|
await getImageSize(imageBlobOrFile);
|
package/src/react/hooks.tsx
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
import { consumeInviteLinkFromWindowLocation } from "jazz-tools/browser";
|
2
2
|
import { useEffect } from "react";
|
3
3
|
|
4
|
-
import {
|
4
|
+
import { CoValueClassOrSchema } from "jazz-tools";
|
5
5
|
import { useJazzContext } from "jazz-tools/react-core";
|
6
6
|
|
7
7
|
export { useCoState, useAuthSecretStorage } from "jazz-tools/react-core";
|
8
8
|
|
9
|
-
export function useAcceptInvite<S extends
|
9
|
+
export function useAcceptInvite<S extends CoValueClassOrSchema>({
|
10
10
|
invitedObjectSchema,
|
11
11
|
onAccept,
|
12
12
|
forValueHint,
|
package/src/react-core/hooks.ts
CHANGED
@@ -11,7 +11,7 @@ import {
|
|
11
11
|
AnonymousJazzAgent,
|
12
12
|
AnyAccountSchema,
|
13
13
|
CoValue,
|
14
|
-
|
14
|
+
CoValueClassOrSchema,
|
15
15
|
InboxSender,
|
16
16
|
InstanceOfSchema,
|
17
17
|
JazzContextManager,
|
@@ -20,7 +20,7 @@ import {
|
|
20
20
|
ResolveQuery,
|
21
21
|
ResolveQueryStrict,
|
22
22
|
SubscriptionScope,
|
23
|
-
|
23
|
+
coValueClassFromCoValueClassOrSchema,
|
24
24
|
} from "jazz-tools";
|
25
25
|
import { JazzContext, JazzContextManagerContext } from "./provider.js";
|
26
26
|
import { getCurrentAccountFromContextManager } from "./utils.js";
|
@@ -80,7 +80,7 @@ export function useIsAuthenticated() {
|
|
80
80
|
}
|
81
81
|
|
82
82
|
function useCoValueSubscription<
|
83
|
-
S extends
|
83
|
+
S extends CoValueClassOrSchema,
|
84
84
|
const R extends ResolveQuery<S>,
|
85
85
|
>(
|
86
86
|
Schema: S,
|
@@ -107,7 +107,7 @@ function useCoValueSubscription<
|
|
107
107
|
options?.resolve ?? true,
|
108
108
|
id,
|
109
109
|
{
|
110
|
-
ref:
|
110
|
+
ref: coValueClassFromCoValueClassOrSchema(Schema),
|
111
111
|
optional: true,
|
112
112
|
},
|
113
113
|
);
|
@@ -142,7 +142,7 @@ function useCoValueSubscription<
|
|
142
142
|
}
|
143
143
|
|
144
144
|
export function useCoState<
|
145
|
-
S extends
|
145
|
+
S extends CoValueClassOrSchema,
|
146
146
|
const R extends ResolveQuery<S> = true,
|
147
147
|
>(
|
148
148
|
Schema: S,
|
@@ -198,7 +198,7 @@ function useAccountSubscription<
|
|
198
198
|
|
199
199
|
const node = contextManager.getCurrentValue()!.node;
|
200
200
|
const subscription = new SubscriptionScope<any>(node, resolve, agent.id, {
|
201
|
-
ref:
|
201
|
+
ref: coValueClassFromCoValueClassOrSchema(Schema),
|
202
202
|
optional: true,
|
203
203
|
});
|
204
204
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
// @vitest-environment happy-dom
|
2
2
|
|
3
|
-
import { RefsToResolve, co, z
|
3
|
+
import { RefsToResolve, co, z } from "jazz-tools";
|
4
4
|
import { beforeEach, describe, expect, it } from "vitest";
|
5
5
|
import { useAccount, useJazzContextManager } from "../hooks.js";
|
6
6
|
import { useIsAuthenticated } from "../index.js";
|
@@ -46,7 +46,7 @@ describe("useAccount", () => {
|
|
46
46
|
});
|
47
47
|
|
48
48
|
const account = await createJazzTestAccount({
|
49
|
-
AccountSchema
|
49
|
+
AccountSchema,
|
50
50
|
});
|
51
51
|
|
52
52
|
const { result } = renderHook(
|
@@ -520,12 +520,13 @@ describe("useCoState", () => {
|
|
520
520
|
const Message = co.map({
|
521
521
|
content: CoRichText,
|
522
522
|
});
|
523
|
+
const Messages = co.list(Message);
|
523
524
|
const Thread = co.map({
|
524
|
-
messages:
|
525
|
+
messages: Messages,
|
525
526
|
});
|
526
527
|
|
527
528
|
const thread = Thread.create({
|
528
|
-
messages:
|
529
|
+
messages: Messages.create([
|
529
530
|
Message.create({
|
530
531
|
content: CoRichText.create("Hello man!"),
|
531
532
|
}),
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { useEffect } from "react";
|
2
2
|
|
3
|
-
import {
|
3
|
+
import { CoValueClassOrSchema, parseInviteLink } from "jazz-tools";
|
4
4
|
import { useJazzContext } from "jazz-tools/react-core";
|
5
5
|
import { Linking } from "react-native";
|
6
6
|
|
@@ -15,7 +15,7 @@ export {
|
|
15
15
|
useAccount,
|
16
16
|
} from "jazz-tools/react-core";
|
17
17
|
|
18
|
-
export function useAcceptInviteNative<S extends
|
18
|
+
export function useAcceptInviteNative<S extends CoValueClassOrSchema>({
|
19
19
|
invitedObjectSchema,
|
20
20
|
onAccept,
|
21
21
|
forValueHint,
|
@@ -2,21 +2,24 @@ import type {
|
|
2
2
|
Account,
|
3
3
|
AccountClass,
|
4
4
|
AnyAccountSchema,
|
5
|
+
CoValueClassOrSchema,
|
5
6
|
CoValueFromRaw,
|
6
|
-
CoValueOrZodSchema,
|
7
7
|
InstanceOfSchema,
|
8
8
|
Loaded,
|
9
9
|
ResolveQuery,
|
10
10
|
ResolveQueryStrict,
|
11
11
|
} from "jazz-tools";
|
12
|
-
import {
|
12
|
+
import {
|
13
|
+
coValueClassFromCoValueClassOrSchema,
|
14
|
+
subscribeToCoValue,
|
15
|
+
} from "jazz-tools";
|
13
16
|
import { untrack } from "svelte";
|
14
17
|
import { createSubscriber } from "svelte/reactivity";
|
15
18
|
import { useIsAuthenticated } from "./auth/useIsAuthenticated.svelte.js";
|
16
19
|
import { getJazzContext } from "./jazz.svelte";
|
17
20
|
|
18
21
|
export class CoState<
|
19
|
-
V extends
|
22
|
+
V extends CoValueClassOrSchema,
|
20
23
|
R extends ResolveQuery<V> = true,
|
21
24
|
> {
|
22
25
|
#value: Loaded<V, R> | undefined | null = undefined;
|
@@ -47,10 +50,10 @@ export class CoState<
|
|
47
50
|
const agent = "me" in ctx ? ctx.me : ctx.guest;
|
48
51
|
|
49
52
|
const unsubscribe = subscribeToCoValue(
|
50
|
-
|
53
|
+
coValueClassFromCoValueClassOrSchema(Schema),
|
51
54
|
id,
|
52
55
|
{
|
53
|
-
// @ts-expect-error The resolve query type isn't compatible with the
|
56
|
+
// @ts-expect-error The resolve query type isn't compatible with the coValueClassFromCoValueClassOrSchema conversion
|
54
57
|
resolve: options?.resolve,
|
55
58
|
loadAs: agent,
|
56
59
|
onUnavailable: () => {
|
@@ -112,10 +115,10 @@ export class AccountCoState<
|
|
112
115
|
const me = ctx.me;
|
113
116
|
|
114
117
|
const unsubscribe = subscribeToCoValue(
|
115
|
-
|
118
|
+
coValueClassFromCoValueClassOrSchema(Schema),
|
116
119
|
me.id,
|
117
120
|
{
|
118
|
-
// @ts-expect-error The resolve query type isn't compatible with the
|
121
|
+
// @ts-expect-error The resolve query type isn't compatible with the coValueClassFromCoValueClassOrSchema conversion
|
119
122
|
resolve: options?.resolve,
|
120
123
|
loadAs: me,
|
121
124
|
onUnavailable: () => {
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import type {
|
2
2
|
AccountClass,
|
3
3
|
AuthSecretStorage,
|
4
|
-
|
4
|
+
CoValueClassOrSchema,
|
5
5
|
ID,
|
6
6
|
InstanceOfSchema,
|
7
7
|
JazzContextType,
|
@@ -66,7 +66,7 @@ export function getAuthSecretStorage() {
|
|
66
66
|
* @param forValueHint - Hint for the value.
|
67
67
|
* @returns The accept invite hook.
|
68
68
|
*/
|
69
|
-
export class InviteListener<V extends
|
69
|
+
export class InviteListener<V extends CoValueClassOrSchema> {
|
70
70
|
constructor({
|
71
71
|
invitedObjectSchema,
|
72
72
|
onAccept,
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { ControlledAccount, RawAccount, type RawCoValue } from "cojson";
|
2
|
-
import {
|
2
|
+
import { CoreCoValueSchema } from "../implementation/zodSchema/schemaTypes/CoValueSchema.js";
|
3
3
|
import {
|
4
4
|
AnonymousJazzAgent,
|
5
5
|
CoValue,
|
@@ -8,13 +8,14 @@ import {
|
|
8
8
|
ID,
|
9
9
|
RegisteredSchemas,
|
10
10
|
accessChildById,
|
11
|
-
|
11
|
+
coValueClassFromCoValueClassOrSchema,
|
12
12
|
coValuesCache,
|
13
13
|
inspect,
|
14
14
|
isCoValueSchema,
|
15
15
|
} from "../internal.js";
|
16
16
|
import type {
|
17
17
|
Account,
|
18
|
+
CoValueClassOrSchema,
|
18
19
|
Group,
|
19
20
|
InstanceOfSchemaCoValuesNullable,
|
20
21
|
} from "../internal.js";
|
@@ -46,9 +47,9 @@ export class CoValueBase implements CoValue {
|
|
46
47
|
|
47
48
|
if (agent instanceof ControlledAccount) {
|
48
49
|
return coValuesCache.get(agent.account, () =>
|
49
|
-
|
50
|
-
|
51
|
-
),
|
50
|
+
coValueClassFromCoValueClassOrSchema(
|
51
|
+
RegisteredSchemas["Account"],
|
52
|
+
).fromRaw(agent.account),
|
52
53
|
);
|
53
54
|
}
|
54
55
|
|
@@ -81,24 +82,11 @@ export class CoValueBase implements CoValue {
|
|
81
82
|
}
|
82
83
|
|
83
84
|
/** @category Type Helpers */
|
84
|
-
castAs<
|
85
|
-
S extends
|
86
|
-
| CoValueClass
|
87
|
-
| z.core.$ZodType
|
88
|
-
| (z.core.$ZodObject<any, any> & {
|
89
|
-
builtin: "Account";
|
90
|
-
migration?: (account: any, creationProps?: { name: string }) => void;
|
91
|
-
})
|
92
|
-
| (z.core.$ZodCustom<any, any> & { builtin: "FileStream" })
|
93
|
-
| (z.core.$ZodCustom<any, any> & {
|
94
|
-
builtin: "CoFeed";
|
95
|
-
element: z.core.$ZodType;
|
96
|
-
}),
|
97
|
-
>(
|
85
|
+
castAs<S extends CoValueClassOrSchema>(
|
98
86
|
schema: S,
|
99
87
|
): S extends CoValueClass
|
100
88
|
? InstanceType<S>
|
101
|
-
: S extends
|
89
|
+
: S extends CoreCoValueSchema
|
102
90
|
? NonNullable<InstanceOfSchemaCoValuesNullable<S>>
|
103
91
|
: never {
|
104
92
|
const cl = isCoValueSchema(schema) ? schema.getCoValueClass() : schema;
|
@@ -16,12 +16,12 @@ import {
|
|
16
16
|
} from "cojson";
|
17
17
|
import {
|
18
18
|
AnonymousJazzAgent,
|
19
|
-
AnyAccountSchema,
|
20
19
|
type CoMap,
|
21
20
|
type CoValue,
|
22
21
|
CoValueBase,
|
23
22
|
CoValueClass,
|
24
|
-
|
23
|
+
CoValueClassOrSchema,
|
24
|
+
CoreAccountSchema,
|
25
25
|
type Group,
|
26
26
|
ID,
|
27
27
|
InstanceOfSchema,
|
@@ -40,7 +40,7 @@ import {
|
|
40
40
|
SubscribeRestArgs,
|
41
41
|
accessChildByKey,
|
42
42
|
activeAccountContext,
|
43
|
-
|
43
|
+
coValueClassFromCoValueClassOrSchema,
|
44
44
|
coValuesCache,
|
45
45
|
createInboxRoot,
|
46
46
|
ensureCoValueLoaded,
|
@@ -254,7 +254,7 @@ export class Account extends CoValueBase implements CoValue {
|
|
254
254
|
return value._owner.getRoleOf(this.id) === "admin";
|
255
255
|
}
|
256
256
|
|
257
|
-
async acceptInvite<S extends
|
257
|
+
async acceptInvite<S extends CoValueClassOrSchema>(
|
258
258
|
valueID: string,
|
259
259
|
inviteSecret: InviteSecret,
|
260
260
|
coValueClass: S,
|
@@ -268,9 +268,13 @@ export class Account extends CoValueBase implements CoValue {
|
|
268
268
|
inviteSecret,
|
269
269
|
);
|
270
270
|
|
271
|
-
return loadCoValue(
|
272
|
-
|
273
|
-
|
271
|
+
return loadCoValue(
|
272
|
+
coValueClassFromCoValueClassOrSchema(coValueClass),
|
273
|
+
valueID,
|
274
|
+
{
|
275
|
+
loadAs: this,
|
276
|
+
},
|
277
|
+
) as Resolved<InstanceOrPrimitiveOfSchema<S>, true> | null;
|
274
278
|
}
|
275
279
|
|
276
280
|
/** @private */
|
@@ -447,9 +451,7 @@ export class Account extends CoValueBase implements CoValue {
|
|
447
451
|
*
|
448
452
|
* @category Subscription & Loading
|
449
453
|
*/
|
450
|
-
waitForSync(options?: {
|
451
|
-
timeout?: number;
|
452
|
-
}) {
|
454
|
+
waitForSync(options?: { timeout?: number }) {
|
453
455
|
return this._raw.core.waitForSync(options);
|
454
456
|
}
|
455
457
|
|
@@ -458,9 +460,7 @@ export class Account extends CoValueBase implements CoValue {
|
|
458
460
|
*
|
459
461
|
* @category Subscription & Loading
|
460
462
|
*/
|
461
|
-
waitForAllCoValuesSync(options?: {
|
462
|
-
timeout?: number;
|
463
|
-
}) {
|
463
|
+
waitForAllCoValuesSync(options?: { timeout?: number }) {
|
464
464
|
return this._raw.core.node.syncManager.waitForAllCoValuesSync(
|
465
465
|
options?.timeout,
|
466
466
|
);
|
@@ -502,7 +502,11 @@ export const AccountAndGroupProxyHandler: ProxyHandler<Account | Group> = {
|
|
502
502
|
return true;
|
503
503
|
} else if (key === "root") {
|
504
504
|
if (value) {
|
505
|
-
target._raw.set(
|
505
|
+
target._raw.set(
|
506
|
+
"root",
|
507
|
+
value.id as unknown as CoID<RawCoMap>,
|
508
|
+
"trusting",
|
509
|
+
);
|
506
510
|
}
|
507
511
|
return true;
|
508
512
|
} else {
|
@@ -12,12 +12,10 @@ import type {
|
|
12
12
|
import { MAX_RECOMMENDED_TX_SIZE, cojsonInternals } from "cojson";
|
13
13
|
import type {
|
14
14
|
AnonymousJazzAgent,
|
15
|
-
AnyAccountSchema,
|
16
15
|
CoValue,
|
17
16
|
CoValueClass,
|
18
17
|
Group,
|
19
18
|
ID,
|
20
|
-
InstanceOfSchema,
|
21
19
|
RefsToResolve,
|
22
20
|
RefsToResolveStrict,
|
23
21
|
Resolved,
|
@@ -31,10 +29,8 @@ import {
|
|
31
29
|
CoValueBase,
|
32
30
|
ItemsSym,
|
33
31
|
Ref,
|
34
|
-
RegisteredSchemas,
|
35
32
|
SchemaInit,
|
36
33
|
accessChildById,
|
37
|
-
anySchemaToCoSchema,
|
38
34
|
coField,
|
39
35
|
ensureCoValueLoaded,
|
40
36
|
inspect,
|
@@ -3,13 +3,11 @@ import { ControlledAccount, RawAccount } from "cojson";
|
|
3
3
|
import { calcPatch } from "fast-myers-diff";
|
4
4
|
import type {
|
5
5
|
Account,
|
6
|
-
AnyAccountSchema,
|
7
6
|
CoValue,
|
8
7
|
CoValueClass,
|
9
8
|
CoValueFromRaw,
|
10
9
|
Group,
|
11
10
|
ID,
|
12
|
-
InstanceOfSchema,
|
13
11
|
RefEncoded,
|
14
12
|
RefsToResolve,
|
15
13
|
RefsToResolveStrict,
|
@@ -26,8 +24,8 @@ import {
|
|
26
24
|
RegisteredSchemas,
|
27
25
|
SchemaInit,
|
28
26
|
accessChildByKey,
|
29
|
-
anySchemaToCoSchema,
|
30
27
|
coField,
|
28
|
+
coValueClassFromCoValueClassOrSchema,
|
31
29
|
coValuesCache,
|
32
30
|
ensureCoValueLoaded,
|
33
31
|
inspect,
|
@@ -117,9 +115,9 @@ export class CoList<out Item = any> extends Array<Item> implements CoValue {
|
|
117
115
|
/** @category Collaboration */
|
118
116
|
get _owner(): Account | Group {
|
119
117
|
return this._raw.group instanceof RawAccount
|
120
|
-
?
|
121
|
-
|
122
|
-
)
|
118
|
+
? coValueClassFromCoValueClassOrSchema(
|
119
|
+
RegisteredSchemas["Account"],
|
120
|
+
).fromRaw(this._raw.group)
|
123
121
|
: RegisteredSchemas["Group"].fromRaw(this._raw.group);
|
124
122
|
}
|
125
123
|
|
@@ -175,9 +173,9 @@ export class CoList<out Item = any> extends Array<Item> implements CoValue {
|
|
175
173
|
|
176
174
|
if (agent instanceof ControlledAccount) {
|
177
175
|
return coValuesCache.get(agent.account, () =>
|
178
|
-
|
179
|
-
|
180
|
-
),
|
176
|
+
coValueClassFromCoValueClassOrSchema(
|
177
|
+
RegisteredSchemas["Account"],
|
178
|
+
).fromRaw(agent.account),
|
181
179
|
);
|
182
180
|
}
|
183
181
|
|
@@ -20,6 +20,7 @@ import type {
|
|
20
20
|
RefsToResolveStrict,
|
21
21
|
Resolved,
|
22
22
|
Schema,
|
23
|
+
Simplify,
|
23
24
|
SubscribeListenerOptions,
|
24
25
|
SubscribeRestArgs,
|
25
26
|
} from "../internal.js";
|
@@ -54,12 +55,6 @@ type CoMapEdit<V> = {
|
|
54
55
|
|
55
56
|
type LastAndAllCoMapEdits<V> = CoMapEdit<V> & { all: CoMapEdit<V>[] };
|
56
57
|
|
57
|
-
export type Simplify<A> = {
|
58
|
-
[K in keyof A]: A[K];
|
59
|
-
} extends infer B
|
60
|
-
? B
|
61
|
-
: never;
|
62
|
-
|
63
58
|
/**
|
64
59
|
* CoMaps are collaborative versions of plain objects, mapping string-like keys to values.
|
65
60
|
*
|
@@ -14,7 +14,7 @@ import {
|
|
14
14
|
Resolved,
|
15
15
|
SubscribeListenerOptions,
|
16
16
|
SubscribeRestArgs,
|
17
|
-
|
17
|
+
coValueClassFromCoValueClassOrSchema,
|
18
18
|
parseCoValueCreateOptions,
|
19
19
|
} from "../internal.js";
|
20
20
|
import {
|
@@ -47,9 +47,9 @@ export class CoPlainText extends String implements CoValue {
|
|
47
47
|
|
48
48
|
if (agent instanceof ControlledAccount) {
|
49
49
|
return coValuesCache.get(agent.account, () =>
|
50
|
-
|
51
|
-
|
52
|
-
),
|
50
|
+
coValueClassFromCoValueClassOrSchema(
|
51
|
+
RegisteredSchemas["Account"],
|
52
|
+
).fromRaw(agent.account),
|
53
53
|
);
|
54
54
|
}
|
55
55
|
|
@@ -5,7 +5,10 @@ import { CoFeedEntry } from "./coFeed.js";
|
|
5
5
|
import { type CoKeys } from "./coMap.js";
|
6
6
|
import { type CoValue, type ID } from "./interfaces.js";
|
7
7
|
|
8
|
-
|
8
|
+
/**
|
9
|
+
* Similar to {@link NonNullable}, but removes only `null` and preserves `undefined`.
|
10
|
+
*/
|
11
|
+
export type NotNull<T> = Exclude<T, null>;
|
9
12
|
|
10
13
|
/**
|
11
14
|
* Used to check if T is a union type.
|
@@ -8,9 +8,9 @@ const ImageDefinitionBase = coMapDefiner({
|
|
8
8
|
}).catchall(coFileStreamDefiner());
|
9
9
|
|
10
10
|
/** @category Media */
|
11
|
-
export const ImageDefinition =
|
11
|
+
export const ImageDefinition = Object.assign({}, ImageDefinitionBase, {
|
12
12
|
highestResAvailable(
|
13
|
-
imageDef:
|
13
|
+
imageDef: ImageDefinition,
|
14
14
|
options?: {
|
15
15
|
maxWidth?: number;
|
16
16
|
targetWidth?: number;
|
@@ -56,5 +56,5 @@ export const ImageDefinition = ImageDefinitionBase.withHelpers((Self) => ({
|
|
56
56
|
}
|
57
57
|
);
|
58
58
|
},
|
59
|
-
})
|
59
|
+
});
|
60
60
|
export type ImageDefinition = Loaded<typeof ImageDefinition>;
|
@@ -153,6 +153,7 @@ export class Group extends CoValueBase implements CoValue {
|
|
153
153
|
member: Group,
|
154
154
|
role?: "reader" | "writer" | "admin" | "inherit",
|
155
155
|
): void;
|
156
|
+
addMember(member: Group | Account, role: "reader" | "writer" | "admin"): void;
|
156
157
|
addMember(
|
157
158
|
member: Group | Everyone | Account,
|
158
159
|
role?: AccountRole | "inherit",
|
@@ -3,13 +3,14 @@ import { CoStreamItem, RawCoStream } from "cojson";
|
|
3
3
|
import {
|
4
4
|
type Account,
|
5
5
|
CoValue,
|
6
|
-
|
6
|
+
CoValueClassOrSchema,
|
7
7
|
ID,
|
8
8
|
InstanceOfSchema,
|
9
9
|
activeAccountContext,
|
10
|
-
|
10
|
+
coValueClassFromCoValueClassOrSchema,
|
11
11
|
loadCoValue,
|
12
12
|
} from "../internal.js";
|
13
|
+
import { isCoValueId } from "../lib/id.js";
|
13
14
|
|
14
15
|
export type InboxInvite = `${CoID<MessagesStream>}/${InviteSecret}`;
|
15
16
|
type TxKey = `${SessionID}/${number}`;
|
@@ -108,7 +109,7 @@ export class Inbox {
|
|
108
109
|
this.failed = failed;
|
109
110
|
}
|
110
111
|
|
111
|
-
subscribe<M extends
|
112
|
+
subscribe<M extends CoValueClassOrSchema, O extends CoValue | undefined>(
|
112
113
|
Schema: M,
|
113
114
|
callback: (
|
114
115
|
message: InstanceOfSchema<M>,
|
@@ -171,7 +172,7 @@ export class Inbox {
|
|
171
172
|
}
|
172
173
|
|
173
174
|
return loadCoValue(
|
174
|
-
|
175
|
+
coValueClassFromCoValueClassOrSchema(Schema),
|
175
176
|
message.get("payload")!,
|
176
177
|
{
|
177
178
|
loadAs: account,
|
@@ -382,7 +383,7 @@ async function acceptInvite(invite: string, account?: Account) {
|
|
382
383
|
|
383
384
|
const inviteSecret = invite.slice(invite.indexOf("/") + 1) as InviteSecret;
|
384
385
|
|
385
|
-
if (!id
|
386
|
+
if (!isCoValueId(id) || !inviteSecret.startsWith("inviteSecret_")) {
|
386
387
|
throw new Error("Invalid inbox ticket");
|
387
388
|
}
|
388
389
|
|
@@ -399,8 +400,8 @@ function getAccountIDfromSessionID(sessionID: SessionID) {
|
|
399
400
|
const until = sessionID.indexOf("_session");
|
400
401
|
const accountID = sessionID.slice(0, until);
|
401
402
|
|
402
|
-
if (accountID
|
403
|
-
return accountID
|
403
|
+
if (isCoValueId(accountID)) {
|
404
|
+
return accountID;
|
404
405
|
}
|
405
406
|
|
406
407
|
return;
|