feat(api): resolve endpoint resources and filter lists by access
This commit is contained in:
1 parent
d7bd68ee7a
commit
2640d3df82
21 files changed
+527
-21
No files matched your search
@@ -15,6 +15,9 @@ import type {
|
||||
WorkspaceView,
|
||||
} from './types.ts'
|
||||
|
||||
/** The frames the feed produces: every follow frame except `replace`, which only access filtering sends. */
|
||||
type WorkspaceFeedFrame = Exclude<WorkspaceFollowFrame, { readonly type: 'replace' }>
|
||||
|
||||
/**
|
||||
* Project one authoritative Workspace entity into its Remote value.
|
||||
* @param workspace - authoritative registry entity.
|
||||
@@ -82,7 +85,7 @@ export class WorkspaceFeed {
|
||||
* @param signal - generation cancellation.
|
||||
* @returns baseline followed by ordered Workspace increments.
|
||||
*/
|
||||
async *follow(signal: AbortSignal): AsyncIterable<WorkspaceFollowFrame> {
|
||||
async *follow(signal: AbortSignal): AsyncIterable<WorkspaceFeedFrame> {
|
||||
signal.throwIfAborted()
|
||||
const follower = new WorkspaceFollower()
|
||||
this.followers.add(follower)
|
||||
@@ -138,7 +141,7 @@ export class WorkspaceFeed {
|
||||
})
|
||||
}
|
||||
|
||||
private publish(frame: Exclude<WorkspaceFollowFrame, { readonly type: 'baseline' }>): void {
|
||||
private publish(frame: Exclude<WorkspaceFeedFrame, { readonly type: 'baseline' }>): void {
|
||||
for (const follower of this.followers) follower.push(frame)
|
||||
}
|
||||
}
|
||||
@@ -148,11 +151,11 @@ function sameStrings(left: readonly string[], right: readonly string[]): boolean
|
||||
}
|
||||
|
||||
class WorkspaceFollower {
|
||||
private readonly frames = new Deque<WorkspaceFollowFrame>()
|
||||
private readonly frames = new Deque<WorkspaceFeedFrame>()
|
||||
private waiting: (() => void) | undefined
|
||||
private closed = false
|
||||
|
||||
push(frame: WorkspaceFollowFrame): void {
|
||||
push(frame: WorkspaceFeedFrame): void {
|
||||
/* v8 ignore next -- closed followers are removed before later publication can reach them. */
|
||||
if (this.closed) return
|
||||
this.frames.pushBack(frame)
|
||||
@@ -165,7 +168,7 @@ class WorkspaceFollower {
|
||||
this.waiting?.()
|
||||
}
|
||||
|
||||
async *read(signal: AbortSignal): AsyncIterable<WorkspaceFollowFrame> {
|
||||
async *read(signal: AbortSignal): AsyncIterable<WorkspaceFeedFrame> {
|
||||
while (!this.closed && !signal.aborted) {
|
||||
const frame = this.frames.popFront()
|
||||
if (frame !== undefined) {
|
||||
|
||||
Reference in new issue
Block a user