agentmail 0.5.14 → 0.5.15

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 (96) hide show
  1. package/dist/cjs/BaseClient.js +2 -2
  2. package/dist/cjs/api/resources/drafts/types/CreateDraftRequest.d.ts +17 -0
  3. package/dist/cjs/api/resources/drafts/types/UpdateDraftRequest.d.ts +22 -8
  4. package/dist/cjs/api/resources/drafts/types/index.d.ts +0 -3
  5. package/dist/cjs/api/resources/drafts/types/index.js +0 -3
  6. package/dist/cjs/api/resources/inboxes/resources/drafts/client/Client.d.ts +13 -0
  7. package/dist/cjs/api/resources/inboxes/resources/drafts/client/Client.js +37 -0
  8. package/dist/cjs/api/resources/inboxes/resources/messages/client/Client.d.ts +0 -69
  9. package/dist/cjs/api/resources/inboxes/resources/messages/client/Client.js +0 -264
  10. package/dist/cjs/api/types/ErrorCode.d.ts +4 -0
  11. package/dist/cjs/api/types/ErrorDocs.d.ts +4 -0
  12. package/dist/cjs/api/types/ErrorFix.d.ts +4 -0
  13. package/dist/cjs/api/types/ErrorResponse.d.ts +3 -0
  14. package/dist/cjs/api/types/ValidationErrorResponse.d.ts +5 -1
  15. package/dist/cjs/api/types/index.d.ts +3 -0
  16. package/dist/cjs/api/types/index.js +3 -0
  17. package/dist/cjs/serialization/resources/drafts/types/CreateDraftRequest.d.ts +4 -0
  18. package/dist/cjs/serialization/resources/drafts/types/CreateDraftRequest.js +4 -0
  19. package/dist/cjs/serialization/resources/drafts/types/UpdateDraftRequest.d.ts +15 -8
  20. package/dist/cjs/serialization/resources/drafts/types/UpdateDraftRequest.js +15 -8
  21. package/dist/cjs/serialization/resources/drafts/types/index.d.ts +0 -3
  22. package/dist/cjs/serialization/resources/drafts/types/index.js +0 -3
  23. package/dist/cjs/serialization/types/ErrorCode.d.ts +7 -0
  24. package/dist/cjs/serialization/{resources/drafts/types/CreateDraftReplyAllRequest.js → types/ErrorCode.js} +3 -20
  25. package/dist/cjs/serialization/types/ErrorDocs.d.ts +7 -0
  26. package/dist/cjs/serialization/{resources/drafts/types/CreateDraftForwardRequest.js → types/ErrorDocs.js} +3 -26
  27. package/dist/cjs/serialization/types/ErrorFix.d.ts +7 -0
  28. package/dist/cjs/serialization/types/ErrorFix.js +39 -0
  29. package/dist/cjs/serialization/types/ErrorResponse.d.ts +6 -0
  30. package/dist/cjs/serialization/types/ErrorResponse.js +6 -0
  31. package/dist/cjs/serialization/types/ValidationErrorResponse.d.ts +8 -0
  32. package/dist/cjs/serialization/types/ValidationErrorResponse.js +8 -0
  33. package/dist/cjs/serialization/types/index.d.ts +3 -0
  34. package/dist/cjs/serialization/types/index.js +3 -0
  35. package/dist/cjs/version.d.ts +1 -1
  36. package/dist/cjs/version.js +1 -1
  37. package/dist/esm/BaseClient.mjs +2 -2
  38. package/dist/esm/api/resources/drafts/types/CreateDraftRequest.d.mts +17 -0
  39. package/dist/esm/api/resources/drafts/types/UpdateDraftRequest.d.mts +22 -8
  40. package/dist/esm/api/resources/drafts/types/index.d.mts +0 -3
  41. package/dist/esm/api/resources/drafts/types/index.mjs +0 -3
  42. package/dist/esm/api/resources/inboxes/resources/drafts/client/Client.d.mts +13 -0
  43. package/dist/esm/api/resources/inboxes/resources/drafts/client/Client.mjs +37 -0
  44. package/dist/esm/api/resources/inboxes/resources/messages/client/Client.d.mts +0 -69
  45. package/dist/esm/api/resources/inboxes/resources/messages/client/Client.mjs +0 -264
  46. package/dist/esm/api/types/ErrorCode.d.mts +4 -0
  47. package/dist/esm/api/types/ErrorDocs.d.mts +4 -0
  48. package/dist/esm/api/types/ErrorFix.d.mts +4 -0
  49. package/dist/esm/api/types/ErrorResponse.d.mts +3 -0
  50. package/dist/esm/api/types/ValidationErrorResponse.d.mts +5 -1
  51. package/dist/esm/api/types/index.d.mts +3 -0
  52. package/dist/esm/api/types/index.mjs +3 -0
  53. package/dist/esm/serialization/resources/drafts/types/CreateDraftRequest.d.mts +4 -0
  54. package/dist/esm/serialization/resources/drafts/types/CreateDraftRequest.mjs +4 -0
  55. package/dist/esm/serialization/resources/drafts/types/UpdateDraftRequest.d.mts +15 -8
  56. package/dist/esm/serialization/resources/drafts/types/UpdateDraftRequest.mjs +15 -8
  57. package/dist/esm/serialization/resources/drafts/types/index.d.mts +0 -3
  58. package/dist/esm/serialization/resources/drafts/types/index.mjs +0 -3
  59. package/dist/esm/serialization/types/ErrorCode.d.mts +7 -0
  60. package/dist/esm/serialization/types/ErrorCode.mjs +3 -0
  61. package/dist/esm/serialization/types/ErrorDocs.d.mts +7 -0
  62. package/dist/esm/serialization/types/ErrorDocs.mjs +3 -0
  63. package/dist/esm/serialization/types/ErrorFix.d.mts +7 -0
  64. package/dist/esm/serialization/types/ErrorFix.mjs +3 -0
  65. package/dist/esm/serialization/types/ErrorResponse.d.mts +6 -0
  66. package/dist/esm/serialization/types/ErrorResponse.mjs +6 -0
  67. package/dist/esm/serialization/types/ValidationErrorResponse.d.mts +8 -0
  68. package/dist/esm/serialization/types/ValidationErrorResponse.mjs +8 -0
  69. package/dist/esm/serialization/types/index.d.mts +3 -0
  70. package/dist/esm/serialization/types/index.mjs +3 -0
  71. package/dist/esm/version.d.mts +1 -1
  72. package/dist/esm/version.mjs +1 -1
  73. package/package.json +1 -1
  74. package/reference.md +10 -258
  75. package/dist/cjs/api/resources/drafts/types/CreateDraftForwardRequest.d.ts +0 -21
  76. package/dist/cjs/api/resources/drafts/types/CreateDraftReplyAllRequest.d.ts +0 -17
  77. package/dist/cjs/api/resources/drafts/types/CreateDraftReplyRequest.d.ts +0 -22
  78. package/dist/cjs/serialization/resources/drafts/types/CreateDraftForwardRequest.d.ts +0 -30
  79. package/dist/cjs/serialization/resources/drafts/types/CreateDraftReplyAllRequest.d.ts +0 -24
  80. package/dist/cjs/serialization/resources/drafts/types/CreateDraftReplyRequest.d.ts +0 -32
  81. package/dist/cjs/serialization/resources/drafts/types/CreateDraftReplyRequest.js +0 -64
  82. package/dist/esm/api/resources/drafts/types/CreateDraftForwardRequest.d.mts +0 -21
  83. package/dist/esm/api/resources/drafts/types/CreateDraftReplyAllRequest.d.mts +0 -17
  84. package/dist/esm/api/resources/drafts/types/CreateDraftReplyRequest.d.mts +0 -22
  85. package/dist/esm/serialization/resources/drafts/types/CreateDraftForwardRequest.d.mts +0 -30
  86. package/dist/esm/serialization/resources/drafts/types/CreateDraftForwardRequest.mjs +0 -26
  87. package/dist/esm/serialization/resources/drafts/types/CreateDraftReplyAllRequest.d.mts +0 -24
  88. package/dist/esm/serialization/resources/drafts/types/CreateDraftReplyAllRequest.mjs +0 -20
  89. package/dist/esm/serialization/resources/drafts/types/CreateDraftReplyRequest.d.mts +0 -32
  90. package/dist/esm/serialization/resources/drafts/types/CreateDraftReplyRequest.mjs +0 -28
  91. /package/dist/cjs/api/{resources/drafts/types/CreateDraftForwardRequest.js → types/ErrorCode.js} +0 -0
  92. /package/dist/cjs/api/{resources/drafts/types/CreateDraftReplyAllRequest.js → types/ErrorDocs.js} +0 -0
  93. /package/dist/cjs/api/{resources/drafts/types/CreateDraftReplyRequest.js → types/ErrorFix.js} +0 -0
  94. /package/dist/esm/api/{resources/drafts/types/CreateDraftForwardRequest.mjs → types/ErrorCode.mjs} +0 -0
  95. /package/dist/esm/api/{resources/drafts/types/CreateDraftReplyAllRequest.mjs → types/ErrorDocs.mjs} +0 -0
  96. /package/dist/esm/api/{resources/drafts/types/CreateDraftReplyRequest.mjs → types/ErrorFix.mjs} +0 -0
