Remote / foldkit-remote-server

MutationSource

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

interface MutationSource<P, R = never> {
  readonly mutation: string
  readonly writes?: {
    readonly entity: string
    readonly writer: unknown
  }
  readonly Input: Schema.Codec<unknown>
  readonly Output: Schema.Codec<unknown>
  readonly Refusal: Schema.Codec<unknown, unknown>
  readonly run: (context: {
    readonly input: unknown
    readonly principal: P
    readonly requestId: string
    readonly keys?: ReadonlyArray<string> | undefined
  }) => Effect.Effect<
    {
      readonly output: unknown
      readonly entities: ReadonlyArray<NormalizedPatch>
      readonly connections: ReadonlyArray<ConnectionChange>
      readonly deleted: ReadonlyArray<{
        readonly entity: string
        readonly id: string
      }>
    },
    RemoteServerError | MutationRefused | RemoteForbidden,
    R
  >
}

Members

MutationSource.mutation

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

readonly mutation: string

MutationSource.writes

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

readonly writes?: {
  readonly entity: string
  readonly writer: unknown
}

For a declared write (RemoteServer.write), the Entity it writes and the writer it lands through, as it was given one. The server never reads it; a startup check such as GuardServer.validate does.

MutationSource.Input

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

readonly Input: Schema.Codec<unknown>

MutationSource.Output

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

readonly Output: Schema.Codec<unknown>

MutationSource.Refusal

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

readonly Refusal: Schema.Codec<unknown, unknown>

MutationSource.run

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

readonly run: (context: {
  readonly input: unknown
  readonly principal: P
  readonly requestId: string
  readonly keys?: ReadonlyArray<string> | undefined
}) => Effect.Effect<
  {
    readonly output: unknown
    readonly entities: ReadonlyArray<NormalizedPatch>
    readonly connections: ReadonlyArray<ConnectionChange>
    readonly deleted: ReadonlyArray<{
      readonly entity: string
      readonly id: string
    }>
  },
  RemoteServerError | MutationRefused | RemoteForbidden,
  R
>