Skip to content

@btravstack/entity


@btravstack/entity ​

Namespaces ​

Interfaces ​

AggregateInstance ​

Defined in: packages/entity/src/types.ts:764

An aggregate instance: an entity's data, toJSON and sameIdentityAs, and emit in place of update. An interface, not a type alias, for emit's polymorphic this (TS2526 — see BaseInstance).

Type Parameters ​

Type ParameterDefault type
S extends Fields-
A extends Schemas-
Ev extends Events-
O extends string-
End extends stringnever

Properties ​

PropertyModifierTypeDefined in
sameIdentityAsreadonly[{ [K in string | number | symbol]: S[K] extends { flags: { identity: true } } ? K : never }[keyof S]] extends [never] ? object : (other) => booleanpackages/entity/src/types.ts:772

Methods ​

emit() ​
ts
emit(...events): Result<Decision<AggregateInstance<S, A, Ev, O, End>, output<Ev>>, never>;

Defined in: packages/entity/src/types.ts:788

Folds events onto this state, verifies the result with make, and returns the decision. Events breaking an invariant, failing their own schema, or a throwing handler are defects: a decision that does not hold is a bug in the command, never something to persist.

A creation event (O, the keys of opens) is excluded: an aggregate that exists cannot be created again, so emitting one is a compile error, as passing a non-creation event to start is. A terminal event (End, the entries of ends) only compiles last. Events are typed by the union's input, since each is parsed before the fold; the decision's events are its output, the type a repository or an outbox stores.

Parameters ​
ParameterType
...events[End] extends [never] ? readonly Extract<input<Ev>, { type?: Exclude<output<Ev>["type"], O>; }>[] : | readonly Extract<input<Ev>, { type?: Exclude<output<Ev>["type"], O | End>; }>[] | readonly [Extract<input<Ev>, { type?: Exclude<output<Ev>["type"], O | End>; }>, Extract<input<Ev>, { type?: End; }>]
Returns ​

Result<Decision<AggregateInstance<S, A, Ev, O, End>, output<Ev>>, never>

toJSON() ​
ts
toJSON(): DeepReadonly<OutputOf<S, A>>;

Defined in: packages/entity/src/types.ts:771

Returns ​

DeepReadonly<OutputOf<S, A>>


BaseInstance ​

Defined in: packages/entity/src/types.ts:397

The instance-side shape every entity's Base class structurally has: the three prototype methods that survive Omit<Base, "update">, plus update itself. update is typed with polymorphic this — the same mechanism decode/make/create use on the static side — so org.update(...) yields the subclass (Organization, with its _tag and class-body members intact), not the structural BaseInstance shape. Expressed independently of any concrete Base class — see EntityStatic for why.

Type Parameters ​

Type Parameter
S extends Fields
A extends Schemas

Properties ​

PropertyModifierTypeDescriptionDefined in
sameIdentityAsreadonly[{ [K in string | number | symbol]: S[K] extends { flags: { identity: true } } ? K : never }[keyof S]] extends [never] ? object : (other) => booleanWhether other is the same business entity: same identity scope (this class, or the abstract root that declared the identity), and every identity field equal by Object.is. Attributes are not compared. A property rather than a method so it can be absent — a compile error — on an entity that declares no identity. The not-callable arm is an inline literal, not a named alias, so TypeDoc has nothing undocumented to report; its property name is the diagnostic.packages/entity/src/types.ts:408

Methods ​

toJSON() ​
ts
toJSON(): DeepReadonly<OutputOf<S, A>>;

Defined in: packages/entity/src/types.ts:398

Returns ​

DeepReadonly<OutputOf<S, A>>

update() ​
ts
update(patch): Result<BaseInstance<S, A>, InvalidEntityClass>;

Defined in: packages/entity/src/types.ts:411

Parameters ​
ParameterType
patchPatchOf<S, A, ImmutableKeys<S>>
Returns ​

Result<BaseInstance<S, A>, InvalidEntityClass>


