@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,275 @@
1
+ /**
2
+ * Standard error format returned by the Zapier API
3
+ */
4
+ export interface ApiError {
5
+ status: number;
6
+ code: string;
7
+ title: string;
8
+ detail: string;
9
+ source?: any;
10
+ meta?: any;
11
+ }
12
+
13
+ /**
14
+ * Base options for all error constructors
15
+ */
16
+ export interface ErrorOptions {
17
+ statusCode?: number;
18
+ errors?: ApiError[];
19
+ cause?: unknown;
20
+ response?: any;
21
+ }
22
+
23
+ /**
24
+ * Base class for all Zapier SDK errors
25
+ * Use instanceof ZapierError to check if an error is from the SDK
26
+ */
27
+ export abstract class ZapierError extends Error {
28
+ abstract readonly name: string;
29
+ public statusCode?: number;
30
+ public errors?: ApiError[];
31
+ public cause?: unknown;
32
+ public response?: any;
33
+
34
+ constructor(message: string, options: ErrorOptions = {}) {
35
+ super(message);
36
+ this.statusCode = options.statusCode;
37
+ this.errors = options.errors;
38
+ this.cause = options.cause;
39
+ this.response = options.response;
40
+ // Maintain proper prototype chain for instanceof checks
41
+ Object.setPrototypeOf(this, new.target.prototype);
42
+ }
43
+ }
44
+
45
+ /**
46
+ * Error thrown when API requests fail
47
+ */
48
+ export class ZapierApiError extends ZapierError {
49
+ readonly name = "ZapierApiError";
50
+
51
+ constructor(message: string, options: ErrorOptions = {}) {
52
+ super(message, options);
53
+ }
54
+ }
55
+
56
+ /**
57
+ * Error thrown when an app is not found
58
+ */
59
+ export class ZapierAppNotFoundError extends ZapierError {
60
+ readonly name = "ZapierAppNotFoundError";
61
+ public appKey?: string;
62
+
63
+ constructor(
64
+ message: string,
65
+ options: ErrorOptions & { appKey?: string } = {},
66
+ ) {
67
+ super(message, options);
68
+ this.appKey = options.appKey;
69
+ }
70
+ }
71
+
72
+ /**
73
+ * Error thrown when validation fails (e.g., invalid parameters)
74
+ */
75
+ export class ZapierValidationError extends ZapierError {
76
+ readonly name = "ZapierValidationError";
77
+ public details?: any;
78
+
79
+ constructor(message: string, options: ErrorOptions & { details?: any } = {}) {
80
+ super(message, options);
81
+ this.details = options.details;
82
+ }
83
+ }
84
+
85
+ /**
86
+ * Error for unrecognized/unknown errors that get wrapped by safe functions
87
+ */
88
+ export class ZapierUnknownError extends ZapierError {
89
+ readonly name = "ZapierUnknownError";
90
+
91
+ constructor(message: string, options: ErrorOptions = {}) {
92
+ super(message, options);
93
+ }
94
+ }
95
+
96
+ /**
97
+ * Error thrown for authentication and authorization failures (401/403)
98
+ */
99
+ export class ZapierAuthenticationError extends ZapierError {
100
+ readonly name = "ZapierAuthenticationError";
101
+
102
+ constructor(message: string, options: ErrorOptions = {}) {
103
+ super(message, options);
104
+ }
105
+ }
106
+
107
+ /**
108
+ * Error thrown when a requested resource is not found
109
+ */
110
+ export class ZapierResourceNotFoundError extends ZapierError {
111
+ readonly name = "ZapierResourceNotFoundError";
112
+ public resourceType?: string;
113
+ public resourceId?: string;
114
+
115
+ constructor(
116
+ message: string,
117
+ options: ErrorOptions & { resourceType?: string; resourceId?: string } = {},
118
+ ) {
119
+ super(message, options);
120
+ this.resourceType = options.resourceType;
121
+ this.resourceId = options.resourceId;
122
+ }
123
+ }
124
+
125
+ /**
126
+ * Error thrown when required app or implementation configuration is missing
127
+ */
128
+ export class ZapierConfigurationError extends ZapierError {
129
+ readonly name = "ZapierConfigurationError";
130
+ public configType?: string;
131
+
132
+ constructor(
133
+ message: string,
134
+ options: ErrorOptions & { configType?: string } = {},
135
+ ) {
136
+ super(message, options);
137
+ this.configType = options.configType;
138
+ }
139
+ }
140
+
141
+ /**
142
+ * Error thrown when code bundling or compilation fails
143
+ */
144
+ export class ZapierBundleError extends ZapierError {
145
+ readonly name = "ZapierBundleError";
146
+ public buildErrors?: string[];
147
+
148
+ constructor(
149
+ message: string,
150
+ options: ErrorOptions & { buildErrors?: string[] } = {},
151
+ ) {
152
+ super(message, options);
153
+ this.buildErrors = options.buildErrors;
154
+ }
155
+ }
156
+
157
+ /**
158
+ * Error thrown when operations timeout or exceed retry limits
159
+ */
160
+ export class ZapierTimeoutError extends ZapierError {
161
+ readonly name = "ZapierTimeoutError";
162
+ public attempts?: number;
163
+ public maxAttempts?: number;
164
+
165
+ constructor(
166
+ message: string,
167
+ options: ErrorOptions & { attempts?: number; maxAttempts?: number } = {},
168
+ ) {
169
+ super(message, options);
170
+ this.attempts = options.attempts;
171
+ this.maxAttempts = options.maxAttempts;
172
+ }
173
+ }
174
+
175
+ /**
176
+ * Error thrown when action execution fails due to errors returned from the third-party service
177
+ * This happens when the Actions API returns a 200 status but includes errors in the response
178
+ */
179
+ export class ZapierActionError extends ZapierError {
180
+ readonly name = "ZapierActionError";
181
+ public appKey?: string;
182
+ public actionKey?: string;
183
+
184
+ constructor(
185
+ message: string,
186
+ options: ErrorOptions & { appKey?: string; actionKey?: string } = {},
187
+ ) {
188
+ super(message, options);
189
+ this.appKey = options.appKey;
190
+ this.actionKey = options.actionKey;
191
+ }
192
+
193
+ // Legacy accessor for backward compatibility
194
+ get actionErrors() {
195
+ return this.errors;
196
+ }
197
+ }
198
+
199
+ /**
200
+ * Error thrown when a resource is not found (404)
201
+ */
202
+ export class ZapierNotFoundError extends ZapierError {
203
+ readonly name = "ZapierNotFoundError";
204
+
205
+ constructor(message: string, options: ErrorOptions = {}) {
206
+ super(message, options);
207
+ }
208
+ }
209
+
210
+ /**
211
+ * Utility function to format error messages for display
212
+ */
213
+ export function formatErrorMessage(error: ZapierError): string {
214
+ let message = error.message;
215
+
216
+ // Add additional context from errors array if available
217
+ if (error.errors && error.errors.length > 0) {
218
+ const additionalErrors = error.errors.slice(1); // Skip first error (already in message)
219
+ if (additionalErrors.length > 0) {
220
+ const errorDetails = additionalErrors
221
+ .map((err) => ` • ${err.detail || err.title || err.code}`)
222
+ .join("\n");
223
+ message += "\n\nAdditional errors:\n" + errorDetails;
224
+ }
225
+ }
226
+
227
+ // Add error-specific context
228
+ if (error instanceof ZapierAppNotFoundError && error.appKey) {
229
+ message += `\nApp key: ${error.appKey}`;
230
+ }
231
+
232
+ if (error instanceof ZapierActionError && (error.appKey || error.actionKey)) {
233
+ const context = [];
234
+ if (error.appKey) context.push(`App: ${error.appKey}`);
235
+ if (error.actionKey) context.push(`Action: ${error.actionKey}`);
236
+ message += `\n${context.join(", ")}`;
237
+ }
238
+
239
+ if (
240
+ error instanceof ZapierResourceNotFoundError &&
241
+ (error.resourceType || error.resourceId)
242
+ ) {
243
+ const context = [];
244
+ if (error.resourceType) context.push(`Type: ${error.resourceType}`);
245
+ if (error.resourceId) context.push(`ID: ${error.resourceId}`);
246
+ message += `\n${context.join(", ")}`;
247
+ }
248
+
249
+ if (
250
+ error instanceof ZapierTimeoutError &&
251
+ (error.attempts || error.maxAttempts)
252
+ ) {
253
+ const context = [];
254
+ if (error.attempts) context.push(`Attempts: ${error.attempts}`);
255
+ if (error.maxAttempts) context.push(`Max attempts: ${error.maxAttempts}`);
256
+ message += `\n${context.join(", ")}`;
257
+ }
258
+
259
+ if (
260
+ error instanceof ZapierBundleError &&
261
+ error.buildErrors &&
262
+ error.buildErrors.length > 0
263
+ ) {
264
+ message +=
265
+ "\n\nBuild errors:\n" +
266
+ error.buildErrors.map((err) => ` • ${err}`).join("\n");
267
+ }
268
+
269
+ // Add status code if available and not already obvious from the message
270
+ if (error.statusCode && !message.includes(`${error.statusCode}`)) {
271
+ message += `\nHTTP Status: ${error.statusCode}`;
272
+ }
273
+
274
+ return message;
275
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Function-related types and interfaces
3
+ */
4
+
5
+ // Common options shared across all function types
6
+ export interface FunctionOptions {
7
+ /** Base URL for Zapier API */
8
+ baseUrl?: string;
9
+ /** Authentication token */
10
+ token?: string;
11
+ /** Function to dynamically resolve authentication token */
12
+ getToken?: () => Promise<string | undefined>;
13
+ /** Optional pre-instantiated API client */
14
+ api?: any;
15
+ /** Enable debug logging */
16
+ debug?: boolean;
17
+ /** Custom fetch implementation */
18
+ fetch?: typeof globalThis.fetch;
19
+ }
20
+
21
+ // Generic type helper for paginated SDK functions
22
+ export type PaginatedSdkFunction<TOptions, TItem> = (
23
+ options: TOptions,
24
+ ) => Promise<{ data: TItem[] }> &
25
+ AsyncIterable<{ data: TItem[]; nextCursor?: string }> & {
26
+ items(): AsyncIterable<TItem>;
27
+ };
@@ -0,0 +1,37 @@
1
+ // packages/zapier-sdk/types/cli-login-shim.d.ts
2
+ declare module '@zapier/zapier-sdk-cli-login' {
3
+ export interface AuthOptions {
4
+ onEvent?: (event: {
5
+ type: string;
6
+ payload: Record<string, any>;
7
+ timestamp: number;
8
+ }) => void;
9
+ fetch?: typeof globalThis.fetch;
10
+ }
11
+
12
+ export interface LoginData {
13
+ access_token: string;
14
+ refresh_token: string;
15
+ expires_in: number;
16
+ }
17
+
18
+ // Minimal API — include only what your SDK actually uses.
19
+ // (Keeping a few extra exports here is harmless and future-proofs a bit.)
20
+ export function getToken(
21
+ options?: AuthOptions
22
+ ): Promise<string | undefined>;
23
+
24
+ export function getValidJwt(
25
+ options?: AuthOptions
26
+ ): Promise<string | undefined>;
27
+
28
+ export function getLoggedInUser(
29
+ options?: AuthOptions
30
+ ): Promise<{ accountId: number; customUserId: number; email: string }>;
31
+
32
+ export function logout(options?: Pick<AuthOptions, 'onEvent'>): void;
33
+
34
+ export function updateLogin(loginData: LoginData): void;
35
+
36
+ export function getConfigPath(): string;
37
+ }
@@ -0,0 +1,105 @@
1
+ /**
2
+ * ------------------------------
3
+ * Plugin Type System with Explicit Context Dependencies
4
+ * ------------------------------
5
+ *
6
+ * This system makes context dependencies explicit to restore TypeScript's
7
+ * ability to catch missing context at compile time.
8
+ */
9
+
10
+ export interface PluginDependencies<TSdk = {}, TContext = {}> {
11
+ sdk: TSdk;
12
+ context: TContext;
13
+ }
14
+
15
+ // Plugin provides = sdk properties + optional context
16
+ export interface PluginProvides extends Record<string, any> {
17
+ context?: Record<string, any>;
18
+ }
19
+
20
+ // Utility type to extract SDK properties (everything except 'context')
21
+ export type ExtractSdkProperties<T extends Record<string, any>> = Omit<
22
+ T,
23
+ "context"
24
+ >;
25
+
26
+ // Utility type to extract context properties from plugin
27
+ export type ExtractContextProperties<T extends PluginProvides> = T["context"];
28
+
29
+ // Helper type to create SDK type with properly typed getContext method
30
+ export type GetSdkType<TPluginProvides extends PluginProvides> =
31
+ ExtractSdkProperties<TPluginProvides> & {
32
+ getContext(): NonNullable<ExtractContextProperties<TPluginProvides>>;
33
+ };
34
+
35
+ // Helper type for standard plugin options with SDK dependency and meta context
36
+ export type PluginOptions<TSdk = {}, TContext = {}> = {
37
+ sdk: TSdk;
38
+ context: TContext & { meta: Record<string, any> };
39
+ };
40
+
41
+ /**
42
+ * Plugin interface — now has 3 type params:
43
+ *
44
+ * TRequiresContext = what this plugin *needs* in context
45
+ * TProvides = what this plugin *returns* (sdk + context)
46
+ * TSdk = current sdk shape when plugin runs
47
+ */
48
+ export interface Plugin<
49
+ TSdk = {},
50
+ TRequiresContext = {},
51
+ TProvides extends PluginProvides = PluginProvides,
52
+ > {
53
+ (params: {
54
+ sdk: TSdk;
55
+ context: TRequiresContext & { meta: Record<string, any> };
56
+ }): TProvides;
57
+ }
58
+
59
+ // Helper type to get missing keys from required context
60
+ type MissingContextKeys<TRequired, TCurrent> =
61
+ TRequired extends Record<string, any>
62
+ ? TCurrent extends Record<string, any>
63
+ ? {
64
+ [K in keyof TRequired]: K extends keyof TCurrent ? never : K;
65
+ }[keyof TRequired]
66
+ : keyof TRequired
67
+ : never;
68
+
69
+ // Helper type to create detailed error message
70
+ type ContextError<TRequired, TCurrent> =
71
+ MissingContextKeys<TRequired, TCurrent> extends never
72
+ ? never
73
+ : MissingContextKeys<TRequired, TCurrent> extends infer Missing
74
+ ? Missing extends string
75
+ ? `❌ Missing required context: { ${Missing}: any }`
76
+ : Missing extends number
77
+ ? `❌ Missing required context: { ${Missing}: any }`
78
+ : `❌ Missing required context properties. Required: ${keyof TRequired extends string ? keyof TRequired : "unknown"}, Available: ${keyof TCurrent extends string ? keyof TCurrent : "unknown"}`
79
+ : "❌ Context requirement not satisfied";
80
+
81
+ /**
82
+ * SDK interface — result of createSdk()
83
+ *
84
+ * addPlugin now enforces that TRequiresContext is assignable to TCurrentContext.
85
+ * If not, TypeScript will emit a detailed error showing missing properties.
86
+ */
87
+ export type Sdk<
88
+ TCurrentSdk = {},
89
+ TCurrentContext = { meta: Record<string, any> },
90
+ > = TCurrentSdk & {
91
+ addPlugin<TRequiresContext, TProvides extends PluginProvides>(
92
+ plugin: Plugin<
93
+ TCurrentSdk & { getContext(): TCurrentContext },
94
+ TRequiresContext,
95
+ TProvides
96
+ >,
97
+ options?: any,
98
+ ): TCurrentContext extends TRequiresContext
99
+ ? Sdk<
100
+ TCurrentSdk & ExtractSdkProperties<TProvides>,
101
+ TCurrentContext & NonNullable<ExtractContextProperties<TProvides>>
102
+ >
103
+ : ContextError<TRequiresContext, TCurrentContext>;
104
+ getContext(): TCurrentContext;
105
+ };
@@ -1,11 +1,12 @@
1
1
  import { z } from "zod";
2
- import { withPositional } from "../schema-utils";
2
+ import { withPositional } from "../utils/schema-utils";
3
+ import { MAX_PAGE_LIMIT } from "../constants";
3
4
 
4
5
  // Shared property definitions for common parameters across functions
5
6
  // These can be reused in function schemas without duplication
6
7
 
7
8
  export const AppKeyPropertySchema = withPositional(
8
- z.string().min(1).describe("App slug (e.g., 'slack', 'github')"),
9
+ z.string().min(1).describe("App key (e.g., 'SlackCLIAPI')"),
9
10
  );
10
11
 
11
12
  export const ActionTypePropertySchema = z
@@ -39,7 +40,7 @@ export const LimitPropertySchema = z
39
40
  .number()
40
41
  .int()
41
42
  .min(1)
42
- .max(1000)
43
+ .max(MAX_PAGE_LIMIT)
43
44
  .default(50)
44
45
  .describe("Maximum number of items to return");
45
46
 
package/src/types/sdk.ts CHANGED
@@ -1,63 +1,85 @@
1
+ /**
2
+ * SDK-related types and interfaces
3
+ */
4
+
5
+ import type { EventCallback } from "./events";
6
+
7
+ // SDK Configuration Types
8
+ export interface BaseSdkOptions {
9
+ token?: string;
10
+ getToken?: () => Promise<string | undefined>;
11
+ onEvent?: EventCallback;
12
+ fetch?: typeof fetch;
13
+ baseUrl?: string;
14
+ debug?: boolean;
15
+ }
16
+
1
17
  // SDK interface composed from individual function interfaces
2
- import type { ListActionsSdkFunction } from "../functions/listActions/schemas";
3
- import type { GetActionSdkFunction } from "../functions/getAction/schemas";
4
- import type { GetAppSdkFunction } from "../functions/getApp/schemas";
5
- import type { RunActionSdkFunction } from "../functions/runAction/schemas";
6
- import type { ListFieldsSdkFunction } from "../functions/listFields/schemas";
7
- import type { ListAuthenticationsSdkFunction } from "../functions/listAuthentications/schemas";
8
- import type { GetAuthenticationSdkFunction } from "../functions/getAuthentication/schemas";
9
- import type { FindFirstAuthenticationSdkFunction } from "../functions/findFirstAuthentication/schemas";
10
- import type { FindUniqueAuthenticationSdkFunction } from "../functions/findUniqueAuthentication/schemas";
11
- import type { GenerateTypesSdkFunction } from "../functions/generateTypes/schemas";
12
- import type { ListAppsSdkFunction } from "../functions/listApps/schemas";
13
- import type { BundleCodeSdkFunction } from "../functions/bundleCode/schemas";
14
- import type { RelayRequestSdkFunction } from "../functions/request/schemas";
18
+ import type { ListInputFieldsSdkFunction } from "../plugins/listInputFields/schemas";
19
+ import type { GetAuthenticationSdkFunction } from "../plugins/getAuthentication/schemas";
20
+ import type { FindFirstAuthenticationSdkFunction } from "../plugins/findFirstAuthentication/schemas";
21
+ import type { FindUniqueAuthenticationSdkFunction } from "../plugins/findUniqueAuthentication/schemas";
22
+ import type { RelayRequestSdkFunction } from "../plugins/request/schemas";
23
+ import type { z } from "zod";
24
+ import { RegistryPluginProvides } from "../plugins/registry";
25
+ import { GetProfilePluginProvides } from "../plugins/getProfile";
26
+ import { AppsPluginProvides } from "../plugins/apps";
27
+ import { FetchPluginProvides } from "../plugins/fetch";
28
+ import { ListAppsPluginProvides } from "../plugins/listApps";
29
+ import { GetAppPluginProvides } from "../plugins/getApp";
30
+ import { ListActionsPluginProvides } from "../plugins/listActions";
31
+ import { GetActionPluginProvides } from "../plugins/getAction";
32
+ import { RunActionPluginProvides } from "../plugins/runAction";
33
+ import { ListAuthenticationsPluginProvides } from "../plugins/listAuthentications";
34
+ import { GetAuthenticationPluginProvides } from "../plugins/getAuthentication";
35
+ import { FindFirstAuthenticationPluginProvides } from "../plugins/findFirstAuthentication";
36
+ import { FindUniqueAuthenticationPluginProvides } from "../plugins/findUniqueAuthentication";
37
+ import { ListInputFieldsPluginProvides } from "../plugins/listInputFields";
38
+ import { RequestPluginProvides } from "../plugins/request";
39
+ import { GetSdkType } from "./plugin";
15
40
 
16
41
  // Plugin interfaces
17
- import type { AppsPluginSdkExtension } from "../plugins/apps/types";
18
- import type { FetchPluginSdkExtension } from "../plugins/fetch/types";
42
+ // Note: Plugin extension types removed - now using new plugin system
43
+
44
+ // Registry entry interface with proper types
45
+ export interface FunctionRegistryEntry {
46
+ name: string;
47
+ inputSchema: z.ZodSchema;
48
+ implementation: Function;
49
+ }
19
50
 
20
51
  // Compose SDK functions from individual function interfaces
21
52
  export interface ZapierSdkFunctions
22
- extends ListActionsSdkFunction,
23
- GetActionSdkFunction,
24
- GetAppSdkFunction,
25
- RunActionSdkFunction,
26
- ListFieldsSdkFunction,
27
- ListAuthenticationsSdkFunction,
53
+ extends ListInputFieldsSdkFunction,
28
54
  GetAuthenticationSdkFunction,
29
55
  FindFirstAuthenticationSdkFunction,
30
56
  FindUniqueAuthenticationSdkFunction,
31
- GenerateTypesSdkFunction,
32
- ListAppsSdkFunction,
33
- BundleCodeSdkFunction,
34
57
  RelayRequestSdkFunction {
35
58
  // All functions now properly typed!
36
59
  }
37
60
 
38
- // Compose SDK plugins from individual plugin interfaces
39
- export interface ZapierSdkPlugins
40
- extends AppsPluginSdkExtension,
41
- FetchPluginSdkExtension {
42
- // All plugins now properly typed!
43
- }
61
+ // Note: ZapierSdkPlugins removed - plugins are now handled by the plugin builder system
44
62
 
45
- // Base SDK interface with core functions only (no plugins)
46
- export interface BaseZapierSdk extends ZapierSdkFunctions {
47
- // Special property for CLI to access schemas
48
- __registry: Array<{
49
- name: string;
50
- inputSchema: any;
51
- implementation: Function;
52
- }>;
53
- }
63
+ // Note: BaseZapierSdk removed - all functions now provided by individual plugins
64
+ // The registry is provided by RegistryPlugin
54
65
 
55
- // Main SDK interface with functions and plugins
56
- export interface ZapierSdk extends ZapierSdkFunctions, ZapierSdkPlugins {
57
- // Special property for CLI to access schemas
58
- __registry: Array<{
59
- name: string;
60
- inputSchema: any;
61
- implementation: Function;
62
- }>;
63
- }
66
+ // Note: ZapierSdk type removed - use ReturnType<typeof createZapierSdk> instead
67
+ // This ensures the type matches exactly what the builder produces
68
+
69
+ export type ZapierSdk = GetSdkType<
70
+ RegistryPluginProvides &
71
+ FetchPluginProvides &
72
+ AppsPluginProvides &
73
+ ListAppsPluginProvides &
74
+ GetAppPluginProvides &
75
+ ListActionsPluginProvides &
76
+ GetActionPluginProvides &
77
+ RunActionPluginProvides &
78
+ ListAuthenticationsPluginProvides &
79
+ GetAuthenticationPluginProvides &
80
+ FindFirstAuthenticationPluginProvides &
81
+ FindUniqueAuthenticationPluginProvides &
82
+ ListInputFieldsPluginProvides &
83
+ RequestPluginProvides &
84
+ GetProfilePluginProvides
85
+ >;