jazz-tools 0.16.2 → 0.16.4

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 (76) hide show
  1. package/.turbo/turbo-build.log +38 -38
  2. package/CHANGELOG.md +22 -0
  3. package/dist/{chunk-CL3ROOZM.js → chunk-74LZG2M3.js} +112 -36
  4. package/dist/chunk-74LZG2M3.js.map +1 -0
  5. package/dist/index.js +1 -1
  6. package/dist/react-core/hooks.d.ts +150 -2
  7. package/dist/react-core/hooks.d.ts.map +1 -1
  8. package/dist/react-core/index.js.map +1 -1
  9. package/dist/testing.js +1 -1
  10. package/dist/tools/coValues/coFeed.d.ts.map +1 -1
  11. package/dist/tools/coValues/coList.d.ts.map +1 -1
  12. package/dist/tools/coValues/coMap.d.ts.map +1 -1
  13. package/dist/tools/coValues/interfaces.d.ts.map +1 -1
  14. package/dist/tools/coValues/schemaUnion.d.ts +7 -2
  15. package/dist/tools/coValues/schemaUnion.d.ts.map +1 -1
  16. package/dist/tools/exports.d.ts +1 -1
  17. package/dist/tools/exports.d.ts.map +1 -1
  18. package/dist/tools/implementation/schema.d.ts +12 -2
  19. package/dist/tools/implementation/schema.d.ts.map +1 -1
  20. package/dist/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.d.ts +2 -4
  21. package/dist/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.d.ts.map +1 -1
  22. package/dist/tools/implementation/zodSchema/schemaTypes/CoListSchema.d.ts +2 -4
  23. package/dist/tools/implementation/zodSchema/schemaTypes/CoListSchema.d.ts.map +1 -1
  24. package/dist/tools/implementation/zodSchema/schemaTypes/CoMapSchema.d.ts +23 -7
  25. package/dist/tools/implementation/zodSchema/schemaTypes/CoMapSchema.d.ts.map +1 -1
  26. package/dist/tools/implementation/zodSchema/typeConverters/CoFieldInit.d.ts +20 -6
  27. package/dist/tools/implementation/zodSchema/typeConverters/CoFieldInit.d.ts.map +1 -1
  28. package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchema.d.ts +4 -4
  29. package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchema.d.ts.map +1 -1
  30. package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.d.ts +3 -3
  31. package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.d.ts.map +1 -1
  32. package/dist/tools/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchema.d.ts +3 -25
  33. package/dist/tools/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchema.d.ts.map +1 -1
  34. package/dist/tools/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchemaCoValuesNullable.d.ts +3 -25
  35. package/dist/tools/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchemaCoValuesNullable.d.ts.map +1 -1
  36. package/dist/tools/implementation/zodSchema/typeConverters/TypeOfZodSchema.d.ts +24 -0
  37. package/dist/tools/implementation/zodSchema/typeConverters/TypeOfZodSchema.d.ts.map +1 -0
  38. package/dist/tools/implementation/zodSchema/unionUtils.d.ts +2 -3
  39. package/dist/tools/implementation/zodSchema/unionUtils.d.ts.map +1 -1
  40. package/dist/tools/implementation/zodSchema/zodSchema.d.ts +4 -5
  41. package/dist/tools/implementation/zodSchema/zodSchema.d.ts.map +1 -1
  42. package/dist/tools/internal.d.ts +1 -0
  43. package/dist/tools/internal.d.ts.map +1 -1
  44. package/dist/tools/subscribe/SubscriptionScope.d.ts.map +1 -1
  45. package/package.json +4 -4
  46. package/src/react-core/hooks.ts +143 -0
  47. package/src/tools/coValues/coFeed.ts +12 -4
  48. package/src/tools/coValues/coList.ts +41 -19
  49. package/src/tools/coValues/coMap.ts +12 -2
  50. package/src/tools/coValues/inbox.ts +1 -1
  51. package/src/tools/coValues/interfaces.ts +2 -3
  52. package/src/tools/coValues/schemaUnion.ts +28 -3
  53. package/src/tools/exports.ts +0 -1
  54. package/src/tools/implementation/schema.ts +28 -2
  55. package/src/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.ts +2 -7
  56. package/src/tools/implementation/zodSchema/schemaTypes/CoListSchema.ts +2 -7
  57. package/src/tools/implementation/zodSchema/schemaTypes/CoMapSchema.ts +61 -12
  58. package/src/tools/implementation/zodSchema/typeConverters/CoFieldInit.ts +74 -9
  59. package/src/tools/implementation/zodSchema/typeConverters/InstanceOfSchema.ts +9 -4
  60. package/src/tools/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.ts +3 -3
  61. package/src/tools/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchema.ts +3 -114
  62. package/src/tools/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchemaCoValuesNullable.ts +5 -129
  63. package/src/tools/implementation/zodSchema/typeConverters/TypeOfZodSchema.ts +79 -0
  64. package/src/tools/implementation/zodSchema/unionUtils.ts +6 -9
  65. package/src/tools/implementation/zodSchema/zodSchema.ts +4 -14
  66. package/src/tools/internal.ts +1 -0
  67. package/src/tools/subscribe/SubscriptionScope.ts +4 -2
  68. package/src/tools/subscribe/utils.ts +2 -2
  69. package/src/tools/tests/coFeed.test.ts +40 -0
  70. package/src/tools/tests/coList.test.ts +42 -0
  71. package/src/tools/tests/coMap.test-d.ts +184 -1
  72. package/src/tools/tests/coMap.test.ts +182 -58
  73. package/src/tools/tests/groupsAndAccounts.test.ts +54 -0
  74. package/src/tools/tests/load.test.ts +19 -0
  75. package/src/tools/tests/zod.test.ts +16 -0
  76. package/dist/chunk-CL3ROOZM.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
 
