feat: replace flat context with tuple-keyed store

Context keys are now tuples instead of strings, inspired by
React Query's query keys. This prevents context collisions
when multiple instances of the same source type are registered.

Sources write to structured keys like
["aris.google-calendar", "nextEvent", { account: "work" }]
and consumers can query by prefix via context.find().

Co-authored-by: Ona <no-reply@ona.com>
This commit is contained in:
2026-03-01 18:47:20 +00:00
parent 8ca8a0d1d2
commit 57b38cafaf
29 changed files with 544 additions and 227 deletions

View File

@@ -1,5 +1,4 @@
import type { Context } from "@aris/core"
import { Context } from "@aris/core"
import { LocationKey, type Location } from "@aris/source-location"
import { describe, expect, test } from "bun:test"
@@ -81,9 +80,9 @@ class FixtureTflApi implements ITflApi {
}
function createContext(location?: Location): Context {
const ctx: Context = { time: new Date("2026-01-15T12:00:00Z") }
const ctx = new Context(new Date("2026-01-15T12:00:00Z"))
if (location) {
ctx[LocationKey] = location
ctx.set([[LocationKey, location]])
}
return ctx
}