mirror of
https://github.com/kennethnym/aris.git
synced 2026-03-20 17:11:17 +00:00
feat: add post-processor pipeline to FeedEngine (#41)
* feat: add post-processor pipeline to FeedEngine Add FeedPostProcessor type and FeedEnhancement interface. Post-processors run after item collection on all update paths (refresh, reactive context, reactive items). Pipeline is chained — each processor sees items as modified by the previous one. Enhancement merging handles additional items, suppression, and grouped items. Throwing processors are caught and recorded in FeedResult.errors. Co-authored-by: Ona <no-reply@ona.com> * docs: document intentional TItems cast in post-processor merge Co-authored-by: Ona <no-reply@ona.com> * fix: filter stale item IDs from groups after pipeline Groups accumulated during the pipeline can reference items that a later processor suppressed. The engine now strips stale IDs and drops empty groups before returning. Co-authored-by: Ona <no-reply@ona.com> * refactor: use reduce for stale group filtering Co-authored-by: Ona <no-reply@ona.com> --------- Co-authored-by: Ona <no-reply@ona.com>
This commit is contained in:
23
packages/aris-core/src/feed-post-processor.ts
Normal file
23
packages/aris-core/src/feed-post-processor.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import type { FeedItem } from "./feed"
|
||||
|
||||
export interface ItemGroup {
|
||||
/** IDs of items to present together */
|
||||
itemIds: string[]
|
||||
/** Summary text for the group */
|
||||
summary: string
|
||||
}
|
||||
|
||||
export interface FeedEnhancement {
|
||||
/** New items to inject into the feed */
|
||||
additionalItems?: FeedItem[]
|
||||
/** Groups of items to present together with a summary */
|
||||
groupedItems?: ItemGroup[]
|
||||
/** Item IDs to remove from the feed */
|
||||
suppress?: string[]
|
||||
}
|
||||
|
||||
/**
|
||||
* A function that transforms feed items and produces enhancement directives.
|
||||
* Use named functions for meaningful error attribution.
|
||||
*/
|
||||
export type FeedPostProcessor = (items: FeedItem[]) => Promise<FeedEnhancement>
|
||||
Reference in New Issue
Block a user