@valkey/valkey-glide-darwin-arm64 1.2.0 → 1.2.1-rc1

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 (439) hide show
  1. package/build-ts/src/BaseClient.d.ts +27 -1
  2. package/build-ts/src/BaseClient.js +9 -1
  3. package/build-ts/src/BaseClient.js.map +1 -1
  4. package/build-ts/src/Commands.d.ts +12 -0
  5. package/build-ts/src/Commands.js.map +1 -1
  6. package/build-ts/src/GlideClient.d.ts +17 -1
  7. package/build-ts/src/GlideClient.js +3 -0
  8. package/build-ts/src/GlideClient.js.map +1 -1
  9. package/build-ts/src/GlideClusterClient.d.ts +23 -7
  10. package/build-ts/src/GlideClusterClient.js +8 -3
  11. package/build-ts/src/GlideClusterClient.js.map +1 -1
  12. package/build-ts/src/ProtobufMessage.js +46 -1
  13. package/build-ts/src/ProtobufMessage.js.map +1 -1
  14. package/node_modules/glide-rs/glide-rs.darwin-arm64.node +0 -0
  15. package/node_modules/glide-rs/index.d.ts +2 -1
  16. package/node_modules/glide-rs/index.js +4 -2
  17. package/npm/glide/index.ts +4 -3
  18. package/npm/glide/package.json +0 -1
  19. package/package.json +2 -2
  20. package/rust-client/node_modules/mingo/README.md +58 -53
  21. package/rust-client/node_modules/mingo/dist/cjs/aggregator.js +18 -20
  22. package/rust-client/node_modules/mingo/dist/cjs/core.js +179 -190
  23. package/rust-client/node_modules/mingo/dist/cjs/cursor.js +34 -34
  24. package/rust-client/node_modules/mingo/dist/cjs/index.js +11 -3
  25. package/rust-client/node_modules/mingo/dist/cjs/init/basic.js +4 -22
  26. package/rust-client/node_modules/mingo/dist/cjs/init/system.js +6 -6
  27. package/rust-client/node_modules/mingo/dist/cjs/lazy.js +58 -61
  28. package/rust-client/node_modules/mingo/dist/cjs/operators/_predicates.js +12 -25
  29. package/rust-client/node_modules/mingo/dist/cjs/operators/accumulator/_internal.js +2 -4
  30. package/rust-client/node_modules/mingo/dist/cjs/operators/accumulator/accumulator.js +1 -2
  31. package/rust-client/node_modules/mingo/dist/cjs/operators/accumulator/first.js +3 -1
  32. package/rust-client/node_modules/mingo/dist/cjs/operators/accumulator/last.js +4 -1
  33. package/rust-client/node_modules/mingo/dist/cjs/operators/accumulator/max.js +9 -6
  34. package/rust-client/node_modules/mingo/dist/cjs/operators/accumulator/mergeObjects.js +5 -1
  35. package/rust-client/node_modules/mingo/dist/cjs/operators/accumulator/min.js +9 -3
  36. package/rust-client/node_modules/mingo/dist/cjs/operators/accumulator/push.js +1 -2
  37. package/rust-client/node_modules/mingo/dist/cjs/operators/accumulator/sum.js +2 -4
  38. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/arithmetic/add.js +9 -10
  39. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/arithmetic/ceil.js +1 -2
  40. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/arithmetic/exp.js +1 -2
  41. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/arithmetic/floor.js +1 -2
  42. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/arithmetic/ln.js +1 -2
  43. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/arithmetic/log.js +1 -2
  44. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/arithmetic/log10.js +1 -2
  45. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/arithmetic/round.js +1 -2
  46. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/arithmetic/sqrt.js +1 -2
  47. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/arithmetic/subtract.js +5 -2
  48. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/arithmetic/trunc.js +1 -2
  49. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/arrayElemAt.js +2 -3
  50. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/arrayToObject.js +3 -4
  51. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/concatArrays.js +11 -5
  52. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/filter.js +1 -0
  53. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/first.js +8 -8
  54. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/firstN.js +2 -4
  55. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/in.js +1 -1
  56. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/indexOfArray.js +5 -10
  57. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/isArray.js +2 -3
  58. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/last.js +8 -8
  59. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/lastN.js +2 -4
  60. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/map.js +1 -0
  61. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/maxN.js +2 -4
  62. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/minN.js +2 -4
  63. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/reduce.js +1 -2
  64. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/reverseArray.js +1 -2
  65. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/sortArray.js +2 -4
  66. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/zip.js +4 -10
  67. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/bitwise/_internal.js +1 -2
  68. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/bitwise/bitNot.js +2 -4
  69. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/boolean/not.js +3 -5
  70. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/comparison/cmp.js +6 -5
  71. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/conditional/cond.js +1 -1
  72. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/conditional/ifNull.js +1 -1
  73. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/conditional/switch.js +1 -2
  74. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/date/_internal.js +157 -65
  75. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/date/dateAdd.js +1 -29
  76. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/date/dateDiff.js +32 -20
  77. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/date/dateFromParts.js +2 -4
  78. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/date/dateFromString.js +13 -9
  79. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/date/dateToString.js +2 -4
  80. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/date/dateTrunc.js +107 -0
  81. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/date/dayOfYear.js +1 -1
  82. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/date/index.js +2 -0
  83. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/date/isoWeekYear.js +1 -4
  84. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/date/week.js +1 -2
  85. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/misc/getField.js +1 -2
  86. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/object/mergeObjects.js +9 -2
  87. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/object/objectToArray.js +5 -1
  88. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/object/setField.js +11 -7
  89. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/set/setDifference.js +9 -1
  90. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/set/setEquals.js +17 -3
  91. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/set/setIntersection.js +2 -1
  92. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/set/setIsSubset.js +15 -1
  93. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/set/setUnion.js +4 -5
  94. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/string/_internal.js +4 -8
  95. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/string/concat.js +5 -2
  96. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/string/indexOfBytes.js +2 -4
  97. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/string/replaceAll.js +1 -2
  98. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/string/replaceOne.js +1 -2
  99. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/string/split.js +1 -2
  100. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/string/strcasecmp.js +1 -2
  101. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/string/substr.js +4 -14
  102. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/string/substrBytes.js +2 -4
  103. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/trignometry/atan2.js +2 -4
  104. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/trignometry/cosh.js +0 -1
  105. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/type/_internal.js +20 -10
  106. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/type/convert.js +3 -5
  107. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/type/toBool.js +2 -4
  108. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/type/toDate.js +3 -6
  109. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/type/toDouble.js +5 -10
  110. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/type/toInt.js +1 -4
  111. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/type/toLong.js +1 -4
  112. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/type/toString.js +11 -10
  113. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/type/type.js +11 -14
  114. package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/addFields.js +1 -2
  115. package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/bucket.js +53 -53
  116. package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/bucketAuto.js +670 -65
  117. package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/count.js +2 -2
  118. package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/densify.js +196 -0
  119. package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/graphLookup.js +78 -0
  120. package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/group.js +6 -9
  121. package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/index.js +4 -0
  122. package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/limit.js +1 -3
  123. package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/lookup.js +47 -10
  124. package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/merge.js +7 -13
  125. package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/out.js +1 -1
  126. package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/project.js +19 -38
  127. package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/redact.js +3 -1
  128. package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/replaceWith.js +9 -2
  129. package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/sample.js +1 -2
  130. package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/setWindowFields.js +10 -20
  131. package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/skip.js +1 -1
  132. package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/sort.js +10 -19
  133. package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/sortByCount.js +5 -3
  134. package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/unionWith.js +1 -1
  135. package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/unset.js +1 -2
  136. package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/unwind.js +5 -9
  137. package/rust-client/node_modules/mingo/dist/cjs/operators/projection/elemMatch.js +2 -3
  138. package/rust-client/node_modules/mingo/dist/cjs/operators/projection/slice.js +2 -3
  139. package/rust-client/node_modules/mingo/dist/cjs/operators/query/bitwise/_internal.js +4 -4
  140. package/rust-client/node_modules/mingo/dist/cjs/operators/update/_internal.js +8 -14
  141. package/rust-client/node_modules/mingo/dist/cjs/operators/update/addToSet.js +1 -2
  142. package/rust-client/node_modules/mingo/dist/cjs/operators/update/bit.js +1 -2
  143. package/rust-client/node_modules/mingo/dist/cjs/operators/update/max.js +1 -2
  144. package/rust-client/node_modules/mingo/dist/cjs/operators/update/min.js +1 -2
  145. package/rust-client/node_modules/mingo/dist/cjs/operators/update/pop.js +1 -2
  146. package/rust-client/node_modules/mingo/dist/cjs/operators/update/pull.js +2 -4
  147. package/rust-client/node_modules/mingo/dist/cjs/operators/update/push.js +3 -9
  148. package/rust-client/node_modules/mingo/dist/cjs/operators/update/rename.js +1 -2
  149. package/rust-client/node_modules/mingo/dist/cjs/operators/update/set.js +1 -2
  150. package/rust-client/node_modules/mingo/dist/cjs/operators/update/unset.js +1 -2
  151. package/rust-client/node_modules/mingo/dist/cjs/operators/window/_internal.js +2 -3
  152. package/rust-client/node_modules/mingo/dist/cjs/operators/window/denseRank.js +8 -10
  153. package/rust-client/node_modules/mingo/dist/cjs/operators/window/derivative.js +4 -6
  154. package/rust-client/node_modules/mingo/dist/cjs/operators/window/documentNumber.js +1 -3
  155. package/rust-client/node_modules/mingo/dist/cjs/operators/window/expMovingAvg.js +4 -6
  156. package/rust-client/node_modules/mingo/dist/cjs/operators/window/integral.js +3 -4
  157. package/rust-client/node_modules/mingo/dist/cjs/operators/window/linearFill.js +4 -6
  158. package/rust-client/node_modules/mingo/dist/cjs/operators/window/locf.js +3 -4
  159. package/rust-client/node_modules/mingo/dist/cjs/operators/window/rank.js +8 -10
  160. package/rust-client/node_modules/mingo/dist/cjs/operators/window/shift.js +2 -2
  161. package/rust-client/node_modules/mingo/dist/cjs/query.js +20 -19
  162. package/rust-client/node_modules/mingo/dist/cjs/types.js +22 -0
  163. package/rust-client/node_modules/mingo/dist/cjs/updater.js +6 -5
  164. package/rust-client/node_modules/mingo/dist/cjs/util.js +265 -388
  165. package/rust-client/node_modules/mingo/dist/esm/aggregator.js +18 -21
  166. package/rust-client/node_modules/mingo/dist/esm/core.js +179 -192
  167. package/rust-client/node_modules/mingo/dist/esm/cursor.js +35 -35
  168. package/rust-client/node_modules/mingo/dist/esm/index.js +8 -2
  169. package/rust-client/node_modules/mingo/dist/esm/init/basic.js +5 -12
  170. package/rust-client/node_modules/mingo/dist/esm/init/system.js +7 -7
  171. package/rust-client/node_modules/mingo/dist/esm/lazy.js +58 -61
  172. package/rust-client/node_modules/mingo/dist/esm/operators/_predicates.js +14 -32
  173. package/rust-client/node_modules/mingo/dist/esm/operators/accumulator/_internal.js +2 -4
  174. package/rust-client/node_modules/mingo/dist/esm/operators/accumulator/accumulator.js +1 -2
  175. package/rust-client/node_modules/mingo/dist/esm/operators/accumulator/first.js +7 -2
  176. package/rust-client/node_modules/mingo/dist/esm/operators/accumulator/last.js +8 -2
  177. package/rust-client/node_modules/mingo/dist/esm/operators/accumulator/max.js +10 -7
  178. package/rust-client/node_modules/mingo/dist/esm/operators/accumulator/mergeObjects.js +5 -1
  179. package/rust-client/node_modules/mingo/dist/esm/operators/accumulator/min.js +10 -4
  180. package/rust-client/node_modules/mingo/dist/esm/operators/accumulator/push.js +1 -2
  181. package/rust-client/node_modules/mingo/dist/esm/operators/accumulator/sum.js +2 -4
  182. package/rust-client/node_modules/mingo/dist/esm/operators/expression/arithmetic/add.js +9 -10
  183. package/rust-client/node_modules/mingo/dist/esm/operators/expression/arithmetic/ceil.js +1 -2
  184. package/rust-client/node_modules/mingo/dist/esm/operators/expression/arithmetic/exp.js +1 -2
  185. package/rust-client/node_modules/mingo/dist/esm/operators/expression/arithmetic/floor.js +1 -2
  186. package/rust-client/node_modules/mingo/dist/esm/operators/expression/arithmetic/ln.js +1 -2
  187. package/rust-client/node_modules/mingo/dist/esm/operators/expression/arithmetic/log.js +1 -2
  188. package/rust-client/node_modules/mingo/dist/esm/operators/expression/arithmetic/log10.js +1 -2
  189. package/rust-client/node_modules/mingo/dist/esm/operators/expression/arithmetic/round.js +1 -2
  190. package/rust-client/node_modules/mingo/dist/esm/operators/expression/arithmetic/sqrt.js +1 -2
  191. package/rust-client/node_modules/mingo/dist/esm/operators/expression/arithmetic/subtract.js +5 -2
  192. package/rust-client/node_modules/mingo/dist/esm/operators/expression/arithmetic/trunc.js +1 -2
  193. package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/arrayElemAt.js +3 -4
  194. package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/arrayToObject.js +3 -4
  195. package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/concatArrays.js +12 -6
  196. package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/filter.js +2 -1
  197. package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/first.js +10 -13
  198. package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/firstN.js +2 -4
  199. package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/in.js +1 -1
  200. package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/indexOfArray.js +5 -10
  201. package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/isArray.js +2 -3
  202. package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/last.js +10 -13
  203. package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/lastN.js +2 -4
  204. package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/map.js +2 -1
  205. package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/maxN.js +2 -4
  206. package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/minN.js +2 -4
  207. package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/reduce.js +1 -2
  208. package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/reverseArray.js +1 -2
  209. package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/sortArray.js +2 -4
  210. package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/zip.js +4 -10
  211. package/rust-client/node_modules/mingo/dist/esm/operators/expression/bitwise/_internal.js +1 -2
  212. package/rust-client/node_modules/mingo/dist/esm/operators/expression/bitwise/bitNot.js +2 -4
  213. package/rust-client/node_modules/mingo/dist/esm/operators/expression/boolean/not.js +4 -6
  214. package/rust-client/node_modules/mingo/dist/esm/operators/expression/comparison/cmp.js +6 -5
  215. package/rust-client/node_modules/mingo/dist/esm/operators/expression/conditional/cond.js +2 -2
  216. package/rust-client/node_modules/mingo/dist/esm/operators/expression/conditional/ifNull.js +1 -1
  217. package/rust-client/node_modules/mingo/dist/esm/operators/expression/conditional/switch.js +1 -2
  218. package/rust-client/node_modules/mingo/dist/esm/operators/expression/date/_internal.js +140 -61
  219. package/rust-client/node_modules/mingo/dist/esm/operators/expression/date/dateAdd.js +2 -35
  220. package/rust-client/node_modules/mingo/dist/esm/operators/expression/date/dateDiff.js +43 -21
  221. package/rust-client/node_modules/mingo/dist/esm/operators/expression/date/dateFromParts.js +2 -4
  222. package/rust-client/node_modules/mingo/dist/esm/operators/expression/date/dateFromString.js +13 -11
  223. package/rust-client/node_modules/mingo/dist/esm/operators/expression/date/dateToString.js +2 -4
  224. package/rust-client/node_modules/mingo/dist/esm/operators/expression/date/dateTrunc.js +97 -0
  225. package/rust-client/node_modules/mingo/dist/esm/operators/expression/date/dayOfYear.js +2 -2
  226. package/rust-client/node_modules/mingo/dist/esm/operators/expression/date/index.js +1 -0
  227. package/rust-client/node_modules/mingo/dist/esm/operators/expression/date/isoWeekYear.js +2 -5
  228. package/rust-client/node_modules/mingo/dist/esm/operators/expression/date/week.js +1 -2
  229. package/rust-client/node_modules/mingo/dist/esm/operators/expression/misc/getField.js +1 -2
  230. package/rust-client/node_modules/mingo/dist/esm/operators/expression/object/mergeObjects.js +10 -3
  231. package/rust-client/node_modules/mingo/dist/esm/operators/expression/object/objectToArray.js +6 -2
  232. package/rust-client/node_modules/mingo/dist/esm/operators/expression/object/setField.js +11 -7
  233. package/rust-client/node_modules/mingo/dist/esm/operators/expression/set/setDifference.js +10 -2
  234. package/rust-client/node_modules/mingo/dist/esm/operators/expression/set/setEquals.js +18 -4
  235. package/rust-client/node_modules/mingo/dist/esm/operators/expression/set/setIntersection.js +3 -2
  236. package/rust-client/node_modules/mingo/dist/esm/operators/expression/set/setIsSubset.js +16 -2
  237. package/rust-client/node_modules/mingo/dist/esm/operators/expression/set/setUnion.js +5 -6
  238. package/rust-client/node_modules/mingo/dist/esm/operators/expression/string/_internal.js +4 -8
  239. package/rust-client/node_modules/mingo/dist/esm/operators/expression/string/concat.js +6 -3
  240. package/rust-client/node_modules/mingo/dist/esm/operators/expression/string/indexOfBytes.js +2 -4
  241. package/rust-client/node_modules/mingo/dist/esm/operators/expression/string/replaceAll.js +1 -2
  242. package/rust-client/node_modules/mingo/dist/esm/operators/expression/string/replaceOne.js +1 -2
  243. package/rust-client/node_modules/mingo/dist/esm/operators/expression/string/split.js +1 -2
  244. package/rust-client/node_modules/mingo/dist/esm/operators/expression/string/strcasecmp.js +1 -2
  245. package/rust-client/node_modules/mingo/dist/esm/operators/expression/string/substr.js +4 -14
  246. package/rust-client/node_modules/mingo/dist/esm/operators/expression/string/substrBytes.js +2 -4
  247. package/rust-client/node_modules/mingo/dist/esm/operators/expression/trignometry/atan2.js +2 -4
  248. package/rust-client/node_modules/mingo/dist/esm/operators/expression/trignometry/cosh.js +0 -1
  249. package/rust-client/node_modules/mingo/dist/esm/operators/expression/type/_internal.js +17 -11
  250. package/rust-client/node_modules/mingo/dist/esm/operators/expression/type/convert.js +3 -5
  251. package/rust-client/node_modules/mingo/dist/esm/operators/expression/type/toBool.js +2 -4
  252. package/rust-client/node_modules/mingo/dist/esm/operators/expression/type/toDate.js +4 -7
  253. package/rust-client/node_modules/mingo/dist/esm/operators/expression/type/toDouble.js +6 -11
  254. package/rust-client/node_modules/mingo/dist/esm/operators/expression/type/toInt.js +2 -5
  255. package/rust-client/node_modules/mingo/dist/esm/operators/expression/type/toLong.js +2 -5
  256. package/rust-client/node_modules/mingo/dist/esm/operators/expression/type/toString.js +12 -11
  257. package/rust-client/node_modules/mingo/dist/esm/operators/expression/type/type.js +12 -15
  258. package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/addFields.js +1 -2
  259. package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/bucket.js +54 -61
  260. package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/bucketAuto.js +679 -66
  261. package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/count.js +3 -3
  262. package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/densify.js +183 -0
  263. package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/graphLookup.js +55 -0
  264. package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/group.js +6 -9
  265. package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/index.js +2 -0
  266. package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/limit.js +1 -3
  267. package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/lookup.js +55 -11
  268. package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/merge.js +9 -14
  269. package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/out.js +2 -2
  270. package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/project.js +21 -42
  271. package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/redact.js +3 -1
  272. package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/replaceWith.js +9 -2
  273. package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/sample.js +1 -2
  274. package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/setWindowFields.js +12 -23
  275. package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/skip.js +1 -1
  276. package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/sort.js +11 -20
  277. package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/sortByCount.js +5 -3
  278. package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/unionWith.js +2 -2
  279. package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/unset.js +1 -2
  280. package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/unwind.js +6 -9
  281. package/rust-client/node_modules/mingo/dist/esm/operators/projection/elemMatch.js +3 -4
  282. package/rust-client/node_modules/mingo/dist/esm/operators/projection/slice.js +2 -3
  283. package/rust-client/node_modules/mingo/dist/esm/operators/query/bitwise/_internal.js +4 -4
  284. package/rust-client/node_modules/mingo/dist/esm/operators/update/_internal.js +9 -14
  285. package/rust-client/node_modules/mingo/dist/esm/operators/update/addToSet.js +1 -2
  286. package/rust-client/node_modules/mingo/dist/esm/operators/update/bit.js +1 -2
  287. package/rust-client/node_modules/mingo/dist/esm/operators/update/max.js +1 -2
  288. package/rust-client/node_modules/mingo/dist/esm/operators/update/min.js +1 -2
  289. package/rust-client/node_modules/mingo/dist/esm/operators/update/pop.js +1 -2
  290. package/rust-client/node_modules/mingo/dist/esm/operators/update/pull.js +2 -4
  291. package/rust-client/node_modules/mingo/dist/esm/operators/update/push.js +3 -9
  292. package/rust-client/node_modules/mingo/dist/esm/operators/update/rename.js +1 -2
  293. package/rust-client/node_modules/mingo/dist/esm/operators/update/set.js +1 -2
  294. package/rust-client/node_modules/mingo/dist/esm/operators/update/unset.js +1 -2
  295. package/rust-client/node_modules/mingo/dist/esm/operators/window/_internal.js +2 -3
  296. package/rust-client/node_modules/mingo/dist/esm/operators/window/denseRank.js +8 -10
  297. package/rust-client/node_modules/mingo/dist/esm/operators/window/derivative.js +4 -6
  298. package/rust-client/node_modules/mingo/dist/esm/operators/window/documentNumber.js +1 -3
  299. package/rust-client/node_modules/mingo/dist/esm/operators/window/expMovingAvg.js +4 -6
  300. package/rust-client/node_modules/mingo/dist/esm/operators/window/integral.js +3 -4
  301. package/rust-client/node_modules/mingo/dist/esm/operators/window/linearFill.js +4 -6
  302. package/rust-client/node_modules/mingo/dist/esm/operators/window/locf.js +3 -4
  303. package/rust-client/node_modules/mingo/dist/esm/operators/window/rank.js +8 -10
  304. package/rust-client/node_modules/mingo/dist/esm/operators/window/shift.js +2 -2
  305. package/rust-client/node_modules/mingo/dist/esm/query.js +22 -32
  306. package/rust-client/node_modules/mingo/dist/esm/types.js +14 -0
  307. package/rust-client/node_modules/mingo/dist/esm/updater.js +5 -5
  308. package/rust-client/node_modules/mingo/dist/esm/util.js +263 -377
  309. package/rust-client/node_modules/mingo/dist/types/aggregator.d.ts +7 -9
  310. package/rust-client/node_modules/mingo/dist/types/core.d.ts +41 -52
  311. package/rust-client/node_modules/mingo/dist/types/cursor.d.ts +6 -12
  312. package/rust-client/node_modules/mingo/dist/types/index.d.ts +8 -4
  313. package/rust-client/node_modules/mingo/dist/types/init/basic.d.ts +1 -6
  314. package/rust-client/node_modules/mingo/dist/types/lazy.d.ts +19 -15
  315. package/rust-client/node_modules/mingo/dist/types/operators/_predicates.d.ts +20 -20
  316. package/rust-client/node_modules/mingo/dist/types/operators/accumulator/accumulator.d.ts +1 -1
  317. package/rust-client/node_modules/mingo/dist/types/operators/accumulator/addToSet.d.ts +1 -1
  318. package/rust-client/node_modules/mingo/dist/types/operators/accumulator/avg.d.ts +1 -1
  319. package/rust-client/node_modules/mingo/dist/types/operators/accumulator/bottom.d.ts +2 -2
  320. package/rust-client/node_modules/mingo/dist/types/operators/accumulator/bottomN.d.ts +4 -4
  321. package/rust-client/node_modules/mingo/dist/types/operators/accumulator/count.d.ts +1 -1
  322. package/rust-client/node_modules/mingo/dist/types/operators/accumulator/covariancePop.d.ts +1 -1
  323. package/rust-client/node_modules/mingo/dist/types/operators/accumulator/covarianceSamp.d.ts +1 -1
  324. package/rust-client/node_modules/mingo/dist/types/operators/accumulator/first.d.ts +2 -2
  325. package/rust-client/node_modules/mingo/dist/types/operators/accumulator/firstN.d.ts +1 -1
  326. package/rust-client/node_modules/mingo/dist/types/operators/accumulator/last.d.ts +4 -4
  327. package/rust-client/node_modules/mingo/dist/types/operators/accumulator/lastN.d.ts +1 -1
  328. package/rust-client/node_modules/mingo/dist/types/operators/accumulator/max.d.ts +4 -5
  329. package/rust-client/node_modules/mingo/dist/types/operators/accumulator/maxN.d.ts +1 -1
  330. package/rust-client/node_modules/mingo/dist/types/operators/accumulator/mergeObjects.d.ts +1 -1
  331. package/rust-client/node_modules/mingo/dist/types/operators/accumulator/min.d.ts +4 -5
  332. package/rust-client/node_modules/mingo/dist/types/operators/accumulator/minN.d.ts +1 -1
  333. package/rust-client/node_modules/mingo/dist/types/operators/accumulator/percentile.d.ts +1 -1
  334. package/rust-client/node_modules/mingo/dist/types/operators/accumulator/push.d.ts +4 -4
  335. package/rust-client/node_modules/mingo/dist/types/operators/accumulator/stdDevPop.d.ts +1 -1
  336. package/rust-client/node_modules/mingo/dist/types/operators/accumulator/stdDevSamp.d.ts +1 -1
  337. package/rust-client/node_modules/mingo/dist/types/operators/accumulator/sum.d.ts +5 -3
  338. package/rust-client/node_modules/mingo/dist/types/operators/accumulator/top.d.ts +2 -2
  339. package/rust-client/node_modules/mingo/dist/types/operators/accumulator/topN.d.ts +4 -4
  340. package/rust-client/node_modules/mingo/dist/types/operators/expression/arithmetic/add.d.ts +1 -1
  341. package/rust-client/node_modules/mingo/dist/types/operators/expression/arithmetic/multiply.d.ts +1 -1
  342. package/rust-client/node_modules/mingo/dist/types/operators/expression/arithmetic/pow.d.ts +1 -1
  343. package/rust-client/node_modules/mingo/dist/types/operators/expression/arithmetic/subtract.d.ts +1 -0
  344. package/rust-client/node_modules/mingo/dist/types/operators/expression/array/arrayElemAt.d.ts +1 -1
  345. package/rust-client/node_modules/mingo/dist/types/operators/expression/array/concatArrays.d.ts +3 -3
  346. package/rust-client/node_modules/mingo/dist/types/operators/expression/array/filter.d.ts +1 -1
  347. package/rust-client/node_modules/mingo/dist/types/operators/expression/array/first.d.ts +0 -4
  348. package/rust-client/node_modules/mingo/dist/types/operators/expression/array/firstN.d.ts +1 -1
  349. package/rust-client/node_modules/mingo/dist/types/operators/expression/array/in.d.ts +2 -2
  350. package/rust-client/node_modules/mingo/dist/types/operators/expression/array/indexOfArray.d.ts +1 -1
  351. package/rust-client/node_modules/mingo/dist/types/operators/expression/array/isArray.d.ts +1 -1
  352. package/rust-client/node_modules/mingo/dist/types/operators/expression/array/last.d.ts +0 -4
  353. package/rust-client/node_modules/mingo/dist/types/operators/expression/array/lastN.d.ts +1 -1
  354. package/rust-client/node_modules/mingo/dist/types/operators/expression/array/map.d.ts +1 -1
  355. package/rust-client/node_modules/mingo/dist/types/operators/expression/array/maxN.d.ts +1 -1
  356. package/rust-client/node_modules/mingo/dist/types/operators/expression/array/minN.d.ts +1 -1
  357. package/rust-client/node_modules/mingo/dist/types/operators/expression/array/range.d.ts +1 -1
  358. package/rust-client/node_modules/mingo/dist/types/operators/expression/array/reduce.d.ts +2 -2
  359. package/rust-client/node_modules/mingo/dist/types/operators/expression/array/reverseArray.d.ts +1 -1
  360. package/rust-client/node_modules/mingo/dist/types/operators/expression/array/slice.d.ts +1 -1
  361. package/rust-client/node_modules/mingo/dist/types/operators/expression/date/_internal.d.ts +31 -9
  362. package/rust-client/node_modules/mingo/dist/types/operators/expression/date/dateFromString.d.ts +2 -2
  363. package/rust-client/node_modules/mingo/dist/types/operators/expression/date/dateToParts.d.ts +2 -2
  364. package/rust-client/node_modules/mingo/dist/types/operators/expression/date/dateTrunc.d.ts +12 -0
  365. package/rust-client/node_modules/mingo/dist/types/operators/expression/date/index.d.ts +1 -0
  366. package/rust-client/node_modules/mingo/dist/types/operators/expression/misc/rand.d.ts +2 -2
  367. package/rust-client/node_modules/mingo/dist/types/operators/expression/object/mergeObjects.d.ts +2 -2
  368. package/rust-client/node_modules/mingo/dist/types/operators/expression/percentile.d.ts +1 -1
  369. package/rust-client/node_modules/mingo/dist/types/operators/expression/set/setIsSubset.d.ts +3 -1
  370. package/rust-client/node_modules/mingo/dist/types/operators/expression/string/_internal.d.ts +4 -4
  371. package/rust-client/node_modules/mingo/dist/types/operators/expression/string/indexOfBytes.d.ts +1 -1
  372. package/rust-client/node_modules/mingo/dist/types/operators/expression/string/replaceAll.d.ts +1 -1
  373. package/rust-client/node_modules/mingo/dist/types/operators/expression/string/replaceOne.d.ts +1 -1
  374. package/rust-client/node_modules/mingo/dist/types/operators/expression/string/split.d.ts +1 -1
  375. package/rust-client/node_modules/mingo/dist/types/operators/expression/string/strLenBytes.d.ts +1 -1
  376. package/rust-client/node_modules/mingo/dist/types/operators/expression/string/strLenCP.d.ts +1 -1
  377. package/rust-client/node_modules/mingo/dist/types/operators/expression/string/substrBytes.d.ts +2 -0
  378. package/rust-client/node_modules/mingo/dist/types/operators/expression/type/_internal.d.ts +6 -2
  379. package/rust-client/node_modules/mingo/dist/types/operators/pipeline/_internal.d.ts +4 -4
  380. package/rust-client/node_modules/mingo/dist/types/operators/pipeline/addFields.d.ts +8 -5
  381. package/rust-client/node_modules/mingo/dist/types/operators/pipeline/bucket.d.ts +8 -5
  382. package/rust-client/node_modules/mingo/dist/types/operators/pipeline/bucketAuto.d.ts +8 -7
  383. package/rust-client/node_modules/mingo/dist/types/operators/pipeline/count.d.ts +7 -5
  384. package/rust-client/node_modules/mingo/dist/types/operators/pipeline/densify.d.ts +12 -0
  385. package/rust-client/node_modules/mingo/dist/types/operators/pipeline/facet.d.ts +7 -1
  386. package/rust-client/node_modules/mingo/dist/types/operators/pipeline/fill.d.ts +6 -3
  387. package/rust-client/node_modules/mingo/dist/types/operators/pipeline/graphLookup.d.ts +13 -0
  388. package/rust-client/node_modules/mingo/dist/types/operators/pipeline/group.d.ts +4 -2
  389. package/rust-client/node_modules/mingo/dist/types/operators/pipeline/index.d.ts +2 -0
  390. package/rust-client/node_modules/mingo/dist/types/operators/pipeline/limit.d.ts +3 -1
  391. package/rust-client/node_modules/mingo/dist/types/operators/pipeline/lookup.d.ts +4 -2
  392. package/rust-client/node_modules/mingo/dist/types/operators/pipeline/match.d.ts +4 -3
  393. package/rust-client/node_modules/mingo/dist/types/operators/pipeline/merge.d.ts +3 -5
  394. package/rust-client/node_modules/mingo/dist/types/operators/pipeline/out.d.ts +5 -3
  395. package/rust-client/node_modules/mingo/dist/types/operators/pipeline/project.d.ts +4 -3
  396. package/rust-client/node_modules/mingo/dist/types/operators/pipeline/redact.d.ts +1 -1
  397. package/rust-client/node_modules/mingo/dist/types/operators/pipeline/replaceRoot.d.ts +5 -5
  398. package/rust-client/node_modules/mingo/dist/types/operators/pipeline/replaceWith.d.ts +8 -1
  399. package/rust-client/node_modules/mingo/dist/types/operators/pipeline/sample.d.ts +7 -5
  400. package/rust-client/node_modules/mingo/dist/types/operators/pipeline/setWindowFields.d.ts +7 -5
  401. package/rust-client/node_modules/mingo/dist/types/operators/pipeline/skip.d.ts +6 -4
  402. package/rust-client/node_modules/mingo/dist/types/operators/pipeline/sort.d.ts +5 -3
  403. package/rust-client/node_modules/mingo/dist/types/operators/pipeline/sortByCount.d.ts +5 -5
  404. package/rust-client/node_modules/mingo/dist/types/operators/pipeline/unionWith.d.ts +3 -1
  405. package/rust-client/node_modules/mingo/dist/types/operators/pipeline/unset.d.ts +2 -0
  406. package/rust-client/node_modules/mingo/dist/types/operators/pipeline/unwind.d.ts +5 -2
  407. package/rust-client/node_modules/mingo/dist/types/operators/query/evaluation/expr.d.ts +2 -2
  408. package/rust-client/node_modules/mingo/dist/types/operators/query/evaluation/jsonSchema.d.ts +2 -2
  409. package/rust-client/node_modules/mingo/dist/types/operators/query/evaluation/where.d.ts +2 -2
  410. package/rust-client/node_modules/mingo/dist/types/operators/update/_internal.d.ts +5 -5
  411. package/rust-client/node_modules/mingo/dist/types/operators/update/addToSet.d.ts +2 -2
  412. package/rust-client/node_modules/mingo/dist/types/operators/update/bit.d.ts +2 -2
  413. package/rust-client/node_modules/mingo/dist/types/operators/update/currentDate.d.ts +2 -2
  414. package/rust-client/node_modules/mingo/dist/types/operators/update/inc.d.ts +2 -2
  415. package/rust-client/node_modules/mingo/dist/types/operators/update/max.d.ts +2 -2
  416. package/rust-client/node_modules/mingo/dist/types/operators/update/min.d.ts +2 -2
  417. package/rust-client/node_modules/mingo/dist/types/operators/update/mul.d.ts +2 -2
  418. package/rust-client/node_modules/mingo/dist/types/operators/update/pop.d.ts +2 -2
  419. package/rust-client/node_modules/mingo/dist/types/operators/update/pull.d.ts +2 -2
  420. package/rust-client/node_modules/mingo/dist/types/operators/update/pullAll.d.ts +2 -2
  421. package/rust-client/node_modules/mingo/dist/types/operators/update/push.d.ts +2 -2
  422. package/rust-client/node_modules/mingo/dist/types/operators/update/rename.d.ts +2 -2
  423. package/rust-client/node_modules/mingo/dist/types/operators/update/set.d.ts +2 -2
  424. package/rust-client/node_modules/mingo/dist/types/operators/update/unset.d.ts +2 -2
  425. package/rust-client/node_modules/mingo/dist/types/operators/window/_internal.d.ts +5 -5
  426. package/rust-client/node_modules/mingo/dist/types/operators/window/denseRank.d.ts +2 -3
  427. package/rust-client/node_modules/mingo/dist/types/operators/window/derivative.d.ts +2 -3
  428. package/rust-client/node_modules/mingo/dist/types/operators/window/documentNumber.d.ts +2 -2
  429. package/rust-client/node_modules/mingo/dist/types/operators/window/expMovingAvg.d.ts +2 -2
  430. package/rust-client/node_modules/mingo/dist/types/operators/window/integral.d.ts +2 -2
  431. package/rust-client/node_modules/mingo/dist/types/operators/window/linearFill.d.ts +2 -2
  432. package/rust-client/node_modules/mingo/dist/types/operators/window/locf.d.ts +2 -2
  433. package/rust-client/node_modules/mingo/dist/types/operators/window/rank.d.ts +2 -2
  434. package/rust-client/node_modules/mingo/dist/types/operators/window/shift.d.ts +2 -2
  435. package/rust-client/node_modules/mingo/dist/types/query.d.ts +5 -7
  436. package/rust-client/node_modules/mingo/dist/types/types.d.ts +18 -15
  437. package/rust-client/node_modules/mingo/dist/types/updater.d.ts +9 -10
  438. package/rust-client/node_modules/mingo/dist/types/util.d.ts +102 -90
  439. package/rust-client/node_modules/mingo/package.json +1 -1
