agentmail 0.5.22 → 0.5.24

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 (81) hide show
  1. package/dist/cjs/BaseClient.js +2 -2
  2. package/dist/cjs/api/resources/inboxes/client/Client.d.ts +20 -0
  3. package/dist/cjs/api/resources/inboxes/client/Client.js +77 -0
  4. package/dist/cjs/api/resources/inboxes/client/requests/SearchInboxesRequest.d.ts +13 -0
  5. package/dist/cjs/api/resources/inboxes/client/requests/SearchInboxesRequest.js +3 -0
  6. package/dist/cjs/api/resources/inboxes/client/requests/index.d.ts +1 -0
  7. package/dist/cjs/api/resources/inboxes/resources/threads/client/Client.d.ts +2 -1
  8. package/dist/cjs/api/resources/inboxes/resources/threads/client/Client.js +11 -5
  9. package/dist/cjs/api/resources/inboxes/resources/threads/client/requests/GetInboxThreadRequest.d.ts +11 -0
  10. package/dist/cjs/api/resources/inboxes/resources/threads/client/requests/GetInboxThreadRequest.js +3 -0
  11. package/dist/cjs/api/resources/inboxes/resources/threads/client/requests/index.d.ts +1 -0
  12. package/dist/cjs/api/resources/inboxes/types/SearchInboxesResponse.d.ts +8 -0
  13. package/dist/cjs/api/resources/inboxes/types/SearchInboxesResponse.js +3 -0
  14. package/dist/cjs/api/resources/inboxes/types/index.d.ts +1 -0
  15. package/dist/cjs/api/resources/inboxes/types/index.js +1 -0
  16. package/dist/cjs/api/resources/pods/resources/inboxes/client/Client.d.ts +22 -0
  17. package/dist/cjs/api/resources/pods/resources/inboxes/client/Client.js +87 -0
  18. package/dist/cjs/api/resources/pods/resources/inboxes/client/requests/SearchInboxesRequest.d.ts +13 -0
  19. package/dist/cjs/api/resources/pods/resources/inboxes/client/requests/SearchInboxesRequest.js +3 -0
  20. package/dist/cjs/api/resources/pods/resources/inboxes/client/requests/index.d.ts +1 -0
  21. package/dist/cjs/api/resources/pods/resources/threads/client/Client.d.ts +2 -1
  22. package/dist/cjs/api/resources/pods/resources/threads/client/Client.js +11 -5
  23. package/dist/cjs/api/resources/pods/resources/threads/client/requests/GetPodThreadRequest.d.ts +11 -0
  24. package/dist/cjs/api/resources/pods/resources/threads/client/requests/GetPodThreadRequest.js +3 -0
  25. package/dist/cjs/api/resources/pods/resources/threads/client/requests/index.d.ts +1 -0
  26. package/dist/cjs/api/resources/threads/client/Client.d.ts +2 -1
  27. package/dist/cjs/api/resources/threads/client/Client.js +11 -5
  28. package/dist/cjs/api/resources/threads/client/requests/GetThreadRequest.d.ts +11 -0
  29. package/dist/cjs/api/resources/threads/client/requests/GetThreadRequest.js +3 -0
  30. package/dist/cjs/api/resources/threads/client/requests/index.d.ts +1 -0
  31. package/dist/cjs/api/resources/threads/types/Thread.d.ts +7 -1
  32. package/dist/cjs/serialization/resources/inboxes/types/SearchInboxesResponse.d.ts +16 -0
  33. package/dist/cjs/serialization/resources/inboxes/types/SearchInboxesResponse.js +48 -0
  34. package/dist/cjs/serialization/resources/inboxes/types/index.d.ts +1 -0
  35. package/dist/cjs/serialization/resources/inboxes/types/index.js +1 -0
  36. package/dist/cjs/serialization/resources/threads/types/Thread.d.ts +6 -0
  37. package/dist/cjs/serialization/resources/threads/types/Thread.js +6 -0
  38. package/dist/cjs/version.d.ts +1 -1
  39. package/dist/cjs/version.js +1 -1
  40. package/dist/esm/BaseClient.mjs +2 -2
  41. package/dist/esm/api/resources/inboxes/client/Client.d.mts +20 -0
  42. package/dist/esm/api/resources/inboxes/client/Client.mjs +77 -0
  43. package/dist/esm/api/resources/inboxes/client/requests/SearchInboxesRequest.d.mts +13 -0
  44. package/dist/esm/api/resources/inboxes/client/requests/SearchInboxesRequest.mjs +2 -0
  45. package/dist/esm/api/resources/inboxes/client/requests/index.d.mts +1 -0
  46. package/dist/esm/api/resources/inboxes/resources/threads/client/Client.d.mts +2 -1
  47. package/dist/esm/api/resources/inboxes/resources/threads/client/Client.mjs +11 -5
  48. package/dist/esm/api/resources/inboxes/resources/threads/client/requests/GetInboxThreadRequest.d.mts +11 -0
  49. package/dist/esm/api/resources/inboxes/resources/threads/client/requests/GetInboxThreadRequest.mjs +2 -0
  50. package/dist/esm/api/resources/inboxes/resources/threads/client/requests/index.d.mts +1 -0
  51. package/dist/esm/api/resources/inboxes/types/SearchInboxesResponse.d.mts +8 -0
  52. package/dist/esm/api/resources/inboxes/types/SearchInboxesResponse.mjs +2 -0
  53. package/dist/esm/api/resources/inboxes/types/index.d.mts +1 -0
  54. package/dist/esm/api/resources/inboxes/types/index.mjs +1 -0
  55. package/dist/esm/api/resources/pods/resources/inboxes/client/Client.d.mts +22 -0
  56. package/dist/esm/api/resources/pods/resources/inboxes/client/Client.mjs +87 -0
  57. package/dist/esm/api/resources/pods/resources/inboxes/client/requests/SearchInboxesRequest.d.mts +13 -0
  58. package/dist/esm/api/resources/pods/resources/inboxes/client/requests/SearchInboxesRequest.mjs +2 -0
  59. package/dist/esm/api/resources/pods/resources/inboxes/client/requests/index.d.mts +1 -0
  60. package/dist/esm/api/resources/pods/resources/threads/client/Client.d.mts +2 -1
  61. package/dist/esm/api/resources/pods/resources/threads/client/Client.mjs +11 -5
  62. package/dist/esm/api/resources/pods/resources/threads/client/requests/GetPodThreadRequest.d.mts +11 -0
  63. package/dist/esm/api/resources/pods/resources/threads/client/requests/GetPodThreadRequest.mjs +2 -0
  64. package/dist/esm/api/resources/pods/resources/threads/client/requests/index.d.mts +1 -0
  65. package/dist/esm/api/resources/threads/client/Client.d.mts +2 -1
  66. package/dist/esm/api/resources/threads/client/Client.mjs +11 -5
  67. package/dist/esm/api/resources/threads/client/requests/GetThreadRequest.d.mts +11 -0
  68. package/dist/esm/api/resources/threads/client/requests/GetThreadRequest.mjs +2 -0
  69. package/dist/esm/api/resources/threads/client/requests/index.d.mts +1 -0
  70. package/dist/esm/api/resources/threads/types/Thread.d.mts +7 -1
  71. package/dist/esm/serialization/resources/inboxes/types/SearchInboxesResponse.d.mts +16 -0
  72. package/dist/esm/serialization/resources/inboxes/types/SearchInboxesResponse.mjs +12 -0
  73. package/dist/esm/serialization/resources/inboxes/types/index.d.mts +1 -0
  74. package/dist/esm/serialization/resources/inboxes/types/index.mjs +1 -0
  75. package/dist/esm/serialization/resources/threads/types/Thread.d.mts +6 -0
  76. package/dist/esm/serialization/resources/threads/types/Thread.mjs +6 -0
  77. package/dist/esm/version.d.mts +1 -1
  78. package/dist/esm/version.mjs +1 -1
  79. package/dist/llms.txt +10 -0
  80. package/package.json +1 -1
  81. package/reference.md +175 -3
