2022-07-04 08:04:11 +00:00
|
|
|
|
|
|
|
export enum FieldType {
|
|
|
|
text = 'text',
|
|
|
|
textarea = 'textarea',
|
2022-07-09 17:58:13 +00:00
|
|
|
html = 'html',
|
2022-07-04 08:04:11 +00:00
|
|
|
email = 'email',
|
|
|
|
number = 'number',
|
|
|
|
integer = 'integer',
|
|
|
|
date = 'date',
|
|
|
|
select = 'select',
|
2022-07-09 17:58:13 +00:00
|
|
|
bool = 'bool',
|
2022-07-04 08:04:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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,
|
2022-07-09 17:58:13 +00:00
|
|
|
hideOn?: {
|
|
|
|
form?: boolean,
|
|
|
|
listing?: boolean,
|
|
|
|
},
|
2022-07-04 08:04:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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 }
|