agentmail 0.0.58 → 0.0.66
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/dist/cjs/Client.d.ts +2 -2
- package/dist/cjs/Client.js +2 -2
- package/dist/cjs/api/resources/domains/client/Client.d.ts +7 -7
- package/dist/cjs/api/resources/domains/client/Client.js +69 -58
- package/dist/cjs/api/resources/drafts/client/Client.d.ts +3 -4
- package/dist/cjs/api/resources/drafts/client/Client.js +84 -71
- package/dist/cjs/api/resources/inboxes/client/Client.d.ts +14 -4
- package/dist/cjs/api/resources/inboxes/client/Client.js +127 -54
- package/dist/cjs/api/resources/inboxes/resources/drafts/client/Client.d.ts +3 -4
- package/dist/cjs/api/resources/inboxes/resources/drafts/client/Client.js +87 -74
- package/dist/cjs/api/resources/inboxes/resources/messages/client/Client.d.ts +3 -4
- package/dist/cjs/api/resources/inboxes/resources/messages/client/Client.js +89 -76
- package/dist/cjs/api/resources/inboxes/resources/metrics/client/Client.d.ts +2 -2
- package/dist/cjs/api/resources/inboxes/resources/metrics/client/Client.js +1 -1
- package/dist/cjs/api/resources/inboxes/resources/threads/client/Client.d.ts +15 -4
- package/dist/cjs/api/resources/inboxes/resources/threads/client/Client.js +138 -61
- package/dist/cjs/api/resources/messages/types/Message.d.ts +5 -8
- package/dist/cjs/api/resources/messages/types/MessageCreatedAt.d.ts +7 -0
- package/dist/cjs/api/resources/messages/types/MessageCreatedAt.js +5 -0
- package/dist/cjs/api/resources/messages/types/MessageInReplyTo.d.ts +7 -0
- package/dist/cjs/api/resources/messages/types/MessageInReplyTo.js +5 -0
- package/dist/cjs/api/resources/messages/types/MessageItem.d.ts +5 -0
- package/dist/cjs/api/resources/messages/types/MessageReferences.d.ts +7 -0
- package/dist/cjs/api/resources/messages/types/MessageReferences.js +5 -0
- package/dist/cjs/api/resources/messages/types/MessageReplyTo.d.ts +7 -0
- package/dist/cjs/api/resources/messages/types/MessageReplyTo.js +5 -0
- package/dist/cjs/api/resources/messages/types/MessageSize.d.ts +7 -0
- package/dist/cjs/api/resources/messages/types/MessageSize.js +5 -0
- package/dist/cjs/api/resources/messages/types/MessageUpdatedAt.d.ts +7 -0
- package/dist/cjs/api/resources/messages/types/MessageUpdatedAt.js +5 -0
- package/dist/cjs/api/resources/messages/types/index.d.ts +6 -0
- package/dist/cjs/api/resources/messages/types/index.js +6 -0
- package/dist/cjs/api/resources/metrics/client/Client.d.ts +2 -2
- package/dist/cjs/api/resources/metrics/client/Client.js +1 -1
- package/dist/cjs/api/resources/threads/client/Client.d.ts +14 -4
- package/dist/cjs/api/resources/threads/client/Client.js +136 -60
- package/dist/cjs/api/resources/threads/types/Thread.d.ts +6 -4
- package/dist/cjs/api/resources/threads/types/ThreadCreatedAt.d.ts +7 -0
- package/dist/cjs/api/resources/threads/types/ThreadCreatedAt.js +5 -0
- package/dist/cjs/api/resources/threads/types/ThreadItem.d.ts +6 -0
- package/dist/cjs/api/resources/threads/types/ThreadLastMessageId.d.ts +7 -0
- package/dist/cjs/api/resources/threads/types/ThreadLastMessageId.js +5 -0
- package/dist/cjs/api/resources/threads/types/ThreadReceivedTimestamp.d.ts +7 -0
- package/dist/cjs/api/resources/threads/types/ThreadReceivedTimestamp.js +5 -0
- package/dist/cjs/api/resources/threads/types/ThreadSentTimestamp.d.ts +7 -0
- package/dist/cjs/api/resources/threads/types/ThreadSentTimestamp.js +5 -0
- package/dist/cjs/api/resources/threads/types/ThreadSize.d.ts +7 -0
- package/dist/cjs/api/resources/threads/types/ThreadSize.js +5 -0
- package/dist/cjs/api/resources/threads/types/ThreadTimestamp.d.ts +1 -1
- package/dist/cjs/api/resources/threads/types/ThreadUpdatedAt.d.ts +7 -0
- package/dist/cjs/api/resources/threads/types/ThreadUpdatedAt.js +5 -0
- package/dist/cjs/api/resources/threads/types/index.d.ts +6 -0
- package/dist/cjs/api/resources/threads/types/index.js +6 -0
- package/dist/cjs/api/resources/webhooks/client/Client.d.ts +3 -4
- package/dist/cjs/api/resources/webhooks/client/Client.js +65 -55
- package/dist/cjs/api/resources/websockets/client/Client.d.ts +1 -1
- package/dist/cjs/api/resources/websockets/client/Client.js +2 -1
- package/dist/cjs/core/fetcher/Fetcher.d.ts +1 -1
- package/dist/cjs/core/fetcher/requestWithRetries.js +44 -8
- package/dist/cjs/core/headers.d.ts +2 -2
- package/dist/cjs/core/index.d.ts +2 -0
- package/dist/cjs/core/index.js +2 -0
- package/dist/cjs/core/pagination/Page.d.ts +32 -0
- package/dist/cjs/core/pagination/Page.js +100 -0
- package/dist/cjs/core/pagination/Pageable.d.ts +14 -0
- package/dist/cjs/core/pagination/Pageable.js +10 -0
- package/dist/cjs/core/pagination/index.d.ts +2 -0
- package/dist/cjs/core/pagination/index.js +7 -0
- package/dist/cjs/core/utils/index.d.ts +1 -0
- package/dist/cjs/core/utils/index.js +5 -0
- package/dist/cjs/core/utils/setObjectProperty.d.ts +11 -0
- package/dist/cjs/core/utils/setObjectProperty.js +42 -0
- package/dist/cjs/core/websocket/ws.d.ts +1 -1
- package/dist/cjs/serialization/resources/messages/types/Message.d.ts +10 -4
- package/dist/cjs/serialization/resources/messages/types/Message.js +10 -4
- package/dist/cjs/serialization/resources/messages/types/MessageCreatedAt.d.ts +10 -0
- package/dist/cjs/serialization/resources/messages/types/MessageCreatedAt.js +41 -0
- package/dist/cjs/serialization/resources/messages/types/MessageInReplyTo.d.ts +10 -0
- package/dist/cjs/serialization/resources/messages/types/MessageInReplyTo.js +41 -0
- package/dist/cjs/serialization/resources/messages/types/MessageItem.d.ts +10 -0
- package/dist/cjs/serialization/resources/messages/types/MessageItem.js +10 -0
- package/dist/cjs/serialization/resources/messages/types/MessageReferences.d.ts +10 -0
- package/dist/cjs/serialization/resources/messages/types/MessageReferences.js +41 -0
- package/dist/cjs/serialization/resources/messages/types/MessageReplyTo.d.ts +10 -0
- package/dist/cjs/serialization/resources/messages/types/MessageReplyTo.js +41 -0
- package/dist/cjs/serialization/resources/messages/types/MessageSize.d.ts +10 -0
- package/dist/cjs/serialization/resources/messages/types/MessageSize.js +41 -0
- package/dist/cjs/serialization/resources/messages/types/MessageUpdatedAt.d.ts +10 -0
- package/dist/cjs/serialization/resources/messages/types/MessageUpdatedAt.js +41 -0
- package/dist/cjs/serialization/resources/messages/types/index.d.ts +6 -0
- package/dist/cjs/serialization/resources/messages/types/index.js +6 -0
- package/dist/cjs/serialization/resources/threads/types/Thread.d.ts +12 -2
- package/dist/cjs/serialization/resources/threads/types/Thread.js +12 -2
- package/dist/cjs/serialization/resources/threads/types/ThreadCreatedAt.d.ts +10 -0
- package/dist/cjs/serialization/resources/threads/types/ThreadCreatedAt.js +41 -0
- package/dist/cjs/serialization/resources/threads/types/ThreadItem.d.ts +12 -0
- package/dist/cjs/serialization/resources/threads/types/ThreadItem.js +12 -0
- package/dist/cjs/serialization/resources/threads/types/ThreadLastMessageId.d.ts +10 -0
- package/dist/cjs/serialization/resources/threads/types/ThreadLastMessageId.js +41 -0
- package/dist/cjs/serialization/resources/threads/types/ThreadReceivedTimestamp.d.ts +10 -0
- package/dist/cjs/serialization/resources/threads/types/ThreadReceivedTimestamp.js +41 -0
- package/dist/cjs/serialization/resources/threads/types/ThreadSentTimestamp.d.ts +10 -0
- package/dist/cjs/serialization/resources/threads/types/ThreadSentTimestamp.js +41 -0
- package/dist/cjs/serialization/resources/threads/types/ThreadSize.d.ts +10 -0
- package/dist/cjs/serialization/resources/threads/types/ThreadSize.js +41 -0
- package/dist/cjs/serialization/resources/threads/types/ThreadUpdatedAt.d.ts +10 -0
- package/dist/cjs/serialization/resources/threads/types/ThreadUpdatedAt.js +41 -0
- package/dist/cjs/serialization/resources/threads/types/index.d.ts +6 -0
- package/dist/cjs/serialization/resources/threads/types/index.js +6 -0
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/Client.d.mts +2 -2
- package/dist/esm/Client.mjs +2 -2
- package/dist/esm/api/resources/domains/client/Client.d.mts +7 -7
- package/dist/esm/api/resources/domains/client/Client.mjs +69 -58
- package/dist/esm/api/resources/drafts/client/Client.d.mts +3 -4
- package/dist/esm/api/resources/drafts/client/Client.mjs +84 -71
- package/dist/esm/api/resources/inboxes/client/Client.d.mts +14 -4
- package/dist/esm/api/resources/inboxes/client/Client.mjs +127 -54
- package/dist/esm/api/resources/inboxes/resources/drafts/client/Client.d.mts +3 -4
- package/dist/esm/api/resources/inboxes/resources/drafts/client/Client.mjs +87 -74
- package/dist/esm/api/resources/inboxes/resources/messages/client/Client.d.mts +3 -4
- package/dist/esm/api/resources/inboxes/resources/messages/client/Client.mjs +89 -76
- package/dist/esm/api/resources/inboxes/resources/metrics/client/Client.d.mts +2 -2
- package/dist/esm/api/resources/inboxes/resources/metrics/client/Client.mjs +1 -1
- package/dist/esm/api/resources/inboxes/resources/threads/client/Client.d.mts +15 -4
- package/dist/esm/api/resources/inboxes/resources/threads/client/Client.mjs +138 -61
- package/dist/esm/api/resources/messages/types/Message.d.mts +5 -8
- package/dist/esm/api/resources/messages/types/MessageCreatedAt.d.mts +7 -0
- package/dist/esm/api/resources/messages/types/MessageCreatedAt.mjs +4 -0
- package/dist/esm/api/resources/messages/types/MessageInReplyTo.d.mts +7 -0
- package/dist/esm/api/resources/messages/types/MessageInReplyTo.mjs +4 -0
- package/dist/esm/api/resources/messages/types/MessageItem.d.mts +5 -0
- package/dist/esm/api/resources/messages/types/MessageReferences.d.mts +7 -0
- package/dist/esm/api/resources/messages/types/MessageReferences.mjs +4 -0
- package/dist/esm/api/resources/messages/types/MessageReplyTo.d.mts +7 -0
- package/dist/esm/api/resources/messages/types/MessageReplyTo.mjs +4 -0
- package/dist/esm/api/resources/messages/types/MessageSize.d.mts +7 -0
- package/dist/esm/api/resources/messages/types/MessageSize.mjs +4 -0
- package/dist/esm/api/resources/messages/types/MessageUpdatedAt.d.mts +7 -0
- package/dist/esm/api/resources/messages/types/MessageUpdatedAt.mjs +4 -0
- package/dist/esm/api/resources/messages/types/index.d.mts +6 -0
- package/dist/esm/api/resources/messages/types/index.mjs +6 -0
- package/dist/esm/api/resources/metrics/client/Client.d.mts +2 -2
- package/dist/esm/api/resources/metrics/client/Client.mjs +1 -1
- package/dist/esm/api/resources/threads/client/Client.d.mts +14 -4
- package/dist/esm/api/resources/threads/client/Client.mjs +136 -60
- package/dist/esm/api/resources/threads/types/Thread.d.mts +6 -4
- package/dist/esm/api/resources/threads/types/ThreadCreatedAt.d.mts +7 -0
- package/dist/esm/api/resources/threads/types/ThreadCreatedAt.mjs +4 -0
- package/dist/esm/api/resources/threads/types/ThreadItem.d.mts +6 -0
- package/dist/esm/api/resources/threads/types/ThreadLastMessageId.d.mts +7 -0
- package/dist/esm/api/resources/threads/types/ThreadLastMessageId.mjs +4 -0
- package/dist/esm/api/resources/threads/types/ThreadReceivedTimestamp.d.mts +7 -0
- package/dist/esm/api/resources/threads/types/ThreadReceivedTimestamp.mjs +4 -0
- package/dist/esm/api/resources/threads/types/ThreadSentTimestamp.d.mts +7 -0
- package/dist/esm/api/resources/threads/types/ThreadSentTimestamp.mjs +4 -0
- package/dist/esm/api/resources/threads/types/ThreadSize.d.mts +7 -0
- package/dist/esm/api/resources/threads/types/ThreadSize.mjs +4 -0
- package/dist/esm/api/resources/threads/types/ThreadTimestamp.d.mts +1 -1
- package/dist/esm/api/resources/threads/types/ThreadUpdatedAt.d.mts +7 -0
- package/dist/esm/api/resources/threads/types/ThreadUpdatedAt.mjs +4 -0
- package/dist/esm/api/resources/threads/types/index.d.mts +6 -0
- package/dist/esm/api/resources/threads/types/index.mjs +6 -0
- package/dist/esm/api/resources/webhooks/client/Client.d.mts +3 -4
- package/dist/esm/api/resources/webhooks/client/Client.mjs +65 -55
- package/dist/esm/api/resources/websockets/client/Client.d.mts +1 -1
- package/dist/esm/api/resources/websockets/client/Client.mjs +2 -1
- package/dist/esm/core/fetcher/Fetcher.d.mts +1 -1
- package/dist/esm/core/fetcher/requestWithRetries.mjs +44 -8
- package/dist/esm/core/headers.d.mts +2 -2
- package/dist/esm/core/index.d.mts +2 -0
- package/dist/esm/core/index.mjs +2 -0
- package/dist/esm/core/pagination/Page.d.mts +32 -0
- package/dist/esm/core/pagination/Page.mjs +96 -0
- package/dist/esm/core/pagination/Pageable.d.mts +14 -0
- package/dist/esm/core/pagination/Pageable.mjs +6 -0
- package/dist/esm/core/pagination/index.d.mts +2 -0
- package/dist/esm/core/pagination/index.mjs +2 -0
- package/dist/esm/core/utils/index.d.mts +1 -0
- package/dist/esm/core/utils/index.mjs +1 -0
- package/dist/esm/core/utils/setObjectProperty.d.mts +11 -0
- package/dist/esm/core/utils/setObjectProperty.mjs +39 -0
- package/dist/esm/core/websocket/ws.d.mts +1 -1
- package/dist/esm/serialization/resources/messages/types/Message.d.mts +10 -4
- package/dist/esm/serialization/resources/messages/types/Message.mjs +10 -4
- package/dist/esm/serialization/resources/messages/types/MessageCreatedAt.d.mts +10 -0
- package/dist/esm/serialization/resources/messages/types/MessageCreatedAt.mjs +5 -0
- package/dist/esm/serialization/resources/messages/types/MessageInReplyTo.d.mts +10 -0
- package/dist/esm/serialization/resources/messages/types/MessageInReplyTo.mjs +5 -0
- package/dist/esm/serialization/resources/messages/types/MessageItem.d.mts +10 -0
- package/dist/esm/serialization/resources/messages/types/MessageItem.mjs +10 -0
- package/dist/esm/serialization/resources/messages/types/MessageReferences.d.mts +10 -0
- package/dist/esm/serialization/resources/messages/types/MessageReferences.mjs +5 -0
- package/dist/esm/serialization/resources/messages/types/MessageReplyTo.d.mts +10 -0
- package/dist/esm/serialization/resources/messages/types/MessageReplyTo.mjs +5 -0
- package/dist/esm/serialization/resources/messages/types/MessageSize.d.mts +10 -0
- package/dist/esm/serialization/resources/messages/types/MessageSize.mjs +5 -0
- package/dist/esm/serialization/resources/messages/types/MessageUpdatedAt.d.mts +10 -0
- package/dist/esm/serialization/resources/messages/types/MessageUpdatedAt.mjs +5 -0
- package/dist/esm/serialization/resources/messages/types/index.d.mts +6 -0
- package/dist/esm/serialization/resources/messages/types/index.mjs +6 -0
- package/dist/esm/serialization/resources/threads/types/Thread.d.mts +12 -2
- package/dist/esm/serialization/resources/threads/types/Thread.mjs +12 -2
- package/dist/esm/serialization/resources/threads/types/ThreadCreatedAt.d.mts +10 -0
- package/dist/esm/serialization/resources/threads/types/ThreadCreatedAt.mjs +5 -0
- package/dist/esm/serialization/resources/threads/types/ThreadItem.d.mts +12 -0
- package/dist/esm/serialization/resources/threads/types/ThreadItem.mjs +12 -0
- package/dist/esm/serialization/resources/threads/types/ThreadLastMessageId.d.mts +10 -0
- package/dist/esm/serialization/resources/threads/types/ThreadLastMessageId.mjs +5 -0
- package/dist/esm/serialization/resources/threads/types/ThreadReceivedTimestamp.d.mts +10 -0
- package/dist/esm/serialization/resources/threads/types/ThreadReceivedTimestamp.mjs +5 -0
- package/dist/esm/serialization/resources/threads/types/ThreadSentTimestamp.d.mts +10 -0
- package/dist/esm/serialization/resources/threads/types/ThreadSentTimestamp.mjs +5 -0
- package/dist/esm/serialization/resources/threads/types/ThreadSize.d.mts +10 -0
- package/dist/esm/serialization/resources/threads/types/ThreadSize.mjs +5 -0
- package/dist/esm/serialization/resources/threads/types/ThreadUpdatedAt.d.mts +10 -0
- package/dist/esm/serialization/resources/threads/types/ThreadUpdatedAt.mjs +5 -0
- package/dist/esm/serialization/resources/threads/types/index.d.mts +6 -0
- package/dist/esm/serialization/resources/threads/types/index.mjs +6 -0
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +1 -1
- package/reference.md +404 -11
|
@@ -27,64 +27,74 @@ export class Webhooks {
|
|
|
27
27
|
* @example
|
|
28
28
|
* await client.webhooks.list()
|
|
29
29
|
*/
|
|
30
|
-
list(
|
|
31
|
-
return core.HttpResponsePromise.fromPromise(this.__list(request, requestOptions));
|
|
32
|
-
}
|
|
33
|
-
__list() {
|
|
30
|
+
list() {
|
|
34
31
|
return __awaiter(this, arguments, void 0, function* (request = {}, requestOptions) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if (_response.ok) {
|
|
55
|
-
return {
|
|
56
|
-
data: serializers.webhooks.ListWebhooksResponse.parseOrThrow(_response.body, {
|
|
57
|
-
unrecognizedObjectKeys: "passthrough",
|
|
58
|
-
allowUnrecognizedUnionMembers: true,
|
|
59
|
-
allowUnrecognizedEnumValues: true,
|
|
60
|
-
skipValidation: true,
|
|
61
|
-
breadcrumbsPrefix: ["response"],
|
|
62
|
-
}),
|
|
63
|
-
rawResponse: _response.rawResponse,
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
if (_response.error.reason === "status-code") {
|
|
67
|
-
throw new errors.AgentMailError({
|
|
68
|
-
statusCode: _response.error.statusCode,
|
|
69
|
-
body: _response.error.body,
|
|
70
|
-
rawResponse: _response.rawResponse,
|
|
32
|
+
const list = core.HttpResponsePromise.interceptFunction((request) => __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
var _a, _b, _c;
|
|
34
|
+
const { limit, pageToken } = request;
|
|
35
|
+
const _queryParams = {};
|
|
36
|
+
if (limit != null) {
|
|
37
|
+
_queryParams["limit"] = limit.toString();
|
|
38
|
+
}
|
|
39
|
+
if (pageToken != null) {
|
|
40
|
+
_queryParams["page_token"] = pageToken;
|
|
41
|
+
}
|
|
42
|
+
let _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
43
|
+
const _response = yield core.fetcher({
|
|
44
|
+
url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.AgentMailEnvironment.Production).http, "/v0/webhooks"),
|
|
45
|
+
method: "GET",
|
|
46
|
+
headers: _headers,
|
|
47
|
+
queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
|
|
48
|
+
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
49
|
+
maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
|
|
50
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
71
51
|
});
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
52
|
+
if (_response.ok) {
|
|
53
|
+
return {
|
|
54
|
+
data: serializers.webhooks.ListWebhooksResponse.parseOrThrow(_response.body, {
|
|
55
|
+
unrecognizedObjectKeys: "passthrough",
|
|
56
|
+
allowUnrecognizedUnionMembers: true,
|
|
57
|
+
allowUnrecognizedEnumValues: true,
|
|
58
|
+
skipValidation: true,
|
|
59
|
+
breadcrumbsPrefix: ["response"],
|
|
60
|
+
}),
|
|
78
61
|
rawResponse: _response.rawResponse,
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
case "unknown":
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
if (_response.error.reason === "status-code") {
|
|
83
65
|
throw new errors.AgentMailError({
|
|
84
|
-
|
|
66
|
+
statusCode: _response.error.statusCode,
|
|
67
|
+
body: _response.error.body,
|
|
85
68
|
rawResponse: _response.rawResponse,
|
|
86
69
|
});
|
|
87
|
-
|
|
70
|
+
}
|
|
71
|
+
switch (_response.error.reason) {
|
|
72
|
+
case "non-json":
|
|
73
|
+
throw new errors.AgentMailError({
|
|
74
|
+
statusCode: _response.error.statusCode,
|
|
75
|
+
body: _response.error.rawBody,
|
|
76
|
+
rawResponse: _response.rawResponse,
|
|
77
|
+
});
|
|
78
|
+
case "timeout":
|
|
79
|
+
throw new errors.AgentMailTimeoutError("Timeout exceeded when calling GET /v0/webhooks.");
|
|
80
|
+
case "unknown":
|
|
81
|
+
throw new errors.AgentMailError({
|
|
82
|
+
message: _response.error.errorMessage,
|
|
83
|
+
rawResponse: _response.rawResponse,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}));
|
|
87
|
+
const dataWithRawResponse = yield list(request).withRawResponse();
|
|
88
|
+
return new core.Pageable({
|
|
89
|
+
response: dataWithRawResponse.data,
|
|
90
|
+
rawResponse: dataWithRawResponse.rawResponse,
|
|
91
|
+
hasNextPage: (response) => (response === null || response === void 0 ? void 0 : response.nextPageToken) != null &&
|
|
92
|
+
!(typeof (response === null || response === void 0 ? void 0 : response.nextPageToken) === "string" && (response === null || response === void 0 ? void 0 : response.nextPageToken) === ""),
|
|
93
|
+
getItems: (response) => { var _a; return (_a = response === null || response === void 0 ? void 0 : response.webhooks) !== null && _a !== void 0 ? _a : []; },
|
|
94
|
+
loadPage: (response) => {
|
|
95
|
+
return list(core.setObjectProperty(request, "pageToken", response === null || response === void 0 ? void 0 : response.nextPageToken));
|
|
96
|
+
},
|
|
97
|
+
});
|
|
88
98
|
});
|
|
89
99
|
}
|
|
90
100
|
/**
|
|
@@ -102,7 +112,7 @@ export class Webhooks {
|
|
|
102
112
|
__get(webhookId, requestOptions) {
|
|
103
113
|
return __awaiter(this, void 0, void 0, function* () {
|
|
104
114
|
var _a, _b, _c;
|
|
105
|
-
|
|
115
|
+
let _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
106
116
|
const _response = yield core.fetcher({
|
|
107
117
|
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/${encodeURIComponent(serializers.webhooks.WebhookId.jsonOrThrow(webhookId, { omitUndefined: true }))}`),
|
|
108
118
|
method: "GET",
|
|
@@ -179,7 +189,7 @@ export class Webhooks {
|
|
|
179
189
|
__create(request, requestOptions) {
|
|
180
190
|
return __awaiter(this, void 0, void 0, function* () {
|
|
181
191
|
var _a, _b, _c;
|
|
182
|
-
|
|
192
|
+
let _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
183
193
|
const _response = yield core.fetcher({
|
|
184
194
|
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"),
|
|
185
195
|
method: "POST",
|
|
@@ -257,7 +267,7 @@ export class Webhooks {
|
|
|
257
267
|
__delete(webhookId, requestOptions) {
|
|
258
268
|
return __awaiter(this, void 0, void 0, function* () {
|
|
259
269
|
var _a, _b, _c;
|
|
260
|
-
|
|
270
|
+
let _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
261
271
|
const _response = yield core.fetcher({
|
|
262
272
|
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/${encodeURIComponent(serializers.webhooks.WebhookId.jsonOrThrow(webhookId, { omitUndefined: true }))}`),
|
|
263
273
|
method: "DELETE",
|
|
@@ -11,7 +11,7 @@ export declare namespace Websockets {
|
|
|
11
11
|
baseUrl?: core.Supplier<string>;
|
|
12
12
|
apiKey?: core.Supplier<core.BearerToken | undefined>;
|
|
13
13
|
/** Additional headers to include in requests. */
|
|
14
|
-
headers?: Record<string, string | core.Supplier<string | undefined> | undefined>;
|
|
14
|
+
headers?: Record<string, string | core.Supplier<string | null | undefined> | null | undefined>;
|
|
15
15
|
}
|
|
16
16
|
interface ConnectArgs {
|
|
17
17
|
authToken?: string | undefined;
|
|
@@ -12,6 +12,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
12
12
|
};
|
|
13
13
|
import * as environments from "../../../../environments.mjs";
|
|
14
14
|
import * as core from "../../../../core/index.mjs";
|
|
15
|
+
import { mergeOnlyDefinedHeaders, mergeHeaders } from "../../../../core/headers.mjs";
|
|
15
16
|
import { WebsocketsSocket } from "./Socket.mjs";
|
|
16
17
|
import * as errors from "../../../../errors/index.mjs";
|
|
17
18
|
export class Websockets {
|
|
@@ -26,7 +27,7 @@ export class Websockets {
|
|
|
26
27
|
if (authToken != null) {
|
|
27
28
|
_queryParams["auth_token"] = authToken;
|
|
28
29
|
}
|
|
29
|
-
let _headers =
|
|
30
|
+
let _headers = mergeHeaders(mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), headers);
|
|
30
31
|
const socket = new core.ReconnectingWebSocket({
|
|
31
32
|
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"),
|
|
32
33
|
protocols: [],
|
|
@@ -6,7 +6,7 @@ export declare namespace Fetcher {
|
|
|
6
6
|
url: string;
|
|
7
7
|
method: string;
|
|
8
8
|
contentType?: string;
|
|
9
|
-
headers?: Record<string, string | Supplier<string | undefined> | undefined>;
|
|
9
|
+
headers?: Record<string, string | Supplier<string | null | undefined> | null | undefined>;
|
|
10
10
|
queryParameters?: Record<string, unknown>;
|
|
11
11
|
body?: unknown;
|
|
12
12
|
timeoutMs?: number;
|
|
@@ -11,21 +11,57 @@ const INITIAL_RETRY_DELAY = 1000; // in milliseconds
|
|
|
11
11
|
const MAX_RETRY_DELAY = 60000; // in milliseconds
|
|
12
12
|
const DEFAULT_MAX_RETRIES = 2;
|
|
13
13
|
const JITTER_FACTOR = 0.2; // 20% random jitter
|
|
14
|
-
function
|
|
15
|
-
// Generate a random value between
|
|
16
|
-
const jitterMultiplier = 1 +
|
|
14
|
+
function addPositiveJitter(delay) {
|
|
15
|
+
// Generate a random value between 0 and +JITTER_FACTOR
|
|
16
|
+
const jitterMultiplier = 1 + Math.random() * JITTER_FACTOR;
|
|
17
17
|
return delay * jitterMultiplier;
|
|
18
18
|
}
|
|
19
|
+
function addSymmetricJitter(delay) {
|
|
20
|
+
// Generate a random value in a JITTER_FACTOR-sized percentage range around delay
|
|
21
|
+
const jitterMultiplier = 1 + (Math.random() - 0.5) * JITTER_FACTOR;
|
|
22
|
+
return delay * jitterMultiplier;
|
|
23
|
+
}
|
|
24
|
+
function getRetryDelayFromHeaders(response, retryAttempt) {
|
|
25
|
+
// Check for Retry-After header first (RFC 7231), with no jitter
|
|
26
|
+
const retryAfter = response.headers.get("Retry-After");
|
|
27
|
+
if (retryAfter) {
|
|
28
|
+
// Parse as number of seconds...
|
|
29
|
+
const retryAfterSeconds = parseInt(retryAfter, 10);
|
|
30
|
+
if (!isNaN(retryAfterSeconds) && retryAfterSeconds > 0) {
|
|
31
|
+
return Math.min(retryAfterSeconds * 1000, MAX_RETRY_DELAY);
|
|
32
|
+
}
|
|
33
|
+
// ...or as an HTTP date; both are valid
|
|
34
|
+
const retryAfterDate = new Date(retryAfter);
|
|
35
|
+
if (!isNaN(retryAfterDate.getTime())) {
|
|
36
|
+
const delay = retryAfterDate.getTime() - Date.now();
|
|
37
|
+
if (delay > 0) {
|
|
38
|
+
return Math.min(Math.max(delay, 0), MAX_RETRY_DELAY);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
// Then check for industry-standard X-RateLimit-Reset header, with positive jitter
|
|
43
|
+
const rateLimitReset = response.headers.get("X-RateLimit-Reset");
|
|
44
|
+
if (rateLimitReset) {
|
|
45
|
+
const resetTime = parseInt(rateLimitReset, 10);
|
|
46
|
+
if (!isNaN(resetTime)) {
|
|
47
|
+
// Assume Unix timestamp in epoch seconds
|
|
48
|
+
const delay = resetTime * 1000 - Date.now();
|
|
49
|
+
if (delay > 0) {
|
|
50
|
+
return addPositiveJitter(Math.min(delay, MAX_RETRY_DELAY));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
// Fall back to exponential backoff, with symmetric jitter
|
|
55
|
+
return addSymmetricJitter(Math.min(INITIAL_RETRY_DELAY * Math.pow(2, retryAttempt), MAX_RETRY_DELAY));
|
|
56
|
+
}
|
|
19
57
|
export function requestWithRetries(requestFn_1) {
|
|
20
58
|
return __awaiter(this, arguments, void 0, function* (requestFn, maxRetries = DEFAULT_MAX_RETRIES) {
|
|
21
59
|
let response = yield requestFn();
|
|
22
60
|
for (let i = 0; i < maxRetries; ++i) {
|
|
23
61
|
if ([408, 429].includes(response.status) || response.status >= 500) {
|
|
24
|
-
//
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
const delayWithJitter = addJitter(baseDelay);
|
|
28
|
-
yield new Promise((resolve) => setTimeout(resolve, delayWithJitter));
|
|
62
|
+
// Get delay with appropriate jitter applied
|
|
63
|
+
const delay = getRetryDelayFromHeaders(response, i);
|
|
64
|
+
yield new Promise((resolve) => setTimeout(resolve, delay));
|
|
29
65
|
response = yield requestFn();
|
|
30
66
|
}
|
|
31
67
|
else {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import * as core from "./index.mjs";
|
|
2
|
-
export declare function mergeHeaders(...headersArray: (Record<string, string | core.Supplier<string | undefined> | undefined> | undefined)[]): Record<string, string | core.Supplier<string | undefined>>;
|
|
3
|
-
export declare function mergeOnlyDefinedHeaders(...headersArray: (Record<string, string | core.Supplier<string | undefined> | undefined> | undefined)[]): Record<string, string | core.Supplier<string | undefined>>;
|
|
2
|
+
export declare function mergeHeaders(...headersArray: (Record<string, string | core.Supplier<string | null | undefined> | null | undefined> | null | undefined)[]): Record<string, string | core.Supplier<string | null | undefined>>;
|
|
3
|
+
export declare function mergeOnlyDefinedHeaders(...headersArray: (Record<string, string | core.Supplier<string | null | undefined> | null | undefined> | null | undefined)[]): Record<string, string | core.Supplier<string | null | undefined>>;
|
package/dist/esm/core/index.mjs
CHANGED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { HttpResponsePromise, RawResponse } from "../fetcher/index.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* A page of results from a paginated API.
|
|
4
|
+
*
|
|
5
|
+
* @template T The type of the items in the page.
|
|
6
|
+
*/
|
|
7
|
+
export declare class Page<T> implements AsyncIterable<T> {
|
|
8
|
+
data: T[];
|
|
9
|
+
rawResponse: RawResponse;
|
|
10
|
+
private response;
|
|
11
|
+
private _hasNextPage;
|
|
12
|
+
private getItems;
|
|
13
|
+
private loadNextPage;
|
|
14
|
+
constructor({ response, rawResponse, hasNextPage, getItems, loadPage, }: {
|
|
15
|
+
response: unknown;
|
|
16
|
+
rawResponse: RawResponse;
|
|
17
|
+
hasNextPage: (response: unknown) => boolean;
|
|
18
|
+
getItems: (response: unknown) => T[];
|
|
19
|
+
loadPage: (response: unknown) => HttpResponsePromise<any>;
|
|
20
|
+
});
|
|
21
|
+
/**
|
|
22
|
+
* Retrieves the next page
|
|
23
|
+
* @returns this
|
|
24
|
+
*/
|
|
25
|
+
getNextPage(): Promise<this>;
|
|
26
|
+
/**
|
|
27
|
+
* @returns whether there is a next page to load
|
|
28
|
+
*/
|
|
29
|
+
hasNextPage(): boolean;
|
|
30
|
+
private iterMessages;
|
|
31
|
+
[Symbol.asyncIterator](): AsyncIterator<T, void, any>;
|
|
32
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
|
11
|
+
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
|
12
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
13
|
+
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
14
|
+
return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
15
|
+
function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
|
|
16
|
+
function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
|
|
17
|
+
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
18
|
+
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
19
|
+
function fulfill(value) { resume("next", value); }
|
|
20
|
+
function reject(value) { resume("throw", value); }
|
|
21
|
+
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
22
|
+
};
|
|
23
|
+
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
24
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
25
|
+
var m = o[Symbol.asyncIterator], i;
|
|
26
|
+
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
27
|
+
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
28
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* A page of results from a paginated API.
|
|
32
|
+
*
|
|
33
|
+
* @template T The type of the items in the page.
|
|
34
|
+
*/
|
|
35
|
+
export class Page {
|
|
36
|
+
constructor({ response, rawResponse, hasNextPage, getItems, loadPage, }) {
|
|
37
|
+
this.response = response;
|
|
38
|
+
this.rawResponse = rawResponse;
|
|
39
|
+
this.data = getItems(response);
|
|
40
|
+
this._hasNextPage = hasNextPage;
|
|
41
|
+
this.getItems = getItems;
|
|
42
|
+
this.loadNextPage = loadPage;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Retrieves the next page
|
|
46
|
+
* @returns this
|
|
47
|
+
*/
|
|
48
|
+
getNextPage() {
|
|
49
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
const { data, rawResponse } = yield this.loadNextPage(this.response).withRawResponse();
|
|
51
|
+
this.response = data;
|
|
52
|
+
this.rawResponse = rawResponse;
|
|
53
|
+
this.data = this.getItems(this.response);
|
|
54
|
+
return this;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* @returns whether there is a next page to load
|
|
59
|
+
*/
|
|
60
|
+
hasNextPage() {
|
|
61
|
+
return this._hasNextPage(this.response);
|
|
62
|
+
}
|
|
63
|
+
iterMessages() {
|
|
64
|
+
return __asyncGenerator(this, arguments, function* iterMessages_1() {
|
|
65
|
+
for (const item of this.data) {
|
|
66
|
+
yield yield __await(item);
|
|
67
|
+
}
|
|
68
|
+
while (this.hasNextPage()) {
|
|
69
|
+
yield __await(this.getNextPage());
|
|
70
|
+
for (const item of this.data) {
|
|
71
|
+
yield yield __await(item);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
[Symbol.asyncIterator]() {
|
|
77
|
+
return __asyncGenerator(this, arguments, function* _a() {
|
|
78
|
+
var _b, e_1, _c, _d;
|
|
79
|
+
try {
|
|
80
|
+
for (var _e = true, _f = __asyncValues(this.iterMessages()), _g; _g = yield __await(_f.next()), _b = _g.done, !_b; _e = true) {
|
|
81
|
+
_d = _g.value;
|
|
82
|
+
_e = false;
|
|
83
|
+
const message = _d;
|
|
84
|
+
yield yield __await(message);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
88
|
+
finally {
|
|
89
|
+
try {
|
|
90
|
+
if (!_e && !_b && (_c = _f.return)) yield __await(_c.call(_f));
|
|
91
|
+
}
|
|
92
|
+
finally { if (e_1) throw e_1.error; }
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { RawResponse } from "../fetcher/index.mjs";
|
|
2
|
+
import { Page } from "./Page.mjs";
|
|
3
|
+
export declare namespace Pageable {
|
|
4
|
+
interface Args<Response, Item> {
|
|
5
|
+
response: Response;
|
|
6
|
+
rawResponse: RawResponse;
|
|
7
|
+
hasNextPage: (response: Response) => boolean;
|
|
8
|
+
getItems: (response: Response) => Item[];
|
|
9
|
+
loadPage: (response: Response) => Promise<Response>;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export declare class Pageable<R, T> extends Page<T> {
|
|
13
|
+
constructor(args: Pageable.Args<R, T>);
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { setObjectProperty } from "./setObjectProperty.mjs";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { setObjectProperty } from "./setObjectProperty.mjs";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sets the value at path of object. If a portion of path doesn’t exist it’s created. This is
|
|
3
|
+
* inspired by Lodash's set function, but is simplified to accommodate our use case.
|
|
4
|
+
* For more details, see https://lodash.com/docs/4.17.15#set.
|
|
5
|
+
*
|
|
6
|
+
* @param object The object to modify.
|
|
7
|
+
* @param path The path of the property to set.
|
|
8
|
+
* @param value The value to set.
|
|
9
|
+
* @return Returns object.
|
|
10
|
+
*/
|
|
11
|
+
export declare function setObjectProperty<T extends object>(object: T, path: string, value: any): T;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sets the value at path of object. If a portion of path doesn’t exist it’s created. This is
|
|
3
|
+
* inspired by Lodash's set function, but is simplified to accommodate our use case.
|
|
4
|
+
* For more details, see https://lodash.com/docs/4.17.15#set.
|
|
5
|
+
*
|
|
6
|
+
* @param object The object to modify.
|
|
7
|
+
* @param path The path of the property to set.
|
|
8
|
+
* @param value The value to set.
|
|
9
|
+
* @return Returns object.
|
|
10
|
+
*/
|
|
11
|
+
export function setObjectProperty(object, path, value) {
|
|
12
|
+
if (object == null) {
|
|
13
|
+
return object;
|
|
14
|
+
}
|
|
15
|
+
const keys = path.split(".");
|
|
16
|
+
if (keys.length === 0) {
|
|
17
|
+
// Invalid path; do nothing.
|
|
18
|
+
return object;
|
|
19
|
+
}
|
|
20
|
+
let current = object;
|
|
21
|
+
for (let i = 0; i < keys.length - 1; i++) {
|
|
22
|
+
const key = keys[i];
|
|
23
|
+
if (key == null) {
|
|
24
|
+
// Unreachable.
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
if (!current[key] || typeof current[key] !== "object") {
|
|
28
|
+
current[key] = {};
|
|
29
|
+
}
|
|
30
|
+
current = current[key];
|
|
31
|
+
}
|
|
32
|
+
const lastKey = keys[keys.length - 1];
|
|
33
|
+
if (lastKey == null) {
|
|
34
|
+
// Unreachable.
|
|
35
|
+
return object;
|
|
36
|
+
}
|
|
37
|
+
current[lastKey] = value;
|
|
38
|
+
return object;
|
|
39
|
+
}
|
|
@@ -7,7 +7,7 @@ export declare namespace ReconnectingWebSocket {
|
|
|
7
7
|
url: string;
|
|
8
8
|
protocols?: string | string[];
|
|
9
9
|
options?: ReconnectingWebSocket.Options;
|
|
10
|
-
headers?: Record<string,
|
|
10
|
+
headers?: Record<string, unknown>;
|
|
11
11
|
queryParameters?: Record<string, string | string[] | object | object[] | null | undefined>;
|
|
12
12
|
}
|
|
13
13
|
type Options = {
|
|
@@ -18,6 +18,11 @@ import { MessagePreview } from "./MessagePreview.mjs";
|
|
|
18
18
|
import { MessageText } from "./MessageText.mjs";
|
|
19
19
|
import { MessageHtml } from "./MessageHtml.mjs";
|
|
20
20
|
import { MessageAttachments } from "./MessageAttachments.mjs";
|
|
21
|
+
import { MessageInReplyTo } from "./MessageInReplyTo.mjs";
|
|
22
|
+
import { MessageReferences } from "./MessageReferences.mjs";
|
|
23
|
+
import { MessageSize } from "./MessageSize.mjs";
|
|
24
|
+
import { MessageUpdatedAt } from "./MessageUpdatedAt.mjs";
|
|
25
|
+
import { MessageCreatedAt } from "./MessageCreatedAt.mjs";
|
|
21
26
|
export declare const Message: core.serialization.ObjectSchema<serializers.Message.Raw, AgentMail.Message>;
|
|
22
27
|
export declare namespace Message {
|
|
23
28
|
interface Raw {
|
|
@@ -36,9 +41,10 @@ export declare namespace Message {
|
|
|
36
41
|
text?: MessageText.Raw | null;
|
|
37
42
|
html?: MessageHtml.Raw | null;
|
|
38
43
|
attachments?: MessageAttachments.Raw | null;
|
|
39
|
-
in_reply_to?:
|
|
40
|
-
references?:
|
|
41
|
-
|
|
42
|
-
|
|
44
|
+
in_reply_to?: MessageInReplyTo.Raw | null;
|
|
45
|
+
references?: MessageReferences.Raw | null;
|
|
46
|
+
size: MessageSize.Raw;
|
|
47
|
+
updated_at: MessageUpdatedAt.Raw;
|
|
48
|
+
created_at: MessageCreatedAt.Raw;
|
|
43
49
|
}
|
|
44
50
|
}
|
|
@@ -16,6 +16,11 @@ import { MessagePreview } from "./MessagePreview.mjs";
|
|
|
16
16
|
import { MessageText } from "./MessageText.mjs";
|
|
17
17
|
import { MessageHtml } from "./MessageHtml.mjs";
|
|
18
18
|
import { MessageAttachments } from "./MessageAttachments.mjs";
|
|
19
|
+
import { MessageInReplyTo } from "./MessageInReplyTo.mjs";
|
|
20
|
+
import { MessageReferences } from "./MessageReferences.mjs";
|
|
21
|
+
import { MessageSize } from "./MessageSize.mjs";
|
|
22
|
+
import { MessageUpdatedAt } from "./MessageUpdatedAt.mjs";
|
|
23
|
+
import { MessageCreatedAt } from "./MessageCreatedAt.mjs";
|
|
19
24
|
export const Message = core.serialization.object({
|
|
20
25
|
inboxId: core.serialization.property("inbox_id", InboxId),
|
|
21
26
|
threadId: core.serialization.property("thread_id", ThreadId),
|
|
@@ -32,8 +37,9 @@ export const Message = core.serialization.object({
|
|
|
32
37
|
text: MessageText.optional(),
|
|
33
38
|
html: MessageHtml.optional(),
|
|
34
39
|
attachments: MessageAttachments.optional(),
|
|
35
|
-
inReplyTo: core.serialization.property("in_reply_to",
|
|
36
|
-
references:
|
|
37
|
-
|
|
38
|
-
|
|
40
|
+
inReplyTo: core.serialization.property("in_reply_to", MessageInReplyTo.optional()),
|
|
41
|
+
references: MessageReferences.optional(),
|
|
42
|
+
size: MessageSize,
|
|
43
|
+
updatedAt: core.serialization.property("updated_at", MessageUpdatedAt),
|
|
44
|
+
createdAt: core.serialization.property("created_at", MessageCreatedAt),
|
|
39
45
|
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
*/
|
|
4
|
+
import * as serializers from "../../../index.mjs";
|
|
5
|
+
import * as AgentMail from "../../../../api/index.mjs";
|
|
6
|
+
import * as core from "../../../../core/index.mjs";
|
|
7
|
+
export declare const MessageCreatedAt: core.serialization.Schema<serializers.MessageCreatedAt.Raw, AgentMail.MessageCreatedAt>;
|
|
8
|
+
export declare namespace MessageCreatedAt {
|
|
9
|
+
type Raw = string;
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
*/
|
|
4
|
+
import * as serializers from "../../../index.mjs";
|
|
5
|
+
import * as AgentMail from "../../../../api/index.mjs";
|
|
6
|
+
import * as core from "../../../../core/index.mjs";
|
|
7
|
+
export declare const MessageInReplyTo: core.serialization.Schema<serializers.MessageInReplyTo.Raw, AgentMail.MessageInReplyTo>;
|
|
8
|
+
export declare namespace MessageInReplyTo {
|
|
9
|
+
type Raw = string;
|
|
10
|
+
}
|
|
@@ -16,6 +16,11 @@ import { MessageBcc } from "./MessageBcc.mjs";
|
|
|
16
16
|
import { MessageSubject } from "./MessageSubject.mjs";
|
|
17
17
|
import { MessagePreview } from "./MessagePreview.mjs";
|
|
18
18
|
import { MessageAttachments } from "./MessageAttachments.mjs";
|
|
19
|
+
import { MessageInReplyTo } from "./MessageInReplyTo.mjs";
|
|
20
|
+
import { MessageReferences } from "./MessageReferences.mjs";
|
|
21
|
+
import { MessageSize } from "./MessageSize.mjs";
|
|
22
|
+
import { MessageUpdatedAt } from "./MessageUpdatedAt.mjs";
|
|
23
|
+
import { MessageCreatedAt } from "./MessageCreatedAt.mjs";
|
|
19
24
|
export declare const MessageItem: core.serialization.ObjectSchema<serializers.MessageItem.Raw, AgentMail.MessageItem>;
|
|
20
25
|
export declare namespace MessageItem {
|
|
21
26
|
interface Raw {
|
|
@@ -31,5 +36,10 @@ export declare namespace MessageItem {
|
|
|
31
36
|
subject?: MessageSubject.Raw | null;
|
|
32
37
|
preview?: MessagePreview.Raw | null;
|
|
33
38
|
attachments?: MessageAttachments.Raw | null;
|
|
39
|
+
in_reply_to?: MessageInReplyTo.Raw | null;
|
|
40
|
+
references?: MessageReferences.Raw | null;
|
|
41
|
+
size: MessageSize.Raw;
|
|
42
|
+
updated_at: MessageUpdatedAt.Raw;
|
|
43
|
+
created_at: MessageCreatedAt.Raw;
|
|
34
44
|
}
|
|
35
45
|
}
|