agentmail 0.5.28 → 0.5.30

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 (116) hide show
  1. package/dist/cjs/BaseClient.js +2 -2
  2. package/dist/cjs/api/resources/attachments/types/AttachmentResponse.d.ts +4 -2
  3. package/dist/cjs/api/resources/inboxes/resources/metrics/client/Client.d.ts +28 -0
  4. package/dist/cjs/api/resources/inboxes/resources/metrics/client/Client.js +98 -0
  5. package/dist/cjs/api/resources/inboxes/resources/metrics/client/requests/QueryRatesRequest.d.ts +14 -0
  6. package/dist/cjs/api/resources/inboxes/resources/metrics/client/requests/QueryRatesRequest.js +3 -0
  7. package/dist/cjs/api/resources/inboxes/resources/metrics/client/requests/index.d.ts +1 -0
  8. package/dist/cjs/api/resources/messages/types/RawMessageResponse.d.ts +2 -2
  9. package/dist/cjs/api/resources/metrics/client/Client.d.ts +28 -0
  10. package/dist/cjs/api/resources/metrics/client/Client.js +98 -0
  11. package/dist/cjs/api/resources/metrics/client/requests/QueryRatesRequest.d.ts +14 -0
  12. package/dist/cjs/api/resources/metrics/client/requests/QueryRatesRequest.js +3 -0
  13. package/dist/cjs/api/resources/metrics/client/requests/index.d.ts +1 -0
  14. package/dist/cjs/api/resources/metrics/types/QueryRatesResponse.d.ts +5 -0
  15. package/dist/cjs/api/resources/metrics/types/QueryRatesResponse.js +3 -0
  16. package/dist/cjs/api/resources/metrics/types/RatePeriod.d.ts +5 -0
  17. package/dist/cjs/api/resources/metrics/types/RatePeriod.js +3 -0
  18. package/dist/cjs/api/resources/metrics/types/RatePoint.d.ts +12 -0
  19. package/dist/cjs/api/resources/metrics/types/RatePoint.js +3 -0
  20. package/dist/cjs/api/resources/metrics/types/RateType.d.ts +10 -0
  21. package/dist/cjs/api/resources/metrics/types/RateType.js +13 -0
  22. package/dist/cjs/api/resources/metrics/types/RateTypes.d.ts +5 -0
  23. package/dist/cjs/api/resources/metrics/types/RateTypes.js +3 -0
  24. package/dist/cjs/api/resources/metrics/types/Window.d.ts +6 -0
  25. package/dist/cjs/api/resources/metrics/types/Window.js +3 -0
  26. package/dist/cjs/api/resources/metrics/types/index.d.ts +6 -0
  27. package/dist/cjs/api/resources/metrics/types/index.js +6 -0
  28. package/dist/cjs/api/resources/pods/resources/metrics/client/Client.d.ts +28 -0
  29. package/dist/cjs/api/resources/pods/resources/metrics/client/Client.js +98 -0
  30. package/dist/cjs/api/resources/pods/resources/metrics/client/requests/QueryRatesRequest.d.ts +14 -0
  31. package/dist/cjs/api/resources/pods/resources/metrics/client/requests/QueryRatesRequest.js +3 -0
  32. package/dist/cjs/api/resources/pods/resources/metrics/client/requests/index.d.ts +1 -0
  33. package/dist/cjs/api/resources/webhooks/types/UpdateInboxWebhookRequest.d.ts +10 -1
  34. package/dist/cjs/api/resources/webhooks/types/UpdatePodWebhookRequest.d.ts +2 -2
  35. package/dist/cjs/api/resources/webhooks/types/Webhook.d.ts +11 -0
  36. package/dist/cjs/serialization/resources/attachments/types/AttachmentResponse.d.ts +1 -0
  37. package/dist/cjs/serialization/resources/attachments/types/AttachmentResponse.js +1 -0
  38. package/dist/cjs/serialization/resources/metrics/types/QueryRatesResponse.d.ts +9 -0
  39. package/dist/cjs/serialization/resources/metrics/types/QueryRatesResponse.js +41 -0
  40. package/dist/cjs/serialization/resources/metrics/types/RatePeriod.d.ts +7 -0
  41. package/dist/cjs/serialization/resources/metrics/types/RatePeriod.js +39 -0
  42. package/dist/cjs/serialization/resources/metrics/types/RatePoint.d.ts +11 -0
  43. package/dist/cjs/serialization/resources/metrics/types/RatePoint.js +43 -0
  44. package/dist/cjs/serialization/resources/metrics/types/RateType.d.ts +7 -0
  45. package/dist/cjs/serialization/resources/metrics/types/RateType.js +39 -0
  46. package/dist/cjs/serialization/resources/metrics/types/RateTypes.d.ts +8 -0
  47. package/dist/cjs/serialization/resources/metrics/types/RateTypes.js +40 -0
  48. package/dist/cjs/serialization/resources/metrics/types/Window.d.ts +7 -0
  49. package/dist/cjs/serialization/resources/metrics/types/Window.js +39 -0
  50. package/dist/cjs/serialization/resources/metrics/types/index.d.ts +6 -0
  51. package/dist/cjs/serialization/resources/metrics/types/index.js +6 -0
  52. package/dist/cjs/serialization/resources/webhooks/types/UpdateInboxWebhookRequest.d.ts +1 -0
  53. package/dist/cjs/serialization/resources/webhooks/types/UpdateInboxWebhookRequest.js +1 -0
  54. package/dist/cjs/serialization/resources/webhooks/types/Webhook.d.ts +2 -0
  55. package/dist/cjs/serialization/resources/webhooks/types/Webhook.js +2 -0
  56. package/dist/cjs/version.d.ts +1 -1
  57. package/dist/cjs/version.js +1 -1
  58. package/dist/esm/BaseClient.mjs +2 -2
  59. package/dist/esm/api/resources/attachments/types/AttachmentResponse.d.mts +4 -2
  60. package/dist/esm/api/resources/inboxes/resources/metrics/client/Client.d.mts +28 -0
  61. package/dist/esm/api/resources/inboxes/resources/metrics/client/Client.mjs +98 -0
  62. package/dist/esm/api/resources/inboxes/resources/metrics/client/requests/QueryRatesRequest.d.mts +14 -0
  63. package/dist/esm/api/resources/inboxes/resources/metrics/client/requests/QueryRatesRequest.mjs +2 -0
  64. package/dist/esm/api/resources/inboxes/resources/metrics/client/requests/index.d.mts +1 -0
  65. package/dist/esm/api/resources/messages/types/RawMessageResponse.d.mts +2 -2
  66. package/dist/esm/api/resources/metrics/client/Client.d.mts +28 -0
  67. package/dist/esm/api/resources/metrics/client/Client.mjs +98 -0
  68. package/dist/esm/api/resources/metrics/client/requests/QueryRatesRequest.d.mts +14 -0
  69. package/dist/esm/api/resources/metrics/client/requests/QueryRatesRequest.mjs +2 -0
  70. package/dist/esm/api/resources/metrics/client/requests/index.d.mts +1 -0
  71. package/dist/esm/api/resources/metrics/types/QueryRatesResponse.d.mts +5 -0
  72. package/dist/esm/api/resources/metrics/types/QueryRatesResponse.mjs +2 -0
  73. package/dist/esm/api/resources/metrics/types/RatePeriod.d.mts +5 -0
  74. package/dist/esm/api/resources/metrics/types/RatePeriod.mjs +2 -0
  75. package/dist/esm/api/resources/metrics/types/RatePoint.d.mts +12 -0
  76. package/dist/esm/api/resources/metrics/types/RatePoint.mjs +2 -0
  77. package/dist/esm/api/resources/metrics/types/RateType.d.mts +10 -0
  78. package/dist/esm/api/resources/metrics/types/RateType.mjs +10 -0
  79. package/dist/esm/api/resources/metrics/types/RateTypes.d.mts +5 -0
  80. package/dist/esm/api/resources/metrics/types/RateTypes.mjs +2 -0
  81. package/dist/esm/api/resources/metrics/types/Window.d.mts +6 -0
  82. package/dist/esm/api/resources/metrics/types/Window.mjs +2 -0
  83. package/dist/esm/api/resources/metrics/types/index.d.mts +6 -0
  84. package/dist/esm/api/resources/metrics/types/index.mjs +6 -0
  85. package/dist/esm/api/resources/pods/resources/metrics/client/Client.d.mts +28 -0
  86. package/dist/esm/api/resources/pods/resources/metrics/client/Client.mjs +98 -0
  87. package/dist/esm/api/resources/pods/resources/metrics/client/requests/QueryRatesRequest.d.mts +14 -0
  88. package/dist/esm/api/resources/pods/resources/metrics/client/requests/QueryRatesRequest.mjs +2 -0
  89. package/dist/esm/api/resources/pods/resources/metrics/client/requests/index.d.mts +1 -0
  90. package/dist/esm/api/resources/webhooks/types/UpdateInboxWebhookRequest.d.mts +10 -1
  91. package/dist/esm/api/resources/webhooks/types/UpdatePodWebhookRequest.d.mts +2 -2
  92. package/dist/esm/api/resources/webhooks/types/Webhook.d.mts +11 -0
  93. package/dist/esm/serialization/resources/attachments/types/AttachmentResponse.d.mts +1 -0
  94. package/dist/esm/serialization/resources/attachments/types/AttachmentResponse.mjs +1 -0
  95. package/dist/esm/serialization/resources/metrics/types/QueryRatesResponse.d.mts +9 -0
  96. package/dist/esm/serialization/resources/metrics/types/QueryRatesResponse.mjs +5 -0
  97. package/dist/esm/serialization/resources/metrics/types/RatePeriod.d.mts +7 -0
  98. package/dist/esm/serialization/resources/metrics/types/RatePeriod.mjs +3 -0
  99. package/dist/esm/serialization/resources/metrics/types/RatePoint.d.mts +11 -0
  100. package/dist/esm/serialization/resources/metrics/types/RatePoint.mjs +7 -0
  101. package/dist/esm/serialization/resources/metrics/types/RateType.d.mts +7 -0
  102. package/dist/esm/serialization/resources/metrics/types/RateType.mjs +3 -0
  103. package/dist/esm/serialization/resources/metrics/types/RateTypes.d.mts +8 -0
  104. package/dist/esm/serialization/resources/metrics/types/RateTypes.mjs +4 -0
  105. package/dist/esm/serialization/resources/metrics/types/Window.d.mts +7 -0
  106. package/dist/esm/serialization/resources/metrics/types/Window.mjs +3 -0
  107. package/dist/esm/serialization/resources/metrics/types/index.d.mts +6 -0
  108. package/dist/esm/serialization/resources/metrics/types/index.mjs +6 -0
  109. package/dist/esm/serialization/resources/webhooks/types/UpdateInboxWebhookRequest.d.mts +1 -0
  110. package/dist/esm/serialization/resources/webhooks/types/UpdateInboxWebhookRequest.mjs +1 -0
  111. package/dist/esm/serialization/resources/webhooks/types/Webhook.d.mts +2 -0
  112. package/dist/esm/serialization/resources/webhooks/types/Webhook.mjs +2 -0
  113. package/dist/esm/version.d.mts +1 -1
  114. package/dist/esm/version.mjs +1 -1
  115. package/package.json +1 -1
  116. package/reference.md +248 -0
