@zapier/zapier-sdk 0.4.1 → 0.5.1

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 (375) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +343 -0
  3. package/dist/api/auth.d.ts +9 -0
  4. package/dist/api/auth.d.ts.map +1 -0
  5. package/dist/api/auth.js +25 -0
  6. package/dist/api/client.d.ts +9 -0
  7. package/dist/api/client.d.ts.map +1 -0
  8. package/dist/api/client.js +322 -0
  9. package/dist/api/debug.d.ts +13 -0
  10. package/dist/api/debug.d.ts.map +1 -0
  11. package/dist/api/debug.js +55 -0
  12. package/dist/api/index.d.ts +29 -0
  13. package/dist/api/index.d.ts.map +1 -0
  14. package/dist/api/index.js +41 -0
  15. package/dist/api/polling.d.ts +16 -0
  16. package/dist/api/polling.d.ts.map +1 -0
  17. package/dist/api/polling.js +45 -0
  18. package/dist/api/schemas.d.ts +2473 -0
  19. package/dist/api/schemas.d.ts.map +1 -0
  20. package/dist/api/schemas.js +355 -0
  21. package/dist/api/types.d.ts +75 -0
  22. package/dist/api/types.d.ts.map +1 -0
  23. package/dist/api/types.js +11 -0
  24. package/dist/auth.d.ts +34 -0
  25. package/dist/auth.d.ts.map +1 -0
  26. package/dist/auth.js +47 -0
  27. package/dist/constants.d.ts +10 -0
  28. package/dist/constants.d.ts.map +1 -0
  29. package/dist/constants.js +9 -0
  30. package/dist/index.cjs +2108 -1379
  31. package/dist/index.d.mts +2440 -620
  32. package/dist/index.d.ts +17 -892
  33. package/dist/index.d.ts.map +1 -0
  34. package/dist/index.js +20 -0
  35. package/dist/index.mjs +2093 -1362
  36. package/dist/plugins/api/index.d.ts +14 -0
  37. package/dist/plugins/api/index.d.ts.map +1 -0
  38. package/dist/plugins/api/index.js +21 -0
  39. package/dist/plugins/apps/index.d.ts +11 -0
  40. package/dist/plugins/apps/index.d.ts.map +1 -0
  41. package/dist/plugins/apps/index.js +91 -0
  42. package/dist/plugins/apps/types.d.ts +30 -0
  43. package/dist/plugins/apps/types.d.ts.map +1 -0
  44. package/dist/plugins/apps/types.js +2 -0
  45. package/dist/plugins/fetch/index.d.ts +21 -0
  46. package/dist/plugins/fetch/index.d.ts.map +1 -0
  47. package/dist/plugins/fetch/index.js +20 -0
  48. package/dist/plugins/findFirstAuthentication/index.d.ts +20 -0
  49. package/dist/plugins/findFirstAuthentication/index.d.ts.map +1 -0
  50. package/dist/plugins/findFirstAuthentication/index.js +24 -0
  51. package/dist/plugins/findFirstAuthentication/index.test.d.ts +2 -0
  52. package/dist/plugins/findFirstAuthentication/index.test.d.ts.map +1 -0
  53. package/dist/plugins/findFirstAuthentication/index.test.js +171 -0
  54. package/dist/plugins/findFirstAuthentication/schemas.d.ts +29 -0
  55. package/dist/plugins/findFirstAuthentication/schemas.d.ts.map +1 -0
  56. package/dist/plugins/findFirstAuthentication/schemas.js +18 -0
  57. package/dist/plugins/findUniqueAuthentication/index.d.ts +20 -0
  58. package/dist/plugins/findUniqueAuthentication/index.d.ts.map +1 -0
  59. package/dist/plugins/findUniqueAuthentication/index.js +31 -0
  60. package/dist/plugins/findUniqueAuthentication/index.test.d.ts +2 -0
  61. package/dist/plugins/findUniqueAuthentication/index.test.d.ts.map +1 -0
  62. package/dist/plugins/findUniqueAuthentication/index.test.js +152 -0
  63. package/dist/plugins/findUniqueAuthentication/schemas.d.ts +29 -0
  64. package/dist/plugins/findUniqueAuthentication/schemas.d.ts.map +1 -0
  65. package/dist/plugins/findUniqueAuthentication/schemas.js +18 -0
  66. package/dist/plugins/getAction/index.d.ts +23 -0
  67. package/dist/plugins/getAction/index.d.ts.map +1 -0
  68. package/dist/plugins/getAction/index.js +28 -0
  69. package/dist/plugins/getAction/index.test.d.ts +2 -0
  70. package/dist/plugins/getAction/index.test.d.ts.map +1 -0
  71. package/dist/plugins/getAction/index.test.js +186 -0
  72. package/dist/plugins/getAction/schemas.d.ts +23 -0
  73. package/dist/plugins/getAction/schemas.d.ts.map +1 -0
  74. package/dist/plugins/getAction/schemas.js +10 -0
  75. package/dist/plugins/getApp/index.d.ts +22 -0
  76. package/dist/plugins/getApp/index.d.ts.map +1 -0
  77. package/dist/plugins/getApp/index.js +39 -0
  78. package/dist/plugins/getApp/index.test.d.ts +2 -0
  79. package/dist/plugins/getApp/index.test.d.ts.map +1 -0
  80. package/dist/plugins/getApp/index.test.js +100 -0
  81. package/dist/plugins/getApp/schemas.d.ts +18 -0
  82. package/dist/plugins/getApp/schemas.d.ts.map +1 -0
  83. package/dist/plugins/getApp/schemas.js +10 -0
  84. package/dist/plugins/getAuthentication/index.d.ts +22 -0
  85. package/dist/plugins/getAuthentication/index.d.ts.map +1 -0
  86. package/dist/plugins/getAuthentication/index.js +41 -0
  87. package/dist/plugins/getAuthentication/index.test.d.ts +2 -0
  88. package/dist/plugins/getAuthentication/index.test.d.ts.map +1 -0
  89. package/dist/plugins/getAuthentication/index.test.js +205 -0
  90. package/dist/plugins/getAuthentication/schemas.d.ts +17 -0
  91. package/dist/plugins/getAuthentication/schemas.d.ts.map +1 -0
  92. package/dist/plugins/getAuthentication/schemas.js +11 -0
  93. package/dist/plugins/getProfile/index.d.ts +23 -0
  94. package/dist/plugins/getProfile/index.d.ts.map +1 -0
  95. package/dist/plugins/getProfile/index.js +29 -0
  96. package/dist/plugins/getProfile/schemas.d.ts +13 -0
  97. package/dist/plugins/getProfile/schemas.d.ts.map +1 -0
  98. package/dist/plugins/getProfile/schemas.js +5 -0
  99. package/dist/plugins/listActions/index.d.ts +28 -0
  100. package/dist/plugins/listActions/index.d.ts.map +1 -0
  101. package/dist/plugins/listActions/index.js +61 -0
  102. package/dist/plugins/listActions/index.test.d.ts +2 -0
  103. package/dist/plugins/listActions/index.test.d.ts.map +1 -0
  104. package/dist/plugins/listActions/index.test.js +467 -0
  105. package/dist/plugins/listActions/schemas.d.ts +29 -0
  106. package/dist/plugins/listActions/schemas.d.ts.map +1 -0
  107. package/dist/plugins/listActions/schemas.js +21 -0
  108. package/dist/plugins/listApps/index.d.ts +28 -0
  109. package/dist/plugins/listApps/index.d.ts.map +1 -0
  110. package/dist/plugins/listApps/index.js +62 -0
  111. package/dist/plugins/listApps/index.test.d.ts +2 -0
  112. package/dist/plugins/listApps/index.test.d.ts.map +1 -0
  113. package/dist/plugins/listApps/index.test.js +313 -0
  114. package/dist/plugins/listApps/schemas.d.ts +30 -0
  115. package/dist/plugins/listApps/schemas.d.ts.map +1 -0
  116. package/dist/plugins/listApps/schemas.js +23 -0
  117. package/dist/plugins/listAuthentications/index.d.ts +28 -0
  118. package/dist/plugins/listAuthentications/index.d.ts.map +1 -0
  119. package/dist/plugins/listAuthentications/index.js +77 -0
  120. package/dist/plugins/listAuthentications/index.test.d.ts +2 -0
  121. package/dist/plugins/listAuthentications/index.test.d.ts.map +1 -0
  122. package/dist/plugins/listAuthentications/index.test.js +564 -0
  123. package/dist/plugins/listAuthentications/schemas.d.ts +38 -0
  124. package/dist/plugins/listAuthentications/schemas.d.ts.map +1 -0
  125. package/dist/plugins/listAuthentications/schemas.js +28 -0
  126. package/dist/plugins/listInputFields/index.d.ts +28 -0
  127. package/dist/plugins/listInputFields/index.d.ts.map +1 -0
  128. package/dist/plugins/listInputFields/index.js +133 -0
  129. package/dist/plugins/listInputFields/index.test.d.ts +2 -0
  130. package/dist/plugins/listInputFields/index.test.d.ts.map +1 -0
  131. package/dist/plugins/listInputFields/index.test.js +325 -0
  132. package/dist/plugins/listInputFields/schemas.d.ts +38 -0
  133. package/dist/plugins/listInputFields/schemas.d.ts.map +1 -0
  134. package/dist/plugins/listInputFields/schemas.js +22 -0
  135. package/dist/plugins/registry/index.d.ts +11 -0
  136. package/dist/plugins/registry/index.d.ts.map +1 -0
  137. package/dist/plugins/registry/index.js +14 -0
  138. package/dist/plugins/request/index.d.ts +19 -0
  139. package/dist/plugins/request/index.d.ts.map +1 -0
  140. package/dist/plugins/request/index.js +62 -0
  141. package/dist/plugins/request/index.test.d.ts +2 -0
  142. package/dist/plugins/request/index.test.d.ts.map +1 -0
  143. package/dist/plugins/request/index.test.js +256 -0
  144. package/dist/plugins/request/schemas.d.ts +69 -0
  145. package/dist/plugins/request/schemas.d.ts.map +1 -0
  146. package/dist/plugins/request/schemas.js +42 -0
  147. package/dist/plugins/runAction/index.d.ts +28 -0
  148. package/dist/plugins/runAction/index.d.ts.map +1 -0
  149. package/dist/plugins/runAction/index.js +86 -0
  150. package/dist/plugins/runAction/index.test.d.ts +2 -0
  151. package/dist/plugins/runAction/index.test.d.ts.map +1 -0
  152. package/dist/plugins/runAction/index.test.js +320 -0
  153. package/dist/plugins/runAction/schemas.d.ts +37 -0
  154. package/dist/plugins/runAction/schemas.d.ts.map +1 -0
  155. package/dist/plugins/runAction/schemas.js +22 -0
  156. package/dist/resolvers/actionKey.d.ts +9 -0
  157. package/dist/resolvers/actionKey.d.ts.map +1 -0
  158. package/dist/resolvers/actionKey.js +19 -0
  159. package/dist/resolvers/actionType.d.ts +9 -0
  160. package/dist/resolvers/actionType.d.ts.map +1 -0
  161. package/dist/resolvers/actionType.js +22 -0
  162. package/dist/resolvers/appKey.d.ts +7 -0
  163. package/dist/resolvers/appKey.d.ts.map +1 -0
  164. package/dist/resolvers/appKey.js +5 -0
  165. package/dist/resolvers/authenticationId.d.ts +9 -0
  166. package/dist/resolvers/authenticationId.d.ts.map +1 -0
  167. package/dist/resolvers/authenticationId.js +33 -0
  168. package/dist/resolvers/index.d.ts +40 -0
  169. package/dist/resolvers/index.d.ts.map +1 -0
  170. package/dist/resolvers/index.js +91 -0
  171. package/dist/resolvers/inputs.d.ts +8 -0
  172. package/dist/resolvers/inputs.d.ts.map +1 -0
  173. package/dist/resolvers/inputs.js +14 -0
  174. package/dist/schemas/Action.d.ts +243 -0
  175. package/dist/schemas/Action.d.ts.map +1 -0
  176. package/dist/schemas/Action.js +34 -0
  177. package/dist/schemas/App.d.ts +26 -0
  178. package/dist/schemas/App.d.ts.map +1 -0
  179. package/dist/schemas/App.js +22 -0
  180. package/dist/schemas/Auth.d.ts +161 -0
  181. package/dist/schemas/Auth.d.ts.map +1 -0
  182. package/dist/schemas/Auth.js +41 -0
  183. package/dist/schemas/Field.d.ts +144 -0
  184. package/dist/schemas/Field.d.ts.map +1 -0
  185. package/dist/schemas/Field.js +105 -0
  186. package/dist/schemas/UserProfile.d.ts +163 -0
  187. package/dist/schemas/UserProfile.d.ts.map +1 -0
  188. package/dist/schemas/UserProfile.js +29 -0
  189. package/dist/sdk.d.ts +10 -0
  190. package/dist/sdk.d.ts.map +1 -0
  191. package/dist/sdk.js +94 -0
  192. package/dist/sdk.test.d.ts +2 -0
  193. package/dist/sdk.test.d.ts.map +1 -0
  194. package/dist/sdk.test.js +135 -0
  195. package/dist/types/domain.d.ts +36 -0
  196. package/dist/types/domain.d.ts.map +1 -0
  197. package/dist/types/domain.js +1 -0
  198. package/dist/types/domain.test.d.ts +2 -0
  199. package/dist/types/domain.test.d.ts.map +1 -0
  200. package/dist/types/domain.test.js +39 -0
  201. package/dist/types/errors.d.ts +143 -0
  202. package/dist/types/errors.d.ts.map +1 -0
  203. package/dist/types/errors.js +187 -0
  204. package/dist/types/events.d.ts +38 -0
  205. package/dist/types/events.d.ts.map +1 -0
  206. package/dist/types/events.js +7 -0
  207. package/dist/types/functions.d.ts +26 -0
  208. package/dist/types/functions.d.ts.map +1 -0
  209. package/dist/types/functions.js +4 -0
  210. package/dist/types/plugin.d.ts +61 -0
  211. package/dist/types/plugin.d.ts.map +1 -0
  212. package/dist/types/plugin.js +9 -0
  213. package/dist/types/properties.d.ts +22 -0
  214. package/dist/types/properties.d.ts.map +1 -0
  215. package/dist/types/properties.js +50 -0
  216. package/dist/types/sdk.d.ts +43 -0
  217. package/dist/types/sdk.d.ts.map +1 -0
  218. package/dist/types/sdk.js +4 -0
  219. package/dist/utils/array-utils.d.ts +31 -0
  220. package/dist/utils/array-utils.d.ts.map +1 -0
  221. package/dist/utils/array-utils.js +36 -0
  222. package/dist/utils/array-utils.test.d.ts +2 -0
  223. package/dist/utils/array-utils.test.d.ts.map +1 -0
  224. package/dist/utils/array-utils.test.js +107 -0
  225. package/dist/utils/domain-utils.d.ts +78 -0
  226. package/dist/utils/domain-utils.d.ts.map +1 -0
  227. package/dist/utils/domain-utils.js +218 -0
  228. package/dist/utils/domain-utils.test.d.ts +2 -0
  229. package/dist/utils/domain-utils.test.d.ts.map +1 -0
  230. package/dist/utils/domain-utils.test.js +192 -0
  231. package/dist/utils/function-utils.d.ts +45 -0
  232. package/dist/utils/function-utils.d.ts.map +1 -0
  233. package/dist/utils/function-utils.js +158 -0
  234. package/dist/utils/function-utils.test.d.ts +2 -0
  235. package/dist/utils/function-utils.test.d.ts.map +1 -0
  236. package/dist/utils/function-utils.test.js +110 -0
  237. package/dist/utils/pagination-utils.d.ts +37 -0
  238. package/dist/utils/pagination-utils.d.ts.map +1 -0
  239. package/dist/utils/pagination-utils.js +165 -0
  240. package/dist/utils/pagination-utils.test.d.ts +17 -0
  241. package/dist/utils/pagination-utils.test.d.ts.map +1 -0
  242. package/dist/utils/pagination-utils.test.js +461 -0
  243. package/dist/utils/schema-utils.d.ts +45 -0
  244. package/dist/utils/schema-utils.d.ts.map +1 -0
  245. package/dist/utils/schema-utils.js +65 -0
  246. package/dist/utils/validation.d.ts +4 -0
  247. package/dist/utils/validation.d.ts.map +1 -0
  248. package/dist/utils/validation.js +30 -0
  249. package/dist/utils/validation.test.d.ts +2 -0
  250. package/dist/utils/validation.test.d.ts.map +1 -0
  251. package/dist/utils/validation.test.js +43 -0
  252. package/package.json +12 -3
  253. package/src/api/client.ts +394 -171
  254. package/src/api/debug.ts +10 -1
  255. package/src/api/index.ts +0 -2
  256. package/src/api/polling.ts +28 -7
  257. package/src/api/schemas.ts +387 -0
  258. package/src/api/types.ts +72 -136
  259. package/src/constants.ts +10 -0
  260. package/src/index.ts +40 -19
  261. package/src/plugins/api/index.ts +47 -0
  262. package/src/plugins/apps/index.ts +25 -19
  263. package/src/plugins/apps/types.ts +7 -11
  264. package/src/plugins/fetch/index.ts +48 -40
  265. package/src/plugins/findFirstAuthentication/index.test.ts +206 -0
  266. package/src/plugins/findFirstAuthentication/index.ts +55 -0
  267. package/src/plugins/findFirstAuthentication/schemas.ts +41 -0
  268. package/src/plugins/findUniqueAuthentication/index.test.ts +197 -0
  269. package/src/plugins/findUniqueAuthentication/index.ts +72 -0
  270. package/src/plugins/findUniqueAuthentication/schemas.ts +42 -0
  271. package/src/plugins/getAction/index.test.ts +239 -0
  272. package/src/plugins/getAction/index.ts +57 -0
  273. package/src/plugins/getAction/schemas.ts +33 -0
  274. package/src/plugins/getApp/index.test.ts +127 -0
  275. package/src/plugins/getApp/index.ts +66 -0
  276. package/src/plugins/getApp/schemas.ts +38 -0
  277. package/src/plugins/getAuthentication/index.test.ts +284 -0
  278. package/src/plugins/getAuthentication/index.ts +86 -0
  279. package/src/plugins/getAuthentication/schemas.ts +31 -0
  280. package/src/plugins/getProfile/index.ts +55 -0
  281. package/src/plugins/getProfile/schemas.ts +26 -0
  282. package/src/plugins/listActions/index.test.ts +582 -0
  283. package/src/plugins/listActions/index.ts +115 -0
  284. package/src/plugins/listActions/schemas.ts +54 -0
  285. package/src/plugins/listApps/index.test.ts +357 -0
  286. package/src/plugins/listApps/index.ts +121 -0
  287. package/src/plugins/listApps/schemas.ts +49 -0
  288. package/src/plugins/listAuthentications/index.test.ts +709 -0
  289. package/src/plugins/listAuthentications/index.ts +136 -0
  290. package/src/plugins/listAuthentications/schemas.ts +60 -0
  291. package/src/plugins/listInputFields/index.test.ts +408 -0
  292. package/src/plugins/listInputFields/index.ts +204 -0
  293. package/src/plugins/listInputFields/schemas.ts +56 -0
  294. package/src/plugins/registry/index.ts +30 -0
  295. package/src/plugins/request/index.test.ts +329 -0
  296. package/src/plugins/request/index.ts +103 -0
  297. package/src/{functions → plugins}/request/schemas.ts +20 -9
  298. package/src/plugins/runAction/index.test.ts +387 -0
  299. package/src/plugins/runAction/index.ts +176 -0
  300. package/src/plugins/runAction/schemas.ts +53 -0
  301. package/src/resolvers/actionKey.ts +6 -4
  302. package/src/resolvers/actionType.ts +7 -2
  303. package/src/resolvers/appKey.ts +1 -1
  304. package/src/resolvers/authenticationId.ts +12 -3
  305. package/src/resolvers/inputs.ts +3 -1
  306. package/src/schemas/Action.ts +18 -12
  307. package/src/schemas/App.ts +11 -19
  308. package/src/schemas/Auth.ts +18 -13
  309. package/src/schemas/Field.ts +106 -11
  310. package/src/schemas/UserProfile.ts +43 -0
  311. package/src/sdk.test.ts +212 -0
  312. package/src/sdk.ts +132 -102
  313. package/src/types/domain.test.ts +50 -0
  314. package/src/types/domain.ts +43 -75
  315. package/src/types/errors.ts +275 -0
  316. package/src/types/functions.ts +27 -0
  317. package/src/types/optional-zapier-sdk-cli-login.d.ts +37 -0
  318. package/src/types/plugin.ts +105 -0
  319. package/src/types/properties.ts +4 -3
  320. package/src/types/sdk.ts +70 -48
  321. package/src/utils/array-utils.test.ts +131 -0
  322. package/src/utils/array-utils.ts +41 -0
  323. package/src/utils/domain-utils.test.ts +239 -0
  324. package/src/utils/domain-utils.ts +283 -0
  325. package/src/utils/function-utils.test.ts +141 -0
  326. package/src/utils/function-utils.ts +245 -0
  327. package/src/utils/pagination-utils.test.ts +620 -0
  328. package/src/utils/pagination-utils.ts +242 -0
  329. package/src/utils/validation.test.ts +50 -0
  330. package/src/utils/validation.ts +44 -0
  331. package/tsconfig.build.json +16 -2
  332. package/tsconfig.json +3 -1
  333. package/tsconfig.tsbuildinfo +1 -0
  334. package/tsup.config.ts +2 -0
  335. package/src/functions/bundleCode/index.ts +0 -78
  336. package/src/functions/bundleCode/info.ts +0 -9
  337. package/src/functions/bundleCode/schemas.ts +0 -30
  338. package/src/functions/findFirstAuthentication/index.ts +0 -24
  339. package/src/functions/findFirstAuthentication/info.ts +0 -9
  340. package/src/functions/findFirstAuthentication/schemas.ts +0 -50
  341. package/src/functions/findUniqueAuthentication/index.ts +0 -35
  342. package/src/functions/findUniqueAuthentication/info.ts +0 -9
  343. package/src/functions/findUniqueAuthentication/schemas.ts +0 -50
  344. package/src/functions/generateTypes/index.ts +0 -363
  345. package/src/functions/generateTypes/info.ts +0 -9
  346. package/src/functions/generateTypes/schemas.ts +0 -31
  347. package/src/functions/getAction/index.ts +0 -33
  348. package/src/functions/getAction/info.ts +0 -9
  349. package/src/functions/getAction/schemas.ts +0 -25
  350. package/src/functions/getApp/index.ts +0 -41
  351. package/src/functions/getApp/info.ts +0 -9
  352. package/src/functions/getApp/schemas.ts +0 -20
  353. package/src/functions/getAuthentication/index.ts +0 -50
  354. package/src/functions/getAuthentication/info.ts +0 -9
  355. package/src/functions/getAuthentication/schemas.ts +0 -29
  356. package/src/functions/listActions/index.ts +0 -149
  357. package/src/functions/listActions/info.ts +0 -9
  358. package/src/functions/listActions/schemas.ts +0 -30
  359. package/src/functions/listApps/index.ts +0 -60
  360. package/src/functions/listApps/info.ts +0 -9
  361. package/src/functions/listApps/schemas.ts +0 -32
  362. package/src/functions/listAuthentications/index.ts +0 -162
  363. package/src/functions/listAuthentications/info.ts +0 -9
  364. package/src/functions/listAuthentications/schemas.ts +0 -50
  365. package/src/functions/listFields/index.ts +0 -86
  366. package/src/functions/listFields/info.ts +0 -9
  367. package/src/functions/listFields/schemas.ts +0 -36
  368. package/src/functions/request/index.ts +0 -150
  369. package/src/functions/request/info.ts +0 -11
  370. package/src/functions/runAction/index.ts +0 -127
  371. package/src/functions/runAction/info.ts +0 -9
  372. package/src/functions/runAction/schemas.ts +0 -34
  373. package/src/plugins/apps/info.ts +0 -12
  374. package/src/plugins/fetch/types.ts +0 -2
  375. /package/src/{schema-utils.ts → utils/schema-utils.ts} +0 -0
