Remote / foldkit-remote-server

EntitySource

interface · packages/remote-server/src/index.ts:260

interface EntitySource<P, R = never> {
  readonly entity: string
  readonly fields?: ReadonlySet<string> | undefined
  readonly read: (
    context: EntitySourceContext<P>,
  ) => Effect.Effect<ReadonlyArray<EntityRecord>, RemoteServerError, R>
  readonly authorize?: (
    principal: P,
    fields: readonly string[],
  ) => readonly string[]
  readonly filter?: (
    principal: P,
    fields: readonly string[],
  ) => Effect.Effect<ReadPlan, RemoteServerError, R>
  readonly visible?: unknown
  readonly shared?: ReadonlySet<string> | undefined
  readonly perViewer?: ReadonlyArray<string> | undefined
  readonly cache?: CachePolicy | undefined
}

Members

EntitySource.entity

property · packages/remote-server/src/index.ts:261

readonly entity: string

EntitySource.fields

property · packages/remote-server/src/index.ts:263

readonly fields?: ReadonlySet<string> | undefined

The fields the entity declares; a request for any other never reaches read.

EntitySource.read

property · packages/remote-server/src/index.ts:264

readonly read: (
  context: EntitySourceContext<P>,
) => Effect.Effect<ReadonlyArray<EntityRecord>, RemoteServerError, R>

EntitySource.authorize

property · packages/remote-server/src/index.ts:268

readonly authorize?: (
  principal: P,
  fields: readonly string[],
) => readonly string[]

Returns the fields this principal may read; omitted means all requested.

EntitySource.filter

property · packages/remote-server/src/index.ts:274

readonly filter?: (
  principal: P,
  fields: readonly string[],
) => Effect.Effect<ReadPlan, RemoteServerError, R>

Decides, per record, what a principal sees of the fields authorize allowed: run once per read, before read. A member it drops from a record is settled unread, as one the source did not return.

EntitySource.visible

property · packages/remote-server/src/index.ts:285

readonly visible?: unknown

The rule that decides which rows this source returns, as it was given one (a Drizzle binding's visible, RemoteServer.memory's readable). The server never runs it: it is here so a check at startup, such as GuardServer.validate, can confirm a source applies the rule its Entity requires.

EntitySource.shared

property · packages/remote-server/src/index.ts:292

readonly shared?: ReadonlySet<string> | undefined

The fields every principal reads alike, of every row: no rule about who is asking hides the row or the field, or changes its value. A promise the server keeps by trusting it: the live hub sends a declared write's value of one to every subscriber as it is, with no read per principal.

EntitySource.perViewer

property · packages/remote-server/src/index.ts:298

readonly perViewer?: ReadonlyArray<string> | undefined

The members answered for whoever reads them (a Derived.exists): a server mounting this source must have a viewer, and refuses to be made without one.

EntitySource.cache

property · packages/remote-server/src/index.ts:304

readonly cache?: CachePolicy | undefined

How long a read of these rows stays fresh, from the Entity's declaration (EdgeCache.of). It never makes a read public: serveFetch caches one only where nothing about it depends on who asks.