agentmail 0.5.11 → 0.5.12

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 (104) hide show
  1. package/dist/cjs/BaseClient.js +2 -2
  2. package/dist/cjs/api/resources/inboxes/resources/metrics/client/Client.d.ts +30 -4
  3. package/dist/cjs/api/resources/inboxes/resources/metrics/client/Client.js +102 -7
  4. package/dist/cjs/api/resources/inboxes/resources/metrics/client/requests/{QueryMetricsRequest.d.ts → QueryEventsRequest.d.ts} +1 -1
  5. package/dist/cjs/api/resources/inboxes/resources/metrics/client/requests/QueryUsageRequest.d.ts +13 -0
  6. package/dist/cjs/api/resources/inboxes/resources/metrics/client/requests/index.d.ts +2 -1
  7. package/dist/cjs/api/resources/metrics/client/Client.d.ts +27 -4
  8. package/dist/cjs/api/resources/metrics/client/Client.js +99 -7
  9. package/dist/cjs/api/resources/metrics/client/requests/{QueryMetricsRequest.d.ts → QueryEventsRequest.d.ts} +1 -1
  10. package/dist/cjs/api/resources/metrics/client/requests/QueryUsageRequest.d.ts +13 -0
  11. package/dist/cjs/api/resources/metrics/client/requests/QueryUsageRequest.js +3 -0
  12. package/dist/cjs/api/resources/metrics/client/requests/index.d.ts +2 -1
  13. package/dist/cjs/api/resources/metrics/types/MetricEventType.d.ts +6 -3
  14. package/dist/cjs/api/resources/metrics/types/MetricEventType.js +6 -3
  15. package/dist/cjs/api/resources/metrics/types/Period.d.ts +2 -2
  16. package/dist/cjs/api/resources/metrics/types/QueryUsageResponse.d.ts +5 -0
  17. package/dist/cjs/api/resources/metrics/types/QueryUsageResponse.js +3 -0
  18. package/dist/cjs/api/resources/metrics/types/UsagePoint.d.ts +6 -0
  19. package/dist/cjs/api/resources/metrics/types/UsagePoint.js +3 -0
  20. package/dist/cjs/api/resources/metrics/types/UsageType.d.ts +14 -0
  21. package/dist/cjs/api/resources/metrics/types/UsageType.js +17 -0
  22. package/dist/cjs/api/resources/metrics/types/UsageTypes.d.ts +5 -0
  23. package/dist/cjs/api/resources/metrics/types/UsageTypes.js +3 -0
  24. package/dist/cjs/api/resources/metrics/types/index.d.ts +4 -0
  25. package/dist/cjs/api/resources/metrics/types/index.js +4 -0
  26. package/dist/cjs/api/resources/pods/resources/metrics/client/Client.d.ts +30 -4
  27. package/dist/cjs/api/resources/pods/resources/metrics/client/Client.js +102 -7
  28. package/dist/cjs/api/resources/pods/resources/metrics/client/requests/{QueryMetricsRequest.d.ts → QueryEventsRequest.d.ts} +1 -1
  29. package/dist/cjs/api/resources/pods/resources/metrics/client/requests/QueryEventsRequest.js +3 -0
  30. package/dist/cjs/api/resources/pods/resources/metrics/client/requests/QueryUsageRequest.d.ts +13 -0
  31. package/dist/cjs/api/resources/pods/resources/metrics/client/requests/QueryUsageRequest.js +3 -0
  32. package/dist/cjs/api/resources/pods/resources/metrics/client/requests/index.d.ts +2 -1
  33. package/dist/cjs/serialization/resources/metrics/types/MetricEventType.d.ts +1 -1
  34. package/dist/cjs/serialization/resources/metrics/types/MetricEventType.js +6 -3
  35. package/dist/cjs/serialization/resources/metrics/types/Period.d.ts +1 -1
  36. package/dist/cjs/serialization/resources/metrics/types/Period.js +1 -1
  37. package/dist/cjs/serialization/resources/metrics/types/QueryUsageResponse.d.ts +9 -0
  38. package/dist/cjs/serialization/resources/metrics/types/QueryUsageResponse.js +41 -0
  39. package/dist/cjs/serialization/resources/metrics/types/UsagePoint.d.ts +10 -0
  40. package/dist/cjs/serialization/resources/metrics/types/UsagePoint.js +42 -0
  41. package/dist/cjs/serialization/resources/metrics/types/UsageType.d.ts +7 -0
  42. package/dist/cjs/serialization/resources/metrics/types/UsageType.js +46 -0
  43. package/dist/cjs/serialization/resources/metrics/types/UsageTypes.d.ts +8 -0
  44. package/dist/cjs/serialization/resources/metrics/types/UsageTypes.js +40 -0
  45. package/dist/cjs/serialization/resources/metrics/types/index.d.ts +4 -0
  46. package/dist/cjs/serialization/resources/metrics/types/index.js +4 -0
  47. package/dist/cjs/version.d.ts +1 -1
  48. package/dist/cjs/version.js +1 -1
  49. package/dist/esm/BaseClient.mjs +2 -2
  50. package/dist/esm/api/resources/inboxes/resources/metrics/client/Client.d.mts +30 -4
  51. package/dist/esm/api/resources/inboxes/resources/metrics/client/Client.mjs +102 -7
  52. package/dist/esm/api/resources/{pods/resources/metrics/client/requests/QueryMetricsRequest.d.mts → inboxes/resources/metrics/client/requests/QueryEventsRequest.d.mts} +1 -1
  53. package/dist/esm/api/resources/inboxes/resources/metrics/client/requests/QueryUsageRequest.d.mts +13 -0
  54. package/dist/esm/api/resources/inboxes/resources/metrics/client/requests/index.d.mts +2 -1
  55. package/dist/esm/api/resources/metrics/client/Client.d.mts +27 -4
  56. package/dist/esm/api/resources/metrics/client/Client.mjs +99 -7
  57. package/dist/esm/api/resources/metrics/client/requests/{QueryMetricsRequest.d.mts → QueryEventsRequest.d.mts} +1 -1
  58. package/dist/esm/api/resources/metrics/client/requests/QueryUsageRequest.d.mts +13 -0
  59. package/dist/esm/api/resources/metrics/client/requests/QueryUsageRequest.mjs +2 -0
  60. package/dist/esm/api/resources/metrics/client/requests/index.d.mts +2 -1
  61. package/dist/esm/api/resources/metrics/types/MetricEventType.d.mts +6 -3
  62. package/dist/esm/api/resources/metrics/types/MetricEventType.mjs +6 -3
  63. package/dist/esm/api/resources/metrics/types/Period.d.mts +2 -2
  64. package/dist/esm/api/resources/metrics/types/QueryUsageResponse.d.mts +5 -0
  65. package/dist/esm/api/resources/metrics/types/QueryUsageResponse.mjs +2 -0
  66. package/dist/esm/api/resources/metrics/types/UsagePoint.d.mts +6 -0
  67. package/dist/esm/api/resources/metrics/types/UsagePoint.mjs +2 -0
  68. package/dist/esm/api/resources/metrics/types/UsageType.d.mts +14 -0
  69. package/dist/esm/api/resources/metrics/types/UsageType.mjs +14 -0
  70. package/dist/esm/api/resources/metrics/types/UsageTypes.d.mts +5 -0
  71. package/dist/esm/api/resources/metrics/types/UsageTypes.mjs +2 -0
  72. package/dist/esm/api/resources/metrics/types/index.d.mts +4 -0
  73. package/dist/esm/api/resources/metrics/types/index.mjs +4 -0
  74. package/dist/esm/api/resources/pods/resources/metrics/client/Client.d.mts +30 -4
  75. package/dist/esm/api/resources/pods/resources/metrics/client/Client.mjs +102 -7
  76. package/dist/esm/api/resources/{inboxes/resources/metrics/client/requests/QueryMetricsRequest.d.mts → pods/resources/metrics/client/requests/QueryEventsRequest.d.mts} +1 -1
  77. package/dist/esm/api/resources/pods/resources/metrics/client/requests/QueryEventsRequest.mjs +2 -0
  78. package/dist/esm/api/resources/pods/resources/metrics/client/requests/QueryUsageRequest.d.mts +13 -0
  79. package/dist/esm/api/resources/pods/resources/metrics/client/requests/QueryUsageRequest.mjs +2 -0
  80. package/dist/esm/api/resources/pods/resources/metrics/client/requests/index.d.mts +2 -1
  81. package/dist/esm/serialization/resources/metrics/types/MetricEventType.d.mts +1 -1
  82. package/dist/esm/serialization/resources/metrics/types/MetricEventType.mjs +6 -3
  83. package/dist/esm/serialization/resources/metrics/types/Period.d.mts +1 -1
  84. package/dist/esm/serialization/resources/metrics/types/Period.mjs +1 -1
  85. package/dist/esm/serialization/resources/metrics/types/QueryUsageResponse.d.mts +9 -0
  86. package/dist/esm/serialization/resources/metrics/types/QueryUsageResponse.mjs +5 -0
  87. package/dist/esm/serialization/resources/metrics/types/UsagePoint.d.mts +10 -0
  88. package/dist/esm/serialization/resources/metrics/types/UsagePoint.mjs +6 -0
  89. package/dist/esm/serialization/resources/metrics/types/UsageType.d.mts +7 -0
  90. package/dist/esm/serialization/resources/metrics/types/UsageType.mjs +10 -0
  91. package/dist/esm/serialization/resources/metrics/types/UsageTypes.d.mts +8 -0
  92. package/dist/esm/serialization/resources/metrics/types/UsageTypes.mjs +4 -0
  93. package/dist/esm/serialization/resources/metrics/types/index.d.mts +4 -0
  94. package/dist/esm/serialization/resources/metrics/types/index.mjs +4 -0
  95. package/dist/esm/version.d.mts +1 -1
  96. package/dist/esm/version.mjs +1 -1
  97. package/package.json +1 -1
  98. package/reference.md +248 -9
  99. /package/dist/cjs/api/resources/inboxes/resources/metrics/client/requests/{QueryMetricsRequest.js → QueryEventsRequest.js} +0 -0
  100. /package/dist/cjs/api/resources/{metrics/client/requests/QueryMetricsRequest.js → inboxes/resources/metrics/client/requests/QueryUsageRequest.js} +0 -0
  101. /package/dist/cjs/api/resources/{pods/resources/metrics/client/requests/QueryMetricsRequest.js → metrics/client/requests/QueryEventsRequest.js} +0 -0
  102. /package/dist/esm/api/resources/inboxes/resources/metrics/client/requests/{QueryMetricsRequest.mjs → QueryEventsRequest.mjs} +0 -0
  103. /package/dist/esm/api/resources/{metrics/client/requests/QueryMetricsRequest.mjs → inboxes/resources/metrics/client/requests/QueryUsageRequest.mjs} +0 -0
  104. /package/dist/esm/api/resources/{pods/resources/metrics/client/requests/QueryMetricsRequest.mjs → metrics/client/requests/QueryEventsRequest.mjs} +0 -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.11",