@@ -0,0 +1,135 @@
1
+ // Test the flat plugin system
2
+ import { describe, it, expect } from "vitest";
3
+ import { createZapierSdk, createSdk } from "./sdk";
4
+ describe("Flat Plugin System", () => {
5
+ it("should create SDK with all expected methods", () => {
6
+ const sdk = createZapierSdk();
7
+ // Test that all core methods are available
8
+ expect(sdk.listApps).toBeDefined();
9
+ expect(sdk.listAuthentications).toBeDefined();
10
+ expect(sdk.getAuthentication).toBeDefined();
11
+ expect(sdk.runAction).toBeDefined();
12
+ expect(sdk.request).toBeDefined();
13
+ // Test that plugin methods are available
14
+ expect(sdk.fetch).toBeDefined();
15
+ expect(sdk.apps).toBeDefined();
16
+ expect(sdk.getProfile).toBeDefined();
17
+ // Test that getContext method is available
18
+ expect(sdk.getContext).toBeDefined();
19
+ expect(typeof sdk.getContext).toBe("function");
20
+ });
21
+ it("should have getContext method that returns context", () => {
22
+ const sdk = createZapierSdk();
23
+ const context = sdk.getContext(); // Type assertion to work around complex context inference
24
+ // Context should be an object
25
+ expect(typeof context).toBe("object");
26
+ expect(context).not.toBeNull();
27
+ // Context should have some properties (specific properties depend on plugin composition)
28
+ expect(Object.keys(context).length).toBeGreaterThan(0);
29
+ // Should have meta object
30
+ expect(context.meta).toBeDefined();
31
+ expect(typeof context.meta).toBe("object");
32
+ // Should have getProfile metadata from the plugin (verify it exists in meta)
33
+ expect("getProfile" in context.meta).toBe(true);
34
+ expect(context.meta.getProfile).toBeDefined();
35
+ expect(context.meta.getProfile.inputSchema).toBeDefined();
36
+ });
37
+ it("should have plugins return flat structure", () => {
38
+ const sdk = createZapierSdk();
39
+ // fetch should be directly available (not sdk.plugins.fetch or sdk.fetch.fetch)
40
+ expect(typeof sdk.fetch).toBe("function");
41
+ // apps should be directly available
42
+ expect(typeof sdk.apps).toBe("object");
43
+ // getProfile should be directly available
44
+ expect(typeof sdk.getProfile).toBe("function");
45
+ });
46
+ it("should support fluent plugin chaining with createSdk", () => {
47
+ // Test that createSdk().addPlugin().addPlugin() works and returns properly typed SDK
48
+ const testPlugin = () => ({
49
+ testMethod: () => "test result",
50
+ });
51
+ const sdk = createSdk().addPlugin(testPlugin);
52
+ // Should have getContext method
53
+ expect(typeof sdk.getContext).toBe("function");
54
+ // Should have addPlugin method for further chaining
55
+ expect(typeof sdk.addPlugin).toBe("function");
56
+ // Should have the plugin method
57
+ expect(typeof sdk.testMethod).toBe("function");
58
+ expect(sdk.testMethod()).toBe("test result");
59
+ });
60
+ it("should support fluent plugin chaining without .getSdk()", () => {
61
+ // This demonstrates the simplified API - no .getSdk() needed!
62
+ const plugin1 = () => ({ method1: () => "method1" });
63
+ const plugin2 = () => ({ method2: () => "method2" });
64
+ // Fluent chaining - each addPlugin returns a new SDK
65
+ const sdk = createSdk().addPlugin(plugin1).addPlugin(plugin2);
66
+ expect(sdk.method1()).toBe("method1");
67
+ expect(sdk.method2()).toBe("method2");
68
+ expect(typeof sdk.getContext).toBe("function");
69
+ expect(typeof sdk.addPlugin).toBe("function"); // Can still add more plugins!
70
+ });
71
+ it("should support plugins with options", () => {
72
+ // Test that addPlugin(pluginFn, options) works correctly
73
+ const pluginWithOptions = (params) => ({
74
+ getMessage: () => params.message,
75
+ });
76
+ const sdk = createSdk().addPlugin(pluginWithOptions, {
77
+ message: "Hello from options!",
78
+ });
79
+ expect(typeof sdk.getMessage).toBe("function");
80
+ expect(sdk.getMessage()).toBe("Hello from options!");
81
+ });
82
+ it("should merge context.meta from multiple plugins", () => {
83
+ // Test that multiple plugins can provide meta without overwriting each other
84
+ const plugin1 = () => ({
85
+ method1: () => "method1",
86
+ context: {
87
+ meta: {
88
+ plugin1: { info: "Plugin 1 metadata" },
89
+ },
90
+ },
91
+ });
92
+ const plugin2 = () => ({
93
+ method2: () => "method2",
94
+ context: {
95
+ meta: {
96
+ plugin2: { info: "Plugin 2 metadata" },
97
+ },
98
+ },
99
+ });
100
+ const sdk = createSdk().addPlugin(plugin1).addPlugin(plugin2);
101
+ const context = sdk.getContext();
102
+ // Both plugins should have their meta preserved
103
+ expect(context.meta.plugin1.info).toBe("Plugin 1 metadata");
104
+ expect(context.meta.plugin2.info).toBe("Plugin 2 metadata");
105
+ // Both methods should work
106
+ expect(sdk.method1()).toBe("method1");
107
+ expect(sdk.method2()).toBe("method2");
108
+ });
109
+ it("should support context requirements for cleaner plugin definitions", () => {
110
+ // Test context requirements work correctly
111
+ const pluginWithHelper = ({ sdk, context }) => ({
112
+ helperMethod: () => `Helper: ${sdk.existingMethod()} + ${context.customContext}`,
113
+ });
114
+ const baseSdk = { existingMethod: () => "base" };
115
+ const baseContext = { customContext: "custom", meta: {} };
116
+ const sdk = createSdk(baseSdk, baseContext).addPlugin(pluginWithHelper);
117
+ expect(sdk.helperMethod()).toBe("Helper: base + custom");
118
+ expect(sdk.existingMethod()).toBe("base"); // Original method still works
119
+ });
120
+ it("should ensure context.meta is always available", () => {
121
+ // Test that context.meta is always at least an empty object, even without explicit initialization
122
+ const plugin = ({ context }) => ({
123
+ testMethod: () => `Meta keys: ${Object.keys(context.meta).length}`,
124
+ });
125
+ // Create SDK without explicitly providing meta
126
+ const sdk = createSdk({}).addPlugin(plugin);
127
+ // Should work without error - meta should be at least an empty object
128
+ expect(sdk.testMethod()).toBe("Meta keys: 0");
129
+ // getContext() should also provide meta
130
+ const context = sdk.getContext();
131
+ expect(context.meta).toBeDefined();
132
+ expect(typeof context.meta).toBe("object");
133
+ expect(context.meta).not.toBeNull();
134
+ });
135
+ });
@@ -0,0 +1,36 @@
1
+ import type { z } from "zod";
2
+ /**
3
+ * Domain model types - representing business entities returned by SDK functions
4
+ * These types are inferred from Item schemas and represent transformed/formatted data.
5
+ */
6
+ import type { AppItemSchema } from "../schemas/App";
7
+ import type { AuthenticationItemSchema } from "../schemas/Auth";
8
+ import type { ActionItemSchema } from "../schemas/Action";
9
+ import type { InputFieldItemSchema } from "../schemas/Field";
10
+ import type { UserProfileItemSchema } from "../schemas/UserProfile";
11
+ /**
12
+ * Represents an app item returned by getApp and listApps functions
13
+ * Inferred from AppItemSchema which extends the base App API schema
14
+ */
15
+ export type AppItem = z.infer<typeof AppItemSchema>;
16
+ /**
17
+ * Represents an authentication item returned by listAuthentications functions
18
+ * Inferred from AuthenticationItemSchema which extends the base Authentication API schema
19
+ */
20
+ export type AuthenticationItem = z.infer<typeof AuthenticationItemSchema>;
21
+ /**
22
+ * Represents an action item returned by listActions functions
23
+ * Inferred from ActionItemSchema which extends the base Action API schema
24
+ */
25
+ export type ActionItem = z.infer<typeof ActionItemSchema>;
26
+ /**
27
+ * Represents an input field item returned by listInputFields functions
28
+ * Inferred from InputFieldItemSchema which extends the base Need API schema
29
+ */
30
+ export type InputFieldItem = z.infer<typeof InputFieldItemSchema>;
31
+ /**
32
+ * Represents a user profile item returned by getProfile function
33
+ * Inferred from UserProfileItemSchema which extends the base UserProfile API schema
34
+ */
35
+ export type UserProfileItem = z.infer<typeof UserProfileItemSchema>;
36
+ //# sourceMappingURL=domain.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"domain.d.ts","sourceRoot":"","sources":["../../src/types/domain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B;;;GAGG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAEpE;;;GAGG;AACH,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAEpD;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE1E;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE1D;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=domain.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"domain.test.d.ts","sourceRoot":"","sources":["../../src/types/domain.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,39 @@
1
+ import { describe, it, expect } from "vitest";
2
+ import { splitVersionedKey } from "../utils/domain-utils";
3
+ describe("splitVersionedKey", () => {
4
+ it("should split versioned key with version", () => {
5
+ const [baseKey, version] = splitVersionedKey("SlackCLIAPI@1.21.1");
6
+ expect(baseKey).toBe("SlackCLIAPI");
7
+ expect(version).toBe("1.21.1");
8
+ });
9
+ it("should split versioned key with complex version", () => {
10
+ const [baseKey, version] = splitVersionedKey("GoogleSheetsAPI@2.5.0-beta.1");
11
+ expect(baseKey).toBe("GoogleSheetsAPI");
12
+ expect(version).toBe("2.5.0-beta.1");
13
+ });
14
+ it("should handle versioned key without version", () => {
15
+ const [baseKey, version] = splitVersionedKey("SomeAPI");
16
+ expect(baseKey).toBe("SomeAPI");
17
+ expect(version).toBeUndefined();
18
+ });
19
+ it("should handle versioned key with multiple @ symbols", () => {
20
+ const [baseKey, version] = splitVersionedKey("ComplexAPI@1.0.0@beta");
21
+ expect(baseKey).toBe("ComplexAPI");
22
+ expect(version).toBe("1.0.0@beta");
23
+ });
24
+ it("should handle edge case with many @ symbols", () => {
25
+ const [baseKey, version] = splitVersionedKey("API@with@multiple@at@symbols@1.2.3");
26
+ expect(baseKey).toBe("API");
27
+ expect(version).toBe("with@multiple@at@symbols@1.2.3");
28
+ });
29
+ it("should handle empty string", () => {
30
+ const [baseKey, version] = splitVersionedKey("");
31
+ expect(baseKey).toBe("");
32
+ expect(version).toBeUndefined();
33
+ });
34
+ it("should handle string that starts with @", () => {
35
+ const [baseKey, version] = splitVersionedKey("@version");
36
+ expect(baseKey).toBe("");
37
+ expect(version).toBe("version");
38
+ });
39
+ });
@@ -0,0 +1,143 @@
1
+ /**
2
+ * Standard error format returned by the Zapier API
3
+ */
4
+ export interface ApiError {
5
+ status: number;
6
+ code: string;
7
+ title: string;
8
+ detail: string;
9
+ source?: any;
10
+ meta?: any;
11
+ }
12
+ /**
13
+ * Base options for all error constructors
14
+ */
15
+ export interface ErrorOptions {
16
+ statusCode?: number;
17
+ errors?: ApiError[];
18
+ cause?: unknown;
19
+ response?: any;
20
+ }
21
+ /**
22
+ * Base class for all Zapier SDK errors
23
+ * Use instanceof ZapierError to check if an error is from the SDK
24
+ */
25
+ export declare abstract class ZapierError extends Error {
26
+ abstract readonly name: string;
27
+ statusCode?: number;
28
+ errors?: ApiError[];
29
+ cause?: unknown;
30
+ response?: any;
31
+ constructor(message: string, options?: ErrorOptions);
32
+ }
33
+ /**
34
+ * Error thrown when API requests fail
35
+ */
36
+ export declare class ZapierApiError extends ZapierError {
37
+ readonly name = "ZapierApiError";
38
+ constructor(message: string, options?: ErrorOptions);
39
+ }
40
+ /**
41
+ * Error thrown when an app is not found
42
+ */
43
+ export declare class ZapierAppNotFoundError extends ZapierError {
44
+ readonly name = "ZapierAppNotFoundError";
45
+ appKey?: string;
46
+ constructor(message: string, options?: ErrorOptions & {
47
+ appKey?: string;
48
+ });
49
+ }
50
+ /**
51
+ * Error thrown when validation fails (e.g., invalid parameters)
52
+ */
53
+ export declare class ZapierValidationError extends ZapierError {
54
+ readonly name = "ZapierValidationError";
55
+ details?: any;
56
+ constructor(message: string, options?: ErrorOptions & {
57
+ details?: any;
58
+ });
59
+ }
60
+ /**
61
+ * Error for unrecognized/unknown errors that get wrapped by safe functions
62
+ */
63
+ export declare class ZapierUnknownError extends ZapierError {
64
+ readonly name = "ZapierUnknownError";
65
+ constructor(message: string, options?: ErrorOptions);
66
+ }
67
+ /**
68
+ * Error thrown for authentication and authorization failures (401/403)
69
+ */
70
+ export declare class ZapierAuthenticationError extends ZapierError {
71
+ readonly name = "ZapierAuthenticationError";
72
+ constructor(message: string, options?: ErrorOptions);
73
+ }
74
+ /**
75
+ * Error thrown when a requested resource is not found
76
+ */
77
+ export declare class ZapierResourceNotFoundError extends ZapierError {
78
+ readonly name = "ZapierResourceNotFoundError";
79
+ resourceType?: string;
80
+ resourceId?: string;
81
+ constructor(message: string, options?: ErrorOptions & {
82
+ resourceType?: string;
83
+ resourceId?: string;
84
+ });
85
+ }
86
+ /**
87
+ * Error thrown when required app or implementation configuration is missing
88
+ */
89
+ export declare class ZapierConfigurationError extends ZapierError {
90
+ readonly name = "ZapierConfigurationError";
91
+ configType?: string;
92
+ constructor(message: string, options?: ErrorOptions & {
93
+ configType?: string;
94
+ });
95
+ }
96
+ /**
97
+ * Error thrown when code bundling or compilation fails
98
+ */
99
+ export declare class ZapierBundleError extends ZapierError {
100
+ readonly name = "ZapierBundleError";
101
+ buildErrors?: string[];
102
+ constructor(message: string, options?: ErrorOptions & {
103
+ buildErrors?: string[];
104
+ });
105
+ }
106
+ /**
107
+ * Error thrown when operations timeout or exceed retry limits
108
+ */
109
+ export declare class ZapierTimeoutError extends ZapierError {
110
+ readonly name = "ZapierTimeoutError";
111
+ attempts?: number;
112
+ maxAttempts?: number;
113
+ constructor(message: string, options?: ErrorOptions & {
114
+ attempts?: number;
115
+ maxAttempts?: number;
116
+ });
117
+ }
118
+ /**
119
+ * Error thrown when action execution fails due to errors returned from the third-party service
120
+ * This happens when the Actions API returns a 200 status but includes errors in the response
121
+ */
122
+ export declare class ZapierActionError extends ZapierError {
123
+ readonly name = "ZapierActionError";
124
+ appKey?: string;
125
+ actionKey?: string;
126
+ constructor(message: string, options?: ErrorOptions & {
127
+ appKey?: string;
128
+ actionKey?: string;
129
+ });
130
+ get actionErrors(): ApiError[] | undefined;
131
+ }
132
+ /**
133
+ * Error thrown when a resource is not found (404)
134
+ */
135
+ export declare class ZapierNotFoundError extends ZapierError {
136
+ readonly name = "ZapierNotFoundError";
137
+ constructor(message: string, options?: ErrorOptions);
138
+ }
139
+ /**
140
+ * Utility function to format error messages for display
141
+ */
142
+ export declare function formatErrorMessage(error: ZapierError): string;
143
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/types/errors.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,187 @@
1
+ /**
2
+ * Base class for all Zapier SDK errors
3
+ * Use instanceof ZapierError to check if an error is from the SDK
4
+ */
5
+ export class ZapierError extends Error {
6
+ constructor(message, options = {}) {
7
+ super(message);
8
+ this.statusCode = options.statusCode;
9
+ this.errors = options.errors;
10
+ this.cause = options.cause;
11
+ this.response = options.response;
12
+ // Maintain proper prototype chain for instanceof checks
13
+ Object.setPrototypeOf(this, new.target.prototype);
14
+ }
15
+ }
16
+ /**
17
+ * Error thrown when API requests fail
18
+ */
19
+ export class ZapierApiError extends ZapierError {
20
+ constructor(message, options = {}) {
21
+ super(message, options);
22
+ this.name = "ZapierApiError";
23
+ }
24
+ }
25
+ /**
26
+ * Error thrown when an app is not found
27
+ */
28
+ export class ZapierAppNotFoundError extends ZapierError {
29
+ constructor(message, options = {}) {
30
+ super(message, options);
31
+ this.name = "ZapierAppNotFoundError";
32
+ this.appKey = options.appKey;
33
+ }
34
+ }
35
+ /**
36
+ * Error thrown when validation fails (e.g., invalid parameters)
37
+ */
38
+ export class ZapierValidationError extends ZapierError {
39
+ constructor(message, options = {}) {
40
+ super(message, options);
41
+ this.name = "ZapierValidationError";
42
+ this.details = options.details;
43
+ }
44
+ }
45
+ /**
46
+ * Error for unrecognized/unknown errors that get wrapped by safe functions
47
+ */
48
+ export class ZapierUnknownError extends ZapierError {
49
+ constructor(message, options = {}) {
50
+ super(message, options);
51
+ this.name = "ZapierUnknownError";
52
+ }
53
+ }
54
+ /**
55
+ * Error thrown for authentication and authorization failures (401/403)
56
+ */
57
+ export class ZapierAuthenticationError extends ZapierError {
58
+ constructor(message, options = {}) {
59
+ super(message, options);
60
+ this.name = "ZapierAuthenticationError";
61
+ }
62
+ }
63
+ /**
64
+ * Error thrown when a requested resource is not found
65
+ */
66
+ export class ZapierResourceNotFoundError extends ZapierError {
67
+ constructor(message, options = {}) {
68
+ super(message, options);
69
+ this.name = "ZapierResourceNotFoundError";
70
+ this.resourceType = options.resourceType;
71
+ this.resourceId = options.resourceId;
72
+ }
73
+ }
74
+ /**
75
+ * Error thrown when required app or implementation configuration is missing
76
+ */
77
+ export class ZapierConfigurationError extends ZapierError {
78
+ constructor(message, options = {}) {
79
+ super(message, options);
80
+ this.name = "ZapierConfigurationError";
81
+ this.configType = options.configType;
82
+ }
83
+ }
84
+ /**
85
+ * Error thrown when code bundling or compilation fails
86
+ */
87
+ export class ZapierBundleError extends ZapierError {
88
+ constructor(message, options = {}) {
89
+ super(message, options);
90
+ this.name = "ZapierBundleError";
91
+ this.buildErrors = options.buildErrors;
92
+ }
93
+ }
94
+ /**
95
+ * Error thrown when operations timeout or exceed retry limits
96
+ */
97
+ export class ZapierTimeoutError extends ZapierError {
98
+ constructor(message, options = {}) {
99
+ super(message, options);
100
+ this.name = "ZapierTimeoutError";
101
+ this.attempts = options.attempts;
102
+ this.maxAttempts = options.maxAttempts;
103
+ }
104
+ }
105
+ /**
106
+ * Error thrown when action execution fails due to errors returned from the third-party service
107
+ * This happens when the Actions API returns a 200 status but includes errors in the response
108
+ */
109
+ export class ZapierActionError extends ZapierError {
110
+ constructor(message, options = {}) {
111
+ super(message, options);
112
+ this.name = "ZapierActionError";
113
+ this.appKey = options.appKey;
114
+ this.actionKey = options.actionKey;
115
+ }
116
+ // Legacy accessor for backward compatibility
117
+ get actionErrors() {
118
+ return this.errors;
119
+ }
120
+ }
121
+ /**
122
+ * Error thrown when a resource is not found (404)
123
+ */
124
+ export class ZapierNotFoundError extends ZapierError {
125
+ constructor(message, options = {}) {
126
+ super(message, options);
127
+ this.name = "ZapierNotFoundError";
128
+ }
129
+ }
130
+ /**
131
+ * Utility function to format error messages for display
132
+ */
133
+ export function formatErrorMessage(error) {
134
+ let message = error.message;
135
+ // Add additional context from errors array if available
136
+ if (error.errors && error.errors.length > 0) {
137
+ const additionalErrors = error.errors.slice(1); // Skip first error (already in message)
138
+ if (additionalErrors.length > 0) {
139
+ const errorDetails = additionalErrors
140
+ .map((err) => ` • ${err.detail || err.title || err.code}`)
141
+ .join("\n");
142
+ message += "\n\nAdditional errors:\n" + errorDetails;
143
+ }
144
+ }
145
+ // Add error-specific context
146
+ if (error instanceof ZapierAppNotFoundError && error.appKey) {
147
+ message += `\nApp key: ${error.appKey}`;
148
+ }
149
+ if (error instanceof ZapierActionError && (error.appKey || error.actionKey)) {
150
+ const context = [];
151
+ if (error.appKey)
152
+ context.push(`App: ${error.appKey}`);
153
+ if (error.actionKey)
154
+ context.push(`Action: ${error.actionKey}`);
155
+ message += `\n${context.join(", ")}`;
156
+ }
157
+ if (error instanceof ZapierResourceNotFoundError &&
158
+ (error.resourceType || error.resourceId)) {
159
+ const context = [];
160
+ if (error.resourceType)
161
+ context.push(`Type: ${error.resourceType}`);
162
+ if (error.resourceId)
163
+ context.push(`ID: ${error.resourceId}`);
164
+ message += `\n${context.join(", ")}`;
165
+ }
166
+ if (error instanceof ZapierTimeoutError &&
167
+ (error.attempts || error.maxAttempts)) {
168
+ const context = [];
169
+ if (error.attempts)
170
+ context.push(`Attempts: ${error.attempts}`);
171
+ if (error.maxAttempts)
172
+ context.push(`Max attempts: ${error.maxAttempts}`);
173
+ message += `\n${context.join(", ")}`;
174
+ }
175
+ if (error instanceof ZapierBundleError &&
176
+ error.buildErrors &&
177
+ error.buildErrors.length > 0) {
178
+ message +=
179
+ "\n\nBuild errors:\n" +
180
+ error.buildErrors.map((err) => ` • ${err}`).join("\n");
181
+ }
182
+ // Add status code if available and not already obvious from the message
183
+ if (error.statusCode && !message.includes(`${error.statusCode}`)) {
184
+ message += `\nHTTP Status: ${error.statusCode}`;
185
+ }
186
+ return message;
187
+ }
@@ -0,0 +1,38 @@
1
+ /**
2
+ * SDK Event System
3
+ *
4
+ * This module provides common event type definitions for the SDK's
5
+ * event system, including authentication, API, and loading events.
6
+ */
7
+ export interface SdkEvent {
8
+ type: string;
9
+ payload?: Record<string, any>;
10
+ timestamp?: number;
11
+ }
12
+ export interface AuthEvent extends SdkEvent {
13
+ type: "auth_refreshing" | "auth_success" | "auth_error" | "auth_logout";
14
+ payload?: {
15
+ message?: string;
16
+ error?: string;
17
+ operation?: string;
18
+ };
19
+ }
20
+ export interface ApiEvent extends SdkEvent {
21
+ type: "api_request" | "api_response" | "api_error";
22
+ payload?: {
23
+ url?: string;
24
+ method?: string;
25
+ status?: number;
26
+ duration?: number;
27
+ error?: string;
28
+ };
29
+ }
30
+ export interface LoadingEvent extends SdkEvent {
31
+ type: "loading_start" | "loading_end";
32
+ payload?: {
33
+ operation?: string;
34
+ resource?: string;
35
+ };
36
+ }
37
+ export type EventCallback = (event: SdkEvent) => void;
38
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/types/events.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,SAAU,SAAQ,QAAQ;IACzC,IAAI,EAAE,iBAAiB,GAAG,cAAc,GAAG,YAAY,GAAG,aAAa,CAAC;IACxE,OAAO,CAAC,EAAE;QACR,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;CACH;AAED,MAAM,WAAW,QAAS,SAAQ,QAAQ;IACxC,IAAI,EAAE,aAAa,GAAG,cAAc,GAAG,WAAW,CAAC;IACnD,OAAO,CAAC,EAAE;QACR,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;CACH;AAED,MAAM,WAAW,YAAa,SAAQ,QAAQ;IAC5C,IAAI,EAAE,eAAe,GAAG,aAAa,CAAC;IACtC,OAAO,CAAC,EAAE;QACR,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC;CACH;AAED,MAAM,MAAM,aAAa,GAAG,CAAC,KAAK,EAAE,QAAQ,KAAK,IAAI,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * SDK Event System
3
+ *
4
+ * This module provides common event type definitions for the SDK's
5
+ * event system, including authentication, API, and loading events.
6
+ */
7
+ export {};
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Function-related types and interfaces
3
+ */
4
+ export interface FunctionOptions {
5
+ /** Base URL for Zapier API */
6
+ baseUrl?: string;
7
+ /** Authentication token */
8
+ token?: string;
9
+ /** Function to dynamically resolve authentication token */
10
+ getToken?: () => Promise<string | undefined>;
11
+ /** Optional pre-instantiated API client */
12
+ api?: any;
13
+ /** Enable debug logging */
14
+ debug?: boolean;
15
+ /** Custom fetch implementation */
16
+ fetch?: typeof globalThis.fetch;
17
+ }
18
+ export type PaginatedSdkFunction<TOptions, TItem> = (options: TOptions) => Promise<{
19
+ data: TItem[];
20
+ }> & AsyncIterable<{
21
+ data: TItem[];
22
+ nextCursor?: string;
23
+ }> & {
24
+ items(): AsyncIterable<TItem>;
25
+ };
26
+ //# sourceMappingURL=functions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../../src/types/functions.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,MAAM,WAAW,eAAe;IAC9B,8BAA8B;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2BAA2B;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2DAA2D;IAC3D,QAAQ,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAC7C,2CAA2C;IAC3C,GAAG,CAAC,EAAE,GAAG,CAAC;IACV,2BAA2B;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,kCAAkC;IAClC,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;CACjC;AAGD,MAAM,MAAM,oBAAoB,CAAC,QAAQ,EAAE,KAAK,IAAI,CAClD,OAAO,EAAE,QAAQ,KACd,OAAO,CAAC;IAAE,IAAI,EAAE,KAAK,EAAE,CAAA;CAAE,CAAC,GAC7B,aAAa,CAAC;IAAE,IAAI,EAAE,KAAK,EAAE,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG;IACtD,KAAK,IAAI,aAAa,CAAC,KAAK,CAAC,CAAC;CAC/B,CAAC"}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Function-related types and interfaces
3
+ */
4
+ export {};