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.
Files changed (88) hide show
  1. package/dist/cjs/Client.js +2 -2
  2. package/dist/cjs/api/resources/apiKeys/client/Client.d.ts +1 -2
  3. package/dist/cjs/api/resources/apiKeys/client/Client.js +62 -52
  4. package/dist/cjs/api/resources/domains/client/Client.d.ts +1 -2
  5. package/dist/cjs/api/resources/domains/client/Client.js +62 -52
  6. package/dist/cjs/api/resources/drafts/client/Client.d.ts +1 -2
  7. package/dist/cjs/api/resources/drafts/client/Client.js +83 -70
  8. package/dist/cjs/api/resources/inboxes/client/Client.d.ts +1 -2
  9. package/dist/cjs/api/resources/inboxes/client/Client.js +62 -52
  10. package/dist/cjs/api/resources/inboxes/resources/drafts/client/Client.d.ts +1 -2
  11. package/dist/cjs/api/resources/inboxes/resources/drafts/client/Client.js +83 -70
  12. package/dist/cjs/api/resources/inboxes/resources/messages/client/Client.d.ts +1 -2
  13. package/dist/cjs/api/resources/inboxes/resources/messages/client/Client.js +83 -70
  14. package/dist/cjs/api/resources/inboxes/resources/threads/client/Client.d.ts +1 -2
  15. package/dist/cjs/api/resources/inboxes/resources/threads/client/Client.js +83 -70
  16. package/dist/cjs/api/resources/pods/client/Client.d.ts +1 -2
  17. package/dist/cjs/api/resources/pods/client/Client.js +62 -52
  18. package/dist/cjs/api/resources/pods/resources/domains/client/Client.d.ts +1 -2
  19. package/dist/cjs/api/resources/pods/resources/domains/client/Client.js +83 -70
  20. package/dist/cjs/api/resources/pods/resources/drafts/client/Client.d.ts +1 -2
  21. package/dist/cjs/api/resources/pods/resources/drafts/client/Client.js +83 -70
  22. package/dist/cjs/api/resources/pods/resources/inboxes/client/Client.d.ts +1 -2
  23. package/dist/cjs/api/resources/pods/resources/inboxes/client/Client.js +83 -70
  24. package/dist/cjs/api/resources/pods/resources/threads/client/Client.d.ts +1 -2
  25. package/dist/cjs/api/resources/pods/resources/threads/client/Client.js +83 -70
  26. package/dist/cjs/api/resources/threads/client/Client.d.ts +1 -2
  27. package/dist/cjs/api/resources/threads/client/Client.js +83 -70
  28. package/dist/cjs/api/resources/webhooks/client/Client.d.ts +1 -2
  29. package/dist/cjs/api/resources/webhooks/client/Client.js +62 -52
  30. package/dist/cjs/core/index.d.ts +2 -0
  31. package/dist/cjs/core/index.js +2 -0
  32. package/dist/cjs/core/pagination/Page.d.ts +32 -0
  33. package/dist/cjs/core/pagination/Page.js +100 -0
  34. package/dist/cjs/core/pagination/Pageable.d.ts +14 -0
  35. package/dist/cjs/core/pagination/Pageable.js +10 -0
  36. package/dist/cjs/core/pagination/index.d.ts +2 -0
  37. package/dist/cjs/core/pagination/index.js +7 -0
  38. package/dist/cjs/core/utils/index.d.ts +1 -0
  39. package/dist/cjs/core/utils/index.js +5 -0
  40. package/dist/cjs/core/utils/setObjectProperty.d.ts +11 -0
  41. package/dist/cjs/core/utils/setObjectProperty.js +42 -0
  42. package/dist/cjs/version.d.ts +1 -1
  43. package/dist/cjs/version.js +1 -1
  44. package/dist/esm/Client.mjs +2 -2
  45. package/dist/esm/api/resources/apiKeys/client/Client.d.mts +1 -2
  46. package/dist/esm/api/resources/apiKeys/client/Client.mjs +62 -52
  47. package/dist/esm/api/resources/domains/client/Client.d.mts +1 -2
  48. package/dist/esm/api/resources/domains/client/Client.mjs +62 -52
  49. package/dist/esm/api/resources/drafts/client/Client.d.mts +1 -2
  50. package/dist/esm/api/resources/drafts/client/Client.mjs +83 -70
  51. package/dist/esm/api/resources/inboxes/client/Client.d.mts +1 -2
  52. package/dist/esm/api/resources/inboxes/client/Client.mjs +62 -52
  53. package/dist/esm/api/resources/inboxes/resources/drafts/client/Client.d.mts +1 -2
  54. package/dist/esm/api/resources/inboxes/resources/drafts/client/Client.mjs +83 -70
  55. package/dist/esm/api/resources/inboxes/resources/messages/client/Client.d.mts +1 -2
  56. package/dist/esm/api/resources/inboxes/resources/messages/client/Client.mjs +83 -70
  57. package/dist/esm/api/resources/inboxes/resources/threads/client/Client.d.mts +1 -2
  58. package/dist/esm/api/resources/inboxes/resources/threads/client/Client.mjs +83 -70
  59. package/dist/esm/api/resources/pods/client/Client.d.mts +1 -2
  60. package/dist/esm/api/resources/pods/client/Client.mjs +62 -52
  61. package/dist/esm/api/resources/pods/resources/domains/client/Client.d.mts +1 -2
  62. package/dist/esm/api/resources/pods/resources/domains/client/Client.mjs +83 -70
  63. package/dist/esm/api/resources/pods/resources/drafts/client/Client.d.mts +1 -2
  64. package/dist/esm/api/resources/pods/resources/drafts/client/Client.mjs +83 -70
  65. package/dist/esm/api/resources/pods/resources/inboxes/client/Client.d.mts +1 -2
  66. package/dist/esm/api/resources/pods/resources/inboxes/client/Client.mjs +83 -70
  67. package/dist/esm/api/resources/pods/resources/threads/client/Client.d.mts +1 -2
  68. package/dist/esm/api/resources/pods/resources/threads/client/Client.mjs +83 -70
  69. package/dist/esm/api/resources/threads/client/Client.d.mts +1 -2
  70. package/dist/esm/api/resources/threads/client/Client.mjs +83 -70
  71. package/dist/esm/api/resources/webhooks/client/Client.d.mts +1 -2
  72. package/dist/esm/api/resources/webhooks/client/Client.mjs +62 -52
  73. package/dist/esm/core/index.d.mts +2 -0
  74. package/dist/esm/core/index.mjs +2 -0
  75. package/dist/esm/core/pagination/Page.d.mts +32 -0
  76. package/dist/esm/core/pagination/Page.mjs +96 -0
  77. package/dist/esm/core/pagination/Pageable.d.mts +14 -0
  78. package/dist/esm/core/pagination/Pageable.mjs +6 -0
  79. package/dist/esm/core/pagination/index.d.mts +2 -0
  80. package/dist/esm/core/pagination/index.mjs +2 -0
  81. package/dist/esm/core/utils/index.d.mts +1 -0
  82. package/dist/esm/core/utils/index.mjs +1 -0
  83. package/dist/esm/core/utils/setObjectProperty.d.mts +11 -0
  84. package/dist/esm/core/utils/setObjectProperty.mjs +39 -0
  85. package/dist/esm/version.d.mts +1 -1
  86. package/dist/esm/version.mjs +1 -1
  87. package/package.json +1 -1
  88. package/reference.md +154 -28