@@ -43,8 +43,8 @@ function normalizeClientOptions(options) {
43
43
  const headers = (0, headers_js_1.mergeHeaders)({
44
44
  "X-Fern-Language": "JavaScript",
45
45
  "X-Fern-SDK-Name": "agentmail",
46
- "X-Fern-SDK-Version": "0.5.28",
47
- "User-Agent": "agentmail/0.5.28",
46
+ "X-Fern-SDK-Version": "0.5.30",
47
+ "User-Agent": "agentmail/0.5.30",
48
48
  "X-Fern-Runtime": core.RUNTIME.type,
49
49
  "X-Fern-Runtime-Version": core.RUNTIME.version,
50
50
  }, options === null || options === void 0 ? void 0 : options.headers);
@@ -6,8 +6,10 @@ export interface AttachmentResponse {
6
6
  contentType?: AgentMail.AttachmentContentType;
7
7
  contentDisposition?: AgentMail.AttachmentContentDisposition;
8
8
  contentId?: AgentMail.AttachmentContentId;
9
- /** URL to download the attachment. */
9
+ /** Signed HTTPS CDN URL to download the attachment bytes. Retrieve a fresh URL when needed rather than storing it permanently. */
10
10
  downloadUrl: string;
11
- /** Time at which the download URL expires. */
11
+ /** Signed HTTPS CDN URL to download extracted plain text, when available. Omitted when no extracted text is available. Expires at the same time as download_url. */
12
+ textUrl?: string;
13
+ /** Time at which download_url and text_url (when present) expire. Retrieve the attachment again to obtain fresh URLs. */
12
14
  expiresAt: Date;
13
15
  }
@@ -53,4 +53,32 @@ export declare class MetricsClient {
53
53
  */
54
54
  queryUsage(inbox_id: AgentMail.inboxes.InboxId, request?: AgentMail.inboxes.QueryUsageRequest, requestOptions?: MetricsClient.RequestOptions): core.HttpResponsePromise<AgentMail.QueryUsageResponse>;
55
55
  private __queryUsage;
56
+ /**
57
+ * Rolling bounce and complaint rates for the inbox. At each `period`
58
+ * grid point, the bounced (or complained) messages over the preceding
59
+ * `window` divided by the messages sent over the same window, with the
60
+ * send count alongside. Account moderation evaluates the organization-wide
61
+ * rate, so use the organization endpoint to see the number it acts on;
62
+ * the inbox view shows which inboxes contribute. Defaults to the rolling
63
+ * 24-hour rate sampled hourly over the last day; `start` must be within
64
+ * the last 90 days, `window` must be a whole multiple of `period`, and
65
+ * the range plus window divided by `period` must not exceed 1000
66
+ * buckets.
67
+ *
68
+ * **CLI:**
69
+ * ```bash
70
+ * agentmail inboxes metrics query-rates --inbox-id <inbox_id>
71
+ * ```
72
+ *
73
+ * @param {AgentMail.inboxes.InboxId} inbox_id
74
+ * @param {AgentMail.inboxes.QueryRatesRequest} request
75
+ * @param {MetricsClient.RequestOptions} requestOptions - Request-specific configuration.
76
+ *
77
+ * @throws {@link AgentMail.ValidationError}
78
+ *
79
+ * @example
80
+ * await client.inboxes.metrics.queryRates("inbox_id")
81
+ */
82
+ queryRates(inbox_id: AgentMail.inboxes.InboxId, request?: AgentMail.inboxes.QueryRatesRequest, requestOptions?: MetricsClient.RequestOptions): core.HttpResponsePromise<AgentMail.QueryRatesResponse>;
83
+ private __queryRates;
56
84
  }
@@ -238,5 +238,103 @@ class MetricsClient {
238
238
  return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/v0/inboxes/{inbox_id}/metrics/usage");
239
239
  });