47
- "User-Agent": "agentmail/0.5.11",
46
+ "X-Fern-SDK-Version": "0.5.12",
47
+ "User-Agent": "agentmail/0.5.12",
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);
@@ -11,20 +11,46 @@ export declare class MetricsClient {
11
11
  protected readonly _options: NormalizedClientOptionsWithAuth<MetricsClient.Options>;
12
12
  constructor(options?: MetricsClient.Options);
13
13
  /**
14
+ * Counts of email events (sent, delivered, bounced, etc.) over time for
15
+ * the inbox. Defaults to the last 24 hours; `start` must be within the
16
+ * last 90 days, and a future `end` is clamped to now. Omit `period` for
17
+ * individual event counts, or set it to sum counts into buckets of that
18
+ * many seconds.
19
+ *
14
20
  * **CLI:**
15
21
  * ```bash
16
22
  * agentmail inboxes:metrics query --inbox-id <inbox_id>
17
23
  * ```
18
24
  *
19
25
  * @param {AgentMail.inboxes.InboxId} inbox_id
20
- * @param {AgentMail.inboxes.QueryMetricsRequest} request
26
+ * @param {AgentMail.inboxes.QueryEventsRequest} request
27
+ * @param {MetricsClient.RequestOptions} requestOptions - Request-specific configuration.
28
+ *
29
+ * @throws {@link AgentMail.ValidationError}
30
+ *
31
+ * @example
32
+ * await client.inboxes.metrics.queryEvents("inbox_id")
33
+ */
34
+ queryEvents(inbox_id: AgentMail.inboxes.InboxId, request?: AgentMail.inboxes.QueryEventsRequest, requestOptions?: MetricsClient.RequestOptions): core.HttpResponsePromise<AgentMail.QueryMetricsResponse>;
35
+ private __queryEvents;
36
+ /**
37
+ * Cumulative usage series for the inbox. Each point is the running total
38
+ * of the usage type at that timestamp, not the change within the bucket.
39
+ * Inbox-scoped queries carry `storage_bytes`, `message_count`, and
40
+ * `thread_count`; requested types that don't apply to the scope are
41
+ * ignored. Defaults to the last 24 hours; `start` must be within the
42
+ * last 90 days, and a future `end` is clamped to now. The range divided
43
+ * by `period` must not exceed 1000 buckets.
44
+ *
45
+ * @param {AgentMail.inboxes.InboxId} inbox_id
46
+ * @param {AgentMail.inboxes.QueryUsageRequest} request
21
47
  * @param {MetricsClient.RequestOptions} requestOptions - Request-specific configuration.
22
48
  *
23
49
  * @throws {@link AgentMail.ValidationError}
24
50
  *
25
51
  * @example
26
- * await client.inboxes.metrics.query("inbox_id")
52
+ * await client.inboxes.metrics.queryUsage("inbox_id")
27
53
  */
28
- query(inbox_id: AgentMail.inboxes.InboxId, request?: AgentMail.inboxes.QueryMetricsRequest, requestOptions?: MetricsClient.RequestOptions): core.HttpResponsePromise<AgentMail.QueryMetricsResponse>;
29
- private __query;
54
+ queryUsage(inbox_id: AgentMail.inboxes.InboxId, request?: AgentMail.inboxes.QueryUsageRequest, requestOptions?: MetricsClient.RequestOptions): core.HttpResponsePromise<AgentMail.QueryUsageResponse>;
55
+ private __queryUsage;
30
56
  }