@@ -277,73 +277,4 @@ export declare class MessagesClient {
277
277
  */
278
278
  forward(inbox_id: AgentMail.inboxes.InboxId, message_id: AgentMail.MessageId, request: AgentMail.SendMessageRequest, requestOptions?: MessagesClient.IdempotentRequestOptions): core.HttpResponsePromise<AgentMail.SendMessageResponse>;
279
279
  private __forward;
280
- /**
281
- * Create a draft that replies to a message instead of sending it. The
282
- * recipients, subject, and threading are derived from the source message.
283
- * Send it later with `Send Draft`.
284
- *
285
- * **CLI:**
286
- * ```bash
287
- * agentmail inboxes:messages draft-reply --inbox-id <inbox_id> --message-id <message_id> --text "Reply text"
288
- * ```
289
- *
290
- * @param {AgentMail.inboxes.InboxId} inbox_id
291
- * @param {AgentMail.MessageId} message_id
292
- * @param {AgentMail.CreateDraftReplyRequest} request
293
- * @param {MessagesClient.RequestOptions} requestOptions - Request-specific configuration.
294
- *
295
- * @throws {@link AgentMail.ValidationError}
296
- * @throws {@link AgentMail.NotFoundError}
297
- *
298
- * @example
299
- * await client.inboxes.messages.draftReply("inbox_id", "message_id", {})
300
- */
301
- draftReply(inbox_id: AgentMail.inboxes.InboxId, message_id: AgentMail.MessageId, request: AgentMail.CreateDraftReplyRequest, requestOptions?: MessagesClient.RequestOptions): core.HttpResponsePromise<AgentMail.Draft>;
302
- private __draftReply;
303
- /**
304
- * Create a draft that replies to every recipient of a message instead of
305
- * sending it. Recipients, subject, and threading are derived from the
306
- * source message. Send it later with `Send Draft`.
307
- *
308
- * **CLI:**
309
- * ```bash
310
- * agentmail inboxes:messages draft-reply-all --inbox-id <inbox_id> --message-id <message_id> --text "Reply text"
311
- * ```
312
- *
313
- * @param {AgentMail.inboxes.InboxId} inbox_id
314
- * @param {AgentMail.MessageId} message_id
315
- * @param {AgentMail.CreateDraftReplyAllRequest} request
316
- * @param {MessagesClient.RequestOptions} requestOptions - Request-specific configuration.
317
- *
318
- * @throws {@link AgentMail.ValidationError}
319
- * @throws {@link AgentMail.NotFoundError}
320
- *
321
- * @example
322
- * await client.inboxes.messages.draftReplyAll("inbox_id", "message_id", {})
323
- */
324
- draftReplyAll(inbox_id: AgentMail.inboxes.InboxId, message_id: AgentMail.MessageId, request: AgentMail.CreateDraftReplyAllRequest, requestOptions?: MessagesClient.RequestOptions): core.HttpResponsePromise<AgentMail.Draft>;
325
- private __draftReplyAll;
326
- /**
327
- * Create a draft that forwards a message instead of sending it. The subject
328
- * and threading are derived from the source message, whose body and
329
- * attachments are merged in at send time. Send it later with `Send Draft`.
330
- *
331
- * **CLI:**
332
- * ```bash
333
- * agentmail inboxes:messages draft-forward --inbox-id <inbox_id> --message-id <message_id> --to recipient@example.com
334
- * ```
335
- *
336
- * @param {AgentMail.inboxes.InboxId} inbox_id
337
- * @param {AgentMail.MessageId} message_id
338
- * @param {AgentMail.CreateDraftForwardRequest} request
339
- * @param {MessagesClient.RequestOptions} requestOptions - Request-specific configuration.
340
- *
341
- * @throws {@link AgentMail.ValidationError}
342
- * @throws {@link AgentMail.NotFoundError}
343
- *
344
- * @example
345
- * await client.inboxes.messages.draftForward("inbox_id", "message_id", {})
346
- */
347
- draftForward(inbox_id: AgentMail.inboxes.InboxId, message_id: AgentMail.MessageId, request: AgentMail.CreateDraftForwardRequest, requestOptions?: MessagesClient.RequestOptions): core.HttpResponsePromise<AgentMail.Draft>;
348
- private __draftForward;
349
280
  }
