@zapier/zapier-sdk 0.4.0 → 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 +2134 -1444
  30. package/dist/index.d.mts +2456 -584
  31. package/dist/index.d.ts +17 -840
  32. package/dist/index.d.ts.map +1 -0
  33. package/dist/index.js +20 -0
  34. package/dist/index.mjs +2118 -1428
  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 +403 -167
  253. package/src/api/debug.ts +10 -1
  254. package/src/api/index.ts +0 -2
  255. package/src/api/polling.ts +31 -14
  256. package/src/api/schemas.ts +387 -0
  257. package/src/api/types.ts +73 -138
  258. package/src/constants.ts +10 -0
  259. package/src/index.ts +45 -20
  260. package/src/plugins/api/index.ts +47 -0
  261. package/src/plugins/apps/index.ts +36 -31
  262. package/src/plugins/apps/types.ts +24 -12
  263. package/src/plugins/fetch/index.ts +58 -0
  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/plugins/request/schemas.ts +64 -0
  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 +133 -105
  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 +71 -46
  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/fetch/index.ts +0 -180
  338. package/src/functions/fetch/info.ts +0 -8
  339. package/src/functions/fetch/schemas.ts +0 -46
  340. package/src/functions/findFirstAuthentication/index.ts +0 -24
  341. package/src/functions/findFirstAuthentication/info.ts +0 -9
  342. package/src/functions/findFirstAuthentication/schemas.ts +0 -50
  343. package/src/functions/findUniqueAuthentication/index.ts +0 -35
  344. package/src/functions/findUniqueAuthentication/info.ts +0 -9
  345. package/src/functions/findUniqueAuthentication/schemas.ts +0 -50
  346. package/src/functions/generateTypes/index.ts +0 -363
  347. package/src/functions/generateTypes/info.ts +0 -9
  348. package/src/functions/generateTypes/schemas.ts +0 -31
  349. package/src/functions/getAction/index.ts +0 -33
  350. package/src/functions/getAction/info.ts +0 -9
  351. package/src/functions/getAction/schemas.ts +0 -25
  352. package/src/functions/getApp/index.ts +0 -41
  353. package/src/functions/getApp/info.ts +0 -9
  354. package/src/functions/getApp/schemas.ts +0 -20
  355. package/src/functions/getAuthentication/index.ts +0 -50
  356. package/src/functions/getAuthentication/info.ts +0 -9
  357. package/src/functions/getAuthentication/schemas.ts +0 -29
  358. package/src/functions/listActions/index.ts +0 -149
  359. package/src/functions/listActions/info.ts +0 -9
  360. package/src/functions/listActions/schemas.ts +0 -30
  361. package/src/functions/listApps/index.ts +0 -60
  362. package/src/functions/listApps/info.ts +0 -9
  363. package/src/functions/listApps/schemas.ts +0 -32
  364. package/src/functions/listAuthentications/index.ts +0 -162
  365. package/src/functions/listAuthentications/info.ts +0 -9
  366. package/src/functions/listAuthentications/schemas.ts +0 -50
  367. package/src/functions/listFields/index.ts +0 -86
  368. package/src/functions/listFields/info.ts +0 -9
  369. package/src/functions/listFields/schemas.ts +0 -36
  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/{schema-utils.ts → utils/schema-utils.ts} +0 -0
package/src/api/types.ts CHANGED
@@ -4,8 +4,37 @@
4
4
  * This module contains all type definitions related to the Zapier API client,
5
5
  * including configuration options, client interfaces, request/response types,
6
6
  * and API response models.
7
+ *
8
+ * API response model types are inferred from Zod schemas defined in api/schemas.ts
9
+ * to ensure a single source of truth and eliminate duplication.
7
10
  */
8
11
 
12
+ import { z } from "zod";
13
+ import {
14
+ NeedChoicesSchema,
15
+ NeedSchema,
16
+ ActionLinksSchema,
17
+ ActionPermissionsSchema,
18
+ ActionSchema,
19
+ ChoiceSchema,
20
+ FieldSchema,
21
+ ActionExecutionResultSchema,
22
+ ActionFieldChoiceSchema,
23
+ ActionFieldSchema,
24
+ AuthenticationSchema,
25
+ AuthenticationsResponseSchema,
26
+ UserProfileSchema,
27
+ AppSchema,
28
+ NeedsRequestSchema,
29
+ NeedsResponseSchema,
30
+ ImplementationSchema,
31
+ ImplementationsResponseSchema,
32
+ ImplementationMetaSchema,
33
+ ImplementationsMetaResponseSchema,
34
+ ServiceSchema,
35
+ ServicesResponseSchema,
36
+ } from "./schemas";
37
+
9
38
  // ============================================================================
