agentmail 0.1.6 → 0.1.7

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 (233) hide show
  1. package/README.md +63 -0
  2. package/dist/cjs/BaseClient.d.ts +14 -1
  3. package/dist/cjs/BaseClient.js +59 -0
  4. package/dist/cjs/Client.d.ts +30 -29
  5. package/dist/cjs/Client.js +12 -53
  6. package/dist/cjs/api/resources/apiKeys/client/Client.d.ts +12 -12
  7. package/dist/cjs/api/resources/apiKeys/client/Client.js +29 -31
  8. package/dist/cjs/api/resources/domains/client/Client.d.ts +19 -19
  9. package/dist/cjs/api/resources/domains/client/Client.js +60 -53
  10. package/dist/cjs/api/resources/drafts/client/Client.d.ts +10 -10
  11. package/dist/cjs/api/resources/drafts/client/Client.js +23 -28
  12. package/dist/cjs/api/resources/events/types/DomainVerifiedEvent.d.ts +7 -0
  13. package/dist/cjs/api/resources/{webhooks → events}/types/EventType.d.ts +1 -0
  14. package/dist/cjs/api/resources/{webhooks → events}/types/EventType.js +1 -0
  15. package/dist/cjs/api/resources/events/types/EventTypes.d.ts +5 -0
  16. package/dist/cjs/api/resources/events/types/EventTypes.js +3 -0
  17. package/dist/cjs/api/resources/events/types/index.d.ts +3 -0
  18. package/dist/cjs/api/resources/events/types/index.js +3 -0
  19. package/dist/cjs/api/resources/inboxes/client/Client.d.ts +30 -30
  20. package/dist/cjs/api/resources/inboxes/client/Client.js +55 -51
  21. package/dist/cjs/api/resources/inboxes/resources/drafts/client/Client.d.ts +27 -27
  22. package/dist/cjs/api/resources/inboxes/resources/drafts/client/Client.js +77 -70
  23. package/dist/cjs/api/resources/inboxes/resources/messages/client/Client.d.ts +25 -25
  24. package/dist/cjs/api/resources/inboxes/resources/messages/client/Client.js +83 -73
  25. package/dist/cjs/api/resources/inboxes/resources/metrics/client/Client.d.ts +8 -8
  26. package/dist/cjs/api/resources/inboxes/resources/metrics/client/Client.js +17 -25
  27. package/dist/cjs/api/resources/inboxes/resources/threads/client/Client.d.ts +17 -17
  28. package/dist/cjs/api/resources/inboxes/resources/threads/client/Client.js +51 -50
  29. package/dist/cjs/api/resources/metrics/client/Client.d.ts +7 -7
  30. package/dist/cjs/api/resources/metrics/client/Client.js +12 -20
  31. package/dist/cjs/api/resources/pods/client/Client.d.ts +27 -27
  32. package/dist/cjs/api/resources/pods/client/Client.js +44 -43
  33. package/dist/cjs/api/resources/pods/resources/domains/client/Client.d.ts +15 -15
  34. package/dist/cjs/api/resources/pods/resources/domains/client/Client.js +41 -43
  35. package/dist/cjs/api/resources/pods/resources/drafts/client/Client.d.ts +12 -12
  36. package/dist/cjs/api/resources/pods/resources/drafts/client/Client.js +30 -35
  37. package/dist/cjs/api/resources/pods/resources/inboxes/client/Client.d.ts +19 -19
  38. package/dist/cjs/api/resources/pods/resources/inboxes/client/Client.js +53 -52
  39. package/dist/cjs/api/resources/pods/resources/threads/client/Client.d.ts +13 -13
  40. package/dist/cjs/api/resources/pods/resources/threads/client/Client.js +39 -41
  41. package/dist/cjs/api/resources/threads/client/Client.d.ts +11 -11
  42. package/dist/cjs/api/resources/threads/client/Client.js +32 -34
  43. package/dist/cjs/api/resources/webhooks/client/Client.d.ts +15 -15
  44. package/dist/cjs/api/resources/webhooks/client/Client.js +40 -39
  45. package/dist/cjs/api/resources/webhooks/types/CreateWebhookRequest.d.ts +1 -1
  46. package/dist/cjs/api/resources/webhooks/types/Webhook.d.ts +1 -1
  47. package/dist/cjs/api/resources/webhooks/types/index.d.ts +0 -2
  48. package/dist/cjs/api/resources/webhooks/types/index.js +0 -2
  49. package/dist/cjs/api/resources/websockets/client/Client.d.ts +6 -6
  50. package/dist/cjs/api/resources/websockets/client/Client.js +8 -19
  51. package/dist/cjs/api/resources/websockets/client/Socket.d.ts +1 -1
  52. package/dist/cjs/api/resources/websockets/types/Subscribe.d.ts +5 -1
  53. package/dist/cjs/api/resources/websockets/types/Subscribed.d.ts +5 -1
  54. package/dist/cjs/auth/BearerAuthProvider.d.ts +14 -0
  55. package/dist/cjs/auth/BearerAuthProvider.js +72 -0
  56. package/dist/cjs/auth/index.d.ts +1 -0
  57. package/dist/cjs/auth/index.js +5 -0
  58. package/dist/cjs/core/auth/AuthProvider.d.ts +4 -1
  59. package/dist/cjs/core/auth/BearerToken.d.ts +3 -1
  60. package/dist/cjs/core/auth/BearerToken.js +7 -6
  61. package/dist/cjs/core/auth/NoOpAuthProvider.d.ts +5 -0
  62. package/dist/cjs/core/auth/NoOpAuthProvider.js +9 -0
  63. package/dist/cjs/core/auth/index.d.ts +1 -0
  64. package/dist/cjs/core/auth/index.js +3 -1
  65. package/dist/cjs/core/exports.d.ts +1 -0
  66. package/dist/cjs/core/exports.js +1 -0
  67. package/dist/cjs/core/fetcher/Fetcher.d.ts +4 -1
  68. package/dist/cjs/core/fetcher/Fetcher.js +202 -9
  69. package/dist/cjs/core/fetcher/getRequestBody.d.ts +1 -1
  70. package/dist/cjs/core/fetcher/getRequestBody.js +4 -0
  71. package/dist/cjs/core/fetcher/makeRequest.d.ts +1 -1
  72. package/dist/cjs/core/fetcher/makeRequest.js +0 -2
  73. package/dist/cjs/core/fetcher/requestWithRetries.js +0 -9
  74. package/dist/cjs/core/fetcher/signals.d.ts +0 -6
  75. package/dist/cjs/core/fetcher/signals.js +0 -12
  76. package/dist/cjs/core/headers.js +6 -4
  77. package/dist/cjs/core/index.d.ts +1 -0
  78. package/dist/cjs/core/index.js +2 -1
  79. package/dist/cjs/core/logging/exports.d.ts +18 -0
  80. package/dist/cjs/core/logging/exports.js +45 -0
  81. package/dist/cjs/core/logging/index.d.ts +1 -0
  82. package/dist/cjs/core/logging/index.js +17 -0
  83. package/dist/cjs/core/logging/logger.d.ts +126 -0
  84. package/dist/cjs/core/logging/logger.js +144 -0
  85. package/dist/cjs/core/schemas/Schema.d.ts +1 -0
  86. package/dist/cjs/core/schemas/Schema.js +1 -0
  87. package/dist/cjs/core/schemas/builders/primitives/index.d.ts +1 -0
  88. package/dist/cjs/core/schemas/builders/primitives/index.js +3 -1
  89. package/dist/cjs/core/schemas/builders/primitives/never.d.ts +2 -0
  90. package/dist/cjs/core/schemas/builders/primitives/never.js +14 -0
  91. package/dist/cjs/core/url/join.js +0 -1
  92. package/dist/cjs/serialization/resources/events/types/DomainVerifiedEvent.d.ts +14 -0
  93. package/dist/cjs/serialization/resources/events/types/DomainVerifiedEvent.js +46 -0
  94. package/dist/cjs/serialization/resources/{webhooks → events}/types/EventType.d.ts +2 -2
  95. package/dist/cjs/serialization/resources/{webhooks → events}/types/EventType.js +1 -0
  96. package/dist/cjs/serialization/resources/{webhooks → events}/types/EventTypes.d.ts +1 -1
  97. package/dist/cjs/serialization/resources/events/types/index.d.ts +3 -0
  98. package/dist/cjs/serialization/resources/events/types/index.js +3 -0
  99. package/dist/cjs/serialization/resources/webhooks/types/CreateWebhookRequest.d.ts +1 -1
  100. package/dist/cjs/serialization/resources/webhooks/types/CreateWebhookRequest.js +1 -1
  101. package/dist/cjs/serialization/resources/webhooks/types/Webhook.d.ts +1 -1
  102. package/dist/cjs/serialization/resources/webhooks/types/Webhook.js +1 -1
  103. package/dist/cjs/serialization/resources/webhooks/types/index.d.ts +0 -2
  104. package/dist/cjs/serialization/resources/webhooks/types/index.js +0 -2
  105. package/dist/cjs/serialization/resources/websockets/client/socket/WebsocketsSocketResponse.d.ts +3 -2
  106. package/dist/cjs/serialization/resources/websockets/client/socket/WebsocketsSocketResponse.js +2 -0
  107. package/dist/cjs/serialization/resources/websockets/types/Subscribe.d.ts +4 -1
  108. package/dist/cjs/serialization/resources/websockets/types/Subscribe.js +4 -1
  109. package/dist/cjs/serialization/resources/websockets/types/Subscribed.d.ts +4 -1
  110. package/dist/cjs/serialization/resources/websockets/types/Subscribed.js +4 -1
  111. package/dist/cjs/version.d.ts +1 -1
  112. package/dist/cjs/version.js +1 -1
  113. package/dist/esm/BaseClient.d.mts +14 -1
  114. package/dist/esm/BaseClient.mjs +24 -1
  115. package/dist/esm/Client.d.mts +30 -29
  116. package/dist/esm/Client.mjs +21 -29
  117. package/dist/esm/api/resources/apiKeys/client/Client.d.mts +12 -12
  118. package/dist/esm/api/resources/apiKeys/client/Client.mjs +28 -30
  119. package/dist/esm/api/resources/domains/client/Client.d.mts +19 -19
  120. package/dist/esm/api/resources/domains/client/Client.mjs +59 -52
  121. package/dist/esm/api/resources/drafts/client/Client.d.mts +10 -10
  122. package/dist/esm/api/resources/drafts/client/Client.mjs +22 -27
  123. package/dist/esm/api/resources/events/types/DomainVerifiedEvent.d.mts +7 -0
  124. package/dist/esm/api/resources/{webhooks → events}/types/EventType.d.mts +1 -0
  125. package/dist/esm/api/resources/{webhooks → events}/types/EventType.mjs +1 -0
  126. package/dist/esm/api/resources/events/types/EventTypes.d.mts +5 -0
  127. package/dist/esm/api/resources/events/types/EventTypes.mjs +2 -0
  128. package/dist/esm/api/resources/events/types/index.d.mts +3 -0
  129. package/dist/esm/api/resources/events/types/index.mjs +3 -0
  130. package/dist/esm/api/resources/inboxes/client/Client.d.mts +30 -30
  131. package/dist/esm/api/resources/inboxes/client/Client.mjs +58 -54
  132. package/dist/esm/api/resources/inboxes/resources/drafts/client/Client.d.mts +27 -27
  133. package/dist/esm/api/resources/inboxes/resources/drafts/client/Client.mjs +76 -69
  134. package/dist/esm/api/resources/inboxes/resources/messages/client/Client.d.mts +25 -25
  135. package/dist/esm/api/resources/inboxes/resources/messages/client/Client.mjs +82 -72
  136. package/dist/esm/api/resources/inboxes/resources/metrics/client/Client.d.mts +8 -8
  137. package/dist/esm/api/resources/inboxes/resources/metrics/client/Client.mjs +16 -24
  138. package/dist/esm/api/resources/inboxes/resources/threads/client/Client.d.mts +17 -17
  139. package/dist/esm/api/resources/inboxes/resources/threads/client/Client.mjs +50 -49
  140. package/dist/esm/api/resources/metrics/client/Client.d.mts +7 -7
  141. package/dist/esm/api/resources/metrics/client/Client.mjs +11 -19
  142. package/dist/esm/api/resources/pods/client/Client.d.mts +27 -27
  143. package/dist/esm/api/resources/pods/client/Client.mjs +47 -46
  144. package/dist/esm/api/resources/pods/resources/domains/client/Client.d.mts +15 -15
  145. package/dist/esm/api/resources/pods/resources/domains/client/Client.mjs +40 -42
  146. package/dist/esm/api/resources/pods/resources/drafts/client/Client.d.mts +12 -12
  147. package/dist/esm/api/resources/pods/resources/drafts/client/Client.mjs +29 -34
  148. package/dist/esm/api/resources/pods/resources/inboxes/client/Client.d.mts +19 -19
  149. package/dist/esm/api/resources/pods/resources/inboxes/client/Client.mjs +52 -51
  150. package/dist/esm/api/resources/pods/resources/threads/client/Client.d.mts +13 -13
  151. package/dist/esm/api/resources/pods/resources/threads/client/Client.mjs +38 -40
  152. package/dist/esm/api/resources/threads/client/Client.d.mts +11 -11
  153. package/dist/esm/api/resources/threads/client/Client.mjs +31 -33
  154. package/dist/esm/api/resources/webhooks/client/Client.d.mts +15 -15
  155. package/dist/esm/api/resources/webhooks/client/Client.mjs +39 -38
  156. package/dist/esm/api/resources/webhooks/types/CreateWebhookRequest.d.mts +1 -1
  157. package/dist/esm/api/resources/webhooks/types/Webhook.d.mts +1 -1
  158. package/dist/esm/api/resources/webhooks/types/index.d.mts +0 -2
  159. package/dist/esm/api/resources/webhooks/types/index.mjs +0 -2
  160. package/dist/esm/api/resources/websockets/client/Client.d.mts +6 -6
  161. package/dist/esm/api/resources/websockets/client/Client.mjs +7 -18
  162. package/dist/esm/api/resources/websockets/client/Socket.d.mts +1 -1
  163. package/dist/esm/api/resources/websockets/types/Subscribe.d.mts +5 -1
  164. package/dist/esm/api/resources/websockets/types/Subscribed.d.mts +5 -1
  165. package/dist/esm/auth/BearerAuthProvider.d.mts +14 -0
  166. package/dist/esm/auth/BearerAuthProvider.mjs +35 -0
  167. package/dist/esm/auth/index.d.mts +1 -0
  168. package/dist/esm/auth/index.mjs +1 -0
  169. package/dist/esm/core/auth/AuthProvider.d.mts +4 -1
  170. package/dist/esm/core/auth/BearerToken.d.mts +3 -1
  171. package/dist/esm/core/auth/BearerToken.mjs +7 -6
  172. package/dist/esm/core/auth/NoOpAuthProvider.d.mts +5 -0
  173. package/dist/esm/core/auth/NoOpAuthProvider.mjs +5 -0
  174. package/dist/esm/core/auth/index.d.mts +1 -0
  175. package/dist/esm/core/auth/index.mjs +1 -0
  176. package/dist/esm/core/exports.d.mts +1 -0
  177. package/dist/esm/core/exports.mjs +1 -0
  178. package/dist/esm/core/fetcher/Fetcher.d.mts +4 -1
  179. package/dist/esm/core/fetcher/Fetcher.mjs +202 -9
  180. package/dist/esm/core/fetcher/getRequestBody.d.mts +1 -1
  181. package/dist/esm/core/fetcher/getRequestBody.mjs +4 -0
  182. package/dist/esm/core/fetcher/makeRequest.d.mts +1 -1
  183. package/dist/esm/core/fetcher/makeRequest.mjs +0 -2
  184. package/dist/esm/core/fetcher/requestWithRetries.mjs +0 -9
  185. package/dist/esm/core/fetcher/signals.d.mts +0 -6
  186. package/dist/esm/core/fetcher/signals.mjs +0 -12
  187. package/dist/esm/core/headers.mjs +6 -4
  188. package/dist/esm/core/index.d.mts +1 -0
  189. package/dist/esm/core/index.mjs +1 -0
  190. package/dist/esm/core/logging/exports.d.mts +18 -0
  191. package/dist/esm/core/logging/exports.mjs +9 -0
  192. package/dist/esm/core/logging/index.d.mts +1 -0
  193. package/dist/esm/core/logging/index.mjs +1 -0
  194. package/dist/esm/core/logging/logger.d.mts +126 -0
  195. package/dist/esm/core/logging/logger.mjs +138 -0
  196. package/dist/esm/core/schemas/Schema.d.mts +1 -0
  197. package/dist/esm/core/schemas/Schema.mjs +1 -0
  198. package/dist/esm/core/schemas/builders/primitives/index.d.mts +1 -0
  199. package/dist/esm/core/schemas/builders/primitives/index.mjs +1 -0
  200. package/dist/esm/core/schemas/builders/primitives/never.d.mts +2 -0
  201. package/dist/esm/core/schemas/builders/primitives/never.mjs +11 -0
  202. package/dist/esm/core/url/join.mjs +0 -1
  203. package/dist/esm/serialization/resources/events/types/DomainVerifiedEvent.d.mts +14 -0
  204. package/dist/esm/serialization/resources/events/types/DomainVerifiedEvent.mjs +10 -0
  205. package/dist/esm/serialization/resources/{webhooks → events}/types/EventType.d.mts +2 -2
  206. package/dist/esm/serialization/resources/{webhooks → events}/types/EventType.mjs +1 -0
  207. package/dist/esm/serialization/resources/{webhooks → events}/types/EventTypes.d.mts +1 -1
  208. package/dist/esm/serialization/resources/events/types/index.d.mts +3 -0
  209. package/dist/esm/serialization/resources/events/types/index.mjs +3 -0
  210. package/dist/esm/serialization/resources/webhooks/types/CreateWebhookRequest.d.mts +1 -1
  211. package/dist/esm/serialization/resources/webhooks/types/CreateWebhookRequest.mjs +1 -1
  212. package/dist/esm/serialization/resources/webhooks/types/Webhook.d.mts +1 -1
  213. package/dist/esm/serialization/resources/webhooks/types/Webhook.mjs +1 -1
  214. package/dist/esm/serialization/resources/webhooks/types/index.d.mts +0 -2
  215. package/dist/esm/serialization/resources/webhooks/types/index.mjs +0 -2
  216. package/dist/esm/serialization/resources/websockets/client/socket/WebsocketsSocketResponse.d.mts +3 -2
  217. package/dist/esm/serialization/resources/websockets/client/socket/WebsocketsSocketResponse.mjs +2 -0
  218. package/dist/esm/serialization/resources/websockets/types/Subscribe.d.mts +4 -1
  219. package/dist/esm/serialization/resources/websockets/types/Subscribe.mjs +4 -1
  220. package/dist/esm/serialization/resources/websockets/types/Subscribed.d.mts +4 -1
  221. package/dist/esm/serialization/resources/websockets/types/Subscribed.mjs +4 -1
  222. package/dist/esm/version.d.mts +1 -1
  223. package/dist/esm/version.mjs +1 -1
  224. package/dist/llms-full.txt +620 -54
  225. package/dist/llms.txt +6 -1
  226. package/package.json +1 -1
  227. package/reference.md +170 -170
  228. package/dist/cjs/api/resources/webhooks/types/EventTypes.d.ts +0 -5
  229. package/dist/esm/api/resources/webhooks/types/EventTypes.d.mts +0 -5
  230. /package/dist/cjs/api/resources/{webhooks/types/EventTypes.js → events/types/DomainVerifiedEvent.js} +0 -0
  231. /package/dist/cjs/serialization/resources/{webhooks → events}/types/EventTypes.js +0 -0
  232. /package/dist/esm/api/resources/{webhooks/types/EventTypes.mjs → events/types/DomainVerifiedEvent.mjs} +0 -0
  233. /package/dist/esm/serialization/resources/{webhooks → events}/types/EventTypes.mjs +0 -0
