corebasic 1.0.211 → 1.0.213

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 (167) hide show
  1. package/dist/index.js +10 -0
  2. package/dist/libs/ObjectId.js +114 -0
  3. package/dist/libs/auth.js +103 -0
  4. package/dist/libs/compression.js +11 -0
  5. package/dist/libs/cpp.js +154 -0
  6. package/dist/libs/dip/suffix/date.js +89 -0
  7. package/dist/libs/dip/suffix/index.js +227 -0
  8. package/dist/libs/dip/suffix/policy.js +113 -0
  9. package/dist/libs/dip/suffix/query.js +279 -0
  10. package/dist/libs/dip/suffix/suffix.js +99 -0
  11. package/dist/libs/dip/suffix/tests/date.test.js +187 -0
  12. package/dist/libs/dip/suffix/tests/index.test.js +441 -0
  13. package/dist/libs/dip/suffix/tests/policy.applySuffixPolicy.test.js +489 -0
  14. package/dist/libs/dip/suffix/tests/policy.test.js +329 -0
  15. package/dist/libs/dip/suffix/tests/suffix.test.js +316 -0
  16. package/dist/libs/dip.js +102 -0
  17. package/dist/libs/dipper.js +73 -0
  18. package/dist/libs/elabase.js +656 -0
  19. package/dist/libs/features.js +366 -0
  20. package/dist/libs/kafka.js +121 -0
  21. package/dist/libs/messaging.js +130 -0
  22. package/dist/libs/mobilecodes.js +562 -0
  23. package/dist/libs/session.js +96 -0
  24. package/dist/libs/utils.js +297 -0
  25. package/index.ts +23 -0
  26. package/libs/{auth.js → auth.ts} +3 -3
  27. package/libs/{compression.js → compression.ts} +1 -1
  28. package/libs/dip/suffix/date.ts +121 -0
  29. package/libs/dip/suffix/{index.js → index.ts} +7 -18
  30. package/libs/dip/suffix/{policy.js → policy.ts} +2 -2
  31. package/libs/dip/suffix/{suffix.js → suffix.ts} +2 -2
  32. package/libs/dip/suffix/tests/{date.test.js → date.test.ts} +1 -1
  33. package/libs/dip/suffix/tests/{index.test.js → index.test.ts} +1 -1
  34. package/libs/dip/suffix/tests/{policy.applySuffixPolicy.test.js → policy.applySuffixPolicy.test.ts} +1 -1
  35. package/libs/dip/suffix/tests/{policy.test.js → policy.test.ts} +1 -1
  36. package/libs/dip/suffix/tests/{suffix.test.js → suffix.test.ts} +1 -1
  37. package/libs/{dip.js → dip.ts} +1 -1
  38. package/libs/{elabase.js → elabase.ts} +4 -4
  39. package/libs/{features.js → features.ts} +5 -5
  40. package/libs/{messaging.js → messaging.ts} +1 -1
  41. package/libs/{session.js → session.ts} +2 -2
  42. package/libs/{utils.js → utils.ts} +80 -9
  43. package/package.json +3 -2
  44. package/tsc/@typescript/typescript-linux-x64/LICENSE +55 -0
  45. package/tsc/@typescript/typescript-linux-x64/NOTICE.txt +436 -0
  46. package/tsc/@typescript/typescript-linux-x64/README.md +3 -0
  47. package/tsc/@typescript/typescript-linux-x64/lib/lib.d.ts +20 -0
  48. package/tsc/@typescript/typescript-linux-x64/lib/lib.decorators.d.ts +382 -0
  49. package/tsc/@typescript/typescript-linux-x64/lib/lib.decorators.legacy.d.ts +20 -0
  50. package/tsc/@typescript/typescript-linux-x64/lib/lib.dom.asynciterable.d.ts +18 -0
  51. package/tsc/@typescript/typescript-linux-x64/lib/lib.dom.d.ts +45125 -0
  52. package/tsc/@typescript/typescript-linux-x64/lib/lib.dom.iterable.d.ts +18 -0
  53. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2015.collection.d.ts +159 -0
  54. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2015.core.d.ts +595 -0
  55. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2015.d.ts +26 -0
  56. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2015.generator.d.ts +75 -0
  57. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2015.iterable.d.ts +603 -0
  58. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2015.promise.d.ts +79 -0
  59. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2015.proxy.d.ts +126 -0
  60. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2015.reflect.d.ts +142 -0
  61. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2015.symbol.d.ts +44 -0
  62. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2015.symbol.wellknown.d.ts +324 -0
  63. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2016.array.include.d.ts +114 -0
  64. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2016.d.ts +19 -0
  65. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2016.full.d.ts +21 -0
  66. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2016.intl.d.ts +29 -0
  67. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2017.arraybuffer.d.ts +19 -0
  68. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2017.d.ts +24 -0
  69. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2017.date.d.ts +29 -0
  70. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2017.full.d.ts +21 -0
  71. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2017.intl.d.ts +42 -0
  72. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2017.object.d.ts +47 -0
  73. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2017.sharedmemory.d.ts +133 -0
  74. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2017.string.d.ts +47 -0
  75. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2017.typedarrays.d.ts +51 -0
  76. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2018.asyncgenerator.d.ts +75 -0
  77. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2018.asynciterable.d.ts +51 -0
  78. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2018.d.ts +22 -0
  79. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2018.full.d.ts +22 -0
  80. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2018.intl.d.ts +81 -0
  81. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2018.promise.d.ts +28 -0
  82. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2018.regexp.d.ts +35 -0
  83. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2019.array.d.ts +77 -0
  84. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2019.d.ts +22 -0
  85. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2019.full.d.ts +22 -0
  86. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2019.intl.d.ts +21 -0
  87. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2019.object.d.ts +31 -0
  88. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2019.string.d.ts +35 -0
  89. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2019.symbol.d.ts +22 -0
  90. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2020.bigint.d.ts +763 -0
  91. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2020.d.ts +25 -0
  92. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2020.date.d.ts +40 -0
  93. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2020.full.d.ts +22 -0
  94. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2020.intl.d.ts +472 -0
  95. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2020.number.d.ts +26 -0
  96. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2020.promise.d.ts +45 -0
  97. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2020.sharedmemory.d.ts +97 -0
  98. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2020.string.d.ts +42 -0
  99. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2020.symbol.wellknown.d.ts +39 -0
  100. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2021.d.ts +21 -0
  101. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2021.full.d.ts +22 -0
  102. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2021.intl.d.ts +164 -0
  103. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2021.promise.d.ts +46 -0
  104. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2021.string.d.ts +31 -0
  105. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2021.weakref.d.ts +76 -0
  106. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2022.array.d.ts +119 -0
  107. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2022.d.ts +23 -0
  108. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2022.error.d.ts +73 -0
  109. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2022.full.d.ts +22 -0
  110. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2022.intl.d.ts +143 -0
  111. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2022.object.d.ts +24 -0
  112. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2022.regexp.d.ts +37 -0
  113. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2022.string.d.ts +23 -0
  114. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2023.array.d.ts +922 -0
  115. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2023.collection.d.ts +19 -0
  116. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2023.d.ts +20 -0
  117. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2023.full.d.ts +22 -0
  118. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2023.intl.d.ts +62 -0
  119. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2024.arraybuffer.d.ts +63 -0
  120. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2024.collection.d.ts +27 -0
  121. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2024.d.ts +24 -0
  122. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2024.full.d.ts +22 -0
  123. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2024.object.d.ts +27 -0
  124. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2024.promise.d.ts +33 -0
  125. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2024.regexp.d.ts +23 -0
  126. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2024.sharedmemory.d.ts +66 -0
  127. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2024.string.d.ts +27 -0
  128. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2025.collection.d.ts +94 -0
  129. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2025.d.ts +23 -0
  130. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2025.float16.d.ts +443 -0
  131. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2025.full.d.ts +22 -0
  132. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2025.intl.d.ts +200 -0
  133. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2025.iterator.d.ts +146 -0
  134. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2025.promise.d.ts +32 -0
  135. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2025.regexp.d.ts +30 -0
  136. package/tsc/@typescript/typescript-linux-x64/lib/lib.es5.d.ts +4599 -0
  137. package/tsc/@typescript/typescript-linux-x64/lib/lib.es6.d.ts +21 -0
  138. package/tsc/@typescript/typescript-linux-x64/lib/lib.esnext.array.d.ts +33 -0
  139. package/tsc/@typescript/typescript-linux-x64/lib/lib.esnext.collection.d.ts +47 -0
  140. package/tsc/@typescript/typescript-linux-x64/lib/lib.esnext.d.ts +27 -0
  141. package/tsc/@typescript/typescript-linux-x64/lib/lib.esnext.date.d.ts +21 -0
  142. package/tsc/@typescript/typescript-linux-x64/lib/lib.esnext.decorators.d.ts +26 -0
  143. package/tsc/@typescript/typescript-linux-x64/lib/lib.esnext.disposable.d.ts +191 -0
  144. package/tsc/@typescript/typescript-linux-x64/lib/lib.esnext.error.d.ts +22 -0
  145. package/tsc/@typescript/typescript-linux-x64/lib/lib.esnext.full.d.ts +22 -0
  146. package/tsc/@typescript/typescript-linux-x64/lib/lib.esnext.intl.d.ts +107 -0
  147. package/tsc/@typescript/typescript-linux-x64/lib/lib.esnext.sharedmemory.d.ts +23 -0
  148. package/tsc/@typescript/typescript-linux-x64/lib/lib.esnext.temporal.d.ts +485 -0
  149. package/tsc/@typescript/typescript-linux-x64/lib/lib.esnext.typedarrays.d.ts +90 -0
  150. package/tsc/@typescript/typescript-linux-x64/lib/lib.scripthost.d.ts +320 -0
  151. package/tsc/@typescript/typescript-linux-x64/lib/lib.webworker.asynciterable.d.ts +18 -0
  152. package/tsc/@typescript/typescript-linux-x64/lib/lib.webworker.d.ts +15606 -0
  153. package/tsc/@typescript/typescript-linux-x64/lib/lib.webworker.importscripts.d.ts +21 -0
  154. package/tsc/@typescript/typescript-linux-x64/lib/lib.webworker.iterable.d.ts +18 -0
  155. package/tsc/@typescript/typescript-linux-x64/lib/tsc +0 -0
  156. package/tsc/@typescript/typescript-linux-x64/lib/tsc.sig +11 -0
  157. package/tsc/@typescript/typescript-linux-x64/package.json +45 -0
  158. package/tsc/notes +14 -0
  159. package/tsconfig.json +48 -0
  160. package/index.js +0 -23
  161. package/libs/dip/suffix/date.js +0 -103
  162. /package/libs/{ObjectId.js → ObjectId.ts} +0 -0
  163. /package/libs/{cpp.js → cpp.ts} +0 -0
  164. /package/libs/dip/suffix/{query.js → query.ts} +0 -0
  165. /package/libs/{dipper.js → dipper.ts} +0 -0
  166. /package/libs/{kafka.js → kafka.ts} +0 -0
  167. /package/libs/{mobilecodes.js → mobilecodes.ts} +0 -0
