@zapier/zapier-sdk 0.32.5 → 0.33.1

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 (129) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/auth.d.ts.map +1 -1
  3. package/dist/auth.js +1 -0
  4. package/dist/constants.d.ts +0 -14
  5. package/dist/constants.d.ts.map +1 -1
  6. package/dist/constants.js +0 -14
  7. package/dist/credentials.d.ts.map +1 -1
  8. package/dist/credentials.js +19 -20
  9. package/dist/index.cjs +22 -37
  10. package/dist/index.d.mts +1 -15
  11. package/dist/index.mjs +23 -30
  12. package/package.json +2 -2
  13. package/dist/api/auth.test.d.ts +0 -2
  14. package/dist/api/auth.test.d.ts.map +0 -1
  15. package/dist/api/auth.test.js +0 -220
  16. package/dist/api/client.test.d.ts +0 -2
  17. package/dist/api/client.test.d.ts.map +0 -1
  18. package/dist/api/client.test.js +0 -611
  19. package/dist/api/debug.test.d.ts +0 -2
  20. package/dist/api/debug.test.d.ts.map +0 -1
  21. package/dist/api/debug.test.js +0 -59
  22. package/dist/api/polling.test.d.ts +0 -2
  23. package/dist/api/polling.test.d.ts.map +0 -1
  24. package/dist/api/polling.test.js +0 -360
  25. package/dist/auth.test.d.ts +0 -2
  26. package/dist/auth.test.d.ts.map +0 -1
  27. package/dist/auth.test.js +0 -480
  28. package/dist/plugins/eventEmission/builders.test.d.ts +0 -2
  29. package/dist/plugins/eventEmission/builders.test.d.ts.map +0 -1
  30. package/dist/plugins/eventEmission/builders.test.js +0 -138
  31. package/dist/plugins/eventEmission/index.test.d.ts +0 -5
  32. package/dist/plugins/eventEmission/index.test.d.ts.map +0 -1
  33. package/dist/plugins/eventEmission/index.test.js +0 -704
  34. package/dist/plugins/eventEmission/transport.test.d.ts +0 -5
  35. package/dist/plugins/eventEmission/transport.test.d.ts.map +0 -1
  36. package/dist/plugins/eventEmission/transport.test.js +0 -164
  37. package/dist/plugins/fetch/index.test.d.ts +0 -2
  38. package/dist/plugins/fetch/index.test.d.ts.map +0 -1
  39. package/dist/plugins/fetch/index.test.js +0 -428
  40. package/dist/plugins/findFirstConnection/index.test.d.ts +0 -2
  41. package/dist/plugins/findFirstConnection/index.test.d.ts.map +0 -1
  42. package/dist/plugins/findFirstConnection/index.test.js +0 -177
  43. package/dist/plugins/findUniqueConnection/index.test.d.ts +0 -2
  44. package/dist/plugins/findUniqueConnection/index.test.d.ts.map +0 -1
  45. package/dist/plugins/findUniqueConnection/index.test.js +0 -159
  46. package/dist/plugins/getAction/index.test.d.ts +0 -2
  47. package/dist/plugins/getAction/index.test.d.ts.map +0 -1
  48. package/dist/plugins/getAction/index.test.js +0 -211
  49. package/dist/plugins/getApp/index.test.d.ts +0 -2
  50. package/dist/plugins/getApp/index.test.d.ts.map +0 -1
  51. package/dist/plugins/getApp/index.test.js +0 -157
  52. package/dist/plugins/getConnection/index.test.d.ts +0 -2
  53. package/dist/plugins/getConnection/index.test.d.ts.map +0 -1
  54. package/dist/plugins/getConnection/index.test.js +0 -124
  55. package/dist/plugins/getInputFieldsSchema/index.test.d.ts +0 -2
  56. package/dist/plugins/getInputFieldsSchema/index.test.d.ts.map +0 -1
  57. package/dist/plugins/getInputFieldsSchema/index.test.js +0 -291
  58. package/dist/plugins/listActions/index.test.d.ts +0 -2
  59. package/dist/plugins/listActions/index.test.d.ts.map +0 -1
  60. package/dist/plugins/listActions/index.test.js +0 -454
  61. package/dist/plugins/listApps/index.test.d.ts +0 -2
  62. package/dist/plugins/listApps/index.test.d.ts.map +0 -1
  63. package/dist/plugins/listApps/index.test.js +0 -124
  64. package/dist/plugins/listConnections/index.test.d.ts +0 -2
  65. package/dist/plugins/listConnections/index.test.d.ts.map +0 -1
  66. package/dist/plugins/listConnections/index.test.js +0 -920
  67. package/dist/plugins/listInputFieldChoices/index.test.d.ts +0 -2
  68. package/dist/plugins/listInputFieldChoices/index.test.d.ts.map +0 -1
  69. package/dist/plugins/listInputFieldChoices/index.test.js +0 -717
  70. package/dist/plugins/listInputFields/index.test.d.ts +0 -2
  71. package/dist/plugins/listInputFields/index.test.d.ts.map +0 -1
  72. package/dist/plugins/listInputFields/index.test.js +0 -359
  73. package/dist/plugins/manifest/index.test.d.ts +0 -2
  74. package/dist/plugins/manifest/index.test.d.ts.map +0 -1
  75. package/dist/plugins/manifest/index.test.js +0 -1179
  76. package/dist/plugins/request/index.test.d.ts +0 -2
  77. package/dist/plugins/request/index.test.d.ts.map +0 -1
  78. package/dist/plugins/request/index.test.js +0 -458
  79. package/dist/plugins/runAction/index.test.d.ts +0 -2
  80. package/dist/plugins/runAction/index.test.d.ts.map +0 -1
  81. package/dist/plugins/runAction/index.test.js +0 -350
  82. package/dist/resolvers/connectionId.test.d.ts +0 -2
  83. package/dist/resolvers/connectionId.test.d.ts.map +0 -1
  84. package/dist/resolvers/connectionId.test.js +0 -61
  85. package/dist/sdk.test.d.ts +0 -2
  86. package/dist/sdk.test.d.ts.map +0 -1
  87. package/dist/sdk.test.js +0 -260
  88. package/dist/types/domain.test.d.ts +0 -2
  89. package/dist/types/domain.test.d.ts.map +0 -1
  90. package/dist/types/domain.test.js +0 -39
  91. package/dist/utils/array-utils.test.d.ts +0 -2
  92. package/dist/utils/array-utils.test.d.ts.map +0 -1
  93. package/dist/utils/array-utils.test.js +0 -107
  94. package/dist/utils/batch-utils.test.d.ts +0 -2
  95. package/dist/utils/batch-utils.test.d.ts.map +0 -1
  96. package/dist/utils/batch-utils.test.js +0 -476
  97. package/dist/utils/domain-utils.test.d.ts +0 -2
  98. package/dist/utils/domain-utils.test.d.ts.map +0 -1
  99. package/dist/utils/domain-utils.test.js +0 -346
  100. package/dist/utils/file-utils.test.d.ts +0 -2
  101. package/dist/utils/file-utils.test.d.ts.map +0 -1
  102. package/dist/utils/file-utils.test.js +0 -51
  103. package/dist/utils/function-utils.test.d.ts +0 -2
  104. package/dist/utils/function-utils.test.d.ts.map +0 -1
  105. package/dist/utils/function-utils.test.js +0 -188
  106. package/dist/utils/id-utils.test.d.ts +0 -2
  107. package/dist/utils/id-utils.test.d.ts.map +0 -1
  108. package/dist/utils/id-utils.test.js +0 -22
  109. package/dist/utils/pagination-utils.test.d.ts +0 -17
  110. package/dist/utils/pagination-utils.test.d.ts.map +0 -1
  111. package/dist/utils/pagination-utils.test.js +0 -461
  112. package/dist/utils/retry-utils.test.d.ts +0 -2
  113. package/dist/utils/retry-utils.test.d.ts.map +0 -1
  114. package/dist/utils/retry-utils.test.js +0 -90
  115. package/dist/utils/string-utils.test.d.ts +0 -2
  116. package/dist/utils/string-utils.test.d.ts.map +0 -1
  117. package/dist/utils/string-utils.test.js +0 -59
  118. package/dist/utils/telemetry-context.test.d.ts +0 -2
  119. package/dist/utils/telemetry-context.test.d.ts.map +0 -1
  120. package/dist/utils/telemetry-context.test.js +0 -154
  121. package/dist/utils/telemetry-utils.test.d.ts +0 -2
  122. package/dist/utils/telemetry-utils.test.d.ts.map +0 -1
  123. package/dist/utils/telemetry-utils.test.js +0 -155
  124. package/dist/utils/url-utils.test.d.ts +0 -2
  125. package/dist/utils/url-utils.test.d.ts.map +0 -1
  126. package/dist/utils/url-utils.test.js +0 -103
  127. package/dist/utils/validation.test.d.ts +0 -2
  128. package/dist/utils/validation.test.d.ts.map +0 -1
  129. package/dist/utils/validation.test.js +0 -44
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=index.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../../src/plugins/listInputFields/index.test.ts"],"names":[],"mappings":""}
@@ -1,359 +0,0 @@
1
- import { describe, it, expect, vi, beforeEach } from "vitest";
2
- import { ZapierValidationError, ZapierConfigurationError, ZapierApiError, } from "../../types/errors";
3
- import { listInputFieldsPlugin } from "./index";
4
- import { getActionPlugin } from "../getAction";
5
- import { getAppPlugin } from "../getApp";
6
- import { listActionsPlugin } from "../listActions";
7
- import { listAppsPlugin } from "../listApps";
8
- import { createSdk } from "../../sdk";
9
- import { eventEmissionPlugin } from "../eventEmission";
10
- const mockNeeds = [
11
- {
12
- key: "message",
13
- label: "Message",
14
- help_text: "The message to send",
15
- required: true,
16
- type: "string",
17
- placeholder: "Enter your message",
18
- default: "",
19
- },
20
- {
21
- key: "channel",
22
- label: "Channel",
23
- help_text: "The channel to send to",
24
- required: true,
25
- type: "string",
26
- choices: [
27
- { value: "#general", label: "General", sample: "#general" },
28
- { value: "#random", label: "Random", sample: "#random" },
29
- ],
30
- },
31
- {
32
- key: "tags",
33
- label: "Tags",
34
- help_text: "List of tags",
35
- type: "string",
36
- list: true,
37
- },
38
- ];
39
- const mockNeedsResponse = {
40
- success: true,
41
- needs: mockNeeds,
42
- };
43
- const mockActionsResponse = {
44
- results: [
45
- {
46
- slug: "slack",
47
- selected_api: "slack",
48
- actions: [
49
- {
50
- key: "send_message",
51
- name: "Send Message",
52
- description: "Send a message to a channel",
53
- type_of: "write",
54
- type: "write",
55
- id: "core:12345",
56
- },
57
- ],
58
- },
59
- ],
60
- meta: {
61
- next_cursor: null,
62
- },
63
- };
64
- describe("listInputFields plugin", () => {
65
- let mockApiClient;
66
- let mockGetVersionedImplementationId;
67
- beforeEach(() => {
68
- vi.clearAllMocks();
69
- mockApiClient = {
70
- get: vi.fn().mockResolvedValue(mockActionsResponse),
71
- post: vi.fn().mockResolvedValue(mockNeedsResponse),
72
- };
73
- mockGetVersionedImplementationId = vi
74
- .fn()
75
- .mockResolvedValue("SlackCLIAPI@1.21.1");
76
- });
77
- function createTestSdk() {
78
- return createSdk({}, {}, {
79
- api: mockApiClient,
80
- meta: {},
81
- options: {},
82
- getVersionedImplementationId: mockGetVersionedImplementationId,
83
- })
84
- .addPlugin(eventEmissionPlugin)
85
- .addPlugin(listAppsPlugin)
86
- .addPlugin(listActionsPlugin)
87
- .addPlugin(getAppPlugin)
88
- .addPlugin(getActionPlugin)
89
- .addPlugin(listInputFieldsPlugin);
90
- }
91
- describe("schema validation", () => {
92
- it("should throw validation error for missing required fields", () => {
93
- const sdk = createTestSdk();
94
- expect(() => {
95
- sdk.listInputFields({
96
- // Missing required fields
97
- });
98
- }).toThrow(ZapierValidationError);
99
- });
100
- it("should throw validation error for invalid field types", () => {
101
- const sdk = createTestSdk();
102
- expect(() => {
103
- sdk.listInputFields({
104
- appKey: 123,
105
- actionType: "write",
106
- actionKey: "send_message",
107
- });
108
- }).toThrow(ZapierValidationError);
109
- });
110
- it("should pass validation with all required fields", async () => {
111
- const sdk = createTestSdk();
112
- const result = await sdk.listInputFields({
113
- appKey: "slack",
114
- actionType: "write",
115
- actionKey: "send_message",
116
- });
117
- expect(result.data).toBeDefined();
118
- });
119
- it("should pass validation with optional fields", async () => {
120
- const sdk = createTestSdk();
121
- const result = await sdk.listInputFields({
122
- appKey: "slack",
123
- actionType: "write",
124
- actionKey: "send_message",
125
- authenticationId: 123,
126
- inputs: { channel: "#general" },
127
- });
128
- expect(result.data).toBeDefined();
129
- });
130
- });
131
- describe("API integration", () => {
132
- it("should call the correct API endpoint", async () => {
133
- const sdk = createTestSdk();
134
- await sdk.listInputFields({
135
- appKey: "slack",
136
- actionType: "write",
137
- actionKey: "send_message",
138
- });
139
- expect(mockApiClient.post).toHaveBeenCalledWith("/zapier/api/v4/implementations/needs/", {
140
- selected_api: "SlackCLIAPI@1.21.1",
141
- action: "send_message",
142
- type_of: "write",
143
- params: {},
144
- });
145
- });
146
- it("should include authentication_id when provided", async () => {
147
- const sdk = createTestSdk();
148
- await sdk.listInputFields({
149
- appKey: "slack",
150
- actionType: "write",
151
- actionKey: "send_message",
152
- authenticationId: 123,
153
- });
154
- expect(mockApiClient.post).toHaveBeenCalledWith("/zapier/api/v4/implementations/needs/", {
155
- selected_api: "SlackCLIAPI@1.21.1",
156
- action: "send_message",
157
- type_of: "write",
158
- params: {},
159
- authentication_id: 123,
160
- });
161
- });
162
- it("should exclude authentication_id when null", async () => {
163
- const sdk = createTestSdk();
164
- await sdk.listInputFields({
165
- appKey: "slack",
166
- actionType: "write",
167
- actionKey: "send_message",
168
- authenticationId: null,
169
- });
170
- expect(mockApiClient.post).toHaveBeenCalledWith("/zapier/api/v4/implementations/needs/", {
171
- selected_api: "SlackCLIAPI@1.21.1",
172
- action: "send_message",
173
- type_of: "write",
174
- params: {},
175
- // No authentication_id
176
- });
177
- });
178
- it("should include inputs when provided", async () => {
179
- const sdk = createTestSdk();
180
- const inputs = { channel: "#general", message: "test" };
181
- await sdk.listInputFields({
182
- appKey: "slack",
183
- actionType: "write",
184
- actionKey: "send_message",
185
- inputs,
186
- });
187
- expect(mockApiClient.post).toHaveBeenCalledWith("/zapier/api/v4/implementations/needs/", {
188
- selected_api: "SlackCLIAPI@1.21.1",
189
- action: "send_message",
190
- type_of: "write",
191
- params: inputs,
192
- });
193
- });
194
- });
195
- describe("data transformation", () => {
196
- it("should transform needs to input field items correctly", async () => {
197
- const sdk = createTestSdk();
198
- const result = await sdk.listInputFields({
199
- appKey: "slack",
200
- actionType: "write",
201
- actionKey: "send_message",
202
- });
203
- expect(result.data).toHaveLength(3);
204
- // Check message field transformation
205
- expect(result.data[0]).toEqual(expect.objectContaining({
206
- key: "message",
207
- title: "Message",
208
- description: "The message to send",
209
- is_required: true,
210
- value_type: "STRING",
211
- placeholder: "Enter your message",
212
- default_value: "",
213
- }));
214
- // Check channel field with SELECT format (choices should NOT be exposed)
215
- expect(result.data[1]).toEqual(expect.objectContaining({
216
- key: "channel",
217
- title: "Channel",
218
- description: "The channel to send to",
219
- is_required: true,
220
- value_type: "STRING",
221
- format: "SELECT",
222
- }));
223
- // Verify choices are NOT exposed in listInputFields output
224
- expect(result.data[1]).not.toHaveProperty("choices");
225
- // Check array field
226
- expect(result.data[2]).toEqual(expect.objectContaining({
227
- key: "tags",
228
- title: "Tags",
229
- description: "List of tags",
230
- value_type: "ARRAY",
231
- items: { type: "STRING" },
232
- }));
233
- });
234
- it("should handle different field types correctly", async () => {
235
- const complexNeeds = [
236
- {
237
- key: "count",
238
- type: "integer",
239
- label: "Count",
240
- required: false,
241
- },
242
- {
243
- key: "price",
244
- type: "decimal",
245
- label: "Price",
246
- },
247
- {
248
- key: "enabled",
249
- type: "boolean",
250
- label: "Enabled",
251
- },
252
- {
253
- key: "config",
254
- type: "dict",
255
- label: "Configuration",
256
- },
257
- {
258
- key: "description",
259
- type: "text",
260
- label: "Description",
261
- },
262
- ];
263
- mockApiClient.post = vi.fn().mockResolvedValue({
264
- success: true,
265
- needs: complexNeeds,
266
- });
267
- const sdk = createTestSdk();
268
- const result = await sdk.listInputFields({
269
- appKey: "slack",
270
- actionType: "write",
271
- actionKey: "send_message",
272
- });
273
- expect(result.data[0].value_type).toBe("INTEGER");
274
- expect(result.data[1].value_type).toBe("NUMBER");
275
- expect(result.data[2].value_type).toBe("BOOLEAN");
276
- expect(result.data[3].value_type).toBe("OBJECT");
277
- expect(result.data[4].value_type).toBe("STRING");
278
- expect(result.data[4].format).toBe("MULTILINE");
279
- });
280
- });
281
- describe("error handling", () => {
282
- it("should throw ZapierConfigurationError when app has no current_implementation_id", async () => {
283
- mockGetVersionedImplementationId.mockResolvedValue(null);
284
- const sdk = createTestSdk();
285
- await expect(sdk.listInputFields({
286
- appKey: "invalid",
287
- actionType: "write",
288
- actionKey: "send_message",
289
- })).rejects.toThrow(ZapierConfigurationError);
290
- });
291
- it("should throw ZapierApiError when API response indicates failure", async () => {
292
- mockApiClient.post = vi.fn().mockResolvedValue({
293
- success: false,
294
- errors: ["Authentication failed", "Invalid credentials"],
295
- });
296
- const sdk = createTestSdk();
297
- await expect(sdk.listInputFields({
298
- appKey: "slack",
299
- actionType: "write",
300
- actionKey: "send_message", // Use valid action so we get to the POST call
301
- })).rejects.toThrow(ZapierApiError);
302
- await expect(sdk.listInputFields({
303
- appKey: "slack",
304
- actionType: "write",
305
- actionKey: "send_message", // Use valid action so we get to the POST call
306
- })).rejects.toThrow("Failed to get input fields: Authentication failed, Invalid credentials");
307
- });
308
- it("should handle API errors gracefully", async () => {
309
- mockApiClient.post = vi
310
- .fn()
311
- .mockRejectedValue(new Error("Network error"));
312
- const sdk = createTestSdk();
313
- await expect(sdk.listInputFields({
314
- appKey: "slack",
315
- actionType: "write",
316
- actionKey: "send_message",
317
- })).rejects.toThrow("Network error");
318
- });
319
- });
320
- describe("context and metadata", () => {
321
- it("should provide context with meta information", () => {
322
- const sdk = createTestSdk();
323
- const context = sdk.getContext();
324
- expect(context.meta.listInputFields).toBeDefined();
325
- expect(context.meta.listInputFields.inputSchema).toBeDefined();
326
- });
327
- });
328
- describe("pagination", () => {
329
- it("should support async iteration over pages", async () => {
330
- const sdk = createTestSdk();
331
- const listInputFieldsResult = sdk.listInputFields({
332
- appKey: "slack",
333
- actionType: "write",
334
- actionKey: "send_message",
335
- });
336
- const pages = [];
337
- for await (const page of listInputFieldsResult) {
338
- pages.push(page);
339
- break; // Just get first page for testing
340
- }
341
- expect(pages).toHaveLength(1);
342
- expect(pages[0].data).toHaveLength(3);
343
- });
344
- it("should support async iteration over individual items", async () => {
345
- const sdk = createTestSdk();
346
- const listInputFieldsResult = sdk.listInputFields({
347
- appKey: "slack",
348
- actionType: "write",
349
- actionKey: "send_message",
350
- });
351
- const items = [];
352
- for await (const item of listInputFieldsResult.items()) {
353
- items.push(item);
354
- }
355
- expect(items).toHaveLength(3);
356
- expect(items[0].key).toBe("message");
357
- });
358
- });
359
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=index.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../../src/plugins/manifest/index.test.ts"],"names":[],"mappings":""}