@zapier/zapier-sdk 0.6.3 → 0.8.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.
Files changed (56) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +73 -41
  3. package/dist/api/schemas.d.ts +114 -0
  4. package/dist/api/schemas.d.ts.map +1 -1
  5. package/dist/api/schemas.js +45 -0
  6. package/dist/api/types.d.ts +5 -1
  7. package/dist/api/types.d.ts.map +1 -1
  8. package/dist/index.cjs +2208 -2022
  9. package/dist/index.d.mts +327 -10
  10. package/dist/index.d.ts +18 -1
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +19 -1
  13. package/dist/index.mjs +2191 -2024
  14. package/dist/plugins/findFirstAuthentication/index.test.js +3 -3
  15. package/dist/plugins/findFirstAuthentication/schemas.d.ts +3 -3
  16. package/dist/plugins/findFirstAuthentication/schemas.js +1 -1
  17. package/dist/plugins/findUniqueAuthentication/index.test.js +3 -3
  18. package/dist/plugins/findUniqueAuthentication/schemas.d.ts +3 -3
  19. package/dist/plugins/findUniqueAuthentication/schemas.js +1 -1
  20. package/dist/plugins/getProfile/index.js +1 -1
  21. package/dist/plugins/listAuthentications/index.d.ts.map +1 -1
  22. package/dist/plugins/listAuthentications/index.js +2 -3
  23. package/dist/plugins/listAuthentications/index.test.js +5 -5
  24. package/dist/plugins/listAuthentications/schemas.d.ts +3 -3
  25. package/dist/plugins/listAuthentications/schemas.js +1 -1
  26. package/dist/plugins/listInputFieldChoices/index.d.ts +28 -0
  27. package/dist/plugins/listInputFieldChoices/index.d.ts.map +1 -0
  28. package/dist/plugins/listInputFieldChoices/index.js +78 -0
  29. package/dist/plugins/listInputFieldChoices/index.test.d.ts +2 -0
  30. package/dist/plugins/listInputFieldChoices/index.test.d.ts.map +1 -0
  31. package/dist/plugins/listInputFieldChoices/index.test.js +537 -0
  32. package/dist/plugins/listInputFieldChoices/schemas.d.ts +61 -0
  33. package/dist/plugins/listInputFieldChoices/schemas.d.ts.map +1 -0
  34. package/dist/plugins/listInputFieldChoices/schemas.js +73 -0
  35. package/dist/plugins/registry/index.js +3 -3
  36. package/dist/sdk.d.ts +93 -0
  37. package/dist/sdk.d.ts.map +1 -1
  38. package/dist/sdk.js +7 -2
  39. package/package.json +1 -1
  40. package/src/api/schemas.ts +62 -0
  41. package/src/api/types.ts +14 -0
  42. package/src/index.ts +25 -1
  43. package/src/plugins/findFirstAuthentication/index.test.ts +3 -3
  44. package/src/plugins/findFirstAuthentication/schemas.ts +1 -1
  45. package/src/plugins/findUniqueAuthentication/index.test.ts +3 -3
  46. package/src/plugins/findUniqueAuthentication/schemas.ts +1 -1
  47. package/src/plugins/getProfile/index.ts +1 -1
  48. package/src/plugins/listAuthentications/index.test.ts +5 -5
  49. package/src/plugins/listAuthentications/index.ts +2 -3
  50. package/src/plugins/listAuthentications/schemas.ts +1 -1
  51. package/src/plugins/listInputFieldChoices/index.test.ts +653 -0
  52. package/src/plugins/listInputFieldChoices/index.ts +152 -0
  53. package/src/plugins/listInputFieldChoices/schemas.ts +139 -0
  54. package/src/plugins/registry/index.ts +3 -3
  55. package/src/sdk.ts +8 -1
  56. package/tsconfig.tsbuildinfo +1 -1
