arg
API reference for @effx/runtime/define/arg
arg.ts overview
Exports Grouped by Category
- utils
- A
- Arg (interface)
- CapabilityMarker (interface)
- Field (type alias)
- InjectedArg (interface)
- JsonValue (type alias)
- LiveStruct (type alias)
- OptionalArg (interface)
- ReadStruct (type alias)
- RootSymbolMarker (interface)
- SchemaMarker (interface)
- SchemaOptions (interface)
- SourceOptionalArg (interface)
- SymbolMarker (interface)
- SymbolOptions (interface)
- args
utils
A
The closed combinator algebra for annotation arguments (spec 0020 §2.2). Every member has a fixed
lowering, an encoded form and a decode Schema derived by the compiler, so an args built from it is
statically lowerable by construction.
Signature
declare const A: {
readonly string: Arg<string, string>
readonly nonEmptyString: Arg<string, string>
readonly number: Arg<number, number>
readonly int: Arg<number, number>
readonly boolean: Arg<boolean, boolean>
readonly literal: <const V extends string | number | boolean>(values_0: V, ...values: Array<V>) => Arg<V>
readonly struct: <const F extends Fields>(
fields: F,
options?: { readonly rejectDuplicate?: ReadonlyArray<keyof F & string> }
) => Arg<LiveStruct<F>, ReadStruct<F>>
readonly optional: <L, R>(arg: Arg<L, R>) => OptionalArg<L, R>
readonly sourceOptional: <L, R>(arg: Arg<L, R>) => SourceOptionalArg<L, R>
readonly injected: <R>(arg: Arg<unknown, R>) => InjectedArg<R>
readonly array: <L, R>(
item: Arg<L, R>,
options?: { readonly unique?: true; readonly nonEmpty?: true }
) => Arg<ReadonlyArray<L>, ReadonlyArray<R>>
readonly nonEmptyArray: <L, R>(
item: Arg<L, R>,
options?: { readonly unique?: true }
) => Arg<readonly [L, ...Array<L>], readonly [R, ...Array<R>]>
readonly record: <L, R>(value: Arg<L, R>) => Arg<Readonly<Record<string, L>>, Readonly<Record<string, R>>>
readonly json: Arg<JsonValue, JsonValue>
readonly jsonObject: Arg<{ readonly [key: string]: JsonValue }, { readonly [key: string]: JsonValue }>
readonly taggedUnion: <const Cases extends Readonly<Record<string, Fields>>>(
cases: Cases
) => Arg<TaggedLive<Cases>, TaggedRead<Cases>>
readonly union: <const Members extends readonly [Arg<unknown, unknown>, ...Array<Arg<unknown, unknown>>]>(
...members: Members
) => Arg<LiveOf<Members[number]>, ReadOf<Members[number]>>
readonly schema: (options?: SchemaOptions) => Arg<Schema.Top, SchemaMarker>
readonly sugar: <L, R, S>(arg: Arg<L, R>, _sugar: Arg<S, unknown>) => Arg<L | S, R>
readonly typed: <L>() => Arg<L, never>
readonly fromSchema: <S extends Schema.Top>(schema: S) => Arg<S["Encoded"], S["Type"]>
readonly symbol: <Live, Read = SymbolMarker>(options: SymbolOptions) => Arg<Live, Read>
readonly capability: <Live>() => Arg<Live, CapabilityMarker>
}Arg (interface)
One argument position of an annotation. Live is what the author writes (checked by tsc);
Read is what the compiler's read receives after lowering and decoding. plan is the only
runtime content: data the frontend lowers by and the compiler derives its decode Schema from.
Live/Read are phantom (never set).
Signature
export interface Arg<out Live, out Read = Live> {
readonly plan: Plan
readonly Live?: Live
readonly Read?: Read
}CapabilityMarker (interface)
The lowered form of Capability.make(name, { resource, focus? }): resource is the model's export name.
Signature
export interface CapabilityMarker {
readonly "~effx/Read": "Capability"
}Field (type alias)
Signature
type Field =
Arg<unknown, unknown> | OptionalArg<unknown, unknown> | SourceOptionalArg<unknown, unknown> | InjectedArg<unknown>InjectedArg (interface)
A struct field supplied by the collector, never written in source.
Signature
export interface InjectedArg<out Read> {
readonly _optional: "injected"
readonly arg: Arg<never, Read>
}JsonValue (type alias)
Signature
type JsonValue = null | string | number | boolean | ReadonlyArray<JsonValue> | { readonly [key: string]: JsonValue }LiveStruct (type alias)
Signature
type LiveStruct<F extends Fields> = Readonly<Flatten<LiveRequired<F> & LiveOptional<F>>>OptionalArg (interface)
A struct field that may be absent in source and in the lowered value.
Signature
export interface OptionalArg<out Live, out Read = Live> {
readonly _optional: "optional"
readonly arg: Arg<Live, Read>
}ReadStruct (type alias)
Signature
type ReadStruct<F extends Fields> = Readonly<Flatten<ReadRequired<F> & ReadOptional<F>>>RootSymbolMarker (interface)
Signature
export interface RootSymbolMarker {
readonly "~effx/Read": "RootSymbol"
}SchemaMarker (interface)
Read markers. The runtime stays free of @effx/ir; the compiler resolves each marker to the real
decoded type (SchemaArg, SymbolArg, …) with a type-level map (Resolved in @effx/compiler).
Signature
export interface SchemaMarker {
readonly "~effx/Read": "Schema"
}SchemaOptions (interface)
Signature
export interface SchemaOptions {
readonly fieldKeys?: FieldKeys
/** With `fieldKeys`: a Schema without static `fields` lowers without them instead of being rejected. */
readonly fieldsOptional?: true
readonly taggedMessage?: true
}SourceOptionalArg (interface)
A struct field that may be absent in source but is required in Read (the 0013 pre-pass fills it).
Signature
export interface SourceOptionalArg<out Live, out Read = Live> {
readonly _optional: "source"
readonly arg: Arg<Live, Read>
}SymbolMarker (interface)
Signature
export interface SymbolMarker {
readonly "~effx/Read": "Symbol"
}SymbolOptions (interface)
Signature
export interface SymbolOptions {
readonly check: SymbolCheck
readonly message?: string
}args
The positional argument list of an annotation.
Signature
declare const args: {
readonly list: (...items: ReadonlyArray<Arg<unknown, unknown>>) => ArgsPlan
readonly rest: (rest: Arg<unknown, unknown>, ...items: ReadonlyArray<Arg<unknown, unknown>>) => ArgsPlan
}