agentmail 0.0.21 → 0.0.23

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 (204) hide show
  1. package/Client.d.ts +3 -0
  2. package/Client.js +5 -0
  3. package/api/resources/inboxes/client/Client.js +3 -3
  4. package/api/resources/index.d.ts +4 -0
  5. package/api/resources/index.js +5 -1
  6. package/api/resources/messages/client/Client.d.ts +2 -0
  7. package/api/resources/messages/client/Client.js +26 -12
  8. package/api/resources/messages/client/requests/ListMessagesRequest.d.ts +1 -2
  9. package/api/resources/messages/errors/MessageRejectedError.d.ts +8 -0
  10. package/api/resources/messages/errors/MessageRejectedError.js +51 -0
  11. package/api/resources/messages/errors/index.d.ts +1 -0
  12. package/api/resources/messages/errors/index.js +17 -0
  13. package/api/resources/messages/index.d.ts +1 -0
  14. package/api/resources/messages/index.js +1 -0
  15. package/api/resources/messages/types/SendMessageResponse.d.ts +1 -0
  16. package/api/resources/threads/client/Client.js +7 -9
  17. package/api/resources/threads/client/requests/ListThreadsRequest.d.ts +1 -2
  18. package/api/resources/webhooks/client/Client.d.ts +71 -0
  19. package/api/resources/webhooks/client/Client.js +316 -0
  20. package/api/resources/webhooks/client/index.d.ts +1 -0
  21. package/api/resources/webhooks/client/index.js +17 -0
  22. package/api/resources/webhooks/client/requests/ListWebhooksRequest.d.ts +12 -0
  23. package/api/resources/webhooks/client/requests/index.d.ts +1 -0
  24. package/api/resources/webhooks/client/requests/index.js +2 -0
  25. package/api/resources/webhooks/index.d.ts +2 -0
  26. package/api/resources/webhooks/index.js +18 -0
  27. package/api/resources/webhooks/types/CreateWebhookRequest.d.ts +9 -0
  28. package/api/{types/Sent.d.ts → resources/webhooks/types/EventId.d.ts} +2 -2
  29. package/api/resources/webhooks/types/EventType.d.ts +7 -0
  30. package/api/resources/webhooks/types/EventType.js +9 -0
  31. package/api/resources/webhooks/types/Events.d.ts +8 -0
  32. package/api/resources/webhooks/types/Inboxes.d.ts +7 -0
  33. package/api/resources/webhooks/types/Inboxes.js +5 -0
  34. package/api/resources/webhooks/types/ListWebhooksResponse.d.ts +11 -0
  35. package/api/resources/webhooks/types/ListWebhooksResponse.js +5 -0
  36. package/api/resources/webhooks/types/MessageReceivedPayload.d.ts +9 -0
  37. package/api/resources/webhooks/types/MessageReceivedPayload.js +5 -0
  38. package/{dist/api/types/Sent.d.ts → api/resources/webhooks/types/SvixId.d.ts} +2 -2
  39. package/api/resources/webhooks/types/SvixId.js +5 -0
  40. package/api/resources/webhooks/types/SvixSignature.d.ts +7 -0
  41. package/api/resources/webhooks/types/SvixSignature.js +5 -0
  42. package/api/resources/webhooks/types/SvixTimestamp.d.ts +7 -0
  43. package/api/resources/webhooks/types/SvixTimestamp.js +5 -0
  44. package/api/resources/webhooks/types/Url.d.ts +7 -0
  45. package/api/resources/webhooks/types/Url.js +5 -0
  46. package/api/resources/webhooks/types/Webhook.d.ts +14 -0
  47. package/api/resources/webhooks/types/Webhook.js +5 -0
  48. package/api/resources/webhooks/types/WebhookId.d.ts +7 -0
  49. package/api/resources/webhooks/types/WebhookId.js +5 -0
  50. package/api/resources/webhooks/types/index.d.ts +13 -0
  51. package/api/resources/webhooks/types/index.js +29 -0
  52. package/api/types/Labels.d.ts +7 -0
  53. package/api/types/Labels.js +5 -0
  54. package/api/types/index.d.ts +1 -2
  55. package/api/types/index.js +1 -2
  56. package/dist/Client.d.ts +3 -0
  57. package/dist/Client.js +5 -0
  58. package/dist/api/resources/inboxes/client/Client.js +3 -3
  59. package/dist/api/resources/index.d.ts +4 -0
  60. package/dist/api/resources/index.js +5 -1
  61. package/dist/api/resources/messages/client/Client.d.ts +2 -0
  62. package/dist/api/resources/messages/client/Client.js +26 -12
  63. package/dist/api/resources/messages/client/requests/ListMessagesRequest.d.ts +1 -2
  64. package/dist/api/resources/messages/errors/MessageRejectedError.d.ts +8 -0
  65. package/dist/api/resources/messages/errors/MessageRejectedError.js +51 -0
  66. package/dist/api/resources/messages/errors/index.d.ts +1 -0
  67. package/dist/api/resources/messages/errors/index.js +17 -0
  68. package/dist/api/resources/messages/index.d.ts +1 -0
  69. package/dist/api/resources/messages/index.js +1 -0
  70. package/dist/api/resources/messages/types/SendMessageResponse.d.ts +1 -0
  71. package/dist/api/resources/threads/client/Client.js +7 -9
  72. package/dist/api/resources/threads/client/requests/ListThreadsRequest.d.ts +1 -2
  73. package/dist/api/resources/webhooks/client/Client.d.ts +71 -0
  74. package/dist/api/resources/webhooks/client/Client.js +316 -0
  75. package/dist/api/resources/webhooks/client/index.d.ts +1 -0
  76. package/dist/api/resources/webhooks/client/index.js +17 -0
  77. package/dist/api/resources/webhooks/client/requests/ListWebhooksRequest.d.ts +12 -0
  78. package/dist/api/resources/webhooks/client/requests/ListWebhooksRequest.js +5 -0
  79. package/dist/api/resources/webhooks/client/requests/index.d.ts +1 -0
  80. package/dist/api/resources/webhooks/client/requests/index.js +2 -0
  81. package/dist/api/resources/webhooks/index.d.ts +2 -0
  82. package/dist/api/resources/webhooks/index.js +18 -0
  83. package/dist/api/resources/webhooks/types/CreateWebhookRequest.d.ts +9 -0
  84. package/dist/api/resources/webhooks/types/CreateWebhookRequest.js +5 -0
  85. package/dist/api/resources/webhooks/types/EventId.d.ts +7 -0
  86. package/dist/api/resources/webhooks/types/EventId.js +5 -0
  87. package/dist/api/resources/webhooks/types/EventType.d.ts +7 -0
  88. package/dist/api/resources/webhooks/types/EventType.js +9 -0
  89. package/dist/api/resources/webhooks/types/Events.d.ts +8 -0
  90. package/dist/api/resources/webhooks/types/Events.js +5 -0
  91. package/dist/api/resources/webhooks/types/Inboxes.d.ts +7 -0
  92. package/dist/api/resources/webhooks/types/Inboxes.js +5 -0
  93. package/dist/api/resources/webhooks/types/ListWebhooksResponse.d.ts +11 -0
  94. package/dist/api/resources/webhooks/types/ListWebhooksResponse.js +5 -0
  95. package/dist/api/resources/webhooks/types/MessageReceivedPayload.d.ts +9 -0
  96. package/dist/api/resources/webhooks/types/MessageReceivedPayload.js +5 -0
  97. package/dist/api/resources/webhooks/types/SvixId.d.ts +7 -0
  98. package/dist/api/resources/webhooks/types/SvixId.js +5 -0
  99. package/dist/api/resources/webhooks/types/SvixSignature.d.ts +7 -0
  100. package/dist/api/resources/webhooks/types/SvixSignature.js +5 -0
  101. package/dist/api/resources/webhooks/types/SvixTimestamp.d.ts +7 -0
  102. package/dist/api/resources/webhooks/types/SvixTimestamp.js +5 -0
  103. package/dist/api/resources/webhooks/types/Url.d.ts +7 -0
  104. package/dist/api/resources/webhooks/types/Url.js +5 -0
  105. package/dist/api/resources/webhooks/types/Webhook.d.ts +14 -0
  106. package/dist/api/resources/webhooks/types/Webhook.js +5 -0
  107. package/dist/api/resources/webhooks/types/WebhookId.d.ts +7 -0
  108. package/dist/api/resources/webhooks/types/WebhookId.js +5 -0
  109. package/dist/api/resources/webhooks/types/index.d.ts +13 -0
  110. package/dist/api/resources/webhooks/types/index.js +29 -0
  111. package/dist/api/types/Labels.d.ts +7 -0
  112. package/dist/api/types/Labels.js +5 -0
  113. package/dist/api/types/index.d.ts +1 -2
  114. package/dist/api/types/index.js +1 -2
  115. package/dist/serialization/resources/index.d.ts +2 -0
  116. package/dist/serialization/resources/index.js +3 -1
  117. package/dist/serialization/resources/messages/types/SendMessageResponse.d.ts +2 -0
  118. package/dist/serialization/resources/messages/types/SendMessageResponse.js +2 -0
  119. package/dist/serialization/resources/webhooks/index.d.ts +1 -0
  120. package/dist/serialization/resources/webhooks/index.js +17 -0
  121. package/dist/serialization/resources/webhooks/types/CreateWebhookRequest.d.ts +17 -0
  122. package/dist/serialization/resources/webhooks/types/CreateWebhookRequest.js +48 -0
  123. package/dist/serialization/resources/webhooks/types/EventId.d.ts +10 -0
  124. package/dist/serialization/resources/webhooks/types/EventId.js +41 -0
  125. package/dist/serialization/resources/webhooks/types/EventType.d.ts +10 -0
  126. package/dist/serialization/resources/webhooks/types/EventType.js +41 -0
  127. package/dist/serialization/resources/webhooks/types/Events.d.ts +11 -0
  128. package/dist/serialization/resources/webhooks/types/Events.js +42 -0
  129. package/dist/serialization/resources/webhooks/types/Inboxes.d.ts +10 -0
  130. package/dist/serialization/resources/webhooks/types/Inboxes.js +41 -0
  131. package/dist/serialization/resources/webhooks/types/ListWebhooksResponse.d.ts +19 -0
  132. package/dist/serialization/resources/webhooks/types/ListWebhooksResponse.js +50 -0
  133. package/dist/serialization/resources/webhooks/types/MessageReceivedPayload.d.ts +17 -0
  134. package/dist/serialization/resources/webhooks/types/MessageReceivedPayload.js +48 -0
  135. package/dist/serialization/resources/webhooks/types/SvixId.d.ts +10 -0
  136. package/dist/serialization/resources/webhooks/types/SvixId.js +41 -0
  137. package/dist/serialization/resources/webhooks/types/SvixSignature.d.ts +10 -0
  138. package/dist/serialization/resources/webhooks/types/SvixSignature.js +41 -0
  139. package/dist/serialization/resources/webhooks/types/SvixTimestamp.d.ts +10 -0
  140. package/dist/serialization/resources/webhooks/types/SvixTimestamp.js +41 -0
  141. package/dist/serialization/resources/webhooks/types/Url.d.ts +10 -0
  142. package/{serialization/types/Sent.js → dist/serialization/resources/webhooks/types/Url.js} +3 -3
  143. package/dist/serialization/resources/webhooks/types/Webhook.d.ts +21 -0
  144. package/dist/serialization/resources/webhooks/types/Webhook.js +52 -0
  145. package/dist/serialization/resources/webhooks/types/WebhookId.d.ts +10 -0
  146. package/dist/serialization/resources/webhooks/types/WebhookId.js +41 -0
  147. package/dist/serialization/resources/webhooks/types/index.d.ts +13 -0
  148. package/dist/serialization/resources/webhooks/types/index.js +29 -0
  149. package/dist/serialization/types/{Sent.d.ts → Labels.d.ts} +3 -3
  150. package/dist/serialization/types/{Received.js → Labels.js} +2 -2
  151. package/dist/serialization/types/index.d.ts +1 -2
  152. package/dist/serialization/types/index.js +1 -2
  153. package/dist/version.d.ts +1 -1
  154. package/dist/version.js +1 -1
  155. package/package.json +1 -1
  156. package/reference.md +198 -0
  157. package/serialization/resources/index.d.ts +2 -0
  158. package/serialization/resources/index.js +3 -1
  159. package/serialization/resources/messages/types/SendMessageResponse.d.ts +2 -0
  160. package/serialization/resources/messages/types/SendMessageResponse.js +2 -0
  161. package/serialization/resources/webhooks/index.d.ts +1 -0
  162. package/serialization/resources/webhooks/index.js +17 -0
  163. package/serialization/resources/webhooks/types/CreateWebhookRequest.d.ts +17 -0
  164. package/serialization/resources/webhooks/types/CreateWebhookRequest.js +48 -0
  165. package/serialization/resources/webhooks/types/EventId.d.ts +10 -0
  166. package/serialization/resources/webhooks/types/EventId.js +41 -0
  167. package/serialization/resources/webhooks/types/EventType.d.ts +10 -0
  168. package/serialization/resources/webhooks/types/EventType.js +41 -0
  169. package/serialization/resources/webhooks/types/Events.d.ts +11 -0
  170. package/serialization/resources/webhooks/types/Events.js +42 -0
  171. package/serialization/resources/webhooks/types/Inboxes.d.ts +10 -0
  172. package/serialization/resources/webhooks/types/Inboxes.js +41 -0
  173. package/serialization/resources/webhooks/types/ListWebhooksResponse.d.ts +19 -0
  174. package/serialization/resources/webhooks/types/ListWebhooksResponse.js +50 -0
  175. package/serialization/resources/webhooks/types/MessageReceivedPayload.d.ts +17 -0
  176. package/serialization/resources/webhooks/types/MessageReceivedPayload.js +48 -0
  177. package/serialization/resources/webhooks/types/SvixId.d.ts +10 -0
  178. package/serialization/resources/webhooks/types/SvixId.js +41 -0
  179. package/serialization/resources/webhooks/types/SvixSignature.d.ts +10 -0
  180. package/serialization/resources/webhooks/types/SvixSignature.js +41 -0
  181. package/serialization/resources/webhooks/types/SvixTimestamp.d.ts +10 -0
  182. package/serialization/resources/webhooks/types/SvixTimestamp.js +41 -0
  183. package/serialization/resources/webhooks/types/Url.d.ts +10 -0
  184. package/serialization/{types/Received.js → resources/webhooks/types/Url.js} +3 -3
  185. package/serialization/resources/webhooks/types/Webhook.d.ts +21 -0
  186. package/serialization/resources/webhooks/types/Webhook.js +52 -0
  187. package/serialization/resources/webhooks/types/WebhookId.d.ts +10 -0
  188. package/serialization/resources/webhooks/types/WebhookId.js +41 -0
  189. package/serialization/resources/webhooks/types/index.d.ts +13 -0
  190. package/serialization/resources/webhooks/types/index.js +29 -0
  191. package/serialization/types/{Sent.d.ts → Labels.d.ts} +3 -3
  192. package/{dist/serialization/types/Sent.js → serialization/types/Labels.js} +2 -2
  193. package/serialization/types/index.d.ts +1 -2
  194. package/serialization/types/index.js +1 -2
  195. package/version.d.ts +1 -1
  196. package/version.js +1 -1
  197. package/api/types/Received.d.ts +0 -7
  198. package/dist/api/types/Received.d.ts +0 -7
  199. package/dist/serialization/types/Received.d.ts +0 -10
  200. package/serialization/types/Received.d.ts +0 -10
  201. /package/api/{types/Received.js → resources/webhooks/client/requests/ListWebhooksRequest.js} +0 -0
  202. /package/api/{types/Sent.js → resources/webhooks/types/CreateWebhookRequest.js} +0 -0
  203. /package/{dist/api/types/Received.js → api/resources/webhooks/types/EventId.js} +0 -0
  204. /package/{dist/api/types/Sent.js → api/resources/webhooks/types/Events.js} +0 -0
