@bjornpagen/bumbledb 1.3.1 → 2.0.0-rc.1

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 (290) hide show
  1. package/COOKBOOK.md +153 -77
  2. package/README.md +107 -41
  3. package/dist/alternatives.d.ts +5 -6
  4. package/dist/alternatives.d.ts.map +1 -1
  5. package/dist/alternatives.js +5 -6
  6. package/dist/alternatives.js.map +1 -1
  7. package/dist/bin.d.ts +3 -0
  8. package/dist/bin.d.ts.map +1 -0
  9. package/dist/bin.js +85 -0
  10. package/dist/bin.js.map +1 -0
  11. package/dist/capacity.d.ts +14 -17
  12. package/dist/capacity.d.ts.map +1 -1
  13. package/dist/capacity.js +7 -7
  14. package/dist/capacity.js.map +1 -1
  15. package/dist/changes.d.ts +32 -40
  16. package/dist/changes.d.ts.map +1 -1
  17. package/dist/changes.js +86 -104
  18. package/dist/changes.js.map +1 -1
  19. package/dist/closed.d.ts +2 -2
  20. package/dist/closed.d.ts.map +1 -1
  21. package/dist/closed.js +5 -5
  22. package/dist/closed.js.map +1 -1
  23. package/dist/codec.d.ts +13 -27
  24. package/dist/codec.d.ts.map +1 -1
  25. package/dist/codec.js +20 -21
  26. package/dist/codec.js.map +1 -1
  27. package/dist/compile.d.ts +26 -50
  28. package/dist/compile.d.ts.map +1 -1
  29. package/dist/compile.js +75 -64
  30. package/dist/compile.js.map +1 -1
  31. package/dist/database/database.d.ts +98 -0
  32. package/dist/database/database.d.ts.map +1 -0
  33. package/dist/database/database.js +249 -0
  34. package/dist/database/database.js.map +1 -0
  35. package/dist/database/driver.d.ts +40 -0
  36. package/dist/database/driver.d.ts.map +1 -0
  37. package/dist/database/driver.js +68 -0
  38. package/dist/database/driver.js.map +1 -0
  39. package/dist/database/fs.d.ts +12 -0
  40. package/dist/database/fs.d.ts.map +1 -0
  41. package/dist/database/fs.js +120 -0
  42. package/dist/database/fs.js.map +1 -0
  43. package/dist/database/generate.d.ts +26 -0
  44. package/dist/database/generate.d.ts.map +1 -0
  45. package/dist/database/generate.js +102 -0
  46. package/dist/database/generate.js.map +1 -0
  47. package/dist/database/hosted.d.ts +32 -0
  48. package/dist/database/hosted.d.ts.map +1 -0
  49. package/dist/database/hosted.js +44 -0
  50. package/dist/database/hosted.js.map +1 -0
  51. package/dist/database/io.d.ts +94 -0
  52. package/dist/database/io.d.ts.map +1 -0
  53. package/dist/database/io.js +35 -0
  54. package/dist/database/io.js.map +1 -0
  55. package/dist/database/mem.d.ts +26 -0
  56. package/dist/database/mem.d.ts.map +1 -0
  57. package/dist/database/mem.js +67 -0
  58. package/dist/database/mem.js.map +1 -0
  59. package/dist/database/migration.d.ts +55 -0
  60. package/dist/database/migration.d.ts.map +1 -0
  61. package/dist/database/migration.js +46 -0
  62. package/dist/database/migration.js.map +1 -0
  63. package/dist/database/s3.d.ts +36 -0
  64. package/dist/database/s3.d.ts.map +1 -0
  65. package/dist/database/s3.js +141 -0
  66. package/dist/database/s3.js.map +1 -0
  67. package/dist/db.d.ts +44 -128
  68. package/dist/db.d.ts.map +1 -1
  69. package/dist/db.js +163 -287
  70. package/dist/db.js.map +1 -1
  71. package/dist/engine.d.ts +7 -0
  72. package/dist/engine.d.ts.map +1 -0
  73. package/dist/engine.js +2 -0
  74. package/dist/engine.js.map +1 -0
  75. package/dist/errors.d.ts +152 -46
  76. package/dist/errors.d.ts.map +1 -1
  77. package/dist/errors.js +107 -19
  78. package/dist/errors.js.map +1 -1
  79. package/dist/face.d.ts +5 -5
  80. package/dist/face.d.ts.map +1 -1
  81. package/dist/face.js +6 -6
  82. package/dist/face.js.map +1 -1
  83. package/dist/fields.d.ts +4 -5
  84. package/dist/fields.d.ts.map +1 -1
  85. package/dist/fields.js +3 -3
  86. package/dist/fields.js.map +1 -1
  87. package/dist/index.d.ts +60 -57
  88. package/dist/index.d.ts.map +1 -1
  89. package/dist/index.js +27 -28
  90. package/dist/index.js.map +1 -1
  91. package/dist/judgment.d.ts +1 -1
  92. package/dist/judgment.js +1 -1
  93. package/dist/law.d.ts +16 -68
  94. package/dist/law.d.ts.map +1 -1
  95. package/dist/law.js +3 -3
  96. package/dist/law.js.map +1 -1
  97. package/dist/lower.d.ts +3 -3
  98. package/dist/lower.d.ts.map +1 -1
  99. package/dist/lower.js +35 -39
  100. package/dist/lower.js.map +1 -1
  101. package/dist/native/addon.d.ts +23 -0
  102. package/dist/native/addon.d.ts.map +1 -0
  103. package/dist/native/addon.js +15 -0
  104. package/dist/native/addon.js.map +1 -0
  105. package/dist/native/binding.d.ts +996 -0
  106. package/dist/native/json.d.ts +14 -0
  107. package/dist/native/json.d.ts.map +1 -0
  108. package/dist/native/json.js +73 -0
  109. package/dist/native/json.js.map +1 -0
  110. package/dist/native/load.d.ts +9 -0
  111. package/dist/native/load.d.ts.map +1 -0
  112. package/dist/native/load.js +30 -0
  113. package/dist/native/load.js.map +1 -0
  114. package/dist/native/op.d.ts +29 -0
  115. package/dist/native/op.d.ts.map +1 -0
  116. package/dist/native/op.js +50 -0
  117. package/dist/native/op.js.map +1 -0
  118. package/dist/query/atom.d.ts +13 -14
  119. package/dist/query/atom.d.ts.map +1 -1
  120. package/dist/query/atom.js +2 -2
  121. package/dist/query/atom.js.map +1 -1
  122. package/dist/query/compute.d.ts +4 -4
  123. package/dist/query/compute.d.ts.map +1 -1
  124. package/dist/query/compute.js +4 -4
  125. package/dist/query/compute.js.map +1 -1
  126. package/dist/query/find.d.ts +8 -8
  127. package/dist/query/find.d.ts.map +1 -1
  128. package/dist/query/find.js +1 -1
  129. package/dist/query/lower.d.ts +22 -17
  130. package/dist/query/lower.d.ts.map +1 -1
  131. package/dist/query/lower.js +230 -343
  132. package/dist/query/lower.js.map +1 -1
  133. package/dist/query/run.d.ts +5 -5
  134. package/dist/query/run.d.ts.map +1 -1
  135. package/dist/query/run.js +32 -15
  136. package/dist/query/run.js.map +1 -1
  137. package/dist/query/scope.d.ts +20 -28
  138. package/dist/query/scope.d.ts.map +1 -1
  139. package/dist/query/scope.js +7 -7
  140. package/dist/query/scope.js.map +1 -1
  141. package/dist/query/segments.d.ts +2 -2
  142. package/dist/query/segments.d.ts.map +1 -1
  143. package/dist/query/segments.js +3 -3
  144. package/dist/query/segments.js.map +1 -1
  145. package/dist/relation.d.ts +1 -1
  146. package/dist/relation.d.ts.map +1 -1
  147. package/dist/relation.js +4 -4
  148. package/dist/relation.js.map +1 -1
  149. package/dist/result.d.ts +15 -22
  150. package/dist/result.d.ts.map +1 -1
  151. package/dist/result.js +30 -39
  152. package/dist/result.js.map +1 -1
  153. package/dist/rows.d.ts +9 -33
  154. package/dist/rows.d.ts.map +1 -1
  155. package/dist/rows.js +8 -12
  156. package/dist/rows.js.map +1 -1
  157. package/dist/runtime.d.ts +17 -20
  158. package/dist/runtime.d.ts.map +1 -1
  159. package/dist/runtime.js +41 -205
  160. package/dist/runtime.js.map +1 -1
  161. package/dist/scalar.d.ts +4 -4
  162. package/dist/scalar.d.ts.map +1 -1
  163. package/dist/scalar.js +24 -8
  164. package/dist/scalar.js.map +1 -1
  165. package/dist/schema.d.ts +7 -18
  166. package/dist/schema.d.ts.map +1 -1
  167. package/dist/schema.js +18 -228
  168. package/dist/schema.js.map +1 -1
  169. package/dist/selection.d.ts +4 -4
  170. package/dist/selection.d.ts.map +1 -1
  171. package/dist/selection.js +5 -5
  172. package/dist/selection.js.map +1 -1
  173. package/dist/shape.d.ts +5 -5
  174. package/dist/shape.d.ts.map +1 -1
  175. package/dist/spec.d.ts +7 -79
  176. package/dist/spec.d.ts.map +1 -1
  177. package/dist/spec.js.map +1 -1
  178. package/dist/statements.d.ts +3 -3
  179. package/dist/statements.d.ts.map +1 -1
  180. package/dist/statements.js +10 -10
  181. package/dist/statements.js.map +1 -1
  182. package/dist/uuid.d.ts +1 -1
  183. package/dist/uuid.d.ts.map +1 -1
  184. package/dist/uuid.js +1 -1
  185. package/dist/uuid.js.map +1 -1
  186. package/dist/values.d.ts +2 -2
  187. package/dist/values.d.ts.map +1 -1
  188. package/dist/values.js +2 -2
  189. package/dist/values.js.map +1 -1
  190. package/package.json +18 -18
  191. package/src/alternatives.ts +7 -8
  192. package/src/bin.ts +82 -0
  193. package/src/capacity.ts +20 -23
  194. package/src/changes.ts +134 -191
  195. package/src/closed.ts +5 -5
  196. package/src/codec.ts +35 -49
  197. package/src/compile.ts +91 -113
  198. package/src/database/database.ts +413 -0
  199. package/src/database/driver.ts +134 -0
  200. package/src/database/fs.ts +119 -0
  201. package/src/database/generate.ts +116 -0
  202. package/src/database/hosted.ts +102 -0
  203. package/src/database/io.ts +134 -0
  204. package/src/database/mem.ts +113 -0
  205. package/src/database/migration.ts +107 -0
  206. package/src/database/s3.ts +231 -0
  207. package/src/db.ts +290 -547
  208. package/src/engine.ts +14 -0
  209. package/src/errors.ts +118 -39
  210. package/src/face.ts +9 -9
  211. package/src/fields.ts +6 -7
  212. package/src/index.ts +92 -105
  213. package/src/judgment.ts +1 -1
  214. package/src/law.ts +18 -70
  215. package/src/lower.ts +61 -72
  216. package/src/native/addon.ts +54 -0
  217. package/src/native/binding.d.ts +996 -0
  218. package/src/native/json.ts +100 -0
  219. package/src/native/load.ts +31 -0
  220. package/src/native/op.ts +73 -0
  221. package/src/query/atom.ts +15 -16
  222. package/src/query/compute.ts +7 -7
  223. package/src/query/find.ts +8 -8
  224. package/src/query/lower.ts +270 -392
  225. package/src/query/run.ts +42 -21
  226. package/src/query/scope.ts +29 -37
  227. package/src/query/segments.ts +4 -4
  228. package/src/relation.ts +4 -4
  229. package/src/result.ts +53 -80
  230. package/src/rows.ts +18 -46
  231. package/src/runtime.ts +50 -277
  232. package/src/scalar.ts +32 -12
  233. package/src/schema.ts +23 -284
  234. package/src/selection.ts +6 -6
  235. package/src/shape.ts +5 -5
  236. package/src/spec.ts +7 -85
  237. package/src/statements.ts +11 -11
  238. package/src/uuid.ts +1 -1
  239. package/src/values.ts +4 -4
  240. package/dist/close.d.ts +0 -24
  241. package/dist/close.d.ts.map +0 -1
  242. package/dist/close.js +0 -34
  243. package/dist/close.js.map +0 -1
  244. package/dist/db-native.d.ts +0 -189
  245. package/dist/db-native.d.ts.map +0 -1
  246. package/dist/db-native.js +0 -13
  247. package/dist/db-native.js.map +0 -1
  248. package/dist/internal/log.d.ts +0 -26
  249. package/dist/internal/log.d.ts.map +0 -1
  250. package/dist/internal/log.js +0 -12
  251. package/dist/internal/log.js.map +0 -1
  252. package/dist/native.d.ts +0 -562
  253. package/dist/native.d.ts.map +0 -1
  254. package/dist/native.js +0 -123
  255. package/dist/native.js.map +0 -1
  256. package/dist/query/description.d.ts +0 -41
  257. package/dist/query/description.d.ts.map +0 -1
  258. package/dist/query/description.js +0 -311
  259. package/dist/query/description.js.map +0 -1
  260. package/dist/query/parse-ir.d.ts +0 -10
  261. package/dist/query/parse-ir.d.ts.map +0 -1
  262. package/dist/query/parse-ir.js +0 -280
  263. package/dist/query/parse-ir.js.map +0 -1
  264. package/dist/runtime-codes.d.ts +0 -2
  265. package/dist/runtime-codes.d.ts.map +0 -1
  266. package/dist/runtime-codes.js +0 -19
  267. package/dist/runtime-codes.js.map +0 -1
  268. package/dist/runtime-errors.d.ts +0 -138
  269. package/dist/runtime-errors.d.ts.map +0 -1
  270. package/dist/runtime-errors.js +0 -111
  271. package/dist/runtime-errors.js.map +0 -1
  272. package/dist/runtime-native.d.ts +0 -136
  273. package/dist/runtime-native.d.ts.map +0 -1
  274. package/dist/runtime-native.js +0 -5
  275. package/dist/runtime-native.js.map +0 -1
  276. package/dist/schema-file.d.ts +0 -7
  277. package/dist/schema-file.d.ts.map +0 -1
  278. package/dist/schema-file.js +0 -24
  279. package/dist/schema-file.js.map +0 -1
  280. package/pack-provenance.json +0 -7
  281. package/src/close.ts +0 -53
  282. package/src/db-native.ts +0 -235
  283. package/src/internal/log.ts +0 -46
  284. package/src/native.ts +0 -736
  285. package/src/query/description.ts +0 -424
  286. package/src/query/parse-ir.ts +0 -293
  287. package/src/runtime-codes.ts +0 -18
  288. package/src/runtime-errors.ts +0 -122
  289. package/src/runtime-native.ts +0 -181
  290. package/src/schema-file.ts +0 -38
