@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
@@ -13,37 +13,64 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
13
13
  if (typeof require !== "undefined") return require.apply(this, arguments);
14
14
  throw Error('Dynamic require of "' + x + '" is not supported');
15
15
  });
16
+ function toTitleCase(input) {
17
+ 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(" ");
18
+ }
19
+ function toSnakeCase(input) {
20
+ let result = input.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/[\s\-]+/g, "_").replace(/_+/g, "_").replace(/^_|_$/g, "").toLowerCase();
21
+ if (/^[0-9]/.test(result)) {
22
+ result = "_" + result;
23
+ }
24
+ return result;
25
+ }
26
+ function pluralize(word) {
27
+ if (/s$/i.test(word)) return word;
28
+ if (/[bcdfghjklmnpqrstvwxz]y$/i.test(word)) {
29
+ return word.slice(0, -1) + "ies";
30
+ }
31
+ return word + "s";
32
+ }
33
+ function pluralizeLastWord(title) {
34
+ const words = title.split(" ");
35
+ return [...words.slice(0, -1), pluralize(words[words.length - 1])].join(" ");
36
+ }
37
+ function resolveCategoryDefinition(ref) {
38
+ const def = typeof ref === "string" ? { key: ref } : ref;
39
+ const title = def.title ?? toTitleCase(def.key);
40
+ return {
41
+ key: def.key,
42
+ title,
43
+ titlePlural: def.titlePlural ?? pluralizeLastWord(title)
44
+ };
45
+ }
16
46
  function canonicalInputSchema(schema) {
17
47
  if (schema instanceof zod.z.ZodUnion) {
18
48
  return schema.options[0];
19
49
  }
20
50
  return schema;
21
51
  }
