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.
- package/.turbo/turbo-build.log +5 -5
- package/CHANGELOG.md +11 -0
- package/dist/{chunk-SJKS4244.js → chunk-DAOCWHIV.js} +48 -5
- package/dist/chunk-DAOCWHIV.js.map +1 -0
- package/dist/coValues/coMap.d.ts +16 -0
- package/dist/coValues/coMap.d.ts.map +1 -1
- package/dist/coValues/group.d.ts +8 -0
- package/dist/coValues/group.d.ts.map +1 -1
- package/dist/coValues/interfaces.d.ts +5 -0
- package/dist/coValues/interfaces.d.ts.map +1 -1
- package/dist/implementation/zodSchema/runtimeConverters/zodSchemaToCoSchema.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/subscribe/SubscriptionScope.d.ts +1 -1
- package/dist/subscribe/SubscriptionScope.d.ts.map +1 -1
- package/dist/testing.js +1 -1
- package/package.json +2 -2
- package/src/coValues/coMap.ts +14 -0
- package/src/coValues/group.ts +12 -0
- package/src/coValues/interfaces.ts +5 -0
- package/src/implementation/zodSchema/runtimeConverters/zodSchemaToCoSchema.ts +9 -1
- package/src/subscribe/SubscriptionScope.ts +22 -3
- package/src/tests/coMap.test.ts +65 -0
- package/src/tests/groupsAndAccounts.test.ts +12 -0
- package/src/tests/schemaUnion.test.ts +5 -5
- package/dist/chunk-SJKS4244.js.map +0 -1
package/.turbo/turbo-build.log
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
> jazz-tools@0.14.
|
2
|
+
> jazz-tools@0.14.21 build /home/runner/_work/jazz/jazz/packages/jazz-tools
|
3
3
|
> tsup && pnpm types
|
4
4
|
|
5
5
|
[34mCLI[39m Building entry: {"index":"src/index.ts","testing":"src/testing.ts"}
|
@@ -11,12 +11,12 @@
|
|
11
11
|
[34mESM[39m Build start
|
12
12
|
[32mESM[39m [1mdist/index.js [22m[32m11.11 KB[39m
|
13
13
|
[32mESM[39m [1mdist/testing.js [22m[32m6.31 KB[39m
|
14
|
-
[32mESM[39m [1mdist/chunk-
|
14
|
+
[32mESM[39m [1mdist/chunk-DAOCWHIV.js [22m[32m136.09 KB[39m
|
15
15
|
[32mESM[39m [1mdist/index.js.map [22m[32m18.38 KB[39m
|
16
16
|
[32mESM[39m [1mdist/testing.js.map [22m[32m12.57 KB[39m
|
17
|
-
[32mESM[39m [1mdist/chunk-
|
18
|
-
[32mESM[39m ⚡️ Build success in
|
17
|
+
[32mESM[39m [1mdist/chunk-DAOCWHIV.js.map [22m[32m311.39 KB[39m
|
18
|
+
[32mESM[39m ⚡️ Build success in 52ms
|
19
19
|
|
20
|
-
> jazz-tools@0.14.
|
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 (
|
3003
|
-
|
3004
|
-
|
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-
|
4798
|
+
//# sourceMappingURL=chunk-DAOCWHIV.js.map
|