@@ -1131,268 +1131,4 @@ export class MessagesClient {
1131
1131
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v0/inboxes/{inbox_id}/messages/{message_id}/forward");
1132
1132
  });
1133
1133
  }
1134
- /**
1135
- * Create a draft that replies to a message instead of sending it. The
1136
- * recipients, subject, and threading are derived from the source message.
1137
- * Send it later with `Send Draft`.
1138
- *
1139
- * **CLI:**
1140
- * ```bash
1141
- * agentmail inboxes:messages draft-reply --inbox-id <inbox_id> --message-id <message_id> --text "Reply text"
1142
- * ```
1143
- *
1144
- * @param {AgentMail.inboxes.InboxId} inbox_id
1145
- * @param {AgentMail.MessageId} message_id
1146
- * @param {AgentMail.CreateDraftReplyRequest} request
1147
- * @param {MessagesClient.RequestOptions} requestOptions - Request-specific configuration.
1148
- *
1149
- * @throws {@link AgentMail.ValidationError}
1150
- * @throws {@link AgentMail.NotFoundError}
1151
- *
1152
- * @example
1153
- * await client.inboxes.messages.draftReply("inbox_id", "message_id", {})
1154
- */
1155
- draftReply(inbox_id, message_id, request, requestOptions) {
1156
- return core.HttpResponsePromise.fromPromise(this.__draftReply(inbox_id, message_id, request, requestOptions));
1157
- }
1158
- __draftReply(inbox_id, message_id, request, requestOptions) {
1159
- return __awaiter(this, void 0, void 0, function* () {
1160
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
1161
- const _authRequest = yield this._options.authProvider.getAuthRequest();
1162
- const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
1163
- const _response = yield core.fetcher({
1164
- 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)
1165
- .http, `/v0/inboxes/${core.url.encodePathParam(serializers.inboxes.InboxId.jsonOrThrow(inbox_id, { omitUndefined: true }))}/messages/${core.url.encodePathParam(serializers.MessageId.jsonOrThrow(message_id, { omitUndefined: true }))}/draft-reply`),
1166
- method: "POST",
1167
- headers: _headers,
1168
- contentType: "application/json",
1169
- queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
1170
- requestType: "json",
1171
- body: serializers.CreateDraftReplyRequest.jsonOrThrow(request, {
1172
- unrecognizedObjectKeys: "strip",
1173
- omitUndefined: true,
1174
- }),
1175
- 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,
1176
- 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,
1177
- abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
1178
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
1179
- logging: this._options.logging,
1180
- });
1181
- if (_response.ok) {
1182
- return {
1183
- data: serializers.Draft.parseOrThrow(_response.body, {
1184
- unrecognizedObjectKeys: "passthrough",
1185
- allowUnrecognizedUnionMembers: true,
1186
- allowUnrecognizedEnumValues: true,
1187
- skipValidation: true,
1188
- breadcrumbsPrefix: ["response"],
1189
- }),
1190
- rawResponse: _response.rawResponse,
1191
- };
1192
- }
1193
- if (_response.error.reason === "status-code") {
1194
- switch (_response.error.statusCode) {
1195
- case 400:
1196
- throw new AgentMail.ValidationError(serializers.ValidationErrorResponse.parseOrThrow(_response.error.body, {
1197
- unrecognizedObjectKeys: "passthrough",
1198
- allowUnrecognizedUnionMembers: true,
1199
- allowUnrecognizedEnumValues: true,
1200
- skipValidation: true,
1201
- breadcrumbsPrefix: ["response"],
1202
- }), _response.rawResponse);
1203
- case 404:
1204
- throw new AgentMail.NotFoundError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
1205
- unrecognizedObjectKeys: "passthrough",
1206
- allowUnrecognizedUnionMembers: true,
1207
- allowUnrecognizedEnumValues: true,
1208
- skipValidation: true,
1209
- breadcrumbsPrefix: ["response"],
1210
- }), _response.rawResponse);
1211
- default:
1212
- throw new errors.AgentMailError({
1213
- statusCode: _response.error.statusCode,
1214
- body: _response.error.body,
1215
- rawResponse: _response.rawResponse,
1216
- });
1217
- }
1218
- }
1219
- return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v0/inboxes/{inbox_id}/messages/{message_id}/draft-reply");
1220
- });
1221
- }
1222
- /**
1223
- * Create a draft that replies to every recipient of a message instead of
1224
- * sending it. Recipients, subject, and threading are derived from the
1225
- * source message. Send it later with `Send Draft`.
1226
- *
1227
- * **CLI:**
1228
- * ```bash
1229
- * agentmail inboxes:messages draft-reply-all --inbox-id <inbox_id> --message-id <message_id> --text "Reply text"
1230
- * ```
1231
- *
1232
- * @param {AgentMail.inboxes.InboxId} inbox_id
1233
- * @param {AgentMail.MessageId} message_id
1234
- * @param {AgentMail.CreateDraftReplyAllRequest} request
1235
- * @param {MessagesClient.RequestOptions} requestOptions - Request-specific configuration.
1236
- *
1237
- * @throws {@link AgentMail.ValidationError}
1238
- * @throws {@link AgentMail.NotFoundError}
1239
- *
1240
- * @example
1241
- * await client.inboxes.messages.draftReplyAll("inbox_id", "message_id", {})
1242
- */
1243
- draftReplyAll(inbox_id, message_id, request, requestOptions) {
1244
- return core.HttpResponsePromise.fromPromise(this.__draftReplyAll(inbox_id, message_id, request, requestOptions));
1245
- }
1246
- __draftReplyAll(inbox_id, message_id, request, requestOptions) {
1247
- return __awaiter(this, void 0, void 0, function* () {
1248
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
1249
- const _authRequest = yield this._options.authProvider.getAuthRequest();
1250
- const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
1251
- const _response = yield core.fetcher({
1252
- 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)
1253
- .http, `/v0/inboxes/${core.url.encodePathParam(serializers.inboxes.InboxId.jsonOrThrow(inbox_id, { omitUndefined: true }))}/messages/${core.url.encodePathParam(serializers.MessageId.jsonOrThrow(message_id, { omitUndefined: true }))}/draft-reply-all`),
1254
- method: "POST",
1255
- headers: _headers,
1256
- contentType: "application/json",
1257
- queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
1258
- requestType: "json",
1259
- body: serializers.CreateDraftReplyAllRequest.jsonOrThrow(request, {
1260
- unrecognizedObjectKeys: "strip",
1261
- omitUndefined: true,
1262
- }),
1263
- 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,
1264
- 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,
1265
- abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
1266
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
1267
- logging: this._options.logging,
1268
- });
1269
- if (_response.ok) {
1270
- return {
1271
- data: serializers.Draft.parseOrThrow(_response.body, {
1272
- unrecognizedObjectKeys: "passthrough",
1273
- allowUnrecognizedUnionMembers: true,
1274
- allowUnrecognizedEnumValues: true,
1275
- skipValidation: true,
1276
- breadcrumbsPrefix: ["response"],
1277
- }),
1278
- rawResponse: _response.rawResponse,
1279
- };
1280
- }
1281
- if (_response.error.reason === "status-code") {
1282
- switch (_response.error.statusCode) {
1283
- case 400:
1284
- throw new AgentMail.ValidationError(serializers.ValidationErrorResponse.parseOrThrow(_response.error.body, {
1285
- unrecognizedObjectKeys: "passthrough",
1286
- allowUnrecognizedUnionMembers: true,
1287
- allowUnrecognizedEnumValues: true,
1288
- skipValidation: true,
1289
- breadcrumbsPrefix: ["response"],
1290
- }), _response.rawResponse);
1291
- case 404:
1292
- throw new AgentMail.NotFoundError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
1293
- unrecognizedObjectKeys: "passthrough",
1294
- allowUnrecognizedUnionMembers: true,
1295
- allowUnrecognizedEnumValues: true,
1296
- skipValidation: true,
1297
- breadcrumbsPrefix: ["response"],
1298
- }), _response.rawResponse);
1299
- default:
1300
- throw new errors.AgentMailError({
1301
- statusCode: _response.error.statusCode,
1302
- body: _response.error.body,
1303
- rawResponse: _response.rawResponse,
1304
- });
1305
- }
1306
- }
1307
- return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v0/inboxes/{inbox_id}/messages/{message_id}/draft-reply-all");
1308
- });
1309
- }
1310
- /**
1311
- * Create a draft that forwards a message instead of sending it. The subject
1312
- * and threading are derived from the source message, whose body and
1313
- * attachments are merged in at send time. Send it later with `Send Draft`.
1314
- *
1315
- * **CLI:**
1316
- * ```bash
1317
- * agentmail inboxes:messages draft-forward --inbox-id <inbox_id> --message-id <message_id> --to recipient@example.com
1318
- * ```
1319
- *
1320
- * @param {AgentMail.inboxes.InboxId} inbox_id
1321
- * @param {AgentMail.MessageId} message_id
1322
- * @param {AgentMail.CreateDraftForwardRequest} request
1323
- * @param {MessagesClient.RequestOptions} requestOptions - Request-specific configuration.
1324
- *
1325
- * @throws {@link AgentMail.ValidationError}
1326
- * @throws {@link AgentMail.NotFoundError}
1327
- *
1328
- * @example
1329
- * await client.inboxes.messages.draftForward("inbox_id", "message_id", {})
1330
- */
1331
- draftForward(inbox_id, message_id, request, requestOptions) {
1332
- return core.HttpResponsePromise.fromPromise(this.__draftForward(inbox_id, message_id, request, requestOptions));
1333
- }
1334
- __draftForward(inbox_id, message_id, request, requestOptions) {
1335
- return __awaiter(this, void 0, void 0, function* () {
1336
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
1337
- const _authRequest = yield this._options.authProvider.getAuthRequest();
1338
- const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
1339
- const _response = yield core.fetcher({
1340
- 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)
1341
- .http, `/v0/inboxes/${core.url.encodePathParam(serializers.inboxes.InboxId.jsonOrThrow(inbox_id, { omitUndefined: true }))}/messages/${core.url.encodePathParam(serializers.MessageId.jsonOrThrow(message_id, { omitUndefined: true }))}/draft-forward`),
1342
- method: "POST",
1343
- headers: _headers,
1344
- contentType: "application/json",
1345
- queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
1346
- requestType: "json",
1347
- body: serializers.CreateDraftForwardRequest.jsonOrThrow(request, {
1348
- unrecognizedObjectKeys: "strip",
1349
- omitUndefined: true,
1350
- }),
1351
- 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,
1352
- 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,
1353
- abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
1354
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
1355
- logging: this._options.logging,
1356
- });
1357
- if (_response.ok) {
1358
- return {
1359
- data: serializers.Draft.parseOrThrow(_response.body, {
1360
- unrecognizedObjectKeys: "passthrough",
1361
- allowUnrecognizedUnionMembers: true,
1362
- allowUnrecognizedEnumValues: true,
1363
- skipValidation: true,
1364
- breadcrumbsPrefix: ["response"],
1365
- }),
1366
- rawResponse: _response.rawResponse,
1367
- };
1368
- }
1369
- if (_response.error.reason === "status-code") {
1370
- switch (_response.error.statusCode) {
1371
- case 400:
1372
- throw new AgentMail.ValidationError(serializers.ValidationErrorResponse.parseOrThrow(_response.error.body, {
1373
- unrecognizedObjectKeys: "passthrough",
1374
- allowUnrecognizedUnionMembers: true,
1375
- allowUnrecognizedEnumValues: true,
1376
- skipValidation: true,
1377
- breadcrumbsPrefix: ["response"],
1378
- }), _response.rawResponse);
1379
- case 404:
1380
- throw new AgentMail.NotFoundError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
1381
- unrecognizedObjectKeys: "passthrough",
1382
- allowUnrecognizedUnionMembers: true,
1383
- allowUnrecognizedEnumValues: true,
1384
- skipValidation: true,
1385
- breadcrumbsPrefix: ["response"],
1386
- }), _response.rawResponse);
1387
- default:
1388
- throw new errors.AgentMailError({
1389
- statusCode: _response.error.statusCode,
1390
- body: _response.error.body,
1391
- rawResponse: _response.rawResponse,
1392
- });
1393
- }
1394
- }
1395
- return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v0/inboxes/{inbox_id}/messages/{message_id}/draft-forward");
1396
- });
1397
- }
1398
1134
  }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Stable, machine-readable error code in snake_case (for example, not_found or missing_permission). Branch on this rather than the message text.
