feat(types): add action api types to ApiInfo

This commit is contained in:
2026-04-16 15:59:32 +00:00
parent 025a7ccca4
commit 4b588d1269
Vendored
+222 -8
View File
@@ -13,24 +13,108 @@ declare global {
export type BoolOrEval = boolean | { eval: string }
/** Structured field validator as defined in Go CollectionField.Validator */
export interface FieldImageValidator {
/** Minimum allowed image width in pixels */
minWidth?: number
/** Maximum allowed image width in pixels */
maxWidth?: number
/** Minimum allowed image height in pixels */
minHeight?: number
/** Maximum allowed image height in pixels */
maxHeight?: number
/** Allow non-image uploads to bypass image dimension checks entirely */
allowNonImages?: boolean
/** Allow image/* uploads to pass when dimensions cannot be determined */
allowUnknownDimensions?: boolean
}
export interface FieldValidator {
/** Array of allowed values */
/** Array of allowed primitive values the field may equal */
in?: any[]
/** Built-in string format validator */
format?: "email" | "url" | "uuid" | "slug"
/** Whether the field is required */
required?: boolean
/** Whether zero-values are allowed when required is true */
allowZero?: boolean
/** JS eval expression for custom validation */
eval?: string
/** Minimum number of items for array fields */
minItems?: number
/** Maximum number of items for array fields */
maxItems?: number
/** Minimum number of characters for string values */
minLength?: number
/** Maximum number of characters for string values */
maxLength?: number
/** Regex pattern the string value must fully match */
pattern?: string
/** Minimum numeric value */
min?: number
/** Maximum numeric value */
max?: number
/** Earliest allowed date/time value for date, time, and datetime fields */
minDate?: string
/** Latest allowed date/time value for date, time, and datetime fields */
maxDate?: string
/** Minimum decoded file size (e.g. 50KB) for file and file[] fields */
minFileSize?: string
/** Maximum decoded file size (e.g. 5MB) */
maxFileSize?: string
/** Allowed MIME types for file and file[] fields */
accept?: string[]
/** Image dimension bounds for newly uploaded file and file[] images */
image?: FieldImageValidator
}
export interface ScoreConfig {
expr?: { [key: string]: any }
}
export interface RegexConfig {
weights?: { [field: string]: number }
scoring?: "count" | "binary" | "log"
}
export interface NormalizeConfig {
use?: string[]
eval?: string
}
export interface NgramConfig {
sizes?: number[]
normalize?: NormalizeConfig
}
export interface RrfConfig {
k?: number
topK?: number
weights?: { [source: string]: number }
}
export interface VectorConfig {
provider: string
documentPrefix?: string
queryPrefix?: string
overflow?: "truncate" | "chunk"
chunkSize?: number
chunkOverlap?: number
}
/** Search configuration for a collection */
export interface SearchConfig {
/** Search config name (used in query parameter qName) */
name: string
/** Search mode: text (MongoDB text index), regex, eval (JS), filter, ngram */
mode: "text" | "regex" | "eval" | "filter" | "ngram"
/** Fields to search in (for text/regex mode) */
/** Search mode: text, regex, eval, filter, ngram, vector or combined */
mode:
| "text"
| "regex"
| "eval"
| "filter"
| "ngram"
| "vector"
| "combined"
/** Fields to search in (for regex and ngram mode) */
fields?: string[]
/** Meta information */
meta?: { [key: string]: any }
@@ -38,6 +122,18 @@ declare global {
eval?: string
/** MongoDB filter template (for filter mode) */
filter?: { [key: string]: any }
/** Ngram search configuration */
ngram?: NgramConfig
/** Regex search configuration */
regex?: RegexConfig
/** Custom scoring for eval/filter search */
score?: ScoreConfig
/** Vector search configuration */
vector?: VectorConfig
/** Reciprocal rank fusion configuration */
rrf?: RrfConfig
/** Auto-regenerate enrichment data when the config changes */
autoRegenerate?: boolean
}
/** Query limits configuration for a collection */
@@ -88,10 +184,76 @@ declare global {
export interface AuditCollectionConfig {
/** Whether audit logging is enabled for this collection */
enabled?: boolean
/** List of actions to audit: create, update, delete, bulkCreate, bulkUpdate, bulkDelete, get */
actions?: string[]
/** List of actions to audit */
actions?: Array<
| "create"
| "update"
| "delete"
| "bulkCreate"
| "bulkUpdate"
| "bulkDelete"
>
}
export interface UploadConfig {
maxBodySize?: string
allowedMimeTypes?: string[]
}
export type LocalizedText = string | Record<string, string>
export type ChoiceValue = string | number | boolean | null
export interface ChoiceItem {
id?: ChoiceValue
value?: ChoiceValue
name?: LocalizedText
label?: LocalizedText
badgeVariant?: "success" | "error" | "warning" | "info" | "neutral"
chipVariant?: "success" | "error" | "warning" | "info" | "neutral"
badgeStyle?: Record<string, string | number | boolean>
chipStyle?: Record<string, string | number | boolean>
}
export type EvalStringConfig = {
eval: string
select?: string[]
}
export type EvalHtmlConfig = {
eval: string
raw?: boolean
select?: string[]
}
export interface PreviewTableColumn {
source?: string
label?: LocalizedText
align?: "left" | "center" | "right"
eval?: string
raw?: boolean
select?: string[]
}
export type PreviewSlotValue = string | EvalStringConfig
export interface PreviewSlots {
label?: PreviewSlotValue
labelStyle?: PreviewSlotValue
secondary?: PreviewSlotValue
tertiary?: PreviewSlotValue
badge?: PreviewSlotValue
image?: PreviewSlotValue
imageFallback?: PreviewSlotValue
mediaFile?: string
eval?: string
raw?: boolean
table?: Array<string | PreviewTableColumn>
select?: string[]
}
export type PreviewConfig = string | EvalHtmlConfig | PreviewSlots
/** Image filter parameters — used in both CollectionConfig.imageFilter and ImagePackage.filter() */
export interface ImageFilterParams {
width?: number
@@ -143,6 +305,7 @@ declare global {
export interface CollectionInfo {
name: string
defaultLanguage?: string
upload?: UploadConfig
permissions?: { [role: string]: PermissionSet }
projections?: { [name: string]: ProjectionConfig }
meta?: { [key: string]: any }
@@ -168,6 +331,53 @@ declare global {
[key: string]: any
}
/** Action endpoint descriptor as returned by context.api() for _actions resources */
export interface ActionInfo {
name: string
meta?: ActionMeta
[key: string]: any
}
export interface ActionMeta {
label?: LocalizedText
muiIcon?: string
description?: LocalizedText
group?: string
hide?: boolean
methods?: Record<string, ActionMethodMeta>
[key: string]: any
}
export interface ActionMethodMeta {
query?: {
title?: LocalizedText
description?: LocalizedText
fields?: CollectionFieldInfo[]
}
data?: {
title?: LocalizedText
description?: LocalizedText
fields?: CollectionFieldInfo[]
}
execution?: ActionExecutionMeta
output?: ActionOutputMeta
[key: string]: any
}
export interface ActionExecutionMeta {
kind?: "sync" | "sse" | string
progress?: boolean
cancellable?: boolean
[key: string]: any
}
export interface ActionOutputMeta {
display?: "summary" | "detail" | "raw" | "download" | "none" | string
title?: LocalizedText
fields?: CollectionFieldInfo[]
[key: string]: any
}
export type MethodPermission = boolean | { allow: boolean; bulk?: boolean }
export type SimpleMethodPermission = boolean | { allow: boolean }
@@ -220,6 +430,7 @@ declare global {
meta?: { [key: string]: any }
assets?: { name: string; path: string }[]
collections?: CollectionInfo[]
actions?: ActionInfo[]
jobs?: JobConfig[]
errors?: { collection?: string; context?: string; error: any }[]
[key: string]: any
@@ -1314,7 +1525,10 @@ declare global {
}
export interface HookContext
extends GetHookData, GetHookGetOnlyData, PostHookData, JobData {
extends GetHookData,
GetHookGetOnlyData,
PostHookData,
JobData {
request(): {
method: string
remoteAddr: string
@@ -1329,7 +1543,7 @@ declare global {
/**
* bodyBytes return []byte go slice of post body for later use pe. in iso8859ToUtf8
*/
bodyBytes(): string
bodyBytes(): Int8Array
}
api(): ApiInfo