@zapier/zapier-sdk 0.18.3 → 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 (417) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/README.md +44 -32
  3. package/dist/index.cjs +658 -693
  4. package/dist/index.d.mts +272 -138
  5. package/dist/index.d.ts +2541 -40
  6. package/dist/index.mjs +638 -692
  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.integration.test.d.ts +0 -5
  17. package/dist/api/client.integration.test.d.ts.map +0 -1
  18. package/dist/api/client.integration.test.js +0 -318
  19. package/dist/api/client.js +0 -374
  20. package/dist/api/client.methods.test.d.ts +0 -2
  21. package/dist/api/client.methods.test.d.ts.map +0 -1
  22. package/dist/api/client.methods.test.js +0 -158
  23. package/dist/api/client.test.d.ts +0 -2
  24. package/dist/api/client.test.d.ts.map +0 -1
  25. package/dist/api/client.test.js +0 -96
  26. package/dist/api/debug.d.ts +0 -14
  27. package/dist/api/debug.d.ts.map +0 -1
  28. package/dist/api/debug.js +0 -131
  29. package/dist/api/debug.test.d.ts +0 -2
  30. package/dist/api/debug.test.d.ts.map +0 -1
  31. package/dist/api/debug.test.js +0 -59
  32. package/dist/api/index.d.ts +0 -30
  33. package/dist/api/index.d.ts.map +0 -1
  34. package/dist/api/index.js +0 -43
  35. package/dist/api/polling.d.ts +0 -46
  36. package/dist/api/polling.d.ts.map +0 -1
  37. package/dist/api/polling.js +0 -139
  38. package/dist/api/polling.test.d.ts +0 -2
  39. package/dist/api/polling.test.d.ts.map +0 -1
  40. package/dist/api/polling.test.js +0 -318
  41. package/dist/api/router.d.ts +0 -16
  42. package/dist/api/router.d.ts.map +0 -1
  43. package/dist/api/router.js +0 -31
  44. package/dist/api/router.test.d.ts +0 -2
  45. package/dist/api/router.test.d.ts.map +0 -1
  46. package/dist/api/router.test.js +0 -103
  47. package/dist/api/schemas.d.ts +0 -531
  48. package/dist/api/schemas.d.ts.map +0 -1
  49. package/dist/api/schemas.js +0 -389
  50. package/dist/api/types.d.ts +0 -82
  51. package/dist/api/types.d.ts.map +0 -1
  52. package/dist/api/types.js +0 -1
  53. package/dist/auth.d.ts +0 -52
  54. package/dist/auth.d.ts.map +0 -1
  55. package/dist/auth.js +0 -72
  56. package/dist/auth.test.d.ts +0 -2
  57. package/dist/auth.test.d.ts.map +0 -1
  58. package/dist/auth.test.js +0 -102
  59. package/dist/constants.d.ts +0 -14
  60. package/dist/constants.d.ts.map +0 -1
  61. package/dist/constants.js +0 -13
  62. package/dist/index.d.ts.map +0 -1
  63. package/dist/index.js +0 -42
  64. package/dist/plugins/api/index.d.ts +0 -12
  65. package/dist/plugins/api/index.d.ts.map +0 -1
  66. package/dist/plugins/api/index.js +0 -24
  67. package/dist/plugins/apps/index.d.ts +0 -15
  68. package/dist/plugins/apps/index.d.ts.map +0 -1
  69. package/dist/plugins/apps/index.js +0 -112
  70. package/dist/plugins/apps/schemas.d.ts +0 -42
  71. package/dist/plugins/apps/schemas.d.ts.map +0 -1
  72. package/dist/plugins/apps/schemas.js +0 -14
  73. package/dist/plugins/eventEmission/builders.d.ts +0 -14
  74. package/dist/plugins/eventEmission/builders.d.ts.map +0 -1
  75. package/dist/plugins/eventEmission/builders.js +0 -109
  76. package/dist/plugins/eventEmission/index.d.ts +0 -38
  77. package/dist/plugins/eventEmission/index.d.ts.map +0 -1
  78. package/dist/plugins/eventEmission/index.js +0 -336
  79. package/dist/plugins/eventEmission/index.test.d.ts +0 -5
  80. package/dist/plugins/eventEmission/index.test.d.ts.map +0 -1
  81. package/dist/plugins/eventEmission/index.test.js +0 -581
  82. package/dist/plugins/eventEmission/transport.d.ts +0 -27
  83. package/dist/plugins/eventEmission/transport.d.ts.map +0 -1
  84. package/dist/plugins/eventEmission/transport.js +0 -104
  85. package/dist/plugins/eventEmission/transport.test.d.ts +0 -5
  86. package/dist/plugins/eventEmission/transport.test.d.ts.map +0 -1
  87. package/dist/plugins/eventEmission/transport.test.js +0 -164
  88. package/dist/plugins/eventEmission/types.d.ts +0 -63
  89. package/dist/plugins/eventEmission/types.d.ts.map +0 -1
  90. package/dist/plugins/eventEmission/types.js +0 -1
  91. package/dist/plugins/eventEmission/utils.d.ts +0 -45
  92. package/dist/plugins/eventEmission/utils.d.ts.map +0 -1
  93. package/dist/plugins/eventEmission/utils.js +0 -114
  94. package/dist/plugins/fetch/index.d.ts +0 -36
  95. package/dist/plugins/fetch/index.d.ts.map +0 -1
  96. package/dist/plugins/fetch/index.js +0 -62
  97. package/dist/plugins/fetch/schemas.d.ts +0 -19
  98. package/dist/plugins/fetch/schemas.d.ts.map +0 -1
  99. package/dist/plugins/fetch/schemas.js +0 -31
  100. package/dist/plugins/findFirstAuthentication/index.d.ts +0 -21
  101. package/dist/plugins/findFirstAuthentication/index.d.ts.map +0 -1
  102. package/dist/plugins/findFirstAuthentication/index.js +0 -36
  103. package/dist/plugins/findFirstAuthentication/index.test.d.ts +0 -2
  104. package/dist/plugins/findFirstAuthentication/index.test.d.ts.map +0 -1
  105. package/dist/plugins/findFirstAuthentication/index.test.js +0 -177
  106. package/dist/plugins/findFirstAuthentication/schemas.d.ts +0 -20
  107. package/dist/plugins/findFirstAuthentication/schemas.d.ts.map +0 -1
  108. package/dist/plugins/findFirstAuthentication/schemas.js +0 -18
  109. package/dist/plugins/findUniqueAuthentication/index.d.ts +0 -21
  110. package/dist/plugins/findUniqueAuthentication/index.d.ts.map +0 -1
  111. package/dist/plugins/findUniqueAuthentication/index.js +0 -39
  112. package/dist/plugins/findUniqueAuthentication/index.test.d.ts +0 -2
  113. package/dist/plugins/findUniqueAuthentication/index.test.d.ts.map +0 -1
  114. package/dist/plugins/findUniqueAuthentication/index.test.js +0 -159
  115. package/dist/plugins/findUniqueAuthentication/schemas.d.ts +0 -20
  116. package/dist/plugins/findUniqueAuthentication/schemas.d.ts.map +0 -1
  117. package/dist/plugins/findUniqueAuthentication/schemas.js +0 -18
  118. package/dist/plugins/getAction/index.d.ts +0 -25
  119. package/dist/plugins/getAction/index.d.ts.map +0 -1
  120. package/dist/plugins/getAction/index.js +0 -42
  121. package/dist/plugins/getAction/index.test.d.ts +0 -2
  122. package/dist/plugins/getAction/index.test.d.ts.map +0 -1
  123. package/dist/plugins/getAction/index.test.js +0 -211
  124. package/dist/plugins/getAction/schemas.d.ts +0 -30
  125. package/dist/plugins/getAction/schemas.d.ts.map +0 -1
  126. package/dist/plugins/getAction/schemas.js +0 -12
  127. package/dist/plugins/getApp/index.d.ts +0 -21
  128. package/dist/plugins/getApp/index.d.ts.map +0 -1
  129. package/dist/plugins/getApp/index.js +0 -44
  130. package/dist/plugins/getApp/index.test.d.ts +0 -2
  131. package/dist/plugins/getApp/index.test.d.ts.map +0 -1
  132. package/dist/plugins/getApp/index.test.js +0 -157
  133. package/dist/plugins/getApp/schemas.d.ts +0 -16
  134. package/dist/plugins/getApp/schemas.d.ts.map +0 -1
  135. package/dist/plugins/getApp/schemas.js +0 -8
  136. package/dist/plugins/getAuthentication/index.d.ts +0 -21
  137. package/dist/plugins/getAuthentication/index.d.ts.map +0 -1
  138. package/dist/plugins/getAuthentication/index.js +0 -29
  139. package/dist/plugins/getAuthentication/index.test.d.ts +0 -2
  140. package/dist/plugins/getAuthentication/index.test.d.ts.map +0 -1
  141. package/dist/plugins/getAuthentication/index.test.js +0 -106
  142. package/dist/plugins/getAuthentication/schemas.d.ts +0 -7
  143. package/dist/plugins/getAuthentication/schemas.d.ts.map +0 -1
  144. package/dist/plugins/getAuthentication/schemas.js +0 -1
  145. package/dist/plugins/getInputFieldsSchema/index.d.ts +0 -23
  146. package/dist/plugins/getInputFieldsSchema/index.d.ts.map +0 -1
  147. package/dist/plugins/getInputFieldsSchema/index.js +0 -53
  148. package/dist/plugins/getInputFieldsSchema/index.test.d.ts +0 -2
  149. package/dist/plugins/getInputFieldsSchema/index.test.d.ts.map +0 -1
  150. package/dist/plugins/getInputFieldsSchema/index.test.js +0 -291
  151. package/dist/plugins/getInputFieldsSchema/schemas.d.ts +0 -28
  152. package/dist/plugins/getInputFieldsSchema/schemas.d.ts.map +0 -1
  153. package/dist/plugins/getInputFieldsSchema/schemas.js +0 -13
  154. package/dist/plugins/getProfile/index.d.ts +0 -25
  155. package/dist/plugins/getProfile/index.d.ts.map +0 -1
  156. package/dist/plugins/getProfile/index.js +0 -39
  157. package/dist/plugins/getProfile/schemas.d.ts +0 -13
  158. package/dist/plugins/getProfile/schemas.d.ts.map +0 -1
  159. package/dist/plugins/getProfile/schemas.js +0 -6
  160. package/dist/plugins/listActions/index.d.ts +0 -30
  161. package/dist/plugins/listActions/index.d.ts.map +0 -1
  162. package/dist/plugins/listActions/index.js +0 -75
  163. package/dist/plugins/listActions/index.test.d.ts +0 -2
  164. package/dist/plugins/listActions/index.test.d.ts.map +0 -1
  165. package/dist/plugins/listActions/index.test.js +0 -453
  166. package/dist/plugins/listActions/schemas.d.ts +0 -35
  167. package/dist/plugins/listActions/schemas.d.ts.map +0 -1
  168. package/dist/plugins/listActions/schemas.js +0 -22
  169. package/dist/plugins/listApps/index.d.ts +0 -25
  170. package/dist/plugins/listApps/index.d.ts.map +0 -1
  171. package/dist/plugins/listApps/index.js +0 -69
  172. package/dist/plugins/listApps/index.test.d.ts +0 -2
  173. package/dist/plugins/listApps/index.test.d.ts.map +0 -1
  174. package/dist/plugins/listApps/index.test.js +0 -141
  175. package/dist/plugins/listApps/schemas.d.ts +0 -26
  176. package/dist/plugins/listApps/schemas.d.ts.map +0 -1
  177. package/dist/plugins/listApps/schemas.js +0 -19
  178. package/dist/plugins/listAuthentications/index.d.ts +0 -24
  179. package/dist/plugins/listAuthentications/index.d.ts.map +0 -1
  180. package/dist/plugins/listAuthentications/index.js +0 -77
  181. package/dist/plugins/listAuthentications/index.test.d.ts +0 -2
  182. package/dist/plugins/listAuthentications/index.test.d.ts.map +0 -1
  183. package/dist/plugins/listAuthentications/index.test.js +0 -832
  184. package/dist/plugins/listAuthentications/schemas.d.ts +0 -30
  185. package/dist/plugins/listAuthentications/schemas.d.ts.map +0 -1
  186. package/dist/plugins/listAuthentications/schemas.js +0 -32
  187. package/dist/plugins/listInputFieldChoices/index.d.ts +0 -33
  188. package/dist/plugins/listInputFieldChoices/index.d.ts.map +0 -1
  189. package/dist/plugins/listInputFieldChoices/index.js +0 -115
  190. package/dist/plugins/listInputFieldChoices/index.test.d.ts +0 -2
  191. package/dist/plugins/listInputFieldChoices/index.test.d.ts.map +0 -1
  192. package/dist/plugins/listInputFieldChoices/index.test.js +0 -717
  193. package/dist/plugins/listInputFieldChoices/schemas.d.ts +0 -43
  194. package/dist/plugins/listInputFieldChoices/schemas.d.ts.map +0 -1
  195. package/dist/plugins/listInputFieldChoices/schemas.js +0 -65
  196. package/dist/plugins/listInputFields/index.d.ts +0 -34
  197. package/dist/plugins/listInputFields/index.d.ts.map +0 -1
  198. package/dist/plugins/listInputFields/index.js +0 -204
  199. package/dist/plugins/listInputFields/index.test.d.ts +0 -2
  200. package/dist/plugins/listInputFields/index.test.d.ts.map +0 -1
  201. package/dist/plugins/listInputFields/index.test.js +0 -359
  202. package/dist/plugins/listInputFields/schemas.d.ts +0 -35
  203. package/dist/plugins/listInputFields/schemas.d.ts.map +0 -1
  204. package/dist/plugins/listInputFields/schemas.js +0 -23
  205. package/dist/plugins/manifest/index.d.ts +0 -85
  206. package/dist/plugins/manifest/index.d.ts.map +0 -1
  207. package/dist/plugins/manifest/index.js +0 -376
  208. package/dist/plugins/manifest/index.test.d.ts +0 -2
  209. package/dist/plugins/manifest/index.test.d.ts.map +0 -1
  210. package/dist/plugins/manifest/index.test.js +0 -1139
  211. package/dist/plugins/manifest/schemas.d.ts +0 -57
  212. package/dist/plugins/manifest/schemas.d.ts.map +0 -1
  213. package/dist/plugins/manifest/schemas.js +0 -50
  214. package/dist/plugins/registry/index.d.ts +0 -21
  215. package/dist/plugins/registry/index.d.ts.map +0 -1
  216. package/dist/plugins/registry/index.js +0 -117
  217. package/dist/plugins/request/index.d.ts +0 -21
  218. package/dist/plugins/request/index.d.ts.map +0 -1
  219. package/dist/plugins/request/index.js +0 -76
  220. package/dist/plugins/request/index.test.d.ts +0 -2
  221. package/dist/plugins/request/index.test.d.ts.map +0 -1
  222. package/dist/plugins/request/index.test.js +0 -337
  223. package/dist/plugins/request/schemas.d.ts +0 -54
  224. package/dist/plugins/request/schemas.d.ts.map +0 -1
  225. package/dist/plugins/request/schemas.js +0 -41
  226. package/dist/plugins/runAction/index.d.ts +0 -33
  227. package/dist/plugins/runAction/index.d.ts.map +0 -1
  228. package/dist/plugins/runAction/index.js +0 -108
  229. package/dist/plugins/runAction/index.test.d.ts +0 -2
  230. package/dist/plugins/runAction/index.test.d.ts.map +0 -1
  231. package/dist/plugins/runAction/index.test.js +0 -333
  232. package/dist/plugins/runAction/schemas.d.ts +0 -34
  233. package/dist/plugins/runAction/schemas.d.ts.map +0 -1
  234. package/dist/plugins/runAction/schemas.js +0 -23
  235. package/dist/resolvers/actionKey.d.ts +0 -15
  236. package/dist/resolvers/actionKey.d.ts.map +0 -1
  237. package/dist/resolvers/actionKey.js +0 -19
  238. package/dist/resolvers/actionType.d.ts +0 -10
  239. package/dist/resolvers/actionType.d.ts.map +0 -1
  240. package/dist/resolvers/actionType.js +0 -21
  241. package/dist/resolvers/appKey.d.ts +0 -3
  242. package/dist/resolvers/appKey.d.ts.map +0 -1
  243. package/dist/resolvers/appKey.js +0 -5
  244. package/dist/resolvers/authenticationId.d.ts +0 -9
  245. package/dist/resolvers/authenticationId.d.ts.map +0 -1
  246. package/dist/resolvers/authenticationId.js +0 -42
  247. package/dist/resolvers/index.d.ts +0 -8
  248. package/dist/resolvers/index.d.ts.map +0 -1
  249. package/dist/resolvers/index.js +0 -8
  250. package/dist/resolvers/inputFieldKey.d.ts +0 -11
  251. package/dist/resolvers/inputFieldKey.d.ts.map +0 -1
  252. package/dist/resolvers/inputFieldKey.js +0 -47
  253. package/dist/resolvers/inputs.d.ts +0 -17
  254. package/dist/resolvers/inputs.d.ts.map +0 -1
  255. package/dist/resolvers/inputs.js +0 -50
  256. package/dist/schemas/Action.d.ts +0 -24
  257. package/dist/schemas/Action.d.ts.map +0 -1
  258. package/dist/schemas/Action.js +0 -40
  259. package/dist/schemas/App.d.ts +0 -57
  260. package/dist/schemas/App.d.ts.map +0 -1
  261. package/dist/schemas/App.js +0 -31
  262. package/dist/schemas/Auth.d.ts +0 -55
  263. package/dist/schemas/Auth.d.ts.map +0 -1
  264. package/dist/schemas/Auth.js +0 -33
  265. package/dist/schemas/Field.d.ts +0 -61
  266. package/dist/schemas/Field.d.ts.map +0 -1
  267. package/dist/schemas/Field.js +0 -116
  268. package/dist/schemas/Run.d.ts +0 -3
  269. package/dist/schemas/Run.d.ts.map +0 -1
  270. package/dist/schemas/Run.js +0 -31
  271. package/dist/schemas/UserProfile.d.ts +0 -13
  272. package/dist/schemas/UserProfile.d.ts.map +0 -1
  273. package/dist/schemas/UserProfile.js +0 -32
  274. package/dist/sdk.d.ts +0 -146
  275. package/dist/sdk.d.ts.map +0 -1
  276. package/dist/sdk.js +0 -112
  277. package/dist/sdk.test.d.ts +0 -2
  278. package/dist/sdk.test.d.ts.map +0 -1
  279. package/dist/sdk.test.js +0 -255
  280. package/dist/services/implementations.d.ts +0 -63
  281. package/dist/services/implementations.d.ts.map +0 -1
  282. package/dist/services/implementations.js +0 -80
  283. package/dist/temporary-internal-core/handlers/listApps.d.ts +0 -67
  284. package/dist/temporary-internal-core/handlers/listApps.d.ts.map +0 -1
  285. package/dist/temporary-internal-core/handlers/listApps.js +0 -134
  286. package/dist/temporary-internal-core/handlers/listApps.test.d.ts +0 -2
  287. package/dist/temporary-internal-core/handlers/listApps.test.d.ts.map +0 -1
  288. package/dist/temporary-internal-core/handlers/listApps.test.js +0 -367
  289. package/dist/temporary-internal-core/index.d.ts +0 -18
  290. package/dist/temporary-internal-core/index.d.ts.map +0 -1
  291. package/dist/temporary-internal-core/index.js +0 -18
  292. package/dist/temporary-internal-core/schemas/apps/index.d.ts +0 -175
  293. package/dist/temporary-internal-core/schemas/apps/index.d.ts.map +0 -1
  294. package/dist/temporary-internal-core/schemas/apps/index.js +0 -97
  295. package/dist/temporary-internal-core/schemas/errors/index.d.ts +0 -139
  296. package/dist/temporary-internal-core/schemas/errors/index.d.ts.map +0 -1
  297. package/dist/temporary-internal-core/schemas/errors/index.js +0 -129
  298. package/dist/temporary-internal-core/schemas/implementations/index.d.ts +0 -127
  299. package/dist/temporary-internal-core/schemas/implementations/index.d.ts.map +0 -1
  300. package/dist/temporary-internal-core/schemas/implementations/index.js +0 -79
  301. package/dist/temporary-internal-core/types/handler.d.ts +0 -51
  302. package/dist/temporary-internal-core/types/handler.d.ts.map +0 -1
  303. package/dist/temporary-internal-core/types/handler.js +0 -8
  304. package/dist/temporary-internal-core/types/index.d.ts +0 -5
  305. package/dist/temporary-internal-core/types/index.d.ts.map +0 -1
  306. package/dist/temporary-internal-core/types/index.js +0 -4
  307. package/dist/temporary-internal-core/utils/app-locators.d.ts +0 -34
  308. package/dist/temporary-internal-core/utils/app-locators.d.ts.map +0 -1
  309. package/dist/temporary-internal-core/utils/app-locators.js +0 -39
  310. package/dist/temporary-internal-core/utils/string-utils.d.ts +0 -28
  311. package/dist/temporary-internal-core/utils/string-utils.d.ts.map +0 -1
  312. package/dist/temporary-internal-core/utils/string-utils.js +0 -52
  313. package/dist/temporary-internal-core/utils/transformations.d.ts +0 -18
  314. package/dist/temporary-internal-core/utils/transformations.d.ts.map +0 -1
  315. package/dist/temporary-internal-core/utils/transformations.js +0 -36
  316. package/dist/types/domain.d.ts +0 -52
  317. package/dist/types/domain.d.ts.map +0 -1
  318. package/dist/types/domain.js +0 -1
  319. package/dist/types/domain.test.d.ts +0 -2
  320. package/dist/types/domain.test.d.ts.map +0 -1
  321. package/dist/types/domain.test.js +0 -39
  322. package/dist/types/errors.d.ts +0 -143
  323. package/dist/types/errors.d.ts.map +0 -1
  324. package/dist/types/errors.js +0 -187
  325. package/dist/types/events.d.ts +0 -38
  326. package/dist/types/events.d.ts.map +0 -1
  327. package/dist/types/events.js +0 -7
  328. package/dist/types/functions.d.ts +0 -27
  329. package/dist/types/functions.d.ts.map +0 -1
  330. package/dist/types/functions.js +0 -1
  331. package/dist/types/plugin.d.ts +0 -75
  332. package/dist/types/plugin.d.ts.map +0 -1
  333. package/dist/types/plugin.js +0 -9
  334. package/dist/types/properties.d.ts +0 -33
  335. package/dist/types/properties.d.ts.map +0 -1
  336. package/dist/types/properties.js +0 -52
  337. package/dist/types/sdk.d.ts +0 -69
  338. package/dist/types/sdk.d.ts.map +0 -1
  339. package/dist/types/sdk.js +0 -4
  340. package/dist/types/telemetry-events.d.ts +0 -105
  341. package/dist/types/telemetry-events.d.ts.map +0 -1
  342. package/dist/types/telemetry-events.js +0 -8
  343. package/dist/utils/array-utils.d.ts +0 -31
  344. package/dist/utils/array-utils.d.ts.map +0 -1
  345. package/dist/utils/array-utils.js +0 -36
  346. package/dist/utils/array-utils.test.d.ts +0 -2
  347. package/dist/utils/array-utils.test.d.ts.map +0 -1
  348. package/dist/utils/array-utils.test.js +0 -107
  349. package/dist/utils/batch-utils.d.ts +0 -72
  350. package/dist/utils/batch-utils.d.ts.map +0 -1
  351. package/dist/utils/batch-utils.js +0 -162
  352. package/dist/utils/batch-utils.test.d.ts +0 -2
  353. package/dist/utils/batch-utils.test.d.ts.map +0 -1
  354. package/dist/utils/batch-utils.test.js +0 -476
  355. package/dist/utils/domain-utils.d.ts +0 -66
  356. package/dist/utils/domain-utils.d.ts.map +0 -1
  357. package/dist/utils/domain-utils.js +0 -164
  358. package/dist/utils/domain-utils.test.d.ts +0 -2
  359. package/dist/utils/domain-utils.test.d.ts.map +0 -1
  360. package/dist/utils/domain-utils.test.js +0 -346
  361. package/dist/utils/file-utils.d.ts +0 -4
  362. package/dist/utils/file-utils.d.ts.map +0 -1
  363. package/dist/utils/file-utils.js +0 -74
  364. package/dist/utils/file-utils.test.d.ts +0 -2
  365. package/dist/utils/file-utils.test.d.ts.map +0 -1
  366. package/dist/utils/file-utils.test.js +0 -51
  367. package/dist/utils/function-utils.d.ts +0 -73
  368. package/dist/utils/function-utils.d.ts.map +0 -1
  369. package/dist/utils/function-utils.js +0 -245
  370. package/dist/utils/function-utils.test.d.ts +0 -2
  371. package/dist/utils/function-utils.test.d.ts.map +0 -1
  372. package/dist/utils/function-utils.test.js +0 -110
  373. package/dist/utils/id-utils.d.ts +0 -13
  374. package/dist/utils/id-utils.d.ts.map +0 -1
  375. package/dist/utils/id-utils.js +0 -22
  376. package/dist/utils/id-utils.test.d.ts +0 -2
  377. package/dist/utils/id-utils.test.d.ts.map +0 -1
  378. package/dist/utils/id-utils.test.js +0 -22
  379. package/dist/utils/pagination-utils.d.ts +0 -37
  380. package/dist/utils/pagination-utils.d.ts.map +0 -1
  381. package/dist/utils/pagination-utils.js +0 -165
  382. package/dist/utils/pagination-utils.test.d.ts +0 -17
  383. package/dist/utils/pagination-utils.test.d.ts.map +0 -1
  384. package/dist/utils/pagination-utils.test.js +0 -461
  385. package/dist/utils/retry-utils.d.ts +0 -45
  386. package/dist/utils/retry-utils.d.ts.map +0 -1
  387. package/dist/utils/retry-utils.js +0 -51
  388. package/dist/utils/retry-utils.test.d.ts +0 -2
  389. package/dist/utils/retry-utils.test.d.ts.map +0 -1
  390. package/dist/utils/retry-utils.test.js +0 -90
  391. package/dist/utils/schema-utils.d.ts +0 -69
  392. package/dist/utils/schema-utils.d.ts.map +0 -1
  393. package/dist/utils/schema-utils.js +0 -72
  394. package/dist/utils/string-utils.d.ts +0 -40
  395. package/dist/utils/string-utils.d.ts.map +0 -1
  396. package/dist/utils/string-utils.js +0 -69
  397. package/dist/utils/string-utils.test.d.ts +0 -2
  398. package/dist/utils/string-utils.test.d.ts.map +0 -1
  399. package/dist/utils/string-utils.test.js +0 -59
  400. package/dist/utils/telemetry-utils.d.ts +0 -44
  401. package/dist/utils/telemetry-utils.d.ts.map +0 -1
  402. package/dist/utils/telemetry-utils.js +0 -55
  403. package/dist/utils/telemetry-utils.test.d.ts +0 -2
  404. package/dist/utils/telemetry-utils.test.d.ts.map +0 -1
  405. package/dist/utils/telemetry-utils.test.js +0 -94
  406. package/dist/utils/url-utils.d.ts +0 -19
  407. package/dist/utils/url-utils.d.ts.map +0 -1
  408. package/dist/utils/url-utils.js +0 -62
  409. package/dist/utils/url-utils.test.d.ts +0 -2
  410. package/dist/utils/url-utils.test.d.ts.map +0 -1
  411. package/dist/utils/url-utils.test.js +0 -103
  412. package/dist/utils/validation.d.ts +0 -4
  413. package/dist/utils/validation.d.ts.map +0 -1
  414. package/dist/utils/validation.js +0 -30
  415. package/dist/utils/validation.test.d.ts +0 -2
  416. package/dist/utils/validation.test.d.ts.map +0 -1
  417. package/dist/utils/validation.test.js +0 -44
