You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
1.3 KiB
65 lines
1.3 KiB
2 years ago
|
|
||
|
export enum FieldType {
|
||
|
text = 'text',
|
||
|
textarea = 'textarea',
|
||
|
email = 'email',
|
||
|
number = 'number',
|
||
|
integer = 'integer',
|
||
|
date = 'date',
|
||
|
select = 'select',
|
||
|
}
|
||
|
|
||
|
enum ResourceAction {
|
||
|
create = 'create',
|
||
|
read = 'read',
|
||
|
readOne = 'readOne',
|
||
|
update = 'update',
|
||
|
delete = 'delete',
|
||
|
}
|
||
|
|
||
|
export enum Renderer {
|
||
|
text = 'text',
|
||
|
html = 'html',
|
||
|
bool = 'bool',
|
||
|
date = 'date',
|
||
|
time = 'time',
|
||
|
datetime = 'datetime',
|
||
|
}
|
||
|
|
||
|
const allResourceActions = [
|
||
|
ResourceAction.create, ResourceAction.read, ResourceAction.readOne,
|
||
|
ResourceAction.update, ResourceAction.delete,
|
||
|
]
|
||
|
|
||
|
export type FieldBase = {
|
||
|
key: string,
|
||
|
display: string,
|
||
|
type: FieldType,
|
||
|
required: boolean,
|
||
|
sort?: 'asc' | 'desc',
|
||
|
renderer?: Renderer,
|
||
|
readonly?: boolean,
|
||
|
helpText?: string,
|
||
|
placeholder?: string,
|
||
|
}
|
||
|
|
||
|
export type SelectOptions = {display: string, value: any}[]
|
||
|
|
||
|
export type FieldDefinition = FieldBase
|
||
|
| FieldBase & { type: FieldType.select, options: SelectOptions }
|
||
|
|
||
|
export interface ResourceConfiguration {
|
||
|
key: string,
|
||
|
collection: string,
|
||
|
primaryKey: string,
|
||
|
display: {
|
||
|
field?: string,
|
||
|
singular: string,
|
||
|
plural: string,
|
||
|
},
|
||
|
supportedActions: ResourceAction[],
|
||
|
fields: FieldDefinition[],
|
||
|
}
|
||
|
|
||
|
export { ResourceAction, allResourceActions }
|