@@ -58,24 +58,30 @@ class MetricsClient {
58
58
  this._options = (0, BaseClient_js_1.normalizeClientOptionsWithAuth)(options);
59
59
  }
60
60
  /**
61
+ * Counts of email events (sent, delivered, bounced, etc.) over time for
62
+ * the inbox. Defaults to the last 24 hours; `start` must be within the
63
+ * last 90 days, and a future `end` is clamped to now. Omit `period` for
64
+ * individual event counts, or set it to sum counts into buckets of that
65
+ * many seconds.
66
+ *
61
67
  * **CLI:**
62
68
  * ```bash
63
69
  * agentmail inboxes:metrics query --inbox-id <inbox_id>
64
70
  * ```
65
71
  *
66
72
  * @param {AgentMail.inboxes.InboxId} inbox_id
67
- * @param {AgentMail.inboxes.QueryMetricsRequest} request
73
+ * @param {AgentMail.inboxes.QueryEventsRequest} request
68
74
  * @param {MetricsClient.RequestOptions} requestOptions - Request-specific configuration.
69
75
  *
70
76
  * @throws {@link AgentMail.ValidationError}
71
77
  *
72
78
  * @example
73
- * await client.inboxes.metrics.query("inbox_id")
79
+ * await client.inboxes.metrics.queryEvents("inbox_id")
74
80
  */
