@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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @zapier/zapier-sdk
2
2
 
3
+ ## 0.98.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 9a5ae37: Added `status` to `listConnections`, `findFirstConnection`, and `findUniqueConnection` to filter connections by expiry: `active` (the default, and the existing behaviour), `expired`, or `all` for both. Previously only non-expired connections were returned by default and `expired: true` returned only expired ones, so a single call could never cover both. `expired` and `isExpired` are now deprecated in favour of `status` and still work; combining `status` with either throws a validation error.
8
+
9
+ ## 0.97.1
10
+
11
+ ### Patch Changes
12
+
13
+ - e45f03b: _This release contains no user-facing changes._
14
+
3
15
  ## 0.97.0
4
16
 
5
17
  ### Minor Changes
package/README.md CHANGED
@@ -2254,16 +2254,16 @@ Find the first connection matching the criteria
2254
2254
 
2255
2255
  **Parameters:**
2256
2256
 
2257
- | Name | Type | Required | Default | Possible Values | Description |
2258
- | ------------------- | --------- | -------- | ------- | --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
2259
- | `options` | `object` | ✅ | — | — | |
2260
- | ​ ↳ `search` | `string` | ❌ | — | — | Search term to filter connections by title |
2261
- | ​ ↳ `title` | `string` | ❌ | — | — | Filter connections by exact title match (searches first, then filters locally) |
2262
- | ​ ↳ `owner` | `string` | ❌ | — | — | Filter by owner, 'me' for your own connections or a specific user ID |
2263
- | ​ ↳ `app` | `string` | ❌ | — | — | App key of connections to list (e.g., 'SlackCLIAPI' or slug like 'github') |
2264
- | ​ ↳ `account` | `string` | ❌ | — | — | Account to filter by |
2265
- | ​ ↳ `includeShared` | `boolean` | ❌ | — | — | Include connections shared with you. By default, only your own connections are returned (owner=me). Set to true to also include shared connections. |
2266
- | ​ ↳ `expired` | `boolean` | ❌ | — | — | Show only expired connections (default: only non-expired connections are returned) |
2257
+ | Name | Type | Required | Default | Possible Values | Description |
2258
+ | ------------------- | --------- | -------- | ------- | -------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
2259
+ | `options` | `object` | ✅ | — | — | |
2260
+ | ​ ↳ `search` | `string` | ❌ | — | — | Search term to filter connections by title |
2261
+ | ​ ↳ `title` | `string` | ❌ | — | — | Filter connections by exact title match (searches first, then filters locally) |
2262
+ | ​ ↳ `owner` | `string` | ❌ | — | — | Filter by owner, 'me' for your own connections or a specific user ID |
2263
+ | ​ ↳ `app` | `string` | ❌ | — | — | App key of connections to list (e.g., 'SlackCLIAPI' or slug like 'github') |
2264
+ | ​ ↳ `account` | `string` | ❌ | — | — | Account to filter by |
2265
+ | ​ ↳ `includeShared` | `boolean` | ❌ | — | — | Include connections shared with you. By default, only your own connections are returned (owner=me). Set to true to also include shared connections. |
2266
+ | ​ ↳ `status` | `string` | ❌ | — | `active`, `expired`, `all` | Filter connections by expiry: 'active' (default) returns only non-expired connections, 'expired' only expired ones, and 'all' returns both. |
2267
2267
 
2268
2268
  **Returns:** `Promise<ConnectionItem>`
2269
2269
 
@@ -2311,16 +2311,16 @@ Find a unique connection matching the criteria
2311
2311
 
2312
2312
  **Parameters:**
2313
2313
 
