jazz-tools 0.14.20 → 0.14.21

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.
@@ -1,5 +1,5 @@
1
1
 
2
- > jazz-tools@0.14.20 build /home/runner/_work/jazz/jazz/packages/jazz-tools
2
+ > jazz-tools@0.14.21 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"}
@@ -11,12 +11,12 @@
11
11
  ESM Build start
12
12
  ESM dist/index.js 11.11 KB
13
13
  ESM dist/testing.js 6.31 KB
14
- ESM dist/chunk-SJKS4244.js 134.94 KB
14
+ ESM dist/chunk-DAOCWHIV.js 136.09 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-SJKS4244.js.map 309.25 KB
18
- ESM ⚡️ Build success in 48ms
17
+ ESM dist/chunk-DAOCWHIV.js.map 311.39 KB
18
+ ESM ⚡️ Build success in 52ms
19
19
 
20
- > jazz-tools@0.14.20 types /home/runner/_work/jazz/jazz/packages/jazz-tools
20
+ > jazz-tools@0.14.21 types /home/runner/_work/jazz/jazz/packages/jazz-tools
21
21
  > tsc --outDir dist
22
22
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # jazz-tools
2
2
 
3
+ ## 0.14.21
4
+
5
+ ### Patch Changes
6
+
7
+ - e7e505e: Adds `makePublic(role)` alias for `group.addMember("everyone", role)`
8
+ - 13b57aa: Fix creation of z.discriminatedUnions of CoValue schemas in Inbox and other places
9
+ - 5662faa: Add `_createdAt` and `_lastUpdatedAt` getters for CoMaps
10
+ - 2116a59: Improve SubscriptionScope.getCurrentValue to be the basis of the new React integration
11
+ - Updated dependencies [c3d8779]
12
+ - cojson@0.14.21
13
+
3
14
  ## 0.14.20
4
15
 
5
16
  ### Patch Changes
@@ -151,6 +151,18 @@ var _CoMap = class _CoMap extends CoValueBase {
151
151
  get _schema() {
152
152
  return this.constructor._schema;
153
153
  }
154
+ /**
155
+ * The timestamp of the creation time of the CoMap
156
+ */
157
+ get _createdAt() {
158
+ return this._raw.earliestTxMadeAt ?? Number.MAX_SAFE_INTEGER;
159
+ }
160
+ /**
161
+ * The timestamp of the last updated time of the CoMap
162
+ */
163
+ get _lastUpdatedAt() {
164
+ return this._raw.latestTxMadeAt;
165
+ }
154
166
  /**
155
167
  * If property `prop` is a `coField.ref(...)`, you can use `coMaps._refs.prop` to access
156
168
  * the `Ref` instead of the potentially loaded/null value.
@@ -1934,6 +1946,17 @@ var _Group = class _Group extends CoValueBase {
1934
1946
  member === "everyone" ? member : member
1935
1947
  );
1936
1948
  }
1949
+ /**
1950
+ * Make the group public, so that everyone can read it.
1951
+ * Alias for `addMember("everyone", role)`.
1952
+ *
1953
+ * @param role - Optional: the role to grant to everyone. Defaults to "reader".
1954
+ * @returns The group itself.
1955
+ */
1956
+ makePublic(role = "reader") {
1957
+ this.addMember("everyone", role);
1958
+ return this;
1959
+ }
1937
1960
  getParentGroups() {
1938
1961
  return this._raw.getParentGroups().map((group) => _Group.fromRaw(group));
1939
1962
  }
@@ -2999,9 +3022,21 @@ var SubscriptionScope = class _SubscriptionScope {
2999
3022
  return true;
3000
3023
  }
3001
3024
  getCurrentValue() {
3002
- if (!this.shouldSendUpdates()) return;
3003
- if (this.errorFromChildren) return this.errorFromChildren;
3004
- return this.value;
3025
+ if (this.value.type === "unauthorized" || this.value.type === "unavailable") {
3026
+ console.error(this.value.toString());
3027
+ return null;
3028
+ }
3029
+ if (!this.shouldSendUpdates()) {
3030
+ return void 0;
3031
+ }
3032
+ if (this.errorFromChildren) {
3033
+ console.error(this.errorFromChildren.toString());
3034
+ return null;
3035
+ }
3036
+ if (this.value.type === "loaded") {
3037
+ return this.value.value;
3038
+ }
3039
+ return void 0;
3005
3040
  }
3006
3041
  triggerUpdate() {
3007
3042
  if (!this.shouldSendUpdates()) return;
@@ -4022,8 +4057,16 @@ function anySchemaToCoSchema(schema) {
4022
4057
  return schema;
4023
4058
  } else if ("getCoSchema" in schema) {
4024
4059
  return schema.getCoSchema();
4060
+ } else if ("def" in schema) {
4061
+ const coSchema = tryZodSchemaToCoSchema(schema);
4062
+ if (!coSchema) {
4063
+ throw new Error(
4064
+ `Unsupported zod type: ${schema.def?.type || JSON.stringify(schema)}`
4065
+ );
4066
+ }
4067
+ return coSchema;
4025
4068
  }
4026
- throw new Error(`Unsupported schema: ${schema}`);
4069
+ throw new Error(`Unsupported schema: ${JSON.stringify(schema)}`);
4027
4070
  }
4028
4071
  function zodSchemaToCoSchemaOrKeepPrimitive(schema) {
4029
4072
  const coSchema = tryZodSchemaToCoSchema(schema);
@@ -4752,4 +4795,4 @@ export {
4752
4795
  JazzContextManager
4753
4796
  };
4754
4797
  /* istanbul ignore file -- @preserve */
4755
- //# sourceMappingURL=chunk-SJKS4244.js.map
4798
+ //# sourceMappingURL=chunk-DAOCWHIV.js.map