jazz-tools 0.14.9 → 0.14.14

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 (48) hide show
  1. package/.turbo/turbo-build.log +6 -6
  2. package/CHANGELOG.md +14 -0
  3. package/dist/{chunk-ORL6R2EV.js → chunk-GRIN3FQP.js} +43 -3
  4. package/dist/chunk-GRIN3FQP.js.map +1 -0
  5. package/dist/coValues/extensions/imageDef.d.ts +2 -2
  6. package/dist/coValues/extensions/imageDef.d.ts.map +1 -1
  7. package/dist/exports.d.ts +1 -1
  8. package/dist/exports.d.ts.map +1 -1
  9. package/dist/implementation/ContextManager.d.ts +5 -2
  10. package/dist/implementation/ContextManager.d.ts.map +1 -1
  11. package/dist/implementation/createContext.d.ts +1 -1
  12. package/dist/implementation/createContext.d.ts.map +1 -1
  13. package/dist/implementation/zodSchema/runtimeConverters/zodFieldToCoFieldDef.d.ts +1 -1
  14. package/dist/implementation/zodSchema/runtimeConverters/zodFieldToCoFieldDef.d.ts.map +1 -1
  15. package/dist/implementation/zodSchema/schemaTypes/CoListSchema.d.ts +1 -0
  16. package/dist/implementation/zodSchema/schemaTypes/CoListSchema.d.ts.map +1 -1
  17. package/dist/implementation/zodSchema/schemaTypes/CoMapSchema.d.ts +1 -0
  18. package/dist/implementation/zodSchema/schemaTypes/CoMapSchema.d.ts.map +1 -1
  19. package/dist/implementation/zodSchema/schemaTypes/CoRecordSchema.d.ts +1 -0
  20. package/dist/implementation/zodSchema/schemaTypes/CoRecordSchema.d.ts.map +1 -1
  21. package/dist/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchema.d.ts +1 -1
  22. package/dist/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchema.d.ts.map +1 -1
  23. package/dist/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchemaCoValuesNullable.d.ts +1 -1
  24. package/dist/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchemaCoValuesNullable.d.ts.map +1 -1
  25. package/dist/implementation/zodSchema/zodCo.d.ts.map +1 -1
  26. package/dist/implementation/zodSchema/zodReExport.d.ts +1 -1
  27. package/dist/implementation/zodSchema/zodReExport.d.ts.map +1 -1
  28. package/dist/index.js +3 -1
  29. package/dist/index.js.map +1 -1
  30. package/dist/subscribe/SubscriptionScope.d.ts +1 -0
  31. package/dist/subscribe/SubscriptionScope.d.ts.map +1 -1
  32. package/dist/testing.js +1 -1
  33. package/package.json +1 -1
  34. package/src/coValues/extensions/imageDef.ts +2 -7
  35. package/src/exports.ts +1 -0
  36. package/src/implementation/ContextManager.ts +34 -2
  37. package/src/implementation/createContext.ts +2 -2
  38. package/src/implementation/zodSchema/runtimeConverters/zodFieldToCoFieldDef.ts +21 -1
  39. package/src/implementation/zodSchema/schemaTypes/CoListSchema.ts +1 -0
  40. package/src/implementation/zodSchema/schemaTypes/CoMapSchema.ts +1 -0
  41. package/src/implementation/zodSchema/schemaTypes/CoRecordSchema.ts +1 -0
  42. package/src/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchema.ts +9 -1
  43. package/src/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchemaCoValuesNullable.ts +9 -1
  44. package/src/implementation/zodSchema/zodCo.ts +3 -0
  45. package/src/implementation/zodSchema/zodReExport.ts +2 -0
  46. package/src/subscribe/SubscriptionScope.ts +6 -0
  47. package/src/tests/zod.test.ts +35 -17
  48. package/dist/chunk-ORL6R2EV.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
 
2
- > jazz-tools@0.14.9 build /home/runner/_work/jazz/jazz/packages/jazz-tools
2
+ > jazz-tools@0.14.14 build /home/runner/_work/jazz/jazz/packages/jazz-tools
3
3
  > tsup && pnpm types
4
4
 
5
5
  CLI Building entry: {"index":"src/index.ts","testing":"src/testing.ts"}
@@ -9,14 +9,14 @@
9
9
  CLI Target: es2021
10
10
  CLI Cleaning output folder
11
11
  ESM Build start
12
- ESM dist/index.js 11.07 KB
12
+ ESM dist/index.js 11.11 KB
13
13
  ESM dist/testing.js 6.31 KB
14
- ESM dist/chunk-ORL6R2EV.js 132.69 KB
14
+ ESM dist/chunk-GRIN3FQP.js 133.77 KB
15
15
  ESM dist/index.js.map 18.38 KB
16
16
  ESM dist/testing.js.map 12.57 KB
17
- ESM dist/chunk-ORL6R2EV.js.map 307.06 KB
18
- ESM ⚡️ Build success in 75ms
17
+ ESM dist/chunk-GRIN3FQP.js.map 309.59 KB
18
+ ESM ⚡️ Build success in 59ms
19
19
 
20
- > jazz-tools@0.14.9 types /home/runner/_work/jazz/jazz/packages/jazz-tools
20
+ > jazz-tools@0.14.14 types /home/runner/_work/jazz/jazz/packages/jazz-tools
21
21
  > tsc --outDir dist
22
22
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # jazz-tools
2
2
 
