@zapier/zapier-sdk 0.4.1 → 0.5.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 (374) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/api/auth.d.ts +9 -0
  3. package/dist/api/auth.d.ts.map +1 -0
  4. package/dist/api/auth.js +25 -0
  5. package/dist/api/client.d.ts +9 -0
  6. package/dist/api/client.d.ts.map +1 -0
  7. package/dist/api/client.js +322 -0
  8. package/dist/api/debug.d.ts +13 -0
  9. package/dist/api/debug.d.ts.map +1 -0
  10. package/dist/api/debug.js +55 -0
  11. package/dist/api/index.d.ts +29 -0
  12. package/dist/api/index.d.ts.map +1 -0
  13. package/dist/api/index.js +41 -0
  14. package/dist/api/polling.d.ts +16 -0
  15. package/dist/api/polling.d.ts.map +1 -0
  16. package/dist/api/polling.js +45 -0
  17. package/dist/api/schemas.d.ts +2473 -0
  18. package/dist/api/schemas.d.ts.map +1 -0
  19. package/dist/api/schemas.js +355 -0
  20. package/dist/api/types.d.ts +75 -0
  21. package/dist/api/types.d.ts.map +1 -0
  22. package/dist/api/types.js +11 -0
  23. package/dist/auth.d.ts +34 -0
  24. package/dist/auth.d.ts.map +1 -0
  25. package/dist/auth.js +47 -0
  26. package/dist/constants.d.ts +10 -0
  27. package/dist/constants.d.ts.map +1 -0
  28. package/dist/constants.js +9 -0
  29. package/dist/index.cjs +2108 -1379
  30. package/dist/index.d.mts +2440 -620
  31. package/dist/index.d.ts +17 -892
  32. package/dist/index.d.ts.map +1 -0
  33. package/dist/index.js +20 -0
  34. package/dist/index.mjs +2093 -1362
  35. package/dist/plugins/api/index.d.ts +14 -0
  36. package/dist/plugins/api/index.d.ts.map +1 -0
  37. package/dist/plugins/api/index.js +21 -0
  38. package/dist/plugins/apps/index.d.ts +11 -0
  39. package/dist/plugins/apps/index.d.ts.map +1 -0
  40. package/dist/plugins/apps/index.js +91 -0
  41. package/dist/plugins/apps/types.d.ts +30 -0
  42. package/dist/plugins/apps/types.d.ts.map +1 -0
  43. package/dist/plugins/apps/types.js +2 -0
  44. package/dist/plugins/fetch/index.d.ts +21 -0
  45. package/dist/plugins/fetch/index.d.ts.map +1 -0
  46. package/dist/plugins/fetch/index.js +20 -0
  47. package/dist/plugins/findFirstAuthentication/index.d.ts +20 -0
  48. package/dist/plugins/findFirstAuthentication/index.d.ts.map +1 -0
  49. package/dist/plugins/findFirstAuthentication/index.js +24 -0
  50. package/dist/plugins/findFirstAuthentication/index.test.d.ts +2 -0
  51. package/dist/plugins/findFirstAuthentication/index.test.d.ts.map +1 -0
  52. package/dist/plugins/findFirstAuthentication/index.test.js +171 -0
  53. package/dist/plugins/findFirstAuthentication/schemas.d.ts +29 -0
  54. package/dist/plugins/findFirstAuthentication/schemas.d.ts.map +1 -0
  55. package/dist/plugins/findFirstAuthentication/schemas.js +18 -0
  56. package/dist/plugins/findUniqueAuthentication/index.d.ts +20 -0
  57. package/dist/plugins/findUniqueAuthentication/index.d.ts.map +1 -0
  58. package/dist/plugins/findUniqueAuthentication/index.js +31 -0
  59. package/dist/plugins/findUniqueAuthentication/index.test.d.ts +2 -0
  60. package/dist/plugins/findUniqueAuthentication/index.test.d.ts.map +1 -0
  61. package/dist/plugins/findUniqueAuthentication/index.test.js +152 -0
  62. package/dist/plugins/findUniqueAuthentication/schemas.d.ts +29 -0
  63. package/dist/plugins/findUniqueAuthentication/schemas.d.ts.map +1 -0
  64. package/dist/plugins/findUniqueAuthentication/schemas.js +18 -0
  65. package/dist/plugins/getAction/index.d.ts +23 -0
  66. package/dist/plugins/getAction/index.d.ts.map +1 -0
  67. package/dist/plugins/getAction/index.js +28 -0
  68. package/dist/plugins/getAction/index.test.d.ts +2 -0
  69. package/dist/plugins/getAction/index.test.d.ts.map +1 -0
  70. package/dist/plugins/getAction/index.test.js +186 -0
  71. package/dist/plugins/getAction/schemas.d.ts +23 -0
  72. package/dist/plugins/getAction/schemas.d.ts.map +1 -0
  73. package/dist/plugins/getAction/schemas.js +10 -0
  74. package/dist/plugins/getApp/index.d.ts +22 -0
  75. package/dist/plugins/getApp/index.d.ts.map +1 -0
  76. package/dist/plugins/getApp/index.js +39 -0
  77. package/dist/plugins/getApp/index.test.d.ts +2 -0
  78. package/dist/plugins/getApp/index.test.d.ts.map +1 -0
  79. package/dist/plugins/getApp/index.test.js +100 -0
  80. package/dist/plugins/getApp/schemas.d.ts +18 -0
  81. package/dist/plugins/getApp/schemas.d.ts.map +1 -0
  82. package/dist/plugins/getApp/schemas.js +10 -0
  83. package/dist/plugins/getAuthentication/index.d.ts +22 -0
  84. package/dist/plugins/getAuthentication/index.d.ts.map +1 -0
  85. package/dist/plugins/getAuthentication/index.js +41 -0
  86. package/dist/plugins/getAuthentication/index.test.d.ts +2 -0
  87. package/dist/plugins/getAuthentication/index.test.d.ts.map +1 -0
  88. package/dist/plugins/getAuthentication/index.test.js +205 -0
  89. package/dist/plugins/getAuthentication/schemas.d.ts +17 -0
  90. package/dist/plugins/getAuthentication/schemas.d.ts.map +1 -0
  91. package/dist/plugins/getAuthentication/schemas.js +11 -0
  92. package/dist/plugins/getProfile/index.d.ts +23 -0
  93. package/dist/plugins/getProfile/index.d.ts.map +1 -0
  94. package/dist/plugins/getProfile/index.js +29 -0
  95. package/dist/plugins/getProfile/schemas.d.ts +13 -0
  96. package/dist/plugins/getProfile/schemas.d.ts.map +1 -0
  97. package/dist/plugins/getProfile/schemas.js +5 -0
  98. package/dist/plugins/listActions/index.d.ts +28 -0
  99. package/dist/plugins/listActions/index.d.ts.map +1 -0
  100. package/dist/plugins/listActions/index.js +61 -0
  101. package/dist/plugins/listActions/index.test.d.ts +2 -0
  102. package/dist/plugins/listActions/index.test.d.ts.map +1 -0
  103. package/dist/plugins/listActions/index.test.js +467 -0
  104. package/dist/plugins/listActions/schemas.d.ts +29 -0
  105. package/dist/plugins/listActions/schemas.d.ts.map +1 -0
  106. package/dist/plugins/listActions/schemas.js +21 -0
  107. package/dist/plugins/listApps/index.d.ts +28 -0
  108. package/dist/plugins/listApps/index.d.ts.map +1 -0
  109. package/dist/plugins/listApps/index.js +62 -0
  110. package/dist/plugins/listApps/index.test.d.ts +2 -0
  111. package/dist/plugins/listApps/index.test.d.ts.map +1 -0
  112. package/dist/plugins/listApps/index.test.js +313 -0
  113. package/dist/plugins/listApps/schemas.d.ts +30 -0
  114. package/dist/plugins/listApps/schemas.d.ts.map +1 -0
  115. package/dist/plugins/listApps/schemas.js +23 -0
  116. package/dist/plugins/listAuthentications/index.d.ts +28 -0
  117. package/dist/plugins/listAuthentications/index.d.ts.map +1 -0
  118. package/dist/plugins/listAuthentications/index.js +77 -0
  119. package/dist/plugins/listAuthentications/index.test.d.ts +2 -0
  120. package/dist/plugins/listAuthentications/index.test.d.ts.map +1 -0
  121. package/dist/plugins/listAuthentications/index.test.js +564 -0
  122. package/dist/plugins/listAuthentications/schemas.d.ts +38 -0
  123. package/dist/plugins/listAuthentications/schemas.d.ts.map +1 -0
  124. package/dist/plugins/listAuthentications/schemas.js +28 -0
  125. package/dist/plugins/listInputFields/index.d.ts +28 -0
  126. package/dist/plugins/listInputFields/index.d.ts.map +1 -0
  127. package/dist/plugins/listInputFields/index.js +133 -0
  128. package/dist/plugins/listInputFields/index.test.d.ts +2 -0
  129. package/dist/plugins/listInputFields/index.test.d.ts.map +1 -0
  130. package/dist/plugins/listInputFields/index.test.js +325 -0
  131. package/dist/plugins/listInputFields/schemas.d.ts +38 -0
  132. package/dist/plugins/listInputFields/schemas.d.ts.map +1 -0
  133. package/dist/plugins/listInputFields/schemas.js +22 -0
  134. package/dist/plugins/registry/index.d.ts +11 -0
  135. package/dist/plugins/registry/index.d.ts.map +1 -0
  136. package/dist/plugins/registry/index.js +14 -0
  137. package/dist/plugins/request/index.d.ts +19 -0
  138. package/dist/plugins/request/index.d.ts.map +1 -0
  139. package/dist/plugins/request/index.js +62 -0
  140. package/dist/plugins/request/index.test.d.ts +2 -0
  141. package/dist/plugins/request/index.test.d.ts.map +1 -0
  142. package/dist/plugins/request/index.test.js +256 -0
  143. package/dist/plugins/request/schemas.d.ts +69 -0
  144. package/dist/plugins/request/schemas.d.ts.map +1 -0
  145. package/dist/plugins/request/schemas.js +42 -0
  146. package/dist/plugins/runAction/index.d.ts +28 -0
  147. package/dist/plugins/runAction/index.d.ts.map +1 -0
  148. package/dist/plugins/runAction/index.js +86 -0
  149. package/dist/plugins/runAction/index.test.d.ts +2 -0
  150. package/dist/plugins/runAction/index.test.d.ts.map +1 -0
  151. package/dist/plugins/runAction/index.test.js +320 -0
  152. package/dist/plugins/runAction/schemas.d.ts +37 -0
  153. package/dist/plugins/runAction/schemas.d.ts.map +1 -0
  154. package/dist/plugins/runAction/schemas.js +22 -0
  155. package/dist/resolvers/actionKey.d.ts +9 -0
  156. package/dist/resolvers/actionKey.d.ts.map +1 -0
  157. package/dist/resolvers/actionKey.js +19 -0
  158. package/dist/resolvers/actionType.d.ts +9 -0
  159. package/dist/resolvers/actionType.d.ts.map +1 -0
  160. package/dist/resolvers/actionType.js +22 -0
  161. package/dist/resolvers/appKey.d.ts +7 -0
  162. package/dist/resolvers/appKey.d.ts.map +1 -0
  163. package/dist/resolvers/appKey.js +5 -0
  164. package/dist/resolvers/authenticationId.d.ts +9 -0
  165. package/dist/resolvers/authenticationId.d.ts.map +1 -0
  166. package/dist/resolvers/authenticationId.js +33 -0
  167. package/dist/resolvers/index.d.ts +40 -0
  168. package/dist/resolvers/index.d.ts.map +1 -0
  169. package/dist/resolvers/index.js +91 -0
  170. package/dist/resolvers/inputs.d.ts +8 -0
  171. package/dist/resolvers/inputs.d.ts.map +1 -0
  172. package/dist/resolvers/inputs.js +14 -0
  173. package/dist/schemas/Action.d.ts +243 -0
  174. package/dist/schemas/Action.d.ts.map +1 -0
  175. package/dist/schemas/Action.js +34 -0
  176. package/dist/schemas/App.d.ts +26 -0
  177. package/dist/schemas/App.d.ts.map +1 -0
  178. package/dist/schemas/App.js +22 -0
  179. package/dist/schemas/Auth.d.ts +161 -0
  180. package/dist/schemas/Auth.d.ts.map +1 -0
  181. package/dist/schemas/Auth.js +41 -0
  182. package/dist/schemas/Field.d.ts +144 -0
  183. package/dist/schemas/Field.d.ts.map +1 -0
  184. package/dist/schemas/Field.js +105 -0
  185. package/dist/schemas/UserProfile.d.ts +163 -0
  186. package/dist/schemas/UserProfile.d.ts.map +1 -0
  187. package/dist/schemas/UserProfile.js +29 -0
  188. package/dist/sdk.d.ts +10 -0
  189. package/dist/sdk.d.ts.map +1 -0
  190. package/dist/sdk.js +94 -0
  191. package/dist/sdk.test.d.ts +2 -0
  192. package/dist/sdk.test.d.ts.map +1 -0
  193. package/dist/sdk.test.js +135 -0
  194. package/dist/types/domain.d.ts +36 -0
  195. package/dist/types/domain.d.ts.map +1 -0
  196. package/dist/types/domain.js +1 -0
  197. package/dist/types/domain.test.d.ts +2 -0
  198. package/dist/types/domain.test.d.ts.map +1 -0
  199. package/dist/types/domain.test.js +39 -0
  200. package/dist/types/errors.d.ts +143 -0
  201. package/dist/types/errors.d.ts.map +1 -0
  202. package/dist/types/errors.js +187 -0
  203. package/dist/types/events.d.ts +38 -0
  204. package/dist/types/events.d.ts.map +1 -0
  205. package/dist/types/events.js +7 -0
  206. package/dist/types/functions.d.ts +26 -0
  207. package/dist/types/functions.d.ts.map +1 -0
  208. package/dist/types/functions.js +4 -0
  209. package/dist/types/plugin.d.ts +61 -0
  210. package/dist/types/plugin.d.ts.map +1 -0
  211. package/dist/types/plugin.js +9 -0
  212. package/dist/types/properties.d.ts +22 -0
  213. package/dist/types/properties.d.ts.map +1 -0
  214. package/dist/types/properties.js +50 -0
  215. package/dist/types/sdk.d.ts +43 -0
  216. package/dist/types/sdk.d.ts.map +1 -0
  217. package/dist/types/sdk.js +4 -0
  218. package/dist/utils/array-utils.d.ts +31 -0
  219. package/dist/utils/array-utils.d.ts.map +1 -0
  220. package/dist/utils/array-utils.js +36 -0
  221. package/dist/utils/array-utils.test.d.ts +2 -0
  222. package/dist/utils/array-utils.test.d.ts.map +1 -0
  223. package/dist/utils/array-utils.test.js +107 -0
  224. package/dist/utils/domain-utils.d.ts +78 -0
  225. package/dist/utils/domain-utils.d.ts.map +1 -0
  226. package/dist/utils/domain-utils.js +218 -0
  227. package/dist/utils/domain-utils.test.d.ts +2 -0
  228. package/dist/utils/domain-utils.test.d.ts.map +1 -0
  229. package/dist/utils/domain-utils.test.js +192 -0
  230. package/dist/utils/function-utils.d.ts +45 -0
  231. package/dist/utils/function-utils.d.ts.map +1 -0
  232. package/dist/utils/function-utils.js +158 -0
  233. package/dist/utils/function-utils.test.d.ts +2 -0
  234. package/dist/utils/function-utils.test.d.ts.map +1 -0
  235. package/dist/utils/function-utils.test.js +110 -0
  236. package/dist/utils/pagination-utils.d.ts +37 -0
  237. package/dist/utils/pagination-utils.d.ts.map +1 -0
  238. package/dist/utils/pagination-utils.js +165 -0
  239. package/dist/utils/pagination-utils.test.d.ts +17 -0
  240. package/dist/utils/pagination-utils.test.d.ts.map +1 -0
  241. package/dist/utils/pagination-utils.test.js +461 -0
  242. package/dist/utils/schema-utils.d.ts +45 -0
  243. package/dist/utils/schema-utils.d.ts.map +1 -0
  244. package/dist/utils/schema-utils.js +65 -0
  245. package/dist/utils/validation.d.ts +4 -0
  246. package/dist/utils/validation.d.ts.map +1 -0
  247. package/dist/utils/validation.js +30 -0
  248. package/dist/utils/validation.test.d.ts +2 -0
  249. package/dist/utils/validation.test.d.ts.map +1 -0
  250. package/dist/utils/validation.test.js +43 -0
  251. package/package.json +12 -3
  252. package/src/api/client.ts +394 -171
  253. package/src/api/debug.ts +10 -1
  254. package/src/api/index.ts +0 -2
  255. package/src/api/polling.ts +28 -7
  256. package/src/api/schemas.ts +387 -0
  257. package/src/api/types.ts +72 -136
  258. package/src/constants.ts +10 -0
  259. package/src/index.ts +40 -19
  260. package/src/plugins/api/index.ts +47 -0
  261. package/src/plugins/apps/index.ts +25 -19
  262. package/src/plugins/apps/types.ts +7 -11
  263. package/src/plugins/fetch/index.ts +48 -40
  264. package/src/plugins/findFirstAuthentication/index.test.ts +206 -0
  265. package/src/plugins/findFirstAuthentication/index.ts +55 -0
  266. package/src/plugins/findFirstAuthentication/schemas.ts +41 -0
  267. package/src/plugins/findUniqueAuthentication/index.test.ts +197 -0
  268. package/src/plugins/findUniqueAuthentication/index.ts +72 -0
  269. package/src/plugins/findUniqueAuthentication/schemas.ts +42 -0
  270. package/src/plugins/getAction/index.test.ts +239 -0
  271. package/src/plugins/getAction/index.ts +57 -0
  272. package/src/plugins/getAction/schemas.ts +33 -0
  273. package/src/plugins/getApp/index.test.ts +127 -0
  274. package/src/plugins/getApp/index.ts +66 -0
  275. package/src/plugins/getApp/schemas.ts +38 -0
  276. package/src/plugins/getAuthentication/index.test.ts +284 -0
  277. package/src/plugins/getAuthentication/index.ts +86 -0
  278. package/src/plugins/getAuthentication/schemas.ts +31 -0
  279. package/src/plugins/getProfile/index.ts +55 -0
  280. package/src/plugins/getProfile/schemas.ts +26 -0
  281. package/src/plugins/listActions/index.test.ts +582 -0
  282. package/src/plugins/listActions/index.ts +115 -0
  283. package/src/plugins/listActions/schemas.ts +54 -0
  284. package/src/plugins/listApps/index.test.ts +357 -0
  285. package/src/plugins/listApps/index.ts +121 -0
  286. package/src/plugins/listApps/schemas.ts +49 -0
  287. package/src/plugins/listAuthentications/index.test.ts +709 -0
  288. package/src/plugins/listAuthentications/index.ts +136 -0
  289. package/src/plugins/listAuthentications/schemas.ts +60 -0
  290. package/src/plugins/listInputFields/index.test.ts +408 -0
  291. package/src/plugins/listInputFields/index.ts +204 -0
  292. package/src/plugins/listInputFields/schemas.ts +56 -0
  293. package/src/plugins/registry/index.ts +30 -0
  294. package/src/plugins/request/index.test.ts +329 -0
  295. package/src/plugins/request/index.ts +103 -0
  296. package/src/{functions → plugins}/request/schemas.ts +20 -9
  297. package/src/plugins/runAction/index.test.ts +387 -0
  298. package/src/plugins/runAction/index.ts +176 -0
  299. package/src/plugins/runAction/schemas.ts +53 -0
  300. package/src/resolvers/actionKey.ts +6 -4
  301. package/src/resolvers/actionType.ts +7 -2
  302. package/src/resolvers/appKey.ts +1 -1
  303. package/src/resolvers/authenticationId.ts +12 -3
  304. package/src/resolvers/inputs.ts +3 -1
  305. package/src/schemas/Action.ts +18 -12
  306. package/src/schemas/App.ts +11 -19
  307. package/src/schemas/Auth.ts +18 -13
  308. package/src/schemas/Field.ts +106 -11
  309. package/src/schemas/UserProfile.ts +43 -0
  310. package/src/sdk.test.ts +212 -0
  311. package/src/sdk.ts +132 -102
  312. package/src/types/domain.test.ts +50 -0
  313. package/src/types/domain.ts +43 -75
  314. package/src/types/errors.ts +275 -0
  315. package/src/types/functions.ts +27 -0
  316. package/src/types/optional-zapier-sdk-cli-login.d.ts +37 -0
  317. package/src/types/plugin.ts +105 -0
  318. package/src/types/properties.ts +4 -3
  319. package/src/types/sdk.ts +70 -48
  320. package/src/utils/array-utils.test.ts +131 -0
  321. package/src/utils/array-utils.ts +41 -0
  322. package/src/utils/domain-utils.test.ts +239 -0
  323. package/src/utils/domain-utils.ts +283 -0
  324. package/src/utils/function-utils.test.ts +141 -0
  325. package/src/utils/function-utils.ts +245 -0
  326. package/src/utils/pagination-utils.test.ts +620 -0
  327. package/src/utils/pagination-utils.ts +242 -0
  328. package/src/utils/validation.test.ts +50 -0
  329. package/src/utils/validation.ts +44 -0
  330. package/tsconfig.build.json +16 -2
  331. package/tsconfig.json +3 -1
  332. package/tsconfig.tsbuildinfo +1 -0
  333. package/tsup.config.ts +2 -0
  334. package/src/functions/bundleCode/index.ts +0 -78
  335. package/src/functions/bundleCode/info.ts +0 -9
  336. package/src/functions/bundleCode/schemas.ts +0 -30
  337. package/src/functions/findFirstAuthentication/index.ts +0 -24
  338. package/src/functions/findFirstAuthentication/info.ts +0 -9
  339. package/src/functions/findFirstAuthentication/schemas.ts +0 -50
  340. package/src/functions/findUniqueAuthentication/index.ts +0 -35
  341. package/src/functions/findUniqueAuthentication/info.ts +0 -9
  342. package/src/functions/findUniqueAuthentication/schemas.ts +0 -50
  343. package/src/functions/generateTypes/index.ts +0 -363
  344. package/src/functions/generateTypes/info.ts +0 -9
  345. package/src/functions/generateTypes/schemas.ts +0 -31
  346. package/src/functions/getAction/index.ts +0 -33
  347. package/src/functions/getAction/info.ts +0 -9
  348. package/src/functions/getAction/schemas.ts +0 -25
  349. package/src/functions/getApp/index.ts +0 -41
  350. package/src/functions/getApp/info.ts +0 -9
  351. package/src/functions/getApp/schemas.ts +0 -20
  352. package/src/functions/getAuthentication/index.ts +0 -50
  353. package/src/functions/getAuthentication/info.ts +0 -9
  354. package/src/functions/getAuthentication/schemas.ts +0 -29
  355. package/src/functions/listActions/index.ts +0 -149
  356. package/src/functions/listActions/info.ts +0 -9
  357. package/src/functions/listActions/schemas.ts +0 -30
  358. package/src/functions/listApps/index.ts +0 -60
  359. package/src/functions/listApps/info.ts +0 -9
  360. package/src/functions/listApps/schemas.ts +0 -32
  361. package/src/functions/listAuthentications/index.ts +0 -162
  362. package/src/functions/listAuthentications/info.ts +0 -9
  363. package/src/functions/listAuthentications/schemas.ts +0 -50
  364. package/src/functions/listFields/index.ts +0 -86
  365. package/src/functions/listFields/info.ts +0 -9
  366. package/src/functions/listFields/schemas.ts +0 -36
  367. package/src/functions/request/index.ts +0 -150
  368. package/src/functions/request/info.ts +0 -11
  369. package/src/functions/runAction/index.ts +0 -127
  370. package/src/functions/runAction/info.ts +0 -9
  371. package/src/functions/runAction/schemas.ts +0 -34
  372. package/src/plugins/apps/info.ts +0 -12
  373. package/src/plugins/fetch/types.ts +0 -2
  374. /package/src/{schema-utils.ts → utils/schema-utils.ts} +0 -0