3
+ */
4
+ export type ErrorCode = string;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Link to the error reference entry for this code.
3
+ */
4
+ export type ErrorDocs = string;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * The concrete next action that resolves the error.
3
+ */
4
+ export type ErrorFix = string;
@@ -1,5 +1,8 @@
1
1
  import type * as AgentMail from "../index.mjs";
2
2
  export interface ErrorResponse {
3
3
  name: AgentMail.ErrorName;
4
+ code?: AgentMail.ErrorCode;
4
5
  message: AgentMail.ErrorMessage;
6
+ fix?: AgentMail.ErrorFix;
7
+ docs?: AgentMail.ErrorDocs;
5
8
  }
@@ -1,6 +1,10 @@
1
1
  import type * as AgentMail from "../index.mjs";
2
2
  export interface ValidationErrorResponse {
3
3
  name: AgentMail.ErrorName;
4
- /** Validation errors. */
4
+ code?: AgentMail.ErrorCode;
5
+ message?: AgentMail.ErrorMessage;
6
+ /** Validation errors. Each entry has a path and a message identifying the invalid field. */
5
7
  errors?: unknown;
8
+ fix?: AgentMail.ErrorFix;
9
+ docs?: AgentMail.ErrorDocs;
6
10
  }
@@ -2,6 +2,9 @@ export * from "./After.mjs";
2
2
  export * from "./Ascending.mjs";
