@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,467 @@
1
+ import { describe, it, expect, vi, beforeEach } from "vitest";
2
+ import { ZapierValidationError, ZapierAuthenticationError, ZapierConfigurationError, } from "../../types/errors";
3
+ import { listActionsPlugin } from "./index";
4
+ import { createSdk } from "../../sdk";
5
+ import { GetAppSchema } from "../getApp/schemas";
6
+ const mockAppResponse = {
7
+ data: {
8
+ slug: "slack",
9
+ name: "Slack",
10
+ current_implementation_id: "SlackCLIAPI@1.20.0",
11
+ key: "slack",
12
+ title: "Slack",
13
+ hex_color: "#4A154B",
14
+ },
15
+ };
16
+ const mockImplementationsResponse = {
17
+ results: [
18
+ {
19
+ slug: "slack",
20
+ selected_api: "slack",
21
+ actions: [
22
+ {
23
+ key: "user_by_email",
24
+ name: "Search User by Email",
25
+ description: "Find a user by email address",
26
+ type_of: "search",
27
+ type: "search",
28
+ },
29
+ {
30
+ key: "send_message",
31
+ name: "Send Message",
32
+ description: "Send a message to a channel",
33
+ type_of: "write",
34
+ type: "write",
35
+ },
36
+ {
37
+ key: "create_channel",
38
+ name: "Create Channel",
39
+ description: "Create a new channel",
40
+ type_of: "write",
41
+ type: "write",
42
+ },
43
+ ],
44
+ },
45
+ ],
46
+ meta: {
47
+ next_cursor: null,
48
+ },
49
+ };
50
+ const mockEmptyImplementationsResponse = {
51
+ results: [],
52
+ meta: {
53
+ next_cursor: null,
54
+ },
55
+ };
56
+ describe("listActions plugin", () => {
57
+ let mockApiClient;
58
+ let mockGetApp;
59
+ beforeEach(() => {
60
+ vi.clearAllMocks();
61
+ mockApiClient = {
62
+ get: vi.fn().mockResolvedValue(mockImplementationsResponse),
63
+ };
64
+ mockGetApp = vi.fn().mockResolvedValue(mockAppResponse);
65
+ });
66
+ function createTestSdk() {
67
+ // Create a proper plugin chain with context dependencies
68
+ const mockGetAppPlugin = () => ({
69
+ getApp: mockGetApp,
70
+ context: {
71
+ meta: {
72
+ getApp: {
73
+ inputSchema: GetAppSchema,
74
+ },
75
+ },
76
+ },
77
+ });
78
+ // Build SDK with proper plugin composition, providing API in initial context
79
+ return createSdk({}, { api: mockApiClient, meta: {} })
80
+ .addPlugin(mockGetAppPlugin)
81
+ .addPlugin(listActionsPlugin);
82
+ }
83
+ describe("schema validation", () => {
84
+ it("should pass validation with valid appKey", async () => {
85
+ const sdk = createTestSdk();
86
+ const result = await sdk.listActions({ appKey: "slack" });
87
+ expect(result.data).toHaveLength(3);
88
+ });
89
+ it("should throw validation error for missing appKey", () => {
90
+ const sdk = createTestSdk();
91
+ expect(() => {
92
+ sdk.listActions({});
93
+ }).toThrow(ZapierValidationError);
94
+ });
95
+ it("should throw validation error for invalid appKey type", () => {
96
+ const sdk = createTestSdk();
97
+ expect(() => {
98
+ sdk.listActions({
99
+ appKey: 123,
100
+ });
101
+ }).toThrow(ZapierValidationError);
102
+ });
103
+ it("should throw validation error for empty appKey", () => {
104
+ const sdk = createTestSdk();
105
+ expect(() => {
106
+ sdk.listActions({ appKey: "" });
107
+ }).toThrow(ZapierValidationError);
108
+ });
109
+ it("should throw validation error for invalid pageSize", () => {
110
+ const sdk = createTestSdk();
111
+ expect(() => {
112
+ sdk.listActions({ appKey: "slack", pageSize: 0 });
113
+ }).toThrow(ZapierValidationError);
114
+ expect(() => {
115
+ sdk.listActions({ appKey: "slack", pageSize: -5 });
116
+ }).toThrow(ZapierValidationError);
117
+ });
118
+ it("should throw validation error for invalid maxItems", () => {
119
+ const sdk = createTestSdk();
120
+ expect(() => {
121
+ sdk.listActions({ appKey: "slack", maxItems: 0 });
122
+ }).toThrow(ZapierValidationError);
123
+ expect(() => {
124
+ sdk.listActions({ appKey: "slack", maxItems: -10 });
125
+ }).toThrow(ZapierValidationError);
126
+ });
127
+ it("should throw validation error for invalid actionType", () => {
128
+ const sdk = createTestSdk();
129
+ expect(() => {
130
+ sdk.listActions({
131
+ appKey: "slack",
132
+ actionType: "invalid-type",
133
+ });
134
+ }).toThrow(ZapierValidationError);
135
+ });
136
+ it("should pass validation with all valid fields", async () => {
137
+ const sdk = createTestSdk();
138
+ const result = await sdk.listActions({
139
+ appKey: "slack",
140
+ actionType: "write",
141
+ pageSize: 10,
142
+ maxItems: 50,
143
+ });
144
+ expect(result.data).toHaveLength(2); // Only write actions
145
+ expect(result.data.every((action) => action.action_type === "write")).toBe(true);
146
+ });
147
+ });
148
+ describe("actionType enum validation", () => {
149
+ const validActionTypes = [
150
+ "read",
151
+ "read_bulk",
152
+ "write",
153
+ "run",
154
+ "search",
155
+ "search_or_write",
156
+ "search_and_write",
157
+ "filter",
158
+ ];
159
+ validActionTypes.forEach((actionType) => {
160
+ it(`should accept valid actionType: ${actionType}`, async () => {
161
+ const mockResponse = {
162
+ results: [
163
+ {
164
+ slug: "slack",
165
+ actions: [
166
+ {
167
+ key: "test_action",
168
+ name: "Test Action",
169
+ description: "Test description",
170
+ type_of: actionType,
171
+ type: actionType,
172
+ },
173
+ ],
174
+ },
175
+ ],
176
+ meta: { next_cursor: null },
177
+ };
178
+ mockApiClient.get = vi.fn().mockResolvedValue(mockResponse);
179
+ const sdk = createTestSdk();
180
+ const result = await sdk.listActions({
181
+ appKey: "slack",
182
+ actionType: actionType,
183
+ });
184
+ expect(result.data).toHaveLength(1);
185
+ expect(result.data[0].action_type).toBe(actionType);
186
+ });
187
+ });
188
+ });
189
+ describe("data transformation", () => {
190
+ it("should transform implementation actions to ActionItem format", async () => {
191
+ const sdk = createTestSdk();
192
+ const result = await sdk.listActions({ appKey: "slack" });
193
+ const firstAction = result.data[0];
194
+ // Check all required ActionItem fields are present
195
+ expect(firstAction).toHaveProperty("key");
196
+ expect(firstAction).toHaveProperty("type", "action");
197
+ expect(firstAction).toHaveProperty("action_type");
198
+ expect(firstAction).toHaveProperty("title");
199
+ expect(firstAction).toHaveProperty("app_key", "slack");
200
+ expect(firstAction).toHaveProperty("description");
201
+ // Check that title is mapped from API name field
202
+ expect(firstAction.title).toBe("Search User by Email");
203
+ expect(firstAction.app_key).toBe("slack");
204
+ expect(firstAction.type).toBe("action");
205
+ });
206
+ it("should map type_of to action_type", async () => {
207
+ const sdk = createTestSdk();
208
+ const result = await sdk.listActions({ appKey: "slack" });
209
+ expect(result.data[0].action_type).toBe("search"); // From type_of field
210
+ expect(result.data[1].action_type).toBe("write"); // From type_of field
211
+ });
212
+ it("should fall back to type field if type_of is missing", async () => {
213
+ const mockResponseWithoutTypeOf = {
214
+ results: [
215
+ {
216
+ slug: "slack",
217
+ actions: [
218
+ {
219
+ key: "test_action",
220
+ name: "Test Action",
221
+ description: "Test description",
222
+ type: "read", // Only type field, no type_of
223
+ },
224
+ ],
225
+ },
226
+ ],
227
+ meta: { next_cursor: null },
228
+ };
229
+ mockApiClient.get = vi.fn().mockResolvedValue(mockResponseWithoutTypeOf);
230
+ const sdk = createTestSdk();
231
+ const result = await sdk.listActions({ appKey: "slack" });
232
+ expect(result.data[0].action_type).toBe("read"); // Falls back to type field
233
+ });
234
+ it("should handle actions with read type", async () => {
235
+ const mockResponseWithoutType = {
236
+ results: [
237
+ {
238
+ slug: "slack",
239
+ actions: [
240
+ {
241
+ key: "test_action",
242
+ name: "Test Action",
243
+ description: "Test description",
244
+ type: "read", // Provide the required type field
245
+ },
246
+ ],
247
+ },
248
+ ],
249
+ meta: { next_cursor: null },
250
+ };
251
+ mockApiClient.get = vi.fn().mockResolvedValue(mockResponseWithoutType);
252
+ const sdk = createTestSdk();
253
+ const result = await sdk.listActions({ appKey: "slack" });
254
+ expect(result.data[0].action_type).toBe("read"); // Should match provided type
255
+ });
256
+ });
257
+ describe("filtering", () => {
258
+ it("should filter actions by actionType", async () => {
259
+ const sdk = createTestSdk();
260
+ const result = await sdk.listActions({
261
+ appKey: "slack",
262
+ actionType: "write",
263
+ });
264
+ expect(result.data).toHaveLength(2);
265
+ expect(result.data.every((action) => action.action_type === "write")).toBe(true);
266
+ expect(result.data.map((action) => action.key)).toEqual([
267
+ "send_message",
268
+ "create_channel",
269
+ ]);
270
+ });
271
+ it("should return empty array when no actions match filter", async () => {
272
+ const sdk = createTestSdk();
273
+ const result = await sdk.listActions({
274
+ appKey: "slack",
275
+ actionType: "filter", // No actions of this type in mock data
276
+ });
277
+ expect(result.data).toHaveLength(0);
278
+ });
279
+ it("should return all actions when no actionType filter provided", async () => {
280
+ const sdk = createTestSdk();
281
+ const result = await sdk.listActions({ appKey: "slack" });
282
+ expect(result.data).toHaveLength(3); // All actions
283
+ });
284
+ });
285
+ describe("pagination", () => {
286
+ it("should handle maxItems limit", async () => {
287
+ const sdk = createTestSdk();
288
+ const result = await sdk.listActions({
289
+ appKey: "slack",
290
+ maxItems: 2,
291
+ });
292
+ expect(result.data).toHaveLength(2); // Limited to maxItems
293
+ });
294
+ it("should support async iteration over pages", async () => {
295
+ const sdk = createTestSdk();
296
+ const listActions = sdk.listActions({ appKey: "slack" });
297
+ const pages = [];
298
+ for await (const page of listActions) {
299
+ pages.push(page);
300
+ break; // Just get first page for testing
301
+ }
302
+ expect(pages).toHaveLength(1);
303
+ expect(pages[0].data).toHaveLength(3);
304
+ expect(pages[0].data[0].key).toBe("user_by_email");
305
+ });
306
+ it("should support async iteration over individual items", async () => {
307
+ const sdk = createTestSdk();
308
+ const listActions = sdk.listActions({
309
+ appKey: "slack",
310
+ maxItems: 2,
311
+ });
312
+ const items = [];
313
+ for await (const item of listActions.items()) {
314
+ items.push(item);
315
+ }
316
+ expect(items).toHaveLength(2);
317
+ expect(items[0].key).toBe("user_by_email");
318
+ expect(items[1].key).toBe("send_message");
319
+ });
320
+ it("should respect pageSize parameter", async () => {
321
+ const sdk = createTestSdk();
322
+ await sdk.listActions({
323
+ appKey: "slack",
324
+ pageSize: 10,
325
+ });
326
+ // Note: Since listActions doesn't actually use pagination internally,
327
+ // we just verify it accepts the parameter without error
328
+ expect(mockApiClient.get).toHaveBeenCalled();
329
+ });
330
+ });
331
+ describe("API integration", () => {
332
+ it("should call getApp to get implementation ID", async () => {
333
+ const sdk = createTestSdk();
334
+ await sdk.listActions({ appKey: "slack" });
335
+ expect(mockGetApp).toHaveBeenCalledWith({
336
+ appKey: "slack",
337
+ });
338
+ });
339
+ it("should pass correct search parameters to implementations API", async () => {
340
+ const sdk = createTestSdk();
341
+ await sdk.listActions({ appKey: "slack" });
342
+ expect(mockApiClient.get).toHaveBeenCalledWith("/api/v4/implementations/", expect.objectContaining({
343
+ searchParams: expect.objectContaining({
344
+ global: "true",
345
+ public_only: "true",
346
+ selected_apis: "SlackCLIAPI", // Extracted from current_implementation_id
347
+ }),
348
+ }));
349
+ });
350
+ });
351
+ describe("error handling", () => {
352
+ it("should throw ZapierConfigurationError when app has no current_implementation_id", async () => {
353
+ mockGetApp.mockResolvedValue({
354
+ data: {
355
+ ...mockAppResponse.data,
356
+ current_implementation_id: undefined, // Missing implementation ID
357
+ },
358
+ });
359
+ const sdk = createTestSdk();
360
+ await expect(sdk.listActions({ appKey: "slack" })).rejects.toThrow(ZapierConfigurationError);
361
+ });
362
+ it("should throw ZapierConfigurationError when current_implementation_id is empty", async () => {
363
+ mockGetApp.mockResolvedValue({
364
+ data: {
365
+ ...mockAppResponse.data,
366
+ current_implementation_id: "", // Empty implementation ID
367
+ },
368
+ });
369
+ const sdk = createTestSdk();
370
+ await expect(sdk.listActions({ appKey: "slack" })).rejects.toThrow(ZapierConfigurationError);
371
+ });
372
+ it("should handle authentication error (401)", async () => {
373
+ mockApiClient.get = vi.fn().mockImplementation((_url, options) => {
374
+ if (options.customErrorHandler) {
375
+ const error = options.customErrorHandler({ status: 401 });
376
+ if (error) {
377
+ throw error;
378
+ }
379
+ }
380
+ throw new Error("Unauthorized");
381
+ });
382
+ const sdk = createTestSdk();
383
+ await expect(sdk.listActions({ appKey: "slack" })).rejects.toThrow(ZapierAuthenticationError);
384
+ });
385
+ it("should handle forbidden error (403)", async () => {
386
+ mockApiClient.get = vi.fn().mockImplementation((_url, options) => {
387
+ if (options.customErrorHandler) {
388
+ const error = options.customErrorHandler({ status: 403 });
389
+ if (error) {
390
+ throw error;
391
+ }
392
+ }
393
+ throw new Error("Forbidden");
394
+ });
395
+ const sdk = createTestSdk();
396
+ await expect(sdk.listActions({ appKey: "slack" })).rejects.toThrow(ZapierAuthenticationError);
397
+ });
398
+ it("should return empty array when implementations API returns no results", async () => {
399
+ mockApiClient.get = vi
400
+ .fn()
401
+ .mockResolvedValue(mockEmptyImplementationsResponse);
402
+ const sdk = createTestSdk();
403
+ const result = await sdk.listActions({ appKey: "slack" });
404
+ expect(result.data).toHaveLength(0);
405
+ });
406
+ it("should handle implementation without actions", async () => {
407
+ const mockResponseWithoutActions = {
408
+ results: [
409
+ {
410
+ slug: "slack",
411
+ // No actions property
412
+ },
413
+ ],
414
+ meta: { next_cursor: null },
415
+ };
416
+ mockApiClient.get = vi.fn().mockResolvedValue(mockResponseWithoutActions);
417
+ const sdk = createTestSdk();
418
+ const result = await sdk.listActions({ appKey: "slack" });
419
+ expect(result.data).toHaveLength(0);
420
+ });
421
+ it("should propagate getApp errors", async () => {
422
+ mockGetApp.mockRejectedValue(new Error("App not found"));
423
+ const sdk = createTestSdk();
424
+ await expect(sdk.listActions({ appKey: "nonexistent" })).rejects.toThrow("App not found");
425
+ });
426
+ });
427
+ describe("implementation ID extraction", () => {
428
+ it("should extract implementation name from versioned ID", async () => {
429
+ mockGetApp.mockResolvedValue({
430
+ data: {
431
+ ...mockAppResponse.data,
432
+ current_implementation_id: "CustomAPIName@2.5.0",
433
+ },
434
+ });
435
+ const sdk = createTestSdk();
436
+ await sdk.listActions({ appKey: "slack" });
437
+ expect(mockApiClient.get).toHaveBeenCalledWith("/api/v4/implementations/", expect.objectContaining({
438
+ searchParams: expect.objectContaining({
439
+ selected_apis: "CustomAPIName", // Extracted name without version
440
+ }),
441
+ }));
442
+ });
443
+ it("should handle implementation ID without version", async () => {
444
+ mockGetApp.mockResolvedValue({
445
+ data: {
446
+ ...mockAppResponse.data,
447
+ current_implementation_id: "PlainAPIName",
448
+ },
449
+ });
450
+ const sdk = createTestSdk();
451
+ await sdk.listActions({ appKey: "slack" });
452
+ expect(mockApiClient.get).toHaveBeenCalledWith("/api/v4/implementations/", expect.objectContaining({
453
+ searchParams: expect.objectContaining({
454
+ selected_apis: "PlainAPIName", // Used as-is
455
+ }),
456
+ }));
457
+ });
458
+ });
459
+ describe("context and metadata", () => {
460
+ it("should provide context with meta information", () => {
461
+ const sdk = createTestSdk();
462
+ const context = sdk.getContext();
463
+ expect(context.meta.listActions).toBeDefined();
464
+ expect(context.meta.listActions.inputSchema).toBeDefined();
465
+ });
466
+ });
467
+ });
@@ -0,0 +1,29 @@
1
+ import { z } from "zod";
2
+ import type { ActionItem } from "../../types/domain";
3
+ import type { PaginatedSdkFunction } from "../../types/functions";
4
+ export declare const ListActionsSchema: z.ZodObject<{
5
+ appKey: z.ZodString;
6
+ actionType: z.ZodOptional<z.ZodEnum<["read", "read_bulk", "write", "run", "search", "search_or_write", "search_and_write", "filter"]>>;
7
+ pageSize: z.ZodOptional<z.ZodNumber>;
8
+ maxItems: z.ZodOptional<z.ZodNumber>;
9
+ }, "strip", z.ZodTypeAny, {
10
+ appKey: string;
11
+ maxItems?: number | undefined;
12
+ pageSize?: number | undefined;
13
+ actionType?: "filter" | "read" | "read_bulk" | "run" | "search" | "search_and_write" | "search_or_write" | "write" | undefined;
14
+ }, {
15
+ appKey: string;
16
+ maxItems?: number | undefined;
17
+ pageSize?: number | undefined;
18
+ actionType?: "filter" | "read" | "read_bulk" | "run" | "search" | "search_and_write" | "search_or_write" | "write" | undefined;
19
+ }>;
20
+ export type ListActionsOptions = z.infer<typeof ListActionsSchema>;
21
+ export interface ListActionsPage {
22
+ data: ActionItem[];
23
+ nextCursor?: string;
24
+ }
25
+ export type ListActionsError = import("../../types/errors").ZapierAuthenticationError | import("../../types/errors").ZapierValidationError | import("../../types/errors").ZapierUnknownError;
26
+ export interface ListActionsSdkFunction {
27
+ listActions: PaginatedSdkFunction<ListActionsOptions, ActionItem>;
28
+ }
29
+ //# sourceMappingURL=schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/plugins/listActions/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAGlE,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;EAsB7B,CAAC;AAGF,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAGnE,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,UAAU,EAAE,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAGD,MAAM,MAAM,gBAAgB,GACxB,OAAO,oBAAoB,EAAE,yBAAyB,GACtD,OAAO,oBAAoB,EAAE,qBAAqB,GAClD,OAAO,oBAAoB,EAAE,kBAAkB,CAAC;AAGpD,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,oBAAoB,CAAC,kBAAkB,EAAE,UAAU,CAAC,CAAC;CACnE"}
@@ -0,0 +1,21 @@
1
+ import { z } from "zod";
2
+ import { AppKeyPropertySchema, ActionTypePropertySchema, } from "../../types/properties";
3
+ import { withOutputSchema } from "../../utils/schema-utils";
4
+ import { ActionItemSchema } from "../../schemas/Action";
5
+ // Pure Zod schema - no resolver metadata!
6
+ export const ListActionsSchema = withOutputSchema(z
7
+ .object({
8
+ appKey: AppKeyPropertySchema.describe("App key of actions to list (e.g., 'SlackCLIAPI')"),
9
+ actionType: ActionTypePropertySchema.optional().describe("Filter actions by type"),
10
+ pageSize: z
11
+ .number()
12
+ .min(1)
13
+ .optional()
14
+ .describe("Number of actions per page"),
15
+ maxItems: z
16
+ .number()
17
+ .min(1)
18
+ .optional()
19
+ .describe("Maximum total items to return across all pages"),
20
+ })
21
+ .describe("List all actions for a specific app"), ActionItemSchema);
@@ -0,0 +1,28 @@
1
+ import type { Plugin } from "../../types/plugin";
2
+ import type { ApiClient } from "../../api/types";
3
+ import { ListAppsSchema } from "./schemas";
4
+ import type { ListAppsOptions } from "./schemas";
5
+ import type { AppItem } from "../../types/domain";
6
+ export interface ListAppsPluginProvides {
7
+ listApps: (options?: ListAppsOptions) => Promise<{
8
+ data: AppItem[];
9
+ }> & AsyncIterable<{
10
+ data: AppItem[];
11
+ nextCursor?: string;
12
+ }> & {
13
+ items(): AsyncIterable<AppItem>;
14
+ };
15
+ context: {
16
+ meta: {
17
+ listApps: {
18
+ inputSchema: typeof ListAppsSchema;
19
+ };
20
+ };
21
+ };
22
+ }
23
+ export declare const listAppsPlugin: Plugin<{}, // no SDK dependencies
24
+ {
25
+ api: ApiClient;
26
+ }, // requires api in context
27
+ ListAppsPluginProvides>;
28
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/listApps/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,KAAK,EAAE,eAAe,EAAgB,MAAM,WAAW,CAAC;AAC/D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AASlD,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,eAAe,KAAK,OAAO,CAAC;QAAE,IAAI,EAAE,OAAO,EAAE,CAAA;KAAE,CAAC,GACnE,aAAa,CAAC;QAAE,IAAI,EAAE,OAAO,EAAE,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG;QACxD,KAAK,IAAI,aAAa,CAAC,OAAO,CAAC,CAAC;KACjC,CAAC;IACJ,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,QAAQ,EAAE;gBACR,WAAW,EAAE,OAAO,cAAc,CAAC;aACpC,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAGD,eAAO,MAAM,cAAc,EAAE,MAAM,CACjC,EAAE,EAAE,sBAAsB;AAC1B;IAAE,GAAG,EAAE,SAAS,CAAA;CAAE,EAAE,0BAA0B;AAC9C,sBAAsB,CAwFvB,CAAC"}
@@ -0,0 +1,62 @@
1
+ import { createPaginatedFunction } from "../../utils/function-utils";
2
+ import { ListAppsSchema } from "./schemas";
3
+ import { groupAppKeysByType, normalizeImplementationMetaToAppItem, splitVersionedKey, } from "../../utils/domain-utils";
4
+ import { extractCursor } from "../../utils/function-utils";
5
+ // Direct plugin function - takes options + sdk + context in one object
6
+ export const listAppsPlugin = ({ context }) => {
7
+ const listApps = createPaginatedFunction(async function listAppsPage(options) {
8
+ const api = context.api;
9
+ const opts = options;
10
+ const appKeys = [...(opts.appKeys ?? [])].map((key) => splitVersionedKey(key)[0]);
11
+ if (opts.search) {
12
+ const searchParams = {};
13
+ searchParams.term = opts.search;
14
+ const searchEnvelope = await api.get("/api/v4/implementations-meta/search/", {
15
+ searchParams,
16
+ });
17
+ const implementations = searchEnvelope.results.map(normalizeImplementationMetaToAppItem);
18
+ const appKeysSet = new Set(appKeys);
19
+ for (const implementation of implementations) {
20
+ if (!appKeysSet.has(implementation.key)) {
21
+ appKeysSet.add(implementation.key);
22
+ appKeys.push(implementation.key);
23
+ }
24
+ }
25
+ }
26
+ const searchParams = {};
27
+ if (opts.pageSize) {
28
+ searchParams.limit = opts.pageSize.toString();
29
+ }
30
+ searchParams.latest_only = "true";
31
+ if (opts.cursor) {
32
+ searchParams.offset = opts.cursor;
33
+ }
34
+ if (appKeys.length > 0) {
35
+ const groupedAppKeys = groupAppKeysByType(appKeys);
36
+ if (groupedAppKeys.selectedApi.length > 0) {
37
+ searchParams.selected_apis = groupedAppKeys.selectedApi.join(",");
38
+ }
39
+ if (groupedAppKeys.slug.length > 0) {
40
+ searchParams.slugs = groupedAppKeys.slug.join(",");
41
+ }
42
+ }
43
+ const implementationsEnvelope = await api.get("/api/v4/implementations-meta/lookup/", {
44
+ searchParams,
45
+ });
46
+ return {
47
+ data: implementationsEnvelope.results.map(normalizeImplementationMetaToAppItem),
48
+ nextCursor: extractCursor(implementationsEnvelope),
49
+ };
50
+ }, ListAppsSchema);
51
+ // Return flat structure - listApps goes directly to SDK
52
+ return {
53
+ listApps,
54
+ context: {
55
+ meta: {
56
+ listApps: {
57
+ inputSchema: ListAppsSchema,
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/listApps/index.test.ts"],"names":[],"mappings":""}