@@ -0,0 +1,100 @@
1
+ /**
2
+ * Spellings for the addon's JSON inputs. 64-bit integers cross as decimal strings, `f64` as its
3
+ * 16-hex-digit IEEE bit pattern (so -0, NaN and the infinities stay exact) and bytes as lowercase
4
+ * hex; JSON numbers only ever carry ordinals.
5
+ */
6
+ import type {
7
+ CapacityBoundSpec,
8
+ CapacityWindowSpec,
9
+ LiteralSetSpec,
10
+ LiteralSpec,
11
+ ValueSpec,
12
+ WeightSpec
13
+ } from "../spec.ts"
14
+ import { f64BitsHex } from "../spec.ts"
15
+ import type {
16
+ BoundSpecIn,
17
+ CapacityWindowSpecIn,
18
+ LiteralSetSpecIn,
19
+ LiteralSpecIn,
20
+ ValueIn,
21
+ WeightSpecIn
22
+ } from "./binding.d.ts"
23
+
24
+ function hex(bytes: Uint8Array): string {
25
+ let out = ""
26
+ for (const byte of bytes) out += byte.toString(16).padStart(2, "0")
27
+ return out
28
+ }
29
+
30
+ function valueIn(value: ValueSpec): ValueIn {
31
+ switch (value.kind) {
32
+ case "bool":
33
+ return { kind: "Bool", value: value.value }
34
+ case "u64":
35
+ return { kind: "U64", value: value.value.toString() }
36
+ case "i64":
37
+ return { kind: "I64", value: value.value.toString() }
38
+ case "f64":
39
+ return { kind: "F64", value: f64BitsHex(value.value) }
40
+ case "string":
41
+ return { kind: "String", value: value.value }
42
+ case "uuid":
43
+ return { kind: "Uuid", value: value.value }
44
+ case "fixedBytes":
45
+ return { kind: "FixedBytes", value: hex(value.value) }
46
+ case "intervalU64":
47
+ return { kind: "IntervalU64", start: value.start.toString(), end: value.end.toString() }
48
+ case "intervalI64":
49
+ return { kind: "IntervalI64", start: value.start.toString(), end: value.end.toString() }
50
+ case "intervalF64":
51
+ return { kind: "IntervalF64", start: f64BitsHex(value.start), end: f64BitsHex(value.end) }
52
+ }
53
+ }
54
+
55
+ function literalIn(literal: LiteralSpec): LiteralSpecIn {
56
+ return literal.kind === "handle"
57
+ ? { kind: "Handle", handle: literal.handle }
58
+ : { kind: "Value", value: valueIn(literal.value) }
59
+ }
60
+
61
+ function literalSetIn(set: LiteralSetSpec): LiteralSetSpecIn {
62
+ return set.kind === "one"
63
+ ? { kind: "One", literal: literalIn(set.literal) }
64
+ : { kind: "Many", literals: set.literals.map(literalIn) }
65
+ }
66
+
67
+ function boundIn(bound: CapacityBoundSpec): BoundSpecIn {
68
+ switch (bound.kind) {
69
+ case "lit":
70
+ return { kind: "Lit", value: bound.value.toString() }
71
+ case "field":
72
+ return { kind: "Field", field: bound.field }
73
+ case "durationField":
74
+ return { kind: "Duration", field: bound.field }
75
+ }
76
+ }
77
+
78
+ function windowIn(window: CapacityWindowSpec): CapacityWindowSpecIn {
79
+ switch (window.kind) {
80
+ case "exact":
81
+ return { kind: "Exact", n: boundIn(window.n) }
82
+ case "range":
83
+ return { kind: "Range", lo: boundIn(window.lo), hi: boundIn(window.hi) }
84
+ case "floor":
85
+ return { kind: "Floor", lo: boundIn(window.lo) }
86
+ }
87
+ }
88
+
89
+ function weightIn(weight: WeightSpec): WeightSpecIn {
90
+ switch (weight.kind) {
91
+ case "unit":
92
+ return { kind: "Unit" }
93
+ case "field":
94
+ return { kind: "Field", field: weight.field }
95
+ case "durationField":
96
+ return { kind: "Duration", field: weight.field }
97
+ }
98
+ }
99
+
100
+ export { literalIn, literalSetIn, valueIn, weightIn, windowIn }
@@ -0,0 +1,31 @@
1
+ import { existsSync } from "node:fs"
2
+ import { createRequire } from "node:module"
3
+ import { fileURLToPath } from "node:url"
4
+ import { NativeLoadError } from "../errors.ts"
5
+
6
+ const require = createRequire(import.meta.url)
7
+
8
+ /** The platforms that ship a prebuilt addon package. */
9
+ export const SHIPPED_PLATFORMS = ["darwin-arm64", "linux-arm64", "linux-x64"] as const
10
+
11
+ /**
12
+ * Loads the addon for `platform-arch`: a development build at the package root
13
+ * (`bdb.<platform>-<arch>.node`, written by `scripts/build.ts dev`) wins over the
14
+ * installed `@bjornpagen/bumbledb-<platform>-<arch>` package.
15
+ */
16
+ export function loadAddon<T>(platform: string, arch: string): T {
17
+ const target = `${platform}-${arch}`
18
+ const dev = fileURLToPath(new URL(`../../bdb.${target}.node`, import.meta.url))
19
+ const source = existsSync(dev) ? dev : `@bjornpagen/bumbledb-${target}`
20
+ try {
21
+ return require(source) as T
22
+ } catch (cause) {
23
+ throw new NativeLoadError({
24
+ target,
25
+ message: SHIPPED_PLATFORMS.some((shipped) => shipped === target)
26
+ ? `load the bumbledb addon from ${source}`
27
+ : `no bumbledb addon for ${target}; prebuilt addons ship for ${SHIPPED_PLATFORMS.join(", ")}`,
28
+ cause
29
+ })
30
+ }
31
+ }
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Effect over the addon's callback protocol. A native verb registers work and returns its lease
3
+ * before any completion can reach JS; the addon then calls back exactly once. Interruption cancels
4
+ * the lease and joins its drain, and a drain that does not close cleanly is a `CloseFailure`
5
+ * defect beside the interrupt.
6
+ */
7
+ import type { Scope } from "effect"
8
+ import { Effect } from "effect"
9
+ import type { DbError } from "../errors.ts"
10
+ import { CloseFailure, dbError } from "../errors.ts"
11
+ import type { OperationRef } from "./addon.ts"
12
+ import { addon } from "./addon.ts"
13
+ import type { CloseOut } from "./binding.d.ts"
14
+
15
+ /** Registers one native operation; the addon calls `done` once its result can be taken. */
16
+ type Start = (done: () => void) => OperationRef
17
+
18
+ /** Starts one native close or cancel transition; the addon reports how it drained. */
19
+ type Drain = (done: (report: CloseOut) => void) => void
20
+
21
+ /** Runs a native close or cancel transition to completion. It cannot be interrupted and never fails. */
22
+ function drain(start: Drain): Effect.Effect<CloseOut> {
23
+ return Effect.callback<CloseOut>((resume) => {
24
+ try {
25
+ start((report) => resume(Effect.succeed(report)))
26
+ } catch {
27
+ resume(Effect.succeed({ _tag: "Failed" }))
28
+ }
29
+ }).pipe(Effect.uninterruptible)
30
+ }
31
+
32
+ /** Drains, then dies with `CloseFailure` unless the transition closed cleanly. */
33
+ function release(operation: string, start: Drain): Effect.Effect<void> {
34
+ return Effect.flatMap(drain(start), (report) =>
35
+ report._tag === "Closed" ? Effect.void : Effect.die(new CloseFailure({ operation, report }))
36
+ )
37
+ }
38
+
39
+ /**
40
+ * One native operation. A completion that arrives after interruption is left to the cancel drain
41
+ * the interruption already started.
42
+ */
43
+ function call<A>(operation: string, start: Start, take: (lease: OperationRef) => A): Effect.Effect<A, DbError> {
44
+ return Effect.callback<A, DbError>((resume, signal) => {
45
+ let lease: OperationRef
46
+ try {
47
+ lease = start(() => {
48
+ if (signal.aborted) return
49
+ try {
50
+ resume(Effect.succeed(take(lease)))
51
+ } catch (cause) {
52
+ resume(Effect.fail(dbError(operation, cause)))
53
+ }
54
+ })
55
+ } catch (cause) {
56
+ resume(Effect.fail(dbError(operation, cause)))
57
+ return
58
+ }
59
+ return release(`${operation}.cancel`, (done) => addon.runtimeCancel(lease, done))
60
+ })
61
+ }
62
+
63
+ /** A native resource owned by the current scope, released by its native close transition. */
64
+ function scoped<A, E, R>(
65
+ operation: string,
66
+ acquire: Effect.Effect<A, E, R>,
67
+ close: (resource: A) => Drain
68
+ ): Effect.Effect<A, E, R | Scope.Scope> {
69
+ return Effect.acquireRelease(acquire, (resource) => release(operation, close(resource)), { interruptible: true })
70
+ }
71
+
72
+ export type { Drain, Start }
73
+ export { call, drain, release, scoped }
package/src/query/atom.ts CHANGED
@@ -1,7 +1,10 @@
1
- import { AuthoringError } from "#errors.ts"
2
- import type { AnyClosedRoster, AnyField, FloatIntervalValue, Infer, IntervalValue } from "#fields.ts"
3
- import type { ClassLookup, ClassRecordOf, SchemaClasses } from "#law.ts"
4
- import type { QueryNode } from "#query/compute.ts"
1
+ import { AuthoringError } from "../errors.ts"
2
+ import type { AnyClosedRoster, AnyField, FloatIntervalValue, Infer, IntervalValue } from "../fields.ts"
3
+ import type { ClassLookup, ClassRecordOf, SchemaClasses } from "../law.ts"
4
+ import type { FieldsShape } from "../relation.ts"
5
+ import type { ScalarKind } from "../scalar.ts"
6
+ import type { Uuid } from "../uuid.ts"
7
+ import type { QueryNode } from "./compute.ts"
5
8
  import type {
6
9
  AntiJoinOk,
7
10
  AnyVar,
@@ -14,12 +17,9 @@ import type {
14
17
  ParamValueAt,
15
18
  SetParam,
16
19
  ShapeOf
17
- } from "#query/scope.ts"
18
- import { isTerm, term } from "#query/scope.ts"
19
- import type { Segments } from "#query/segments.ts"
20
- import type { FieldsShape } from "#relation.ts"
21
- import type { ScalarKind } from "#scalar.ts"
22
- import type { Uuid } from "#uuid.ts"
20
+ } from "./scope.ts"
21
+ import { isTerm, term } from "./scope.ts"
22
+ import type { Segments } from "./segments.ts"
23
23
 