75
- query(inbox_id, request = {}, requestOptions) {
76
- return core.HttpResponsePromise.fromPromise(this.__query(inbox_id, request, requestOptions));
81
+ queryEvents(inbox_id, request = {}, requestOptions) {
82
+ return core.HttpResponsePromise.fromPromise(this.__queryEvents(inbox_id, request, requestOptions));
77
83
  }
78
- __query(inbox_id_1) {
84
+ __queryEvents(inbox_id_1) {
79
85
  return __awaiter(this, arguments, void 0, function* (inbox_id, request = {}, requestOptions) {
80
86
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
81
87
  const { eventTypes, start, end, period, limit, descending } = request;
@@ -100,7 +106,7 @@ class MetricsClient {
100
106
  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);
101
107
  const _response = yield core.fetcher({
102
108
  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)
103
- .http, `/v0/inboxes/${core.url.encodePathParam(serializers.inboxes.InboxId.jsonOrThrow(inbox_id, { omitUndefined: true }))}/metrics`),
109
+ .http, `/v0/inboxes/${core.url.encodePathParam(serializers.inboxes.InboxId.jsonOrThrow(inbox_id, { omitUndefined: true }))}/metrics/events`),
104
110
  method: "GET",
105
111
  headers: _headers,
106
112
  queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
@@ -140,7 +146,96 @@ class MetricsClient {
140
146
  });
141
147
  }
142
148
  }
143
- return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/v0/inboxes/{inbox_id}/metrics");
149
+ return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/v0/inboxes/{inbox_id}/metrics/events");
150
+ });
151
+ }
152
+ /**
153
+ * Cumulative usage series for the inbox. Each point is the running total
154
+ * of the usage type at that timestamp, not the change within the bucket.
155
+ * Inbox-scoped queries carry `storage_bytes`, `message_count`, and
156
+ * `thread_count`; requested types that don't apply to the scope are
157
+ * ignored. Defaults to the last 24 hours; `start` must be within the
158
+ * last 90 days, and a future `end` is clamped to now. The range divided
159
+ * by `period` must not exceed 1000 buckets.
160
+ *
161
+ * @param {AgentMail.inboxes.InboxId} inbox_id
162
+ * @param {AgentMail.inboxes.QueryUsageRequest} request
163
+ * @param {MetricsClient.RequestOptions} requestOptions - Request-specific configuration.
164
+ *
165
+ * @throws {@link AgentMail.ValidationError}
166
+ *
167
+ * @example
168
+ * await client.inboxes.metrics.queryUsage("inbox_id")
169
+ */
170
+ queryUsage(inbox_id, request = {}, requestOptions) {
171
+ return core.HttpResponsePromise.fromPromise(this.__queryUsage(inbox_id, request, requestOptions));
172
+ }
173
+ __queryUsage(inbox_id_1) {
174
+ return __awaiter(this, arguments, void 0, function* (inbox_id, request = {}, requestOptions) {
175
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
176
+ const { usageTypes, start, end, period, limit, descending } = request;
177
+ const _queryParams = {
178
+ usage_types: usageTypes != null
179
+ ? (0, json_js_1.toJson)(serializers.UsageTypes.jsonOrThrow(usageTypes, {
180
+ unrecognizedObjectKeys: "strip",
181
+ omitUndefined: true,
182
+ }))
183
+ : undefined,
184
+ start: start != null
185
+ ? serializers.Start.jsonOrThrow(start, { unrecognizedObjectKeys: "strip", omitUndefined: true })
186
+ : undefined,
187
+ end: end != null
188
+ ? serializers.End.jsonOrThrow(end, { unrecognizedObjectKeys: "strip", omitUndefined: true })
189
+ : undefined,
190
+ period,
191
+ limit,
192
+ descending,
193
+ };
194
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
195
+ 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);
196
+ const _response = yield core.fetcher({
197
+ 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)
198
+ .http, `/v0/inboxes/${core.url.encodePathParam(serializers.inboxes.InboxId.jsonOrThrow(inbox_id, { omitUndefined: true }))}/metrics/usage`),
199
+ method: "GET",
200
+ headers: _headers,
201
+ queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
202
+ 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,
203
+ 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,
204
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
205
+ fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
206
+ logging: this._options.logging,
207
+ });
208
+ if (_response.ok) {
209
+ return {
210
+ data: serializers.QueryUsageResponse.parseOrThrow(_response.body, {
211
+ unrecognizedObjectKeys: "passthrough",
212
+ allowUnrecognizedUnionMembers: true,
213
+ allowUnrecognizedEnumValues: true,
214
+ skipValidation: true,
215
+ breadcrumbsPrefix: ["response"],
216
+ }),
217
+ rawResponse: _response.rawResponse,
218
+ };
219
+ }
220
+ if (_response.error.reason === "status-code") {
221
+ switch (_response.error.statusCode) {
222
+ case 400:
223
+ throw new AgentMail.ValidationError(serializers.ValidationErrorResponse.parseOrThrow(_response.error.body, {
224
+ unrecognizedObjectKeys: "passthrough",
225
+ allowUnrecognizedUnionMembers: true,
226
+ allowUnrecognizedEnumValues: true,
227
+ skipValidation: true,
228
+ breadcrumbsPrefix: ["response"],
229
+ }), _response.rawResponse);
230
+ default:
231
+ throw new errors.AgentMailError({
232
+ statusCode: _response.error.statusCode,
233
+ body: _response.error.body,
234
+ rawResponse: _response.rawResponse,
235
+ });
236
+ }
237
+ }
238
+ return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/v0/inboxes/{inbox_id}/metrics/usage");
144
239
  });
