Function: defineSchema()
defineSchema<
Relations,ActionRelations,SubT,ObjT,HierarchyProp>(schema):AuthSchema<Relations,ActionRelations,HierarchyProp,SubT,ObjT>
Defined in: packages/polizy/src/types.ts:169
Helper function to define an AuthSchema with strong type inference for structure. Captures the literal types of relation and action names. Subject and Object types are captured via optional arrays and generics.
Type Parameters
Relations
Relations extends Readonly<Record<string, RelationDefinition>>
ActionRelations
ActionRelations extends Readonly<Record<string, readonly keyof Relations[]>>
SubT
SubT extends string
ObjT
ObjT extends string
HierarchyProp
HierarchyProp extends Readonly<Record<keyof ActionRelations, readonly keyof ActionRelations[]>> | undefined = undefined
Parameters
schema
actionToRelations
ActionRelations
fieldLevelObjects?
readonly ObjT[]
fieldSeparator?
string
hierarchyPropagation?
HierarchyProp
objectTypes?
readonly ObjT[]
relations
Relations
subjectTypes?
readonly SubT[]
Returns
AuthSchema<Relations, ActionRelations, HierarchyProp, SubT, ObjT>