@zapier/zapier-sdk 0.33.0 → 0.33.2

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 (128) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/index.cjs +2 -1
  3. package/dist/index.d.mts +9 -1
  4. package/dist/index.d.ts +1 -1
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.mjs +2 -1
  7. package/dist/plugins/registry/index.d.ts.map +1 -1
  8. package/dist/plugins/registry/index.js +1 -0
  9. package/dist/types/sdk.d.ts +8 -0
  10. package/dist/types/sdk.d.ts.map +1 -1
  11. package/package.json +2 -2
  12. package/dist/api/auth.test.d.ts +0 -2
  13. package/dist/api/auth.test.d.ts.map +0 -1
  14. package/dist/api/auth.test.js +0 -220
  15. package/dist/api/client.test.d.ts +0 -2
  16. package/dist/api/client.test.d.ts.map +0 -1
  17. package/dist/api/client.test.js +0 -611
  18. package/dist/api/debug.test.d.ts +0 -2
  19. package/dist/api/debug.test.d.ts.map +0 -1
  20. package/dist/api/debug.test.js +0 -59
  21. package/dist/api/polling.test.d.ts +0 -2
  22. package/dist/api/polling.test.d.ts.map +0 -1
  23. package/dist/api/polling.test.js +0 -360
  24. package/dist/auth.test.d.ts +0 -2
  25. package/dist/auth.test.d.ts.map +0 -1
  26. package/dist/auth.test.js +0 -480
  27. package/dist/plugins/eventEmission/builders.test.d.ts +0 -2
  28. package/dist/plugins/eventEmission/builders.test.d.ts.map +0 -1
  29. package/dist/plugins/eventEmission/builders.test.js +0 -138
  30. package/dist/plugins/eventEmission/index.test.d.ts +0 -5
  31. package/dist/plugins/eventEmission/index.test.d.ts.map +0 -1
  32. package/dist/plugins/eventEmission/index.test.js +0 -712
  33. package/dist/plugins/eventEmission/transport.test.d.ts +0 -5
  34. package/dist/plugins/eventEmission/transport.test.d.ts.map +0 -1
  35. package/dist/plugins/eventEmission/transport.test.js +0 -164
  36. package/dist/plugins/fetch/index.test.d.ts +0 -2
  37. package/dist/plugins/fetch/index.test.d.ts.map +0 -1
  38. package/dist/plugins/fetch/index.test.js +0 -428
  39. package/dist/plugins/findFirstConnection/index.test.d.ts +0 -2
  40. package/dist/plugins/findFirstConnection/index.test.d.ts.map +0 -1
  41. package/dist/plugins/findFirstConnection/index.test.js +0 -177
  42. package/dist/plugins/findUniqueConnection/index.test.d.ts +0 -2
  43. package/dist/plugins/findUniqueConnection/index.test.d.ts.map +0 -1
  44. package/dist/plugins/findUniqueConnection/index.test.js +0 -159
  45. package/dist/plugins/getAction/index.test.d.ts +0 -2
  46. package/dist/plugins/getAction/index.test.d.ts.map +0 -1
  47. package/dist/plugins/getAction/index.test.js +0 -211
  48. package/dist/plugins/getApp/index.test.d.ts +0 -2
  49. package/dist/plugins/getApp/index.test.d.ts.map +0 -1
  50. package/dist/plugins/getApp/index.test.js +0 -157
  51. package/dist/plugins/getConnection/index.test.d.ts +0 -2
  52. package/dist/plugins/getConnection/index.test.d.ts.map +0 -1
  53. package/dist/plugins/getConnection/index.test.js +0 -124
  54. package/dist/plugins/getInputFieldsSchema/index.test.d.ts +0 -2
  55. package/dist/plugins/getInputFieldsSchema/index.test.d.ts.map +0 -1
  56. package/dist/plugins/getInputFieldsSchema/index.test.js +0 -291
  57. package/dist/plugins/listActions/index.test.d.ts +0 -2
  58. package/dist/plugins/listActions/index.test.d.ts.map +0 -1
  59. package/dist/plugins/listActions/index.test.js +0 -454
  60. package/dist/plugins/listApps/index.test.d.ts +0 -2
  61. package/dist/plugins/listApps/index.test.d.ts.map +0 -1
  62. package/dist/plugins/listApps/index.test.js +0 -124
  63. package/dist/plugins/listConnections/index.test.d.ts +0 -2
  64. package/dist/plugins/listConnections/index.test.d.ts.map +0 -1
  65. package/dist/plugins/listConnections/index.test.js +0 -920
  66. package/dist/plugins/listInputFieldChoices/index.test.d.ts +0 -2
  67. package/dist/plugins/listInputFieldChoices/index.test.d.ts.map +0 -1
  68. package/dist/plugins/listInputFieldChoices/index.test.js +0 -717
  69. package/dist/plugins/listInputFields/index.test.d.ts +0 -2
  70. package/dist/plugins/listInputFields/index.test.d.ts.map +0 -1
  71. package/dist/plugins/listInputFields/index.test.js +0 -359
  72. package/dist/plugins/manifest/index.test.d.ts +0 -2
  73. package/dist/plugins/manifest/index.test.d.ts.map +0 -1
  74. package/dist/plugins/manifest/index.test.js +0 -1179
  75. package/dist/plugins/request/index.test.d.ts +0 -2
  76. package/dist/plugins/request/index.test.d.ts.map +0 -1
  77. package/dist/plugins/request/index.test.js +0 -458
  78. package/dist/plugins/runAction/index.test.d.ts +0 -2
  79. package/dist/plugins/runAction/index.test.d.ts.map +0 -1
  80. package/dist/plugins/runAction/index.test.js +0 -350
  81. package/dist/resolvers/connectionId.test.d.ts +0 -2
  82. package/dist/resolvers/connectionId.test.d.ts.map +0 -1
  83. package/dist/resolvers/connectionId.test.js +0 -61
  84. package/dist/sdk.test.d.ts +0 -2
  85. package/dist/sdk.test.d.ts.map +0 -1
  86. package/dist/sdk.test.js +0 -260
  87. package/dist/types/domain.test.d.ts +0 -2
  88. package/dist/types/domain.test.d.ts.map +0 -1
  89. package/dist/types/domain.test.js +0 -39
  90. package/dist/utils/array-utils.test.d.ts +0 -2
  91. package/dist/utils/array-utils.test.d.ts.map +0 -1
  92. package/dist/utils/array-utils.test.js +0 -107
  93. package/dist/utils/batch-utils.test.d.ts +0 -2
  94. package/dist/utils/batch-utils.test.d.ts.map +0 -1
  95. package/dist/utils/batch-utils.test.js +0 -476
  96. package/dist/utils/domain-utils.test.d.ts +0 -2
  97. package/dist/utils/domain-utils.test.d.ts.map +0 -1
  98. package/dist/utils/domain-utils.test.js +0 -346
  99. package/dist/utils/file-utils.test.d.ts +0 -2
  100. package/dist/utils/file-utils.test.d.ts.map +0 -1
  101. package/dist/utils/file-utils.test.js +0 -51
  102. package/dist/utils/function-utils.test.d.ts +0 -2
  103. package/dist/utils/function-utils.test.d.ts.map +0 -1
  104. package/dist/utils/function-utils.test.js +0 -188
  105. package/dist/utils/id-utils.test.d.ts +0 -2
  106. package/dist/utils/id-utils.test.d.ts.map +0 -1
  107. package/dist/utils/id-utils.test.js +0 -22
  108. package/dist/utils/pagination-utils.test.d.ts +0 -17
  109. package/dist/utils/pagination-utils.test.d.ts.map +0 -1
  110. package/dist/utils/pagination-utils.test.js +0 -461
  111. package/dist/utils/retry-utils.test.d.ts +0 -2
  112. package/dist/utils/retry-utils.test.d.ts.map +0 -1
  113. package/dist/utils/retry-utils.test.js +0 -90
  114. package/dist/utils/string-utils.test.d.ts +0 -2
  115. package/dist/utils/string-utils.test.d.ts.map +0 -1
  116. package/dist/utils/string-utils.test.js +0 -59
  117. package/dist/utils/telemetry-context.test.d.ts +0 -2
  118. package/dist/utils/telemetry-context.test.d.ts.map +0 -1
  119. package/dist/utils/telemetry-context.test.js +0 -154
  120. package/dist/utils/telemetry-utils.test.d.ts +0 -2
  121. package/dist/utils/telemetry-utils.test.d.ts.map +0 -1
  122. package/dist/utils/telemetry-utils.test.js +0 -155
  123. package/dist/utils/url-utils.test.d.ts +0 -2
  124. package/dist/utils/url-utils.test.d.ts.map +0 -1
  125. package/dist/utils/url-utils.test.js +0 -103
  126. package/dist/utils/validation.test.d.ts +0 -2
  127. package/dist/utils/validation.test.d.ts.map +0 -1
  128. package/dist/utils/validation.test.js +0 -44
