@zapier/kitcore 0.10.0 → 0.10.1
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/CHANGELOG.md +6 -0
- package/dist/index.cjs +47 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +48 -24
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @zapier/kitcore
|
|
2
2
|
|
|
3
|
+
## 0.10.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 0e38143: Method-lifecycle observers (`onMethodStart` / `onMethodEnd`) are now isolated from the methods they observe. A throwing observer is logged and ignored instead of breaking the method call, and a throw in one observer no longer stops its siblings from running. Paginated methods also fire `onMethodEnd` in the same microtask the call settles, including when the first page fails, matching non-paginated methods.
|
|
8
|
+
|
|
3
9
|
## 0.10.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/dist/index.cjs
CHANGED
|
@@ -270,13 +270,34 @@ function buildRegistry({
|
|
|
270
270
|
}
|
|
271
271
|
|
|
272
272
|
// src/utils/build-hooks.ts
|
|
273
|
+
var isolated = /* @__PURE__ */ new WeakSet();
|
|
274
|
+
function isolate(observer) {
|
|
275
|
+
if (!observer) return void 0;
|
|
276
|
+
if (isolated.has(observer)) return observer;
|
|
277
|
+
const wrapped = (ctx) => {
|
|
278
|
+
try {
|
|
279
|
+
observer(ctx);
|
|
280
|
+
} catch (error) {
|
|
281
|
+
console.error(
|
|
282
|
+
"[core] A method-lifecycle observer threw and was ignored. Observers are fire-and-forget and must not throw.",
|
|
283
|
+
error
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
isolated.add(wrapped);
|
|
288
|
+
return wrapped;
|
|
289
|
+
}
|
|
273
290
|
function composeVoid(existing, added) {
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
291
|
+
const wrappedExisting = isolate(existing);
|
|
292
|
+
const wrappedAdded = isolate(added);
|
|
293
|
+
if (!wrappedExisting) return wrappedAdded;
|
|
294
|
+
if (!wrappedAdded) return wrappedExisting;
|
|
295
|
+
const composed = (ctx) => {
|
|
296
|
+
wrappedExisting(ctx);
|
|
297
|
+
wrappedAdded(ctx);
|
|
279
298
|
};
|
|
299
|
+
isolated.add(composed);
|
|
300
|
+
return composed;
|
|
280
301
|
}
|
|
281
302
|
function buildHooks(existing, added) {
|
|
282
303
|
const result = {};
|
|
@@ -1025,24 +1046,27 @@ function createPaginatedFunction(coreFn, options) {
|
|
|
1025
1046
|
return result.value;
|
|
1026
1047
|
});
|
|
1027
1048
|
if (hooks?.onMethodEnd) {
|
|
1028
|
-
firstPagePromise.then(
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1049
|
+
firstPagePromise.then(
|
|
1050
|
+
() => {
|
|
1051
|
+
hooks.onMethodEnd({
|
|
1052
|
+
methodName: functionName,
|
|
1053
|
+
args,
|
|
1054
|
+
isPaginated: true,
|
|
1055
|
+
depth,
|
|
1056
|
+
durationMs: Date.now() - startTime
|
|
1057
|
+
});
|
|
1058
|
+
},
|
|
1059
|
+
(error) => {
|
|
1060
|
+
hooks.onMethodEnd({
|
|
1061
|
+
methodName: functionName,
|
|
1062
|
+
args,
|
|
1063
|
+
isPaginated: true,
|
|
1064
|
+
depth,
|
|
1065
|
+
durationMs: Date.now() - startTime,
|
|
1066
|
+
error: error instanceof Error ? error : new Error(String(error))
|
|
1067
|
+
});
|
|
1068
|
+
}
|
|
1069
|
+
);
|
|
1046
1070
|
}
|
|
1047
1071
|
const pageStream = async function* () {
|
|
1048
1072
|
yield await firstPagePromise;
|