@zapier/zapier-sdk 0.77.1 → 0.78.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 (800) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/experimental.cjs +1057 -178
  3. package/dist/experimental.d.mts +22 -39
  4. package/dist/experimental.d.ts +932 -964
  5. package/dist/experimental.mjs +1049 -179
  6. package/dist/{index-BZShISEr.d.mts → index-BgbftweS.d.mts} +4771 -3841
  7. package/dist/{index-BZShISEr.d.ts → index-BgbftweS.d.ts} +4771 -3841
  8. package/dist/index.cjs +2489 -1617
  9. package/dist/index.d.mts +1 -2
  10. package/dist/index.d.ts +6 -81
  11. package/dist/index.mjs +2481 -1618
  12. package/package.json +2 -2
  13. package/dist/api/approval-review-stream.d.ts +0 -25
  14. package/dist/api/approval-review-stream.d.ts.map +0 -1
  15. package/dist/api/approval-review-stream.js +0 -104
  16. package/dist/api/auth.d.ts +0 -14
  17. package/dist/api/auth.d.ts.map +0 -1
  18. package/dist/api/auth.js +0 -77
  19. package/dist/api/client.d.ts +0 -9
  20. package/dist/api/client.d.ts.map +0 -1
  21. package/dist/api/client.js +0 -1232
  22. package/dist/api/concurrency.d.ts +0 -28
  23. package/dist/api/concurrency.d.ts.map +0 -1
  24. package/dist/api/concurrency.js +0 -90
  25. package/dist/api/debug.d.ts +0 -14
  26. package/dist/api/debug.d.ts.map +0 -1
  27. package/dist/api/debug.js +0 -133
  28. package/dist/api/error-classification.d.ts +0 -19
  29. package/dist/api/error-classification.d.ts.map +0 -1
  30. package/dist/api/error-classification.js +0 -31
  31. package/dist/api/index.d.ts +0 -33
  32. package/dist/api/index.d.ts.map +0 -1
  33. package/dist/api/index.js +0 -44
  34. package/dist/api/polling.d.ts +0 -64
  35. package/dist/api/polling.d.ts.map +0 -1
  36. package/dist/api/polling.js +0 -180
  37. package/dist/api/schemas.d.ts +0 -423
  38. package/dist/api/schemas.d.ts.map +0 -1
  39. package/dist/api/schemas.js +0 -323
  40. package/dist/api/sse-parser.d.ts +0 -51
  41. package/dist/api/sse-parser.d.ts.map +0 -1
  42. package/dist/api/sse-parser.js +0 -95
  43. package/dist/api/types.d.ts +0 -215
  44. package/dist/api/types.d.ts.map +0 -1
  45. package/dist/api/types.js +0 -1
  46. package/dist/auth.d.ts +0 -149
  47. package/dist/auth.d.ts.map +0 -1
  48. package/dist/auth.js +0 -526
  49. package/dist/cache.d.ts +0 -50
  50. package/dist/cache.d.ts.map +0 -1
  51. package/dist/cache.js +0 -47
  52. package/dist/constants.d.ts +0 -84
  53. package/dist/constants.d.ts.map +0 -1
  54. package/dist/constants.js +0 -122
  55. package/dist/core-stack.d.ts +0 -24
  56. package/dist/core-stack.d.ts.map +0 -1
  57. package/dist/core-stack.js +0 -32
  58. package/dist/credentials.d.ts +0 -57
  59. package/dist/credentials.d.ts.map +0 -1
  60. package/dist/credentials.js +0 -184
  61. package/dist/define/apps-entrypoint.d.ts +0 -3
  62. package/dist/define/apps-entrypoint.d.ts.map +0 -1
  63. package/dist/define/apps-entrypoint.js +0 -1
  64. package/dist/define/apps-registry-keys.d.ts +0 -2
  65. package/dist/define/apps-registry-keys.d.ts.map +0 -1
  66. package/dist/define/apps-registry-keys.js +0 -2
  67. package/dist/define/apps-registry.d.ts +0 -13
  68. package/dist/define/apps-registry.d.ts.map +0 -1
  69. package/dist/define/apps-registry.js +0 -31
  70. package/dist/define/apps-registry.json +0 -9010
  71. package/dist/define/apps.d.ts +0 -11
  72. package/dist/define/apps.d.ts.map +0 -1
  73. package/dist/define/apps.js +0 -2
  74. package/dist/define/define.d.ts +0 -13
  75. package/dist/define/define.d.ts.map +0 -1
  76. package/dist/define/define.js +0 -93
  77. package/dist/define/helpers.d.ts +0 -8
  78. package/dist/define/helpers.d.ts.map +0 -1
  79. package/dist/define/helpers.js +0 -6
  80. package/dist/define/index.d.ts +0 -5
  81. package/dist/define/index.d.ts.map +0 -1
  82. package/dist/define/index.js +0 -2
  83. package/dist/define/types.d.ts +0 -246
  84. package/dist/define/types.d.ts.map +0 -1
  85. package/dist/define/types.js +0 -1
  86. package/dist/experimental.d.ts.map +0 -1
  87. package/dist/experimental.js +0 -232
  88. package/dist/formatters/action.d.ts +0 -4
  89. package/dist/formatters/action.d.ts.map +0 -1
  90. package/dist/formatters/action.js +0 -18
  91. package/dist/formatters/actionResult.d.ts +0 -3
  92. package/dist/formatters/actionResult.d.ts.map +0 -1
  93. package/dist/formatters/actionResult.js +0 -25
  94. package/dist/formatters/app.d.ts +0 -4
  95. package/dist/formatters/app.d.ts.map +0 -1
  96. package/dist/formatters/app.js +0 -10
  97. package/dist/formatters/clientCredentials.d.ts +0 -5
  98. package/dist/formatters/clientCredentials.d.ts.map +0 -1
  99. package/dist/formatters/clientCredentials.js +0 -27
  100. package/dist/formatters/connection.d.ts +0 -4
  101. package/dist/formatters/connection.d.ts.map +0 -1
  102. package/dist/formatters/connection.js +0 -26
  103. package/dist/formatters/field.d.ts +0 -4
  104. package/dist/formatters/field.d.ts.map +0 -1
  105. package/dist/formatters/field.js +0 -51
  106. package/dist/formatters/index.d.ts +0 -2
  107. package/dist/formatters/index.d.ts.map +0 -1
  108. package/dist/formatters/index.js +0 -1
  109. package/dist/formatters/inputFieldChoice.d.ts +0 -4
  110. package/dist/formatters/inputFieldChoice.d.ts.map +0 -1
  111. package/dist/formatters/inputFieldChoice.js +0 -16
  112. package/dist/formatters/tableField.d.ts +0 -4
  113. package/dist/formatters/tableField.d.ts.map +0 -1
  114. package/dist/formatters/tableField.js +0 -7
  115. package/dist/formatters/tableRecord.d.ts +0 -8
  116. package/dist/formatters/tableRecord.d.ts.map +0 -1
  117. package/dist/formatters/tableRecord.js +0 -24
  118. package/dist/formatters/triggerInbox.d.ts +0 -4
  119. package/dist/formatters/triggerInbox.d.ts.map +0 -1
  120. package/dist/formatters/triggerInbox.js +0 -31
  121. package/dist/formatters/triggerMessage.d.ts +0 -5
  122. package/dist/formatters/triggerMessage.d.ts.map +0 -1
  123. package/dist/formatters/triggerMessage.js +0 -34
  124. package/dist/formatters/userProfile.d.ts +0 -4
  125. package/dist/formatters/userProfile.d.ts.map +0 -1
  126. package/dist/formatters/userProfile.js +0 -19
  127. package/dist/index.d.ts.map +0 -1
  128. package/dist/index.js +0 -94
  129. package/dist/plugins/api/index.d.ts +0 -30
  130. package/dist/plugins/api/index.d.ts.map +0 -1
  131. package/dist/plugins/api/index.js +0 -35
  132. package/dist/plugins/apps/index.d.ts +0 -118
  133. package/dist/plugins/apps/index.d.ts.map +0 -1
  134. package/dist/plugins/apps/index.js +0 -156
  135. package/dist/plugins/apps/schemas.d.ts +0 -50
  136. package/dist/plugins/apps/schemas.d.ts.map +0 -1
  137. package/dist/plugins/apps/schemas.js +0 -37
  138. package/dist/plugins/capabilities/index.d.ts +0 -27
  139. package/dist/plugins/capabilities/index.d.ts.map +0 -1
  140. package/dist/plugins/capabilities/index.js +0 -75
  141. package/dist/plugins/codeSubstrate/cancelDurableRun/index.d.ts +0 -70
  142. package/dist/plugins/codeSubstrate/cancelDurableRun/index.d.ts.map +0 -1
  143. package/dist/plugins/codeSubstrate/cancelDurableRun/index.js +0 -28
  144. package/dist/plugins/codeSubstrate/cancelDurableRun/schemas.d.ts +0 -11
  145. package/dist/plugins/codeSubstrate/cancelDurableRun/schemas.d.ts.map +0 -1
  146. package/dist/plugins/codeSubstrate/cancelDurableRun/schemas.js +0 -12
  147. package/dist/plugins/codeSubstrate/createWorkflow/index.d.ts +0 -49
  148. package/dist/plugins/codeSubstrate/createWorkflow/index.d.ts.map +0 -1
  149. package/dist/plugins/codeSubstrate/createWorkflow/index.js +0 -24
  150. package/dist/plugins/codeSubstrate/createWorkflow/schemas.d.ts +0 -20
  151. package/dist/plugins/codeSubstrate/createWorkflow/schemas.d.ts.map +0 -1
  152. package/dist/plugins/codeSubstrate/createWorkflow/schemas.js +0 -42
  153. package/dist/plugins/codeSubstrate/deleteWorkflow/index.d.ts +0 -75
  154. package/dist/plugins/codeSubstrate/deleteWorkflow/index.d.ts.map +0 -1
  155. package/dist/plugins/codeSubstrate/deleteWorkflow/index.js +0 -28
  156. package/dist/plugins/codeSubstrate/deleteWorkflow/schemas.d.ts +0 -10
  157. package/dist/plugins/codeSubstrate/deleteWorkflow/schemas.d.ts.map +0 -1
  158. package/dist/plugins/codeSubstrate/deleteWorkflow/schemas.js +0 -13
  159. package/dist/plugins/codeSubstrate/disableWorkflow/index.d.ts +0 -76
  160. package/dist/plugins/codeSubstrate/disableWorkflow/index.d.ts.map +0 -1
  161. package/dist/plugins/codeSubstrate/disableWorkflow/index.js +0 -21
  162. package/dist/plugins/codeSubstrate/disableWorkflow/schemas.d.ts +0 -11
  163. package/dist/plugins/codeSubstrate/disableWorkflow/schemas.d.ts.map +0 -1
  164. package/dist/plugins/codeSubstrate/disableWorkflow/schemas.js +0 -12
  165. package/dist/plugins/codeSubstrate/enableWorkflow/index.d.ts +0 -76
  166. package/dist/plugins/codeSubstrate/enableWorkflow/index.d.ts.map +0 -1
  167. package/dist/plugins/codeSubstrate/enableWorkflow/index.js +0 -21
  168. package/dist/plugins/codeSubstrate/enableWorkflow/schemas.d.ts +0 -11
  169. package/dist/plugins/codeSubstrate/enableWorkflow/schemas.d.ts.map +0 -1
  170. package/dist/plugins/codeSubstrate/enableWorkflow/schemas.js +0 -12
  171. package/dist/plugins/codeSubstrate/getDurableRun/index.d.ts +0 -119
  172. package/dist/plugins/codeSubstrate/getDurableRun/index.d.ts.map +0 -1
  173. package/dist/plugins/codeSubstrate/getDurableRun/index.js +0 -21
  174. package/dist/plugins/codeSubstrate/getDurableRun/schemas.d.ts +0 -178
  175. package/dist/plugins/codeSubstrate/getDurableRun/schemas.d.ts.map +0 -1
  176. package/dist/plugins/codeSubstrate/getDurableRun/schemas.js +0 -126
  177. package/dist/plugins/codeSubstrate/getTriggerRun/index.d.ts +0 -47
  178. package/dist/plugins/codeSubstrate/getTriggerRun/index.d.ts.map +0 -1
  179. package/dist/plugins/codeSubstrate/getTriggerRun/index.js +0 -23
  180. package/dist/plugins/codeSubstrate/getTriggerRun/schemas.d.ts +0 -24
  181. package/dist/plugins/codeSubstrate/getTriggerRun/schemas.d.ts.map +0 -1
  182. package/dist/plugins/codeSubstrate/getTriggerRun/schemas.js +0 -30
  183. package/dist/plugins/codeSubstrate/getWorkflow/index.d.ts +0 -114
  184. package/dist/plugins/codeSubstrate/getWorkflow/index.d.ts.map +0 -1
  185. package/dist/plugins/codeSubstrate/getWorkflow/index.js +0 -21
  186. package/dist/plugins/codeSubstrate/getWorkflow/schemas.d.ts +0 -81
  187. package/dist/plugins/codeSubstrate/getWorkflow/schemas.d.ts.map +0 -1
  188. package/dist/plugins/codeSubstrate/getWorkflow/schemas.js +0 -71
  189. package/dist/plugins/codeSubstrate/getWorkflowRun/index.d.ts +0 -112
  190. package/dist/plugins/codeSubstrate/getWorkflowRun/index.d.ts.map +0 -1
  191. package/dist/plugins/codeSubstrate/getWorkflowRun/index.js +0 -25
  192. package/dist/plugins/codeSubstrate/getWorkflowRun/schemas.d.ts +0 -26
  193. package/dist/plugins/codeSubstrate/getWorkflowRun/schemas.d.ts.map +0 -1
  194. package/dist/plugins/codeSubstrate/getWorkflowRun/schemas.js +0 -43
  195. package/dist/plugins/codeSubstrate/getWorkflowVersion/index.d.ts +0 -132
  196. package/dist/plugins/codeSubstrate/getWorkflowVersion/index.d.ts.map +0 -1
  197. package/dist/plugins/codeSubstrate/getWorkflowVersion/index.js +0 -25
  198. package/dist/plugins/codeSubstrate/getWorkflowVersion/schemas.d.ts +0 -30
  199. package/dist/plugins/codeSubstrate/getWorkflowVersion/schemas.d.ts.map +0 -1
  200. package/dist/plugins/codeSubstrate/getWorkflowVersion/schemas.js +0 -35
  201. package/dist/plugins/codeSubstrate/listDurableRuns/index.d.ts +0 -55
  202. package/dist/plugins/codeSubstrate/listDurableRuns/index.d.ts.map +0 -1
  203. package/dist/plugins/codeSubstrate/listDurableRuns/index.js +0 -31
  204. package/dist/plugins/codeSubstrate/listDurableRuns/schemas.d.ts +0 -73
  205. package/dist/plugins/codeSubstrate/listDurableRuns/schemas.d.ts.map +0 -1
  206. package/dist/plugins/codeSubstrate/listDurableRuns/schemas.js +0 -58
  207. package/dist/plugins/codeSubstrate/listWorkflowRuns/index.d.ts +0 -88
  208. package/dist/plugins/codeSubstrate/listWorkflowRuns/index.d.ts.map +0 -1
  209. package/dist/plugins/codeSubstrate/listWorkflowRuns/index.js +0 -34
  210. package/dist/plugins/codeSubstrate/listWorkflowRuns/schemas.d.ts +0 -63
  211. package/dist/plugins/codeSubstrate/listWorkflowRuns/schemas.d.ts.map +0 -1
  212. package/dist/plugins/codeSubstrate/listWorkflowRuns/schemas.js +0 -69
  213. package/dist/plugins/codeSubstrate/listWorkflowVersions/index.d.ts +0 -98
  214. package/dist/plugins/codeSubstrate/listWorkflowVersions/index.d.ts.map +0 -1
  215. package/dist/plugins/codeSubstrate/listWorkflowVersions/index.js +0 -34
  216. package/dist/plugins/codeSubstrate/listWorkflowVersions/schemas.d.ts +0 -63
  217. package/dist/plugins/codeSubstrate/listWorkflowVersions/schemas.d.ts.map +0 -1
  218. package/dist/plugins/codeSubstrate/listWorkflowVersions/schemas.js +0 -58
  219. package/dist/plugins/codeSubstrate/listWorkflows/index.d.ts +0 -61
  220. package/dist/plugins/codeSubstrate/listWorkflows/index.d.ts.map +0 -1
  221. package/dist/plugins/codeSubstrate/listWorkflows/index.js +0 -28
  222. package/dist/plugins/codeSubstrate/listWorkflows/schemas.d.ts +0 -86
  223. package/dist/plugins/codeSubstrate/listWorkflows/schemas.d.ts.map +0 -1
  224. package/dist/plugins/codeSubstrate/listWorkflows/schemas.js +0 -79
  225. package/dist/plugins/codeSubstrate/publishWorkflowVersion/index.d.ts +0 -150
  226. package/dist/plugins/codeSubstrate/publishWorkflowVersion/index.d.ts.map +0 -1
  227. package/dist/plugins/codeSubstrate/publishWorkflowVersion/index.js +0 -80
  228. package/dist/plugins/codeSubstrate/publishWorkflowVersion/schemas.d.ts +0 -158
  229. package/dist/plugins/codeSubstrate/publishWorkflowVersion/schemas.d.ts.map +0 -1
  230. package/dist/plugins/codeSubstrate/publishWorkflowVersion/schemas.js +0 -124
  231. package/dist/plugins/codeSubstrate/runDurable/index.d.ts +0 -94
  232. package/dist/plugins/codeSubstrate/runDurable/index.d.ts.map +0 -1
  233. package/dist/plugins/codeSubstrate/runDurable/index.js +0 -41
  234. package/dist/plugins/codeSubstrate/runDurable/schemas.d.ts +0 -149
  235. package/dist/plugins/codeSubstrate/runDurable/schemas.d.ts.map +0 -1
  236. package/dist/plugins/codeSubstrate/runDurable/schemas.js +0 -95
  237. package/dist/plugins/codeSubstrate/shared-schemas.d.ts +0 -41
  238. package/dist/plugins/codeSubstrate/shared-schemas.d.ts.map +0 -1
  239. package/dist/plugins/codeSubstrate/shared-schemas.js +0 -83
  240. package/dist/plugins/codeSubstrate/shared.d.ts +0 -72
  241. package/dist/plugins/codeSubstrate/shared.d.ts.map +0 -1
  242. package/dist/plugins/codeSubstrate/shared.js +0 -115
  243. package/dist/plugins/codeSubstrate/triggerWorkflow/index.d.ts +0 -78
  244. package/dist/plugins/codeSubstrate/triggerWorkflow/index.d.ts.map +0 -1
  245. package/dist/plugins/codeSubstrate/triggerWorkflow/index.js +0 -40
  246. package/dist/plugins/codeSubstrate/triggerWorkflow/schemas.d.ts +0 -16
  247. package/dist/plugins/codeSubstrate/triggerWorkflow/schemas.d.ts.map +0 -1
  248. package/dist/plugins/codeSubstrate/triggerWorkflow/schemas.js +0 -26
  249. package/dist/plugins/codeSubstrate/updateWorkflow/index.d.ts +0 -85
  250. package/dist/plugins/codeSubstrate/updateWorkflow/index.d.ts.map +0 -1
  251. package/dist/plugins/codeSubstrate/updateWorkflow/index.js +0 -28
  252. package/dist/plugins/codeSubstrate/updateWorkflow/schemas.d.ts +0 -20
  253. package/dist/plugins/codeSubstrate/updateWorkflow/schemas.d.ts.map +0 -1
  254. package/dist/plugins/codeSubstrate/updateWorkflow/schemas.js +0 -37
  255. package/dist/plugins/connections/index.d.ts +0 -19
  256. package/dist/plugins/connections/index.d.ts.map +0 -1
  257. package/dist/plugins/connections/index.js +0 -21
  258. package/dist/plugins/createClientCredentials/index.d.ts +0 -32
  259. package/dist/plugins/createClientCredentials/index.d.ts.map +0 -1
  260. package/dist/plugins/createClientCredentials/index.js +0 -29
  261. package/dist/plugins/createClientCredentials/schemas.d.ts +0 -18
  262. package/dist/plugins/createClientCredentials/schemas.d.ts.map +0 -1
  263. package/dist/plugins/createClientCredentials/schemas.js +0 -16
  264. package/dist/plugins/createConnection/index.d.ts +0 -189
  265. package/dist/plugins/createConnection/index.d.ts.map +0 -1
  266. package/dist/plugins/createConnection/index.js +0 -71
  267. package/dist/plugins/createConnection/schemas.d.ts +0 -21
  268. package/dist/plugins/createConnection/schemas.d.ts.map +0 -1
  269. package/dist/plugins/createConnection/schemas.js +0 -38
  270. package/dist/plugins/deleteClientCredentials/index.d.ts +0 -48
  271. package/dist/plugins/deleteClientCredentials/index.d.ts.map +0 -1
  272. package/dist/plugins/deleteClientCredentials/index.js +0 -21
  273. package/dist/plugins/deleteClientCredentials/schemas.d.ts +0 -12
  274. package/dist/plugins/deleteClientCredentials/schemas.d.ts.map +0 -1
  275. package/dist/plugins/deleteClientCredentials/schemas.js +0 -8
  276. package/dist/plugins/deprecated/authentications.d.ts +0 -763
  277. package/dist/plugins/deprecated/authentications.d.ts.map +0 -1
  278. package/dist/plugins/deprecated/authentications.js +0 -100
  279. package/dist/plugins/deprecated/inputFields.d.ts +0 -503
  280. package/dist/plugins/deprecated/inputFields.d.ts.map +0 -1
  281. package/dist/plugins/deprecated/inputFields.js +0 -81
  282. package/dist/plugins/eventEmission/builders.d.ts +0 -14
  283. package/dist/plugins/eventEmission/builders.d.ts.map +0 -1
  284. package/dist/plugins/eventEmission/builders.js +0 -117
  285. package/dist/plugins/eventEmission/event-emission-hook.d.ts +0 -10
  286. package/dist/plugins/eventEmission/event-emission-hook.d.ts.map +0 -1
  287. package/dist/plugins/eventEmission/event-emission-hook.js +0 -47
  288. package/dist/plugins/eventEmission/index.d.ts +0 -50
  289. package/dist/plugins/eventEmission/index.d.ts.map +0 -1
  290. package/dist/plugins/eventEmission/index.js +0 -398
  291. package/dist/plugins/eventEmission/method-metadata.d.ts +0 -16
  292. package/dist/plugins/eventEmission/method-metadata.d.ts.map +0 -1
  293. package/dist/plugins/eventEmission/method-metadata.js +0 -20
  294. package/dist/plugins/eventEmission/transport.d.ts +0 -27
  295. package/dist/plugins/eventEmission/transport.d.ts.map +0 -1
  296. package/dist/plugins/eventEmission/transport.js +0 -105
  297. package/dist/plugins/eventEmission/types.d.ts +0 -67
  298. package/dist/plugins/eventEmission/types.d.ts.map +0 -1
  299. package/dist/plugins/eventEmission/types.js +0 -1
  300. package/dist/plugins/eventEmission/utils.d.ts +0 -56
  301. package/dist/plugins/eventEmission/utils.d.ts.map +0 -1
  302. package/dist/plugins/eventEmission/utils.js +0 -142
  303. package/dist/plugins/fetch/index.d.ts +0 -72
  304. package/dist/plugins/fetch/index.d.ts.map +0 -1
  305. package/dist/plugins/fetch/index.js +0 -238
  306. package/dist/plugins/fetch/schemas.d.ts +0 -28
  307. package/dist/plugins/fetch/schemas.d.ts.map +0 -1
  308. package/dist/plugins/fetch/schemas.js +0 -52
  309. package/dist/plugins/findFirstConnection/index.d.ts +0 -115
  310. package/dist/plugins/findFirstConnection/index.d.ts.map +0 -1
  311. package/dist/plugins/findFirstConnection/index.js +0 -25
  312. package/dist/plugins/findFirstConnection/schemas.d.ts +0 -25
  313. package/dist/plugins/findFirstConnection/schemas.d.ts.map +0 -1
  314. package/dist/plugins/findFirstConnection/schemas.js +0 -9
  315. package/dist/plugins/findUniqueConnection/index.d.ts +0 -115
  316. package/dist/plugins/findUniqueConnection/index.d.ts.map +0 -1
  317. package/dist/plugins/findUniqueConnection/index.js +0 -28
  318. package/dist/plugins/findUniqueConnection/schemas.d.ts +0 -25
  319. package/dist/plugins/findUniqueConnection/schemas.d.ts.map +0 -1
  320. package/dist/plugins/findUniqueConnection/schemas.js +0 -9
  321. package/dist/plugins/getAction/index.d.ts +0 -215
  322. package/dist/plugins/getAction/index.d.ts.map +0 -1
  323. package/dist/plugins/getAction/index.js +0 -41
  324. package/dist/plugins/getAction/schemas.d.ts +0 -82
  325. package/dist/plugins/getAction/schemas.d.ts.map +0 -1
  326. package/dist/plugins/getAction/schemas.js +0 -22
  327. package/dist/plugins/getActionInputFieldsSchema/index.d.ts +0 -301
  328. package/dist/plugins/getActionInputFieldsSchema/index.d.ts.map +0 -1
  329. package/dist/plugins/getActionInputFieldsSchema/index.js +0 -57
  330. package/dist/plugins/getActionInputFieldsSchema/schemas.d.ts +0 -97
  331. package/dist/plugins/getActionInputFieldsSchema/schemas.d.ts.map +0 -1
  332. package/dist/plugins/getActionInputFieldsSchema/schemas.js +0 -49
  333. package/dist/plugins/getApp/index.d.ts +0 -146
  334. package/dist/plugins/getApp/index.d.ts.map +0 -1
  335. package/dist/plugins/getApp/index.js +0 -24
  336. package/dist/plugins/getApp/schemas.d.ts +0 -32
  337. package/dist/plugins/getApp/schemas.d.ts.map +0 -1
  338. package/dist/plugins/getApp/schemas.js +0 -18
  339. package/dist/plugins/getConnection/index.d.ts +0 -179
  340. package/dist/plugins/getConnection/index.d.ts.map +0 -1
  341. package/dist/plugins/getConnection/index.js +0 -33
  342. package/dist/plugins/getConnection/schemas.d.ts +0 -12
  343. package/dist/plugins/getConnection/schemas.d.ts.map +0 -1
  344. package/dist/plugins/getConnection/schemas.js +0 -14
  345. package/dist/plugins/getConnectionStartUrl/index.d.ts +0 -206
  346. package/dist/plugins/getConnectionStartUrl/index.d.ts.map +0 -1
  347. package/dist/plugins/getConnectionStartUrl/index.js +0 -39
  348. package/dist/plugins/getConnectionStartUrl/schemas.d.ts +0 -15
  349. package/dist/plugins/getConnectionStartUrl/schemas.d.ts.map +0 -1
  350. package/dist/plugins/getConnectionStartUrl/schemas.js +0 -23
  351. package/dist/plugins/getProfile/index.d.ts +0 -32
  352. package/dist/plugins/getProfile/index.d.ts.map +0 -1
  353. package/dist/plugins/getProfile/index.js +0 -28
  354. package/dist/plugins/getProfile/schemas.d.ts +0 -4
  355. package/dist/plugins/getProfile/schemas.d.ts.map +0 -1
  356. package/dist/plugins/getProfile/schemas.js +0 -5
  357. package/dist/plugins/listActionInputFieldChoices/index.d.ts +0 -372
  358. package/dist/plugins/listActionInputFieldChoices/index.d.ts.map +0 -1
  359. package/dist/plugins/listActionInputFieldChoices/index.js +0 -110
  360. package/dist/plugins/listActionInputFieldChoices/schemas.d.ts +0 -133
  361. package/dist/plugins/listActionInputFieldChoices/schemas.d.ts.map +0 -1
  362. package/dist/plugins/listActionInputFieldChoices/schemas.js +0 -75
  363. package/dist/plugins/listActionInputFields/index.d.ts +0 -330
  364. package/dist/plugins/listActionInputFields/index.d.ts.map +0 -1
  365. package/dist/plugins/listActionInputFields/index.js +0 -208
  366. package/dist/plugins/listActionInputFields/schemas.d.ts +0 -113
  367. package/dist/plugins/listActionInputFields/schemas.d.ts.map +0 -1
  368. package/dist/plugins/listActionInputFields/schemas.js +0 -56
  369. package/dist/plugins/listActions/index.d.ts +0 -219
  370. package/dist/plugins/listActions/index.d.ts.map +0 -1
  371. package/dist/plugins/listActions/index.js +0 -60
  372. package/dist/plugins/listActions/schemas.d.ts +0 -78
  373. package/dist/plugins/listActions/schemas.d.ts.map +0 -1
  374. package/dist/plugins/listActions/schemas.js +0 -33
  375. package/dist/plugins/listApps/index.d.ts +0 -127
  376. package/dist/plugins/listApps/index.d.ts.map +0 -1
  377. package/dist/plugins/listApps/index.js +0 -63
  378. package/dist/plugins/listApps/schemas.d.ts +0 -43
  379. package/dist/plugins/listApps/schemas.d.ts.map +0 -1
  380. package/dist/plugins/listApps/schemas.js +0 -54
  381. package/dist/plugins/listClientCredentials/index.d.ts +0 -36
  382. package/dist/plugins/listClientCredentials/index.d.ts.map +0 -1
  383. package/dist/plugins/listClientCredentials/index.js +0 -32
  384. package/dist/plugins/listClientCredentials/schemas.d.ts +0 -17
  385. package/dist/plugins/listClientCredentials/schemas.d.ts.map +0 -1
  386. package/dist/plugins/listClientCredentials/schemas.js +0 -23
  387. package/dist/plugins/listConnections/index.d.ts +0 -243
  388. package/dist/plugins/listConnections/index.d.ts.map +0 -1
  389. package/dist/plugins/listConnections/index.js +0 -97
  390. package/dist/plugins/listConnections/schemas.d.ts +0 -34
  391. package/dist/plugins/listConnections/schemas.d.ts.map +0 -1
  392. package/dist/plugins/listConnections/schemas.js +0 -74
  393. package/dist/plugins/manifest/index.d.ts +0 -97
  394. package/dist/plugins/manifest/index.d.ts.map +0 -1
  395. package/dist/plugins/manifest/index.js +0 -395
  396. package/dist/plugins/manifest/schemas.d.ts +0 -88
  397. package/dist/plugins/manifest/schemas.d.ts.map +0 -1
  398. package/dist/plugins/manifest/schemas.js +0 -61
  399. package/dist/plugins/registry/index.d.ts +0 -17
  400. package/dist/plugins/registry/index.d.ts.map +0 -1
  401. package/dist/plugins/registry/index.js +0 -11
  402. package/dist/plugins/request/index.d.ts +0 -70
  403. package/dist/plugins/request/index.d.ts.map +0 -1
  404. package/dist/plugins/request/index.js +0 -28
  405. package/dist/plugins/request/schemas.d.ts +0 -46
  406. package/dist/plugins/request/schemas.d.ts.map +0 -1
  407. package/dist/plugins/request/schemas.js +0 -42
  408. package/dist/plugins/runAction/index.d.ts +0 -313
  409. package/dist/plugins/runAction/index.d.ts.map +0 -1
  410. package/dist/plugins/runAction/index.js +0 -190
  411. package/dist/plugins/runAction/schemas.d.ts +0 -108
  412. package/dist/plugins/runAction/schemas.d.ts.map +0 -1
  413. package/dist/plugins/runAction/schemas.js +0 -53
  414. package/dist/plugins/tables/createTable/index.d.ts +0 -48
  415. package/dist/plugins/tables/createTable/index.d.ts.map +0 -1
  416. package/dist/plugins/tables/createTable/index.js +0 -20
  417. package/dist/plugins/tables/createTable/schemas.d.ts +0 -36
  418. package/dist/plugins/tables/createTable/schemas.d.ts.map +0 -1
  419. package/dist/plugins/tables/createTable/schemas.js +0 -16
  420. package/dist/plugins/tables/createTableFields/index.d.ts +0 -92
  421. package/dist/plugins/tables/createTableFields/index.d.ts.map +0 -1
  422. package/dist/plugins/tables/createTableFields/index.js +0 -29
  423. package/dist/plugins/tables/createTableFields/schemas.d.ts +0 -317
  424. package/dist/plugins/tables/createTableFields/schemas.d.ts.map +0 -1
  425. package/dist/plugins/tables/createTableFields/schemas.js +0 -62
  426. package/dist/plugins/tables/createTableRecords/index.d.ts +0 -114
  427. package/dist/plugins/tables/createTableRecords/index.d.ts.map +0 -1
  428. package/dist/plugins/tables/createTableRecords/index.js +0 -43
  429. package/dist/plugins/tables/createTableRecords/schemas.d.ts +0 -92
  430. package/dist/plugins/tables/createTableRecords/schemas.d.ts.map +0 -1
  431. package/dist/plugins/tables/createTableRecords/schemas.js +0 -55
  432. package/dist/plugins/tables/deleteTable/index.d.ts +0 -74
  433. package/dist/plugins/tables/deleteTable/index.d.ts.map +0 -1
  434. package/dist/plugins/tables/deleteTable/index.js +0 -23
  435. package/dist/plugins/tables/deleteTable/schemas.d.ts +0 -28
  436. package/dist/plugins/tables/deleteTable/schemas.d.ts.map +0 -1
  437. package/dist/plugins/tables/deleteTable/schemas.js +0 -21
  438. package/dist/plugins/tables/deleteTableFields/index.d.ts +0 -102
  439. package/dist/plugins/tables/deleteTableFields/index.d.ts.map +0 -1
  440. package/dist/plugins/tables/deleteTableFields/index.js +0 -30
  441. package/dist/plugins/tables/deleteTableFields/schemas.d.ts +0 -34
  442. package/dist/plugins/tables/deleteTableFields/schemas.d.ts.map +0 -1
  443. package/dist/plugins/tables/deleteTableFields/schemas.js +0 -29
  444. package/dist/plugins/tables/deleteTableRecords/index.d.ts +0 -123
  445. package/dist/plugins/tables/deleteTableRecords/index.d.ts.map +0 -1
  446. package/dist/plugins/tables/deleteTableRecords/index.js +0 -23
  447. package/dist/plugins/tables/deleteTableRecords/schemas.d.ts +0 -34
  448. package/dist/plugins/tables/deleteTableRecords/schemas.d.ts.map +0 -1
  449. package/dist/plugins/tables/deleteTableRecords/schemas.js +0 -30
  450. package/dist/plugins/tables/getTable/index.d.ts +0 -81
  451. package/dist/plugins/tables/getTable/index.d.ts.map +0 -1
  452. package/dist/plugins/tables/getTable/index.js +0 -24
  453. package/dist/plugins/tables/getTable/schemas.d.ts +0 -49
  454. package/dist/plugins/tables/getTable/schemas.d.ts.map +0 -1
  455. package/dist/plugins/tables/getTable/schemas.js +0 -27
  456. package/dist/plugins/tables/getTableRecord/index.d.ts +0 -131
  457. package/dist/plugins/tables/getTableRecord/index.d.ts.map +0 -1
  458. package/dist/plugins/tables/getTableRecord/index.js +0 -38
  459. package/dist/plugins/tables/getTableRecord/schemas.d.ts +0 -88
  460. package/dist/plugins/tables/getTableRecord/schemas.d.ts.map +0 -1
  461. package/dist/plugins/tables/getTableRecord/schemas.js +0 -56
  462. package/dist/plugins/tables/listTableFields/index.d.ts +0 -86
  463. package/dist/plugins/tables/listTableFields/index.d.ts.map +0 -1
  464. package/dist/plugins/tables/listTableFields/index.js +0 -41
  465. package/dist/plugins/tables/listTableFields/schemas.d.ts +0 -225
  466. package/dist/plugins/tables/listTableFields/schemas.d.ts.map +0 -1
  467. package/dist/plugins/tables/listTableFields/schemas.js +0 -93
  468. package/dist/plugins/tables/listTableRecords/index.d.ts +0 -136
  469. package/dist/plugins/tables/listTableRecords/index.d.ts.map +0 -1
  470. package/dist/plugins/tables/listTableRecords/index.js +0 -81
  471. package/dist/plugins/tables/listTableRecords/schemas.d.ts +0 -256
  472. package/dist/plugins/tables/listTableRecords/schemas.d.ts.map +0 -1
  473. package/dist/plugins/tables/listTableRecords/schemas.js +0 -95
  474. package/dist/plugins/tables/listTables/index.d.ts +0 -60
  475. package/dist/plugins/tables/listTables/index.d.ts.map +0 -1
  476. package/dist/plugins/tables/listTables/index.js +0 -67
  477. package/dist/plugins/tables/listTables/schemas.d.ts +0 -85
  478. package/dist/plugins/tables/listTables/schemas.d.ts.map +0 -1
  479. package/dist/plugins/tables/listTables/schemas.js +0 -72
  480. package/dist/plugins/tables/shared.d.ts +0 -10
  481. package/dist/plugins/tables/shared.d.ts.map +0 -1
  482. package/dist/plugins/tables/shared.js +0 -9
  483. package/dist/plugins/tables/updateTableRecords/index.d.ts +0 -116
  484. package/dist/plugins/tables/updateTableRecords/index.d.ts.map +0 -1
  485. package/dist/plugins/tables/updateTableRecords/index.js +0 -47
  486. package/dist/plugins/tables/updateTableRecords/schemas.d.ts +0 -97
  487. package/dist/plugins/tables/updateTableRecords/schemas.d.ts.map +0 -1
  488. package/dist/plugins/tables/updateTableRecords/schemas.js +0 -55
  489. package/dist/plugins/tables/utils.d.ts +0 -69
  490. package/dist/plugins/tables/utils.d.ts.map +0 -1
  491. package/dist/plugins/tables/utils.js +0 -270
  492. package/dist/plugins/triggers/ackTriggerInboxMessages/index.d.ts +0 -108
  493. package/dist/plugins/triggers/ackTriggerInboxMessages/index.d.ts.map +0 -1
  494. package/dist/plugins/triggers/ackTriggerInboxMessages/index.js +0 -36
  495. package/dist/plugins/triggers/ackTriggerInboxMessages/schemas.d.ts +0 -34
  496. package/dist/plugins/triggers/ackTriggerInboxMessages/schemas.d.ts.map +0 -1
  497. package/dist/plugins/triggers/ackTriggerInboxMessages/schemas.js +0 -17
  498. package/dist/plugins/triggers/createTriggerInbox/index.d.ts +0 -292
  499. package/dist/plugins/triggers/createTriggerInbox/index.d.ts.map +0 -1
  500. package/dist/plugins/triggers/createTriggerInbox/index.js +0 -68
  501. package/dist/plugins/triggers/createTriggerInbox/schemas.d.ts +0 -20
  502. package/dist/plugins/triggers/createTriggerInbox/schemas.d.ts.map +0 -1
  503. package/dist/plugins/triggers/createTriggerInbox/schemas.js +0 -21
  504. package/dist/plugins/triggers/deleteTriggerInbox/index.d.ts +0 -81
  505. package/dist/plugins/triggers/deleteTriggerInbox/index.d.ts.map +0 -1
  506. package/dist/plugins/triggers/deleteTriggerInbox/index.js +0 -29
  507. package/dist/plugins/triggers/deleteTriggerInbox/schemas.d.ts +0 -13
  508. package/dist/plugins/triggers/deleteTriggerInbox/schemas.d.ts.map +0 -1
  509. package/dist/plugins/triggers/deleteTriggerInbox/schemas.js +0 -9
  510. package/dist/plugins/triggers/drainTriggerInbox/index.d.ts +0 -277
  511. package/dist/plugins/triggers/drainTriggerInbox/index.d.ts.map +0 -1
  512. package/dist/plugins/triggers/drainTriggerInbox/index.js +0 -260
  513. package/dist/plugins/triggers/drainTriggerInbox/pipeline.d.ts +0 -56
  514. package/dist/plugins/triggers/drainTriggerInbox/pipeline.d.ts.map +0 -1
  515. package/dist/plugins/triggers/drainTriggerInbox/pipeline.js +0 -225
  516. package/dist/plugins/triggers/drainTriggerInbox/schemas.d.ts +0 -104
  517. package/dist/plugins/triggers/drainTriggerInbox/schemas.d.ts.map +0 -1
  518. package/dist/plugins/triggers/drainTriggerInbox/schemas.js +0 -102
  519. package/dist/plugins/triggers/ensureTriggerInbox/index.d.ts +0 -292
  520. package/dist/plugins/triggers/ensureTriggerInbox/index.d.ts.map +0 -1
  521. package/dist/plugins/triggers/ensureTriggerInbox/index.js +0 -65
  522. package/dist/plugins/triggers/ensureTriggerInbox/schemas.d.ts +0 -20
  523. package/dist/plugins/triggers/ensureTriggerInbox/schemas.d.ts.map +0 -1
  524. package/dist/plugins/triggers/ensureTriggerInbox/schemas.js +0 -21
  525. package/dist/plugins/triggers/getTriggerInbox/index.d.ts +0 -81
  526. package/dist/plugins/triggers/getTriggerInbox/index.d.ts.map +0 -1
  527. package/dist/plugins/triggers/getTriggerInbox/index.js +0 -28
  528. package/dist/plugins/triggers/getTriggerInbox/schemas.d.ts +0 -13
  529. package/dist/plugins/triggers/getTriggerInbox/schemas.d.ts.map +0 -1
  530. package/dist/plugins/triggers/getTriggerInbox/schemas.js +0 -9
  531. package/dist/plugins/triggers/getTriggerInputFieldsSchema/index.d.ts +0 -277
  532. package/dist/plugins/triggers/getTriggerInputFieldsSchema/index.d.ts.map +0 -1
  533. package/dist/plugins/triggers/getTriggerInputFieldsSchema/index.js +0 -23
  534. package/dist/plugins/triggers/getTriggerInputFieldsSchema/schemas.d.ts +0 -13
  535. package/dist/plugins/triggers/getTriggerInputFieldsSchema/schemas.d.ts.map +0 -1
  536. package/dist/plugins/triggers/getTriggerInputFieldsSchema/schemas.js +0 -10
  537. package/dist/plugins/triggers/leaseTriggerInboxMessages/index.d.ts +0 -89
  538. package/dist/plugins/triggers/leaseTriggerInboxMessages/index.d.ts.map +0 -1
  539. package/dist/plugins/triggers/leaseTriggerInboxMessages/index.js +0 -74
  540. package/dist/plugins/triggers/leaseTriggerInboxMessages/schemas.d.ts +0 -57
  541. package/dist/plugins/triggers/leaseTriggerInboxMessages/schemas.d.ts.map +0 -1
  542. package/dist/plugins/triggers/leaseTriggerInboxMessages/schemas.js +0 -25
  543. package/dist/plugins/triggers/listTriggerInboxMessages/index.d.ts +0 -82
  544. package/dist/plugins/triggers/listTriggerInboxMessages/index.d.ts.map +0 -1
  545. package/dist/plugins/triggers/listTriggerInboxMessages/index.js +0 -40
  546. package/dist/plugins/triggers/listTriggerInboxMessages/schemas.d.ts +0 -37
  547. package/dist/plugins/triggers/listTriggerInboxMessages/schemas.d.ts.map +0 -1
  548. package/dist/plugins/triggers/listTriggerInboxMessages/schemas.js +0 -27
  549. package/dist/plugins/triggers/listTriggerInboxes/index.d.ts +0 -56
  550. package/dist/plugins/triggers/listTriggerInboxes/index.d.ts.map +0 -1
  551. package/dist/plugins/triggers/listTriggerInboxes/index.js +0 -42
  552. package/dist/plugins/triggers/listTriggerInboxes/schemas.d.ts +0 -58
  553. package/dist/plugins/triggers/listTriggerInboxes/schemas.d.ts.map +0 -1
  554. package/dist/plugins/triggers/listTriggerInboxes/schemas.js +0 -35
  555. package/dist/plugins/triggers/listTriggerInputFieldChoices/index.d.ts +0 -360
  556. package/dist/plugins/triggers/listTriggerInputFieldChoices/index.d.ts.map +0 -1
  557. package/dist/plugins/triggers/listTriggerInputFieldChoices/index.js +0 -32
  558. package/dist/plugins/triggers/listTriggerInputFieldChoices/schemas.d.ts +0 -20
  559. package/dist/plugins/triggers/listTriggerInputFieldChoices/schemas.d.ts.map +0 -1
  560. package/dist/plugins/triggers/listTriggerInputFieldChoices/schemas.js +0 -28
  561. package/dist/plugins/triggers/listTriggerInputFields/index.d.ts +0 -330
  562. package/dist/plugins/triggers/listTriggerInputFields/index.d.ts.map +0 -1
  563. package/dist/plugins/triggers/listTriggerInputFields/index.js +0 -34
  564. package/dist/plugins/triggers/listTriggerInputFields/schemas.d.ts +0 -16
  565. package/dist/plugins/triggers/listTriggerInputFields/schemas.d.ts.map +0 -1
  566. package/dist/plugins/triggers/listTriggerInputFields/schemas.js +0 -21
  567. package/dist/plugins/triggers/listTriggers/index.d.ts +0 -207
  568. package/dist/plugins/triggers/listTriggers/index.d.ts.map +0 -1
  569. package/dist/plugins/triggers/listTriggers/index.js +0 -26
  570. package/dist/plugins/triggers/listTriggers/schemas.d.ts +0 -11
  571. package/dist/plugins/triggers/listTriggers/schemas.d.ts.map +0 -1
  572. package/dist/plugins/triggers/listTriggers/schemas.js +0 -18
  573. package/dist/plugins/triggers/pauseTriggerInbox/index.d.ts +0 -81
  574. package/dist/plugins/triggers/pauseTriggerInbox/index.d.ts.map +0 -1
  575. package/dist/plugins/triggers/pauseTriggerInbox/index.js +0 -28
  576. package/dist/plugins/triggers/pauseTriggerInbox/schemas.d.ts +0 -13
  577. package/dist/plugins/triggers/pauseTriggerInbox/schemas.d.ts.map +0 -1
  578. package/dist/plugins/triggers/pauseTriggerInbox/schemas.js +0 -9
  579. package/dist/plugins/triggers/releaseTriggerInboxMessages/index.d.ts +0 -108
  580. package/dist/plugins/triggers/releaseTriggerInboxMessages/index.d.ts.map +0 -1
  581. package/dist/plugins/triggers/releaseTriggerInboxMessages/index.js +0 -38
  582. package/dist/plugins/triggers/releaseTriggerInboxMessages/schemas.d.ts +0 -34
  583. package/dist/plugins/triggers/releaseTriggerInboxMessages/schemas.d.ts.map +0 -1
  584. package/dist/plugins/triggers/releaseTriggerInboxMessages/schemas.js +0 -17
  585. package/dist/plugins/triggers/resumeTriggerInbox/index.d.ts +0 -81
  586. package/dist/plugins/triggers/resumeTriggerInbox/index.d.ts.map +0 -1
  587. package/dist/plugins/triggers/resumeTriggerInbox/index.js +0 -28
  588. package/dist/plugins/triggers/resumeTriggerInbox/schemas.d.ts +0 -13
  589. package/dist/plugins/triggers/resumeTriggerInbox/schemas.d.ts.map +0 -1
  590. package/dist/plugins/triggers/resumeTriggerInbox/schemas.js +0 -9
  591. package/dist/plugins/triggers/shared.d.ts +0 -17
  592. package/dist/plugins/triggers/shared.d.ts.map +0 -1
  593. package/dist/plugins/triggers/shared.js +0 -16
  594. package/dist/plugins/triggers/updateTriggerInbox/index.d.ts +0 -82
  595. package/dist/plugins/triggers/updateTriggerInbox/index.d.ts.map +0 -1
  596. package/dist/plugins/triggers/updateTriggerInbox/index.js +0 -32
  597. package/dist/plugins/triggers/updateTriggerInbox/schemas.d.ts +0 -14
  598. package/dist/plugins/triggers/updateTriggerInbox/schemas.d.ts.map +0 -1
  599. package/dist/plugins/triggers/updateTriggerInbox/schemas.js +0 -15
  600. package/dist/plugins/triggers/utils.d.ts +0 -23
  601. package/dist/plugins/triggers/utils.d.ts.map +0 -1
  602. package/dist/plugins/triggers/utils.js +0 -45
  603. package/dist/plugins/triggers/watchTriggerInbox/index.d.ts +0 -221
  604. package/dist/plugins/triggers/watchTriggerInbox/index.d.ts.map +0 -1
  605. package/dist/plugins/triggers/watchTriggerInbox/index.js +0 -402
  606. package/dist/plugins/triggers/watchTriggerInbox/sse.d.ts +0 -32
  607. package/dist/plugins/triggers/watchTriggerInbox/sse.d.ts.map +0 -1
  608. package/dist/plugins/triggers/watchTriggerInbox/sse.js +0 -36
  609. package/dist/plugins/waitForNewConnection/index.d.ts +0 -209
  610. package/dist/plugins/waitForNewConnection/index.d.ts.map +0 -1
  611. package/dist/plugins/waitForNewConnection/index.js +0 -75
  612. package/dist/plugins/waitForNewConnection/schemas.d.ts +0 -17
  613. package/dist/plugins/waitForNewConnection/schemas.d.ts.map +0 -1
  614. package/dist/plugins/waitForNewConnection/schemas.js +0 -39
  615. package/dist/resolvers/actionKey.d.ts +0 -16
  616. package/dist/resolvers/actionKey.d.ts.map +0 -1
  617. package/dist/resolvers/actionKey.js +0 -20
  618. package/dist/resolvers/actionType.d.ts +0 -14
  619. package/dist/resolvers/actionType.d.ts.map +0 -1
  620. package/dist/resolvers/actionType.js +0 -24
  621. package/dist/resolvers/appKey.d.ts +0 -13
  622. package/dist/resolvers/appKey.d.ts.map +0 -1
  623. package/dist/resolvers/appKey.js +0 -50
  624. package/dist/resolvers/clientCredentialsName.d.ts +0 -3
  625. package/dist/resolvers/clientCredentialsName.d.ts.map +0 -1
  626. package/dist/resolvers/clientCredentialsName.js +0 -5
  627. package/dist/resolvers/clientId.d.ts +0 -5
  628. package/dist/resolvers/clientId.d.ts.map +0 -1
  629. package/dist/resolvers/clientId.js +0 -14
  630. package/dist/resolvers/connectionId.d.ts +0 -12
  631. package/dist/resolvers/connectionId.d.ts.map +0 -1
  632. package/dist/resolvers/connectionId.js +0 -52
  633. package/dist/resolvers/durableRunId.d.ts +0 -5
  634. package/dist/resolvers/durableRunId.d.ts.map +0 -1
  635. package/dist/resolvers/durableRunId.js +0 -15
  636. package/dist/resolvers/index.d.ts +0 -27
  637. package/dist/resolvers/index.d.ts.map +0 -1
  638. package/dist/resolvers/index.js +0 -28
  639. package/dist/resolvers/inputFieldKey.d.ts +0 -12
  640. package/dist/resolvers/inputFieldKey.d.ts.map +0 -1
  641. package/dist/resolvers/inputFieldKey.js +0 -51
  642. package/dist/resolvers/inputs.d.ts +0 -17
  643. package/dist/resolvers/inputs.d.ts.map +0 -1
  644. package/dist/resolvers/inputs.js +0 -50
  645. package/dist/resolvers/tableFieldIds.d.ts +0 -7
  646. package/dist/resolvers/tableFieldIds.d.ts.map +0 -1
  647. package/dist/resolvers/tableFieldIds.js +0 -20
  648. package/dist/resolvers/tableFields.d.ts +0 -3
  649. package/dist/resolvers/tableFields.d.ts.map +0 -1
  650. package/dist/resolvers/tableFields.js +0 -31
  651. package/dist/resolvers/tableFilters.d.ts +0 -6
  652. package/dist/resolvers/tableFilters.d.ts.map +0 -1
  653. package/dist/resolvers/tableFilters.js +0 -74
  654. package/dist/resolvers/tableId.d.ts +0 -5
  655. package/dist/resolvers/tableId.d.ts.map +0 -1
  656. package/dist/resolvers/tableId.js +0 -30
  657. package/dist/resolvers/tableName.d.ts +0 -3
  658. package/dist/resolvers/tableName.d.ts.map +0 -1
  659. package/dist/resolvers/tableName.js +0 -5
  660. package/dist/resolvers/tableRecordId.d.ts +0 -10
  661. package/dist/resolvers/tableRecordId.d.ts.map +0 -1
  662. package/dist/resolvers/tableRecordId.js +0 -49
  663. package/dist/resolvers/tableRecords.d.ts +0 -9
  664. package/dist/resolvers/tableRecords.d.ts.map +0 -1
  665. package/dist/resolvers/tableRecords.js +0 -77
  666. package/dist/resolvers/tableSort.d.ts +0 -6
  667. package/dist/resolvers/tableSort.d.ts.map +0 -1
  668. package/dist/resolvers/tableSort.js +0 -43
  669. package/dist/resolvers/triggerInbox.d.ts +0 -5
  670. package/dist/resolvers/triggerInbox.d.ts.map +0 -1
  671. package/dist/resolvers/triggerInbox.js +0 -19
  672. package/dist/resolvers/triggerMessages.d.ts +0 -7
  673. package/dist/resolvers/triggerMessages.d.ts.map +0 -1
  674. package/dist/resolvers/triggerMessages.js +0 -21
  675. package/dist/resolvers/workflowId.d.ts +0 -5
  676. package/dist/resolvers/workflowId.d.ts.map +0 -1
  677. package/dist/resolvers/workflowId.js +0 -15
  678. package/dist/resolvers/workflowRunId.d.ts +0 -7
  679. package/dist/resolvers/workflowRunId.d.ts.map +0 -1
  680. package/dist/resolvers/workflowRunId.js +0 -20
  681. package/dist/resolvers/workflowVersionId.d.ts +0 -7
  682. package/dist/resolvers/workflowVersionId.d.ts.map +0 -1
  683. package/dist/resolvers/workflowVersionId.js +0 -20
  684. package/dist/schemas/Action.d.ts +0 -24
  685. package/dist/schemas/Action.d.ts.map +0 -1
  686. package/dist/schemas/Action.js +0 -16
  687. package/dist/schemas/App.d.ts +0 -56
  688. package/dist/schemas/App.d.ts.map +0 -1
  689. package/dist/schemas/App.js +0 -5
  690. package/dist/schemas/ClientCredentials.d.ts +0 -19
  691. package/dist/schemas/ClientCredentials.d.ts.map +0 -1
  692. package/dist/schemas/ClientCredentials.js +0 -6
  693. package/dist/schemas/Connection.d.ts +0 -32
  694. package/dist/schemas/Connection.d.ts.map +0 -1
  695. package/dist/schemas/Connection.js +0 -5
  696. package/dist/schemas/Field.d.ts +0 -61
  697. package/dist/schemas/Field.d.ts.map +0 -1
  698. package/dist/schemas/Field.js +0 -49
  699. package/dist/schemas/Run.d.ts +0 -3
  700. package/dist/schemas/Run.d.ts.map +0 -1
  701. package/dist/schemas/Run.js +0 -5
  702. package/dist/schemas/TriggerInbox.d.ts +0 -59
  703. package/dist/schemas/TriggerInbox.d.ts.map +0 -1
  704. package/dist/schemas/TriggerInbox.js +0 -49
  705. package/dist/schemas/TriggerMessage.d.ts +0 -48
  706. package/dist/schemas/TriggerMessage.d.ts.map +0 -1
  707. package/dist/schemas/TriggerMessage.js +0 -21
  708. package/dist/schemas/UserProfile.d.ts +0 -12
  709. package/dist/schemas/UserProfile.d.ts.map +0 -1
  710. package/dist/schemas/UserProfile.js +0 -13
  711. package/dist/sdk-version.d.ts +0 -28
  712. package/dist/sdk-version.d.ts.map +0 -1
  713. package/dist/sdk-version.js +0 -29
  714. package/dist/sdk.d.ts +0 -6065
  715. package/dist/sdk.d.ts.map +0 -1
  716. package/dist/sdk.js +0 -173
  717. package/dist/services/implementations.d.ts +0 -63
  718. package/dist/services/implementations.d.ts.map +0 -1
  719. package/dist/services/implementations.js +0 -79
  720. package/dist/types/connections.d.ts +0 -19
  721. package/dist/types/connections.d.ts.map +0 -1
  722. package/dist/types/connections.js +0 -20
  723. package/dist/types/credentials.d.ts +0 -186
  724. package/dist/types/credentials.d.ts.map +0 -1
  725. package/dist/types/credentials.js +0 -123
  726. package/dist/types/domain.d.ts +0 -52
  727. package/dist/types/domain.d.ts.map +0 -1
  728. package/dist/types/domain.js +0 -1
  729. package/dist/types/errors.d.ts +0 -254
  730. package/dist/types/errors.d.ts.map +0 -1
  731. package/dist/types/errors.js +0 -336
  732. package/dist/types/events.d.ts +0 -38
  733. package/dist/types/events.d.ts.map +0 -1
  734. package/dist/types/events.js +0 -7
  735. package/dist/types/functions.d.ts +0 -2
  736. package/dist/types/functions.d.ts.map +0 -1
  737. package/dist/types/functions.js +0 -1
  738. package/dist/types/properties.d.ts +0 -83
  739. package/dist/types/properties.d.ts.map +0 -1
  740. package/dist/types/properties.js +0 -120
  741. package/dist/types/sdk.d.ts +0 -97
  742. package/dist/types/sdk.d.ts.map +0 -1
  743. package/dist/types/sdk.js +0 -114
  744. package/dist/types/signals.d.ts +0 -20
  745. package/dist/types/signals.d.ts.map +0 -1
  746. package/dist/types/signals.js +0 -21
  747. package/dist/types/telemetry-events.d.ts +0 -114
  748. package/dist/types/telemetry-events.d.ts.map +0 -1
  749. package/dist/types/telemetry-events.js +0 -10
  750. package/dist/utils/abort-utils.d.ts +0 -77
  751. package/dist/utils/abort-utils.d.ts.map +0 -1
  752. package/dist/utils/abort-utils.js +0 -122
  753. package/dist/utils/agent.d.ts +0 -44
  754. package/dist/utils/agent.d.ts.map +0 -1
  755. package/dist/utils/agent.js +0 -76
  756. package/dist/utils/array-utils.d.ts +0 -31
  757. package/dist/utils/array-utils.d.ts.map +0 -1
  758. package/dist/utils/array-utils.js +0 -36
  759. package/dist/utils/batch-utils.d.ts +0 -72
  760. package/dist/utils/batch-utils.d.ts.map +0 -1
  761. package/dist/utils/batch-utils.js +0 -161
  762. package/dist/utils/caller-context.d.ts +0 -21
  763. package/dist/utils/caller-context.d.ts.map +0 -1
  764. package/dist/utils/caller-context.js +0 -35
  765. package/dist/utils/domain-utils.d.ts +0 -96
  766. package/dist/utils/domain-utils.d.ts.map +0 -1
  767. package/dist/utils/domain-utils.js +0 -248
  768. package/dist/utils/file-utils.d.ts +0 -4
  769. package/dist/utils/file-utils.d.ts.map +0 -1
  770. package/dist/utils/file-utils.js +0 -74
  771. package/dist/utils/id-utils.d.ts +0 -15
  772. package/dist/utils/id-utils.d.ts.map +0 -1
  773. package/dist/utils/id-utils.js +0 -24
  774. package/dist/utils/logging.d.ts +0 -2
  775. package/dist/utils/logging.d.ts.map +0 -1
  776. package/dist/utils/logging.js +0 -2
  777. package/dist/utils/open-approval.d.ts +0 -2
  778. package/dist/utils/open-approval.d.ts.map +0 -1
  779. package/dist/utils/open-approval.js +0 -13
  780. package/dist/utils/open-url.d.ts +0 -3
  781. package/dist/utils/open-url.d.ts.map +0 -1
  782. package/dist/utils/open-url.js +0 -79
  783. package/dist/utils/pagination.d.ts +0 -38
  784. package/dist/utils/pagination.d.ts.map +0 -1
  785. package/dist/utils/pagination.js +0 -53
  786. package/dist/utils/retry-utils.d.ts +0 -70
  787. package/dist/utils/retry-utils.d.ts.map +0 -1
  788. package/dist/utils/retry-utils.js +0 -97
  789. package/dist/utils/should-open-browser.d.ts +0 -24
  790. package/dist/utils/should-open-browser.d.ts.map +0 -1
  791. package/dist/utils/should-open-browser.js +0 -55
  792. package/dist/utils/telemetry.d.ts +0 -11
  793. package/dist/utils/telemetry.d.ts.map +0 -1
  794. package/dist/utils/telemetry.js +0 -19
  795. package/dist/utils/type-guard-utils.d.ts +0 -7
  796. package/dist/utils/type-guard-utils.d.ts.map +0 -1
  797. package/dist/utils/type-guard-utils.js +0 -11
  798. package/dist/utils/url-utils.d.ts +0 -25
  799. package/dist/utils/url-utils.d.ts.map +0 -1
  800. package/dist/utils/url-utils.js +0 -79
