@zapier/zapier-sdk 0.18.4 → 0.19.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 (372) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/README.md +43 -31
  3. package/dist/index.cjs +365 -64
  4. package/dist/index.d.mts +220 -33
  5. package/dist/index.d.ts +2541 -40
  6. package/dist/index.mjs +345 -63
  7. package/package.json +14 -13
  8. package/dist/api/auth.d.ts +0 -19
  9. package/dist/api/auth.d.ts.map +0 -1
  10. package/dist/api/auth.js +0 -70
  11. package/dist/api/auth.test.d.ts +0 -2
  12. package/dist/api/auth.test.d.ts.map +0 -1
  13. package/dist/api/auth.test.js +0 -220
  14. package/dist/api/client.d.ts +0 -9
  15. package/dist/api/client.d.ts.map +0 -1
  16. package/dist/api/client.js +0 -356
  17. package/dist/api/client.test.d.ts +0 -2
  18. package/dist/api/client.test.d.ts.map +0 -1
  19. package/dist/api/client.test.js +0 -96
  20. package/dist/api/debug.d.ts +0 -14
  21. package/dist/api/debug.d.ts.map +0 -1
  22. package/dist/api/debug.js +0 -131
  23. package/dist/api/debug.test.d.ts +0 -2
  24. package/dist/api/debug.test.d.ts.map +0 -1
  25. package/dist/api/debug.test.js +0 -59
  26. package/dist/api/index.d.ts +0 -30
  27. package/dist/api/index.d.ts.map +0 -1
  28. package/dist/api/index.js +0 -43
  29. package/dist/api/polling.d.ts +0 -46
  30. package/dist/api/polling.d.ts.map +0 -1
  31. package/dist/api/polling.js +0 -139
  32. package/dist/api/polling.test.d.ts +0 -2
  33. package/dist/api/polling.test.d.ts.map +0 -1
  34. package/dist/api/polling.test.js +0 -318
  35. package/dist/api/schemas.d.ts +0 -422
  36. package/dist/api/schemas.d.ts.map +0 -1
  37. package/dist/api/schemas.js +0 -322
  38. package/dist/api/types.d.ts +0 -83
  39. package/dist/api/types.d.ts.map +0 -1
  40. package/dist/api/types.js +0 -1
  41. package/dist/auth.d.ts +0 -52
  42. package/dist/auth.d.ts.map +0 -1
  43. package/dist/auth.js +0 -72
  44. package/dist/auth.test.d.ts +0 -2
  45. package/dist/auth.test.d.ts.map +0 -1
  46. package/dist/auth.test.js +0 -102
  47. package/dist/constants.d.ts +0 -14
  48. package/dist/constants.d.ts.map +0 -1
  49. package/dist/constants.js +0 -13
  50. package/dist/index.d.ts.map +0 -1
  51. package/dist/index.js +0 -42
  52. package/dist/plugins/api/index.d.ts +0 -12
  53. package/dist/plugins/api/index.d.ts.map +0 -1
  54. package/dist/plugins/api/index.js +0 -24
  55. package/dist/plugins/apps/index.d.ts +0 -15
  56. package/dist/plugins/apps/index.d.ts.map +0 -1
  57. package/dist/plugins/apps/index.js +0 -112
  58. package/dist/plugins/apps/schemas.d.ts +0 -42
  59. package/dist/plugins/apps/schemas.d.ts.map +0 -1
  60. package/dist/plugins/apps/schemas.js +0 -14
  61. package/dist/plugins/eventEmission/builders.d.ts +0 -14
  62. package/dist/plugins/eventEmission/builders.d.ts.map +0 -1
  63. package/dist/plugins/eventEmission/builders.js +0 -109
  64. package/dist/plugins/eventEmission/index.d.ts +0 -38
  65. package/dist/plugins/eventEmission/index.d.ts.map +0 -1
  66. package/dist/plugins/eventEmission/index.js +0 -336
  67. package/dist/plugins/eventEmission/index.test.d.ts +0 -5
  68. package/dist/plugins/eventEmission/index.test.d.ts.map +0 -1
  69. package/dist/plugins/eventEmission/index.test.js +0 -581
  70. package/dist/plugins/eventEmission/transport.d.ts +0 -27
  71. package/dist/plugins/eventEmission/transport.d.ts.map +0 -1
  72. package/dist/plugins/eventEmission/transport.js +0 -104
  73. package/dist/plugins/eventEmission/transport.test.d.ts +0 -5
  74. package/dist/plugins/eventEmission/transport.test.d.ts.map +0 -1
  75. package/dist/plugins/eventEmission/transport.test.js +0 -164
  76. package/dist/plugins/eventEmission/types.d.ts +0 -63
  77. package/dist/plugins/eventEmission/types.d.ts.map +0 -1
  78. package/dist/plugins/eventEmission/types.js +0 -1
  79. package/dist/plugins/eventEmission/utils.d.ts +0 -45
  80. package/dist/plugins/eventEmission/utils.d.ts.map +0 -1
  81. package/dist/plugins/eventEmission/utils.js +0 -114
  82. package/dist/plugins/fetch/index.d.ts +0 -36
  83. package/dist/plugins/fetch/index.d.ts.map +0 -1
  84. package/dist/plugins/fetch/index.js +0 -62
  85. package/dist/plugins/fetch/schemas.d.ts +0 -19
  86. package/dist/plugins/fetch/schemas.d.ts.map +0 -1
  87. package/dist/plugins/fetch/schemas.js +0 -31
  88. package/dist/plugins/findFirstAuthentication/index.d.ts +0 -21
  89. package/dist/plugins/findFirstAuthentication/index.d.ts.map +0 -1
  90. package/dist/plugins/findFirstAuthentication/index.js +0 -36
  91. package/dist/plugins/findFirstAuthentication/index.test.d.ts +0 -2
  92. package/dist/plugins/findFirstAuthentication/index.test.d.ts.map +0 -1
  93. package/dist/plugins/findFirstAuthentication/index.test.js +0 -177
  94. package/dist/plugins/findFirstAuthentication/schemas.d.ts +0 -20
  95. package/dist/plugins/findFirstAuthentication/schemas.d.ts.map +0 -1
  96. package/dist/plugins/findFirstAuthentication/schemas.js +0 -18
  97. package/dist/plugins/findUniqueAuthentication/index.d.ts +0 -21
  98. package/dist/plugins/findUniqueAuthentication/index.d.ts.map +0 -1
  99. package/dist/plugins/findUniqueAuthentication/index.js +0 -39
  100. package/dist/plugins/findUniqueAuthentication/index.test.d.ts +0 -2
  101. package/dist/plugins/findUniqueAuthentication/index.test.d.ts.map +0 -1
  102. package/dist/plugins/findUniqueAuthentication/index.test.js +0 -159
  103. package/dist/plugins/findUniqueAuthentication/schemas.d.ts +0 -20
  104. package/dist/plugins/findUniqueAuthentication/schemas.d.ts.map +0 -1
  105. package/dist/plugins/findUniqueAuthentication/schemas.js +0 -18
  106. package/dist/plugins/getAction/index.d.ts +0 -25
  107. package/dist/plugins/getAction/index.d.ts.map +0 -1
  108. package/dist/plugins/getAction/index.js +0 -42
  109. package/dist/plugins/getAction/index.test.d.ts +0 -2
  110. package/dist/plugins/getAction/index.test.d.ts.map +0 -1
  111. package/dist/plugins/getAction/index.test.js +0 -211
  112. package/dist/plugins/getAction/schemas.d.ts +0 -30
  113. package/dist/plugins/getAction/schemas.d.ts.map +0 -1
  114. package/dist/plugins/getAction/schemas.js +0 -12
  115. package/dist/plugins/getApp/index.d.ts +0 -21
  116. package/dist/plugins/getApp/index.d.ts.map +0 -1
  117. package/dist/plugins/getApp/index.js +0 -44
  118. package/dist/plugins/getApp/index.test.d.ts +0 -2
  119. package/dist/plugins/getApp/index.test.d.ts.map +0 -1
  120. package/dist/plugins/getApp/index.test.js +0 -157
  121. package/dist/plugins/getApp/schemas.d.ts +0 -16
  122. package/dist/plugins/getApp/schemas.d.ts.map +0 -1
  123. package/dist/plugins/getApp/schemas.js +0 -8
  124. package/dist/plugins/getAuthentication/index.d.ts +0 -21
  125. package/dist/plugins/getAuthentication/index.d.ts.map +0 -1
  126. package/dist/plugins/getAuthentication/index.js +0 -29
  127. package/dist/plugins/getAuthentication/index.test.d.ts +0 -2
  128. package/dist/plugins/getAuthentication/index.test.d.ts.map +0 -1
  129. package/dist/plugins/getAuthentication/index.test.js +0 -106
  130. package/dist/plugins/getAuthentication/schemas.d.ts +0 -7
  131. package/dist/plugins/getAuthentication/schemas.d.ts.map +0 -1
  132. package/dist/plugins/getAuthentication/schemas.js +0 -1
  133. package/dist/plugins/getInputFieldsSchema/index.d.ts +0 -23
  134. package/dist/plugins/getInputFieldsSchema/index.d.ts.map +0 -1
  135. package/dist/plugins/getInputFieldsSchema/index.js +0 -53
  136. package/dist/plugins/getInputFieldsSchema/index.test.d.ts +0 -2
  137. package/dist/plugins/getInputFieldsSchema/index.test.d.ts.map +0 -1
  138. package/dist/plugins/getInputFieldsSchema/index.test.js +0 -291
  139. package/dist/plugins/getInputFieldsSchema/schemas.d.ts +0 -28
  140. package/dist/plugins/getInputFieldsSchema/schemas.d.ts.map +0 -1
  141. package/dist/plugins/getInputFieldsSchema/schemas.js +0 -13
  142. package/dist/plugins/getProfile/index.d.ts +0 -25
  143. package/dist/plugins/getProfile/index.d.ts.map +0 -1
  144. package/dist/plugins/getProfile/index.js +0 -39
  145. package/dist/plugins/getProfile/schemas.d.ts +0 -13
  146. package/dist/plugins/getProfile/schemas.d.ts.map +0 -1
  147. package/dist/plugins/getProfile/schemas.js +0 -6
  148. package/dist/plugins/listActions/index.d.ts +0 -30
  149. package/dist/plugins/listActions/index.d.ts.map +0 -1
  150. package/dist/plugins/listActions/index.js +0 -75
  151. package/dist/plugins/listActions/index.test.d.ts +0 -2
  152. package/dist/plugins/listActions/index.test.d.ts.map +0 -1
  153. package/dist/plugins/listActions/index.test.js +0 -453
  154. package/dist/plugins/listActions/schemas.d.ts +0 -35
  155. package/dist/plugins/listActions/schemas.d.ts.map +0 -1
  156. package/dist/plugins/listActions/schemas.js +0 -22
  157. package/dist/plugins/listApps/index.d.ts +0 -19
  158. package/dist/plugins/listApps/index.d.ts.map +0 -1
  159. package/dist/plugins/listApps/index.js +0 -67
  160. package/dist/plugins/listApps/index.test.d.ts +0 -2
  161. package/dist/plugins/listApps/index.test.d.ts.map +0 -1
  162. package/dist/plugins/listApps/index.test.js +0 -121
  163. package/dist/plugins/listApps/schemas.d.ts +0 -47
  164. package/dist/plugins/listApps/schemas.d.ts.map +0 -1
  165. package/dist/plugins/listApps/schemas.js +0 -49
  166. package/dist/plugins/listAuthentications/index.d.ts +0 -24
  167. package/dist/plugins/listAuthentications/index.d.ts.map +0 -1
  168. package/dist/plugins/listAuthentications/index.js +0 -77
  169. package/dist/plugins/listAuthentications/index.test.d.ts +0 -2
  170. package/dist/plugins/listAuthentications/index.test.d.ts.map +0 -1
  171. package/dist/plugins/listAuthentications/index.test.js +0 -848
  172. package/dist/plugins/listAuthentications/schemas.d.ts +0 -30
  173. package/dist/plugins/listAuthentications/schemas.d.ts.map +0 -1
  174. package/dist/plugins/listAuthentications/schemas.js +0 -32
  175. package/dist/plugins/listInputFieldChoices/index.d.ts +0 -33
  176. package/dist/plugins/listInputFieldChoices/index.d.ts.map +0 -1
  177. package/dist/plugins/listInputFieldChoices/index.js +0 -115
  178. package/dist/plugins/listInputFieldChoices/index.test.d.ts +0 -2
  179. package/dist/plugins/listInputFieldChoices/index.test.d.ts.map +0 -1
  180. package/dist/plugins/listInputFieldChoices/index.test.js +0 -717
  181. package/dist/plugins/listInputFieldChoices/schemas.d.ts +0 -43
  182. package/dist/plugins/listInputFieldChoices/schemas.d.ts.map +0 -1
  183. package/dist/plugins/listInputFieldChoices/schemas.js +0 -65
  184. package/dist/plugins/listInputFields/index.d.ts +0 -34
  185. package/dist/plugins/listInputFields/index.d.ts.map +0 -1
  186. package/dist/plugins/listInputFields/index.js +0 -204
  187. package/dist/plugins/listInputFields/index.test.d.ts +0 -2
  188. package/dist/plugins/listInputFields/index.test.d.ts.map +0 -1
  189. package/dist/plugins/listInputFields/index.test.js +0 -359
  190. package/dist/plugins/listInputFields/schemas.d.ts +0 -35
  191. package/dist/plugins/listInputFields/schemas.d.ts.map +0 -1
  192. package/dist/plugins/listInputFields/schemas.js +0 -23
  193. package/dist/plugins/manifest/index.d.ts +0 -85
  194. package/dist/plugins/manifest/index.d.ts.map +0 -1
  195. package/dist/plugins/manifest/index.js +0 -376
  196. package/dist/plugins/manifest/index.test.d.ts +0 -2
  197. package/dist/plugins/manifest/index.test.d.ts.map +0 -1
  198. package/dist/plugins/manifest/index.test.js +0 -1139
  199. package/dist/plugins/manifest/schemas.d.ts +0 -57
  200. package/dist/plugins/manifest/schemas.d.ts.map +0 -1
  201. package/dist/plugins/manifest/schemas.js +0 -50
  202. package/dist/plugins/registry/index.d.ts +0 -21
  203. package/dist/plugins/registry/index.d.ts.map +0 -1
  204. package/dist/plugins/registry/index.js +0 -117
  205. package/dist/plugins/request/index.d.ts +0 -21
  206. package/dist/plugins/request/index.d.ts.map +0 -1
  207. package/dist/plugins/request/index.js +0 -76
  208. package/dist/plugins/request/index.test.d.ts +0 -2
  209. package/dist/plugins/request/index.test.d.ts.map +0 -1
  210. package/dist/plugins/request/index.test.js +0 -337
  211. package/dist/plugins/request/schemas.d.ts +0 -54
  212. package/dist/plugins/request/schemas.d.ts.map +0 -1
  213. package/dist/plugins/request/schemas.js +0 -41
  214. package/dist/plugins/runAction/index.d.ts +0 -33
  215. package/dist/plugins/runAction/index.d.ts.map +0 -1
  216. package/dist/plugins/runAction/index.js +0 -108
  217. package/dist/plugins/runAction/index.test.d.ts +0 -2
  218. package/dist/plugins/runAction/index.test.d.ts.map +0 -1
  219. package/dist/plugins/runAction/index.test.js +0 -333
  220. package/dist/plugins/runAction/schemas.d.ts +0 -34
  221. package/dist/plugins/runAction/schemas.d.ts.map +0 -1
  222. package/dist/plugins/runAction/schemas.js +0 -23
  223. package/dist/resolvers/actionKey.d.ts +0 -15
  224. package/dist/resolvers/actionKey.d.ts.map +0 -1
  225. package/dist/resolvers/actionKey.js +0 -19
  226. package/dist/resolvers/actionType.d.ts +0 -10
  227. package/dist/resolvers/actionType.d.ts.map +0 -1
  228. package/dist/resolvers/actionType.js +0 -21
  229. package/dist/resolvers/appKey.d.ts +0 -3
  230. package/dist/resolvers/appKey.d.ts.map +0 -1
  231. package/dist/resolvers/appKey.js +0 -5
  232. package/dist/resolvers/authenticationId.d.ts +0 -9
  233. package/dist/resolvers/authenticationId.d.ts.map +0 -1
  234. package/dist/resolvers/authenticationId.js +0 -42
  235. package/dist/resolvers/index.d.ts +0 -8
  236. package/dist/resolvers/index.d.ts.map +0 -1
  237. package/dist/resolvers/index.js +0 -8
  238. package/dist/resolvers/inputFieldKey.d.ts +0 -11
  239. package/dist/resolvers/inputFieldKey.d.ts.map +0 -1
  240. package/dist/resolvers/inputFieldKey.js +0 -47
  241. package/dist/resolvers/inputs.d.ts +0 -17
  242. package/dist/resolvers/inputs.d.ts.map +0 -1
  243. package/dist/resolvers/inputs.js +0 -50
  244. package/dist/schemas/Action.d.ts +0 -24
  245. package/dist/schemas/Action.d.ts.map +0 -1
  246. package/dist/schemas/Action.js +0 -40
  247. package/dist/schemas/App.d.ts +0 -57
  248. package/dist/schemas/App.d.ts.map +0 -1
  249. package/dist/schemas/App.js +0 -26
  250. package/dist/schemas/Auth.d.ts +0 -55
  251. package/dist/schemas/Auth.d.ts.map +0 -1
  252. package/dist/schemas/Auth.js +0 -33
  253. package/dist/schemas/Field.d.ts +0 -61
  254. package/dist/schemas/Field.d.ts.map +0 -1
  255. package/dist/schemas/Field.js +0 -116
  256. package/dist/schemas/Run.d.ts +0 -3
  257. package/dist/schemas/Run.d.ts.map +0 -1
  258. package/dist/schemas/Run.js +0 -31
  259. package/dist/schemas/UserProfile.d.ts +0 -13
  260. package/dist/schemas/UserProfile.d.ts.map +0 -1
  261. package/dist/schemas/UserProfile.js +0 -32
  262. package/dist/sdk.d.ts +0 -146
  263. package/dist/sdk.d.ts.map +0 -1
  264. package/dist/sdk.js +0 -112
  265. package/dist/sdk.test.d.ts +0 -2
  266. package/dist/sdk.test.d.ts.map +0 -1
  267. package/dist/sdk.test.js +0 -258
  268. package/dist/services/implementations.d.ts +0 -63
  269. package/dist/services/implementations.d.ts.map +0 -1
  270. package/dist/services/implementations.js +0 -80
  271. package/dist/types/domain.d.ts +0 -52
  272. package/dist/types/domain.d.ts.map +0 -1
  273. package/dist/types/domain.js +0 -1
  274. package/dist/types/domain.test.d.ts +0 -2
  275. package/dist/types/domain.test.d.ts.map +0 -1
  276. package/dist/types/domain.test.js +0 -39
  277. package/dist/types/errors.d.ts +0 -143
  278. package/dist/types/errors.d.ts.map +0 -1
  279. package/dist/types/errors.js +0 -187
  280. package/dist/types/events.d.ts +0 -38
  281. package/dist/types/events.d.ts.map +0 -1
  282. package/dist/types/events.js +0 -7
  283. package/dist/types/functions.d.ts +0 -27
  284. package/dist/types/functions.d.ts.map +0 -1
  285. package/dist/types/functions.js +0 -1
  286. package/dist/types/plugin.d.ts +0 -75
  287. package/dist/types/plugin.d.ts.map +0 -1
  288. package/dist/types/plugin.js +0 -9
  289. package/dist/types/properties.d.ts +0 -33
  290. package/dist/types/properties.d.ts.map +0 -1
  291. package/dist/types/properties.js +0 -52
  292. package/dist/types/sdk.d.ts +0 -69
  293. package/dist/types/sdk.d.ts.map +0 -1
  294. package/dist/types/sdk.js +0 -4
  295. package/dist/types/telemetry-events.d.ts +0 -105
  296. package/dist/types/telemetry-events.d.ts.map +0 -1
  297. package/dist/types/telemetry-events.js +0 -8
  298. package/dist/utils/array-utils.d.ts +0 -31
  299. package/dist/utils/array-utils.d.ts.map +0 -1
  300. package/dist/utils/array-utils.js +0 -36
  301. package/dist/utils/array-utils.test.d.ts +0 -2
  302. package/dist/utils/array-utils.test.d.ts.map +0 -1
  303. package/dist/utils/array-utils.test.js +0 -107
  304. package/dist/utils/batch-utils.d.ts +0 -72
  305. package/dist/utils/batch-utils.d.ts.map +0 -1
  306. package/dist/utils/batch-utils.js +0 -162
  307. package/dist/utils/batch-utils.test.d.ts +0 -2
  308. package/dist/utils/batch-utils.test.d.ts.map +0 -1
  309. package/dist/utils/batch-utils.test.js +0 -476
  310. package/dist/utils/domain-utils.d.ts +0 -66
  311. package/dist/utils/domain-utils.d.ts.map +0 -1
  312. package/dist/utils/domain-utils.js +0 -164
  313. package/dist/utils/domain-utils.test.d.ts +0 -2
  314. package/dist/utils/domain-utils.test.d.ts.map +0 -1
  315. package/dist/utils/domain-utils.test.js +0 -346
  316. package/dist/utils/file-utils.d.ts +0 -4
  317. package/dist/utils/file-utils.d.ts.map +0 -1
  318. package/dist/utils/file-utils.js +0 -74
  319. package/dist/utils/file-utils.test.d.ts +0 -2
  320. package/dist/utils/file-utils.test.d.ts.map +0 -1
  321. package/dist/utils/file-utils.test.js +0 -51
  322. package/dist/utils/function-utils.d.ts +0 -73
  323. package/dist/utils/function-utils.d.ts.map +0 -1
  324. package/dist/utils/function-utils.js +0 -245
  325. package/dist/utils/function-utils.test.d.ts +0 -2
  326. package/dist/utils/function-utils.test.d.ts.map +0 -1
  327. package/dist/utils/function-utils.test.js +0 -110
  328. package/dist/utils/id-utils.d.ts +0 -13
  329. package/dist/utils/id-utils.d.ts.map +0 -1
  330. package/dist/utils/id-utils.js +0 -22
  331. package/dist/utils/id-utils.test.d.ts +0 -2
  332. package/dist/utils/id-utils.test.d.ts.map +0 -1
  333. package/dist/utils/id-utils.test.js +0 -22
  334. package/dist/utils/pagination-utils.d.ts +0 -37
  335. package/dist/utils/pagination-utils.d.ts.map +0 -1
  336. package/dist/utils/pagination-utils.js +0 -165
  337. package/dist/utils/pagination-utils.test.d.ts +0 -17
  338. package/dist/utils/pagination-utils.test.d.ts.map +0 -1
  339. package/dist/utils/pagination-utils.test.js +0 -461
  340. package/dist/utils/retry-utils.d.ts +0 -45
  341. package/dist/utils/retry-utils.d.ts.map +0 -1
  342. package/dist/utils/retry-utils.js +0 -51
  343. package/dist/utils/retry-utils.test.d.ts +0 -2
  344. package/dist/utils/retry-utils.test.d.ts.map +0 -1
  345. package/dist/utils/retry-utils.test.js +0 -90
  346. package/dist/utils/schema-utils.d.ts +0 -69
  347. package/dist/utils/schema-utils.d.ts.map +0 -1
  348. package/dist/utils/schema-utils.js +0 -72
  349. package/dist/utils/string-utils.d.ts +0 -40
  350. package/dist/utils/string-utils.d.ts.map +0 -1
  351. package/dist/utils/string-utils.js +0 -69
  352. package/dist/utils/string-utils.test.d.ts +0 -2
  353. package/dist/utils/string-utils.test.d.ts.map +0 -1
  354. package/dist/utils/string-utils.test.js +0 -59
  355. package/dist/utils/telemetry-utils.d.ts +0 -44
  356. package/dist/utils/telemetry-utils.d.ts.map +0 -1
  357. package/dist/utils/telemetry-utils.js +0 -55
  358. package/dist/utils/telemetry-utils.test.d.ts +0 -2
  359. package/dist/utils/telemetry-utils.test.d.ts.map +0 -1
  360. package/dist/utils/telemetry-utils.test.js +0 -94
  361. package/dist/utils/url-utils.d.ts +0 -19
  362. package/dist/utils/url-utils.d.ts.map +0 -1
  363. package/dist/utils/url-utils.js +0 -62
  364. package/dist/utils/url-utils.test.d.ts +0 -2
  365. package/dist/utils/url-utils.test.d.ts.map +0 -1
  366. package/dist/utils/url-utils.test.js +0 -103
  367. package/dist/utils/validation.d.ts +0 -4
  368. package/dist/utils/validation.d.ts.map +0 -1
  369. package/dist/utils/validation.js +0 -30
  370. package/dist/utils/validation.test.d.ts +0 -2
  371. package/dist/utils/validation.test.d.ts.map +0 -1
  372. package/dist/utils/validation.test.js +0 -44