2
- > jazz-tools@0.16.2 build /home/runner/_work/jazz/jazz/packages/jazz-tools
2
+ > jazz-tools@0.16.4 build /home/runner/_work/jazz/jazz/packages/jazz-tools
3
3
  > tsup && pnpm types && pnpm build:svelte
4
4
 
5
5
  CLI Building entry: {"index":"src/index.ts","testing":"src/testing.ts"}
@@ -107,81 +107,81 @@
107
107
  ESM Build start
108
108
  CLI Cleaning output folder
109
109
  ESM Build start
110
- ESM dist/react/ssr.js 688.00 B
111
- ESM dist/react/ssr.js.map 1.12 KB
112
- ESM ⚡️ Build success in 16ms
113
- ESM dist/tiptap/index.js 564.00 B
114
- ESM dist/tiptap/index.js.map 1.21 KB
115
- ESM ⚡️ Build success in 14ms
116
110
  ESM dist/browser-media-images/index.js 2.55 KB
117
111
  ESM dist/browser-media-images/index.js.map 5.46 KB
118
- ESM ⚡️ Build success in 19ms
112
+ ESM ⚡️ Build success in 25ms
113
+ ESM dist/react/ssr.js 688.00 B
114
+ ESM dist/react/ssr.js.map 1.12 KB
115
+ ESM ⚡️ Build success in 27ms
119
116
  ESM dist/worker/index.js 2.31 KB
120
117
  ESM dist/worker/index.js.map 4.77 KB
121
- ESM ⚡️ Build success in 20ms
118
+ ESM ⚡️ Build success in 25ms
119
+ ESM dist/tiptap/index.js 564.00 B
120
+ ESM dist/tiptap/index.js.map 1.21 KB
121
+ ESM ⚡️ Build success in 26ms
122
+ ESM dist/react-native-media-images/index.js 6.19 KB
123
+ ESM dist/react-native-media-images/index.js.map 10.96 KB
124
+ ESM ⚡️ Build success in 30ms
122
125
  ESM dist/react-core/index.js 8.42 KB
123
126
  ESM dist/react-core/testing.js 1.17 KB
124
127
  ESM dist/react-core/chunk-7DYMJ74I.js 279.00 B
125
- ESM dist/react-core/index.js.map 16.44 KB
126
- ESM dist/react-core/chunk-7DYMJ74I.js.map 533.00 B
128
+ ESM dist/react-core/index.js.map 20.69 KB
127
129
  ESM dist/react-core/testing.js.map 1.82 KB
