@zapier/zapier-sdk 0.4.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (374) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/api/auth.d.ts +9 -0
  3. package/dist/api/auth.d.ts.map +1 -0
  4. package/dist/api/auth.js +25 -0
  5. package/dist/api/client.d.ts +9 -0
  6. package/dist/api/client.d.ts.map +1 -0
  7. package/dist/api/client.js +322 -0
  8. package/dist/api/debug.d.ts +13 -0
  9. package/dist/api/debug.d.ts.map +1 -0
  10. package/dist/api/debug.js +55 -0
  11. package/dist/api/index.d.ts +29 -0
  12. package/dist/api/index.d.ts.map +1 -0
  13. package/dist/api/index.js +41 -0
  14. package/dist/api/polling.d.ts +16 -0
  15. package/dist/api/polling.d.ts.map +1 -0
  16. package/dist/api/polling.js +45 -0
  17. package/dist/api/schemas.d.ts +2473 -0
  18. package/dist/api/schemas.d.ts.map +1 -0
  19. package/dist/api/schemas.js +355 -0
  20. package/dist/api/types.d.ts +75 -0
  21. package/dist/api/types.d.ts.map +1 -0
  22. package/dist/api/types.js +11 -0
  23. package/dist/auth.d.ts +34 -0
  24. package/dist/auth.d.ts.map +1 -0
  25. package/dist/auth.js +47 -0
  26. package/dist/constants.d.ts +10 -0
  27. package/dist/constants.d.ts.map +1 -0
  28. package/dist/constants.js +9 -0
  29. package/dist/index.cjs +2108 -1379
  30. package/dist/index.d.mts +2440 -620
  31. package/dist/index.d.ts +17 -892
  32. package/dist/index.d.ts.map +1 -0
  33. package/dist/index.js +20 -0
  34. package/dist/index.mjs +2093 -1362
  35. package/dist/plugins/api/index.d.ts +14 -0
  36. package/dist/plugins/api/index.d.ts.map +1 -0
  37. package/dist/plugins/api/index.js +21 -0
  38. package/dist/plugins/apps/index.d.ts +11 -0
  39. package/dist/plugins/apps/index.d.ts.map +1 -0
  40. package/dist/plugins/apps/index.js +91 -0
  41. package/dist/plugins/apps/types.d.ts +30 -0
  42. package/dist/plugins/apps/types.d.ts.map +1 -0
  43. package/dist/plugins/apps/types.js +2 -0
  44. package/dist/plugins/fetch/index.d.ts +21 -0
  45. package/dist/plugins/fetch/index.d.ts.map +1 -0
  46. package/dist/plugins/fetch/index.js +20 -0
  47. package/dist/plugins/findFirstAuthentication/index.d.ts +20 -0
  48. package/dist/plugins/findFirstAuthentication/index.d.ts.map +1 -0
  49. package/dist/plugins/findFirstAuthentication/index.js +24 -0
  50. package/dist/plugins/findFirstAuthentication/index.test.d.ts +2 -0
  51. package/dist/plugins/findFirstAuthentication/index.test.d.ts.map +1 -0
  52. package/dist/plugins/findFirstAuthentication/index.test.js +171 -0
  53. package/dist/plugins/findFirstAuthentication/schemas.d.ts +29 -0
  54. package/dist/plugins/findFirstAuthentication/schemas.d.ts.map +1 -0
  55. package/dist/plugins/findFirstAuthentication/schemas.js +18 -0
  56. package/dist/plugins/findUniqueAuthentication/index.d.ts +20 -0
  57. package/dist/plugins/findUniqueAuthentication/index.d.ts.map +1 -0
  58. package/dist/plugins/findUniqueAuthentication/index.js +31 -0
  59. package/dist/plugins/findUniqueAuthentication/index.test.d.ts +2 -0
  60. package/dist/plugins/findUniqueAuthentication/index.test.d.ts.map +1 -0
  61. package/dist/plugins/findUniqueAuthentication/index.test.js +152 -0
  62. package/dist/plugins/findUniqueAuthentication/schemas.d.ts +29 -0
  63. package/dist/plugins/findUniqueAuthentication/schemas.d.ts.map +1 -0
  64. package/dist/plugins/findUniqueAuthentication/schemas.js +18 -0
  65. package/dist/plugins/getAction/index.d.ts +23 -0
  66. package/dist/plugins/getAction/index.d.ts.map +1 -0
  67. package/dist/plugins/getAction/index.js +28 -0
  68. package/dist/plugins/getAction/index.test.d.ts +2 -0
  69. package/dist/plugins/getAction/index.test.d.ts.map +1 -0
  70. package/dist/plugins/getAction/index.test.js +186 -0
  71. package/dist/plugins/getAction/schemas.d.ts +23 -0
  72. package/dist/plugins/getAction/schemas.d.ts.map +1 -0
  73. package/dist/plugins/getAction/schemas.js +10 -0
  74. package/dist/plugins/getApp/index.d.ts +22 -0
  75. package/dist/plugins/getApp/index.d.ts.map +1 -0
  76. package/dist/plugins/getApp/index.js +39 -0
  77. package/dist/plugins/getApp/index.test.d.ts +2 -0
  78. package/dist/plugins/getApp/index.test.d.ts.map +1 -0
  79. package/dist/plugins/getApp/index.test.js +100 -0
  80. package/dist/plugins/getApp/schemas.d.ts +18 -0
  81. package/dist/plugins/getApp/schemas.d.ts.map +1 -0
  82. package/dist/plugins/getApp/schemas.js +10 -0
  83. package/dist/plugins/getAuthentication/index.d.ts +22 -0
  84. package/dist/plugins/getAuthentication/index.d.ts.map +1 -0
  85. package/dist/plugins/getAuthentication/index.js +41 -0
  86. package/dist/plugins/getAuthentication/index.test.d.ts +2 -0
  87. package/dist/plugins/getAuthentication/index.test.d.ts.map +1 -0
  88. package/dist/plugins/getAuthentication/index.test.js +205 -0
  89. package/dist/plugins/getAuthentication/schemas.d.ts +17 -0
  90. package/dist/plugins/getAuthentication/schemas.d.ts.map +1 -0
  91. package/dist/plugins/getAuthentication/schemas.js +11 -0
  92. package/dist/plugins/getProfile/index.d.ts +23 -0
  93. package/dist/plugins/getProfile/index.d.ts.map +1 -0
  94. package/dist/plugins/getProfile/index.js +29 -0
  95. package/dist/plugins/getProfile/schemas.d.ts +13 -0
  96. package/dist/plugins/getProfile/schemas.d.ts.map +1 -0
  97. package/dist/plugins/getProfile/schemas.js +5 -0
  98. package/dist/plugins/listActions/index.d.ts +28 -0
  99. package/dist/plugins/listActions/index.d.ts.map +1 -0
  100. package/dist/plugins/listActions/index.js +61 -0
  101. package/dist/plugins/listActions/index.test.d.ts +2 -0
  102. package/dist/plugins/listActions/index.test.d.ts.map +1 -0
  103. package/dist/plugins/listActions/index.test.js +467 -0
  104. package/dist/plugins/listActions/schemas.d.ts +29 -0
  105. package/dist/plugins/listActions/schemas.d.ts.map +1 -0
  106. package/dist/plugins/listActions/schemas.js +21 -0
  107. package/dist/plugins/listApps/index.d.ts +28 -0
  108. package/dist/plugins/listApps/index.d.ts.map +1 -0
  109. package/dist/plugins/listApps/index.js +62 -0
  110. package/dist/plugins/listApps/index.test.d.ts +2 -0
  111. package/dist/plugins/listApps/index.test.d.ts.map +1 -0
  112. package/dist/plugins/listApps/index.test.js +313 -0
  113. package/dist/plugins/listApps/schemas.d.ts +30 -0
  114. package/dist/plugins/listApps/schemas.d.ts.map +1 -0
  115. package/dist/plugins/listApps/schemas.js +23 -0
  116. package/dist/plugins/listAuthentications/index.d.ts +28 -0
  117. package/dist/plugins/listAuthentications/index.d.ts.map +1 -0
  118. package/dist/plugins/listAuthentications/index.js +77 -0
  119. package/dist/plugins/listAuthentications/index.test.d.ts +2 -0
  120. package/dist/plugins/listAuthentications/index.test.d.ts.map +1 -0
  121. package/dist/plugins/listAuthentications/index.test.js +564 -0
  122. package/dist/plugins/listAuthentications/schemas.d.ts +38 -0
  123. package/dist/plugins/listAuthentications/schemas.d.ts.map +1 -0
  124. package/dist/plugins/listAuthentications/schemas.js +28 -0
  125. package/dist/plugins/listInputFields/index.d.ts +28 -0
  126. package/dist/plugins/listInputFields/index.d.ts.map +1 -0
  127. package/dist/plugins/listInputFields/index.js +133 -0
  128. package/dist/plugins/listInputFields/index.test.d.ts +2 -0
  129. package/dist/plugins/listInputFields/index.test.d.ts.map +1 -0
  130. package/dist/plugins/listInputFields/index.test.js +325 -0
  131. package/dist/plugins/listInputFields/schemas.d.ts +38 -0
  132. package/dist/plugins/listInputFields/schemas.d.ts.map +1 -0
  133. package/dist/plugins/listInputFields/schemas.js +22 -0
  134. package/dist/plugins/registry/index.d.ts +11 -0
  135. package/dist/plugins/registry/index.d.ts.map +1 -0
  136. package/dist/plugins/registry/index.js +14 -0
  137. package/dist/plugins/request/index.d.ts +19 -0
  138. package/dist/plugins/request/index.d.ts.map +1 -0
  139. package/dist/plugins/request/index.js +62 -0
  140. package/dist/plugins/request/index.test.d.ts +2 -0
  141. package/dist/plugins/request/index.test.d.ts.map +1 -0
  142. package/dist/plugins/request/index.test.js +256 -0
  143. package/dist/plugins/request/schemas.d.ts +69 -0
  144. package/dist/plugins/request/schemas.d.ts.map +1 -0
  145. package/dist/plugins/request/schemas.js +42 -0
  146. package/dist/plugins/runAction/index.d.ts +28 -0
  147. package/dist/plugins/runAction/index.d.ts.map +1 -0
  148. package/dist/plugins/runAction/index.js +86 -0
  149. package/dist/plugins/runAction/index.test.d.ts +2 -0
  150. package/dist/plugins/runAction/index.test.d.ts.map +1 -0
  151. package/dist/plugins/runAction/index.test.js +320 -0
  152. package/dist/plugins/runAction/schemas.d.ts +37 -0
  153. package/dist/plugins/runAction/schemas.d.ts.map +1 -0
  154. package/dist/plugins/runAction/schemas.js +22 -0
  155. package/dist/resolvers/actionKey.d.ts +9 -0
  156. package/dist/resolvers/actionKey.d.ts.map +1 -0
  157. package/dist/resolvers/actionKey.js +19 -0
  158. package/dist/resolvers/actionType.d.ts +9 -0
  159. package/dist/resolvers/actionType.d.ts.map +1 -0
  160. package/dist/resolvers/actionType.js +22 -0
  161. package/dist/resolvers/appKey.d.ts +7 -0
  162. package/dist/resolvers/appKey.d.ts.map +1 -0
  163. package/dist/resolvers/appKey.js +5 -0
  164. package/dist/resolvers/authenticationId.d.ts +9 -0
  165. package/dist/resolvers/authenticationId.d.ts.map +1 -0
  166. package/dist/resolvers/authenticationId.js +33 -0
  167. package/dist/resolvers/index.d.ts +40 -0
  168. package/dist/resolvers/index.d.ts.map +1 -0
  169. package/dist/resolvers/index.js +91 -0
  170. package/dist/resolvers/inputs.d.ts +8 -0
  171. package/dist/resolvers/inputs.d.ts.map +1 -0
  172. package/dist/resolvers/inputs.js +14 -0
  173. package/dist/schemas/Action.d.ts +243 -0
  174. package/dist/schemas/Action.d.ts.map +1 -0
  175. package/dist/schemas/Action.js +34 -0
  176. package/dist/schemas/App.d.ts +26 -0
  177. package/dist/schemas/App.d.ts.map +1 -0
  178. package/dist/schemas/App.js +22 -0
  179. package/dist/schemas/Auth.d.ts +161 -0
  180. package/dist/schemas/Auth.d.ts.map +1 -0
  181. package/dist/schemas/Auth.js +41 -0
  182. package/dist/schemas/Field.d.ts +144 -0
  183. package/dist/schemas/Field.d.ts.map +1 -0
  184. package/dist/schemas/Field.js +105 -0
  185. package/dist/schemas/UserProfile.d.ts +163 -0
  186. package/dist/schemas/UserProfile.d.ts.map +1 -0
  187. package/dist/schemas/UserProfile.js +29 -0
  188. package/dist/sdk.d.ts +10 -0
  189. package/dist/sdk.d.ts.map +1 -0
  190. package/dist/sdk.js +94 -0
  191. package/dist/sdk.test.d.ts +2 -0
  192. package/dist/sdk.test.d.ts.map +1 -0
  193. package/dist/sdk.test.js +135 -0
  194. package/dist/types/domain.d.ts +36 -0
  195. package/dist/types/domain.d.ts.map +1 -0
  196. package/dist/types/domain.js +1 -0
  197. package/dist/types/domain.test.d.ts +2 -0
  198. package/dist/types/domain.test.d.ts.map +1 -0
  199. package/dist/types/domain.test.js +39 -0
  200. package/dist/types/errors.d.ts +143 -0
  201. package/dist/types/errors.d.ts.map +1 -0
  202. package/dist/types/errors.js +187 -0
  203. package/dist/types/events.d.ts +38 -0
  204. package/dist/types/events.d.ts.map +1 -0
  205. package/dist/types/events.js +7 -0
  206. package/dist/types/functions.d.ts +26 -0
  207. package/dist/types/functions.d.ts.map +1 -0
  208. package/dist/types/functions.js +4 -0
  209. package/dist/types/plugin.d.ts +61 -0
  210. package/dist/types/plugin.d.ts.map +1 -0
  211. package/dist/types/plugin.js +9 -0
  212. package/dist/types/properties.d.ts +22 -0
  213. package/dist/types/properties.d.ts.map +1 -0
  214. package/dist/types/properties.js +50 -0
  215. package/dist/types/sdk.d.ts +43 -0
  216. package/dist/types/sdk.d.ts.map +1 -0
  217. package/dist/types/sdk.js +4 -0
  218. package/dist/utils/array-utils.d.ts +31 -0
  219. package/dist/utils/array-utils.d.ts.map +1 -0
  220. package/dist/utils/array-utils.js +36 -0
  221. package/dist/utils/array-utils.test.d.ts +2 -0
  222. package/dist/utils/array-utils.test.d.ts.map +1 -0
  223. package/dist/utils/array-utils.test.js +107 -0
  224. package/dist/utils/domain-utils.d.ts +78 -0
  225. package/dist/utils/domain-utils.d.ts.map +1 -0
  226. package/dist/utils/domain-utils.js +218 -0
  227. package/dist/utils/domain-utils.test.d.ts +2 -0
  228. package/dist/utils/domain-utils.test.d.ts.map +1 -0
  229. package/dist/utils/domain-utils.test.js +192 -0
  230. package/dist/utils/function-utils.d.ts +45 -0
  231. package/dist/utils/function-utils.d.ts.map +1 -0
  232. package/dist/utils/function-utils.js +158 -0
  233. package/dist/utils/function-utils.test.d.ts +2 -0
  234. package/dist/utils/function-utils.test.d.ts.map +1 -0
  235. package/dist/utils/function-utils.test.js +110 -0
  236. package/dist/utils/pagination-utils.d.ts +37 -0
  237. package/dist/utils/pagination-utils.d.ts.map +1 -0
  238. package/dist/utils/pagination-utils.js +165 -0
  239. package/dist/utils/pagination-utils.test.d.ts +17 -0
  240. package/dist/utils/pagination-utils.test.d.ts.map +1 -0
  241. package/dist/utils/pagination-utils.test.js +461 -0
  242. package/dist/utils/schema-utils.d.ts +45 -0
  243. package/dist/utils/schema-utils.d.ts.map +1 -0
  244. package/dist/utils/schema-utils.js +65 -0
  245. package/dist/utils/validation.d.ts +4 -0
  246. package/dist/utils/validation.d.ts.map +1 -0
  247. package/dist/utils/validation.js +30 -0
  248. package/dist/utils/validation.test.d.ts +2 -0
  249. package/dist/utils/validation.test.d.ts.map +1 -0
  250. package/dist/utils/validation.test.js +43 -0
  251. package/package.json +12 -3
  252. package/src/api/client.ts +394 -171
  253. package/src/api/debug.ts +10 -1
  254. package/src/api/index.ts +0 -2
  255. package/src/api/polling.ts +28 -7
  256. package/src/api/schemas.ts +387 -0
  257. package/src/api/types.ts +72 -136
  258. package/src/constants.ts +10 -0
  259. package/src/index.ts +40 -19
  260. package/src/plugins/api/index.ts +47 -0
  261. package/src/plugins/apps/index.ts +25 -19
  262. package/src/plugins/apps/types.ts +7 -11
  263. package/src/plugins/fetch/index.ts +48 -40
  264. package/src/plugins/findFirstAuthentication/index.test.ts +206 -0
  265. package/src/plugins/findFirstAuthentication/index.ts +55 -0
  266. package/src/plugins/findFirstAuthentication/schemas.ts +41 -0
  267. package/src/plugins/findUniqueAuthentication/index.test.ts +197 -0
  268. package/src/plugins/findUniqueAuthentication/index.ts +72 -0
  269. package/src/plugins/findUniqueAuthentication/schemas.ts +42 -0
  270. package/src/plugins/getAction/index.test.ts +239 -0
  271. package/src/plugins/getAction/index.ts +57 -0
  272. package/src/plugins/getAction/schemas.ts +33 -0
  273. package/src/plugins/getApp/index.test.ts +127 -0
  274. package/src/plugins/getApp/index.ts +66 -0
  275. package/src/plugins/getApp/schemas.ts +38 -0
  276. package/src/plugins/getAuthentication/index.test.ts +284 -0
  277. package/src/plugins/getAuthentication/index.ts +86 -0
  278. package/src/plugins/getAuthentication/schemas.ts +31 -0
  279. package/src/plugins/getProfile/index.ts +55 -0
  280. package/src/plugins/getProfile/schemas.ts +26 -0
  281. package/src/plugins/listActions/index.test.ts +582 -0
  282. package/src/plugins/listActions/index.ts +115 -0
  283. package/src/plugins/listActions/schemas.ts +54 -0
  284. package/src/plugins/listApps/index.test.ts +357 -0
  285. package/src/plugins/listApps/index.ts +121 -0
  286. package/src/plugins/listApps/schemas.ts +49 -0
  287. package/src/plugins/listAuthentications/index.test.ts +709 -0
  288. package/src/plugins/listAuthentications/index.ts +136 -0
  289. package/src/plugins/listAuthentications/schemas.ts +60 -0
  290. package/src/plugins/listInputFields/index.test.ts +408 -0
  291. package/src/plugins/listInputFields/index.ts +204 -0
  292. package/src/plugins/listInputFields/schemas.ts +56 -0
  293. package/src/plugins/registry/index.ts +30 -0
  294. package/src/plugins/request/index.test.ts +329 -0
  295. package/src/plugins/request/index.ts +103 -0
  296. package/src/{functions → plugins}/request/schemas.ts +20 -9
  297. package/src/plugins/runAction/index.test.ts +387 -0
  298. package/src/plugins/runAction/index.ts +176 -0
  299. package/src/plugins/runAction/schemas.ts +53 -0
  300. package/src/resolvers/actionKey.ts +6 -4
  301. package/src/resolvers/actionType.ts +7 -2
  302. package/src/resolvers/appKey.ts +1 -1
  303. package/src/resolvers/authenticationId.ts +12 -3
  304. package/src/resolvers/inputs.ts +3 -1
  305. package/src/schemas/Action.ts +18 -12
  306. package/src/schemas/App.ts +11 -19
  307. package/src/schemas/Auth.ts +18 -13
  308. package/src/schemas/Field.ts +106 -11
  309. package/src/schemas/UserProfile.ts +43 -0
  310. package/src/sdk.test.ts +212 -0
  311. package/src/sdk.ts +132 -102
  312. package/src/types/domain.test.ts +50 -0
  313. package/src/types/domain.ts +43 -75
  314. package/src/types/errors.ts +275 -0
  315. package/src/types/functions.ts +27 -0
  316. package/src/types/optional-zapier-sdk-cli-login.d.ts +37 -0
  317. package/src/types/plugin.ts +105 -0
  318. package/src/types/properties.ts +4 -3
  319. package/src/types/sdk.ts +70 -48
  320. package/src/utils/array-utils.test.ts +131 -0
  321. package/src/utils/array-utils.ts +41 -0
  322. package/src/utils/domain-utils.test.ts +239 -0
  323. package/src/utils/domain-utils.ts +283 -0
  324. package/src/utils/function-utils.test.ts +141 -0
  325. package/src/utils/function-utils.ts +245 -0
  326. package/src/utils/pagination-utils.test.ts +620 -0
  327. package/src/utils/pagination-utils.ts +242 -0
  328. package/src/utils/validation.test.ts +50 -0
  329. package/src/utils/validation.ts +44 -0
  330. package/tsconfig.build.json +16 -2
  331. package/tsconfig.json +3 -1
  332. package/tsconfig.tsbuildinfo +1 -0
  333. package/tsup.config.ts +2 -0
  334. package/src/functions/bundleCode/index.ts +0 -78
  335. package/src/functions/bundleCode/info.ts +0 -9
  336. package/src/functions/bundleCode/schemas.ts +0 -30
  337. package/src/functions/findFirstAuthentication/index.ts +0 -24
  338. package/src/functions/findFirstAuthentication/info.ts +0 -9
  339. package/src/functions/findFirstAuthentication/schemas.ts +0 -50
  340. package/src/functions/findUniqueAuthentication/index.ts +0 -35
  341. package/src/functions/findUniqueAuthentication/info.ts +0 -9
  342. package/src/functions/findUniqueAuthentication/schemas.ts +0 -50
  343. package/src/functions/generateTypes/index.ts +0 -363
  344. package/src/functions/generateTypes/info.ts +0 -9
  345. package/src/functions/generateTypes/schemas.ts +0 -31
  346. package/src/functions/getAction/index.ts +0 -33
  347. package/src/functions/getAction/info.ts +0 -9
  348. package/src/functions/getAction/schemas.ts +0 -25
  349. package/src/functions/getApp/index.ts +0 -41
  350. package/src/functions/getApp/info.ts +0 -9
  351. package/src/functions/getApp/schemas.ts +0 -20
  352. package/src/functions/getAuthentication/index.ts +0 -50
  353. package/src/functions/getAuthentication/info.ts +0 -9
  354. package/src/functions/getAuthentication/schemas.ts +0 -29
  355. package/src/functions/listActions/index.ts +0 -149
  356. package/src/functions/listActions/info.ts +0 -9
  357. package/src/functions/listActions/schemas.ts +0 -30
  358. package/src/functions/listApps/index.ts +0 -60
  359. package/src/functions/listApps/info.ts +0 -9
  360. package/src/functions/listApps/schemas.ts +0 -32
  361. package/src/functions/listAuthentications/index.ts +0 -162
  362. package/src/functions/listAuthentications/info.ts +0 -9
  363. package/src/functions/listAuthentications/schemas.ts +0 -50
  364. package/src/functions/listFields/index.ts +0 -86
  365. package/src/functions/listFields/info.ts +0 -9
  366. package/src/functions/listFields/schemas.ts +0 -36
  367. package/src/functions/request/index.ts +0 -150
  368. package/src/functions/request/info.ts +0 -11
  369. package/src/functions/runAction/index.ts +0 -127
  370. package/src/functions/runAction/info.ts +0 -9
  371. package/src/functions/runAction/schemas.ts +0 -34
  372. package/src/plugins/apps/info.ts +0 -12
  373. package/src/plugins/fetch/types.ts +0 -2
  374. /package/src/{schema-utils.ts → utils/schema-utils.ts} +0 -0
