@zapier/zapier-sdk 0.33.4 → 0.34.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,11 @@
1
1
  # @zapier/zapier-sdk
2
2
 
3
+ ## 0.34.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 3700f6a: Fix --json output
8
+
3
9
  ## 0.33.4
4
10
 
5
11
  ### Patch Changes
package/README.md CHANGED
@@ -440,19 +440,19 @@ Get the available choices for a dynamic dropdown input field
440
440
 
441
441
  **Parameters:**
442
442
 
443
- | Name | Type | Required | Default | Possible Values | Description |
444
- | ----------------- | ---------------- | -------- | ------- | ---------------------------------------------------------------------------------------------- | ------------------------------------------------------ |
445
- | `options` | `object` | ✅ | — | — | |
446
- | ↳ `appKey` | `string` | ✅ | — | — | App key (e.g., 'SlackCLIAPI' or slug like 'github') |
447
- | ↳ `actionType` | `string` | ✅ | — | `read`, `read_bulk`, `write`, `run`, `search`, `search_or_write`, `search_and_write`, `filter` | Action type that matches the action's defined type |
448
- | ↳ `actionKey` | `string` | ✅ | — | — | Action key to execute |
449
- | ↳ `inputFieldKey` | `string` | ✅ | — | — | Input field key to get choices for. |
450
- | ↳ `connectionId` | `string, number` | ❌ | — | — | Connection ID to use for this action |
451
- | ↳ `inputs` | `object` | ❌ | — | — | Current input values that may affect available choices |
452
- | ↳ `page` | `number` | ❌ | — | — | Page number for paginated results |
453
- | ↳ `pageSize` | `number` | ❌ | — | — | Number of choices per page |
454
- | ↳ `maxItems` | `number` | ❌ | — | — | Maximum total items to return across all pages |
455
- | ↳ `cursor` | `string` | ❌ | — | — | Cursor to start from |
443
+ | Name | Type | Required | Default | Possible Values | Description |
444
+ | ----------------- | ---------------- | -------- | ------- | ---------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
445
+ | `options` | `object` | ✅ | — | — | |
446
+ | ↳ `appKey` | `string` | ✅ | — | — | App key (e.g., 'SlackCLIAPI' or slug like 'github') |
447
+ | ↳ `actionType` | `string` | ✅ | — | `read`, `read_bulk`, `write`, `run`, `search`, `search_or_write`, `search_and_write`, `filter` | Action type that matches the action's defined type |
448
+ | ↳ `actionKey` | `string` | ✅ | — | — | Action key to execute |
449
+ | ↳ `inputFieldKey` | `string` | ✅ | — | — | Input field key to get choices for. |
450
+ | ↳ `connectionId` | `string, number` | ❌ | — | — | Connection ID to use when listing available field choices. Required if the action needs a connection to populate dynamic dropdown options. |
451
+ | ↳ `inputs` | `object` | ❌ | — | — | Current input values that may affect available choices |
452
+ | ↳ `page` | `number` | ❌ | — | — | Page number for paginated results |
453
+ | ↳ `pageSize` | `number` | ❌ | — | — | Number of choices per page |
454
+ | ↳ `maxItems` | `number` | ❌ | — | — | Maximum total items to return across all pages |
455
+ | ↳ `cursor` | `string` | ❌ | — | — | Cursor to start from |
456
456
 
457
457
  **Returns:** `Promise<PaginatedResult<InputFieldChoiceItem>>`
458
458
 
@@ -497,17 +497,17 @@ Get the input fields required for a specific action
497
497
 
498
498
  **Parameters:**
499
499
 
500
- | Name | Type | Required | Default | Possible Values | Description |
501
- | ---------------- | ---------------- | -------- | ------- | ---------------------------------------------------------------------------------------------- | ----------------------------------------------------- |
502
- | `options` | `object` | ✅ | — | — | |
503
- | ↳ `appKey` | `string` | ✅ | — | — | App key (e.g., 'SlackCLIAPI' or slug like 'github') |
504
- | ↳ `actionType` | `string` | ✅ | — | `read`, `read_bulk`, `write`, `run`, `search`, `search_or_write`, `search_and_write`, `filter` | Action type that matches the action's defined type |
505
- | ↳ `actionKey` | `string` | ✅ | — | — | Action key to execute |
506
- | ↳ `connectionId` | `string, number` | ❌ | — | — | Connection ID to use for this action |
507
- | ↳ `inputs` | `object` | ❌ | — | — | Current input values that may affect available fields |
508
- | ↳ `pageSize` | `number` | ❌ | — | — | Number of input fields per page |
509
- | ↳ `maxItems` | `number` | ❌ | — | — | Maximum total items to return across all pages |
510
- | ↳ `cursor` | `string` | ❌ | — | — | Cursor to start from |
500
+ | Name | Type | Required | Default | Possible Values | Description |
501
+ | ---------------- | ---------------- | -------- | ------- | ---------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
502
+ | `options` | `object` | ✅ | — | — | |
503
+ | ↳ `appKey` | `string` | ✅ | — | — | App key (e.g., 'SlackCLIAPI' or slug like 'github') |
504
+ | ↳ `actionType` | `string` | ✅ | — | `read`, `read_bulk`, `write`, `run`, `search`, `search_or_write`, `search_and_write`, `filter` | Action type that matches the action's defined type |
505
+ | ↳ `actionKey` | `string` | ✅ | — | — | Action key to execute |
506
+ | ↳ `connectionId` | `string, number` | ❌ | — | — | Connection ID to use when listing input fields. Required if the action needs a connection to determine available fields. |
507
+ | ↳ `inputs` | `object` | ❌ | — | — | Current input values that may affect available fields |
508
+ | ↳ `pageSize` | `number` | ❌ | — | — | Number of input fields per page |
509
+ | ↳ `maxItems` | `number` | ❌ | — | — | Maximum total items to return across all pages |
510
+ | ↳ `cursor` | `string` | ❌ | — | — | Cursor to start from |
511
511
 