@@ -0,0 +1,316 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
18
+ }) : function(o, v) {
19
+ o["default"] = v;
20
+ });
21
+ var __importStar = (this && this.__importStar) || (function () {
22
+ var ownKeys = function(o) {
23
+ ownKeys = Object.getOwnPropertyNames || function (o) {
24
+ var ar = [];
25
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
+ return ar;
27
+ };
28
+ return ownKeys(o);
29
+ };
30
+ return function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ })();
38
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
39
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
40
+ return new (P || (P = Promise))(function (resolve, reject) {
41
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
42
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
43
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
44
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
45
+ });
46
+ };
47
+ var __importDefault = (this && this.__importDefault) || function (mod) {
48
+ return (mod && mod.__esModule) ? mod : { "default": mod };
49
+ };
50
+ Object.defineProperty(exports, "__esModule", { value: true });
51
+ exports.Webhooks = void 0;
52
+ const environments = __importStar(require("../../../../environments"));
53
+ const core = __importStar(require("../../../../core"));
54
+ const AgentMail = __importStar(require("../../../index"));
55
+ const url_join_1 = __importDefault(require("url-join"));
56
+ const serializers = __importStar(require("../../../../serialization/index"));
57
+ const errors = __importStar(require("../../../../errors/index"));
58
+ class Webhooks {
59
+ constructor(_options = {}) {
60
+ this._options = _options;
61
+ }
62
+ /**
63
+ * @param {AgentMail.ListWebhooksRequest} request
64
+ * @param {Webhooks.RequestOptions} requestOptions - Request-specific configuration.
65
+ *
66
+ * @example
67
+ * await client.webhooks.list()
68
+ */
69
+ list() {
70
+ return __awaiter(this, arguments, void 0, function* (request = {}, requestOptions) {
71
+ var _a, _b;
72
+ const { limit, lastKey } = request;
73
+ const _queryParams = {};
74
+ if (limit != null) {
75
+ _queryParams["limit"] = limit.toString();
76
+ }
77
+ if (lastKey != null) {
78
+ _queryParams["last_key"] = lastKey;
79
+ }
80
+ const _response = yield core.fetcher({
81
+ url: (0, url_join_1.default)((_b = (_a = (yield core.Supplier.get(this._options.baseUrl))) !== null && _a !== void 0 ? _a : (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.AgentMailEnvironment.Production, "/v0/webhooks"),
82
+ method: "GET",
83
+ headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "agentmail", "X-Fern-SDK-Version": "0.0.23", "User-Agent": "agentmail/0.0.23", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
84
+ contentType: "application/json",
85
+ queryParameters: _queryParams,
86
+ requestType: "json",
87
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
88
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
89
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
90
+ });
91
+ if (_response.ok) {
92
+ return serializers.ListWebhooksResponse.parseOrThrow(_response.body, {
93
+ unrecognizedObjectKeys: "passthrough",
94
+ allowUnrecognizedUnionMembers: true,
95
+ allowUnrecognizedEnumValues: true,
96
+ breadcrumbsPrefix: ["response"],
97
+ });
98
+ }
99
+ if (_response.error.reason === "status-code") {
100
+ throw new errors.AgentMailError({
101
+ statusCode: _response.error.statusCode,
102
+ body: _response.error.body,
103
+ });
104
+ }
105
+ switch (_response.error.reason) {
106
+ case "non-json":
107
+ throw new errors.AgentMailError({
108
+ statusCode: _response.error.statusCode,
109
+ body: _response.error.rawBody,
110
+ });
111
+ case "timeout":
112
+ throw new errors.AgentMailTimeoutError("Timeout exceeded when calling GET /v0/webhooks.");
113
+ case "unknown":
114
+ throw new errors.AgentMailError({
115
+ message: _response.error.errorMessage,
116
+ });
117
+ }
118
+ });
119
+ }
120
+ /**
121
+ * @param {AgentMail.WebhookId} webhookId
122
+ * @param {Webhooks.RequestOptions} requestOptions - Request-specific configuration.
123
+ *
124
+ * @throws {@link AgentMail.NotFoundError}
125
+ *
126
+ * @example
127
+ * await client.webhooks.get("webhook_id")
128
+ */
129
+ get(webhookId, requestOptions) {
130
+ return __awaiter(this, void 0, void 0, function* () {
131
+ var _a, _b;
132
+ const _response = yield core.fetcher({
133
+ url: (0, url_join_1.default)((_b = (_a = (yield core.Supplier.get(this._options.baseUrl))) !== null && _a !== void 0 ? _a : (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.AgentMailEnvironment.Production, `/v0/webhooks/${encodeURIComponent(serializers.WebhookId.jsonOrThrow(webhookId))}`),
134
+ method: "GET",
135
+ headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "agentmail", "X-Fern-SDK-Version": "0.0.23", "User-Agent": "agentmail/0.0.23", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
136
+ contentType: "application/json",
137
+ requestType: "json",
138
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
139
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
140
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
141
+ });
142
+ if (_response.ok) {
143
+ return serializers.Webhook.parseOrThrow(_response.body, {
144
+ unrecognizedObjectKeys: "passthrough",
145
+ allowUnrecognizedUnionMembers: true,
146
+ allowUnrecognizedEnumValues: true,
147
+ breadcrumbsPrefix: ["response"],
148
+ });
149
+ }
150
+ if (_response.error.reason === "status-code") {
151
+ switch (_response.error.statusCode) {
152
+ case 404:
153
+ throw new AgentMail.NotFoundError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
154
+ unrecognizedObjectKeys: "passthrough",
155
+ allowUnrecognizedUnionMembers: true,
156
+ allowUnrecognizedEnumValues: true,
157
+ breadcrumbsPrefix: ["response"],
158
+ }));
159
+ default:
160
+ throw new errors.AgentMailError({
161
+ statusCode: _response.error.statusCode,
162
+ body: _response.error.body,
163
+ });
164
+ }
165
+ }
166
+ switch (_response.error.reason) {
167
+ case "non-json":
168
+ throw new errors.AgentMailError({
169
+ statusCode: _response.error.statusCode,
170
+ body: _response.error.rawBody,
171
+ });
172
+ case "timeout":
173
+ throw new errors.AgentMailTimeoutError("Timeout exceeded when calling GET /v0/webhooks/{webhook_id}.");
174
+ case "unknown":
175
+ throw new errors.AgentMailError({
176
+ message: _response.error.errorMessage,
177
+ });
178
+ }
179
+ });
180
+ }
181
+ /**
182
+ * @param {AgentMail.CreateWebhookRequest} request
183
+ * @param {Webhooks.RequestOptions} requestOptions - Request-specific configuration.
184
+ *
185
+ * @throws {@link AgentMail.ValidationError}
186
+ *
187
+ * @example
188
+ * await client.webhooks.create({
189
+ * url: "url",
190
+ * events: undefined,
191
+ * inboxes: undefined
192
+ * })
193
+ */
194
+ create(request, requestOptions) {
195
+ return __awaiter(this, void 0, void 0, function* () {
196
+ var _a, _b;
197
+ const _response = yield core.fetcher({
198
+ url: (0, url_join_1.default)((_b = (_a = (yield core.Supplier.get(this._options.baseUrl))) !== null && _a !== void 0 ? _a : (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.AgentMailEnvironment.Production, "/v0/webhooks"),
199
+ method: "POST",
200
+ headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "agentmail", "X-Fern-SDK-Version": "0.0.23", "User-Agent": "agentmail/0.0.23", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
201
+ contentType: "application/json",
202
+ requestType: "json",
203
+ body: serializers.CreateWebhookRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
204
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
205
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
206
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
207
+ });
208
+ if (_response.ok) {
209
+ return serializers.Webhook.parseOrThrow(_response.body, {
210
+ unrecognizedObjectKeys: "passthrough",
211
+ allowUnrecognizedUnionMembers: true,
212
+ allowUnrecognizedEnumValues: true,
213
+ breadcrumbsPrefix: ["response"],
214
+ });
215
+ }
216
+ if (_response.error.reason === "status-code") {
217
+ switch (_response.error.statusCode) {
218
+ case 400:
219
+ throw new AgentMail.ValidationError(serializers.ValidationErrorResponse.parseOrThrow(_response.error.body, {
220
+ unrecognizedObjectKeys: "passthrough",
221
+ allowUnrecognizedUnionMembers: true,
222
+ allowUnrecognizedEnumValues: true,
223
+ breadcrumbsPrefix: ["response"],
224
+ }));
225
+ default:
226
+ throw new errors.AgentMailError({
227
+ statusCode: _response.error.statusCode,
228
+ body: _response.error.body,
229
+ });
230
+ }
231
+ }
232
+ switch (_response.error.reason) {
233
+ case "non-json":
234
+ throw new errors.AgentMailError({
235
+ statusCode: _response.error.statusCode,
236
+ body: _response.error.rawBody,
237
+ });
238
+ case "timeout":
239
+ throw new errors.AgentMailTimeoutError("Timeout exceeded when calling POST /v0/webhooks.");
240
+ case "unknown":
241
+ throw new errors.AgentMailError({
242
+ message: _response.error.errorMessage,
243
+ });
244
+ }
245
+ });
246
+ }
247
+ /**
248
+ * @param {AgentMail.WebhookId} webhookId
249
+ * @param {Webhooks.RequestOptions} requestOptions - Request-specific configuration.
250
+ *
251
+ * @throws {@link AgentMail.NotFoundError}
252
+ *
253
+ * @example
254
+ * await client.webhooks.delete("webhook_id")
255
+ */
256
+ delete(webhookId, requestOptions) {
257
+ return __awaiter(this, void 0, void 0, function* () {
258
+ var _a, _b;
259
+ const _response = yield core.fetcher({
260
+ url: (0, url_join_1.default)((_b = (_a = (yield core.Supplier.get(this._options.baseUrl))) !== null && _a !== void 0 ? _a : (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.AgentMailEnvironment.Production, `/v0/webhooks/${encodeURIComponent(serializers.WebhookId.jsonOrThrow(webhookId))}`),
261
+ method: "DELETE",
262
+ headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "agentmail", "X-Fern-SDK-Version": "0.0.23", "User-Agent": "agentmail/0.0.23", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
263
+ contentType: "application/json",
264
+ requestType: "json",
265
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
266
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
267
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
268
+ });
269
+ if (_response.ok) {
270
+ return;
271
+ }
272
+ if (_response.error.reason === "status-code") {
273
+ switch (_response.error.statusCode) {
274
+ case 404:
275
+ throw new AgentMail.NotFoundError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
276
+ unrecognizedObjectKeys: "passthrough",
277
+ allowUnrecognizedUnionMembers: true,
278
+ allowUnrecognizedEnumValues: true,
279
+ breadcrumbsPrefix: ["response"],
280
+ }));
281
+ default:
282
+ throw new errors.AgentMailError({
283
+ statusCode: _response.error.statusCode,
284
+ body: _response.error.body,
285
+ });
286
+ }
287
+ }
288
+ switch (_response.error.reason) {
289
+ case "non-json":
290
+ throw new errors.AgentMailError({
291
+ statusCode: _response.error.statusCode,
292
+ body: _response.error.rawBody,
293
+ });
294
+ case "timeout":
295
+ throw new errors.AgentMailTimeoutError("Timeout exceeded when calling DELETE /v0/webhooks/{webhook_id}.");
296
+ case "unknown":
297
+ throw new errors.AgentMailError({
298
+ message: _response.error.errorMessage,
299
+ });
300
+ }
301
+ });
302
+ }
303
+ _getAuthorizationHeader() {
304
+ return __awaiter(this, void 0, void 0, function* () {
305
+ var _a;
306
+ const bearer = (_a = (yield core.Supplier.get(this._options.apiKey))) !== null && _a !== void 0 ? _a : process === null || process === void 0 ? void 0 : process.env["AGENTMAIL_API_KEY"];
307
+ if (bearer == null) {
308
+ throw new errors.AgentMailError({
309
+ message: "Please specify a bearer by either passing it in to the constructor or initializing a AGENTMAIL_API_KEY environment variable",
310
+ });
311
+ }
312
+ return `Bearer ${bearer}`;
313
+ });
314
+ }
315
+ }
316
+ exports.Webhooks = Webhooks;
@@ -0,0 +1 @@
1
+ export * from "./requests";
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./requests"), exports);
@@ -0,0 +1,12 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as AgentMail from "../../../../index";
5
+ /**
6
+ * @example
7
+ * {}
8
+ */
9
+ export interface ListWebhooksRequest {
10
+ limit?: AgentMail.Limit;
11
+ lastKey?: AgentMail.LastKey;
12
+ }
@@ -0,0 +1 @@
1
+ export { type ListWebhooksRequest } from "./ListWebhooksRequest";
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ export * from "./types";
2
+ export * from "./client";
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./types"), exports);
18
+ __exportStar(require("./client"), exports);
@@ -0,0 +1,9 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as AgentMail from "../../../index";
5
+ export interface CreateWebhookRequest {
6
+ url: AgentMail.Url;
7
+ events?: AgentMail.Events;
8
+ inboxes?: AgentMail.Inboxes;
9
+ }
@@ -2,6 +2,6 @@
2
2
  * This file was auto-generated by Fern from our API Definition.
3
3
  */
4
4
  /**
5
- * Whether to filter by sent threads/messages.
5
+ * ID of event.
6
6
  */
7
- export type Sent = boolean;
7
+ export type EventId = string;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export type EventType = "message.received";
5
+ export declare const EventType: {
6
+ readonly MessageReceived: "message.received";
7
+ };
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.EventType = void 0;
7
+ exports.EventType = {
8
+ MessageReceived: "message.received",
9
+ };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as AgentMail from "../../../index";
5
+ /**
6
+ * Event types to send. Omit to send all event types.
7
+ */
8
+ export type Events = AgentMail.EventType[];
@@ -0,0 +1,7 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ /**
5
+ * Inboxes for which to send events. Omit to send events for all inboxes.
6
+ */
7
+ export type Inboxes = string[];
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,11 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as AgentMail from "../../../index";
5
+ export interface ListWebhooksResponse {
6
+ /** Webhook items. Ordered by `created_at` ascending. */
7
+ webhooks: AgentMail.Webhook[];
8
+ count: AgentMail.Count;
9
+ limit?: AgentMail.Limit;
10
+ lastKey?: AgentMail.LastKey;
11
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,9 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as AgentMail from "../../../index";
5
+ export interface MessageReceivedPayload {
6
+ eventType: AgentMail.EventType;
7
+ eventId: AgentMail.EventId;
8
+ message: AgentMail.Message;
9
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -2,6 +2,6 @@
2
2
  * This file was auto-generated by Fern from our API Definition.
3
3
  */
4
4
  /**
5
- * Whether to filter by sent threads/messages.
5
+ * ID of webhook message.
6
6
  */
7
- export type Sent = boolean;
7
+ export type SvixId = string;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,7 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ /**
5
+ * Signature of webhook message.
6
+ */
7
+ export type SvixSignature = string;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,7 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ /**
5
+ * Timestamp of webhook message.
6
+ */
7
+ export type SvixTimestamp = Date;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,7 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ /**
5
+ * URL of webhook endpoint.
6
+ */
7
+ export type Url = string;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,14 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as AgentMail from "../../../index";
5
+ export interface Webhook {
6
+ webhookId: AgentMail.WebhookId;
7
+ url: AgentMail.Url;
8
+ events?: AgentMail.Events;
9
+ inboxes?: AgentMail.Inboxes;
10
+ /** Secret for webhook signature verification. */
11
+ secret: string;
12
+ /** Time at which webhook was created. */
13
+ createdAt: Date;
14
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,7 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ /**
5
+ * ID of webhook.
6
+ */
7
+ export type WebhookId = string;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,13 @@
1
+ export * from "./WebhookId";
2
+ export * from "./Url";
3
+ export * from "./EventType";
4
+ export * from "./Events";
5
+ export * from "./Inboxes";
6
+ export * from "./Webhook";
7
+ export * from "./ListWebhooksResponse";
8
+ export * from "./CreateWebhookRequest";
9
+ export * from "./EventId";
10
+ export * from "./MessageReceivedPayload";
11
+ export * from "./SvixId";
12
+ export * from "./SvixTimestamp";
13
+ export * from "./SvixSignature";
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./WebhookId"), exports);
18
+ __exportStar(require("./Url"), exports);
19
+ __exportStar(require("./EventType"), exports);
20
+ __exportStar(require("./Events"), exports);
21
+ __exportStar(require("./Inboxes"), exports);
22
+ __exportStar(require("./Webhook"), exports);
23
+ __exportStar(require("./ListWebhooksResponse"), exports);
24
+ __exportStar(require("./CreateWebhookRequest"), exports);
25
+ __exportStar(require("./EventId"), exports);
26
+ __exportStar(require("./MessageReceivedPayload"), exports);
27
+ __exportStar(require("./SvixId"), exports);
28
+ __exportStar(require("./SvixTimestamp"), exports);
29
+ __exportStar(require("./SvixSignature"), exports);
@@ -0,0 +1,7 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ /**
5
+ * Labels to filter by.
6
+ */
7
+ export type Labels = string[];
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });