agentmail 0.5.13 → 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 (107) hide show
  1. package/dist/cjs/BaseClient.d.ts +3 -0
  2. package/dist/cjs/BaseClient.js +2 -2
  3. package/dist/cjs/api/errors/ConflictError.d.ts +6 -0
  4. package/dist/cjs/{serialization/resources/drafts/types/CreateDraftReplyAllRequest.js → api/errors/ConflictError.js} +18 -20
  5. package/dist/cjs/api/errors/index.d.ts +1 -0
  6. package/dist/cjs/api/errors/index.js +1 -0
  7. package/dist/cjs/api/resources/drafts/types/CreateDraftRequest.d.ts +17 -0
  8. package/dist/cjs/api/resources/drafts/types/UpdateDraftRequest.d.ts +22 -8
  9. package/dist/cjs/api/resources/drafts/types/index.d.ts +0 -3
  10. package/dist/cjs/api/resources/drafts/types/index.js +0 -3
  11. package/dist/cjs/api/resources/inboxes/resources/drafts/client/Client.d.ts +19 -3
  12. package/dist/cjs/api/resources/inboxes/resources/drafts/client/Client.js +48 -2
  13. package/dist/cjs/api/resources/inboxes/resources/messages/client/Client.d.ts +15 -78
  14. package/dist/cjs/api/resources/inboxes/resources/messages/client/Client.js +41 -269
  15. package/dist/cjs/api/types/ErrorCode.d.ts +4 -0
  16. package/dist/cjs/api/types/ErrorDocs.d.ts +4 -0
  17. package/dist/cjs/api/types/ErrorFix.d.ts +4 -0
  18. package/dist/cjs/api/types/ErrorResponse.d.ts +3 -0
  19. package/dist/cjs/api/types/ValidationErrorResponse.d.ts +5 -1
  20. package/dist/cjs/api/types/index.d.ts +3 -0
  21. package/dist/cjs/api/types/index.js +3 -0
  22. package/dist/cjs/serialization/resources/drafts/types/CreateDraftRequest.d.ts +4 -0
  23. package/dist/cjs/serialization/resources/drafts/types/CreateDraftRequest.js +4 -0
  24. package/dist/cjs/serialization/resources/drafts/types/UpdateDraftRequest.d.ts +15 -8
  25. package/dist/cjs/serialization/resources/drafts/types/UpdateDraftRequest.js +15 -8
  26. package/dist/cjs/serialization/resources/drafts/types/index.d.ts +0 -3
  27. package/dist/cjs/serialization/resources/drafts/types/index.js +0 -3
  28. package/dist/cjs/serialization/types/ErrorCode.d.ts +7 -0
  29. package/dist/cjs/serialization/{resources/drafts/types/CreateDraftForwardRequest.js → types/ErrorCode.js} +3 -26
  30. package/dist/cjs/serialization/types/ErrorDocs.d.ts +7 -0
  31. package/dist/cjs/serialization/types/ErrorDocs.js +39 -0
  32. package/dist/cjs/serialization/types/ErrorFix.d.ts +7 -0
  33. package/dist/cjs/serialization/types/ErrorFix.js +39 -0
  34. package/dist/cjs/serialization/types/ErrorResponse.d.ts +6 -0
  35. package/dist/cjs/serialization/types/ErrorResponse.js +6 -0
  36. package/dist/cjs/serialization/types/ValidationErrorResponse.d.ts +8 -0
  37. package/dist/cjs/serialization/types/ValidationErrorResponse.js +8 -0
  38. package/dist/cjs/serialization/types/index.d.ts +3 -0
  39. package/dist/cjs/serialization/types/index.js +3 -0
  40. package/dist/cjs/version.d.ts +1 -1
  41. package/dist/cjs/version.js +1 -1
  42. package/dist/esm/BaseClient.d.mts +3 -0
  43. package/dist/esm/BaseClient.mjs +2 -2
  44. package/dist/esm/api/errors/ConflictError.d.mts +6 -0
  45. package/dist/esm/api/errors/ConflictError.mjs +17 -0
  46. package/dist/esm/api/errors/index.d.mts +1 -0
  47. package/dist/esm/api/errors/index.mjs +1 -0
  48. package/dist/esm/api/resources/drafts/types/CreateDraftRequest.d.mts +17 -0
  49. package/dist/esm/api/resources/drafts/types/UpdateDraftRequest.d.mts +22 -8
  50. package/dist/esm/api/resources/drafts/types/index.d.mts +0 -3
  51. package/dist/esm/api/resources/drafts/types/index.mjs +0 -3
  52. package/dist/esm/api/resources/inboxes/resources/drafts/client/Client.d.mts +19 -3
  53. package/dist/esm/api/resources/inboxes/resources/drafts/client/Client.mjs +49 -3
  54. package/dist/esm/api/resources/inboxes/resources/messages/client/Client.d.mts +15 -78
  55. package/dist/esm/api/resources/inboxes/resources/messages/client/Client.mjs +42 -270
  56. package/dist/esm/api/types/ErrorCode.d.mts +4 -0
  57. package/dist/esm/api/types/ErrorDocs.d.mts +4 -0
  58. package/dist/esm/api/types/ErrorFix.d.mts +4 -0
  59. package/dist/esm/api/types/ErrorResponse.d.mts +3 -0
  60. package/dist/esm/api/types/ValidationErrorResponse.d.mts +5 -1
  61. package/dist/esm/api/types/index.d.mts +3 -0
  62. package/dist/esm/api/types/index.mjs +3 -0
  63. package/dist/esm/serialization/resources/drafts/types/CreateDraftRequest.d.mts +4 -0
  64. package/dist/esm/serialization/resources/drafts/types/CreateDraftRequest.mjs +4 -0
  65. package/dist/esm/serialization/resources/drafts/types/UpdateDraftRequest.d.mts +15 -8
  66. package/dist/esm/serialization/resources/drafts/types/UpdateDraftRequest.mjs +15 -8
  67. package/dist/esm/serialization/resources/drafts/types/index.d.mts +0 -3
  68. package/dist/esm/serialization/resources/drafts/types/index.mjs +0 -3
  69. package/dist/esm/serialization/types/ErrorCode.d.mts +7 -0
  70. package/dist/esm/serialization/types/ErrorCode.mjs +3 -0
  71. package/dist/esm/serialization/types/ErrorDocs.d.mts +7 -0
  72. package/dist/esm/serialization/types/ErrorDocs.mjs +3 -0
  73. package/dist/esm/serialization/types/ErrorFix.d.mts +7 -0
  74. package/dist/esm/serialization/types/ErrorFix.mjs +3 -0
  75. package/dist/esm/serialization/types/ErrorResponse.d.mts +6 -0
  76. package/dist/esm/serialization/types/ErrorResponse.mjs +6 -0
  77. package/dist/esm/serialization/types/ValidationErrorResponse.d.mts +8 -0
  78. package/dist/esm/serialization/types/ValidationErrorResponse.mjs +8 -0
  79. package/dist/esm/serialization/types/index.d.mts +3 -0
  80. package/dist/esm/serialization/types/index.mjs +3 -0
  81. package/dist/esm/version.d.mts +1 -1
  82. package/dist/esm/version.mjs +1 -1
  83. package/dist/llms.txt +13 -0
  84. package/package.json +1 -1
  85. package/reference.md +15 -263
  86. package/dist/cjs/api/resources/drafts/types/CreateDraftForwardRequest.d.ts +0 -21
  87. package/dist/cjs/api/resources/drafts/types/CreateDraftReplyAllRequest.d.ts +0 -17
  88. package/dist/cjs/api/resources/drafts/types/CreateDraftReplyRequest.d.ts +0 -22
  89. package/dist/cjs/serialization/resources/drafts/types/CreateDraftForwardRequest.d.ts +0 -30
  90. package/dist/cjs/serialization/resources/drafts/types/CreateDraftReplyAllRequest.d.ts +0 -24
  91. package/dist/cjs/serialization/resources/drafts/types/CreateDraftReplyRequest.d.ts +0 -32
  92. package/dist/cjs/serialization/resources/drafts/types/CreateDraftReplyRequest.js +0 -64
  93. package/dist/esm/api/resources/drafts/types/CreateDraftForwardRequest.d.mts +0 -21
  94. package/dist/esm/api/resources/drafts/types/CreateDraftReplyAllRequest.d.mts +0 -17
  95. package/dist/esm/api/resources/drafts/types/CreateDraftReplyRequest.d.mts +0 -22
  96. package/dist/esm/serialization/resources/drafts/types/CreateDraftForwardRequest.d.mts +0 -30
  97. package/dist/esm/serialization/resources/drafts/types/CreateDraftForwardRequest.mjs +0 -26
  98. package/dist/esm/serialization/resources/drafts/types/CreateDraftReplyAllRequest.d.mts +0 -24
  99. package/dist/esm/serialization/resources/drafts/types/CreateDraftReplyAllRequest.mjs +0 -20
  100. package/dist/esm/serialization/resources/drafts/types/CreateDraftReplyRequest.d.mts +0 -32
  101. package/dist/esm/serialization/resources/drafts/types/CreateDraftReplyRequest.mjs +0 -28
  102. /package/dist/cjs/api/{resources/drafts/types/CreateDraftForwardRequest.js → types/ErrorCode.js} +0 -0
  103. /package/dist/cjs/api/{resources/drafts/types/CreateDraftReplyAllRequest.js → types/ErrorDocs.js} +0 -0
  104. /package/dist/cjs/api/{resources/drafts/types/CreateDraftReplyRequest.js → types/ErrorFix.js} +0 -0
  105. /package/dist/esm/api/{resources/drafts/types/CreateDraftForwardRequest.mjs → types/ErrorCode.mjs} +0 -0
  106. /package/dist/esm/api/{resources/drafts/types/CreateDraftReplyAllRequest.mjs → types/ErrorDocs.mjs} +0 -0
  107. /package/dist/esm/api/{resources/drafts/types/CreateDraftReplyRequest.mjs → types/ErrorFix.mjs} +0 -0
