agentmail 0.0.69 → 0.0.71

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 (60) hide show
  1. package/dist/cjs/Client.d.ts +3 -0
  2. package/dist/cjs/Client.js +17 -12
  3. package/dist/cjs/api/resources/apiKeys/client/Client.d.ts +65 -0
  4. package/dist/cjs/api/resources/apiKeys/client/Client.js +292 -0
  5. package/dist/cjs/api/resources/apiKeys/client/index.d.ts +2 -0
  6. package/dist/cjs/api/resources/apiKeys/client/index.js +17 -0
  7. package/dist/cjs/api/resources/apiKeys/client/requests/ListApiKeysRequest.d.ts +12 -0
  8. package/dist/cjs/api/resources/apiKeys/client/requests/ListApiKeysRequest.js +5 -0
  9. package/dist/cjs/api/resources/apiKeys/client/requests/index.d.ts +1 -0
  10. package/dist/cjs/api/resources/apiKeys/client/requests/index.js +2 -0
  11. package/dist/cjs/api/resources/apiKeys/index.d.ts +2 -0
  12. package/dist/cjs/api/resources/apiKeys/index.js +18 -0
  13. package/dist/cjs/api/resources/apiKeys/types/ApiKey.d.ts +12 -0
  14. package/dist/cjs/api/resources/apiKeys/types/ApiKey.js +5 -0
  15. package/dist/cjs/api/resources/apiKeys/types/ApiKeyId.d.ts +7 -0
  16. package/dist/cjs/api/resources/apiKeys/types/ApiKeyId.js +5 -0
  17. package/dist/cjs/api/resources/apiKeys/types/CreateApiKeyRequest.d.ts +7 -0
  18. package/dist/cjs/api/resources/apiKeys/types/CreateApiKeyRequest.js +5 -0
  19. package/dist/cjs/api/resources/apiKeys/types/CreateApiKeyResponse.d.ts +12 -0
  20. package/dist/cjs/api/resources/apiKeys/types/CreateApiKeyResponse.js +5 -0
  21. package/dist/cjs/api/resources/apiKeys/types/CreatedAt.d.ts +7 -0
  22. package/dist/cjs/api/resources/apiKeys/types/CreatedAt.js +5 -0
  23. package/dist/cjs/api/resources/apiKeys/types/ListApiKeysResponse.d.ts +10 -0
  24. package/dist/cjs/api/resources/apiKeys/types/ListApiKeysResponse.js +5 -0
  25. package/dist/cjs/api/resources/apiKeys/types/Name.d.ts +7 -0
  26. package/dist/cjs/api/resources/apiKeys/types/Name.js +5 -0
  27. package/dist/cjs/api/resources/apiKeys/types/Prefix.d.ts +7 -0
  28. package/dist/cjs/api/resources/apiKeys/types/Prefix.js +5 -0
  29. package/dist/cjs/api/resources/apiKeys/types/index.d.ts +8 -0
  30. package/dist/cjs/api/resources/apiKeys/types/index.js +24 -0
  31. package/dist/cjs/api/resources/index.d.ts +3 -0
  32. package/dist/cjs/api/resources/index.js +4 -1
  33. package/dist/cjs/serialization/resources/apiKeys/index.d.ts +1 -0
  34. package/dist/cjs/serialization/resources/apiKeys/index.js +17 -0
  35. package/dist/cjs/serialization/resources/apiKeys/types/ApiKey.d.ts +20 -0
  36. package/dist/cjs/serialization/resources/apiKeys/types/ApiKey.js +51 -0
  37. package/dist/cjs/serialization/resources/apiKeys/types/ApiKeyId.d.ts +10 -0
  38. package/dist/cjs/serialization/resources/apiKeys/types/ApiKeyId.js +41 -0
  39. package/dist/cjs/serialization/resources/apiKeys/types/CreateApiKeyRequest.d.ts +13 -0
  40. package/dist/cjs/serialization/resources/apiKeys/types/CreateApiKeyRequest.js +44 -0
  41. package/dist/cjs/serialization/resources/apiKeys/types/CreateApiKeyResponse.d.ts +20 -0
  42. package/dist/cjs/serialization/resources/apiKeys/types/CreateApiKeyResponse.js +51 -0
  43. package/dist/cjs/serialization/resources/apiKeys/types/CreatedAt.d.ts +10 -0
  44. package/dist/cjs/serialization/resources/apiKeys/types/CreatedAt.js +41 -0
  45. package/dist/cjs/serialization/resources/apiKeys/types/ListApiKeysResponse.d.ts +17 -0
  46. package/dist/cjs/serialization/resources/apiKeys/types/ListApiKeysResponse.js +48 -0
  47. package/dist/cjs/serialization/resources/apiKeys/types/Name.d.ts +10 -0
  48. package/dist/cjs/serialization/resources/apiKeys/types/Name.js +41 -0
  49. package/dist/cjs/serialization/resources/apiKeys/types/Prefix.d.ts +10 -0
  50. package/dist/cjs/serialization/resources/apiKeys/types/Prefix.js +41 -0
  51. package/dist/cjs/serialization/resources/apiKeys/types/index.d.ts +8 -0
  52. package/dist/cjs/serialization/resources/apiKeys/types/index.js +24 -0
  53. package/dist/cjs/serialization/resources/index.d.ts +2 -0
  54. package/dist/cjs/serialization/resources/index.js +3 -1
  55. package/dist/cjs/version.d.ts +1 -1
  56. package/dist/cjs/version.js +1 -1
  57. package/dist/llms-full.txt +478 -157
  58. package/dist/llms.txt +5 -2
  59. package/package.json +1 -1
  60. package/reference.md +157 -0
