@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
@@ -1,78 +0,0 @@
1
- import type { BundleCodeOptions } from "./schemas";
2
-
3
- /**
4
- * Bundle TypeScript code into executable JavaScript
5
- *
6
- * This function can be used standalone without instantiating a full SDK,
7
- * which enables better tree-shaking in applications that only need this functionality.
8
- *
9
- * @param options - Bundling configuration options
10
- * @returns Promise<string> - Bundled JavaScript code
11
- */
12
- export async function bundleCode(options: BundleCodeOptions): Promise<string> {
13
- const {
14
- input,
15
- output,
16
- target = "es2020",
17
- cjs = false,
18
- minify = false,
19
- string: returnString = false,
20
- } = options;
21
-
22
- // Dynamically import esbuild
23
- const { buildSync } = await import("esbuild");
24
- const fs = await import("fs");
25
- const path = await import("path");
26
-
27
- // Resolve input path
28
- const resolvedInput = path.resolve(process.cwd(), input);
29
-
30
- try {
31
- // Bundle with esbuild
32
- const result = buildSync({
33
- entryPoints: [resolvedInput],
34
- bundle: true,
35
- platform: "node",
36
- target: target,
37
- format: cjs ? "cjs" : "esm",
38
- minify: minify,
39
- write: false,
40
- external: [], // Bundle everything
41
- banner: {
42
- js: "#!/usr/bin/env node",
43
- },
44
- });
45
-
46
- if (result.errors.length > 0) {
47
- throw new Error(
48
- `Bundle failed: ${result.errors.map((e) => e.text).join(", ")}`,
49
- );
50
- }
51
-
52
- const bundledCode = result.outputFiles?.[0]?.text;
53
- if (!bundledCode) {
54
- throw new Error("No output generated");
55
- }
56
-
57
- let finalOutput = bundledCode;
58
-
59
- if (returnString) {
60
- // Output as quoted string for node -e using JSON.stringify
61
- finalOutput = JSON.stringify(bundledCode);
62
- }
63
-
64
- // Write to file if output path specified
65
- if (output) {
66
- fs.mkdirSync(path.dirname(output), { recursive: true });
67
- fs.writeFileSync(output, finalOutput, "utf8");
68
- }
69
-
70
- return finalOutput;
71
- } catch (error) {
72
- throw new Error(
73
- `Bundle failed: ${
74
- error instanceof Error ? error.message : "Unknown error"
75
- }`,
76
- );
77
- }
78
- }
@@ -1,9 +0,0 @@
1
- import { bundleCode } from "./index";
2
- import { BundleCodeSchema } from "./schemas";
3
-
4
- // Function registry info - imports both function and schema
5
- export const bundleCodeInfo = {
6
- name: bundleCode.name,
7
- inputSchema: BundleCodeSchema,
8
- implementation: bundleCode,
9
- };
@@ -1,30 +0,0 @@
1
- import { z } from "zod";
2
- import { OutputPropertySchema } from "../../types/properties";
3
-
4
- // Pure Zod schema - no resolver metadata!
5
- export const BundleCodeSchema = z
6
- .object({
7
- input: z.string().min(1).describe("Input TypeScript file path to bundle"),
8
- output: OutputPropertySchema.optional().describe(
9
- "Output file path (defaults to input with .js extension)",
10
- ),
11
- string: z
12
- .boolean()
13
- .default(false)
14
- .describe("Return bundled code as string instead of writing to file"),
15
- minify: z.boolean().default(false).describe("Minify the bundled output"),
16
- target: z.string().default("es2017").describe("ECMAScript target version"),
17
- cjs: z
18
- .boolean()
19
- .default(false)
20
- .describe("Output CommonJS format instead of ESM"),
21
- })
22
- .describe("Bundle TypeScript code into executable JavaScript");
23
-
24
- // Type inferred from schema (no additional function config needed for bundleCode)
25
- export type BundleCodeOptions = z.infer<typeof BundleCodeSchema>;
26
-
27
- // SDK function interface - ready to be mixed into main SDK interface
28
- export interface BundleCodeSdkFunction {
29
- bundleCode: (options: BundleCodeOptions) => Promise<string>;
30
- }
@@ -1,180 +0,0 @@
1
- import { getOrCreateApiClient } from "../../api";
2
- import type { FunctionOptions } from "../../types/domain";
3
-
4
- export interface RelayFetchOptions {
5
- /** HTTP method */
6
- method?: string;
7
- /** Request body as a string */
8
- body?: string;
9
- /** Request headers */
10
- headers?: HeadersInit;
11
- /** Zapier authentication ID to use for the request */
12
- authenticationId?: number;
13
- /** URL to send async response to (makes request async) */
14
- callbackUrl?: string;
15
- /** Optional JSON string authentication template to bypass Notary lookup */
16
- authenticationTemplate?: string;
17
- }
18
-
19
- export interface RelayFetchConfig extends FunctionOptions {
20
- /** Event callback function */
21
- onEvent?: (event: any) => void;
22
- }
23
-
24
- /**
25
- * Transforms full URLs into Relay format: /relay/{domain}/{path}
26
- *
27
- * @param url - The full URL to transform (e.g., "https://api.github.com/user")
28
- * @returns The relay path format (e.g., "/relay/api.github.com/user")
29
- */
30
- function transformUrlToRelayPath(url: string | URL): string {
31
- const targetUrl = new URL(url);
32
-
33
- // Build the Relay path: /relay/{domain}{pathname}{search}{hash}
34
- const relayPath = `/relay/${targetUrl.hostname}${targetUrl.pathname}${targetUrl.search}${targetUrl.hash}`;
35
-
36
- return relayPath;
37
- }
38
-
39
- /**
40
- * Fetch function that can make requests to external APIs through Zapier's Relay service
41
- *
42
- * This function takes full URLs (like https://api.github.com/user) and transforms them
43
- * into the relay format (/relay/api.github.com/user) for the API client to route
44
- * to relay.zapier.com.
45
- *
46
- * @param url - The full URL to fetch
47
- * @param options - Fetch options with additional Relay-specific parameters
48
- * @param config - SDK configuration options
49
- * @returns Promise<Response> - The response from the request
50
- */
51
- /**
52
- * Schema-compatible wrapper function for the fetch functionality
53
- */
54
- export async function fetch(
55
- options: {
56
- url: string;
57
- method?: string;
58
- body?: string;
59
- headers?: Record<string, string>;
60
- authenticationId?: number;
61
- callbackUrl?: string;
62
- authenticationTemplate?: string;
63
- } & FunctionOptions,
64
- ): Promise<Response> {
65
- const {
66
- url,
67
- method = "GET",
68
- body,
69
- headers,
70
- authenticationId,
71
- callbackUrl,
72
- authenticationTemplate,
73
- ...config
74
- } = options;
75
-
76
- return relayFetch(
77
- url,
78
- {
79
- method,
80
- body,
81
- headers,
82
- authenticationId,
83
- callbackUrl,
84
- authenticationTemplate,
85
- },
86
- config,
87
- );
88
- }
89
-
90
- /**
91
- * Internal fetch implementation
92
- */
93
- export async function relayFetch(
94
- url: string | URL,
95
- options: RelayFetchOptions = {},
96
- config: RelayFetchConfig = {},
97
- ): Promise<Response> {
98
- const api = getOrCreateApiClient(config);
99
-
100
- // Extract Relay-specific options
101
- const {
102
- authenticationId,
103
- callbackUrl,
104
- authenticationTemplate,
105
- method = "GET",
106
- body,
107
- ...fetchOptions
108
- } = options;
109
-
110
- // Transform full URL to relay path format
111
- const relayPath = transformUrlToRelayPath(url);
112
-
113
- // Build headers for the request
114
- const headers: Record<string, string> = {};
115
-
116
- // Copy existing headers
117
- if (fetchOptions.headers) {
118
- const headerEntries =
119
- fetchOptions.headers instanceof Headers
120
- ? Array.from(fetchOptions.headers.entries())
121
- : Object.entries(fetchOptions.headers);
122
-
123
- for (const [key, value] of headerEntries) {
124
- headers[key] = value;
125
- }
126
- }
127
-
128
- // Add Relay-specific headers
129
- if (authenticationId) {
130
- headers["X-Relay-Authentication-Id"] = authenticationId.toString();
131
- }
132
-
133
- if (callbackUrl) {
134
- headers["X-Relay-Callback-Url"] = callbackUrl;
135
- }
136
-
137
- if (authenticationTemplate) {
138
- headers["X-Authentication-Template"] = authenticationTemplate;
139
- }
140
-
141
- // For Relay requests, we need to disable the default authorization and add our own
142
- const requestOptions = {
143
- headers,
144
- authRequired: false, // Disable automatic Authorization header
145
- customErrorHandler: (response: Response) => {
146
- if (!response.ok) {
147
- return new Error(
148
- `Relay request failed: ${response.status} ${response.statusText}`,
149
- );
150
- }
151
- return undefined;
152
- },
153
- };
154
-
155
- // Add X-Relay-Authorization header manually
156
- let token = config.token;
157
- if (!token && config.getToken) {
158
- token = await config.getToken();
159
- }
160
- if (!token) {
161
- const { getTokenFromEnvOrConfig } = await import("../../auth");
162
- token = await getTokenFromEnvOrConfig({
163
- onEvent: config.onEvent,
164
- fetch: config.fetch,
165
- });
166
- }
167
- if (token) {
168
- const { getAuthorizationHeader } = await import("../../api/auth");
169
- headers["X-Relay-Authorization"] = getAuthorizationHeader(token);
170
- }
171
-
172
- // Use the API client's fetch method directly
173
- return await api.fetch(relayPath, {
174
- method,
175
- body,
176
- headers: requestOptions.headers,
177
- authRequired: requestOptions.authRequired,
178
- customErrorHandler: requestOptions.customErrorHandler,
179
- });
180
- }
@@ -1,8 +0,0 @@
1
- import { fetch } from "./index";
2
- import { RelayFetchSchema } from "./schemas";
3
-
4
- export const fetchInfo = {
5
- name: "fetch",
6
- inputSchema: RelayFetchSchema,
7
- implementation: fetch,
8
- };
@@ -1,46 +0,0 @@
1
- import { z } from "zod";
2
- import type { FunctionOptions } from "../../types/domain";
3
-
4
- // Pure Zod schema for the fetch function
5
- export const RelayFetchSchema = z
6
- .object({
7
- url: z
8
- .string()
9
- .url()
10
- .describe("The URL to fetch (will be proxied through Relay)"),
11
- method: z
12
- .enum(["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"])
13
- .optional()
14
- .describe("HTTP method"),
15
- body: z.string().optional().describe("Request body as a string"),
16
- authenticationId: z
17
- .number()
18
- .int()
19
- .optional()
20
- .describe("Zapier authentication ID to use for the request"),
21
- callbackUrl: z
22
- .string()
23
- .url()
24
- .optional()
25
- .describe("URL to send async response to (makes request async)"),
26
- authenticationTemplate: z
27
- .string()
28
- .optional()
29
- .describe(
30
- "Optional JSON string authentication template to bypass Notary lookup",
31
- ),
32
- headers: z.record(z.string()).optional().describe("Request headers"),
33
- })
34
- .describe("Make authenticated HTTP requests through Zapier's Relay service");
35
-
36
- // Type inferred from schema + function config
37
- export type RelayFetchOptions = z.infer<typeof RelayFetchSchema> &
38
- FunctionOptions & {
39
- /** Base URL for Relay service */
40
- relayBaseUrl?: string;
41
- };
42
-
43
- // SDK function interface
44
- export interface RelayFetchSdkFunction {
45
- fetch: (options: RelayFetchOptions) => Promise<Response>;
46
- }
@@ -1,24 +0,0 @@
1
- import type { Authentication } from "../../types/domain";
2
- import { listAuthentications } from "../listAuthentications";
3
- import type { FindFirstAuthenticationOptions } from "./schemas";
4
-
5
- /**
6
- * Find the first authentication matching the given criteria
7
- *
8
- * This function can be used standalone without instantiating a full SDK,
9
- * which enables better tree-shaking in applications that only need this functionality.
10
- *
11
- * @param options - Filtering and API configuration options
12
- * @returns Promise<Authentication | null> - First matching authentication or null if not found
13
- */
14
- export async function findFirstAuthentication(
15
- options: Partial<FindFirstAuthenticationOptions> = {},
16
- ): Promise<Authentication | null> {
17
- // Use listAuthentications with limit 1 to get the first result
18
- const auths = await listAuthentications({
19
- ...options,
20
- limit: 1,
21
- });
22
-
23
- return auths.length > 0 ? auths[0] : null;
24
- }
@@ -1,9 +0,0 @@
1
- import { findFirstAuthentication } from "./index";
2
- import { FindFirstAuthenticationSchema } from "./schemas";
3
-
4
- // Function registry info - imports both function and schema
5
- export const findFirstAuthenticationInfo = {
6
- name: findFirstAuthentication.name,
7
- inputSchema: FindFirstAuthenticationSchema,
8
- implementation: findFirstAuthentication,
9
- };
@@ -1,50 +0,0 @@
1
- import { z } from "zod";
2
- import {
3
- AppKeyPropertySchema,
4
- LimitPropertySchema,
5
- OffsetPropertySchema,
6
- } from "../../types/properties";
7
- import { withOutputSchema } from "../../schema-utils";
8
- import { AuthItemSchema } from "../../schemas/Auth";
9
- import type { Authentication, FunctionOptions } from "../../types/domain";
10
-
11
- // Pure Zod schema - no resolver metadata!
12
- export const FindFirstAuthenticationSchema = withOutputSchema(
13
- z
14
- .object({
15
- appKey: AppKeyPropertySchema.optional().describe(
16
- "App slug to get authentications for (e.g., 'slack', 'github')",
17
- ),
18
- search: z
19
- .string()
20
- .optional()
21
- .describe("Search term to filter authentications by title"),
22
- title: z
23
- .string()
24
- .optional()
25
- .describe("Filter authentications by exact title match"),
26
- account_id: z.string().optional().describe("Filter by account ID"),
27
- owner: z.string().optional().describe("Filter by owner"),
28
- limit: LimitPropertySchema.optional().describe(
29
- "Maximum number of items to return (1-200)",
30
- ),
31
- offset: OffsetPropertySchema.optional().describe(
32
- "Number of items to skip for pagination",
33
- ),
34
- })
35
- .describe("Find the first authentication matching the criteria"),
36
- AuthItemSchema,
37
- );
38
-
39
- // Type inferred from schema + function config
40
- export type FindFirstAuthenticationOptions = z.infer<
41
- typeof FindFirstAuthenticationSchema
42
- > &
43
- FunctionOptions;
44
-
45
- // SDK function interface - ready to be mixed into main SDK interface
46
- export interface FindFirstAuthenticationSdkFunction {
47
- findFirstAuthentication: (
48
- options?: Partial<FindFirstAuthenticationOptions>,
49
- ) => Promise<Authentication | null>;
50
- }
@@ -1,35 +0,0 @@
1
- import type { Authentication } from "../../types/domain";
2
- import { listAuthentications } from "../listAuthentications";
3
- import type { FindUniqueAuthenticationOptions } from "./schemas";
4
-
5
- /**
6
- * Find a unique authentication matching the given criteria
7
- *
8
- * This function can be used standalone without instantiating a full SDK,
9
- * which enables better tree-shaking in applications that only need this functionality.
10
- *
11
- * @param options - Filtering and API configuration options
12
- * @returns Promise<Authentication> - The unique matching authentication
13
- * @throws Error if no authentication found or multiple authentications found
14
- */
15
- export async function findUniqueAuthentication(
16
- options: Partial<FindUniqueAuthenticationOptions> = {},
17
- ): Promise<Authentication> {
18
- // Use listAuthentications with a reasonable limit to check for uniqueness
19
- const auths = await listAuthentications({
20
- ...options,
21
- limit: 2, // Get up to 2 to check for uniqueness
22
- });
23
-
24
- if (auths.length === 0) {
25
- throw new Error("No authentication found matching the specified criteria");
26
- }
27
-
28
- if (auths.length > 1) {
29
- throw new Error(
30
- "Multiple authentications found matching the specified criteria. Expected exactly one.",
31
- );
32
- }
33
-
34
- return auths[0];
35
- }
@@ -1,9 +0,0 @@
1
- import { findUniqueAuthentication } from "./index";
2
- import { FindUniqueAuthenticationSchema } from "./schemas";
3
-
4
- // Function registry info - imports both function and schema
5
- export const findUniqueAuthenticationInfo = {
6
- name: findUniqueAuthentication.name,
7
- inputSchema: FindUniqueAuthenticationSchema,
8
- implementation: findUniqueAuthentication,
9
- };
@@ -1,50 +0,0 @@
1
- import { z } from "zod";
2
- import {
3
- AppKeyPropertySchema,
4
- LimitPropertySchema,
5
- OffsetPropertySchema,
6
- } from "../../types/properties";
7
- import { withOutputSchema } from "../../schema-utils";
8
- import { AuthItemSchema } from "../../schemas/Auth";
9
- import type { Authentication, FunctionOptions } from "../../types/domain";
10
-
11
- // Pure Zod schema - no resolver metadata!
12
- export const FindUniqueAuthenticationSchema = withOutputSchema(
13
- z
14
- .object({
15
- appKey: AppKeyPropertySchema.optional().describe(
16
- "App slug to get authentications for (e.g., 'slack', 'github')",
17
- ),
18
- search: z
19
- .string()
20
- .optional()
21
- .describe("Search term to filter authentications by title"),
22
- title: z
23
- .string()
24
- .optional()
25
- .describe("Filter authentications by exact title match"),
26
- account_id: z.string().optional().describe("Filter by account ID"),
27
- owner: z.string().optional().describe("Filter by owner"),
28
- limit: LimitPropertySchema.optional().describe(
29
- "Maximum number of items to return (1-200)",
30
- ),
31
- offset: OffsetPropertySchema.optional().describe(
32
- "Number of items to skip for pagination",
33
- ),
34
- })
35
- .describe("Find a unique authentication matching the criteria"),
36
- AuthItemSchema,
37
- );
38
-
39
- // Type inferred from schema + function config
40
- export type FindUniqueAuthenticationOptions = z.infer<
41
- typeof FindUniqueAuthenticationSchema
42
- > &
43
- FunctionOptions;
44
-
45
- // SDK function interface - ready to be mixed into main SDK interface
46
- export interface FindUniqueAuthenticationSdkFunction {
47
- findUniqueAuthentication: (
48
- options?: Partial<FindUniqueAuthenticationOptions>,
49
- ) => Promise<Authentication>;
50
- }