@@ -34,29 +34,6 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  };
35
35
  })();
36
36
  Object.defineProperty(exports, "__esModule", { value: true });
37
- exports.CreateDraftForwardRequest = void 0;
38
- const core = __importStar(require("../../../../core/index.js"));
39
- const SendAttachment_js_1 = require("../../attachments/types/SendAttachment.js");
40
- const DraftBcc_js_1 = require("./DraftBcc.js");
41
- const DraftCc_js_1 = require("./DraftCc.js");
42
- const DraftClientId_js_1 = require("./DraftClientId.js");
43
- const DraftHtml_js_1 = require("./DraftHtml.js");
44
- const DraftLabels_js_1 = require("./DraftLabels.js");
45
- const DraftReplyTo_js_1 = require("./DraftReplyTo.js");
46
- const DraftSendAt_js_1 = require("./DraftSendAt.js");
47
- const DraftSubject_js_1 = require("./DraftSubject.js");
48
- const DraftText_js_1 = require("./DraftText.js");
49
- const DraftTo_js_1 = require("./DraftTo.js");
50
- exports.CreateDraftForwardRequest = core.serialization.object({
51
- labels: DraftLabels_js_1.DraftLabels.optional(),
52
- replyTo: core.serialization.property("reply_to", DraftReplyTo_js_1.DraftReplyTo.optional()),
53
- to: DraftTo_js_1.DraftTo.optional(),
54
- cc: DraftCc_js_1.DraftCc.optional(),
55
- bcc: DraftBcc_js_1.DraftBcc.optional(),
56
- subject: DraftSubject_js_1.DraftSubject.optional(),
57
- text: DraftText_js_1.DraftText.optional(),
58
- html: DraftHtml_js_1.DraftHtml.optional(),
59
- attachments: core.serialization.list(SendAttachment_js_1.SendAttachment).optional(),
60
- sendAt: core.serialization.property("send_at", DraftSendAt_js_1.DraftSendAt.optional()),
61
- clientId: core.serialization.property("client_id", DraftClientId_js_1.DraftClientId.optional()),
62
- });
37
+ exports.ErrorCode = void 0;
38
+ const core = __importStar(require("../../core/index.js"));
39
+ exports.ErrorCode = core.serialization.string();
@@ -0,0 +1,7 @@
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
+ 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,39 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ exports.ErrorDocs = void 0;
38
+ const core = __importStar(require("../../core/index.js"));
39
+ exports.ErrorDocs = core.serialization.string();
@@ -0,0 +1,7 @@
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
+ 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,39 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ exports.ErrorFix = void 0;
38
+ const core = __importStar(require("../../core/index.js"));
39
+ exports.ErrorFix = core.serialization.string();
@@ -1,12 +1,18 @@
1
1
  import type * as AgentMail from "../../api/index.js";