128
- ESM ⚡️ Build success in 23ms
129
- ESM dist/react-native-media-images/index.js 6.19 KB
130
- ESM dist/react-native-media-images/index.js.map 10.96 KB
131
- ESM ⚡️ Build success in 21ms
130
+ ESM dist/react-core/chunk-7DYMJ74I.js.map 533.00 B
131
+ ESM ⚡️ Build success in 32ms
132
+ ESM dist/expo/index.js 4.65 KB
133
+ ESM dist/expo/testing.js 112.00 B
134
+ ESM dist/expo/crypto.js 109.00 B
135
+ ESM dist/expo/index.js.map 10.17 KB
136
+ ESM dist/expo/testing.js.map 168.00 B
137
+ ESM dist/expo/crypto.js.map 166.00 B
138
+ ESM ⚡️ Build success in 37ms
132
139
  ESM dist/react-native/index.js 2.53 KB
133
140
  ESM dist/react-native/testing.js 120.00 B
134
141
  ESM dist/react-native/crypto.js 117.00 B
135
142
  ESM dist/react-native/index.js.map 5.68 KB
136
143
  ESM dist/react-native/testing.js.map 176.00 B
137
144
  ESM dist/react-native/crypto.js.map 174.00 B
138
- ESM ⚡️ Build success in 26ms
145
+ ESM ⚡️ Build success in 41ms
146
+ ESM dist/react/index.js 20.70 KB
147
+ ESM dist/react/testing.js 122.00 B
148
+ ESM dist/react/index.js.map 34.14 KB
149
+ ESM dist/react/testing.js.map 165.00 B
150
+ ESM ⚡️ Build success in 43ms
139
151
  ESM dist/browser/index.js 13.43 KB
140
152
  ESM dist/browser/index.js.map 28.65 KB
141
- ESM ⚡️ Build success in 32ms
142
- ESM dist/expo/index.js 4.65 KB
143
- ESM dist/expo/testing.js 112.00 B
144
- ESM dist/expo/crypto.js 109.00 B
145
- ESM dist/expo/index.js.map 10.17 KB
146
- ESM dist/expo/testing.js.map 168.00 B
147
- ESM dist/expo/crypto.js.map 166.00 B
148
- ESM ⚡️ Build success in 32ms
153
+ ESM ⚡️ Build success in 49ms
149
154
  ESM dist/react-native-core/index.js 16.95 KB
150
155
  ESM dist/react-native-core/testing.js 119.00 B
151
156
  ESM dist/react-native-core/crypto.js 2.10 KB
152
157
  ESM dist/react-native-core/index.js.map 33.57 KB
153
158
  ESM dist/react-native-core/testing.js.map 175.00 B
154
159
  ESM dist/react-native-core/crypto.js.map 4.25 KB
155
- ESM ⚡️ Build success in 37ms
156
- ESM dist/react/index.js 20.70 KB
157
- ESM dist/react/testing.js 122.00 B
158
- ESM dist/react/index.js.map 34.14 KB
159
- ESM dist/react/testing.js.map 165.00 B
160
- ESM ⚡️ Build success in 43ms
160
+ ESM ⚡️ Build success in 54ms
161
161
  ESM dist/prosemirror/index.js 76.90 KB
162
162
  ESM dist/prosemirror/index.js.map 305.53 KB
163
- ESM ⚡️ Build success in 45ms
163
+ ESM ⚡️ Build success in 61ms
164
164
  ESM dist/inspector/index.js 60.37 KB
165
165
  ESM dist/inspector/index.js.map 107.85 KB
166
- ESM ⚡️ Build success in 70ms
166
+ ESM ⚡️ Build success in 73ms
167
167
  ESM dist/testing.js 6.76 KB
168
168
  ESM dist/index.js 26.00 KB
169
- ESM dist/chunk-CL3ROOZM.js 148.99 KB
169
+ ESM dist/chunk-74LZG2M3.js 151.07 KB
170
170
  ESM dist/testing.js.map 13.06 KB
171
171
  ESM dist/index.js.map 52.65 KB
