agentmail 0.0.24 → 0.0.26

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 (281) hide show
  1. package/Client.d.ts +3 -0
  2. package/Client.js +7 -2
  3. package/README.md +1 -1
  4. package/api/resources/drafts/client/Client.d.ts +53 -0
  5. package/api/resources/drafts/client/Client.js +218 -0
  6. package/api/resources/drafts/client/index.d.ts +1 -0
  7. package/api/resources/drafts/client/index.js +17 -0
  8. package/api/resources/drafts/client/requests/ListDraftsRequest.d.ts +15 -0
  9. package/api/resources/drafts/client/requests/index.d.ts +1 -0
  10. package/api/resources/drafts/client/requests/index.js +2 -0
  11. package/api/resources/drafts/index.d.ts +2 -0
  12. package/api/resources/drafts/index.js +18 -0
  13. package/api/resources/drafts/types/Draft.d.ts +51 -0
  14. package/api/resources/drafts/types/DraftAttachments.d.ts +8 -0
  15. package/api/resources/drafts/types/DraftAttachments.js +5 -0
  16. package/api/resources/drafts/types/DraftBcc.d.ts +7 -0
  17. package/api/resources/drafts/types/DraftBcc.js +5 -0
  18. package/api/resources/drafts/types/DraftCc.d.ts +7 -0
  19. package/api/resources/drafts/types/DraftCc.js +5 -0
  20. package/api/resources/drafts/types/DraftCreatedAt.d.ts +7 -0
  21. package/api/resources/drafts/types/DraftCreatedAt.js +5 -0
  22. package/api/resources/drafts/types/DraftEventId.d.ts +7 -0
  23. package/api/resources/drafts/types/DraftEventId.js +5 -0
  24. package/api/resources/drafts/types/DraftHtml.d.ts +7 -0
  25. package/api/resources/drafts/types/DraftHtml.js +5 -0
  26. package/api/resources/drafts/types/DraftId.d.ts +7 -0
  27. package/api/resources/drafts/types/DraftId.js +5 -0
  28. package/api/resources/drafts/types/DraftInReplyTo.d.ts +7 -0
  29. package/api/resources/drafts/types/DraftInReplyTo.js +5 -0
  30. package/api/resources/drafts/types/DraftItem.d.ts +21 -0
  31. package/api/resources/drafts/types/DraftItem.js +5 -0
  32. package/api/resources/drafts/types/DraftLabels.d.ts +7 -0
  33. package/api/resources/drafts/types/DraftLabels.js +5 -0
  34. package/api/resources/drafts/types/DraftPreview.d.ts +7 -0
  35. package/api/resources/drafts/types/DraftPreview.js +5 -0
  36. package/api/resources/drafts/types/DraftReferences.d.ts +7 -0
  37. package/api/resources/drafts/types/DraftReferences.js +5 -0
  38. package/api/resources/drafts/types/DraftSubject.d.ts +7 -0
  39. package/api/resources/drafts/types/DraftSubject.js +5 -0
  40. package/api/resources/drafts/types/DraftText.d.ts +7 -0
  41. package/api/resources/drafts/types/DraftText.js +5 -0
  42. package/api/resources/drafts/types/DraftTo.d.ts +7 -0
  43. package/api/resources/drafts/types/DraftTo.js +5 -0
  44. package/api/resources/drafts/types/DraftUpdatedAt.d.ts +7 -0
  45. package/api/resources/drafts/types/DraftUpdatedAt.js +5 -0
  46. package/api/resources/drafts/types/ListDraftsResponse.d.ts +51 -0
  47. package/api/resources/drafts/types/ListDraftsResponse.js +5 -0
  48. package/api/resources/drafts/types/index.d.ts +18 -0
  49. package/api/resources/drafts/types/index.js +34 -0
  50. package/api/resources/inboxes/client/Client.js +8 -3
  51. package/api/resources/inboxes/types/Inbox.d.ts +0 -4
  52. package/api/resources/inboxes/types/ListInboxesResponse.d.ts +2 -3
  53. package/api/resources/index.d.ts +3 -0
  54. package/api/resources/index.js +4 -1
  55. package/api/resources/messages/client/Client.js +18 -5
  56. package/api/resources/messages/types/ListMessagesResponse.d.ts +6 -4
  57. package/api/resources/messages/types/Message.d.ts +4 -8
  58. package/api/resources/messages/types/MessageItem.d.ts +3 -0
  59. package/api/resources/messages/types/SendAttachment.d.ts +1 -1
  60. package/api/resources/messages/types/index.d.ts +4 -5
  61. package/api/resources/messages/types/index.js +4 -5
  62. package/api/resources/threads/client/Client.js +6 -2
  63. package/api/resources/threads/types/ListThreadsResponse.d.ts +4 -2
  64. package/api/resources/threads/types/Thread.d.ts +2 -5
  65. package/api/resources/threads/types/ThreadItem.d.ts +1 -0
  66. package/api/resources/threads/types/index.d.ts +1 -1
  67. package/api/resources/threads/types/index.js +1 -1
  68. package/api/resources/webhooks/client/Client.js +10 -4
  69. package/api/resources/webhooks/types/ListWebhooksResponse.d.ts +2 -2
  70. package/dist/Client.d.ts +3 -0
  71. package/dist/Client.js +7 -2
  72. package/dist/api/resources/drafts/client/Client.d.ts +53 -0
  73. package/dist/api/resources/drafts/client/Client.js +218 -0
  74. package/dist/api/resources/drafts/client/index.d.ts +1 -0
  75. package/dist/api/resources/drafts/client/index.js +17 -0
  76. package/dist/api/resources/drafts/client/requests/ListDraftsRequest.d.ts +15 -0
  77. package/dist/api/resources/drafts/client/requests/ListDraftsRequest.js +5 -0
  78. package/dist/api/resources/drafts/client/requests/index.d.ts +1 -0
  79. package/dist/api/resources/drafts/client/requests/index.js +2 -0
  80. package/dist/api/resources/drafts/index.d.ts +2 -0
  81. package/dist/api/resources/drafts/index.js +18 -0
  82. package/dist/api/resources/drafts/types/Draft.d.ts +51 -0
  83. package/dist/api/resources/drafts/types/Draft.js +5 -0
  84. package/dist/api/resources/drafts/types/DraftAttachments.d.ts +8 -0
  85. package/dist/api/resources/drafts/types/DraftAttachments.js +5 -0
  86. package/dist/api/resources/drafts/types/DraftBcc.d.ts +7 -0
  87. package/dist/api/resources/drafts/types/DraftBcc.js +5 -0
  88. package/dist/api/resources/drafts/types/DraftCc.d.ts +7 -0
  89. package/dist/api/resources/drafts/types/DraftCc.js +5 -0
  90. package/dist/api/resources/drafts/types/DraftCreatedAt.d.ts +7 -0
  91. package/dist/api/resources/drafts/types/DraftCreatedAt.js +5 -0
  92. package/dist/api/resources/drafts/types/DraftEventId.d.ts +7 -0
  93. package/dist/api/resources/drafts/types/DraftEventId.js +5 -0
  94. package/dist/api/resources/drafts/types/DraftHtml.d.ts +7 -0
  95. package/dist/api/resources/drafts/types/DraftHtml.js +5 -0
  96. package/dist/api/resources/drafts/types/DraftId.d.ts +7 -0
  97. package/dist/api/resources/drafts/types/DraftId.js +5 -0
  98. package/dist/api/resources/drafts/types/DraftInReplyTo.d.ts +7 -0
  99. package/dist/api/resources/drafts/types/DraftInReplyTo.js +5 -0
  100. package/dist/api/resources/drafts/types/DraftItem.d.ts +21 -0
  101. package/dist/api/resources/drafts/types/DraftItem.js +5 -0
  102. package/dist/api/resources/drafts/types/DraftLabels.d.ts +7 -0
  103. package/dist/api/resources/drafts/types/DraftLabels.js +5 -0
  104. package/dist/api/resources/drafts/types/DraftPreview.d.ts +7 -0
  105. package/dist/api/resources/drafts/types/DraftPreview.js +5 -0
  106. package/dist/api/resources/drafts/types/DraftReferences.d.ts +7 -0
  107. package/dist/api/resources/drafts/types/DraftReferences.js +5 -0
  108. package/dist/api/resources/drafts/types/DraftSubject.d.ts +7 -0
  109. package/dist/api/resources/drafts/types/DraftSubject.js +5 -0
  110. package/dist/api/resources/drafts/types/DraftText.d.ts +7 -0
  111. package/dist/api/resources/drafts/types/DraftText.js +5 -0
  112. package/dist/api/resources/drafts/types/DraftTo.d.ts +7 -0
  113. package/dist/api/resources/drafts/types/DraftTo.js +5 -0
  114. package/dist/api/resources/drafts/types/DraftUpdatedAt.d.ts +7 -0
  115. package/dist/api/resources/drafts/types/DraftUpdatedAt.js +5 -0
  116. package/dist/api/resources/drafts/types/ListDraftsResponse.d.ts +51 -0
  117. package/dist/api/resources/drafts/types/ListDraftsResponse.js +5 -0
  118. package/dist/api/resources/drafts/types/index.d.ts +18 -0
  119. package/dist/api/resources/drafts/types/index.js +34 -0
  120. package/dist/api/resources/inboxes/client/Client.js +8 -3
  121. package/dist/api/resources/inboxes/types/Inbox.d.ts +0 -4
  122. package/dist/api/resources/inboxes/types/ListInboxesResponse.d.ts +2 -3
  123. package/dist/api/resources/index.d.ts +3 -0
  124. package/dist/api/resources/index.js +4 -1
  125. package/dist/api/resources/messages/client/Client.js +18 -5
  126. package/dist/api/resources/messages/types/ListMessagesResponse.d.ts +6 -4
  127. package/dist/api/resources/messages/types/Message.d.ts +4 -8
  128. package/dist/api/resources/messages/types/MessageItem.d.ts +3 -0
  129. package/dist/api/resources/messages/types/SendAttachment.d.ts +1 -1
  130. package/dist/api/resources/messages/types/index.d.ts +4 -5
  131. package/dist/api/resources/messages/types/index.js +4 -5
  132. package/dist/api/resources/threads/client/Client.js +6 -2
  133. package/dist/api/resources/threads/types/ListThreadsResponse.d.ts +4 -2
  134. package/dist/api/resources/threads/types/Thread.d.ts +2 -5
  135. package/dist/api/resources/threads/types/ThreadItem.d.ts +1 -0
  136. package/dist/api/resources/threads/types/index.d.ts +1 -1
  137. package/dist/api/resources/threads/types/index.js +1 -1
  138. package/dist/api/resources/webhooks/client/Client.js +10 -4
  139. package/dist/api/resources/webhooks/types/ListWebhooksResponse.d.ts +2 -2
  140. package/dist/serialization/resources/drafts/index.d.ts +1 -0
  141. package/dist/serialization/resources/drafts/index.js +17 -0
  142. package/dist/serialization/resources/drafts/types/Draft.d.ts +45 -0
  143. package/dist/serialization/resources/drafts/types/Draft.js +76 -0
  144. package/dist/serialization/resources/drafts/types/DraftAttachments.d.ts +11 -0
  145. package/dist/serialization/resources/drafts/types/DraftAttachments.js +42 -0
  146. package/dist/serialization/resources/drafts/types/DraftBcc.d.ts +10 -0
  147. package/dist/serialization/resources/drafts/types/DraftBcc.js +41 -0
  148. package/dist/serialization/resources/drafts/types/DraftCc.d.ts +10 -0
  149. package/dist/serialization/resources/drafts/types/DraftCc.js +41 -0
  150. package/dist/serialization/resources/{messages/types/MessageReplyTo.d.ts → drafts/types/DraftCreatedAt.d.ts} +2 -2
  151. package/dist/serialization/resources/{messages/types/MessageReplyTo.js → drafts/types/DraftCreatedAt.js} +2 -2
  152. package/{serialization/resources/messages/types/MessageReplyTo.d.ts → dist/serialization/resources/drafts/types/DraftEventId.d.ts} +2 -2
  153. package/{serialization/resources/messages/types/MessageReplyTo.js → dist/serialization/resources/drafts/types/DraftEventId.js} +2 -2
  154. package/dist/serialization/resources/drafts/types/DraftHtml.d.ts +10 -0
  155. package/dist/serialization/resources/drafts/types/DraftHtml.js +41 -0
  156. package/dist/serialization/resources/drafts/types/DraftId.d.ts +10 -0
  157. package/dist/serialization/resources/drafts/types/DraftId.js +41 -0
  158. package/dist/serialization/resources/drafts/types/DraftInReplyTo.d.ts +10 -0
  159. package/dist/serialization/resources/drafts/types/DraftInReplyTo.js +41 -0
  160. package/dist/serialization/resources/drafts/types/DraftItem.d.ts +41 -0
  161. package/dist/serialization/resources/drafts/types/DraftItem.js +72 -0
  162. package/dist/serialization/resources/drafts/types/DraftLabels.d.ts +10 -0
  163. package/dist/serialization/resources/drafts/types/DraftLabels.js +41 -0
  164. package/dist/serialization/resources/drafts/types/DraftPreview.d.ts +10 -0
  165. package/dist/serialization/resources/drafts/types/DraftPreview.js +41 -0
  166. package/dist/serialization/resources/drafts/types/DraftReferences.d.ts +10 -0
  167. package/dist/serialization/resources/drafts/types/DraftReferences.js +41 -0
  168. package/dist/serialization/resources/drafts/types/DraftSubject.d.ts +10 -0
  169. package/dist/serialization/resources/drafts/types/DraftSubject.js +41 -0
  170. package/dist/serialization/resources/drafts/types/DraftText.d.ts +10 -0
  171. package/dist/serialization/resources/drafts/types/DraftText.js +41 -0
  172. package/dist/serialization/resources/drafts/types/DraftTo.d.ts +10 -0
  173. package/dist/serialization/resources/drafts/types/DraftTo.js +41 -0
  174. package/dist/serialization/resources/drafts/types/DraftUpdatedAt.d.ts +10 -0
  175. package/dist/serialization/resources/drafts/types/DraftUpdatedAt.js +41 -0
  176. package/dist/serialization/resources/drafts/types/ListDraftsResponse.d.ts +19 -0
  177. package/dist/serialization/resources/drafts/types/ListDraftsResponse.js +50 -0
  178. package/dist/serialization/resources/drafts/types/index.d.ts +18 -0
  179. package/dist/serialization/resources/drafts/types/index.js +34 -0
  180. package/dist/serialization/resources/inboxes/types/Inbox.d.ts +0 -1
  181. package/dist/serialization/resources/inboxes/types/Inbox.js +0 -1
  182. package/dist/serialization/resources/inboxes/types/ListInboxesResponse.d.ts +2 -2
  183. package/dist/serialization/resources/inboxes/types/ListInboxesResponse.js +2 -2
  184. package/dist/serialization/resources/index.d.ts +2 -0
  185. package/dist/serialization/resources/index.js +3 -1
  186. package/dist/serialization/resources/messages/types/ListMessagesResponse.d.ts +2 -2
  187. package/dist/serialization/resources/messages/types/ListMessagesResponse.js +2 -2
  188. package/dist/serialization/resources/messages/types/Message.d.ts +6 -10
  189. package/dist/serialization/resources/messages/types/Message.js +6 -10
  190. package/dist/serialization/resources/messages/types/MessageItem.d.ts +6 -0
  191. package/dist/serialization/resources/messages/types/MessageItem.js +6 -0
  192. package/dist/serialization/resources/messages/types/SendAttachment.d.ts +1 -1
  193. package/dist/serialization/resources/messages/types/SendAttachment.js +1 -1
  194. package/dist/serialization/resources/messages/types/index.d.ts +4 -5
  195. package/dist/serialization/resources/messages/types/index.js +4 -5
  196. package/dist/serialization/resources/threads/types/ListThreadsResponse.d.ts +2 -2
  197. package/dist/serialization/resources/threads/types/ListThreadsResponse.js +2 -2
  198. package/dist/serialization/resources/threads/types/Thread.d.ts +2 -4
  199. package/dist/serialization/resources/threads/types/Thread.js +2 -4
  200. package/dist/serialization/resources/threads/types/ThreadItem.d.ts +2 -0
  201. package/dist/serialization/resources/threads/types/ThreadItem.js +2 -0
  202. package/dist/serialization/resources/threads/types/index.d.ts +1 -1
  203. package/dist/serialization/resources/threads/types/index.js +1 -1
  204. package/dist/serialization/resources/webhooks/types/ListWebhooksResponse.d.ts +2 -2
  205. package/dist/serialization/resources/webhooks/types/ListWebhooksResponse.js +2 -2
  206. package/dist/version.d.ts +1 -1
  207. package/dist/version.js +1 -1
  208. package/package.json +1 -1
  209. package/reference.md +116 -0
  210. package/serialization/resources/drafts/index.d.ts +1 -0
  211. package/serialization/resources/drafts/index.js +17 -0
  212. package/serialization/resources/drafts/types/Draft.d.ts +45 -0
  213. package/serialization/resources/drafts/types/Draft.js +76 -0
  214. package/serialization/resources/drafts/types/DraftAttachments.d.ts +11 -0
  215. package/serialization/resources/drafts/types/DraftAttachments.js +42 -0
  216. package/serialization/resources/drafts/types/DraftBcc.d.ts +10 -0
  217. package/serialization/resources/drafts/types/DraftBcc.js +41 -0
  218. package/serialization/resources/drafts/types/DraftCc.d.ts +10 -0
  219. package/serialization/resources/drafts/types/DraftCc.js +41 -0
  220. package/serialization/resources/drafts/types/DraftCreatedAt.d.ts +10 -0
  221. package/serialization/resources/drafts/types/DraftCreatedAt.js +41 -0
  222. package/serialization/resources/drafts/types/DraftEventId.d.ts +10 -0
  223. package/serialization/resources/drafts/types/DraftEventId.js +41 -0
  224. package/serialization/resources/drafts/types/DraftHtml.d.ts +10 -0
  225. package/serialization/resources/drafts/types/DraftHtml.js +41 -0
  226. package/serialization/resources/drafts/types/DraftId.d.ts +10 -0
  227. package/serialization/resources/drafts/types/DraftId.js +41 -0
  228. package/serialization/resources/drafts/types/DraftInReplyTo.d.ts +10 -0
  229. package/serialization/resources/drafts/types/DraftInReplyTo.js +41 -0
  230. package/serialization/resources/drafts/types/DraftItem.d.ts +41 -0
  231. package/serialization/resources/drafts/types/DraftItem.js +72 -0
  232. package/serialization/resources/drafts/types/DraftLabels.d.ts +10 -0
  233. package/serialization/resources/drafts/types/DraftLabels.js +41 -0
  234. package/serialization/resources/drafts/types/DraftPreview.d.ts +10 -0
  235. package/serialization/resources/drafts/types/DraftPreview.js +41 -0
  236. package/serialization/resources/drafts/types/DraftReferences.d.ts +10 -0
  237. package/serialization/resources/drafts/types/DraftReferences.js +41 -0
  238. package/serialization/resources/drafts/types/DraftSubject.d.ts +10 -0
  239. package/serialization/resources/drafts/types/DraftSubject.js +41 -0
  240. package/serialization/resources/drafts/types/DraftText.d.ts +10 -0
  241. package/serialization/resources/drafts/types/DraftText.js +41 -0
  242. package/serialization/resources/drafts/types/DraftTo.d.ts +10 -0
  243. package/serialization/resources/drafts/types/DraftTo.js +41 -0
  244. package/serialization/resources/drafts/types/DraftUpdatedAt.d.ts +10 -0
  245. package/serialization/resources/drafts/types/DraftUpdatedAt.js +41 -0
  246. package/serialization/resources/drafts/types/ListDraftsResponse.d.ts +19 -0
  247. package/serialization/resources/drafts/types/ListDraftsResponse.js +50 -0
  248. package/serialization/resources/drafts/types/index.d.ts +18 -0
  249. package/serialization/resources/drafts/types/index.js +34 -0
  250. package/serialization/resources/inboxes/types/Inbox.d.ts +0 -1
  251. package/serialization/resources/inboxes/types/Inbox.js +0 -1
  252. package/serialization/resources/inboxes/types/ListInboxesResponse.d.ts +2 -2
  253. package/serialization/resources/inboxes/types/ListInboxesResponse.js +2 -2
  254. package/serialization/resources/index.d.ts +2 -0
  255. package/serialization/resources/index.js +3 -1
  256. package/serialization/resources/messages/types/ListMessagesResponse.d.ts +2 -2
  257. package/serialization/resources/messages/types/ListMessagesResponse.js +2 -2
  258. package/serialization/resources/messages/types/Message.d.ts +6 -10
  259. package/serialization/resources/messages/types/Message.js +6 -10
  260. package/serialization/resources/messages/types/MessageItem.d.ts +6 -0
  261. package/serialization/resources/messages/types/MessageItem.js +6 -0
  262. package/serialization/resources/messages/types/SendAttachment.d.ts +1 -1
  263. package/serialization/resources/messages/types/SendAttachment.js +1 -1
  264. package/serialization/resources/messages/types/index.d.ts +4 -5
  265. package/serialization/resources/messages/types/index.js +4 -5
  266. package/serialization/resources/threads/types/ListThreadsResponse.d.ts +2 -2
  267. package/serialization/resources/threads/types/ListThreadsResponse.js +2 -2
  268. package/serialization/resources/threads/types/Thread.d.ts +2 -4
  269. package/serialization/resources/threads/types/Thread.js +2 -4
  270. package/serialization/resources/threads/types/ThreadItem.d.ts +2 -0
  271. package/serialization/resources/threads/types/ThreadItem.js +2 -0
  272. package/serialization/resources/threads/types/index.d.ts +1 -1
  273. package/serialization/resources/threads/types/index.js +1 -1
  274. package/serialization/resources/webhooks/types/ListWebhooksResponse.d.ts +2 -2
  275. package/serialization/resources/webhooks/types/ListWebhooksResponse.js +2 -2
  276. package/version.d.ts +1 -1
  277. package/version.js +1 -1
  278. package/api/resources/messages/types/MessageReplyTo.d.ts +0 -7
  279. package/dist/api/resources/messages/types/MessageReplyTo.d.ts +0 -7
  280. /package/api/resources/{messages/types/MessageReplyTo.js → drafts/client/requests/ListDraftsRequest.js} +0 -0
  281. /package/{dist/api/resources/messages/types/MessageReplyTo.js → api/resources/drafts/types/Draft.js} +0 -0