512
512
  **Returns:** `Promise<PaginatedResult<RootFieldItemItem>>`
513
513
 
@@ -548,18 +548,18 @@ Execute an action with the given inputs
548
548
 
549
549
  **Parameters:**
550
550
 
551
- | Name | Type | Required | Default | Possible Values | Description |
552
- | ---------------- | ---------------- | -------- | ------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
553
- | `options` | `object` | ✅ | — | — | |
554
- | ↳ `appKey` | `string` | ✅ | — | — | App key (e.g., 'SlackCLIAPI' or slug like 'github') |
555
- | ↳ `actionType` | `string` | ✅ | — | `read`, `read_bulk`, `write`, `run`, `search`, `search_or_write`, `search_and_write`, `filter` | Action type that matches the action's defined type |
556
- | ↳ `actionKey` | `string` | ✅ | — | — | Action key to execute |
557
- | ↳ `connectionId` | `string, number` | ❌ | — | — | Connection ID to use for this action |
558
- | ↳ `inputs` | `object` | ❌ | — | — | Input parameters for the action |
559
- | ↳ `timeoutMs` | `number` | ❌ | — | — | Maximum time to wait for action completion in milliseconds (default: 180000) |
560
- | ↳ `pageSize` | `number` | ❌ | — | — | Number of results per page |
561
- | ↳ `maxItems` | `number` | ❌ | — | — | Maximum total items to return across all pages |
562
- | ↳ `cursor` | `string` | ❌ | — | — | Cursor to start from |
551
+ | Name | Type | Required | Default | Possible Values | Description |
552
+ | ---------------- | ---------------- | -------- | ------- | ---------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
553
+ | `options` | `object` | ✅ | — | — | |
554
+ | ↳ `appKey` | `string` | ✅ | — | — | App key (e.g., 'SlackCLIAPI' or slug like 'github') |
555
+ | ↳ `actionType` | `string` | ✅ | — | `read`, `read_bulk`, `write`, `run`, `search`, `search_or_write`, `search_and_write`, `filter` | Action type that matches the action's defined type |
556
+ | ↳ `actionKey` | `string` | ✅ | — | — | Action key to execute |
557
+ | ↳ `connectionId` | `string, number` | ❌ | — | — | Connection ID to use when running the action. Required if the action needs a connection to authenticate and interact with the service. |
558
+ | ↳ `inputs` | `object` | ❌ | — | — | Input parameters for the action |
559
+ | ↳ `timeoutMs` | `number` | ❌ | — | — | Maximum time to wait for action completion in milliseconds (default: 180000) |
560
+ | ↳ `pageSize` | `number` | ❌ | — | — | Number of results per page |
561
+ | ↳ `maxItems` | `number` | ❌ | — | — | Maximum total items to return across all pages |
562
+ | ↳ `cursor` | `string` | ❌ | — | — | Cursor to start from |
563
563
 
564
564
  **Returns:** `Promise<PaginatedResult<ActionResultItem>>`
565
565
 
package/dist/index.cjs CHANGED
@@ -122,12 +122,14 @@ var ZapierApiError = class extends ZapierError {
122
122
  constructor(message, options = {}) {
123
123
  super(message, options);
124
124
  this.name = "ZapierApiError";
125
+ this.code = "ZAPIER_API_ERROR";
125
126
  }
126
127
  };
127
128
  var ZapierAppNotFoundError = class extends ZapierError {
128
129
  constructor(message, options = {}) {
129
130
  super(message, options);
130
131
  this.name = "ZapierAppNotFoundError";
132
+ this.code = "ZAPIER_APP_NOT_FOUND_ERROR";
131
133
  this.appKey = options.appKey;
132
134
  }
133
135
  };
@@ -135,6 +137,7 @@ var ZapierValidationError = class extends ZapierError {
135
137
  constructor(message, options = {}) {
136
138
  super(message, options);
137
139
  this.name = "ZapierValidationError";
140
+ this.code = "ZAPIER_VALIDATION_ERROR";
138
141
  this.details = options.details;
139
142
  }
140
143
  };
@@ -142,18 +145,21 @@ var ZapierUnknownError = class extends ZapierError {
142
145
  constructor(message, options = {}) {
143
146
  super(message, options);
144
147
  this.name = "ZapierUnknownError";
148
+ this.code = "ZAPIER_UNKNOWN_ERROR";
145
149
  }
146
150
  };
147
151
  var ZapierAuthenticationError = class extends ZapierError {
148
152
  constructor(message, options = {}) {
149
153
  super(message, options);
150
154
  this.name = "ZapierAuthenticationError";
155
+ this.code = "ZAPIER_AUTHENTICATION_ERROR";
151
156
  }
152
157
  };
