agentmail 0.1.5 → 0.1.7
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/domains/types/Domain.d.ts +1 -0
- package/dist/cjs/api/resources/domains/types/DomainItem.d.ts +1 -0
- 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/inboxes/types/Inbox.d.ts +1 -0
- package/dist/cjs/api/resources/messages/types/ReplyToMessageRequest.d.ts +1 -0
- package/dist/cjs/api/resources/messages/types/SendMessageHeaders.d.ts +4 -0
- package/dist/cjs/api/resources/messages/types/SendMessageHeaders.js +3 -0
- package/dist/cjs/api/resources/messages/types/SendMessageRequest.d.ts +1 -0
- package/dist/cjs/api/resources/messages/types/index.d.ts +1 -0
- package/dist/cjs/api/resources/messages/types/index.js +1 -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/domains/types/Domain.d.ts +2 -0
- package/dist/cjs/serialization/resources/domains/types/Domain.js +2 -0
- package/dist/cjs/serialization/resources/domains/types/DomainItem.d.ts +2 -0
- package/dist/cjs/serialization/resources/domains/types/DomainItem.js +2 -0
- 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/inboxes/types/Inbox.d.ts +2 -0
- package/dist/cjs/serialization/resources/inboxes/types/Inbox.js +2 -0
- package/dist/cjs/serialization/resources/messages/types/ReplyToMessageRequest.d.ts +2 -0
- package/dist/cjs/serialization/resources/messages/types/ReplyToMessageRequest.js +2 -0
- package/dist/cjs/serialization/resources/messages/types/SendMessageHeaders.d.ts +7 -0
- package/dist/cjs/serialization/resources/messages/types/SendMessageHeaders.js +39 -0
- package/dist/cjs/serialization/resources/messages/types/SendMessageRequest.d.ts +2 -0
- package/dist/cjs/serialization/resources/messages/types/SendMessageRequest.js +2 -0
- package/dist/cjs/serialization/resources/messages/types/index.d.ts +1 -0
- package/dist/cjs/serialization/resources/messages/types/index.js +1 -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/domains/types/Domain.d.mts +1 -0
- package/dist/esm/api/resources/domains/types/DomainItem.d.mts +1 -0
- 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/inboxes/types/Inbox.d.mts +1 -0
- package/dist/esm/api/resources/messages/types/ReplyToMessageRequest.d.mts +1 -0
- package/dist/esm/api/resources/messages/types/SendMessageHeaders.d.mts +4 -0
- package/dist/esm/api/resources/messages/types/SendMessageHeaders.mjs +2 -0
- package/dist/esm/api/resources/messages/types/SendMessageRequest.d.mts +1 -0
- package/dist/esm/api/resources/messages/types/index.d.mts +1 -0
- package/dist/esm/api/resources/messages/types/index.mjs +1 -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/domains/types/Domain.d.mts +2 -0
- package/dist/esm/serialization/resources/domains/types/Domain.mjs +2 -0
- package/dist/esm/serialization/resources/domains/types/DomainItem.d.mts +2 -0
- package/dist/esm/serialization/resources/domains/types/DomainItem.mjs +2 -0
- 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/inboxes/types/Inbox.d.mts +2 -0
- package/dist/esm/serialization/resources/inboxes/types/Inbox.mjs +2 -0
- package/dist/esm/serialization/resources/messages/types/ReplyToMessageRequest.d.mts +2 -0
- package/dist/esm/serialization/resources/messages/types/ReplyToMessageRequest.mjs +2 -0
- package/dist/esm/serialization/resources/messages/types/SendMessageHeaders.d.mts +7 -0
- package/dist/esm/serialization/resources/messages/types/SendMessageHeaders.mjs +3 -0
- package/dist/esm/serialization/resources/messages/types/SendMessageRequest.d.mts +2 -0
- package/dist/esm/serialization/resources/messages/types/SendMessageRequest.mjs +2 -0
- package/dist/esm/serialization/resources/messages/types/index.d.mts +1 -0
- package/dist/esm/serialization/resources/messages/types/index.mjs +1 -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 +1241 -123
- package/dist/llms.txt +7 -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
|
@@ -43,20 +43,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
43
43
|
});
|
|
44
44
|
};
|
|
45
45
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
-
exports.
|
|
46
|
+
exports.WebhooksClient = void 0;
|
|
47
|
+
const BaseClient_js_1 = require("../../../../BaseClient.js");
|
|
47
48
|
const headers_js_1 = require("../../../../core/headers.js");
|
|
48
49
|
const core = __importStar(require("../../../../core/index.js"));
|
|
49
50
|
const environments = __importStar(require("../../../../environments.js"));
|
|
50
51
|
const errors = __importStar(require("../../../../errors/index.js"));
|
|
51
52
|
const serializers = __importStar(require("../../../../serialization/index.js"));
|
|
52
53
|
const AgentMail = __importStar(require("../../../index.js"));
|
|
53
|
-
class
|
|
54
|
-
constructor(
|
|
55
|
-
this._options =
|
|
54
|
+
class WebhooksClient {
|
|
55
|
+
constructor(options = {}) {
|
|
56
|
+
this._options = (0, BaseClient_js_1.normalizeClientOptionsWithAuth)(options);
|
|
56
57
|
}
|
|
57
58
|
/**
|
|
58
59
|
* @param {AgentMail.webhooks.ListWebhooksRequest} request
|
|
59
|
-
* @param {
|
|
60
|
+
* @param {WebhooksClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
60
61
|
*
|
|
61
62
|
* @example
|
|
62
63
|
* await client.webhooks.list()
|
|
@@ -66,7 +67,7 @@ class Webhooks {
|
|
|
66
67
|
}
|
|
67
68
|
__list() {
|
|
68
69
|
return __awaiter(this, arguments, void 0, function* (request = {}, requestOptions) {
|
|
69
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
70
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
70
71
|
const { limit, pageToken } = request;
|
|
71
72
|
const _queryParams = {};
|
|
72
73
|
if (limit != null) {
|
|
@@ -75,7 +76,8 @@ class Webhooks {
|
|
|
75
76
|
if (pageToken != null) {
|
|
76
77
|
_queryParams.page_token = pageToken;
|
|
77
78
|
}
|
|
78
|
-
const
|
|
79
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
80
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
79
81
|
const _response = yield core.fetcher({
|
|
80
82
|
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"),
|
|
81
83
|
method: "GET",
|
|
@@ -84,6 +86,8 @@ class Webhooks {
|
|
|
84
86
|
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,
|
|
85
87
|
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,
|
|
86
88
|
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
89
|
+
fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
|
|
90
|
+
logging: this._options.logging,
|
|
87
91
|
});
|
|
88
92
|
if (_response.ok) {
|
|
89
93
|
return {
|
|
@@ -122,29 +126,32 @@ class Webhooks {
|
|
|
122
126
|
});
|
|
123
127
|
}
|
|
124
128
|
/**
|
|
125
|
-
* @param {AgentMail.webhooks.WebhookId}
|
|
126
|
-
* @param {
|
|
129
|
+
* @param {AgentMail.webhooks.WebhookId} webhook_id
|
|
130
|
+
* @param {WebhooksClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
127
131
|
*
|
|
128
132
|
* @throws {@link AgentMail.NotFoundError}
|
|
129
133
|
*
|
|
130
134
|
* @example
|
|
131
135
|
* await client.webhooks.get("webhook_id")
|
|
132
136
|
*/
|
|
133
|
-
get(
|
|
134
|
-
return core.HttpResponsePromise.fromPromise(this.__get(
|
|
137
|
+
get(webhook_id, requestOptions) {
|
|
138
|
+
return core.HttpResponsePromise.fromPromise(this.__get(webhook_id, requestOptions));
|
|
135
139
|
}
|
|
136
|
-
__get(
|
|
140
|
+
__get(webhook_id, requestOptions) {
|
|
137
141
|
return __awaiter(this, void 0, void 0, function* () {
|
|
138
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
139
|
-
const
|
|
142
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
143
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
144
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
140
145
|
const _response = yield core.fetcher({
|
|
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/webhooks/${core.url.encodePathParam(serializers.webhooks.WebhookId.jsonOrThrow(
|
|
146
|
+
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 }))}`),
|
|
142
147
|
method: "GET",
|
|
143
148
|
headers: _headers,
|
|
144
149
|
queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
|
|
145
150
|
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,
|
|
146
151
|
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,
|
|
147
152
|
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
153
|
+
fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
|
|
154
|
+
logging: this._options.logging,
|
|
148
155
|
});
|
|
149
156
|
if (_response.ok) {
|
|
150
157
|
return {
|
|
@@ -195,7 +202,7 @@ class Webhooks {
|
|
|
195
202
|
}
|
|
196
203
|
/**
|
|
197
204
|
* @param {AgentMail.webhooks.CreateWebhookRequest} request
|
|
198
|
-
* @param {
|
|
205
|
+
* @param {WebhooksClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
199
206
|
*
|
|
200
207
|
* @throws {@link AgentMail.ValidationError}
|
|
201
208
|
*
|
|
@@ -210,8 +217,9 @@ class Webhooks {
|
|
|
210
217
|
}
|
|
211
218
|
__create(request, requestOptions) {
|
|
212
219
|
return __awaiter(this, void 0, void 0, function* () {
|
|
213
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
214
|
-
const
|
|
220
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
221
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
222
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
215
223
|
const _response = yield core.fetcher({
|
|
216
224
|
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"),
|
|
217
225
|
method: "POST",
|
|
@@ -228,6 +236,8 @@ class Webhooks {
|
|
|
228
236
|
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,
|
|
229
237
|
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,
|
|
230
238
|
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
239
|
+
fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
|
|
240
|
+
logging: this._options.logging,
|
|
231
241
|
});
|
|
232
242
|
if (_response.ok) {
|
|
233
243
|
return {
|
|
@@ -277,29 +287,32 @@ class Webhooks {
|
|
|
277
287
|
});
|
|
278
288
|
}
|
|
279
289
|
/**
|
|
280
|
-
* @param {AgentMail.webhooks.WebhookId}
|
|
281
|
-
* @param {
|
|
290
|
+
* @param {AgentMail.webhooks.WebhookId} webhook_id
|
|
291
|
+
* @param {WebhooksClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
282
292
|
*
|
|
283
293
|
* @throws {@link AgentMail.NotFoundError}
|
|
284
294
|
*
|
|
285
295
|
* @example
|
|
286
296
|
* await client.webhooks.delete("webhook_id")
|
|
287
297
|
*/
|
|
288
|
-
delete(
|
|
289
|
-
return core.HttpResponsePromise.fromPromise(this.__delete(
|
|
298
|
+
delete(webhook_id, requestOptions) {
|
|
299
|
+
return core.HttpResponsePromise.fromPromise(this.__delete(webhook_id, requestOptions));
|
|
290
300
|
}
|
|
291
|
-
__delete(
|
|
301
|
+
__delete(webhook_id, requestOptions) {
|
|
292
302
|
return __awaiter(this, void 0, void 0, function* () {
|
|
293
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
294
|
-
const
|
|
303
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
304
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
305
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
295
306
|
const _response = yield core.fetcher({
|
|
296
|
-
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(
|
|
307
|
+
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 }))}`),
|
|
297
308
|
method: "DELETE",
|
|
298
309
|
headers: _headers,
|
|
299
310
|
queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
|
|
300
311
|
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,
|
|
301
312
|
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,
|
|
302
313
|
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
314
|
+
fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
|
|
315
|
+
logging: this._options.logging,
|
|
303
316
|
});
|
|
304
317
|
if (_response.ok) {
|
|
305
318
|
return { data: undefined, rawResponse: _response.rawResponse };
|
|
@@ -339,17 +352,5 @@ class Webhooks {
|
|
|
339
352
|
}
|
|
340
353
|
});
|
|
341
354
|
}
|
|
342
|
-
_getAuthorizationHeader() {
|
|
343
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
344
|
-
var _a;
|
|
345
|
-
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;
|
|
346
|
-
if (bearer == null) {
|
|
347
|
-
throw new errors.AgentMailError({
|
|
348
|
-
message: "Please specify a bearer by either passing it in to the constructor or initializing a AGENTMAIL_API_KEY environment variable",
|
|
349
|
-
});
|
|
350
|
-
}
|
|
351
|
-
return `Bearer ${bearer}`;
|
|
352
|
-
});
|
|
353
|
-
}
|
|
354
355
|
}
|
|
355
|
-
exports.
|
|
356
|
+
exports.WebhooksClient = WebhooksClient;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type * as AgentMail from "../../../index.js";
|
|
2
2
|
export interface CreateWebhookRequest {
|
|
3
3
|
url: AgentMail.webhooks.Url;
|
|
4
|
-
eventTypes: AgentMail.
|
|
4
|
+
eventTypes: AgentMail.EventTypes;
|
|
5
5
|
inboxIds?: AgentMail.webhooks.InboxIds;
|
|
6
6
|
clientId?: AgentMail.webhooks.ClientId;
|
|
7
7
|
}
|
|
@@ -2,7 +2,7 @@ import type * as AgentMail from "../../../index.js";
|
|
|
2
2
|
export interface Webhook {
|
|
3
3
|
webhookId: AgentMail.webhooks.WebhookId;
|
|
4
4
|
url: AgentMail.webhooks.Url;
|
|
5
|
-
eventTypes?: AgentMail.
|
|
5
|
+
eventTypes?: AgentMail.EventTypes;
|
|
6
6
|
inboxIds?: AgentMail.webhooks.InboxIds;
|
|
7
7
|
/** Secret for webhook signature verification. */
|
|
8
8
|
secret: string;
|
|
@@ -16,8 +16,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./ClientId.js"), exports);
|
|
18
18
|
__exportStar(require("./CreateWebhookRequest.js"), exports);
|
|
19
|
-
__exportStar(require("./EventType.js"), exports);
|
|
20
|
-
__exportStar(require("./EventTypes.js"), exports);
|
|
21
19
|
__exportStar(require("./InboxIds.js"), exports);
|
|
22
20
|
__exportStar(require("./ListWebhooksResponse.js"), exports);
|
|
23
21
|
__exportStar(require("./Url.js"), exports);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { BaseClientOptions } from "../../../../BaseClient.js";
|
|
2
|
+
import { type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.js";
|
|
2
3
|
import { WebsocketsSocket } from "./Socket.js";
|
|
3
|
-
export declare namespace
|
|
4
|
+
export declare namespace WebsocketsClient {
|
|
4
5
|
interface Options extends BaseClientOptions {
|
|
5
6
|
}
|
|
6
7
|
interface ConnectArgs {
|
|
@@ -13,9 +14,8 @@ export declare namespace Websockets {
|
|
|
13
14
|
reconnectAttempts?: number;
|
|
14
15
|
}
|
|
15
16
|
}
|
|
16
|
-
export declare class
|
|
17
|
-
protected readonly _options:
|
|
18
|
-
constructor(
|
|
19
|
-
connect(args?:
|
|
20
|
-
protected _getAuthorizationHeader(): Promise<string>;
|
|
17
|
+
export declare class WebsocketsClient {
|
|
18
|
+
protected readonly _options: NormalizedClientOptionsWithAuth<WebsocketsClient.Options>;
|
|
19
|
+
constructor(options?: WebsocketsClient.Options);
|
|
20
|
+
connect(args?: WebsocketsClient.ConnectArgs): Promise<WebsocketsSocket>;
|
|
21
21
|
}
|
|
@@ -43,15 +43,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
43
43
|
});
|
|
44
44
|
};
|
|
45
45
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
-
exports.
|
|
46
|
+
exports.WebsocketsClient = void 0;
|
|
47
|
+
const BaseClient_js_1 = require("../../../../BaseClient.js");
|
|
47
48
|
const headers_js_1 = require("../../../../core/headers.js");
|
|
48
49
|
const core = __importStar(require("../../../../core/index.js"));
|
|
49
50
|
const environments = __importStar(require("../../../../environments.js"));
|
|
50
|
-
const errors = __importStar(require("../../../../errors/index.js"));
|
|
51
51
|
const Socket_js_1 = require("./Socket.js");
|
|
52
|
-
class
|
|
53
|
-
constructor(
|
|
54
|
-
this._options =
|
|
52
|
+
class WebsocketsClient {
|
|
53
|
+
constructor(options = {}) {
|
|
54
|
+
this._options = (0, BaseClient_js_1.normalizeClientOptionsWithAuth)(options);
|
|
55
55
|
}
|
|
56
56
|
connect() {
|
|
57
57
|
return __awaiter(this, arguments, void 0, function* (args = {}) {
|
|
@@ -61,7 +61,8 @@ class Websockets {
|
|
|
61
61
|
if (authToken != null) {
|
|
62
62
|
_queryParams.auth_token = authToken;
|
|
63
63
|
}
|
|
64
|
-
const
|
|
64
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
65
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, headers);
|
|
65
66
|
const socket = new core.ReconnectingWebSocket({
|
|
66
67
|
url: core.url.join((_a = (yield core.Supplier.get(this._options.baseUrl))) !== null && _a !== void 0 ? _a : ((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.AgentMailEnvironment.Production).websockets, "/v0"),
|
|
67
68
|
protocols: [],
|
|
@@ -72,17 +73,5 @@ class Websockets {
|
|
|
72
73
|
return new Socket_js_1.WebsocketsSocket({ socket });
|
|
73
74
|
});
|
|
74
75
|
}
|
|
75
|
-
_getAuthorizationHeader() {
|
|
76
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
-
var _a;
|
|
78
|
-
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;
|
|
79
|
-
if (bearer == null) {
|
|
80
|
-
throw new errors.AgentMailError({
|
|
81
|
-
message: "Please specify a bearer by either passing it in to the constructor or initializing a AGENTMAIL_API_KEY environment variable",
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
return `Bearer ${bearer}`;
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
76
|
}
|
|
88
|
-
exports.
|
|
77
|
+
exports.WebsocketsClient = WebsocketsClient;
|
|
@@ -4,7 +4,7 @@ export declare namespace WebsocketsSocket {
|
|
|
4
4
|
interface Args {
|
|
5
5
|
socket: core.ReconnectingWebSocket;
|
|
6
6
|
}
|
|
7
|
-
type Response = AgentMail.Subscribed | AgentMail.MessageReceivedEvent | AgentMail.MessageSentEvent | AgentMail.MessageDeliveredEvent | AgentMail.MessageBouncedEvent | AgentMail.MessageComplainedEvent | AgentMail.MessageRejectedEvent;
|
|
7
|
+
type Response = AgentMail.Subscribed | AgentMail.MessageReceivedEvent | AgentMail.MessageSentEvent | AgentMail.MessageDeliveredEvent | AgentMail.MessageBouncedEvent | AgentMail.MessageComplainedEvent | AgentMail.MessageRejectedEvent | AgentMail.DomainVerifiedEvent;
|
|
8
8
|
type EventHandlers = {
|
|
9
9
|
open?: () => void;
|
|
10
10
|
message?: (message: Response) => void;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import type * as AgentMail from "../../../index.js";
|
|
1
2
|
export interface Subscribe {
|
|
2
3
|
type: "subscribe";
|
|
4
|
+
eventTypes?: AgentMail.EventTypes;
|
|
3
5
|
/** IDs of the inboxes to subscribe to. */
|
|
4
|
-
inboxIds
|
|
6
|
+
inboxIds?: string[];
|
|
7
|
+
/** IDs of the pods to subscribe to. */
|
|
8
|
+
podIds?: string[];
|
|
5
9
|
}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import type * as AgentMail from "../../../index.js";
|
|
1
2
|
export interface Subscribed {
|
|
2
3
|
type: "subscribed";
|
|
4
|
+
eventTypes?: AgentMail.EventTypes;
|
|
3
5
|
/** IDs of the inboxes that have been subscribed to. */
|
|
4
|
-
inboxIds
|
|
6
|
+
inboxIds?: string[];
|
|
7
|
+
/** IDs of the pods that have been subscribed to. */
|
|
8
|
+
podIds?: string[];
|
|
5
9
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as core from "../core/index.js";
|
|
2
|
+
export declare namespace BearerAuthProvider {
|
|
3
|
+
interface Options {
|
|
4
|
+
apiKey?: core.Supplier<core.BearerToken | undefined>;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
export declare class BearerAuthProvider implements core.AuthProvider {
|
|
8
|
+
private readonly token;
|
|
9
|
+
constructor(options: BearerAuthProvider.Options);
|
|
10
|
+
static canCreate(options: BearerAuthProvider.Options): boolean;
|
|
11
|
+
getAuthRequest(_arg?: {
|
|
12
|
+
endpointMetadata?: core.EndpointMetadata;
|
|
13
|
+
}): Promise<core.AuthRequest>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
37
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
38
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
39
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
40
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
41
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
42
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
+
exports.BearerAuthProvider = void 0;
|
|
47
|
+
const core = __importStar(require("../core/index.js"));
|
|
48
|
+
const errors = __importStar(require("../errors/index.js"));
|
|
49
|
+
class BearerAuthProvider {
|
|
50
|
+
constructor(options) {
|
|
51
|
+
this.token = options.apiKey;
|
|
52
|
+
}
|
|
53
|
+
static canCreate(options) {
|
|
54
|
+
var _a;
|
|
55
|
+
return options.apiKey != null || ((_a = process.env) === null || _a === void 0 ? void 0 : _a.AGENTMAIL_API_KEY) != null;
|
|
56
|
+
}
|
|
57
|
+
getAuthRequest(_arg) {
|
|
58
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
+
var _a, _b;
|
|
60
|
+
const apiKey = (_a = (yield core.Supplier.get(this.token))) !== null && _a !== void 0 ? _a : (_b = process.env) === null || _b === void 0 ? void 0 : _b.AGENTMAIL_API_KEY;
|
|
61
|
+
if (apiKey == null) {
|
|
62
|
+
throw new errors.AgentMailError({
|
|
63
|
+
message: "Please specify a apiKey by either passing it in to the constructor or initializing a AGENTMAIL_API_KEY environment variable",
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
headers: { Authorization: `Bearer ${apiKey}` },
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
exports.BearerAuthProvider = BearerAuthProvider;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { BearerAuthProvider } from "./BearerAuthProvider.js";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BearerAuthProvider = void 0;
|
|
4
|
+
var BearerAuthProvider_js_1 = require("./BearerAuthProvider.js");
|
|
5
|
+
Object.defineProperty(exports, "BearerAuthProvider", { enumerable: true, get: function () { return BearerAuthProvider_js_1.BearerAuthProvider; } });
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import type { EndpointMetadata } from "../fetcher/EndpointMetadata.js";
|
|
1
2
|
import type { AuthRequest } from "./AuthRequest.js";
|
|
2
3
|
export interface AuthProvider {
|
|
3
|
-
getAuthRequest(
|
|
4
|
+
getAuthRequest(arg?: {
|
|
5
|
+
endpointMetadata?: EndpointMetadata;
|
|
6
|
+
}): Promise<AuthRequest>;
|
|
4
7
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export type BearerToken = string;
|
|
2
|
+
declare function toAuthorizationHeader(token: string | undefined): string | undefined;
|
|
2
3
|
export declare const BearerToken: {
|
|
3
|
-
toAuthorizationHeader:
|
|
4
|
+
toAuthorizationHeader: typeof toAuthorizationHeader;
|
|
4
5
|
fromAuthorizationHeader: (header: string) => BearerToken;
|
|
5
6
|
};
|
|
7
|
+
export {};
|
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BearerToken = void 0;
|
|
4
4
|
const BEARER_AUTH_HEADER_PREFIX = /^Bearer /i;
|
|
5
|
+
function toAuthorizationHeader(token) {
|
|
6
|
+
if (token == null) {
|
|
7
|
+
return undefined;
|
|
8
|
+
}
|
|
9
|
+
return `Bearer ${token}`;
|
|
10
|
+
}
|
|
5
11
|
exports.BearerToken = {
|
|
6
|
-
toAuthorizationHeader:
|
|
7
|
-
if (token == null) {
|
|
8
|
-
return undefined;
|
|
9
|
-
}
|
|
10
|
-
return `Bearer ${token}`;
|
|
11
|
-
},
|
|
12
|
+
toAuthorizationHeader: toAuthorizationHeader,
|
|
12
13
|
fromAuthorizationHeader: (header) => {
|
|
13
14
|
return header.replace(BEARER_AUTH_HEADER_PREFIX, "").trim();
|
|
14
15
|
},
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BearerToken = exports.BasicAuth = void 0;
|
|
3
|
+
exports.NoOpAuthProvider = exports.BearerToken = exports.BasicAuth = void 0;
|
|
4
4
|
var BasicAuth_js_1 = require("./BasicAuth.js");
|
|
5
5
|
Object.defineProperty(exports, "BasicAuth", { enumerable: true, get: function () { return BasicAuth_js_1.BasicAuth; } });
|
|
6
6
|
var BearerToken_js_1 = require("./BearerToken.js");
|
|
7
7
|
Object.defineProperty(exports, "BearerToken", { enumerable: true, get: function () { return BearerToken_js_1.BearerToken; } });
|
|
8
|
+
var NoOpAuthProvider_js_1 = require("./NoOpAuthProvider.js");
|
|
9
|
+
Object.defineProperty(exports, "NoOpAuthProvider", { enumerable: true, get: function () { return NoOpAuthProvider_js_1.NoOpAuthProvider; } });
|
package/dist/cjs/core/exports.js
CHANGED
|
@@ -14,4 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./logging/exports.js"), exports);
|
|
17
18
|
__exportStar(require("./websocket/exports.js"), exports);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type LogConfig, type Logger } from "../logging/logger.js";
|
|
1
2
|
import type { APIResponse } from "./APIResponse.js";
|
|
2
3
|
import type { EndpointMetadata } from "./EndpointMetadata.js";
|
|
3
4
|
import { EndpointSupplier } from "./EndpointSupplier.js";
|
|
@@ -14,10 +15,12 @@ export declare namespace Fetcher {
|
|
|
14
15
|
maxRetries?: number;
|
|
15
16
|
withCredentials?: boolean;
|
|
16
17
|
abortSignal?: AbortSignal;
|
|
17
|
-
requestType?: "json" | "file" | "bytes";
|
|
18
|
+
requestType?: "json" | "file" | "bytes" | "form" | "other";
|
|
18
19
|
responseType?: "json" | "blob" | "sse" | "streaming" | "text" | "arrayBuffer" | "binary-response";
|
|
19
20
|
duplex?: "half";
|
|
20
21
|
endpointMetadata?: EndpointMetadata;
|
|
22
|
+
fetchFn?: typeof fetch;
|
|
23
|
+
logging?: LogConfig | Logger;
|
|
21
24
|
}
|
|
22
25
|
type Error = FailedStatusCodeError | NonJsonError | TimeoutError | UnknownError;
|
|
23
26
|
interface FailedStatusCodeError {
|