agentmail 0.4.13 → 0.4.15
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 +46 -14
- package/dist/cjs/BaseClient.js +2 -2
- package/dist/cjs/Client.d.ts +12 -0
- package/dist/cjs/Client.js +74 -0
- package/dist/cjs/api/errors/UnprocessableError.d.ts +6 -0
- package/dist/cjs/api/errors/UnprocessableError.js +54 -0
- package/dist/cjs/api/errors/index.d.ts +1 -0
- package/dist/cjs/api/errors/index.js +1 -0
- package/dist/cjs/api/resources/agent/exports.d.ts +2 -0
- package/dist/cjs/api/resources/agent/exports.js +21 -0
- package/dist/cjs/api/resources/apiKeys/exports.d.ts +2 -0
- package/dist/cjs/api/resources/apiKeys/exports.js +21 -0
- package/dist/cjs/api/resources/attachments/exports.d.ts +1 -0
- package/dist/cjs/api/resources/attachments/exports.js +18 -0
- package/dist/cjs/api/resources/domains/exports.d.ts +2 -0
- package/dist/cjs/api/resources/domains/exports.js +21 -0
- package/dist/cjs/api/resources/drafts/exports.d.ts +2 -0
- package/dist/cjs/api/resources/drafts/exports.js +21 -0
- package/dist/cjs/api/resources/events/exports.d.ts +1 -0
- package/dist/cjs/api/resources/events/exports.js +18 -0
- package/dist/cjs/api/resources/inboxes/exports.d.ts +3 -0
- package/dist/cjs/api/resources/inboxes/exports.js +22 -0
- package/dist/cjs/api/resources/inboxes/resources/apiKeys/exports.d.ts +2 -0
- package/dist/cjs/api/resources/inboxes/resources/apiKeys/exports.js +21 -0
- package/dist/cjs/api/resources/inboxes/resources/drafts/exports.d.ts +2 -0
- package/dist/cjs/api/resources/inboxes/resources/drafts/exports.js +21 -0
- package/dist/cjs/api/resources/inboxes/resources/lists/exports.d.ts +2 -0
- package/dist/cjs/api/resources/inboxes/resources/lists/exports.js +21 -0
- package/dist/cjs/api/resources/inboxes/resources/messages/client/Client.d.ts +1 -1
- package/dist/cjs/api/resources/inboxes/resources/messages/client/Client.js +1 -1
- package/dist/cjs/api/resources/inboxes/resources/messages/exports.d.ts +2 -0
- package/dist/cjs/api/resources/inboxes/resources/messages/exports.js +21 -0
- package/dist/cjs/api/resources/inboxes/resources/metrics/exports.d.ts +2 -0
- package/dist/cjs/api/resources/inboxes/resources/metrics/exports.js +21 -0
- package/dist/cjs/api/resources/inboxes/resources/threads/client/Client.d.ts +17 -0
- package/dist/cjs/api/resources/inboxes/resources/threads/client/Client.js +90 -0
- package/dist/cjs/api/resources/inboxes/resources/threads/exports.d.ts +2 -0
- package/dist/cjs/api/resources/inboxes/resources/threads/exports.js +21 -0
- package/dist/cjs/api/resources/lists/exports.d.ts +2 -0
- package/dist/cjs/api/resources/lists/exports.js +21 -0
- package/dist/cjs/api/resources/messages/exports.d.ts +1 -0
- package/dist/cjs/api/resources/messages/exports.js +18 -0
- package/dist/cjs/api/resources/messages/types/UpdateMessageResponse.d.ts +5 -0
- package/dist/cjs/api/resources/messages/types/UpdateMessageResponse.js +3 -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/exports.d.ts +2 -0
- package/dist/cjs/api/resources/metrics/exports.js +21 -0
- package/dist/cjs/api/resources/metrics/types/QueryMetricsResponse.d.ts +1 -1
- package/dist/cjs/api/resources/organizations/exports.d.ts +2 -0
- package/dist/cjs/api/resources/organizations/exports.js +21 -0
- package/dist/cjs/api/resources/pods/exports.d.ts +3 -0
- package/dist/cjs/api/resources/pods/exports.js +22 -0
- package/dist/cjs/api/resources/pods/resources/apiKeys/exports.d.ts +2 -0
- package/dist/cjs/api/resources/pods/resources/apiKeys/exports.js +21 -0
- package/dist/cjs/api/resources/pods/resources/domains/exports.d.ts +2 -0
- package/dist/cjs/api/resources/pods/resources/domains/exports.js +21 -0
- package/dist/cjs/api/resources/pods/resources/drafts/exports.d.ts +2 -0
- package/dist/cjs/api/resources/pods/resources/drafts/exports.js +21 -0
- package/dist/cjs/api/resources/pods/resources/inboxes/exports.d.ts +2 -0
- package/dist/cjs/api/resources/pods/resources/inboxes/exports.js +21 -0
- package/dist/cjs/api/resources/pods/resources/lists/exports.d.ts +2 -0
- package/dist/cjs/api/resources/pods/resources/lists/exports.js +21 -0
- package/dist/cjs/api/resources/pods/resources/metrics/exports.d.ts +2 -0
- package/dist/cjs/api/resources/pods/resources/metrics/exports.js +21 -0
- package/dist/cjs/api/resources/pods/resources/threads/client/Client.d.ts +17 -0
- package/dist/cjs/api/resources/pods/resources/threads/client/Client.js +90 -0
- package/dist/cjs/api/resources/pods/resources/threads/exports.d.ts +2 -0
- package/dist/cjs/api/resources/pods/resources/threads/exports.js +21 -0
- package/dist/cjs/api/resources/threads/client/Client.d.ts +16 -0
- package/dist/cjs/api/resources/threads/client/Client.js +89 -0
- package/dist/cjs/api/resources/threads/exports.d.ts +2 -0
- package/dist/cjs/api/resources/threads/exports.js +21 -0
- package/dist/cjs/api/resources/threads/types/UpdateThreadRequest.d.ts +6 -0
- package/dist/cjs/api/resources/threads/types/UpdateThreadRequest.js +3 -0
- package/dist/cjs/api/resources/threads/types/UpdateThreadResponse.d.ts +5 -0
- package/dist/cjs/api/resources/threads/types/UpdateThreadResponse.js +3 -0
- package/dist/cjs/api/resources/threads/types/index.d.ts +2 -0
- package/dist/cjs/api/resources/threads/types/index.js +2 -0
- package/dist/cjs/api/resources/webhooks/exports.d.ts +3 -0
- package/dist/cjs/api/resources/webhooks/exports.js +22 -0
- package/dist/cjs/api/resources/webhooks/resources/events/exports.d.ts +1 -0
- package/dist/cjs/api/resources/webhooks/resources/events/exports.js +18 -0
- package/dist/cjs/api/resources/websockets/client/Client.d.ts +6 -0
- package/dist/cjs/api/resources/websockets/client/Client.js +8 -3
- package/dist/cjs/api/resources/websockets/client/Socket.d.ts +2 -2
- package/dist/cjs/api/resources/websockets/client/Socket.js +2 -2
- package/dist/cjs/api/resources/websockets/exports.d.ts +3 -0
- package/dist/cjs/api/resources/websockets/exports.js +23 -0
- package/dist/cjs/core/fetcher/BinaryResponse.d.ts +1 -1
- package/dist/cjs/core/fetcher/Fetcher.js +8 -2
- package/dist/cjs/core/fetcher/index.d.ts +2 -0
- package/dist/cjs/core/fetcher/index.js +3 -1
- package/dist/cjs/core/fetcher/makePassthroughRequest.d.ts +49 -0
- package/dist/cjs/core/fetcher/makePassthroughRequest.js +135 -0
- package/dist/cjs/core/fetcher/makeRequest.d.ts +6 -1
- package/dist/cjs/core/fetcher/makeRequest.js +30 -9
- package/dist/cjs/core/runtime/runtime.js +8 -7
- package/dist/cjs/core/schemas/builders/list/list.js +12 -17
- package/dist/cjs/core/schemas/builders/object/object.js +102 -40
- package/dist/cjs/core/schemas/builders/object-like/getObjectLikeUtils.js +10 -3
- package/dist/cjs/core/schemas/builders/record/index.d.ts +2 -2
- package/dist/cjs/core/schemas/builders/record/index.js +2 -1
- package/dist/cjs/core/schemas/builders/record/record.d.ts +2 -1
- package/dist/cjs/core/schemas/builders/record/record.js +63 -25
- package/dist/cjs/core/schemas/builders/record/types.d.ts +2 -0
- package/dist/cjs/core/schemas/builders/union/union.js +9 -12
- package/dist/cjs/core/schemas/utils/isPlainObject.js +4 -6
- package/dist/cjs/core/websocket/ws.d.ts +14 -2
- package/dist/cjs/core/websocket/ws.js +51 -7
- package/dist/cjs/serialization/resources/messages/types/UpdateMessageResponse.d.ts +12 -0
- package/dist/cjs/serialization/resources/messages/types/UpdateMessageResponse.js +44 -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/metrics/types/QueryMetricsResponse.js +1 -1
- package/dist/cjs/serialization/resources/threads/types/UpdateThreadRequest.d.ts +10 -0
- package/dist/cjs/serialization/resources/threads/types/UpdateThreadRequest.js +42 -0
- package/dist/cjs/serialization/resources/threads/types/UpdateThreadResponse.d.ts +12 -0
- package/dist/cjs/serialization/resources/threads/types/UpdateThreadResponse.js +44 -0
- package/dist/cjs/serialization/resources/threads/types/index.d.ts +2 -0
- package/dist/cjs/serialization/resources/threads/types/index.js +2 -0
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/BaseClient.mjs +2 -2
- package/dist/esm/Client.d.mts +12 -0
- package/dist/esm/Client.mjs +41 -0
- package/dist/esm/api/errors/UnprocessableError.d.mts +6 -0
- package/dist/esm/api/errors/UnprocessableError.mjs +17 -0
- package/dist/esm/api/errors/index.d.mts +1 -0
- package/dist/esm/api/errors/index.mjs +1 -0
- package/dist/esm/api/resources/agent/exports.d.mts +2 -0
- package/dist/esm/api/resources/agent/exports.mjs +3 -0
- package/dist/esm/api/resources/apiKeys/exports.d.mts +2 -0
- package/dist/esm/api/resources/apiKeys/exports.mjs +3 -0
- package/dist/esm/api/resources/attachments/exports.d.mts +1 -0
- package/dist/esm/api/resources/attachments/exports.mjs +2 -0
- package/dist/esm/api/resources/domains/exports.d.mts +2 -0
- package/dist/esm/api/resources/domains/exports.mjs +3 -0
- package/dist/esm/api/resources/drafts/exports.d.mts +2 -0
- package/dist/esm/api/resources/drafts/exports.mjs +3 -0
- package/dist/esm/api/resources/events/exports.d.mts +1 -0
- package/dist/esm/api/resources/events/exports.mjs +2 -0
- package/dist/esm/api/resources/inboxes/exports.d.mts +3 -0
- package/dist/esm/api/resources/inboxes/exports.mjs +4 -0
- package/dist/esm/api/resources/inboxes/resources/apiKeys/exports.d.mts +2 -0
- package/dist/esm/api/resources/inboxes/resources/apiKeys/exports.mjs +3 -0
- package/dist/esm/api/resources/inboxes/resources/drafts/exports.d.mts +2 -0
- package/dist/esm/api/resources/inboxes/resources/drafts/exports.mjs +3 -0
- package/dist/esm/api/resources/inboxes/resources/lists/exports.d.mts +2 -0
- package/dist/esm/api/resources/inboxes/resources/lists/exports.mjs +3 -0
- package/dist/esm/api/resources/inboxes/resources/messages/client/Client.d.mts +1 -1
- package/dist/esm/api/resources/inboxes/resources/messages/client/Client.mjs +1 -1
- package/dist/esm/api/resources/inboxes/resources/messages/exports.d.mts +2 -0
- package/dist/esm/api/resources/inboxes/resources/messages/exports.mjs +3 -0
- package/dist/esm/api/resources/inboxes/resources/metrics/exports.d.mts +2 -0
- package/dist/esm/api/resources/inboxes/resources/metrics/exports.mjs +3 -0
- package/dist/esm/api/resources/inboxes/resources/threads/client/Client.d.mts +17 -0
- package/dist/esm/api/resources/inboxes/resources/threads/client/Client.mjs +90 -0
- package/dist/esm/api/resources/inboxes/resources/threads/exports.d.mts +2 -0
- package/dist/esm/api/resources/inboxes/resources/threads/exports.mjs +3 -0
- package/dist/esm/api/resources/lists/exports.d.mts +2 -0
- package/dist/esm/api/resources/lists/exports.mjs +3 -0
- package/dist/esm/api/resources/messages/exports.d.mts +1 -0
- package/dist/esm/api/resources/messages/exports.mjs +2 -0
- package/dist/esm/api/resources/messages/types/UpdateMessageResponse.d.mts +5 -0
- package/dist/esm/api/resources/messages/types/UpdateMessageResponse.mjs +2 -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/exports.d.mts +2 -0
- package/dist/esm/api/resources/metrics/exports.mjs +3 -0
- package/dist/esm/api/resources/metrics/types/QueryMetricsResponse.d.mts +1 -1
- package/dist/esm/api/resources/organizations/exports.d.mts +2 -0
- package/dist/esm/api/resources/organizations/exports.mjs +3 -0
- package/dist/esm/api/resources/pods/exports.d.mts +3 -0
- package/dist/esm/api/resources/pods/exports.mjs +4 -0
- package/dist/esm/api/resources/pods/resources/apiKeys/exports.d.mts +2 -0
- package/dist/esm/api/resources/pods/resources/apiKeys/exports.mjs +3 -0
- package/dist/esm/api/resources/pods/resources/domains/exports.d.mts +2 -0
- package/dist/esm/api/resources/pods/resources/domains/exports.mjs +3 -0
- package/dist/esm/api/resources/pods/resources/drafts/exports.d.mts +2 -0
- package/dist/esm/api/resources/pods/resources/drafts/exports.mjs +3 -0
- package/dist/esm/api/resources/pods/resources/inboxes/exports.d.mts +2 -0
- package/dist/esm/api/resources/pods/resources/inboxes/exports.mjs +3 -0
- package/dist/esm/api/resources/pods/resources/lists/exports.d.mts +2 -0
- package/dist/esm/api/resources/pods/resources/lists/exports.mjs +3 -0
- package/dist/esm/api/resources/pods/resources/metrics/exports.d.mts +2 -0
- package/dist/esm/api/resources/pods/resources/metrics/exports.mjs +3 -0
- package/dist/esm/api/resources/pods/resources/threads/client/Client.d.mts +17 -0
- package/dist/esm/api/resources/pods/resources/threads/client/Client.mjs +90 -0
- package/dist/esm/api/resources/pods/resources/threads/exports.d.mts +2 -0
- package/dist/esm/api/resources/pods/resources/threads/exports.mjs +3 -0
- package/dist/esm/api/resources/threads/client/Client.d.mts +16 -0
- package/dist/esm/api/resources/threads/client/Client.mjs +89 -0
- package/dist/esm/api/resources/threads/exports.d.mts +2 -0
- package/dist/esm/api/resources/threads/exports.mjs +3 -0
- package/dist/esm/api/resources/threads/types/UpdateThreadRequest.d.mts +6 -0
- package/dist/esm/api/resources/threads/types/UpdateThreadRequest.mjs +2 -0
- package/dist/esm/api/resources/threads/types/UpdateThreadResponse.d.mts +5 -0
- package/dist/esm/api/resources/threads/types/UpdateThreadResponse.mjs +2 -0
- package/dist/esm/api/resources/threads/types/index.d.mts +2 -0
- package/dist/esm/api/resources/threads/types/index.mjs +2 -0
- package/dist/esm/api/resources/webhooks/exports.d.mts +3 -0
- package/dist/esm/api/resources/webhooks/exports.mjs +4 -0
- package/dist/esm/api/resources/webhooks/resources/events/exports.d.mts +1 -0
- package/dist/esm/api/resources/webhooks/resources/events/exports.mjs +2 -0
- package/dist/esm/api/resources/websockets/client/Client.d.mts +6 -0
- package/dist/esm/api/resources/websockets/client/Client.mjs +8 -3
- package/dist/esm/api/resources/websockets/client/Socket.d.mts +2 -2
- package/dist/esm/api/resources/websockets/client/Socket.mjs +2 -2
- package/dist/esm/api/resources/websockets/exports.d.mts +3 -0
- package/dist/esm/api/resources/websockets/exports.mjs +4 -0
- package/dist/esm/core/fetcher/BinaryResponse.d.mts +1 -1
- package/dist/esm/core/fetcher/Fetcher.mjs +8 -2
- package/dist/esm/core/fetcher/index.d.mts +2 -0
- package/dist/esm/core/fetcher/index.mjs +1 -0
- package/dist/esm/core/fetcher/makePassthroughRequest.d.mts +49 -0
- package/dist/esm/core/fetcher/makePassthroughRequest.mjs +132 -0
- package/dist/esm/core/fetcher/makeRequest.d.mts +6 -1
- package/dist/esm/core/fetcher/makeRequest.mjs +28 -9
- package/dist/esm/core/runtime/runtime.mjs +8 -7
- package/dist/esm/core/schemas/builders/list/list.mjs +12 -17
- package/dist/esm/core/schemas/builders/object/object.mjs +102 -40
- package/dist/esm/core/schemas/builders/object-like/getObjectLikeUtils.mjs +10 -3
- package/dist/esm/core/schemas/builders/record/index.d.mts +2 -2
- package/dist/esm/core/schemas/builders/record/index.mjs +1 -1
- package/dist/esm/core/schemas/builders/record/record.d.mts +2 -1
- package/dist/esm/core/schemas/builders/record/record.mjs +62 -25
- package/dist/esm/core/schemas/builders/record/types.d.mts +2 -0
- package/dist/esm/core/schemas/builders/union/union.mjs +9 -12
- package/dist/esm/core/schemas/utils/isPlainObject.mjs +4 -6
- package/dist/esm/core/websocket/ws.d.mts +14 -2
- package/dist/esm/core/websocket/ws.mjs +51 -7
- package/dist/esm/serialization/resources/messages/types/UpdateMessageResponse.d.mts +12 -0
- package/dist/esm/serialization/resources/messages/types/UpdateMessageResponse.mjs +8 -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/metrics/types/QueryMetricsResponse.mjs +1 -1
- package/dist/esm/serialization/resources/threads/types/UpdateThreadRequest.d.mts +10 -0
- package/dist/esm/serialization/resources/threads/types/UpdateThreadRequest.mjs +6 -0
- package/dist/esm/serialization/resources/threads/types/UpdateThreadResponse.d.mts +12 -0
- package/dist/esm/serialization/resources/threads/types/UpdateThreadResponse.mjs +8 -0
- package/dist/esm/serialization/resources/threads/types/index.d.mts +2 -0
- package/dist/esm/serialization/resources/threads/types/index.mjs +2 -0
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +305 -13
- package/reference.md +231 -1
|
@@ -0,0 +1,21 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
15
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
16
|
+
};
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.ThreadsClient = void 0;
|
|
19
|
+
var Client_js_1 = require("./client/Client.js");
|
|
20
|
+
Object.defineProperty(exports, "ThreadsClient", { enumerable: true, get: function () { return Client_js_1.ThreadsClient; } });
|
|
21
|
+
__exportStar(require("./client/index.js"), exports);
|
|
@@ -44,6 +44,22 @@ export declare class ThreadsClient {
|
|
|
44
44
|
*/
|
|
45
45
|
getAttachment(thread_id: AgentMail.ThreadId, attachment_id: AgentMail.AttachmentId, requestOptions?: ThreadsClient.RequestOptions): core.HttpResponsePromise<AgentMail.AttachmentResponse>;
|
|
46
46
|
private __getAttachment;
|
|
47
|
+
/**
|
|
48
|
+
* Updates thread labels. Cannot add or remove system labels (sent, received, bounced, etc.). Rejects requests with a `422` for threads with 100 or more messages.
|
|
49
|
+
*
|
|
50
|
+
* @param {AgentMail.ThreadId} thread_id
|
|
51
|
+
* @param {AgentMail.UpdateThreadRequest} request
|
|
52
|
+
* @param {ThreadsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
53
|
+
*
|
|
54
|
+
* @throws {@link AgentMail.ValidationError}
|
|
55
|
+
* @throws {@link AgentMail.NotFoundError}
|
|
56
|
+
* @throws {@link AgentMail.UnprocessableError}
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* await client.threads.update("thread_id", {})
|
|
60
|
+
*/
|
|
61
|
+
update(thread_id: AgentMail.ThreadId, request: AgentMail.UpdateThreadRequest, requestOptions?: ThreadsClient.RequestOptions): core.HttpResponsePromise<AgentMail.UpdateThreadResponse>;
|
|
62
|
+
private __update;
|
|
47
63
|
/**
|
|
48
64
|
* Moves the thread to trash by adding a trash label to all messages. If the thread is already in trash, it will be permanently deleted. Use `permanent=true` to force permanent deletion.
|
|
49
65
|
*
|
|
@@ -265,6 +265,95 @@ class ThreadsClient {
|
|
|
265
265
|
return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/v0/threads/{thread_id}/attachments/{attachment_id}");
|
|
266
266
|
});
|
|
267
267
|
}
|
|
268
|
+
/**
|
|
269
|
+
* Updates thread labels. Cannot add or remove system labels (sent, received, bounced, etc.). Rejects requests with a `422` for threads with 100 or more messages.
|
|
270
|
+
*
|
|
271
|
+
* @param {AgentMail.ThreadId} thread_id
|
|
272
|
+
* @param {AgentMail.UpdateThreadRequest} request
|
|
273
|
+
* @param {ThreadsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
274
|
+
*
|
|
275
|
+
* @throws {@link AgentMail.ValidationError}
|
|
276
|
+
* @throws {@link AgentMail.NotFoundError}
|
|
277
|
+
* @throws {@link AgentMail.UnprocessableError}
|
|
278
|
+
*
|
|
279
|
+
* @example
|
|
280
|
+
* await client.threads.update("thread_id", {})
|
|
281
|
+
*/
|
|
282
|
+
update(thread_id, request, requestOptions) {
|
|
283
|
+
return core.HttpResponsePromise.fromPromise(this.__update(thread_id, request, requestOptions));
|
|
284
|
+
}
|
|
285
|
+
__update(thread_id, request, requestOptions) {
|
|
286
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
287
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
288
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
289
|
+
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);
|
|
290
|
+
const _response = yield core.fetcher({
|
|
291
|
+
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.Prod)
|
|
292
|
+
.http, `/v0/threads/${core.url.encodePathParam(serializers.ThreadId.jsonOrThrow(thread_id, { omitUndefined: true }))}`),
|
|
293
|
+
method: "PATCH",
|
|
294
|
+
headers: _headers,
|
|
295
|
+
contentType: "application/json",
|
|
296
|
+
queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
|
|
297
|
+
requestType: "json",
|
|
298
|
+
body: serializers.UpdateThreadRequest.jsonOrThrow(request, {
|
|
299
|
+
unrecognizedObjectKeys: "strip",
|
|
300
|
+
omitUndefined: true,
|
|
301
|
+
}),
|
|
302
|
+
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,
|
|
303
|
+
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,
|
|
304
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
305
|
+
fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
|
|
306
|
+
logging: this._options.logging,
|
|
307
|
+
});
|
|
308
|
+
if (_response.ok) {
|
|
309
|
+
return {
|
|
310
|
+
data: serializers.UpdateThreadResponse.parseOrThrow(_response.body, {
|
|
311
|
+
unrecognizedObjectKeys: "passthrough",
|
|
312
|
+
allowUnrecognizedUnionMembers: true,
|
|
313
|
+
allowUnrecognizedEnumValues: true,
|
|
314
|
+
skipValidation: true,
|
|
315
|
+
breadcrumbsPrefix: ["response"],
|
|
316
|
+
}),
|
|
317
|
+
rawResponse: _response.rawResponse,
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
if (_response.error.reason === "status-code") {
|
|
321
|
+
switch (_response.error.statusCode) {
|
|
322
|
+
case 400:
|
|
323
|
+
throw new AgentMail.ValidationError(serializers.ValidationErrorResponse.parseOrThrow(_response.error.body, {
|
|
324
|
+
unrecognizedObjectKeys: "passthrough",
|
|
325
|
+
allowUnrecognizedUnionMembers: true,
|
|
326
|
+
allowUnrecognizedEnumValues: true,
|
|
327
|
+
skipValidation: true,
|
|
328
|
+
breadcrumbsPrefix: ["response"],
|
|
329
|
+
}), _response.rawResponse);
|
|
330
|
+
case 404:
|
|
331
|
+
throw new AgentMail.NotFoundError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
|
|
332
|
+
unrecognizedObjectKeys: "passthrough",
|
|
333
|
+
allowUnrecognizedUnionMembers: true,
|
|
334
|
+
allowUnrecognizedEnumValues: true,
|
|
335
|
+
skipValidation: true,
|
|
336
|
+
breadcrumbsPrefix: ["response"],
|
|
337
|
+
}), _response.rawResponse);
|
|
338
|
+
case 422:
|
|
339
|
+
throw new AgentMail.UnprocessableError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
|
|
340
|
+
unrecognizedObjectKeys: "passthrough",
|
|
341
|
+
allowUnrecognizedUnionMembers: true,
|
|
342
|
+
allowUnrecognizedEnumValues: true,
|
|
343
|
+
skipValidation: true,
|
|
344
|
+
breadcrumbsPrefix: ["response"],
|
|
345
|
+
}), _response.rawResponse);
|
|
346
|
+
default:
|
|
347
|
+
throw new errors.AgentMailError({
|
|
348
|
+
statusCode: _response.error.statusCode,
|
|
349
|
+
body: _response.error.body,
|
|
350
|
+
rawResponse: _response.rawResponse,
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "PATCH", "/v0/threads/{thread_id}");
|
|
355
|
+
});
|
|
356
|
+
}
|
|
268
357
|
/**
|
|
269
358
|
* Moves the thread to trash by adding a trash label to all messages. If the thread is already in trash, it will be permanently deleted. Use `permanent=true` to force permanent deletion.
|
|
270
359
|
*
|
|
@@ -0,0 +1,21 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
15
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
16
|
+
};
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.ThreadsClient = void 0;
|
|
19
|
+
var Client_js_1 = require("./client/Client.js");
|
|
20
|
+
Object.defineProperty(exports, "ThreadsClient", { enumerable: true, get: function () { return Client_js_1.ThreadsClient; } });
|
|
21
|
+
__exportStar(require("./client/index.js"), exports);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export interface UpdateThreadRequest {
|
|
2
|
+
/** Labels to add to thread. Cannot be system labels. */
|
|
3
|
+
addLabels?: string[];
|
|
4
|
+
/** Labels to remove from thread. Cannot be system labels. Takes priority over `add_labels` (in the event of duplicate labels passed in). */
|
|
5
|
+
removeLabels?: string[];
|
|
6
|
+
}
|
|
@@ -32,3 +32,5 @@ __exportStar(require("./ThreadSize.js"), exports);
|
|
|
32
32
|
__exportStar(require("./ThreadSubject.js"), exports);
|
|
33
33
|
__exportStar(require("./ThreadTimestamp.js"), exports);
|
|
34
34
|
__exportStar(require("./ThreadUpdatedAt.js"), exports);
|
|
35
|
+
__exportStar(require("./UpdateThreadRequest.js"), exports);
|
|
36
|
+
__exportStar(require("./UpdateThreadResponse.js"), exports);
|
|
@@ -0,0 +1,22 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
15
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
16
|
+
};
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.WebhooksClient = void 0;
|
|
19
|
+
var Client_js_1 = require("./client/Client.js");
|
|
20
|
+
Object.defineProperty(exports, "WebhooksClient", { enumerable: true, get: function () { return Client_js_1.WebhooksClient; } });
|
|
21
|
+
__exportStar(require("./client/index.js"), exports);
|
|
22
|
+
__exportStar(require("./resources/index.js"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./index.js";
|
|
@@ -0,0 +1,18 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
15
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
16
|
+
};
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
__exportStar(require("./index.js"), exports);
|
|
@@ -5,6 +5,8 @@ export declare namespace WebsocketsClient {
|
|
|
5
5
|
type Options = BaseClientOptions;
|
|
6
6
|
interface ConnectArgs {
|
|
7
7
|
apiKey?: string;
|
|
8
|
+
/** WebSocket subprotocols to use for the connection. */
|
|
9
|
+
protocols?: string | string[];
|
|
8
10
|
/** Additional query parameters to send with the websocket connect request. */
|
|
9
11
|
queryParams?: Record<string, unknown>;
|
|
10
12
|
/** Arbitrary headers to send with the websocket connect request. */
|
|
@@ -13,6 +15,10 @@ export declare namespace WebsocketsClient {
|
|
|
13
15
|
debug?: boolean;
|
|
14
16
|
/** Number of reconnect attempts. Defaults to 30. */
|
|
15
17
|
reconnectAttempts?: number;
|
|
18
|
+
/** The timeout for establishing the WebSocket connection in seconds. */
|
|
19
|
+
connectionTimeoutInSeconds?: number;
|
|
20
|
+
/** A signal to abort the WebSocket connection. */
|
|
21
|
+
abortSignal?: AbortSignal;
|
|
16
22
|
}
|
|
17
23
|
}
|
|
18
24
|
export declare class WebsocketsClient {
|
|
@@ -56,7 +56,7 @@ class WebsocketsClient {
|
|
|
56
56
|
connect() {
|
|
57
57
|
return __awaiter(this, arguments, void 0, function* (args = {}) {
|
|
58
58
|
var _a, _b;
|
|
59
|
-
const { apiKey, queryParams, headers, debug, reconnectAttempts } = args;
|
|
59
|
+
const { apiKey, protocols, queryParams, headers, debug, reconnectAttempts, connectionTimeoutInSeconds, abortSignal, } = args;
|
|
60
60
|
const _queryParams = {
|
|
61
61
|
api_key: apiKey,
|
|
62
62
|
};
|
|
@@ -65,10 +65,15 @@ class WebsocketsClient {
|
|
|
65
65
|
const socket = new core.ReconnectingWebSocket({
|
|
66
66
|
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.Prod)
|
|
67
67
|
.websockets, "/v0"),
|
|
68
|
-
protocols: [],
|
|
68
|
+
protocols: protocols !== null && protocols !== void 0 ? protocols : [],
|
|
69
69
|
queryParameters: Object.assign(Object.assign({}, _queryParams), queryParams),
|
|
70
70
|
headers: _headers,
|
|
71
|
-
options: {
|
|
71
|
+
options: {
|
|
72
|
+
debug: debug !== null && debug !== void 0 ? debug : false,
|
|
73
|
+
maxRetries: reconnectAttempts !== null && reconnectAttempts !== void 0 ? reconnectAttempts : 30,
|
|
74
|
+
connectionTimeout: connectionTimeoutInSeconds != null ? connectionTimeoutInSeconds * 1000 : undefined,
|
|
75
|
+
},
|
|
76
|
+
abortSignal: abortSignal,
|
|
72
77
|
});
|
|
73
78
|
return new Socket_js_1.WebsocketsSocket({ socket });
|
|
74
79
|
});
|
|
@@ -21,7 +21,7 @@ export declare class WebsocketsSocket {
|
|
|
21
21
|
private handleError;
|
|
22
22
|
constructor(args: WebsocketsSocket.Args);
|
|
23
23
|
/** The current state of the connection; this is one of the readyState constants. */
|
|
24
|
-
get readyState():
|
|
24
|
+
get readyState(): core.ReconnectingWebSocket.ReadyState;
|
|
25
25
|
/**
|
|
26
26
|
* @param event - The event to attach to.
|
|
27
27
|
* @param callback - The callback to run when the event is triggered.
|
|
@@ -43,5 +43,5 @@ export declare class WebsocketsSocket {
|
|
|
43
43
|
/** Asserts that the websocket is open. */
|
|
44
44
|
private assertSocketIsOpen;
|
|
45
45
|
/** Send a binary payload to the websocket. */
|
|
46
|
-
protected sendBinary(payload:
|
|
46
|
+
protected sendBinary(payload: ArrayBuffer | Blob | ArrayBufferView): void;
|
|
47
47
|
}
|
|
@@ -136,7 +136,7 @@ class WebsocketsSocket {
|
|
|
136
136
|
/** Returns a promise that resolves when the websocket is open. */
|
|
137
137
|
waitForOpen() {
|
|
138
138
|
return __awaiter(this, void 0, void 0, function* () {
|
|
139
|
-
if (this.socket.readyState === core.ReconnectingWebSocket.OPEN) {
|
|
139
|
+
if (this.socket.readyState === core.ReconnectingWebSocket.ReadyState.OPEN) {
|
|
140
140
|
return this.socket;
|
|
141
141
|
}
|
|
142
142
|
return new Promise((resolve, reject) => {
|
|
@@ -154,7 +154,7 @@ class WebsocketsSocket {
|
|
|
154
154
|
if (!this.socket) {
|
|
155
155
|
throw new Error("Socket is not connected.");
|
|
156
156
|
}
|
|
157
|
-
if (this.socket.readyState !== core.ReconnectingWebSocket.OPEN) {
|
|
157
|
+
if (this.socket.readyState !== core.ReconnectingWebSocket.ReadyState.OPEN) {
|
|
158
158
|
throw new Error("Socket is not open.");
|
|
159
159
|
}
|
|
160
160
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
15
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
16
|
+
};
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.WebsocketsSocket = exports.WebsocketsClient = void 0;
|
|
19
|
+
var Client_js_1 = require("./client/Client.js");
|
|
20
|
+
Object.defineProperty(exports, "WebsocketsClient", { enumerable: true, get: function () { return Client_js_1.WebsocketsClient; } });
|
|
21
|
+
__exportStar(require("./client/index.js"), exports);
|
|
22
|
+
var Socket_js_1 = require("./client/Socket.js");
|
|
23
|
+
Object.defineProperty(exports, "WebsocketsSocket", { enumerable: true, get: function () { return Socket_js_1.WebsocketsSocket; } });
|
|
@@ -14,6 +14,6 @@ export type BinaryResponse = {
|
|
|
14
14
|
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bytes)
|
|
15
15
|
* Some versions of the Fetch API may not support this method.
|
|
16
16
|
*/
|
|
17
|
-
bytes?():
|
|
17
|
+
bytes?(): Promise<Uint8Array>;
|
|
18
18
|
};
|
|
19
19
|
export declare function getBinaryResponse(response: Response): BinaryResponse;
|
|
@@ -156,7 +156,13 @@ function getHeaders(args) {
|
|
|
156
156
|
return __awaiter(this, void 0, void 0, function* () {
|
|
157
157
|
var _a;
|
|
158
158
|
const newHeaders = new Headers_js_1.Headers();
|
|
159
|
-
newHeaders.set("Accept", args.responseType === "json"
|
|
159
|
+
newHeaders.set("Accept", args.responseType === "json"
|
|
160
|
+
? "application/json"
|
|
161
|
+
: args.responseType === "text"
|
|
162
|
+
? "text/plain"
|
|
163
|
+
: args.responseType === "sse"
|
|
164
|
+
? "text/event-stream"
|
|
165
|
+
: "*/*");
|
|
160
166
|
if (args.body !== undefined && args.contentType != null) {
|
|
161
167
|
newHeaders.set("Content-Type", args.contentType);
|
|
162
168
|
}
|
|
@@ -200,7 +206,7 @@ function fetcherImpl(args) {
|
|
|
200
206
|
}
|
|
201
207
|
try {
|
|
202
208
|
const response = yield (0, requestWithRetries_js_1.requestWithRetries)(() => __awaiter(this, void 0, void 0, function* () {
|
|
203
|
-
return (0, makeRequest_js_1.makeRequest)(fetchFn, url, args.method, headers, requestBody, args.timeoutMs, args.abortSignal, args.withCredentials, args.duplex);
|
|
209
|
+
return (0, makeRequest_js_1.makeRequest)(fetchFn, url, args.method, headers, requestBody, args.timeoutMs, args.abortSignal, args.withCredentials, args.duplex, args.responseType === "streaming" || args.responseType === "sse");
|
|
204
210
|
}), args.maxRetries);
|
|
205
211
|
if (response.status >= 200 && response.status < 400) {
|
|
206
212
|
if (logger.isDebug()) {
|
|
@@ -6,6 +6,8 @@ export type { Fetcher, FetchFunction } from "./Fetcher.js";
|
|
|
6
6
|
export { fetcher } from "./Fetcher.js";
|
|
7
7
|
export { getHeader } from "./getHeader.js";
|
|
8
8
|
export { HttpResponsePromise } from "./HttpResponsePromise.js";
|
|
9
|
+
export type { PassthroughRequest } from "./makePassthroughRequest.js";
|
|
10
|
+
export { makePassthroughRequest } from "./makePassthroughRequest.js";
|
|
9
11
|
export type { RawResponse, WithRawResponse } from "./RawResponse.js";
|
|
10
12
|
export { abortRawResponse, toRawResponse, unknownRawResponse } from "./RawResponse.js";
|
|
11
13
|
export { Supplier } from "./Supplier.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Supplier = exports.unknownRawResponse = exports.toRawResponse = exports.abortRawResponse = exports.HttpResponsePromise = exports.getHeader = exports.fetcher = exports.EndpointSupplier = void 0;
|
|
3
|
+
exports.Supplier = exports.unknownRawResponse = exports.toRawResponse = exports.abortRawResponse = exports.makePassthroughRequest = exports.HttpResponsePromise = exports.getHeader = exports.fetcher = exports.EndpointSupplier = void 0;
|
|
4
4
|
var EndpointSupplier_js_1 = require("./EndpointSupplier.js");
|
|
5
5
|
Object.defineProperty(exports, "EndpointSupplier", { enumerable: true, get: function () { return EndpointSupplier_js_1.EndpointSupplier; } });
|
|
6
6
|
var Fetcher_js_1 = require("./Fetcher.js");
|
|
@@ -9,6 +9,8 @@ var getHeader_js_1 = require("./getHeader.js");
|
|
|
9
9
|
Object.defineProperty(exports, "getHeader", { enumerable: true, get: function () { return getHeader_js_1.getHeader; } });
|
|
10
10
|
var HttpResponsePromise_js_1 = require("./HttpResponsePromise.js");
|
|
11
11
|
Object.defineProperty(exports, "HttpResponsePromise", { enumerable: true, get: function () { return HttpResponsePromise_js_1.HttpResponsePromise; } });
|
|
12
|
+
var makePassthroughRequest_js_1 = require("./makePassthroughRequest.js");
|
|
13
|
+
Object.defineProperty(exports, "makePassthroughRequest", { enumerable: true, get: function () { return makePassthroughRequest_js_1.makePassthroughRequest; } });
|
|
12
14
|
var RawResponse_js_1 = require("./RawResponse.js");
|
|
13
15
|
Object.defineProperty(exports, "abortRawResponse", { enumerable: true, get: function () { return RawResponse_js_1.abortRawResponse; } });
|
|
14
16
|
Object.defineProperty(exports, "toRawResponse", { enumerable: true, get: function () { return RawResponse_js_1.toRawResponse; } });
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { type LogConfig, type Logger } from "../logging/logger.js";
|
|
2
|
+
import { Supplier } from "./Supplier.js";
|
|
3
|
+
export declare namespace PassthroughRequest {
|
|
4
|
+
/**
|
|
5
|
+
* Per-request options that can override the SDK client defaults.
|
|
6
|
+
*/
|
|
7
|
+
interface RequestOptions {
|
|
8
|
+
/** Override the default timeout for this request (in seconds). */
|
|
9
|
+
timeoutInSeconds?: number;
|
|
10
|
+
/** Override the default number of retries for this request. */
|
|
11
|
+
maxRetries?: number;
|
|
12
|
+
/** Additional headers to include in this request. */
|
|
13
|
+
headers?: Record<string, string>;
|
|
14
|
+
/** Abort signal for this request. */
|
|
15
|
+
abortSignal?: AbortSignal;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* SDK client configuration used by the passthrough fetch method.
|
|
19
|
+
*/
|
|
20
|
+
interface ClientOptions {
|
|
21
|
+
/** The base URL or environment for the client. */
|
|
22
|
+
environment?: Supplier<string>;
|
|
23
|
+
/** Override the base URL. */
|
|
24
|
+
baseUrl?: Supplier<string>;
|
|
25
|
+
/** Default headers to include in requests. */
|
|
26
|
+
headers?: Record<string, unknown>;
|
|
27
|
+
/** Default maximum time to wait for a response in seconds. */
|
|
28
|
+
timeoutInSeconds?: number;
|
|
29
|
+
/** Default number of times to retry the request. Defaults to 2. */
|
|
30
|
+
maxRetries?: number;
|
|
31
|
+
/** A custom fetch function. */
|
|
32
|
+
fetch?: typeof fetch;
|
|
33
|
+
/** Logging configuration. */
|
|
34
|
+
logging?: LogConfig | Logger;
|
|
35
|
+
/** A function that returns auth headers. */
|
|
36
|
+
getAuthHeaders?: () => Promise<Record<string, string>>;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Makes a passthrough HTTP request using the SDK's configuration (auth, retry, logging, etc.)
|
|
41
|
+
* while mimicking the standard `fetch` API.
|
|
42
|
+
*
|
|
43
|
+
* @param input - The URL, path, or Request object. If a relative path, it will be resolved against the configured base URL.
|
|
44
|
+
* @param init - Standard RequestInit options (method, headers, body, signal, etc.)
|
|
45
|
+
* @param clientOptions - SDK client options (auth, default headers, logging, etc.)
|
|
46
|
+
* @param requestOptions - Per-request overrides (timeout, retries, extra headers, abort signal).
|
|
47
|
+
* @returns A standard Response object.
|
|
48
|
+
*/
|
|
49
|
+
export declare function makePassthroughRequest(input: Request | string | URL, init: RequestInit | undefined, clientOptions: PassthroughRequest.ClientOptions, requestOptions?: PassthroughRequest.RequestOptions): Promise<Response>;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.makePassthroughRequest = makePassthroughRequest;
|
|
13
|
+
const logger_js_1 = require("../logging/logger.js");
|
|
14
|
+
const join_js_1 = require("../url/join.js");
|
|
15
|
+
const EndpointSupplier_js_1 = require("./EndpointSupplier.js");
|
|
16
|
+
const getFetchFn_js_1 = require("./getFetchFn.js");
|
|
17
|
+
const makeRequest_js_1 = require("./makeRequest.js");
|
|
18
|
+
const requestWithRetries_js_1 = require("./requestWithRetries.js");
|
|
19
|
+
const Supplier_js_1 = require("./Supplier.js");
|
|
20
|
+
/**
|
|
21
|
+
* Makes a passthrough HTTP request using the SDK's configuration (auth, retry, logging, etc.)
|
|
22
|
+
* while mimicking the standard `fetch` API.
|
|
23
|
+
*
|
|
24
|
+
* @param input - The URL, path, or Request object. If a relative path, it will be resolved against the configured base URL.
|
|
25
|
+
* @param init - Standard RequestInit options (method, headers, body, signal, etc.)
|
|
26
|
+
* @param clientOptions - SDK client options (auth, default headers, logging, etc.)
|
|
27
|
+
* @param requestOptions - Per-request overrides (timeout, retries, extra headers, abort signal).
|
|
28
|
+
* @returns A standard Response object.
|
|
29
|
+
*/
|
|
30
|
+
function makePassthroughRequest(input, init, clientOptions, requestOptions) {
|
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
33
|
+
const logger = (0, logger_js_1.createLogger)(clientOptions.logging);
|
|
34
|
+
// Extract URL and default init properties from Request object if provided
|
|
35
|
+
let url;
|
|
36
|
+
let effectiveInit = init;
|
|
37
|
+
if (input instanceof Request) {
|
|
38
|
+
url = input.url;
|
|
39
|
+
// If no explicit init provided, extract properties from the Request object
|
|
40
|
+
if (init == null) {
|
|
41
|
+
effectiveInit = {
|
|
42
|
+
method: input.method,
|
|
43
|
+
headers: Object.fromEntries(input.headers.entries()),
|
|
44
|
+
body: input.body,
|
|
45
|
+
signal: input.signal,
|
|
46
|
+
credentials: input.credentials,
|
|
47
|
+
cache: input.cache,
|
|
48
|
+
redirect: input.redirect,
|
|
49
|
+
referrer: input.referrer,
|
|
50
|
+
integrity: input.integrity,
|
|
51
|
+
mode: input.mode,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
url = input instanceof URL ? input.toString() : input;
|
|
57
|
+
}
|
|
58
|
+
// Resolve the base URL
|
|
59
|
+
const baseUrl = (_a = (clientOptions.baseUrl != null ? yield Supplier_js_1.Supplier.get(clientOptions.baseUrl) : undefined)) !== null && _a !== void 0 ? _a : (clientOptions.environment != null ? yield Supplier_js_1.Supplier.get(clientOptions.environment) : undefined);
|
|
60
|
+
// Determine the full URL
|
|
61
|
+
let fullUrl;
|
|
62
|
+
if (url.startsWith("http://") || url.startsWith("https://")) {
|
|
63
|
+
fullUrl = url;
|
|
64
|
+
}
|
|
65
|
+
else if (baseUrl != null) {
|
|
66
|
+
fullUrl = (0, join_js_1.join)(baseUrl, url);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
fullUrl = url;
|
|
70
|
+
}
|
|
71
|
+
// Merge headers: SDK default headers -> auth headers -> user-provided headers
|
|
72
|
+
const mergedHeaders = {};
|
|
73
|
+
// Apply SDK default headers (resolve suppliers)
|
|
74
|
+
if (clientOptions.headers != null) {
|
|
75
|
+
for (const [key, value] of Object.entries(clientOptions.headers)) {
|
|
76
|
+
const resolved = yield EndpointSupplier_js_1.EndpointSupplier.get(value, { endpointMetadata: {} });
|
|
77
|
+
if (resolved != null) {
|
|
78
|
+
mergedHeaders[key.toLowerCase()] = `${resolved}`;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
// Apply auth headers
|
|
83
|
+
if (clientOptions.getAuthHeaders != null) {
|
|
84
|
+
const authHeaders = yield clientOptions.getAuthHeaders();
|
|
85
|
+
for (const [key, value] of Object.entries(authHeaders)) {
|
|
86
|
+
mergedHeaders[key.toLowerCase()] = value;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
// Apply user-provided headers from init
|
|
90
|
+
if ((effectiveInit === null || effectiveInit === void 0 ? void 0 : effectiveInit.headers) != null) {
|
|
91
|
+
const initHeaders = effectiveInit.headers instanceof Headers
|
|
92
|
+
? Object.fromEntries(effectiveInit.headers.entries())
|
|
93
|
+
: Array.isArray(effectiveInit.headers)
|
|
94
|
+
? Object.fromEntries(effectiveInit.headers)
|
|
95
|
+
: effectiveInit.headers;
|
|
96
|
+
for (const [key, value] of Object.entries(initHeaders)) {
|
|
97
|
+
if (value != null) {
|
|
98
|
+
mergedHeaders[key.toLowerCase()] = value;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
// Apply per-request option headers (highest priority)
|
|
103
|
+
if ((requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers) != null) {
|
|
104
|
+
for (const [key, value] of Object.entries(requestOptions.headers)) {
|
|
105
|
+
mergedHeaders[key.toLowerCase()] = value;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
const method = (_b = effectiveInit === null || effectiveInit === void 0 ? void 0 : effectiveInit.method) !== null && _b !== void 0 ? _b : "GET";
|
|
109
|
+
const body = effectiveInit === null || effectiveInit === void 0 ? void 0 : effectiveInit.body;
|
|
110
|
+
const timeoutInSeconds = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _c !== void 0 ? _c : clientOptions.timeoutInSeconds;
|
|
111
|
+
const timeoutMs = timeoutInSeconds != null ? timeoutInSeconds * 1000 : undefined;
|
|
112
|
+
const maxRetries = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _d !== void 0 ? _d : clientOptions.maxRetries;
|
|
113
|
+
const abortSignal = (_f = (_e = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal) !== null && _e !== void 0 ? _e : effectiveInit === null || effectiveInit === void 0 ? void 0 : effectiveInit.signal) !== null && _f !== void 0 ? _f : undefined;
|
|
114
|
+
const fetchFn = (_g = clientOptions.fetch) !== null && _g !== void 0 ? _g : (yield (0, getFetchFn_js_1.getFetchFn)());
|
|
115
|
+
if (logger.isDebug()) {
|
|
116
|
+
logger.debug("Making passthrough HTTP request", {
|
|
117
|
+
method,
|
|
118
|
+
url: fullUrl,
|
|
119
|
+
hasBody: body != null,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
const response = yield (0, requestWithRetries_js_1.requestWithRetries)(() => __awaiter(this, void 0, void 0, function* () {
|
|
123
|
+
return (0, makeRequest_js_1.makeRequest)(fetchFn, fullUrl, method, mergedHeaders, body !== null && body !== void 0 ? body : undefined, timeoutMs, abortSignal, (effectiveInit === null || effectiveInit === void 0 ? void 0 : effectiveInit.credentials) === "include", undefined, // duplex
|
|
124
|
+
false);
|
|
125
|
+
}), maxRetries);
|
|
126
|
+
if (logger.isDebug()) {
|
|
127
|
+
logger.debug("Passthrough HTTP request completed", {
|
|
128
|
+
method,
|
|
129
|
+
url: fullUrl,
|
|
130
|
+
statusCode: response.status,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
return response;
|
|
134
|
+
});
|
|
135
|
+
}
|
|
@@ -1 +1,6 @@
|
|
|
1
|
-
export declare
|
|
1
|
+
export declare function isCacheNoStoreSupported(): boolean;
|
|
2
|
+
/**
|
|
3
|
+
* Reset the cached result of `isCacheNoStoreSupported`. Exposed for testing only.
|
|
4
|
+
*/
|
|
5
|
+
export declare function resetCacheNoStoreSupported(): void;
|
|
6
|
+
export declare const makeRequest: (fetchFn: (url: string, init: RequestInit) => Promise<Response>, url: string, method: string, headers: Headers | Record<string, string>, requestBody: BodyInit | undefined, timeoutMs?: number, abortSignal?: AbortSignal, withCredentials?: boolean, duplex?: "half", disableCache?: boolean) => Promise<Response>;
|