@@ -5,6 +5,7 @@ import * as environments from "./environments.js";
5
5
  import * as core from "./core/index.js";
6
6
  import { Inboxes } from "./api/resources/inboxes/client/Client.js";
7
7
  import { Webhooks } from "./api/resources/webhooks/client/Client.js";
8
+ import { ApiKeys } from "./api/resources/apiKeys/client/Client.js";
8
9
  import { Domains } from "./api/resources/domains/client/Client.js";
9
10
  import { Drafts } from "./api/resources/drafts/client/Client.js";
10
11
  import { Metrics } from "./api/resources/metrics/client/Client.js";
@@ -36,6 +37,7 @@ export declare class AgentMailClient {
36
37
  protected readonly _options: AgentMailClient.Options;
37
38
  protected _inboxes: Inboxes | undefined;
38
39
  protected _webhooks: Webhooks | undefined;
40
+ protected _apiKeys: ApiKeys | undefined;
39
41
  protected _domains: Domains | undefined;
40
42
  protected _drafts: Drafts | undefined;
41
43
  protected _metrics: Metrics | undefined;
@@ -44,6 +46,7 @@ export declare class AgentMailClient {
44
46
  constructor(_options?: AgentMailClient.Options);
45
47
  get inboxes(): Inboxes;
46
48
  get webhooks(): Webhooks;
49
+ get apiKeys(): ApiKeys;
47
50
  get domains(): Domains;
48
51
  get drafts(): Drafts;
49
52
  get metrics(): Metrics;
@@ -41,18 +41,19 @@ const core = __importStar(require("./core/index.js"));
41
41
  const headers_js_1 = require("./core/headers.js");
42
42
  const Client_js_1 = require("./api/resources/inboxes/client/Client.js");
43
43
  const Client_js_2 = require("./api/resources/webhooks/client/Client.js");
44
- const Client_js_3 = require("./api/resources/domains/client/Client.js");
45
- const Client_js_4 = require("./api/resources/drafts/client/Client.js");
46
- const Client_js_5 = require("./api/resources/metrics/client/Client.js");
47
- const Client_js_6 = require("./api/resources/threads/client/Client.js");
48
- const Client_js_7 = require("./api/resources/websockets/client/Client.js");
44
+ const Client_js_3 = require("./api/resources/apiKeys/client/Client.js");
45
+ const Client_js_4 = require("./api/resources/domains/client/Client.js");
46
+ const Client_js_5 = require("./api/resources/drafts/client/Client.js");
47
+ const Client_js_6 = require("./api/resources/metrics/client/Client.js");
48
+ const Client_js_7 = require("./api/resources/threads/client/Client.js");
49
+ const Client_js_8 = require("./api/resources/websockets/client/Client.js");
49
50
  class AgentMailClient {
50
51
  constructor(_options = {}) {
51
52
  this._options = Object.assign(Object.assign({}, _options), { headers: (0, headers_js_1.mergeHeaders)({
52
53
  "X-Fern-Language": "JavaScript",
53
54
  "X-Fern-SDK-Name": "agentmail",
54
- "X-Fern-SDK-Version": "0.0.69",
55
- "User-Agent": "agentmail/0.0.69",
55
+ "X-Fern-SDK-Version": "0.0.71",
56
+ "User-Agent": "agentmail/0.0.71",
56
57
  "X-Fern-Runtime": core.RUNTIME.type,
57
58
  "X-Fern-Runtime-Version": core.RUNTIME.version,
58
59
  }, _options === null || _options === void 0 ? void 0 : _options.headers) });
@@ -65,25 +66,29 @@ class AgentMailClient {
65
66
  var _a;
66
67
  return ((_a = this._webhooks) !== null && _a !== void 0 ? _a : (this._webhooks = new Client_js_2.Webhooks(this._options)));
67
68
  }
69
+ get apiKeys() {
70
+ var _a;
71
+ return ((_a = this._apiKeys) !== null && _a !== void 0 ? _a : (this._apiKeys = new Client_js_3.ApiKeys(this._options)));
72
+ }
68
73
  get domains() {
69
74
  var _a;
70
- return ((_a = this._domains) !== null && _a !== void 0 ? _a : (this._domains = new Client_js_3.Domains(this._options)));
75
+ return ((_a = this._domains) !== null && _a !== void 0 ? _a : (this._domains = new Client_js_4.Domains(this._options)));
71
76
  }
72
77
  get drafts() {
73
78
  var _a;
74
- return ((_a = this._drafts) !== null && _a !== void 0 ? _a : (this._drafts = new Client_js_4.Drafts(this._options)));
79
+ return ((_a = this._drafts) !== null && _a !== void 0 ? _a : (this._drafts = new Client_js_5.Drafts(this._options)));
75
80
  }
76
81
  get metrics() {
77
82
  var _a;
78
- return ((_a = this._metrics) !== null && _a !== void 0 ? _a : (this._metrics = new Client_js_5.Metrics(this._options)));
83
+ return ((_a = this._metrics) !== null && _a !== void 0 ? _a : (this._metrics = new Client_js_6.Metrics(this._options)));
79
84
  }
80
85
  get threads() {
81
86
  var _a;
82
- return ((_a = this._threads) !== null && _a !== void 0 ? _a : (this._threads = new Client_js_6.Threads(this._options)));
87
+ return ((_a = this._threads) !== null && _a !== void 0 ? _a : (this._threads = new Client_js_7.Threads(this._options)));
83
88
  }
84
89
  get websockets() {
85
90
  var _a;
86
- return ((_a = this._websockets) !== null && _a !== void 0 ? _a : (this._websockets = new Client_js_7.Websockets(this._options)));
91
+ return ((_a = this._websockets) !== null && _a !== void 0 ? _a : (this._websockets = new Client_js_8.Websockets(this._options)));
87
92
  }
88
93
  }
89
94
  exports.AgentMailClient = AgentMailClient;
@@ -0,0 +1,65 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as environments from "../../../../environments.js";
5
+ import * as core from "../../../../core/index.js";
6
+ import * as AgentMail from "../../../index.js";
7
+ export declare namespace ApiKeys {
8
+ interface Options {
9
+ environment?: core.Supplier<environments.AgentMailEnvironment | environments.AgentMailEnvironmentUrls>;
10
+ /** Specify a custom URL to connect the client to. */
11
+ baseUrl?: core.Supplier<string>;
12
+ apiKey?: core.Supplier<core.BearerToken | undefined>;
13
+ /** Additional headers to include in requests. */
14
+ headers?: Record<string, string | core.Supplier<string | null | undefined> | null | undefined>;
15
+ }
16
+ interface RequestOptions {
17
+ /** The maximum time to wait for a response in seconds. */
18
+ timeoutInSeconds?: number;
19
+ /** The number of times to retry the request. Defaults to 2. */
20
+ maxRetries?: number;
21
+ /** A hook to abort the request. */
22
+ abortSignal?: AbortSignal;
23
+ /** Additional query string parameters to include in the request. */
24
+ queryParams?: Record<string, unknown>;
25
+ /** Additional headers to include in the request. */
26
+ headers?: Record<string, string | core.Supplier<string | null | undefined> | null | undefined>;
27
+ }
28
+ }
29
+ export declare class ApiKeys {
30
+ protected readonly _options: ApiKeys.Options;
31
+ constructor(_options?: ApiKeys.Options);
32
+ /**
33
+ * @param {AgentMail.ListApiKeysRequest} request
34
+ * @param {ApiKeys.RequestOptions} requestOptions - Request-specific configuration.
35
+ *
36
+ * @example
37
+ * await client.apiKeys.list()
38
+ */
39
+ list(request?: AgentMail.ListApiKeysRequest, requestOptions?: ApiKeys.RequestOptions): Promise<core.Page<AgentMail.ApiKey>>;
40
+ /**
41
+ * @param {AgentMail.CreateApiKeyRequest} request
42
+ * @param {ApiKeys.RequestOptions} requestOptions - Request-specific configuration.
43
+ *
44
+ * @throws {@link AgentMail.ValidationError}
45
+ *
46
+ * @example
47
+ * await client.apiKeys.create({
48
+ * name: "name"
49
+ * })
50
+ */
51
+ create(request: AgentMail.CreateApiKeyRequest, requestOptions?: ApiKeys.RequestOptions): core.HttpResponsePromise<AgentMail.CreateApiKeyResponse>;
52
+ private __create;
53
+ /**
54
+ * @param {AgentMail.ApiKeyId} apiKey
55
+ * @param {ApiKeys.RequestOptions} requestOptions - Request-specific configuration.
56
+ *
57
+ * @throws {@link AgentMail.NotFoundError}
58
+ *
59
+ * @example
60
+ * await client.apiKeys.delete("api_key")
61
+ */
62
+ delete(apiKey: AgentMail.ApiKeyId, requestOptions?: ApiKeys.RequestOptions): core.HttpResponsePromise<void>;
63
+ private __delete;
64
+ protected _getAuthorizationHeader(): Promise<string>;
65
+ }
@@ -0,0 +1,292 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
48
+ exports.ApiKeys = void 0;
49
+ const environments = __importStar(require("../../../../environments.js"));
50
+ const core = __importStar(require("../../../../core/index.js"));
51
+ const AgentMail = __importStar(require("../../../index.js"));
52
+ const headers_js_1 = require("../../../../core/headers.js");
53
+ const serializers = __importStar(require("../../../../serialization/index.js"));
54
+ const errors = __importStar(require("../../../../errors/index.js"));
55
+ class ApiKeys {
56
+ constructor(_options = {}) {
57
+ this._options = _options;
58
+ }
59
+ /**
60
+ * @param {AgentMail.ListApiKeysRequest} request
61
+ * @param {ApiKeys.RequestOptions} requestOptions - Request-specific configuration.
62
+ *
63
+ * @example
64
+ * await client.apiKeys.list()
65
+ */
66
+ list() {
67
+ return __awaiter(this, arguments, void 0, function* (request = {}, requestOptions) {
68
+ const list = core.HttpResponsePromise.interceptFunction((request) => __awaiter(this, void 0, void 0, function* () {
69
+ var _a, _b, _c;
70
+ const { limit, pageToken } = request;
71
+ const _queryParams = {};
72
+ if (limit != null) {
73
+ _queryParams["limit"] = limit.toString();
74
+ }
75
+ if (pageToken != null) {
76
+ _queryParams["page_token"] = pageToken;
77
+ }
78
+ let _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
79
+ const _response = yield core.fetcher({
80
+ 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.Production).http, "/v0/api-keys"),
81
+ method: "GET",
82
+ headers: _headers,
83
+ queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
84
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
85
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
86
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
87
+ });
88
+ if (_response.ok) {
89
+ return {
90
+ data: serializers.ListApiKeysResponse.parseOrThrow(_response.body, {
91
+ unrecognizedObjectKeys: "passthrough",
92
+ allowUnrecognizedUnionMembers: true,
93
+ allowUnrecognizedEnumValues: true,
94
+ skipValidation: true,
95
+ breadcrumbsPrefix: ["response"],
96
+ }),
97
+ rawResponse: _response.rawResponse,
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
+ rawResponse: _response.rawResponse,
105
+ });
106
+ }
107
+ switch (_response.error.reason) {
108
+ case "non-json":
109
+ throw new errors.AgentMailError({
110
+ statusCode: _response.error.statusCode,
111
+ body: _response.error.rawBody,
112
+ rawResponse: _response.rawResponse,
113
+ });
114
+ case "timeout":
115
+ throw new errors.AgentMailTimeoutError("Timeout exceeded when calling GET /v0/api-keys.");
116
+ case "unknown":
117
+ throw new errors.AgentMailError({
118
+ message: _response.error.errorMessage,
119
+ rawResponse: _response.rawResponse,
120
+ });
121
+ }
122
+ }));
123
+ const dataWithRawResponse = yield list(request).withRawResponse();
124
+ return new core.Pageable({
125
+ response: dataWithRawResponse.data,
126
+ rawResponse: dataWithRawResponse.rawResponse,
127
+ hasNextPage: (response) => (response === null || response === void 0 ? void 0 : response.nextPageToken) != null &&
128
+ !(typeof (response === null || response === void 0 ? void 0 : response.nextPageToken) === "string" && (response === null || response === void 0 ? void 0 : response.nextPageToken) === ""),
129
+ getItems: (response) => { var _a; return (_a = response === null || response === void 0 ? void 0 : response.apiKeys) !== null && _a !== void 0 ? _a : []; },
130
+ loadPage: (response) => {
131
+ return list(core.setObjectProperty(request, "pageToken", response === null || response === void 0 ? void 0 : response.nextPageToken));
132
+ },
133
+ });
134
+ });
135
+ }
136
+ /**
137
+ * @param {AgentMail.CreateApiKeyRequest} request
138
+ * @param {ApiKeys.RequestOptions} requestOptions - Request-specific configuration.
139
+ *
140
+ * @throws {@link AgentMail.ValidationError}
141
+ *
142
+ * @example
143
+ * await client.apiKeys.create({
144
+ * name: "name"
145
+ * })
146
+ */
147
+ create(request, requestOptions) {
148
+ return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions));
149
+ }
150
+ __create(request, requestOptions) {
151
+ return __awaiter(this, void 0, void 0, function* () {
152
+ var _a, _b, _c;
153
+ let _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
154
+ const _response = yield core.fetcher({
155
+ 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.Production).http, "/v0/api-keys"),
156
+ method: "POST",
157
+ headers: _headers,
158
+ contentType: "application/json",
159
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
160
+ requestType: "json",
161
+ body: serializers.CreateApiKeyRequest.jsonOrThrow(request, {
162
+ unrecognizedObjectKeys: "strip",
163
+ omitUndefined: true,
164
+ }),
165
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
166
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
167
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
168
+ });
169
+ if (_response.ok) {
170
+ return {
171
+ data: serializers.CreateApiKeyResponse.parseOrThrow(_response.body, {
172
+ unrecognizedObjectKeys: "passthrough",
173
+ allowUnrecognizedUnionMembers: true,
174
+ allowUnrecognizedEnumValues: true,
175
+ skipValidation: true,
176
+ breadcrumbsPrefix: ["response"],
177
+ }),
178
+ rawResponse: _response.rawResponse,
179
+ };
180
+ }
181
+ if (_response.error.reason === "status-code") {
182
+ switch (_response.error.statusCode) {
183
+ case 400:
184
+ throw new AgentMail.ValidationError(serializers.ValidationErrorResponse.parseOrThrow(_response.error.body, {
185
+ unrecognizedObjectKeys: "passthrough",
186
+ allowUnrecognizedUnionMembers: true,
187
+ allowUnrecognizedEnumValues: true,
188
+ skipValidation: true,
189
+ breadcrumbsPrefix: ["response"],
190
+ }), _response.rawResponse);
191
+ default:
192
+ throw new errors.AgentMailError({
193
+ statusCode: _response.error.statusCode,
194
+ body: _response.error.body,
195
+ rawResponse: _response.rawResponse,
196
+ });
197
+ }
198
+ }
199
+ switch (_response.error.reason) {
200
+ case "non-json":
201
+ throw new errors.AgentMailError({
202
+ statusCode: _response.error.statusCode,
203
+ body: _response.error.rawBody,
204
+ rawResponse: _response.rawResponse,
205
+ });
206
+ case "timeout":
207
+ throw new errors.AgentMailTimeoutError("Timeout exceeded when calling POST /v0/api-keys.");
208
+ case "unknown":
209
+ throw new errors.AgentMailError({
210
+ message: _response.error.errorMessage,
211
+ rawResponse: _response.rawResponse,
212
+ });
213
+ }
214
+ });
215
+ }
216
+ /**
217
+ * @param {AgentMail.ApiKeyId} apiKey
218
+ * @param {ApiKeys.RequestOptions} requestOptions - Request-specific configuration.
219
+ *
220
+ * @throws {@link AgentMail.NotFoundError}
221
+ *
222
+ * @example
223
+ * await client.apiKeys.delete("api_key")
224
+ */
225
+ delete(apiKey, requestOptions) {
226
+ return core.HttpResponsePromise.fromPromise(this.__delete(apiKey, requestOptions));
227
+ }
228
+ __delete(apiKey, requestOptions) {
229
+ return __awaiter(this, void 0, void 0, function* () {
230
+ var _a, _b, _c;
231
+ let _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
232
+ const _response = yield core.fetcher({
233
+ 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.Production).http, `/v0/api-keys/${encodeURIComponent(serializers.ApiKeyId.jsonOrThrow(apiKey, { omitUndefined: true }))}`),
234
+ method: "DELETE",
235
+ headers: _headers,
236
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
237
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
238
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
239
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
240
+ });
241
+ if (_response.ok) {
242
+ return { data: undefined, rawResponse: _response.rawResponse };
243
+ }
244
+ if (_response.error.reason === "status-code") {
245
+ switch (_response.error.statusCode) {
246
+ case 404:
247
+ throw new AgentMail.NotFoundError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
248
+ unrecognizedObjectKeys: "passthrough",
249
+ allowUnrecognizedUnionMembers: true,
250
+ allowUnrecognizedEnumValues: true,
251
+ skipValidation: true,
252
+ breadcrumbsPrefix: ["response"],
253
+ }), _response.rawResponse);
254
+ default:
255
+ throw new errors.AgentMailError({
256
+ statusCode: _response.error.statusCode,
257
+ body: _response.error.body,
258
+ rawResponse: _response.rawResponse,
259
+ });
260
+ }
261
+ }
262
+ switch (_response.error.reason) {
263
+ case "non-json":
264
+ throw new errors.AgentMailError({
265
+ statusCode: _response.error.statusCode,
266
+ body: _response.error.rawBody,
267
+ rawResponse: _response.rawResponse,
268
+ });
269
+ case "timeout":
270
+ throw new errors.AgentMailTimeoutError("Timeout exceeded when calling DELETE /v0/api-keys/{api_key}.");
271
+ case "unknown":
272
+ throw new errors.AgentMailError({
273
+ message: _response.error.errorMessage,
274
+ rawResponse: _response.rawResponse,
275
+ });
276
+ }
277
+ });
278
+ }
279
+ _getAuthorizationHeader() {
280
+ return __awaiter(this, void 0, void 0, function* () {
281
+ var _a;
282
+ 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"];
283
+ if (bearer == null) {
284
+ throw new errors.AgentMailError({
285
+ message: "Please specify a bearer by either passing it in to the constructor or initializing a AGENTMAIL_API_KEY environment variable",
286
+ });
287
+ }
288
+ return `Bearer ${bearer}`;
289
+ });
290
+ }
291
+ }
292
+ exports.ApiKeys = ApiKeys;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ export * from "./requests/index.js";
@@ -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/index.js"), 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.js";
5
+ /**
6
+ * @example
7
+ * {}
8
+ */
9
+ export interface ListApiKeysRequest {
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 ListApiKeysRequest } from "./ListApiKeysRequest.js";
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ export * from "./types/index.js";
2
+ export * from "./client/index.js";
@@ -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/index.js"), exports);
18
+ __exportStar(require("./client/index.js"), 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.js";
5
+ export interface ApiKey {
6
+ apiKeyId: AgentMail.ApiKeyId;
7
+ prefix: AgentMail.Prefix;
8
+ name: AgentMail.Name;
9
+ /** Time at which api key was last used. */
10
+ usedAt?: Date;
11
+ createdAt: AgentMail.CreatedAt;
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,7 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ /**
5
+ * ID of api key.
6
+ */
7
+ export type ApiKeyId = 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
+ import * as AgentMail from "../../../index.js";
5
+ export interface CreateApiKeyRequest {
6
+ name: AgentMail.Name;
7
+ }
@@ -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,12 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as AgentMail from "../../../index.js";
5
+ export interface CreateApiKeyResponse {
6
+ apiKeyId: AgentMail.ApiKeyId;
7
+ /** API key. */
8
+ apiKey: string;
9
+ prefix: AgentMail.Prefix;
10
+ name: AgentMail.Name;
11
+ createdAt: AgentMail.CreatedAt;
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,7 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ /**
5
+ * Time at which api key was created.
6
+ */
7
+ export type CreatedAt = 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,10 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as AgentMail from "../../../index.js";
5
+ export interface ListApiKeysResponse {
6
+ count: AgentMail.Count;
7
+ nextPageToken?: AgentMail.PageToken;
8
+ /** Ordered by `created_at` descending. */
9
+ apiKeys: AgentMail.ApiKey[];
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,7 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ /**
5
+ * Name of api key.
6
+ */
7
+ export type Name = 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
+ * Prefix of api key.
6
+ */
7
+ export type Prefix = string;