agentmail 0.0.78 → 0.1.1

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