3
+ ## 0.14.14
4
+
5
+ ### Patch Changes
6
+
7
+ - e32a1f7: Add useAnonymousFallback option in JazzContextManager
8
+
9
+ ## 0.14.10
10
+
11
+ ### Patch Changes
12
+
13
+ - dc746a2: Make the react peerDependency definition more relaxed
14
+ - f869d9a: Deprecated the withHelpers method in favor of standalone functions
15
+ - 3fe6832: Add support for z.catch/default. We ignore them for the moment and flag a warning.
16
+
3
17
  ## 0.14.9
4
18
 
5
19
  ### Patch Changes
@@ -2970,6 +2970,11 @@ var SubscriptionScope = class _SubscriptionScope {
2970
2970
  }
2971
2971
  return true;
2972
2972
  }
2973
+ getCurrentValue() {
2974
+ if (!this.shouldSendUpdates()) return;
2975
+ if (this.errorFromChildren) return this.errorFromChildren;
2976
+ return this.value;
2977
+ }
2973
2978
  triggerUpdate() {
2974
2979
  if (!this.shouldSendUpdates()) return;
2975
2980
  if (!this.dirty) return;
@@ -3403,7 +3408,7 @@ async function createJazzContext(options) {
3403
3408
  authSecretStorage
3404
3409
  };
3405
3410
  }
3406
- async function createAnonymousJazzContext({
3411
+ function createAnonymousJazzContext({
3407
3412
  peersToLoadFrom,
3408
3413
  crypto
3409
3414
  }) {
@@ -3783,6 +3788,13 @@ function zodFieldToCoFieldDef(schema) {
3783
3788
  return zodFieldToCoFieldDef(
3784
3789
  schema.unwrap()
3785
3790
  );
3791
+ } else if (schema._zod.def.type === "default" || schema._zod.def.type === "catch") {
3792
+ console.warn(
3793
+ "z.default()/z.catch() are not supported in collaborative schemas. They will be ignored."
3794
+ );
3795
+ return zodFieldToCoFieldDef(
3796
+ schema.def.innerType
3797
+ );
3786
3798
  } else if (schema._zod.def.type === "literal") {
3787
3799
  if (schema._zod.def.values.some(
3788
3800
  (literal2) => typeof literal2 === "undefined"
@@ -3983,6 +3995,7 @@ var ImageDefinition = ImageDefinitionBase.withHelpers((Self) => ({
3983
3995
 
3984
3996
  // src/implementation/ContextManager.ts
3985
3997
  import { cojsonInternals as cojsonInternals4 } from "cojson";
3998
+ import { PureJSCrypto } from "cojson/dist/crypto/PureJSCrypto";
3986
3999
 
3987
4000
  // src/auth/KvStoreContext.ts
3988
4001
  var KvStoreContext = class _KvStoreContext {
@@ -4146,8 +4159,28 @@ var InMemoryKVStore = class {
4146
4159
  };
4147
4160
 
4148
4161
  // src/implementation/ContextManager.ts
4162
+ function getAnonymousFallback() {
4163
+ const context = createAnonymousJazzContext({
4164
+ peersToLoadFrom: [],
4165
+ crypto: new PureJSCrypto()
4166
+ });
4167
+ return {
4168
+ guest: context.agent,
4169
+ node: context.agent.node,
4170
+ done: () => {
4171
+ },
4172
+ logOut: async () => {
4173
+ },
4174
+ isAuthenticated: false,
4175
+ authenticate: async () => {
4176
+ },
4177
+ register: async () => {
4178
+ throw new Error("Not implemented");
4179
+ }
4180
+ };
4181
+ }
4149
4182
  var JazzContextManager = class {
4150
- constructor() {
4183
+ constructor(opts) {
4151
4184
  this.authSecretStorage = new AuthSecretStorage();
4152
4185
  this.keepContextOpen = false;
4153
4186
  this.logOut = async () => {
@@ -4224,6 +4257,9 @@ var JazzContextManager = class {
4224
4257
  };
4225
4258
  };
4226
4259
  KvStoreContext.getInstance().initialize(this.getKvStore());
4260
+ if (opts?.useAnonymousFallback) {
4261
+ this.value = getAnonymousFallback();
4262
+ }
4227
4263
  }
4228
4264
  getKvStore() {
4229
4265
  return new InMemoryKVStore();
@@ -4275,6 +4311,9 @@ var JazzContextManager = class {
4275
4311
  getCurrentValue() {
4276
4312
  return this.value;
4277
4313
  }
4314
+ setCurrentValue(value) {
4315
+ this.value = value;
4316
+ }
4278
4317
  getAuthSecretStorage() {
4279
4318
  return this.authSecretStorage;
4280
4319
  }
@@ -4620,6 +4659,7 @@ export {
4620
4659
  activeAccountContext,
4621
4660
  Encoders,
4622
4661
  coField,
4662
+ SubscriptionScope,
4623
4663
  randomSessionProvider,
4624
4664
  createJazzContextFromExistingCredentials,
4625
4665
  createJazzContextForNewAccount,
@@ -4635,4 +4675,4 @@ export {
4635
4675
  JazzContextManager
4636
4676
  };
4637
4677
  /* istanbul ignore file -- @preserve */
4638
- //# sourceMappingURL=chunk-ORL6R2EV.js.map
4678
+ //# sourceMappingURL=chunk-GRIN3FQP.js.map