2
2
  import * as core from "../../core/index.js";
3
3
  import type * as serializers from "../index.js";
4
+ import { ErrorCode } from "./ErrorCode.js";
5
+ import { ErrorDocs } from "./ErrorDocs.js";
6
+ import { ErrorFix } from "./ErrorFix.js";
4
7
  import { ErrorMessage } from "./ErrorMessage.js";
5
8
  import { ErrorName } from "./ErrorName.js";
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
  }
@@ -36,9 +36,15 @@ var __importStar = (this && this.__importStar) || (function () {
36
36
  Object.defineProperty(exports, "__esModule", { value: true });
37
37
  exports.ErrorResponse = void 0;
38
38
  const core = __importStar(require("../../core/index.js"));
39
+ const ErrorCode_js_1 = require("./ErrorCode.js");
40
+ const ErrorDocs_js_1 = require("./ErrorDocs.js");
41
+ const ErrorFix_js_1 = require("./ErrorFix.js");
39
42
  const ErrorMessage_js_1 = require("./ErrorMessage.js");
40
43
  const ErrorName_js_1 = require("./ErrorName.js");
41
44
  exports.ErrorResponse = core.serialization.object({
42
45
  name: ErrorName_js_1.ErrorName,
46
+ code: ErrorCode_js_1.ErrorCode.optional(),
43
47
  message: ErrorMessage_js_1.ErrorMessage,
48
+ fix: ErrorFix_js_1.ErrorFix.optional(),
49
+ docs: ErrorDocs_js_1.ErrorDocs.optional(),
44
50
  });
@@ -1,11 +1,19 @@
1
1
  import type * as AgentMail from "../../api/index.js";
2
2
  import * as core from "../../core/index.js";
3
3
  import type * as serializers from "../index.js";
4
+ import { ErrorCode } from "./ErrorCode.js";
5
+ import { ErrorDocs } from "./ErrorDocs.js";
6
+ import { ErrorFix } from "./ErrorFix.js";
7
+ import { ErrorMessage } from "./ErrorMessage.js";
4
8
  import { ErrorName } from "./ErrorName.js";
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
  }
@@ -36,8 +36,16 @@ var __importStar = (this && this.__importStar) || (function () {
36
36
  Object.defineProperty(exports, "__esModule", { value: true });
37
37
  exports.ValidationErrorResponse = void 0;
38
38
  const core = __importStar(require("../../core/index.js"));
39
+ const ErrorCode_js_1 = require("./ErrorCode.js");
40
+ const ErrorDocs_js_1 = require("./ErrorDocs.js");
41
+ const ErrorFix_js_1 = require("./ErrorFix.js");
42
+ const ErrorMessage_js_1 = require("./ErrorMessage.js");
39
43
  const ErrorName_js_1 = require("./ErrorName.js");
40
44
  exports.ValidationErrorResponse = core.serialization.object({
41
45
  name: ErrorName_js_1.ErrorName,
46
+ code: ErrorCode_js_1.ErrorCode.optional(),
47
+ message: ErrorMessage_js_1.ErrorMessage.optional(),
42
48
  errors: core.serialization.unknown(),
49
+ fix: ErrorFix_js_1.ErrorFix.optional(),
50
+ docs: ErrorDocs_js_1.ErrorDocs.optional(),
43
51
  });
@@ -2,6 +2,9 @@ export * from "./After.js";
2
2
  export * from "./Ascending.js";
3
3
  export * from "./Before.js";
4
4
  export * from "./Count.js";
5
+ export * from "./ErrorCode.js";
6
+ export * from "./ErrorDocs.js";
7
+ export * from "./ErrorFix.js";
5
8
  export * from "./ErrorMessage.js";
6
9
  export * from "./ErrorName.js";
7
10
  export * from "./ErrorResponse.js";
@@ -18,6 +18,9 @@ __exportStar(require("./After.js"), exports);
18
18
  __exportStar(require("./Ascending.js"), exports);
19
19
  __exportStar(require("./Before.js"), exports);
20
20
  __exportStar(require("./Count.js"), exports);
21
+ __exportStar(require("./ErrorCode.js"), exports);
22
+ __exportStar(require("./ErrorDocs.js"), exports);
23
+ __exportStar(require("./ErrorFix.js"), exports);
21
24
  __exportStar(require("./ErrorMessage.js"), exports);
22
25
  __exportStar(require("./ErrorName.js"), exports);
23
26
  __exportStar(require("./ErrorResponse.js"), exports);
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.5.13";
1
+ export declare const SDK_VERSION = "0.5.15";
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SDK_VERSION = void 0;
4
- exports.SDK_VERSION = "0.5.13";
4
+ exports.SDK_VERSION = "0.5.15";
@@ -28,6 +28,9 @@ export interface BaseRequestOptions {
28
28
  /** Additional headers to include in the request. */
29
29
  headers?: Record<string, string | core.Supplier<string | null | undefined> | null | undefined>;
30
30
  }
31
+ export interface BaseIdempotentRequestOptions {
32
+ idempotencyKey?: string | undefined;
33
+ }
31
34
  export type NormalizedClientOptions<T extends BaseClientOptions = BaseClientOptions> = T & {
32
35
  logging: core.logging.Logger;
33
36
  authProvider?: core.AuthProvider;
@@ -6,8 +6,8 @@ export function normalizeClientOptions(options) {
6
6
  const headers = mergeHeaders({
7
7
  "X-Fern-Language": "JavaScript",
8
8
  "X-Fern-SDK-Name": "agentmail",
9
- "X-Fern-SDK-Version": "0.5.13",
10
- "User-Agent": "agentmail/0.5.13",
9
+ "X-Fern-SDK-Version": "0.5.15",
10
+ "User-Agent": "agentmail/0.5.15",
11
11
  "X-Fern-Runtime": core.RUNTIME.type,
12
12
  "X-Fern-Runtime-Version": core.RUNTIME.version,
13
13
  }, options === null || options === void 0 ? void 0 : options.headers);
@@ -0,0 +1,6 @@
1
+ import type * as core from "../../core/index.mjs";
2
+ import * as errors from "../../errors/index.mjs";
3
+ import type * as AgentMail from "../index.mjs";
4
+ export declare class ConflictError extends errors.AgentMailError {
5
+ constructor(body: AgentMail.ErrorResponse, rawResponse?: core.RawResponse);
6
+ }
@@ -0,0 +1,17 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ import * as errors from "../../errors/index.mjs";
3
+ export class ConflictError extends errors.AgentMailError {
4
+ constructor(body, rawResponse) {
5
+ super({
6
+ message: "ConflictError",
7
+ statusCode: 409,
8
+ body: body,
9
+ rawResponse: rawResponse,
10
+ });
11
+ Object.setPrototypeOf(this, new.target.prototype);
12
+ if (Error.captureStackTrace) {
13
+ Error.captureStackTrace(this, this.constructor);
14
+ }
15
+ this.name = this.constructor.name;
16
+ }
17
+ }
@@ -1,3 +1,4 @@
1
+ export * from "./ConflictError.mjs";
1
2
  export * from "./IsTakenError.mjs";
2
3
  export * from "./NotFoundError.mjs";
3
4
  export * from "./UnprocessableError.mjs";
@@ -1,3 +1,4 @@
1
+ export * from "./ConflictError.mjs";
1
2
  export * from "./IsTakenError.mjs";
2
3
  export * from "./NotFoundError.mjs";
3
4
  export * from "./UnprocessableError.mjs";
@@ -1,4 +1,19 @@
1
1
  import type * as AgentMail from "../../../index.mjs";
2
+ /**
3
+ * Body for creating a draft. Supports plain, reply, reply-all, and forward
4
+ * drafts:
5
+ *
6
+ * - **Plain draft:** supply `to`, `subject`, `text`, etc.
7
+ * - **Reply:** set `in_reply_to` to a message ID. Recipients, subject, and
8
+ * threading are derived from that message. Set `reply_all` to address the
9
+ * whole thread (you then cannot also pass `to`, `cc`, or `bcc`).
10
+ * - **Forward:** set `forward_of` to a message ID. The subject and threading
11
+ * are derived from the source message, whose body and attachments are
12
+ * merged in at send time.
13
+ *
14
+ * `in_reply_to` and `forward_of` are mutually exclusive, and reading the
15
+ * referenced message requires `message_read` permission.
16
+ */
2
17
  export interface CreateDraftRequest {
3
18
  labels?: AgentMail.DraftLabels;
4
19
  replyTo?: AgentMail.DraftReplyTo;
@@ -11,6 +26,8 @@ export interface CreateDraftRequest {
11
26
  /** Attachments to include in draft. */
12
27
  attachments?: AgentMail.SendAttachment[];
13
28
  inReplyTo?: AgentMail.DraftInReplyTo;
29
+ forwardOf?: AgentMail.DraftForwardOf;
30
+ replyAll?: AgentMail.DraftReplyAll;
14
31
  sendAt?: AgentMail.DraftSendAt;
15
32
  clientId?: AgentMail.DraftClientId;
16
33
  }
@@ -1,11 +1,25 @@
1
1
  import type * as AgentMail from "../../../index.mjs";
2
+ /**
3
+ * Edit fields on an existing draft. A draft's kind (plain, reply, or forward)
4
+ * is fixed at creation and cannot be changed here. Omitting a field leaves it
5
+ * unchanged; passing `null` (or `[]` for a recipient field) clears it. Pass
6
+ * `send_at` to schedule or reschedule the draft, or `null` to un-schedule it.
7
+ */
2
8
  export interface UpdateDraftRequest {
3
- replyTo?: AgentMail.DraftReplyTo;
4
- to?: AgentMail.DraftTo;
5
- cc?: AgentMail.DraftCc;
6
- bcc?: AgentMail.DraftBcc;
7
- subject?: AgentMail.DraftSubject;
8
- text?: AgentMail.DraftText;
9
- html?: AgentMail.DraftHtml;
10
- sendAt?: AgentMail.DraftSendAt;
9
+ replyTo?: AgentMail.DraftReplyTo | null;
10
+ to?: AgentMail.DraftTo | null;
11
+ cc?: AgentMail.DraftCc | null;
12
+ bcc?: AgentMail.DraftBcc | null;
13
+ subject?: AgentMail.DraftSubject | null;
14
+ text?: AgentMail.DraftText | null;
15
+ html?: AgentMail.DraftHtml | null;
16
+ /** Attachments to add to the draft. */
17
+ addAttachments?: AgentMail.SendAttachment[];
18
+ /** IDs of attachments to remove from the draft. */
19
+ removeAttachments?: AgentMail.AttachmentId[];
20
+ /** Label or labels to add to the draft. */
21
+ addLabels?: AgentMail.DraftLabels;
22
+ /** Label or labels to remove from the draft. */
23
+ removeLabels?: AgentMail.DraftLabels;
24
+ sendAt?: AgentMail.DraftSendAt | null;
11
25
  }
@@ -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";
@@ -1,4 +1,4 @@
1
- import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.mjs";
1
+ import type { BaseClientOptions, BaseIdempotentRequestOptions, BaseRequestOptions } from "../../../../../../BaseClient.mjs";
2
2
  import { type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.mjs";
3
3
  import * as core from "../../../../../../core/index.mjs";
4
4
  import * as AgentMail from "../../../../../index.mjs";
@@ -6,6 +6,8 @@ export declare namespace DraftsClient {
6
6
  type Options = BaseClientOptions;
7
7
  interface RequestOptions extends BaseRequestOptions {
8
8
  }
9
+ interface IdempotentRequestOptions extends RequestOptions, BaseIdempotentRequestOptions {
10
+ }
9
11
  }
10
12
  export declare class DraftsClient {
11
13
  protected readonly _options: NormalizedClientOptionsWithAuth<DraftsClient.Options>;
@@ -63,6 +65,12 @@ export declare class DraftsClient {
63
65
  getAttachment(inbox_id: AgentMail.inboxes.InboxId, draft_id: AgentMail.DraftId, attachment_id: AgentMail.AttachmentId, requestOptions?: DraftsClient.RequestOptions): core.HttpResponsePromise<AgentMail.AttachmentResponse>;
64
66
  private __getAttachment;
65
67
  /**
68
+ * Create a draft. Supply `in_reply_to` to create a reply draft (with
69
+ * `reply_all` to address the whole thread), whose recipients, subject, and
70
+ * threading are derived from the referenced message, or `forward_of` to
71
+ * create a forward draft, which derives the subject, threading, and
72
+ * forwarded content from the source but keeps recipients caller-supplied.
73
+ *
66
74
  * **CLI:**
67
75
  * ```bash
68
76
  * agentmail inboxes:drafts create --inbox-id <inbox_id> --to recipient@example.com --subject "Draft subject" --text "Draft body"
@@ -72,6 +80,7 @@ export declare class DraftsClient {
72
80
  * @param {AgentMail.CreateDraftRequest} request
73
81
  * @param {DraftsClient.RequestOptions} requestOptions - Request-specific configuration.
74
82
  *
83
+ * @throws {@link AgentMail.ValidationError}
75
84
  * @throws {@link AgentMail.NotFoundError}
76
85
  *
77
86
  * @example
@@ -80,6 +89,10 @@ export declare class DraftsClient {
80
89
  create(inbox_id: AgentMail.inboxes.InboxId, request: AgentMail.CreateDraftRequest, requestOptions?: DraftsClient.RequestOptions): core.HttpResponsePromise<AgentMail.Draft>;
81
90
  private __create;
82
91
  /**
92
+ * Edit fields on an existing draft. Passing `null` clears a field (or `[]`
93
+ * for a recipient field); `send_at: null` un-schedules a scheduled draft.
94
+ * A draft that is already being sent cannot be edited.
95
+ *
83
96
  * **CLI:**
84
97
  * ```bash
85
98
  * agentmail inboxes:drafts update --inbox-id <inbox_id> --draft-id <draft_id> --subject "Updated subject"
@@ -90,7 +103,9 @@ export declare class DraftsClient {
90
103
  * @param {AgentMail.UpdateDraftRequest} request
91
104
  * @param {DraftsClient.RequestOptions} requestOptions - Request-specific configuration.
92
105
  *
106
+ * @throws {@link AgentMail.ValidationError}
93
107
  * @throws {@link AgentMail.NotFoundError}
108
+ * @throws {@link AgentMail.ConflictError}
94
109
  *
95
110
  * @example
96
111
  * await client.inboxes.drafts.update("inbox_id", "draft_id", {})
@@ -123,15 +138,16 @@ export declare class DraftsClient {
123
138
  * @param {AgentMail.inboxes.InboxId} inbox_id
124
139
  * @param {AgentMail.DraftId} draft_id
125
140
  * @param {AgentMail.UpdateMessageRequest} request
126
- * @param {DraftsClient.RequestOptions} requestOptions - Request-specific configuration.
141
+ * @param {DraftsClient.IdempotentRequestOptions} requestOptions - Request-specific configuration.
127
142
  *
128
143
  * @throws {@link AgentMail.NotFoundError}
129
144
  * @throws {@link AgentMail.ValidationError}
145
+ * @throws {@link AgentMail.ConflictError}
130
146
  * @throws {@link AgentMail.MessageRejectedError}
131
147
  *
132
148
  * @example
133
149
  * await client.inboxes.drafts.send("inbox_id", "draft_id", {})
134
150
  */
135
- send(inbox_id: AgentMail.inboxes.InboxId, draft_id: AgentMail.DraftId, request: AgentMail.UpdateMessageRequest, requestOptions?: DraftsClient.RequestOptions): core.HttpResponsePromise<AgentMail.SendMessageResponse>;
151
+ send(inbox_id: AgentMail.inboxes.InboxId, draft_id: AgentMail.DraftId, request: AgentMail.UpdateMessageRequest, requestOptions?: DraftsClient.IdempotentRequestOptions): core.HttpResponsePromise<AgentMail.SendMessageResponse>;
136
152
  private __send;
137
153
  }
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  import { normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.mjs";
12
- import { mergeHeaders } from "../../../../../../core/headers.mjs";
12
+ import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.mjs";
13
13
  import * as core from "../../../../../../core/index.mjs";
14
14
  import { toJson } from "../../../../../../core/json.mjs";
15
15
  import * as environments from "../../../../../../environments.mjs";
@@ -245,6 +245,12 @@ export class DraftsClient {
245
245
  });
246
246
  }
247
247
  /**
248
+ * Create a draft. Supply `in_reply_to` to create a reply draft (with
249
+ * `reply_all` to address the whole thread), whose recipients, subject, and
250
+ * threading are derived from the referenced message, or `forward_of` to
251
+ * create a forward draft, which derives the subject, threading, and
252
+ * forwarded content from the source but keeps recipients caller-supplied.
253
+ *
248
254
  * **CLI:**
249
255
  * ```bash
250
256
  * agentmail inboxes:drafts create --inbox-id <inbox_id> --to recipient@example.com --subject "Draft subject" --text "Draft body"
@@ -254,6 +260,7 @@ export class DraftsClient {
254
260
  * @param {AgentMail.CreateDraftRequest} request
255
261
  * @param {DraftsClient.RequestOptions} requestOptions - Request-specific configuration.
256
262
  *
263
+ * @throws {@link AgentMail.ValidationError}
257
264
  * @throws {@link AgentMail.NotFoundError}
258
265
  *
259
266
  * @example
@@ -299,6 +306,14 @@ export class DraftsClient {
299
306
  }
300
307
  if (_response.error.reason === "status-code") {
301
308
  switch (_response.error.statusCode) {
309
+ case 400:
310
+ throw new AgentMail.ValidationError(serializers.ValidationErrorResponse.parseOrThrow(_response.error.body, {
311
+ unrecognizedObjectKeys: "passthrough",
312
+ allowUnrecognizedUnionMembers: true,
313
+ allowUnrecognizedEnumValues: true,
314
+ skipValidation: true,
315
+ breadcrumbsPrefix: ["response"],
316
+ }), _response.rawResponse);
302
317
  case 404:
303
318
  throw new AgentMail.NotFoundError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
304
319
  unrecognizedObjectKeys: "passthrough",
@@ -319,6 +334,10 @@ export class DraftsClient {
319
334
  });
320
335
  }
321
336
  /**
337
+ * Edit fields on an existing draft. Passing `null` clears a field (or `[]`
338
+ * for a recipient field); `send_at: null` un-schedules a scheduled draft.
339
+ * A draft that is already being sent cannot be edited.
340
+ *
322
341
  * **CLI:**
323
342
  * ```bash
324
343
  * agentmail inboxes:drafts update --inbox-id <inbox_id> --draft-id <draft_id> --subject "Updated subject"
@@ -329,7 +348,9 @@ export class DraftsClient {
329
348
  * @param {AgentMail.UpdateDraftRequest} request
330
349
  * @param {DraftsClient.RequestOptions} requestOptions - Request-specific configuration.
331
350
  *
351
+ * @throws {@link AgentMail.ValidationError}
332
352
  * @throws {@link AgentMail.NotFoundError}
353
+ * @throws {@link AgentMail.ConflictError}
333
354
  *
334
355
  * @example
335
356
  * await client.inboxes.drafts.update("inbox_id", "draft_id", {})
@@ -374,6 +395,14 @@ export class DraftsClient {
374
395
  }
375
396
  if (_response.error.reason === "status-code") {
376
397
  switch (_response.error.statusCode) {
398
+ case 400:
399
+ throw new AgentMail.ValidationError(serializers.ValidationErrorResponse.parseOrThrow(_response.error.body, {
400
+ unrecognizedObjectKeys: "passthrough",
401
+ allowUnrecognizedUnionMembers: true,
402
+ allowUnrecognizedEnumValues: true,
403
+ skipValidation: true,
404
+ breadcrumbsPrefix: ["response"],
405
+ }), _response.rawResponse);
377
406
  case 404:
378
407
  throw new AgentMail.NotFoundError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
379
408
  unrecognizedObjectKeys: "passthrough",
@@ -382,6 +411,14 @@ export class DraftsClient {
382
411
  skipValidation: true,
383
412
  breadcrumbsPrefix: ["response"],
384
413
  }), _response.rawResponse);
414
+ case 409:
415
+ throw new AgentMail.ConflictError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
416
+ unrecognizedObjectKeys: "passthrough",
417
+ allowUnrecognizedUnionMembers: true,
418
+ allowUnrecognizedEnumValues: true,
419
+ skipValidation: true,
420
+ breadcrumbsPrefix: ["response"],
421
+ }), _response.rawResponse);
385
422
  default:
386
423
  throw new errors.AgentMailError({
387
424
  statusCode: _response.error.statusCode,
@@ -461,10 +498,11 @@ export class DraftsClient {
461
498
  * @param {AgentMail.inboxes.InboxId} inbox_id
462
499
  * @param {AgentMail.DraftId} draft_id
463
500
  * @param {AgentMail.UpdateMessageRequest} request
464
- * @param {DraftsClient.RequestOptions} requestOptions - Request-specific configuration.
501
+ * @param {DraftsClient.IdempotentRequestOptions} requestOptions - Request-specific configuration.
465
502
  *
466
503
  * @throws {@link AgentMail.NotFoundError}
467
504
  * @throws {@link AgentMail.ValidationError}
505
+ * @throws {@link AgentMail.ConflictError}
468
506
  * @throws {@link AgentMail.MessageRejectedError}
469
507
  *
470
508
  * @example
@@ -477,7 +515,7 @@ export class DraftsClient {
477
515
  return __awaiter(this, void 0, void 0, function* () {
478
516
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
479
517
  const _authRequest = yield this._options.authProvider.getAuthRequest();
480
- 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);
518
+ const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ "Idempotency-Key": requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.idempotencyKey }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
481
519
  const _response = yield core.fetcher({
482
520
  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)
483
521
  .http, `/v0/inboxes/${core.url.encodePathParam(serializers.inboxes.InboxId.jsonOrThrow(inbox_id, { omitUndefined: true }))}/drafts/${core.url.encodePathParam(serializers.DraftId.jsonOrThrow(draft_id, { omitUndefined: true }))}/send`),
@@ -526,6 +564,14 @@ export class DraftsClient {
526
564
  skipValidation: true,
527
565
  breadcrumbsPrefix: ["response"],
528
566
  }), _response.rawResponse);
567
+ case 409:
568
+ throw new AgentMail.ConflictError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
569
+ unrecognizedObjectKeys: "passthrough",
570
+ allowUnrecognizedUnionMembers: true,
571
+ allowUnrecognizedEnumValues: true,
572
+ skipValidation: true,
573
+ breadcrumbsPrefix: ["response"],
574
+ }), _response.rawResponse);
529
575
  case 403:
530
576
  throw new AgentMail.MessageRejectedError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
531
577
  unrecognizedObjectKeys: "passthrough",