102 lines
3.0 KiB
TypeScript
102 lines
3.0 KiB
TypeScript
import apiClient from './client'
|
|
|
|
export type ConditionField =
|
|
| 'from_address'
|
|
| 'to_address'
|
|
| 'subject'
|
|
| 'mailbox_id'
|
|
| 'pec_type'
|
|
/** Tassonomia (N2): verifica se il messaggio ha gia' una specifica etichetta (UUID come valore) */
|
|
| 'has_label'
|
|
/** Rischio e Riservatezza (N3): verifica il livello gia' impostato sul messaggio */
|
|
| 'risk_level'
|
|
| 'confidentiality'
|
|
/** Campi aggiuntivi del messaggio */
|
|
| 'has_attachments' // "true" / "false"
|
|
| 'direction' // "inbound" / "outbound"
|
|
| 'protocol_type' // "pec_it" / "rem_eu"
|
|
| 'body_contains' // testo nel corpo del messaggio
|
|
|
|
export type ConditionOperator = 'contains' | 'equals' | 'starts_with' | 'ends_with' | 'regex' | 'not_contains'
|
|
|
|
export type ActionType =
|
|
| 'apply_label'
|
|
| 'assign_vbox'
|
|
| 'mark_read'
|
|
| 'mark_starred'
|
|
| 'notify_webhook'
|
|
/** Tassonomia (N2): applica un nodo tassonomico (Ambito/Processo/Classificazione) */
|
|
| 'apply_taxonomy'
|
|
/** Rischio e Riservatezza (N3): imposta il livello di rischio o riservatezza */
|
|
| 'set_risk_level'
|
|
| 'set_confidentiality'
|
|
/** Gestione messaggio */
|
|
| 'archive'
|
|
| 'mark_for_conservation'
|
|
/** Scadenzario: valore = giorni (es. "30") o formato "+30d", "+4w", "+1y" */
|
|
| 'set_deadline'
|
|
/** Fascicolazione: valore = UUID del fascicolo */
|
|
| 'add_to_fascicolo'
|
|
/** Notifiche multi-canale: valore = UUID del NotificationChannel */
|
|
| 'notify_channel'
|
|
|
|
export interface RoutingRuleCondition {
|
|
id: string
|
|
field: ConditionField
|
|
operator: ConditionOperator
|
|
value: string
|
|
}
|
|
|
|
export interface RoutingRuleAction {
|
|
id: string
|
|
action_type: ActionType
|
|
action_value: string | null
|
|
}
|
|
|
|
export interface RoutingRuleResponse {
|
|
id: string
|
|
tenant_id: string
|
|
name: string
|
|
description: string | null
|
|
is_active: boolean
|
|
priority: number
|
|
stop_processing: boolean
|
|
conditions: RoutingRuleCondition[]
|
|
actions: RoutingRuleAction[]
|
|
created_by: string | null
|
|
created_at: string
|
|
updated_at: string
|
|
}
|
|
|
|
export interface RoutingRuleCreate {
|
|
name: string
|
|
description?: string | null
|
|
is_active?: boolean
|
|
priority?: number
|
|
stop_processing?: boolean
|
|
conditions?: Array<{ field: ConditionField; operator: ConditionOperator; value: string }>
|
|
actions?: Array<{ action_type: ActionType; action_value?: string | null }>
|
|
}
|
|
|
|
export type RoutingRuleUpdate = Partial<RoutingRuleCreate>
|
|
|
|
export const routingRulesApi = {
|
|
list: () =>
|
|
apiClient.get<{ items: RoutingRuleResponse[]; total: number }>('/routing-rules').then((r) => r.data),
|
|
|
|
get: (id: string) =>
|
|
apiClient.get<RoutingRuleResponse>(`/routing-rules/${id}`).then((r) => r.data),
|
|
|
|
create: (data: RoutingRuleCreate) =>
|
|
apiClient.post<RoutingRuleResponse>('/routing-rules', data).then((r) => r.data),
|
|
|
|
update: (id: string, data: RoutingRuleUpdate) =>
|
|
apiClient.put<RoutingRuleResponse>(`/routing-rules/${id}`, data).then((r) => r.data),
|
|
|
|
delete: (id: string) =>
|
|
apiClient.delete(`/routing-rules/${id}`).then((r) => r.data),
|
|
|
|
toggle: (id: string) =>
|
|
apiClient.post<RoutingRuleResponse>(`/routing-rules/${id}/toggle`).then((r) => r.data),
|
|
}
|