@@ -25,64 +25,74 @@ export class ApiKeys {
25
25
  * @example
26
26
  * await client.apiKeys.list()
27
27
  */
28
- list(request = {}, requestOptions) {
29
- return core.HttpResponsePromise.fromPromise(this.__list(request, requestOptions));
30
- }
31
- __list() {
28
+ list() {
32
29
  return __awaiter(this, arguments, void 0, function* (request = {}, requestOptions) {
33
- var _a, _b, _c, _d, _e, _f, _g, _h;
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
- const _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/api-keys"),
45
- method: "GET",
46
- headers: _headers,
47
- queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
48
- timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
49
- maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
50
- abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
51
- });
52
- if (_response.ok) {
53
- return {
54
- data: serializers.ListApiKeysResponse.parseOrThrow(_response.body, {
55
- unrecognizedObjectKeys: "passthrough",
56
- allowUnrecognizedUnionMembers: true,
57
- allowUnrecognizedEnumValues: true,
58
- skipValidation: true,
59
- breadcrumbsPrefix: ["response"],
60
- }),
61
- rawResponse: _response.rawResponse,
62
- };
63
- }
64
- if (_response.error.reason === "status-code") {
65
- throw new errors.AgentMailError({
66
- statusCode: _response.error.statusCode,
67
- body: _response.error.body,
68
- rawResponse: _response.rawResponse,
30
+ const list = core.HttpResponsePromise.interceptFunction((request) => __awaiter(this, void 0, void 0, function* () {
31
+ var _a, _b, _c, _d, _e, _f, _g, _h;
32
+ const { limit, pageToken } = request;
33
+ const _queryParams = {};
34
+ if (limit != null) {
35
+ _queryParams.limit = limit.toString();
36
+ }
37
+ if (pageToken != null) {
38
+ _queryParams.page_token = pageToken;
39
+ }
40
+ const _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);
41
+ const _response = yield core.fetcher({
42
+ 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/api-keys"),
43
+ method: "GET",
44
+ headers: _headers,
45
+ queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
46
+ 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,
47
+ 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,
48
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
69
49
  });
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,
50
+ if (_response.ok) {
51
+ return {
52
+ data: serializers.ListApiKeysResponse.parseOrThrow(_response.body, {
53
+ unrecognizedObjectKeys: "passthrough",
54
+ allowUnrecognizedUnionMembers: true,
55
+ allowUnrecognizedEnumValues: true,
56
+ skipValidation: true,
57
+ breadcrumbsPrefix: ["response"],
58
+ }),
76
59
  rawResponse: _response.rawResponse,
77
- });
78
- case "timeout":
79
- throw new errors.AgentMailTimeoutError("Timeout exceeded when calling GET /v0/api-keys.");
80
- case "unknown":
60
+ };
61
+ }
62
+ if (_response.error.reason === "status-code") {
81
63
  throw new errors.AgentMailError({
82
- message: _response.error.errorMessage,
64
+ statusCode: _response.error.statusCode,
65
+ body: _response.error.body,
83
66
  rawResponse: _response.rawResponse,
84
67
  });
85
- }
68
+ }
69
+ switch (_response.error.reason) {
70
+ case "non-json":
71
+ throw new errors.AgentMailError({
72
+ statusCode: _response.error.statusCode,
73
+ body: _response.error.rawBody,
74
+ rawResponse: _response.rawResponse,
75
+ });
76
+ case "timeout":
77
+ throw new errors.AgentMailTimeoutError("Timeout exceeded when calling GET /v0/api-keys.");
78
+ case "unknown":
79
+ throw new errors.AgentMailError({
80
+ message: _response.error.errorMessage,
81
+ rawResponse: _response.rawResponse,
82
+ });
83
+ }
84
+ }));
85
+ const dataWithRawResponse = yield list(request).withRawResponse();
86
+ return new core.Pageable({
87
+ response: dataWithRawResponse.data,
88
+ rawResponse: dataWithRawResponse.rawResponse,
89
+ hasNextPage: (response) => (response === null || response === void 0 ? void 0 : response.nextPageToken) != null &&
90
+ !(typeof (response === null || response === void 0 ? void 0 : response.nextPageToken) === "string" && (response === null || response === void 0 ? void 0 : response.nextPageToken) === ""),
91
+ getItems: (response) => { var _a; return (_a = response === null || response === void 0 ? void 0 : response.apiKeys) !== null && _a !== void 0 ? _a : []; },
92
+ loadPage: (response) => {
93
+ return list(core.setObjectProperty(request, "pageToken", response === null || response === void 0 ? void 0 : response.nextPageToken));
94
+ },
95
+ });
86
96
  });
