Skip to main content
Some business verbs apply to many kinds of objects: archiving an order and archiving an invoice mean the same thing to the person clicking the button, even though each needs its own code. An operation interface declares that shared shape once. Each object type then supplies its own concrete operation that implements it.
bijection/archive.ts

Declaring an interface

defineOperationInterface takes three fields:
  • name: the interface’s name. It starts with a letter or _, may contain letters, digits, _ and ., and is at most 128 characters long.
  • args: the shared arguments, without the target.
  • returns: the shared result.
An interface owns no tables, rules, credentials or handler. It describes a shape, and implementing it grants nothing.

Implementing an interface

A concrete operation opts in with implements. Each implementation must:
  • declare target: { argument: "target" }, with a required target argument that is an ID of its own object type;
  • declare exactly the interface’s other arguments, and exactly its result.
defineOperation refuses an implementation whose shape does not match. An operation can implement up to 16 interfaces. When you deploy, at most one operation per interface and object type is admitted in a component, private operations included. Two implementations for the same pair are refused rather than one being picked.
Nothing is inferred. An interface does not make a view’s field editable, and does not map one argument name to another. Each implementation spells out its own change.

Discovering implementations

The exported interface is an ordinary query. Call it with an optional on filter, the name of an object type in your schema, and it returns the public implementations in that component that the caller can currently read:
src/archive.ts
operationImplementationReference turns a discovered implementation into an ordinary operation reference. From there, previewing, invoking, recovering and following a request work as for any operation. An empty result means no implementation is available to this caller, not that none exists. Discovery grants nothing either: previewing and invoking still need the concrete operation’s grants.
Resolve the interface once, before the first submission. To retry or recover a request, reuse the same concrete reference and request key. Discovering again could select a different implementation, and it cannot redirect a request that was already accepted.