145
240
  }
146
241
  }
@@ -3,7 +3,7 @@ import type * as AgentMail from "../../../../../../index.js";
3
3
  * @example
4
4
  * {}
5
5
  */
6
- export interface QueryMetricsRequest {
6
+ export interface QueryEventsRequest {
7
7
  eventTypes?: AgentMail.MetricEventTypes;
8
8
  start?: AgentMail.Start;
9
9
  end?: AgentMail.End;
@@ -0,0 +1,13 @@
1
+ import type * as AgentMail from "../../../../../../index.js";
2
+ /**
3
+ * @example
4
+ * {}
5
+ */
6
+ export interface QueryUsageRequest {
7
+ usageTypes?: AgentMail.UsageTypes;
8
+ start?: AgentMail.Start;
9
+ end?: AgentMail.End;
10
+ period?: AgentMail.Period;
11
+ limit?: AgentMail.MetricLimit;
12
+ descending?: AgentMail.Descending;
13
+ }
@@ -1 +1,2 @@
1
- export type { QueryMetricsRequest } from "./QueryMetricsRequest.js";
1
+ export type { QueryEventsRequest } from "./QueryEventsRequest.js";
2
+ export type { QueryUsageRequest } from "./QueryUsageRequest.js";
@@ -11,19 +11,42 @@ export declare class MetricsClient {
11
11
  protected readonly _options: NormalizedClientOptionsWithAuth<MetricsClient.Options>;
12
12
  constructor(options?: MetricsClient.Options);
13
13
  /**
14
+ * Counts of email events (sent, delivered, bounced, etc.) over time for
15
+ * the organization. Defaults to the last 24 hours; `start` must be within
16
+ * the last 90 days, and a future `end` is clamped to now. Omit `period`
17
+ * for individual event counts, or set it to sum counts into buckets of
18
+ * that many seconds.
19
+ *
14
20
  * **CLI:**
15
21
  * ```bash
16
22
  * agentmail metrics list
17
23
  * ```
18
24
  *
19
- * @param {AgentMail.QueryMetricsRequest} request
25
+ * @param {AgentMail.QueryEventsRequest} request
26
+ * @param {MetricsClient.RequestOptions} requestOptions - Request-specific configuration.
27
+ *
28
+ * @throws {@link AgentMail.ValidationError}
29
+ *
30
+ * @example
31
+ * await client.metrics.queryEvents()
32
+ */
33
+ queryEvents(request?: AgentMail.QueryEventsRequest, requestOptions?: MetricsClient.RequestOptions): core.HttpResponsePromise<AgentMail.QueryMetricsResponse>;
34
+ private __queryEvents;
35
+ /**
36
+ * Cumulative usage series for the organization. Each point is the running
37
+ * total of the usage type at that timestamp, not the change within the
38
+ * bucket. Defaults to the last 24 hours; `start` must be within the last
39
+ * 90 days, and a future `end` is clamped to now. The range divided by
40
+ * `period` must not exceed 1000 buckets.
41
+ *
42
+ * @param {AgentMail.QueryUsageRequest} request
20
43
  * @param {MetricsClient.RequestOptions} requestOptions - Request-specific configuration.
21
44
  *
22
45
  * @throws {@link AgentMail.ValidationError}
23
46
  *
24
47
  * @example
25
- * await client.metrics.query()
48
+ * await client.metrics.queryUsage()
26
49
  */
27
- query(request?: AgentMail.QueryMetricsRequest, requestOptions?: MetricsClient.RequestOptions): core.HttpResponsePromise<AgentMail.QueryMetricsResponse>;
28
- private __query;
50
+ queryUsage(request?: AgentMail.QueryUsageRequest, requestOptions?: MetricsClient.RequestOptions): core.HttpResponsePromise<AgentMail.QueryUsageResponse>;
51
+ private __queryUsage;
29
52
  }
@@ -58,23 +58,29 @@ class MetricsClient {
58
58
  this._options = (0, BaseClient_js_1.normalizeClientOptionsWithAuth)(options);
59
59
  }
60
60
  /**
61
+ * Counts of email events (sent, delivered, bounced, etc.) over time for
62
+ * the organization. Defaults to the last 24 hours; `start` must be within
63
+ * the last 90 days, and a future `end` is clamped to now. Omit `period`
64
+ * for individual event counts, or set it to sum counts into buckets of
65
+ * that many seconds.
66
+ *
61
67
  * **CLI:**
62
68
  * ```bash
63
69
  * agentmail metrics list
64
70
  * ```
65
71
  *
66
- * @param {AgentMail.QueryMetricsRequest} request
72
+ * @param {AgentMail.QueryEventsRequest} request
67
73
  * @param {MetricsClient.RequestOptions} requestOptions - Request-specific configuration.
68
74
  *
69
75
  * @throws {@link AgentMail.ValidationError}
70
76
  *
71
77
  * @example
72
- * await client.metrics.query()
78
+ * await client.metrics.queryEvents()
73
79
  */
74
- query(request = {}, requestOptions) {
75
- return core.HttpResponsePromise.fromPromise(this.__query(request, requestOptions));
80
+ queryEvents(request = {}, requestOptions) {
81
+ return core.HttpResponsePromise.fromPromise(this.__queryEvents(request, requestOptions));
76
82
  }
77
- __query() {
83
+ __queryEvents() {
78
84
  return __awaiter(this, arguments, void 0, function* (request = {}, requestOptions) {
79
85
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
80
86
  const { eventTypes, start, end, period, limit, descending } = request;
@@ -99,7 +105,7 @@ class MetricsClient {
99
105
  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
106
  const _response = yield core.fetcher({
101
107
  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)
102
- .http, "/v0/metrics"),
108
+ .http, "/v0/metrics/events"),
103
109
  method: "GET",
104
110
  headers: _headers,
105
111
  queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
@@ -139,7 +145,93 @@ class MetricsClient {
139
145
  });
140
146
  }
141
147
  }
142
- return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/v0/metrics");
148
+ return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/v0/metrics/events");
149
+ });
150
+ }
151
+ /**
152
+ * Cumulative usage series for the organization. Each point is the running
153
+ * total of the usage type at that timestamp, not the change within the
154
+ * bucket. Defaults to the last 24 hours; `start` must be within the last
155
+ * 90 days, and a future `end` is clamped to now. The range divided by
156
+ * `period` must not exceed 1000 buckets.
157
+ *
158
+ * @param {AgentMail.QueryUsageRequest} request
159
+ * @param {MetricsClient.RequestOptions} requestOptions - Request-specific configuration.
160
+ *
161
+ * @throws {@link AgentMail.ValidationError}
162
+ *
163
+ * @example
164
+ * await client.metrics.queryUsage()
165
+ */
166
+ queryUsage(request = {}, requestOptions) {
167
+ return core.HttpResponsePromise.fromPromise(this.__queryUsage(request, requestOptions));
168
+ }
169
+ __queryUsage() {
170
+ return __awaiter(this, arguments, void 0, function* (request = {}, requestOptions) {
171
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
172
+ const { usageTypes, start, end, period, limit, descending } = request;
173
+ const _queryParams = {
174
+ usage_types: usageTypes != null
175
+ ? (0, json_js_1.toJson)(serializers.UsageTypes.jsonOrThrow(usageTypes, {
176
+ unrecognizedObjectKeys: "strip",
177
+ omitUndefined: true,
178
+ }))
179
+ : undefined,
180
+ start: start != null
181
+ ? serializers.Start.jsonOrThrow(start, { unrecognizedObjectKeys: "strip", omitUndefined: true })
182
+ : undefined,
183
+ end: end != null
184
+ ? serializers.End.jsonOrThrow(end, { unrecognizedObjectKeys: "strip", omitUndefined: true })
185
+ : undefined,
186
+ period,
187
+ limit,
188
+ descending,
189
+ };
190
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
191
+ 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);
192
+ const _response = yield core.fetcher({
193
+ 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)
194
+ .http, "/v0/metrics/usage"),
195
+ method: "GET",
196
+ headers: _headers,
197
+ queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
198
+ 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,
199
+ 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,
200
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
201
+ fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
202
+ logging: this._options.logging,
203
+ });
204
+ if (_response.ok) {
205
+ return {
206
+ data: serializers.QueryUsageResponse.parseOrThrow(_response.body, {
207
+ unrecognizedObjectKeys: "passthrough",
208
+ allowUnrecognizedUnionMembers: true,
209
+ allowUnrecognizedEnumValues: true,
210
+ skipValidation: true,
211
+ breadcrumbsPrefix: ["response"],
212
+ }),
213
+ rawResponse: _response.rawResponse,
214
+ };
215
+ }
216
+ if (_response.error.reason === "status-code") {
217
+ switch (_response.error.statusCode) {
218
+ case 400:
219
+ throw new AgentMail.ValidationError(serializers.ValidationErrorResponse.parseOrThrow(_response.error.body, {
220
+ unrecognizedObjectKeys: "passthrough",
221
+ allowUnrecognizedUnionMembers: true,
222
+ allowUnrecognizedEnumValues: true,
223
+ skipValidation: true,
224
+ breadcrumbsPrefix: ["response"],
225
+ }), _response.rawResponse);
226
+ default:
227
+ throw new errors.AgentMailError({
228
+ statusCode: _response.error.statusCode,
229
+ body: _response.error.body,
230
+ rawResponse: _response.rawResponse,
231
+ });
232
+ }
233
+ }
234
+ return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/v0/metrics/usage");
143
235
  });