2314
- | Name | Type | Required | Default | Possible Values | Description |
2315
- | ------------------- | --------- | -------- | ------- | --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
2316
- | `options` | `object` | ✅ | — | — | |
2317
- | ​ ↳ `search` | `string` | ❌ | — | — | Search term to filter connections by title |
2318
- | ​ ↳ `title` | `string` | ❌ | — | — | Filter connections by exact title match (searches first, then filters locally) |
2319
- | ​ ↳ `owner` | `string` | ❌ | — | — | Filter by owner, 'me' for your own connections or a specific user ID |
2320
- | ​ ↳ `app` | `string` | ❌ | — | — | App key of connections to list (e.g., 'SlackCLIAPI' or slug like 'github') |
2321
- | ​ ↳ `account` | `string` | ❌ | — | — | Account to filter by |
2322
- | ​ ↳ `includeShared` | `boolean` | ❌ | — | — | Include connections shared with you. By default, only your own connections are returned (owner=me). Set to true to also include shared connections. |
2323
- | ​ ↳ `expired` | `boolean` | ❌ | — | — | Show only expired connections (default: only non-expired connections are returned) |
2314
+ | Name | Type | Required | Default | Possible Values | Description |
2315
+ | ------------------- | --------- | -------- | ------- | -------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
2316
+ | `options` | `object` | ✅ | — | — | |
2317
+ | ​ ↳ `search` | `string` | ❌ | — | — | Search term to filter connections by title |
2318
+ | ​ ↳ `title` | `string` | ❌ | — | — | Filter connections by exact title match (searches first, then filters locally) |
2319
+ | ​ ↳ `owner` | `string` | ❌ | — | — | Filter by owner, 'me' for your own connections or a specific user ID |
2320
+ | ​ ↳ `app` | `string` | ❌ | — | — | App key of connections to list (e.g., 'SlackCLIAPI' or slug like 'github') |
2321
+ | ​ ↳ `account` | `string` | ❌ | — | — | Account to filter by |
2322
+ | ​ ↳ `includeShared` | `boolean` | ❌ | — | — | Include connections shared with you. By default, only your own connections are returned (owner=me). Set to true to also include shared connections. |
2323
+ | ​ ↳ `status` | `string` | ❌ | — | `active`, `expired`, `all` | Filter connections by expiry: 'active' (default) returns only non-expired connections, 'expired' only expired ones, and 'all' returns both. |
2324
2324
 
2325
2325
  **Returns:** `Promise<ConnectionItem>`
2326
2326
 
@@ -2462,20 +2462,20 @@ List available connections with optional filtering
2462
2462
 
2463
2463
  **Parameters:**
2464
2464
 
2465
- | Name | Type | Required | Default | Possible Values | Description |
2466
- | ------------------- | --------- | -------- | ------- | --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
2467
- | `options` | `object` | ✅ | — | — | |
2468
- | ​ ↳ `search` | `string` | ❌ | — | — | Search term to filter connections by title |
2469
- | ​ ↳ `title` | `string` | ❌ | — | — | Filter connections by exact title match (searches first, then filters locally) |
2470
- | ​ ↳ `owner` | `string` | ❌ | — | — | Filter by owner, 'me' for your own connections or a specific user ID |
2471
- | ​ ↳ `app` | `string` | ❌ | — | — | App key of connections to list (e.g., 'SlackCLIAPI' or slug like 'github') |
2472
- | ​ ↳ `connections` | `array` | ❌ | — | — | List of connection IDs to filter by |
2473
- | ​ ↳ `account` | `string` | ❌ | — | — | Account to filter by |
2474
- | ​ ↳ `includeShared` | `boolean` | ❌ | — | — | Include connections shared with you. By default, only your own connections are returned (owner=me). Set to true to also include shared connections. |
2475
- | ​ ↳ `expired` | `boolean` | ❌ | — | — | Show only expired connections (default: only non-expired connections are returned) |
2476
- | ​ ↳ `pageSize` | `number` | ❌ | — | — | Number of connections per page |
2477
- | ​ ↳ `maxItems` | `number` | ❌ | — | — | Maximum total items to return across all pages |
2478
- | ​ ↳ `cursor` | `string` | ❌ | — | — | Cursor to start from |
2465
+ | Name | Type | Required | Default | Possible Values | Description |
2466
+ | ------------------- | --------- | -------- | ------- | -------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
2467
+ | `options` | `object` | ✅ | — | — | |
2468
+ | ​ ↳ `search` | `string` | ❌ | — | — | Search term to filter connections by title |
2469
+ | ​ ↳ `title` | `string` | ❌ | — | — | Filter connections by exact title match (searches first, then filters locally) |
2470
+ | ​ ↳ `owner` | `string` | ❌ | — | — | Filter by owner, 'me' for your own connections or a specific user ID |
2471
+ | ​ ↳ `app` | `string` | ❌ | — | — | App key of connections to list (e.g., 'SlackCLIAPI' or slug like 'github') |
2472
+ | ​ ↳ `connections` | `array` | ❌ | — | — | List of connection IDs to filter by |
2473
+ | ​ ↳ `account` | `string` | ❌ | — | — | Account to filter by |
2474
+ | ​ ↳ `includeShared` | `boolean` | ❌ | — | — | Include connections shared with you. By default, only your own connections are returned (owner=me). Set to true to also include shared connections. |
2475
+ | ​ ↳ `status` | `string` | ❌ | — | `active`, `expired`, `all` | Filter connections by expiry: 'active' (default) returns only non-expired connections, 'expired' only expired ones, and 'all' returns both. |
2476
+ | ​ ↳ `pageSize` | `number` | ❌ | — | — | Number of connections per page |
2477
+ | ​ ↳ `maxItems` | `number` | ❌ | — | — | Maximum total items to return across all pages |
2478
+ | ​ ↳ `cursor` | `string` | ❌ | — | — | Cursor to start from |
2479
2479
 