240
240
  }
241
+ /**
242
+ * Rolling bounce and complaint rates for the inbox. At each `period`
243
+ * grid point, the bounced (or complained) messages over the preceding
244
+ * `window` divided by the messages sent over the same window, with the
245
+ * send count alongside. Account moderation evaluates the organization-wide
246
+ * rate, so use the organization endpoint to see the number it acts on;
247
+ * the inbox view shows which inboxes contribute. Defaults to the rolling
248
+ * 24-hour rate sampled hourly over the last day; `start` must be within
249
+ * the last 90 days, `window` must be a whole multiple of `period`, and
250
+ * the range plus window divided by `period` must not exceed 1000
251
+ * buckets.
252
+ *
253
+ * **CLI:**
254
+ * ```bash
255
+ * agentmail inboxes metrics query-rates --inbox-id <inbox_id>
256
+ * ```
257
+ *
258
+ * @param {AgentMail.inboxes.InboxId} inbox_id
259
+ * @param {AgentMail.inboxes.QueryRatesRequest} request
260
+ * @param {MetricsClient.RequestOptions} requestOptions - Request-specific configuration.
261
+ *
262
+ * @throws {@link AgentMail.ValidationError}
263
+ *
264
+ * @example
265
+ * await client.inboxes.metrics.queryRates("inbox_id")
266
+ */
267
+ queryRates(inbox_id, request = {}, requestOptions) {
268
+ return core.HttpResponsePromise.fromPromise(this.__queryRates(inbox_id, request, requestOptions));
269
+ }
270
+ __queryRates(inbox_id_1) {
271
+ return __awaiter(this, arguments, void 0, function* (inbox_id, request = {}, requestOptions) {
272
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
273
+ const { rateTypes, start, end, period, window, limit, descending } = request;
274
+ const _queryParams = {
275
+ rate_types: rateTypes != null
276
+ ? (0, json_js_1.toJson)(serializers.RateTypes.jsonOrThrow(rateTypes, {
277
+ unrecognizedObjectKeys: "strip",
278
+ omitUndefined: true,
279
+ }))
280
+ : undefined,
281
+ start: start != null
282
+ ? serializers.Start.jsonOrThrow(start, { unrecognizedObjectKeys: "strip", omitUndefined: true })
283
+ : undefined,
284
+ end: end != null
285
+ ? serializers.End.jsonOrThrow(end, { unrecognizedObjectKeys: "strip", omitUndefined: true })
286
+ : undefined,
287
+ period,
288
+ window,
289
+ limit,
290
+ descending,
291
+ };
292
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
293
+ 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);
294
+ const _response = yield core.fetcher({
295
+ 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.Prod)
296
+ .http, `/v0/inboxes/${core.url.encodePathParam(serializers.inboxes.InboxId.jsonOrThrow(inbox_id, { omitUndefined: true }))}/metrics/rates`),
297
+ method: "GET",
298
+ headers: _headers,
299
+ queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
300
+ 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,
301
+ 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,
302
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
303
+ fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
304
+ logging: this._options.logging,
305
+ });
306
+ if (_response.ok) {
307
+ return {
308
+ data: serializers.QueryRatesResponse.parseOrThrow(_response.body, {
309
+ unrecognizedObjectKeys: "passthrough",
310
+ allowUnrecognizedUnionMembers: true,
311
+ allowUnrecognizedEnumValues: true,
312
+ skipValidation: true,
313
+ breadcrumbsPrefix: ["response"],
314
+ }),
315
+ rawResponse: _response.rawResponse,
316
+ };
317
+ }
318
+ if (_response.error.reason === "status-code") {
319
+ switch (_response.error.statusCode) {
320
+ case 400:
321
+ throw new AgentMail.ValidationError(serializers.ValidationErrorResponse.parseOrThrow(_response.error.body, {
322
+ unrecognizedObjectKeys: "passthrough",
323
+ allowUnrecognizedUnionMembers: true,
324
+ allowUnrecognizedEnumValues: true,
325
+ skipValidation: true,
326
+ breadcrumbsPrefix: ["response"],
327
+ }), _response.rawResponse);
328
+ default:
329
+ throw new errors.AgentMailError({
330
+ statusCode: _response.error.statusCode,
331
+ body: _response.error.body,
332
+ rawResponse: _response.rawResponse,
333
+ });
334
+ }
335
+ }
336
+ return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/v0/inboxes/{inbox_id}/metrics/rates");
337
+ });
338
+ }
241
339
  }
