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