@zapier/zapier-sdk 0.65.0 → 0.68.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 (491) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/README.md +64 -34
  3. package/dist/api/client.d.ts.map +1 -1
  4. package/dist/api/client.js +2 -0
  5. package/dist/api/debug.d.ts.map +1 -1
  6. package/dist/api/debug.js +6 -4
  7. package/dist/api/polling.d.ts +2 -0
  8. package/dist/api/polling.d.ts.map +1 -1
  9. package/dist/api/polling.js +10 -2
  10. package/dist/auth.d.ts.map +1 -1
  11. package/dist/auth.js +8 -5
  12. package/dist/core-stack.d.ts +24 -0
  13. package/dist/core-stack.d.ts.map +1 -0
  14. package/dist/core-stack.js +32 -0
  15. package/dist/experimental.cjs +1598 -1323
  16. package/dist/experimental.d.mts +3476 -224
  17. package/dist/experimental.d.ts +3508 -256
  18. package/dist/experimental.d.ts.map +1 -1
  19. package/dist/experimental.js +117 -87
  20. package/dist/experimental.mjs +1585 -1322
  21. package/dist/formatters/action.d.ts +4 -0
  22. package/dist/formatters/action.d.ts.map +1 -0
  23. package/dist/formatters/action.js +18 -0
  24. package/dist/formatters/actionResult.d.ts +3 -0
  25. package/dist/formatters/actionResult.d.ts.map +1 -0
  26. package/dist/formatters/actionResult.js +25 -0
  27. package/dist/formatters/app.d.ts +4 -0
  28. package/dist/formatters/app.d.ts.map +1 -0
  29. package/dist/formatters/app.js +10 -0
  30. package/dist/formatters/clientCredentials.d.ts +5 -0
  31. package/dist/formatters/clientCredentials.d.ts.map +1 -0
  32. package/dist/formatters/clientCredentials.js +27 -0
  33. package/dist/formatters/connection.d.ts +4 -0
  34. package/dist/formatters/connection.d.ts.map +1 -0
  35. package/dist/formatters/connection.js +26 -0
  36. package/dist/formatters/field.d.ts +4 -0
  37. package/dist/formatters/field.d.ts.map +1 -0
  38. package/dist/formatters/field.js +51 -0
  39. package/dist/formatters/inputFieldChoice.d.ts +4 -0
  40. package/dist/formatters/inputFieldChoice.d.ts.map +1 -0
  41. package/dist/formatters/inputFieldChoice.js +16 -0
  42. package/dist/formatters/tableField.d.ts +4 -0
  43. package/dist/formatters/tableField.d.ts.map +1 -0
  44. package/dist/formatters/tableField.js +7 -0
  45. package/dist/formatters/tableRecord.d.ts +5 -3
  46. package/dist/formatters/tableRecord.d.ts.map +1 -1
  47. package/dist/formatters/tableRecord.js +4 -3
  48. package/dist/formatters/triggerInbox.d.ts +4 -0
  49. package/dist/formatters/triggerInbox.d.ts.map +1 -0
  50. package/dist/formatters/triggerInbox.js +31 -0
  51. package/dist/formatters/triggerMessage.d.ts +5 -0
  52. package/dist/formatters/triggerMessage.d.ts.map +1 -0
  53. package/dist/formatters/triggerMessage.js +34 -0
  54. package/dist/formatters/userProfile.d.ts +4 -0
  55. package/dist/formatters/userProfile.d.ts.map +1 -0
  56. package/dist/formatters/userProfile.js +19 -0
  57. package/dist/{index-JhNxS_mq.d.mts → index-oRnHsPn5.d.mts} +12906 -7603
  58. package/dist/{index-JhNxS_mq.d.ts → index-oRnHsPn5.d.ts} +12906 -7603
  59. package/dist/index.cjs +1729 -1469
  60. package/dist/index.d.mts +2 -2
  61. package/dist/index.d.ts +12 -9
  62. package/dist/index.d.ts.map +1 -1
  63. package/dist/index.js +21 -7
  64. package/dist/index.mjs +1716 -1468
  65. package/dist/plugins/api/index.d.ts +1 -1
  66. package/dist/plugins/api/index.js +1 -1
  67. package/dist/plugins/apps/index.d.ts +8 -5
  68. package/dist/plugins/apps/index.d.ts.map +1 -1
  69. package/dist/plugins/apps/index.js +1 -1
  70. package/dist/plugins/capabilities/index.d.ts +1 -1
  71. package/dist/plugins/capabilities/index.js +1 -1
  72. package/dist/plugins/codeSubstrate/cancelDurableRun/index.d.ts +32 -2
  73. package/dist/plugins/codeSubstrate/cancelDurableRun/index.d.ts.map +1 -1
  74. package/dist/plugins/codeSubstrate/cancelDurableRun/index.js +1 -1
  75. package/dist/plugins/codeSubstrate/createWorkflow/index.d.ts +2 -2
  76. package/dist/plugins/codeSubstrate/createWorkflow/index.js +1 -1
  77. package/dist/plugins/codeSubstrate/deleteWorkflow/index.d.ts +27 -2
  78. package/dist/plugins/codeSubstrate/deleteWorkflow/index.d.ts.map +1 -1
  79. package/dist/plugins/codeSubstrate/deleteWorkflow/index.js +1 -1
  80. package/dist/plugins/codeSubstrate/disableWorkflow/index.d.ts +27 -2
  81. package/dist/plugins/codeSubstrate/disableWorkflow/index.d.ts.map +1 -1
  82. package/dist/plugins/codeSubstrate/disableWorkflow/index.js +1 -1
  83. package/dist/plugins/codeSubstrate/enableWorkflow/index.d.ts +27 -2
  84. package/dist/plugins/codeSubstrate/enableWorkflow/index.d.ts.map +1 -1
  85. package/dist/plugins/codeSubstrate/enableWorkflow/index.js +1 -1
  86. package/dist/plugins/codeSubstrate/getDurableRun/index.d.ts +32 -2
  87. package/dist/plugins/codeSubstrate/getDurableRun/index.d.ts.map +1 -1
  88. package/dist/plugins/codeSubstrate/getDurableRun/index.js +1 -1
  89. package/dist/plugins/codeSubstrate/getTriggerRun/index.d.ts +2 -2
  90. package/dist/plugins/codeSubstrate/getTriggerRun/index.js +1 -1
  91. package/dist/plugins/codeSubstrate/getWorkflow/index.d.ts +27 -2
  92. package/dist/plugins/codeSubstrate/getWorkflow/index.d.ts.map +1 -1
  93. package/dist/plugins/codeSubstrate/getWorkflow/index.js +1 -1
  94. package/dist/plugins/codeSubstrate/getWorkflowRun/index.d.ts +55 -2
  95. package/dist/plugins/codeSubstrate/getWorkflowRun/index.d.ts.map +1 -1
  96. package/dist/plugins/codeSubstrate/getWorkflowRun/index.js +1 -1
  97. package/dist/plugins/codeSubstrate/getWorkflowVersion/index.d.ts +51 -2
  98. package/dist/plugins/codeSubstrate/getWorkflowVersion/index.d.ts.map +1 -1
  99. package/dist/plugins/codeSubstrate/getWorkflowVersion/index.js +1 -1
  100. package/dist/plugins/codeSubstrate/listDurableRuns/index.d.ts +3 -3
  101. package/dist/plugins/codeSubstrate/listDurableRuns/index.d.ts.map +1 -1
  102. package/dist/plugins/codeSubstrate/listDurableRuns/index.js +1 -1
  103. package/dist/plugins/codeSubstrate/listWorkflowRuns/index.d.ts +28 -3
  104. package/dist/plugins/codeSubstrate/listWorkflowRuns/index.d.ts.map +1 -1
  105. package/dist/plugins/codeSubstrate/listWorkflowRuns/index.js +1 -1
  106. package/dist/plugins/codeSubstrate/listWorkflowVersions/index.d.ts +28 -3
  107. package/dist/plugins/codeSubstrate/listWorkflowVersions/index.d.ts.map +1 -1
  108. package/dist/plugins/codeSubstrate/listWorkflowVersions/index.js +1 -1
  109. package/dist/plugins/codeSubstrate/listWorkflows/index.d.ts +3 -3
  110. package/dist/plugins/codeSubstrate/listWorkflows/index.d.ts.map +1 -1
  111. package/dist/plugins/codeSubstrate/listWorkflows/index.js +2 -3
  112. package/dist/plugins/codeSubstrate/publishWorkflowVersion/index.d.ts +27 -2
  113. package/dist/plugins/codeSubstrate/publishWorkflowVersion/index.d.ts.map +1 -1
  114. package/dist/plugins/codeSubstrate/publishWorkflowVersion/index.js +1 -1
  115. package/dist/plugins/codeSubstrate/runDurable/index.d.ts +2 -2
  116. package/dist/plugins/codeSubstrate/runDurable/index.js +1 -1
  117. package/dist/plugins/codeSubstrate/triggerWorkflow/index.d.ts +73 -0
  118. package/dist/plugins/codeSubstrate/triggerWorkflow/index.d.ts.map +1 -0
  119. package/dist/plugins/codeSubstrate/triggerWorkflow/index.js +52 -0
  120. package/dist/plugins/codeSubstrate/triggerWorkflow/schemas.d.ts +16 -0
  121. package/dist/plugins/codeSubstrate/triggerWorkflow/schemas.d.ts.map +1 -0
  122. package/dist/plugins/codeSubstrate/triggerWorkflow/schemas.js +31 -0
  123. package/dist/plugins/codeSubstrate/updateWorkflow/index.d.ts +27 -2
  124. package/dist/plugins/codeSubstrate/updateWorkflow/index.d.ts.map +1 -1
  125. package/dist/plugins/codeSubstrate/updateWorkflow/index.js +1 -1
  126. package/dist/plugins/connections/index.d.ts +1 -1
  127. package/dist/plugins/connections/index.js +1 -1
  128. package/dist/plugins/createClientCredentials/index.d.ts +2 -2
  129. package/dist/plugins/createClientCredentials/index.d.ts.map +1 -1
  130. package/dist/plugins/createClientCredentials/index.js +4 -2
  131. package/dist/plugins/createClientCredentials/schemas.d.ts +1 -2
  132. package/dist/plugins/createClientCredentials/schemas.d.ts.map +1 -1
  133. package/dist/plugins/deleteClientCredentials/index.d.ts +24 -2
  134. package/dist/plugins/deleteClientCredentials/index.d.ts.map +1 -1
  135. package/dist/plugins/deleteClientCredentials/index.js +2 -2
  136. package/dist/plugins/deleteClientCredentials/schemas.d.ts +1 -2
  137. package/dist/plugins/deleteClientCredentials/schemas.d.ts.map +1 -1
  138. package/dist/plugins/deprecated/authentications.d.ts +144 -16
  139. package/dist/plugins/deprecated/authentications.d.ts.map +1 -1
  140. package/dist/plugins/deprecated/authentications.js +14 -5
  141. package/dist/plugins/deprecated/inputFields.d.ts +58 -23
  142. package/dist/plugins/deprecated/inputFields.d.ts.map +1 -1
  143. package/dist/plugins/deprecated/inputFields.js +15 -7
  144. package/dist/plugins/eventEmission/event-emission-hook.d.ts +10 -0
  145. package/dist/plugins/eventEmission/event-emission-hook.d.ts.map +1 -0
  146. package/dist/plugins/eventEmission/event-emission-hook.js +47 -0
  147. package/dist/plugins/eventEmission/index.d.ts +5 -3
  148. package/dist/plugins/eventEmission/index.d.ts.map +1 -1
  149. package/dist/plugins/eventEmission/index.js +16 -9
  150. package/dist/plugins/eventEmission/method-metadata.d.ts +16 -0
  151. package/dist/plugins/eventEmission/method-metadata.d.ts.map +1 -0
  152. package/dist/plugins/eventEmission/method-metadata.js +20 -0
  153. package/dist/plugins/eventEmission/transport.d.ts.map +1 -1
  154. package/dist/plugins/eventEmission/transport.js +2 -1
  155. package/dist/plugins/eventEmission/types.d.ts +1 -1
  156. package/dist/plugins/eventEmission/types.d.ts.map +1 -1
  157. package/dist/plugins/fetch/index.d.ts +11 -5
  158. package/dist/plugins/fetch/index.d.ts.map +1 -1
  159. package/dist/plugins/fetch/index.js +42 -32
  160. package/dist/plugins/fetch/schemas.d.ts +1 -1
  161. package/dist/plugins/findFirstConnection/index.d.ts +4 -4
  162. package/dist/plugins/findFirstConnection/index.d.ts.map +1 -1
  163. package/dist/plugins/findFirstConnection/index.js +4 -2
  164. package/dist/plugins/findFirstConnection/schemas.d.ts +2 -2
  165. package/dist/plugins/findUniqueConnection/index.d.ts +4 -4
  166. package/dist/plugins/findUniqueConnection/index.d.ts.map +1 -1
  167. package/dist/plugins/findUniqueConnection/index.js +4 -2
  168. package/dist/plugins/findUniqueConnection/schemas.d.ts +2 -2
  169. package/dist/plugins/getAction/index.d.ts +141 -4
  170. package/dist/plugins/getAction/index.d.ts.map +1 -1
  171. package/dist/plugins/getAction/index.js +5 -3
  172. package/dist/plugins/getAction/schemas.d.ts +6 -6
  173. package/dist/plugins/getActionInputFieldsSchema/index.d.ts +232 -3
  174. package/dist/plugins/getActionInputFieldsSchema/index.d.ts.map +1 -1
  175. package/dist/plugins/getActionInputFieldsSchema/index.js +3 -3
  176. package/dist/plugins/getActionInputFieldsSchema/schemas.d.ts +6 -6
  177. package/dist/plugins/getApp/index.d.ts +4 -4
  178. package/dist/plugins/getApp/index.d.ts.map +1 -1
  179. package/dist/plugins/getApp/index.js +3 -1
  180. package/dist/plugins/getApp/schemas.d.ts +4 -4
  181. package/dist/plugins/getConnection/index.d.ts +125 -2
  182. package/dist/plugins/getConnection/index.d.ts.map +1 -1
  183. package/dist/plugins/getConnection/index.js +4 -2
  184. package/dist/plugins/getProfile/index.d.ts +2 -2
  185. package/dist/plugins/getProfile/index.d.ts.map +1 -1
  186. package/dist/plugins/getProfile/index.js +4 -2
  187. package/dist/plugins/getProfile/schemas.d.ts +1 -2
  188. package/dist/plugins/getProfile/schemas.d.ts.map +1 -1
  189. package/dist/plugins/listActionInputFieldChoices/index.d.ts +287 -4
  190. package/dist/plugins/listActionInputFieldChoices/index.d.ts.map +1 -1
  191. package/dist/plugins/listActionInputFieldChoices/index.js +6 -4
  192. package/dist/plugins/listActionInputFieldChoices/schemas.d.ts +8 -8
  193. package/dist/plugins/listActionInputFieldChoices/schemas.d.ts.map +1 -1
  194. package/dist/plugins/listActionInputFieldChoices/schemas.js +1 -22
  195. package/dist/plugins/listActionInputFields/index.d.ts +168 -5
  196. package/dist/plugins/listActionInputFields/index.d.ts.map +1 -1
  197. package/dist/plugins/listActionInputFields/index.js +7 -5
  198. package/dist/plugins/listActionInputFields/schemas.d.ts +6 -6
  199. package/dist/plugins/listActions/index.d.ts +140 -3
  200. package/dist/plugins/listActions/index.d.ts.map +1 -1
  201. package/dist/plugins/listActions/index.js +6 -4
  202. package/dist/plugins/listActions/schemas.d.ts +4 -4
  203. package/dist/plugins/listApps/index.d.ts +3 -3
  204. package/dist/plugins/listApps/index.d.ts.map +1 -1
  205. package/dist/plugins/listApps/index.js +6 -4
  206. package/dist/plugins/listClientCredentials/index.d.ts +3 -3
  207. package/dist/plugins/listClientCredentials/index.d.ts.map +1 -1
  208. package/dist/plugins/listClientCredentials/index.js +6 -4
  209. package/dist/plugins/listConnections/index.d.ts +140 -3
  210. package/dist/plugins/listConnections/index.d.ts.map +1 -1
  211. package/dist/plugins/listConnections/index.js +7 -5
  212. package/dist/plugins/listConnections/schemas.d.ts +2 -2
  213. package/dist/plugins/manifest/index.d.ts +1 -1
  214. package/dist/plugins/manifest/index.d.ts.map +1 -1
  215. package/dist/plugins/manifest/index.js +6 -4
  216. package/dist/plugins/registry/index.d.ts +1 -1
  217. package/dist/plugins/registry/index.js +1 -1
  218. package/dist/plugins/request/index.d.ts +8 -5
  219. package/dist/plugins/request/index.d.ts.map +1 -1
  220. package/dist/plugins/request/index.js +4 -3
  221. package/dist/plugins/request/schemas.d.ts +2 -2
  222. package/dist/plugins/runAction/index.d.ts +168 -5
  223. package/dist/plugins/runAction/index.d.ts.map +1 -1
  224. package/dist/plugins/runAction/index.js +9 -5
  225. package/dist/plugins/runAction/schemas.d.ts +6 -6
  226. package/dist/plugins/tables/createTable/index.d.ts +2 -2
  227. package/dist/plugins/tables/createTable/index.js +2 -2
  228. package/dist/plugins/tables/createTable/schemas.d.ts +1 -2
  229. package/dist/plugins/tables/createTable/schemas.d.ts.map +1 -1
  230. package/dist/plugins/tables/createTableFields/index.d.ts +34 -2
  231. package/dist/plugins/tables/createTableFields/index.d.ts.map +1 -1
  232. package/dist/plugins/tables/createTableFields/index.js +4 -2
  233. package/dist/plugins/tables/createTableFields/schemas.d.ts +3 -4
  234. package/dist/plugins/tables/createTableFields/schemas.d.ts.map +1 -1
  235. package/dist/plugins/tables/createTableRecords/index.d.ts +63 -2
  236. package/dist/plugins/tables/createTableRecords/index.d.ts.map +1 -1
  237. package/dist/plugins/tables/createTableRecords/index.js +2 -2
  238. package/dist/plugins/tables/createTableRecords/schemas.d.ts +3 -4
  239. package/dist/plugins/tables/createTableRecords/schemas.d.ts.map +1 -1
  240. package/dist/plugins/tables/deleteTable/index.d.ts +34 -2
  241. package/dist/plugins/tables/deleteTable/index.d.ts.map +1 -1
  242. package/dist/plugins/tables/deleteTable/index.js +2 -2
  243. package/dist/plugins/tables/deleteTable/schemas.d.ts +3 -4
  244. package/dist/plugins/tables/deleteTable/schemas.d.ts.map +1 -1
  245. package/dist/plugins/tables/deleteTableFields/index.d.ts +63 -2
  246. package/dist/plugins/tables/deleteTableFields/index.d.ts.map +1 -1
  247. package/dist/plugins/tables/deleteTableFields/index.js +2 -2
  248. package/dist/plugins/tables/deleteTableFields/schemas.d.ts +4 -5
  249. package/dist/plugins/tables/deleteTableFields/schemas.d.ts.map +1 -1
  250. package/dist/plugins/tables/deleteTableRecords/index.d.ts +84 -2
  251. package/dist/plugins/tables/deleteTableRecords/index.d.ts.map +1 -1
  252. package/dist/plugins/tables/deleteTableRecords/index.js +2 -2
  253. package/dist/plugins/tables/deleteTableRecords/schemas.d.ts +4 -5
  254. package/dist/plugins/tables/deleteTableRecords/schemas.d.ts.map +1 -1
  255. package/dist/plugins/tables/getTable/index.d.ts +34 -2
  256. package/dist/plugins/tables/getTable/index.d.ts.map +1 -1
  257. package/dist/plugins/tables/getTable/index.js +2 -2
  258. package/dist/plugins/tables/getTable/schemas.d.ts +2 -2
  259. package/dist/plugins/tables/getTableRecord/index.d.ts +84 -2
  260. package/dist/plugins/tables/getTableRecord/index.d.ts.map +1 -1
  261. package/dist/plugins/tables/getTableRecord/index.js +2 -2
  262. package/dist/plugins/tables/getTableRecord/schemas.d.ts +6 -7
  263. package/dist/plugins/tables/getTableRecord/schemas.d.ts.map +1 -1
  264. package/dist/plugins/tables/getTableRecord/schemas.js +1 -10
  265. package/dist/plugins/tables/listTableFields/index.d.ts +34 -2
  266. package/dist/plugins/tables/listTableFields/index.d.ts.map +1 -1
  267. package/dist/plugins/tables/listTableFields/index.js +4 -2
  268. package/dist/plugins/tables/listTableFields/schemas.d.ts +4 -5
  269. package/dist/plugins/tables/listTableFields/schemas.d.ts.map +1 -1
  270. package/dist/plugins/tables/listTableFields/schemas.js +1 -9
  271. package/dist/plugins/tables/listTableRecords/index.d.ts +65 -4
  272. package/dist/plugins/tables/listTableRecords/index.d.ts.map +1 -1
  273. package/dist/plugins/tables/listTableRecords/index.js +3 -3
  274. package/dist/plugins/tables/listTableRecords/schemas.d.ts +2 -2
  275. package/dist/plugins/tables/listTables/index.d.ts +3 -3
  276. package/dist/plugins/tables/listTables/index.d.ts.map +1 -1
  277. package/dist/plugins/tables/listTables/index.js +4 -4
  278. package/dist/plugins/tables/updateTableRecords/index.d.ts +63 -2
  279. package/dist/plugins/tables/updateTableRecords/index.d.ts.map +1 -1
  280. package/dist/plugins/tables/updateTableRecords/index.js +2 -2
  281. package/dist/plugins/tables/updateTableRecords/schemas.d.ts +3 -4
  282. package/dist/plugins/tables/updateTableRecords/schemas.d.ts.map +1 -1
  283. package/dist/plugins/triggers/ackTriggerInboxMessages/index.d.ts +59 -2
  284. package/dist/plugins/triggers/ackTriggerInboxMessages/index.d.ts.map +1 -1
  285. package/dist/plugins/triggers/ackTriggerInboxMessages/index.js +1 -1
  286. package/dist/plugins/triggers/ackTriggerInboxMessages/schemas.d.ts +1 -1
  287. package/dist/plugins/triggers/createTriggerInbox/index.d.ts +231 -2
  288. package/dist/plugins/triggers/createTriggerInbox/index.d.ts.map +1 -1
  289. package/dist/plugins/triggers/createTriggerInbox/index.js +3 -1
  290. package/dist/plugins/triggers/createTriggerInbox/schemas.d.ts +3 -4
  291. package/dist/plugins/triggers/createTriggerInbox/schemas.d.ts.map +1 -1
  292. package/dist/plugins/triggers/deleteTriggerInbox/index.d.ts +33 -2
  293. package/dist/plugins/triggers/deleteTriggerInbox/index.d.ts.map +1 -1
  294. package/dist/plugins/triggers/deleteTriggerInbox/index.js +3 -1
  295. package/dist/plugins/triggers/deleteTriggerInbox/schemas.d.ts +2 -3
  296. package/dist/plugins/triggers/deleteTriggerInbox/schemas.d.ts.map +1 -1
  297. package/dist/plugins/triggers/drainTriggerInbox/index.d.ts +68 -6
  298. package/dist/plugins/triggers/drainTriggerInbox/index.d.ts.map +1 -1
  299. package/dist/plugins/triggers/drainTriggerInbox/index.js +1 -1
  300. package/dist/plugins/triggers/drainTriggerInbox/schemas.d.ts +2 -2
  301. package/dist/plugins/triggers/ensureTriggerInbox/index.d.ts +231 -2
  302. package/dist/plugins/triggers/ensureTriggerInbox/index.d.ts.map +1 -1
  303. package/dist/plugins/triggers/ensureTriggerInbox/index.js +3 -1
  304. package/dist/plugins/triggers/ensureTriggerInbox/schemas.d.ts +3 -4
  305. package/dist/plugins/triggers/ensureTriggerInbox/schemas.d.ts.map +1 -1
  306. package/dist/plugins/triggers/getTriggerInbox/index.d.ts +33 -2
  307. package/dist/plugins/triggers/getTriggerInbox/index.d.ts.map +1 -1
  308. package/dist/plugins/triggers/getTriggerInbox/index.js +3 -1
  309. package/dist/plugins/triggers/getTriggerInbox/schemas.d.ts +2 -3
  310. package/dist/plugins/triggers/getTriggerInbox/schemas.d.ts.map +1 -1
  311. package/dist/plugins/triggers/getTriggerInputFieldsSchema/index.d.ts +232 -3
  312. package/dist/plugins/triggers/getTriggerInputFieldsSchema/index.d.ts.map +1 -1
  313. package/dist/plugins/triggers/getTriggerInputFieldsSchema/index.js +1 -1
  314. package/dist/plugins/triggers/getTriggerInputFieldsSchema/schemas.d.ts +2 -2
  315. package/dist/plugins/triggers/leaseTriggerInboxMessages/index.d.ts +33 -2
  316. package/dist/plugins/triggers/leaseTriggerInboxMessages/index.d.ts.map +1 -1
  317. package/dist/plugins/triggers/leaseTriggerInboxMessages/index.js +1 -1
  318. package/dist/plugins/triggers/leaseTriggerInboxMessages/schemas.d.ts +1 -1
  319. package/dist/plugins/triggers/listTriggerInboxMessages/index.d.ts +34 -3
  320. package/dist/plugins/triggers/listTriggerInboxMessages/index.d.ts.map +1 -1
  321. package/dist/plugins/triggers/listTriggerInboxMessages/index.js +5 -13
  322. package/dist/plugins/triggers/listTriggerInboxMessages/schemas.d.ts +1 -1
  323. package/dist/plugins/triggers/listTriggerInboxes/index.d.ts +3 -3
  324. package/dist/plugins/triggers/listTriggerInboxes/index.d.ts.map +1 -1
  325. package/dist/plugins/triggers/listTriggerInboxes/index.js +5 -14
  326. package/dist/plugins/triggers/listTriggerInputFieldChoices/index.d.ts +288 -5
  327. package/dist/plugins/triggers/listTriggerInputFieldChoices/index.d.ts.map +1 -1
  328. package/dist/plugins/triggers/listTriggerInputFieldChoices/index.js +7 -5
  329. package/dist/plugins/triggers/listTriggerInputFieldChoices/schemas.d.ts +3 -3
  330. package/dist/plugins/triggers/listTriggerInputFields/index.d.ts +234 -5
  331. package/dist/plugins/triggers/listTriggerInputFields/index.d.ts.map +1 -1
  332. package/dist/plugins/triggers/listTriggerInputFields/index.js +6 -5
  333. package/dist/plugins/triggers/listTriggerInputFields/schemas.d.ts +2 -2
  334. package/dist/plugins/triggers/listTriggers/index.d.ts +142 -5
  335. package/dist/plugins/triggers/listTriggers/index.d.ts.map +1 -1
  336. package/dist/plugins/triggers/listTriggers/index.js +6 -5
  337. package/dist/plugins/triggers/listTriggers/schemas.d.ts +1 -1
  338. package/dist/plugins/triggers/pauseTriggerInbox/index.d.ts +33 -2
  339. package/dist/plugins/triggers/pauseTriggerInbox/index.d.ts.map +1 -1
  340. package/dist/plugins/triggers/pauseTriggerInbox/index.js +3 -1
  341. package/dist/plugins/triggers/pauseTriggerInbox/schemas.d.ts +2 -3
  342. package/dist/plugins/triggers/pauseTriggerInbox/schemas.d.ts.map +1 -1
  343. package/dist/plugins/triggers/releaseTriggerInboxMessages/index.d.ts +59 -2
  344. package/dist/plugins/triggers/releaseTriggerInboxMessages/index.d.ts.map +1 -1
  345. package/dist/plugins/triggers/releaseTriggerInboxMessages/index.js +1 -1
  346. package/dist/plugins/triggers/releaseTriggerInboxMessages/schemas.d.ts +1 -1
  347. package/dist/plugins/triggers/resumeTriggerInbox/index.d.ts +33 -2
  348. package/dist/plugins/triggers/resumeTriggerInbox/index.d.ts.map +1 -1
  349. package/dist/plugins/triggers/resumeTriggerInbox/index.js +3 -1
  350. package/dist/plugins/triggers/resumeTriggerInbox/schemas.d.ts +2 -3
  351. package/dist/plugins/triggers/resumeTriggerInbox/schemas.d.ts.map +1 -1
  352. package/dist/plugins/triggers/updateTriggerInbox/index.d.ts +33 -2
  353. package/dist/plugins/triggers/updateTriggerInbox/index.d.ts.map +1 -1
  354. package/dist/plugins/triggers/updateTriggerInbox/index.js +3 -1
  355. package/dist/plugins/triggers/updateTriggerInbox/schemas.d.ts +2 -3
  356. package/dist/plugins/triggers/updateTriggerInbox/schemas.d.ts.map +1 -1
  357. package/dist/plugins/triggers/watchTriggerInbox/index.d.ts +37 -6
  358. package/dist/plugins/triggers/watchTriggerInbox/index.d.ts.map +1 -1
  359. package/dist/plugins/triggers/watchTriggerInbox/index.js +1 -1
  360. package/dist/resolvers/actionKey.d.ts +3 -2
  361. package/dist/resolvers/actionKey.d.ts.map +1 -1
  362. package/dist/resolvers/actionType.d.ts +7 -2
  363. package/dist/resolvers/actionType.d.ts.map +1 -1
  364. package/dist/resolvers/actionType.js +3 -0
  365. package/dist/resolvers/appKey.d.ts +10 -5
  366. package/dist/resolvers/appKey.d.ts.map +1 -1
  367. package/dist/resolvers/appKey.js +3 -0
  368. package/dist/resolvers/clientCredentialsName.d.ts +1 -1
  369. package/dist/resolvers/clientCredentialsName.d.ts.map +1 -1
  370. package/dist/resolvers/clientId.d.ts +3 -2
  371. package/dist/resolvers/clientId.d.ts.map +1 -1
  372. package/dist/resolvers/clientId.js +1 -1
  373. package/dist/resolvers/connectionId.d.ts +5 -2
  374. package/dist/resolvers/connectionId.d.ts.map +1 -1
  375. package/dist/resolvers/connectionId.js +1 -1
  376. package/dist/resolvers/durableRunId.d.ts +3 -2
  377. package/dist/resolvers/durableRunId.d.ts.map +1 -1
  378. package/dist/resolvers/durableRunId.js +3 -2
  379. package/dist/resolvers/inputFieldKey.d.ts +3 -2
  380. package/dist/resolvers/inputFieldKey.d.ts.map +1 -1
  381. package/dist/resolvers/inputFieldKey.js +1 -1
  382. package/dist/resolvers/tableFieldIds.d.ts +3 -2
  383. package/dist/resolvers/tableFieldIds.d.ts.map +1 -1
  384. package/dist/resolvers/tableFields.d.ts +2 -2
  385. package/dist/resolvers/tableFields.d.ts.map +1 -1
  386. package/dist/resolvers/tableFilters.d.ts +3 -2
  387. package/dist/resolvers/tableFilters.d.ts.map +1 -1
  388. package/dist/resolvers/tableId.d.ts +3 -2
  389. package/dist/resolvers/tableId.d.ts.map +1 -1
  390. package/dist/resolvers/tableId.js +1 -1
  391. package/dist/resolvers/tableName.d.ts +1 -1
  392. package/dist/resolvers/tableName.d.ts.map +1 -1
  393. package/dist/resolvers/tableRecordId.d.ts +4 -3
  394. package/dist/resolvers/tableRecordId.d.ts.map +1 -1
  395. package/dist/resolvers/tableRecords.d.ts +4 -3
  396. package/dist/resolvers/tableRecords.d.ts.map +1 -1
  397. package/dist/resolvers/tableSort.d.ts +3 -2
  398. package/dist/resolvers/tableSort.d.ts.map +1 -1
  399. package/dist/resolvers/triggerInbox.d.ts +3 -2
  400. package/dist/resolvers/triggerInbox.d.ts.map +1 -1
  401. package/dist/resolvers/triggerInbox.js +1 -1
  402. package/dist/resolvers/triggerMessages.d.ts +3 -2
  403. package/dist/resolvers/triggerMessages.d.ts.map +1 -1
  404. package/dist/resolvers/triggerMessages.js +2 -4
  405. package/dist/resolvers/workflowId.d.ts +3 -2
  406. package/dist/resolvers/workflowId.d.ts.map +1 -1
  407. package/dist/resolvers/workflowId.js +3 -2
  408. package/dist/resolvers/workflowRunId.d.ts +3 -2
  409. package/dist/resolvers/workflowRunId.d.ts.map +1 -1
  410. package/dist/resolvers/workflowRunId.js +5 -5
  411. package/dist/resolvers/workflowVersionId.d.ts +3 -2
  412. package/dist/resolvers/workflowVersionId.d.ts.map +1 -1
  413. package/dist/resolvers/workflowVersionId.js +7 -7
  414. package/dist/schemas/Action.d.ts.map +1 -1
  415. package/dist/schemas/Action.js +6 -30
  416. package/dist/schemas/App.d.ts +0 -1
  417. package/dist/schemas/App.d.ts.map +1 -1
  418. package/dist/schemas/App.js +2 -14
  419. package/dist/schemas/ClientCredentials.d.ts.map +1 -1
  420. package/dist/schemas/ClientCredentials.js +3 -41
  421. package/dist/schemas/Connection.d.ts.map +1 -1
  422. package/dist/schemas/Connection.js +2 -28
  423. package/dist/schemas/Field.d.ts.map +1 -1
  424. package/dist/schemas/Field.js +3 -70
  425. package/dist/schemas/Run.d.ts.map +1 -1
  426. package/dist/schemas/Run.js +3 -29
  427. package/dist/schemas/TriggerInbox.d.ts.map +1 -1
  428. package/dist/schemas/TriggerInbox.js +1 -33
  429. package/dist/schemas/TriggerMessage.d.ts.map +1 -1
  430. package/dist/schemas/TriggerMessage.js +2 -60
  431. package/dist/schemas/UserProfile.d.ts +0 -1
  432. package/dist/schemas/UserProfile.d.ts.map +1 -1
  433. package/dist/schemas/UserProfile.js +1 -20
  434. package/dist/sdk.d.ts +2761 -441
  435. package/dist/sdk.d.ts.map +1 -1
  436. package/dist/sdk.js +93 -129
  437. package/dist/types/errors.d.ts +44 -42
  438. package/dist/types/errors.d.ts.map +1 -1
  439. package/dist/types/errors.js +79 -33
  440. package/dist/types/functions.d.ts +1 -41
  441. package/dist/types/functions.d.ts.map +1 -1
  442. package/dist/types/properties.d.ts +7 -7
  443. package/dist/types/properties.js +1 -1
  444. package/dist/types/sdk.d.ts +1 -1
  445. package/dist/types/sdk.d.ts.map +1 -1
  446. package/dist/types/telemetry-events.d.ts +1 -1
  447. package/dist/types/telemetry-events.d.ts.map +1 -1
  448. package/dist/utils/domain-utils.js +1 -1
  449. package/dist/utils/logging.d.ts +1 -12
  450. package/dist/utils/logging.d.ts.map +1 -1
  451. package/dist/utils/logging.js +2 -20
  452. package/dist/utils/pagination.d.ts +38 -0
  453. package/dist/utils/pagination.d.ts.map +1 -0
  454. package/dist/utils/pagination.js +53 -0
  455. package/package.json +3 -2
  456. package/dist/registry.d.ts +0 -9
  457. package/dist/registry.d.ts.map +0 -1
  458. package/dist/registry.js +0 -103
  459. package/dist/types/meta.d.ts +0 -9
  460. package/dist/types/meta.d.ts.map +0 -1
  461. package/dist/types/meta.js +0 -3
  462. package/dist/types/plugin.d.ts +0 -84
  463. package/dist/types/plugin.d.ts.map +0 -1
  464. package/dist/types/plugin.js +0 -13
  465. package/dist/types/registry.d.ts +0 -54
  466. package/dist/types/registry.d.ts.map +0 -1
  467. package/dist/types/registry.js +0 -1
  468. package/dist/utils/function-utils.d.ts +0 -59
  469. package/dist/utils/function-utils.d.ts.map +0 -1
  470. package/dist/utils/function-utils.js +0 -245
  471. package/dist/utils/pagination-utils.d.ts +0 -73
  472. package/dist/utils/pagination-utils.d.ts.map +0 -1
  473. package/dist/utils/pagination-utils.js +0 -308
  474. package/dist/utils/plugin-utils.d.ts +0 -245
  475. package/dist/utils/plugin-utils.d.ts.map +0 -1
  476. package/dist/utils/plugin-utils.js +0 -234
  477. package/dist/utils/schema-utils.d.ts +0 -211
  478. package/dist/utils/schema-utils.d.ts.map +0 -1
  479. package/dist/utils/schema-utils.js +0 -72
  480. package/dist/utils/string-utils.d.ts +0 -40
  481. package/dist/utils/string-utils.d.ts.map +0 -1
  482. package/dist/utils/string-utils.js +0 -69
  483. package/dist/utils/telemetry-context.d.ts +0 -15
  484. package/dist/utils/telemetry-context.d.ts.map +0 -1
  485. package/dist/utils/telemetry-context.js +0 -48
  486. package/dist/utils/telemetry-utils.d.ts +0 -44
  487. package/dist/utils/telemetry-utils.d.ts.map +0 -1
  488. package/dist/utils/telemetry-utils.js +0 -60
  489. package/dist/utils/validation.d.ts +0 -4
  490. package/dist/utils/validation.d.ts.map +0 -1
  491. package/dist/utils/validation.js +0 -30
