@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/dist/index.mjs CHANGED
@@ -89,6 +89,28 @@ function openEnum(values, description) {
89
89
  return z.union([z.enum(values), z.string()]).describe(description);
90
90
  }
91
91
 
92
+ // src/utils/stability.ts
93
+ var STABILITY_LEVELS = ["stable", "beta", "experimental"];
94
+ var STABILITY_TITLES = {
95
+ stable: "Stable",
96
+ beta: "Beta",
97
+ experimental: "Experimental"
98
+ };
99
+ function normalizeStability(meta) {
100
+ if (meta.stability !== void 0) {
101
+ return STABILITY_LEVELS.includes(meta.stability) ? meta.stability : "experimental";
102
+ }
103
+ return meta.experimental ? "experimental" : "stable";
104
+ }
105
+ function applyStabilityLabel({
106
+ description,
107
+ stability,
108
+ placement = "suffix"
109
+ }) {
110
+ if (stability === void 0 || stability === "stable") return description;
111
+ return placement === "prefix" ? `[${STABILITY_TITLES[stability]}] ${description}` : `${description} (${stability})`;
112
+ }
113
+
92
114
  // src/registry.ts
93
115
  function resolveCategoryDefinition(ref) {
94
116
  const def = typeof ref === "string" ? { key: ref } : ref;
@@ -133,6 +155,7 @@ function buildRegistry({
133
155
  return typeof rootProperty === "object" && rootProperty !== null;
134
156
  }).map((key) => {
135
157
  const m = meta[key];
158
+ const stability = normalizeStability(m);
136
159
  return {
137
160
  name: key,
138
161
  description: m.description,
@@ -148,7 +171,11 @@ function buildRegistry({
148
171
  ),
149
172
  resolvers: resolvers?.[key],
150
173
  formatter: formatters?.[key],
151
- experimental: m.experimental,
174
+ stability,
175
+ // Deprecated derived read, literal by name: only the experimental
176
+ // tier reads true. Beta reads false — the "not stable" warning duty
177
+ // lives in `stability` and the runtime notice, not this boolean.
178
+ experimental: stability === "experimental",
152
179
  packages: m.packages,
153
180
  confirm: m.confirm ?? (m.type === "delete" ? "delete" : void 0),
154
181
  deprecation: m.deprecation,
@@ -237,6 +264,20 @@ function createDeprecationLogger(tag) {
237
264
  };
238
265
  }
239
266
  var { logDeprecation, resetDeprecationWarnings } = createDeprecationLogger("core");
267
+ function createStabilityNoticeLogger(tag) {
268
+ const loggedNotices = /* @__PURE__ */ new Set();
269
+ return {
270
+ logStabilityNotice(message) {
271
+ if (loggedNotices.has(message)) return;
272
+ loggedNotices.add(message);
273
+ console.warn(`[${tag}] ${message}`);
274
+ },
275
+ resetStabilityNotices() {
276
+ loggedNotices.clear();
277
+ }
278
+ };
279
+ }
280
+ var { logStabilityNotice, resetStabilityNotices } = createStabilityNoticeLogger("core");
240
281
 
241
282
  // src/types/errors.ts
242
283
  var CORE_ERROR_SYMBOL = Symbol.for("kitcore.error");
@@ -721,6 +762,19 @@ function defaultLogDeprecation({
721
762
  }) {
722
763
  logDeprecation(`${methodName}() is deprecated. ${deprecation.message}`);
723
764
  }
765
+ var STABILITY_NOTICE_DETAILS = {
766
+ beta: "Its API shape is settled, but it is not yet covered by stable-tier guarantees.",
767
+ experimental: "It may change shape or disappear without notice."
768
+ };
769
+ function defaultLogStabilityNotice({
770
+ methodName,
771
+ stability
772
+ }) {
773
+ if (stability === "stable") return;
774
+ logStabilityNotice(
775
+ `${methodName}() is a ${stability} API. ${STABILITY_NOTICE_DETAILS[stability]}`
776
+ );
777
+ }
724
778
  var CORE_OPTIONS_ID = "kitcore/coreOptions";
725
779
 
726
780
  // src/utils/function-utils.ts
@@ -769,6 +823,18 @@ function signalDeprecation(context, methodName, getDeprecation) {
769
823
  const handler = resolveCoreOptions(context)?.logDeprecation ?? defaultLogDeprecation;
770
824
  runIsolatedObserver(() => handler(warning));
771
825
  }
826
+ function signalStability(context, methodName, getStability) {
827
+ if (isInsideObserver()) return;
828
+ const stability = getStability?.();
829
+ if (!stability || stability === "stable") return;
830
+ const notice = {
831
+ type: "stability",
832
+ methodName,
833
+ stability
834
+ };
835
+ const handler = resolveCoreOptions(context)?.logStabilityNotice ?? defaultLogStabilityNotice;
836
+ runIsolatedObserver(() => handler(notice));
837
+ }
772
838
  function normalizeError(error, adaptError) {
773
839
  if (error instanceof Error) return error;
774
840
  const message = typeof error === "object" && error !== null && "message" in error && typeof error.message === "string" ? error.message : String(error);
@@ -782,7 +848,7 @@ function normalizeError(error, adaptError) {
782
848
  );
783
849
  }
784
850
  function createFunction(coreFn, options) {
785
- const { sdk, schema, name, annotator, getDeprecation } = options;
851
+ const { sdk, schema, name, annotator, getDeprecation, getStability } = options;
786
852
  const functionName = name || coreFn.name;
787
853
  const namedFunctions = {
788
854
  [functionName]: async function(callOptions) {
@@ -790,6 +856,7 @@ function createFunction(coreFn, options) {
790
856
  const context = resolveCallContext(internal);
791
857
  if (!isCallContext(internal) && internal !== INTERNAL_CALL) {
792
858
  signalDeprecation(sdk.context, functionName, getDeprecation);
859
+ signalStability(sdk.context, functionName, getStability);
793
860
  }
794
861
  return runInMethodScope(async () => {
795
862
  const startTime = Date.now();
@@ -856,12 +923,21 @@ function createFunction(coreFn, options) {
856
923
  return namedFunctions[functionName];
857
924
  }
858
925
  function createRawFunction(coreFn, options) {
859
- const { sdk, name, schema, positional, annotator, getDeprecation } = options;
926
+ const {
927
+ sdk,
928
+ name,
929
+ schema,
930
+ positional,
931
+ annotator,
932
+ getDeprecation,
933
+ getStability
934
+ } = options;
860
935
  return function(rawInput) {
861
936
  const internal = arguments[1];
862
937
  const context = resolveCallContext(internal);
863
938
  if (!isCallContext(internal) && internal !== INTERNAL_CALL) {
864
939
  signalDeprecation(sdk.context, name, getDeprecation);
940
+ signalStability(sdk.context, name, getStability);
865
941
  }
866
942
  return runInMethodScope(() => {
867
943
  const startTime = Date.now();
@@ -967,7 +1043,8 @@ function createPaginatedFunction(coreFn, options) {
967
1043
  adaptPage,
968
1044
  annotator,
969
1045
  finalizePage,
970
- getDeprecation
1046
+ getDeprecation,
1047
+ getStability
971
1048
  } = options;
972
1049
  const pageFunction = createPageFunction(coreFn, {
973
1050
  sdk,
@@ -981,6 +1058,7 @@ function createPaginatedFunction(coreFn, options) {
981
1058
  const context = resolveCallContext(internal);
982
1059
  if (!isCallContext(internal) && internal !== INTERNAL_CALL) {
983
1060
  signalDeprecation(sdk.context, functionName, getDeprecation);
1061
+ signalStability(sdk.context, functionName, getStability);
984
1062
  }
985
1063
  return runInMethodScope(() => {
986
1064
  const startTime = Date.now();
@@ -1425,6 +1503,7 @@ var LEAF_META_KEYS = [
1425
1503
  "returnType",
1426
1504
  "outputSchema",
1427
1505
  "packages",
1506
+ "stability",
1428
1507
  "experimental",
1429
1508
  "confirm",
1430
1509
  "deprecation",
@@ -2303,8 +2382,9 @@ function bindValue({
2303
2382
  frameworkOrigin = false
2304
2383
  }) {
2305
2384
  if (entry.pluginType === "property" && entry.getValue) {
2385
+ const getValue = entry.getValue;
2306
2386
  Object.defineProperty(target, key, {
2307
- get: entry.getValue,
2387
+ get: ctx ? () => getValue(ctx) : getValue,
2308
2388
  enumerable: true,
2309
2389
  configurable: true
2310
2390
  });
@@ -2692,7 +2772,8 @@ function buildMethodEntries(descriptors, context, states) {
2692
2772
  // (item mode's sibling); dropped paths surface as `[].x` in the page's
2693
2773
  // `meta`, unioned across items.
2694
2774
  finalizePage: (page) => applyListOutputPolicy(page, outputPolicy()),
2695
- getDeprecation: () => entry.meta?.deprecation
2775
+ getDeprecation: () => entry.meta?.deprecation,
2776
+ getStability: () => entry.meta ? normalizeStability(entry.meta) : void 0
2696
2777
  }
2697
2778
  );
2698
2779
  } else if (out.type === "item") {
@@ -2704,7 +2785,8 @@ function buildMethodEntries(descriptors, context, states) {
2704
2785
  schema: descriptor.inputSchema,
2705
2786
  name: descriptor.name,
2706
2787
  annotator: boundAnnotator,
2707
- getDeprecation: () => entry.meta?.deprecation
2788
+ getDeprecation: () => entry.meta?.deprecation,
2789
+ getStability: () => entry.meta ? normalizeStability(entry.meta) : void 0
2708
2790
  }
2709
2791
  );
2710
2792
  } else {
@@ -2718,8 +2800,10 @@ function buildMethodEntries(descriptors, context, states) {
2718
2800
  annotator: boundAnnotator,
2719
2801
  // The boundary reads the deprecation LIVE off the entry, so a
2720
2802
  // deprecation merged after build (defineMethodOverride, addPlugin)
2721
- // fires too.
2722
- getDeprecation: () => entry.meta?.deprecation
2803
+ // fires too. Same for the stability level, normalized from the
2804
+ // entry meta (declared level or legacy `experimental` boolean).
2805
+ getDeprecation: () => entry.meta?.deprecation,
2806
+ getStability: () => entry.meta ? normalizeStability(entry.meta) : void 0
2723
2807
  }
2724
2808
  );
2725
2809
  }
@@ -2839,9 +2923,14 @@ function buildEagerArtifacts(descriptors, context, states) {
2839
2923
  plugins[id] = {
2840
2924
  pluginType: "property",
2841
2925
  name: descriptor.name,
2842
- getValue: () => get({
2843
- imports: buildImports({ plugins, importBindings }),
2844
- 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
2845
2934
  }),
2846
2935
  meta: descriptor.meta,
2847
2936
  dynamicMembers: descriptor.dynamicMembers
@@ -4779,7 +4868,10 @@ export {
4779
4868
  CoreErrorCode,
4780
4869
  CoreSignal,
4781
4870
  RETRY_HTTP_REQUEST_OPTIONS_ID,
4871
+ STABILITY_LEVELS,
4872
+ STABILITY_TITLES,
4782
4873
  addPlugin,
4874
+ applyStabilityLabel,
4783
4875
  attemptHttpRequestPlugin,
4784
4876
  authorizeHttpRequestPlugin,
4785
4877
  canonicalInputSchema,
@@ -4799,6 +4891,7 @@ export {
4799
4891
  createPluginStack,
4800
4892
  createPrefixedCursor,
4801
4893
  createSdk,
4894
+ createStabilityNoticeLogger,
4802
4895
  createValidator,
4803
4896
  dangerousContextPlugin,
4804
4897
  declareDefault,
@@ -4840,6 +4933,7 @@ export {
4840
4933
  isPositional,
4841
4934
  isTelemetryNested,
4842
4935
  normalizeConnectionPlugin,
4936
+ normalizeStability,
4843
4937
  omitExports,
4844
4938
  openEnum,
4845
4939
  paginate,