agentmail 0.4.13 → 0.4.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (247) hide show
  1. package/README.md +46 -14
  2. package/dist/cjs/BaseClient.js +2 -2
  3. package/dist/cjs/Client.d.ts +12 -0
  4. package/dist/cjs/Client.js +74 -0
  5. package/dist/cjs/api/errors/UnprocessableError.d.ts +6 -0
  6. package/dist/cjs/api/errors/UnprocessableError.js +54 -0
  7. package/dist/cjs/api/errors/index.d.ts +1 -0
  8. package/dist/cjs/api/errors/index.js +1 -0
  9. package/dist/cjs/api/resources/agent/exports.d.ts +2 -0
  10. package/dist/cjs/api/resources/agent/exports.js +21 -0
  11. package/dist/cjs/api/resources/apiKeys/exports.d.ts +2 -0
  12. package/dist/cjs/api/resources/apiKeys/exports.js +21 -0
  13. package/dist/cjs/api/resources/attachments/exports.d.ts +1 -0
  14. package/dist/cjs/api/resources/attachments/exports.js +18 -0
  15. package/dist/cjs/api/resources/domains/exports.d.ts +2 -0
  16. package/dist/cjs/api/resources/domains/exports.js +21 -0
  17. package/dist/cjs/api/resources/drafts/exports.d.ts +2 -0
  18. package/dist/cjs/api/resources/drafts/exports.js +21 -0
  19. package/dist/cjs/api/resources/events/exports.d.ts +1 -0
  20. package/dist/cjs/api/resources/events/exports.js +18 -0
  21. package/dist/cjs/api/resources/inboxes/exports.d.ts +3 -0
  22. package/dist/cjs/api/resources/inboxes/exports.js +22 -0
  23. package/dist/cjs/api/resources/inboxes/resources/apiKeys/exports.d.ts +2 -0
  24. package/dist/cjs/api/resources/inboxes/resources/apiKeys/exports.js +21 -0
  25. package/dist/cjs/api/resources/inboxes/resources/drafts/exports.d.ts +2 -0
  26. package/dist/cjs/api/resources/inboxes/resources/drafts/exports.js +21 -0
  27. package/dist/cjs/api/resources/inboxes/resources/lists/exports.d.ts +2 -0
  28. package/dist/cjs/api/resources/inboxes/resources/lists/exports.js +21 -0
  29. package/dist/cjs/api/resources/inboxes/resources/messages/client/Client.d.ts +1 -1
  30. package/dist/cjs/api/resources/inboxes/resources/messages/client/Client.js +1 -1
  31. package/dist/cjs/api/resources/inboxes/resources/messages/exports.d.ts +2 -0
  32. package/dist/cjs/api/resources/inboxes/resources/messages/exports.js +21 -0
  33. package/dist/cjs/api/resources/inboxes/resources/metrics/exports.d.ts +2 -0
  34. package/dist/cjs/api/resources/inboxes/resources/metrics/exports.js +21 -0
  35. package/dist/cjs/api/resources/inboxes/resources/threads/client/Client.d.ts +17 -0
  36. package/dist/cjs/api/resources/inboxes/resources/threads/client/Client.js +90 -0
  37. package/dist/cjs/api/resources/inboxes/resources/threads/exports.d.ts +2 -0
  38. package/dist/cjs/api/resources/inboxes/resources/threads/exports.js +21 -0
  39. package/dist/cjs/api/resources/lists/exports.d.ts +2 -0
  40. package/dist/cjs/api/resources/lists/exports.js +21 -0
  41. package/dist/cjs/api/resources/messages/exports.d.ts +1 -0
  42. package/dist/cjs/api/resources/messages/exports.js +18 -0
  43. package/dist/cjs/api/resources/messages/types/UpdateMessageResponse.d.ts +5 -0
  44. package/dist/cjs/api/resources/messages/types/UpdateMessageResponse.js +3 -0
  45. package/dist/cjs/api/resources/messages/types/index.d.ts +1 -0
  46. package/dist/cjs/api/resources/messages/types/index.js +1 -0
  47. package/dist/cjs/api/resources/metrics/exports.d.ts +2 -0
  48. package/dist/cjs/api/resources/metrics/exports.js +21 -0
  49. package/dist/cjs/api/resources/metrics/types/QueryMetricsResponse.d.ts +1 -1
  50. package/dist/cjs/api/resources/organizations/exports.d.ts +2 -0
  51. package/dist/cjs/api/resources/organizations/exports.js +21 -0
  52. package/dist/cjs/api/resources/pods/exports.d.ts +3 -0
  53. package/dist/cjs/api/resources/pods/exports.js +22 -0
  54. package/dist/cjs/api/resources/pods/resources/apiKeys/exports.d.ts +2 -0
  55. package/dist/cjs/api/resources/pods/resources/apiKeys/exports.js +21 -0
  56. package/dist/cjs/api/resources/pods/resources/domains/exports.d.ts +2 -0
  57. package/dist/cjs/api/resources/pods/resources/domains/exports.js +21 -0
  58. package/dist/cjs/api/resources/pods/resources/drafts/exports.d.ts +2 -0
  59. package/dist/cjs/api/resources/pods/resources/drafts/exports.js +21 -0
  60. package/dist/cjs/api/resources/pods/resources/inboxes/exports.d.ts +2 -0
  61. package/dist/cjs/api/resources/pods/resources/inboxes/exports.js +21 -0
  62. package/dist/cjs/api/resources/pods/resources/lists/exports.d.ts +2 -0
  63. package/dist/cjs/api/resources/pods/resources/lists/exports.js +21 -0
  64. package/dist/cjs/api/resources/pods/resources/metrics/exports.d.ts +2 -0
  65. package/dist/cjs/api/resources/pods/resources/metrics/exports.js +21 -0
  66. package/dist/cjs/api/resources/pods/resources/threads/client/Client.d.ts +17 -0
  67. package/dist/cjs/api/resources/pods/resources/threads/client/Client.js +90 -0
  68. package/dist/cjs/api/resources/pods/resources/threads/exports.d.ts +2 -0
  69. package/dist/cjs/api/resources/pods/resources/threads/exports.js +21 -0
  70. package/dist/cjs/api/resources/threads/client/Client.d.ts +16 -0
  71. package/dist/cjs/api/resources/threads/client/Client.js +89 -0
  72. package/dist/cjs/api/resources/threads/exports.d.ts +2 -0
  73. package/dist/cjs/api/resources/threads/exports.js +21 -0
  74. package/dist/cjs/api/resources/threads/types/UpdateThreadRequest.d.ts +6 -0
  75. package/dist/cjs/api/resources/threads/types/UpdateThreadRequest.js +3 -0
  76. package/dist/cjs/api/resources/threads/types/UpdateThreadResponse.d.ts +5 -0
  77. package/dist/cjs/api/resources/threads/types/UpdateThreadResponse.js +3 -0
  78. package/dist/cjs/api/resources/threads/types/index.d.ts +2 -0
  79. package/dist/cjs/api/resources/threads/types/index.js +2 -0
  80. package/dist/cjs/api/resources/webhooks/exports.d.ts +3 -0
  81. package/dist/cjs/api/resources/webhooks/exports.js +22 -0
  82. package/dist/cjs/api/resources/webhooks/resources/events/exports.d.ts +1 -0
  83. package/dist/cjs/api/resources/webhooks/resources/events/exports.js +18 -0
  84. package/dist/cjs/api/resources/websockets/client/Client.d.ts +6 -0
  85. package/dist/cjs/api/resources/websockets/client/Client.js +8 -3
  86. package/dist/cjs/api/resources/websockets/client/Socket.d.ts +2 -2
  87. package/dist/cjs/api/resources/websockets/client/Socket.js +2 -2
  88. package/dist/cjs/api/resources/websockets/exports.d.ts +3 -0
  89. package/dist/cjs/api/resources/websockets/exports.js +23 -0
  90. package/dist/cjs/core/fetcher/BinaryResponse.d.ts +1 -1
  91. package/dist/cjs/core/fetcher/Fetcher.js +8 -2
  92. package/dist/cjs/core/fetcher/index.d.ts +2 -0
  93. package/dist/cjs/core/fetcher/index.js +3 -1
  94. package/dist/cjs/core/fetcher/makePassthroughRequest.d.ts +49 -0
  95. package/dist/cjs/core/fetcher/makePassthroughRequest.js +135 -0
  96. package/dist/cjs/core/fetcher/makeRequest.d.ts +6 -1
  97. package/dist/cjs/core/fetcher/makeRequest.js +30 -9
  98. package/dist/cjs/core/runtime/runtime.js +8 -7
  99. package/dist/cjs/core/schemas/builders/list/list.js +12 -17
  100. package/dist/cjs/core/schemas/builders/object/object.js +102 -40
  101. package/dist/cjs/core/schemas/builders/object-like/getObjectLikeUtils.js +10 -3
  102. package/dist/cjs/core/schemas/builders/record/index.d.ts +2 -2
  103. package/dist/cjs/core/schemas/builders/record/index.js +2 -1
  104. package/dist/cjs/core/schemas/builders/record/record.d.ts +2 -1
  105. package/dist/cjs/core/schemas/builders/record/record.js +63 -25
  106. package/dist/cjs/core/schemas/builders/record/types.d.ts +2 -0
  107. package/dist/cjs/core/schemas/builders/union/union.js +9 -12
  108. package/dist/cjs/core/schemas/utils/isPlainObject.js +4 -6
  109. package/dist/cjs/core/websocket/ws.d.ts +14 -2
  110. package/dist/cjs/core/websocket/ws.js +51 -7
  111. package/dist/cjs/serialization/resources/messages/types/UpdateMessageResponse.d.ts +12 -0
  112. package/dist/cjs/serialization/resources/messages/types/UpdateMessageResponse.js +44 -0
  113. package/dist/cjs/serialization/resources/messages/types/index.d.ts +1 -0
  114. package/dist/cjs/serialization/resources/messages/types/index.js +1 -0
  115. package/dist/cjs/serialization/resources/metrics/types/QueryMetricsResponse.js +1 -1
  116. package/dist/cjs/serialization/resources/threads/types/UpdateThreadRequest.d.ts +10 -0
  117. package/dist/cjs/serialization/resources/threads/types/UpdateThreadRequest.js +42 -0
  118. package/dist/cjs/serialization/resources/threads/types/UpdateThreadResponse.d.ts +12 -0
  119. package/dist/cjs/serialization/resources/threads/types/UpdateThreadResponse.js +44 -0
  120. package/dist/cjs/serialization/resources/threads/types/index.d.ts +2 -0
  121. package/dist/cjs/serialization/resources/threads/types/index.js +2 -0
  122. package/dist/cjs/version.d.ts +1 -1
  123. package/dist/cjs/version.js +1 -1
  124. package/dist/esm/BaseClient.mjs +2 -2
  125. package/dist/esm/Client.d.mts +12 -0
  126. package/dist/esm/Client.mjs +41 -0
  127. package/dist/esm/api/errors/UnprocessableError.d.mts +6 -0
  128. package/dist/esm/api/errors/UnprocessableError.mjs +17 -0
  129. package/dist/esm/api/errors/index.d.mts +1 -0
  130. package/dist/esm/api/errors/index.mjs +1 -0
  131. package/dist/esm/api/resources/agent/exports.d.mts +2 -0
  132. package/dist/esm/api/resources/agent/exports.mjs +3 -0
  133. package/dist/esm/api/resources/apiKeys/exports.d.mts +2 -0
  134. package/dist/esm/api/resources/apiKeys/exports.mjs +3 -0
  135. package/dist/esm/api/resources/attachments/exports.d.mts +1 -0
  136. package/dist/esm/api/resources/attachments/exports.mjs +2 -0
  137. package/dist/esm/api/resources/domains/exports.d.mts +2 -0
  138. package/dist/esm/api/resources/domains/exports.mjs +3 -0
  139. package/dist/esm/api/resources/drafts/exports.d.mts +2 -0
  140. package/dist/esm/api/resources/drafts/exports.mjs +3 -0
  141. package/dist/esm/api/resources/events/exports.d.mts +1 -0
  142. package/dist/esm/api/resources/events/exports.mjs +2 -0
  143. package/dist/esm/api/resources/inboxes/exports.d.mts +3 -0
  144. package/dist/esm/api/resources/inboxes/exports.mjs +4 -0
  145. package/dist/esm/api/resources/inboxes/resources/apiKeys/exports.d.mts +2 -0
  146. package/dist/esm/api/resources/inboxes/resources/apiKeys/exports.mjs +3 -0
  147. package/dist/esm/api/resources/inboxes/resources/drafts/exports.d.mts +2 -0
  148. package/dist/esm/api/resources/inboxes/resources/drafts/exports.mjs +3 -0
  149. package/dist/esm/api/resources/inboxes/resources/lists/exports.d.mts +2 -0
  150. package/dist/esm/api/resources/inboxes/resources/lists/exports.mjs +3 -0
  151. package/dist/esm/api/resources/inboxes/resources/messages/client/Client.d.mts +1 -1
  152. package/dist/esm/api/resources/inboxes/resources/messages/client/Client.mjs +1 -1
  153. package/dist/esm/api/resources/inboxes/resources/messages/exports.d.mts +2 -0
  154. package/dist/esm/api/resources/inboxes/resources/messages/exports.mjs +3 -0
  155. package/dist/esm/api/resources/inboxes/resources/metrics/exports.d.mts +2 -0
  156. package/dist/esm/api/resources/inboxes/resources/metrics/exports.mjs +3 -0
  157. package/dist/esm/api/resources/inboxes/resources/threads/client/Client.d.mts +17 -0
  158. package/dist/esm/api/resources/inboxes/resources/threads/client/Client.mjs +90 -0
  159. package/dist/esm/api/resources/inboxes/resources/threads/exports.d.mts +2 -0
  160. package/dist/esm/api/resources/inboxes/resources/threads/exports.mjs +3 -0
  161. package/dist/esm/api/resources/lists/exports.d.mts +2 -0
  162. package/dist/esm/api/resources/lists/exports.mjs +3 -0
  163. package/dist/esm/api/resources/messages/exports.d.mts +1 -0
  164. package/dist/esm/api/resources/messages/exports.mjs +2 -0
  165. package/dist/esm/api/resources/messages/types/UpdateMessageResponse.d.mts +5 -0
  166. package/dist/esm/api/resources/messages/types/UpdateMessageResponse.mjs +2 -0
  167. package/dist/esm/api/resources/messages/types/index.d.mts +1 -0
  168. package/dist/esm/api/resources/messages/types/index.mjs +1 -0
  169. package/dist/esm/api/resources/metrics/exports.d.mts +2 -0
  170. package/dist/esm/api/resources/metrics/exports.mjs +3 -0
  171. package/dist/esm/api/resources/metrics/types/QueryMetricsResponse.d.mts +1 -1
  172. package/dist/esm/api/resources/organizations/exports.d.mts +2 -0
  173. package/dist/esm/api/resources/organizations/exports.mjs +3 -0
  174. package/dist/esm/api/resources/pods/exports.d.mts +3 -0
  175. package/dist/esm/api/resources/pods/exports.mjs +4 -0
  176. package/dist/esm/api/resources/pods/resources/apiKeys/exports.d.mts +2 -0
  177. package/dist/esm/api/resources/pods/resources/apiKeys/exports.mjs +3 -0
  178. package/dist/esm/api/resources/pods/resources/domains/exports.d.mts +2 -0
  179. package/dist/esm/api/resources/pods/resources/domains/exports.mjs +3 -0
  180. package/dist/esm/api/resources/pods/resources/drafts/exports.d.mts +2 -0
  181. package/dist/esm/api/resources/pods/resources/drafts/exports.mjs +3 -0
  182. package/dist/esm/api/resources/pods/resources/inboxes/exports.d.mts +2 -0
  183. package/dist/esm/api/resources/pods/resources/inboxes/exports.mjs +3 -0
  184. package/dist/esm/api/resources/pods/resources/lists/exports.d.mts +2 -0
  185. package/dist/esm/api/resources/pods/resources/lists/exports.mjs +3 -0
  186. package/dist/esm/api/resources/pods/resources/metrics/exports.d.mts +2 -0
  187. package/dist/esm/api/resources/pods/resources/metrics/exports.mjs +3 -0
  188. package/dist/esm/api/resources/pods/resources/threads/client/Client.d.mts +17 -0
  189. package/dist/esm/api/resources/pods/resources/threads/client/Client.mjs +90 -0
  190. package/dist/esm/api/resources/pods/resources/threads/exports.d.mts +2 -0
  191. package/dist/esm/api/resources/pods/resources/threads/exports.mjs +3 -0
  192. package/dist/esm/api/resources/threads/client/Client.d.mts +16 -0
  193. package/dist/esm/api/resources/threads/client/Client.mjs +89 -0
  194. package/dist/esm/api/resources/threads/exports.d.mts +2 -0
  195. package/dist/esm/api/resources/threads/exports.mjs +3 -0
  196. package/dist/esm/api/resources/threads/types/UpdateThreadRequest.d.mts +6 -0
  197. package/dist/esm/api/resources/threads/types/UpdateThreadRequest.mjs +2 -0
  198. package/dist/esm/api/resources/threads/types/UpdateThreadResponse.d.mts +5 -0
  199. package/dist/esm/api/resources/threads/types/UpdateThreadResponse.mjs +2 -0
  200. package/dist/esm/api/resources/threads/types/index.d.mts +2 -0
  201. package/dist/esm/api/resources/threads/types/index.mjs +2 -0
  202. package/dist/esm/api/resources/webhooks/exports.d.mts +3 -0
  203. package/dist/esm/api/resources/webhooks/exports.mjs +4 -0
  204. package/dist/esm/api/resources/webhooks/resources/events/exports.d.mts +1 -0
  205. package/dist/esm/api/resources/webhooks/resources/events/exports.mjs +2 -0
  206. package/dist/esm/api/resources/websockets/client/Client.d.mts +6 -0
  207. package/dist/esm/api/resources/websockets/client/Client.mjs +8 -3
  208. package/dist/esm/api/resources/websockets/client/Socket.d.mts +2 -2
  209. package/dist/esm/api/resources/websockets/client/Socket.mjs +2 -2
  210. package/dist/esm/api/resources/websockets/exports.d.mts +3 -0
  211. package/dist/esm/api/resources/websockets/exports.mjs +4 -0
  212. package/dist/esm/core/fetcher/BinaryResponse.d.mts +1 -1
  213. package/dist/esm/core/fetcher/Fetcher.mjs +8 -2
  214. package/dist/esm/core/fetcher/index.d.mts +2 -0
  215. package/dist/esm/core/fetcher/index.mjs +1 -0
  216. package/dist/esm/core/fetcher/makePassthroughRequest.d.mts +49 -0
  217. package/dist/esm/core/fetcher/makePassthroughRequest.mjs +132 -0
  218. package/dist/esm/core/fetcher/makeRequest.d.mts +6 -1
  219. package/dist/esm/core/fetcher/makeRequest.mjs +28 -9
  220. package/dist/esm/core/runtime/runtime.mjs +8 -7
  221. package/dist/esm/core/schemas/builders/list/list.mjs +12 -17
  222. package/dist/esm/core/schemas/builders/object/object.mjs +102 -40
  223. package/dist/esm/core/schemas/builders/object-like/getObjectLikeUtils.mjs +10 -3
  224. package/dist/esm/core/schemas/builders/record/index.d.mts +2 -2
  225. package/dist/esm/core/schemas/builders/record/index.mjs +1 -1
  226. package/dist/esm/core/schemas/builders/record/record.d.mts +2 -1
  227. package/dist/esm/core/schemas/builders/record/record.mjs +62 -25
  228. package/dist/esm/core/schemas/builders/record/types.d.mts +2 -0
  229. package/dist/esm/core/schemas/builders/union/union.mjs +9 -12
  230. package/dist/esm/core/schemas/utils/isPlainObject.mjs +4 -6
  231. package/dist/esm/core/websocket/ws.d.mts +14 -2
  232. package/dist/esm/core/websocket/ws.mjs +51 -7
  233. package/dist/esm/serialization/resources/messages/types/UpdateMessageResponse.d.mts +12 -0
  234. package/dist/esm/serialization/resources/messages/types/UpdateMessageResponse.mjs +8 -0
  235. package/dist/esm/serialization/resources/messages/types/index.d.mts +1 -0
  236. package/dist/esm/serialization/resources/messages/types/index.mjs +1 -0
  237. package/dist/esm/serialization/resources/metrics/types/QueryMetricsResponse.mjs +1 -1
  238. package/dist/esm/serialization/resources/threads/types/UpdateThreadRequest.d.mts +10 -0
  239. package/dist/esm/serialization/resources/threads/types/UpdateThreadRequest.mjs +6 -0
  240. package/dist/esm/serialization/resources/threads/types/UpdateThreadResponse.d.mts +12 -0
  241. package/dist/esm/serialization/resources/threads/types/UpdateThreadResponse.mjs +8 -0
  242. package/dist/esm/serialization/resources/threads/types/index.d.mts +2 -0
  243. package/dist/esm/serialization/resources/threads/types/index.mjs +2 -0
  244. package/dist/esm/version.d.mts +1 -1
  245. package/dist/esm/version.mjs +1 -1
  246. package/package.json +305 -13
  247. package/reference.md +231 -1