@@ -0,0 +1,653 @@
1
+ import { describe, it, expect, vi, beforeEach } from "vitest";
2
+ import { ZapierValidationError, ZapierApiError } from "../../types/errors";
3
+ import { listInputFieldChoicesPlugin } from "./index";
4
+ import { createSdk } from "../../sdk";
5
+ import type { ApiClient } from "../../api";
6
+ import type { ListInputFieldChoicesOptions } from "./schemas";
7
+ import type { NeedChoicesResponse, NeedChoices } from "../../api/types";
8
+ import { GetActionSchema } from "../getAction/schemas";
9
+
10
+ const mockChoices: NeedChoices[] = [
11
+ {
12
+ key: "general",
13
+ label: "General Channel",
14
+ sample: "#general",
15
+ value: "general",
16
+ },
17
+ {
18
+ key: "random",
19
+ label: "Random Channel",
20
+ sample: "#random",
21
+ value: "random",
22
+ },
23
+ {
24
+ key: "dev",
25
+ label: "Development Channel",
26
+ sample: "#dev",
27
+ value: "dev",
28
+ },
29
+ ];
30
+
31
+ const mockChoicesResponse: NeedChoicesResponse = {
32
+ success: true,
33
+ choices: mockChoices,
34
+ };
35
+
36
+ const mockPaginatedChoicesResponse: NeedChoicesResponse = {
37
+ success: true,
38
+ choices: mockChoices.slice(0, 2),
39
+ next_page: 1,
40
+ };
41
+
42
+ const mockExternalChoicesResponse: NeedChoicesResponse = {
43
+ success: true,
44
+ choices: mockChoices,
45
+ meta: { page: "0" },
46
+ links: {
47
+ next: "https://api.zapier.com/api/v4/implementations/choices/?page=1",
48
+ prev: null,
49
+ },
50
+ };
51
+
52
+ describe("listInputFieldChoices plugin", () => {
53
+ let mockApiClient: ApiClient;
54
+ let mockGetAction: any;
55
+
56
+ beforeEach(() => {
57
+ vi.clearAllMocks();
58
+ mockApiClient = {
59
+ post: vi.fn().mockResolvedValue(mockChoicesResponse),
60
+ } as Partial<ApiClient> as ApiClient;
61
+
62
+ mockGetAction = vi.fn().mockResolvedValue({
63
+ data: { id: "core:123", key: "send_message", action_type: "read" },
64
+ });
65
+ });
66
+
67
+ function createTestSdk() {
68
+ // Create a mock getAction plugin
69
+ const mockGetActionPlugin = () => ({
70
+ getAction: mockGetAction,
71
+ context: {
72
+ meta: {
73
+ getAction: {
74
+ inputSchema: GetActionSchema,
75
+ },
76
+ },
77
+ },
78
+ });
79
+
80
+ // Build SDK with proper plugin composition
81
+ return createSdk({}, {}, { api: mockApiClient, meta: {} })
82
+ .addPlugin(mockGetActionPlugin)
83
+ .addPlugin(listInputFieldChoicesPlugin as any);
84
+ }
85
+
86
+ describe("schema validation", () => {
87
+ it("should throw validation error for missing inputFieldKey", async () => {
88
+ const sdk = createTestSdk();
89
+
90
+ try {
91
+ await sdk.listInputFieldChoices({
92
+ appKey: "slack",
93
+ actionType: "read",
94
+ actionKey: "send_message",
95
+ // Missing inputFieldKey
96
+ } as ListInputFieldChoicesOptions);
97
+ expect.fail("Expected ZapierValidationError to be thrown");
98
+ } catch (error) {
99
+ expect(error).toBeInstanceOf(ZapierValidationError);
100
+ }
101
+ });
102
+
103
+ it("should throw validation error for missing actionKey", async () => {
104
+ const sdk = createTestSdk();
105
+
106
+ try {
107
+ await sdk.listInputFieldChoices({
108
+ appKey: "slack",
109
+ actionType: "read",
110
+ inputFieldKey: "channel",
111
+ // Missing actionKey
112
+ } as ListInputFieldChoicesOptions);
113
+ expect.fail("Expected ZapierValidationError to be thrown");
114
+ } catch (error) {
115
+ expect(error).toBeInstanceOf(ZapierValidationError);
116
+ }
117
+ });
118
+
119
+ it("should pass validation with action method", async () => {
120
+ const sdk = createTestSdk();
121
+ const result = await sdk.listInputFieldChoices({
122
+ appKey: "slack",
123
+ actionType: "read",
124
+ actionKey: "send_message",
125
+ inputFieldKey: "channel",
126
+ });
127
+
128
+ expect(result.data).toBeDefined();
129
+ });
130
+
131
+ it("should pass validation with optional fields", async () => {
132
+ const sdk = createTestSdk();
133
+ const result = await sdk.listInputFieldChoices({
134
+ appKey: "slack",
135
+ actionType: "read",
136
+ actionKey: "send_message",
137
+ inputFieldKey: "channel",
138
+ authenticationId: 456,
139
+ inputs: { workspace: "my-team" },
140
+ page: 0,
141
+ });
142
+
143
+ expect(result.data).toBeDefined();
144
+ });
145
+
146
+ it("should throw validation error for empty string actionKey", async () => {
147
+ const sdk = createTestSdk();
148
+
149
+ try {
150
+ await sdk.listInputFieldChoices({
151
+ appKey: "slack",
152
+ actionType: "read",
153
+ actionKey: "", // Empty string
154
+ inputFieldKey: "channel",
155
+ } as ListInputFieldChoicesOptions);
156
+ expect.fail("Expected ZapierValidationError to be thrown");
157
+ } catch (error) {
158
+ expect(error).toBeInstanceOf(ZapierValidationError);
159
+ }
160
+ });
161
+
162
+ it("should throw validation error for empty string inputFieldKey", async () => {
163
+ const sdk = createTestSdk();
164
+
165
+ try {
166
+ await sdk.listInputFieldChoices({
167
+ appKey: "slack",
168
+ actionType: "read",
169
+ actionKey: "send_message",
170
+ inputFieldKey: "", // Empty string
171
+ } as ListInputFieldChoicesOptions);
172
+ expect.fail("Expected ZapierValidationError to be thrown");
173
+ } catch (error) {
174
+ expect(error).toBeInstanceOf(ZapierValidationError);
175
+ }
176
+ });
177
+ });
178
+
179
+ describe("API integration - action method", () => {
180
+ it("should call the correct API endpoint with action method", async () => {
181
+ const sdk = createTestSdk();
182
+ await sdk.listInputFieldChoices({
183
+ appKey: "slack",
184
+ actionType: "read",
185
+ actionKey: "send_message",
186
+ inputFieldKey: "channel",
187
+ });
188
+
189
+ expect(mockGetAction).toHaveBeenCalledWith({
190
+ appKey: "slack",
191
+ actionType: "read",
192
+ actionKey: "send_message",
193
+ });
194
+ expect(mockApiClient.post).toHaveBeenCalledWith(
195
+ "/api/v4/implementations/choices/",
196
+ {
197
+ action_id: "core:123",
198
+ input_field_id: "channel",
199
+ page: 0,
200
+ params: {},
201
+ },
202
+ );
203
+ });
204
+
205
+ it("should include authentication_id when provided", async () => {
206
+ const sdk = createTestSdk();
207
+ await sdk.listInputFieldChoices({
208
+ appKey: "slack",
209
+ actionType: "read",
210
+ actionKey: "send_message",
211
+ inputFieldKey: "channel",
212
+ authenticationId: 456,
213
+ });
214
+
215
+ expect(mockApiClient.post).toHaveBeenCalledWith(
216
+ "/api/v4/implementations/choices/",
217
+ {
218
+ action_id: "core:123",
219
+ input_field_id: "channel",
220
+ authentication_id: 456,
221
+ page: 0,
222
+ params: {},
223
+ },
224
+ );
225
+ });
226
+
227
+ it("should exclude authentication_id when null", async () => {
228
+ const sdk = createTestSdk();
229
+ await sdk.listInputFieldChoices({
230
+ appKey: "slack",
231
+ actionType: "read",
232
+ actionKey: "send_message",
233
+ inputFieldKey: "channel",
234
+ authenticationId: null,
235
+ });
236
+
237
+ expect(mockApiClient.post).toHaveBeenCalledWith(
238
+ "/api/v4/implementations/choices/",
239
+ {
240
+ action_id: "core:123",
241
+ input_field_id: "channel",
242
+ page: 0,
243
+ params: {},
244
+ // No authentication_id
245
+ },
246
+ );
247
+ });
248
+
249
+ it("should include inputs when provided", async () => {
250
+ const sdk = createTestSdk();
251
+ const inputs = { workspace: "my-team", board: "project" };
252
+
253
+ await sdk.listInputFieldChoices({
254
+ appKey: "slack",
255
+ actionType: "read",
256
+ actionKey: "send_message",
257
+ inputFieldKey: "channel",
258
+ inputs,
259
+ });
260
+
261
+ expect(mockApiClient.post).toHaveBeenCalledWith(
262
+ "/api/v4/implementations/choices/",
263
+ {
264
+ action_id: "core:123",
265
+ input_field_id: "channel",
266
+ page: 0,
267
+ params: inputs,
268
+ },
269
+ );
270
+ });
271
+
272
+ it("should include page when provided", async () => {
273
+ const sdk = createTestSdk();
274
+
275
+ await sdk.listInputFieldChoices({
276
+ appKey: "slack",
277
+ actionType: "read",
278
+ actionKey: "send_message",
279
+ inputFieldKey: "channel",
280
+ page: 2,
281
+ });
282
+
283
+ expect(mockApiClient.post).toHaveBeenCalledWith(
284
+ "/api/v4/implementations/choices/",
285
+ {
286
+ action_id: "core:123",
287
+ input_field_id: "channel",
288
+ page: 2,
289
+ params: {},
290
+ },
291
+ );
292
+ });
293
+ });
294
+
295
+ describe("data transformation", () => {
296
+ it("should transform choices to input field choice items correctly", async () => {
297
+ const sdk = createTestSdk();
298
+ const result = await sdk.listInputFieldChoices({
299
+ appKey: "slack",
300
+ actionType: "read",
301
+ actionKey: "send_message",
302
+ inputFieldKey: "channel",
303
+ });
304
+
305
+ expect(result.data).toHaveLength(3);
306
+
307
+ // Check first choice transformation
308
+ expect(result.data[0]).toEqual({
309
+ key: "general",
310
+ label: "General Channel",
311
+ sample: "#general",
312
+ value: "general",
313
+ });
314
+
315
+ // Check second choice transformation
316
+ expect(result.data[1]).toEqual({
317
+ key: "random",
318
+ label: "Random Channel",
319
+ sample: "#random",
320
+ value: "random",
321
+ });
322
+ });
323
+
324
+ it("should handle choices with missing fields gracefully", async () => {
325
+ const sparseChoices: NeedChoices[] = [
326
+ { key: "item1", label: "Item 1" },
327
+ { value: "item2", sample: "item2" },
328
+ { label: "Item 3" },
329
+ ];
330
+
331
+ mockApiClient.post = vi.fn().mockResolvedValue({
332
+ success: true,
333
+ choices: sparseChoices,
334
+ });
335
+
336
+ const sdk = createTestSdk();
337
+ const result = await sdk.listInputFieldChoices({
338
+ appKey: "slack",
339
+ actionType: "read",
340
+ actionKey: "send_message",
341
+ inputFieldKey: "item",
342
+ });
343
+
344
+ expect(result.data).toHaveLength(3);
345
+ expect(result.data[0]).toEqual({
346
+ key: "item1",
347
+ label: "Item 1",
348
+ sample: undefined,
349
+ value: undefined,
350
+ });
351
+ expect(result.data[1]).toEqual({
352
+ key: undefined,
353
+ label: undefined,
354
+ sample: "item2",
355
+ value: "item2",
356
+ });
357
+ });
358
+ });
359
+
360
+ describe("pagination handling", () => {
361
+ it("should handle next_page pagination correctly in the plugin", async () => {
362
+ mockApiClient.post = vi
363
+ .fn()
364
+ .mockResolvedValue(mockPaginatedChoicesResponse);
365
+
366
+ const sdk = createTestSdk();
367
+
368
+ // Test that the plugin correctly sets nextCursor when next_page is present
369
+ const listChoicesResult = sdk.listInputFieldChoices({
370
+ appKey: "slack",
371
+ actionType: "read",
372
+ actionKey: "send_message",
373
+ inputFieldKey: "channel",
374
+ pageSize: 2, // Set a small page size to test pagination behavior
375
+ });
376
+
377
+ const pages = [];
378
+ for await (const page of listChoicesResult) {
379
+ pages.push(page);
380
+ break; // Just get first page for testing
381
+ }
382
+
383
+ expect(pages).toHaveLength(1);
384
+ expect(pages[0].nextCursor).toBe("1");
385
+ });
386
+
387
+ it("should handle external action link-based pagination correctly in the plugin", async () => {
388
+ mockApiClient.post = vi
389
+ .fn()
390
+ .mockResolvedValue(mockExternalChoicesResponse);
391
+
392
+ const sdk = createTestSdk();
393
+
394
+ // Test that the plugin correctly extracts cursor from links.next
395
+ const listChoicesResult = sdk.listInputFieldChoices({
396
+ appKey: "slack",
397
+ actionType: "read",
398
+ actionKey: "send_message",
399
+ inputFieldKey: "option",
400
+ pageSize: 3, // Set a small page size to test pagination behavior
401
+ });
402
+
403
+ const pages = [];
404
+ for await (const page of listChoicesResult) {
405
+ pages.push(page);
406
+ break; // Just get first page for testing
407
+ }
408
+
409
+ expect(pages).toHaveLength(1);
410
+ expect(pages[0].nextCursor).toBe("1"); // Extracted from links.next URL
411
+ });
412
+
413
+ it("should handle no pagination", async () => {
414
+ const sdk = createTestSdk();
415
+ const listChoicesResult = sdk.listInputFieldChoices({
416
+ appKey: "slack",
417
+ actionType: "read",
418
+ actionKey: "send_message",
419
+ inputFieldKey: "channel",
420
+ });
421
+
422
+ const pages = [];
423
+ for await (const page of listChoicesResult) {
424
+ pages.push(page);
425
+ break; // Just get first page for testing
426
+ }
427
+
428
+ expect(pages).toHaveLength(1);
429
+ expect(pages[0].nextCursor).toBeUndefined();
430
+ });
431
+
432
+ it("should support async iteration over individual items", async () => {
433
+ const sdk = createTestSdk();
434
+ const listChoicesResult = sdk.listInputFieldChoices({
435
+ appKey: "slack",
436
+ actionType: "read",
437
+ actionKey: "send_message",
438
+ inputFieldKey: "channel",
439
+ });
440
+
441
+ const items = [];
442
+ for await (const item of listChoicesResult.items()) {
443
+ items.push(item);
444
+ }
445
+
446
+ expect(items).toHaveLength(3);
447
+ expect(items[0].key).toBe("general");
448
+ });
449
+
450
+ it("should handle malformed links.next URL gracefully", async () => {
451
+ const malformedExternalResponse: NeedChoicesResponse = {
452
+ success: true,
453
+ choices: mockChoices,
454
+ links: {
455
+ next: "invalid-url-format", // Malformed URL
456
+ prev: null,
457
+ },
458
+ };
459
+
460
+ mockApiClient.post = vi.fn().mockResolvedValue(malformedExternalResponse);
461
+
462
+ const sdk = createTestSdk();
463
+ const listChoicesResult = sdk.listInputFieldChoices({
464
+ appKey: "slack",
465
+ actionType: "read",
466
+ actionKey: "send_message",
467
+ inputFieldKey: "option",
468
+ });
469
+
470
+ const pages = [];
471
+ for await (const page of listChoicesResult) {
472
+ pages.push(page);
473
+ break;
474
+ }
475
+
476
+ expect(pages).toHaveLength(1);
477
+ expect(pages[0].nextCursor).toBeUndefined(); // Should handle gracefully
478
+ });
479
+
480
+ it("should handle links.next URL without page parameter", async () => {
481
+ const noPageResponse: NeedChoicesResponse = {
482
+ success: true,
483
+ choices: mockChoices,
484
+ links: {
485
+ next: "https://api.zapier.com/api/v4/implementations/choices/", // No page param
486
+ prev: null,
487
+ },
488
+ };
489
+
490
+ mockApiClient.post = vi.fn().mockResolvedValue(noPageResponse);
491
+
492
+ const sdk = createTestSdk();
493
+ const listChoicesResult = sdk.listInputFieldChoices({
494
+ appKey: "slack",
495
+ actionType: "read",
496
+ actionKey: "send_message",
497
+ inputFieldKey: "option",
498
+ });
499
+
500
+ const pages = [];
501
+ for await (const page of listChoicesResult) {
502
+ pages.push(page);
503
+ break;
504
+ }
505
+
506
+ expect(pages).toHaveLength(1);
507
+ expect(pages[0].nextCursor).toBeUndefined();
508
+ });
509
+ });
510
+
511
+ describe("error handling", () => {
512
+ it("should throw ZapierApiError when API response indicates failure", async () => {
513
+ mockApiClient.post = vi.fn().mockResolvedValue({
514
+ success: false,
515
+ errors: ["Invalid field", "Missing authentication"],
516
+ });
517
+
518
+ const sdk = createTestSdk();
519
+ await expect(
520
+ sdk.listInputFieldChoices({
521
+ appKey: "slack",
522
+ actionType: "read",
523
+ actionKey: "send_message",
524
+ inputFieldKey: "invalid_field",
525
+ }),
526
+ ).rejects.toThrow(ZapierApiError);
527
+
528
+ await expect(
529
+ sdk.listInputFieldChoices({
530
+ appKey: "slack",
531
+ actionType: "read",
532
+ actionKey: "send_message",
533
+ inputFieldKey: "invalid_field",
534
+ }),
535
+ ).rejects.toThrow(
536
+ "Failed to get input field choices: Invalid field, Missing authentication",
537
+ );
538
+ });
539
+
540
+ it("should handle API errors gracefully", async () => {
541
+ mockApiClient.post = vi
542
+ .fn()
543
+ .mockRejectedValue(new Error("Network error"));
544
+
545
+ const sdk = createTestSdk();
546
+ await expect(
547
+ sdk.listInputFieldChoices({
548
+ appKey: "slack",
549
+ actionType: "read",
550
+ actionKey: "send_message",
551
+ inputFieldKey: "channel",
552
+ }),
553
+ ).rejects.toThrow("Network error");
554
+ });
555
+
556
+ it("should handle empty choices array response", async () => {
557
+ mockApiClient.post = vi.fn().mockResolvedValue({
558
+ success: true,
559
+ choices: [], // Empty choices
560
+ });
561
+
562
+ const sdk = createTestSdk();
563
+ const result = await sdk.listInputFieldChoices({
564
+ appKey: "slack",
565
+ actionType: "read",
566
+ actionKey: "send_message",
567
+ inputFieldKey: "channel",
568
+ });
569
+
570
+ expect(result.data).toEqual([]);
571
+ });
572
+
573
+ it("should handle missing choices field in response", async () => {
574
+ mockApiClient.post = vi.fn().mockResolvedValue({
575
+ success: true,
576
+ // Missing choices field
577
+ });
578
+
579
+ const sdk = createTestSdk();
580
+ const result = await sdk.listInputFieldChoices({
581
+ appKey: "slack",
582
+ actionType: "read",
583
+ actionKey: "send_message",
584
+ inputFieldKey: "channel",
585
+ });
586
+
587
+ expect(result.data).toEqual([]);
588
+ });
589
+
590
+ it("should treat missing success field as failure", async () => {
591
+ mockApiClient.post = vi.fn().mockResolvedValue({
592
+ // Missing success field (undefined)
593
+ choices: mockChoices,
594
+ });
595
+
596
+ const sdk = createTestSdk();
597
+ await expect(
598
+ sdk.listInputFieldChoices({
599
+ appKey: "slack",
600
+ actionType: "read",
601
+ actionKey: "send_message",
602
+ inputFieldKey: "channel",
603
+ }),
604
+ ).rejects.toThrow("Failed to get input field choices: Unknown error");
605
+ });
606
+
607
+ it("should handle API response with errors but no error messages", async () => {
608
+ mockApiClient.post = vi.fn().mockResolvedValue({
609
+ success: false,
610
+ // Missing errors field
611
+ });
612
+
613
+ const sdk = createTestSdk();
614
+ await expect(
615
+ sdk.listInputFieldChoices({
616
+ appKey: "slack",
617
+ actionType: "read",
618
+ actionKey: "send_message",
619
+ inputFieldKey: "channel",
620
+ }),
621
+ ).rejects.toThrow("Failed to get input field choices: Unknown error");
622
+ });
623
+
624
+ it("should handle API response with empty errors array", async () => {
625
+ mockApiClient.post = vi.fn().mockResolvedValue({
626
+ success: false,
627
+ errors: [], // Empty errors array
628
+ });
629
+
630
+ const sdk = createTestSdk();
631
+ await expect(
632
+ sdk.listInputFieldChoices({
633
+ appKey: "slack",
634
+ actionType: "read",
635
+ actionKey: "send_message",
636
+ inputFieldKey: "channel",
637
+ }),
638
+ ).rejects.toThrow("Failed to get input field choices: Unknown error");
639
+ });
640
+ });
641
+
642
+ describe("context and metadata", () => {
643
+ it("should provide context with meta information", () => {
644
+ const sdk = createTestSdk();
645
+ const context = sdk.getContext();
646
+
647
+ expect((context.meta as any).listInputFieldChoices).toBeDefined();
648
+ expect(
649
+ (context.meta as any).listInputFieldChoices.inputSchema,
650
+ ).toBeDefined();
651
+ });
652
+ });
653
+ });