2480
2480
  **Returns:** `Promise<PaginatedResult<ConnectionItem>>`
2481
2481
 
@@ -66,6 +66,13 @@ function getNegatable(schema) {
66
66
  function openEnum(values, description) {
67
67
  return z.union([z.enum(values), z.string()]).describe(description);
68
68
  }
69
+ var STABILITY_LEVELS = ["stable", "beta", "experimental"];
70
+ function normalizeStability(meta) {
71
+ if (meta.stability !== void 0) {
72
+ return STABILITY_LEVELS.includes(meta.stability) ? meta.stability : "experimental";
73
+ }
74
+ return meta.experimental ? "experimental" : "stable";
75
+ }
69
76
  function resolveCategoryDefinition(ref) {
70
77
  const def = typeof ref === "string" ? { key: ref } : ref;
71
78
  const title = def.title ?? toTitleCase(def.key);
@@ -109,6 +116,7 @@ function buildRegistry({
109
116
  return typeof rootProperty === "object" && rootProperty !== null;
110
117
  }).map((key) => {
111
118
  const m = meta[key];
119
+ const stability = normalizeStability(m);
112
120
  return {
113
121
  name: key,
114
122
  description: m.description,
@@ -124,7 +132,11 @@ function buildRegistry({
124
132
  ),
125
133
  resolvers: resolvers?.[key],
126
134
  formatter: formatters?.[key],
127
- experimental: m.experimental,
135
+ stability,
136
+ // Deprecated derived read, literal by name: only the experimental
137
+ // tier reads true. Beta reads false — the "not stable" warning duty
138
+ // lives in `stability` and the runtime notice, not this boolean.
139
+ experimental: stability === "experimental",
128
140
  packages: m.packages,
129
141
  confirm: m.confirm ?? (m.type === "delete" ? "delete" : void 0),
130
142
  deprecation: m.deprecation,
@@ -209,6 +221,20 @@ function createDeprecationLogger(tag) {
209
221
  };
210
222
  }
211
223
  var { logDeprecation} = createDeprecationLogger("core");
224
+ function createStabilityNoticeLogger(tag) {
225
+ const loggedNotices = /* @__PURE__ */ new Set();
226
+ return {
227
+ logStabilityNotice(message) {
228
+ if (loggedNotices.has(message)) return;
229
+ loggedNotices.add(message);
230
+ console.warn(`[${tag}] ${message}`);
231
+ },
232
+ resetStabilityNotices() {
233
+ loggedNotices.clear();
234
+ }
235
+ };
236
+ }
237
+ var { logStabilityNotice} = createStabilityNoticeLogger("core");
212
238
  var CORE_ERROR_SYMBOL = Symbol.for("kitcore.error");
213
239
  var CoreErrorCode = {
214
240
  Validation: "VALIDATION_ERROR",
@@ -620,6 +646,19 @@ function defaultLogDeprecation({
620
646
  }) {
621
647
  logDeprecation(`${methodName}() is deprecated. ${deprecation.message}`);
622
648
  }
649
+ var STABILITY_NOTICE_DETAILS = {
650
+ beta: "Its API shape is settled, but it is not yet covered by stable-tier guarantees.",
651
+ experimental: "It may change shape or disappear without notice."
652
+ };
653
+ function defaultLogStabilityNotice({
654
+ methodName,
655
+ stability
656
+ }) {
657
+ if (stability === "stable") return;
658
+ logStabilityNotice(
659
+ `${methodName}() is a ${stability} API. ${STABILITY_NOTICE_DETAILS[stability]}`
660
+ );
661
+ }
623
662
  var CORE_OPTIONS_ID = "kitcore/coreOptions";
624
663
  function resolveCoreOptions(context) {
625
664
  const entry = context.plugins?.[CORE_OPTIONS_ID];
@@ -666,6 +705,18 @@ function signalDeprecation(context, methodName, getDeprecation) {
666
705
  const handler = resolveCoreOptions(context)?.logDeprecation ?? defaultLogDeprecation;
667
706
  runIsolatedObserver(() => handler(warning));
668
707
  }
708
+ function signalStability(context, methodName, getStability) {
709
+ if (isInsideObserver()) return;
710
+ const stability = getStability?.();
711
+ if (!stability || stability === "stable") return;
712
+ const notice = {
713
+ type: "stability",
714
+ methodName,
715
+ stability
716
+ };
717
+ const handler = resolveCoreOptions(context)?.logStabilityNotice ?? defaultLogStabilityNotice;
718
+ runIsolatedObserver(() => handler(notice));
719
+ }
669
720
  function normalizeError(error, adaptError) {
670
721
  if (error instanceof Error) return error;
671
722
  const message = typeof error === "object" && error !== null && "message" in error && typeof error.message === "string" ? error.message : String(error);
@@ -679,7 +730,7 @@ function normalizeError(error, adaptError) {
679
730
  );
680
731
  }
681
732
  function createFunction(coreFn, options) {
682
- const { sdk, schema, name, annotator, getDeprecation } = options;
733
+ const { sdk, schema, name, annotator, getDeprecation, getStability } = options;
683
734
  const functionName = name || coreFn.name;
684
735
  const namedFunctions = {
685
736
  [functionName]: async function(callOptions) {
@@ -687,6 +738,7 @@ function createFunction(coreFn, options) {
687
738
  const context = resolveCallContext(internal);
688
739
  if (!isCallContext(internal) && internal !== INTERNAL_CALL) {
689
740
  signalDeprecation(sdk.context, functionName, getDeprecation);
741
+ signalStability(sdk.context, functionName, getStability);
690
742
  }
691
743
  return runInMethodScope(async () => {
692
744
  const startTime = Date.now();
@@ -753,12 +805,21 @@ function createFunction(coreFn, options) {
753
805
  return namedFunctions[functionName];
754
806
  }
755
807
  function createRawFunction(coreFn, options) {
756
- const { sdk, name, schema, positional, annotator, getDeprecation } = options;
808
+ const {
809
+ sdk,
810
+ name,
811
+ schema,
812
+ positional,
813
+ annotator,
814
+ getDeprecation,
815
+ getStability
816
+ } = options;
757
817
  return function(rawInput) {
758
818
  const internal = arguments[1];
759
819
  const context = resolveCallContext(internal);
760
820
  if (!isCallContext(internal) && internal !== INTERNAL_CALL) {
761
821
  signalDeprecation(sdk.context, name, getDeprecation);
822
+ signalStability(sdk.context, name, getStability);
762
823
  }
763
824
  return runInMethodScope(() => {
764
825
  const startTime = Date.now();
@@ -864,7 +925,8 @@ function createPaginatedFunction(coreFn, options) {
864
925
  adaptPage,
865
926
  annotator,
866
927
  finalizePage,
867
- getDeprecation
928
+ getDeprecation,
929
+ getStability
868
930
  } = options;
869
931
  const pageFunction = createPageFunction(coreFn, {
870
932
  sdk,
@@ -878,6 +940,7 @@ function createPaginatedFunction(coreFn, options) {
878
940
  const context = resolveCallContext(internal);
879
941
  if (!isCallContext(internal) && internal !== INTERNAL_CALL) {
880
942
  signalDeprecation(sdk.context, functionName, getDeprecation);
943
+ signalStability(sdk.context, functionName, getStability);
881
944
  }
882
945
  return runInMethodScope(() => {
883
946
  const startTime = Date.now();
@@ -1316,6 +1379,7 @@ var LEAF_META_KEYS = [
1316
1379
  "returnType",
1317
1380
  "outputSchema",
1318
1381
  "packages",
1382
+ "stability",
1319
1383
  "experimental",
1320
1384
  "confirm",
1321
1385
  "deprecation",
@@ -2541,7 +2605,8 @@ function buildMethodEntries(descriptors, context, states) {
2541
2605
  // (item mode's sibling); dropped paths surface as `[].x` in the page's
2542
2606
  // `meta`, unioned across items.
2543
2607
  finalizePage: (page) => applyListOutputPolicy(page, outputPolicy()),
2544
- getDeprecation: () => entry.meta?.deprecation
2608
+ getDeprecation: () => entry.meta?.deprecation,
2609
+ getStability: () => entry.meta ? normalizeStability(entry.meta) : void 0
2545
2610
  }
2546
2611
  );
2547
2612
  } else if (out.type === "item") {
@@ -2553,7 +2618,8 @@ function buildMethodEntries(descriptors, context, states) {
2553
2618
  schema: descriptor.inputSchema,
2554
2619
  name: descriptor.name,
2555
2620
  annotator: boundAnnotator,
2556
- getDeprecation: () => entry.meta?.deprecation
2621
+ getDeprecation: () => entry.meta?.deprecation,
2622
+ getStability: () => entry.meta ? normalizeStability(entry.meta) : void 0
2557
2623
  }
2558
2624
  );
2559
2625
  } else {
@@ -2567,8 +2633,10 @@ function buildMethodEntries(descriptors, context, states) {
2567
2633
  annotator: boundAnnotator,
2568
2634
  // The boundary reads the deprecation LIVE off the entry, so a
2569
2635
  // deprecation merged after build (defineMethodOverride, addPlugin)
2570
- // fires too.
2571
- getDeprecation: () => entry.meta?.deprecation
2636
+ // fires too. Same for the stability level, normalized from the
2637
+ // entry meta (declared level or legacy `experimental` boolean).
2638
+ getDeprecation: () => entry.meta?.deprecation,
2639
+ getStability: () => entry.meta ? normalizeStability(entry.meta) : void 0
2572
2640
  }
2573
2641
  );
2574
2642
  }
@@ -6512,7 +6580,7 @@ function parseDeprecationDate(value) {
6512
6580
  }
6513
6581
 
6514
6582
  // src/sdk-version.ts
6515
- var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.97.0" : void 0) || "unknown";
6583
+ var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.98.0" : void 0) || "unknown";
6516
6584
 
6517
6585
  // src/utils/open-url.ts
6518
6586
  var nodePrefix = "node:";
@@ -6909,11 +6977,16 @@ var ZapierApiClient = class {
6909
6977
  if (!approvalContext) {
6910
6978
  return { response };
6911
6979
  }
6980
+ const askStatementIdsHeader = response.headers.get(
6981
+ "x-zapier-ask-statement-ids"
6982
+ );
6983
+ const askStatementIds = askStatementIdsHeader ? JSON.parse(askStatementIdsHeader) : void 0;
6912
6984
  try {
6913
6985
  await this.runOneApprovalRound(
6914
6986
  approvalContext,
6915
6987
  approvalMode,
6916
- init?.signal ?? void 0
6988
+ init?.signal ?? void 0,
6989
+ askStatementIds
6917
6990
  );
6918
6991
  } catch (error) {
6919
6992
  return { response, approvalRoundError: error };
@@ -7516,7 +7589,7 @@ var ZapierApiClient = class {
7516
7589
  * Caller is responsible for passing a non-"disabled" mode; this method
7517
7590
  * unconditionally creates an approval.
7518
7591
  */
7519
- async runOneApprovalRound(buildContext, mode, signal) {
7592
+ async runOneApprovalRound(buildContext, mode, signal, askStatementIds) {
7520
7593
  const context = buildContext();
7521
7594
  let approvalResponse;
7522
7595
  try {
@@ -7526,7 +7599,10 @@ var ZapierApiClient = class {
7526
7599
  "Content-Type": "application/json",
7527
7600
  Accept: "application/json"
7528
7601
  },
7529
- body: JSON.stringify({ context }),
7602
+ body: JSON.stringify({
7603
+ context,
7604
+ ...askStatementIds?.length ? { ask_statement_ids: askStatementIds } : {}
7605
+ }),
7530
7606
  signal
7531
7607
  });
7532
7608
  } catch (err) {
@@ -11854,14 +11930,24 @@ var ListConnectionsQuerySchema = ListConnectionsQuerySchema$1.omit({
11854
11930
  includeShared: z.boolean().optional().describe(
11855
11931
  "Include connections shared with you. By default, only your own connections are returned (owner=me). Set to true to also include shared connections."
11856
11932
  ),
11857
- /** @deprecated Use `expired` instead */
11933
+ // Filters on connection expiry. Not a mirror of a server-side status
11934
+ // field: the API expresses this as the is_expired filter, which we send as
11935
+ // false for "active", true for "expired", and omit for "all".
11936
+ status: z.enum(["active", "expired", "all"]).optional().describe(
11937
+ "Filter connections by expiry: 'active' (default) returns only non-expired connections, 'expired' only expired ones, and 'all' returns both."
11938
+ ),
11939
+ /** @deprecated Use `status` instead */
11858
11940
  isExpired: z.boolean().optional().describe("Filter by expired status").meta({
11859
11941
  deprecated: true,
11860
- deprecationMessage: "Use --expired instead to show only expired connections."
11942
+ deprecationMessage: "Use --status expired instead to show only expired connections, or --status all for both."
11861
11943
  }),
11944
+ /** @deprecated Use `status` instead */
11862
11945
  expired: z.boolean().optional().describe(
11863
11946
  "Show only expired connections (default: only non-expired connections are returned)"
11864
- ),
11947
+ ).meta({
11948
+ deprecated: true,
11949
+ deprecationMessage: "Use --status expired instead to show only expired connections, or --status all for both."
11950
+ }),
11865
11951
  // Override pageSize to make optional
11866
11952
  pageSize: z.number().min(1).optional().describe("Number of connections per page"),
11867
11953
  // SDK specific property for pagination/iterable helpers
@@ -11987,10 +12073,15 @@ var listConnectionsPlugin = defineMethod({
11987
12073
  if (owner) {
11988
12074
  searchParams.owner = owner;
11989
12075
  }
11990
- if (input.isExpired !== void 0) {
11991
- searchParams.is_expired = input.isExpired.toString();
11992
- } else {
11993
- searchParams.is_expired = (input.expired ?? false).toString();
12076
+ const expiredFilter = input.isExpired ?? input.expired;
12077
+ if (input.status !== void 0 && expiredFilter !== void 0) {
12078
+ throw new ZapierValidationError(
12079
+ 'The "status" option replaces "expired" and "isExpired", so it cannot be combined with either.'
12080
+ );
12081
+ }
12082
+ const status = input.status ?? (expiredFilter ? "expired" : "active");
12083
+ if (status !== "all") {
12084
+ searchParams.is_expired = (status === "expired").toString();
11994
12085
  }
11995
12086
  if (input.cursor) {
11996
12087
  searchParams.offset = input.cursor;