37 lines
1014 B
TypeScript
37 lines
1014 B
TypeScript
import type { ZodType } from 'zod'
|
|
import type { UiGridColumn, UiGridFilter, UiGridSort } from '../ui/adapter/contracts'
|
|
|
|
export type CrudPermission = 'read' | 'create' | 'update' | 'delete' | 'export' | 'review' | 'publish'
|
|
export interface CrudListQuery {
|
|
page: number
|
|
pageSize: number
|
|
search?: string
|
|
sorts: UiGridSort[]
|
|
filters: UiGridFilter[]
|
|
}
|
|
export interface CrudPageResult<T> {
|
|
items: T[]
|
|
total: number
|
|
asOf: string
|
|
projectionVersion: string
|
|
watermark?: string
|
|
stale: boolean
|
|
}
|
|
export interface CrudMutationContext {
|
|
idempotencyKey: string
|
|
ifMatch?: string
|
|
reason?: string
|
|
correlationId?: string
|
|
}
|
|
export interface CrudResourceContract<TItem, TForm> {
|
|
resourceCode: string
|
|
routeBase: string
|
|
queryKey: readonly string[]
|
|
columns: UiGridColumn[]
|
|
formSchema: ZodType<TForm>
|
|
permissions: Partial<Record<CrudPermission, string>>
|
|
defaultQuery: CrudListQuery
|
|
parseListResponse(payload: unknown): CrudPageResult<TItem>
|
|
parseDetailResponse(payload: unknown): TItem
|
|
}
|