22
- var categoryDefinitions = {
23
- account: { title: "Account" },
24
- app: { title: "App", titlePlural: "Apps" },
25
- connection: { title: "Connection" },
26
- action: { title: "Action" },
27
- "client-credentials": {
28
- title: "Client Credentials",
29
- titlePlural: "Client Credentials"
30
- },
31
- table: { title: "Table" },
32
- trigger: { title: "Trigger" },
33
- "code-workflow": {
34
- title: "Code Workflow",
35
- titlePlural: "Code Workflows"
36
- },
37
- http: { title: "HTTP Request" },
38
- utility: { title: "Utility", titlePlural: "Utilities" },
39
- other: { title: "Other" }
40
- };
41
- var knownCategories = Object.keys(categoryDefinitions);
42
52
  function buildRegistry({
43
53
  sdk,
44
54
  meta,
45
55
  packageFilter
46
56
  }) {
57
+ const definitionsByKey = /* @__PURE__ */ new Map();
58
+ const objectDeclaredKeys = /* @__PURE__ */ new Set();
59
+ for (const m of Object.values(meta)) {
60
+ for (const ref of m.categories ?? []) {
61
+ const key = typeof ref === "string" ? ref : ref.key;
62
+ if (typeof ref === "object") {
63
+ objectDeclaredKeys.add(key);
64
+ definitionsByKey.set(key, resolveCategoryDefinition(ref));
65
+ } else if (!objectDeclaredKeys.has(key)) {
66
+ definitionsByKey.set(key, resolveCategoryDefinition(ref));
67
+ }
68
+ }
69
+ }
70
+ if (!definitionsByKey.has("other")) {
71
+ definitionsByKey.set("other", resolveCategoryDefinition("other"));
72
+ }
73
+ const knownCategories = Array.from(definitionsByKey.keys());
47
74
  const functions = Object.keys(meta).filter((key) => {
48
75
  const property = sdk[key];
49
76
  if (typeof property === "function") return true;
@@ -61,7 +88,9 @@ function buildRegistry({
61
88
  inputSchema: canonicalInputSchema(m.inputSchema),
62
89
  inputParameters: m.inputParameters,
63
90
  outputSchema: m.outputSchema,
64
- categories: m.categories || [],
91
+ categories: (m.categories ?? []).map(
92
+ (c) => typeof c === "string" ? c : c.key
93
+ ),
65
94
  resolvers: m.resolvers,
66
95
  formatter: m.formatter,
67
96
  experimental: m.experimental,
@@ -76,471 +105,134 @@ function buildRegistry({
76
105
  const filteredCategories = knownCategories.slice().sort((a, b) => {
77
106
  if (a === "other") return 1;
78
107
  if (b === "other") return -1;
79
- return categoryDefinitions[a].title.localeCompare(
80
- categoryDefinitions[b].title
81
- );
108
+ return definitionsByKey.get(a).title.localeCompare(definitionsByKey.get(b).title);
82
109
  }).map((categoryKey) => {
83
110
  const categoryFunctions = filteredFunctions.filter(
84
111
  (f) => f.categories.includes(categoryKey) || categoryKey === "other" && !f.categories.some((c) => knownCategories.includes(c))
85
112
  ).map((f) => f.name).sort();
86
- const definition = categoryDefinitions[categoryKey];
113
+ const def = definitionsByKey.get(categoryKey);
87
114
  return {
88
115
  key: categoryKey,
89
- title: definition.title,
90
- titlePlural: definition.titlePlural ?? `${definition.title}s`,
116
+ title: def.title,
117
+ titlePlural: def.titlePlural,
91
118
  functions: categoryFunctions
92
119
  };
93
120
  }).filter((category) => category.functions.length > 0);
94
121
  return { functions: filteredFunctions, categories: filteredCategories };
95
122
  }
96
-
97
- // src/utils/logging.ts
98
- var loggedDeprecations = /* @__PURE__ */ new Set();
99
- function logDeprecation(message) {
100
- if (loggedDeprecations.has(message)) return;
101
- loggedDeprecations.add(message);
102
- console.warn(`[zapier-sdk] Deprecation: ${message}`);
123
+ function composeVoid(existing, added) {
124
+ if (!existing) return added;
125
+ if (!added) return existing;
126
+ return (ctx) => {
127
+ existing(ctx);
128
+ added(ctx);
129
+ };
103
130
  }
104
- function resetDeprecationWarnings() {
105
- loggedDeprecations.clear();
131
+ function buildHooks(existing, added) {
132
+ const result = {};
133
+ const start = composeVoid(existing.onMethodStart, added.onMethodStart);
134
+ if (start) result.onMethodStart = start;
135
+ const end = composeVoid(existing.onMethodEnd, added.onMethodEnd);
136
+ if (end) result.onMethodEnd = end;
137
+ return result;
106
138
  }
107
- function withFormatter(schema, formatMeta) {
108
- Object.assign(schema._zod.def, {
109
- formatMeta
110
- });
111
- return schema;
139
+ function createDeprecationLogger(tag) {
140
+ const loggedDeprecations = /* @__PURE__ */ new Set();
141
+ return {
142
+ logDeprecation(message) {
143
+ if (loggedDeprecations.has(message)) return;
144
+ loggedDeprecations.add(message);
145
+ console.warn(`[${tag}] Deprecation: ${message}`);
146
+ },
147
+ resetDeprecationWarnings() {
148
+ loggedDeprecations.clear();
149
+ }
150
+ };
112
151
  }
113
- function withPositional(schema) {
114
- Object.assign(schema._zod.def, {
115
- positionalMeta: { positional: true }
152
+ var { logDeprecation} = createDeprecationLogger("core");
153
+ var CORE_ERROR_SYMBOL = Symbol.for("kitcore.error");
154
+ var CoreErrorCode = {
155
+ Validation: "VALIDATION_ERROR",
156
+ Unknown: "UNKNOWN_ERROR"
157
+ };
158
+ var CoreError = class extends Error {
159
+ constructor(message, options = {}) {
160
+ super(message);
161
+ this.name = "CoreError";
162
+ if (options.statusCode !== void 0) this.statusCode = options.statusCode;
163
+ if (options.errors !== void 0) this.errors = options.errors;
164
+ if (options.cause !== void 0) this.cause = options.cause;
165
+ if (options.response !== void 0) this.response = options.response;
166
+ Object.setPrototypeOf(this, new.target.prototype);
167
+ }
168
+ };
169
+ function createCoreError(options, adaptError) {
170
+ const error = adaptError?.(options) ?? new CoreError(options.message, { cause: options.cause });
171
+ Object.defineProperty(error, CORE_ERROR_SYMBOL, {
172
+ value: true,
173
+ enumerable: false,
174
+ configurable: true,
175
+ writable: false
116
176
  });
117
- return schema;
177
+ Object.defineProperty(error, "coreCode", {
178
+ value: options.code,
179
+ enumerable: false,
180
+ configurable: true,
181
+ writable: false
182
+ });
183
+ return error;
118
184
  }
119
- function schemaHasPositionalMeta(schema) {
120
- return "positionalMeta" in schema._zod.def;
185
+ function isCoreError(value) {
186
+ return Boolean(
187
+ value && typeof value === "object" && value[CORE_ERROR_SYMBOL] === true
188
+ );
121
189
  }
122
- function isPositional(schema) {
123
- if (schemaHasPositionalMeta(schema) && schema._zod.def.positionalMeta?.positional) {
124
- return true;
125
- }
126
- if (schema instanceof zod.z.ZodOptional) {
127
- return isPositional(schema._zod.def.innerType);
128
- }
129
- if (schema instanceof zod.z.ZodDefault) {
130
- return isPositional(schema._zod.def.innerType);
131
- }
132
- return false;
190
+ function getCoreErrorCode(value) {
191
+ if (!isCoreError(value)) return void 0;
192
+ return value.coreCode;
133
193
  }
134
-
135
- // src/constants.ts
136
- var ZAPIER_BASE_URL = globalThis.process?.env?.ZAPIER_BASE_URL || "https://zapier.com";
137
- function getZapierSdkService() {
138
- return globalThis.process?.env?.ZAPIER_SDK_SERVICE;
194
+ function getCoreErrorCause(value) {
195
+ if (!isCoreError(value)) return void 0;
196
+ return value.cause;
139
197
  }
140
- var MAX_PAGE_LIMIT = 1e4;
141
- var DEFAULT_PAGE_SIZE = 100;
142
- var DEFAULT_ACTION_TIMEOUT_MS = 18e4;
143
- function parseIntEnvVar(name) {
144
- const value = globalThis.process?.env?.[name];
145
- if (value === void 0) return void 0;
146
- const parsed = parseInt(value, 10);
147
- if (isNaN(parsed)) {
148
- console.warn(
149
- `[zapier-sdk] Invalid value for ${name}: "${value}" (expected integer)`
150
- );
151
- return void 0;
152
- }
153
- return parsed;
198
+ var CURSOR_VERSION = 1;
199
+ var CURSOR_SOURCE = {
200
+ API: "api",
201
+ SDK: "sdk"
202
+ };
203
+ function encodeBase64(str) {
204
+ return btoa(
205
+ Array.from(
206
+ new TextEncoder().encode(str),
207
+ (b) => String.fromCharCode(b)
208
+ ).join("")
209
+ );
154
210
  }
155
- var ZAPIER_MAX_NETWORK_RETRIES = parseIntEnvVar("ZAPIER_MAX_NETWORK_RETRIES") ?? 3;
156
- var ZAPIER_MAX_NETWORK_RETRY_DELAY_MS = parseIntEnvVar("ZAPIER_MAX_NETWORK_RETRY_DELAY_MS") ?? 6e4;
157
- var MAX_CONCURRENCY_LIMIT = 1e4;
158
- function parseConcurrencyEnvVar(name) {
159
- const value = globalThis.process?.env?.[name];
160
- if (!value) return void 0;
161
- if (value === "Infinity") return Infinity;
162
- if (/^[1-9]\d*$/.test(value)) {
163
- const parsed = parseInt(value, 10);
164
- if (parsed <= MAX_CONCURRENCY_LIMIT) return parsed;
165
- }
166
- console.warn(
167
- `[zapier-sdk] Invalid value for ${name}: "${value}" (expected positive integer 1-${MAX_CONCURRENCY_LIMIT} or "Infinity")`
211
+ function decodeBase64(str) {
212
+ return new TextDecoder().decode(
213
+ Uint8Array.from(atob(str), (c) => c.charCodeAt(0))
168
214
  );
169
- return void 0;
170
215
  }
171
- var ZAPIER_MAX_CONCURRENT_REQUESTS = parseConcurrencyEnvVar("ZAPIER_MAX_CONCURRENT_REQUESTS") ?? 200;
172
- function getZapierApprovalMode() {
173
- const value = globalThis.process?.env?.ZAPIER_APPROVAL_MODE;
174
- if (value === "disabled" || value === "poll" || value === "throw")
175
- return value;
176
- return void 0;
216
+ function encodeApiCursor(cursor) {
217
+ const envelope = {
218
+ v: CURSOR_VERSION,
219
+ source: CURSOR_SOURCE.API,
220
+ cursor
221
+ };
222
+ return encodeBase64(JSON.stringify(envelope));
177
223
  }
178
- function getZapierDefaultApprovalMode() {
179
- const isInteractive = !!globalThis.process?.stdin?.isTTY && !!globalThis.process?.stdout?.isTTY;
180
- return isInteractive ? "poll" : "throw";
224
+ function encodeSdkCursor(offset, cursor) {
225
+ const envelope = {
226
+ v: CURSOR_VERSION,
227
+ source: CURSOR_SOURCE.SDK,
228
+ cursor,
229
+ offset
230
+ };
231
+ return encodeBase64(JSON.stringify(envelope));
181
232
  }
182
- var DEFAULT_APPROVAL_TIMEOUT_MS = 10 * 60 * 1e3;
183
- var DEFAULT_MAX_APPROVAL_RETRIES = 2;
184
-
185
- // src/types/properties.ts
186
- var AppKeyPropertySchema = withPositional(
187
- zod.z.string().min(1).describe("App key (e.g., 'SlackCLIAPI' or slug like 'github')")
188
- );
189
- var AppPropertySchema = withPositional(
190
- zod.z.string().min(1).describe(
191
- "App slug (e.g., 'github'), implementation name (e.g., 'SlackCLIAPI'), or versioned ID (e.g., 'github@1.2.3')"
192
- )
193
- );
194
- var ActionTypePropertySchema = zod.z.enum([
195
- "read",
196
- "read_bulk",
197
- "write",
198
- "run",
199
- "search",
200
- "search_or_write",
201
- "search_and_write",
202
- "filter"
203
- ]).describe("Action type that matches the action's defined type");
204
- var ActionKeyPropertySchema = zod.z.string().min(1).describe("Action key to execute");
205
- var ActionPropertySchema = withPositional(
206
- zod.z.string().min(1).describe("Action key (e.g., 'send_message' or 'find_row')")
207
- );
208
- var InputFieldPropertySchema = withPositional(
209
- zod.z.string().min(1).describe("Input field key to get choices for")
210
- );
211
- var ConnectionIdPropertySchema = zod.z.union([zod.z.string(), zod.z.number().int().positive()]).describe("Connection ID to use for this action");
212
- var AuthenticationIdPropertySchema = ConnectionIdPropertySchema.meta({
213
- deprecated: true
214
- });
215
- var ConnectionPropertySchema = zod.z.union([zod.z.string(), zod.z.number().int().positive()]).describe(
216
- "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."
217
- );
218
- var InputsPropertySchema = zod.z.record(zod.z.string(), zod.z.unknown()).describe("Input parameters for the action");
219
- var LimitPropertySchema = zod.z.number().int().min(1).max(MAX_PAGE_LIMIT).default(50).describe("Maximum number of items to return");
220
- var OffsetPropertySchema = zod.z.number().int().min(0).default(0).describe("Number of items to skip for pagination");
221
- var OutputPropertySchema = zod.z.string().describe("Output file path");
222
- var DebugPropertySchema = zod.z.boolean().default(false).describe("Enable debug logging");
223
- var ParamsPropertySchema = zod.z.record(zod.z.string(), zod.z.unknown()).describe("Additional parameters");
224
- var ActionTimeoutMsPropertySchema = zod.z.number().min(1e3).optional().describe(
225
- `Maximum time to wait for action completion in milliseconds (default: ${DEFAULT_ACTION_TIMEOUT_MS})`
226
- );
227
- var TablePropertySchema = withPositional(
228
- zod.z.string().regex(/^[A-Z0-9]{26}$/, "Table ID must be a valid ULID").describe("The unique identifier of the table")
229
- );
230
- var RecordPropertySchema = withPositional(
231
- zod.z.string().regex(/^[A-Z0-9]{26}$/, "Record ID must be a valid ULID").describe("The unique identifier of the record")
232
- );
233
- var RecordsPropertySchema = zod.z.array(zod.z.string().regex(/^[A-Z0-9]{26}$/, "Record ID must be a valid ULID")).min(1).max(100).describe("Record IDs to operate on");
234
- var FieldsPropertySchema = zod.z.array(zod.z.union([zod.z.string(), zod.z.number()])).describe(
235
- 'Fields to operate on. Accepts field names (e.g., "Email") or IDs (e.g., "f6", "6", or 6).'
236
- );
237
- var AppsPropertySchema = zod.z.array(zod.z.string()).describe("Filter by app keys (e.g., 'SlackCLIAPI' or slug like 'github')");
238
- var TablesPropertySchema = zod.z.array(zod.z.string()).describe("Filter by specific table IDs");
239
- var ConnectionsPropertySchema = zod.z.array(zod.z.string()).describe("List of connection IDs to filter by");
240
- var TriggerInboxPropertySchema = withPositional(
241
- zod.z.string().min(1).describe(
242
- "Trigger inbox identifier \u2014 UUID or name. Non-UUID values are resolved by name via the inbox list endpoint."
243
- )
244
- );
245
- var TriggerInboxNamePropertySchema = zod.z.string().min(1).max(100).describe(
246
- "Inbox name; unique per (user, account). Enables get-or-create on createTriggerInbox."
247
- );
248
- var LeasePropertySchema = zod.z.string().min(1).describe("Lease ID returned from leaseTriggerInboxMessages");
249
- var LeaseSecondsPropertySchema = zod.z.number().int().min(1).max(3600).describe(
250
- "Seconds until the lease expires; messages return to available if not acked. API default is 300 (5 minutes)."
251
- );
252
- var LeaseLimitPropertySchema = zod.z.number().int().min(1).max(100).describe("Maximum messages to lease in a single batch (1-100)");
253
-
254
- // src/plugins/apps/schemas.ts
255
- var ActionExecutionInputSchema = zod.z.object({
256
- inputs: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
257
- /** @deprecated Use `connection` instead. */
258
- connectionId: ConnectionIdPropertySchema.optional().meta({
259
- deprecated: true
260
- }),
261
- connection: ConnectionPropertySchema.optional(),
262
- /** @deprecated Use connection instead */
263
- authenticationId: AuthenticationIdPropertySchema.optional().meta({
264
- deprecated: true
265
- }),
266
- timeoutMs: ActionTimeoutMsPropertySchema
267
- }).describe(
268
- "Execute an action with the given inputs for the bound app, as an alternative to runAction"
269
- ).meta({
270
- aliases: { connectionId: "connection", authenticationId: "connection" }
271
- });
272
- var AppFactoryInputSchema = zod.z.object({
273
- /** @deprecated Use `connection` instead. */
274
- connectionId: ConnectionIdPropertySchema.optional().meta({
275
- deprecated: true
276
- }),
277
- connection: ConnectionPropertySchema.optional(),
278
- /** @deprecated Use connection instead */
279
- authenticationId: AuthenticationIdPropertySchema.optional().meta({
280
- deprecated: true
281
- })
282
- }).describe("Bind a connection alias or numeric connectionId to an app").meta({
283
- aliases: { connectionId: "connection", authenticationId: "connection" }
284
- });
285
-
286
- // src/types/errors.ts
287
- var ZapierError = class extends Error {
288
- constructor(message, options = {}) {
289
- super(message);
290
- this.statusCode = options.statusCode;
291
- this.errors = options.errors;
292
- this.cause = options.cause;
293
- this.response = options.response;
294
- Object.setPrototypeOf(this, new.target.prototype);
295
- }
296
- };
297
- var ZapierApiError = class extends ZapierError {
298
- constructor(message, options = {}) {
299
- super(message, options);
300
- this.name = "ZapierApiError";
301
- this.code = "ZAPIER_API_ERROR";
302
- }
303
- };
304
- var ZapierAppNotFoundError = class extends ZapierError {
305
- constructor(message, options = {}) {
306
- super(message, options);
307
- this.name = "ZapierAppNotFoundError";
308
- this.code = "ZAPIER_APP_NOT_FOUND_ERROR";
309
- this.appKey = options.appKey;
310
- }
311
- };
312
- var ZapierValidationError = class extends ZapierError {
313
- constructor(message, options = {}) {
314
- super(message, options);
315
- this.name = "ZapierValidationError";
316
- this.code = "ZAPIER_VALIDATION_ERROR";
317
- this.details = options.details;
318
- }
319
- };
320
- var ZapierUnknownError = class extends ZapierError {
321
- constructor(message, options = {}) {
322
- super(message, options);
323
- this.name = "ZapierUnknownError";
324
- this.code = "ZAPIER_UNKNOWN_ERROR";
325
- }
326
- };
327
- var ZapierAuthenticationError = class extends ZapierError {
328
- constructor(message, options = {}) {
329
- super(message, options);
330
- this.name = "ZapierAuthenticationError";
331
- this.code = "ZAPIER_AUTHENTICATION_ERROR";
332
- }
333
- };
334
- var ZapierNotFoundError = class extends ZapierError {
335
- constructor(message, options = {}) {
336
- super(message, options);
337
- this.name = "ZapierNotFoundError";
338
- this.code = "ZAPIER_NOT_FOUND_ERROR";
339
- }
340
- };
341
- var ZapierResourceNotFoundError = class extends ZapierNotFoundError {
342
- constructor(message, options = {}) {
343
- super(message, options);
344
- this.name = "ZapierResourceNotFoundError";
345
- this.code = "ZAPIER_RESOURCE_NOT_FOUND_ERROR";
346
- this.resourceType = options.resourceType;
347
- this.resourceId = options.resourceId;
348
- }
349
- };
350
- var ZapierConfigurationError = class extends ZapierError {
351
- constructor(message, options = {}) {
352
- super(message, options);
353
- this.name = "ZapierConfigurationError";
354
- this.code = "ZAPIER_CONFIGURATION_ERROR";
355
- this.configType = options.configType;
356
- }
357
- };
358
- var ZapierBundleError = class extends ZapierError {
359
- constructor(message, options = {}) {
360
- super(message, options);
361
- this.name = "ZapierBundleError";
362
- this.code = "ZAPIER_BUNDLE_ERROR";
363
- this.buildErrors = options.buildErrors;
364
- }
365
- };
366
- var ZapierTimeoutError = class extends ZapierError {
367
- constructor(message, options = {}) {
368
- super(message, options);
369
- this.name = "ZapierTimeoutError";
370
- this.code = "ZAPIER_TIMEOUT_ERROR";
371
- this.attempts = options.attempts;
372
- this.maxAttempts = options.maxAttempts;
373
- }
374
- };
375
- var ZapierActionError = class extends ZapierError {
376
- constructor(message, options = {}) {
377
- super(message, options);
378
- this.name = "ZapierActionError";
379
- this.code = "ZAPIER_ACTION_ERROR";
380
- this.appKey = options.appKey;
381
- this.actionKey = options.actionKey;
382
- }
383
- // Legacy accessor for backward compatibility
384
- get actionErrors() {
385
- return this.errors;
386
- }
387
- };
388
- var ZapierConflictError = class extends ZapierError {
389
- constructor(message, options = {}) {
390
- super(message, options);
391
- this.name = "ZapierConflictError";
392
- this.code = "ZAPIER_CONFLICT_ERROR";
393
- this.resourceType = options.resourceType;
394
- }
395
- };
396
- var ZapierRateLimitError = class extends ZapierError {
397
- constructor(message, options = {}) {
398
- super(message, options);
399
- this.name = "ZapierRateLimitError";
400
- this.code = "ZAPIER_RATE_LIMIT_ERROR";
401
- this.rateLimit = options.rateLimit ?? {};
402
- this.retries = options.retries ?? 0;
403
- }
404
- };
405
- var ZapierApprovalError = class extends ZapierError {
406
- constructor(message, options = {}) {
407
- super(message, options);
408
- this.name = "ZapierApprovalError";
409
- this.code = "ZAPIER_APPROVAL_ERROR";
410
- this.approvalId = options.approvalId;
411
- this.approvalStatus = options.status;
412
- this.approvalUrl = options.approvalUrl;
413
- this.pollUrl = options.pollUrl;
414
- }
415
- };
416
- var ZapierRelayError = class extends ZapierError {
417
- constructor(message, options = {}) {
418
- super(message, options);
419
- this.name = "ZapierRelayError";
420
- this.code = "ZAPIER_RELAY_ERROR";
421
- }
422
- };
423
- function formatErrorMessage(error) {
424
- let message = error.message;
425
- if (error.errors && error.errors.length > 0) {
426
- const additionalErrors = error.errors.slice(1);
427
- if (additionalErrors.length > 0) {
428
- const errorDetails = additionalErrors.map((err) => ` \u2022 ${err.detail || err.title || err.code}`).join("\n");
429
- message += "\n\nAdditional errors:\n" + errorDetails;
430
- }
431
- }
432
- if (error instanceof ZapierAppNotFoundError && error.appKey) {
433
- message += `
434
- App key: ${error.appKey}`;
435
- }
436
- if (error instanceof ZapierActionError && (error.appKey || error.actionKey)) {
437
- const context = [];
438
- if (error.appKey) context.push(`App: ${error.appKey}`);
439
- if (error.actionKey) context.push(`Action: ${error.actionKey}`);
440
- message += `
441
- ${context.join(", ")}`;
442
- }
443
- if (error instanceof ZapierResourceNotFoundError && (error.resourceType || error.resourceId)) {
444
- const context = [];
445
- if (error.resourceType) context.push(`Type: ${error.resourceType}`);
446
- if (error.resourceId) context.push(`ID: ${error.resourceId}`);
447
- message += `
448
- ${context.join(", ")}`;
449
- }
450
- if (error instanceof ZapierConflictError && error.resourceType) {
451
- message += `
452
- Type: ${error.resourceType}`;
453
- }
454
- if (error instanceof ZapierTimeoutError && (error.attempts || error.maxAttempts)) {
455
- const context = [];
456
- if (error.attempts) context.push(`Attempts: ${error.attempts}`);
457
- if (error.maxAttempts) context.push(`Max attempts: ${error.maxAttempts}`);
458
- message += `
459
- ${context.join(", ")}`;
460
- }
461
- if (error instanceof ZapierBundleError && error.buildErrors && error.buildErrors.length > 0) {
462
- message += "\n\nBuild errors:\n" + error.buildErrors.map((err) => ` \u2022 ${err}`).join("\n");
463
- }
464
- if (error instanceof ZapierApprovalError && error.approvalUrl) {
465
- message += `
466
- Approval URL: ${error.approvalUrl}`;
467
- }
468
- if (error instanceof ZapierRateLimitError) {
469
- const { limit, remaining, retryAfterMs } = error.rateLimit;
470
- const parts = [];
471
- if (limit !== void 0) {
472
- const used = remaining !== void 0 ? limit - remaining : limit;
473
- parts.push(`${used}/${limit} used`);
474
- }
475
- if (retryAfterMs !== void 0 && retryAfterMs > 0) {
476
- parts.push(`retry in ${formatDuration(retryAfterMs)}`);
477
- }
478
- if (error.retries > 0) {
479
- parts.push(
480
- `after ${error.retries} retr${error.retries === 1 ? "y" : "ies"}`
481
- );
482
- }
483
- if (parts.length > 0) {
484
- message += `
485
- ${parts.join(", ")}`;
486
- }
487
- }
488
- if (error.statusCode && !message.includes(`${error.statusCode}`)) {
489
- message += `
490
- HTTP Status: ${error.statusCode}`;
491
- }
492
- return message;
493
- }
494
- function formatDuration(ms) {
495
- const seconds = Math.round(ms / 1e3);
496
- if (seconds < 60) return `${seconds}s`;
497
- const minutes = Math.round(seconds / 60);
498
- if (minutes < 60) return `${minutes}m`;
499
- const hours = Math.round(minutes / 60);
500
- if (hours < 24) return `${hours}h`;
501
- const days = Math.round(hours / 24);
502
- return `${days}d`;
503
- }
504
-
505
- // src/utils/pagination-utils.ts
506
- var CURSOR_VERSION = 1;
507
- var CURSOR_SOURCE = {
508
- API: "api",
509
- SDK: "sdk"
510
- };
511
- function encodeBase64(str) {
512
- return btoa(
513
- Array.from(
514
- new TextEncoder().encode(str),
515
- (b) => String.fromCharCode(b)
516
- ).join("")
517
- );
518
- }
519
- function decodeBase64(str) {
520
- return new TextDecoder().decode(
521
- Uint8Array.from(atob(str), (c) => c.charCodeAt(0))
522
- );
523
- }
524
- function encodeApiCursor(cursor) {
525
- const envelope = {
526
- v: CURSOR_VERSION,
527
- source: CURSOR_SOURCE.API,
528
- cursor
529
- };
530
- return encodeBase64(JSON.stringify(envelope));
531
- }
532
- function encodeSdkCursor(offset, cursor) {
533
- const envelope = {
534
- v: CURSOR_VERSION,
535
- source: CURSOR_SOURCE.SDK,
536
- cursor,
537
- offset
538
- };
539
- return encodeBase64(JSON.stringify(envelope));
540
- }
541
- function decodeIncomingCursor(incoming) {
542
- if (!incoming) {
543
- return { offset: 0, cursor: void 0 };
233
+ function decodeIncomingCursor(incoming) {
234
+ if (!incoming) {
235
+ return { offset: 0, cursor: void 0 };
544
236
  }
545
237
  try {
546
238
  const decoded = decodeBase64(incoming);
@@ -755,144 +447,117 @@ function concatPaginated({
755
447
  function toIterable(source) {
756
448
  return { [Symbol.asyncIterator]: () => source[Symbol.asyncIterator]() };
757
449
  }
758
-
759
- // src/utils/validation.ts
760
- var validate = (schema, input) => {
450
+ var parseOrThrow = (schema, input, { adaptError } = {}) => {
761
451
  const result = schema.safeParse(input);
762
452
  if (!result.success) {
763
- const errorMessages = result.error.issues.map((error) => {
764
- const path = error.path.length > 0 ? error.path.join(".") : "input";
765
- return `${path}: ${error.message}`;
766
- });
767
- const message = `Validation failed:
768
- ${errorMessages.join("\n ")}`;
769
- throw new ZapierValidationError(message, {
770
- details: {
771
- zodErrors: result.error.issues,
772
- input
773
- }
453
+ const errorMessages = result.error.issues.map((issue) => {
454
+ const path = issue.path.length > 0 ? issue.path.join(".") : "input";
455
+ return `${path}: ${issue.message}`;
774
456
  });
457
+ throw createCoreError(
458
+ {
459
+ code: CoreErrorCode.Validation,
460
+ message: `Validation failed:
461
+ ${errorMessages.join("\n ")}`,
462
+ details: {
463
+ zodErrors: result.error.issues,
464
+ input
465
+ }
466
+ },
467
+ adaptError
468
+ );
775
469
  }
776
470
  return result.data;
777
471
  };
778
- function createValidator(schema) {
472
+ function createValidator(schema, { adaptError } = {}) {
779
473
  return function validateFn(input) {
780
- return validate(schema, input);
474
+ return parseOrThrow(schema, input, { adaptError });
781
475
  };
782
476
  }
783
- var validateOptions = (schema, options) => {
784
- return validate(schema, options);
785
- };
786
- var telemetryStore = null;
477
+ var validateOptions = (schema, options, { adaptError } = {}) => parseOrThrow(schema, options, { adaptError });
478
+ var scopeStore = null;
787
479
  try {
788
- telemetryStore = new async_hooks.AsyncLocalStorage();
480
+ scopeStore = new async_hooks.AsyncLocalStorage();
789
481
  } catch {
790
482
  }
791
- function isTelemetryNested() {
792
- if (!telemetryStore) return true;
793
- const store = telemetryStore.getStore();
794
- return store !== void 0 && store.depth > 0;
483
+ function getCurrentScope() {
484
+ if (!scopeStore) return void 0;
485
+ return scopeStore.getStore();
795
486
  }
796
- function runWithTelemetryContext(fn) {
797
- if (!telemetryStore) return fn();
798
- const currentDepth = telemetryStore.getStore()?.depth ?? -1;
799
- return telemetryStore.run({ depth: currentDepth + 1 }, fn);
487
+ function getCurrentDepth() {
488
+ return getCurrentScope()?.depth ?? 0;
800
489
  }
801
- function setMethodMetadata(metadata) {
802
- if (!telemetryStore) return;
803
- const store = telemetryStore.getStore();
804
- if (!store) return;
805
- store.methodMetadata = { ...store.methodMetadata, ...metadata };
490
+ function runInMethodScope(fn) {
491
+ if (!scopeStore) return fn();
492
+ const currentDepth = scopeStore.getStore()?.depth ?? -1;
493
+ return scopeStore.run({ depth: currentDepth + 1 }, fn);
806
494
  }
807
- function getMethodMetadata() {
808
- if (!telemetryStore) return void 0;
809
- return telemetryStore.getStore()?.methodMetadata;
495
+ var runWithTelemetryContext = runInMethodScope;
496
+ function normalizeError(error, adaptError) {
497
+ if (error instanceof Error) return error;
498
+ const message = typeof error === "object" && error !== null && "message" in error && typeof error.message === "string" ? error.message : String(error);
499
+ return createCoreError(
500
+ {
501
+ code: CoreErrorCode.Unknown,
502
+ message,
503
+ cause: error
504
+ },
505
+ adaptError
506
+ );
810
507
  }
811
-
812
- // src/utils/function-utils.ts
813
- function extractCursor(data) {
814
- if (!data?.next) {
815
- return void 0;
816
- }
817
- try {
818
- const urlObj = new URL(data.next);
819
- const offset = urlObj.searchParams.get("offset");
820
- return offset || void 0;
821
- } catch {
822
- return void 0;
823
- }
824
- }
825
- function normalizeError(error) {
826
- if (error instanceof ZapierError) {
827
- return error;
828
- }
829
- const message = error instanceof Error ? error.message : String(error);
830
- const cause = error instanceof Error ? error : void 0;
831
- if (error instanceof Error) {
832
- if (error.name === "ZapierAuthenticationError") {
833
- return new ZapierAuthenticationError(message, { cause });
834
- }
835
- }
836
- return new ZapierUnknownError(message, { cause });
837
- }
838
- function createFunction(coreFn, schema, telemetry) {
508
+ function createFunction(coreFn, options) {
509
+ const { sdk, schema } = options;
839
510
  const functionName = coreFn.name;
840
511
  const namedFunctions = {
841
- [functionName]: async function(options) {
842
- return runWithTelemetryContext(async () => {
512
+ [functionName]: async function(callOptions) {
513
+ return runInMethodScope(async () => {
843
514
  const startTime = Date.now();
844
- const normalizedOptions = options ?? {};
845
- const isNested = isTelemetryNested();
515
+ const normalizedOptions = callOptions ?? {};
516
+ const args = [normalizedOptions];
517
+ const depth = getCurrentDepth();
518
+ const hooks = sdk.context.hooks;
519
+ const adaptError = sdk.context.core?.adaptError;
520
+ hooks?.onMethodStart?.({
521
+ methodName: functionName,
522
+ args,
523
+ isPaginated: false,
524
+ depth
525
+ });
846
526
  try {
527
+ let result;
847
528
  if (schema) {
848
- const validatedOptions = validateOptions(schema, normalizedOptions);
849
- const result2 = await coreFn({
529
+ const validatedOptions = validateOptions(
530
+ schema,
531
+ normalizedOptions,
532
+ {
533
+ adaptError
534
+ }
535
+ );
536
+ result = await coreFn({
850
537
  ...normalizedOptions,
851
538
  ...validatedOptions
852
539
  });
853
- if (!isNested && telemetry?.onMethodCalled) {
854
- const argumentCount = Object.keys(
855
- normalizedOptions
856
- ).length;
857
- telemetry.onMethodCalled({
858
- methodName: functionName,
859
- durationMs: Date.now() - startTime,
860
- success: true,
861
- argumentCount,
862
- isPaginated: false
863
- });
864
- }
865
- return result2;
866
- }
867
- const result = await coreFn(normalizedOptions);
868
- if (!isNested && telemetry?.onMethodCalled) {
869
- const argumentCount = Object.keys(
870
- normalizedOptions
871
- ).length;
872
- telemetry.onMethodCalled({
873
- methodName: functionName,
874
- durationMs: Date.now() - startTime,
875
- success: true,
876
- argumentCount,
877
- isPaginated: false
878
- });
540
+ } else {
541
+ result = await coreFn(normalizedOptions);
879
542
  }
543
+ hooks?.onMethodEnd?.({
544
+ methodName: functionName,
545
+ args,
546
+ isPaginated: false,
547
+ depth,
548
+ durationMs: Date.now() - startTime
549
+ });
880
550
  return result;
881
551
  } catch (error) {
882
- const normalizedError = normalizeError(error);
883
- if (!isNested && telemetry?.onMethodCalled) {
884
- const argumentCount = Object.keys(
885
- normalizedOptions
886
- ).length;
887
- telemetry.onMethodCalled({
888
- methodName: functionName,
889
- durationMs: Date.now() - startTime,
890
- success: false,
891
- error: normalizedError,
892
- argumentCount,
893
- isPaginated: false
894
- });
895
- }
552
+ const normalizedError = normalizeError(error, adaptError);
553
+ hooks?.onMethodEnd?.({
554
+ methodName: functionName,
555
+ args,
556
+ isPaginated: false,
557
+ depth,
558
+ durationMs: Date.now() - startTime,
559
+ error: normalizedError
560
+ });
896
561
  throw normalizedError;
897
562
  }
898
563
  });
@@ -900,49 +565,63 @@ function createFunction(coreFn, schema, telemetry) {
900
565
  };
901
566
  return namedFunctions[functionName];
902
567
  }
903
- function createPageFunction(coreFn) {
568
+ function isSdkPage(value) {
569
+ if (typeof value !== "object" || value === null) return false;
570
+ const page = value;
571
+ if (!Array.isArray(page.data)) return false;
572
+ if (page.nextCursor !== void 0 && typeof page.nextCursor !== "string") {
573
+ return false;
574
+ }
575
+ return Object.keys(page).every((k) => k === "data" || k === "nextCursor");
576
+ }
577
+ function createPageFunction(coreFn, {
578
+ sdk,
579
+ adaptPage
580
+ }) {
904
581
  const functionName = coreFn.name + "Page";
905
582
  const namedFunctions = {
906
583
  [functionName]: async function(options) {
907
584
  try {
908
- const result = await coreFn(options);
909
- if (result && typeof result === "object" && "data" in result) {
910
- const paginatedResult = result;
911
- let nextCursor;
912
- if (paginatedResult.nextCursor) {
913
- nextCursor = paginatedResult.nextCursor;
914
- } else if (paginatedResult.links?.next) {
915
- nextCursor = extractCursor({ next: paginatedResult.links.next });
916
- }
917
- return {
918
- data: Array.isArray(paginatedResult.data) ? paginatedResult.data : [paginatedResult.data],
919
- nextCursor
920
- };
921
- }
922
- if (Array.isArray(result)) {
923
- return { data: result };
585
+ const response = await coreFn(options);
586
+ const page = adaptPage ? adaptPage(response) : response;
587
+ if (!isSdkPage(page)) {
588
+ throw new Error(
589
+ `${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\`.`
590
+ );
924
591
  }
925
- return { data: [result] };
592
+ return page;
926
593
  } catch (error) {
927
- throw normalizeError(error);
594
+ throw normalizeError(
595
+ error,
596
+ sdk.context.core?.adaptError
597
+ );
928
598
  }
929
599
  }
930
600
  };
931
601
  return namedFunctions[functionName];
932
602
  }
933
- function createPaginatedFunction(coreFn, schema, telemetry, explicitFunctionName, defaultPageSize) {
934
- const pageFunction = createPageFunction(coreFn);
935
- const functionName = explicitFunctionName || coreFn.name;
936
- const validator = schema ? createValidator(schema) : null;
603
+ function createPaginatedFunction(coreFn, options) {
604
+ const { sdk, schema, name, defaultPageSize, adaptPage } = options;
605
+ const pageFunction = createPageFunction(coreFn, { sdk, adaptPage });
606
+ const functionName = name || coreFn.name;
937
607
  const namedFunctions = {
938
- [functionName]: function(options) {
939
- return runWithTelemetryContext(() => {
608
+ [functionName]: function(callOptions) {
609
+ return runInMethodScope(() => {
940
610
  const startTime = Date.now();
941
- const normalizedOptions = options ?? {};
942
- const isNested = isTelemetryNested();
611
+ const normalizedOptions = callOptions ?? {};
612
+ const args = [normalizedOptions];
613
+ const depth = getCurrentDepth();
614
+ const hooks = sdk.context.hooks;
615
+ const adaptError = sdk.context.core?.adaptError;
616
+ hooks?.onMethodStart?.({
617
+ methodName: functionName,
618
+ args,
619
+ isPaginated: true,
620
+ depth
621
+ });
943
622
  const validatedOptions = {
944
623
  ...normalizedOptions,
945
- ...validator ? validator(normalizedOptions) : normalizedOptions
624
+ ...schema ? createValidator(schema, { adaptError })(normalizedOptions) : normalizedOptions
946
625
  };
947
626
  const pageSize = validatedOptions.pageSize ?? defaultPageSize;
948
627
  const optimizedOptions = {
@@ -956,29 +635,23 @@ function createPaginatedFunction(coreFn, schema, telemetry, explicitFunctionName
956
635
  }
957
636
  return result.value;
958
637
  });
959
- if (!isNested && telemetry?.onMethodCalled) {
638
+ if (hooks?.onMethodEnd) {
960
639
  firstPagePromise.then(() => {
961
- const argumentCount = Object.keys(
962
- normalizedOptions
963
- ).length;
964
- telemetry.onMethodCalled({
640
+ hooks.onMethodEnd({
965
641
  methodName: functionName,
966
- durationMs: Date.now() - startTime,
967
- success: true,
968
- argumentCount,
969
- isPaginated: true
642
+ args,
643
+ isPaginated: true,
644
+ depth,
645
+ durationMs: Date.now() - startTime
970
646
  });
971
647
  }).catch((error) => {
972
- const argumentCount = Object.keys(
973
- normalizedOptions
974
- ).length;
975
- telemetry.onMethodCalled({
648
+ hooks.onMethodEnd({
976
649
  methodName: functionName,
650
+ args,
651
+ isPaginated: true,
652
+ depth,
977
653
  durationMs: Date.now() - startTime,
978
- success: false,
979
- error: error instanceof Error ? error : new Error(String(error)),
980
- argumentCount,
981
- isPaginated: true
654
+ error: error instanceof Error ? error : new Error(String(error))
982
655
  });
983
656
  });
984
657
  }
@@ -1010,37 +683,9 @@ function createPaginatedFunction(coreFn, schema, telemetry, explicitFunctionName
1010
683
  };
1011
684
  return namedFunctions[functionName];
1012
685
  }
1013
-
1014
- // src/utils/telemetry-utils.ts
1015
- function createTelemetryCallback(emitMethodCalled, methodName) {
1016
- return {
1017
- onMethodCalled: (data) => {
1018
- const metadata = getMethodMetadata();
1019
- emitMethodCalled({
1020
- method_name: methodName,
1021
- execution_duration_ms: data.durationMs,
1022
- success_flag: data.success,
1023
- error_message: data.error?.message ?? null,
1024
- error_type: data.error?.constructor.name ?? null,
1025
- argument_count: data.argumentCount,
1026
- is_paginated: data.isPaginated,
1027
- selected_api: metadata?.selectedApi ?? null,
1028
- operation_type: metadata?.operationType ?? null,
1029
- operation_key: metadata?.operationKey ?? null
1030
- });
1031
- }
1032
- };
1033
- }
1034
-
1035
- // src/utils/plugin-utils.ts
1036
686
  function definePlugin(fn) {
1037
687
  return fn;
1038
688
  }
1039
- function maybeTelemetry(sdk, name) {
1040
- const ctx = sdk.context;
1041
- if (!ctx.eventEmission) return void 0;
1042
- return createTelemetryCallback(ctx.eventEmission.emitMethodCalled, name);
1043
- }
1044
689
  function createPluginMethod(sdk, config) {
1045
690
  const { name, inputSchema, handler, ...metaFields } = config;
1046
691
  const namedHandlers = {
@@ -1048,11 +693,10 @@ function createPluginMethod(sdk, config) {
1048
693
  return handler({ sdk, options });
1049
694
  }
1050
695
  };
1051
- const wrappedFn = createFunction(
1052
- namedHandlers[name],
1053
- inputSchema,
1054
- maybeTelemetry(sdk, name)
1055
- );
696
+ const wrappedFn = createFunction(namedHandlers[name], {
697
+ sdk,
698
+ schema: inputSchema
699
+ });
1056
700
  return {
1057
701
  [name]: wrappedFn,
1058
702
  context: {
@@ -1070,29 +714,22 @@ function createPaginatedPluginMethod(sdk, config) {
1070
714
  name,
1071
715
  inputSchema,
1072
716
  handler,
1073
- extractCursor: extractCursorFn,
717
+ adaptPage,
1074
718
  defaultPageSize,
1075
719
  ...metaFields
1076
720
  } = config;
1077
- const namedPageHandlers = {
1078
- [name]: async function(options) {
1079
- const response = await handler({ sdk, options });
1080
- if (extractCursorFn) {
1081
- const extracted = extractCursorFn(response);
1082
- if (extracted !== void 0) {
1083
- return { data: response.data, nextCursor: extracted };
1084
- }
1085
- }
1086
- return response;
721
+ const namedHandlers = {
722
+ [name]: function(options) {
723
+ return handler({ sdk, options });
1087
724
  }
1088
725
  };
1089
- const wrappedFn = createPaginatedFunction(
1090
- namedPageHandlers[name],
1091
- inputSchema,
1092
- maybeTelemetry(sdk, name),
726
+ const wrappedFn = createPaginatedFunction(namedHandlers[name], {
727
+ sdk,
728
+ schema: inputSchema,
1093
729
  name,
1094
- defaultPageSize
1095
- );
730
+ defaultPageSize,
731
+ adaptPage
732
+ });
1096
733
  return {
1097
734
  [name]: wrappedFn,
1098
735
  context: {
@@ -1103,90 +740,684 @@ function createPaginatedPluginMethod(sdk, config) {
1103
740
  }
1104
741
  }
1105
742
  }
1106
- };
1107
- }
1108
- function mergeRootKeysWithCollisionCheck(target, source, seen) {
1109
- for (const key of Object.keys(source)) {
1110
- if (seen.has(key)) {
1111
- throw new Error(
1112
- `composePlugins: duplicate root key "${key}". Plugins composed in the same call must register distinct method names.`
1113
- );
743
+ };
744
+ }
745
+ function splitPluginContribution(result) {
746
+ const { context, ...rootKeys } = result;
747
+ const { meta, hooks, ...contextRest } = context ?? {};
748
+ return {
749
+ rootKeys,
750
+ meta: meta ?? {},
751
+ hooks: hooks ?? {},
752
+ contextRest
753
+ };
754
+ }
755
+ var RESERVED_ROOT_KEYS = /* @__PURE__ */ new Set([
756
+ "context",
757
+ "getRegistry",
758
+ "addPlugin"
759
+ ]);
760
+ function hasOwn(obj, key) {
761
+ return Object.prototype.hasOwnProperty.call(obj, key);
762
+ }
763
+ function setOwn(target, key, value) {
764
+ Object.defineProperty(target, key, {
765
+ value,
766
+ enumerable: true,
767
+ configurable: true,
768
+ writable: true
769
+ });
770
+ }
771
+ function checkCollisions(target, source, kind, callerLabel, override) {
772
+ for (const key of Object.keys(source)) {
773
+ if (kind === "root key" && RESERVED_ROOT_KEYS.has(key)) {
774
+ throw new Error(
775
+ `${callerLabel}: plugin attempted to register reserved root key "${key}". The SDK uses this key for its own accessor; rename the plugin's method.`
776
+ );
777
+ }
778
+ if (!override && hasOwn(target, key)) {
779
+ throw new Error(
780
+ `${callerLabel}: duplicate ${kind} "${key}". If the override is intentional, pass { override: true } in the options.`
781
+ );
782
+ }
783
+ }
784
+ }
785
+ function applyOwnProperties(target, source) {
786
+ for (const key of Object.keys(source)) {
787
+ setOwn(target, key, source[key]);
788
+ }
789
+ }
790
+ function createPluginAccumulator(initialProperties = {}, initialContext = {}) {
791
+ const initialMeta = initialContext.meta ?? {};
792
+ const initialHooks = initialContext.hooks ?? {};
793
+ const context = {
794
+ ...initialContext,
795
+ meta: { ...initialMeta },
796
+ hooks: { ...initialHooks }
797
+ };
798
+ const view = { ...initialProperties, context };
799
+ return { view, context };
800
+ }
801
+ function mergeContribution(propertiesTarget, contextTarget, contribution, options) {
802
+ checkCollisions(
803
+ propertiesTarget,
804
+ contribution.rootKeys,
805
+ "root key",
806
+ options.callerLabel,
807
+ options.override
808
+ );
809
+ checkCollisions(
810
+ contextTarget.meta,
811
+ contribution.meta,
812
+ "context.meta key",
813
+ options.callerLabel,
814
+ options.override
815
+ );
816
+ checkCollisions(
817
+ contextTarget,
818
+ contribution.contextRest,
819
+ "context key",
820
+ options.callerLabel,
821
+ options.override
822
+ );
823
+ applyOwnProperties(propertiesTarget, contribution.rootKeys);
824
+ applyOwnProperties(contextTarget.meta, contribution.meta);
825
+ applyOwnProperties(contextTarget, contribution.contextRest);
826
+ contextTarget.hooks = buildHooks(contextTarget.hooks, contribution.hooks);
827
+ }
828
+ function applyPluginContribution(acc, contribution, options) {
829
+ mergeContribution(acc.view, acc.context, contribution, options);
830
+ }
831
+ function wrapAsSdk(properties, context, opts) {
832
+ const sdk = {
833
+ ...properties,
834
+ context,
835
+ getRegistry(qopts) {
836
+ return buildRegistry({
837
+ sdk,
838
+ meta: context.meta,
839
+ packageFilter: qopts?.package
840
+ });
841
+ }
842
+ };
843
+ if (opts?.addPlugin !== void 0) {
844
+ sdk.addPlugin = opts.addPlugin;
845
+ }
846
+ return sdk;
847
+ }
848
+ function wrapAccumulatorAsSdk(acc) {
849
+ const { context: _ctx, ...rootKeys } = acc.view;
850
+ return wrapAsSdk(
851
+ rootKeys,
852
+ acc.context
853
+ );
854
+ }
855
+ function applyPluginToSdk(sdk, plugin, options) {
856
+ const context = sdk.context;
857
+ const contribution = splitPluginContribution(
858
+ plugin(sdk)
859
+ );
860
+ mergeContribution(sdk, context, contribution, {
861
+ callerLabel: "addPlugin",
862
+ override: options.override === true
863
+ });
864
+ }
865
+ function buildStackAccumulator(head, callerLabel) {
866
+ const ordered = [];
867
+ let node = head;
868
+ while (node) {
869
+ ordered.unshift(node);
870
+ node = node.prev;
871
+ }
872
+ const acc = createPluginAccumulator();
873
+ for (const { plugin, override } of ordered) {
874
+ const contribution = splitPluginContribution(
875
+ plugin(acc.view)
876
+ );
877
+ applyPluginContribution(acc, contribution, { callerLabel, override });
878
+ }
879
+ return acc;
880
+ }
881
+ function addPlugin(sdk, plugin, options) {
882
+ applyPluginToSdk(
883
+ sdk,
884
+ plugin,
885
+ options ?? {}
886
+ );
887
+ }
888
+ function buildSdk(properties, context) {
889
+ const addPlugin2 = (plugin, options) => {
890
+ logDeprecation(
891
+ "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."
892
+ );
893
+ const contribution = splitPluginContribution(
894
+ plugin({ ...properties, context })
895
+ );
896
+ const mergedProperties = { ...properties };
897
+ const mergedContext = {
898
+ ...context,
899
+ meta: { ...context.meta },
900
+ hooks: { ...context.hooks }
901
+ };
902
+ mergeContribution(mergedProperties, mergedContext, contribution, {
903
+ callerLabel: "addPlugin",
904
+ override: options?.override === true
905
+ });
906
+ return buildSdk(
907
+ mergedProperties,
908
+ mergedContext
909
+ );
910
+ };
911
+ return wrapAsSdk(properties, context, { addPlugin: addPlugin2 });
912
+ }
913
+ function withDeprecatedAddPlugin(sdk) {
914
+ const initialProperties = {};
915
+ for (const key of Object.keys(sdk)) {
916
+ if (key === "context" || key === "getRegistry" || key === "addPlugin") {
917
+ continue;
918
+ }
919
+ initialProperties[key] = sdk[key];
920
+ }
921
+ const initialContext = sdk.context;
922
+ return buildSdk(
923
+ initialProperties,
924
+ initialContext
925
+ );
926
+ }
927
+ function composePlugins(...plugins) {
928
+ logDeprecation(
929
+ "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."
930
+ );
931
+ let stack = buildPluginStack(
932
+ null,
933
+ "composePlugins"
934
+ );
935
+ for (const plugin of plugins) {
936
+ stack = stack.use(plugin);
937
+ }
938
+ return stack.toPlugin();
939
+ }
940
+ function createPluginStack() {
941
+ return buildPluginStack(null, "createPluginStack");
942
+ }
943
+ function buildPluginStack(head, callerLabel) {
944
+ return {
945
+ use(plugin, options) {
946
+ const next = {
947
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
948
+ plugin,
949
+ override: options?.override === true,
950
+ prev: head
951
+ };
952
+ return buildPluginStack(next, callerLabel);
953
+ },
954
+ toPlugin() {
955
+ const ordered = [];
956
+ let node = head;
957
+ while (node) {
958
+ ordered.unshift(node);
959
+ node = node.prev;
960
+ }
961
+ return (outerSdk) => {
962
+ const { context: outerContext, ...outerProperties } = outerSdk ?? {};
963
+ const viewAcc = createPluginAccumulator(outerProperties, outerContext);
964
+ const contribsAcc = createPluginAccumulator();
965
+ for (const { plugin: subPlugin, override } of ordered) {
966
+ const contribution = splitPluginContribution(
967
+ subPlugin(viewAcc.view)
968
+ );
969
+ applyPluginContribution(viewAcc, contribution, {
970
+ callerLabel,
971
+ override
972
+ });
973
+ applyPluginContribution(contribsAcc, contribution, {
974
+ callerLabel,
975
+ override
976
+ });
977
+ }
978
+ const { context: _ignored, ...contributedRoot } = contribsAcc.view;
979
+ return {
980
+ ...contributedRoot,
981
+ context: contribsAcc.context
982
+ };
983
+ };
984
+ },
985
+ toSdk() {
986
+ return wrapAccumulatorAsSdk(
987
+ buildStackAccumulator(head, callerLabel)
988
+ );
989
+ }
990
+ };
991
+ }
992
+ function createCorePlugin(options) {
993
+ return () => ({
994
+ context: {
995
+ core: options
996
+ }
997
+ });
998
+ }
999
+ function withPositional(schema) {
1000
+ Object.assign(schema._zod.def, {
1001
+ positionalMeta: { positional: true }
1002
+ });
1003
+ return schema;
1004
+ }
1005
+ function schemaHasPositionalMeta(schema) {
1006
+ return "positionalMeta" in schema._zod.def;
1007
+ }
1008
+ function isPositional(schema) {
1009
+ if (schemaHasPositionalMeta(schema) && schema._zod.def.positionalMeta?.positional) {
1010
+ return true;
1011
+ }
1012
+ if (schema instanceof zod.z.ZodOptional) {
1013
+ return isPositional(schema._zod.def.innerType);
1014
+ }
1015
+ if (schema instanceof zod.z.ZodDefault) {
1016
+ return isPositional(schema._zod.def.innerType);
1017
+ }
1018
+ return false;
1019
+ }
1020
+
1021
+ // src/utils/logging.ts
1022
+ var { logDeprecation: logDeprecation2, resetDeprecationWarnings: resetDeprecationWarnings2 } = createDeprecationLogger("zapier-sdk");
1023
+
1024
+ // src/types/errors.ts
1025
+ var _a, _b;
1026
+ var ZapierError = class extends (_b = Error, _a = CORE_ERROR_SYMBOL, _b) {
1027
+ constructor(message, options = {}) {
1028
+ super(message);
1029
+ this[_a] = true;
1030
+ this.name = "ZapierError";
1031
+ this.code = "ZAPIER_ERROR";
1032
+ if (options.statusCode !== void 0) this.statusCode = options.statusCode;
1033
+ if (options.errors !== void 0) this.errors = options.errors;
1034
+ if (options.cause !== void 0) this.cause = options.cause;
1035
+ if (options.response !== void 0) this.response = options.response;
1036
+ Object.setPrototypeOf(this, new.target.prototype);
1037
+ }
1038
+ };
1039
+ var ZapierValidationError = class extends ZapierError {
1040
+ constructor(message, options = {}) {
1041
+ super(message, options);
1042
+ this.name = "ZapierValidationError";
1043
+ this.code = "ZAPIER_VALIDATION_ERROR";
1044
+ this.details = options.details;
1045
+ }
1046
+ };
1047
+ var ZapierUnknownError = class extends ZapierError {
1048
+ constructor() {
1049
+ super(...arguments);
1050
+ this.name = "ZapierUnknownError";
1051
+ this.code = "ZAPIER_UNKNOWN_ERROR";
1052
+ }
1053
+ };
1054
+ var ZapierAuthenticationError = class extends ZapierError {
1055
+ constructor() {
1056
+ super(...arguments);
1057
+ this.name = "ZapierAuthenticationError";
1058
+ this.code = "ZAPIER_AUTHENTICATION_ERROR";
1059
+ }
1060
+ };
1061
+ var zapierAdaptError = (options) => {
1062
+ switch (options.code) {
1063
+ case CoreErrorCode.Validation:
1064
+ return new ZapierValidationError(options.message, {
1065
+ cause: options.cause,
1066
+ details: options.details
1067
+ });
1068
+ case CoreErrorCode.Unknown:
1069
+ return new ZapierUnknownError(options.message, {
1070
+ cause: options.cause
1071
+ });
1072
+ default:
1073
+ return new ZapierError(options.message, { cause: options.cause });
1074
+ }
1075
+ };
1076
+ var ZapierApiError = class extends ZapierError {
1077
+ constructor(message, options = {}) {
1078
+ super(message, options);
1079
+ this.name = "ZapierApiError";
1080
+ this.code = "ZAPIER_API_ERROR";
1081
+ }
1082
+ };
1083
+ var ZapierAppNotFoundError = class extends ZapierError {
1084
+ constructor(message, options = {}) {
1085
+ super(message, options);
1086
+ this.name = "ZapierAppNotFoundError";
1087
+ this.code = "ZAPIER_APP_NOT_FOUND_ERROR";
1088
+ this.appKey = options.appKey;
1089
+ }
1090
+ };
1091
+ var ZapierNotFoundError = class extends ZapierError {
1092
+ constructor(message, options = {}) {
1093
+ super(message, options);
1094
+ this.name = "ZapierNotFoundError";
1095
+ this.code = "ZAPIER_NOT_FOUND_ERROR";
1096
+ }
1097
+ };
1098
+ var ZapierResourceNotFoundError = class extends ZapierNotFoundError {
1099
+ constructor(message, options = {}) {
1100
+ super(message, options);
1101
+ this.name = "ZapierResourceNotFoundError";
1102
+ this.code = "ZAPIER_RESOURCE_NOT_FOUND_ERROR";
1103
+ this.resourceType = options.resourceType;
1104
+ this.resourceId = options.resourceId;
1105
+ }
1106
+ };
1107
+ var ZapierConfigurationError = class extends ZapierError {
1108
+ constructor(message, options = {}) {
1109
+ super(message, options);
1110
+ this.name = "ZapierConfigurationError";
1111
+ this.code = "ZAPIER_CONFIGURATION_ERROR";
1112
+ this.configType = options.configType;
1113
+ }
1114
+ };
1115
+ var ZapierBundleError = class extends ZapierError {
1116
+ constructor(message, options = {}) {
1117
+ super(message, options);
1118
+ this.name = "ZapierBundleError";
1119
+ this.code = "ZAPIER_BUNDLE_ERROR";
1120
+ this.buildErrors = options.buildErrors;
1121
+ }
1122
+ };
1123
+ var ZapierTimeoutError = class extends ZapierError {
1124
+ constructor(message, options = {}) {
1125
+ super(message, options);
1126
+ this.name = "ZapierTimeoutError";
1127
+ this.code = "ZAPIER_TIMEOUT_ERROR";
1128
+ this.attempts = options.attempts;
1129
+ this.maxAttempts = options.maxAttempts;
1130
+ }
1131
+ };
1132
+ var ZapierActionError = class extends ZapierError {
1133
+ constructor(message, options = {}) {
1134
+ super(message, options);
1135
+ this.name = "ZapierActionError";
1136
+ this.code = "ZAPIER_ACTION_ERROR";
1137
+ this.appKey = options.appKey;
1138
+ this.actionKey = options.actionKey;
1139
+ }
1140
+ // Legacy accessor for backward compatibility
1141
+ get actionErrors() {
1142
+ return this.errors;
1143
+ }
1144
+ };
1145
+ var ZapierConflictError = class extends ZapierError {
1146
+ constructor(message, options = {}) {
1147
+ super(message, options);
1148
+ this.name = "ZapierConflictError";
1149
+ this.code = "ZAPIER_CONFLICT_ERROR";
1150
+ this.resourceType = options.resourceType;
1151
+ }
1152
+ };
1153
+ var ZapierRateLimitError = class extends ZapierError {
1154
+ constructor(message, options = {}) {
1155
+ super(message, options);
1156
+ this.name = "ZapierRateLimitError";
1157
+ this.code = "ZAPIER_RATE_LIMIT_ERROR";
1158
+ this.rateLimit = options.rateLimit ?? {};
1159
+ this.retries = options.retries ?? 0;
1160
+ }
1161
+ };
1162
+ var ZapierApprovalError = class extends ZapierError {
1163
+ constructor(message, options = {}) {
1164
+ super(message, options);
1165
+ this.name = "ZapierApprovalError";
1166
+ this.code = "ZAPIER_APPROVAL_ERROR";
1167
+ this.approvalId = options.approvalId;
1168
+ this.approvalStatus = options.status;
1169
+ this.approvalUrl = options.approvalUrl;
1170
+ this.pollUrl = options.pollUrl;
1171
+ }
1172
+ };
1173
+ var ZapierRelayError = class extends ZapierError {
1174
+ constructor(message, options = {}) {
1175
+ super(message, options);
1176
+ this.name = "ZapierRelayError";
1177
+ this.code = "ZAPIER_RELAY_ERROR";
1178
+ }
1179
+ };
1180
+ function formatErrorMessage(error) {
1181
+ let message = error.message;
1182
+ if (error.errors && error.errors.length > 0) {
1183
+ const additionalErrors = error.errors.slice(1);
1184
+ if (additionalErrors.length > 0) {
1185
+ const errorDetails = additionalErrors.map((err) => ` \u2022 ${err.detail || err.title || err.code}`).join("\n");
1186
+ message += "\n\nAdditional errors:\n" + errorDetails;
1187
+ }
1188
+ }
1189
+ if (error instanceof ZapierAppNotFoundError && error.appKey) {
1190
+ message += `
1191
+ App key: ${error.appKey}`;
1192
+ }
1193
+ if (error instanceof ZapierActionError && (error.appKey || error.actionKey)) {
1194
+ const context = [];
1195
+ if (error.appKey) context.push(`App: ${error.appKey}`);
1196
+ if (error.actionKey) context.push(`Action: ${error.actionKey}`);
1197
+ message += `
1198
+ ${context.join(", ")}`;
1199
+ }
1200
+ if (error instanceof ZapierResourceNotFoundError && (error.resourceType || error.resourceId)) {
1201
+ const context = [];
1202
+ if (error.resourceType) context.push(`Type: ${error.resourceType}`);
1203
+ if (error.resourceId) context.push(`ID: ${error.resourceId}`);
1204
+ message += `
1205
+ ${context.join(", ")}`;
1206
+ }
1207
+ if (error instanceof ZapierConflictError && error.resourceType) {
1208
+ message += `
1209
+ Type: ${error.resourceType}`;
1210
+ }
1211
+ if (error instanceof ZapierTimeoutError && (error.attempts || error.maxAttempts)) {
1212
+ const context = [];
1213
+ if (error.attempts) context.push(`Attempts: ${error.attempts}`);
1214
+ if (error.maxAttempts) context.push(`Max attempts: ${error.maxAttempts}`);
1215
+ message += `
1216
+ ${context.join(", ")}`;
1217
+ }
1218
+ if (error instanceof ZapierBundleError && error.buildErrors && error.buildErrors.length > 0) {
1219
+ message += "\n\nBuild errors:\n" + error.buildErrors.map((err) => ` \u2022 ${err}`).join("\n");
1220
+ }
1221
+ if (error instanceof ZapierApprovalError && error.approvalUrl) {
1222
+ message += `
1223
+ Approval URL: ${error.approvalUrl}`;
1224
+ }
1225
+ if (error instanceof ZapierRateLimitError) {
1226
+ const { limit, remaining, retryAfterMs } = error.rateLimit;
1227
+ const parts = [];
1228
+ if (limit !== void 0) {
1229
+ const used = remaining !== void 0 ? limit - remaining : limit;
1230
+ parts.push(`${used}/${limit} used`);
1231
+ }
1232
+ if (retryAfterMs !== void 0 && retryAfterMs > 0) {
1233
+ parts.push(`retry in ${formatDuration(retryAfterMs)}`);
1114
1234
  }
1115
- seen.add(key);
1116
- target[key] = source[key];
1117
- }
1118
- }
1119
- function mergeMetaKeysWithCollisionCheck(target, source, seen) {
1120
- for (const key of Object.keys(source)) {
1121
- if (seen.has(key)) {
1122
- throw new Error(
1123
- `composePlugins: duplicate context.meta key "${key}". Two sub-plugins registered metadata for the same name.`
1235
+ if (error.retries > 0) {
1236
+ parts.push(
1237
+ `after ${error.retries} retr${error.retries === 1 ? "y" : "ies"}`
1124
1238
  );
1125
1239
  }
1126
- seen.add(key);
1127
- target[key] = source[key];
1128
- }
1129
- }
1130
- function mergeContextKeysWithCollisionCheck(target, source, seen) {
1131
- for (const key of Object.keys(source)) {
1132
- if (seen.has(key)) {
1133
- throw new Error(
1134
- `composePlugins: duplicate context key "${key}". Two sub-plugins contributed the same context.${key} field.`
1135
- );
1240
+ if (parts.length > 0) {
1241
+ message += `
1242
+ ${parts.join(", ")}`;
1136
1243
  }
1137
- seen.add(key);
1138
- target[key] = source[key];
1139
1244
  }
1245
+ if (error.statusCode && !message.includes(`${error.statusCode}`)) {
1246
+ message += `
1247
+ HTTP Status: ${error.statusCode}`;
1248
+ }
1249
+ return message;
1140
1250
  }
1141
- function composePlugins(...plugins) {
1142
- return (sdk) => {
1143
- const merged = { context: { meta: {} } };
1144
- const seenRoot = /* @__PURE__ */ new Set();
1145
- const seenMeta = /* @__PURE__ */ new Set();
1146
- const seenContext = /* @__PURE__ */ new Set();
1147
- for (const plugin of plugins) {
1148
- const { context, ...rootKeys } = plugin(sdk);
1149
- mergeRootKeysWithCollisionCheck(merged, rootKeys, seenRoot);
1150
- if (context) {
1151
- const { meta, ...nonMetaContext } = context;
1152
- if (meta) {
1153
- mergeMetaKeysWithCollisionCheck(merged.context.meta, meta, seenMeta);
1154
- }
1155
- mergeContextKeysWithCollisionCheck(
1156
- merged.context,
1157
- nonMetaContext,
1158
- seenContext
1159
- );
1160
- }
1161
- }
1162
- return merged;
1163
- };
1251
+ function formatDuration(ms) {
1252
+ const seconds = Math.round(ms / 1e3);
1253
+ if (seconds < 60) return `${seconds}s`;
1254
+ const minutes = Math.round(seconds / 60);
1255
+ if (minutes < 60) return `${minutes}m`;
1256
+ const hours = Math.round(minutes / 60);
1257
+ if (hours < 24) return `${hours}h`;
1258
+ const days = Math.round(hours / 24);
1259
+ return `${days}d`;
1164
1260
  }
1165
- function getStringProperty(obj, key) {
1166
- if (typeof obj === "object" && obj !== null && key in obj) {
1167
- const value = obj[key];
1168
- return typeof value === "string" ? value : void 0;
1261
+
1262
+ // src/core-stack.ts
1263
+ var zapierCorePlugin = createCorePlugin({
1264
+ adaptError: zapierAdaptError
1265
+ });
1266
+ function createZapierCoreStack() {
1267
+ return createPluginStack().use(zapierCorePlugin);
1268
+ }
1269
+
1270
+ // src/constants.ts
1271
+ var ZAPIER_BASE_URL = globalThis.process?.env?.ZAPIER_BASE_URL || "https://zapier.com";
1272
+ function getZapierSdkService() {
1273
+ return globalThis.process?.env?.ZAPIER_SDK_SERVICE;
1274
+ }
1275
+ var MAX_PAGE_LIMIT = 1e4;
1276
+ var DEFAULT_PAGE_SIZE = 100;
1277
+ var DEFAULT_ACTION_TIMEOUT_MS = 18e4;
1278
+ function parseIntEnvVar(name) {
1279
+ const value = globalThis.process?.env?.[name];
1280
+ if (value === void 0) return void 0;
1281
+ const parsed = parseInt(value, 10);
1282
+ if (isNaN(parsed)) {
1283
+ console.warn(
1284
+ `[zapier-sdk] Invalid value for ${name}: "${value}" (expected integer)`
1285
+ );
1286
+ return void 0;
1287
+ }
1288
+ return parsed;
1289
+ }
1290
+ var ZAPIER_MAX_NETWORK_RETRIES = parseIntEnvVar("ZAPIER_MAX_NETWORK_RETRIES") ?? 3;
1291
+ var ZAPIER_MAX_NETWORK_RETRY_DELAY_MS = parseIntEnvVar("ZAPIER_MAX_NETWORK_RETRY_DELAY_MS") ?? 6e4;
1292
+ var MAX_CONCURRENCY_LIMIT = 1e4;
1293
+ function parseConcurrencyEnvVar(name) {
1294
+ const value = globalThis.process?.env?.[name];
1295
+ if (!value) return void 0;
1296
+ if (value === "Infinity") return Infinity;
1297
+ if (/^[1-9]\d*$/.test(value)) {
1298
+ const parsed = parseInt(value, 10);
1299
+ if (parsed <= MAX_CONCURRENCY_LIMIT) return parsed;
1169
1300
  }
1301
+ console.warn(
1302
+ `[zapier-sdk] Invalid value for ${name}: "${value}" (expected positive integer 1-${MAX_CONCURRENCY_LIMIT} or "Infinity")`
1303
+ );
1170
1304
  return void 0;
1171
1305
  }
1172
- function formatActionResult(item) {
1173
- const obj = typeof item === "object" && item !== null ? item : {};
1174
- const title = getStringProperty(obj, "title") || getStringProperty(obj, "name") || getStringProperty(obj, "label") || getStringProperty(obj, "subject") || "Action Result";
1175
- return {
1176
- title,
1177
- id: getStringProperty(obj, "id"),
1178
- key: getStringProperty(obj, "key"),
1179
- description: getStringProperty(obj, "description"),
1180
- data: item,
1181
- // Let formatJsonOutput handle the JSON rendering
1182
- details: []
1183
- // Not used when data is provided
1184
- };
1306
+ var ZAPIER_MAX_CONCURRENT_REQUESTS = parseConcurrencyEnvVar("ZAPIER_MAX_CONCURRENT_REQUESTS") ?? 200;
1307
+ function getZapierApprovalMode() {
1308
+ const value = globalThis.process?.env?.ZAPIER_APPROVAL_MODE;
1309
+ if (value === "disabled" || value === "poll" || value === "throw")
1310
+ return value;
1311
+ return void 0;
1312
+ }
1313
+ function getZapierDefaultApprovalMode() {
1314
+ const isInteractive = !!globalThis.process?.stdin?.isTTY && !!globalThis.process?.stdout?.isTTY;
1315
+ return isInteractive ? "poll" : "throw";
1185
1316
  }
1186
- var ActionResultItemSchema = withFormatter(
1187
- zod.z.unknown().describe("Action execution result"),
1188
- { format: formatActionResult }
1317
+ var DEFAULT_APPROVAL_TIMEOUT_MS = 10 * 60 * 1e3;
1318
+ var DEFAULT_MAX_APPROVAL_RETRIES = 2;
1319
+
1320
+ // src/types/properties.ts
1321
+ var AppKeyPropertySchema = withPositional(
1322
+ zod.z.string().min(1).describe("App key (e.g., 'SlackCLIAPI' or slug like 'github')")
1323
+ );
1324
+ var AppPropertySchema = withPositional(
1325
+ zod.z.string().min(1).describe(
1326
+ "App slug (e.g., 'github'), implementation name (e.g., 'SlackCLIAPI'), or versioned ID (e.g., 'github@1.2.3')"
1327
+ )
1328
+ );
1329
+ var ActionTypePropertySchema = zod.z.enum([
1330
+ "read",
1331
+ "read_bulk",
1332
+ "write",
1333
+ "run",
1334
+ "search",
1335
+ "search_or_write",
1336
+ "search_and_write",
1337
+ "filter"
1338
+ ]).describe("Action type that matches the action's defined type");
1339
+ var ActionKeyPropertySchema = zod.z.string().min(1).describe("Action key to execute");
1340
+ var ActionPropertySchema = withPositional(
1341
+ zod.z.string().min(1).describe("Action key (e.g., 'send_message' or 'find_row')")
1342
+ );
1343
+ var InputFieldPropertySchema = withPositional(
1344
+ zod.z.string().min(1).describe("Input field key to get choices for")
1345
+ );
1346
+ var ConnectionIdPropertySchema = zod.z.union([zod.z.string(), zod.z.number().int().positive()]).describe("Connection ID to use for this action");
1347
+ var AuthenticationIdPropertySchema = ConnectionIdPropertySchema.meta({
1348
+ deprecated: true
1349
+ });
1350
+ var ConnectionPropertySchema = zod.z.union([zod.z.string(), zod.z.number().int().positive()]).describe(
1351
+ "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."
1352
+ );
1353
+ var InputsPropertySchema = zod.z.record(zod.z.string(), zod.z.unknown()).describe("Input parameters for the action");
1354
+ var LimitPropertySchema = zod.z.number().int().min(1).max(MAX_PAGE_LIMIT).default(50).describe("Maximum number of items to return");
1355
+ var OffsetPropertySchema = zod.z.number().int().min(0).default(0).describe("Number of items to skip for pagination");
1356
+ var OutputPropertySchema = zod.z.string().describe("Output file path");
1357
+ var DebugPropertySchema = zod.z.boolean().default(false).describe("Enable debug logging");
1358
+ var ParamsPropertySchema = zod.z.record(zod.z.string(), zod.z.unknown()).describe("Additional parameters");
1359
+ var ActionTimeoutMsPropertySchema = zod.z.number().min(1e3).optional().describe(
1360
+ `Maximum time to wait for action completion in milliseconds (default: ${DEFAULT_ACTION_TIMEOUT_MS})`
1361
+ );
1362
+ var TablePropertySchema = withPositional(
1363
+ zod.z.string().regex(/^[A-Z0-9]{26}$/, "Table ID must be a valid ULID").describe("The unique identifier of the table")
1364
+ );
1365
+ var RecordPropertySchema = withPositional(
1366
+ zod.z.string().regex(/^[A-Z0-9]{26}$/, "Record ID must be a valid ULID").describe("The unique identifier of the record")
1367
+ );
1368
+ var RecordsPropertySchema = zod.z.array(zod.z.string().regex(/^[A-Z0-9]{26}$/, "Record ID must be a valid ULID")).min(1).max(100).describe("Record IDs to operate on");
1369
+ var FieldsPropertySchema = zod.z.array(zod.z.union([zod.z.string(), zod.z.number()])).describe(
1370
+ 'Fields to operate on. Accepts field names (e.g., "Email") or IDs (e.g., "f6", "6", or 6).'
1371
+ );
1372
+ var AppsPropertySchema = zod.z.array(zod.z.string()).describe("Filter by app keys (e.g., 'SlackCLIAPI' or slug like 'github')");
1373
+ var TablesPropertySchema = zod.z.array(zod.z.string()).describe("Filter by specific table IDs");
1374
+ var ConnectionsPropertySchema = zod.z.array(zod.z.string()).describe("List of connection IDs to filter by");
1375
+ var TriggerInboxPropertySchema = withPositional(
1376
+ zod.z.string().min(1).describe(
1377
+ "Trigger inbox identifier \u2014 UUID or name. Non-UUID values are resolved by name via the inbox list endpoint."
1378
+ )
1379
+ );
1380
+ var TriggerInboxNamePropertySchema = zod.z.string().min(1).max(100).describe(
1381
+ "Inbox name; unique per (user, account). Enables get-or-create on createTriggerInbox."
1382
+ );
1383
+ var LeasePropertySchema = zod.z.string().min(1).describe("Lease ID returned from leaseTriggerInboxMessages");
1384
+ var LeaseSecondsPropertySchema = zod.z.number().int().min(1).max(3600).describe(
1385
+ "Seconds until the lease expires; messages return to available if not acked. API default is 300 (5 minutes)."
1189
1386
  );
1387
+ var LeaseLimitPropertySchema = zod.z.number().int().min(1).max(100).describe("Maximum messages to lease in a single batch (1-100)");
1388
+
1389
+ // src/plugins/apps/schemas.ts
1390
+ var ActionExecutionInputSchema = zod.z.object({
1391
+ inputs: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
1392
+ /** @deprecated Use `connection` instead. */
1393
+ connectionId: ConnectionIdPropertySchema.optional().meta({
1394
+ deprecated: true
1395
+ }),
1396
+ connection: ConnectionPropertySchema.optional(),
1397
+ /** @deprecated Use connection instead */
1398
+ authenticationId: AuthenticationIdPropertySchema.optional().meta({
1399
+ deprecated: true
1400
+ }),
1401
+ timeoutMs: ActionTimeoutMsPropertySchema
1402
+ }).describe(
1403
+ "Execute an action with the given inputs for the bound app, as an alternative to runAction"
1404
+ ).meta({
1405
+ aliases: { connectionId: "connection", authenticationId: "connection" }
1406
+ });
1407
+ var AppFactoryInputSchema = zod.z.object({
1408
+ /** @deprecated Use `connection` instead. */
1409
+ connectionId: ConnectionIdPropertySchema.optional().meta({
1410
+ deprecated: true
1411
+ }),
1412
+ connection: ConnectionPropertySchema.optional(),
1413
+ /** @deprecated Use connection instead */
1414
+ authenticationId: AuthenticationIdPropertySchema.optional().meta({
1415
+ deprecated: true
1416
+ })
1417
+ }).describe("Bind a connection alias or numeric connectionId to an app").meta({
1418
+ aliases: { connectionId: "connection", authenticationId: "connection" }
1419
+ });
1420
+ var ActionResultItemSchema = zod.z.unknown().describe("Action execution result");
1190
1421
 
1191
1422
  // src/plugins/apps/index.ts
1192
1423
  function resolveProxyConnection({
@@ -1407,18 +1638,6 @@ var FetchInitSchema = zod.z.object({
1407
1638
  aliases: { connectionId: "connection", authenticationId: "connection" }
1408
1639
  });
1409
1640
 
1410
- // src/utils/string-utils.ts
1411
- function toTitleCase(input) {
1412
- 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(" ");
1413
- }
1414
- function toSnakeCase(input) {
1415
- let result = input.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/[\s\-]+/g, "_").replace(/_+/g, "_").replace(/^_|_$/g, "").toLowerCase();
1416
- if (/^[0-9]/.test(result)) {
1417
- result = "_" + result;
1418
- }
1419
- return result;
1420
- }
1421
-
1422
1641
  // src/utils/domain-utils.ts
1423
1642
  function isConnectionId(value) {
1424
1643
  return /^\d+$/.test(value) || isUuid(value);
@@ -1721,15 +1940,25 @@ function buildAbortHandle({
1721
1940
  return combineAbortSignals({ handles });
1722
1941
  }
1723
1942
  var FetchInitSdkValidationSchema = zod.z.looseObject(FetchInitZapierFieldsSchema.shape).optional();
1724
- var validateFetchInit = createValidator(FetchInitSdkValidationSchema);
1725
1943
  var fetchPlugin = definePlugin(
1726
1944
  (sdk) => {
1945
+ const validateFetchInit = createValidator(FetchInitSdkValidationSchema, {
1946
+ adaptError: sdk.context.core?.adaptError
1947
+ });
1727
1948
  return {
1728
1949
  fetch: async function fetch2(url, init) {
1729
- return runWithTelemetryContext(async () => {
1950
+ return runInMethodScope(async () => {
1730
1951
  const { api } = sdk.context;
1952
+ const { onMethodStart, onMethodEnd } = sdk.context.hooks;
1731
1953
  const startTime = Date.now();
1732
- const isNested = isTelemetryNested();
1954
+ const depth = getCurrentDepth();
1955
+ const args = init === void 0 ? [url] : [url, init];
1956
+ onMethodStart?.({
1957
+ methodName: "fetch",
1958
+ args,
1959
+ isPaginated: false,
1960
+ depth
1961
+ });
1733
1962
  try {
1734
1963
  if (init) {
1735
1964
  validateFetchInit(init);
@@ -1801,17 +2030,13 @@ var fetchPlugin = definePlugin(
1801
2030
  statusCode: result.status
1802
2031
  });
1803
2032
  }
1804
- if (!isNested) {
1805
- sdk.context.eventEmission.emitMethodCalled({
1806
- method_name: "fetch",
1807
- execution_duration_ms: Date.now() - startTime,
1808
- success_flag: true,
1809
- error_message: null,
1810
- error_type: null,
1811
- argument_count: init ? 2 : 1,
1812
- is_paginated: false
1813
- });
1814
- }
2033
+ onMethodEnd?.({
2034
+ methodName: "fetch",
2035
+ args,
2036
+ isPaginated: false,
2037
+ depth,
2038
+ durationMs: Date.now() - startTime
2039
+ });
1815
2040
  return result;
1816
2041
  } catch (error) {
1817
2042
  throw rewrapIfMaxTimeTimeout({
@@ -1823,17 +2048,14 @@ var fetchPlugin = definePlugin(
1823
2048
  abortHandle?.dispose();
1824
2049
  }
1825
2050
  } catch (error) {
1826
- if (!isNested) {
1827
- sdk.context.eventEmission.emitMethodCalled({
1828
- method_name: "fetch",
1829
- execution_duration_ms: Date.now() - startTime,
1830
- success_flag: false,
1831
- error_message: error instanceof Error ? error.message : String(error),
1832
- error_type: error instanceof Error ? error.constructor.name : "Unknown",
1833
- argument_count: init ? 2 : 1,
1834
- is_paginated: false
1835
- });
1836
- }
2051
+ onMethodEnd?.({
2052
+ methodName: "fetch",
2053
+ args,
2054
+ isPaginated: false,
2055
+ depth,
2056
+ durationMs: Date.now() - startTime,
2057
+ error: error instanceof Error ? error : new Error(String(error))
2058
+ });
1837
2059
  throw error;
1838
2060
  }
1839
2061
  });
@@ -1843,7 +2065,11 @@ var fetchPlugin = definePlugin(
1843
2065
  fetch: {
1844
2066
  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.",
1845
2067
  packages: ["sdk", "cli", "mcp"],
1846
- categories: ["http"],
2068
+ // Auto-derive would produce "Http"/"Https" from the key alone;
2069
+ // declare the title explicitly here so the registry renders
2070
+ // "HTTP Request". Other plugins in this category use the bare
2071
+ // string "http"; the object form wins regardless of order.
2072
+ categories: [{ key: "http", title: "HTTP Request" }],
1847
2073
  returnType: "Response",
1848
2074
  inputParameters: [
1849
2075
  { name: "url", schema: FetchUrlSchema },
@@ -1932,7 +2158,7 @@ function createDebugLogger(enabled) {
1932
2158
  }
1933
2159
  return (message, data) => {
1934
2160
  if (data === void 0 || data === "") {
1935
- console.log(`[Zapier SDK] ${message}`);
2161
+ console.error(`[Zapier SDK] ${message}`);
1936
2162
  return;
1937
2163
  }
1938
2164
  if (utilModule) {
@@ -1941,9 +2167,9 @@ function createDebugLogger(enabled) {
1941
2167
  depth: null,
1942
2168
  breakLength: 80
1943
2169
  });
1944
- console.log(`[Zapier SDK] ${message}`, formatted);
2170
+ console.error(`[Zapier SDK] ${message}`, formatted);
1945
2171
  } else {
1946
- console.log(`[Zapier SDK] ${message}`, data);
2172
+ console.error(`[Zapier SDK] ${message}`, data);
1947
2173
  }
1948
2174
  };
1949
2175
  }
@@ -2142,7 +2368,8 @@ async function pollUntilComplete(options) {
2142
2368
  pendingStatus = DEFAULT_PENDING_STATUS,
2143
2369
  isPending,
2144
2370
  resultExtractor = (response) => response,
2145
- signal
2371
+ signal,
2372
+ maxPollingIntervalMs
2146
2373
  } = options;
2147
2374
  if (timeoutMs <= 0) {
2148
2375
  throw new ZapierValidationError("Timeout must be greater than 0", {
@@ -2154,6 +2381,14 @@ async function pollUntilComplete(options) {
2154
2381
  details: { initialDelay }
2155
2382
  });
2156
2383
  }
2384
+ if (maxPollingIntervalMs !== void 0 && maxPollingIntervalMs <= 0) {
2385
+ throw new ZapierValidationError(
2386
+ "Max polling interval must be greater than 0",
2387
+ {
2388
+ details: { maxPollingIntervalMs }
2389
+ }
2390
+ );
2391
+ }
2157
2392
  if (signal?.aborted) throw makeAbortError();
2158
2393
  const startTime = Date.now();
2159
2394
  let attempts = 0;
@@ -2176,7 +2411,8 @@ async function pollUntilComplete(options) {
2176
2411
  if (attempts > 0) {
2177
2412
  const interval = getPollingInterval(elapsedTime);
2178
2413
  const waitTime = calculateErrorBackoffMs(interval, errorCount);
2179
- await sleep(waitTime, signal);
2414
+ const cappedWaitTime = maxPollingIntervalMs === void 0 ? waitTime : Math.min(waitTime, maxPollingIntervalMs);
2415
+ await sleep(cappedWaitTime, signal);
2180
2416
  if (signal?.aborted) throw makeAbortError();
2181
2417
  }
2182
2418
  attempts++;
@@ -2459,17 +2695,17 @@ function resolveCredentialsFromEnv(sdkBaseUrl) {
2459
2695
  }
2460
2696
  }
2461
2697
  if (globalThis.process?.env?.ZAPIER_TOKEN) {
2462
- logDeprecation(
2698
+ logDeprecation2(
2463
2699
  "ZAPIER_TOKEN is deprecated. Use ZAPIER_CREDENTIALS instead."
2464
2700
  );
2465
2701
  return globalThis.process?.env?.ZAPIER_TOKEN;
2466
2702
  }
2467
2703
  if (globalThis.process?.env?.ZAPIER_AUTH_CLIENT_ID) {
2468
- logDeprecation(
2704
+ logDeprecation2(
2469
2705
  "ZAPIER_AUTH_CLIENT_ID is deprecated. Use ZAPIER_CREDENTIALS_CLIENT_ID instead."
2470
2706
  );
2471
2707
  if (globalThis.process?.env?.ZAPIER_AUTH_BASE_URL) {
2472
- logDeprecation(
2708
+ logDeprecation2(
2473
2709
  "ZAPIER_AUTH_BASE_URL is deprecated. Use ZAPIER_CREDENTIALS_BASE_URL instead."
2474
2710
  );
2475
2711
  }
@@ -2503,7 +2739,7 @@ async function resolveCredentials(options = {}) {
2503
2739
  return options.credentials;
2504
2740
  }
2505
2741
  if (options.token !== void 0) {
2506
- logDeprecation(
2742
+ logDeprecation2(
2507
2743
  "The `token` option is deprecated. Use `credentials` instead."
2508
2744
  );
2509
2745
  return options.token;
@@ -2745,7 +2981,7 @@ async function tryStoredClientCredentialToken(options) {
2745
2981
  const cached = await readCachedToken(cacheKey, cache);
2746
2982
  if (cached !== void 0) {
2747
2983
  if (options.debug)
2748
- console.log(
2984
+ console.error(
2749
2985
  `[auth] Using cached token (clientId: ${activeCredential.clientId})`
2750
2986
  );
2751
2987
  emitAuthResolved(options.onEvent, "client_credentials");
@@ -2764,7 +3000,7 @@ async function tryStoredClientCredentialToken(options) {
2764
3000
  );
2765
3001
  }
2766
3002
  if (options.debug)
2767
- console.log(
3003
+ console.error(
2768
3004
  `[auth] Using stored client credential (clientId: ${storedCredential.clientId})`
2769
3005
  );
2770
3006
  const token = await resolveAuthTokenFromCredentials(
@@ -2786,7 +3022,7 @@ async function resolveAuthToken(options = {}) {
2786
3022
  const storedToken = await tryStoredClientCredentialToken(options);
2787
3023
  if (storedToken !== void 0) return storedToken;
2788
3024
  if (options.debug) {
2789
- console.log("[auth] Using JWT (no stored client credential found)");
3025
+ console.error("[auth] Using JWT (no stored client credential found)");
2790
3026
  }
2791
3027
  const jwtToken = await getTokenFromCliLogin({
2792
3028
  onEvent: options.onEvent,
@@ -2816,7 +3052,7 @@ async function resolveAuthTokenFromCredentials(credentials, options) {
2816
3052
  const cached = await readCachedToken(cacheKey, cache);
2817
3053
  if (cached !== void 0) {
2818
3054
  if (options.debug) {
2819
- console.log(`[auth] Using cached token (clientId: ${clientId})`);
3055
+ console.error(`[auth] Using cached token (clientId: ${clientId})`);
2820
3056
  }
2821
3057
  return cached;
2822
3058
  }
@@ -2826,7 +3062,7 @@ async function resolveAuthTokenFromCredentials(credentials, options) {
2826
3062
  const recheck = await readCachedToken(cacheKey, cache);
2827
3063
  if (recheck !== void 0) {
2828
3064
  if (options.debug) {
2829
- console.log(
3065
+ console.error(
2830
3066
  `[auth] Using cached token (clientId: ${clientId}, locked recheck)`
2831
3067
  );
2832
3068
  }
@@ -2889,7 +3125,7 @@ async function invalidateCredentialsToken(options) {
2889
3125
  }
2890
3126
 
2891
3127
  // src/sdk-version.ts
2892
- var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.64.0" : void 0) || "unknown";
3128
+ var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.67.0" : void 0) || "unknown";
2893
3129
 
2894
3130
  // src/utils/open-url.ts
2895
3131
  var nodePrefix = "node:";
@@ -2974,6 +3210,7 @@ var PollApprovalResponseSchema = zod.z.object({
2974
3210
  status: ApprovalStatusSchema,
2975
3211
  approval_id: zod.z.string()
2976
3212
  });
3213
+ var APPROVAL_MAX_POLLING_INTERVAL_MS = 5e3;
2977
3214
  function parseRateLimitHeaders(response) {
2978
3215
  const info = {};
2979
3216
  const retryAfter = response.headers.get("retry-after");
@@ -3682,6 +3919,7 @@ var ZapierApiClient = class {
3682
3919
  })
3683
3920
  ),
3684
3921
  timeoutMs,
3922
+ maxPollingIntervalMs: APPROVAL_MAX_POLLING_INTERVAL_MS,
3685
3923
  isPending: (body2) => {
3686
3924
  const parsed = PollApprovalResponseSchema.safeParse(body2);
3687
3925
  return parsed.success && parsed.data.status === "pending_approval";
@@ -3816,36 +4054,36 @@ var apiPlugin = definePlugin(
3816
4054
  }
3817
4055
  );
3818
4056
  var GetProfileSchema = zod.z.object({}).optional().describe("Get current user's profile information");
3819
- var UserProfileItemSchema = withFormatter(
3820
- zod.z.object({
3821
- id: zod.z.string(),
3822
- first_name: zod.z.string(),
3823
- last_name: zod.z.string(),
3824
- full_name: zod.z.string(),
3825
- email: zod.z.string(),
3826
- email_confirmed: zod.z.boolean(),
3827
- timezone: zod.z.string()
3828
- }),
3829
- {
3830
- format: (item) => {
3831
- const details = [];
3832
- if ("email" in item) {
3833
- details.push({ text: item.email, style: "dim" });
3834
- }
3835
- if ("timezone" in item && item.timezone) {
3836
- details.push({
3837
- text: `Timezone: ${item.timezone}`,
3838
- style: "accent"
3839
- });
3840
- }
3841
- return {
3842
- title: item.full_name,
3843
- id: item.id,
3844
- details
3845
- };
4057
+ var UserProfileItemSchema = zod.z.object({
4058
+ id: zod.z.string(),
4059
+ first_name: zod.z.string(),
4060
+ last_name: zod.z.string(),
4061
+ full_name: zod.z.string(),
4062
+ email: zod.z.string(),
4063
+ email_confirmed: zod.z.boolean(),
4064
+ timezone: zod.z.string()
4065
+ });
4066
+
4067
+ // src/formatters/userProfile.ts
4068
+ var userProfileItemFormatter = {
4069
+ format: (item) => {
4070
+ const details = [];
4071
+ if (item.email) {
4072
+ details.push({ text: item.email, style: "dim" });
4073
+ }
4074
+ if (item.timezone) {
4075
+ details.push({
4076
+ text: `Timezone: ${item.timezone}`,
4077
+ style: "accent"
4078
+ });
3846
4079
  }
4080
+ return {
4081
+ title: item.full_name,
4082
+ id: item.id,
4083
+ details
4084
+ };
3847
4085
  }
3848
- );
4086
+ };
3849
4087
 
3850
4088
  // src/plugins/getProfile/index.ts
3851
4089
  var getProfilePlugin = definePlugin(
@@ -3856,6 +4094,7 @@ var getProfilePlugin = definePlugin(
3856
4094
  itemType: "Profile",
3857
4095
  inputSchema: GetProfileSchema,
3858
4096
  outputSchema: UserProfileItemSchema,
4097
+ formatter: userProfileItemFormatter,
3859
4098
  handler: async ({ sdk: sdk2 }) => {
3860
4099
  const profile = await sdk2.context.api.get(
3861
4100
  "/zapier/api/v4/profile/",
@@ -3875,6 +4114,29 @@ var getProfilePlugin = definePlugin(
3875
4114
  }
3876
4115
  })
3877
4116
  );
4117
+
4118
+ // src/utils/pagination.ts
4119
+ function extractCursorFromUrl(url) {
4120
+ try {
4121
+ const params = new URL(url).searchParams;
4122
+ return params.get("offset") ?? params.get("cursor") ?? void 0;
4123
+ } catch {
4124
+ return void 0;
4125
+ }
4126
+ }
4127
+ function adaptZapierPage(response) {
4128
+ const r = response ?? {};
4129
+ const data = r.data;
4130
+ const linksNext = r.links?.next;
4131
+ if (typeof linksNext === "string") {
4132
+ return { data, nextCursor: extractCursorFromUrl(linksNext) };
4133
+ }
4134
+ if (typeof r.next === "string") {
4135
+ return { data, nextCursor: extractCursorFromUrl(r.next) };
4136
+ }
4137
+ return { data };
4138
+ }
4139
+ var zapierPagination = { adaptPage: adaptZapierPage };
3878
4140
  var ListAppsSchema = apps.ListAppsQuerySchema.omit({
3879
4141
  offset: true,
3880
4142
  app_keys: true,
@@ -3896,27 +4158,30 @@ var ListAppsSchema = apps.ListAppsQuerySchema.omit({
3896
4158
  // SDK specific property for pagination/iterable helpers
3897
4159
  cursor: zod.z.string().optional().describe("Cursor to start from")
3898
4160
  }).describe("List all available apps with optional filtering");
3899
- var AppItemSchema = withFormatter(apps.AppItemSchema, {
3900
- format: (item) => {
3901
- return {
3902
- title: item.title,
3903
- key: item.key,
3904
- keys: getAppKeyList(item),
3905
- description: item.description,
3906
- details: []
3907
- };
3908
- }
3909
- });
4161
+ var AppItemSchema = apps.AppItemSchema;
4162
+
4163
+ // src/formatters/app.ts
4164
+ var appItemFormatter = {
4165
+ format: (item) => ({
4166
+ title: item.title,
4167
+ key: item.key,
4168
+ keys: getAppKeyList(item),
4169
+ description: item.description,
4170
+ details: []
4171
+ })
4172
+ };
3910
4173
 
3911
4174
  // src/plugins/listApps/index.ts
3912
4175
  var listAppsPlugin = definePlugin(
3913
4176
  (sdk) => createPaginatedPluginMethod(sdk, {
4177
+ ...zapierPagination,
3914
4178
  name: "listApps",
3915
4179
  categories: ["app"],
3916
4180
  type: "list",
3917
4181
  itemType: "App",
3918
4182
  inputSchema: ListAppsSchema,
3919
4183
  outputSchema: AppItemSchema,
4184
+ formatter: appItemFormatter,
3920
4185
  defaultPageSize: DEFAULT_PAGE_SIZE,
3921
4186
  handler: async ({ sdk: sdk2, options }) => {
3922
4187
  const { api, resolveAppKeys: resolveAppKeys2 } = sdk2.context;
@@ -3956,8 +4221,7 @@ var listAppsPlugin = definePlugin(
3956
4221
  ...options.cursor && { offset: options.cursor }
3957
4222
  }
3958
4223
  });
3959
- },
3960
- extractCursor: (response) => extractCursor(response.links)
4224
+ }
3961
4225
  })
3962
4226
  );
3963
4227
  var GetAppDescription = "Get detailed information about a specific app";
@@ -4174,7 +4438,7 @@ var inputFieldKeyResolver = {
4174
4438
  type: "dynamic",
4175
4439
  depends: ["app", "action", "actionType", "connection"],
4176
4440
  fetch: async (sdk, resolvedParams) => {
4177
- const fieldsResponse = await sdk.listInputFields({
4441
+ const fieldsResponse = await sdk.listActionInputFields({
4178
4442
  app: resolvedParams.app,
4179
4443
  action: resolvedParams.action,
4180
4444
  actionType: resolvedParams.actionType,
@@ -4280,7 +4544,8 @@ var workflowIdResolver = {
4280
4544
  name: "workflow",
4281
4545
  message: "Select a workflow:",
4282
4546
  choices: workflows.map((workflow) => ({
4283
- name: workflow.enabled ? workflow.name : `${workflow.name} (disabled)`,
4547
+ name: workflow.name,
4548
+ hint: workflow.enabled ? void 0 : [workflow.id, "disabled"],
4284
4549
  value: workflow.id
4285
4550
  }))
4286
4551
  })
@@ -4295,7 +4560,8 @@ var durableRunIdResolver = {
4295
4560
  name: "run",
4296
4561
  message: "Select a run:",
4297
4562
  choices: runs.map((run) => ({
4298
- name: `${run.id} \u2014 ${run.status}`,
4563
+ name: run.id,
4564
+ hint: run.status,
4299
4565
  value: run.id
4300
4566
  }))
4301
4567
  })
@@ -4305,11 +4571,7 @@ var durableRunIdResolver = {
4305
4571
  var workflowVersionIdResolver = {
4306
4572
  type: "dynamic",
4307
4573
  depends: ["workflow"],
4308
- fetch: async (sdk, params) => toIterable(
4309
- sdk.listWorkflowVersions({
4310
- workflow: params.workflow
4311
- })
4312
- ),
4574
+ fetch: async (sdk, params) => toIterable(sdk.listWorkflowVersions({ workflow: params.workflow })),
4313
4575
  prompt: (versions) => ({
4314
4576
  type: "list",
4315
4577
  name: "version",
@@ -4321,15 +4583,27 @@ var workflowVersionIdResolver = {
4321
4583
  })
4322
4584
  };
4323
4585
 
4586
+ // src/resolvers/workflowRunId.ts
4587
+ var workflowRunIdResolver = {
4588
+ type: "dynamic",
4589
+ depends: ["workflow"],
4590
+ fetch: async (sdk, params) => toIterable(sdk.listWorkflowRuns({ workflow: params.workflow })),
4591
+ prompt: (runs) => ({
4592
+ type: "list",
4593
+ name: "run",
4594
+ message: "Select a workflow run:",
4595
+ choices: runs.map((r) => ({
4596
+ name: `${r.id} \u2014 ${r.status}`,
4597
+ value: r.id
4598
+ }))
4599
+ })
4600
+ };
4601
+
4324
4602
  // src/resolvers/triggerMessages.ts
4325
4603
  var triggerMessagesResolver = {
4326
4604
  type: "dynamic",
4327
4605
  depends: ["inbox"],
4328
- fetch: async (sdk, params) => toIterable(
4329
- sdk.listTriggerInboxMessages({
4330
- inbox: params.inbox
4331
- })
4332
- ),
4606
+ fetch: async (sdk, params) => toIterable(sdk.listTriggerInboxMessages({ inbox: params.inbox })),
4333
4607
  prompt: (messages) => ({
4334
4608
  type: "checkbox",
4335
4609
  name: "messages",
@@ -4703,7 +4977,7 @@ var FieldApiItemSchema = zod.z.object({
4703
4977
  var ListTableFieldsApiResponseSchema = zod.z.object({
4704
4978
  data: zod.z.array(FieldApiItemSchema)
4705
4979
  });
4706
- var FieldItemSchemaBase = zod.z.object({
4980
+ var FieldItemSchema = zod.z.object({
4707
4981
  id: zod.z.string(),
4708
4982
  type: FieldTypeSchema,
4709
4983
  name: zod.z.string(),
@@ -4713,13 +4987,6 @@ var FieldItemSchemaBase = zod.z.object({
4713
4987
  config: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
4714
4988
  deleted_at: zod.z.string().nullable().optional()
4715
4989
  });
4716
- var FieldItemSchema = withFormatter(FieldItemSchemaBase, {
4717
- format: (item) => ({
4718
- title: item.name,
4719
- id: item.id,
4720
- details: [{ text: `Type: ${item.type}`, style: "dim" }]
4721
- })
4722
- });
4723
4990
  var ListTableFieldsDescription = "List fields for a table";
4724
4991
  var ListTableFieldsOptionsBaseSchema = zod.z.object({
4725
4992
  fields: FieldsPropertySchema.optional(),
@@ -4975,6 +5242,7 @@ var getAppPlugin = definePlugin(
4975
5242
  itemType: "App",
4976
5243
  inputSchema: GetAppInputSchema,
4977
5244
  outputSchema: AppItemSchema,
5245
+ formatter: appItemFormatter,
4978
5246
  resolvers: { app: appKeyResolver },
4979
5247
  handler: async ({ sdk: sdk2, options }) => {
4980
5248
  const appKey = "app" in options ? options.app : options.appKey;
@@ -5308,48 +5576,54 @@ zod.z.object({
5308
5576
  });
5309
5577
 
5310
5578
  // src/schemas/Action.ts
5311
- var ActionItemSchema = withFormatter(
5312
- ActionSchema.omit({ type: true, name: true, selected_api: true }).extend({
5313
- app_key: zod.z.string(),
5314
- // App key without version (extracted from selected_api)
5315
- app_version: zod.z.string().optional(),
5316
- // Version extracted from selected_api
5317
- action_type: ActionSchema.shape.type,
5318
- // Mapped from original 'type' field
5319
- title: zod.z.string(),
5320
- // Mapped from original 'name' field
5321
- type: zod.z.literal("action")
5322
- // Fixed type identifier
5323
- }),
5324
- {
5325
- format: (item) => {
5326
- const details = [];
5327
- details.push({
5328
- text: `Type: ${item.action_type}`,
5329
- style: "accent"
5330
- });
5331
- if (item.app_key) {
5332
- details.push({
5333
- text: `App: ${item.app_key}`,
5334
- style: "normal"
5335
- });
5336
- }
5337
- if (item.description) {
5338
- details.push({
5339
- text: item.description,
5340
- style: "dim"
5341
- });
5342
- }
5343
- return {
5344
- title: item.title || item.key,
5345
- id: item.id,
5346
- key: item.key,
5347
- description: item.description,
5348
- details
5349
- };
5579
+ var ActionItemSchema = ActionSchema.omit({
5580
+ type: true,
5581
+ name: true,
5582
+ selected_api: true
5583
+ }).extend({
5584
+ app_key: zod.z.string(),
5585
+ // App key without version (extracted from selected_api)
5586
+ app_version: zod.z.string().optional(),
5587
+ // Version extracted from selected_api
5588
+ action_type: ActionSchema.shape.type,
5589
+ // Mapped from original 'type' field
5590
+ title: zod.z.string(),
5591
+ // Mapped from original 'name' field
5592
+ type: zod.z.literal("action")
5593
+ // Fixed type identifier
5594
+ });
5595
+
5596
+ // src/formatters/action.ts
5597
+ var actionItemFormatter = {
5598
+ format: (item) => {
5599
+ const details = [{ text: `Type: ${item.action_type}`, style: "accent" }];
5600
+ if (item.app_key) {
5601
+ details.push({ text: `App: ${item.app_key}`, style: "normal" });
5350
5602
  }
5603
+ if (item.description) {
5604
+ details.push({ text: item.description, style: "dim" });
5605
+ }
5606
+ return {
5607
+ title: item.title || item.key,
5608
+ id: item.id,
5609
+ key: item.key,
5610
+ description: item.description,
5611
+ details
5612
+ };
5351
5613
  }
5352
- );
5614
+ };
5615
+
5616
+ // src/plugins/eventEmission/method-metadata.ts
5617
+ var SCOPE_KEY = "methodMetadata";
5618
+ function setMethodMetadata(metadata) {
5619
+ const scope = getCurrentScope();
5620
+ if (!scope) return;
5621
+ const existing = scope[SCOPE_KEY];
5622
+ scope[SCOPE_KEY] = { ...existing, ...metadata };
5623
+ }
5624
+ function getMethodMetadata() {
5625
+ return getCurrentScope()?.[SCOPE_KEY];
5626
+ }
5353
5627
 
5354
5628
  // src/plugins/listActions/index.ts
5355
5629
  var listActionsPlugin = definePlugin(
@@ -5360,12 +5634,10 @@ var listActionsPlugin = definePlugin(
5360
5634
  itemType: "Action",
5361
5635
  inputSchema: ListActionsInputSchema,
5362
5636
  outputSchema: ActionItemSchema,
5637
+ formatter: actionItemFormatter,
5363
5638
  defaultPageSize: DEFAULT_PAGE_SIZE,
5364
5639
  resolvers: { app: appKeyResolver, actionType: actionTypeResolver },
5365
- handler: async ({
5366
- sdk: sdk2,
5367
- options
5368
- }) => {
5640
+ handler: async ({ sdk: sdk2, options }) => {
5369
5641
  const { api, getVersionedImplementationId } = sdk2.context;
5370
5642
  const appKey = "app" in options ? options.app : options.appKey;
5371
5643
  const selectedApi = await getVersionedImplementationId(appKey);
@@ -5433,6 +5705,7 @@ var getActionPlugin = definePlugin(
5433
5705
  itemType: "Action",
5434
5706
  inputSchema: GetActionInputSchema,
5435
5707
  outputSchema: ActionItemSchema,
5708
+ formatter: actionItemFormatter,
5436
5709
  resolvers: {
5437
5710
  app: appKeyResolver,
5438
5711
  actionType: actionTypeResolver,
@@ -5494,6 +5767,29 @@ var RunActionSchemaDeprecated = zod.z.object({
5494
5767
  actionKey: ActionKeyPropertySchema
5495
5768
  }).merge(RunActionBaseSchema);
5496
5769
  var RunActionInputSchema = zod.z.union([RunActionSchema, RunActionSchemaDeprecated]).describe(RunActionDescription);
5770
+
5771
+ // src/formatters/actionResult.ts
5772
+ function getStringProperty(obj, key) {
5773
+ if (typeof obj === "object" && obj !== null && key in obj) {
5774
+ const value = obj[key];
5775
+ return typeof value === "string" ? value : void 0;
5776
+ }
5777
+ return void 0;
5778
+ }
5779
+ var actionResultItemFormatter = {
5780
+ format: (item) => {
5781
+ const obj = typeof item === "object" && item !== null ? item : {};
5782
+ const title = getStringProperty(obj, "title") || getStringProperty(obj, "name") || getStringProperty(obj, "label") || getStringProperty(obj, "subject") || "Action Result";
5783
+ return {
5784
+ title,
5785
+ id: getStringProperty(obj, "id"),
5786
+ key: getStringProperty(obj, "key"),
5787
+ description: getStringProperty(obj, "description"),
5788
+ data: item,
5789
+ details: []
5790
+ };
5791
+ }
5792
+ };
5497
5793
  async function executeAction(actionOptions) {
5498
5794
  const {
5499
5795
  api,
@@ -5623,6 +5919,7 @@ var runActionPlugin = definePlugin(
5623
5919
  itemType: "ActionResult",
5624
5920
  inputSchema: RunActionInputSchema,
5625
5921
  outputSchema: ActionResultItemSchema,
5922
+ formatter: actionResultItemFormatter,
5626
5923
  resolvers: {
5627
5924
  app: appKeyResolver,
5628
5925
  actionType: actionTypeResolver,
@@ -5630,10 +5927,7 @@ var runActionPlugin = definePlugin(
5630
5927
  connection: connectionIdResolver,
5631
5928
  inputs: inputsResolver
5632
5929
  },
5633
- handler: async ({
5634
- sdk: sdk2,
5635
- options
5636
- }) => {
5930
+ handler: async ({ sdk: sdk2, options }) => {
5637
5931
  const { api } = sdk2.context;
5638
5932
  const appKey = "app" in options ? options.app : options.appKey;
5639
5933
  const actionKey = "action" in options ? options.action : options.actionKey;
@@ -5686,7 +5980,9 @@ var runActionPlugin = definePlugin(
5686
5980
  }
5687
5981
  return {
5688
5982
  data: result.results || [],
5689
- nextCursor: result.next_page
5983
+ // Coerce to a string: the API returns a numeric page index, but
5984
+ // `SdkPage.nextCursor` is a string (and the page guard enforces it).
5985
+ nextCursor: result.next_page != null ? String(result.next_page) : void 0
5690
5986
  };
5691
5987
  }
5692
5988
  });
@@ -5741,7 +6037,10 @@ var ListConnectionsQuerySchema = connections.ListConnectionsQuerySchema.omit({
5741
6037
  // SDK specific property for pagination/iterable helpers
5742
6038
  cursor: zod.z.string().optional().describe("Cursor to start from")
5743
6039
  }).describe("List available connections with optional filtering");
5744
- var ConnectionItemSchema = withFormatter(connections.ConnectionItemSchema, {
6040
+ var ConnectionItemSchema = connections.ConnectionItemSchema;
6041
+
6042
+ // src/formatters/connection.ts
6043
+ var connectionItemFormatter = {
5745
6044
  format: (item) => {
5746
6045
  const details = [];
5747
6046
  if (item.identifier) {
@@ -5766,17 +6065,19 @@ var ConnectionItemSchema = withFormatter(connections.ConnectionItemSchema, {
5766
6065
  details
5767
6066
  };
5768
6067
  }
5769
- });
6068
+ };
5770
6069
 
5771
6070
  // src/plugins/listConnections/index.ts
5772
6071
  var listConnectionsPlugin = definePlugin(
5773
6072
  (sdk) => createPaginatedPluginMethod(sdk, {
6073
+ ...zapierPagination,
5774
6074
  name: "listConnections",
5775
6075
  categories: ["connection"],
5776
6076
  type: "list",
5777
6077
  itemType: "Connection",
5778
6078
  inputSchema: ListConnectionsQuerySchema,
5779
6079
  outputSchema: ConnectionItemSchema,
6080
+ formatter: connectionItemFormatter,
5780
6081
  defaultPageSize: DEFAULT_PAGE_SIZE,
5781
6082
  resolvers: { app: appKeyResolver },
5782
6083
  handler: async ({ sdk: sdk2, options }) => {
@@ -5849,8 +6150,7 @@ var listConnectionsPlugin = definePlugin(
5849
6150
  ...response,
5850
6151
  data: response.data.map(transformConnectionItem)
5851
6152
  };
5852
- },
5853
- extractCursor: (response) => extractCursor(response.links)
6153
+ }
5854
6154
  })
5855
6155
  );
5856
6156
  var GetConnectionParamSchema = zod.z.object({
@@ -5874,6 +6174,7 @@ var getConnectionPlugin = definePlugin(
5874
6174
  itemType: "Connection",
5875
6175
  inputSchema: GetConnectionParamSchema,
5876
6176
  outputSchema: ConnectionItemSchema,
6177
+ formatter: connectionItemFormatter,
5877
6178
  resolvers: { connection: connectionIdGenericResolver },
5878
6179
  handler: async ({ sdk: sdk2, options }) => {
5879
6180
  const { api } = sdk2.context;
@@ -5914,6 +6215,7 @@ var findFirstConnectionPlugin = definePlugin(
5914
6215
  itemType: "Connection",
5915
6216
  inputSchema: FindFirstConnectionSchema,
5916
6217
  outputSchema: ConnectionItemSchema,
6218
+ formatter: connectionItemFormatter,
5917
6219
  handler: async ({ sdk: sdk2, options = {} }) => {
5918
6220
  const connectionsResponse = await sdk2.listConnections({
5919
6221
  ...options,
@@ -5949,6 +6251,7 @@ var findUniqueConnectionPlugin = definePlugin(
5949
6251
  itemType: "Connection",
5950
6252
  inputSchema: FindUniqueConnectionSchema,
5951
6253
  outputSchema: ConnectionItemSchema,
6254
+ formatter: connectionItemFormatter,
5952
6255
  handler: async ({ sdk: sdk2, options = {} }) => {
5953
6256
  const connectionsResponse = await sdk2.listConnections({
5954
6257
  ...options,
@@ -5979,11 +6282,13 @@ var listAuthenticationsPlugin = definePlugin(
5979
6282
  meta: {
5980
6283
  listAuthentications: {
5981
6284
  packages: ["cli", "mcp"],
5982
- categories: ["connection", "deprecated"],
6285
+ categories: ["connection"],
6286
+ deprecation: { message: "Use listConnections instead." },
5983
6287
  type: "list",
5984
6288
  itemType: "Connection",
5985
6289
  inputSchema: ListConnectionsQuerySchema,
5986
- outputSchema: ConnectionItemSchema
6290
+ outputSchema: ConnectionItemSchema,
6291
+ formatter: connectionItemFormatter
5987
6292
  }
5988
6293
  }
5989
6294
  }
@@ -5996,11 +6301,13 @@ var getAuthenticationPlugin = definePlugin(
5996
6301
  meta: {
5997
6302
  getAuthentication: {
5998
6303
  packages: ["cli", "mcp"],
5999
- categories: ["connection", "deprecated"],
6304
+ categories: ["connection"],
6305
+ deprecation: { message: "Use getConnection instead." },
6000
6306
  type: "item",
6001
6307
  itemType: "Connection",
6002
6308
  inputSchema: GetConnectionParamSchema,
6003
- outputSchema: ConnectionItemSchema
6309
+ outputSchema: ConnectionItemSchema,
6310
+ formatter: connectionItemFormatter
6004
6311
  }
6005
6312
  }
6006
6313
  }
@@ -6013,11 +6320,13 @@ var findFirstAuthenticationPlugin = definePlugin(
6013
6320
  meta: {
6014
6321
  findFirstAuthentication: {
6015
6322
  packages: ["cli", "mcp"],
6016
- categories: ["connection", "deprecated"],
6323
+ categories: ["connection"],
6324
+ deprecation: { message: "Use findFirstConnection instead." },
6017
6325
  type: "item",
6018
6326
  itemType: "Connection",
6019
6327
  inputSchema: FindFirstConnectionSchema,
6020
- outputSchema: ConnectionItemSchema
6328
+ outputSchema: ConnectionItemSchema,
6329
+ formatter: connectionItemFormatter
6021
6330
  }
6022
6331
  }
6023
6332
  }
@@ -6030,11 +6339,13 @@ var findUniqueAuthenticationPlugin = definePlugin(
6030
6339
  meta: {
6031
6340
  findUniqueAuthentication: {
6032
6341
  packages: ["cli", "mcp"],
6033
- categories: ["connection", "deprecated"],
6342
+ categories: ["connection"],
6343
+ deprecation: { message: "Use findUniqueConnection instead." },
6034
6344
  type: "item",
6035
6345
  itemType: "Connection",
6036
6346
  inputSchema: FindUniqueConnectionSchema,
6037
- outputSchema: ConnectionItemSchema
6347
+ outputSchema: ConnectionItemSchema,
6348
+ formatter: connectionItemFormatter
6038
6349
  }
6039
6350
  }
6040
6351
  }
@@ -6051,58 +6362,49 @@ var ListClientCredentialsQuerySchema = clientCredentials.ListClientCredentialsQu
6051
6362
  // SDK specific property for pagination/iterable helpers
6052
6363
  cursor: zod.z.string().optional().describe("Cursor to start from")
6053
6364
  }).describe("List client credentials for the authenticated user");
6054
- var ClientCredentialsItemSchema = withFormatter(
6055
- clientCredentials.ClientCredentialsItemSchema,
6056
- {
6057
- format: (item) => {
6058
- const details = [];
6059
- if (item.allowed_scopes && item.allowed_scopes.length > 0) {
6060
- details.push({
6061
- text: `Scopes: ${item.allowed_scopes.join(", ")}`,
6062
- style: "accent"
6063
- });
6064
- }
6065
- if (item.created_at) {
6066
- details.push({
6067
- text: `Created: ${new Date(item.created_at).toLocaleDateString()}`,
6068
- style: "dim"
6069
- });
6070
- }
6071
- return {
6072
- title: item.name,
6073
- id: item.client_id,
6074
- details
6075
- };
6365
+ var ClientCredentialsItemSchema = clientCredentials.ClientCredentialsItemSchema;
6366
+ var ClientCredentialsCreatedItemSchema = clientCredentials.ClientCredentialsCreatedItemSchema;
6367
+
6368
+ // src/formatters/clientCredentials.ts
6369
+ var clientCredentialsItemFormatter = {
6370
+ format: (item) => {
6371
+ const details = [];
6372
+ if (item.allowed_scopes && item.allowed_scopes.length > 0) {
6373
+ details.push({
6374
+ text: `Scopes: ${item.allowed_scopes.join(", ")}`,
6375
+ style: "accent"
6376
+ });
6076
6377
  }
6077
- }
6078
- );
6079
- var ClientCredentialsCreatedItemSchema = withFormatter(
6080
- clientCredentials.ClientCredentialsCreatedItemSchema,
6081
- {
6082
- format: (item) => {
6083
- return {
6084
- title: item.name,
6085
- id: item.client_id,
6086
- details: [
6087
- {
6088
- text: `Client Secret: ${item.client_secret}`,
6089
- style: "accent"
6090
- }
6091
- ]
6092
- };
6378
+ if (item.created_at) {
6379
+ details.push({
6380
+ text: `Created: ${new Date(item.created_at).toLocaleDateString()}`,
6381
+ style: "dim"
6382
+ });
6093
6383
  }
6384
+ return { title: item.name, id: item.client_id, details };
6094
6385
  }
6095
- );
6386
+ };
6387
+ var clientCredentialsCreatedItemFormatter = {
6388
+ format: (item) => ({
6389
+ title: item.name,
6390
+ id: item.client_id,
6391
+ details: [
6392
+ { text: `Client Secret: ${item.client_secret}`, style: "accent" }
6393
+ ]
6394
+ })
6395
+ };
6096
6396
 
6097
6397
  // src/plugins/listClientCredentials/index.ts
6098
6398
  var listClientCredentialsPlugin = definePlugin(
6099
6399
  (sdk) => createPaginatedPluginMethod(sdk, {
6400
+ ...zapierPagination,
6100
6401
  name: "listClientCredentials",
6101
6402
  categories: ["client-credentials"],
6102
6403
  type: "list",
6103
6404
  itemType: "ClientCredentials",
6104
6405
  inputSchema: ListClientCredentialsQuerySchema,
6105
6406
  outputSchema: ClientCredentialsItemSchema,
6407
+ formatter: clientCredentialsItemFormatter,
6106
6408
  defaultPageSize: DEFAULT_PAGE_SIZE,
6107
6409
  handler: async ({
6108
6410
  sdk: sdk2,
@@ -6123,8 +6425,7 @@ var listClientCredentialsPlugin = definePlugin(
6123
6425
  requiredScopes: ["credentials"]
6124
6426
  }
6125
6427
  );
6126
- },
6127
- extractCursor: (response) => extractCursor(response.links)
6428
+ }
6128
6429
  })
6129
6430
  );
6130
6431
  var CreateClientCredentialsSchema = clientCredentials.CreateClientCredentialsRequestSchema.omit({ allowed_scopes: true }).extend({
@@ -6142,6 +6443,7 @@ var createClientCredentialsPlugin = definePlugin(
6142
6443
  itemType: "ClientCredentials",
6143
6444
  inputSchema: CreateClientCredentialsSchema,
6144
6445
  outputSchema: ClientCredentialsCreatedItemSchema,
6446
+ formatter: clientCredentialsCreatedItemFormatter,
6145
6447
  confirm: "create-secret",
6146
6448
  resolvers: { name: clientCredentialsNameResolver },
6147
6449
  handler: async ({ sdk: sdk2, options }) => {
@@ -6231,99 +6533,36 @@ var BaseFieldItemSchema = zod.z.object({
6231
6533
  key: zod.z.string()
6232
6534
  // From need.key
6233
6535
  });
6234
- var InputFieldItemSchema = withFormatter(
6235
- BaseFieldItemSchema.extend({
6236
- type: zod.z.literal("input_field"),
6237
- default_value: zod.z.string(),
6238
- // Mapped from 'default' with fallback to ""
6239
- depends_on: zod.z.array(zod.z.string()),
6240
- // Mapped from 'depends_on' with fallback to []
6241
- description: zod.z.string(),
6242
- // Mapped from 'help_text' with fallback to ""
6243
- invalidates_input_fields: zod.z.boolean(),
6244
- // Mapped from 'alters_custom_fields' with fallback to false
6245
- is_required: zod.z.boolean(),
6246
- // Mapped from 'required' with fallback to false
6247
- placeholder: zod.z.string(),
6248
- // Mapped from 'placeholder' with fallback to ""
6249
- title: zod.z.string(),
6250
- // Mapped from 'label' with fallback to ""
6251
- value_type: zod.z.string(),
6252
- // Computed from InputFieldType enum
6253
- format: zod.z.string().optional(),
6254
- // Computed from InputFieldFormat enum (optional)
6255
- items: zod.z.object({ type: zod.z.string() }).optional()
6256
- // Computed from ItemsType enum (optional, only for arrays)
6257
- }),
6258
- {
6259
- format: (item) => {
6260
- const details = [];
6261
- const typeInfo = [
6262
- item.value_type && `Type: ${item.value_type}`,
6263
- `Required: ${item.is_required ? "Yes" : "No"}`
6264
- ].filter(Boolean).join(" | ");
6265
- if (typeInfo) {
6266
- details.push({ text: typeInfo, style: "dim" });
6267
- }
6268
- if (item.description) {
6269
- details.push({
6270
- text: item.description,
6271
- style: "normal"
6272
- });
6273
- }
6274
- if (item.default_value) {
6275
- details.push({
6276
- text: `Default: ${item.default_value}`,
6277
- style: "accent"
6278
- });
6279
- }
6280
- if (item.placeholder) {
6281
- details.push({
6282
- text: `Placeholder: ${item.placeholder}`,
6283
- style: "dim"
6284
- });
6285
- }
6286
- if (item.depends_on && item.depends_on.length > 0) {
6287
- details.push({
6288
- text: `Depends on: ${item.depends_on.join(", ")}`,
6289
- style: "warning"
6290
- });
6291
- }
6292
- if (item.format) {
6293
- details.push({ text: `Format: ${item.format}`, style: "dim" });
6294
- }
6295
- if (item.items) {
6296
- details.push({
6297
- text: `Items type: ${item.items.type}`,
6298
- style: "dim"
6299
- });
6300
- }
6301
- return {
6302
- title: item.title || item.key,
6303
- key: item.key,
6304
- description: item.description,
6305
- details
6306
- };
6307
- }
6308
- }
6309
- );
6310
- var InfoFieldItemSchema = withFormatter(
6311
- BaseFieldItemSchema.extend({
6312
- type: zod.z.literal("info_field"),
6313
- description: zod.z.string(),
6314
- // From need.help_text
6315
- title: zod.z.string().optional()
6316
- // Optional title
6317
- }),
6318
- {
6319
- format: (item) => ({
6320
- title: item.title || "Info",
6321
- key: item.key,
6322
- description: item.description,
6323
- details: [{ text: item.description, style: "normal" }]
6324
- })
6325
- }
6326
- );
6536
+ var InputFieldItemSchema = BaseFieldItemSchema.extend({
6537
+ type: zod.z.literal("input_field"),
6538
+ default_value: zod.z.string(),
6539
+ // Mapped from 'default' with fallback to ""
6540
+ depends_on: zod.z.array(zod.z.string()),
6541
+ // Mapped from 'depends_on' with fallback to []
6542
+ description: zod.z.string(),
6543
+ // Mapped from 'help_text' with fallback to ""
6544
+ invalidates_input_fields: zod.z.boolean(),
6545
+ // Mapped from 'alters_custom_fields' with fallback to false
6546
+ is_required: zod.z.boolean(),
6547
+ // Mapped from 'required' with fallback to false
6548
+ placeholder: zod.z.string(),
6549
+ // Mapped from 'placeholder' with fallback to ""
6550
+ title: zod.z.string(),
6551
+ // Mapped from 'label' with fallback to ""
6552
+ value_type: zod.z.string(),
6553
+ // Computed from InputFieldType enum
6554
+ format: zod.z.string().optional(),
6555
+ // Computed from InputFieldFormat enum (optional)
6556
+ items: zod.z.object({ type: zod.z.string() }).optional()
6557
+ // Computed from ItemsType enum (optional, only for arrays)
6558
+ });
6559
+ var InfoFieldItemSchema = BaseFieldItemSchema.extend({
6560
+ type: zod.z.literal("info_field"),
6561
+ description: zod.z.string(),
6562
+ // From need.help_text
6563
+ title: zod.z.string().optional()
6564
+ // Optional title
6565
+ });
6327
6566
  var FieldsetItemSchema = BaseFieldItemSchema.extend({
6328
6567
  type: zod.z.literal("fieldset"),
6329
6568
  title: zod.z.string(),
@@ -6343,6 +6582,53 @@ var RootFieldItemSchema = zod.z.union([
6343
6582
  FieldsetItemSchema
6344
6583
  ]);
6345
6584
 
6585
+ // src/formatters/field.ts
6586
+ function formatInputField(item) {
6587
+ const details = [];
6588
+ const typeInfo = [
6589
+ item.value_type && `Type: ${item.value_type}`,
6590
+ `Required: ${item.is_required ? "Yes" : "No"}`
6591
+ ].filter(Boolean).join(" | ");
6592
+ if (typeInfo) details.push({ text: typeInfo, style: "dim" });
6593
+ if (item.description)
6594
+ details.push({ text: item.description, style: "normal" });
6595
+ if (item.default_value)
6596
+ details.push({ text: `Default: ${item.default_value}`, style: "accent" });
6597
+ if (item.placeholder)
6598
+ details.push({ text: `Placeholder: ${item.placeholder}`, style: "dim" });
6599
+ if (item.depends_on && item.depends_on.length > 0) {
6600
+ details.push({
6601
+ text: `Depends on: ${item.depends_on.join(", ")}`,
6602
+ style: "warning"
6603
+ });
6604
+ }
6605
+ if (item.format)
6606
+ details.push({ text: `Format: ${item.format}`, style: "dim" });
6607
+ if (item.items)
6608
+ details.push({ text: `Items type: ${item.items.type}`, style: "dim" });
6609
+ return {
6610
+ title: item.title || item.key,
6611
+ key: item.key,
6612
+ description: item.description,
6613
+ details
6614
+ };
6615
+ }
6616
+ function formatInfoField(item) {
6617
+ return {
6618
+ title: item.title || "Info",
6619
+ key: item.key,
6620
+ description: item.description,
6621
+ details: [{ text: item.description, style: "normal" }]
6622
+ };
6623
+ }
6624
+ var rootFieldItemFormatter = {
6625
+ format: (item) => {
6626
+ if (item.type === "input_field") return formatInputField(item);
6627
+ if (item.type === "info_field") return formatInfoField(item);
6628
+ return { title: item.title || item.key, key: item.key, details: [] };
6629
+ }
6630
+ };
6631
+
6346
6632
  // src/services/implementations.ts
6347
6633
  async function fetchImplementationNeeds({
6348
6634
  api,
@@ -6508,6 +6794,7 @@ var listActionInputFieldsPlugin = definePlugin(
6508
6794
  itemType: "RootField",
6509
6795
  inputSchema: ListActionInputFieldsInputSchema,
6510
6796
  outputSchema: RootFieldItemSchema,
6797
+ formatter: rootFieldItemFormatter,
6511
6798
  defaultPageSize: DEFAULT_PAGE_SIZE,
6512
6799
  resolvers: {
6513
6800
  app: appKeyResolver,
@@ -6516,10 +6803,7 @@ var listActionInputFieldsPlugin = definePlugin(
6516
6803
  connection: connectionIdResolver,
6517
6804
  inputs: inputsAllOptionalResolver
6518
6805
  },
6519
- handler: async ({
6520
- sdk: sdk2,
6521
- options
6522
- }) => {
6806
+ handler: async ({ sdk: sdk2, options }) => {
6523
6807
  const { api, getVersionedImplementationId } = sdk2.context;
6524
6808
  const appKey = "app" in options ? options.app : options.appKey;
6525
6809
  const actionKey = "action" in options ? options.action : options.actionKey;
@@ -6681,26 +6965,7 @@ var getActionInputFieldsSchemaPlugin = definePlugin(
6681
6965
  }
6682
6966
  })
6683
6967
  );
6684
- var InputFieldChoiceItemSchema = withFormatter(NeedChoicesSchema, {
6685
- format: (item) => {
6686
- const title = item.label || item.key || "Choice";
6687
- const details = [];
6688
- if (item.label && item.key && item.label !== item.key) {
6689
- details.push({ text: `Key: ${item.key}`, style: "dim" });
6690
- }
6691
- if (item.sample && item.sample !== item.key) {
6692
- details.push({ text: `Sample: ${item.sample}`, style: "dim" });
6693
- }
6694
- if (item.value && item.value !== item.key) {
6695
- details.push({ text: `Value: ${item.value}`, style: "normal" });
6696
- }
6697
- return {
6698
- title,
6699
- key: item.key,
6700
- details
6701
- };
6702
- }
6703
- });
6968
+ var InputFieldChoiceItemSchema = NeedChoicesSchema;
6704
6969
  var ListActionInputFieldChoicesDescription = "Get the available choices for a dynamic dropdown input field";
6705
6970
  var ListActionInputFieldChoicesBaseSchema = zod.z.object({
6706
6971
  connection: ConnectionPropertySchema.optional().describe(
@@ -6744,6 +7009,24 @@ var ListActionInputFieldChoicesInputSchema = zod.z.union([
6744
7009
  ListActionInputFieldChoicesSchemaDeprecated
6745
7010
  ]).describe(ListActionInputFieldChoicesDescription);
6746
7011
 
7012
+ // src/formatters/inputFieldChoice.ts
7013
+ var inputFieldChoiceItemFormatter = {
7014
+ format: (item) => {
7015
+ const title = item.label || item.key || "Choice";
7016
+ const details = [];
7017
+ if (item.label && item.key && item.label !== item.key) {
7018
+ details.push({ text: `Key: ${item.key}`, style: "dim" });
7019
+ }
7020
+ if (item.sample && item.sample !== item.key) {
7021
+ details.push({ text: `Sample: ${item.sample}`, style: "dim" });
7022
+ }
7023
+ if (item.value && item.value !== item.key) {
7024
+ details.push({ text: `Value: ${item.value}`, style: "normal" });
7025
+ }
7026
+ return { title, key: item.key, details };
7027
+ }
7028
+ };
7029
+
6747
7030
  // src/plugins/listActionInputFieldChoices/index.ts
6748
7031
  function transformNeedChoicesToInputFieldChoiceItem(choice) {
6749
7032
  return {
@@ -6761,6 +7044,7 @@ var listActionInputFieldChoicesPlugin = definePlugin(
6761
7044
  itemType: "InputFieldChoice",
6762
7045
  inputSchema: ListActionInputFieldChoicesInputSchema,
6763
7046
  outputSchema: InputFieldChoiceItemSchema,
7047
+ formatter: inputFieldChoiceItemFormatter,
6764
7048
  defaultPageSize: DEFAULT_PAGE_SIZE,
6765
7049
  resolvers: {
6766
7050
  app: appKeyResolver,
@@ -6770,10 +7054,7 @@ var listActionInputFieldChoicesPlugin = definePlugin(
6770
7054
  inputField: inputFieldKeyResolver,
6771
7055
  inputs: inputsAllOptionalResolver
6772
7056
  },
6773
- handler: async ({
6774
- sdk: sdk2,
6775
- options
6776
- }) => {
7057
+ handler: async ({ sdk: sdk2, options }) => {
6777
7058
  const { api, getVersionedImplementationId } = sdk2.context;
6778
7059
  const appKey = "app" in options ? options.app : options.appKey;
6779
7060
  const actionKey = "action" in options ? options.action : options.actionKey;
@@ -6870,11 +7151,13 @@ var listInputFieldsDeprecatedPlugin = definePlugin(
6870
7151
  context: {
6871
7152
  meta: {
6872
7153
  listInputFields: {
6873
- categories: ["action", "deprecated"],
7154
+ categories: ["action"],
7155
+ deprecation: { message: "Use listActionInputFields instead." },
6874
7156
  type: "list",
6875
7157
  itemType: "RootField",
6876
7158
  inputSchema: ListActionInputFieldsInputSchema,
6877
7159
  outputSchema: RootFieldItemSchema,
7160
+ formatter: rootFieldItemFormatter,
6878
7161
  defaultPageSize: DEFAULT_PAGE_SIZE
6879
7162
  }
6880
7163
  }
@@ -6887,11 +7170,15 @@ var listInputFieldChoicesDeprecatedPlugin = definePlugin(
6887
7170
  context: {
6888
7171
  meta: {
6889
7172
  listInputFieldChoices: {
6890
- categories: ["action", "deprecated"],
7173
+ categories: ["action"],
7174
+ deprecation: {
7175
+ message: "Use listActionInputFieldChoices instead."
7176
+ },
6891
7177
  type: "list",
6892
7178
  itemType: "InputFieldChoiceItem",
6893
7179
  inputSchema: ListActionInputFieldChoicesInputSchema,
6894
7180
  outputSchema: InputFieldChoiceItemSchema,
7181
+ formatter: inputFieldChoiceItemFormatter,
6895
7182
  defaultPageSize: DEFAULT_PAGE_SIZE
6896
7183
  }
6897
7184
  }
@@ -6904,7 +7191,8 @@ var getInputFieldsSchemaDeprecatedPlugin = definePlugin(
6904
7191
  context: {
6905
7192
  meta: {
6906
7193
  getInputFieldsSchema: {
6907
- categories: ["action", "deprecated"],
7194
+ categories: ["action"],
7195
+ deprecation: { message: "Use getActionInputFieldsSchema instead." },
6908
7196
  type: "function",
6909
7197
  inputSchema: GetActionInputFieldsSchemaInputSchema
6910
7198
  }
@@ -6968,6 +7256,7 @@ var tablesDefaults = {
6968
7256
  var listTablesPlugin = definePlugin(
6969
7257
  (sdk) => createPaginatedPluginMethod(sdk, {
6970
7258
  ...tablesDefaults,
7259
+ ...zapierPagination,
6971
7260
  name: "listTables",
6972
7261
  type: "list",
6973
7262
  itemType: "Table",
@@ -7023,8 +7312,7 @@ var listTablesPlugin = definePlugin(
7023
7312
  data: response.data.map(transformTableItem),
7024
7313
  links: response.links
7025
7314
  };
7026
- },
7027
- extractCursor: (response) => extractCursor(response.links)
7315
+ }
7028
7316
  })
7029
7317
  );
7030
7318
  var GetTableApiResponseSchema = zod.z.object({
@@ -7127,6 +7415,15 @@ var createTablePlugin = definePlugin(
7127
7415
  })
7128
7416
  );
7129
7417
 
7418
+ // src/formatters/tableField.ts
7419
+ var tableFieldItemFormatter = {
7420
+ format: (item) => ({
7421
+ title: item.name,
7422
+ id: item.id,
7423
+ details: [{ text: `Type: ${item.type}`, style: "dim" }]
7424
+ })
7425
+ };
7426
+
7130
7427
  // src/plugins/tables/listTableFields/index.ts
7131
7428
  var listTableFieldsPlugin = definePlugin(
7132
7429
  (sdk) => createPluginMethod(sdk, {
@@ -7136,6 +7433,7 @@ var listTableFieldsPlugin = definePlugin(
7136
7433
  itemType: "Field",
7137
7434
  inputSchema: ListTableFieldsOptionsInputSchema,
7138
7435
  outputSchema: FieldItemSchema,
7436
+ formatter: tableFieldItemFormatter,
7139
7437
  resolvers: { table: tableIdResolver },
7140
7438
  handler: async ({ sdk: sdk2, options }) => {
7141
7439
  const { api } = sdk2.context;
@@ -7208,6 +7506,7 @@ var createTableFieldsPlugin = definePlugin(
7208
7506
  returnType: "FieldItem[]",
7209
7507
  inputSchema: CreateTableFieldsOptionsInputSchema,
7210
7508
  outputSchema: FieldItemSchema,
7509
+ formatter: tableFieldItemFormatter,
7211
7510
  resolvers: { table: tableIdResolver, fields: tableFieldsResolver },
7212
7511
  handler: async ({ sdk: sdk2, options }) => {
7213
7512
  const tableId = "table" in options ? options.table : options.tableId;
@@ -7286,21 +7585,13 @@ var RecordApiItemSchema = zod.z.object({
7286
7585
  is_source_record: zod.z.boolean().nullable().optional(),
7287
7586
  deleted_at: zod.z.string().nullable().optional()
7288
7587
  });
7289
- var RecordItemSchemaBase = zod.z.object({
7588
+ var RecordItemSchema = zod.z.object({
7290
7589
  id: zod.z.string(),
7291
7590
  data: zod.z.record(zod.z.string(), zod.z.unknown()),
7292
7591
  created_at: zod.z.string(),
7293
7592
  edited_at: zod.z.string(),
7294
7593
  deleted_at: zod.z.string().nullable().optional()
7295
7594
  });
7296
- var RecordItemSchema = withFormatter(RecordItemSchemaBase, {
7297
- format: (item) => ({
7298
- title: `Record ${item.id}`,
7299
- id: item.id,
7300
- data: item.data,
7301
- details: []
7302
- })
7303
- });
7304
7595
  var GetTableRecordApiResponseSchema = zod.z.object({
7305
7596
  data: RecordApiItemSchema
7306
7597
  });
@@ -7324,9 +7615,9 @@ var tableRecordFormatter = {
7324
7615
  if (context) return context;
7325
7616
  const hasFieldIds = Object.keys(item.data).some(isFieldId);
7326
7617
  if (!hasFieldIds) return {};
7327
- const { data: fields } = await sdk.listTableFields({
7328
- table: params.tableId
7329
- });
7618
+ const table = params.table ?? params.tableId;
7619
+ if (!table) return {};
7620
+ const { data: fields } = await sdk.listTableFields({ table });
7330
7621
  return Object.fromEntries(fields.map((f) => [f.id, f.name]));
7331
7622
  },
7332
7623
  format: (item, fieldLabels) => ({
@@ -7451,10 +7742,7 @@ var listTableRecordsPlugin = definePlugin(
7451
7742
  sort: tableSortResolver
7452
7743
  },
7453
7744
  formatter: tableRecordFormatter,
7454
- handler: async ({
7455
- sdk: sdk2,
7456
- options
7457
- }) => {
7745
+ handler: async ({ sdk: sdk2, options }) => {
7458
7746
  const { api } = sdk2.context;
7459
7747
  const tableId = "table" in options ? options.table : options.tableId;
7460
7748
  const translator = await createFieldKeyTranslator({
@@ -7732,11 +8020,12 @@ var requestPlugin = definePlugin(
7732
8020
  (sdk) => createPluginMethod(sdk, {
7733
8021
  name: "request",
7734
8022
  packages: ["cli", "mcp"],
7735
- categories: ["http", "deprecated"],
8023
+ categories: ["http"],
8024
+ deprecation: { message: "Use fetch() instead." },
7736
8025
  returnType: "Response",
7737
8026
  inputSchema: RelayRequestSchema,
7738
8027
  handler: async ({ sdk: sdk2, options }) => {
7739
- logDeprecation("request() is deprecated. Use fetch() instead.");
8028
+ logDeprecation2("request() is deprecated. Use fetch() instead.");
7740
8029
  const {
7741
8030
  url,
7742
8031
  method,
@@ -7956,7 +8245,7 @@ async function listAppsForSlugsPage({
7956
8245
  data: implementationsEnvelope.results.map(
7957
8246
  normalizeImplementationMetaToAppItem
7958
8247
  ),
7959
- nextCursor: extractCursor(implementationsEnvelope)
8248
+ nextCursor: implementationsEnvelope.next ? extractCursorFromUrl(implementationsEnvelope.next) : void 0
7960
8249
  };
7961
8250
  }
7962
8251
  function findManifestEntry({
@@ -8377,7 +8666,7 @@ function createConsoleTransport() {
8377
8666
  return {
8378
8667
  async emit(subject, event) {
8379
8668
  try {
8380
- console.log(
8669
+ console.error(
8381
8670
  "[SDK Telemetry]",
8382
8671
  JSON.stringify({ subject, properties: event }, null, 2)
8383
8672
  );
@@ -8586,6 +8875,35 @@ function buildMethodCalledEvent(data, context = {}) {
8586
8875
  };
8587
8876
  }
8588
8877
 
8878
+ // src/plugins/eventEmission/event-emission-hook.ts
8879
+ function computeArgumentCount(args) {
8880
+ if (args.length === 1) {
8881
+ const arg0 = args[0];
8882
+ if (arg0 !== null && typeof arg0 === "object" && !Array.isArray(arg0) && Object.getPrototypeOf(arg0) === Object.prototype) {
8883
+ return Object.keys(arg0).length;
8884
+ }
8885
+ }
8886
+ return args.filter((a) => a !== void 0).length;
8887
+ }
8888
+ function makeMethodEndHook(emitMethodCalled) {
8889
+ return ({ methodName, args, isPaginated, depth, durationMs, error }) => {
8890
+ if (depth > 0) return;
8891
+ const metadata = getMethodMetadata();
8892
+ emitMethodCalled({
8893
+ method_name: methodName,
8894
+ execution_duration_ms: durationMs,
8895
+ success_flag: !error,
8896
+ error_message: error?.message ?? null,
8897
+ error_type: error?.constructor.name ?? null,
8898
+ argument_count: computeArgumentCount(args),
8899
+ is_paginated: isPaginated,
8900
+ selected_api: metadata?.selectedApi ?? null,
8901
+ operation_type: metadata?.operationType ?? null,
8902
+ operation_key: metadata?.operationKey ?? null
8903
+ });
8904
+ };
8905
+ }
8906
+
8589
8907
  // src/plugins/eventEmission/index.ts
8590
8908
  var TELEMETRY_EMIT_TIMEOUT_MS = 300;
8591
8909
  var registeredListeners = {};
@@ -8716,6 +9034,8 @@ var eventEmissionPlugin = definePlugin(
8716
9034
  }
8717
9035
  }
8718
9036
  if (!config.enabled) {
9037
+ const noopEmitMethodCalled = () => {
9038
+ };
8719
9039
  return {
8720
9040
  context: {
8721
9041
  eventEmission: {
@@ -8733,12 +9053,13 @@ var eventEmissionPlugin = definePlugin(
8733
9053
  visitor_id: null,
8734
9054
  correlation_id: null
8735
9055
  }),
8736
- emitMethodCalled: () => {
8737
- },
8738
9056
  flush: async () => {
8739
9057
  },
8740
9058
  close: async () => {
8741
9059
  }
9060
+ },
9061
+ hooks: {
9062
+ onMethodEnd: makeMethodEndHook(noopEmitMethodCalled)
8742
9063
  }
8743
9064
  }
8744
9065
  };
@@ -8907,7 +9228,21 @@ var eventEmissionPlugin = definePlugin(
8907
9228
  APPLICATION_LIFECYCLE_EVENT_SUBJECT,
8908
9229
  exitEvent
8909
9230
  );
8910
- removeExistingListeners();
9231
+ removeExistingListeners();
9232
+ };
9233
+ const emitMethodCalled = (data) => {
9234
+ const event = {
9235
+ ...buildMethodCalledEvent(data),
9236
+ call_context: config.callContext ?? "sdk"
9237
+ };
9238
+ trackEmission(
9239
+ silentEmit(
9240
+ transport,
9241
+ METHOD_CALLED_EVENT_SUBJECT,
9242
+ event,
9243
+ getUserContext
9244
+ )
9245
+ );
8911
9246
  };
8912
9247
  return {
8913
9248
  context: {
@@ -8920,22 +9255,11 @@ var eventEmissionPlugin = definePlugin(
8920
9255
  );
8921
9256
  },
8922
9257
  createBaseEvent: createBaseEventHelper,
8923
- emitMethodCalled: (data) => {
8924
- const event = {
8925
- ...buildMethodCalledEvent(data),
8926
- call_context: config.callContext ?? "sdk"
8927
- };
8928
- trackEmission(
8929
- silentEmit(
8930
- transport,
8931
- METHOD_CALLED_EVENT_SUBJECT,
8932
- event,
8933
- getUserContext
8934
- )
8935
- );
8936
- },
8937
9258
  flush,
8938
9259
  close
9260
+ },
9261
+ hooks: {
9262
+ onMethodEnd: makeMethodEndHook(emitMethodCalled)
8939
9263
  }
8940
9264
  }
8941
9265
  };
@@ -8947,78 +9271,22 @@ function createOptionsPlugin(options) {
8947
9271
  return () => ({ context: { options } });
8948
9272
  }
8949
9273
  function createSdk() {
8950
- return buildSdk({}, { meta: {} });
8951
- }
8952
- function buildSdk(properties, context) {
8953
- const frozenContext = Object.freeze(context);
8954
- const registryCache = /* @__PURE__ */ new Map();
8955
- const sdk = {
8956
- ...properties,
8957
- get context() {
8958
- return frozenContext;
8959
- },
8960
- getContext: () => frozenContext,
8961
- // runtime compat shim, not in types
8962
- getRegistry(options) {
8963
- const cacheKey = options?.package ?? "__all__";
8964
- if (!registryCache.has(cacheKey)) {
8965
- registryCache.set(
8966
- cacheKey,
8967
- buildRegistry({
8968
- sdk,
8969
- meta: frozenContext.meta,
8970
- packageFilter: options?.package
8971
- })
8972
- );
8973
- }
8974
- return registryCache.get(cacheKey);
8975
- },
8976
- addPlugin(plugin, options) {
8977
- const pluginResult = plugin({
8978
- ...properties,
8979
- context: frozenContext
8980
- });
8981
- const { context: pluginContext, ...pluginProperties } = pluginResult;
8982
- const { meta: pluginMeta, ...pluginContextRest } = pluginContext ?? {};
8983
- const existingProperties = properties;
8984
- const existingContext = context;
8985
- const existingMeta = context.meta ?? {};
8986
- const collisions = [];
8987
- for (const key of Object.keys(pluginProperties)) {
8988
- if (key in existingProperties) collisions.push(`method "${key}"`);
8989
- }
8990
- for (const key of Object.keys(pluginContextRest)) {
8991
- if (key in existingContext) collisions.push(`context.${key}`);
8992
- }
8993
- if (collisions.length > 0 && !options?.override) {
8994
- const name = plugin.name || "anonymous plugin";
8995
- console.warn(
8996
- `[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.`
8997
- );
8998
- return buildSdk(properties, context);
8999
- }
9000
- const mergedProperties = { ...properties, ...pluginProperties };
9001
- const mergedContext = {
9002
- ...context,
9003
- ...pluginContextRest,
9004
- meta: { ...existingMeta, ...pluginMeta ?? {} }
9005
- };
9006
- return buildSdk(
9007
- mergedProperties,
9008
- mergedContext
9009
- );
9010
- }
9011
- };
9012
- return sdk;
9274
+ logDeprecation2(
9275
+ "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."
9276
+ );
9277
+ return withDeprecatedAddPlugin(createZapierCoreStack().toSdk());
9013
9278
  }
9014
9279
  function createZapierSdkWithoutRegistry(options = {}) {
9015
- logDeprecation(
9280
+ logDeprecation2(
9016
9281
  "createZapierSdkWithoutRegistry is deprecated; use createZapierSdk instead. getRegistry is now available on every sdk."
9017
9282
  );
9018
9283
  return createZapierSdk(options);
9019
9284
  }
9285
+ function createZapierSdkStack(options = {}) {
9286
+ 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);
9287
+ }
9020
9288
  function createZapierSdk(options = {}) {
9021
- 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);
9289
+ return withDeprecatedAddPlugin(createZapierSdkStack(options).toSdk());
9022
9290
  }
9023
9291
  var TriggerInboxStatusSchema = zod.z.union([
9024
9292
  zod.z.enum([
@@ -9050,7 +9318,7 @@ var TriggerSubscriptionApiSchema = zod.z.object({
9050
9318
  action_key: zod.z.string(),
9051
9319
  inputs: zod.z.record(zod.z.string(), zod.z.unknown())
9052
9320
  });
9053
- var TriggerInboxItemSchemaBase = zod.z.object({
9321
+ var TriggerInboxItemSchema = zod.z.object({
9054
9322
  id: zod.z.string(),
9055
9323
  created_at: zod.z.string(),
9056
9324
  name: zod.z.string().nullable(),
@@ -9059,40 +9327,6 @@ var TriggerInboxItemSchemaBase = zod.z.object({
9059
9327
  notification_url: zod.z.string().nullable(),
9060
9328
  subscription: TriggerSubscriptionApiSchema
9061
9329
  });
9062
- var TriggerInboxItemSchema = withFormatter(
9063
- TriggerInboxItemSchemaBase,
9064
- {
9065
- format: (item) => {
9066
- const details = [
9067
- {
9068
- text: `Status: ${item.status}`,
9069
- style: item.status === "active" ? "accent" : "dim"
9070
- },
9071
- {
9072
- text: `Subscription: ${item.subscription.app_key} / ${item.subscription.action_key}`,
9073
- style: "dim"
9074
- }
9075
- ];
9076
- if (item.paused_reason) {
9077
- details.push({
9078
- text: `Paused reason: ${item.paused_reason}`,
9079
- style: "warning"
9080
- });
9081
- }
9082
- if (item.notification_url) {
9083
- details.push({
9084
- text: `Notify: ${item.notification_url}`,
9085
- style: "dim"
9086
- });
9087
- }
9088
- return {
9089
- title: item.name ?? `Trigger Inbox ${item.id}`,
9090
- id: item.id,
9091
- details
9092
- };
9093
- }
9094
- }
9095
- );
9096
9330
 
9097
9331
  // src/plugins/triggers/createTriggerInbox/schemas.ts
9098
9332
  var CreateTriggerInboxDescription = "Create a new trigger inbox subscription. Always creates a new inbox; use ensureTriggerInbox for get-or-create on a stable name.";
@@ -9111,6 +9345,39 @@ var CreateTriggerInboxSchema = zod.z.object({
9111
9345
  notificationUrl: zod.z.string().url().optional().describe("Webhook URL to POST to when new messages arrive")
9112
9346
  }).describe(CreateTriggerInboxDescription);
9113
9347
 
9348
+ // src/formatters/triggerInbox.ts
9349
+ var triggerInboxItemFormatter = {
9350
+ format: (item) => {
9351
+ const details = [
9352
+ {
9353
+ text: `Status: ${item.status}`,
9354
+ style: item.status === "active" ? "accent" : "dim"
9355
+ },
9356
+ {
9357
+ text: `Subscription: ${item.subscription.app_key} / ${item.subscription.action_key}`,
9358
+ style: "dim"
9359
+ }
9360
+ ];
9361
+ if (item.paused_reason) {
9362
+ details.push({
9363
+ text: `Paused reason: ${item.paused_reason}`,
9364
+ style: "warning"
9365
+ });
9366
+ }
9367
+ if (item.notification_url) {
9368
+ details.push({
9369
+ text: `Notify: ${item.notification_url}`,
9370
+ style: "dim"
9371
+ });
9372
+ }
9373
+ return {
9374
+ title: item.name ?? `Trigger Inbox ${item.id}`,
9375
+ id: item.id,
9376
+ details
9377
+ };
9378
+ }
9379
+ };
9380
+
9114
9381
  // src/plugins/triggers/shared.ts
9115
9382
  var triggersDefaults = {
9116
9383
  categories: ["trigger"],
@@ -9159,6 +9426,7 @@ var createTriggerInboxPlugin = definePlugin(
9159
9426
  itemType: "TriggerInbox",
9160
9427
  inputSchema: CreateTriggerInboxSchema,
9161
9428
  outputSchema: TriggerInboxItemSchema,
9429
+ formatter: triggerInboxItemFormatter,
9162
9430
  // actionKeyResolver and inputsResolver depend on actionType, which is
9163
9431
  // always "read" for triggers. Pin it as a constant resolver so it's
9164
9432
  // seeded into resolvedParams without polluting the user-facing schema
@@ -9252,6 +9520,7 @@ var ensureTriggerInboxPlugin = definePlugin(
9252
9520
  itemType: "TriggerInbox",
9253
9521
  inputSchema: EnsureTriggerInboxSchema,
9254
9522
  outputSchema: TriggerInboxItemSchema,
9523
+ formatter: triggerInboxItemFormatter,
9255
9524
  // actionKeyResolver and inputsResolver depend on actionType, which is
9256
9525
  // always "read" for triggers. Pin it as a constant resolver so it's
9257
9526
  // seeded into resolvedParams without polluting the user-facing schema.
@@ -9336,24 +9605,16 @@ var ListTriggerInboxesApiResponseSchema = zod.z.object({
9336
9605
  });
9337
9606
 
9338
9607
  // src/plugins/triggers/listTriggerInboxes/index.ts
9339
- function extractNextOffset(next) {
9340
- if (!next) return void 0;
9341
- try {
9342
- const url = new URL(next);
9343
- const offset = url.searchParams.get("offset");
9344
- return offset || void 0;
9345
- } catch {
9346
- return void 0;
9347
- }
9348
- }
9349
9608
  var listTriggerInboxesPlugin = definePlugin(
9350
9609
  (sdk) => createPaginatedPluginMethod(sdk, {
9351
9610
  ...triggersDefaults,
9611
+ ...zapierPagination,
9352
9612
  name: "listTriggerInboxes",
9353
9613
  type: "list",
9354
9614
  itemType: "TriggerInbox",
9355
9615
  inputSchema: ListTriggerInboxesSchema,
9356
9616
  outputSchema: TriggerInboxItemSchema,
9617
+ formatter: triggerInboxItemFormatter,
9357
9618
  defaultPageSize: DEFAULT_PAGE_SIZE,
9358
9619
  handler: async ({ sdk: sdk2, options }) => {
9359
9620
  const { api } = sdk2.context;
@@ -9379,8 +9640,7 @@ var listTriggerInboxesPlugin = definePlugin(
9379
9640
  data: response.results,
9380
9641
  next: response.next ?? null
9381
9642
  };
9382
- },
9383
- extractCursor: (response) => extractNextOffset(response.next)
9643
+ }
9384
9644
  })
9385
9645
  );
9386
9646
  var GetTriggerInboxSchema = zod.z.object({
@@ -9396,6 +9656,7 @@ var getTriggerInboxPlugin = definePlugin(
9396
9656
  itemType: "TriggerInbox",
9397
9657
  inputSchema: GetTriggerInboxSchema,
9398
9658
  outputSchema: TriggerInboxItemSchema,
9659
+ formatter: triggerInboxItemFormatter,
9399
9660
  resolvers: { inbox: triggerInboxResolver },
9400
9661
  handler: async ({ sdk: sdk2, options }) => {
9401
9662
  const { inbox } = options;
@@ -9430,6 +9691,7 @@ var updateTriggerInboxPlugin = definePlugin(
9430
9691
  itemType: "TriggerInbox",
9431
9692
  inputSchema: UpdateTriggerInboxSchema,
9432
9693
  outputSchema: TriggerInboxItemSchema,
9694
+ formatter: triggerInboxItemFormatter,
9433
9695
  resolvers: { inbox: triggerInboxResolver },
9434
9696
  handler: async ({ sdk: sdk2, options }) => {
9435
9697
  const { inbox, notificationUrl } = options;
@@ -9466,6 +9728,7 @@ var deleteTriggerInboxPlugin = definePlugin(
9466
9728
  itemType: "TriggerInbox",
9467
9729
  inputSchema: DeleteTriggerInboxSchema,
9468
9730
  outputSchema: TriggerInboxItemSchema,
9731
+ formatter: triggerInboxItemFormatter,
9469
9732
  resolvers: { inbox: triggerInboxResolver },
9470
9733
  confirm: "delete",
9471
9734
  handler: async ({ sdk: sdk2, options }) => {
@@ -9499,6 +9762,7 @@ var pauseTriggerInboxPlugin = definePlugin(
9499
9762
  itemType: "TriggerInbox",
9500
9763
  inputSchema: PauseTriggerInboxSchema,
9501
9764
  outputSchema: TriggerInboxItemSchema,
9765
+ formatter: triggerInboxItemFormatter,
9502
9766
  resolvers: { inbox: triggerInboxResolver },
9503
9767
  handler: async ({ sdk: sdk2, options }) => {
9504
9768
  const { inbox } = options;
@@ -9531,6 +9795,7 @@ var resumeTriggerInboxPlugin = definePlugin(
9531
9795
  itemType: "TriggerInbox",
9532
9796
  inputSchema: ResumeTriggerInboxSchema,
9533
9797
  outputSchema: TriggerInboxItemSchema,
9798
+ formatter: triggerInboxItemFormatter,
9534
9799
  resolvers: { inbox: triggerInboxResolver },
9535
9800
  handler: async ({ sdk: sdk2, options }) => {
9536
9801
  const { inbox } = options;
@@ -9556,78 +9821,15 @@ var TriggerMessageAttributesSchema = zod.z.object({
9556
9821
  error_message: zod.z.string().nullable(),
9557
9822
  possible_duplicate_data: zod.z.boolean()
9558
9823
  });
9559
- var TriggerMessageItemSchemaBase = zod.z.object({
9824
+ var TriggerMessageItemSchema = zod.z.object({
9560
9825
  id: zod.z.string(),
9561
9826
  created_at: zod.z.string(),
9562
9827
  status: TriggerMessageStatusSchema,
9563
9828
  message_attributes: TriggerMessageAttributesSchema
9564
9829
  });
9565
- var TriggerMessageItemSchema = withFormatter(
9566
- TriggerMessageItemSchemaBase,
9567
- {
9568
- format: (item) => {
9569
- const details = [
9570
- { text: `Status: ${item.status}`, style: "dim" },
9571
- {
9572
- text: `Lease count: ${item.message_attributes.lease_count}`,
9573
- style: "dim"
9574
- }
9575
- ];
9576
- if (item.message_attributes.error_message) {
9577
- details.push({
9578
- text: `Error: ${item.message_attributes.error_message}`,
9579
- style: "warning"
9580
- });
9581
- }
9582
- if (item.message_attributes.possible_duplicate_data) {
9583
- details.push({
9584
- text: "Possible duplicate data",
9585
- style: "warning"
9586
- });
9587
- }
9588
- return {
9589
- title: `Message ${item.id}`,
9590
- id: item.id,
9591
- details
9592
- };
9593
- }
9594
- }
9595
- );
9596
- var LeasedTriggerMessageItemSchemaBase = TriggerMessageItemSchemaBase.extend({
9830
+ var LeasedTriggerMessageItemSchema = TriggerMessageItemSchema.extend({
9597
9831
  payload: zod.z.record(zod.z.string(), zod.z.unknown())
9598
9832
  });
9599
- var LeasedTriggerMessageItemSchema = withFormatter(
9600
- LeasedTriggerMessageItemSchemaBase,
9601
- {
9602
- format: (item) => {
9603
- const details = [
9604
- { text: `Status: ${item.status}`, style: "dim" },
9605
- {
9606
- text: `Lease count: ${item.message_attributes.lease_count}`,
9607
- style: "dim"
9608
- }
9609
- ];
9610
- if (item.message_attributes.error_message) {
9611
- details.push({
9612
- text: `Error: ${item.message_attributes.error_message}`,
9613
- style: "warning"
9614
- });
9615
- }
9616
- if (item.message_attributes.possible_duplicate_data) {
9617
- details.push({
9618
- text: "Possible duplicate data",
9619
- style: "warning"
9620
- });
9621
- }
9622
- return {
9623
- title: `Message ${item.id}`,
9624
- id: item.id,
9625
- data: item.payload,
9626
- details
9627
- };
9628
- }
9629
- }
9630
- );
9631
9833
 
9632
9834
  // src/plugins/triggers/listTriggerInboxMessages/schemas.ts
9633
9835
  var ListTriggerInboxMessagesSchema = zod.z.object({
@@ -9642,24 +9844,45 @@ var ListTriggerInboxMessagesApiResponseSchema = zod.z.object({
9642
9844
  results: zod.z.array(TriggerMessageItemSchema)
9643
9845
  });
9644
9846
 
9645
- // src/plugins/triggers/listTriggerInboxMessages/index.ts
9646
- function extractNextCursor(next) {
9647
- if (!next) return void 0;
9648
- try {
9649
- const url = new URL(next);
9650
- return url.searchParams.get("cursor") ?? void 0;
9651
- } catch {
9652
- return void 0;
9847
+ // src/formatters/triggerMessage.ts
9848
+ function buildBaseDetails(item) {
9849
+ const details = [
9850
+ { text: `Status: ${item.status}`, style: "dim" },
9851
+ {
9852
+ text: `Lease count: ${item.message_attributes.lease_count}`,
9853
+ style: "dim"
9854
+ }
9855
+ ];
9856
+ if (item.message_attributes.error_message) {
9857
+ details.push({
9858
+ text: `Error: ${item.message_attributes.error_message}`,
9859
+ style: "warning"
9860
+ });
9861
+ }
9862
+ if (item.message_attributes.possible_duplicate_data) {
9863
+ details.push({ text: "Possible duplicate data", style: "warning" });
9653
9864
  }
9865
+ return details;
9654
9866
  }
9867
+ var triggerMessageItemFormatter = {
9868
+ format: (item) => ({
9869
+ title: `Message ${item.id}`,
9870
+ id: item.id,
9871
+ details: buildBaseDetails(item)
9872
+ })
9873
+ };
9874
+
9875
+ // src/plugins/triggers/listTriggerInboxMessages/index.ts
9655
9876
  var listTriggerInboxMessagesPlugin = definePlugin(
9656
9877
  (sdk) => createPaginatedPluginMethod(sdk, {
9657
9878
  ...triggersDefaults,
9879
+ ...zapierPagination,
9658
9880
  name: "listTriggerInboxMessages",
9659
9881
  type: "list",
9660
9882
  itemType: "TriggerMessage",
9661
9883
  inputSchema: ListTriggerInboxMessagesSchema,
9662
9884
  outputSchema: TriggerMessageItemSchema,
9885
+ formatter: triggerMessageItemFormatter,
9663
9886
  defaultPageSize: DEFAULT_PAGE_SIZE,
9664
9887
  resolvers: { inbox: triggerInboxResolver },
9665
9888
  handler: async ({ sdk: sdk2, options }) => {
@@ -9684,8 +9907,7 @@ var listTriggerInboxMessagesPlugin = definePlugin(
9684
9907
  data: response.results,
9685
9908
  next: response.next ?? null
9686
9909
  };
9687
- },
9688
- extractCursor: (response) => extractNextCursor(response.next)
9910
+ }
9689
9911
  })
9690
9912
  );
9691
9913
  var LeaseTriggerInboxMessagesSchema = zod.z.object({
@@ -10408,17 +10630,14 @@ var listTriggersPlugin = definePlugin(
10408
10630
  itemType: "Action",
10409
10631
  inputSchema: ListTriggersSchema,
10410
10632
  outputSchema: ActionItemSchema,
10633
+ formatter: actionItemFormatter,
10411
10634
  defaultPageSize: DEFAULT_PAGE_SIZE,
10412
10635
  resolvers: { app: appKeyResolver },
10413
- handler: async ({
10414
- sdk: sdk2,
10415
- options
10416
- }) => {
10417
- const result = await sdk2.listActions({
10636
+ handler: async ({ sdk: sdk2, options }) => {
10637
+ return await sdk2.listActions({
10418
10638
  ...options,
10419
10639
  actionType: "read"
10420
10640
  });
10421
- return { data: result.data, nextCursor: result.nextCursor };
10422
10641
  }
10423
10642
  })
10424
10643
  );
@@ -10445,6 +10664,7 @@ var listTriggerInputFieldsPlugin = definePlugin(
10445
10664
  itemType: "RootField",
10446
10665
  inputSchema: ListTriggerInputFieldsSchema,
10447
10666
  outputSchema: RootFieldItemSchema,
10667
+ formatter: rootFieldItemFormatter,
10448
10668
  defaultPageSize: DEFAULT_PAGE_SIZE,
10449
10669
  // actionKeyResolver and inputsAllOptionalResolver depend on actionType.
10450
10670
  // Pin it to "read" so they resolve correctly without the user setting it.
@@ -10455,15 +10675,11 @@ var listTriggerInputFieldsPlugin = definePlugin(
10455
10675
  inputs: inputsAllOptionalResolver,
10456
10676
  actionType: { type: "constant", value: "read" }
10457
10677
  },
10458
- handler: async ({
10459
- sdk: sdk2,
10460
- options
10461
- }) => {
10462
- const result = await sdk2.listActionInputFields({
10678
+ handler: async ({ sdk: sdk2, options }) => {
10679
+ return await sdk2.listActionInputFields({
10463
10680
  ...options,
10464
10681
  actionType: "read"
10465
10682
  });
10466
- return { data: result.data, nextCursor: result.nextCursor };
10467
10683
  }
10468
10684
  })
10469
10685
  );
@@ -10494,6 +10710,7 @@ var listTriggerInputFieldChoicesPlugin = definePlugin(
10494
10710
  itemType: "InputFieldChoice",
10495
10711
  inputSchema: ListTriggerInputFieldChoicesSchema,
10496
10712
  outputSchema: InputFieldChoiceItemSchema,
10713
+ formatter: inputFieldChoiceItemFormatter,
10497
10714
  defaultPageSize: DEFAULT_PAGE_SIZE,
10498
10715
  resolvers: {
10499
10716
  app: appKeyResolver,
@@ -10503,15 +10720,11 @@ var listTriggerInputFieldChoicesPlugin = definePlugin(
10503
10720
  inputs: inputsAllOptionalResolver,
10504
10721
  actionType: { type: "constant", value: "read" }
10505
10722
  },
10506
- handler: async ({
10507
- sdk: sdk2,
10508
- options
10509
- }) => {
10510
- const result = await sdk2.listActionInputFieldChoices({
10723
+ handler: async ({ sdk: sdk2, options }) => {
10724
+ return await sdk2.listActionInputFieldChoices({
10511
10725
  ...options,
10512
10726
  actionType: "read"
10513
10727
  });
10514
- return { data: result.data, nextCursor: result.nextCursor };
10515
10728
  }
10516
10729
  })
10517
10730
  );
@@ -10613,10 +10826,9 @@ var listWorkflowsPlugin = definePlugin(
10613
10826
  const response = ListWorkflowsApiResponseSchema.parse(raw);
10614
10827
  return {
10615
10828
  data: response.workflows,
10616
- next: response.next_cursor ?? null
10829
+ nextCursor: response.next_cursor ?? void 0
10617
10830
  };
10618
- },
10619
- extractCursor: (response) => response.next ?? void 0
10831
+ }
10620
10832
  })
10621
10833
  );
10622
10834
  var WorkflowVersionSchema = zod.z.object({
@@ -11326,6 +11538,249 @@ var getWorkflowVersionPlugin = definePlugin(
11326
11538
  }
11327
11539
  })
11328
11540
  );
11541
+ var WorkflowRunStatusSchema = zod.z.union([
11542
+ zod.z.enum(["initialized", "started", "finished", "failed", "cancelled"]),
11543
+ zod.z.string()
11544
+ ]).describe(
11545
+ "Workflow run lifecycle status. `finished` / `failed` / `cancelled` are terminal."
11546
+ );
11547
+ var WorkflowRunListItemSchema = zod.z.object({
11548
+ id: zod.z.string().describe("Workflow run ID (UUID)"),
11549
+ trigger_id: zod.z.string().nullable().describe(
11550
+ "ID of the trigger that fired this run, if any. Null for runs created without a trigger."
11551
+ ),
11552
+ durable_run_id: zod.z.string().nullable().describe(
11553
+ "Linked sdkdurableapi run ID. Null until the durable run is created."
11554
+ ),
11555
+ workflow_version_id: zod.z.string().nullable().describe("Workflow version the run is bound to. Null in rare edge cases."),
11556
+ status: WorkflowRunStatusSchema,
11557
+ input: zod.z.unknown().describe("Input passed to the run"),
11558
+ output: zod.z.unknown().nullable().describe("Return value, present when status is `finished`"),
11559
+ error: zod.z.unknown().nullable().describe("Error payload when status is `failed` (null otherwise)"),
11560
+ created_at: zod.z.string().describe("When the run was created (ISO-8601)"),
11561
+ updated_at: zod.z.string().describe("When the run was last updated (ISO-8601)")
11562
+ });
11563
+ var ListWorkflowRunsOptionsSchema = zod.z.object({
11564
+ workflow: zod.z.string().uuid().describe("Durable workflow ID"),
11565
+ pageSize: zod.z.number().int().min(1).max(100).optional().describe("Number of runs per page (max 100)"),
11566
+ cursor: zod.z.string().optional().describe("Pagination cursor"),
11567
+ maxItems: zod.z.number().int().min(1).optional().describe("Maximum total runs to return across all pages")
11568
+ }).describe(
11569
+ "List workflow runs (triggered executions) for a specific deployed workflow, newest first"
11570
+ );
11571
+ var ListWorkflowRunsApiResponseSchema = zod.z.object({
11572
+ results: zod.z.array(WorkflowRunListItemSchema),
11573
+ meta: zod.z.object({
11574
+ limit: zod.z.number(),
11575
+ cursor: zod.z.string().nullable().optional(),
11576
+ next_cursor: zod.z.string().nullable().optional()
11577
+ }),
11578
+ links: zod.z.object({
11579
+ next: zod.z.string().nullable().optional()
11580
+ }).optional()
11581
+ });
11582
+
11583
+ // src/plugins/codeSubstrate/listWorkflowRuns/index.ts
11584
+ var listWorkflowRunsPlugin = definePlugin(
11585
+ (sdk) => createPaginatedPluginMethod(sdk, {
11586
+ ...codeSubstrateDefaults,
11587
+ name: "listWorkflowRuns",
11588
+ type: "list",
11589
+ itemType: "WorkflowRun",
11590
+ inputSchema: ListWorkflowRunsOptionsSchema,
11591
+ outputSchema: WorkflowRunListItemSchema,
11592
+ defaultPageSize: DEFAULT_PAGE_SIZE,
11593
+ resolvers: { workflow: workflowIdResolver },
11594
+ handler: async ({ sdk: sdk2, options }) => {
11595
+ const searchParams = {};
11596
+ if (options.pageSize !== void 0) {
11597
+ searchParams.limit = options.pageSize.toString();
11598
+ }
11599
+ if (options.cursor) {
11600
+ searchParams.cursor = options.cursor;
11601
+ }
11602
+ const raw = await sdk2.context.api.get(
11603
+ `/durableworkflowzaps/api/v0/workflows/${encodeURIComponent(options.workflow)}/runs`,
11604
+ {
11605
+ searchParams,
11606
+ authRequired: true,
11607
+ resource: { type: "workflow", id: options.workflow }
11608
+ }
11609
+ );
11610
+ const response = ListWorkflowRunsApiResponseSchema.parse(raw);
11611
+ return {
11612
+ data: response.results,
11613
+ nextCursor: response.meta.next_cursor ?? void 0
11614
+ };
11615
+ }
11616
+ })
11617
+ );
11618
+ var GetWorkflowRunOptionsSchema = zod.z.object({
11619
+ // Picker-only field — the API endpoint is /workflows/runs/:id and
11620
+ // does not take a workflow id, but the run-id picker is scoped to a
11621
+ // parent workflow so the user can browse runs without enumerating
11622
+ // every run across every workflow on the account.
11623
+ workflow: zod.z.string().uuid().optional().describe(
11624
+ "Parent workflow ID \u2014 used only to scope the CLI run-id picker; ignored by the API call."
11625
+ ),
11626
+ run: zod.z.string().uuid().describe("Workflow run ID")
11627
+ }).describe(
11628
+ "Get the current state of a workflow run (a triggered execution of a deployed workflow)"
11629
+ );
11630
+ var GetWorkflowRunResponseSchema = zod.z.object({
11631
+ id: zod.z.string().describe("Workflow run ID (UUID)"),
11632
+ trigger_id: zod.z.string().nullable().describe("ID of the trigger that fired this run, if any"),
11633
+ durable_run_id: zod.z.string().nullable().describe(
11634
+ "Linked sdkdurableapi run ID. Null until the durable run is created."
11635
+ ),
11636
+ workflow_version_id: zod.z.string().nullable().describe("Workflow version the run is bound to"),
11637
+ status: WorkflowRunStatusSchema,
11638
+ input: zod.z.unknown().describe("Input passed to the run"),
11639
+ output: zod.z.unknown().nullable().describe("Return value, present when status is `finished`"),
11640
+ error: zod.z.unknown().nullable().describe("Error payload when status is `failed` (null otherwise)"),
11641
+ created_at: zod.z.string().describe("When the run was created (ISO-8601)"),
11642
+ updated_at: zod.z.string().describe("When the run was last updated (ISO-8601)")
11643
+ });
11644
+
11645
+ // src/plugins/codeSubstrate/getWorkflowRun/index.ts
11646
+ var getWorkflowRunPlugin = definePlugin(
11647
+ (sdk) => createPluginMethod(sdk, {
11648
+ ...codeSubstrateDefaults,
11649
+ name: "getWorkflowRun",
11650
+ type: "item",
11651
+ itemType: "WorkflowRun",
11652
+ inputSchema: GetWorkflowRunOptionsSchema,
11653
+ outputSchema: GetWorkflowRunResponseSchema,
11654
+ resolvers: {
11655
+ workflow: workflowIdResolver,
11656
+ run: workflowRunIdResolver
11657
+ },
11658
+ handler: async ({ sdk: sdk2, options }) => {
11659
+ const raw = await sdk2.context.api.get(
11660
+ `/durableworkflowzaps/api/v0/workflows/runs/${encodeURIComponent(options.run)}`,
11661
+ {
11662
+ authRequired: true,
11663
+ resource: { type: "workflow-run", id: options.run }
11664
+ }
11665
+ );
11666
+ const data = GetWorkflowRunResponseSchema.parse(raw);
11667
+ return { data };
11668
+ }
11669
+ })
11670
+ );
11671
+ var GetTriggerRunOptionsSchema = zod.z.object({
11672
+ trigger: zod.z.string().uuid().describe("Workflow trigger ID")
11673
+ }).describe(
11674
+ "Get the workflow run associated with a deployed workflow's trigger. Useful immediately after firing a trigger, when you have the trigger ID but not yet the run ID."
11675
+ );
11676
+ var GetTriggerRunResponseSchema = zod.z.object({
11677
+ id: zod.z.string().describe("Workflow run ID (UUID)"),
11678
+ durable_run_id: zod.z.string().nullable().describe(
11679
+ "Linked sdkdurableapi run ID. Null until the durable run is created."
11680
+ ),
11681
+ workflow_version_id: zod.z.string().nullable().describe("Workflow version the run is bound to"),
11682
+ status: WorkflowRunStatusSchema,
11683
+ input: zod.z.unknown().describe("Input passed to the run"),
11684
+ output: zod.z.unknown().nullable().describe("Return value, present when status is `finished`"),
11685
+ error: zod.z.unknown().nullable().describe("Error payload when status is `failed` (null otherwise)"),
11686
+ created_at: zod.z.string().describe("When the run was created (ISO-8601)"),
11687
+ updated_at: zod.z.string().describe("When the run was last updated (ISO-8601)")
11688
+ });
11689
+
11690
+ // src/plugins/codeSubstrate/getTriggerRun/index.ts
11691
+ var getTriggerRunPlugin = definePlugin(
11692
+ (sdk) => createPluginMethod(sdk, {
11693
+ ...codeSubstrateDefaults,
11694
+ name: "getTriggerRun",
11695
+ type: "item",
11696
+ itemType: "WorkflowRun",
11697
+ inputSchema: GetTriggerRunOptionsSchema,
11698
+ outputSchema: GetTriggerRunResponseSchema,
11699
+ // No resolver for `trigger` — users typically have the trigger id
11700
+ // from a recent trigger fire and pass it directly. Authoring a
11701
+ // picker would require listing triggers across all workflows,
11702
+ // which has no clean entry point today.
11703
+ handler: async ({ sdk: sdk2, options }) => {
11704
+ const raw = await sdk2.context.api.get(
11705
+ `/durableworkflowzaps/api/v0/workflows/triggers/${encodeURIComponent(options.trigger)}/run`,
11706
+ {
11707
+ authRequired: true,
11708
+ resource: { type: "workflow-trigger", id: options.trigger }
11709
+ }
11710
+ );
11711
+ const data = GetTriggerRunResponseSchema.parse(raw);
11712
+ return { data };
11713
+ }
11714
+ })
11715
+ );
11716
+ var TriggerWorkflowLookupResponseSchema = zod.z.object({
11717
+ trigger_url: zod.z.string()
11718
+ }).passthrough();
11719
+ var TriggerWorkflowOptionsSchema = zod.z.object({
11720
+ workflow: zod.z.string().uuid().describe("Durable workflow ID"),
11721
+ input: zod.z.unknown().optional().describe(
11722
+ "JSON payload delivered as the trigger body. Sent as `application/json`; omit to fire with an empty body."
11723
+ )
11724
+ }).describe(
11725
+ "Look up a workflow's trigger URL and fire it manually. The trigger endpoint is tokenized (the URL contains a secret) and takes no auth header, so the SDK uses a raw fetch rather than the api plugin."
11726
+ );
11727
+ var TriggerWorkflowResponseSchema = zod.z.object({
11728
+ workflow: zod.z.string().describe("The workflow ID that was triggered"),
11729
+ status: zod.z.number().int().describe("HTTP status returned by the trigger endpoint"),
11730
+ body: zod.z.unknown().describe(
11731
+ "Response body from the trigger endpoint. Parsed as JSON when the response body parses, otherwise returned as the raw response text."
11732
+ )
11733
+ });
11734
+
11735
+ // src/plugins/codeSubstrate/triggerWorkflow/index.ts
11736
+ var triggerWorkflowPlugin = definePlugin(
11737
+ (sdk) => createPluginMethod(sdk, {
11738
+ ...codeSubstrateDefaults,
11739
+ name: "triggerWorkflow",
11740
+ type: "create",
11741
+ itemType: "WorkflowRun",
11742
+ inputSchema: TriggerWorkflowOptionsSchema,
11743
+ outputSchema: TriggerWorkflowResponseSchema,
11744
+ resolvers: { workflow: workflowIdResolver },
11745
+ handler: async ({ sdk: sdk2, options }) => {
11746
+ const rawWorkflow = await sdk2.context.api.get(
11747
+ `/durableworkflowzaps/api/v0/workflows/${encodeURIComponent(options.workflow)}`,
11748
+ {
11749
+ authRequired: true,
11750
+ resource: { type: "workflow", id: options.workflow }
11751
+ }
11752
+ );
11753
+ const workflow = TriggerWorkflowLookupResponseSchema.parse(rawWorkflow);
11754
+ const fetch2 = sdk2.context.options.fetch ?? globalThis.fetch;
11755
+ const response = await fetch2(workflow.trigger_url, {
11756
+ method: "POST",
11757
+ headers: { "Content-Type": "application/json" },
11758
+ body: options.input === void 0 ? void 0 : JSON.stringify(options.input)
11759
+ });
11760
+ const text = await response.text().catch(() => "");
11761
+ let body = text;
11762
+ if (text) {
11763
+ try {
11764
+ body = JSON.parse(text);
11765
+ } catch {
11766
+ body = text;
11767
+ }
11768
+ }
11769
+ if (!response.ok) {
11770
+ throw new ZapierApiError(
11771
+ `Trigger failed: ${response.status} ${response.statusText}: ${text || "(empty body)"}`,
11772
+ { statusCode: response.status, response: body }
11773
+ );
11774
+ }
11775
+ const data = {
11776
+ workflow: options.workflow,
11777
+ status: response.status,
11778
+ body
11779
+ };
11780
+ return { data };
11781
+ }
11782
+ })
11783
+ );
11329
11784
 
11330
11785
  // src/utils/batch-utils.ts
11331
11786
  var DEFAULT_CONCURRENCY = 10;
@@ -11477,15 +11932,18 @@ var BaseSdkOptionsSchema = zod.z.object({
11477
11932
 
11478
11933
  // src/plugins/registry/index.ts
11479
11934
  var registryPlugin = definePlugin((_sdk) => {
11480
- logDeprecation(
11935
+ logDeprecation2(
11481
11936
  "registryPlugin is deprecated and a no-op; getRegistry is now built into every sdk. Remove .addPlugin(registryPlugin)."
11482
11937
  );
11483
11938
  return {};
11484
11939
  });
11485
11940
 
11486
11941
  // src/experimental.ts
11942
+ function createZapierSdkStack2(options = {}) {
11943
+ 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(listTriggerInboxesPlugin).use(createTriggerInboxPlugin).use(ensureTriggerInboxPlugin).use(getTriggerInboxPlugin).use(updateTriggerInboxPlugin).use(deleteTriggerInboxPlugin).use(pauseTriggerInboxPlugin).use(resumeTriggerInboxPlugin).use(listTriggerInboxMessagesPlugin).use(leaseTriggerInboxMessagesPlugin).use(ackTriggerInboxMessagesPlugin).use(releaseTriggerInboxMessagesPlugin).use(drainTriggerInboxPlugin).use(watchTriggerInboxPlugin).use(listTriggersPlugin).use(listTriggerInputFieldsPlugin).use(listTriggerInputFieldChoicesPlugin).use(getTriggerInputFieldsSchemaPlugin).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(listWorkflowsPlugin).use(getWorkflowPlugin).use(createWorkflowPlugin).use(updateWorkflowPlugin).use(enableWorkflowPlugin).use(disableWorkflowPlugin).use(deleteWorkflowPlugin).use(listDurableRunsPlugin).use(getDurableRunPlugin).use(runDurablePlugin).use(cancelDurableRunPlugin).use(publishWorkflowVersionPlugin).use(listWorkflowVersionsPlugin).use(getWorkflowVersionPlugin).use(listWorkflowRunsPlugin).use(getWorkflowRunPlugin).use(getTriggerRunPlugin).use(triggerWorkflowPlugin).use(appsPlugin).use(getProfilePlugin);
11944
+ }
11487
11945
  function createZapierSdk2(options = {}) {
11488
- 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(createTriggerInboxPlugin).addPlugin(ensureTriggerInboxPlugin).addPlugin(listTriggerInboxesPlugin).addPlugin(getTriggerInboxPlugin).addPlugin(updateTriggerInboxPlugin).addPlugin(deleteTriggerInboxPlugin).addPlugin(pauseTriggerInboxPlugin).addPlugin(resumeTriggerInboxPlugin).addPlugin(listTriggerInboxMessagesPlugin).addPlugin(leaseTriggerInboxMessagesPlugin).addPlugin(ackTriggerInboxMessagesPlugin).addPlugin(releaseTriggerInboxMessagesPlugin).addPlugin(drainTriggerInboxPlugin).addPlugin(watchTriggerInboxPlugin).addPlugin(listTriggersPlugin).addPlugin(listTriggerInputFieldsPlugin).addPlugin(listTriggerInputFieldChoicesPlugin).addPlugin(getTriggerInputFieldsSchemaPlugin).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(listWorkflowsPlugin).addPlugin(getWorkflowPlugin).addPlugin(createWorkflowPlugin).addPlugin(updateWorkflowPlugin).addPlugin(enableWorkflowPlugin).addPlugin(disableWorkflowPlugin).addPlugin(deleteWorkflowPlugin).addPlugin(listDurableRunsPlugin).addPlugin(getDurableRunPlugin).addPlugin(runDurablePlugin).addPlugin(cancelDurableRunPlugin).addPlugin(publishWorkflowVersionPlugin).addPlugin(listWorkflowVersionsPlugin).addPlugin(getWorkflowVersionPlugin).addPlugin(appsPlugin).addPlugin(getProfilePlugin);
11946
+ return withDeprecatedAddPlugin(createZapierSdkStack2(options).toSdk());
11489
11947
  }
11490
11948
 
11491
11949
  exports.ActionKeyPropertySchema = ActionKeyPropertySchema;
@@ -11499,12 +11957,14 @@ exports.AuthenticationIdPropertySchema = AuthenticationIdPropertySchema;
11499
11957
  exports.BaseSdkOptionsSchema = BaseSdkOptionsSchema;
11500
11958
  exports.CONTEXT_CACHE_MAX_SIZE = CONTEXT_CACHE_MAX_SIZE;
11501
11959
  exports.CONTEXT_CACHE_TTL_MS = CONTEXT_CACHE_TTL_MS;
11960
+ exports.CORE_ERROR_SYMBOL = CORE_ERROR_SYMBOL;
11502
11961
  exports.ClientCredentialsObjectSchema = ClientCredentialsObjectSchema;
11503
11962
  exports.ConnectionEntrySchema = ConnectionEntrySchema;
11504
11963
  exports.ConnectionIdPropertySchema = ConnectionIdPropertySchema;
11505
11964
  exports.ConnectionPropertySchema = ConnectionPropertySchema;
11506
11965
  exports.ConnectionsMapSchema = ConnectionsMapSchema;
11507
11966
  exports.ConnectionsPropertySchema = ConnectionsPropertySchema;
11967
+ exports.CoreErrorCode = CoreErrorCode;
11508
11968
  exports.CredentialsFunctionSchema = CredentialsFunctionSchema;
11509
11969
  exports.CredentialsObjectSchema = CredentialsObjectSchema;
11510
11970
  exports.CredentialsSchema = CredentialsSchema;
@@ -11561,6 +12021,7 @@ exports.ZapierUnknownError = ZapierUnknownError;
11561
12021
  exports.ZapierValidationError = ZapierValidationError;
11562
12022
  exports.actionKeyResolver = actionKeyResolver;
11563
12023
  exports.actionTypeResolver = actionTypeResolver;
12024
+ exports.addPlugin = addPlugin;
11564
12025
  exports.apiPlugin = apiPlugin;
11565
12026
  exports.appKeyResolver = appKeyResolver;
11566
12027
  exports.appsPlugin = appsPlugin;
@@ -11582,17 +12043,21 @@ exports.connectionIdResolver = connectionIdResolver;
11582
12043
  exports.connectionsPlugin = connectionsPlugin;
11583
12044
  exports.createBaseEvent = createBaseEvent;
11584
12045
  exports.createClientCredentialsPlugin = createClientCredentialsPlugin;
12046
+ exports.createCorePlugin = createCorePlugin;
11585
12047
  exports.createFunction = createFunction;
11586
12048
  exports.createMemoryCache = createMemoryCache;
11587
12049
  exports.createOptionsPlugin = createOptionsPlugin;
11588
12050
  exports.createPaginatedPluginMethod = createPaginatedPluginMethod;
11589
12051
  exports.createPluginMethod = createPluginMethod;
12052
+ exports.createPluginStack = createPluginStack;
11590
12053
  exports.createSdk = createSdk;
11591
12054
  exports.createTableFieldsPlugin = createTableFieldsPlugin;
11592
12055
  exports.createTablePlugin = createTablePlugin;
11593
12056
  exports.createTableRecordsPlugin = createTableRecordsPlugin;
11594
12057
  exports.createZapierApi = createZapierApi;
12058
+ exports.createZapierCoreStack = createZapierCoreStack;
11595
12059
  exports.createZapierSdk = createZapierSdk2;
12060
+ exports.createZapierSdkStack = createZapierSdkStack2;
11596
12061
  exports.createZapierSdkWithoutRegistry = createZapierSdkWithoutRegistry;
11597
12062
  exports.definePlugin = definePlugin;
11598
12063
  exports.deleteClientCredentialsPlugin = deleteClientCredentialsPlugin;
@@ -11614,6 +12079,8 @@ exports.getBaseUrlFromCredentials = getBaseUrlFromCredentials;
11614
12079
  exports.getCiPlatform = getCiPlatform;
11615
12080
  exports.getClientIdFromCredentials = getClientIdFromCredentials;
11616
12081
  exports.getConnectionPlugin = getConnectionPlugin;
12082
+ exports.getCoreErrorCause = getCoreErrorCause;
12083
+ exports.getCoreErrorCode = getCoreErrorCode;
11617
12084
  exports.getCpuTime = getCpuTime;
11618
12085
  exports.getCurrentTimestamp = getCurrentTimestamp;
11619
12086
  exports.getMemoryUsage = getMemoryUsage;
@@ -11638,6 +12105,7 @@ exports.invalidateCredentialsToken = invalidateCredentialsToken;
11638
12105
  exports.isCi = isCi;
11639
12106
  exports.isCliLoginAvailable = isCliLoginAvailable;
11640
12107
  exports.isClientCredentials = isClientCredentials;
12108
+ exports.isCoreError = isCoreError;
11641
12109
  exports.isCredentialsFunction = isCredentialsFunction;
11642
12110
  exports.isCredentialsObject = isCredentialsObject;
11643
12111
  exports.isPkceCredentials = isPkceCredentials;
@@ -11651,17 +12119,18 @@ exports.listConnectionsPlugin = listConnectionsPlugin;
11651
12119
  exports.listTableFieldsPlugin = listTableFieldsPlugin;
11652
12120
  exports.listTableRecordsPlugin = listTableRecordsPlugin;
11653
12121
  exports.listTablesPlugin = listTablesPlugin;
11654
- exports.logDeprecation = logDeprecation;
12122
+ exports.logDeprecation = logDeprecation2;
11655
12123
  exports.manifestPlugin = manifestPlugin;
11656
12124
  exports.parseConcurrencyEnvVar = parseConcurrencyEnvVar;
11657
12125
  exports.readManifestFromFile = readManifestFromFile;
11658
12126
  exports.registryPlugin = registryPlugin;
11659
12127
  exports.requestPlugin = requestPlugin;
11660
- exports.resetDeprecationWarnings = resetDeprecationWarnings;
12128
+ exports.resetDeprecationWarnings = resetDeprecationWarnings2;
11661
12129
  exports.resolveAuthToken = resolveAuthToken;
11662
12130
  exports.resolveCredentials = resolveCredentials;
11663
12131
  exports.resolveCredentialsFromEnv = resolveCredentialsFromEnv;
11664
12132
  exports.runActionPlugin = runActionPlugin;
12133
+ exports.runInMethodScope = runInMethodScope;
11665
12134
  exports.runWithTelemetryContext = runWithTelemetryContext;
11666
12135
  exports.tableFieldIdsResolver = tableFieldIdsResolver;
11667
12136
  exports.tableFieldsResolver = tableFieldsResolver;
@@ -11679,4 +12148,6 @@ exports.triggerInboxResolver = triggerInboxResolver;
11679
12148
  exports.triggerMessagesResolver = triggerMessagesResolver;
11680
12149
  exports.updateTableRecordsPlugin = updateTableRecordsPlugin;
11681
12150
  exports.workflowIdResolver = workflowIdResolver;
12151
+ exports.workflowRunIdResolver = workflowRunIdResolver;
11682
12152
  exports.workflowVersionIdResolver = workflowVersionIdResolver;
12153
+ exports.zapierAdaptError = zapierAdaptError;