ConstructionKey ​

Defined in: packages/entity/src/types.ts:373

A type-level construction lock: no outside code can produce a value assignable to Sealed<D>, so new SomeEntity(...) does not compile. It closes the constructor without a runtime check, which unthrown/no-throw forbids.

ConstructionKey is exported but unconstructable — a private constructor and a private field make it unforgeable structurally, and it has no runtime existence at all. Exporting it is what lets a consumer compile:

A declare const CtorKey: unique symbol kept module-private was measured to break every downstream library that emits declarations — TS4020: 'extends' clause of exported class 'Organization' has or is using private name 'CtorKey' — because a unique symbol in computed-key position cannot be named across a module boundary even when exported. An ordinary named property whose type is an exported class can, so the emitted .d.ts references it as import("@btravstack/entity").Sealed<…>.

A literal protected constructor was measured and does not work either: TypeScript refuses to assign a protected-constructor class to any construct signature (TS2684), so the statics could only return the base class rather than the subclass. private is worse still — TS2675, the declaration form class X extends Entity("X")(...) stops compiling outright.


DecisionKey ​

Defined in: packages/entity/src/types.ts:726

The unforgeable half of a Decision — the same construction as ConstructionKey, for the same reason: a private member makes a type no object literal can satisfy, and it emits as an ordinary declared class.

Type Aliases ​

AbstractEntity() ​

ts
type AbstractEntity<Name, S, A> = RootInstance<S, A>;

Defined in: packages/entity/src/types.ts:537

What Entity.abstract(name)(fields, options?) returns.

Deliberately not an entity: no make, no factory, no schema members. The absence of a tag is what lets extend intersect the receiver's instance type unmapped — see RootInstance. name labels the root in its defect message and never reaches an instance.

Type Parameters ​

Type Parameter
Name extends string
S extends Fields
A extends Schemas
ts
type new AbstractEntity(d): RootInstance<S, A>;

What Entity.abstract(name)(fields, options?) returns.

Deliberately not an entity: no make, no factory, no schema members. The absence of a tag is what lets extend intersect the receiver's instance type unmapped — see RootInstance. name labels the root in its defect message and never reaches an instance.

Parameters ​

ParameterType
dSealed<OutputOf<S, A>>

Returns ​

RootInstance<S, A>

Properties ​

PropertyModifierTypeDefined in
entityNamereadonlyNamepackages/entity/src/types.ts:539

Methods ​

extend() ​
ts
extend<This, Tag2>(this, tag): <S2, A2>(fields, options?) => EntityStatic<Tag2, MergedFields<S, S2>, MergedComputed<A, A2>, BehaviourOf<This>>;

Defined in: packages/entity/src/types.ts:551

A new entity carrying this root's fields plus more, under its own tag, and inheriting the instance half of the class body of whatever it was called on: its methods and accessors, but not its statics and not its field initialisers. extend rewires the instance prototype and nothing else, so a root's constructor never runs — see docs/reference/declaration.md.

The this parameter is what picks up a behaviour-only intermediate root: abstract class Auditable extends AccountBase { … } then Auditable.extend(...) carries both bodies.

Type Parameters ​
Type Parameter
This
Tag2 extends string
Parameters ​
ParameterType
thisThis
tagTag2
Returns ​

<S2, A2>(fields, options?) => EntityStatic<Tag2, MergedFields<S, S2>, MergedComputed<A, A2>, BehaviourOf<This>>


AggregateStatic() ​

ts
type AggregateStatic<Tag, S, A, Ev, O, End> = ConstructedAggregate<Tag, S, A, Ev, O, End>;

Defined in: packages/entity/src/types.ts:822

What Entity.aggregate(tag)(fields, options) returns. Deliberately not an EntityStatic: no update, no factories, no createInput/updateInput — state changes only through events, and start is creation. No _zod slot in the type either, so an aggregate cannot be nested as another entity's field: a root is referenced by id, never embedded.