144
236
  }
145
237
  }
@@ -3,7 +3,7 @@ import type * as AgentMail from "../../../../index.js";
3
3
  * @example
4
4
  * {}
5
5
  */
6
- export interface QueryMetricsRequest {
6
+ export interface QueryEventsRequest {
7
7
  eventTypes?: AgentMail.MetricEventTypes;
8
8
  start?: AgentMail.Start;
9
9
  end?: AgentMail.End;
@@ -0,0 +1,13 @@
1
+ import type * as AgentMail from "../../../../index.js";
2
+ /**
3
+ * @example
4
+ * {}
5
+ */
6
+ export interface QueryUsageRequest {
7
+ usageTypes?: AgentMail.UsageTypes;
8
+ start?: AgentMail.Start;
9
+ end?: AgentMail.End;
10
+ period?: AgentMail.Period;
11
+ limit?: AgentMail.MetricLimit;
12
+ descending?: AgentMail.Descending;
13
+ }
@@ -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 +1,2 @@
1
- export type { QueryMetricsRequest } from "./QueryMetricsRequest.js";
1
+ export type { QueryEventsRequest } from "./QueryEventsRequest.js";
2
+ export type { QueryUsageRequest } from "./QueryUsageRequest.js";
@@ -1,11 +1,14 @@
1
1
  /** Type of metric event. */
2
2
  export declare const MetricEventType: {
3
+ readonly MessageReceived: "message.received";
4
+ readonly MessageReceivedSpam: "message.received.spam";
5
+ readonly MessageReceivedBlocked: "message.received.blocked";
6
+ readonly MessageReceivedUnauthenticated: "message.received.unauthenticated";
3
7
  readonly MessageSent: "message.sent";
4
8
  readonly MessageDelivered: "message.delivered";
5
9
  readonly MessageBounced: "message.bounced";
6
- readonly MessageDelayed: "message.delayed";
7
- readonly MessageRejected: "message.rejected";
8
10
  readonly MessageComplained: "message.complained";
9
- readonly MessageReceived: "message.received";
11
+ readonly MessageRejected: "message.rejected";
12
+ readonly DomainVerified: "domain.verified";
10
13
  };
11
14
  export type MetricEventType = (typeof MetricEventType)[keyof typeof MetricEventType];
@@ -4,11 +4,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.MetricEventType = void 0;
5
5
  /** Type of metric event. */
6
6
  exports.MetricEventType = {
7
+ MessageReceived: "message.received",
8
+ MessageReceivedSpam: "message.received.spam",
9
+ MessageReceivedBlocked: "message.received.blocked",
10
+ MessageReceivedUnauthenticated: "message.received.unauthenticated",
7
11
  MessageSent: "message.sent",
8
12
  MessageDelivered: "message.delivered",
9
13
  MessageBounced: "message.bounced",
10
- MessageDelayed: "message.delayed",
11
- MessageRejected: "message.rejected",
12
14
  MessageComplained: "message.complained",
13
- MessageReceived: "message.received",
15
+ MessageRejected: "message.rejected",
16
+ DomainVerified: "domain.verified",
14
17
  };
@@ -1,4 +1,4 @@
1
1
  /**
2
- * Period in number of seconds for the query.
2
+ * Size of each time bucket as a whole number of seconds, between 1 and 86400.
3
3
  */
4
- export type Period = string;
4
+ export type Period = number;
@@ -0,0 +1,5 @@
1
+ import type * as AgentMail from "../../../index.js";
2
+ /**
3
+ * Cumulative usage series grouped by usage type.
4
+ */
5
+ export type QueryUsageResponse = Partial<Record<AgentMail.UsageType, AgentMail.UsagePoint[]>>;
@@ -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
+ export interface UsagePoint {
2
+ /** Timestamp of the point. */
3
+ timestamp: Date;
4
+ /** Cumulative value of the usage metric at the timestamp. */
5
+ value: number;
6
+ }
@@ -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,14 @@
1
+ /**
2
+ * Type of usage metric. Inbox-scoped queries carry `storage_bytes`,
3
+ * `message_count`, and `thread_count`; pod-scoped queries add `inbox_count`
4
+ * and `domain_count`; organization-scoped queries add `pod_count`.
5
+ */
6
+ export declare const UsageType: {
7
+ readonly StorageBytes: "storage_bytes";
8
+ readonly MessageCount: "message_count";
9
+ readonly ThreadCount: "thread_count";
10
+ readonly InboxCount: "inbox_count";
11
+ readonly PodCount: "pod_count";
12
+ readonly DomainCount: "domain_count";
13
+ };
14
+ export type UsageType = (typeof UsageType)[keyof typeof UsageType];
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.UsageType = void 0;
5
+ /**
6
+ * Type of usage metric. Inbox-scoped queries carry `storage_bytes`,
7
+ * `message_count`, and `thread_count`; pod-scoped queries add `inbox_count`
8
+ * and `domain_count`; organization-scoped queries add `pod_count`.
9
+ */
10
+ exports.UsageType = {
11
+ StorageBytes: "storage_bytes",
12
+ MessageCount: "message_count",
13
+ ThreadCount: "thread_count",
14
+ InboxCount: "inbox_count",
15
+ PodCount: "pod_count",
16
+ DomainCount: "domain_count",
17
+ };
@@ -0,0 +1,5 @@
1
+ import type * as AgentMail from "../../../index.js";
2
+ /**
3
+ * List of usage metric types to query. Omit to query every type valid for the scope.
4
+ */
5
+ export type UsageTypes = AgentMail.UsageType[];
@@ -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,4 +6,8 @@ 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 "./QueryUsageResponse.js";
9
10
  export * from "./Start.js";
11
+ export * from "./UsagePoint.js";
12
+ export * from "./UsageType.js";
13
+ export * from "./UsageTypes.js";
@@ -22,4 +22,8 @@ __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("./QueryUsageResponse.js"), exports);
25
26
  __exportStar(require("./Start.js"), exports);
27
+ __exportStar(require("./UsagePoint.js"), exports);
28
+ __exportStar(require("./UsageType.js"), exports);
29
+ __exportStar(require("./UsageTypes.js"), exports);