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
@@ -10,8 +10,35 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.makeRequest = void 0;
13
+ exports.isCacheNoStoreSupported = isCacheNoStoreSupported;
14
+ exports.resetCacheNoStoreSupported = resetCacheNoStoreSupported;
13
15
  const signals_js_1 = require("./signals.js");
14
- const makeRequest = (fetchFn, url, method, headers, requestBody, timeoutMs, abortSignal, withCredentials, duplex) => __awaiter(void 0, void 0, void 0, function* () {
16
+ /**
17
+ * Cached result of checking whether the current runtime supports
18
+ * the `cache` option in `Request`. Some runtimes (e.g. Cloudflare Workers)
19
+ * throw a TypeError when this option is used.
20
+ */
21
+ let _cacheNoStoreSupported;
22
+ function isCacheNoStoreSupported() {
23
+ if (_cacheNoStoreSupported != null) {
24
+ return _cacheNoStoreSupported;
25
+ }
26
+ try {
27
+ new Request("http://localhost", { cache: "no-store" });
28
+ _cacheNoStoreSupported = true;
29
+ }
30
+ catch (_a) {
31
+ _cacheNoStoreSupported = false;
32
+ }
33
+ return _cacheNoStoreSupported;
34
+ }
35
+ /**
36
+ * Reset the cached result of `isCacheNoStoreSupported`. Exposed for testing only.
37
+ */
38
+ function resetCacheNoStoreSupported() {
39
+ _cacheNoStoreSupported = undefined;
40
+ }
41
+ const makeRequest = (fetchFn, url, method, headers, requestBody, timeoutMs, abortSignal, withCredentials, duplex, disableCache) => __awaiter(void 0, void 0, void 0, function* () {
15
42
  const signals = [];
16
43
  let timeoutAbortId;
17
44
  if (timeoutMs != null) {
@@ -23,15 +50,9 @@ const makeRequest = (fetchFn, url, method, headers, requestBody, timeoutMs, abor
23
50
  signals.push(abortSignal);
24
51
  }
25
52
  const newSignals = (0, signals_js_1.anySignal)(signals);
26
- const response = yield fetchFn(url, {
27
- method: method,
28
- headers,
29
- body: requestBody,
30
- signal: newSignals,
31
- credentials: withCredentials ? "include" : undefined,
53
+ const response = yield fetchFn(url, Object.assign({ method: method, headers, body: requestBody, signal: newSignals, credentials: withCredentials ? "include" : undefined,
32
54
  // @ts-ignore
33
- duplex,
34
- });
55
+ duplex }, (disableCache && isCacheNoStoreSupported() ? { cache: "no-store" } : {})));
35
56
  if (timeoutAbortId != null) {
36
57
  clearTimeout(timeoutAbortId);
37
58
  }
@@ -84,17 +84,18 @@ function evaluateRuntime() {
84
84
  }
85
85
  /**
86
86
  * A constant that indicates whether the environment the code is running is Node.JS.
87
+ *
88
+ * We assign `process` to a local variable first to avoid being flagged by
89
+ * bundlers that perform static analysis on `process.versions` (e.g. Next.js
90
+ * Edge Runtime warns about Node.js APIs even when they are guarded).
87
91
  */
88
- const isNode = typeof process !== "undefined" &&
89
- "version" in process &&
90
- !!process.version &&
91
- "versions" in process &&
92
- !!((_e = process.versions) === null || _e === void 0 ? void 0 : _e.node);
92
+ const _process = typeof process !== "undefined" ? process : undefined;
93
+ const isNode = typeof _process !== "undefined" && typeof ((_e = _process.versions) === null || _e === void 0 ? void 0 : _e.node) === "string";
93
94
  if (isNode) {
94
95
  return {
95
96
  type: "node",
96
- version: process.versions.node,
97
- parsedVersion: Number(process.versions.node.split(".")[0]),
97
+ version: _process.versions.node,
98
+ parsedVersion: Number(_process.versions.node.split(".")[0]),
98
99
  };
99
100
  }
100
101
  return {
@@ -31,24 +31,19 @@ function validateAndTransformArray(value, transformItem) {
31
31
  ],
32
32
  };
33
33
  }
34
- const maybeValidItems = value.map((item, index) => transformItem(item, index));
35
- return maybeValidItems.reduce((acc, item) => {
36
- if (acc.ok && item.ok) {
37
- return {
38
- ok: true,
39
- value: [...acc.value, item.value],
40
- };
34
+ const result = [];
35
+ const errors = [];
36
+ for (let i = 0; i < value.length; i++) {
37
+ const item = transformItem(value[i], i);
38
+ if (item.ok) {
39
+ result.push(item.value);
41
40
  }
42
- const errors = [];
43
- if (!acc.ok) {
44
- errors.push(...acc.errors);
45
- }
46
- if (!item.ok) {
41
+ else {
47
42
  errors.push(...item.errors);
48
43
  }
49
- return {
50
- ok: false,
51
- errors,
52
- };
53
- }, { ok: true, value: [] });
44
+ }
45
+ if (errors.length === 0) {
46
+ return { ok: true, value: result };
47
+ }
48
+ return { ok: false, errors };
54
49
  }
@@ -13,63 +13,113 @@ const partition_js_1 = require("../../utils/partition.js");
13
13
  const index_js_1 = require("../object-like/index.js");
14
14
  const index_js_2 = require("../schema-utils/index.js");
15
15
  const property_js_1 = require("./property.js");
16
+ // eslint-disable-next-line @typescript-eslint/unbound-method
17
+ const _hasOwn = Object.prototype.hasOwnProperty;
16
18
  function object(schemas) {
17
- const baseSchema = {
18
- _getRawProperties: () => Object.entries(schemas).map(([parsedKey, propertySchema]) => (0, property_js_1.isProperty)(propertySchema) ? propertySchema.rawKey : parsedKey),
19
- _getParsedProperties: () => (0, keys_js_1.keys)(schemas),
20
- parse: (raw, opts) => {
21
- const rawKeyToProperty = {};
22
- const requiredKeys = [];
19
+ // All property metadata is lazily computed on first use.
20
+ // This keeps schema construction free of iteration, which matters when
21
+ // many schemas are defined but only some are exercised at runtime.
22
+ // Required-key computation is also deferred because lazy() schemas may
23
+ // not be resolved at construction time.
24
+ let _rawKeyToProperty;
25
+ function getRawKeyToProperty() {
26
+ if (_rawKeyToProperty == null) {
27
+ _rawKeyToProperty = {};
23
28
  for (const [parsedKey, schemaOrObjectProperty] of (0, entries_js_1.entries)(schemas)) {
24
- const rawKey = (0, property_js_1.isProperty)(schemaOrObjectProperty) ? schemaOrObjectProperty.rawKey : parsedKey;
29
+ const rawKey = (0, property_js_1.isProperty)(schemaOrObjectProperty)
30
+ ? schemaOrObjectProperty.rawKey
31
+ : parsedKey;
25
32
  const valueSchema = (0, property_js_1.isProperty)(schemaOrObjectProperty)
26
33
  ? schemaOrObjectProperty.valueSchema
27
34
  : schemaOrObjectProperty;
28
- const property = {
35
+ _rawKeyToProperty[rawKey] = {
29
36
  rawKey,
30
37
  parsedKey: parsedKey,
31
38
  valueSchema,
32
39
  };
33
- rawKeyToProperty[rawKey] = property;
40
+ }
41
+ }
42
+ return _rawKeyToProperty;
43
+ }
44
+ let _parseRequiredKeys;
45
+ let _jsonRequiredKeys;
46
+ let _parseRequiredKeysSet;
47
+ let _jsonRequiredKeysSet;
48
+ function getParseRequiredKeys() {
49
+ if (_parseRequiredKeys == null) {
50
+ _parseRequiredKeys = [];
51
+ _jsonRequiredKeys = [];
52
+ for (const [parsedKey, schemaOrObjectProperty] of (0, entries_js_1.entries)(schemas)) {
53
+ const rawKey = (0, property_js_1.isProperty)(schemaOrObjectProperty)
54
+ ? schemaOrObjectProperty.rawKey
55
+ : parsedKey;
56
+ const valueSchema = (0, property_js_1.isProperty)(schemaOrObjectProperty)
57
+ ? schemaOrObjectProperty.valueSchema
58
+ : schemaOrObjectProperty;
34
59
  if (isSchemaRequired(valueSchema)) {
35
- requiredKeys.push(rawKey);
60
+ _parseRequiredKeys.push(rawKey);
61
+ _jsonRequiredKeys.push(parsedKey);
36
62
  }
37
63
  }
64
+ _parseRequiredKeysSet = new Set(_parseRequiredKeys);
65
+ _jsonRequiredKeysSet = new Set(_jsonRequiredKeys);
66
+ }
67
+ return _parseRequiredKeys;
68
+ }
69
+ function getJsonRequiredKeys() {
70
+ if (_jsonRequiredKeys == null) {
71
+ getParseRequiredKeys();
72
+ }
73
+ return _jsonRequiredKeys;
74
+ }
75
+ function getParseRequiredKeysSet() {
76
+ if (_parseRequiredKeysSet == null) {
77
+ getParseRequiredKeys();
78
+ }
79
+ return _parseRequiredKeysSet;
80
+ }
81
+ function getJsonRequiredKeysSet() {
82
+ if (_jsonRequiredKeysSet == null) {
83
+ getParseRequiredKeys();
84
+ }
85
+ return _jsonRequiredKeysSet;
86
+ }
87
+ const baseSchema = {
88
+ _getRawProperties: () => Object.entries(schemas).map(([parsedKey, propertySchema]) => (0, property_js_1.isProperty)(propertySchema) ? propertySchema.rawKey : parsedKey),
89
+ _getParsedProperties: () => (0, keys_js_1.keys)(schemas),
90
+ parse: (raw, opts) => {
91
+ var _a;
92
+ const breadcrumbsPrefix = (_a = opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix) !== null && _a !== void 0 ? _a : [];
38
93
  return validateAndTransformObject({
39
94
  value: raw,
40
- requiredKeys,
95
+ requiredKeys: getParseRequiredKeys(),
96
+ requiredKeysSet: getParseRequiredKeysSet(),
41
97
  getProperty: (rawKey) => {
42
- const property = rawKeyToProperty[rawKey];
98
+ const property = getRawKeyToProperty()[rawKey];
43
99
  if (property == null) {
44
100
  return undefined;
45
101
  }
46
102
  return {
47
103
  transformedKey: property.parsedKey,
48
104
  transform: (propertyValue) => {
49
- var _a;
50
- return property.valueSchema.parse(propertyValue, Object.assign(Object.assign({}, opts), { breadcrumbsPrefix: [...((_a = opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix) !== null && _a !== void 0 ? _a : []), rawKey] }));
105
+ const childBreadcrumbs = [...breadcrumbsPrefix, rawKey];
106
+ return property.valueSchema.parse(propertyValue, Object.assign(Object.assign({}, opts), { breadcrumbsPrefix: childBreadcrumbs }));
51
107
  },
52
108
  };
53
109
  },
54
110
  unrecognizedObjectKeys: opts === null || opts === void 0 ? void 0 : opts.unrecognizedObjectKeys,
55
111
  skipValidation: opts === null || opts === void 0 ? void 0 : opts.skipValidation,
56
- breadcrumbsPrefix: opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix,
112
+ breadcrumbsPrefix,
57
113
  omitUndefined: opts === null || opts === void 0 ? void 0 : opts.omitUndefined,
58
114
  });
59
115
  },
60
116
  json: (parsed, opts) => {
61
- const requiredKeys = [];
62
- for (const [parsedKey, schemaOrObjectProperty] of (0, entries_js_1.entries)(schemas)) {
63
- const valueSchema = (0, property_js_1.isProperty)(schemaOrObjectProperty)
64
- ? schemaOrObjectProperty.valueSchema
65
- : schemaOrObjectProperty;
66
- if (isSchemaRequired(valueSchema)) {
67
- requiredKeys.push(parsedKey);
68
- }
69
- }
117
+ var _a;
118
+ const breadcrumbsPrefix = (_a = opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix) !== null && _a !== void 0 ? _a : [];
70
119
  return validateAndTransformObject({
71
120
  value: parsed,
72
- requiredKeys,
121
+ requiredKeys: getJsonRequiredKeys(),
122
+ requiredKeysSet: getJsonRequiredKeysSet(),
73
123
  getProperty: (parsedKey) => {
74
124
  const property = schemas[parsedKey];
75
125
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
@@ -80,8 +130,8 @@ function object(schemas) {
80
130
  return {
81
131
  transformedKey: property.rawKey,
82
132
  transform: (propertyValue) => {
83
- var _a;
84
- return property.valueSchema.json(propertyValue, Object.assign(Object.assign({}, opts), { breadcrumbsPrefix: [...((_a = opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix) !== null && _a !== void 0 ? _a : []), parsedKey] }));
133
+ const childBreadcrumbs = [...breadcrumbsPrefix, parsedKey];
134
+ return property.valueSchema.json(propertyValue, Object.assign(Object.assign({}, opts), { breadcrumbsPrefix: childBreadcrumbs }));
85
135
  },
86
136
  };
87
137
  }
@@ -89,15 +139,15 @@ function object(schemas) {
89
139
  return {
90
140
  transformedKey: parsedKey,
91
141
  transform: (propertyValue) => {
92
- var _a;
93
- return property.json(propertyValue, Object.assign(Object.assign({}, opts), { breadcrumbsPrefix: [...((_a = opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix) !== null && _a !== void 0 ? _a : []), parsedKey] }));
142
+ const childBreadcrumbs = [...breadcrumbsPrefix, parsedKey];
143
+ return property.json(propertyValue, Object.assign(Object.assign({}, opts), { breadcrumbsPrefix: childBreadcrumbs }));
94
144
  },
95
145
  };
96
146
  }
97
147
  },
98
148
  unrecognizedObjectKeys: opts === null || opts === void 0 ? void 0 : opts.unrecognizedObjectKeys,
99
149
  skipValidation: opts === null || opts === void 0 ? void 0 : opts.skipValidation,
100
- breadcrumbsPrefix: opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix,
150
+ breadcrumbsPrefix,
101
151
  omitUndefined: opts === null || opts === void 0 ? void 0 : opts.omitUndefined,
102
152
  });
103
153
  },
@@ -105,7 +155,7 @@ function object(schemas) {
105
155
  };
106
156
  return Object.assign(Object.assign(Object.assign(Object.assign({}, (0, maybeSkipValidation_js_1.maybeSkipValidation)(baseSchema)), (0, index_js_2.getSchemaUtils)(baseSchema)), (0, index_js_1.getObjectLikeUtils)(baseSchema)), getObjectUtils(baseSchema));
107
157
  }
108
- function validateAndTransformObject({ value, requiredKeys, getProperty, unrecognizedObjectKeys = "fail", skipValidation = false, breadcrumbsPrefix = [], }) {
158
+ function validateAndTransformObject({ value, requiredKeys, requiredKeysSet, getProperty, unrecognizedObjectKeys = "fail", skipValidation = false, breadcrumbsPrefix = [], }) {
109
159
  if (!(0, isPlainObject_js_1.isPlainObject)(value)) {
110
160
  return {
111
161
  ok: false,
@@ -117,13 +167,21 @@ function validateAndTransformObject({ value, requiredKeys, getProperty, unrecogn
117
167
  ],
118
168
  };
119
169
  }
120
- const missingRequiredKeys = new Set(requiredKeys);
170
+ // Track which required keys have been seen.
171
+ // Use a counter instead of copying the Set to avoid per-call allocation.
172
+ let missingRequiredCount = requiredKeys.length;
121
173
  const errors = [];
122
174
  const transformed = {};
123
- for (const [preTransformedKey, preTransformedItemValue] of Object.entries(value)) {
175
+ for (const preTransformedKey in value) {
176
+ if (!_hasOwn.call(value, preTransformedKey)) {
177
+ continue;
178
+ }
179
+ const preTransformedItemValue = value[preTransformedKey];
124
180
  const property = getProperty(preTransformedKey);
125
181
  if (property != null) {
126
- missingRequiredKeys.delete(preTransformedKey);
182
+ if (missingRequiredCount > 0 && requiredKeysSet.has(preTransformedKey)) {
183
+ missingRequiredCount--;
184
+ }
127
185
  const value = property.transform(preTransformedItemValue);
128
186
  if (value.ok) {
129
187
  transformed[property.transformedKey] = value.value;
@@ -149,12 +207,16 @@ function validateAndTransformObject({ value, requiredKeys, getProperty, unrecogn
149
207
  }
150
208
  }
151
209
  }
152
- errors.push(...requiredKeys
153
- .filter((key) => missingRequiredKeys.has(key))
154
- .map((key) => ({
155
- path: breadcrumbsPrefix,
156
- message: `Missing required key "${key}"`,
157
- })));
210
+ if (missingRequiredCount > 0) {
211
+ for (const key of requiredKeys) {
212
+ if (!(key in value)) {
213
+ errors.push({
214
+ path: breadcrumbsPrefix,
215
+ message: `Missing required key "${key}"`,
216
+ });
217
+ }
218
+ }
219
+ }
158
220
  if (errors.length === 0 || skipValidation) {
159
221
  return {
160
222
  ok: true,
@@ -6,6 +6,8 @@ const filterObject_js_1 = require("../../utils/filterObject.js");
6
6
  const getErrorMessageForIncorrectType_js_1 = require("../../utils/getErrorMessageForIncorrectType.js");
7
7
  const isPlainObject_js_1 = require("../../utils/isPlainObject.js");
8
8
  const index_js_1 = require("../schema-utils/index.js");
9
+ // eslint-disable-next-line @typescript-eslint/unbound-method
10
+ const _hasOwn = Object.prototype.hasOwnProperty;
9
11
  function getObjectLikeUtils(schema) {
10
12
  return {
11
13
  withParsedProperties: (properties) => withParsedProperties(schema, properties),
@@ -21,9 +23,14 @@ function withParsedProperties(objectLike, properties) {
21
23
  if (!parsedObject.ok) {
22
24
  return parsedObject;
23
25
  }
24
- const additionalProperties = Object.entries(properties).reduce((processed, [key, value]) => {
25
- return Object.assign(Object.assign({}, processed), { [key]: typeof value === "function" ? value(parsedObject.value) : value });
26
- }, {});
26
+ const additionalProperties = {};
27
+ for (const key in properties) {
28
+ if (_hasOwn.call(properties, key)) {
29
+ const value = properties[key];
30
+ additionalProperties[key] =
31
+ typeof value === "function" ? value(parsedObject.value) : value;
32
+ }
33
+ }
27
34
  return {
28
35
  ok: true,
29
36
  value: Object.assign(Object.assign({}, parsedObject.value), additionalProperties),
@@ -1,2 +1,2 @@
1
- export { record } from "./record.js";
2
- export type { BaseRecordSchema, RecordSchema } from "./types.js";
1
+ export { partialRecord, record } from "./record.js";
2
+ export type { BasePartialRecordSchema, BaseRecordSchema, PartialRecordSchema, RecordSchema } from "./types.js";
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.record = void 0;
3
+ exports.record = exports.partialRecord = void 0;
4
4
  var record_js_1 = require("./record.js");
5
+ Object.defineProperty(exports, "partialRecord", { enumerable: true, get: function () { return record_js_1.partialRecord; } });
5
6
  Object.defineProperty(exports, "record", { enumerable: true, get: function () { return record_js_1.record; } });
@@ -1,3 +1,4 @@
1
1
  import { type Schema } from "../../Schema.js";
2
- import type { RecordSchema } from "./types.js";
2
+ import type { PartialRecordSchema, RecordSchema } from "./types.js";
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,12 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.record = record;
4
+ exports.partialRecord = partialRecord;
4
5
  const Schema_js_1 = require("../../Schema.js");
5
- const entries_js_1 = require("../../utils/entries.js");
6
6
  const getErrorMessageForIncorrectType_js_1 = require("../../utils/getErrorMessageForIncorrectType.js");
7
7
  const isPlainObject_js_1 = require("../../utils/isPlainObject.js");
8
8
  const maybeSkipValidation_js_1 = require("../../utils/maybeSkipValidation.js");
9
9
  const index_js_1 = require("../schema-utils/index.js");
10
+ // eslint-disable-next-line @typescript-eslint/unbound-method
11
+ const _hasOwn = Object.prototype.hasOwnProperty;
10
12
  function record(keySchema, valueSchema) {
11
13
  const baseSchema = {
12
14
  parse: (raw, opts) => {
@@ -43,6 +45,42 @@ function record(keySchema, valueSchema) {
43
45
  };
44
46
  return Object.assign(Object.assign({}, (0, maybeSkipValidation_js_1.maybeSkipValidation)(baseSchema)), (0, index_js_1.getSchemaUtils)(baseSchema));
45
47
  }
48
+ function partialRecord(keySchema, valueSchema) {
49
+ const baseSchema = {
50
+ parse: (raw, opts) => {
51
+ return validateAndTransformRecord({
52
+ value: raw,
53
+ isKeyNumeric: keySchema.getType() === Schema_js_1.SchemaType.NUMBER,
54
+ transformKey: (key) => {
55
+ var _a;
56
+ 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)`] }));
57
+ },
58
+ transformValue: (value, key) => {
59
+ var _a;
60
+ 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}`] }));
61
+ },
62
+ breadcrumbsPrefix: opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix,
63
+ });
64
+ },
65
+ json: (parsed, opts) => {
66
+ return validateAndTransformRecord({
67
+ value: parsed,
68
+ isKeyNumeric: keySchema.getType() === Schema_js_1.SchemaType.NUMBER,
69
+ transformKey: (key) => {
70
+ var _a;
71
+ 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)`] }));
72
+ },
73
+ transformValue: (value, key) => {
74
+ var _a;
75
+ 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}`] }));
76
+ },
77
+ breadcrumbsPrefix: opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix,
78
+ });
79
+ },
80
+ getType: () => Schema_js_1.SchemaType.RECORD,
81
+ };
82
+ return Object.assign(Object.assign({}, (0, maybeSkipValidation_js_1.maybeSkipValidation)(baseSchema)), (0, index_js_1.getSchemaUtils)(baseSchema));
83
+ }
46
84
  function validateAndTransformRecord({ value, isKeyNumeric, transformKey, transformValue, breadcrumbsPrefix = [], }) {
47
85
  if (!(0, isPlainObject_js_1.isPlainObject)(value)) {
48
86
  return {
@@ -55,11 +93,16 @@ function validateAndTransformRecord({ value, isKeyNumeric, transformKey, transfo
55
93
  ],
56
94
  };
57
95
  }
58
- return (0, entries_js_1.entries)(value).reduce((accPromise, [stringKey, value]) => {
59
- if (value === undefined) {
60
- return accPromise;
96
+ const result = {};
97
+ const errors = [];
98
+ for (const stringKey in value) {
99
+ if (!_hasOwn.call(value, stringKey)) {
100
+ continue;
101
+ }
102
+ const entryValue = value[stringKey];
103
+ if (entryValue === undefined) {
104
+ continue;
61
105
  }
62
- const acc = accPromise;
63
106
  let key = stringKey;
64
107
  if (isKeyNumeric) {
65
108
  const numberKey = stringKey.length > 0 ? Number(stringKey) : NaN;
@@ -68,26 +111,21 @@ function validateAndTransformRecord({ value, isKeyNumeric, transformKey, transfo
68
111
  }
69
112
  }
70
113
  const transformedKey = transformKey(key);
71
- const transformedValue = transformValue(value, key);
72
- if (acc.ok && transformedKey.ok && transformedValue.ok) {
73
- return {
74
- ok: true,
75
- value: Object.assign(Object.assign({}, acc.value), { [transformedKey.value]: transformedValue.value }),
76
- };
77
- }
78
- const errors = [];
79
- if (!acc.ok) {
80
- errors.push(...acc.errors);
114
+ const transformedValue = transformValue(entryValue, key);
115
+ if (transformedKey.ok && transformedValue.ok) {
116
+ result[transformedKey.value] = transformedValue.value;
81
117
  }
82
- if (!transformedKey.ok) {
83
- errors.push(...transformedKey.errors);
84
- }
85
- if (!transformedValue.ok) {
86
- errors.push(...transformedValue.errors);
118
+ else {
119
+ if (!transformedKey.ok) {
120
+ errors.push(...transformedKey.errors);
121
+ }
122
+ if (!transformedValue.ok) {
123
+ errors.push(...transformedValue.errors);
124
+ }
87
125
  }
88
- return {
89
- ok: false,
90
- errors,
91
- };
92
- }, { ok: true, value: {} });
126
+ }
127
+ if (errors.length === 0) {
128
+ return { ok: true, value: result };
129
+ }
130
+ return { ok: false, errors };
93
131
  }
@@ -2,3 +2,5 @@ import type { BaseSchema } from "../../Schema.js";
2
2
  import type { SchemaUtils } from "../schema-utils/index.js";
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,15 +1,4 @@
1
1
  "use strict";
2
- var __rest = (this && this.__rest) || function (s, e) {
3
- var t = {};
4
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
- t[p] = s[p];
6
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
- t[p[i]] = s[p[i]];
10
- }
11
- return t;
12
- };
13
2
  Object.defineProperty(exports, "__esModule", { value: true });
14
3
  exports.union = union;
15
4
  const Schema_js_1 = require("../../Schema.js");
@@ -20,6 +9,8 @@ const maybeSkipValidation_js_1 = require("../../utils/maybeSkipValidation.js");
20
9
  const index_js_1 = require("../enum/index.js");
21
10
  const index_js_2 = require("../object-like/index.js");
22
11
  const index_js_3 = require("../schema-utils/index.js");
12
+ // eslint-disable-next-line @typescript-eslint/unbound-method
13
+ const _hasOwn = Object.prototype.hasOwnProperty;
23
14
  function union(discriminant, union) {
24
15
  const rawDiscriminant = typeof discriminant === "string" ? discriminant : discriminant.rawDiscriminant;
25
16
  const parsedDiscriminant = typeof discriminant === "string"
@@ -79,7 +70,13 @@ function transformAndValidateUnion({ value, discriminant, transformedDiscriminan
79
70
  ],
80
71
  };
81
72
  }
82
- const _a = value, _b = discriminant, discriminantValue = _a[_b], additionalProperties = __rest(_a, [typeof _b === "symbol" ? _b : _b + ""]);
73
+ const discriminantValue = value[discriminant];
74
+ const additionalProperties = {};
75
+ for (const key in value) {
76
+ if (_hasOwn.call(value, key) && key !== discriminant) {
77
+ additionalProperties[key] = value[key];
78
+ }
79
+ }
83
80
  if (discriminantValue == null) {
84
81
  return {
85
82
  ok: false,
@@ -6,12 +6,10 @@ function isPlainObject(value) {
6
6
  if (typeof value !== "object" || value === null) {
7
7
  return false;
8
8
  }
9
- if (Object.getPrototypeOf(value) === null) {
9
+ const proto = Object.getPrototypeOf(value);
10
+ if (proto === null) {
10
11
  return true;
11
12
  }
12
- let proto = value;
13
- while (Object.getPrototypeOf(proto) !== null) {
14
- proto = Object.getPrototypeOf(proto);
15
- }
16
- return Object.getPrototypeOf(value) === proto;
13
+ // Check that the prototype chain has exactly one level (i.e., proto is Object.prototype)
14
+ return Object.getPrototypeOf(proto) === null;
17
15
  }
@@ -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
+ }