Remote / foldkit-remote-server

EntitySource

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

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
}

Members

EntitySource.entity

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

readonly entity: string

EntitySource.fields

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

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:103

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

EntitySource.authorize

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

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:113

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:124

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:131

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.