@@ -0,0 +1,136 @@
1
+ import type { Plugin, GetSdkType } from "../../types/plugin";
2
+ import type { ApiClient } from "../../api";
3
+ import type { AuthenticationsResponse } from "../../api/types";
4
+ import type { AuthenticationItem } from "../../types/domain";
5
+ import {
6
+ ListAuthenticationsSchema,
7
+ type ListAuthenticationsOptions,
8
+ type ListAuthenticationsPage,
9
+ } from "./schemas";
10
+ import { normalizeAuthenticationItem } from "../../utils/domain-utils";
11
+ import { ZapierAuthenticationError } from "../../types/errors";
12
+ import {
13
+ createPaginatedFunction,
14
+ extractCursor,
15
+ } from "../../utils/function-utils";
16
+ import type { GetAppPluginProvides } from "../getApp";
17
+
18
+ export interface ListAuthenticationsPluginProvides {
19
+ listAuthentications: (options?: ListAuthenticationsOptions) => Promise<{
20
+ data: AuthenticationItem[];
21
+ }> &
22
+ AsyncIterable<{ data: AuthenticationItem[]; nextCursor?: string }> & {
23
+ items(): AsyncIterable<AuthenticationItem>;
24
+ };
25
+ context: {
26
+ meta: {
27
+ listAuthentications: {
28
+ inputSchema: typeof ListAuthenticationsSchema;
29
+ };
30
+ };
31
+ };
32
+ }
33
+
34
+ export const listAuthenticationsPlugin: Plugin<
35
+ GetSdkType<GetAppPluginProvides>, // requires getApp in SDK
36
+ { api: ApiClient }, // requires api in context
37
+ ListAuthenticationsPluginProvides
38
+ > = ({ sdk, context }) => {
39
+ const listAuthentications = createPaginatedFunction(
40
+ async function listAuthenticationsPage(
41
+ options: ListAuthenticationsOptions & { cursor?: string } & {
42
+ pageSize: number;
43
+ },
44
+ ): Promise<ListAuthenticationsPage> {
45
+ const { api } = context;
46
+
47
+ // Build search parameters
48
+ const searchParams: Record<string, string> = {};
49
+
50
+ // Handle appKey filtering by getting the selected_api first
51
+ if (options.appKey) {
52
+ const app = await sdk.getApp({
53
+ appKey: options.appKey,
54
+ });
55
+
56
+ const selectedApi = app.data.current_implementation_id;
57
+ if (selectedApi) {
58
+ // Use versionless_selected_api to find auths across all app versions
59
+ // Extract the base name without the version (e.g., "SlackCLIAPI" from "SlackCLIAPI@1.21.1")
60
+ const versionlessApi = selectedApi.split("@")[0];
61
+ searchParams.versionless_selected_api = versionlessApi;
62
+ }
63
+ }
64
+
65
+ // Add other query parameters if provided
66
+ // Use title as search if no explicit search provided
67
+ if (options.search) {
68
+ searchParams.search = options.search;
69
+ } else if (options.title) {
70
+ searchParams.search = options.title;
71
+ }
72
+ if (options.account_id) {
73
+ searchParams.account_id = options.account_id;
74
+ }
75
+ if (options.owner) {
76
+ searchParams.owner = options.owner;
77
+ }
78
+ // pageSize is now guaranteed to be set by the higher-order function
79
+ searchParams.limit = options.pageSize.toString();
80
+ if (options.cursor) {
81
+ // Convert cursor back to offset for the API
82
+ searchParams.offset = options.cursor;
83
+ }
84
+
85
+ const data: AuthenticationsResponse = await api.get(
86
+ "/api/v4/authentications/",
87
+ {
88
+ searchParams,
89
+ customErrorHandler: ({ status }) => {
90
+ if (status === 401) {
91
+ return new ZapierAuthenticationError(
92
+ `Authentication failed. Your token may not have permission to access authentications or may be expired. (HTTP ${status})`,
93
+ { statusCode: status },
94
+ );
95
+ }
96
+ if (status === 403) {
97
+ return new ZapierAuthenticationError(
98
+ `Access forbidden. Your token may not have the required scopes to list authentications. (HTTP ${status})`,
99
+ { statusCode: status },
100
+ );
101
+ }
102
+ return undefined;
103
+ },
104
+ authRequired: true,
105
+ },
106
+ );
107
+
108
+ // Transform API response and filter by exact title match if specified
109
+ let auths = (data.results || []).map((auth) =>
110
+ normalizeAuthenticationItem(auth),
111
+ );
112
+
113
+ // Filter by exact title match if specified
114
+ if (options.title) {
115
+ auths = auths.filter((auth) => auth.title === options.title);
116
+ }
117
+
118
+ return {
119
+ data: auths,
120
+ nextCursor: extractCursor(data),
121
+ };
122
+ },
123
+ ListAuthenticationsSchema,
124
+ );
125
+
126
+ return {
127
+ listAuthentications,
128
+ context: {
129
+ meta: {
130
+ listAuthentications: {
131
+ inputSchema: ListAuthenticationsSchema,
132
+ },
133
+ },
134
+ },
135
+ };
136
+ };
@@ -0,0 +1,60 @@
1
+ import { z } from "zod";
2
+ import { AppKeyPropertySchema } from "../../types/properties";
3
+ import type { PaginatedSdkFunction } from "../../types/functions";
4
+ import type { AuthenticationItem } from "../../types/domain";
5
+
6
+ // Pure Zod schema - no resolver metadata!
7
+ export const ListAuthenticationsSchema = z
8
+ .object({
9
+ appKey: AppKeyPropertySchema.optional().describe(
10
+ "App key of authentications to list (e.g., 'SlackCLIAPI')",
11
+ ),
12
+ search: z
13
+ .string()
14
+ .optional()
15
+ .describe("Search term to filter authentications by title"),
16
+ title: z
17
+ .string()
18
+ .optional()
19
+ .describe("Filter authentications by exact title match"),
20
+ account_id: z.string().optional().describe("Filter by account ID"),
21
+ owner: z.string().optional().describe("Filter by owner"),
22
+ pageSize: z
23
+ .number()
24
+ .min(1)
25
+ .optional()
26
+ .describe("Number of authentications per page"),
27
+ maxItems: z
28
+ .number()
29
+ .min(1)
30
+ .optional()
31
+ .describe("Maximum total items to return across all pages"),
32
+ })
33
+ .describe("List available authentications with optional filtering");
34
+
35
+ // Type inferred from schema
36
+ export type ListAuthenticationsOptions = z.infer<
37
+ typeof ListAuthenticationsSchema
38
+ >;
39
+
40
+ // Page result structure
41
+ export interface ListAuthenticationsPage {
42
+ data: AuthenticationItem[];
43
+ nextCursor?: string;
44
+ }
45
+
46
+ // Error union for this function
47
+ export type ListAuthenticationsError =
48
+ | import("../../types/errors").ZapierAuthenticationError
49
+ | import("../../types/errors").ZapierApiError
50
+ | import("../../types/errors").ZapierAppNotFoundError
51
+ | import("../../types/errors").ZapierValidationError
52
+ | import("../../types/errors").ZapierUnknownError;
53
+
54
+ // SDK function interface - ready to be mixed into main SDK interface
55
+ export interface ListAuthenticationsSdkFunction {
56
+ listAuthentications: PaginatedSdkFunction<
57
+ ListAuthenticationsOptions,
58
+ AuthenticationItem
59
+ >;
60
+ }
@@ -0,0 +1,408 @@
1
+ import { describe, it, expect, vi, beforeEach } from "vitest";
2
+ import {
3
+ ZapierValidationError,
4
+ ZapierConfigurationError,
5
+ ZapierApiError,
6
+ } from "../../types/errors";
7
+ import { listInputFieldsPlugin } from "./index";
8
+ import { createSdk } from "../../sdk";
9
+ import type { ApiClient } from "../../api";
10
+ import type { ListInputFieldsOptions } from "./schemas";
11
+ import type { NeedsResponse, Need } from "../../api/types";
12
+
13
+ const mockNeeds: Need[] = [
14
+ {
15
+ key: "message",
16
+ label: "Message",
17
+ help_text: "The message to send",
18
+ required: true,
19
+ type: "string",
20
+ placeholder: "Enter your message",
21
+ default: "",
22
+ },
23
+ {
24
+ key: "channel",
25
+ label: "Channel",
26
+ help_text: "The channel to send to",
27
+ required: true,
28
+ type: "string",
29
+ choices: [
30
+ { value: "#general", label: "General", sample: "#general" },
31
+ { value: "#random", label: "Random", sample: "#random" },
32
+ ],
33
+ },
34
+ {
35
+ key: "tags",
36
+ label: "Tags",
37
+ help_text: "List of tags",
38
+ type: "string",
39
+ list: true,
40
+ },
41
+ ];
42
+
43
+ const mockNeedsResponse: NeedsResponse = {
44
+ success: true,
45
+ needs: mockNeeds,
46
+ };
47
+
48
+ describe("listInputFields plugin", () => {
49
+ let mockApiClient: ApiClient;
50
+ let mockGetApp: any;
51
+
52
+ beforeEach(() => {
53
+ vi.clearAllMocks();
54
+ mockApiClient = {
55
+ post: vi.fn().mockResolvedValue(mockNeedsResponse),
56
+ } as Partial<ApiClient> as ApiClient;
57
+
58
+ mockGetApp = vi.fn().mockResolvedValue({
59
+ data: { current_implementation_id: "SlackCLIAPI@1.21.1" },
60
+ });
61
+ });
62
+
63
+ function createTestSdk() {
64
+ return createSdk(
65
+ { getApp: mockGetApp },
66
+ { api: mockApiClient, meta: {} },
67
+ ).addPlugin(listInputFieldsPlugin as any);
68
+ }
69
+
70
+ describe("schema validation", () => {
71
+ it("should throw validation error for missing required fields", () => {
72
+ const sdk = createTestSdk();
73
+ expect(() => {
74
+ sdk.listInputFields({
75
+ // Missing required fields
76
+ } as ListInputFieldsOptions);
77
+ }).toThrow(ZapierValidationError);
78
+ });
79
+
80
+ it("should throw validation error for invalid field types", () => {
81
+ const sdk = createTestSdk();
82
+ expect(() => {
83
+ sdk.listInputFields({
84
+ appKey: 123 as any,
85
+ actionType: "write",
86
+ actionKey: "send_message",
87
+ });
88
+ }).toThrow(ZapierValidationError);
89
+ });
90
+
91
+ it("should pass validation with all required fields", async () => {
92
+ const sdk = createTestSdk();
93
+ const result = await sdk.listInputFields({
94
+ appKey: "slack",
95
+ actionType: "write",
96
+ actionKey: "send_message",
97
+ });
98
+
99
+ expect(result.data).toBeDefined();
100
+ });
101
+
102
+ it("should pass validation with optional fields", async () => {
103
+ const sdk = createTestSdk();
104
+ const result = await sdk.listInputFields({
105
+ appKey: "slack",
106
+ actionType: "write",
107
+ actionKey: "send_message",
108
+ authenticationId: 123,
109
+ inputs: { channel: "#general" },
110
+ });
111
+
112
+ expect(result.data).toBeDefined();
113
+ });
114
+ });
115
+
116
+ describe("API integration", () => {
117
+ it("should call the correct API endpoint", async () => {
118
+ const sdk = createTestSdk();
119
+ await sdk.listInputFields({
120
+ appKey: "slack",
121
+ actionType: "write",
122
+ actionKey: "send_message",
123
+ });
124
+
125
+ expect(mockApiClient.post).toHaveBeenCalledWith(
126
+ "/api/v4/implementations/needs/",
127
+ {
128
+ selected_api: "SlackCLIAPI@1.21.1",
129
+ action: "send_message",
130
+ type_of: "write",
131
+ params: {},
132
+ },
133
+ );
134
+ });
135
+
136
+ it("should include authentication_id when provided", async () => {
137
+ const sdk = createTestSdk();
138
+ await sdk.listInputFields({
139
+ appKey: "slack",
140
+ actionType: "write",
141
+ actionKey: "send_message",
142
+ authenticationId: 123,
143
+ });
144
+
145
+ expect(mockApiClient.post).toHaveBeenCalledWith(
146
+ "/api/v4/implementations/needs/",
147
+ {
148
+ selected_api: "SlackCLIAPI@1.21.1",
149
+ action: "send_message",
150
+ type_of: "write",
151
+ params: {},
152
+ authentication_id: 123,
153
+ },
154
+ );
155
+ });
156
+
157
+ it("should exclude authentication_id when null", async () => {
158
+ const sdk = createTestSdk();
159
+ await sdk.listInputFields({
160
+ appKey: "slack",
161
+ actionType: "write",
162
+ actionKey: "send_message",
163
+ authenticationId: null,
164
+ });
165
+
166
+ expect(mockApiClient.post).toHaveBeenCalledWith(
167
+ "/api/v4/implementations/needs/",
168
+ {
169
+ selected_api: "SlackCLIAPI@1.21.1",
170
+ action: "send_message",
171
+ type_of: "write",
172
+ params: {},
173
+ // No authentication_id
174
+ },
175
+ );
176
+ });
177
+
178
+ it("should include inputs when provided", async () => {
179
+ const sdk = createTestSdk();
180
+ const inputs = { channel: "#general", message: "test" };
181
+
182
+ await sdk.listInputFields({
183
+ appKey: "slack",
184
+ actionType: "write",
185
+ actionKey: "send_message",
186
+ inputs,
187
+ });
188
+
189
+ expect(mockApiClient.post).toHaveBeenCalledWith(
190
+ "/api/v4/implementations/needs/",
191
+ {
192
+ selected_api: "SlackCLIAPI@1.21.1",
193
+ action: "send_message",
194
+ type_of: "write",
195
+ params: inputs,
196
+ },
197
+ );
198
+ });
199
+ });
200
+
201
+ describe("data transformation", () => {
202
+ it("should transform needs to input field items correctly", async () => {
203
+ const sdk = createTestSdk();
204
+ const result = await sdk.listInputFields({
205
+ appKey: "slack",
206
+ actionType: "write",
207
+ actionKey: "send_message",
208
+ });
209
+
210
+ expect(result.data).toHaveLength(3);
211
+
212
+ // Check message field transformation
213
+ expect(result.data[0]).toEqual(
214
+ expect.objectContaining({
215
+ id: "message",
216
+ title: "Message",
217
+ description: "The message to send",
218
+ is_required: true,
219
+ value_type: "STRING",
220
+ placeholder: "Enter your message",
221
+ default_value: "",
222
+ }),
223
+ );
224
+
225
+ // Check channel field with choices (SELECT format)
226
+ expect(result.data[1]).toEqual(
227
+ expect.objectContaining({
228
+ id: "channel",
229
+ title: "Channel",
230
+ description: "The channel to send to",
231
+ is_required: true,
232
+ value_type: "STRING",
233
+ format: "SELECT",
234
+ choices: [
235
+ { value: "#general", label: "General", sample: "#general" },
236
+ { value: "#random", label: "Random", sample: "#random" },
237
+ ],
238
+ }),
239
+ );
240
+
241
+ // Check array field
242
+ expect(result.data[2]).toEqual(
243
+ expect.objectContaining({
244
+ id: "tags",
245
+ title: "Tags",
246
+ description: "List of tags",
247
+ value_type: "ARRAY",
248
+ items: { type: "STRING" },
249
+ }),
250
+ );
251
+ });
252
+
253
+ it("should handle different field types correctly", async () => {
254
+ const complexNeeds: Need[] = [
255
+ {
256
+ key: "count",
257
+ type: "integer",
258
+ label: "Count",
259
+ required: false,
260
+ },
261
+ {
262
+ key: "price",
263
+ type: "decimal",
264
+ label: "Price",
265
+ },
266
+ {
267
+ key: "enabled",
268
+ type: "boolean",
269
+ label: "Enabled",
270
+ },
271
+ {
272
+ key: "config",
273
+ type: "dict",
274
+ label: "Configuration",
275
+ },
276
+ {
277
+ key: "description",
278
+ type: "text",
279
+ label: "Description",
280
+ },
281
+ ];
282
+
283
+ mockApiClient.post = vi.fn().mockResolvedValue({
284
+ success: true,
285
+ needs: complexNeeds,
286
+ });
287
+
288
+ const sdk = createTestSdk();
289
+ const result = await sdk.listInputFields({
290
+ appKey: "slack",
291
+ actionType: "write",
292
+ actionKey: "send_message",
293
+ });
294
+
295
+ expect(result.data[0].value_type).toBe("INTEGER");
296
+ expect(result.data[1].value_type).toBe("NUMBER");
297
+ expect(result.data[2].value_type).toBe("BOOLEAN");
298
+ expect(result.data[3].value_type).toBe("OBJECT");
299
+ expect(result.data[4].value_type).toBe("STRING");
300
+ expect(result.data[4].format).toBe("MULTILINE");
301
+ });
302
+ });
303
+
304
+ describe("error handling", () => {
305
+ it("should throw ZapierConfigurationError when app has no current_implementation_id", async () => {
306
+ mockGetApp.mockResolvedValue({
307
+ data: { current_implementation_id: undefined },
308
+ });
309
+
310
+ const sdk = createTestSdk();
311
+ await expect(
312
+ sdk.listInputFields({
313
+ appKey: "invalid",
314
+ actionType: "write",
315
+ actionKey: "send_message",
316
+ }),
317
+ ).rejects.toThrow(ZapierConfigurationError);
318
+ });
319
+
320
+ it("should throw ZapierApiError when API response indicates failure", async () => {
321
+ mockApiClient.post = vi.fn().mockResolvedValue({
322
+ success: false,
323
+ errors: ["Invalid action", "Missing parameter"],
324
+ });
325
+
326
+ const sdk = createTestSdk();
327
+ await expect(
328
+ sdk.listInputFields({
329
+ appKey: "slack",
330
+ actionType: "write",
331
+ actionKey: "invalid_action",
332
+ }),
333
+ ).rejects.toThrow(ZapierApiError);
334
+
335
+ await expect(
336
+ sdk.listInputFields({
337
+ appKey: "slack",
338
+ actionType: "write",
339
+ actionKey: "invalid_action",
340
+ }),
341
+ ).rejects.toThrow(
342
+ "Failed to get action fields: Invalid action, Missing parameter",
343
+ );
344
+ });
345
+
346
+ it("should handle API errors gracefully", async () => {
347
+ mockApiClient.post = vi
348
+ .fn()
349
+ .mockRejectedValue(new Error("Network error"));
350
+
351
+ const sdk = createTestSdk();
352
+ await expect(
353
+ sdk.listInputFields({
354
+ appKey: "slack",
355
+ actionType: "write",
356
+ actionKey: "send_message",
357
+ }),
358
+ ).rejects.toThrow("Network error");
359
+ });
360
+ });
361
+
362
+ describe("context and metadata", () => {
363
+ it("should provide context with meta information", () => {
364
+ const sdk = createTestSdk();
365
+ const context = sdk.getContext();
366
+
367
+ expect((context.meta as any).listInputFields).toBeDefined();
368
+ expect((context.meta as any).listInputFields.inputSchema).toBeDefined();
369
+ });
370
+ });
371
+
372
+ describe("pagination", () => {
373
+ it("should support async iteration over pages", async () => {
374
+ const sdk = createTestSdk();
375
+ const listInputFieldsResult = sdk.listInputFields({
376
+ appKey: "slack",
377
+ actionType: "write",
378
+ actionKey: "send_message",
379
+ });
380
+
381
+ const pages = [];
382
+ for await (const page of listInputFieldsResult) {
383
+ pages.push(page);
384
+ break; // Just get first page for testing
385
+ }
386
+
387
+ expect(pages).toHaveLength(1);
388
+ expect(pages[0].data).toHaveLength(3);
389
+ });
390
+
391
+ it("should support async iteration over individual items", async () => {
392
+ const sdk = createTestSdk();
393
+ const listInputFieldsResult = sdk.listInputFields({
394
+ appKey: "slack",
395
+ actionType: "write",
396
+ actionKey: "send_message",
397
+ });
398
+
399
+ const items = [];
400
+ for await (const item of listInputFieldsResult.items()) {
401
+ items.push(item);
402
+ }
403
+
404
+ expect(items).toHaveLength(3);
405
+ expect(items[0].id).toBe("message");
406
+ });
407
+ });
408
+ });