3
3
  export * from "./Before.mjs";
4
4
  export * from "./Count.mjs";
5
+ export * from "./ErrorCode.mjs";
6
+ export * from "./ErrorDocs.mjs";
7
+ export * from "./ErrorFix.mjs";
5
8
  export * from "./ErrorMessage.mjs";
6
9
  export * from "./ErrorName.mjs";
7
10
  export * from "./ErrorResponse.mjs";
@@ -2,6 +2,9 @@ export * from "./After.mjs";
2
2
  export * from "./Ascending.mjs";
3
3
  export * from "./Before.mjs";
4
4
  export * from "./Count.mjs";
5
+ export * from "./ErrorCode.mjs";
6
+ export * from "./ErrorDocs.mjs";
7
+ export * from "./ErrorFix.mjs";
5
8
  export * from "./ErrorMessage.mjs";
6
9
  export * from "./ErrorName.mjs";
7
10
  export * from "./ErrorResponse.mjs";
@@ -5,9 +5,11 @@ import { SendAttachment } from "../../attachments/types/SendAttachment.mjs";
5
5
  import { DraftBcc } from "./DraftBcc.mjs";
6
6
  import { DraftCc } from "./DraftCc.mjs";
7
7
  import { DraftClientId } from "./DraftClientId.mjs";
