import { type Opt, types } from '@mikro-orm/core'; import { Entity, Property } from '@mikro-orm/decorators/legacy'; import type { Constructor } from '@wener/utils'; import { Feature } from '../../Feature'; import { EntityFeature } from '../enum'; import type { HasStateStatusEntity } from './types'; export function withStateStatusEntity({ status, state }: { status: string; state: string }) { return (Base: TBase) => { @Feature([EntityFeature.HasStateStatus]) @Entity({ abstract: true }) class HasStateStatusMixinEntity extends Base implements HasStateStatusEntity { @Property({ type: types.string, nullable: false, default: state }) state!: string & Opt; @Property({ type: types.string, nullable: false, default: status }) status!: string & Opt; } return HasStateStatusMixinEntity; }; }