@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,26 @@
1
+ import { z } from "zod";
2
+ import { withOutputSchema } from "../../utils/schema-utils";
3
+ import { UserProfileItemSchema } from "../../schemas/UserProfile";
4
+ import type { FunctionOptions } from "../../types/functions";
5
+ import type { UserProfileItem } from "../../types/domain";
6
+ import { ZapierApiError, ZapierValidationError } from "../../types/errors";
7
+
8
+ // Union of all possible errors for getProfile
9
+ export type GetProfileError = ZapierApiError | ZapierValidationError;
10
+
11
+ // Pure Zod schema - no resolver metadata!
12
+ export const GetProfileSchema = withOutputSchema(
13
+ z.object({}).optional().describe("Get current user's profile information"),
14
+ UserProfileItemSchema,
15
+ );
16
+
17
+ // Type inferred from schema + function config
18
+ export type GetProfileOptions = z.infer<typeof GetProfileSchema> &
19
+ FunctionOptions;
20
+
21
+ // SDK function interface - ready to be mixed into main SDK interface
22
+ export interface GetProfileSdkFunction {
23
+ getProfile: (
24
+ options?: GetProfileOptions,
25
+ ) => Promise<{ data: UserProfileItem }>;
26
+ }
@@ -0,0 +1,582 @@
1
+ import { describe, it, expect, vi, beforeEach } from "vitest";
2
+ import {
3
+ ZapierValidationError,
4
+ ZapierAuthenticationError,
5
+ ZapierConfigurationError,
6
+ } from "../../types/errors";
7
+ import { listActionsPlugin } from "./index";
8
+ import { createSdk } from "../../sdk";
9
+ import type { ApiClient } from "../../api";
10
+ import type { ListActionsOptions } from "./schemas";
11
+ import { App } from "../../api/types";
12
+ import { GetAppSchema } from "../getApp/schemas";
13
+
14
+ const mockAppResponse = {
15
+ data: {
16
+ slug: "slack",
17
+ name: "Slack",
18
+ current_implementation_id: "SlackCLIAPI@1.20.0",
19
+ key: "slack",
20
+ title: "Slack",
21
+ hex_color: "#4A154B",
22
+ } as Partial<App> as App & { key: string; title: string; hex_color: string },
23
+ };
24
+
25
+ const mockImplementationsResponse = {
26
+ results: [
27
+ {
28
+ slug: "slack",
29
+ selected_api: "slack",
30
+ actions: [
31
+ {
32
+ key: "user_by_email",
33
+ name: "Search User by Email",
34
+ description: "Find a user by email address",
35
+ type_of: "search",
36
+ type: "search",
37
+ },
38
+ {
39
+ key: "send_message",
40
+ name: "Send Message",
41
+ description: "Send a message to a channel",
42
+ type_of: "write",
43
+ type: "write",
44
+ },
45
+ {
46
+ key: "create_channel",
47
+ name: "Create Channel",
48
+ description: "Create a new channel",
49
+ type_of: "write",
50
+ type: "write",
51
+ },
52
+ ],
53
+ },
54
+ ],
55
+ meta: {
56
+ next_cursor: null,
57
+ },
58
+ };
59
+
60
+ const mockEmptyImplementationsResponse = {
61
+ results: [],
62
+ meta: {
63
+ next_cursor: null,
64
+ },
65
+ };
66
+
67
+ describe("listActions plugin", () => {
68
+ let mockApiClient: ApiClient;
69
+ let mockGetApp: any;
70
+
71
+ beforeEach(() => {
72
+ vi.clearAllMocks();
73
+ mockApiClient = {
74
+ get: vi.fn().mockResolvedValue(mockImplementationsResponse),
75
+ } as Partial<ApiClient> as ApiClient;
76
+
77
+ mockGetApp = vi.fn().mockResolvedValue(mockAppResponse);
78
+ });
79
+
80
+ function createTestSdk() {
81
+ // Create a proper plugin chain with context dependencies
82
+ const mockGetAppPlugin = () => ({
83
+ getApp: mockGetApp,
84
+ context: {
85
+ meta: {
86
+ getApp: {
87
+ inputSchema: GetAppSchema,
88
+ },
89
+ },
90
+ },
91
+ });
92
+
93
+ // Build SDK with proper plugin composition, providing API in initial context
94
+ return createSdk({}, { api: mockApiClient, meta: {} })
95
+ .addPlugin(mockGetAppPlugin)
96
+ .addPlugin(listActionsPlugin);
97
+ }
98
+
99
+ describe("schema validation", () => {
100
+ it("should pass validation with valid appKey", async () => {
101
+ const sdk = createTestSdk();
102
+ const result = await sdk.listActions({ appKey: "slack" });
103
+ expect(result.data).toHaveLength(3);
104
+ });
105
+
106
+ it("should throw validation error for missing appKey", () => {
107
+ const sdk = createTestSdk();
108
+ expect(() => {
109
+ sdk.listActions(
110
+ {} as Partial<ListActionsOptions> as ListActionsOptions,
111
+ );
112
+ }).toThrow(ZapierValidationError);
113
+ });
114
+
115
+ it("should throw validation error for invalid appKey type", () => {
116
+ const sdk = createTestSdk();
117
+ expect(() => {
118
+ sdk.listActions({
119
+ appKey: 123 as any,
120
+ });
121
+ }).toThrow(ZapierValidationError);
122
+ });
123
+
124
+ it("should throw validation error for empty appKey", () => {
125
+ const sdk = createTestSdk();
126
+ expect(() => {
127
+ sdk.listActions({ appKey: "" });
128
+ }).toThrow(ZapierValidationError);
129
+ });
130
+
131
+ it("should throw validation error for invalid pageSize", () => {
132
+ const sdk = createTestSdk();
133
+ expect(() => {
134
+ sdk.listActions({ appKey: "slack", pageSize: 0 });
135
+ }).toThrow(ZapierValidationError);
136
+
137
+ expect(() => {
138
+ sdk.listActions({ appKey: "slack", pageSize: -5 });
139
+ }).toThrow(ZapierValidationError);
140
+ });
141
+
142
+ it("should throw validation error for invalid maxItems", () => {
143
+ const sdk = createTestSdk();
144
+ expect(() => {
145
+ sdk.listActions({ appKey: "slack", maxItems: 0 as any });
146
+ }).toThrow(ZapierValidationError);
147
+
148
+ expect(() => {
149
+ sdk.listActions({ appKey: "slack", maxItems: -10 as any });
150
+ }).toThrow(ZapierValidationError);
151
+ });
152
+
153
+ it("should throw validation error for invalid actionType", () => {
154
+ const sdk = createTestSdk();
155
+ expect(() => {
156
+ sdk.listActions({
157
+ appKey: "slack",
158
+ actionType: "invalid-type" as any,
159
+ });
160
+ }).toThrow(ZapierValidationError);
161
+ });
162
+
163
+ it("should pass validation with all valid fields", async () => {
164
+ const sdk = createTestSdk();
165
+ const result = await sdk.listActions({
166
+ appKey: "slack",
167
+ actionType: "write",
168
+ pageSize: 10,
169
+ maxItems: 50,
170
+ });
171
+
172
+ expect(result.data).toHaveLength(2); // Only write actions
173
+ expect(
174
+ result.data.every((action) => action.action_type === "write"),
175
+ ).toBe(true);
176
+ });
177
+ });
178
+
179
+ describe("actionType enum validation", () => {
180
+ const validActionTypes = [
181
+ "read",
182
+ "read_bulk",
183
+ "write",
184
+ "run",
185
+ "search",
186
+ "search_or_write",
187
+ "search_and_write",
188
+ "filter",
189
+ ] as const;
190
+
191
+ validActionTypes.forEach((actionType) => {
192
+ it(`should accept valid actionType: ${actionType}`, async () => {
193
+ const mockResponse = {
194
+ results: [
195
+ {
196
+ slug: "slack",
197
+ actions: [
198
+ {
199
+ key: "test_action",
200
+ name: "Test Action",
201
+ description: "Test description",
202
+ type_of: actionType,
203
+ type: actionType,
204
+ },
205
+ ],
206
+ },
207
+ ],
208
+ meta: { next_cursor: null },
209
+ };
210
+
211
+ mockApiClient.get = vi.fn().mockResolvedValue(mockResponse);
212
+
213
+ const sdk = createTestSdk();
214
+ const result = await sdk.listActions({
215
+ appKey: "slack",
216
+ actionType: actionType,
217
+ });
218
+
219
+ expect(result.data).toHaveLength(1);
220
+ expect(result.data[0].action_type).toBe(actionType);
221
+ });
222
+ });
223
+ });
224
+
225
+ describe("data transformation", () => {
226
+ it("should transform implementation actions to ActionItem format", async () => {
227
+ const sdk = createTestSdk();
228
+ const result = await sdk.listActions({ appKey: "slack" });
229
+
230
+ const firstAction = result.data[0];
231
+
232
+ // Check all required ActionItem fields are present
233
+ expect(firstAction).toHaveProperty("key");
234
+ expect(firstAction).toHaveProperty("type", "action");
235
+ expect(firstAction).toHaveProperty("action_type");
236
+ expect(firstAction).toHaveProperty("title");
237
+ expect(firstAction).toHaveProperty("app_key", "slack");
238
+ expect(firstAction).toHaveProperty("description");
239
+
240
+ // Check that title is mapped from API name field
241
+ expect(firstAction.title).toBe("Search User by Email");
242
+ expect(firstAction.app_key).toBe("slack");
243
+ expect(firstAction.type).toBe("action");
244
+ });
245
+
246
+ it("should map type_of to action_type", async () => {
247
+ const sdk = createTestSdk();
248
+ const result = await sdk.listActions({ appKey: "slack" });
249
+
250
+ expect(result.data[0].action_type).toBe("search"); // From type_of field
251
+ expect(result.data[1].action_type).toBe("write"); // From type_of field
252
+ });
253
+
254
+ it("should fall back to type field if type_of is missing", async () => {
255
+ const mockResponseWithoutTypeOf = {
256
+ results: [
257
+ {
258
+ slug: "slack",
259
+ actions: [
260
+ {
261
+ key: "test_action",
262
+ name: "Test Action",
263
+ description: "Test description",
264
+ type: "read", // Only type field, no type_of
265
+ },
266
+ ],
267
+ },
268
+ ],
269
+ meta: { next_cursor: null },
270
+ };
271
+
272
+ mockApiClient.get = vi.fn().mockResolvedValue(mockResponseWithoutTypeOf);
273
+
274
+ const sdk = createTestSdk();
275
+ const result = await sdk.listActions({ appKey: "slack" });
276
+
277
+ expect(result.data[0].action_type).toBe("read"); // Falls back to type field
278
+ });
279
+
280
+ it("should handle actions with read type", async () => {
281
+ const mockResponseWithoutType = {
282
+ results: [
283
+ {
284
+ slug: "slack",
285
+ actions: [
286
+ {
287
+ key: "test_action",
288
+ name: "Test Action",
289
+ description: "Test description",
290
+ type: "read", // Provide the required type field
291
+ },
292
+ ],
293
+ },
294
+ ],
295
+ meta: { next_cursor: null },
296
+ };
297
+
298
+ mockApiClient.get = vi.fn().mockResolvedValue(mockResponseWithoutType);
299
+
300
+ const sdk = createTestSdk();
301
+ const result = await sdk.listActions({ appKey: "slack" });
302
+
303
+ expect(result.data[0].action_type).toBe("read"); // Should match provided type
304
+ });
305
+ });
306
+
307
+ describe("filtering", () => {
308
+ it("should filter actions by actionType", async () => {
309
+ const sdk = createTestSdk();
310
+ const result = await sdk.listActions({
311
+ appKey: "slack",
312
+ actionType: "write",
313
+ });
314
+
315
+ expect(result.data).toHaveLength(2);
316
+ expect(
317
+ result.data.every((action) => action.action_type === "write"),
318
+ ).toBe(true);
319
+ expect(result.data.map((action) => action.key)).toEqual([
320
+ "send_message",
321
+ "create_channel",
322
+ ]);
323
+ });
324
+
325
+ it("should return empty array when no actions match filter", async () => {
326
+ const sdk = createTestSdk();
327
+ const result = await sdk.listActions({
328
+ appKey: "slack",
329
+ actionType: "filter", // No actions of this type in mock data
330
+ });
331
+
332
+ expect(result.data).toHaveLength(0);
333
+ });
334
+
335
+ it("should return all actions when no actionType filter provided", async () => {
336
+ const sdk = createTestSdk();
337
+ const result = await sdk.listActions({ appKey: "slack" });
338
+
339
+ expect(result.data).toHaveLength(3); // All actions
340
+ });
341
+ });
342
+
343
+ describe("pagination", () => {
344
+ it("should handle maxItems limit", async () => {
345
+ const sdk = createTestSdk();
346
+ const result = await sdk.listActions({
347
+ appKey: "slack",
348
+ maxItems: 2,
349
+ });
350
+
351
+ expect(result.data).toHaveLength(2); // Limited to maxItems
352
+ });
353
+
354
+ it("should support async iteration over pages", async () => {
355
+ const sdk = createTestSdk();
356
+ const listActions = sdk.listActions({ appKey: "slack" });
357
+
358
+ const pages = [];
359
+ for await (const page of listActions) {
360
+ pages.push(page);
361
+ break; // Just get first page for testing
362
+ }
363
+
364
+ expect(pages).toHaveLength(1);
365
+ expect(pages[0].data).toHaveLength(3);
366
+ expect(pages[0].data[0].key).toBe("user_by_email");
367
+ });
368
+
369
+ it("should support async iteration over individual items", async () => {
370
+ const sdk = createTestSdk();
371
+ const listActions = sdk.listActions({
372
+ appKey: "slack",
373
+ maxItems: 2,
374
+ });
375
+
376
+ const items = [];
377
+ for await (const item of listActions.items()) {
378
+ items.push(item);
379
+ }
380
+
381
+ expect(items).toHaveLength(2);
382
+ expect(items[0].key).toBe("user_by_email");
383
+ expect(items[1].key).toBe("send_message");
384
+ });
385
+
386
+ it("should respect pageSize parameter", async () => {
387
+ const sdk = createTestSdk();
388
+ await sdk.listActions({
389
+ appKey: "slack",
390
+ pageSize: 10,
391
+ });
392
+
393
+ // Note: Since listActions doesn't actually use pagination internally,
394
+ // we just verify it accepts the parameter without error
395
+ expect(mockApiClient.get).toHaveBeenCalled();
396
+ });
397
+ });
398
+
399
+ describe("API integration", () => {
400
+ it("should call getApp to get implementation ID", async () => {
401
+ const sdk = createTestSdk();
402
+ await sdk.listActions({ appKey: "slack" });
403
+
404
+ expect(mockGetApp).toHaveBeenCalledWith({
405
+ appKey: "slack",
406
+ });
407
+ });
408
+
409
+ it("should pass correct search parameters to implementations API", async () => {
410
+ const sdk = createTestSdk();
411
+ await sdk.listActions({ appKey: "slack" });
412
+
413
+ expect(mockApiClient.get).toHaveBeenCalledWith(
414
+ "/api/v4/implementations/",
415
+ expect.objectContaining({
416
+ searchParams: expect.objectContaining({
417
+ global: "true",
418
+ public_only: "true",
419
+ selected_apis: "SlackCLIAPI", // Extracted from current_implementation_id
420
+ }),
421
+ }),
422
+ );
423
+ });
424
+ });
425
+
426
+ describe("error handling", () => {
427
+ it("should throw ZapierConfigurationError when app has no current_implementation_id", async () => {
428
+ mockGetApp.mockResolvedValue({
429
+ data: {
430
+ ...mockAppResponse.data,
431
+ current_implementation_id: undefined, // Missing implementation ID
432
+ },
433
+ });
434
+
435
+ const sdk = createTestSdk();
436
+ await expect(sdk.listActions({ appKey: "slack" })).rejects.toThrow(
437
+ ZapierConfigurationError,
438
+ );
439
+ });
440
+
441
+ it("should throw ZapierConfigurationError when current_implementation_id is empty", async () => {
442
+ mockGetApp.mockResolvedValue({
443
+ data: {
444
+ ...mockAppResponse.data,
445
+ current_implementation_id: "", // Empty implementation ID
446
+ },
447
+ });
448
+
449
+ const sdk = createTestSdk();
450
+ await expect(sdk.listActions({ appKey: "slack" })).rejects.toThrow(
451
+ ZapierConfigurationError,
452
+ );
453
+ });
454
+
455
+ it("should handle authentication error (401)", async () => {
456
+ mockApiClient.get = vi.fn().mockImplementation((_url, options) => {
457
+ if (options.customErrorHandler) {
458
+ const error = options.customErrorHandler({ status: 401 });
459
+ if (error) {
460
+ throw error;
461
+ }
462
+ }
463
+ throw new Error("Unauthorized");
464
+ });
465
+
466
+ const sdk = createTestSdk();
467
+ await expect(sdk.listActions({ appKey: "slack" })).rejects.toThrow(
468
+ ZapierAuthenticationError,
469
+ );
470
+ });
471
+
472
+ it("should handle forbidden error (403)", async () => {
473
+ mockApiClient.get = vi.fn().mockImplementation((_url, options) => {
474
+ if (options.customErrorHandler) {
475
+ const error = options.customErrorHandler({ status: 403 });
476
+ if (error) {
477
+ throw error;
478
+ }
479
+ }
480
+ throw new Error("Forbidden");
481
+ });
482
+
483
+ const sdk = createTestSdk();
484
+ await expect(sdk.listActions({ appKey: "slack" })).rejects.toThrow(
485
+ ZapierAuthenticationError,
486
+ );
487
+ });
488
+
489
+ it("should return empty array when implementations API returns no results", async () => {
490
+ mockApiClient.get = vi
491
+ .fn()
492
+ .mockResolvedValue(mockEmptyImplementationsResponse);
493
+
494
+ const sdk = createTestSdk();
495
+ const result = await sdk.listActions({ appKey: "slack" });
496
+
497
+ expect(result.data).toHaveLength(0);
498
+ });
499
+
500
+ it("should handle implementation without actions", async () => {
501
+ const mockResponseWithoutActions = {
502
+ results: [
503
+ {
504
+ slug: "slack",
505
+ // No actions property
506
+ },
507
+ ],
508
+ meta: { next_cursor: null },
509
+ };
510
+
511
+ mockApiClient.get = vi.fn().mockResolvedValue(mockResponseWithoutActions);
512
+
513
+ const sdk = createTestSdk();
514
+ const result = await sdk.listActions({ appKey: "slack" });
515
+
516
+ expect(result.data).toHaveLength(0);
517
+ });
518
+
519
+ it("should propagate getApp errors", async () => {
520
+ mockGetApp.mockRejectedValue(new Error("App not found"));
521
+
522
+ const sdk = createTestSdk();
523
+ await expect(sdk.listActions({ appKey: "nonexistent" })).rejects.toThrow(
524
+ "App not found",
525
+ );
526
+ });
527
+ });
528
+
529
+ describe("implementation ID extraction", () => {
530
+ it("should extract implementation name from versioned ID", async () => {
531
+ mockGetApp.mockResolvedValue({
532
+ data: {
533
+ ...mockAppResponse.data,
534
+ current_implementation_id: "CustomAPIName@2.5.0",
535
+ },
536
+ });
537
+
538
+ const sdk = createTestSdk();
539
+ await sdk.listActions({ appKey: "slack" });
540
+
541
+ expect(mockApiClient.get).toHaveBeenCalledWith(
542
+ "/api/v4/implementations/",
543
+ expect.objectContaining({
544
+ searchParams: expect.objectContaining({
545
+ selected_apis: "CustomAPIName", // Extracted name without version
546
+ }),
547
+ }),
548
+ );
549
+ });
550
+
551
+ it("should handle implementation ID without version", async () => {
552
+ mockGetApp.mockResolvedValue({
553
+ data: {
554
+ ...mockAppResponse.data,
555
+ current_implementation_id: "PlainAPIName",
556
+ },
557
+ });
558
+
559
+ const sdk = createTestSdk();
560
+ await sdk.listActions({ appKey: "slack" });
561
+
562
+ expect(mockApiClient.get).toHaveBeenCalledWith(
563
+ "/api/v4/implementations/",
564
+ expect.objectContaining({
565
+ searchParams: expect.objectContaining({
566
+ selected_apis: "PlainAPIName", // Used as-is
567
+ }),
568
+ }),
569
+ );
570
+ });
571
+ });
572
+
573
+ describe("context and metadata", () => {
574
+ it("should provide context with meta information", () => {
575
+ const sdk = createTestSdk();
576
+ const context = sdk.getContext();
577
+
578
+ expect(context.meta.listActions).toBeDefined();
579
+ expect(context.meta.listActions.inputSchema).toBeDefined();
580
+ });
581
+ });
582
+ });