242
340
  exports.MetricsClient = MetricsClient;
@@ -0,0 +1,14 @@
1
+ import type * as AgentMail from "../../../../../../index.js";
2
+ /**
3
+ * @example
4
+ * {}
5
+ */
6
+ export interface QueryRatesRequest {
7
+ rateTypes?: AgentMail.RateTypes;
8
+ start?: AgentMail.Start;
9
+ end?: AgentMail.End;
10
+ period?: AgentMail.RatePeriod;
11
+ window?: AgentMail.Window;
12
+ limit?: AgentMail.MetricLimit;
13
+ descending?: AgentMail.Descending;
14
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +1,3 @@
1
1
  export type { QueryEventsRequest } from "./QueryEventsRequest.js";
2
+ export type { QueryRatesRequest } from "./QueryRatesRequest.js";
2
3
  export type { QueryUsageRequest } from "./QueryUsageRequest.js";
@@ -1,13 +1,13 @@
1
1
  import type * as AgentMail from "../../../index.js";
2
2
  /**
3
- * S3 presigned URL to download the raw .eml file.
3
+ * CloudFront signed URL to download the raw .eml file.
4
4
  */
5
5
  export interface RawMessageResponse {
6
6
  /** ID of the message. */
7
7
  messageId: AgentMail.MessageId;
8
8
  /** Size of the raw message in bytes. */
9
9
  size: AgentMail.MessageSize;
10
- /** S3 presigned URL to download the raw message. Expires at expires_at. */
10
+ /** CloudFront signed URL to download the raw message. Expires at expires_at. */
11
11
  downloadUrl: string;
12
12
  /** Time at which the download URL expires. */
13
13
  expiresAt: Date;
@@ -49,4 +49,32 @@ export declare class MetricsClient {
49
49
  */
50
50
  queryUsage(request?: AgentMail.QueryUsageRequest, requestOptions?: MetricsClient.RequestOptions): core.HttpResponsePromise<AgentMail.QueryUsageResponse>;
51
51
  private __queryUsage;
52
+ /**
53
+ * Rolling bounce and complaint rates for the organization. At each
54
+ * `period` grid point, the bounced (or complained) messages over the
55
+ * preceding `window` divided by the messages sent over the same window,
56
+ * with the send count alongside so you can see the volume behind
57
+ * it. This is the number AgentMail's account moderation acts on: a
58
+ * warning at a 5% bounce rate and suspension at 10%, evaluated over a
59
+ * rolling 24 hours once at least 1,000 messages were sent in that
60
+ * window. Defaults to the rolling 24-hour rate sampled hourly over the
61
+ * last day; `start` must be within the last 90 days, `window` must be a
62
+ * whole multiple of `period`, and the range plus window divided by
63
+ * `period` must not exceed 1000 buckets.
64
+ *
65
+ * **CLI:**
66
+ * ```bash
67
+ * agentmail metrics query-rates
68
+ * ```
69
+ *
70
+ * @param {AgentMail.QueryRatesRequest} request
71
+ * @param {MetricsClient.RequestOptions} requestOptions - Request-specific configuration.
72
+ *
73
+ * @throws {@link AgentMail.ValidationError}
74
+ *
75
+ * @example
76
+ * await client.metrics.queryRates()
77
+ */
78
+ queryRates(request?: AgentMail.QueryRatesRequest, requestOptions?: MetricsClient.RequestOptions): core.HttpResponsePromise<AgentMail.QueryRatesResponse>;
79
+ private __queryRates;
52
80
  }
@@ -234,5 +234,103 @@ class MetricsClient {
234
234
  return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/v0/metrics/usage");
235
235
  });
236
236
  }
