@zapier/zapier-sdk 0.77.0 → 0.77.2

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 (800) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/experimental.cjs +4 -3
  3. package/dist/experimental.d.mts +2 -3
  4. package/dist/experimental.d.ts +918 -934
  5. package/dist/experimental.mjs +4 -3
  6. package/dist/{index-BZShISEr.d.mts → index-kC0bJpsG.d.mts} +25 -3
  7. package/dist/{index-BZShISEr.d.ts → index-kC0bJpsG.d.ts} +25 -3
  8. package/dist/index.cjs +4 -3
  9. package/dist/index.d.mts +1 -2
  10. package/dist/index.d.ts +6 -81
  11. package/dist/index.mjs +4 -3
  12. package/package.json +3 -3
  13. package/dist/api/approval-review-stream.d.ts +0 -25
  14. package/dist/api/approval-review-stream.d.ts.map +0 -1
  15. package/dist/api/approval-review-stream.js +0 -104
  16. package/dist/api/auth.d.ts +0 -14
  17. package/dist/api/auth.d.ts.map +0 -1
  18. package/dist/api/auth.js +0 -77
  19. package/dist/api/client.d.ts +0 -9
  20. package/dist/api/client.d.ts.map +0 -1
  21. package/dist/api/client.js +0 -1232
  22. package/dist/api/concurrency.d.ts +0 -28
  23. package/dist/api/concurrency.d.ts.map +0 -1
  24. package/dist/api/concurrency.js +0 -90
  25. package/dist/api/debug.d.ts +0 -14
  26. package/dist/api/debug.d.ts.map +0 -1
  27. package/dist/api/debug.js +0 -133
  28. package/dist/api/error-classification.d.ts +0 -19
  29. package/dist/api/error-classification.d.ts.map +0 -1
  30. package/dist/api/error-classification.js +0 -31
  31. package/dist/api/index.d.ts +0 -33
  32. package/dist/api/index.d.ts.map +0 -1
  33. package/dist/api/index.js +0 -44
  34. package/dist/api/polling.d.ts +0 -64
  35. package/dist/api/polling.d.ts.map +0 -1
  36. package/dist/api/polling.js +0 -180
  37. package/dist/api/schemas.d.ts +0 -423
  38. package/dist/api/schemas.d.ts.map +0 -1
  39. package/dist/api/schemas.js +0 -323
  40. package/dist/api/sse-parser.d.ts +0 -51
  41. package/dist/api/sse-parser.d.ts.map +0 -1
  42. package/dist/api/sse-parser.js +0 -95
  43. package/dist/api/types.d.ts +0 -215
  44. package/dist/api/types.d.ts.map +0 -1
  45. package/dist/api/types.js +0 -1
  46. package/dist/auth.d.ts +0 -149
  47. package/dist/auth.d.ts.map +0 -1
  48. package/dist/auth.js +0 -526
  49. package/dist/cache.d.ts +0 -50
  50. package/dist/cache.d.ts.map +0 -1
  51. package/dist/cache.js +0 -47
  52. package/dist/constants.d.ts +0 -84
  53. package/dist/constants.d.ts.map +0 -1
  54. package/dist/constants.js +0 -122
  55. package/dist/core-stack.d.ts +0 -24
  56. package/dist/core-stack.d.ts.map +0 -1
  57. package/dist/core-stack.js +0 -32
  58. package/dist/credentials.d.ts +0 -57
  59. package/dist/credentials.d.ts.map +0 -1
  60. package/dist/credentials.js +0 -184
  61. package/dist/define/apps-entrypoint.d.ts +0 -3
  62. package/dist/define/apps-entrypoint.d.ts.map +0 -1
  63. package/dist/define/apps-entrypoint.js +0 -1
  64. package/dist/define/apps-registry-keys.d.ts +0 -2
  65. package/dist/define/apps-registry-keys.d.ts.map +0 -1
  66. package/dist/define/apps-registry-keys.js +0 -2
  67. package/dist/define/apps-registry.d.ts +0 -13
  68. package/dist/define/apps-registry.d.ts.map +0 -1
  69. package/dist/define/apps-registry.js +0 -31
  70. package/dist/define/apps-registry.json +0 -9010
  71. package/dist/define/apps.d.ts +0 -11
  72. package/dist/define/apps.d.ts.map +0 -1
  73. package/dist/define/apps.js +0 -2
  74. package/dist/define/define.d.ts +0 -13
  75. package/dist/define/define.d.ts.map +0 -1
  76. package/dist/define/define.js +0 -93
  77. package/dist/define/helpers.d.ts +0 -8
  78. package/dist/define/helpers.d.ts.map +0 -1
  79. package/dist/define/helpers.js +0 -6
  80. package/dist/define/index.d.ts +0 -5
  81. package/dist/define/index.d.ts.map +0 -1
  82. package/dist/define/index.js +0 -2
  83. package/dist/define/types.d.ts +0 -246
  84. package/dist/define/types.d.ts.map +0 -1
  85. package/dist/define/types.js +0 -1
  86. package/dist/experimental.d.ts.map +0 -1
  87. package/dist/experimental.js +0 -232
  88. package/dist/formatters/action.d.ts +0 -4
  89. package/dist/formatters/action.d.ts.map +0 -1
  90. package/dist/formatters/action.js +0 -18
  91. package/dist/formatters/actionResult.d.ts +0 -3
  92. package/dist/formatters/actionResult.d.ts.map +0 -1
  93. package/dist/formatters/actionResult.js +0 -25
  94. package/dist/formatters/app.d.ts +0 -4
  95. package/dist/formatters/app.d.ts.map +0 -1
  96. package/dist/formatters/app.js +0 -10
  97. package/dist/formatters/clientCredentials.d.ts +0 -5
  98. package/dist/formatters/clientCredentials.d.ts.map +0 -1
  99. package/dist/formatters/clientCredentials.js +0 -27
  100. package/dist/formatters/connection.d.ts +0 -4
  101. package/dist/formatters/connection.d.ts.map +0 -1
  102. package/dist/formatters/connection.js +0 -26
  103. package/dist/formatters/field.d.ts +0 -4
  104. package/dist/formatters/field.d.ts.map +0 -1
  105. package/dist/formatters/field.js +0 -51
  106. package/dist/formatters/index.d.ts +0 -2
  107. package/dist/formatters/index.d.ts.map +0 -1
  108. package/dist/formatters/index.js +0 -1
  109. package/dist/formatters/inputFieldChoice.d.ts +0 -4
  110. package/dist/formatters/inputFieldChoice.d.ts.map +0 -1
  111. package/dist/formatters/inputFieldChoice.js +0 -16
  112. package/dist/formatters/tableField.d.ts +0 -4
  113. package/dist/formatters/tableField.d.ts.map +0 -1
  114. package/dist/formatters/tableField.js +0 -7
  115. package/dist/formatters/tableRecord.d.ts +0 -8
  116. package/dist/formatters/tableRecord.d.ts.map +0 -1
  117. package/dist/formatters/tableRecord.js +0 -24
  118. package/dist/formatters/triggerInbox.d.ts +0 -4
  119. package/dist/formatters/triggerInbox.d.ts.map +0 -1
  120. package/dist/formatters/triggerInbox.js +0 -31
  121. package/dist/formatters/triggerMessage.d.ts +0 -5
  122. package/dist/formatters/triggerMessage.d.ts.map +0 -1
  123. package/dist/formatters/triggerMessage.js +0 -34
  124. package/dist/formatters/userProfile.d.ts +0 -4
  125. package/dist/formatters/userProfile.d.ts.map +0 -1
  126. package/dist/formatters/userProfile.js +0 -19
  127. package/dist/index.d.ts.map +0 -1
  128. package/dist/index.js +0 -94
  129. package/dist/plugins/api/index.d.ts +0 -30
  130. package/dist/plugins/api/index.d.ts.map +0 -1
  131. package/dist/plugins/api/index.js +0 -35
  132. package/dist/plugins/apps/index.d.ts +0 -118
  133. package/dist/plugins/apps/index.d.ts.map +0 -1
  134. package/dist/plugins/apps/index.js +0 -156
  135. package/dist/plugins/apps/schemas.d.ts +0 -50
  136. package/dist/plugins/apps/schemas.d.ts.map +0 -1
  137. package/dist/plugins/apps/schemas.js +0 -37
  138. package/dist/plugins/capabilities/index.d.ts +0 -27
  139. package/dist/plugins/capabilities/index.d.ts.map +0 -1
  140. package/dist/plugins/capabilities/index.js +0 -75
  141. package/dist/plugins/codeSubstrate/cancelDurableRun/index.d.ts +0 -70
  142. package/dist/plugins/codeSubstrate/cancelDurableRun/index.d.ts.map +0 -1
  143. package/dist/plugins/codeSubstrate/cancelDurableRun/index.js +0 -28
  144. package/dist/plugins/codeSubstrate/cancelDurableRun/schemas.d.ts +0 -11
  145. package/dist/plugins/codeSubstrate/cancelDurableRun/schemas.d.ts.map +0 -1
  146. package/dist/plugins/codeSubstrate/cancelDurableRun/schemas.js +0 -12
  147. package/dist/plugins/codeSubstrate/createWorkflow/index.d.ts +0 -49
  148. package/dist/plugins/codeSubstrate/createWorkflow/index.d.ts.map +0 -1
  149. package/dist/plugins/codeSubstrate/createWorkflow/index.js +0 -24
  150. package/dist/plugins/codeSubstrate/createWorkflow/schemas.d.ts +0 -20
  151. package/dist/plugins/codeSubstrate/createWorkflow/schemas.d.ts.map +0 -1
  152. package/dist/plugins/codeSubstrate/createWorkflow/schemas.js +0 -42
  153. package/dist/plugins/codeSubstrate/deleteWorkflow/index.d.ts +0 -75
  154. package/dist/plugins/codeSubstrate/deleteWorkflow/index.d.ts.map +0 -1
  155. package/dist/plugins/codeSubstrate/deleteWorkflow/index.js +0 -28
  156. package/dist/plugins/codeSubstrate/deleteWorkflow/schemas.d.ts +0 -10
  157. package/dist/plugins/codeSubstrate/deleteWorkflow/schemas.d.ts.map +0 -1
  158. package/dist/plugins/codeSubstrate/deleteWorkflow/schemas.js +0 -13
  159. package/dist/plugins/codeSubstrate/disableWorkflow/index.d.ts +0 -76
  160. package/dist/plugins/codeSubstrate/disableWorkflow/index.d.ts.map +0 -1
  161. package/dist/plugins/codeSubstrate/disableWorkflow/index.js +0 -21
  162. package/dist/plugins/codeSubstrate/disableWorkflow/schemas.d.ts +0 -11
  163. package/dist/plugins/codeSubstrate/disableWorkflow/schemas.d.ts.map +0 -1
  164. package/dist/plugins/codeSubstrate/disableWorkflow/schemas.js +0 -12
  165. package/dist/plugins/codeSubstrate/enableWorkflow/index.d.ts +0 -76
  166. package/dist/plugins/codeSubstrate/enableWorkflow/index.d.ts.map +0 -1
  167. package/dist/plugins/codeSubstrate/enableWorkflow/index.js +0 -21
  168. package/dist/plugins/codeSubstrate/enableWorkflow/schemas.d.ts +0 -11
  169. package/dist/plugins/codeSubstrate/enableWorkflow/schemas.d.ts.map +0 -1
  170. package/dist/plugins/codeSubstrate/enableWorkflow/schemas.js +0 -12
  171. package/dist/plugins/codeSubstrate/getDurableRun/index.d.ts +0 -119
  172. package/dist/plugins/codeSubstrate/getDurableRun/index.d.ts.map +0 -1
  173. package/dist/plugins/codeSubstrate/getDurableRun/index.js +0 -21
  174. package/dist/plugins/codeSubstrate/getDurableRun/schemas.d.ts +0 -178
  175. package/dist/plugins/codeSubstrate/getDurableRun/schemas.d.ts.map +0 -1
  176. package/dist/plugins/codeSubstrate/getDurableRun/schemas.js +0 -126
  177. package/dist/plugins/codeSubstrate/getTriggerRun/index.d.ts +0 -47
  178. package/dist/plugins/codeSubstrate/getTriggerRun/index.d.ts.map +0 -1
  179. package/dist/plugins/codeSubstrate/getTriggerRun/index.js +0 -23
  180. package/dist/plugins/codeSubstrate/getTriggerRun/schemas.d.ts +0 -24
  181. package/dist/plugins/codeSubstrate/getTriggerRun/schemas.d.ts.map +0 -1
  182. package/dist/plugins/codeSubstrate/getTriggerRun/schemas.js +0 -30
  183. package/dist/plugins/codeSubstrate/getWorkflow/index.d.ts +0 -114
  184. package/dist/plugins/codeSubstrate/getWorkflow/index.d.ts.map +0 -1
  185. package/dist/plugins/codeSubstrate/getWorkflow/index.js +0 -21
  186. package/dist/plugins/codeSubstrate/getWorkflow/schemas.d.ts +0 -81
  187. package/dist/plugins/codeSubstrate/getWorkflow/schemas.d.ts.map +0 -1
  188. package/dist/plugins/codeSubstrate/getWorkflow/schemas.js +0 -71
  189. package/dist/plugins/codeSubstrate/getWorkflowRun/index.d.ts +0 -112
  190. package/dist/plugins/codeSubstrate/getWorkflowRun/index.d.ts.map +0 -1
  191. package/dist/plugins/codeSubstrate/getWorkflowRun/index.js +0 -25
  192. package/dist/plugins/codeSubstrate/getWorkflowRun/schemas.d.ts +0 -26
  193. package/dist/plugins/codeSubstrate/getWorkflowRun/schemas.d.ts.map +0 -1
  194. package/dist/plugins/codeSubstrate/getWorkflowRun/schemas.js +0 -43
  195. package/dist/plugins/codeSubstrate/getWorkflowVersion/index.d.ts +0 -132
  196. package/dist/plugins/codeSubstrate/getWorkflowVersion/index.d.ts.map +0 -1
  197. package/dist/plugins/codeSubstrate/getWorkflowVersion/index.js +0 -25
  198. package/dist/plugins/codeSubstrate/getWorkflowVersion/schemas.d.ts +0 -30
  199. package/dist/plugins/codeSubstrate/getWorkflowVersion/schemas.d.ts.map +0 -1
  200. package/dist/plugins/codeSubstrate/getWorkflowVersion/schemas.js +0 -35
  201. package/dist/plugins/codeSubstrate/listDurableRuns/index.d.ts +0 -55
  202. package/dist/plugins/codeSubstrate/listDurableRuns/index.d.ts.map +0 -1
  203. package/dist/plugins/codeSubstrate/listDurableRuns/index.js +0 -31
  204. package/dist/plugins/codeSubstrate/listDurableRuns/schemas.d.ts +0 -73
  205. package/dist/plugins/codeSubstrate/listDurableRuns/schemas.d.ts.map +0 -1
  206. package/dist/plugins/codeSubstrate/listDurableRuns/schemas.js +0 -58
  207. package/dist/plugins/codeSubstrate/listWorkflowRuns/index.d.ts +0 -88
  208. package/dist/plugins/codeSubstrate/listWorkflowRuns/index.d.ts.map +0 -1
  209. package/dist/plugins/codeSubstrate/listWorkflowRuns/index.js +0 -34
  210. package/dist/plugins/codeSubstrate/listWorkflowRuns/schemas.d.ts +0 -63
  211. package/dist/plugins/codeSubstrate/listWorkflowRuns/schemas.d.ts.map +0 -1
  212. package/dist/plugins/codeSubstrate/listWorkflowRuns/schemas.js +0 -69
  213. package/dist/plugins/codeSubstrate/listWorkflowVersions/index.d.ts +0 -98
  214. package/dist/plugins/codeSubstrate/listWorkflowVersions/index.d.ts.map +0 -1
  215. package/dist/plugins/codeSubstrate/listWorkflowVersions/index.js +0 -34
  216. package/dist/plugins/codeSubstrate/listWorkflowVersions/schemas.d.ts +0 -63
  217. package/dist/plugins/codeSubstrate/listWorkflowVersions/schemas.d.ts.map +0 -1
  218. package/dist/plugins/codeSubstrate/listWorkflowVersions/schemas.js +0 -58
  219. package/dist/plugins/codeSubstrate/listWorkflows/index.d.ts +0 -61
  220. package/dist/plugins/codeSubstrate/listWorkflows/index.d.ts.map +0 -1
  221. package/dist/plugins/codeSubstrate/listWorkflows/index.js +0 -28
  222. package/dist/plugins/codeSubstrate/listWorkflows/schemas.d.ts +0 -86
  223. package/dist/plugins/codeSubstrate/listWorkflows/schemas.d.ts.map +0 -1
  224. package/dist/plugins/codeSubstrate/listWorkflows/schemas.js +0 -79
  225. package/dist/plugins/codeSubstrate/publishWorkflowVersion/index.d.ts +0 -150
  226. package/dist/plugins/codeSubstrate/publishWorkflowVersion/index.d.ts.map +0 -1
  227. package/dist/plugins/codeSubstrate/publishWorkflowVersion/index.js +0 -80
  228. package/dist/plugins/codeSubstrate/publishWorkflowVersion/schemas.d.ts +0 -158
  229. package/dist/plugins/codeSubstrate/publishWorkflowVersion/schemas.d.ts.map +0 -1
  230. package/dist/plugins/codeSubstrate/publishWorkflowVersion/schemas.js +0 -124
  231. package/dist/plugins/codeSubstrate/runDurable/index.d.ts +0 -94
  232. package/dist/plugins/codeSubstrate/runDurable/index.d.ts.map +0 -1
  233. package/dist/plugins/codeSubstrate/runDurable/index.js +0 -41
  234. package/dist/plugins/codeSubstrate/runDurable/schemas.d.ts +0 -149
  235. package/dist/plugins/codeSubstrate/runDurable/schemas.d.ts.map +0 -1
  236. package/dist/plugins/codeSubstrate/runDurable/schemas.js +0 -95
  237. package/dist/plugins/codeSubstrate/shared-schemas.d.ts +0 -41
  238. package/dist/plugins/codeSubstrate/shared-schemas.d.ts.map +0 -1
  239. package/dist/plugins/codeSubstrate/shared-schemas.js +0 -83
  240. package/dist/plugins/codeSubstrate/shared.d.ts +0 -72
  241. package/dist/plugins/codeSubstrate/shared.d.ts.map +0 -1
  242. package/dist/plugins/codeSubstrate/shared.js +0 -115
  243. package/dist/plugins/codeSubstrate/triggerWorkflow/index.d.ts +0 -78
  244. package/dist/plugins/codeSubstrate/triggerWorkflow/index.d.ts.map +0 -1
  245. package/dist/plugins/codeSubstrate/triggerWorkflow/index.js +0 -40
  246. package/dist/plugins/codeSubstrate/triggerWorkflow/schemas.d.ts +0 -16
  247. package/dist/plugins/codeSubstrate/triggerWorkflow/schemas.d.ts.map +0 -1
  248. package/dist/plugins/codeSubstrate/triggerWorkflow/schemas.js +0 -26
  249. package/dist/plugins/codeSubstrate/updateWorkflow/index.d.ts +0 -85
  250. package/dist/plugins/codeSubstrate/updateWorkflow/index.d.ts.map +0 -1
  251. package/dist/plugins/codeSubstrate/updateWorkflow/index.js +0 -28
  252. package/dist/plugins/codeSubstrate/updateWorkflow/schemas.d.ts +0 -20
  253. package/dist/plugins/codeSubstrate/updateWorkflow/schemas.d.ts.map +0 -1
  254. package/dist/plugins/codeSubstrate/updateWorkflow/schemas.js +0 -37
  255. package/dist/plugins/connections/index.d.ts +0 -19
  256. package/dist/plugins/connections/index.d.ts.map +0 -1
  257. package/dist/plugins/connections/index.js +0 -21
  258. package/dist/plugins/createClientCredentials/index.d.ts +0 -32
  259. package/dist/plugins/createClientCredentials/index.d.ts.map +0 -1
  260. package/dist/plugins/createClientCredentials/index.js +0 -29
  261. package/dist/plugins/createClientCredentials/schemas.d.ts +0 -18
  262. package/dist/plugins/createClientCredentials/schemas.d.ts.map +0 -1
  263. package/dist/plugins/createClientCredentials/schemas.js +0 -16
  264. package/dist/plugins/createConnection/index.d.ts +0 -189
  265. package/dist/plugins/createConnection/index.d.ts.map +0 -1
  266. package/dist/plugins/createConnection/index.js +0 -71
  267. package/dist/plugins/createConnection/schemas.d.ts +0 -21
  268. package/dist/plugins/createConnection/schemas.d.ts.map +0 -1
  269. package/dist/plugins/createConnection/schemas.js +0 -38
  270. package/dist/plugins/deleteClientCredentials/index.d.ts +0 -48
  271. package/dist/plugins/deleteClientCredentials/index.d.ts.map +0 -1
  272. package/dist/plugins/deleteClientCredentials/index.js +0 -21
  273. package/dist/plugins/deleteClientCredentials/schemas.d.ts +0 -12
  274. package/dist/plugins/deleteClientCredentials/schemas.d.ts.map +0 -1
  275. package/dist/plugins/deleteClientCredentials/schemas.js +0 -8
  276. package/dist/plugins/deprecated/authentications.d.ts +0 -763
  277. package/dist/plugins/deprecated/authentications.d.ts.map +0 -1
  278. package/dist/plugins/deprecated/authentications.js +0 -100
  279. package/dist/plugins/deprecated/inputFields.d.ts +0 -503
  280. package/dist/plugins/deprecated/inputFields.d.ts.map +0 -1
  281. package/dist/plugins/deprecated/inputFields.js +0 -81
  282. package/dist/plugins/eventEmission/builders.d.ts +0 -14
  283. package/dist/plugins/eventEmission/builders.d.ts.map +0 -1
  284. package/dist/plugins/eventEmission/builders.js +0 -117
  285. package/dist/plugins/eventEmission/event-emission-hook.d.ts +0 -10
  286. package/dist/plugins/eventEmission/event-emission-hook.d.ts.map +0 -1
  287. package/dist/plugins/eventEmission/event-emission-hook.js +0 -47
  288. package/dist/plugins/eventEmission/index.d.ts +0 -50
  289. package/dist/plugins/eventEmission/index.d.ts.map +0 -1
  290. package/dist/plugins/eventEmission/index.js +0 -398
  291. package/dist/plugins/eventEmission/method-metadata.d.ts +0 -16
  292. package/dist/plugins/eventEmission/method-metadata.d.ts.map +0 -1
  293. package/dist/plugins/eventEmission/method-metadata.js +0 -20
  294. package/dist/plugins/eventEmission/transport.d.ts +0 -27
  295. package/dist/plugins/eventEmission/transport.d.ts.map +0 -1
  296. package/dist/plugins/eventEmission/transport.js +0 -105
  297. package/dist/plugins/eventEmission/types.d.ts +0 -67
  298. package/dist/plugins/eventEmission/types.d.ts.map +0 -1
  299. package/dist/plugins/eventEmission/types.js +0 -1
  300. package/dist/plugins/eventEmission/utils.d.ts +0 -56
  301. package/dist/plugins/eventEmission/utils.d.ts.map +0 -1
  302. package/dist/plugins/eventEmission/utils.js +0 -142
  303. package/dist/plugins/fetch/index.d.ts +0 -72
  304. package/dist/plugins/fetch/index.d.ts.map +0 -1
  305. package/dist/plugins/fetch/index.js +0 -238
  306. package/dist/plugins/fetch/schemas.d.ts +0 -28
  307. package/dist/plugins/fetch/schemas.d.ts.map +0 -1
  308. package/dist/plugins/fetch/schemas.js +0 -52
  309. package/dist/plugins/findFirstConnection/index.d.ts +0 -115
  310. package/dist/plugins/findFirstConnection/index.d.ts.map +0 -1
  311. package/dist/plugins/findFirstConnection/index.js +0 -25
  312. package/dist/plugins/findFirstConnection/schemas.d.ts +0 -25
  313. package/dist/plugins/findFirstConnection/schemas.d.ts.map +0 -1
  314. package/dist/plugins/findFirstConnection/schemas.js +0 -9
  315. package/dist/plugins/findUniqueConnection/index.d.ts +0 -115
  316. package/dist/plugins/findUniqueConnection/index.d.ts.map +0 -1
  317. package/dist/plugins/findUniqueConnection/index.js +0 -28
  318. package/dist/plugins/findUniqueConnection/schemas.d.ts +0 -25
  319. package/dist/plugins/findUniqueConnection/schemas.d.ts.map +0 -1
  320. package/dist/plugins/findUniqueConnection/schemas.js +0 -9
  321. package/dist/plugins/getAction/index.d.ts +0 -215
  322. package/dist/plugins/getAction/index.d.ts.map +0 -1
  323. package/dist/plugins/getAction/index.js +0 -41
  324. package/dist/plugins/getAction/schemas.d.ts +0 -82
  325. package/dist/plugins/getAction/schemas.d.ts.map +0 -1
  326. package/dist/plugins/getAction/schemas.js +0 -22
  327. package/dist/plugins/getActionInputFieldsSchema/index.d.ts +0 -301
  328. package/dist/plugins/getActionInputFieldsSchema/index.d.ts.map +0 -1
  329. package/dist/plugins/getActionInputFieldsSchema/index.js +0 -57
  330. package/dist/plugins/getActionInputFieldsSchema/schemas.d.ts +0 -97
  331. package/dist/plugins/getActionInputFieldsSchema/schemas.d.ts.map +0 -1
  332. package/dist/plugins/getActionInputFieldsSchema/schemas.js +0 -49
  333. package/dist/plugins/getApp/index.d.ts +0 -146
  334. package/dist/plugins/getApp/index.d.ts.map +0 -1
  335. package/dist/plugins/getApp/index.js +0 -24
  336. package/dist/plugins/getApp/schemas.d.ts +0 -32
  337. package/dist/plugins/getApp/schemas.d.ts.map +0 -1
  338. package/dist/plugins/getApp/schemas.js +0 -18
  339. package/dist/plugins/getConnection/index.d.ts +0 -179
  340. package/dist/plugins/getConnection/index.d.ts.map +0 -1
  341. package/dist/plugins/getConnection/index.js +0 -33
  342. package/dist/plugins/getConnection/schemas.d.ts +0 -12
  343. package/dist/plugins/getConnection/schemas.d.ts.map +0 -1
  344. package/dist/plugins/getConnection/schemas.js +0 -14
  345. package/dist/plugins/getConnectionStartUrl/index.d.ts +0 -206
  346. package/dist/plugins/getConnectionStartUrl/index.d.ts.map +0 -1
  347. package/dist/plugins/getConnectionStartUrl/index.js +0 -39
  348. package/dist/plugins/getConnectionStartUrl/schemas.d.ts +0 -15
  349. package/dist/plugins/getConnectionStartUrl/schemas.d.ts.map +0 -1
  350. package/dist/plugins/getConnectionStartUrl/schemas.js +0 -23
  351. package/dist/plugins/getProfile/index.d.ts +0 -32
  352. package/dist/plugins/getProfile/index.d.ts.map +0 -1
  353. package/dist/plugins/getProfile/index.js +0 -28
  354. package/dist/plugins/getProfile/schemas.d.ts +0 -4
  355. package/dist/plugins/getProfile/schemas.d.ts.map +0 -1
  356. package/dist/plugins/getProfile/schemas.js +0 -5
  357. package/dist/plugins/listActionInputFieldChoices/index.d.ts +0 -372
  358. package/dist/plugins/listActionInputFieldChoices/index.d.ts.map +0 -1
  359. package/dist/plugins/listActionInputFieldChoices/index.js +0 -110
  360. package/dist/plugins/listActionInputFieldChoices/schemas.d.ts +0 -133
  361. package/dist/plugins/listActionInputFieldChoices/schemas.d.ts.map +0 -1
  362. package/dist/plugins/listActionInputFieldChoices/schemas.js +0 -75
  363. package/dist/plugins/listActionInputFields/index.d.ts +0 -330
  364. package/dist/plugins/listActionInputFields/index.d.ts.map +0 -1
  365. package/dist/plugins/listActionInputFields/index.js +0 -208
  366. package/dist/plugins/listActionInputFields/schemas.d.ts +0 -113
  367. package/dist/plugins/listActionInputFields/schemas.d.ts.map +0 -1
  368. package/dist/plugins/listActionInputFields/schemas.js +0 -56
  369. package/dist/plugins/listActions/index.d.ts +0 -219
  370. package/dist/plugins/listActions/index.d.ts.map +0 -1
  371. package/dist/plugins/listActions/index.js +0 -60
  372. package/dist/plugins/listActions/schemas.d.ts +0 -78
  373. package/dist/plugins/listActions/schemas.d.ts.map +0 -1
  374. package/dist/plugins/listActions/schemas.js +0 -33
  375. package/dist/plugins/listApps/index.d.ts +0 -127
  376. package/dist/plugins/listApps/index.d.ts.map +0 -1
  377. package/dist/plugins/listApps/index.js +0 -63
  378. package/dist/plugins/listApps/schemas.d.ts +0 -43
  379. package/dist/plugins/listApps/schemas.d.ts.map +0 -1
  380. package/dist/plugins/listApps/schemas.js +0 -54
  381. package/dist/plugins/listClientCredentials/index.d.ts +0 -36
  382. package/dist/plugins/listClientCredentials/index.d.ts.map +0 -1
  383. package/dist/plugins/listClientCredentials/index.js +0 -32
  384. package/dist/plugins/listClientCredentials/schemas.d.ts +0 -17
  385. package/dist/plugins/listClientCredentials/schemas.d.ts.map +0 -1
  386. package/dist/plugins/listClientCredentials/schemas.js +0 -23
  387. package/dist/plugins/listConnections/index.d.ts +0 -243
  388. package/dist/plugins/listConnections/index.d.ts.map +0 -1
  389. package/dist/plugins/listConnections/index.js +0 -97
  390. package/dist/plugins/listConnections/schemas.d.ts +0 -34
  391. package/dist/plugins/listConnections/schemas.d.ts.map +0 -1
  392. package/dist/plugins/listConnections/schemas.js +0 -74
  393. package/dist/plugins/manifest/index.d.ts +0 -97
  394. package/dist/plugins/manifest/index.d.ts.map +0 -1
  395. package/dist/plugins/manifest/index.js +0 -395
  396. package/dist/plugins/manifest/schemas.d.ts +0 -88
  397. package/dist/plugins/manifest/schemas.d.ts.map +0 -1
  398. package/dist/plugins/manifest/schemas.js +0 -61
  399. package/dist/plugins/registry/index.d.ts +0 -17
  400. package/dist/plugins/registry/index.d.ts.map +0 -1
  401. package/dist/plugins/registry/index.js +0 -11
  402. package/dist/plugins/request/index.d.ts +0 -70
  403. package/dist/plugins/request/index.d.ts.map +0 -1
  404. package/dist/plugins/request/index.js +0 -28
  405. package/dist/plugins/request/schemas.d.ts +0 -46
  406. package/dist/plugins/request/schemas.d.ts.map +0 -1
  407. package/dist/plugins/request/schemas.js +0 -42
  408. package/dist/plugins/runAction/index.d.ts +0 -313
  409. package/dist/plugins/runAction/index.d.ts.map +0 -1
  410. package/dist/plugins/runAction/index.js +0 -189
  411. package/dist/plugins/runAction/schemas.d.ts +0 -108
  412. package/dist/plugins/runAction/schemas.d.ts.map +0 -1
  413. package/dist/plugins/runAction/schemas.js +0 -53
  414. package/dist/plugins/tables/createTable/index.d.ts +0 -48
  415. package/dist/plugins/tables/createTable/index.d.ts.map +0 -1
  416. package/dist/plugins/tables/createTable/index.js +0 -20
  417. package/dist/plugins/tables/createTable/schemas.d.ts +0 -36
  418. package/dist/plugins/tables/createTable/schemas.d.ts.map +0 -1
  419. package/dist/plugins/tables/createTable/schemas.js +0 -16
  420. package/dist/plugins/tables/createTableFields/index.d.ts +0 -92
  421. package/dist/plugins/tables/createTableFields/index.d.ts.map +0 -1
  422. package/dist/plugins/tables/createTableFields/index.js +0 -29
  423. package/dist/plugins/tables/createTableFields/schemas.d.ts +0 -317
  424. package/dist/plugins/tables/createTableFields/schemas.d.ts.map +0 -1
  425. package/dist/plugins/tables/createTableFields/schemas.js +0 -62
  426. package/dist/plugins/tables/createTableRecords/index.d.ts +0 -114
  427. package/dist/plugins/tables/createTableRecords/index.d.ts.map +0 -1
  428. package/dist/plugins/tables/createTableRecords/index.js +0 -43
  429. package/dist/plugins/tables/createTableRecords/schemas.d.ts +0 -92
  430. package/dist/plugins/tables/createTableRecords/schemas.d.ts.map +0 -1
  431. package/dist/plugins/tables/createTableRecords/schemas.js +0 -55
  432. package/dist/plugins/tables/deleteTable/index.d.ts +0 -74
  433. package/dist/plugins/tables/deleteTable/index.d.ts.map +0 -1
  434. package/dist/plugins/tables/deleteTable/index.js +0 -23
  435. package/dist/plugins/tables/deleteTable/schemas.d.ts +0 -28
  436. package/dist/plugins/tables/deleteTable/schemas.d.ts.map +0 -1
  437. package/dist/plugins/tables/deleteTable/schemas.js +0 -21
  438. package/dist/plugins/tables/deleteTableFields/index.d.ts +0 -102
  439. package/dist/plugins/tables/deleteTableFields/index.d.ts.map +0 -1
  440. package/dist/plugins/tables/deleteTableFields/index.js +0 -30
  441. package/dist/plugins/tables/deleteTableFields/schemas.d.ts +0 -34
  442. package/dist/plugins/tables/deleteTableFields/schemas.d.ts.map +0 -1
  443. package/dist/plugins/tables/deleteTableFields/schemas.js +0 -29
  444. package/dist/plugins/tables/deleteTableRecords/index.d.ts +0 -123
  445. package/dist/plugins/tables/deleteTableRecords/index.d.ts.map +0 -1
  446. package/dist/plugins/tables/deleteTableRecords/index.js +0 -23
  447. package/dist/plugins/tables/deleteTableRecords/schemas.d.ts +0 -34
  448. package/dist/plugins/tables/deleteTableRecords/schemas.d.ts.map +0 -1
  449. package/dist/plugins/tables/deleteTableRecords/schemas.js +0 -30
  450. package/dist/plugins/tables/getTable/index.d.ts +0 -81
  451. package/dist/plugins/tables/getTable/index.d.ts.map +0 -1
  452. package/dist/plugins/tables/getTable/index.js +0 -24
  453. package/dist/plugins/tables/getTable/schemas.d.ts +0 -49
  454. package/dist/plugins/tables/getTable/schemas.d.ts.map +0 -1
  455. package/dist/plugins/tables/getTable/schemas.js +0 -27
  456. package/dist/plugins/tables/getTableRecord/index.d.ts +0 -131
  457. package/dist/plugins/tables/getTableRecord/index.d.ts.map +0 -1
  458. package/dist/plugins/tables/getTableRecord/index.js +0 -38
  459. package/dist/plugins/tables/getTableRecord/schemas.d.ts +0 -88
  460. package/dist/plugins/tables/getTableRecord/schemas.d.ts.map +0 -1
  461. package/dist/plugins/tables/getTableRecord/schemas.js +0 -56
  462. package/dist/plugins/tables/listTableFields/index.d.ts +0 -86
  463. package/dist/plugins/tables/listTableFields/index.d.ts.map +0 -1
  464. package/dist/plugins/tables/listTableFields/index.js +0 -41
  465. package/dist/plugins/tables/listTableFields/schemas.d.ts +0 -225
  466. package/dist/plugins/tables/listTableFields/schemas.d.ts.map +0 -1
  467. package/dist/plugins/tables/listTableFields/schemas.js +0 -93
  468. package/dist/plugins/tables/listTableRecords/index.d.ts +0 -136
  469. package/dist/plugins/tables/listTableRecords/index.d.ts.map +0 -1
  470. package/dist/plugins/tables/listTableRecords/index.js +0 -81
  471. package/dist/plugins/tables/listTableRecords/schemas.d.ts +0 -256
  472. package/dist/plugins/tables/listTableRecords/schemas.d.ts.map +0 -1
  473. package/dist/plugins/tables/listTableRecords/schemas.js +0 -95
  474. package/dist/plugins/tables/listTables/index.d.ts +0 -60
  475. package/dist/plugins/tables/listTables/index.d.ts.map +0 -1
  476. package/dist/plugins/tables/listTables/index.js +0 -67
  477. package/dist/plugins/tables/listTables/schemas.d.ts +0 -85
  478. package/dist/plugins/tables/listTables/schemas.d.ts.map +0 -1
  479. package/dist/plugins/tables/listTables/schemas.js +0 -72
  480. package/dist/plugins/tables/shared.d.ts +0 -10
  481. package/dist/plugins/tables/shared.d.ts.map +0 -1
  482. package/dist/plugins/tables/shared.js +0 -9
  483. package/dist/plugins/tables/updateTableRecords/index.d.ts +0 -116
  484. package/dist/plugins/tables/updateTableRecords/index.d.ts.map +0 -1
  485. package/dist/plugins/tables/updateTableRecords/index.js +0 -47
  486. package/dist/plugins/tables/updateTableRecords/schemas.d.ts +0 -97
  487. package/dist/plugins/tables/updateTableRecords/schemas.d.ts.map +0 -1
  488. package/dist/plugins/tables/updateTableRecords/schemas.js +0 -55
  489. package/dist/plugins/tables/utils.d.ts +0 -69
  490. package/dist/plugins/tables/utils.d.ts.map +0 -1
  491. package/dist/plugins/tables/utils.js +0 -270
  492. package/dist/plugins/triggers/ackTriggerInboxMessages/index.d.ts +0 -108
  493. package/dist/plugins/triggers/ackTriggerInboxMessages/index.d.ts.map +0 -1
  494. package/dist/plugins/triggers/ackTriggerInboxMessages/index.js +0 -36
  495. package/dist/plugins/triggers/ackTriggerInboxMessages/schemas.d.ts +0 -34
  496. package/dist/plugins/triggers/ackTriggerInboxMessages/schemas.d.ts.map +0 -1
  497. package/dist/plugins/triggers/ackTriggerInboxMessages/schemas.js +0 -17
  498. package/dist/plugins/triggers/createTriggerInbox/index.d.ts +0 -292
  499. package/dist/plugins/triggers/createTriggerInbox/index.d.ts.map +0 -1
  500. package/dist/plugins/triggers/createTriggerInbox/index.js +0 -68
  501. package/dist/plugins/triggers/createTriggerInbox/schemas.d.ts +0 -20
  502. package/dist/plugins/triggers/createTriggerInbox/schemas.d.ts.map +0 -1
  503. package/dist/plugins/triggers/createTriggerInbox/schemas.js +0 -21
  504. package/dist/plugins/triggers/deleteTriggerInbox/index.d.ts +0 -81
  505. package/dist/plugins/triggers/deleteTriggerInbox/index.d.ts.map +0 -1
  506. package/dist/plugins/triggers/deleteTriggerInbox/index.js +0 -29
  507. package/dist/plugins/triggers/deleteTriggerInbox/schemas.d.ts +0 -13
  508. package/dist/plugins/triggers/deleteTriggerInbox/schemas.d.ts.map +0 -1
  509. package/dist/plugins/triggers/deleteTriggerInbox/schemas.js +0 -9
  510. package/dist/plugins/triggers/drainTriggerInbox/index.d.ts +0 -277
  511. package/dist/plugins/triggers/drainTriggerInbox/index.d.ts.map +0 -1
  512. package/dist/plugins/triggers/drainTriggerInbox/index.js +0 -260
  513. package/dist/plugins/triggers/drainTriggerInbox/pipeline.d.ts +0 -56
  514. package/dist/plugins/triggers/drainTriggerInbox/pipeline.d.ts.map +0 -1
  515. package/dist/plugins/triggers/drainTriggerInbox/pipeline.js +0 -225
  516. package/dist/plugins/triggers/drainTriggerInbox/schemas.d.ts +0 -104
  517. package/dist/plugins/triggers/drainTriggerInbox/schemas.d.ts.map +0 -1
  518. package/dist/plugins/triggers/drainTriggerInbox/schemas.js +0 -102
  519. package/dist/plugins/triggers/ensureTriggerInbox/index.d.ts +0 -292
  520. package/dist/plugins/triggers/ensureTriggerInbox/index.d.ts.map +0 -1
  521. package/dist/plugins/triggers/ensureTriggerInbox/index.js +0 -65
  522. package/dist/plugins/triggers/ensureTriggerInbox/schemas.d.ts +0 -20
  523. package/dist/plugins/triggers/ensureTriggerInbox/schemas.d.ts.map +0 -1
  524. package/dist/plugins/triggers/ensureTriggerInbox/schemas.js +0 -21
  525. package/dist/plugins/triggers/getTriggerInbox/index.d.ts +0 -81
  526. package/dist/plugins/triggers/getTriggerInbox/index.d.ts.map +0 -1
  527. package/dist/plugins/triggers/getTriggerInbox/index.js +0 -28
  528. package/dist/plugins/triggers/getTriggerInbox/schemas.d.ts +0 -13
  529. package/dist/plugins/triggers/getTriggerInbox/schemas.d.ts.map +0 -1
  530. package/dist/plugins/triggers/getTriggerInbox/schemas.js +0 -9
  531. package/dist/plugins/triggers/getTriggerInputFieldsSchema/index.d.ts +0 -277
  532. package/dist/plugins/triggers/getTriggerInputFieldsSchema/index.d.ts.map +0 -1
  533. package/dist/plugins/triggers/getTriggerInputFieldsSchema/index.js +0 -23
  534. package/dist/plugins/triggers/getTriggerInputFieldsSchema/schemas.d.ts +0 -13
  535. package/dist/plugins/triggers/getTriggerInputFieldsSchema/schemas.d.ts.map +0 -1
  536. package/dist/plugins/triggers/getTriggerInputFieldsSchema/schemas.js +0 -10
  537. package/dist/plugins/triggers/leaseTriggerInboxMessages/index.d.ts +0 -89
  538. package/dist/plugins/triggers/leaseTriggerInboxMessages/index.d.ts.map +0 -1
  539. package/dist/plugins/triggers/leaseTriggerInboxMessages/index.js +0 -74
  540. package/dist/plugins/triggers/leaseTriggerInboxMessages/schemas.d.ts +0 -57
  541. package/dist/plugins/triggers/leaseTriggerInboxMessages/schemas.d.ts.map +0 -1
  542. package/dist/plugins/triggers/leaseTriggerInboxMessages/schemas.js +0 -25
  543. package/dist/plugins/triggers/listTriggerInboxMessages/index.d.ts +0 -82
  544. package/dist/plugins/triggers/listTriggerInboxMessages/index.d.ts.map +0 -1
  545. package/dist/plugins/triggers/listTriggerInboxMessages/index.js +0 -40
  546. package/dist/plugins/triggers/listTriggerInboxMessages/schemas.d.ts +0 -37
  547. package/dist/plugins/triggers/listTriggerInboxMessages/schemas.d.ts.map +0 -1
  548. package/dist/plugins/triggers/listTriggerInboxMessages/schemas.js +0 -27
  549. package/dist/plugins/triggers/listTriggerInboxes/index.d.ts +0 -56
  550. package/dist/plugins/triggers/listTriggerInboxes/index.d.ts.map +0 -1
  551. package/dist/plugins/triggers/listTriggerInboxes/index.js +0 -42
  552. package/dist/plugins/triggers/listTriggerInboxes/schemas.d.ts +0 -58
  553. package/dist/plugins/triggers/listTriggerInboxes/schemas.d.ts.map +0 -1
  554. package/dist/plugins/triggers/listTriggerInboxes/schemas.js +0 -35
  555. package/dist/plugins/triggers/listTriggerInputFieldChoices/index.d.ts +0 -360
  556. package/dist/plugins/triggers/listTriggerInputFieldChoices/index.d.ts.map +0 -1
  557. package/dist/plugins/triggers/listTriggerInputFieldChoices/index.js +0 -32
  558. package/dist/plugins/triggers/listTriggerInputFieldChoices/schemas.d.ts +0 -20
  559. package/dist/plugins/triggers/listTriggerInputFieldChoices/schemas.d.ts.map +0 -1
  560. package/dist/plugins/triggers/listTriggerInputFieldChoices/schemas.js +0 -28
  561. package/dist/plugins/triggers/listTriggerInputFields/index.d.ts +0 -330
  562. package/dist/plugins/triggers/listTriggerInputFields/index.d.ts.map +0 -1
  563. package/dist/plugins/triggers/listTriggerInputFields/index.js +0 -34
  564. package/dist/plugins/triggers/listTriggerInputFields/schemas.d.ts +0 -16
  565. package/dist/plugins/triggers/listTriggerInputFields/schemas.d.ts.map +0 -1
  566. package/dist/plugins/triggers/listTriggerInputFields/schemas.js +0 -21
  567. package/dist/plugins/triggers/listTriggers/index.d.ts +0 -207
  568. package/dist/plugins/triggers/listTriggers/index.d.ts.map +0 -1
  569. package/dist/plugins/triggers/listTriggers/index.js +0 -26
  570. package/dist/plugins/triggers/listTriggers/schemas.d.ts +0 -11
  571. package/dist/plugins/triggers/listTriggers/schemas.d.ts.map +0 -1
  572. package/dist/plugins/triggers/listTriggers/schemas.js +0 -18
  573. package/dist/plugins/triggers/pauseTriggerInbox/index.d.ts +0 -81
  574. package/dist/plugins/triggers/pauseTriggerInbox/index.d.ts.map +0 -1
  575. package/dist/plugins/triggers/pauseTriggerInbox/index.js +0 -28
  576. package/dist/plugins/triggers/pauseTriggerInbox/schemas.d.ts +0 -13
  577. package/dist/plugins/triggers/pauseTriggerInbox/schemas.d.ts.map +0 -1
  578. package/dist/plugins/triggers/pauseTriggerInbox/schemas.js +0 -9
  579. package/dist/plugins/triggers/releaseTriggerInboxMessages/index.d.ts +0 -108
  580. package/dist/plugins/triggers/releaseTriggerInboxMessages/index.d.ts.map +0 -1
  581. package/dist/plugins/triggers/releaseTriggerInboxMessages/index.js +0 -38
  582. package/dist/plugins/triggers/releaseTriggerInboxMessages/schemas.d.ts +0 -34
  583. package/dist/plugins/triggers/releaseTriggerInboxMessages/schemas.d.ts.map +0 -1
  584. package/dist/plugins/triggers/releaseTriggerInboxMessages/schemas.js +0 -17
  585. package/dist/plugins/triggers/resumeTriggerInbox/index.d.ts +0 -81
  586. package/dist/plugins/triggers/resumeTriggerInbox/index.d.ts.map +0 -1
  587. package/dist/plugins/triggers/resumeTriggerInbox/index.js +0 -28
  588. package/dist/plugins/triggers/resumeTriggerInbox/schemas.d.ts +0 -13
  589. package/dist/plugins/triggers/resumeTriggerInbox/schemas.d.ts.map +0 -1
  590. package/dist/plugins/triggers/resumeTriggerInbox/schemas.js +0 -9
  591. package/dist/plugins/triggers/shared.d.ts +0 -17
  592. package/dist/plugins/triggers/shared.d.ts.map +0 -1
  593. package/dist/plugins/triggers/shared.js +0 -16
  594. package/dist/plugins/triggers/updateTriggerInbox/index.d.ts +0 -82
  595. package/dist/plugins/triggers/updateTriggerInbox/index.d.ts.map +0 -1
  596. package/dist/plugins/triggers/updateTriggerInbox/index.js +0 -32
  597. package/dist/plugins/triggers/updateTriggerInbox/schemas.d.ts +0 -14
  598. package/dist/plugins/triggers/updateTriggerInbox/schemas.d.ts.map +0 -1
  599. package/dist/plugins/triggers/updateTriggerInbox/schemas.js +0 -15
  600. package/dist/plugins/triggers/utils.d.ts +0 -23
  601. package/dist/plugins/triggers/utils.d.ts.map +0 -1
  602. package/dist/plugins/triggers/utils.js +0 -45
  603. package/dist/plugins/triggers/watchTriggerInbox/index.d.ts +0 -221
  604. package/dist/plugins/triggers/watchTriggerInbox/index.d.ts.map +0 -1
  605. package/dist/plugins/triggers/watchTriggerInbox/index.js +0 -402
  606. package/dist/plugins/triggers/watchTriggerInbox/sse.d.ts +0 -32
  607. package/dist/plugins/triggers/watchTriggerInbox/sse.d.ts.map +0 -1
  608. package/dist/plugins/triggers/watchTriggerInbox/sse.js +0 -36
  609. package/dist/plugins/waitForNewConnection/index.d.ts +0 -209
  610. package/dist/plugins/waitForNewConnection/index.d.ts.map +0 -1
  611. package/dist/plugins/waitForNewConnection/index.js +0 -75
  612. package/dist/plugins/waitForNewConnection/schemas.d.ts +0 -17
  613. package/dist/plugins/waitForNewConnection/schemas.d.ts.map +0 -1
  614. package/dist/plugins/waitForNewConnection/schemas.js +0 -39
  615. package/dist/resolvers/actionKey.d.ts +0 -16
  616. package/dist/resolvers/actionKey.d.ts.map +0 -1
  617. package/dist/resolvers/actionKey.js +0 -20
  618. package/dist/resolvers/actionType.d.ts +0 -14
  619. package/dist/resolvers/actionType.d.ts.map +0 -1
  620. package/dist/resolvers/actionType.js +0 -24
  621. package/dist/resolvers/appKey.d.ts +0 -13
  622. package/dist/resolvers/appKey.d.ts.map +0 -1
  623. package/dist/resolvers/appKey.js +0 -50
  624. package/dist/resolvers/clientCredentialsName.d.ts +0 -3
  625. package/dist/resolvers/clientCredentialsName.d.ts.map +0 -1
  626. package/dist/resolvers/clientCredentialsName.js +0 -5
  627. package/dist/resolvers/clientId.d.ts +0 -5
  628. package/dist/resolvers/clientId.d.ts.map +0 -1
  629. package/dist/resolvers/clientId.js +0 -14
  630. package/dist/resolvers/connectionId.d.ts +0 -12
  631. package/dist/resolvers/connectionId.d.ts.map +0 -1
  632. package/dist/resolvers/connectionId.js +0 -52
  633. package/dist/resolvers/durableRunId.d.ts +0 -5
  634. package/dist/resolvers/durableRunId.d.ts.map +0 -1
  635. package/dist/resolvers/durableRunId.js +0 -15
  636. package/dist/resolvers/index.d.ts +0 -27
  637. package/dist/resolvers/index.d.ts.map +0 -1
  638. package/dist/resolvers/index.js +0 -28
  639. package/dist/resolvers/inputFieldKey.d.ts +0 -12
  640. package/dist/resolvers/inputFieldKey.d.ts.map +0 -1
  641. package/dist/resolvers/inputFieldKey.js +0 -51
  642. package/dist/resolvers/inputs.d.ts +0 -17
  643. package/dist/resolvers/inputs.d.ts.map +0 -1
  644. package/dist/resolvers/inputs.js +0 -50
  645. package/dist/resolvers/tableFieldIds.d.ts +0 -7
  646. package/dist/resolvers/tableFieldIds.d.ts.map +0 -1
  647. package/dist/resolvers/tableFieldIds.js +0 -20
  648. package/dist/resolvers/tableFields.d.ts +0 -3
  649. package/dist/resolvers/tableFields.d.ts.map +0 -1
  650. package/dist/resolvers/tableFields.js +0 -31
  651. package/dist/resolvers/tableFilters.d.ts +0 -6
  652. package/dist/resolvers/tableFilters.d.ts.map +0 -1
  653. package/dist/resolvers/tableFilters.js +0 -74
  654. package/dist/resolvers/tableId.d.ts +0 -5
  655. package/dist/resolvers/tableId.d.ts.map +0 -1
  656. package/dist/resolvers/tableId.js +0 -30
  657. package/dist/resolvers/tableName.d.ts +0 -3
  658. package/dist/resolvers/tableName.d.ts.map +0 -1
  659. package/dist/resolvers/tableName.js +0 -5
  660. package/dist/resolvers/tableRecordId.d.ts +0 -10
  661. package/dist/resolvers/tableRecordId.d.ts.map +0 -1
  662. package/dist/resolvers/tableRecordId.js +0 -49
  663. package/dist/resolvers/tableRecords.d.ts +0 -9
  664. package/dist/resolvers/tableRecords.d.ts.map +0 -1
  665. package/dist/resolvers/tableRecords.js +0 -77
  666. package/dist/resolvers/tableSort.d.ts +0 -6
  667. package/dist/resolvers/tableSort.d.ts.map +0 -1
  668. package/dist/resolvers/tableSort.js +0 -43
  669. package/dist/resolvers/triggerInbox.d.ts +0 -5
  670. package/dist/resolvers/triggerInbox.d.ts.map +0 -1
  671. package/dist/resolvers/triggerInbox.js +0 -19
  672. package/dist/resolvers/triggerMessages.d.ts +0 -7
  673. package/dist/resolvers/triggerMessages.d.ts.map +0 -1
  674. package/dist/resolvers/triggerMessages.js +0 -21
  675. package/dist/resolvers/workflowId.d.ts +0 -5
  676. package/dist/resolvers/workflowId.d.ts.map +0 -1
  677. package/dist/resolvers/workflowId.js +0 -15
  678. package/dist/resolvers/workflowRunId.d.ts +0 -7
  679. package/dist/resolvers/workflowRunId.d.ts.map +0 -1
  680. package/dist/resolvers/workflowRunId.js +0 -20
  681. package/dist/resolvers/workflowVersionId.d.ts +0 -7
  682. package/dist/resolvers/workflowVersionId.d.ts.map +0 -1
  683. package/dist/resolvers/workflowVersionId.js +0 -20
  684. package/dist/schemas/Action.d.ts +0 -24
  685. package/dist/schemas/Action.d.ts.map +0 -1
  686. package/dist/schemas/Action.js +0 -16
  687. package/dist/schemas/App.d.ts +0 -56
  688. package/dist/schemas/App.d.ts.map +0 -1
  689. package/dist/schemas/App.js +0 -5
  690. package/dist/schemas/ClientCredentials.d.ts +0 -19
  691. package/dist/schemas/ClientCredentials.d.ts.map +0 -1
  692. package/dist/schemas/ClientCredentials.js +0 -6
  693. package/dist/schemas/Connection.d.ts +0 -32
  694. package/dist/schemas/Connection.d.ts.map +0 -1
  695. package/dist/schemas/Connection.js +0 -5
  696. package/dist/schemas/Field.d.ts +0 -61
  697. package/dist/schemas/Field.d.ts.map +0 -1
  698. package/dist/schemas/Field.js +0 -49
  699. package/dist/schemas/Run.d.ts +0 -3
  700. package/dist/schemas/Run.d.ts.map +0 -1
  701. package/dist/schemas/Run.js +0 -5
  702. package/dist/schemas/TriggerInbox.d.ts +0 -59
  703. package/dist/schemas/TriggerInbox.d.ts.map +0 -1
  704. package/dist/schemas/TriggerInbox.js +0 -49
  705. package/dist/schemas/TriggerMessage.d.ts +0 -48
  706. package/dist/schemas/TriggerMessage.d.ts.map +0 -1
  707. package/dist/schemas/TriggerMessage.js +0 -21
  708. package/dist/schemas/UserProfile.d.ts +0 -12
  709. package/dist/schemas/UserProfile.d.ts.map +0 -1
  710. package/dist/schemas/UserProfile.js +0 -13
  711. package/dist/sdk-version.d.ts +0 -28
  712. package/dist/sdk-version.d.ts.map +0 -1
  713. package/dist/sdk-version.js +0 -29
  714. package/dist/sdk.d.ts +0 -6065
  715. package/dist/sdk.d.ts.map +0 -1
  716. package/dist/sdk.js +0 -173
  717. package/dist/services/implementations.d.ts +0 -63
  718. package/dist/services/implementations.d.ts.map +0 -1
  719. package/dist/services/implementations.js +0 -79
  720. package/dist/types/connections.d.ts +0 -19
  721. package/dist/types/connections.d.ts.map +0 -1
  722. package/dist/types/connections.js +0 -20
  723. package/dist/types/credentials.d.ts +0 -186
  724. package/dist/types/credentials.d.ts.map +0 -1
  725. package/dist/types/credentials.js +0 -123
  726. package/dist/types/domain.d.ts +0 -52
  727. package/dist/types/domain.d.ts.map +0 -1
  728. package/dist/types/domain.js +0 -1
  729. package/dist/types/errors.d.ts +0 -254
  730. package/dist/types/errors.d.ts.map +0 -1
  731. package/dist/types/errors.js +0 -336
  732. package/dist/types/events.d.ts +0 -38
  733. package/dist/types/events.d.ts.map +0 -1
  734. package/dist/types/events.js +0 -7
  735. package/dist/types/functions.d.ts +0 -2
  736. package/dist/types/functions.d.ts.map +0 -1
  737. package/dist/types/functions.js +0 -1
  738. package/dist/types/properties.d.ts +0 -83
  739. package/dist/types/properties.d.ts.map +0 -1
  740. package/dist/types/properties.js +0 -120
  741. package/dist/types/sdk.d.ts +0 -97
  742. package/dist/types/sdk.d.ts.map +0 -1
  743. package/dist/types/sdk.js +0 -114
  744. package/dist/types/signals.d.ts +0 -20
  745. package/dist/types/signals.d.ts.map +0 -1
  746. package/dist/types/signals.js +0 -21
  747. package/dist/types/telemetry-events.d.ts +0 -114
  748. package/dist/types/telemetry-events.d.ts.map +0 -1
  749. package/dist/types/telemetry-events.js +0 -10
  750. package/dist/utils/abort-utils.d.ts +0 -77
  751. package/dist/utils/abort-utils.d.ts.map +0 -1
  752. package/dist/utils/abort-utils.js +0 -122
  753. package/dist/utils/agent.d.ts +0 -44
  754. package/dist/utils/agent.d.ts.map +0 -1
  755. package/dist/utils/agent.js +0 -76
  756. package/dist/utils/array-utils.d.ts +0 -31
  757. package/dist/utils/array-utils.d.ts.map +0 -1
  758. package/dist/utils/array-utils.js +0 -36
  759. package/dist/utils/batch-utils.d.ts +0 -72
  760. package/dist/utils/batch-utils.d.ts.map +0 -1
  761. package/dist/utils/batch-utils.js +0 -161
  762. package/dist/utils/caller-context.d.ts +0 -21
  763. package/dist/utils/caller-context.d.ts.map +0 -1
  764. package/dist/utils/caller-context.js +0 -35
  765. package/dist/utils/domain-utils.d.ts +0 -96
  766. package/dist/utils/domain-utils.d.ts.map +0 -1
  767. package/dist/utils/domain-utils.js +0 -248
  768. package/dist/utils/file-utils.d.ts +0 -4
  769. package/dist/utils/file-utils.d.ts.map +0 -1
  770. package/dist/utils/file-utils.js +0 -74
  771. package/dist/utils/id-utils.d.ts +0 -15
  772. package/dist/utils/id-utils.d.ts.map +0 -1
  773. package/dist/utils/id-utils.js +0 -24
  774. package/dist/utils/logging.d.ts +0 -2
  775. package/dist/utils/logging.d.ts.map +0 -1
  776. package/dist/utils/logging.js +0 -2
  777. package/dist/utils/open-approval.d.ts +0 -2
  778. package/dist/utils/open-approval.d.ts.map +0 -1
  779. package/dist/utils/open-approval.js +0 -13
  780. package/dist/utils/open-url.d.ts +0 -3
  781. package/dist/utils/open-url.d.ts.map +0 -1
  782. package/dist/utils/open-url.js +0 -79
  783. package/dist/utils/pagination.d.ts +0 -38
  784. package/dist/utils/pagination.d.ts.map +0 -1
  785. package/dist/utils/pagination.js +0 -53
  786. package/dist/utils/retry-utils.d.ts +0 -70
  787. package/dist/utils/retry-utils.d.ts.map +0 -1
  788. package/dist/utils/retry-utils.js +0 -97
  789. package/dist/utils/should-open-browser.d.ts +0 -24
  790. package/dist/utils/should-open-browser.d.ts.map +0 -1
  791. package/dist/utils/should-open-browser.js +0 -55
  792. package/dist/utils/telemetry.d.ts +0 -11
  793. package/dist/utils/telemetry.d.ts.map +0 -1
  794. package/dist/utils/telemetry.js +0 -19
  795. package/dist/utils/type-guard-utils.d.ts +0 -7
  796. package/dist/utils/type-guard-utils.d.ts.map +0 -1
  797. package/dist/utils/type-guard-utils.js +0 -11
  798. package/dist/utils/url-utils.d.ts +0 -25
  799. package/dist/utils/url-utils.d.ts.map +0 -1
  800. package/dist/utils/url-utils.js +0 -79