87
97
  }
88
98
  /**
@@ -17,8 +17,7 @@ export declare class Domains {
17
17
  * @example
18
18
  * await client.domains.list()
19
19
  */
20
- list(request?: AgentMail.ListDomainsRequest, requestOptions?: Domains.RequestOptions): core.HttpResponsePromise<AgentMail.ListDomainsResponse>;
21
- private __list;
20
+ list(request?: AgentMail.ListDomainsRequest, requestOptions?: Domains.RequestOptions): Promise<core.Page<AgentMail.DomainSummary>>;
22
21
  /**
23
22
  * @param {AgentMail.DomainId} domainId
24
23
  * @param {Domains.RequestOptions} requestOptions - Request-specific configuration.
@@ -25,64 +25,74 @@ export class Domains {
25
25
  * @example
26
26
  * await client.domains.list()
27
27
  */
28
- list(request = {}, requestOptions) {
29
- return core.HttpResponsePromise.fromPromise(this.__list(request, requestOptions));
30
- }
31
- __list() {
28
+ list() {
32
29
  return __awaiter(this, arguments, void 0, function* (request = {}, requestOptions) {
33
- var _a, _b, _c, _d, _e, _f, _g, _h;
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
- const _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/domains"),
45
- method: "GET",
46
- headers: _headers,
47
- queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
48
- timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
49
- maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
50
- abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
51
- });
52
- if (_response.ok) {
53
- return {
54
- data: serializers.ListDomainsResponse.parseOrThrow(_response.body, {
55
- unrecognizedObjectKeys: "passthrough",
56
- allowUnrecognizedUnionMembers: true,
57
- allowUnrecognizedEnumValues: true,
58
- skipValidation: true,
59
- breadcrumbsPrefix: ["response"],
60
- }),
61
- rawResponse: _response.rawResponse,
62
- };
63
- }
64
- if (_response.error.reason === "status-code") {
65
- throw new errors.AgentMailError({
66
- statusCode: _response.error.statusCode,
67
- body: _response.error.body,
68
- rawResponse: _response.rawResponse,
30
+ const list = core.HttpResponsePromise.interceptFunction((request) => __awaiter(this, void 0, void 0, function* () {
31
+ var _a, _b, _c, _d, _e, _f, _g, _h;
32
+ const { limit, pageToken } = request;
33
+ const _queryParams = {};
34
+ if (limit != null) {
35
+ _queryParams.limit = limit.toString();
36
+ }
37
+ if (pageToken != null) {
38
+ _queryParams.page_token = pageToken;
39
+ }
40
+ const _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);
41
+ const _response = yield core.fetcher({
42
+ 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/domains"),
43
+ method: "GET",
44
+ headers: _headers,
45
+ queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
46
+ 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,
47
+ 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,
48
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
69
49
  });
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,
50
+ if (_response.ok) {
51
+ return {
52
+ data: serializers.ListDomainsResponse.parseOrThrow(_response.body, {
53
+ unrecognizedObjectKeys: "passthrough",
54
+ allowUnrecognizedUnionMembers: true,
55
+ allowUnrecognizedEnumValues: true,
56
+ skipValidation: true,
57
+ breadcrumbsPrefix: ["response"],
58
+ }),
76
59
  rawResponse: _response.rawResponse,
77
- });
78
- case "timeout":
79
- throw new errors.AgentMailTimeoutError("Timeout exceeded when calling GET /v0/domains.");
80
- case "unknown":
60
+ };
61
+ }
62
+ if (_response.error.reason === "status-code") {
81
63
  throw new errors.AgentMailError({
82
- message: _response.error.errorMessage,
64
+ statusCode: _response.error.statusCode,
65
+ body: _response.error.body,
83
66
  rawResponse: _response.rawResponse,
84
67
  });
85
- }
68
+ }
69
+ switch (_response.error.reason) {
70
+ case "non-json":
71
+ throw new errors.AgentMailError({
72
+ statusCode: _response.error.statusCode,
73
+ body: _response.error.rawBody,
74
+ rawResponse: _response.rawResponse,
75
+ });
76
+ case "timeout":
77
+ throw new errors.AgentMailTimeoutError("Timeout exceeded when calling GET /v0/domains.");
78
+ case "unknown":
79
+ throw new errors.AgentMailError({
80
+ message: _response.error.errorMessage,
81
+ rawResponse: _response.rawResponse,
82
+ });
83
+ }
84
+ }));
85
+ const dataWithRawResponse = yield list(request).withRawResponse();
86
+ return new core.Pageable({
87
+ response: dataWithRawResponse.data,
88
+ rawResponse: dataWithRawResponse.rawResponse,
89
+ hasNextPage: (response) => (response === null || response === void 0 ? void 0 : response.nextPageToken) != null &&
90
+ !(typeof (response === null || response === void 0 ? void 0 : response.nextPageToken) === "string" && (response === null || response === void 0 ? void 0 : response.nextPageToken) === ""),
91
+ getItems: (response) => { var _a; return (_a = response === null || response === void 0 ? void 0 : response.domains) !== null && _a !== void 0 ? _a : []; },
92
+ loadPage: (response) => {
93
+ return list(core.setObjectProperty(request, "pageToken", response === null || response === void 0 ? void 0 : response.nextPageToken));
94
+ },
95
+ });
86
96
  });