O is the opening event types — a literal union of event names, so it costs a few characters in a consumer's declarations, unlike the field-key unions the dead-end ledger in GeneratedKeys warns about. End, the terminal event types, is the same kind of union.

Type Parameters ​

Type ParameterDefault type
Tag extends string-
S extends Fields-
A extends Schemas-
Ev extends Events-
O extends string-
End extends stringnever
ts
type new AggregateStatic(d): ConstructedAggregate<Tag, S, A, Ev, O, End>;

What Entity.aggregate(tag)(fields, options) returns. Deliberately not an EntityStatic: no update, no factories, no createInput/updateInput — state changes only through events, and start is creation. No _zod slot in the type either, so an aggregate cannot be nested as another entity's field: a root is referenced by id, never embedded.

O is the opening event types — a literal union of event names, so it costs a few characters in a consumer's declarations, unlike the field-key unions the dead-end ledger in GeneratedKeys warns about. End, the terminal event types, is the same kind of union.

Parameters ​

ParameterType
dSealed<OutputOf<S, A>>

Returns ​

ConstructedAggregate<Tag, S, A, Ev, O, End>

Properties ​

PropertyModifierTypeDescriptionDefined in
__eventreadonlyz.output<Ev>the event union, read by Entity.Eventpackages/entity/src/types.ts:841
__inputreadonlyInputOf<S>-packages/entity/src/types.ts:838
__instancereadonlyConstructedAggregate<Tag, S, A, Ev, O, End>-packages/entity/src/types.ts:842
__outputreadonlyOutputOf<S, A>-packages/entity/src/types.ts:839
entityNamereadonlyTag-packages/entity/src/types.ts:831
eventsreadonlyEvthe declared event union, for an outbox or an event store's contractpackages/entity/src/types.ts:837
inputreadonlyz.ZodObject<PlainOf<S, "input">>-packages/entity/src/types.ts:832
jsonreadonlyz.ZodObject<JsonOf<S, A>>what z.encode(output, x.toJSON()) writes: a response body, each codec as its wire formpackages/entity/src/types.ts:835
outputreadonlyz.ZodObject<PlainOf<S, "output"> & A>-packages/entity/src/types.ts:833

Methods ​

inspect() ​
ts
inspect(state): Result<Inspection<OutputOf<S, A>>, InvalidEntityClass>;

Defined in: packages/entity/src/types.ts:853

Parameters ​
ParameterType
stateunknown
Returns ​

Result<Inspection<OutputOf<S, A>>, InvalidEntityClass>

make() ​
ts
make<T>(
   this, 
   state, 
   loaded
): Result<T, InvalidEntityClass>;

Defined in: packages/entity/src/types.ts:848

a snapshot or a state-based row → aggregate; emits nothing. The version is required: it is what the aggregate's next decision tells the store to expect, so an aggregate can never be saved without one.

Type Parameters ​
Type Parameter
T
Parameters ​
ParameterType
thisnew (d) => T
stateunknown
loaded{ version: number; }
loaded.versionnumber
Returns ​

Result<T, InvalidEntityClass>

replay() ​
ts
replay<T>(this, events): Result<T, InvalidEntityClass>;

Defined in: packages/entity/src/types.ts:860

a stored stream → aggregate: parse every event, fold, one make; emits nothing

Type Parameters ​
Type Parameter
T
Parameters ​
ParameterType
thisnew (d) => T
eventsunknown
Returns ​

Result<T, InvalidEntityClass>

start() ​
ts
start<T>(this, event): Result<Decision<T, output<Ev>>, never>;

Defined in: packages/entity/src/types.ts:855

an opening event → the decision that creates the aggregate

Type Parameters ​
Type Parameter
T
Parameters ​
ParameterType
thisnew (d) => T
eventExtract<input<Ev>, { type?: K; }>
Returns ​

Result<Decision<T, output<Ev>>, never>


Decision ​

ts
type Decision<A, E> = object;

Defined in: packages/entity/src/types.ts:749

