@zapier/kitcore 0.15.0 → 0.16.0

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/dist/index.d.mts CHANGED
@@ -1263,10 +1263,10 @@ type DataOf<TResponse> = TResponse extends {
1263
1263
  } ? TData : never;
1264
1264
  /**
1265
1265
  * A leaf plugin that is a single value (not a function). `value` is a static
1266
- * constant; `get({ imports })` computes the value from imports. Like a
1267
- * method's `setup`, `get` runs eagerly at createSdk (dependencies first), so a
1268
- * module-level value is built on import. An imported/surfaced property yields
1269
- * the value, not a callable.
1266
+ * constant; `get({ imports, state })` computes the value from imports and
1267
+ * `setup` state, re-running live on each read. An optional `setup` runs once
1268
+ * eagerly at createSdk (dependencies first, like a method's `setup`) to build
1269
+ * that state. An imported/surfaced property yields the value, not a callable.
1270
1270
  */
1271
1271
  interface PropertyPlugin<TName extends string = string, TValue = unknown> {
1272
1272
  pluginType: "property";
@@ -1306,6 +1306,7 @@ interface PropertyPlugin<TName extends string = string, TValue = unknown> {
1306
1306
  get?: (bag: {
1307
1307
  imports: Record<string, unknown>;
1308
1308
  state: unknown;
1309
+ callContext?: CallContext;
1309
1310
  }) => TValue;
1310
1311
  /** Descriptive metadata for the registry / CLI / MCP / docs (carry-only). */
1311
1312
  meta?: LeafMeta;
@@ -1548,7 +1549,10 @@ interface PropertyEntry {
1548
1549
  pluginType: "property";
1549
1550
  name: string;
1550
1551
  value?: any;
1551
- getValue?: () => any;
1552
+ /** Re-derives the value per read. Receives the live per-call `CallContext`
1553
+ * when installed on a method's `imports` bag with a threaded context, and
1554
+ * nothing on a surface / build-time read. */
1555
+ getValue?: (callContext?: CallContext) => any;
1552
1556
  /** Carried from the descriptor for the registry / CLI / MCP / docs. */
1553
1557
  meta?: LeafMeta;
1554
1558
  /** Carried from the descriptor: templated registry members for this
@@ -2627,9 +2631,11 @@ declare function declareOptionalMethod<const TId extends string, TInput = unknow
2627
2631
  optional: true;
2628
2632
  } & PluginSummary<never, never>;
2629
2633
  /**
2630
- * Define a property leaf. Either a static `value` or a computed `get` (eager,
2631
- * dependencies first, like `setup`). `createSdk`, a dependent's `imports`, or
2632
- * an aggregate's re-export binds it under its bare `name` and yields the value.
2634
+ * Define a property leaf. Either a static `value` or a computed `get`, which
2635
+ * re-runs live on each read; an optional `setup` runs once at `createSdk`
2636
+ * (dependencies first, like a method's `setup`) to build the state `get` reads.
2637
+ * `createSdk`, a dependent's `imports`, or an aggregate's re-export binds it
2638
+ * under its bare `name` and yields the value.
2633
2639
  */
2634
2640
  declare function defineProperty<const TName extends string, TValue, const TNamespace extends string = "">(config: {
2635
2641
  name: TName;
@@ -2651,6 +2657,13 @@ declare function defineProperty<const TName extends string, TValue, const TImpor
2651
2657
  get: (bag: {
2652
2658
  imports: ImportsOf<TImports>;
2653
2659
  state: TState;
2660
+ /** The live per-call context when the property is read from a method's
2661
+ * `imports` bag — every method call has one, at any depth. Undefined only
2662
+ * where no call is in flight: the property bound onto the SDK object
2663
+ * itself, and reads from a `setup`-time imports bag. A context-aware
2664
+ * property reads its `callId` off this; because its value is then specific
2665
+ * to the reading call, callers must not cache it across calls. */
2666
+ callContext?: CallContext;
2654
2667
  }) => TValue;
2655
2668
  /** Templated registry members for this property's dynamic sub-surface (e.g.
2656
2669
  * a proxy): each a bodyless declaration keyed by `path` instead of `name`. */
package/dist/index.d.ts CHANGED
@@ -1263,10 +1263,10 @@ type DataOf<TResponse> = TResponse extends {
1263
1263
  } ? TData : never;
1264
1264
  /**
1265
1265
  * A leaf plugin that is a single value (not a function). `value` is a static
1266
- * constant; `get({ imports })` computes the value from imports. Like a
1267
- * method's `setup`, `get` runs eagerly at createSdk (dependencies first), so a
1268
- * module-level value is built on import. An imported/surfaced property yields
1269
- * the value, not a callable.
1266
+ * constant; `get({ imports, state })` computes the value from imports and
1267
+ * `setup` state, re-running live on each read. An optional `setup` runs once
1268
+ * eagerly at createSdk (dependencies first, like a method's `setup`) to build
1269
+ * that state. An imported/surfaced property yields the value, not a callable.
1270
1270
  */
1271
1271
  interface PropertyPlugin<TName extends string = string, TValue = unknown> {
1272
1272
  pluginType: "property";
@@ -1306,6 +1306,7 @@ interface PropertyPlugin<TName extends string = string, TValue = unknown> {
1306
1306
  get?: (bag: {
1307
1307
  imports: Record<string, unknown>;
1308
1308
  state: unknown;
1309
+ callContext?: CallContext;
1309
1310
  }) => TValue;
1310
1311
  /** Descriptive metadata for the registry / CLI / MCP / docs (carry-only). */
1311
1312
  meta?: LeafMeta;
@@ -1548,7 +1549,10 @@ interface PropertyEntry {
1548
1549
  pluginType: "property";
1549
1550
  name: string;
1550
1551
  value?: any;
1551
- getValue?: () => any;
1552
+ /** Re-derives the value per read. Receives the live per-call `CallContext`
1553
+ * when installed on a method's `imports` bag with a threaded context, and
1554
+ * nothing on a surface / build-time read. */
1555
+ getValue?: (callContext?: CallContext) => any;
1552
1556
  /** Carried from the descriptor for the registry / CLI / MCP / docs. */
1553
1557
  meta?: LeafMeta;
1554
1558
  /** Carried from the descriptor: templated registry members for this
@@ -2627,9 +2631,11 @@ declare function declareOptionalMethod<const TId extends string, TInput = unknow
2627
2631
  optional: true;
2628
2632
  } & PluginSummary<never, never>;
2629
2633
  /**
2630
- * Define a property leaf. Either a static `value` or a computed `get` (eager,
2631
- * dependencies first, like `setup`). `createSdk`, a dependent's `imports`, or
2632
- * an aggregate's re-export binds it under its bare `name` and yields the value.
2634
+ * Define a property leaf. Either a static `value` or a computed `get`, which
2635
+ * re-runs live on each read; an optional `setup` runs once at `createSdk`
2636
+ * (dependencies first, like a method's `setup`) to build the state `get` reads.
2637
+ * `createSdk`, a dependent's `imports`, or an aggregate's re-export binds it
2638
+ * under its bare `name` and yields the value.
2633
2639
  */
2634
2640
  declare function defineProperty<const TName extends string, TValue, const TNamespace extends string = "">(config: {
2635
2641
  name: TName;
@@ -2651,6 +2657,13 @@ declare function defineProperty<const TName extends string, TValue, const TImpor
2651
2657
  get: (bag: {
2652
2658
  imports: ImportsOf<TImports>;
2653
2659
  state: TState;
2660
+ /** The live per-call context when the property is read from a method's
2661
+ * `imports` bag — every method call has one, at any depth. Undefined only
2662
+ * where no call is in flight: the property bound onto the SDK object
2663
+ * itself, and reads from a `setup`-time imports bag. A context-aware
2664
+ * property reads its `callId` off this; because its value is then specific
2665
+ * to the reading call, callers must not cache it across calls. */
2666
+ callContext?: CallContext;
2654
2667
  }) => TValue;
2655
2668
  /** Templated registry members for this property's dynamic sub-surface (e.g.
2656
2669
  * a proxy): each a bodyless declaration keyed by `path` instead of `name`. */
package/dist/index.mjs CHANGED
@@ -2382,8 +2382,9 @@ function bindValue({
2382
2382
  frameworkOrigin = false
2383
2383
  }) {
2384
2384
  if (entry.pluginType === "property" && entry.getValue) {
2385
+ const getValue = entry.getValue;
2385
2386
  Object.defineProperty(target, key, {
2386
- get: entry.getValue,
2387
+ get: ctx ? () => getValue(ctx) : getValue,
2387
2388
  enumerable: true,
2388
2389
  configurable: true
2389
2390
  });
@@ -2922,9 +2923,14 @@ function buildEagerArtifacts(descriptors, context, states) {
2922
2923
  plugins[id] = {
2923
2924
  pluginType: "property",
2924
2925
  name: descriptor.name,
2925
- getValue: () => get({
2926
- imports: buildImports({ plugins, importBindings }),
2927
- state: states.get(id)
2926
+ getValue: (callContext) => get({
2927
+ imports: buildImports({
2928
+ plugins,
2929
+ importBindings,
2930
+ ctx: callContext
2931
+ }),
2932
+ state: states.get(id),
2933
+ callContext
2928
2934
  }),
2929
2935
  meta: descriptor.meta,
2930
2936
  dynamicMembers: descriptor.dynamicMembers