8
+ import { DraftForwardOf } from "./DraftForwardOf.mjs";
8
9
  import { DraftHtml } from "./DraftHtml.mjs";
9
10
  import { DraftInReplyTo } from "./DraftInReplyTo.mjs";
10
11
  import { DraftLabels } from "./DraftLabels.mjs";
12
+ import { DraftReplyAll } from "./DraftReplyAll.mjs";
11
13
  import { DraftReplyTo } from "./DraftReplyTo.mjs";
12
14
  import { DraftSendAt } from "./DraftSendAt.mjs";
13
15
  import { DraftSubject } from "./DraftSubject.mjs";
@@ -26,6 +28,8 @@ export declare namespace CreateDraftRequest {
26
28
  html?: DraftHtml.Raw | null;
27
29
  attachments?: SendAttachment.Raw[] | null;
28
30
  in_reply_to?: DraftInReplyTo.Raw | null;
31
+ forward_of?: DraftForwardOf.Raw | null;
32
+ reply_all?: DraftReplyAll.Raw | null;
29
33
  send_at?: DraftSendAt.Raw | null;
30
34
  client_id?: DraftClientId.Raw | null;
31
35
  }
@@ -4,9 +4,11 @@ import { SendAttachment } from "../../attachments/types/SendAttachment.mjs";
4
4
  import { DraftBcc } from "./DraftBcc.mjs";
5
5
  import { DraftCc } from "./DraftCc.mjs";
6
6
  import { DraftClientId } from "./DraftClientId.mjs";
7
+ import { DraftForwardOf } from "./DraftForwardOf.mjs";
7
8
  import { DraftHtml } from "./DraftHtml.mjs";
8
9
  import { DraftInReplyTo } from "./DraftInReplyTo.mjs";
9
10
  import { DraftLabels } from "./DraftLabels.mjs";
11
+ import { DraftReplyAll } from "./DraftReplyAll.mjs";
10
12
  import { DraftReplyTo } from "./DraftReplyTo.mjs";
11
13
  import { DraftSendAt } from "./DraftSendAt.mjs";
12
14
  import { DraftSubject } from "./DraftSubject.mjs";
@@ -23,6 +25,8 @@ export const CreateDraftRequest = core.serialization.object({
23
25
  html: DraftHtml.optional(),
24
26
  attachments: core.serialization.list(SendAttachment).optional(),
25
27
  inReplyTo: core.serialization.property("in_reply_to", DraftInReplyTo.optional()),
28
+ forwardOf: core.serialization.property("forward_of", DraftForwardOf.optional()),
29
+ replyAll: core.serialization.property("reply_all", DraftReplyAll.optional()),
26
30
  sendAt: core.serialization.property("send_at", DraftSendAt.optional()),
27
31
  clientId: core.serialization.property("client_id", DraftClientId.optional()),
28
32
  });