What a command returns: the state, already verified by make; every event decided since the aggregate was loaded; and the version it was loaded at. Only emit and start build one, so a repository that takes a Decision can only be handed events that were folded and checked against every invariant — and it needs nothing else to save one.

events accumulates across chained commands, so saving the last decision of a chain loses none of the earlier ones. expectedVersion is the one the store must still be at: 0 for a new aggregate, the stream length after replay, the row's version after make. The package carries it and never interprets it.

isTerminal is true once a decided event is one of the aggregate's ends: the aggregate is over, so a repository stops loading it (keeping its version, so a stale save still conflicts), and nothing more can be decided on that state.

Type Parameters ​

Type Parameter
A
E

Properties ​

PropertyModifierTypeDefined in
__onlyEmitOrStartMakeADecisionreadonlyDecisionKeypackages/entity/src/types.ts:755
eventsreadonlyreadonly E[]packages/entity/src/types.ts:751
expectedVersionreadonlynumberpackages/entity/src/types.ts:752
isTerminalreadonlybooleanpackages/entity/src/types.ts:753
statereadonlyApackages/entity/src/types.ts:750

EntityStatic() ​

ts
type EntityStatic<Tag, S, A, B> = BaseInstance<S, A> & DeepReadonly<OutputOf<S, A>, "data"> & object & B;

Defined in: packages/entity/src/types.ts:582

The full static surface Entity(tag)(fields, options?) returns.

Named here, in entity.ts's companion types module, rather than left as the inline Base as unknown as {…} cast at the end of the builder, so it can double as the builder's explicit return-type annotation, and so the package's exported helper types (Input, Output, CreateInput, Patch) have a single surface to read the shapes off. This is why every member below is expressed from S/A/Tag alone instead of the builder's body-local Base/input/output/etc. — those aren't in scope at the annotation position, before the body that declares them.

There are no G/I parameters: the key unions are computed inside the body from the flags S carries — see GeneratedKeys for why they must never move into a parameter list.

Type Parameters ​

Type ParameterDefault type
Tag extends string-
S extends Fields-
A extends Schemas-
BRecord<never, never>
ts
type new EntityStatic(d): BaseInstance<S, A> & DeepReadonly<OutputOf<S, A>, "data"> & object & B;

The full static surface Entity(tag)(fields, options?) returns.

Named here, in entity.ts's companion types module, rather than left as the inline Base as unknown as {…} cast at the end of the builder, so it can double as the builder's explicit return-type annotation, and so the package's exported helper types (Input, Output, CreateInput, Patch) have a single surface to read the shapes off. This is why every member below is expressed from S/A/Tag alone instead of the builder's body-local Base/input/output/etc. — those aren't in scope at the annotation position, before the body that declares them.

There are no G/I parameters: the key unions are computed inside the body from the flags S carries — see GeneratedKeys for why they must never move into a parameter list.

Parameters ​

ParameterType
dSealed<OutputOf<S, A>>

Returns ​

BaseInstance<S, A> & DeepReadonly<OutputOf<S, A>, "data"> & object & B

Properties ​

