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.
Files changed (228) hide show
  1. package/.svelte-kit/__package__/jazz.class.svelte.js +1 -1
  2. package/.svelte-kit/__package__/media/image.svelte +3 -9
  3. package/.svelte-kit/__package__/media/image.svelte.d.ts +1 -6
  4. package/.svelte-kit/__package__/media/image.svelte.d.ts.map +1 -1
  5. package/.svelte-kit/__package__/media/image.types.d.ts +7 -0
  6. package/.svelte-kit/__package__/media/image.types.d.ts.map +1 -0
  7. package/.svelte-kit/__package__/media/image.types.js +1 -0
  8. package/.svelte-kit/__package__/tests/media/image.svelte.test.js +31 -31
  9. package/.turbo/turbo-build.log +50 -50
  10. package/CHANGELOG.md +31 -0
  11. package/dist/browser/index.js +2 -2
  12. package/dist/browser/index.js.map +1 -1
  13. package/dist/{chunk-LZOF6WP5.js → chunk-HJ3GTGY7.js} +1320 -1018
  14. package/dist/chunk-HJ3GTGY7.js.map +1 -0
  15. package/dist/index.js +18 -18
  16. package/dist/index.js.map +1 -1
  17. package/dist/inspector/{custom-element-ZSNTCECD.js → custom-element-WCY6D3QJ.js} +3 -3
  18. package/dist/inspector/{custom-element-ZSNTCECD.js.map → custom-element-WCY6D3QJ.js.map} +1 -1
  19. package/dist/inspector/index.js +1 -1
  20. package/dist/inspector/index.js.map +1 -1
  21. package/dist/inspector/register-custom-element.js +1 -1
  22. package/dist/media/{chunk-E5J3WLQW.js → chunk-KR2V6X2N.js} +14 -9
  23. package/dist/media/chunk-KR2V6X2N.js.map +1 -0
  24. package/dist/media/create-image.d.ts +6 -6
  25. package/dist/media/index.browser.d.ts +6 -6
  26. package/dist/media/index.browser.js +1 -1
  27. package/dist/media/index.d.ts +1 -1
  28. package/dist/media/index.js +1 -1
  29. package/dist/media/index.native.d.ts +6 -6
  30. package/dist/media/index.native.js +1 -1
  31. package/dist/media/utils.d.ts.map +1 -1
  32. package/dist/prosemirror/index.js +2 -2
  33. package/dist/prosemirror/index.js.map +1 -1
  34. package/dist/react/index.js +7 -5
  35. package/dist/react/index.js.map +1 -1
  36. package/dist/react-core/hooks.d.ts.map +1 -1
  37. package/dist/react-core/index.js +4658 -23
  38. package/dist/react-core/index.js.map +1 -1
  39. package/dist/react-native-core/index.js +1 -1
  40. package/dist/react-native-core/index.js.map +1 -1
  41. package/dist/svelte/jazz.class.svelte.js +1 -1
  42. package/dist/svelte/media/image.svelte +3 -9
  43. package/dist/svelte/media/image.svelte.d.ts +1 -6
  44. package/dist/svelte/media/image.svelte.d.ts.map +1 -1
  45. package/dist/svelte/media/image.types.d.ts +7 -0
  46. package/dist/svelte/media/image.types.d.ts.map +1 -0
  47. package/dist/svelte/media/image.types.js +1 -0
  48. package/dist/svelte/tests/media/image.svelte.test.js +31 -31
  49. package/dist/testing.js +18 -14
  50. package/dist/testing.js.map +1 -1
  51. package/dist/tools/coValues/CoFieldInit.d.ts +13 -0
  52. package/dist/tools/coValues/CoFieldInit.d.ts.map +1 -0
  53. package/dist/tools/coValues/CoValueBase.d.ts +18 -15
  54. package/dist/tools/coValues/CoValueBase.d.ts.map +1 -1
  55. package/dist/tools/coValues/account.d.ts +100 -46
  56. package/dist/tools/coValues/account.d.ts.map +1 -1
  57. package/dist/tools/coValues/coFeed.d.ts +78 -62
  58. package/dist/tools/coValues/coFeed.d.ts.map +1 -1
  59. package/dist/tools/coValues/coList.d.ts +212 -99
  60. package/dist/tools/coValues/coList.d.ts.map +1 -1
  61. package/dist/tools/coValues/coMap.d.ts +200 -192
  62. package/dist/tools/coValues/coMap.d.ts.map +1 -1
  63. package/dist/tools/coValues/coPlainText.d.ts +30 -22
  64. package/dist/tools/coValues/coPlainText.d.ts.map +1 -1
  65. package/dist/tools/coValues/deepLoading.d.ts +13 -13
  66. package/dist/tools/coValues/deepLoading.d.ts.map +1 -1
  67. package/dist/tools/coValues/extensions/imageDef.d.ts +1 -1
  68. package/dist/tools/coValues/group.d.ts +32 -32
  69. package/dist/tools/coValues/group.d.ts.map +1 -1
  70. package/dist/tools/coValues/inbox.d.ts.map +1 -1
  71. package/dist/tools/coValues/interfaces.d.ts +18 -17
  72. package/dist/tools/coValues/interfaces.d.ts.map +1 -1
  73. package/dist/tools/coValues/profile.d.ts +6 -5
  74. package/dist/tools/coValues/profile.d.ts.map +1 -1
  75. package/dist/tools/coValues/schemaUnion.d.ts +3 -3
  76. package/dist/tools/coValues/schemaUnion.d.ts.map +1 -1
  77. package/dist/tools/exports.d.ts +1 -1
  78. package/dist/tools/exports.d.ts.map +1 -1
  79. package/dist/tools/implementation/anonymousJazzAgent.d.ts +2 -1
  80. package/dist/tools/implementation/anonymousJazzAgent.d.ts.map +1 -1
  81. package/dist/tools/implementation/schema.d.ts +5 -5
  82. package/dist/tools/implementation/schema.d.ts.map +1 -1
  83. package/dist/tools/implementation/symbols.d.ts +2 -0
  84. package/dist/tools/implementation/symbols.d.ts.map +1 -1
  85. package/dist/tools/implementation/zodSchema/schemaTypes/AccountSchema.d.ts +2 -2
  86. package/dist/tools/implementation/zodSchema/schemaTypes/AccountSchema.d.ts.map +1 -1
  87. package/dist/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.d.ts +6 -2
  88. package/dist/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.d.ts.map +1 -1
  89. package/dist/tools/implementation/zodSchema/schemaTypes/CoListSchema.d.ts +8 -3
  90. package/dist/tools/implementation/zodSchema/schemaTypes/CoListSchema.d.ts.map +1 -1
  91. package/dist/tools/implementation/zodSchema/schemaTypes/CoMapSchema.d.ts +12 -7
  92. package/dist/tools/implementation/zodSchema/schemaTypes/CoMapSchema.d.ts.map +1 -1
  93. package/dist/tools/implementation/zodSchema/schemaTypes/CoRecordSchema.d.ts +13 -7
  94. package/dist/tools/implementation/zodSchema/schemaTypes/CoRecordSchema.d.ts.map +1 -1
  95. package/dist/tools/implementation/zodSchema/schemaTypes/FileStreamSchema.d.ts +11 -2
  96. package/dist/tools/implementation/zodSchema/schemaTypes/FileStreamSchema.d.ts.map +1 -1
  97. package/dist/tools/implementation/zodSchema/schemaTypes/PlainTextSchema.d.ts +4 -0
  98. package/dist/tools/implementation/zodSchema/schemaTypes/PlainTextSchema.d.ts.map +1 -1
  99. package/dist/tools/implementation/zodSchema/schemaTypes/RichTextSchema.d.ts +4 -0
  100. package/dist/tools/implementation/zodSchema/schemaTypes/RichTextSchema.d.ts.map +1 -1
  101. package/dist/tools/implementation/zodSchema/typeConverters/{CoFieldInit.d.ts → CoFieldSchemaInit.d.ts} +7 -7
  102. package/dist/tools/implementation/zodSchema/typeConverters/CoFieldSchemaInit.d.ts.map +1 -0
  103. package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchema.d.ts +4 -4
  104. package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchema.d.ts.map +1 -1
  105. package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.d.ts +4 -4
  106. package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.d.ts.map +1 -1
  107. package/dist/tools/implementation/zodSchema/zodCo.d.ts +2 -2
  108. package/dist/tools/implementation/zodSchema/zodCo.d.ts.map +1 -1
  109. package/dist/tools/internal.d.ts +2 -1
  110. package/dist/tools/internal.d.ts.map +1 -1
  111. package/dist/tools/lib/migration.d.ts +1 -1
  112. package/dist/tools/lib/migration.d.ts.map +1 -1
  113. package/dist/tools/subscribe/SubscriptionScope.d.ts.map +1 -1
  114. package/dist/tools/subscribe/index.d.ts +1 -1
  115. package/dist/tools/subscribe/index.d.ts.map +1 -1
  116. package/dist/tools/subscribe/utils.d.ts +2 -2
  117. package/dist/tools/subscribe/utils.d.ts.map +1 -1
  118. package/dist/tools/testing.d.ts.map +1 -1
  119. package/dist/tools/tests/utils.d.ts +2 -6
  120. package/dist/tools/tests/utils.d.ts.map +1 -1
  121. package/dist/worker/index.js +3 -3
  122. package/dist/worker/index.js.map +1 -1
  123. package/package.json +4 -4
  124. package/src/browser/auth/PasskeyAuth.ts +2 -2
  125. package/src/browser/createBrowserContext.ts +2 -2
  126. package/src/browser/tests/PasskeyAuth.test.ts +2 -2
  127. package/src/inspector/custom-element.tsx +2 -2
  128. package/src/inspector/viewer/new-app.tsx +1 -1
  129. package/src/media/create-image.test.ts +7 -7
  130. package/src/media/create-image.ts +5 -3
  131. package/src/media/index.ts +1 -1
  132. package/src/media/utils.test.ts +72 -66
  133. package/src/media/utils.ts +9 -6
  134. package/src/prosemirror/lib/plugin.ts +1 -1
  135. package/src/prosemirror/lib/sync.ts +1 -1
  136. package/src/prosemirror/tests/plugin.test.ts +4 -4
  137. package/src/react/media/image.tsx +2 -2
  138. package/src/react/tests/media/image.test.tsx +52 -32
  139. package/src/react-core/hooks.ts +11 -5
  140. package/src/react-core/tests/useAccount.test.ts +16 -22
  141. package/src/react-core/tests/useCoState.test.ts +19 -19
  142. package/src/react-core/tests/useInboxSender.test.ts +5 -2
  143. package/src/react-core/tests/usePassPhraseAuth.test.ts +6 -6
  144. package/src/react-native-core/media/image.tsx +1 -1
  145. package/src/svelte/jazz.class.svelte.ts +1 -1
  146. package/src/svelte/media/image.svelte +3 -9
  147. package/src/svelte/media/image.types.ts +7 -0
  148. package/src/svelte/tests/media/image.svelte.test.ts +34 -32
  149. package/src/tools/auth/DemoAuth.ts +2 -2
  150. package/src/tools/auth/PassphraseAuth.ts +2 -2
  151. package/src/tools/auth/clerk/index.ts +2 -2
  152. package/src/tools/auth/clerk/tests/JazzClerkAuth.test.ts +1 -1
  153. package/src/tools/coValues/CoFieldInit.ts +20 -0
  154. package/src/tools/coValues/CoValueBase.ts +40 -60
  155. package/src/tools/coValues/account.ts +306 -232
  156. package/src/tools/coValues/coFeed.ts +185 -153
  157. package/src/tools/coValues/coList.ts +507 -334
  158. package/src/tools/coValues/coMap.ts +420 -286
  159. package/src/tools/coValues/coPlainText.ts +94 -110
  160. package/src/tools/coValues/deepLoading.ts +13 -13
  161. package/src/tools/coValues/group.ts +100 -114
  162. package/src/tools/coValues/inbox.ts +16 -14
  163. package/src/tools/coValues/interfaces.ts +49 -31
  164. package/src/tools/coValues/profile.ts +8 -6
  165. package/src/tools/coValues/request.ts +9 -9
  166. package/src/tools/coValues/schemaUnion.ts +11 -5
  167. package/src/tools/exports.ts +1 -1
  168. package/src/tools/implementation/ContextManager.ts +4 -4
  169. package/src/tools/implementation/anonymousJazzAgent.ts +2 -1
  170. package/src/tools/implementation/createContext.ts +1 -1
  171. package/src/tools/implementation/devtoolsFormatters.ts +9 -9
  172. package/src/tools/implementation/invites.ts +2 -2
  173. package/src/tools/implementation/schema.ts +7 -7
  174. package/src/tools/implementation/symbols.ts +3 -0
  175. package/src/tools/implementation/zodSchema/schemaTypes/AccountSchema.ts +2 -2
  176. package/src/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.ts +11 -2
  177. package/src/tools/implementation/zodSchema/schemaTypes/CoListSchema.ts +18 -7
  178. package/src/tools/implementation/zodSchema/schemaTypes/CoMapSchema.ts +17 -7
  179. package/src/tools/implementation/zodSchema/schemaTypes/CoRecordSchema.ts +20 -11
  180. package/src/tools/implementation/zodSchema/schemaTypes/FileStreamSchema.ts +19 -2
  181. package/src/tools/implementation/zodSchema/schemaTypes/PlainTextSchema.ts +6 -0
  182. package/src/tools/implementation/zodSchema/schemaTypes/RichTextSchema.ts +6 -0
  183. package/src/tools/implementation/zodSchema/typeConverters/{CoFieldInit.ts → CoFieldSchemaInit.ts} +11 -11
  184. package/src/tools/implementation/zodSchema/typeConverters/InstanceOfSchema.ts +4 -4
  185. package/src/tools/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.ts +4 -4
  186. package/src/tools/implementation/zodSchema/zodCo.ts +2 -2
  187. package/src/tools/internal.ts +2 -1
  188. package/src/tools/lib/migration.ts +5 -5
  189. package/src/tools/subscribe/SubscriptionScope.ts +32 -24
  190. package/src/tools/subscribe/index.ts +4 -4
  191. package/src/tools/subscribe/utils.ts +11 -11
  192. package/src/tools/testing.ts +17 -13
  193. package/src/tools/tests/ContextManager.test.ts +68 -57
  194. package/src/tools/tests/PassphraseAuth.test.ts +2 -2
  195. package/src/tools/tests/account.test.ts +139 -69
  196. package/src/tools/tests/coDiscriminatedUnion.test-d.ts +12 -6
  197. package/src/tools/tests/coDiscriminatedUnion.test.ts +26 -17
  198. package/src/tools/tests/coFeed.test-d.ts +18 -17
  199. package/src/tools/tests/coFeed.test.ts +108 -97
  200. package/src/tools/tests/coList.test-d.ts +18 -23
  201. package/src/tools/tests/coList.test.ts +350 -165
  202. package/src/tools/tests/coMap.record.test-d.ts +9 -13
  203. package/src/tools/tests/coMap.record.test.ts +37 -23
  204. package/src/tools/tests/coMap.test-d.ts +43 -21
  205. package/src/tools/tests/coMap.test.ts +360 -182
  206. package/src/tools/tests/coOptional.test.ts +28 -13
  207. package/src/tools/tests/coPlainText.test.ts +15 -15
  208. package/src/tools/tests/createContext.test.ts +14 -14
  209. package/src/tools/tests/deepLoading.test.ts +95 -94
  210. package/src/tools/tests/exportImport.test.ts +61 -41
  211. package/src/tools/tests/groupsAndAccounts.test.ts +333 -116
  212. package/src/tools/tests/inbox.test.ts +22 -17
  213. package/src/tools/tests/interfaces.test.ts +12 -11
  214. package/src/tools/tests/invites.test.ts +6 -4
  215. package/src/tools/tests/load.test.ts +20 -18
  216. package/src/tools/tests/patterns/notifications.test.ts +6 -6
  217. package/src/tools/tests/patterns/quest.test.ts +3 -3
  218. package/src/tools/tests/patterns/requestToJoin.test.ts +22 -22
  219. package/src/tools/tests/request.test.ts +38 -39
  220. package/src/tools/tests/schemaUnion.test.ts +64 -10
  221. package/src/tools/tests/subscribe.test.ts +64 -64
  222. package/src/tools/tests/testing.test.ts +5 -9
  223. package/src/tools/tests/utils.ts +3 -3
  224. package/src/tools/tests/zod.test.ts +3 -3
  225. package/src/worker/index.ts +3 -3
  226. package/dist/chunk-LZOF6WP5.js.map +0 -1
  227. package/dist/media/chunk-E5J3WLQW.js.map +0 -1
  228. package/dist/tools/implementation/zodSchema/typeConverters/CoFieldInit.d.ts.map +0 -1
