agentmail 0.0.78 → 0.1.0
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.js +2 -2
- package/dist/cjs/api/resources/apiKeys/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/apiKeys/client/Client.js +62 -52
- package/dist/cjs/api/resources/domains/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/domains/client/Client.js +62 -52
- package/dist/cjs/api/resources/drafts/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/drafts/client/Client.js +83 -70
- package/dist/cjs/api/resources/inboxes/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/inboxes/client/Client.js +62 -52
- package/dist/cjs/api/resources/inboxes/resources/drafts/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/inboxes/resources/drafts/client/Client.js +83 -70
- package/dist/cjs/api/resources/inboxes/resources/messages/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/inboxes/resources/messages/client/Client.js +83 -70
- package/dist/cjs/api/resources/inboxes/resources/threads/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/inboxes/resources/threads/client/Client.js +83 -70
- package/dist/cjs/api/resources/pods/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/pods/client/Client.js +62 -52
- package/dist/cjs/api/resources/pods/resources/domains/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/pods/resources/domains/client/Client.js +83 -70
- package/dist/cjs/api/resources/pods/resources/drafts/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/pods/resources/drafts/client/Client.js +83 -70
- package/dist/cjs/api/resources/pods/resources/inboxes/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/pods/resources/inboxes/client/Client.js +83 -70
- package/dist/cjs/api/resources/pods/resources/threads/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/pods/resources/threads/client/Client.js +83 -70
- package/dist/cjs/api/resources/threads/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/threads/client/Client.js +83 -70
- package/dist/cjs/api/resources/webhooks/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/webhooks/client/Client.js +62 -52
- 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/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/Client.mjs +2 -2
- package/dist/esm/api/resources/apiKeys/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/apiKeys/client/Client.mjs +62 -52
- package/dist/esm/api/resources/domains/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/domains/client/Client.mjs +62 -52
- package/dist/esm/api/resources/drafts/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/drafts/client/Client.mjs +83 -70
- package/dist/esm/api/resources/inboxes/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/inboxes/client/Client.mjs +62 -52
- package/dist/esm/api/resources/inboxes/resources/drafts/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/inboxes/resources/drafts/client/Client.mjs +83 -70
- package/dist/esm/api/resources/inboxes/resources/messages/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/inboxes/resources/messages/client/Client.mjs +83 -70
- package/dist/esm/api/resources/inboxes/resources/threads/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/inboxes/resources/threads/client/Client.mjs +83 -70
- package/dist/esm/api/resources/pods/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/pods/client/Client.mjs +62 -52
- package/dist/esm/api/resources/pods/resources/domains/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/pods/resources/domains/client/Client.mjs +83 -70
- package/dist/esm/api/resources/pods/resources/drafts/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/pods/resources/drafts/client/Client.mjs +83 -70
- package/dist/esm/api/resources/pods/resources/inboxes/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/pods/resources/inboxes/client/Client.mjs +83 -70
- package/dist/esm/api/resources/pods/resources/threads/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/pods/resources/threads/client/Client.mjs +83 -70
- package/dist/esm/api/resources/threads/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/threads/client/Client.mjs +83 -70
- package/dist/esm/api/resources/webhooks/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/webhooks/client/Client.mjs +62 -52
- 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/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +1 -1
- package/reference.md +154 -28
|
@@ -64,87 +64,100 @@ class Threads {
|
|
|
64
64
|
* @example
|
|
65
65
|
* await client.threads.list()
|
|
66
66
|
*/
|
|
67
|
-
list(
|
|
68
|
-
return core.HttpResponsePromise.fromPromise(this.__list(request, requestOptions));
|
|
69
|
-
}
|
|
70
|
-
__list() {
|
|
67
|
+
list() {
|
|
71
68
|
return __awaiter(this, arguments, void 0, function* (request = {}, requestOptions) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
headers:
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
breadcrumbsPrefix: ["response"],
|
|
111
|
-
}),
|
|
112
|
-
rawResponse: _response.rawResponse,
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
if (_response.error.reason === "status-code") {
|
|
116
|
-
switch (_response.error.statusCode) {
|
|
117
|
-
case 404:
|
|
118
|
-
throw new AgentMail.NotFoundError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
|
|
69
|
+
const list = core.HttpResponsePromise.interceptFunction((request) => __awaiter(this, void 0, void 0, function* () {
|
|
70
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
71
|
+
const { limit, pageToken, labels, before, after, ascending } = request;
|
|
72
|
+
const _queryParams = {};
|
|
73
|
+
if (limit != null) {
|
|
74
|
+
_queryParams.limit = limit.toString();
|
|
75
|
+
}
|
|
76
|
+
if (pageToken != null) {
|
|
77
|
+
_queryParams.page_token = pageToken;
|
|
78
|
+
}
|
|
79
|
+
if (labels != null) {
|
|
80
|
+
_queryParams.labels = (0, json_js_1.toJson)(serializers.Labels.jsonOrThrow(labels, {
|
|
81
|
+
unrecognizedObjectKeys: "strip",
|
|
82
|
+
omitUndefined: true,
|
|
83
|
+
}));
|
|
84
|
+
}
|
|
85
|
+
if (before != null) {
|
|
86
|
+
_queryParams.before = before.toISOString();
|
|
87
|
+
}
|
|
88
|
+
if (after != null) {
|
|
89
|
+
_queryParams.after = after.toISOString();
|
|
90
|
+
}
|
|
91
|
+
if (ascending != null) {
|
|
92
|
+
_queryParams.ascending = ascending.toString();
|
|
93
|
+
}
|
|
94
|
+
const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
95
|
+
const _response = yield core.fetcher({
|
|
96
|
+
url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.AgentMailEnvironment.Production).http, "/v0/threads"),
|
|
97
|
+
method: "GET",
|
|
98
|
+
headers: _headers,
|
|
99
|
+
queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
|
|
100
|
+
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,
|
|
101
|
+
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,
|
|
102
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
103
|
+
});
|
|
104
|
+
if (_response.ok) {
|
|
105
|
+
return {
|
|
106
|
+
data: serializers.ListThreadsResponse.parseOrThrow(_response.body, {
|
|
119
107
|
unrecognizedObjectKeys: "passthrough",
|
|
120
108
|
allowUnrecognizedUnionMembers: true,
|
|
121
109
|
allowUnrecognizedEnumValues: true,
|
|
122
110
|
skipValidation: true,
|
|
123
111
|
breadcrumbsPrefix: ["response"],
|
|
124
|
-
}),
|
|
125
|
-
|
|
112
|
+
}),
|
|
113
|
+
rawResponse: _response.rawResponse,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
if (_response.error.reason === "status-code") {
|
|
117
|
+
switch (_response.error.statusCode) {
|
|
118
|
+
case 404:
|
|
119
|
+
throw new AgentMail.NotFoundError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
|
|
120
|
+
unrecognizedObjectKeys: "passthrough",
|
|
121
|
+
allowUnrecognizedUnionMembers: true,
|
|
122
|
+
allowUnrecognizedEnumValues: true,
|
|
123
|
+
skipValidation: true,
|
|
124
|
+
breadcrumbsPrefix: ["response"],
|
|
125
|
+
}), _response.rawResponse);
|
|
126
|
+
default:
|
|
127
|
+
throw new errors.AgentMailError({
|
|
128
|
+
statusCode: _response.error.statusCode,
|
|
129
|
+
body: _response.error.body,
|
|
130
|
+
rawResponse: _response.rawResponse,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
switch (_response.error.reason) {
|
|
135
|
+
case "non-json":
|
|
126
136
|
throw new errors.AgentMailError({
|
|
127
137
|
statusCode: _response.error.statusCode,
|
|
128
|
-
body: _response.error.
|
|
138
|
+
body: _response.error.rawBody,
|
|
139
|
+
rawResponse: _response.rawResponse,
|
|
140
|
+
});
|
|
141
|
+
case "timeout":
|
|
142
|
+
throw new errors.AgentMailTimeoutError("Timeout exceeded when calling GET /v0/threads.");
|
|
143
|
+
case "unknown":
|
|
144
|
+
throw new errors.AgentMailError({
|
|
145
|
+
message: _response.error.errorMessage,
|
|
129
146
|
rawResponse: _response.rawResponse,
|
|
130
147
|
});
|
|
131
148
|
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
message: _response.error.errorMessage,
|
|
145
|
-
rawResponse: _response.rawResponse,
|
|
146
|
-
});
|
|
147
|
-
}
|
|
149
|
+
}));
|
|
150
|
+
const dataWithRawResponse = yield list(request).withRawResponse();
|
|
151
|
+
return new core.Pageable({
|
|
152
|
+
response: dataWithRawResponse.data,
|
|
153
|
+
rawResponse: dataWithRawResponse.rawResponse,
|
|
154
|
+
hasNextPage: (response) => (response === null || response === void 0 ? void 0 : response.nextPageToken) != null &&
|
|
155
|
+
!(typeof (response === null || response === void 0 ? void 0 : response.nextPageToken) === "string" && (response === null || response === void 0 ? void 0 : response.nextPageToken) === ""),
|
|
156
|
+
getItems: (response) => { var _a; return (_a = response === null || response === void 0 ? void 0 : response.threads) !== null && _a !== void 0 ? _a : []; },
|
|
157
|
+
loadPage: (response) => {
|
|
158
|
+
return list(core.setObjectProperty(request, "pageToken", response === null || response === void 0 ? void 0 : response.nextPageToken));
|
|
159
|
+
},
|
|
160
|
+
});
|
|
148
161
|
});
|
|
149
162
|
}
|
|
150
163
|
/**
|
|
@@ -17,8 +17,7 @@ export declare class Webhooks {
|
|
|
17
17
|
* @example
|
|
18
18
|
* await client.webhooks.list()
|
|
19
19
|
*/
|
|
20
|
-
list(request?: AgentMail.webhooks.ListWebhooksRequest, requestOptions?: Webhooks.RequestOptions): core.
|
|
21
|
-
private __list;
|
|
20
|
+
list(request?: AgentMail.webhooks.ListWebhooksRequest, requestOptions?: Webhooks.RequestOptions): Promise<core.Page<AgentMail.webhooks.Webhook>>;
|
|
22
21
|
/**
|
|
23
22
|
* @param {AgentMail.webhooks.WebhookId} webhookId
|
|
24
23
|
* @param {Webhooks.RequestOptions} requestOptions - Request-specific configuration.
|
|
@@ -61,64 +61,74 @@ class Webhooks {
|
|
|
61
61
|
* @example
|
|
62
62
|
* await client.webhooks.list()
|
|
63
63
|
*/
|
|
64
|
-
list(
|
|
65
|
-
return core.HttpResponsePromise.fromPromise(this.__list(request, requestOptions));
|
|
66
|
-
}
|
|
67
|
-
__list() {
|
|
64
|
+
list() {
|
|
68
65
|
return __awaiter(this, arguments, void 0, function* (request = {}, requestOptions) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
if (_response.ok) {
|
|
89
|
-
return {
|
|
90
|
-
data: serializers.webhooks.ListWebhooksResponse.parseOrThrow(_response.body, {
|
|
91
|
-
unrecognizedObjectKeys: "passthrough",
|
|
92
|
-
allowUnrecognizedUnionMembers: true,
|
|
93
|
-
allowUnrecognizedEnumValues: true,
|
|
94
|
-
skipValidation: true,
|
|
95
|
-
breadcrumbsPrefix: ["response"],
|
|
96
|
-
}),
|
|
97
|
-
rawResponse: _response.rawResponse,
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
if (_response.error.reason === "status-code") {
|
|
101
|
-
throw new errors.AgentMailError({
|
|
102
|
-
statusCode: _response.error.statusCode,
|
|
103
|
-
body: _response.error.body,
|
|
104
|
-
rawResponse: _response.rawResponse,
|
|
66
|
+
const list = core.HttpResponsePromise.interceptFunction((request) => __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
68
|
+
const { limit, pageToken } = request;
|
|
69
|
+
const _queryParams = {};
|
|
70
|
+
if (limit != null) {
|
|
71
|
+
_queryParams.limit = limit.toString();
|
|
72
|
+
}
|
|
73
|
+
if (pageToken != null) {
|
|
74
|
+
_queryParams.page_token = pageToken;
|
|
75
|
+
}
|
|
76
|
+
const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
77
|
+
const _response = yield core.fetcher({
|
|
78
|
+
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"),
|
|
79
|
+
method: "GET",
|
|
80
|
+
headers: _headers,
|
|
81
|
+
queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
|
|
82
|
+
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,
|
|
83
|
+
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,
|
|
84
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
105
85
|
});
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
86
|
+
if (_response.ok) {
|
|
87
|
+
return {
|
|
88
|
+
data: serializers.webhooks.ListWebhooksResponse.parseOrThrow(_response.body, {
|
|
89
|
+
unrecognizedObjectKeys: "passthrough",
|
|
90
|
+
allowUnrecognizedUnionMembers: true,
|
|
91
|
+
allowUnrecognizedEnumValues: true,
|
|
92
|
+
skipValidation: true,
|
|
93
|
+
breadcrumbsPrefix: ["response"],
|
|
94
|
+
}),
|
|
112
95
|
rawResponse: _response.rawResponse,
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
case "unknown":
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
if (_response.error.reason === "status-code") {
|
|
117
99
|
throw new errors.AgentMailError({
|
|
118
|
-
|
|
100
|
+
statusCode: _response.error.statusCode,
|
|
101
|
+
body: _response.error.body,
|
|
119
102
|
rawResponse: _response.rawResponse,
|
|
120
103
|
});
|
|
121
|
-
|
|
104
|
+
}
|
|
105
|
+
switch (_response.error.reason) {
|
|
106
|
+
case "non-json":
|
|
107
|
+
throw new errors.AgentMailError({
|
|
108
|
+
statusCode: _response.error.statusCode,
|
|
109
|
+
body: _response.error.rawBody,
|
|
110
|
+
rawResponse: _response.rawResponse,
|
|
111
|
+
});
|
|
112
|
+
case "timeout":
|
|
113
|
+
throw new errors.AgentMailTimeoutError("Timeout exceeded when calling GET /v0/webhooks.");
|
|
114
|
+
case "unknown":
|
|
115
|
+
throw new errors.AgentMailError({
|
|
116
|
+
message: _response.error.errorMessage,
|
|
117
|
+
rawResponse: _response.rawResponse,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}));
|
|
121
|
+
const dataWithRawResponse = yield list(request).withRawResponse();
|
|
122
|
+
return new core.Pageable({
|
|
123
|
+
response: dataWithRawResponse.data,
|
|
124
|
+
rawResponse: dataWithRawResponse.rawResponse,
|
|
125
|
+
hasNextPage: (response) => (response === null || response === void 0 ? void 0 : response.nextPageToken) != null &&
|
|
126
|
+
!(typeof (response === null || response === void 0 ? void 0 : response.nextPageToken) === "string" && (response === null || response === void 0 ? void 0 : response.nextPageToken) === ""),
|
|
127
|
+
getItems: (response) => { var _a; return (_a = response === null || response === void 0 ? void 0 : response.webhooks) !== null && _a !== void 0 ? _a : []; },
|
|
128
|
+
loadPage: (response) => {
|
|
129
|
+
return list(core.setObjectProperty(request, "pageToken", response === null || response === void 0 ? void 0 : response.nextPageToken));
|
|
130
|
+
},
|
|
131
|
+
});
|
|
122
132
|
});
|
|
123
133
|
}
|
|
124
134
|
/**
|
package/dist/cjs/core/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export * from "./auth/index.js";
|
|
2
2
|
export * from "./base64.js";
|
|
3
3
|
export * from "./fetcher/index.js";
|
|
4
|
+
export * from "./pagination/index.js";
|
|
4
5
|
export * from "./runtime/index.js";
|
|
5
6
|
export * as serialization from "./schemas/index.js";
|
|
6
7
|
export * as url from "./url/index.js";
|
|
8
|
+
export * from "./utils/index.js";
|
|
7
9
|
export * from "./websocket/index.js";
|
package/dist/cjs/core/index.js
CHANGED
|
@@ -40,7 +40,9 @@ exports.url = exports.serialization = void 0;
|
|
|
40
40
|
__exportStar(require("./auth/index.js"), exports);
|
|
41
41
|
__exportStar(require("./base64.js"), exports);
|
|
42
42
|
__exportStar(require("./fetcher/index.js"), exports);
|
|
43
|
+
__exportStar(require("./pagination/index.js"), exports);
|
|
43
44
|
__exportStar(require("./runtime/index.js"), exports);
|
|
44
45
|
exports.serialization = __importStar(require("./schemas/index.js"));
|
|
45
46
|
exports.url = __importStar(require("./url/index.js"));
|
|
47
|
+
__exportStar(require("./utils/index.js"), exports);
|
|
46
48
|
__exportStar(require("./websocket/index.js"), exports);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { HttpResponsePromise, RawResponse } from "../fetcher/index.js";
|
|
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,100 @@
|
|
|
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
|
+
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
|
12
|
+
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
|
13
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
14
|
+
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
15
|
+
return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
16
|
+
function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
|
|
17
|
+
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]); } }
|
|
18
|
+
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
19
|
+
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
20
|
+
function fulfill(value) { resume("next", value); }
|
|
21
|
+
function reject(value) { resume("throw", value); }
|
|
22
|
+
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
23
|
+
};
|
|
24
|
+
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
25
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
26
|
+
var m = o[Symbol.asyncIterator], i;
|
|
27
|
+
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);
|
|
28
|
+
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); }); }; }
|
|
29
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
30
|
+
};
|
|
31
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
+
exports.Page = void 0;
|
|
33
|
+
/**
|
|
34
|
+
* A page of results from a paginated API.
|
|
35
|
+
*
|
|
36
|
+
* @template T The type of the items in the page.
|
|
37
|
+
*/
|
|
38
|
+
class Page {
|
|
39
|
+
constructor({ response, rawResponse, hasNextPage, getItems, loadPage, }) {
|
|
40
|
+
this.response = response;
|
|
41
|
+
this.rawResponse = rawResponse;
|
|
42
|
+
this.data = getItems(response);
|
|
43
|
+
this._hasNextPage = hasNextPage;
|
|
44
|
+
this.getItems = getItems;
|
|
45
|
+
this.loadNextPage = loadPage;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Retrieves the next page
|
|
49
|
+
* @returns this
|
|
50
|
+
*/
|
|
51
|
+
getNextPage() {
|
|
52
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
const { data, rawResponse } = yield this.loadNextPage(this.response).withRawResponse();
|
|
54
|
+
this.response = data;
|
|
55
|
+
this.rawResponse = rawResponse;
|
|
56
|
+
this.data = this.getItems(this.response);
|
|
57
|
+
return this;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* @returns whether there is a next page to load
|
|
62
|
+
*/
|
|
63
|
+
hasNextPage() {
|
|
64
|
+
return this._hasNextPage(this.response);
|
|
65
|
+
}
|
|
66
|
+
iterMessages() {
|
|
67
|
+
return __asyncGenerator(this, arguments, function* iterMessages_1() {
|
|
68
|
+
for (const item of this.data) {
|
|
69
|
+
yield yield __await(item);
|
|
70
|
+
}
|
|
71
|
+
while (this.hasNextPage()) {
|
|
72
|
+
yield __await(this.getNextPage());
|
|
73
|
+
for (const item of this.data) {
|
|
74
|
+
yield yield __await(item);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
[Symbol.asyncIterator]() {
|
|
80
|
+
return __asyncGenerator(this, arguments, function* _a() {
|
|
81
|
+
var _b, e_1, _c, _d;
|
|
82
|
+
try {
|
|
83
|
+
for (var _e = true, _f = __asyncValues(this.iterMessages()), _g; _g = yield __await(_f.next()), _b = _g.done, !_b; _e = true) {
|
|
84
|
+
_d = _g.value;
|
|
85
|
+
_e = false;
|
|
86
|
+
const message = _d;
|
|
87
|
+
yield yield __await(message);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
91
|
+
finally {
|
|
92
|
+
try {
|
|
93
|
+
if (!_e && !_b && (_c = _f.return)) yield __await(_c.call(_f));
|
|
94
|
+
}
|
|
95
|
+
finally { if (e_1) throw e_1.error; }
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
exports.Page = Page;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { RawResponse } from "../fetcher/index.js";
|
|
2
|
+
import { Page } from "./Page.js";
|
|
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,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Pageable = void 0;
|
|
4
|
+
const Page_js_1 = require("./Page.js");
|
|
5
|
+
class Pageable extends Page_js_1.Page {
|
|
6
|
+
constructor(args) {
|
|
7
|
+
super(args);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.Pageable = Pageable;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Pageable = exports.Page = void 0;
|
|
4
|
+
var Page_js_1 = require("./Page.js");
|
|
5
|
+
Object.defineProperty(exports, "Page", { enumerable: true, get: function () { return Page_js_1.Page; } });
|
|
6
|
+
var Pageable_js_1 = require("./Pageable.js");
|
|
7
|
+
Object.defineProperty(exports, "Pageable", { enumerable: true, get: function () { return Pageable_js_1.Pageable; } });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { setObjectProperty } from "./setObjectProperty.js";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setObjectProperty = void 0;
|
|
4
|
+
var setObjectProperty_js_1 = require("./setObjectProperty.js");
|
|
5
|
+
Object.defineProperty(exports, "setObjectProperty", { enumerable: true, get: function () { return setObjectProperty_js_1.setObjectProperty; } });
|
|
@@ -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,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setObjectProperty = setObjectProperty;
|
|
4
|
+
/**
|
|
5
|
+
* Sets the value at path of object. If a portion of path doesn’t exist it’s created. This is
|
|
6
|
+
* inspired by Lodash's set function, but is simplified to accommodate our use case.
|
|
7
|
+
* For more details, see https://lodash.com/docs/4.17.15#set.
|
|
8
|
+
*
|
|
9
|
+
* @param object The object to modify.
|
|
10
|
+
* @param path The path of the property to set.
|
|
11
|
+
* @param value The value to set.
|
|
12
|
+
* @return Returns object.
|
|
13
|
+
*/
|
|
14
|
+
function setObjectProperty(object, path, value) {
|
|
15
|
+
if (object == null) {
|
|
16
|
+
return object;
|
|
17
|
+
}
|
|
18
|
+
const keys = path.split(".");
|
|
19
|
+
if (keys.length === 0) {
|
|
20
|
+
// Invalid path; do nothing.
|
|
21
|
+
return object;
|
|
22
|
+
}
|
|
23
|
+
let current = object;
|
|
24
|
+
for (let i = 0; i < keys.length - 1; i++) {
|
|
25
|
+
const key = keys[i];
|
|
26
|
+
if (key == null) {
|
|
27
|
+
// Unreachable.
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
if (!current[key] || typeof current[key] !== "object") {
|
|
31
|
+
current[key] = {};
|
|
32
|
+
}
|
|
33
|
+
current = current[key];
|
|
34
|
+
}
|
|
35
|
+
const lastKey = keys[keys.length - 1];
|
|
36
|
+
if (lastKey == null) {
|
|
37
|
+
// Unreachable.
|
|
38
|
+
return object;
|
|
39
|
+
}
|
|
40
|
+
current[lastKey] = value;
|
|
41
|
+
return object;
|
|
42
|
+
}
|
package/dist/cjs/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.0
|
|
1
|
+
export declare const SDK_VERSION = "0.1.0";
|
package/dist/cjs/version.js
CHANGED
package/dist/esm/Client.mjs
CHANGED
|
@@ -15,8 +15,8 @@ export class AgentMailClient {
|
|
|
15
15
|
this._options = Object.assign(Object.assign({}, _options), { headers: mergeHeaders({
|
|
16
16
|
"X-Fern-Language": "JavaScript",
|
|
17
17
|
"X-Fern-SDK-Name": "agentmail",
|
|
18
|
-
"X-Fern-SDK-Version": "0.0
|
|
19
|
-
"User-Agent": "agentmail/0.0
|
|
18
|
+
"X-Fern-SDK-Version": "0.1.0",
|
|
19
|
+
"User-Agent": "agentmail/0.1.0",
|
|
20
20
|
"X-Fern-Runtime": core.RUNTIME.type,
|
|
21
21
|
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
22
22
|
}, _options === null || _options === void 0 ? void 0 : _options.headers) });
|
|
@@ -17,8 +17,7 @@ export declare class ApiKeys {
|
|
|
17
17
|
* @example
|
|
18
18
|
* await client.apiKeys.list()
|
|
19
19
|
*/
|
|
20
|
-
list(request?: AgentMail.ListApiKeysRequest, requestOptions?: ApiKeys.RequestOptions): core.
|
|
21
|
-
private __list;
|
|
20
|
+
list(request?: AgentMail.ListApiKeysRequest, requestOptions?: ApiKeys.RequestOptions): Promise<core.Page<AgentMail.ApiKey>>;
|
|
22
21
|
/**
|
|
23
22
|
* @param {AgentMail.CreateApiKeyRequest} request
|
|
24
23
|
* @param {ApiKeys.RequestOptions} requestOptions - Request-specific configuration.
|