@@ -1,346 +0,0 @@
1
- import { describe, it, expect } from "vitest";
2
- import { groupVersionedAppKeysByType, groupAppKeysByType, toAppLocator, } from "./domain-utils";
3
- describe("domain-utils", () => {
4
- describe("groupVersionedAppKeysByType", () => {
5
- it("should reject UUID app keys", () => {
6
- expect(() => {
7
- groupVersionedAppKeysByType(["61e47557-af91-4b0c-a3e0-c28606357664"]);
8
- }).toThrow("UUID app keys are not supported. Use app slug or implementation ID instead of: 61e47557-af91-4b0c-a3e0-c28606357664");
9
- });
10
- it("should categorize *API as selectedApi", () => {
11
- const result = groupVersionedAppKeysByType(["FormatterCLIAPI"]);
12
- expect(result).toEqual({
13
- selectedApi: ["FormatterCLIAPI"],
14
- slug: [],
15
- });
16
- });
17
- it("should categorize various API types as selectedApi", () => {
18
- const result = groupVersionedAppKeysByType([
19
- "FormatterCLIAPI",
20
- "SlackAPI",
21
- "GmailRESTAPI",
22
- "WebhookAPI",
23
- "AnythingWithUppercase",
24
- ]);
25
- expect(result).toEqual({
26
- selectedApi: [
27
- "FormatterCLIAPI",
28
- "SlackAPI",
29
- "GmailRESTAPI",
30
- "WebhookAPI",
31
- "AnythingWithUppercase",
32
- ],
33
- slug: [],
34
- });
35
- });
36
- it("should categorize lower-case strings as slugs, converting underscores to dashes", () => {
37
- const result = groupVersionedAppKeysByType([
38
- "slack",
39
- "google-sheets",
40
- "_100hires_ats",
41
- "amazon_redshift",
42
- ]);
43
- expect(result).toEqual({
44
- selectedApi: [],
45
- slug: ["slack", "google-sheets", "100hires-ats", "amazon-redshift"],
46
- });
47
- });
48
- it("should preserve version from API implementations", () => {
49
- const result = groupVersionedAppKeysByType(["FormatterCLIAPI@1.0.0"]);
50
- expect(result).toEqual({
51
- selectedApi: ["FormatterCLIAPI@1.0.0"],
52
- slug: [],
53
- });
54
- });
55
- it("should preserve version from slugs", () => {
56
- const result = groupVersionedAppKeysByType(["slack@2.1.0"]);
57
- expect(result).toEqual({
58
- selectedApi: [],
59
- slug: ["slack@2.1.0"],
60
- });
61
- });
62
- it("should handle mixed types correctly", () => {
63
- const result = groupVersionedAppKeysByType([
64
- "FormatterCLIAPI@1.0.0",
65
- "slack",
66
- "AnotherAPI",
67
- "gmail@3.0.1",
68
- ]);
69
- expect(result).toEqual({
70
- selectedApi: ["FormatterCLIAPI@1.0.0", "AnotherAPI"],
71
- slug: ["slack", "gmail@3.0.1"],
72
- });
73
- });
74
- it("should handle empty array", () => {
75
- const result = groupVersionedAppKeysByType([]);
76
- expect(result).toEqual({
77
- selectedApi: [],
78
- slug: [],
79
- });
80
- });
81
- it("should reject uppercase and lowercase UUIDs", () => {
82
- expect(() => {
83
- groupVersionedAppKeysByType(["61E47557-AF91-4B0C-A3E0-C28606357664"]);
84
- }).toThrow("UUID app keys are not supported. Use app slug or implementation ID instead of: 61E47557-AF91-4B0C-A3E0-C28606357664");
85
- expect(() => {
86
- groupVersionedAppKeysByType(["f47ac10b-58cc-4372-a567-0e02b2c3d479"]);
87
- }).toThrow("UUID app keys are not supported. Use app slug or implementation ID instead of: f47ac10b-58cc-4372-a567-0e02b2c3d479");
88
- });
89
- it("should categorize partial UUIDs as slugs", () => {
90
- const result = groupVersionedAppKeysByType([
91
- "61e47557-af91-4b0c-a3e0", // too short
92
- "61e47557-af91-4b0c-a3e0-c28606357664-extra", // too long
93
- ]);
94
- expect(result).toEqual({
95
- selectedApi: [],
96
- slug: [
97
- "61e47557-af91-4b0c-a3e0",
98
- "61e47557-af91-4b0c-a3e0-c28606357664-extra",
99
- ],
100
- });
101
- });
102
- it("should dedupe exact duplicate versioned keys", () => {
103
- const result = groupVersionedAppKeysByType([
104
- "slack@2.1.0",
105
- "FormatterCLIAPI@1.0.0",
106
- "slack@2.1.0", // exact duplicate
107
- "FormatterCLIAPI@1.0.0", // exact duplicate
108
- "slack@2.1.1",
109
- "FormatterCLIAPI@1.0.1",
110
- ]);
111
- expect(result).toEqual({
112
- selectedApi: ["FormatterCLIAPI@1.0.0", "FormatterCLIAPI@1.0.1"],
113
- slug: ["slack@2.1.0", "slack@2.1.1"],
114
- });
115
- });
116
- });
117
- describe("groupAppKeysByType", () => {
118
- it("should strip versions from API implementations", () => {
119
- const result = groupAppKeysByType(["FormatterCLIAPI@1.0.0"]);
120
- expect(result).toEqual({
121
- selectedApi: ["FormatterCLIAPI"],
122
- slug: [],
123
- });
124
- });
125
- it("should strip versions from slugs", () => {
126
- const result = groupAppKeysByType(["slack@2.1.0"]);
127
- expect(result).toEqual({
128
- selectedApi: [],
129
- slug: ["slack"],
130
- });
131
- });
132
- it("should handle mixed types and strip versions", () => {
133
- const result = groupAppKeysByType([
134
- "FormatterCLIAPI@1.0.0",
135
- "slack",
136
- "AnotherAPI@2.3.4",
137
- "gmail@3.0.1",
138
- ]);
139
- expect(result).toEqual({
140
- selectedApi: ["FormatterCLIAPI", "AnotherAPI"],
141
- slug: ["slack", "gmail"],
142
- });
143
- });
144
- it("should handle keys without versions", () => {
145
- const result = groupAppKeysByType([
146
- "FormatterCLIAPI",
147
- "slack",
148
- "AnotherAPI",
149
- ]);
150
- expect(result).toEqual({
151
- selectedApi: ["FormatterCLIAPI", "AnotherAPI"],
152
- slug: ["slack"],
153
- });
154
- });
155
- it("should reject UUID app keys (delegated to versioned function)", () => {
156
- expect(() => {
157
- groupAppKeysByType(["61e47557-af91-4b0c-a3e0-c28606357664"]);
158
- }).toThrow("UUID app keys are not supported. Use app slug or implementation ID instead of: 61e47557-af91-4b0c-a3e0-c28606357664");
159
- });
160
- it("should handle empty array", () => {
161
- const result = groupAppKeysByType([]);
162
- expect(result).toEqual({
163
- selectedApi: [],
164
- slug: [],
165
- });
166
- });
167
- it("should dedupe multiple versions of same base key", () => {
168
- const result = groupAppKeysByType([
169
- "slack@1.0.0",
170
- "FormatterCLIAPI@2.1.0",
171
- "slack@1.2.3", // different version of slack
172
- "FormatterCLIAPI@1.0.0", // different version of FormatterCLIAPI
173
- "gmail",
174
- ]);
175
- expect(result).toEqual({
176
- selectedApi: ["FormatterCLIAPI"], // only one instance despite multiple versions
177
- slug: ["slack", "gmail"], // only one slack despite multiple versions
178
- });
179
- });
180
- it("should dedupe exact duplicates after version stripping", () => {
181
- const result = groupAppKeysByType([
182
- "slack@1.0.0",
183
- "slack", // no version
184
- "slack@2.0.0", // different version
185
- "FormatterCLIAPI",
186
- "FormatterCLIAPI@1.5.0",
187
- ]);
188
- expect(result).toEqual({
189
- selectedApi: ["FormatterCLIAPI"],
190
- slug: ["slack"],
191
- });
192
- });
193
- });
194
- describe("toAppLocator", () => {
195
- it("should reject UUID app keys", () => {
196
- expect(() => {
197
- toAppLocator("61e47557-af91-4b0c-a3e0-c28606357664");
198
- }).toThrow("UUID app keys are not supported. Use app slug or implementation ID instead of: 61e47557-af91-4b0c-a3e0-c28606357664");
199
- });
200
- it("should reject UUID app keys with versions", () => {
201
- expect(() => {
202
- toAppLocator("61e47557-af91-4b0c-a3e0-c28606357664@1.0.0");
203
- }).toThrow("UUID app keys are not supported. Use app slug or implementation ID instead of: 61e47557-af91-4b0c-a3e0-c28606357664@1.0.0");
204
- });
205
- it("should reject uppercase UUID app keys", () => {
206
- expect(() => {
207
- toAppLocator("61E47557-AF91-4B0C-A3E0-C28606357664");
208
- }).toThrow("UUID app keys are not supported. Use app slug or implementation ID instead of: 61E47557-AF91-4B0C-A3E0-C28606357664");
209
- });
210
- it("should handle simple slug without version", () => {
211
- const result = toAppLocator("slack");
212
- expect(result).toEqual({
213
- lookupAppKey: "slack",
214
- slug: "slack",
215
- implementationName: undefined,
216
- version: undefined,
217
- });
218
- });
219
- it("should handle slug with version", () => {
220
- const result = toAppLocator("slack@1.0.0");
221
- expect(result).toEqual({
222
- lookupAppKey: "slack",
223
- slug: "slack",
224
- implementationName: undefined,
225
- version: "1.0.0",
226
- });
227
- });
228
- it("should handle dashified slug", () => {
229
- const result = toAppLocator("google-sheets");
230
- expect(result).toEqual({
231
- lookupAppKey: "google-sheets",
232
- slug: "google-sheets",
233
- implementationName: undefined,
234
- version: undefined,
235
- });
236
- });
237
- it("should handle dashified slug with version", () => {
238
- const result = toAppLocator("google-sheets@2.1.3");
239
- expect(result).toEqual({
240
- lookupAppKey: "google-sheets",
241
- slug: "google-sheets",
242
- implementationName: undefined,
243
- version: "2.1.3",
244
- });
245
- });
246
- it("should handle snake_cased slug and convert to dash", () => {
247
- const result = toAppLocator("google_sheets");
248
- expect(result).toEqual({
249
- lookupAppKey: "google_sheets",
250
- slug: "google-sheets",
251
- implementationName: undefined,
252
- version: undefined,
253
- });
254
- });
255
- it("should handle snake_cased slug with version and convert to dash", () => {
256
- const result = toAppLocator("google_sheets@2.1.3");
257
- expect(result).toEqual({
258
- lookupAppKey: "google_sheets",
259
- slug: "google-sheets",
260
- implementationName: undefined,
261
- version: "2.1.3",
262
- });
263
- });
264
- it("should handle leading underscore snake_cased slug", () => {
265
- const result = toAppLocator("_100hires_ats");
266
- expect(result).toEqual({
267
- lookupAppKey: "_100hires_ats",
268
- slug: "100hires-ats",
269
- implementationName: undefined,
270
- version: undefined,
271
- });
272
- });
273
- it("should handle leading underscore snake_cased slug with version", () => {
274
- const result = toAppLocator("_100hires_ats@3.0.0");
275
- expect(result).toEqual({
276
- lookupAppKey: "_100hires_ats",
277
- slug: "100hires-ats",
278
- implementationName: undefined,
279
- version: "3.0.0",
280
- });
281
- });
282
- it("should handle implementation name without version", () => {
283
- const result = toAppLocator("SlackCLIAPI");
284
- expect(result).toEqual({
285
- lookupAppKey: "SlackCLIAPI",
286
- slug: undefined,
287
- implementationName: "SlackCLIAPI",
288
- version: undefined,
289
- });
290
- });
291
- it("should handle implementation name with version", () => {
292
- const result = toAppLocator("SlackCLIAPI@1.29.0");
293
- expect(result).toEqual({
294
- lookupAppKey: "SlackCLIAPI",
295
- slug: undefined,
296
- implementationName: "SlackCLIAPI",
297
- version: "1.29.0",
298
- });
299
- });
300
- it("should handle edge cases with complex version numbers", () => {
301
- const result = toAppLocator("slack@1.2.3-beta.4+build.5");
302
- expect(result).toEqual({
303
- lookupAppKey: "slack",
304
- slug: "slack",
305
- implementationName: undefined,
306
- version: "1.2.3-beta.4+build.5",
307
- });
308
- });
309
- it("should handle single character app keys", () => {
310
- const result = toAppLocator("a");
311
- expect(result).toEqual({
312
- lookupAppKey: "a",
313
- slug: "a",
314
- implementationName: undefined,
315
- version: undefined,
316
- });
317
- });
318
- it("should handle app keys with numbers", () => {
319
- const result = toAppLocator("app123");
320
- expect(result).toEqual({
321
- lookupAppKey: "app123",
322
- slug: "app123",
323
- implementationName: undefined,
324
- version: undefined,
325
- });
326
- });
327
- it("should handle mixed case app keys that aren't implementation names", () => {
328
- const result = toAppLocator("SlackBot");
329
- expect(result).toEqual({
330
- lookupAppKey: "SlackBot",
331
- slug: undefined,
332
- implementationName: "SlackBot",
333
- version: undefined,
334
- });
335
- });
336
- it("should handle empty version (app key ending with @)", () => {
337
- const result = toAppLocator("slack@");
338
- expect(result).toEqual({
339
- lookupAppKey: "slack",
340
- slug: "slack",
341
- implementationName: undefined,
342
- version: "",
343
- });
344
- });
345
- });
346
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=file-utils.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"file-utils.test.d.ts","sourceRoot":"","sources":["../../src/utils/file-utils.test.ts"],"names":[],"mappings":""}
@@ -1,51 +0,0 @@
1
- import { describe, it, expect, vi } from "vitest";
2
- import { resolve, writeFile, readFile } from "./file-utils";
3
- // Mock the dynamic imports to simulate missing modules
4
- vi.mock("fs/promises", () => {
5
- throw new Error("Module not found");
6
- });
7
- vi.mock("path", () => {
8
- throw new Error("Module not found");
9
- });
10
- describe("file-utils", () => {
11
- describe("resolve", () => {
12
- it("should handle absolute paths", async () => {
13
- expect(await resolve("/absolute/path")).toBe("/absolute/path");
14
- });
15
- it("should handle relative paths with ./", async () => {
16
- expect(await resolve("./relative/path")).toBe("/relative/path");
17
- expect(await resolve("./relative/path", "/base")).toBe("/base/relative/path");
18
- expect(await resolve("./relative/path", "/base/")).toBe("/base/relative/path");
19
- });
20
- it("should handle parent directory paths with ../", async () => {
21
- expect(await resolve("../parent/path")).toBe("/parent/path");
22
- expect(await resolve("../../nested/parent/path")).toBe("/nested/parent/path");
23
- expect(await resolve("../parent/path", "/base")).toBe("/base/parent/path");
24
- });
25
- it("should handle paths without prefix", async () => {
26
- expect(await resolve("simple/path")).toBe("/simple/path");
27
- expect(await resolve("simple/path", "/base")).toBe("/base/simple/path");
28
- expect(await resolve("simple/path", "/base/")).toBe("/base/simple/path");
29
- });
30
- });
31
- describe("writeFile and readFile with in-memory filesystem", () => {
32
- it("should write and read files using in-memory filesystem when fs is not available", async () => {
33
- const filePath = "/test/file.txt";
34
- const content = "Hello, world!";
35
- await writeFile(filePath, content);
36
- const readContent = await readFile(filePath);
37
- expect(readContent).toBe(content);
38
- });
39
- it("should throw error when reading non-existent file", async () => {
40
- await expect(readFile("/non/existent/file.txt")).rejects.toThrow("File not found: /non/existent/file.txt");
41
- });
42
- it("should handle multiple files in in-memory filesystem", async () => {
43
- await writeFile("/file1.txt", "content1");
44
- await writeFile("/file2.txt", "content2");
45
- await writeFile("/dir/file3.txt", "content3");
46
- expect(await readFile("/file1.txt")).toBe("content1");
47
- expect(await readFile("/file2.txt")).toBe("content2");
48
- expect(await readFile("/dir/file3.txt")).toBe("content3");
49
- });
50
- });
51
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=function-utils.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"function-utils.test.d.ts","sourceRoot":"","sources":["../../src/utils/function-utils.test.ts"],"names":[],"mappings":""}
@@ -1,188 +0,0 @@
1
- import { describe, it, expect, vi } from "vitest";
2
- import { createFunction, createPaginatedFunction } from "./function-utils";
3
- import { ZapierValidationError, ZapierUnknownError } from "../types/errors";
4
- import { ALL_ITEMS, listTestItems } from "./pagination-utils.test";
5
- import { isTelemetryNested } from "./telemetry-context";
6
- describe("createFunction", () => {
7
- it("should return result from core function", async () => {
8
- const mockCoreFn = async (options) => {
9
- return `Hello, ${options.name}!`;
10
- };
11
- const wrappedFn = createFunction(mockCoreFn);
12
- const result = await wrappedFn({ name: "World" });
13
- expect(result).toBe("Hello, World!");
14
- });
15
- });
16
- describe.each([
17
- { name: "createFunction", createFn: createFunction },
18
- { name: "createPaginatedFunction", createFn: createPaginatedFunction },
19
- ])("$name", ({ createFn }) => {
20
- it("should preserve function name", async () => {
21
- async function testCoreFn(options) {
22
- return options.value * 2;
23
- }
24
- const wrappedFn = createFn(testCoreFn);
25
- expect(wrappedFn.name).toBe("testCoreFn");
26
- });
27
- it("should normalize and rethrow ZapierError instances", async () => {
28
- const mockError = new ZapierValidationError("Validation failed", {
29
- details: { field: "name" },
30
- });
31
- const mockCoreFn = async () => {
32
- throw mockError;
33
- };
34
- const wrappedFn = createFn(mockCoreFn);
35
- await expect(wrappedFn({})).rejects.toBe(mockError);
36
- });
37
- it("should normalize generic Error to ZapierUnknownError", async () => {
38
- const mockCoreFn = async () => {
39
- throw new Error("Something went wrong");
40
- };
41
- const wrappedFn = createFn(mockCoreFn);
42
- await expect(wrappedFn({})).rejects.toThrow(ZapierUnknownError);
43
- });
44
- it("should normalize non-Error values to ZapierUnknownError", async () => {
45
- const mockCoreFn = async () => {
46
- throw "String error";
47
- };
48
- const wrappedFn = createFn(mockCoreFn);
49
- await expect(wrappedFn({})).rejects.toThrow(ZapierUnknownError);
50
- });
51
- });
52
- describe("createPaginatedFunction", () => {
53
- it("should wrap non-array result in {data: [result]}", async () => {
54
- const mockCoreFn = async (options) => {
55
- return `Hello, ${options.name}!`;
56
- };
57
- const wrappedFn = createPaginatedFunction(mockCoreFn);
58
- const result = await wrappedFn({ name: "World" });
59
- expect(result).toEqual({ data: ["Hello, World!"] });
60
- });
61
- it("should wrap array result in {data: result}", async () => {
62
- const mockCoreFn = async (options) => {
63
- return Array.from({ length: options.count }, (_, i) => `Item ${i + 1}`);
64
- };
65
- const wrappedFn = createPaginatedFunction(mockCoreFn);
66
- const result = await wrappedFn({ count: 3 });
67
- expect(result).toEqual({ data: ["Item 1", "Item 2", "Item 3"] });
68
- });
69
- it("should return {data} object unchanged", async () => {
70
- const mockCoreFn = async (options) => {
71
- return { data: options.items };
72
- };
73
- const wrappedFn = createPaginatedFunction(mockCoreFn);
74
- const result = await wrappedFn({ items: ["A", "B", "C"] });
75
- expect(result).toEqual({ data: ["A", "B", "C"] });
76
- });
77
- it("should allow for await iteration over pages", async () => {
78
- const listItems = createPaginatedFunction(listTestItems);
79
- const pages = [];
80
- for await (const page of listItems({ pageSize: 3 })) {
81
- pages.push(page);
82
- if (pages.length >= 3)
83
- break;
84
- }
85
- // Should have collected 3 pages
86
- expect(pages).toHaveLength(3);
87
- // Check first page structure
88
- expect(pages[0]).toEqual({
89
- data: ALL_ITEMS.slice(0, 3),
90
- nextCursor: "cursor-3",
91
- });
92
- // Check second page
93
- expect(pages[1]).toEqual({
94
- data: ALL_ITEMS.slice(3, 6),
95
- nextCursor: "cursor-6",
96
- });
97
- });
98
- it("should allow for await iteration over individual items", async () => {
99
- const listItems = createPaginatedFunction(listTestItems);
100
- const items = [];
101
- for await (const item of listItems({ pageSize: 3 }).items()) {
102
- items.push(item);
103
- if (items.length >= 7)
104
- break; // Get first 7 items across pages
105
- }
106
- // Should have collected 7 individual items
107
- expect(items).toHaveLength(7);
108
- // Should be the first 7 items from ALL_ITEMS (flattened from pages)
109
- expect(items).toEqual(ALL_ITEMS.slice(0, 7));
110
- });
111
- });
112
- describe("telemetry nesting via AsyncLocalStorage", () => {
113
- it("emits telemetry for a top-level createFunction call", async () => {
114
- const onMethodCalled = vi.fn();
115
- const telemetry = { onMethodCalled };
116
- async function myMethod(options) {
117
- return options.value * 2;
118
- }
119
- const wrapped = createFunction(myMethod, undefined, telemetry);
120
- await wrapped({ value: 5 });
121
- expect(onMethodCalled).toHaveBeenCalledOnce();
122
- expect(onMethodCalled).toHaveBeenCalledWith(expect.objectContaining({
123
- methodName: "myMethod",
124
- success: true,
125
- isPaginated: false,
126
- }));
127
- });
128
- it("emits telemetry for a top-level createPaginatedFunction call", async () => {
129
- const onMethodCalled = vi.fn();
130
- const wrapped = createPaginatedFunction(listTestItems, undefined, { onMethodCalled }, "topLevelList");
131
- await wrapped({ pageSize: 3 });
132
- expect(onMethodCalled).toHaveBeenCalledOnce();
133
- expect(onMethodCalled).toHaveBeenCalledWith(expect.objectContaining({
134
- methodName: "topLevelList",
135
- success: true,
136
- isPaginated: true,
137
- }));
138
- });
139
- it("suppresses telemetry when createFunction calls another createFunction", async () => {
140
- const outerTelemetry = vi.fn();
141
- const innerTelemetry = vi.fn();
142
- async function innerMethod(_options) {
143
- return "inner";
144
- }
145
- const wrappedInner = createFunction(innerMethod, undefined, {
146
- onMethodCalled: innerTelemetry,
147
- });
148
- async function outerMethod(_options) {
149
- return wrappedInner({});
150
- }
151
- const wrappedOuter = createFunction(outerMethod, undefined, {
152
- onMethodCalled: outerTelemetry,
153
- });
154
- await wrappedOuter({});
155
- expect(outerTelemetry).toHaveBeenCalledOnce();
156
- expect(innerTelemetry).not.toHaveBeenCalled();
157
- });
158
- it("suppresses telemetry for nested createPaginatedFunction calls", async () => {
159
- const outerTelemetry = vi.fn();
160
- const innerTelemetry = vi.fn();
161
- const wrappedInner = createPaginatedFunction(listTestItems, undefined, { onMethodCalled: innerTelemetry }, "innerList");
162
- async function outerMethod(_options) {
163
- const result = await wrappedInner({ pageSize: 3 });
164
- return result.data;
165
- }
166
- const wrappedOuter = createFunction(outerMethod, undefined, {
167
- onMethodCalled: outerTelemetry,
168
- });
169
- await wrappedOuter({});
170
- expect(outerTelemetry).toHaveBeenCalledOnce();
171
- expect(innerTelemetry).not.toHaveBeenCalled();
172
- });
173
- it("context is restored after nested call completes", async () => {
174
- expect(isTelemetryNested()).toBe(false);
175
- async function inner(_options) {
176
- return "inner";
177
- }
178
- const wrappedInner = createFunction(inner);
179
- async function outer(_options) {
180
- await wrappedInner({});
181
- expect(isTelemetryNested()).toBe(false);
182
- return "outer";
183
- }
184
- const wrappedOuter = createFunction(outer);
185
- await wrappedOuter({});
186
- expect(isTelemetryNested()).toBe(false);
187
- });
188
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=id-utils.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"id-utils.test.d.ts","sourceRoot":"","sources":["../../src/utils/id-utils.test.ts"],"names":[],"mappings":""}
@@ -1,22 +0,0 @@
1
- import { describe, it, expect } from "vitest";
2
- import { coerceToNumericId } from "./id-utils";
3
- import { ZapierValidationError } from "../types/errors";
4
- describe("coerceToNumericId", () => {
5
- it("should return number unchanged", () => {
6
- expect(coerceToNumericId("test_id", 123)).toBe(123);
7
- });
8
- it("should convert string number to number", () => {
9
- expect(coerceToNumericId("test_id", "456")).toBe(456);
10
- });
11
- it("should throw for non-numeric string", () => {
12
- expect(() => coerceToNumericId("auth_id", "abc")).toThrow(ZapierValidationError);
13
- expect(() => coerceToNumericId("auth_id", "abc")).toThrow('The auth_id "abc" could not be converted to a number');
14
- });
15
- it("should throw for empty string", () => {
16
- expect(() => coerceToNumericId("test_id", "")).toThrow(ZapierValidationError);
17
- expect(() => coerceToNumericId("test_id", "")).toThrow("The test_id cannot be empty");
18
- });
19
- it("should throw for Infinity", () => {
20
- expect(() => coerceToNumericId("test_id", Infinity)).toThrow(ZapierValidationError);
21
- });
22
- });
@@ -1,17 +0,0 @@
1
- export declare const ALL_ITEMS: {
2
- id: number;
3
- name: string;
4
- }[];
5
- export declare function listTestItems(options: {
6
- pageSize?: number;
7
- cursor?: string;
8
- filter?: string;
9
- maxItems?: number;
10
- }): Promise<{
11
- data: {
12
- id: number;
13
- name: string;
14
- }[];
15
- nextCursor: string | undefined;
16
- }>;
17
- //# sourceMappingURL=pagination-utils.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pagination-utils.test.d.ts","sourceRoot":"","sources":["../../src/utils/pagination-utils.test.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,SAAS;;;GAGnB,CAAC;AAGJ,wBAAsB,aAAa,CAAC,OAAO,EAAE;IAC3C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;;;;;;GA6CA"}