@@ -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 CoFieldInit<S extends CoValueClass | AnyZodOrCoValueSchema> =
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
- ? CoListInit<T>
34
+ ? CoListSchemaInit<T>
35
35
  : S extends CoreCoFeedSchema<infer T>
36
- ? CoFeedInit<T>
36
+ ? CoFeedSchemaInit<T>
37
37
  : S extends CorePlainTextSchema | CoreRichTextSchema
38
38
  ? string
39
39
  : S extends CoreCoOptionalSchema<infer T>
40
- ? CoFieldInit<T> | undefined
40
+ ? CoFieldSchemaInit<T> | undefined
41
41
  : S extends CoDiscriminatedUnionSchema<infer Members>
42
- ? CoFieldInit<Members[number]>
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]: CoFieldInit<Shape[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]?: CoFieldInit<Shape[Key]>;
68
+ : never]?: CoFieldSchemaInit<Shape[Key]>;
69
69
  }
70
70
  >;
71
71
 
72
- export type CoListInit<T extends AnyZodOrCoValueSchema> = Simplify<
73
- ReadonlyArray<CoFieldInit<T>>
72
+ export type CoListSchemaInit<T extends AnyZodOrCoValueSchema> = Simplify<
73
+ ReadonlyArray<CoFieldSchemaInit<T>>
74
74
  >;
