generated from alphane/template
45 lines
1.1 KiB
TypeScript
45 lines
1.1 KiB
TypeScript
/** Keep in sync with api/src/controllers/base-controller.ts#ModelOrder */
|
|
export type ModelOrder =
|
|
| [string, string]
|
|
| [string, string, string]
|
|
| [string, string, string, string]
|
|
| [string, string, string, string, string]
|
|
| [string, string, string, string, string, string]
|
|
|
|
export type Policy = {
|
|
show: boolean
|
|
create: boolean
|
|
update: boolean
|
|
destroy: boolean
|
|
}
|
|
|
|
export type WhereOptions<Model, Attributes extends keyof Model> = {
|
|
[K in Attributes]?: Model[K] | Model[K][]
|
|
}
|
|
|
|
export type FiltersOptions<Options> = Partial<Options>
|
|
|
|
export type QueryOptions<WhereOptions, FiltersOptions> = Partial<{
|
|
where: WhereOptions
|
|
filters: FiltersOptions
|
|
order: ModelOrder[]
|
|
page: number
|
|
perPage: number
|
|
}>
|
|
|
|
// Keep in sync with api/src/controllers/base-controller.ts
|
|
export const MAX_PER_PAGE = 1000
|
|
|
|
export type ApiResponseError = { field?: string; text: string }
|
|
|
|
export type ApiResponseLegacy<T> = {
|
|
data: T
|
|
errors: ApiResponseError[]
|
|
messages?: string[]
|
|
}
|
|
|
|
export type ApiResponse<TPayload = object> = {
|
|
errors: ApiResponseError[]
|
|
messages?: string[]
|
|
} & TPayload
|