@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,176 @@
1
+ import type { Plugin, GetSdkType } from "../../types/plugin";
2
+ import type { ApiClient } from "../../api";
3
+ import {
4
+ RunActionSchema,
5
+ type RunActionOptions,
6
+ type RunActionPage,
7
+ } from "./schemas";
8
+ import {
9
+ ZapierValidationError,
10
+ ZapierConfigurationError,
11
+ ZapierActionError,
12
+ } from "../../types/errors";
13
+ import { createPaginatedFunction } from "../../utils/function-utils";
14
+ import type { GetActionPluginProvides } from "../getAction";
15
+ import type { GetAppPluginProvides } from "../getApp";
16
+
17
+ export interface RunActionPluginProvides {
18
+ runAction: (options?: RunActionOptions) => Promise<{ data: any[] }> &
19
+ AsyncIterable<{ data: any[]; nextCursor?: string }> & {
20
+ items(): AsyncIterable<any>;
21
+ };
22
+ context: {
23
+ meta: {
24
+ runAction: {
25
+ inputSchema: typeof RunActionSchema;
26
+ };
27
+ };
28
+ };
29
+ }
30
+
31
+ interface ExecuteActionOptions {
32
+ api: ApiClient;
33
+ sdk: GetSdkType<GetActionPluginProvides & GetAppPluginProvides>;
34
+ appKey: string;
35
+ actionKey: string;
36
+ actionType: string;
37
+ executionOptions: { inputs: Record<string, unknown> };
38
+ authenticationId?: number | null;
39
+ options: RunActionOptions;
40
+ }
41
+
42
+ async function executeAction(actionOptions: ExecuteActionOptions): Promise<{
43
+ results: unknown[];
44
+ errors?: Array<{ detail?: string; title?: string }>;
45
+ }> {
46
+ const {
47
+ api,
48
+ sdk,
49
+ appKey,
50
+ actionKey,
51
+ actionType,
52
+ executionOptions,
53
+ authenticationId,
54
+ } = actionOptions;
55
+
56
+ // Use the getApp plugin to get the current implementation ID
57
+ const appData = await sdk.getApp({ appKey });
58
+ const selectedApi = appData.data.current_implementation_id;
59
+
60
+ if (!selectedApi) {
61
+ throw new ZapierConfigurationError(
62
+ "No current_implementation_id found for app",
63
+ { configType: "current_implementation_id" },
64
+ );
65
+ }
66
+
67
+ // Step 1: POST to /actions/v1/runs to start execution
68
+ const runRequestData: {
69
+ selected_api: string;
70
+ action_key: string;
71
+ action_type: string;
72
+ inputs: Record<string, unknown>;
73
+ authentication_id?: number | null;
74
+ } = {
75
+ selected_api: selectedApi,
76
+ action_key: actionKey,
77
+ action_type: actionType,
78
+ inputs: executionOptions.inputs || {},
79
+ };
80
+
81
+ // Only include authentication_id if it's provided
82
+ if (authenticationId !== null && authenticationId !== undefined) {
83
+ runRequestData.authentication_id = authenticationId;
84
+ }
85
+
86
+ const runRequest = {
87
+ data: runRequestData,
88
+ };
89
+
90
+ const runData = await api.post("/api/actions/v1/runs", runRequest);
91
+ const runId = runData.data.id;
92
+
93
+ // Step 2: Poll GET /actions/v1/runs/{run_id} for results
94
+ return await api.poll(`/api/actions/v1/runs/${runId}`, {
95
+ successStatus: 200,
96
+ pendingStatus: 202,
97
+ resultExtractor: (result: { data: unknown }) => result.data,
98
+ });
99
+ }
100
+
101
+ export const runActionPlugin: Plugin<
102
+ GetSdkType<GetActionPluginProvides & GetAppPluginProvides>, // requires getAction and getApp in SDK
103
+ { api: ApiClient }, // requires api in context
104
+ RunActionPluginProvides
105
+ > = ({ sdk, context }) => {
106
+ const runAction = createPaginatedFunction(async function runActionPage(
107
+ options: RunActionOptions & { cursor?: string } & { pageSize: number },
108
+ ): Promise<RunActionPage> {
109
+ const { api } = context;
110
+ const {
111
+ appKey,
112
+ actionKey,
113
+ actionType,
114
+ authenticationId,
115
+ inputs = {},
116
+ } = options;
117
+
118
+ // Validate that the action exists using the getAction plugin
119
+ const actionData = await sdk.getAction({
120
+ appKey: appKey,
121
+ actionKey: actionKey,
122
+ actionType: actionType,
123
+ });
124
+
125
+ // Validate action type matches
126
+ if (actionData.data.action_type !== actionType) {
127
+ throw new ZapierValidationError(
128
+ `Action type mismatch: expected ${actionType}, got ${actionData.data.action_type}`,
129
+ );
130
+ }
131
+
132
+ // Execute the action using the Actions API (supports all action types)
133
+ const result = await executeAction({
134
+ api,
135
+ sdk,
136
+ appKey,
137
+ actionKey,
138
+ actionType,
139
+ executionOptions: { inputs },
140
+ authenticationId,
141
+ options,
142
+ });
143
+
144
+ // Check for errors in the result and throw if present
145
+ if (result.errors && result.errors.length > 0) {
146
+ const errorMessage = result.errors
147
+ .map(
148
+ (error: { detail?: string; title?: string }) =>
149
+ error.detail || error.title || "Unknown error",
150
+ )
151
+ .join("; ");
152
+
153
+ throw new ZapierActionError(`Action execution failed: ${errorMessage}`, {
154
+ appKey,
155
+ actionKey,
156
+ });
157
+ }
158
+
159
+ // Return the results array wrapped in data with empty nextCursor (no pagination for action execution)
160
+ return {
161
+ data: result.results || [],
162
+ nextCursor: undefined, // No pagination implemented yet
163
+ };
164
+ }, RunActionSchema);
165
+
166
+ return {
167
+ runAction,
168
+ context: {
169
+ meta: {
170
+ runAction: {
171
+ inputSchema: RunActionSchema,
172
+ },
173
+ },
174
+ },
175
+ };
176
+ };
@@ -0,0 +1,53 @@
1
+ import { z } from "zod";
2
+ import {
3
+ AppKeyPropertySchema,
4
+ ActionTypePropertySchema,
5
+ ActionKeyPropertySchema,
6
+ AuthenticationIdPropertySchema,
7
+ InputsPropertySchema,
8
+ } from "../../types/properties";
9
+ import type { PaginatedSdkFunction } from "../../types/functions";
10
+
11
+ // Pure Zod schema - no resolver metadata!
12
+ export const RunActionSchema = z
13
+ .object({
14
+ appKey: AppKeyPropertySchema,
15
+ actionType: ActionTypePropertySchema,
16
+ actionKey: ActionKeyPropertySchema,
17
+ authenticationId: AuthenticationIdPropertySchema.nullable().optional(),
18
+ inputs: InputsPropertySchema.optional().describe(
19
+ "Input parameters for the action",
20
+ ),
21
+ pageSize: z
22
+ .number()
23
+ .min(1)
24
+ .optional()
25
+ .describe("Number of results per page"),
26
+ maxItems: z
27
+ .number()
28
+ .min(1)
29
+ .optional()
30
+ .describe("Maximum total items to return across all pages"),
31
+ })
32
+ .describe("Execute an action with the given inputs");
33
+
34
+ // Type inferred from schema
35
+ export type RunActionOptions = z.infer<typeof RunActionSchema>;
36
+
37
+ // Page result structure (for consistency with other paginated functions)
38
+ export interface RunActionPage {
39
+ data: any[];
40
+ nextCursor?: string;
41
+ }
42
+
43
+ // Error union for this function
44
+ export type RunActionError =
45
+ | import("../../types/errors").ZapierActionError
46
+ | import("../../types/errors").ZapierValidationError
47
+ | import("../../types/errors").ZapierConfigurationError
48
+ | import("../../types/errors").ZapierUnknownError;
49
+
50
+ // SDK function interface - ready to be mixed into main SDK interface
51
+ export interface RunActionSdkFunction {
52
+ runAction: PaginatedSdkFunction<RunActionOptions, any>;
53
+ }
@@ -14,9 +14,11 @@ export const actionKeyResolver: ActionKeyResolver = {
14
14
  type: "dynamic",
15
15
  depends: ["appKey", "actionType"] as const,
16
16
  fetch: async (sdk: ZapierSdk, resolvedParams: Record<string, any>) => {
17
- const actions = await sdk.listActions({ appKey: resolvedParams.appKey });
18
- return actions.filter(
19
- (action: any) => action.type === resolvedParams.actionType,
17
+ const actionsResponse = await sdk.listActions({
18
+ appKey: resolvedParams.appKey,
19
+ });
20
+ return actionsResponse.data.filter(
21
+ (action: any) => action.action_type === resolvedParams.actionType,
20
22
  );
21
23
  },
22
24
  prompt: (actions: any[]) => ({
@@ -24,7 +26,7 @@ export const actionKeyResolver: ActionKeyResolver = {
24
26
  name: "actionKey",
25
27
  message: "Select action:",
26
28
  choices: actions.map((action) => ({
27
- name: `${action.name || action.key} - ${
29
+ name: `${action.title || action.name || action.key} - ${
28
30
  action.description || "No description"
29
31
  }`,
30
32
  value: action.key,
@@ -14,8 +14,13 @@ export const actionTypeResolver: ActionTypeResolver = {
14
14
  type: "dynamic",
15
15
  depends: ["appKey"] as const,
16
16
  fetch: async (sdk: ZapierSdk, resolvedParams: Record<string, any>) => {
17
- const actions = await sdk.listActions({ appKey: resolvedParams.appKey });
18
- const types = [...new Set(actions.map((action: any) => action.type))];
17
+ const actionsResponse = await sdk.listActions({
18
+ appKey: resolvedParams.appKey,
19
+ });
20
+
21
+ const types = [
22
+ ...new Set(actionsResponse.data.map((action) => action.action_type)),
23
+ ];
19
24
  return types.map((type) => ({ key: type, name: type }));
20
25
  },
21
26
  prompt: (types: any[]) => ({
@@ -7,5 +7,5 @@ export interface AppKeyResolver {
7
7
  export const appKeyResolver: AppKeyResolver = {
8
8
  type: "static",
9
9
  inputType: "text",
10
- placeholder: "Enter app slug (e.g., 'slack', 'github')",
10
+ placeholder: "Enter app key (e.g., 'SlackCLIAPI' or slug like 'github')",
11
11
  };
@@ -14,11 +14,20 @@ export const authenticationIdResolver: AuthenticationIdResolver = {
14
14
  type: "dynamic",
15
15
  depends: ["appKey"] as const,
16
16
  fetch: async (sdk: ZapierSdk, resolvedParams: Record<string, any>) => {
17
- // Get auths for the specific app (owned auths will be prioritized automatically)
18
- return await sdk.listAuthentications({
17
+ const myAuths = await sdk.listAuthentications({
19
18
  appKey: resolvedParams.appKey,
20
- limit: 1000,
19
+ maxItems: 1000,
20
+ owner: "me",
21
21
  });
22
+ const allAuths = await sdk.listAuthentications({
23
+ appKey: resolvedParams.appKey,
24
+ maxItems: 1000,
25
+ });
26
+ // Filter out myAuths from allAuths
27
+ const otherAuths = allAuths.data.filter(
28
+ (auth) => !myAuths.data.some((myAuth) => myAuth.id === auth.id),
29
+ );
30
+ return [...myAuths.data, ...otherAuths];
22
31
  },
23
32
  prompt: (auths: any[], params: Record<string, any>) => ({
24
33
  type: "list",
@@ -13,11 +13,13 @@ export const inputsResolver: InputsResolver = {
13
13
  type: "fields",
14
14
  depends: ["appKey", "actionKey", "actionType", "authenticationId"] as const,
15
15
  fetch: async (sdk: ZapierSdk, resolvedParams: Record<string, any>) => {
16
- return await sdk.listFields({
16
+ const fieldsResponse = await sdk.listInputFields({
17
17
  appKey: resolvedParams.appKey,
18
18
  actionKey: resolvedParams.actionKey,
19
19
  actionType: resolvedParams.actionType,
20
20
  authenticationId: resolvedParams.authenticationId,
21
+ inputs: resolvedParams.inputs, // Pass along currently resolved inputs
21
22
  });
23
+ return fieldsResponse.data;
22
24
  },
23
25
  };
@@ -1,31 +1,37 @@
1
1
  import { z } from "zod";
2
- import { withFormatter } from "../schema-utils";
2
+ import { withFormatter } from "../utils/schema-utils";
3
+ import { ActionSchema } from "../api/schemas";
3
4
 
4
5
  // ============================================================================
5
- // Action Schemas
6
+ // Action Item Schema (extends API schema with computed fields and formatting)
6
7
  // ============================================================================
7
8
 
8
9
  export const ActionItemSchema = withFormatter(
9
- z.object({
10
- key: z.string(),
11
- name: z.string().optional(),
12
- type: z.string(),
13
- appKey: z.string().optional(),
14
- description: z.string().optional(),
10
+ ActionSchema.omit({ type: true, name: true }).extend({
11
+ app_key: z.string(), // Mapped from selected_api
12
+ action_type: ActionSchema.shape.type, // Mapped from original 'type' field
13
+ title: z.string(), // Mapped from original 'name' field
14
+ type: z.literal("action"), // Fixed type identifier
15
15
  }),
16
16
  {
17
17
  format: (item) => {
18
18
  const details = [];
19
- details.push({ text: `Type: ${item.type}`, style: "accent" as const });
20
- if (item.appKey) {
21
- details.push({ text: `App: ${item.appKey}`, style: "normal" as const });
19
+ details.push({
20
+ text: `Type: ${item.action_type}`,
21
+ style: "accent" as const,
22
+ });
23
+ if (item.app_key) {
24
+ details.push({
25
+ text: `App: ${item.app_key}`,
26
+ style: "normal" as const,
27
+ });
22
28
  }
23
29
  if (item.description) {
24
30
  details.push({ text: item.description, style: "dim" as const });
25
31
  }
26
32
 
27
33
  return {
28
- title: item.name || item.key,
34
+ title: item.title || item.name || item.key,
29
35
  subtitle: `(${item.key})`,
30
36
  details,
31
37
  };
@@ -1,36 +1,28 @@
1
1
  import { z } from "zod";
2
- import { withFormatter } from "../schema-utils";
2
+ import { withFormatter } from "../utils/schema-utils";
3
3
 
4
- export { FormattedItem, FormatMetadata } from "../schema-utils";
4
+ export { FormattedItem, FormatMetadata } from "../utils/schema-utils";
5
5
 
6
6
  // ============================================================================
7
- // App Schemas
7
+ // App Item Schema (extends API schema with computed fields and formatting)
8
8
  // ============================================================================
9
9
 
10
10
  export const AppItemSchema = withFormatter(
11
11
  z.object({
12
- key: z.string(),
13
- name: z.string().optional(),
12
+ // Essential properties only
13
+ title: z.string(), // Mapped from name
14
+ key: z.string(), // Mapped from selected_api
15
+ current_implementation_id: z.string(), // From id, keeps the full version
16
+ version: z.string().optional(), // Extracted from implementation ID
14
17
  description: z.string().optional(),
15
- category: z.string().optional(),
18
+ slug: z.string().optional(),
16
19
  }),
17
20
  {
18
21
  format: (item) => {
19
- const details = [];
20
- if (item.description) {
21
- details.push({ text: item.description, style: "dim" as const });
22
- }
23
- if (item.category) {
24
- details.push({
25
- text: `Category: ${item.category}`,
26
- style: "accent" as const,
27
- });
28
- }
29
-
30
22
  return {
31
- title: item.name || item.key,
23
+ title: item.title,
32
24
  subtitle: `(${item.key})`,
33
- details,
25
+ details: [],
34
26
  };
35
27
  },
36
28
  },
@@ -1,20 +1,22 @@
1
1
  import { z } from "zod";
2
- import { withFormatter } from "../schema-utils";
2
+ import { withFormatter } from "../utils/schema-utils";
3
+ import { AuthenticationSchema } from "../api/schemas";
3
4
 
4
5
  // ============================================================================
5
- // Auth Schemas
6
+ // Authentication Item Schema (extends API schema with computed fields and formatting)
6
7
  // ============================================================================
7
8
 
8
- export const AuthItemSchema = withFormatter(
9
- z.object({
10
- id: z.number(),
11
- title: z.string().optional(),
12
- identifier: z.string().optional(),
13
- account_id: z.string().optional(),
14
- is_private: z.boolean().optional(),
15
- shared_with_all: z.boolean().optional(),
16
- marked_stale_at: z.string().optional(),
17
- }),
9
+ export const AuthenticationItemSchema = withFormatter(
10
+ AuthenticationSchema.omit({ selected_api: true, customuser_id: true }).extend(
11
+ {
12
+ implementation_id: z.string().optional(), // Renamed from selected_api
13
+ is_expired: z.string().optional(), // Mapped from is_stale
14
+ expired_at: z.string().nullable().optional(), // Mapped from marked_stale_at
15
+ app_key: z.string().optional(), // App key from implementations endpoint
16
+ version: z.string().optional(), // Version extracted from implementation_id
17
+ user_id: z.number().optional(),
18
+ },
19
+ ),
18
20
  {
19
21
  format: (item) => {
20
22
  const details = [];
@@ -27,7 +29,7 @@ export const AuthItemSchema = withFormatter(
27
29
  }
28
30
 
29
31
  details.push({
30
- text: `Account: ${item.account_id || "unknown"} | Private: ${item.is_private || false} | Shared: ${item.shared_with_all || false}`,
32
+ text: `Account: ${item.account_id} | Private: ${item.is_private} | Shared: ${item.shared_with_all}`,
31
33
  style: "dim" as const,
32
34
  });
33
35
 
@@ -47,6 +49,9 @@ export const AuthItemSchema = withFormatter(
47
49
  },
48
50
  );
49
51
 
52
+ // Legacy alias for backward compatibility
53
+ export const AuthItemSchema = AuthenticationItemSchema;
54
+
50
55
  // ============================================================================
51
56
  // Type Exports
52
57
  // ============================================================================
@@ -1,25 +1,117 @@
1
1
  import { z } from "zod";
2
- import { withFormatter } from "../schema-utils";
2
+ import { withFormatter } from "../utils/schema-utils";
3
+ import { NeedSchema } from "../api/schemas";
3
4
 
4
5
  // ============================================================================
5
- // Field Schemas
6
+ // Input Field Item Schema (extends API Need schema with computed fields and formatting)
6
7
  // ============================================================================
7
8
 
8
- export const FieldItemSchema = withFormatter(
9
- z.object({
10
- key: z.string(),
11
- name: z.string().optional(),
12
- description: z.string().optional(),
9
+ export const InputFieldItemSchema = withFormatter(
10
+ NeedSchema.omit({
11
+ depends_on: true,
12
+ placeholder: true,
13
+ required: true,
14
+ format: true,
15
+ }).extend({
16
+ id: z.string(), // Mapped from 'key'
17
+ default_value: z.string(), // Mapped from 'default' with fallback to ""
18
+ depends_on: z.array(z.string()), // Override: mapped from 'depends_on' with fallback to []
19
+ description: z.string(), // Mapped from 'help_text' with fallback to ""
20
+ invalidates_input_fields: z.boolean(), // Mapped from 'alters_custom_fields' with fallback to false
21
+ is_required: z.boolean(), // Override: mapped from 'required' with fallback to false
22
+ placeholder: z.string(), // Override: mapped from 'placeholder' with fallback to ""
23
+ title: z.string(), // Mapped from 'label' with fallback to ""
24
+ value_type: z.string(), // Computed from InputFieldType enum
25
+ format: z.string().optional(), // Override: computed from InputFieldFormat enum (optional)
26
+ items: z.object({ type: z.string() }).optional(), // Computed from ItemsType enum (optional, only for arrays)
13
27
  }),
14
28
  {
15
29
  format: (item) => {
16
30
  const details = [];
17
- if (item.description) {
18
- details.push({ text: item.description, style: "dim" as const });
31
+
32
+ // Type and required status
33
+ const typeInfo = [
34
+ item.type && `Type: ${item.type}`,
35
+ `Required: ${item.required ? "Yes" : "No"}`,
36
+ ]
37
+ .filter(Boolean)
38
+ .join(" | ");
39
+ if (typeInfo) {
40
+ details.push({ text: typeInfo, style: "dim" as const });
41
+ }
42
+
43
+ // Help text
44
+ if (item.helpText) {
45
+ details.push({ text: item.helpText, style: "normal" as const });
46
+ }
47
+
48
+ // Default value
49
+ if (item.default !== undefined) {
50
+ details.push({
51
+ text: `Default: ${item.default}`,
52
+ style: "accent" as const,
53
+ });
54
+ }
55
+
56
+ // Placeholder
57
+ if (item.placeholder) {
58
+ details.push({
59
+ text: `Placeholder: ${item.placeholder}`,
60
+ style: "dim" as const,
61
+ });
62
+ }
63
+
64
+ // Choices
65
+ if (item.choices && item.choices.length > 0) {
66
+ const choiceText =
67
+ item.choices.length <= 3
68
+ ? `Choices: ${item.choices.map((c: any) => c.label || c.value).join(", ")}`
69
+ : `Choices: ${item.choices
70
+ .slice(0, 3)
71
+ .map((c: any) => c.label || c.value)
72
+ .join(", ")} (+${item.choices.length - 3} more)`;
73
+ details.push({ text: choiceText, style: "accent" as const });
74
+ }
75
+
76
+ // Dependencies
77
+ if (item.dependsOn && item.dependsOn.length > 0) {
78
+ details.push({
79
+ text: `Depends on: ${item.dependsOn.join(", ")}`,
80
+ style: "warning" as const,
81
+ });
82
+ }
83
+
84
+ // Format information
85
+ if (item.format) {
86
+ details.push({ text: `Format: ${item.format}`, style: "dim" as const });
87
+ }
88
+
89
+ // Input format
90
+ if (item.inputFormat && item.inputFormat.length > 0) {
91
+ details.push({
92
+ text: `Input formats: ${item.inputFormat.join(", ")}`,
93
+ style: "dim" as const,
94
+ });
95
+ }
96
+
97
+ // Special field flags
98
+ const flags = [];
99
+ if (item.computed) flags.push("computed");
100
+ if (item.customField) flags.push("custom");
101
+ if (flags.length > 0) {
102
+ details.push({
103
+ text: `Flags: ${flags.join(", ")}`,
104
+ style: "success" as const,
105
+ });
106
+ }
107
+
108
+ // Backwards compatibility: show description if no helpText
109
+ if (item.description && !item.helpText) {
110
+ details.push({ text: item.description, style: "normal" as const });
19
111
  }
20
112
 
21
113
  return {
22
- title: item.name || item.key,
114
+ title: item.label || item.name || item.key,
23
115
  subtitle: `(${item.key})`,
24
116
  details,
25
117
  };
@@ -31,4 +123,7 @@ export const FieldItemSchema = withFormatter(
31
123
  // Type Exports
32
124
  // ============================================================================
33
125
 
34
- export type FieldItem = z.infer<typeof FieldItemSchema>;
126
+ export type InputFieldItem = z.infer<typeof InputFieldItemSchema>;
127
+
128
+ // Legacy alias for backward compatibility
129
+ export type FieldItem = InputFieldItem;
@@ -0,0 +1,43 @@
1
+ import { z } from "zod";
2
+ import { withFormatter } from "../utils/schema-utils";
3
+ import { UserProfileSchema } from "../api/schemas";
4
+
5
+ export { FormattedItem, FormatMetadata } from "../utils/schema-utils";
6
+
7
+ // ============================================================================
8
+ // User Profile Item Schema (extends API schema with computed fields and formatting)
9
+ // ============================================================================
10
+
11
+ export const UserProfileItemSchema = withFormatter(
12
+ UserProfileSchema.omit({ user_id: true }).extend({
13
+ full_name: z.string(), // Computed field: first_name + " " + last_name
14
+ }),
15
+ {
16
+ format: (item) => {
17
+ const details = [];
18
+ details.push({ text: item.email, style: "dim" as const });
19
+ if (item.timezone) {
20
+ details.push({
21
+ text: `Timezone: ${item.timezone}`,
22
+ style: "accent" as const,
23
+ });
24
+ }
25
+ details.push({
26
+ text: `Member since: ${item.since_signup}`,
27
+ style: "dim" as const,
28
+ });
29
+
30
+ return {
31
+ title: item.full_name,
32
+ subtitle: `@${item.username}`,
33
+ details,
34
+ };
35
+ },
36
+ },
37
+ );
38
+
39
+ // ============================================================================
40
+ // Type Exports
41
+ // ============================================================================
42
+
43
+ export type UserProfileItem = z.infer<typeof UserProfileItemSchema>;