@@ -1,9 +1,12 @@
1
1
  import type * as AgentMail from "../../../../api/index.mjs";
2
2
  import * as core from "../../../../core/index.mjs";
3
3
  import type * as serializers from "../../../index.mjs";
4
+ import { AttachmentId } from "../../attachments/types/AttachmentId.mjs";
5
+ import { SendAttachment } from "../../attachments/types/SendAttachment.mjs";
4
6
  import { DraftBcc } from "./DraftBcc.mjs";
5
7
  import { DraftCc } from "./DraftCc.mjs";
6
8
  import { DraftHtml } from "./DraftHtml.mjs";
9
+ import { DraftLabels } from "./DraftLabels.mjs";
7
10
  import { DraftReplyTo } from "./DraftReplyTo.mjs";
8
11
  import { DraftSendAt } from "./DraftSendAt.mjs";
9
12
  import { DraftSubject } from "./DraftSubject.mjs";
@@ -12,13 +15,17 @@ import { DraftTo } from "./DraftTo.mjs";
12
15
  export declare const UpdateDraftRequest: core.serialization.ObjectSchema<serializers.UpdateDraftRequest.Raw, AgentMail.UpdateDraftRequest>;
13
16
  export declare namespace UpdateDraftRequest {
14
17
  interface Raw {
15
- reply_to?: DraftReplyTo.Raw | null;
16
- to?: DraftTo.Raw | null;
17
- cc?: DraftCc.Raw | null;
18
- bcc?: DraftBcc.Raw | null;
19
- subject?: DraftSubject.Raw | null;
20
- text?: DraftText.Raw | null;
21
- html?: DraftHtml.Raw | null;
22
- send_at?: DraftSendAt.Raw | null;
18
+ reply_to?: (DraftReplyTo.Raw | null | undefined) | null;
19
+ to?: (DraftTo.Raw | null | undefined) | null;
20
+ cc?: (DraftCc.Raw | null | undefined) | null;
21
+ bcc?: (DraftBcc.Raw | null | undefined) | null;
22
+ subject?: (DraftSubject.Raw | null | undefined) | null;
23
+ text?: (DraftText.Raw | null | undefined) | null;
24
+ html?: (DraftHtml.Raw | null | undefined) | null;
25
+ add_attachments?: SendAttachment.Raw[] | null;
26
+ remove_attachments?: AttachmentId.Raw[] | null;
27
+ add_labels?: DraftLabels.Raw | null;
28
+ remove_labels?: DraftLabels.Raw | null;
29
+ send_at?: (DraftSendAt.Raw | null | undefined) | null;
23
30
  }
24
31
  }
@@ -1,20 +1,27 @@
1
1
  // This file was auto-generated by Fern from our API Definition.
2
2
  import * as core from "../../../../core/index.mjs";
3
+ import { AttachmentId } from "../../attachments/types/AttachmentId.mjs";
4
+ import { SendAttachment } from "../../attachments/types/SendAttachment.mjs";
3
5
  import { DraftBcc } from "./DraftBcc.mjs";
4
6
  import { DraftCc } from "./DraftCc.mjs";
5
7
  import { DraftHtml } from "./DraftHtml.mjs";
8
+ import { DraftLabels } from "./DraftLabels.mjs";
6
9
  import { DraftReplyTo } from "./DraftReplyTo.mjs";
7
10
  import { DraftSendAt } from "./DraftSendAt.mjs";
8
11
  import { DraftSubject } from "./DraftSubject.mjs";
9
12
  import { DraftText } from "./DraftText.mjs";
10
13
  import { DraftTo } from "./DraftTo.mjs";
11
14
  export const UpdateDraftRequest = core.serialization.object({
12
- replyTo: core.serialization.property("reply_to", DraftReplyTo.optional()),
13
- to: DraftTo.optional(),
14
- cc: DraftCc.optional(),
15
- bcc: DraftBcc.optional(),
16
- subject: DraftSubject.optional(),
17
- text: DraftText.optional(),
18
- html: DraftHtml.optional(),
19
- sendAt: core.serialization.property("send_at", DraftSendAt.optional()),
15
+ replyTo: core.serialization.property("reply_to", DraftReplyTo.optionalNullable()),
16
+ to: DraftTo.optionalNullable(),
17
+ cc: DraftCc.optionalNullable(),
18
+ bcc: DraftBcc.optionalNullable(),
19
+ subject: DraftSubject.optionalNullable(),
20
+ text: DraftText.optionalNullable(),
21
+ html: DraftHtml.optionalNullable(),
22
+ addAttachments: core.serialization.property("add_attachments", core.serialization.list(SendAttachment).optional()),
23
+ removeAttachments: core.serialization.property("remove_attachments", core.serialization.list(AttachmentId).optional()),
24
+ addLabels: core.serialization.property("add_labels", DraftLabels.optional()),
25
+ removeLabels: core.serialization.property("remove_labels", DraftLabels.optional()),
26
+ sendAt: core.serialization.property("send_at", DraftSendAt.optionalNullable()),
20
27
  });
@@ -1,6 +1,3 @@
1
- export * from "./CreateDraftForwardRequest.mjs";
2
- export * from "./CreateDraftReplyAllRequest.mjs";
3
- export * from "./CreateDraftReplyRequest.mjs";
4
1
  export * from "./CreateDraftRequest.mjs";
5
2
  export * from "./Draft.mjs";
