Skip to content

@btravstack/contract


@btravstack/contract

Type Aliases

Authenticated

ts
type Authenticated<T> = T & object;

Defined in: auth.ts:10

A contract node whose procedures require an authenticated caller.

Type Declaration

NameTypeDefined in
[PRINCIPAL]trueauth.ts:10

Type Parameters

Type Parameter
T

IsMarked

ts
type IsMarked<T> = T extends object ? true : false;

Defined in: auth.ts:16

Whether this exact node carries the marker.

Type Parameters

Type Parameter
T

PrincipalKey

ts
type PrincipalKey = typeof PRINCIPAL;

Defined in: auth.ts:13

The marker's key, so a consumer's mapped type can Exclude it from keyof.

Functions

authenticated()

ts
function authenticated<T>(node): Authenticated<T>;

Defined in: auth.ts:38

Marks a contract node as requiring an authenticated caller — a record protects every procedure beneath it, a procedure protects itself.

ts
export const contract = {
  orders: authenticated({ place, find }),
  customers: { find, quote: authenticated(oc.input(…).output(…)) },
};

Returns the node unchanged and applies after a builder chain, never inside one. See packages/contract/CLAUDE.md.

Type Parameters

Type Parameter
T extends object

Parameters

ParameterType
nodeT

Returns

Authenticated<T>


isAuthenticated()

ts
function isAuthenticated(node): boolean;

Defined in: auth.ts:44

Whether this exact node was marked. Ancestry is the caller's to carry.

Parameters

ParameterType
nodeobject

Returns

boolean

Released under the MIT License.