PropertyModifierTypeDescriptionDefined in
__createInputreadonlyCreateInputOf<S, GeneratedKeys<S>>-packages/entity/src/types.ts:632
__inputreadonlyInputOf<S>phantom carriers, so consumers can recover the shapes for annotationspackages/entity/src/types.ts:630
__instancereadonlyConstructedInstance<Tag, S, A> & Bthe instance type, read by Entity.Instancepackages/entity/src/types.ts:635
__outputreadonlyOutputOf<S, A>-packages/entity/src/types.ts:631
__patchreadonlyPatchOf<S, A, ImmutableKeys<S>>-packages/entity/src/types.ts:633
_zodreadonlyz.ZodType<ConstructedInstance<Tag, S, A> & B>["_zod"]The zod slots that make the class itself a schema, so it composes directly: z.object({ owner: Organization }), z.array(Organization), or as a field of another entity. Parsing yields a real instance. Only these two are declared, never the full ZodType: that would put a throwing .parse() on every entity beside make, which is the opposite of what this package is for. Wrapping still works through zod's function forms — z.optional(Organization) rather than Organization.optional(). The runtime binds to whichever class the slot is read from, so a schema built from a subclass yields that subclass. The type cannot say so — a property, unlike a method, takes no this parameter to infer the receiver from — so it states the base shape and a caller narrows with instanceof.packages/entity/src/types.ts:627
~standardreadonlyz.ZodType<ConstructedInstance<Tag, S, A> & B>["~standard"]-packages/entity/src/types.ts:628
createInputreadonlyz.ZodObject<Omit<PlainOf<S, "input">, GeneratedKeys<S>>>-packages/entity/src/types.ts:610
entityNamereadonlyTag-packages/entity/src/types.ts:602
inputreadonlyz.ZodObject<PlainOf<S, "input">>-packages/entity/src/types.ts:606
jsonreadonlyz.ZodObject<JsonOf<S, A>>what z.encode(output, x.toJSON()) writes: a response body, each codec as its wire formpackages/entity/src/types.ts:609
outputreadonlyz.ZodObject<PlainOf<S, "output"> & A>-packages/entity/src/types.ts:607
updateInputreadonlyz.ZodObject<UpdateInputShapeOf<S, A, ImmutableKeys<S>>>-packages/entity/src/types.ts:611

Methods ​

factory() ​
ts
factory<T>(this, generators): EntityFactory<T, S, { [K in string | number | symbol]: S[K] extends { flags: { generated: true } } ? K : never }[keyof S]>;

Defined in: packages/entity/src/types.ts:643

Type Parameters ​
Type Parameter
T
Parameters ​
ParameterType
thisnew (d) => T
generatorsGenerators<S, GeneratedKeys<S>>
Returns ​

EntityFactory<T, S, { [K in string | number | symbol]: S[K] extends { flags: { generated: true } } ? K : never }[keyof S]>

factoryAsync() ​
ts
factoryAsync<T>(this, generators): AsyncEntityFactory<T, S, { [K in string | number | symbol]: S[K] extends { flags: { generated: true } } ? K : never }[keyof S]>;

Defined in: packages/entity/src/types.ts:647

Type Parameters ​
Type Parameter
T
Parameters ​
ParameterType
thisnew (d) => T
generatorsAsyncGenerators<S, GeneratedKeys<S>>
Returns ​

AsyncEntityFactory<T, S, { [K in string | number | symbol]: S[K] extends { flags: { generated: true } } ? K : never }[keyof S]>

inspect() ​
ts
inspect(state): Result<Inspection<OutputOf<S, A>>, InvalidEntityClass>;

Defined in: packages/entity/src/types.ts:638

stored data → its data plus the invariants it breaks, never an entity

Parameters ​
ParameterType
stateunknown
Returns ​

Result<Inspection<OutputOf<S, A>>, InvalidEntityClass>

make() ​
ts
make<T>(this, state): Result<T, InvalidEntityClass>;

Defined in: packages/entity/src/types.ts:636

Type Parameters ​
Type Parameter
T
Parameters ​
ParameterType
thisnew (d) => T
stateunknown
Returns ​

Result<T, InvalidEntityClass>

parseCreate() ​
ts
parseCreate(raw): Result<DeepReadonly<Omit<$InferObjectOutput<SchemasOf<S>, {
}>, { [K in string | number | symbol]: S[K] extends { flags: { generated: true } } ? K : never }[keyof S]>, "creation">, InvalidEntityClass>;

Defined in: packages/entity/src/types.ts:640

a create command → factory's input; fields and nested entities, not invariants

Parameters ​
ParameterType
rawunknown
Returns ​

Result<DeepReadonly<Omit<$InferObjectOutput<SchemasOf<S>, { }>, { [K in string | number | symbol]: S[K] extends { flags: { generated: true } } ? K : never }[keyof S]>, "creation">, InvalidEntityClass>