@@ -1,848 +0,0 @@
1
- import { describe, it, expect, vi, beforeEach } from "vitest";
2
- import { ZapierValidationError, ZapierAuthenticationError, } from "../../types/errors";
3
- import { listAuthenticationsPlugin } from "./index";
4
- import { createSdk } from "../../sdk";
5
- import { eventEmissionPlugin } from "../eventEmission";
6
- // Mock transport for testing - prevents real HTTP telemetry requests
7
- const mockTransport = {
8
- emit: vi.fn().mockResolvedValue(undefined),
9
- close: vi.fn().mockResolvedValue(undefined),
10
- };
11
- vi.mock("../eventEmission/transport", () => ({
12
- createTransport: vi.fn(() => mockTransport),
13
- }));
14
- // Mock CLI login package - prevents real token resolution requests
15
- vi.mock("@zapier/zapier-sdk-cli-login", () => ({
16
- getToken: vi.fn().mockResolvedValue(undefined),
17
- }));
18
- // Mock response in the new API format (data array, not results)
19
- const mockAuthenticationsResponse = {
20
- data: [
21
- {
22
- id: "123",
23
- date: "2021-01-01",
24
- account_id: "456",
25
- implementation_id: "SlackCLIAPI@1.21.1",
26
- is_invite_only: false,
27
- is_private: false,
28
- shared_with_all: false,
29
- is_expired: "false",
30
- expired_at: null,
31
- label: "My Slack Workspace",
32
- title: "My Slack Workspace",
33
- },
34
- {
35
- id: "789",
36
- date: "2021-02-01",
37
- account_id: "456",
38
- implementation_id: "GitHubAPI@2.1.0",
39
- is_invite_only: false,
40
- is_private: false,
41
- shared_with_all: true,
42
- is_expired: "true",
43
- expired_at: "2021-06-01",
44
- label: "GitHub Integration",
45
- title: "GitHub Integration",
46
- },
47
- ],
48
- nextCursor: undefined,
49
- };
50
- describe("listAuthentications plugin", () => {
51
- let mockApiClient;
52
- let mockGetVersionedImplementationId;
53
- beforeEach(() => {
54
- vi.clearAllMocks();
55
- mockApiClient = {
56
- get: vi.fn().mockResolvedValue(mockAuthenticationsResponse),
57
- };
58
- mockGetVersionedImplementationId = vi
59
- .fn()
60
- .mockResolvedValue("SlackCLIAPI@1.21.1");
61
- });
62
- const apiPlugin = () => ({
63
- context: {
64
- api: mockApiClient,
65
- },
66
- });
67
- const mockResolveAppKeys = vi.fn().mockResolvedValue([]);
68
- const manifestPlugin = () => ({
69
- context: {
70
- manifest: null,
71
- getVersionedImplementationId: mockGetVersionedImplementationId,
72
- resolveAppKeys: mockResolveAppKeys,
73
- updateManifestEntry: vi
74
- .fn()
75
- .mockResolvedValue(["test-key", {}, { apps: {} }]),
76
- addActionEntry: vi.fn().mockResolvedValue(["test-key", {}, { apps: {} }]),
77
- findActionEntry: vi.fn().mockResolvedValue({
78
- key: "test-key",
79
- entry: {},
80
- manifest: { apps: {} },
81
- }),
82
- hasActionEntry: vi.fn().mockResolvedValue(true),
83
- listActionEntries: vi
84
- .fn()
85
- .mockResolvedValue([
86
- ["test-key", { key: "test-key", entry: {}, manifest: { apps: {} } }],
87
- ]),
88
- deleteActionEntry: vi.fn().mockResolvedValue({ apps: {} }),
89
- findManifestEntry: vi
90
- .fn()
91
- .mockResolvedValue([
92
- "test-key",
93
- { key: "test-key", entry: {}, manifest: { apps: {} } },
94
- ]),
95
- readManifestFromFile: vi.fn().mockResolvedValue({ apps: {} }),
96
- },
97
- });
98
- function createTestSdk() {
99
- return createSdk()
100
- .addPlugin(() => ({
101
- context: {
102
- options: {},
103
- },
104
- }))
105
- .addPlugin(apiPlugin)
106
- .addPlugin(eventEmissionPlugin)
107
- .addPlugin(manifestPlugin)
108
- .addPlugin(listAuthenticationsPlugin);
109
- }
110
- describe("schema validation", () => {
111
- it("should pass validation with empty options", async () => {
112
- const sdk = createTestSdk();
113
- const result = await sdk.listAuthentications({});
114
- expect(result.data).toHaveLength(2);
115
- });
116
- it("should handle undefined options", async () => {
117
- const sdk = createTestSdk();
118
- const result = await sdk.listAuthentications();
119
- expect(result.data).toHaveLength(2);
120
- expect(result.data[0]).toMatchObject({
121
- id: "123",
122
- });
123
- });
124
- it("should throw validation error for invalid appKey type", () => {
125
- const sdk = createTestSdk();
126
- expect(() => {
127
- sdk.listAuthentications({
128
- appKey: 123,
129
- });
130
- }).toThrow(ZapierValidationError);
131
- });
132
- it("should throw validation error for invalid search type", () => {
133
- const sdk = createTestSdk();
134
- expect(() => {
135
- sdk.listAuthentications({
136
- search: 123,
137
- });
138
- }).toThrow(ZapierValidationError);
139
- });
140
- it("should throw validation error for invalid title type", () => {
141
- const sdk = createTestSdk();
142
- expect(() => {
143
- sdk.listAuthentications({
144
- title: 123,
145
- });
146
- }).toThrow(ZapierValidationError);
147
- });
148
- it("should throw validation error for invalid accountId type", () => {
149
- const sdk = createTestSdk();
150
- expect(() => {
151
- sdk.listAuthentications({
152
- accountId: 123,
153
- });
154
- }).toThrow(ZapierValidationError);
155
- });
156
- it("should throw validation error for invalid owner type", () => {
157
- const sdk = createTestSdk();
158
- expect(() => {
159
- sdk.listAuthentications({
160
- owner: 123,
161
- });
162
- }).toThrow(ZapierValidationError);
163
- });
164
- it("should throw validation error for invalid authenticationIds type", () => {
165
- const sdk = createTestSdk();
166
- expect(() => {
167
- sdk.listAuthentications({
168
- authenticationIds: "123", // Should be array of strings
169
- });
170
- }).toThrow(ZapierValidationError);
171
- expect(() => {
172
- sdk.listAuthentications({
173
- authenticationIds: [123], // Should be array of strings, not numbers
174
- });
175
- }).toThrow(ZapierValidationError);
176
- });
177
- it("should throw validation error for invalid pageSize", () => {
178
- const sdk = createTestSdk();
179
- expect(() => {
180
- sdk.listAuthentications({
181
- pageSize: 0, // Should be >= 1
182
- });
183
- }).toThrow(ZapierValidationError);
184
- expect(() => {
185
- sdk.listAuthentications({
186
- pageSize: -5, // Should be >= 1
187
- });
188
- }).toThrow(ZapierValidationError);
189
- });
190
- it("should throw validation error for invalid maxItems", () => {
191
- const sdk = createTestSdk();
192
- expect(() => {
193
- sdk.listAuthentications({
194
- maxItems: 0, // Should be >= 1
195
- });
196
- }).toThrow(ZapierValidationError);
197
- expect(() => {
198
- sdk.listAuthentications({
199
- maxItems: -10, // Should be >= 1
200
- });
201
- }).toThrow(ZapierValidationError);
202
- });
203
- it("should pass validation with all valid fields", async () => {
204
- const sdk = createTestSdk();
205
- const result = await sdk.listAuthentications({
206
- appKey: "slack",
207
- authenticationIds: ["123", "456"],
208
- search: "workspace",
209
- title: "My Slack Workspace",
210
- accountId: "acc_123",
211
- owner: "me",
212
- pageSize: 10,
213
- maxItems: 50,
214
- });
215
- expect(result.data).toBeDefined();
216
- });
217
- });
218
- describe("data mapping", () => {
219
- it("should pass through is_expired and expired_at fields", async () => {
220
- const sdk = createTestSdk();
221
- const result = await sdk.listAuthentications();
222
- // API returns these fields directly (no client-side transformation)
223
- expect(result.data[0].is_expired).toBe("false");
224
- expect(result.data[0].expired_at).toBe(null);
225
- expect(result.data[1].is_expired).toBe("true");
226
- expect(result.data[1].expired_at).toBe("2021-06-01");
227
- });
228
- it("should pass through label field when title is missing", async () => {
229
- const responseWithoutTitle = {
230
- ...mockAuthenticationsResponse,
231
- data: [
232
- {
233
- ...mockAuthenticationsResponse.data[0],
234
- title: undefined,
235
- label: "Label Only Auth",
236
- },
237
- ],
238
- nextCursor: undefined,
239
- };
240
- mockApiClient.get = vi.fn().mockResolvedValue(responseWithoutTitle);
241
- const sdk = createTestSdk();
242
- const result = await sdk.listAuthentications({});
243
- // New API passes through fields directly - title coercion happens server-side
244
- expect(result.data[0].title).toBeUndefined();
245
- expect(result.data[0].label).toBe("Label Only Auth");
246
- });
247
- it("should handle authentications with neither title nor label", async () => {
248
- const responseWithoutTitleOrLabel = {
249
- ...mockAuthenticationsResponse,
250
- data: [
251
- {
252
- ...mockAuthenticationsResponse.data[0],
253
- title: undefined,
254
- label: undefined,
255
- },
256
- ],
257
- nextCursor: undefined,
258
- };
259
- mockApiClient.get = vi
260
- .fn()
261
- .mockResolvedValue(responseWithoutTitleOrLabel);
262
- const sdk = createTestSdk();
263
- const result = await sdk.listAuthentications({});
264
- expect(result.data[0].title).toBeUndefined();
265
- });
266
- });
267
- describe("filtering", () => {
268
- it("should pass search parameter to API when provided", async () => {
269
- const sdk = createTestSdk();
270
- await sdk.listAuthentications({ search: "workspace" });
271
- expect(mockApiClient.get).toHaveBeenCalledWith("/api/v0/authentications", expect.objectContaining({
272
- searchParams: expect.objectContaining({
273
- search: "workspace",
274
- }),
275
- }));
276
- });
277
- it("should pass title parameter separately to API", async () => {
278
- const sdk = createTestSdk();
279
- await sdk.listAuthentications({ title: "My Slack Workspace" });
280
- expect(mockApiClient.get).toHaveBeenCalledWith("/api/v0/authentications", expect.objectContaining({
281
- searchParams: expect.objectContaining({
282
- title: "My Slack Workspace",
283
- }),
284
- }));
285
- });
286
- it("should pass both search and title when both provided", async () => {
287
- const sdk = createTestSdk();
288
- await sdk.listAuthentications({
289
- search: "explicit search",
290
- title: "My Title",
291
- });
292
- expect(mockApiClient.get).toHaveBeenCalledWith("/api/v0/authentications", expect.objectContaining({
293
- searchParams: expect.objectContaining({
294
- search: "explicit search",
295
- title: "My Title",
296
- }),
297
- }));
298
- });
299
- it("should pass accountId filter to API", async () => {
300
- const sdk = createTestSdk();
301
- await sdk.listAuthentications({ accountId: "acc_123" });
302
- expect(mockApiClient.get).toHaveBeenCalledWith("/api/v0/authentications", expect.objectContaining({
303
- searchParams: expect.objectContaining({
304
- accountId: "acc_123",
305
- }),
306
- }));
307
- });
308
- it("should pass owner filter to API", async () => {
309
- const sdk = createTestSdk();
310
- await sdk.listAuthentications({ owner: "me" });
311
- expect(mockApiClient.get).toHaveBeenCalledWith("/api/v0/authentications", expect.objectContaining({
312
- searchParams: expect.objectContaining({
313
- owner: "me",
314
- }),
315
- }));
316
- });
317
- it("should pass authenticationIds as comma-separated string to API", async () => {
318
- const sdk = createTestSdk();
319
- await sdk.listAuthentications({
320
- authenticationIds: ["123", "456", "789"],
321
- });
322
- expect(mockApiClient.get).toHaveBeenCalledWith("/api/v0/authentications", expect.objectContaining({
323
- searchParams: expect.objectContaining({
324
- authenticationIds: "123,456,789",
325
- }),
326
- }));
327
- });
328
- it("should not include authenticationIds parameter when array is empty", async () => {
329
- const sdk = createTestSdk();
330
- await sdk.listAuthentications({
331
- authenticationIds: [],
332
- });
333
- expect(mockApiClient.get).toHaveBeenCalledWith("/api/v0/authentications", expect.objectContaining({
334
- searchParams: expect.not.objectContaining({
335
- authenticationIds: expect.anything(),
336
- }),
337
- }));
338
- });
339
- it("should not include undefined optional parameters in searchParams", async () => {
340
- const sdk = createTestSdk();
341
- await sdk.listAuthentications({});
342
- const callArgs = mockApiClient.get.mock.calls[0];
343
- const searchParams = callArgs[1].searchParams;
344
- // Should only have pageSize (default), not undefined params
345
- expect(searchParams).not.toHaveProperty("search");
346
- expect(searchParams).not.toHaveProperty("title");
347
- expect(searchParams).not.toHaveProperty("accountId");
348
- expect(searchParams).not.toHaveProperty("owner");
349
- expect(searchParams).not.toHaveProperty("authenticationIds");
350
- expect(searchParams).not.toHaveProperty("appKey");
351
- });
352
- });
353
- describe("pagination", () => {
354
- it("should handle pagination with maxItems by collecting all items", async () => {
355
- // Mock multiple pages - first page has 2 items, second page has 1 item
356
- mockApiClient.get = vi
357
- .fn()
358
- .mockResolvedValueOnce({
359
- data: mockAuthenticationsResponse.data,
360
- nextCursor: "2",
361
- })
362
- .mockResolvedValueOnce({
363
- data: [
364
- {
365
- id: "999",
366
- date: "2021-03-01",
367
- account_id: "456",
368
- implementation_id: "DropboxAPI@3.0.0",
369
- is_invite_only: false,
370
- is_private: false,
371
- shared_with_all: false,
372
- is_expired: "false",
373
- expired_at: null,
374
- title: "Dropbox Integration",
375
- },
376
- ],
377
- nextCursor: undefined,
378
- });
379
- const sdk = createTestSdk();
380
- // Collect all items using the items() iterator
381
- const items = [];
382
- for await (const item of sdk
383
- .listAuthentications({ maxItems: 3 })
384
- .items()) {
385
- items.push(item);
386
- }
387
- expect(items).toHaveLength(3); // Should stop at maxItems
388
- expect(mockApiClient.get).toHaveBeenCalledTimes(2); // Should fetch both pages
389
- });
390
- it("should return first page when awaited", async () => {
391
- mockApiClient.get = vi.fn().mockResolvedValue({
392
- data: mockAuthenticationsResponse.data,
393
- nextCursor: undefined,
394
- });
395
- const sdk = createTestSdk();
396
- const result = await sdk.listAuthentications({});
397
- // Await returns first page only
398
- expect(result.data).toHaveLength(2);
399
- expect(mockApiClient.get).toHaveBeenCalledTimes(1);
400
- });
401
- it("should support async iteration over pages", async () => {
402
- mockApiClient.get = vi
403
- .fn()
404
- .mockResolvedValueOnce({
405
- data: mockAuthenticationsResponse.data.slice(0, 1),
406
- nextCursor: "1",
407
- })
408
- .mockResolvedValueOnce({
409
- data: mockAuthenticationsResponse.data.slice(1, 2),
410
- nextCursor: undefined,
411
- });
412
- const sdk = createTestSdk();
413
- const pages = [];
414
- for await (const page of sdk.listAuthentications({ pageSize: 1 })) {
415
- pages.push(page);
416
- if (pages.length >= 2)
417
- break;
418
- }
419
- expect(pages).toHaveLength(2);
420
- expect(pages[0].data).toHaveLength(1);
421
- expect(pages[1].data).toHaveLength(1);
422
- expect(pages[0].data[0].id).toBe("123");
423
- expect(pages[1].data[0].id).toBe("789");
424
- });
425
- it("should support async iteration over individual items", async () => {
426
- const sdk = createTestSdk();
427
- const items = [];
428
- for await (const item of sdk
429
- .listAuthentications({ maxItems: 2 })
430
- .items()) {
431
- items.push(item);
432
- }
433
- expect(items).toHaveLength(2);
434
- expect(items[0].id).toBe("123");
435
- expect(items[1].id).toBe("789");
436
- });
437
- it("should set pageSize in searchParams for API calls", async () => {
438
- const sdk = createTestSdk();
439
- await sdk.listAuthentications({ pageSize: 15 });
440
- expect(mockApiClient.get).toHaveBeenCalledWith("/api/v0/authentications", expect.objectContaining({
441
- searchParams: expect.objectContaining({
442
- pageSize: "15",
443
- }),
444
- }));
445
- });
446
- it("should pass cursor as offset parameter", async () => {
447
- mockApiClient.get = vi
448
- .fn()
449
- .mockResolvedValueOnce({
450
- data: mockAuthenticationsResponse.data.slice(0, 1),
451
- nextCursor: "cursor-abc-123",
452
- })
453
- .mockResolvedValueOnce({
454
- data: mockAuthenticationsResponse.data.slice(1, 2),
455
- nextCursor: undefined,
456
- });
457
- const sdk = createTestSdk();
458
- const pages = [];
459
- for await (const page of sdk.listAuthentications({ pageSize: 1 })) {
460
- pages.push(page);
461
- if (pages.length >= 2)
462
- break;
463
- }
464
- // Second call should include the cursor as offset
465
- expect(mockApiClient.get).toHaveBeenNthCalledWith(2, "/api/v0/authentications", expect.objectContaining({
466
- searchParams: expect.objectContaining({
467
- offset: "cursor-abc-123",
468
- }),
469
- }));
470
- });
471
- it("should stop pagination when nextCursor is undefined", async () => {
472
- mockApiClient.get = vi.fn().mockResolvedValue({
473
- data: mockAuthenticationsResponse.data,
474
- nextCursor: undefined,
475
- });
476
- const sdk = createTestSdk();
477
- const pages = [];
478
- for await (const page of sdk.listAuthentications({})) {
479
- pages.push(page);
480
- }
481
- expect(pages).toHaveLength(1);
482
- expect(mockApiClient.get).toHaveBeenCalledTimes(1);
483
- });
484
- });
485
- describe("API integration", () => {
486
- it("should call the correct API endpoint", async () => {
487
- const sdk = createTestSdk();
488
- await sdk.listAuthentications({});
489
- expect(mockApiClient.get).toHaveBeenCalledWith("/api/v0/authentications", expect.any(Object));
490
- });
491
- it("should pass pageSize as string in searchParams", async () => {
492
- const sdk = createTestSdk();
493
- await sdk.listAuthentications({ pageSize: 25 });
494
- expect(mockApiClient.get).toHaveBeenCalledWith("/api/v0/authentications", expect.objectContaining({
495
- searchParams: expect.objectContaining({
496
- pageSize: "25",
497
- }),
498
- }));
499
- });
500
- it("should handle cursor-based pagination with nextCursor", async () => {
501
- mockApiClient.get = vi
502
- .fn()
503
- .mockResolvedValueOnce({
504
- data: mockAuthenticationsResponse.data.slice(0, 1),
505
- nextCursor: "offset-1",
506
- })
507
- .mockResolvedValueOnce({
508
- data: mockAuthenticationsResponse.data.slice(1, 2),
509
- nextCursor: undefined,
510
- });
511
- const sdk = createTestSdk();
512
- // Test that the function can handle multiple pages
513
- let pageCount = 0;
514
- for await (const _page of sdk.listAuthentications({ pageSize: 1 })) {
515
- pageCount++;
516
- if (pageCount >= 2)
517
- break;
518
- }
519
- expect(pageCount).toBe(2);
520
- expect(mockApiClient.get).toHaveBeenCalledTimes(2);
521
- // The second call should include the offset from the nextCursor
522
- expect(mockApiClient.get).toHaveBeenNthCalledWith(2, "/api/v0/authentications", expect.objectContaining({
523
- searchParams: expect.objectContaining({
524
- offset: "offset-1",
525
- }),
526
- }));
527
- });
528
- it("should set authRequired to true in API call options", async () => {
529
- const sdk = createTestSdk();
530
- await sdk.listAuthentications({});
531
- expect(mockApiClient.get).toHaveBeenCalledWith("/api/v0/authentications", expect.objectContaining({
532
- authRequired: true,
533
- }));
534
- });
535
- it("should include customErrorHandler in API call options", async () => {
536
- const sdk = createTestSdk();
537
- await sdk.listAuthentications({});
538
- expect(mockApiClient.get).toHaveBeenCalledWith("/api/v0/authentications", expect.objectContaining({
539
- customErrorHandler: expect.any(Function),
540
- }));
541
- });
542
- });
543
- describe("error handling", () => {
544
- it("should throw ZapierAuthenticationError for 401 responses", async () => {
545
- mockApiClient.get = vi.fn().mockImplementation((_url, options) => {
546
- // Simulate the API client calling the customErrorHandler
547
- const error = options.customErrorHandler({ status: 401 });
548
- if (error)
549
- throw error;
550
- });
551
- const sdk = createTestSdk();
552
- await expect(sdk.listAuthentications({})).rejects.toThrow(ZapierAuthenticationError);
553
- await expect(sdk.listAuthentications({})).rejects.toThrow(/Authentication failed.*HTTP 401/);
554
- });
555
- it("should throw ZapierAuthenticationError for 403 responses", async () => {
556
- mockApiClient.get = vi.fn().mockImplementation((_url, options) => {
557
- // Simulate the API client calling the customErrorHandler
558
- const error = options.customErrorHandler({ status: 403 });
559
- if (error)
560
- throw error;
561
- });
562
- const sdk = createTestSdk();
563
- await expect(sdk.listAuthentications({})).rejects.toThrow(ZapierAuthenticationError);
564
- await expect(sdk.listAuthentications({})).rejects.toThrow(/Access forbidden.*HTTP 403/);
565
- });
566
- it("should return undefined from customErrorHandler for non-401/403 errors", async () => {
567
- let customErrorHandlerResult;
568
- mockApiClient.get = vi.fn().mockImplementation((_url, options) => {
569
- // Capture the customErrorHandler result for 500
570
- customErrorHandlerResult = options.customErrorHandler({ status: 500 });
571
- // Return valid data since we're just testing the handler
572
- return mockAuthenticationsResponse;
573
- });
574
- const sdk = createTestSdk();
575
- await sdk.listAuthentications({});
576
- // The customErrorHandler should return undefined for other status codes
577
- expect(customErrorHandlerResult).toBeUndefined();
578
- });
579
- it("should handle empty data array", async () => {
580
- const emptyResponse = {
581
- data: [],
582
- nextCursor: undefined,
583
- };
584
- mockApiClient.get = vi.fn().mockResolvedValue(emptyResponse);
585
- const sdk = createTestSdk();
586
- const result = await sdk.listAuthentications({});
587
- expect(result.data).toHaveLength(0);
588
- expect(Array.isArray(result.data)).toBe(true);
589
- });
590
- it("should handle API errors gracefully", async () => {
591
- const networkError = new Error("Network error");
592
- mockApiClient.get = vi.fn().mockRejectedValue(networkError);
593
- const sdk = createTestSdk();
594
- await expect(sdk.listAuthentications({})).rejects.toThrow("Network error");
595
- });
596
- });
597
- describe("app key integration", () => {
598
- it("should not add appKey parameter when getVersionedImplementationId returns null", async () => {
599
- mockGetVersionedImplementationId.mockResolvedValue(null);
600
- const sdk = createTestSdk();
601
- await sdk.listAuthentications({ appKey: "slack" });
602
- // Should not add appKey parameter when implementation can't be resolved
603
- expect(mockApiClient.get).toHaveBeenCalledWith("/api/v0/authentications", expect.objectContaining({
604
- searchParams: expect.not.objectContaining({
605
- appKey: expect.any(String),
606
- }),
607
- }));
608
- });
609
- it("should extract versionless app key from versioned implementation ID", async () => {
610
- mockGetVersionedImplementationId.mockResolvedValue("SlackCLIAPI@2.1.3");
611
- const sdk = createTestSdk();
612
- await sdk.listAuthentications({ appKey: "slack" });
613
- expect(mockApiClient.get).toHaveBeenCalledWith("/api/v0/authentications", expect.objectContaining({
614
- searchParams: expect.objectContaining({
615
- appKey: "SlackCLIAPI",
616
- }),
617
- }));
618
- });
619
- it("should handle implementation ID without version", async () => {
620
- mockGetVersionedImplementationId.mockResolvedValue("SlackCLIAPI");
621
- const sdk = createTestSdk();
622
- await sdk.listAuthentications({ appKey: "slack" });
623
- expect(mockApiClient.get).toHaveBeenCalledWith("/api/v0/authentications", expect.objectContaining({
624
- searchParams: expect.objectContaining({
625
- appKey: "SlackCLIAPI",
626
- }),
627
- }));
628
- });
629
- it("should call getVersionedImplementationId with the provided appKey", async () => {
630
- const sdk = createTestSdk();
631
- await sdk.listAuthentications({ appKey: "my-custom-app" });
632
- expect(mockGetVersionedImplementationId).toHaveBeenCalledWith("my-custom-app");
633
- });
634
- it("should not call getVersionedImplementationId when appKey is not provided", async () => {
635
- const sdk = createTestSdk();
636
- await sdk.listAuthentications({});
637
- expect(mockGetVersionedImplementationId).not.toHaveBeenCalled();
638
- });
639
- });
640
- describe("response transformation", () => {
641
- it("should preserve all authentication fields from new API response", async () => {
642
- const authWithAllFields = {
643
- data: [
644
- {
645
- id: "123",
646
- date: "2021-01-01",
647
- lastchanged: "2021-01-02",
648
- account_id: "456",
649
- profile_id: "789",
650
- implementation_id: "SlackCLIAPI@1.21.1",
651
- destination_selected_api: "SlackDestAPI@1.0.0",
652
- is_invite_only: true,
653
- is_private: true,
654
- shared_with_all: false,
655
- is_expired: "true",
656
- is_shared: "false",
657
- expired_at: "2021-06-01",
658
- label: "Auth Label",
659
- title: "Auth Title",
660
- identifier: "auth-identifier",
661
- url: "https://example.com",
662
- groups: "group1,group2",
663
- members: "user1,user2",
664
- permissions: { read: true, write: false },
665
- app_key: "SlackCLIAPI",
666
- app_version: "1.21.1",
667
- },
668
- ],
669
- nextCursor: undefined,
670
- };
671
- mockApiClient.get = vi.fn().mockResolvedValue(authWithAllFields);
672
- const sdk = createTestSdk();
673
- const result = await sdk.listAuthentications({});
674
- const auth = result.data[0];
675
- // Verify all fields are passed through from the new API
676
- expect(auth.id).toBe("123");
677
- expect(auth.date).toBe("2021-01-01");
678
- expect(auth.lastchanged).toBe("2021-01-02");
679
- expect(auth.account_id).toBe("456");
680
- expect(auth.profile_id).toBe("789");
681
- expect(auth.implementation_id).toBe("SlackCLIAPI@1.21.1");
682
- expect(auth.destination_selected_api).toBe("SlackDestAPI@1.0.0");
683
- expect(auth.is_invite_only).toBe(true);
684
- expect(auth.is_private).toBe(true);
685
- expect(auth.shared_with_all).toBe(false);
686
- expect(auth.is_shared).toBe("false");
687
- expect(auth.label).toBe("Auth Label");
688
- expect(auth.title).toBe("Auth Title");
689
- expect(auth.identifier).toBe("auth-identifier");
690
- expect(auth.url).toBe("https://example.com");
691
- expect(auth.groups).toBe("group1,group2");
692
- expect(auth.members).toBe("user1,user2");
693
- expect(auth.permissions).toEqual({ read: true, write: false });
694
- expect(auth.is_expired).toBe("true");
695
- expect(auth.expired_at).toBe("2021-06-01");
696
- expect(auth.app_key).toBe("SlackCLIAPI");
697
- expect(auth.app_version).toBe("1.21.1");
698
- });
699
- it("should handle authentications with minimal fields", async () => {
700
- const minimalAuth = {
701
- data: [
702
- {
703
- id: "100",
704
- account_id: "200",
705
- implementation_id: "TestAPI@1.0.0",
706
- },
707
- ],
708
- nextCursor: undefined,
709
- };
710
- mockApiClient.get = vi.fn().mockResolvedValue(minimalAuth);
711
- const sdk = createTestSdk();
712
- const result = await sdk.listAuthentications({});
713
- const auth = result.data[0];
714
- expect(auth.id).toBe("100");
715
- expect(auth.account_id).toBe("200");
716
- expect(auth.implementation_id).toBe("TestAPI@1.0.0");
717
- });
718
- });
719
- describe("context and metadata", () => {
720
- it("should provide context with meta information", () => {
721
- const sdk = createTestSdk();
722
- const context = sdk.getContext();
723
- expect(context.meta.listAuthentications).toBeDefined();
724
- expect(context.meta.listAuthentications.inputSchema).toBeDefined();
725
- });
726
- it("should include all required metadata properties", () => {
727
- const sdk = createTestSdk();
728
- const context = sdk.getContext();
729
- const meta = context.meta.listAuthentications;
730
- expect(meta.categories).toContain("authentication");
731
- expect(meta.type).toBe("list");
732
- expect(meta.itemType).toBe("Authentication");
733
- expect(meta.inputSchema).toBeDefined();
734
- expect(meta.outputSchema).toBeDefined();
735
- expect(meta.resolvers).toBeDefined();
736
- expect(meta.resolvers.appKey).toBeDefined();
737
- });
738
- });
739
- describe("edge cases", () => {
740
- it("should handle special characters in search parameter", async () => {
741
- const sdk = createTestSdk();
742
- await sdk.listAuthentications({ search: "test@email.com" });
743
- expect(mockApiClient.get).toHaveBeenCalledWith("/api/v0/authentications", expect.objectContaining({
744
- searchParams: expect.objectContaining({
745
- search: "test@email.com",
746
- }),
747
- }));
748
- });
749
- it("should handle special characters in title parameter", async () => {
750
- const sdk = createTestSdk();
751
- await sdk.listAuthentications({ title: "My Auth (Test) #1" });
752
- expect(mockApiClient.get).toHaveBeenCalledWith("/api/v0/authentications", expect.objectContaining({
753
- searchParams: expect.objectContaining({
754
- title: "My Auth (Test) #1",
755
- }),
756
- }));
757
- });
758
- it("should handle single authenticationId in array", async () => {
759
- const sdk = createTestSdk();
760
- await sdk.listAuthentications({ authenticationIds: ["single-id"] });
761
- expect(mockApiClient.get).toHaveBeenCalledWith("/api/v0/authentications", expect.objectContaining({
762
- searchParams: expect.objectContaining({
763
- authenticationIds: "single-id",
764
- }),
765
- }));
766
- });
767
- it("should handle multiple filters combined", async () => {
768
- const sdk = createTestSdk();
769
- await sdk.listAuthentications({
770
- appKey: "slack",
771
- search: "workspace",
772
- title: "My Workspace",
773
- accountId: "acc_123",
774
- owner: "me",
775
- authenticationIds: ["id1", "id2"],
776
- pageSize: 10,
777
- });
778
- expect(mockApiClient.get).toHaveBeenCalledWith("/api/v0/authentications", expect.objectContaining({
779
- searchParams: expect.objectContaining({
780
- appKey: "SlackCLIAPI",
781
- search: "workspace",
782
- title: "My Workspace",
783
- accountId: "acc_123",
784
- owner: "me",
785
- authenticationIds: "id1,id2",
786
- pageSize: "10",
787
- }),
788
- }));
789
- });
790
- it("should handle maxItems less than pageSize", async () => {
791
- mockApiClient.get = vi.fn().mockResolvedValue({
792
- data: mockAuthenticationsResponse.data,
793
- nextCursor: "next-page",
794
- });
795
- const sdk = createTestSdk();
796
- const items = [];
797
- for await (const item of sdk
798
- .listAuthentications({ pageSize: 10, maxItems: 1 })
799
- .items()) {
800
- items.push(item);
801
- }
802
- expect(items).toHaveLength(1);
803
- // Should only make one API call even though there's a next page
804
- expect(mockApiClient.get).toHaveBeenCalledTimes(1);
805
- });
806
- it("should handle owner filter with user ID instead of 'me'", async () => {
807
- const sdk = createTestSdk();
808
- await sdk.listAuthentications({ owner: "user_12345" });
809
- expect(mockApiClient.get).toHaveBeenCalledWith("/api/v0/authentications", expect.objectContaining({
810
- searchParams: expect.objectContaining({
811
- owner: "user_12345",
812
- }),
813
- }));
814
- });
815
- it("should pass through nextCursor in response", async () => {
816
- mockApiClient.get = vi.fn().mockResolvedValue({
817
- data: mockAuthenticationsResponse.data,
818
- nextCursor: "cursor-for-next-page",
819
- });
820
- const sdk = createTestSdk();
821
- const result = await sdk.listAuthentications({});
822
- expect(result.nextCursor).toBe("cursor-for-next-page");
823
- });
824
- it("should handle undefined nextCursor in response", async () => {
825
- mockApiClient.get = vi.fn().mockResolvedValue({
826
- data: mockAuthenticationsResponse.data,
827
- nextCursor: undefined,
828
- });
829
- const sdk = createTestSdk();
830
- const result = await sdk.listAuthentications({});
831
- expect(result.nextCursor).toBeUndefined();
832
- });
833
- });
834
- describe("concurrent requests", () => {
835
- it("should handle multiple concurrent listAuthentications calls", async () => {
836
- const sdk = createTestSdk();
837
- const [result1, result2, result3] = await Promise.all([
838
- sdk.listAuthentications({ search: "first" }),
839
- sdk.listAuthentications({ search: "second" }),
840
- sdk.listAuthentications({ search: "third" }),
841
- ]);
842
- expect(result1.data).toHaveLength(2);
843
- expect(result2.data).toHaveLength(2);
844
- expect(result3.data).toHaveLength(2);
845
- expect(mockApiClient.get).toHaveBeenCalledTimes(3);
846
- });
847
- });
848
- });