87
97
  }
88
98
  /**
@@ -19,8 +19,7 @@ export declare class Drafts {
19
19
  * @example
20
20
  * await client.drafts.list()
21
21
  */
22
- list(request?: AgentMail.ListDraftsRequest, requestOptions?: Drafts.RequestOptions): core.HttpResponsePromise<AgentMail.ListDraftsResponse>;
23
- private __list;
22
+ list(request?: AgentMail.ListDraftsRequest, requestOptions?: Drafts.RequestOptions): Promise<core.Page<AgentMail.DraftItem>>;
24
23
  /**
25
24
  * @param {AgentMail.DraftId} draftId
26
25
  * @param {Drafts.RequestOptions} requestOptions - Request-specific configuration.
@@ -28,87 +28,100 @@ export class Drafts {
28
28
  * @example
29
29
  * await client.drafts.list()
30
30
  */
31
- list(request = {}, requestOptions) {
32
- return core.HttpResponsePromise.fromPromise(this.__list(request, requestOptions));
33
- }
34
- __list() {
31
+ list() {
35
32
  return __awaiter(this, arguments, void 0, function* (request = {}, requestOptions) {
36
- var _a, _b, _c, _d, _e, _f, _g, _h;
37
- const { limit, pageToken, labels, before, after, ascending } = request;
38
- const _queryParams = {};
39
- if (limit != null) {
40
- _queryParams.limit = limit.toString();
41
- }
42
- if (pageToken != null) {
43
- _queryParams.page_token = pageToken;
44
- }
45
- if (labels != null) {
46
- _queryParams.labels = toJson(serializers.Labels.jsonOrThrow(labels, { unrecognizedObjectKeys: "strip", omitUndefined: true }));
47
- }
48
- if (before != null) {
49
- _queryParams.before = before.toISOString();
50
- }
51
- if (after != null) {
52
- _queryParams.after = after.toISOString();
53
- }
54
- if (ascending != null) {
55
- _queryParams.ascending = ascending.toString();
56
- }
57
- const _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);
58
- const _response = yield core.fetcher({
59
- 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/drafts"),
60
- method: "GET",
61
- headers: _headers,
62
- queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
63
- 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,
64
- 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,
65
- abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
66
- });
67
- if (_response.ok) {
68
- return {
69
- data: serializers.ListDraftsResponse.parseOrThrow(_response.body, {
70
- unrecognizedObjectKeys: "passthrough",
71
- allowUnrecognizedUnionMembers: true,
72
- allowUnrecognizedEnumValues: true,
73
- skipValidation: true,
74
- breadcrumbsPrefix: ["response"],
75
- }),
76
- rawResponse: _response.rawResponse,
77
- };
78
- }
79
- if (_response.error.reason === "status-code") {
80
- switch (_response.error.statusCode) {
81
- case 404:
82
- throw new AgentMail.NotFoundError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
33
+ const list = core.HttpResponsePromise.interceptFunction((request) => __awaiter(this, void 0, void 0, function* () {
34
+ var _a, _b, _c, _d, _e, _f, _g, _h;
35
+ const { limit, pageToken, labels, before, after, ascending } = request;
36
+ const _queryParams = {};
37
+ if (limit != null) {
38
+ _queryParams.limit = limit.toString();
39
+ }
40
+ if (pageToken != null) {
41
+ _queryParams.page_token = pageToken;
42
+ }
43
+ if (labels != null) {
44
+ _queryParams.labels = toJson(serializers.Labels.jsonOrThrow(labels, {
45
+ unrecognizedObjectKeys: "strip",
46
+ omitUndefined: true,
47
+ }));
48
+ }
49
+ if (before != null) {
50
+ _queryParams.before = before.toISOString();
51
+ }
52
+ if (after != null) {
53
+ _queryParams.after = after.toISOString();
54
+ }
55
+ if (ascending != null) {
56
+ _queryParams.ascending = ascending.toString();
57
+ }
58
+ const _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);
59
+ const _response = yield core.fetcher({
60
+ 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/drafts"),
61
+ method: "GET",
62
+ headers: _headers,
63
+ queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
64
+ 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,
65
+ 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,
66
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
67
+ });
68
+ if (_response.ok) {
69
+ return {
70
+ data: serializers.ListDraftsResponse.parseOrThrow(_response.body, {
83
71
  unrecognizedObjectKeys: "passthrough",
84
72
  allowUnrecognizedUnionMembers: true,
85
73
  allowUnrecognizedEnumValues: true,
86
74
  skipValidation: true,
87
75
  breadcrumbsPrefix: ["response"],
88
- }), _response.rawResponse);
89
- default:
76
+ }),
77
+ rawResponse: _response.rawResponse,
78
+ };
79
+ }
80
+ if (_response.error.reason === "status-code") {
81
+ switch (_response.error.statusCode) {
82
+ case 404:
83
+ throw new AgentMail.NotFoundError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
84
+ unrecognizedObjectKeys: "passthrough",
85
+ allowUnrecognizedUnionMembers: true,
86
+ allowUnrecognizedEnumValues: true,
87
+ skipValidation: true,
88
+ breadcrumbsPrefix: ["response"],
89
+ }), _response.rawResponse);
90
+ default:
91
+ throw new errors.AgentMailError({
92
+ statusCode: _response.error.statusCode,
93
+ body: _response.error.body,
94
+ rawResponse: _response.rawResponse,
95
+ });
96
+ }
97
+ }
98
+ switch (_response.error.reason) {
99
+ case "non-json":
90
100
  throw new errors.AgentMailError({
91
101
  statusCode: _response.error.statusCode,
92
- body: _response.error.body,
102
+ body: _response.error.rawBody,
103
+ rawResponse: _response.rawResponse,
104
+ });
105
+ case "timeout":
106
+ throw new errors.AgentMailTimeoutError("Timeout exceeded when calling GET /v0/drafts.");
107
+ case "unknown":
108
+ throw new errors.AgentMailError({
109
+ message: _response.error.errorMessage,
93
110
  rawResponse: _response.rawResponse,
94
111
  });
95
112
  }
96
- }
97
- switch (_response.error.reason) {
98
- case "non-json":
99
- throw new errors.AgentMailError({
100
- statusCode: _response.error.statusCode,
101
- body: _response.error.rawBody,
102
- rawResponse: _response.rawResponse,
103
- });
104
- case "timeout":
105
- throw new errors.AgentMailTimeoutError("Timeout exceeded when calling GET /v0/drafts.");
106
- case "unknown":
107
- throw new errors.AgentMailError({
108
- message: _response.error.errorMessage,
109
- rawResponse: _response.rawResponse,
110
- });
111
- }
113
+ }));
114
+ const dataWithRawResponse = yield list(request).withRawResponse();
115
+ return new core.Pageable({
116
+ response: dataWithRawResponse.data,
117
+ rawResponse: dataWithRawResponse.rawResponse,
118
+ hasNextPage: (response) => (response === null || response === void 0 ? void 0 : response.nextPageToken) != null &&
119
+ !(typeof (response === null || response === void 0 ? void 0 : response.nextPageToken) === "string" && (response === null || response === void 0 ? void 0 : response.nextPageToken) === ""),
120
+ getItems: (response) => { var _a; return (_a = response === null || response === void 0 ? void 0 : response.drafts) !== null && _a !== void 0 ? _a : []; },
121
+ loadPage: (response) => {
122
+ return list(core.setObjectProperty(request, "pageToken", response === null || response === void 0 ? void 0 : response.nextPageToken));
123
+ },
124
+ });
112
125
  });
