agentmail 0.1.6 → 0.1.8
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.
- package/README.md +63 -0
- package/dist/cjs/BaseClient.d.ts +14 -1
- package/dist/cjs/BaseClient.js +59 -0
- package/dist/cjs/Client.d.ts +30 -29
- package/dist/cjs/Client.js +12 -53
- package/dist/cjs/api/resources/apiKeys/client/Client.d.ts +12 -12
- package/dist/cjs/api/resources/apiKeys/client/Client.js +29 -31
- package/dist/cjs/api/resources/domains/client/Client.d.ts +19 -19
- package/dist/cjs/api/resources/domains/client/Client.js +60 -53
- package/dist/cjs/api/resources/drafts/client/Client.d.ts +10 -10
- package/dist/cjs/api/resources/drafts/client/Client.js +23 -28
- package/dist/cjs/api/resources/events/types/DomainVerifiedEvent.d.ts +7 -0
- package/dist/cjs/api/resources/{webhooks → events}/types/EventType.d.ts +1 -0
- package/dist/cjs/api/resources/{webhooks → events}/types/EventType.js +1 -0
- package/dist/cjs/api/resources/events/types/EventTypes.d.ts +5 -0
- package/dist/cjs/api/resources/events/types/EventTypes.js +3 -0
- package/dist/cjs/api/resources/events/types/index.d.ts +3 -0
- package/dist/cjs/api/resources/events/types/index.js +3 -0
- package/dist/cjs/api/resources/inboxes/client/Client.d.ts +30 -30
- package/dist/cjs/api/resources/inboxes/client/Client.js +55 -51
- package/dist/cjs/api/resources/inboxes/resources/drafts/client/Client.d.ts +27 -27
- package/dist/cjs/api/resources/inboxes/resources/drafts/client/Client.js +77 -70
- package/dist/cjs/api/resources/inboxes/resources/messages/client/Client.d.ts +25 -25
- package/dist/cjs/api/resources/inboxes/resources/messages/client/Client.js +83 -73
- package/dist/cjs/api/resources/inboxes/resources/metrics/client/Client.d.ts +8 -8
- package/dist/cjs/api/resources/inboxes/resources/metrics/client/Client.js +17 -25
- package/dist/cjs/api/resources/inboxes/resources/threads/client/Client.d.ts +17 -17
- package/dist/cjs/api/resources/inboxes/resources/threads/client/Client.js +51 -50
- package/dist/cjs/api/resources/messages/types/Message.d.ts +4 -0
- package/dist/cjs/api/resources/metrics/client/Client.d.ts +7 -7
- package/dist/cjs/api/resources/metrics/client/Client.js +12 -20
- package/dist/cjs/api/resources/pods/client/Client.d.ts +27 -27
- package/dist/cjs/api/resources/pods/client/Client.js +44 -43
- package/dist/cjs/api/resources/pods/resources/domains/client/Client.d.ts +15 -15
- package/dist/cjs/api/resources/pods/resources/domains/client/Client.js +41 -43
- package/dist/cjs/api/resources/pods/resources/drafts/client/Client.d.ts +12 -12
- package/dist/cjs/api/resources/pods/resources/drafts/client/Client.js +30 -35
- package/dist/cjs/api/resources/pods/resources/inboxes/client/Client.d.ts +19 -19
- package/dist/cjs/api/resources/pods/resources/inboxes/client/Client.js +53 -52
- package/dist/cjs/api/resources/pods/resources/threads/client/Client.d.ts +13 -13
- package/dist/cjs/api/resources/pods/resources/threads/client/Client.js +39 -41
- package/dist/cjs/api/resources/threads/client/Client.d.ts +11 -11
- package/dist/cjs/api/resources/threads/client/Client.js +32 -34
- package/dist/cjs/api/resources/webhooks/client/Client.d.ts +15 -15
- package/dist/cjs/api/resources/webhooks/client/Client.js +40 -39
- package/dist/cjs/api/resources/webhooks/types/CreateWebhookRequest.d.ts +1 -1
- package/dist/cjs/api/resources/webhooks/types/Webhook.d.ts +1 -1
- package/dist/cjs/api/resources/webhooks/types/index.d.ts +0 -2
- package/dist/cjs/api/resources/webhooks/types/index.js +0 -2
- package/dist/cjs/api/resources/websockets/client/Client.d.ts +6 -6
- package/dist/cjs/api/resources/websockets/client/Client.js +8 -19
- package/dist/cjs/api/resources/websockets/client/Socket.d.ts +1 -1
- package/dist/cjs/api/resources/websockets/types/Subscribe.d.ts +5 -1
- package/dist/cjs/api/resources/websockets/types/Subscribed.d.ts +5 -1
- package/dist/cjs/auth/BearerAuthProvider.d.ts +14 -0
- package/dist/cjs/auth/BearerAuthProvider.js +72 -0
- package/dist/cjs/auth/index.d.ts +1 -0
- package/dist/cjs/auth/index.js +5 -0
- package/dist/cjs/core/auth/AuthProvider.d.ts +4 -1
- package/dist/cjs/core/auth/BearerToken.d.ts +3 -1
- package/dist/cjs/core/auth/BearerToken.js +7 -6
- package/dist/cjs/core/auth/NoOpAuthProvider.d.ts +5 -0
- package/dist/cjs/core/auth/NoOpAuthProvider.js +9 -0
- package/dist/cjs/core/auth/index.d.ts +1 -0
- package/dist/cjs/core/auth/index.js +3 -1
- package/dist/cjs/core/exports.d.ts +1 -0
- package/dist/cjs/core/exports.js +1 -0
- package/dist/cjs/core/fetcher/Fetcher.d.ts +4 -1
- package/dist/cjs/core/fetcher/Fetcher.js +202 -9
- package/dist/cjs/core/fetcher/getRequestBody.d.ts +1 -1
- package/dist/cjs/core/fetcher/getRequestBody.js +4 -0
- package/dist/cjs/core/fetcher/makeRequest.d.ts +1 -1
- package/dist/cjs/core/fetcher/makeRequest.js +0 -2
- package/dist/cjs/core/fetcher/requestWithRetries.js +0 -9
- package/dist/cjs/core/fetcher/signals.d.ts +0 -6
- package/dist/cjs/core/fetcher/signals.js +0 -12
- package/dist/cjs/core/headers.js +6 -4
- package/dist/cjs/core/index.d.ts +1 -0
- package/dist/cjs/core/index.js +2 -1
- package/dist/cjs/core/logging/exports.d.ts +18 -0
- package/dist/cjs/core/logging/exports.js +45 -0
- package/dist/cjs/core/logging/index.d.ts +1 -0
- package/dist/cjs/core/logging/index.js +17 -0
- package/dist/cjs/core/logging/logger.d.ts +126 -0
- package/dist/cjs/core/logging/logger.js +144 -0
- package/dist/cjs/core/schemas/Schema.d.ts +1 -0
- package/dist/cjs/core/schemas/Schema.js +1 -0
- package/dist/cjs/core/schemas/builders/primitives/index.d.ts +1 -0
- package/dist/cjs/core/schemas/builders/primitives/index.js +3 -1
- package/dist/cjs/core/schemas/builders/primitives/never.d.ts +2 -0
- package/dist/cjs/core/schemas/builders/primitives/never.js +14 -0
- package/dist/cjs/core/url/join.js +0 -1
- package/dist/cjs/serialization/resources/events/types/DomainVerifiedEvent.d.ts +14 -0
- package/dist/cjs/serialization/resources/events/types/DomainVerifiedEvent.js +46 -0
- package/dist/cjs/serialization/resources/{webhooks → events}/types/EventType.d.ts +2 -2
- package/dist/cjs/serialization/resources/{webhooks → events}/types/EventType.js +1 -0
- package/dist/cjs/serialization/resources/{webhooks → events}/types/EventTypes.d.ts +1 -1
- package/dist/cjs/serialization/resources/events/types/index.d.ts +3 -0
- package/dist/cjs/serialization/resources/events/types/index.js +3 -0
- package/dist/cjs/serialization/resources/messages/types/Message.d.ts +2 -0
- package/dist/cjs/serialization/resources/messages/types/Message.js +2 -0
- package/dist/cjs/serialization/resources/webhooks/types/CreateWebhookRequest.d.ts +1 -1
- package/dist/cjs/serialization/resources/webhooks/types/CreateWebhookRequest.js +1 -1
- package/dist/cjs/serialization/resources/webhooks/types/Webhook.d.ts +1 -1
- package/dist/cjs/serialization/resources/webhooks/types/Webhook.js +1 -1
- package/dist/cjs/serialization/resources/webhooks/types/index.d.ts +0 -2
- package/dist/cjs/serialization/resources/webhooks/types/index.js +0 -2
- package/dist/cjs/serialization/resources/websockets/client/socket/WebsocketsSocketResponse.d.ts +3 -2
- package/dist/cjs/serialization/resources/websockets/client/socket/WebsocketsSocketResponse.js +2 -0
- package/dist/cjs/serialization/resources/websockets/types/Subscribe.d.ts +4 -1
- package/dist/cjs/serialization/resources/websockets/types/Subscribe.js +4 -1
- package/dist/cjs/serialization/resources/websockets/types/Subscribed.d.ts +4 -1
- package/dist/cjs/serialization/resources/websockets/types/Subscribed.js +4 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/BaseClient.d.mts +14 -1
- package/dist/esm/BaseClient.mjs +24 -1
- package/dist/esm/Client.d.mts +30 -29
- package/dist/esm/Client.mjs +21 -29
- package/dist/esm/api/resources/apiKeys/client/Client.d.mts +12 -12
- package/dist/esm/api/resources/apiKeys/client/Client.mjs +28 -30
- package/dist/esm/api/resources/domains/client/Client.d.mts +19 -19
- package/dist/esm/api/resources/domains/client/Client.mjs +59 -52
- package/dist/esm/api/resources/drafts/client/Client.d.mts +10 -10
- package/dist/esm/api/resources/drafts/client/Client.mjs +22 -27
- package/dist/esm/api/resources/events/types/DomainVerifiedEvent.d.mts +7 -0
- package/dist/esm/api/resources/{webhooks → events}/types/EventType.d.mts +1 -0
- package/dist/esm/api/resources/{webhooks → events}/types/EventType.mjs +1 -0
- package/dist/esm/api/resources/events/types/EventTypes.d.mts +5 -0
- package/dist/esm/api/resources/events/types/EventTypes.mjs +2 -0
- package/dist/esm/api/resources/events/types/index.d.mts +3 -0
- package/dist/esm/api/resources/events/types/index.mjs +3 -0
- package/dist/esm/api/resources/inboxes/client/Client.d.mts +30 -30
- package/dist/esm/api/resources/inboxes/client/Client.mjs +58 -54
- package/dist/esm/api/resources/inboxes/resources/drafts/client/Client.d.mts +27 -27
- package/dist/esm/api/resources/inboxes/resources/drafts/client/Client.mjs +76 -69
- package/dist/esm/api/resources/inboxes/resources/messages/client/Client.d.mts +25 -25
- package/dist/esm/api/resources/inboxes/resources/messages/client/Client.mjs +82 -72
- package/dist/esm/api/resources/inboxes/resources/metrics/client/Client.d.mts +8 -8
- package/dist/esm/api/resources/inboxes/resources/metrics/client/Client.mjs +16 -24
- package/dist/esm/api/resources/inboxes/resources/threads/client/Client.d.mts +17 -17
- package/dist/esm/api/resources/inboxes/resources/threads/client/Client.mjs +50 -49
- package/dist/esm/api/resources/messages/types/Message.d.mts +4 -0
- package/dist/esm/api/resources/metrics/client/Client.d.mts +7 -7
- package/dist/esm/api/resources/metrics/client/Client.mjs +11 -19
- package/dist/esm/api/resources/pods/client/Client.d.mts +27 -27
- package/dist/esm/api/resources/pods/client/Client.mjs +47 -46
- package/dist/esm/api/resources/pods/resources/domains/client/Client.d.mts +15 -15
- package/dist/esm/api/resources/pods/resources/domains/client/Client.mjs +40 -42
- package/dist/esm/api/resources/pods/resources/drafts/client/Client.d.mts +12 -12
- package/dist/esm/api/resources/pods/resources/drafts/client/Client.mjs +29 -34
- package/dist/esm/api/resources/pods/resources/inboxes/client/Client.d.mts +19 -19
- package/dist/esm/api/resources/pods/resources/inboxes/client/Client.mjs +52 -51
- package/dist/esm/api/resources/pods/resources/threads/client/Client.d.mts +13 -13
- package/dist/esm/api/resources/pods/resources/threads/client/Client.mjs +38 -40
- package/dist/esm/api/resources/threads/client/Client.d.mts +11 -11
- package/dist/esm/api/resources/threads/client/Client.mjs +31 -33
- package/dist/esm/api/resources/webhooks/client/Client.d.mts +15 -15
- package/dist/esm/api/resources/webhooks/client/Client.mjs +39 -38
- package/dist/esm/api/resources/webhooks/types/CreateWebhookRequest.d.mts +1 -1
- package/dist/esm/api/resources/webhooks/types/Webhook.d.mts +1 -1
- package/dist/esm/api/resources/webhooks/types/index.d.mts +0 -2
- package/dist/esm/api/resources/webhooks/types/index.mjs +0 -2
- package/dist/esm/api/resources/websockets/client/Client.d.mts +6 -6
- package/dist/esm/api/resources/websockets/client/Client.mjs +7 -18
- package/dist/esm/api/resources/websockets/client/Socket.d.mts +1 -1
- package/dist/esm/api/resources/websockets/types/Subscribe.d.mts +5 -1
- package/dist/esm/api/resources/websockets/types/Subscribed.d.mts +5 -1
- package/dist/esm/auth/BearerAuthProvider.d.mts +14 -0
- package/dist/esm/auth/BearerAuthProvider.mjs +35 -0
- package/dist/esm/auth/index.d.mts +1 -0
- package/dist/esm/auth/index.mjs +1 -0
- package/dist/esm/core/auth/AuthProvider.d.mts +4 -1
- package/dist/esm/core/auth/BearerToken.d.mts +3 -1
- package/dist/esm/core/auth/BearerToken.mjs +7 -6
- package/dist/esm/core/auth/NoOpAuthProvider.d.mts +5 -0
- package/dist/esm/core/auth/NoOpAuthProvider.mjs +5 -0
- package/dist/esm/core/auth/index.d.mts +1 -0
- package/dist/esm/core/auth/index.mjs +1 -0
- package/dist/esm/core/exports.d.mts +1 -0
- package/dist/esm/core/exports.mjs +1 -0
- package/dist/esm/core/fetcher/Fetcher.d.mts +4 -1
- package/dist/esm/core/fetcher/Fetcher.mjs +202 -9
- package/dist/esm/core/fetcher/getRequestBody.d.mts +1 -1
- package/dist/esm/core/fetcher/getRequestBody.mjs +4 -0
- package/dist/esm/core/fetcher/makeRequest.d.mts +1 -1
- package/dist/esm/core/fetcher/makeRequest.mjs +0 -2
- package/dist/esm/core/fetcher/requestWithRetries.mjs +0 -9
- package/dist/esm/core/fetcher/signals.d.mts +0 -6
- package/dist/esm/core/fetcher/signals.mjs +0 -12
- package/dist/esm/core/headers.mjs +6 -4
- package/dist/esm/core/index.d.mts +1 -0
- package/dist/esm/core/index.mjs +1 -0
- package/dist/esm/core/logging/exports.d.mts +18 -0
- package/dist/esm/core/logging/exports.mjs +9 -0
- package/dist/esm/core/logging/index.d.mts +1 -0
- package/dist/esm/core/logging/index.mjs +1 -0
- package/dist/esm/core/logging/logger.d.mts +126 -0
- package/dist/esm/core/logging/logger.mjs +138 -0
- package/dist/esm/core/schemas/Schema.d.mts +1 -0
- package/dist/esm/core/schemas/Schema.mjs +1 -0
- package/dist/esm/core/schemas/builders/primitives/index.d.mts +1 -0
- package/dist/esm/core/schemas/builders/primitives/index.mjs +1 -0
- package/dist/esm/core/schemas/builders/primitives/never.d.mts +2 -0
- package/dist/esm/core/schemas/builders/primitives/never.mjs +11 -0
- package/dist/esm/core/url/join.mjs +0 -1
- package/dist/esm/serialization/resources/events/types/DomainVerifiedEvent.d.mts +14 -0
- package/dist/esm/serialization/resources/events/types/DomainVerifiedEvent.mjs +10 -0
- package/dist/esm/serialization/resources/{webhooks → events}/types/EventType.d.mts +2 -2
- package/dist/esm/serialization/resources/{webhooks → events}/types/EventType.mjs +1 -0
- package/dist/esm/serialization/resources/{webhooks → events}/types/EventTypes.d.mts +1 -1
- package/dist/esm/serialization/resources/events/types/index.d.mts +3 -0
- package/dist/esm/serialization/resources/events/types/index.mjs +3 -0
- package/dist/esm/serialization/resources/messages/types/Message.d.mts +2 -0
- package/dist/esm/serialization/resources/messages/types/Message.mjs +2 -0
- package/dist/esm/serialization/resources/webhooks/types/CreateWebhookRequest.d.mts +1 -1
- package/dist/esm/serialization/resources/webhooks/types/CreateWebhookRequest.mjs +1 -1
- package/dist/esm/serialization/resources/webhooks/types/Webhook.d.mts +1 -1
- package/dist/esm/serialization/resources/webhooks/types/Webhook.mjs +1 -1
- package/dist/esm/serialization/resources/webhooks/types/index.d.mts +0 -2
- package/dist/esm/serialization/resources/webhooks/types/index.mjs +0 -2
- package/dist/esm/serialization/resources/websockets/client/socket/WebsocketsSocketResponse.d.mts +3 -2
- package/dist/esm/serialization/resources/websockets/client/socket/WebsocketsSocketResponse.mjs +2 -0
- package/dist/esm/serialization/resources/websockets/types/Subscribe.d.mts +4 -1
- package/dist/esm/serialization/resources/websockets/types/Subscribe.mjs +4 -1
- package/dist/esm/serialization/resources/websockets/types/Subscribed.d.mts +4 -1
- package/dist/esm/serialization/resources/websockets/types/Subscribed.mjs +4 -1
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/dist/llms-full.txt +620 -54
- package/dist/llms.txt +6 -1
- package/package.json +1 -1
- package/reference.md +170 -170
- package/dist/cjs/api/resources/webhooks/types/EventTypes.d.ts +0 -5
- package/dist/esm/api/resources/webhooks/types/EventTypes.d.mts +0 -5
- /package/dist/cjs/api/resources/{webhooks/types/EventTypes.js → events/types/DomainVerifiedEvent.js} +0 -0
- /package/dist/cjs/serialization/resources/{webhooks → events}/types/EventTypes.js +0 -0
- /package/dist/esm/api/resources/{webhooks/types/EventTypes.mjs → events/types/DomainVerifiedEvent.mjs} +0 -0
- /package/dist/esm/serialization/resources/{webhooks → events}/types/EventTypes.mjs +0 -0
|
@@ -8,33 +8,34 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
import {
|
|
11
|
+
import { normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.mjs";
|
|
12
|
+
import { mergeHeaders } from "../../../../../../core/headers.mjs";
|
|
12
13
|
import * as core from "../../../../../../core/index.mjs";
|
|
13
14
|
import { toJson } from "../../../../../../core/json.mjs";
|
|
14
15
|
import * as environments from "../../../../../../environments.mjs";
|
|
15
16
|
import * as errors from "../../../../../../errors/index.mjs";
|
|
16
17
|
import * as serializers from "../../../../../../serialization/index.mjs";
|
|
17
18
|
import * as AgentMail from "../../../../../index.mjs";
|
|
18
|
-
export class
|
|
19
|
-
constructor(
|
|
20
|
-
this._options =
|
|
19
|
+
export class ThreadsClient {
|
|
20
|
+
constructor(options = {}) {
|
|
21
|
+
this._options = normalizeClientOptionsWithAuth(options);
|
|
21
22
|
}
|
|
22
23
|
/**
|
|
23
|
-
* @param {AgentMail.pods.PodId}
|
|
24
|
+
* @param {AgentMail.pods.PodId} pod_id
|
|
24
25
|
* @param {AgentMail.pods.ListThreadsRequest} request
|
|
25
|
-
* @param {
|
|
26
|
+
* @param {ThreadsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
26
27
|
*
|
|
27
28
|
* @throws {@link AgentMail.NotFoundError}
|
|
28
29
|
*
|
|
29
30
|
* @example
|
|
30
31
|
* await client.pods.threads.list("pod_id")
|
|
31
32
|
*/
|
|
32
|
-
list(
|
|
33
|
-
return core.HttpResponsePromise.fromPromise(this.__list(
|
|
33
|
+
list(pod_id, request = {}, requestOptions) {
|
|
34
|
+
return core.HttpResponsePromise.fromPromise(this.__list(pod_id, request, requestOptions));
|
|
34
35
|
}
|
|
35
|
-
__list(
|
|
36
|
-
return __awaiter(this, arguments, void 0, function* (
|
|
37
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
36
|
+
__list(pod_id_1) {
|
|
37
|
+
return __awaiter(this, arguments, void 0, function* (pod_id, request = {}, requestOptions) {
|
|
38
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
38
39
|
const { limit, pageToken, labels, before, after, ascending } = request;
|
|
39
40
|
const _queryParams = {};
|
|
40
41
|
if (limit != null) {
|
|
@@ -60,15 +61,18 @@ export class Threads {
|
|
|
60
61
|
if (ascending != null) {
|
|
61
62
|
_queryParams.ascending = ascending.toString();
|
|
62
63
|
}
|
|
63
|
-
const
|
|
64
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
65
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
64
66
|
const _response = yield core.fetcher({
|
|
65
|
-
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/pods/${core.url.encodePathParam(serializers.pods.PodId.jsonOrThrow(
|
|
67
|
+
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/pods/${core.url.encodePathParam(serializers.pods.PodId.jsonOrThrow(pod_id, { omitUndefined: true }))}/threads`),
|
|
66
68
|
method: "GET",
|
|
67
69
|
headers: _headers,
|
|
68
70
|
queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
|
|
69
71
|
timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
|
|
70
72
|
maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
|
|
71
73
|
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
74
|
+
fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
|
|
75
|
+
logging: this._options.logging,
|
|
72
76
|
});
|
|
73
77
|
if (_response.ok) {
|
|
74
78
|
return {
|
|
@@ -118,30 +122,33 @@ export class Threads {
|
|
|
118
122
|
});
|
|
119
123
|
}
|
|
120
124
|
/**
|
|
121
|
-
* @param {AgentMail.pods.PodId}
|
|
122
|
-
* @param {AgentMail.ThreadId}
|
|
123
|
-
* @param {
|
|
125
|
+
* @param {AgentMail.pods.PodId} pod_id
|
|
126
|
+
* @param {AgentMail.ThreadId} thread_id
|
|
127
|
+
* @param {ThreadsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
124
128
|
*
|
|
125
129
|
* @throws {@link AgentMail.NotFoundError}
|
|
126
130
|
*
|
|
127
131
|
* @example
|
|
128
132
|
* await client.pods.threads.get("pod_id", "thread_id")
|
|
129
133
|
*/
|
|
130
|
-
get(
|
|
131
|
-
return core.HttpResponsePromise.fromPromise(this.__get(
|
|
134
|
+
get(pod_id, thread_id, requestOptions) {
|
|
135
|
+
return core.HttpResponsePromise.fromPromise(this.__get(pod_id, thread_id, requestOptions));
|
|
132
136
|
}
|
|
133
|
-
__get(
|
|
137
|
+
__get(pod_id, thread_id, requestOptions) {
|
|
134
138
|
return __awaiter(this, void 0, void 0, function* () {
|
|
135
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
136
|
-
const
|
|
139
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
140
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
141
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
137
142
|
const _response = yield core.fetcher({
|
|
138
|
-
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/pods/${core.url.encodePathParam(serializers.pods.PodId.jsonOrThrow(
|
|
143
|
+
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/pods/${core.url.encodePathParam(serializers.pods.PodId.jsonOrThrow(pod_id, { omitUndefined: true }))}/threads/${core.url.encodePathParam(serializers.ThreadId.jsonOrThrow(thread_id, { omitUndefined: true }))}`),
|
|
139
144
|
method: "GET",
|
|
140
145
|
headers: _headers,
|
|
141
146
|
queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
|
|
142
147
|
timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
|
|
143
148
|
maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
|
|
144
149
|
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
150
|
+
fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
|
|
151
|
+
logging: this._options.logging,
|
|
145
152
|
});
|
|
146
153
|
if (_response.ok) {
|
|
147
154
|
return {
|
|
@@ -193,15 +200,16 @@ export class Threads {
|
|
|
193
200
|
/**
|
|
194
201
|
* @throws {@link AgentMail.NotFoundError}
|
|
195
202
|
*/
|
|
196
|
-
getAttachment(
|
|
197
|
-
return core.HttpResponsePromise.fromPromise(this.__getAttachment(
|
|
203
|
+
getAttachment(pod_id, thread_id, attachment_id, requestOptions) {
|
|
204
|
+
return core.HttpResponsePromise.fromPromise(this.__getAttachment(pod_id, thread_id, attachment_id, requestOptions));
|
|
198
205
|
}
|
|
199
|
-
__getAttachment(
|
|
206
|
+
__getAttachment(pod_id, thread_id, attachment_id, requestOptions) {
|
|
200
207
|
return __awaiter(this, void 0, void 0, function* () {
|
|
201
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
202
|
-
const
|
|
208
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
209
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
210
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
203
211
|
const _response = yield core.fetcher({
|
|
204
|
-
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/pods/${core.url.encodePathParam(serializers.pods.PodId.jsonOrThrow(
|
|
212
|
+
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/pods/${core.url.encodePathParam(serializers.pods.PodId.jsonOrThrow(pod_id, { omitUndefined: true }))}/threads/${core.url.encodePathParam(serializers.ThreadId.jsonOrThrow(thread_id, { omitUndefined: true }))}/attachments/${core.url.encodePathParam(serializers.AttachmentId.jsonOrThrow(attachment_id, { omitUndefined: true }))}`),
|
|
205
213
|
method: "GET",
|
|
206
214
|
headers: _headers,
|
|
207
215
|
queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
|
|
@@ -209,6 +217,8 @@ export class Threads {
|
|
|
209
217
|
timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
|
|
210
218
|
maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
|
|
211
219
|
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
220
|
+
fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
|
|
221
|
+
logging: this._options.logging,
|
|
212
222
|
});
|
|
213
223
|
if (_response.ok) {
|
|
214
224
|
return { data: _response.body, rawResponse: _response.rawResponse };
|
|
@@ -248,16 +258,4 @@ export class Threads {
|
|
|
248
258
|
}
|
|
249
259
|
});
|
|
250
260
|
}
|
|
251
|
-
_getAuthorizationHeader() {
|
|
252
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
253
|
-
var _a;
|
|
254
|
-
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;
|
|
255
|
-
if (bearer == null) {
|
|
256
|
-
throw new errors.AgentMailError({
|
|
257
|
-
message: "Please specify a bearer by either passing it in to the constructor or initializing a AGENTMAIL_API_KEY environment variable",
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
return `Bearer ${bearer}`;
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
261
|
}
|
|
@@ -1,41 +1,41 @@
|
|
|
1
1
|
import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.mjs";
|
|
2
|
+
import { type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.mjs";
|
|
2
3
|
import * as core from "../../../../core/index.mjs";
|
|
3
4
|
import * as AgentMail from "../../../index.mjs";
|
|
4
|
-
export declare namespace
|
|
5
|
+
export declare namespace ThreadsClient {
|
|
5
6
|
interface Options extends BaseClientOptions {
|
|
6
7
|
}
|
|
7
8
|
interface RequestOptions extends BaseRequestOptions {
|
|
8
9
|
}
|
|
9
10
|
}
|
|
10
|
-
export declare class
|
|
11
|
-
protected readonly _options:
|
|
12
|
-
constructor(
|
|
11
|
+
export declare class ThreadsClient {
|
|
12
|
+
protected readonly _options: NormalizedClientOptionsWithAuth<ThreadsClient.Options>;
|
|
13
|
+
constructor(options?: ThreadsClient.Options);
|
|
13
14
|
/**
|
|
14
15
|
* @param {AgentMail.ListThreadsRequest} request
|
|
15
|
-
* @param {
|
|
16
|
+
* @param {ThreadsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
16
17
|
*
|
|
17
18
|
* @throws {@link AgentMail.NotFoundError}
|
|
18
19
|
*
|
|
19
20
|
* @example
|
|
20
21
|
* await client.threads.list()
|
|
21
22
|
*/
|
|
22
|
-
list(request?: AgentMail.ListThreadsRequest, requestOptions?:
|
|
23
|
+
list(request?: AgentMail.ListThreadsRequest, requestOptions?: ThreadsClient.RequestOptions): core.HttpResponsePromise<AgentMail.ListThreadsResponse>;
|
|
23
24
|
private __list;
|
|
24
25
|
/**
|
|
25
|
-
* @param {AgentMail.ThreadId}
|
|
26
|
-
* @param {
|
|
26
|
+
* @param {AgentMail.ThreadId} thread_id
|
|
27
|
+
* @param {ThreadsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
27
28
|
*
|
|
28
29
|
* @throws {@link AgentMail.NotFoundError}
|
|
29
30
|
*
|
|
30
31
|
* @example
|
|
31
32
|
* await client.threads.get("thread_id")
|
|
32
33
|
*/
|
|
33
|
-
get(
|
|
34
|
+
get(thread_id: AgentMail.ThreadId, requestOptions?: ThreadsClient.RequestOptions): core.HttpResponsePromise<AgentMail.Thread>;
|
|
34
35
|
private __get;
|
|
35
36
|
/**
|
|
36
37
|
* @throws {@link AgentMail.NotFoundError}
|
|
37
38
|
*/
|
|
38
|
-
getAttachment(
|
|
39
|
+
getAttachment(thread_id: AgentMail.ThreadId, attachment_id: AgentMail.AttachmentId, requestOptions?: ThreadsClient.RequestOptions): core.HttpResponsePromise<core.BinaryResponse>;
|
|
39
40
|
private __getAttachment;
|
|
40
|
-
protected _getAuthorizationHeader(): Promise<string>;
|
|
41
41
|
}
|
|
@@ -8,20 +8,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
import {
|
|
11
|
+
import { normalizeClientOptionsWithAuth } from "../../../../BaseClient.mjs";
|
|
12
|
+
import { mergeHeaders } from "../../../../core/headers.mjs";
|
|
12
13
|
import * as core from "../../../../core/index.mjs";
|
|
13
14
|
import { toJson } from "../../../../core/json.mjs";
|
|
14
15
|
import * as environments from "../../../../environments.mjs";
|
|
15
16
|
import * as errors from "../../../../errors/index.mjs";
|
|
16
17
|
import * as serializers from "../../../../serialization/index.mjs";
|
|
17
18
|
import * as AgentMail from "../../../index.mjs";
|
|
18
|
-
export class
|
|
19
|
-
constructor(
|
|
20
|
-
this._options =
|
|
19
|
+
export class ThreadsClient {
|
|
20
|
+
constructor(options = {}) {
|
|
21
|
+
this._options = normalizeClientOptionsWithAuth(options);
|
|
21
22
|
}
|
|
22
23
|
/**
|
|
23
24
|
* @param {AgentMail.ListThreadsRequest} request
|
|
24
|
-
* @param {
|
|
25
|
+
* @param {ThreadsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
25
26
|
*
|
|
26
27
|
* @throws {@link AgentMail.NotFoundError}
|
|
27
28
|
*
|
|
@@ -33,7 +34,7 @@ export class Threads {
|
|
|
33
34
|
}
|
|
34
35
|
__list() {
|
|
35
36
|
return __awaiter(this, arguments, void 0, function* (request = {}, requestOptions) {
|
|
36
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
37
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
37
38
|
const { limit, pageToken, labels, before, after, ascending } = request;
|
|
38
39
|
const _queryParams = {};
|
|
39
40
|
if (limit != null) {
|
|
@@ -59,7 +60,8 @@ export class Threads {
|
|
|
59
60
|
if (ascending != null) {
|
|
60
61
|
_queryParams.ascending = ascending.toString();
|
|
61
62
|
}
|
|
62
|
-
const
|
|
63
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
64
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
63
65
|
const _response = yield core.fetcher({
|
|
64
66
|
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/threads"),
|
|
65
67
|
method: "GET",
|
|
@@ -68,6 +70,8 @@ export class Threads {
|
|
|
68
70
|
timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
|
|
69
71
|
maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
|
|
70
72
|
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
73
|
+
fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
|
|
74
|
+
logging: this._options.logging,
|
|
71
75
|
});
|
|
72
76
|
if (_response.ok) {
|
|
73
77
|
return {
|
|
@@ -117,29 +121,32 @@ export class Threads {
|
|
|
117
121
|
});
|
|
118
122
|
}
|
|
119
123
|
/**
|
|
120
|
-
* @param {AgentMail.ThreadId}
|
|
121
|
-
* @param {
|
|
124
|
+
* @param {AgentMail.ThreadId} thread_id
|
|
125
|
+
* @param {ThreadsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
122
126
|
*
|
|
123
127
|
* @throws {@link AgentMail.NotFoundError}
|
|
124
128
|
*
|
|
125
129
|
* @example
|
|
126
130
|
* await client.threads.get("thread_id")
|
|
127
131
|
*/
|
|
128
|
-
get(
|
|
129
|
-
return core.HttpResponsePromise.fromPromise(this.__get(
|
|
132
|
+
get(thread_id, requestOptions) {
|
|
133
|
+
return core.HttpResponsePromise.fromPromise(this.__get(thread_id, requestOptions));
|
|
130
134
|
}
|
|
131
|
-
__get(
|
|
135
|
+
__get(thread_id, requestOptions) {
|
|
132
136
|
return __awaiter(this, void 0, void 0, function* () {
|
|
133
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
134
|
-
const
|
|
137
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
138
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
139
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
135
140
|
const _response = yield core.fetcher({
|
|
136
|
-
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/threads/${core.url.encodePathParam(serializers.ThreadId.jsonOrThrow(
|
|
141
|
+
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/threads/${core.url.encodePathParam(serializers.ThreadId.jsonOrThrow(thread_id, { omitUndefined: true }))}`),
|
|
137
142
|
method: "GET",
|
|
138
143
|
headers: _headers,
|
|
139
144
|
queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
|
|
140
145
|
timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
|
|
141
146
|
maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
|
|
142
147
|
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
148
|
+
fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
|
|
149
|
+
logging: this._options.logging,
|
|
143
150
|
});
|
|
144
151
|
if (_response.ok) {
|
|
145
152
|
return {
|
|
@@ -191,15 +198,16 @@ export class Threads {
|
|
|
191
198
|
/**
|
|
192
199
|
* @throws {@link AgentMail.NotFoundError}
|
|
193
200
|
*/
|
|
194
|
-
getAttachment(
|
|
195
|
-
return core.HttpResponsePromise.fromPromise(this.__getAttachment(
|
|
201
|
+
getAttachment(thread_id, attachment_id, requestOptions) {
|
|
202
|
+
return core.HttpResponsePromise.fromPromise(this.__getAttachment(thread_id, attachment_id, requestOptions));
|
|
196
203
|
}
|
|
197
|
-
__getAttachment(
|
|
204
|
+
__getAttachment(thread_id, attachment_id, requestOptions) {
|
|
198
205
|
return __awaiter(this, void 0, void 0, function* () {
|
|
199
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
200
|
-
const
|
|
206
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
207
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
208
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
201
209
|
const _response = yield core.fetcher({
|
|
202
|
-
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/threads/${core.url.encodePathParam(serializers.ThreadId.jsonOrThrow(
|
|
210
|
+
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/threads/${core.url.encodePathParam(serializers.ThreadId.jsonOrThrow(thread_id, { omitUndefined: true }))}/attachments/${core.url.encodePathParam(serializers.AttachmentId.jsonOrThrow(attachment_id, { omitUndefined: true }))}`),
|
|
203
211
|
method: "GET",
|
|
204
212
|
headers: _headers,
|
|
205
213
|
queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
|
|
@@ -207,6 +215,8 @@ export class Threads {
|
|
|
207
215
|
timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
|
|
208
216
|
maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
|
|
209
217
|
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
218
|
+
fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
|
|
219
|
+
logging: this._options.logging,
|
|
210
220
|
});
|
|
211
221
|
if (_response.ok) {
|
|
212
222
|
return { data: _response.body, rawResponse: _response.rawResponse };
|
|
@@ -246,16 +256,4 @@ export class Threads {
|
|
|
246
256
|
}
|
|
247
257
|
});
|
|
248
258
|
}
|
|
249
|
-
_getAuthorizationHeader() {
|
|
250
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
251
|
-
var _a;
|
|
252
|
-
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;
|
|
253
|
-
if (bearer == null) {
|
|
254
|
-
throw new errors.AgentMailError({
|
|
255
|
-
message: "Please specify a bearer by either passing it in to the constructor or initializing a AGENTMAIL_API_KEY environment variable",
|
|
256
|
-
});
|
|
257
|
-
}
|
|
258
|
-
return `Bearer ${bearer}`;
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
259
|
}
|
|
@@ -1,38 +1,39 @@
|
|
|
1
1
|
import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.mjs";
|
|
2
|
+
import { type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.mjs";
|
|
2
3
|
import * as core from "../../../../core/index.mjs";
|
|
3
4
|
import * as AgentMail from "../../../index.mjs";
|
|
4
|
-
export declare namespace
|
|
5
|
+
export declare namespace WebhooksClient {
|
|
5
6
|
interface Options extends BaseClientOptions {
|
|
6
7
|
}
|
|
7
8
|
interface RequestOptions extends BaseRequestOptions {
|
|
8
9
|
}
|
|
9
10
|
}
|
|
10
|
-
export declare class
|
|
11
|
-
protected readonly _options:
|
|
12
|
-
constructor(
|
|
11
|
+
export declare class WebhooksClient {
|
|
12
|
+
protected readonly _options: NormalizedClientOptionsWithAuth<WebhooksClient.Options>;
|
|
13
|
+
constructor(options?: WebhooksClient.Options);
|
|
13
14
|
/**
|
|
14
15
|
* @param {AgentMail.webhooks.ListWebhooksRequest} request
|
|
15
|
-
* @param {
|
|
16
|
+
* @param {WebhooksClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
16
17
|
*
|
|
17
18
|
* @example
|
|
18
19
|
* await client.webhooks.list()
|
|
19
20
|
*/
|
|
20
|
-
list(request?: AgentMail.webhooks.ListWebhooksRequest, requestOptions?:
|
|
21
|
+
list(request?: AgentMail.webhooks.ListWebhooksRequest, requestOptions?: WebhooksClient.RequestOptions): core.HttpResponsePromise<AgentMail.webhooks.ListWebhooksResponse>;
|
|
21
22
|
private __list;
|
|
22
23
|
/**
|
|
23
|
-
* @param {AgentMail.webhooks.WebhookId}
|
|
24
|
-
* @param {
|
|
24
|
+
* @param {AgentMail.webhooks.WebhookId} webhook_id
|
|
25
|
+
* @param {WebhooksClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
25
26
|
*
|
|
26
27
|
* @throws {@link AgentMail.NotFoundError}
|
|
27
28
|
*
|
|
28
29
|
* @example
|
|
29
30
|
* await client.webhooks.get("webhook_id")
|
|
30
31
|
*/
|
|
31
|
-
get(
|
|
32
|
+
get(webhook_id: AgentMail.webhooks.WebhookId, requestOptions?: WebhooksClient.RequestOptions): core.HttpResponsePromise<AgentMail.webhooks.Webhook>;
|
|
32
33
|
private __get;
|
|
33
34
|
/**
|
|
34
35
|
* @param {AgentMail.webhooks.CreateWebhookRequest} request
|
|
35
|
-
* @param {
|
|
36
|
+
* @param {WebhooksClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
36
37
|
*
|
|
37
38
|
* @throws {@link AgentMail.ValidationError}
|
|
38
39
|
*
|
|
@@ -42,18 +43,17 @@ export declare class Webhooks {
|
|
|
42
43
|
* eventTypes: ["message.received", "message.received"]
|
|
43
44
|
* })
|
|
44
45
|
*/
|
|
45
|
-
create(request: AgentMail.webhooks.CreateWebhookRequest, requestOptions?:
|
|
46
|
+
create(request: AgentMail.webhooks.CreateWebhookRequest, requestOptions?: WebhooksClient.RequestOptions): core.HttpResponsePromise<AgentMail.webhooks.Webhook>;
|
|
46
47
|
private __create;
|
|
47
48
|
/**
|
|
48
|
-
* @param {AgentMail.webhooks.WebhookId}
|
|
49
|
-
* @param {
|
|
49
|
+
* @param {AgentMail.webhooks.WebhookId} webhook_id
|
|
50
|
+
* @param {WebhooksClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
50
51
|
*
|
|
51
52
|
* @throws {@link AgentMail.NotFoundError}
|
|
52
53
|
*
|
|
53
54
|
* @example
|
|
54
55
|
* await client.webhooks.delete("webhook_id")
|
|
55
56
|
*/
|
|
56
|
-
delete(
|
|
57
|
+
delete(webhook_id: AgentMail.webhooks.WebhookId, requestOptions?: WebhooksClient.RequestOptions): core.HttpResponsePromise<void>;
|
|
57
58
|
private __delete;
|
|
58
|
-
protected _getAuthorizationHeader(): Promise<string>;
|
|
59
59
|
}
|
|
@@ -8,19 +8,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
import {
|
|
11
|
+
import { normalizeClientOptionsWithAuth } from "../../../../BaseClient.mjs";
|
|
12
|
+
import { mergeHeaders } from "../../../../core/headers.mjs";
|
|
12
13
|
import * as core from "../../../../core/index.mjs";
|
|
13
14
|
import * as environments from "../../../../environments.mjs";
|
|
14
15
|
import * as errors from "../../../../errors/index.mjs";
|
|
15
16
|
import * as serializers from "../../../../serialization/index.mjs";
|
|
16
17
|
import * as AgentMail from "../../../index.mjs";
|
|
17
|
-
export class
|
|
18
|
-
constructor(
|
|
19
|
-
this._options =
|
|
18
|
+
export class WebhooksClient {
|
|
19
|
+
constructor(options = {}) {
|
|
20
|
+
this._options = normalizeClientOptionsWithAuth(options);
|
|
20
21
|
}
|
|
21
22
|
/**
|
|
22
23
|
* @param {AgentMail.webhooks.ListWebhooksRequest} request
|
|
23
|
-
* @param {
|
|
24
|
+
* @param {WebhooksClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
24
25
|
*
|
|
25
26
|
* @example
|
|
26
27
|
* await client.webhooks.list()
|
|
@@ -30,7 +31,7 @@ export class Webhooks {
|
|
|
30
31
|
}
|
|
31
32
|
__list() {
|
|
32
33
|
return __awaiter(this, arguments, void 0, function* (request = {}, requestOptions) {
|
|
33
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
34
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
34
35
|
const { limit, pageToken } = request;
|
|
35
36
|
const _queryParams = {};
|
|
36
37
|
if (limit != null) {
|
|
@@ -39,7 +40,8 @@ export class Webhooks {
|
|
|
39
40
|
if (pageToken != null) {
|
|
40
41
|
_queryParams.page_token = pageToken;
|
|
41
42
|
}
|
|
42
|
-
const
|
|
43
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
44
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
43
45
|
const _response = yield core.fetcher({
|
|
44
46
|
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/webhooks"),
|
|
45
47
|
method: "GET",
|
|
@@ -48,6 +50,8 @@ export class Webhooks {
|
|
|
48
50
|
timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
|
|
49
51
|
maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
|
|
50
52
|
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
53
|
+
fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
|
|
54
|
+
logging: this._options.logging,
|
|
51
55
|
});
|
|
52
56
|
if (_response.ok) {
|
|
53
57
|
return {
|
|
@@ -86,29 +90,32 @@ export class Webhooks {
|
|
|
86
90
|
});
|
|
87
91
|
}
|
|
88
92
|
/**
|
|
89
|
-
* @param {AgentMail.webhooks.WebhookId}
|
|
90
|
-
* @param {
|
|
93
|
+
* @param {AgentMail.webhooks.WebhookId} webhook_id
|
|
94
|
+
* @param {WebhooksClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
91
95
|
*
|
|
92
96
|
* @throws {@link AgentMail.NotFoundError}
|
|
93
97
|
*
|
|
94
98
|
* @example
|
|
95
99
|
* await client.webhooks.get("webhook_id")
|
|
96
100
|
*/
|
|
97
|
-
get(
|
|
98
|
-
return core.HttpResponsePromise.fromPromise(this.__get(
|
|
101
|
+
get(webhook_id, requestOptions) {
|
|
102
|
+
return core.HttpResponsePromise.fromPromise(this.__get(webhook_id, requestOptions));
|
|
99
103
|
}
|
|
100
|
-
__get(
|
|
104
|
+
__get(webhook_id, requestOptions) {
|
|
101
105
|
return __awaiter(this, void 0, void 0, function* () {
|
|
102
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
103
|
-
const
|
|
106
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
107
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
108
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
104
109
|
const _response = yield core.fetcher({
|
|
105
|
-
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/webhooks/${core.url.encodePathParam(serializers.webhooks.WebhookId.jsonOrThrow(
|
|
110
|
+
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/webhooks/${core.url.encodePathParam(serializers.webhooks.WebhookId.jsonOrThrow(webhook_id, { omitUndefined: true }))}`),
|
|
106
111
|
method: "GET",
|
|
107
112
|
headers: _headers,
|
|
108
113
|
queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
|
|
109
114
|
timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
|
|
110
115
|
maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
|
|
111
116
|
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
117
|
+
fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
|
|
118
|
+
logging: this._options.logging,
|
|
112
119
|
});
|
|
113
120
|
if (_response.ok) {
|
|
114
121
|
return {
|
|
@@ -159,7 +166,7 @@ export class Webhooks {
|
|
|
159
166
|
}
|
|
160
167
|
/**
|
|
161
168
|
* @param {AgentMail.webhooks.CreateWebhookRequest} request
|
|
162
|
-
* @param {
|
|
169
|
+
* @param {WebhooksClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
163
170
|
*
|
|
164
171
|
* @throws {@link AgentMail.ValidationError}
|
|
165
172
|
*
|
|
@@ -174,8 +181,9 @@ export class Webhooks {
|
|
|
174
181
|
}
|
|
175
182
|
__create(request, requestOptions) {
|
|
176
183
|
return __awaiter(this, void 0, void 0, function* () {
|
|
177
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
178
|
-
const
|
|
184
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
185
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
186
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
179
187
|
const _response = yield core.fetcher({
|
|
180
188
|
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/webhooks"),
|
|
181
189
|
method: "POST",
|
|
@@ -192,6 +200,8 @@ export class Webhooks {
|
|
|
192
200
|
timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
|
|
193
201
|
maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
|
|
194
202
|
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
203
|
+
fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
|
|
204
|
+
logging: this._options.logging,
|
|
195
205
|
});
|
|
196
206
|
if (_response.ok) {
|
|
197
207
|
return {
|
|
@@ -241,29 +251,32 @@ export class Webhooks {
|
|
|
241
251
|
});
|
|
242
252
|
}
|
|
243
253
|
/**
|
|
244
|
-
* @param {AgentMail.webhooks.WebhookId}
|
|
245
|
-
* @param {
|
|
254
|
+
* @param {AgentMail.webhooks.WebhookId} webhook_id
|
|
255
|
+
* @param {WebhooksClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
246
256
|
*
|
|
247
257
|
* @throws {@link AgentMail.NotFoundError}
|
|
248
258
|
*
|
|
249
259
|
* @example
|
|
250
260
|
* await client.webhooks.delete("webhook_id")
|
|
251
261
|
*/
|
|
252
|
-
delete(
|
|
253
|
-
return core.HttpResponsePromise.fromPromise(this.__delete(
|
|
262
|
+
delete(webhook_id, requestOptions) {
|
|
263
|
+
return core.HttpResponsePromise.fromPromise(this.__delete(webhook_id, requestOptions));
|
|
254
264
|
}
|
|
255
|
-
__delete(
|
|
265
|
+
__delete(webhook_id, requestOptions) {
|
|
256
266
|
return __awaiter(this, void 0, void 0, function* () {
|
|
257
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
258
|
-
const
|
|
267
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
268
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
269
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
259
270
|
const _response = yield core.fetcher({
|
|
260
|
-
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/webhooks/${core.url.encodePathParam(serializers.webhooks.WebhookId.jsonOrThrow(
|
|
271
|
+
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/webhooks/${core.url.encodePathParam(serializers.webhooks.WebhookId.jsonOrThrow(webhook_id, { omitUndefined: true }))}`),
|
|
261
272
|
method: "DELETE",
|
|
262
273
|
headers: _headers,
|
|
263
274
|
queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
|
|
264
275
|
timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
|
|
265
276
|
maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
|
|
266
277
|
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
278
|
+
fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
|
|
279
|
+
logging: this._options.logging,
|
|
267
280
|
});
|
|
268
281
|
if (_response.ok) {
|
|
269
282
|
return { data: undefined, rawResponse: _response.rawResponse };
|
|
@@ -303,16 +316,4 @@ export class Webhooks {
|
|
|
303
316
|
}
|
|
304
317
|
});
|
|
305
318
|
}
|
|
306
|
-
_getAuthorizationHeader() {
|
|
307
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
308
|
-
var _a;
|
|
309
|
-
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;
|
|
310
|
-
if (bearer == null) {
|
|
311
|
-
throw new errors.AgentMailError({
|
|
312
|
-
message: "Please specify a bearer by either passing it in to the constructor or initializing a AGENTMAIL_API_KEY environment variable",
|
|
313
|
-
});
|
|
314
|
-
}
|
|
315
|
-
return `Bearer ${bearer}`;
|
|
316
|
-
});
|
|
317
|
-
}
|
|
318
319
|
}
|