@@ -43,7 +43,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
43
43
  });
44
44
  };
45
45
  Object.defineProperty(exports, "__esModule", { value: true });
46
- exports.Threads = void 0;
46
+ exports.ThreadsClient = void 0;
47
+ const BaseClient_js_1 = require("../../../../../../BaseClient.js");
47
48
  const headers_js_1 = require("../../../../../../core/headers.js");
48
49
  const core = __importStar(require("../../../../../../core/index.js"));
49
50
  const json_js_1 = require("../../../../../../core/json.js");
@@ -51,26 +52,26 @@ const environments = __importStar(require("../../../../../../environments.js"));
51
52
  const errors = __importStar(require("../../../../../../errors/index.js"));
52
53
  const serializers = __importStar(require("../../../../../../serialization/index.js"));
53
54
  const AgentMail = __importStar(require("../../../../../index.js"));
54
- class Threads {
55
- constructor(_options = {}) {
56
- this._options = _options;
55
+ class ThreadsClient {
56
+ constructor(options = {}) {
57
+ this._options = (0, BaseClient_js_1.normalizeClientOptionsWithAuth)(options);
57
58
  }
58
59
  /**
59
- * @param {AgentMail.inboxes.InboxId} inboxId
60
+ * @param {AgentMail.inboxes.InboxId} inbox_id
60
61
  * @param {AgentMail.inboxes.ListThreadsRequest} request
61
- * @param {Threads.RequestOptions} requestOptions - Request-specific configuration.
62
+ * @param {ThreadsClient.RequestOptions} requestOptions - Request-specific configuration.
62
63
  *
63
64
  * @throws {@link AgentMail.NotFoundError}
64
65
  *
65
66
  * @example
66
67
  * await client.inboxes.threads.list("inbox_id")
67
68
  */
68
- list(inboxId, request = {}, requestOptions) {
69
- return core.HttpResponsePromise.fromPromise(this.__list(inboxId, request, requestOptions));
69
+ list(inbox_id, request = {}, requestOptions) {
70
+ return core.HttpResponsePromise.fromPromise(this.__list(inbox_id, request, requestOptions));
70
71
  }
71
- __list(inboxId_1) {
72
- return __awaiter(this, arguments, void 0, function* (inboxId, request = {}, requestOptions) {
73
- var _a, _b, _c, _d, _e, _f, _g, _h;
72
+ __list(inbox_id_1) {
73
+ return __awaiter(this, arguments, void 0, function* (inbox_id, request = {}, requestOptions) {
74
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
74
75
  const { limit, pageToken, labels, before, after, ascending } = request;
75
76
  const _queryParams = {};
76
77
  if (limit != null) {
@@ -96,15 +97,18 @@ class Threads {
96
97
  if (ascending != null) {
97
98
  _queryParams.ascending = ascending.toString();
98
99
  }
99
- const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
100
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
101
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
100
102
  const _response = yield core.fetcher({
101
- url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.AgentMailEnvironment.Production).http, `/v0/inboxes/${core.url.encodePathParam(serializers.inboxes.InboxId.jsonOrThrow(inboxId, { omitUndefined: true }))}/threads`),
103
+ url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.AgentMailEnvironment.Production).http, `/v0/inboxes/${core.url.encodePathParam(serializers.inboxes.InboxId.jsonOrThrow(inbox_id, { omitUndefined: true }))}/threads`),
102
104
  method: "GET",
103
105
  headers: _headers,
104
106
  queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
105
107
  timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
106
108
  maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
107
109
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
110
+ fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
111
+ logging: this._options.logging,
108
112
  });
109
113
  if (_response.ok) {
110
114
  return {
@@ -154,30 +158,33 @@ class Threads {
154
158
  });
155
159
  }
156
160
  /**
157
- * @param {AgentMail.inboxes.InboxId} inboxId
158
- * @param {AgentMail.ThreadId} threadId
159
- * @param {Threads.RequestOptions} requestOptions - Request-specific configuration.
161
+ * @param {AgentMail.inboxes.InboxId} inbox_id
162
+ * @param {AgentMail.ThreadId} thread_id
163
+ * @param {ThreadsClient.RequestOptions} requestOptions - Request-specific configuration.
160
164
  *
161
165
  * @throws {@link AgentMail.NotFoundError}
162
166
  *
163
167
  * @example
164
168
  * await client.inboxes.threads.get("inbox_id", "thread_id")
165
169
  */
166
- get(inboxId, threadId, requestOptions) {
167
- return core.HttpResponsePromise.fromPromise(this.__get(inboxId, threadId, requestOptions));
170
+ get(inbox_id, thread_id, requestOptions) {
171
+ return core.HttpResponsePromise.fromPromise(this.__get(inbox_id, thread_id, requestOptions));
168
172
  }
169
- __get(inboxId, threadId, requestOptions) {
173
+ __get(inbox_id, thread_id, requestOptions) {
170
174
  return __awaiter(this, void 0, void 0, function* () {
171
- var _a, _b, _c, _d, _e, _f, _g, _h;
172
- const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
175
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
176
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
177
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
173
178
  const _response = yield core.fetcher({
174
- url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.AgentMailEnvironment.Production).http, `/v0/inboxes/${core.url.encodePathParam(serializers.inboxes.InboxId.jsonOrThrow(inboxId, { omitUndefined: true }))}/threads/${core.url.encodePathParam(serializers.ThreadId.jsonOrThrow(threadId, { omitUndefined: true }))}`),
179
+ url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.AgentMailEnvironment.Production).http, `/v0/inboxes/${core.url.encodePathParam(serializers.inboxes.InboxId.jsonOrThrow(inbox_id, { omitUndefined: true }))}/threads/${core.url.encodePathParam(serializers.ThreadId.jsonOrThrow(thread_id, { omitUndefined: true }))}`),
175
180
  method: "GET",
176
181
  headers: _headers,
177
182
  queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
178
183
  timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
179
184
  maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
180
185
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
186
+ fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
187
+ logging: this._options.logging,
181
188
  });
182
189
  if (_response.ok) {
183
190
  return {
@@ -229,15 +236,16 @@ class Threads {
229
236
  /**
230
237
  * @throws {@link AgentMail.NotFoundError}
231
238
  */
232
- getAttachment(inboxId, threadId, attachmentId, requestOptions) {
233
- return core.HttpResponsePromise.fromPromise(this.__getAttachment(inboxId, threadId, attachmentId, requestOptions));
239
+ getAttachment(inbox_id, thread_id, attachment_id, requestOptions) {
240
+ return core.HttpResponsePromise.fromPromise(this.__getAttachment(inbox_id, thread_id, attachment_id, requestOptions));
234
241
  }
235
- __getAttachment(inboxId, threadId, attachmentId, requestOptions) {
242
+ __getAttachment(inbox_id, thread_id, attachment_id, requestOptions) {
236
243
  return __awaiter(this, void 0, void 0, function* () {
237
- var _a, _b, _c, _d, _e, _f, _g, _h;
238
- const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
244
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
245
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
246
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
239
247
  const _response = yield core.fetcher({
240
- url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.AgentMailEnvironment.Production).http, `/v0/inboxes/${core.url.encodePathParam(serializers.inboxes.InboxId.jsonOrThrow(inboxId, { omitUndefined: true }))}/threads/${core.url.encodePathParam(serializers.ThreadId.jsonOrThrow(threadId, { omitUndefined: true }))}/attachments/${core.url.encodePathParam(serializers.AttachmentId.jsonOrThrow(attachmentId, { omitUndefined: true }))}`),
248
+ url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.AgentMailEnvironment.Production).http, `/v0/inboxes/${core.url.encodePathParam(serializers.inboxes.InboxId.jsonOrThrow(inbox_id, { omitUndefined: true }))}/threads/${core.url.encodePathParam(serializers.ThreadId.jsonOrThrow(thread_id, { omitUndefined: true }))}/attachments/${core.url.encodePathParam(serializers.AttachmentId.jsonOrThrow(attachment_id, { omitUndefined: true }))}`),
241
249
  method: "GET",
242
250
  headers: _headers,
243
251
  queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
@@ -245,6 +253,8 @@ class Threads {
245
253
  timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
246
254
  maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
247
255
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
256
+ fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
257
+ logging: this._options.logging,
248
258
  });
249
259
  if (_response.ok) {
250
260
  return { data: _response.body, rawResponse: _response.rawResponse };
@@ -285,30 +295,33 @@ class Threads {
285
295
  });
286
296
  }
287
297
  /**
288
- * @param {AgentMail.inboxes.InboxId} inboxId
289
- * @param {AgentMail.ThreadId} threadId
290
- * @param {Threads.RequestOptions} requestOptions - Request-specific configuration.
298
+ * @param {AgentMail.inboxes.InboxId} inbox_id
299
+ * @param {AgentMail.ThreadId} thread_id
300
+ * @param {ThreadsClient.RequestOptions} requestOptions - Request-specific configuration.
291
301
  *
292
302
  * @throws {@link AgentMail.NotFoundError}
293
303
  *
294
304
  * @example
295
305
  * await client.inboxes.threads.delete("inbox_id", "thread_id")
296
306
  */
297
- delete(inboxId, threadId, requestOptions) {
298
- return core.HttpResponsePromise.fromPromise(this.__delete(inboxId, threadId, requestOptions));
307
+ delete(inbox_id, thread_id, requestOptions) {
308
+ return core.HttpResponsePromise.fromPromise(this.__delete(inbox_id, thread_id, requestOptions));
299
309
  }
300
- __delete(inboxId, threadId, requestOptions) {
310
+ __delete(inbox_id, thread_id, requestOptions) {
301
311
  return __awaiter(this, void 0, void 0, function* () {
302
- var _a, _b, _c, _d, _e, _f, _g, _h;
303
- const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
312
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
313
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
314
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
304
315
  const _response = yield core.fetcher({
305
- url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.AgentMailEnvironment.Production).http, `/v0/inboxes/${core.url.encodePathParam(serializers.inboxes.InboxId.jsonOrThrow(inboxId, { omitUndefined: true }))}/threads/${core.url.encodePathParam(serializers.ThreadId.jsonOrThrow(threadId, { omitUndefined: true }))}`),
316
+ url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.AgentMailEnvironment.Production).http, `/v0/inboxes/${core.url.encodePathParam(serializers.inboxes.InboxId.jsonOrThrow(inbox_id, { omitUndefined: true }))}/threads/${core.url.encodePathParam(serializers.ThreadId.jsonOrThrow(thread_id, { omitUndefined: true }))}`),
306
317
  method: "DELETE",
307
318
  headers: _headers,
308
319
  queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
309
320
  timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
310
321
  maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
311
322
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
323
+ fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
324
+ logging: this._options.logging,
312
325
  });
313
326
  if (_response.ok) {
314
327
  return { data: undefined, rawResponse: _response.rawResponse };
@@ -348,17 +361,5 @@ class Threads {
348
361
  }
349
362
  });
350
363
  }
351
- _getAuthorizationHeader() {
352
- return __awaiter(this, void 0, void 0, function* () {
353
- var _a;
354
- 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;
355
- if (bearer == null) {
356
- throw new errors.AgentMailError({
357
- message: "Please specify a bearer by either passing it in to the constructor or initializing a AGENTMAIL_API_KEY environment variable",
358
- });
359
- }
360
- return `Bearer ${bearer}`;
361
- });
362
- }
363
364
  }
364
- exports.Threads = Threads;
365
+ exports.ThreadsClient = ThreadsClient;
@@ -1,18 +1,19 @@
1
1
  import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js";
2
+ import { type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.js";
2
3
  import * as core from "../../../../core/index.js";
3
4
  import * as AgentMail from "../../../index.js";
4
- export declare namespace Metrics {
5
+ export declare namespace MetricsClient {
5
6
  interface Options extends BaseClientOptions {
6
7
  }
7
8
  interface RequestOptions extends BaseRequestOptions {
8
9
  }
9
10
  }
10
- export declare class Metrics {
11
- protected readonly _options: Metrics.Options;
12
- constructor(_options?: Metrics.Options);
11
+ export declare class MetricsClient {
12
+ protected readonly _options: NormalizedClientOptionsWithAuth<MetricsClient.Options>;
13
+ constructor(options?: MetricsClient.Options);
13
14
  /**
14
15
  * @param {AgentMail.ListMetricsRequest} request
15
- * @param {Metrics.RequestOptions} requestOptions - Request-specific configuration.
16
+ * @param {MetricsClient.RequestOptions} requestOptions - Request-specific configuration.
16
17
  *
17
18
  * @throws {@link AgentMail.NotFoundError}
18
19
  *
@@ -22,7 +23,6 @@ export declare class Metrics {
22
23
  * endTimestamp: new Date("2024-01-15T09:30:00.000Z")
23
24
  * })
24
25
  */
25
- list(request: AgentMail.ListMetricsRequest, requestOptions?: Metrics.RequestOptions): core.HttpResponsePromise<AgentMail.ListMetricsResponse>;
26
+ list(request: AgentMail.ListMetricsRequest, requestOptions?: MetricsClient.RequestOptions): core.HttpResponsePromise<AgentMail.ListMetricsResponse>;
26
27
  private __list;
27
- protected _getAuthorizationHeader(): Promise<string>;
28
28
  }
@@ -43,7 +43,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
43
43
  });
44
44
  };
45
45
  Object.defineProperty(exports, "__esModule", { value: true });
46
- exports.Metrics = void 0;
46
+ exports.MetricsClient = void 0;
47
+ const BaseClient_js_1 = require("../../../../BaseClient.js");
47
48
  const headers_js_1 = require("../../../../core/headers.js");
48
49
  const core = __importStar(require("../../../../core/index.js"));
49
50
  const json_js_1 = require("../../../../core/json.js");
@@ -51,13 +52,13 @@ const environments = __importStar(require("../../../../environments.js"));
51
52
  const errors = __importStar(require("../../../../errors/index.js"));
52
53
  const serializers = __importStar(require("../../../../serialization/index.js"));
53
54
  const AgentMail = __importStar(require("../../../index.js"));
54
- class Metrics {
55
- constructor(_options = {}) {
56
- this._options = _options;
55
+ class MetricsClient {
56
+ constructor(options = {}) {
57
+ this._options = (0, BaseClient_js_1.normalizeClientOptionsWithAuth)(options);
57
58
  }
58
59
  /**
59
60
  * @param {AgentMail.ListMetricsRequest} request
60
- * @param {Metrics.RequestOptions} requestOptions - Request-specific configuration.
61
+ * @param {MetricsClient.RequestOptions} requestOptions - Request-specific configuration.
61
62
  *
62
63
  * @throws {@link AgentMail.NotFoundError}
63
64
  *
@@ -72,7 +73,7 @@ class Metrics {
72
73
  }
73
74
  __list(request, requestOptions) {
74
75
  return __awaiter(this, void 0, void 0, function* () {
75
- var _a, _b, _c, _d, _e, _f, _g, _h;
76
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
76
77
  const { eventTypes, startTimestamp, endTimestamp } = request;
77
78
  const _queryParams = {};
78
79
  if (eventTypes != null) {
@@ -85,7 +86,8 @@ class Metrics {
85
86
  }
86
87
  _queryParams.start_timestamp = startTimestamp.toISOString();
87
88
  _queryParams.end_timestamp = endTimestamp.toISOString();
88
- const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
89
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
90
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
89
91
  const _response = yield core.fetcher({
90
92
  url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.AgentMailEnvironment.Production).http, "/v0/metrics"),
91
93
  method: "GET",
@@ -94,6 +96,8 @@ class Metrics {
94
96
  timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
95
97
  maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
96
98
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
99
+ fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
100
+ logging: this._options.logging,
97
101
  });
98
102
  if (_response.ok) {
99
103
  return {
@@ -142,17 +146,5 @@ class Metrics {
142
146
  }
143
147
  });
144
148
  }
145
- _getAuthorizationHeader() {
146
- return __awaiter(this, void 0, void 0, function* () {
147
- var _a;
148
- 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;
149
- if (bearer == null) {
150
- throw new errors.AgentMailError({
151
- message: "Please specify a bearer by either passing it in to the constructor or initializing a AGENTMAIL_API_KEY environment variable",
152
- });
153
- }
154
- return `Bearer ${bearer}`;
155
- });
156
- }
157
149
  }
158
- exports.Metrics = Metrics;
150
+ exports.MetricsClient = MetricsClient;
@@ -1,68 +1,68 @@
1
1
  import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js";
2
+ import { type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.js";
2
3
  import * as core from "../../../../core/index.js";
3
4
  import * as AgentMail from "../../../index.js";
4
- import { Domains } from "../resources/domains/client/Client.js";
5
- import { Drafts } from "../resources/drafts/client/Client.js";
6
- import { Inboxes } from "../resources/inboxes/client/Client.js";
7
- import { Threads } from "../resources/threads/client/Client.js";
8
- export declare namespace Pods {
5
+ import { DomainsClient } from "../resources/domains/client/Client.js";
6
+ import { DraftsClient } from "../resources/drafts/client/Client.js";
7
+ import { InboxesClient } from "../resources/inboxes/client/Client.js";
8
+ import { ThreadsClient } from "../resources/threads/client/Client.js";
9
+ export declare namespace PodsClient {
9
10
  interface Options extends BaseClientOptions {
10
11
  }
11
12
  interface RequestOptions extends BaseRequestOptions {
12
13
  }
13
14
  }
14
- export declare class Pods {
15
- protected readonly _options: Pods.Options;
16
- protected _inboxes: Inboxes | undefined;
17
- protected _threads: Threads | undefined;
18
- protected _drafts: Drafts | undefined;
19
- protected _domains: Domains | undefined;
20
- constructor(_options?: Pods.Options);
21
- get inboxes(): Inboxes;
22
- get threads(): Threads;
23
- get drafts(): Drafts;
24
- get domains(): Domains;
15
+ export declare class PodsClient {
16
+ protected readonly _options: NormalizedClientOptionsWithAuth<PodsClient.Options>;
17
+ protected _inboxes: InboxesClient | undefined;
18
+ protected _threads: ThreadsClient | undefined;
19
+ protected _drafts: DraftsClient | undefined;
20
+ protected _domains: DomainsClient | undefined;
21
+ constructor(options?: PodsClient.Options);
22
+ get inboxes(): InboxesClient;
23
+ get threads(): ThreadsClient;
24
+ get drafts(): DraftsClient;
25
+ get domains(): DomainsClient;
25
26
  /**
26
27
  * @param {AgentMail.pods.ListPodsRequest} request
27
- * @param {Pods.RequestOptions} requestOptions - Request-specific configuration.
28
+ * @param {PodsClient.RequestOptions} requestOptions - Request-specific configuration.
28
29
  *
29
30
  * @example
30
31
  * await client.pods.list()
31
32
  */
32
- list(request?: AgentMail.pods.ListPodsRequest, requestOptions?: Pods.RequestOptions): core.HttpResponsePromise<AgentMail.pods.ListPodsResponse>;
33
+ list(request?: AgentMail.pods.ListPodsRequest, requestOptions?: PodsClient.RequestOptions): core.HttpResponsePromise<AgentMail.pods.ListPodsResponse>;
33
34
  private __list;
34
35
  /**
35
- * @param {AgentMail.pods.PodId} podId
36
- * @param {Pods.RequestOptions} requestOptions - Request-specific configuration.
36
+ * @param {AgentMail.pods.PodId} pod_id
37
+ * @param {PodsClient.RequestOptions} requestOptions - Request-specific configuration.
37
38
  *
38
39
  * @throws {@link AgentMail.NotFoundError}
39
40
  *
40
41
  * @example
41
42
  * await client.pods.get("pod_id")
42
43
  */
43
- get(podId: AgentMail.pods.PodId, requestOptions?: Pods.RequestOptions): core.HttpResponsePromise<AgentMail.pods.Pod>;
44
+ get(pod_id: AgentMail.pods.PodId, requestOptions?: PodsClient.RequestOptions): core.HttpResponsePromise<AgentMail.pods.Pod>;
44
45
  private __get;
45
46
  /**
46
47
  * @param {AgentMail.pods.CreatePodRequest} request
47
- * @param {Pods.RequestOptions} requestOptions - Request-specific configuration.
48
+ * @param {PodsClient.RequestOptions} requestOptions - Request-specific configuration.
48
49
  *
49
50
  * @throws {@link AgentMail.ValidationError}
50
51
  *
51
52
  * @example
52
53
  * await client.pods.create({})
53
54
  */
54
- create(request: AgentMail.pods.CreatePodRequest, requestOptions?: Pods.RequestOptions): core.HttpResponsePromise<AgentMail.pods.Pod>;
55
+ create(request: AgentMail.pods.CreatePodRequest, requestOptions?: PodsClient.RequestOptions): core.HttpResponsePromise<AgentMail.pods.Pod>;
55
56
  private __create;
56
57
  /**
57
- * @param {AgentMail.pods.PodId} podId
58
- * @param {Pods.RequestOptions} requestOptions - Request-specific configuration.
58
+ * @param {AgentMail.pods.PodId} pod_id
59
+ * @param {PodsClient.RequestOptions} requestOptions - Request-specific configuration.
59
60
  *
60
61
  * @throws {@link AgentMail.NotFoundError}
61
62
  *
62
63
  * @example
63
64
  * await client.pods.delete("pod_id")
64
65
  */
65
- delete(podId: AgentMail.pods.PodId, requestOptions?: Pods.RequestOptions): core.HttpResponsePromise<void>;
66
+ delete(pod_id: AgentMail.pods.PodId, requestOptions?: PodsClient.RequestOptions): core.HttpResponsePromise<void>;
66
67
  private __delete;
67
- protected _getAuthorizationHeader(): Promise<string>;
68
68
  }
@@ -43,7 +43,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
43
43
  });
44
44
  };
45
45
  Object.defineProperty(exports, "__esModule", { value: true });
46
- exports.Pods = void 0;
46
+ exports.PodsClient = void 0;
47
+ const BaseClient_js_1 = require("../../../../BaseClient.js");
47
48
  const headers_js_1 = require("../../../../core/headers.js");
48
49
  const core = __importStar(require("../../../../core/index.js"));
49
50
  const environments = __importStar(require("../../../../environments.js"));
@@ -54,29 +55,29 @@ const Client_js_1 = require("../resources/domains/client/Client.js");
54
55
  const Client_js_2 = require("../resources/drafts/client/Client.js");
55
56
  const Client_js_3 = require("../resources/inboxes/client/Client.js");
56
57
  const Client_js_4 = require("../resources/threads/client/Client.js");
57
- class Pods {
58
- constructor(_options = {}) {
59
- this._options = _options;
58
+ class PodsClient {
59
+ constructor(options = {}) {
60
+ this._options = (0, BaseClient_js_1.normalizeClientOptionsWithAuth)(options);
60
61
  }
61
62
  get inboxes() {
62
63
  var _a;
63
- return ((_a = this._inboxes) !== null && _a !== void 0 ? _a : (this._inboxes = new Client_js_3.Inboxes(this._options)));
64
+ return ((_a = this._inboxes) !== null && _a !== void 0 ? _a : (this._inboxes = new Client_js_3.InboxesClient(this._options)));
64
65
  }
65
66
  get threads() {
66
67
  var _a;
67
- return ((_a = this._threads) !== null && _a !== void 0 ? _a : (this._threads = new Client_js_4.Threads(this._options)));
68
+ return ((_a = this._threads) !== null && _a !== void 0 ? _a : (this._threads = new Client_js_4.ThreadsClient(this._options)));
68
69
  }
69
70
  get drafts() {
70
71
  var _a;
71
- return ((_a = this._drafts) !== null && _a !== void 0 ? _a : (this._drafts = new Client_js_2.Drafts(this._options)));
72
+ return ((_a = this._drafts) !== null && _a !== void 0 ? _a : (this._drafts = new Client_js_2.DraftsClient(this._options)));
72
73
  }
73
74
  get domains() {
74
75
  var _a;
75
- return ((_a = this._domains) !== null && _a !== void 0 ? _a : (this._domains = new Client_js_1.Domains(this._options)));
76
+ return ((_a = this._domains) !== null && _a !== void 0 ? _a : (this._domains = new Client_js_1.DomainsClient(this._options)));
76
77
  }
77
78
  /**
78
79
  * @param {AgentMail.pods.ListPodsRequest} request
79
- * @param {Pods.RequestOptions} requestOptions - Request-specific configuration.
80
+ * @param {PodsClient.RequestOptions} requestOptions - Request-specific configuration.
80
81
  *
81
82
  * @example
82
83
  * await client.pods.list()
@@ -86,7 +87,7 @@ class Pods {
86
87
  }
87
88
  __list() {
88
89
  return __awaiter(this, arguments, void 0, function* (request = {}, requestOptions) {
89
- var _a, _b, _c, _d, _e, _f, _g, _h;
90
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
90
91
  const { limit, pageToken } = request;
91
92
  const _queryParams = {};
92
93
  if (limit != null) {
@@ -95,7 +96,8 @@ class Pods {
95
96
  if (pageToken != null) {
96
97
  _queryParams.page_token = pageToken;
97
98
  }
98
- const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
99
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
100
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
99
101
  const _response = yield core.fetcher({
100
102
  url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.AgentMailEnvironment.Production).http, "/v0/pods"),
101
103
  method: "GET",
@@ -104,6 +106,8 @@ class Pods {
104
106
  timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
105
107
  maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
106
108
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
109
+ fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
110
+ logging: this._options.logging,
107
111
  });
108
112
  if (_response.ok) {
109
113
  return {
@@ -142,29 +146,32 @@ class Pods {
142
146
  });
143
147
  }
144
148
  /**
145
- * @param {AgentMail.pods.PodId} podId
146
- * @param {Pods.RequestOptions} requestOptions - Request-specific configuration.
149
+ * @param {AgentMail.pods.PodId} pod_id
150
+ * @param {PodsClient.RequestOptions} requestOptions - Request-specific configuration.
147
151
  *
148
152
  * @throws {@link AgentMail.NotFoundError}
149
153
  *
150
154
  * @example
151
155
  * await client.pods.get("pod_id")
152
156
  */
153
- get(podId, requestOptions) {
154
- return core.HttpResponsePromise.fromPromise(this.__get(podId, requestOptions));
157
+ get(pod_id, requestOptions) {
158
+ return core.HttpResponsePromise.fromPromise(this.__get(pod_id, requestOptions));
155
159
  }
156
- __get(podId, requestOptions) {
160
+ __get(pod_id, requestOptions) {
157
161
  return __awaiter(this, void 0, void 0, function* () {
158
- var _a, _b, _c, _d, _e, _f, _g, _h;
159
- const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
162
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
163
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
164
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
160
165
  const _response = yield core.fetcher({
161
- url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.AgentMailEnvironment.Production).http, `/v0/pods/${core.url.encodePathParam(serializers.pods.PodId.jsonOrThrow(podId, { omitUndefined: true }))}`),
166
+ url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.AgentMailEnvironment.Production).http, `/v0/pods/${core.url.encodePathParam(serializers.pods.PodId.jsonOrThrow(pod_id, { omitUndefined: true }))}`),
162
167
  method: "GET",
163
168
  headers: _headers,
164
169
  queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
165
170
  timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
166
171
  maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
167
172
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
173
+ fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
174
+ logging: this._options.logging,
168
175
  });
169
176
  if (_response.ok) {
170
177
  return {
@@ -215,7 +222,7 @@ class Pods {
215
222
  }
216
223
  /**
217
224
  * @param {AgentMail.pods.CreatePodRequest} request
218
- * @param {Pods.RequestOptions} requestOptions - Request-specific configuration.
225
+ * @param {PodsClient.RequestOptions} requestOptions - Request-specific configuration.
219
226
  *
220
227
  * @throws {@link AgentMail.ValidationError}
221
228
  *
@@ -227,8 +234,9 @@ class Pods {
227
234
  }
228
235
  __create(request, requestOptions) {
229
236
  return __awaiter(this, void 0, void 0, function* () {
230
- var _a, _b, _c, _d, _e, _f, _g, _h;
231
- const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
237
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
238
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
239
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
232
240
  const _response = yield core.fetcher({
233
241
  url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.AgentMailEnvironment.Production).http, "/v0/pods"),
234
242
  method: "POST",
@@ -245,6 +253,8 @@ class Pods {
245
253
  timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
246
254
  maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
247
255
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
256
+ fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
257
+ logging: this._options.logging,
248
258
  });
249
259
  if (_response.ok) {
250
260
  return {
@@ -294,29 +304,32 @@ class Pods {
294
304
  });
295
305
  }
296
306
  /**
297
- * @param {AgentMail.pods.PodId} podId
298
- * @param {Pods.RequestOptions} requestOptions - Request-specific configuration.
307
+ * @param {AgentMail.pods.PodId} pod_id
308
+ * @param {PodsClient.RequestOptions} requestOptions - Request-specific configuration.
299
309
  *
300
310
  * @throws {@link AgentMail.NotFoundError}
301
311
  *
302
312
  * @example
303
313
  * await client.pods.delete("pod_id")
304
314
  */
305
- delete(podId, requestOptions) {
306
- return core.HttpResponsePromise.fromPromise(this.__delete(podId, requestOptions));
315
+ delete(pod_id, requestOptions) {
316
+ return core.HttpResponsePromise.fromPromise(this.__delete(pod_id, requestOptions));
307
317
  }
308
- __delete(podId, requestOptions) {
318
+ __delete(pod_id, requestOptions) {
309
319
  return __awaiter(this, void 0, void 0, function* () {
310
- var _a, _b, _c, _d, _e, _f, _g, _h;
311
- const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
320
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
321
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
322
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
312
323
  const _response = yield core.fetcher({
313
- url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.AgentMailEnvironment.Production).http, `/v0/pods/${core.url.encodePathParam(serializers.pods.PodId.jsonOrThrow(podId, { omitUndefined: true }))}`),
324
+ url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.AgentMailEnvironment.Production).http, `/v0/pods/${core.url.encodePathParam(serializers.pods.PodId.jsonOrThrow(pod_id, { omitUndefined: true }))}`),
314
325
  method: "DELETE",
315
326
  headers: _headers,
316
327
  queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
317
328
  timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
318
329
  maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
319
330
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
331
+ fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
332
+ logging: this._options.logging,
320
333
  });
321
334
  if (_response.ok) {
322
335
  return { data: undefined, rawResponse: _response.rawResponse };
@@ -356,17 +369,5 @@ class Pods {
356
369
  }
357
370
  });
358
371
  }
359
- _getAuthorizationHeader() {
360
- return __awaiter(this, void 0, void 0, function* () {
361
- var _a;
362
- 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;
363
- if (bearer == null) {
364
- throw new errors.AgentMailError({
365
- message: "Please specify a bearer by either passing it in to the constructor or initializing a AGENTMAIL_API_KEY environment variable",
366
- });
367
- }
368
- return `Bearer ${bearer}`;
369
- });
370
- }
371
372
  }
372
- exports.Pods = Pods;
373
+ exports.PodsClient = PodsClient;