@@ -1,8 +1,8 @@
1
1
  import { Lazy } from "../../lazy";
2
- import { assert, isString } from "../../util";
3
- const $count = (collection, expr, _) => {
2
+ import { assert, isEmpty, isString } from "../../util";
3
+ const $count = (collection, expr, _options) => {
4
4
  assert(
5
- isString(expr) && expr.trim() !== "" && expr.indexOf(".") === -1 && expr.trim()[0] !== "$",
5
+ isString(expr) && !isEmpty(expr) && expr.indexOf(".") === -1 && expr.trim()[0] !== "$",
6
6
  "Invalid expression value for $count"
7
7
  );
8
8
  return Lazy([
@@ -0,0 +1,183 @@
1
+ import { ComputeOptions } from "../../core";
2
+ import { concat, Lazy } from "../../lazy";
3
+ import { TIME_UNITS } from "../../types";
4
+ import {
5
+ assert,
6
+ isArray,
7
+ isDate,
8
+ isNil,
9
+ isNumber,
10
+ isObject,
11
+ isString,
12
+ resolve,
13
+ ValueMap
14
+ } from "../../util";
15
+ import { $dateAdd } from "../expression/date/dateAdd";
16
+ import { $sort } from "./sort";
17
+ const EMPTY_OBJECT = Object.freeze({});
18
+ const $densify = (collection, expr, options) => {
19
+ const { step, bounds, unit } = expr.range;
20
+ if (unit) {
21
+ assert(TIME_UNITS.includes(unit), "");
22
+ assert(
23
+ Number.isInteger(step) && step > 0,
24
+ "The step parameter in a range statement must be a whole number when densifying a date range."
25
+ );
26
+ } else {
27
+ assert(
28
+ isNumber(step) && step > 0,
29
+ "The step parameter in a range statement must be a strictly positive numeric value."
30
+ );
31
+ }
32
+ if (isArray(bounds)) {
33
+ assert(
34
+ !!bounds && bounds.length === 2,
35
+ "A bounding array in a range statement must have exactly two elements."
36
+ );
37
+ assert(
38
+ (bounds.every(isNumber) || bounds.every(isDate)) && bounds[0] < bounds[1],
39
+ "A bounding array must be an ascending array of either two dates or two numbers."
40
+ );
41
+ assert(
42
+ unit && !bounds.some(isNumber),
43
+ "Numeric bounds may not have unit parameter."
44
+ );
45
+ }
46
+ if (expr.partitionByFields) {
47
+ assert(
48
+ isArray(expr.partitionByFields),
49
+ "$densify: `partitionByFields` must be an array of strings"
50
+ );
51
+ }
52
+ collection = $sort(collection, { [expr.field]: 1 }, options);
53
+ const nilOptions = ComputeOptions.init(options, null);
54
+ const computeNextValue = (value) => {
55
+ return isNumber(value) ? value + step : $dateAdd(
56
+ EMPTY_OBJECT,
57
+ { startDate: value, unit, amount: step },
58
+ nilOptions
59
+ );
60
+ };
61
+ const isValidUnit = !!unit && TIME_UNITS.includes(unit);
62
+ const getFieldValue = (o) => {
63
+ const v = resolve(o, expr.field);
64
+ if (isNil(v)) return v;
65
+ if (isNumber(v)) {
66
+ assert(
67
+ !isValidUnit,
68
+ "$densify: Encountered non-date value in collection when step has a date unit."
69
+ );
70
+ } else if (isDate(v)) {
71
+ assert(
72
+ isValidUnit,
73
+ "$densify: Encountered date value in collection when step does not have a date unit."
74
+ );
75
+ } else {
76
+ assert(false, "$densify: Densify field type must be numeric or a date");
77
+ }
78
+ return v;
79
+ };
80
+ const peekItem = new Array();
81
+ const nilFieldsIterator = Lazy(() => {
82
+ const item = collection.next();
83
+ const fieldValue = getFieldValue(item.value);
84
+ if (isNil(fieldValue)) return item;
85
+ peekItem.push(item);
86
+ return { done: true };
87
+ });
88
+ const nextDensifyValueMap = ValueMap.init(
89
+ options.hashFunction
90
+ );
91
+ const [lower, upper] = isArray(bounds) ? bounds : [bounds, bounds];
92
+ let maxFieldValue = void 0;
93
+ const updateMaxFieldValue = (value) => {
94
+ maxFieldValue = maxFieldValue === void 0 || maxFieldValue < value ? value : maxFieldValue;
95
+ };
96
+ const rootKey = [];
97
+ const densifyIterator = Lazy(() => {
98
+ const item = peekItem.length > 0 ? peekItem.pop() : collection.next();
99
+ if (item.done) return item;
100
+ let partitionKey = rootKey;
101
+ if (isArray(expr.partitionByFields)) {
102
+ partitionKey = expr.partitionByFields.map(
103
+ (k) => resolve(item.value, k)
104
+ );
105
+ assert(
106
+ partitionKey.every(isString),
107
+ "$densify: Partition fields must evaluate to string values."
108
+ );
109
+ }
110
+ assert(isObject(item.value), "$densify: collection must contain documents");
111
+ const itemValue = getFieldValue(item.value);
112
+ if (!nextDensifyValueMap.has(partitionKey)) {
113
+ if (lower == "full") {
114
+ if (!nextDensifyValueMap.has(rootKey)) {
115
+ nextDensifyValueMap.set(rootKey, itemValue);
116
+ }
117
+ nextDensifyValueMap.set(partitionKey, nextDensifyValueMap.get(rootKey));
118
+ } else if (lower == "partition") {
119
+ nextDensifyValueMap.set(partitionKey, itemValue);
120
+ } else {
121
+ nextDensifyValueMap.set(partitionKey, lower);
122
+ }
123
+ }
124
+ const densifyValue = nextDensifyValueMap.get(partitionKey);
125
+ if (
126
+ // current item field value is lower than current densify value.
127
+ itemValue <= densifyValue || // range value equals or exceeds upper bound
128
+ upper != "full" && upper != "partition" && densifyValue >= upper
129
+ ) {
130
+ if (densifyValue <= itemValue) {
131
+ nextDensifyValueMap.set(partitionKey, computeNextValue(densifyValue));
132
+ }
133
+ updateMaxFieldValue(itemValue);
134
+ return item;
135
+ }
136
+ nextDensifyValueMap.set(partitionKey, computeNextValue(densifyValue));
137
+ updateMaxFieldValue(densifyValue);
138
+ const denseObj = { [expr.field]: densifyValue };
139
+ if (partitionKey) {
140
+ partitionKey.forEach((v, i) => {
141
+ denseObj[expr.partitionByFields[i]] = v;
142
+ });
143
+ }
144
+ peekItem.push(item);
145
+ return { done: false, value: denseObj };
146
+ });
147
+ if (lower !== "full") return concat(nilFieldsIterator, densifyIterator);
148
+ let paritionIndex = -1;
149
+ let partitionKeysSet = void 0;
150
+ const fullBoundsIterator = Lazy(() => {
151
+ if (paritionIndex === -1) {
152
+ const fullDensifyValue = nextDensifyValueMap.get(rootKey);
153
+ nextDensifyValueMap.delete(rootKey);
154
+ partitionKeysSet = Array.from(nextDensifyValueMap.keys());
155
+ if (partitionKeysSet.length === 0) {
156
+ partitionKeysSet.push(rootKey);
157
+ nextDensifyValueMap.set(rootKey, fullDensifyValue);
158
+ }
159
+ paritionIndex++;
160
+ }
161
+ do {
162
+ const partitionKey = partitionKeysSet[paritionIndex];
163
+ const partitionMaxValue = nextDensifyValueMap.get(partitionKey);
164
+ if (partitionMaxValue < maxFieldValue) {
165
+ nextDensifyValueMap.set(
166
+ partitionKey,
167
+ computeNextValue(partitionMaxValue)
168
+ );
169
+ const denseObj = { [expr.field]: partitionMaxValue };
170
+ partitionKey.forEach((v, i) => {
171
+ denseObj[expr.partitionByFields[i]] = v;
172
+ });
173
+ return { done: false, value: denseObj };
174
+ }
175
+ paritionIndex++;
176
+ } while (paritionIndex < partitionKeysSet.length);
177
+ return { done: true };
178
+ });
179
+ return concat(nilFieldsIterator, densifyIterator, fullBoundsIterator);
180
+ };
181
+ export {
182
+ $densify
183
+ };
@@ -0,0 +1,55 @@
1
+ import { computeValue } from "../../core";
2
+ import { Lazy } from "../../lazy";
3
+ import { flatten, isNil, isString, setValue, ValueMap } from "../../util";
4
+ import { $lookup } from "./lookup";
5
+ const $graphLookup = (collection, expr, options) => {
6
+ const fromColl = isString(expr.from) ? options?.collectionResolver(expr.from) : expr.from;
7
+ const {
8
+ connectFromField,
9
+ connectToField,
10
+ as: asField,
11
+ maxDepth,
12
+ depthField,
13
+ restrictSearchWithMatch: matchExpr
14
+ } = expr;
15
+ const pipelineExpr = matchExpr ? { pipeline: [{ $match: matchExpr }] } : {};
16
+ return collection.map((obj) => {
17
+ const matchObj = {};
18
+ setValue(
19
+ matchObj,
20
+ connectFromField,
21
+ computeValue(obj, expr.startWith, null, options)
22
+ );
23
+ let matches = [matchObj];
24
+ let i = -1;
25
+ const map = ValueMap.init(options.hashFunction);
26
+ do {
27
+ i++;
28
+ matches = flatten(
29
+ $lookup(
30
+ Lazy(matches),
31
+ {
32
+ from: fromColl,
33
+ localField: connectFromField,
34
+ foreignField: connectToField,
35
+ as: asField,
36
+ ...pipelineExpr
37
+ },
38
+ options
39
+ ).map((o) => o[asField]).value()
40
+ );
41
+ const oldSize = map.size;
42
+ matches.forEach((k) => map.set(k, map.get(k) ?? i));
43
+ if (oldSize == map.size) break;
44
+ } while (isNil(maxDepth) || i < maxDepth);
45
+ const result = new Array(map.size);
46
+ let n = 0;
47
+ map.forEach((v, k) => {
48
+ result[n++] = Object.assign(depthField ? { [depthField]: v } : {}, k);
49
+ });
50
+ return { ...obj, [asField]: result };
51
+ });
52
+ };
53
+ export {
54
+ $graphLookup
55
+ };
@@ -5,33 +5,30 @@ import {
5
5
  import { assert, groupBy, has } from "../../util";
6
6
  const ID_KEY = "_id";
7
7
  const $group = (collection, expr, options) => {
8
- assert(has(expr, ID_KEY), "a group specification must include an _id");
8
+ assert(has(expr, ID_KEY), "$group specification must include an '_id'");
9
9
  const idExpr = expr[ID_KEY];
10
10
  const copts = ComputeOptions.init(options);
11
+ const newFields = Object.keys(expr).filter((k) => k != ID_KEY);
11
12
  return collection.transform((coll) => {
12
13
  const partitions = groupBy(
13
14
  coll,
14
15
  (obj) => computeValue(obj, idExpr, null, options),
15
16
  options.hashFunction
16
17
  );
17
- expr = { ...expr };
18
- delete expr[ID_KEY];
19
18
  let i = -1;
20
19
  const partitionKeys = Array.from(partitions.keys());
21
- const size = partitions.size;
22
20
  return () => {
23
- if (++i === size)
24
- return { done: true };
21
+ if (++i === partitions.size) return { done: true };
25
22
  const groupId = partitionKeys[i];
26
23
  const obj = {};
27
24
  if (groupId !== void 0) {
28
25
  obj[ID_KEY] = groupId;
29
26
  }
30
- for (const [key, val] of Object.entries(expr)) {
27
+ for (const key of newFields) {
31
28
  obj[key] = computeValue(
32
29
  partitions.get(groupId),
33
- val,
34
- key,
30
+ expr[key],
31
+ null,
35
32
  copts.update(null, { groupId })
36
33
  );
37
34
  }
@@ -2,8 +2,10 @@ export * from "./addFields";
2
2
  export * from "./bucket";
3
3
  export * from "./bucketAuto";
4
4
  export * from "./count";
5
+ export * from "./densify";
5
6
  export * from "./facet";
6
7
  export * from "./fill";
8
+ export * from "./graphLookup";
7
9
  export * from "./group";
8
10
  export * from "./limit";
9
11
  export * from "./lookup";
@@ -1,6 +1,4 @@
1
- const $limit = (collection, expr, options) => {
2
- return collection.take(expr);
3
- };
1
+ const $limit = (collection, expr, _options) => collection.take(expr);
4
2
  export {
5
3
  $limit
6
4
  };
@@ -1,18 +1,62 @@
1
- import { assert, hashCode, into, isString, resolve } from "../../util";
1
+ import { Aggregator } from "../../aggregator";
2
+ import { computeValue } from "../../core";
3
+ import {
4
+ ensureArray,
5
+ flatten,
6
+ isArray,
7
+ isString,
8
+ resolve,
9
+ ValueMap
10
+ } from "../../util";
2
11
  const $lookup = (collection, expr, options) => {
3
12
  const joinColl = isString(expr.from) ? options?.collectionResolver(expr.from) : expr.from;
4
- assert(joinColl instanceof Array, `'from' field must resolve to an array`);
5
- const hash = {};
6
- for (const obj of joinColl) {
7
- const k = hashCode(resolve(obj, expr.foreignField), options?.hashFunction);
8
- hash[k] = hash[k] || [];
9
- hash[k].push(obj);
13
+ const { let: letExpr, pipeline, foreignField, localField } = expr;
14
+ const subQueryPipeline = pipeline || [];
15
+ let lookupEq = (_) => [true, []];
16
+ if (foreignField && localField) {
17
+ const map = ValueMap.init(options.hashFunction);
18
+ for (const doc of joinColl) {
19
+ ensureArray(resolve(doc, foreignField) ?? null).forEach((v) => {
20
+ const xs = map.get(v);
21
+ const arr = xs ?? [];
22
+ arr.push(doc);
23
+ if (arr !== xs) map.set(v, arr);
24
+ });
25
+ }
26
+ lookupEq = (o) => {
27
+ const local = resolve(o, localField) ?? null;
28
+ if (isArray(local)) {
29
+ if (subQueryPipeline.length) {
30
+ return [local.some((v) => map.has(v)), null];
31
+ }
32
+ const result2 = Array.from(
33
+ new Set(flatten(local.map((v) => map.get(v), options.hashFunction)))
34
+ );
35
+ return [result2.length > 0, result2];
36
+ }
37
+ const result = map.get(local) ?? null;
38
+ return [result !== null, result ?? []];
39
+ };
40
+ if (subQueryPipeline.length === 0) {
41
+ return collection.map((obj) => {
42
+ return {
43
+ ...obj,
44
+ [expr.as]: lookupEq(obj).pop()
45
+ };
46
+ });
47
+ }
10
48
  }
49
+ const agg = new Aggregator(subQueryPipeline, options);
11
50
  return collection.map((obj) => {
12
- const k = hashCode(resolve(obj, expr.localField), options?.hashFunction);
13
- const newObj = into({}, obj);
14
- newObj[expr.as] = hash[k] || [];
15
- return newObj;
51
+ const variables = computeValue(obj, letExpr, null, options);
52
+ const opts = Object.assign({}, options, {
53
+ variables: { ...options.variables, ...variables }
54
+ });
55
+ const [ok, res] = lookupEq(obj);
56
+ return {
57
+ ...obj,
58
+ [expr.as]: ok ? agg.run(joinColl, opts) : res
59
+ };
16
60
  });
17
61
  };
18
62
  export {
@@ -9,35 +9,30 @@ import {
9
9
  isArray,
10
10
  isString,
11
11
  MingoError,
12
- resolve
12
+ resolve,
13
+ ValueMap
13
14
  } from "../../util";
14
15
  import { $mergeObjects } from "../expression";
15
16
  const $merge = (collection, expr, options) => {
16
17
  const output = isString(expr.into) ? options?.collectionResolver(expr.into) : expr.into;
17
- assert(
18
- output instanceof Array,
19
- `$merge: option 'into' must resolve to an array`
20
- );
18
+ assert(isArray(output), `$merge: option 'into' must resolve to an array`);
21
19
  const onField = expr.on || options.idKey;
22
- const getHash = (o) => {
23
- const val = isString(onField) ? resolve(o, onField) : onField.map((s) => resolve(o, s));
24
- return hashCode(val, options.hashFunction);
25
- };
26
- const hash = {};
20
+ const getHash = isString(onField) ? (o) => hashCode(resolve(o, onField), options.hashFunction) : (o) => hashCode(onField.map((s) => resolve(o, s), options.hashFunction));
21
+ const map = ValueMap.init();
27
22
  for (let i = 0; i < output.length; i++) {
28
23
  const obj = output[i];
29
24
  const k = getHash(obj);
30
25
  assert(
31
- !hash[k],
26
+ !map.has(k),
32
27
  "$merge: 'into' collection must have unique entries for the 'on' field."
33
28
  );
34
- hash[k] = [obj, i];
29
+ map.set(k, [obj, i]);
35
30
  }
36
31
  const copts = ComputeOptions.init(options);
37
32
  return collection.map((o) => {
38
33
  const k = getHash(o);
39
- if (hash[k]) {
40
- const [target, i] = hash[k];
34
+ if (map.has(k)) {
35
+ const [target, i] = map.get(k);
41
36
  const variables = computeValue(
42
37
  target,
43
38
  expr.let || { new: "$$ROOT" },
@@ -1,7 +1,7 @@
1
- import { assert, cloneDeep, isString } from "../../util";
1
+ import { assert, cloneDeep, isArray, isString } from "../../util";
2
2
  const $out = (collection, expr, options) => {
3
3
  const outputColl = isString(expr) ? options?.collectionResolver(expr) : expr;
4
- assert(outputColl instanceof Array, `expression must resolve to an array`);
4
+ assert(isArray(outputColl), `expression must resolve to an array`);
5
5
  return collection.map((o) => {
6
6
  outputColl.push(cloneDeep(o));
7
7
  return o;
@@ -1,16 +1,15 @@
1
1
  import {
2
2
  ComputeOptions,
3
3
  computeValue,
4
- getOperator,
5
- OperatorType
4
+ getOperator
6
5
  } from "../../core";
7
6
  import {
8
7
  assert,
9
8
  ensureArray,
10
9
  filterMissing,
11
10
  has,
12
- inArray,
13
11
  into,
12
+ isArray,
14
13
  isEmpty,
15
14
  isNil,
16
15
  isNumber,
@@ -18,42 +17,27 @@ import {
18
17
  isOperator,
19
18
  isString,
20
19
  merge,
21
- notInArray,
22
20
  removeValue,
23
21
  resolveGraph,
24
22
  setValue
25
23
  } from "../../util";
24
+ const DESCRIPTORS = new Set(Array.from([0, 1, false, true]));
26
25
  const $project = (collection, expr, options) => {
27
- if (isEmpty(expr))
28
- return collection;
29
- let expressionKeys = Object.keys(expr);
30
- let idOnlyExcluded = false;
26
+ if (isEmpty(expr)) return collection;
27
+ const expressionKeys = Object.keys(expr);
31
28
  validateExpression(expr, options);
32
29
  const ID_KEY = options.idKey;
33
- if (inArray(expressionKeys, ID_KEY)) {
34
- const id = expr[ID_KEY];
35
- if (id === 0 || id === false) {
36
- expressionKeys = expressionKeys.filter(
37
- notInArray.bind(null, [ID_KEY])
38
- );
39
- idOnlyExcluded = expressionKeys.length == 0;
40
- }
41
- } else {
30
+ if (!expressionKeys.includes(ID_KEY)) {
42
31
  expressionKeys.push(ID_KEY);
43
32
  }
44
33
  const copts = ComputeOptions.init(options);
45
- return collection.map((obj) => processObject(
46
- obj,
47
- expr,
48
- copts.update(obj),
49
- expressionKeys,
50
- idOnlyExcluded
51
- ));
34
+ return collection.map((obj) => processObject(obj, expr, copts.update(obj), expressionKeys));
52
35
  };
53
- function processObject(obj, expr, options, expressionKeys, idOnlyExcluded) {
36
+ function processObject(obj, expr, options, expressionKeys) {
54
37
  let newObj = {};
55
38
  let foundSlice = false;
56
39
  let foundExclusion = false;
40
+ const idOnlyExcluded = expr[options.idKey] === 0 && expressionKeys.length === 1;
57
41
  const dropKeys = [];
58
42
  if (idOnlyExcluded) {
59
43
  dropKeys.push(options.idKey);
@@ -61,19 +45,18 @@ function processObject(obj, expr, options, expressionKeys, idOnlyExcluded) {
61
45
  for (const key of expressionKeys) {
62
46
  let value = void 0;
63
47
  const subExpr = expr[key];
64
- if (key !== options.idKey && inArray([0, false], subExpr)) {
48
+ if (key !== options.idKey && (subExpr === 0 || subExpr === false)) {
65
49
  foundExclusion = true;
66
50
  }
67
51
  if (key === options.idKey && isEmpty(subExpr)) {
68
52
  value = obj[key];
69
53
  } else if (isString(subExpr)) {
70
54
  value = computeValue(obj, subExpr, key, options);
71
- } else if (inArray([1, true], subExpr)) {
72
- } else if (subExpr instanceof Array) {
55
+ } else if (subExpr === 1 || subExpr === true) {
56
+ } else if (isArray(subExpr)) {
73
57
  value = subExpr.map((v) => {
74
58
  const r = computeValue(obj, v, null, options);
75
- if (isNil(r))
76
- return null;
59
+ if (isNil(r)) return null;
77
60
  return r;
78
61
  });
79
62
  } else if (isObject(subExpr)) {
@@ -81,7 +64,7 @@ function processObject(obj, expr, options, expressionKeys, idOnlyExcluded) {
81
64
  const subExprKeys = Object.keys(subExpr);
82
65
  const operator = subExprKeys.length == 1 ? subExprKeys[0] : "";
83
66
  const call = getOperator(
84
- OperatorType.PROJECTION,
67
+ "projection",
85
68
  operator,
86
69
  options
87
70
  );
@@ -101,9 +84,9 @@ function processObject(obj, expr, options, expressionKeys, idOnlyExcluded) {
101
84
  } else if (has(obj, key)) {
102
85
  validateExpression(subExprObj, options);
103
86
  let target = obj[key];
104
- if (target instanceof Array) {
87
+ if (isArray(target)) {
105
88
  value = target.map(
106
- (o) => processObject(o, subExprObj, options, subExprKeys, false)
89
+ (o) => processObject(o, subExprObj, options, subExprKeys)
107
90
  );
108
91
  } else {
109
92
  target = isObject(target) ? target : obj;
@@ -111,8 +94,7 @@ function processObject(obj, expr, options, expressionKeys, idOnlyExcluded) {
111
94
  target,
112
95
  subExprObj,
113
96
  options,
114
- subExprKeys,
115
- false
97
+ subExprKeys
116
98
  );
117
99
  }
118
100
  } else {
@@ -125,12 +107,10 @@ function processObject(obj, expr, options, expressionKeys, idOnlyExcluded) {
125
107
  const objPathGraph = resolveGraph(obj, key, {
126
108
  preserveMissing: true
127
109
  });
128
- if (objPathGraph !== void 0) {
129
- merge(newObj, objPathGraph, {
130
- flatten: true
131
- });
110
+ if (isObject(objPathGraph)) {
111
+ merge(newObj, objPathGraph);
132
112
  }
133
- if (notInArray([0, 1, false, true], subExpr)) {
113
+ if (!DESCRIPTORS.has(subExpr)) {
134
114
  if (value === void 0) {
135
115
  removeValue(newObj, key, { descendArray: true });
136
116
  } else {
@@ -152,8 +132,7 @@ function processObject(obj, expr, options, expressionKeys, idOnlyExcluded) {
152
132
  function validateExpression(expr, options) {
153
133
  const check = [false, false];
154
134
  for (const [k, v] of Object.entries(expr)) {
155
- if (k === options?.idKey)
156
- return;
135
+ if (k === options?.idKey) return;
157
136
  if (v === 0 || v === false) {
158
137
  check[0] = true;
159
138
  } else if (v === 1 || v === true) {
@@ -1,7 +1,9 @@
1
1
  import { ComputeOptions, redact } from "../../core";
2
2
  const $redact = (collection, expr, options) => {
3
3
  const copts = ComputeOptions.init(options);
4
- return collection.map((obj) => redact(obj, expr, copts.update(obj)));
4
+ return collection.map(
5
+ (obj) => redact(obj, expr, copts.update(obj))
6
+ );
5
7
  };
6
8
  export {
7
9
  $redact
@@ -1,5 +1,12 @@
1
- import { $replaceRoot } from "./replaceRoot";
2
- const $replaceWith = $replaceRoot;
1
+ import { computeValue } from "../../core";
2
+ import { assert, isObject } from "../../util";
3
+ const $replaceWith = (collection, expr, options) => {
4
+ return collection.map((obj) => {
5
+ obj = computeValue(obj, expr, null, options);
6
+ assert(isObject(obj), "$replaceWith expression must return an object");
7
+ return obj;
8
+ });
9
+ };
3
10
  export {
4
11
  $replaceWith
5
12
  };
@@ -3,8 +3,7 @@ const $sample = (collection, expr, _options) => {
3
3
  const len = xs.length;
4
4
  let i = -1;
5
5
  return () => {
6
- if (++i === expr.size)
7
- return { done: true };
6
+ if (++i === expr.size) return { done: true };
8
7
  const n = Math.floor(Math.random() * len);
9
8
  return { value: xs[n], done: false };
10
9
  };