rcs-js 0.0.1 → 1.0.2

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 (672) hide show
  1. package/Client.d.ts +93 -0
  2. package/Client.js +384 -0
  3. package/README.md +137 -0
  4. package/api/client/index.d.ts +1 -0
  5. package/api/client/index.js +17 -0
  6. package/api/client/requests/CheckRcsCapabilityRequest.d.ts +21 -0
  7. package/api/client/requests/CheckRcsCapabilityRequest.js +5 -0
  8. package/api/client/requests/UpdateSettingsRequest.d.ts +13 -0
  9. package/api/client/requests/UpdateSettingsRequest.js +5 -0
  10. package/api/client/requests/index.d.ts +2 -0
  11. package/api/client/requests/index.js +2 -0
  12. package/api/errors/BadRequestError.d.ts +8 -0
  13. package/api/errors/BadRequestError.js +41 -0
  14. package/api/errors/InternalServerError.d.ts +8 -0
  15. package/api/errors/InternalServerError.js +41 -0
  16. package/api/errors/UnauthorizedError.d.ts +8 -0
  17. package/api/errors/UnauthorizedError.js +41 -0
  18. package/api/errors/index.d.ts +3 -0
  19. package/api/errors/index.js +19 -0
  20. package/api/index.d.ts +3 -0
  21. package/api/index.js +19 -0
  22. package/api/types/Action.d.ts +5 -0
  23. package/api/types/Action.js +5 -0
  24. package/api/types/BadRequestErrorBody.d.ts +6 -0
  25. package/api/types/BadRequestErrorBody.js +5 -0
  26. package/api/types/BasicRcs.d.ts +13 -0
  27. package/api/types/BasicRcs.js +5 -0
  28. package/api/types/BasicRcsMessage.d.ts +10 -0
  29. package/api/types/BasicRcsMessage.js +5 -0
  30. package/api/types/Call.d.ts +9 -0
  31. package/api/types/Call.js +5 -0
  32. package/api/types/Card.d.ts +16 -0
  33. package/api/types/Card.js +5 -0
  34. package/api/types/CardRcs.d.ts +12 -0
  35. package/api/types/CardRcs.js +5 -0
  36. package/api/types/CardRcsMessage.d.ts +13 -0
  37. package/api/types/CardRcsMessage.js +5 -0
  38. package/api/types/CardStyle.d.ts +16 -0
  39. package/api/types/CardStyle.js +5 -0
  40. package/api/types/CardStyleImageAlignment.d.ts +11 -0
  41. package/api/types/CardStyleImageAlignment.js +10 -0
  42. package/api/types/CardStyleMediaHeight.d.ts +12 -0
  43. package/api/types/CardStyleMediaHeight.js +11 -0
  44. package/api/types/CardStyleOrientation.d.ts +11 -0
  45. package/api/types/CardStyleOrientation.js +10 -0
  46. package/api/types/CardStyleWidth.d.ts +11 -0
  47. package/api/types/CardStyleWidth.js +10 -0
  48. package/api/types/CarouselRcs.d.ts +12 -0
  49. package/api/types/CarouselRcs.js +5 -0
  50. package/api/types/CarouselRcsMessage.d.ts +13 -0
  51. package/api/types/CarouselRcsMessage.js +5 -0
  52. package/api/types/CheckRcsCapabilityResponse.d.ts +7 -0
  53. package/api/types/CheckRcsCapabilityResponse.js +5 -0
  54. package/api/types/Event.d.ts +15 -0
  55. package/api/types/Event.js +5 -0
  56. package/api/types/GetAccountNumberResponse.d.ts +7 -0
  57. package/api/types/GetAccountNumberResponse.js +5 -0
  58. package/api/types/InternalServerErrorBody.d.ts +6 -0
  59. package/api/types/InternalServerErrorBody.js +5 -0
  60. package/api/types/LatLng.d.ts +12 -0
  61. package/api/types/LatLng.js +5 -0
  62. package/api/types/MediaRcs.d.ts +12 -0
  63. package/api/types/MediaRcs.js +5 -0
  64. package/api/types/MediaRcsMessage.d.ts +14 -0
  65. package/api/types/MediaRcsMessage.js +5 -0
  66. package/api/types/MediaType.d.ts +14 -0
  67. package/api/types/MediaType.js +13 -0
  68. package/api/types/PhoneNumber.d.ts +7 -0
  69. package/api/types/PhoneNumber.js +5 -0
  70. package/api/types/Postback.d.ts +11 -0
  71. package/api/types/Postback.js +5 -0
  72. package/api/types/SendRequest.d.ts +5 -0
  73. package/api/types/SendRequest.js +5 -0
  74. package/api/types/SendResponse.d.ts +7 -0
  75. package/api/types/SendResponse.js +5 -0
  76. package/api/types/ShareLocation.d.ts +7 -0
  77. package/api/types/ShareLocation.js +5 -0
  78. package/api/types/Sms.d.ts +12 -0
  79. package/api/types/Sms.js +5 -0
  80. package/api/types/SmsMessage.d.ts +12 -0
  81. package/api/types/SmsMessage.js +5 -0
  82. package/api/types/UnauthorizedErrorBody.d.ts +6 -0
  83. package/api/types/UnauthorizedErrorBody.js +5 -0
  84. package/api/types/UpdateSettingsResponse.d.ts +6 -0
  85. package/api/types/UpdateSettingsResponse.js +5 -0
  86. package/api/types/Url.d.ts +9 -0
  87. package/api/types/Url.js +5 -0
  88. package/api/types/ViewLocation.d.ts +11 -0
  89. package/api/types/ViewLocation.js +5 -0
  90. package/api/types/index.d.ts +34 -0
  91. package/api/types/index.js +50 -0
  92. package/core/fetcher/APIResponse.d.ts +10 -0
  93. package/core/fetcher/APIResponse.js +2 -0
  94. package/core/fetcher/Fetcher.d.ts +39 -0
  95. package/core/fetcher/Fetcher.js +99 -0
  96. package/core/fetcher/Supplier.d.ts +4 -0
  97. package/core/fetcher/Supplier.js +22 -0
  98. package/core/fetcher/createRequestUrl.d.ts +1 -0
  99. package/core/fetcher/createRequestUrl.js +13 -0
  100. package/core/fetcher/getFetchFn.d.ts +4 -0
  101. package/core/fetcher/getFetchFn.js +59 -0
  102. package/core/fetcher/getHeader.d.ts +1 -0
  103. package/core/fetcher/getHeader.js +12 -0
  104. package/core/fetcher/getRequestBody.d.ts +7 -0
  105. package/core/fetcher/getRequestBody.js +23 -0
  106. package/core/fetcher/getResponseBody.d.ts +1 -0
  107. package/core/fetcher/getResponseBody.js +52 -0
  108. package/core/fetcher/index.d.ts +5 -0
  109. package/core/fetcher/index.js +9 -0
  110. package/core/fetcher/makeRequest.d.ts +1 -0
  111. package/core/fetcher/makeRequest.js +42 -0
  112. package/core/fetcher/requestWithRetries.d.ts +1 -0
  113. package/core/fetcher/requestWithRetries.js +32 -0
  114. package/core/fetcher/signals.d.ts +12 -0
  115. package/core/fetcher/signals.js +37 -0
  116. package/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.d.ts +30 -0
  117. package/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.js +247 -0
  118. package/core/fetcher/stream-wrappers/NodePre18StreamWrapper.d.ts +22 -0
  119. package/core/fetcher/stream-wrappers/NodePre18StreamWrapper.js +124 -0
  120. package/core/fetcher/stream-wrappers/UndiciStreamWrapper.d.ts +31 -0
  121. package/core/fetcher/stream-wrappers/UndiciStreamWrapper.js +229 -0
  122. package/core/fetcher/stream-wrappers/chooseStreamWrapper.d.ts +18 -0
  123. package/core/fetcher/stream-wrappers/chooseStreamWrapper.js +50 -0
  124. package/core/index.d.ts +3 -0
  125. package/core/index.js +32 -0
  126. package/core/runtime/index.d.ts +1 -0
  127. package/core/runtime/index.js +5 -0
  128. package/core/runtime/runtime.d.ts +9 -0
  129. package/core/runtime/runtime.js +93 -0
  130. package/core/schemas/Schema.d.ts +85 -0
  131. package/core/schemas/Schema.js +22 -0
  132. package/core/schemas/builders/bigint/bigint.d.ts +2 -0
  133. package/core/schemas/builders/bigint/bigint.js +50 -0
  134. package/core/schemas/builders/bigint/index.d.ts +1 -0
  135. package/core/schemas/builders/bigint/index.js +5 -0
  136. package/core/schemas/builders/date/date.d.ts +2 -0
  137. package/core/schemas/builders/date/date.js +63 -0
  138. package/core/schemas/builders/date/index.d.ts +1 -0
  139. package/core/schemas/builders/date/index.js +5 -0
  140. package/core/schemas/builders/enum/enum.d.ts +2 -0
  141. package/core/schemas/builders/enum/enum.js +39 -0
  142. package/core/schemas/builders/enum/index.d.ts +1 -0
  143. package/core/schemas/builders/enum/index.js +5 -0
  144. package/core/schemas/builders/index.d.ts +14 -0
  145. package/core/schemas/builders/index.js +30 -0
  146. package/core/schemas/builders/lazy/index.d.ts +3 -0
  147. package/core/schemas/builders/lazy/index.js +7 -0
  148. package/core/schemas/builders/lazy/lazy.d.ts +5 -0
  149. package/core/schemas/builders/lazy/lazy.js +25 -0
  150. package/core/schemas/builders/lazy/lazyObject.d.ts +3 -0
  151. package/core/schemas/builders/lazy/lazyObject.js +12 -0
  152. package/core/schemas/builders/list/index.d.ts +1 -0
  153. package/core/schemas/builders/list/index.js +5 -0
  154. package/core/schemas/builders/list/list.d.ts +2 -0
  155. package/core/schemas/builders/list/list.js +55 -0
  156. package/core/schemas/builders/literals/booleanLiteral.d.ts +2 -0
  157. package/core/schemas/builders/literals/booleanLiteral.js +29 -0
  158. package/core/schemas/builders/literals/index.d.ts +2 -0
  159. package/core/schemas/builders/literals/index.js +7 -0
  160. package/core/schemas/builders/literals/stringLiteral.d.ts +2 -0
  161. package/core/schemas/builders/literals/stringLiteral.js +29 -0
  162. package/core/schemas/builders/object/index.d.ts +6 -0
  163. package/core/schemas/builders/object/index.js +11 -0
  164. package/core/schemas/builders/object/object.d.ts +3 -0
  165. package/core/schemas/builders/object/object.js +233 -0
  166. package/core/schemas/builders/object/objectWithoutOptionalProperties.d.ts +6 -0
  167. package/core/schemas/builders/object/objectWithoutOptionalProperties.js +8 -0
  168. package/core/schemas/builders/object/property.d.ts +8 -0
  169. package/core/schemas/builders/object/property.js +16 -0
  170. package/core/schemas/builders/object/types.d.ts +26 -0
  171. package/core/schemas/builders/object/types.js +2 -0
  172. package/core/schemas/builders/object-like/getObjectLikeUtils.d.ts +9 -0
  173. package/core/schemas/builders/object-like/getObjectLikeUtils.js +54 -0
  174. package/core/schemas/builders/object-like/index.d.ts +2 -0
  175. package/core/schemas/builders/object-like/index.js +6 -0
  176. package/core/schemas/builders/object-like/types.d.ts +7 -0
  177. package/core/schemas/builders/object-like/types.js +2 -0
  178. package/core/schemas/builders/primitives/any.d.ts +1 -0
  179. package/core/schemas/builders/primitives/any.js +6 -0
  180. package/core/schemas/builders/primitives/boolean.d.ts +1 -0
  181. package/core/schemas/builders/primitives/boolean.js +25 -0
  182. package/core/schemas/builders/primitives/index.d.ts +5 -0
  183. package/core/schemas/builders/primitives/index.js +13 -0
  184. package/core/schemas/builders/primitives/number.d.ts +1 -0
  185. package/core/schemas/builders/primitives/number.js +25 -0
  186. package/core/schemas/builders/primitives/string.d.ts +1 -0
  187. package/core/schemas/builders/primitives/string.js +25 -0
  188. package/core/schemas/builders/primitives/unknown.d.ts +1 -0
  189. package/core/schemas/builders/primitives/unknown.js +6 -0
  190. package/core/schemas/builders/record/index.d.ts +2 -0
  191. package/core/schemas/builders/record/index.js +5 -0
  192. package/core/schemas/builders/record/record.d.ts +3 -0
  193. package/core/schemas/builders/record/record.js +95 -0
  194. package/core/schemas/builders/record/types.d.ts +4 -0
  195. package/core/schemas/builders/record/types.js +2 -0
  196. package/core/schemas/builders/schema-utils/JsonError.d.ts +5 -0
  197. package/core/schemas/builders/schema-utils/JsonError.js +12 -0
  198. package/core/schemas/builders/schema-utils/ParseError.d.ts +5 -0
  199. package/core/schemas/builders/schema-utils/ParseError.js +12 -0
  200. package/core/schemas/builders/schema-utils/getSchemaUtils.d.ts +17 -0
  201. package/core/schemas/builders/schema-utils/getSchemaUtils.js +82 -0
  202. package/core/schemas/builders/schema-utils/index.d.ts +4 -0
  203. package/core/schemas/builders/schema-utils/index.js +11 -0
  204. package/core/schemas/builders/schema-utils/stringifyValidationErrors.d.ts +2 -0
  205. package/core/schemas/builders/schema-utils/stringifyValidationErrors.js +10 -0
  206. package/core/schemas/builders/set/index.d.ts +1 -0
  207. package/core/schemas/builders/set/index.js +5 -0
  208. package/core/schemas/builders/set/set.d.ts +2 -0
  209. package/core/schemas/builders/set/set.js +44 -0
  210. package/core/schemas/builders/undiscriminated-union/index.d.ts +2 -0
  211. package/core/schemas/builders/undiscriminated-union/index.js +5 -0
  212. package/core/schemas/builders/undiscriminated-union/types.d.ts +4 -0
  213. package/core/schemas/builders/undiscriminated-union/types.js +2 -0
  214. package/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.d.ts +3 -0
  215. package/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.js +40 -0
  216. package/core/schemas/builders/union/discriminant.d.ts +5 -0
  217. package/core/schemas/builders/union/discriminant.js +10 -0
  218. package/core/schemas/builders/union/index.d.ts +4 -0
  219. package/core/schemas/builders/union/index.js +7 -0
  220. package/core/schemas/builders/union/types.d.ts +13 -0
  221. package/core/schemas/builders/union/types.js +2 -0
  222. package/core/schemas/builders/union/union.d.ts +4 -0
  223. package/core/schemas/builders/union/union.js +130 -0
  224. package/core/schemas/index.d.ts +2 -0
  225. package/core/schemas/index.js +17 -0
  226. package/core/schemas/utils/MaybePromise.d.ts +1 -0
  227. package/core/schemas/utils/MaybePromise.js +2 -0
  228. package/core/schemas/utils/addQuestionMarksToNullableProperties.d.ts +7 -0
  229. package/core/schemas/utils/addQuestionMarksToNullableProperties.js +2 -0
  230. package/core/schemas/utils/createIdentitySchemaCreator.d.ts +2 -0
  231. package/core/schemas/utils/createIdentitySchemaCreator.js +16 -0
  232. package/core/schemas/utils/entries.d.ts +1 -0
  233. package/core/schemas/utils/entries.js +7 -0
  234. package/core/schemas/utils/filterObject.d.ts +1 -0
  235. package/core/schemas/utils/filterObject.js +14 -0
  236. package/core/schemas/utils/getErrorMessageForIncorrectType.d.ts +1 -0
  237. package/core/schemas/utils/getErrorMessageForIncorrectType.js +28 -0
  238. package/core/schemas/utils/isPlainObject.d.ts +1 -0
  239. package/core/schemas/utils/isPlainObject.js +18 -0
  240. package/core/schemas/utils/keys.d.ts +1 -0
  241. package/core/schemas/utils/keys.js +7 -0
  242. package/core/schemas/utils/maybeSkipValidation.d.ts +2 -0
  243. package/core/schemas/utils/maybeSkipValidation.js +28 -0
  244. package/core/schemas/utils/partition.d.ts +1 -0
  245. package/core/schemas/utils/partition.js +16 -0
  246. package/dist/Client.d.ts +93 -0
  247. package/dist/Client.js +384 -0
  248. package/dist/api/client/index.d.ts +1 -0
  249. package/dist/api/client/index.js +17 -0
  250. package/dist/api/client/requests/CheckRcsCapabilityRequest.d.ts +21 -0
  251. package/dist/api/client/requests/CheckRcsCapabilityRequest.js +5 -0
  252. package/dist/api/client/requests/UpdateSettingsRequest.d.ts +13 -0
  253. package/dist/api/client/requests/UpdateSettingsRequest.js +5 -0
  254. package/dist/api/client/requests/index.d.ts +2 -0
  255. package/dist/api/client/requests/index.js +2 -0
  256. package/dist/api/errors/BadRequestError.d.ts +8 -0
  257. package/dist/api/errors/BadRequestError.js +41 -0
  258. package/dist/api/errors/InternalServerError.d.ts +8 -0
  259. package/dist/api/errors/InternalServerError.js +41 -0
  260. package/dist/api/errors/UnauthorizedError.d.ts +8 -0
  261. package/dist/api/errors/UnauthorizedError.js +41 -0
  262. package/dist/api/errors/index.d.ts +3 -0
  263. package/dist/api/errors/index.js +19 -0
  264. package/dist/api/index.d.ts +3 -0
  265. package/dist/api/index.js +19 -0
  266. package/dist/api/types/Action.d.ts +5 -0
  267. package/dist/api/types/Action.js +5 -0
  268. package/dist/api/types/BadRequestErrorBody.d.ts +6 -0
  269. package/dist/api/types/BadRequestErrorBody.js +5 -0
  270. package/dist/api/types/BasicRcs.d.ts +13 -0
  271. package/dist/api/types/BasicRcs.js +5 -0
  272. package/dist/api/types/BasicRcsMessage.d.ts +10 -0
  273. package/dist/api/types/BasicRcsMessage.js +5 -0
  274. package/dist/api/types/Call.d.ts +9 -0
  275. package/dist/api/types/Call.js +5 -0
  276. package/dist/api/types/Card.d.ts +16 -0
  277. package/dist/api/types/Card.js +5 -0
  278. package/dist/api/types/CardRcs.d.ts +12 -0
  279. package/dist/api/types/CardRcs.js +5 -0
  280. package/dist/api/types/CardRcsMessage.d.ts +13 -0
  281. package/dist/api/types/CardRcsMessage.js +5 -0
  282. package/dist/api/types/CardStyle.d.ts +16 -0
  283. package/dist/api/types/CardStyle.js +5 -0
  284. package/dist/api/types/CardStyleImageAlignment.d.ts +11 -0
  285. package/dist/api/types/CardStyleImageAlignment.js +10 -0
  286. package/dist/api/types/CardStyleMediaHeight.d.ts +12 -0
  287. package/dist/api/types/CardStyleMediaHeight.js +11 -0
  288. package/dist/api/types/CardStyleOrientation.d.ts +11 -0
  289. package/dist/api/types/CardStyleOrientation.js +10 -0
  290. package/dist/api/types/CardStyleWidth.d.ts +11 -0
  291. package/dist/api/types/CardStyleWidth.js +10 -0
  292. package/dist/api/types/CarouselRcs.d.ts +12 -0
  293. package/dist/api/types/CarouselRcs.js +5 -0
  294. package/dist/api/types/CarouselRcsMessage.d.ts +13 -0
  295. package/dist/api/types/CarouselRcsMessage.js +5 -0
  296. package/dist/api/types/CheckRcsCapabilityResponse.d.ts +7 -0
  297. package/dist/api/types/CheckRcsCapabilityResponse.js +5 -0
  298. package/dist/api/types/Event.d.ts +15 -0
  299. package/dist/api/types/Event.js +5 -0
  300. package/dist/api/types/GetAccountNumberResponse.d.ts +7 -0
  301. package/dist/api/types/GetAccountNumberResponse.js +5 -0
  302. package/dist/api/types/InternalServerErrorBody.d.ts +6 -0
  303. package/dist/api/types/InternalServerErrorBody.js +5 -0
  304. package/dist/api/types/LatLng.d.ts +12 -0
  305. package/dist/api/types/LatLng.js +5 -0
  306. package/dist/api/types/MediaRcs.d.ts +12 -0
  307. package/dist/api/types/MediaRcs.js +5 -0
  308. package/dist/api/types/MediaRcsMessage.d.ts +14 -0
  309. package/dist/api/types/MediaRcsMessage.js +5 -0
  310. package/dist/api/types/MediaType.d.ts +14 -0
  311. package/dist/api/types/MediaType.js +13 -0
  312. package/dist/api/types/PhoneNumber.d.ts +7 -0
  313. package/dist/api/types/PhoneNumber.js +5 -0
  314. package/dist/api/types/Postback.d.ts +11 -0
  315. package/dist/api/types/Postback.js +5 -0
  316. package/dist/api/types/SendRequest.d.ts +5 -0
  317. package/dist/api/types/SendRequest.js +5 -0
  318. package/dist/api/types/SendResponse.d.ts +7 -0
  319. package/dist/api/types/SendResponse.js +5 -0
  320. package/dist/api/types/ShareLocation.d.ts +7 -0
  321. package/dist/api/types/ShareLocation.js +5 -0
  322. package/dist/api/types/Sms.d.ts +12 -0
  323. package/dist/api/types/Sms.js +5 -0
  324. package/dist/api/types/SmsMessage.d.ts +12 -0
  325. package/dist/api/types/SmsMessage.js +5 -0
  326. package/dist/api/types/UnauthorizedErrorBody.d.ts +6 -0
  327. package/dist/api/types/UnauthorizedErrorBody.js +5 -0
  328. package/dist/api/types/UpdateSettingsResponse.d.ts +6 -0
  329. package/dist/api/types/UpdateSettingsResponse.js +5 -0
  330. package/dist/api/types/Url.d.ts +9 -0
  331. package/dist/api/types/Url.js +5 -0
  332. package/dist/api/types/ViewLocation.d.ts +11 -0
  333. package/dist/api/types/ViewLocation.js +5 -0
  334. package/dist/api/types/index.d.ts +34 -0
  335. package/dist/api/types/index.js +50 -0
  336. package/dist/core/fetcher/APIResponse.d.ts +10 -0
  337. package/dist/core/fetcher/APIResponse.js +2 -0
  338. package/dist/core/fetcher/Fetcher.d.ts +39 -0
  339. package/dist/core/fetcher/Fetcher.js +99 -0
  340. package/dist/core/fetcher/Supplier.d.ts +4 -0
  341. package/dist/core/fetcher/Supplier.js +22 -0
  342. package/dist/core/fetcher/createRequestUrl.d.ts +1 -0
  343. package/dist/core/fetcher/createRequestUrl.js +13 -0
  344. package/dist/core/fetcher/getFetchFn.d.ts +4 -0
  345. package/dist/core/fetcher/getFetchFn.js +59 -0
  346. package/dist/core/fetcher/getHeader.d.ts +1 -0
  347. package/dist/core/fetcher/getHeader.js +12 -0
  348. package/dist/core/fetcher/getRequestBody.d.ts +7 -0
  349. package/dist/core/fetcher/getRequestBody.js +23 -0
  350. package/dist/core/fetcher/getResponseBody.d.ts +1 -0
  351. package/dist/core/fetcher/getResponseBody.js +52 -0
  352. package/dist/core/fetcher/index.d.ts +5 -0
  353. package/dist/core/fetcher/index.js +9 -0
  354. package/dist/core/fetcher/makeRequest.d.ts +1 -0
  355. package/dist/core/fetcher/makeRequest.js +42 -0
  356. package/dist/core/fetcher/requestWithRetries.d.ts +1 -0
  357. package/dist/core/fetcher/requestWithRetries.js +32 -0
  358. package/dist/core/fetcher/signals.d.ts +12 -0
  359. package/dist/core/fetcher/signals.js +37 -0
  360. package/dist/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.d.ts +30 -0
  361. package/dist/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.js +247 -0
  362. package/dist/core/fetcher/stream-wrappers/NodePre18StreamWrapper.d.ts +22 -0
  363. package/dist/core/fetcher/stream-wrappers/NodePre18StreamWrapper.js +124 -0
  364. package/dist/core/fetcher/stream-wrappers/UndiciStreamWrapper.d.ts +31 -0
  365. package/dist/core/fetcher/stream-wrappers/UndiciStreamWrapper.js +229 -0
  366. package/dist/core/fetcher/stream-wrappers/chooseStreamWrapper.d.ts +18 -0
  367. package/dist/core/fetcher/stream-wrappers/chooseStreamWrapper.js +50 -0
  368. package/dist/core/index.d.ts +3 -0
  369. package/dist/core/index.js +32 -0
  370. package/dist/core/runtime/index.d.ts +1 -0
  371. package/dist/core/runtime/index.js +5 -0
  372. package/dist/core/runtime/runtime.d.ts +9 -0
  373. package/dist/core/runtime/runtime.js +93 -0
  374. package/dist/core/schemas/Schema.d.ts +85 -0
  375. package/dist/core/schemas/Schema.js +22 -0
  376. package/dist/core/schemas/builders/bigint/bigint.d.ts +2 -0
  377. package/dist/core/schemas/builders/bigint/bigint.js +50 -0
  378. package/dist/core/schemas/builders/bigint/index.d.ts +1 -0
  379. package/dist/core/schemas/builders/bigint/index.js +5 -0
  380. package/dist/core/schemas/builders/date/date.d.ts +2 -0
  381. package/dist/core/schemas/builders/date/date.js +63 -0
  382. package/dist/core/schemas/builders/date/index.d.ts +1 -0
  383. package/dist/core/schemas/builders/date/index.js +5 -0
  384. package/dist/core/schemas/builders/enum/enum.d.ts +2 -0
  385. package/dist/core/schemas/builders/enum/enum.js +39 -0
  386. package/dist/core/schemas/builders/enum/index.d.ts +1 -0
  387. package/dist/core/schemas/builders/enum/index.js +5 -0
  388. package/dist/core/schemas/builders/index.d.ts +14 -0
  389. package/dist/core/schemas/builders/index.js +30 -0
  390. package/dist/core/schemas/builders/lazy/index.d.ts +3 -0
  391. package/dist/core/schemas/builders/lazy/index.js +7 -0
  392. package/dist/core/schemas/builders/lazy/lazy.d.ts +5 -0
  393. package/dist/core/schemas/builders/lazy/lazy.js +25 -0
  394. package/dist/core/schemas/builders/lazy/lazyObject.d.ts +3 -0
  395. package/dist/core/schemas/builders/lazy/lazyObject.js +12 -0
  396. package/dist/core/schemas/builders/list/index.d.ts +1 -0
  397. package/dist/core/schemas/builders/list/index.js +5 -0
  398. package/dist/core/schemas/builders/list/list.d.ts +2 -0
  399. package/dist/core/schemas/builders/list/list.js +55 -0
  400. package/dist/core/schemas/builders/literals/booleanLiteral.d.ts +2 -0
  401. package/dist/core/schemas/builders/literals/booleanLiteral.js +29 -0
  402. package/dist/core/schemas/builders/literals/index.d.ts +2 -0
  403. package/dist/core/schemas/builders/literals/index.js +7 -0
  404. package/dist/core/schemas/builders/literals/stringLiteral.d.ts +2 -0
  405. package/dist/core/schemas/builders/literals/stringLiteral.js +29 -0
  406. package/dist/core/schemas/builders/object/index.d.ts +6 -0
  407. package/dist/core/schemas/builders/object/index.js +11 -0
  408. package/dist/core/schemas/builders/object/object.d.ts +3 -0
  409. package/dist/core/schemas/builders/object/object.js +233 -0
  410. package/dist/core/schemas/builders/object/objectWithoutOptionalProperties.d.ts +6 -0
  411. package/dist/core/schemas/builders/object/objectWithoutOptionalProperties.js +8 -0
  412. package/dist/core/schemas/builders/object/property.d.ts +8 -0
  413. package/dist/core/schemas/builders/object/property.js +16 -0
  414. package/dist/core/schemas/builders/object/types.d.ts +26 -0
  415. package/dist/core/schemas/builders/object/types.js +2 -0
  416. package/dist/core/schemas/builders/object-like/getObjectLikeUtils.d.ts +9 -0
  417. package/dist/core/schemas/builders/object-like/getObjectLikeUtils.js +54 -0
  418. package/dist/core/schemas/builders/object-like/index.d.ts +2 -0
  419. package/dist/core/schemas/builders/object-like/index.js +6 -0
  420. package/dist/core/schemas/builders/object-like/types.d.ts +7 -0
  421. package/dist/core/schemas/builders/object-like/types.js +2 -0
  422. package/dist/core/schemas/builders/primitives/any.d.ts +1 -0
  423. package/dist/core/schemas/builders/primitives/any.js +6 -0
  424. package/dist/core/schemas/builders/primitives/boolean.d.ts +1 -0
  425. package/dist/core/schemas/builders/primitives/boolean.js +25 -0
  426. package/dist/core/schemas/builders/primitives/index.d.ts +5 -0
  427. package/dist/core/schemas/builders/primitives/index.js +13 -0
  428. package/dist/core/schemas/builders/primitives/number.d.ts +1 -0
  429. package/dist/core/schemas/builders/primitives/number.js +25 -0
  430. package/dist/core/schemas/builders/primitives/string.d.ts +1 -0
  431. package/dist/core/schemas/builders/primitives/string.js +25 -0
  432. package/dist/core/schemas/builders/primitives/unknown.d.ts +1 -0
  433. package/dist/core/schemas/builders/primitives/unknown.js +6 -0
  434. package/dist/core/schemas/builders/record/index.d.ts +2 -0
  435. package/dist/core/schemas/builders/record/index.js +5 -0
  436. package/dist/core/schemas/builders/record/record.d.ts +3 -0
  437. package/dist/core/schemas/builders/record/record.js +95 -0
  438. package/dist/core/schemas/builders/record/types.d.ts +4 -0
  439. package/dist/core/schemas/builders/record/types.js +2 -0
  440. package/dist/core/schemas/builders/schema-utils/JsonError.d.ts +5 -0
  441. package/dist/core/schemas/builders/schema-utils/JsonError.js +12 -0
  442. package/dist/core/schemas/builders/schema-utils/ParseError.d.ts +5 -0
  443. package/dist/core/schemas/builders/schema-utils/ParseError.js +12 -0
  444. package/dist/core/schemas/builders/schema-utils/getSchemaUtils.d.ts +17 -0
  445. package/dist/core/schemas/builders/schema-utils/getSchemaUtils.js +82 -0
  446. package/dist/core/schemas/builders/schema-utils/index.d.ts +4 -0
  447. package/dist/core/schemas/builders/schema-utils/index.js +11 -0
  448. package/dist/core/schemas/builders/schema-utils/stringifyValidationErrors.d.ts +2 -0
  449. package/dist/core/schemas/builders/schema-utils/stringifyValidationErrors.js +10 -0
  450. package/dist/core/schemas/builders/set/index.d.ts +1 -0
  451. package/dist/core/schemas/builders/set/index.js +5 -0
  452. package/dist/core/schemas/builders/set/set.d.ts +2 -0
  453. package/dist/core/schemas/builders/set/set.js +44 -0
  454. package/dist/core/schemas/builders/undiscriminated-union/index.d.ts +2 -0
  455. package/dist/core/schemas/builders/undiscriminated-union/index.js +5 -0
  456. package/dist/core/schemas/builders/undiscriminated-union/types.d.ts +4 -0
  457. package/dist/core/schemas/builders/undiscriminated-union/types.js +2 -0
  458. package/dist/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.d.ts +3 -0
  459. package/dist/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.js +40 -0
  460. package/dist/core/schemas/builders/union/discriminant.d.ts +5 -0
  461. package/dist/core/schemas/builders/union/discriminant.js +10 -0
  462. package/dist/core/schemas/builders/union/index.d.ts +4 -0
  463. package/dist/core/schemas/builders/union/index.js +7 -0
  464. package/dist/core/schemas/builders/union/types.d.ts +13 -0
  465. package/dist/core/schemas/builders/union/types.js +2 -0
  466. package/dist/core/schemas/builders/union/union.d.ts +4 -0
  467. package/dist/core/schemas/builders/union/union.js +130 -0
  468. package/dist/core/schemas/index.d.ts +2 -0
  469. package/dist/core/schemas/index.js +17 -0
  470. package/dist/core/schemas/utils/MaybePromise.d.ts +1 -0
  471. package/dist/core/schemas/utils/MaybePromise.js +2 -0
  472. package/dist/core/schemas/utils/addQuestionMarksToNullableProperties.d.ts +7 -0
  473. package/dist/core/schemas/utils/addQuestionMarksToNullableProperties.js +2 -0
  474. package/dist/core/schemas/utils/createIdentitySchemaCreator.d.ts +2 -0
  475. package/dist/core/schemas/utils/createIdentitySchemaCreator.js +16 -0
  476. package/dist/core/schemas/utils/entries.d.ts +1 -0
  477. package/dist/core/schemas/utils/entries.js +7 -0
  478. package/dist/core/schemas/utils/filterObject.d.ts +1 -0
  479. package/dist/core/schemas/utils/filterObject.js +14 -0
  480. package/dist/core/schemas/utils/getErrorMessageForIncorrectType.d.ts +1 -0
  481. package/dist/core/schemas/utils/getErrorMessageForIncorrectType.js +28 -0
  482. package/dist/core/schemas/utils/isPlainObject.d.ts +1 -0
  483. package/dist/core/schemas/utils/isPlainObject.js +18 -0
  484. package/dist/core/schemas/utils/keys.d.ts +1 -0
  485. package/dist/core/schemas/utils/keys.js +7 -0
  486. package/dist/core/schemas/utils/maybeSkipValidation.d.ts +2 -0
  487. package/dist/core/schemas/utils/maybeSkipValidation.js +28 -0
  488. package/dist/core/schemas/utils/partition.d.ts +1 -0
  489. package/dist/core/schemas/utils/partition.js +16 -0
  490. package/dist/environments.d.ts +7 -0
  491. package/dist/environments.js +9 -0
  492. package/dist/errors/PinnacleError.d.ts +12 -0
  493. package/dist/errors/PinnacleError.js +32 -0
  494. package/dist/errors/PinnacleTimeoutError.d.ts +6 -0
  495. package/dist/errors/PinnacleTimeoutError.js +13 -0
  496. package/dist/errors/index.d.ts +2 -0
  497. package/dist/errors/index.js +7 -0
  498. package/dist/index.d.ts +4 -0
  499. package/dist/index.js +32 -5
  500. package/dist/serialization/client/index.d.ts +1 -0
  501. package/dist/serialization/client/index.js +17 -0
  502. package/dist/serialization/client/requests/UpdateSettingsRequest.d.ts +12 -0
  503. package/dist/serialization/client/requests/UpdateSettingsRequest.js +33 -0
  504. package/dist/serialization/client/requests/index.d.ts +1 -0
  505. package/dist/serialization/client/requests/index.js +5 -0
  506. package/dist/serialization/index.d.ts +2 -0
  507. package/dist/serialization/index.js +18 -0
  508. package/dist/serialization/types/Action.d.ts +15 -0
  509. package/dist/serialization/types/Action.js +36 -0
  510. package/dist/serialization/types/BadRequestErrorBody.d.ts +12 -0
  511. package/dist/serialization/types/BadRequestErrorBody.js +33 -0
  512. package/dist/serialization/types/BasicRcs.d.ts +18 -0
  513. package/dist/serialization/types/BasicRcs.js +39 -0
  514. package/dist/serialization/types/BasicRcsMessage.d.ts +12 -0
  515. package/dist/serialization/types/BasicRcsMessage.js +33 -0
  516. package/dist/serialization/types/Call.d.ts +13 -0
  517. package/dist/serialization/types/Call.js +34 -0
  518. package/dist/serialization/types/Card.d.ts +18 -0
  519. package/dist/serialization/types/Card.js +39 -0
  520. package/dist/serialization/types/CardRcs.d.ts +16 -0
  521. package/dist/serialization/types/CardRcs.js +37 -0
  522. package/dist/serialization/types/CardRcsMessage.d.ts +15 -0
  523. package/dist/serialization/types/CardRcsMessage.js +36 -0
  524. package/dist/serialization/types/CardStyle.d.ts +20 -0
  525. package/dist/serialization/types/CardStyle.js +41 -0
  526. package/dist/serialization/types/CardStyleImageAlignment.d.ts +10 -0
  527. package/dist/serialization/types/CardStyleImageAlignment.js +31 -0
  528. package/dist/serialization/types/CardStyleMediaHeight.d.ts +10 -0
  529. package/dist/serialization/types/CardStyleMediaHeight.js +31 -0
  530. package/dist/serialization/types/CardStyleOrientation.d.ts +10 -0
  531. package/dist/serialization/types/CardStyleOrientation.js +31 -0
  532. package/dist/serialization/types/CardStyleWidth.d.ts +10 -0
  533. package/dist/serialization/types/CardStyleWidth.js +31 -0
  534. package/dist/serialization/types/CarouselRcs.d.ts +16 -0
  535. package/dist/serialization/types/CarouselRcs.js +37 -0
  536. package/dist/serialization/types/CarouselRcsMessage.d.ts +15 -0
  537. package/dist/serialization/types/CarouselRcsMessage.js +36 -0
  538. package/dist/serialization/types/CheckRcsCapabilityResponse.d.ts +13 -0
  539. package/dist/serialization/types/CheckRcsCapabilityResponse.js +34 -0
  540. package/dist/serialization/types/Event.d.ts +16 -0
  541. package/dist/serialization/types/Event.js +37 -0
  542. package/dist/serialization/types/GetAccountNumberResponse.d.ts +12 -0
  543. package/dist/serialization/types/GetAccountNumberResponse.js +33 -0
  544. package/dist/serialization/types/InternalServerErrorBody.d.ts +12 -0
  545. package/dist/serialization/types/InternalServerErrorBody.js +33 -0
  546. package/dist/serialization/types/LatLng.d.ts +13 -0
  547. package/dist/serialization/types/LatLng.js +34 -0
  548. package/dist/serialization/types/MediaRcs.d.ts +16 -0
  549. package/dist/serialization/types/MediaRcs.js +37 -0
  550. package/dist/serialization/types/MediaRcsMessage.d.ts +16 -0
  551. package/dist/serialization/types/MediaRcsMessage.js +37 -0
  552. package/dist/serialization/types/MediaType.d.ts +10 -0
  553. package/dist/serialization/types/MediaType.js +31 -0
  554. package/dist/serialization/types/PhoneNumber.d.ts +10 -0
  555. package/dist/serialization/types/PhoneNumber.js +31 -0
  556. package/dist/serialization/types/Postback.d.ts +14 -0
  557. package/dist/serialization/types/Postback.js +35 -0
  558. package/dist/serialization/types/SendRequest.d.ts +15 -0
  559. package/dist/serialization/types/SendRequest.js +36 -0
  560. package/dist/serialization/types/SendResponse.d.ts +12 -0
  561. package/dist/serialization/types/SendResponse.js +33 -0
  562. package/dist/serialization/types/ShareLocation.d.ts +12 -0
  563. package/dist/serialization/types/ShareLocation.js +33 -0
  564. package/dist/serialization/types/Sms.d.ts +16 -0
  565. package/dist/serialization/types/Sms.js +37 -0
  566. package/dist/serialization/types/SmsMessage.d.ts +13 -0
  567. package/dist/serialization/types/SmsMessage.js +34 -0
  568. package/dist/serialization/types/UnauthorizedErrorBody.d.ts +12 -0
  569. package/dist/serialization/types/UnauthorizedErrorBody.js +33 -0
  570. package/dist/serialization/types/UpdateSettingsResponse.d.ts +12 -0
  571. package/dist/serialization/types/UpdateSettingsResponse.js +33 -0
  572. package/dist/serialization/types/Url.d.ts +13 -0
  573. package/dist/serialization/types/Url.js +34 -0
  574. package/dist/serialization/types/ViewLocation.d.ts +15 -0
  575. package/dist/serialization/types/ViewLocation.js +36 -0
  576. package/dist/serialization/types/index.d.ts +34 -0
  577. package/dist/serialization/types/index.js +50 -0
  578. package/dist/version.d.ts +1 -0
  579. package/dist/version.js +4 -0
  580. package/environments.d.ts +7 -0
  581. package/environments.js +9 -0
  582. package/errors/PinnacleError.d.ts +12 -0
  583. package/errors/PinnacleError.js +32 -0
  584. package/errors/PinnacleTimeoutError.d.ts +6 -0
  585. package/errors/PinnacleTimeoutError.js +13 -0
  586. package/errors/index.d.ts +2 -0
  587. package/errors/index.js +7 -0
  588. package/index.d.ts +4 -0
  589. package/index.js +34 -0
  590. package/jest.config.js +5 -0
  591. package/package.json +42 -24
  592. package/reference.md +76 -0
  593. package/serialization/client/index.d.ts +1 -0
  594. package/serialization/client/index.js +17 -0
  595. package/serialization/client/requests/UpdateSettingsRequest.d.ts +12 -0
  596. package/serialization/client/requests/UpdateSettingsRequest.js +33 -0
  597. package/serialization/client/requests/index.d.ts +1 -0
  598. package/serialization/client/requests/index.js +5 -0
  599. package/serialization/index.d.ts +2 -0
  600. package/serialization/index.js +18 -0
  601. package/serialization/types/Action.d.ts +15 -0
  602. package/serialization/types/Action.js +36 -0
  603. package/serialization/types/BadRequestErrorBody.d.ts +12 -0
  604. package/serialization/types/BadRequestErrorBody.js +33 -0
  605. package/serialization/types/BasicRcs.d.ts +18 -0
  606. package/serialization/types/BasicRcs.js +39 -0
  607. package/serialization/types/BasicRcsMessage.d.ts +12 -0
  608. package/serialization/types/BasicRcsMessage.js +33 -0
  609. package/serialization/types/Call.d.ts +13 -0
  610. package/serialization/types/Call.js +34 -0
  611. package/serialization/types/Card.d.ts +18 -0
  612. package/serialization/types/Card.js +39 -0
  613. package/serialization/types/CardRcs.d.ts +16 -0
  614. package/serialization/types/CardRcs.js +37 -0
  615. package/serialization/types/CardRcsMessage.d.ts +15 -0
  616. package/serialization/types/CardRcsMessage.js +36 -0
  617. package/serialization/types/CardStyle.d.ts +20 -0
  618. package/serialization/types/CardStyle.js +41 -0
  619. package/serialization/types/CardStyleImageAlignment.d.ts +10 -0
  620. package/serialization/types/CardStyleImageAlignment.js +31 -0
  621. package/serialization/types/CardStyleMediaHeight.d.ts +10 -0
  622. package/serialization/types/CardStyleMediaHeight.js +31 -0
  623. package/serialization/types/CardStyleOrientation.d.ts +10 -0
  624. package/serialization/types/CardStyleOrientation.js +31 -0
  625. package/serialization/types/CardStyleWidth.d.ts +10 -0
  626. package/serialization/types/CardStyleWidth.js +31 -0
  627. package/serialization/types/CarouselRcs.d.ts +16 -0
  628. package/serialization/types/CarouselRcs.js +37 -0
  629. package/serialization/types/CarouselRcsMessage.d.ts +15 -0
  630. package/serialization/types/CarouselRcsMessage.js +36 -0
  631. package/serialization/types/CheckRcsCapabilityResponse.d.ts +13 -0
  632. package/serialization/types/CheckRcsCapabilityResponse.js +34 -0
  633. package/serialization/types/Event.d.ts +16 -0
  634. package/serialization/types/Event.js +37 -0
  635. package/serialization/types/GetAccountNumberResponse.d.ts +12 -0
  636. package/serialization/types/GetAccountNumberResponse.js +33 -0
  637. package/serialization/types/InternalServerErrorBody.d.ts +12 -0
  638. package/serialization/types/InternalServerErrorBody.js +33 -0
  639. package/serialization/types/LatLng.d.ts +13 -0
  640. package/serialization/types/LatLng.js +34 -0
  641. package/serialization/types/MediaRcs.d.ts +16 -0
  642. package/serialization/types/MediaRcs.js +37 -0
  643. package/serialization/types/MediaRcsMessage.d.ts +16 -0
  644. package/serialization/types/MediaRcsMessage.js +37 -0
  645. package/serialization/types/MediaType.d.ts +10 -0
  646. package/serialization/types/MediaType.js +31 -0
  647. package/serialization/types/PhoneNumber.d.ts +10 -0
  648. package/serialization/types/PhoneNumber.js +31 -0
  649. package/serialization/types/Postback.d.ts +14 -0
  650. package/serialization/types/Postback.js +35 -0
  651. package/serialization/types/SendRequest.d.ts +15 -0
  652. package/serialization/types/SendRequest.js +36 -0
  653. package/serialization/types/SendResponse.d.ts +12 -0
  654. package/serialization/types/SendResponse.js +33 -0
  655. package/serialization/types/ShareLocation.d.ts +12 -0
  656. package/serialization/types/ShareLocation.js +33 -0
  657. package/serialization/types/Sms.d.ts +16 -0
  658. package/serialization/types/Sms.js +37 -0
  659. package/serialization/types/SmsMessage.d.ts +13 -0
  660. package/serialization/types/SmsMessage.js +34 -0
  661. package/serialization/types/UnauthorizedErrorBody.d.ts +12 -0
  662. package/serialization/types/UnauthorizedErrorBody.js +33 -0
  663. package/serialization/types/UpdateSettingsResponse.d.ts +12 -0
  664. package/serialization/types/UpdateSettingsResponse.js +33 -0
  665. package/serialization/types/Url.d.ts +13 -0
  666. package/serialization/types/Url.js +34 -0
  667. package/serialization/types/ViewLocation.d.ts +15 -0
  668. package/serialization/types/ViewLocation.js +36 -0
  669. package/serialization/types/index.d.ts +34 -0
  670. package/serialization/types/index.js +50 -0
  671. package/version.d.ts +1 -0
  672. package/version.js +4 -0
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.date = void 0;
4
+ const Schema_1 = require("../../Schema");
5
+ const getErrorMessageForIncorrectType_1 = require("../../utils/getErrorMessageForIncorrectType");
6
+ const maybeSkipValidation_1 = require("../../utils/maybeSkipValidation");
7
+ const schema_utils_1 = require("../schema-utils");
8
+ // https://stackoverflow.com/questions/12756159/regex-and-iso8601-formatted-datetime
9
+ const ISO_8601_REGEX = /^([+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([.,]\d+(?!:))?)?(\17[0-5]\d([.,]\d+)?)?([zZ]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/;
10
+ function date() {
11
+ const baseSchema = {
12
+ parse: (raw, { breadcrumbsPrefix = [] } = {}) => {
13
+ if (typeof raw !== "string") {
14
+ return {
15
+ ok: false,
16
+ errors: [
17
+ {
18
+ path: breadcrumbsPrefix,
19
+ message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(raw, "string"),
20
+ },
21
+ ],
22
+ };
23
+ }
24
+ if (!ISO_8601_REGEX.test(raw)) {
25
+ return {
26
+ ok: false,
27
+ errors: [
28
+ {
29
+ path: breadcrumbsPrefix,
30
+ message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(raw, "ISO 8601 date string"),
31
+ },
32
+ ],
33
+ };
34
+ }
35
+ return {
36
+ ok: true,
37
+ value: new Date(raw),
38
+ };
39
+ },
40
+ json: (date, { breadcrumbsPrefix = [] } = {}) => {
41
+ if (date instanceof Date) {
42
+ return {
43
+ ok: true,
44
+ value: date.toISOString(),
45
+ };
46
+ }
47
+ else {
48
+ return {
49
+ ok: false,
50
+ errors: [
51
+ {
52
+ path: breadcrumbsPrefix,
53
+ message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(date, "Date object"),
54
+ },
55
+ ],
56
+ };
57
+ }
58
+ },
59
+ getType: () => Schema_1.SchemaType.DATE,
60
+ };
61
+ return Object.assign(Object.assign({}, (0, maybeSkipValidation_1.maybeSkipValidation)(baseSchema)), (0, schema_utils_1.getSchemaUtils)(baseSchema));
62
+ }
63
+ exports.date = date;
@@ -0,0 +1 @@
1
+ export { date } from "./date";
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.date = void 0;
4
+ var date_1 = require("./date");
5
+ Object.defineProperty(exports, "date", { enumerable: true, get: function () { return date_1.date; } });
@@ -0,0 +1,2 @@
1
+ import { Schema } from "../../Schema";
2
+ export declare function enum_<U extends string, E extends U[]>(values: E): Schema<E[number], E[number]>;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.enum_ = void 0;
4
+ const Schema_1 = require("../../Schema");
5
+ const createIdentitySchemaCreator_1 = require("../../utils/createIdentitySchemaCreator");
6
+ const getErrorMessageForIncorrectType_1 = require("../../utils/getErrorMessageForIncorrectType");
7
+ function enum_(values) {
8
+ const validValues = new Set(values);
9
+ const schemaCreator = (0, createIdentitySchemaCreator_1.createIdentitySchemaCreator)(Schema_1.SchemaType.ENUM, (value, { allowUnrecognizedEnumValues, breadcrumbsPrefix = [] } = {}) => {
10
+ if (typeof value !== "string") {
11
+ return {
12
+ ok: false,
13
+ errors: [
14
+ {
15
+ path: breadcrumbsPrefix,
16
+ message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(value, "string"),
17
+ },
18
+ ],
19
+ };
20
+ }
21
+ if (!validValues.has(value) && !allowUnrecognizedEnumValues) {
22
+ return {
23
+ ok: false,
24
+ errors: [
25
+ {
26
+ path: breadcrumbsPrefix,
27
+ message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(value, "enum"),
28
+ },
29
+ ],
30
+ };
31
+ }
32
+ return {
33
+ ok: true,
34
+ value: value,
35
+ };
36
+ });
37
+ return schemaCreator();
38
+ }
39
+ exports.enum_ = enum_;
@@ -0,0 +1 @@
1
+ export { enum_ } from "./enum";
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.enum_ = void 0;
4
+ var enum_1 = require("./enum");
5
+ Object.defineProperty(exports, "enum_", { enumerable: true, get: function () { return enum_1.enum_; } });
@@ -0,0 +1,14 @@
1
+ export * from "./bigint";
2
+ export * from "./date";
3
+ export * from "./enum";
4
+ export * from "./lazy";
5
+ export * from "./list";
6
+ export * from "./literals";
7
+ export * from "./object";
8
+ export * from "./object-like";
9
+ export * from "./primitives";
10
+ export * from "./record";
11
+ export * from "./schema-utils";
12
+ export * from "./set";
13
+ export * from "./undiscriminated-union";
14
+ export * from "./union";
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./bigint"), exports);
18
+ __exportStar(require("./date"), exports);
19
+ __exportStar(require("./enum"), exports);
20
+ __exportStar(require("./lazy"), exports);
21
+ __exportStar(require("./list"), exports);
22
+ __exportStar(require("./literals"), exports);
23
+ __exportStar(require("./object"), exports);
24
+ __exportStar(require("./object-like"), exports);
25
+ __exportStar(require("./primitives"), exports);
26
+ __exportStar(require("./record"), exports);
27
+ __exportStar(require("./schema-utils"), exports);
28
+ __exportStar(require("./set"), exports);
29
+ __exportStar(require("./undiscriminated-union"), exports);
30
+ __exportStar(require("./union"), exports);
@@ -0,0 +1,3 @@
1
+ export { lazy } from "./lazy";
2
+ export type { SchemaGetter } from "./lazy";
3
+ export { lazyObject } from "./lazyObject";
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.lazyObject = exports.lazy = void 0;
4
+ var lazy_1 = require("./lazy");
5
+ Object.defineProperty(exports, "lazy", { enumerable: true, get: function () { return lazy_1.lazy; } });
6
+ var lazyObject_1 = require("./lazyObject");
7
+ Object.defineProperty(exports, "lazyObject", { enumerable: true, get: function () { return lazyObject_1.lazyObject; } });
@@ -0,0 +1,5 @@
1
+ import { BaseSchema, Schema } from "../../Schema";
2
+ export declare type SchemaGetter<SchemaType extends Schema<any, any>> = () => SchemaType;
3
+ export declare function lazy<Raw, Parsed>(getter: SchemaGetter<Schema<Raw, Parsed>>): Schema<Raw, Parsed>;
4
+ export declare function constructLazyBaseSchema<Raw, Parsed>(getter: SchemaGetter<Schema<Raw, Parsed>>): BaseSchema<Raw, Parsed>;
5
+ export declare function getMemoizedSchema<SchemaType extends Schema<any, any>>(getter: SchemaGetter<SchemaType>): SchemaType;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getMemoizedSchema = exports.constructLazyBaseSchema = exports.lazy = void 0;
4
+ const schema_utils_1 = require("../schema-utils");
5
+ function lazy(getter) {
6
+ const baseSchema = constructLazyBaseSchema(getter);
7
+ return Object.assign(Object.assign({}, baseSchema), (0, schema_utils_1.getSchemaUtils)(baseSchema));
8
+ }
9
+ exports.lazy = lazy;
10
+ function constructLazyBaseSchema(getter) {
11
+ return {
12
+ parse: (raw, opts) => getMemoizedSchema(getter).parse(raw, opts),
13
+ json: (parsed, opts) => getMemoizedSchema(getter).json(parsed, opts),
14
+ getType: () => getMemoizedSchema(getter).getType(),
15
+ };
16
+ }
17
+ exports.constructLazyBaseSchema = constructLazyBaseSchema;
18
+ function getMemoizedSchema(getter) {
19
+ const castedGetter = getter;
20
+ if (castedGetter.__zurg_memoized == null) {
21
+ castedGetter.__zurg_memoized = getter();
22
+ }
23
+ return castedGetter.__zurg_memoized;
24
+ }
25
+ exports.getMemoizedSchema = getMemoizedSchema;
@@ -0,0 +1,3 @@
1
+ import { ObjectSchema } from "../object/types";
2
+ import { SchemaGetter } from "./lazy";
3
+ export declare function lazyObject<Raw, Parsed>(getter: SchemaGetter<ObjectSchema<Raw, Parsed>>): ObjectSchema<Raw, Parsed>;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.lazyObject = void 0;
4
+ const object_1 = require("../object");
5
+ const object_like_1 = require("../object-like");
6
+ const schema_utils_1 = require("../schema-utils");
7
+ const lazy_1 = require("./lazy");
8
+ function lazyObject(getter) {
9
+ const baseSchema = Object.assign(Object.assign({}, (0, lazy_1.constructLazyBaseSchema)(getter)), { _getRawProperties: () => (0, lazy_1.getMemoizedSchema)(getter)._getRawProperties(), _getParsedProperties: () => (0, lazy_1.getMemoizedSchema)(getter)._getParsedProperties() });
10
+ return Object.assign(Object.assign(Object.assign(Object.assign({}, baseSchema), (0, schema_utils_1.getSchemaUtils)(baseSchema)), (0, object_like_1.getObjectLikeUtils)(baseSchema)), (0, object_1.getObjectUtils)(baseSchema));
11
+ }
12
+ exports.lazyObject = lazyObject;
@@ -0,0 +1 @@
1
+ export { list } from "./list";
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.list = void 0;
4
+ var list_1 = require("./list");
5
+ Object.defineProperty(exports, "list", { enumerable: true, get: function () { return list_1.list; } });
@@ -0,0 +1,2 @@
1
+ import { Schema } from "../../Schema";
2
+ export declare function list<Raw, Parsed>(schema: Schema<Raw, Parsed>): Schema<Raw[], Parsed[]>;
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.list = void 0;
4
+ const Schema_1 = require("../../Schema");
5
+ const getErrorMessageForIncorrectType_1 = require("../../utils/getErrorMessageForIncorrectType");
6
+ const maybeSkipValidation_1 = require("../../utils/maybeSkipValidation");
7
+ const schema_utils_1 = require("../schema-utils");
8
+ function list(schema) {
9
+ const baseSchema = {
10
+ parse: (raw, opts) => validateAndTransformArray(raw, (item, index) => {
11
+ var _a;
12
+ return schema.parse(item, Object.assign(Object.assign({}, opts), { breadcrumbsPrefix: [...((_a = opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix) !== null && _a !== void 0 ? _a : []), `[${index}]`] }));
13
+ }),
14
+ json: (parsed, opts) => validateAndTransformArray(parsed, (item, index) => {
15
+ var _a;
16
+ return schema.json(item, Object.assign(Object.assign({}, opts), { breadcrumbsPrefix: [...((_a = opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix) !== null && _a !== void 0 ? _a : []), `[${index}]`] }));
17
+ }),
18
+ getType: () => Schema_1.SchemaType.LIST,
19
+ };
20
+ return Object.assign(Object.assign({}, (0, maybeSkipValidation_1.maybeSkipValidation)(baseSchema)), (0, schema_utils_1.getSchemaUtils)(baseSchema));
21
+ }
22
+ exports.list = list;
23
+ function validateAndTransformArray(value, transformItem) {
24
+ if (!Array.isArray(value)) {
25
+ return {
26
+ ok: false,
27
+ errors: [
28
+ {
29
+ message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(value, "list"),
30
+ path: [],
31
+ },
32
+ ],
33
+ };
34
+ }
35
+ const maybeValidItems = value.map((item, index) => transformItem(item, index));
36
+ return maybeValidItems.reduce((acc, item) => {
37
+ if (acc.ok && item.ok) {
38
+ return {
39
+ ok: true,
40
+ value: [...acc.value, item.value],
41
+ };
42
+ }
43
+ const errors = [];
44
+ if (!acc.ok) {
45
+ errors.push(...acc.errors);
46
+ }
47
+ if (!item.ok) {
48
+ errors.push(...item.errors);
49
+ }
50
+ return {
51
+ ok: false,
52
+ errors,
53
+ };
54
+ }, { ok: true, value: [] });
55
+ }
@@ -0,0 +1,2 @@
1
+ import { Schema } from "../../Schema";
2
+ export declare function booleanLiteral<V extends boolean>(literal: V): Schema<V, V>;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.booleanLiteral = void 0;
4
+ const Schema_1 = require("../../Schema");
5
+ const createIdentitySchemaCreator_1 = require("../../utils/createIdentitySchemaCreator");
6
+ const getErrorMessageForIncorrectType_1 = require("../../utils/getErrorMessageForIncorrectType");
7
+ function booleanLiteral(literal) {
8
+ const schemaCreator = (0, createIdentitySchemaCreator_1.createIdentitySchemaCreator)(Schema_1.SchemaType.BOOLEAN_LITERAL, (value, { breadcrumbsPrefix = [] } = {}) => {
9
+ if (value === literal) {
10
+ return {
11
+ ok: true,
12
+ value: literal,
13
+ };
14
+ }
15
+ else {
16
+ return {
17
+ ok: false,
18
+ errors: [
19
+ {
20
+ path: breadcrumbsPrefix,
21
+ message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(value, `${literal.toString()}`),
22
+ },
23
+ ],
24
+ };
25
+ }
26
+ });
27
+ return schemaCreator();
28
+ }
29
+ exports.booleanLiteral = booleanLiteral;
@@ -0,0 +1,2 @@
1
+ export { stringLiteral } from "./stringLiteral";
2
+ export { booleanLiteral } from "./booleanLiteral";
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.booleanLiteral = exports.stringLiteral = void 0;
4
+ var stringLiteral_1 = require("./stringLiteral");
5
+ Object.defineProperty(exports, "stringLiteral", { enumerable: true, get: function () { return stringLiteral_1.stringLiteral; } });
6
+ var booleanLiteral_1 = require("./booleanLiteral");
7
+ Object.defineProperty(exports, "booleanLiteral", { enumerable: true, get: function () { return booleanLiteral_1.booleanLiteral; } });
@@ -0,0 +1,2 @@
1
+ import { Schema } from "../../Schema";
2
+ export declare function stringLiteral<V extends string>(literal: V): Schema<V, V>;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.stringLiteral = void 0;
4
+ const Schema_1 = require("../../Schema");
5
+ const createIdentitySchemaCreator_1 = require("../../utils/createIdentitySchemaCreator");
6
+ const getErrorMessageForIncorrectType_1 = require("../../utils/getErrorMessageForIncorrectType");
7
+ function stringLiteral(literal) {
8
+ const schemaCreator = (0, createIdentitySchemaCreator_1.createIdentitySchemaCreator)(Schema_1.SchemaType.STRING_LITERAL, (value, { breadcrumbsPrefix = [] } = {}) => {
9
+ if (value === literal) {
10
+ return {
11
+ ok: true,
12
+ value: literal,
13
+ };
14
+ }
15
+ else {
16
+ return {
17
+ ok: false,
18
+ errors: [
19
+ {
20
+ path: breadcrumbsPrefix,
21
+ message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(value, `"${literal}"`),
22
+ },
23
+ ],
24
+ };
25
+ }
26
+ });
27
+ return schemaCreator();
28
+ }
29
+ exports.stringLiteral = stringLiteral;
@@ -0,0 +1,6 @@
1
+ export { getObjectUtils, object } from "./object";
2
+ export { objectWithoutOptionalProperties } from "./objectWithoutOptionalProperties";
3
+ export type { inferObjectWithoutOptionalPropertiesSchemaFromPropertySchemas, inferParsedObjectWithoutOptionalPropertiesFromPropertySchemas, } from "./objectWithoutOptionalProperties";
4
+ export { isProperty, property } from "./property";
5
+ export type { Property } from "./property";
6
+ export type { BaseObjectSchema, inferObjectSchemaFromPropertySchemas, inferParsedObject, inferParsedObjectFromPropertySchemas, inferParsedPropertySchema, inferRawKey, inferRawObject, inferRawObjectFromPropertySchemas, inferRawPropertySchema, ObjectSchema, ObjectUtils, PropertySchemas, } from "./types";
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.property = exports.isProperty = exports.objectWithoutOptionalProperties = exports.object = exports.getObjectUtils = void 0;
4
+ var object_1 = require("./object");
5
+ Object.defineProperty(exports, "getObjectUtils", { enumerable: true, get: function () { return object_1.getObjectUtils; } });
6
+ Object.defineProperty(exports, "object", { enumerable: true, get: function () { return object_1.object; } });
7
+ var objectWithoutOptionalProperties_1 = require("./objectWithoutOptionalProperties");
8
+ Object.defineProperty(exports, "objectWithoutOptionalProperties", { enumerable: true, get: function () { return objectWithoutOptionalProperties_1.objectWithoutOptionalProperties; } });
9
+ var property_1 = require("./property");
10
+ Object.defineProperty(exports, "isProperty", { enumerable: true, get: function () { return property_1.isProperty; } });
11
+ Object.defineProperty(exports, "property", { enumerable: true, get: function () { return property_1.property; } });
@@ -0,0 +1,3 @@
1
+ import { BaseObjectSchema, inferObjectSchemaFromPropertySchemas, ObjectUtils, PropertySchemas } from "./types";
2
+ export declare function object<ParsedKeys extends string, T extends PropertySchemas<ParsedKeys>>(schemas: T): inferObjectSchemaFromPropertySchemas<T>;
3
+ export declare function getObjectUtils<Raw, Parsed>(schema: BaseObjectSchema<Raw, Parsed>): ObjectUtils<Raw, Parsed>;
@@ -0,0 +1,233 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getObjectUtils = exports.object = void 0;
4
+ const Schema_1 = require("../../Schema");
5
+ const entries_1 = require("../../utils/entries");
6
+ const filterObject_1 = require("../../utils/filterObject");
7
+ const getErrorMessageForIncorrectType_1 = require("../../utils/getErrorMessageForIncorrectType");
8
+ const isPlainObject_1 = require("../../utils/isPlainObject");
9
+ const keys_1 = require("../../utils/keys");
10
+ const maybeSkipValidation_1 = require("../../utils/maybeSkipValidation");
11
+ const partition_1 = require("../../utils/partition");
12
+ const object_like_1 = require("../object-like");
13
+ const schema_utils_1 = require("../schema-utils");
14
+ const property_1 = require("./property");
15
+ function object(schemas) {
16
+ const baseSchema = {
17
+ _getRawProperties: () => Object.entries(schemas).map(([parsedKey, propertySchema]) => (0, property_1.isProperty)(propertySchema) ? propertySchema.rawKey : parsedKey),
18
+ _getParsedProperties: () => (0, keys_1.keys)(schemas),
19
+ parse: (raw, opts) => {
20
+ const rawKeyToProperty = {};
21
+ const requiredKeys = [];
22
+ for (const [parsedKey, schemaOrObjectProperty] of (0, entries_1.entries)(schemas)) {
23
+ const rawKey = (0, property_1.isProperty)(schemaOrObjectProperty) ? schemaOrObjectProperty.rawKey : parsedKey;
24
+ const valueSchema = (0, property_1.isProperty)(schemaOrObjectProperty)
25
+ ? schemaOrObjectProperty.valueSchema
26
+ : schemaOrObjectProperty;
27
+ const property = {
28
+ rawKey,
29
+ parsedKey: parsedKey,
30
+ valueSchema,
31
+ };
32
+ rawKeyToProperty[rawKey] = property;
33
+ if (isSchemaRequired(valueSchema)) {
34
+ requiredKeys.push(rawKey);
35
+ }
36
+ }
37
+ return validateAndTransformObject({
38
+ value: raw,
39
+ requiredKeys,
40
+ getProperty: (rawKey) => {
41
+ const property = rawKeyToProperty[rawKey];
42
+ if (property == null) {
43
+ return undefined;
44
+ }
45
+ return {
46
+ transformedKey: property.parsedKey,
47
+ transform: (propertyValue) => {
48
+ var _a;
49
+ 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] }));
50
+ },
51
+ };
52
+ },
53
+ unrecognizedObjectKeys: opts === null || opts === void 0 ? void 0 : opts.unrecognizedObjectKeys,
54
+ skipValidation: opts === null || opts === void 0 ? void 0 : opts.skipValidation,
55
+ breadcrumbsPrefix: opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix,
56
+ omitUndefined: opts === null || opts === void 0 ? void 0 : opts.omitUndefined,
57
+ });
58
+ },
59
+ json: (parsed, opts) => {
60
+ const requiredKeys = [];
61
+ for (const [parsedKey, schemaOrObjectProperty] of (0, entries_1.entries)(schemas)) {
62
+ const valueSchema = (0, property_1.isProperty)(schemaOrObjectProperty)
63
+ ? schemaOrObjectProperty.valueSchema
64
+ : schemaOrObjectProperty;
65
+ if (isSchemaRequired(valueSchema)) {
66
+ requiredKeys.push(parsedKey);
67
+ }
68
+ }
69
+ return validateAndTransformObject({
70
+ value: parsed,
71
+ requiredKeys,
72
+ getProperty: (parsedKey) => {
73
+ const property = schemas[parsedKey];
74
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
75
+ if (property == null) {
76
+ return undefined;
77
+ }
78
+ if ((0, property_1.isProperty)(property)) {
79
+ return {
80
+ transformedKey: property.rawKey,
81
+ transform: (propertyValue) => {
82
+ var _a;
83
+ 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] }));
84
+ },
85
+ };
86
+ }
87
+ else {
88
+ return {
89
+ transformedKey: parsedKey,
90
+ transform: (propertyValue) => {
91
+ var _a;
92
+ 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] }));
93
+ },
94
+ };
95
+ }
96
+ },
97
+ unrecognizedObjectKeys: opts === null || opts === void 0 ? void 0 : opts.unrecognizedObjectKeys,
98
+ skipValidation: opts === null || opts === void 0 ? void 0 : opts.skipValidation,
99
+ breadcrumbsPrefix: opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix,
100
+ omitUndefined: opts === null || opts === void 0 ? void 0 : opts.omitUndefined,
101
+ });
102
+ },
103
+ getType: () => Schema_1.SchemaType.OBJECT,
104
+ };
105
+ return Object.assign(Object.assign(Object.assign(Object.assign({}, (0, maybeSkipValidation_1.maybeSkipValidation)(baseSchema)), (0, schema_utils_1.getSchemaUtils)(baseSchema)), (0, object_like_1.getObjectLikeUtils)(baseSchema)), getObjectUtils(baseSchema));
106
+ }
107
+ exports.object = object;
108
+ function validateAndTransformObject({ value, requiredKeys, getProperty, unrecognizedObjectKeys = "fail", skipValidation = false, breadcrumbsPrefix = [], }) {
109
+ if (!(0, isPlainObject_1.isPlainObject)(value)) {
110
+ return {
111
+ ok: false,
112
+ errors: [
113
+ {
114
+ path: breadcrumbsPrefix,
115
+ message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(value, "object"),
116
+ },
117
+ ],
118
+ };
119
+ }
120
+ const missingRequiredKeys = new Set(requiredKeys);
121
+ const errors = [];
122
+ const transformed = {};
123
+ for (const [preTransformedKey, preTransformedItemValue] of Object.entries(value)) {
124
+ const property = getProperty(preTransformedKey);
125
+ if (property != null) {
126
+ missingRequiredKeys.delete(preTransformedKey);
127
+ const value = property.transform(preTransformedItemValue);
128
+ if (value.ok) {
129
+ transformed[property.transformedKey] = value.value;
130
+ }
131
+ else {
132
+ transformed[preTransformedKey] = preTransformedItemValue;
133
+ errors.push(...value.errors);
134
+ }
135
+ }
136
+ else {
137
+ switch (unrecognizedObjectKeys) {
138
+ case "fail":
139
+ errors.push({
140
+ path: [...breadcrumbsPrefix, preTransformedKey],
141
+ message: `Unexpected key "${preTransformedKey}"`,
142
+ });
143
+ break;
144
+ case "strip":
145
+ break;
146
+ case "passthrough":
147
+ transformed[preTransformedKey] = preTransformedItemValue;
148
+ break;
149
+ }
150
+ }
151
+ }
152
+ errors.push(...requiredKeys
153
+ .filter((key) => missingRequiredKeys.has(key))
154
+ .map((key) => ({
155
+ path: breadcrumbsPrefix,
156
+ message: `Missing required key "${key}"`,
157
+ })));
158
+ if (errors.length === 0 || skipValidation) {
159
+ return {
160
+ ok: true,
161
+ value: transformed,
162
+ };
163
+ }
164
+ else {
165
+ return {
166
+ ok: false,
167
+ errors,
168
+ };
169
+ }
170
+ }
171
+ function getObjectUtils(schema) {
172
+ return {
173
+ extend: (extension) => {
174
+ const baseSchema = {
175
+ _getParsedProperties: () => [...schema._getParsedProperties(), ...extension._getParsedProperties()],
176
+ _getRawProperties: () => [...schema._getRawProperties(), ...extension._getRawProperties()],
177
+ parse: (raw, opts) => {
178
+ return validateAndTransformExtendedObject({
179
+ extensionKeys: extension._getRawProperties(),
180
+ value: raw,
181
+ transformBase: (rawBase) => schema.parse(rawBase, opts),
182
+ transformExtension: (rawExtension) => extension.parse(rawExtension, opts),
183
+ });
184
+ },
185
+ json: (parsed, opts) => {
186
+ return validateAndTransformExtendedObject({
187
+ extensionKeys: extension._getParsedProperties(),
188
+ value: parsed,
189
+ transformBase: (parsedBase) => schema.json(parsedBase, opts),
190
+ transformExtension: (parsedExtension) => extension.json(parsedExtension, opts),
191
+ });
192
+ },
193
+ getType: () => Schema_1.SchemaType.OBJECT,
194
+ };
195
+ return Object.assign(Object.assign(Object.assign(Object.assign({}, baseSchema), (0, schema_utils_1.getSchemaUtils)(baseSchema)), (0, object_like_1.getObjectLikeUtils)(baseSchema)), getObjectUtils(baseSchema));
196
+ },
197
+ };
198
+ }
199
+ exports.getObjectUtils = getObjectUtils;
200
+ function validateAndTransformExtendedObject({ extensionKeys, value, transformBase, transformExtension, }) {
201
+ const extensionPropertiesSet = new Set(extensionKeys);
202
+ const [extensionProperties, baseProperties] = (0, partition_1.partition)((0, keys_1.keys)(value), (key) => extensionPropertiesSet.has(key));
203
+ const transformedBase = transformBase((0, filterObject_1.filterObject)(value, baseProperties));
204
+ const transformedExtension = transformExtension((0, filterObject_1.filterObject)(value, extensionProperties));
205
+ if (transformedBase.ok && transformedExtension.ok) {
206
+ return {
207
+ ok: true,
208
+ value: Object.assign(Object.assign({}, transformedBase.value), transformedExtension.value),
209
+ };
210
+ }
211
+ else {
212
+ return {
213
+ ok: false,
214
+ errors: [
215
+ ...(transformedBase.ok ? [] : transformedBase.errors),
216
+ ...(transformedExtension.ok ? [] : transformedExtension.errors),
217
+ ],
218
+ };
219
+ }
220
+ }
221
+ function isSchemaRequired(schema) {
222
+ return !isSchemaOptional(schema);
223
+ }
224
+ function isSchemaOptional(schema) {
225
+ switch (schema.getType()) {
226
+ case Schema_1.SchemaType.ANY:
227
+ case Schema_1.SchemaType.UNKNOWN:
228
+ case Schema_1.SchemaType.OPTIONAL:
229
+ return true;
230
+ default:
231
+ return false;
232
+ }
233
+ }