@zapier/kitcore 0.9.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 CHANGED
@@ -1,5 +1,17 @@
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
+
9
+ ## 0.10.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 4e560c0: Added `isCoreCancelledSignal`, a brand-based guard for the cancellation signal raised by `Controller.resolve`. It recognizes the signal across bundle boundaries where `instanceof CoreCancelledSignal` would not.
14
+
3
15
  ## 0.9.0
4
16
 
5
17
  ### Minor Changes
package/dist/index.cjs CHANGED
@@ -74,6 +74,7 @@ __export(index_exports, {
74
74
  getOutputSchema: () => getOutputSchema,
75
75
  getRegistryPlugin: () => getRegistryPlugin,
76
76
  getSchemaDescription: () => getSchemaDescription,
77
+ isCoreCancelledSignal: () => isCoreCancelledSignal,
77
78
  isCoreError: () => isCoreError,
78
79
  isCoreSignal: () => isCoreSignal,
79
80
  isNestedMethodCall: () => isNestedMethodCall,
@@ -269,13 +270,34 @@ function buildRegistry({
269
270
  }
270
271
 
271
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
+ }
272
290
  function composeVoid(existing, added) {
273
- if (!existing) return added;
274
- if (!added) return existing;
275
- return (ctx) => {
276
- existing(ctx);
277
- added(ctx);
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);
278
298
  };
299
+ isolated.add(composed);
300
+ return composed;
279
301
  }
280
302
  function buildHooks(existing, added) {
281
303
  const result = {};
@@ -1024,24 +1046,27 @@ function createPaginatedFunction(coreFn, options) {
1024
1046
  return result.value;
1025
1047
  });
1026
1048
  if (hooks?.onMethodEnd) {
1027
- firstPagePromise.then(() => {
1028
- hooks.onMethodEnd({
1029
- methodName: functionName,
1030
- args,
1031
- isPaginated: true,
1032
- depth,
1033
- durationMs: Date.now() - startTime
1034
- });
1035
- }).catch((error) => {
1036
- hooks.onMethodEnd({
1037
- methodName: functionName,
1038
- args,
1039
- isPaginated: true,
1040
- depth,
1041
- durationMs: Date.now() - startTime,
1042
- error: error instanceof Error ? error : new Error(String(error))
1043
- });
1044
- });
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
+ );
1045
1070
  }
1046
1071
  const pageStream = async function* () {
1047
1072
  yield await firstPagePromise;
@@ -2819,6 +2844,9 @@ var CoreCancelledSignal = class extends CoreSignal {
2819
2844
  this.code = "CANCELLED";
2820
2845
  }
2821
2846
  };
2847
+ function isCoreCancelledSignal(value) {
2848
+ return isCoreSignal(value) && value.code === "CANCELLED";
2849
+ }
2822
2850
 
2823
2851
  // src/model/resolution/plan.ts
2824
2852
  var import_zod3 = require("zod");
@@ -4117,6 +4145,7 @@ function createCorePlugin(options) {
4117
4145
  getOutputSchema,
4118
4146
  getRegistryPlugin,
4119
4147
  getSchemaDescription,
4148
+ isCoreCancelledSignal,
4120
4149
  isCoreError,
4121
4150
  isCoreSignal,
4122
4151
  isNestedMethodCall,