237
+ /**
238
+ * Rolling bounce and complaint rates for the organization. At each
239
+ * `period` grid point, the bounced (or complained) messages over the
240
+ * preceding `window` divided by the messages sent over the same window,
241
+ * with the send count alongside so you can see the volume behind
242
+ * it. This is the number AgentMail's account moderation acts on: a
243
+ * warning at a 5% bounce rate and suspension at 10%, evaluated over a
244
+ * rolling 24 hours once at least 1,000 messages were sent in that
245
+ * window. Defaults to the rolling 24-hour rate sampled hourly over the
246
+ * last day; `start` must be within the last 90 days, `window` must be a
247
+ * whole multiple of `period`, and the range plus window divided by
248
+ * `period` must not exceed 1000 buckets.
249
+ *
250
+ * **CLI:**
251
+ * ```bash
252
+ * agentmail metrics query-rates
253
+ * ```
254
+ *
255
+ * @param {AgentMail.QueryRatesRequest} request
256
+ * @param {MetricsClient.RequestOptions} requestOptions - Request-specific configuration.
257
+ *
258
+ * @throws {@link AgentMail.ValidationError}
259
+ *
260
+ * @example
261
+ * await client.metrics.queryRates()
262
+ */
263
+ queryRates(request = {}, requestOptions) {
264
+ return core.HttpResponsePromise.fromPromise(this.__queryRates(request, requestOptions));
265
+ }
266
+ __queryRates() {
267
+ return __awaiter(this, arguments, void 0, function* (request = {}, requestOptions) {
268
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
269
+ const { rateTypes, start, end, period, window, limit, descending } = request;
270
+ const _queryParams = {
271
+ rate_types: rateTypes != null
272
+ ? (0, json_js_1.toJson)(serializers.RateTypes.jsonOrThrow(rateTypes, {
273
+ unrecognizedObjectKeys: "strip",
274
+ omitUndefined: true,
275
+ }))
276
+ : undefined,
277
+ start: start != null
278
+ ? serializers.Start.jsonOrThrow(start, { unrecognizedObjectKeys: "strip", omitUndefined: true })
279
+ : undefined,
280
+ end: end != null
281
+ ? serializers.End.jsonOrThrow(end, { unrecognizedObjectKeys: "strip", omitUndefined: true })
282
+ : undefined,
283
+ period,
284
+ window,
285
+ limit,
286
+ descending,
287
+ };
288
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
289
+ 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);
290
+ const _response = yield core.fetcher({
291
+ 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.Prod)
292
+ .http, "/v0/metrics/rates"),
293
+ method: "GET",
294
+ headers: _headers,
295
+ queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
296
+ 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,
297
+ 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,
298
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
299
+ fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
300
+ logging: this._options.logging,
301
+ });
302
+ if (_response.ok) {
303
+ return {
304
+ data: serializers.QueryRatesResponse.parseOrThrow(_response.body, {
305
+ unrecognizedObjectKeys: "passthrough",
306
+ allowUnrecognizedUnionMembers: true,
307
+ allowUnrecognizedEnumValues: true,
308
+ skipValidation: true,
309
+ breadcrumbsPrefix: ["response"],
310
+ }),
311
+ rawResponse: _response.rawResponse,
312
+ };
313
+ }
314
+ if (_response.error.reason === "status-code") {
315
+ switch (_response.error.statusCode) {
316
+ case 400:
317
+ throw new AgentMail.ValidationError(serializers.ValidationErrorResponse.parseOrThrow(_response.error.body, {
318
+ unrecognizedObjectKeys: "passthrough",
319
+ allowUnrecognizedUnionMembers: true,
320
+ allowUnrecognizedEnumValues: true,
321
+ skipValidation: true,
322
+ breadcrumbsPrefix: ["response"],
323
+ }), _response.rawResponse);
324
+ default:
325
+ throw new errors.AgentMailError({
326
+ statusCode: _response.error.statusCode,
327
+ body: _response.error.body,
328
+ rawResponse: _response.rawResponse,
329
+ });
330
+ }
331
+ }
332
+ return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/v0/metrics/rates");
333
+ });
334
+ }
237
335
  }
