jazz-tools 0.13.0 → 0.13.3
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 +14 -0
- package/dist/{chunk-FKK4CPZZ.js → chunk-YZW2QELD.js} +90 -42
- package/dist/chunk-YZW2QELD.js.map +1 -0
- package/dist/coValues/deepLoading.d.ts +8 -2
- package/dist/coValues/deepLoading.d.ts.map +1 -1
- package/dist/coValues/interfaces.d.ts +1 -1
- package/dist/coValues/interfaces.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/testing.js +1 -1
- package/package.json +2 -2
- package/src/coValues/deepLoading.ts +89 -39
- package/src/coValues/interfaces.ts +17 -5
- package/src/tests/deepLoading.test.ts +104 -4
- package/vitest.config.ts +10 -0
- package/dist/chunk-FKK4CPZZ.js.map +0 -1
package/.turbo/turbo-build.log
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
> jazz-tools@0.13.
|
2
|
+
> jazz-tools@0.13.3 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[32m1.50 KB[39m
|
13
13
|
[32mESM[39m [1mdist/testing.js [22m[32m6.26 KB[39m
|
14
|
-
[32mESM[39m [1mdist/chunk-
|
14
|
+
[32mESM[39m [1mdist/chunk-YZW2QELD.js [22m[32m127.20 KB[39m
|
15
15
|
[32mESM[39m [1mdist/index.js.map [22m[32m259.00 B[39m
|
16
16
|
[32mESM[39m [1mdist/testing.js.map [22m[32m12.37 KB[39m
|
17
|
-
[32mESM[39m [1mdist/chunk-
|
18
|
-
[32mESM[39m ⚡️ Build success in
|
17
|
+
[32mESM[39m [1mdist/chunk-YZW2QELD.js.map [22m[32m300.00 KB[39m
|
18
|
+
[32mESM[39m ⚡️ Build success in 67ms
|
19
19
|
|
20
|
-
> jazz-tools@0.13.
|
20
|
+
> jazz-tools@0.13.3 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.13.3
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- 12f8bfa: Log permission errors when loading or subscribing to values
|
8
|
+
- bd57177: Handle null properties in the CoMap deep loading
|
9
|
+
|
10
|
+
## 0.13.2
|
11
|
+
|
12
|
+
### Patch Changes
|
13
|
+
|
14
|
+
- Updated dependencies [c551839]
|
15
|
+
- cojson@0.13.2
|
16
|
+
|
3
17
|
## 0.13.0
|
4
18
|
|
5
19
|
### Patch Changes
|
@@ -63,37 +63,48 @@ function isOptionalField(value, key) {
|
|
63
63
|
}
|
64
64
|
function fulfillsDepth(depth, value) {
|
65
65
|
if (depth === true || depth === void 0) {
|
66
|
-
return
|
66
|
+
return {
|
67
|
+
status: "fulfilled"
|
68
|
+
};
|
67
69
|
}
|
68
70
|
if (value._type === "CoMap" || value._type === "Group" || value._type === "Account") {
|
69
71
|
const map = value;
|
70
72
|
if ("$each" in depth) {
|
71
|
-
|
73
|
+
const result = { status: "fulfilled" };
|
72
74
|
for (const [key, item] of Object.entries(value)) {
|
73
|
-
|
75
|
+
const rawValue = map._raw.get(key);
|
76
|
+
if (rawValue !== void 0) {
|
74
77
|
if (!item) {
|
75
78
|
if (hasReadAccess(map, key)) {
|
76
|
-
result = "unfulfilled";
|
79
|
+
result.status = "unfulfilled";
|
77
80
|
continue;
|
78
81
|
} else {
|
79
|
-
return
|
82
|
+
return {
|
83
|
+
status: "unauthorized",
|
84
|
+
path: [key],
|
85
|
+
id: rawValue
|
86
|
+
};
|
80
87
|
}
|
81
88
|
}
|
82
89
|
const innerResult = fulfillsDepth(depth.$each, item);
|
83
|
-
if (innerResult === "unfulfilled") {
|
84
|
-
result = "unfulfilled";
|
85
|
-
} else if (innerResult === "unauthorized" && !isOptionalField(value, ItemsSym)) {
|
86
|
-
|
90
|
+
if (innerResult.status === "unfulfilled") {
|
91
|
+
result.status = "unfulfilled";
|
92
|
+
} else if (innerResult.status === "unauthorized" && !isOptionalField(value, ItemsSym)) {
|
93
|
+
innerResult.path.unshift(key);
|
94
|
+
return innerResult;
|
87
95
|
}
|
88
96
|
} else if (!isOptionalField(value, ItemsSym)) {
|
89
|
-
return
|
97
|
+
return {
|
98
|
+
status: "unfulfilled"
|
99
|
+
};
|
90
100
|
}
|
91
101
|
}
|
92
102
|
return result;
|
93
103
|
} else {
|
94
|
-
|
104
|
+
const result = { status: "fulfilled" };
|
95
105
|
for (const key of Object.keys(depth)) {
|
96
|
-
|
106
|
+
const rawValue = map._raw.get(key);
|
107
|
+
if (rawValue === void 0 || rawValue === null) {
|
97
108
|
if (!map._schema?.[key]) {
|
98
109
|
if (map._schema?.[ItemsSym]) {
|
99
110
|
if (isOptionalField(map, ItemsSym)) {
|
@@ -119,17 +130,22 @@ function fulfillsDepth(depth, value) {
|
|
119
130
|
const item = value[key];
|
120
131
|
if (!item) {
|
121
132
|
if (hasReadAccess(map, key)) {
|
122
|
-
result = "unfulfilled";
|
133
|
+
result.status = "unfulfilled";
|
123
134
|
continue;
|
124
135
|
} else {
|
125
|
-
return
|
136
|
+
return {
|
137
|
+
status: "unauthorized",
|
138
|
+
path: [key],
|
139
|
+
id: rawValue
|
140
|
+
};
|
126
141
|
}
|
127
142
|
}
|
128
143
|
const innerResult = fulfillsDepth(depth[key], item);
|
129
|
-
if (innerResult === "unfulfilled") {
|
130
|
-
result = "unfulfilled";
|
131
|
-
} else if (innerResult === "unauthorized" && !isOptionalField(value, key)) {
|
132
|
-
|
144
|
+
if (innerResult.status === "unfulfilled") {
|
145
|
+
result.status = "unfulfilled";
|
146
|
+
} else if (innerResult.status === "unauthorized" && !isOptionalField(value, key)) {
|
147
|
+
innerResult.path.unshift(key);
|
148
|
+
return innerResult;
|
133
149
|
}
|
134
150
|
}
|
135
151
|
}
|
@@ -137,58 +153,78 @@ function fulfillsDepth(depth, value) {
|
|
137
153
|
}
|
138
154
|
} else if (value._type === "CoList") {
|
139
155
|
if ("$each" in depth) {
|
140
|
-
|
156
|
+
const result = { status: "fulfilled" };
|
141
157
|
for (const [key, item] of value.entries()) {
|
142
158
|
if (hasRefValue(value, key)) {
|
143
159
|
if (!item) {
|
144
160
|
if (hasReadAccess(value, key)) {
|
145
|
-
result = "unfulfilled";
|
161
|
+
result.status = "unfulfilled";
|
146
162
|
continue;
|
147
163
|
} else {
|
148
|
-
return
|
164
|
+
return {
|
165
|
+
status: "unauthorized",
|
166
|
+
path: [key.toString()],
|
167
|
+
id: value._raw.get(key) ?? "undefined"
|
168
|
+
};
|
149
169
|
}
|
150
170
|
}
|
151
171
|
const innerResult = fulfillsDepth(depth.$each, item);
|
152
|
-
if (innerResult === "unfulfilled") {
|
153
|
-
result = "unfulfilled";
|
154
|
-
} else if (innerResult === "unauthorized" && !isOptionalField(value, ItemsSym)) {
|
155
|
-
|
172
|
+
if (innerResult.status === "unfulfilled") {
|
173
|
+
result.status = "unfulfilled";
|
174
|
+
} else if (innerResult.status === "unauthorized" && !isOptionalField(value, ItemsSym)) {
|
175
|
+
innerResult.path.unshift(key.toString());
|
176
|
+
return innerResult;
|
156
177
|
}
|
157
178
|
} else if (!isOptionalField(value, ItemsSym)) {
|
158
|
-
return
|
179
|
+
return {
|
180
|
+
status: "unfulfilled"
|
181
|
+
};
|
159
182
|
}
|
160
183
|
}
|
161
184
|
return result;
|
162
185
|
}
|
163
|
-
return
|
186
|
+
return {
|
187
|
+
status: "fulfilled"
|
188
|
+
};
|
164
189
|
} else if (value._type === "CoStream") {
|
165
190
|
if ("$each" in depth) {
|
166
|
-
|
191
|
+
const result = { status: "fulfilled" };
|
167
192
|
for (const item of Object.values(value.perSession)) {
|
168
193
|
if (item.ref) {
|
169
194
|
if (!item.value) {
|
170
195
|
if (item.ref.hasReadAccess()) {
|
171
|
-
result = "unfulfilled";
|
196
|
+
result.status = "unfulfilled";
|
172
197
|
continue;
|
173
198
|
} else {
|
174
|
-
return
|
199
|
+
return {
|
200
|
+
status: "unauthorized",
|
201
|
+
path: [item.ref.id],
|
202
|
+
id: item.ref.id
|
203
|
+
};
|
175
204
|
}
|
176
205
|
}
|
177
206
|
const innerResult = fulfillsDepth(depth.$each, item.value);
|
178
|
-
if (innerResult === "unfulfilled") {
|
179
|
-
result = "unfulfilled";
|
180
|
-
} else if (innerResult === "unauthorized" && !isOptionalField(value, ItemsSym)) {
|
181
|
-
|
207
|
+
if (innerResult.status === "unfulfilled") {
|
208
|
+
result.status = "unfulfilled";
|
209
|
+
} else if (innerResult.status === "unauthorized" && !isOptionalField(value, ItemsSym)) {
|
210
|
+
innerResult.path.unshift(item.ref.id);
|
211
|
+
return innerResult;
|
182
212
|
}
|
183
213
|
} else if (!isOptionalField(value, ItemsSym)) {
|
184
|
-
return
|
214
|
+
return {
|
215
|
+
status: "unfulfilled"
|
216
|
+
};
|
185
217
|
}
|
186
218
|
}
|
187
219
|
return result;
|
188
220
|
}
|
189
|
-
return
|
221
|
+
return {
|
222
|
+
status: "fulfilled"
|
223
|
+
};
|
190
224
|
} else if (value._type === "BinaryCoStream" || value._type === "CoPlainText") {
|
191
|
-
return
|
225
|
+
return {
|
226
|
+
status: "fulfilled"
|
227
|
+
};
|
192
228
|
} else {
|
193
229
|
console.error(value);
|
194
230
|
throw new Error("Unexpected value type: " + value._type);
|
@@ -952,7 +988,11 @@ function subscribeToCoValue(cls, id, options, listener) {
|
|
952
988
|
(update, subscription2) => {
|
953
989
|
if (subscription2.syncResolution) return;
|
954
990
|
if (!ref2.hasReadAccess()) {
|
955
|
-
|
991
|
+
console.error(
|
992
|
+
"Not enough permissions to load / subscribe to CoValue",
|
993
|
+
id
|
994
|
+
);
|
995
|
+
options.onUnauthorized?.([]);
|
956
996
|
return;
|
957
997
|
}
|
958
998
|
let result;
|
@@ -970,11 +1010,19 @@ function subscribeToCoValue(cls, id, options, listener) {
|
|
970
1010
|
} finally {
|
971
1011
|
subscription2.syncResolution = false;
|
972
1012
|
}
|
973
|
-
if (result === "unauthorized") {
|
974
|
-
|
1013
|
+
if (result.status === "unauthorized") {
|
1014
|
+
console.error(
|
1015
|
+
"Not enough permissions to load / subscribe to CoValue",
|
1016
|
+
id,
|
1017
|
+
"on path",
|
1018
|
+
result.path.join("."),
|
1019
|
+
"unaccessible value:",
|
1020
|
+
result.id
|
1021
|
+
);
|
1022
|
+
options.onUnauthorized?.(result.path);
|
975
1023
|
return;
|
976
1024
|
}
|
977
|
-
if (result === "fulfilled") {
|
1025
|
+
if (result.status === "fulfilled") {
|
978
1026
|
listener(update, subscription2.unsubscribeAll);
|
979
1027
|
}
|
980
1028
|
}
|
@@ -4379,4 +4427,4 @@ export {
|
|
4379
4427
|
consumeInviteLink
|
4380
4428
|
};
|
4381
4429
|
/* istanbul ignore file -- @preserve */
|
4382
|
-
//# sourceMappingURL=chunk-
|
4430
|
+
//# sourceMappingURL=chunk-YZW2QELD.js.map
|