@zapier/kitcore 0.14.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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @zapier/kitcore
2
2
 
3
+ ## 0.16.0
4
+
5
+ ### Minor Changes
6
+
7
+ - cd0616e: Added an optional `callContext` to the `defineProperty` `get` bag, so a property getter can read the current call's context (e.g. its correlation id) when accessed through a method's `imports`. Every method call supplies one, at any depth; it is absent only where no call is in flight — the property bound onto the SDK object itself, and reads from a `setup`-time `imports` bag. Additive — existing property getters are unaffected.
8
+
9
+ ## 0.15.0
10
+
11
+ ### Minor Changes
12
+
13
+ - f0fe306: Add the API stability ladder: `PluginMeta.stability` (`"stable" | "beta" | "experimental"`) replaces the `experimental` boolean as the authored stability signal. The registry projection normalizes every entry to a concrete `FunctionRegistryEntry.stability`; the `experimental` boolean is deprecated but preserved as an input (`true` normalizes to `"experimental"`) and as a derived read (`stability === "experimental"` — literal by name; the not-stable warning duty lives in `stability` and the runtime notice). New exports: `STABILITY_LEVELS`, `STABILITY_TITLES`, `normalizeStability`, `applyStabilityLabel`, and the `StabilityLevel` type. The method boundary now reports every surface call of a beta / experimental method to `CoreOptions.logStabilityNotice` (default: once-per-process deduped `console.warn`), mirroring the deprecation signal — internal delegation never signals.
14
+
3
15
  ## 0.14.0
4
16
 
5
17
  ### Minor Changes
