jazz-tools 0.13.2 → 0.13.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.
@@ -1,5 +1,5 @@
1
1
 
2
- > jazz-tools@0.13.2 build /home/runner/_work/jazz/jazz/packages/jazz-tools
2
+ > jazz-tools@0.13.4 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 1.50 KB
13
13
  ESM dist/testing.js 6.26 KB
14
- ESM dist/chunk-FKK4CPZZ.js 125.77 KB
14
+ ESM dist/chunk-JNC2UVYB.js 127.31 KB
15
15
  ESM dist/index.js.map 259.00 B
16
16
  ESM dist/testing.js.map 12.37 KB
17
- ESM dist/chunk-FKK4CPZZ.js.map 297.37 KB
18
- ESM ⚡️ Build success in 48ms
17
+ ESM dist/chunk-JNC2UVYB.js.map 300.24 KB
18
+ ESM ⚡️ Build success in 64ms
19
19
 
20
- > jazz-tools@0.13.2 types /home/runner/_work/jazz/jazz/packages/jazz-tools
20
+ > jazz-tools@0.13.4 types /home/runner/_work/jazz/jazz/packages/jazz-tools
21
21
  > tsc --outDir dist
22
22
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # jazz-tools
2
2
 
3
+ ## 0.13.4
4
+
5
+ ### Patch Changes
6
+
7
+ - 3129982: Add logOutReplacement hook to replace the Jazz logout function with a custom one
8
+
9
+ ## 0.13.3
10
+
11
+ ### Patch Changes
12
+
13
+ - 12f8bfa: Log permission errors when loading or subscribing to values
14
+ - bd57177: Handle null properties in the CoMap deep loading
15
+
3
16
  ## 0.13.2
4
17
 
5
18
  ### 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 "fulfilled";
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
- let result = "fulfilled";
73
+ const result = { status: "fulfilled" };
72
74
  for (const [key, item] of Object.entries(value)) {
73
- if (map._raw.get(key) !== void 0) {
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 "unauthorized";
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
- return "unauthorized";
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 "unfulfilled";
97
+ return {
98
+ status: "unfulfilled"
99
+ };
90
100
  }
91
101
  }
92
102
  return result;
93
103
  } else {
94
- let result = "fulfilled";
104
+ const result = { status: "fulfilled" };
95
105
  for (const key of Object.keys(depth)) {
96
- if (map._raw.get(key) === void 0) {
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 "unauthorized";
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
- return "unauthorized";
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
- let result = "fulfilled";
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 "unauthorized";
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
- return "unauthorized";
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 "unfulfilled";
179
+ return {
180
+ status: "unfulfilled"
181
+ };
159
182
  }
160
183
  }
161
184
  return result;
162
185
  }
163
- return "fulfilled";
186
+ return {
187
+ status: "fulfilled"
188
+ };
164
189
  } else if (value._type === "CoStream") {
165
190
  if ("$each" in depth) {
166
- let result = "fulfilled";
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 "unauthorized";
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
- return "unauthorized";
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 "unfulfilled";
214
+ return {
215
+ status: "unfulfilled"
216
+ };
185
217
  }
186
218
  }
187
219
  return result;
188
220
  }
189
- return "fulfilled";
221
+ return {
222
+ status: "fulfilled"
223
+ };
190
224
  } else if (value._type === "BinaryCoStream" || value._type === "CoPlainText") {
191
- return "fulfilled";
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
- options.onUnauthorized?.();
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
- options.onUnauthorized?.();
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
  }
@@ -3899,8 +3947,12 @@ var JazzContextManager = class {
3899
3947
  return;
3900
3948
  }
3901
3949
  await this.props.onLogOut?.();
3902
- await this.context.logOut();
3903
- return this.createContext(this.props);
3950
+ if (this.props.logOutReplacement) {
3951
+ await this.props.logOutReplacement();
3952
+ } else {
3953
+ await this.context.logOut();
3954
+ return this.createContext(this.props);
3955
+ }
3904
3956
  };
3905
3957
  this.done = () => {
3906
3958
  if (!this.context) {
@@ -4379,4 +4431,4 @@ export {
4379
4431
  consumeInviteLink
4380
4432
  };
4381
4433
  /* istanbul ignore file -- @preserve */
4382
- //# sourceMappingURL=chunk-FKK4CPZZ.js.map
4434
+ //# sourceMappingURL=chunk-JNC2UVYB.js.map