API Reference cratis_arc v#0.1.0

Copy Markdown View Source

Modules

Arc

Arc for Elixir: an opinionated CQRS application framework for Phoenix and Plug, on Cratis Chronicle.

The runtime of one Arc application: discovery, configuration and the processes that serve observable queries.

Authentication handlers turn an incoming request into an Arc.Principal.

Reads the principal from conn.assigns[:arc_principal] (an Arc.Principal), or builds one from the signed-in user your own authentication assigned: conn.assigns.current_scope.user (the phx.gen.auth shape) or conn.assigns.current_user, a map with :id and optionally :name, :email and :roles.

Authenticates from the Microsoft identity platform headers an ingress supplies: x-ms-client-principal (a base64 client principal), x-ms-client-principal-id and x-ms-client-principal-name. These are what Azure App Service, Container Apps, Cratis AuthProxy and the Lens browser extension send.

Authorization declarations and checks for commands and queries.

Appends the events a command returned to Chronicle.

A model-bound command: a module whose struct is the request and whose handle/2 decides.

The outcome of executing a command, shaped as the Arc command result envelope.

Request-scoped facts handed to every command, query, validator and policy.

Compile-time metadata of a command or a read model, exposed as __arc__/0 on the artifact.

Metadata of one query on a read model.

A cross-cutting rule that runs for commands and queries, whatever their own declarations say.

The identity the frontend shows: who the caller is, their roles, and application-specific details.

The input of an identity details provider: the authenticated caller.

The result of an identity details provider, when it needs more than {:ok, details}: whether the user may enter the application at all, and the details to show.

Acting on behalf of a user: verifies the RS256 assertion Cratis AuthProxy signs for an on-behalf session and attaches the actor to the represented user's principal.

Supplies the application-specific details of the signed-in user.

The resolved identity, as served from /.cratis/me.

Signed forwarded identity: an ingress attests the identity headers it sends with an HMAC-SHA256 over the request, so the headers are no longer trusted merely because they are present.

A development tenant, as listed by /.cratis/tenants.

Lists the tenants a tool such as Lens offers to select.

A development user, as listed by /.cratis/users for tools such as Lens.

Lists the development users a tool such as Lens offers to sign in as.

The Arc commands and queries, called in-process from a LiveView.

A command as a Phoenix form.

Name conversions shared by routing, the wire format and proxy generation.

Tells observable queries to run again.

A page of results from a query that pages itself, for example a query over a database.

Runs commands and queries: authorize, bind, validate, provide, handle, record.

The Arc HTTP contract on Plug.

The multiplexed WebSocket hub at /.cratis/queries/ws.

Serves a single-page application: static files from a directory, and the index.html for every other GET that accepts HTML, so client-side routes survive a refresh.

The multiplexed Server-Sent Events hub at /.cratis/queries/sse.

A named authorization policy. Register it on the application with policies: [can_publish: MyApp.Policies.CanPublish].

The authenticated caller of a command or query.

Generates TypeScript proxies for the React frontend packages (@cratis/arc, @cratis/arc.react) from the commands and read models of an Arc.Application.

The outcome of executing a query, shaped as the Arc query result envelope.

A read model container: the module that declares queries over one model type.

Declares the fields of a command, a parameter object or a nested type.

Typed metadata for one declared field.

One live subscription to an observable query.

Resolves which tenant a request is for.

ExUnit support that runs the real Arc pipelines against Chronicle's in-memory kernel.

ExUnit.CaseTemplate that starts an in-memory Chronicle client per test and puts an Arc.Test.Scenario in the context as :arc.

The application and Chronicle test client of one test.

The field types Arc understands, and conversion between wire values and Elixir values.

Builds validation results and evaluates declarative field rules.

One validation outcome, carried in the command and query result envelopes.

A source of change notifications for observable queries.

Converts Elixir values to the JSON-ready shape of the Arc wire format.

Mix Tasks

Generates TypeScript proxies for the React frontend. Proxy generation is opt-in.

Regenerates TypeScript proxies after each compile. Opt in by adding the compiler