@valkey/valkey-glide-darwin-arm64 1.2.0 → 1.2.1-rc0
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.
- package/build-ts/src/BaseClient.d.ts +27 -1
- package/build-ts/src/BaseClient.js +9 -1
- package/build-ts/src/BaseClient.js.map +1 -1
- package/build-ts/src/Commands.d.ts +12 -0
- package/build-ts/src/Commands.js.map +1 -1
- package/build-ts/src/GlideClient.d.ts +17 -1
- package/build-ts/src/GlideClient.js +3 -0
- package/build-ts/src/GlideClient.js.map +1 -1
- package/build-ts/src/GlideClusterClient.d.ts +23 -7
- package/build-ts/src/GlideClusterClient.js +8 -3
- package/build-ts/src/GlideClusterClient.js.map +1 -1
- package/build-ts/src/ProtobufMessage.js +46 -1
- package/build-ts/src/ProtobufMessage.js.map +1 -1
- package/node_modules/glide-rs/glide-rs.darwin-arm64.node +0 -0
- package/node_modules/glide-rs/index.d.ts +2 -1
- package/node_modules/glide-rs/index.js +4 -2
- package/npm/glide/index.ts +4 -3
- package/npm/glide/package.json +0 -1
- package/package.json +2 -2
- package/rust-client/node_modules/mingo/README.md +58 -53
- package/rust-client/node_modules/mingo/dist/cjs/aggregator.js +18 -20
- package/rust-client/node_modules/mingo/dist/cjs/core.js +179 -190
- package/rust-client/node_modules/mingo/dist/cjs/cursor.js +34 -34
- package/rust-client/node_modules/mingo/dist/cjs/index.js +11 -3
- package/rust-client/node_modules/mingo/dist/cjs/init/basic.js +4 -22
- package/rust-client/node_modules/mingo/dist/cjs/init/system.js +6 -6
- package/rust-client/node_modules/mingo/dist/cjs/lazy.js +58 -61
- package/rust-client/node_modules/mingo/dist/cjs/operators/_predicates.js +12 -25
- package/rust-client/node_modules/mingo/dist/cjs/operators/accumulator/_internal.js +2 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/accumulator/accumulator.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/accumulator/first.js +3 -1
- package/rust-client/node_modules/mingo/dist/cjs/operators/accumulator/last.js +4 -1
- package/rust-client/node_modules/mingo/dist/cjs/operators/accumulator/max.js +9 -6
- package/rust-client/node_modules/mingo/dist/cjs/operators/accumulator/mergeObjects.js +5 -1
- package/rust-client/node_modules/mingo/dist/cjs/operators/accumulator/min.js +9 -3
- package/rust-client/node_modules/mingo/dist/cjs/operators/accumulator/push.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/accumulator/sum.js +2 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/arithmetic/add.js +9 -10
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/arithmetic/ceil.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/arithmetic/exp.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/arithmetic/floor.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/arithmetic/ln.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/arithmetic/log.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/arithmetic/log10.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/arithmetic/round.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/arithmetic/sqrt.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/arithmetic/subtract.js +5 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/arithmetic/trunc.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/arrayElemAt.js +2 -3
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/arrayToObject.js +3 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/concatArrays.js +11 -5
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/filter.js +1 -0
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/first.js +8 -8
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/firstN.js +2 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/in.js +1 -1
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/indexOfArray.js +5 -10
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/isArray.js +2 -3
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/last.js +8 -8
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/lastN.js +2 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/map.js +1 -0
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/maxN.js +2 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/minN.js +2 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/reduce.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/reverseArray.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/sortArray.js +2 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/zip.js +4 -10
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/bitwise/_internal.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/bitwise/bitNot.js +2 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/boolean/not.js +3 -5
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/comparison/cmp.js +6 -5
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/conditional/cond.js +1 -1
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/conditional/ifNull.js +1 -1
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/conditional/switch.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/date/_internal.js +157 -65
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/date/dateAdd.js +1 -29
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/date/dateDiff.js +32 -20
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/date/dateFromParts.js +2 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/date/dateFromString.js +13 -9
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/date/dateToString.js +2 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/date/dateTrunc.js +107 -0
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/date/dayOfYear.js +1 -1
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/date/index.js +2 -0
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/date/isoWeekYear.js +1 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/date/week.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/misc/getField.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/object/mergeObjects.js +9 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/object/objectToArray.js +5 -1
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/object/setField.js +11 -7
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/set/setDifference.js +9 -1
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/set/setEquals.js +17 -3
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/set/setIntersection.js +2 -1
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/set/setIsSubset.js +15 -1
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/set/setUnion.js +4 -5
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/string/_internal.js +4 -8
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/string/concat.js +5 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/string/indexOfBytes.js +2 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/string/replaceAll.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/string/replaceOne.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/string/split.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/string/strcasecmp.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/string/substr.js +4 -14
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/string/substrBytes.js +2 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/trignometry/atan2.js +2 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/trignometry/cosh.js +0 -1
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/type/_internal.js +20 -10
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/type/convert.js +3 -5
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/type/toBool.js +2 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/type/toDate.js +3 -6
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/type/toDouble.js +5 -10
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/type/toInt.js +1 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/type/toLong.js +1 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/type/toString.js +11 -10
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/type/type.js +11 -14
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/addFields.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/bucket.js +53 -53
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/bucketAuto.js +670 -65
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/count.js +2 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/densify.js +196 -0
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/graphLookup.js +78 -0
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/group.js +6 -9
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/index.js +4 -0
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/limit.js +1 -3
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/lookup.js +47 -10
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/merge.js +7 -13
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/out.js +1 -1
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/project.js +19 -38
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/redact.js +3 -1
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/replaceWith.js +9 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/sample.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/setWindowFields.js +10 -20
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/skip.js +1 -1
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/sort.js +10 -19
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/sortByCount.js +5 -3
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/unionWith.js +1 -1
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/unset.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/unwind.js +5 -9
- package/rust-client/node_modules/mingo/dist/cjs/operators/projection/elemMatch.js +2 -3
- package/rust-client/node_modules/mingo/dist/cjs/operators/projection/slice.js +2 -3
- package/rust-client/node_modules/mingo/dist/cjs/operators/query/bitwise/_internal.js +4 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/update/_internal.js +8 -14
- package/rust-client/node_modules/mingo/dist/cjs/operators/update/addToSet.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/update/bit.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/update/max.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/update/min.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/update/pop.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/update/pull.js +2 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/update/push.js +3 -9
- package/rust-client/node_modules/mingo/dist/cjs/operators/update/rename.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/update/set.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/update/unset.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/window/_internal.js +2 -3
- package/rust-client/node_modules/mingo/dist/cjs/operators/window/denseRank.js +8 -10
- package/rust-client/node_modules/mingo/dist/cjs/operators/window/derivative.js +4 -6
- package/rust-client/node_modules/mingo/dist/cjs/operators/window/documentNumber.js +1 -3
- package/rust-client/node_modules/mingo/dist/cjs/operators/window/expMovingAvg.js +4 -6
- package/rust-client/node_modules/mingo/dist/cjs/operators/window/integral.js +3 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/window/linearFill.js +4 -6
- package/rust-client/node_modules/mingo/dist/cjs/operators/window/locf.js +3 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/window/rank.js +8 -10
- package/rust-client/node_modules/mingo/dist/cjs/operators/window/shift.js +2 -2
- package/rust-client/node_modules/mingo/dist/cjs/query.js +20 -19
- package/rust-client/node_modules/mingo/dist/cjs/types.js +22 -0
- package/rust-client/node_modules/mingo/dist/cjs/updater.js +6 -5
- package/rust-client/node_modules/mingo/dist/cjs/util.js +265 -388
- package/rust-client/node_modules/mingo/dist/esm/aggregator.js +18 -21
- package/rust-client/node_modules/mingo/dist/esm/core.js +179 -192
- package/rust-client/node_modules/mingo/dist/esm/cursor.js +35 -35
- package/rust-client/node_modules/mingo/dist/esm/index.js +8 -2
- package/rust-client/node_modules/mingo/dist/esm/init/basic.js +5 -12
- package/rust-client/node_modules/mingo/dist/esm/init/system.js +7 -7
- package/rust-client/node_modules/mingo/dist/esm/lazy.js +58 -61
- package/rust-client/node_modules/mingo/dist/esm/operators/_predicates.js +14 -32
- package/rust-client/node_modules/mingo/dist/esm/operators/accumulator/_internal.js +2 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/accumulator/accumulator.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/accumulator/first.js +7 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/accumulator/last.js +8 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/accumulator/max.js +10 -7
- package/rust-client/node_modules/mingo/dist/esm/operators/accumulator/mergeObjects.js +5 -1
- package/rust-client/node_modules/mingo/dist/esm/operators/accumulator/min.js +10 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/accumulator/push.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/accumulator/sum.js +2 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/arithmetic/add.js +9 -10
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/arithmetic/ceil.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/arithmetic/exp.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/arithmetic/floor.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/arithmetic/ln.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/arithmetic/log.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/arithmetic/log10.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/arithmetic/round.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/arithmetic/sqrt.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/arithmetic/subtract.js +5 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/arithmetic/trunc.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/arrayElemAt.js +3 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/arrayToObject.js +3 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/concatArrays.js +12 -6
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/filter.js +2 -1
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/first.js +10 -13
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/firstN.js +2 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/in.js +1 -1
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/indexOfArray.js +5 -10
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/isArray.js +2 -3
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/last.js +10 -13
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/lastN.js +2 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/map.js +2 -1
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/maxN.js +2 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/minN.js +2 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/reduce.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/reverseArray.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/sortArray.js +2 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/zip.js +4 -10
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/bitwise/_internal.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/bitwise/bitNot.js +2 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/boolean/not.js +4 -6
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/comparison/cmp.js +6 -5
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/conditional/cond.js +2 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/conditional/ifNull.js +1 -1
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/conditional/switch.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/date/_internal.js +140 -61
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/date/dateAdd.js +2 -35
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/date/dateDiff.js +43 -21
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/date/dateFromParts.js +2 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/date/dateFromString.js +13 -11
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/date/dateToString.js +2 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/date/dateTrunc.js +97 -0
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/date/dayOfYear.js +2 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/date/index.js +1 -0
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/date/isoWeekYear.js +2 -5
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/date/week.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/misc/getField.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/object/mergeObjects.js +10 -3
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/object/objectToArray.js +6 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/object/setField.js +11 -7
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/set/setDifference.js +10 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/set/setEquals.js +18 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/set/setIntersection.js +3 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/set/setIsSubset.js +16 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/set/setUnion.js +5 -6
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/string/_internal.js +4 -8
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/string/concat.js +6 -3
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/string/indexOfBytes.js +2 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/string/replaceAll.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/string/replaceOne.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/string/split.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/string/strcasecmp.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/string/substr.js +4 -14
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/string/substrBytes.js +2 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/trignometry/atan2.js +2 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/trignometry/cosh.js +0 -1
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/type/_internal.js +17 -11
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/type/convert.js +3 -5
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/type/toBool.js +2 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/type/toDate.js +4 -7
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/type/toDouble.js +6 -11
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/type/toInt.js +2 -5
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/type/toLong.js +2 -5
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/type/toString.js +12 -11
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/type/type.js +12 -15
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/addFields.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/bucket.js +54 -61
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/bucketAuto.js +679 -66
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/count.js +3 -3
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/densify.js +183 -0
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/graphLookup.js +55 -0
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/group.js +6 -9
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/index.js +2 -0
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/limit.js +1 -3
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/lookup.js +55 -11
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/merge.js +9 -14
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/out.js +2 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/project.js +21 -42
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/redact.js +3 -1
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/replaceWith.js +9 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/sample.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/setWindowFields.js +12 -23
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/skip.js +1 -1
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/sort.js +11 -20
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/sortByCount.js +5 -3
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/unionWith.js +2 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/unset.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/unwind.js +6 -9
- package/rust-client/node_modules/mingo/dist/esm/operators/projection/elemMatch.js +3 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/projection/slice.js +2 -3
- package/rust-client/node_modules/mingo/dist/esm/operators/query/bitwise/_internal.js +4 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/update/_internal.js +9 -14
- package/rust-client/node_modules/mingo/dist/esm/operators/update/addToSet.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/update/bit.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/update/max.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/update/min.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/update/pop.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/update/pull.js +2 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/update/push.js +3 -9
- package/rust-client/node_modules/mingo/dist/esm/operators/update/rename.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/update/set.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/update/unset.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/window/_internal.js +2 -3
- package/rust-client/node_modules/mingo/dist/esm/operators/window/denseRank.js +8 -10
- package/rust-client/node_modules/mingo/dist/esm/operators/window/derivative.js +4 -6
- package/rust-client/node_modules/mingo/dist/esm/operators/window/documentNumber.js +1 -3
- package/rust-client/node_modules/mingo/dist/esm/operators/window/expMovingAvg.js +4 -6
- package/rust-client/node_modules/mingo/dist/esm/operators/window/integral.js +3 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/window/linearFill.js +4 -6
- package/rust-client/node_modules/mingo/dist/esm/operators/window/locf.js +3 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/window/rank.js +8 -10
- package/rust-client/node_modules/mingo/dist/esm/operators/window/shift.js +2 -2
- package/rust-client/node_modules/mingo/dist/esm/query.js +22 -32
- package/rust-client/node_modules/mingo/dist/esm/types.js +14 -0
- package/rust-client/node_modules/mingo/dist/esm/updater.js +5 -5
- package/rust-client/node_modules/mingo/dist/esm/util.js +263 -377
- package/rust-client/node_modules/mingo/dist/types/aggregator.d.ts +7 -9
- package/rust-client/node_modules/mingo/dist/types/core.d.ts +41 -52
- package/rust-client/node_modules/mingo/dist/types/cursor.d.ts +6 -12
- package/rust-client/node_modules/mingo/dist/types/index.d.ts +8 -4
- package/rust-client/node_modules/mingo/dist/types/init/basic.d.ts +1 -6
- package/rust-client/node_modules/mingo/dist/types/lazy.d.ts +19 -15
- package/rust-client/node_modules/mingo/dist/types/operators/_predicates.d.ts +20 -20
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/accumulator.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/addToSet.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/avg.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/bottom.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/bottomN.d.ts +4 -4
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/count.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/covariancePop.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/covarianceSamp.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/first.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/firstN.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/last.d.ts +4 -4
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/lastN.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/max.d.ts +4 -5
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/maxN.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/mergeObjects.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/min.d.ts +4 -5
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/minN.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/percentile.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/push.d.ts +4 -4
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/stdDevPop.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/stdDevSamp.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/sum.d.ts +5 -3
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/top.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/topN.d.ts +4 -4
- package/rust-client/node_modules/mingo/dist/types/operators/expression/arithmetic/add.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/arithmetic/multiply.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/arithmetic/pow.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/arithmetic/subtract.d.ts +1 -0
- package/rust-client/node_modules/mingo/dist/types/operators/expression/array/arrayElemAt.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/array/concatArrays.d.ts +3 -3
- package/rust-client/node_modules/mingo/dist/types/operators/expression/array/filter.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/array/first.d.ts +0 -4
- package/rust-client/node_modules/mingo/dist/types/operators/expression/array/firstN.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/array/in.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/expression/array/indexOfArray.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/array/isArray.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/array/last.d.ts +0 -4
- package/rust-client/node_modules/mingo/dist/types/operators/expression/array/lastN.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/array/map.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/array/maxN.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/array/minN.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/array/range.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/array/reduce.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/expression/array/reverseArray.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/array/slice.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/date/_internal.d.ts +31 -9
- package/rust-client/node_modules/mingo/dist/types/operators/expression/date/dateFromString.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/expression/date/dateToParts.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/expression/date/dateTrunc.d.ts +12 -0
- package/rust-client/node_modules/mingo/dist/types/operators/expression/date/index.d.ts +1 -0
- package/rust-client/node_modules/mingo/dist/types/operators/expression/misc/rand.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/expression/object/mergeObjects.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/expression/percentile.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/set/setIsSubset.d.ts +3 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/string/_internal.d.ts +4 -4
- package/rust-client/node_modules/mingo/dist/types/operators/expression/string/indexOfBytes.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/string/replaceAll.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/string/replaceOne.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/string/split.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/string/strLenBytes.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/string/strLenCP.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/string/substrBytes.d.ts +2 -0
- package/rust-client/node_modules/mingo/dist/types/operators/expression/type/_internal.d.ts +6 -2
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/_internal.d.ts +4 -4
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/addFields.d.ts +8 -5
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/bucket.d.ts +8 -5
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/bucketAuto.d.ts +8 -7
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/count.d.ts +7 -5
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/densify.d.ts +12 -0
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/facet.d.ts +7 -1
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/fill.d.ts +6 -3
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/graphLookup.d.ts +13 -0
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/group.d.ts +4 -2
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/index.d.ts +2 -0
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/limit.d.ts +3 -1
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/lookup.d.ts +4 -2
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/match.d.ts +4 -3
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/merge.d.ts +3 -5
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/out.d.ts +5 -3
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/project.d.ts +4 -3
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/redact.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/replaceRoot.d.ts +5 -5
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/replaceWith.d.ts +8 -1
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/sample.d.ts +7 -5
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/setWindowFields.d.ts +7 -5
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/skip.d.ts +6 -4
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/sort.d.ts +5 -3
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/sortByCount.d.ts +5 -5
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/unionWith.d.ts +3 -1
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/unset.d.ts +2 -0
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/unwind.d.ts +5 -2
- package/rust-client/node_modules/mingo/dist/types/operators/query/evaluation/expr.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/query/evaluation/jsonSchema.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/query/evaluation/where.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/update/_internal.d.ts +5 -5
- package/rust-client/node_modules/mingo/dist/types/operators/update/addToSet.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/update/bit.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/update/currentDate.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/update/inc.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/update/max.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/update/min.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/update/mul.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/update/pop.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/update/pull.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/update/pullAll.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/update/push.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/update/rename.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/update/set.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/update/unset.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/window/_internal.d.ts +5 -5
- package/rust-client/node_modules/mingo/dist/types/operators/window/denseRank.d.ts +2 -3
- package/rust-client/node_modules/mingo/dist/types/operators/window/derivative.d.ts +2 -3
- package/rust-client/node_modules/mingo/dist/types/operators/window/documentNumber.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/window/expMovingAvg.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/window/integral.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/window/linearFill.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/window/locf.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/window/rank.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/window/shift.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/query.d.ts +5 -7
- package/rust-client/node_modules/mingo/dist/types/types.d.ts +18 -15
- package/rust-client/node_modules/mingo/dist/types/updater.d.ts +9 -10
- package/rust-client/node_modules/mingo/dist/types/util.d.ts +102 -90
- package/rust-client/node_modules/mingo/package.json +1 -1
|
@@ -1,58 +1,76 @@
|
|
|
1
1
|
import { computeValue } from "../../../core";
|
|
2
|
-
import { isDate, isNil, isNumber } from "../../../util";
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
181,
|
|
11
|
-
212,
|
|
12
|
-
243,
|
|
13
|
-
273,
|
|
14
|
-
304,
|
|
15
|
-
334
|
|
2
|
+
import { isDate, isNil, isNumber, MingoError } from "../../../util";
|
|
3
|
+
const LEAP_YEAR_REF_POINT = -1e9;
|
|
4
|
+
const DAYS_PER_WEEK = 7;
|
|
5
|
+
const isLeapYear = (y) => (y & 3) == 0 && (y % 100 != 0 || y % 400 == 0);
|
|
6
|
+
const DAYS_IN_YEAR = [
|
|
7
|
+
365,
|
|
8
|
+
366
|
|
9
|
+
/*leap*/
|
|
16
10
|
];
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
182,
|
|
25
|
-
|
|
26
|
-
244,
|
|
27
|
-
274,
|
|
28
|
-
305,
|
|
29
|
-
335
|
|
11
|
+
const daysInYear = (year) => DAYS_IN_YEAR[+isLeapYear(year)];
|
|
12
|
+
const DAYS_IN_MONTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
13
|
+
const daysInMonth = (d) => DAYS_IN_MONTH[d.getUTCMonth()] + Number(
|
|
14
|
+
d.getUTCMonth() === 1 && isLeapYear(d.getUTCFullYear())
|
|
15
|
+
);
|
|
16
|
+
const YEAR_DAYS_OFFSET = [
|
|
17
|
+
[0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334],
|
|
18
|
+
[0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335]
|
|
19
|
+
/*leap*/
|
|
30
20
|
];
|
|
21
|
+
const dayOfYear = (d) => YEAR_DAYS_OFFSET[+isLeapYear(d.getUTCFullYear())][d.getUTCMonth()] + d.getUTCDate();
|
|
22
|
+
const isoWeekday = (date, startOfWeek = "sun") => {
|
|
23
|
+
const dow = date.getUTCDay() || 7;
|
|
24
|
+
return (dow - ISO_WEEKDAY_MAP[startOfWeek] + DAYS_PER_WEEK) % DAYS_PER_WEEK;
|
|
25
|
+
};
|
|
31
26
|
const p = (y) => (y + Math.floor(y / 4) - Math.floor(y / 100) + Math.floor(y / 400)) % 7;
|
|
32
27
|
const weeks = (y) => 52 + Number(p(y) == 4 || p(y - 1) == 3);
|
|
33
|
-
const isLeapYear = (year) => (year & 3) == 0 && (year % 100 != 0 || year % 400 == 0);
|
|
34
|
-
const getDayOfYear = (d) => (isLeapYear(d.getUTCFullYear()) ? LEAP_YEAR_DAYS_OFFSET : COMMON_YEAR_DAYS_OFFSET)[d.getUTCMonth()] + d.getUTCDate();
|
|
35
28
|
function isoWeek(d) {
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (w > weeks(d.getUTCFullYear()))
|
|
40
|
-
return 1;
|
|
29
|
+
const dow = d.getUTCDay() || 7;
|
|
30
|
+
const w = Math.floor((10 + dayOfYear(d) - dow) / 7);
|
|
31
|
+
if (w < 1) return weeks(d.getUTCFullYear() - 1);
|
|
32
|
+
if (w > weeks(d.getUTCFullYear())) return 1;
|
|
41
33
|
return w;
|
|
42
34
|
}
|
|
43
35
|
function isoWeekYear(d) {
|
|
44
|
-
return d.getUTCFullYear() - Number(d.getUTCMonth()
|
|
36
|
+
return d.getUTCFullYear() - Number(d.getUTCMonth() === 0 && d.getUTCDate() == 1 && d.getUTCDay() < 1);
|
|
45
37
|
}
|
|
46
38
|
const MINUTES_PER_HOUR = 60;
|
|
47
39
|
const MILLIS_PER_DAY = 1e3 * 60 * 60 * 24;
|
|
48
|
-
const
|
|
49
|
-
week: MILLIS_PER_DAY *
|
|
40
|
+
const TIMEUNIT_IN_MILLIS = {
|
|
41
|
+
week: MILLIS_PER_DAY * DAYS_PER_WEEK,
|
|
50
42
|
day: MILLIS_PER_DAY,
|
|
51
43
|
hour: 1e3 * 60 * 60,
|
|
52
44
|
minute: 1e3 * 60,
|
|
53
45
|
second: 1e3,
|
|
54
46
|
millisecond: 1
|
|
55
47
|
};
|
|
48
|
+
const DAYS_OF_WEEK = [
|
|
49
|
+
"monday",
|
|
50
|
+
"mon",
|
|
51
|
+
"tuesday",
|
|
52
|
+
"tue",
|
|
53
|
+
"wednesday",
|
|
54
|
+
"wed",
|
|
55
|
+
"thursday",
|
|
56
|
+
"thu",
|
|
57
|
+
"friday",
|
|
58
|
+
"fri",
|
|
59
|
+
"saturday",
|
|
60
|
+
"sat",
|
|
61
|
+
"sunday",
|
|
62
|
+
"sun"
|
|
63
|
+
];
|
|
64
|
+
const DAYS_OF_WEEK_SET = new Set(DAYS_OF_WEEK);
|
|
65
|
+
const ISO_WEEKDAY_MAP = Object.freeze({
|
|
66
|
+
mon: 1,
|
|
67
|
+
tue: 2,
|
|
68
|
+
wed: 3,
|
|
69
|
+
thu: 4,
|
|
70
|
+
fri: 5,
|
|
71
|
+
sat: 6,
|
|
72
|
+
sun: 7
|
|
73
|
+
});
|
|
56
74
|
const DATE_FORMAT = "%Y-%m-%dT%H:%M:%S.%LZ";
|
|
57
75
|
const DATE_PART_INTERVAL = [
|
|
58
76
|
["year", 0, 9999],
|
|
@@ -63,7 +81,7 @@ const DATE_PART_INTERVAL = [
|
|
|
63
81
|
["second", 0, 59],
|
|
64
82
|
["millisecond", 0, 999]
|
|
65
83
|
];
|
|
66
|
-
const DATE_SYM_TABLE = {
|
|
84
|
+
const DATE_SYM_TABLE = Object.freeze({
|
|
67
85
|
"%Y": { name: "year", padding: 4, re: /([0-9]{4})/ },
|
|
68
86
|
"%G": { name: "year", padding: 4, re: /([0-9]{4})/ },
|
|
69
87
|
"%m": { name: "month", padding: 2, re: /(0[1-9]|1[012])/ },
|
|
@@ -82,13 +100,20 @@ const DATE_SYM_TABLE = {
|
|
|
82
100
|
},
|
|
83
101
|
"%Z": { name: "minuteOffset", padding: 3, re: /([+-][0-9]{3})/ }
|
|
84
102
|
// "%%": "%",
|
|
85
|
-
};
|
|
103
|
+
});
|
|
104
|
+
const TIMEZONE_RE = /^[a-zA-Z_]+\/[a-zA-Z_]+$/;
|
|
86
105
|
function parseTimezone(tzstr) {
|
|
87
|
-
if (isNil(tzstr))
|
|
88
|
-
|
|
106
|
+
if (isNil(tzstr)) return 0;
|
|
107
|
+
if (TIMEZONE_RE.test(tzstr)) {
|
|
108
|
+
const date = /* @__PURE__ */ new Date();
|
|
109
|
+
const utcDate = new Date(date.toLocaleString("en-US", { timeZone: "UTC" }));
|
|
110
|
+
const tzDate = new Date(date.toLocaleString("en-US", { timeZone: tzstr }));
|
|
111
|
+
return (tzDate.getTime() - utcDate.getTime()) / 6e4;
|
|
112
|
+
}
|
|
89
113
|
const m = DATE_SYM_TABLE["%z"].re.exec(tzstr);
|
|
90
|
-
if (!m)
|
|
91
|
-
throw
|
|
114
|
+
if (!m) {
|
|
115
|
+
throw new MingoError(`Timezone '${tzstr}' is invalid or not supported`);
|
|
116
|
+
}
|
|
92
117
|
const hr = parseInt(m[2]) || 0;
|
|
93
118
|
const min = parseInt(m[3]) || 0;
|
|
94
119
|
return (Math.abs(hr * MINUTES_PER_HOUR) + min) * (hr < 0 ? -1 : 1);
|
|
@@ -100,11 +125,10 @@ function adjustDate(d, minuteOffset) {
|
|
|
100
125
|
d.setUTCMinutes(d.getUTCMinutes() + minuteOffset);
|
|
101
126
|
}
|
|
102
127
|
function computeDate(obj, expr, options) {
|
|
128
|
+
if (isDate(obj)) return obj;
|
|
103
129
|
const d = computeValue(obj, expr, null, options);
|
|
104
|
-
if (isDate(d))
|
|
105
|
-
|
|
106
|
-
if (isNumber(d))
|
|
107
|
-
return new Date(d * 1e3);
|
|
130
|
+
if (isDate(d)) return new Date(d);
|
|
131
|
+
if (isNumber(d)) return new Date(d * 1e3);
|
|
108
132
|
if (d.date) {
|
|
109
133
|
const date = isDate(d.date) ? new Date(d.date) : new Date(d.date * 1e3);
|
|
110
134
|
if (d.timezone) {
|
|
@@ -112,36 +136,91 @@ function computeDate(obj, expr, options) {
|
|
|
112
136
|
}
|
|
113
137
|
return date;
|
|
114
138
|
}
|
|
115
|
-
throw Error(`cannot convert ${expr
|
|
139
|
+
throw Error(`cannot convert ${JSON.stringify(expr)} to date`);
|
|
116
140
|
}
|
|
117
141
|
function padDigits(n, digits) {
|
|
118
142
|
return new Array(Math.max(digits - String(n).length + 1, 0)).join("0") + n.toString();
|
|
119
143
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
144
|
+
const leapYearsSinceReferencePoint = (year) => {
|
|
145
|
+
const yearsSinceReferencePoint = year - LEAP_YEAR_REF_POINT;
|
|
146
|
+
return Math.trunc(yearsSinceReferencePoint / 4) - Math.trunc(yearsSinceReferencePoint / 100) + Math.trunc(yearsSinceReferencePoint / 400);
|
|
147
|
+
};
|
|
148
|
+
function daysBetweenYears(startYear, endYear) {
|
|
149
|
+
return Math.trunc(
|
|
150
|
+
leapYearsSinceReferencePoint(endYear - 1) - leapYearsSinceReferencePoint(startYear - 1) + (endYear - startYear) * DAYS_IN_YEAR[0]
|
|
151
|
+
);
|
|
128
152
|
}
|
|
153
|
+
const dateDiffYear = (start, end) => end.getUTCFullYear() - start.getUTCFullYear();
|
|
154
|
+
const dateDiffMonth = (start, end) => end.getUTCMonth() - start.getUTCMonth() + dateDiffYear(start, end) * 12;
|
|
155
|
+
const dateDiffQuarter = (start, end) => {
|
|
156
|
+
const a = Math.trunc(start.getUTCMonth() / 3);
|
|
157
|
+
const b = Math.trunc(end.getUTCMonth() / 3);
|
|
158
|
+
return b - a + dateDiffYear(start, end) * 4;
|
|
159
|
+
};
|
|
160
|
+
const dateDiffDay = (start, end) => dayOfYear(end) - dayOfYear(start) + daysBetweenYears(start.getUTCFullYear(), end.getUTCFullYear());
|
|
161
|
+
const dateDiffWeek = (start, end, startOfWeek) => {
|
|
162
|
+
const wk = (startOfWeek || "sun").substring(0, 3);
|
|
163
|
+
return Math.trunc(
|
|
164
|
+
(dateDiffDay(start, end) + isoWeekday(start, wk) - isoWeekday(end, wk)) / DAYS_PER_WEEK
|
|
165
|
+
);
|
|
166
|
+
};
|
|
167
|
+
const dateDiffHour = (start, end) => end.getUTCHours() - start.getUTCHours() + dateDiffDay(start, end) * 24;
|
|
168
|
+
const addMonth = (d, amount) => {
|
|
169
|
+
const m = d.getUTCMonth() + amount;
|
|
170
|
+
const yearOffset = Math.floor(m / 12);
|
|
171
|
+
if (m < 0) {
|
|
172
|
+
const month = m % 12 + 12;
|
|
173
|
+
d.setUTCFullYear(d.getUTCFullYear() + yearOffset, month, d.getUTCDate());
|
|
174
|
+
} else {
|
|
175
|
+
d.setUTCFullYear(d.getUTCFullYear() + yearOffset, m % 12, d.getUTCDate());
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
const dateAdd = (date, unit, amount, _timezone) => {
|
|
179
|
+
const d = new Date(date);
|
|
180
|
+
switch (unit) {
|
|
181
|
+
case "year":
|
|
182
|
+
d.setUTCFullYear(d.getUTCFullYear() + amount);
|
|
183
|
+
break;
|
|
184
|
+
case "quarter":
|
|
185
|
+
addMonth(d, 3 * amount);
|
|
186
|
+
break;
|
|
187
|
+
case "month":
|
|
188
|
+
addMonth(d, amount);
|
|
189
|
+
break;
|
|
190
|
+
default:
|
|
191
|
+
d.setTime(d.getTime() + TIMEUNIT_IN_MILLIS[unit] * amount);
|
|
192
|
+
}
|
|
193
|
+
return d;
|
|
194
|
+
};
|
|
129
195
|
export {
|
|
130
196
|
DATE_FORMAT,
|
|
131
197
|
DATE_PART_INTERVAL,
|
|
132
198
|
DATE_SYM_TABLE,
|
|
133
|
-
|
|
199
|
+
DAYS_OF_WEEK,
|
|
200
|
+
DAYS_OF_WEEK_SET,
|
|
201
|
+
DAYS_PER_WEEK,
|
|
202
|
+
LEAP_YEAR_REF_POINT,
|
|
134
203
|
MILLIS_PER_DAY,
|
|
135
204
|
MINUTES_PER_HOUR,
|
|
205
|
+
TIMEUNIT_IN_MILLIS,
|
|
136
206
|
adjustDate,
|
|
137
207
|
computeDate,
|
|
208
|
+
dateAdd,
|
|
209
|
+
dateDiffDay,
|
|
210
|
+
dateDiffHour,
|
|
211
|
+
dateDiffMonth,
|
|
212
|
+
dateDiffQuarter,
|
|
213
|
+
dateDiffWeek,
|
|
214
|
+
dateDiffYear,
|
|
215
|
+
dayOfYear,
|
|
216
|
+
daysBetweenYears,
|
|
217
|
+
daysInMonth,
|
|
218
|
+
daysInYear,
|
|
138
219
|
formatTimezone,
|
|
139
|
-
getDayOfYear,
|
|
140
220
|
isLeapYear,
|
|
141
221
|
isoWeek,
|
|
142
222
|
isoWeekYear,
|
|
223
|
+
isoWeekday,
|
|
143
224
|
padDigits,
|
|
144
|
-
parseTimezone
|
|
145
|
-
regexQuote,
|
|
146
|
-
regexStrip
|
|
225
|
+
parseTimezone
|
|
147
226
|
};
|
|
@@ -1,42 +1,9 @@
|
|
|
1
1
|
import { computeValue } from "../../../core";
|
|
2
|
-
import {
|
|
3
|
-
adjustDate,
|
|
4
|
-
computeDate,
|
|
5
|
-
DURATION_IN_MILLIS,
|
|
6
|
-
parseTimezone
|
|
7
|
-
} from "./_internal";
|
|
2
|
+
import { dateAdd } from "./_internal";
|
|
8
3
|
const $dateAdd = (obj, expr, options) => {
|
|
9
4
|
const args = computeValue(obj, expr, null, options);
|
|
10
|
-
|
|
11
|
-
switch (args.unit) {
|
|
12
|
-
case "year":
|
|
13
|
-
d.setUTCFullYear(d.getUTCFullYear() + args.amount);
|
|
14
|
-
break;
|
|
15
|
-
case "quarter":
|
|
16
|
-
addMonth(d, 3 * args.amount);
|
|
17
|
-
break;
|
|
18
|
-
case "month":
|
|
19
|
-
addMonth(d, args.amount);
|
|
20
|
-
break;
|
|
21
|
-
default:
|
|
22
|
-
d.setTime(d.getTime() + DURATION_IN_MILLIS[args.unit] * args.amount);
|
|
23
|
-
}
|
|
24
|
-
if (args.timezone) {
|
|
25
|
-
const tz = parseTimezone(args.timezone);
|
|
26
|
-
adjustDate(d, tz);
|
|
27
|
-
}
|
|
28
|
-
return d;
|
|
5
|
+
return dateAdd(args.startDate, args.unit, args.amount, args.timezone);
|
|
29
6
|
};
|
|
30
|
-
function addMonth(d, amount) {
|
|
31
|
-
const m = d.getUTCMonth() + amount;
|
|
32
|
-
const yearOffset = Math.floor(m / 12);
|
|
33
|
-
if (m < 0) {
|
|
34
|
-
const month = m % 12 + 12;
|
|
35
|
-
d.setUTCFullYear(d.getUTCFullYear() + yearOffset, month, d.getUTCDate());
|
|
36
|
-
} else {
|
|
37
|
-
d.setUTCFullYear(d.getUTCFullYear() + yearOffset, m % 12, d.getUTCDate());
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
7
|
export {
|
|
41
8
|
$dateAdd
|
|
42
9
|
};
|
|
@@ -1,32 +1,54 @@
|
|
|
1
1
|
import { computeValue } from "../../../core";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
adjustDate,
|
|
4
|
+
dateDiffDay,
|
|
5
|
+
dateDiffHour,
|
|
6
|
+
dateDiffMonth,
|
|
7
|
+
dateDiffQuarter,
|
|
8
|
+
dateDiffWeek,
|
|
9
|
+
dateDiffYear,
|
|
10
|
+
parseTimezone,
|
|
11
|
+
TIMEUNIT_IN_MILLIS
|
|
12
|
+
} from "./_internal";
|
|
3
13
|
const $dateDiff = (obj, expr, options) => {
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
14
|
+
const { startDate, endDate, unit, timezone, startOfWeek } = computeValue(
|
|
15
|
+
obj,
|
|
16
|
+
expr,
|
|
17
|
+
null,
|
|
18
|
+
options
|
|
19
|
+
);
|
|
20
|
+
const d1 = new Date(startDate);
|
|
21
|
+
const d2 = new Date(endDate);
|
|
22
|
+
const minuteOffset = parseTimezone(timezone);
|
|
23
|
+
adjustDate(d1, minuteOffset);
|
|
24
|
+
adjustDate(d2, minuteOffset);
|
|
25
|
+
switch (unit) {
|
|
9
26
|
case "year":
|
|
27
|
+
return dateDiffYear(d1, d2);
|
|
10
28
|
case "quarter":
|
|
29
|
+
return dateDiffQuarter(d1, d2);
|
|
11
30
|
case "month":
|
|
12
|
-
|
|
13
|
-
|
|
31
|
+
return dateDiffMonth(d1, d2);
|
|
32
|
+
case "week":
|
|
33
|
+
return dateDiffWeek(d1, d2, startOfWeek);
|
|
34
|
+
case "day":
|
|
35
|
+
return dateDiffDay(d1, d2);
|
|
36
|
+
case "hour":
|
|
37
|
+
return dateDiffHour(d1, d2);
|
|
38
|
+
case "minute":
|
|
39
|
+
d1.setUTCSeconds(0);
|
|
40
|
+
d1.setUTCMilliseconds(0);
|
|
41
|
+
d2.setUTCSeconds(0);
|
|
42
|
+
d2.setUTCMilliseconds(0);
|
|
43
|
+
return Math.round(
|
|
44
|
+
(d2.getTime() - d1.getTime()) / TIMEUNIT_IN_MILLIS[unit]
|
|
45
|
+
);
|
|
14
46
|
default:
|
|
15
|
-
|
|
47
|
+
return Math.round(
|
|
48
|
+
(d2.getTime() - d1.getTime()) / TIMEUNIT_IN_MILLIS[unit]
|
|
49
|
+
);
|
|
16
50
|
}
|
|
17
|
-
return diff;
|
|
18
51
|
};
|
|
19
|
-
const unitMonths = {
|
|
20
|
-
year: 12,
|
|
21
|
-
quarter: 3,
|
|
22
|
-
month: 1
|
|
23
|
-
};
|
|
24
|
-
function diffYQM(d1, d2, unit) {
|
|
25
|
-
let months = (d2.getUTCFullYear() - d1.getUTCFullYear()) * 12;
|
|
26
|
-
months -= d1.getUTCMonth();
|
|
27
|
-
months += d2.getUTCMonth();
|
|
28
|
-
return Math.trunc(months / unitMonths[unit]);
|
|
29
|
-
}
|
|
30
52
|
export {
|
|
31
53
|
$dateDiff
|
|
32
54
|
};
|
|
@@ -20,10 +20,8 @@ const $dateFromParts = (obj, expr, options) => {
|
|
|
20
20
|
let part = (args[k] || 0) + remainder;
|
|
21
21
|
remainder = 0;
|
|
22
22
|
const limit = max + 1;
|
|
23
|
-
if (k == "hour")
|
|
24
|
-
|
|
25
|
-
if (k == "minute")
|
|
26
|
-
part += minuteOffset % MINUTES_PER_HOUR * -1;
|
|
23
|
+
if (k == "hour") part += Math.floor(minuteOffset / MINUTES_PER_HOUR) * -1;
|
|
24
|
+
if (k == "minute") part += minuteOffset % MINUTES_PER_HOUR * -1;
|
|
27
25
|
if (part < min) {
|
|
28
26
|
const delta = min - part;
|
|
29
27
|
remainder = -1 * Math.ceil(delta / limit);
|
|
@@ -5,9 +5,7 @@ import {
|
|
|
5
5
|
DATE_FORMAT,
|
|
6
6
|
DATE_SYM_TABLE,
|
|
7
7
|
MINUTES_PER_HOUR,
|
|
8
|
-
parseTimezone
|
|
9
|
-
regexQuote,
|
|
10
|
-
regexStrip
|
|
8
|
+
parseTimezone
|
|
11
9
|
} from "./_internal";
|
|
12
10
|
const buildMap = (letters, sign) => {
|
|
13
11
|
const h = {};
|
|
@@ -19,13 +17,20 @@ const TZ_LETTER_OFFSETS = {
|
|
|
19
17
|
...buildMap("NOPQRSTUVWXY", -1),
|
|
20
18
|
Z: 0
|
|
21
19
|
};
|
|
20
|
+
const regexStrip = (s) => s.replace(/^\//, "").replace(/\/$/, "");
|
|
21
|
+
const REGEX_SPECIAL_CHARS = ["^", ".", "-", "*", "?", "$"];
|
|
22
|
+
const regexQuote = (s) => {
|
|
23
|
+
REGEX_SPECIAL_CHARS.forEach((c) => {
|
|
24
|
+
s = s.replace(c, `\\${c}`);
|
|
25
|
+
});
|
|
26
|
+
return s;
|
|
27
|
+
};
|
|
22
28
|
const $dateFromString = (obj, expr, options) => {
|
|
23
29
|
const args = computeValue(obj, expr, null, options);
|
|
24
30
|
args.format = args.format || DATE_FORMAT;
|
|
25
31
|
args.onNull = args.onNull || null;
|
|
26
32
|
let dateString = args.dateString;
|
|
27
|
-
if (isNil(dateString))
|
|
28
|
-
return args.onNull;
|
|
33
|
+
if (isNil(dateString)) return args.onNull;
|
|
29
34
|
const separators = args.format.split(/%[YGmdHMSLuVzZ]/);
|
|
30
35
|
separators.reverse();
|
|
31
36
|
const matches = args.format.match(
|
|
@@ -61,12 +66,9 @@ const $dateFromString = (obj, expr, options) => {
|
|
|
61
66
|
const d = new Date(
|
|
62
67
|
Date.UTC(dateParts.year, dateParts.month - 1, dateParts.day, 0, 0, 0)
|
|
63
68
|
);
|
|
64
|
-
if (!isNil(dateParts.hour))
|
|
65
|
-
|
|
66
|
-
if (!isNil(dateParts.
|
|
67
|
-
d.setUTCMinutes(dateParts.minute);
|
|
68
|
-
if (!isNil(dateParts.second))
|
|
69
|
-
d.setUTCSeconds(dateParts.second);
|
|
69
|
+
if (!isNil(dateParts.hour)) d.setUTCHours(dateParts.hour);
|
|
70
|
+
if (!isNil(dateParts.minute)) d.setUTCMinutes(dateParts.minute);
|
|
71
|
+
if (!isNil(dateParts.second)) d.setUTCSeconds(dateParts.second);
|
|
70
72
|
if (!isNil(dateParts.millisecond))
|
|
71
73
|
d.setUTCMilliseconds(dateParts.millisecond);
|
|
72
74
|
adjustDate(d, -minuteOffset);
|
|
@@ -34,10 +34,8 @@ const DATE_FUNCTIONS = {
|
|
|
34
34
|
};
|
|
35
35
|
const $dateToString = (obj, expr, options) => {
|
|
36
36
|
const args = computeValue(obj, expr, null, options);
|
|
37
|
-
if (isNil(args.onNull))
|
|
38
|
-
|
|
39
|
-
if (isNil(args.date))
|
|
40
|
-
return args.onNull;
|
|
37
|
+
if (isNil(args.onNull)) args.onNull = null;
|
|
38
|
+
if (isNil(args.date)) return args.onNull;
|
|
41
39
|
const date = computeDate(obj, args.date, options);
|
|
42
40
|
let format = args.format || DATE_FORMAT;
|
|
43
41
|
const minuteOffset = parseTimezone(args.timezone);
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { computeValue } from "../../../core";
|
|
2
|
+
import { TIME_UNITS } from "../../../types";
|
|
3
|
+
import { assert, isDate, isNil } from "../../../util";
|
|
4
|
+
import {
|
|
5
|
+
adjustDate,
|
|
6
|
+
dateAdd,
|
|
7
|
+
dateDiffDay,
|
|
8
|
+
dateDiffMonth,
|
|
9
|
+
dateDiffQuarter,
|
|
10
|
+
dateDiffWeek,
|
|
11
|
+
dateDiffYear,
|
|
12
|
+
DAYS_OF_WEEK_SET,
|
|
13
|
+
DAYS_PER_WEEK,
|
|
14
|
+
isoWeekday,
|
|
15
|
+
parseTimezone,
|
|
16
|
+
TIMEUNIT_IN_MILLIS
|
|
17
|
+
} from "./_internal";
|
|
18
|
+
const REF_DATE_MILLIS = 9466848e5;
|
|
19
|
+
const distanceToBinLowerBound = (value, binSize) => {
|
|
20
|
+
let remainder = value % binSize;
|
|
21
|
+
if (remainder < 0) {
|
|
22
|
+
remainder += binSize;
|
|
23
|
+
}
|
|
24
|
+
return remainder;
|
|
25
|
+
};
|
|
26
|
+
const DATE_DIFF_FN = {
|
|
27
|
+
day: dateDiffDay,
|
|
28
|
+
month: dateDiffMonth,
|
|
29
|
+
quarter: dateDiffQuarter,
|
|
30
|
+
year: dateDiffYear
|
|
31
|
+
};
|
|
32
|
+
const $dateTrunc = (obj, expr, options) => {
|
|
33
|
+
const {
|
|
34
|
+
date,
|
|
35
|
+
unit,
|
|
36
|
+
binSize: optBinSize,
|
|
37
|
+
timezone,
|
|
38
|
+
startOfWeek: optStartOfWeek
|
|
39
|
+
} = computeValue(obj, expr, null, options);
|
|
40
|
+
if (isNil(date) || isNil(unit)) return null;
|
|
41
|
+
const startOfWeek = (optStartOfWeek ?? "sun").toLowerCase().substring(0, 3);
|
|
42
|
+
assert(
|
|
43
|
+
isDate(date),
|
|
44
|
+
"$dateTrunc: 'date' must resolve to a valid Date object."
|
|
45
|
+
);
|
|
46
|
+
assert(TIME_UNITS.includes(unit), "$dateTrunc: unit is invalid.");
|
|
47
|
+
assert(
|
|
48
|
+
unit != "week" || DAYS_OF_WEEK_SET.has(startOfWeek),
|
|
49
|
+
`$dateTrunc: startOfWeek '${startOfWeek}' is not a valid.`
|
|
50
|
+
);
|
|
51
|
+
assert(
|
|
52
|
+
isNil(optBinSize) || optBinSize > 0,
|
|
53
|
+
"$dateTrunc requires 'binSize' to be greater than 0, but got value 0."
|
|
54
|
+
);
|
|
55
|
+
const binSize = optBinSize ?? 1;
|
|
56
|
+
switch (unit) {
|
|
57
|
+
case "millisecond":
|
|
58
|
+
case "second":
|
|
59
|
+
case "minute":
|
|
60
|
+
case "hour": {
|
|
61
|
+
const binSizeMillis = binSize * TIMEUNIT_IN_MILLIS[unit];
|
|
62
|
+
const shiftedDate = date.getTime() - REF_DATE_MILLIS;
|
|
63
|
+
return new Date(
|
|
64
|
+
date.getTime() - distanceToBinLowerBound(shiftedDate, binSizeMillis)
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
default: {
|
|
68
|
+
assert(binSize <= 1e11, "dateTrunc unsupported binSize value");
|
|
69
|
+
const d = new Date(date);
|
|
70
|
+
const refPointDate = new Date(REF_DATE_MILLIS);
|
|
71
|
+
let distanceFromRefPoint = 0;
|
|
72
|
+
if (unit == "week") {
|
|
73
|
+
const refPointDayOfWeek = isoWeekday(refPointDate, startOfWeek);
|
|
74
|
+
const daysToAdjustBy = (DAYS_PER_WEEK - refPointDayOfWeek) % DAYS_PER_WEEK;
|
|
75
|
+
refPointDate.setTime(
|
|
76
|
+
refPointDate.getTime() + daysToAdjustBy * TIMEUNIT_IN_MILLIS.day
|
|
77
|
+
);
|
|
78
|
+
distanceFromRefPoint = dateDiffWeek(refPointDate, d, startOfWeek);
|
|
79
|
+
} else {
|
|
80
|
+
distanceFromRefPoint = DATE_DIFF_FN[unit](refPointDate, d);
|
|
81
|
+
}
|
|
82
|
+
const binLowerBoundFromRefPoint = distanceFromRefPoint - distanceToBinLowerBound(distanceFromRefPoint, binSize);
|
|
83
|
+
const newDate = dateAdd(
|
|
84
|
+
refPointDate,
|
|
85
|
+
unit,
|
|
86
|
+
binLowerBoundFromRefPoint,
|
|
87
|
+
timezone
|
|
88
|
+
);
|
|
89
|
+
const minuteOffset = parseTimezone(timezone);
|
|
90
|
+
adjustDate(newDate, -minuteOffset);
|
|
91
|
+
return newDate;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
export {
|
|
96
|
+
$dateTrunc
|
|
97
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { computeDate,
|
|
1
|
+
import { computeDate, dayOfYear } from "./_internal";
|
|
2
2
|
const $dayOfYear = (obj, expr, options) => {
|
|
3
|
-
return
|
|
3
|
+
return dayOfYear(computeDate(obj, expr, options));
|
|
4
4
|
};
|
|
5
5
|
export {
|
|
6
6
|
$dayOfYear
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import { computeDate } from "./_internal";
|
|
2
|
-
const $isoWeekYear = (obj, expr, options) =>
|
|
3
|
-
const d = computeDate(obj, expr, options);
|
|
4
|
-
return d.getUTCFullYear() - Number(d.getUTCMonth() == 0 && d.getUTCDate() == 1 && d.getUTCDay() < 1);
|
|
5
|
-
};
|
|
1
|
+
import { computeDate, isoWeekYear } from "./_internal";
|
|
2
|
+
const $isoWeekYear = (obj, expr, options) => isoWeekYear(computeDate(obj, expr, options));
|
|
6
3
|
export {
|
|
7
4
|
$isoWeekYear
|
|
8
5
|
};
|
|
@@ -4,8 +4,7 @@ const $week = (obj, expr, options) => {
|
|
|
4
4
|
const result = isoWeek(d);
|
|
5
5
|
if (d.getUTCDay() > 0 && d.getUTCDate() == 1 && d.getUTCMonth() == 0)
|
|
6
6
|
return 0;
|
|
7
|
-
if (d.getUTCDay() == 0)
|
|
8
|
-
return result + 1;
|
|
7
|
+
if (d.getUTCDay() == 0) return result + 1;
|
|
9
8
|
return result;
|
|
10
9
|
};
|
|
11
10
|
export {
|
|
@@ -3,8 +3,7 @@ import { assert, isNil, isObject, isString } from "../../../util";
|
|
|
3
3
|
const $getField = (obj, expr, options) => {
|
|
4
4
|
const args = computeValue(obj, expr, null, options);
|
|
5
5
|
const [field, input] = isObject(args) ? [args.field, args.input || obj] : [args, obj];
|
|
6
|
-
if (isNil(input))
|
|
7
|
-
return null;
|
|
6
|
+
if (isNil(input)) return null;
|
|
8
7
|
assert(
|
|
9
8
|
isObject(input),
|
|
10
9
|
"$getField expression 'input' must evaluate to an object"
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
import { computeValue } from "../../../core";
|
|
2
|
-
import {
|
|
2
|
+
import { isNil } from "../../../util";
|
|
3
3
|
const $mergeObjects = (obj, expr, options) => {
|
|
4
|
-
const docs = computeValue(obj, expr, null, options);
|
|
5
|
-
|
|
4
|
+
const docs = computeValue(obj, expr, null, options) ?? [];
|
|
5
|
+
const acc = {};
|
|
6
|
+
for (const o of docs) {
|
|
7
|
+
if (isNil(o)) continue;
|
|
8
|
+
for (const k of Object.keys(o)) {
|
|
9
|
+
if (o[k] !== void 0) acc[k] = o[k];
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return acc;
|
|
6
13
|
};
|
|
7
14
|
export {
|
|
8
15
|
$mergeObjects
|
package/rust-client/node_modules/mingo/dist/esm/operators/expression/object/objectToArray.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { computeValue } from "../../../core";
|
|
2
|
-
import { assert, isObject } from "../../../util";
|
|
2
|
+
import { assert, isNil, isObject, typeOf } from "../../../util";
|
|
3
3
|
const $objectToArray = (obj, expr, options) => {
|
|
4
4
|
const val = computeValue(obj, expr, null, options);
|
|
5
|
-
|
|
5
|
+
if (isNil(val)) return null;
|
|
6
|
+
assert(
|
|
7
|
+
isObject(val),
|
|
8
|
+
`$objectToArray requires a document input, found: ${typeOf(val)}`
|
|
9
|
+
);
|
|
6
10
|
const entries = Object.entries(val);
|
|
7
11
|
const result = new Array(entries.length);
|
|
8
12
|
let i = 0;
|