75
75
 
76
- export type CoFeedInit<T extends AnyZodOrCoValueSchema> = Simplify<
77
- ReadonlyArray<CoFieldInit<T>>
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
- -readonly [key in keyof Shape]: InstanceOrPrimitiveOfSchema<
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
- -readonly [key in z.output<K> &
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
- -readonly [key in keyof Shape]: InstanceOrPrimitiveOfSchema<
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
@@ -29,7 +29,7 @@ export type InstanceOfSchemaCoValuesNullable<
29
29
  ? S extends CoreAccountSchema<infer Shape>
30
30
  ?
31
31
  | ({
32
- -readonly [key in keyof Shape]: InstanceOrPrimitiveOfSchemaCoValuesNullable<
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
- -readonly [key in z.output<K> &
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
- -readonly [key in keyof Shape]: InstanceOrPrimitiveOfSchemaCoValuesNullable<
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
  }
@@ -103,10 +103,10 @@ export const coMapDefiner = <Shape extends z.core.$ZodLooseShape>(
103
103
  * // Migration logic for existing accounts
104
104
  * if (account.profile === undefined) {
105
105
  * const group = Group.create();
106
- * account.profile = co.profile().create(
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
  * });
@@ -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/CoFieldInit.js";
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 { CoValue } from "../internal.js";
1
+ import { TypeSym, type CoValue } from "../internal.js";
2
2
 
3
3
  export function applyCoValueMigrations(instance: CoValue) {
4
- const node = instance._raw.core.node;
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._type !== "Account" &&
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, getOwnerFromRawValue } from "./utils.js";
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
- getOwnerFromRawValue(update).myRole() !== undefined;
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 _raw value makes us cover the cases where the group
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._raw !== update;
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._raw, this),
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._raw.core.verified.isStreaming();
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 this.value.value._raw.core.verified.header.meta?.type === "binary";
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._type === "CoMap" || value._type === "Account") {
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._type === "CoList") {
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._type;
433
+ const coValueType = value[TypeSym];
431
434
 
432
435
  if (Object.keys(depth).length > 0) {
433
- if (coValueType === "CoMap" || coValueType === "Account") {
436
+ if (
437
+ coValueType === "CoMap" ||
438
+ coValueType === "Account" ||
439
+ coValueType === "Group"
440
+ ) {
434
441
  const map = value as CoMap;
435
- const keys = "$each" in depth ? map._raw.keys() : Object.keys(depth);
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._type === "CoList") {
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._raw.processNewTransactions();
451
- const entries = list._raw.entries();
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._type === "CoStream") {
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._raw.sessions()) {
469
- const values = stream._raw.items[session] ?? [];
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._raw.get(key) as string | undefined;
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._raw.entries();
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._raw.core.node;
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
- coValueClassFromCoValueClassOrSchema,
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 getOwnerFromRawValue(raw: RawCoValue) {
13
- const owner = raw.group;
12
+ export function myRoleForRawValue(raw: RawCoValue): Role | undefined {
13
+ const rawOwner = raw.group;
14
14
 
15
- return coValuesCache.get(owner, () =>
16
- owner instanceof RawAccount
17
- ? coValueClassFromCoValueClassOrSchema(
18
- RegisteredSchemas["Account"],
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,
@@ -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._raw.core.node;
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(b.id, a.id, {
323
- peer1role: aRole,
324
- peer2role: bRole,
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._raw.core.node.syncManager.addPeer(aPeer);
328
- b._raw.core.node.syncManager.addPeer(bPeer);
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._raw.core.node;
354
+ syncServer.current = account.$jazz.localNode;
351
355
  syncServer.asyncPeers = asyncPeers;
352
356
 
353
357
  return account;