10
39
  // API Client Infrastructure Types
11
40
  // ============================================================================
@@ -26,11 +55,10 @@ export interface ApiClient {
26
55
  delete: (path: string, options?: RequestOptions) => Promise<any>;
27
56
  poll: (path: string, options?: PollOptions) => Promise<any>;
28
57
  fetch: (
29
- input: string | URL,
58
+ path: string,
30
59
  init?: RequestInit & {
31
60
  searchParams?: Record<string, string>;
32
61
  authRequired?: boolean;
33
- customErrorHandler?: (response: Response) => Error | undefined;
34
62
  },
35
63
  ) => Promise<Response>;
36
64
  }
@@ -39,7 +67,11 @@ export interface RequestOptions {
39
67
  headers?: Record<string, string>;
40
68
  searchParams?: Record<string, string>;
41
69
  authRequired?: boolean;
42
- customErrorHandler?: (response: Response) => Error | undefined;
70
+ customErrorHandler?: (errorInfo: {
71
+ status: number;
72
+ statusText: string;
73
+ data: any;
74
+ }) => Error | undefined;
43
75
  }
44
76
 
45
77
  export interface PollOptions extends RequestOptions {
@@ -56,140 +88,43 @@ export interface DebugLogger {
56
88
  }
57
89
 
58
90
  // ============================================================================
59
- // API Response Models
91
+ // API Response Models (inferred from Zod schemas)
60
92
  // ============================================================================
61
93
 
62
- export interface Integration {
63
- key: string;
64
- name: string;
65
- description: string;
66
- version: string;
67
- category?: string;
68
- actions: Action[];
69
- triggers: Trigger[];
70
- current_implementation_id?: string;
71
- }
72
-
73
- export interface Action {
74
- key: string;
75
- name: string;
76
- description: string;
77
- appKey: string;
78
- type:
79
- | "read"
80
- | "read_bulk"
81
- | "write"
82
- | "run"
83
- | "search"
84
- | "search_or_write"
85
- | "search_and_write"
86
- | "filter";
87
- inputFields: Field[];
88
- outputFields: Field[];
89
- }
90
-
91
- export interface Trigger {
92
- key: string;
93
- name: string;
94
- description: string;
95
- appKey: string;
96
- type: "instant" | "polling" | "webhook";
97
- outputFields: Field[];
98
- }
99
-
100
- export interface Field {
101
- key: string;
102
- label: string;
103
- type:
104
- | "string"
105
- | "number"
106
- | "boolean"
107
- | "datetime"
108
- | "file"
109
- | "object"
110
- | "array";
111
- required: boolean;
112
- description?: string;
113
- choices?: Choice[];
114
- }
115
-
116
- export interface Choice {
117
- value: string | number;
118
- label: string;
119
- }
120
-
121
- export interface ActionExecutionResult {
122
- success: boolean;
123
- data?: any;
124
- error?: string;
125
- metadata?: {
126
- executionTime?: number;
127
- requestId?: string;
128
- };
129
- }
130
-
131
- export interface ActionField {
132
- key: string;
133
- label?: string;
134
- required: boolean;
135
- type?: string;
136
- helpText?: string;
137
- helpTextHtml?: string;
138
- choices?: ActionFieldChoice[];
139
- default?: string;
140
- placeholder?: string;
141
- computed?: boolean;
142
- customField?: boolean;
143
- dependsOn?: string[];
144
- format?: string;
145
- inputFormat?: string[];
146
- }
147
-
148
- export interface ActionFieldChoice {
149
- value: string | number;
150
- label: string;
151
- }
152
-
153
- export interface NeedsRequest {
154
- selected_api: string;
155
- action: string;
156
- type_of: string;
157
- authentication_id?: number;
158
- params?: Record<string, any>;
159
- }
160
-
161
- export interface NeedsResponse {
162
- success: boolean;
163
- needs?: ActionField[];
164
- errors?: string[];
165
- }
166
-
167
- export interface Authentication {
168
- id: number;
169
- date: string;
170
- lastchanged?: string;
171
- account_id: number;
172
- customuser_id?: number;
173
- selected_api: string;
174
- destination_selected_api?: string | null;
175
- is_invite_only: boolean;
176
- is_private: boolean;
177
- shared_with_all: boolean;
178
- is_stale?: string;
179
- is_shared?: string;
180
- marked_stale_at?: string | null;
181
- label?: string | null;
182
- identifier?: string | null;
183
- title?: string | null;
184
- url?: string;
185
- groups?: string;
186
- members?: string;
187
- permissions?: Record<string, boolean>;
188
- }
189
-
190
- export interface AuthenticationsResponse {
191
- count: number;
192
- next?: string | null;
193
- previous?: string | null;
194
- results: Authentication[];
195
- }
94
+ // Basic building blocks
95
+ export type NeedChoices = z.infer<typeof NeedChoicesSchema>;
96
+ export type Need = z.infer<typeof NeedSchema>;
97
+ export type ActionLinks = z.infer<typeof ActionLinksSchema>;
98
+ export type ActionPermissions = z.infer<typeof ActionPermissionsSchema>;
99
+ export type Action = z.infer<typeof ActionSchema>;
100
+ export type Choice = z.infer<typeof ChoiceSchema>;
101
+ export type Field = z.infer<typeof FieldSchema>;
102
+ export type ActionExecutionResult = z.infer<typeof ActionExecutionResultSchema>;
103
+ export type ActionFieldChoice = z.infer<typeof ActionFieldChoiceSchema>;
104
+ export type ActionField = z.infer<typeof ActionFieldSchema>;
105
+
106
+ // Main API entities
107
+ export type Authentication = z.infer<typeof AuthenticationSchema>;
108
+ export type AuthenticationsResponse = z.infer<
109
+ typeof AuthenticationsResponseSchema
110
+ >;
111
+ export type UserProfile = z.infer<typeof UserProfileSchema>;
112
+ export type App = z.infer<typeof AppSchema>;
113
+ export type Service = z.infer<typeof ServiceSchema>;
114
+ export type ServicesResponse = z.infer<typeof ServicesResponseSchema>;
115
+
116
+ // Request/Response types
117
+ export type NeedsRequest = z.infer<typeof NeedsRequestSchema>;
118
+ export type NeedsResponse = z.infer<typeof NeedsResponseSchema>;
119
+
120
+ // Implementation types
121
+ export type Implementation = z.infer<typeof ImplementationSchema>;
122
+ export type ImplementationsResponse = z.infer<
123
+ typeof ImplementationsResponseSchema
124
+ >;
125
+
126
+ // Implementation Meta types (lightweight)
127
+ export type ImplementationMeta = z.infer<typeof ImplementationMetaSchema>;
128
+ export type ImplementationsMetaResponse = z.infer<
129
+ typeof ImplementationsMetaResponseSchema
130
+ >;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * SDK Constants
3
+ *
4
+ * This module contains shared constants used throughout the SDK.
5
+ */
6
+
7
+ /**
8
+ * Maximum number of items that can be requested per page across all paginated functions
9
+ */
10
+ export const MAX_PAGE_LIMIT = 10000;
package/src/index.ts CHANGED
@@ -1,10 +1,31 @@
1
1
  // Export everything from types and plugins
2
2
  export * from "./types/domain";
3
+ export * from "./types/functions";
3
4
  export * from "./types/properties";
5
+ export * from "./types/errors";
4
6
  export * from "./plugins/apps";
7
+ export * from "./plugins/fetch";
8
+
9
+ // Export API types directly (no longer re-exported from domain)
10
+ export type {
11
+ Action,
12
+ App,
13
+ Need,
14
+ Field,
15
+ Choice,
16
+ ActionExecutionResult,
17
+ ActionField,
18
+ ActionFieldChoice,
19
+ NeedsRequest,
20
+ NeedsResponse,
21
+ Authentication,
22
+ AuthenticationsResponse,
23
+ UserProfile,
24
+ } from "./api/types";
5
25
 
6
26
  // Export schema utilities for CLI
7
- export { isPositional } from "./schema-utils";
27
+ export { isPositional } from "./utils/schema-utils";
28
+ export { hasResolver } from "./resolvers";
8
29
 
9
30
  // Export auth utilities for CLI use
10
31
  export * from "./auth";
@@ -14,24 +35,28 @@ export * from "./resolvers";
14
35
 
15
36
  // Note: SdkSchemas is now available via SDK.__registry
16
37
 
17
- // Export individual functions for tree-shaking
18
- export { listAuthentications } from "./functions/listAuthentications";
19
- export { getAuthentication } from "./functions/getAuthentication";
20
- export { findFirstAuthentication } from "./functions/findFirstAuthentication";
21
- export { findUniqueAuthentication } from "./functions/findUniqueAuthentication";
22
- export { listApps } from "./functions/listApps";
23
- export { getApp } from "./functions/getApp";
24
- export { listActions } from "./functions/listActions";
25
- export { getAction } from "./functions/getAction";
26
- export { runAction } from "./functions/runAction";
27
- export { listFields } from "./functions/listFields";
28
- export { generateTypes } from "./functions/generateTypes";
29
- export { bundleCode } from "./functions/bundleCode";
30
- export { fetch, relayFetch } from "./functions/fetch";
31
- export { RelayFetchSchema } from "./functions/fetch/schemas";
32
-
33
- // Export the main combined SDK
34
- export { createZapierSdk, ZapierSdkOptions } from "./sdk";
38
+ // All functions now available through the plugin system via createZapierSdk()
39
+ // Export plugin schemas for external use
40
+ export {
41
+ RelayRequestSchema,
42
+ RelayFetchSchema,
43
+ } from "./plugins/request/schemas";
44
+
45
+ // Export the main combined SDK and new flexible SDK creator
46
+ export { createZapierSdk, createSdk, ZapierSdkOptions } from "./sdk";
35
47
 
36
48
  // Export SDK types from types (not sdk.ts to avoid circular imports)
37
- export type { BaseZapierSdk, ZapierSdk } from "./types/sdk";
49
+ export type { FunctionRegistryEntry } from "./types/sdk";
50
+
51
+ // Export plugin utilities and SDK types
52
+ export type {
53
+ Plugin,
54
+ PluginProvides,
55
+ PluginDependencies,
56
+ PluginOptions,
57
+ GetSdkType,
58
+ Sdk,
59
+ } from "./types/plugin";
60
+
61
+ // Export ZapierSdk from sdk.ts (it's now ReturnType<typeof createZapierSdk>)
62
+ export type { ZapierSdk } from "./types/sdk";
@@ -0,0 +1,47 @@
1
+ import { createZapierApi } from "../../api";
2
+ import type { ApiClient } from "../../api/types";
3
+ import type { BaseSdkOptions } from "../../types/sdk";
4
+ import type { Plugin } from "../../types/plugin";
5
+
6
+ export interface ApiPluginOptions extends BaseSdkOptions {}
7
+
8
+ // API plugin only provides context, no SDK methods
9
+ export interface ApiPluginProvides {
10
+ context: {
11
+ api: ApiClient;
12
+ };
13
+ }
14
+
15
+ // API plugin requires no context and provides api in context
16
+ export const apiPlugin: Plugin<
17
+ {}, // no SDK dependencies
18
+ {}, // requires no context
19
+ ApiPluginProvides
20
+ > = (params) => {
21
+ // Extract all options - everything passed to the plugin
22
+ const {
23
+ fetch: customFetch = globalThis.fetch,
24
+ baseUrl = "https://zapier.com",
25
+ token,
26
+ getToken,
27
+ onEvent,
28
+ debug = false,
29
+ } = params as any;
30
+
31
+ // Create the API client - it will handle token resolution internally
32
+ const api = createZapierApi({
33
+ baseUrl,
34
+ token,
35
+ getToken,
36
+ debug,
37
+ fetch: customFetch,
38
+ onEvent,
39
+ });
40
+
41
+ // Return flat structure with context only
42
+ return {
43
+ context: {
44
+ api, // Provide API client in context for other plugins to use
45
+ },
46
+ };
47
+ };
@@ -1,12 +1,16 @@
1
- import {
2
- ActionExecutionOptions,
3
- ActionExecutionResult,
4
- } from "../../types/domain";
1
+ import { ActionExecutionOptions } from "./types";
5
2
  import type { ActionProxy } from "./types";
6
- import type { ZapierSdk } from "../../types/sdk";
3
+ import { ZapierValidationError } from "../../types/errors";
4
+ import type { Plugin, GetSdkType } from "../../types/plugin";
5
+ import type { FetchPluginProvides } from "../fetch/index";
6
+ import type { RunActionPluginProvides } from "../runAction/index";
7
7
 
8
- export interface AppsPluginOptions {
9
- sdk: ZapierSdk;
8
+ export interface AppsPluginProvides {
9
+ apps: ActionProxy;
10
+ }
11
+
12
+ interface AppsPluginOptions {
13
+ sdk: GetSdkType<FetchPluginProvides & RunActionPluginProvides>;
10
14
  }
11
15
 
12
16
  interface AppFactoryOptions {
@@ -20,9 +24,7 @@ function createActionFunction(
20
24
  options: AppsPluginOptions,
21
25
  pinnedAuthId?: number,
22
26
  ) {
23
- return async (
24
- actionOptions: ActionExecutionOptions = {},
25
- ): Promise<ActionExecutionResult> => {
27
+ return (actionOptions: ActionExecutionOptions = {}): any => {
26
28
  const { sdk } = options;
27
29
  const { inputs, authenticationId: providedAuthenticationId } =
28
30
  actionOptions;
@@ -31,7 +33,7 @@ function createActionFunction(
31
33
  const authenticationId = pinnedAuthId || providedAuthenticationId;
32
34
 
33
35
  if (!authenticationId) {
34
- throw new Error(
36
+ throw new ZapierValidationError(
35
37
  `Authentication ID is required. Either use the factory pattern: sdk.apps.${appKey}({ authenticationId }) or provide authenticationId in the action call.`,
36
38
  );
37
39
  }
@@ -55,29 +57,28 @@ function createActionTypeProxy(
55
57
  ) {
56
58
  // Special handling for "fetch" action type
57
59
  if (actionType === "fetch") {
58
- return async (fetchOptions: {
59
- url: string;
60
- method?: "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "HEAD" | "OPTIONS";
61
- body?: string;
62
- headers?: Record<string, string>;
63
- callbackUrl?: string;
64
- authenticationTemplate?: string;
65
- authenticationId?: number;
66
- }) => {
60
+ return async (
61
+ url: string | URL,
62
+ init?: RequestInit & {
63
+ authenticationId?: number;
64
+ callbackUrl?: string;
65
+ authenticationTemplate?: string;
66
+ },
67
+ ) => {
67
68
  const { sdk } = options;
68
69
 
69
70
  // Use pinned auth ID first, then provided auth ID
70
- const authenticationId = pinnedAuthId || fetchOptions.authenticationId;
71
+ const authenticationId = pinnedAuthId || init?.authenticationId;
71
72
 
72
73
  if (!authenticationId) {
73
- throw new Error(
74
+ throw new ZapierValidationError(
74
75
  `Authentication ID is required for fetch. Either use the factory pattern: sdk.apps.${appKey}({ authenticationId }).fetch(...) or provide authenticationId in the fetch call.`,
75
76
  );
76
77
  }
77
78
 
78
79
  // Call sdk.fetch with the resolved authenticationId
79
- return sdk.fetch({
80
- ...fetchOptions,
80
+ return sdk.fetch(url, {
81
+ ...init,
81
82
  authenticationId,
82
83
  });
83
84
  };
@@ -161,10 +162,14 @@ function createAppsProxy(options: AppsPluginOptions): ActionProxy {
161
162
  return appsProxy;
162
163
  }
163
164
 
164
- // Export the plugin creation function
165
- export function createAppsPlugin(options: AppsPluginOptions): ActionProxy {
166
- return createAppsProxy(options);
167
- }
168
-
169
- // Re-export types
170
- export type { ActionProxy, AppsPluginSdkExtension } from "./types";
165
+ // Direct plugin function - takes options + sdk + context in one object
166
+ export const appsPlugin: Plugin<
167
+ GetSdkType<FetchPluginProvides & RunActionPluginProvides>, // requires fetch + runAction in SDK
168
+ {}, // no context requirements
169
+ AppsPluginProvides
170
+ > = ({ sdk }) => {
171
+ // Return flat structure - apps goes directly to SDK
172
+ return {
173
+ apps: createAppsProxy({ sdk }),
174
+ };
175
+ };
@@ -1,18 +1,33 @@
1
- import type {
2
- ActionExecutionOptions,
3
- ActionExecutionResult,
4
- } from "../../types/domain";
1
+ // Apps plugin-specific execution options
2
+ export interface ActionExecutionOptions {
3
+ inputs?: Record<string, any>;
4
+ authenticationId?: number;
5
+ }
5
6
 
6
7
  interface AppFactoryOptions {
7
8
  authenticationId: number;
8
9
  }
9
10
 
10
- interface ActionTypeProxy {
11
- [action: string]: (
12
- options?: ActionExecutionOptions,
13
- ) => Promise<ActionExecutionResult>;
11
+ // Base action type proxy for regular actions
12
+ interface BaseActionTypeProxy {
13
+ [action: string]: (options?: ActionExecutionOptions) => any;
14
+ }
15
+
16
+ // Special fetch function type
17
+ interface FetchActionType {
18
+ fetch: (
19
+ url: string | URL,
20
+ init?: RequestInit & {
21
+ authenticationId?: number;
22
+ callbackUrl?: string;
23
+ authenticationTemplate?: string;
24
+ },
25
+ ) => Promise<Response>;
14
26
  }
15
27
 
28
+ // Combined action type proxy
29
+ type ActionTypeProxy = BaseActionTypeProxy & Partial<FetchActionType>;
30
+
16
31
  interface AppProxy {
17
32
  [type: string]: ActionTypeProxy;
18
33
  }
@@ -28,7 +43,4 @@ export interface ActionProxy {
28
43
  [app: string]: AppProxyWithFactory;
29
44
  }
30
45
 
31
- // Plugin interface - ready to be mixed into main SDK interface
32
- export interface AppsPluginSdkExtension {
33
- apps: ActionProxy;
34
- }
46
+ // Note: AppsPluginSdkExtension removed - now using AppsPluginProvides in index.ts
@@ -0,0 +1,58 @@
1
+ import { RelayRequestOptions } from "../request/schemas";
2
+ import type { Plugin, GetSdkType } from "../../types/plugin";
3
+ import type { RequestPluginProvides } from "../request";
4
+
5
+ export interface FetchPluginProvides {
6
+ fetch: (
7
+ url: string | URL,
8
+ init?: RequestInit & {
9
+ authenticationId?: number;
10
+ callbackUrl?: string;
11
+ authenticationTemplate?: string;
12
+ },
13
+ ) => Promise<Response>;
14
+ }
15
+
16
+ /**
17
+ * Direct plugin function - takes options + sdk + context in one object
18
+ */
19
+ export const fetchPlugin: Plugin<
20
+ GetSdkType<RequestPluginProvides>, // requires request in SDK
21
+ {}, // requires no context (uses SDK methods)
22
+ FetchPluginProvides
23
+ > = ({ sdk }) => {
24
+ // Return flat structure - fetch goes directly to SDK
25
+ return {
26
+ fetch: async function fetch(
27
+ url: string | URL,
28
+ init?: RequestInit & {
29
+ authenticationId?: number;
30
+ callbackUrl?: string;
31
+ authenticationTemplate?: string;
32
+ },
33
+ ): Promise<Response> {
34
+ const {
35
+ authenticationId,
36
+ callbackUrl,
37
+ authenticationTemplate,
38
+ ...fetchInit
39
+ } = init || {};
40
+
41
+ return sdk.request({
42
+ url: url.toString(),
43
+ method: fetchInit.method as RelayRequestOptions["method"],
44
+ body: fetchInit.body,
45
+ headers: fetchInit.headers,
46
+ authenticationId,
47
+ callbackUrl,
48
+ authenticationTemplate,
49
+ });
50
+ },
51
+ };
52
+ };
53
+
54
+ export type ZapierFetchInitOptions = RequestInit & {
55
+ authenticationId?: number;
56
+ callbackUrl?: string;
57
+ authenticationTemplate?: string;
58
+ };