@zapier/zapier-sdk 0.97.0 → 0.98.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.
@@ -68,6 +68,13 @@ function getNegatable(schema) {
68
68
  function openEnum(values, description) {
69
69
  return zod.z.union([zod.z.enum(values), zod.z.string()]).describe(description);
70
70
  }
71
+ var STABILITY_LEVELS = ["stable", "beta", "experimental"];
72
+ function normalizeStability(meta) {
73
+ if (meta.stability !== void 0) {
74
+ return STABILITY_LEVELS.includes(meta.stability) ? meta.stability : "experimental";
75
+ }
76
+ return meta.experimental ? "experimental" : "stable";
77
+ }
71
78
  function resolveCategoryDefinition(ref) {
72
79
  const def = typeof ref === "string" ? { key: ref } : ref;
73
80
  const title = def.title ?? toTitleCase(def.key);
@@ -111,6 +118,7 @@ function buildRegistry({
111
118
  return typeof rootProperty === "object" && rootProperty !== null;
112
119
  }).map((key) => {
113
120
  const m = meta[key];
121
+ const stability = normalizeStability(m);
114
122
  return {
115
123
  name: key,
116
124
  description: m.description,
@@ -126,7 +134,11 @@ function buildRegistry({
126
134
  ),
127
135
  resolvers: resolvers?.[key],
128
136
  formatter: formatters?.[key],
129
- experimental: m.experimental,
137
+ stability,
138
+ // Deprecated derived read, literal by name: only the experimental
139
+ // tier reads true. Beta reads false — the "not stable" warning duty
140
+ // lives in `stability` and the runtime notice, not this boolean.
141
+ experimental: stability === "experimental",
130
142
  packages: m.packages,
131
143
  confirm: m.confirm ?? (m.type === "delete" ? "delete" : void 0),
132
144
  deprecation: m.deprecation,
@@ -211,6 +223,20 @@ function createDeprecationLogger(tag) {
211
223
  };
212
224
  }
213
225
  var { logDeprecation} = createDeprecationLogger("core");
226
+ function createStabilityNoticeLogger(tag) {
227
+ const loggedNotices = /* @__PURE__ */ new Set();
228
+ return {
229
+ logStabilityNotice(message) {
230
+ if (loggedNotices.has(message)) return;
231
+ loggedNotices.add(message);
232
+ console.warn(`[${tag}] ${message}`);
233
+ },
234
+ resetStabilityNotices() {
235
+ loggedNotices.clear();
236
+ }
237
+ };
238
+ }
239
+ var { logStabilityNotice} = createStabilityNoticeLogger("core");
214
240
  var CORE_ERROR_SYMBOL = Symbol.for("kitcore.error");
215
241
  var CoreErrorCode = {
216
242
  Validation: "VALIDATION_ERROR",
@@ -622,6 +648,19 @@ function defaultLogDeprecation({
622
648
  }) {
623
649
  logDeprecation(`${methodName}() is deprecated. ${deprecation.message}`);
624
650
  }
651
+ var STABILITY_NOTICE_DETAILS = {
652
+ beta: "Its API shape is settled, but it is not yet covered by stable-tier guarantees.",
653
+ experimental: "It may change shape or disappear without notice."
654
+ };
655
+ function defaultLogStabilityNotice({
656
+ methodName,
657
+ stability
658
+ }) {
659
+ if (stability === "stable") return;
660
+ logStabilityNotice(
661
+ `${methodName}() is a ${stability} API. ${STABILITY_NOTICE_DETAILS[stability]}`
662
+ );
663
+ }
625
664
  var CORE_OPTIONS_ID = "kitcore/coreOptions";
626
665
  function resolveCoreOptions(context) {
627
666
  const entry = context.plugins?.[CORE_OPTIONS_ID];
@@ -668,6 +707,18 @@ function signalDeprecation(context, methodName, getDeprecation) {
668
707
  const handler = resolveCoreOptions(context)?.logDeprecation ?? defaultLogDeprecation;
669
708
  runIsolatedObserver(() => handler(warning));
670
709
  }
710
+ function signalStability(context, methodName, getStability) {
711
+ if (isInsideObserver()) return;
712
+ const stability = getStability?.();
713
+ if (!stability || stability === "stable") return;
714
+ const notice = {
715
+ type: "stability",
716
+ methodName,
717
+ stability
718
+ };
719
+ const handler = resolveCoreOptions(context)?.logStabilityNotice ?? defaultLogStabilityNotice;
720
+ runIsolatedObserver(() => handler(notice));
721
+ }
671
722
  function normalizeError(error, adaptError) {
672
723
  if (error instanceof Error) return error;
673
724
  const message = typeof error === "object" && error !== null && "message" in error && typeof error.message === "string" ? error.message : String(error);
@@ -681,7 +732,7 @@ function normalizeError(error, adaptError) {
681
732
  );
682
733
  }
683
734
  function createFunction(coreFn, options) {
684
- const { sdk, schema, name, annotator, getDeprecation } = options;
735
+ const { sdk, schema, name, annotator, getDeprecation, getStability } = options;
685
736
  const functionName = name || coreFn.name;
686
737
  const namedFunctions = {
687
738
  [functionName]: async function(callOptions) {
@@ -689,6 +740,7 @@ function createFunction(coreFn, options) {
689
740
  const context = resolveCallContext(internal);
690
741
  if (!isCallContext(internal) && internal !== INTERNAL_CALL) {
691
742
  signalDeprecation(sdk.context, functionName, getDeprecation);
743
+ signalStability(sdk.context, functionName, getStability);
692
744
  }
693
745
  return runInMethodScope(async () => {
694
746
  const startTime = Date.now();
@@ -755,12 +807,21 @@ function createFunction(coreFn, options) {
755
807
  return namedFunctions[functionName];
756
808
  }
757
809
  function createRawFunction(coreFn, options) {
758
- const { sdk, name, schema, positional, annotator, getDeprecation } = options;
810
+ const {
811
+ sdk,
812
+ name,
813
+ schema,
814
+ positional,
815
+ annotator,
816
+ getDeprecation,
817
+ getStability
818
+ } = options;
759
819
  return function(rawInput) {
760
820
  const internal = arguments[1];
761
821
  const context = resolveCallContext(internal);
762
822
  if (!isCallContext(internal) && internal !== INTERNAL_CALL) {
763
823
  signalDeprecation(sdk.context, name, getDeprecation);
824
+ signalStability(sdk.context, name, getStability);
764
825
  }
765
826
  return runInMethodScope(() => {
766
827
  const startTime = Date.now();
@@ -866,7 +927,8 @@ function createPaginatedFunction(coreFn, options) {
866
927
  adaptPage,
867
928
  annotator,
868
929
  finalizePage,
869
- getDeprecation
930
+ getDeprecation,
931
+ getStability
870
932
  } = options;
871
933
  const pageFunction = createPageFunction(coreFn, {
872
934
  sdk,
@@ -880,6 +942,7 @@ function createPaginatedFunction(coreFn, options) {
880
942
  const context = resolveCallContext(internal);
881
943
  if (!isCallContext(internal) && internal !== INTERNAL_CALL) {
882
944
  signalDeprecation(sdk.context, functionName, getDeprecation);
945
+ signalStability(sdk.context, functionName, getStability);
883
946
  }
884
947
  return runInMethodScope(() => {
885
948
  const startTime = Date.now();
@@ -1318,6 +1381,7 @@ var LEAF_META_KEYS = [
1318
1381
  "returnType",
1319
1382
  "outputSchema",
1320
1383
  "packages",
1384
+ "stability",
1321
1385
  "experimental",
1322
1386
  "confirm",
1323
1387
  "deprecation",
@@ -2543,7 +2607,8 @@ function buildMethodEntries(descriptors, context, states) {
2543
2607
  // (item mode's sibling); dropped paths surface as `[].x` in the page's
2544
2608
  // `meta`, unioned across items.
2545
2609
  finalizePage: (page) => applyListOutputPolicy(page, outputPolicy()),
2546
- getDeprecation: () => entry.meta?.deprecation
2610
+ getDeprecation: () => entry.meta?.deprecation,
2611
+ getStability: () => entry.meta ? normalizeStability(entry.meta) : void 0
2547
2612
  }
2548
2613
  );
2549
2614
  } else if (out.type === "item") {
@@ -2555,7 +2620,8 @@ function buildMethodEntries(descriptors, context, states) {
2555
2620
  schema: descriptor.inputSchema,
2556
2621
  name: descriptor.name,
2557
2622
  annotator: boundAnnotator,
2558
- getDeprecation: () => entry.meta?.deprecation
2623
+ getDeprecation: () => entry.meta?.deprecation,
2624
+ getStability: () => entry.meta ? normalizeStability(entry.meta) : void 0
2559
2625
  }
2560
2626
  );
2561
2627
  } else {
@@ -2569,8 +2635,10 @@ function buildMethodEntries(descriptors, context, states) {
2569
2635
  annotator: boundAnnotator,
2570
2636
  // The boundary reads the deprecation LIVE off the entry, so a
2571
2637
  // deprecation merged after build (defineMethodOverride, addPlugin)
2572
- // fires too.
2573
- getDeprecation: () => entry.meta?.deprecation
2638
+ // fires too. Same for the stability level, normalized from the
2639
+ // entry meta (declared level or legacy `experimental` boolean).
2640
+ getDeprecation: () => entry.meta?.deprecation,
2641
+ getStability: () => entry.meta ? normalizeStability(entry.meta) : void 0
2574
2642
  }
2575
2643
  );
2576
2644
  }
@@ -6514,7 +6582,7 @@ function parseDeprecationDate(value) {
6514
6582
  }
6515
6583
 
6516
6584
  // src/sdk-version.ts
6517
- var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.97.0" : void 0) || "unknown";
6585
+ var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.98.0" : void 0) || "unknown";
6518
6586
 
6519
6587
  // src/utils/open-url.ts
6520
6588
  var nodePrefix = "node:";
@@ -6911,11 +6979,16 @@ var ZapierApiClient = class {
6911
6979
  if (!approvalContext) {
6912
6980
  return { response };
6913
6981
  }
6982
+ const askStatementIdsHeader = response.headers.get(
6983
+ "x-zapier-ask-statement-ids"
6984
+ );
6985
+ const askStatementIds = askStatementIdsHeader ? JSON.parse(askStatementIdsHeader) : void 0;
6914
6986
  try {
6915
6987
  await this.runOneApprovalRound(
6916
6988
  approvalContext,
6917
6989
  approvalMode,
6918
- init?.signal ?? void 0
6990
+ init?.signal ?? void 0,
6991
+ askStatementIds
6919
6992
  );
6920
6993
  } catch (error) {
6921
6994
  return { response, approvalRoundError: error };
@@ -7518,7 +7591,7 @@ var ZapierApiClient = class {
7518
7591
  * Caller is responsible for passing a non-"disabled" mode; this method
7519
7592
  * unconditionally creates an approval.
7520
7593
  */
7521
- async runOneApprovalRound(buildContext, mode, signal) {
7594
+ async runOneApprovalRound(buildContext, mode, signal, askStatementIds) {
7522
7595
  const context = buildContext();
7523
7596
  let approvalResponse;
7524
7597
  try {
@@ -7528,7 +7601,10 @@ var ZapierApiClient = class {
7528
7601
  "Content-Type": "application/json",
7529
7602
  Accept: "application/json"
7530
7603
  },
7531
- body: JSON.stringify({ context }),
7604
+ body: JSON.stringify({
7605
+ context,
7606
+ ...askStatementIds?.length ? { ask_statement_ids: askStatementIds } : {}
7607
+ }),
7532
7608
  signal
7533
7609
  });
7534
7610
  } catch (err) {
@@ -11856,14 +11932,24 @@ var ListConnectionsQuerySchema = connections.ListConnectionsQuerySchema.omit({
11856
11932
  includeShared: zod.z.boolean().optional().describe(
11857
11933
  "Include connections shared with you. By default, only your own connections are returned (owner=me). Set to true to also include shared connections."
11858
11934
  ),
11859
- /** @deprecated Use `expired` instead */
11935
+ // Filters on connection expiry. Not a mirror of a server-side status
11936
+ // field: the API expresses this as the is_expired filter, which we send as
11937
+ // false for "active", true for "expired", and omit for "all".
11938
+ status: zod.z.enum(["active", "expired", "all"]).optional().describe(
11939
+ "Filter connections by expiry: 'active' (default) returns only non-expired connections, 'expired' only expired ones, and 'all' returns both."
11940
+ ),
11941
+ /** @deprecated Use `status` instead */
11860
11942
  isExpired: zod.z.boolean().optional().describe("Filter by expired status").meta({
11861
11943
  deprecated: true,
11862
- deprecationMessage: "Use --expired instead to show only expired connections."
11944
+ deprecationMessage: "Use --status expired instead to show only expired connections, or --status all for both."
11863
11945
  }),
11946
+ /** @deprecated Use `status` instead */
11864
11947
  expired: zod.z.boolean().optional().describe(
11865
11948
  "Show only expired connections (default: only non-expired connections are returned)"
11866
- ),
11949
+ ).meta({
11950
+ deprecated: true,
11951
+ deprecationMessage: "Use --status expired instead to show only expired connections, or --status all for both."
11952
+ }),
11867
11953
  // Override pageSize to make optional
11868
11954
  pageSize: zod.z.number().min(1).optional().describe("Number of connections per page"),
11869
11955
  // SDK specific property for pagination/iterable helpers
@@ -11989,10 +12075,15 @@ var listConnectionsPlugin = defineMethod({
11989
12075
  if (owner) {
11990
12076
  searchParams.owner = owner;
11991
12077
  }
11992
- if (input.isExpired !== void 0) {
11993
- searchParams.is_expired = input.isExpired.toString();
11994
- } else {
11995
- searchParams.is_expired = (input.expired ?? false).toString();
12078
+ const expiredFilter = input.isExpired ?? input.expired;
12079
+ if (input.status !== void 0 && expiredFilter !== void 0) {
12080
+ throw new ZapierValidationError(
12081
+ 'The "status" option replaces "expired" and "isExpired", so it cannot be combined with either.'
12082
+ );
12083
+ }
12084
+ const status = input.status ?? (expiredFilter ? "expired" : "active");
12085
+ if (status !== "all") {
12086
+ searchParams.is_expired = (status === "expired").toString();
11996
12087
  }
11997
12088
  if (input.cursor) {
11998
12089
  searchParams.offset = input.cursor;