@zapier/zapier-sdk 0.64.0 → 0.67.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (500) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/README.md +165 -6
  3. package/dist/api/client.d.ts.map +1 -1
  4. package/dist/api/client.js +2 -0
  5. package/dist/api/debug.d.ts.map +1 -1
  6. package/dist/api/debug.js +6 -4
  7. package/dist/api/polling.d.ts +2 -0
  8. package/dist/api/polling.d.ts.map +1 -1
  9. package/dist/api/polling.js +10 -2
  10. package/dist/auth.d.ts.map +1 -1
  11. package/dist/auth.js +8 -5
  12. package/dist/core-stack.d.ts +24 -0
  13. package/dist/core-stack.d.ts.map +1 -0
  14. package/dist/core-stack.js +32 -0
  15. package/dist/experimental.cjs +1803 -1332
  16. package/dist/experimental.d.mts +3508 -182
  17. package/dist/experimental.d.ts +3578 -252
  18. package/dist/experimental.d.ts.map +1 -1
  19. package/dist/experimental.js +120 -84
  20. package/dist/experimental.mjs +1789 -1331
  21. package/dist/formatters/action.d.ts +4 -0
  22. package/dist/formatters/action.d.ts.map +1 -0
  23. package/dist/formatters/action.js +18 -0
  24. package/dist/formatters/actionResult.d.ts +3 -0
  25. package/dist/formatters/actionResult.d.ts.map +1 -0
  26. package/dist/formatters/actionResult.js +25 -0
  27. package/dist/formatters/app.d.ts +4 -0
  28. package/dist/formatters/app.d.ts.map +1 -0
  29. package/dist/formatters/app.js +10 -0
  30. package/dist/formatters/clientCredentials.d.ts +5 -0
  31. package/dist/formatters/clientCredentials.d.ts.map +1 -0
  32. package/dist/formatters/clientCredentials.js +27 -0
  33. package/dist/formatters/connection.d.ts +4 -0
  34. package/dist/formatters/connection.d.ts.map +1 -0
  35. package/dist/formatters/connection.js +26 -0
  36. package/dist/formatters/field.d.ts +4 -0
  37. package/dist/formatters/field.d.ts.map +1 -0
  38. package/dist/formatters/field.js +51 -0
  39. package/dist/formatters/inputFieldChoice.d.ts +4 -0
  40. package/dist/formatters/inputFieldChoice.d.ts.map +1 -0
  41. package/dist/formatters/inputFieldChoice.js +16 -0
  42. package/dist/formatters/tableField.d.ts +4 -0
  43. package/dist/formatters/tableField.d.ts.map +1 -0
  44. package/dist/formatters/tableField.js +7 -0
  45. package/dist/formatters/tableRecord.d.ts +5 -3
  46. package/dist/formatters/tableRecord.d.ts.map +1 -1
  47. package/dist/formatters/tableRecord.js +4 -3
  48. package/dist/formatters/triggerInbox.d.ts +4 -0
  49. package/dist/formatters/triggerInbox.d.ts.map +1 -0
  50. package/dist/formatters/triggerInbox.js +31 -0
  51. package/dist/formatters/triggerMessage.d.ts +5 -0
  52. package/dist/formatters/triggerMessage.d.ts.map +1 -0
  53. package/dist/formatters/triggerMessage.js +34 -0
  54. package/dist/formatters/userProfile.d.ts +4 -0
  55. package/dist/formatters/userProfile.d.ts.map +1 -0
  56. package/dist/formatters/userProfile.js +19 -0
  57. package/dist/{index-Bfvj0KLi.d.mts → index-Dh0b5NAY.d.mts} +13058 -7731
  58. package/dist/{index-Bfvj0KLi.d.ts → index-Dh0b5NAY.d.ts} +13058 -7731
  59. package/dist/index.cjs +1745 -1464
  60. package/dist/index.d.mts +2 -2
  61. package/dist/index.d.ts +12 -9
  62. package/dist/index.d.ts.map +1 -1
  63. package/dist/index.js +21 -7
  64. package/dist/index.mjs +1731 -1463
  65. package/dist/plugins/api/index.d.ts +1 -1
  66. package/dist/plugins/api/index.js +1 -1
  67. package/dist/plugins/apps/index.d.ts +8 -5
  68. package/dist/plugins/apps/index.d.ts.map +1 -1
  69. package/dist/plugins/apps/index.js +1 -1
  70. package/dist/plugins/capabilities/index.d.ts +1 -1
  71. package/dist/plugins/capabilities/index.js +1 -1
  72. package/dist/plugins/codeSubstrate/cancelDurableRun/index.d.ts +32 -2
  73. package/dist/plugins/codeSubstrate/cancelDurableRun/index.d.ts.map +1 -1
  74. package/dist/plugins/codeSubstrate/cancelDurableRun/index.js +1 -1
  75. package/dist/plugins/codeSubstrate/createWorkflow/index.d.ts +2 -2
  76. package/dist/plugins/codeSubstrate/createWorkflow/index.js +1 -1
  77. package/dist/plugins/codeSubstrate/deleteWorkflow/index.d.ts +27 -2
  78. package/dist/plugins/codeSubstrate/deleteWorkflow/index.d.ts.map +1 -1
  79. package/dist/plugins/codeSubstrate/deleteWorkflow/index.js +1 -1
  80. package/dist/plugins/codeSubstrate/disableWorkflow/index.d.ts +27 -2
  81. package/dist/plugins/codeSubstrate/disableWorkflow/index.d.ts.map +1 -1
  82. package/dist/plugins/codeSubstrate/disableWorkflow/index.js +1 -1
  83. package/dist/plugins/codeSubstrate/enableWorkflow/index.d.ts +27 -2
  84. package/dist/plugins/codeSubstrate/enableWorkflow/index.d.ts.map +1 -1
  85. package/dist/plugins/codeSubstrate/enableWorkflow/index.js +1 -1
  86. package/dist/plugins/codeSubstrate/getDurableRun/index.d.ts +32 -2
  87. package/dist/plugins/codeSubstrate/getDurableRun/index.d.ts.map +1 -1
  88. package/dist/plugins/codeSubstrate/getDurableRun/index.js +1 -1
  89. package/dist/plugins/codeSubstrate/getTriggerRun/index.d.ts +47 -0
  90. package/dist/plugins/codeSubstrate/getTriggerRun/index.d.ts.map +1 -0
  91. package/dist/plugins/codeSubstrate/getTriggerRun/index.js +23 -0
  92. package/dist/plugins/codeSubstrate/getTriggerRun/schemas.d.ts +24 -0
  93. package/dist/plugins/codeSubstrate/getTriggerRun/schemas.d.ts.map +1 -0
  94. package/dist/plugins/codeSubstrate/getTriggerRun/schemas.js +30 -0
  95. package/dist/plugins/codeSubstrate/getWorkflow/index.d.ts +27 -2
  96. package/dist/plugins/codeSubstrate/getWorkflow/index.d.ts.map +1 -1
  97. package/dist/plugins/codeSubstrate/getWorkflow/index.js +1 -1
  98. package/dist/plugins/codeSubstrate/getWorkflowRun/index.d.ts +102 -0
  99. package/dist/plugins/codeSubstrate/getWorkflowRun/index.d.ts.map +1 -0
  100. package/dist/plugins/codeSubstrate/getWorkflowRun/index.js +25 -0
  101. package/dist/plugins/codeSubstrate/getWorkflowRun/schemas.d.ts +26 -0
  102. package/dist/plugins/codeSubstrate/getWorkflowRun/schemas.d.ts.map +1 -0
  103. package/dist/plugins/codeSubstrate/getWorkflowRun/schemas.js +43 -0
  104. package/dist/plugins/codeSubstrate/getWorkflowVersion/index.d.ts +51 -2
  105. package/dist/plugins/codeSubstrate/getWorkflowVersion/index.d.ts.map +1 -1
  106. package/dist/plugins/codeSubstrate/getWorkflowVersion/index.js +1 -1
  107. package/dist/plugins/codeSubstrate/listDurableRuns/index.d.ts +3 -3
  108. package/dist/plugins/codeSubstrate/listDurableRuns/index.d.ts.map +1 -1
  109. package/dist/plugins/codeSubstrate/listDurableRuns/index.js +1 -1
  110. package/dist/plugins/codeSubstrate/listWorkflowRuns/index.d.ts +78 -0
  111. package/dist/plugins/codeSubstrate/listWorkflowRuns/index.d.ts.map +1 -0
  112. package/dist/plugins/codeSubstrate/listWorkflowRuns/index.js +34 -0
  113. package/dist/plugins/codeSubstrate/listWorkflowRuns/schemas.d.ts +65 -0
  114. package/dist/plugins/codeSubstrate/listWorkflowRuns/schemas.d.ts.map +1 -0
  115. package/dist/plugins/codeSubstrate/listWorkflowRuns/schemas.js +69 -0
  116. package/dist/plugins/codeSubstrate/listWorkflowVersions/index.d.ts +28 -3
  117. package/dist/plugins/codeSubstrate/listWorkflowVersions/index.d.ts.map +1 -1
  118. package/dist/plugins/codeSubstrate/listWorkflowVersions/index.js +1 -1
  119. package/dist/plugins/codeSubstrate/listWorkflows/index.d.ts +3 -3
  120. package/dist/plugins/codeSubstrate/listWorkflows/index.d.ts.map +1 -1
  121. package/dist/plugins/codeSubstrate/listWorkflows/index.js +2 -3
  122. package/dist/plugins/codeSubstrate/publishWorkflowVersion/index.d.ts +27 -2
  123. package/dist/plugins/codeSubstrate/publishWorkflowVersion/index.d.ts.map +1 -1
  124. package/dist/plugins/codeSubstrate/publishWorkflowVersion/index.js +1 -1
  125. package/dist/plugins/codeSubstrate/runDurable/index.d.ts +2 -2
  126. package/dist/plugins/codeSubstrate/runDurable/index.js +1 -1
  127. package/dist/plugins/codeSubstrate/triggerWorkflow/index.d.ts +73 -0
  128. package/dist/plugins/codeSubstrate/triggerWorkflow/index.d.ts.map +1 -0
  129. package/dist/plugins/codeSubstrate/triggerWorkflow/index.js +52 -0
  130. package/dist/plugins/codeSubstrate/triggerWorkflow/schemas.d.ts +16 -0
  131. package/dist/plugins/codeSubstrate/triggerWorkflow/schemas.d.ts.map +1 -0
  132. package/dist/plugins/codeSubstrate/triggerWorkflow/schemas.js +31 -0
  133. package/dist/plugins/codeSubstrate/updateWorkflow/index.d.ts +27 -2
  134. package/dist/plugins/codeSubstrate/updateWorkflow/index.d.ts.map +1 -1
  135. package/dist/plugins/codeSubstrate/updateWorkflow/index.js +1 -1
  136. package/dist/plugins/connections/index.d.ts +1 -1
  137. package/dist/plugins/connections/index.js +1 -1
  138. package/dist/plugins/createClientCredentials/index.d.ts +2 -2
  139. package/dist/plugins/createClientCredentials/index.d.ts.map +1 -1
  140. package/dist/plugins/createClientCredentials/index.js +4 -2
  141. package/dist/plugins/createClientCredentials/schemas.d.ts +1 -2
  142. package/dist/plugins/createClientCredentials/schemas.d.ts.map +1 -1
  143. package/dist/plugins/deleteClientCredentials/index.d.ts +24 -2
  144. package/dist/plugins/deleteClientCredentials/index.d.ts.map +1 -1
  145. package/dist/plugins/deleteClientCredentials/index.js +2 -2
  146. package/dist/plugins/deleteClientCredentials/schemas.d.ts +1 -2
  147. package/dist/plugins/deleteClientCredentials/schemas.d.ts.map +1 -1
  148. package/dist/plugins/deprecated/authentications.d.ts +144 -16
  149. package/dist/plugins/deprecated/authentications.d.ts.map +1 -1
  150. package/dist/plugins/deprecated/authentications.js +14 -5
  151. package/dist/plugins/deprecated/inputFields.d.ts +58 -23
  152. package/dist/plugins/deprecated/inputFields.d.ts.map +1 -1
  153. package/dist/plugins/deprecated/inputFields.js +15 -7
  154. package/dist/plugins/eventEmission/event-emission-hook.d.ts +10 -0
  155. package/dist/plugins/eventEmission/event-emission-hook.d.ts.map +1 -0
  156. package/dist/plugins/eventEmission/event-emission-hook.js +47 -0
  157. package/dist/plugins/eventEmission/index.d.ts +5 -3
  158. package/dist/plugins/eventEmission/index.d.ts.map +1 -1
  159. package/dist/plugins/eventEmission/index.js +16 -9
  160. package/dist/plugins/eventEmission/method-metadata.d.ts +16 -0
  161. package/dist/plugins/eventEmission/method-metadata.d.ts.map +1 -0
  162. package/dist/plugins/eventEmission/method-metadata.js +20 -0
  163. package/dist/plugins/eventEmission/transport.d.ts.map +1 -1
  164. package/dist/plugins/eventEmission/transport.js +2 -1
  165. package/dist/plugins/fetch/index.d.ts +11 -5
  166. package/dist/plugins/fetch/index.d.ts.map +1 -1
  167. package/dist/plugins/fetch/index.js +42 -32
  168. package/dist/plugins/fetch/schemas.d.ts +1 -1
  169. package/dist/plugins/findFirstConnection/index.d.ts +4 -4
  170. package/dist/plugins/findFirstConnection/index.d.ts.map +1 -1
  171. package/dist/plugins/findFirstConnection/index.js +4 -2
  172. package/dist/plugins/findFirstConnection/schemas.d.ts +2 -2
  173. package/dist/plugins/findUniqueConnection/index.d.ts +4 -4
  174. package/dist/plugins/findUniqueConnection/index.d.ts.map +1 -1
  175. package/dist/plugins/findUniqueConnection/index.js +4 -2
  176. package/dist/plugins/findUniqueConnection/schemas.d.ts +2 -2
  177. package/dist/plugins/getAction/index.d.ts +141 -4
  178. package/dist/plugins/getAction/index.d.ts.map +1 -1
  179. package/dist/plugins/getAction/index.js +5 -3
  180. package/dist/plugins/getAction/schemas.d.ts +6 -6
  181. package/dist/plugins/getActionInputFieldsSchema/index.d.ts +232 -3
  182. package/dist/plugins/getActionInputFieldsSchema/index.d.ts.map +1 -1
  183. package/dist/plugins/getActionInputFieldsSchema/index.js +3 -3
  184. package/dist/plugins/getActionInputFieldsSchema/schemas.d.ts +6 -6
  185. package/dist/plugins/getApp/index.d.ts +4 -4
  186. package/dist/plugins/getApp/index.d.ts.map +1 -1
  187. package/dist/plugins/getApp/index.js +3 -1
  188. package/dist/plugins/getApp/schemas.d.ts +4 -4
  189. package/dist/plugins/getConnection/index.d.ts +125 -2
  190. package/dist/plugins/getConnection/index.d.ts.map +1 -1
  191. package/dist/plugins/getConnection/index.js +4 -2
  192. package/dist/plugins/getProfile/index.d.ts +2 -2
  193. package/dist/plugins/getProfile/index.d.ts.map +1 -1
  194. package/dist/plugins/getProfile/index.js +4 -2
  195. package/dist/plugins/getProfile/schemas.d.ts +1 -2
  196. package/dist/plugins/getProfile/schemas.d.ts.map +1 -1
  197. package/dist/plugins/listActionInputFieldChoices/index.d.ts +287 -4
  198. package/dist/plugins/listActionInputFieldChoices/index.d.ts.map +1 -1
  199. package/dist/plugins/listActionInputFieldChoices/index.js +6 -4
  200. package/dist/plugins/listActionInputFieldChoices/schemas.d.ts +8 -8
  201. package/dist/plugins/listActionInputFieldChoices/schemas.d.ts.map +1 -1
  202. package/dist/plugins/listActionInputFieldChoices/schemas.js +1 -22
  203. package/dist/plugins/listActionInputFields/index.d.ts +168 -5
  204. package/dist/plugins/listActionInputFields/index.d.ts.map +1 -1
  205. package/dist/plugins/listActionInputFields/index.js +7 -5
  206. package/dist/plugins/listActionInputFields/schemas.d.ts +6 -6
  207. package/dist/plugins/listActions/index.d.ts +140 -3
  208. package/dist/plugins/listActions/index.d.ts.map +1 -1
  209. package/dist/plugins/listActions/index.js +6 -4
  210. package/dist/plugins/listActions/schemas.d.ts +4 -4
  211. package/dist/plugins/listApps/index.d.ts +3 -3
  212. package/dist/plugins/listApps/index.d.ts.map +1 -1
  213. package/dist/plugins/listApps/index.js +6 -4
  214. package/dist/plugins/listClientCredentials/index.d.ts +3 -3
  215. package/dist/plugins/listClientCredentials/index.d.ts.map +1 -1
  216. package/dist/plugins/listClientCredentials/index.js +6 -4
  217. package/dist/plugins/listConnections/index.d.ts +140 -3
  218. package/dist/plugins/listConnections/index.d.ts.map +1 -1
  219. package/dist/plugins/listConnections/index.js +7 -5
  220. package/dist/plugins/listConnections/schemas.d.ts +2 -2
  221. package/dist/plugins/manifest/index.d.ts +1 -1
  222. package/dist/plugins/manifest/index.d.ts.map +1 -1
  223. package/dist/plugins/manifest/index.js +6 -4
  224. package/dist/plugins/registry/index.d.ts +1 -1
  225. package/dist/plugins/registry/index.js +1 -1
  226. package/dist/plugins/request/index.d.ts +8 -5
  227. package/dist/plugins/request/index.d.ts.map +1 -1
  228. package/dist/plugins/request/index.js +4 -3
  229. package/dist/plugins/request/schemas.d.ts +2 -2
  230. package/dist/plugins/runAction/index.d.ts +168 -5
  231. package/dist/plugins/runAction/index.d.ts.map +1 -1
  232. package/dist/plugins/runAction/index.js +9 -5
  233. package/dist/plugins/runAction/schemas.d.ts +6 -6
  234. package/dist/plugins/tables/createTable/index.d.ts +2 -2
  235. package/dist/plugins/tables/createTable/index.js +2 -2
  236. package/dist/plugins/tables/createTable/schemas.d.ts +1 -2
  237. package/dist/plugins/tables/createTable/schemas.d.ts.map +1 -1
  238. package/dist/plugins/tables/createTableFields/index.d.ts +34 -2
  239. package/dist/plugins/tables/createTableFields/index.d.ts.map +1 -1
  240. package/dist/plugins/tables/createTableFields/index.js +4 -2
  241. package/dist/plugins/tables/createTableFields/schemas.d.ts +3 -4
  242. package/dist/plugins/tables/createTableFields/schemas.d.ts.map +1 -1
  243. package/dist/plugins/tables/createTableRecords/index.d.ts +63 -2
  244. package/dist/plugins/tables/createTableRecords/index.d.ts.map +1 -1
  245. package/dist/plugins/tables/createTableRecords/index.js +2 -2
  246. package/dist/plugins/tables/createTableRecords/schemas.d.ts +3 -4
  247. package/dist/plugins/tables/createTableRecords/schemas.d.ts.map +1 -1
  248. package/dist/plugins/tables/deleteTable/index.d.ts +34 -2
  249. package/dist/plugins/tables/deleteTable/index.d.ts.map +1 -1
  250. package/dist/plugins/tables/deleteTable/index.js +2 -2
  251. package/dist/plugins/tables/deleteTable/schemas.d.ts +3 -4
  252. package/dist/plugins/tables/deleteTable/schemas.d.ts.map +1 -1
  253. package/dist/plugins/tables/deleteTableFields/index.d.ts +63 -2
  254. package/dist/plugins/tables/deleteTableFields/index.d.ts.map +1 -1
  255. package/dist/plugins/tables/deleteTableFields/index.js +2 -2
  256. package/dist/plugins/tables/deleteTableFields/schemas.d.ts +4 -5
  257. package/dist/plugins/tables/deleteTableFields/schemas.d.ts.map +1 -1
  258. package/dist/plugins/tables/deleteTableRecords/index.d.ts +84 -2
  259. package/dist/plugins/tables/deleteTableRecords/index.d.ts.map +1 -1
  260. package/dist/plugins/tables/deleteTableRecords/index.js +2 -2
  261. package/dist/plugins/tables/deleteTableRecords/schemas.d.ts +4 -5
  262. package/dist/plugins/tables/deleteTableRecords/schemas.d.ts.map +1 -1
  263. package/dist/plugins/tables/getTable/index.d.ts +34 -2
  264. package/dist/plugins/tables/getTable/index.d.ts.map +1 -1
  265. package/dist/plugins/tables/getTable/index.js +2 -2
  266. package/dist/plugins/tables/getTable/schemas.d.ts +2 -2
  267. package/dist/plugins/tables/getTableRecord/index.d.ts +84 -2
  268. package/dist/plugins/tables/getTableRecord/index.d.ts.map +1 -1
  269. package/dist/plugins/tables/getTableRecord/index.js +2 -2
  270. package/dist/plugins/tables/getTableRecord/schemas.d.ts +6 -7
  271. package/dist/plugins/tables/getTableRecord/schemas.d.ts.map +1 -1
  272. package/dist/plugins/tables/getTableRecord/schemas.js +1 -10
  273. package/dist/plugins/tables/listTableFields/index.d.ts +34 -2
  274. package/dist/plugins/tables/listTableFields/index.d.ts.map +1 -1
  275. package/dist/plugins/tables/listTableFields/index.js +4 -2
  276. package/dist/plugins/tables/listTableFields/schemas.d.ts +4 -5
  277. package/dist/plugins/tables/listTableFields/schemas.d.ts.map +1 -1
  278. package/dist/plugins/tables/listTableFields/schemas.js +1 -9
  279. package/dist/plugins/tables/listTableRecords/index.d.ts +65 -4
  280. package/dist/plugins/tables/listTableRecords/index.d.ts.map +1 -1
  281. package/dist/plugins/tables/listTableRecords/index.js +3 -3
  282. package/dist/plugins/tables/listTableRecords/schemas.d.ts +2 -2
  283. package/dist/plugins/tables/listTables/index.d.ts +3 -3
  284. package/dist/plugins/tables/listTables/index.d.ts.map +1 -1
  285. package/dist/plugins/tables/listTables/index.js +4 -4
  286. package/dist/plugins/tables/updateTableRecords/index.d.ts +63 -2
  287. package/dist/plugins/tables/updateTableRecords/index.d.ts.map +1 -1
  288. package/dist/plugins/tables/updateTableRecords/index.js +2 -2
  289. package/dist/plugins/tables/updateTableRecords/schemas.d.ts +3 -4
  290. package/dist/plugins/tables/updateTableRecords/schemas.d.ts.map +1 -1
  291. package/dist/plugins/triggers/ackTriggerInboxMessages/index.d.ts +59 -2
  292. package/dist/plugins/triggers/ackTriggerInboxMessages/index.d.ts.map +1 -1
  293. package/dist/plugins/triggers/ackTriggerInboxMessages/index.js +1 -1
  294. package/dist/plugins/triggers/ackTriggerInboxMessages/schemas.d.ts +1 -1
  295. package/dist/plugins/triggers/createTriggerInbox/index.d.ts +231 -2
  296. package/dist/plugins/triggers/createTriggerInbox/index.d.ts.map +1 -1
  297. package/dist/plugins/triggers/createTriggerInbox/index.js +3 -1
  298. package/dist/plugins/triggers/createTriggerInbox/schemas.d.ts +3 -4
  299. package/dist/plugins/triggers/createTriggerInbox/schemas.d.ts.map +1 -1
  300. package/dist/plugins/triggers/deleteTriggerInbox/index.d.ts +33 -2
  301. package/dist/plugins/triggers/deleteTriggerInbox/index.d.ts.map +1 -1
  302. package/dist/plugins/triggers/deleteTriggerInbox/index.js +3 -1
  303. package/dist/plugins/triggers/deleteTriggerInbox/schemas.d.ts +2 -3
  304. package/dist/plugins/triggers/deleteTriggerInbox/schemas.d.ts.map +1 -1
  305. package/dist/plugins/triggers/drainTriggerInbox/index.d.ts +68 -6
  306. package/dist/plugins/triggers/drainTriggerInbox/index.d.ts.map +1 -1
  307. package/dist/plugins/triggers/drainTriggerInbox/index.js +1 -1
  308. package/dist/plugins/triggers/drainTriggerInbox/schemas.d.ts +2 -2
  309. package/dist/plugins/triggers/ensureTriggerInbox/index.d.ts +231 -2
  310. package/dist/plugins/triggers/ensureTriggerInbox/index.d.ts.map +1 -1
  311. package/dist/plugins/triggers/ensureTriggerInbox/index.js +3 -1
  312. package/dist/plugins/triggers/ensureTriggerInbox/schemas.d.ts +3 -4
  313. package/dist/plugins/triggers/ensureTriggerInbox/schemas.d.ts.map +1 -1
  314. package/dist/plugins/triggers/getTriggerInbox/index.d.ts +33 -2
  315. package/dist/plugins/triggers/getTriggerInbox/index.d.ts.map +1 -1
  316. package/dist/plugins/triggers/getTriggerInbox/index.js +3 -1
  317. package/dist/plugins/triggers/getTriggerInbox/schemas.d.ts +2 -3
  318. package/dist/plugins/triggers/getTriggerInbox/schemas.d.ts.map +1 -1
  319. package/dist/plugins/triggers/getTriggerInputFieldsSchema/index.d.ts +232 -3
  320. package/dist/plugins/triggers/getTriggerInputFieldsSchema/index.d.ts.map +1 -1
  321. package/dist/plugins/triggers/getTriggerInputFieldsSchema/index.js +1 -1
  322. package/dist/plugins/triggers/getTriggerInputFieldsSchema/schemas.d.ts +2 -2
  323. package/dist/plugins/triggers/leaseTriggerInboxMessages/index.d.ts +33 -2
  324. package/dist/plugins/triggers/leaseTriggerInboxMessages/index.d.ts.map +1 -1
  325. package/dist/plugins/triggers/leaseTriggerInboxMessages/index.js +1 -1
  326. package/dist/plugins/triggers/leaseTriggerInboxMessages/schemas.d.ts +1 -1
  327. package/dist/plugins/triggers/listTriggerInboxMessages/index.d.ts +34 -3
  328. package/dist/plugins/triggers/listTriggerInboxMessages/index.d.ts.map +1 -1
  329. package/dist/plugins/triggers/listTriggerInboxMessages/index.js +5 -13
  330. package/dist/plugins/triggers/listTriggerInboxMessages/schemas.d.ts +1 -1
  331. package/dist/plugins/triggers/listTriggerInboxes/index.d.ts +3 -3
  332. package/dist/plugins/triggers/listTriggerInboxes/index.d.ts.map +1 -1
  333. package/dist/plugins/triggers/listTriggerInboxes/index.js +5 -14
  334. package/dist/plugins/triggers/listTriggerInputFieldChoices/index.d.ts +288 -5
  335. package/dist/plugins/triggers/listTriggerInputFieldChoices/index.d.ts.map +1 -1
  336. package/dist/plugins/triggers/listTriggerInputFieldChoices/index.js +7 -5
  337. package/dist/plugins/triggers/listTriggerInputFieldChoices/schemas.d.ts +3 -3
  338. package/dist/plugins/triggers/listTriggerInputFields/index.d.ts +234 -5
  339. package/dist/plugins/triggers/listTriggerInputFields/index.d.ts.map +1 -1
  340. package/dist/plugins/triggers/listTriggerInputFields/index.js +6 -5
  341. package/dist/plugins/triggers/listTriggerInputFields/schemas.d.ts +2 -2
  342. package/dist/plugins/triggers/listTriggers/index.d.ts +142 -5
  343. package/dist/plugins/triggers/listTriggers/index.d.ts.map +1 -1
  344. package/dist/plugins/triggers/listTriggers/index.js +6 -5
  345. package/dist/plugins/triggers/listTriggers/schemas.d.ts +1 -1
  346. package/dist/plugins/triggers/pauseTriggerInbox/index.d.ts +33 -2
  347. package/dist/plugins/triggers/pauseTriggerInbox/index.d.ts.map +1 -1
  348. package/dist/plugins/triggers/pauseTriggerInbox/index.js +3 -1
  349. package/dist/plugins/triggers/pauseTriggerInbox/schemas.d.ts +2 -3
  350. package/dist/plugins/triggers/pauseTriggerInbox/schemas.d.ts.map +1 -1
  351. package/dist/plugins/triggers/releaseTriggerInboxMessages/index.d.ts +59 -2
  352. package/dist/plugins/triggers/releaseTriggerInboxMessages/index.d.ts.map +1 -1
  353. package/dist/plugins/triggers/releaseTriggerInboxMessages/index.js +1 -1
  354. package/dist/plugins/triggers/releaseTriggerInboxMessages/schemas.d.ts +1 -1
  355. package/dist/plugins/triggers/resumeTriggerInbox/index.d.ts +33 -2
  356. package/dist/plugins/triggers/resumeTriggerInbox/index.d.ts.map +1 -1
  357. package/dist/plugins/triggers/resumeTriggerInbox/index.js +3 -1
  358. package/dist/plugins/triggers/resumeTriggerInbox/schemas.d.ts +2 -3
  359. package/dist/plugins/triggers/resumeTriggerInbox/schemas.d.ts.map +1 -1
  360. package/dist/plugins/triggers/updateTriggerInbox/index.d.ts +33 -2
  361. package/dist/plugins/triggers/updateTriggerInbox/index.d.ts.map +1 -1
  362. package/dist/plugins/triggers/updateTriggerInbox/index.js +3 -1
  363. package/dist/plugins/triggers/updateTriggerInbox/schemas.d.ts +2 -3
  364. package/dist/plugins/triggers/updateTriggerInbox/schemas.d.ts.map +1 -1
  365. package/dist/plugins/triggers/watchTriggerInbox/index.d.ts +37 -6
  366. package/dist/plugins/triggers/watchTriggerInbox/index.d.ts.map +1 -1
  367. package/dist/plugins/triggers/watchTriggerInbox/index.js +1 -1
  368. package/dist/resolvers/actionKey.d.ts +3 -2
  369. package/dist/resolvers/actionKey.d.ts.map +1 -1
  370. package/dist/resolvers/actionType.d.ts +7 -2
  371. package/dist/resolvers/actionType.d.ts.map +1 -1
  372. package/dist/resolvers/actionType.js +3 -0
  373. package/dist/resolvers/appKey.d.ts +10 -5
  374. package/dist/resolvers/appKey.d.ts.map +1 -1
  375. package/dist/resolvers/appKey.js +3 -0
  376. package/dist/resolvers/clientCredentialsName.d.ts +1 -1
  377. package/dist/resolvers/clientCredentialsName.d.ts.map +1 -1
  378. package/dist/resolvers/clientId.d.ts +3 -2
  379. package/dist/resolvers/clientId.d.ts.map +1 -1
  380. package/dist/resolvers/clientId.js +1 -1
  381. package/dist/resolvers/connectionId.d.ts +5 -2
  382. package/dist/resolvers/connectionId.d.ts.map +1 -1
  383. package/dist/resolvers/connectionId.js +1 -1
  384. package/dist/resolvers/durableRunId.d.ts +3 -2
  385. package/dist/resolvers/durableRunId.d.ts.map +1 -1
  386. package/dist/resolvers/durableRunId.js +3 -2
  387. package/dist/resolvers/index.d.ts +1 -0
  388. package/dist/resolvers/index.d.ts.map +1 -1
  389. package/dist/resolvers/index.js +1 -0
  390. package/dist/resolvers/inputFieldKey.d.ts +3 -2
  391. package/dist/resolvers/inputFieldKey.d.ts.map +1 -1
  392. package/dist/resolvers/inputFieldKey.js +1 -1
  393. package/dist/resolvers/tableFieldIds.d.ts +3 -2
  394. package/dist/resolvers/tableFieldIds.d.ts.map +1 -1
  395. package/dist/resolvers/tableFields.d.ts +2 -2
  396. package/dist/resolvers/tableFields.d.ts.map +1 -1
  397. package/dist/resolvers/tableFilters.d.ts +3 -2
  398. package/dist/resolvers/tableFilters.d.ts.map +1 -1
  399. package/dist/resolvers/tableId.d.ts +3 -2
  400. package/dist/resolvers/tableId.d.ts.map +1 -1
  401. package/dist/resolvers/tableId.js +1 -1
  402. package/dist/resolvers/tableName.d.ts +1 -1
  403. package/dist/resolvers/tableName.d.ts.map +1 -1
  404. package/dist/resolvers/tableRecordId.d.ts +4 -3
  405. package/dist/resolvers/tableRecordId.d.ts.map +1 -1
  406. package/dist/resolvers/tableRecords.d.ts +4 -3
  407. package/dist/resolvers/tableRecords.d.ts.map +1 -1
  408. package/dist/resolvers/tableSort.d.ts +3 -2
  409. package/dist/resolvers/tableSort.d.ts.map +1 -1
  410. package/dist/resolvers/triggerInbox.d.ts +3 -2
  411. package/dist/resolvers/triggerInbox.d.ts.map +1 -1
  412. package/dist/resolvers/triggerInbox.js +1 -1
  413. package/dist/resolvers/triggerMessages.d.ts +3 -2
  414. package/dist/resolvers/triggerMessages.d.ts.map +1 -1
  415. package/dist/resolvers/triggerMessages.js +2 -4
  416. package/dist/resolvers/workflowId.d.ts +3 -2
  417. package/dist/resolvers/workflowId.d.ts.map +1 -1
  418. package/dist/resolvers/workflowId.js +3 -2
  419. package/dist/resolvers/workflowRunId.d.ts +7 -0
  420. package/dist/resolvers/workflowRunId.d.ts.map +1 -0
  421. package/dist/resolvers/workflowRunId.js +20 -0
  422. package/dist/resolvers/workflowVersionId.d.ts +3 -2
  423. package/dist/resolvers/workflowVersionId.d.ts.map +1 -1
  424. package/dist/resolvers/workflowVersionId.js +7 -7
  425. package/dist/schemas/Action.d.ts.map +1 -1
  426. package/dist/schemas/Action.js +6 -30
  427. package/dist/schemas/App.d.ts +0 -1
  428. package/dist/schemas/App.d.ts.map +1 -1
  429. package/dist/schemas/App.js +2 -14
  430. package/dist/schemas/ClientCredentials.d.ts.map +1 -1
  431. package/dist/schemas/ClientCredentials.js +3 -41
  432. package/dist/schemas/Connection.d.ts.map +1 -1
  433. package/dist/schemas/Connection.js +2 -28
  434. package/dist/schemas/Field.d.ts.map +1 -1
  435. package/dist/schemas/Field.js +3 -70
  436. package/dist/schemas/Run.d.ts.map +1 -1
  437. package/dist/schemas/Run.js +3 -29
  438. package/dist/schemas/TriggerInbox.d.ts.map +1 -1
  439. package/dist/schemas/TriggerInbox.js +1 -33
  440. package/dist/schemas/TriggerMessage.d.ts.map +1 -1
  441. package/dist/schemas/TriggerMessage.js +2 -60
  442. package/dist/schemas/UserProfile.d.ts +0 -1
  443. package/dist/schemas/UserProfile.d.ts.map +1 -1
  444. package/dist/schemas/UserProfile.js +1 -20
  445. package/dist/sdk.d.ts +2761 -441
  446. package/dist/sdk.d.ts.map +1 -1
  447. package/dist/sdk.js +93 -129
  448. package/dist/types/errors.d.ts +44 -42
  449. package/dist/types/errors.d.ts.map +1 -1
  450. package/dist/types/errors.js +79 -33
  451. package/dist/types/functions.d.ts +1 -41
  452. package/dist/types/functions.d.ts.map +1 -1
  453. package/dist/types/properties.d.ts +7 -7
  454. package/dist/types/properties.js +1 -1
  455. package/dist/types/sdk.d.ts +1 -1
  456. package/dist/types/sdk.d.ts.map +1 -1
  457. package/dist/utils/domain-utils.js +1 -1
  458. package/dist/utils/logging.d.ts +1 -12
  459. package/dist/utils/logging.d.ts.map +1 -1
  460. package/dist/utils/logging.js +2 -20
  461. package/dist/utils/pagination.d.ts +38 -0
  462. package/dist/utils/pagination.d.ts.map +1 -0
  463. package/dist/utils/pagination.js +53 -0
  464. package/package.json +3 -2
  465. package/dist/registry.d.ts +0 -9
  466. package/dist/registry.d.ts.map +0 -1
  467. package/dist/registry.js +0 -103
  468. package/dist/types/meta.d.ts +0 -9
  469. package/dist/types/meta.d.ts.map +0 -1
  470. package/dist/types/meta.js +0 -3
  471. package/dist/types/plugin.d.ts +0 -84
  472. package/dist/types/plugin.d.ts.map +0 -1
  473. package/dist/types/plugin.js +0 -13
  474. package/dist/types/registry.d.ts +0 -54
  475. package/dist/types/registry.d.ts.map +0 -1
  476. package/dist/types/registry.js +0 -1
  477. package/dist/utils/function-utils.d.ts +0 -59
  478. package/dist/utils/function-utils.d.ts.map +0 -1
  479. package/dist/utils/function-utils.js +0 -245
  480. package/dist/utils/pagination-utils.d.ts +0 -73
  481. package/dist/utils/pagination-utils.d.ts.map +0 -1
  482. package/dist/utils/pagination-utils.js +0 -308
  483. package/dist/utils/plugin-utils.d.ts +0 -245
  484. package/dist/utils/plugin-utils.d.ts.map +0 -1
  485. package/dist/utils/plugin-utils.js +0 -234
  486. package/dist/utils/schema-utils.d.ts +0 -211
  487. package/dist/utils/schema-utils.d.ts.map +0 -1
  488. package/dist/utils/schema-utils.js +0 -72
  489. package/dist/utils/string-utils.d.ts +0 -40
  490. package/dist/utils/string-utils.d.ts.map +0 -1
  491. package/dist/utils/string-utils.js +0 -69
  492. package/dist/utils/telemetry-context.d.ts +0 -15
  493. package/dist/utils/telemetry-context.d.ts.map +0 -1
  494. package/dist/utils/telemetry-context.js +0 -48
  495. package/dist/utils/telemetry-utils.d.ts +0 -44
  496. package/dist/utils/telemetry-utils.d.ts.map +0 -1
  497. package/dist/utils/telemetry-utils.js +0 -60
  498. package/dist/utils/validation.d.ts +0 -4
  499. package/dist/utils/validation.d.ts.map +0 -1
  500. package/dist/utils/validation.js +0 -30