238
336
  exports.MetricsClient = MetricsClient;
@@ -0,0 +1,14 @@
1
+ import type * as AgentMail from "../../../../index.js";
2
+ /**
3
+ * @example
4
+ * {}
5
+ */
6
+ export interface QueryRatesRequest {
7
+ rateTypes?: AgentMail.RateTypes;
8
+ start?: AgentMail.Start;
9
+ end?: AgentMail.End;
10
+ period?: AgentMail.RatePeriod;
11
+ window?: AgentMail.Window;
12
+ limit?: AgentMail.MetricLimit;
13
+ descending?: AgentMail.Descending;
14
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +1,3 @@
1
1
  export type { QueryEventsRequest } from "./QueryEventsRequest.js";
2
+ export type { QueryRatesRequest } from "./QueryRatesRequest.js";
2
3
  export type { QueryUsageRequest } from "./QueryUsageRequest.js";
@@ -0,0 +1,5 @@
1
+ import type * as AgentMail from "../../../index.js";
2
+ /**
3
+ * Rate series grouped by rate type.
4
+ */
5
+ export type QueryRatesResponse = Partial<Record<AgentMail.RateType, AgentMail.RatePoint[]>>;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,5 @@
1
+ /**
2
+ * How often a point is sampled, as a whole number of seconds between 60
3
+ * and 86400. Defaults to 3600 (one point per hour).
4
+ */
5
+ export type RatePeriod = number;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,12 @@
1
+ export interface RatePoint {
2
+ /** End of the window the point covers; the window is the `window` seconds before it. */
3
+ timestamp: Date;
4
+ /**
5
+ * Bounced or complained messages divided by messages sent over the
6
+ * window, as a fraction (0.05 is 5%). Null when nothing was sent in
7
+ * the window.
8
+ */
9
+ rate?: number;
10
+ /** Messages sent in the window, counted per recipient. */
11
+ sent: number;
12
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Type of rate. `bounce` is bounced messages divided by messages sent,
3
+ * counting permanent and transient bounces; `complaint` is spam complaints
4
+ * divided by messages sent.
5
+ */
6
+ export declare const RateType: {
7
+ readonly Bounce: "bounce";
8
+ readonly Complaint: "complaint";
9
+ };
10
+ export type RateType = (typeof RateType)[keyof typeof RateType];
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.RateType = void 0;
5
+ /**
6
+ * Type of rate. `bounce` is bounced messages divided by messages sent,
7
+ * counting permanent and transient bounces; `complaint` is spam complaints
8
+ * divided by messages sent.
9
+ */
10
+ exports.RateType = {
11
+ Bounce: "bounce",
12
+ Complaint: "complaint",
13
+ };
@@ -0,0 +1,5 @@
1
+ import type * as AgentMail from "../../../index.js";
2
+ /**
3
+ * List of rate types to query. Omit to query both.
4
+ */
5
+ export type RateTypes = AgentMail.RateType[];
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,6 @@
1
+ /**
2
+ * How far back each point looks, as a whole number of seconds. Must be a
3
+ * whole multiple of `period`, at most 30 days (2592000). Defaults to 86400
4
+ * (a rolling 24-hour rate).
5
+ */
6
+ export type Window = number;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -6,8 +6,14 @@ export * from "./MetricEventTypes.js";
6
6
  export * from "./MetricLimit.js";
7
7
  export * from "./Period.js";
8
8
  export * from "./QueryMetricsResponse.js";
9
+ export * from "./QueryRatesResponse.js";
9
10
  export * from "./QueryUsageResponse.js";
11
+ export * from "./RatePeriod.js";
12
+ export * from "./RatePoint.js";
13
+ export * from "./RateType.js";
14
+ export * from "./RateTypes.js";
10
15
  export * from "./Start.js";
11
16
  export * from "./UsagePoint.js";
12
17
  export * from "./UsageType.js";
13
18
  export * from "./UsageTypes.js";
19
+ export * from "./Window.js";
@@ -22,8 +22,14 @@ __exportStar(require("./MetricEventTypes.js"), exports);
22
22
  __exportStar(require("./MetricLimit.js"), exports);
23
23
  __exportStar(require("./Period.js"), exports);
24
24
  __exportStar(require("./QueryMetricsResponse.js"), exports);
25
+ __exportStar(require("./QueryRatesResponse.js"), exports);
25
26
  __exportStar(require("./QueryUsageResponse.js"), exports);
27
+ __exportStar(require("./RatePeriod.js"), exports);
28
+ __exportStar(require("./RatePoint.js"), exports);
29
+ __exportStar(require("./RateType.js"), exports);
30
+ __exportStar(require("./RateTypes.js"), exports);
26
31
  __exportStar(require("./Start.js"), exports);
27
32
  __exportStar(require("./UsagePoint.js"), exports);
28
33
  __exportStar(require("./UsageType.js"), exports);
29
34
  __exportStar(require("./UsageTypes.js"), exports);
35
+ __exportStar(require("./Window.js"), exports);
@@ -53,4 +53,32 @@ export declare class MetricsClient {
53
53
  */
54
54
  queryUsage(pod_id: AgentMail.pods.PodId, request?: AgentMail.pods.QueryUsageRequest, requestOptions?: MetricsClient.RequestOptions): core.HttpResponsePromise<AgentMail.QueryUsageResponse>;
55
55
  private __queryUsage;
56
+ /**
57
+ * Rolling bounce and complaint rates for the pod. At each `period` grid
58
+ * point, the bounced (or complained) messages over the preceding
59
+ * `window` divided by the messages sent over the same window, with the
60
+ * send count alongside. Account moderation evaluates the organization-wide
61
+ * rate, so use the organization endpoint to see the number it acts on;
62
+ * the pod view shows which pods contribute. Defaults to the rolling
63
+ * 24-hour rate sampled hourly over the last day; `start` must be within
64
+ * the last 90 days, `window` must be a whole multiple of `period`, and
65
+ * the range plus window divided by `period` must not exceed 1000
66
+ * buckets.
67
+ *
68
+ * **CLI:**
69
+ * ```bash
70
+ * agentmail pods metrics query-rates --pod-id <pod_id>
71
+ * ```
72
+ *
73
+ * @param {AgentMail.pods.PodId} pod_id
74
+ * @param {AgentMail.pods.QueryRatesRequest} request
75
+ * @param {MetricsClient.RequestOptions} requestOptions - Request-specific configuration.
76
+ *
77
+ * @throws {@link AgentMail.ValidationError}
78
+ *
79
+ * @example
80
+ * await client.pods.metrics.queryRates("pod_id")
81
+ */
82
+ queryRates(pod_id: AgentMail.pods.PodId, request?: AgentMail.pods.QueryRatesRequest, requestOptions?: MetricsClient.RequestOptions): core.HttpResponsePromise<AgentMail.QueryRatesResponse>;
83
+ private __queryRates;
56
84
  }
@@ -238,5 +238,103 @@ class MetricsClient {
238
238
  return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/v0/pods/{pod_id}/metrics/usage");
239
239
  });
240
240
  }
