Moved current version to legacy
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Julien Valverdé
2024-01-20 22:02:14 +01:00
parent 019066bb9c
commit fc95a5d53a
32 changed files with 782 additions and 1509 deletions

View File

@@ -0,0 +1,29 @@
import { mapValues } from "lodash-es"
import { makeObservable, observable } from "mobx"
import { AbstractConstructor } from "type-fest"
import { z } from "zod"
import { SchemableClass } from ".."
export function makeSchemableClassObservable<
C extends SchemableClass<SchemaT, SchemaUnknownKeys, SchemaCatchall, Values, DefaultValues>,
SchemaT extends z.ZodRawShape,
SchemaUnknownKeys extends z.UnknownKeysParam,
SchemaCatchall extends z.ZodTypeAny,
Values extends {},
DefaultValues extends Partial<Values>,
>(
extend: C | SchemableClass<SchemaT, SchemaUnknownKeys, SchemaCatchall, Values, DefaultValues>
) {
return class extends (extend as AbstractConstructor<any>) {
constructor(...args: any[]) {
super(...args)
makeObservable(this,
mapValues(this.schema.shape, () => observable)
)
}
} as unknown as C
}