package/dist/index.cjs CHANGED
@@ -30,7 +30,10 @@ __export(index_exports, {
30
30
  CoreErrorCode: () => CoreErrorCode,
31
31
  CoreSignal: () => CoreSignal,
32
32
  RETRY_HTTP_REQUEST_OPTIONS_ID: () => RETRY_HTTP_REQUEST_OPTIONS_ID,
33
+ STABILITY_LEVELS: () => STABILITY_LEVELS,
34
+ STABILITY_TITLES: () => STABILITY_TITLES,
33
35
  addPlugin: () => addPlugin,
36
+ applyStabilityLabel: () => applyStabilityLabel,
34
37
  attemptHttpRequestPlugin: () => attemptHttpRequestPlugin,
35
38
  authorizeHttpRequestPlugin: () => authorizeHttpRequestPlugin,
36
39
  canonicalInputSchema: () => canonicalInputSchema,
@@ -50,6 +53,7 @@ __export(index_exports, {
50
53
  createPluginStack: () => createPluginStack,
51
54
  createPrefixedCursor: () => createPrefixedCursor,
52
55
  createSdk: () => createSdk,
56
+ createStabilityNoticeLogger: () => createStabilityNoticeLogger,
53
57
  createValidator: () => createValidator,
54
58
  dangerousContextPlugin: () => dangerousContextPlugin,
55
59
  declareDefault: () => declareDefault,
@@ -91,6 +95,7 @@ __export(index_exports, {
91
95
  isPositional: () => isPositional,
92
96
  isTelemetryNested: () => isTelemetryNested,
93
97
  normalizeConnectionPlugin: () => normalizeConnectionPlugin,
98
+ normalizeStability: () => normalizeStability,
94
99
  omitExports: () => omitExports,
95
100
  openEnum: () => openEnum,
96
101
  paginate: () => paginate,
@@ -210,6 +215,28 @@ function openEnum(values, description) {
210
215
  return import_zod.z.union([import_zod.z.enum(values), import_zod.z.string()]).describe(description);
211
216
  }
212
217
 
218
+ // src/utils/stability.ts
219
+ var STABILITY_LEVELS = ["stable", "beta", "experimental"];
220
+ var STABILITY_TITLES = {
221
+ stable: "Stable",
222
+ beta: "Beta",
223
+ experimental: "Experimental"
224
+ };
225
+ function normalizeStability(meta) {
226
+ if (meta.stability !== void 0) {
227
+ return STABILITY_LEVELS.includes(meta.stability) ? meta.stability : "experimental";
228
+ }
229
+ return meta.experimental ? "experimental" : "stable";
230
+ }
231
+ function applyStabilityLabel({
232
+ description,
233
+ stability,
234
+ placement = "suffix"
235
+ }) {
236
+ if (stability === void 0 || stability === "stable") return description;
237
+ return placement === "prefix" ? `[${STABILITY_TITLES[stability]}] ${description}` : `${description} (${stability})`;
238
+ }
239
+
213
240
  // src/registry.ts
214
241
  function resolveCategoryDefinition(ref) {
215
242
  const def = typeof ref === "string" ? { key: ref } : ref;
@@ -254,6 +281,7 @@ function buildRegistry({
254
281
  return typeof rootProperty === "object" && rootProperty !== null;
255
282
  }).map((key) => {
256
283
  const m = meta[key];
284
+ const stability = normalizeStability(m);
257
285
  return {
258
286
  name: key,
259
287
  description: m.description,
@@ -269,7 +297,11 @@ function buildRegistry({
269
297
  ),
270
298
  resolvers: resolvers?.[key],
271
299
  formatter: formatters?.[key],
272
- experimental: m.experimental,
300
+ stability,
301
+ // Deprecated derived read, literal by name: only the experimental
302
+ // tier reads true. Beta reads false — the "not stable" warning duty
303
+ // lives in `stability` and the runtime notice, not this boolean.
304
+ experimental: stability === "experimental",
273
305
  packages: m.packages,
274
306
  confirm: m.confirm ?? (m.type === "delete" ? "delete" : void 0),
275
307
  deprecation: m.deprecation,
@@ -358,6 +390,20 @@ function createDeprecationLogger(tag) {
358
390
  };
359
391
  }
360
392
  var { logDeprecation, resetDeprecationWarnings } = createDeprecationLogger("core");
393
+ function createStabilityNoticeLogger(tag) {
394
+ const loggedNotices = /* @__PURE__ */ new Set();
395
+ return {
396
+ logStabilityNotice(message) {
397
+ if (loggedNotices.has(message)) return;
398
+ loggedNotices.add(message);
399
+ console.warn(`[${tag}] ${message}`);
400
+ },
401
+ resetStabilityNotices() {
402
+ loggedNotices.clear();
403
+ }
404
+ };
405
+ }
406
+ var { logStabilityNotice, resetStabilityNotices } = createStabilityNoticeLogger("core");
361
407
 
362
408
  // src/types/errors.ts
363
409
  var CORE_ERROR_SYMBOL = Symbol.for("kitcore.error");
@@ -840,6 +886,19 @@ function defaultLogDeprecation({
840
886
  }) {
841
887
  logDeprecation(`${methodName}() is deprecated. ${deprecation.message}`);
842
888
  }
889
+ var STABILITY_NOTICE_DETAILS = {
890
+ beta: "Its API shape is settled, but it is not yet covered by stable-tier guarantees.",
891
+ experimental: "It may change shape or disappear without notice."
892
+ };
893
+ function defaultLogStabilityNotice({
894
+ methodName,
895
+ stability
896
+ }) {
897
+ if (stability === "stable") return;
898
+ logStabilityNotice(
899
+ `${methodName}() is a ${stability} API. ${STABILITY_NOTICE_DETAILS[stability]}`
900
+ );
901
+ }
843
902
  var CORE_OPTIONS_ID = "kitcore/coreOptions";
844
903
 
845
904
  // src/utils/function-utils.ts
@@ -888,6 +947,18 @@ function signalDeprecation(context, methodName, getDeprecation) {
888
947
  const handler = resolveCoreOptions(context)?.logDeprecation ?? defaultLogDeprecation;
889
948
  runIsolatedObserver(() => handler(warning));
890
949
  }
950
+ function signalStability(context, methodName, getStability) {
951
+ if (isInsideObserver()) return;
952
+ const stability = getStability?.();
953
+ if (!stability || stability === "stable") return;
954
+ const notice = {
955
+ type: "stability",
956
+ methodName,
957
+ stability
958
+ };
959
+ const handler = resolveCoreOptions(context)?.logStabilityNotice ?? defaultLogStabilityNotice;
960
+ runIsolatedObserver(() => handler(notice));
961
+ }
891
962
  function normalizeError(error, adaptError) {
892
963
  if (error instanceof Error) return error;
893
964
  const message = typeof error === "object" && error !== null && "message" in error && typeof error.message === "string" ? error.message : String(error);
@@ -901,7 +972,7 @@ function normalizeError(error, adaptError) {
901
972
  );
902
973
  }
903
974
  function createFunction(coreFn, options) {
904
- const { sdk, schema, name, annotator, getDeprecation } = options;
975
+ const { sdk, schema, name, annotator, getDeprecation, getStability } = options;
905
976
  const functionName = name || coreFn.name;
906
977
  const namedFunctions = {
907
978
  [functionName]: async function(callOptions) {
@@ -909,6 +980,7 @@ function createFunction(coreFn, options) {
909
980
  const context = resolveCallContext(internal);
910
981
  if (!isCallContext(internal) && internal !== INTERNAL_CALL) {
911
982
  signalDeprecation(sdk.context, functionName, getDeprecation);
983
+ signalStability(sdk.context, functionName, getStability);
912
984
  }
913
985
  return runInMethodScope(async () => {
914
986
  const startTime = Date.now();
@@ -975,12 +1047,21 @@ function createFunction(coreFn, options) {
975
1047
  return namedFunctions[functionName];
976
1048
  }
977
1049
  function createRawFunction(coreFn, options) {
978
- const { sdk, name, schema, positional, annotator, getDeprecation } = options;
1050
+ const {
1051
+ sdk,
1052
+ name,
1053
+ schema,
1054
+ positional,
1055
+ annotator,
1056
+ getDeprecation,
1057
+ getStability
1058
+ } = options;
979
1059
  return function(rawInput) {
980
1060
  const internal = arguments[1];
981
1061
  const context = resolveCallContext(internal);
982
1062
  if (!isCallContext(internal) && internal !== INTERNAL_CALL) {
983
1063
  signalDeprecation(sdk.context, name, getDeprecation);
1064
+ signalStability(sdk.context, name, getStability);
984
1065
  }
985
1066
  return runInMethodScope(() => {
986
1067
  const startTime = Date.now();
@@ -1086,7 +1167,8 @@ function createPaginatedFunction(coreFn, options) {
1086
1167
  adaptPage,
1087
1168
  annotator,
1088
1169
  finalizePage,
1089
- getDeprecation
1170
+ getDeprecation,
1171
+ getStability
1090
1172
  } = options;
1091
1173
  const pageFunction = createPageFunction(coreFn, {
1092
1174
  sdk,
@@ -1100,6 +1182,7 @@ function createPaginatedFunction(coreFn, options) {
1100
1182
  const context = resolveCallContext(internal);
1101
1183
  if (!isCallContext(internal) && internal !== INTERNAL_CALL) {
1102
1184
  signalDeprecation(sdk.context, functionName, getDeprecation);
1185
+ signalStability(sdk.context, functionName, getStability);
1103
1186
  }
1104
1187
  return runInMethodScope(() => {
1105
1188
  const startTime = Date.now();
@@ -1544,6 +1627,7 @@ var LEAF_META_KEYS = [
1544
1627
  "returnType",
1545
1628
  "outputSchema",
1546
1629
  "packages",
1630
+ "stability",
1547
1631
  "experimental",
1548
1632
  "confirm",
1549
1633
  "deprecation",
@@ -2422,8 +2506,9 @@ function bindValue({
2422
2506
  frameworkOrigin = false
2423
2507
  }) {
2424
2508
  if (entry.pluginType === "property" && entry.getValue) {
2509
+ const getValue = entry.getValue;
2425
2510
  Object.defineProperty(target, key, {
2426
- get: entry.getValue,
2511
+ get: ctx ? () => getValue(ctx) : getValue,
2427
2512
  enumerable: true,
2428
2513
  configurable: true
2429
2514
  });
@@ -2811,7 +2896,8 @@ function buildMethodEntries(descriptors, context, states) {
2811
2896
  // (item mode's sibling); dropped paths surface as `[].x` in the page's
2812
2897
  // `meta`, unioned across items.
2813
2898
  finalizePage: (page) => applyListOutputPolicy(page, outputPolicy()),
2814
- getDeprecation: () => entry.meta?.deprecation
2899
+ getDeprecation: () => entry.meta?.deprecation,
2900
+ getStability: () => entry.meta ? normalizeStability(entry.meta) : void 0
2815
2901
  }
2816
2902
  );
2817
2903
  } else if (out.type === "item") {
@@ -2823,7 +2909,8 @@ function buildMethodEntries(descriptors, context, states) {
2823
2909
  schema: descriptor.inputSchema,
2824
2910
  name: descriptor.name,
2825
2911
  annotator: boundAnnotator,
2826
- getDeprecation: () => entry.meta?.deprecation
2912
+ getDeprecation: () => entry.meta?.deprecation,
2913
+ getStability: () => entry.meta ? normalizeStability(entry.meta) : void 0
2827
2914
  }
2828
2915
  );
2829
2916
  } else {
@@ -2837,8 +2924,10 @@ function buildMethodEntries(descriptors, context, states) {
2837
2924
  annotator: boundAnnotator,
2838
2925
  // The boundary reads the deprecation LIVE off the entry, so a
2839
2926
  // deprecation merged after build (defineMethodOverride, addPlugin)
2840
- // fires too.
2841
- getDeprecation: () => entry.meta?.deprecation
2927
+ // fires too. Same for the stability level, normalized from the
2928
+ // entry meta (declared level or legacy `experimental` boolean).
2929
+ getDeprecation: () => entry.meta?.deprecation,
2930
+ getStability: () => entry.meta ? normalizeStability(entry.meta) : void 0
2842
2931
  }
2843
2932
  );
2844
2933
  }
@@ -2958,9 +3047,14 @@ function buildEagerArtifacts(descriptors, context, states) {
2958
3047
  plugins[id] = {
2959
3048
  pluginType: "property",
2960
3049
  name: descriptor.name,
2961
- getValue: () => get({
2962
- imports: buildImports({ plugins, importBindings }),
2963
- state: states.get(id)
3050
+ getValue: (callContext) => get({
3051
+ imports: buildImports({
3052
+ plugins,
3053
+ importBindings,
3054
+ ctx: callContext
3055
+ }),
3056
+ state: states.get(id),
3057
+ callContext
2964
3058
  }),
2965
3059
  meta: descriptor.meta,
2966
3060
  dynamicMembers: descriptor.dynamicMembers
@@ -4899,7 +4993,10 @@ var resolveConnectionPlugin = defineMethod({
4899
4993
  CoreErrorCode,
4900
4994
  CoreSignal,
4901
4995
  RETRY_HTTP_REQUEST_OPTIONS_ID,
4996
+ STABILITY_LEVELS,
4997
+ STABILITY_TITLES,
4902
4998
  addPlugin,
4999
+ applyStabilityLabel,
4903
5000
  attemptHttpRequestPlugin,
4904
5001
  authorizeHttpRequestPlugin,
4905
5002
  canonicalInputSchema,
@@ -4919,6 +5016,7 @@ var resolveConnectionPlugin = defineMethod({
4919
5016
  createPluginStack,
4920
5017
  createPrefixedCursor,
4921
5018
  createSdk,
5019
+ createStabilityNoticeLogger,
4922
5020
  createValidator,
4923
5021
  dangerousContextPlugin,
4924
5022
  declareDefault,
@@ -4960,6 +5058,7 @@ var resolveConnectionPlugin = defineMethod({
4960
5058
  isPositional,
4961
5059
  isTelemetryNested,
4962
5060
  normalizeConnectionPlugin,
5061
+ normalizeStability,
4963
5062
  omitExports,
4964
5063
  openEnum,
4965
5064
  paginate,