241
+ /**
242
+ * Rolling bounce and complaint rates for the pod. At each `period` grid
243
+ * point, the bounced (or complained) messages over the preceding
244
+ * `window` divided by the messages sent over the same window, with the
245
+ * send count alongside. Account moderation evaluates the organization-wide
246
+ * rate, so use the organization endpoint to see the number it acts on;
247
+ * the pod view shows which pods contribute. Defaults to the rolling
248
+ * 24-hour rate sampled hourly over the last day; `start` must be within
249
+ * the last 90 days, `window` must be a whole multiple of `period`, and
250
+ * the range plus window divided by `period` must not exceed 1000
251
+ * buckets.
252
+ *
253
+ * **CLI:**
254
+ * ```bash
255
+ * agentmail pods metrics query-rates --pod-id <pod_id>
256
+ * ```
257
+ *
258
+ * @param {AgentMail.pods.PodId} pod_id
259
+ * @param {AgentMail.pods.QueryRatesRequest} request
260
+ * @param {MetricsClient.RequestOptions} requestOptions - Request-specific configuration.
261
+ *
262
+ * @throws {@link AgentMail.ValidationError}
263
+ *
264
+ * @example
265
+ * await client.pods.metrics.queryRates("pod_id")
266
+ */
267
+ queryRates(pod_id, request = {}, requestOptions) {
268
+ return core.HttpResponsePromise.fromPromise(this.__queryRates(pod_id, request, requestOptions));
269
+ }
270
+ __queryRates(pod_id_1) {
271
+ return __awaiter(this, arguments, void 0, function* (pod_id, request = {}, requestOptions) {
272
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
273
+ const { rateTypes, start, end, period, window, limit, descending } = request;
274
+ const _queryParams = {
275
+ rate_types: rateTypes != null
276
+ ? (0, json_js_1.toJson)(serializers.RateTypes.jsonOrThrow(rateTypes, {
277
+ unrecognizedObjectKeys: "strip",
278
+ omitUndefined: true,
279
+ }))
280
+ : undefined,
281
+ start: start != null
282
+ ? serializers.Start.jsonOrThrow(start, { unrecognizedObjectKeys: "strip", omitUndefined: true })
283
+ : undefined,
284
+ end: end != null
285
+ ? serializers.End.jsonOrThrow(end, { unrecognizedObjectKeys: "strip", omitUndefined: true })
286
+ : undefined,
287
+ period,
288
+ window,
289
+ limit,
290
+ descending,
291
+ };
292
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
293
+ 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);
294
+ const _response = yield core.fetcher({
295
+ 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.Prod)
296
+ .http, `/v0/pods/${core.url.encodePathParam(serializers.pods.PodId.jsonOrThrow(pod_id, { omitUndefined: true }))}/metrics/rates`),
297
+ method: "GET",
298
+ headers: _headers,
299
+ queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
300
+ 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,
301
+ 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,
302
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
303
+ fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
304
+ logging: this._options.logging,
305
+ });
306
+ if (_response.ok) {
307
+ return {
308
+ data: serializers.QueryRatesResponse.parseOrThrow(_response.body, {
309
+ unrecognizedObjectKeys: "passthrough",
310
+ allowUnrecognizedUnionMembers: true,
311
+ allowUnrecognizedEnumValues: true,
312
+ skipValidation: true,
313
+ breadcrumbsPrefix: ["response"],
314
+ }),
315
+ rawResponse: _response.rawResponse,
316
+ };
317
+ }
318
+ if (_response.error.reason === "status-code") {
319
+ switch (_response.error.statusCode) {
320
+ case 400:
321
+ throw new AgentMail.ValidationError(serializers.ValidationErrorResponse.parseOrThrow(_response.error.body, {
322
+ unrecognizedObjectKeys: "passthrough",
323
+ allowUnrecognizedUnionMembers: true,
324
+ allowUnrecognizedEnumValues: true,
325
+ skipValidation: true,
326
+ breadcrumbsPrefix: ["response"],
327
+ }), _response.rawResponse);
328
+ default:
329
+ throw new errors.AgentMailError({
330
+ statusCode: _response.error.statusCode,
331
+ body: _response.error.body,
332
+ rawResponse: _response.rawResponse,
333
+ });
334
+ }
335
+ }
336
+ return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/v0/pods/{pod_id}/metrics/rates");
337
+ });
338
+ }
241
339
  }
242
340
  exports.MetricsClient = MetricsClient;