6
3
  export * from "./DraftAttachments.mjs";
@@ -1,6 +1,3 @@
1
- export * from "./CreateDraftForwardRequest.mjs";
2
- export * from "./CreateDraftReplyAllRequest.mjs";
3
- export * from "./CreateDraftReplyRequest.mjs";
4
1
  export * from "./CreateDraftRequest.mjs";
5
2
  export * from "./Draft.mjs";
6
3
  export * from "./DraftAttachments.mjs";
@@ -0,0 +1,7 @@
1
+ import type * as AgentMail from "../../api/index.mjs";
2
+ import * as core from "../../core/index.mjs";
3
+ import type * as serializers from "../index.mjs";
4
+ export declare const ErrorCode: core.serialization.Schema<serializers.ErrorCode.Raw, AgentMail.ErrorCode>;
5
+ export declare namespace ErrorCode {
6
+ type Raw = string;
7
+ }
@@ -0,0 +1,3 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ import * as core from "../../core/index.mjs";
3
+ export const ErrorCode = core.serialization.string();
@@ -0,0 +1,7 @@
1
+ import type * as AgentMail from "../../api/index.mjs";
2
+ import * as core from "../../core/index.mjs";
3
+ import type * as serializers from "../index.mjs";
4
+ export declare const ErrorDocs: core.serialization.Schema<serializers.ErrorDocs.Raw, AgentMail.ErrorDocs>;
5
+ export declare namespace ErrorDocs {
6
+ type Raw = string;
7
+ }
@@ -0,0 +1,3 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ import * as core from "../../core/index.mjs";
3
+ export const ErrorDocs = core.serialization.string();
@@ -0,0 +1,7 @@
1
+ import type * as AgentMail from "../../api/index.mjs";
2
+ import * as core from "../../core/index.mjs";
3
+ import type * as serializers from "../index.mjs";
4
+ export declare const ErrorFix: core.serialization.Schema<serializers.ErrorFix.Raw, AgentMail.ErrorFix>;
5
+ export declare namespace ErrorFix {
6
+ type Raw = string;
7
+ }
@@ -0,0 +1,3 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ import * as core from "../../core/index.mjs";
3
+ export const ErrorFix = core.serialization.string();
@@ -1,12 +1,18 @@
1
1
  import type * as AgentMail from "../../api/index.mjs";
2
2
  import * as core from "../../core/index.mjs";
3
3
  import type * as serializers from "../index.mjs";
4
+ import { ErrorCode } from "./ErrorCode.mjs";
5
+ import { ErrorDocs } from "./ErrorDocs.mjs";
6
+ import { ErrorFix } from "./ErrorFix.mjs";
4
7
  import { ErrorMessage } from "./ErrorMessage.mjs";
5
8
  import { ErrorName } from "./ErrorName.mjs";
6
9
  export declare const ErrorResponse: core.serialization.ObjectSchema<serializers.ErrorResponse.Raw, AgentMail.ErrorResponse>;
7
10
  export declare namespace ErrorResponse {
8
11
  interface Raw {
9
12
  name: ErrorName.Raw;
13
+ code?: ErrorCode.Raw | null;
10
14
  message: ErrorMessage.Raw;
15
+ fix?: ErrorFix.Raw | null;
16
+ docs?: ErrorDocs.Raw | null;
11
17
  }
12
18
  }
@@ -1,8 +1,14 @@
1
1
  // This file was auto-generated by Fern from our API Definition.
2
2
  import * as core from "../../core/index.mjs";
3
+ import { ErrorCode } from "./ErrorCode.mjs";
4
+ import { ErrorDocs } from "./ErrorDocs.mjs";
5
+ import { ErrorFix } from "./ErrorFix.mjs";
3
6
  import { ErrorMessage } from "./ErrorMessage.mjs";
4
7
  import { ErrorName } from "./ErrorName.mjs";
5
8
  export const ErrorResponse = core.serialization.object({
6
9
  name: ErrorName,
10
+ code: ErrorCode.optional(),
7
11
  message: ErrorMessage,
12
+ fix: ErrorFix.optional(),
13
+ docs: ErrorDocs.optional(),
8
14
  });
@@ -1,11 +1,19 @@
1
1
  import type * as AgentMail from "../../api/index.mjs";
2
2
  import * as core from "../../core/index.mjs";
3
3
  import type * as serializers from "../index.mjs";
4
+ import { ErrorCode } from "./ErrorCode.mjs";
5
+ import { ErrorDocs } from "./ErrorDocs.mjs";
6
+ import { ErrorFix } from "./ErrorFix.mjs";
7
+ import { ErrorMessage } from "./ErrorMessage.mjs";
4
8
  import { ErrorName } from "./ErrorName.mjs";
5
9
  export declare const ValidationErrorResponse: core.serialization.ObjectSchema<serializers.ValidationErrorResponse.Raw, AgentMail.ValidationErrorResponse>;
6
10
  export declare namespace ValidationErrorResponse {
7
11
  interface Raw {
8
12
  name: ErrorName.Raw;
13
+ code?: ErrorCode.Raw | null;
14
+ message?: ErrorMessage.Raw | null;
9
15
  errors?: unknown;
16
+ fix?: ErrorFix.Raw | null;
17
+ docs?: ErrorDocs.Raw | null;
10
18
  }
11
19
  }