@@ -2,6 +2,8 @@ import { filterObject } from "../../utils/filterObject.mjs";
2
2
  import { getErrorMessageForIncorrectType } from "../../utils/getErrorMessageForIncorrectType.mjs";
3
3
  import { isPlainObject } from "../../utils/isPlainObject.mjs";
4
4
  import { getSchemaUtils } from "../schema-utils/index.mjs";
5
+ // eslint-disable-next-line @typescript-eslint/unbound-method
6
+ const _hasOwn = Object.prototype.hasOwnProperty;
5
7
  export function getObjectLikeUtils(schema) {
6
8
  return {
7
9
  withParsedProperties: (properties) => withParsedProperties(schema, properties),
@@ -17,9 +19,14 @@ export function withParsedProperties(objectLike, properties) {
17
19
  if (!parsedObject.ok) {
18
20
  return parsedObject;
19
21
  }
20
- const additionalProperties = Object.entries(properties).reduce((processed, [key, value]) => {
21
- return Object.assign(Object.assign({}, processed), { [key]: typeof value === "function" ? value(parsedObject.value) : value });
22
- }, {});
22
+ const additionalProperties = {};
23
+ for (const key in properties) {
24
+ if (_hasOwn.call(properties, key)) {
25
+ const value = properties[key];
26
+ additionalProperties[key] =
27
+ typeof value === "function" ? value(parsedObject.value) : value;
28
+ }
29
+ }
23
30
  return {
24
31
  ok: true,
25
32
  value: Object.assign(Object.assign({}, parsedObject.value), additionalProperties),
@@ -1,2 +1,2 @@
1
- export { record } from "./record.mjs";
2
- export type { BaseRecordSchema, RecordSchema } from "./types.mjs";
1
+ export { partialRecord, record } from "./record.mjs";
2
+ export type { BasePartialRecordSchema, BaseRecordSchema, PartialRecordSchema, RecordSchema } from "./types.mjs";
@@ -1 +1 @@
1
- export { record } from "./record.mjs";
1
+ export { partialRecord, record } from "./record.mjs";
@@ -1,3 +1,4 @@
1
1
  import { type Schema } from "../../Schema.mjs";
2
- import type { RecordSchema } from "./types.mjs";
2
+ import type { PartialRecordSchema, RecordSchema } from "./types.mjs";
3
3
  export declare function record<RawKey extends string | number, RawValue, ParsedValue, ParsedKey extends string | number>(keySchema: Schema<RawKey, ParsedKey>, valueSchema: Schema<RawValue, ParsedValue>): RecordSchema<RawKey, RawValue, ParsedKey, ParsedValue>;
4
+ export declare function partialRecord<RawKey extends string | number, RawValue, ParsedValue, ParsedKey extends string | number>(keySchema: Schema<RawKey, ParsedKey>, valueSchema: Schema<RawValue, ParsedValue>): PartialRecordSchema<RawKey, RawValue, ParsedKey, ParsedValue>;
@@ -1,9 +1,10 @@
1
1
  import { SchemaType } from "../../Schema.mjs";
2
- import { entries } from "../../utils/entries.mjs";
3
2
  import { getErrorMessageForIncorrectType } from "../../utils/getErrorMessageForIncorrectType.mjs";
4
3
  import { isPlainObject } from "../../utils/isPlainObject.mjs";
5
4
  import { maybeSkipValidation } from "../../utils/maybeSkipValidation.mjs";
6
5
  import { getSchemaUtils } from "../schema-utils/index.mjs";
6
+ // eslint-disable-next-line @typescript-eslint/unbound-method
7
+ const _hasOwn = Object.prototype.hasOwnProperty;
7
8
  export function record(keySchema, valueSchema) {
8
9
  const baseSchema = {
9
10
  parse: (raw, opts) => {
@@ -40,6 +41,42 @@ export function record(keySchema, valueSchema) {
40
41
  };
41
42
  return Object.assign(Object.assign({}, maybeSkipValidation(baseSchema)), getSchemaUtils(baseSchema));
42
43
  }
44
+ export function partialRecord(keySchema, valueSchema) {
45
+ const baseSchema = {
46
+ parse: (raw, opts) => {
47
+ return validateAndTransformRecord({
48
+ value: raw,
49
+ isKeyNumeric: keySchema.getType() === SchemaType.NUMBER,
50
+ transformKey: (key) => {
51
+ var _a;
52
+ return keySchema.parse(key, Object.assign(Object.assign({}, opts), { breadcrumbsPrefix: [...((_a = opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix) !== null && _a !== void 0 ? _a : []), `${key} (key)`] }));
53
+ },
54
+ transformValue: (value, key) => {
55
+ var _a;
56
+ return valueSchema.parse(value, Object.assign(Object.assign({}, opts), { breadcrumbsPrefix: [...((_a = opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix) !== null && _a !== void 0 ? _a : []), `${key}`] }));
57
+ },
58
+ breadcrumbsPrefix: opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix,
59
+ });
60
+ },
61
+ json: (parsed, opts) => {
62
+ return validateAndTransformRecord({
63
+ value: parsed,
64
+ isKeyNumeric: keySchema.getType() === SchemaType.NUMBER,
65
+ transformKey: (key) => {
66
+ var _a;
67
+ return keySchema.json(key, Object.assign(Object.assign({}, opts), { breadcrumbsPrefix: [...((_a = opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix) !== null && _a !== void 0 ? _a : []), `${key} (key)`] }));
68
+ },
69
+ transformValue: (value, key) => {
70
+ var _a;
71
+ return valueSchema.json(value, Object.assign(Object.assign({}, opts), { breadcrumbsPrefix: [...((_a = opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix) !== null && _a !== void 0 ? _a : []), `${key}`] }));
72
+ },
73
+ breadcrumbsPrefix: opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix,
74
+ });
75
+ },
76
+ getType: () => SchemaType.RECORD,
77
+ };
78
+ return Object.assign(Object.assign({}, maybeSkipValidation(baseSchema)), getSchemaUtils(baseSchema));
79
+ }
43
80
  function validateAndTransformRecord({ value, isKeyNumeric, transformKey, transformValue, breadcrumbsPrefix = [], }) {
44
81
  if (!isPlainObject(value)) {
45
82
  return {
@@ -52,11 +89,16 @@ function validateAndTransformRecord({ value, isKeyNumeric, transformKey, transfo
52
89
  ],
53
90
  };
54
91
  }
55
- return entries(value).reduce((accPromise, [stringKey, value]) => {
56
- if (value === undefined) {
57
- return accPromise;
92
+ const result = {};
93
+ const errors = [];
94
+ for (const stringKey in value) {
95
+ if (!_hasOwn.call(value, stringKey)) {
96
+ continue;
97
+ }
98
+ const entryValue = value[stringKey];
99
+ if (entryValue === undefined) {
100
+ continue;
58
101
  }
59
- const acc = accPromise;
60
102
  let key = stringKey;
61
103
  if (isKeyNumeric) {
62
104
  const numberKey = stringKey.length > 0 ? Number(stringKey) : NaN;
@@ -65,26 +107,21 @@ function validateAndTransformRecord({ value, isKeyNumeric, transformKey, transfo
65
107
  }
66
108
  }
67
109
  const transformedKey = transformKey(key);
68
- const transformedValue = transformValue(value, key);
69
- if (acc.ok && transformedKey.ok && transformedValue.ok) {
70
- return {
71
- ok: true,
72
- value: Object.assign(Object.assign({}, acc.value), { [transformedKey.value]: transformedValue.value }),
73
- };
74
- }
75
- const errors = [];
76
- if (!acc.ok) {
77
- errors.push(...acc.errors);
110
+ const transformedValue = transformValue(entryValue, key);
111
+ if (transformedKey.ok && transformedValue.ok) {
112
+ result[transformedKey.value] = transformedValue.value;
78
113
  }
79
- if (!transformedKey.ok) {
80
- errors.push(...transformedKey.errors);
81
- }
82
- if (!transformedValue.ok) {
83
- errors.push(...transformedValue.errors);
114
+ else {
115
+ if (!transformedKey.ok) {
116
+ errors.push(...transformedKey.errors);
117
+ }
118
+ if (!transformedValue.ok) {
119
+ errors.push(...transformedValue.errors);
120
+ }
84
121
  }
85
- return {
86
- ok: false,
87
- errors,
88
- };
89
- }, { ok: true, value: {} });
122
+ }
123
+ if (errors.length === 0) {
124
+ return { ok: true, value: result };
125
+ }
126
+ return { ok: false, errors };
90
127
  }
@@ -2,3 +2,5 @@ import type { BaseSchema } from "../../Schema.mjs";
2
2
  import type { SchemaUtils } from "../schema-utils/index.mjs";
3
3
  export type RecordSchema<RawKey extends string | number, RawValue, ParsedKey extends string | number, ParsedValue> = BaseRecordSchema<RawKey, RawValue, ParsedKey, ParsedValue> & SchemaUtils<Record<RawKey, RawValue>, Record<ParsedKey, ParsedValue>>;
4
4
  export type BaseRecordSchema<RawKey extends string | number, RawValue, ParsedKey extends string | number, ParsedValue> = BaseSchema<Record<RawKey, RawValue>, Record<ParsedKey, ParsedValue>>;
5
+ export type PartialRecordSchema<RawKey extends string | number, RawValue, ParsedKey extends string | number, ParsedValue> = BasePartialRecordSchema<RawKey, RawValue, ParsedKey, ParsedValue> & SchemaUtils<Record<RawKey, RawValue>, Partial<Record<ParsedKey, ParsedValue>>>;
6
+ export type BasePartialRecordSchema<RawKey extends string | number, RawValue, ParsedKey extends string | number, ParsedValue> = BaseSchema<Record<RawKey, RawValue>, Partial<Record<ParsedKey, ParsedValue>>>;
@@ -1,14 +1,3 @@
1
- var __rest = (this && this.__rest) || function (s, e) {
2
- var t = {};
3
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
- t[p] = s[p];
5
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
- t[p[i]] = s[p[i]];
9
- }
10
- return t;
11
- };
12
1
  import { SchemaType } from "../../Schema.mjs";
13
2
  import { getErrorMessageForIncorrectType } from "../../utils/getErrorMessageForIncorrectType.mjs";
14
3
  import { isPlainObject } from "../../utils/isPlainObject.mjs";
@@ -17,6 +6,8 @@ import { maybeSkipValidation } from "../../utils/maybeSkipValidation.mjs";
17
6
  import { enum_ } from "../enum/index.mjs";
18
7
  import { getObjectLikeUtils } from "../object-like/index.mjs";
19
8
  import { getSchemaUtils } from "../schema-utils/index.mjs";
9
+ // eslint-disable-next-line @typescript-eslint/unbound-method
10
+ const _hasOwn = Object.prototype.hasOwnProperty;
20
11
  export function union(discriminant, union) {
21
12
  const rawDiscriminant = typeof discriminant === "string" ? discriminant : discriminant.rawDiscriminant;
22
13
  const parsedDiscriminant = typeof discriminant === "string"
@@ -76,7 +67,13 @@ function transformAndValidateUnion({ value, discriminant, transformedDiscriminan
76
67
  ],
77
68
  };
78
69
  }
79
- const _a = value, _b = discriminant, discriminantValue = _a[_b], additionalProperties = __rest(_a, [typeof _b === "symbol" ? _b : _b + ""]);
70
+ const discriminantValue = value[discriminant];
71
+ const additionalProperties = {};
72
+ for (const key in value) {
73
+ if (_hasOwn.call(value, key) && key !== discriminant) {
74
+ additionalProperties[key] = value[key];
75
+ }
76
+ }
80
77
  if (discriminantValue == null) {
81
78
  return {
82
79
  ok: false,
@@ -3,12 +3,10 @@ export function isPlainObject(value) {
3
3
  if (typeof value !== "object" || value === null) {
4
4
  return false;
5
5
  }
6
- if (Object.getPrototypeOf(value) === null) {
6
+ const proto = Object.getPrototypeOf(value);
7
+ if (proto === null) {
7
8
  return true;
8
9
  }
9
- let proto = value;
10
- while (Object.getPrototypeOf(proto) !== null) {
11
- proto = Object.getPrototypeOf(proto);
12
- }
13
- return Object.getPrototypeOf(value) === proto;
10
+ // Check that the prototype chain has exactly one level (i.e., proto is Object.prototype)
11
+ return Object.getPrototypeOf(proto) === null;
14
12
  }
@@ -9,6 +9,7 @@ export declare namespace ReconnectingWebSocket {
9
9
  options?: ReconnectingWebSocket.Options;
10
10
  headers?: Record<string, unknown>;
11
11
  queryParameters?: Record<string, unknown>;
12
+ abortSignal?: AbortSignal;
12
13
  }
13
14
  type Options = {
14
15
  WebSocket?: any;
@@ -47,7 +48,8 @@ export declare class ReconnectingWebSocket {
47
48
  private readonly _options;
48
49
  private readonly _headers?;
49
50
  private readonly _queryParameters?;
50
- constructor({ url, protocols, options, headers, queryParameters }: ReconnectingWebSocket.Args);
51
+ private readonly _abortSignal?;
52
+ constructor({ url, protocols, options, headers, queryParameters, abortSignal }: ReconnectingWebSocket.Args);
51
53
  static readonly CONNECTING = 0;
52
54
  static readonly OPEN = 1;
53
55
  static readonly CLOSING = 2;
@@ -83,7 +85,7 @@ export declare class ReconnectingWebSocket {
83
85
  /**
84
86
  * The current state of the connection; this is one of the Ready state constants
85
87
  */
86
- get readyState(): number;
88
+ get readyState(): ReconnectingWebSocket.ReadyState;
87
89
  /**
88
90
  * The URL as resolved by the constructor
89
91
  */
@@ -133,6 +135,7 @@ export declare class ReconnectingWebSocket {
133
135
  private _wait;
134
136
  private _getNextUrl;
135
137
  private _connect;
138
+ private _handleAbort;
136
139
  private _handleTimeout;
137
140
  private _disconnect;
138
141
  private _acceptOpen;
@@ -145,3 +148,12 @@ export declare class ReconnectingWebSocket {
145
148
  private _addListeners;
146
149
  private _clearTimeouts;
147
150
  }
151
+ export declare namespace ReconnectingWebSocket {
152
+ const ReadyState: {
153
+ readonly CONNECTING: 0;
154
+ readonly OPEN: 1;
155
+ readonly CLOSING: 2;
156
+ readonly CLOSED: 3;
157
+ };
158
+ type ReadyState = (typeof ReadyState)[keyof typeof ReadyState];
159
+ }
@@ -3,13 +3,13 @@ import { RUNTIME } from "../runtime/index.mjs";
3
3
  import { toQueryString } from "../url/qs.mjs";
4
4
  import * as Events from "./events.mjs";
5
5
  const getGlobalWebSocket = () => {
6
- if (typeof WebSocket !== "undefined") {
6
+ if (RUNTIME.type === "node" || RUNTIME.type === "bun" || RUNTIME.type === "deno") {
7
+ return NodeWebSocket;
8
+ }
9
+ else if (typeof WebSocket !== "undefined") {
7
10
  // @ts-ignore
8
11
  return WebSocket;
9
12
  }
10
- else if (RUNTIME.type === "node") {
11
- return NodeWebSocket;
12
- }
13
13
  return undefined;
14
14
  };
15
15
  /**
@@ -28,7 +28,7 @@ const DEFAULT_OPTIONS = {
28
28
  debug: false,
29
29
  };
30
30
  export class ReconnectingWebSocket {
31
- constructor({ url, protocols, options, headers, queryParameters }) {
31
+ constructor({ url, protocols, options, headers, queryParameters, abortSignal }) {
32
32
  this._listeners = {
33
33
  error: [],
34
34
  message: [],
@@ -62,6 +62,27 @@ export class ReconnectingWebSocket {
62
62
  * this indicates that the connection is ready to send and receive data
63
63
  */
64
64
  this.onopen = null;
65
+ this._handleAbort = () => {
66
+ if (this._closeCalled) {
67
+ return;
68
+ }
69
+ this._debug("abort signal fired");
70
+ this._shouldReconnect = false;
71
+ this._closeCalled = true;
72
+ this._clearTimeouts();
73
+ if (this._ws) {
74
+ this._removeListeners();
75
+ // Absorb async errors emitted by ws when closing during CONNECTING state
76
+ this._ws.addEventListener("error", () => { });
77
+ try {
78
+ this._ws.close(1000, "aborted");
79
+ this._handleClose(new Events.CloseEvent(1000, "aborted", this));
80
+ }
81
+ catch (_error) {
82
+ // ignore
83
+ }
84
+ }
85
+ };
65
86
  this._handleOpen = (event) => {
66
87
  this._debug("open event");
67
88
  const { minUptime = DEFAULT_OPTIONS.minUptime } = this._options;
@@ -112,6 +133,10 @@ export class ReconnectingWebSocket {
112
133
  this._options = options !== null && options !== void 0 ? options : DEFAULT_OPTIONS;
113
134
  this._headers = headers;
114
135
  this._queryParameters = queryParameters;
136
+ this._abortSignal = abortSignal;
137
+ if (this._abortSignal) {
138
+ this._abortSignal.addEventListener("abort", this._handleAbort, { once: true });
139
+ }
115
140
  if (this._options.startClosed) {
116
141
  this._shouldReconnect = false;
117
142
  }
@@ -175,7 +200,9 @@ export class ReconnectingWebSocket {
175
200
  if (this._ws) {
176
201
  return this._ws.readyState;
177
202
  }
178
- return this._options.startClosed ? ReconnectingWebSocket.CLOSED : ReconnectingWebSocket.CONNECTING;
203
+ return this._options.startClosed
204
+ ? ReconnectingWebSocket.ReadyState.CLOSED
205
+ : ReconnectingWebSocket.ReadyState.CONNECTING;
179
206
  }
180
207
  /**
181
208
  * The URL as resolved by the constructor
@@ -304,9 +331,14 @@ export class ReconnectingWebSocket {
304
331
  throw Error("Invalid URL");
305
332
  }
306
333
  _connect() {
334
+ var _a;
307
335
  if (this._connectLock || !this._shouldReconnect) {
308
336
  return;
309
337
  }
338
+ if ((_a = this._abortSignal) === null || _a === void 0 ? void 0 : _a.aborted) {
339
+ this._debug("connect aborted");
340
+ return;
341
+ }
310
342
  this._connectLock = true;
311
343
  const { maxRetries = DEFAULT_OPTIONS.maxRetries, connectionTimeout = DEFAULT_OPTIONS.connectionTimeout, WebSocket = getGlobalWebSocket(), } = this._options;
312
344
  if (this._retryCount >= maxRetries) {
@@ -322,7 +354,9 @@ export class ReconnectingWebSocket {
322
354
  this._wait()
323
355
  .then(() => this._getNextUrl(this._url))
324
356
  .then((url) => {
325
- if (this._closeCalled) {
357
+ var _a;
358
+ if (this._closeCalled || ((_a = this._abortSignal) === null || _a === void 0 ? void 0 : _a.aborted)) {
359
+ this._connectLock = false;
326
360
  return;
327
361
  }
328
362
  const options = {};
@@ -352,6 +386,8 @@ export class ReconnectingWebSocket {
352
386
  return;
353
387
  }
354
388
  this._removeListeners();
389
+ // Absorb async errors emitted by ws when closing during CONNECTING state
390
+ this._ws.addEventListener("error", () => { });
355
391
  try {
356
392
  this._ws.close(code, reason);
357
393
  this._handleClose(new Events.CloseEvent(code, reason, this));
@@ -405,3 +441,11 @@ ReconnectingWebSocket.CONNECTING = 0;
405
441
  ReconnectingWebSocket.OPEN = 1;
406
442
  ReconnectingWebSocket.CLOSING = 2;
407
443
  ReconnectingWebSocket.CLOSED = 3;
444
+ (function (ReconnectingWebSocket) {
445
+ ReconnectingWebSocket.ReadyState = {
446
+ CONNECTING: 0,
447
+ OPEN: 1,
448
+ CLOSING: 2,
449
+ CLOSED: 3,
450
+ };
451
+ })(ReconnectingWebSocket || (ReconnectingWebSocket = {}));
@@ -0,0 +1,12 @@
1
+ import type * as AgentMail from "../../../../api/index.mjs";
2
+ import * as core from "../../../../core/index.mjs";
3
+ import type * as serializers from "../../../index.mjs";
4
+ import { MessageId } from "./MessageId.mjs";
5
+ import { MessageLabels } from "./MessageLabels.mjs";
6
+ export declare const UpdateMessageResponse: core.serialization.ObjectSchema<serializers.UpdateMessageResponse.Raw, AgentMail.UpdateMessageResponse>;
7
+ export declare namespace UpdateMessageResponse {
8
+ interface Raw {
9
+ message_id: MessageId.Raw;
10
+ labels: MessageLabels.Raw;
11
+ }
12
+ }
@@ -0,0 +1,8 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ import * as core from "../../../../core/index.mjs";
3
+ import { MessageId } from "./MessageId.mjs";
4
+ import { MessageLabels } from "./MessageLabels.mjs";
5
+ export const UpdateMessageResponse = core.serialization.object({
6
+ messageId: core.serialization.property("message_id", MessageId),
7
+ labels: MessageLabels,
8
+ });
@@ -34,3 +34,4 @@ export * from "./SendMessageRequest.mjs";
34
34
  export * from "./SendMessageResponse.mjs";
35
35
  export * from "./SendMessageTo.mjs";
36
36
  export * from "./UpdateMessageRequest.mjs";
37
+ export * from "./UpdateMessageResponse.mjs";
@@ -34,3 +34,4 @@ export * from "./SendMessageRequest.mjs";
34
34
  export * from "./SendMessageResponse.mjs";
35
35
  export * from "./SendMessageTo.mjs";
36
36
  export * from "./UpdateMessageRequest.mjs";
37
+ export * from "./UpdateMessageResponse.mjs";
@@ -2,4 +2,4 @@
2
2
  import * as core from "../../../../core/index.mjs";
3
3
  import { MetricBucket } from "./MetricBucket.mjs";
4
4
  import { MetricEventType } from "./MetricEventType.mjs";
5
- export const QueryMetricsResponse = core.serialization.record(MetricEventType, core.serialization.list(MetricBucket).optional());
5
+ export const QueryMetricsResponse = core.serialization.partialRecord(MetricEventType, core.serialization.list(MetricBucket).optional());
@@ -0,0 +1,10 @@
1
+ import type * as AgentMail from "../../../../api/index.mjs";
2
+ import * as core from "../../../../core/index.mjs";
3
+ import type * as serializers from "../../../index.mjs";
4
+ export declare const UpdateThreadRequest: core.serialization.ObjectSchema<serializers.UpdateThreadRequest.Raw, AgentMail.UpdateThreadRequest>;
5
+ export declare namespace UpdateThreadRequest {
6
+ interface Raw {
7
+ add_labels?: string[] | null;
8
+ remove_labels?: string[] | null;
9
+ }
10
+ }
@@ -0,0 +1,6 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ import * as core from "../../../../core/index.mjs";
3
+ export const UpdateThreadRequest = core.serialization.object({
4
+ addLabels: core.serialization.property("add_labels", core.serialization.list(core.serialization.string()).optional()),
5
+ removeLabels: core.serialization.property("remove_labels", core.serialization.list(core.serialization.string()).optional()),
6
+ });
@@ -0,0 +1,12 @@
1
+ import type * as AgentMail from "../../../../api/index.mjs";
2
+ import * as core from "../../../../core/index.mjs";
3
+ import type * as serializers from "../../../index.mjs";
4
+ import { ThreadId } from "./ThreadId.mjs";
5
+ import { ThreadLabels } from "./ThreadLabels.mjs";
6
+ export declare const UpdateThreadResponse: core.serialization.ObjectSchema<serializers.UpdateThreadResponse.Raw, AgentMail.UpdateThreadResponse>;
7
+ export declare namespace UpdateThreadResponse {
8
+ interface Raw {
9
+ thread_id: ThreadId.Raw;
10
+ labels: ThreadLabels.Raw;
11
+ }
12
+ }
@@ -0,0 +1,8 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ import * as core from "../../../../core/index.mjs";
3
+ import { ThreadId } from "./ThreadId.mjs";
4
+ import { ThreadLabels } from "./ThreadLabels.mjs";
5
+ export const UpdateThreadResponse = core.serialization.object({
6
+ threadId: core.serialization.property("thread_id", ThreadId),
7
+ labels: ThreadLabels,
8
+ });
@@ -16,3 +16,5 @@ export * from "./ThreadSize.mjs";
16
16
  export * from "./ThreadSubject.mjs";
17
17
  export * from "./ThreadTimestamp.mjs";
18
18
  export * from "./ThreadUpdatedAt.mjs";
19
+ export * from "./UpdateThreadRequest.mjs";
20
+ export * from "./UpdateThreadResponse.mjs";
@@ -16,3 +16,5 @@ export * from "./ThreadSize.mjs";
16
16
  export * from "./ThreadSubject.mjs";
17
17
  export * from "./ThreadTimestamp.mjs";
18
18
  export * from "./ThreadUpdatedAt.mjs";
19
+ export * from "./UpdateThreadRequest.mjs";
20
+ export * from "./UpdateThreadResponse.mjs";
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.4.13";
1
+ export declare const SDK_VERSION = "0.4.15";
@@ -1 +1 @@
1
- export const SDK_VERSION = "0.4.13";
1
+ export const SDK_VERSION = "0.4.15";