agentmail 0.0.34 → 0.0.35

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 (148) hide show
  1. package/Client.d.ts +3 -0
  2. package/Client.js +11 -6
  3. package/api/resources/contexts/client/Client.d.ts +76 -0
  4. package/api/resources/contexts/client/Client.js +327 -0
  5. package/api/resources/contexts/client/index.d.ts +1 -0
  6. package/api/resources/contexts/client/index.js +17 -0
  7. package/api/resources/contexts/client/requests/ListContextsRequest.d.ts +12 -0
  8. package/api/resources/contexts/client/requests/ListContextsRequest.js +5 -0
  9. package/api/resources/contexts/client/requests/index.d.ts +1 -0
  10. package/api/resources/contexts/client/requests/index.js +2 -0
  11. package/api/resources/contexts/index.d.ts +2 -0
  12. package/api/resources/contexts/index.js +18 -0
  13. package/api/resources/contexts/types/Context.d.ts +15 -0
  14. package/api/resources/contexts/types/Context.js +5 -0
  15. package/api/resources/contexts/types/ContextData.d.ts +7 -0
  16. package/api/resources/contexts/types/ContextData.js +5 -0
  17. package/api/resources/contexts/types/ContextId.d.ts +7 -0
  18. package/api/resources/contexts/types/ContextId.js +5 -0
  19. package/api/resources/contexts/types/ContextIsEvent.d.ts +7 -0
  20. package/api/resources/contexts/types/ContextIsEvent.js +5 -0
  21. package/api/resources/contexts/types/ContextMetadata.d.ts +7 -0
  22. package/api/resources/contexts/types/ContextMetadata.js +5 -0
  23. package/api/resources/contexts/types/ContextType.d.ts +7 -0
  24. package/api/resources/contexts/types/ContextType.js +5 -0
  25. package/api/resources/contexts/types/CreateContextRequest.d.ts +10 -0
  26. package/api/resources/contexts/types/CreateContextRequest.js +5 -0
  27. package/api/resources/contexts/types/ListContextsResponse.d.ts +11 -0
  28. package/api/resources/contexts/types/ListContextsResponse.js +5 -0
  29. package/api/resources/contexts/types/index.d.ts +8 -0
  30. package/api/resources/contexts/types/index.js +24 -0
  31. package/api/resources/drafts/client/Client.js +2 -2
  32. package/api/resources/drafts/types/ListDraftsResponse.d.ts +1 -1
  33. package/api/resources/inboxes/client/Client.js +3 -3
  34. package/api/resources/inboxes/resources/drafts/client/Client.js +4 -4
  35. package/api/resources/inboxes/resources/messages/client/Client.js +6 -6
  36. package/api/resources/inboxes/resources/threads/client/Client.js +2 -2
  37. package/api/resources/inboxes/types/Inbox.d.ts +2 -0
  38. package/api/resources/inboxes/types/ListInboxesResponse.d.ts +1 -1
  39. package/api/resources/index.d.ts +3 -0
  40. package/api/resources/index.js +4 -1
  41. package/api/resources/messages/types/ListMessagesResponse.d.ts +1 -1
  42. package/api/resources/threads/client/Client.js +2 -2
  43. package/api/resources/threads/types/ListThreadsResponse.d.ts +1 -1
  44. package/api/resources/threads/types/Thread.d.ts +1 -1
  45. package/api/resources/webhooks/client/Client.js +4 -4
  46. package/api/resources/webhooks/types/ListWebhooksResponse.d.ts +1 -1
  47. package/api/types/PageToken.d.ts +1 -1
  48. package/dist/Client.d.ts +3 -0
  49. package/dist/Client.js +11 -6
  50. package/dist/api/resources/contexts/client/Client.d.ts +76 -0
  51. package/dist/api/resources/contexts/client/Client.js +327 -0
  52. package/dist/api/resources/contexts/client/index.d.ts +1 -0
  53. package/dist/api/resources/contexts/client/index.js +17 -0
  54. package/dist/api/resources/contexts/client/requests/ListContextsRequest.d.ts +12 -0
  55. package/dist/api/resources/contexts/client/requests/ListContextsRequest.js +5 -0
  56. package/dist/api/resources/contexts/client/requests/index.d.ts +1 -0
  57. package/dist/api/resources/contexts/client/requests/index.js +2 -0
  58. package/dist/api/resources/contexts/index.d.ts +2 -0
  59. package/dist/api/resources/contexts/index.js +18 -0
  60. package/dist/api/resources/contexts/types/Context.d.ts +15 -0
  61. package/dist/api/resources/contexts/types/Context.js +5 -0
  62. package/dist/api/resources/contexts/types/ContextData.d.ts +7 -0
  63. package/dist/api/resources/contexts/types/ContextData.js +5 -0
  64. package/dist/api/resources/contexts/types/ContextId.d.ts +7 -0
  65. package/dist/api/resources/contexts/types/ContextId.js +5 -0
  66. package/dist/api/resources/contexts/types/ContextIsEvent.d.ts +7 -0
  67. package/dist/api/resources/contexts/types/ContextIsEvent.js +5 -0
  68. package/dist/api/resources/contexts/types/ContextMetadata.d.ts +7 -0
  69. package/dist/api/resources/contexts/types/ContextMetadata.js +5 -0
  70. package/dist/api/resources/contexts/types/ContextType.d.ts +7 -0
  71. package/dist/api/resources/contexts/types/ContextType.js +5 -0
  72. package/dist/api/resources/contexts/types/CreateContextRequest.d.ts +10 -0
  73. package/dist/api/resources/contexts/types/CreateContextRequest.js +5 -0
  74. package/dist/api/resources/contexts/types/ListContextsResponse.d.ts +11 -0
  75. package/dist/api/resources/contexts/types/ListContextsResponse.js +5 -0
  76. package/dist/api/resources/contexts/types/index.d.ts +8 -0
  77. package/dist/api/resources/contexts/types/index.js +24 -0
  78. package/dist/api/resources/drafts/client/Client.js +2 -2
  79. package/dist/api/resources/drafts/types/ListDraftsResponse.d.ts +1 -1
  80. package/dist/api/resources/inboxes/client/Client.js +3 -3
  81. package/dist/api/resources/inboxes/resources/drafts/client/Client.js +4 -4
  82. package/dist/api/resources/inboxes/resources/messages/client/Client.js +6 -6
  83. package/dist/api/resources/inboxes/resources/threads/client/Client.js +2 -2
  84. package/dist/api/resources/inboxes/types/Inbox.d.ts +2 -0
  85. package/dist/api/resources/inboxes/types/ListInboxesResponse.d.ts +1 -1
  86. package/dist/api/resources/index.d.ts +3 -0
  87. package/dist/api/resources/index.js +4 -1
  88. package/dist/api/resources/messages/types/ListMessagesResponse.d.ts +1 -1
  89. package/dist/api/resources/threads/client/Client.js +2 -2
  90. package/dist/api/resources/threads/types/ListThreadsResponse.d.ts +1 -1
  91. package/dist/api/resources/threads/types/Thread.d.ts +1 -1
  92. package/dist/api/resources/webhooks/client/Client.js +4 -4
  93. package/dist/api/resources/webhooks/types/ListWebhooksResponse.d.ts +1 -1
  94. package/dist/api/types/PageToken.d.ts +1 -1
  95. package/dist/serialization/resources/contexts/index.d.ts +1 -0
  96. package/dist/serialization/resources/contexts/index.js +17 -0
  97. package/dist/serialization/resources/contexts/types/Context.d.ts +23 -0
  98. package/dist/serialization/resources/contexts/types/Context.js +54 -0
  99. package/dist/serialization/resources/contexts/types/ContextData.d.ts +10 -0
  100. package/dist/serialization/resources/contexts/types/ContextData.js +41 -0
  101. package/dist/serialization/resources/contexts/types/ContextId.d.ts +10 -0
  102. package/dist/serialization/resources/contexts/types/ContextId.js +41 -0
  103. package/dist/serialization/resources/contexts/types/ContextIsEvent.d.ts +10 -0
  104. package/dist/serialization/resources/contexts/types/ContextIsEvent.js +41 -0
  105. package/dist/serialization/resources/contexts/types/ContextMetadata.d.ts +10 -0
  106. package/dist/serialization/resources/contexts/types/ContextMetadata.js +41 -0
  107. package/dist/serialization/resources/contexts/types/ContextType.d.ts +10 -0
  108. package/dist/serialization/resources/contexts/types/ContextType.js +41 -0
  109. package/dist/serialization/resources/contexts/types/CreateContextRequest.d.ts +19 -0
  110. package/dist/serialization/resources/contexts/types/CreateContextRequest.js +50 -0
  111. package/dist/serialization/resources/contexts/types/ListContextsResponse.d.ts +19 -0
  112. package/dist/serialization/resources/contexts/types/ListContextsResponse.js +50 -0
  113. package/dist/serialization/resources/contexts/types/index.d.ts +8 -0
  114. package/dist/serialization/resources/contexts/types/index.js +24 -0
  115. package/dist/serialization/resources/inboxes/types/Inbox.d.ts +1 -0
  116. package/dist/serialization/resources/inboxes/types/Inbox.js +1 -0
  117. package/dist/serialization/resources/index.d.ts +2 -0
  118. package/dist/serialization/resources/index.js +3 -1
  119. package/dist/version.d.ts +1 -1
  120. package/dist/version.js +1 -1
  121. package/package.json +1 -1
  122. package/reference.md +203 -0
  123. package/serialization/resources/contexts/index.d.ts +1 -0
  124. package/serialization/resources/contexts/index.js +17 -0
  125. package/serialization/resources/contexts/types/Context.d.ts +23 -0
  126. package/serialization/resources/contexts/types/Context.js +54 -0
  127. package/serialization/resources/contexts/types/ContextData.d.ts +10 -0
  128. package/serialization/resources/contexts/types/ContextData.js +41 -0
  129. package/serialization/resources/contexts/types/ContextId.d.ts +10 -0
  130. package/serialization/resources/contexts/types/ContextId.js +41 -0
  131. package/serialization/resources/contexts/types/ContextIsEvent.d.ts +10 -0
  132. package/serialization/resources/contexts/types/ContextIsEvent.js +41 -0
  133. package/serialization/resources/contexts/types/ContextMetadata.d.ts +10 -0
  134. package/serialization/resources/contexts/types/ContextMetadata.js +41 -0
  135. package/serialization/resources/contexts/types/ContextType.d.ts +10 -0
  136. package/serialization/resources/contexts/types/ContextType.js +41 -0
  137. package/serialization/resources/contexts/types/CreateContextRequest.d.ts +19 -0
  138. package/serialization/resources/contexts/types/CreateContextRequest.js +50 -0
  139. package/serialization/resources/contexts/types/ListContextsResponse.d.ts +19 -0
  140. package/serialization/resources/contexts/types/ListContextsResponse.js +50 -0
  141. package/serialization/resources/contexts/types/index.d.ts +8 -0
  142. package/serialization/resources/contexts/types/index.js +24 -0
  143. package/serialization/resources/inboxes/types/Inbox.d.ts +1 -0
  144. package/serialization/resources/inboxes/types/Inbox.js +1 -0
  145. package/serialization/resources/index.d.ts +2 -0
  146. package/serialization/resources/index.js +3 -1
  147. package/version.d.ts +1 -1
  148. package/version.js +1 -1