@@ -1,1139 +0,0 @@
1
- import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
2
- import { manifestPlugin, readManifestFromFile, findManifestEntry, getPreferredManifestEntryKey, } from "./index";
3
- import { createSdk } from "../../sdk";
4
- import { eventEmissionPlugin } from "../eventEmission";
5
- // Mock file-utils module
6
- vi.mock("../../utils/file-utils", () => ({
7
- readFile: vi.fn(),
8
- writeFile: vi.fn(),
9
- resolve: vi.fn((path) => Promise.resolve(`/resolved/${path}`)),
10
- }));
11
- import { readFile, resolve } from "../../utils/file-utils";
12
- const mockReadFile = vi.mocked(readFile);
13
- const mockResolve = vi.mocked(resolve);
14
- const mockResolveAppKeys = vi.fn();
15
- describe("manifestPlugin", () => {
16
- const mockManifest = {
17
- apps: {
18
- slack: {
19
- implementationName: "SlackCLIAPI",
20
- version: "1.21.1",
21
- },
22
- "google-sheets": {
23
- implementationName: "GoogleSheetsCLIAPI",
24
- version: "2.0.0",
25
- },
26
- },
27
- };
28
- const mockManifestContent = JSON.stringify(mockManifest);
29
- let mockApiClient;
30
- let mockSdk;
31
- beforeEach(() => {
32
- vi.clearAllMocks();
33
- vi.spyOn(console, "warn").mockImplementation(() => { });
34
- mockApiClient = {
35
- get: vi.fn().mockImplementation((url, options) => {
36
- if (url === "/zapier/api/v4/implementations/") {
37
- // Mock for manifest entries (versioned)
38
- return Promise.resolve({
39
- count: 1,
40
- next: null,
41
- previous: null,
42
- results: [
43
- {
44
- selected_api: "SlackCLIAPI@1.29.0",
45
- app_id: null,
46
- service_id: null,
47
- auth_type: "oauth",
48
- auth_fields: [
49
- {
50
- key: "access_token",
51
- required: true,
52
- type: "unicode",
53
- computed: true,
54
- },
55
- ],
56
- is_deprecated: false,
57
- is_private_only: false,
58
- is_invite_only: false,
59
- is_beta: false,
60
- is_premium: false,
61
- is_hidden: false,
62
- name: "Slack (1.29.0)",
63
- name_clean: "Slack",
64
- version: "1.29.0",
65
- slug: null,
66
- images: {
67
- url_16x16: "https://zapier-images.imgix.net/storage/services/6cf3f5a461feadfba7abc93c4c395b33_2.png?auto=format%2Ccompress&fit=crop&h=16&ixlib=python-3.0.0&q=50&w=16",
68
- url_32x32: "https://zapier-images.imgix.net/storage/services/6cf3f5a461feadfba7abc93c4c395b33_2.png?auto=format%2Ccompress&fit=crop&h=32&ixlib=python-3.0.0&q=50&w=32",
69
- url_64x64: "https://zapier-images.imgix.net/storage/services/6cf3f5a461feadfba7abc93c4c395b33_2.png?auto=format%2Ccompress&fit=crop&h=64&ixlib=python-3.0.0&q=50&w=64",
70
- url_128x128: "https://zapier-images.imgix.net/storage/services/6cf3f5a461feadfba7abc93c4c395b33_2.png?auto=format%2Ccompress&fit=crop&h=128&ixlib=python-3.0.0&q=50&w=128",
71
- },
72
- primary_color: null,
73
- secondary_color: null,
74
- classification: "third-party",
75
- current_implementation: "SlackCLIAPI@1.30.0",
76
- is_adoptable: true,
77
- is_usable: true,
78
- update_cta_level: "info",
79
- update_cta_message: "This version is legacy. Consider updating to the latest version for better support.",
80
- badges: [
81
- {
82
- label: "Legacy",
83
- color: "primary",
84
- tooltip_markdown: "This version is legacy. Consider updating to the latest version for better support.",
85
- },
86
- ],
87
- },
88
- ],
89
- });
90
- }
91
- else if (url === "/zapier/api/v4/implementations-meta/lookup/") {
92
- // Mock for implementations-meta/lookup fallback
93
- const searchParams = options?.searchParams || {};
94
- // Check if we're looking for a nonexistent app
95
- if (searchParams.slugs?.includes("nonexistent") ||
96
- searchParams.selected_apis?.includes("nonexistent")) {
97
- return Promise.resolve({
98
- count: 0,
99
- next: null,
100
- previous: null,
101
- results: [],
102
- });
103
- }
104
- // Return successful response for known apps (like slack)
105
- return Promise.resolve({
106
- count: 1,
107
- next: null,
108
- previous: null,
109
- results: [
110
- {
111
- id: "SlackCLIAPI@1.30.0",
112
- name: "Slack",
113
- slug: "slack",
114
- images: {},
115
- },
116
- ],
117
- });
118
- }
119
- return Promise.resolve({ count: 0, results: [] });
120
- }),
121
- };
122
- mockSdk = {
123
- listApps: vi.fn().mockReturnValue({
124
- items: vi.fn().mockReturnValue([
125
- {
126
- title: "Slack",
127
- key: "slack",
128
- current_implementation_id: "SlackCLIAPI@1.30.0",
129
- description: "Team communication platform",
130
- },
131
- ][Symbol.iterator]()),
132
- }),
133
- };
134
- });
135
- afterEach(() => {
136
- vi.restoreAllMocks();
137
- });
138
- const apiPlugin = () => ({
139
- context: {
140
- api: mockApiClient,
141
- },
142
- });
143
- const listAppsMockPlugin = () => ({
144
- listApps: mockSdk.listApps,
145
- context: {
146
- meta: {
147
- listApps: {
148
- inputSchema: {},
149
- },
150
- },
151
- },
152
- });
153
- function createTestSdk(options = {}) {
154
- return createSdk(options)
155
- .addPlugin(() => ({
156
- context: {
157
- options: {},
158
- },
159
- }))
160
- .addPlugin(apiPlugin)
161
- .addPlugin(eventEmissionPlugin)
162
- .addPlugin(manifestPlugin);
163
- }
164
- describe("plugin initialization", () => {
165
- it("should provide helper functions with direct manifest", () => {
166
- const sdk = createTestSdk({ manifest: mockManifest });
167
- const context = sdk.getContext();
168
- expect(context.getVersionedImplementationId).toBeInstanceOf(Function);
169
- });
170
- it("should provide helper functions with manifestPath", async () => {
171
- mockReadFile.mockResolvedValue(mockManifestContent);
172
- const sdk = createTestSdk({ manifestPath: "manifest.json" });
173
- const context = sdk.getContext();
174
- expect(context.getVersionedImplementationId).toBeInstanceOf(Function);
175
- // Verify file operations happen when functions are called
176
- await context.getVersionedImplementationId("slack");
177
- expect(mockResolve).toHaveBeenCalledWith("manifest.json");
178
- expect(mockReadFile).toHaveBeenCalledWith("/resolved/manifest.json");
179
- });
180
- it("should provide helper functions when no manifest or path provided", () => {
181
- const sdk = createTestSdk();
182
- const context = sdk.getContext();
183
- expect(context.getVersionedImplementationId).toBeInstanceOf(Function);
184
- // Manifest functions are available even when no manifest is provided
185
- });
186
- it("should prioritize direct manifest over manifestPath", () => {
187
- mockReadFile.mockResolvedValue('{"apps": {"other": {"implementationName": "Other", "version": "1.0.0"}}}');
188
- createTestSdk({
189
- manifest: mockManifest,
190
- manifestPath: "manifest.json",
191
- });
192
- // Verify that direct manifest is used and file loading is not needed
193
- expect(mockReadFile).not.toHaveBeenCalled();
194
- });
195
- });
196
- describe("getVersionedImplementationId function", () => {
197
- it("should return versioned implementation ID when app exists in manifest", async () => {
198
- const sdk = createTestSdk({ manifest: mockManifest });
199
- const context = sdk.getContext();
200
- const result = await context.getVersionedImplementationId("slack");
201
- expect(result).toBe("SlackCLIAPI@1.21.1");
202
- });
203
- it("should fetch and return versioned implementation ID when app not in manifest", async () => {
204
- const sdk = createTestSdk();
205
- const context = sdk.getContext();
206
- const result = await context.getVersionedImplementationId("slack");
207
- expect(result).toBe("SlackCLIAPI@1.30.0");
208
- });
209
- it("should return null when app does not exist", async () => {
210
- mockSdk.listApps = vi.fn().mockReturnValue({
211
- items: vi.fn().mockReturnValue([][Symbol.iterator]()),
212
- });
213
- const sdk = createTestSdk();
214
- const context = sdk.getContext();
215
- const result = await context.getVersionedImplementationId("nonexistent");
216
- expect(result).toBeNull();
217
- });
218
- });
219
- describe("manifest parsing", () => {
220
- it("should parse valid manifest content", () => {
221
- createTestSdk({ manifest: mockManifest });
222
- // Verify manifest is parsed correctly for other functions to use
223
- });
224
- it("should handle manifest with missing version", () => {
225
- const manifestWithoutVersion = {
226
- apps: {
227
- slack: {
228
- implementationName: "SlackCLIAPI",
229
- },
230
- },
231
- };
232
- createTestSdk({ manifest: manifestWithoutVersion });
233
- // Verify manifest with missing version is handled correctly
234
- });
235
- it("should handle empty manifest", () => {
236
- createTestSdk({ manifest: {} });
237
- // Verify empty manifest is handled correctly
238
- });
239
- });
240
- describe("file loading", () => {
241
- it("should load manifest from file successfully", async () => {
242
- mockReadFile.mockResolvedValue(mockManifestContent);
243
- const sdk = createTestSdk({ manifestPath: "manifest.json" });
244
- const context = sdk.getContext();
245
- // Verify that file operations happen when functions are called
246
- await context.getVersionedImplementationId("slack");
247
- expect(mockResolve).toHaveBeenCalledWith("manifest.json");
248
- expect(mockReadFile).toHaveBeenCalledWith("/resolved/manifest.json");
249
- });
250
- it("should handle file read errors gracefully", async () => {
251
- mockReadFile.mockRejectedValue(new Error("File not found"));
252
- const sdk = createTestSdk({ manifestPath: "nonexistent.json" });
253
- const context = sdk.getContext();
254
- // Trigger file loading by calling a function
255
- await context.getVersionedImplementationId("slack");
256
- // Verify file loading errors are handled gracefully
257
- expect(console.warn).toHaveBeenCalledWith(expect.stringContaining("Failed to read manifest from nonexistent.json"));
258
- });
259
- it("should handle invalid JSON gracefully", async () => {
260
- mockReadFile.mockResolvedValue("invalid json content");
261
- const sdk = createTestSdk({ manifestPath: "invalid.json" });
262
- const context = sdk.getContext();
263
- // Trigger file loading by calling a function
264
- await context.getVersionedImplementationId("slack");
265
- // Verify JSON parsing errors are handled gracefully
266
- expect(console.warn).toHaveBeenCalledWith(expect.stringContaining("Failed to parse manifest from /resolved/invalid.json"), expect.any(SyntaxError));
267
- });
268
- it("should handle JSON without apps property", () => {
269
- mockReadFile.mockResolvedValue('{"other": "data"}');
270
- createTestSdk({ manifestPath: "no-apps.json" });
271
- // Verify missing apps property is handled correctly
272
- });
273
- it("should handle JSON with invalid apps format", () => {
274
- mockReadFile.mockResolvedValue('{"apps": "not an object"}');
275
- createTestSdk({ manifestPath: "invalid-apps.json" });
276
- // Verify invalid apps format is handled correctly
277
- });
278
- });
279
- describe("integration with SDK", () => {
280
- it("should work with createSdk", async () => {
281
- const sdk = createSdk({ manifest: mockManifest })
282
- .addPlugin(apiPlugin)
283
- .addPlugin(listAppsMockPlugin)
284
- .addPlugin(manifestPlugin);
285
- const context = sdk.getContext();
286
- // Verify that the manifest data is used correctly by other functions
287
- const versionedId = await context.getVersionedImplementationId("slack");
288
- expect(versionedId).toBe("SlackCLIAPI@1.21.1");
289
- });
290
- });
291
- describe("findManifestEntry function", () => {
292
- it("should find entry by direct key match", () => {
293
- const manifest = {
294
- apps: {
295
- slack: { implementationName: "SlackCLIAPI", version: "1.21.1" },
296
- gmail: { implementationName: "GmailCLIAPI", version: "2.0.0" },
297
- },
298
- };
299
- const result = findManifestEntry({ appKey: "slack", manifest });
300
- expect(result).toEqual([
301
- "slack",
302
- { implementationName: "SlackCLIAPI", version: "1.21.1" },
303
- ]);
304
- });
305
- it("should find entry by implementation name match", () => {
306
- const manifest = {
307
- apps: {
308
- SlackCLIAPI: { implementationName: "SlackCLIAPI", version: "1.21.1" },
309
- GmailCLIAPI: { implementationName: "GmailCLIAPI", version: "2.0.0" },
310
- },
311
- };
312
- const result = findManifestEntry({ appKey: "SlackCLIAPI", manifest });
313
- expect(result).toEqual([
314
- "SlackCLIAPI",
315
- { implementationName: "SlackCLIAPI", version: "1.21.1" },
316
- ]);
317
- });
318
- it("should find existing key when searching by implementation name", () => {
319
- const manifest = {
320
- apps: {
321
- SlackCLIAPI: { implementationName: "SlackCLIAPI", version: "1.21.1" },
322
- },
323
- };
324
- // This is the key test: searching by implementation name should find existing entry
325
- const result = findManifestEntry({ appKey: "SlackCLIAPI", manifest });
326
- expect(result).toEqual([
327
- "SlackCLIAPI",
328
- { implementationName: "SlackCLIAPI", version: "1.21.1" },
329
- ]);
330
- });
331
- it("should return null when no match found", () => {
332
- const manifest = {
333
- apps: {
334
- gmail: { implementationName: "GmailCLIAPI", version: "2.0.0" },
335
- },
336
- };
337
- const result = findManifestEntry({ appKey: "slack", manifest });
338
- expect(result).toBeNull();
339
- });
340
- it("should handle snake-cased slugs", () => {
341
- const manifest = {
342
- apps: {
343
- "google-sheets": {
344
- implementationName: "GoogleSheetsCLIAPI",
345
- version: "1.0.0",
346
- },
347
- },
348
- };
349
- const result = findManifestEntry({ appKey: "google_sheets", manifest });
350
- expect(result).toEqual([
351
- "google-sheets",
352
- { implementationName: "GoogleSheetsCLIAPI", version: "1.0.0" },
353
- ]);
354
- });
355
- it("should NOT find entry when searching slug against implementation name key (current limitation)", () => {
356
- const manifest = {
357
- apps: {
358
- SlackCLIAPI: { implementationName: "SlackCLIAPI", version: "1.21.1" },
359
- },
360
- };
361
- // This will fail - we search by "slack" but can't find "SlackCLIAPI" entry
362
- // This is the core issue we need to solve
363
- const result = findManifestEntry({ appKey: "slack", manifest });
364
- expect(result).toBeNull(); // Current behavior - doesn't find it
365
- // We need to fix this so it CAN find existing implementation name entries
366
- });
367
- });
368
- describe("updateManifestEntry with slug-to-implementation matching", () => {
369
- it("should find existing implementation name entry when input is slug", async () => {
370
- // Mock existing manifest with implementation name as key
371
- mockReadFile.mockResolvedValue(JSON.stringify({
372
- apps: {
373
- SlackCLIAPI: {
374
- implementationName: "SlackCLIAPI",
375
- version: "1.21.1",
376
- },
377
- },
378
- }));
379
- // Mock resolveAppKeys to resolve "slack" to "SlackCLIAPI"
380
- mockResolveAppKeys.mockResolvedValue([
381
- {
382
- slug: "slack",
383
- implementationName: "SlackCLIAPI",
384
- version: "1.30.0",
385
- lookupAppKey: "slack",
386
- },
387
- ]);
388
- const sdk = createTestSdk();
389
- const context = sdk.getContext();
390
- // This should now find the existing "SlackCLIAPI" entry
391
- const { key: manifestKey } = await context.updateManifestEntry({
392
- appKey: "slack", // Input is slug
393
- entry: { implementationName: "SlackCLIAPI", version: "1.30.0" },
394
- });
395
- // Should return the existing key, not create a new one
396
- expect(manifestKey).toBe("SlackCLIAPI");
397
- });
398
- });
399
- describe("resolveAppKeys function", () => {
400
- it("should resolve slug to manifest entry even when manifest uses implementation name as key", async () => {
401
- const manifest = {
402
- apps: {
403
- SlackCLIAPI: { implementationName: "SlackCLIAPI", version: "1.21.1" },
404
- },
405
- };
406
- // Mock API to return slack app data when looking up "slack"
407
- mockApiClient.get = vi.fn().mockResolvedValue({
408
- count: 1,
409
- next: null,
410
- previous: null,
411
- results: [
412
- {
413
- id: "SlackCLIAPI@1.30.0",
414
- name: "Slack",
415
- slug: "slack",
416
- key: "SlackCLIAPI", // This is the implementation name
417
- version: "1.30.0",
418
- },
419
- ],
420
- });
421
- // Test resolveAppKeys directly using the manifest plugin
422
- const sdk = createSdk({ manifest })
423
- .addPlugin(apiPlugin)
424
- .addPlugin(manifestPlugin);
425
- const context = sdk.getContext();
426
- const resolved = await context.resolveAppKeys({ appKeys: ["slack"] });
427
- // Should find the manifest entry and use its version (1.21.1) instead of latest (1.30.0)
428
- expect(resolved).toHaveLength(1);
429
- expect(resolved[0]).toEqual({
430
- slug: "slack",
431
- implementationName: "SlackCLIAPI",
432
- version: "1.21.1", // Should use manifest version, not API version
433
- lookupAppKey: "slack",
434
- });
435
- });
436
- it("should fall back to API version when no manifest entry found", async () => {
437
- const manifest = { apps: {} }; // Empty manifest
438
- // Mock API to return slack app data
439
- mockApiClient.get = vi.fn().mockResolvedValue({
440
- count: 1,
441
- next: null,
442
- previous: null,
443
- results: [
444
- {
445
- id: "SlackCLIAPI@1.30.0",
446
- name: "Slack",
447
- slug: "slack",
448
- key: "SlackCLIAPI",
449
- version: "1.30.0",
450
- },
451
- ],
452
- });
453
- const sdk = createSdk({ manifest })
454
- .addPlugin(apiPlugin)
455
- .addPlugin(manifestPlugin);
456
- const context = sdk.getContext();
457
- const resolved = await context.resolveAppKeys({ appKeys: ["slack"] });
458
- // Should use API version since no manifest entry found
459
- expect(resolved).toHaveLength(1);
460
- expect(resolved[0]).toEqual({
461
- slug: "slack",
462
- implementationName: "SlackCLIAPI",
463
- version: "1.30.0", // Should use API version
464
- lookupAppKey: "slack",
465
- });
466
- });
467
- it("should always use version from input when specified (slug@version)", async () => {
468
- const manifest = {
469
- apps: {
470
- SlackCLIAPI: { implementationName: "SlackCLIAPI", version: "1.21.1" },
471
- },
472
- };
473
- // Mock API to return slack app data
474
- mockApiClient.get = vi.fn().mockResolvedValue({
475
- count: 1,
476
- next: null,
477
- previous: null,
478
- results: [
479
- {
480
- id: "SlackCLIAPI@1.30.0",
481
- name: "Slack",
482
- slug: "slack",
483
- key: "SlackCLIAPI",
484
- version: "1.30.0",
485
- },
486
- ],
487
- });
488
- const sdk = createSdk({ manifest })
489
- .addPlugin(apiPlugin)
490
- .addPlugin(manifestPlugin);
491
- const context = sdk.getContext();
492
- // Input version should take precedence over both manifest (1.21.1) and API (1.30.0)
493
- const resolved = await context.resolveAppKeys({
494
- appKeys: ["slack@1.2.3"],
495
- });
496
- expect(resolved).toHaveLength(1);
497
- expect(resolved[0]).toEqual({
498
- slug: "slack",
499
- implementationName: "SlackCLIAPI",
500
- version: "1.2.3", // Should use input version, not manifest or API
501
- lookupAppKey: "slack",
502
- });
503
- });
504
- it("should always use version from input when specified (implementationName@version)", async () => {
505
- const manifest = {
506
- apps: {
507
- SlackCLIAPI: { implementationName: "SlackCLIAPI", version: "1.21.1" },
508
- },
509
- };
510
- const sdk = createSdk({ manifest })
511
- .addPlugin(apiPlugin)
512
- .addPlugin(manifestPlugin);
513
- const context = sdk.getContext();
514
- // Input version should take precedence over manifest version
515
- const resolved = await context.resolveAppKeys({
516
- appKeys: ["SlackCLIAPI@1.2.3"],
517
- });
518
- expect(resolved).toHaveLength(1);
519
- expect(resolved[0]).toEqual({
520
- implementationName: "SlackCLIAPI",
521
- version: "1.2.3", // Should use input version, not manifest version
522
- lookupAppKey: "SlackCLIAPI",
523
- });
524
- });
525
- });
526
- });
527
- describe("readManifestFromFile", () => {
528
- const mockManifestContent = JSON.stringify({
529
- apps: {
530
- slack: {
531
- implementationName: "SlackCLIAPI",
532
- version: "1.21.1",
533
- },
534
- "google-sheets": {
535
- implementationName: "GoogleSheetsCLIAPI",
536
- version: "2.0.0",
537
- },
538
- },
539
- });
540
- beforeEach(() => {
541
- vi.clearAllMocks();
542
- });
543
- it("should read and parse manifest from file", async () => {
544
- mockReadFile.mockResolvedValue(mockManifestContent);
545
- const result = await readManifestFromFile("manifest.json");
546
- expect(mockResolve).toHaveBeenCalledWith("manifest.json");
547
- expect(mockReadFile).toHaveBeenCalledWith("/resolved/manifest.json");
548
- expect(result).toEqual({
549
- apps: {
550
- slack: {
551
- implementationName: "SlackCLIAPI",
552
- version: "1.21.1",
553
- },
554
- "google-sheets": {
555
- implementationName: "GoogleSheetsCLIAPI",
556
- version: "2.0.0",
557
- },
558
- },
559
- });
560
- });
561
- it("should handle file read errors", async () => {
562
- mockReadFile.mockRejectedValue(new Error("File not found"));
563
- const result = await readManifestFromFile("nonexistent.json");
564
- expect(result).toBeNull();
565
- });
566
- it("should handle invalid JSON content", async () => {
567
- mockReadFile.mockResolvedValue("invalid json");
568
- const result = await readManifestFromFile("invalid.json");
569
- expect(result).toBeNull();
570
- });
571
- describe("getPreferredManifestEntryKey", () => {
572
- let mockApi;
573
- beforeEach(() => {
574
- mockApi = {
575
- get: vi.fn(),
576
- };
577
- });
578
- it("should prefer slug when available", async () => {
579
- const result = await getPreferredManifestEntryKey({
580
- appKey: "slack",
581
- api: mockApi,
582
- });
583
- expect(result).toBe("slack");
584
- });
585
- it("should look up slug for implementation name", async () => {
586
- // Mock API response for implementation name lookup
587
- mockApi.get = vi.fn().mockResolvedValueOnce({
588
- results: [
589
- {
590
- key: "SlackCLIAPI",
591
- slug: "slack",
592
- version: "1.0.0",
593
- current_implementation_id: "SlackCLIAPI@1.0.0",
594
- },
595
- ],
596
- next: null,
597
- });
598
- const result = await getPreferredManifestEntryKey({
599
- appKey: "SlackCLIAPI",
600
- api: mockApi,
601
- });
602
- expect(result).toBe("slack");
603
- expect(mockApi.get).toHaveBeenCalledWith("/zapier/api/v4/implementations-meta/lookup/", {
604
- searchParams: { selected_apis: "SlackCLIAPI" },
605
- });
606
- });
607
- it("should fall back to implementation name if slug lookup fails", async () => {
608
- // Mock API to return empty results
609
- mockApi.get = vi.fn().mockResolvedValueOnce({
610
- results: [],
611
- next: null,
612
- });
613
- const result = await getPreferredManifestEntryKey({
614
- appKey: "SlackCLIAPI",
615
- api: mockApi,
616
- });
617
- expect(result).toBe("SlackCLIAPI");
618
- });
619
- it("should fall back to original key if no slug or implementation name", async () => {
620
- const result = await getPreferredManifestEntryKey({
621
- appKey: "some-random-key",
622
- api: mockApi,
623
- });
624
- expect(result).toBe("some-random-key");
625
- });
626
- });
627
- describe("Action management", () => {
628
- const mockManifest = {
629
- apps: {
630
- slack: {
631
- implementationName: "SlackCLIAPI",
632
- version: "1.21.1",
633
- },
634
- },
635
- };
636
- let mockApiClient;
637
- beforeEach(() => {
638
- vi.clearAllMocks();
639
- vi.spyOn(console, "warn").mockImplementation(() => { });
640
- mockApiClient = {
641
- get: vi.fn(),
642
- };
643
- });
644
- afterEach(() => {
645
- vi.restoreAllMocks();
646
- });
647
- const apiPlugin = () => ({
648
- context: {
649
- api: mockApiClient,
650
- },
651
- });
652
- function createTestSdk(options = {}) {
653
- return createSdk(options).addPlugin(apiPlugin).addPlugin(manifestPlugin);
654
- }
655
- describe("findActionEntry", () => {
656
- it("should find an existing action by name", () => {
657
- const manifest = {
658
- apps: mockManifest.apps,
659
- actions: {
660
- "weekly-report": {
661
- appKey: "slack",
662
- actionKey: "post_message",
663
- actionType: "write",
664
- authenticationId: 123,
665
- inputs: { channel: "#general" },
666
- schema: {},
667
- createdAt: "2025-11-18T12:00:00.000Z",
668
- },
669
- },
670
- };
671
- const sdk = createTestSdk({ manifest });
672
- const context = sdk.getContext();
673
- const action = context.findActionEntry({
674
- name: "weekly-report",
675
- manifest,
676
- });
677
- expect(action).toEqual({
678
- appKey: "slack",
679
- actionKey: "post_message",
680
- actionType: "write",
681
- authenticationId: 123,
682
- inputs: { channel: "#general" },
683
- schema: {},
684
- createdAt: "2025-11-18T12:00:00.000Z",
685
- });
686
- });
687
- it("should return null for non-existent action", () => {
688
- const manifest = {
689
- apps: mockManifest.apps,
690
- actions: {},
691
- };
692
- const sdk = createTestSdk({ manifest });
693
- const context = sdk.getContext();
694
- const action = context.findActionEntry({
695
- name: "non-existent",
696
- manifest,
697
- });
698
- expect(action).toBeNull();
699
- });
700
- it("should return null when manifest has no actions section", () => {
701
- const manifest = {
702
- apps: mockManifest.apps,
703
- };
704
- const sdk = createTestSdk({ manifest });
705
- const context = sdk.getContext();
706
- const action = context.findActionEntry({
707
- name: "any-action",
708
- manifest,
709
- });
710
- expect(action).toBeNull();
711
- });
712
- });
713
- describe("hasActionEntry", () => {
714
- it("should return true for existing action", () => {
715
- const manifest = {
716
- apps: mockManifest.apps,
717
- actions: {
718
- "weekly-report": {
719
- appKey: "slack",
720
- actionKey: "post_message",
721
- actionType: "write",
722
- authenticationId: 123,
723
- inputs: {},
724
- schema: {},
725
- createdAt: "2025-11-18T12:00:00.000Z",
726
- },
727
- },
728
- };
729
- const sdk = createTestSdk({ manifest });
730
- const context = sdk.getContext();
731
- const exists = context.hasActionEntry({
732
- name: "weekly-report",
733
- manifest,
734
- });
735
- expect(exists).toBe(true);
736
- });
737
- it("should return false for non-existent action", () => {
738
- const manifest = {
739
- apps: mockManifest.apps,
740
- actions: {},
741
- };
742
- const sdk = createTestSdk({ manifest });
743
- const context = sdk.getContext();
744
- const exists = context.hasActionEntry({
745
- name: "non-existent",
746
- manifest,
747
- });
748
- expect(exists).toBe(false);
749
- });
750
- it("should return false when manifest has no actions section", () => {
751
- const manifest = {
752
- apps: mockManifest.apps,
753
- };
754
- const sdk = createTestSdk({ manifest });
755
- const context = sdk.getContext();
756
- const exists = context.hasActionEntry({ name: "any-action", manifest });
757
- expect(exists).toBe(false);
758
- });
759
- });
760
- describe("listActionEntries", () => {
761
- it("should return all actions as [name, entry] tuples", async () => {
762
- const mockManifestContent = JSON.stringify({
763
- apps: mockManifest.apps,
764
- actions: {
765
- "weekly-report": {
766
- appKey: "slack",
767
- actionKey: "post_message",
768
- actionType: "write",
769
- authenticationId: 123,
770
- inputs: { channel: "#general" },
771
- schema: {},
772
- createdAt: "2025-11-18T12:00:00.000Z",
773
- },
774
- "daily-summary": {
775
- appKey: "slack",
776
- actionKey: "post_message",
777
- actionType: "write",
778
- authenticationId: 123,
779
- inputs: { channel: "#daily" },
780
- schema: {},
781
- createdAt: "2025-11-18T13:00:00.000Z",
782
- },
783
- },
784
- });
785
- mockReadFile.mockResolvedValue(mockManifestContent);
786
- const sdk = createTestSdk({ manifestPath: ".zapierrc" });
787
- const context = sdk.getContext();
788
- const actions = await context.listActionEntries({
789
- configPath: ".zapierrc",
790
- });
791
- expect(actions).toHaveLength(2);
792
- expect(actions).toEqual([
793
- [
794
- "weekly-report",
795
- {
796
- appKey: "slack",
797
- actionKey: "post_message",
798
- actionType: "write",
799
- authenticationId: 123,
800
- inputs: { channel: "#general" },
801
- schema: {},
802
- createdAt: "2025-11-18T12:00:00.000Z",
803
- },
804
- ],
805
- [
806
- "daily-summary",
807
- {
808
- appKey: "slack",
809
- actionKey: "post_message",
810
- actionType: "write",
811
- authenticationId: 123,
812
- inputs: { channel: "#daily" },
813
- schema: {},
814
- createdAt: "2025-11-18T13:00:00.000Z",
815
- },
816
- ],
817
- ]);
818
- });
819
- it("should return empty array when no actions exist", async () => {
820
- const mockManifestContent = JSON.stringify({
821
- apps: mockManifest.apps,
822
- });
823
- mockReadFile.mockResolvedValue(mockManifestContent);
824
- const sdk = createTestSdk({ manifestPath: ".zapierrc" });
825
- const context = sdk.getContext();
826
- const actions = await context.listActionEntries({
827
- configPath: ".zapierrc",
828
- });
829
- expect(actions).toEqual([]);
830
- });
831
- it("should use default configPath when not provided", async () => {
832
- const mockManifestContent = JSON.stringify({
833
- apps: mockManifest.apps,
834
- actions: {},
835
- });
836
- mockReadFile.mockResolvedValue(mockManifestContent);
837
- const sdk = createTestSdk();
838
- const context = sdk.getContext();
839
- await context.listActionEntries();
840
- expect(mockResolve).toHaveBeenCalledWith(".zapierrc");
841
- });
842
- });
843
- describe("addActionEntry", () => {
844
- it("should successfully add a new action", async () => {
845
- const mockManifestContent = JSON.stringify({
846
- apps: mockManifest.apps,
847
- });
848
- mockReadFile.mockResolvedValue(mockManifestContent);
849
- const sdk = createTestSdk({ manifestPath: ".zapierrc" });
850
- const context = sdk.getContext();
851
- const entry = {
852
- appKey: "slack",
853
- actionKey: "post_message",
854
- actionType: "write",
855
- authenticationId: 123,
856
- inputs: { channel: "#general" },
857
- schema: { type: "object" },
858
- createdAt: "2025-11-18T12:00:00.000Z",
859
- };
860
- const { name, entry: returnedEntry, manifest: updatedManifest, } = await context.addActionEntry({
861
- name: "weekly-report",
862
- entry,
863
- configPath: ".zapierrc",
864
- });
865
- expect(name).toBe("weekly-report");
866
- expect(returnedEntry).toEqual(entry);
867
- expect(updatedManifest.actions).toEqual({
868
- "weekly-report": entry,
869
- });
870
- });
871
- it("should throw error when action name already exists", async () => {
872
- const mockManifestContent = JSON.stringify({
873
- apps: mockManifest.apps,
874
- actions: {
875
- "weekly-report": {
876
- appKey: "slack",
877
- actionKey: "post_message",
878
- actionType: "write",
879
- authenticationId: 123,
880
- inputs: {},
881
- schema: {},
882
- createdAt: "2025-11-18T12:00:00.000Z",
883
- },
884
- },
885
- });
886
- mockReadFile.mockResolvedValue(mockManifestContent);
887
- const sdk = createTestSdk({ manifestPath: ".zapierrc" });
888
- const context = sdk.getContext();
889
- const entry = {
890
- appKey: "slack",
891
- actionKey: "post_message",
892
- actionType: "write",
893
- authenticationId: 123,
894
- inputs: {},
895
- schema: {},
896
- createdAt: "2025-11-18T13:00:00.000Z",
897
- };
898
- await expect(context.addActionEntry({
899
- name: "weekly-report",
900
- entry,
901
- configPath: ".zapierrc",
902
- })).rejects.toThrow('Action "weekly-report" already exists. Please choose a different name or remove the existing action first.');
903
- });
904
- it("should allow duplicate name with skipWrite option", async () => {
905
- const mockManifestContent = JSON.stringify({
906
- apps: mockManifest.apps,
907
- actions: {
908
- "weekly-report": {
909
- appKey: "slack",
910
- actionKey: "post_message",
911
- actionType: "write",
912
- authenticationId: 123,
913
- inputs: {},
914
- schema: {},
915
- createdAt: "2025-11-18T12:00:00.000Z",
916
- },
917
- },
918
- });
919
- mockReadFile.mockResolvedValue(mockManifestContent);
920
- const sdk = createTestSdk({ manifestPath: ".zapierrc" });
921
- const context = sdk.getContext();
922
- const entry = {
923
- appKey: "slack",
924
- actionKey: "post_message",
925
- actionType: "write",
926
- authenticationId: 456,
927
- inputs: {},
928
- schema: {},
929
- createdAt: "2025-11-18T13:00:00.000Z",
930
- };
931
- const { name, entry: returnedEntry } = await context.addActionEntry({
932
- name: "weekly-report",
933
- entry,
934
- configPath: ".zapierrc",
935
- skipWrite: true,
936
- });
937
- expect(name).toBe("weekly-report");
938
- expect(returnedEntry).toEqual(entry);
939
- });
940
- it("should create actions section if it doesn't exist", async () => {
941
- const mockManifestContent = JSON.stringify({
942
- apps: mockManifest.apps,
943
- });
944
- mockReadFile.mockResolvedValue(mockManifestContent);
945
- const sdk = createTestSdk({ manifestPath: ".zapierrc" });
946
- const context = sdk.getContext();
947
- const entry = {
948
- appKey: "slack",
949
- actionKey: "post_message",
950
- actionType: "write",
951
- authenticationId: 123,
952
- inputs: {},
953
- schema: {},
954
- createdAt: "2025-11-18T12:00:00.000Z",
955
- };
956
- const { manifest: updatedManifest } = await context.addActionEntry({
957
- name: "first-action",
958
- entry,
959
- configPath: ".zapierrc",
960
- });
961
- expect(updatedManifest.actions).toBeDefined();
962
- expect(updatedManifest.actions).toEqual({
963
- "first-action": entry,
964
- });
965
- });
966
- });
967
- describe("deleteActionEntry", () => {
968
- it("should successfully delete an existing action", async () => {
969
- const mockManifestContent = JSON.stringify({
970
- apps: mockManifest.apps,
971
- actions: {
972
- "weekly-report": {
973
- appKey: "slack",
974
- actionKey: "post_message",
975
- actionType: "write",
976
- authenticationId: 123,
977
- inputs: {},
978
- schema: {},
979
- createdAt: "2025-11-18T12:00:00.000Z",
980
- },
981
- "daily-summary": {
982
- appKey: "slack",
983
- actionKey: "post_message",
984
- actionType: "write",
985
- authenticationId: 123,
986
- inputs: {},
987
- schema: {},
988
- createdAt: "2025-11-18T13:00:00.000Z",
989
- },
990
- },
991
- });
992
- mockReadFile.mockResolvedValue(mockManifestContent);
993
- const sdk = createTestSdk({ manifestPath: ".zapierrc" });
994
- const context = sdk.getContext();
995
- const updatedManifest = await context.deleteActionEntry({
996
- name: "weekly-report",
997
- configPath: ".zapierrc",
998
- });
999
- expect(updatedManifest.actions).toEqual({
1000
- "daily-summary": {
1001
- appKey: "slack",
1002
- actionKey: "post_message",
1003
- actionType: "write",
1004
- authenticationId: 123,
1005
- inputs: {},
1006
- schema: {},
1007
- createdAt: "2025-11-18T13:00:00.000Z",
1008
- },
1009
- });
1010
- expect(updatedManifest.actions?.["weekly-report"]).toBeUndefined();
1011
- });
1012
- it("should throw error when action does not exist", async () => {
1013
- const mockManifestContent = JSON.stringify({
1014
- apps: mockManifest.apps,
1015
- actions: {},
1016
- });
1017
- mockReadFile.mockResolvedValue(mockManifestContent);
1018
- const sdk = createTestSdk({ manifestPath: ".zapierrc" });
1019
- const context = sdk.getContext();
1020
- await expect(context.deleteActionEntry({
1021
- name: "non-existent",
1022
- configPath: ".zapierrc",
1023
- })).rejects.toThrow('Action "non-existent" does not exist.');
1024
- });
1025
- it("should work with skipWrite option", async () => {
1026
- const mockManifestContent = JSON.stringify({
1027
- apps: mockManifest.apps,
1028
- actions: {
1029
- "weekly-report": {
1030
- appKey: "slack",
1031
- actionKey: "post_message",
1032
- actionType: "write",
1033
- authenticationId: 123,
1034
- inputs: {},
1035
- schema: {},
1036
- createdAt: "2025-11-18T12:00:00.000Z",
1037
- },
1038
- },
1039
- });
1040
- mockReadFile.mockResolvedValue(mockManifestContent);
1041
- const sdk = createTestSdk({ manifestPath: ".zapierrc" });
1042
- const context = sdk.getContext();
1043
- const updatedManifest = await context.deleteActionEntry({
1044
- name: "weekly-report",
1045
- configPath: ".zapierrc",
1046
- skipWrite: true,
1047
- });
1048
- expect(updatedManifest.actions).toEqual({});
1049
- });
1050
- it("should handle deleting the last action", async () => {
1051
- const mockManifestContent = JSON.stringify({
1052
- apps: mockManifest.apps,
1053
- actions: {
1054
- "only-action": {
1055
- appKey: "slack",
1056
- actionKey: "post_message",
1057
- actionType: "write",
1058
- authenticationId: 123,
1059
- inputs: {},
1060
- schema: {},
1061
- createdAt: "2025-11-18T12:00:00.000Z",
1062
- },
1063
- },
1064
- });
1065
- mockReadFile.mockResolvedValue(mockManifestContent);
1066
- const sdk = createTestSdk({ manifestPath: ".zapierrc" });
1067
- const context = sdk.getContext();
1068
- const updatedManifest = await context.deleteActionEntry({
1069
- name: "only-action",
1070
- configPath: ".zapierrc",
1071
- });
1072
- expect(updatedManifest.actions).toEqual({});
1073
- });
1074
- });
1075
- describe("action CRUD integration", () => {
1076
- it("should support full CRUD workflow", async () => {
1077
- const mockManifestContent = JSON.stringify({
1078
- apps: mockManifest.apps,
1079
- });
1080
- mockReadFile.mockResolvedValue(mockManifestContent);
1081
- const sdk = createTestSdk({ manifestPath: ".zapierrc" });
1082
- const context = sdk.getContext();
1083
- // Create first action
1084
- const entry1 = {
1085
- appKey: "slack",
1086
- actionKey: "post_message",
1087
- actionType: "write",
1088
- authenticationId: 123,
1089
- inputs: { channel: "#general" },
1090
- schema: {},
1091
- createdAt: "2025-11-18T12:00:00.000Z",
1092
- };
1093
- const { manifest: manifest1 } = await context.addActionEntry({
1094
- name: "action-1",
1095
- entry: entry1,
1096
- skipWrite: true,
1097
- });
1098
- // Create second action
1099
- const entry2 = {
1100
- appKey: "slack",
1101
- actionKey: "post_message",
1102
- actionType: "write",
1103
- authenticationId: 123,
1104
- inputs: { channel: "#daily" },
1105
- schema: {},
1106
- createdAt: "2025-11-18T13:00:00.000Z",
1107
- };
1108
- const { manifest: manifest2 } = await context.addActionEntry({
1109
- name: "action-2",
1110
- entry: entry2,
1111
- manifest: manifest1,
1112
- skipWrite: true,
1113
- });
1114
- // Verify both actions exist
1115
- expect(context.hasActionEntry({ name: "action-1", manifest: manifest2 })).toBe(true);
1116
- expect(context.hasActionEntry({ name: "action-2", manifest: manifest2 })).toBe(true);
1117
- // Find action
1118
- const foundAction = context.findActionEntry({
1119
- name: "action-1",
1120
- manifest: manifest2,
1121
- });
1122
- expect(foundAction).toEqual(entry1);
1123
- // List actions
1124
- mockReadFile.mockResolvedValue(JSON.stringify(manifest2));
1125
- const actions = await context.listActionEntries({
1126
- configPath: ".zapierrc",
1127
- });
1128
- expect(actions).toHaveLength(2);
1129
- // Delete action
1130
- const manifest3 = await context.deleteActionEntry({
1131
- name: "action-1",
1132
- skipWrite: true,
1133
- });
1134
- expect(context.hasActionEntry({ name: "action-1", manifest: manifest3 })).toBe(false);
1135
- expect(context.hasActionEntry({ name: "action-2", manifest: manifest3 })).toBe(true);
1136
- });
1137
- });
1138
- });
1139
- });