jazz-tools 0.17.14 → 0.18.1
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 +60 -46
- package/CHANGELOG.md +41 -0
- package/dist/better-auth/auth/client.d.ts +29 -0
- package/dist/better-auth/auth/client.d.ts.map +1 -0
- package/dist/better-auth/auth/client.js +127 -0
- package/dist/better-auth/auth/client.js.map +1 -0
- package/dist/better-auth/auth/react.d.ts +2170 -0
- package/dist/better-auth/auth/react.d.ts.map +1 -0
- package/dist/better-auth/auth/react.js +40 -0
- package/dist/better-auth/auth/react.js.map +1 -0
- package/dist/better-auth/auth/server.d.ts +14 -0
- package/dist/better-auth/auth/server.d.ts.map +1 -0
- package/dist/better-auth/auth/server.js +198 -0
- package/dist/better-auth/auth/server.js.map +1 -0
- package/dist/better-auth/auth/tests/client.test.d.ts +2 -0
- package/dist/better-auth/auth/tests/client.test.d.ts.map +1 -0
- package/dist/better-auth/auth/tests/server.test.d.ts +2 -0
- package/dist/better-auth/auth/tests/server.test.d.ts.map +1 -0
- package/dist/browser/index.js +2 -2
- package/dist/browser/index.js.map +1 -1
- package/dist/{chunk-LZOF6WP5.js → chunk-IERUTUXB.js} +1336 -1017
- package/dist/chunk-IERUTUXB.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 +4675 -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 +101 -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 +210 -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 +3 -3
- 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 +23 -4
- package/src/better-auth/auth/client.ts +169 -0
- package/src/better-auth/auth/react.tsx +105 -0
- package/src/better-auth/auth/server.ts +250 -0
- package/src/better-auth/auth/tests/client.test.ts +249 -0
- package/src/better-auth/auth/tests/server.test.ts +226 -0
- 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 +311 -232
- package/src/tools/coValues/coFeed.ts +185 -153
- package/src/tools/coValues/coList.ts +507 -334
- package/src/tools/coValues/coMap.ts +434 -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 +3 -3
- 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 +70 -59
- package/src/tools/tests/PassphraseAuth.test.ts +2 -2
- package/src/tools/tests/account.test.ts +188 -67
- 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 +459 -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 +7 -7
- 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 +7 -11
- 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/tsup.config.ts +9 -0
- 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
package/src/tools/implementation/zodSchema/typeConverters/{CoFieldInit.ts → CoFieldSchemaInit.ts}
RENAMED
@@ -22,7 +22,7 @@ import { TypeOfZodSchema } from "./TypeOfZodSchema.js";
|
|
22
22
|
* For CoValue fields, this can be either a shallowly-loaded CoValue instance
|
23
23
|
* or a JSON object that will be used to create the CoValue.
|
24
24
|
*/
|
25
|
-
export type
|
25
|
+
export type CoFieldSchemaInit<S extends CoValueClass | AnyZodOrCoValueSchema> =
|
26
26
|
S extends CoreCoValueSchema
|
27
27
|
?
|
28
28
|
| Loaded<S>
|
@@ -31,15 +31,15 @@ export type CoFieldInit<S extends CoValueClass | AnyZodOrCoValueSchema> =
|
|
31
31
|
: S extends CoreCoMapSchema<infer Shape>
|
32
32
|
? CoMapSchemaInit<Shape>
|
33
33
|
: S extends CoreCoListSchema<infer T>
|
34
|
-
?
|
34
|
+
? CoListSchemaInit<T>
|
35
35
|
: S extends CoreCoFeedSchema<infer T>
|
36
|
-
?
|
36
|
+
? CoFeedSchemaInit<T>
|
37
37
|
: S extends CorePlainTextSchema | CoreRichTextSchema
|
38
38
|
? string
|
39
39
|
: S extends CoreCoOptionalSchema<infer T>
|
40
|
-
?
|
40
|
+
? CoFieldSchemaInit<T> | undefined
|
41
41
|
: S extends CoDiscriminatedUnionSchema<infer Members>
|
42
|
-
?
|
42
|
+
? CoFieldSchemaInit<Members[number]>
|
43
43
|
: never)
|
44
44
|
: S extends z.core.$ZodType
|
45
45
|
? TypeOfZodSchema<S>
|
@@ -59,20 +59,20 @@ export type CoMapSchemaInit<Shape extends z.core.$ZodLooseShape> = Simplify<
|
|
59
59
|
| CoreCoOptionalSchema
|
60
60
|
| z.core.$ZodOptional
|
61
61
|
? never
|
62
|
-
: Key]:
|
62
|
+
: Key]: CoFieldSchemaInit<Shape[Key]>;
|
63
63
|
} & {
|
64
64
|
[Key in keyof Shape as Shape[Key] extends
|
65
65
|
| CoreCoOptionalSchema
|
66
66
|
| z.core.$ZodOptional
|
67
67
|
? Key
|
68
|
-
: never]?:
|
68
|
+
: never]?: CoFieldSchemaInit<Shape[Key]>;
|
69
69
|
}
|
70
70
|
>;
|
71
71
|
|
72
|
-
export type
|
73
|
-
ReadonlyArray<
|
72
|
+
export type CoListSchemaInit<T extends AnyZodOrCoValueSchema> = Simplify<
|
73
|
+
ReadonlyArray<CoFieldSchemaInit<T>>
|
74
74
|
>;
|
75
75
|
|
76
|
-
export type
|
77
|
-
ReadonlyArray<
|
76
|
+
export type CoFeedSchemaInit<T extends AnyZodOrCoValueSchema> = Simplify<
|
77
|
+
ReadonlyArray<CoFieldSchemaInit<T>>
|
78
78
|
>;
|
@@ -27,23 +27,23 @@ export type InstanceOfSchema<S extends CoValueClass | AnyZodOrCoValueSchema> =
|
|
27
27
|
S extends CoreCoValueSchema
|
28
28
|
? S extends CoreAccountSchema<infer Shape>
|
29
29
|
? {
|
30
|
-
|
30
|
+
readonly [key in keyof Shape]: InstanceOrPrimitiveOfSchema<
|
31
31
|
Shape[key]
|
32
32
|
>;
|
33
33
|
} & Account
|
34
34
|
: S extends CoreCoRecordSchema<infer K, infer V>
|
35
35
|
? {
|
36
|
-
|
36
|
+
readonly [key in z.output<K> &
|
37
37
|
string]: InstanceOrPrimitiveOfSchema<V>;
|
38
38
|
} & CoMap
|
39
39
|
: S extends CoreCoMapSchema<infer Shape, infer CatchAll>
|
40
40
|
? {
|
41
|
-
|
41
|
+
readonly [key in keyof Shape]: InstanceOrPrimitiveOfSchema<
|
42
42
|
Shape[key]
|
43
43
|
>;
|
44
44
|
} & (CatchAll extends AnyZodOrCoValueSchema
|
45
45
|
? {
|
46
|
-
[key: string]: InstanceOrPrimitiveOfSchema<CatchAll>;
|
46
|
+
readonly [key: string]: InstanceOrPrimitiveOfSchema<CatchAll>;
|
47
47
|
}
|
48
48
|
: {}) &
|
49
49
|
CoMap
|
package/src/tools/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.ts
CHANGED
@@ -29,7 +29,7 @@ export type InstanceOfSchemaCoValuesNullable<
|
|
29
29
|
? S extends CoreAccountSchema<infer Shape>
|
30
30
|
?
|
31
31
|
| ({
|
32
|
-
|
32
|
+
readonly [key in keyof Shape]: InstanceOrPrimitiveOfSchemaCoValuesNullable<
|
33
33
|
Shape[key]
|
34
34
|
>;
|
35
35
|
} & Account)
|
@@ -37,19 +37,19 @@ export type InstanceOfSchemaCoValuesNullable<
|
|
37
37
|
: S extends CoreCoRecordSchema<infer K, infer V>
|
38
38
|
?
|
39
39
|
| ({
|
40
|
-
|
40
|
+
readonly [key in z.output<K> &
|
41
41
|
string]: InstanceOrPrimitiveOfSchemaCoValuesNullable<V>;
|
42
42
|
} & CoMap)
|
43
43
|
| null
|
44
44
|
: S extends CoreCoMapSchema<infer Shape, infer CatchAll>
|
45
45
|
?
|
46
46
|
| ({
|
47
|
-
|
47
|
+
readonly [key in keyof Shape]: InstanceOrPrimitiveOfSchemaCoValuesNullable<
|
48
48
|
Shape[key]
|
49
49
|
>;
|
50
50
|
} & (CatchAll extends AnyZodOrCoValueSchema
|
51
51
|
? {
|
52
|
-
[
|
52
|
+
readonly [
|
53
53
|
key: string
|
54
54
|
]: InstanceOrPrimitiveOfSchemaCoValuesNullable<CatchAll>;
|
55
55
|
}
|
@@ -101,12 +101,12 @@ export const coMapDefiner = <Shape extends z.core.$ZodLooseShape>(
|
|
101
101
|
* }),
|
102
102
|
* }).withMigration(async (account) => {
|
103
103
|
* // Migration logic for existing accounts
|
104
|
-
* if (account.profile
|
104
|
+
* if (!account.$jazz.has("profile")) {
|
105
105
|
* const group = Group.create();
|
106
|
-
* account.profile
|
106
|
+
* account.$jazz.set("profile", co.profile().create(
|
107
107
|
* { name: getRandomUsername() },
|
108
108
|
* group
|
109
|
-
* );
|
109
|
+
* ));
|
110
110
|
* group.addMember("everyone", "reader");
|
111
111
|
* }
|
112
112
|
* });
|
package/src/tools/internal.ts
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
export * from "./coValues/interfaces.js";
|
2
2
|
export * from "./coValues/CoValueBase.js";
|
3
|
+
export * from "./coValues/CoFieldInit.js";
|
3
4
|
export * from "./implementation/inspect.js";
|
4
5
|
export * from "./implementation/symbols.js";
|
5
6
|
|
@@ -45,7 +46,7 @@ export * from "./implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSc
|
|
45
46
|
export * from "./implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchemaCoValuesNullable.js";
|
46
47
|
export * from "./implementation/zodSchema/typeConverters/InstanceOfSchema.js";
|
47
48
|
export * from "./implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.js";
|
48
|
-
export * from "./implementation/zodSchema/typeConverters/
|
49
|
+
export * from "./implementation/zodSchema/typeConverters/CoFieldSchemaInit.js";
|
49
50
|
export * from "./implementation/zodSchema/runtimeConverters/coValueSchemaTransformation.js";
|
50
51
|
export * from "./implementation/zodSchema/runtimeConverters/schemaFieldToCoFieldDef.js";
|
51
52
|
export * from "./coValues/extensions/imageDef.js";
|
@@ -1,7 +1,7 @@
|
|
1
|
-
import type
|
1
|
+
import { TypeSym, type CoValue } from "../internal.js";
|
2
2
|
|
3
3
|
export function applyCoValueMigrations(instance: CoValue) {
|
4
|
-
const node = instance.
|
4
|
+
const node = instance.$jazz.raw.core.node;
|
5
5
|
|
6
6
|
// @ts-expect-error _migratedCoValues is a custom expando property
|
7
7
|
const migratedCoValues = (node._migratedCoValues ??= new Set<string>());
|
@@ -9,11 +9,11 @@ export function applyCoValueMigrations(instance: CoValue) {
|
|
9
9
|
if (
|
10
10
|
"migrate" in instance &&
|
11
11
|
typeof instance.migrate === "function" &&
|
12
|
-
instance
|
13
|
-
!migratedCoValues.has(instance.id)
|
12
|
+
instance[TypeSym] !== "Account" &&
|
13
|
+
!migratedCoValues.has(instance.$jazz.id)
|
14
14
|
) {
|
15
15
|
// We flag this before the migration to avoid that internal loads trigger the migration again
|
16
|
-
migratedCoValues.add(instance.id);
|
16
|
+
migratedCoValues.add(instance.$jazz.id);
|
17
17
|
|
18
18
|
const result = instance.migrate?.(instance);
|
19
19
|
if (result && "then" in result) {
|
@@ -7,6 +7,7 @@ import {
|
|
7
7
|
type ID,
|
8
8
|
type RefEncoded,
|
9
9
|
type RefsToResolve,
|
10
|
+
TypeSym,
|
10
11
|
instantiateRefEncodedFromRaw,
|
11
12
|
isRefEncoded,
|
12
13
|
} from "../internal.js";
|
@@ -14,7 +15,7 @@ import { applyCoValueMigrations } from "../lib/migration.js";
|
|
14
15
|
import { CoValueCoreSubscription } from "./CoValueCoreSubscription.js";
|
15
16
|
import { JazzError, type JazzErrorIssue } from "./JazzError.js";
|
16
17
|
import type { SubscriptionValue, Unloaded } from "./types.js";
|
17
|
-
import { createCoValue,
|
18
|
+
import { createCoValue, myRoleForRawValue } from "./utils.js";
|
18
19
|
|
19
20
|
export class SubscriptionScope<D extends CoValue> {
|
20
21
|
childNodes = new Map<string, SubscriptionScope<CoValue>>();
|
@@ -121,7 +122,7 @@ export class SubscriptionScope<D extends CoValue> {
|
|
121
122
|
// Groups and accounts are accessible by everyone, for the other coValues we use the role to check access
|
122
123
|
const hasAccess =
|
123
124
|
ruleset.type !== "ownedByGroup" ||
|
124
|
-
|
125
|
+
myRoleForRawValue(update) !== undefined;
|
125
126
|
|
126
127
|
if (!hasAccess) {
|
127
128
|
if (this.value.type !== "unauthorized") {
|
@@ -152,9 +153,9 @@ export class SubscriptionScope<D extends CoValue> {
|
|
152
153
|
} else {
|
153
154
|
const hasChanged =
|
154
155
|
update.totalValidTransactions !== this.totalValidTransactions ||
|
155
|
-
// Checking the identity of the
|
156
|
+
// Checking the identity of the raw value makes us cover the cases where the group
|
156
157
|
// has been updated and the coValues that don't update the totalValidTransactions value (e.g. FileStream)
|
157
|
-
this.value.value.
|
158
|
+
this.value.value.$jazz.raw !== update;
|
158
159
|
|
159
160
|
if (this.loadChildren()) {
|
160
161
|
this.updateValue(createCoValue(this.schema, update, this));
|
@@ -241,7 +242,7 @@ export class SubscriptionScope<D extends CoValue> {
|
|
241
242
|
// On child updates, we re-create the value instance to make the updates
|
242
243
|
// seamless-immutable and so be compatible with React and the React compiler
|
243
244
|
this.updateValue(
|
244
|
-
createCoValue(this.schema, this.value.value.
|
245
|
+
createCoValue(this.schema, this.value.value.$jazz.raw, this),
|
245
246
|
);
|
246
247
|
}
|
247
248
|
}
|
@@ -300,7 +301,7 @@ export class SubscriptionScope<D extends CoValue> {
|
|
300
301
|
return false;
|
301
302
|
}
|
302
303
|
|
303
|
-
return this.value.value.
|
304
|
+
return this.value.value.$jazz.raw.core.verified.isStreaming();
|
304
305
|
}
|
305
306
|
|
306
307
|
isFileStream() {
|
@@ -308,7 +309,9 @@ export class SubscriptionScope<D extends CoValue> {
|
|
308
309
|
return false;
|
309
310
|
}
|
310
311
|
|
311
|
-
return
|
312
|
+
return (
|
313
|
+
this.value.value.$jazz.raw.core.verified.header.meta?.type === "binary"
|
314
|
+
);
|
312
315
|
}
|
313
316
|
|
314
317
|
triggerUpdate() {
|
@@ -369,11 +372,11 @@ export class SubscriptionScope<D extends CoValue> {
|
|
369
372
|
// This helps alot with correctness when triggering the autoloading while rendering components (on React and Svelte)
|
370
373
|
this.silenceUpdates = true;
|
371
374
|
|
372
|
-
if (value
|
375
|
+
if (value[TypeSym] === "CoMap" || value[TypeSym] === "Account") {
|
373
376
|
const map = value as CoMap;
|
374
377
|
|
375
378
|
this.loadCoMapKey(map, key, true);
|
376
|
-
} else if (value
|
379
|
+
} else if (value[TypeSym] === "CoList") {
|
377
380
|
const list = value as CoList;
|
378
381
|
|
379
382
|
this.loadCoListKey(list, key, true);
|
@@ -427,12 +430,17 @@ export class SubscriptionScope<D extends CoValue> {
|
|
427
430
|
|
428
431
|
const idsToLoad = new Set<string>(this.idsSubscribed);
|
429
432
|
|
430
|
-
const coValueType = value
|
433
|
+
const coValueType = value[TypeSym];
|
431
434
|
|
432
435
|
if (Object.keys(depth).length > 0) {
|
433
|
-
if (
|
436
|
+
if (
|
437
|
+
coValueType === "CoMap" ||
|
438
|
+
coValueType === "Account" ||
|
439
|
+
coValueType === "Group"
|
440
|
+
) {
|
434
441
|
const map = value as CoMap;
|
435
|
-
const keys =
|
442
|
+
const keys =
|
443
|
+
"$each" in depth ? map.$jazz.raw.keys() : Object.keys(depth);
|
436
444
|
|
437
445
|
for (const key of keys) {
|
438
446
|
const id = this.loadCoMapKey(map, key, depth[key] ?? depth.$each);
|
@@ -441,14 +449,14 @@ export class SubscriptionScope<D extends CoValue> {
|
|
441
449
|
idsToLoad.add(id);
|
442
450
|
}
|
443
451
|
}
|
444
|
-
} else if (value
|
452
|
+
} else if (value[TypeSym] === "CoList") {
|
445
453
|
const list = value as CoList;
|
446
454
|
|
447
|
-
const descriptor = list.getItemsDescriptor();
|
455
|
+
const descriptor = list.$jazz.getItemsDescriptor();
|
448
456
|
|
449
457
|
if (descriptor && isRefEncoded(descriptor)) {
|
450
|
-
list.
|
451
|
-
const entries = list.
|
458
|
+
list.$jazz.raw.processNewTransactions();
|
459
|
+
const entries = list.$jazz.raw.entries();
|
452
460
|
const keys =
|
453
461
|
"$each" in depth ? Object.keys(entries) : Object.keys(depth);
|
454
462
|
|
@@ -460,13 +468,13 @@ export class SubscriptionScope<D extends CoValue> {
|
|
460
468
|
}
|
461
469
|
}
|
462
470
|
}
|
463
|
-
} else if (value
|
471
|
+
} else if (value[TypeSym] === "CoStream") {
|
464
472
|
const stream = value as CoFeed;
|
465
|
-
const descriptor = stream.getItemsDescriptor();
|
473
|
+
const descriptor = stream.$jazz.getItemsDescriptor();
|
466
474
|
|
467
475
|
if (descriptor && isRefEncoded(descriptor)) {
|
468
|
-
for (const session of stream.
|
469
|
-
const values = stream.
|
476
|
+
for (const session of stream.$jazz.raw.sessions()) {
|
477
|
+
const values = stream.$jazz.raw.items[session] ?? [];
|
470
478
|
|
471
479
|
for (const [i, item] of values.entries()) {
|
472
480
|
const key = `${session}/${i}`;
|
@@ -525,8 +533,8 @@ export class SubscriptionScope<D extends CoValue> {
|
|
525
533
|
return undefined;
|
526
534
|
}
|
527
535
|
|
528
|
-
const id = map.
|
529
|
-
const descriptor = map.getDescriptor(key);
|
536
|
+
const id = map.$jazz.raw.get(key) as string | undefined;
|
537
|
+
const descriptor = map.$jazz.getDescriptor(key);
|
530
538
|
|
531
539
|
if (!descriptor) {
|
532
540
|
this.childErrors.set(
|
@@ -568,13 +576,13 @@ export class SubscriptionScope<D extends CoValue> {
|
|
568
576
|
}
|
569
577
|
|
570
578
|
loadCoListKey(list: CoList, key: string, depth: Record<string, any> | true) {
|
571
|
-
const descriptor = list.getItemsDescriptor();
|
579
|
+
const descriptor = list.$jazz.getItemsDescriptor();
|
572
580
|
|
573
581
|
if (!descriptor || !isRefEncoded(descriptor)) {
|
574
582
|
return undefined;
|
575
583
|
}
|
576
584
|
|
577
|
-
const entries = list.
|
585
|
+
const entries = list.$jazz.raw.entries();
|
578
586
|
const entry = entries[Number(key)];
|
579
587
|
|
580
588
|
if (!entry) {
|
@@ -2,22 +2,22 @@ import type { CoValue, CoValueClass, RefEncoded } from "../internal.js";
|
|
2
2
|
import { SubscriptionScope } from "./SubscriptionScope.js";
|
3
3
|
|
4
4
|
export function getSubscriptionScope<D extends CoValue>(value: D) {
|
5
|
-
const subscriptionScope = value._subscriptionScope;
|
5
|
+
const subscriptionScope = value.$jazz._subscriptionScope;
|
6
6
|
|
7
7
|
if (subscriptionScope) {
|
8
8
|
return subscriptionScope;
|
9
9
|
}
|
10
10
|
|
11
|
-
const node = value.
|
11
|
+
const node = value.$jazz.raw.core.node;
|
12
12
|
const resolve = true;
|
13
|
-
const id = value.id;
|
13
|
+
const id = value.$jazz.id;
|
14
14
|
|
15
15
|
const newSubscriptionScope = new SubscriptionScope(node, resolve, id, {
|
16
16
|
ref: value.constructor as CoValueClass<D>,
|
17
17
|
optional: false,
|
18
18
|
});
|
19
19
|
|
20
|
-
Object.defineProperty(value, "_subscriptionScope", {
|
20
|
+
Object.defineProperty(value.$jazz, "_subscriptionScope", {
|
21
21
|
value: subscriptionScope,
|
22
22
|
writable: false,
|
23
23
|
enumerable: false,
|
@@ -1,24 +1,24 @@
|
|
1
|
-
import { RawAccount, RawCoValue } from "cojson";
|
1
|
+
import { RawAccount, RawCoValue, Role } from "cojson";
|
2
2
|
import { RegisteredSchemas } from "../coValues/registeredSchemas.js";
|
3
3
|
import {
|
4
4
|
CoValue,
|
5
5
|
RefEncoded,
|
6
|
-
|
6
|
+
accountOrGroupToGroup,
|
7
7
|
instantiateRefEncodedFromRaw,
|
8
8
|
} from "../internal.js";
|
9
9
|
import { coValuesCache } from "../lib/cache.js";
|
10
10
|
import { SubscriptionScope } from "./SubscriptionScope.js";
|
11
11
|
|
12
|
-
export function
|
13
|
-
const
|
12
|
+
export function myRoleForRawValue(raw: RawCoValue): Role | undefined {
|
13
|
+
const rawOwner = raw.group;
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
?
|
18
|
-
|
19
|
-
).fromRaw(owner)
|
20
|
-
: RegisteredSchemas["Group"].fromRaw(owner as any),
|
15
|
+
const owner = coValuesCache.get(rawOwner, () =>
|
16
|
+
rawOwner instanceof RawAccount
|
17
|
+
? RegisteredSchemas["Account"].fromRaw(rawOwner)
|
18
|
+
: RegisteredSchemas["Group"].fromRaw(rawOwner),
|
21
19
|
);
|
20
|
+
|
21
|
+
return accountOrGroupToGroup(owner).myRole();
|
22
22
|
}
|
23
23
|
|
24
24
|
export function createCoValue<D extends CoValue>(
|
@@ -28,7 +28,7 @@ export function createCoValue<D extends CoValue>(
|
|
28
28
|
) {
|
29
29
|
const freshValueInstance = instantiateRefEncodedFromRaw(ref, raw);
|
30
30
|
|
31
|
-
Object.defineProperty(freshValueInstance, "_subscriptionScope", {
|
31
|
+
Object.defineProperty(freshValueInstance.$jazz, "_subscriptionScope", {
|
32
32
|
value: subscriptionScope,
|
33
33
|
writable: false,
|
34
34
|
enumerable: false,
|
package/src/tools/testing.ts
CHANGED
@@ -141,7 +141,7 @@ export async function createJazzTestAccount<
|
|
141
141
|
});
|
142
142
|
|
143
143
|
const account = AccountClass.fromNode(node);
|
144
|
-
SecretSeedMap.set(account.id, secretSeed);
|
144
|
+
SecretSeedMap.set(account.$jazz.id, secretSeed);
|
145
145
|
|
146
146
|
if (options?.isCurrentActiveAccount) {
|
147
147
|
activeAccountContext.set(account);
|
@@ -222,12 +222,12 @@ export class TestJazzContextManager<
|
|
222
222
|
|
223
223
|
const provider = props?.isAuthenticated ? "testProvider" : "anonymous";
|
224
224
|
const storage = context.getAuthSecretStorage();
|
225
|
-
const node = account.
|
225
|
+
const node = account.$jazz.localNode;
|
226
226
|
|
227
227
|
const credentials = {
|
228
|
-
accountID: account.id,
|
228
|
+
accountID: account.$jazz.id,
|
229
229
|
accountSecret: node.getCurrentAgent().agentSecret,
|
230
|
-
secretSeed: SecretSeedMap.get(account.id),
|
230
|
+
secretSeed: SecretSeedMap.get(account.$jazz.id),
|
231
231
|
provider,
|
232
232
|
} satisfies AuthCredentials;
|
233
233
|
|
@@ -319,16 +319,20 @@ export async function linkAccounts(
|
|
319
319
|
aRole: "server" | "client" = "server",
|
320
320
|
bRole: "server" | "client" = "server",
|
321
321
|
) {
|
322
|
-
const [aPeer, bPeer] = cojsonInternals.connectedPeers(
|
323
|
-
|
324
|
-
|
325
|
-
|
322
|
+
const [aPeer, bPeer] = cojsonInternals.connectedPeers(
|
323
|
+
b.$jazz.id,
|
324
|
+
a.$jazz.id,
|
325
|
+
{
|
326
|
+
peer1role: aRole,
|
327
|
+
peer2role: bRole,
|
328
|
+
},
|
329
|
+
);
|
326
330
|
|
327
|
-
a.
|
328
|
-
b.
|
331
|
+
a.$jazz.localNode.syncManager.addPeer(aPeer);
|
332
|
+
b.$jazz.localNode.syncManager.addPeer(bPeer);
|
329
333
|
|
330
|
-
await a.waitForAllCoValuesSync();
|
331
|
-
await b.waitForAllCoValuesSync();
|
334
|
+
await a.$jazz.waitForAllCoValuesSync();
|
335
|
+
await b.$jazz.waitForAllCoValuesSync();
|
332
336
|
}
|
333
337
|
|
334
338
|
export async function setupJazzTestSync({
|
@@ -347,7 +351,7 @@ export async function setupJazzTestSync({
|
|
347
351
|
crypto: await TestJSCrypto.create(),
|
348
352
|
});
|
349
353
|
|
350
|
-
syncServer.current = account.
|
354
|
+
syncServer.current = account.$jazz.localNode;
|
351
355
|
syncServer.asyncPeers = asyncPeers;
|
352
356
|
|
353
357
|
return account;
|