Remote / foldkit-remote-domain

DomainRemote

namespace · packages/remote-domain/src/index.ts:22

const DomainRemote = {
  view,
  command,
  query,
  refuse,
  forbid,
  unauthenticated,
  fail,
  layer,
}

A Domain Api as Remote's authority: layer answers RemoteClient from the Api's client, through Views bound to Entities (view) and commands bound to mutations (command), and lists bound to paged Queries (query), each Rejection answered as refuse, forbid, unauthenticated or fail says.

In the guides

Members

DomainRemote.view

function · packages/remote-domain/src/adapter/binding.ts:212

view<E extends AnyEntity, A extends AnyApi, const Name extends ViewNameOf<A>>(
  entity: E,
  api: A,
  name: Name,
  config: ViewConfig<E>,
): ViewBinding<E, A>

Binds a View to the Entity whose rows it serves. Throws, naming it, for a View the Api does not serve, an Entity field its state lacks, or a revision the Entity does not store as a number.

DomainRemote.command

function · packages/remote-domain/src/adapter/binding.ts:286

command<
  M extends AnyMutation,
  A extends AnyApi,
  const Name extends CommandNameOf<A>,
  Given extends AnyEntity = never,
>(
  mutation: M,
  api: A,
  name: Name,
  config: CommandConfig<M, CommandOf<A, Name>, EntityOfMutation<M, Given>>,
): CommandBinding<M, A>

Binds a command to the mutation it lands. Throws, naming it, for a command the Api does not serve, and for written on an Entity whose reader may not be every writer.

DomainRemote.query

function · packages/remote-domain/src/adapter/query.ts:84

query<
  D extends AnyListQuery,
  A extends AnyApi,
  const Name extends PagedQueryNameOf<A>,
>(
  descriptor: D,
  api: A,
  name: Name,
  config: QueryConfig<D, DomainQueryOf<A, Name>>,
): QueryBinding<D, A>

Binds a Remote query to the paged Domain Query that answers it. Throws, naming it, for a Query the Api does not serve or one that is not paged.

DomainRemote.refuse

function · packages/remote-domain/src/adapter/binding.ts:323

refuse<const R>(refusal: R): Refuse<R>

Answers a Rejection as the mutation's own Refusal.

DomainRemote.forbid

function · packages/remote-domain/src/adapter/binding.ts:326

forbid(reason?: string): Forbid

Answers a Rejection as RemoteForbidden, with words for who asked when given.

DomainRemote.unauthenticated

function · packages/remote-domain/src/adapter/binding.ts:332

unauthenticated(reason?: string): Unauthenticated

Answers a Rejection as RemoteUnauthenticated: who asks must sign in first.

DomainRemote.fail

function · packages/remote-domain/src/adapter/binding.ts:338

fail(message: string): Fail

Answers a Rejection as a RemoteMutationError with no refusal to match on.

DomainRemote.layer

function · packages/remote-domain/src/adapter/layer.ts:141

layer<A extends AnyApi>(
  api: A,
  config: LayerConfig<A>,
): Layer.Layer<RemoteClient, never, ClientIdentifier<A>>

A RemoteClient answered from the Api's client. Reads and live reads go to the bound Views; writes to the bound commands, each under a commandId derived from who asks and what, so a retry is the same command and nothing else is.