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
package/README.md CHANGED
@@ -162,6 +162,69 @@ console.log(data);
162
162
  console.log(rawResponse.headers['X-My-Header']);
163
163
  ```
164
164
 
165
+ ### Logging
166
+
167
+ The SDK supports logging. You can configure the logger by passing in a `logging` object to the client options.
168
+
169
+ ```typescript
170
+ import { AgentMailClient, logging } from "agentmail";
171
+
172
+ const client = new AgentMailClient({
173
+ ...
174
+ logging: {
175
+ level: logging.LogLevel.Debug, // defaults to logging.LogLevel.Info
176
+ logger: new logging.ConsoleLogger(), // defaults to ConsoleLogger
177
+ silent: false, // defaults to true, set to false to enable logging
178
+ }
179
+ });
180
+ ```
181
+ The `logging` object can have the following properties:
182
+ - `level`: The log level to use. Defaults to `logging.LogLevel.Info`.
183
+ - `logger`: The logger to use. Defaults to a `logging.ConsoleLogger`.
184
+ - `silent`: Whether to silence the logger. Defaults to `true`.
185
+
186
+ The `level` property can be one of the following values:
187
+ - `logging.LogLevel.Debug`
188
+ - `logging.LogLevel.Info`
189
+ - `logging.LogLevel.Warn`
190
+ - `logging.LogLevel.Error`
191
+
192
+ To provide a custom logger, you can pass in an object that implements the `logging.ILogger` interface.
193
+
194
+ <details>
195
+ <summary>Custom logger examples</summary>
196
+
197
+ Here's an example using the popular `winston` logging library.
198
+ ```ts
199
+ import winston from 'winston';
200
+
201
+ const winstonLogger = winston.createLogger({...});
202
+
203
+ const logger: logging.ILogger = {
204
+ debug: (msg, ...args) => winstonLogger.debug(msg, ...args),
205
+ info: (msg, ...args) => winstonLogger.info(msg, ...args),
206
+ warn: (msg, ...args) => winstonLogger.warn(msg, ...args),
207
+ error: (msg, ...args) => winstonLogger.error(msg, ...args),
208
+ };
209
+ ```
210
+
211
+ Here's an example using the popular `pino` logging library.
212
+
213
+ ```ts
214
+ import pino from 'pino';
215
+
216
+ const pinoLogger = pino({...});
217
+
218
+ const logger: logging.ILogger = {
219
+ debug: (msg, ...args) => pinoLogger.debug(args, msg),
220
+ info: (msg, ...args) => pinoLogger.info(args, msg),
221
+ warn: (msg, ...args) => pinoLogger.warn(args, msg),
222
+ error: (msg, ...args) => pinoLogger.error(args, msg),
223
+ };
224
+ ```
225
+ </details>
226
+
227
+
165
228
  ### Runtime Compatibility
166
229
 
167
230
 
@@ -1,4 +1,4 @@
1
- import type * as core from "./core/index.js";
1
+ import * as core from "./core/index.js";
2
2
  import type * as environments from "./environments.js";
3
3
  export interface BaseClientOptions {
4
4
  environment?: core.Supplier<environments.AgentMailEnvironment | environments.AgentMailEnvironmentUrls>;
@@ -11,6 +11,10 @@ export interface BaseClientOptions {
11
11
  timeoutInSeconds?: number;
12
12
  /** The default number of times to retry the request. Defaults to 2. */
13
13
  maxRetries?: number;
14
+ /** Provide a custom fetch implementation. Useful for platforms that don't have a built-in fetch or need a custom implementation. */
15
+ fetch?: typeof fetch;
16
+ /** Configure logging for the client. */
17
+ logging?: core.logging.LogConfig | core.logging.Logger;
14
18
  }
15
19
  export interface BaseRequestOptions {
16
20
  /** The maximum time to wait for a response in seconds. */
@@ -24,3 +28,12 @@ export interface BaseRequestOptions {
24
28
  /** Additional headers to include in the request. */
25
29
  headers?: Record<string, string | core.Supplier<string | null | undefined> | null | undefined>;
26
30
  }
31
+ export type NormalizedClientOptions<T extends BaseClientOptions> = T & {
32
+ logging: core.logging.Logger;
33
+ authProvider?: core.AuthProvider;
34
+ };
35
+ export type NormalizedClientOptionsWithAuth<T extends BaseClientOptions> = NormalizedClientOptions<T> & {
36
+ authProvider: core.AuthProvider;
37
+ };
38
+ export declare function normalizeClientOptions<T extends BaseClientOptions>(options: T): NormalizedClientOptions<T>;
39
+ export declare function normalizeClientOptionsWithAuth<T extends BaseClientOptions>(options: T): NormalizedClientOptionsWithAuth<T>;
@@ -1,3 +1,62 @@
1
1
  "use strict";
2
2
  // This file was auto-generated by Fern from our API Definition.
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
3
36
  Object.defineProperty(exports, "__esModule", { value: true });
37
+ exports.normalizeClientOptions = normalizeClientOptions;
38
+ exports.normalizeClientOptionsWithAuth = normalizeClientOptionsWithAuth;
39
+ const BearerAuthProvider_js_1 = require("./auth/BearerAuthProvider.js");
40
+ const headers_js_1 = require("./core/headers.js");
41
+ const core = __importStar(require("./core/index.js"));
42
+ function normalizeClientOptions(options) {
43
+ const headers = (0, headers_js_1.mergeHeaders)({
44
+ "X-Fern-Language": "JavaScript",
45
+ "X-Fern-SDK-Name": "agentmail",
46
+ "X-Fern-SDK-Version": "0.1.7",
47
+ "User-Agent": "agentmail/0.1.7",
48
+ "X-Fern-Runtime": core.RUNTIME.type,
49
+ "X-Fern-Runtime-Version": core.RUNTIME.version,
50
+ }, options === null || options === void 0 ? void 0 : options.headers);
51
+ return Object.assign(Object.assign({}, options), { logging: core.logging.createLogger(options === null || options === void 0 ? void 0 : options.logging), headers });
52
+ }
53
+ function normalizeClientOptionsWithAuth(options) {
54
+ var _a;
55
+ const normalized = normalizeClientOptions(options);
56
+ const normalizedWithNoOpAuthProvider = withNoOpAuthProvider(normalized);
57
+ (_a = normalized.authProvider) !== null && _a !== void 0 ? _a : (normalized.authProvider = new BearerAuthProvider_js_1.BearerAuthProvider(normalizedWithNoOpAuthProvider));
58
+ return normalized;
59
+ }
60
+ function withNoOpAuthProvider(options) {
61
+ return Object.assign(Object.assign({}, options), { authProvider: new core.NoOpAuthProvider() });
62
+ }
@@ -1,13 +1,14 @@
1
- import { ApiKeys } from "./api/resources/apiKeys/client/Client.js";
2
- import { Domains } from "./api/resources/domains/client/Client.js";
3
- import { Drafts } from "./api/resources/drafts/client/Client.js";
4
- import { Inboxes } from "./api/resources/inboxes/client/Client.js";
5
- import { Metrics } from "./api/resources/metrics/client/Client.js";
6
- import { Pods } from "./api/resources/pods/client/Client.js";
7
- import { Threads } from "./api/resources/threads/client/Client.js";
8
- import { Webhooks } from "./api/resources/webhooks/client/Client.js";
9
- import { Websockets } from "./api/resources/websockets/client/Client.js";
1
+ import { ApiKeysClient } from "./api/resources/apiKeys/client/Client.js";
2
+ import { DomainsClient } from "./api/resources/domains/client/Client.js";
3
+ import { DraftsClient } from "./api/resources/drafts/client/Client.js";
4
+ import { InboxesClient } from "./api/resources/inboxes/client/Client.js";
5
+ import { MetricsClient } from "./api/resources/metrics/client/Client.js";
6
+ import { PodsClient } from "./api/resources/pods/client/Client.js";
7
+ import { ThreadsClient } from "./api/resources/threads/client/Client.js";
8
+ import { WebhooksClient } from "./api/resources/webhooks/client/Client.js";
9
+ import { WebsocketsClient } from "./api/resources/websockets/client/Client.js";
10
10
  import type { BaseClientOptions, BaseRequestOptions } from "./BaseClient.js";
11
+ import { type NormalizedClientOptionsWithAuth } from "./BaseClient.js";
11
12
  export declare namespace AgentMailClient {
12
13
  interface Options extends BaseClientOptions {
13
14
  }
@@ -15,24 +16,24 @@ export declare namespace AgentMailClient {
15
16
  }
16
17
  }
17
18
  export declare class AgentMailClient {
18
- protected readonly _options: AgentMailClient.Options;
19
- protected _inboxes: Inboxes | undefined;
20
- protected _pods: Pods | undefined;
21
- protected _webhooks: Webhooks | undefined;
22
- protected _apiKeys: ApiKeys | undefined;
23
- protected _domains: Domains | undefined;
24
- protected _drafts: Drafts | undefined;
25
- protected _metrics: Metrics | undefined;
26
- protected _threads: Threads | undefined;
27
- protected _websockets: Websockets | undefined;
28
- constructor(_options?: AgentMailClient.Options);
29
- get inboxes(): Inboxes;
30
- get pods(): Pods;
31
- get webhooks(): Webhooks;
32
- get apiKeys(): ApiKeys;
33
- get domains(): Domains;
34
- get drafts(): Drafts;
35
- get metrics(): Metrics;
36
- get threads(): Threads;
37
- get websockets(): Websockets;
19
+ protected readonly _options: NormalizedClientOptionsWithAuth<AgentMailClient.Options>;
20
+ protected _inboxes: InboxesClient | undefined;
21
+ protected _pods: PodsClient | undefined;
22
+ protected _webhooks: WebhooksClient | undefined;
23
+ protected _apiKeys: ApiKeysClient | undefined;
24
+ protected _domains: DomainsClient | undefined;
25
+ protected _drafts: DraftsClient | undefined;
26
+ protected _metrics: MetricsClient | undefined;
27
+ protected _threads: ThreadsClient | undefined;
28
+ protected _websockets: WebsocketsClient | undefined;
29
+ constructor(options?: AgentMailClient.Options);
30
+ get inboxes(): InboxesClient;
31
+ get pods(): PodsClient;
32
+ get webhooks(): WebhooksClient;
33
+ get apiKeys(): ApiKeysClient;
34
+ get domains(): DomainsClient;
35
+ get drafts(): DraftsClient;
36
+ get metrics(): MetricsClient;
37
+ get threads(): ThreadsClient;
38
+ get websockets(): WebsocketsClient;
38
39
  }
@@ -1,38 +1,5 @@
1
1
  "use strict";
2
2
  // This file was auto-generated by Fern from our API Definition.
3
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
- if (k2 === undefined) k2 = k;
5
- var desc = Object.getOwnPropertyDescriptor(m, k);
6
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
- desc = { enumerable: true, get: function() { return m[k]; } };
8
- }
9
- Object.defineProperty(o, k2, desc);
10
- }) : (function(o, m, k, k2) {
11
- if (k2 === undefined) k2 = k;
12
- o[k2] = m[k];
13
- }));
14
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
- Object.defineProperty(o, "default", { enumerable: true, value: v });
16
- }) : function(o, v) {
17
- o["default"] = v;
18
- });
19
- var __importStar = (this && this.__importStar) || (function () {
20
- var ownKeys = function(o) {
21
- ownKeys = Object.getOwnPropertyNames || function (o) {
22
- var ar = [];
23
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
- return ar;
25
- };
26
- return ownKeys(o);
27
- };
28
- return function (mod) {
29
- if (mod && mod.__esModule) return mod;
30
- var result = {};
31
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
- __setModuleDefault(result, mod);
33
- return result;
34
- };
35
- })();
36
3
  Object.defineProperty(exports, "__esModule", { value: true });
37
4
  exports.AgentMailClient = void 0;
38
5
  const Client_js_1 = require("./api/resources/apiKeys/client/Client.js");
@@ -44,54 +11,46 @@ const Client_js_6 = require("./api/resources/pods/client/Client.js");
44
11
  const Client_js_7 = require("./api/resources/threads/client/Client.js");
45
12
  const Client_js_8 = require("./api/resources/webhooks/client/Client.js");
46
13
  const Client_js_9 = require("./api/resources/websockets/client/Client.js");
47
- const headers_js_1 = require("./core/headers.js");
48
- const core = __importStar(require("./core/index.js"));
14
+ const BaseClient_js_1 = require("./BaseClient.js");
49
15
  class AgentMailClient {
50
- constructor(_options = {}) {
51
- this._options = Object.assign(Object.assign({}, _options), { headers: (0, headers_js_1.mergeHeaders)({
52
- "X-Fern-Language": "JavaScript",
53
- "X-Fern-SDK-Name": "agentmail",
54
- "X-Fern-SDK-Version": "0.1.6",
55
- "User-Agent": "agentmail/0.1.6",
56
- "X-Fern-Runtime": core.RUNTIME.type,
57
- "X-Fern-Runtime-Version": core.RUNTIME.version,
58
- }, _options === null || _options === void 0 ? void 0 : _options.headers) });
16
+ constructor(options = {}) {
17
+ this._options = (0, BaseClient_js_1.normalizeClientOptionsWithAuth)(options);
59
18
  }
60
19
  get inboxes() {
61
20
  var _a;
62
- return ((_a = this._inboxes) !== null && _a !== void 0 ? _a : (this._inboxes = new Client_js_4.Inboxes(this._options)));
21
+ return ((_a = this._inboxes) !== null && _a !== void 0 ? _a : (this._inboxes = new Client_js_4.InboxesClient(this._options)));
63
22
  }
64
23
  get pods() {
65
24
  var _a;
66
- return ((_a = this._pods) !== null && _a !== void 0 ? _a : (this._pods = new Client_js_6.Pods(this._options)));
25
+ return ((_a = this._pods) !== null && _a !== void 0 ? _a : (this._pods = new Client_js_6.PodsClient(this._options)));
67
26
  }
68
27
  get webhooks() {
69
28
  var _a;
70
- return ((_a = this._webhooks) !== null && _a !== void 0 ? _a : (this._webhooks = new Client_js_8.Webhooks(this._options)));
29
+ return ((_a = this._webhooks) !== null && _a !== void 0 ? _a : (this._webhooks = new Client_js_8.WebhooksClient(this._options)));
71
30
  }
72
31
  get apiKeys() {
73
32
  var _a;
74
- return ((_a = this._apiKeys) !== null && _a !== void 0 ? _a : (this._apiKeys = new Client_js_1.ApiKeys(this._options)));
33
+ return ((_a = this._apiKeys) !== null && _a !== void 0 ? _a : (this._apiKeys = new Client_js_1.ApiKeysClient(this._options)));
75
34
  }
76
35
  get domains() {
77
36
  var _a;
78
- return ((_a = this._domains) !== null && _a !== void 0 ? _a : (this._domains = new Client_js_2.Domains(this._options)));
37
+ return ((_a = this._domains) !== null && _a !== void 0 ? _a : (this._domains = new Client_js_2.DomainsClient(this._options)));
79
38
  }
80
39
  get drafts() {
81
40
  var _a;
82
- return ((_a = this._drafts) !== null && _a !== void 0 ? _a : (this._drafts = new Client_js_3.Drafts(this._options)));
41
+ return ((_a = this._drafts) !== null && _a !== void 0 ? _a : (this._drafts = new Client_js_3.DraftsClient(this._options)));
83
42
  }
84
43
  get metrics() {
85
44
  var _a;
86
- return ((_a = this._metrics) !== null && _a !== void 0 ? _a : (this._metrics = new Client_js_5.Metrics(this._options)));
45
+ return ((_a = this._metrics) !== null && _a !== void 0 ? _a : (this._metrics = new Client_js_5.MetricsClient(this._options)));
87
46
  }
88
47
  get threads() {
89
48
  var _a;
90
- return ((_a = this._threads) !== null && _a !== void 0 ? _a : (this._threads = new Client_js_7.Threads(this._options)));
49
+ return ((_a = this._threads) !== null && _a !== void 0 ? _a : (this._threads = new Client_js_7.ThreadsClient(this._options)));
91
50
  }
92
51
  get websockets() {
93
52
  var _a;
94
- return ((_a = this._websockets) !== null && _a !== void 0 ? _a : (this._websockets = new Client_js_9.Websockets(this._options)));
53
+ return ((_a = this._websockets) !== null && _a !== void 0 ? _a : (this._websockets = new Client_js_9.WebsocketsClient(this._options)));
95
54
  }
96
55
  }
97
56
  exports.AgentMailClient = AgentMailClient;
@@ -1,27 +1,28 @@
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 ApiKeys {
5
+ export declare namespace ApiKeysClient {
5
6
  interface Options extends BaseClientOptions {
6
7
  }
7
8
  interface RequestOptions extends BaseRequestOptions {
8
9
  }
9
10
  }
10
- export declare class ApiKeys {
11
- protected readonly _options: ApiKeys.Options;
12
- constructor(_options?: ApiKeys.Options);
11
+ export declare class ApiKeysClient {
12
+ protected readonly _options: NormalizedClientOptionsWithAuth<ApiKeysClient.Options>;
13
+ constructor(options?: ApiKeysClient.Options);
13
14
  /**
14
15
  * @param {AgentMail.ListApiKeysRequest} request
15
- * @param {ApiKeys.RequestOptions} requestOptions - Request-specific configuration.
16
+ * @param {ApiKeysClient.RequestOptions} requestOptions - Request-specific configuration.
16
17
  *
17
18
  * @example
18
19
  * await client.apiKeys.list()
19
20
  */
20
- list(request?: AgentMail.ListApiKeysRequest, requestOptions?: ApiKeys.RequestOptions): core.HttpResponsePromise<AgentMail.ListApiKeysResponse>;
21
+ list(request?: AgentMail.ListApiKeysRequest, requestOptions?: ApiKeysClient.RequestOptions): core.HttpResponsePromise<AgentMail.ListApiKeysResponse>;
21
22
  private __list;
22
23
  /**
23
24
  * @param {AgentMail.CreateApiKeyRequest} request
24
- * @param {ApiKeys.RequestOptions} requestOptions - Request-specific configuration.
25
+ * @param {ApiKeysClient.RequestOptions} requestOptions - Request-specific configuration.
25
26
  *
26
27
  * @throws {@link AgentMail.ValidationError}
27
28
  *
@@ -30,18 +31,17 @@ export declare class ApiKeys {
30
31
  * name: "name"
31
32
  * })
32
33
  */
33
- create(request: AgentMail.CreateApiKeyRequest, requestOptions?: ApiKeys.RequestOptions): core.HttpResponsePromise<AgentMail.CreateApiKeyResponse>;
34
+ create(request: AgentMail.CreateApiKeyRequest, requestOptions?: ApiKeysClient.RequestOptions): core.HttpResponsePromise<AgentMail.CreateApiKeyResponse>;
34
35
  private __create;
35
36
  /**
36
- * @param {AgentMail.ApiKeyId} apiKey
37
- * @param {ApiKeys.RequestOptions} requestOptions - Request-specific configuration.
37
+ * @param {AgentMail.ApiKeyId} api_key
38
+ * @param {ApiKeysClient.RequestOptions} requestOptions - Request-specific configuration.
38
39
  *
39
40
  * @throws {@link AgentMail.NotFoundError}
40
41
  *
41
42
  * @example
42
43
  * await client.apiKeys.delete("api_key")
43
44
  */
44
- delete(apiKey: AgentMail.ApiKeyId, requestOptions?: ApiKeys.RequestOptions): core.HttpResponsePromise<void>;
45
+ delete(api_key: AgentMail.ApiKeyId, requestOptions?: ApiKeysClient.RequestOptions): core.HttpResponsePromise<void>;
45
46
  private __delete;
46
- protected _getAuthorizationHeader(): Promise<string>;
47
47
  }
@@ -43,20 +43,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
43
43
  });
44
44
  };
45
45
  Object.defineProperty(exports, "__esModule", { value: true });
46
- exports.ApiKeys = void 0;
46
+ exports.ApiKeysClient = 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"));
50
51
  const errors = __importStar(require("../../../../errors/index.js"));
51
52
  const serializers = __importStar(require("../../../../serialization/index.js"));
52
53
  const AgentMail = __importStar(require("../../../index.js"));
53
- class ApiKeys {
54
- constructor(_options = {}) {
55
- this._options = _options;
54
+ class ApiKeysClient {
55
+ constructor(options = {}) {
56
+ this._options = (0, BaseClient_js_1.normalizeClientOptionsWithAuth)(options);
56
57
  }
57
58
  /**
58
59
  * @param {AgentMail.ListApiKeysRequest} request
59
- * @param {ApiKeys.RequestOptions} requestOptions - Request-specific configuration.
60
+ * @param {ApiKeysClient.RequestOptions} requestOptions - Request-specific configuration.
60
61
  *
61
62
  * @example
62
63
  * await client.apiKeys.list()
@@ -66,7 +67,7 @@ class ApiKeys {
66
67
  }
67
68
  __list() {
68
69
  return __awaiter(this, arguments, void 0, function* (request = {}, requestOptions) {
69
- var _a, _b, _c, _d, _e, _f, _g, _h;
70
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
70
71
  const { limit, pageToken } = request;
71
72
  const _queryParams = {};
72
73
  if (limit != null) {
@@ -75,7 +76,8 @@ class ApiKeys {
75
76
  if (pageToken != null) {
76
77
  _queryParams.page_token = pageToken;
77
78
  }
78
- 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);
79
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
80
+ 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);
79
81
  const _response = yield core.fetcher({
80
82
  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/api-keys"),
81
83
  method: "GET",
@@ -84,6 +86,8 @@ class ApiKeys {
84
86
  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,
85
87
  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,
86
88
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
89
+ fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
90
+ logging: this._options.logging,
87
91
  });
88
92
  if (_response.ok) {
89
93
  return {
@@ -123,7 +127,7 @@ class ApiKeys {
123
127
  }
124
128
  /**
125
129
  * @param {AgentMail.CreateApiKeyRequest} request
126
- * @param {ApiKeys.RequestOptions} requestOptions - Request-specific configuration.
130
+ * @param {ApiKeysClient.RequestOptions} requestOptions - Request-specific configuration.
127
131
  *
128
132
  * @throws {@link AgentMail.ValidationError}
129
133
  *
@@ -137,8 +141,9 @@ class ApiKeys {
137
141
  }
138
142
  __create(request, requestOptions) {
139
143
  return __awaiter(this, void 0, void 0, function* () {
140
- var _a, _b, _c, _d, _e, _f, _g, _h;
141
- 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);
144
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
145
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
146
+ 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);
142
147
  const _response = yield core.fetcher({
143
148
  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/api-keys"),
144
149
  method: "POST",
@@ -155,6 +160,8 @@ class ApiKeys {
155
160
  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,
156
161
  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,
157
162
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
163
+ fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
164
+ logging: this._options.logging,
158
165
  });
159
166
  if (_response.ok) {
160
167
  return {
@@ -204,29 +211,32 @@ class ApiKeys {
204
211
  });
205
212
  }
206
213
  /**
207
- * @param {AgentMail.ApiKeyId} apiKey
208
- * @param {ApiKeys.RequestOptions} requestOptions - Request-specific configuration.
214
+ * @param {AgentMail.ApiKeyId} api_key
215
+ * @param {ApiKeysClient.RequestOptions} requestOptions - Request-specific configuration.
209
216
  *
210
217
  * @throws {@link AgentMail.NotFoundError}
211
218
  *
212
219
  * @example
213
220
  * await client.apiKeys.delete("api_key")
214
221
  */
215
- delete(apiKey, requestOptions) {
216
- return core.HttpResponsePromise.fromPromise(this.__delete(apiKey, requestOptions));
222
+ delete(api_key, requestOptions) {
223
+ return core.HttpResponsePromise.fromPromise(this.__delete(api_key, requestOptions));
217
224
  }
218
- __delete(apiKey, requestOptions) {
225
+ __delete(api_key, requestOptions) {
219
226
  return __awaiter(this, void 0, void 0, function* () {
220
- var _a, _b, _c, _d, _e, _f, _g, _h;
221
- 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);
227
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
228
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
229
+ 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);
222
230
  const _response = yield core.fetcher({
223
- 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/api-keys/${core.url.encodePathParam(serializers.ApiKeyId.jsonOrThrow(apiKey, { omitUndefined: true }))}`),
231
+ 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/api-keys/${core.url.encodePathParam(serializers.ApiKeyId.jsonOrThrow(api_key, { omitUndefined: true }))}`),
224
232
  method: "DELETE",
225
233
  headers: _headers,
226
234
  queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
227
235
  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,
228
236
  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,
229
237
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
238
+ fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
239
+ logging: this._options.logging,
230
240
  });
231
241
  if (_response.ok) {
232
242
  return { data: undefined, rawResponse: _response.rawResponse };
@@ -266,17 +276,5 @@ class ApiKeys {
266
276
  }
267
277
  });
268
278
  }
269
- _getAuthorizationHeader() {
270
- return __awaiter(this, void 0, void 0, function* () {
271
- var _a;
272
- 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;
273
- if (bearer == null) {
274
- throw new errors.AgentMailError({
275
- message: "Please specify a bearer by either passing it in to the constructor or initializing a AGENTMAIL_API_KEY environment variable",
276
- });
277
- }
278
- return `Bearer ${bearer}`;
279
- });
280
- }
281
279
  }
282
- exports.ApiKeys = ApiKeys;
280
+ exports.ApiKeysClient = ApiKeysClient;
@@ -1,43 +1,44 @@
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 Domains {
5
+ export declare namespace DomainsClient {
5
6
  interface Options extends BaseClientOptions {
6
7
  }
7
8
  interface RequestOptions extends BaseRequestOptions {
8
9
  }
9
10
  }
10
- export declare class Domains {
11
- protected readonly _options: Domains.Options;
12
- constructor(_options?: Domains.Options);
11
+ export declare class DomainsClient {
12
+ protected readonly _options: NormalizedClientOptionsWithAuth<DomainsClient.Options>;
13
+ constructor(options?: DomainsClient.Options);
13
14
  /**
14
15
  * @param {AgentMail.ListDomainsRequest} request
15
- * @param {Domains.RequestOptions} requestOptions - Request-specific configuration.
16
+ * @param {DomainsClient.RequestOptions} requestOptions - Request-specific configuration.
16
17
  *
17
18
  * @example
18
19
  * await client.domains.list()
19
20
  */
20
- list(request?: AgentMail.ListDomainsRequest, requestOptions?: Domains.RequestOptions): core.HttpResponsePromise<AgentMail.ListDomainsResponse>;
21
+ list(request?: AgentMail.ListDomainsRequest, requestOptions?: DomainsClient.RequestOptions): core.HttpResponsePromise<AgentMail.ListDomainsResponse>;
21
22
  private __list;
22
23
  /**
23
- * @param {AgentMail.DomainId} domainId
24
- * @param {Domains.RequestOptions} requestOptions - Request-specific configuration.
24
+ * @param {AgentMail.DomainId} domain_id
25
+ * @param {DomainsClient.RequestOptions} requestOptions - Request-specific configuration.
25
26
  *
26
27
  * @throws {@link AgentMail.NotFoundError}
27
28
  *
28
29
  * @example
29
30
  * await client.domains.get("domain_id")
30
31
  */
31
- get(domainId: AgentMail.DomainId, requestOptions?: Domains.RequestOptions): core.HttpResponsePromise<AgentMail.Domain>;
32
+ get(domain_id: AgentMail.DomainId, requestOptions?: DomainsClient.RequestOptions): core.HttpResponsePromise<AgentMail.Domain>;
32
33
  private __get;
33
34
  /**
34
35
  * @throws {@link AgentMail.NotFoundError}
35
36
  */
36
- getZoneFile(domainId: AgentMail.DomainId, requestOptions?: Domains.RequestOptions): core.HttpResponsePromise<core.BinaryResponse>;
37
+ getZoneFile(domain_id: AgentMail.DomainId, requestOptions?: DomainsClient.RequestOptions): core.HttpResponsePromise<core.BinaryResponse>;
37
38
  private __getZoneFile;
38
39
  /**
39
40
  * @param {AgentMail.CreateDomainRequest} request
40
- * @param {Domains.RequestOptions} requestOptions - Request-specific configuration.
41
+ * @param {DomainsClient.RequestOptions} requestOptions - Request-specific configuration.
41
42
  *
42
43
  * @throws {@link AgentMail.ValidationError}
43
44
  *
@@ -47,29 +48,28 @@ export declare class Domains {
47
48
  * feedbackEnabled: true
48
49
  * })
49
50
  */
50
- create(request: AgentMail.CreateDomainRequest, requestOptions?: Domains.RequestOptions): core.HttpResponsePromise<AgentMail.Domain>;
51
+ create(request: AgentMail.CreateDomainRequest, requestOptions?: DomainsClient.RequestOptions): core.HttpResponsePromise<AgentMail.Domain>;
51
52
  private __create;
52
53
  /**
53
- * @param {AgentMail.DomainId} domainId
54
- * @param {Domains.RequestOptions} requestOptions - Request-specific configuration.
54
+ * @param {AgentMail.DomainId} domain_id
55
+ * @param {DomainsClient.RequestOptions} requestOptions - Request-specific configuration.
55
56
  *
56
57
  * @throws {@link AgentMail.NotFoundError}
57
58
  *
58
59
  * @example
59
60
  * await client.domains.delete("domain_id")
60
61
  */
61
- delete(domainId: AgentMail.DomainId, requestOptions?: Domains.RequestOptions): core.HttpResponsePromise<void>;
62
+ delete(domain_id: AgentMail.DomainId, requestOptions?: DomainsClient.RequestOptions): core.HttpResponsePromise<void>;
62
63
  private __delete;
63
64
  /**
64
- * @param {AgentMail.DomainId} domainId
65
- * @param {Domains.RequestOptions} requestOptions - Request-specific configuration.
65
+ * @param {AgentMail.DomainId} domain_id
66
+ * @param {DomainsClient.RequestOptions} requestOptions - Request-specific configuration.
66
67
  *
67
68
  * @throws {@link AgentMail.NotFoundError}
68
69
  *
69
70
  * @example
70
71
  * await client.domains.verify("domain_id")
71
72
  */
72
- verify(domainId: AgentMail.DomainId, requestOptions?: Domains.RequestOptions): core.HttpResponsePromise<void>;
73
+ verify(domain_id: AgentMail.DomainId, requestOptions?: DomainsClient.RequestOptions): core.HttpResponsePromise<void>;
73
74
  private __verify;
74
- protected _getAuthorizationHeader(): Promise<string>;
75
75
  }