@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,220 +0,0 @@
1
- import { describe, it, expect } from "vitest";
2
- import { isJwt, getAuthorizationHeader, extractUserIdsFromJwt } from "./auth";
3
- describe("api/auth", () => {
4
- describe("isJwt", () => {
5
- it("should return true for valid JWT tokens", () => {
6
- const validJwt = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c";
7
- expect(isJwt(validJwt)).toBe(true);
8
- });
9
- it("should return true for JWT with minimal valid parts", () => {
10
- const minimalJwt = "a.b.c";
11
- expect(isJwt(minimalJwt)).toBe(true);
12
- });
13
- it("should return false for tokens with fewer than 3 parts", () => {
14
- expect(isJwt("header.payload")).toBe(false);
15
- expect(isJwt("onlyonepart")).toBe(false);
16
- expect(isJwt("")).toBe(false);
17
- });
18
- it("should return false for tokens with more than 3 parts", () => {
19
- expect(isJwt("part1.part2.part3.part4")).toBe(false);
20
- });
21
- it("should return false for tokens with empty parts", () => {
22
- expect(isJwt("..")).toBe(false);
23
- expect(isJwt(".payload.signature")).toBe(false);
24
- expect(isJwt("header..signature")).toBe(false);
25
- expect(isJwt("header.payload.")).toBe(false);
26
- });
27
- it("should return false for tokens with invalid base64url characters", () => {
28
- expect(isJwt("header+plus.payload.signature")).toBe(false);
29
- expect(isJwt("header.payload/slash.signature")).toBe(false);
30
- expect(isJwt("header.payload=padding.signature")).toBe(false);
31
- expect(isJwt("header.payload with space.signature")).toBe(false);
32
- });
33
- it("should accept valid base64url characters including dashes and underscores", () => {
34
- const validBase64Url = "abc-123_XYZ.def-456_UVW.ghi-789_RST";
35
- expect(isJwt(validBase64Url)).toBe(true);
36
- });
37
- });
38
- describe("getAuthorizationHeader", () => {
39
- it("should return JWT prefix for valid JWT tokens", () => {
40
- const jwt = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIn0.dozjgNryP4J3jVmNHl0w5N_XgL0n3I9PlFUP0THsR8U";
41
- expect(getAuthorizationHeader(jwt)).toBe(`JWT ${jwt}`);
42
- });
43
- it("should return Bearer prefix for non-JWT tokens", () => {
44
- const apiKey = "sk_test_1234567890abcdef";
45
- expect(getAuthorizationHeader(apiKey)).toBe(`Bearer ${apiKey}`);
46
- });
47
- it("should return Bearer prefix for tokens with wrong number of parts", () => {
48
- expect(getAuthorizationHeader("header.payload")).toBe("Bearer header.payload");
49
- });
50
- it("should return Bearer prefix for empty string", () => {
51
- expect(getAuthorizationHeader("")).toBe("Bearer ");
52
- });
53
- });
54
- describe("extractUserIdsFromJwt", () => {
55
- function createJwt(payload) {
56
- const header = Buffer.from(JSON.stringify({ alg: "HS256", typ: "JWT" })).toString("base64url");
57
- const payloadEncoded = Buffer.from(JSON.stringify(payload)).toString("base64url");
58
- const signature = "fake_signature_for_testing";
59
- return `${header}.${payloadEncoded}.${signature}`;
60
- }
61
- it("should return null values for invalid JWT tokens", () => {
62
- expect(extractUserIdsFromJwt("not-a-jwt")).toEqual({
63
- customuser_id: null,
64
- account_id: null,
65
- });
66
- });
67
- it("should return null values for JWT with invalid payload", () => {
68
- const invalidJwt = "header.not-valid-base64!.signature";
69
- expect(extractUserIdsFromJwt(invalidJwt)).toEqual({
70
- customuser_id: null,
71
- account_id: null,
72
- });
73
- });
74
- it("should extract customuser_id and account_id from regular JWT", () => {
75
- const payload = {
76
- sub: "12345",
77
- sub_type: "customuser",
78
- "zap:acc": "67890",
79
- };
80
- const jwt = createJwt(payload);
81
- expect(extractUserIdsFromJwt(jwt)).toEqual({
82
- customuser_id: 12345,
83
- account_id: 67890,
84
- });
85
- });
86
- it("should handle numeric sub and zap:acc values", () => {
87
- const payload = {
88
- sub: 99999,
89
- sub_type: "customuser",
90
- "zap:acc": 11111,
91
- };
92
- const jwt = createJwt(payload);
93
- expect(extractUserIdsFromJwt(jwt)).toEqual({
94
- customuser_id: 99999,
95
- account_id: 11111,
96
- });
97
- });
98
- it("should return null customuser_id when sub_type is not customuser", () => {
99
- const payload = {
100
- sub: "12345",
101
- sub_type: "other",
102
- "zap:acc": "67890",
103
- };
104
- const jwt = createJwt(payload);
105
- expect(extractUserIdsFromJwt(jwt)).toEqual({
106
- customuser_id: null,
107
- account_id: 67890,
108
- });
109
- });
110
- it("should return null customuser_id when sub is missing", () => {
111
- const payload = {
112
- sub_type: "customuser",
113
- "zap:acc": "67890",
114
- };
115
- const jwt = createJwt(payload);
116
- expect(extractUserIdsFromJwt(jwt)).toEqual({
117
- customuser_id: null,
118
- account_id: 67890,
119
- });
120
- });
121
- it("should return null account_id when zap:acc is missing", () => {
122
- const payload = {
123
- sub: "12345",
124
- sub_type: "customuser",
125
- };
126
- const jwt = createJwt(payload);
127
- expect(extractUserIdsFromJwt(jwt)).toEqual({
128
- customuser_id: 12345,
129
- account_id: null,
130
- });
131
- });
132
- it("should return null values when both fields are missing", () => {
133
- const payload = {
134
- other_field: "value",
135
- };
136
- const jwt = createJwt(payload);
137
- expect(extractUserIdsFromJwt(jwt)).toEqual({
138
- customuser_id: null,
139
- account_id: null,
140
- });
141
- });
142
- it("should handle nested JWT for service tokens", () => {
143
- const nestedPayload = {
144
- sub: "12345",
145
- sub_type: "customuser",
146
- "zap:acc": "67890",
147
- };
148
- const nestedJwt = createJwt(nestedPayload);
149
- const servicePayload = {
150
- sub_type: "service",
151
- njwt: nestedJwt,
152
- };
153
- const serviceJwt = createJwt(servicePayload);
154
- expect(extractUserIdsFromJwt(serviceJwt)).toEqual({
155
- customuser_id: 12345,
156
- account_id: 67890,
157
- });
158
- });
159
- it("should fall back to outer payload when nested JWT is invalid", () => {
160
- const servicePayload = {
161
- sub_type: "service",
162
- njwt: "invalid.jwt",
163
- "zap:acc": "99999",
164
- };
165
- const serviceJwt = createJwt(servicePayload);
166
- expect(extractUserIdsFromJwt(serviceJwt)).toEqual({
167
- customuser_id: null,
168
- account_id: 99999,
169
- });
170
- });
171
- it("should use outer payload when sub_type is service but njwt is missing", () => {
172
- const servicePayload = {
173
- sub: "12345",
174
- sub_type: "service",
175
- "zap:acc": "67890",
176
- };
177
- const serviceJwt = createJwt(servicePayload);
178
- expect(extractUserIdsFromJwt(serviceJwt)).toEqual({
179
- customuser_id: null,
180
- account_id: 67890,
181
- });
182
- });
183
- it("should return null for non-numeric sub values", () => {
184
- const payload = {
185
- sub: "not-a-number",
186
- sub_type: "customuser",
187
- "zap:acc": "67890",
188
- };
189
- const jwt = createJwt(payload);
190
- expect(extractUserIdsFromJwt(jwt)).toEqual({
191
- customuser_id: null,
192
- account_id: 67890,
193
- });
194
- });
195
- it("should return null for non-numeric zap:acc values", () => {
196
- const payload = {
197
- sub: "12345",
198
- sub_type: "customuser",
199
- "zap:acc": "not-a-number",
200
- };
201
- const jwt = createJwt(payload);
202
- expect(extractUserIdsFromJwt(jwt)).toEqual({
203
- customuser_id: 12345,
204
- account_id: null,
205
- });
206
- });
207
- it("should return null for values that parse to NaN", () => {
208
- const payload = {
209
- sub: "abc",
210
- sub_type: "customuser",
211
- "zap:acc": "xyz",
212
- };
213
- const jwt = createJwt(payload);
214
- expect(extractUserIdsFromJwt(jwt)).toEqual({
215
- customuser_id: null,
216
- account_id: null,
217
- });
218
- });
219
- });
220
- });
@@ -1,9 +0,0 @@
1
- /**
2
- * API Client Implementation
3
- *
4
- * This module contains the core API client implementation, including
5
- * HTTP method handlers, response processing, and client factory functions.
6
- */
7
- import type { ApiClient, ApiClientOptions } from "./types";
8
- export declare const createZapierApi: (options: ApiClientOptions) => ApiClient;
9
- //# sourceMappingURL=client.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,SAAS,EACT,gBAAgB,EAGjB,MAAM,SAAS,CAAC;AA4ejB,eAAO,MAAM,eAAe,GAAI,SAAS,gBAAgB,KAAG,SAW3D,CAAC"}
@@ -1,356 +0,0 @@
1
- /**
2
- * API Client Implementation
3
- *
4
- * This module contains the core API client implementation, including
5
- * HTTP method handlers, response processing, and client factory functions.
6
- */
7
- import { getAuthorizationHeader } from "./auth";
8
- import { createDebugLogger, createDebugFetch } from "./debug";
9
- import { pollUntilComplete } from "./polling";
10
- import { resolveAuthToken } from "../auth";
11
- import { getZapierBaseUrl } from "../utils/url-utils";
12
- import { ZapierApiError, ZapierAuthenticationError, ZapierValidationError, ZapierNotFoundError, } from "../types/errors";
13
- // Configuration for paths
14
- const pathConfig = {
15
- // e.g. /relay -> https://sdkapi.zapier.com/api/v0/sdk/relay/...
16
- "/relay": {
17
- authHeader: "X-Relay-Authorization",
18
- pathPrefix: "/api/v0/sdk/relay",
19
- },
20
- // e.g. /zapier -> https://sdkapi.zapier.com/api/v0/sdk/zapier/...
21
- "/zapier": {
22
- authHeader: "Authorization",
23
- pathPrefix: "/api/v0/sdk/zapier",
24
- },
25
- };
26
- class ZapierApiClient {
27
- constructor(options) {
28
- this.options = options;
29
- this.fetch = async (path, init) => {
30
- return this.plainFetch(path, init);
31
- };
32
- this.get = async (path, options = {}) => {
33
- return this.fetchJson("GET", path, undefined, options);
34
- };
35
- this.post = async (path, data, options = {}) => {
36
- return this.fetchJson("POST", path, data, options);
37
- };
38
- this.put = async (path, data, options = {}) => {
39
- return this.fetchJson("PUT", path, data, options);
40
- };
41
- this.delete = async (path, options = {}) => {
42
- return this.fetchJson("DELETE", path, undefined, options);
43
- };
44
- this.poll = async (path, options = {}) => {
45
- return pollUntilComplete({
46
- fetchPoll: () => this.plainFetch(path, {
47
- method: "GET",
48
- searchParams: options.searchParams,
49
- authRequired: options.authRequired,
50
- }),
51
- initialDelay: options.initialDelay,
52
- timeoutMs: options.timeoutMs,
53
- successStatus: options.successStatus,
54
- pendingStatus: options.pendingStatus,
55
- resultExtractor: options.resultExtractor,
56
- });
57
- };
58
- }
59
- // Helper to parse response data
60
- async parseResult(response) {
61
- try {
62
- return { type: "json", data: await response.json() };
63
- }
64
- catch {
65
- return { type: "text", data: await response.text() };
66
- }
67
- }
68
- // Helper to get a token from the different places it could be gotten
69
- async getAuthToken() {
70
- return resolveAuthToken({
71
- token: this.options.token,
72
- getToken: this.options.getToken,
73
- onEvent: this.options.onEvent,
74
- fetch: this.options.fetch,
75
- baseUrl: this.options.baseUrl,
76
- authBaseUrl: this.options.authBaseUrl,
77
- authClientId: this.options.authClientId,
78
- });
79
- }
80
- // Helper to handle responses
81
- async handleResponse(params) {
82
- const { response, customErrorHandler, wasMissingAuthToken } = params;
83
- const { data: responseData } = await this.parseResult(response);
84
- if (response.ok) {
85
- return responseData;
86
- }
87
- const errorInfo = {
88
- status: response.status,
89
- statusText: response.statusText,
90
- data: responseData,
91
- };
92
- // Check for custom error handling first
93
- if (customErrorHandler) {
94
- const customError = customErrorHandler(errorInfo);
95
- if (customError) {
96
- // javascript may not respect customErrorHandler return type, so we need to throw a proper error if it's not an Error
97
- if (customError instanceof Error) {
98
- throw customError;
99
- }
100
- else {
101
- throw new Error(`customErrorHandler returned a non-Error: ${JSON.stringify(customError)}`);
102
- }
103
- }
104
- }
105
- // Parse the error response
106
- const { message, errors } = this.parseErrorResponse(errorInfo);
107
- const errorOptions = {
108
- statusCode: response.status,
109
- errors,
110
- };
111
- // Use appropriate error type based on status code
112
- if (response.status === 404) {
113
- throw new ZapierNotFoundError(message, errorOptions);
114
- }
115
- if (response.status === 401 || response.status === 403) {
116
- // If we get a 401/403 error and no auth token was provided, give helpful message
117
- if (wasMissingAuthToken) {
118
- throw new ZapierAuthenticationError(`Authentication required (HTTP ${response.status}). Please provide a token in options or set ZAPIER_TOKEN environment variable.`, errorOptions);
119
- }
120
- throw new ZapierAuthenticationError(message, errorOptions);
121
- }
122
- if (response.status === 400) {
123
- throw new ZapierValidationError(message, errorOptions);
124
- }
125
- // Generic API error for other status codes
126
- throw new ZapierApiError(message, errorOptions);
127
- }
128
- hasErrorArray(data) {
129
- return (typeof data === "object" &&
130
- data !== null &&
131
- "errors" in data &&
132
- Array.isArray(data.errors));
133
- }
134
- // Helper to check if data has API errors
135
- isApiErrorArray(dataArray) {
136
- const data = dataArray[0];
137
- return (typeof data === "object" &&
138
- data !== null &&
139
- "message" in data &&
140
- "code" in data &&
141
- "title" in data &&
142
- "detail" in data);
143
- }
144
- // Do our best to extract an error message from the response data
145
- extractErrorMessage(data) {
146
- if (typeof data === "string") {
147
- return data;
148
- }
149
- if (typeof data === "object" && data !== null) {
150
- if ("message" in data && typeof data.message === "string") {
151
- return data.message;
152
- }
153
- if ("error" in data) {
154
- if (typeof data.error === "string") {
155
- return data.error;
156
- }
157
- if (typeof data.error === "object" && data.error !== null) {
158
- if ("message" in data.error &&
159
- typeof data.error.message === "string") {
160
- return data.error.message;
161
- }
162
- }
163
- try {
164
- return JSON.stringify(data.error);
165
- }
166
- catch {
167
- /* defend against circular objects, even though they shouldn't be coming back from the wire */
168
- }
169
- }
170
- if ("errors" in data && Array.isArray(data.errors)) {
171
- if (this.isApiErrorArray(data.errors)) {
172
- return data.errors[0].detail || data.errors[0].title;
173
- }
174
- else if (data.errors.length > 0) {
175
- // Handle simple string errors array
176
- const firstError = data.errors[0];
177
- if (typeof firstError === "string") {
178
- return firstError;
179
- }
180
- // For non-string errors, stringify them
181
- try {
182
- return JSON.stringify(firstError);
183
- }
184
- catch {
185
- return String(firstError);
186
- }
187
- }
188
- }
189
- }
190
- return undefined;
191
- }
192
- // Helper to parse API error response
193
- parseErrorResponse(errorInfo) {
194
- // If we can't parse data, use status text
195
- const fallbackMessage = `HTTP ${errorInfo.status}: ${errorInfo.statusText}`;
196
- try {
197
- // Check if the response has the standard error format
198
- if (typeof errorInfo.data === "string") {
199
- return { message: `${fallbackMessage}: ${errorInfo.data}` };
200
- }
201
- const errorMessage = this.extractErrorMessage(errorInfo.data) || fallbackMessage;
202
- if (this.hasErrorArray(errorInfo.data)) {
203
- if (this.isApiErrorArray(errorInfo.data.errors)) {
204
- return {
205
- message: errorMessage,
206
- errors: errorInfo.data.errors,
207
- };
208
- }
209
- else {
210
- return {
211
- message: errorMessage,
212
- errors: errorInfo.data.errors.map((e) => ({
213
- status: errorInfo.status,
214
- code: String(errorInfo.status),
215
- title: errorInfo.statusText,
216
- detail: JSON.stringify(e),
217
- })),
218
- };
219
- }
220
- }
221
- return { message: errorMessage };
222
- }
223
- catch {
224
- return { message: fallbackMessage };
225
- }
226
- }
227
- // Apply any special routing logic for configured paths.
228
- applyPathConfiguration(path) {
229
- // Find matching path configuration.
230
- const matchingPathKey = Object.keys(pathConfig).find((configPath) => path === configPath || path.startsWith(configPath + "/"));
231
- const config = matchingPathKey ? pathConfig[matchingPathKey] : undefined;
232
- // Check if baseUrl is a Zapier-inferred base URL.
233
- const zapierBaseUrl = getZapierBaseUrl(this.options.baseUrl);
234
- // Let's remain compatible with a base URL that is set to a Zapier-inferred
235
- // domain, rather than requiring the base URL to go to our proxy. Later, the
236
- // proxy will be removed, so this should make that transition easier.
237
- if (zapierBaseUrl === this.options.baseUrl) {
238
- // If baseUrl is already the Zapier base URL, use sdkapi subdomain.
239
- const originalBaseUrl = new URL(this.options.baseUrl);
240
- const finalBaseUrl = `https://sdkapi.${originalBaseUrl.hostname}`;
241
- // Only prepend pathPrefix if there's a matching config with pathPrefix.
242
- let finalPath = path;
243
- if (config &&
244
- "pathPrefix" in config &&
245
- config.pathPrefix &&
246
- matchingPathKey) {
247
- // Strip the matching path key, and use the pathPrefix instead.
248
- const pathWithoutPrefix = path.slice(matchingPathKey.length) || "/";
249
- finalPath = `${config.pathPrefix}${pathWithoutPrefix}`;
250
- }
251
- return {
252
- url: new URL(finalPath, finalBaseUrl),
253
- pathConfig: config,
254
- };
255
- }
256
- // For a base URL that isn't a Zapier-inferred domain, use the whole base URL.
257
- const baseUrl = new URL(this.options.baseUrl);
258
- const fullPath = baseUrl.pathname.replace(/\/$/, "") + path;
259
- return {
260
- url: new URL(fullPath, baseUrl.origin),
261
- pathConfig: config,
262
- };
263
- }
264
- // Helper to build full URLs and return routing info
265
- buildUrl(path, searchParams) {
266
- const { url, pathConfig: config } = this.applyPathConfiguration(path);
267
- if (searchParams) {
268
- Object.entries(searchParams).forEach(([key, value]) => {
269
- url.searchParams.set(key, value);
270
- });
271
- }
272
- return { url: url.toString(), pathConfig: config };
273
- }
274
- // Helper to build headers
275
- async buildHeaders(options = {}, pathConfig) {
276
- const headers = new Headers(options.headers ?? {});
277
- // Even if auth is not required, we still want to add it in case it adds
278
- // useful context to the API. The session is a good example of this. Auth
279
- // is not required, but if we don't add auth, then we won't get the user's
280
- // session!
281
- const authToken = await this.getAuthToken();
282
- if (authToken) {
283
- const authHeaderName = pathConfig && pathConfig.authHeader
284
- ? pathConfig.authHeader
285
- : "Authorization";
286
- headers.set(authHeaderName, getAuthorizationHeader(authToken));
287
- }
288
- // If we know auth is required, and we don't have a token, throw an error
289
- // before we even make a request.
290
- if (options.authRequired) {
291
- if (headers.get("Authorization") == null && authToken == null) {
292
- throw new ZapierAuthenticationError(`Authentication required but no token available. Please set ZAPIER_TOKEN, or run the 'login' command with the CLI.`);
293
- }
294
- }
295
- return headers;
296
- }
297
- // Helper to perform HTTP requests with JSON handling
298
- async fetchJson(method, path, data, options = {}) {
299
- const headers = { ...options.headers };
300
- // Add Content-Type for JSON requests with body data
301
- if (data && typeof data === "object") {
302
- headers["Content-Type"] = "application/json";
303
- }
304
- // Check if we have an auth token available
305
- const wasMissingAuthToken = options.authRequired && (await this.getAuthToken()) == null;
306
- const response = await this.plainFetch(path, {
307
- ...options,
308
- method,
309
- body: data != null ? JSON.stringify(data) : undefined,
310
- headers,
311
- });
312
- // plainFetch already handled all auth and headers
313
- const result = await this.handleResponse({
314
- response,
315
- customErrorHandler: options.customErrorHandler,
316
- wasMissingAuthToken,
317
- });
318
- if (typeof result === "string") {
319
- throw new ZapierValidationError(`Response could not be parsed as JSON: ${result}`);
320
- }
321
- return result;
322
- }
323
- // Plain fetch method for API paths (must start with /)
324
- async plainFetch(path, fetchOptions) {
325
- if (!path.startsWith("/")) {
326
- throw new ZapierValidationError(`plainFetch expects a path starting with '/', got: ${path}`);
327
- }
328
- if (fetchOptions?.body && typeof fetchOptions.body === "object") {
329
- fetchOptions.body = JSON.stringify(fetchOptions.body);
330
- }
331
- const { url, pathConfig } = this.buildUrl(path, fetchOptions?.searchParams);
332
- const builtHeaders = await this.buildHeaders(fetchOptions, pathConfig);
333
- const inputHeaders = new Headers(fetchOptions?.headers ?? {});
334
- const mergedHeaders = new Headers();
335
- builtHeaders.forEach((value, key) => {
336
- mergedHeaders.set(key, value);
337
- });
338
- inputHeaders.forEach((value, key) => {
339
- mergedHeaders.set(key, value);
340
- });
341
- return await this.options.fetch(url, {
342
- ...fetchOptions,
343
- headers: mergedHeaders,
344
- });
345
- }
346
- }
347
- export const createZapierApi = (options) => {
348
- const { debug = false, fetch: originalFetch = globalThis.fetch } = options;
349
- const debugLog = createDebugLogger(debug);
350
- const debugFetch = createDebugFetch({ originalFetch, debugLog });
351
- return new ZapierApiClient({
352
- ...options,
353
- debug,
354
- fetch: debugFetch,
355
- });
356
- };
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=client.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.test.d.ts","sourceRoot":"","sources":["../../src/api/client.test.ts"],"names":[],"mappings":""}