package/dist/index.mjs CHANGED
@@ -11,547 +11,271 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
11
11
  if (typeof require !== "undefined") return require.apply(this, arguments);
12
12
  throw Error('Dynamic require of "' + x + '" is not supported');
13
13
  });
14
- function withFormatter(schema, formatMeta) {
15
- Object.assign(schema._zod.def, {
16
- formatMeta
17
- });
18
- return schema;
19
- }
20
- function withPositional(schema) {
21
- Object.assign(schema._zod.def, {
22
- positionalMeta: { positional: true }
23
- });
24
- return schema;
25
- }
26
- function schemaHasPositionalMeta(schema) {
27
- return "positionalMeta" in schema._zod.def;
14
+ function toTitleCase(input) {
15
+ return input.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[_\-]+/g, " ").replace(/\s+/g, " ").trim().split(" ").map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(" ");
28
16
  }
29
- function isPositional(schema) {
30
- if (schemaHasPositionalMeta(schema) && schema._zod.def.positionalMeta?.positional) {
31
- return true;
32
- }
33
- if (schema instanceof z.ZodOptional) {
34
- return isPositional(schema._zod.def.innerType);
17
+ function toSnakeCase(input) {
18
+ let result = input.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/[\s\-]+/g, "_").replace(/_+/g, "_").replace(/^_|_$/g, "").toLowerCase();
19
+ if (/^[0-9]/.test(result)) {
20
+ result = "_" + result;
35
21
  }
36
- if (schema instanceof z.ZodDefault) {
37
- return isPositional(schema._zod.def.innerType);
22
+ return result;
23
+ }
24
+ function pluralize(word) {
25
+ if (/s$/i.test(word)) return word;
26
+ if (/[bcdfghjklmnpqrstvwxz]y$/i.test(word)) {
27
+ return word.slice(0, -1) + "ies";
38
28
  }
39
- return false;
29
+ return word + "s";
40
30
  }
41
-
42
- // src/constants.ts
43
- var ZAPIER_BASE_URL = globalThis.process?.env?.ZAPIER_BASE_URL || "https://zapier.com";
44
- function getZapierSdkService() {
45
- return globalThis.process?.env?.ZAPIER_SDK_SERVICE;
31
+ function pluralizeLastWord(title) {
32
+ const words = title.split(" ");
33
+ return [...words.slice(0, -1), pluralize(words[words.length - 1])].join(" ");
46
34
  }
47
- var MAX_PAGE_LIMIT = 1e4;
48
- var DEFAULT_PAGE_SIZE = 100;
49
- var DEFAULT_ACTION_TIMEOUT_MS = 18e4;
50
- function parseIntEnvVar(name) {
51
- const value = globalThis.process?.env?.[name];
52
- if (value === void 0) return void 0;
53
- const parsed = parseInt(value, 10);
54
- if (isNaN(parsed)) {
55
- console.warn(
56
- `[zapier-sdk] Invalid value for ${name}: "${value}" (expected integer)`
57
- );
58
- return void 0;
35
+ function resolveCategoryDefinition(ref) {
36
+ const def = typeof ref === "string" ? { key: ref } : ref;
37
+ const title = def.title ?? toTitleCase(def.key);
38
+ return {
39
+ key: def.key,
40
+ title,
41
+ titlePlural: def.titlePlural ?? pluralizeLastWord(title)
42
+ };
43
+ }
44
+ function canonicalInputSchema(schema) {
45
+ if (schema instanceof z.ZodUnion) {
46
+ return schema.options[0];
59
47
  }
60
- return parsed;
48
+ return schema;
61
49
  }
62
- var ZAPIER_MAX_NETWORK_RETRIES = parseIntEnvVar("ZAPIER_MAX_NETWORK_RETRIES") ?? 3;
63
- var ZAPIER_MAX_NETWORK_RETRY_DELAY_MS = parseIntEnvVar("ZAPIER_MAX_NETWORK_RETRY_DELAY_MS") ?? 6e4;
64
- var MAX_CONCURRENCY_LIMIT = 1e4;
65
- function parseConcurrencyEnvVar(name) {
66
- const value = globalThis.process?.env?.[name];
67
- if (!value) return void 0;
68
- if (value === "Infinity") return Infinity;
69
- if (/^[1-9]\d*$/.test(value)) {
70
- const parsed = parseInt(value, 10);
71
- if (parsed <= MAX_CONCURRENCY_LIMIT) return parsed;
50
+ function buildRegistry({
51
+ sdk,
52
+ meta,
53
+ packageFilter
54
+ }) {
55
+ const definitionsByKey = /* @__PURE__ */ new Map();
56
+ const objectDeclaredKeys = /* @__PURE__ */ new Set();
57
+ for (const m of Object.values(meta)) {
58
+ for (const ref of m.categories ?? []) {
59
+ const key = typeof ref === "string" ? ref : ref.key;
60
+ if (typeof ref === "object") {
61
+ objectDeclaredKeys.add(key);
62
+ definitionsByKey.set(key, resolveCategoryDefinition(ref));
63
+ } else if (!objectDeclaredKeys.has(key)) {
64
+ definitionsByKey.set(key, resolveCategoryDefinition(ref));
65
+ }
66
+ }
72
67
  }
73
- console.warn(
74
- `[zapier-sdk] Invalid value for ${name}: "${value}" (expected positive integer 1-${MAX_CONCURRENCY_LIMIT} or "Infinity")`
75
- );
76
- return void 0;
68
+ if (!definitionsByKey.has("other")) {
69
+ definitionsByKey.set("other", resolveCategoryDefinition("other"));
70
+ }
71
+ const knownCategories = Array.from(definitionsByKey.keys());
72
+ const functions = Object.keys(meta).filter((key) => {
73
+ const property = sdk[key];
74
+ if (typeof property === "function") return true;
75
+ const [rootKey] = key.split(".");
76
+ const rootProperty = sdk[rootKey];
77
+ return typeof rootProperty === "object" && rootProperty !== null;
78
+ }).map((key) => {
79
+ const m = meta[key];
80
+ return {
81
+ name: key,
82
+ description: m.description,
83
+ type: m.type,
84
+ itemType: m.itemType,
85
+ returnType: m.returnType,
86
+ inputSchema: canonicalInputSchema(m.inputSchema),
87
+ inputParameters: m.inputParameters,
88
+ outputSchema: m.outputSchema,
89
+ categories: (m.categories ?? []).map(
90
+ (c) => typeof c === "string" ? c : c.key
91
+ ),
92
+ resolvers: m.resolvers,
93
+ formatter: m.formatter,
94
+ experimental: m.experimental,
95
+ packages: m.packages,
96
+ confirm: m.confirm ?? (m.type === "delete" ? "delete" : void 0),
97
+ deprecation: m.deprecation,
98
+ aliases: m.aliases,
99
+ supportsJsonOutput: m.supportsJsonOutput ?? true
100
+ };
101
+ }).sort((a, b) => a.name.localeCompare(b.name));
102
+ const filteredFunctions = packageFilter ? functions.filter((f) => !f.packages || f.packages.includes(packageFilter)) : functions;
103
+ const filteredCategories = knownCategories.slice().sort((a, b) => {
104
+ if (a === "other") return 1;
105
+ if (b === "other") return -1;
106
+ return definitionsByKey.get(a).title.localeCompare(definitionsByKey.get(b).title);
107
+ }).map((categoryKey) => {
108
+ const categoryFunctions = filteredFunctions.filter(
109
+ (f) => f.categories.includes(categoryKey) || categoryKey === "other" && !f.categories.some((c) => knownCategories.includes(c))
110
+ ).map((f) => f.name).sort();
111
+ const def = definitionsByKey.get(categoryKey);
112
+ return {
113
+ key: categoryKey,
114
+ title: def.title,
115
+ titlePlural: def.titlePlural,
116
+ functions: categoryFunctions
117
+ };
118
+ }).filter((category) => category.functions.length > 0);
119
+ return { functions: filteredFunctions, categories: filteredCategories };
77
120
  }
78
- var ZAPIER_MAX_CONCURRENT_REQUESTS = parseConcurrencyEnvVar("ZAPIER_MAX_CONCURRENT_REQUESTS") ?? 200;
79
- function getZapierApprovalMode() {
80
- const value = globalThis.process?.env?.ZAPIER_APPROVAL_MODE;
81
- if (value === "disabled" || value === "poll" || value === "throw")
82
- return value;
83
- return void 0;
121
+ function composeVoid(existing, added) {
122
+ if (!existing) return added;
123
+ if (!added) return existing;
124
+ return (ctx) => {
125
+ existing(ctx);
126
+ added(ctx);
127
+ };
84
128
  }
85
- function getZapierDefaultApprovalMode() {
86
- const isInteractive = !!globalThis.process?.stdin?.isTTY && !!globalThis.process?.stdout?.isTTY;
87
- return isInteractive ? "poll" : "throw";
129
+ function buildHooks(existing, added) {
130
+ const result = {};
131
+ const start = composeVoid(existing.onMethodStart, added.onMethodStart);
132
+ if (start) result.onMethodStart = start;
133
+ const end = composeVoid(existing.onMethodEnd, added.onMethodEnd);
134
+ if (end) result.onMethodEnd = end;
135
+ return result;
88
136
  }
89
- var DEFAULT_APPROVAL_TIMEOUT_MS = 10 * 60 * 1e3;
90
- var DEFAULT_MAX_APPROVAL_RETRIES = 2;
91
-
92
- // src/types/properties.ts
93
- var AppKeyPropertySchema = withPositional(
94
- z.string().min(1).describe("App key (e.g., 'SlackCLIAPI' or slug like 'github')")
95
- );
96
- var AppPropertySchema = withPositional(
97
- z.string().min(1).describe(
98
- "App slug (e.g., 'github'), implementation name (e.g., 'SlackCLIAPI'), or versioned ID (e.g., 'github@1.2.3')"
99
- )
100
- );
101
- var ActionTypePropertySchema = z.enum([
102
- "read",
103
- "read_bulk",
104
- "write",
105
- "run",
106
- "search",
107
- "search_or_write",
108
- "search_and_write",
109
- "filter"
110
- ]).describe("Action type that matches the action's defined type");
111
- var ActionKeyPropertySchema = z.string().min(1).describe("Action key to execute");
112
- var ActionPropertySchema = withPositional(
113
- z.string().min(1).describe("Action key (e.g., 'send_message' or 'find_row')")
114
- );
115
- var InputFieldPropertySchema = withPositional(
116
- z.string().min(1).describe("Input field key to get choices for")
117
- );
118
- var ConnectionIdPropertySchema = z.union([z.string(), z.number().int().positive()]).describe("Connection ID to use for this action");
119
- var AuthenticationIdPropertySchema = ConnectionIdPropertySchema.meta({
120
- deprecated: true
121
- });
122
- var ConnectionPropertySchema = z.union([z.string(), z.number().int().positive()]).describe(
123
- "Connection alias or connection ID (UUID or positive integer). Strings that match a key in the connections map are resolved against it; otherwise the value is used as a connection ID directly."
124
- );
125
- var InputsPropertySchema = z.record(z.string(), z.unknown()).describe("Input parameters for the action");
126
- var LimitPropertySchema = z.number().int().min(1).max(MAX_PAGE_LIMIT).default(50).describe("Maximum number of items to return");
127
- var OffsetPropertySchema = z.number().int().min(0).default(0).describe("Number of items to skip for pagination");
128
- var OutputPropertySchema = z.string().describe("Output file path");
129
- var DebugPropertySchema = z.boolean().default(false).describe("Enable debug logging");
130
- var ParamsPropertySchema = z.record(z.string(), z.unknown()).describe("Additional parameters");
131
- var ActionTimeoutMsPropertySchema = z.number().min(1e3).optional().describe(
132
- `Maximum time to wait for action completion in milliseconds (default: ${DEFAULT_ACTION_TIMEOUT_MS})`
133
- );
134
- var TablePropertySchema = withPositional(
135
- z.string().regex(/^[A-Z0-9]{26}$/, "Table ID must be a valid ULID").describe("The unique identifier of the table")
136
- );
137
- var RecordPropertySchema = withPositional(
138
- z.string().regex(/^[A-Z0-9]{26}$/, "Record ID must be a valid ULID").describe("The unique identifier of the record")
139
- );
140
- var RecordsPropertySchema = z.array(z.string().regex(/^[A-Z0-9]{26}$/, "Record ID must be a valid ULID")).min(1).max(100).describe("Record IDs to operate on");
141
- var FieldsPropertySchema = z.array(z.union([z.string(), z.number()])).describe(
142
- 'Fields to operate on. Accepts field names (e.g., "Email") or IDs (e.g., "f6", "6", or 6).'
143
- );
144
- var AppsPropertySchema = z.array(z.string()).describe("Filter by app keys (e.g., 'SlackCLIAPI' or slug like 'github')");
145
- var TablesPropertySchema = z.array(z.string()).describe("Filter by specific table IDs");
146
- var ConnectionsPropertySchema = z.array(z.string()).describe("List of connection IDs to filter by");
147
- var TriggerInboxPropertySchema = withPositional(
148
- z.string().min(1).describe(
149
- "Trigger inbox identifier \u2014 UUID or name. Non-UUID values are resolved by name via the inbox list endpoint."
150
- )
151
- );
152
- var TriggerInboxNamePropertySchema = z.string().min(1).max(100).describe(
153
- "Inbox name; unique per (user, account). Enables get-or-create on createTriggerInbox."
154
- );
155
- var LeasePropertySchema = z.string().min(1).describe("Lease ID returned from leaseTriggerInboxMessages");
156
- var LeaseSecondsPropertySchema = z.number().int().min(1).max(3600).describe(
157
- "Seconds until the lease expires; messages return to available if not acked. API default is 300 (5 minutes)."
158
- );
159
- var LeaseLimitPropertySchema = z.number().int().min(1).max(100).describe("Maximum messages to lease in a single batch (1-100)");
160
-
161
- // src/types/errors.ts
162
- var ZapierError = class extends Error {
137
+ function createDeprecationLogger(tag) {
138
+ const loggedDeprecations = /* @__PURE__ */ new Set();
139
+ return {
140
+ logDeprecation(message) {
141
+ if (loggedDeprecations.has(message)) return;
142
+ loggedDeprecations.add(message);
143
+ console.warn(`[${tag}] Deprecation: ${message}`);
144
+ },
145
+ resetDeprecationWarnings() {
146
+ loggedDeprecations.clear();
147
+ }
148
+ };
149
+ }
150
+ var { logDeprecation} = createDeprecationLogger("core");
151
+ var CORE_ERROR_SYMBOL = Symbol.for("kitcore.error");
152
+ var CoreErrorCode = {
153
+ Validation: "VALIDATION_ERROR",
154
+ Unknown: "UNKNOWN_ERROR"
155
+ };
156
+ var CoreError = class extends Error {
163
157
  constructor(message, options = {}) {
164
158
  super(message);
165
- this.statusCode = options.statusCode;
166
- this.errors = options.errors;
167
- this.cause = options.cause;
168
- this.response = options.response;
159
+ this.name = "CoreError";
160
+ if (options.statusCode !== void 0) this.statusCode = options.statusCode;
161
+ if (options.errors !== void 0) this.errors = options.errors;
162
+ if (options.cause !== void 0) this.cause = options.cause;
163
+ if (options.response !== void 0) this.response = options.response;
169
164
  Object.setPrototypeOf(this, new.target.prototype);
170
165
  }
171
166
  };
172
- var ZapierApiError = class extends ZapierError {
173
- constructor(message, options = {}) {
174
- super(message, options);
175
- this.name = "ZapierApiError";
176
- this.code = "ZAPIER_API_ERROR";
177
- }
178
- };
179
- var ZapierAppNotFoundError = class extends ZapierError {
180
- constructor(message, options = {}) {
181
- super(message, options);
182
- this.name = "ZapierAppNotFoundError";
183
- this.code = "ZAPIER_APP_NOT_FOUND_ERROR";
184
- this.appKey = options.appKey;
185
- }
186
- };
187
- var ZapierValidationError = class extends ZapierError {
188
- constructor(message, options = {}) {
189
- super(message, options);
190
- this.name = "ZapierValidationError";
191
- this.code = "ZAPIER_VALIDATION_ERROR";
192
- this.details = options.details;
193
- }
194
- };
195
- var ZapierUnknownError = class extends ZapierError {
196
- constructor(message, options = {}) {
197
- super(message, options);
198
- this.name = "ZapierUnknownError";
199
- this.code = "ZAPIER_UNKNOWN_ERROR";
200
- }
167
+ function createCoreError(options, adaptError) {
168
+ const error = adaptError?.(options) ?? new CoreError(options.message, { cause: options.cause });
169
+ Object.defineProperty(error, CORE_ERROR_SYMBOL, {
170
+ value: true,
171
+ enumerable: false,
172
+ configurable: true,
173
+ writable: false
174
+ });
175
+ Object.defineProperty(error, "coreCode", {
176
+ value: options.code,
177
+ enumerable: false,
178
+ configurable: true,
179
+ writable: false
180
+ });
181
+ return error;
182
+ }
183
+ function isCoreError(value) {
184
+ return Boolean(
185
+ value && typeof value === "object" && value[CORE_ERROR_SYMBOL] === true
186
+ );
187
+ }
188
+ function getCoreErrorCode(value) {
189
+ if (!isCoreError(value)) return void 0;
190
+ return value.coreCode;
191
+ }
192
+ function getCoreErrorCause(value) {
193
+ if (!isCoreError(value)) return void 0;
194
+ return value.cause;
195
+ }
196
+ var CURSOR_VERSION = 1;
197
+ var CURSOR_SOURCE = {
198
+ API: "api",
199
+ SDK: "sdk"
201
200
  };
202
- var ZapierAuthenticationError = class extends ZapierError {
203
- constructor(message, options = {}) {
204
- super(message, options);
205
- this.name = "ZapierAuthenticationError";
206
- this.code = "ZAPIER_AUTHENTICATION_ERROR";
207
- }
208
- };
209
- var ZapierNotFoundError = class extends ZapierError {
210
- constructor(message, options = {}) {
211
- super(message, options);
212
- this.name = "ZapierNotFoundError";
213
- this.code = "ZAPIER_NOT_FOUND_ERROR";
214
- }
215
- };
216
- var ZapierResourceNotFoundError = class extends ZapierNotFoundError {
217
- constructor(message, options = {}) {
218
- super(message, options);
219
- this.name = "ZapierResourceNotFoundError";
220
- this.code = "ZAPIER_RESOURCE_NOT_FOUND_ERROR";
221
- this.resourceType = options.resourceType;
222
- this.resourceId = options.resourceId;
223
- }
224
- };
225
- var ZapierConfigurationError = class extends ZapierError {
226
- constructor(message, options = {}) {
227
- super(message, options);
228
- this.name = "ZapierConfigurationError";
229
- this.code = "ZAPIER_CONFIGURATION_ERROR";
230
- this.configType = options.configType;
231
- }
232
- };
233
- var ZapierBundleError = class extends ZapierError {
234
- constructor(message, options = {}) {
235
- super(message, options);
236
- this.name = "ZapierBundleError";
237
- this.code = "ZAPIER_BUNDLE_ERROR";
238
- this.buildErrors = options.buildErrors;
239
- }
240
- };
241
- var ZapierTimeoutError = class extends ZapierError {
242
- constructor(message, options = {}) {
243
- super(message, options);
244
- this.name = "ZapierTimeoutError";
245
- this.code = "ZAPIER_TIMEOUT_ERROR";
246
- this.attempts = options.attempts;
247
- this.maxAttempts = options.maxAttempts;
248
- }
249
- };
250
- var ZapierActionError = class extends ZapierError {
251
- constructor(message, options = {}) {
252
- super(message, options);
253
- this.name = "ZapierActionError";
254
- this.code = "ZAPIER_ACTION_ERROR";
255
- this.appKey = options.appKey;
256
- this.actionKey = options.actionKey;
257
- }
258
- // Legacy accessor for backward compatibility
259
- get actionErrors() {
260
- return this.errors;
261
- }
262
- };
263
- var ZapierConflictError = class extends ZapierError {
264
- constructor(message, options = {}) {
265
- super(message, options);
266
- this.name = "ZapierConflictError";
267
- this.code = "ZAPIER_CONFLICT_ERROR";
268
- this.resourceType = options.resourceType;
269
- }
270
- };
271
- var ZapierRateLimitError = class extends ZapierError {
272
- constructor(message, options = {}) {
273
- super(message, options);
274
- this.name = "ZapierRateLimitError";
275
- this.code = "ZAPIER_RATE_LIMIT_ERROR";
276
- this.rateLimit = options.rateLimit ?? {};
277
- this.retries = options.retries ?? 0;
278
- }
279
- };
280
- var ZapierApprovalError = class extends ZapierError {
281
- constructor(message, options = {}) {
282
- super(message, options);
283
- this.name = "ZapierApprovalError";
284
- this.code = "ZAPIER_APPROVAL_ERROR";
285
- this.approvalId = options.approvalId;
286
- this.approvalStatus = options.status;
287
- this.approvalUrl = options.approvalUrl;
288
- this.pollUrl = options.pollUrl;
289
- }
290
- };
291
- var ZapierRelayError = class extends ZapierError {
292
- constructor(message, options = {}) {
293
- super(message, options);
294
- this.name = "ZapierRelayError";
295
- this.code = "ZAPIER_RELAY_ERROR";
296
- }
297
- };
298
- function formatErrorMessage(error) {
299
- let message = error.message;
300
- if (error.errors && error.errors.length > 0) {
301
- const additionalErrors = error.errors.slice(1);
302
- if (additionalErrors.length > 0) {
303
- const errorDetails = additionalErrors.map((err) => ` \u2022 ${err.detail || err.title || err.code}`).join("\n");
304
- message += "\n\nAdditional errors:\n" + errorDetails;
305
- }
306
- }
307
- if (error instanceof ZapierAppNotFoundError && error.appKey) {
308
- message += `
309
- App key: ${error.appKey}`;
310
- }
311
- if (error instanceof ZapierActionError && (error.appKey || error.actionKey)) {
312
- const context = [];
313
- if (error.appKey) context.push(`App: ${error.appKey}`);
314
- if (error.actionKey) context.push(`Action: ${error.actionKey}`);
315
- message += `
316
- ${context.join(", ")}`;
317
- }
318
- if (error instanceof ZapierResourceNotFoundError && (error.resourceType || error.resourceId)) {
319
- const context = [];
320
- if (error.resourceType) context.push(`Type: ${error.resourceType}`);
321
- if (error.resourceId) context.push(`ID: ${error.resourceId}`);
322
- message += `
323
- ${context.join(", ")}`;
324
- }
325
- if (error instanceof ZapierConflictError && error.resourceType) {
326
- message += `
327
- Type: ${error.resourceType}`;
328
- }
329
- if (error instanceof ZapierTimeoutError && (error.attempts || error.maxAttempts)) {
330
- const context = [];
331
- if (error.attempts) context.push(`Attempts: ${error.attempts}`);
332
- if (error.maxAttempts) context.push(`Max attempts: ${error.maxAttempts}`);
333
- message += `
334
- ${context.join(", ")}`;
335
- }
336
- if (error instanceof ZapierBundleError && error.buildErrors && error.buildErrors.length > 0) {
337
- message += "\n\nBuild errors:\n" + error.buildErrors.map((err) => ` \u2022 ${err}`).join("\n");
338
- }
339
- if (error instanceof ZapierApprovalError && error.approvalUrl) {
340
- message += `
341
- Approval URL: ${error.approvalUrl}`;
201
+ function encodeBase64(str) {
202
+ return btoa(
203
+ Array.from(
204
+ new TextEncoder().encode(str),
205
+ (b) => String.fromCharCode(b)
206
+ ).join("")
207
+ );
208
+ }
209
+ function decodeBase64(str) {
210
+ return new TextDecoder().decode(
211
+ Uint8Array.from(atob(str), (c) => c.charCodeAt(0))
212
+ );
213
+ }
214
+ function encodeApiCursor(cursor) {
215
+ const envelope = {
216
+ v: CURSOR_VERSION,
217
+ source: CURSOR_SOURCE.API,
218
+ cursor
219
+ };
220
+ return encodeBase64(JSON.stringify(envelope));
221
+ }
222
+ function encodeSdkCursor(offset, cursor) {
223
+ const envelope = {
224
+ v: CURSOR_VERSION,
225
+ source: CURSOR_SOURCE.SDK,
226
+ cursor,
227
+ offset
228
+ };
229
+ return encodeBase64(JSON.stringify(envelope));
230
+ }
231
+ function decodeIncomingCursor(incoming) {
232
+ if (!incoming) {
233
+ return { offset: 0, cursor: void 0 };
342
234
  }
343
- if (error instanceof ZapierRateLimitError) {
344
- const { limit, remaining, retryAfterMs } = error.rateLimit;
345
- const parts = [];
346
- if (limit !== void 0) {
347
- const used = remaining !== void 0 ? limit - remaining : limit;
348
- parts.push(`${used}/${limit} used`);
349
- }
350
- if (retryAfterMs !== void 0 && retryAfterMs > 0) {
351
- parts.push(`retry in ${formatDuration(retryAfterMs)}`);
235
+ try {
236
+ const decoded = decodeBase64(incoming);
237
+ const envelope = JSON.parse(decoded);
238
+ if (envelope.v !== CURSOR_VERSION) {
239
+ return { offset: 0, cursor: incoming };
352
240
  }
353
- if (error.retries > 0) {
354
- parts.push(
355
- `after ${error.retries} retr${error.retries === 1 ? "y" : "ies"}`
356
- );
241
+ if (envelope.source === CURSOR_SOURCE.SDK) {
242
+ return { offset: envelope.offset ?? 0, cursor: envelope.cursor };
357
243
  }
358
- if (parts.length > 0) {
359
- message += `
360
- ${parts.join(", ")}`;
244
+ if (envelope.source === CURSOR_SOURCE.API) {
245
+ return { offset: 0, cursor: envelope.cursor };
361
246
  }
247
+ return { offset: 0, cursor: incoming };
248
+ } catch {
249
+ return { offset: 0, cursor: incoming };
362
250
  }
363
- if (error.statusCode && !message.includes(`${error.statusCode}`)) {
364
- message += `
365
- HTTP Status: ${error.statusCode}`;
366
- }
367
- return message;
368
251
  }
369
- function formatDuration(ms) {
370
- const seconds = Math.round(ms / 1e3);
371
- if (seconds < 60) return `${seconds}s`;
372
- const minutes = Math.round(seconds / 60);
373
- if (minutes < 60) return `${minutes}m`;
374
- const hours = Math.round(minutes / 60);
375
- if (hours < 24) return `${hours}h`;
376
- const days = Math.round(hours / 24);
377
- return `${days}d`;
378
- }
379
-
380
- // src/types/signals.ts
381
- var ZapierSignal = class extends Error {
382
- constructor(message) {
383
- super(message);
384
- Object.setPrototypeOf(this, new.target.prototype);
385
- }
386
- };
387
- var ZapierReleaseTriggerMessageSignal = class extends ZapierSignal {
388
- constructor() {
389
- super(...arguments);
390
- this.name = "ZapierReleaseTriggerMessageSignal";
391
- this.code = "ZAPIER_RELEASE_TRIGGER_MESSAGE_SIGNAL";
392
- }
393
- };
394
- var ZapierAbortDrainSignal = class extends ZapierSignal {
395
- constructor() {
396
- super(...arguments);
397
- this.name = "ZapierAbortDrainSignal";
398
- this.code = "ZAPIER_ABORT_DRAIN_SIGNAL";
399
- }
400
- };
401
- var TriggerInboxCommandBaseSchema = z.object({
402
- inbox: TriggerInboxPropertySchema,
403
- onMessage: z.function().optional().meta({ exampleRequired: true }).describe(
404
- "Per-message handler. Resolves to ack; rejects to release-or-leave per `releaseOnError`. Throw `ZapierReleaseTriggerMessageSignal` to release explicitly, or `ZapierAbortDrainSignal` to stop after the current batch."
405
- ),
406
- concurrency: z.number().int().min(1).optional().describe(
407
- "Per-message handler workers running in parallel. Defaults to `leaseLimit`, or 1 if neither is set."
408
- ),
409
- leaseLimit: z.number().int().min(1).max(100).optional().describe(
410
- "Per-lease HTTP batch size. Defaults to `concurrency`, or 1 if neither is set."
411
- ),
412
- leaseSeconds: LeaseSecondsPropertySchema.optional(),
413
- releaseOnError: z.boolean().optional().describe(
414
- "If true, errors release the message when the drain finishes. If false (default), errors leave it leased until the lease timeout. `ZapierReleaseTriggerMessageSignal` always releases regardless."
415
- ),
416
- continueOnError: z.boolean().optional().describe(
417
- "If false (default, fail-fast), the first handler error rejects and stops the drain. If true, handler errors are observed via `onError` and the drain continues. SDK-level errors (lease / ack / release) reject regardless."
418
- ),
419
- onError: z.function().optional().describe(
420
- "Per-message error observer for `continueOnError: true`. Called with the failure and the message; control-flow signals are filtered out. Throws from `onError` are swallowed."
421
- ),
422
- signal: z.custom((v) => v instanceof AbortSignal).optional().describe(
423
- "Abort signal. Aborting cancels in-flight HTTP, releases unprocessed messages, and resolves cleanly. Errors during shutdown still reject."
424
- )
425
- });
426
- TriggerInboxCommandBaseSchema.extend({
427
- maxMessages: z.number().int().min(1).optional().describe(
428
- "Cap total messages drained. Defaults to draining the inbox until empty."
429
- )
430
- }).describe(
431
- "Drain an existing trigger inbox: lease currently-available messages and process them via onMessage. Returns when the inbox is empty, maxMessages is reached, the abort signal fires, or a fatal error rejects."
432
- );
433
- TriggerInboxCommandBaseSchema.extend({
434
- maxDrainIntervalSeconds: z.number().int().min(1).optional().describe(
435
- "Maximum seconds between empty-inbox poll attempts (default: 60). Caps the back-off cadence."
436
- )
437
- }).describe(
438
- "Continuously consume a trigger inbox: drain currently-available messages, then poll with backoff for new arrivals, until aborted. Stop via the `signal` AbortSignal or by throwing `ZapierAbortDrainSignal` from a handler. Resolves cleanly on abort; rejects on a fatal error or a fail-fast handler error."
439
- );
440
- var ActionExecutionInputSchema = z.object({
441
- inputs: z.record(z.string(), z.unknown()).optional(),
442
- /** @deprecated Use `connection` instead. */
443
- connectionId: ConnectionIdPropertySchema.optional().meta({
444
- deprecated: true
445
- }),
446
- connection: ConnectionPropertySchema.optional(),
447
- /** @deprecated Use connection instead */
448
- authenticationId: AuthenticationIdPropertySchema.optional().meta({
449
- deprecated: true
450
- }),
451
- timeoutMs: ActionTimeoutMsPropertySchema
452
- }).describe(
453
- "Execute an action with the given inputs for the bound app, as an alternative to runAction"
454
- ).meta({
455
- aliases: { connectionId: "connection", authenticationId: "connection" }
456
- });
457
- var AppFactoryInputSchema = z.object({
458
- /** @deprecated Use `connection` instead. */
459
- connectionId: ConnectionIdPropertySchema.optional().meta({
460
- deprecated: true
461
- }),
462
- connection: ConnectionPropertySchema.optional(),
463
- /** @deprecated Use connection instead */
464
- authenticationId: AuthenticationIdPropertySchema.optional().meta({
465
- deprecated: true
466
- })
467
- }).describe("Bind a connection alias or numeric connectionId to an app").meta({
468
- aliases: { connectionId: "connection", authenticationId: "connection" }
469
- });
470
-
471
- // src/utils/pagination-utils.ts
472
- var CURSOR_VERSION = 1;
473
- var CURSOR_SOURCE = {
474
- API: "api",
475
- SDK: "sdk"
476
- };
477
- function encodeBase64(str) {
478
- return btoa(
479
- Array.from(
480
- new TextEncoder().encode(str),
481
- (b) => String.fromCharCode(b)
482
- ).join("")
483
- );
484
- }
485
- function decodeBase64(str) {
486
- return new TextDecoder().decode(
487
- Uint8Array.from(atob(str), (c) => c.charCodeAt(0))
488
- );
489
- }
490
- function encodeApiCursor(cursor) {
491
- const envelope = {
492
- v: CURSOR_VERSION,
493
- source: CURSOR_SOURCE.API,
494
- cursor
495
- };
496
- return encodeBase64(JSON.stringify(envelope));
497
- }
498
- function encodeSdkCursor(offset, cursor) {
499
- const envelope = {
500
- v: CURSOR_VERSION,
501
- source: CURSOR_SOURCE.SDK,
502
- cursor,
503
- offset
504
- };
505
- return encodeBase64(JSON.stringify(envelope));
506
- }
507
- function decodeIncomingCursor(incoming) {
508
- if (!incoming) {
509
- return { offset: 0, cursor: void 0 };
510
- }
511
- try {
512
- const decoded = decodeBase64(incoming);
513
- const envelope = JSON.parse(decoded);
514
- if (envelope.v !== CURSOR_VERSION) {
515
- return { offset: 0, cursor: incoming };
516
- }
517
- if (envelope.source === CURSOR_SOURCE.SDK) {
518
- return { offset: envelope.offset ?? 0, cursor: envelope.cursor };
519
- }
520
- if (envelope.source === CURSOR_SOURCE.API) {
521
- return { offset: 0, cursor: envelope.cursor };
522
- }
523
- return { offset: 0, cursor: incoming };
524
- } catch {
525
- return { offset: 0, cursor: incoming };
526
- }
527
- }
528
- async function* paginateMaxItemsWithUnencodedCursor(pageFunction, pageOptions) {
529
- let cursor = pageOptions?.cursor;
530
- let totalItemsYielded = 0;
531
- const maxItems = pageOptions?.maxItems;
532
- const pageSize = pageOptions?.pageSize;
533
- do {
534
- const options = {
535
- ...pageOptions || {},
536
- cursor,
537
- pageSize: maxItems !== void 0 && pageSize !== void 0 ? Math.min(pageSize, maxItems) : pageSize
538
- };
539
- const page = await pageFunction(options);
540
- if (maxItems !== void 0) {
541
- const remainingItems = maxItems - totalItemsYielded;
542
- if (page.data.length >= remainingItems) {
543
- yield {
544
- ...page,
545
- data: page.data.slice(0, remainingItems),
546
- nextCursor: void 0
547
- };
548
- break;
549
- }
550
- }
551
- yield page;
552
- totalItemsYielded += page.data.length;
553
- cursor = page.nextCursor;
554
- } while (cursor);
252
+ async function* paginateMaxItemsWithUnencodedCursor(pageFunction, pageOptions) {
253
+ let cursor = pageOptions?.cursor;
254
+ let totalItemsYielded = 0;
255
+ const maxItems = pageOptions?.maxItems;
256
+ const pageSize = pageOptions?.pageSize;
257
+ do {
258
+ const options = {
259
+ ...pageOptions || {},
260
+ cursor,
261
+ pageSize: maxItems !== void 0 && pageSize !== void 0 ? Math.min(pageSize, maxItems) : pageSize
262
+ };
263
+ const page = await pageFunction(options);
264
+ if (maxItems !== void 0) {
265
+ const remainingItems = maxItems - totalItemsYielded;
266
+ if (page.data.length >= remainingItems) {
267
+ yield {
268
+ ...page,
269
+ data: page.data.slice(0, remainingItems),
270
+ nextCursor: void 0
271
+ };
272
+ break;
273
+ }
274
+ }
275
+ yield page;
276
+ totalItemsYielded += page.data.length;
277
+ cursor = page.nextCursor;
278
+ } while (cursor);
555
279
  }
556
280
  async function* paginateBuffered(pageFunction, pageOptions) {
557
281
  const pageSize = pageOptions?.pageSize;
@@ -721,438 +445,1025 @@ function concatPaginated({
721
445
  function toIterable(source) {
722
446
  return { [Symbol.asyncIterator]: () => source[Symbol.asyncIterator]() };
723
447
  }
724
-
725
- // src/utils/validation.ts
726
- var validate = (schema, input) => {
448
+ var parseOrThrow = (schema, input, { adaptError } = {}) => {
727
449
  const result = schema.safeParse(input);
728
450
  if (!result.success) {
729
- const errorMessages = result.error.issues.map((error) => {
730
- const path = error.path.length > 0 ? error.path.join(".") : "input";
731
- return `${path}: ${error.message}`;
451
+ const errorMessages = result.error.issues.map((issue) => {
452
+ const path = issue.path.length > 0 ? issue.path.join(".") : "input";
453
+ return `${path}: ${issue.message}`;
732
454
  });
733
- const message = `Validation failed:
734
- ${errorMessages.join("\n ")}`;
735
- throw new ZapierValidationError(message, {
736
- details: {
737
- zodErrors: result.error.issues,
738
- input
455
+ throw createCoreError(
456
+ {
457
+ code: CoreErrorCode.Validation,
458
+ message: `Validation failed:
459
+ ${errorMessages.join("\n ")}`,
460
+ details: {
461
+ zodErrors: result.error.issues,
462
+ input
463
+ }
464
+ },
465
+ adaptError
466
+ );
467
+ }
468
+ return result.data;
469
+ };
470
+ function createValidator(schema, { adaptError } = {}) {
471
+ return function validateFn(input) {
472
+ return parseOrThrow(schema, input, { adaptError });
473
+ };
474
+ }
475
+ var validateOptions = (schema, options, { adaptError } = {}) => parseOrThrow(schema, options, { adaptError });
476
+ var scopeStore = null;
477
+ try {
478
+ scopeStore = new AsyncLocalStorage();
479
+ } catch {
480
+ }
481
+ function getCurrentScope() {
482
+ if (!scopeStore) return void 0;
483
+ return scopeStore.getStore();
484
+ }
485
+ function getCurrentDepth() {
486
+ return getCurrentScope()?.depth ?? 0;
487
+ }
488
+ function runInMethodScope(fn) {
489
+ if (!scopeStore) return fn();
490
+ const currentDepth = scopeStore.getStore()?.depth ?? -1;
491
+ return scopeStore.run({ depth: currentDepth + 1 }, fn);
492
+ }
493
+ var runWithTelemetryContext = runInMethodScope;
494
+ function normalizeError(error, adaptError) {
495
+ if (error instanceof Error) return error;
496
+ const message = typeof error === "object" && error !== null && "message" in error && typeof error.message === "string" ? error.message : String(error);
497
+ return createCoreError(
498
+ {
499
+ code: CoreErrorCode.Unknown,
500
+ message,
501
+ cause: error
502
+ },
503
+ adaptError
504
+ );
505
+ }
506
+ function createFunction(coreFn, options) {
507
+ const { sdk, schema } = options;
508
+ const functionName = coreFn.name;
509
+ const namedFunctions = {
510
+ [functionName]: async function(callOptions) {
511
+ return runInMethodScope(async () => {
512
+ const startTime = Date.now();
513
+ const normalizedOptions = callOptions ?? {};
514
+ const args = [normalizedOptions];
515
+ const depth = getCurrentDepth();
516
+ const hooks = sdk.context.hooks;
517
+ const adaptError = sdk.context.core?.adaptError;
518
+ hooks?.onMethodStart?.({
519
+ methodName: functionName,
520
+ args,
521
+ isPaginated: false,
522
+ depth
523
+ });
524
+ try {
525
+ let result;
526
+ if (schema) {
527
+ const validatedOptions = validateOptions(
528
+ schema,
529
+ normalizedOptions,
530
+ {
531
+ adaptError
532
+ }
533
+ );
534
+ result = await coreFn({
535
+ ...normalizedOptions,
536
+ ...validatedOptions
537
+ });
538
+ } else {
539
+ result = await coreFn(normalizedOptions);
540
+ }
541
+ hooks?.onMethodEnd?.({
542
+ methodName: functionName,
543
+ args,
544
+ isPaginated: false,
545
+ depth,
546
+ durationMs: Date.now() - startTime
547
+ });
548
+ return result;
549
+ } catch (error) {
550
+ const normalizedError = normalizeError(error, adaptError);
551
+ hooks?.onMethodEnd?.({
552
+ methodName: functionName,
553
+ args,
554
+ isPaginated: false,
555
+ depth,
556
+ durationMs: Date.now() - startTime,
557
+ error: normalizedError
558
+ });
559
+ throw normalizedError;
560
+ }
561
+ });
562
+ }
563
+ };
564
+ return namedFunctions[functionName];
565
+ }
566
+ function isSdkPage(value) {
567
+ if (typeof value !== "object" || value === null) return false;
568
+ const page = value;
569
+ if (!Array.isArray(page.data)) return false;
570
+ if (page.nextCursor !== void 0 && typeof page.nextCursor !== "string") {
571
+ return false;
572
+ }
573
+ return Object.keys(page).every((k) => k === "data" || k === "nextCursor");
574
+ }
575
+ function createPageFunction(coreFn, {
576
+ sdk,
577
+ adaptPage
578
+ }) {
579
+ const functionName = coreFn.name + "Page";
580
+ const namedFunctions = {
581
+ [functionName]: async function(options) {
582
+ try {
583
+ const response = await coreFn(options);
584
+ const page = adaptPage ? adaptPage(response) : response;
585
+ if (!isSdkPage(page)) {
586
+ throw new Error(
587
+ `${functionName}: paginated result must be exactly { data: TItem[], nextCursor? } (produced by the handler or its \`adaptPage\`); got keys [${page && typeof page === "object" ? Object.keys(page).join(", ") : typeof page}]. If the handler returns a raw shape, set \`adaptPage\` to translate it; if \`adaptPage\` already runs, it must return only \`data\`/\`nextCursor\`.`
588
+ );
589
+ }
590
+ return page;
591
+ } catch (error) {
592
+ throw normalizeError(
593
+ error,
594
+ sdk.context.core?.adaptError
595
+ );
739
596
  }
740
- });
597
+ }
598
+ };
599
+ return namedFunctions[functionName];
600
+ }
601
+ function createPaginatedFunction(coreFn, options) {
602
+ const { sdk, schema, name, defaultPageSize, adaptPage } = options;
603
+ const pageFunction = createPageFunction(coreFn, { sdk, adaptPage });
604
+ const functionName = name || coreFn.name;
605
+ const namedFunctions = {
606
+ [functionName]: function(callOptions) {
607
+ return runInMethodScope(() => {
608
+ const startTime = Date.now();
609
+ const normalizedOptions = callOptions ?? {};
610
+ const args = [normalizedOptions];
611
+ const depth = getCurrentDepth();
612
+ const hooks = sdk.context.hooks;
613
+ const adaptError = sdk.context.core?.adaptError;
614
+ hooks?.onMethodStart?.({
615
+ methodName: functionName,
616
+ args,
617
+ isPaginated: true,
618
+ depth
619
+ });
620
+ const validatedOptions = {
621
+ ...normalizedOptions,
622
+ ...schema ? createValidator(schema, { adaptError })(normalizedOptions) : normalizedOptions
623
+ };
624
+ const pageSize = validatedOptions.pageSize ?? defaultPageSize;
625
+ const optimizedOptions = {
626
+ ...validatedOptions,
627
+ pageSize
628
+ };
629
+ const iterator = paginate(pageFunction, optimizedOptions);
630
+ const firstPagePromise = iterator.next().then((result) => {
631
+ if (result.done) {
632
+ throw new Error("Paginate should always iterate at least once");
633
+ }
634
+ return result.value;
635
+ });
636
+ if (hooks?.onMethodEnd) {
637
+ firstPagePromise.then(() => {
638
+ hooks.onMethodEnd({
639
+ methodName: functionName,
640
+ args,
641
+ isPaginated: true,
642
+ depth,
643
+ durationMs: Date.now() - startTime
644
+ });
645
+ }).catch((error) => {
646
+ hooks.onMethodEnd({
647
+ methodName: functionName,
648
+ args,
649
+ isPaginated: true,
650
+ depth,
651
+ durationMs: Date.now() - startTime,
652
+ error: error instanceof Error ? error : new Error(String(error))
653
+ });
654
+ });
655
+ }
656
+ return Object.assign(firstPagePromise, {
657
+ [Symbol.asyncIterator]: async function* () {
658
+ yield await firstPagePromise;
659
+ for await (const page of iterator) {
660
+ yield page;
661
+ }
662
+ },
663
+ items: function() {
664
+ return {
665
+ [Symbol.asyncIterator]: async function* () {
666
+ const firstPage = await firstPagePromise;
667
+ for (const item of firstPage.data) {
668
+ yield item;
669
+ }
670
+ for await (const page of iterator) {
671
+ for (const item of page.data) {
672
+ yield item;
673
+ }
674
+ }
675
+ }
676
+ };
677
+ }
678
+ });
679
+ });
680
+ }
681
+ };
682
+ return namedFunctions[functionName];
683
+ }
684
+ function definePlugin(fn) {
685
+ return fn;
686
+ }
687
+ function createPluginMethod(sdk, config) {
688
+ const { name, inputSchema, handler, ...metaFields } = config;
689
+ const namedHandlers = {
690
+ [name]: async function(options) {
691
+ return handler({ sdk, options });
692
+ }
693
+ };
694
+ const wrappedFn = createFunction(namedHandlers[name], {
695
+ sdk,
696
+ schema: inputSchema
697
+ });
698
+ return {
699
+ [name]: wrappedFn,
700
+ context: {
701
+ meta: {
702
+ [name]: {
703
+ ...metaFields,
704
+ ...inputSchema ? { inputSchema } : {}
705
+ }
706
+ }
707
+ }
708
+ };
709
+ }
710
+ function createPaginatedPluginMethod(sdk, config) {
711
+ const {
712
+ name,
713
+ inputSchema,
714
+ handler,
715
+ adaptPage,
716
+ defaultPageSize,
717
+ ...metaFields
718
+ } = config;
719
+ const namedHandlers = {
720
+ [name]: function(options) {
721
+ return handler({ sdk, options });
722
+ }
723
+ };
724
+ const wrappedFn = createPaginatedFunction(namedHandlers[name], {
725
+ sdk,
726
+ schema: inputSchema,
727
+ name,
728
+ defaultPageSize,
729
+ adaptPage
730
+ });
731
+ return {
732
+ [name]: wrappedFn,
733
+ context: {
734
+ meta: {
735
+ [name]: {
736
+ ...metaFields,
737
+ ...inputSchema ? { inputSchema } : {}
738
+ }
739
+ }
740
+ }
741
+ };
742
+ }
743
+ function splitPluginContribution(result) {
744
+ const { context, ...rootKeys } = result;
745
+ const { meta, hooks, ...contextRest } = context ?? {};
746
+ return {
747
+ rootKeys,
748
+ meta: meta ?? {},
749
+ hooks: hooks ?? {},
750
+ contextRest
751
+ };
752
+ }
753
+ var RESERVED_ROOT_KEYS = /* @__PURE__ */ new Set([
754
+ "context",
755
+ "getRegistry",
756
+ "addPlugin"
757
+ ]);
758
+ function hasOwn(obj, key) {
759
+ return Object.prototype.hasOwnProperty.call(obj, key);
760
+ }
761
+ function setOwn(target, key, value) {
762
+ Object.defineProperty(target, key, {
763
+ value,
764
+ enumerable: true,
765
+ configurable: true,
766
+ writable: true
767
+ });
768
+ }
769
+ function checkCollisions(target, source, kind, callerLabel, override) {
770
+ for (const key of Object.keys(source)) {
771
+ if (kind === "root key" && RESERVED_ROOT_KEYS.has(key)) {
772
+ throw new Error(
773
+ `${callerLabel}: plugin attempted to register reserved root key "${key}". The SDK uses this key for its own accessor; rename the plugin's method.`
774
+ );
775
+ }
776
+ if (!override && hasOwn(target, key)) {
777
+ throw new Error(
778
+ `${callerLabel}: duplicate ${kind} "${key}". If the override is intentional, pass { override: true } in the options.`
779
+ );
780
+ }
781
+ }
782
+ }
783
+ function applyOwnProperties(target, source) {
784
+ for (const key of Object.keys(source)) {
785
+ setOwn(target, key, source[key]);
786
+ }
787
+ }
788
+ function createPluginAccumulator(initialProperties = {}, initialContext = {}) {
789
+ const initialMeta = initialContext.meta ?? {};
790
+ const initialHooks = initialContext.hooks ?? {};
791
+ const context = {
792
+ ...initialContext,
793
+ meta: { ...initialMeta },
794
+ hooks: { ...initialHooks }
795
+ };
796
+ const view = { ...initialProperties, context };
797
+ return { view, context };
798
+ }
799
+ function mergeContribution(propertiesTarget, contextTarget, contribution, options) {
800
+ checkCollisions(
801
+ propertiesTarget,
802
+ contribution.rootKeys,
803
+ "root key",
804
+ options.callerLabel,
805
+ options.override
806
+ );
807
+ checkCollisions(
808
+ contextTarget.meta,
809
+ contribution.meta,
810
+ "context.meta key",
811
+ options.callerLabel,
812
+ options.override
813
+ );
814
+ checkCollisions(
815
+ contextTarget,
816
+ contribution.contextRest,
817
+ "context key",
818
+ options.callerLabel,
819
+ options.override
820
+ );
821
+ applyOwnProperties(propertiesTarget, contribution.rootKeys);
822
+ applyOwnProperties(contextTarget.meta, contribution.meta);
823
+ applyOwnProperties(contextTarget, contribution.contextRest);
824
+ contextTarget.hooks = buildHooks(contextTarget.hooks, contribution.hooks);
825
+ }
826
+ function applyPluginContribution(acc, contribution, options) {
827
+ mergeContribution(acc.view, acc.context, contribution, options);
828
+ }
829
+ function wrapAsSdk(properties, context, opts) {
830
+ const sdk = {
831
+ ...properties,
832
+ context,
833
+ getRegistry(qopts) {
834
+ return buildRegistry({
835
+ sdk,
836
+ meta: context.meta,
837
+ packageFilter: qopts?.package
838
+ });
839
+ }
840
+ };
841
+ if (opts?.addPlugin !== void 0) {
842
+ sdk.addPlugin = opts.addPlugin;
843
+ }
844
+ return sdk;
845
+ }
846
+ function wrapAccumulatorAsSdk(acc) {
847
+ const { context: _ctx, ...rootKeys } = acc.view;
848
+ return wrapAsSdk(
849
+ rootKeys,
850
+ acc.context
851
+ );
852
+ }
853
+ function applyPluginToSdk(sdk, plugin, options) {
854
+ const context = sdk.context;
855
+ const contribution = splitPluginContribution(
856
+ plugin(sdk)
857
+ );
858
+ mergeContribution(sdk, context, contribution, {
859
+ callerLabel: "addPlugin",
860
+ override: options.override === true
861
+ });
862
+ }
863
+ function buildStackAccumulator(head, callerLabel) {
864
+ const ordered = [];
865
+ let node = head;
866
+ while (node) {
867
+ ordered.unshift(node);
868
+ node = node.prev;
869
+ }
870
+ const acc = createPluginAccumulator();
871
+ for (const { plugin, override } of ordered) {
872
+ const contribution = splitPluginContribution(
873
+ plugin(acc.view)
874
+ );
875
+ applyPluginContribution(acc, contribution, { callerLabel, override });
876
+ }
877
+ return acc;
878
+ }
879
+ function addPlugin(sdk, plugin, options) {
880
+ applyPluginToSdk(
881
+ sdk,
882
+ plugin,
883
+ options ?? {}
884
+ );
885
+ }
886
+ function buildSdk(properties, context) {
887
+ const addPlugin2 = (plugin, options) => {
888
+ logDeprecation(
889
+ "sdk.addPlugin(plugin) (the chain-style extension) is deprecated. Build the SDK in one pass with createPluginStack().use(...).toSdk() instead \u2014 each .toSdk() produces fresh plugin closures and avoids the closure-sharing semantics that caused this to be deprecated."
890
+ );
891
+ const contribution = splitPluginContribution(
892
+ plugin({ ...properties, context })
893
+ );
894
+ const mergedProperties = { ...properties };
895
+ const mergedContext = {
896
+ ...context,
897
+ meta: { ...context.meta },
898
+ hooks: { ...context.hooks }
899
+ };
900
+ mergeContribution(mergedProperties, mergedContext, contribution, {
901
+ callerLabel: "addPlugin",
902
+ override: options?.override === true
903
+ });
904
+ return buildSdk(
905
+ mergedProperties,
906
+ mergedContext
907
+ );
908
+ };
909
+ return wrapAsSdk(properties, context, { addPlugin: addPlugin2 });
910
+ }
911
+ function withDeprecatedAddPlugin(sdk) {
912
+ const initialProperties = {};
913
+ for (const key of Object.keys(sdk)) {
914
+ if (key === "context" || key === "getRegistry" || key === "addPlugin") {
915
+ continue;
916
+ }
917
+ initialProperties[key] = sdk[key];
918
+ }
919
+ const initialContext = sdk.context;
920
+ return buildSdk(
921
+ initialProperties,
922
+ initialContext
923
+ );
924
+ }
925
+ function composePlugins(...plugins) {
926
+ logDeprecation(
927
+ "composePlugins(...) is deprecated. Use createPluginStack().use(a).use(b).use(c).toPlugin() instead. The stack carries the same collision-detection and hook-composition behavior, supports per-step { override: true } for intentional duplicates, and progressively narrows types so dependency mistakes surface at the specific .use call."
928
+ );
929
+ let stack = buildPluginStack(
930
+ null,
931
+ "composePlugins"
932
+ );
933
+ for (const plugin of plugins) {
934
+ stack = stack.use(plugin);
935
+ }
936
+ return stack.toPlugin();
937
+ }
938
+ function createPluginStack() {
939
+ return buildPluginStack(null, "createPluginStack");
940
+ }
941
+ function buildPluginStack(head, callerLabel) {
942
+ return {
943
+ use(plugin, options) {
944
+ const next = {
945
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
946
+ plugin,
947
+ override: options?.override === true,
948
+ prev: head
949
+ };
950
+ return buildPluginStack(next, callerLabel);
951
+ },
952
+ toPlugin() {
953
+ const ordered = [];
954
+ let node = head;
955
+ while (node) {
956
+ ordered.unshift(node);
957
+ node = node.prev;
958
+ }
959
+ return (outerSdk) => {
960
+ const { context: outerContext, ...outerProperties } = outerSdk ?? {};
961
+ const viewAcc = createPluginAccumulator(outerProperties, outerContext);
962
+ const contribsAcc = createPluginAccumulator();
963
+ for (const { plugin: subPlugin, override } of ordered) {
964
+ const contribution = splitPluginContribution(
965
+ subPlugin(viewAcc.view)
966
+ );
967
+ applyPluginContribution(viewAcc, contribution, {
968
+ callerLabel,
969
+ override
970
+ });
971
+ applyPluginContribution(contribsAcc, contribution, {
972
+ callerLabel,
973
+ override
974
+ });
975
+ }
976
+ const { context: _ignored, ...contributedRoot } = contribsAcc.view;
977
+ return {
978
+ ...contributedRoot,
979
+ context: contribsAcc.context
980
+ };
981
+ };
982
+ },
983
+ toSdk() {
984
+ return wrapAccumulatorAsSdk(
985
+ buildStackAccumulator(head, callerLabel)
986
+ );
987
+ }
988
+ };
989
+ }
990
+ function createCorePlugin(options) {
991
+ return () => ({
992
+ context: {
993
+ core: options
994
+ }
995
+ });
996
+ }
997
+ function withPositional(schema) {
998
+ Object.assign(schema._zod.def, {
999
+ positionalMeta: { positional: true }
1000
+ });
1001
+ return schema;
1002
+ }
1003
+ function schemaHasPositionalMeta(schema) {
1004
+ return "positionalMeta" in schema._zod.def;
1005
+ }
1006
+ function isPositional(schema) {
1007
+ if (schemaHasPositionalMeta(schema) && schema._zod.def.positionalMeta?.positional) {
1008
+ return true;
1009
+ }
1010
+ if (schema instanceof z.ZodOptional) {
1011
+ return isPositional(schema._zod.def.innerType);
1012
+ }
1013
+ if (schema instanceof z.ZodDefault) {
1014
+ return isPositional(schema._zod.def.innerType);
1015
+ }
1016
+ return false;
1017
+ }
1018
+
1019
+ // src/constants.ts
1020
+ var ZAPIER_BASE_URL = globalThis.process?.env?.ZAPIER_BASE_URL || "https://zapier.com";
1021
+ function getZapierSdkService() {
1022
+ return globalThis.process?.env?.ZAPIER_SDK_SERVICE;
1023
+ }
1024
+ var MAX_PAGE_LIMIT = 1e4;
1025
+ var DEFAULT_PAGE_SIZE = 100;
1026
+ var DEFAULT_ACTION_TIMEOUT_MS = 18e4;
1027
+ function parseIntEnvVar(name) {
1028
+ const value = globalThis.process?.env?.[name];
1029
+ if (value === void 0) return void 0;
1030
+ const parsed = parseInt(value, 10);
1031
+ if (isNaN(parsed)) {
1032
+ console.warn(
1033
+ `[zapier-sdk] Invalid value for ${name}: "${value}" (expected integer)`
1034
+ );
1035
+ return void 0;
1036
+ }
1037
+ return parsed;
1038
+ }
1039
+ var ZAPIER_MAX_NETWORK_RETRIES = parseIntEnvVar("ZAPIER_MAX_NETWORK_RETRIES") ?? 3;
1040
+ var ZAPIER_MAX_NETWORK_RETRY_DELAY_MS = parseIntEnvVar("ZAPIER_MAX_NETWORK_RETRY_DELAY_MS") ?? 6e4;
1041
+ var MAX_CONCURRENCY_LIMIT = 1e4;
1042
+ function parseConcurrencyEnvVar(name) {
1043
+ const value = globalThis.process?.env?.[name];
1044
+ if (!value) return void 0;
1045
+ if (value === "Infinity") return Infinity;
1046
+ if (/^[1-9]\d*$/.test(value)) {
1047
+ const parsed = parseInt(value, 10);
1048
+ if (parsed <= MAX_CONCURRENCY_LIMIT) return parsed;
1049
+ }
1050
+ console.warn(
1051
+ `[zapier-sdk] Invalid value for ${name}: "${value}" (expected positive integer 1-${MAX_CONCURRENCY_LIMIT} or "Infinity")`
1052
+ );
1053
+ return void 0;
1054
+ }
1055
+ var ZAPIER_MAX_CONCURRENT_REQUESTS = parseConcurrencyEnvVar("ZAPIER_MAX_CONCURRENT_REQUESTS") ?? 200;
1056
+ function getZapierApprovalMode() {
1057
+ const value = globalThis.process?.env?.ZAPIER_APPROVAL_MODE;
1058
+ if (value === "disabled" || value === "poll" || value === "throw")
1059
+ return value;
1060
+ return void 0;
1061
+ }
1062
+ function getZapierDefaultApprovalMode() {
1063
+ const isInteractive = !!globalThis.process?.stdin?.isTTY && !!globalThis.process?.stdout?.isTTY;
1064
+ return isInteractive ? "poll" : "throw";
1065
+ }
1066
+ var DEFAULT_APPROVAL_TIMEOUT_MS = 10 * 60 * 1e3;
1067
+ var DEFAULT_MAX_APPROVAL_RETRIES = 2;
1068
+
1069
+ // src/types/properties.ts
1070
+ var AppKeyPropertySchema = withPositional(
1071
+ z.string().min(1).describe("App key (e.g., 'SlackCLIAPI' or slug like 'github')")
1072
+ );
1073
+ var AppPropertySchema = withPositional(
1074
+ z.string().min(1).describe(
1075
+ "App slug (e.g., 'github'), implementation name (e.g., 'SlackCLIAPI'), or versioned ID (e.g., 'github@1.2.3')"
1076
+ )
1077
+ );
1078
+ var ActionTypePropertySchema = z.enum([
1079
+ "read",
1080
+ "read_bulk",
1081
+ "write",
1082
+ "run",
1083
+ "search",
1084
+ "search_or_write",
1085
+ "search_and_write",
1086
+ "filter"
1087
+ ]).describe("Action type that matches the action's defined type");
1088
+ var ActionKeyPropertySchema = z.string().min(1).describe("Action key to execute");
1089
+ var ActionPropertySchema = withPositional(
1090
+ z.string().min(1).describe("Action key (e.g., 'send_message' or 'find_row')")
1091
+ );
1092
+ var InputFieldPropertySchema = withPositional(
1093
+ z.string().min(1).describe("Input field key to get choices for")
1094
+ );
1095
+ var ConnectionIdPropertySchema = z.union([z.string(), z.number().int().positive()]).describe("Connection ID to use for this action");
1096
+ var AuthenticationIdPropertySchema = ConnectionIdPropertySchema.meta({
1097
+ deprecated: true
1098
+ });
1099
+ var ConnectionPropertySchema = z.union([z.string(), z.number().int().positive()]).describe(
1100
+ "Connection alias or connection ID (UUID or positive integer). Strings that match a key in the connections map are resolved against it; otherwise the value is used as a connection ID directly."
1101
+ );
1102
+ var InputsPropertySchema = z.record(z.string(), z.unknown()).describe("Input parameters for the action");
1103
+ var LimitPropertySchema = z.number().int().min(1).max(MAX_PAGE_LIMIT).default(50).describe("Maximum number of items to return");
1104
+ var OffsetPropertySchema = z.number().int().min(0).default(0).describe("Number of items to skip for pagination");
1105
+ var OutputPropertySchema = z.string().describe("Output file path");
1106
+ var DebugPropertySchema = z.boolean().default(false).describe("Enable debug logging");
1107
+ var ParamsPropertySchema = z.record(z.string(), z.unknown()).describe("Additional parameters");
1108
+ var ActionTimeoutMsPropertySchema = z.number().min(1e3).optional().describe(
1109
+ `Maximum time to wait for action completion in milliseconds (default: ${DEFAULT_ACTION_TIMEOUT_MS})`
1110
+ );
1111
+ var TablePropertySchema = withPositional(
1112
+ z.string().regex(/^[A-Z0-9]{26}$/, "Table ID must be a valid ULID").describe("The unique identifier of the table")
1113
+ );
1114
+ var RecordPropertySchema = withPositional(
1115
+ z.string().regex(/^[A-Z0-9]{26}$/, "Record ID must be a valid ULID").describe("The unique identifier of the record")
1116
+ );
1117
+ var RecordsPropertySchema = z.array(z.string().regex(/^[A-Z0-9]{26}$/, "Record ID must be a valid ULID")).min(1).max(100).describe("Record IDs to operate on");
1118
+ var FieldsPropertySchema = z.array(z.union([z.string(), z.number()])).describe(
1119
+ 'Fields to operate on. Accepts field names (e.g., "Email") or IDs (e.g., "f6", "6", or 6).'
1120
+ );
1121
+ var AppsPropertySchema = z.array(z.string()).describe("Filter by app keys (e.g., 'SlackCLIAPI' or slug like 'github')");
1122
+ var TablesPropertySchema = z.array(z.string()).describe("Filter by specific table IDs");
1123
+ var ConnectionsPropertySchema = z.array(z.string()).describe("List of connection IDs to filter by");
1124
+ var TriggerInboxPropertySchema = withPositional(
1125
+ z.string().min(1).describe(
1126
+ "Trigger inbox identifier \u2014 UUID or name. Non-UUID values are resolved by name via the inbox list endpoint."
1127
+ )
1128
+ );
1129
+ var TriggerInboxNamePropertySchema = z.string().min(1).max(100).describe(
1130
+ "Inbox name; unique per (user, account). Enables get-or-create on createTriggerInbox."
1131
+ );
1132
+ var LeasePropertySchema = z.string().min(1).describe("Lease ID returned from leaseTriggerInboxMessages");
1133
+ var LeaseSecondsPropertySchema = z.number().int().min(1).max(3600).describe(
1134
+ "Seconds until the lease expires; messages return to available if not acked. API default is 300 (5 minutes)."
1135
+ );
1136
+ var LeaseLimitPropertySchema = z.number().int().min(1).max(100).describe("Maximum messages to lease in a single batch (1-100)");
1137
+
1138
+ // src/types/errors.ts
1139
+ var _a, _b;
1140
+ var ZapierError = class extends (_b = Error, _a = CORE_ERROR_SYMBOL, _b) {
1141
+ constructor(message, options = {}) {
1142
+ super(message);
1143
+ this[_a] = true;
1144
+ this.name = "ZapierError";
1145
+ this.code = "ZAPIER_ERROR";
1146
+ if (options.statusCode !== void 0) this.statusCode = options.statusCode;
1147
+ if (options.errors !== void 0) this.errors = options.errors;
1148
+ if (options.cause !== void 0) this.cause = options.cause;
1149
+ if (options.response !== void 0) this.response = options.response;
1150
+ Object.setPrototypeOf(this, new.target.prototype);
1151
+ }
1152
+ };
1153
+ var ZapierValidationError = class extends ZapierError {
1154
+ constructor(message, options = {}) {
1155
+ super(message, options);
1156
+ this.name = "ZapierValidationError";
1157
+ this.code = "ZAPIER_VALIDATION_ERROR";
1158
+ this.details = options.details;
1159
+ }
1160
+ };
1161
+ var ZapierUnknownError = class extends ZapierError {
1162
+ constructor() {
1163
+ super(...arguments);
1164
+ this.name = "ZapierUnknownError";
1165
+ this.code = "ZAPIER_UNKNOWN_ERROR";
1166
+ }
1167
+ };
1168
+ var ZapierAuthenticationError = class extends ZapierError {
1169
+ constructor() {
1170
+ super(...arguments);
1171
+ this.name = "ZapierAuthenticationError";
1172
+ this.code = "ZAPIER_AUTHENTICATION_ERROR";
1173
+ }
1174
+ };
1175
+ var zapierAdaptError = (options) => {
1176
+ switch (options.code) {
1177
+ case CoreErrorCode.Validation:
1178
+ return new ZapierValidationError(options.message, {
1179
+ cause: options.cause,
1180
+ details: options.details
1181
+ });
1182
+ case CoreErrorCode.Unknown:
1183
+ return new ZapierUnknownError(options.message, {
1184
+ cause: options.cause
1185
+ });
1186
+ default:
1187
+ return new ZapierError(options.message, { cause: options.cause });
1188
+ }
1189
+ };
1190
+ var ZapierApiError = class extends ZapierError {
1191
+ constructor(message, options = {}) {
1192
+ super(message, options);
1193
+ this.name = "ZapierApiError";
1194
+ this.code = "ZAPIER_API_ERROR";
1195
+ }
1196
+ };
1197
+ var ZapierAppNotFoundError = class extends ZapierError {
1198
+ constructor(message, options = {}) {
1199
+ super(message, options);
1200
+ this.name = "ZapierAppNotFoundError";
1201
+ this.code = "ZAPIER_APP_NOT_FOUND_ERROR";
1202
+ this.appKey = options.appKey;
1203
+ }
1204
+ };
1205
+ var ZapierNotFoundError = class extends ZapierError {
1206
+ constructor(message, options = {}) {
1207
+ super(message, options);
1208
+ this.name = "ZapierNotFoundError";
1209
+ this.code = "ZAPIER_NOT_FOUND_ERROR";
1210
+ }
1211
+ };
1212
+ var ZapierResourceNotFoundError = class extends ZapierNotFoundError {
1213
+ constructor(message, options = {}) {
1214
+ super(message, options);
1215
+ this.name = "ZapierResourceNotFoundError";
1216
+ this.code = "ZAPIER_RESOURCE_NOT_FOUND_ERROR";
1217
+ this.resourceType = options.resourceType;
1218
+ this.resourceId = options.resourceId;
1219
+ }
1220
+ };
1221
+ var ZapierConfigurationError = class extends ZapierError {
1222
+ constructor(message, options = {}) {
1223
+ super(message, options);
1224
+ this.name = "ZapierConfigurationError";
1225
+ this.code = "ZAPIER_CONFIGURATION_ERROR";
1226
+ this.configType = options.configType;
1227
+ }
1228
+ };
1229
+ var ZapierBundleError = class extends ZapierError {
1230
+ constructor(message, options = {}) {
1231
+ super(message, options);
1232
+ this.name = "ZapierBundleError";
1233
+ this.code = "ZAPIER_BUNDLE_ERROR";
1234
+ this.buildErrors = options.buildErrors;
1235
+ }
1236
+ };
1237
+ var ZapierTimeoutError = class extends ZapierError {
1238
+ constructor(message, options = {}) {
1239
+ super(message, options);
1240
+ this.name = "ZapierTimeoutError";
1241
+ this.code = "ZAPIER_TIMEOUT_ERROR";
1242
+ this.attempts = options.attempts;
1243
+ this.maxAttempts = options.maxAttempts;
1244
+ }
1245
+ };
1246
+ var ZapierActionError = class extends ZapierError {
1247
+ constructor(message, options = {}) {
1248
+ super(message, options);
1249
+ this.name = "ZapierActionError";
1250
+ this.code = "ZAPIER_ACTION_ERROR";
1251
+ this.appKey = options.appKey;
1252
+ this.actionKey = options.actionKey;
1253
+ }
1254
+ // Legacy accessor for backward compatibility
1255
+ get actionErrors() {
1256
+ return this.errors;
1257
+ }
1258
+ };
1259
+ var ZapierConflictError = class extends ZapierError {
1260
+ constructor(message, options = {}) {
1261
+ super(message, options);
1262
+ this.name = "ZapierConflictError";
1263
+ this.code = "ZAPIER_CONFLICT_ERROR";
1264
+ this.resourceType = options.resourceType;
1265
+ }
1266
+ };
1267
+ var ZapierRateLimitError = class extends ZapierError {
1268
+ constructor(message, options = {}) {
1269
+ super(message, options);
1270
+ this.name = "ZapierRateLimitError";
1271
+ this.code = "ZAPIER_RATE_LIMIT_ERROR";
1272
+ this.rateLimit = options.rateLimit ?? {};
1273
+ this.retries = options.retries ?? 0;
1274
+ }
1275
+ };
1276
+ var ZapierApprovalError = class extends ZapierError {
1277
+ constructor(message, options = {}) {
1278
+ super(message, options);
1279
+ this.name = "ZapierApprovalError";
1280
+ this.code = "ZAPIER_APPROVAL_ERROR";
1281
+ this.approvalId = options.approvalId;
1282
+ this.approvalStatus = options.status;
1283
+ this.approvalUrl = options.approvalUrl;
1284
+ this.pollUrl = options.pollUrl;
741
1285
  }
742
- return result.data;
743
1286
  };
744
- function createValidator(schema) {
745
- return function validateFn(input) {
746
- return validate(schema, input);
747
- };
748
- }
749
- var validateOptions = (schema, options) => {
750
- return validate(schema, options);
1287
+ var ZapierRelayError = class extends ZapierError {
1288
+ constructor(message, options = {}) {
1289
+ super(message, options);
1290
+ this.name = "ZapierRelayError";
1291
+ this.code = "ZAPIER_RELAY_ERROR";
1292
+ }
751
1293
  };
752
- var telemetryStore = null;
753
- try {
754
- telemetryStore = new AsyncLocalStorage();
755
- } catch {
756
- }
757
- function isTelemetryNested() {
758
- if (!telemetryStore) return true;
759
- const store = telemetryStore.getStore();
760
- return store !== void 0 && store.depth > 0;
761
- }
762
- function runWithTelemetryContext(fn) {
763
- if (!telemetryStore) return fn();
764
- const currentDepth = telemetryStore.getStore()?.depth ?? -1;
765
- return telemetryStore.run({ depth: currentDepth + 1 }, fn);
766
- }
767
- function setMethodMetadata(metadata) {
768
- if (!telemetryStore) return;
769
- const store = telemetryStore.getStore();
770
- if (!store) return;
771
- store.methodMetadata = { ...store.methodMetadata, ...metadata };
772
- }
773
- function getMethodMetadata() {
774
- if (!telemetryStore) return void 0;
775
- return telemetryStore.getStore()?.methodMetadata;
776
- }
777
-
778
- // src/utils/function-utils.ts
779
- function extractCursor(data) {
780
- if (!data?.next) {
781
- return void 0;
1294
+ function formatErrorMessage(error) {
1295
+ let message = error.message;
1296
+ if (error.errors && error.errors.length > 0) {
1297
+ const additionalErrors = error.errors.slice(1);
1298
+ if (additionalErrors.length > 0) {
1299
+ const errorDetails = additionalErrors.map((err) => ` \u2022 ${err.detail || err.title || err.code}`).join("\n");
1300
+ message += "\n\nAdditional errors:\n" + errorDetails;
1301
+ }
782
1302
  }
783
- try {
784
- const urlObj = new URL(data.next);
785
- const offset = urlObj.searchParams.get("offset");
786
- return offset || void 0;
787
- } catch {
788
- return void 0;
1303
+ if (error instanceof ZapierAppNotFoundError && error.appKey) {
1304
+ message += `
1305
+ App key: ${error.appKey}`;
789
1306
  }
790
- }
791
- function normalizeError(error) {
792
- if (error instanceof ZapierError) {
793
- return error;
1307
+ if (error instanceof ZapierActionError && (error.appKey || error.actionKey)) {
1308
+ const context = [];
1309
+ if (error.appKey) context.push(`App: ${error.appKey}`);
1310
+ if (error.actionKey) context.push(`Action: ${error.actionKey}`);
1311
+ message += `
1312
+ ${context.join(", ")}`;
794
1313
  }
795
- const message = error instanceof Error ? error.message : String(error);
796
- const cause = error instanceof Error ? error : void 0;
797
- if (error instanceof Error) {
798
- if (error.name === "ZapierAuthenticationError") {
799
- return new ZapierAuthenticationError(message, { cause });
800
- }
1314
+ if (error instanceof ZapierResourceNotFoundError && (error.resourceType || error.resourceId)) {
1315
+ const context = [];
1316
+ if (error.resourceType) context.push(`Type: ${error.resourceType}`);
1317
+ if (error.resourceId) context.push(`ID: ${error.resourceId}`);
1318
+ message += `
1319
+ ${context.join(", ")}`;
801
1320
  }
802
- return new ZapierUnknownError(message, { cause });
803
- }
804
- function createFunction(coreFn, schema, telemetry) {
805
- const functionName = coreFn.name;
806
- const namedFunctions = {
807
- [functionName]: async function(options) {
808
- return runWithTelemetryContext(async () => {
809
- const startTime = Date.now();
810
- const normalizedOptions = options ?? {};
811
- const isNested = isTelemetryNested();
812
- try {
813
- if (schema) {
814
- const validatedOptions = validateOptions(schema, normalizedOptions);
815
- const result2 = await coreFn({
816
- ...normalizedOptions,
817
- ...validatedOptions
818
- });
819
- if (!isNested && telemetry?.onMethodCalled) {
820
- const argumentCount = Object.keys(
821
- normalizedOptions
822
- ).length;
823
- telemetry.onMethodCalled({
824
- methodName: functionName,
825
- durationMs: Date.now() - startTime,
826
- success: true,
827
- argumentCount,
828
- isPaginated: false
829
- });
830
- }
831
- return result2;
832
- }
833
- const result = await coreFn(normalizedOptions);
834
- if (!isNested && telemetry?.onMethodCalled) {
835
- const argumentCount = Object.keys(
836
- normalizedOptions
837
- ).length;
838
- telemetry.onMethodCalled({
839
- methodName: functionName,
840
- durationMs: Date.now() - startTime,
841
- success: true,
842
- argumentCount,
843
- isPaginated: false
844
- });
845
- }
846
- return result;
847
- } catch (error) {
848
- const normalizedError = normalizeError(error);
849
- if (!isNested && telemetry?.onMethodCalled) {
850
- const argumentCount = Object.keys(
851
- normalizedOptions
852
- ).length;
853
- telemetry.onMethodCalled({
854
- methodName: functionName,
855
- durationMs: Date.now() - startTime,
856
- success: false,
857
- error: normalizedError,
858
- argumentCount,
859
- isPaginated: false
860
- });
861
- }
862
- throw normalizedError;
863
- }
864
- });
865
- }
866
- };
867
- return namedFunctions[functionName];
868
- }
869
- function createPageFunction(coreFn) {
870
- const functionName = coreFn.name + "Page";
871
- const namedFunctions = {
872
- [functionName]: async function(options) {
873
- try {
874
- const result = await coreFn(options);
875
- if (result && typeof result === "object" && "data" in result) {
876
- const paginatedResult = result;
877
- let nextCursor;
878
- if (paginatedResult.nextCursor) {
879
- nextCursor = paginatedResult.nextCursor;
880
- } else if (paginatedResult.links?.next) {
881
- nextCursor = extractCursor({ next: paginatedResult.links.next });
882
- }
883
- return {
884
- data: Array.isArray(paginatedResult.data) ? paginatedResult.data : [paginatedResult.data],
885
- nextCursor
886
- };
887
- }
888
- if (Array.isArray(result)) {
889
- return { data: result };
890
- }
891
- return { data: [result] };
892
- } catch (error) {
893
- throw normalizeError(error);
894
- }
895
- }
896
- };
897
- return namedFunctions[functionName];
898
- }
899
- function createPaginatedFunction(coreFn, schema, telemetry, explicitFunctionName, defaultPageSize) {
900
- const pageFunction = createPageFunction(coreFn);
901
- const functionName = explicitFunctionName || coreFn.name;
902
- const validator = schema ? createValidator(schema) : null;
903
- const namedFunctions = {
904
- [functionName]: function(options) {
905
- return runWithTelemetryContext(() => {
906
- const startTime = Date.now();
907
- const normalizedOptions = options ?? {};
908
- const isNested = isTelemetryNested();
909
- const validatedOptions = {
910
- ...normalizedOptions,
911
- ...validator ? validator(normalizedOptions) : normalizedOptions
912
- };
913
- const pageSize = validatedOptions.pageSize ?? defaultPageSize;
914
- const optimizedOptions = {
915
- ...validatedOptions,
916
- pageSize
917
- };
918
- const iterator = paginate(pageFunction, optimizedOptions);
919
- const firstPagePromise = iterator.next().then((result) => {
920
- if (result.done) {
921
- throw new Error("Paginate should always iterate at least once");
922
- }
923
- return result.value;
924
- });
925
- if (!isNested && telemetry?.onMethodCalled) {
926
- firstPagePromise.then(() => {
927
- const argumentCount = Object.keys(
928
- normalizedOptions
929
- ).length;
930
- telemetry.onMethodCalled({
931
- methodName: functionName,
932
- durationMs: Date.now() - startTime,
933
- success: true,
934
- argumentCount,
935
- isPaginated: true
936
- });
937
- }).catch((error) => {
938
- const argumentCount = Object.keys(
939
- normalizedOptions
940
- ).length;
941
- telemetry.onMethodCalled({
942
- methodName: functionName,
943
- durationMs: Date.now() - startTime,
944
- success: false,
945
- error: error instanceof Error ? error : new Error(String(error)),
946
- argumentCount,
947
- isPaginated: true
948
- });
949
- });
950
- }
951
- return Object.assign(firstPagePromise, {
952
- [Symbol.asyncIterator]: async function* () {
953
- yield await firstPagePromise;
954
- for await (const page of iterator) {
955
- yield page;
956
- }
957
- },
958
- items: function() {
959
- return {
960
- [Symbol.asyncIterator]: async function* () {
961
- const firstPage = await firstPagePromise;
962
- for (const item of firstPage.data) {
963
- yield item;
964
- }
965
- for await (const page of iterator) {
966
- for (const item of page.data) {
967
- yield item;
968
- }
969
- }
970
- }
971
- };
972
- }
973
- });
974
- });
975
- }
976
- };
977
- return namedFunctions[functionName];
978
- }
979
-
980
- // src/utils/telemetry-utils.ts
981
- function createTelemetryCallback(emitMethodCalled, methodName) {
982
- return {
983
- onMethodCalled: (data) => {
984
- const metadata = getMethodMetadata();
985
- emitMethodCalled({
986
- method_name: methodName,
987
- execution_duration_ms: data.durationMs,
988
- success_flag: data.success,
989
- error_message: data.error?.message ?? null,
990
- error_type: data.error?.constructor.name ?? null,
991
- argument_count: data.argumentCount,
992
- is_paginated: data.isPaginated,
993
- selected_api: metadata?.selectedApi ?? null,
994
- operation_type: metadata?.operationType ?? null,
995
- operation_key: metadata?.operationKey ?? null
996
- });
997
- }
998
- };
999
- }
1000
-
1001
- // src/utils/plugin-utils.ts
1002
- function definePlugin(fn) {
1003
- return fn;
1004
- }
1005
- function maybeTelemetry(sdk, name) {
1006
- const ctx = sdk.context;
1007
- if (!ctx.eventEmission) return void 0;
1008
- return createTelemetryCallback(ctx.eventEmission.emitMethodCalled, name);
1009
- }
1010
- function createPluginMethod(sdk, config) {
1011
- const { name, inputSchema, handler, ...metaFields } = config;
1012
- const namedHandlers = {
1013
- [name]: async function(options) {
1014
- return handler({ sdk, options });
1015
- }
1016
- };
1017
- const wrappedFn = createFunction(
1018
- namedHandlers[name],
1019
- inputSchema,
1020
- maybeTelemetry(sdk, name)
1021
- );
1022
- return {
1023
- [name]: wrappedFn,
1024
- context: {
1025
- meta: {
1026
- [name]: {
1027
- ...metaFields,
1028
- ...inputSchema ? { inputSchema } : {}
1029
- }
1030
- }
1031
- }
1032
- };
1033
- }
1034
- function createPaginatedPluginMethod(sdk, config) {
1035
- const {
1036
- name,
1037
- inputSchema,
1038
- handler,
1039
- extractCursor: extractCursorFn,
1040
- defaultPageSize,
1041
- ...metaFields
1042
- } = config;
1043
- const namedPageHandlers = {
1044
- [name]: async function(options) {
1045
- const response = await handler({ sdk, options });
1046
- if (extractCursorFn) {
1047
- const extracted = extractCursorFn(response);
1048
- if (extracted !== void 0) {
1049
- return { data: response.data, nextCursor: extracted };
1050
- }
1051
- }
1052
- return response;
1053
- }
1054
- };
1055
- const wrappedFn = createPaginatedFunction(
1056
- namedPageHandlers[name],
1057
- inputSchema,
1058
- maybeTelemetry(sdk, name),
1059
- name,
1060
- defaultPageSize
1061
- );
1062
- return {
1063
- [name]: wrappedFn,
1064
- context: {
1065
- meta: {
1066
- [name]: {
1067
- ...metaFields,
1068
- ...inputSchema ? { inputSchema } : {}
1069
- }
1070
- }
1321
+ if (error instanceof ZapierConflictError && error.resourceType) {
1322
+ message += `
1323
+ Type: ${error.resourceType}`;
1324
+ }
1325
+ if (error instanceof ZapierTimeoutError && (error.attempts || error.maxAttempts)) {
1326
+ const context = [];
1327
+ if (error.attempts) context.push(`Attempts: ${error.attempts}`);
1328
+ if (error.maxAttempts) context.push(`Max attempts: ${error.maxAttempts}`);
1329
+ message += `
1330
+ ${context.join(", ")}`;
1331
+ }
1332
+ if (error instanceof ZapierBundleError && error.buildErrors && error.buildErrors.length > 0) {
1333
+ message += "\n\nBuild errors:\n" + error.buildErrors.map((err) => ` \u2022 ${err}`).join("\n");
1334
+ }
1335
+ if (error instanceof ZapierApprovalError && error.approvalUrl) {
1336
+ message += `
1337
+ Approval URL: ${error.approvalUrl}`;
1338
+ }
1339
+ if (error instanceof ZapierRateLimitError) {
1340
+ const { limit, remaining, retryAfterMs } = error.rateLimit;
1341
+ const parts = [];
1342
+ if (limit !== void 0) {
1343
+ const used = remaining !== void 0 ? limit - remaining : limit;
1344
+ parts.push(`${used}/${limit} used`);
1071
1345
  }
1072
- };
1073
- }
1074
- function mergeRootKeysWithCollisionCheck(target, source, seen) {
1075
- for (const key of Object.keys(source)) {
1076
- if (seen.has(key)) {
1077
- throw new Error(
1078
- `composePlugins: duplicate root key "${key}". Plugins composed in the same call must register distinct method names.`
1079
- );
1346
+ if (retryAfterMs !== void 0 && retryAfterMs > 0) {
1347
+ parts.push(`retry in ${formatDuration(retryAfterMs)}`);
1080
1348
  }
1081
- seen.add(key);
1082
- target[key] = source[key];
1083
- }
1084
- }
1085
- function mergeMetaKeysWithCollisionCheck(target, source, seen) {
1086
- for (const key of Object.keys(source)) {
1087
- if (seen.has(key)) {
1088
- throw new Error(
1089
- `composePlugins: duplicate context.meta key "${key}". Two sub-plugins registered metadata for the same name.`
1349
+ if (error.retries > 0) {
1350
+ parts.push(
1351
+ `after ${error.retries} retr${error.retries === 1 ? "y" : "ies"}`
1090
1352
  );
1091
1353
  }
1092
- seen.add(key);
1093
- target[key] = source[key];
1094
- }
1095
- }
1096
- function mergeContextKeysWithCollisionCheck(target, source, seen) {
1097
- for (const key of Object.keys(source)) {
1098
- if (seen.has(key)) {
1099
- throw new Error(
1100
- `composePlugins: duplicate context key "${key}". Two sub-plugins contributed the same context.${key} field.`
1101
- );
1354
+ if (parts.length > 0) {
1355
+ message += `
1356
+ ${parts.join(", ")}`;
1102
1357
  }
1103
- seen.add(key);
1104
- target[key] = source[key];
1105
1358
  }
1106
- }
1107
- function composePlugins(...plugins) {
1108
- return (sdk) => {
1109
- const merged = { context: { meta: {} } };
1110
- const seenRoot = /* @__PURE__ */ new Set();
1111
- const seenMeta = /* @__PURE__ */ new Set();
1112
- const seenContext = /* @__PURE__ */ new Set();
1113
- for (const plugin of plugins) {
1114
- const { context, ...rootKeys } = plugin(sdk);
1115
- mergeRootKeysWithCollisionCheck(merged, rootKeys, seenRoot);
1116
- if (context) {
1117
- const { meta, ...nonMetaContext } = context;
1118
- if (meta) {
1119
- mergeMetaKeysWithCollisionCheck(merged.context.meta, meta, seenMeta);
1120
- }
1121
- mergeContextKeysWithCollisionCheck(
1122
- merged.context,
1123
- nonMetaContext,
1124
- seenContext
1125
- );
1126
- }
1127
- }
1128
- return merged;
1129
- };
1130
- }
1131
- function getStringProperty(obj, key) {
1132
- if (typeof obj === "object" && obj !== null && key in obj) {
1133
- const value = obj[key];
1134
- return typeof value === "string" ? value : void 0;
1359
+ if (error.statusCode && !message.includes(`${error.statusCode}`)) {
1360
+ message += `
1361
+ HTTP Status: ${error.statusCode}`;
1135
1362
  }
1136
- return void 0;
1363
+ return message;
1137
1364
  }
1138
- function formatActionResult(item) {
1139
- const obj = typeof item === "object" && item !== null ? item : {};
1140
- const title = getStringProperty(obj, "title") || getStringProperty(obj, "name") || getStringProperty(obj, "label") || getStringProperty(obj, "subject") || "Action Result";
1141
- return {
1142
- title,
1143
- id: getStringProperty(obj, "id"),
1144
- key: getStringProperty(obj, "key"),
1145
- description: getStringProperty(obj, "description"),
1146
- data: item,
1147
- // Let formatJsonOutput handle the JSON rendering
1148
- details: []
1149
- // Not used when data is provided
1150
- };
1365
+ function formatDuration(ms) {
1366
+ const seconds = Math.round(ms / 1e3);
1367
+ if (seconds < 60) return `${seconds}s`;
1368
+ const minutes = Math.round(seconds / 60);
1369
+ if (minutes < 60) return `${minutes}m`;
1370
+ const hours = Math.round(minutes / 60);
1371
+ if (hours < 24) return `${hours}h`;
1372
+ const days = Math.round(hours / 24);
1373
+ return `${days}d`;
1151
1374
  }
1152
- var ActionResultItemSchema = withFormatter(
1153
- z.unknown().describe("Action execution result"),
1154
- { format: formatActionResult }
1375
+
1376
+ // src/types/signals.ts
1377
+ var ZapierSignal = class extends Error {
1378
+ constructor(message) {
1379
+ super(message);
1380
+ Object.setPrototypeOf(this, new.target.prototype);
1381
+ }
1382
+ };
1383
+ var ZapierReleaseTriggerMessageSignal = class extends ZapierSignal {
1384
+ constructor() {
1385
+ super(...arguments);
1386
+ this.name = "ZapierReleaseTriggerMessageSignal";
1387
+ this.code = "ZAPIER_RELEASE_TRIGGER_MESSAGE_SIGNAL";
1388
+ }
1389
+ };
1390
+ var ZapierAbortDrainSignal = class extends ZapierSignal {
1391
+ constructor() {
1392
+ super(...arguments);
1393
+ this.name = "ZapierAbortDrainSignal";
1394
+ this.code = "ZAPIER_ABORT_DRAIN_SIGNAL";
1395
+ }
1396
+ };
1397
+ var TriggerInboxCommandBaseSchema = z.object({
1398
+ inbox: TriggerInboxPropertySchema,
1399
+ onMessage: z.function().optional().meta({ exampleRequired: true }).describe(
1400
+ "Per-message handler. Resolves to ack; rejects to release-or-leave per `releaseOnError`. Throw `ZapierReleaseTriggerMessageSignal` to release explicitly, or `ZapierAbortDrainSignal` to stop after the current batch."
1401
+ ),
1402
+ concurrency: z.number().int().min(1).optional().describe(
1403
+ "Per-message handler workers running in parallel. Defaults to `leaseLimit`, or 1 if neither is set."
1404
+ ),
1405
+ leaseLimit: z.number().int().min(1).max(100).optional().describe(
1406
+ "Per-lease HTTP batch size. Defaults to `concurrency`, or 1 if neither is set."
1407
+ ),
1408
+ leaseSeconds: LeaseSecondsPropertySchema.optional(),
1409
+ releaseOnError: z.boolean().optional().describe(
1410
+ "If true, errors release the message when the drain finishes. If false (default), errors leave it leased until the lease timeout. `ZapierReleaseTriggerMessageSignal` always releases regardless."
1411
+ ),
1412
+ continueOnError: z.boolean().optional().describe(
1413
+ "If false (default, fail-fast), the first handler error rejects and stops the drain. If true, handler errors are observed via `onError` and the drain continues. SDK-level errors (lease / ack / release) reject regardless."
1414
+ ),
1415
+ onError: z.function().optional().describe(
1416
+ "Per-message error observer for `continueOnError: true`. Called with the failure and the message; control-flow signals are filtered out. Throws from `onError` are swallowed."
1417
+ ),
1418
+ signal: z.custom((v) => v instanceof AbortSignal).optional().describe(
1419
+ "Abort signal. Aborting cancels in-flight HTTP, releases unprocessed messages, and resolves cleanly. Errors during shutdown still reject."
1420
+ )
1421
+ });
1422
+ TriggerInboxCommandBaseSchema.extend({
1423
+ maxMessages: z.number().int().min(1).optional().describe(
1424
+ "Cap total messages drained. Defaults to draining the inbox until empty."
1425
+ )
1426
+ }).describe(
1427
+ "Drain an existing trigger inbox: lease currently-available messages and process them via onMessage. Returns when the inbox is empty, maxMessages is reached, the abort signal fires, or a fatal error rejects."
1428
+ );
1429
+ TriggerInboxCommandBaseSchema.extend({
1430
+ maxDrainIntervalSeconds: z.number().int().min(1).optional().describe(
1431
+ "Maximum seconds between empty-inbox poll attempts (default: 60). Caps the back-off cadence."
1432
+ )
1433
+ }).describe(
1434
+ "Continuously consume a trigger inbox: drain currently-available messages, then poll with backoff for new arrivals, until aborted. Stop via the `signal` AbortSignal or by throwing `ZapierAbortDrainSignal` from a handler. Resolves cleanly on abort; rejects on a fatal error or a fail-fast handler error."
1155
1435
  );
1436
+ var ActionExecutionInputSchema = z.object({
1437
+ inputs: z.record(z.string(), z.unknown()).optional(),
1438
+ /** @deprecated Use `connection` instead. */
1439
+ connectionId: ConnectionIdPropertySchema.optional().meta({
1440
+ deprecated: true
1441
+ }),
1442
+ connection: ConnectionPropertySchema.optional(),
1443
+ /** @deprecated Use connection instead */
1444
+ authenticationId: AuthenticationIdPropertySchema.optional().meta({
1445
+ deprecated: true
1446
+ }),
1447
+ timeoutMs: ActionTimeoutMsPropertySchema
1448
+ }).describe(
1449
+ "Execute an action with the given inputs for the bound app, as an alternative to runAction"
1450
+ ).meta({
1451
+ aliases: { connectionId: "connection", authenticationId: "connection" }
1452
+ });
1453
+ var AppFactoryInputSchema = z.object({
1454
+ /** @deprecated Use `connection` instead. */
1455
+ connectionId: ConnectionIdPropertySchema.optional().meta({
1456
+ deprecated: true
1457
+ }),
1458
+ connection: ConnectionPropertySchema.optional(),
1459
+ /** @deprecated Use connection instead */
1460
+ authenticationId: AuthenticationIdPropertySchema.optional().meta({
1461
+ deprecated: true
1462
+ })
1463
+ }).describe("Bind a connection alias or numeric connectionId to an app").meta({
1464
+ aliases: { connectionId: "connection", authenticationId: "connection" }
1465
+ });
1466
+ var ActionResultItemSchema = z.unknown().describe("Action execution result");
1156
1467
 
1157
1468
  // src/plugins/apps/index.ts
1158
1469
  function resolveProxyConnection({
@@ -1373,18 +1684,6 @@ var FetchInitSchema = z.object({
1373
1684
  aliases: { connectionId: "connection", authenticationId: "connection" }
1374
1685
  });
1375
1686
 
1376
- // src/utils/string-utils.ts
1377
- function toTitleCase(input) {
1378
- return input.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[_\-]+/g, " ").replace(/\s+/g, " ").trim().split(" ").map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(" ");
1379
- }
1380
- function toSnakeCase(input) {
1381
- let result = input.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/[\s\-]+/g, "_").replace(/_+/g, "_").replace(/^_|_$/g, "").toLowerCase();
1382
- if (/^[0-9]/.test(result)) {
1383
- result = "_" + result;
1384
- }
1385
- return result;
1386
- }
1387
-
1388
1687
  // src/utils/domain-utils.ts
1389
1688
  function isConnectionId(value) {
1390
1689
  return /^\d+$/.test(value) || isUuid(value);
@@ -1687,15 +1986,25 @@ function buildAbortHandle({
1687
1986
  return combineAbortSignals({ handles });
1688
1987
  }
1689
1988
  var FetchInitSdkValidationSchema = z.looseObject(FetchInitZapierFieldsSchema.shape).optional();
1690
- var validateFetchInit = createValidator(FetchInitSdkValidationSchema);
1691
1989
  var fetchPlugin = definePlugin(
1692
1990
  (sdk) => {
1991
+ const validateFetchInit = createValidator(FetchInitSdkValidationSchema, {
1992
+ adaptError: sdk.context.core?.adaptError
1993
+ });
1693
1994
  return {
1694
1995
  fetch: async function fetch2(url, init) {
1695
- return runWithTelemetryContext(async () => {
1996
+ return runInMethodScope(async () => {
1696
1997
  const { api } = sdk.context;
1998
+ const { onMethodStart, onMethodEnd } = sdk.context.hooks;
1697
1999
  const startTime = Date.now();
1698
- const isNested = isTelemetryNested();
2000
+ const depth = getCurrentDepth();
2001
+ const args = init === void 0 ? [url] : [url, init];
2002
+ onMethodStart?.({
2003
+ methodName: "fetch",
2004
+ args,
2005
+ isPaginated: false,
2006
+ depth
2007
+ });
1699
2008
  try {
1700
2009
  if (init) {
1701
2010
  validateFetchInit(init);
@@ -1767,17 +2076,13 @@ var fetchPlugin = definePlugin(
1767
2076
  statusCode: result.status
1768
2077
  });
1769
2078
  }
1770
- if (!isNested) {
1771
- sdk.context.eventEmission.emitMethodCalled({
1772
- method_name: "fetch",
1773
- execution_duration_ms: Date.now() - startTime,
1774
- success_flag: true,
1775
- error_message: null,
1776
- error_type: null,
1777
- argument_count: init ? 2 : 1,
1778
- is_paginated: false
1779
- });
1780
- }
2079
+ onMethodEnd?.({
2080
+ methodName: "fetch",
2081
+ args,
2082
+ isPaginated: false,
2083
+ depth,
2084
+ durationMs: Date.now() - startTime
2085
+ });
1781
2086
  return result;
1782
2087
  } catch (error) {
1783
2088
  throw rewrapIfMaxTimeTimeout({
@@ -1789,17 +2094,14 @@ var fetchPlugin = definePlugin(
1789
2094
  abortHandle?.dispose();
1790
2095
  }
1791
2096
  } catch (error) {
1792
- if (!isNested) {
1793
- sdk.context.eventEmission.emitMethodCalled({
1794
- method_name: "fetch",
1795
- execution_duration_ms: Date.now() - startTime,
1796
- success_flag: false,
1797
- error_message: error instanceof Error ? error.message : String(error),
1798
- error_type: error instanceof Error ? error.constructor.name : "Unknown",
1799
- argument_count: init ? 2 : 1,
1800
- is_paginated: false
1801
- });
1802
- }
2097
+ onMethodEnd?.({
2098
+ methodName: "fetch",
2099
+ args,
2100
+ isPaginated: false,
2101
+ depth,
2102
+ durationMs: Date.now() - startTime,
2103
+ error: error instanceof Error ? error : new Error(String(error))
2104
+ });
1803
2105
  throw error;
1804
2106
  }
1805
2107
  });
@@ -1809,7 +2111,11 @@ var fetchPlugin = definePlugin(
1809
2111
  fetch: {
1810
2112
  description: "Make authenticated HTTP requests to any API through Zapier. Pass a connectionId to automatically inject the user's stored credentials (OAuth tokens, API keys, etc.) into the outgoing request. Mirrors the native fetch(url, init?) signature with additional Zapier-specific options.",
1811
2113
  packages: ["sdk", "cli", "mcp"],
1812
- categories: ["http"],
2114
+ // Auto-derive would produce "Http"/"Https" from the key alone;
2115
+ // declare the title explicitly here so the registry renders
2116
+ // "HTTP Request". Other plugins in this category use the bare
2117
+ // string "http"; the object form wins regardless of order.
2118
+ categories: [{ key: "http", title: "HTTP Request" }],
1813
2119
  returnType: "Response",
1814
2120
  inputParameters: [
1815
2121
  { name: "url", schema: FetchUrlSchema },
@@ -1821,6 +2127,29 @@ var fetchPlugin = definePlugin(
1821
2127
  };
1822
2128
  }
1823
2129
  );
2130
+
2131
+ // src/utils/pagination.ts
2132
+ function extractCursorFromUrl(url) {
2133
+ try {
2134
+ const params = new URL(url).searchParams;
2135
+ return params.get("offset") ?? params.get("cursor") ?? void 0;
2136
+ } catch {
2137
+ return void 0;
2138
+ }
2139
+ }
2140
+ function adaptZapierPage(response) {
2141
+ const r = response ?? {};
2142
+ const data = r.data;
2143
+ const linksNext = r.links?.next;
2144
+ if (typeof linksNext === "string") {
2145
+ return { data, nextCursor: extractCursorFromUrl(linksNext) };
2146
+ }
2147
+ if (typeof r.next === "string") {
2148
+ return { data, nextCursor: extractCursorFromUrl(r.next) };
2149
+ }
2150
+ return { data };
2151
+ }
2152
+ var zapierPagination = { adaptPage: adaptZapierPage };
1824
2153
  var ListAppsSchema = ListAppsQuerySchema.omit({
1825
2154
  offset: true,
1826
2155
  app_keys: true,
@@ -1842,27 +2171,30 @@ var ListAppsSchema = ListAppsQuerySchema.omit({
1842
2171
  // SDK specific property for pagination/iterable helpers
1843
2172
  cursor: z.string().optional().describe("Cursor to start from")
1844
2173
  }).describe("List all available apps with optional filtering");
1845
- var AppItemSchema = withFormatter(AppItemSchema$1, {
1846
- format: (item) => {
1847
- return {
1848
- title: item.title,
1849
- key: item.key,
1850
- keys: getAppKeyList(item),
1851
- description: item.description,
1852
- details: []
1853
- };
1854
- }
1855
- });
2174
+ var AppItemSchema = AppItemSchema$1;
2175
+
2176
+ // src/formatters/app.ts
2177
+ var appItemFormatter = {
2178
+ format: (item) => ({
2179
+ title: item.title,
2180
+ key: item.key,
2181
+ keys: getAppKeyList(item),
2182
+ description: item.description,
2183
+ details: []
2184
+ })
2185
+ };
1856
2186
 
1857
2187
  // src/plugins/listApps/index.ts
1858
2188
  var listAppsPlugin = definePlugin(
1859
2189
  (sdk) => createPaginatedPluginMethod(sdk, {
2190
+ ...zapierPagination,
1860
2191
  name: "listApps",
1861
2192
  categories: ["app"],
1862
2193
  type: "list",
1863
2194
  itemType: "App",
1864
2195
  inputSchema: ListAppsSchema,
1865
2196
  outputSchema: AppItemSchema,
2197
+ formatter: appItemFormatter,
1866
2198
  defaultPageSize: DEFAULT_PAGE_SIZE,
1867
2199
  handler: async ({ sdk: sdk2, options }) => {
1868
2200
  const { api, resolveAppKeys: resolveAppKeys2 } = sdk2.context;
@@ -1902,8 +2234,7 @@ var listAppsPlugin = definePlugin(
1902
2234
  ...options.cursor && { offset: options.cursor }
1903
2235
  }
1904
2236
  });
1905
- },
1906
- extractCursor: (response) => extractCursor(response.links)
2237
+ }
1907
2238
  })
1908
2239
  );
1909
2240
  var ListActionsDescription = "List all actions for a specific app";
@@ -2228,48 +2559,42 @@ z.object({
2228
2559
  });
2229
2560
 
2230
2561
  // src/schemas/Action.ts
2231
- var ActionItemSchema = withFormatter(
2232
- ActionSchema.omit({ type: true, name: true, selected_api: true }).extend({
2233
- app_key: z.string(),
2234
- // App key without version (extracted from selected_api)
2235
- app_version: z.string().optional(),
2236
- // Version extracted from selected_api
2237
- action_type: ActionSchema.shape.type,
2238
- // Mapped from original 'type' field
2239
- title: z.string(),
2240
- // Mapped from original 'name' field
2241
- type: z.literal("action")
2242
- // Fixed type identifier
2243
- }),
2244
- {
2245
- format: (item) => {
2246
- const details = [];
2247
- details.push({
2248
- text: `Type: ${item.action_type}`,
2249
- style: "accent"
2250
- });
2251
- if (item.app_key) {
2252
- details.push({
2253
- text: `App: ${item.app_key}`,
2254
- style: "normal"
2255
- });
2256
- }
2257
- if (item.description) {
2258
- details.push({
2259
- text: item.description,
2260
- style: "dim"
2261
- });
2262
- }
2263
- return {
2264
- title: item.title || item.key,
2265
- id: item.id,
2266
- key: item.key,
2267
- description: item.description,
2268
- details
2269
- };
2562
+ var ActionItemSchema = ActionSchema.omit({
2563
+ type: true,
2564
+ name: true,
2565
+ selected_api: true
2566
+ }).extend({
2567
+ app_key: z.string(),
2568
+ // App key without version (extracted from selected_api)
2569
+ app_version: z.string().optional(),
2570
+ // Version extracted from selected_api
2571
+ action_type: ActionSchema.shape.type,
2572
+ // Mapped from original 'type' field
2573
+ title: z.string(),
2574
+ // Mapped from original 'name' field
2575
+ type: z.literal("action")
2576
+ // Fixed type identifier
2577
+ });
2578
+
2579
+ // src/formatters/action.ts
2580
+ var actionItemFormatter = {
2581
+ format: (item) => {
2582
+ const details = [{ text: `Type: ${item.action_type}`, style: "accent" }];
2583
+ if (item.app_key) {
2584
+ details.push({ text: `App: ${item.app_key}`, style: "normal" });
2585
+ }
2586
+ if (item.description) {
2587
+ details.push({ text: item.description, style: "dim" });
2270
2588
  }
2589
+ return {
2590
+ title: item.title || item.key,
2591
+ id: item.id,
2592
+ key: item.key,
2593
+ description: item.description,
2594
+ details
2595
+ };
2271
2596
  }
2272
- );
2597
+ };
2273
2598
 
2274
2599
  // src/resolvers/appKey.ts
2275
2600
  var appKeyResolver = {
@@ -2476,7 +2801,7 @@ var inputFieldKeyResolver = {
2476
2801
  type: "dynamic",
2477
2802
  depends: ["app", "action", "actionType", "connection"],
2478
2803
  fetch: async (sdk, resolvedParams) => {
2479
- const fieldsResponse = await sdk.listInputFields({
2804
+ const fieldsResponse = await sdk.listActionInputFields({
2480
2805
  app: resolvedParams.app,
2481
2806
  action: resolvedParams.action,
2482
2807
  actionType: resolvedParams.actionType,
@@ -2582,7 +2907,8 @@ var workflowIdResolver = {
2582
2907
  name: "workflow",
2583
2908
  message: "Select a workflow:",
2584
2909
  choices: workflows.map((workflow) => ({
2585
- name: workflow.enabled ? workflow.name : `${workflow.name} (disabled)`,
2910
+ name: workflow.name,
2911
+ hint: workflow.enabled ? void 0 : [workflow.id, "disabled"],
2586
2912
  value: workflow.id
2587
2913
  }))
2588
2914
  })
@@ -2597,7 +2923,8 @@ var durableRunIdResolver = {
2597
2923
  name: "run",
2598
2924
  message: "Select a run:",
2599
2925
  choices: runs.map((run) => ({
2600
- name: `${run.id} \u2014 ${run.status}`,
2926
+ name: run.id,
2927
+ hint: run.status,
2601
2928
  value: run.id
2602
2929
  }))
2603
2930
  })
@@ -2607,11 +2934,7 @@ var durableRunIdResolver = {
2607
2934
  var workflowVersionIdResolver = {
2608
2935
  type: "dynamic",
2609
2936
  depends: ["workflow"],
2610
- fetch: async (sdk, params) => toIterable(
2611
- sdk.listWorkflowVersions({
2612
- workflow: params.workflow
2613
- })
2614
- ),
2937
+ fetch: async (sdk, params) => toIterable(sdk.listWorkflowVersions({ workflow: params.workflow })),
2615
2938
  prompt: (versions) => ({
2616
2939
  type: "list",
2617
2940
  name: "version",
@@ -2623,15 +2946,27 @@ var workflowVersionIdResolver = {
2623
2946
  })
2624
2947
  };
2625
2948
 
2949
+ // src/resolvers/workflowRunId.ts
2950
+ var workflowRunIdResolver = {
2951
+ type: "dynamic",
2952
+ depends: ["workflow"],
2953
+ fetch: async (sdk, params) => toIterable(sdk.listWorkflowRuns({ workflow: params.workflow })),
2954
+ prompt: (runs) => ({
2955
+ type: "list",
2956
+ name: "run",
2957
+ message: "Select a workflow run:",
2958
+ choices: runs.map((r) => ({
2959
+ name: `${r.id} \u2014 ${r.status}`,
2960
+ value: r.id
2961
+ }))
2962
+ })
2963
+ };
2964
+
2626
2965
  // src/resolvers/triggerMessages.ts
2627
2966
  var triggerMessagesResolver = {
2628
2967
  type: "dynamic",
2629
2968
  depends: ["inbox"],
2630
- fetch: async (sdk, params) => toIterable(
2631
- sdk.listTriggerInboxMessages({
2632
- inbox: params.inbox
2633
- })
2634
- ),
2969
+ fetch: async (sdk, params) => toIterable(sdk.listTriggerInboxMessages({ inbox: params.inbox })),
2635
2970
  prompt: (messages) => ({
2636
2971
  type: "checkbox",
2637
2972
  name: "messages",
@@ -3005,7 +3340,7 @@ var FieldApiItemSchema = z.object({
3005
3340
  var ListTableFieldsApiResponseSchema = z.object({
3006
3341
  data: z.array(FieldApiItemSchema)
3007
3342
  });
3008
- var FieldItemSchemaBase = z.object({
3343
+ var FieldItemSchema = z.object({
3009
3344
  id: z.string(),
3010
3345
  type: FieldTypeSchema,
3011
3346
  name: z.string(),
@@ -3015,13 +3350,6 @@ var FieldItemSchemaBase = z.object({
3015
3350
  config: z.record(z.string(), z.unknown()).optional(),
3016
3351
  deleted_at: z.string().nullable().optional()
3017
3352
  });
3018
- var FieldItemSchema = withFormatter(FieldItemSchemaBase, {
3019
- format: (item) => ({
3020
- title: item.name,
3021
- id: item.id,
3022
- details: [{ text: `Type: ${item.type}`, style: "dim" }]
3023
- })
3024
- });
3025
3353
  var ListTableFieldsDescription = "List fields for a table";
3026
3354
  var ListTableFieldsOptionsBaseSchema = z.object({
3027
3355
  fields: FieldsPropertySchema.optional(),
@@ -3268,6 +3596,18 @@ var tableSortResolver = {
3268
3596
  }
3269
3597
  };
3270
3598
 
3599
+ // src/plugins/eventEmission/method-metadata.ts
3600
+ var SCOPE_KEY = "methodMetadata";
3601
+ function setMethodMetadata(metadata) {
3602
+ const scope = getCurrentScope();
3603
+ if (!scope) return;
3604
+ const existing = scope[SCOPE_KEY];
3605
+ scope[SCOPE_KEY] = { ...existing, ...metadata };
3606
+ }
3607
+ function getMethodMetadata() {
3608
+ return getCurrentScope()?.[SCOPE_KEY];
3609
+ }
3610
+
3271
3611
  // src/plugins/listActions/index.ts
3272
3612
  var listActionsPlugin = definePlugin(
3273
3613
  (sdk) => createPaginatedPluginMethod(sdk, {
@@ -3277,12 +3617,10 @@ var listActionsPlugin = definePlugin(
3277
3617
  itemType: "Action",
3278
3618
  inputSchema: ListActionsInputSchema,
3279
3619
  outputSchema: ActionItemSchema,
3620
+ formatter: actionItemFormatter,
3280
3621
  defaultPageSize: DEFAULT_PAGE_SIZE,
3281
3622
  resolvers: { app: appKeyResolver, actionType: actionTypeResolver },
3282
- handler: async ({
3283
- sdk: sdk2,
3284
- options
3285
- }) => {
3623
+ handler: async ({ sdk: sdk2, options }) => {
3286
3624
  const { api, getVersionedImplementationId } = sdk2.context;
3287
3625
  const appKey = "app" in options ? options.app : options.appKey;
3288
3626
  const selectedApi = await getVersionedImplementationId(appKey);
@@ -3369,99 +3707,36 @@ var BaseFieldItemSchema = z.object({
3369
3707
  key: z.string()
3370
3708
  // From need.key
3371
3709
  });
3372
- var InputFieldItemSchema = withFormatter(
3373
- BaseFieldItemSchema.extend({
3374
- type: z.literal("input_field"),
3375
- default_value: z.string(),
3376
- // Mapped from 'default' with fallback to ""
3377
- depends_on: z.array(z.string()),
3378
- // Mapped from 'depends_on' with fallback to []
3379
- description: z.string(),
3380
- // Mapped from 'help_text' with fallback to ""
3381
- invalidates_input_fields: z.boolean(),
3382
- // Mapped from 'alters_custom_fields' with fallback to false
3383
- is_required: z.boolean(),
3384
- // Mapped from 'required' with fallback to false
3385
- placeholder: z.string(),
3386
- // Mapped from 'placeholder' with fallback to ""
3387
- title: z.string(),
3388
- // Mapped from 'label' with fallback to ""
3389
- value_type: z.string(),
3390
- // Computed from InputFieldType enum
3391
- format: z.string().optional(),
3392
- // Computed from InputFieldFormat enum (optional)
3393
- items: z.object({ type: z.string() }).optional()
3394
- // Computed from ItemsType enum (optional, only for arrays)
3395
- }),
3396
- {
3397
- format: (item) => {
3398
- const details = [];
3399
- const typeInfo = [
3400
- item.value_type && `Type: ${item.value_type}`,
3401
- `Required: ${item.is_required ? "Yes" : "No"}`
3402
- ].filter(Boolean).join(" | ");
3403
- if (typeInfo) {
3404
- details.push({ text: typeInfo, style: "dim" });
3405
- }
3406
- if (item.description) {
3407
- details.push({
3408
- text: item.description,
3409
- style: "normal"
3410
- });
3411
- }
3412
- if (item.default_value) {
3413
- details.push({
3414
- text: `Default: ${item.default_value}`,
3415
- style: "accent"
3416
- });
3417
- }
3418
- if (item.placeholder) {
3419
- details.push({
3420
- text: `Placeholder: ${item.placeholder}`,
3421
- style: "dim"
3422
- });
3423
- }
3424
- if (item.depends_on && item.depends_on.length > 0) {
3425
- details.push({
3426
- text: `Depends on: ${item.depends_on.join(", ")}`,
3427
- style: "warning"
3428
- });
3429
- }
3430
- if (item.format) {
3431
- details.push({ text: `Format: ${item.format}`, style: "dim" });
3432
- }
3433
- if (item.items) {
3434
- details.push({
3435
- text: `Items type: ${item.items.type}`,
3436
- style: "dim"
3437
- });
3438
- }
3439
- return {
3440
- title: item.title || item.key,
3441
- key: item.key,
3442
- description: item.description,
3443
- details
3444
- };
3445
- }
3446
- }
3447
- );
3448
- var InfoFieldItemSchema = withFormatter(
3449
- BaseFieldItemSchema.extend({
3450
- type: z.literal("info_field"),
3451
- description: z.string(),
3452
- // From need.help_text
3453
- title: z.string().optional()
3454
- // Optional title
3455
- }),
3456
- {
3457
- format: (item) => ({
3458
- title: item.title || "Info",
3459
- key: item.key,
3460
- description: item.description,
3461
- details: [{ text: item.description, style: "normal" }]
3462
- })
3463
- }
3464
- );
3710
+ var InputFieldItemSchema = BaseFieldItemSchema.extend({
3711
+ type: z.literal("input_field"),
3712
+ default_value: z.string(),
3713
+ // Mapped from 'default' with fallback to ""
3714
+ depends_on: z.array(z.string()),
3715
+ // Mapped from 'depends_on' with fallback to []
3716
+ description: z.string(),
3717
+ // Mapped from 'help_text' with fallback to ""
3718
+ invalidates_input_fields: z.boolean(),
3719
+ // Mapped from 'alters_custom_fields' with fallback to false
3720
+ is_required: z.boolean(),
3721
+ // Mapped from 'required' with fallback to false
3722
+ placeholder: z.string(),
3723
+ // Mapped from 'placeholder' with fallback to ""
3724
+ title: z.string(),
3725
+ // Mapped from 'label' with fallback to ""
3726
+ value_type: z.string(),
3727
+ // Computed from InputFieldType enum
3728
+ format: z.string().optional(),
3729
+ // Computed from InputFieldFormat enum (optional)
3730
+ items: z.object({ type: z.string() }).optional()
3731
+ // Computed from ItemsType enum (optional, only for arrays)
3732
+ });
3733
+ var InfoFieldItemSchema = BaseFieldItemSchema.extend({
3734
+ type: z.literal("info_field"),
3735
+ description: z.string(),
3736
+ // From need.help_text
3737
+ title: z.string().optional()
3738
+ // Optional title
3739
+ });
3465
3740
  var FieldsetItemSchema = BaseFieldItemSchema.extend({
3466
3741
  type: z.literal("fieldset"),
3467
3742
  title: z.string(),
@@ -3481,6 +3756,53 @@ var RootFieldItemSchema = z.union([
3481
3756
  FieldsetItemSchema
3482
3757
  ]);
3483
3758
 
3759
+ // src/formatters/field.ts
3760
+ function formatInputField(item) {
3761
+ const details = [];
3762
+ const typeInfo = [
3763
+ item.value_type && `Type: ${item.value_type}`,
3764
+ `Required: ${item.is_required ? "Yes" : "No"}`
3765
+ ].filter(Boolean).join(" | ");
3766
+ if (typeInfo) details.push({ text: typeInfo, style: "dim" });
3767
+ if (item.description)
3768
+ details.push({ text: item.description, style: "normal" });
3769
+ if (item.default_value)
3770
+ details.push({ text: `Default: ${item.default_value}`, style: "accent" });
3771
+ if (item.placeholder)
3772
+ details.push({ text: `Placeholder: ${item.placeholder}`, style: "dim" });
3773
+ if (item.depends_on && item.depends_on.length > 0) {
3774
+ details.push({
3775
+ text: `Depends on: ${item.depends_on.join(", ")}`,
3776
+ style: "warning"
3777
+ });
3778
+ }
3779
+ if (item.format)
3780
+ details.push({ text: `Format: ${item.format}`, style: "dim" });
3781
+ if (item.items)
3782
+ details.push({ text: `Items type: ${item.items.type}`, style: "dim" });
3783
+ return {
3784
+ title: item.title || item.key,
3785
+ key: item.key,
3786
+ description: item.description,
3787
+ details
3788
+ };
3789
+ }
3790
+ function formatInfoField(item) {
3791
+ return {
3792
+ title: item.title || "Info",
3793
+ key: item.key,
3794
+ description: item.description,
3795
+ details: [{ text: item.description, style: "normal" }]
3796
+ };
3797
+ }
3798
+ var rootFieldItemFormatter = {
3799
+ format: (item) => {
3800
+ if (item.type === "input_field") return formatInputField(item);
3801
+ if (item.type === "info_field") return formatInfoField(item);
3802
+ return { title: item.title || item.key, key: item.key, details: [] };
3803
+ }
3804
+ };
3805
+
3484
3806
  // src/services/implementations.ts
3485
3807
  async function fetchImplementationNeeds({
3486
3808
  api,
@@ -3646,6 +3968,7 @@ var listActionInputFieldsPlugin = definePlugin(
3646
3968
  itemType: "RootField",
3647
3969
  inputSchema: ListActionInputFieldsInputSchema,
3648
3970
  outputSchema: RootFieldItemSchema,
3971
+ formatter: rootFieldItemFormatter,
3649
3972
  defaultPageSize: DEFAULT_PAGE_SIZE,
3650
3973
  resolvers: {
3651
3974
  app: appKeyResolver,
@@ -3654,10 +3977,7 @@ var listActionInputFieldsPlugin = definePlugin(
3654
3977
  connection: connectionIdResolver,
3655
3978
  inputs: inputsAllOptionalResolver
3656
3979
  },
3657
- handler: async ({
3658
- sdk: sdk2,
3659
- options
3660
- }) => {
3980
+ handler: async ({ sdk: sdk2, options }) => {
3661
3981
  const { api, getVersionedImplementationId } = sdk2.context;
3662
3982
  const appKey = "app" in options ? options.app : options.appKey;
3663
3983
  const actionKey = "action" in options ? options.action : options.actionKey;
@@ -3705,26 +4025,7 @@ var listActionInputFieldsPlugin = definePlugin(
3705
4025
  }
3706
4026
  })
3707
4027
  );
3708
- var InputFieldChoiceItemSchema = withFormatter(NeedChoicesSchema, {
3709
- format: (item) => {
3710
- const title = item.label || item.key || "Choice";
3711
- const details = [];
3712
- if (item.label && item.key && item.label !== item.key) {
3713
- details.push({ text: `Key: ${item.key}`, style: "dim" });
3714
- }
3715
- if (item.sample && item.sample !== item.key) {
3716
- details.push({ text: `Sample: ${item.sample}`, style: "dim" });
3717
- }
3718
- if (item.value && item.value !== item.key) {
3719
- details.push({ text: `Value: ${item.value}`, style: "normal" });
3720
- }
3721
- return {
3722
- title,
3723
- key: item.key,
3724
- details
3725
- };
3726
- }
3727
- });
4028
+ var InputFieldChoiceItemSchema = NeedChoicesSchema;
3728
4029
  var ListActionInputFieldChoicesDescription = "Get the available choices for a dynamic dropdown input field";
3729
4030
  var ListActionInputFieldChoicesBaseSchema = z.object({
3730
4031
  connection: ConnectionPropertySchema.optional().describe(
@@ -3768,6 +4069,24 @@ var ListActionInputFieldChoicesInputSchema = z.union([
3768
4069
  ListActionInputFieldChoicesSchemaDeprecated
3769
4070
  ]).describe(ListActionInputFieldChoicesDescription);
3770
4071
 
4072
+ // src/formatters/inputFieldChoice.ts
4073
+ var inputFieldChoiceItemFormatter = {
4074
+ format: (item) => {
4075
+ const title = item.label || item.key || "Choice";
4076
+ const details = [];
4077
+ if (item.label && item.key && item.label !== item.key) {
4078
+ details.push({ text: `Key: ${item.key}`, style: "dim" });
4079
+ }
4080
+ if (item.sample && item.sample !== item.key) {
4081
+ details.push({ text: `Sample: ${item.sample}`, style: "dim" });
4082
+ }
4083
+ if (item.value && item.value !== item.key) {
4084
+ details.push({ text: `Value: ${item.value}`, style: "normal" });
4085
+ }
4086
+ return { title, key: item.key, details };
4087
+ }
4088
+ };
4089
+
3771
4090
  // src/plugins/listActionInputFieldChoices/index.ts
3772
4091
  function transformNeedChoicesToInputFieldChoiceItem(choice) {
3773
4092
  return {
@@ -3785,6 +4104,7 @@ var listActionInputFieldChoicesPlugin = definePlugin(
3785
4104
  itemType: "InputFieldChoice",
3786
4105
  inputSchema: ListActionInputFieldChoicesInputSchema,
3787
4106
  outputSchema: InputFieldChoiceItemSchema,
4107
+ formatter: inputFieldChoiceItemFormatter,
3788
4108
  defaultPageSize: DEFAULT_PAGE_SIZE,
3789
4109
  resolvers: {
3790
4110
  app: appKeyResolver,
@@ -3794,10 +4114,7 @@ var listActionInputFieldChoicesPlugin = definePlugin(
3794
4114
  inputField: inputFieldKeyResolver,
3795
4115
  inputs: inputsAllOptionalResolver
3796
4116
  },
3797
- handler: async ({
3798
- sdk: sdk2,
3799
- options
3800
- }) => {
4117
+ handler: async ({ sdk: sdk2, options }) => {
3801
4118
  const { api, getVersionedImplementationId } = sdk2.context;
3802
4119
  const appKey = "app" in options ? options.app : options.appKey;
3803
4120
  const actionKey = "action" in options ? options.action : options.actionKey;
@@ -4049,7 +4366,10 @@ var ListConnectionsQuerySchema = ListConnectionsQuerySchema$1.omit({
4049
4366
  // SDK specific property for pagination/iterable helpers
4050
4367
  cursor: z.string().optional().describe("Cursor to start from")
4051
4368
  }).describe("List available connections with optional filtering");
4052
- var ConnectionItemSchema = withFormatter(ConnectionItemSchema$1, {
4369
+ var ConnectionItemSchema = ConnectionItemSchema$1;
4370
+
4371
+ // src/formatters/connection.ts
4372
+ var connectionItemFormatter = {
4053
4373
  format: (item) => {
4054
4374
  const details = [];
4055
4375
  if (item.identifier) {
@@ -4074,17 +4394,19 @@ var ConnectionItemSchema = withFormatter(ConnectionItemSchema$1, {
4074
4394
  details
4075
4395
  };
4076
4396
  }
4077
- });
4397
+ };
4078
4398
 
4079
4399
  // src/plugins/listConnections/index.ts
4080
4400
  var listConnectionsPlugin = definePlugin(
4081
4401
  (sdk) => createPaginatedPluginMethod(sdk, {
4402
+ ...zapierPagination,
4082
4403
  name: "listConnections",
4083
4404
  categories: ["connection"],
4084
4405
  type: "list",
4085
4406
  itemType: "Connection",
4086
4407
  inputSchema: ListConnectionsQuerySchema,
4087
4408
  outputSchema: ConnectionItemSchema,
4409
+ formatter: connectionItemFormatter,
4088
4410
  defaultPageSize: DEFAULT_PAGE_SIZE,
4089
4411
  resolvers: { app: appKeyResolver },
4090
4412
  handler: async ({ sdk: sdk2, options }) => {
@@ -4157,8 +4479,7 @@ var listConnectionsPlugin = definePlugin(
4157
4479
  ...response,
4158
4480
  data: response.data.map(transformConnectionItem)
4159
4481
  };
4160
- },
4161
- extractCursor: (response) => extractCursor(response.links)
4482
+ }
4162
4483
  })
4163
4484
  );
4164
4485
  var ListClientCredentialsQuerySchema = ListClientCredentialsQuerySchema$1.omit({
@@ -4172,58 +4493,49 @@ var ListClientCredentialsQuerySchema = ListClientCredentialsQuerySchema$1.omit({
4172
4493
  // SDK specific property for pagination/iterable helpers
4173
4494
  cursor: z.string().optional().describe("Cursor to start from")
4174
4495
  }).describe("List client credentials for the authenticated user");
4175
- var ClientCredentialsItemSchema = withFormatter(
4176
- ClientCredentialsItemSchema$1,
4177
- {
4178
- format: (item) => {
4179
- const details = [];
4180
- if (item.allowed_scopes && item.allowed_scopes.length > 0) {
4181
- details.push({
4182
- text: `Scopes: ${item.allowed_scopes.join(", ")}`,
4183
- style: "accent"
4184
- });
4185
- }
4186
- if (item.created_at) {
4187
- details.push({
4188
- text: `Created: ${new Date(item.created_at).toLocaleDateString()}`,
4189
- style: "dim"
4190
- });
4191
- }
4192
- return {
4193
- title: item.name,
4194
- id: item.client_id,
4195
- details
4196
- };
4496
+ var ClientCredentialsItemSchema = ClientCredentialsItemSchema$1;
4497
+ var ClientCredentialsCreatedItemSchema = ClientCredentialsCreatedItemSchema$1;
4498
+
4499
+ // src/formatters/clientCredentials.ts
4500
+ var clientCredentialsItemFormatter = {
4501
+ format: (item) => {
4502
+ const details = [];
4503
+ if (item.allowed_scopes && item.allowed_scopes.length > 0) {
4504
+ details.push({
4505
+ text: `Scopes: ${item.allowed_scopes.join(", ")}`,
4506
+ style: "accent"
4507
+ });
4197
4508
  }
4198
- }
4199
- );
4200
- var ClientCredentialsCreatedItemSchema = withFormatter(
4201
- ClientCredentialsCreatedItemSchema$1,
4202
- {
4203
- format: (item) => {
4204
- return {
4205
- title: item.name,
4206
- id: item.client_id,
4207
- details: [
4208
- {
4209
- text: `Client Secret: ${item.client_secret}`,
4210
- style: "accent"
4211
- }
4212
- ]
4213
- };
4509
+ if (item.created_at) {
4510
+ details.push({
4511
+ text: `Created: ${new Date(item.created_at).toLocaleDateString()}`,
4512
+ style: "dim"
4513
+ });
4214
4514
  }
4515
+ return { title: item.name, id: item.client_id, details };
4215
4516
  }
4216
- );
4517
+ };
4518
+ var clientCredentialsCreatedItemFormatter = {
4519
+ format: (item) => ({
4520
+ title: item.name,
4521
+ id: item.client_id,
4522
+ details: [
4523
+ { text: `Client Secret: ${item.client_secret}`, style: "accent" }
4524
+ ]
4525
+ })
4526
+ };
4217
4527
 
4218
4528
  // src/plugins/listClientCredentials/index.ts
4219
4529
  var listClientCredentialsPlugin = definePlugin(
4220
4530
  (sdk) => createPaginatedPluginMethod(sdk, {
4531
+ ...zapierPagination,
4221
4532
  name: "listClientCredentials",
4222
4533
  categories: ["client-credentials"],
4223
4534
  type: "list",
4224
4535
  itemType: "ClientCredentials",
4225
4536
  inputSchema: ListClientCredentialsQuerySchema,
4226
4537
  outputSchema: ClientCredentialsItemSchema,
4538
+ formatter: clientCredentialsItemFormatter,
4227
4539
  defaultPageSize: DEFAULT_PAGE_SIZE,
4228
4540
  handler: async ({
4229
4541
  sdk: sdk2,
@@ -4244,8 +4556,7 @@ var listClientCredentialsPlugin = definePlugin(
4244
4556
  requiredScopes: ["credentials"]
4245
4557
  }
4246
4558
  );
4247
- },
4248
- extractCursor: (response) => extractCursor(response.links)
4559
+ }
4249
4560
  })
4250
4561
  );
4251
4562
  var CreateClientCredentialsSchema = CreateClientCredentialsRequestSchema.omit({ allowed_scopes: true }).extend({
@@ -4263,6 +4574,7 @@ var createClientCredentialsPlugin = definePlugin(
4263
4574
  itemType: "ClientCredentials",
4264
4575
  inputSchema: CreateClientCredentialsSchema,
4265
4576
  outputSchema: ClientCredentialsCreatedItemSchema,
4577
+ formatter: clientCredentialsCreatedItemFormatter,
4266
4578
  confirm: "create-secret",
4267
4579
  resolvers: { name: clientCredentialsNameResolver },
4268
4580
  handler: async ({ sdk: sdk2, options }) => {
@@ -4329,6 +4641,7 @@ var getAppPlugin = definePlugin(
4329
4641
  itemType: "App",
4330
4642
  inputSchema: GetAppInputSchema,
4331
4643
  outputSchema: AppItemSchema,
4644
+ formatter: appItemFormatter,
4332
4645
  resolvers: { app: appKeyResolver },
4333
4646
  handler: async ({ sdk: sdk2, options }) => {
4334
4647
  const appKey = "app" in options ? options.app : options.appKey;
@@ -4362,6 +4675,7 @@ var getActionPlugin = definePlugin(
4362
4675
  itemType: "Action",
4363
4676
  inputSchema: GetActionInputSchema,
4364
4677
  outputSchema: ActionItemSchema,
4678
+ formatter: actionItemFormatter,
4365
4679
  resolvers: {
4366
4680
  app: appKeyResolver,
4367
4681
  actionType: actionTypeResolver,
@@ -4408,6 +4722,7 @@ var getConnectionPlugin = definePlugin(
4408
4722
  itemType: "Connection",
4409
4723
  inputSchema: GetConnectionParamSchema,
4410
4724
  outputSchema: ConnectionItemSchema,
4725
+ formatter: connectionItemFormatter,
4411
4726
  resolvers: { connection: connectionIdGenericResolver },
4412
4727
  handler: async ({ sdk: sdk2, options }) => {
4413
4728
  const { api } = sdk2.context;
@@ -4448,6 +4763,7 @@ var findFirstConnectionPlugin = definePlugin(
4448
4763
  itemType: "Connection",
4449
4764
  inputSchema: FindFirstConnectionSchema,
4450
4765
  outputSchema: ConnectionItemSchema,
4766
+ formatter: connectionItemFormatter,
4451
4767
  handler: async ({ sdk: sdk2, options = {} }) => {
4452
4768
  const connectionsResponse = await sdk2.listConnections({
4453
4769
  ...options,
@@ -4483,6 +4799,7 @@ var findUniqueConnectionPlugin = definePlugin(
4483
4799
  itemType: "Connection",
4484
4800
  inputSchema: FindUniqueConnectionSchema,
4485
4801
  outputSchema: ConnectionItemSchema,
4802
+ formatter: connectionItemFormatter,
4486
4803
  handler: async ({ sdk: sdk2, options = {} }) => {
4487
4804
  const connectionsResponse = await sdk2.listConnections({
4488
4805
  ...options,
@@ -4540,6 +4857,29 @@ var RunActionSchemaDeprecated = z.object({
4540
4857
  actionKey: ActionKeyPropertySchema
4541
4858
  }).merge(RunActionBaseSchema);
4542
4859
  var RunActionInputSchema = z.union([RunActionSchema, RunActionSchemaDeprecated]).describe(RunActionDescription);
4860
+
4861
+ // src/formatters/actionResult.ts
4862
+ function getStringProperty(obj, key) {
4863
+ if (typeof obj === "object" && obj !== null && key in obj) {
4864
+ const value = obj[key];
4865
+ return typeof value === "string" ? value : void 0;
4866
+ }
4867
+ return void 0;
4868
+ }
4869
+ var actionResultItemFormatter = {
4870
+ format: (item) => {
4871
+ const obj = typeof item === "object" && item !== null ? item : {};
4872
+ const title = getStringProperty(obj, "title") || getStringProperty(obj, "name") || getStringProperty(obj, "label") || getStringProperty(obj, "subject") || "Action Result";
4873
+ return {
4874
+ title,
4875
+ id: getStringProperty(obj, "id"),
4876
+ key: getStringProperty(obj, "key"),
4877
+ description: getStringProperty(obj, "description"),
4878
+ data: item,
4879
+ details: []
4880
+ };
4881
+ }
4882
+ };
4543
4883
  async function executeAction(actionOptions) {
4544
4884
  const {
4545
4885
  api,
@@ -4669,6 +5009,7 @@ var runActionPlugin = definePlugin(
4669
5009
  itemType: "ActionResult",
4670
5010
  inputSchema: RunActionInputSchema,
4671
5011
  outputSchema: ActionResultItemSchema,
5012
+ formatter: actionResultItemFormatter,
4672
5013
  resolvers: {
4673
5014
  app: appKeyResolver,
4674
5015
  actionType: actionTypeResolver,
@@ -4676,10 +5017,7 @@ var runActionPlugin = definePlugin(
4676
5017
  connection: connectionIdResolver,
4677
5018
  inputs: inputsResolver
4678
5019
  },
4679
- handler: async ({
4680
- sdk: sdk2,
4681
- options
4682
- }) => {
5020
+ handler: async ({ sdk: sdk2, options }) => {
4683
5021
  const { api } = sdk2.context;
4684
5022
  const appKey = "app" in options ? options.app : options.appKey;
4685
5023
  const actionKey = "action" in options ? options.action : options.actionKey;
@@ -4732,7 +5070,9 @@ var runActionPlugin = definePlugin(
4732
5070
  }
4733
5071
  return {
4734
5072
  data: result.results || [],
4735
- nextCursor: result.next_page
5073
+ // Coerce to a string: the API returns a numeric page index, but
5074
+ // `SdkPage.nextCursor` is a string (and the page guard enforces it).
5075
+ nextCursor: result.next_page != null ? String(result.next_page) : void 0
4736
5076
  };
4737
5077
  }
4738
5078
  });
@@ -4762,26 +5102,19 @@ var RelayRequestSchema = z.object({
4762
5102
  var RelayFetchSchema = RelayRequestSchema;
4763
5103
 
4764
5104
  // src/utils/logging.ts
4765
- var loggedDeprecations = /* @__PURE__ */ new Set();
4766
- function logDeprecation(message) {
4767
- if (loggedDeprecations.has(message)) return;
4768
- loggedDeprecations.add(message);
4769
- console.warn(`[zapier-sdk] Deprecation: ${message}`);
4770
- }
4771
- function resetDeprecationWarnings() {
4772
- loggedDeprecations.clear();
4773
- }
5105
+ var { logDeprecation: logDeprecation2, resetDeprecationWarnings: resetDeprecationWarnings2 } = createDeprecationLogger("zapier-sdk");
4774
5106
 
4775
5107
  // src/plugins/request/index.ts
4776
5108
  var requestPlugin = definePlugin(
4777
5109
  (sdk) => createPluginMethod(sdk, {
4778
5110
  name: "request",
4779
5111
  packages: ["cli", "mcp"],
4780
- categories: ["http", "deprecated"],
5112
+ categories: ["http"],
5113
+ deprecation: { message: "Use fetch() instead." },
4781
5114
  returnType: "Response",
4782
5115
  inputSchema: RelayRequestSchema,
4783
5116
  handler: async ({ sdk: sdk2, options }) => {
4784
- logDeprecation("request() is deprecated. Use fetch() instead.");
5117
+ logDeprecation2("request() is deprecated. Use fetch() instead.");
4785
5118
  const {
4786
5119
  url,
4787
5120
  method,
@@ -5001,7 +5334,7 @@ async function listAppsForSlugsPage({
5001
5334
  data: implementationsEnvelope.results.map(
5002
5335
  normalizeImplementationMetaToAppItem
5003
5336
  ),
5004
- nextCursor: extractCursor(implementationsEnvelope)
5337
+ nextCursor: implementationsEnvelope.next ? extractCursorFromUrl(implementationsEnvelope.next) : void 0
5005
5338
  };
5006
5339
  }
5007
5340
  function findManifestEntry({
@@ -5279,36 +5612,36 @@ var manifestPlugin = definePlugin(
5279
5612
  }
5280
5613
  );
5281
5614
  var GetProfileSchema = z.object({}).optional().describe("Get current user's profile information");
5282
- var UserProfileItemSchema = withFormatter(
5283
- z.object({
5284
- id: z.string(),
5285
- first_name: z.string(),
5286
- last_name: z.string(),
5287
- full_name: z.string(),
5288
- email: z.string(),
5289
- email_confirmed: z.boolean(),
5290
- timezone: z.string()
5291
- }),
5292
- {
5293
- format: (item) => {
5294
- const details = [];
5295
- if ("email" in item) {
5296
- details.push({ text: item.email, style: "dim" });
5297
- }
5298
- if ("timezone" in item && item.timezone) {
5299
- details.push({
5300
- text: `Timezone: ${item.timezone}`,
5301
- style: "accent"
5302
- });
5303
- }
5304
- return {
5305
- title: item.full_name,
5306
- id: item.id,
5307
- details
5308
- };
5615
+ var UserProfileItemSchema = z.object({
5616
+ id: z.string(),
5617
+ first_name: z.string(),
5618
+ last_name: z.string(),
5619
+ full_name: z.string(),
5620
+ email: z.string(),
5621
+ email_confirmed: z.boolean(),
5622
+ timezone: z.string()
5623
+ });
5624
+
5625
+ // src/formatters/userProfile.ts
5626
+ var userProfileItemFormatter = {
5627
+ format: (item) => {
5628
+ const details = [];
5629
+ if (item.email) {
5630
+ details.push({ text: item.email, style: "dim" });
5631
+ }
5632
+ if (item.timezone) {
5633
+ details.push({
5634
+ text: `Timezone: ${item.timezone}`,
5635
+ style: "accent"
5636
+ });
5309
5637
  }
5638
+ return {
5639
+ title: item.full_name,
5640
+ id: item.id,
5641
+ details
5642
+ };
5310
5643
  }
5311
- );
5644
+ };
5312
5645
 
5313
5646
  // src/plugins/getProfile/index.ts
5314
5647
  var getProfilePlugin = definePlugin(
@@ -5319,6 +5652,7 @@ var getProfilePlugin = definePlugin(
5319
5652
  itemType: "Profile",
5320
5653
  inputSchema: GetProfileSchema,
5321
5654
  outputSchema: UserProfileItemSchema,
5655
+ formatter: userProfileItemFormatter,
5322
5656
  handler: async ({ sdk: sdk2 }) => {
5323
5657
  const profile = await sdk2.context.api.get(
5324
5658
  "/zapier/api/v4/profile/",
@@ -5415,7 +5749,7 @@ function createDebugLogger(enabled) {
5415
5749
  }
5416
5750
  return (message, data) => {
5417
5751
  if (data === void 0 || data === "") {
5418
- console.log(`[Zapier SDK] ${message}`);
5752
+ console.error(`[Zapier SDK] ${message}`);
5419
5753
  return;
5420
5754
  }
5421
5755
  if (utilModule) {
@@ -5424,9 +5758,9 @@ function createDebugLogger(enabled) {
5424
5758
  depth: null,
5425
5759
  breakLength: 80
5426
5760
  });
5427
- console.log(`[Zapier SDK] ${message}`, formatted);
5761
+ console.error(`[Zapier SDK] ${message}`, formatted);
5428
5762
  } else {
5429
- console.log(`[Zapier SDK] ${message}`, data);
5763
+ console.error(`[Zapier SDK] ${message}`, data);
5430
5764
  }
5431
5765
  };
5432
5766
  }
@@ -5625,7 +5959,8 @@ async function pollUntilComplete(options) {
5625
5959
  pendingStatus = DEFAULT_PENDING_STATUS,
5626
5960
  isPending,
5627
5961
  resultExtractor = (response) => response,
5628
- signal
5962
+ signal,
5963
+ maxPollingIntervalMs
5629
5964
  } = options;
5630
5965
  if (timeoutMs <= 0) {
5631
5966
  throw new ZapierValidationError("Timeout must be greater than 0", {
@@ -5637,6 +5972,14 @@ async function pollUntilComplete(options) {
5637
5972
  details: { initialDelay }
5638
5973
  });
5639
5974
  }
5975
+ if (maxPollingIntervalMs !== void 0 && maxPollingIntervalMs <= 0) {
5976
+ throw new ZapierValidationError(
5977
+ "Max polling interval must be greater than 0",
5978
+ {
5979
+ details: { maxPollingIntervalMs }
5980
+ }
5981
+ );
5982
+ }
5640
5983
  if (signal?.aborted) throw makeAbortError();
5641
5984
  const startTime = Date.now();
5642
5985
  let attempts = 0;
@@ -5659,7 +6002,8 @@ async function pollUntilComplete(options) {
5659
6002
  if (attempts > 0) {
5660
6003
  const interval = getPollingInterval(elapsedTime);
5661
6004
  const waitTime = calculateErrorBackoffMs(interval, errorCount);
5662
- await sleep(waitTime, signal);
6005
+ const cappedWaitTime = maxPollingIntervalMs === void 0 ? waitTime : Math.min(waitTime, maxPollingIntervalMs);
6006
+ await sleep(cappedWaitTime, signal);
5663
6007
  if (signal?.aborted) throw makeAbortError();
5664
6008
  }
5665
6009
  attempts++;
@@ -5942,17 +6286,17 @@ function resolveCredentialsFromEnv(sdkBaseUrl) {
5942
6286
  }
5943
6287
  }
5944
6288
  if (globalThis.process?.env?.ZAPIER_TOKEN) {
5945
- logDeprecation(
6289
+ logDeprecation2(
5946
6290
  "ZAPIER_TOKEN is deprecated. Use ZAPIER_CREDENTIALS instead."
5947
6291
  );
5948
6292
  return globalThis.process?.env?.ZAPIER_TOKEN;
5949
6293
  }
5950
6294
  if (globalThis.process?.env?.ZAPIER_AUTH_CLIENT_ID) {
5951
- logDeprecation(
6295
+ logDeprecation2(
5952
6296
  "ZAPIER_AUTH_CLIENT_ID is deprecated. Use ZAPIER_CREDENTIALS_CLIENT_ID instead."
5953
6297
  );
5954
6298
  if (globalThis.process?.env?.ZAPIER_AUTH_BASE_URL) {
5955
- logDeprecation(
6299
+ logDeprecation2(
5956
6300
  "ZAPIER_AUTH_BASE_URL is deprecated. Use ZAPIER_CREDENTIALS_BASE_URL instead."
5957
6301
  );
5958
6302
  }
@@ -5986,7 +6330,7 @@ async function resolveCredentials(options = {}) {
5986
6330
  return options.credentials;
5987
6331
  }
5988
6332
  if (options.token !== void 0) {
5989
- logDeprecation(
6333
+ logDeprecation2(
5990
6334
  "The `token` option is deprecated. Use `credentials` instead."
5991
6335
  );
5992
6336
  return options.token;
@@ -6228,7 +6572,7 @@ async function tryStoredClientCredentialToken(options) {
6228
6572
  const cached = await readCachedToken(cacheKey, cache);
6229
6573
  if (cached !== void 0) {
6230
6574
  if (options.debug)
6231
- console.log(
6575
+ console.error(
6232
6576
  `[auth] Using cached token (clientId: ${activeCredential.clientId})`
6233
6577
  );
6234
6578
  emitAuthResolved(options.onEvent, "client_credentials");
@@ -6247,7 +6591,7 @@ async function tryStoredClientCredentialToken(options) {
6247
6591
  );
6248
6592
  }
6249
6593
  if (options.debug)
6250
- console.log(
6594
+ console.error(
6251
6595
  `[auth] Using stored client credential (clientId: ${storedCredential.clientId})`
6252
6596
  );
6253
6597
  const token = await resolveAuthTokenFromCredentials(
@@ -6269,7 +6613,7 @@ async function resolveAuthToken(options = {}) {
6269
6613
  const storedToken = await tryStoredClientCredentialToken(options);
6270
6614
  if (storedToken !== void 0) return storedToken;
6271
6615
  if (options.debug) {
6272
- console.log("[auth] Using JWT (no stored client credential found)");
6616
+ console.error("[auth] Using JWT (no stored client credential found)");
6273
6617
  }
6274
6618
  const jwtToken = await getTokenFromCliLogin({
6275
6619
  onEvent: options.onEvent,
@@ -6299,7 +6643,7 @@ async function resolveAuthTokenFromCredentials(credentials, options) {
6299
6643
  const cached = await readCachedToken(cacheKey, cache);
6300
6644
  if (cached !== void 0) {
6301
6645
  if (options.debug) {
6302
- console.log(`[auth] Using cached token (clientId: ${clientId})`);
6646
+ console.error(`[auth] Using cached token (clientId: ${clientId})`);
6303
6647
  }
6304
6648
  return cached;
6305
6649
  }
@@ -6309,7 +6653,7 @@ async function resolveAuthTokenFromCredentials(credentials, options) {
6309
6653
  const recheck = await readCachedToken(cacheKey, cache);
6310
6654
  if (recheck !== void 0) {
6311
6655
  if (options.debug) {
6312
- console.log(
6656
+ console.error(
6313
6657
  `[auth] Using cached token (clientId: ${clientId}, locked recheck)`
6314
6658
  );
6315
6659
  }
@@ -6372,7 +6716,7 @@ async function invalidateCredentialsToken(options) {
6372
6716
  }
6373
6717
 
6374
6718
  // src/sdk-version.ts
6375
- var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.64.0" : void 0) || "unknown";
6719
+ var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.67.0" : void 0) || "unknown";
6376
6720
 
6377
6721
  // src/utils/open-url.ts
6378
6722
  var nodePrefix = "node:";
@@ -6457,6 +6801,7 @@ var PollApprovalResponseSchema = z.object({
6457
6801
  status: ApprovalStatusSchema,
6458
6802
  approval_id: z.string()
6459
6803
  });
6804
+ var APPROVAL_MAX_POLLING_INTERVAL_MS = 5e3;
6460
6805
  function parseRateLimitHeaders(response) {
6461
6806
  const info = {};
6462
6807
  const retryAfter = response.headers.get("retry-after");
@@ -7165,6 +7510,7 @@ var ZapierApiClient = class {
7165
7510
  })
7166
7511
  ),
7167
7512
  timeoutMs,
7513
+ maxPollingIntervalMs: APPROVAL_MAX_POLLING_INTERVAL_MS,
7168
7514
  isPending: (body2) => {
7169
7515
  const parsed = PollApprovalResponseSchema.safeParse(body2);
7170
7516
  return parsed.success && parsed.data.status === "pending_approval";
@@ -7532,6 +7878,7 @@ var tablesDefaults = {
7532
7878
  var listTablesPlugin = definePlugin(
7533
7879
  (sdk) => createPaginatedPluginMethod(sdk, {
7534
7880
  ...tablesDefaults,
7881
+ ...zapierPagination,
7535
7882
  name: "listTables",
7536
7883
  type: "list",
7537
7884
  itemType: "Table",
@@ -7587,8 +7934,7 @@ var listTablesPlugin = definePlugin(
7587
7934
  data: response.data.map(transformTableItem),
7588
7935
  links: response.links
7589
7936
  };
7590
- },
7591
- extractCursor: (response) => extractCursor(response.links)
7937
+ }
7592
7938
  })
7593
7939
  );
7594
7940
  var GetTableApiResponseSchema = z.object({
@@ -7691,6 +8037,15 @@ var deleteTablePlugin = definePlugin(
7691
8037
  })
7692
8038
  );
7693
8039
 
8040
+ // src/formatters/tableField.ts
8041
+ var tableFieldItemFormatter = {
8042
+ format: (item) => ({
8043
+ title: item.name,
8044
+ id: item.id,
8045
+ details: [{ text: `Type: ${item.type}`, style: "dim" }]
8046
+ })
8047
+ };
8048
+
7694
8049
  // src/plugins/tables/listTableFields/index.ts
7695
8050
  var listTableFieldsPlugin = definePlugin(
7696
8051
  (sdk) => createPluginMethod(sdk, {
@@ -7700,6 +8055,7 @@ var listTableFieldsPlugin = definePlugin(
7700
8055
  itemType: "Field",
7701
8056
  inputSchema: ListTableFieldsOptionsInputSchema,
7702
8057
  outputSchema: FieldItemSchema,
8058
+ formatter: tableFieldItemFormatter,
7703
8059
  resolvers: { table: tableIdResolver },
7704
8060
  handler: async ({ sdk: sdk2, options }) => {
7705
8061
  const { api } = sdk2.context;
@@ -7772,6 +8128,7 @@ var createTableFieldsPlugin = definePlugin(
7772
8128
  returnType: "FieldItem[]",
7773
8129
  inputSchema: CreateTableFieldsOptionsInputSchema,
7774
8130
  outputSchema: FieldItemSchema,
8131
+ formatter: tableFieldItemFormatter,
7775
8132
  resolvers: { table: tableIdResolver, fields: tableFieldsResolver },
7776
8133
  handler: async ({ sdk: sdk2, options }) => {
7777
8134
  const tableId = "table" in options ? options.table : options.tableId;
@@ -7850,21 +8207,13 @@ var RecordApiItemSchema = z.object({
7850
8207
  is_source_record: z.boolean().nullable().optional(),
7851
8208
  deleted_at: z.string().nullable().optional()
7852
8209
  });
7853
- var RecordItemSchemaBase = z.object({
8210
+ var RecordItemSchema = z.object({
7854
8211
  id: z.string(),
7855
8212
  data: z.record(z.string(), z.unknown()),
7856
8213
  created_at: z.string(),
7857
8214
  edited_at: z.string(),
7858
8215
  deleted_at: z.string().nullable().optional()
7859
8216
  });
7860
- var RecordItemSchema = withFormatter(RecordItemSchemaBase, {
7861
- format: (item) => ({
7862
- title: `Record ${item.id}`,
7863
- id: item.id,
7864
- data: item.data,
7865
- details: []
7866
- })
7867
- });
7868
8217
  var GetTableRecordApiResponseSchema = z.object({
7869
8218
  data: RecordApiItemSchema
7870
8219
  });
@@ -7888,9 +8237,9 @@ var tableRecordFormatter = {
7888
8237
  if (context) return context;
7889
8238
  const hasFieldIds = Object.keys(item.data).some(isFieldId);
7890
8239
  if (!hasFieldIds) return {};
7891
- const { data: fields } = await sdk.listTableFields({
7892
- table: params.tableId
7893
- });
8240
+ const table = params.table ?? params.tableId;
8241
+ if (!table) return {};
8242
+ const { data: fields } = await sdk.listTableFields({ table });
7894
8243
  return Object.fromEntries(fields.map((f) => [f.id, f.name]));
7895
8244
  },
7896
8245
  format: (item, fieldLabels) => ({
@@ -8015,10 +8364,7 @@ var listTableRecordsPlugin = definePlugin(
8015
8364
  sort: tableSortResolver
8016
8365
  },
8017
8366
  formatter: tableRecordFormatter,
8018
- handler: async ({
8019
- sdk: sdk2,
8020
- options
8021
- }) => {
8367
+ handler: async ({ sdk: sdk2, options }) => {
8022
8368
  const { api } = sdk2.context;
8023
8369
  const tableId = "table" in options ? options.table : options.tableId;
8024
8370
  const translator = await createFieldKeyTranslator({
@@ -8268,85 +8614,13 @@ var updateTableRecordsPlugin = definePlugin(
8268
8614
  }
8269
8615
  })
8270
8616
  );
8271
- function canonicalInputSchema(schema) {
8272
- if (schema instanceof z.ZodUnion) {
8273
- return schema.options[0];
8274
- }
8275
- return schema;
8276
- }
8277
- var categoryDefinitions = {
8278
- account: { title: "Account" },
8279
- app: { title: "App", titlePlural: "Apps" },
8280
- connection: { title: "Connection" },
8281
- action: { title: "Action" },
8282
- "client-credentials": {
8283
- title: "Client Credentials",
8284
- titlePlural: "Client Credentials"
8285
- },
8286
- table: { title: "Table" },
8287
- trigger: { title: "Trigger" },
8288
- "code-workflow": {
8289
- title: "Code Workflow",
8290
- titlePlural: "Code Workflows"
8291
- },
8292
- http: { title: "HTTP Request" },
8293
- utility: { title: "Utility", titlePlural: "Utilities" },
8294
- other: { title: "Other" }
8295
- };
8296
- var knownCategories = Object.keys(categoryDefinitions);
8297
- function buildRegistry({
8298
- sdk,
8299
- meta,
8300
- packageFilter
8301
- }) {
8302
- const functions = Object.keys(meta).filter((key) => {
8303
- const property = sdk[key];
8304
- if (typeof property === "function") return true;
8305
- const [rootKey] = key.split(".");
8306
- const rootProperty = sdk[rootKey];
8307
- return typeof rootProperty === "object" && rootProperty !== null;
8308
- }).map((key) => {
8309
- const m = meta[key];
8310
- return {
8311
- name: key,
8312
- description: m.description,
8313
- type: m.type,
8314
- itemType: m.itemType,
8315
- returnType: m.returnType,
8316
- inputSchema: canonicalInputSchema(m.inputSchema),
8317
- inputParameters: m.inputParameters,
8318
- outputSchema: m.outputSchema,
8319
- categories: m.categories || [],
8320
- resolvers: m.resolvers,
8321
- formatter: m.formatter,
8322
- experimental: m.experimental,
8323
- packages: m.packages,
8324
- confirm: m.confirm ?? (m.type === "delete" ? "delete" : void 0),
8325
- deprecation: m.deprecation,
8326
- aliases: m.aliases,
8327
- supportsJsonOutput: m.supportsJsonOutput ?? true
8328
- };
8329
- }).sort((a, b) => a.name.localeCompare(b.name));
8330
- const filteredFunctions = packageFilter ? functions.filter((f) => !f.packages || f.packages.includes(packageFilter)) : functions;
8331
- const filteredCategories = knownCategories.slice().sort((a, b) => {
8332
- if (a === "other") return 1;
8333
- if (b === "other") return -1;
8334
- return categoryDefinitions[a].title.localeCompare(
8335
- categoryDefinitions[b].title
8336
- );
8337
- }).map((categoryKey) => {
8338
- const categoryFunctions = filteredFunctions.filter(
8339
- (f) => f.categories.includes(categoryKey) || categoryKey === "other" && !f.categories.some((c) => knownCategories.includes(c))
8340
- ).map((f) => f.name).sort();
8341
- const definition = categoryDefinitions[categoryKey];
8342
- return {
8343
- key: categoryKey,
8344
- title: definition.title,
8345
- titlePlural: definition.titlePlural ?? `${definition.title}s`,
8346
- functions: categoryFunctions
8347
- };
8348
- }).filter((category) => category.functions.length > 0);
8349
- return { functions: filteredFunctions, categories: filteredCategories };
8617
+
8618
+ // src/core-stack.ts
8619
+ var zapierCorePlugin = createCorePlugin({
8620
+ adaptError: zapierAdaptError
8621
+ });
8622
+ function createZapierCoreStack() {
8623
+ return createPluginStack().use(zapierCorePlugin);
8350
8624
  }
8351
8625
 
8352
8626
  // src/plugins/deprecated/authentications.ts
@@ -8357,11 +8631,13 @@ var listAuthenticationsPlugin = definePlugin(
8357
8631
  meta: {
8358
8632
  listAuthentications: {
8359
8633
  packages: ["cli", "mcp"],
8360
- categories: ["connection", "deprecated"],
8634
+ categories: ["connection"],
8635
+ deprecation: { message: "Use listConnections instead." },
8361
8636
  type: "list",
8362
8637
  itemType: "Connection",
8363
8638
  inputSchema: ListConnectionsQuerySchema,
8364
- outputSchema: ConnectionItemSchema
8639
+ outputSchema: ConnectionItemSchema,
8640
+ formatter: connectionItemFormatter
8365
8641
  }
8366
8642
  }
8367
8643
  }
@@ -8374,11 +8650,13 @@ var getAuthenticationPlugin = definePlugin(
8374
8650
  meta: {
8375
8651
  getAuthentication: {
8376
8652
  packages: ["cli", "mcp"],
8377
- categories: ["connection", "deprecated"],
8653
+ categories: ["connection"],
8654
+ deprecation: { message: "Use getConnection instead." },
8378
8655
  type: "item",
8379
8656
  itemType: "Connection",
8380
8657
  inputSchema: GetConnectionParamSchema,
8381
- outputSchema: ConnectionItemSchema
8658
+ outputSchema: ConnectionItemSchema,
8659
+ formatter: connectionItemFormatter
8382
8660
  }
8383
8661
  }
8384
8662
  }
@@ -8391,11 +8669,13 @@ var findFirstAuthenticationPlugin = definePlugin(
8391
8669
  meta: {
8392
8670
  findFirstAuthentication: {
8393
8671
  packages: ["cli", "mcp"],
8394
- categories: ["connection", "deprecated"],
8672
+ categories: ["connection"],
8673
+ deprecation: { message: "Use findFirstConnection instead." },
8395
8674
  type: "item",
8396
8675
  itemType: "Connection",
8397
8676
  inputSchema: FindFirstConnectionSchema,
8398
- outputSchema: ConnectionItemSchema
8677
+ outputSchema: ConnectionItemSchema,
8678
+ formatter: connectionItemFormatter
8399
8679
  }
8400
8680
  }
8401
8681
  }
@@ -8408,11 +8688,13 @@ var findUniqueAuthenticationPlugin = definePlugin(
8408
8688
  meta: {
8409
8689
  findUniqueAuthentication: {
8410
8690
  packages: ["cli", "mcp"],
8411
- categories: ["connection", "deprecated"],
8691
+ categories: ["connection"],
8692
+ deprecation: { message: "Use findUniqueConnection instead." },
8412
8693
  type: "item",
8413
8694
  itemType: "Connection",
8414
8695
  inputSchema: FindUniqueConnectionSchema,
8415
- outputSchema: ConnectionItemSchema
8696
+ outputSchema: ConnectionItemSchema,
8697
+ formatter: connectionItemFormatter
8416
8698
  }
8417
8699
  }
8418
8700
  }
@@ -8426,11 +8708,13 @@ var listInputFieldsDeprecatedPlugin = definePlugin(
8426
8708
  context: {
8427
8709
  meta: {
8428
8710
  listInputFields: {
8429
- categories: ["action", "deprecated"],
8711
+ categories: ["action"],
8712
+ deprecation: { message: "Use listActionInputFields instead." },
8430
8713
  type: "list",
8431
8714
  itemType: "RootField",
8432
8715
  inputSchema: ListActionInputFieldsInputSchema,
8433
8716
  outputSchema: RootFieldItemSchema,
8717
+ formatter: rootFieldItemFormatter,
8434
8718
  defaultPageSize: DEFAULT_PAGE_SIZE
8435
8719
  }
8436
8720
  }
@@ -8443,11 +8727,15 @@ var listInputFieldChoicesDeprecatedPlugin = definePlugin(
8443
8727
  context: {
8444
8728
  meta: {
8445
8729
  listInputFieldChoices: {
8446
- categories: ["action", "deprecated"],
8730
+ categories: ["action"],
8731
+ deprecation: {
8732
+ message: "Use listActionInputFieldChoices instead."
8733
+ },
8447
8734
  type: "list",
8448
8735
  itemType: "InputFieldChoiceItem",
8449
8736
  inputSchema: ListActionInputFieldChoicesInputSchema,
8450
8737
  outputSchema: InputFieldChoiceItemSchema,
8738
+ formatter: inputFieldChoiceItemFormatter,
8451
8739
  defaultPageSize: DEFAULT_PAGE_SIZE
8452
8740
  }
8453
8741
  }
@@ -8460,7 +8748,8 @@ var getInputFieldsSchemaDeprecatedPlugin = definePlugin(
8460
8748
  context: {
8461
8749
  meta: {
8462
8750
  getInputFieldsSchema: {
8463
- categories: ["action", "deprecated"],
8751
+ categories: ["action"],
8752
+ deprecation: { message: "Use getActionInputFieldsSchema instead." },
8464
8753
  type: "function",
8465
8754
  inputSchema: GetActionInputFieldsSchemaInputSchema
8466
8755
  }
@@ -8524,7 +8813,7 @@ function createConsoleTransport() {
8524
8813
  return {
8525
8814
  async emit(subject, event) {
8526
8815
  try {
8527
- console.log(
8816
+ console.error(
8528
8817
  "[SDK Telemetry]",
8529
8818
  JSON.stringify({ subject, properties: event }, null, 2)
8530
8819
  );
@@ -8733,6 +9022,35 @@ function buildMethodCalledEvent(data, context = {}) {
8733
9022
  };
8734
9023
  }
8735
9024
 
9025
+ // src/plugins/eventEmission/event-emission-hook.ts
9026
+ function computeArgumentCount(args) {
9027
+ if (args.length === 1) {
9028
+ const arg0 = args[0];
9029
+ if (arg0 !== null && typeof arg0 === "object" && !Array.isArray(arg0) && Object.getPrototypeOf(arg0) === Object.prototype) {
9030
+ return Object.keys(arg0).length;
9031
+ }
9032
+ }
9033
+ return args.filter((a) => a !== void 0).length;
9034
+ }
9035
+ function makeMethodEndHook(emitMethodCalled) {
9036
+ return ({ methodName, args, isPaginated, depth, durationMs, error }) => {
9037
+ if (depth > 0) return;
9038
+ const metadata = getMethodMetadata();
9039
+ emitMethodCalled({
9040
+ method_name: methodName,
9041
+ execution_duration_ms: durationMs,
9042
+ success_flag: !error,
9043
+ error_message: error?.message ?? null,
9044
+ error_type: error?.constructor.name ?? null,
9045
+ argument_count: computeArgumentCount(args),
9046
+ is_paginated: isPaginated,
9047
+ selected_api: metadata?.selectedApi ?? null,
9048
+ operation_type: metadata?.operationType ?? null,
9049
+ operation_key: metadata?.operationKey ?? null
9050
+ });
9051
+ };
9052
+ }
9053
+
8736
9054
  // src/plugins/eventEmission/index.ts
8737
9055
  var TELEMETRY_EMIT_TIMEOUT_MS = 300;
8738
9056
  var registeredListeners = {};
@@ -8863,6 +9181,8 @@ var eventEmissionPlugin = definePlugin(
8863
9181
  }
8864
9182
  }
8865
9183
  if (!config.enabled) {
9184
+ const noopEmitMethodCalled = () => {
9185
+ };
8866
9186
  return {
8867
9187
  context: {
8868
9188
  eventEmission: {
@@ -8880,12 +9200,13 @@ var eventEmissionPlugin = definePlugin(
8880
9200
  visitor_id: null,
8881
9201
  correlation_id: null
8882
9202
  }),
8883
- emitMethodCalled: () => {
8884
- },
8885
9203
  flush: async () => {
8886
9204
  },
8887
9205
  close: async () => {
8888
9206
  }
9207
+ },
9208
+ hooks: {
9209
+ onMethodEnd: makeMethodEndHook(noopEmitMethodCalled)
8889
9210
  }
8890
9211
  }
8891
9212
  };
@@ -9056,6 +9377,20 @@ var eventEmissionPlugin = definePlugin(
9056
9377
  );
9057
9378
  removeExistingListeners();
9058
9379
  };
9380
+ const emitMethodCalled = (data) => {
9381
+ const event = {
9382
+ ...buildMethodCalledEvent(data),
9383
+ call_context: config.callContext ?? "sdk"
9384
+ };
9385
+ trackEmission(
9386
+ silentEmit(
9387
+ transport,
9388
+ METHOD_CALLED_EVENT_SUBJECT,
9389
+ event,
9390
+ getUserContext
9391
+ )
9392
+ );
9393
+ };
9059
9394
  return {
9060
9395
  context: {
9061
9396
  eventEmission: {
@@ -9067,22 +9402,11 @@ var eventEmissionPlugin = definePlugin(
9067
9402
  );
9068
9403
  },
9069
9404
  createBaseEvent: createBaseEventHelper,
9070
- emitMethodCalled: (data) => {
9071
- const event = {
9072
- ...buildMethodCalledEvent(data),
9073
- call_context: config.callContext ?? "sdk"
9074
- };
9075
- trackEmission(
9076
- silentEmit(
9077
- transport,
9078
- METHOD_CALLED_EVENT_SUBJECT,
9079
- event,
9080
- getUserContext
9081
- )
9082
- );
9083
- },
9084
9405
  flush,
9085
9406
  close
9407
+ },
9408
+ hooks: {
9409
+ onMethodEnd: makeMethodEndHook(emitMethodCalled)
9086
9410
  }
9087
9411
  }
9088
9412
  };
@@ -9094,78 +9418,22 @@ function createOptionsPlugin(options) {
9094
9418
  return () => ({ context: { options } });
9095
9419
  }
9096
9420
  function createSdk() {
9097
- return buildSdk({}, { meta: {} });
9098
- }
9099
- function buildSdk(properties, context) {
9100
- const frozenContext = Object.freeze(context);
9101
- const registryCache = /* @__PURE__ */ new Map();
9102
- const sdk = {
9103
- ...properties,
9104
- get context() {
9105
- return frozenContext;
9106
- },
9107
- getContext: () => frozenContext,
9108
- // runtime compat shim, not in types
9109
- getRegistry(options) {
9110
- const cacheKey = options?.package ?? "__all__";
9111
- if (!registryCache.has(cacheKey)) {
9112
- registryCache.set(
9113
- cacheKey,
9114
- buildRegistry({
9115
- sdk,
9116
- meta: frozenContext.meta,
9117
- packageFilter: options?.package
9118
- })
9119
- );
9120
- }
9121
- return registryCache.get(cacheKey);
9122
- },
9123
- addPlugin(plugin, options) {
9124
- const pluginResult = plugin({
9125
- ...properties,
9126
- context: frozenContext
9127
- });
9128
- const { context: pluginContext, ...pluginProperties } = pluginResult;
9129
- const { meta: pluginMeta, ...pluginContextRest } = pluginContext ?? {};
9130
- const existingProperties = properties;
9131
- const existingContext = context;
9132
- const existingMeta = context.meta ?? {};
9133
- const collisions = [];
9134
- for (const key of Object.keys(pluginProperties)) {
9135
- if (key in existingProperties) collisions.push(`method "${key}"`);
9136
- }
9137
- for (const key of Object.keys(pluginContextRest)) {
9138
- if (key in existingContext) collisions.push(`context.${key}`);
9139
- }
9140
- if (collisions.length > 0 && !options?.override) {
9141
- const name = plugin.name || "anonymous plugin";
9142
- console.warn(
9143
- `[zapier-sdk] Skipping "${name}" \u2014 duplicate registration of: ${collisions.join(", ")}. If the duplicate is intentional, pass { override: true } to addPlugin or wrap with composePlugins(...). Otherwise rename the method or remove the duplicate.`
9144
- );
9145
- return buildSdk(properties, context);
9146
- }
9147
- const mergedProperties = { ...properties, ...pluginProperties };
9148
- const mergedContext = {
9149
- ...context,
9150
- ...pluginContextRest,
9151
- meta: { ...existingMeta, ...pluginMeta ?? {} }
9152
- };
9153
- return buildSdk(
9154
- mergedProperties,
9155
- mergedContext
9156
- );
9157
- }
9158
- };
9159
- return sdk;
9421
+ logDeprecation2(
9422
+ "createSdk() is deprecated. Build SDKs with createPluginStack().use(...).toSdk() instead. The chain pattern shares plugin closures (and their state) across derived SDKs in ways that are rarely what callers expect; stacks produce fresh closures per .toSdk() call."
9423
+ );
9424
+ return withDeprecatedAddPlugin(createZapierCoreStack().toSdk());
9160
9425
  }
9161
9426
  function createZapierSdkWithoutRegistry(options = {}) {
9162
- logDeprecation(
9427
+ logDeprecation2(
9163
9428
  "createZapierSdkWithoutRegistry is deprecated; use createZapierSdk instead. getRegistry is now available on every sdk."
9164
9429
  );
9165
9430
  return createZapierSdk(options);
9166
9431
  }
9432
+ function createZapierSdkStack(options = {}) {
9433
+ return createZapierCoreStack().use(createOptionsPlugin(options)).use(eventEmissionPlugin).use(apiPlugin).use(manifestPlugin).use(capabilitiesPlugin).use(connectionsPlugin).use(listAppsPlugin).use(getAppPlugin).use(listConnectionsPlugin).use(getConnectionPlugin).use(findFirstConnectionPlugin).use(findUniqueConnectionPlugin).use(listActionsPlugin).use(getActionPlugin).use(listActionInputFieldsPlugin).use(getActionInputFieldsSchemaPlugin).use(listActionInputFieldChoicesPlugin).use(listInputFieldsDeprecatedPlugin).use(getInputFieldsSchemaDeprecatedPlugin).use(listInputFieldChoicesDeprecatedPlugin).use(runActionPlugin).use(listAuthenticationsPlugin).use(getAuthenticationPlugin).use(findFirstAuthenticationPlugin).use(findUniqueAuthenticationPlugin).use(listClientCredentialsPlugin).use(createClientCredentialsPlugin).use(deleteClientCredentialsPlugin).use(fetchPlugin).use(requestPlugin).use(listTablesPlugin).use(getTablePlugin).use(deleteTablePlugin).use(createTablePlugin).use(listTableFieldsPlugin).use(createTableFieldsPlugin).use(deleteTableFieldsPlugin).use(listTableRecordsPlugin).use(getTableRecordPlugin).use(createTableRecordsPlugin).use(deleteTableRecordsPlugin).use(updateTableRecordsPlugin).use(appsPlugin).use(getProfilePlugin);
9434
+ }
9167
9435
  function createZapierSdk(options = {}) {
9168
- return createSdk().addPlugin(createOptionsPlugin(options)).addPlugin(eventEmissionPlugin).addPlugin(apiPlugin).addPlugin(manifestPlugin).addPlugin(capabilitiesPlugin).addPlugin(connectionsPlugin).addPlugin(listAppsPlugin).addPlugin(getAppPlugin).addPlugin(listActionsPlugin).addPlugin(getActionPlugin).addPlugin(listActionInputFieldsPlugin).addPlugin(getActionInputFieldsSchemaPlugin).addPlugin(listActionInputFieldChoicesPlugin).addPlugin(listInputFieldsDeprecatedPlugin).addPlugin(getInputFieldsSchemaDeprecatedPlugin).addPlugin(listInputFieldChoicesDeprecatedPlugin).addPlugin(runActionPlugin).addPlugin(listConnectionsPlugin).addPlugin(getConnectionPlugin).addPlugin(findFirstConnectionPlugin).addPlugin(findUniqueConnectionPlugin).addPlugin(listAuthenticationsPlugin).addPlugin(getAuthenticationPlugin).addPlugin(findFirstAuthenticationPlugin).addPlugin(findUniqueAuthenticationPlugin).addPlugin(listClientCredentialsPlugin).addPlugin(createClientCredentialsPlugin).addPlugin(deleteClientCredentialsPlugin).addPlugin(fetchPlugin).addPlugin(requestPlugin).addPlugin(listTablesPlugin).addPlugin(getTablePlugin).addPlugin(deleteTablePlugin).addPlugin(createTablePlugin).addPlugin(listTableFieldsPlugin).addPlugin(createTableFieldsPlugin).addPlugin(deleteTableFieldsPlugin).addPlugin(getTableRecordPlugin).addPlugin(listTableRecordsPlugin).addPlugin(createTableRecordsPlugin).addPlugin(deleteTableRecordsPlugin).addPlugin(updateTableRecordsPlugin).addPlugin(appsPlugin).addPlugin(getProfilePlugin);
9436
+ return withDeprecatedAddPlugin(createZapierSdkStack(options).toSdk());
9169
9437
  }
9170
9438
  var BaseSdkOptionsSchema = z.object({
9171
9439
  credentials: CredentialsSchema.optional().describe(
@@ -9228,10 +9496,10 @@ var BaseSdkOptionsSchema = z.object({
9228
9496
 
9229
9497
  // src/plugins/registry/index.ts
9230
9498
  var registryPlugin = definePlugin((_sdk) => {
9231
- logDeprecation(
9499
+ logDeprecation2(
9232
9500
  "registryPlugin is deprecated and a no-op; getRegistry is now built into every sdk. Remove .addPlugin(registryPlugin)."
9233
9501
  );
9234
9502
  return {};
9235
9503
  });
9236
9504
 
9237
- export { ActionKeyPropertySchema, ActionPropertySchema, ActionTimeoutMsPropertySchema, ActionTypePropertySchema, AppKeyPropertySchema, AppPropertySchema, AppsPropertySchema, AuthenticationIdPropertySchema, BaseSdkOptionsSchema, CONTEXT_CACHE_MAX_SIZE, CONTEXT_CACHE_TTL_MS, ClientCredentialsObjectSchema, ConnectionEntrySchema, ConnectionIdPropertySchema, ConnectionPropertySchema, ConnectionsMapSchema, ConnectionsPropertySchema, CredentialsFunctionSchema, CredentialsObjectSchema, CredentialsSchema, DEFAULT_ACTION_TIMEOUT_MS, DEFAULT_APPROVAL_TIMEOUT_MS, DEFAULT_CONFIG_PATH, DEFAULT_MAX_APPROVAL_RETRIES, DEFAULT_PAGE_SIZE, DebugPropertySchema, FieldsPropertySchema, InputFieldPropertySchema, InputsPropertySchema, LeaseLimitPropertySchema, LeasePropertySchema, LeaseSecondsPropertySchema, LimitPropertySchema, MAX_CONCURRENCY_LIMIT, MAX_PAGE_LIMIT, OffsetPropertySchema, OutputPropertySchema, ParamsPropertySchema, PkceCredentialsObjectSchema, RecordPropertySchema, RecordsPropertySchema, RelayFetchSchema, RelayRequestSchema, ResolvedCredentialsSchema, TablePropertySchema, TablesPropertySchema, TriggerInboxNamePropertySchema, TriggerInboxPropertySchema, ZAPIER_BASE_URL, ZAPIER_MAX_CONCURRENT_REQUESTS, ZAPIER_MAX_NETWORK_RETRIES, ZAPIER_MAX_NETWORK_RETRY_DELAY_MS, ZapierAbortDrainSignal, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierApprovalError, ZapierAuthenticationError, ZapierBundleError, ZapierConfigurationError, ZapierConflictError, ZapierError, ZapierNotFoundError, ZapierRateLimitError, ZapierRelayError, ZapierReleaseTriggerMessageSignal, ZapierResourceNotFoundError, ZapierSignal, ZapierTimeoutError, ZapierUnknownError, ZapierValidationError, actionKeyResolver, actionTypeResolver, apiPlugin, appKeyResolver, appsPlugin, connectionIdGenericResolver as authenticationIdGenericResolver, connectionIdResolver as authenticationIdResolver, batch, buildApplicationLifecycleEvent, buildCapabilityMessage, buildErrorEvent, buildErrorEventWithContext, buildMethodCalledEvent, cleanupEventListeners, clearTokenCache, clientCredentialsNameResolver, clientIdResolver, composePlugins, connectionIdGenericResolver, connectionIdResolver, connectionsPlugin, createBaseEvent, createClientCredentialsPlugin, createFunction, createMemoryCache, createOptionsPlugin, createPaginatedPluginMethod, createPluginMethod, createSdk, createTableFieldsPlugin, createTablePlugin, createTableRecordsPlugin, createZapierApi, createZapierSdk, createZapierSdkWithoutRegistry, definePlugin, deleteClientCredentialsPlugin, deleteTableFieldsPlugin, deleteTablePlugin, deleteTableRecordsPlugin, durableRunIdResolver, eventEmissionPlugin, fetchPlugin, findFirstConnectionPlugin, findManifestEntry, findUniqueConnectionPlugin, formatErrorMessage, generateEventId, getActionInputFieldsSchemaPlugin, getActionPlugin, getAppPlugin, getBaseUrlFromCredentials, getCiPlatform, getClientIdFromCredentials, getConnectionPlugin, getCpuTime, getCurrentTimestamp, getMemoryUsage, getOrCreateApiClient, getOsInfo, getPlatformVersions, getPreferredManifestEntryKey, getProfilePlugin, getReleaseId, getTablePlugin, getTableRecordPlugin, getTokenFromCliLogin, getZapierApprovalMode, getZapierDefaultApprovalMode, getZapierSdkService, injectCliLogin, inputFieldKeyResolver, inputsAllOptionalResolver, inputsResolver, invalidateCachedToken, invalidateCredentialsToken, isCi, isCliLoginAvailable, isClientCredentials, isCredentialsFunction, isCredentialsObject, isPkceCredentials, isPositional, listActionInputFieldChoicesPlugin, listActionInputFieldsPlugin, listActionsPlugin, listAppsPlugin, listClientCredentialsPlugin, listConnectionsPlugin, listTableFieldsPlugin, listTableRecordsPlugin, listTablesPlugin, logDeprecation, manifestPlugin, parseConcurrencyEnvVar, readManifestFromFile, registryPlugin, requestPlugin, resetDeprecationWarnings, resolveAuthToken, resolveCredentials, resolveCredentialsFromEnv, runActionPlugin, runWithTelemetryContext, tableFieldIdsResolver, tableFieldsResolver, tableFiltersResolver, tableIdResolver, tableNameResolver, tableRecordIdResolver, tableRecordIdsResolver, tableRecordsResolver, tableSortResolver, tableUpdateRecordsResolver, toSnakeCase, toTitleCase, triggerInboxResolver, triggerMessagesResolver, updateTableRecordsPlugin, workflowIdResolver, workflowVersionIdResolver };
9505
+ export { ActionKeyPropertySchema, ActionPropertySchema, ActionTimeoutMsPropertySchema, ActionTypePropertySchema, AppKeyPropertySchema, AppPropertySchema, AppsPropertySchema, AuthenticationIdPropertySchema, BaseSdkOptionsSchema, CONTEXT_CACHE_MAX_SIZE, CONTEXT_CACHE_TTL_MS, CORE_ERROR_SYMBOL, ClientCredentialsObjectSchema, ConnectionEntrySchema, ConnectionIdPropertySchema, ConnectionPropertySchema, ConnectionsMapSchema, ConnectionsPropertySchema, CoreErrorCode, CredentialsFunctionSchema, CredentialsObjectSchema, CredentialsSchema, DEFAULT_ACTION_TIMEOUT_MS, DEFAULT_APPROVAL_TIMEOUT_MS, DEFAULT_CONFIG_PATH, DEFAULT_MAX_APPROVAL_RETRIES, DEFAULT_PAGE_SIZE, DebugPropertySchema, FieldsPropertySchema, InputFieldPropertySchema, InputsPropertySchema, LeaseLimitPropertySchema, LeasePropertySchema, LeaseSecondsPropertySchema, LimitPropertySchema, MAX_CONCURRENCY_LIMIT, MAX_PAGE_LIMIT, OffsetPropertySchema, OutputPropertySchema, ParamsPropertySchema, PkceCredentialsObjectSchema, RecordPropertySchema, RecordsPropertySchema, RelayFetchSchema, RelayRequestSchema, ResolvedCredentialsSchema, TablePropertySchema, TablesPropertySchema, TriggerInboxNamePropertySchema, TriggerInboxPropertySchema, ZAPIER_BASE_URL, ZAPIER_MAX_CONCURRENT_REQUESTS, ZAPIER_MAX_NETWORK_RETRIES, ZAPIER_MAX_NETWORK_RETRY_DELAY_MS, ZapierAbortDrainSignal, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierApprovalError, ZapierAuthenticationError, ZapierBundleError, ZapierConfigurationError, ZapierConflictError, ZapierError, ZapierNotFoundError, ZapierRateLimitError, ZapierRelayError, ZapierReleaseTriggerMessageSignal, ZapierResourceNotFoundError, ZapierSignal, ZapierTimeoutError, ZapierUnknownError, ZapierValidationError, actionKeyResolver, actionTypeResolver, addPlugin, apiPlugin, appKeyResolver, appsPlugin, connectionIdGenericResolver as authenticationIdGenericResolver, connectionIdResolver as authenticationIdResolver, batch, buildApplicationLifecycleEvent, buildCapabilityMessage, buildErrorEvent, buildErrorEventWithContext, buildMethodCalledEvent, cleanupEventListeners, clearTokenCache, clientCredentialsNameResolver, clientIdResolver, composePlugins, connectionIdGenericResolver, connectionIdResolver, connectionsPlugin, createBaseEvent, createClientCredentialsPlugin, createCorePlugin, createFunction, createMemoryCache, createOptionsPlugin, createPaginatedPluginMethod, createPluginMethod, createPluginStack, createSdk, createTableFieldsPlugin, createTablePlugin, createTableRecordsPlugin, createZapierApi, createZapierCoreStack, createZapierSdk, createZapierSdkStack, createZapierSdkWithoutRegistry, definePlugin, deleteClientCredentialsPlugin, deleteTableFieldsPlugin, deleteTablePlugin, deleteTableRecordsPlugin, durableRunIdResolver, eventEmissionPlugin, fetchPlugin, findFirstConnectionPlugin, findManifestEntry, findUniqueConnectionPlugin, formatErrorMessage, generateEventId, getActionInputFieldsSchemaPlugin, getActionPlugin, getAppPlugin, getBaseUrlFromCredentials, getCiPlatform, getClientIdFromCredentials, getConnectionPlugin, getCoreErrorCause, getCoreErrorCode, getCpuTime, getCurrentTimestamp, getMemoryUsage, getOrCreateApiClient, getOsInfo, getPlatformVersions, getPreferredManifestEntryKey, getProfilePlugin, getReleaseId, getTablePlugin, getTableRecordPlugin, getTokenFromCliLogin, getZapierApprovalMode, getZapierDefaultApprovalMode, getZapierSdkService, injectCliLogin, inputFieldKeyResolver, inputsAllOptionalResolver, inputsResolver, invalidateCachedToken, invalidateCredentialsToken, isCi, isCliLoginAvailable, isClientCredentials, isCoreError, isCredentialsFunction, isCredentialsObject, isPkceCredentials, isPositional, listActionInputFieldChoicesPlugin, listActionInputFieldsPlugin, listActionsPlugin, listAppsPlugin, listClientCredentialsPlugin, listConnectionsPlugin, listTableFieldsPlugin, listTableRecordsPlugin, listTablesPlugin, logDeprecation2 as logDeprecation, manifestPlugin, parseConcurrencyEnvVar, readManifestFromFile, registryPlugin, requestPlugin, resetDeprecationWarnings2 as resetDeprecationWarnings, resolveAuthToken, resolveCredentials, resolveCredentialsFromEnv, runActionPlugin, runInMethodScope, runWithTelemetryContext, tableFieldIdsResolver, tableFieldsResolver, tableFiltersResolver, tableIdResolver, tableNameResolver, tableRecordIdResolver, tableRecordIdsResolver, tableRecordsResolver, tableSortResolver, tableUpdateRecordsResolver, toSnakeCase, toTitleCase, triggerInboxResolver, triggerMessagesResolver, updateTableRecordsPlugin, workflowIdResolver, workflowRunIdResolver, workflowVersionIdResolver, zapierAdaptError };