153
158
  var ZapierResourceNotFoundError = class extends ZapierError {
154
159
  constructor(message, options = {}) {
155
160
  super(message, options);
156
161
  this.name = "ZapierResourceNotFoundError";
162
+ this.code = "ZAPIER_RESOURCE_NOT_FOUND_ERROR";
157
163
  this.resourceType = options.resourceType;
158
164
  this.resourceId = options.resourceId;
159
165
  }
@@ -162,6 +168,7 @@ var ZapierConfigurationError = class extends ZapierError {
162
168
  constructor(message, options = {}) {
163
169
  super(message, options);
164
170
  this.name = "ZapierConfigurationError";
171
+ this.code = "ZAPIER_CONFIGURATION_ERROR";
165
172
  this.configType = options.configType;
166
173
  }
167
174
  };
@@ -169,6 +176,7 @@ var ZapierBundleError = class extends ZapierError {
169
176
  constructor(message, options = {}) {
170
177
  super(message, options);
171
178
  this.name = "ZapierBundleError";
179
+ this.code = "ZAPIER_BUNDLE_ERROR";
172
180
  this.buildErrors = options.buildErrors;
173
181
  }
174
182
  };
@@ -176,6 +184,7 @@ var ZapierTimeoutError = class extends ZapierError {
176
184
  constructor(message, options = {}) {
177
185
  super(message, options);
178
186
  this.name = "ZapierTimeoutError";
187
+ this.code = "ZAPIER_TIMEOUT_ERROR";
179
188
  this.attempts = options.attempts;
180
189
  this.maxAttempts = options.maxAttempts;
181
190
  }
@@ -184,6 +193,7 @@ var ZapierActionError = class extends ZapierError {
184
193
  constructor(message, options = {}) {
185
194
  super(message, options);
186
195
  this.name = "ZapierActionError";
196
+ this.code = "ZAPIER_ACTION_ERROR";
187
197
  this.appKey = options.appKey;
188
198
  this.actionKey = options.actionKey;
189
199
  }
@@ -196,12 +206,14 @@ var ZapierNotFoundError = class extends ZapierError {
196
206
  constructor(message, options = {}) {
197
207
  super(message, options);
198
208
  this.name = "ZapierNotFoundError";
209
+ this.code = "ZAPIER_NOT_FOUND_ERROR";
199
210
  }
200
211
  };
201
212
  var ZapierRateLimitError = class extends ZapierError {
202
213
  constructor(message, options = {}) {
203
214
  super(message, options);
204
215
  this.name = "ZapierRateLimitError";
216
+ this.code = "ZAPIER_RATE_LIMIT_ERROR";
205
217
  this.rateLimit = options.rateLimit ?? {};
206
218
  this.retries = options.retries ?? 0;
207
219
  }
@@ -210,6 +222,7 @@ var ZapierRelayError = class extends ZapierError {
210
222
  constructor(message, options = {}) {
211
223
  super(message, options);
212
224
  this.name = "ZapierRelayError";
225
+ this.code = "ZAPIER_RELAY_ERROR";
213
226
  }
214
227
  };
215
228
  function formatErrorMessage(error) {
@@ -632,32 +645,63 @@ var fetchPlugin = ({ context }) => {
632
645
  };
633
646
 
634
647
  // src/utils/pagination-utils.ts
635
- var offsetCursorMarker = "$$offset$$";
636
- function splitOffsetCursor(cursor) {
637
- if (!cursor) {
638
- return [0, cursor];
648
+ var CURSOR_VERSION = 1;
649
+ var CURSOR_SOURCE = {
650
+ API: "api",
651
+ SDK: "sdk"
652
+ };
653
+ function encodeBase64(str) {
654
+ return btoa(
655
+ Array.from(
656
+ new TextEncoder().encode(str),
657
+ (b) => String.fromCharCode(b)
658
+ ).join("")
659
+ );
660
+ }
661
+ function decodeBase64(str) {
662
+ return new TextDecoder().decode(
663
+ Uint8Array.from(atob(str), (c) => c.charCodeAt(0))
664
+ );
665
+ }
666
+ function encodeApiCursor(cursor) {
667
+ const envelope = {
668
+ v: CURSOR_VERSION,
669
+ source: CURSOR_SOURCE.API,
670
+ cursor
671
+ };
672
+ return encodeBase64(JSON.stringify(envelope));
673
+ }
674
+ function encodeSdkCursor(offset, cursor) {
675
+ const envelope = {
676
+ v: CURSOR_VERSION,
677
+ source: CURSOR_SOURCE.SDK,
678
+ cursor,
679
+ offset
680
+ };
681
+ return encodeBase64(JSON.stringify(envelope));
682
+ }
683
+ function decodeIncomingCursor(incoming) {
684
+ if (!incoming) {
685
+ return { offset: 0, cursor: void 0 };
639
686
  }
640
687
  try {
641
- const parsedCursor = JSON.parse(cursor);
642
- if (!Array.isArray(parsedCursor)) {
643
- return [0, cursor];
688
+ const decoded = decodeBase64(incoming);
689
+ const envelope = JSON.parse(decoded);
690
+ if (envelope.v !== CURSOR_VERSION) {
691
+ return { offset: 0, cursor: incoming };
644
692
  }
645
- const [marker, offset, currentCursor] = parsedCursor;
646
- if (marker !== offsetCursorMarker) {
647
- return [0, cursor];
693
+ if (envelope.source === CURSOR_SOURCE.SDK) {
694
+ return { offset: envelope.offset ?? 0, cursor: envelope.cursor };
648
695
  }
649
- if (typeof offset !== "number") {
650
- return [0, cursor];
696
+ if (envelope.source === CURSOR_SOURCE.API) {
697
+ return { offset: 0, cursor: envelope.cursor };
651
698
  }
652
- return [offset, currentCursor];
699
+ return { offset: 0, cursor: incoming };
653
700
  } catch {
654
- return [0, cursor];
701
+ return { offset: 0, cursor: incoming };
655
702
  }
656
703
  }
657
- function createOffsetCursor(offset, currentCursor) {
658
- return JSON.stringify([offsetCursorMarker, offset, currentCursor]);
659
- }
660
- async function* paginateMaxItems(pageFunction, pageOptions) {
704
+ async function* paginateMaxItemsWithUnencodedCursor(pageFunction, pageOptions) {
661
705
  let cursor = pageOptions?.cursor;
662
706
  let totalItemsYielded = 0;
663
707
  const maxItems = pageOptions?.maxItems;
@@ -672,12 +716,11 @@ async function* paginateMaxItems(pageFunction, pageOptions) {
672
716
  if (maxItems !== void 0) {
673
717
  const remainingItems = maxItems - totalItemsYielded;
674
718
  if (page.data.length >= remainingItems) {
675
- const yieldedPage = {
719
+ yield {
676
720
  ...page,
677
721
  data: page.data.slice(0, remainingItems),
678
722
  nextCursor: void 0
679
723
  };
680
- yield yieldedPage;
681
724
  break;
682
725
  }
683
726
  }
@@ -688,16 +731,38 @@ async function* paginateMaxItems(pageFunction, pageOptions) {
688
731
  }
689
732
  async function* paginateBuffered(pageFunction, pageOptions) {
690
733
  const pageSize = pageOptions?.pageSize;
691
- const [cursorOffset, currentCursor] = splitOffsetCursor(pageOptions?.cursor);
734
+ const { offset: cursorOffset, cursor: initialCursor } = decodeIncomingCursor(
735
+ pageOptions?.cursor
736
+ );
737
+ const requestedMaxItems = pageOptions?.maxItems;
692
738
  const options = {
693
739
  ...pageOptions || {},
694
- cursor: currentCursor
740
+ cursor: initialCursor,
741
+ // SDK cursors can carry an offset into a raw backend page. Since maxItems
742
+ // is expected to be relative to the resumed position, we add that offset
743
+ // so raw pagination still yields enough items after offset slicing.
744
+ maxItems: requestedMaxItems !== void 0 && cursorOffset > 0 ? requestedMaxItems + cursorOffset : requestedMaxItems
695
745
  };
696
- const iterator = paginateMaxItems(pageFunction, options);
746
+ if (!pageSize) {
747
+ for await (const page of paginateMaxItemsWithUnencodedCursor(
748
+ pageFunction,
749
+ options
750
+ )) {
751
+ yield {
752
+ ...page,
753
+ nextCursor: page.nextCursor ? encodeApiCursor(page.nextCursor) : void 0
754
+ };
755
+ }
756
+ return;
757
+ }
697
758
  let bufferedPages = [];
698
759
  let isFirstPage = true;
699
- let cursor;
700
- for await (let page of iterator) {
760
+ let rawCursor;
761
+ for await (let page of paginateMaxItemsWithUnencodedCursor(
762
+ pageFunction,
763
+ options
764
+ )) {
765
+ const nextRawCursor = page.nextCursor;
701
766
  if (isFirstPage) {
702
767
  isFirstPage = false;
703
768
  if (cursorOffset) {
@@ -707,18 +772,13 @@ async function* paginateBuffered(pageFunction, pageOptions) {
707
772
  };
708
773
  }
709
774
  }
710
- if (!pageSize) {
711
- yield page;
712
- cursor = page.nextCursor;
713
- continue;
714
- }
715
775
  const bufferedLength = bufferedPages.reduce(
716
- (acc, page2) => acc + page2.data.length,
776
+ (acc, p) => acc + p.data.length,
717
777
  0
718
778
  );
719
779
  if (bufferedLength + page.data.length < pageSize) {
720
780
  bufferedPages.push(page);
721
- cursor = page.nextCursor;
781
+ rawCursor = nextRawCursor;
722
782
  continue;
723
783
  }
724
784
  const bufferedItems = bufferedPages.map((p) => p.data).flat();
@@ -729,28 +789,28 @@ async function* paginateBuffered(pageFunction, pageOptions) {
729
789
  yield {
730
790
  ...page,
731
791
  data: pageItems,
732
- nextCursor: page.nextCursor
792
+ nextCursor: nextRawCursor ? encodeApiCursor(nextRawCursor) : void 0
733
793
  };
734
794
  bufferedPages = [];
735
- cursor = page.nextCursor;
795
+ rawCursor = nextRawCursor;
736
796
  continue;
737
797
  }
738
798
  yield {
739
799
  ...page,
740
800
  data: pageItems,
741
- nextCursor: createOffsetCursor(
801
+ nextCursor: encodeSdkCursor(
742
802
  page.data.length - remainingItems.length,
743
- cursor
803
+ rawCursor
744
804
  )
745
805
  };
746
806
  while (remainingItems.length > pageSize) {
747
- const pageItems2 = remainingItems.splice(0, pageSize);
807
+ const chunkItems = remainingItems.splice(0, pageSize);
748
808
  yield {
749
809
  ...page,
750
- data: pageItems2,
751
- nextCursor: createOffsetCursor(
810
+ data: chunkItems,
811
+ nextCursor: encodeSdkCursor(
752
812
  page.data.length - remainingItems.length,
753
- cursor
813
+ rawCursor
754
814
  )
755
815
  };
756
816
  }
@@ -760,7 +820,7 @@ async function* paginateBuffered(pageFunction, pageOptions) {
760
820
  data: remainingItems
761
821
  }
762
822
  ];
763
- cursor = page.nextCursor;
823
+ rawCursor = nextRawCursor;
764
824
  }
765
825
  if (bufferedPages.length > 0) {
766
826
  const lastBufferedPage = bufferedPages.slice(-1)[0];
@@ -1897,7 +1957,9 @@ var ListInputFieldsSchema = zod.z.object({
1897
1957
  appKey: AppKeyPropertySchema,
1898
1958
  actionType: ActionTypePropertySchema,
1899
1959
  actionKey: ActionKeyPropertySchema,
1900
- connectionId: ConnectionIdPropertySchema.nullable().optional(),
1960
+ connectionId: ConnectionIdPropertySchema.nullable().optional().describe(
1961
+ "Connection ID to use when listing input fields. Required if the action needs a connection to determine available fields."
1962
+ ),
1901
1963
  /** @deprecated Use connectionId instead */
1902
1964
  authenticationId: AuthenticationIdPropertySchema.nullable().optional(),
1903
1965
  inputs: InputsPropertySchema.optional().describe(
@@ -2895,7 +2957,9 @@ var RunActionSchema = zod.z.object({
2895
2957
  appKey: AppKeyPropertySchema,
2896
2958
  actionType: ActionTypePropertySchema,
2897
2959
  actionKey: ActionKeyPropertySchema,
2898
- connectionId: ConnectionIdPropertySchema.nullable().optional(),
2960
+ connectionId: ConnectionIdPropertySchema.nullable().optional().describe(
2961
+ "Connection ID to use when running the action. Required if the action needs a connection to authenticate and interact with the service."
2962
+ ),
2899
2963
  /** @deprecated Use connectionId instead */
2900
2964
  authenticationId: ConnectionIdPropertySchema.nullable().optional(),
2901
2965
  inputs: InputsPropertySchema.optional().describe(
@@ -4980,7 +5044,8 @@ var registryPlugin = ({ sdk, context }) => {
4980
5044
  confirm: meta.confirm ?? (meta.type === "delete" ? "delete" : void 0),
4981
5045
  deprecation: meta.deprecation,
4982
5046
  deprecatedParameters: meta.deprecatedParameters,
4983
- aliases: meta.aliases
5047
+ aliases: meta.aliases,
5048
+ supportsJsonOutput: meta.supportsJsonOutput ?? true
4984
5049
  };
4985
5050
  }).sort((a, b) => a.name.localeCompare(b.name));
4986
5051
  const knownCategories = Object.keys(categoryDefinitions);
@@ -5214,7 +5279,9 @@ var ListInputFieldChoicesSchema = zod.z.object({
5214
5279
  // Input field specification
5215
5280
  inputFieldKey: zod.z.string().min(1).describe("Input field key to get choices for."),
5216
5281
  // Common parameters
5217
- connectionId: ConnectionIdPropertySchema.nullable().optional(),
5282
+ connectionId: ConnectionIdPropertySchema.nullable().optional().describe(
5283
+ "Connection ID to use when listing available field choices. Required if the action needs a connection to populate dynamic dropdown options."
5284
+ ),
5218
5285
  /** @deprecated Use connectionId instead */
5219
5286
  authenticationId: AuthenticationIdPropertySchema.nullable().optional(),
5220
5287
  inputs: InputsPropertySchema.optional().describe(
@@ -5513,7 +5580,7 @@ function getCpuTime() {
5513
5580
  }
5514
5581
 
5515
5582
  // src/plugins/eventEmission/builders.ts
5516
- var SDK_VERSION = "0.33.4";
5583
+ var SDK_VERSION = "0.34.0";
5517
5584
  function createBaseEvent(context = {}) {
5518
5585
  return {
5519
5586
  event_id: generateEventId(),
package/dist/index.d.mts CHANGED
@@ -1045,12 +1045,11 @@ interface FunctionOptions {
1045
1045
  /** Custom fetch implementation */
1046
1046
  fetch?: typeof globalThis.fetch;
1047
1047
  }
1048
- type PaginatedSdkFunction<TOptions, TItem> = (options: TOptions) => Promise<{
1049
- data: TItem[];
1050
- }> & AsyncIterable<{
1051
- data: TItem[];
1048
+ interface SdkPage<T = unknown> {
1049
+ data: T[];
1052
1050
  nextCursor?: string;
1053
- }> & {
1051
+ }
1052
+ type PaginatedSdkFunction<TOptions, TItem> = (options: TOptions) => Promise<SdkPage<TItem>> & AsyncIterable<SdkPage<TItem>> & {
1054
1053
  items(): AsyncIterable<TItem>;
1055
1054
  };
1056
1055
 
@@ -1080,6 +1079,7 @@ interface ErrorOptions {
1080
1079
  */
1081
1080
  declare abstract class ZapierError extends Error {
1082
1081
  abstract readonly name: string;
1082
+ abstract readonly code: string;
1083
1083
  statusCode?: number;
1084
1084
  errors?: ApiError[];
1085
1085
  cause?: unknown;
@@ -1091,6 +1091,7 @@ declare abstract class ZapierError extends Error {
1091
1091
  */
1092
1092
  declare class ZapierApiError extends ZapierError {
1093
1093
  readonly name = "ZapierApiError";
1094
+ readonly code: "ZAPIER_API_ERROR";
1094
1095
  constructor(message: string, options?: ErrorOptions);
1095
1096
  }
1096
1097
  /**
@@ -1098,6 +1099,7 @@ declare class ZapierApiError extends ZapierError {
1098
1099
  */
1099
1100
  declare class ZapierAppNotFoundError extends ZapierError {
1100
1101
  readonly name = "ZapierAppNotFoundError";
1102
+ readonly code: "ZAPIER_APP_NOT_FOUND_ERROR";
1101
1103
  appKey?: string;
1102
1104
  constructor(message: string, options?: ErrorOptions & {
1103
1105
  appKey?: string;
@@ -1108,6 +1110,7 @@ declare class ZapierAppNotFoundError extends ZapierError {
1108
1110
  */
1109
1111
  declare class ZapierValidationError extends ZapierError {
1110
1112
  readonly name = "ZapierValidationError";
1113
+ readonly code: "ZAPIER_VALIDATION_ERROR";
1111
1114
  details?: unknown;
1112
1115
  constructor(message: string, options?: ErrorOptions & {
1113
1116
  details?: unknown;
@@ -1118,6 +1121,7 @@ declare class ZapierValidationError extends ZapierError {
1118
1121
  */
1119
1122
  declare class ZapierUnknownError extends ZapierError {
1120
1123
  readonly name = "ZapierUnknownError";
1124
+ readonly code: "ZAPIER_UNKNOWN_ERROR";
1121
1125
  constructor(message: string, options?: ErrorOptions);
1122
1126
  }
1123
1127
  /**
@@ -1125,6 +1129,7 @@ declare class ZapierUnknownError extends ZapierError {
1125
1129
  */
1126
1130
  declare class ZapierAuthenticationError extends ZapierError {
1127
1131
  readonly name = "ZapierAuthenticationError";
1132
+ readonly code: "ZAPIER_AUTHENTICATION_ERROR";
1128
1133
  constructor(message: string, options?: ErrorOptions);
1129
1134
  }
1130
1135
  /**
@@ -1132,6 +1137,7 @@ declare class ZapierAuthenticationError extends ZapierError {
1132
1137
  */
1133
1138
  declare class ZapierResourceNotFoundError extends ZapierError {
1134
1139
  readonly name = "ZapierResourceNotFoundError";
1140
+ readonly code: "ZAPIER_RESOURCE_NOT_FOUND_ERROR";
1135
1141
  resourceType?: string;
1136
1142
  resourceId?: string;
1137
1143
  constructor(message: string, options?: ErrorOptions & {
@@ -1144,6 +1150,7 @@ declare class ZapierResourceNotFoundError extends ZapierError {
1144
1150
  */
1145
1151
  declare class ZapierConfigurationError extends ZapierError {
1146
1152
  readonly name = "ZapierConfigurationError";
1153
+ readonly code: "ZAPIER_CONFIGURATION_ERROR";
1147
1154
  configType?: string;
1148
1155
  constructor(message: string, options?: ErrorOptions & {
1149
1156
  configType?: string;
@@ -1154,6 +1161,7 @@ declare class ZapierConfigurationError extends ZapierError {
1154
1161
  */
1155
1162
  declare class ZapierBundleError extends ZapierError {
1156
1163
  readonly name = "ZapierBundleError";
1164
+ readonly code: "ZAPIER_BUNDLE_ERROR";
1157
1165
  buildErrors?: string[];
1158
1166
  constructor(message: string, options?: ErrorOptions & {
1159
1167
  buildErrors?: string[];
@@ -1164,6 +1172,7 @@ declare class ZapierBundleError extends ZapierError {
1164
1172
  */
1165
1173
  declare class ZapierTimeoutError extends ZapierError {
1166
1174
  readonly name = "ZapierTimeoutError";
1175
+ readonly code: "ZAPIER_TIMEOUT_ERROR";
1167
1176
  attempts?: number;
1168
1177
  maxAttempts?: number;
1169
1178
  constructor(message: string, options?: ErrorOptions & {
@@ -1177,6 +1186,7 @@ declare class ZapierTimeoutError extends ZapierError {
1177
1186
  */
1178
1187
  declare class ZapierActionError extends ZapierError {
1179
1188
  readonly name = "ZapierActionError";
1189
+ readonly code: "ZAPIER_ACTION_ERROR";
1180
1190
  appKey?: string;
1181
1191
  actionKey?: string;
1182
1192
  constructor(message: string, options?: ErrorOptions & {
@@ -1190,6 +1200,7 @@ declare class ZapierActionError extends ZapierError {
1190
1200
  */
1191
1201
  declare class ZapierNotFoundError extends ZapierError {
1192
1202
  readonly name = "ZapierNotFoundError";
1203
+ readonly code: "ZAPIER_NOT_FOUND_ERROR";
1193
1204
  constructor(message: string, options?: ErrorOptions);
1194
1205
  }
1195
1206
  /**
@@ -1210,6 +1221,7 @@ interface RateLimitInfo {
1210
1221
  */
1211
1222
  declare class ZapierRateLimitError extends ZapierError {
1212
1223
  readonly name = "ZapierRateLimitError";
1224
+ readonly code: "ZAPIER_RATE_LIMIT_ERROR";
1213
1225
  rateLimit: RateLimitInfo;
1214
1226
  retries: number;
1215
1227
  constructor(message: string, options?: ErrorOptions & {
@@ -1223,6 +1235,7 @@ declare class ZapierRateLimitError extends ZapierError {
1223
1235
  */
1224
1236
  declare class ZapierRelayError extends ZapierError {
1225
1237
  readonly name = "ZapierRelayError";
1238
+ readonly code: "ZAPIER_RELAY_ERROR";
1226
1239
  constructor(message: string, options?: ErrorOptions);
1227
1240
  }
1228
1241
  /**
@@ -2143,6 +2156,8 @@ interface FunctionRegistryEntry {
2143
2156
  deprecatedParameters?: string[];
2144
2157
  /** Short flag aliases for CLI options (e.g., { request: "X", header: "H" }) */
2145
2158
  aliases?: Record<string, string>;
2159
+ /** Defaults to true. Set to false to suppress --json (e.g. login/logout/init). */
2160
+ supportsJsonOutput: boolean;
2146
2161
  }
2147
2162
  interface FunctionDeprecation {
2148
2163
  /** User-facing deprecation message for why/how to migrate */
@@ -2969,4 +2984,4 @@ declare function createZapierSdkWithoutRegistry(options?: ZapierSdkOptions): Sdk
2969
2984
  }>;
2970
2985
  declare function createZapierSdk(options?: ZapierSdkOptions): ZapierSdk;
2971
2986
 
2972
- export { type Action, type ActionEntry, type ActionExecutionOptions, type ActionExecutionResult, type ActionField, type ActionFieldChoice, type ActionItem$1 as ActionItem, type ActionKeyProperty, ActionKeyPropertySchema, type ActionTimeoutMsProperty, ActionTimeoutMsPropertySchema, type ActionTypeProperty, ActionTypePropertySchema, type AddActionEntryOptions, type AddActionEntryResult, type ApiError, type ApiEvent, type ApiPluginOptions, type ApiPluginProvides, type App, type AppItem, type AppKeyProperty, AppKeyPropertySchema, type ApplicationLifecycleEventData, type AppsPluginProvides, type AuthEvent, type AuthenticationIdProperty, AuthenticationIdPropertySchema, type BaseEvent, BaseSdkOptionsSchema, type BatchOptions, type Choice, type ClientCredentialsObject, ClientCredentialsObjectSchema, type Connection, type ConnectionIdProperty, ConnectionIdPropertySchema, type ConnectionItem, type ConnectionsResponse, type CreateClientCredentialsPluginProvides, type Credentials, type CredentialsFunction, CredentialsFunctionSchema, type CredentialsObject, CredentialsObjectSchema, CredentialsSchema, DEFAULT_ACTION_TIMEOUT_MS, DEFAULT_CONFIG_PATH, type DebugProperty, DebugPropertySchema, type DeleteClientCredentialsPluginProvides, type DynamicResolver, type EnhancedErrorEventData, type ErrorOptions, type EventCallback, type EventContext, type EventEmissionContext, type FetchPluginProvides, type Field, type FieldsResolver, type FieldsetItem, type FindFirstAuthenticationPluginProvides, type FindFirstConnectionPluginProvides, type FindUniqueAuthenticationPluginProvides, type FindUniqueConnectionPluginProvides, type FormatMetadata, type FormattedItem, type FunctionDeprecation, type FunctionOptions, type FunctionRegistryEntry, type GetActionPluginProvides, type GetAppPluginProvides, type GetAuthenticationPluginProvides, type GetConnectionPluginProvides, type GetContextType, type GetProfilePluginProvides, type GetSdkType, type InfoFieldItem, type InputFieldItem, type InputsProperty, InputsPropertySchema, type LimitProperty, LimitPropertySchema, type ListActionsPluginProvides, type ListAppsPluginProvides, type ListAuthenticationsPluginProvides, type ListClientCredentialsPluginProvides, type ListConnectionsPluginProvides, type ListInputFieldsPluginProvides, type LoadingEvent, MAX_PAGE_LIMIT, type Manifest, type ManifestEntry, type ManifestPluginOptions, type ManifestPluginProvides, type MethodCalledEvent, type MethodCalledEventData, type Need, type NeedsRequest, type NeedsResponse, type OffsetProperty, OffsetPropertySchema, type OutputProperty, OutputPropertySchema, type PaginatedSdkFunction, type ParamsProperty, ParamsPropertySchema, type PkceCredentialsObject, PkceCredentialsObjectSchema, type Plugin, type PluginDependencies, type PluginOptions, type PluginProvides, type PositionalMetadata, type RateLimitInfo, RelayFetchSchema, RelayRequestSchema, type RequestPluginProvides, type ResolveAuthTokenOptions, type ResolveCredentialsOptions, type ResolvedCredentials, ResolvedCredentialsSchema, type Resolver, type RootFieldItem, type RunActionPluginProvides, type Sdk, type SdkEvent, type StaticResolver, type UpdateManifestEntryOptions, type UpdateManifestEntryResult, type UserProfile, type UserProfileItem, ZAPIER_BASE_URL, ZAPIER_MAX_NETWORK_RETRIES, ZAPIER_MAX_NETWORK_RETRY_DELAY_MS, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierAuthenticationError, ZapierBundleError, ZapierConfigurationError, ZapierError, type ZapierFetchInitOptions, ZapierNotFoundError, ZapierRateLimitError, ZapierRelayError, ZapierResourceNotFoundError, type ZapierSdk, type ZapierSdkApps, type ZapierSdkOptions, ZapierTimeoutError, ZapierUnknownError, ZapierValidationError, actionKeyResolver, actionTypeResolver, apiPlugin, appKeyResolver, appsPlugin, connectionIdGenericResolver as authenticationIdGenericResolver, connectionIdResolver as authenticationIdResolver, batch, buildApplicationLifecycleEvent, buildErrorEvent, buildErrorEventWithContext, buildMethodCalledEvent, clearTokenCache, clientCredentialsNameResolver, clientIdResolver, connectionIdGenericResolver, connectionIdResolver, createBaseEvent, createClientCredentialsPlugin, createFunction, createSdk, createZapierSdk, createZapierSdkWithoutRegistry, deleteClientCredentialsPlugin, fetchPlugin, findFirstConnectionPlugin, findManifestEntry, findUniqueConnectionPlugin, formatErrorMessage, generateEventId, getActionPlugin, getAppPlugin, getBaseUrlFromCredentials, getCiPlatform, getClientIdFromCredentials, getConnectionPlugin, getCpuTime, getCurrentTimestamp, getMemoryUsage, getOsInfo, getPlatformVersions, getPreferredManifestEntryKey, getProfilePlugin, getReleaseId, getTokenFromCliLogin, injectCliLogin, inputFieldKeyResolver, inputsAllOptionalResolver, inputsResolver, invalidateCachedToken, invalidateCredentialsToken, isCi, isCliLoginAvailable, isClientCredentials, isCredentialsFunction, isCredentialsObject, isPkceCredentials, isPositional, listActionsPlugin, listAppsPlugin, listClientCredentialsPlugin, listConnectionsPlugin, listInputFieldsPlugin, logDeprecation, manifestPlugin, readManifestFromFile, registryPlugin, requestPlugin, resetDeprecationWarnings, resolveAuthToken, resolveCredentials, resolveCredentialsFromEnv, runActionPlugin, runWithTelemetryContext, toSnakeCase, toTitleCase };
2987
+ export { type Action, type ActionEntry, type ActionExecutionOptions, type ActionExecutionResult, type ActionField, type ActionFieldChoice, type ActionItem$1 as ActionItem, type ActionKeyProperty, ActionKeyPropertySchema, type ActionTimeoutMsProperty, ActionTimeoutMsPropertySchema, type ActionTypeProperty, ActionTypePropertySchema, type AddActionEntryOptions, type AddActionEntryResult, type ApiError, type ApiEvent, type ApiPluginOptions, type ApiPluginProvides, type App, type AppItem, type AppKeyProperty, AppKeyPropertySchema, type ApplicationLifecycleEventData, type AppsPluginProvides, type AuthEvent, type AuthenticationIdProperty, AuthenticationIdPropertySchema, type BaseEvent, BaseSdkOptionsSchema, type BatchOptions, type Choice, type ClientCredentialsObject, ClientCredentialsObjectSchema, type Connection, type ConnectionIdProperty, ConnectionIdPropertySchema, type ConnectionItem, type ConnectionsResponse, type CreateClientCredentialsPluginProvides, type Credentials, type CredentialsFunction, CredentialsFunctionSchema, type CredentialsObject, CredentialsObjectSchema, CredentialsSchema, DEFAULT_ACTION_TIMEOUT_MS, DEFAULT_CONFIG_PATH, type DebugProperty, DebugPropertySchema, type DeleteClientCredentialsPluginProvides, type DynamicResolver, type EnhancedErrorEventData, type ErrorOptions, type EventCallback, type EventContext, type EventEmissionContext, type FetchPluginProvides, type Field, type FieldsResolver, type FieldsetItem, type FindFirstAuthenticationPluginProvides, type FindFirstConnectionPluginProvides, type FindUniqueAuthenticationPluginProvides, type FindUniqueConnectionPluginProvides, type FormatMetadata, type FormattedItem, type FunctionDeprecation, type FunctionOptions, type FunctionRegistryEntry, type GetActionPluginProvides, type GetAppPluginProvides, type GetAuthenticationPluginProvides, type GetConnectionPluginProvides, type GetContextType, type GetProfilePluginProvides, type GetSdkType, type InfoFieldItem, type InputFieldItem, type InputsProperty, InputsPropertySchema, type LimitProperty, LimitPropertySchema, type ListActionsPluginProvides, type ListAppsPluginProvides, type ListAuthenticationsPluginProvides, type ListClientCredentialsPluginProvides, type ListConnectionsPluginProvides, type ListInputFieldsPluginProvides, type LoadingEvent, MAX_PAGE_LIMIT, type Manifest, type ManifestEntry, type ManifestPluginOptions, type ManifestPluginProvides, type MethodCalledEvent, type MethodCalledEventData, type Need, type NeedsRequest, type NeedsResponse, type OffsetProperty, OffsetPropertySchema, type OutputProperty, OutputPropertySchema, type PaginatedSdkFunction, type ParamsProperty, ParamsPropertySchema, type PkceCredentialsObject, PkceCredentialsObjectSchema, type Plugin, type PluginDependencies, type PluginOptions, type PluginProvides, type PositionalMetadata, type RateLimitInfo, RelayFetchSchema, RelayRequestSchema, type RequestPluginProvides, type ResolveAuthTokenOptions, type ResolveCredentialsOptions, type ResolvedCredentials, ResolvedCredentialsSchema, type Resolver, type RootFieldItem, type RunActionPluginProvides, type Sdk, type SdkEvent, type SdkPage, type StaticResolver, type UpdateManifestEntryOptions, type UpdateManifestEntryResult, type UserProfile, type UserProfileItem, ZAPIER_BASE_URL, ZAPIER_MAX_NETWORK_RETRIES, ZAPIER_MAX_NETWORK_RETRY_DELAY_MS, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierAuthenticationError, ZapierBundleError, ZapierConfigurationError, ZapierError, type ZapierFetchInitOptions, ZapierNotFoundError, ZapierRateLimitError, ZapierRelayError, ZapierResourceNotFoundError, type ZapierSdk, type ZapierSdkApps, type ZapierSdkOptions, ZapierTimeoutError, ZapierUnknownError, ZapierValidationError, actionKeyResolver, actionTypeResolver, apiPlugin, appKeyResolver, appsPlugin, connectionIdGenericResolver as authenticationIdGenericResolver, connectionIdResolver as authenticationIdResolver, batch, buildApplicationLifecycleEvent, buildErrorEvent, buildErrorEventWithContext, buildMethodCalledEvent, clearTokenCache, clientCredentialsNameResolver, clientIdResolver, connectionIdGenericResolver, connectionIdResolver, createBaseEvent, createClientCredentialsPlugin, createFunction, createSdk, createZapierSdk, createZapierSdkWithoutRegistry, deleteClientCredentialsPlugin, fetchPlugin, findFirstConnectionPlugin, findManifestEntry, findUniqueConnectionPlugin, formatErrorMessage, generateEventId, getActionPlugin, getAppPlugin, getBaseUrlFromCredentials, getCiPlatform, getClientIdFromCredentials, getConnectionPlugin, getCpuTime, getCurrentTimestamp, getMemoryUsage, getOsInfo, getPlatformVersions, getPreferredManifestEntryKey, getProfilePlugin, getReleaseId, getTokenFromCliLogin, injectCliLogin, inputFieldKeyResolver, inputsAllOptionalResolver, inputsResolver, invalidateCachedToken, invalidateCredentialsToken, isCi, isCliLoginAvailable, isClientCredentials, isCredentialsFunction, isCredentialsObject, isPkceCredentials, isPositional, listActionsPlugin, listAppsPlugin, listClientCredentialsPlugin, listConnectionsPlugin, listInputFieldsPlugin, logDeprecation, manifestPlugin, readManifestFromFile, registryPlugin, requestPlugin, resetDeprecationWarnings, resolveAuthToken, resolveCredentials, resolveCredentialsFromEnv, runActionPlugin, runWithTelemetryContext, toSnakeCase, toTitleCase };