EntityUnion ​

ts
type EntityUnion<K, M> = object & Pick<z.ZodType<InstanceOf<M[number]>>, "_zod" | "~standard">;

Defined in: packages/entity/src/union.ts:40

What Entity.union(...) returns: a value, never a constructor.

There is deliberately no new signature. A class's instance type cannot be a union — TS2509: Base constructor return type 'Personal | Business' is not an object type or intersection of object types with statically known members — so a class form could only ever type as the members' shared root, which is both unable to narrow and redundant with the root the author already named. It shipped in 0.4.0 and was removed in #57. TS2507 at the declaration is the replacement, and it fires where the mistake is written.

Type Parameters ​

Type Parameter
K extends string
M extends readonly UnionMember[]

Type Declaration ​

NameTypeDescriptionDefined in
__instanceInstanceOf<M[number]>the exact member union, read by Entity.Instancepackages/entity/src/union.ts:51
discriminantK-packages/entity/src/union.ts:41
inputz.ZodType<z.output<M[number]["input"]>, z.input<M[number]["input"]>>-packages/entity/src/union.ts:46
jsonz.ZodType<z.output<M[number]["json"]>, z.input<M[number]["json"]>>each member's json, discriminated on the same field — a response bodypackages/entity/src/union.ts:49
membersM-packages/entity/src/union.ts:42
outputz.ZodType<z.output<M[number]["output"]>, z.input<M[number]["output"]>>-packages/entity/src/union.ts:47
inspect()(state) => Result<Inspection<output<M[number]["output"]>>, InvalidEntityClass>dispatches on the discriminant like make, then reports — see an entity's inspectpackages/entity/src/union.ts:54
make()(state) => Result<output<M[number]>, InvalidEntityClass>-packages/entity/src/union.ts:52

FieldSpec ​

ts
type FieldSpec<T, F> = object;

Defined in: packages/entity/src/field.ts:11

One flagged field: the schema, held — never impersonated. Anything standing in front of an entity-class field breaks make, which constructs through this (TypeError: Ctor is not a constructor — measured), so the spec object is the only shape a marker may take.

Type Parameters ​

Type Parameter
T extends z.core.$ZodType
F extends Flags

Properties ​

PropertyModifierTypeDefined in
flagsreadonlyFpackages/entity/src/field.ts:13
schemareadonlyTpackages/entity/src/field.ts:12

Inspection ​

ts
type Inspection<D> = object;

Defined in: packages/entity/src/types.ts:318

What inspect returns: a stored row's data, and the rules it breaks.

Deliberately not an entity. data is plain frozen data — no _tag, no update, no sameIdentityAs, no class body — so it cannot be handed to a command that expects the entity, and ignoring violations cannot smuggle a row that breaks today's rules into the command model. The way back is a migration followed by make, which is strict. violations are the issues make would have failed with, params.code and all, so Entity.codeOf reads them.

Named, and exported from index.ts, so a consumer's emitted declarations print Inspection<…> rather than spelling the object out at every inspect call they return from.

Type Parameters ​

Type Parameter
D

Properties ​

PropertyModifierTypeDefined in
datareadonlyDeepReadonly<D>packages/entity/src/types.ts:319
violationsreadonlySchemaIssuespackages/entity/src/types.ts:320

MergedComputed ​

ts
type MergedComputed<A, A2> = Omit<A, keyof A2> & A2;

Defined in: packages/entity/src/types.ts:486

A root's computed map merged with a variant's — what extend hands EntityStatic as its A.

Omit<A, keyof A2> & A2, never A & A2: the runtime spread lets a variant's computed key win, and a plain intersection would type a redefined key as Upper & Lower while the value is Lower.

