Replies: 2 comments 2 replies
-
I like the idea, i'll open an issue to keep track of the progression. |
Beta Was this translation helpful? Give feedback.
0 replies
-
I was thinking to generate a type like this: export type EntityManagerTypes<MetadataType = never, OperationMetadataType = never, Permissions extends string = never, SecurityDomain extends object = never> = {
entityManager: EntityManager<MetadataType, OperationMetadataType, Permissions, SecurityDomain>
params: {
metadata: MetadataType
middleware: EntityManagerMiddleware<MetadataType, OperationMetadataType>
groupMiddleware: GroupMiddleware<any, MetadataType, OperationMetadataType>
overrides: {
hotel: Pick<Partial<HotelDAOParams<MetadataType, OperationMetadataType>>, 'idGenerator' | 'middlewares' | 'metadata'>
reservation: Pick<Partial<ReservationDAOParams<MetadataType, OperationMetadataType>>, 'idGenerator' | 'middlewares' | 'metadata'>
role: Pick<Partial<RoleDAOParams<MetadataType, OperationMetadataType>>, 'middlewares' | 'metadata'>
room: Pick<Partial<RoomDAOParams<MetadataType, OperationMetadataType>>, 'idGenerator' | 'middlewares' | 'metadata'>
user: Pick<Partial<UserDAOParams<MetadataType, OperationMetadataType>>, 'idGenerator' | 'middlewares' | 'metadata'>
userRole: Pick<Partial<UserRoleDAOParams<MetadataType, OperationMetadataType>>, 'middlewares' | 'metadata'>
}
mongodb: Record<'default', M.Db | 'mock'>
scalars: T.UserInputDriverDataTypeAdapterMap<types.Scalars, 'mongo'>
log: T.LogInput<'hotel' | 'reservation' | 'role' | 'room' | 'user' | 'userRole'>
security: T.EntityManagerSecurtyPolicy<DAOGenericsMap<MetadataType, OperationMetadataType>, OperationMetadataType, Permissions, SecurityDomain>
}
security: {
context: T.DAOSecurityContext<SecurityDomain, Permissions>
policies: T.DAOSecurityPolicies<DAOGenericsMap<MetadataType, OperationMetadataType>, Permissions, SecurityDomain>
permissions: Permissions
domain: SecurityDomain
}
} I'd like to generate an all-encompassing type so that whatever type you need is there. Maybe I could add all the various DAOs too. In your cases you can do something like this: type EMT = EntityManagerTypes<...>
function getScalarSettings(): EMT['params']['scalars'] {
return { ... }
}
function getSecuritySettings(): EMT['params']['security'] {
return {
policies: getSecurityPolicies()
...
}
}
function getSecurityPolicies(): EMT['security']['policies'] {
return { ... }
} |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Right now it's really hard to decouple setting creation from EntityManager creation. This is because all the setting types in EntityManager are buried within layers of nested generics. In order to decouple code whilst maintaining typing + autocomplete, we have to dig into the internals of Typettta to find the right type. This means our code is now coupled to the implementation of the code generation.
In terms of what settings to expose as simplified types, I think
scalars
,security
, andsecurity.policies
should be given their own types.WITHOUT SUGGESTION
WITH SUGGESTION
Beta Was this translation helpful? Give feedback.
All reactions