172
- ESM dist/chunk-CL3ROOZM.js.map 356.97 KB
173
- ESM ⚡️ Build success in 77ms
172
+ ESM dist/chunk-74LZG2M3.js.map 362.38 KB
173
+ ESM ⚡️ Build success in 91ms
174
174
  ESM dist/inspector/register-custom-element.js 218.00 B
175
175
  ESM dist/inspector/register-custom-element.js.map 314.00 B
176
176
  ESM dist/inspector/custom-element-TUXKXSZU.js 1.53 MB
177
177
  ESM dist/inspector/custom-element-TUXKXSZU.js.map 2.35 MB
178
- ESM ⚡️ Build success in 115ms
178
+ ESM ⚡️ Build success in 135ms
179
179
 
180
- > jazz-tools@0.16.2 types /home/runner/_work/jazz/jazz/packages/jazz-tools
180
+ > jazz-tools@0.16.4 types /home/runner/_work/jazz/jazz/packages/jazz-tools
181
181
  > tsc --outDir dist
182
182
 
183
183
 
184
- > jazz-tools@0.16.2 build:svelte /home/runner/_work/jazz/jazz/packages/jazz-tools
184
+ > jazz-tools@0.16.4 build:svelte /home/runner/_work/jazz/jazz/packages/jazz-tools
185
185
  > rm -rf dist/svelte && svelte-package -i src/svelte -o dist/svelte --tsconfig tsconfig.svelte.json
186
186
 
187
187
  src/svelte -> dist/svelte
package/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # jazz-tools
2
2
 