@@ -0,0 +1,133 @@
1
+ import { ListInputFieldsSchema, } from "./schemas";
2
+ import { ZapierConfigurationError, ZapierApiError } from "../../types/errors";
3
+ import { createPaginatedFunction } from "../../utils/function-utils";
4
+ // Enums for input field transformation
5
+ var InputFieldType;
6
+ (function (InputFieldType) {
7
+ InputFieldType["STRING"] = "STRING";
8
+ InputFieldType["NUMBER"] = "NUMBER";
9
+ InputFieldType["INTEGER"] = "INTEGER";
10
+ InputFieldType["BOOLEAN"] = "BOOLEAN";
11
+ InputFieldType["OBJECT"] = "OBJECT";
12
+ InputFieldType["ARRAY"] = "ARRAY";
13
+ })(InputFieldType || (InputFieldType = {}));
14
+ var InputFieldFormat;
15
+ (function (InputFieldFormat) {
16
+ InputFieldFormat["DATETIME"] = "DATETIME";
17
+ InputFieldFormat["SELECT"] = "SELECT";
18
+ InputFieldFormat["MULTILINE"] = "MULTILINE";
19
+ InputFieldFormat["FILE"] = "FILE";
20
+ InputFieldFormat["PASSWORD"] = "PASSWORD";
21
+ InputFieldFormat["CODE"] = "CODE";
22
+ })(InputFieldFormat || (InputFieldFormat = {}));
23
+ var ItemsType;
24
+ (function (ItemsType) {
25
+ ItemsType["STRING"] = "STRING";
26
+ ItemsType["NUMBER"] = "NUMBER";
27
+ ItemsType["INTEGER"] = "INTEGER";
28
+ ItemsType["BOOLEAN"] = "BOOLEAN";
29
+ ItemsType["OBJECT"] = "OBJECT";
30
+ })(ItemsType || (ItemsType = {}));
31
+ // Transformation helper functions
32
+ function getInputFieldTypeFromNeed(need) {
33
+ if (need.list) {
34
+ return InputFieldType.ARRAY;
35
+ }
36
+ const typeMap = {
37
+ string: InputFieldType.STRING,
38
+ decimal: InputFieldType.NUMBER,
39
+ integer: InputFieldType.INTEGER,
40
+ boolean: InputFieldType.BOOLEAN,
41
+ dict: InputFieldType.OBJECT,
42
+ };
43
+ return typeMap[need.type || ""] || InputFieldType.STRING;
44
+ }
45
+ function getInputFieldFormatFromNeed(need) {
46
+ if (need.prefill || need.choices) {
47
+ return InputFieldFormat.SELECT;
48
+ }
49
+ const formatMap = {
50
+ text: InputFieldFormat.MULTILINE,
51
+ datetime: InputFieldFormat.DATETIME,
52
+ file: InputFieldFormat.FILE,
53
+ password: InputFieldFormat.PASSWORD,
54
+ code: InputFieldFormat.CODE,
55
+ };
56
+ return formatMap[need.type || ""];
57
+ }
58
+ function getItemsTypeFromNeed(need) {
59
+ if (!need.list) {
60
+ return undefined;
61
+ }
62
+ const typeMap = {
63
+ string: ItemsType.STRING,
64
+ decimal: ItemsType.NUMBER,
65
+ integer: ItemsType.INTEGER,
66
+ boolean: ItemsType.BOOLEAN,
67
+ dict: ItemsType.OBJECT,
68
+ };
69
+ return typeMap[need.type || ""] || ItemsType.STRING;
70
+ }
71
+ // Transform Need to InputFieldItem
72
+ function transformNeedToInputFieldItem(need) {
73
+ const itemsType = getItemsTypeFromNeed(need);
74
+ return {
75
+ ...need, // Pass through all original Need fields
76
+ id: need.key,
77
+ default_value: need.default || "",
78
+ depends_on: need.depends_on || [],
79
+ description: need.help_text || "",
80
+ invalidates_input_fields: need.alters_custom_fields || false,
81
+ is_required: need.required || false,
82
+ placeholder: need.placeholder || "",
83
+ title: need.label || "",
84
+ value_type: getInputFieldTypeFromNeed(need),
85
+ format: getInputFieldFormatFromNeed(need),
86
+ items: itemsType ? { type: itemsType } : undefined,
87
+ };
88
+ }
89
+ export const listInputFieldsPlugin = ({ sdk, context }) => {
90
+ const listInputFields = createPaginatedFunction(async function listInputFieldsPage(options) {
91
+ // Note: This function ignores pageSize and cursor since it's not actually paginated internally
92
+ const { api } = context;
93
+ // Extract parameters
94
+ const { appKey, actionKey, actionType, authenticationId, inputs } = options;
95
+ // Use the getApp plugin
96
+ const appData = await sdk.getApp({ appKey });
97
+ const selectedApi = appData.data.current_implementation_id;
98
+ if (!selectedApi) {
99
+ throw new ZapierConfigurationError("No current_implementation_id found for app", { configType: "current_implementation_id" });
100
+ }
101
+ // Build needs request
102
+ const needsRequest = {
103
+ selected_api: selectedApi,
104
+ action: actionKey,
105
+ type_of: actionType,
106
+ params: inputs || {},
107
+ };
108
+ // Only include authentication_id if it's not null (skip authentication when null)
109
+ if (authenticationId !== null) {
110
+ needsRequest.authentication_id = authenticationId;
111
+ }
112
+ const needsData = await api.post("/api/v4/implementations/needs/", needsRequest);
113
+ if (!needsData.success) {
114
+ throw new ZapierApiError(`Failed to get action fields: ${needsData.errors?.join(", ") || "Unknown error"}`);
115
+ }
116
+ // Transform Need objects to InputFieldItem objects
117
+ const inputFields = (needsData.needs || []).map(transformNeedToInputFieldItem);
118
+ return {
119
+ data: inputFields,
120
+ nextCursor: undefined, // No pagination needed since we return all input fields
121
+ };
122
+ }, ListInputFieldsSchema);
123
+ return {
124
+ listInputFields,
125
+ context: {
126
+ meta: {
127
+ listInputFields: {
128
+ inputSchema: ListInputFieldsSchema,
129
+ },
130
+ },
131
+ },
132
+ };
133
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../../src/plugins/listInputFields/index.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,325 @@
1
+ import { describe, it, expect, vi, beforeEach } from "vitest";
2
+ import { ZapierValidationError, ZapierConfigurationError, ZapierApiError, } from "../../types/errors";
3
+ import { listInputFieldsPlugin } from "./index";
4
+ import { createSdk } from "../../sdk";
5
+ const mockNeeds = [
6
+ {
7
+ key: "message",
8
+ label: "Message",
9
+ help_text: "The message to send",
10
+ required: true,
11
+ type: "string",
12
+ placeholder: "Enter your message",
13
+ default: "",
14
+ },
15
+ {
16
+ key: "channel",
17
+ label: "Channel",
18
+ help_text: "The channel to send to",
19
+ required: true,
20
+ type: "string",
21
+ choices: [
22
+ { value: "#general", label: "General", sample: "#general" },
23
+ { value: "#random", label: "Random", sample: "#random" },
24
+ ],
25
+ },
26
+ {
27
+ key: "tags",
28
+ label: "Tags",
29
+ help_text: "List of tags",
30
+ type: "string",
31
+ list: true,
32
+ },
33
+ ];
34
+ const mockNeedsResponse = {
35
+ success: true,
36
+ needs: mockNeeds,
37
+ };
38
+ describe("listInputFields plugin", () => {
39
+ let mockApiClient;
40
+ let mockGetApp;
41
+ beforeEach(() => {
42
+ vi.clearAllMocks();
43
+ mockApiClient = {
44
+ post: vi.fn().mockResolvedValue(mockNeedsResponse),
45
+ };
46
+ mockGetApp = vi.fn().mockResolvedValue({
47
+ data: { current_implementation_id: "SlackCLIAPI@1.21.1" },
48
+ });
49
+ });
50
+ function createTestSdk() {
51
+ return createSdk({ getApp: mockGetApp }, { api: mockApiClient, meta: {} }).addPlugin(listInputFieldsPlugin);
52
+ }
53
+ describe("schema validation", () => {
54
+ it("should throw validation error for missing required fields", () => {
55
+ const sdk = createTestSdk();
56
+ expect(() => {
57
+ sdk.listInputFields({
58
+ // Missing required fields
59
+ });
60
+ }).toThrow(ZapierValidationError);
61
+ });
62
+ it("should throw validation error for invalid field types", () => {
63
+ const sdk = createTestSdk();
64
+ expect(() => {
65
+ sdk.listInputFields({
66
+ appKey: 123,
67
+ actionType: "write",
68
+ actionKey: "send_message",
69
+ });
70
+ }).toThrow(ZapierValidationError);
71
+ });
72
+ it("should pass validation with all required fields", async () => {
73
+ const sdk = createTestSdk();
74
+ const result = await sdk.listInputFields({
75
+ appKey: "slack",
76
+ actionType: "write",
77
+ actionKey: "send_message",
78
+ });
79
+ expect(result.data).toBeDefined();
80
+ });
81
+ it("should pass validation with optional fields", async () => {
82
+ const sdk = createTestSdk();
83
+ const result = await sdk.listInputFields({
84
+ appKey: "slack",
85
+ actionType: "write",
86
+ actionKey: "send_message",
87
+ authenticationId: 123,
88
+ inputs: { channel: "#general" },
89
+ });
90
+ expect(result.data).toBeDefined();
91
+ });
92
+ });
93
+ describe("API integration", () => {
94
+ it("should call the correct API endpoint", async () => {
95
+ const sdk = createTestSdk();
96
+ await sdk.listInputFields({
97
+ appKey: "slack",
98
+ actionType: "write",
99
+ actionKey: "send_message",
100
+ });
101
+ expect(mockApiClient.post).toHaveBeenCalledWith("/api/v4/implementations/needs/", {
102
+ selected_api: "SlackCLIAPI@1.21.1",
103
+ action: "send_message",
104
+ type_of: "write",
105
+ params: {},
106
+ });
107
+ });
108
+ it("should include authentication_id when provided", async () => {
109
+ const sdk = createTestSdk();
110
+ await sdk.listInputFields({
111
+ appKey: "slack",
112
+ actionType: "write",
113
+ actionKey: "send_message",
114
+ authenticationId: 123,
115
+ });
116
+ expect(mockApiClient.post).toHaveBeenCalledWith("/api/v4/implementations/needs/", {
117
+ selected_api: "SlackCLIAPI@1.21.1",
118
+ action: "send_message",
119
+ type_of: "write",
120
+ params: {},
121
+ authentication_id: 123,
122
+ });
123
+ });
124
+ it("should exclude authentication_id when null", async () => {
125
+ const sdk = createTestSdk();
126
+ await sdk.listInputFields({
127
+ appKey: "slack",
128
+ actionType: "write",
129
+ actionKey: "send_message",
130
+ authenticationId: null,
131
+ });
132
+ expect(mockApiClient.post).toHaveBeenCalledWith("/api/v4/implementations/needs/", {
133
+ selected_api: "SlackCLIAPI@1.21.1",
134
+ action: "send_message",
135
+ type_of: "write",
136
+ params: {},
137
+ // No authentication_id
138
+ });
139
+ });
140
+ it("should include inputs when provided", async () => {
141
+ const sdk = createTestSdk();
142
+ const inputs = { channel: "#general", message: "test" };
143
+ await sdk.listInputFields({
144
+ appKey: "slack",
145
+ actionType: "write",
146
+ actionKey: "send_message",
147
+ inputs,
148
+ });
149
+ expect(mockApiClient.post).toHaveBeenCalledWith("/api/v4/implementations/needs/", {
150
+ selected_api: "SlackCLIAPI@1.21.1",
151
+ action: "send_message",
152
+ type_of: "write",
153
+ params: inputs,
154
+ });
155
+ });
156
+ });
157
+ describe("data transformation", () => {
158
+ it("should transform needs to input field items correctly", async () => {
159
+ const sdk = createTestSdk();
160
+ const result = await sdk.listInputFields({
161
+ appKey: "slack",
162
+ actionType: "write",
163
+ actionKey: "send_message",
164
+ });
165
+ expect(result.data).toHaveLength(3);
166
+ // Check message field transformation
167
+ expect(result.data[0]).toEqual(expect.objectContaining({
168
+ id: "message",
169
+ title: "Message",
170
+ description: "The message to send",
171
+ is_required: true,
172
+ value_type: "STRING",
173
+ placeholder: "Enter your message",
174
+ default_value: "",
175
+ }));
176
+ // Check channel field with choices (SELECT format)
177
+ expect(result.data[1]).toEqual(expect.objectContaining({
178
+ id: "channel",
179
+ title: "Channel",
180
+ description: "The channel to send to",
181
+ is_required: true,
182
+ value_type: "STRING",
183
+ format: "SELECT",
184
+ choices: [
185
+ { value: "#general", label: "General", sample: "#general" },
186
+ { value: "#random", label: "Random", sample: "#random" },
187
+ ],
188
+ }));
189
+ // Check array field
190
+ expect(result.data[2]).toEqual(expect.objectContaining({
191
+ id: "tags",
192
+ title: "Tags",
193
+ description: "List of tags",
194
+ value_type: "ARRAY",
195
+ items: { type: "STRING" },
196
+ }));
197
+ });
198
+ it("should handle different field types correctly", async () => {
199
+ const complexNeeds = [
200
+ {
201
+ key: "count",
202
+ type: "integer",
203
+ label: "Count",
204
+ required: false,
205
+ },
206
+ {
207
+ key: "price",
208
+ type: "decimal",
209
+ label: "Price",
210
+ },
211
+ {
212
+ key: "enabled",
213
+ type: "boolean",
214
+ label: "Enabled",
215
+ },
216
+ {
217
+ key: "config",
218
+ type: "dict",
219
+ label: "Configuration",
220
+ },
221
+ {
222
+ key: "description",
223
+ type: "text",
224
+ label: "Description",
225
+ },
226
+ ];
227
+ mockApiClient.post = vi.fn().mockResolvedValue({
228
+ success: true,
229
+ needs: complexNeeds,
230
+ });
231
+ const sdk = createTestSdk();
232
+ const result = await sdk.listInputFields({
233
+ appKey: "slack",
234
+ actionType: "write",
235
+ actionKey: "send_message",
236
+ });
237
+ expect(result.data[0].value_type).toBe("INTEGER");
238
+ expect(result.data[1].value_type).toBe("NUMBER");
239
+ expect(result.data[2].value_type).toBe("BOOLEAN");
240
+ expect(result.data[3].value_type).toBe("OBJECT");
241
+ expect(result.data[4].value_type).toBe("STRING");
242
+ expect(result.data[4].format).toBe("MULTILINE");
243
+ });
244
+ });
245
+ describe("error handling", () => {
246
+ it("should throw ZapierConfigurationError when app has no current_implementation_id", async () => {
247
+ mockGetApp.mockResolvedValue({
248
+ data: { current_implementation_id: undefined },
249
+ });
250
+ const sdk = createTestSdk();
251
+ await expect(sdk.listInputFields({
252
+ appKey: "invalid",
253
+ actionType: "write",
254
+ actionKey: "send_message",
255
+ })).rejects.toThrow(ZapierConfigurationError);
256
+ });
257
+ it("should throw ZapierApiError when API response indicates failure", async () => {
258
+ mockApiClient.post = vi.fn().mockResolvedValue({
259
+ success: false,
260
+ errors: ["Invalid action", "Missing parameter"],
261
+ });
262
+ const sdk = createTestSdk();
263
+ await expect(sdk.listInputFields({
264
+ appKey: "slack",
265
+ actionType: "write",
266
+ actionKey: "invalid_action",
267
+ })).rejects.toThrow(ZapierApiError);
268
+ await expect(sdk.listInputFields({
269
+ appKey: "slack",
270
+ actionType: "write",
271
+ actionKey: "invalid_action",
272
+ })).rejects.toThrow("Failed to get action fields: Invalid action, Missing parameter");
273
+ });
274
+ it("should handle API errors gracefully", async () => {
275
+ mockApiClient.post = vi
276
+ .fn()
277
+ .mockRejectedValue(new Error("Network error"));
278
+ const sdk = createTestSdk();
279
+ await expect(sdk.listInputFields({
280
+ appKey: "slack",
281
+ actionType: "write",
282
+ actionKey: "send_message",
283
+ })).rejects.toThrow("Network error");
284
+ });
285
+ });
286
+ describe("context and metadata", () => {
287
+ it("should provide context with meta information", () => {
288
+ const sdk = createTestSdk();
289
+ const context = sdk.getContext();
290
+ expect(context.meta.listInputFields).toBeDefined();
291
+ expect(context.meta.listInputFields.inputSchema).toBeDefined();
292
+ });
293
+ });
294
+ describe("pagination", () => {
295
+ it("should support async iteration over pages", async () => {
296
+ const sdk = createTestSdk();
297
+ const listInputFieldsResult = sdk.listInputFields({
298
+ appKey: "slack",
299
+ actionType: "write",
300
+ actionKey: "send_message",
301
+ });
302
+ const pages = [];
303
+ for await (const page of listInputFieldsResult) {
304
+ pages.push(page);
305
+ break; // Just get first page for testing
306
+ }
307
+ expect(pages).toHaveLength(1);
308
+ expect(pages[0].data).toHaveLength(3);
309
+ });
310
+ it("should support async iteration over individual items", async () => {
311
+ const sdk = createTestSdk();
312
+ const listInputFieldsResult = sdk.listInputFields({
313
+ appKey: "slack",
314
+ actionType: "write",
315
+ actionKey: "send_message",
316
+ });
317
+ const items = [];
318
+ for await (const item of listInputFieldsResult.items()) {
319
+ items.push(item);
320
+ }
321
+ expect(items).toHaveLength(3);
322
+ expect(items[0].id).toBe("message");
323
+ });
324
+ });
325
+ });
@@ -0,0 +1,38 @@
1
+ import { z } from "zod";
2
+ import type { InputFieldItem } from "../../types/domain";
3
+ import type { PaginatedSdkFunction } from "../../types/functions";
4
+ export declare const ListInputFieldsSchema: z.ZodObject<{
5
+ appKey: z.ZodString;
6
+ actionType: z.ZodEnum<["read", "read_bulk", "write", "run", "search", "search_or_write", "search_and_write", "filter"]>;
7
+ actionKey: z.ZodString;
8
+ authenticationId: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
9
+ inputs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
10
+ pageSize: z.ZodOptional<z.ZodNumber>;
11
+ maxItems: z.ZodOptional<z.ZodNumber>;
12
+ }, "strip", z.ZodTypeAny, {
13
+ appKey: string;
14
+ actionType: "filter" | "read" | "read_bulk" | "run" | "search" | "search_and_write" | "search_or_write" | "write";
15
+ actionKey: string;
16
+ authenticationId?: number | null | undefined;
17
+ maxItems?: number | undefined;
18
+ pageSize?: number | undefined;
19
+ inputs?: Record<string, any> | undefined;
20
+ }, {
21
+ appKey: string;
22
+ actionType: "filter" | "read" | "read_bulk" | "run" | "search" | "search_and_write" | "search_or_write" | "write";
23
+ actionKey: string;
24
+ authenticationId?: number | null | undefined;
25
+ maxItems?: number | undefined;
26
+ pageSize?: number | undefined;
27
+ inputs?: Record<string, any> | undefined;
28
+ }>;
29
+ export type ListInputFieldsOptions = z.infer<typeof ListInputFieldsSchema>;
30
+ export type ListInputFieldsError = import("../../types/errors").ZapierConfigurationError | import("../../types/errors").ZapierApiError | import("../../types/errors").ZapierAuthenticationError | import("../../types/errors").ZapierAppNotFoundError | import("../../types/errors").ZapierValidationError | import("../../types/errors").ZapierUnknownError;
31
+ export interface ListInputFieldsPage {
32
+ data: InputFieldItem[];
33
+ nextCursor?: string;
34
+ }
35
+ export interface ListInputFieldsSdkFunction {
36
+ listInputFields: PaginatedSdkFunction<ListInputFieldsOptions, InputFieldItem>;
37
+ }
38
+ //# sourceMappingURL=schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/plugins/listInputFields/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAQxB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAGlE,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;EAoBgC,CAAC;AAGnE,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAG3E,MAAM,MAAM,oBAAoB,GAC5B,OAAO,oBAAoB,EAAE,wBAAwB,GACrD,OAAO,oBAAoB,EAAE,cAAc,GAC3C,OAAO,oBAAoB,EAAE,yBAAyB,GACtD,OAAO,oBAAoB,EAAE,sBAAsB,GACnD,OAAO,oBAAoB,EAAE,qBAAqB,GAClD,OAAO,oBAAoB,EAAE,kBAAkB,CAAC;AAGpD,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,cAAc,EAAE,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAGD,MAAM,WAAW,0BAA0B;IACzC,eAAe,EAAE,oBAAoB,CAAC,sBAAsB,EAAE,cAAc,CAAC,CAAC;CAC/E"}
@@ -0,0 +1,22 @@
1
+ import { z } from "zod";
2
+ import { AppKeyPropertySchema, ActionTypePropertySchema, ActionKeyPropertySchema, AuthenticationIdPropertySchema, InputsPropertySchema, } from "../../types/properties";
3
+ // Pure Zod schema - no resolver metadata!
4
+ export const ListInputFieldsSchema = z
5
+ .object({
6
+ appKey: AppKeyPropertySchema,
7
+ actionType: ActionTypePropertySchema,
8
+ actionKey: ActionKeyPropertySchema,
9
+ authenticationId: AuthenticationIdPropertySchema.nullable().optional(),
10
+ inputs: InputsPropertySchema.optional().describe("Current input values that may affect available fields"),
11
+ pageSize: z
12
+ .number()
13
+ .min(1)
14
+ .optional()
15
+ .describe("Number of input fields per page"),
16
+ maxItems: z
17
+ .number()
18
+ .min(1)
19
+ .optional()
20
+ .describe("Maximum total items to return across all pages"),
21
+ })
22
+ .describe("Get the input fields required for a specific action");
@@ -0,0 +1,11 @@
1
+ import type { Plugin } from "../../types/plugin";
2
+ import { FunctionRegistryEntry } from "../../types/sdk";
3
+ export interface RegisterPluginFunctionOptions {
4
+ }
5
+ export interface RegistryPluginProvides {
6
+ __registry: FunctionRegistryEntry[];
7
+ }
8
+ export declare const registryPlugin: Plugin<{}, // accepts any SDK shape
9
+ {}, // requires no context
10
+ RegistryPluginProvides>;
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/registry/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAExD,MAAM,WAAW,6BAA6B;CAAG;AAGjD,MAAM,WAAW,sBAAsB;IACrC,UAAU,EAAE,qBAAqB,EAAE,CAAC;CACrC;AAGD,eAAO,MAAM,cAAc,EAAE,MAAM,CACjC,EAAE,EAAE,wBAAwB;AAC5B,EAAE,EAAE,sBAAsB;AAC1B,sBAAsB,CAevB,CAAC"}
@@ -0,0 +1,14 @@
1
+ // Registry plugin requires no context but collects SDK metadata
2
+ export const registryPlugin = ({ sdk, context }) => {
3
+ const metaKeys = Object.keys(context.meta || {});
4
+ const registryEntries = metaKeys.map((key) => {
5
+ return {
6
+ ...context.meta[key],
7
+ name: key,
8
+ implementation: sdk[key],
9
+ };
10
+ });
11
+ return {
12
+ __registry: registryEntries,
13
+ };
14
+ };
@@ -0,0 +1,19 @@
1
+ import type { Plugin } from "../../types/plugin";
2
+ import type { ApiClient } from "../../api";
3
+ import { RelayRequestSchema, type RelayRequestOptions } from "./schemas";
4
+ export interface RequestPluginProvides {
5
+ request: (options: RelayRequestOptions) => Promise<Response>;
6
+ context: {
7
+ meta: {
8
+ request: {
9
+ inputSchema: typeof RelayRequestSchema;
10
+ };
11
+ };
12
+ };
13
+ }
14
+ export declare const requestPlugin: Plugin<{}, // no SDK dependencies
15
+ {
16
+ api: ApiClient;
17
+ }, // requires api in context
18
+ RequestPluginProvides>;
19
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/request/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,KAAK,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAmBzE,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,CAAC,OAAO,EAAE,mBAAmB,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC7D,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,OAAO,EAAE;gBACP,WAAW,EAAE,OAAO,kBAAkB,CAAC;aACxC,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,aAAa,EAAE,MAAM,CAChC,EAAE,EAAE,sBAAsB;AAC1B;IAAE,GAAG,EAAE,SAAS,CAAA;CAAE,EAAE,0BAA0B;AAC9C,qBAAqB,CAmEtB,CAAC"}
@@ -0,0 +1,62 @@
1
+ import { RelayRequestSchema } from "./schemas";
2
+ import { createFunction } from "../../utils/function-utils";
3
+ /**
4
+ * Transforms full URLs into Relay format: /relay/{domain}/{path}
5
+ *
6
+ * @param url - The full URL to transform (e.g., "https://api.github.com/user")
7
+ * @returns The relay path format (e.g., "/relay/api.github.com/user")
8
+ */
9
+ function transformUrlToRelayPath(url) {
10
+ const targetUrl = new URL(url);
11
+ // Build the Relay path: /relay/{host}{pathname}{search}{hash}
12
+ // Use host instead of hostname to include port if present
13
+ const relayPath = `/relay/${targetUrl.host}${targetUrl.pathname}${targetUrl.search}${targetUrl.hash}`;
14
+ return relayPath;
15
+ }
16
+ export const requestPlugin = ({ context }) => {
17
+ const request = createFunction(async function request(options) {
18
+ const { api } = context;
19
+ const { url, method = "GET", body, headers: optionsHeaders, authenticationId, callbackUrl, authenticationTemplate, } = options;
20
+ // Transform full URL to relay path format
21
+ const relayPath = transformUrlToRelayPath(url);
22
+ // Build headers for the request
23
+ const headers = {};
24
+ // Copy existing headers
25
+ if (optionsHeaders) {
26
+ const headerEntries = optionsHeaders instanceof Headers
27
+ ? Array.from(optionsHeaders.entries())
28
+ : Array.isArray(optionsHeaders)
29
+ ? optionsHeaders
30
+ : Object.entries(optionsHeaders);
31
+ for (const [key, value] of headerEntries) {
32
+ headers[key] = value;
33
+ }
34
+ }
35
+ // Add Relay-specific headers
36
+ if (authenticationId) {
37
+ headers["X-Relay-Authentication-Id"] = authenticationId.toString();
38
+ }
39
+ if (callbackUrl) {
40
+ headers["X-Relay-Callback-Url"] = callbackUrl;
41
+ }
42
+ if (authenticationTemplate) {
43
+ headers["X-Authentication-Template"] = authenticationTemplate;
44
+ }
45
+ // Use the API client's fetch method directly - let it handle auth automatically
46
+ return await api.fetch(relayPath, {
47
+ method,
48
+ body,
49
+ headers,
50
+ });
51
+ }, RelayRequestSchema);
52
+ return {
53
+ request,
54
+ context: {
55
+ meta: {
56
+ request: {
57
+ inputSchema: RelayRequestSchema,
58
+ },
59
+ },
60
+ },
61
+ };
62
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../../src/plugins/request/index.test.ts"],"names":[],"mappings":""}