package/dist/index.cjs CHANGED
@@ -52,6 +52,7 @@ function canonicalInputSchema(schema) {
52
52
  function buildRegistry({
53
53
  sdk,
54
54
  meta,
55
+ formatters,
55
56
  packageFilter
56
57
  }) {
57
58
  const definitionsByKey = /* @__PURE__ */ new Map();
@@ -92,7 +93,7 @@ function buildRegistry({
92
93
  (c) => typeof c === "string" ? c : c.key
93
94
  ),
94
95
  resolvers: m.resolvers,
95
- formatter: m.formatter,
96
+ formatter: formatters?.[key],
96
97
  experimental: m.experimental,
97
98
  packages: m.packages,
98
99
  confirm: m.confirm ?? (m.type === "delete" ? "delete" : void 0),
@@ -518,8 +519,8 @@ function normalizeError(error, adaptError) {
518
519
  );
519
520
  }
520
521
  function createFunction(coreFn, options) {
521
- const { sdk, schema } = options;
522
- const functionName = coreFn.name;
522
+ const { sdk, schema, name } = options;
523
+ const functionName = name || coreFn.name;
523
524
  const namedFunctions = {
524
525
  [functionName]: async function(callOptions) {
525
526
  return runInMethodScope(async () => {
@@ -694,9 +695,6 @@ function createPaginatedFunction(coreFn, options) {
694
695
  };
695
696
  return namedFunctions[functionName];
696
697
  }
697
- function definePlugin(fn) {
698
- return fn;
699
- }
700
698
  function createPluginMethod(sdk, config) {
701
699
  const { name, inputSchema, handler, ...metaFields } = config;
702
700
  const namedHandlers = {
@@ -765,8 +763,7 @@ function splitPluginContribution(result) {
765
763
  }
766
764
  var RESERVED_ROOT_KEYS = /* @__PURE__ */ new Set([
767
765
  "context",
768
- "getRegistry",
769
- "addPlugin"
766
+ "getRegistry"
770
767
  ]);
771
768
  function hasOwn(obj, key) {
772
769
  return Object.prototype.hasOwnProperty.call(obj, key);
@@ -780,15 +777,28 @@ function setOwn(target, key, value) {
780
777
  });
781
778
  }
782
779
  function checkCollisions(target, source, kind, callerLabel, override) {
780
+ if (kind === "root key") {
781
+ checkRootKeyCollisions(target, Object.keys(source), override, callerLabel);
782
+ return;
783
+ }
783
784
  for (const key of Object.keys(source)) {
784
- if (kind === "root key" && RESERVED_ROOT_KEYS.has(key)) {
785
+ if (!override && hasOwn(target, key)) {
786
+ throw new Error(
787
+ `${callerLabel}: duplicate ${kind} "${key}". If the override is intentional, pass { override: true } in the options.`
788
+ );
789
+ }
790
+ }
791
+ }
792
+ function checkRootKeyCollisions(target, keys, override, callerLabel) {
793
+ for (const key of keys) {
794
+ if (RESERVED_ROOT_KEYS.has(key)) {
785
795
  throw new Error(
786
796
  `${callerLabel}: plugin attempted to register reserved root key "${key}". The SDK uses this key for its own accessor; rename the plugin's method.`
787
797
  );
788
798
  }
789
799
  if (!override && hasOwn(target, key)) {
790
800
  throw new Error(
791
- `${callerLabel}: duplicate ${kind} "${key}". If the override is intentional, pass { override: true } in the options.`
801
+ `${callerLabel}: duplicate root key "${key}". If the override is intentional, pass { override: true } in the options.`
792
802
  );
793
803
  }
794
804
  }
@@ -839,7 +849,7 @@ function mergeContribution(propertiesTarget, contextTarget, contribution, option
839
849
  function applyPluginContribution(acc, contribution, options) {
840
850
  mergeContribution(acc.view, acc.context, contribution, options);
841
851
  }
842
- function wrapAsSdk(properties, context, opts) {
852
+ function wrapAsSdk(properties, context) {
843
853
  const sdk = {
844
854
  ...properties,
845
855
  context,
@@ -851,9 +861,6 @@ function wrapAsSdk(properties, context, opts) {
851
861
  });
852
862
  }
853
863
  };
854
- if (opts?.addPlugin !== void 0) {
855
- sdk.addPlugin = opts.addPlugin;
856
- }
857
864
  return sdk;
858
865
  }
859
866
  function wrapAccumulatorAsSdk(acc) {
@@ -872,126 +879,92 @@ function applyPluginToSdk(sdk, plugin, options) {
872
879
  callerLabel: "addPlugin",
873
880
  override: options.override === true
874
881
  });
882
+ return contribution;
875
883
  }
876
- function buildStackAccumulator(head, callerLabel) {
877
- const ordered = [];
884
+ function resolveStack(head) {
885
+ const entries = [];
878
886
  let node = head;
879
887
  while (node) {
880
- ordered.unshift(node);
888
+ entries.unshift({ apply: node.entry, override: node.override });
881
889
  node = node.prev;
882
890
  }
883
- const acc = createPluginAccumulator();
884
- for (const { plugin, override } of ordered) {
885
- const contribution = splitPluginContribution(
886
- plugin(acc.view)
887
- );
888
- applyPluginContribution(acc, contribution, { callerLabel, override });
889
- }
890
- return acc;
891
- }
892
- function addPlugin(sdk, plugin, options) {
893
- applyPluginToSdk(
894
- sdk,
895
- plugin,
896
- options ?? {}
897
- );
891
+ return entries;
892
+ }
893
+ function composeStackHooks(hooks) {
894
+ let composed = {};
895
+ for (const h of hooks) composed = buildHooks(composed, h);
896
+ return composed;
897
+ }
898
+ function collapseStackEntries(entries, callerLabel) {
899
+ return (outerSdk) => {
900
+ const { context: outerContext, ...outerProperties } = outerSdk ?? {};
901
+ const viewAcc = createPluginAccumulator(outerProperties, outerContext);
902
+ const contribsAcc = createPluginAccumulator();
903
+ const hooks = [];
904
+ for (const { apply, override } of entries) {
905
+ const contribution = splitPluginContribution(
906
+ apply(viewAcc.view)
907
+ );
908
+ const hookless = { ...contribution, hooks: {} };
909
+ applyPluginContribution(viewAcc, hookless, { callerLabel, override });
910
+ applyPluginContribution(contribsAcc, hookless, { callerLabel, override });
911
+ hooks.push(contribution.hooks);
912
+ }
913
+ const stackHooks = composeStackHooks(hooks);
914
+ viewAcc.context.hooks = buildHooks(viewAcc.context.hooks, stackHooks);
915
+ contribsAcc.context.hooks = stackHooks;
916
+ const { context: _ignored, ...contributedRoot } = contribsAcc.view;
917
+ return {
918
+ ...contributedRoot,
919
+ context: contribsAcc.context
920
+ };
921
+ };
898
922
  }
899
- function buildSdk(properties, context) {
900
- const addPlugin2 = (plugin, options) => {
901
- logDeprecation(
902
- "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."
903
- );
923
+ function buildStackAccumulator(head, callerLabel) {
924
+ const entries = resolveStack(head);
925
+ const acc = createPluginAccumulator();
926
+ const hooks = [];
927
+ for (const { apply, override } of entries) {
904
928
  const contribution = splitPluginContribution(
905
- plugin({ ...properties, context })
929
+ apply(acc.view)
906
930
  );
907
- const mergedProperties = { ...properties };
908
- const mergedContext = {
909
- ...context,
910
- meta: { ...context.meta },
911
- hooks: { ...context.hooks }
912
- };
913
- mergeContribution(mergedProperties, mergedContext, contribution, {
914
- callerLabel: "addPlugin",
915
- override: options?.override === true
916
- });
917
- return buildSdk(
918
- mergedProperties,
919
- mergedContext
931
+ applyPluginContribution(
932
+ acc,
933
+ { ...contribution, hooks: {} },
934
+ { callerLabel, override }
920
935
  );
921
- };
922
- return wrapAsSdk(properties, context, { addPlugin: addPlugin2 });
923
- }
924
- function withDeprecatedAddPlugin(sdk) {
925
- const initialProperties = {};
926
- for (const key of Object.keys(sdk)) {
927
- if (key === "context" || key === "getRegistry" || key === "addPlugin") {
928
- continue;
929
- }
930
- initialProperties[key] = sdk[key];
936
+ hooks.push(contribution.hooks);
931
937
  }
932
- const initialContext = sdk.context;
933
- return buildSdk(
934
- initialProperties,
935
- initialContext
936
- );
938
+ acc.context.hooks = composeStackHooks(hooks);
939
+ return acc;
937
940
  }
938
941
  function composePlugins(...plugins) {
939
942
  logDeprecation(
940
- "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."
941
- );
942
- let stack = buildPluginStack(
943
- null,
944
- "composePlugins"
943
+ "composePlugins(...) is deprecated. Use createPluginStack().use(a).use(b).use(c).toPlugin({ name }) instead. The stack carries the same collision-detection and hook-composition behavior and supports per-step { override: true } for intentional duplicates."
945
944
  );
945
+ let head = null;
946
946
  for (const plugin of plugins) {
947
- stack = stack.use(plugin);
947
+ head = { entry: plugin, override: false, prev: head };
948
948
  }
949
- return stack.toPlugin();
949
+ const entries = resolveStack(head);
950
+ return collapseStackEntries(entries, "composePlugins");
950
951
  }
951
952
  function createPluginStack() {
952
953
  return buildPluginStack(null, "createPluginStack");
953
954
  }
954
955
  function buildPluginStack(head, callerLabel) {
955
- return {
956
+ const stack = {
956
957
  use(plugin, options) {
957
958
  const next = {
958
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
959
- plugin,
959
+ entry: plugin,
960
960
  override: options?.override === true,
961
961
  prev: head
962
962
  };
963
963
  return buildPluginStack(next, callerLabel);
964
964
  },
965
965
  toPlugin() {
966
- const ordered = [];
967
- let node = head;
968
- while (node) {
969
- ordered.unshift(node);
970
- node = node.prev;
971
- }
972
- return (outerSdk) => {
973
- const { context: outerContext, ...outerProperties } = outerSdk ?? {};
974
- const viewAcc = createPluginAccumulator(outerProperties, outerContext);
975
- const contribsAcc = createPluginAccumulator();
976
- for (const { plugin: subPlugin, override } of ordered) {
977
- const contribution = splitPluginContribution(
978
- subPlugin(viewAcc.view)
979
- );
980
- applyPluginContribution(viewAcc, contribution, {
981
- callerLabel,
982
- override
983
- });
984
- applyPluginContribution(contribsAcc, contribution, {
985
- callerLabel,
986
- override
987
- });
988
- }
989
- const { context: _ignored, ...contributedRoot } = contribsAcc.view;
990
- return {
991
- ...contributedRoot,
992
- context: contribsAcc.context
993
- };
994
- };
966
+ const entries = resolveStack(head);
967
+ return collapseStackEntries(entries, callerLabel);
995
968
  },
996
969
  toSdk() {
997
970
  return wrapAccumulatorAsSdk(
@@ -999,419 +972,1304 @@ function buildPluginStack(head, callerLabel) {
999
972
  );
1000
973
  }
1001
974
  };
975
+ return stack;
976
+ }
977
+ function parseId(id) {
978
+ const at = id.lastIndexOf("/");
979
+ return at === -1 ? { name: id, namespace: void 0 } : { name: id.slice(at + 1), namespace: id.slice(0, at) };
980
+ }
981
+ function makeId(name, namespace, kind = "leaf") {
982
+ validateName(name, kind);
983
+ if (namespace !== void 0) validateNamespace(namespace);
984
+ return namespace ? `${namespace}/${name}` : name;
985
+ }
986
+ var NAME_RE = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
987
+ var SEGMENT_RE = /^@?[A-Za-z0-9._-]+$/;
988
+ function validateName(name, kind) {
989
+ if (name === "") throw new Error("Plugin name must not be empty.");
990
+ if (kind === "leaf") {
991
+ if (!NAME_RE.test(name)) {
992
+ throw new Error(
993
+ `Plugin name "${name}" must be a valid JS identifier (it is the binding name).`
994
+ );
995
+ }
996
+ } else if (!SEGMENT_RE.test(name)) {
997
+ throw new Error(
998
+ `Plugin name "${name}" must be package-like (letters, digits, ".", "_", "-", optional leading "@") with no "/".`
999
+ );
1000
+ }
1002
1001
  }
1003
- function createCorePlugin(options) {
1004
- return () => ({
1005
- context: {
1006
- core: options
1002
+ function validateNamespace(namespace) {
1003
+ if (namespace === "") throw new Error("Plugin namespace must not be empty.");
1004
+ for (const segment of namespace.split("/")) {
1005
+ if (!SEGMENT_RE.test(segment)) {
1006
+ throw new Error(
1007
+ `Plugin namespace "${namespace}" is invalid: each "/"-separated segment must be package-like (letters, digits, ".", "_", "-", optional leading "@").`
1008
+ );
1007
1009
  }
1008
- });
1010
+ }
1009
1011
  }
1010
- function withPositional(schema) {
1011
- Object.assign(schema._zod.def, {
1012
- positionalMeta: { positional: true }
1013
- });
1014
- return schema;
1012
+ var LEAF_META_KEYS = [
1013
+ "description",
1014
+ "categories",
1015
+ "type",
1016
+ "itemType",
1017
+ "returnType",
1018
+ "outputSchema",
1019
+ "inputParameters",
1020
+ "packages",
1021
+ "experimental",
1022
+ "confirm",
1023
+ "deprecation",
1024
+ "aliases",
1025
+ "supportsJsonOutput"
1026
+ ];
1027
+ function normalizeImports(deps) {
1028
+ if (!deps) return { plugins: [], bindings: [] };
1029
+ const seen = /* @__PURE__ */ new Map();
1030
+ const bindings = [];
1031
+ const add = (binding, id) => {
1032
+ const priorId = seen.get(binding);
1033
+ if (priorId !== void 0 && priorId !== id) {
1034
+ throw new Error(
1035
+ `Import binding "${binding}" is declared twice. Two different plugins ("${priorId}" and "${id}") bind the same name; wrap one in selectExports to rename it.`
1036
+ );
1037
+ }
1038
+ if (priorId === void 0) {
1039
+ seen.set(binding, id);
1040
+ bindings.push({ binding, id });
1041
+ }
1042
+ };
1043
+ for (const plugin of deps) {
1044
+ if (plugin.pluginType === "aggregate") {
1045
+ for (const [binding, child] of Object.entries(plugin.exports)) {
1046
+ add(binding, child.id);
1047
+ }
1048
+ } else {
1049
+ add(plugin.name, plugin.id);
1050
+ }
1051
+ }
1052
+ return { plugins: deps, bindings };
1015
1053
  }
1016
- function schemaHasPositionalMeta(schema) {
1017
- return "positionalMeta" in schema._zod.def;
1054
+ function collectLeafMeta(config) {
1055
+ let meta;
1056
+ for (const key of LEAF_META_KEYS) {
1057
+ if (config[key] !== void 0) (meta ?? (meta = {}))[key] = config[key];
1058
+ }
1059
+ return meta;
1018
1060
  }
1019
- function isPositional(schema) {
1020
- if (schemaHasPositionalMeta(schema) && schema._zod.def.positionalMeta?.positional) {
1021
- return true;
1061
+ function defineMethod(config) {
1062
+ const deps = normalizeImports(config.imports);
1063
+ return {
1064
+ pluginType: "method",
1065
+ name: config.name,
1066
+ namespace: config.namespace,
1067
+ id: makeId(config.name, config.namespace),
1068
+ imports: deps.plugins,
1069
+ importBindings: deps.bindings,
1070
+ inputSchema: config.inputSchema,
1071
+ meta: collectLeafMeta(config),
1072
+ resolvers: config.resolvers,
1073
+ formatter: config.formatter,
1074
+ output: config.output,
1075
+ positional: config.positional,
1076
+ setup: config.setup,
1077
+ run: config.run
1078
+ };
1079
+ }
1080
+ function defineFormatter(config) {
1081
+ const deps = normalizeImports(config.imports);
1082
+ return {
1083
+ imports: deps.plugins,
1084
+ importBindings: deps.bindings,
1085
+ fetchContext: config.fetchContext,
1086
+ format: config.format
1087
+ };
1088
+ }
1089
+ function declareMethod(config) {
1090
+ const { name, namespace } = parseId(config.id);
1091
+ const id = makeId(name, namespace);
1092
+ return {
1093
+ pluginType: "method",
1094
+ name,
1095
+ namespace,
1096
+ id,
1097
+ standIn: true,
1098
+ imports: [],
1099
+ importBindings: [],
1100
+ run: () => {
1101
+ throw new Error(
1102
+ `Plugin "${id}" is a stand-in (declareMethod) with no implementation. Register the real plugin under this id.`
1103
+ );
1104
+ }
1105
+ };
1106
+ }
1107
+ function defineProperty(config) {
1108
+ const deps = normalizeImports(config.imports);
1109
+ return {
1110
+ pluginType: "property",
1111
+ name: config.name,
1112
+ namespace: config.namespace,
1113
+ id: makeId(config.name, config.namespace),
1114
+ imports: deps.plugins,
1115
+ importBindings: deps.bindings,
1116
+ setup: config.setup,
1117
+ value: config.value,
1118
+ get: config.get,
1119
+ meta: collectLeafMeta(config)
1120
+ };
1121
+ }
1122
+ function declareProperty(config) {
1123
+ const { name, namespace } = parseId(config.id);
1124
+ return {
1125
+ pluginType: "property",
1126
+ name,
1127
+ namespace,
1128
+ id: makeId(name, namespace),
1129
+ standIn: true,
1130
+ imports: [],
1131
+ importBindings: []
1132
+ };
1133
+ }
1134
+ function definePlugin(fnOrConfig) {
1135
+ if (typeof fnOrConfig === "function") return fnOrConfig;
1136
+ const config = fnOrConfig;
1137
+ const deps = normalizeImports(config.imports);
1138
+ return {
1139
+ pluginType: "aggregate",
1140
+ name: config.name,
1141
+ namespace: config.namespace,
1142
+ id: makeId(config.name, config.namespace, "aggregate"),
1143
+ imports: deps.plugins,
1144
+ importBindings: deps.bindings,
1145
+ exports: normalizeExports(config.exports),
1146
+ middleware: config.middleware
1147
+ };
1148
+ }
1149
+ function normalizeExports(exports) {
1150
+ if (!exports) return {};
1151
+ const out = {};
1152
+ const add = (binding, leaf) => {
1153
+ const existing = out[binding];
1154
+ if (existing && existing.id !== leaf.id) {
1155
+ throw new Error(
1156
+ `definePlugin: duplicate export binding "${binding}". Two different plugins ("${existing.id}" and "${leaf.id}") bind the same name; wrap one in selectExports to rename it.`
1157
+ );
1158
+ }
1159
+ out[binding] = leaf;
1160
+ };
1161
+ for (const element of exports) {
1162
+ if (element.pluginType === "aggregate") {
1163
+ for (const [binding, child] of Object.entries(element.exports)) {
1164
+ add(binding, child);
1165
+ }
1166
+ } else {
1167
+ add(element.name, element);
1168
+ }
1022
1169
  }
1023
- if (schema instanceof zod.z.ZodOptional) {
1024
- return isPositional(schema._zod.def.innerType);
1170
+ return out;
1171
+ }
1172
+ function fromFunctionPlugin(fn, config) {
1173
+ return {
1174
+ pluginType: "legacy",
1175
+ name: config.name,
1176
+ namespace: config.namespace,
1177
+ id: makeId(config.name, config.namespace, "aggregate"),
1178
+ imports: [],
1179
+ importBindings: [],
1180
+ run: fn
1181
+ };
1182
+ }
1183
+ function defineLegacyMerge(args) {
1184
+ return {
1185
+ pluginType: "legacy-merge",
1186
+ name: args.name,
1187
+ namespace: args.namespace,
1188
+ id: makeId(args.name, args.namespace, "aggregate"),
1189
+ legacy: fromFunctionPlugin(args.legacy, {
1190
+ name: args.name,
1191
+ namespace: args.namespace
1192
+ }),
1193
+ plugin: args.plugin
1194
+ };
1195
+ }
1196
+ function legacyGraphEntry(name, value, pluginMeta) {
1197
+ const { inputSchema, ...rest } = pluginMeta ?? {};
1198
+ const meta = Object.keys(rest).length ? rest : void 0;
1199
+ if (typeof value === "function") {
1200
+ return {
1201
+ pluginType: "method",
1202
+ name,
1203
+ value,
1204
+ chain: [],
1205
+ ...inputSchema ? { inputSchema } : {},
1206
+ ...meta ? { meta } : {}
1207
+ };
1025
1208
  }
1026
- if (schema instanceof zod.z.ZodDefault) {
1027
- return isPositional(schema._zod.def.innerType);
1209
+ return { pluginType: "property", name, value, ...meta ? { meta } : {} };
1210
+ }
1211
+ function adaptLegacyFormatter(legacy, sdk) {
1212
+ const legacyFetch = legacy.fetch;
1213
+ return {
1214
+ fetchContext: legacyFetch ? async ({ items, input, context }) => {
1215
+ let ctx = context;
1216
+ for (const item of items) {
1217
+ ctx = await legacyFetch(sdk, input, item, ctx);
1218
+ }
1219
+ return ctx;
1220
+ } : void 0,
1221
+ format: ({ item, context }) => legacy.format(item, context)
1222
+ };
1223
+ }
1224
+ function normalizeFormatter(entry, sdk) {
1225
+ if (entry.pluginType !== "method") return void 0;
1226
+ if (entry.formatter) return entry.formatter;
1227
+ const legacy = entry.meta?.formatter;
1228
+ return legacy ? adaptLegacyFormatter(legacy, sdk) : void 0;
1229
+ }
1230
+ function pluginEntryMeta(entry) {
1231
+ if (entry.pluginType === "method" && entry.meta) {
1232
+ return entry.inputSchema ? { ...entry.meta, inputSchema: entry.inputSchema } : entry.meta;
1028
1233
  }
1029
- return false;
1234
+ if (entry.pluginType === "property" && entry.meta) return entry.meta;
1235
+ return void 0;
1030
1236
  }
1031
-
1032
- // src/constants.ts
1033
- var ZAPIER_BASE_URL = globalThis.process?.env?.ZAPIER_BASE_URL || "https://zapier.com";
1034
- function getZapierSdkService() {
1035
- return globalThis.process?.env?.ZAPIER_SDK_SERVICE;
1237
+ function buildSurfaceRegistry(context, packageFilter) {
1238
+ const meta = {};
1239
+ const surface = {};
1240
+ const entries = {};
1241
+ for (const [binding, id] of Object.entries(context.surface)) {
1242
+ const entry = context.plugins[id];
1243
+ if (!entry || entry.pluginType === "aggregate") continue;
1244
+ surface[binding] = entry.value;
1245
+ entries[binding] = entry;
1246
+ const m = pluginEntryMeta(entry);
1247
+ if (m) meta[binding] = m;
1248
+ }
1249
+ const formatters = {};
1250
+ for (const [binding, entry] of Object.entries(entries)) {
1251
+ const f = normalizeFormatter(entry, surface);
1252
+ if (f) formatters[binding] = f;
1253
+ }
1254
+ return buildRegistry({ sdk: surface, meta, formatters, packageFilter });
1255
+ }
1256
+ var dangerousContextPlugin = {
1257
+ pluginType: "property",
1258
+ name: "context",
1259
+ namespace: "kitcore",
1260
+ id: "kitcore/context",
1261
+ imports: [],
1262
+ importBindings: [],
1263
+ privileged: true
1264
+ };
1265
+ defineMethod({
1266
+ name: "getRegistry",
1267
+ namespace: "kitcore",
1268
+ imports: [dangerousContextPlugin],
1269
+ inputSchema: zod.z.object({ package: zod.z.string().optional() }).optional(),
1270
+ run: ({ imports, input }) => buildSurfaceRegistry(imports.context, input?.package)
1271
+ });
1272
+ function normalizeOutput(output) {
1273
+ if (output === void 0) return { type: "raw" };
1274
+ if (typeof output === "string") return { type: output };
1275
+ return output;
1036
1276
  }
1037
- var MAX_PAGE_LIMIT = 1e4;
1038
- var DEFAULT_PAGE_SIZE = 100;
1039
- var DEFAULT_ACTION_TIMEOUT_MS = 18e4;
1040
- function parseIntEnvVar(name) {
1041
- const value = globalThis.process?.env?.[name];
1042
- if (value === void 0) return void 0;
1043
- const parsed = parseInt(value, 10);
1044
- if (isNaN(parsed)) {
1045
- console.warn(
1046
- `[zapier-sdk] Invalid value for ${name}: "${value}" (expected integer)`
1047
- );
1048
- return void 0;
1277
+ var CONTEXT = Symbol("kitcore.context");
1278
+ function getContext(sdk) {
1279
+ return sdk[CONTEXT];
1280
+ }
1281
+ function isResolverRef(value) {
1282
+ return "ref" in value;
1283
+ }
1284
+ function nestedResolvers(resolver) {
1285
+ const out = [];
1286
+ if (resolver.type === "object") {
1287
+ for (const field of Object.values(resolver.properties ?? {})) {
1288
+ if (!isResolverRef(field.resolver)) out.push(field.resolver);
1289
+ }
1290
+ out.push(...Object.values(resolver.definitions ?? {}));
1291
+ } else if (resolver.type === "array") {
1292
+ if (!isResolverRef(resolver.items)) out.push(resolver.items);
1293
+ out.push(...Object.values(resolver.definitions ?? {}));
1049
1294
  }
1050
- return parsed;
1295
+ return out;
1051
1296
  }
1052
- var ZAPIER_MAX_NETWORK_RETRIES = parseIntEnvVar("ZAPIER_MAX_NETWORK_RETRIES") ?? 3;
1053
- var ZAPIER_MAX_NETWORK_RETRY_DELAY_MS = parseIntEnvVar("ZAPIER_MAX_NETWORK_RETRY_DELAY_MS") ?? 6e4;
1054
- var MAX_CONCURRENCY_LIMIT = 1e4;
1055
- function parseConcurrencyEnvVar(name) {
1056
- const value = globalThis.process?.env?.[name];
1057
- if (!value) return void 0;
1058
- if (value === "Infinity") return Infinity;
1059
- if (/^[1-9]\d*$/.test(value)) {
1060
- const parsed = parseInt(value, 10);
1061
- if (parsed <= MAX_CONCURRENCY_LIMIT) return parsed;
1297
+ function resolverImportEdges(resolver) {
1298
+ const out = [...resolver.imports];
1299
+ for (const child of nestedResolvers(resolver)) {
1300
+ out.push(...resolverImportEdges(child));
1062
1301
  }
1063
- console.warn(
1064
- `[zapier-sdk] Invalid value for ${name}: "${value}" (expected positive integer 1-${MAX_CONCURRENCY_LIMIT} or "Infinity")`
1065
- );
1066
- return void 0;
1302
+ return out;
1067
1303
  }
1068
- var ZAPIER_MAX_CONCURRENT_REQUESTS = parseConcurrencyEnvVar("ZAPIER_MAX_CONCURRENT_REQUESTS") ?? 200;
1069
- function getZapierApprovalMode() {
1070
- const value = globalThis.process?.env?.ZAPIER_APPROVAL_MODE;
1071
- if (value === "disabled" || value === "poll" || value === "throw")
1072
- return value;
1073
- return void 0;
1304
+ function methodAttachmentEdges(plugin) {
1305
+ const out = [];
1306
+ if (plugin.resolvers) {
1307
+ for (const resolver of Object.values(plugin.resolvers)) {
1308
+ out.push(...resolverImportEdges(resolver));
1309
+ }
1310
+ }
1311
+ if (plugin.formatter) out.push(...plugin.formatter.imports);
1312
+ return out;
1074
1313
  }
1075
- function getZapierOpenAutoModeApprovalsInBrowser() {
1076
- const value = globalThis.process?.env?.ZAPIER_OPEN_AUTO_MODE_APPROVALS_IN_BROWSER;
1077
- if (value === void 0) return void 0;
1078
- return value === "true";
1314
+ function edgesOf(plugin) {
1315
+ if (plugin.pluginType === "aggregate") {
1316
+ return [...Object.values(plugin.exports), ...plugin.imports];
1317
+ }
1318
+ if (plugin.pluginType === "method") {
1319
+ return [...plugin.imports, ...methodAttachmentEdges(plugin)];
1320
+ }
1321
+ return plugin.imports;
1079
1322
  }
1080
- function getZapierDefaultApprovalMode() {
1081
- const isInteractive = !!globalThis.process?.stdin?.isTTY && !!globalThis.process?.stdout?.isTTY;
1082
- return isInteractive ? "poll" : "throw";
1323
+ function isStandIn(plugin) {
1324
+ return (plugin.pluginType === "method" || plugin.pluginType === "property" || plugin.pluginType === "aggregate") && plugin.standIn === true;
1083
1325
  }
1084
- var DEFAULT_APPROVAL_TIMEOUT_MS = 10 * 60 * 1e3;
1085
- var DEFAULT_MAX_APPROVAL_RETRIES = 2;
1086
-
1087
- // src/types/properties.ts
1088
- var AppKeyPropertySchema = withPositional(
1089
- zod.z.string().min(1).describe("App key (e.g., 'SlackCLIAPI' or slug like 'github')")
1090
- );
1091
- var AppPropertySchema = withPositional(
1092
- zod.z.string().min(1).describe(
1093
- "App slug (e.g., 'github'), implementation name (e.g., 'SlackCLIAPI'), or versioned ID (e.g., 'github@1.2.3')"
1094
- )
1095
- );
1096
- var ActionTypePropertySchema = zod.z.enum([
1097
- "read",
1098
- "read_bulk",
1099
- "write",
1100
- "run",
1101
- "search",
1102
- "search_or_write",
1103
- "search_and_write",
1104
- "filter"
1105
- ]).describe("Action type that matches the action's defined type");
1106
- var ActionKeyPropertySchema = zod.z.string().min(1).describe("Action key to execute");
1107
- var ActionPropertySchema = withPositional(
1108
- zod.z.string().min(1).describe("Action key (e.g., 'send_message' or 'find_row')")
1109
- );
1110
- var InputFieldPropertySchema = withPositional(
1111
- zod.z.string().min(1).describe("Input field key to get choices for")
1112
- );
1113
- var ConnectionIdPropertySchema = zod.z.union([zod.z.string(), zod.z.number().int().positive()]).describe("Connection ID to use for this action");
1114
- var AuthenticationIdPropertySchema = ConnectionIdPropertySchema.meta({
1115
- deprecated: true
1116
- });
1117
- var ConnectionPropertySchema = zod.z.union([zod.z.string(), zod.z.number().int().positive()]).describe(
1118
- "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."
1119
- );
1120
- var InputsPropertySchema = zod.z.record(zod.z.string(), zod.z.unknown()).describe("Input parameters for the action");
1121
- var LimitPropertySchema = zod.z.number().int().min(1).max(MAX_PAGE_LIMIT).default(50).describe("Maximum number of items to return");
1122
- var OffsetPropertySchema = zod.z.number().int().min(0).default(0).describe("Number of items to skip for pagination");
1123
- var OutputPropertySchema = zod.z.string().describe("Output file path");
1124
- var DebugPropertySchema = zod.z.boolean().default(false).describe("Enable debug logging");
1125
- var ParamsPropertySchema = zod.z.record(zod.z.string(), zod.z.unknown()).describe("Additional parameters");
1126
- var ActionTimeoutMsPropertySchema = zod.z.number().min(1e3).optional().describe(
1127
- `Maximum time to wait for action completion in milliseconds (default: ${DEFAULT_ACTION_TIMEOUT_MS})`
1128
- );
1129
- var TablePropertySchema = withPositional(
1130
- zod.z.string().regex(/^[A-Z0-9]{26}$/, "Table ID must be a valid ULID").describe("The unique identifier of the table")
1131
- );
1132
- var RecordPropertySchema = withPositional(
1133
- zod.z.string().regex(/^[A-Z0-9]{26}$/, "Record ID must be a valid ULID").describe("The unique identifier of the record")
1134
- );
1135
- 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");
1136
- var FieldsPropertySchema = zod.z.array(zod.z.union([zod.z.string(), zod.z.number()])).describe(
1137
- 'Fields to operate on. Accepts field names (e.g., "Email") or IDs (e.g., "f6", "6", or 6).'
1138
- );
1139
- var AppsPropertySchema = zod.z.array(zod.z.string()).describe("Filter by app keys (e.g., 'SlackCLIAPI' or slug like 'github')");
1140
- var TablesPropertySchema = zod.z.array(zod.z.string()).describe("Filter by specific table IDs");
1141
- var ConnectionsPropertySchema = zod.z.array(zod.z.string()).describe("List of connection IDs to filter by");
1142
- var TriggerInboxPropertySchema = withPositional(
1143
- zod.z.string().min(1).describe(
1144
- "Trigger inbox identifier \u2014 UUID or name. Non-UUID values are resolved by name via the inbox list endpoint."
1145
- )
1146
- );
1147
- var TriggerInboxNamePropertySchema = zod.z.string().min(1).max(100).describe(
1148
- "Inbox name; unique per (user, account). Enables get-or-create on createTriggerInbox."
1149
- );
1150
- var LeasePropertySchema = zod.z.string().min(1).describe("Lease ID returned from leaseTriggerInboxMessages");
1151
- var LeaseSecondsPropertySchema = zod.z.number().int().min(1).max(3600).describe(
1152
- "Seconds until the lease expires; messages return to available if not acked. API default is 300 (5 minutes)."
1153
- );
1154
- var LeaseLimitPropertySchema = zod.z.number().int().min(1).max(100).describe("Maximum messages to lease in a single batch (1-100)");
1155
-
1156
- // src/types/errors.ts
1157
- var _a, _b;
1158
- var ZapierError = class extends (_b = Error, _a = CORE_ERROR_SYMBOL, _b) {
1159
- constructor(message, options = {}) {
1160
- super(message);
1161
- this[_a] = true;
1162
- this.name = "ZapierError";
1163
- this.code = "ZAPIER_ERROR";
1164
- if (options.statusCode !== void 0) this.statusCode = options.statusCode;
1165
- if (options.errors !== void 0) this.errors = options.errors;
1166
- if (options.cause !== void 0) this.cause = options.cause;
1167
- if (options.response !== void 0) this.response = options.response;
1168
- Object.setPrototypeOf(this, new.target.prototype);
1169
- }
1170
- };
1171
- var ZapierValidationError = class extends ZapierError {
1172
- constructor(message, options = {}) {
1173
- super(message, options);
1174
- this.name = "ZapierValidationError";
1175
- this.code = "ZAPIER_VALIDATION_ERROR";
1176
- this.details = options.details;
1326
+ function topoOrder(descriptors) {
1327
+ const order = [];
1328
+ const visited = /* @__PURE__ */ new Set();
1329
+ const visit = (id) => {
1330
+ if (visited.has(id)) return;
1331
+ visited.add(id);
1332
+ const descriptor = descriptors.get(id);
1333
+ if (descriptor) for (const edge of edgesOf(descriptor)) visit(edge.id);
1334
+ order.push(id);
1335
+ };
1336
+ for (const id of descriptors.keys()) visit(id);
1337
+ return order;
1338
+ }
1339
+ function collectPlugins(root, materialized = /* @__PURE__ */ new Set()) {
1340
+ const byId = /* @__PURE__ */ new Map();
1341
+ const visit = (plugin) => {
1342
+ if (materialized.has(plugin.id)) return;
1343
+ const existing = byId.get(plugin.id);
1344
+ if (existing === plugin) return;
1345
+ if (existing) {
1346
+ const bothReal = !isStandIn(existing) && !isStandIn(plugin);
1347
+ if (bothReal) {
1348
+ throw new Error(
1349
+ `createSdk: duplicate plugin id "${plugin.id}". Two different plugins registered under the same id.`
1350
+ );
1351
+ }
1352
+ if (isStandIn(existing) && !isStandIn(plugin)) {
1353
+ byId.set(plugin.id, plugin);
1354
+ for (const edge of edgesOf(plugin)) visit(edge);
1355
+ }
1356
+ return;
1357
+ }
1358
+ byId.set(plugin.id, plugin);
1359
+ for (const edge of edgesOf(plugin)) visit(edge);
1360
+ };
1361
+ visit(root);
1362
+ for (const [id, plugin] of byId) {
1363
+ if (isStandIn(plugin)) {
1364
+ throw new Error(
1365
+ `createSdk: missing dependency "${id}". A plugin depends on it (via a stand-in) but no implementation was registered.`
1366
+ );
1367
+ }
1177
1368
  }
1178
- };
1179
- var ZapierUnknownError = class extends ZapierError {
1180
- constructor() {
1181
- super(...arguments);
1182
- this.name = "ZapierUnknownError";
1183
- this.code = "ZAPIER_UNKNOWN_ERROR";
1369
+ return byId;
1370
+ }
1371
+ function bindValue(target, key, entry) {
1372
+ if (entry.pluginType === "property" && entry.getValue) {
1373
+ Object.defineProperty(target, key, {
1374
+ get: entry.getValue,
1375
+ enumerable: true,
1376
+ configurable: true
1377
+ });
1378
+ } else {
1379
+ Object.defineProperty(target, key, {
1380
+ value: entry.value,
1381
+ writable: true,
1382
+ enumerable: true,
1383
+ configurable: true
1384
+ });
1184
1385
  }
1185
- };
1186
- var ZapierAuthenticationError = class extends ZapierError {
1187
- constructor() {
1188
- super(...arguments);
1189
- this.name = "ZapierAuthenticationError";
1190
- this.code = "ZAPIER_AUTHENTICATION_ERROR";
1386
+ }
1387
+ function buildSurface(context, ...maps) {
1388
+ const sdk = {};
1389
+ for (const map of maps) {
1390
+ Object.defineProperties(sdk, Object.getOwnPropertyDescriptors(map));
1191
1391
  }
1192
- };
1193
- var zapierAdaptError = (options) => {
1194
- switch (options.code) {
1195
- case CoreErrorCode.Validation:
1196
- return new ZapierValidationError(options.message, {
1197
- cause: options.cause,
1198
- details: options.details
1199
- });
1200
- case CoreErrorCode.Unknown:
1201
- return new ZapierUnknownError(options.message, {
1202
- cause: options.cause
1203
- });
1204
- default:
1205
- return new ZapierError(options.message, { cause: options.cause });
1392
+ sdk.context = context;
1393
+ sdk[CONTEXT] = context;
1394
+ return sdk;
1395
+ }
1396
+ function buildImports(plugins, importBindings) {
1397
+ const imports = {};
1398
+ for (const { binding, id } of importBindings) {
1399
+ bindValue(imports, binding, plugins[id]);
1206
1400
  }
1207
- };
1208
- var ZapierApiError = class extends ZapierError {
1209
- constructor(message, options = {}) {
1210
- super(message, options);
1211
- this.name = "ZapierApiError";
1212
- this.code = "ZAPIER_API_ERROR";
1401
+ return imports;
1402
+ }
1403
+ function mirrorLegacyRootKeys(context, rootKeys, meta) {
1404
+ const exports = {};
1405
+ for (const [name, value] of Object.entries(rootKeys)) {
1406
+ context.plugins[name] = legacyGraphEntry(name, value, meta[name]);
1407
+ exports[name] = value;
1213
1408
  }
1214
- };
1215
- var ZapierAppNotFoundError = class extends ZapierError {
1216
- constructor(message, options = {}) {
1217
- super(message, options);
1218
- this.name = "ZapierAppNotFoundError";
1219
- this.code = "ZAPIER_APP_NOT_FOUND_ERROR";
1220
- this.appKey = options.appKey;
1409
+ return exports;
1410
+ }
1411
+ function recordExportSurface(context, exports) {
1412
+ for (const [binding, child] of Object.entries(exports)) {
1413
+ context.surface[binding] = child.id;
1221
1414
  }
1222
- };
1223
- var ZapierNotFoundError = class extends ZapierError {
1224
- constructor(message, options = {}) {
1225
- super(message, options);
1226
- this.name = "ZapierNotFoundError";
1227
- this.code = "ZAPIER_NOT_FOUND_ERROR";
1415
+ }
1416
+ function materialize(descriptors, context) {
1417
+ const states = /* @__PURE__ */ new Map();
1418
+ runLegacyPass(descriptors, context);
1419
+ buildMethodEntries(descriptors, context, states);
1420
+ buildEagerArtifacts(descriptors, context, states);
1421
+ bindAttachments(descriptors, context);
1422
+ resolveAggregates(descriptors, context);
1423
+ assembleMiddleware(descriptors, context);
1424
+ return context.plugins;
1425
+ }
1426
+ function bindResolver(resolver, plugins) {
1427
+ switch (resolver.type) {
1428
+ case "static":
1429
+ return {
1430
+ type: "static",
1431
+ requireParams: resolver.requireParams,
1432
+ requireCapabilities: resolver.requireCapabilities,
1433
+ inputType: resolver.inputType,
1434
+ placeholder: resolver.placeholder
1435
+ };
1436
+ case "constant":
1437
+ return {
1438
+ type: "constant",
1439
+ value: resolver.value,
1440
+ requireParams: resolver.requireParams,
1441
+ requireCapabilities: resolver.requireCapabilities
1442
+ };
1443
+ case "info":
1444
+ return { type: "info", text: resolver.text };
1445
+ case "object": {
1446
+ const imports = buildImports(plugins, resolver.importBindings);
1447
+ const bound = {
1448
+ type: "object",
1449
+ requireParams: resolver.requireParams,
1450
+ requireCapabilities: resolver.requireCapabilities
1451
+ };
1452
+ if (resolver.properties)
1453
+ bound.properties = bindFields(resolver.properties, plugins);
1454
+ if (resolver.definitions)
1455
+ bound.definitions = bindDefinitions(resolver.definitions, plugins);
1456
+ const { fetch: fetch2 } = resolver;
1457
+ if (fetch2) bound.fetch = ({ params }) => fetch2({ imports, params });
1458
+ return bound;
1459
+ }
1460
+ case "array": {
1461
+ const bound = {
1462
+ type: "array",
1463
+ requireParams: resolver.requireParams,
1464
+ requireCapabilities: resolver.requireCapabilities,
1465
+ minItems: resolver.minItems,
1466
+ maxItems: resolver.maxItems,
1467
+ items: isResolverRef(resolver.items) ? resolver.items : bindResolver(resolver.items, plugins)
1468
+ };
1469
+ if (resolver.definitions)
1470
+ bound.definitions = bindDefinitions(resolver.definitions, plugins);
1471
+ return bound;
1472
+ }
1473
+ default: {
1474
+ const imports = buildImports(plugins, resolver.importBindings);
1475
+ const bound = {
1476
+ type: "dynamic",
1477
+ requireParams: resolver.requireParams,
1478
+ requireCapabilities: resolver.requireCapabilities,
1479
+ inputType: resolver.inputType,
1480
+ placeholder: resolver.placeholder,
1481
+ prompt: resolver.prompt
1482
+ };
1483
+ const { fetch: fetch2, tryResolveWithoutPrompt } = resolver;
1484
+ if (fetch2)
1485
+ bound.fetch = ({ params, search }) => fetch2({ imports, params, search });
1486
+ if (tryResolveWithoutPrompt) {
1487
+ bound.tryResolveWithoutPrompt = ({ params }) => tryResolveWithoutPrompt({ imports, params });
1488
+ }
1489
+ return bound;
1490
+ }
1228
1491
  }
1229
- };
1230
- var ZapierResourceNotFoundError = class extends ZapierNotFoundError {
1231
- constructor(message, options = {}) {
1232
- super(message, options);
1233
- this.name = "ZapierResourceNotFoundError";
1234
- this.code = "ZAPIER_RESOURCE_NOT_FOUND_ERROR";
1235
- this.resourceType = options.resourceType;
1236
- this.resourceId = options.resourceId;
1492
+ }
1493
+ function bindFields(fields, plugins) {
1494
+ const out = {};
1495
+ for (const [key, field] of Object.entries(fields)) {
1496
+ out[key] = {
1497
+ ...field,
1498
+ resolver: isResolverRef(field.resolver) ? field.resolver : bindResolver(field.resolver, plugins)
1499
+ };
1237
1500
  }
1238
- };
1239
- var ZapierConfigurationError = class extends ZapierError {
1240
- constructor(message, options = {}) {
1241
- super(message, options);
1242
- this.name = "ZapierConfigurationError";
1243
- this.code = "ZAPIER_CONFIGURATION_ERROR";
1244
- this.configType = options.configType;
1501
+ return out;
1502
+ }
1503
+ function bindDefinitions(definitions, plugins) {
1504
+ const out = {};
1505
+ for (const [key, def] of Object.entries(definitions)) {
1506
+ out[key] = bindResolver(def, plugins);
1245
1507
  }
1246
- };
1247
- var ZapierBundleError = class extends ZapierError {
1248
- constructor(message, options = {}) {
1249
- super(message, options);
1250
- this.name = "ZapierBundleError";
1251
- this.code = "ZAPIER_BUNDLE_ERROR";
1252
- this.buildErrors = options.buildErrors;
1508
+ return out;
1509
+ }
1510
+ function bindFormatter(formatter, plugins) {
1511
+ const imports = buildImports(plugins, formatter.importBindings);
1512
+ const bound = { format: formatter.format };
1513
+ const { fetchContext } = formatter;
1514
+ if (fetchContext)
1515
+ bound.fetchContext = ({ items, input, context }) => fetchContext({ imports, items, input, context });
1516
+ return bound;
1517
+ }
1518
+ function bindAttachments(descriptors, context) {
1519
+ const plugins = context.plugins;
1520
+ for (const [id, descriptor] of descriptors) {
1521
+ if (descriptor.pluginType !== "method") continue;
1522
+ const entry = plugins[id];
1523
+ if (!entry || entry.pluginType !== "method") continue;
1524
+ if (descriptor.resolvers) {
1525
+ const bound = {};
1526
+ for (const [param, resolver] of Object.entries(descriptor.resolvers)) {
1527
+ bound[param] = bindResolver(resolver, plugins);
1528
+ }
1529
+ entry.resolvers = bound;
1530
+ }
1531
+ if (descriptor.formatter) {
1532
+ entry.formatter = bindFormatter(descriptor.formatter, plugins);
1533
+ }
1253
1534
  }
1254
- };
1255
- var ZapierTimeoutError = class extends ZapierError {
1256
- constructor(message, options = {}) {
1257
- super(message, options);
1258
- this.name = "ZapierTimeoutError";
1259
- this.code = "ZAPIER_TIMEOUT_ERROR";
1260
- this.attempts = options.attempts;
1261
- this.maxAttempts = options.maxAttempts;
1535
+ }
1536
+ function runLegacyPass(descriptors, context) {
1537
+ const plugins = context.plugins;
1538
+ const compatView = new Proxy(
1539
+ {},
1540
+ {
1541
+ get: (_target, prop) => {
1542
+ if (prop === "context") return context;
1543
+ const entry = plugins[prop];
1544
+ return entry?.value;
1545
+ }
1546
+ }
1547
+ );
1548
+ for (const id of topoOrder(descriptors)) {
1549
+ const descriptor = descriptors.get(id);
1550
+ if (!descriptor || descriptor.pluginType !== "legacy") continue;
1551
+ const { rootKeys, meta, hooks, contextRest } = splitPluginContribution(
1552
+ descriptor.run(compatView)
1553
+ );
1554
+ Object.assign(context.meta, meta);
1555
+ Object.assign(context, contextRest);
1556
+ context.hooks = buildHooks(context.hooks, hooks);
1557
+ const exports = mirrorLegacyRootKeys(context, rootKeys, meta);
1558
+ if (!("getRegistry" in exports)) {
1559
+ let getRegistry2 = function(options) {
1560
+ const sdk = this ?? exports;
1561
+ const meta2 = {};
1562
+ const formatters = {};
1563
+ for (const [binding, id2] of Object.entries(context.surface)) {
1564
+ const entry = context.plugins[id2];
1565
+ if (!entry || entry.pluginType === "aggregate") continue;
1566
+ const m = pluginEntryMeta(entry);
1567
+ if (m) meta2[binding] = m;
1568
+ const f = normalizeFormatter(entry, sdk);
1569
+ if (f) formatters[binding] = f;
1570
+ }
1571
+ Object.assign(meta2, context.meta);
1572
+ return buildRegistry({
1573
+ sdk,
1574
+ meta: meta2,
1575
+ formatters,
1576
+ packageFilter: options?.package
1577
+ });
1578
+ };
1579
+ exports.getRegistry = getRegistry2;
1580
+ plugins.getRegistry = {
1581
+ pluginType: "method",
1582
+ name: "getRegistry",
1583
+ value: getRegistry2,
1584
+ chain: []
1585
+ };
1586
+ }
1587
+ plugins[id] = { pluginType: "aggregate", name: descriptor.name, exports };
1588
+ }
1589
+ }
1590
+ function buildMethodEntries(descriptors, context, states) {
1591
+ const plugins = context.plugins;
1592
+ for (const [id, descriptor] of descriptors) {
1593
+ if (descriptor.pluginType !== "method") continue;
1594
+ const out = normalizeOutput(descriptor.output);
1595
+ const entry = {
1596
+ pluginType: "method",
1597
+ name: descriptor.name,
1598
+ chain: [],
1599
+ inputSchema: descriptor.inputSchema,
1600
+ // Derive the presentation type from the output mode when the author did
1601
+ // not set one; an explicit meta.type (e.g. "create") still wins.
1602
+ meta: out.type === "raw" || descriptor.meta?.type ? descriptor.meta : { ...descriptor.meta, type: out.type },
1603
+ output: out,
1604
+ // Replaced below; never called.
1605
+ value: () => void 0
1606
+ };
1607
+ const callRun = (input) => descriptor.run({
1608
+ imports: buildImports(plugins, descriptor.importBindings),
1609
+ state: states.get(id),
1610
+ input
1611
+ });
1612
+ const fold = (coreFn) => (input) => {
1613
+ let next = coreFn;
1614
+ for (const wrap of entry.chain) {
1615
+ const inner = next;
1616
+ next = (i) => wrap.run({
1617
+ imports: buildImports(plugins, wrap.owner.importBindings),
1618
+ next: inner,
1619
+ input: i
1620
+ });
1621
+ }
1622
+ return next(input);
1623
+ };
1624
+ const sdk = { context };
1625
+ if (out.type === "list") {
1626
+ entry.value = createPaginatedFunction(
1627
+ fold(callRun),
1628
+ {
1629
+ sdk,
1630
+ schema: descriptor.inputSchema,
1631
+ name: descriptor.name,
1632
+ defaultPageSize: out.defaultPageSize,
1633
+ adaptPage: out.adaptPage
1634
+ }
1635
+ );
1636
+ } else if (out.type === "item") {
1637
+ const itemCore = async (input) => ({
1638
+ data: await callRun(input)
1639
+ });
1640
+ entry.value = createFunction(
1641
+ fold(itemCore),
1642
+ { sdk, schema: descriptor.inputSchema, name: descriptor.name }
1643
+ );
1644
+ } else {
1645
+ entry.value = (rawInput) => {
1646
+ const input = descriptor.inputSchema ? descriptor.inputSchema.parse(rawInput) : rawInput;
1647
+ return fold(callRun)(input);
1648
+ };
1649
+ }
1650
+ if (descriptor.positional) {
1651
+ const names = descriptor.positional;
1652
+ const canonicalValue = entry.value;
1653
+ entry.value = (...args) => {
1654
+ const packed = {};
1655
+ names.forEach((name, i) => {
1656
+ if (i < args.length) packed[name] = args[i];
1657
+ });
1658
+ return canonicalValue(packed);
1659
+ };
1660
+ entry.positional = names;
1661
+ }
1662
+ plugins[id] = entry;
1262
1663
  }
1263
- };
1264
- var ZapierActionError = class extends ZapierError {
1265
- constructor(message, options = {}) {
1266
- super(message, options);
1267
- this.name = "ZapierActionError";
1268
- this.code = "ZAPIER_ACTION_ERROR";
1269
- this.appKey = options.appKey;
1270
- this.actionKey = options.actionKey;
1664
+ }
1665
+ function buildEagerArtifacts(descriptors, context, states) {
1666
+ const plugins = context.plugins;
1667
+ const built = /* @__PURE__ */ new Set();
1668
+ const building = /* @__PURE__ */ new Set();
1669
+ const ensureBuilt = (id) => {
1670
+ if (built.has(id)) return;
1671
+ const descriptor = descriptors.get(id);
1672
+ if (!descriptor || descriptor.pluginType === "aggregate" || descriptor.pluginType === "legacy") {
1673
+ built.add(id);
1674
+ return;
1675
+ }
1676
+ if (building.has(id)) {
1677
+ throw new Error(`createSdk: dependency cycle at "${id}".`);
1678
+ }
1679
+ building.add(id);
1680
+ for (const { id: depId } of descriptor.importBindings) ensureBuilt(depId);
1681
+ if (descriptor.pluginType === "method") {
1682
+ states.set(
1683
+ id,
1684
+ descriptor.setup ? descriptor.setup({
1685
+ imports: buildImports(plugins, descriptor.importBindings)
1686
+ }) : void 0
1687
+ );
1688
+ } else {
1689
+ states.set(
1690
+ id,
1691
+ descriptor.setup ? descriptor.setup({
1692
+ imports: buildImports(plugins, descriptor.importBindings)
1693
+ }) : void 0
1694
+ );
1695
+ if (descriptor.privileged) {
1696
+ plugins[id] = {
1697
+ pluginType: "property",
1698
+ name: descriptor.name,
1699
+ value: context,
1700
+ meta: descriptor.meta
1701
+ };
1702
+ } else if (descriptor.get) {
1703
+ const get = descriptor.get;
1704
+ const importBindings = descriptor.importBindings;
1705
+ plugins[id] = {
1706
+ pluginType: "property",
1707
+ name: descriptor.name,
1708
+ getValue: () => get({
1709
+ imports: buildImports(plugins, importBindings),
1710
+ state: states.get(id)
1711
+ }),
1712
+ meta: descriptor.meta
1713
+ };
1714
+ } else {
1715
+ plugins[id] = {
1716
+ pluginType: "property",
1717
+ name: descriptor.name,
1718
+ value: descriptor.value,
1719
+ meta: descriptor.meta
1720
+ };
1721
+ }
1722
+ }
1723
+ building.delete(id);
1724
+ built.add(id);
1725
+ };
1726
+ for (const id of descriptors.keys()) ensureBuilt(id);
1727
+ }
1728
+ function resolveAggregates(descriptors, context) {
1729
+ const plugins = context.plugins;
1730
+ for (const [id, descriptor] of descriptors) {
1731
+ if (descriptor.pluginType !== "aggregate") continue;
1732
+ const exports = {};
1733
+ for (const [binding, child] of Object.entries(descriptor.exports)) {
1734
+ bindValue(exports, binding, plugins[child.id]);
1735
+ }
1736
+ plugins[id] = { pluginType: "aggregate", name: descriptor.name, exports };
1271
1737
  }
1272
- // Legacy accessor for backward compatibility
1273
- get actionErrors() {
1274
- return this.errors;
1738
+ }
1739
+ function assembleMiddleware(descriptors, context) {
1740
+ const plugins = context.plugins;
1741
+ for (const id of topoOrder(descriptors)) {
1742
+ const descriptor = descriptors.get(id);
1743
+ if (!descriptor || descriptor.pluginType !== "aggregate" || !descriptor.middleware) {
1744
+ continue;
1745
+ }
1746
+ for (const [targetBinding, fn] of Object.entries(descriptor.middleware)) {
1747
+ const edge = descriptor.importBindings.find(
1748
+ (b) => b.binding === targetBinding
1749
+ );
1750
+ if (!edge) {
1751
+ throw new Error(
1752
+ `createSdk: middleware target "${targetBinding}" in plugin "${id}" is not a direct dependency. A middleware target must be a declared dependency of the wrapping plugin.`
1753
+ );
1754
+ }
1755
+ const target = plugins[edge.id];
1756
+ if (!target || target.pluginType !== "method") {
1757
+ throw new Error(
1758
+ `createSdk: middleware target "${targetBinding}" in plugin "${id}" does not resolve to a method.`
1759
+ );
1760
+ }
1761
+ if (target.output?.type === "list") {
1762
+ throw new Error(
1763
+ `createSdk: middleware target "${targetBinding}" in plugin "${id}" resolves to a list-output method, which does not support middleware yet.`
1764
+ );
1765
+ }
1766
+ target.chain.push({ run: fn, owner: descriptor });
1767
+ }
1275
1768
  }
1276
- };
1277
- var ZapierConflictError = class extends ZapierError {
1278
- constructor(message, options = {}) {
1279
- super(message, options);
1280
- this.name = "ZapierConflictError";
1281
- this.code = "ZAPIER_CONFLICT_ERROR";
1282
- this.resourceType = options.resourceType;
1769
+ }
1770
+ function createSdk(root) {
1771
+ const context = { plugins: {}, meta: {}, hooks: {}, surface: {} };
1772
+ if (root.pluginType === "legacy-merge") {
1773
+ const { legacy, plugin } = root;
1774
+ const collectRoot = {
1775
+ pluginType: "aggregate",
1776
+ name: root.name,
1777
+ id: `${root.id}:merge`,
1778
+ imports: [legacy, plugin],
1779
+ importBindings: [],
1780
+ exports: {}
1781
+ };
1782
+ const plugins2 = materialize(collectPlugins(collectRoot), context);
1783
+ const legacyExports = plugins2[legacy.id].exports;
1784
+ let pluginSurface;
1785
+ if (plugin.pluginType === "aggregate") {
1786
+ pluginSurface = plugins2[plugin.id].exports;
1787
+ } else {
1788
+ pluginSurface = {};
1789
+ bindValue(pluginSurface, plugin.name, plugins2[plugin.id]);
1790
+ }
1791
+ for (const key of Object.keys(legacyExports)) context.surface[key] = key;
1792
+ if (plugin.pluginType === "aggregate") {
1793
+ recordExportSurface(context, plugin.exports);
1794
+ } else {
1795
+ context.surface[plugin.name] = plugin.id;
1796
+ }
1797
+ return buildSurface(context, legacyExports, pluginSurface);
1798
+ }
1799
+ const plugins = materialize(collectPlugins(root), context);
1800
+ if (root.pluginType === "method" || root.pluginType === "property") {
1801
+ context.surface[root.name] = root.id;
1802
+ const sdk = buildSurface(context);
1803
+ bindValue(sdk, root.name, plugins[root.id]);
1804
+ return sdk;
1805
+ }
1806
+ if (root.pluginType === "aggregate")
1807
+ recordExportSurface(context, root.exports);
1808
+ return buildSurface(context, plugins[root.id].exports);
1809
+ }
1810
+ function addModelPlugin(sdk, plugin, options = {}) {
1811
+ const override = options.override === true;
1812
+ const context = getContext(sdk);
1813
+ const surfaceKeys = plugin.pluginType === "aggregate" ? Object.keys(plugin.exports) : [plugin.name];
1814
+ checkRootKeyCollisions(sdk, surfaceKeys, override, "addPlugin");
1815
+ const materialized = new Set(Object.keys(context.plugins));
1816
+ if (override && materialized.has(plugin.id)) {
1817
+ throw new Error(
1818
+ `addPlugin: cannot override already-materialized plugin "${plugin.id}" on the incremental path. Rebuild the SDK with the replacement via createSdk.`
1819
+ );
1283
1820
  }
1284
- };
1285
- var ZapierRateLimitError = class extends ZapierError {
1286
- constructor(message, options = {}) {
1287
- super(message, options);
1288
- this.name = "ZapierRateLimitError";
1289
- this.code = "ZAPIER_RATE_LIMIT_ERROR";
1290
- this.rateLimit = options.rateLimit ?? {};
1291
- this.retries = options.retries ?? 0;
1821
+ materialize(collectPlugins(plugin, materialized), context);
1822
+ const entry = context.plugins[plugin.id];
1823
+ if (entry.pluginType === "aggregate") {
1824
+ Object.defineProperties(
1825
+ sdk,
1826
+ Object.getOwnPropertyDescriptors(entry.exports)
1827
+ );
1828
+ for (const [binding, child] of Object.entries(
1829
+ plugin.exports
1830
+ )) {
1831
+ context.surface[binding] = child.id;
1832
+ }
1833
+ } else {
1834
+ bindValue(sdk, plugin.name, entry);
1835
+ context.surface[plugin.name] = plugin.id;
1292
1836
  }
1293
- };
1294
- var ZapierApprovalError = class extends ZapierError {
1295
- constructor(message, options = {}) {
1296
- super(message, options);
1297
- this.name = "ZapierApprovalError";
1298
- this.code = "ZAPIER_APPROVAL_ERROR";
1299
- this.approvalId = options.approvalId;
1300
- this.approvalStatus = options.status;
1301
- this.approvalUrl = options.approvalUrl;
1302
- this.pollUrl = options.pollUrl;
1303
- this.streamUrl = options.streamUrl;
1304
- this.reason = options.reason;
1837
+ }
1838
+ function addPlugin(sdk, plugin, options) {
1839
+ if (typeof plugin === "function") {
1840
+ const record = sdk;
1841
+ const contribution = applyPluginToSdk(
1842
+ record,
1843
+ plugin,
1844
+ options ?? {}
1845
+ );
1846
+ const context = record[CONTEXT];
1847
+ if (context) {
1848
+ mirrorLegacyRootKeys(context, contribution.rootKeys, contribution.meta);
1849
+ for (const name of Object.keys(contribution.rootKeys)) {
1850
+ context.surface[name] = name;
1851
+ }
1852
+ }
1853
+ return;
1305
1854
  }
1306
- };
1307
- var ZapierRelayError = class extends ZapierError {
1308
- constructor(message, options = {}) {
1309
- super(message, options);
1310
- this.name = "ZapierRelayError";
1311
- this.code = "ZAPIER_RELAY_ERROR";
1312
- }
1313
- };
1314
- function formatErrorMessage(error) {
1315
- let message = error.message;
1316
- if (error.errors && error.errors.length > 0) {
1317
- const additionalErrors = error.errors.slice(1);
1318
- if (additionalErrors.length > 0) {
1319
- const errorDetails = additionalErrors.map((err) => ` \u2022 ${err.detail || err.title || err.code}`).join("\n");
1320
- message += "\n\nAdditional errors:\n" + errorDetails;
1855
+ addModelPlugin(
1856
+ sdk,
1857
+ plugin,
1858
+ options ?? {}
1859
+ );
1860
+ }
1861
+ function createCorePlugin(options) {
1862
+ return () => ({
1863
+ context: {
1864
+ core: options
1321
1865
  }
1866
+ });
1867
+ }
1868
+ function withPositional(schema) {
1869
+ Object.assign(schema._zod.def, {
1870
+ positionalMeta: { positional: true }
1871
+ });
1872
+ return schema;
1873
+ }
1874
+ function schemaHasPositionalMeta(schema) {
1875
+ return "positionalMeta" in schema._zod.def;
1876
+ }
1877
+ function isPositional(schema) {
1878
+ if (schemaHasPositionalMeta(schema) && schema._zod.def.positionalMeta?.positional) {
1879
+ return true;
1322
1880
  }
1323
- if (error instanceof ZapierAppNotFoundError && error.appKey) {
1324
- message += `
1325
- App key: ${error.appKey}`;
1326
- }
1327
- if (error instanceof ZapierActionError && (error.appKey || error.actionKey)) {
1328
- const context = [];
1329
- if (error.appKey) context.push(`App: ${error.appKey}`);
1330
- if (error.actionKey) context.push(`Action: ${error.actionKey}`);
1331
- message += `
1332
- ${context.join(", ")}`;
1333
- }
1334
- if (error instanceof ZapierResourceNotFoundError && (error.resourceType || error.resourceId)) {
1335
- const context = [];
1336
- if (error.resourceType) context.push(`Type: ${error.resourceType}`);
1337
- if (error.resourceId) context.push(`ID: ${error.resourceId}`);
1338
- message += `
1339
- ${context.join(", ")}`;
1340
- }
1341
- if (error instanceof ZapierConflictError && error.resourceType) {
1342
- message += `
1343
- Type: ${error.resourceType}`;
1344
- }
1345
- if (error instanceof ZapierTimeoutError && (error.attempts || error.maxAttempts)) {
1346
- const context = [];
1347
- if (error.attempts) context.push(`Attempts: ${error.attempts}`);
1348
- if (error.maxAttempts) context.push(`Max attempts: ${error.maxAttempts}`);
1349
- message += `
1350
- ${context.join(", ")}`;
1351
- }
1352
- if (error instanceof ZapierBundleError && error.buildErrors && error.buildErrors.length > 0) {
1353
- message += "\n\nBuild errors:\n" + error.buildErrors.map((err) => ` \u2022 ${err}`).join("\n");
1881
+ if (schema instanceof zod.z.ZodOptional) {
1882
+ return isPositional(schema._zod.def.innerType);
1354
1883
  }
1355
- if (error instanceof ZapierApprovalError && error.approvalUrl) {
1356
- message += `
1357
- Approval URL: ${error.approvalUrl}`;
1884
+ if (schema instanceof zod.z.ZodDefault) {
1885
+ return isPositional(schema._zod.def.innerType);
1358
1886
  }
1359
- if (error instanceof ZapierRateLimitError) {
1360
- const { limit, remaining, retryAfterMs } = error.rateLimit;
1361
- const parts = [];
1362
- if (limit !== void 0) {
1363
- const used = remaining !== void 0 ? limit - remaining : limit;
1364
- parts.push(`${used}/${limit} used`);
1365
- }
1366
- if (retryAfterMs !== void 0 && retryAfterMs > 0) {
1367
- parts.push(`retry in ${formatDuration(retryAfterMs)}`);
1368
- }
1369
- if (error.retries > 0) {
1370
- parts.push(
1371
- `after ${error.retries} retr${error.retries === 1 ? "y" : "ies"}`
1372
- );
1373
- }
1374
- if (parts.length > 0) {
1375
- message += `
1376
- ${parts.join(", ")}`;
1377
- }
1887
+ return false;
1888
+ }
1889
+
1890
+ // src/constants.ts
1891
+ var ZAPIER_BASE_URL = globalThis.process?.env?.ZAPIER_BASE_URL || "https://zapier.com";
1892
+ function getZapierSdkService() {
1893
+ return globalThis.process?.env?.ZAPIER_SDK_SERVICE;
1894
+ }
1895
+ var MAX_PAGE_LIMIT = 1e4;
1896
+ var DEFAULT_PAGE_SIZE = 100;
1897
+ var DEFAULT_ACTION_TIMEOUT_MS = 18e4;
1898
+ function parseIntEnvVar(name) {
1899
+ const value = globalThis.process?.env?.[name];
1900
+ if (value === void 0) return void 0;
1901
+ const parsed = parseInt(value, 10);
1902
+ if (isNaN(parsed)) {
1903
+ console.warn(
1904
+ `[zapier-sdk] Invalid value for ${name}: "${value}" (expected integer)`
1905
+ );
1906
+ return void 0;
1378
1907
  }
1379
- if (error.statusCode && !message.includes(`${error.statusCode}`)) {
1380
- message += `
1381
- HTTP Status: ${error.statusCode}`;
1908
+ return parsed;
1909
+ }
1910
+ var ZAPIER_MAX_NETWORK_RETRIES = parseIntEnvVar("ZAPIER_MAX_NETWORK_RETRIES") ?? 3;
1911
+ var ZAPIER_MAX_NETWORK_RETRY_DELAY_MS = parseIntEnvVar("ZAPIER_MAX_NETWORK_RETRY_DELAY_MS") ?? 6e4;
1912
+ var MAX_CONCURRENCY_LIMIT = 1e4;
1913
+ function parseConcurrencyEnvVar(name) {
1914
+ const value = globalThis.process?.env?.[name];
1915
+ if (!value) return void 0;
1916
+ if (value === "Infinity") return Infinity;
1917
+ if (/^[1-9]\d*$/.test(value)) {
1918
+ const parsed = parseInt(value, 10);
1919
+ if (parsed <= MAX_CONCURRENCY_LIMIT) return parsed;
1382
1920
  }
1383
- return message;
1921
+ console.warn(
1922
+ `[zapier-sdk] Invalid value for ${name}: "${value}" (expected positive integer 1-${MAX_CONCURRENCY_LIMIT} or "Infinity")`
1923
+ );
1924
+ return void 0;
1384
1925
  }
1385
- function formatDuration(ms) {
1386
- const seconds = Math.round(ms / 1e3);
1387
- if (seconds < 60) return `${seconds}s`;
1388
- const minutes = Math.round(seconds / 60);
1389
- if (minutes < 60) return `${minutes}m`;
1390
- const hours = Math.round(minutes / 60);
1391
- if (hours < 24) return `${hours}h`;
1392
- const days = Math.round(hours / 24);
1393
- return `${days}d`;
1926
+ var ZAPIER_MAX_CONCURRENT_REQUESTS = parseConcurrencyEnvVar("ZAPIER_MAX_CONCURRENT_REQUESTS") ?? 200;
1927
+ function getZapierApprovalMode() {
1928
+ const value = globalThis.process?.env?.ZAPIER_APPROVAL_MODE;
1929
+ if (value === "disabled" || value === "poll" || value === "throw")
1930
+ return value;
1931
+ return void 0;
1932
+ }
1933
+ function getZapierOpenAutoModeApprovalsInBrowser() {
1934
+ const value = globalThis.process?.env?.ZAPIER_OPEN_AUTO_MODE_APPROVALS_IN_BROWSER;
1935
+ if (value === void 0) return void 0;
1936
+ return value === "true";
1394
1937
  }
1938
+ function getZapierDefaultApprovalMode() {
1939
+ const isInteractive = !!globalThis.process?.stdin?.isTTY && !!globalThis.process?.stdout?.isTTY;
1940
+ return isInteractive ? "poll" : "throw";
1941
+ }
1942
+ var DEFAULT_APPROVAL_TIMEOUT_MS = 10 * 60 * 1e3;
1943
+ var DEFAULT_MAX_APPROVAL_RETRIES = 2;
1395
1944
 
1396
- // src/types/signals.ts
1397
- var ZapierSignal = class extends Error {
1398
- constructor(message) {
1945
+ // src/types/properties.ts
1946
+ var AppKeyPropertySchema = withPositional(
1947
+ zod.z.string().min(1).describe("App key (e.g., 'SlackCLIAPI' or slug like 'github')")
1948
+ );
1949
+ var AppPropertySchema = withPositional(
1950
+ zod.z.string().min(1).describe(
1951
+ "App slug (e.g., 'github'), implementation name (e.g., 'SlackCLIAPI'), or versioned ID (e.g., 'github@1.2.3')"
1952
+ )
1953
+ );
1954
+ var ActionTypePropertySchema = zod.z.enum([
1955
+ "read",
1956
+ "read_bulk",
1957
+ "write",
1958
+ "run",
1959
+ "search",
1960
+ "search_or_write",
1961
+ "search_and_write",
1962
+ "filter"
1963
+ ]).describe("Action type that matches the action's defined type");
1964
+ var ActionKeyPropertySchema = zod.z.string().min(1).describe("Action key to execute");
1965
+ var ActionPropertySchema = withPositional(
1966
+ zod.z.string().min(1).describe("Action key (e.g., 'send_message' or 'find_row')")
1967
+ );
1968
+ var InputFieldPropertySchema = withPositional(
1969
+ zod.z.string().min(1).describe("Input field key to get choices for")
1970
+ );
1971
+ var ConnectionIdPropertySchema = zod.z.union([zod.z.string(), zod.z.number().int().positive()]).describe("Connection ID to use for this action");
1972
+ var AuthenticationIdPropertySchema = ConnectionIdPropertySchema.meta({
1973
+ deprecated: true
1974
+ });
1975
+ var ConnectionPropertySchema = zod.z.union([zod.z.string(), zod.z.number().int().positive()]).describe(
1976
+ "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."
1977
+ );
1978
+ var InputsPropertySchema = zod.z.record(zod.z.string(), zod.z.unknown()).describe("Input parameters for the action");
1979
+ var LimitPropertySchema = zod.z.number().int().min(1).max(MAX_PAGE_LIMIT).default(50).describe("Maximum number of items to return");
1980
+ var OffsetPropertySchema = zod.z.number().int().min(0).default(0).describe("Number of items to skip for pagination");
1981
+ var OutputPropertySchema = zod.z.string().describe("Output file path");
1982
+ var DebugPropertySchema = zod.z.boolean().default(false).describe("Enable debug logging");
1983
+ var ParamsPropertySchema = zod.z.record(zod.z.string(), zod.z.unknown()).describe("Additional parameters");
1984
+ var ActionTimeoutMsPropertySchema = zod.z.number().min(1e3).optional().describe(
1985
+ `Maximum time to wait for action completion in milliseconds (default: ${DEFAULT_ACTION_TIMEOUT_MS})`
1986
+ );
1987
+ var TablePropertySchema = withPositional(
1988
+ zod.z.string().regex(/^[A-Z0-9]{26}$/, "Table ID must be a valid ULID").describe("The unique identifier of the table")
1989
+ );
1990
+ var RecordPropertySchema = withPositional(
1991
+ zod.z.string().regex(/^[A-Z0-9]{26}$/, "Record ID must be a valid ULID").describe("The unique identifier of the record")
1992
+ );
1993
+ 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");
1994
+ var FieldsPropertySchema = zod.z.array(zod.z.union([zod.z.string(), zod.z.number()])).describe(
1995
+ 'Fields to operate on. Accepts field names (e.g., "Email") or IDs (e.g., "f6", "6", or 6).'
1996
+ );
1997
+ var AppsPropertySchema = zod.z.array(zod.z.string()).describe("Filter by app keys (e.g., 'SlackCLIAPI' or slug like 'github')");
1998
+ var TablesPropertySchema = zod.z.array(zod.z.string()).describe("Filter by specific table IDs");
1999
+ var ConnectionsPropertySchema = zod.z.array(zod.z.string()).describe("List of connection IDs to filter by");
2000
+ var TriggerInboxPropertySchema = withPositional(
2001
+ zod.z.string().min(1).describe(
2002
+ "Trigger inbox identifier \u2014 UUID or name. Non-UUID values are resolved by name via the inbox list endpoint."
2003
+ )
2004
+ );
2005
+ var TriggerInboxNamePropertySchema = zod.z.string().min(1).max(100).describe(
2006
+ "Inbox name; unique per (user, account). Enables get-or-create on createTriggerInbox."
2007
+ );
2008
+ var LeasePropertySchema = zod.z.string().min(1).describe("Lease ID returned from leaseTriggerInboxMessages");
2009
+ var LeaseSecondsPropertySchema = zod.z.number().int().min(1).max(3600).describe(
2010
+ "Seconds until the lease expires; messages return to available if not acked. API default is 300 (5 minutes)."
2011
+ );
2012
+ var LeaseLimitPropertySchema = zod.z.number().int().min(1).max(100).describe("Maximum messages to lease in a single batch (1-100)");
2013
+
2014
+ // src/types/errors.ts
2015
+ var _a, _b;
2016
+ var ZapierError = class extends (_b = Error, _a = CORE_ERROR_SYMBOL, _b) {
2017
+ constructor(message, options = {}) {
1399
2018
  super(message);
2019
+ this[_a] = true;
2020
+ this.name = "ZapierError";
2021
+ this.code = "ZAPIER_ERROR";
2022
+ if (options.statusCode !== void 0) this.statusCode = options.statusCode;
2023
+ if (options.errors !== void 0) this.errors = options.errors;
2024
+ if (options.cause !== void 0) this.cause = options.cause;
2025
+ if (options.response !== void 0) this.response = options.response;
1400
2026
  Object.setPrototypeOf(this, new.target.prototype);
1401
2027
  }
1402
2028
  };
1403
- var ZapierReleaseTriggerMessageSignal = class extends ZapierSignal {
1404
- constructor() {
1405
- super(...arguments);
1406
- this.name = "ZapierReleaseTriggerMessageSignal";
1407
- this.code = "ZAPIER_RELEASE_TRIGGER_MESSAGE_SIGNAL";
2029
+ var ZapierValidationError = class extends ZapierError {
2030
+ constructor(message, options = {}) {
2031
+ super(message, options);
2032
+ this.name = "ZapierValidationError";
2033
+ this.code = "ZAPIER_VALIDATION_ERROR";
2034
+ this.details = options.details;
1408
2035
  }
1409
2036
  };
1410
- var ZapierAbortDrainSignal = class extends ZapierSignal {
2037
+ var ZapierUnknownError = class extends ZapierError {
1411
2038
  constructor() {
1412
2039
  super(...arguments);
1413
- this.name = "ZapierAbortDrainSignal";
1414
- this.code = "ZAPIER_ABORT_DRAIN_SIGNAL";
2040
+ this.name = "ZapierUnknownError";
2041
+ this.code = "ZAPIER_UNKNOWN_ERROR";
2042
+ }
2043
+ };
2044
+ var ZapierAuthenticationError = class extends ZapierError {
2045
+ constructor() {
2046
+ super(...arguments);
2047
+ this.name = "ZapierAuthenticationError";
2048
+ this.code = "ZAPIER_AUTHENTICATION_ERROR";
2049
+ }
2050
+ };
2051
+ var zapierAdaptError = (options) => {
2052
+ switch (options.code) {
2053
+ case CoreErrorCode.Validation:
2054
+ return new ZapierValidationError(options.message, {
2055
+ cause: options.cause,
2056
+ details: options.details
2057
+ });
2058
+ case CoreErrorCode.Unknown:
2059
+ return new ZapierUnknownError(options.message, {
2060
+ cause: options.cause
2061
+ });
2062
+ default:
2063
+ return new ZapierError(options.message, { cause: options.cause });
2064
+ }
2065
+ };
2066
+ var ZapierApiError = class extends ZapierError {
2067
+ constructor(message, options = {}) {
2068
+ super(message, options);
2069
+ this.name = "ZapierApiError";
2070
+ this.code = "ZAPIER_API_ERROR";
2071
+ }
2072
+ };
2073
+ var ZapierAppNotFoundError = class extends ZapierError {
2074
+ constructor(message, options = {}) {
2075
+ super(message, options);
2076
+ this.name = "ZapierAppNotFoundError";
2077
+ this.code = "ZAPIER_APP_NOT_FOUND_ERROR";
2078
+ this.appKey = options.appKey;
2079
+ }
2080
+ };
2081
+ var ZapierNotFoundError = class extends ZapierError {
2082
+ constructor(message, options = {}) {
2083
+ super(message, options);
2084
+ this.name = "ZapierNotFoundError";
2085
+ this.code = "ZAPIER_NOT_FOUND_ERROR";
2086
+ }
2087
+ };
2088
+ var ZapierResourceNotFoundError = class extends ZapierNotFoundError {
2089
+ constructor(message, options = {}) {
2090
+ super(message, options);
2091
+ this.name = "ZapierResourceNotFoundError";
2092
+ this.code = "ZAPIER_RESOURCE_NOT_FOUND_ERROR";
2093
+ this.resourceType = options.resourceType;
2094
+ this.resourceId = options.resourceId;
2095
+ }
2096
+ };
2097
+ var ZapierConfigurationError = class extends ZapierError {
2098
+ constructor(message, options = {}) {
2099
+ super(message, options);
2100
+ this.name = "ZapierConfigurationError";
2101
+ this.code = "ZAPIER_CONFIGURATION_ERROR";
2102
+ this.configType = options.configType;
2103
+ }
2104
+ };
2105
+ var ZapierBundleError = class extends ZapierError {
2106
+ constructor(message, options = {}) {
2107
+ super(message, options);
2108
+ this.name = "ZapierBundleError";
2109
+ this.code = "ZAPIER_BUNDLE_ERROR";
2110
+ this.buildErrors = options.buildErrors;
2111
+ }
2112
+ };
2113
+ var ZapierTimeoutError = class extends ZapierError {
2114
+ constructor(message, options = {}) {
2115
+ super(message, options);
2116
+ this.name = "ZapierTimeoutError";
2117
+ this.code = "ZAPIER_TIMEOUT_ERROR";
2118
+ this.attempts = options.attempts;
2119
+ this.maxAttempts = options.maxAttempts;
2120
+ }
2121
+ };
2122
+ var ZapierActionError = class extends ZapierError {
2123
+ constructor(message, options = {}) {
2124
+ super(message, options);
2125
+ this.name = "ZapierActionError";
2126
+ this.code = "ZAPIER_ACTION_ERROR";
2127
+ this.appKey = options.appKey;
2128
+ this.actionKey = options.actionKey;
2129
+ }
2130
+ // Legacy accessor for backward compatibility
2131
+ get actionErrors() {
2132
+ return this.errors;
2133
+ }
2134
+ };
2135
+ var ZapierConflictError = class extends ZapierError {
2136
+ constructor(message, options = {}) {
2137
+ super(message, options);
2138
+ this.name = "ZapierConflictError";
2139
+ this.code = "ZAPIER_CONFLICT_ERROR";
2140
+ this.resourceType = options.resourceType;
2141
+ }
2142
+ };
2143
+ var ZapierRateLimitError = class extends ZapierError {
2144
+ constructor(message, options = {}) {
2145
+ super(message, options);
2146
+ this.name = "ZapierRateLimitError";
2147
+ this.code = "ZAPIER_RATE_LIMIT_ERROR";
2148
+ this.rateLimit = options.rateLimit ?? {};
2149
+ this.retries = options.retries ?? 0;
2150
+ }
2151
+ };
2152
+ var ZapierApprovalError = class extends ZapierError {
2153
+ constructor(message, options = {}) {
2154
+ super(message, options);
2155
+ this.name = "ZapierApprovalError";
2156
+ this.code = "ZAPIER_APPROVAL_ERROR";
2157
+ this.approvalId = options.approvalId;
2158
+ this.approvalStatus = options.status;
2159
+ this.approvalUrl = options.approvalUrl;
2160
+ this.pollUrl = options.pollUrl;
2161
+ this.streamUrl = options.streamUrl;
2162
+ this.reason = options.reason;
2163
+ }
2164
+ };
2165
+ var ZapierRelayError = class extends ZapierError {
2166
+ constructor(message, options = {}) {
2167
+ super(message, options);
2168
+ this.name = "ZapierRelayError";
2169
+ this.code = "ZAPIER_RELAY_ERROR";
2170
+ }
2171
+ };
2172
+ function formatErrorMessage(error) {
2173
+ let message = error.message;
2174
+ if (error.errors && error.errors.length > 0) {
2175
+ const additionalErrors = error.errors.slice(1);
2176
+ if (additionalErrors.length > 0) {
2177
+ const errorDetails = additionalErrors.map((err) => ` \u2022 ${err.detail || err.title || err.code}`).join("\n");
2178
+ message += "\n\nAdditional errors:\n" + errorDetails;
2179
+ }
2180
+ }
2181
+ if (error instanceof ZapierAppNotFoundError && error.appKey) {
2182
+ message += `
2183
+ App key: ${error.appKey}`;
2184
+ }
2185
+ if (error instanceof ZapierActionError && (error.appKey || error.actionKey)) {
2186
+ const context = [];
2187
+ if (error.appKey) context.push(`App: ${error.appKey}`);
2188
+ if (error.actionKey) context.push(`Action: ${error.actionKey}`);
2189
+ message += `
2190
+ ${context.join(", ")}`;
2191
+ }
2192
+ if (error instanceof ZapierResourceNotFoundError && (error.resourceType || error.resourceId)) {
2193
+ const context = [];
2194
+ if (error.resourceType) context.push(`Type: ${error.resourceType}`);
2195
+ if (error.resourceId) context.push(`ID: ${error.resourceId}`);
2196
+ message += `
2197
+ ${context.join(", ")}`;
2198
+ }
2199
+ if (error instanceof ZapierConflictError && error.resourceType) {
2200
+ message += `
2201
+ Type: ${error.resourceType}`;
2202
+ }
2203
+ if (error instanceof ZapierTimeoutError && (error.attempts || error.maxAttempts)) {
2204
+ const context = [];
2205
+ if (error.attempts) context.push(`Attempts: ${error.attempts}`);
2206
+ if (error.maxAttempts) context.push(`Max attempts: ${error.maxAttempts}`);
2207
+ message += `
2208
+ ${context.join(", ")}`;
2209
+ }
2210
+ if (error instanceof ZapierBundleError && error.buildErrors && error.buildErrors.length > 0) {
2211
+ message += "\n\nBuild errors:\n" + error.buildErrors.map((err) => ` \u2022 ${err}`).join("\n");
2212
+ }
2213
+ if (error instanceof ZapierApprovalError && error.approvalUrl) {
2214
+ message += `
2215
+ Approval URL: ${error.approvalUrl}`;
2216
+ }
2217
+ if (error instanceof ZapierRateLimitError) {
2218
+ const { limit, remaining, retryAfterMs } = error.rateLimit;
2219
+ const parts = [];
2220
+ if (limit !== void 0) {
2221
+ const used = remaining !== void 0 ? limit - remaining : limit;
2222
+ parts.push(`${used}/${limit} used`);
2223
+ }
2224
+ if (retryAfterMs !== void 0 && retryAfterMs > 0) {
2225
+ parts.push(`retry in ${formatDuration(retryAfterMs)}`);
2226
+ }
2227
+ if (error.retries > 0) {
2228
+ parts.push(
2229
+ `after ${error.retries} retr${error.retries === 1 ? "y" : "ies"}`
2230
+ );
2231
+ }
2232
+ if (parts.length > 0) {
2233
+ message += `
2234
+ ${parts.join(", ")}`;
2235
+ }
2236
+ }
2237
+ if (error.statusCode && !message.includes(`${error.statusCode}`)) {
2238
+ message += `
2239
+ HTTP Status: ${error.statusCode}`;
2240
+ }
2241
+ return message;
2242
+ }
2243
+ function formatDuration(ms) {
2244
+ const seconds = Math.round(ms / 1e3);
2245
+ if (seconds < 60) return `${seconds}s`;
2246
+ const minutes = Math.round(seconds / 60);
2247
+ if (minutes < 60) return `${minutes}m`;
2248
+ const hours = Math.round(minutes / 60);
2249
+ if (hours < 24) return `${hours}h`;
2250
+ const days = Math.round(hours / 24);
2251
+ return `${days}d`;
2252
+ }
2253
+
2254
+ // src/types/signals.ts
2255
+ var ZapierSignal = class extends Error {
2256
+ constructor(message) {
2257
+ super(message);
2258
+ Object.setPrototypeOf(this, new.target.prototype);
2259
+ }
2260
+ };
2261
+ var ZapierReleaseTriggerMessageSignal = class extends ZapierSignal {
2262
+ constructor() {
2263
+ super(...arguments);
2264
+ this.name = "ZapierReleaseTriggerMessageSignal";
2265
+ this.code = "ZAPIER_RELEASE_TRIGGER_MESSAGE_SIGNAL";
2266
+ }
2267
+ };
2268
+ var ZapierAbortDrainSignal = class extends ZapierSignal {
2269
+ constructor() {
2270
+ super(...arguments);
2271
+ this.name = "ZapierAbortDrainSignal";
2272
+ this.code = "ZAPIER_ABORT_DRAIN_SIGNAL";
1415
2273
  }
1416
2274
  };
1417
2275
  var TriggerInboxCommandBaseSchema = zod.z.object({
@@ -4898,7 +5756,7 @@ var actionResultItemFormatter = {
4898
5756
  id: getStringProperty(obj, "id"),
4899
5757
  key: getStringProperty(obj, "key"),
4900
5758
  description: getStringProperty(obj, "description"),
4901
- data: item,
5759
+ raw: item,
4902
5760
  details: []
4903
5761
  };
4904
5762
  }
@@ -5647,8 +6505,10 @@ var UserProfileItemSchema = zod.z.object({
5647
6505
  });
5648
6506
 
5649
6507
  // src/formatters/userProfile.ts
5650
- var userProfileItemFormatter = {
5651
- format: (item) => {
6508
+ var userProfileItemFormatter = defineFormatter({
6509
+ format: ({
6510
+ item
6511
+ }) => {
5652
6512
  const details = [];
5653
6513
  if (item.email) {
5654
6514
  details.push({ text: item.email, style: "dim" });
@@ -5661,41 +6521,38 @@ var userProfileItemFormatter = {
5661
6521
  }
5662
6522
  return {
5663
6523
  title: item.full_name,
5664
- id: item.id,
6524
+ hint: item.id,
5665
6525
  details
5666
6526
  };
5667
6527
  }
5668
- };
6528
+ });
5669
6529
 
5670
6530
  // src/plugins/getProfile/index.ts
5671
- var getProfilePlugin = definePlugin(
5672
- (sdk) => createPluginMethod(sdk, {
5673
- name: "getProfile",
5674
- categories: ["account"],
5675
- type: "item",
5676
- itemType: "Profile",
5677
- inputSchema: GetProfileSchema,
5678
- outputSchema: UserProfileItemSchema,
5679
- formatter: userProfileItemFormatter,
5680
- handler: async ({ sdk: sdk2 }) => {
5681
- const profile = await sdk2.context.api.get(
5682
- "/zapier/api/v4/profile/",
5683
- { authRequired: true }
5684
- );
5685
- return {
5686
- data: {
5687
- id: String(profile.public_id ?? profile.id),
5688
- first_name: profile.first_name,
5689
- last_name: profile.last_name,
5690
- full_name: `${profile.first_name} ${profile.last_name}`,
5691
- email: profile.email,
5692
- email_confirmed: profile.email_confirmed,
5693
- timezone: profile.timezone
5694
- }
5695
- };
5696
- }
5697
- })
5698
- );
6531
+ var getProfilePlugin = defineMethod({
6532
+ name: "getProfile",
6533
+ imports: [dangerousContextPlugin],
6534
+ inputSchema: GetProfileSchema,
6535
+ output: "item",
6536
+ formatter: userProfileItemFormatter,
6537
+ categories: ["account"],
6538
+ itemType: "Profile",
6539
+ outputSchema: UserProfileItemSchema,
6540
+ run: async ({ imports }) => {
6541
+ const api = imports.context.api;
6542
+ const profile = await api.get("/zapier/api/v4/profile/", {
6543
+ authRequired: true
6544
+ });
6545
+ return {
6546
+ id: String(profile.public_id ?? profile.id),
6547
+ first_name: profile.first_name,
6548
+ last_name: profile.last_name,
6549
+ full_name: `${profile.first_name} ${profile.last_name}`,
6550
+ email: profile.email,
6551
+ email_confirmed: profile.email_confirmed,
6552
+ timezone: profile.timezone
6553
+ };
6554
+ }
6555
+ });
5699
6556
 
5700
6557
  // src/api/auth.ts
5701
6558
  function isJwt(token) {
@@ -6997,7 +7854,7 @@ function parseApprovalReviewStreamPayload(parsed, toolNames) {
6997
7854
  }
6998
7855
 
6999
7856
  // src/sdk-version.ts
7000
- var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.77.1" : void 0) || "unknown";
7857
+ var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.78.0" : void 0) || "unknown";
7001
7858
 
7002
7859
  // src/utils/open-url.ts
7003
7860
  var nodePrefix = "node:";
@@ -8242,182 +9099,401 @@ var apiPlugin = definePlugin(
8242
9099
  }
8243
9100
  );
8244
9101
 
8245
- // src/utils/batch-utils.ts
8246
- var DEFAULT_CONCURRENCY = 10;
8247
- var BATCH_START_DELAY_MS = 25;
8248
- var DEFAULT_BATCH_TIMEOUT_MS = 18e4;
8249
- async function batch(tasks, options = {}) {
8250
- const {
8251
- concurrency = DEFAULT_CONCURRENCY,
8252
- retry = true,
8253
- batchDelay = BATCH_START_DELAY_MS,
8254
- timeoutMs = DEFAULT_BATCH_TIMEOUT_MS,
8255
- taskTimeoutMs
8256
- } = options;
8257
- if (concurrency <= 0) {
8258
- throw new Error("Concurrency must be greater than 0");
8259
- }
8260
- if (timeoutMs <= 0) {
8261
- throw new Error("Timeout must be greater than 0");
8262
- }
8263
- if (taskTimeoutMs !== void 0 && taskTimeoutMs <= 0) {
8264
- throw new Error("Task timeout must be greater than 0");
8265
- }
8266
- if (tasks.length === 0) {
8267
- return [];
8268
- }
8269
- const startTime = Date.now();
8270
- const results = new Array(tasks.length);
8271
- const taskQueue = tasks.map((task, index) => ({
8272
- index,
8273
- task,
8274
- errorCount: 0
8275
- }));
8276
- async function executeTask(taskState) {
8277
- const { index, task, errorCount } = taskState;
8278
- try {
8279
- let result;
8280
- if (taskTimeoutMs !== void 0) {
8281
- const timeoutPromise = sleep(taskTimeoutMs).then(() => {
9102
+ // src/core-stack.ts
9103
+ var zapierCorePlugin = createCorePlugin({
9104
+ adaptError: zapierAdaptError
9105
+ });
9106
+ function createZapierCoreStack() {
9107
+ return createPluginStack().use(zapierCorePlugin);
9108
+ }
9109
+ var GetConnectionStartUrlSchema = zod.z.object({
9110
+ app: AppPropertySchema
9111
+ }).describe(
9112
+ "Mint a short-lived URL that begins an SDK-initiated connection flow. The URL is signed by zapier.com and bound to the current user/account \u2014 opening it in a different browser session will fail the binding check. Returns the URL as data so the caller decides what to do with it.\n\nUse this directly (rather than the higher-level `create-connection`) when you want either of: (a) hand off the URL and *not* block waiting for completion \u2014 call this alone, skip `wait-for-new-connection` entirely, or (b) do something custom between minting the URL and waiting for the connection \u2014 call this, then email or DM the URL, render it as a QR code for mobile sign-in, etc., then call `wait-for-new-connection`. For the common case where you'd just print and poll back-to-back, `create-connection` is one call.\n\nPair with `wait-for-new-connection` to detect completion: pass the `startedAt` returned here straight through (it's the server's mint time, so polling isn't affected by client clock skew). Example (JS):\n\n```ts\nconst { data: { url, app, startedAt } } = await zapier.getConnectionStartUrl({ app: 'slack' });\n// hand `url` off \u2014 print it, DM it, email it, render a button, whatever\nconst { data: conn } = await zapier.waitForNewConnection({ app, startedAt });\n```"
9113
+ );
9114
+ var GetConnectionStartUrlItemSchema = zod.z.object({
9115
+ url: zod.z.string().describe(
9116
+ "URL the user should open in their browser to complete the auth flow. Single-use, time-limited."
9117
+ ),
9118
+ expiresAt: zod.z.number().describe(
9119
+ "Unix timestamp (seconds) after which the URL's signature is rejected by zapier.com."
9120
+ ),
9121
+ startedAt: zod.z.number().describe(
9122
+ "Unix timestamp (seconds) when the server minted the URL. Use it as the `startedAt` for `wait-for-new-connection` so polling is anchored to server time rather than a possibly-skewed client clock."
9123
+ ),
9124
+ app: zod.z.string().describe(
9125
+ "Versionless app key the URL was minted for (e.g., 'SlackCLIAPI'). Useful for downstream filtering."
9126
+ )
9127
+ }).describe(
9128
+ "The signed start-URL plus metadata needed to poll for completion."
9129
+ );
9130
+
9131
+ // src/plugins/getConnectionStartUrl/index.ts
9132
+ var START_PATH = "/zapier/api/authentications/v1/sdk/connections/start";
9133
+ var getConnectionStartUrlPlugin = definePlugin(
9134
+ (sdk) => createPluginMethod(sdk, {
9135
+ name: "getConnectionStartUrl",
9136
+ categories: ["connection"],
9137
+ type: "create",
9138
+ itemType: "ConnectionStartUrl",
9139
+ inputSchema: GetConnectionStartUrlSchema,
9140
+ outputSchema: GetConnectionStartUrlItemSchema,
9141
+ resolvers: { app: appKeyResolver },
9142
+ handler: async ({
9143
+ sdk: inner,
9144
+ options
9145
+ }) => {
9146
+ const versionedKey = await inner.context.getVersionedImplementationId(
9147
+ options.app
9148
+ );
9149
+ const selectedApi = versionedKey ? versionedKey.split("@")[0] : options.app;
9150
+ setMethodMetadata({ selectedApi });
9151
+ const response = await inner.context.api.post(
9152
+ START_PATH,
9153
+ { selected_api: selectedApi },
9154
+ { authRequired: true }
9155
+ );
9156
+ return {
9157
+ data: GetConnectionStartUrlItemSchema.parse({
9158
+ url: response.url,
9159
+ expiresAt: response.expires_at,
9160
+ startedAt: response.started_at,
9161
+ app: selectedApi
9162
+ })
9163
+ };
9164
+ }
9165
+ })
9166
+ );
9167
+ var WaitForNewConnectionSchema = zod.z.object({
9168
+ app: AppPropertySchema,
9169
+ startedAt: zod.z.number().int().nonnegative().describe(
9170
+ "Unix timestamp (seconds). Only connections whose `date` is at or after this value count as 'new'. Prefer the `startedAt` returned by `get-connection-start-url` \u2014 it's server-stamped, so the comparison isn't thrown off by client clock skew. If you mint the timestamp yourself, capture it *before* showing the start URL so a fast OAuth completion isn't missed."
9171
+ ),
9172
+ timeoutMs: zod.z.number().int().positive().optional().describe(
9173
+ "How long to wait before giving up. Default 5 minutes (300_000)."
9174
+ ),
9175
+ pollIntervalMs: zod.z.number().int().positive().optional().describe(
9176
+ "Delay before the first poll request, in ms. Default 3 seconds (3_000). Subsequent polling cadence is managed by the SDK's polling primitive (backoff with sane defaults)."
9177
+ )
9178
+ }).describe(
9179
+ "Wait for a new connection to appear for the given app. Polls `/api/v0/connections` with server-side `ordering=-date` until the most recent matching row's `date` is at or after the started-at timestamp, then returns it. Pair with `get-connection-start-url` \u2014 that mints the URL the user opens, this waits for the resulting connection to land. Errors with a timeout after the configured timeout (default 5 min). Example (JS):\n\n```ts\nconst { data: { url, app, startedAt } } = await zapier.getConnectionStartUrl({ app: 'slack' });\n// show `url` to the user via the channel they're reading from\nconst { data: conn } = await zapier.waitForNewConnection({ app, startedAt });\n```"
9180
+ );
9181
+ var WaitForNewConnectionItemSchema = zod.z.object({
9182
+ id: zod.z.string().describe(
9183
+ "The new connection's ID. Public UUID when available, falling back to the numeric ID."
9184
+ ),
9185
+ app: zod.z.string().describe(
9186
+ "Versionless app key the connection was created for (e.g., 'SlackCLIAPI')."
9187
+ ),
9188
+ title: zod.z.string().nullable().optional().describe(
9189
+ "Human-readable connection title set by the auth flow, when available."
9190
+ )
9191
+ }).describe("The new connection that was detected.");
9192
+
9193
+ // src/plugins/waitForNewConnection/index.ts
9194
+ var CONNECTIONS_PATH = "/api/v0/connections";
9195
+ var waitForNewConnectionPlugin = definePlugin(
9196
+ (sdk) => createPluginMethod(sdk, {
9197
+ name: "waitForNewConnection",
9198
+ categories: ["connection"],
9199
+ type: "item",
9200
+ itemType: "Connection",
9201
+ inputSchema: WaitForNewConnectionSchema,
9202
+ outputSchema: WaitForNewConnectionItemSchema,
9203
+ resolvers: { app: appKeyResolver },
9204
+ handler: async ({
9205
+ sdk: inner,
9206
+ options
9207
+ }) => {
9208
+ const versionedKey = await inner.context.getVersionedImplementationId(
9209
+ options.app
9210
+ );
9211
+ const appKey = versionedKey ? versionedKey.split("@")[0] : options.app;
9212
+ setMethodMetadata({ selectedApi: appKey });
9213
+ try {
9214
+ const top = await inner.context.api.poll(
9215
+ CONNECTIONS_PATH,
9216
+ {
9217
+ searchParams: {
9218
+ app_key: appKey,
9219
+ // Scope to the current user's own connections. The connection
9220
+ // we're waiting on is by definition owned by the caller; without
9221
+ // this the one-row head-check could match a teammate's freshly
9222
+ // created connection for the same app.
9223
+ owner: "me",
9224
+ is_expired: "false",
9225
+ ordering: "-date",
9226
+ page_size: "1"
9227
+ },
9228
+ authRequired: true,
9229
+ timeoutMs: options.timeoutMs ?? 3e5,
9230
+ initialDelay: options.pollIntervalMs ?? 3e3,
9231
+ isPending: (body) => {
9232
+ const rows = body.data ?? [];
9233
+ const head = rows[0];
9234
+ if (!head?.date) return true;
9235
+ const created = Math.floor(new Date(head.date).getTime() / 1e3);
9236
+ return !Number.isFinite(created) || created < options.startedAt;
9237
+ },
9238
+ resultExtractor: (body) => (
9239
+ // `isPending` guaranteed a fresh row at index 0 before this fires.
9240
+ body.data[0]
9241
+ )
9242
+ }
9243
+ );
9244
+ return {
9245
+ data: WaitForNewConnectionItemSchema.parse({
9246
+ id: String(top.public_id ?? top.id),
9247
+ app: appKey,
9248
+ title: top.title ?? null
9249
+ })
9250
+ };
9251
+ } catch (err) {
9252
+ if (err instanceof ZapierTimeoutError) {
8282
9253
  throw new ZapierTimeoutError(
8283
- `Task timed out after ${taskTimeoutMs}ms`
9254
+ `Timed out waiting for a new "${appKey}" connection. If the user completed the auth flow, retrieve the connection via sdk.getConnection({ id }) with the ID shown on the completion page.`
8284
9255
  );
8285
- });
8286
- result = await Promise.race([task(), timeoutPromise]);
8287
- } else {
8288
- result = await task();
8289
- }
8290
- results[index] = { status: "fulfilled", value: result };
8291
- } catch (error) {
8292
- const newErrorCount = errorCount + 1;
8293
- const isTimeout = error instanceof ZapierTimeoutError;
8294
- if (retry && !isTimeout && newErrorCount < MAX_CONSECUTIVE_ERRORS) {
8295
- const waitTime = calculateErrorBackoffMs(1e3, newErrorCount);
8296
- await sleep(waitTime);
8297
- taskQueue.push({
8298
- index,
8299
- task,
8300
- errorCount: newErrorCount
8301
- });
8302
- } else {
8303
- results[index] = { status: "rejected", reason: error };
9256
+ }
9257
+ throw err;
8304
9258
  }
8305
9259
  }
9260
+ })
9261
+ );
9262
+
9263
+ // src/utils/should-open-browser.ts
9264
+ function shouldOpenBrowser() {
9265
+ if (isCiEnv()) return false;
9266
+ const env = globalThis.process?.env;
9267
+ if (env?.SSH_TTY || env?.SSH_CONNECTION) return false;
9268
+ if (globalThis.process?.platform === "linux" && !env?.DISPLAY && !env?.WAYLAND_DISPLAY) {
9269
+ return false;
8306
9270
  }
8307
- async function worker() {
8308
- while (taskQueue.length > 0) {
8309
- const elapsedTime = Date.now() - startTime;
8310
- if (elapsedTime >= timeoutMs) {
8311
- throw new ZapierTimeoutError(
8312
- `Batch operation timed out after ${Math.floor(elapsedTime / 1e3)}s. ${taskQueue.length} task(s) not completed.`
8313
- );
9271
+ return true;
9272
+ }
9273
+ function isCiEnv() {
9274
+ const env = globalThis.process?.env;
9275
+ return !!(env?.CI || env?.CONTINUOUS_INTEGRATION || env?.GITHUB_ACTIONS || env?.JENKINS_URL || env?.GITLAB_CI || env?.CIRCLECI || env?.TRAVIS || env?.BUILDKITE || env?.DRONE || env?.BITBUCKET_PIPELINES_UUID);
9276
+ }
9277
+ var CreateConnectionSchema = zod.z.object({
9278
+ app: AppPropertySchema,
9279
+ browser: zod.z.enum(["auto", "always", "never"]).default("auto").describe(
9280
+ "When to auto-open the URL in a browser. `auto` (default) opens in local sessions and skips opening in CI / SSH / headless-Linux. `always` forces the open attempt. `never` skips it. The URL is always printed to stderr regardless \u2014 a failed or skipped open degrades gracefully to copy-paste."
9281
+ ),
9282
+ timeoutMs: zod.z.number().int().positive().optional().describe(
9283
+ "How long to wait for the user to complete the connection flow before giving up. Default 5 minutes (300_000)."
9284
+ ),
9285
+ pollIntervalMs: zod.z.number().int().positive().optional().describe(
9286
+ "Delay before the first poll request, in ms. Default 3 seconds (3_000). Subsequent polling cadence is managed by the SDK's polling primitive (backoff with sane defaults)."
9287
+ )
9288
+ }).describe(
9289
+ "Create a new app connection, end-to-end. Mints the start URL via `get-connection-start-url`, prints it to stderr, opportunistically opens it in a browser when it looks safe to do so (skipping CI / SSH / headless-Linux by default \u2014 pass `--browser always` to force, `--browser never` to suppress), then polls via `wait-for-new-connection` until the user completes OAuth and the new connection appears. Returns the connection.\n\nThis is the right command for most callers. Reach for the lower-level building blocks when you want either of: (a) hand off the URL and *not* block on completion \u2014 call `get-connection-start-url` alone, no `wait-for-new-connection` needed, or (b) do something custom between minting the URL and waiting \u2014 call `get-connection-start-url`, do your work (email or DM the URL, render a QR code, etc.), then `wait-for-new-connection`."
9290
+ );
9291
+ var CreateConnectionItemSchema = zod.z.object({
9292
+ id: zod.z.string().describe(
9293
+ "The new connection's ID. Public UUID when available, falling back to the numeric ID."
9294
+ ),
9295
+ app: zod.z.string().describe(
9296
+ "Versionless app key the connection was created for (e.g., 'SlackCLIAPI')."
9297
+ ),
9298
+ title: zod.z.string().nullable().optional().describe(
9299
+ "Human-readable connection title set by the auth flow, when available."
9300
+ )
9301
+ }).describe("The newly created connection.");
9302
+
9303
+ // src/plugins/createConnection/index.ts
9304
+ var createConnectionPlugin = definePlugin(
9305
+ (sdk) => createPluginMethod(sdk, {
9306
+ name: "createConnection",
9307
+ categories: ["connection"],
9308
+ type: "create",
9309
+ itemType: "Connection",
9310
+ inputSchema: CreateConnectionSchema,
9311
+ outputSchema: CreateConnectionItemSchema,
9312
+ resolvers: { app: appKeyResolver },
9313
+ formatter: {
9314
+ format: (item) => ({
9315
+ title: `Connection created: ${item.title || item.id}`,
9316
+ id: item.id,
9317
+ details: [
9318
+ { text: `App: ${item.app}`, style: "normal" },
9319
+ { text: `ID: ${item.id}`, style: "accent" }
9320
+ ]
9321
+ })
9322
+ },
9323
+ handler: async ({
9324
+ sdk: inner,
9325
+ options
9326
+ }) => {
9327
+ const { data: start } = await inner.getConnectionStartUrl({
9328
+ app: options.app
9329
+ });
9330
+ setMethodMetadata({ selectedApi: start.app });
9331
+ console.error(
9332
+ `
9333
+ Open this URL to complete the connection:
9334
+ ${start.url}
9335
+ `
9336
+ );
9337
+ const shouldOpen = options.browser === "always" || options.browser === "auto" && shouldOpenBrowser();
9338
+ if (shouldOpen) {
9339
+ try {
9340
+ await open_url_default(start.url);
9341
+ } catch {
9342
+ }
8314
9343
  }
8315
- const taskState = taskQueue.shift();
8316
- if (!taskState) break;
8317
- await executeTask(taskState);
8318
- if (taskQueue.length > 0 && batchDelay > 0) {
8319
- await sleep(batchDelay);
9344
+ const { data: fresh } = await inner.waitForNewConnection({
9345
+ app: start.app,
9346
+ // Server-stamped mint time: measured on the same clock as a
9347
+ // connection's `date`, so the freshness check is immune to
9348
+ // client/server clock skew.
9349
+ startedAt: start.startedAt,
9350
+ timeoutMs: options.timeoutMs,
9351
+ pollIntervalMs: options.pollIntervalMs
9352
+ });
9353
+ return {
9354
+ data: CreateConnectionItemSchema.parse({
9355
+ id: fresh.id,
9356
+ app: start.app,
9357
+ title: fresh.title ?? null
9358
+ })
9359
+ };
9360
+ }
9361
+ })
9362
+ );
9363
+
9364
+ // src/plugins/deprecated/authentications.ts
9365
+ var listAuthenticationsPlugin = definePlugin(
9366
+ (sdk) => ({
9367
+ listAuthentications: sdk.listConnections,
9368
+ context: {
9369
+ meta: {
9370
+ listAuthentications: {
9371
+ packages: ["cli", "mcp"],
9372
+ categories: ["connection"],
9373
+ deprecation: { message: "Use listConnections instead." },
9374
+ type: "list",
9375
+ itemType: "Connection",
9376
+ inputSchema: ListConnectionsQuerySchema,
9377
+ outputSchema: ConnectionItemSchema,
9378
+ formatter: connectionItemFormatter
9379
+ }
8320
9380
  }
8321
9381
  }
8322
- }
8323
- const workerCount = Math.min(concurrency, tasks.length);
8324
- const workers = [];
8325
- for (let i = 0; i < workerCount; i++) {
8326
- workers.push(worker());
8327
- if (i < workerCount - 1 && batchDelay > 0) {
8328
- await sleep(batchDelay / 10);
9382
+ })
9383
+ );
9384
+ var getAuthenticationPlugin = definePlugin(
9385
+ (sdk) => ({
9386
+ getAuthentication: sdk.getConnection,
9387
+ context: {
9388
+ meta: {
9389
+ getAuthentication: {
9390
+ packages: ["cli", "mcp"],
9391
+ categories: ["connection"],
9392
+ deprecation: { message: "Use getConnection instead." },
9393
+ type: "item",
9394
+ itemType: "Connection",
9395
+ inputSchema: GetConnectionParamSchema,
9396
+ outputSchema: ConnectionItemSchema,
9397
+ formatter: connectionItemFormatter
9398
+ }
9399
+ }
8329
9400
  }
8330
- }
8331
- await Promise.all(workers);
8332
- return results;
8333
- }
8334
-
8335
- // src/plugins/connections/index.ts
8336
- var connectionsPlugin = definePlugin(
8337
- (sdk) => {
8338
- let cachedMap;
8339
- async function loadConnectionsMap() {
8340
- if (cachedMap === void 0) {
8341
- cachedMap = await sdk.context.getManifestConnections() ?? null;
9401
+ })
9402
+ );
9403
+ var findFirstAuthenticationPlugin = definePlugin(
9404
+ (sdk) => ({
9405
+ findFirstAuthentication: sdk.findFirstConnection,
9406
+ context: {
9407
+ meta: {
9408
+ findFirstAuthentication: {
9409
+ packages: ["cli", "mcp"],
9410
+ categories: ["connection"],
9411
+ deprecation: { message: "Use findFirstConnection instead." },
9412
+ type: "item",
9413
+ itemType: "Connection",
9414
+ inputSchema: FindFirstConnectionSchema,
9415
+ outputSchema: ConnectionItemSchema,
9416
+ formatter: connectionItemFormatter
9417
+ }
8342
9418
  }
8343
- return cachedMap;
8344
9419
  }
8345
- return {
8346
- context: {
8347
- resolveConnection: async (name) => {
8348
- const map = await loadConnectionsMap();
8349
- return map?.[name];
8350
- },
8351
- getConnectionsMap: async () => {
8352
- return loadConnectionsMap();
9420
+ })
9421
+ );
9422
+ var findUniqueAuthenticationPlugin = definePlugin(
9423
+ (sdk) => ({
9424
+ findUniqueAuthentication: sdk.findUniqueConnection,
9425
+ context: {
9426
+ meta: {
9427
+ findUniqueAuthentication: {
9428
+ packages: ["cli", "mcp"],
9429
+ categories: ["connection"],
9430
+ deprecation: { message: "Use findUniqueConnection instead." },
9431
+ type: "item",
9432
+ itemType: "Connection",
9433
+ inputSchema: FindUniqueConnectionSchema,
9434
+ outputSchema: ConnectionItemSchema,
9435
+ formatter: connectionItemFormatter
9436
+ }
9437
+ }
9438
+ }
9439
+ })
9440
+ );
9441
+
9442
+ // src/plugins/deprecated/inputFields.ts
9443
+ var listInputFieldsDeprecatedPlugin = definePlugin(
9444
+ (sdk) => ({
9445
+ listInputFields: sdk.listActionInputFields,
9446
+ context: {
9447
+ meta: {
9448
+ listInputFields: {
9449
+ categories: ["action"],
9450
+ deprecation: { message: "Use listActionInputFields instead." },
9451
+ type: "list",
9452
+ itemType: "RootField",
9453
+ inputSchema: ListActionInputFieldsInputSchema,
9454
+ outputSchema: RootFieldItemSchema,
9455
+ formatter: rootFieldItemFormatter,
9456
+ defaultPageSize: DEFAULT_PAGE_SIZE
8353
9457
  }
8354
9458
  }
8355
- };
8356
- }
9459
+ }
9460
+ })
8357
9461
  );
8358
-
8359
- // src/plugins/capabilities/index.ts
8360
- function toDescription(key) {
8361
- const words = key.replace(/^can/, "").replace(/([A-Z])/g, " $1").trim().toLowerCase();
8362
- return `To ${words}`;
8363
- }
8364
- function toEnvVar(key) {
8365
- return "ZAPIER_" + key.replace(/([A-Z])/g, "_$1").toUpperCase();
8366
- }
8367
- function toCliFlag(key) {
8368
- return "--" + key.replace(/([A-Z])/g, "-$1").toLowerCase();
8369
- }
8370
- function buildCapabilityMessage(key) {
8371
- return [
8372
- `${toDescription(key)}, use ${toCliFlag(key)} in the CLI,`,
8373
- `set ${key}: true in SDK options or .zapierrc,`,
8374
- `or set ${toEnvVar(key)}=true.`
8375
- ].join(" ");
8376
- }
8377
- var GATED_FLAGS = [
8378
- "canIncludeSharedConnections",
8379
- "canIncludeSharedTables",
8380
- "canDeleteTables"
8381
- ];
8382
- function isEnabledByEnv(key) {
8383
- const value = globalThis.process?.env?.[toEnvVar(key)];
8384
- if (value === void 0) return void 0;
8385
- if (value === "true" || value === "1") return true;
8386
- if (value === "false" || value === "0") return false;
8387
- return void 0;
8388
- }
8389
- var capabilitiesPlugin = definePlugin(
8390
- (sdk) => {
8391
- const options = sdk.context.options ?? {};
8392
- let cached;
8393
- async function resolveFlags() {
8394
- if (cached) return cached;
8395
- const manifest = await sdk.context.getResolvedManifest();
8396
- cached = {};
8397
- for (const flag of GATED_FLAGS) {
8398
- cached[flag] = Boolean(
8399
- options[flag] ?? isEnabledByEnv(flag) ?? manifest?.[flag]
8400
- );
9462
+ var listInputFieldChoicesDeprecatedPlugin = definePlugin(
9463
+ (sdk) => ({
9464
+ listInputFieldChoices: sdk.listActionInputFieldChoices,
9465
+ context: {
9466
+ meta: {
9467
+ listInputFieldChoices: {
9468
+ categories: ["action"],
9469
+ deprecation: {
9470
+ message: "Use listActionInputFieldChoices instead."
9471
+ },
9472
+ type: "list",
9473
+ itemType: "InputFieldChoiceItem",
9474
+ inputSchema: ListActionInputFieldChoicesInputSchema,
9475
+ outputSchema: InputFieldChoiceItemSchema,
9476
+ formatter: inputFieldChoiceItemFormatter,
9477
+ defaultPageSize: DEFAULT_PAGE_SIZE
9478
+ }
8401
9479
  }
8402
- return cached;
8403
9480
  }
8404
- return {
8405
- context: {
8406
- checkCapability: async (key) => {
8407
- const flags = await resolveFlags();
8408
- if (flags[key]) return;
8409
- throw new ZapierConfigurationError(
8410
- buildCapabilityMessage(key) + " (If you are an AI agent, you MUST NOT retry. Ask the user if they want to enable this.)",
8411
- { configType: key }
8412
- );
8413
- },
8414
- hasCapability: async (key) => {
8415
- const flags = await resolveFlags();
8416
- return flags[key];
9481
+ })
9482
+ );
9483
+ var getInputFieldsSchemaDeprecatedPlugin = definePlugin(
9484
+ (sdk) => ({
9485
+ getInputFieldsSchema: sdk.getActionInputFieldsSchema,
9486
+ context: {
9487
+ meta: {
9488
+ getInputFieldsSchema: {
9489
+ categories: ["action"],
9490
+ deprecation: { message: "Use getActionInputFieldsSchema instead." },
9491
+ type: "function",
9492
+ inputSchema: GetActionInputFieldsSchemaInputSchema
8417
9493
  }
8418
9494
  }
8419
- };
8420
- }
9495
+ }
9496
+ })
8421
9497
  );
8422
9498
  var TableApiItemSchema = zod.z.object({
8423
9499
  id: zod.z.string(),
@@ -8534,256 +9610,67 @@ var listTablesPlugin = definePlugin(
8534
9610
  }
8535
9611
  })
8536
9612
  );
8537
- var GetTableApiResponseSchema = zod.z.object({
8538
- data: TableApiItemSchema
8539
- });
8540
- var GetTableDescription = "Get detailed information about a specific table";
8541
- var GetTableOptionsSchema = zod.z.object({
8542
- table: TablePropertySchema
8543
- }).describe(GetTableDescription).meta({ aliases: { tableId: "table" } });
8544
- var GetTableOptionsSchemaDeprecated = zod.z.object({
8545
- tableId: zod.z.string().regex(/^[A-Z0-9]{26}$/, "Table ID must be a valid ULID").describe("The unique identifier of the table to retrieve")
8546
- });
8547
- var GetTableOptionsInputSchema = zod.z.union([GetTableOptionsSchema, GetTableOptionsSchemaDeprecated]).describe(GetTableDescription);
8548
-
8549
- // src/plugins/tables/getTable/index.ts
8550
- var getTablePlugin = definePlugin(
8551
- (sdk) => createPluginMethod(sdk, {
8552
- ...tablesDefaults,
8553
- name: "getTable",
8554
- type: "item",
8555
- itemType: "Table",
8556
- inputSchema: GetTableOptionsInputSchema,
8557
- outputSchema: TableItemSchema,
8558
- resolvers: { table: tableIdResolver },
8559
- handler: async ({ sdk: sdk2, options }) => {
8560
- const tableId = "table" in options ? options.table : options.tableId;
8561
- const rawResponse = await sdk2.context.api.get(
8562
- `/tables/api/v1/tables/${tableId}`,
8563
- {
8564
- authRequired: true,
8565
- resource: { type: "table", id: tableId }
8566
- }
8567
- );
8568
- const response = GetTableApiResponseSchema.parse(rawResponse);
8569
- return { data: transformTableItem(response.data) };
8570
- }
8571
- })
8572
- );
8573
- var CreateTableApiResponseSchema = zod.z.object({
8574
- data: TableApiItemSchema
8575
- });
8576
- var CreateTableOptionsSchema = zod.z.object({
8577
- name: zod.z.string().min(1).describe("The name for the new table"),
8578
- description: zod.z.string().optional().describe("An optional description of the table")
8579
- }).describe("Create a new table");
8580
-
8581
- // src/plugins/tables/createTable/index.ts
8582
- var createTablePlugin = definePlugin(
8583
- (sdk) => createPluginMethod(sdk, {
8584
- ...tablesDefaults,
8585
- name: "createTable",
8586
- type: "create",
8587
- itemType: "Table",
8588
- inputSchema: CreateTableOptionsSchema,
8589
- outputSchema: TableItemSchema,
8590
- resolvers: { name: tableNameResolver },
8591
- handler: async ({ sdk: sdk2, options }) => {
8592
- const rawResponse = await sdk2.context.api.post(
8593
- "/tables/api/v1/tables",
8594
- { name: options.name, description: options.description },
8595
- { authRequired: true }
8596
- );
8597
- const response = CreateTableApiResponseSchema.parse(rawResponse);
8598
- return { data: transformTableItem(response.data) };
8599
- }
8600
- })
8601
- );
8602
- var DeleteTableDescription = "Delete a table by its ID";
8603
- var DeleteTableOptionsSchema = zod.z.object({
8604
- table: TablePropertySchema
8605
- }).describe(DeleteTableDescription).meta({ aliases: { tableId: "table" } });
8606
- var DeleteTableOptionsSchemaDeprecated = zod.z.object({
8607
- tableId: zod.z.string().regex(/^[A-Z0-9]{26}$/, "Table ID must be a valid ULID").describe("The unique identifier of the table to delete")
8608
- });
8609
- var DeleteTableOptionsInputSchema = zod.z.union([DeleteTableOptionsSchema, DeleteTableOptionsSchemaDeprecated]).describe(DeleteTableDescription);
8610
-
8611
- // src/plugins/tables/deleteTable/index.ts
8612
- var deleteTablePlugin = definePlugin(
8613
- (sdk) => createPluginMethod(sdk, {
8614
- ...tablesDefaults,
8615
- name: "deleteTable",
8616
- type: "delete",
8617
- itemType: "Table",
8618
- inputSchema: DeleteTableOptionsInputSchema,
8619
- resolvers: { table: tableIdResolver },
8620
- confirm: "delete",
8621
- handler: async ({ sdk: sdk2, options }) => {
8622
- await sdk2.context.checkCapability("canDeleteTables");
8623
- const tableId = "table" in options ? options.table : options.tableId;
8624
- await sdk2.context.api.delete(
8625
- `/tables/api/v1/tables/${tableId}`,
8626
- void 0,
8627
- {
8628
- authRequired: true,
8629
- resource: { type: "table", id: tableId }
8630
- }
8631
- );
8632
- return { success: true };
8633
- }
8634
- })
8635
- );
8636
-
8637
- // src/formatters/tableField.ts
8638
- var tableFieldItemFormatter = {
8639
- format: (item) => ({
8640
- title: item.name,
8641
- id: item.id,
8642
- details: [{ text: `Type: ${item.type}`, style: "dim" }]
8643
- })
8644
- };
8645
-
8646
- // src/plugins/tables/listTableFields/index.ts
8647
- var listTableFieldsPlugin = definePlugin(
8648
- (sdk) => createPluginMethod(sdk, {
8649
- ...tablesDefaults,
8650
- name: "listTableFields",
8651
- type: "list",
8652
- itemType: "Field",
8653
- inputSchema: ListTableFieldsOptionsInputSchema,
8654
- outputSchema: FieldItemSchema,
8655
- formatter: tableFieldItemFormatter,
8656
- resolvers: { table: tableIdResolver },
8657
- handler: async ({ sdk: sdk2, options }) => {
8658
- const { api } = sdk2.context;
8659
- const tableId = "table" in options ? options.table : options.tableId;
8660
- const fieldKeys = "fields" in options ? options.fields : options.fieldKeys;
8661
- const searchParams = {};
8662
- if (fieldKeys && fieldKeys.length > 0) {
8663
- const numericIds = await resolveFieldKeys({
8664
- api,
8665
- tableId,
8666
- fieldKeys
8667
- });
8668
- searchParams.field_ids = numericIds.join(",");
8669
- }
8670
- if (options.trash) {
8671
- searchParams.trash = options.trash;
8672
- }
8673
- const rawResponse = await api.get(
8674
- `/tables/api/v1/tables/${tableId}/fields`,
8675
- {
8676
- searchParams: Object.keys(searchParams).length > 0 ? searchParams : void 0,
8677
- authRequired: true,
8678
- resource: { type: "table", id: tableId }
8679
- }
8680
- );
8681
- const response = ListTableFieldsApiResponseSchema.parse(rawResponse);
8682
- return { data: response.data.map(transformFieldItem) };
8683
- }
8684
- })
8685
- );
8686
- var FieldChangesetItemSchema = zod.z.object({
8687
- new: FieldApiItemSchema,
8688
- old: FieldApiItemSchema.nullable(),
8689
- kind: zod.z.enum(["created", "updated", "deleted"])
8690
- });
8691
- var CreateTableFieldsApiResponseSchema = zod.z.object({
8692
- data: zod.z.array(FieldChangesetItemSchema),
8693
- meta: zod.z.object({
8694
- did_change: zod.z.boolean()
8695
- }).optional()
8696
- });
8697
- var NewFieldSchema = zod.z.object({
8698
- type: FieldTypeSchema.describe("The data type of the field"),
8699
- name: zod.z.string().min(1).describe("The display name of the field"),
8700
- options: zod.z.record(zod.z.string(), zod.z.unknown()).optional().describe("Data configuration options for the field"),
8701
- config: zod.z.record(zod.z.string(), zod.z.unknown()).optional().describe("Display configuration for the field")
8702
- });
8703
- var CreateTableFieldsDescription = "Create one or more fields in a table";
8704
- var CreateTableFieldsBase = zod.z.object({
8705
- fields: zod.z.array(NewFieldSchema).min(1).describe("Array of field definitions to create")
9613
+ var GetTableApiResponseSchema = zod.z.object({
9614
+ data: TableApiItemSchema
8706
9615
  });
8707
- var CreateTableFieldsOptionsSchema = zod.z.object({
9616
+ var GetTableDescription = "Get detailed information about a specific table";
9617
+ var GetTableOptionsSchema = zod.z.object({
8708
9618
  table: TablePropertySchema
8709
- }).merge(CreateTableFieldsBase).describe(CreateTableFieldsDescription).meta({ aliases: { tableId: "table" } });
8710
- var CreateTableFieldsOptionsSchemaDeprecated = zod.z.object({
8711
- tableId: zod.z.string().regex(/^[A-Z0-9]{26}$/, "Table ID must be a valid ULID").describe("The unique identifier of the table")
8712
- }).merge(CreateTableFieldsBase);
8713
- var CreateTableFieldsOptionsInputSchema = zod.z.union([
8714
- CreateTableFieldsOptionsSchema,
8715
- CreateTableFieldsOptionsSchemaDeprecated
8716
- ]).describe(CreateTableFieldsDescription);
9619
+ }).describe(GetTableDescription).meta({ aliases: { tableId: "table" } });
9620
+ var GetTableOptionsSchemaDeprecated = zod.z.object({
9621
+ tableId: zod.z.string().regex(/^[A-Z0-9]{26}$/, "Table ID must be a valid ULID").describe("The unique identifier of the table to retrieve")
9622
+ });
9623
+ var GetTableOptionsInputSchema = zod.z.union([GetTableOptionsSchema, GetTableOptionsSchemaDeprecated]).describe(GetTableDescription);
8717
9624
 
8718
- // src/plugins/tables/createTableFields/index.ts
8719
- var createTableFieldsPlugin = definePlugin(
9625
+ // src/plugins/tables/getTable/index.ts
9626
+ var getTablePlugin = definePlugin(
8720
9627
  (sdk) => createPluginMethod(sdk, {
8721
9628
  ...tablesDefaults,
8722
- name: "createTableFields",
8723
- type: "create",
8724
- itemType: "Field",
8725
- returnType: "FieldItem[]",
8726
- inputSchema: CreateTableFieldsOptionsInputSchema,
8727
- outputSchema: FieldItemSchema,
8728
- formatter: tableFieldItemFormatter,
8729
- resolvers: { table: tableIdResolver, fields: tableFieldsResolver },
9629
+ name: "getTable",
9630
+ type: "item",
9631
+ itemType: "Table",
9632
+ inputSchema: GetTableOptionsInputSchema,
9633
+ outputSchema: TableItemSchema,
9634
+ resolvers: { table: tableIdResolver },
8730
9635
  handler: async ({ sdk: sdk2, options }) => {
8731
9636
  const tableId = "table" in options ? options.table : options.tableId;
8732
- const rawResponse = await sdk2.context.api.post(
8733
- `/tables/api/v1/tables/${tableId}/fields`,
8734
- { new_fields: options.fields },
9637
+ const rawResponse = await sdk2.context.api.get(
9638
+ `/tables/api/v1/tables/${tableId}`,
8735
9639
  {
8736
9640
  authRequired: true,
8737
9641
  resource: { type: "table", id: tableId }
8738
9642
  }
8739
9643
  );
8740
- const response = CreateTableFieldsApiResponseSchema.parse(rawResponse);
8741
- return {
8742
- data: response.data.map(
8743
- (changeset) => transformFieldItem(changeset.new)
8744
- )
8745
- };
9644
+ const response = GetTableApiResponseSchema.parse(rawResponse);
9645
+ return { data: transformTableItem(response.data) };
8746
9646
  }
8747
9647
  })
8748
9648
  );
8749
- var DeleteTableFieldsDescription = "Delete one or more fields from a table";
8750
- var DeleteTableFieldsOptionsSchema = zod.z.object({
8751
- table: TablePropertySchema,
8752
- fields: FieldsPropertySchema.min(1)
8753
- }).describe(DeleteTableFieldsDescription).meta({ aliases: { tableId: "table", fieldKeys: "fields" } });
8754
- var DeleteTableFieldsOptionsSchemaDeprecated = zod.z.object({
8755
- tableId: zod.z.string().regex(/^[A-Z0-9]{26}$/, "Table ID must be a valid ULID").describe("The unique identifier of the table"),
8756
- fieldKeys: zod.z.array(zod.z.union([zod.z.string(), zod.z.number()])).min(1).describe(
8757
- 'Fields to delete. Accepts field names (e.g., "Email") or IDs (e.g., "f6", "6", or 6).'
8758
- )
9649
+ var DeleteTableDescription = "Delete a table by its ID";
9650
+ var DeleteTableOptionsSchema = zod.z.object({
9651
+ table: TablePropertySchema
9652
+ }).describe(DeleteTableDescription).meta({ aliases: { tableId: "table" } });
9653
+ var DeleteTableOptionsSchemaDeprecated = zod.z.object({
9654
+ tableId: zod.z.string().regex(/^[A-Z0-9]{26}$/, "Table ID must be a valid ULID").describe("The unique identifier of the table to delete")
8759
9655
  });
8760
- var DeleteTableFieldsOptionsInputSchema = zod.z.union([
8761
- DeleteTableFieldsOptionsSchema,
8762
- DeleteTableFieldsOptionsSchemaDeprecated
8763
- ]).describe(DeleteTableFieldsDescription);
9656
+ var DeleteTableOptionsInputSchema = zod.z.union([DeleteTableOptionsSchema, DeleteTableOptionsSchemaDeprecated]).describe(DeleteTableDescription);
8764
9657
 
8765
- // src/plugins/tables/deleteTableFields/index.ts
8766
- var deleteTableFieldsPlugin = definePlugin(
9658
+ // src/plugins/tables/deleteTable/index.ts
9659
+ var deleteTablePlugin = definePlugin(
8767
9660
  (sdk) => createPluginMethod(sdk, {
8768
9661
  ...tablesDefaults,
8769
- name: "deleteTableFields",
9662
+ name: "deleteTable",
8770
9663
  type: "delete",
8771
- itemType: "Field",
8772
- inputSchema: DeleteTableFieldsOptionsInputSchema,
8773
- resolvers: { table: tableIdResolver, fields: tableFieldIdsResolver },
9664
+ itemType: "Table",
9665
+ inputSchema: DeleteTableOptionsInputSchema,
9666
+ resolvers: { table: tableIdResolver },
8774
9667
  confirm: "delete",
8775
9668
  handler: async ({ sdk: sdk2, options }) => {
8776
- const { api } = sdk2.context;
9669
+ await sdk2.context.checkCapability("canDeleteTables");
8777
9670
  const tableId = "table" in options ? options.table : options.tableId;
8778
- const fieldKeys = "fields" in options ? options.fields : options.fieldKeys;
8779
- const numericFieldIds = await resolveFieldKeys({
8780
- api,
8781
- tableId,
8782
- fieldKeys
8783
- });
8784
- await api.delete(
8785
- `/tables/api/v1/tables/${tableId}/fields`,
8786
- { field_ids: numericFieldIds },
9671
+ await sdk2.context.api.delete(
9672
+ `/tables/api/v1/tables/${tableId}`,
9673
+ void 0,
8787
9674
  {
8788
9675
  authRequired: true,
8789
9676
  resource: { type: "table", id: tableId }
@@ -8793,820 +9680,700 @@ var deleteTableFieldsPlugin = definePlugin(
8793
9680
  }
8794
9681
  })
8795
9682
  );
8796
- var RecordApiItemSchema = zod.z.object({
8797
- id: zod.z.string().regex(/^[A-Z0-9]{26}$/, "Record ID must be a valid ULID"),
8798
- data: zod.z.record(zod.z.string(), zod.z.unknown()),
8799
- created_at: zod.z.string(),
8800
- edited_at: zod.z.string(),
8801
- schema_revision_id: zod.z.number(),
8802
- errors: zod.z.record(zod.z.string(), zod.z.unknown()).nullable().optional(),
8803
- orig_data: zod.z.record(zod.z.string(), zod.z.unknown()).nullable().optional(),
8804
- is_source_record: zod.z.boolean().nullable().optional(),
8805
- deleted_at: zod.z.string().nullable().optional()
8806
- });
8807
- var RecordItemSchema = zod.z.object({
8808
- id: zod.z.string(),
8809
- data: zod.z.record(zod.z.string(), zod.z.unknown()),
8810
- created_at: zod.z.string(),
8811
- edited_at: zod.z.string(),
8812
- deleted_at: zod.z.string().nullable().optional()
8813
- });
8814
- var GetTableRecordApiResponseSchema = zod.z.object({
8815
- data: RecordApiItemSchema
8816
- });
8817
- var GetTableRecordDescription = "Get a single record from a table by ID";
8818
- var GetTableRecordOptionsBaseSchema = zod.z.object({
8819
- keyMode: KeyModeSchema
8820
- });
8821
- var GetTableRecordOptionsSchema = zod.z.object({
8822
- table: TablePropertySchema,
8823
- record: RecordPropertySchema
8824
- }).merge(GetTableRecordOptionsBaseSchema).describe(GetTableRecordDescription).meta({ aliases: { tableId: "table", recordId: "record" } });
8825
- var GetTableRecordOptionsSchemaDeprecated = zod.z.object({
8826
- tableId: zod.z.string().regex(/^[A-Z0-9]{26}$/, "Table ID must be a valid ULID").describe("The unique identifier of the table"),
8827
- recordId: zod.z.string().regex(/^[A-Z0-9]{26}$/, "Record ID must be a valid ULID").describe("The unique identifier of the record")
8828
- }).merge(GetTableRecordOptionsBaseSchema);
8829
- var GetTableRecordOptionsInputSchema = zod.z.union([GetTableRecordOptionsSchema, GetTableRecordOptionsSchemaDeprecated]).describe(GetTableRecordDescription);
8830
-
8831
- // src/formatters/tableRecord.ts
8832
- var tableRecordFormatter = {
8833
- fetch: async (sdk, params, item, context) => {
8834
- if (context) return context;
8835
- const hasFieldIds = Object.keys(item.data).some(isFieldId);
8836
- if (!hasFieldIds) return {};
8837
- const table = params.table ?? params.tableId;
8838
- if (!table) return {};
8839
- const { data: fields } = await sdk.listTableFields({ table });
8840
- return Object.fromEntries(fields.map((f) => [f.id, f.name]));
8841
- },
8842
- format: (item, fieldLabels) => ({
8843
- title: `Record ${item.id}`,
8844
- id: item.id,
8845
- details: Object.entries(item.data).map(([k, v]) => ({
8846
- label: fieldLabels?.[k] ?? k,
8847
- text: formatFieldValue(v),
8848
- style: "normal"
8849
- }))
8850
- })
8851
- };
8852
-
8853
- // src/plugins/tables/getTableRecord/index.ts
8854
- var getTableRecordPlugin = definePlugin(
8855
- (sdk) => createPluginMethod(sdk, {
8856
- ...tablesDefaults,
8857
- name: "getTableRecord",
8858
- type: "item",
8859
- itemType: "Record",
8860
- inputSchema: GetTableRecordOptionsInputSchema,
8861
- outputSchema: RecordItemSchema,
8862
- resolvers: { table: tableIdResolver, record: tableRecordIdResolver },
8863
- formatter: tableRecordFormatter,
8864
- handler: async ({ sdk: sdk2, options }) => {
8865
- const { api } = sdk2.context;
8866
- const tableId = "table" in options ? options.table : options.tableId;
8867
- const recordId = "record" in options ? options.record : options.recordId;
8868
- const rawResponse = await api.get(
8869
- `/tables/api/v1/tables/${tableId}/records/${recordId}`,
8870
- {
8871
- authRequired: true,
8872
- resource: { type: "record", id: recordId }
8873
- }
8874
- );
8875
- const response = GetTableRecordApiResponseSchema.parse(rawResponse);
8876
- const translator = await createFieldKeyTranslator({
8877
- api,
8878
- tableId,
8879
- keyMode: options.keyMode
8880
- });
8881
- return {
8882
- data: {
8883
- ...transformRecordItem(response.data),
8884
- data: translator.translateOutput(response.data.data)
8885
- }
8886
- };
8887
- }
8888
- })
8889
- );
8890
- var ListTableRecordsApiResponseSchema = zod.z.object({
8891
- data: zod.z.array(RecordApiItemSchema),
8892
- meta: zod.z.object({
8893
- pagination: zod.z.object({
8894
- start_cursor: zod.z.string().nullable().optional(),
8895
- end_cursor: zod.z.string().nullable().optional(),
8896
- has_more: zod.z.boolean().optional(),
8897
- has_less: zod.z.boolean().optional()
8898
- }).optional()
8899
- }).optional()
8900
- });
8901
- var FilterOperatorSchema = zod.z.enum([
8902
- "exact",
8903
- "different",
8904
- "contains",
8905
- "icontains",
8906
- "gte",
8907
- "gt",
8908
- "lt",
8909
- "lte",
8910
- "range",
8911
- "in",
8912
- "isnull",
8913
- "startswith",
8914
- "search",
8915
- "is_within"
8916
- ]);
8917
- var FilterConditionSchema = zod.z.object({
8918
- fieldKey: zod.z.string().describe("The field key to filter on (e.g. f1, f2)"),
8919
- operator: FilterOperatorSchema.describe("The comparison operator"),
8920
- value: zod.z.unknown().optional().describe("The value to compare against")
8921
- });
8922
- var SortDirectionSchema = zod.z.enum(["asc", "desc"]);
8923
- var SortConditionSchema = zod.z.object({
8924
- fieldKey: zod.z.string().describe("The field key to sort by"),
8925
- direction: SortDirectionSchema.optional().default("asc").describe("Sort direction")
8926
- });
8927
- var ListTableRecordsDescription = "List records in a table with optional filtering and sorting";
8928
- var ListTableRecordsBase = zod.z.object({
8929
- filters: zod.z.array(FilterConditionSchema).optional().describe("Filter conditions for the query"),
8930
- sort: SortConditionSchema.optional().describe("Sort records by a field"),
8931
- pageSize: zod.z.number().min(1).max(1e3).optional().describe("Number of records per page (max 1000)"),
8932
- maxItems: zod.z.number().min(1).optional().describe("Maximum total items to return across all pages"),
8933
- cursor: zod.z.string().optional().describe("Cursor to start from"),
8934
- keyMode: KeyModeSchema,
8935
- trash: TrashSchema
9683
+ var CreateTableApiResponseSchema = zod.z.object({
9684
+ data: TableApiItemSchema
8936
9685
  });
8937
- var ListTableRecordsOptionsSchema = zod.z.object({
8938
- table: TablePropertySchema
8939
- }).merge(ListTableRecordsBase).describe(ListTableRecordsDescription).meta({ aliases: { tableId: "table" } });
8940
- var ListTableRecordsOptionsSchemaDeprecated = zod.z.object({
8941
- tableId: zod.z.string().regex(/^[A-Z0-9]{26}$/, "Table ID must be a valid ULID").describe("The unique identifier of the table")
8942
- }).merge(ListTableRecordsBase);
8943
- var ListTableRecordsOptionsInputSchema = zod.z.union([
8944
- ListTableRecordsOptionsSchema,
8945
- ListTableRecordsOptionsSchemaDeprecated
8946
- ]).describe(ListTableRecordsDescription);
9686
+ var CreateTableOptionsSchema = zod.z.object({
9687
+ name: zod.z.string().min(1).describe("The name for the new table"),
9688
+ description: zod.z.string().optional().describe("An optional description of the table")
9689
+ }).describe("Create a new table");
8947
9690
 
8948
- // src/plugins/tables/listTableRecords/index.ts
8949
- var listTableRecordsPlugin = definePlugin(
8950
- (sdk) => createPaginatedPluginMethod(sdk, {
9691
+ // src/plugins/tables/createTable/index.ts
9692
+ var createTablePlugin = definePlugin(
9693
+ (sdk) => createPluginMethod(sdk, {
8951
9694
  ...tablesDefaults,
8952
- name: "listTableRecords",
9695
+ name: "createTable",
9696
+ type: "create",
9697
+ itemType: "Table",
9698
+ inputSchema: CreateTableOptionsSchema,
9699
+ outputSchema: TableItemSchema,
9700
+ resolvers: { name: tableNameResolver },
9701
+ handler: async ({ sdk: sdk2, options }) => {
9702
+ const rawResponse = await sdk2.context.api.post(
9703
+ "/tables/api/v1/tables",
9704
+ { name: options.name, description: options.description },
9705
+ { authRequired: true }
9706
+ );
9707
+ const response = CreateTableApiResponseSchema.parse(rawResponse);
9708
+ return { data: transformTableItem(response.data) };
9709
+ }
9710
+ })
9711
+ );
9712
+
9713
+ // src/formatters/tableField.ts
9714
+ var tableFieldItemFormatter = {
9715
+ format: (item) => ({
9716
+ title: item.name,
9717
+ id: item.id,
9718
+ details: [{ text: `Type: ${item.type}`, style: "dim" }]
9719
+ })
9720
+ };
9721
+
9722
+ // src/plugins/tables/listTableFields/index.ts
9723
+ var listTableFieldsPlugin = definePlugin(
9724
+ (sdk) => createPluginMethod(sdk, {
9725
+ ...tablesDefaults,
9726
+ name: "listTableFields",
8953
9727
  type: "list",
8954
- itemType: "Record",
8955
- inputSchema: ListTableRecordsOptionsInputSchema,
8956
- outputSchema: RecordItemSchema,
8957
- defaultPageSize: DEFAULT_PAGE_SIZE,
8958
- resolvers: {
8959
- table: tableIdResolver,
8960
- filters: tableFiltersResolver,
8961
- sort: tableSortResolver
8962
- },
8963
- formatter: tableRecordFormatter,
9728
+ itemType: "Field",
9729
+ inputSchema: ListTableFieldsOptionsInputSchema,
9730
+ outputSchema: FieldItemSchema,
9731
+ formatter: tableFieldItemFormatter,
9732
+ resolvers: { table: tableIdResolver },
8964
9733
  handler: async ({ sdk: sdk2, options }) => {
8965
9734
  const { api } = sdk2.context;
8966
9735
  const tableId = "table" in options ? options.table : options.tableId;
8967
- const translator = await createFieldKeyTranslator({
8968
- api,
8969
- tableId,
8970
- keyMode: options.keyMode
8971
- });
8972
- const body = {};
8973
- if (options.pageSize !== void 0) {
8974
- body.limit = options.pageSize;
8975
- }
8976
- if (options.filters) {
8977
- body.filters = options.filters.map((f) => ({
8978
- key: translator.translateFieldKey(f.fieldKey),
8979
- operator: f.operator,
8980
- value: f.value
8981
- }));
8982
- }
8983
- if (options.sort) {
8984
- body.orders = [
8985
- {
8986
- key: translator.translateFieldKey(options.sort.fieldKey),
8987
- direction: options.sort.direction
8988
- }
8989
- ];
8990
- }
8991
- if (options.cursor) {
8992
- body.cursor_query = {
8993
- query_type: "window",
8994
- start_cursor: options.cursor
8995
- };
9736
+ const fieldKeys = "fields" in options ? options.fields : options.fieldKeys;
9737
+ const searchParams = {};
9738
+ if (fieldKeys && fieldKeys.length > 0) {
9739
+ const numericIds = await resolveFieldKeys({
9740
+ api,
9741
+ tableId,
9742
+ fieldKeys
9743
+ });
9744
+ searchParams.field_ids = numericIds.join(",");
8996
9745
  }
8997
- const searchParams = {
8998
- allow_nested_queries: "true"
8999
- };
9000
9746
  if (options.trash) {
9001
9747
  searchParams.trash = options.trash;
9002
9748
  }
9003
- const rawResponse = await api.post(
9004
- `/tables/api/v1/tables/${tableId}/records/query`,
9005
- body,
9749
+ const rawResponse = await api.get(
9750
+ `/tables/api/v1/tables/${tableId}/fields`,
9006
9751
  {
9007
- searchParams,
9752
+ searchParams: Object.keys(searchParams).length > 0 ? searchParams : void 0,
9008
9753
  authRequired: true,
9009
9754
  resource: { type: "table", id: tableId }
9010
9755
  }
9011
9756
  );
9012
- throwOnResponseErrors(rawResponse);
9013
- const response = ListTableRecordsApiResponseSchema.parse(rawResponse);
9014
- const pagination = response.meta?.pagination;
9015
- const nextCursor = pagination?.has_more && pagination.end_cursor ? pagination.end_cursor : void 0;
9016
- return {
9017
- data: response.data.map((item) => ({
9018
- ...transformRecordItem(item),
9019
- data: translator.translateOutput(item.data)
9020
- })),
9021
- nextCursor
9022
- };
9757
+ const response = ListTableFieldsApiResponseSchema.parse(rawResponse);
9758
+ return { data: response.data.map(transformFieldItem) };
9023
9759
  }
9024
9760
  })
9025
9761
  );
9026
- var RecordChangesetSchema = zod.z.object({
9027
- change_id: zod.z.string(),
9028
- old: RecordApiItemSchema.nullable(),
9029
- new: RecordApiItemSchema,
9030
- changed_field_ids: zod.z.array(zod.z.number()).nullable(),
9031
- record_id: zod.z.string()
9762
+ var FieldChangesetItemSchema = zod.z.object({
9763
+ new: FieldApiItemSchema,
9764
+ old: FieldApiItemSchema.nullable(),
9765
+ kind: zod.z.enum(["created", "updated", "deleted"])
9032
9766
  });
9033
- var CreateTableRecordsApiResponseSchema = zod.z.object({
9034
- data: zod.z.array(RecordChangesetSchema)
9767
+ var CreateTableFieldsApiResponseSchema = zod.z.object({
9768
+ data: zod.z.array(FieldChangesetItemSchema),
9769
+ meta: zod.z.object({
9770
+ did_change: zod.z.boolean()
9771
+ }).optional()
9035
9772
  });
9036
- var NewRecordSchema = zod.z.object({
9037
- data: zod.z.record(zod.z.string(), zod.z.unknown()).describe("The field values for the record, keyed by field ID")
9773
+ var NewFieldSchema = zod.z.object({
9774
+ type: FieldTypeSchema.describe("The data type of the field"),
9775
+ name: zod.z.string().min(1).describe("The display name of the field"),
9776
+ options: zod.z.record(zod.z.string(), zod.z.unknown()).optional().describe("Data configuration options for the field"),
9777
+ config: zod.z.record(zod.z.string(), zod.z.unknown()).optional().describe("Display configuration for the field")
9038
9778
  });
9039
- var CreateTableRecordsDescription = "Create one or more records in a table";
9040
- var CreateTableRecordsBase = zod.z.object({
9041
- records: zod.z.array(NewRecordSchema).min(1).max(100).describe("Array of records to create (max 100)"),
9042
- keyMode: KeyModeSchema
9779
+ var CreateTableFieldsDescription = "Create one or more fields in a table";
9780
+ var CreateTableFieldsBase = zod.z.object({
9781
+ fields: zod.z.array(NewFieldSchema).min(1).describe("Array of field definitions to create")
9043
9782
  });
9044
- var CreateTableRecordsOptionsSchema = zod.z.object({
9783
+ var CreateTableFieldsOptionsSchema = zod.z.object({
9045
9784
  table: TablePropertySchema
9046
- }).merge(CreateTableRecordsBase).describe(CreateTableRecordsDescription).meta({ aliases: { tableId: "table" } });
9047
- var CreateTableRecordsOptionsSchemaDeprecated = zod.z.object({
9785
+ }).merge(CreateTableFieldsBase).describe(CreateTableFieldsDescription).meta({ aliases: { tableId: "table" } });
9786
+ var CreateTableFieldsOptionsSchemaDeprecated = zod.z.object({
9048
9787
  tableId: zod.z.string().regex(/^[A-Z0-9]{26}$/, "Table ID must be a valid ULID").describe("The unique identifier of the table")
9049
- }).merge(CreateTableRecordsBase);
9050
- var CreateTableRecordsOptionsInputSchema = zod.z.union([
9051
- CreateTableRecordsOptionsSchema,
9052
- CreateTableRecordsOptionsSchemaDeprecated
9053
- ]).describe(CreateTableRecordsDescription);
9788
+ }).merge(CreateTableFieldsBase);
9789
+ var CreateTableFieldsOptionsInputSchema = zod.z.union([
9790
+ CreateTableFieldsOptionsSchema,
9791
+ CreateTableFieldsOptionsSchemaDeprecated
9792
+ ]).describe(CreateTableFieldsDescription);
9054
9793
 
9055
- // src/plugins/tables/createTableRecords/index.ts
9056
- var createTableRecordsPlugin = definePlugin(
9794
+ // src/plugins/tables/createTableFields/index.ts
9795
+ var createTableFieldsPlugin = definePlugin(
9057
9796
  (sdk) => createPluginMethod(sdk, {
9058
9797
  ...tablesDefaults,
9059
- name: "createTableRecords",
9798
+ name: "createTableFields",
9060
9799
  type: "create",
9061
- itemType: "Record",
9062
- returnType: "RecordItem[]",
9063
- inputSchema: CreateTableRecordsOptionsInputSchema,
9064
- outputSchema: RecordItemSchema,
9065
- resolvers: { table: tableIdResolver, records: tableRecordsResolver },
9066
- formatter: tableRecordFormatter,
9067
- handler: async ({ sdk: sdk2, options }) => {
9068
- const { api } = sdk2.context;
9069
- const tableId = "table" in options ? options.table : options.tableId;
9070
- const translator = await createFieldKeyTranslator({
9071
- api,
9072
- tableId,
9073
- keyMode: options.keyMode
9074
- });
9075
- const rawResponse = await api.post(
9076
- `/tables/api/v1/tables/${tableId}/records`,
9077
- {
9078
- new_records: options.records.map((record) => ({
9079
- data: translator.translateInput(record.data)
9080
- }))
9081
- },
9082
- { authRequired: true, resource: { type: "table", id: tableId } }
9083
- );
9084
- throwOnResponseErrors(rawResponse);
9085
- const response = CreateTableRecordsApiResponseSchema.parse(rawResponse);
9086
- for (const changeset of response.data) {
9087
- throwOnRecordErrors(changeset.new);
9088
- }
9089
- return {
9090
- data: response.data.map((changeset) => ({
9091
- ...transformRecordItem(changeset.new),
9092
- data: translator.translateOutput(changeset.new.data)
9093
- }))
9094
- };
9095
- }
9096
- })
9097
- );
9098
- var DeleteTableRecordsDescription = "Delete one or more records from a table";
9099
- var DeleteTableRecordsOptionsSchema = zod.z.object({
9100
- table: TablePropertySchema,
9101
- records: RecordsPropertySchema
9102
- }).describe(DeleteTableRecordsDescription).meta({ aliases: { tableId: "table", recordIds: "records" } });
9103
- var DeleteTableRecordsOptionsSchemaDeprecated = zod.z.object({
9104
- tableId: zod.z.string().regex(/^[A-Z0-9]{26}$/, "Table ID must be a valid ULID").describe("The unique identifier of the table"),
9105
- recordIds: zod.z.array(zod.z.string().regex(/^[A-Z0-9]{26}$/, "Record ID must be a valid ULID")).min(1).max(100).describe("Array of record IDs to delete (max 100)")
9106
- });
9107
- var DeleteTableRecordsOptionsInputSchema = zod.z.union([
9108
- DeleteTableRecordsOptionsSchema,
9109
- DeleteTableRecordsOptionsSchemaDeprecated
9110
- ]).describe(DeleteTableRecordsDescription);
9111
-
9112
- // src/plugins/tables/deleteTableRecords/index.ts
9113
- var deleteTableRecordsPlugin = definePlugin(
9114
- (sdk) => createPluginMethod(sdk, {
9115
- ...tablesDefaults,
9116
- name: "deleteTableRecords",
9117
- type: "delete",
9118
- itemType: "Record",
9119
- inputSchema: DeleteTableRecordsOptionsInputSchema,
9120
- resolvers: { table: tableIdResolver, records: tableRecordIdsResolver },
9121
- confirm: "delete",
9122
- handler: async ({ sdk: sdk2, options }) => {
9123
- const tableId = "table" in options ? options.table : options.tableId;
9124
- const recordIds = "records" in options ? options.records : options.recordIds;
9125
- await sdk2.context.api.delete(
9126
- `/tables/api/v1/tables/${tableId}/records`,
9127
- { record_ids: recordIds },
9800
+ itemType: "Field",
9801
+ returnType: "FieldItem[]",
9802
+ inputSchema: CreateTableFieldsOptionsInputSchema,
9803
+ outputSchema: FieldItemSchema,
9804
+ formatter: tableFieldItemFormatter,
9805
+ resolvers: { table: tableIdResolver, fields: tableFieldsResolver },
9806
+ handler: async ({ sdk: sdk2, options }) => {
9807
+ const tableId = "table" in options ? options.table : options.tableId;
9808
+ const rawResponse = await sdk2.context.api.post(
9809
+ `/tables/api/v1/tables/${tableId}/fields`,
9810
+ { new_fields: options.fields },
9128
9811
  {
9129
9812
  authRequired: true,
9130
9813
  resource: { type: "table", id: tableId }
9131
9814
  }
9132
9815
  );
9133
- return { success: true };
9816
+ const response = CreateTableFieldsApiResponseSchema.parse(rawResponse);
9817
+ return {
9818
+ data: response.data.map(
9819
+ (changeset) => transformFieldItem(changeset.new)
9820
+ )
9821
+ };
9134
9822
  }
9135
9823
  })
9136
9824
  );
9137
- var RecordChangesetSchema2 = zod.z.object({
9138
- change_id: zod.z.string(),
9139
- old: RecordApiItemSchema.nullable(),
9140
- new: RecordApiItemSchema,
9141
- changed_field_ids: zod.z.array(zod.z.number()).nullable(),
9142
- record_id: zod.z.string()
9143
- });
9144
- var UpdateTableRecordsApiResponseSchema = zod.z.object({
9145
- data: zod.z.array(RecordChangesetSchema2)
9146
- });
9147
- var UpdateRecordSchema = zod.z.object({
9148
- id: zod.z.string().describe("The record ID to update"),
9149
- data: zod.z.record(zod.z.string(), zod.z.unknown()).describe("The field values to update, keyed by field key")
9150
- });
9151
- var UpdateTableRecordsDescription = "Update one or more records in a table";
9152
- var UpdateTableRecordsBase = zod.z.object({
9153
- records: zod.z.array(UpdateRecordSchema).min(1).max(100).describe("Array of records to update (max 100)"),
9154
- keyMode: KeyModeSchema
9825
+ var DeleteTableFieldsDescription = "Delete one or more fields from a table";
9826
+ var DeleteTableFieldsOptionsSchema = zod.z.object({
9827
+ table: TablePropertySchema,
9828
+ fields: FieldsPropertySchema.min(1)
9829
+ }).describe(DeleteTableFieldsDescription).meta({ aliases: { tableId: "table", fieldKeys: "fields" } });
9830
+ var DeleteTableFieldsOptionsSchemaDeprecated = zod.z.object({
9831
+ tableId: zod.z.string().regex(/^[A-Z0-9]{26}$/, "Table ID must be a valid ULID").describe("The unique identifier of the table"),
9832
+ fieldKeys: zod.z.array(zod.z.union([zod.z.string(), zod.z.number()])).min(1).describe(
9833
+ 'Fields to delete. Accepts field names (e.g., "Email") or IDs (e.g., "f6", "6", or 6).'
9834
+ )
9155
9835
  });
9156
- var UpdateTableRecordsOptionsSchema = zod.z.object({
9157
- table: TablePropertySchema
9158
- }).merge(UpdateTableRecordsBase).describe(UpdateTableRecordsDescription).meta({ aliases: { tableId: "table" } });
9159
- var UpdateTableRecordsOptionsSchemaDeprecated = zod.z.object({
9160
- tableId: zod.z.string().regex(/^[A-Z0-9]{26}$/, "Table ID must be a valid ULID").describe("The unique identifier of the table")
9161
- }).merge(UpdateTableRecordsBase);
9162
- var UpdateTableRecordsOptionsInputSchema = zod.z.union([
9163
- UpdateTableRecordsOptionsSchema,
9164
- UpdateTableRecordsOptionsSchemaDeprecated
9165
- ]).describe(UpdateTableRecordsDescription);
9836
+ var DeleteTableFieldsOptionsInputSchema = zod.z.union([
9837
+ DeleteTableFieldsOptionsSchema,
9838
+ DeleteTableFieldsOptionsSchemaDeprecated
9839
+ ]).describe(DeleteTableFieldsDescription);
9166
9840
 
9167
- // src/plugins/tables/updateTableRecords/index.ts
9168
- var updateTableRecordsPlugin = definePlugin(
9841
+ // src/plugins/tables/deleteTableFields/index.ts
9842
+ var deleteTableFieldsPlugin = definePlugin(
9169
9843
  (sdk) => createPluginMethod(sdk, {
9170
9844
  ...tablesDefaults,
9171
- name: "updateTableRecords",
9172
- type: "update",
9173
- itemType: "Record",
9174
- returnType: "RecordItem[]",
9175
- inputSchema: UpdateTableRecordsOptionsInputSchema,
9176
- outputSchema: RecordItemSchema,
9177
- resolvers: {
9178
- table: tableIdResolver,
9179
- records: tableUpdateRecordsResolver
9180
- },
9181
- formatter: tableRecordFormatter,
9845
+ name: "deleteTableFields",
9846
+ type: "delete",
9847
+ itemType: "Field",
9848
+ inputSchema: DeleteTableFieldsOptionsInputSchema,
9849
+ resolvers: { table: tableIdResolver, fields: tableFieldIdsResolver },
9850
+ confirm: "delete",
9182
9851
  handler: async ({ sdk: sdk2, options }) => {
9183
9852
  const { api } = sdk2.context;
9184
9853
  const tableId = "table" in options ? options.table : options.tableId;
9185
- const translator = await createFieldKeyTranslator({
9854
+ const fieldKeys = "fields" in options ? options.fields : options.fieldKeys;
9855
+ const numericFieldIds = await resolveFieldKeys({
9186
9856
  api,
9187
9857
  tableId,
9188
- keyMode: options.keyMode
9858
+ fieldKeys
9189
9859
  });
9190
- const rawResponse = await api.patch(
9191
- `/tables/api/v1/tables/${tableId}/records`,
9860
+ await api.delete(
9861
+ `/tables/api/v1/tables/${tableId}/fields`,
9862
+ { field_ids: numericFieldIds },
9192
9863
  {
9193
- updated_records: options.records.map((record) => ({
9194
- id: record.id,
9195
- data: translator.translateInput(record.data)
9196
- }))
9197
- },
9198
- { authRequired: true, resource: { type: "table", id: tableId } }
9864
+ authRequired: true,
9865
+ resource: { type: "table", id: tableId }
9866
+ }
9199
9867
  );
9200
- throwOnResponseErrors(rawResponse);
9201
- const response = UpdateTableRecordsApiResponseSchema.parse(rawResponse);
9202
- for (const changeset of response.data) {
9203
- throwOnRecordErrors(changeset.new);
9204
- }
9205
- return {
9206
- data: response.data.map((changeset) => ({
9207
- ...transformRecordItem(changeset.new),
9208
- data: translator.translateOutput(changeset.new.data)
9209
- }))
9210
- };
9868
+ return { success: true };
9211
9869
  }
9212
9870
  })
9213
9871
  );
9214
-
9215
- // src/core-stack.ts
9216
- var zapierCorePlugin = createCorePlugin({
9217
- adaptError: zapierAdaptError
9872
+ var RecordApiItemSchema = zod.z.object({
9873
+ id: zod.z.string().regex(/^[A-Z0-9]{26}$/, "Record ID must be a valid ULID"),
9874
+ data: zod.z.record(zod.z.string(), zod.z.unknown()),
9875
+ created_at: zod.z.string(),
9876
+ edited_at: zod.z.string(),
9877
+ schema_revision_id: zod.z.number(),
9878
+ errors: zod.z.record(zod.z.string(), zod.z.unknown()).nullable().optional(),
9879
+ orig_data: zod.z.record(zod.z.string(), zod.z.unknown()).nullable().optional(),
9880
+ is_source_record: zod.z.boolean().nullable().optional(),
9881
+ deleted_at: zod.z.string().nullable().optional()
9218
9882
  });
9219
- function createZapierCoreStack() {
9220
- return createPluginStack().use(zapierCorePlugin);
9221
- }
9222
- var GetConnectionStartUrlSchema = zod.z.object({
9223
- app: AppPropertySchema
9224
- }).describe(
9225
- "Mint a short-lived URL that begins an SDK-initiated connection flow. The URL is signed by zapier.com and bound to the current user/account \u2014 opening it in a different browser session will fail the binding check. Returns the URL as data so the caller decides what to do with it.\n\nUse this directly (rather than the higher-level `create-connection`) when you want either of: (a) hand off the URL and *not* block waiting for completion \u2014 call this alone, skip `wait-for-new-connection` entirely, or (b) do something custom between minting the URL and waiting for the connection \u2014 call this, then email or DM the URL, render it as a QR code for mobile sign-in, etc., then call `wait-for-new-connection`. For the common case where you'd just print and poll back-to-back, `create-connection` is one call.\n\nPair with `wait-for-new-connection` to detect completion: pass the `startedAt` returned here straight through (it's the server's mint time, so polling isn't affected by client clock skew). Example (JS):\n\n```ts\nconst { data: { url, app, startedAt } } = await zapier.getConnectionStartUrl({ app: 'slack' });\n// hand `url` off \u2014 print it, DM it, email it, render a button, whatever\nconst { data: conn } = await zapier.waitForNewConnection({ app, startedAt });\n```"
9226
- );
9227
- var GetConnectionStartUrlItemSchema = zod.z.object({
9228
- url: zod.z.string().describe(
9229
- "URL the user should open in their browser to complete the auth flow. Single-use, time-limited."
9230
- ),
9231
- expiresAt: zod.z.number().describe(
9232
- "Unix timestamp (seconds) after which the URL's signature is rejected by zapier.com."
9233
- ),
9234
- startedAt: zod.z.number().describe(
9235
- "Unix timestamp (seconds) when the server minted the URL. Use it as the `startedAt` for `wait-for-new-connection` so polling is anchored to server time rather than a possibly-skewed client clock."
9236
- ),
9237
- app: zod.z.string().describe(
9238
- "Versionless app key the URL was minted for (e.g., 'SlackCLIAPI'). Useful for downstream filtering."
9239
- )
9240
- }).describe(
9241
- "The signed start-URL plus metadata needed to poll for completion."
9242
- );
9883
+ var RecordItemSchema = zod.z.object({
9884
+ id: zod.z.string(),
9885
+ data: zod.z.record(zod.z.string(), zod.z.unknown()),
9886
+ created_at: zod.z.string(),
9887
+ edited_at: zod.z.string(),
9888
+ deleted_at: zod.z.string().nullable().optional()
9889
+ });
9890
+ var GetTableRecordApiResponseSchema = zod.z.object({
9891
+ data: RecordApiItemSchema
9892
+ });
9893
+ var GetTableRecordDescription = "Get a single record from a table by ID";
9894
+ var GetTableRecordOptionsBaseSchema = zod.z.object({
9895
+ keyMode: KeyModeSchema
9896
+ });
9897
+ var GetTableRecordOptionsSchema = zod.z.object({
9898
+ table: TablePropertySchema,
9899
+ record: RecordPropertySchema
9900
+ }).merge(GetTableRecordOptionsBaseSchema).describe(GetTableRecordDescription).meta({ aliases: { tableId: "table", recordId: "record" } });
9901
+ var GetTableRecordOptionsSchemaDeprecated = zod.z.object({
9902
+ tableId: zod.z.string().regex(/^[A-Z0-9]{26}$/, "Table ID must be a valid ULID").describe("The unique identifier of the table"),
9903
+ recordId: zod.z.string().regex(/^[A-Z0-9]{26}$/, "Record ID must be a valid ULID").describe("The unique identifier of the record")
9904
+ }).merge(GetTableRecordOptionsBaseSchema);
9905
+ var GetTableRecordOptionsInputSchema = zod.z.union([GetTableRecordOptionsSchema, GetTableRecordOptionsSchemaDeprecated]).describe(GetTableRecordDescription);
9243
9906
 
9244
- // src/plugins/getConnectionStartUrl/index.ts
9245
- var START_PATH = "/zapier/api/authentications/v1/sdk/connections/start";
9246
- var getConnectionStartUrlPlugin = definePlugin(
9247
- (sdk) => createPluginMethod(sdk, {
9248
- name: "getConnectionStartUrl",
9249
- categories: ["connection"],
9250
- type: "create",
9251
- itemType: "ConnectionStartUrl",
9252
- inputSchema: GetConnectionStartUrlSchema,
9253
- outputSchema: GetConnectionStartUrlItemSchema,
9254
- resolvers: { app: appKeyResolver },
9255
- handler: async ({
9256
- sdk: inner,
9257
- options
9258
- }) => {
9259
- const versionedKey = await inner.context.getVersionedImplementationId(
9260
- options.app
9261
- );
9262
- const selectedApi = versionedKey ? versionedKey.split("@")[0] : options.app;
9263
- setMethodMetadata({ selectedApi });
9264
- const response = await inner.context.api.post(
9265
- START_PATH,
9266
- { selected_api: selectedApi },
9267
- { authRequired: true }
9268
- );
9269
- return {
9270
- data: GetConnectionStartUrlItemSchema.parse({
9271
- url: response.url,
9272
- expiresAt: response.expires_at,
9273
- startedAt: response.started_at,
9274
- app: selectedApi
9275
- })
9276
- };
9277
- }
9907
+ // src/formatters/tableRecord.ts
9908
+ var tableRecordFormatter = {
9909
+ fetch: async (sdk, params, item, context) => {
9910
+ if (context) return context;
9911
+ const hasFieldIds = Object.keys(item.data).some(isFieldId);
9912
+ if (!hasFieldIds) return {};
9913
+ const table = params.table ?? params.tableId;
9914
+ if (!table) return {};
9915
+ const { data: fields } = await sdk.listTableFields({ table });
9916
+ return Object.fromEntries(fields.map((f) => [f.id, f.name]));
9917
+ },
9918
+ format: (item, fieldLabels) => ({
9919
+ title: `Record ${item.id}`,
9920
+ id: item.id,
9921
+ details: Object.entries(item.data).map(([k, v]) => ({
9922
+ label: fieldLabels?.[k] ?? k,
9923
+ text: formatFieldValue(v),
9924
+ style: "normal"
9925
+ }))
9278
9926
  })
9279
- );
9280
- var WaitForNewConnectionSchema = zod.z.object({
9281
- app: AppPropertySchema,
9282
- startedAt: zod.z.number().int().nonnegative().describe(
9283
- "Unix timestamp (seconds). Only connections whose `date` is at or after this value count as 'new'. Prefer the `startedAt` returned by `get-connection-start-url` \u2014 it's server-stamped, so the comparison isn't thrown off by client clock skew. If you mint the timestamp yourself, capture it *before* showing the start URL so a fast OAuth completion isn't missed."
9284
- ),
9285
- timeoutMs: zod.z.number().int().positive().optional().describe(
9286
- "How long to wait before giving up. Default 5 minutes (300_000)."
9287
- ),
9288
- pollIntervalMs: zod.z.number().int().positive().optional().describe(
9289
- "Delay before the first poll request, in ms. Default 3 seconds (3_000). Subsequent polling cadence is managed by the SDK's polling primitive (backoff with sane defaults)."
9290
- )
9291
- }).describe(
9292
- "Wait for a new connection to appear for the given app. Polls `/api/v0/connections` with server-side `ordering=-date` until the most recent matching row's `date` is at or after the started-at timestamp, then returns it. Pair with `get-connection-start-url` \u2014 that mints the URL the user opens, this waits for the resulting connection to land. Errors with a timeout after the configured timeout (default 5 min). Example (JS):\n\n```ts\nconst { data: { url, app, startedAt } } = await zapier.getConnectionStartUrl({ app: 'slack' });\n// show `url` to the user via the channel they're reading from\nconst { data: conn } = await zapier.waitForNewConnection({ app, startedAt });\n```"
9293
- );
9294
- var WaitForNewConnectionItemSchema = zod.z.object({
9295
- id: zod.z.string().describe(
9296
- "The new connection's ID. Public UUID when available, falling back to the numeric ID."
9297
- ),
9298
- app: zod.z.string().describe(
9299
- "Versionless app key the connection was created for (e.g., 'SlackCLIAPI')."
9300
- ),
9301
- title: zod.z.string().nullable().optional().describe(
9302
- "Human-readable connection title set by the auth flow, when available."
9303
- )
9304
- }).describe("The new connection that was detected.");
9927
+ };
9305
9928
 
9306
- // src/plugins/waitForNewConnection/index.ts
9307
- var CONNECTIONS_PATH = "/api/v0/connections";
9308
- var waitForNewConnectionPlugin = definePlugin(
9309
- (sdk) => createPluginMethod(sdk, {
9310
- name: "waitForNewConnection",
9311
- categories: ["connection"],
9929
+ // src/plugins/tables/getTableRecord/index.ts
9930
+ var getTableRecordPlugin = definePlugin(
9931
+ (sdk) => createPluginMethod(sdk, {
9932
+ ...tablesDefaults,
9933
+ name: "getTableRecord",
9312
9934
  type: "item",
9313
- itemType: "Connection",
9314
- inputSchema: WaitForNewConnectionSchema,
9315
- outputSchema: WaitForNewConnectionItemSchema,
9316
- resolvers: { app: appKeyResolver },
9317
- handler: async ({
9318
- sdk: inner,
9319
- options
9320
- }) => {
9321
- const versionedKey = await inner.context.getVersionedImplementationId(
9322
- options.app
9935
+ itemType: "Record",
9936
+ inputSchema: GetTableRecordOptionsInputSchema,
9937
+ outputSchema: RecordItemSchema,
9938
+ resolvers: { table: tableIdResolver, record: tableRecordIdResolver },
9939
+ formatter: tableRecordFormatter,
9940
+ handler: async ({ sdk: sdk2, options }) => {
9941
+ const { api } = sdk2.context;
9942
+ const tableId = "table" in options ? options.table : options.tableId;
9943
+ const recordId = "record" in options ? options.record : options.recordId;
9944
+ const rawResponse = await api.get(
9945
+ `/tables/api/v1/tables/${tableId}/records/${recordId}`,
9946
+ {
9947
+ authRequired: true,
9948
+ resource: { type: "record", id: recordId }
9949
+ }
9323
9950
  );
9324
- const appKey = versionedKey ? versionedKey.split("@")[0] : options.app;
9325
- setMethodMetadata({ selectedApi: appKey });
9326
- try {
9327
- const top = await inner.context.api.poll(
9328
- CONNECTIONS_PATH,
9329
- {
9330
- searchParams: {
9331
- app_key: appKey,
9332
- // Scope to the current user's own connections. The connection
9333
- // we're waiting on is by definition owned by the caller; without
9334
- // this the one-row head-check could match a teammate's freshly
9335
- // created connection for the same app.
9336
- owner: "me",
9337
- is_expired: "false",
9338
- ordering: "-date",
9339
- page_size: "1"
9340
- },
9341
- authRequired: true,
9342
- timeoutMs: options.timeoutMs ?? 3e5,
9343
- initialDelay: options.pollIntervalMs ?? 3e3,
9344
- isPending: (body) => {
9345
- const rows = body.data ?? [];
9346
- const head = rows[0];
9347
- if (!head?.date) return true;
9348
- const created = Math.floor(new Date(head.date).getTime() / 1e3);
9349
- return !Number.isFinite(created) || created < options.startedAt;
9350
- },
9351
- resultExtractor: (body) => (
9352
- // `isPending` guaranteed a fresh row at index 0 before this fires.
9353
- body.data[0]
9354
- )
9355
- }
9356
- );
9357
- return {
9358
- data: WaitForNewConnectionItemSchema.parse({
9359
- id: String(top.public_id ?? top.id),
9360
- app: appKey,
9361
- title: top.title ?? null
9362
- })
9363
- };
9364
- } catch (err) {
9365
- if (err instanceof ZapierTimeoutError) {
9366
- throw new ZapierTimeoutError(
9367
- `Timed out waiting for a new "${appKey}" connection. If the user completed the auth flow, retrieve the connection via sdk.getConnection({ id }) with the ID shown on the completion page.`
9368
- );
9951
+ const response = GetTableRecordApiResponseSchema.parse(rawResponse);
9952
+ const translator = await createFieldKeyTranslator({
9953
+ api,
9954
+ tableId,
9955
+ keyMode: options.keyMode
9956
+ });
9957
+ return {
9958
+ data: {
9959
+ ...transformRecordItem(response.data),
9960
+ data: translator.translateOutput(response.data.data)
9369
9961
  }
9370
- throw err;
9371
- }
9962
+ };
9372
9963
  }
9373
9964
  })
9374
9965
  );
9966
+ var ListTableRecordsApiResponseSchema = zod.z.object({
9967
+ data: zod.z.array(RecordApiItemSchema),
9968
+ meta: zod.z.object({
9969
+ pagination: zod.z.object({
9970
+ start_cursor: zod.z.string().nullable().optional(),
9971
+ end_cursor: zod.z.string().nullable().optional(),
9972
+ has_more: zod.z.boolean().optional(),
9973
+ has_less: zod.z.boolean().optional()
9974
+ }).optional()
9975
+ }).optional()
9976
+ });
9977
+ var FilterOperatorSchema = zod.z.enum([
9978
+ "exact",
9979
+ "different",
9980
+ "contains",
9981
+ "icontains",
9982
+ "gte",
9983
+ "gt",
9984
+ "lt",
9985
+ "lte",
9986
+ "range",
9987
+ "in",
9988
+ "isnull",
9989
+ "startswith",
9990
+ "search",
9991
+ "is_within"
9992
+ ]);
9993
+ var FilterConditionSchema = zod.z.object({
9994
+ fieldKey: zod.z.string().describe("The field key to filter on (e.g. f1, f2)"),
9995
+ operator: FilterOperatorSchema.describe("The comparison operator"),
9996
+ value: zod.z.unknown().optional().describe("The value to compare against")
9997
+ });
9998
+ var SortDirectionSchema = zod.z.enum(["asc", "desc"]);
9999
+ var SortConditionSchema = zod.z.object({
10000
+ fieldKey: zod.z.string().describe("The field key to sort by"),
10001
+ direction: SortDirectionSchema.optional().default("asc").describe("Sort direction")
10002
+ });
10003
+ var ListTableRecordsDescription = "List records in a table with optional filtering and sorting";
10004
+ var ListTableRecordsBase = zod.z.object({
10005
+ filters: zod.z.array(FilterConditionSchema).optional().describe("Filter conditions for the query"),
10006
+ sort: SortConditionSchema.optional().describe("Sort records by a field"),
10007
+ pageSize: zod.z.number().min(1).max(1e3).optional().describe("Number of records per page (max 1000)"),
10008
+ maxItems: zod.z.number().min(1).optional().describe("Maximum total items to return across all pages"),
10009
+ cursor: zod.z.string().optional().describe("Cursor to start from"),
10010
+ keyMode: KeyModeSchema,
10011
+ trash: TrashSchema
10012
+ });
10013
+ var ListTableRecordsOptionsSchema = zod.z.object({
10014
+ table: TablePropertySchema
10015
+ }).merge(ListTableRecordsBase).describe(ListTableRecordsDescription).meta({ aliases: { tableId: "table" } });
10016
+ var ListTableRecordsOptionsSchemaDeprecated = zod.z.object({
10017
+ tableId: zod.z.string().regex(/^[A-Z0-9]{26}$/, "Table ID must be a valid ULID").describe("The unique identifier of the table")
10018
+ }).merge(ListTableRecordsBase);
10019
+ var ListTableRecordsOptionsInputSchema = zod.z.union([
10020
+ ListTableRecordsOptionsSchema,
10021
+ ListTableRecordsOptionsSchemaDeprecated
10022
+ ]).describe(ListTableRecordsDescription);
9375
10023
 
9376
- // src/utils/should-open-browser.ts
9377
- function shouldOpenBrowser() {
9378
- if (isCiEnv()) return false;
9379
- const env = globalThis.process?.env;
9380
- if (env?.SSH_TTY || env?.SSH_CONNECTION) return false;
9381
- if (globalThis.process?.platform === "linux" && !env?.DISPLAY && !env?.WAYLAND_DISPLAY) {
9382
- return false;
9383
- }
9384
- return true;
9385
- }
9386
- function isCiEnv() {
9387
- const env = globalThis.process?.env;
9388
- return !!(env?.CI || env?.CONTINUOUS_INTEGRATION || env?.GITHUB_ACTIONS || env?.JENKINS_URL || env?.GITLAB_CI || env?.CIRCLECI || env?.TRAVIS || env?.BUILDKITE || env?.DRONE || env?.BITBUCKET_PIPELINES_UUID);
9389
- }
9390
- var CreateConnectionSchema = zod.z.object({
9391
- app: AppPropertySchema,
9392
- browser: zod.z.enum(["auto", "always", "never"]).default("auto").describe(
9393
- "When to auto-open the URL in a browser. `auto` (default) opens in local sessions and skips opening in CI / SSH / headless-Linux. `always` forces the open attempt. `never` skips it. The URL is always printed to stderr regardless \u2014 a failed or skipped open degrades gracefully to copy-paste."
9394
- ),
9395
- timeoutMs: zod.z.number().int().positive().optional().describe(
9396
- "How long to wait for the user to complete the connection flow before giving up. Default 5 minutes (300_000)."
9397
- ),
9398
- pollIntervalMs: zod.z.number().int().positive().optional().describe(
9399
- "Delay before the first poll request, in ms. Default 3 seconds (3_000). Subsequent polling cadence is managed by the SDK's polling primitive (backoff with sane defaults)."
9400
- )
9401
- }).describe(
9402
- "Create a new app connection, end-to-end. Mints the start URL via `get-connection-start-url`, prints it to stderr, opportunistically opens it in a browser when it looks safe to do so (skipping CI / SSH / headless-Linux by default \u2014 pass `--browser always` to force, `--browser never` to suppress), then polls via `wait-for-new-connection` until the user completes OAuth and the new connection appears. Returns the connection.\n\nThis is the right command for most callers. Reach for the lower-level building blocks when you want either of: (a) hand off the URL and *not* block on completion \u2014 call `get-connection-start-url` alone, no `wait-for-new-connection` needed, or (b) do something custom between minting the URL and waiting \u2014 call `get-connection-start-url`, do your work (email or DM the URL, render a QR code, etc.), then `wait-for-new-connection`."
9403
- );
9404
- var CreateConnectionItemSchema = zod.z.object({
9405
- id: zod.z.string().describe(
9406
- "The new connection's ID. Public UUID when available, falling back to the numeric ID."
9407
- ),
9408
- app: zod.z.string().describe(
9409
- "Versionless app key the connection was created for (e.g., 'SlackCLIAPI')."
9410
- ),
9411
- title: zod.z.string().nullable().optional().describe(
9412
- "Human-readable connection title set by the auth flow, when available."
9413
- )
9414
- }).describe("The newly created connection.");
10024
+ // src/plugins/tables/listTableRecords/index.ts
10025
+ var listTableRecordsPlugin = definePlugin(
10026
+ (sdk) => createPaginatedPluginMethod(sdk, {
10027
+ ...tablesDefaults,
10028
+ name: "listTableRecords",
10029
+ type: "list",
10030
+ itemType: "Record",
10031
+ inputSchema: ListTableRecordsOptionsInputSchema,
10032
+ outputSchema: RecordItemSchema,
10033
+ defaultPageSize: DEFAULT_PAGE_SIZE,
10034
+ resolvers: {
10035
+ table: tableIdResolver,
10036
+ filters: tableFiltersResolver,
10037
+ sort: tableSortResolver
10038
+ },
10039
+ formatter: tableRecordFormatter,
10040
+ handler: async ({ sdk: sdk2, options }) => {
10041
+ const { api } = sdk2.context;
10042
+ const tableId = "table" in options ? options.table : options.tableId;
10043
+ const translator = await createFieldKeyTranslator({
10044
+ api,
10045
+ tableId,
10046
+ keyMode: options.keyMode
10047
+ });
10048
+ const body = {};
10049
+ if (options.pageSize !== void 0) {
10050
+ body.limit = options.pageSize;
10051
+ }
10052
+ if (options.filters) {
10053
+ body.filters = options.filters.map((f) => ({
10054
+ key: translator.translateFieldKey(f.fieldKey),
10055
+ operator: f.operator,
10056
+ value: f.value
10057
+ }));
10058
+ }
10059
+ if (options.sort) {
10060
+ body.orders = [
10061
+ {
10062
+ key: translator.translateFieldKey(options.sort.fieldKey),
10063
+ direction: options.sort.direction
10064
+ }
10065
+ ];
10066
+ }
10067
+ if (options.cursor) {
10068
+ body.cursor_query = {
10069
+ query_type: "window",
10070
+ start_cursor: options.cursor
10071
+ };
10072
+ }
10073
+ const searchParams = {
10074
+ allow_nested_queries: "true"
10075
+ };
10076
+ if (options.trash) {
10077
+ searchParams.trash = options.trash;
10078
+ }
10079
+ const rawResponse = await api.post(
10080
+ `/tables/api/v1/tables/${tableId}/records/query`,
10081
+ body,
10082
+ {
10083
+ searchParams,
10084
+ authRequired: true,
10085
+ resource: { type: "table", id: tableId }
10086
+ }
10087
+ );
10088
+ throwOnResponseErrors(rawResponse);
10089
+ const response = ListTableRecordsApiResponseSchema.parse(rawResponse);
10090
+ const pagination = response.meta?.pagination;
10091
+ const nextCursor = pagination?.has_more && pagination.end_cursor ? pagination.end_cursor : void 0;
10092
+ return {
10093
+ data: response.data.map((item) => ({
10094
+ ...transformRecordItem(item),
10095
+ data: translator.translateOutput(item.data)
10096
+ })),
10097
+ nextCursor
10098
+ };
10099
+ }
10100
+ })
10101
+ );
10102
+ var RecordChangesetSchema = zod.z.object({
10103
+ change_id: zod.z.string(),
10104
+ old: RecordApiItemSchema.nullable(),
10105
+ new: RecordApiItemSchema,
10106
+ changed_field_ids: zod.z.array(zod.z.number()).nullable(),
10107
+ record_id: zod.z.string()
10108
+ });
10109
+ var CreateTableRecordsApiResponseSchema = zod.z.object({
10110
+ data: zod.z.array(RecordChangesetSchema)
10111
+ });
10112
+ var NewRecordSchema = zod.z.object({
10113
+ data: zod.z.record(zod.z.string(), zod.z.unknown()).describe("The field values for the record, keyed by field ID")
10114
+ });
10115
+ var CreateTableRecordsDescription = "Create one or more records in a table";
10116
+ var CreateTableRecordsBase = zod.z.object({
10117
+ records: zod.z.array(NewRecordSchema).min(1).max(100).describe("Array of records to create (max 100)"),
10118
+ keyMode: KeyModeSchema
10119
+ });
10120
+ var CreateTableRecordsOptionsSchema = zod.z.object({
10121
+ table: TablePropertySchema
10122
+ }).merge(CreateTableRecordsBase).describe(CreateTableRecordsDescription).meta({ aliases: { tableId: "table" } });
10123
+ var CreateTableRecordsOptionsSchemaDeprecated = zod.z.object({
10124
+ tableId: zod.z.string().regex(/^[A-Z0-9]{26}$/, "Table ID must be a valid ULID").describe("The unique identifier of the table")
10125
+ }).merge(CreateTableRecordsBase);
10126
+ var CreateTableRecordsOptionsInputSchema = zod.z.union([
10127
+ CreateTableRecordsOptionsSchema,
10128
+ CreateTableRecordsOptionsSchemaDeprecated
10129
+ ]).describe(CreateTableRecordsDescription);
9415
10130
 
9416
- // src/plugins/createConnection/index.ts
9417
- var createConnectionPlugin = definePlugin(
10131
+ // src/plugins/tables/createTableRecords/index.ts
10132
+ var createTableRecordsPlugin = definePlugin(
9418
10133
  (sdk) => createPluginMethod(sdk, {
9419
- name: "createConnection",
9420
- categories: ["connection"],
10134
+ ...tablesDefaults,
10135
+ name: "createTableRecords",
9421
10136
  type: "create",
9422
- itemType: "Connection",
9423
- inputSchema: CreateConnectionSchema,
9424
- outputSchema: CreateConnectionItemSchema,
9425
- resolvers: { app: appKeyResolver },
9426
- formatter: {
9427
- format: (item) => ({
9428
- title: `Connection created: ${item.title || item.id}`,
9429
- id: item.id,
9430
- details: [
9431
- { text: `App: ${item.app}`, style: "normal" },
9432
- { text: `ID: ${item.id}`, style: "accent" }
9433
- ]
9434
- })
9435
- },
9436
- handler: async ({
9437
- sdk: inner,
9438
- options
9439
- }) => {
9440
- const { data: start } = await inner.getConnectionStartUrl({
9441
- app: options.app
10137
+ itemType: "Record",
10138
+ returnType: "RecordItem[]",
10139
+ inputSchema: CreateTableRecordsOptionsInputSchema,
10140
+ outputSchema: RecordItemSchema,
10141
+ resolvers: { table: tableIdResolver, records: tableRecordsResolver },
10142
+ formatter: tableRecordFormatter,
10143
+ handler: async ({ sdk: sdk2, options }) => {
10144
+ const { api } = sdk2.context;
10145
+ const tableId = "table" in options ? options.table : options.tableId;
10146
+ const translator = await createFieldKeyTranslator({
10147
+ api,
10148
+ tableId,
10149
+ keyMode: options.keyMode
9442
10150
  });
9443
- setMethodMetadata({ selectedApi: start.app });
9444
- console.error(
9445
- `
9446
- Open this URL to complete the connection:
9447
- ${start.url}
9448
- `
10151
+ const rawResponse = await api.post(
10152
+ `/tables/api/v1/tables/${tableId}/records`,
10153
+ {
10154
+ new_records: options.records.map((record) => ({
10155
+ data: translator.translateInput(record.data)
10156
+ }))
10157
+ },
10158
+ { authRequired: true, resource: { type: "table", id: tableId } }
9449
10159
  );
9450
- const shouldOpen = options.browser === "always" || options.browser === "auto" && shouldOpenBrowser();
9451
- if (shouldOpen) {
9452
- try {
9453
- await open_url_default(start.url);
9454
- } catch {
9455
- }
10160
+ throwOnResponseErrors(rawResponse);
10161
+ const response = CreateTableRecordsApiResponseSchema.parse(rawResponse);
10162
+ for (const changeset of response.data) {
10163
+ throwOnRecordErrors(changeset.new);
9456
10164
  }
9457
- const { data: fresh } = await inner.waitForNewConnection({
9458
- app: start.app,
9459
- // Server-stamped mint time: measured on the same clock as a
9460
- // connection's `date`, so the freshness check is immune to
9461
- // client/server clock skew.
9462
- startedAt: start.startedAt,
9463
- timeoutMs: options.timeoutMs,
9464
- pollIntervalMs: options.pollIntervalMs
9465
- });
9466
10165
  return {
9467
- data: CreateConnectionItemSchema.parse({
9468
- id: fresh.id,
9469
- app: start.app,
9470
- title: fresh.title ?? null
9471
- })
10166
+ data: response.data.map((changeset) => ({
10167
+ ...transformRecordItem(changeset.new),
10168
+ data: translator.translateOutput(changeset.new.data)
10169
+ }))
9472
10170
  };
9473
10171
  }
9474
10172
  })
9475
10173
  );
10174
+ var DeleteTableRecordsDescription = "Delete one or more records from a table";
10175
+ var DeleteTableRecordsOptionsSchema = zod.z.object({
10176
+ table: TablePropertySchema,
10177
+ records: RecordsPropertySchema
10178
+ }).describe(DeleteTableRecordsDescription).meta({ aliases: { tableId: "table", recordIds: "records" } });
10179
+ var DeleteTableRecordsOptionsSchemaDeprecated = zod.z.object({
10180
+ tableId: zod.z.string().regex(/^[A-Z0-9]{26}$/, "Table ID must be a valid ULID").describe("The unique identifier of the table"),
10181
+ recordIds: zod.z.array(zod.z.string().regex(/^[A-Z0-9]{26}$/, "Record ID must be a valid ULID")).min(1).max(100).describe("Array of record IDs to delete (max 100)")
10182
+ });
10183
+ var DeleteTableRecordsOptionsInputSchema = zod.z.union([
10184
+ DeleteTableRecordsOptionsSchema,
10185
+ DeleteTableRecordsOptionsSchemaDeprecated
10186
+ ]).describe(DeleteTableRecordsDescription);
9476
10187
 
9477
- // src/plugins/deprecated/authentications.ts
9478
- var listAuthenticationsPlugin = definePlugin(
9479
- (sdk) => ({
9480
- listAuthentications: sdk.listConnections,
9481
- context: {
9482
- meta: {
9483
- listAuthentications: {
9484
- packages: ["cli", "mcp"],
9485
- categories: ["connection"],
9486
- deprecation: { message: "Use listConnections instead." },
9487
- type: "list",
9488
- itemType: "Connection",
9489
- inputSchema: ListConnectionsQuerySchema,
9490
- outputSchema: ConnectionItemSchema,
9491
- formatter: connectionItemFormatter
9492
- }
9493
- }
9494
- }
9495
- })
9496
- );
9497
- var getAuthenticationPlugin = definePlugin(
9498
- (sdk) => ({
9499
- getAuthentication: sdk.getConnection,
9500
- context: {
9501
- meta: {
9502
- getAuthentication: {
9503
- packages: ["cli", "mcp"],
9504
- categories: ["connection"],
9505
- deprecation: { message: "Use getConnection instead." },
9506
- type: "item",
9507
- itemType: "Connection",
9508
- inputSchema: GetConnectionParamSchema,
9509
- outputSchema: ConnectionItemSchema,
9510
- formatter: connectionItemFormatter
10188
+ // src/plugins/tables/deleteTableRecords/index.ts
10189
+ var deleteTableRecordsPlugin = definePlugin(
10190
+ (sdk) => createPluginMethod(sdk, {
10191
+ ...tablesDefaults,
10192
+ name: "deleteTableRecords",
10193
+ type: "delete",
10194
+ itemType: "Record",
10195
+ inputSchema: DeleteTableRecordsOptionsInputSchema,
10196
+ resolvers: { table: tableIdResolver, records: tableRecordIdsResolver },
10197
+ confirm: "delete",
10198
+ handler: async ({ sdk: sdk2, options }) => {
10199
+ const tableId = "table" in options ? options.table : options.tableId;
10200
+ const recordIds = "records" in options ? options.records : options.recordIds;
10201
+ await sdk2.context.api.delete(
10202
+ `/tables/api/v1/tables/${tableId}/records`,
10203
+ { record_ids: recordIds },
10204
+ {
10205
+ authRequired: true,
10206
+ resource: { type: "table", id: tableId }
9511
10207
  }
9512
- }
10208
+ );
10209
+ return { success: true };
9513
10210
  }
9514
10211
  })
9515
10212
  );
9516
- var findFirstAuthenticationPlugin = definePlugin(
9517
- (sdk) => ({
9518
- findFirstAuthentication: sdk.findFirstConnection,
9519
- context: {
9520
- meta: {
9521
- findFirstAuthentication: {
9522
- packages: ["cli", "mcp"],
9523
- categories: ["connection"],
9524
- deprecation: { message: "Use findFirstConnection instead." },
9525
- type: "item",
9526
- itemType: "Connection",
9527
- inputSchema: FindFirstConnectionSchema,
9528
- outputSchema: ConnectionItemSchema,
9529
- formatter: connectionItemFormatter
9530
- }
10213
+ var RecordChangesetSchema2 = zod.z.object({
10214
+ change_id: zod.z.string(),
10215
+ old: RecordApiItemSchema.nullable(),
10216
+ new: RecordApiItemSchema,
10217
+ changed_field_ids: zod.z.array(zod.z.number()).nullable(),
10218
+ record_id: zod.z.string()
10219
+ });
10220
+ var UpdateTableRecordsApiResponseSchema = zod.z.object({
10221
+ data: zod.z.array(RecordChangesetSchema2)
10222
+ });
10223
+ var UpdateRecordSchema = zod.z.object({
10224
+ id: zod.z.string().describe("The record ID to update"),
10225
+ data: zod.z.record(zod.z.string(), zod.z.unknown()).describe("The field values to update, keyed by field key")
10226
+ });
10227
+ var UpdateTableRecordsDescription = "Update one or more records in a table";
10228
+ var UpdateTableRecordsBase = zod.z.object({
10229
+ records: zod.z.array(UpdateRecordSchema).min(1).max(100).describe("Array of records to update (max 100)"),
10230
+ keyMode: KeyModeSchema
10231
+ });
10232
+ var UpdateTableRecordsOptionsSchema = zod.z.object({
10233
+ table: TablePropertySchema
10234
+ }).merge(UpdateTableRecordsBase).describe(UpdateTableRecordsDescription).meta({ aliases: { tableId: "table" } });
10235
+ var UpdateTableRecordsOptionsSchemaDeprecated = zod.z.object({
10236
+ tableId: zod.z.string().regex(/^[A-Z0-9]{26}$/, "Table ID must be a valid ULID").describe("The unique identifier of the table")
10237
+ }).merge(UpdateTableRecordsBase);
10238
+ var UpdateTableRecordsOptionsInputSchema = zod.z.union([
10239
+ UpdateTableRecordsOptionsSchema,
10240
+ UpdateTableRecordsOptionsSchemaDeprecated
10241
+ ]).describe(UpdateTableRecordsDescription);
10242
+
10243
+ // src/plugins/tables/updateTableRecords/index.ts
10244
+ var updateTableRecordsPlugin = definePlugin(
10245
+ (sdk) => createPluginMethod(sdk, {
10246
+ ...tablesDefaults,
10247
+ name: "updateTableRecords",
10248
+ type: "update",
10249
+ itemType: "Record",
10250
+ returnType: "RecordItem[]",
10251
+ inputSchema: UpdateTableRecordsOptionsInputSchema,
10252
+ outputSchema: RecordItemSchema,
10253
+ resolvers: {
10254
+ table: tableIdResolver,
10255
+ records: tableUpdateRecordsResolver
10256
+ },
10257
+ formatter: tableRecordFormatter,
10258
+ handler: async ({ sdk: sdk2, options }) => {
10259
+ const { api } = sdk2.context;
10260
+ const tableId = "table" in options ? options.table : options.tableId;
10261
+ const translator = await createFieldKeyTranslator({
10262
+ api,
10263
+ tableId,
10264
+ keyMode: options.keyMode
10265
+ });
10266
+ const rawResponse = await api.patch(
10267
+ `/tables/api/v1/tables/${tableId}/records`,
10268
+ {
10269
+ updated_records: options.records.map((record) => ({
10270
+ id: record.id,
10271
+ data: translator.translateInput(record.data)
10272
+ }))
10273
+ },
10274
+ { authRequired: true, resource: { type: "table", id: tableId } }
10275
+ );
10276
+ throwOnResponseErrors(rawResponse);
10277
+ const response = UpdateTableRecordsApiResponseSchema.parse(rawResponse);
10278
+ for (const changeset of response.data) {
10279
+ throwOnRecordErrors(changeset.new);
9531
10280
  }
10281
+ return {
10282
+ data: response.data.map((changeset) => ({
10283
+ ...transformRecordItem(changeset.new),
10284
+ data: translator.translateOutput(changeset.new.data)
10285
+ }))
10286
+ };
9532
10287
  }
9533
10288
  })
9534
10289
  );
9535
- var findUniqueAuthenticationPlugin = definePlugin(
9536
- (sdk) => ({
9537
- findUniqueAuthentication: sdk.findUniqueConnection,
9538
- context: {
9539
- meta: {
9540
- findUniqueAuthentication: {
9541
- packages: ["cli", "mcp"],
9542
- categories: ["connection"],
9543
- deprecation: { message: "Use findUniqueConnection instead." },
9544
- type: "item",
9545
- itemType: "Connection",
9546
- inputSchema: FindUniqueConnectionSchema,
9547
- outputSchema: ConnectionItemSchema,
9548
- formatter: connectionItemFormatter
9549
- }
10290
+
10291
+ // src/plugins/capabilities/index.ts
10292
+ function toDescription(key) {
10293
+ const words = key.replace(/^can/, "").replace(/([A-Z])/g, " $1").trim().toLowerCase();
10294
+ return `To ${words}`;
10295
+ }
10296
+ function toEnvVar(key) {
10297
+ return "ZAPIER_" + key.replace(/([A-Z])/g, "_$1").toUpperCase();
10298
+ }
10299
+ function toCliFlag(key) {
10300
+ return "--" + key.replace(/([A-Z])/g, "-$1").toLowerCase();
10301
+ }
10302
+ function buildCapabilityMessage(key) {
10303
+ return [
10304
+ `${toDescription(key)}, use ${toCliFlag(key)} in the CLI,`,
10305
+ `set ${key}: true in SDK options or .zapierrc,`,
10306
+ `or set ${toEnvVar(key)}=true.`
10307
+ ].join(" ");
10308
+ }
10309
+ var GATED_FLAGS = [
10310
+ "canIncludeSharedConnections",
10311
+ "canIncludeSharedTables",
10312
+ "canDeleteTables"
10313
+ ];
10314
+ function isEnabledByEnv(key) {
10315
+ const value = globalThis.process?.env?.[toEnvVar(key)];
10316
+ if (value === void 0) return void 0;
10317
+ if (value === "true" || value === "1") return true;
10318
+ if (value === "false" || value === "0") return false;
10319
+ return void 0;
10320
+ }
10321
+ var capabilitiesPlugin = definePlugin(
10322
+ (sdk) => {
10323
+ const options = sdk.context.options ?? {};
10324
+ let cached;
10325
+ async function resolveFlags() {
10326
+ if (cached) return cached;
10327
+ const manifest = await sdk.context.getResolvedManifest();
10328
+ cached = {};
10329
+ for (const flag of GATED_FLAGS) {
10330
+ cached[flag] = Boolean(
10331
+ options[flag] ?? isEnabledByEnv(flag) ?? manifest?.[flag]
10332
+ );
9550
10333
  }
10334
+ return cached;
9551
10335
  }
9552
- })
9553
- );
9554
-
9555
- // src/plugins/deprecated/inputFields.ts
9556
- var listInputFieldsDeprecatedPlugin = definePlugin(
9557
- (sdk) => ({
9558
- listInputFields: sdk.listActionInputFields,
9559
- context: {
9560
- meta: {
9561
- listInputFields: {
9562
- categories: ["action"],
9563
- deprecation: { message: "Use listActionInputFields instead." },
9564
- type: "list",
9565
- itemType: "RootField",
9566
- inputSchema: ListActionInputFieldsInputSchema,
9567
- outputSchema: RootFieldItemSchema,
9568
- formatter: rootFieldItemFormatter,
9569
- defaultPageSize: DEFAULT_PAGE_SIZE
10336
+ return {
10337
+ context: {
10338
+ checkCapability: async (key) => {
10339
+ const flags = await resolveFlags();
10340
+ if (flags[key]) return;
10341
+ throw new ZapierConfigurationError(
10342
+ buildCapabilityMessage(key) + " (If you are an AI agent, you MUST NOT retry. Ask the user if they want to enable this.)",
10343
+ { configType: key }
10344
+ );
10345
+ },
10346
+ hasCapability: async (key) => {
10347
+ const flags = await resolveFlags();
10348
+ return flags[key];
9570
10349
  }
9571
10350
  }
9572
- }
9573
- })
10351
+ };
10352
+ }
9574
10353
  );
9575
- var listInputFieldChoicesDeprecatedPlugin = definePlugin(
9576
- (sdk) => ({
9577
- listInputFieldChoices: sdk.listActionInputFieldChoices,
9578
- context: {
9579
- meta: {
9580
- listInputFieldChoices: {
9581
- categories: ["action"],
9582
- deprecation: {
9583
- message: "Use listActionInputFieldChoices instead."
9584
- },
9585
- type: "list",
9586
- itemType: "InputFieldChoiceItem",
9587
- inputSchema: ListActionInputFieldChoicesInputSchema,
9588
- outputSchema: InputFieldChoiceItemSchema,
9589
- formatter: inputFieldChoiceItemFormatter,
9590
- defaultPageSize: DEFAULT_PAGE_SIZE
9591
- }
10354
+
10355
+ // src/plugins/connections/index.ts
10356
+ var connectionsPlugin = definePlugin(
10357
+ (sdk) => {
10358
+ let cachedMap;
10359
+ async function loadConnectionsMap() {
10360
+ if (cachedMap === void 0) {
10361
+ cachedMap = await sdk.context.getManifestConnections() ?? null;
9592
10362
  }
10363
+ return cachedMap;
9593
10364
  }
9594
- })
9595
- );
9596
- var getInputFieldsSchemaDeprecatedPlugin = definePlugin(
9597
- (sdk) => ({
9598
- getInputFieldsSchema: sdk.getActionInputFieldsSchema,
9599
- context: {
9600
- meta: {
9601
- getInputFieldsSchema: {
9602
- categories: ["action"],
9603
- deprecation: { message: "Use getActionInputFieldsSchema instead." },
9604
- type: "function",
9605
- inputSchema: GetActionInputFieldsSchemaInputSchema
10365
+ return {
10366
+ context: {
10367
+ resolveConnection: async (name) => {
10368
+ const map = await loadConnectionsMap();
10369
+ return map?.[name];
10370
+ },
10371
+ getConnectionsMap: async () => {
10372
+ return loadConnectionsMap();
9606
10373
  }
9607
10374
  }
9608
- }
9609
- })
10375
+ };
10376
+ }
9610
10377
  );
9611
10378
 
9612
10379
  // src/plugins/eventEmission/transport.ts
@@ -10300,12 +11067,6 @@ var eventEmissionPlugin = definePlugin(
10300
11067
  function createOptionsPlugin(options) {
10301
11068
  return () => ({ context: { options } });
10302
11069
  }
10303
- function createSdk() {
10304
- logDeprecation2(
10305
- "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."
10306
- );
10307
- return withDeprecatedAddPlugin(createZapierCoreStack().toSdk());
10308
- }
10309
11070
  function createZapierSdkWithoutRegistry(options = {}) {
10310
11071
  logDeprecation2(
10311
11072
  "createZapierSdkWithoutRegistry is deprecated; use createZapierSdk instead. getRegistry is now available on every sdk."
@@ -10313,10 +11074,112 @@ function createZapierSdkWithoutRegistry(options = {}) {
10313
11074
  return createZapierSdk(options);
10314
11075
  }
10315
11076
  function createZapierSdkStack(options = {}) {
10316
- 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(getConnectionStartUrlPlugin).use(waitForNewConnectionPlugin).use(createConnectionPlugin).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);
11077
+ 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(getConnectionStartUrlPlugin).use(waitForNewConnectionPlugin).use(createConnectionPlugin).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);
10317
11078
  }
11079
+ var zapierSdkPlugin = definePlugin({
11080
+ namespace: "zapier",
11081
+ name: "sdk",
11082
+ exports: [getProfilePlugin]
11083
+ });
10318
11084
  function createZapierSdk(options = {}) {
10319
- return withDeprecatedAddPlugin(createZapierSdkStack(options).toSdk());
11085
+ return createSdk(
11086
+ defineLegacyMerge({
11087
+ namespace: "zapier",
11088
+ name: "sdk-stack-merge",
11089
+ legacy: createZapierSdkStack(options).toPlugin(),
11090
+ plugin: zapierSdkPlugin
11091
+ })
11092
+ );
11093
+ }
11094
+
11095
+ // src/utils/batch-utils.ts
11096
+ var DEFAULT_CONCURRENCY = 10;
11097
+ var BATCH_START_DELAY_MS = 25;
11098
+ var DEFAULT_BATCH_TIMEOUT_MS = 18e4;
11099
+ async function batch(tasks, options = {}) {
11100
+ const {
11101
+ concurrency = DEFAULT_CONCURRENCY,
11102
+ retry = true,
11103
+ batchDelay = BATCH_START_DELAY_MS,
11104
+ timeoutMs = DEFAULT_BATCH_TIMEOUT_MS,
11105
+ taskTimeoutMs
11106
+ } = options;
11107
+ if (concurrency <= 0) {
11108
+ throw new Error("Concurrency must be greater than 0");
11109
+ }
11110
+ if (timeoutMs <= 0) {
11111
+ throw new Error("Timeout must be greater than 0");
11112
+ }
11113
+ if (taskTimeoutMs !== void 0 && taskTimeoutMs <= 0) {
11114
+ throw new Error("Task timeout must be greater than 0");
11115
+ }
11116
+ if (tasks.length === 0) {
11117
+ return [];
11118
+ }
11119
+ const startTime = Date.now();
11120
+ const results = new Array(tasks.length);
11121
+ const taskQueue = tasks.map((task, index) => ({
11122
+ index,
11123
+ task,
11124
+ errorCount: 0
11125
+ }));
11126
+ async function executeTask(taskState) {
11127
+ const { index, task, errorCount } = taskState;
11128
+ try {
11129
+ let result;
11130
+ if (taskTimeoutMs !== void 0) {
11131
+ const timeoutPromise = sleep(taskTimeoutMs).then(() => {
11132
+ throw new ZapierTimeoutError(
11133
+ `Task timed out after ${taskTimeoutMs}ms`
11134
+ );
11135
+ });
11136
+ result = await Promise.race([task(), timeoutPromise]);
11137
+ } else {
11138
+ result = await task();
11139
+ }
11140
+ results[index] = { status: "fulfilled", value: result };
11141
+ } catch (error) {
11142
+ const newErrorCount = errorCount + 1;
11143
+ const isTimeout = error instanceof ZapierTimeoutError;
11144
+ if (retry && !isTimeout && newErrorCount < MAX_CONSECUTIVE_ERRORS) {
11145
+ const waitTime = calculateErrorBackoffMs(1e3, newErrorCount);
11146
+ await sleep(waitTime);
11147
+ taskQueue.push({
11148
+ index,
11149
+ task,
11150
+ errorCount: newErrorCount
11151
+ });
11152
+ } else {
11153
+ results[index] = { status: "rejected", reason: error };
11154
+ }
11155
+ }
11156
+ }
11157
+ async function worker() {
11158
+ while (taskQueue.length > 0) {
11159
+ const elapsedTime = Date.now() - startTime;
11160
+ if (elapsedTime >= timeoutMs) {
11161
+ throw new ZapierTimeoutError(
11162
+ `Batch operation timed out after ${Math.floor(elapsedTime / 1e3)}s. ${taskQueue.length} task(s) not completed.`
11163
+ );
11164
+ }
11165
+ const taskState = taskQueue.shift();
11166
+ if (!taskState) break;
11167
+ await executeTask(taskState);
11168
+ if (taskQueue.length > 0 && batchDelay > 0) {
11169
+ await sleep(batchDelay);
11170
+ }
11171
+ }
11172
+ }
11173
+ const workerCount = Math.min(concurrency, tasks.length);
11174
+ const workers = [];
11175
+ for (let i = 0; i < workerCount; i++) {
11176
+ workers.push(worker());
11177
+ if (i < workerCount - 1 && batchDelay > 0) {
11178
+ await sleep(batchDelay / 10);
11179
+ }
11180
+ }
11181
+ await Promise.all(workers);
11182
+ return results;
10320
11183
  }
10321
11184
  var BaseSdkOptionsSchema = zod.z.object({
10322
11185
  credentials: CredentialsSchema.optional().describe(
@@ -10502,7 +11365,13 @@ exports.createZapierCoreStack = createZapierCoreStack;
10502
11365
  exports.createZapierSdk = createZapierSdk;
10503
11366
  exports.createZapierSdkStack = createZapierSdkStack;
10504
11367
  exports.createZapierSdkWithoutRegistry = createZapierSdkWithoutRegistry;
11368
+ exports.dangerousContextPlugin = dangerousContextPlugin;
11369
+ exports.declareMethod = declareMethod;
11370
+ exports.declareProperty = declareProperty;
11371
+ exports.defineLegacyMerge = defineLegacyMerge;
11372
+ exports.defineMethod = defineMethod;
10505
11373
  exports.definePlugin = definePlugin;
11374
+ exports.defineProperty = defineProperty;
10506
11375
  exports.deleteClientCredentialsPlugin = deleteClientCredentialsPlugin;
10507
11376
  exports.deleteTableFieldsPlugin = deleteTableFieldsPlugin;
10508
11377
  exports.deleteTablePlugin = deleteTablePlugin;
@@ -10514,6 +11383,7 @@ exports.findFirstConnectionPlugin = findFirstConnectionPlugin;
10514
11383
  exports.findManifestEntry = findManifestEntry;
10515
11384
  exports.findUniqueConnectionPlugin = findUniqueConnectionPlugin;
10516
11385
  exports.formatErrorMessage = formatErrorMessage;
11386
+ exports.fromFunctionPlugin = fromFunctionPlugin;
10517
11387
  exports.generateEventId = generateEventId;
10518
11388
  exports.getActionInputFieldsSchemaPlugin = getActionInputFieldsSchemaPlugin;
10519
11389
  exports.getActionPlugin = getActionPlugin;
@@ -10524,6 +11394,7 @@ exports.getCallerContext = getCallerContext;
10524
11394
  exports.getCiPlatform = getCiPlatform;
10525
11395
  exports.getClientIdFromCredentials = getClientIdFromCredentials;
10526
11396
  exports.getConnectionPlugin = getConnectionPlugin;
11397
+ exports.getContext = getContext;
10527
11398
  exports.getCoreErrorCause = getCoreErrorCause;
10528
11399
  exports.getCoreErrorCode = getCoreErrorCode;
10529
11400
  exports.getCpuTime = getCpuTime;
@@ -10601,3 +11472,4 @@ exports.workflowIdResolver = workflowIdResolver;
10601
11472
  exports.workflowRunIdResolver = workflowRunIdResolver;
10602
11473
  exports.workflowVersionIdResolver = workflowVersionIdResolver;
10603
11474
  exports.zapierAdaptError = zapierAdaptError;
11475
+ exports.zapierSdkPlugin = zapierSdkPlugin;