@langchain/core 1.0.0-alpha.3 → 1.0.0-alpha.5

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 (570) hide show
  1. package/README.md +3 -19
  2. package/dist/agents.d.ts.map +1 -1
  3. package/dist/caches/base.cjs +2 -2
  4. package/dist/caches/base.cjs.map +1 -1
  5. package/dist/caches/base.d.ts.map +1 -1
  6. package/dist/callbacks/base.d.ts.map +1 -1
  7. package/dist/document_loaders/langsmith.cjs +1 -1
  8. package/dist/document_loaders/langsmith.cjs.map +1 -1
  9. package/dist/document_loaders/langsmith.js +1 -1
  10. package/dist/document_loaders/langsmith.js.map +1 -1
  11. package/dist/embeddings.cjs.map +1 -1
  12. package/dist/embeddings.d.cts +6 -6
  13. package/dist/embeddings.d.cts.map +1 -1
  14. package/dist/embeddings.d.ts +6 -6
  15. package/dist/embeddings.d.ts.map +1 -1
  16. package/dist/embeddings.js.map +1 -1
  17. package/dist/errors/index.cjs.map +1 -1
  18. package/dist/errors/index.js.map +1 -1
  19. package/dist/indexing/base.cjs +2 -2
  20. package/dist/indexing/base.cjs.map +1 -1
  21. package/dist/indexing/base.d.cts +0 -3
  22. package/dist/indexing/base.d.cts.map +1 -1
  23. package/dist/indexing/base.d.ts +0 -3
  24. package/dist/indexing/base.d.ts.map +1 -1
  25. package/dist/indexing/base.js +2 -2
  26. package/dist/indexing/base.js.map +1 -1
  27. package/dist/language_models/base.cjs +1 -1
  28. package/dist/language_models/base.cjs.map +1 -1
  29. package/dist/language_models/base.d.cts +3 -3
  30. package/dist/language_models/base.d.cts.map +1 -1
  31. package/dist/language_models/base.d.ts +3 -3
  32. package/dist/language_models/base.d.ts.map +1 -1
  33. package/dist/language_models/base.js +1 -1
  34. package/dist/language_models/base.js.map +1 -1
  35. package/dist/language_models/chat_models.cjs.map +1 -1
  36. package/dist/language_models/chat_models.d.ts.map +1 -1
  37. package/dist/language_models/chat_models.js.map +1 -1
  38. package/dist/language_models/llms.cjs.map +1 -1
  39. package/dist/language_models/llms.js.map +1 -1
  40. package/dist/load/import_map.cjs +0 -4
  41. package/dist/load/import_map.cjs.map +1 -1
  42. package/dist/load/import_map.js +2 -6
  43. package/dist/load/import_map.js.map +1 -1
  44. package/dist/load/index.cjs.map +1 -1
  45. package/dist/load/index.js.map +1 -1
  46. package/dist/load/serializable.cjs.map +1 -1
  47. package/dist/load/serializable.d.cts +1 -3
  48. package/dist/load/serializable.d.cts.map +1 -1
  49. package/dist/load/serializable.d.ts +1 -3
  50. package/dist/load/serializable.d.ts.map +1 -1
  51. package/dist/load/serializable.js.map +1 -1
  52. package/dist/messages/ai.cjs +17 -12
  53. package/dist/messages/ai.cjs.map +1 -1
  54. package/dist/messages/ai.js +17 -12
  55. package/dist/messages/ai.js.map +1 -1
  56. package/dist/messages/base.cjs +12 -5
  57. package/dist/messages/base.cjs.map +1 -1
  58. package/dist/messages/base.d.cts +1 -2
  59. package/dist/messages/base.d.cts.map +1 -1
  60. package/dist/messages/base.d.ts +1 -2
  61. package/dist/messages/base.d.ts.map +1 -1
  62. package/dist/messages/base.js +12 -5
  63. package/dist/messages/base.js.map +1 -1
  64. package/dist/messages/block_translators/utils.cjs +1 -1
  65. package/dist/messages/block_translators/utils.cjs.map +1 -1
  66. package/dist/messages/block_translators/utils.js +1 -1
  67. package/dist/messages/block_translators/utils.js.map +1 -1
  68. package/dist/messages/index.cjs +1 -1
  69. package/dist/messages/index.js +1 -1
  70. package/dist/messages/modifier.cjs +4 -1
  71. package/dist/messages/modifier.cjs.map +1 -1
  72. package/dist/messages/modifier.js +4 -1
  73. package/dist/messages/modifier.js.map +1 -1
  74. package/dist/messages/tool.cjs +7 -7
  75. package/dist/messages/tool.cjs.map +1 -1
  76. package/dist/messages/tool.js +7 -7
  77. package/dist/messages/tool.js.map +1 -1
  78. package/dist/messages/transformers.cjs +2 -2
  79. package/dist/messages/transformers.cjs.map +1 -1
  80. package/dist/messages/transformers.js +2 -2
  81. package/dist/messages/transformers.js.map +1 -1
  82. package/dist/messages/utils.cjs +5 -0
  83. package/dist/messages/utils.cjs.map +1 -1
  84. package/dist/messages/utils.js +5 -0
  85. package/dist/messages/utils.js.map +1 -1
  86. package/dist/output_parsers/list.cjs +1 -1
  87. package/dist/output_parsers/list.cjs.map +1 -1
  88. package/dist/output_parsers/list.js +1 -1
  89. package/dist/output_parsers/list.js.map +1 -1
  90. package/dist/output_parsers/openai_functions/json_output_functions_parsers.d.cts +1 -1
  91. package/dist/output_parsers/openai_functions/json_output_functions_parsers.d.ts +1 -1
  92. package/dist/output_parsers/openai_tools/json_output_tools_parsers.cjs +1 -1
  93. package/dist/output_parsers/openai_tools/json_output_tools_parsers.cjs.map +1 -1
  94. package/dist/output_parsers/openai_tools/json_output_tools_parsers.js +1 -1
  95. package/dist/output_parsers/openai_tools/json_output_tools_parsers.js.map +1 -1
  96. package/dist/output_parsers/structured.cjs +2 -1
  97. package/dist/output_parsers/structured.cjs.map +1 -1
  98. package/dist/output_parsers/structured.js +2 -1
  99. package/dist/output_parsers/structured.js.map +1 -1
  100. package/dist/prompts/chat.cjs +3 -1
  101. package/dist/prompts/chat.cjs.map +1 -1
  102. package/dist/prompts/chat.d.cts +4 -12
  103. package/dist/prompts/chat.d.cts.map +1 -1
  104. package/dist/prompts/chat.d.ts +4 -12
  105. package/dist/prompts/chat.d.ts.map +1 -1
  106. package/dist/prompts/chat.js +3 -1
  107. package/dist/prompts/chat.js.map +1 -1
  108. package/dist/prompts/image.cjs.map +1 -1
  109. package/dist/prompts/image.d.cts +0 -2
  110. package/dist/prompts/image.d.cts.map +1 -1
  111. package/dist/prompts/image.d.ts +0 -2
  112. package/dist/prompts/image.d.ts.map +1 -1
  113. package/dist/prompts/image.js.map +1 -1
  114. package/dist/prompts/pipeline.cjs.map +1 -1
  115. package/dist/prompts/pipeline.js.map +1 -1
  116. package/dist/prompts/prompt.cjs.map +1 -1
  117. package/dist/prompts/prompt.d.cts +4 -16
  118. package/dist/prompts/prompt.d.cts.map +1 -1
  119. package/dist/prompts/prompt.d.ts +4 -16
  120. package/dist/prompts/prompt.d.ts.map +1 -1
  121. package/dist/prompts/prompt.js.map +1 -1
  122. package/dist/prompts/structured.cjs.map +1 -1
  123. package/dist/prompts/structured.js.map +1 -1
  124. package/dist/prompts/template.cjs +4 -2
  125. package/dist/prompts/template.cjs.map +1 -1
  126. package/dist/prompts/template.js +4 -2
  127. package/dist/prompts/template.js.map +1 -1
  128. package/dist/runnables/base.cjs +6 -6
  129. package/dist/runnables/base.cjs.map +1 -1
  130. package/dist/runnables/base.d.cts +0 -3
  131. package/dist/runnables/base.d.cts.map +1 -1
  132. package/dist/runnables/base.d.ts +0 -3
  133. package/dist/runnables/base.d.ts.map +1 -1
  134. package/dist/runnables/base.js +6 -6
  135. package/dist/runnables/base.js.map +1 -1
  136. package/dist/runnables/branch.cjs +2 -2
  137. package/dist/runnables/branch.cjs.map +1 -1
  138. package/dist/runnables/branch.js +2 -2
  139. package/dist/runnables/branch.js.map +1 -1
  140. package/dist/runnables/config.cjs.map +1 -1
  141. package/dist/runnables/config.js.map +1 -1
  142. package/dist/runnables/graph.cjs +1 -1
  143. package/dist/runnables/graph.cjs.map +1 -1
  144. package/dist/runnables/graph.js +1 -1
  145. package/dist/runnables/graph.js.map +1 -1
  146. package/dist/runnables/graph_mermaid.cjs +26 -3
  147. package/dist/runnables/graph_mermaid.cjs.map +1 -1
  148. package/dist/runnables/graph_mermaid.js +26 -3
  149. package/dist/runnables/graph_mermaid.js.map +1 -1
  150. package/dist/runnables/remote.cjs.map +1 -1
  151. package/dist/runnables/remote.js.map +1 -1
  152. package/dist/runnables/types.d.cts +0 -1
  153. package/dist/runnables/types.d.cts.map +1 -1
  154. package/dist/runnables/types.d.ts +0 -1
  155. package/dist/runnables/types.d.ts.map +1 -1
  156. package/dist/singletons/async_local_storage/context.cjs.map +1 -1
  157. package/dist/singletons/async_local_storage/context.d.cts +0 -1
  158. package/dist/singletons/async_local_storage/context.d.cts.map +1 -1
  159. package/dist/singletons/async_local_storage/context.d.ts +0 -1
  160. package/dist/singletons/async_local_storage/context.d.ts.map +1 -1
  161. package/dist/singletons/async_local_storage/context.js.map +1 -1
  162. package/dist/singletons/callbacks.cjs.map +1 -1
  163. package/dist/singletons/callbacks.js.map +1 -1
  164. package/dist/tools/index.cjs.map +1 -1
  165. package/dist/tools/index.d.cts +2 -2
  166. package/dist/tools/index.d.cts.map +1 -1
  167. package/dist/tools/index.d.ts +2 -2
  168. package/dist/tools/index.d.ts.map +1 -1
  169. package/dist/tools/index.js.map +1 -1
  170. package/dist/tools/types.d.cts +5 -5
  171. package/dist/tools/types.d.cts.map +1 -1
  172. package/dist/tools/types.d.ts +5 -5
  173. package/dist/tools/types.d.ts.map +1 -1
  174. package/dist/tracers/base.cjs.map +1 -1
  175. package/dist/tracers/base.js.map +1 -1
  176. package/dist/tracers/console.cjs +1 -1
  177. package/dist/tracers/console.cjs.map +1 -1
  178. package/dist/tracers/console.js +1 -1
  179. package/dist/tracers/console.js.map +1 -1
  180. package/dist/tracers/event_stream.cjs +1 -1
  181. package/dist/tracers/event_stream.cjs.map +1 -1
  182. package/dist/tracers/event_stream.d.cts +0 -1
  183. package/dist/tracers/event_stream.d.cts.map +1 -1
  184. package/dist/tracers/event_stream.d.ts +0 -1
  185. package/dist/tracers/event_stream.d.ts.map +1 -1
  186. package/dist/tracers/event_stream.js +1 -1
  187. package/dist/tracers/event_stream.js.map +1 -1
  188. package/dist/tracers/log_stream.cjs.map +1 -1
  189. package/dist/tracers/log_stream.js.map +1 -1
  190. package/dist/tracers/tracer_langchain.cjs.map +1 -1
  191. package/dist/tracers/tracer_langchain.js.map +1 -1
  192. package/dist/utils/chunk_array.cjs.map +1 -1
  193. package/dist/utils/chunk_array.js.map +1 -1
  194. package/dist/utils/env.cjs +1 -1
  195. package/dist/utils/env.cjs.map +1 -1
  196. package/dist/utils/env.js +1 -1
  197. package/dist/utils/env.js.map +1 -1
  198. package/dist/utils/event_source_parse.cjs.map +1 -1
  199. package/dist/utils/event_source_parse.d.cts.map +1 -1
  200. package/dist/utils/event_source_parse.d.ts.map +1 -1
  201. package/dist/utils/event_source_parse.js.map +1 -1
  202. package/dist/utils/hash.cjs +3 -8
  203. package/dist/utils/hash.cjs.map +1 -1
  204. package/dist/utils/hash.d.cts +1 -2
  205. package/dist/utils/hash.d.cts.map +1 -1
  206. package/dist/utils/hash.d.ts +1 -2
  207. package/dist/utils/hash.d.ts.map +1 -1
  208. package/dist/utils/hash.js +2 -6
  209. package/dist/utils/hash.js.map +1 -1
  210. package/dist/utils/js-sha256/hash.cjs +0 -9
  211. package/dist/utils/js-sha256/hash.cjs.map +1 -1
  212. package/dist/utils/js-sha256/hash.js +1 -5
  213. package/dist/utils/js-sha256/hash.js.map +1 -1
  214. package/dist/utils/json.cjs +2 -2
  215. package/dist/utils/json.cjs.map +1 -1
  216. package/dist/utils/json.js +2 -2
  217. package/dist/utils/json.js.map +1 -1
  218. package/dist/utils/json_schema.cjs +3 -2
  219. package/dist/utils/json_schema.cjs.map +1 -1
  220. package/dist/utils/json_schema.d.cts +8 -4
  221. package/dist/utils/json_schema.d.cts.map +1 -1
  222. package/dist/utils/json_schema.d.ts +8 -4
  223. package/dist/utils/json_schema.d.ts.map +1 -1
  224. package/dist/utils/json_schema.js +2 -1
  225. package/dist/utils/json_schema.js.map +1 -1
  226. package/dist/utils/stream.cjs.map +1 -1
  227. package/dist/utils/stream.js.map +1 -1
  228. package/dist/utils/testing/chat_models.cjs +245 -0
  229. package/dist/utils/testing/chat_models.cjs.map +1 -0
  230. package/dist/utils/testing/chat_models.d.cts +134 -0
  231. package/dist/utils/testing/chat_models.d.cts.map +1 -0
  232. package/dist/utils/testing/chat_models.d.ts +134 -0
  233. package/dist/utils/testing/chat_models.d.ts.map +1 -0
  234. package/dist/utils/testing/chat_models.js +243 -0
  235. package/dist/utils/testing/chat_models.js.map +1 -0
  236. package/dist/utils/testing/embeddings.cjs +90 -0
  237. package/dist/utils/testing/embeddings.cjs.map +1 -0
  238. package/dist/utils/testing/embeddings.d.cts +58 -0
  239. package/dist/utils/testing/embeddings.d.cts.map +1 -0
  240. package/dist/utils/testing/embeddings.d.ts +58 -0
  241. package/dist/utils/testing/embeddings.d.ts.map +1 -0
  242. package/dist/utils/testing/embeddings.js +89 -0
  243. package/dist/utils/testing/embeddings.js.map +1 -0
  244. package/dist/utils/testing/index.cjs +42 -655
  245. package/dist/utils/testing/index.cjs.map +1 -1
  246. package/dist/utils/testing/index.d.cts +11 -384
  247. package/dist/utils/testing/index.d.ts +11 -384
  248. package/dist/utils/testing/index.js +10 -623
  249. package/dist/utils/testing/index.js.map +1 -1
  250. package/dist/utils/testing/llms.cjs +59 -0
  251. package/dist/utils/testing/llms.cjs.map +1 -0
  252. package/dist/utils/testing/llms.d.cts +31 -0
  253. package/dist/utils/testing/llms.d.cts.map +1 -0
  254. package/dist/utils/testing/llms.d.ts +31 -0
  255. package/dist/utils/testing/llms.d.ts.map +1 -0
  256. package/dist/utils/testing/llms.js +58 -0
  257. package/dist/utils/testing/llms.js.map +1 -0
  258. package/dist/utils/testing/message_history.cjs +67 -0
  259. package/dist/utils/testing/message_history.cjs.map +1 -0
  260. package/dist/utils/testing/message_history.d.cts +31 -0
  261. package/dist/utils/testing/message_history.d.cts.map +1 -0
  262. package/dist/utils/testing/message_history.d.ts +31 -0
  263. package/dist/utils/testing/message_history.d.ts.map +1 -0
  264. package/dist/utils/testing/message_history.js +65 -0
  265. package/dist/utils/testing/message_history.js.map +1 -0
  266. package/dist/utils/testing/output_parsers.cjs +20 -0
  267. package/dist/utils/testing/output_parsers.cjs.map +1 -0
  268. package/dist/utils/testing/output_parsers.d.cts +16 -0
  269. package/dist/utils/testing/output_parsers.d.cts.map +1 -0
  270. package/dist/utils/testing/output_parsers.d.ts +16 -0
  271. package/dist/utils/testing/output_parsers.d.ts.map +1 -0
  272. package/dist/utils/testing/output_parsers.js +20 -0
  273. package/dist/utils/testing/output_parsers.js.map +1 -0
  274. package/dist/utils/testing/retrievers.cjs +19 -0
  275. package/dist/utils/testing/retrievers.cjs.map +1 -0
  276. package/dist/utils/testing/retrievers.d.cts +17 -0
  277. package/dist/utils/testing/retrievers.d.cts.map +1 -0
  278. package/dist/utils/testing/retrievers.d.ts +17 -0
  279. package/dist/utils/testing/retrievers.d.ts.map +1 -0
  280. package/dist/utils/testing/retrievers.js +19 -0
  281. package/dist/utils/testing/retrievers.js.map +1 -0
  282. package/dist/utils/testing/runnables.cjs +19 -0
  283. package/dist/utils/testing/runnables.cjs.map +1 -0
  284. package/dist/utils/testing/runnables.d.cts +15 -0
  285. package/dist/utils/testing/runnables.d.cts.map +1 -0
  286. package/dist/utils/testing/runnables.d.ts +15 -0
  287. package/dist/utils/testing/runnables.d.ts.map +1 -0
  288. package/dist/utils/testing/runnables.js +19 -0
  289. package/dist/utils/testing/runnables.js.map +1 -0
  290. package/dist/utils/testing/tools.cjs +21 -0
  291. package/dist/utils/testing/tools.cjs.map +1 -0
  292. package/dist/utils/testing/tools.d.cts +21 -0
  293. package/dist/utils/testing/tools.d.cts.map +1 -0
  294. package/dist/utils/testing/tools.d.ts +21 -0
  295. package/dist/utils/testing/tools.d.ts.map +1 -0
  296. package/dist/utils/testing/tools.js +21 -0
  297. package/dist/utils/testing/tools.js.map +1 -0
  298. package/dist/utils/testing/tracers.cjs +25 -0
  299. package/dist/utils/testing/tracers.cjs.map +1 -0
  300. package/dist/utils/testing/tracers.d.cts +15 -0
  301. package/dist/utils/testing/tracers.d.cts.map +1 -0
  302. package/dist/utils/testing/tracers.d.ts +15 -0
  303. package/dist/utils/testing/tracers.d.ts.map +1 -0
  304. package/dist/utils/testing/tracers.js +25 -0
  305. package/dist/utils/testing/tracers.js.map +1 -0
  306. package/dist/utils/testing/vectorstores.cjs +129 -0
  307. package/dist/utils/testing/vectorstores.cjs.map +1 -0
  308. package/dist/utils/testing/vectorstores.d.cts +101 -0
  309. package/dist/utils/testing/vectorstores.d.cts.map +1 -0
  310. package/dist/utils/testing/vectorstores.d.ts +101 -0
  311. package/dist/utils/testing/vectorstores.d.ts.map +1 -0
  312. package/dist/utils/testing/vectorstores.js +129 -0
  313. package/dist/utils/testing/vectorstores.js.map +1 -0
  314. package/dist/utils/zod-to-json-schema/Options.cjs +40 -0
  315. package/dist/utils/zod-to-json-schema/Options.cjs.map +1 -0
  316. package/dist/utils/zod-to-json-schema/Options.js +37 -0
  317. package/dist/utils/zod-to-json-schema/Options.js.map +1 -0
  318. package/dist/utils/zod-to-json-schema/Refs.cjs +30 -0
  319. package/dist/utils/zod-to-json-schema/Refs.cjs.map +1 -0
  320. package/dist/utils/zod-to-json-schema/Refs.js +30 -0
  321. package/dist/utils/zod-to-json-schema/Refs.js.map +1 -0
  322. package/dist/utils/zod-to-json-schema/errorMessages.cjs +18 -0
  323. package/dist/utils/zod-to-json-schema/errorMessages.cjs.map +1 -0
  324. package/dist/utils/zod-to-json-schema/errorMessages.d.cts +11 -0
  325. package/dist/utils/zod-to-json-schema/errorMessages.d.cts.map +1 -0
  326. package/dist/utils/zod-to-json-schema/errorMessages.d.ts +11 -0
  327. package/dist/utils/zod-to-json-schema/errorMessages.d.ts.map +1 -0
  328. package/dist/utils/zod-to-json-schema/errorMessages.js +16 -0
  329. package/dist/utils/zod-to-json-schema/errorMessages.js.map +1 -0
  330. package/dist/utils/zod-to-json-schema/getRelativePath.cjs +11 -0
  331. package/dist/utils/zod-to-json-schema/getRelativePath.cjs.map +1 -0
  332. package/dist/utils/zod-to-json-schema/getRelativePath.js +10 -0
  333. package/dist/utils/zod-to-json-schema/getRelativePath.js.map +1 -0
  334. package/dist/utils/zod-to-json-schema/index.cjs +37 -0
  335. package/dist/utils/zod-to-json-schema/index.js +37 -0
  336. package/dist/utils/zod-to-json-schema/parseDef.cjs +57 -0
  337. package/dist/utils/zod-to-json-schema/parseDef.cjs.map +1 -0
  338. package/dist/utils/zod-to-json-schema/parseDef.js +57 -0
  339. package/dist/utils/zod-to-json-schema/parseDef.js.map +1 -0
  340. package/dist/utils/zod-to-json-schema/parseTypes.d.cts +38 -0
  341. package/dist/utils/zod-to-json-schema/parseTypes.d.cts.map +1 -0
  342. package/dist/utils/zod-to-json-schema/parseTypes.d.ts +38 -0
  343. package/dist/utils/zod-to-json-schema/parseTypes.d.ts.map +1 -0
  344. package/dist/utils/zod-to-json-schema/parsers/any.cjs +17 -0
  345. package/dist/utils/zod-to-json-schema/parsers/any.cjs.map +1 -0
  346. package/dist/utils/zod-to-json-schema/parsers/any.d.cts +7 -0
  347. package/dist/utils/zod-to-json-schema/parsers/any.d.cts.map +1 -0
  348. package/dist/utils/zod-to-json-schema/parsers/any.d.ts +7 -0
  349. package/dist/utils/zod-to-json-schema/parsers/any.d.ts.map +1 -0
  350. package/dist/utils/zod-to-json-schema/parsers/any.js +17 -0
  351. package/dist/utils/zod-to-json-schema/parsers/any.js.map +1 -0
  352. package/dist/utils/zod-to-json-schema/parsers/array.cjs +24 -0
  353. package/dist/utils/zod-to-json-schema/parsers/array.cjs.map +1 -0
  354. package/dist/utils/zod-to-json-schema/parsers/array.d.cts +14 -0
  355. package/dist/utils/zod-to-json-schema/parsers/array.d.cts.map +1 -0
  356. package/dist/utils/zod-to-json-schema/parsers/array.d.ts +15 -0
  357. package/dist/utils/zod-to-json-schema/parsers/array.d.ts.map +1 -0
  358. package/dist/utils/zod-to-json-schema/parsers/array.js +23 -0
  359. package/dist/utils/zod-to-json-schema/parsers/array.js.map +1 -0
  360. package/dist/utils/zod-to-json-schema/parsers/bigint.cjs +36 -0
  361. package/dist/utils/zod-to-json-schema/parsers/bigint.cjs.map +1 -0
  362. package/dist/utils/zod-to-json-schema/parsers/bigint.d.cts +16 -0
  363. package/dist/utils/zod-to-json-schema/parsers/bigint.d.cts.map +1 -0
  364. package/dist/utils/zod-to-json-schema/parsers/bigint.d.ts +17 -0
  365. package/dist/utils/zod-to-json-schema/parsers/bigint.d.ts.map +1 -0
  366. package/dist/utils/zod-to-json-schema/parsers/bigint.js +36 -0
  367. package/dist/utils/zod-to-json-schema/parsers/bigint.js.map +1 -0
  368. package/dist/utils/zod-to-json-schema/parsers/boolean.cjs +9 -0
  369. package/dist/utils/zod-to-json-schema/parsers/boolean.cjs.map +1 -0
  370. package/dist/utils/zod-to-json-schema/parsers/boolean.d.cts +7 -0
  371. package/dist/utils/zod-to-json-schema/parsers/boolean.d.cts.map +1 -0
  372. package/dist/utils/zod-to-json-schema/parsers/boolean.d.ts +7 -0
  373. package/dist/utils/zod-to-json-schema/parsers/boolean.d.ts.map +1 -0
  374. package/dist/utils/zod-to-json-schema/parsers/boolean.js +8 -0
  375. package/dist/utils/zod-to-json-schema/parsers/boolean.js.map +1 -0
  376. package/dist/utils/zod-to-json-schema/parsers/branded.cjs +10 -0
  377. package/dist/utils/zod-to-json-schema/parsers/branded.cjs.map +1 -0
  378. package/dist/utils/zod-to-json-schema/parsers/branded.js +10 -0
  379. package/dist/utils/zod-to-json-schema/parsers/branded.js.map +1 -0
  380. package/dist/utils/zod-to-json-schema/parsers/catch.cjs +10 -0
  381. package/dist/utils/zod-to-json-schema/parsers/catch.cjs.map +1 -0
  382. package/dist/utils/zod-to-json-schema/parsers/catch.js +10 -0
  383. package/dist/utils/zod-to-json-schema/parsers/catch.js.map +1 -0
  384. package/dist/utils/zod-to-json-schema/parsers/date.cjs +39 -0
  385. package/dist/utils/zod-to-json-schema/parsers/date.cjs.map +1 -0
  386. package/dist/utils/zod-to-json-schema/parsers/date.d.cts +17 -0
  387. package/dist/utils/zod-to-json-schema/parsers/date.d.cts.map +1 -0
  388. package/dist/utils/zod-to-json-schema/parsers/date.d.ts +17 -0
  389. package/dist/utils/zod-to-json-schema/parsers/date.d.ts.map +1 -0
  390. package/dist/utils/zod-to-json-schema/parsers/date.js +39 -0
  391. package/dist/utils/zod-to-json-schema/parsers/date.js.map +1 -0
  392. package/dist/utils/zod-to-json-schema/parsers/default.cjs +13 -0
  393. package/dist/utils/zod-to-json-schema/parsers/default.cjs.map +1 -0
  394. package/dist/utils/zod-to-json-schema/parsers/default.js +13 -0
  395. package/dist/utils/zod-to-json-schema/parsers/default.js.map +1 -0
  396. package/dist/utils/zod-to-json-schema/parsers/effects.cjs +11 -0
  397. package/dist/utils/zod-to-json-schema/parsers/effects.cjs.map +1 -0
  398. package/dist/utils/zod-to-json-schema/parsers/effects.js +11 -0
  399. package/dist/utils/zod-to-json-schema/parsers/effects.js.map +1 -0
  400. package/dist/utils/zod-to-json-schema/parsers/enum.cjs +12 -0
  401. package/dist/utils/zod-to-json-schema/parsers/enum.cjs.map +1 -0
  402. package/dist/utils/zod-to-json-schema/parsers/enum.d.cts +8 -0
  403. package/dist/utils/zod-to-json-schema/parsers/enum.d.cts.map +1 -0
  404. package/dist/utils/zod-to-json-schema/parsers/enum.d.ts +10 -0
  405. package/dist/utils/zod-to-json-schema/parsers/enum.d.ts.map +1 -0
  406. package/dist/utils/zod-to-json-schema/parsers/enum.js +11 -0
  407. package/dist/utils/zod-to-json-schema/parsers/enum.js.map +1 -0
  408. package/dist/utils/zod-to-json-schema/parsers/intersection.cjs +47 -0
  409. package/dist/utils/zod-to-json-schema/parsers/intersection.cjs.map +1 -0
  410. package/dist/utils/zod-to-json-schema/parsers/intersection.d.cts +10 -0
  411. package/dist/utils/zod-to-json-schema/parsers/intersection.d.cts.map +1 -0
  412. package/dist/utils/zod-to-json-schema/parsers/intersection.d.ts +11 -0
  413. package/dist/utils/zod-to-json-schema/parsers/intersection.d.ts.map +1 -0
  414. package/dist/utils/zod-to-json-schema/parsers/intersection.js +47 -0
  415. package/dist/utils/zod-to-json-schema/parsers/intersection.js.map +1 -0
  416. package/dist/utils/zod-to-json-schema/parsers/literal.cjs +18 -0
  417. package/dist/utils/zod-to-json-schema/parsers/literal.cjs.map +1 -0
  418. package/dist/utils/zod-to-json-schema/parsers/literal.d.cts +11 -0
  419. package/dist/utils/zod-to-json-schema/parsers/literal.d.cts.map +1 -0
  420. package/dist/utils/zod-to-json-schema/parsers/literal.d.ts +12 -0
  421. package/dist/utils/zod-to-json-schema/parsers/literal.d.ts.map +1 -0
  422. package/dist/utils/zod-to-json-schema/parsers/literal.js +17 -0
  423. package/dist/utils/zod-to-json-schema/parsers/literal.js.map +1 -0
  424. package/dist/utils/zod-to-json-schema/parsers/map.cjs +40 -0
  425. package/dist/utils/zod-to-json-schema/parsers/map.cjs.map +1 -0
  426. package/dist/utils/zod-to-json-schema/parsers/map.d.cts +17 -0
  427. package/dist/utils/zod-to-json-schema/parsers/map.d.cts.map +1 -0
  428. package/dist/utils/zod-to-json-schema/parsers/map.d.ts +17 -0
  429. package/dist/utils/zod-to-json-schema/parsers/map.d.ts.map +1 -0
  430. package/dist/utils/zod-to-json-schema/parsers/map.js +40 -0
  431. package/dist/utils/zod-to-json-schema/parsers/map.js.map +1 -0
  432. package/dist/utils/zod-to-json-schema/parsers/nativeEnum.cjs +18 -0
  433. package/dist/utils/zod-to-json-schema/parsers/nativeEnum.cjs.map +1 -0
  434. package/dist/utils/zod-to-json-schema/parsers/nativeEnum.d.cts +8 -0
  435. package/dist/utils/zod-to-json-schema/parsers/nativeEnum.d.cts.map +1 -0
  436. package/dist/utils/zod-to-json-schema/parsers/nativeEnum.d.ts +10 -0
  437. package/dist/utils/zod-to-json-schema/parsers/nativeEnum.d.ts.map +1 -0
  438. package/dist/utils/zod-to-json-schema/parsers/nativeEnum.js +17 -0
  439. package/dist/utils/zod-to-json-schema/parsers/nativeEnum.js.map +1 -0
  440. package/dist/utils/zod-to-json-schema/parsers/never.cjs +13 -0
  441. package/dist/utils/zod-to-json-schema/parsers/never.cjs.map +1 -0
  442. package/dist/utils/zod-to-json-schema/parsers/never.d.cts +9 -0
  443. package/dist/utils/zod-to-json-schema/parsers/never.d.cts.map +1 -0
  444. package/dist/utils/zod-to-json-schema/parsers/never.d.ts +9 -0
  445. package/dist/utils/zod-to-json-schema/parsers/never.d.ts.map +1 -0
  446. package/dist/utils/zod-to-json-schema/parsers/never.js +13 -0
  447. package/dist/utils/zod-to-json-schema/parsers/never.js.map +1 -0
  448. package/dist/utils/zod-to-json-schema/parsers/null.cjs +12 -0
  449. package/dist/utils/zod-to-json-schema/parsers/null.cjs.map +1 -0
  450. package/dist/utils/zod-to-json-schema/parsers/null.d.cts +7 -0
  451. package/dist/utils/zod-to-json-schema/parsers/null.d.cts.map +1 -0
  452. package/dist/utils/zod-to-json-schema/parsers/null.d.ts +7 -0
  453. package/dist/utils/zod-to-json-schema/parsers/null.d.ts.map +1 -0
  454. package/dist/utils/zod-to-json-schema/parsers/null.js +11 -0
  455. package/dist/utils/zod-to-json-schema/parsers/null.js.map +1 -0
  456. package/dist/utils/zod-to-json-schema/parsers/nullable.cjs +46 -0
  457. package/dist/utils/zod-to-json-schema/parsers/nullable.cjs.map +1 -0
  458. package/dist/utils/zod-to-json-schema/parsers/nullable.d.cts +12 -0
  459. package/dist/utils/zod-to-json-schema/parsers/nullable.d.cts.map +1 -0
  460. package/dist/utils/zod-to-json-schema/parsers/nullable.d.ts +13 -0
  461. package/dist/utils/zod-to-json-schema/parsers/nullable.d.ts.map +1 -0
  462. package/dist/utils/zod-to-json-schema/parsers/nullable.js +46 -0
  463. package/dist/utils/zod-to-json-schema/parsers/nullable.js.map +1 -0
  464. package/dist/utils/zod-to-json-schema/parsers/number.cjs +37 -0
  465. package/dist/utils/zod-to-json-schema/parsers/number.cjs.map +1 -0
  466. package/dist/utils/zod-to-json-schema/parsers/number.d.cts +15 -0
  467. package/dist/utils/zod-to-json-schema/parsers/number.d.cts.map +1 -0
  468. package/dist/utils/zod-to-json-schema/parsers/number.d.ts +16 -0
  469. package/dist/utils/zod-to-json-schema/parsers/number.d.ts.map +1 -0
  470. package/dist/utils/zod-to-json-schema/parsers/number.js +37 -0
  471. package/dist/utils/zod-to-json-schema/parsers/number.js.map +1 -0
  472. package/dist/utils/zod-to-json-schema/parsers/object.cjs +64 -0
  473. package/dist/utils/zod-to-json-schema/parsers/object.cjs.map +1 -0
  474. package/dist/utils/zod-to-json-schema/parsers/object.d.cts +12 -0
  475. package/dist/utils/zod-to-json-schema/parsers/object.d.cts.map +1 -0
  476. package/dist/utils/zod-to-json-schema/parsers/object.d.ts +13 -0
  477. package/dist/utils/zod-to-json-schema/parsers/object.d.ts.map +1 -0
  478. package/dist/utils/zod-to-json-schema/parsers/object.js +64 -0
  479. package/dist/utils/zod-to-json-schema/parsers/object.js.map +1 -0
  480. package/dist/utils/zod-to-json-schema/parsers/optional.cjs +20 -0
  481. package/dist/utils/zod-to-json-schema/parsers/optional.cjs.map +1 -0
  482. package/dist/utils/zod-to-json-schema/parsers/optional.js +20 -0
  483. package/dist/utils/zod-to-json-schema/parsers/optional.js.map +1 -0
  484. package/dist/utils/zod-to-json-schema/parsers/pipeline.cjs +28 -0
  485. package/dist/utils/zod-to-json-schema/parsers/pipeline.cjs.map +1 -0
  486. package/dist/utils/zod-to-json-schema/parsers/pipeline.js +28 -0
  487. package/dist/utils/zod-to-json-schema/parsers/pipeline.js.map +1 -0
  488. package/dist/utils/zod-to-json-schema/parsers/promise.cjs +10 -0
  489. package/dist/utils/zod-to-json-schema/parsers/promise.cjs.map +1 -0
  490. package/dist/utils/zod-to-json-schema/parsers/promise.js +10 -0
  491. package/dist/utils/zod-to-json-schema/parsers/promise.js.map +1 -0
  492. package/dist/utils/zod-to-json-schema/parsers/readonly.cjs +10 -0
  493. package/dist/utils/zod-to-json-schema/parsers/readonly.cjs.map +1 -0
  494. package/dist/utils/zod-to-json-schema/parsers/readonly.js +10 -0
  495. package/dist/utils/zod-to-json-schema/parsers/readonly.js.map +1 -0
  496. package/dist/utils/zod-to-json-schema/parsers/record.cjs +57 -0
  497. package/dist/utils/zod-to-json-schema/parsers/record.cjs.map +1 -0
  498. package/dist/utils/zod-to-json-schema/parsers/record.d.cts +14 -0
  499. package/dist/utils/zod-to-json-schema/parsers/record.d.cts.map +1 -0
  500. package/dist/utils/zod-to-json-schema/parsers/record.d.ts +15 -0
  501. package/dist/utils/zod-to-json-schema/parsers/record.d.ts.map +1 -0
  502. package/dist/utils/zod-to-json-schema/parsers/record.js +56 -0
  503. package/dist/utils/zod-to-json-schema/parsers/record.js.map +1 -0
  504. package/dist/utils/zod-to-json-schema/parsers/set.cjs +22 -0
  505. package/dist/utils/zod-to-json-schema/parsers/set.cjs.map +1 -0
  506. package/dist/utils/zod-to-json-schema/parsers/set.d.cts +15 -0
  507. package/dist/utils/zod-to-json-schema/parsers/set.d.cts.map +1 -0
  508. package/dist/utils/zod-to-json-schema/parsers/set.d.ts +16 -0
  509. package/dist/utils/zod-to-json-schema/parsers/set.d.ts.map +1 -0
  510. package/dist/utils/zod-to-json-schema/parsers/set.js +22 -0
  511. package/dist/utils/zod-to-json-schema/parsers/set.js.map +1 -0
  512. package/dist/utils/zod-to-json-schema/parsers/string.cjs +255 -0
  513. package/dist/utils/zod-to-json-schema/parsers/string.cjs.map +1 -0
  514. package/dist/utils/zod-to-json-schema/parsers/string.d.cts +28 -0
  515. package/dist/utils/zod-to-json-schema/parsers/string.d.cts.map +1 -0
  516. package/dist/utils/zod-to-json-schema/parsers/string.d.ts +29 -0
  517. package/dist/utils/zod-to-json-schema/parsers/string.d.ts.map +1 -0
  518. package/dist/utils/zod-to-json-schema/parsers/string.js +254 -0
  519. package/dist/utils/zod-to-json-schema/parsers/string.js.map +1 -0
  520. package/dist/utils/zod-to-json-schema/parsers/tuple.cjs +38 -0
  521. package/dist/utils/zod-to-json-schema/parsers/tuple.cjs.map +1 -0
  522. package/dist/utils/zod-to-json-schema/parsers/tuple.d.cts +15 -0
  523. package/dist/utils/zod-to-json-schema/parsers/tuple.d.cts.map +1 -0
  524. package/dist/utils/zod-to-json-schema/parsers/tuple.d.ts +16 -0
  525. package/dist/utils/zod-to-json-schema/parsers/tuple.d.ts.map +1 -0
  526. package/dist/utils/zod-to-json-schema/parsers/tuple.js +38 -0
  527. package/dist/utils/zod-to-json-schema/parsers/tuple.js.map +1 -0
  528. package/dist/utils/zod-to-json-schema/parsers/undefined.cjs +10 -0
  529. package/dist/utils/zod-to-json-schema/parsers/undefined.cjs.map +1 -0
  530. package/dist/utils/zod-to-json-schema/parsers/undefined.d.cts +9 -0
  531. package/dist/utils/zod-to-json-schema/parsers/undefined.d.cts.map +1 -0
  532. package/dist/utils/zod-to-json-schema/parsers/undefined.d.ts +9 -0
  533. package/dist/utils/zod-to-json-schema/parsers/undefined.d.ts.map +1 -0
  534. package/dist/utils/zod-to-json-schema/parsers/undefined.js +10 -0
  535. package/dist/utils/zod-to-json-schema/parsers/undefined.js.map +1 -0
  536. package/dist/utils/zod-to-json-schema/parsers/union.cjs +67 -0
  537. package/dist/utils/zod-to-json-schema/parsers/union.cjs.map +1 -0
  538. package/dist/utils/zod-to-json-schema/parsers/union.d.cts +24 -0
  539. package/dist/utils/zod-to-json-schema/parsers/union.d.cts.map +1 -0
  540. package/dist/utils/zod-to-json-schema/parsers/union.d.ts +25 -0
  541. package/dist/utils/zod-to-json-schema/parsers/union.d.ts.map +1 -0
  542. package/dist/utils/zod-to-json-schema/parsers/union.js +66 -0
  543. package/dist/utils/zod-to-json-schema/parsers/union.js.map +1 -0
  544. package/dist/utils/zod-to-json-schema/parsers/unknown.cjs +10 -0
  545. package/dist/utils/zod-to-json-schema/parsers/unknown.cjs.map +1 -0
  546. package/dist/utils/zod-to-json-schema/parsers/unknown.d.cts +7 -0
  547. package/dist/utils/zod-to-json-schema/parsers/unknown.d.cts.map +1 -0
  548. package/dist/utils/zod-to-json-schema/parsers/unknown.d.ts +7 -0
  549. package/dist/utils/zod-to-json-schema/parsers/unknown.d.ts.map +1 -0
  550. package/dist/utils/zod-to-json-schema/parsers/unknown.js +10 -0
  551. package/dist/utils/zod-to-json-schema/parsers/unknown.js.map +1 -0
  552. package/dist/utils/zod-to-json-schema/selectParser.cjs +81 -0
  553. package/dist/utils/zod-to-json-schema/selectParser.cjs.map +1 -0
  554. package/dist/utils/zod-to-json-schema/selectParser.js +80 -0
  555. package/dist/utils/zod-to-json-schema/selectParser.js.map +1 -0
  556. package/dist/utils/zod-to-json-schema/zodToJsonSchema.cjs +70 -0
  557. package/dist/utils/zod-to-json-schema/zodToJsonSchema.cjs.map +1 -0
  558. package/dist/utils/zod-to-json-schema/zodToJsonSchema.js +70 -0
  559. package/dist/utils/zod-to-json-schema/zodToJsonSchema.js.map +1 -0
  560. package/package.json +7 -36
  561. package/dist/utils/js-sha1/hash.cjs +0 -291
  562. package/dist/utils/js-sha1/hash.cjs.map +0 -1
  563. package/dist/utils/js-sha1/hash.d.cts +0 -9
  564. package/dist/utils/js-sha1/hash.d.cts.map +0 -1
  565. package/dist/utils/js-sha1/hash.d.ts +0 -9
  566. package/dist/utils/js-sha1/hash.d.ts.map +0 -1
  567. package/dist/utils/js-sha1/hash.js +0 -284
  568. package/dist/utils/js-sha1/hash.js.map +0 -1
  569. package/dist/utils/testing/index.d.cts.map +0 -1
  570. package/dist/utils/testing/index.d.ts.map +0 -1
