Remote / foldkit-remote-server

MutationSource

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

interface MutationSource<P, R = never> {
  readonly mutation: string
  readonly writes?: {
    readonly entity: string
    readonly writer: unknown
    readonly write: AnyWrite
  }
  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 viewer: Option.Option<EntityRef>
    readonly requestId: string
    readonly operation: Option.Option<string>
    readonly now: number
    readonly read: (
      ref: EntityRef,
      fields: ReadonlyArray<string>,
    ) => Effect.Effect<
      Option.Option<Readonly<Record<string, unknown>>>,
      RemoteServerError
    >
    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
      }>
      readonly pointed?: ReadonlyArray<{
        readonly entity: string
        readonly id: string
      }>
    },
    | RemoteServerError
    | MutationRefused
    | RemoteForbidden
    | RemoteUnauthenticated,
    R
  >
}

Members

MutationSource.mutation

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

readonly mutation: string

MutationSource.writes

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

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

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

MutationSource.Input

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

readonly Input: Schema.Codec<unknown>

MutationSource.Output

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

readonly Output: Schema.Codec<unknown>

MutationSource.Refusal

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

readonly Refusal: Schema.Codec<unknown, unknown>

MutationSource.run

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

readonly run: (context: {
  readonly input: unknown
  readonly principal: P
  readonly viewer: Option.Option<EntityRef>
  readonly requestId: string
  readonly operation: Option.Option<string>
  readonly now: number
  readonly read: (
    ref: EntityRef,
    fields: ReadonlyArray<string>,
  ) => Effect.Effect<
    Option.Option<Readonly<Record<string, unknown>>>,
    RemoteServerError
  >
  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
    }>
    readonly pointed?: ReadonlyArray<{
      readonly entity: string
      readonly id: string
    }>
  },
  | RemoteServerError
  | MutationRefused
  | RemoteForbidden
  | RemoteUnauthenticated,
  R
>