@zapier/zapier-sdk 0.33.3 → 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 +12 -0
- package/README.md +36 -36
- package/dist/index.cjs +128 -52
- package/dist/index.d.mts +21 -6
- package/dist/index.mjs +128 -52
- package/dist/plugins/eventEmission/index.d.ts.map +1 -1
- package/dist/plugins/eventEmission/index.js +15 -6
- package/dist/plugins/listInputFieldChoices/schemas.d.ts.map +1 -1
- package/dist/plugins/listInputFieldChoices/schemas.js +3 -1
- package/dist/plugins/listInputFields/schemas.d.ts.map +1 -1
- package/dist/plugins/listInputFields/schemas.js +3 -1
- package/dist/plugins/registry/index.d.ts.map +1 -1
- package/dist/plugins/registry/index.js +1 -0
- package/dist/plugins/runAction/schemas.d.ts.map +1 -1
- package/dist/plugins/runAction/schemas.js +3 -1
- package/dist/types/errors.d.ts +14 -0
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/errors.js +13 -0
- package/dist/types/functions.d.ts +4 -5
- package/dist/types/functions.d.ts.map +1 -1
- package/dist/types/sdk.d.ts +2 -0
- package/dist/types/sdk.d.ts.map +1 -1
- package/dist/utils/pagination-utils.d.ts +8 -2
- package/dist/utils/pagination-utils.d.ts.map +1 -1
- package/dist/utils/pagination-utils.js +101 -44
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @zapier/zapier-sdk
|
|
2
2
|
|
|
3
|
+
## 0.34.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 3700f6a: Fix --json output
|
|
8
|
+
|
|
9
|
+
## 0.33.4
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- d9e0f1d: Fix user properties being overwritten by context merge in telemetry events
|
|
14
|
+
|
|
3
15
|
## 0.33.3
|
|
4
16
|
|
|
5
17
|
### 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
|
|
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
|
|
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
|
|
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
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
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
|
|
642
|
-
|
|
643
|
-
|
|
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
|
-
|
|
646
|
-
|
|
647
|
-
return [0, cursor];
|
|
693
|
+
if (envelope.source === CURSOR_SOURCE.SDK) {
|
|
694
|
+
return { offset: envelope.offset ?? 0, cursor: envelope.cursor };
|
|
648
695
|
}
|
|
649
|
-
if (
|
|
650
|
-
return
|
|
696
|
+
if (envelope.source === CURSOR_SOURCE.API) {
|
|
697
|
+
return { offset: 0, cursor: envelope.cursor };
|
|
651
698
|
}
|
|
652
|
-
return
|
|
699
|
+
return { offset: 0, cursor: incoming };
|
|
653
700
|
} catch {
|
|
654
|
-
return
|
|
701
|
+
return { offset: 0, cursor: incoming };
|
|
655
702
|
}
|
|
656
703
|
}
|
|
657
|
-
function
|
|
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
|
-
|
|
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
|
|
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:
|
|
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
|
-
|
|
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
|
|
700
|
-
for await (let page of
|
|
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,
|
|
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
|
-
|
|
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:
|
|
792
|
+
nextCursor: nextRawCursor ? encodeApiCursor(nextRawCursor) : void 0
|
|
733
793
|
};
|
|
734
794
|
bufferedPages = [];
|
|
735
|
-
|
|
795
|
+
rawCursor = nextRawCursor;
|
|
736
796
|
continue;
|
|
737
797
|
}
|
|
738
798
|
yield {
|
|
739
799
|
...page,
|
|
740
800
|
data: pageItems,
|
|
741
|
-
nextCursor:
|
|
801
|
+
nextCursor: encodeSdkCursor(
|
|
742
802
|
page.data.length - remainingItems.length,
|
|
743
|
-
|
|
803
|
+
rawCursor
|
|
744
804
|
)
|
|
745
805
|
};
|
|
746
806
|
while (remainingItems.length > pageSize) {
|
|
747
|
-
const
|
|
807
|
+
const chunkItems = remainingItems.splice(0, pageSize);
|
|
748
808
|
yield {
|
|
749
809
|
...page,
|
|
750
|
-
data:
|
|
751
|
-
nextCursor:
|
|
810
|
+
data: chunkItems,
|
|
811
|
+
nextCursor: encodeSdkCursor(
|
|
752
812
|
page.data.length - remainingItems.length,
|
|
753
|
-
|
|
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
|
-
|
|
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.
|
|
5583
|
+
var SDK_VERSION = "0.34.0";
|
|
5517
5584
|
function createBaseEvent(context = {}) {
|
|
5518
5585
|
return {
|
|
5519
5586
|
event_id: generateEventId(),
|
|
@@ -5648,13 +5715,22 @@ async function emitWithTimeout(transport, subject, event) {
|
|
|
5648
5715
|
} catch {
|
|
5649
5716
|
}
|
|
5650
5717
|
}
|
|
5718
|
+
function mergeUserContext(event, userContext) {
|
|
5719
|
+
const merged = { ...event };
|
|
5720
|
+
for (const [key, value] of Object.entries(userContext)) {
|
|
5721
|
+
if (merged[key] == null) {
|
|
5722
|
+
merged[key] = value;
|
|
5723
|
+
}
|
|
5724
|
+
}
|
|
5725
|
+
return merged;
|
|
5726
|
+
}
|
|
5651
5727
|
async function silentEmit(transport, subject, event, userContextPromise) {
|
|
5652
5728
|
try {
|
|
5653
5729
|
let enrichedEvent = event;
|
|
5654
5730
|
if (userContextPromise) {
|
|
5655
5731
|
try {
|
|
5656
5732
|
const userContext = await userContextPromise;
|
|
5657
|
-
enrichedEvent =
|
|
5733
|
+
enrichedEvent = mergeUserContext(event, userContext);
|
|
5658
5734
|
} catch {
|
|
5659
5735
|
}
|
|
5660
5736
|
}
|
|
@@ -5771,7 +5847,7 @@ var eventEmissionPlugin = ({ context }) => {
|
|
|
5771
5847
|
};
|
|
5772
5848
|
try {
|
|
5773
5849
|
const userContext = await getUserContext;
|
|
5774
|
-
return
|
|
5850
|
+
return mergeUserContext(baseEvent, userContext);
|
|
5775
5851
|
} catch {
|
|
5776
5852
|
return baseEvent;
|
|
5777
5853
|
}
|
|
@@ -5824,7 +5900,7 @@ var eventEmissionPlugin = ({ context }) => {
|
|
|
5824
5900
|
});
|
|
5825
5901
|
try {
|
|
5826
5902
|
const userContext = await getUserContext;
|
|
5827
|
-
errorEvent =
|
|
5903
|
+
errorEvent = mergeUserContext(errorEvent, userContext);
|
|
5828
5904
|
} catch {
|
|
5829
5905
|
}
|
|
5830
5906
|
await emitWithTimeout(
|
|
@@ -5852,7 +5928,7 @@ var eventEmissionPlugin = ({ context }) => {
|
|
|
5852
5928
|
});
|
|
5853
5929
|
try {
|
|
5854
5930
|
const userContext = await getUserContext;
|
|
5855
|
-
errorEvent =
|
|
5931
|
+
errorEvent = mergeUserContext(errorEvent, userContext);
|
|
5856
5932
|
} catch {
|
|
5857
5933
|
}
|
|
5858
5934
|
await emitWithTimeout(
|
|
@@ -5874,7 +5950,7 @@ var eventEmissionPlugin = ({ context }) => {
|
|
|
5874
5950
|
});
|
|
5875
5951
|
try {
|
|
5876
5952
|
const userContext = await getUserContext;
|
|
5877
|
-
signalEvent =
|
|
5953
|
+
signalEvent = mergeUserContext(signalEvent, userContext);
|
|
5878
5954
|
} catch {
|
|
5879
5955
|
}
|
|
5880
5956
|
await emitWithTimeout(
|
|
@@ -5908,7 +5984,7 @@ var eventEmissionPlugin = ({ context }) => {
|
|
|
5908
5984
|
});
|
|
5909
5985
|
try {
|
|
5910
5986
|
const userContext = await getUserContext;
|
|
5911
|
-
exitEvent =
|
|
5987
|
+
exitEvent = mergeUserContext(exitEvent, userContext);
|
|
5912
5988
|
} catch {
|
|
5913
5989
|
}
|
|
5914
5990
|
await emitWithTimeout(
|