@@ -0,0 +1,101 @@
1
+ import { Document } from "../../documents/document.cjs";
2
+ import { EmbeddingsInterface } from "../../embeddings.cjs";
3
+ import { VectorStore } from "../../vectorstores.cjs";
4
+ import { cosine } from "../ml-distance/similarities.cjs";
5
+
6
+ //#region src/utils/testing/vectorstores.d.ts
7
+
8
+ /**
9
+ * Interface representing a vector in memory. It includes the content
10
+ * (text), the corresponding embedding (vector), and any associated
11
+ * metadata.
12
+ */
13
+ interface MemoryVector {
14
+ content: string;
15
+ embedding: number[];
16
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
17
+ metadata: Record<string, any>;
18
+ }
19
+ /**
20
+ * Interface for the arguments that can be passed to the
21
+ * `FakeVectorStore` constructor. It includes an optional `similarity`
22
+ * function.
23
+ */
24
+ interface FakeVectorStoreArgs {
25
+ similarity?: typeof cosine;
26
+ }
27
+ /**
28
+ * Class that extends `VectorStore` to store vectors in memory. Provides
29
+ * methods for adding documents, performing similarity searches, and
30
+ * creating instances from texts, documents, or an existing index.
31
+ */
32
+ declare class FakeVectorStore extends VectorStore {
33
+ FilterType: (doc: Document) => boolean;
34
+ memoryVectors: MemoryVector[];
35
+ similarity: typeof cosine;
36
+ _vectorstoreType(): string;
37
+ constructor(embeddings: EmbeddingsInterface, {
38
+ similarity,
39
+ ...rest
40
+ }?: FakeVectorStoreArgs);
41
+ /**
42
+ * Method to add documents to the memory vector store. It extracts the
43
+ * text from each document, generates embeddings for them, and adds the
44
+ * resulting vectors to the store.
45
+ * @param documents Array of `Document` instances to be added to the store.
46
+ * @returns Promise that resolves when all documents have been added.
47
+ */
48
+ addDocuments(documents: Document[]): Promise<void>;
49
+ /**
50
+ * Method to add vectors to the memory vector store. It creates
51
+ * `MemoryVector` instances for each vector and document pair and adds
52
+ * them to the store.
53
+ * @param vectors Array of vectors to be added to the store.
54
+ * @param documents Array of `Document` instances corresponding to the vectors.
55
+ * @returns Promise that resolves when all vectors have been added.
56
+ */
57
+ addVectors(vectors: number[][], documents: Document[]): Promise<void>;
58
+ /**
59
+ * Method to perform a similarity search in the memory vector store. It
60
+ * calculates the similarity between the query vector and each vector in
61
+ * the store, sorts the results by similarity, and returns the top `k`
62
+ * results along with their scores.
63
+ * @param query Query vector to compare against the vectors in the store.
64
+ * @param k Number of top results to return.
65
+ * @param filter Optional filter function to apply to the vectors before performing the search.
66
+ * @returns Promise that resolves with an array of tuples, each containing a `Document` and its similarity score.
67
+ */
68
+ similaritySearchVectorWithScore(query: number[], k: number, filter?: this["FilterType"]): Promise<[Document, number][]>;
69
+ /**
70
+ * Static method to create a `FakeVectorStore` instance from an array of
71
+ * texts. It creates a `Document` for each text and metadata pair, and
72
+ * adds them to the store.
73
+ * @param texts Array of texts to be added to the store.
74
+ * @param metadatas Array or single object of metadata corresponding to the texts.
75
+ * @param embeddings `Embeddings` instance used to generate embeddings for the texts.
76
+ * @param dbConfig Optional `FakeVectorStoreArgs` to configure the `FakeVectorStore` instance.
77
+ * @returns Promise that resolves with a new `FakeVectorStore` instance.
78
+ */
79
+ static fromTexts(texts: string[], metadatas: object[] | object, embeddings: EmbeddingsInterface, dbConfig?: FakeVectorStoreArgs): Promise<FakeVectorStore>;
80
+ /**
81
+ * Static method to create a `FakeVectorStore` instance from an array of
82
+ * `Document` instances. It adds the documents to the store.
83
+ * @param docs Array of `Document` instances to be added to the store.
84
+ * @param embeddings `Embeddings` instance used to generate embeddings for the documents.
85
+ * @param dbConfig Optional `FakeVectorStoreArgs` to configure the `FakeVectorStore` instance.
86
+ * @returns Promise that resolves with a new `FakeVectorStore` instance.
87
+ */
88
+ static fromDocuments(docs: Document[], embeddings: EmbeddingsInterface, dbConfig?: FakeVectorStoreArgs): Promise<FakeVectorStore>;
89
+ /**
90
+ * Static method to create a `FakeVectorStore` instance from an existing
91
+ * index. It creates a new `FakeVectorStore` instance without adding any
92
+ * documents or vectors.
93
+ * @param embeddings `Embeddings` instance used to generate embeddings for the documents.
94
+ * @param dbConfig Optional `FakeVectorStoreArgs` to configure the `FakeVectorStore` instance.
95
+ * @returns Promise that resolves with a new `FakeVectorStore` instance.
96
+ */
97
+ static fromExistingIndex(embeddings: EmbeddingsInterface, dbConfig?: FakeVectorStoreArgs): Promise<FakeVectorStore>;
98
+ }
99
+ //#endregion
100
+ export { FakeVectorStore, FakeVectorStoreArgs };
101
+ //# sourceMappingURL=vectorstores.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vectorstores.d.cts","names":["Document","EmbeddingsInterface","VectorStore","cosine","MemoryVector","Record","FakeVectorStoreArgs","FakeVectorStore","similarity","Promise"],"sources":["../../../src/utils/testing/vectorstores.d.ts"],"sourcesContent":["import { Document } from \"../../documents/document.js\";\nimport { EmbeddingsInterface } from \"../../embeddings.js\";\nimport { VectorStore } from \"../../vectorstores.js\";\nimport { cosine } from \"../ml-distance/similarities.js\";\n/**\n * Interface representing a vector in memory. It includes the content\n * (text), the corresponding embedding (vector), and any associated\n * metadata.\n */\ninterface MemoryVector {\n content: string;\n embedding: number[];\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n metadata: Record<string, any>;\n}\n/**\n * Interface for the arguments that can be passed to the\n * `FakeVectorStore` constructor. It includes an optional `similarity`\n * function.\n */\nexport interface FakeVectorStoreArgs {\n similarity?: typeof cosine;\n}\n/**\n * Class that extends `VectorStore` to store vectors in memory. Provides\n * methods for adding documents, performing similarity searches, and\n * creating instances from texts, documents, or an existing index.\n */\nexport declare class FakeVectorStore extends VectorStore {\n FilterType: (doc: Document) => boolean;\n memoryVectors: MemoryVector[];\n similarity: typeof cosine;\n _vectorstoreType(): string;\n constructor(embeddings: EmbeddingsInterface, { similarity, ...rest }?: FakeVectorStoreArgs);\n /**\n * Method to add documents to the memory vector store. It extracts the\n * text from each document, generates embeddings for them, and adds the\n * resulting vectors to the store.\n * @param documents Array of `Document` instances to be added to the store.\n * @returns Promise that resolves when all documents have been added.\n */\n addDocuments(documents: Document[]): Promise<void>;\n /**\n * Method to add vectors to the memory vector store. It creates\n * `MemoryVector` instances for each vector and document pair and adds\n * them to the store.\n * @param vectors Array of vectors to be added to the store.\n * @param documents Array of `Document` instances corresponding to the vectors.\n * @returns Promise that resolves when all vectors have been added.\n */\n addVectors(vectors: number[][], documents: Document[]): Promise<void>;\n /**\n * Method to perform a similarity search in the memory vector store. It\n * calculates the similarity between the query vector and each vector in\n * the store, sorts the results by similarity, and returns the top `k`\n * results along with their scores.\n * @param query Query vector to compare against the vectors in the store.\n * @param k Number of top results to return.\n * @param filter Optional filter function to apply to the vectors before performing the search.\n * @returns Promise that resolves with an array of tuples, each containing a `Document` and its similarity score.\n */\n similaritySearchVectorWithScore(query: number[], k: number, filter?: this[\"FilterType\"]): Promise<[Document, number][]>;\n /**\n * Static method to create a `FakeVectorStore` instance from an array of\n * texts. It creates a `Document` for each text and metadata pair, and\n * adds them to the store.\n * @param texts Array of texts to be added to the store.\n * @param metadatas Array or single object of metadata corresponding to the texts.\n * @param embeddings `Embeddings` instance used to generate embeddings for the texts.\n * @param dbConfig Optional `FakeVectorStoreArgs` to configure the `FakeVectorStore` instance.\n * @returns Promise that resolves with a new `FakeVectorStore` instance.\n */\n static fromTexts(texts: string[], metadatas: object[] | object, embeddings: EmbeddingsInterface, dbConfig?: FakeVectorStoreArgs): Promise<FakeVectorStore>;\n /**\n * Static method to create a `FakeVectorStore` instance from an array of\n * `Document` instances. It adds the documents to the store.\n * @param docs Array of `Document` instances to be added to the store.\n * @param embeddings `Embeddings` instance used to generate embeddings for the documents.\n * @param dbConfig Optional `FakeVectorStoreArgs` to configure the `FakeVectorStore` instance.\n * @returns Promise that resolves with a new `FakeVectorStore` instance.\n */\n static fromDocuments(docs: Document[], embeddings: EmbeddingsInterface, dbConfig?: FakeVectorStoreArgs): Promise<FakeVectorStore>;\n /**\n * Static method to create a `FakeVectorStore` instance from an existing\n * index. It creates a new `FakeVectorStore` instance without adding any\n * documents or vectors.\n * @param embeddings `Embeddings` instance used to generate embeddings for the documents.\n * @param dbConfig Optional `FakeVectorStoreArgs` to configure the `FakeVectorStore` instance.\n * @returns Promise that resolves with a new `FakeVectorStore` instance.\n */\n static fromExistingIndex(embeddings: EmbeddingsInterface, dbConfig?: FakeVectorStoreArgs): Promise<FakeVectorStore>;\n}\nexport {};\n"],"mappings":";;;;;;;;;AAGwD;AAiBxD;AAQA;UAnBUI,YAAAA,CAmB0B;EAAA,OACdJ,EAAAA,MAAAA;EAAQ,SACXI,EAAAA,MAAAA,EAAAA;EAAY;EACF,QAEDH,EApBdI,MAoBcJ,CAAAA,MAAAA,EAAAA,GAAAA,CAAAA;;;;;;;AA4B2ED,UAzCtFM,mBAAAA,CAyCsFN;EAAQ,UAAjBS,CAAAA,EAAAA,OAxCtEN,MAwCsEM;;;;;;;AAoBPH,cArDlEC,eAAAA,SAAwBL,WAAAA,CAqD0CI;EAAmB,UAAWC,EAAAA,CAAAA,GAAAA,EApD/FP,QAoD+FO,EAAAA,GAAAA,OAAAA;EAAe,aAAvBE,EAnD1FL,YAmD0FK,EAAAA;EAAO,UAS3ER,EAAAA,OA3DlBE,MA2DkBF;EAAmB,gBAAaK,CAAAA,CAAAA,EAAAA,MAAAA;EAAmB,WAAWC,CAAAA,UAAAA,EAzD3EN,mBAyD2EM,EAAAA;IAAAA,UAAAA;IAAAA,GAAAA;EAAAA,CAAAA,CAAAA,EAzD5BD,mBAyD4BC;EAAe;;AA9D9D;;;;;0BAa5BP,aAAaS;;;;;;;;;6CASMT,aAAaS;;;;;;;;;;;4FAWkCA,SAAST;;;;;;;;;;;8EAWvBC,gCAAgCK,sBAAsBG,QAAQF;;;;;;;;;6BAS/GP,wBAAwBC,gCAAgCK,sBAAsBG,QAAQF;;;;;;;;;uCAS5EN,gCAAgCK,sBAAsBG,QAAQF"}
@@ -0,0 +1,101 @@
1
+ import { Document } from "../../documents/document.js";
2
+ import { EmbeddingsInterface } from "../../embeddings.js";
3
+ import { VectorStore } from "../../vectorstores.js";
4
+ import { cosine } from "../ml-distance/similarities.js";
5
+
6
+ //#region src/utils/testing/vectorstores.d.ts
7
+
8
+ /**
9
+ * Interface representing a vector in memory. It includes the content
10
+ * (text), the corresponding embedding (vector), and any associated
11
+ * metadata.
12
+ */
13
+ interface MemoryVector {
14
+ content: string;
15
+ embedding: number[];
16
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
17
+ metadata: Record<string, any>;
18
+ }
19
+ /**
20
+ * Interface for the arguments that can be passed to the
21
+ * `FakeVectorStore` constructor. It includes an optional `similarity`
22
+ * function.
23
+ */
24
+ interface FakeVectorStoreArgs {
25
+ similarity?: typeof cosine;
26
+ }
27
+ /**
28
+ * Class that extends `VectorStore` to store vectors in memory. Provides
29
+ * methods for adding documents, performing similarity searches, and
30
+ * creating instances from texts, documents, or an existing index.
31
+ */
32
+ declare class FakeVectorStore extends VectorStore {
33
+ FilterType: (doc: Document) => boolean;
34
+ memoryVectors: MemoryVector[];
35
+ similarity: typeof cosine;
36
+ _vectorstoreType(): string;
37
+ constructor(embeddings: EmbeddingsInterface, {
38
+ similarity,
39
+ ...rest
40
+ }?: FakeVectorStoreArgs);
41
+ /**
42
+ * Method to add documents to the memory vector store. It extracts the
43
+ * text from each document, generates embeddings for them, and adds the
44
+ * resulting vectors to the store.
45
+ * @param documents Array of `Document` instances to be added to the store.
46
+ * @returns Promise that resolves when all documents have been added.
47
+ */
48
+ addDocuments(documents: Document[]): Promise<void>;
49
+ /**
50
+ * Method to add vectors to the memory vector store. It creates
51
+ * `MemoryVector` instances for each vector and document pair and adds
52
+ * them to the store.
53
+ * @param vectors Array of vectors to be added to the store.
54
+ * @param documents Array of `Document` instances corresponding to the vectors.
55
+ * @returns Promise that resolves when all vectors have been added.
56
+ */
57
+ addVectors(vectors: number[][], documents: Document[]): Promise<void>;
58
+ /**
59
+ * Method to perform a similarity search in the memory vector store. It
60
+ * calculates the similarity between the query vector and each vector in
61
+ * the store, sorts the results by similarity, and returns the top `k`
62
+ * results along with their scores.
63
+ * @param query Query vector to compare against the vectors in the store.
64
+ * @param k Number of top results to return.
65
+ * @param filter Optional filter function to apply to the vectors before performing the search.
66
+ * @returns Promise that resolves with an array of tuples, each containing a `Document` and its similarity score.
67
+ */
68
+ similaritySearchVectorWithScore(query: number[], k: number, filter?: this["FilterType"]): Promise<[Document, number][]>;
69
+ /**
70
+ * Static method to create a `FakeVectorStore` instance from an array of
71
+ * texts. It creates a `Document` for each text and metadata pair, and
72
+ * adds them to the store.
73
+ * @param texts Array of texts to be added to the store.
74
+ * @param metadatas Array or single object of metadata corresponding to the texts.
75
+ * @param embeddings `Embeddings` instance used to generate embeddings for the texts.
76
+ * @param dbConfig Optional `FakeVectorStoreArgs` to configure the `FakeVectorStore` instance.
77
+ * @returns Promise that resolves with a new `FakeVectorStore` instance.
78
+ */
79
+ static fromTexts(texts: string[], metadatas: object[] | object, embeddings: EmbeddingsInterface, dbConfig?: FakeVectorStoreArgs): Promise<FakeVectorStore>;
80
+ /**
81
+ * Static method to create a `FakeVectorStore` instance from an array of
82
+ * `Document` instances. It adds the documents to the store.
83
+ * @param docs Array of `Document` instances to be added to the store.
84
+ * @param embeddings `Embeddings` instance used to generate embeddings for the documents.
85
+ * @param dbConfig Optional `FakeVectorStoreArgs` to configure the `FakeVectorStore` instance.
86
+ * @returns Promise that resolves with a new `FakeVectorStore` instance.
87
+ */
88
+ static fromDocuments(docs: Document[], embeddings: EmbeddingsInterface, dbConfig?: FakeVectorStoreArgs): Promise<FakeVectorStore>;
89
+ /**
90
+ * Static method to create a `FakeVectorStore` instance from an existing
91
+ * index. It creates a new `FakeVectorStore` instance without adding any
92
+ * documents or vectors.
93
+ * @param embeddings `Embeddings` instance used to generate embeddings for the documents.
94
+ * @param dbConfig Optional `FakeVectorStoreArgs` to configure the `FakeVectorStore` instance.
95
+ * @returns Promise that resolves with a new `FakeVectorStore` instance.
96
+ */
97
+ static fromExistingIndex(embeddings: EmbeddingsInterface, dbConfig?: FakeVectorStoreArgs): Promise<FakeVectorStore>;
98
+ }
99
+ //#endregion
100
+ export { FakeVectorStore, FakeVectorStoreArgs };
101
+ //# sourceMappingURL=vectorstores.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vectorstores.d.ts","names":["Document","EmbeddingsInterface","VectorStore","cosine","MemoryVector","Record","FakeVectorStoreArgs","FakeVectorStore","similarity","Promise"],"sources":["../../../src/utils/testing/vectorstores.d.ts"],"sourcesContent":["import { Document } from \"../../documents/document.js\";\nimport { EmbeddingsInterface } from \"../../embeddings.js\";\nimport { VectorStore } from \"../../vectorstores.js\";\nimport { cosine } from \"../ml-distance/similarities.js\";\n/**\n * Interface representing a vector in memory. It includes the content\n * (text), the corresponding embedding (vector), and any associated\n * metadata.\n */\ninterface MemoryVector {\n content: string;\n embedding: number[];\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n metadata: Record<string, any>;\n}\n/**\n * Interface for the arguments that can be passed to the\n * `FakeVectorStore` constructor. It includes an optional `similarity`\n * function.\n */\nexport interface FakeVectorStoreArgs {\n similarity?: typeof cosine;\n}\n/**\n * Class that extends `VectorStore` to store vectors in memory. Provides\n * methods for adding documents, performing similarity searches, and\n * creating instances from texts, documents, or an existing index.\n */\nexport declare class FakeVectorStore extends VectorStore {\n FilterType: (doc: Document) => boolean;\n memoryVectors: MemoryVector[];\n similarity: typeof cosine;\n _vectorstoreType(): string;\n constructor(embeddings: EmbeddingsInterface, { similarity, ...rest }?: FakeVectorStoreArgs);\n /**\n * Method to add documents to the memory vector store. It extracts the\n * text from each document, generates embeddings for them, and adds the\n * resulting vectors to the store.\n * @param documents Array of `Document` instances to be added to the store.\n * @returns Promise that resolves when all documents have been added.\n */\n addDocuments(documents: Document[]): Promise<void>;\n /**\n * Method to add vectors to the memory vector store. It creates\n * `MemoryVector` instances for each vector and document pair and adds\n * them to the store.\n * @param vectors Array of vectors to be added to the store.\n * @param documents Array of `Document` instances corresponding to the vectors.\n * @returns Promise that resolves when all vectors have been added.\n */\n addVectors(vectors: number[][], documents: Document[]): Promise<void>;\n /**\n * Method to perform a similarity search in the memory vector store. It\n * calculates the similarity between the query vector and each vector in\n * the store, sorts the results by similarity, and returns the top `k`\n * results along with their scores.\n * @param query Query vector to compare against the vectors in the store.\n * @param k Number of top results to return.\n * @param filter Optional filter function to apply to the vectors before performing the search.\n * @returns Promise that resolves with an array of tuples, each containing a `Document` and its similarity score.\n */\n similaritySearchVectorWithScore(query: number[], k: number, filter?: this[\"FilterType\"]): Promise<[Document, number][]>;\n /**\n * Static method to create a `FakeVectorStore` instance from an array of\n * texts. It creates a `Document` for each text and metadata pair, and\n * adds them to the store.\n * @param texts Array of texts to be added to the store.\n * @param metadatas Array or single object of metadata corresponding to the texts.\n * @param embeddings `Embeddings` instance used to generate embeddings for the texts.\n * @param dbConfig Optional `FakeVectorStoreArgs` to configure the `FakeVectorStore` instance.\n * @returns Promise that resolves with a new `FakeVectorStore` instance.\n */\n static fromTexts(texts: string[], metadatas: object[] | object, embeddings: EmbeddingsInterface, dbConfig?: FakeVectorStoreArgs): Promise<FakeVectorStore>;\n /**\n * Static method to create a `FakeVectorStore` instance from an array of\n * `Document` instances. It adds the documents to the store.\n * @param docs Array of `Document` instances to be added to the store.\n * @param embeddings `Embeddings` instance used to generate embeddings for the documents.\n * @param dbConfig Optional `FakeVectorStoreArgs` to configure the `FakeVectorStore` instance.\n * @returns Promise that resolves with a new `FakeVectorStore` instance.\n */\n static fromDocuments(docs: Document[], embeddings: EmbeddingsInterface, dbConfig?: FakeVectorStoreArgs): Promise<FakeVectorStore>;\n /**\n * Static method to create a `FakeVectorStore` instance from an existing\n * index. It creates a new `FakeVectorStore` instance without adding any\n * documents or vectors.\n * @param embeddings `Embeddings` instance used to generate embeddings for the documents.\n * @param dbConfig Optional `FakeVectorStoreArgs` to configure the `FakeVectorStore` instance.\n * @returns Promise that resolves with a new `FakeVectorStore` instance.\n */\n static fromExistingIndex(embeddings: EmbeddingsInterface, dbConfig?: FakeVectorStoreArgs): Promise<FakeVectorStore>;\n}\nexport {};\n"],"mappings":";;;;;;;;;AAGwD;AAiBxD;AAQA;UAnBUI,YAAAA,CAmB0B;EAAA,OACdJ,EAAAA,MAAAA;EAAQ,SACXI,EAAAA,MAAAA,EAAAA;EAAY;EACF,QAEDH,EApBdI,MAoBcJ,CAAAA,MAAAA,EAAAA,GAAAA,CAAAA;;;;;;;AA4B2ED,UAzCtFM,mBAAAA,CAyCsFN;EAAQ,UAAjBS,CAAAA,EAAAA,OAxCtEN,MAwCsEM;;;;;;;AAoBPH,cArDlEC,eAAAA,SAAwBL,WAAAA,CAqD0CI;EAAmB,UAAWC,EAAAA,CAAAA,GAAAA,EApD/FP,QAoD+FO,EAAAA,GAAAA,OAAAA;EAAe,aAAvBE,EAnD1FL,YAmD0FK,EAAAA;EAAO,UAS3ER,EAAAA,OA3DlBE,MA2DkBF;EAAmB,gBAAaK,CAAAA,CAAAA,EAAAA,MAAAA;EAAmB,WAAWC,CAAAA,UAAAA,EAzD3EN,mBAyD2EM,EAAAA;IAAAA,UAAAA;IAAAA,GAAAA;EAAAA,CAAAA,CAAAA,EAzD5BD,mBAyD4BC;EAAe;;AA9D9D;;;;;0BAa5BP,aAAaS;;;;;;;;;6CASMT,aAAaS;;;;;;;;;;;4FAWkCA,SAAST;;;;;;;;;;;8EAWvBC,gCAAgCK,sBAAsBG,QAAQF;;;;;;;;;6BAS/GP,wBAAwBC,gCAAgCK,sBAAsBG,QAAQF;;;;;;;;;uCAS5EN,gCAAgCK,sBAAsBG,QAAQF"}
@@ -0,0 +1,129 @@
1
+ import { VectorStore } from "../../vectorstores.js";
2
+ import { Document } from "../../documents/document.js";
3
+ import { cosine } from "../ml-distance/similarities.js";
4
+
5
+ //#region src/utils/testing/vectorstores.ts
6
+ /**
7
+ * Class that extends `VectorStore` to store vectors in memory. Provides
8
+ * methods for adding documents, performing similarity searches, and
9
+ * creating instances from texts, documents, or an existing index.
10
+ */
11
+ var FakeVectorStore = class FakeVectorStore extends VectorStore {
12
+ memoryVectors = [];
13
+ similarity;
14
+ _vectorstoreType() {
15
+ return "memory";
16
+ }
17
+ constructor(embeddings, { similarity,...rest } = {}) {
18
+ super(embeddings, rest);
19
+ this.similarity = similarity ?? cosine;
20
+ }
21
+ /**
22
+ * Method to add documents to the memory vector store. It extracts the
23
+ * text from each document, generates embeddings for them, and adds the
24
+ * resulting vectors to the store.
25
+ * @param documents Array of `Document` instances to be added to the store.
26
+ * @returns Promise that resolves when all documents have been added.
27
+ */
28
+ async addDocuments(documents) {
29
+ const texts = documents.map(({ pageContent }) => pageContent);
30
+ return this.addVectors(await this.embeddings.embedDocuments(texts), documents);
31
+ }
32
+ /**
33
+ * Method to add vectors to the memory vector store. It creates
34
+ * `MemoryVector` instances for each vector and document pair and adds
35
+ * them to the store.
36
+ * @param vectors Array of vectors to be added to the store.
37
+ * @param documents Array of `Document` instances corresponding to the vectors.
38
+ * @returns Promise that resolves when all vectors have been added.
39
+ */
40
+ async addVectors(vectors, documents) {
41
+ const memoryVectors = vectors.map((embedding, idx) => ({
42
+ content: documents[idx].pageContent,
43
+ embedding,
44
+ metadata: documents[idx].metadata
45
+ }));
46
+ this.memoryVectors = this.memoryVectors.concat(memoryVectors);
47
+ }
48
+ /**
49
+ * Method to perform a similarity search in the memory vector store. It
50
+ * calculates the similarity between the query vector and each vector in
51
+ * the store, sorts the results by similarity, and returns the top `k`
52
+ * results along with their scores.
53
+ * @param query Query vector to compare against the vectors in the store.
54
+ * @param k Number of top results to return.
55
+ * @param filter Optional filter function to apply to the vectors before performing the search.
56
+ * @returns Promise that resolves with an array of tuples, each containing a `Document` and its similarity score.
57
+ */
58
+ async similaritySearchVectorWithScore(query, k, filter) {
59
+ const filterFunction = (memoryVector) => {
60
+ if (!filter) return true;
61
+ const doc = new Document({
62
+ metadata: memoryVector.metadata,
63
+ pageContent: memoryVector.content
64
+ });
65
+ return filter(doc);
66
+ };
67
+ const filteredMemoryVectors = this.memoryVectors.filter(filterFunction);
68
+ const searches = filteredMemoryVectors.map((vector, index) => ({
69
+ similarity: this.similarity(query, vector.embedding),
70
+ index
71
+ })).sort((a, b) => a.similarity > b.similarity ? -1 : 0).slice(0, k);
72
+ const result = searches.map((search) => [new Document({
73
+ metadata: filteredMemoryVectors[search.index].metadata,
74
+ pageContent: filteredMemoryVectors[search.index].content
75
+ }), search.similarity]);
76
+ return result;
77
+ }
78
+ /**
79
+ * Static method to create a `FakeVectorStore` instance from an array of
80
+ * texts. It creates a `Document` for each text and metadata pair, and
81
+ * adds them to the store.
82
+ * @param texts Array of texts to be added to the store.
83
+ * @param metadatas Array or single object of metadata corresponding to the texts.
84
+ * @param embeddings `Embeddings` instance used to generate embeddings for the texts.
85
+ * @param dbConfig Optional `FakeVectorStoreArgs` to configure the `FakeVectorStore` instance.
86
+ * @returns Promise that resolves with a new `FakeVectorStore` instance.
87
+ */
88
+ static async fromTexts(texts, metadatas, embeddings, dbConfig) {
89
+ const docs = [];
90
+ for (let i = 0; i < texts.length; i += 1) {
91
+ const metadata = Array.isArray(metadatas) ? metadatas[i] : metadatas;
92
+ const newDoc = new Document({
93
+ pageContent: texts[i],
94
+ metadata
95
+ });
96
+ docs.push(newDoc);
97
+ }
98
+ return FakeVectorStore.fromDocuments(docs, embeddings, dbConfig);
99
+ }
100
+ /**
101
+ * Static method to create a `FakeVectorStore` instance from an array of
102
+ * `Document` instances. It adds the documents to the store.
103
+ * @param docs Array of `Document` instances to be added to the store.
104
+ * @param embeddings `Embeddings` instance used to generate embeddings for the documents.
105
+ * @param dbConfig Optional `FakeVectorStoreArgs` to configure the `FakeVectorStore` instance.
106
+ * @returns Promise that resolves with a new `FakeVectorStore` instance.
107
+ */
108
+ static async fromDocuments(docs, embeddings, dbConfig) {
109
+ const instance = new this(embeddings, dbConfig);
110
+ await instance.addDocuments(docs);
111
+ return instance;
112
+ }
113
+ /**
114
+ * Static method to create a `FakeVectorStore` instance from an existing
115
+ * index. It creates a new `FakeVectorStore` instance without adding any
116
+ * documents or vectors.
117
+ * @param embeddings `Embeddings` instance used to generate embeddings for the documents.
118
+ * @param dbConfig Optional `FakeVectorStoreArgs` to configure the `FakeVectorStore` instance.
119
+ * @returns Promise that resolves with a new `FakeVectorStore` instance.
120
+ */
121
+ static async fromExistingIndex(embeddings, dbConfig) {
122
+ const instance = new this(embeddings, dbConfig);
123
+ return instance;
124
+ }
125
+ };
126
+
127
+ //#endregion
128
+ export { FakeVectorStore };
129
+ //# sourceMappingURL=vectorstores.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vectorstores.js","names":["embeddings: EmbeddingsInterface","documents: Document[]","vectors: number[][]","query: number[]","k: number","filter?: this[\"FilterType\"]","memoryVector: MemoryVector","result: [Document, number][]","texts: string[]","metadatas: object[] | object","dbConfig?: FakeVectorStoreArgs","docs: Document[]"],"sources":["../../../src/utils/testing/vectorstores.ts"],"sourcesContent":["import { Document } from \"../../documents/document.js\";\nimport { EmbeddingsInterface } from \"../../embeddings.js\";\nimport { VectorStore } from \"../../vectorstores.js\";\nimport { cosine } from \"../ml-distance/similarities.js\";\n\n/**\n * Interface representing a vector in memory. It includes the content\n * (text), the corresponding embedding (vector), and any associated\n * metadata.\n */\ninterface MemoryVector {\n content: string;\n embedding: number[];\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n metadata: Record<string, any>;\n}\n\n/**\n * Interface for the arguments that can be passed to the\n * `FakeVectorStore` constructor. It includes an optional `similarity`\n * function.\n */\nexport interface FakeVectorStoreArgs {\n similarity?: typeof cosine;\n}\n\n/**\n * Class that extends `VectorStore` to store vectors in memory. Provides\n * methods for adding documents, performing similarity searches, and\n * creating instances from texts, documents, or an existing index.\n */\nexport class FakeVectorStore extends VectorStore {\n declare FilterType: (doc: Document) => boolean;\n\n memoryVectors: MemoryVector[] = [];\n\n similarity: typeof cosine;\n\n _vectorstoreType(): string {\n return \"memory\";\n }\n\n constructor(\n embeddings: EmbeddingsInterface,\n { similarity, ...rest }: FakeVectorStoreArgs = {}\n ) {\n super(embeddings, rest);\n\n this.similarity = similarity ?? cosine;\n }\n\n /**\n * Method to add documents to the memory vector store. It extracts the\n * text from each document, generates embeddings for them, and adds the\n * resulting vectors to the store.\n * @param documents Array of `Document` instances to be added to the store.\n * @returns Promise that resolves when all documents have been added.\n */\n async addDocuments(documents: Document[]): Promise<void> {\n const texts = documents.map(({ pageContent }) => pageContent);\n return this.addVectors(\n await this.embeddings.embedDocuments(texts),\n documents\n );\n }\n\n /**\n * Method to add vectors to the memory vector store. It creates\n * `MemoryVector` instances for each vector and document pair and adds\n * them to the store.\n * @param vectors Array of vectors to be added to the store.\n * @param documents Array of `Document` instances corresponding to the vectors.\n * @returns Promise that resolves when all vectors have been added.\n */\n async addVectors(vectors: number[][], documents: Document[]): Promise<void> {\n const memoryVectors = vectors.map((embedding, idx) => ({\n content: documents[idx].pageContent,\n embedding,\n metadata: documents[idx].metadata,\n }));\n\n this.memoryVectors = this.memoryVectors.concat(memoryVectors);\n }\n\n /**\n * Method to perform a similarity search in the memory vector store. It\n * calculates the similarity between the query vector and each vector in\n * the store, sorts the results by similarity, and returns the top `k`\n * results along with their scores.\n * @param query Query vector to compare against the vectors in the store.\n * @param k Number of top results to return.\n * @param filter Optional filter function to apply to the vectors before performing the search.\n * @returns Promise that resolves with an array of tuples, each containing a `Document` and its similarity score.\n */\n async similaritySearchVectorWithScore(\n query: number[],\n k: number,\n filter?: this[\"FilterType\"]\n ): Promise<[Document, number][]> {\n const filterFunction = (memoryVector: MemoryVector) => {\n if (!filter) {\n return true;\n }\n\n const doc = new Document({\n metadata: memoryVector.metadata,\n pageContent: memoryVector.content,\n });\n return filter(doc);\n };\n const filteredMemoryVectors = this.memoryVectors.filter(filterFunction);\n const searches = filteredMemoryVectors\n .map((vector, index) => ({\n similarity: this.similarity(query, vector.embedding),\n index,\n }))\n .sort((a, b) => (a.similarity > b.similarity ? -1 : 0))\n .slice(0, k);\n\n const result: [Document, number][] = searches.map((search) => [\n new Document({\n metadata: filteredMemoryVectors[search.index].metadata,\n pageContent: filteredMemoryVectors[search.index].content,\n }),\n search.similarity,\n ]);\n\n return result;\n }\n\n /**\n * Static method to create a `FakeVectorStore` instance from an array of\n * texts. It creates a `Document` for each text and metadata pair, and\n * adds them to the store.\n * @param texts Array of texts to be added to the store.\n * @param metadatas Array or single object of metadata corresponding to the texts.\n * @param embeddings `Embeddings` instance used to generate embeddings for the texts.\n * @param dbConfig Optional `FakeVectorStoreArgs` to configure the `FakeVectorStore` instance.\n * @returns Promise that resolves with a new `FakeVectorStore` instance.\n */\n static async fromTexts(\n texts: string[],\n metadatas: object[] | object,\n embeddings: EmbeddingsInterface,\n dbConfig?: FakeVectorStoreArgs\n ): Promise<FakeVectorStore> {\n const docs: Document[] = [];\n for (let i = 0; i < texts.length; i += 1) {\n const metadata = Array.isArray(metadatas) ? metadatas[i] : metadatas;\n const newDoc = new Document({\n pageContent: texts[i],\n metadata,\n });\n docs.push(newDoc);\n }\n return FakeVectorStore.fromDocuments(docs, embeddings, dbConfig);\n }\n\n /**\n * Static method to create a `FakeVectorStore` instance from an array of\n * `Document` instances. It adds the documents to the store.\n * @param docs Array of `Document` instances to be added to the store.\n * @param embeddings `Embeddings` instance used to generate embeddings for the documents.\n * @param dbConfig Optional `FakeVectorStoreArgs` to configure the `FakeVectorStore` instance.\n * @returns Promise that resolves with a new `FakeVectorStore` instance.\n */\n static async fromDocuments(\n docs: Document[],\n embeddings: EmbeddingsInterface,\n dbConfig?: FakeVectorStoreArgs\n ): Promise<FakeVectorStore> {\n const instance = new this(embeddings, dbConfig);\n await instance.addDocuments(docs);\n return instance;\n }\n\n /**\n * Static method to create a `FakeVectorStore` instance from an existing\n * index. It creates a new `FakeVectorStore` instance without adding any\n * documents or vectors.\n * @param embeddings `Embeddings` instance used to generate embeddings for the documents.\n * @param dbConfig Optional `FakeVectorStoreArgs` to configure the `FakeVectorStore` instance.\n * @returns Promise that resolves with a new `FakeVectorStore` instance.\n */\n static async fromExistingIndex(\n embeddings: EmbeddingsInterface,\n dbConfig?: FakeVectorStoreArgs\n ): Promise<FakeVectorStore> {\n const instance = new this(embeddings, dbConfig);\n return instance;\n }\n}\n"],"mappings":";;;;;;;;;;AA+BA,IAAa,kBAAb,MAAa,wBAAwB,YAAY;CAG/C,gBAAgC,CAAE;CAElC;CAEA,mBAA2B;AACzB,SAAO;CACR;CAED,YACEA,YACA,EAAE,WAAY,GAAG,MAA2B,GAAG,CAAE,GACjD;EACA,MAAM,YAAY,KAAK;EAEvB,KAAK,aAAa,cAAc;CACjC;;;;;;;;CASD,MAAM,aAAaC,WAAsC;EACvD,MAAM,QAAQ,UAAU,IAAI,CAAC,EAAE,aAAa,KAAK,YAAY;AAC7D,SAAO,KAAK,WACV,MAAM,KAAK,WAAW,eAAe,MAAM,EAC3C,UACD;CACF;;;;;;;;;CAUD,MAAM,WAAWC,SAAqBD,WAAsC;EAC1E,MAAM,gBAAgB,QAAQ,IAAI,CAAC,WAAW,SAAS;GACrD,SAAS,UAAU,KAAK;GACxB;GACA,UAAU,UAAU,KAAK;EAC1B,GAAE;EAEH,KAAK,gBAAgB,KAAK,cAAc,OAAO,cAAc;CAC9D;;;;;;;;;;;CAYD,MAAM,gCACJE,OACAC,GACAC,QAC+B;EAC/B,MAAM,iBAAiB,CAACC,iBAA+B;AACrD,OAAI,CAAC,OACH,QAAO;GAGT,MAAM,MAAM,IAAI,SAAS;IACvB,UAAU,aAAa;IACvB,aAAa,aAAa;GAC3B;AACD,UAAO,OAAO,IAAI;EACnB;EACD,MAAM,wBAAwB,KAAK,cAAc,OAAO,eAAe;EACvE,MAAM,WAAW,sBACd,IAAI,CAAC,QAAQ,WAAW;GACvB,YAAY,KAAK,WAAW,OAAO,OAAO,UAAU;GACpD;EACD,GAAE,CACF,KAAK,CAAC,GAAG,MAAO,EAAE,aAAa,EAAE,aAAa,KAAK,EAAG,CACtD,MAAM,GAAG,EAAE;EAEd,MAAMC,SAA+B,SAAS,IAAI,CAAC,WAAW,CAC5D,IAAI,SAAS;GACX,UAAU,sBAAsB,OAAO,OAAO;GAC9C,aAAa,sBAAsB,OAAO,OAAO;EAClD,IACD,OAAO,UACR,EAAC;AAEF,SAAO;CACR;;;;;;;;;;;CAYD,aAAa,UACXC,OACAC,WACAT,YACAU,UAC0B;EAC1B,MAAMC,OAAmB,CAAE;AAC3B,OAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK,GAAG;GACxC,MAAM,WAAW,MAAM,QAAQ,UAAU,GAAG,UAAU,KAAK;GAC3D,MAAM,SAAS,IAAI,SAAS;IAC1B,aAAa,MAAM;IACnB;GACD;GACD,KAAK,KAAK,OAAO;EAClB;AACD,SAAO,gBAAgB,cAAc,MAAM,YAAY,SAAS;CACjE;;;;;;;;;CAUD,aAAa,cACXA,MACAX,YACAU,UAC0B;EAC1B,MAAM,WAAW,IAAI,KAAK,YAAY;EACtC,MAAM,SAAS,aAAa,KAAK;AACjC,SAAO;CACR;;;;;;;;;CAUD,aAAa,kBACXV,YACAU,UAC0B;EAC1B,MAAM,WAAW,IAAI,KAAK,YAAY;AACtC,SAAO;CACR;AACF"}
@@ -0,0 +1,40 @@
1
+
2
+ //#region src/utils/zod-to-json-schema/Options.ts
3
+ const ignoreOverride = Symbol("Let zodToJsonSchema decide on which parser to use");
4
+ const defaultOptions = {
5
+ name: void 0,
6
+ $refStrategy: "root",
7
+ basePath: ["#"],
8
+ effectStrategy: "input",
9
+ pipeStrategy: "all",
10
+ dateStrategy: "format:date-time",
11
+ mapStrategy: "entries",
12
+ removeAdditionalStrategy: "passthrough",
13
+ allowedAdditionalProperties: true,
14
+ rejectedAdditionalProperties: false,
15
+ definitionPath: "definitions",
16
+ target: "jsonSchema7",
17
+ strictUnions: false,
18
+ definitions: {},
19
+ errorMessages: false,
20
+ markdownDescription: false,
21
+ patternStrategy: "escape",
22
+ applyRegexFlags: false,
23
+ emailStrategy: "format:email",
24
+ base64Strategy: "contentEncoding:base64",
25
+ nameStrategy: "ref",
26
+ openAiAnyTypeName: "OpenAiAnyType"
27
+ };
28
+ const getDefaultOptions = (options) => typeof options === "string" ? {
29
+ ...defaultOptions,
30
+ name: options
31
+ } : {
32
+ ...defaultOptions,
33
+ ...options
34
+ };
35
+
36
+ //#endregion
37
+ exports.defaultOptions = defaultOptions;
38
+ exports.getDefaultOptions = getDefaultOptions;
39
+ exports.ignoreOverride = ignoreOverride;
40
+ //# sourceMappingURL=Options.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Options.cjs","names":["defaultOptions: Options","options: Partial<Options<Target>> | string | undefined"],"sources":["../../../src/utils/zod-to-json-schema/Options.ts"],"sourcesContent":["import { ZodSchema, ZodTypeDef } from \"zod/v3\";\nimport { Refs, Seen } from \"./Refs\";\nimport { JsonSchema7Type } from \"./parseTypes\";\n\nexport type Targets =\n | \"jsonSchema7\"\n | \"jsonSchema2019-09\"\n | \"openApi3\"\n | \"openAi\";\n\nexport type DateStrategy =\n | \"format:date-time\"\n | \"format:date\"\n | \"string\"\n | \"integer\";\n\nexport const ignoreOverride = Symbol(\n \"Let zodToJsonSchema decide on which parser to use\"\n);\n\nexport type OverrideCallback = (\n def: ZodTypeDef,\n refs: Refs,\n seen: Seen | undefined,\n forceResolution?: boolean\n) => JsonSchema7Type | undefined | typeof ignoreOverride;\n\nexport type PostProcessCallback = (\n jsonSchema: JsonSchema7Type | undefined,\n def: ZodTypeDef,\n refs: Refs\n) => JsonSchema7Type | undefined;\n\nexport const jsonDescription: PostProcessCallback = (jsonSchema, def) => {\n if (def.description) {\n try {\n return {\n ...jsonSchema,\n ...JSON.parse(def.description),\n };\n } catch {}\n }\n\n return jsonSchema;\n};\n\nexport type Options<Target extends Targets = \"jsonSchema7\"> = {\n name: string | undefined;\n $refStrategy: \"root\" | \"relative\" | \"none\" | \"seen\";\n basePath: string[];\n effectStrategy: \"input\" | \"any\";\n pipeStrategy: \"input\" | \"output\" | \"all\";\n dateStrategy: DateStrategy | DateStrategy[];\n mapStrategy: \"entries\" | \"record\";\n removeAdditionalStrategy: \"passthrough\" | \"strict\";\n allowedAdditionalProperties: true | undefined;\n rejectedAdditionalProperties: false | undefined;\n target: Target;\n strictUnions: boolean;\n definitionPath: string;\n definitions: Record<string, ZodSchema>;\n errorMessages: boolean;\n markdownDescription: boolean;\n patternStrategy: \"escape\" | \"preserve\";\n applyRegexFlags: boolean;\n emailStrategy: \"format:email\" | \"format:idn-email\" | \"pattern:zod\";\n base64Strategy: \"format:binary\" | \"contentEncoding:base64\" | \"pattern:zod\";\n nameStrategy: \"ref\" | \"title\";\n override?: OverrideCallback;\n postProcess?: PostProcessCallback;\n openAiAnyTypeName: string;\n};\n\nexport const defaultOptions: Options = {\n name: undefined,\n $refStrategy: \"root\",\n basePath: [\"#\"],\n effectStrategy: \"input\",\n pipeStrategy: \"all\",\n dateStrategy: \"format:date-time\",\n mapStrategy: \"entries\",\n removeAdditionalStrategy: \"passthrough\",\n allowedAdditionalProperties: true,\n rejectedAdditionalProperties: false,\n definitionPath: \"definitions\",\n target: \"jsonSchema7\",\n strictUnions: false,\n definitions: {},\n errorMessages: false,\n markdownDescription: false,\n patternStrategy: \"escape\",\n applyRegexFlags: false,\n emailStrategy: \"format:email\",\n base64Strategy: \"contentEncoding:base64\",\n nameStrategy: \"ref\",\n openAiAnyTypeName: \"OpenAiAnyType\",\n};\n\nexport const getDefaultOptions = <Target extends Targets>(\n options: Partial<Options<Target>> | string | undefined\n) =>\n (typeof options === \"string\"\n ? {\n ...defaultOptions,\n name: options,\n }\n : {\n ...defaultOptions,\n ...options,\n }) as Options<Target>;\n"],"mappings":";;AAgBA,MAAa,iBAAiB,OAC5B,oDACD;AAuDD,MAAaA,iBAA0B;CACrC,MAAM;CACN,cAAc;CACd,UAAU,CAAC,GAAI;CACf,gBAAgB;CAChB,cAAc;CACd,cAAc;CACd,aAAa;CACb,0BAA0B;CAC1B,6BAA6B;CAC7B,8BAA8B;CAC9B,gBAAgB;CAChB,QAAQ;CACR,cAAc;CACd,aAAa,CAAE;CACf,eAAe;CACf,qBAAqB;CACrB,iBAAiB;CACjB,iBAAiB;CACjB,eAAe;CACf,gBAAgB;CAChB,cAAc;CACd,mBAAmB;AACpB;AAED,MAAa,oBAAoB,CAC/BC,YAEC,OAAO,YAAY,WAChB;CACE,GAAG;CACH,MAAM;AACP,IACD;CACE,GAAG;CACH,GAAG;AACJ"}
@@ -0,0 +1,37 @@
1
+ //#region src/utils/zod-to-json-schema/Options.ts
2
+ const ignoreOverride = Symbol("Let zodToJsonSchema decide on which parser to use");
3
+ const defaultOptions = {
4
+ name: void 0,
5
+ $refStrategy: "root",
6
+ basePath: ["#"],
7
+ effectStrategy: "input",
8
+ pipeStrategy: "all",
9
+ dateStrategy: "format:date-time",
10
+ mapStrategy: "entries",
11
+ removeAdditionalStrategy: "passthrough",
12
+ allowedAdditionalProperties: true,
13
+ rejectedAdditionalProperties: false,
14
+ definitionPath: "definitions",
15
+ target: "jsonSchema7",
16
+ strictUnions: false,
17
+ definitions: {},
18
+ errorMessages: false,
19
+ markdownDescription: false,
20
+ patternStrategy: "escape",
21
+ applyRegexFlags: false,
22
+ emailStrategy: "format:email",
23
+ base64Strategy: "contentEncoding:base64",
24
+ nameStrategy: "ref",
25
+ openAiAnyTypeName: "OpenAiAnyType"
26
+ };
27
+ const getDefaultOptions = (options) => typeof options === "string" ? {
28
+ ...defaultOptions,
29
+ name: options
30
+ } : {
31
+ ...defaultOptions,
32
+ ...options
33
+ };
34
+
35
+ //#endregion
36
+ export { defaultOptions, getDefaultOptions, ignoreOverride };
37
+ //# sourceMappingURL=Options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Options.js","names":["defaultOptions: Options","options: Partial<Options<Target>> | string | undefined"],"sources":["../../../src/utils/zod-to-json-schema/Options.ts"],"sourcesContent":["import { ZodSchema, ZodTypeDef } from \"zod/v3\";\nimport { Refs, Seen } from \"./Refs\";\nimport { JsonSchema7Type } from \"./parseTypes\";\n\nexport type Targets =\n | \"jsonSchema7\"\n | \"jsonSchema2019-09\"\n | \"openApi3\"\n | \"openAi\";\n\nexport type DateStrategy =\n | \"format:date-time\"\n | \"format:date\"\n | \"string\"\n | \"integer\";\n\nexport const ignoreOverride = Symbol(\n \"Let zodToJsonSchema decide on which parser to use\"\n);\n\nexport type OverrideCallback = (\n def: ZodTypeDef,\n refs: Refs,\n seen: Seen | undefined,\n forceResolution?: boolean\n) => JsonSchema7Type | undefined | typeof ignoreOverride;\n\nexport type PostProcessCallback = (\n jsonSchema: JsonSchema7Type | undefined,\n def: ZodTypeDef,\n refs: Refs\n) => JsonSchema7Type | undefined;\n\nexport const jsonDescription: PostProcessCallback = (jsonSchema, def) => {\n if (def.description) {\n try {\n return {\n ...jsonSchema,\n ...JSON.parse(def.description),\n };\n } catch {}\n }\n\n return jsonSchema;\n};\n\nexport type Options<Target extends Targets = \"jsonSchema7\"> = {\n name: string | undefined;\n $refStrategy: \"root\" | \"relative\" | \"none\" | \"seen\";\n basePath: string[];\n effectStrategy: \"input\" | \"any\";\n pipeStrategy: \"input\" | \"output\" | \"all\";\n dateStrategy: DateStrategy | DateStrategy[];\n mapStrategy: \"entries\" | \"record\";\n removeAdditionalStrategy: \"passthrough\" | \"strict\";\n allowedAdditionalProperties: true | undefined;\n rejectedAdditionalProperties: false | undefined;\n target: Target;\n strictUnions: boolean;\n definitionPath: string;\n definitions: Record<string, ZodSchema>;\n errorMessages: boolean;\n markdownDescription: boolean;\n patternStrategy: \"escape\" | \"preserve\";\n applyRegexFlags: boolean;\n emailStrategy: \"format:email\" | \"format:idn-email\" | \"pattern:zod\";\n base64Strategy: \"format:binary\" | \"contentEncoding:base64\" | \"pattern:zod\";\n nameStrategy: \"ref\" | \"title\";\n override?: OverrideCallback;\n postProcess?: PostProcessCallback;\n openAiAnyTypeName: string;\n};\n\nexport const defaultOptions: Options = {\n name: undefined,\n $refStrategy: \"root\",\n basePath: [\"#\"],\n effectStrategy: \"input\",\n pipeStrategy: \"all\",\n dateStrategy: \"format:date-time\",\n mapStrategy: \"entries\",\n removeAdditionalStrategy: \"passthrough\",\n allowedAdditionalProperties: true,\n rejectedAdditionalProperties: false,\n definitionPath: \"definitions\",\n target: \"jsonSchema7\",\n strictUnions: false,\n definitions: {},\n errorMessages: false,\n markdownDescription: false,\n patternStrategy: \"escape\",\n applyRegexFlags: false,\n emailStrategy: \"format:email\",\n base64Strategy: \"contentEncoding:base64\",\n nameStrategy: \"ref\",\n openAiAnyTypeName: \"OpenAiAnyType\",\n};\n\nexport const getDefaultOptions = <Target extends Targets>(\n options: Partial<Options<Target>> | string | undefined\n) =>\n (typeof options === \"string\"\n ? {\n ...defaultOptions,\n name: options,\n }\n : {\n ...defaultOptions,\n ...options,\n }) as Options<Target>;\n"],"mappings":";AAgBA,MAAa,iBAAiB,OAC5B,oDACD;AAuDD,MAAaA,iBAA0B;CACrC,MAAM;CACN,cAAc;CACd,UAAU,CAAC,GAAI;CACf,gBAAgB;CAChB,cAAc;CACd,cAAc;CACd,aAAa;CACb,0BAA0B;CAC1B,6BAA6B;CAC7B,8BAA8B;CAC9B,gBAAgB;CAChB,QAAQ;CACR,cAAc;CACd,aAAa,CAAE;CACf,eAAe;CACf,qBAAqB;CACrB,iBAAiB;CACjB,iBAAiB;CACjB,eAAe;CACf,gBAAgB;CAChB,cAAc;CACd,mBAAmB;AACpB;AAED,MAAa,oBAAoB,CAC/BC,YAEC,OAAO,YAAY,WAChB;CACE,GAAG;CACH,MAAM;AACP,IACD;CACE,GAAG;CACH,GAAG;AACJ"}
@@ -0,0 +1,30 @@
1
+ const require_Options = require('./Options.cjs');
2
+
3
+ //#region src/utils/zod-to-json-schema/Refs.ts
4
+ const getRefs = (options) => {
5
+ const _options = require_Options.getDefaultOptions(options);
6
+ const currentPath = _options.name !== void 0 ? [
7
+ ..._options.basePath,
8
+ _options.definitionPath,
9
+ _options.name
10
+ ] : _options.basePath;
11
+ return {
12
+ ..._options,
13
+ flags: { hasReferencedOpenAiAnyType: false },
14
+ currentPath,
15
+ propertyPath: void 0,
16
+ seen: new Map(Object.entries(_options.definitions).map(([name, def]) => [def._def, {
17
+ def: def._def,
18
+ path: [
19
+ ..._options.basePath,
20
+ _options.definitionPath,
21
+ name
22
+ ],
23
+ jsonSchema: void 0
24
+ }]))
25
+ };
26
+ };
27
+
28
+ //#endregion
29
+ exports.getRefs = getRefs;
30
+ //# sourceMappingURL=Refs.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Refs.cjs","names":["options?: string | Partial<Options<Targets>>","getDefaultOptions"],"sources":["../../../src/utils/zod-to-json-schema/Refs.ts"],"sourcesContent":["import { ZodTypeDef } from \"zod/v3\";\nimport { getDefaultOptions, Options, Targets } from \"./Options.js\";\nimport { JsonSchema7Type } from \"./parseTypes.js\";\n\nexport type Refs = {\n seen: Map<ZodTypeDef, Seen>;\n currentPath: string[];\n propertyPath: string[] | undefined;\n flags: { hasReferencedOpenAiAnyType: boolean };\n} & Options<Targets>;\n\nexport type Seen = {\n def: ZodTypeDef;\n path: string[];\n jsonSchema: JsonSchema7Type | undefined;\n};\n\nexport const getRefs = (options?: string | Partial<Options<Targets>>): Refs => {\n const _options = getDefaultOptions(options);\n const currentPath =\n _options.name !== undefined\n ? [..._options.basePath, _options.definitionPath, _options.name]\n : _options.basePath;\n return {\n ..._options,\n flags: { hasReferencedOpenAiAnyType: false },\n currentPath: currentPath,\n propertyPath: undefined,\n seen: new Map(\n Object.entries(_options.definitions).map(([name, def]) => [\n def._def,\n {\n def: def._def,\n path: [..._options.basePath, _options.definitionPath, name],\n // Resolution of references will be forced even though seen, so it's ok that the schema is undefined here for now.\n jsonSchema: undefined,\n },\n ])\n ),\n };\n};\n"],"mappings":";;;AAiBA,MAAa,UAAU,CAACA,YAAuD;CAC7E,MAAM,WAAWC,kCAAkB,QAAQ;CAC3C,MAAM,cACJ,SAAS,SAAS,SACd;EAAC,GAAG,SAAS;EAAU,SAAS;EAAgB,SAAS;CAAK,IAC9D,SAAS;AACf,QAAO;EACL,GAAG;EACH,OAAO,EAAE,4BAA4B,MAAO;EAC/B;EACb,cAAc;EACd,MAAM,IAAI,IACR,OAAO,QAAQ,SAAS,YAAY,CAAC,IAAI,CAAC,CAAC,MAAM,IAAI,KAAK,CACxD,IAAI,MACJ;GACE,KAAK,IAAI;GACT,MAAM;IAAC,GAAG,SAAS;IAAU,SAAS;IAAgB;GAAK;GAE3D,YAAY;EACb,CACF,EAAC;CAEL;AACF"}
@@ -0,0 +1,30 @@
1
+ import { getDefaultOptions } from "./Options.js";
2
+
3
+ //#region src/utils/zod-to-json-schema/Refs.ts
4
+ const getRefs = (options) => {
5
+ const _options = getDefaultOptions(options);
6
+ const currentPath = _options.name !== void 0 ? [
7
+ ..._options.basePath,
8
+ _options.definitionPath,
9
+ _options.name
10
+ ] : _options.basePath;
11
+ return {
12
+ ..._options,
13
+ flags: { hasReferencedOpenAiAnyType: false },
14
+ currentPath,
15
+ propertyPath: void 0,
16
+ seen: new Map(Object.entries(_options.definitions).map(([name, def]) => [def._def, {
17
+ def: def._def,
18
+ path: [
19
+ ..._options.basePath,
20
+ _options.definitionPath,
21
+ name
22
+ ],
23
+ jsonSchema: void 0
24
+ }]))
25
+ };
26
+ };
27
+
28
+ //#endregion
29
+ export { getRefs };
30
+ //# sourceMappingURL=Refs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Refs.js","names":["options?: string | Partial<Options<Targets>>"],"sources":["../../../src/utils/zod-to-json-schema/Refs.ts"],"sourcesContent":["import { ZodTypeDef } from \"zod/v3\";\nimport { getDefaultOptions, Options, Targets } from \"./Options.js\";\nimport { JsonSchema7Type } from \"./parseTypes.js\";\n\nexport type Refs = {\n seen: Map<ZodTypeDef, Seen>;\n currentPath: string[];\n propertyPath: string[] | undefined;\n flags: { hasReferencedOpenAiAnyType: boolean };\n} & Options<Targets>;\n\nexport type Seen = {\n def: ZodTypeDef;\n path: string[];\n jsonSchema: JsonSchema7Type | undefined;\n};\n\nexport const getRefs = (options?: string | Partial<Options<Targets>>): Refs => {\n const _options = getDefaultOptions(options);\n const currentPath =\n _options.name !== undefined\n ? [..._options.basePath, _options.definitionPath, _options.name]\n : _options.basePath;\n return {\n ..._options,\n flags: { hasReferencedOpenAiAnyType: false },\n currentPath: currentPath,\n propertyPath: undefined,\n seen: new Map(\n Object.entries(_options.definitions).map(([name, def]) => [\n def._def,\n {\n def: def._def,\n path: [..._options.basePath, _options.definitionPath, name],\n // Resolution of references will be forced even though seen, so it's ok that the schema is undefined here for now.\n jsonSchema: undefined,\n },\n ])\n ),\n };\n};\n"],"mappings":";;;AAiBA,MAAa,UAAU,CAACA,YAAuD;CAC7E,MAAM,WAAW,kBAAkB,QAAQ;CAC3C,MAAM,cACJ,SAAS,SAAS,SACd;EAAC,GAAG,SAAS;EAAU,SAAS;EAAgB,SAAS;CAAK,IAC9D,SAAS;AACf,QAAO;EACL,GAAG;EACH,OAAO,EAAE,4BAA4B,MAAO;EAC/B;EACb,cAAc;EACd,MAAM,IAAI,IACR,OAAO,QAAQ,SAAS,YAAY,CAAC,IAAI,CAAC,CAAC,MAAM,IAAI,KAAK,CACxD,IAAI,MACJ;GACE,KAAK,IAAI;GACT,MAAM;IAAC,GAAG,SAAS;IAAU,SAAS;IAAgB;GAAK;GAE3D,YAAY;EACb,CACF,EAAC;CAEL;AACF"}
@@ -0,0 +1,18 @@
1
+
2
+ //#region src/utils/zod-to-json-schema/errorMessages.ts
3
+ function addErrorMessage(res, key, errorMessage, refs) {
4
+ if (!refs?.errorMessages) return;
5
+ if (errorMessage) res.errorMessage = {
6
+ ...res.errorMessage,
7
+ [key]: errorMessage
8
+ };
9
+ }
10
+ function setResponseValueAndErrors(res, key, value, errorMessage, refs) {
11
+ res[key] = value;
12
+ addErrorMessage(res, key, errorMessage, refs);
13
+ }
14
+
15
+ //#endregion
16
+ exports.addErrorMessage = addErrorMessage;
17
+ exports.setResponseValueAndErrors = setResponseValueAndErrors;
18
+ //# sourceMappingURL=errorMessages.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errorMessages.cjs","names":["res: T","key: keyof T","errorMessage: string | undefined","refs: Refs","res: Json7Type","key: Key","value: Json7Type[Key]"],"sources":["../../../src/utils/zod-to-json-schema/errorMessages.ts"],"sourcesContent":["import { JsonSchema7TypeUnion } from \"./parseTypes.js\";\nimport { Refs } from \"./Refs.js\";\n\nexport type ErrorMessages<\n T extends JsonSchema7TypeUnion | { format: string } | { pattern: string },\n OmitProperties extends string = \"\",\n> = Partial<\n Omit<{ [key in keyof T]: string }, OmitProperties | \"type\" | \"errorMessages\">\n>;\n\nexport function addErrorMessage<\n T extends { errorMessage?: ErrorMessages<any> },\n>(res: T, key: keyof T, errorMessage: string | undefined, refs: Refs) {\n if (!refs?.errorMessages) return;\n if (errorMessage) {\n res.errorMessage = {\n ...res.errorMessage,\n [key]: errorMessage,\n };\n }\n}\n\nexport function setResponseValueAndErrors<\n Json7Type extends JsonSchema7TypeUnion & {\n errorMessage?: ErrorMessages<Json7Type>;\n },\n Key extends keyof Omit<Json7Type, \"errorMessage\">,\n>(\n res: Json7Type,\n key: Key,\n value: Json7Type[Key],\n errorMessage: string | undefined,\n refs: Refs,\n) {\n res[key] = value;\n addErrorMessage(res, key, errorMessage, refs);\n}\n"],"mappings":";;AAUA,SAAgB,gBAEdA,KAAQC,KAAcC,cAAkCC,MAAY;AACpE,KAAI,CAAC,MAAM,cAAe;AAC1B,KAAI,cACF,IAAI,eAAe;EACjB,GAAG,IAAI;GACN,MAAM;CACR;AAEJ;AAED,SAAgB,0BAMdC,KACAC,KACAC,OACAJ,cACAC,MACA;CACA,IAAI,OAAO;CACX,gBAAgB,KAAK,KAAK,cAAc,KAAK;AAC9C"}
@@ -0,0 +1,11 @@
1
+ import { JsonSchema7TypeUnion } from "./parseTypes.cjs";
2
+
3
+ //#region src/utils/zod-to-json-schema/errorMessages.d.ts
4
+ type ErrorMessages<T extends JsonSchema7TypeUnion | {
5
+ format: string;
6
+ } | {
7
+ pattern: string;
8
+ }, OmitProperties extends string = ""> = Partial<Omit<{ [key in keyof T]: string }, OmitProperties | "type" | "errorMessages">>;
9
+ //#endregion
10
+ export { ErrorMessages };
11
+ //# sourceMappingURL=errorMessages.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errorMessages.d.cts","names":["JsonSchema7TypeUnion","Refs","ErrorMessages","T","OmitProperties","Omit","Partial","addErrorMessage","setResponseValueAndErrors","Json7Type","Key"],"sources":["../../../src/utils/zod-to-json-schema/errorMessages.d.ts"],"sourcesContent":["import { JsonSchema7TypeUnion } from \"./parseTypes.js\";\nimport { Refs } from \"./Refs.js\";\nexport type ErrorMessages<T extends JsonSchema7TypeUnion | {\n format: string;\n} | {\n pattern: string;\n}, OmitProperties extends string = \"\"> = Partial<Omit<{\n [key in keyof T]: string;\n}, OmitProperties | \"type\" | \"errorMessages\">>;\nexport declare function addErrorMessage<T extends {\n errorMessage?: ErrorMessages<any>;\n}>(res: T, key: keyof T, errorMessage: string | undefined, refs: Refs): void;\nexport declare function setResponseValueAndErrors<Json7Type extends JsonSchema7TypeUnion & {\n errorMessage?: ErrorMessages<Json7Type>;\n}, Key extends keyof Omit<Json7Type, \"errorMessage\">>(res: Json7Type, key: Key, value: Json7Type[Key], errorMessage: string | undefined, refs: Refs): void;\n"],"mappings":";;;KAEYE,wBAAwBF;EAAxBE,MAAAA,EAAAA,MAAAA;CAAa,GAAA;EAAA,OAAWF,EAAAA,MAAAA;CAAoB,EAAA,uBAKtCG,MAAAA,GAAAA,EAAAA,CAAAA,GADuBG,OACvBH,CAD+BE,IAC/BF,CAAAA,UACfC,MADeD,CACfC,GAAAA,MAAAA,EAAc,EAAdA,cAF8CC,GAAAA,MAAAA,GAAAA,eAAAA,CAAAA,CAAAA"}
@@ -0,0 +1,11 @@
1
+ import { JsonSchema7TypeUnion } from "./parseTypes.js";
2
+
3
+ //#region src/utils/zod-to-json-schema/errorMessages.d.ts
4
+ type ErrorMessages<T extends JsonSchema7TypeUnion | {
5
+ format: string;
6
+ } | {
7
+ pattern: string;
8
+ }, OmitProperties extends string = ""> = Partial<Omit<{ [key in keyof T]: string }, OmitProperties | "type" | "errorMessages">>;
9
+ //#endregion
10
+ export { ErrorMessages };
11
+ //# sourceMappingURL=errorMessages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errorMessages.d.ts","names":["JsonSchema7TypeUnion","Refs","ErrorMessages","T","OmitProperties","Omit","Partial","addErrorMessage","setResponseValueAndErrors","Json7Type","Key"],"sources":["../../../src/utils/zod-to-json-schema/errorMessages.d.ts"],"sourcesContent":["import { JsonSchema7TypeUnion } from \"./parseTypes.js\";\nimport { Refs } from \"./Refs.js\";\nexport type ErrorMessages<T extends JsonSchema7TypeUnion | {\n format: string;\n} | {\n pattern: string;\n}, OmitProperties extends string = \"\"> = Partial<Omit<{\n [key in keyof T]: string;\n}, OmitProperties | \"type\" | \"errorMessages\">>;\nexport declare function addErrorMessage<T extends {\n errorMessage?: ErrorMessages<any>;\n}>(res: T, key: keyof T, errorMessage: string | undefined, refs: Refs): void;\nexport declare function setResponseValueAndErrors<Json7Type extends JsonSchema7TypeUnion & {\n errorMessage?: ErrorMessages<Json7Type>;\n}, Key extends keyof Omit<Json7Type, \"errorMessage\">>(res: Json7Type, key: Key, value: Json7Type[Key], errorMessage: string | undefined, refs: Refs): void;\n"],"mappings":";;;KAEYE,wBAAwBF;EAAxBE,MAAAA,EAAAA,MAAAA;CAAa,GAAA;EAAA,OAAWF,EAAAA,MAAAA;CAAoB,EAAA,uBAKtCG,MAAAA,GAAAA,EAAAA,CAAAA,GADuBG,OACvBH,CAD+BE,IAC/BF,CAAAA,UACfC,MADeD,CACfC,GAAAA,MAAAA,EAAc,EAAdA,cAF8CC,GAAAA,MAAAA,GAAAA,eAAAA,CAAAA,CAAAA"}