24
24
  type BindingTermData =
25
25
  | { readonly kind: "var"; readonly ref: AnyVar }
@@ -387,12 +387,11 @@ function not(
387
387
  * Whether a variable's OWN field is NUMERIC (u64/i64/f64) — the judgment the
388
388
  * point side of `pointIn` and the `sum` input read: a point lives in the
389
389
  * interval's element domain, and a quantifier is not an addition, so bool
390
- * (orderable, never numeric) is exactly here refused. A CLOSED reference
391
- * is excluded even though its kind is `u64`: a vocabulary's declaration-id
392
- * order is an accident, not semantics
393
- * § orderability), so every order-comparison and fold position refuses
394
- * closed-bound terms — the construction-time validations in
395
- * `#query/lower.ts` are that ban's runtime twin.
390
+ * (orderable, never numeric) is refused here. A CLOSED reference is
391
+ * excluded even though its kind is `u64`: a vocabulary's declaration-id
392
+ * order carries no meaning, so every order-comparison and fold position
393
+ * refuses closed-bound terms; `query/lower.ts` checks the same at
394
+ * construction.
396
395
  */
397
396
  type NumericVarOk<V extends AnyVar> = V["field"] extends { readonly closed: AnyClosedRoster }
398
397
  ? false
@@ -1,11 +1,9 @@
1
1
  /** Query scalar expressions use the same nodes that native preparation reads.
2
2
  * Distinct i64 and u64 kinds survive TypeScript's shared bigint carrier. */
