@zapier/zapier-sdk 0.4.1 → 0.5.1

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 (375) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +343 -0
  3. package/dist/api/auth.d.ts +9 -0
  4. package/dist/api/auth.d.ts.map +1 -0
  5. package/dist/api/auth.js +25 -0
  6. package/dist/api/client.d.ts +9 -0
  7. package/dist/api/client.d.ts.map +1 -0
  8. package/dist/api/client.js +322 -0
  9. package/dist/api/debug.d.ts +13 -0
  10. package/dist/api/debug.d.ts.map +1 -0
  11. package/dist/api/debug.js +55 -0
  12. package/dist/api/index.d.ts +29 -0
  13. package/dist/api/index.d.ts.map +1 -0
  14. package/dist/api/index.js +41 -0
  15. package/dist/api/polling.d.ts +16 -0
  16. package/dist/api/polling.d.ts.map +1 -0
  17. package/dist/api/polling.js +45 -0
  18. package/dist/api/schemas.d.ts +2473 -0
  19. package/dist/api/schemas.d.ts.map +1 -0
  20. package/dist/api/schemas.js +355 -0
  21. package/dist/api/types.d.ts +75 -0
  22. package/dist/api/types.d.ts.map +1 -0
  23. package/dist/api/types.js +11 -0
  24. package/dist/auth.d.ts +34 -0
  25. package/dist/auth.d.ts.map +1 -0
  26. package/dist/auth.js +47 -0
  27. package/dist/constants.d.ts +10 -0
  28. package/dist/constants.d.ts.map +1 -0
  29. package/dist/constants.js +9 -0
  30. package/dist/index.cjs +2108 -1379
  31. package/dist/index.d.mts +2440 -620
  32. package/dist/index.d.ts +17 -892
  33. package/dist/index.d.ts.map +1 -0
  34. package/dist/index.js +20 -0
  35. package/dist/index.mjs +2093 -1362
  36. package/dist/plugins/api/index.d.ts +14 -0
  37. package/dist/plugins/api/index.d.ts.map +1 -0
  38. package/dist/plugins/api/index.js +21 -0
  39. package/dist/plugins/apps/index.d.ts +11 -0
  40. package/dist/plugins/apps/index.d.ts.map +1 -0
  41. package/dist/plugins/apps/index.js +91 -0
  42. package/dist/plugins/apps/types.d.ts +30 -0
  43. package/dist/plugins/apps/types.d.ts.map +1 -0
  44. package/dist/plugins/apps/types.js +2 -0
  45. package/dist/plugins/fetch/index.d.ts +21 -0
  46. package/dist/plugins/fetch/index.d.ts.map +1 -0
  47. package/dist/plugins/fetch/index.js +20 -0
  48. package/dist/plugins/findFirstAuthentication/index.d.ts +20 -0
  49. package/dist/plugins/findFirstAuthentication/index.d.ts.map +1 -0
  50. package/dist/plugins/findFirstAuthentication/index.js +24 -0
  51. package/dist/plugins/findFirstAuthentication/index.test.d.ts +2 -0
  52. package/dist/plugins/findFirstAuthentication/index.test.d.ts.map +1 -0
  53. package/dist/plugins/findFirstAuthentication/index.test.js +171 -0
  54. package/dist/plugins/findFirstAuthentication/schemas.d.ts +29 -0
  55. package/dist/plugins/findFirstAuthentication/schemas.d.ts.map +1 -0
  56. package/dist/plugins/findFirstAuthentication/schemas.js +18 -0
  57. package/dist/plugins/findUniqueAuthentication/index.d.ts +20 -0
  58. package/dist/plugins/findUniqueAuthentication/index.d.ts.map +1 -0
  59. package/dist/plugins/findUniqueAuthentication/index.js +31 -0
  60. package/dist/plugins/findUniqueAuthentication/index.test.d.ts +2 -0
  61. package/dist/plugins/findUniqueAuthentication/index.test.d.ts.map +1 -0
  62. package/dist/plugins/findUniqueAuthentication/index.test.js +152 -0
  63. package/dist/plugins/findUniqueAuthentication/schemas.d.ts +29 -0
  64. package/dist/plugins/findUniqueAuthentication/schemas.d.ts.map +1 -0
  65. package/dist/plugins/findUniqueAuthentication/schemas.js +18 -0
  66. package/dist/plugins/getAction/index.d.ts +23 -0
  67. package/dist/plugins/getAction/index.d.ts.map +1 -0
  68. package/dist/plugins/getAction/index.js +28 -0
  69. package/dist/plugins/getAction/index.test.d.ts +2 -0
  70. package/dist/plugins/getAction/index.test.d.ts.map +1 -0
  71. package/dist/plugins/getAction/index.test.js +186 -0
  72. package/dist/plugins/getAction/schemas.d.ts +23 -0
  73. package/dist/plugins/getAction/schemas.d.ts.map +1 -0
  74. package/dist/plugins/getAction/schemas.js +10 -0
  75. package/dist/plugins/getApp/index.d.ts +22 -0
  76. package/dist/plugins/getApp/index.d.ts.map +1 -0
  77. package/dist/plugins/getApp/index.js +39 -0
  78. package/dist/plugins/getApp/index.test.d.ts +2 -0
  79. package/dist/plugins/getApp/index.test.d.ts.map +1 -0
  80. package/dist/plugins/getApp/index.test.js +100 -0
  81. package/dist/plugins/getApp/schemas.d.ts +18 -0
  82. package/dist/plugins/getApp/schemas.d.ts.map +1 -0
  83. package/dist/plugins/getApp/schemas.js +10 -0
  84. package/dist/plugins/getAuthentication/index.d.ts +22 -0
  85. package/dist/plugins/getAuthentication/index.d.ts.map +1 -0
  86. package/dist/plugins/getAuthentication/index.js +41 -0
  87. package/dist/plugins/getAuthentication/index.test.d.ts +2 -0
  88. package/dist/plugins/getAuthentication/index.test.d.ts.map +1 -0
  89. package/dist/plugins/getAuthentication/index.test.js +205 -0
  90. package/dist/plugins/getAuthentication/schemas.d.ts +17 -0
  91. package/dist/plugins/getAuthentication/schemas.d.ts.map +1 -0
  92. package/dist/plugins/getAuthentication/schemas.js +11 -0
  93. package/dist/plugins/getProfile/index.d.ts +23 -0
  94. package/dist/plugins/getProfile/index.d.ts.map +1 -0
  95. package/dist/plugins/getProfile/index.js +29 -0
  96. package/dist/plugins/getProfile/schemas.d.ts +13 -0
  97. package/dist/plugins/getProfile/schemas.d.ts.map +1 -0
  98. package/dist/plugins/getProfile/schemas.js +5 -0
  99. package/dist/plugins/listActions/index.d.ts +28 -0
  100. package/dist/plugins/listActions/index.d.ts.map +1 -0
  101. package/dist/plugins/listActions/index.js +61 -0
  102. package/dist/plugins/listActions/index.test.d.ts +2 -0
  103. package/dist/plugins/listActions/index.test.d.ts.map +1 -0
  104. package/dist/plugins/listActions/index.test.js +467 -0
  105. package/dist/plugins/listActions/schemas.d.ts +29 -0
  106. package/dist/plugins/listActions/schemas.d.ts.map +1 -0
  107. package/dist/plugins/listActions/schemas.js +21 -0
  108. package/dist/plugins/listApps/index.d.ts +28 -0
  109. package/dist/plugins/listApps/index.d.ts.map +1 -0
  110. package/dist/plugins/listApps/index.js +62 -0
  111. package/dist/plugins/listApps/index.test.d.ts +2 -0
  112. package/dist/plugins/listApps/index.test.d.ts.map +1 -0
  113. package/dist/plugins/listApps/index.test.js +313 -0
  114. package/dist/plugins/listApps/schemas.d.ts +30 -0
  115. package/dist/plugins/listApps/schemas.d.ts.map +1 -0
  116. package/dist/plugins/listApps/schemas.js +23 -0
  117. package/dist/plugins/listAuthentications/index.d.ts +28 -0
  118. package/dist/plugins/listAuthentications/index.d.ts.map +1 -0
  119. package/dist/plugins/listAuthentications/index.js +77 -0
  120. package/dist/plugins/listAuthentications/index.test.d.ts +2 -0
  121. package/dist/plugins/listAuthentications/index.test.d.ts.map +1 -0
  122. package/dist/plugins/listAuthentications/index.test.js +564 -0
  123. package/dist/plugins/listAuthentications/schemas.d.ts +38 -0
  124. package/dist/plugins/listAuthentications/schemas.d.ts.map +1 -0
  125. package/dist/plugins/listAuthentications/schemas.js +28 -0
  126. package/dist/plugins/listInputFields/index.d.ts +28 -0
  127. package/dist/plugins/listInputFields/index.d.ts.map +1 -0
  128. package/dist/plugins/listInputFields/index.js +133 -0
  129. package/dist/plugins/listInputFields/index.test.d.ts +2 -0
  130. package/dist/plugins/listInputFields/index.test.d.ts.map +1 -0
  131. package/dist/plugins/listInputFields/index.test.js +325 -0
  132. package/dist/plugins/listInputFields/schemas.d.ts +38 -0
  133. package/dist/plugins/listInputFields/schemas.d.ts.map +1 -0
  134. package/dist/plugins/listInputFields/schemas.js +22 -0
  135. package/dist/plugins/registry/index.d.ts +11 -0
  136. package/dist/plugins/registry/index.d.ts.map +1 -0
  137. package/dist/plugins/registry/index.js +14 -0
  138. package/dist/plugins/request/index.d.ts +19 -0
  139. package/dist/plugins/request/index.d.ts.map +1 -0
  140. package/dist/plugins/request/index.js +62 -0
  141. package/dist/plugins/request/index.test.d.ts +2 -0
  142. package/dist/plugins/request/index.test.d.ts.map +1 -0
  143. package/dist/plugins/request/index.test.js +256 -0
  144. package/dist/plugins/request/schemas.d.ts +69 -0
  145. package/dist/plugins/request/schemas.d.ts.map +1 -0
  146. package/dist/plugins/request/schemas.js +42 -0
  147. package/dist/plugins/runAction/index.d.ts +28 -0
  148. package/dist/plugins/runAction/index.d.ts.map +1 -0
  149. package/dist/plugins/runAction/index.js +86 -0
  150. package/dist/plugins/runAction/index.test.d.ts +2 -0
  151. package/dist/plugins/runAction/index.test.d.ts.map +1 -0
  152. package/dist/plugins/runAction/index.test.js +320 -0
  153. package/dist/plugins/runAction/schemas.d.ts +37 -0
  154. package/dist/plugins/runAction/schemas.d.ts.map +1 -0
  155. package/dist/plugins/runAction/schemas.js +22 -0
  156. package/dist/resolvers/actionKey.d.ts +9 -0
  157. package/dist/resolvers/actionKey.d.ts.map +1 -0
  158. package/dist/resolvers/actionKey.js +19 -0
  159. package/dist/resolvers/actionType.d.ts +9 -0
  160. package/dist/resolvers/actionType.d.ts.map +1 -0
  161. package/dist/resolvers/actionType.js +22 -0
  162. package/dist/resolvers/appKey.d.ts +7 -0
  163. package/dist/resolvers/appKey.d.ts.map +1 -0
  164. package/dist/resolvers/appKey.js +5 -0
  165. package/dist/resolvers/authenticationId.d.ts +9 -0
  166. package/dist/resolvers/authenticationId.d.ts.map +1 -0
  167. package/dist/resolvers/authenticationId.js +33 -0
  168. package/dist/resolvers/index.d.ts +40 -0
  169. package/dist/resolvers/index.d.ts.map +1 -0
  170. package/dist/resolvers/index.js +91 -0
  171. package/dist/resolvers/inputs.d.ts +8 -0
  172. package/dist/resolvers/inputs.d.ts.map +1 -0
  173. package/dist/resolvers/inputs.js +14 -0
  174. package/dist/schemas/Action.d.ts +243 -0
  175. package/dist/schemas/Action.d.ts.map +1 -0
  176. package/dist/schemas/Action.js +34 -0
  177. package/dist/schemas/App.d.ts +26 -0
  178. package/dist/schemas/App.d.ts.map +1 -0
  179. package/dist/schemas/App.js +22 -0
  180. package/dist/schemas/Auth.d.ts +161 -0
  181. package/dist/schemas/Auth.d.ts.map +1 -0
  182. package/dist/schemas/Auth.js +41 -0
  183. package/dist/schemas/Field.d.ts +144 -0
  184. package/dist/schemas/Field.d.ts.map +1 -0
  185. package/dist/schemas/Field.js +105 -0
  186. package/dist/schemas/UserProfile.d.ts +163 -0
  187. package/dist/schemas/UserProfile.d.ts.map +1 -0
  188. package/dist/schemas/UserProfile.js +29 -0
  189. package/dist/sdk.d.ts +10 -0
  190. package/dist/sdk.d.ts.map +1 -0
  191. package/dist/sdk.js +94 -0
  192. package/dist/sdk.test.d.ts +2 -0
  193. package/dist/sdk.test.d.ts.map +1 -0
  194. package/dist/sdk.test.js +135 -0
  195. package/dist/types/domain.d.ts +36 -0
  196. package/dist/types/domain.d.ts.map +1 -0
  197. package/dist/types/domain.js +1 -0
  198. package/dist/types/domain.test.d.ts +2 -0
  199. package/dist/types/domain.test.d.ts.map +1 -0
  200. package/dist/types/domain.test.js +39 -0
  201. package/dist/types/errors.d.ts +143 -0
  202. package/dist/types/errors.d.ts.map +1 -0
  203. package/dist/types/errors.js +187 -0
  204. package/dist/types/events.d.ts +38 -0
  205. package/dist/types/events.d.ts.map +1 -0
  206. package/dist/types/events.js +7 -0
  207. package/dist/types/functions.d.ts +26 -0
  208. package/dist/types/functions.d.ts.map +1 -0
  209. package/dist/types/functions.js +4 -0
  210. package/dist/types/plugin.d.ts +61 -0
  211. package/dist/types/plugin.d.ts.map +1 -0
  212. package/dist/types/plugin.js +9 -0
  213. package/dist/types/properties.d.ts +22 -0
  214. package/dist/types/properties.d.ts.map +1 -0
  215. package/dist/types/properties.js +50 -0
  216. package/dist/types/sdk.d.ts +43 -0
  217. package/dist/types/sdk.d.ts.map +1 -0
  218. package/dist/types/sdk.js +4 -0
  219. package/dist/utils/array-utils.d.ts +31 -0
  220. package/dist/utils/array-utils.d.ts.map +1 -0
  221. package/dist/utils/array-utils.js +36 -0
  222. package/dist/utils/array-utils.test.d.ts +2 -0
  223. package/dist/utils/array-utils.test.d.ts.map +1 -0
  224. package/dist/utils/array-utils.test.js +107 -0
  225. package/dist/utils/domain-utils.d.ts +78 -0
  226. package/dist/utils/domain-utils.d.ts.map +1 -0
  227. package/dist/utils/domain-utils.js +218 -0
  228. package/dist/utils/domain-utils.test.d.ts +2 -0
  229. package/dist/utils/domain-utils.test.d.ts.map +1 -0
  230. package/dist/utils/domain-utils.test.js +192 -0
  231. package/dist/utils/function-utils.d.ts +45 -0
  232. package/dist/utils/function-utils.d.ts.map +1 -0
  233. package/dist/utils/function-utils.js +158 -0
  234. package/dist/utils/function-utils.test.d.ts +2 -0
  235. package/dist/utils/function-utils.test.d.ts.map +1 -0
  236. package/dist/utils/function-utils.test.js +110 -0
  237. package/dist/utils/pagination-utils.d.ts +37 -0
  238. package/dist/utils/pagination-utils.d.ts.map +1 -0
  239. package/dist/utils/pagination-utils.js +165 -0
  240. package/dist/utils/pagination-utils.test.d.ts +17 -0
  241. package/dist/utils/pagination-utils.test.d.ts.map +1 -0
  242. package/dist/utils/pagination-utils.test.js +461 -0
  243. package/dist/utils/schema-utils.d.ts +45 -0
  244. package/dist/utils/schema-utils.d.ts.map +1 -0
  245. package/dist/utils/schema-utils.js +65 -0
  246. package/dist/utils/validation.d.ts +4 -0
  247. package/dist/utils/validation.d.ts.map +1 -0
  248. package/dist/utils/validation.js +30 -0
  249. package/dist/utils/validation.test.d.ts +2 -0
  250. package/dist/utils/validation.test.d.ts.map +1 -0
  251. package/dist/utils/validation.test.js +43 -0
  252. package/package.json +12 -3
  253. package/src/api/client.ts +394 -171
  254. package/src/api/debug.ts +10 -1
  255. package/src/api/index.ts +0 -2
  256. package/src/api/polling.ts +28 -7
  257. package/src/api/schemas.ts +387 -0
  258. package/src/api/types.ts +72 -136
  259. package/src/constants.ts +10 -0
  260. package/src/index.ts +40 -19
  261. package/src/plugins/api/index.ts +47 -0
  262. package/src/plugins/apps/index.ts +25 -19
  263. package/src/plugins/apps/types.ts +7 -11
  264. package/src/plugins/fetch/index.ts +48 -40
  265. package/src/plugins/findFirstAuthentication/index.test.ts +206 -0
  266. package/src/plugins/findFirstAuthentication/index.ts +55 -0
  267. package/src/plugins/findFirstAuthentication/schemas.ts +41 -0
  268. package/src/plugins/findUniqueAuthentication/index.test.ts +197 -0
  269. package/src/plugins/findUniqueAuthentication/index.ts +72 -0
  270. package/src/plugins/findUniqueAuthentication/schemas.ts +42 -0
  271. package/src/plugins/getAction/index.test.ts +239 -0
  272. package/src/plugins/getAction/index.ts +57 -0
  273. package/src/plugins/getAction/schemas.ts +33 -0
  274. package/src/plugins/getApp/index.test.ts +127 -0
  275. package/src/plugins/getApp/index.ts +66 -0
  276. package/src/plugins/getApp/schemas.ts +38 -0
  277. package/src/plugins/getAuthentication/index.test.ts +284 -0
  278. package/src/plugins/getAuthentication/index.ts +86 -0
  279. package/src/plugins/getAuthentication/schemas.ts +31 -0
  280. package/src/plugins/getProfile/index.ts +55 -0
  281. package/src/plugins/getProfile/schemas.ts +26 -0
  282. package/src/plugins/listActions/index.test.ts +582 -0
  283. package/src/plugins/listActions/index.ts +115 -0
  284. package/src/plugins/listActions/schemas.ts +54 -0
  285. package/src/plugins/listApps/index.test.ts +357 -0
  286. package/src/plugins/listApps/index.ts +121 -0
  287. package/src/plugins/listApps/schemas.ts +49 -0
  288. package/src/plugins/listAuthentications/index.test.ts +709 -0
  289. package/src/plugins/listAuthentications/index.ts +136 -0
  290. package/src/plugins/listAuthentications/schemas.ts +60 -0
  291. package/src/plugins/listInputFields/index.test.ts +408 -0
  292. package/src/plugins/listInputFields/index.ts +204 -0
  293. package/src/plugins/listInputFields/schemas.ts +56 -0
  294. package/src/plugins/registry/index.ts +30 -0
  295. package/src/plugins/request/index.test.ts +329 -0
  296. package/src/plugins/request/index.ts +103 -0
  297. package/src/{functions → plugins}/request/schemas.ts +20 -9
  298. package/src/plugins/runAction/index.test.ts +387 -0
  299. package/src/plugins/runAction/index.ts +176 -0
  300. package/src/plugins/runAction/schemas.ts +53 -0
  301. package/src/resolvers/actionKey.ts +6 -4
  302. package/src/resolvers/actionType.ts +7 -2
  303. package/src/resolvers/appKey.ts +1 -1
  304. package/src/resolvers/authenticationId.ts +12 -3
  305. package/src/resolvers/inputs.ts +3 -1
  306. package/src/schemas/Action.ts +18 -12
  307. package/src/schemas/App.ts +11 -19
  308. package/src/schemas/Auth.ts +18 -13
  309. package/src/schemas/Field.ts +106 -11
  310. package/src/schemas/UserProfile.ts +43 -0
  311. package/src/sdk.test.ts +212 -0
  312. package/src/sdk.ts +132 -102
  313. package/src/types/domain.test.ts +50 -0
  314. package/src/types/domain.ts +43 -75
  315. package/src/types/errors.ts +275 -0
  316. package/src/types/functions.ts +27 -0
  317. package/src/types/optional-zapier-sdk-cli-login.d.ts +37 -0
  318. package/src/types/plugin.ts +105 -0
  319. package/src/types/properties.ts +4 -3
  320. package/src/types/sdk.ts +70 -48
  321. package/src/utils/array-utils.test.ts +131 -0
  322. package/src/utils/array-utils.ts +41 -0
  323. package/src/utils/domain-utils.test.ts +239 -0
  324. package/src/utils/domain-utils.ts +283 -0
  325. package/src/utils/function-utils.test.ts +141 -0
  326. package/src/utils/function-utils.ts +245 -0
  327. package/src/utils/pagination-utils.test.ts +620 -0
  328. package/src/utils/pagination-utils.ts +242 -0
  329. package/src/utils/validation.test.ts +50 -0
  330. package/src/utils/validation.ts +44 -0
  331. package/tsconfig.build.json +16 -2
  332. package/tsconfig.json +3 -1
  333. package/tsconfig.tsbuildinfo +1 -0
  334. package/tsup.config.ts +2 -0
  335. package/src/functions/bundleCode/index.ts +0 -78
  336. package/src/functions/bundleCode/info.ts +0 -9
  337. package/src/functions/bundleCode/schemas.ts +0 -30
  338. package/src/functions/findFirstAuthentication/index.ts +0 -24
  339. package/src/functions/findFirstAuthentication/info.ts +0 -9
  340. package/src/functions/findFirstAuthentication/schemas.ts +0 -50
  341. package/src/functions/findUniqueAuthentication/index.ts +0 -35
  342. package/src/functions/findUniqueAuthentication/info.ts +0 -9
  343. package/src/functions/findUniqueAuthentication/schemas.ts +0 -50
  344. package/src/functions/generateTypes/index.ts +0 -363
  345. package/src/functions/generateTypes/info.ts +0 -9
  346. package/src/functions/generateTypes/schemas.ts +0 -31
  347. package/src/functions/getAction/index.ts +0 -33
  348. package/src/functions/getAction/info.ts +0 -9
  349. package/src/functions/getAction/schemas.ts +0 -25
  350. package/src/functions/getApp/index.ts +0 -41
  351. package/src/functions/getApp/info.ts +0 -9
  352. package/src/functions/getApp/schemas.ts +0 -20
  353. package/src/functions/getAuthentication/index.ts +0 -50
  354. package/src/functions/getAuthentication/info.ts +0 -9
  355. package/src/functions/getAuthentication/schemas.ts +0 -29
  356. package/src/functions/listActions/index.ts +0 -149
  357. package/src/functions/listActions/info.ts +0 -9
  358. package/src/functions/listActions/schemas.ts +0 -30
  359. package/src/functions/listApps/index.ts +0 -60
  360. package/src/functions/listApps/info.ts +0 -9
  361. package/src/functions/listApps/schemas.ts +0 -32
  362. package/src/functions/listAuthentications/index.ts +0 -162
  363. package/src/functions/listAuthentications/info.ts +0 -9
  364. package/src/functions/listAuthentications/schemas.ts +0 -50
  365. package/src/functions/listFields/index.ts +0 -86
  366. package/src/functions/listFields/info.ts +0 -9
  367. package/src/functions/listFields/schemas.ts +0 -36
  368. package/src/functions/request/index.ts +0 -150
  369. package/src/functions/request/info.ts +0 -11
  370. package/src/functions/runAction/index.ts +0 -127
  371. package/src/functions/runAction/info.ts +0 -9
  372. package/src/functions/runAction/schemas.ts +0 -34
  373. package/src/plugins/apps/info.ts +0 -12
  374. package/src/plugins/fetch/types.ts +0 -2
  375. /package/src/{schema-utils.ts → utils/schema-utils.ts} +0 -0