@@ -1,1232 +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 { createSemaphore } from "./concurrency";
9
- import { createDebugLogger, createDebugFetch } from "./debug";
10
- import { pollUntilComplete } from "./polling";
11
- import { resolveAuthToken, invalidateCredentialsToken, isCliLoginAvailable, } from "../auth";
12
- import { getZapierBaseUrl, isLocalhostBaseUrl } from "../utils/url-utils";
13
- import { sleep, calculateExponentialBackoffMs } from "../utils/retry-utils";
14
- import { isPlainObject } from "../utils/type-guard-utils";
15
- import { isAbortError } from "../utils/abort-utils";
16
- import { getCallerContext } from "../utils/caller-context";
17
- import { getAgent } from "../utils/agent";
18
- import { createSseParserStream, jsonFrames, } from "./sse-parser";
19
- import { consumeApprovalReviewStream } from "./approval-review-stream";
20
- import { ZapierApiError, ZapierApprovalError, ZapierAuthenticationError, ZapierConfigurationError, ZapierTimeoutError, ZapierValidationError, ZapierResourceNotFoundError, ZapierRateLimitError, } from "../types/errors";
21
- import { MAX_CONCURRENCY_LIMIT, ZAPIER_MAX_CONCURRENT_REQUESTS, ZAPIER_MAX_NETWORK_RETRIES, ZAPIER_MAX_NETWORK_RETRY_DELAY_MS, getZapierApprovalMode, getZapierDefaultApprovalMode, getZapierOpenAutoModeApprovalsInBrowser, getZapierSdkService, DEFAULT_APPROVAL_TIMEOUT_MS, DEFAULT_MAX_APPROVAL_RETRIES, } from "../constants";
22
- import { SDK_VERSION } from "../sdk-version";
23
- import { openApproval } from "../utils/open-approval";
24
- import { z } from "zod";
25
- const ApprovalStatusSchema = z.enum([
26
- "pending_approval",
27
- "approved",
28
- "denied",
29
- "failed",
30
- ]);
31
- const ApprovalModeSchema = z.enum(["manual", "auto"]);
32
- const CreateApprovalResponseSchema = z
33
- .object({
34
- id: z.string().optional(),
35
- status: ApprovalStatusSchema,
36
- approval_id: z.string().optional(),
37
- mode: ApprovalModeSchema,
38
- approval_url: z.string().url(),
39
- poll_url: z.string().url(),
40
- stream_url: z.string().url().optional(),
41
- reason: z.string().optional(),
42
- })
43
- .transform((approval, ctx) => {
44
- const id = approval.id ?? approval.approval_id;
45
- if (!id) {
46
- ctx.addIssue({
47
- code: "custom",
48
- message: "Approval response must include id",
49
- });
50
- return z.NEVER;
51
- }
52
- return { ...approval, id };
53
- });
54
- const PollApprovalResponseSchema = z.object({
55
- id: z.string().optional(),
56
- status: ApprovalStatusSchema,
57
- approval_id: z.string().optional(),
58
- mode: ApprovalModeSchema.optional(),
59
- reason: z.string().optional(),
60
- });
61
- const APPROVAL_MAX_POLLING_INTERVAL_MS = 5000;
62
- /**
63
- * Parse rate limit information from response headers
64
- */
65
- function parseRateLimitHeaders(response) {
66
- const info = {};
67
- // Parse Retry-After header (can be seconds or HTTP date)
68
- const retryAfter = response.headers.get("retry-after");
69
- if (retryAfter) {
70
- const seconds = parseInt(retryAfter, 10);
71
- if (!isNaN(seconds)) {
72
- info.retryAfterMs = seconds * 1000;
73
- }
74
- else {
75
- // Try parsing as HTTP date
76
- const date = Date.parse(retryAfter);
77
- if (!isNaN(date)) {
78
- info.retryAfterMs = Math.max(0, date - Date.now());
79
- }
80
- }
81
- }
82
- // Parse X-RateLimit-Reset (Unix timestamp)
83
- const reset = response.headers.get("x-ratelimit-reset");
84
- if (reset) {
85
- const resetTimestamp = parseInt(reset, 10);
86
- if (!isNaN(resetTimestamp)) {
87
- // Convert to ms (timestamps are usually in seconds)
88
- info.resetMs = resetTimestamp * 1000;
89
- // If no Retry-After, calculate wait time from reset
90
- if (info.retryAfterMs === undefined) {
91
- info.retryAfterMs = Math.max(0, info.resetMs - Date.now());
92
- }
93
- }
94
- }
95
- // Parse X-RateLimit-Limit
96
- const limit = response.headers.get("x-ratelimit-limit");
97
- if (limit) {
98
- const limitNum = parseInt(limit, 10);
99
- if (!isNaN(limitNum)) {
100
- info.limit = limitNum;
101
- }
102
- }
103
- // Parse X-RateLimit-Remaining
104
- const remaining = response.headers.get("x-ratelimit-remaining");
105
- if (remaining) {
106
- const remainingNum = parseInt(remaining, 10);
107
- if (!isNaN(remainingNum)) {
108
- info.remaining = remainingNum;
109
- }
110
- }
111
- return info;
112
- }
113
- // Configuration for paths
114
- const pathConfig = {
115
- // e.g. /relay -> https://sdkapi.zapier.com/api/v0/sdk/relay/...
116
- "/relay": {
117
- authHeader: "X-Relay-Authorization",
118
- pathPrefix: "/api/v0/sdk/relay",
119
- },
120
- // e.g. /zapier -> https://sdkapi.zapier.com/api/v0/sdk/zapier/...
121
- "/zapier": {
122
- authHeader: "Authorization",
123
- pathPrefix: "/api/v0/sdk/zapier",
124
- },
125
- // e.g. /tables -> https://sdkapi.zapier.com/api/v0/sdk/tables/...
126
- "/tables": {
127
- authHeader: "Authorization",
128
- pathPrefix: "/api/v0/sdk/tables",
129
- },
130
- // e.g. /trigger-inbox -> https://sdkapi.zapier.com/api/v0/sdk/trigger-inbox/...
131
- "/trigger-inbox": {
132
- authHeader: "Authorization",
133
- pathPrefix: "/api/v0/sdk/trigger-inbox",
134
- },
135
- // e.g. /sdkdurableapi -> https://sdkapi.zapier.com/api/v0/sdk/sdkdurableapi/...
136
- // sdkapi proxies to the sdkdurableapi backend.
137
- "/sdkdurableapi": {
138
- authHeader: "Authorization",
139
- pathPrefix: "/api/v0/sdk/sdkdurableapi",
140
- },
141
- // e.g. /durableworkflowzaps -> https://sdkapi.zapier.com/api/v0/sdk/durableworkflowzaps/...
142
- // sdkapi proxies to the durableworkflowzaps backend.
143
- "/durableworkflowzaps": {
144
- authHeader: "Authorization",
145
- pathPrefix: "/api/v0/sdk/durableworkflowzaps",
146
- },
147
- };
148
- class ZapierApiClient {
149
- constructor(options) {
150
- this.options = options;
151
- /**
152
- * Perform a request against an already-resolved URL.
153
- *
154
- * Does auth, header merging, and 429 retry — all the cross-cutting
155
- * concerns that every Zapier-bound HTTP call needs. Callers that have a
156
- * path (e.g. `/relay/...`) should use `rawFetch` instead, which does
157
- * path → URL resolution and delegates here.
158
- *
159
- * Exposed as a separate helper so call sites with a server-supplied
160
- * absolute URL (e.g. an approval poll URL) can still share the same
161
- * auth/retry pipeline instead of reaching for `this.options.fetch`
162
- * directly and drifting.
163
- */
164
- this.rawFetchUrl = async (url, init, pathConfig) => {
165
- if (init?.body && (isPlainObject(init.body) || Array.isArray(init.body))) {
166
- init.body = JSON.stringify(init.body);
167
- }
168
- const builtHeaders = await this.buildHeaders(init, pathConfig);
169
- const inputHeaders = new Headers(init?.headers ?? {});
170
- const mergedHeaders = new Headers();
171
- builtHeaders.forEach((value, key) => {
172
- mergedHeaders.set(key, value);
173
- });
174
- inputHeaders.forEach((value, key) => {
175
- mergedHeaders.set(key, value);
176
- });
177
- this.applyTelemetryHeaders(mergedHeaders);
178
- let retries = 0;
179
- // Retry loop for rate limiting (429)
180
- while (true) {
181
- const response = await this.options.fetch(url, {
182
- ...init,
183
- headers: mergedHeaders,
184
- });
185
- if (response.status !== 429) {
186
- return response;
187
- }
188
- // Calculate delay: prefer Retry-After/X-RateLimit-Reset, fall back to exponential backoff
189
- const rateLimitInfo = parseRateLimitHeaders(response);
190
- const delayMs = rateLimitInfo.retryAfterMs ??
191
- calculateExponentialBackoffMs(retries + 1);
192
- // If delay exceeds maxNetworkRetryDelayMs or retries exhausted, throw immediately
193
- if (delayMs > this.maxNetworkRetryDelayMs ||
194
- retries >= this.maxNetworkRetries) {
195
- throw new ZapierRateLimitError("Rate limited", {
196
- statusCode: 429,
197
- rateLimit: rateLimitInfo,
198
- retries,
199
- });
200
- }
201
- retries++;
202
- // Emit retry event
203
- this.emitEvent("api:rate_limit_retry", {
204
- retry: retries,
205
- maxNetworkRetries: this.maxNetworkRetries,
206
- delayMs,
207
- path: url,
208
- method: init?.method ?? "GET",
209
- rateLimit: rateLimitInfo,
210
- });
211
- // Pass the caller's signal into sleep so an abort during the
212
- // backoff stops the wait — the next fetch in the loop then
213
- // surfaces the abort, and `withSemaphore`'s finally releases the
214
- // permit. Without this, an aborted request keeps holding its
215
- // slot for the full Retry-After interval and blocks every queued
216
- // waiter behind it.
217
- await sleep(delayMs, init?.signal ?? undefined);
218
- }
219
- };
220
- /**
221
- * Wrap an outbound HTTP call with the concurrency semaphore. Used by both
222
- * `rawFetch` (path-based) and the approval-poll path (absolute URL); each
223
- * caller acquires per-attempt, so 429 retry sleep is held but the gap
224
- * between approval polls and the human-approval wait are not.
225
- *
226
- * The release is registered in a finally that wraps the entire post-
227
- * acquire flow — including the `wait_end` event emission — so a throwing
228
- * `onEvent` handler can never leak a permit.
229
- *
230
- * Slot lifetime is intentionally tied to "fetch resolves" (headers
231
- * received), NOT to "response body fully consumed". WHATWG `fetch()`
232
- * resolves once headers are in; the body is still streaming. We rely on
233
- * that boundary so streaming responses (SSE, long-running chunked reads)
234
- * don't pin a permit for the lifetime of the stream — a single SSE
235
- * consumer would otherwise hold one of N slots for as long as the
236
- * connection stays open. Do not move the release into a path that awaits
237
- * body consumption (e.g. `parseResult` / `response.text()`); doing so
238
- * would silently break streaming consumers without failing any of the
239
- * short-request tests.
240
- */
241
- this.withSemaphore = async (context, fn) => {
242
- const fastRelease = this.semaphore.tryAcquire();
243
- let waitStart = null;
244
- let release = fastRelease;
245
- if (release === null) {
246
- waitStart = Date.now();
247
- this.emitEvent("api:concurrency_wait_start", {
248
- url: context.url,
249
- method: context.method,
250
- });
251
- release = await this.semaphore.acquire(context.signal ?? undefined);
252
- }
253
- const acquiredRelease = release;
254
- try {
255
- if (waitStart !== null) {
256
- this.emitEvent("api:concurrency_wait_end", {
257
- url: context.url,
258
- method: context.method,
259
- waitedMs: Date.now() - waitStart,
260
- });
261
- }
262
- return await fn();
263
- }
264
- finally {
265
- acquiredRelease();
266
- }
267
- };
268
- /**
269
- * Perform a request with auth, header merging, and rate-limit (429) retries.
270
- * Does NOT handle 403 approval_required — that's routed by `fetch`.
271
- *
272
- * Concurrency: a semaphore slot is held across the entire call, including
273
- * the 429 retry sleep inside `rawFetchUrl`. That keeps backpressure
274
- * coherent — when the server is rate-limiting us, we don't dump more
275
- * parallelism into the queue.
276
- */
277
- this.rawFetch = async (path, init) => {
278
- if (!path.startsWith("/")) {
279
- throw new ZapierValidationError(`fetch expects a path starting with '/', got: ${path}`);
280
- }
281
- const { url, pathConfig } = this.buildUrl(path, init?.searchParams);
282
- return this.withSemaphore({ url, method: init?.method ?? "GET", signal: init?.signal }, () => this.rawFetchUrl(url, init, pathConfig));
283
- };
284
- /**
285
- * Approval-aware HTTP fetch.
286
- *
287
- * Wraps `rawFetch` with the backend's just-in-time approval protocol. The
288
- * backend signals approval state via a 403 response with an
289
- * `x-zapier-error-type` header:
290
- *
291
- * - `request_denied_by_policy` → a policy rule permanently blocks the
292
- * request; no human can approve it. Throw.
293
- * - `approval_required` → the request needs human approval; the
294
- * SDK creates an approval, opens the URL
295
- * (poll mode), waits for resolution, and
296
- * retries the original request.
297
- * - anything else → not our concern, pass through.
298
- *
299
- * The retry loop exists because a single user action can legitimately
300
- * require multiple sequential approvals (e.g. policies that approve one
301
- * step at a time). Each iteration is either a first attempt or a post-
302
- * approval retry; `maxApprovalRetries` bounds the loop as a runaway-loop
303
- * safeguard.
304
- *
305
- * Loop accounting: `attempt` counts rawFetch calls, not approval rounds.
306
- * With `maxRetries = N` we perform up to `N + 1` rawFetch calls and at
307
- * most `N` approval rounds. The `attempt === maxRetries` guard ensures we
308
- * don't run an (N+1)th approval round we'll never consume — if the final
309
- * retry still returns `approval_required`, we break out and throw
310
- * `max_retries_exceeded` instead.
311
- */
312
- this.fetch = async (path, init) => {
313
- const maxRetries = this.options.maxApprovalRetries ?? DEFAULT_MAX_APPROVAL_RETRIES;
314
- // `<= maxRetries` gives us one initial attempt plus `maxRetries` post-
315
- // approval retries. See "Loop accounting" in the jsdoc above.
316
- for (let attempt = 0; attempt <= maxRetries; attempt++) {
317
- const response = await this.rawFetch(path, init);
318
- // Happy path and non-403 errors: hand the response back untouched. Any
319
- // other error handling (e.g. 4xx envelope parsing) lives downstream.
320
- if (response.status !== 403)
321
- return response;
322
- // All approval-related responses are 403 + a typed header. Classify the
323
- // kind of 403 we got exactly once, here — no other call site should be
324
- // reading `x-zapier-error-type`.
325
- const errorType = response.headers.get("x-zapier-error-type");
326
- // Terminal policy denial: a rule blocked the request and no approval
327
- // can unblock it. Bubble the server-provided detail message so callers
328
- // surface the actual reason ("Spend over $X requires finance approval",
329
- // etc.) rather than a generic one.
330
- if (errorType === "request_denied_by_policy") {
331
- const { data } = await this.parseResult(response);
332
- const { message, errors } = this.parseErrorResponse({
333
- status: response.status,
334
- statusText: response.statusText,
335
- data,
336
- });
337
- throw new ZapierApprovalError(message || "Request explicitly denied by policy", {
338
- status: "policy_denied",
339
- statusCode: response.status,
340
- errors,
341
- });
342
- }
343
- // 403 with no `approval_required` header isn't part of the approval
344
- // protocol — could be auth scope, per-endpoint perms, etc. Pass it
345
- // through so the caller's normal error handling sees it.
346
- if (errorType !== "approval_required")
347
- return response;
348
- // We got `approval_required`. If this was our last scheduled attempt,
349
- // don't start an approval round we can't retry — fall out of the loop
350
- // and throw `max_retries_exceeded` below.
351
- if (attempt === maxRetries)
352
- break;
353
- // Resolve the mode: explicit option > env var > TTY-based default.
354
- const mode = this.options.approvalMode ??
355
- getZapierApprovalMode() ??
356
- getZapierDefaultApprovalMode();
357
- if (mode === "disabled") {
358
- throw new ZapierApprovalError("Approvals are disabled. Set approvalMode to 'poll' or 'throw' (or ZAPIER_APPROVAL_MODE) to enable.", { status: "approval_required" });
359
- }
360
- // `approvalContext` is a builder, not a value, because the SDK may
361
- // retry the same request across multiple approval rounds and each POST
362
- // to /approvals needs a freshly-built context (timestamps, etc.).
363
- // Missing context is a programmer error — this code path is only
364
- // reachable for callers that opted into approval-capable requests.
365
- if (!init?.approvalContext) {
366
- throw new ZapierApiError(`Received 403 approval_required for ${path}, but the caller did not provide an approvalContext builder. Every approval-capable request must pass approvalContext so the SDK can create the approval with the correct policy context.`, { statusCode: 403 });
367
- }
368
- // Create the approval, open the URL (poll mode) or throw with the URL
369
- // attached (throw mode), and wait for terminal resolution. Returns only
370
- // on "approved" — every other outcome throws from inside the helper.
371
- // On return, loop back to retry the original request.
372
- await this.runOneApprovalRound(init.approvalContext, mode, init.signal ?? undefined);
373
- }
374
- // Only reachable when the final attempt returned `approval_required`
375
- // (see the `break` above). Every other terminal outcome throws inline.
376
- throw new ZapierApprovalError(`Exceeded maximum approval retries (${maxRetries}) for ${path}`, { status: "max_retries_exceeded" });
377
- };
378
- /**
379
- * Streaming counterpart to `fetch`. Opens a Server-Sent Events connection
380
- * through the same pipeline (auth, base URL, 429 retry, approval flow,
381
- * concurrency) and yields parsed `{ data }` frames. On a non-ok response it
382
- * throws the same `ZapierError` subclasses as the JSON path — callers
383
- * classify errors off `statusCode` instead of hand-rolling the mapping.
384
- *
385
- * The concurrency permit is released when the underlying `fetch` resolves
386
- * (headers received), not when the body finishes, so a long-lived stream
387
- * never pins a slot — see `withSemaphore`.
388
- */
389
- this.fetchStream = (path, init) => this.streamSse(path, init);
390
- /**
391
- * Like `fetchStream`, but parses each frame's `data` as JSON. Diverges from
392
- * `fetchJson` deliberately: that throws on invalid JSON, but a long-lived
393
- * stream must survive a single malformed frame, so a parse failure is yielded
394
- * as `{ parsed: false, data: null, raw }` rather than thrown. A non-ok
395
- * response still throws the shared `ZapierError` (from `fetchStream`, before
396
- * any frame), so transport / auth failures surface as usual.
397
- */
398
- this.fetchJsonStream = (path, init) => jsonFrames(this.fetchStream(path, init));
399
- this.streamTrustedJsonUrl = (url, init) => jsonFrames(this.streamTrustedSseUrl(url, init));
400
- this.get = async (path, options = {}) => {
401
- return this.fetchJson("GET", path, undefined, options);
402
- };
403
- this.post = async (path, data, options = {}) => {
404
- return this.fetchJson("POST", path, data, options);
405
- };
406
- this.put = async (path, data, options = {}) => {
407
- return this.fetchJson("PUT", path, data, options);
408
- };
409
- this.patch = async (path, data, options = {}) => {
410
- return this.fetchJson("PATCH", path, data, options);
411
- };
412
- this.delete = async (path, data, options = {}) => {
413
- return this.fetchJson("DELETE", path, data, options);
414
- };
415
- this.poll = async (path, options = {}) => {
416
- return pollUntilComplete({
417
- fetchPoll: () => this.fetch(path, {
418
- method: "GET",
419
- searchParams: options.searchParams,
420
- authRequired: options.authRequired,
421
- signal: options.signal,
422
- }),
423
- initialDelay: options.initialDelay,
424
- timeoutMs: options.timeoutMs,
425
- successStatus: options.successStatus,
426
- pendingStatus: options.pendingStatus,
427
- isPending: options.isPending,
428
- resultExtractor: options.resultExtractor,
429
- signal: options.signal,
430
- });
431
- };
432
- this.maxNetworkRetries =
433
- options.maxNetworkRetries ?? ZAPIER_MAX_NETWORK_RETRIES;
434
- this.maxNetworkRetryDelayMs =
435
- options.maxNetworkRetryDelayMs ?? ZAPIER_MAX_NETWORK_RETRY_DELAY_MS;
436
- // NaN coerces to the default rather than throwing so a CLI flag with a
437
- // garbage value (parseInt produces NaN) falls back instead of crashing
438
- // SDK construction. Other invalid values (0, negatives, non-integers,
439
- // over-cap) still throw so a misconfigured programmatic caller gets a
440
- // clear error. Peer numeric options like maxNetworkRetries don't coerce
441
- // NaN — they let it flow into comparisons that misbehave silently. The
442
- // asymmetry is deliberate.
443
- const requested = options.maxConcurrentRequests;
444
- const limit = requested === undefined || Number.isNaN(requested)
445
- ? ZAPIER_MAX_CONCURRENT_REQUESTS
446
- : requested;
447
- if (limit !== Infinity &&
448
- (!Number.isInteger(limit) || limit < 1 || limit > MAX_CONCURRENCY_LIMIT)) {
449
- throw new ZapierConfigurationError(`Invalid maxConcurrentRequests: ${limit} (expected positive integer 1-${MAX_CONCURRENCY_LIMIT} or Infinity)`, { configType: "maxConcurrentRequests" });
450
- }
451
- this.semaphore = createSemaphore(limit);
452
- }
453
- // Emit an event if onEvent handler is configured
454
- emitEvent(type, payload) {
455
- if (this.options.onEvent) {
456
- this.options.onEvent({ type, payload, timestamp: Date.now() });
457
- }
458
- }
459
- // Helper to parse response data
460
- async parseResult(response) {
461
- // Read as text first to avoid "Body has already been read" errors
462
- // if json() fails partway through parsing
463
- const text = await response.text();
464
- try {
465
- return { type: "json", data: JSON.parse(text) };
466
- }
467
- catch {
468
- return { type: "text", data: text };
469
- }
470
- }
471
- // Helper to get a token from the different places it could be gotten
472
- async getAuthToken(options) {
473
- return resolveAuthToken({
474
- credentials: this.options.credentials,
475
- token: this.options.token,
476
- onEvent: this.options.onEvent,
477
- fetch: this.options.fetch,
478
- baseUrl: this.options.baseUrl,
479
- requiredScopes: options?.requiredScopes,
480
- debug: this.options.debug,
481
- cache: this.options.cache,
482
- });
483
- }
484
- // Helper to handle responses
485
- async handleResponse(params) {
486
- const { data: responseData } = await this.parseResult(params.response);
487
- if (params.response.ok) {
488
- return responseData;
489
- }
490
- // Returns Promise<never> (every branch throws); returning it satisfies
491
- // this method's type without an unreachable fall-through.
492
- return this.throwForErrorResponse({ ...params, responseData });
493
- }
494
- /**
495
- * Maps a non-ok response to the appropriate ZapierError subclass and throws.
496
- * Takes the already-parsed body so a streaming caller (`fetchStream`) gets
497
- * the exact same status→error classification as the JSON path without
498
- * re-reading — or reading on the success path, which would consume the
499
- * stream — the response body.
500
- */
501
- async throwForErrorResponse(params) {
502
- const { response, responseData, customErrorHandler, resource, wasMissingAuthToken, requiredScopes, } = params;
503
- const errorInfo = {
504
- status: response.status,
505
- statusText: response.statusText,
506
- data: responseData,
507
- };
508
- // Precedence: customErrorHandler runs first; if it returns an Error,
509
- // throw it. If it returns undefined (or wasn't provided), fall through
510
- // to the resource-enriched / bare defaults below.
511
- if (customErrorHandler) {
512
- const customError = customErrorHandler(errorInfo);
513
- if (customError) {
514
- // javascript may not respect customErrorHandler return type, so we need to throw a proper error if it's not an Error
515
- if (customError instanceof Error) {
516
- throw customError;
517
- }
518
- else {
519
- throw new Error(`customErrorHandler returned a non-Error: ${JSON.stringify(customError)}`);
520
- }
521
- }
522
- }
523
- // Parse the error response
524
- const { message, errors } = this.parseErrorResponse(errorInfo);
525
- const errorOptions = {
526
- statusCode: response.status,
527
- errors,
528
- };
529
- // 404: always throw ZapierResourceNotFoundError (subclass of
530
- // ZapierNotFoundError, so existing instanceof checks still pass).
531
- // resourceType/resourceId are populated when the caller passed a
532
- // `resource` hint, otherwise left undefined. The message is the
533
- // server's detail verbatim; formatErrorMessage surfaces the resource
534
- // hint separately (Type: ..., ID: ...) so we don't duplicate it here.
535
- if (response.status === 404) {
536
- throw new ZapierResourceNotFoundError(message, {
537
- ...errorOptions,
538
- resourceType: resource?.type,
539
- resourceId: resource?.id !== undefined ? String(resource.id) : undefined,
540
- });
541
- }
542
- if (response.status === 401 || response.status === 403) {
543
- // If we get a 401/403 error and no auth token was provided, give helpful message
544
- if (wasMissingAuthToken) {
545
- throw new ZapierAuthenticationError(`Authentication required (HTTP ${response.status}). Please provide credentials in options or set ZAPIER_CREDENTIALS environment variable.`, errorOptions);
546
- }
547
- // On 401, invalidate the cached token so the next request fires
548
- // a fresh exchange. Passing baseUrl + cache explicitly so the
549
- // invalidation targets the same cache key the token was stored
550
- // under (both are part of the key identity).
551
- if (response.status === 401) {
552
- await invalidateCredentialsToken({
553
- credentials: this.options.credentials,
554
- token: this.options.token,
555
- baseUrl: this.options.baseUrl,
556
- requiredScopes,
557
- cache: this.options.cache,
558
- });
559
- }
560
- throw new ZapierAuthenticationError(message, errorOptions);
561
- }
562
- if (response.status === 400) {
563
- throw new ZapierValidationError(message, errorOptions);
564
- }
565
- // Generic API error for other status codes
566
- throw new ZapierApiError(message, errorOptions);
567
- }
568
- hasErrorArray(data) {
569
- return (typeof data === "object" &&
570
- data !== null &&
571
- "errors" in data &&
572
- Array.isArray(data.errors));
573
- }
574
- // Helper to check if data has API errors
575
- isApiErrorArray(dataArray) {
576
- const data = dataArray[0];
577
- return (typeof data === "object" &&
578
- data !== null &&
579
- "code" in data &&
580
- "title" in data &&
581
- "detail" in data);
582
- }
583
- // Do our best to extract an error message from the response data
584
- extractErrorMessage(data) {
585
- if (typeof data === "string") {
586
- return data;
587
- }
588
- if (typeof data === "object" && data !== null) {
589
- if ("message" in data && typeof data.message === "string") {
590
- return data.message;
591
- }
592
- if ("error" in data) {
593
- if (typeof data.error === "string") {
594
- return data.error;
595
- }
596
- if (typeof data.error === "object" && data.error !== null) {
597
- if ("message" in data.error &&
598
- typeof data.error.message === "string") {
599
- return data.error.message;
600
- }
601
- }
602
- try {
603
- return JSON.stringify(data.error);
604
- }
605
- catch {
606
- /* defend against circular objects, even though they shouldn't be coming back from the wire */
607
- }
608
- }
609
- if ("errors" in data && Array.isArray(data.errors)) {
610
- if (this.isApiErrorArray(data.errors)) {
611
- return data.errors[0].detail || data.errors[0].title;
612
- }
613
- else if (data.errors.length > 0) {
614
- // Handle simple string errors array
615
- const firstError = data.errors[0];
616
- if (typeof firstError === "string") {
617
- return firstError;
618
- }
619
- // For non-string errors, stringify them
620
- try {
621
- return JSON.stringify(firstError);
622
- }
623
- catch {
624
- return String(firstError);
625
- }
626
- }
627
- }
628
- }
629
- return undefined;
630
- }
631
- // Helper to parse API error response
632
- parseErrorResponse(errorInfo) {
633
- // If we can't parse data, use status text
634
- const fallbackMessage = `HTTP ${errorInfo.status}: ${errorInfo.statusText}`;
635
- try {
636
- // Check if the response has the standard error format
637
- if (typeof errorInfo.data === "string") {
638
- return { message: `${fallbackMessage}: ${errorInfo.data}` };
639
- }
640
- const errorMessage = this.extractErrorMessage(errorInfo.data) || fallbackMessage;
641
- if (this.hasErrorArray(errorInfo.data)) {
642
- if (this.isApiErrorArray(errorInfo.data.errors)) {
643
- return {
644
- message: errorMessage,
645
- errors: errorInfo.data.errors,
646
- };
647
- }
648
- else {
649
- return {
650
- message: errorMessage,
651
- errors: errorInfo.data.errors.map((e) => ({
652
- status: errorInfo.status,
653
- code: String(errorInfo.status),
654
- title: errorInfo.statusText,
655
- detail: JSON.stringify(e),
656
- })),
657
- };
658
- }
659
- }
660
- return { message: errorMessage };
661
- }
662
- catch {
663
- return { message: fallbackMessage };
664
- }
665
- }
666
- // Apply any special routing logic for configured paths.
667
- applyPathConfiguration(path) {
668
- // Find matching path configuration.
669
- const matchingPathKey = Object.keys(pathConfig).find((configPath) => path === configPath || path.startsWith(configPath + "/"));
670
- const config = matchingPathKey ? pathConfig[matchingPathKey] : undefined;
671
- // Apply pathPrefix if there's a matching config with pathPrefix.
672
- let finalPath = path;
673
- if (config &&
674
- "pathPrefix" in config &&
675
- config.pathPrefix &&
676
- matchingPathKey) {
677
- // Strip the matching path key, and use the pathPrefix instead.
678
- const pathWithoutPrefix = path.slice(matchingPathKey.length) || "/";
679
- finalPath = `${config.pathPrefix}${pathWithoutPrefix}`;
680
- }
681
- // Check if baseUrl is a Zapier-inferred base URL.
682
- const zapierBaseUrl = getZapierBaseUrl(this.options.baseUrl);
683
- // Let's remain compatible with a base URL that is set to a Zapier-inferred
684
- // domain, rather than requiring the base URL to go to our proxy. Later, the
685
- // proxy will be removed, so this should make that transition easier.
686
- if (zapierBaseUrl === this.options.baseUrl.replace(/\/$/, "")) {
687
- // If baseUrl is already the Zapier base URL, use sdkapi subdomain.
688
- const originalBaseUrl = new URL(this.options.baseUrl);
689
- const finalBaseUrl = `https://sdkapi.${originalBaseUrl.hostname}`;
690
- return {
691
- url: new URL(finalPath, finalBaseUrl),
692
- pathConfig: config,
693
- };
694
- }
695
- // For a base URL that isn't a Zapier-inferred domain (e.g., localhost),
696
- // preserve any path from the base URL and append the final path.
697
- const baseUrl = new URL(this.options.baseUrl);
698
- const basePath = baseUrl.pathname.replace(/\/$/, "");
699
- return {
700
- url: new URL(basePath + finalPath, baseUrl.origin),
701
- pathConfig: config,
702
- };
703
- }
704
- // Helper to build full URLs and return routing info
705
- buildUrl(path, searchParams) {
706
- const { url, pathConfig: config } = this.applyPathConfiguration(path);
707
- if (searchParams) {
708
- Object.entries(searchParams).forEach(([key, value]) => {
709
- url.searchParams.set(key, value);
710
- });
711
- }
712
- return { url: url.toString(), pathConfig: config };
713
- }
714
- // Helper to build headers
715
- async buildHeaders(options = {}, pathConfig) {
716
- const headers = new Headers(options.headers ?? {});
717
- // Even if auth is not required, we still want to add it in case it adds
718
- // useful context to the API. The session is a good example of this. Auth
719
- // is not required, but if we don't add auth, then we won't get the user's
720
- // session!
721
- const authToken = await this.getAuthToken({
722
- requiredScopes: options.requiredScopes,
723
- });
724
- if (authToken) {
725
- const authHeaderName = pathConfig && pathConfig.authHeader
726
- ? pathConfig.authHeader
727
- : "Authorization";
728
- headers.set(authHeaderName, getAuthorizationHeader(authToken));
729
- }
730
- // If we know auth is required, and we don't have a token, throw an error
731
- // before we even make a request.
732
- if (options.authRequired) {
733
- const authHeaderName = pathConfig?.authHeader ?? "Authorization";
734
- if (headers.get(authHeaderName) == null && authToken == null) {
735
- const message = isCliLoginAvailable() === false
736
- ? "Authentication required but no credentials available. " +
737
- "To use CLI login, install the CLI as a dev dependency " +
738
- "(e.g. `npm install -D @zapier/zapier-sdk-cli`) and " +
739
- "log in (e.g. `npx zapier-sdk login`). " +
740
- "Alternatively, set the ZAPIER_CREDENTIALS environment variable " +
741
- "or ZAPIER_CREDENTIALS_CLIENT_ID and " +
742
- "ZAPIER_CREDENTIALS_CLIENT_SECRET environment variables."
743
- : "Authentication required but no credentials available. " +
744
- "Please log in (e.g. `npx zapier-sdk login`) or set the " +
745
- "ZAPIER_CREDENTIALS environment variable or " +
746
- "ZAPIER_CREDENTIALS_CLIENT_ID and " +
747
- "ZAPIER_CREDENTIALS_CLIENT_SECRET environment variables.";
748
- throw new ZapierAuthenticationError(message);
749
- }
750
- }
751
- return headers;
752
- }
753
- // Telemetry headers consumed by sdkapi's ApiRequestCompletedEvent.
754
- // Applied at the outbound layer (after caller-supplied header merging) so
755
- // they always reflect the SDK's actual identity and can't be spoofed via
756
- // options.headers.
757
- //
758
- // We emit both the standard `zapier-*` names (per the API header guidance the
759
- // gateway now expects) and the legacy `x-zapier-*` names. The legacy names are
760
- // kept for backward compatibility with consumers that haven't migrated yet;
761
- // they can be removed once nothing reads them.
762
- applyTelemetryHeaders(headers) {
763
- headers.set("zapier-sdk-version", SDK_VERSION);
764
- headers.set("x-zapier-sdk-version", SDK_VERSION);
765
- const sdkService = getZapierSdkService();
766
- if (sdkService) {
767
- headers.set("zapier-service", sdkService);
768
- headers.set("x-zapier-service", sdkService);
769
- }
770
- const agent = getAgent();
771
- if (agent) {
772
- headers.set("zapier-sdk-agent", agent);
773
- }
774
- const callerPackage = this.options.callerPackage;
775
- if (callerPackage) {
776
- headers.set("zapier-sdk-package", callerPackage.name);
777
- headers.set("x-zapier-sdk-package", callerPackage.name);
778
- headers.set("zapier-sdk-package-version", callerPackage.version);
779
- headers.set("x-zapier-sdk-package-version", callerPackage.version);
780
- const { packageOperation } = getCallerContext();
781
- if (packageOperation) {
782
- headers.set("zapier-sdk-package-operation", packageOperation);
783
- }
784
- }
785
- }
786
- // Helper to perform HTTP requests with JSON handling
787
- async fetchJson(method, path, data, options = {}) {
788
- const headers = { ...options.headers };
789
- // Add Content-Type for JSON requests with body data
790
- if (data && typeof data === "object") {
791
- headers["Content-Type"] = "application/json";
792
- }
793
- // Check if we have an auth token available
794
- const wasMissingAuthToken = options.authRequired &&
795
- (await this.getAuthToken({
796
- requiredScopes: options.requiredScopes,
797
- })) == null;
798
- const response = await this.fetch(path, {
799
- ...options,
800
- method,
801
- body: data != null ? JSON.stringify(data) : undefined,
802
- headers,
803
- });
804
- const result = await this.handleResponse({
805
- response,
806
- customErrorHandler: options.customErrorHandler,
807
- resource: options.resource,
808
- wasMissingAuthToken,
809
- requiredScopes: options.requiredScopes,
810
- });
811
- // Allow empty responses for DELETE or 204 No Content
812
- if (typeof result === "string") {
813
- if (result === "" && (method === "DELETE" || response.status === 204)) {
814
- return undefined;
815
- }
816
- throw new ZapierValidationError(`Response could not be parsed as JSON: ${result}`);
817
- }
818
- return result;
819
- }
820
- // The generator body for `fetchStream`. Kept as a prototype method (not an
821
- // arrow class field, which can't be a generator) and exposed through the
822
- // bound `fetchStream` arrow above for parity with the other client methods.
823
- async *streamSse(path, init) {
824
- const { onOpen, headers: initHeaders, ...fetchInit } = init ?? {};
825
- const signal = fetchInit.signal ?? undefined;
826
- if (signal?.aborted)
827
- return;
828
- // Mirror fetchJson: when auth was required but no token resolved, a 401/403
829
- // should surface the "Authentication required" message rather than a bare
830
- // auth error.
831
- const wasMissingAuthToken = fetchInit.authRequired === true &&
832
- (await this.getAuthToken({
833
- requiredScopes: fetchInit.requiredScopes,
834
- })) == null;
835
- const headers = new Headers(initHeaders);
836
- if (!headers.has("Accept"))
837
- headers.set("Accept", "text/event-stream");
838
- let response;
839
- try {
840
- response = await this.fetch(path, {
841
- ...fetchInit,
842
- method: fetchInit.method ?? "GET",
843
- headers,
844
- });
845
- }
846
- catch (err) {
847
- // Aborts unwind quietly; everything else (including a ZapierApprovalError
848
- // from a policy-denied stream) propagates so the caller can classify it.
849
- if (signal?.aborted || isAbortError(err))
850
- return;
851
- throw err;
852
- }
853
- yield* this.readSseResponse({
854
- response,
855
- signal,
856
- onOpen,
857
- wasMissingAuthToken,
858
- requiredScopes: fetchInit.requiredScopes,
859
- });
860
- }
861
- // Approval `stream_url` is server-supplied and origin-pinned before use, like
862
- // `poll_url`; keep absolute-URL streaming private rather than widening the
863
- // public path-based `fetchStream` API.
864
- async *streamTrustedSseUrl(url, init) {
865
- const { onOpen, headers: initHeaders, ...fetchInit } = init ?? {};
866
- const signal = fetchInit.signal ?? undefined;
867
- if (signal?.aborted)
868
- return;
869
- const wasMissingAuthToken = fetchInit.authRequired === true &&
870
- (await this.getAuthToken({
871
- requiredScopes: fetchInit.requiredScopes,
872
- })) == null;
873
- const headers = new Headers(initHeaders);
874
- if (!headers.has("Accept"))
875
- headers.set("Accept", "text/event-stream");
876
- let response;
877
- try {
878
- response = await this.withSemaphore({ url, method: fetchInit.method ?? "GET", signal }, () => this.rawFetchUrl(url, {
879
- ...fetchInit,
880
- method: fetchInit.method ?? "GET",
881
- headers,
882
- }));
883
- }
884
- catch (err) {
885
- if (signal?.aborted || isAbortError(err))
886
- return;
887
- throw err;
888
- }
889
- yield* this.readSseResponse({
890
- response,
891
- signal,
892
- onOpen,
893
- wasMissingAuthToken,
894
- requiredScopes: fetchInit.requiredScopes,
895
- });
896
- }
897
- async *readSseResponse({ response, signal, onOpen, wasMissingAuthToken, requiredScopes, }) {
898
- if (!response.ok) {
899
- // Parse the error body only on this non-ok branch — reading it on the ok
900
- // path would consume the stream. Map it exactly like the JSON path does.
901
- const { data } = await this.parseResult(response);
902
- await this.throwForErrorResponse({
903
- response,
904
- responseData: data,
905
- wasMissingAuthToken,
906
- requiredScopes,
907
- });
908
- }
909
- if (!response.body)
910
- return;
911
- const reader = response.body
912
- .pipeThrough(new TextDecoderStream())
913
- .pipeThrough(createSseParserStream())
914
- .getReader();
915
- // Cancelling the reader resolves any pending read() with {done: true},
916
- // which unblocks the loop below on abort.
917
- const onAbort = () => {
918
- reader.cancel().catch(() => { });
919
- };
920
- try {
921
- // Connection is live; fire onOpen before the first read so the caller can
922
- // run any catch-up work. Inside the try so a throwing onOpen is still
923
- // followed by the finally's cancel() — the socket never leaks. Reached
924
- // only after the ok + body checks, so it never fires on a non-ok response
925
- // or an empty body.
926
- onOpen?.();
927
- signal?.addEventListener("abort", onAbort, { once: true });
928
- while (!signal?.aborted) {
929
- const { done, value } = await reader.read();
930
- if (done || signal?.aborted)
931
- return;
932
- yield value;
933
- }
934
- }
935
- finally {
936
- signal?.removeEventListener("abort", onAbort);
937
- // cancel() (not just releaseLock) so the underlying HTTP connection
938
- // closes on every unwind path — abort, clean end, throw, throwing onOpen,
939
- // or the consumer calling .return(). A leaked socket would outlive the
940
- // stream.
941
- await reader.cancel().catch(() => { });
942
- }
943
- }
944
- /**
945
- * Run a single approval round: create the approval, open the URL (poll mode)
946
- * or throw (throw mode), poll until resolved, and emit events. Throws on
947
- * denied/failed/timeout/unexpected status. Returns on approved.
948
- *
949
- * Caller is responsible for passing a non-"disabled" mode; this method
950
- * unconditionally creates an approval.
951
- */
952
- async runOneApprovalRound(buildContext, mode, signal) {
953
- const context = buildContext();
954
- // Route through rawFetch so the approval POST shares auth + 429 retry.
955
- let approvalResponse;
956
- try {
957
- approvalResponse = await this.rawFetch("/api/v0/approvals", {
958
- method: "POST",
959
- headers: {
960
- "Content-Type": "application/json",
961
- Accept: "application/json",
962
- },
963
- body: JSON.stringify({ context }),
964
- signal,
965
- });
966
- }
967
- catch (err) {
968
- if (isAbortError(err))
969
- throw err;
970
- throw new ZapierApiError("Failed to create approval request", {
971
- statusCode: 0,
972
- cause: err,
973
- });
974
- }
975
- if (!approvalResponse.ok) {
976
- const body = await approvalResponse.text().catch(() => undefined);
977
- throw new ZapierApiError(`Failed to create approval request: ${approvalResponse.status}`, { statusCode: approvalResponse.status, response: body });
978
- }
979
- let body;
980
- try {
981
- body = await approvalResponse.text();
982
- }
983
- catch (err) {
984
- throw new ZapierApiError("Failed to read approval response body", {
985
- statusCode: approvalResponse.status,
986
- cause: err,
987
- });
988
- }
989
- let approval;
990
- try {
991
- approval = CreateApprovalResponseSchema.parse(JSON.parse(body));
992
- }
993
- catch (err) {
994
- throw new ZapierApiError(`Failed to parse approval response: ${body}`, {
995
- statusCode: approvalResponse.status,
996
- cause: err,
997
- response: body,
998
- });
999
- }
1000
- // Origin-pin server-supplied URLs before we attach the bearer token
1001
- // (poll_url) or open them in the user's browser (approval_url). Without
1002
- // this, a compromised or buggy sdkapi response could redirect the SDK to
1003
- // an attacker-controlled host and leak the auth token.
1004
- const sdkapiOrigin = new URL(this.buildUrl("/api/v0/approvals").url).origin;
1005
- const browserOrigin = getZapierBaseUrl(this.options.baseUrl) ?? sdkapiOrigin;
1006
- const assertApprovalOrigin = (url, expectedOrigin, label) => {
1007
- let parsed;
1008
- try {
1009
- parsed = new URL(url);
1010
- }
1011
- catch {
1012
- throw new ZapierApiError(`Invalid approval ${label}: ${url}`, {
1013
- statusCode: approvalResponse.status,
1014
- response: body,
1015
- });
1016
- }
1017
- if (parsed.origin !== expectedOrigin) {
1018
- throw new ZapierApiError(`Approval ${label} origin ${parsed.origin} does not match expected ${expectedOrigin}`, { statusCode: approvalResponse.status, response: body });
1019
- }
1020
- };
1021
- // In local dev the SDK API, approvalsapi, and approval frontend run on
1022
- // different localhost ports, so neither origin can match. The check
1023
- // exists to stop a compromised sdkapi from redirecting bearer-token
1024
- // traffic to an attacker host — that threat model doesn't apply when
1025
- // the dev owns every service on the machine.
1026
- if (!isLocalhostBaseUrl(this.options.baseUrl)) {
1027
- assertApprovalOrigin(approval.poll_url, sdkapiOrigin, "poll_url");
1028
- if (approval.stream_url) {
1029
- assertApprovalOrigin(approval.stream_url, sdkapiOrigin, "stream_url");
1030
- }
1031
- assertApprovalOrigin(approval.approval_url, browserOrigin, "approval_url");
1032
- }
1033
- this.emitEvent("approval:required", {
1034
- approvalId: approval.id,
1035
- approvalUrl: approval.approval_url,
1036
- mode: approval.mode,
1037
- ...(approval.stream_url ? { streamUrl: approval.stream_url } : {}),
1038
- });
1039
- const shouldOpenAutoModeApproval = this.options.openAutoModeApprovalsInBrowser ??
1040
- getZapierOpenAutoModeApprovalsInBrowser() ??
1041
- false;
1042
- if (approval.mode === "auto") {
1043
- if (shouldOpenAutoModeApproval) {
1044
- await openApproval(approval.approval_url);
1045
- }
1046
- if (approval.status === "approved") {
1047
- this.emitEvent("approval:approved", {
1048
- approvalId: approval.id,
1049
- });
1050
- return;
1051
- }
1052
- if (approval.status === "denied") {
1053
- this.emitEvent("approval:denied", {
1054
- approvalId: approval.id,
1055
- ...(approval.reason ? { reason: approval.reason } : {}),
1056
- });
1057
- throw new ZapierApprovalError(approval.reason
1058
- ? `Request denied: ${approval.reason}`
1059
- : "Request denied by user", {
1060
- approvalId: approval.id,
1061
- status: "denied",
1062
- reason: approval.reason,
1063
- });
1064
- }
1065
- if (approval.status === "failed") {
1066
- this.throwApprovalFailed({
1067
- approvalId: approval.id,
1068
- approvalUrl: approval.approval_url,
1069
- pollUrl: approval.poll_url,
1070
- streamUrl: approval.stream_url,
1071
- reason: approval.reason,
1072
- });
1073
- }
1074
- }
1075
- else {
1076
- if (mode === "throw") {
1077
- throw new ZapierApprovalError("This request requires approval.", {
1078
- approvalId: approval.id,
1079
- approvalUrl: approval.approval_url,
1080
- pollUrl: approval.poll_url,
1081
- streamUrl: approval.stream_url,
1082
- status: "pending",
1083
- });
1084
- }
1085
- // mode === "poll", manual approval — open browser and poll
1086
- await openApproval(approval.approval_url);
1087
- }
1088
- const timeoutMs = this.options.approvalTimeoutMs ?? DEFAULT_APPROVAL_TIMEOUT_MS;
1089
- let streamAbortController;
1090
- let streamPromise;
1091
- let removeStreamAbortListener;
1092
- if (approval.mode === "auto" && approval.stream_url) {
1093
- const streamUrl = approval.stream_url;
1094
- streamAbortController = new AbortController();
1095
- const abortStream = () => streamAbortController?.abort();
1096
- if (signal?.aborted) {
1097
- abortStream();
1098
- }
1099
- else if (signal) {
1100
- signal.addEventListener("abort", abortStream, { once: true });
1101
- removeStreamAbortListener = () => signal.removeEventListener("abort", abortStream);
1102
- }
1103
- streamPromise = consumeApprovalReviewStream({
1104
- approvalId: approval.id,
1105
- streamUrl,
1106
- signal: streamAbortController.signal,
1107
- stream: (url, streamInit) => this.streamTrustedJsonUrl(url, streamInit),
1108
- emitEvent: (type, payload) => this.emitEvent(type, payload),
1109
- });
1110
- }
1111
- let rawPollResult;
1112
- try {
1113
- rawPollResult = await pollUntilComplete({
1114
- // poll_url is an absolute URL supplied by the server, so we use
1115
- // rawFetchUrl directly (skipping path resolution) but still share
1116
- // auth + interactive-header + 429-retry with the rest of the SDK.
1117
- // Each individual poll request goes through the concurrency
1118
- // semaphore — but we deliberately do not hold a slot across the
1119
- // sleep between polls or across the human-approval wait.
1120
- fetchPoll: () => this.withSemaphore({ url: approval.poll_url, method: "GET", signal }, () => this.rawFetchUrl(approval.poll_url, {
1121
- method: "GET",
1122
- headers: { Accept: "application/json" },
1123
- signal,
1124
- })),
1125
- timeoutMs,
1126
- maxPollingIntervalMs: APPROVAL_MAX_POLLING_INTERVAL_MS,
1127
- signal,
1128
- isPending: (body) => {
1129
- const parsed = PollApprovalResponseSchema.safeParse(body);
1130
- return parsed.success && parsed.data.status === "pending_approval";
1131
- },
1132
- });
1133
- }
1134
- catch (err) {
1135
- if (!(err instanceof ZapierTimeoutError)) {
1136
- this.emitEvent("approval:error", {
1137
- approvalId: approval.id,
1138
- message: err instanceof Error ? err.message : String(err),
1139
- });
1140
- throw err;
1141
- }
1142
- this.emitEvent("approval:timeout", {
1143
- approvalId: approval.id,
1144
- });
1145
- throw new ZapierApprovalError(`Approval timed out after ${timeoutMs / 1000} seconds`, {
1146
- approvalId: approval.id,
1147
- approvalUrl: approval.approval_url,
1148
- pollUrl: approval.poll_url,
1149
- streamUrl: approval.stream_url,
1150
- status: "timeout",
1151
- cause: err,
1152
- });
1153
- }
1154
- finally {
1155
- removeStreamAbortListener?.();
1156
- streamAbortController?.abort();
1157
- await streamPromise;
1158
- }
1159
- const pollParse = PollApprovalResponseSchema.safeParse(rawPollResult);
1160
- if (!pollParse.success) {
1161
- const bodyPreview = typeof rawPollResult === "string"
1162
- ? rawPollResult
1163
- : JSON.stringify(rawPollResult);
1164
- this.emitEvent("approval:error", {
1165
- approvalId: approval.id,
1166
- message: `Failed to parse approval poll response: ${bodyPreview}`,
1167
- });
1168
- throw new ZapierApiError(`Failed to parse approval poll response: ${bodyPreview}`, {
1169
- statusCode: 0,
1170
- cause: pollParse.error,
1171
- response: rawPollResult,
1172
- });
1173
- }
1174
- const pollResult = pollParse.data;
1175
- if (pollResult.status === "denied") {
1176
- this.emitEvent("approval:denied", {
1177
- approvalId: approval.id,
1178
- ...(pollResult.reason ? { reason: pollResult.reason } : {}),
1179
- });
1180
- throw new ZapierApprovalError(pollResult.reason
1181
- ? `Request denied: ${pollResult.reason}`
1182
- : "Request denied by user", {
1183
- approvalId: approval.id,
1184
- status: "denied",
1185
- reason: pollResult.reason,
1186
- });
1187
- }
1188
- if (pollResult.status === "failed") {
1189
- this.throwApprovalFailed({
1190
- approvalId: approval.id,
1191
- approvalUrl: approval.approval_url,
1192
- pollUrl: approval.poll_url,
1193
- streamUrl: approval.stream_url,
1194
- reason: pollResult.reason,
1195
- });
1196
- }
1197
- if (pollResult.status !== "approved") {
1198
- this.emitEvent("approval:error", {
1199
- approvalId: approval.id,
1200
- message: `Unexpected approval status received: ${pollResult.status}`,
1201
- });
1202
- throw new ZapierApiError(`Unexpected approval status received: ${pollResult.status}`);
1203
- }
1204
- this.emitEvent("approval:approved", {
1205
- approvalId: approval.id,
1206
- });
1207
- }
1208
- throwApprovalFailed({ approvalId, approvalUrl, pollUrl, streamUrl, reason, }) {
1209
- this.emitEvent("approval:failed", {
1210
- approvalId,
1211
- ...(reason ? { reason } : {}),
1212
- });
1213
- throw new ZapierApprovalError(reason ? `Approval failed: ${reason}` : "Approval failed", {
1214
- approvalId,
1215
- approvalUrl,
1216
- pollUrl,
1217
- streamUrl,
1218
- status: "failed",
1219
- reason,
1220
- });
1221
- }
1222
- }
1223
- export const createZapierApi = (options) => {
1224
- const { debug = false, fetch: originalFetch = globalThis.fetch } = options;
1225
- const debugLog = createDebugLogger(debug);
1226
- const debugFetch = createDebugFetch({ originalFetch, debugLog });
1227
- return new ZapierApiClient({
1228
- ...options,
1229
- debug,
1230
- fetch: debugFetch,
1231
- });
1232
- };