113
126
  }
114
127
  /**
@@ -29,8 +29,7 @@ export declare class Inboxes {
29
29
  * @example
30
30
  * await client.inboxes.list()
31
31
  */
32
- list(request?: AgentMail.inboxes.ListInboxesRequest, requestOptions?: Inboxes.RequestOptions): core.HttpResponsePromise<AgentMail.inboxes.ListInboxesResponse>;
33
- private __list;
32
+ list(request?: AgentMail.inboxes.ListInboxesRequest, requestOptions?: Inboxes.RequestOptions): Promise<core.Page<AgentMail.inboxes.Inbox>>;
34
33
  /**
35
34
  * @param {AgentMail.inboxes.InboxId} inboxId
36
35
  * @param {Inboxes.RequestOptions} requestOptions - Request-specific configuration.
@@ -45,64 +45,74 @@ export class Inboxes {
45
45
  * @example
46
46
  * await client.inboxes.list()
47
47
  */
48
- list(request = {}, requestOptions) {
49
- return core.HttpResponsePromise.fromPromise(this.__list(request, requestOptions));
50
- }
51
- __list() {
48
+ list() {
52
49
  return __awaiter(this, arguments, void 0, function* (request = {}, requestOptions) {
53
- var _a, _b, _c, _d, _e, _f, _g, _h;
54
- const { limit, pageToken } = request;
55
- const _queryParams = {};
56
- if (limit != null) {
57
- _queryParams.limit = limit.toString();
58
- }
59
- if (pageToken != null) {
60
- _queryParams.page_token = pageToken;
61
- }
62
- const _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);
63
- const _response = yield core.fetcher({
64
- 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/inboxes"),
65
- method: "GET",
66
- headers: _headers,
67
- queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
68
- timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
69
- maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
70
- abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
71
- });
72
- if (_response.ok) {
73
- return {
74
- data: serializers.inboxes.ListInboxesResponse.parseOrThrow(_response.body, {
75
- unrecognizedObjectKeys: "passthrough",
76
- allowUnrecognizedUnionMembers: true,
77
- allowUnrecognizedEnumValues: true,
78
- skipValidation: true,
79
- breadcrumbsPrefix: ["response"],
80
- }),
81
- rawResponse: _response.rawResponse,
82
- };
83
- }
84
- if (_response.error.reason === "status-code") {
85
- throw new errors.AgentMailError({
86
- statusCode: _response.error.statusCode,
87
- body: _response.error.body,
88
- rawResponse: _response.rawResponse,
50
+ const list = core.HttpResponsePromise.interceptFunction((request) => __awaiter(this, void 0, void 0, function* () {
51
+ var _a, _b, _c, _d, _e, _f, _g, _h;
52
+ const { limit, pageToken } = request;
53
+ const _queryParams = {};
54
+ if (limit != null) {
55
+ _queryParams.limit = limit.toString();
56
+ }
57
+ if (pageToken != null) {
58
+ _queryParams.page_token = pageToken;
59
+ }
60
+ const _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);
61
+ const _response = yield core.fetcher({
62
+ 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/inboxes"),
63
+ method: "GET",
64
+ headers: _headers,
65
+ queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
66
+ 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,
67
+ 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,
68
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
89
69
  });
90
- }
91
- switch (_response.error.reason) {
92
- case "non-json":
93
- throw new errors.AgentMailError({
94
- statusCode: _response.error.statusCode,
95
- body: _response.error.rawBody,
70
+ if (_response.ok) {
71
+ return {
72
+ data: serializers.inboxes.ListInboxesResponse.parseOrThrow(_response.body, {
73
+ unrecognizedObjectKeys: "passthrough",
74
+ allowUnrecognizedUnionMembers: true,
75
+ allowUnrecognizedEnumValues: true,
76
+ skipValidation: true,
77
+ breadcrumbsPrefix: ["response"],
78
+ }),
96
79
  rawResponse: _response.rawResponse,
97
- });
98
- case "timeout":
99
- throw new errors.AgentMailTimeoutError("Timeout exceeded when calling GET /v0/inboxes.");
100
- case "unknown":
80
+ };
81
+ }
82
+ if (_response.error.reason === "status-code") {
101
83
  throw new errors.AgentMailError({
102
- message: _response.error.errorMessage,
84
+ statusCode: _response.error.statusCode,
85
+ body: _response.error.body,
103
86
  rawResponse: _response.rawResponse,
104
87
  });
105
- }
88
+ }
89
+ switch (_response.error.reason) {
90
+ case "non-json":
91
+ throw new errors.AgentMailError({
92
+ statusCode: _response.error.statusCode,
93
+ body: _response.error.rawBody,
94
+ rawResponse: _response.rawResponse,
95
+ });
96
+ case "timeout":
97
+ throw new errors.AgentMailTimeoutError("Timeout exceeded when calling GET /v0/inboxes.");
98
+ case "unknown":
99
+ throw new errors.AgentMailError({
100
+ message: _response.error.errorMessage,
101
+ rawResponse: _response.rawResponse,
102
+ });
103
+ }
104
+ }));
105
+ const dataWithRawResponse = yield list(request).withRawResponse();
106
+ return new core.Pageable({
107
+ response: dataWithRawResponse.data,
108
+ rawResponse: dataWithRawResponse.rawResponse,
109
+ hasNextPage: (response) => (response === null || response === void 0 ? void 0 : response.nextPageToken) != null &&
110
+ !(typeof (response === null || response === void 0 ? void 0 : response.nextPageToken) === "string" && (response === null || response === void 0 ? void 0 : response.nextPageToken) === ""),
111
+ getItems: (response) => { var _a; return (_a = response === null || response === void 0 ? void 0 : response.inboxes) !== null && _a !== void 0 ? _a : []; },
112
+ loadPage: (response) => {
113
+ return list(core.setObjectProperty(request, "pageToken", response === null || response === void 0 ? void 0 : response.nextPageToken));
114
+ },
115
+ });
106
116
  });
107
117
  }
108
118
  /**
@@ -20,8 +20,7 @@ export declare class Drafts {
20
20
  * @example
21
21
  * await client.inboxes.drafts.list("inbox_id")
22
22
  */
23
- list(inboxId: AgentMail.inboxes.InboxId, request?: AgentMail.inboxes.ListDraftsRequest, requestOptions?: Drafts.RequestOptions): core.HttpResponsePromise<AgentMail.ListDraftsResponse>;
24
- private __list;
23
+ list(inboxId: AgentMail.inboxes.InboxId, request?: AgentMail.inboxes.ListDraftsRequest, requestOptions?: Drafts.RequestOptions): Promise<core.Page<AgentMail.DraftItem>>;
25
24
  /**
26
25
  * @param {AgentMail.inboxes.InboxId} inboxId
27
26
  * @param {AgentMail.DraftId} draftId