@@ -89,7 +89,7 @@ class Threads {
89
89
  const _response = yield core.fetcher({
90
90
  url: (0, url_join_1.default)((_b = (_a = (yield core.Supplier.get(this._options.baseUrl))) !== null && _a !== void 0 ? _a : (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.AgentMailEnvironment.Production, `/v0/inboxes/${encodeURIComponent(serializers.InboxId.jsonOrThrow(inboxId))}/threads`),
91
91
  method: "GET",
92
- headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "agentmail", "X-Fern-SDK-Version": "0.0.24", "User-Agent": "agentmail/0.0.24", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
92
+ headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "agentmail", "X-Fern-SDK-Version": "0.0.26", "User-Agent": "agentmail/0.0.26", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
93
93
  contentType: "application/json",
94
94
  queryParameters: _queryParams,
95
95
  requestType: "json",
@@ -102,6 +102,7 @@ class Threads {
102
102
  unrecognizedObjectKeys: "passthrough",
103
103
  allowUnrecognizedUnionMembers: true,
104
104
  allowUnrecognizedEnumValues: true,
105
+ skipValidation: true,
105
106
  breadcrumbsPrefix: ["response"],
106
107
  });
107
108
  }
@@ -112,6 +113,7 @@ class Threads {
112
113
  unrecognizedObjectKeys: "passthrough",
113
114
  allowUnrecognizedUnionMembers: true,
114
115
  allowUnrecognizedEnumValues: true,
116
+ skipValidation: true,
115
117
  breadcrumbsPrefix: ["response"],
116
118
  }));
117
119
  default:
@@ -152,7 +154,7 @@ class Threads {
152
154
  const _response = yield core.fetcher({
153
155
  url: (0, url_join_1.default)((_b = (_a = (yield core.Supplier.get(this._options.baseUrl))) !== null && _a !== void 0 ? _a : (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.AgentMailEnvironment.Production, `/v0/inboxes/${encodeURIComponent(serializers.InboxId.jsonOrThrow(inboxId))}/threads/${encodeURIComponent(serializers.ThreadId.jsonOrThrow(threadId))}`),
154
156
  method: "GET",
155
- headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "agentmail", "X-Fern-SDK-Version": "0.0.24", "User-Agent": "agentmail/0.0.24", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
157
+ headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "agentmail", "X-Fern-SDK-Version": "0.0.26", "User-Agent": "agentmail/0.0.26", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
156
158
  contentType: "application/json",
157
159
  requestType: "json",
158
160
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
@@ -164,6 +166,7 @@ class Threads {
164
166
  unrecognizedObjectKeys: "passthrough",
165
167
  allowUnrecognizedUnionMembers: true,
166
168
  allowUnrecognizedEnumValues: true,
169
+ skipValidation: true,
167
170
  breadcrumbsPrefix: ["response"],
168
171
  });
169
172
  }
@@ -174,6 +177,7 @@ class Threads {
174
177
  unrecognizedObjectKeys: "passthrough",
175
178
  allowUnrecognizedUnionMembers: true,
176
179
  allowUnrecognizedEnumValues: true,
180
+ skipValidation: true,
177
181
  breadcrumbsPrefix: ["response"],
178
182
  }));
179
183
  default:
@@ -6,6 +6,7 @@ import * as AgentMail from "../../../index";
6
6
  * @example
7
7
  * {
8
8
  * threads: [{
9
+ * inboxId: "yourinbox@agentmail.to",
9
10
  * threadId: "thread_123",
10
11
  * eventId: "event_123",
11
12
  * labels: ["RECEIVED", "UNREAD"],
@@ -16,6 +17,7 @@ import * as AgentMail from "../../../index";
16
17
  * subject: "Project Discussion",
17
18
  * preview: "Let's review the timeline for..."
18
19
  * }, {
20
+ * inboxId: "yourinbox@agentmail.to",
19
21
  * threadId: "thread_456",
20
22
  * eventId: "event_456",
21
23
  * labels: ["SENT"],
@@ -32,9 +34,9 @@ import * as AgentMail from "../../../index";
32
34
  * }
33
35
  */
34
36
  export interface ListThreadsResponse {
35
- /** Thread items. Ordered by `updated_at` descending. */
36
- threads: AgentMail.ThreadItem[];
37
37
  count: AgentMail.Count;
38
38
  limit?: AgentMail.Limit;
39
39
  lastKey?: AgentMail.LastKey;
40
+ /** Thread items. Ordered by `timestamp` descending. */
41
+ threads: AgentMail.ThreadItem[];
40
42
  }
@@ -5,7 +5,6 @@ import * as AgentMail from "../../../index";
5
5
  /**
6
6
  * @example
7
7
  * {
8
- * organizationId: "org_123",
9
8
  * inboxId: "yourinbox@agentmail.to",
10
9
  * threadId: "thread_123",
11
10
  * eventId: "event_123",
@@ -25,12 +24,12 @@ import * as AgentMail from "../../../index";
25
24
  * from: "alice@example.com",
26
25
  * to: ["bob@example.com"],
27
26
  * text: "Let's review the timeline for the project.",
28
- * inboxId: "yourinbox@agentmail.to",
29
- * organizationId: "org_123"
27
+ * inboxId: "yourinbox@agentmail.to"
30
28
  * }]
31
29
  * }
32
30
  */
33
31
  export interface Thread {
32
+ inboxId: AgentMail.InboxId;
34
33
  threadId: AgentMail.ThreadId;
35
34
  eventId: AgentMail.ThreadEventId;
36
35
  labels: AgentMail.ThreadLabels;
@@ -43,6 +42,4 @@ export interface Thread {
43
42
  attachments?: AgentMail.ThreadAttachments;
44
43
  /** Messages in thread. Ordered by `sent_at` ascending. */
45
44
  messages: AgentMail.Message[];
46
- inboxId: AgentMail.InboxId;
47
- organizationId: AgentMail.OrganizationId;
48
45
  }
@@ -3,6 +3,7 @@
3
3
  */
4
4
  import * as AgentMail from "../../../index";
5
5
  export interface ThreadItem {
6
+ inboxId: AgentMail.InboxId;
6
7
  threadId: AgentMail.ThreadId;
7
8
  eventId: AgentMail.ThreadEventId;
8
9
  labels: AgentMail.ThreadLabels;
@@ -1,4 +1,3 @@
1
- export * from "./ThreadAttachment";
2
1
  export * from "./ThreadId";
3
2
  export * from "./ThreadEventId";
4
3
  export * from "./ThreadLabels";
@@ -8,6 +7,7 @@ export * from "./ThreadRecipients";
8
7
  export * from "./ThreadMessageCount";
9
8
  export * from "./ThreadSubject";
10
9
  export * from "./ThreadPreview";
10
+ export * from "./ThreadAttachment";
11
11
  export * from "./ThreadAttachments";
12
12
  export * from "./ThreadItem";
13
13
  export * from "./Thread";
@@ -14,7 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./ThreadAttachment"), exports);
18
17
  __exportStar(require("./ThreadId"), exports);
19
18
  __exportStar(require("./ThreadEventId"), exports);
20
19
  __exportStar(require("./ThreadLabels"), exports);
@@ -24,6 +23,7 @@ __exportStar(require("./ThreadRecipients"), exports);
24
23
  __exportStar(require("./ThreadMessageCount"), exports);
25
24
  __exportStar(require("./ThreadSubject"), exports);
26
25
  __exportStar(require("./ThreadPreview"), exports);
26
+ __exportStar(require("./ThreadAttachment"), exports);
27
27
  __exportStar(require("./ThreadAttachments"), exports);
28
28
  __exportStar(require("./ThreadItem"), exports);
29
29
  __exportStar(require("./Thread"), exports);
@@ -80,7 +80,7 @@ class Webhooks {
80
80
  const _response = yield core.fetcher({
81
81
  url: (0, url_join_1.default)((_b = (_a = (yield core.Supplier.get(this._options.baseUrl))) !== null && _a !== void 0 ? _a : (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.AgentMailEnvironment.Production, "/v0/webhooks"),
82
82
  method: "GET",
83
- headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "agentmail", "X-Fern-SDK-Version": "0.0.24", "User-Agent": "agentmail/0.0.24", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
83
+ headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "agentmail", "X-Fern-SDK-Version": "0.0.26", "User-Agent": "agentmail/0.0.26", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
84
84
  contentType: "application/json",
85
85
  queryParameters: _queryParams,
86
86
  requestType: "json",
@@ -93,6 +93,7 @@ class Webhooks {
93
93
  unrecognizedObjectKeys: "passthrough",
94
94
  allowUnrecognizedUnionMembers: true,
95
95
  allowUnrecognizedEnumValues: true,
96
+ skipValidation: true,
96
97
  breadcrumbsPrefix: ["response"],
97
98
  });
98
99
  }
@@ -132,7 +133,7 @@ class Webhooks {
132
133
  const _response = yield core.fetcher({
133
134
  url: (0, url_join_1.default)((_b = (_a = (yield core.Supplier.get(this._options.baseUrl))) !== null && _a !== void 0 ? _a : (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.AgentMailEnvironment.Production, `/v0/webhooks/${encodeURIComponent(serializers.WebhookId.jsonOrThrow(webhookId))}`),
134
135
  method: "GET",
135
- headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "agentmail", "X-Fern-SDK-Version": "0.0.24", "User-Agent": "agentmail/0.0.24", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
136
+ headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "agentmail", "X-Fern-SDK-Version": "0.0.26", "User-Agent": "agentmail/0.0.26", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
136
137
  contentType: "application/json",
137
138
  requestType: "json",
138
139
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
@@ -144,6 +145,7 @@ class Webhooks {
144
145
  unrecognizedObjectKeys: "passthrough",
145
146
  allowUnrecognizedUnionMembers: true,
146
147
  allowUnrecognizedEnumValues: true,
148
+ skipValidation: true,
147
149
  breadcrumbsPrefix: ["response"],
148
150
  });
149
151
  }
@@ -154,6 +156,7 @@ class Webhooks {
154
156
  unrecognizedObjectKeys: "passthrough",
155
157
  allowUnrecognizedUnionMembers: true,
156
158
  allowUnrecognizedEnumValues: true,
159
+ skipValidation: true,
157
160
  breadcrumbsPrefix: ["response"],
158
161
  }));
159
162
  default:
@@ -197,7 +200,7 @@ class Webhooks {
197
200
  const _response = yield core.fetcher({
198
201
  url: (0, url_join_1.default)((_b = (_a = (yield core.Supplier.get(this._options.baseUrl))) !== null && _a !== void 0 ? _a : (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.AgentMailEnvironment.Production, "/v0/webhooks"),
199
202
  method: "POST",
200
- headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "agentmail", "X-Fern-SDK-Version": "0.0.24", "User-Agent": "agentmail/0.0.24", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
203
+ headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "agentmail", "X-Fern-SDK-Version": "0.0.26", "User-Agent": "agentmail/0.0.26", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
201
204
  contentType: "application/json",
202
205
  requestType: "json",
203
206
  body: serializers.CreateWebhookRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
@@ -210,6 +213,7 @@ class Webhooks {
210
213
  unrecognizedObjectKeys: "passthrough",
211
214
  allowUnrecognizedUnionMembers: true,
212
215
  allowUnrecognizedEnumValues: true,
216
+ skipValidation: true,
213
217
  breadcrumbsPrefix: ["response"],
214
218
  });
215
219
  }
@@ -220,6 +224,7 @@ class Webhooks {
220
224
  unrecognizedObjectKeys: "passthrough",
221
225
  allowUnrecognizedUnionMembers: true,
222
226
  allowUnrecognizedEnumValues: true,
227
+ skipValidation: true,
223
228
  breadcrumbsPrefix: ["response"],
224
229
  }));
225
230
  default:
@@ -259,7 +264,7 @@ class Webhooks {
259
264
  const _response = yield core.fetcher({
260
265
  url: (0, url_join_1.default)((_b = (_a = (yield core.Supplier.get(this._options.baseUrl))) !== null && _a !== void 0 ? _a : (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.AgentMailEnvironment.Production, `/v0/webhooks/${encodeURIComponent(serializers.WebhookId.jsonOrThrow(webhookId))}`),
261
266
  method: "DELETE",
262
- headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "agentmail", "X-Fern-SDK-Version": "0.0.24", "User-Agent": "agentmail/0.0.24", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
267
+ headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "agentmail", "X-Fern-SDK-Version": "0.0.26", "User-Agent": "agentmail/0.0.26", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
263
268
  contentType: "application/json",
264
269
  requestType: "json",
265
270
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
@@ -276,6 +281,7 @@ class Webhooks {
276
281
  unrecognizedObjectKeys: "passthrough",
277
282
  allowUnrecognizedUnionMembers: true,
278
283
  allowUnrecognizedEnumValues: true,
284
+ skipValidation: true,
279
285
  breadcrumbsPrefix: ["response"],
280
286
  }));
281
287
  default:
@@ -3,9 +3,9 @@
3
3
  */
4
4
  import * as AgentMail from "../../../index";
5
5
  export interface ListWebhooksResponse {
6
- /** Webhook items. Ordered by `created_at` ascending. */
7
- webhooks: AgentMail.Webhook[];
8
6
  count: AgentMail.Count;
9
7
  limit?: AgentMail.Limit;
10
8
  lastKey?: AgentMail.LastKey;
9
+ /** Webhook items. Ordered by `created_at` ascending. */
10
+ webhooks: AgentMail.Webhook[];
11
11
  }
package/dist/Client.d.ts CHANGED
@@ -6,6 +6,7 @@ import * as core from "./core";
6
6
  import { Inboxes } from "./api/resources/inboxes/client/Client";
7
7
  import { Threads } from "./api/resources/threads/client/Client";
8
8
  import { Messages } from "./api/resources/messages/client/Client";
9
+ import { Drafts } from "./api/resources/drafts/client/Client";
9
10
  import { Webhooks } from "./api/resources/webhooks/client/Client";
10
11
  export declare namespace AgentMailClient {
11
12
  interface Options {
@@ -30,10 +31,12 @@ export declare class AgentMailClient {
30
31
  protected _inboxes: Inboxes | undefined;
31
32
  protected _threads: Threads | undefined;
32
33
  protected _messages: Messages | undefined;
34
+ protected _drafts: Drafts | undefined;
33
35
  protected _webhooks: Webhooks | undefined;
34
36
  constructor(_options?: AgentMailClient.Options);
35
37
  get inboxes(): Inboxes;
36
38
  get threads(): Threads;
37
39
  get messages(): Messages;
40
+ get drafts(): Drafts;
38
41
  get webhooks(): Webhooks;
39
42
  }
package/dist/Client.js CHANGED
@@ -7,7 +7,8 @@ exports.AgentMailClient = void 0;
7
7
  const Client_1 = require("./api/resources/inboxes/client/Client");
8
8
  const Client_2 = require("./api/resources/threads/client/Client");
9
9
  const Client_3 = require("./api/resources/messages/client/Client");
10
- const Client_4 = require("./api/resources/webhooks/client/Client");
10
+ const Client_4 = require("./api/resources/drafts/client/Client");
11
+ const Client_5 = require("./api/resources/webhooks/client/Client");
11
12
  class AgentMailClient {
12
13
  constructor(_options = {}) {
13
14
  this._options = _options;
@@ -24,9 +25,13 @@ class AgentMailClient {
24
25
  var _a;
25
26
  return ((_a = this._messages) !== null && _a !== void 0 ? _a : (this._messages = new Client_3.Messages(this._options)));
26
27
  }
28
+ get drafts() {
29
+ var _a;
30
+ return ((_a = this._drafts) !== null && _a !== void 0 ? _a : (this._drafts = new Client_4.Drafts(this._options)));
31
+ }
27
32
  get webhooks() {
28
33
  var _a;
29
- return ((_a = this._webhooks) !== null && _a !== void 0 ? _a : (this._webhooks = new Client_4.Webhooks(this._options)));
34
+ return ((_a = this._webhooks) !== null && _a !== void 0 ? _a : (this._webhooks = new Client_5.Webhooks(this._options)));
30
35
  }
31
36
  }
32
37
  exports.AgentMailClient = AgentMailClient;
@@ -0,0 +1,53 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as environments from "../../../../environments";
5
+ import * as core from "../../../../core";
6
+ import * as AgentMail from "../../../index";
7
+ export declare namespace Drafts {
8
+ interface Options {
9
+ environment?: core.Supplier<environments.AgentMailEnvironment | string>;
10
+ /** Specify a custom URL to connect the client to. */
11
+ baseUrl?: core.Supplier<string>;
12
+ apiKey?: core.Supplier<core.BearerToken | undefined>;
13
+ }
14
+ interface RequestOptions {
15
+ /** The maximum time to wait for a response in seconds. */
16
+ timeoutInSeconds?: number;
17
+ /** The number of times to retry the request. Defaults to 2. */
18
+ maxRetries?: number;
19
+ /** A hook to abort the request. */
20
+ abortSignal?: AbortSignal;
21
+ /** Additional headers to include in the request. */
22
+ headers?: Record<string, string>;
23
+ }
24
+ }
25
+ export declare class Drafts {
26
+ protected readonly _options: Drafts.Options;
27
+ constructor(_options?: Drafts.Options);
28
+ /**
29
+ * @param {AgentMail.InboxId} inboxId
30
+ * @param {AgentMail.ListDraftsRequest} request
31
+ * @param {Drafts.RequestOptions} requestOptions - Request-specific configuration.
32
+ *
33
+ * @throws {@link AgentMail.NotFoundError}
34
+ *
35
+ * @example
36
+ * await client.drafts.list("yourinbox@agentmail.to", {
37
+ * limit: 10
38
+ * })
39
+ */
40
+ list(inboxId: AgentMail.InboxId, request?: AgentMail.ListDraftsRequest, requestOptions?: Drafts.RequestOptions): Promise<AgentMail.ListDraftsResponse>;
41
+ /**
42
+ * @param {AgentMail.InboxId} inboxId
43
+ * @param {AgentMail.DraftId} draftId
44
+ * @param {Drafts.RequestOptions} requestOptions - Request-specific configuration.
45
+ *
46
+ * @throws {@link AgentMail.NotFoundError}
47
+ *
48
+ * @example
49
+ * await client.drafts.get("yourinbox@agentmail.to", "draft_123")
50
+ */
51
+ get(inboxId: AgentMail.InboxId, draftId: AgentMail.DraftId, requestOptions?: Drafts.RequestOptions): Promise<AgentMail.Draft>;
52
+ protected _getAuthorizationHeader(): Promise<string>;
53
+ }
@@ -0,0 +1,218 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
18
+ }) : function(o, v) {
19
+ o["default"] = v;
20
+ });
21
+ var __importStar = (this && this.__importStar) || (function () {
22
+ var ownKeys = function(o) {
23
+ ownKeys = Object.getOwnPropertyNames || function (o) {
24
+ var ar = [];
25
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
+ return ar;
27
+ };
28
+ return ownKeys(o);
29
+ };
30
+ return function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ })();
38
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
39
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
40
+ return new (P || (P = Promise))(function (resolve, reject) {
41
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
42
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
43
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
44
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
45
+ });
46
+ };
47
+ var __importDefault = (this && this.__importDefault) || function (mod) {
48
+ return (mod && mod.__esModule) ? mod : { "default": mod };
49
+ };
50
+ Object.defineProperty(exports, "__esModule", { value: true });
51
+ exports.Drafts = void 0;
52
+ const environments = __importStar(require("../../../../environments"));
53
+ const core = __importStar(require("../../../../core"));
54
+ const AgentMail = __importStar(require("../../../index"));
55
+ const serializers = __importStar(require("../../../../serialization/index"));
56
+ const json_1 = require("../../../../core/json");
57
+ const url_join_1 = __importDefault(require("url-join"));
58
+ const errors = __importStar(require("../../../../errors/index"));
59
+ class Drafts {
60
+ constructor(_options = {}) {
61
+ this._options = _options;
62
+ }
63
+ /**
64
+ * @param {AgentMail.InboxId} inboxId
65
+ * @param {AgentMail.ListDraftsRequest} request
66
+ * @param {Drafts.RequestOptions} requestOptions - Request-specific configuration.
67
+ *
68
+ * @throws {@link AgentMail.NotFoundError}
69
+ *
70
+ * @example
71
+ * await client.drafts.list("yourinbox@agentmail.to", {
72
+ * limit: 10
73
+ * })
74
+ */
75
+ list(inboxId_1) {
76
+ return __awaiter(this, arguments, void 0, function* (inboxId, request = {}, requestOptions) {
77
+ var _a, _b;
78
+ const { limit, lastKey, labels } = request;
79
+ const _queryParams = {};
80
+ if (limit != null) {
81
+ _queryParams["limit"] = limit.toString();
82
+ }
83
+ if (lastKey != null) {
84
+ _queryParams["last_key"] = lastKey;
85
+ }
86
+ if (labels != null) {
87
+ _queryParams["labels"] = (0, json_1.toJson)(serializers.Labels.jsonOrThrow(labels, { unrecognizedObjectKeys: "strip" }));
88
+ }
89
+ const _response = yield core.fetcher({
90
+ url: (0, url_join_1.default)((_b = (_a = (yield core.Supplier.get(this._options.baseUrl))) !== null && _a !== void 0 ? _a : (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.AgentMailEnvironment.Production, `/v0/inboxes/${encodeURIComponent(serializers.InboxId.jsonOrThrow(inboxId))}/drafts`),
91
+ method: "GET",
92
+ headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "agentmail", "X-Fern-SDK-Version": "0.0.26", "User-Agent": "agentmail/0.0.26", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
93
+ contentType: "application/json",
94
+ queryParameters: _queryParams,
95
+ requestType: "json",
96
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
97
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
98
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
99
+ });
100
+ if (_response.ok) {
101
+ return serializers.ListDraftsResponse.parseOrThrow(_response.body, {
102
+ unrecognizedObjectKeys: "passthrough",
103
+ allowUnrecognizedUnionMembers: true,
104
+ allowUnrecognizedEnumValues: true,
105
+ skipValidation: true,
106
+ breadcrumbsPrefix: ["response"],
107
+ });
108
+ }
109
+ if (_response.error.reason === "status-code") {
110
+ switch (_response.error.statusCode) {
111
+ case 404:
112
+ throw new AgentMail.NotFoundError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
113
+ unrecognizedObjectKeys: "passthrough",
114
+ allowUnrecognizedUnionMembers: true,
115
+ allowUnrecognizedEnumValues: true,
116
+ skipValidation: true,
117
+ breadcrumbsPrefix: ["response"],
118
+ }));
119
+ default:
120
+ throw new errors.AgentMailError({
121
+ statusCode: _response.error.statusCode,
122
+ body: _response.error.body,
123
+ });
124
+ }
125
+ }
126
+ switch (_response.error.reason) {
127
+ case "non-json":
128
+ throw new errors.AgentMailError({
129
+ statusCode: _response.error.statusCode,
130
+ body: _response.error.rawBody,
131
+ });
132
+ case "timeout":
133
+ throw new errors.AgentMailTimeoutError("Timeout exceeded when calling GET /v0/inboxes/{inbox_id}/drafts.");
134
+ case "unknown":
135
+ throw new errors.AgentMailError({
136
+ message: _response.error.errorMessage,
137
+ });
138
+ }
139
+ });
140
+ }
141
+ /**
142
+ * @param {AgentMail.InboxId} inboxId
143
+ * @param {AgentMail.DraftId} draftId
144
+ * @param {Drafts.RequestOptions} requestOptions - Request-specific configuration.
145
+ *
146
+ * @throws {@link AgentMail.NotFoundError}
147
+ *
148
+ * @example
149
+ * await client.drafts.get("yourinbox@agentmail.to", "draft_123")
150
+ */
151
+ get(inboxId, draftId, requestOptions) {
152
+ return __awaiter(this, void 0, void 0, function* () {
153
+ var _a, _b;
154
+ const _response = yield core.fetcher({
155
+ url: (0, url_join_1.default)((_b = (_a = (yield core.Supplier.get(this._options.baseUrl))) !== null && _a !== void 0 ? _a : (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.AgentMailEnvironment.Production, `/v0/inboxes/${encodeURIComponent(serializers.InboxId.jsonOrThrow(inboxId))}/drafts/${encodeURIComponent(serializers.DraftId.jsonOrThrow(draftId))}`),
156
+ method: "GET",
157
+ headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "agentmail", "X-Fern-SDK-Version": "0.0.26", "User-Agent": "agentmail/0.0.26", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
158
+ contentType: "application/json",
159
+ requestType: "json",
160
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
161
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
162
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
163
+ });
164
+ if (_response.ok) {
165
+ return serializers.Draft.parseOrThrow(_response.body, {
166
+ unrecognizedObjectKeys: "passthrough",
167
+ allowUnrecognizedUnionMembers: true,
168
+ allowUnrecognizedEnumValues: true,
169
+ skipValidation: true,
170
+ breadcrumbsPrefix: ["response"],
171
+ });
172
+ }
173
+ if (_response.error.reason === "status-code") {
174
+ switch (_response.error.statusCode) {
175
+ case 404:
176
+ throw new AgentMail.NotFoundError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
177
+ unrecognizedObjectKeys: "passthrough",
178
+ allowUnrecognizedUnionMembers: true,
179
+ allowUnrecognizedEnumValues: true,
180
+ skipValidation: true,
181
+ breadcrumbsPrefix: ["response"],
182
+ }));
183
+ default:
184
+ throw new errors.AgentMailError({
185
+ statusCode: _response.error.statusCode,
186
+ body: _response.error.body,
187
+ });
188
+ }
189
+ }
190
+ switch (_response.error.reason) {
191
+ case "non-json":
192
+ throw new errors.AgentMailError({
193
+ statusCode: _response.error.statusCode,
194
+ body: _response.error.rawBody,
195
+ });
196
+ case "timeout":
197
+ throw new errors.AgentMailTimeoutError("Timeout exceeded when calling GET /v0/inboxes/{inbox_id}/drafts/{draft_id}.");
198
+ case "unknown":
199
+ throw new errors.AgentMailError({
200
+ message: _response.error.errorMessage,
201
+ });
202
+ }
203
+ });
204
+ }
205
+ _getAuthorizationHeader() {
206
+ return __awaiter(this, void 0, void 0, function* () {
207
+ var _a;
208
+ const bearer = (_a = (yield core.Supplier.get(this._options.apiKey))) !== null && _a !== void 0 ? _a : process === null || process === void 0 ? void 0 : process.env["AGENTMAIL_API_KEY"];
209
+ if (bearer == null) {
210
+ throw new errors.AgentMailError({
211
+ message: "Please specify a bearer by either passing it in to the constructor or initializing a AGENTMAIL_API_KEY environment variable",
212
+ });
213
+ }
214
+ return `Bearer ${bearer}`;
215
+ });
216
+ }
217
+ }
218
+ exports.Drafts = Drafts;
@@ -0,0 +1 @@
1
+ export * from "./requests";
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./requests"), exports);
@@ -0,0 +1,15 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as AgentMail from "../../../../index";
5
+ /**
6
+ * @example
7
+ * {
8
+ * limit: 10
9
+ * }
10
+ */
11
+ export interface ListDraftsRequest {
12
+ limit?: AgentMail.Limit;
13
+ lastKey?: AgentMail.LastKey;
14
+ labels?: AgentMail.Labels;
15
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export { type ListDraftsRequest } from "./ListDraftsRequest";
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ export * from "./types";
2
+ export * from "./client";
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./types"), exports);
18
+ __exportStar(require("./client"), exports);