@@ -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.22",
47
- "User-Agent": "agentmail/0.5.22",
46
+ "X-Fern-SDK-Version": "0.5.24",
47
+ "User-Agent": "agentmail/0.5.24",
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);
@@ -51,6 +51,26 @@ export declare class InboxesClient {
51
51
  */
52
52
  list(request?: AgentMail.inboxes.ListInboxesRequest, requestOptions?: InboxesClient.RequestOptions): core.HttpResponsePromise<AgentMail.inboxes.ListInboxesResponse>;
53
53
  private __list;
54
+ /**
55
+ * Searches inboxes in the organization by address or display name, ranked
56
+ * by relevance. Each word in the query matches the start of a word in the
57
+ * address or display name, so `sup` matches `support@example.com` but
58
+ * `port` does not. An exact address match always ranks first. `limit`
59
+ * cannot exceed 100. A page can be empty and still carry a
60
+ * `next_page_token`; keep paging until the token is absent.
61
+ *
62
+ * @param {AgentMail.inboxes.SearchInboxesRequest} request
63
+ * @param {InboxesClient.RequestOptions} requestOptions - Request-specific configuration.
64
+ *
65
+ * @throws {@link AgentMail.ValidationError}
66
+ *
67
+ * @example
68
+ * await client.inboxes.search({
69
+ * q: "q"
70
+ * })
71
+ */
72
+ search(request: AgentMail.inboxes.SearchInboxesRequest, requestOptions?: InboxesClient.RequestOptions): core.HttpResponsePromise<AgentMail.inboxes.SearchInboxesResponse>;
73
+ private __search;
54
74
  /**
55
75
  * **CLI:**
56
76
  * ```bash
@@ -161,6 +161,83 @@ class InboxesClient {
161
161
  return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/v0/inboxes");
162
162
  });
163
163
  }
164
+ /**
165
+ * Searches inboxes in the organization by address or display name, ranked
166
+ * by relevance. Each word in the query matches the start of a word in the
167
+ * address or display name, so `sup` matches `support@example.com` but
168
+ * `port` does not. An exact address match always ranks first. `limit`
169
+ * cannot exceed 100. A page can be empty and still carry a
170
+ * `next_page_token`; keep paging until the token is absent.
171
+ *
172
+ * @param {AgentMail.inboxes.SearchInboxesRequest} request
173
+ * @param {InboxesClient.RequestOptions} requestOptions - Request-specific configuration.
174
+ *
175
+ * @throws {@link AgentMail.ValidationError}
176
+ *
177
+ * @example
178
+ * await client.inboxes.search({
179
+ * q: "q"
180
+ * })
181
+ */
182
+ search(request, requestOptions) {
183
+ return core.HttpResponsePromise.fromPromise(this.__search(request, requestOptions));
184
+ }
185
+ __search(request, requestOptions) {
186
+ return __awaiter(this, void 0, void 0, function* () {
187
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
188
+ const { q, limit, pageToken } = request;
189
+ const _queryParams = {
190
+ q,
191
+ limit,
192
+ page_token: pageToken,
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/search"),
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.inboxes.SearchInboxesResponse.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/search");
239
+ });
240
+ }
164
241
  /**
165
242
  * **CLI:**
166
243
  * ```bash
@@ -0,0 +1,13 @@
1
+ import type * as AgentMail from "../../../../index.js";
2
+ /**
3
+ * @example
4
+ * {
5
+ * q: "q"
6
+ * }
7
+ */
8
+ export interface SearchInboxesRequest {
9
+ /** Address or display name to search for. Matches word prefixes. Must be 2 to 256 characters. */
10
+ q: string;
11
+ limit?: AgentMail.Limit;
12
+ pageToken?: AgentMail.PageToken;
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
1
  export type { ListInboxesRequest } from "./ListInboxesRequest.js";
2
+ export type { SearchInboxesRequest } from "./SearchInboxesRequest.js";
@@ -60,6 +60,7 @@ export declare class ThreadsClient {
60
60
  *
61
61
  * @param {AgentMail.inboxes.InboxId} inbox_id
62
62
  * @param {AgentMail.ThreadId} thread_id
63
+ * @param {AgentMail.inboxes.GetInboxThreadRequest} request
63
64
  * @param {ThreadsClient.RequestOptions} requestOptions - Request-specific configuration.
64
65
  *
65
66
  * @throws {@link AgentMail.NotFoundError}
@@ -67,7 +68,7 @@ export declare class ThreadsClient {
67
68
  * @example
68
69
  * await client.inboxes.threads.get("inbox_id", "thread_id")
69
70
  */
70
- get(inbox_id: AgentMail.inboxes.InboxId, thread_id: AgentMail.ThreadId, requestOptions?: ThreadsClient.RequestOptions): core.HttpResponsePromise<AgentMail.Thread>;
71
+ get(inbox_id: AgentMail.inboxes.InboxId, thread_id: AgentMail.ThreadId, request?: AgentMail.inboxes.GetInboxThreadRequest, requestOptions?: ThreadsClient.RequestOptions): core.HttpResponsePromise<AgentMail.Thread>;
71
72
  private __get;
72
73
  /**
73
74
  * **CLI:**
@@ -254,6 +254,7 @@ class ThreadsClient {
254
254
  *
255
255
  * @param {AgentMail.inboxes.InboxId} inbox_id
256
256
  * @param {AgentMail.ThreadId} thread_id
257
+ * @param {AgentMail.inboxes.GetInboxThreadRequest} request
257
258
  * @param {ThreadsClient.RequestOptions} requestOptions - Request-specific configuration.
258
259
  *
259
260
  * @throws {@link AgentMail.NotFoundError}
@@ -261,12 +262,17 @@ class ThreadsClient {
261
262
  * @example
262
263
  * await client.inboxes.threads.get("inbox_id", "thread_id")
263
264
  */
264
- get(inbox_id, thread_id, requestOptions) {
265
- return core.HttpResponsePromise.fromPromise(this.__get(inbox_id, thread_id, requestOptions));
265
+ get(inbox_id, thread_id, request = {}, requestOptions) {
266
+ return core.HttpResponsePromise.fromPromise(this.__get(inbox_id, thread_id, request, requestOptions));
266
267
  }
267
- __get(inbox_id, thread_id, requestOptions) {
268
- return __awaiter(this, void 0, void 0, function* () {
268
+ __get(inbox_id_1, thread_id_1) {
269
+ return __awaiter(this, arguments, void 0, function* (inbox_id, thread_id, request = {}, requestOptions) {
269
270
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
271
+ const { limit, pageToken } = request;
272
+ const _queryParams = {
273
+ limit,
274
+ page_token: pageToken,
275
+ };
270
276
  const _authRequest = yield this._options.authProvider.getAuthRequest();
271
277
  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);
272
278
  const _response = yield core.fetcher({
@@ -274,7 +280,7 @@ class ThreadsClient {
274
280
  .http, `/v0/inboxes/${core.url.encodePathParam(serializers.inboxes.InboxId.jsonOrThrow(inbox_id, { omitUndefined: true }))}/threads/${core.url.encodePathParam(serializers.ThreadId.jsonOrThrow(thread_id, { omitUndefined: true }))}`),
275
281
  method: "GET",
276
282
  headers: _headers,
277
- queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
283
+ queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
278
284
  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,
279
285
  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,
280
286
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
@@ -0,0 +1,11 @@
1
+ import type * as AgentMail from "../../../../../../index.js";
2
+ /**
3
+ * @example
4
+ * {}
5
+ */
6
+ export interface GetInboxThreadRequest {
7
+ /** Maximum number of messages to return. Cannot exceed 100. */
8
+ limit?: AgentMail.Limit;
9
+ /** Token returned by the previous response for retrieving the next, older page. */
10
+ pageToken?: AgentMail.PageToken;
11
+ }
@@ -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
+ export type { GetInboxThreadRequest } from "./GetInboxThreadRequest.js";
1
2
  export type { ListThreadsRequest } from "./ListThreadsRequest.js";
2
3
  export type { SearchThreadsRequest } from "./SearchThreadsRequest.js";
@@ -0,0 +1,8 @@
1
+ import type * as AgentMail from "../../../index.js";
2
+ export interface SearchInboxesResponse {
3
+ count: AgentMail.Count;
4
+ limit?: AgentMail.Limit;
5
+ nextPageToken?: AgentMail.PageToken;
6
+ /** Ordered by relevance, best match first. */
7
+ inboxes: AgentMail.inboxes.Inbox[];
8
+ }
@@ -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 });
@@ -7,5 +7,6 @@ export * from "./InboxId.js";
7
7
  export * from "./ListInboxesResponse.js";
8
8
  export * from "./Metadata.js";
9
9
  export * from "./MetadataValue.js";
10
+ export * from "./SearchInboxesResponse.js";
10
11
  export * from "./UpdateInboxRequest.js";
11
12
  export * from "./UpdateMetadata.js";
@@ -23,5 +23,6 @@ __exportStar(require("./InboxId.js"), exports);
23
23
  __exportStar(require("./ListInboxesResponse.js"), exports);
24
24
  __exportStar(require("./Metadata.js"), exports);
25
25
  __exportStar(require("./MetadataValue.js"), exports);
26
+ __exportStar(require("./SearchInboxesResponse.js"), exports);
26
27
  __exportStar(require("./UpdateInboxRequest.js"), exports);
27
28
  __exportStar(require("./UpdateMetadata.js"), exports);
@@ -27,6 +27,28 @@ export declare class InboxesClient {
27
27
  */
28
28
  list(pod_id: AgentMail.pods.PodId, request?: AgentMail.pods.ListInboxesRequest, requestOptions?: InboxesClient.RequestOptions): core.HttpResponsePromise<AgentMail.inboxes.ListInboxesResponse>;
29
29
  private __list;
30
+ /**
31
+ * Searches inboxes in the pod by address or display name, ranked by
32
+ * relevance. Each word in the query matches the start of a word in the
33
+ * address or display name, so `sup` matches `support@example.com` but
34
+ * `port` does not. An exact address match always ranks first. `limit`
35
+ * cannot exceed 100. A page can be empty and still carry a
36
+ * `next_page_token`; keep paging until the token is absent.
37
+ *
38
+ * @param {AgentMail.pods.PodId} pod_id
39
+ * @param {AgentMail.pods.SearchInboxesRequest} request
40
+ * @param {InboxesClient.RequestOptions} requestOptions - Request-specific configuration.
41
+ *
42
+ * @throws {@link AgentMail.ValidationError}
43
+ * @throws {@link AgentMail.NotFoundError}
44
+ *
45
+ * @example
46
+ * await client.pods.inboxes.search("pod_id", {
47
+ * q: "q"
48
+ * })
49
+ */
50
+ search(pod_id: AgentMail.pods.PodId, request: AgentMail.pods.SearchInboxesRequest, requestOptions?: InboxesClient.RequestOptions): core.HttpResponsePromise<AgentMail.inboxes.SearchInboxesResponse>;
51
+ private __search;
30
52
  /**
31
53
  * **CLI:**
32
54
  * ```bash
@@ -130,6 +130,93 @@ class InboxesClient {
130
130
  return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/v0/pods/{pod_id}/inboxes");
131
131
  });
132
132
  }
133
+ /**
134
+ * Searches inboxes in the pod by address or display name, ranked by
135
+ * relevance. Each word in the query matches the start of a word in the
136
+ * address or display name, so `sup` matches `support@example.com` but
137
+ * `port` does not. An exact address match always ranks first. `limit`
138
+ * cannot exceed 100. A page can be empty and still carry a
139
+ * `next_page_token`; keep paging until the token is absent.
140
+ *
141
+ * @param {AgentMail.pods.PodId} pod_id
142
+ * @param {AgentMail.pods.SearchInboxesRequest} request
143
+ * @param {InboxesClient.RequestOptions} requestOptions - Request-specific configuration.
144
+ *
145
+ * @throws {@link AgentMail.ValidationError}
146
+ * @throws {@link AgentMail.NotFoundError}
147
+ *
148
+ * @example
149
+ * await client.pods.inboxes.search("pod_id", {
150
+ * q: "q"
151
+ * })
152
+ */
153
+ search(pod_id, request, requestOptions) {
154
+ return core.HttpResponsePromise.fromPromise(this.__search(pod_id, request, requestOptions));
155
+ }
156
+ __search(pod_id, request, requestOptions) {
157
+ return __awaiter(this, void 0, void 0, function* () {
158
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
159
+ const { q, limit, pageToken } = request;
160
+ const _queryParams = {
161
+ q,
162
+ limit,
163
+ page_token: pageToken,
164
+ };
165
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
166
+ 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);
167
+ const _response = yield core.fetcher({
168
+ 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)
169
+ .http, `/v0/pods/${core.url.encodePathParam(serializers.pods.PodId.jsonOrThrow(pod_id, { omitUndefined: true }))}/inboxes/search`),
170
+ method: "GET",
171
+ headers: _headers,
172
+ queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
173
+ 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,
174
+ 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,
175
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
176
+ fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
177
+ logging: this._options.logging,
178
+ });
179
+ if (_response.ok) {
180
+ return {
181
+ data: serializers.inboxes.SearchInboxesResponse.parseOrThrow(_response.body, {
182
+ unrecognizedObjectKeys: "passthrough",
183
+ allowUnrecognizedUnionMembers: true,
184
+ allowUnrecognizedEnumValues: true,
185
+ skipValidation: true,
186
+ breadcrumbsPrefix: ["response"],
187
+ }),
188
+ rawResponse: _response.rawResponse,
189
+ };
190
+ }
191
+ if (_response.error.reason === "status-code") {
192
+ switch (_response.error.statusCode) {
193
+ case 400:
194
+ throw new AgentMail.ValidationError(serializers.ValidationErrorResponse.parseOrThrow(_response.error.body, {
195
+ unrecognizedObjectKeys: "passthrough",
196
+ allowUnrecognizedUnionMembers: true,
197
+ allowUnrecognizedEnumValues: true,
198
+ skipValidation: true,
199
+ breadcrumbsPrefix: ["response"],
200
+ }), _response.rawResponse);
201
+ case 404:
202
+ throw new AgentMail.NotFoundError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
203
+ unrecognizedObjectKeys: "passthrough",
204
+ allowUnrecognizedUnionMembers: true,
205
+ allowUnrecognizedEnumValues: true,
206
+ skipValidation: true,
207
+ breadcrumbsPrefix: ["response"],
208
+ }), _response.rawResponse);
209
+ default:
210
+ throw new errors.AgentMailError({
211
+ statusCode: _response.error.statusCode,
212
+ body: _response.error.body,
213
+ rawResponse: _response.rawResponse,
214
+ });
215
+ }
216
+ }
217
+ return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/v0/pods/{pod_id}/inboxes/search");
218
+ });
219
+ }
133
220
  /**
134
221
  * **CLI:**
135
222
  * ```bash
@@ -0,0 +1,13 @@
1
+ import type * as AgentMail from "../../../../../../index.js";
2
+ /**
3
+ * @example
4
+ * {
5
+ * q: "q"
6
+ * }
7
+ */
8
+ export interface SearchInboxesRequest {
9
+ /** Address or display name to search for. Matches word prefixes. Must be 2 to 256 characters. */
10
+ q: string;
11
+ limit?: AgentMail.Limit;
12
+ pageToken?: AgentMail.PageToken;
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
1
  export type { ListInboxesRequest } from "./ListInboxesRequest.js";
2
+ export type { SearchInboxesRequest } from "./SearchInboxesRequest.js";
@@ -60,6 +60,7 @@ export declare class ThreadsClient {
60
60
  *
61
61
  * @param {AgentMail.pods.PodId} pod_id
62
62
  * @param {AgentMail.ThreadId} thread_id
63
+ * @param {AgentMail.pods.GetPodThreadRequest} request
63
64
  * @param {ThreadsClient.RequestOptions} requestOptions - Request-specific configuration.
64
65
  *
65
66
  * @throws {@link AgentMail.NotFoundError}
@@ -67,7 +68,7 @@ export declare class ThreadsClient {
67
68
  * @example
68
69
  * await client.pods.threads.get("pod_id", "thread_id")
69
70
  */
70
- get(pod_id: AgentMail.pods.PodId, thread_id: AgentMail.ThreadId, requestOptions?: ThreadsClient.RequestOptions): core.HttpResponsePromise<AgentMail.Thread>;
71
+ get(pod_id: AgentMail.pods.PodId, thread_id: AgentMail.ThreadId, request?: AgentMail.pods.GetPodThreadRequest, requestOptions?: ThreadsClient.RequestOptions): core.HttpResponsePromise<AgentMail.Thread>;
71
72
  private __get;
72
73
  /**
73
74
  * **CLI:**
@@ -254,6 +254,7 @@ class ThreadsClient {
254
254
  *
255
255
  * @param {AgentMail.pods.PodId} pod_id
256
256
  * @param {AgentMail.ThreadId} thread_id
257
+ * @param {AgentMail.pods.GetPodThreadRequest} request
257
258
  * @param {ThreadsClient.RequestOptions} requestOptions - Request-specific configuration.
258
259
  *
259
260
  * @throws {@link AgentMail.NotFoundError}
@@ -261,12 +262,17 @@ class ThreadsClient {
261
262
  * @example
262
263
  * await client.pods.threads.get("pod_id", "thread_id")
263
264
  */
264
- get(pod_id, thread_id, requestOptions) {
265
- return core.HttpResponsePromise.fromPromise(this.__get(pod_id, thread_id, requestOptions));
265
+ get(pod_id, thread_id, request = {}, requestOptions) {
266
+ return core.HttpResponsePromise.fromPromise(this.__get(pod_id, thread_id, request, requestOptions));
266
267
  }
267
- __get(pod_id, thread_id, requestOptions) {
268
- return __awaiter(this, void 0, void 0, function* () {
268
+ __get(pod_id_1, thread_id_1) {
269
+ return __awaiter(this, arguments, void 0, function* (pod_id, thread_id, request = {}, requestOptions) {
269
270
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
271
+ const { limit, pageToken } = request;
272
+ const _queryParams = {
273
+ limit,
274
+ page_token: pageToken,
275
+ };
270
276
  const _authRequest = yield this._options.authProvider.getAuthRequest();
271
277
  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);
272
278
  const _response = yield core.fetcher({
@@ -274,7 +280,7 @@ class ThreadsClient {
274
280
  .http, `/v0/pods/${core.url.encodePathParam(serializers.pods.PodId.jsonOrThrow(pod_id, { omitUndefined: true }))}/threads/${core.url.encodePathParam(serializers.ThreadId.jsonOrThrow(thread_id, { omitUndefined: true }))}`),
275
281
  method: "GET",
276
282
  headers: _headers,
277
- queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
283
+ queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
278
284
  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,
279
285
  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,
280
286
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
@@ -0,0 +1,11 @@
1
+ import type * as AgentMail from "../../../../../../index.js";
2
+ /**
3
+ * @example
4
+ * {}
5
+ */
6
+ export interface GetPodThreadRequest {
7
+ /** Maximum number of messages to return. Cannot exceed 100. */
8
+ limit?: AgentMail.Limit;
9
+ /** Token returned by the previous response for retrieving the next, older page. */
10
+ pageToken?: AgentMail.PageToken;
11
+ }
@@ -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
+ export type { GetPodThreadRequest } from "./GetPodThreadRequest.js";
1
2
  export type { ListThreadsRequest } from "./ListThreadsRequest.js";
2
3
  export type { SearchThreadsRequest } from "./SearchThreadsRequest.js";
@@ -59,6 +59,7 @@ export declare class ThreadsClient {
59
59
  * ```
60
60
  *
61
61
  * @param {AgentMail.ThreadId} thread_id
62
+ * @param {AgentMail.GetThreadRequest} request
62
63
  * @param {ThreadsClient.RequestOptions} requestOptions - Request-specific configuration.
63
64
  *
64
65
  * @throws {@link AgentMail.NotFoundError}
@@ -66,7 +67,7 @@ export declare class ThreadsClient {
66
67
  * @example
67
68
  * await client.threads.get("thread_id")
68
69
  */
69
- get(thread_id: AgentMail.ThreadId, requestOptions?: ThreadsClient.RequestOptions): core.HttpResponsePromise<AgentMail.Thread>;
70
+ get(thread_id: AgentMail.ThreadId, request?: AgentMail.GetThreadRequest, requestOptions?: ThreadsClient.RequestOptions): core.HttpResponsePromise<AgentMail.Thread>;
70
71
  private __get;
71
72
  /**
72
73
  * **CLI:**
@@ -253,6 +253,7 @@ class ThreadsClient {
253
253
  * ```
254
254
  *
255
255
  * @param {AgentMail.ThreadId} thread_id
256
+ * @param {AgentMail.GetThreadRequest} request
256
257
  * @param {ThreadsClient.RequestOptions} requestOptions - Request-specific configuration.
257
258
  *
258
259
  * @throws {@link AgentMail.NotFoundError}
@@ -260,12 +261,17 @@ class ThreadsClient {
260
261
  * @example
261
262
  * await client.threads.get("thread_id")
262
263
  */
263
- get(thread_id, requestOptions) {
264
- return core.HttpResponsePromise.fromPromise(this.__get(thread_id, requestOptions));
264
+ get(thread_id, request = {}, requestOptions) {
265
+ return core.HttpResponsePromise.fromPromise(this.__get(thread_id, request, requestOptions));
265
266
  }
266
- __get(thread_id, requestOptions) {
267
- return __awaiter(this, void 0, void 0, function* () {
267
+ __get(thread_id_1) {
268
+ return __awaiter(this, arguments, void 0, function* (thread_id, request = {}, requestOptions) {
268
269
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
270
+ const { limit, pageToken } = request;
271
+ const _queryParams = {
272
+ limit,
273
+ page_token: pageToken,
274
+ };
269
275
  const _authRequest = yield this._options.authProvider.getAuthRequest();
270
276
  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);
271
277
  const _response = yield core.fetcher({
@@ -273,7 +279,7 @@ class ThreadsClient {
273
279
  .http, `/v0/threads/${core.url.encodePathParam(serializers.ThreadId.jsonOrThrow(thread_id, { omitUndefined: true }))}`),
274
280
  method: "GET",
275
281
  headers: _headers,
276
- queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
282
+ queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
277
283
  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,
278
284
  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,
279
285
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
@@ -0,0 +1,11 @@
1
+ import type * as AgentMail from "../../../../index.js";
2
+ /**
3
+ * @example
4
+ * {}
5
+ */
6
+ export interface GetThreadRequest {
7
+ /** Maximum number of messages to return. Cannot exceed 100. */
8
+ limit?: AgentMail.Limit;
9
+ /** Token returned by the previous response for retrieving the next, older page. */
10
+ pageToken?: AgentMail.PageToken;
11
+ }
@@ -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
+ export type { GetThreadRequest } from "./GetThreadRequest.js";
1
2
  export type { ListThreadsRequest } from "./ListThreadsRequest.js";
2
3
  export type { SearchThreadsRequest } from "./SearchThreadsRequest.js";
@@ -16,6 +16,12 @@ export interface Thread {
16
16
  size: AgentMail.ThreadSize;
17
17
  updatedAt: AgentMail.ThreadUpdatedAt;
18
18
  createdAt: AgentMail.ThreadCreatedAt;
19
- /** Messages in thread. Ordered by `timestamp` ascending. */
19
+ /** Number of messages in this response page. */
20
+ count: AgentMail.Count;
21
+ /** Maximum number of messages requested for this page. */
22
+ limit?: AgentMail.Limit;
23
+ /** Token for the next, older page of messages. Omitted when this page completes the thread. */
24
+ nextPageToken?: AgentMail.PageToken;
25
+ /** Messages in this page, ordered by `timestamp` ascending. The first page contains the newest messages; follow `next_page_token` to retrieve older pages. */
20
26
  messages: AgentMail.Message[];
21
27
  }
@@ -0,0 +1,16 @@
1
+ import type * as AgentMail from "../../../../api/index.js";
2
+ import * as core from "../../../../core/index.js";
3
+ import type * as serializers from "../../../index.js";
4
+ import { Count } from "../../../types/Count.js";
5
+ import { Limit } from "../../../types/Limit.js";
6
+ import { PageToken } from "../../../types/PageToken.js";
7
+ import { Inbox } from "./Inbox.js";
8
+ export declare const SearchInboxesResponse: core.serialization.ObjectSchema<serializers.inboxes.SearchInboxesResponse.Raw, AgentMail.inboxes.SearchInboxesResponse>;
9
+ export declare namespace SearchInboxesResponse {
10
+ interface Raw {
11
+ count: Count.Raw;
12
+ limit?: Limit.Raw | null;
13
+ next_page_token?: PageToken.Raw | null;
14
+ inboxes: Inbox.Raw[];
15
+ }
16
+ }