Changelog - 2026-10-24
A read's result type follows its fields
Enhancement Breaking ChangeIn one line. find, findOne and findById return only the columns filter.fields names, so reading a column you did not select, or naming one that does not exist, fails at compile time.
const rows = await productRepository.find({ filter: { fields: ['id', 'name'] } });
// rows: Array<Pick<TProduct, 'id' | 'name'>>
rows[0].name; // ok
rows[0].price; // error: 'price' was not selected
await productRepository.find({ filter: { fields: ['id', 'nmae'] } }); // error: 'nmae' is not a columnWhat changed
fieldsis typed.TFiltertakes the model and the selection (TFilter<T, F>);fieldsacceptsReadonlyArray<keyof T>or an object keyed by column. Only atrueentry selects.- The row follows it. A literal
fieldsgivesPick<T, ...>. Nofields, an empty selection or a non-literal array gives the whole row. Relations a model declares optional (items?: ...) stay readable, because anincludeadds them. - An explicit type wins.
find<MyRow>(...)returnsMyRow[]whateverfieldssays. - New exports from
@venizia/ignis-filterand@venizia/ignis-kernel:TRow,TSelectedRow,TByIdFilter;TFieldsandTFiltergain the model parameter. - Same signatures everywhere. The kernel contract and abstract repository, the relational and soft-deletable repositories, the search repository and
HttpRepository. - Controllers. The repository slot of
ControllerFactory.defineCrudControlleraccepts a repository whose extra options narrowIExtraOptions(a typed transaction).
Who is affected
- Everyone who reads with
fields. A read that uses a column it did not select now fails to compile. At run time that column isundefined. - A repository that overrides
find,findOneorfindById. With the old<R = E>signature it stops compiling, and hooks that infer the row from the class degrade tounknown. Migrate the override (below). - A read with no
fields. No action needed; the row type is unchanged.
Breaking changes
WARNING
Type-level only; nothing changes at run time. A fields list kept in a constant, a generic repository base class, or an override of a read method must change.
1. Field lists kept in constants need as const. A plain array is widened to string[], which is no longer accepted.
// Before
const TICKET_FIELDS = ['id', 'status'];
// After
const TICKET_FIELDS = ['id', 'status'] as const;2. An override of a read method uses the new generics.
// Before
override async findOne<R = E>(opts?: IFindArgs<E>): Promise<R | null>;
// After
override async findOne<R = unknown, const F extends TFields<E> = TFields<E>>(
opts?: IFindArgs<E> & { filter?: TFilter<E, F> },
): Promise<TRow<E, R, F> | null>;findById takes filter?: TByIdFilter<E, F>; find returns Array<TRow<E, R, F>>.
3. Generic code needs a cast where the row cannot be resolved. Inside a class generic in the row type, this.findById<DataObject>(...) keeps its row unresolved, so a property read or a null check on it fails. Cast the result to the row type. The same applies to fields: { slug: true } on a generic D: cast it to TFields<D>.
4. A filter parsed from a request is untyped. A fields of string[] | Record<string, boolean> is not assignable to a typed fields; cast the filter (as TFilter<T>) after validating it.
5. Test doubles of a read method cast with as unknown as typeof repository.findOne.
Details
- The search repository keeps
whereuntyped, as before; onlyfieldsis typed.