@@ -0,0 +1,100 @@
1
+ import { describe, it, expect, vi, beforeEach } from "vitest";
2
+ import { ZapierValidationError, ZapierAppNotFoundError, } from "../../types/errors";
3
+ import { getAppPlugin } from "./index";
4
+ import { createSdk } from "../../sdk";
5
+ import { apiPlugin } from "../api/index";
6
+ import { listAppsPlugin } from "../listApps";
7
+ function createTestSdk() {
8
+ return createSdk()
9
+ .addPlugin(apiPlugin, { fetch: global.fetch })
10
+ .addPlugin(listAppsPlugin)
11
+ .addPlugin(getAppPlugin);
12
+ }
13
+ describe("getApp plugin", () => {
14
+ beforeEach(() => {
15
+ vi.clearAllMocks();
16
+ });
17
+ describe("schema validation", () => {
18
+ it("should throw validation error for missing appKey", async () => {
19
+ const sdk = createTestSdk();
20
+ await expect(sdk.getApp({})).rejects.toThrow(ZapierValidationError);
21
+ });
22
+ it("should throw validation error for invalid appKey type", async () => {
23
+ const sdk = createTestSdk();
24
+ await expect(sdk.getApp({
25
+ appKey: 123,
26
+ })).rejects.toThrow(ZapierValidationError);
27
+ });
28
+ it("should throw validation error for empty string appKey", async () => {
29
+ const sdk = createTestSdk();
30
+ await expect(sdk.getApp({
31
+ appKey: "",
32
+ })).rejects.toThrow(ZapierValidationError);
33
+ });
34
+ it("should pass validation with valid appKey", async () => {
35
+ const sdk = createTestSdk();
36
+ const context = sdk.getContext();
37
+ // Mock the API client in context to respond to listApps implementation
38
+ context.api.get = vi.fn().mockResolvedValue({
39
+ results: [
40
+ {
41
+ id: "SlackCLIAPI@1.0.0",
42
+ name: "Slack",
43
+ description: "Team communication",
44
+ primary_color: "#4A154B",
45
+ categories: ["communication"],
46
+ },
47
+ ],
48
+ next: null,
49
+ });
50
+ const result = await sdk.getApp({
51
+ appKey: "slack",
52
+ });
53
+ expect(result.data.title).toBe("Slack");
54
+ expect(result.data.key).toBe("SlackCLIAPI");
55
+ expect(result.data.current_implementation_id).toBe("SlackCLIAPI@1.0.0");
56
+ expect(result.data.version).toBe("1.0.0");
57
+ });
58
+ });
59
+ describe("error handling", () => {
60
+ it("should throw ZapierAppNotFoundError when app does not exist", async () => {
61
+ const sdk = createTestSdk();
62
+ const context = sdk.getContext();
63
+ // Mock API to return empty results (app not found)
64
+ context.api.get = vi.fn().mockResolvedValue({
65
+ results: [],
66
+ next: null,
67
+ });
68
+ await expect(sdk.getApp({
69
+ appKey: "nonexistent-app",
70
+ })).rejects.toThrow(ZapierAppNotFoundError);
71
+ });
72
+ });
73
+ describe("data mapping", () => {
74
+ it("should return essential app properties", async () => {
75
+ const sdk = createTestSdk();
76
+ const context = sdk.getContext();
77
+ // Mock the API client in context to respond to listApps implementation
78
+ context.api.get = vi.fn().mockResolvedValue({
79
+ results: [
80
+ {
81
+ id: "TestCLIAPI@1.0.0",
82
+ name: "Test App",
83
+ description: "Test description",
84
+ primary_color: "#FF0000",
85
+ categories: ["testing"],
86
+ },
87
+ ],
88
+ next: null,
89
+ });
90
+ const result = await sdk.getApp({
91
+ appKey: "test",
92
+ });
93
+ expect(result.data.title).toBeDefined();
94
+ expect(result.data.key).toBeDefined();
95
+ expect(result.data.current_implementation_id).toBeDefined();
96
+ expect(result.data.title).toBe("Test App");
97
+ expect(result.data.key).toBe("TestCLIAPI");
98
+ });
99
+ });
100
+ });
@@ -0,0 +1,18 @@
1
+ import { z } from "zod";
2
+ import type { AppItem } from "../../types/domain";
3
+ import { ZapierApiError, ZapierAppNotFoundError, ZapierValidationError } from "../../types/errors";
4
+ export type GetAppError = ZapierAppNotFoundError | ZapierApiError | ZapierValidationError;
5
+ export declare const GetAppSchema: z.ZodObject<{
6
+ appKey: z.ZodString;
7
+ }, "strip", z.ZodTypeAny, {
8
+ appKey: string;
9
+ }, {
10
+ appKey: string;
11
+ }>;
12
+ export type GetAppOptions = z.infer<typeof GetAppSchema>;
13
+ export interface GetAppSdkFunction {
14
+ getApp: (options: GetAppOptions) => Promise<{
15
+ data: AppItem;
16
+ }>;
17
+ }
18
+ //# sourceMappingURL=schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/plugins/getApp/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EACL,cAAc,EACd,sBAAsB,EACtB,qBAAqB,EACtB,MAAM,oBAAoB,CAAC;AAK5B,MAAM,MAAM,WAAW,GACnB,sBAAsB,GACtB,cAAc,GACd,qBAAqB,CAAC;AAG1B,eAAO,MAAM,YAAY;;;;;;EASxB,CAAC;AAGF,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAGzD,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,OAAO,CAAC;QAAE,IAAI,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;CAChE"}
@@ -0,0 +1,10 @@
1
+ import { z } from "zod";
2
+ import { AppKeyPropertySchema } from "../../types/properties";
3
+ import { withOutputSchema } from "../../utils/schema-utils";
4
+ import { AppItemSchema } from "../../schemas/App";
5
+ // Pure Zod schema - no resolver metadata!
6
+ export const GetAppSchema = withOutputSchema(z
7
+ .object({
8
+ appKey: AppKeyPropertySchema.describe("App key of app to fetch (e.g., 'SlackCLIAPI')"),
9
+ })
10
+ .describe("Get detailed information about a specific app"), AppItemSchema);
@@ -0,0 +1,22 @@
1
+ import type { Plugin } from "../../types/plugin";
2
+ import type { ApiClient } from "../../api";
3
+ import type { AuthenticationItem } from "../../types/domain";
4
+ import { GetAuthenticationSchema, type GetAuthenticationOptions } from "./schemas";
5
+ export interface GetAuthenticationPluginProvides {
6
+ getAuthentication: (options: GetAuthenticationOptions) => Promise<{
7
+ data: AuthenticationItem;
8
+ }>;
9
+ context: {
10
+ meta: {
11
+ getAuthentication: {
12
+ inputSchema: typeof GetAuthenticationSchema;
13
+ };
14
+ };
15
+ };
16
+ }
17
+ export declare const getAuthenticationPlugin: Plugin<{}, // no SDK dependencies
18
+ {
19
+ api: ApiClient;
20
+ }, // requires api in context
21
+ GetAuthenticationPluginProvides>;
22
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/getAuthentication/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EACL,uBAAuB,EACvB,KAAK,wBAAwB,EAC9B,MAAM,WAAW,CAAC;AAQnB,MAAM,WAAW,+BAA+B;IAC9C,iBAAiB,EAAE,CACjB,OAAO,EAAE,wBAAwB,KAC9B,OAAO,CAAC;QAAE,IAAI,EAAE,kBAAkB,CAAA;KAAE,CAAC,CAAC;IAC3C,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,iBAAiB,EAAE;gBACjB,WAAW,EAAE,OAAO,uBAAuB,CAAC;aAC7C,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAC1C,EAAE,EAAE,sBAAsB;AAC1B;IAAE,GAAG,EAAE,SAAS,CAAA;CAAE,EAAE,0BAA0B;AAC9C,+BAA+B,CAsDhC,CAAC"}
@@ -0,0 +1,41 @@
1
+ import { GetAuthenticationSchema, } from "./schemas";
2
+ import { ZapierAuthenticationError, ZapierResourceNotFoundError, } from "../../types/errors";
3
+ import { createFunction } from "../../utils/function-utils";
4
+ import { normalizeAuthenticationItem } from "../../utils/domain-utils";
5
+ export const getAuthenticationPlugin = ({ context }) => {
6
+ const getAuthentication = createFunction(async function getAuthentication(options) {
7
+ const { api } = context;
8
+ const { authenticationId } = options;
9
+ const data = await api.get(`/api/v4/authentications/${authenticationId}/`, {
10
+ customErrorHandler: ({ status }) => {
11
+ if (status === 401) {
12
+ return new ZapierAuthenticationError(`Authentication failed. Your token may not have permission to access authentications or may be expired. (HTTP ${status})`, { statusCode: status });
13
+ }
14
+ if (status === 403) {
15
+ return new ZapierAuthenticationError(`Access forbidden. Your token may not have the required scopes to get authentication ${authenticationId}. (HTTP ${status})`, { statusCode: status });
16
+ }
17
+ if (status === 404) {
18
+ return new ZapierResourceNotFoundError(`Authentication ${authenticationId} not found. It may not exist or you may not have access to it. (HTTP ${status})`, {
19
+ resourceType: "Authentication",
20
+ resourceId: String(authenticationId),
21
+ });
22
+ }
23
+ return undefined;
24
+ },
25
+ authRequired: true,
26
+ });
27
+ return {
28
+ data: normalizeAuthenticationItem(data),
29
+ };
30
+ }, GetAuthenticationSchema);
31
+ return {
32
+ getAuthentication,
33
+ context: {
34
+ meta: {
35
+ getAuthentication: {
36
+ inputSchema: GetAuthenticationSchema,
37
+ },
38
+ },
39
+ },
40
+ };
41
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../../src/plugins/getAuthentication/index.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,205 @@
1
+ import { describe, it, expect, vi, beforeEach } from "vitest";
2
+ import { ZapierValidationError, ZapierAuthenticationError, ZapierResourceNotFoundError, } from "../../types/errors";
3
+ import { getAuthenticationPlugin } from "./index";
4
+ import { createSdk } from "../../sdk";
5
+ const mockAuthenticationResponse = {
6
+ id: 123,
7
+ date: "2021-01-01",
8
+ account_id: 456,
9
+ selected_api: "SlackCLIAPI@1.21.1",
10
+ is_invite_only: false,
11
+ is_private: false,
12
+ shared_with_all: false,
13
+ is_stale: "false",
14
+ marked_stale_at: null,
15
+ label: "My Slack Workspace",
16
+ title: "My Slack Workspace",
17
+ };
18
+ describe("getAuthentication plugin", () => {
19
+ let mockApiClient;
20
+ beforeEach(() => {
21
+ vi.clearAllMocks();
22
+ mockApiClient = {
23
+ get: vi.fn().mockResolvedValue(mockAuthenticationResponse),
24
+ };
25
+ });
26
+ function createTestSdk() {
27
+ return createSdk({}, { api: mockApiClient, meta: {} }).addPlugin(getAuthenticationPlugin);
28
+ }
29
+ describe("schema validation", () => {
30
+ it("should throw validation error for missing authenticationId", async () => {
31
+ const sdk = createTestSdk();
32
+ await expect(sdk.getAuthentication({})).rejects.toThrow(ZapierValidationError);
33
+ });
34
+ it("should throw validation error for invalid authenticationId type", async () => {
35
+ const sdk = createTestSdk();
36
+ await expect(sdk.getAuthentication({
37
+ authenticationId: "invalid",
38
+ })).rejects.toThrow(ZapierValidationError);
39
+ });
40
+ it("should throw validation error for negative authenticationId", async () => {
41
+ const sdk = createTestSdk();
42
+ await expect(sdk.getAuthentication({
43
+ authenticationId: -1,
44
+ })).rejects.toThrow(ZapierValidationError);
45
+ });
46
+ it("should throw validation error for zero authenticationId", async () => {
47
+ const sdk = createTestSdk();
48
+ await expect(sdk.getAuthentication({
49
+ authenticationId: 0,
50
+ })).rejects.toThrow(ZapierValidationError);
51
+ });
52
+ it("should pass validation with valid authenticationId", async () => {
53
+ const sdk = createTestSdk();
54
+ const result = await sdk.getAuthentication({
55
+ authenticationId: 123,
56
+ });
57
+ expect(result.data).toBeDefined();
58
+ });
59
+ });
60
+ describe("API integration", () => {
61
+ it("should call the correct API endpoint", async () => {
62
+ const sdk = createTestSdk();
63
+ await sdk.getAuthentication({ authenticationId: 123 });
64
+ expect(mockApiClient.get).toHaveBeenCalledWith("/api/v4/authentications/123/", expect.objectContaining({
65
+ authRequired: true,
66
+ customErrorHandler: expect.any(Function),
67
+ }));
68
+ });
69
+ it("should return normalized authentication data", async () => {
70
+ const sdk = createTestSdk();
71
+ const result = await sdk.getAuthentication({ authenticationId: 123 });
72
+ expect(result.data).toEqual({
73
+ id: 123,
74
+ date: "2021-01-01",
75
+ account_id: 456,
76
+ implementation_id: "SlackCLIAPI@1.21.1",
77
+ is_invite_only: false,
78
+ is_private: false,
79
+ shared_with_all: false,
80
+ is_expired: "false",
81
+ expired_at: null,
82
+ label: "My Slack Workspace",
83
+ title: "My Slack Workspace",
84
+ app_key: "SlackCLIAPI",
85
+ version: "1.21.1",
86
+ user_id: undefined, // customuser_id wasn't in mock data
87
+ is_stale: "false", // Original field preserved
88
+ marked_stale_at: null, // Original field preserved
89
+ });
90
+ });
91
+ });
92
+ describe("error handling", () => {
93
+ it("should throw ZapierAuthenticationError for 401 responses", async () => {
94
+ const customErrorHandler = vi
95
+ .fn()
96
+ .mockReturnValue(new ZapierAuthenticationError("Authentication failed. Your token may not have permission to access authentications or may be expired. (HTTP 401)", { statusCode: 401 }));
97
+ mockApiClient.get = vi.fn().mockImplementation(() => {
98
+ const error = customErrorHandler({ status: 401 });
99
+ throw error;
100
+ });
101
+ const sdk = createTestSdk();
102
+ await expect(sdk.getAuthentication({ authenticationId: 123 })).rejects.toThrow(ZapierAuthenticationError);
103
+ });
104
+ it("should throw ZapierAuthenticationError for 403 responses", async () => {
105
+ const customErrorHandler = vi
106
+ .fn()
107
+ .mockReturnValue(new ZapierAuthenticationError("Access forbidden. Your token may not have the required scopes to get authentication 123. (HTTP 403)", { statusCode: 403 }));
108
+ mockApiClient.get = vi.fn().mockImplementation(() => {
109
+ const error = customErrorHandler({ status: 403 });
110
+ throw error;
111
+ });
112
+ const sdk = createTestSdk();
113
+ await expect(sdk.getAuthentication({ authenticationId: 123 })).rejects.toThrow(ZapierAuthenticationError);
114
+ });
115
+ it("should throw ZapierResourceNotFoundError for 404 responses", async () => {
116
+ const customErrorHandler = vi.fn().mockReturnValue(new ZapierResourceNotFoundError("Authentication 123 not found. It may not exist or you may not have access to it. (HTTP 404)", {
117
+ resourceType: "Authentication",
118
+ resourceId: "123",
119
+ }));
120
+ mockApiClient.get = vi.fn().mockImplementation(() => {
121
+ const error = customErrorHandler({ status: 404 });
122
+ throw error;
123
+ });
124
+ const sdk = createTestSdk();
125
+ await expect(sdk.getAuthentication({ authenticationId: 123 })).rejects.toThrow(ZapierResourceNotFoundError);
126
+ });
127
+ it("should handle network errors", async () => {
128
+ mockApiClient.get = vi.fn().mockRejectedValue(new Error("Network error"));
129
+ const sdk = createTestSdk();
130
+ await expect(sdk.getAuthentication({ authenticationId: 123 })).rejects.toThrow("Network error");
131
+ });
132
+ });
133
+ describe("data transformation", () => {
134
+ it("should map is_stale to is_expired and marked_stale_at to expired_at", async () => {
135
+ const authWithExpiration = {
136
+ ...mockAuthenticationResponse,
137
+ is_stale: "true",
138
+ marked_stale_at: "2021-06-01",
139
+ };
140
+ mockApiClient.get = vi.fn().mockResolvedValue(authWithExpiration);
141
+ const sdk = createTestSdk();
142
+ const result = await sdk.getAuthentication({ authenticationId: 123 });
143
+ expect(result.data.is_expired).toBe("true");
144
+ expect(result.data.expired_at).toBe("2021-06-01");
145
+ });
146
+ it("should preserve all original authentication fields", async () => {
147
+ const authWithAllFields = {
148
+ id: 123,
149
+ date: "2021-01-01",
150
+ lastchanged: "2021-01-02",
151
+ account_id: 456,
152
+ customuser_id: 789,
153
+ selected_api: "SlackCLIAPI@1.21.1",
154
+ destination_selected_api: "SlackDestAPI@1.0.0",
155
+ is_invite_only: true,
156
+ is_private: true,
157
+ shared_with_all: false,
158
+ is_stale: "true",
159
+ is_shared: "false",
160
+ marked_stale_at: "2021-06-01",
161
+ label: "Auth Label",
162
+ title: "Auth Title",
163
+ identifier: "auth-identifier",
164
+ url: "https://example.com",
165
+ groups: "group1,group2",
166
+ members: "user1,user2",
167
+ permissions: { read: true, write: false },
168
+ };
169
+ mockApiClient.get = vi.fn().mockResolvedValue(authWithAllFields);
170
+ const sdk = createTestSdk();
171
+ const result = await sdk.getAuthentication({ authenticationId: 123 });
172
+ const auth = result.data;
173
+ // Verify original fields are preserved
174
+ expect(auth.id).toBe(123);
175
+ expect(auth.date).toBe("2021-01-01");
176
+ expect(auth.lastchanged).toBe("2021-01-02");
177
+ expect(auth.account_id).toBe(456);
178
+ expect(auth.user_id).toBe(789);
179
+ expect(auth.implementation_id).toBe("SlackCLIAPI@1.21.1");
180
+ expect(auth.destination_selected_api).toBe("SlackDestAPI@1.0.0");
181
+ expect(auth.is_invite_only).toBe(true);
182
+ expect(auth.is_private).toBe(true);
183
+ expect(auth.shared_with_all).toBe(false);
184
+ expect(auth.is_shared).toBe("false");
185
+ expect(auth.label).toBe("Auth Label");
186
+ expect(auth.title).toBe("Auth Title");
187
+ expect(auth.identifier).toBe("auth-identifier");
188
+ expect(auth.url).toBe("https://example.com");
189
+ expect(auth.groups).toBe("group1,group2");
190
+ expect(auth.members).toBe("user1,user2");
191
+ expect(auth.permissions).toEqual({ read: true, write: false });
192
+ // Verify mapped fields
193
+ expect(auth.is_expired).toBe("true");
194
+ expect(auth.expired_at).toBe("2021-06-01");
195
+ });
196
+ });
197
+ describe("context and metadata", () => {
198
+ it("should provide context with meta information", () => {
199
+ const sdk = createTestSdk();
200
+ const context = sdk.getContext();
201
+ expect(context.meta.getAuthentication).toBeDefined();
202
+ expect(context.meta.getAuthentication.inputSchema).toBeDefined();
203
+ });
204
+ });
205
+ });
@@ -0,0 +1,17 @@
1
+ import { z } from "zod";
2
+ import type { AuthenticationItem } from "../../types/domain";
3
+ export declare const GetAuthenticationSchema: z.ZodObject<{
4
+ authenticationId: z.ZodNumber;
5
+ }, "strip", z.ZodTypeAny, {
6
+ authenticationId: number;
7
+ }, {
8
+ authenticationId: number;
9
+ }>;
10
+ export type GetAuthenticationOptions = z.infer<typeof GetAuthenticationSchema>;
11
+ export type GetAuthenticationError = import("../../types/errors").ZapierAuthenticationError | import("../../types/errors").ZapierResourceNotFoundError | import("../../types/errors").ZapierApiError | import("../../types/errors").ZapierValidationError | import("../../types/errors").ZapierUnknownError;
12
+ export interface GetAuthenticationSdkFunction {
13
+ getAuthentication: (options: GetAuthenticationOptions) => Promise<{
14
+ data: AuthenticationItem;
15
+ }>;
16
+ }
17
+ //# sourceMappingURL=schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/plugins/getAuthentication/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAG7D,eAAO,MAAM,uBAAuB;;;;;;EAQc,CAAC;AAGnD,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAG/E,MAAM,MAAM,sBAAsB,GAC9B,OAAO,oBAAoB,EAAE,yBAAyB,GACtD,OAAO,oBAAoB,EAAE,2BAA2B,GACxD,OAAO,oBAAoB,EAAE,cAAc,GAC3C,OAAO,oBAAoB,EAAE,qBAAqB,GAClD,OAAO,oBAAoB,EAAE,kBAAkB,CAAC;AAGpD,MAAM,WAAW,4BAA4B;IAC3C,iBAAiB,EAAE,CACjB,OAAO,EAAE,wBAAwB,KAC9B,OAAO,CAAC;QAAE,IAAI,EAAE,kBAAkB,CAAA;KAAE,CAAC,CAAC;CAC5C"}
@@ -0,0 +1,11 @@
1
+ import { z } from "zod";
2
+ // Pure Zod schema - no resolver metadata!
3
+ export const GetAuthenticationSchema = z
4
+ .object({
5
+ authenticationId: z
6
+ .number()
7
+ .int()
8
+ .positive()
9
+ .describe("Authentication ID to retrieve"),
10
+ })
11
+ .describe("Get a specific authentication by ID");
@@ -0,0 +1,23 @@
1
+ import type { GetProfileOptions } from "./schemas";
2
+ import type { ApiClient } from "../../api/types";
3
+ import type { Plugin } from "../../types/plugin";
4
+ import type { UserProfileItem } from "../../types/domain";
5
+ import { GetProfileSchema } from "./schemas";
6
+ export interface GetProfilePluginProvides {
7
+ getProfile: (options?: GetProfileOptions) => Promise<{
8
+ data: UserProfileItem;
9
+ }>;
10
+ context: {
11
+ meta: {
12
+ getProfile: {
13
+ inputSchema: typeof GetProfileSchema;
14
+ };
15
+ };
16
+ };
17
+ }
18
+ export declare const getProfilePlugin: Plugin<{}, // no SDK dependencies
19
+ {
20
+ api: ApiClient;
21
+ }, // requires api in context
22
+ GetProfilePluginProvides>;
23
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/getProfile/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,KAAK,EAAe,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE9D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAG7C,MAAM,WAAW,wBAAwB;IACvC,UAAU,EAAE,CACV,OAAO,CAAC,EAAE,iBAAiB,KACxB,OAAO,CAAC;QAAE,IAAI,EAAE,eAAe,CAAA;KAAE,CAAC,CAAC;IACxC,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,UAAU,EAAE;gBACV,WAAW,EAAE,OAAO,gBAAgB,CAAC;aACtC,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAGD,eAAO,MAAM,gBAAgB,EAAE,MAAM,CACnC,EAAE,EAAE,sBAAsB;AAC1B;IAAE,GAAG,EAAE,SAAS,CAAA;CAAE,EAAE,0BAA0B;AAC9C,wBAAwB,CA6BzB,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { createFunction } from "../../utils/function-utils";
2
+ import { GetProfileSchema } from "./schemas";
3
+ // Direct plugin function - takes options + sdk + context in one object
4
+ export const getProfilePlugin = ({ context }) => {
5
+ const getProfile = createFunction(async function getProfile() {
6
+ const profile = await context.api.get("/api/v4/profile/", {
7
+ authRequired: true,
8
+ });
9
+ // Remove user_id since that's our internal user ID which could confuse things!
10
+ const { user_id: _unusedUserId, ...data } = profile;
11
+ return {
12
+ data: {
13
+ ...data, // Pass through all API response fields
14
+ full_name: `${profile.first_name} ${profile.last_name}`, // Computed field
15
+ },
16
+ };
17
+ }, GetProfileSchema);
18
+ // Return flat structure - getProfile goes directly to SDK
19
+ return {
20
+ getProfile,
21
+ context: {
22
+ meta: {
23
+ getProfile: {
24
+ inputSchema: GetProfileSchema,
25
+ },
26
+ },
27
+ },
28
+ };
29
+ };
@@ -0,0 +1,13 @@
1
+ import { z } from "zod";
2
+ import type { FunctionOptions } from "../../types/functions";
3
+ import type { UserProfileItem } from "../../types/domain";
4
+ import { ZapierApiError, ZapierValidationError } from "../../types/errors";
5
+ export type GetProfileError = ZapierApiError | ZapierValidationError;
6
+ export declare const GetProfileSchema: z.ZodOptional<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>;
7
+ export type GetProfileOptions = z.infer<typeof GetProfileSchema> & FunctionOptions;
8
+ export interface GetProfileSdkFunction {
9
+ getProfile: (options?: GetProfileOptions) => Promise<{
10
+ data: UserProfileItem;
11
+ }>;
12
+ }
13
+ //# sourceMappingURL=schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/plugins/getProfile/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAG3E,MAAM,MAAM,eAAe,GAAG,cAAc,GAAG,qBAAqB,CAAC;AAGrE,eAAO,MAAM,gBAAgB,+DAG5B,CAAC;AAGF,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,GAC9D,eAAe,CAAC;AAGlB,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,CACV,OAAO,CAAC,EAAE,iBAAiB,KACxB,OAAO,CAAC;QAAE,IAAI,EAAE,eAAe,CAAA;KAAE,CAAC,CAAC;CACzC"}
@@ -0,0 +1,5 @@
1
+ import { z } from "zod";
2
+ import { withOutputSchema } from "../../utils/schema-utils";
3
+ import { UserProfileItemSchema } from "../../schemas/UserProfile";
4
+ // Pure Zod schema - no resolver metadata!
5
+ export const GetProfileSchema = withOutputSchema(z.object({}).optional().describe("Get current user's profile information"), UserProfileItemSchema);
@@ -0,0 +1,28 @@
1
+ import type { Plugin, GetSdkType } from "../../types/plugin";
2
+ import type { ApiClient } from "../../api";
3
+ import type { ActionItem } from "../../types/domain";
4
+ import { ListActionsSchema, type ListActionsOptions } from "./schemas";
5
+ import type { GetAppPluginProvides } from "../getApp";
6
+ export interface ListActionsPluginProvides {
7
+ listActions: (options?: ListActionsOptions) => Promise<{
8
+ data: ActionItem[];
9
+ }> & AsyncIterable<{
10
+ data: ActionItem[];
11
+ nextCursor?: string;
12
+ }> & {
13
+ items(): AsyncIterable<ActionItem>;
14
+ };
15
+ context: {
16
+ meta: {
17
+ listActions: {
18
+ inputSchema: typeof ListActionsSchema;
19
+ };
20
+ };
21
+ };
22
+ }
23
+ export declare const listActionsPlugin: Plugin<GetSdkType<GetAppPluginProvides>, // requires getApp in SDK
24
+ {
25
+ api: ApiClient;
26
+ }, // requires api in context
27
+ ListActionsPluginProvides>;
28
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/listActions/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,EACL,iBAAiB,EACjB,KAAK,kBAAkB,EAExB,MAAM,WAAW,CAAC;AAMnB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAEtD,MAAM,WAAW,yBAAyB;IACxC,WAAW,EAAE,CAAC,OAAO,CAAC,EAAE,kBAAkB,KAAK,OAAO,CAAC;QACrD,IAAI,EAAE,UAAU,EAAE,CAAC;KACpB,CAAC,GACA,aAAa,CAAC;QAAE,IAAI,EAAE,UAAU,EAAE,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG;QAC3D,KAAK,IAAI,aAAa,CAAC,UAAU,CAAC,CAAC;KACpC,CAAC;IACJ,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,WAAW,EAAE;gBACX,WAAW,EAAE,OAAO,iBAAiB,CAAC;aACvC,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,iBAAiB,EAAE,MAAM,CACpC,UAAU,CAAC,oBAAoB,CAAC,EAAE,yBAAyB;AAC3D;IAAE,GAAG,EAAE,SAAS,CAAA;CAAE,EAAE,0BAA0B;AAC9C,yBAAyB,CA+E1B,CAAC"}
@@ -0,0 +1,61 @@
1
+ import { normalizeActionItem } from "../../utils/domain-utils";
2
+ import { ListActionsSchema, } from "./schemas";
3
+ import { ZapierConfigurationError, ZapierAuthenticationError, } from "../../types/errors";
4
+ import { createPaginatedFunction } from "../../utils/function-utils";
5
+ export const listActionsPlugin = ({ sdk, context }) => {
6
+ const listActions = createPaginatedFunction(async function listActionsPage(options) {
7
+ const { api } = context;
8
+ // Use the getApp function from the SDK (dependency injection)
9
+ const app = await sdk.getApp({ appKey: options.appKey });
10
+ const implementationId = app.data.current_implementation_id?.split("@")[0];
11
+ if (!implementationId) {
12
+ throw new ZapierConfigurationError("No current_implementation_id found for app", { configType: "current_implementation_id" });
13
+ }
14
+ const searchParams = {
15
+ global: "true",
16
+ public_only: "true",
17
+ selected_apis: implementationId,
18
+ };
19
+ const data = await api.get("/api/v4/implementations/", {
20
+ searchParams,
21
+ customErrorHandler: ({ status }) => {
22
+ if (status === 401) {
23
+ return new ZapierAuthenticationError(`Authentication failed. Your token may not have permission to access implementations or may be expired. (HTTP ${status})`, { statusCode: status });
24
+ }
25
+ if (status === 403) {
26
+ return new ZapierAuthenticationError(`Access forbidden. Your token may not have the required scopes to list implementations. (HTTP ${status})`, { statusCode: status });
27
+ }
28
+ return undefined;
29
+ },
30
+ });
31
+ let allActions = [];
32
+ for (const implementation of data.results || []) {
33
+ if (implementation.actions) {
34
+ for (const action of implementation.actions) {
35
+ const actionWithContext = {
36
+ ...action,
37
+ selected_api: action.selected_api || implementation.selected_api,
38
+ };
39
+ allActions.push(normalizeActionItem(actionWithContext));
40
+ }
41
+ }
42
+ }
43
+ if (options.actionType) {
44
+ allActions = allActions.filter((action) => action.action_type === options.actionType);
45
+ }
46
+ return {
47
+ data: allActions,
48
+ nextCursor: undefined,
49
+ };
50
+ }, ListActionsSchema);
51
+ return {
52
+ listActions,
53
+ context: {
54
+ meta: {
55
+ listActions: {
56
+ inputSchema: ListActionsSchema,
57
+ },
58
+ },
59
+ },
60
+ };
61
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../../src/plugins/listActions/index.test.ts"],"names":[],"mappings":""}