mirror of
https://github.com/kennethnym/aris.git
synced 2026-02-02 13:11:17 +00:00
feat(core): add FeedController orchestration layer
Adds orchestration for feed reconciliation with context-driven updates: - FeedController: holds context, debounces updates, reconciles sources - ContextBridge: bridges context providers to controller - ContextProvider: reactive + on-demand context value interface - Branded ContextKey<T> for type-safe context keys Moves source files to src/ directory and consolidates tests into integration test. Co-authored-by: Ona <no-reply@ona.com>
This commit is contained in:
35
packages/aris-core/src/data-source.ts
Normal file
35
packages/aris-core/src/data-source.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import type { Context } from "./context"
|
||||
import type { FeedItem } from "./feed"
|
||||
|
||||
/**
|
||||
* Produces feed items from an external source.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* type WeatherItem = FeedItem<"weather", { temp: number }>
|
||||
*
|
||||
* class WeatherDataSource implements DataSource<WeatherItem> {
|
||||
* readonly type = "weather"
|
||||
*
|
||||
* async query(context: Context): Promise<WeatherItem[]> {
|
||||
* const location = contextValue(context, LocationKey)
|
||||
* if (!location) return []
|
||||
* const data = await fetchWeather(location)
|
||||
* return [{
|
||||
* id: `weather-${Date.now()}`,
|
||||
* type: this.type,
|
||||
* priority: 0.5,
|
||||
* timestamp: context.time,
|
||||
* data: { temp: data.temperature },
|
||||
* }]
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
export interface DataSource<TItem extends FeedItem = FeedItem, TConfig = unknown> {
|
||||
/** Unique identifier for this source type */
|
||||
readonly type: TItem["type"]
|
||||
|
||||
/** Queries the source and returns feed items */
|
||||
query(context: Context, config: TConfig): Promise<TItem[]>
|
||||
}
|
||||
Reference in New Issue
Block a user