Named rather than written inline at extend's return type, which was measured to emit a dangling reference: with A = Record<never, never> — a root declaring no computed, which is the default — TypeScript 5.9.3 wrote the unsubstituted Omit<Record<never, never>, keyof A2> & Record<never, never> into the consumer's .d.ts, where the consumer's own compiler rejected it with TS2304: Cannot find name 'A2'. TypeScript 7.0.2 substitutes the same position correctly. Naming it is only half the fix: the emitter writes the name only because index.ts exports it, and unexporting it was measured to expand the alias structurally and bring the identical dangling A2 straight back. See the export list there, and do not un-export it.

The fields half of the same merge is MergedFields, below.

Type Parameters ​

Type Parameter
A extends Schemas
A2 extends Schemas

MergedFields ​

ts
type MergedFields<S, S2> = Omit<S, keyof S2> & S2;

Defined in: packages/entity/src/types.ts:519

A root's field map merged with a variant's — what extend hands EntityStatic as its S.

Omit<S, keyof S2> & S2, never S & S2, for MergedComputed's reason one map over: the runtime spread is { ...parent.fields, ...nextFields }, so a variant redeclaring an inherited field wins, and a plain intersection would type that key as ZodBranded<Parent> & ZodBranded<Child> while the schema held is the child's alone.

Named and exported from the start for the reason measured on MergedComputed: written inline, the 5.9.3 emitter copied that alias's A2 through unsubstituted and consumers failed with TS2304. This is the same alias in the same position, so it was never written inline here and the S2 spelling of that failure has not been observed — it is inferred from the A2 one, not a second measurement. See the export list in index.ts, and do not un-export it.

Serialised width was the recorded reason this half was deferred, since every variant pays it where MergedComputed is paid only by one declaring computed. Measured rather than assumed: the emitter writes the alias by reference, so the billing fixture's index.d.ts grew 10,061 → 10,145 bytes — 42 per variant, against the 274,048 an unnamed type expands to — and all four typecheck steps stayed clean on both compilers. The TS7056 budget is serialised characters, and a named alias barely spends it.

NoRedeclaredKeys now forbids keyof S ∩ keyof S2 outright, so the child-wins branch here is unreachable at compile time; the alias stays as the runtime-honest spelling, and base.test-d.ts guards the rejection itself rather than the merge's resolution, in case the forbid ever loosens.

Type Parameters ​

Type Parameter
S extends Fields
S2 extends Fields

Sealed ​

ts
type Sealed<D> = D & object;

Defined in: packages/entity/src/types.ts:380

Type Parameters ​

Type Parameter
D

Type Declaration ​

NameTypeDefined in
__useMakeOrFactoryInsteadConstructionKeypackages/entity/src/types.ts:380

UnionMember ​

ts
type UnionMember = object & z.core.$ZodType;

Defined in: packages/entity/src/union.ts:12

The part of an entity a union needs. Typed loosely — EntityStatic is generic in the entity's own shape, and a union has to accept any of them.

Type Declaration ​

NameTypeDefined in
entityNamestringpackages/entity/src/union.ts:13
inputz.ZodObject<z.core.$ZodLooseShape>packages/entity/src/union.ts:14
jsonz.ZodObject<z.core.$ZodLooseShape>packages/entity/src/union.ts:16
outputz.ZodObject<z.core.$ZodLooseShape>packages/entity/src/union.ts:15
inspect()(state) => Result<Inspection<unknown>, InvalidEntityClass>packages/entity/src/union.ts:18
make()(state) => Result<unknown, InvalidEntityClass>packages/entity/src/union.ts:17

Functions ​

Entity() ​

ts
function Entity<Tag>(tag): <S, A>(fields, options?) => EntityStatic<Tag, S, A>;

Defined in: packages/entity/src/entity.ts:81

class X extends Entity("X")({ …fields }) {}

Curried on the tag so it reads next to the class name it labels, ahead of the field map. The tag is a non-enumerable instance property: it exists for P.tag matching and never reaches the wire.

Type Parameters ​

Type Parameter
Tag extends string

Parameters ​

ParameterType
tagTag

Returns ​

<S, A>(fields, options?) => EntityStatic<Tag, S, A>

Released under the MIT License.