@@ -1,245 +0,0 @@
1
- /**
2
- * Generic utility functions for creating paginated SDK functions
3
- */
4
- import { ZapierError, ZapierUnknownError, ZapierAuthenticationError, } from "../types/errors";
5
- import { paginate } from "./pagination-utils";
6
- import { createValidator, validateOptions } from "./validation";
7
- import { isTelemetryNested, runWithTelemetryContext, } from "./telemetry-context";
8
- /**
9
- * Helper function to extract cursor from pagination data
10
- * Supports JSON:API style `links.next` URLs by extracting the `offset` parameter.
11
- */
12
- export function extractCursor(data) {
13
- if (!data?.next) {
14
- return undefined;
15
- }
16
- try {
17
- const urlObj = new URL(data.next);
18
- const offset = urlObj.searchParams.get("offset");
19
- return offset || undefined;
20
- }
21
- catch {
22
- return undefined;
23
- }
24
- }
25
- /**
26
- * Helper function to convert unknown errors to SDK errors.
27
- * Recognizes errors by name (e.g., from cli-login package which can't
28
- * import SDK errors directly) and converts them to proper SDK errors.
29
- */
30
- function normalizeError(error) {
31
- if (error instanceof ZapierError) {
32
- return error;
33
- }
34
- const message = error instanceof Error ? error.message : String(error);
35
- const cause = error instanceof Error ? error : undefined;
36
- // Check for known error names from packages that can't import SDK errors
37
- if (error instanceof Error) {
38
- if (error.name === "ZapierAuthenticationError") {
39
- return new ZapierAuthenticationError(message, { cause });
40
- }
41
- }
42
- return new ZapierUnknownError(message, { cause });
43
- }
44
- /**
45
- * Higher-order function that creates a function from a core function
46
- *
47
- * @param coreFn - Function that returns T directly or throws errors
48
- * @param schema - Optional Zod schema for validation
49
- * @param telemetry - Optional telemetry callbacks
50
- * @returns A function that normalizes and rethrows errors
51
- */
52
- export function createFunction(coreFn, schema, telemetry) {
53
- const functionName = coreFn.name;
54
- // Create a named function using dynamic property access
55
- const namedFunctions = {
56
- [functionName]: async function (options) {
57
- return runWithTelemetryContext(async () => {
58
- const startTime = Date.now();
59
- const normalizedOptions = (options ?? {});
60
- const isNested = isTelemetryNested();
61
- try {
62
- if (schema) {
63
- const validatedOptions = validateOptions(schema, normalizedOptions);
64
- const result = await coreFn({
65
- ...normalizedOptions,
66
- ...validatedOptions,
67
- });
68
- if (!isNested && telemetry?.onMethodCalled) {
69
- const argumentCount = Object.keys(normalizedOptions).length;
70
- telemetry.onMethodCalled({
71
- methodName: functionName,
72
- durationMs: Date.now() - startTime,
73
- success: true,
74
- argumentCount,
75
- isPaginated: false,
76
- });
77
- }
78
- return result;
79
- }
80
- const result = await coreFn(normalizedOptions);
81
- if (!isNested && telemetry?.onMethodCalled) {
82
- const argumentCount = Object.keys(normalizedOptions).length;
83
- telemetry.onMethodCalled({
84
- methodName: functionName,
85
- durationMs: Date.now() - startTime,
86
- success: true,
87
- argumentCount,
88
- isPaginated: false,
89
- });
90
- }
91
- return result;
92
- }
93
- catch (error) {
94
- const normalizedError = normalizeError(error);
95
- if (!isNested && telemetry?.onMethodCalled) {
96
- const argumentCount = Object.keys(normalizedOptions).length;
97
- telemetry.onMethodCalled({
98
- methodName: functionName,
99
- durationMs: Date.now() - startTime,
100
- success: false,
101
- error: normalizedError,
102
- argumentCount,
103
- isPaginated: false,
104
- });
105
- }
106
- throw normalizedError;
107
- }
108
- });
109
- },
110
- };
111
- return namedFunctions[functionName];
112
- }
113
- /**
114
- * Higher-order function that creates a page function that wraps results in {data}
115
- * Internal utility used by createPaginatedFunction
116
- */
117
- function createPageFunction(coreFn) {
118
- const functionName = coreFn.name + "Page";
119
- // Create a named function using dynamic property access
120
- const namedFunctions = {
121
- [functionName]: async function (options) {
122
- try {
123
- const result = await coreFn(options);
124
- // If result already has a data property, ensure it's an array
125
- if (result && typeof result === "object" && "data" in result) {
126
- const paginatedResult = result;
127
- // Support both nextCursor and JSON:API links.next format
128
- let nextCursor;
129
- if (paginatedResult.nextCursor) {
130
- nextCursor = paginatedResult.nextCursor;
131
- }
132
- else if (paginatedResult.links?.next) {
133
- // Extract cursor from fully qualified URL (JSON:API spec format)
134
- nextCursor = extractCursor({ next: paginatedResult.links.next });
135
- }
136
- return {
137
- data: Array.isArray(paginatedResult.data)
138
- ? paginatedResult.data
139
- : [paginatedResult.data],
140
- nextCursor,
141
- };
142
- }
143
- // If result is an array, wrap in {data: result}
144
- if (Array.isArray(result)) {
145
- return { data: result };
146
- }
147
- // If result is non-array, wrap in {data: [result]}
148
- return { data: [result] };
149
- }
150
- catch (error) {
151
- // Catch and normalize any errors, then rethrow
152
- throw normalizeError(error);
153
- }
154
- },
155
- };
156
- return namedFunctions[functionName];
157
- }
158
- export function createPaginatedFunction(coreFn, schema, telemetry, explicitFunctionName, defaultPageSize) {
159
- const pageFunction = createPageFunction(coreFn);
160
- const functionName = explicitFunctionName || coreFn.name;
161
- const validator = schema ? createValidator(schema) : null;
162
- // Create the main paginated function
163
- const namedFunctions = {
164
- [functionName]: function (options) {
165
- return runWithTelemetryContext(() => {
166
- const startTime = Date.now();
167
- // Convert undefined options to empty object
168
- const normalizedOptions = (options ?? {});
169
- const isNested = isTelemetryNested();
170
- // Validate options if schema provided (validated fields take precedence)
171
- const validatedOptions = {
172
- ...normalizedOptions,
173
- ...(validator ? validator(normalizedOptions) : normalizedOptions),
174
- };
175
- const pageSize = validatedOptions.pageSize ?? defaultPageSize;
176
- const optimizedOptions = {
177
- ...validatedOptions,
178
- pageSize,
179
- };
180
- const iterator = paginate(pageFunction, optimizedOptions);
181
- // Get a promise for the first iteration
182
- const firstPagePromise = iterator.next().then((result) => {
183
- if (result.done) {
184
- throw new Error("Paginate should always iterate at least once");
185
- }
186
- return result.value;
187
- });
188
- // Emit telemetry after first page completes
189
- if (!isNested && telemetry?.onMethodCalled) {
190
- firstPagePromise
191
- .then(() => {
192
- const argumentCount = Object.keys(normalizedOptions).length;
193
- telemetry.onMethodCalled({
194
- methodName: functionName,
195
- durationMs: Date.now() - startTime,
196
- success: true,
197
- argumentCount,
198
- isPaginated: true,
199
- });
200
- })
201
- .catch((error) => {
202
- const argumentCount = Object.keys(normalizedOptions).length;
203
- telemetry.onMethodCalled({
204
- methodName: functionName,
205
- durationMs: Date.now() - startTime,
206
- success: false,
207
- error: error instanceof Error ? error : new Error(String(error)),
208
- argumentCount,
209
- isPaginated: true,
210
- });
211
- });
212
- }
213
- // Add Symbol.asyncIterator to make the promise iterable
214
- return Object.assign(firstPagePromise, {
215
- [Symbol.asyncIterator]: async function* () {
216
- // Yield the first page (await the promise)
217
- yield await firstPagePromise;
218
- // Yield the rest of the pages
219
- for await (const page of iterator) {
220
- yield page;
221
- }
222
- },
223
- items: function () {
224
- return {
225
- [Symbol.asyncIterator]: async function* () {
226
- // Yield the first page items
227
- const firstPage = await firstPagePromise;
228
- for (const item of firstPage.data) {
229
- yield item;
230
- }
231
- // Yield items from the rest of the pages
232
- for await (const page of iterator) {
233
- for (const item of page.data) {
234
- yield item;
235
- }
236
- }
237
- },
238
- };
239
- },
240
- });
241
- });
242
- },
243
- };
244
- return namedFunctions[functionName];
245
- }
@@ -1,73 +0,0 @@
1
- type TPageOptions<TOptions> = TOptions extends undefined ? {
2
- cursor?: string;
3
- maxItems?: number;
4
- pageSize?: number;
5
- } : TOptions & {
6
- cursor?: string;
7
- maxItems?: number;
8
- pageSize?: number;
9
- };
10
- export declare function decodeIncomingCursor(incoming?: string): {
11
- offset: number;
12
- cursor: string | undefined;
13
- };
14
- export declare function createPrefixedCursor(prefix: string, cursor: string | undefined): string;
15
- export declare function splitPrefixedCursor(cursor: string | undefined, prefixes?: string[]): [string | undefined, string | undefined];
16
- /**
17
- * Utility for paginating through API endpoints that return cursor-based pages.
18
- * Accepts and yields SDK-encoded cursor envelopes. Any incoming cursor is decoded
19
- * before being passed to the page function; all outgoing cursors are encoded.
20
- *
21
- * @param pageFunction - Function that fetches a single page with {data, nextCursor} structure
22
- * @param pageOptions - Options to pass to the page function (cursor will be managed automatically)
23
- * @returns Async iterator that yields pages with encoded cursors
24
- */
25
- export declare function paginateMaxItems<TOptions, TPage extends {
26
- data: any[];
27
- nextCursor?: string;
28
- }>(pageFunction: (options: TOptions & {
29
- cursor?: string;
30
- maxItems?: number;
31
- pageSize?: number;
32
- }) => Promise<TPage>, pageOptions?: TPageOptions<TOptions>): AsyncIterableIterator<TPage>;
33
- export declare function paginateBuffered<TOptions, TPage extends {
34
- data: any[];
35
- nextCursor?: string;
36
- }>(pageFunction: (options: TOptions & {
37
- cursor?: string;
38
- maxItems?: number;
39
- pageSize?: number;
40
- }) => Promise<TPage>, pageOptions?: TPageOptions<TOptions>): AsyncIterableIterator<TPage>;
41
- export declare const paginate: typeof paginateBuffered;
42
- interface PaginatedResult<TItem> {
43
- data: TItem[];
44
- nextCursor?: string;
45
- }
46
- type PaginatedSource<TItem> = () => PromiseLike<PaginatedResult<TItem>> & AsyncIterable<PaginatedResult<TItem>>;
47
- /**
48
- * Concatenate multiple paginated SDK results into a single paginated stream.
49
- * Each source is a function returning a dual Promise+AsyncIterable (as SDK
50
- * paginated methods return). Sources are drained in order.
51
- *
52
- * The optional `dedupe` key extractor filters items from source N against
53
- * all items seen in sources 0 through N-1.
54
- *
55
- * Uses paginateBuffered internally to normalize page sizes across source
56
- * boundaries — e.g. if the first source only has 2 items, they'll be
57
- * buffered with items from the next source into a full page.
58
- *
59
- * Returns the same dual Promise+AsyncIterable shape that resolvers expect.
60
- */
61
- export declare function concatPaginated<TItem>({ sources, dedupe, pageSize, }: {
62
- sources: PaginatedSource<TItem>[];
63
- dedupe?: (item: TItem) => string;
64
- pageSize?: number;
65
- }): PromiseLike<PaginatedResult<TItem>> & AsyncIterable<PaginatedResult<TItem>>;
66
- /**
67
- * Strip the PromiseLike from an async iterable, returning a plain
68
- * AsyncIterable. This prevents async functions from unwrapping the
69
- * iterable (since async only unwraps PromiseLike, not AsyncIterable).
70
- */
71
- export declare function toIterable<T>(source: AsyncIterable<T>): AsyncIterable<T>;
72
- export {};
73
- //# sourceMappingURL=pagination-utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pagination-utils.d.ts","sourceRoot":"","sources":["../../src/utils/pagination-utils.ts"],"names":[],"mappings":"AAsBA,KAAK,YAAY,CAAC,QAAQ,IAAI,QAAQ,SAAS,SAAS,GACpD;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GACzD,QAAQ,GAAG;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAmCzE,wBAAgB,oBAAoB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG;IACvD,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5B,CAyBA;AAED,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,GAAG,SAAS,GACzB,MAAM,CAKR;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,QAAQ,CAAC,EAAE,MAAM,EAAE,GAClB,CAAC,MAAM,GAAG,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC,CAkB1C;AAuDD;;;;;;;;GAQG;AACH,wBAAuB,gBAAgB,CACrC,QAAQ,EACR,KAAK,SAAS;IAAE,IAAI,EAAE,GAAG,EAAE,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,EAElD,YAAY,EAAE,CACZ,OAAO,EAAE,QAAQ,GAAG;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,KACE,OAAO,CAAC,KAAK,CAAC,EACnB,WAAW,CAAC,EAAE,YAAY,CAAC,QAAQ,CAAC,GACnC,qBAAqB,CAAC,KAAK,CAAC,CAkB9B;AAED,wBAAuB,gBAAgB,CACrC,QAAQ,EACR,KAAK,SAAS;IAAE,IAAI,EAAE,GAAG,EAAE,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,EAElD,YAAY,EAAE,CACZ,OAAO,EAAE,QAAQ,GAAG;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,KACE,OAAO,CAAC,KAAK,CAAC,EACnB,WAAW,CAAC,EAAE,YAAY,CAAC,QAAQ,CAAC,GACnC,qBAAqB,CAAC,KAAK,CAAC,CA2H9B;AAED,eAAO,MAAM,QAAQ,yBAAmB,CAAC;AAMzC,UAAU,eAAe,CAAC,KAAK;IAC7B,IAAI,EAAE,KAAK,EAAE,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,KAAK,eAAe,CAAC,KAAK,IAAI,MAAM,WAAW,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,GACrE,aAAa,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC;AAExC;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,EACrC,OAAO,EACP,MAAM,EACN,QAAc,GACf,EAAE;IACD,OAAO,EAAE,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC;IAClC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,MAAM,CAAC;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,GAAG,WAAW,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,GACrC,aAAa,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAiFtC;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAExE"}
@@ -1,308 +0,0 @@
1
- const CURSOR_VERSION = 1;
2
- const CURSOR_SOURCE = {
3
- API: "api",
4
- SDK: "sdk",
5
- };
6
- function encodeBase64(str) {
7
- return btoa(Array.from(new TextEncoder().encode(str), (b) => String.fromCharCode(b)).join(""));
8
- }
9
- function decodeBase64(str) {
10
- return new TextDecoder().decode(Uint8Array.from(atob(str), (c) => c.charCodeAt(0)));
11
- }
12
- function encodeApiCursor(cursor) {
13
- const envelope = {
14
- v: CURSOR_VERSION,
15
- source: CURSOR_SOURCE.API,
16
- cursor,
17
- };
18
- return encodeBase64(JSON.stringify(envelope));
19
- }
20
- function encodeSdkCursor(offset, cursor) {
21
- const envelope = {
22
- v: CURSOR_VERSION,
23
- source: CURSOR_SOURCE.SDK,
24
- cursor,
25
- offset,
26
- };
27
- return encodeBase64(JSON.stringify(envelope));
28
- }
29
- export function decodeIncomingCursor(incoming) {
30
- if (!incoming) {
31
- return { offset: 0, cursor: undefined };
32
- }
33
- try {
34
- const decoded = decodeBase64(incoming);
35
- const envelope = JSON.parse(decoded);
36
- if (envelope.v !== CURSOR_VERSION) {
37
- return { offset: 0, cursor: incoming };
38
- }
39
- if (envelope.source === CURSOR_SOURCE.SDK) {
40
- return { offset: envelope.offset ?? 0, cursor: envelope.cursor };
41
- }
42
- if (envelope.source === CURSOR_SOURCE.API) {
43
- return { offset: 0, cursor: envelope.cursor };
44
- }
45
- return { offset: 0, cursor: incoming };
46
- }
47
- catch {
48
- return { offset: 0, cursor: incoming };
49
- }
50
- }
51
- export function createPrefixedCursor(prefix, cursor) {
52
- if (!cursor) {
53
- return `${prefix}::`;
54
- }
55
- return `${prefix}::${cursor}`;
56
- }
57
- export function splitPrefixedCursor(cursor, prefixes) {
58
- if (!cursor) {
59
- return [undefined, undefined];
60
- }
61
- const [prefix, ...rest] = cursor.split("::");
62
- if (prefixes && !prefixes.includes(prefix)) {
63
- return [undefined, cursor];
64
- }
65
- cursor = rest.join("::");
66
- if (!cursor) {
67
- return [prefix, undefined];
68
- }
69
- return [prefix, cursor];
70
- }
71
- /**
72
- * Internal primitive: paginates through a page function using raw (unencoded) cursors.
73
- * Encoding and decoding of cursors is the responsibility of the public wrappers.
74
- */
75
- async function* paginateMaxItemsWithUnencodedCursor(pageFunction, pageOptions) {
76
- let cursor = pageOptions?.cursor;
77
- let totalItemsYielded = 0;
78
- const maxItems = pageOptions?.maxItems;
79
- const pageSize = pageOptions?.pageSize;
80
- do {
81
- const options = {
82
- ...(pageOptions || {}),
83
- cursor,
84
- pageSize: maxItems !== undefined && pageSize !== undefined
85
- ? Math.min(pageSize, maxItems)
86
- : pageSize,
87
- };
88
- const page = await pageFunction(options);
89
- if (maxItems !== undefined) {
90
- const remainingItems = maxItems - totalItemsYielded;
91
- if (page.data.length >= remainingItems) {
92
- yield {
93
- ...page,
94
- data: page.data.slice(0, remainingItems),
95
- nextCursor: undefined,
96
- };
97
- break;
98
- }
99
- }
100
- yield page;
101
- totalItemsYielded += page.data.length;
102
- cursor = page.nextCursor;
103
- } while (cursor);
104
- }
105
- /**
106
- * Utility for paginating through API endpoints that return cursor-based pages.
107
- * Accepts and yields SDK-encoded cursor envelopes. Any incoming cursor is decoded
108
- * before being passed to the page function; all outgoing cursors are encoded.
109
- *
110
- * @param pageFunction - Function that fetches a single page with {data, nextCursor} structure
111
- * @param pageOptions - Options to pass to the page function (cursor will be managed automatically)
112
- * @returns Async iterator that yields pages with encoded cursors
113
- */
114
- export async function* paginateMaxItems(pageFunction, pageOptions) {
115
- const { cursor } = decodeIncomingCursor(pageOptions?.cursor);
116
- const options = {
117
- ...(pageOptions || {}),
118
- cursor,
119
- };
120
- for await (const page of paginateMaxItemsWithUnencodedCursor(pageFunction, options)) {
121
- yield {
122
- ...page,
123
- nextCursor: page.nextCursor
124
- ? encodeApiCursor(page.nextCursor)
125
- : undefined,
126
- };
127
- }
128
- }
129
- export async function* paginateBuffered(pageFunction, pageOptions) {
130
- const pageSize = pageOptions?.pageSize;
131
- const { offset: cursorOffset, cursor: initialCursor } = decodeIncomingCursor(pageOptions?.cursor);
132
- const requestedMaxItems = pageOptions?.maxItems;
133
- const options = {
134
- ...(pageOptions || {}),
135
- cursor: initialCursor,
136
- // SDK cursors can carry an offset into a raw backend page. Since maxItems
137
- // is expected to be relative to the resumed position, we add that offset
138
- // so raw pagination still yields enough items after offset slicing.
139
- maxItems: requestedMaxItems !== undefined && cursorOffset > 0
140
- ? requestedMaxItems + cursorOffset
141
- : requestedMaxItems,
142
- };
143
- if (!pageSize) {
144
- for await (const page of paginateMaxItemsWithUnencodedCursor(pageFunction, options)) {
145
- yield {
146
- ...page,
147
- nextCursor: page.nextCursor
148
- ? encodeApiCursor(page.nextCursor)
149
- : undefined,
150
- };
151
- }
152
- return;
153
- }
154
- let bufferedPages = [];
155
- let isFirstPage = true;
156
- let rawCursor;
157
- for await (let page of paginateMaxItemsWithUnencodedCursor(pageFunction, options)) {
158
- const nextRawCursor = page.nextCursor;
159
- if (isFirstPage) {
160
- isFirstPage = false;
161
- if (cursorOffset) {
162
- page = {
163
- ...page,
164
- data: page.data.slice(cursorOffset),
165
- };
166
- }
167
- }
168
- const bufferedLength = bufferedPages.reduce((acc, p) => acc + p.data.length, 0);
169
- // If we don't have enough to fill a page, buffer this page.
170
- if (bufferedLength + page.data.length < pageSize) {
171
- bufferedPages.push(page);
172
- rawCursor = nextRawCursor;
173
- continue;
174
- }
175
- // Let's yield a page from our buffered pages.
176
- const bufferedItems = bufferedPages.map((p) => p.data).flat();
177
- const allItems = [...bufferedItems, ...page.data];
178
- const pageItems = allItems.slice(0, pageSize);
179
- const remainingItems = allItems.slice(pageItems.length);
180
- // No extra items to buffer, so we can just yield a normal page with a cursor to the next one.
181
- if (remainingItems.length === 0) {
182
- yield {
183
- ...page,
184
- data: pageItems,
185
- nextCursor: nextRawCursor ? encodeApiCursor(nextRawCursor) : undefined,
186
- };
187
- bufferedPages = [];
188
- rawCursor = nextRawCursor;
189
- continue;
190
- }
191
- // Yield our items with a cursor to offset into this page.
192
- yield {
193
- ...page,
194
- data: pageItems,
195
- nextCursor: encodeSdkCursor(page.data.length - remainingItems.length, rawCursor),
196
- };
197
- while (remainingItems.length > pageSize) {
198
- const chunkItems = remainingItems.splice(0, pageSize);
199
- yield {
200
- ...page,
201
- data: chunkItems,
202
- nextCursor: encodeSdkCursor(page.data.length - remainingItems.length, rawCursor),
203
- };
204
- }
205
- bufferedPages = [
206
- {
207
- ...page,
208
- data: remainingItems,
209
- },
210
- ];
211
- rawCursor = nextRawCursor;
212
- }
213
- if (bufferedPages.length > 0) {
214
- const lastBufferedPage = bufferedPages.slice(-1)[0];
215
- const bufferedItems = bufferedPages.map((p) => p.data).flat();
216
- yield {
217
- ...lastBufferedPage,
218
- data: bufferedItems,
219
- };
220
- }
221
- }
222
- export const paginate = paginateBuffered;
223
- /**
224
- * Concatenate multiple paginated SDK results into a single paginated stream.
225
- * Each source is a function returning a dual Promise+AsyncIterable (as SDK
226
- * paginated methods return). Sources are drained in order.
227
- *
228
- * The optional `dedupe` key extractor filters items from source N against
229
- * all items seen in sources 0 through N-1.
230
- *
231
- * Uses paginateBuffered internally to normalize page sizes across source
232
- * boundaries — e.g. if the first source only has 2 items, they'll be
233
- * buffered with items from the next source into a full page.
234
- *
235
- * Returns the same dual Promise+AsyncIterable shape that resolvers expect.
236
- */
237
- export function concatPaginated({ sources, dedupe, pageSize = 100, }) {
238
- if (sources.length === 0) {
239
- const empty = { data: [] };
240
- return Object.assign(Promise.resolve(empty), {
241
- [Symbol.asyncIterator]: async function* () {
242
- yield empty;
243
- },
244
- });
245
- }
246
- let sourceIndex = 0;
247
- let currentIterator = null;
248
- const seen = new Set();
249
- const pageFunction = async (_options) => {
250
- while (sourceIndex < sources.length) {
251
- if (!currentIterator) {
252
- const result = sources[sourceIndex]();
253
- currentIterator = result[Symbol.asyncIterator]();
254
- }
255
- const next = await currentIterator.next();
256
- if (next.done) {
257
- sourceIndex++;
258
- currentIterator = null;
259
- continue;
260
- }
261
- let items = next.value.data;
262
- if (dedupe) {
263
- if (sourceIndex > 0) {
264
- items = items.filter((item) => !seen.has(dedupe(item)));
265
- }
266
- for (const item of items) {
267
- seen.add(dedupe(item));
268
- }
269
- }
270
- const hasMoreInSource = next.value.nextCursor != null;
271
- const hasMoreSources = sourceIndex < sources.length - 1;
272
- // Synthetic sentinel — not a real API cursor. It just signals to
273
- // paginateBuffered that more data exists (from the current source or
274
- // the next one). This works because concatPaginated manages its own
275
- // iteration state internally. Currently only used by CLI resolvers;
276
- // if this is ever used in user-facing SDK methods, we should replace
277
- // it with a stateless composite cursor (e.g. sourceIndex + inner cursor).
278
- return {
279
- data: items,
280
- nextCursor: hasMoreInSource || hasMoreSources ? "__has_more__" : undefined,
281
- };
282
- }
283
- return { data: [] };
284
- };
285
- const iterator = paginateBuffered(pageFunction, { pageSize });
286
- const firstPagePromise = iterator.next().then((result) => {
287
- if (result.done) {
288
- return { data: [] };
289
- }
290
- return result.value;
291
- });
292
- return Object.assign(firstPagePromise, {
293
- [Symbol.asyncIterator]: async function* () {
294
- yield await firstPagePromise;
295
- for await (const page of { [Symbol.asyncIterator]: () => iterator }) {
296
- yield page;
297
- }
298
- },
299
- });
300
- }
301
- /**
302
- * Strip the PromiseLike from an async iterable, returning a plain
303
- * AsyncIterable. This prevents async functions from unwrapping the
304
- * iterable (since async only unwraps PromiseLike, not AsyncIterable).
305
- */
306
- export function toIterable(source) {
307
- return { [Symbol.asyncIterator]: () => source[Symbol.asyncIterator]() };
308
- }