3
+ ## 0.16.4
4
+
5
+ ### Patch Changes
6
+
7
+ - 16764f6: Added `pick()` and `partial()` methods to CoMapSchema
8
+ - Updated dependencies [f9d538f]
9
+ - Updated dependencies [802b5a3]
10
+ - cojson@0.16.4
11
+ - cojson-storage-indexeddb@0.16.4
12
+ - cojson-transport-ws@0.16.4
13
+
14
+ ## 0.16.3
15
+
16
+ ### Patch Changes
17
+
18
+ - 43d3511: Streamlined CoValue creation:
19
+ - CoValues can be created with plain JSON objects. Nested CoValues will be automatically created when necessary.
20
+ - Optional fields can be ommited (i.e. it's no longer necessary to provide an explicit `undefined` value).
21
+ - cojson@0.16.3
22
+ - cojson-storage-indexeddb@0.16.3
23
+ - cojson-transport-ws@0.16.3
24
+
3
25
  ## 0.16.2
4
26
 
5
27
  ### Patch Changes
@@ -118,11 +118,6 @@ function isAnyCoValueSchema(schema) {
118
118
  return "collaborative" in schema && schema.collaborative === true;
119
119
  }
120
120
 
121
- // src/tools/coValues/interfaces.ts
122
- import {
123
- emptyKnownState
124
- } from "cojson";
125
-
126
121
  // src/tools/coValues/CoValueBase.ts
127
122
  import { ControlledAccount, RawAccount } from "cojson";
128
123
  var CoValueBase = class {
@@ -406,8 +401,17 @@ var _CoMap = class _CoMap extends CoValueBase {
406
401
  if (descriptor === "json") {
407
402
  rawInit[key] = initValue;
408
403
  } else if (isRefEncoded(descriptor)) {
409
- if (initValue) {
410
- rawInit[key] = initValue.id;
404
+ if (initValue != null) {
405
+ let refId = initValue.id;
406
+ if (!refId) {
407
+ const coValue = instantiateRefEncodedWithInit(
408
+ descriptor,
409
+ initValue,
410
+ owner
411
+ );
412
+ refId = coValue.id;
413
+ }
414
+ rawInit[key] = refId;
411
415
  }
412
416
  } else if ("encoded" in descriptor) {
413
417
  rawInit[key] = descriptor.encoded.encode(
@@ -846,7 +850,7 @@ var _CoList = class _CoList extends Array {
846
850
  const { owner } = parseCoValueCreateOptions(options);
847
851
  const instance = new this({ init: items, owner });
848
852
  const raw = owner._raw.createList(
849
- toRawItems(items, instance._schema[ItemsSym])
853
+ toRawItems(items, instance._schema[ItemsSym], owner)
850
854
  );
851
855
  Object.defineProperties(instance, {
852
856
  id: {
@@ -859,14 +863,18 @@ var _CoList = class _CoList extends Array {
859
863
  }
860
864
  push(...items) {
861
865
  this._raw.appendItems(
862
- toRawItems(items, this._schema[ItemsSym]),
866
+ toRawItems(items, this._schema[ItemsSym], this._owner),
863
867
  void 0,
864
868
  "private"
865
869
  );
866
870
  return this._raw.entries().length;
867
871
  }
868
872
  unshift(...items) {
869
- for (const item of toRawItems(items, this._schema[ItemsSym])) {
873
+ for (const item of toRawItems(
874
+ items,
875
+ this._schema[ItemsSym],
876
+ this._owner
877
+ )) {
870
878
  this._raw.prepend(item);
871
879
  }
872
880
  return this._raw.entries().length;
@@ -893,7 +901,11 @@ var _CoList = class _CoList extends Array {
893
901
  for (let idxToDelete = start + deleteCount - 1; idxToDelete >= start; idxToDelete--) {
894
902
  this._raw.delete(idxToDelete);
895
903
  }
896
- const rawItems = toRawItems(items, this._schema[ItemsSym]);
904
+ const rawItems = toRawItems(
905
+ items,
906
+ this._schema[ItemsSym],
907
+ this._owner
908
+ );
897
909
  if (rawItems.length === 0) {
898
910
  return deleted;
899
911
  }
@@ -1026,13 +1038,29 @@ var _CoList = class _CoList extends Array {
1026
1038
  };
1027
1039
  _CoList.prototype._type = "CoList";
1028
1040
  var CoList = _CoList;
1029
- function toRawItems(items, itemDescriptor) {
1030
- const rawItems = itemDescriptor === "json" ? items : "encoded" in itemDescriptor ? items?.map((e) => itemDescriptor.encoded.encode(e)) : isRefEncoded(itemDescriptor) ? items?.map((v) => {
1031
- if (!v) return null;
1032
- return v.id;
1033
- }) : (() => {
1041
+ function toRawItems(items, itemDescriptor, owner) {
1042
+ let rawItems = [];
1043
+ if (itemDescriptor === "json") {
1044
+ rawItems = items;
1045
+ } else if ("encoded" in itemDescriptor) {
1046
+ rawItems = items?.map((e) => itemDescriptor.encoded.encode(e));
1047
+ } else if (isRefEncoded(itemDescriptor)) {
1048
+ rawItems = items?.map((value) => {
1049
+ if (value == null) return null;
1050
+ let refId = value.id;
1051
+ if (!refId) {
1052
+ const coValue = instantiateRefEncodedWithInit(
1053
+ itemDescriptor,
1054
+ value,
1055
+ owner
1056
+ );
1057
+ refId = coValue.id;
1058
+ }
1059
+ return refId;
1060
+ });
1061
+ } else {
1034
1062
  throw new Error("Invalid element descriptor");
1035
- })();
1063
+ }
1036
1064
  return rawItems;
1037
1065
  }
1038
1066
  var CoListProxyHandler = {
@@ -1265,7 +1293,16 @@ var _CoFeed = class _CoFeed extends CoValueBase {
1265
1293
  } else if ("encoded" in itemDescriptor) {
1266
1294
  this._raw.push(itemDescriptor.encoded.encode(item));
1267
1295
  } else if (isRefEncoded(itemDescriptor)) {
1268
- this._raw.push(item.id);
1296
+ let refId = item.id;
1297
+ if (!refId) {
1298
+ const coValue = instantiateRefEncodedWithInit(
1299
+ itemDescriptor,
1300
+ item,
1301
+ this._owner
1302
+ );
1303
+ refId = coValue.id;
1304
+ }
1305
+ this._raw.push(refId);
1269
1306
  }
1270
1307
  }
1271
1308
  /**
@@ -2696,6 +2733,10 @@ var SchemaUnion = class _SchemaUnion extends CoValueBase {
2696
2733
  **/
2697
2734
  static Of(discriminator) {
2698
2735
  return class SchemaUnionClass extends _SchemaUnion {
2736
+ static create(init, owner) {
2737
+ const ResolvedClass = discriminator(new Map(Object.entries(init)));
2738
+ return ResolvedClass.create(init, owner);
2739
+ }
2699
2740
  static fromRaw(raw) {
2700
2741
  const ResolvedClass = discriminator(
2701
2742
  raw
@@ -2704,13 +2745,15 @@ var SchemaUnion = class _SchemaUnion extends CoValueBase {
2704
2745
  }
2705
2746
  };
2706
2747
  }
2748
+ static create(init, owner) {
2749
+ throw new Error("Not implemented");
2750
+ }
2707
2751
  /**
2708
2752
  * Create an instance from raw data. This is called internally and should not be used directly.
2709
2753
  * Use {@link SchemaUnion.Of} to create a union type instead.
2710
2754
  *
2711
2755
  * @internal
2712
2756
  */
2713
- // @ts-ignore
2714
2757
  static fromRaw(raw) {
2715
2758
  throw new Error("Not implemented");
2716
2759
  }
@@ -2940,11 +2983,21 @@ function ref(arg, options) {
2940
2983
  function isRefEncoded(schema) {
2941
2984
  return typeof schema === "object" && "ref" in schema && "optional" in schema && typeof schema.ref === "function";
2942
2985
  }
2943
- function instantiateRefEncoded(schema, raw) {
2986
+ function instantiateRefEncodedFromRaw(schema, raw) {
2944
2987
  return isCoValueClass(schema.ref) ? schema.ref.fromRaw(raw) : schema.ref(
2945
2988
  raw
2946
2989
  ).fromRaw(raw);
2947
2990
  }
2991
+ function instantiateRefEncodedWithInit(schema, init, parentOwner) {
2992
+ if (!isCoValueClass(schema.ref)) {
2993
+ throw Error(
2994
+ `Cannot automatically create CoValue from value: ${JSON.stringify(init)}. Use the CoValue schema's create() method instead.`
2995
+ );
2996
+ }
2997
+ const owner = Group.create();
2998
+ owner.addMember(parentOwner.castAs(Group));
2999
+ return schema.ref.create(init, owner);
3000
+ }
2948
3001
 
2949
3002
  // src/tools/lib/migration.ts
2950
3003
  function applyCoValueMigrations(instance) {
@@ -3063,7 +3116,7 @@ function getOwnerFromRawValue(raw) {
3063
3116
  );
3064
3117
  }
3065
3118
  function createCoValue(ref2, raw, subscriptionScope) {
3066
- const freshValueInstance = instantiateRefEncoded(ref2, raw);
3119
+ const freshValueInstance = instantiateRefEncodedFromRaw(ref2, raw);
3067
3120
  Object.defineProperty(freshValueInstance, "_subscriptionScope", {
3068
3121
  value: subscriptionScope,
3069
3122
  writable: false,
@@ -3138,7 +3191,9 @@ var SubscriptionScope = class _SubscriptionScope {
3138
3191
  return;
3139
3192
  }
3140
3193
  this.migrating = true;
3141
- applyCoValueMigrations(instantiateRefEncoded(this.schema, value));
3194
+ applyCoValueMigrations(
3195
+ instantiateRefEncodedFromRaw(this.schema, value)
3196
+ );
3142
3197
  this.migrated = true;
3143
3198
  this.handleUpdate(lastUpdate);
3144
3199
  return;
@@ -4003,6 +4058,33 @@ function enrichCoMapSchema(schema, coValueClass) {
4003
4058
  },
4004
4059
  optional: () => {
4005
4060
  return coOptionalDefiner(coValueSchema);
4061
+ },
4062
+ pick: (keys) => {
4063
+ const keysSet = new Set(Object.keys(keys));
4064
+ const pickedShape = {};
4065
+ for (const [key, value] of Object.entries(coValueSchema.shape)) {
4066
+ if (keysSet.has(key)) {
4067
+ pickedShape[key] = value;
4068
+ }
4069
+ }
4070
+ return coMapDefiner(pickedShape);
4071
+ },
4072
+ partial: () => {
4073
+ const partialShape = {};
4074
+ for (const [key, value] of Object.entries(coValueSchema.shape)) {
4075
+ if (isAnyCoValueSchema2(value)) {
4076
+ partialShape[key] = coOptionalDefiner(value);
4077
+ } else {
4078
+ partialShape[key] = z.optional(coValueSchema.shape[key]);
4079
+ }
4080
+ }
4081
+ const partialCoMapSchema = coMapDefiner(partialShape);
4082
+ if (coValueSchema.catchAll) {
4083
+ return partialCoMapSchema.catchall(
4084
+ coValueSchema.catchAll
4085
+ );
4086
+ }
4087
+ return partialCoMapSchema;
4006
4088
  }
4007
4089
  });
4008
4090
  return coValueSchema;
@@ -4182,7 +4264,6 @@ function enrichAccountSchema(schema, coValueClass) {
4182
4264
  }
4183
4265
 
4184
4266
  // src/tools/implementation/zodSchema/unionUtils.ts
4185
- import { RawCoList } from "cojson";
4186
4267
  function schemaUnionDiscriminatorFor(schema) {
4187
4268
  if (isUnionOfCoMapsDeeply(schema)) {
4188
4269
  const definition = schema.getDefinition();
@@ -4216,17 +4297,12 @@ function schemaUnionDiscriminatorFor(schema) {
4216
4297
  );
4217
4298
  }
4218
4299
  }
4219
- const determineSchema = (_raw) => {
4220
- if (_raw instanceof RawCoList) {
4221
- throw new Error(
4222
- "co.discriminatedUnion() of collaborative types is not supported for CoLists"
4223
- );
4224
- }
4300
+ const determineSchema = (discriminable) => {
4225
4301
  for (const option of availableOptions) {
4226
4302
  let match = true;
4227
4303
  for (const key of Object.keys(discriminatorMap)) {
4228
4304
  const discriminatorDef = option.getDefinition().shape[key];
4229
- const discriminatorValue = _raw.get(key);
4305
+ const discriminatorValue = discriminable.get(key);
4230
4306
  if (discriminatorValue && typeof discriminatorValue === "object") {
4231
4307
  throw new Error("Discriminator must be a primitive value");
4232
4308
  }
@@ -5075,9 +5151,9 @@ function isAccountInstance(instance) {
5075
5151
  return "_type" in instance && instance._type === "Account";
5076
5152
  }
5077
5153
  function parseCoValueCreateOptions(options) {
5078
- const Group9 = RegisteredSchemas["Group"];
5154
+ const Group10 = RegisteredSchemas["Group"];
5079
5155
  if (!options) {
5080
- return { owner: Group9.create(), uniqueness: void 0 };
5156
+ return { owner: Group10.create(), uniqueness: void 0 };
5081
5157
  }
5082
5158
  if ("_type" in options) {
5083
5159
  if (options._type === "Account" || options._type === "Group") {
@@ -5086,7 +5162,7 @@ function parseCoValueCreateOptions(options) {
5086
5162
  }
5087
5163
  const uniqueness = options.unique ? { uniqueness: options.unique } : void 0;
5088
5164
  return {
5089
- owner: options.owner ?? Group9.create(),
5165
+ owner: options.owner ?? Group10.create(),
5090
5166
  uniqueness
5091
5167
  };
5092
5168
  }
@@ -5157,8 +5233,8 @@ function loadContentPiecesFromCoValue(core2, valuesExported, contentPieces) {
5157
5233
  loadContentPiecesFromCoValue(depCoValue, valuesExported, contentPieces);
5158
5234
  }
5159
5235
  }
5160
- const pieces = core2.verified.newContentSince(emptyKnownState(core2.id));
5161
- for (const piece of pieces ?? []) {
5236
+ const pieces = core2.verified.newContentSince(void 0) ?? [];
5237
+ for (const piece of pieces) {
5162
5238
  contentPieces.push(piece);
5163
5239
  }
5164
5240
  }
@@ -5211,4 +5287,4 @@ export {
5211
5287
  JazzContextManager
5212
5288
  };
5213
5289
  /* istanbul ignore file -- @preserve */
5214
- //# sourceMappingURL=chunk-CL3ROOZM.js.map
5290
+ //# sourceMappingURL=chunk-74LZG2M3.js.map