@@ -0,0 +1,441 @@
1
+ import { describe, test } from "node:test";
2
+ import assert from "node:assert/strict";
3
+ import { reduceRanges, extractBounds } from "../index.js";
4
+ // -----------------------------------------------------------------------------
5
+ // reduceRanges()
6
+ // -----------------------------------------------------------------------------
7
+ describe("reduceRanges()", () => {
8
+ test("reduceRanges: empty", () => {
9
+ assert.deepEqual(reduceRanges([]), []);
10
+ });
11
+ test("reduceRanges: primitive passthrough", () => {
12
+ assert.deepEqual(reduceRanges([1, "A", true]), [1, "A", true]);
13
+ });
14
+ test("reduceRanges: null passthrough", () => {
15
+ assert.deepEqual(reduceRanges([null]), [null]);
16
+ });
17
+ test("reduceRanges: array passthrough", () => {
18
+ assert.deepEqual(reduceRanges([[1, 2]]), [[1, 2]]);
19
+ });
20
+ test("reduceRanges: unknown object passthrough", () => {
21
+ assert.deepEqual(reduceRanges([
22
+ { $regex: "abc" }
23
+ ]), [
24
+ { $regex: "abc" }
25
+ ]);
26
+ });
27
+ test("reduceRanges: single $gt", () => {
28
+ assert.deepEqual(reduceRanges([
29
+ { $gt: 5 }
30
+ ]), [
31
+ { $gt: 5 }
32
+ ]);
33
+ });
34
+ test("reduceRanges: single $gte", () => {
35
+ assert.deepEqual(reduceRanges([
36
+ { $gte: 5 }
37
+ ]), [
38
+ { $gte: 5 }
39
+ ]);
40
+ });
41
+ test("reduceRanges: single $lt", () => {
42
+ assert.deepEqual(reduceRanges([
43
+ { $lt: 10 }
44
+ ]), [
45
+ { $lt: 10 }
46
+ ]);
47
+ });
48
+ test("reduceRanges: single $lte", () => {
49
+ assert.deepEqual(reduceRanges([
50
+ { $lte: 10 }
51
+ ]), [
52
+ { $lte: 10 }
53
+ ]);
54
+ });
55
+ test("reduceRanges: wider $gt kept", () => {
56
+ assert.deepEqual(reduceRanges([
57
+ { $gt: 5 },
58
+ { $gt: 10 }
59
+ ]), [
60
+ { $gt: 5 }
61
+ ]);
62
+ });
63
+ test("reduceRanges: wider $gte kept", () => {
64
+ assert.deepEqual(reduceRanges([
65
+ { $gte: 5 },
66
+ { $gte: 10 }
67
+ ]), [
68
+ { $gte: 5 }
69
+ ]);
70
+ });
71
+ test("reduceRanges: wider $lt kept", () => {
72
+ assert.deepEqual(reduceRanges([
73
+ { $lt: 20 },
74
+ { $lt: 10 }
75
+ ]), [
76
+ { $lt: 20 }
77
+ ]);
78
+ });
79
+ test("reduceRanges: wider $lte kept", () => {
80
+ assert.deepEqual(reduceRanges([
81
+ { $lte: 20 },
82
+ { $lte: 10 }
83
+ ]), [
84
+ { $lte: 20 }
85
+ ]);
86
+ });
87
+ test("reduceRanges: gt + gte", () => {
88
+ assert.deepEqual(reduceRanges([
89
+ { $gt: 5 },
90
+ { $gte: 10 }
91
+ ]), [
92
+ { $gt: 5 }
93
+ ]);
94
+ });
95
+ test("reduceRanges: gte + gt", () => {
96
+ assert.deepEqual(reduceRanges([
97
+ { $gte: 5 },
98
+ { $gt: 10 }
99
+ ]), [
100
+ { $gte: 5 }
101
+ ]);
102
+ });
103
+ test("reduceRanges: gt == gte", () => {
104
+ assert.deepEqual(reduceRanges([
105
+ { $gt: 5 },
106
+ { $gte: 5 }
107
+ ]), [
108
+ { $gte: 5 }
109
+ ]);
110
+ });
111
+ test("reduceRanges: lt + lte", () => {
112
+ assert.deepEqual(reduceRanges([
113
+ { $lt: 20 },
114
+ { $lte: 10 }
115
+ ]), [
116
+ { $lt: 20 }
117
+ ]);
118
+ });
119
+ test("reduceRanges: lte + lt", () => {
120
+ assert.deepEqual(reduceRanges([
121
+ { $lte: 20 },
122
+ { $lt: 10 }
123
+ ]), [
124
+ { $lte: 20 }
125
+ ]);
126
+ });
127
+ test("reduceRanges: lt == lte", () => {
128
+ assert.deepEqual(reduceRanges([
129
+ { $lt: 20 },
130
+ { $lte: 20 }
131
+ ]), [
132
+ { $lte: 20 }
133
+ ]);
134
+ });
135
+ test("reduceRanges: lower + upper", () => {
136
+ assert.deepEqual(reduceRanges([
137
+ { $gt: 5 },
138
+ { $lt: 20 }
139
+ ]), [
140
+ { $gt: 5 },
141
+ { $lt: 20 }
142
+ ]);
143
+ });
144
+ test("reduceRanges: mixed objects preserved", () => {
145
+ assert.deepEqual(reduceRanges([
146
+ { $gt: 5 },
147
+ { $regex: "abc" },
148
+ { $lt: 20 }
149
+ ]), [
150
+ { $regex: "abc" },
151
+ { $gt: 5 },
152
+ { $lt: 20 }
153
+ ]);
154
+ });
155
+ test("reduceRanges: duplicate gt", () => {
156
+ assert.deepEqual(reduceRanges([
157
+ { $gt: 5 },
158
+ { $gt: 5 }
159
+ ]), [
160
+ { $gt: 5 }
161
+ ]);
162
+ });
163
+ test("reduceRanges: duplicate lt", () => {
164
+ assert.deepEqual(reduceRanges([
165
+ { $lt: 10 },
166
+ { $lt: 10 }
167
+ ]), [
168
+ { $lt: 10 }
169
+ ]);
170
+ });
171
+ test("reduceRanges: negative values", () => {
172
+ assert.deepEqual(reduceRanges([
173
+ { $gt: -10 },
174
+ { $lt: -1 }
175
+ ]), [
176
+ { $gt: -10 },
177
+ { $lt: -1 }
178
+ ]);
179
+ });
180
+ test("reduceRanges: zero", () => {
181
+ assert.deepEqual(reduceRanges([
182
+ { $gte: 0 },
183
+ { $lte: 0 }
184
+ ]), [
185
+ { $gte: 0 },
186
+ { $lte: 0 }
187
+ ]);
188
+ });
189
+ test("reduceRanges: idempotent", () => {
190
+ const input = [
191
+ { $gt: 5 },
192
+ { $gt: 10 },
193
+ { $lt: 20 },
194
+ { $lt: 10 },
195
+ { $regex: "abc" }
196
+ ];
197
+ assert.deepEqual(reduceRanges(reduceRanges(input)), reduceRanges(input));
198
+ });
199
+ test("reduceRanges: widens lower bounds conservatively", () => {
200
+ assert.deepEqual(reduceRanges([
201
+ { $gte: 10 },
202
+ { $gte: 20 }
203
+ ]), [
204
+ { $gte: 10 }
205
+ ]);
206
+ });
207
+ test("reduceRanges: widens upper bounds conservatively", () => {
208
+ assert.deepEqual(reduceRanges([
209
+ { $lte: 50 },
210
+ { $lte: 100 }
211
+ ]), [
212
+ { $lte: 100 }
213
+ ]);
214
+ });
215
+ test("reduceRanges: prefers inclusive bound when values match as lower bound", () => {
216
+ assert.deepEqual(reduceRanges([
217
+ { $gt: 10 },
218
+ { $gte: 10 }
219
+ ]), [
220
+ { $gte: 10 }
221
+ ]);
222
+ });
223
+ test("reduceRanges: prefers inclusive bound when values match as upper bound", () => {
224
+ assert.deepEqual(reduceRanges([
225
+ { $lt: 10 },
226
+ { $lte: 10 }
227
+ ]), [
228
+ { $lte: 10 }
229
+ ]);
230
+ });
231
+ test("reduceRanges: keeps widest lower bound", () => {
232
+ assert.deepEqual(reduceRanges([
233
+ { $gt: 20 },
234
+ { $gte: 10 }
235
+ ]), [
236
+ { $gte: 10 }
237
+ ]);
238
+ });
239
+ test("reduceRanges: keeps widest upper bound", () => {
240
+ assert.deepEqual(reduceRanges([
241
+ { $lt: 50 },
242
+ { $lte: 100 }
243
+ ]), [
244
+ { $lte: 100 }
245
+ ]);
246
+ });
247
+ test("reduceRanges: preserves non-range values", () => {
248
+ assert.deepEqual(reduceRanges([
249
+ { $gte: 10 },
250
+ "hello",
251
+ { $exists: true }
252
+ ]), [
253
+ "hello",
254
+ { $exists: true },
255
+ { $gte: 10 }
256
+ ]);
257
+ });
258
+ });
259
+ // -----------------------------------------------------------------------------
260
+ // extractBounds()
261
+ // -----------------------------------------------------------------------------
262
+ describe("extractBounds()", () => {
263
+ test("extractBounds: empty", () => {
264
+ assert.deepEqual(extractBounds([]), {
265
+ values: [],
266
+ from: null,
267
+ to: null,
268
+ fromOp: null,
269
+ toOp: null,
270
+ });
271
+ });
272
+ test("extractBounds: primitives", () => {
273
+ assert.deepEqual(extractBounds([
274
+ 1,
275
+ "A"
276
+ ]), {
277
+ values: [
278
+ 1,
279
+ "A"
280
+ ],
281
+ from: null,
282
+ to: null,
283
+ fromOp: null,
284
+ toOp: null,
285
+ });
286
+ });
287
+ test("extractBounds: single gt", () => {
288
+ assert.deepEqual(extractBounds([
289
+ { $gt: 5 }
290
+ ]), {
291
+ values: [],
292
+ from: 5,
293
+ to: null,
294
+ fromOp: "$gt",
295
+ toOp: null,
296
+ });
297
+ });
298
+ test("extractBounds: single gte", () => {
299
+ assert.deepEqual(extractBounds([
300
+ { $gte: 5 }
301
+ ]), {
302
+ values: [],
303
+ from: 5,
304
+ to: null,
305
+ fromOp: "$gte",
306
+ toOp: null,
307
+ });
308
+ });
309
+ test("extractBounds: single lt", () => {
310
+ assert.deepEqual(extractBounds([
311
+ { $lt: 10 }
312
+ ]), {
313
+ values: [],
314
+ from: null,
315
+ to: 10,
316
+ fromOp: null,
317
+ toOp: "$lt",
318
+ });
319
+ });
320
+ test("extractBounds: single lte", () => {
321
+ assert.deepEqual(extractBounds([
322
+ { $lte: 10 }
323
+ ]), {
324
+ values: [],
325
+ from: null,
326
+ to: 10,
327
+ fromOp: null,
328
+ toOp: "$lte",
329
+ });
330
+ });
331
+ test("extractBounds: lower + upper", () => {
332
+ assert.deepEqual(extractBounds([
333
+ { $gt: 5 },
334
+ { $lt: 20 }
335
+ ]), {
336
+ values: [],
337
+ from: 5,
338
+ to: 20,
339
+ fromOp: "$gt",
340
+ toOp: "$lt",
341
+ });
342
+ });
343
+ test("extractBounds: unknown object preserved", () => {
344
+ assert.deepEqual(extractBounds([
345
+ { $regex: "abc" }
346
+ ]), {
347
+ values: [
348
+ { $regex: "abc" }
349
+ ],
350
+ from: null,
351
+ to: null,
352
+ fromOp: null,
353
+ toOp: null,
354
+ });
355
+ });
356
+ test("extractBounds: primitive + bounds", () => {
357
+ assert.deepEqual(extractBounds([
358
+ "Sales",
359
+ { $gt: 5 },
360
+ { $lt: 20 }
361
+ ]), {
362
+ values: [
363
+ "Sales"
364
+ ],
365
+ from: 5,
366
+ to: 20,
367
+ fromOp: "$gt",
368
+ toOp: "$lt",
369
+ });
370
+ });
371
+ test("extractBounds(reduceRanges()) planner pipeline", () => {
372
+ assert.deepEqual(extractBounds(reduceRanges([
373
+ { $gt: 5 },
374
+ { $gt: 10 },
375
+ { $lt: 20 },
376
+ { $lt: 10 }
377
+ ])), {
378
+ values: [],
379
+ from: 5,
380
+ to: 20,
381
+ fromOp: "$gt",
382
+ toOp: "$lt",
383
+ });
384
+ });
385
+ test("extractBounds(reduceRanges()) inclusive", () => {
386
+ assert.deepEqual(extractBounds(reduceRanges([
387
+ { $gt: 5 },
388
+ { $gte: 5 },
389
+ { $lt: 20 },
390
+ { $lte: 20 }
391
+ ])), {
392
+ values: [],
393
+ from: 5,
394
+ to: 20,
395
+ fromOp: "$gte",
396
+ toOp: "$lte",
397
+ });
398
+ });
399
+ test("extractBounds(reduceRanges()) inclusive 2", () => {
400
+ assert.deepEqual(extractBounds(reduceRanges([
401
+ { $gte: 5 },
402
+ { $gt: 5 },
403
+ { $lte: 20 },
404
+ { $lt: 20 },
405
+ ])), {
406
+ values: [],
407
+ from: 5,
408
+ to: 20,
409
+ fromOp: "$gte",
410
+ toOp: "$lte",
411
+ });
412
+ });
413
+ test("extractBounds(reduceRanges()) inclusive 3", () => {
414
+ assert.deepEqual(extractBounds(reduceRanges([
415
+ { $gt: 4 },
416
+ { $gte: 5 },
417
+ { $lt: 21 },
418
+ { $lte: 20 }
419
+ ])), {
420
+ values: [],
421
+ from: 4,
422
+ to: 21,
423
+ fromOp: "$gt",
424
+ toOp: "$lt",
425
+ });
426
+ });
427
+ test("extractBounds(reduceRanges()) inclusive 4", () => {
428
+ assert.deepEqual(extractBounds(reduceRanges([
429
+ { $gt: 5 },
430
+ { $gte: 4 },
431
+ { $lt: 20 },
432
+ { $lte: 21 }
433
+ ])), {
434
+ values: [],
435
+ from: 4,
436
+ to: 21,
437
+ fromOp: "$gte",
438
+ toOp: "$lte",
439
+ });
440
+ });
441
+ });