3
- import { AuthoringError } from "#errors.ts"
4
- import type { AnyField } from "#fields.ts"
5
- import { bool as boolField, f64 as f64Field, i64 as i64Field, rosterOf, u64 as u64Field } from "#fields.ts"
6
- import type { AnyVar } from "#query/scope.ts"
7
- import { isTerm, term } from "#query/scope.ts"
8
- import type { Rounding, ScalarKind, ScalarLiteral, ScalarNode } from "#scalar.ts"
3
+ import { AuthoringError } from "../errors.ts"
4
+ import type { AnyField } from "../fields.ts"
5
+ import { bool as boolField, f64 as f64Field, i64 as i64Field, rosterOf, u64 as u64Field } from "../fields.ts"
6
+ import type { Rounding, ScalarKind, ScalarLiteral, ScalarNode } from "../scalar.ts"
9
7
  import {
10
8
  checkBool,
11
9
  checkF64,
@@ -22,7 +20,9 @@ import {
22
20
  scalarMeasure,
23
21
  scalarMulDiv,
24
22
  scalarNegate
25
- } from "#scalar.ts"
23
+ } from "../scalar.ts"
24
+ import type { AnyVar } from "./scope.ts"
25
+ import { isTerm, term } from "./scope.ts"
26
26
 
27
27
  /** Query expression, including interval leaves consumed by measure. */