@@ -0,0 +1,327 @@
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.Contexts = 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 Contexts {
59
+ constructor(_options = {}) {
60
+ this._options = _options;
61
+ }
62
+ /**
63
+ * @param {AgentMail.ListContextsRequest} request
64
+ * @param {Contexts.RequestOptions} requestOptions - Request-specific configuration.
65
+ *
66
+ * @example
67
+ * await client.contexts.list()
68
+ */
69
+ list() {
70
+ return __awaiter(this, arguments, void 0, function* (request = {}, requestOptions) {
71
+ var _a, _b;
72
+ const { limit, pageToken } = request;
73
+ const _queryParams = {};
74
+ if (limit != null) {
75
+ _queryParams["limit"] = limit.toString();
76
+ }
77
+ if (pageToken != null) {
78
+ _queryParams["page_token"] = pageToken;
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/contexts"),
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.35", "User-Agent": "agentmail/0.0.35", "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.ListContextsResponse.parseOrThrow(_response.body, {
93
+ unrecognizedObjectKeys: "passthrough",
94
+ allowUnrecognizedUnionMembers: true,
95
+ allowUnrecognizedEnumValues: true,
96
+ skipValidation: true,
97
+ breadcrumbsPrefix: ["response"],
98
+ });
99
+ }
100
+ if (_response.error.reason === "status-code") {
101
+ throw new errors.AgentMailError({
102
+ statusCode: _response.error.statusCode,
103
+ body: _response.error.body,
104
+ });
105
+ }
106
+ switch (_response.error.reason) {
107
+ case "non-json":
108
+ throw new errors.AgentMailError({
109
+ statusCode: _response.error.statusCode,
110
+ body: _response.error.rawBody,
111
+ });
112
+ case "timeout":
113
+ throw new errors.AgentMailTimeoutError("Timeout exceeded when calling GET /v0/contexts.");
114
+ case "unknown":
115
+ throw new errors.AgentMailError({
116
+ message: _response.error.errorMessage,
117
+ });
118
+ }
119
+ });
120
+ }
121
+ /**
122
+ * @param {AgentMail.ContextId} contextId
123
+ * @param {Contexts.RequestOptions} requestOptions - Request-specific configuration.
124
+ *
125
+ * @throws {@link AgentMail.NotFoundError}
126
+ *
127
+ * @example
128
+ * await client.contexts.get("context_id")
129
+ */
130
+ get(contextId, requestOptions) {
131
+ return __awaiter(this, void 0, void 0, function* () {
132
+ var _a, _b;
133
+ const _response = yield core.fetcher({
134
+ 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/contexts/${encodeURIComponent(serializers.ContextId.jsonOrThrow(contextId))}`),
135
+ method: "GET",
136
+ headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "agentmail", "X-Fern-SDK-Version": "0.0.35", "User-Agent": "agentmail/0.0.35", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
137
+ contentType: "application/json",
138
+ requestType: "json",
139
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
140
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
141
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
142
+ });
143
+ if (_response.ok) {
144
+ return serializers.Context.parseOrThrow(_response.body, {
145
+ unrecognizedObjectKeys: "passthrough",
146
+ allowUnrecognizedUnionMembers: true,
147
+ allowUnrecognizedEnumValues: true,
148
+ skipValidation: true,
149
+ breadcrumbsPrefix: ["response"],
150
+ });
151
+ }
152
+ if (_response.error.reason === "status-code") {
153
+ switch (_response.error.statusCode) {
154
+ case 404:
155
+ throw new AgentMail.NotFoundError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
156
+ unrecognizedObjectKeys: "passthrough",
157
+ allowUnrecognizedUnionMembers: true,
158
+ allowUnrecognizedEnumValues: true,
159
+ skipValidation: true,
160
+ breadcrumbsPrefix: ["response"],
161
+ }));
162
+ default:
163
+ throw new errors.AgentMailError({
164
+ statusCode: _response.error.statusCode,
165
+ body: _response.error.body,
166
+ });
167
+ }
168
+ }
169
+ switch (_response.error.reason) {
170
+ case "non-json":
171
+ throw new errors.AgentMailError({
172
+ statusCode: _response.error.statusCode,
173
+ body: _response.error.rawBody,
174
+ });
175
+ case "timeout":
176
+ throw new errors.AgentMailTimeoutError("Timeout exceeded when calling GET /v0/contexts/{context_id}.");
177
+ case "unknown":
178
+ throw new errors.AgentMailError({
179
+ message: _response.error.errorMessage,
180
+ });
181
+ }
182
+ });
183
+ }
184
+ /**
185
+ * @param {AgentMail.CreateContextRequest} request
186
+ * @param {Contexts.RequestOptions} requestOptions - Request-specific configuration.
187
+ *
188
+ * @throws {@link AgentMail.ValidationError}
189
+ *
190
+ * @example
191
+ * await client.contexts.create({
192
+ * type: "type",
193
+ * data: {
194
+ * "data": {
195
+ * "key": "value"
196
+ * }
197
+ * },
198
+ * metadata: undefined,
199
+ * isEvent: true
200
+ * })
201
+ */
202
+ create(request, requestOptions) {
203
+ return __awaiter(this, void 0, void 0, function* () {
204
+ var _a, _b;
205
+ const _response = yield core.fetcher({
206
+ 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/contexts"),
207
+ method: "POST",
208
+ headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "agentmail", "X-Fern-SDK-Version": "0.0.35", "User-Agent": "agentmail/0.0.35", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
209
+ contentType: "application/json",
210
+ requestType: "json",
211
+ body: serializers.CreateContextRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
212
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
213
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
214
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
215
+ });
216
+ if (_response.ok) {
217
+ return serializers.Context.parseOrThrow(_response.body, {
218
+ unrecognizedObjectKeys: "passthrough",
219
+ allowUnrecognizedUnionMembers: true,
220
+ allowUnrecognizedEnumValues: true,
221
+ skipValidation: true,
222
+ breadcrumbsPrefix: ["response"],
223
+ });
224
+ }
225
+ if (_response.error.reason === "status-code") {
226
+ switch (_response.error.statusCode) {
227
+ case 400:
228
+ throw new AgentMail.ValidationError(serializers.ValidationErrorResponse.parseOrThrow(_response.error.body, {
229
+ unrecognizedObjectKeys: "passthrough",
230
+ allowUnrecognizedUnionMembers: true,
231
+ allowUnrecognizedEnumValues: true,
232
+ skipValidation: true,
233
+ breadcrumbsPrefix: ["response"],
234
+ }));
235
+ default:
236
+ throw new errors.AgentMailError({
237
+ statusCode: _response.error.statusCode,
238
+ body: _response.error.body,
239
+ });
240
+ }
241
+ }
242
+ switch (_response.error.reason) {
243
+ case "non-json":
244
+ throw new errors.AgentMailError({
245
+ statusCode: _response.error.statusCode,
246
+ body: _response.error.rawBody,
247
+ });
248
+ case "timeout":
249
+ throw new errors.AgentMailTimeoutError("Timeout exceeded when calling POST /v0/contexts.");
250
+ case "unknown":
251
+ throw new errors.AgentMailError({
252
+ message: _response.error.errorMessage,
253
+ });
254
+ }
255
+ });
256
+ }
257
+ /**
258
+ * @param {AgentMail.ContextId} contextId
259
+ * @param {Contexts.RequestOptions} requestOptions - Request-specific configuration.
260
+ *
261
+ * @throws {@link AgentMail.NotFoundError}
262
+ *
263
+ * @example
264
+ * await client.contexts.delete("context_id")
265
+ */
266
+ delete(contextId, requestOptions) {
267
+ return __awaiter(this, void 0, void 0, function* () {
268
+ var _a, _b;
269
+ const _response = yield core.fetcher({
270
+ 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/contexts/${encodeURIComponent(serializers.ContextId.jsonOrThrow(contextId))}`),
271
+ method: "DELETE",
272
+ headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "agentmail", "X-Fern-SDK-Version": "0.0.35", "User-Agent": "agentmail/0.0.35", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
273
+ contentType: "application/json",
274
+ requestType: "json",
275
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
276
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
277
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
278
+ });
279
+ if (_response.ok) {
280
+ return;
281
+ }
282
+ if (_response.error.reason === "status-code") {
283
+ switch (_response.error.statusCode) {
284
+ case 404:
285
+ throw new AgentMail.NotFoundError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
286
+ unrecognizedObjectKeys: "passthrough",
287
+ allowUnrecognizedUnionMembers: true,
288
+ allowUnrecognizedEnumValues: true,
289
+ skipValidation: true,
290
+ breadcrumbsPrefix: ["response"],
291
+ }));
292
+ default:
293
+ throw new errors.AgentMailError({
294
+ statusCode: _response.error.statusCode,
295
+ body: _response.error.body,
296
+ });
297
+ }
298
+ }
299
+ switch (_response.error.reason) {
300
+ case "non-json":
301
+ throw new errors.AgentMailError({
302
+ statusCode: _response.error.statusCode,
303
+ body: _response.error.rawBody,
304
+ });
305
+ case "timeout":
306
+ throw new errors.AgentMailTimeoutError("Timeout exceeded when calling DELETE /v0/contexts/{context_id}.");
307
+ case "unknown":
308
+ throw new errors.AgentMailError({
309
+ message: _response.error.errorMessage,
310
+ });
311
+ }
312
+ });
313
+ }
314
+ _getAuthorizationHeader() {
315
+ return __awaiter(this, void 0, void 0, function* () {
316
+ var _a;
317
+ 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"];
318
+ if (bearer == null) {
319
+ throw new errors.AgentMailError({
320
+ message: "Please specify a bearer by either passing it in to the constructor or initializing a AGENTMAIL_API_KEY environment variable",
321
+ });
322
+ }
323
+ return `Bearer ${bearer}`;
324
+ });
325
+ }
326
+ }
327
+ exports.Contexts = Contexts;
@@ -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 ListContextsRequest {
10
+ limit?: AgentMail.Limit;
11
+ pageToken?: AgentMail.PageToken;
12
+ }
@@ -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 @@
1
+ export { type ListContextsRequest } from "./ListContextsRequest";
@@ -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,15 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as AgentMail from "../../../index";
5
+ export interface Context {
6
+ contextId: AgentMail.ContextId;
7
+ type: AgentMail.ContextType;
8
+ data: AgentMail.ContextData;
9
+ metadata?: AgentMail.ContextMetadata;
10
+ isEvent: AgentMail.ContextIsEvent;
11
+ /** Time at which context was last updated. */
12
+ updatedAt: Date;
13
+ /** Time at which context was created. */
14
+ createdAt: Date;
15
+ }
@@ -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
+ * Data of context.
6
+ */
7
+ export type ContextData = Record<string, unknown>;
@@ -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 context.
6
+ */
7
+ export type ContextId = 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
+ * Whether the context is an event.
6
+ */
7
+ export type ContextIsEvent = boolean;
@@ -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
+ * Metadata of context.
6
+ */
7
+ export type ContextMetadata = Record<string, unknown>;
@@ -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
+ * Type of context.
6
+ */
7
+ export type ContextType = 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,10 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as AgentMail from "../../../index";
5
+ export interface CreateContextRequest {
6
+ type: AgentMail.ContextType;
7
+ data: AgentMail.ContextData;
8
+ metadata?: AgentMail.ContextMetadata;
9
+ isEvent: AgentMail.ContextIsEvent;
10
+ }
@@ -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 ListContextsResponse {
6
+ count: AgentMail.Count;
7
+ limit?: AgentMail.Limit;
8
+ nextPageToken?: AgentMail.PageToken;
9
+ /** Ordered by `created_at` descending. */
10
+ contexts: AgentMail.Context[];
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,8 @@
1
+ export * from "./ContextId";
2
+ export * from "./ContextType";
3
+ export * from "./ContextData";
4
+ export * from "./ContextMetadata";
5
+ export * from "./ContextIsEvent";
6
+ export * from "./Context";
7
+ export * from "./ListContextsResponse";
8
+ export * from "./CreateContextRequest";
@@ -0,0 +1,24 @@
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("./ContextId"), exports);
18
+ __exportStar(require("./ContextType"), exports);
19
+ __exportStar(require("./ContextData"), exports);
20
+ __exportStar(require("./ContextMetadata"), exports);
21
+ __exportStar(require("./ContextIsEvent"), exports);
22
+ __exportStar(require("./Context"), exports);
23
+ __exportStar(require("./ListContextsResponse"), exports);
24
+ __exportStar(require("./CreateContextRequest"), exports);
@@ -89,7 +89,7 @@ class Drafts {
89
89
  const _response = yield core.fetcher({
90
90
  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/drafts"),
91
91
  method: "GET",
92
- headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "agentmail", "X-Fern-SDK-Version": "0.0.34", "User-Agent": "agentmail/0.0.34", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
92
+ headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "agentmail", "X-Fern-SDK-Version": "0.0.35", "User-Agent": "agentmail/0.0.35", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
93
93
  contentType: "application/json",
94
94
  queryParameters: _queryParams,
95
95
  requestType: "json",
@@ -153,7 +153,7 @@ class Drafts {
153
153
  const _response = yield core.fetcher({
154
154
  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/drafts/${encodeURIComponent(serializers.DraftId.jsonOrThrow(draftId))}`),
155
155
  method: "GET",
156
- headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "agentmail", "X-Fern-SDK-Version": "0.0.34", "User-Agent": "agentmail/0.0.34", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
156
+ headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "agentmail", "X-Fern-SDK-Version": "0.0.35", "User-Agent": "agentmail/0.0.35", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
157
157
  contentType: "application/json",
158
158
  requestType: "json",
159
159
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
@@ -6,6 +6,6 @@ export interface ListDraftsResponse {
6
6
  count: AgentMail.Count;
7
7
  limit?: AgentMail.Limit;
8
8
  nextPageToken?: AgentMail.PageToken;
9
- /** Draft items. Ordered by `updated_at` descending. */
9
+ /** Ordered by `updated_at` descending. */
10
10
  drafts: AgentMail.DraftItem[];
11
11
  }
@@ -95,7 +95,7 @@ class Inboxes {
95
95
  const _response = yield core.fetcher({
96
96
  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/inboxes"),
97
97
  method: "GET",
98
- headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "agentmail", "X-Fern-SDK-Version": "0.0.34", "User-Agent": "agentmail/0.0.34", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
98
+ headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "agentmail", "X-Fern-SDK-Version": "0.0.35", "User-Agent": "agentmail/0.0.35", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
99
99
  contentType: "application/json",
100
100
  queryParameters: _queryParams,
101
101
  requestType: "json",
@@ -148,7 +148,7 @@ class Inboxes {
148
148
  const _response = yield core.fetcher({
149
149
  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/inboxes/${encodeURIComponent(serializers.inboxes.InboxId.jsonOrThrow(inboxId))}`),
150
150
  method: "GET",
151
- headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "agentmail", "X-Fern-SDK-Version": "0.0.34", "User-Agent": "agentmail/0.0.34", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
151
+ headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "agentmail", "X-Fern-SDK-Version": "0.0.35", "User-Agent": "agentmail/0.0.35", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
152
152
  contentType: "application/json",
153
153
  requestType: "json",
154
154
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
@@ -215,7 +215,7 @@ class Inboxes {
215
215
  const _response = yield core.fetcher({
216
216
  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/inboxes"),
217
217
  method: "POST",
218
- headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "agentmail", "X-Fern-SDK-Version": "0.0.34", "User-Agent": "agentmail/0.0.34", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
218
+ headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "agentmail", "X-Fern-SDK-Version": "0.0.35", "User-Agent": "agentmail/0.0.35", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
219
219
  contentType: "application/json",
220
220
  requestType: "json",
221
221
  body: serializers.inboxes.CreateInboxRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),