28
28
  type QueryNode = ScalarNode
package/src/query/find.ts CHANGED
@@ -1,10 +1,10 @@
1
- import type { BoolField, F64Field, I64Field, Infer, IntervalField, U64Field } from "#fields.ts"
2
- import type { SchemaClasses } from "#law.ts"
3
- import type { IntervalVarOk, NumericVarOk } from "#query/atom.ts"
4
- import type { AnyComputeExpr, ComputeExpr, ComputeValue } from "#query/compute.ts"
5
- import type { AnyVar, MintSlotOf } from "#query/scope.ts"
6
- import type { Segments } from "#query/segments.ts"
7
- import type { ScalarKind } from "#scalar.ts"
1
+ import type { BoolField, F64Field, I64Field, Infer, IntervalField, U64Field } from "../fields.ts"
2
+ import type { SchemaClasses } from "../law.ts"
3
+ import type { ScalarKind } from "../scalar.ts"
4
+ import type { IntervalVarOk, NumericVarOk } from "./atom.ts"
5
+ import type { AnyComputeExpr, ComputeExpr, ComputeValue } from "./compute.ts"
6
+ import type { AnyVar, MintSlotOf } from "./scope.ts"
7
+ import type { Segments } from "./segments.ts"
8
8
 
9
9
  type FoldOpName = "sum" | "mean" | "min" | "max" | "pack"
10
10
 
@@ -35,7 +35,7 @@ function count(): CountAgg {
35
35
  * Exact checked sum over a NUMERIC (u64/i64/f64) variable — wide accumulator,
36
36
  * one finalize range check; overflow is the engine's typed runtime error —
37
37
  * of a measured interval in a following stage. Bool stays refused: a
38
- * quantifier is not an addition (R3).
38
+ * quantifier is not an addition.
39
39
  */
40
40
  function sum<const O extends AnyVar>(over: O): Agg<"sum", O> {
41
41
  return aggregate("sum", over)