378 lines
7.8 KiB
TypeScript
378 lines
7.8 KiB
TypeScript
export type Paginated<T> = {
|
|
count: number;
|
|
next: string | null;
|
|
previous: string | null;
|
|
results: T[];
|
|
};
|
|
|
|
export type UserStatus = 'active' | 'inactive' | 'superadmin';
|
|
|
|
export type User = {
|
|
id: number;
|
|
user_name: string;
|
|
display_name: string;
|
|
status: UserStatus;
|
|
created_at: string;
|
|
updated_at: string;
|
|
};
|
|
|
|
export type Site = {
|
|
id: string;
|
|
site_name: string;
|
|
user: number;
|
|
created_at: string;
|
|
updated_at: string;
|
|
};
|
|
|
|
export type PusatRegistration = {
|
|
site_id: string;
|
|
site_name: string;
|
|
code: string;
|
|
active_site_id: number | null;
|
|
registered_at: string | null;
|
|
};
|
|
|
|
export type FeedInButtonUrl = {
|
|
label: string;
|
|
url: string;
|
|
};
|
|
|
|
export type Kandang = {
|
|
id: number;
|
|
kandang_name: string;
|
|
feed_in_button_urls: FeedInButtonUrl[];
|
|
site: string;
|
|
created_at: string;
|
|
updated_at: string;
|
|
};
|
|
|
|
export type Flock = {
|
|
id: number;
|
|
flock_name: string;
|
|
kandang: number;
|
|
created_at: string;
|
|
updated_at: string;
|
|
};
|
|
|
|
export type CycleStatus = 'active' | 'pending_close' | 'closed';
|
|
|
|
export type Cycle = {
|
|
id: number;
|
|
kandang: number;
|
|
kandang_name: string;
|
|
total_days: number;
|
|
current_day: number;
|
|
visible_through_date: string;
|
|
soft_end_date?: string;
|
|
start_date: string;
|
|
end_date: string | null;
|
|
chick_in_weight: number;
|
|
doc_in_count: number;
|
|
feed_initial_balance: number;
|
|
feed_initial_balance_date?: string | null;
|
|
status: CycleStatus;
|
|
proposed_end_date?: string | null;
|
|
close_requested_at?: string | null;
|
|
close_requested_by?: number | null;
|
|
created_at: string;
|
|
updated_at: string;
|
|
};
|
|
|
|
export type KPI = {
|
|
id: number;
|
|
cycle: number;
|
|
kandang: number;
|
|
flock_id: number;
|
|
date: string;
|
|
age: number;
|
|
mortality: number;
|
|
mortality_total: number;
|
|
feed: number;
|
|
feed_total: number;
|
|
harvest: number;
|
|
harvest_total: number;
|
|
harvest_weight: number;
|
|
harvest_weight_total: number;
|
|
chicken_life: number;
|
|
chicken_life_percentage: number;
|
|
iot_weight: number;
|
|
average_harvest_day: number;
|
|
average_harvest_weight: number;
|
|
fcr: number;
|
|
eef: number;
|
|
cc: number;
|
|
cw: number;
|
|
fs: number;
|
|
manual: number;
|
|
created_at: string;
|
|
updated_at: string;
|
|
};
|
|
|
|
export type ManualInput = {
|
|
id: number;
|
|
cycle: number;
|
|
kandang: number;
|
|
flock_id: number;
|
|
date: string;
|
|
age_manual: number;
|
|
mortality_manual: number;
|
|
mortality_manual_total: number;
|
|
feed_in_manual: number;
|
|
feed_use_manual: number;
|
|
feed_in_manual_total: number;
|
|
feed_use_manual_total: number;
|
|
feed_out_manual: number;
|
|
feed_out_manual_total: number;
|
|
harvest_manual: number;
|
|
harvest_manual_total: number;
|
|
harvest_weight_manual: number;
|
|
harvest_weight_manual_total: number;
|
|
manual_weight: number;
|
|
average_harvest_day_manual: number;
|
|
average_harvest_weight_manual: number;
|
|
fcr_manual: number;
|
|
eef_manual: number;
|
|
created_at: string;
|
|
updated_at: string;
|
|
};
|
|
|
|
export type ChickenCounting = {
|
|
id: number;
|
|
cycle: number;
|
|
kandang: number;
|
|
flock_id: number;
|
|
date: string;
|
|
total_count: number;
|
|
mortality_count: number;
|
|
created_at: string;
|
|
updated_at: string;
|
|
};
|
|
|
|
export type ChickenWeight = {
|
|
id: number;
|
|
cycle: number;
|
|
kandang: number;
|
|
flock_id: number;
|
|
date: string;
|
|
age: number;
|
|
doc_weight: number;
|
|
average_weight: number;
|
|
chicken_count: number;
|
|
uniformity: number;
|
|
average_daily_gain: number;
|
|
created_at: string;
|
|
updated_at: string;
|
|
};
|
|
|
|
export type LatestAvg = {
|
|
average_weight: number;
|
|
date: string;
|
|
age: number;
|
|
uniformity: number;
|
|
average_daily_gain: number;
|
|
cycle: number;
|
|
kandang: number;
|
|
};
|
|
|
|
export type Karung = {
|
|
id: number;
|
|
cycle: number;
|
|
kandang: number;
|
|
flock_id: number;
|
|
date: string;
|
|
in_today: number;
|
|
out_today: number;
|
|
in_total: number;
|
|
out_total: number;
|
|
feed_use_today: number;
|
|
feed_use_total: number;
|
|
created_at: string;
|
|
updated_at: string;
|
|
};
|
|
|
|
export type PanelIoT = {
|
|
id: number;
|
|
flock: number;
|
|
flock_id: number;
|
|
kandang: number | null;
|
|
date: string;
|
|
timestamp: string | null;
|
|
wind_speed: number;
|
|
humidity: number;
|
|
water_total: number;
|
|
average_temperature: number;
|
|
experience_temperature: number;
|
|
created_at: string;
|
|
updated_at: string;
|
|
};
|
|
|
|
export type AIInsight = {
|
|
id: number;
|
|
cycle: number;
|
|
kandang: number | null;
|
|
flock_id?: number;
|
|
date: string;
|
|
insight_text: string;
|
|
/** Condition from graded facts: healthy | warning | critical | unknown */
|
|
alert: string;
|
|
topic: string;
|
|
report_type: string;
|
|
report_period: string;
|
|
summary?: string;
|
|
citations?: InsightCitation[];
|
|
created_at: string;
|
|
updated_at: string;
|
|
};
|
|
|
|
export type InsightReportType = 'page' | 'daily' | 'weekly' | 'end_cycle';
|
|
|
|
export type InsightTopic =
|
|
| 'hitung_ayam'
|
|
| 'berat_ayam'
|
|
| 'fcr'
|
|
| 'eef'
|
|
| 'iot_panel'
|
|
| 'hitung_karung'
|
|
| 'dashboard';
|
|
|
|
export type InsightCitation = {
|
|
id?: string;
|
|
title?: string;
|
|
chapter?: string;
|
|
excerpt?: string;
|
|
source?: string;
|
|
};
|
|
|
|
/**
|
|
* Curated page context sent to the insight service.
|
|
* `kandangId` is required — never generate for "all kandang".
|
|
*/
|
|
export type InsightContext = {
|
|
kandangId: number;
|
|
kandangName?: string;
|
|
cycleId?: number;
|
|
hari_ke?: number | null;
|
|
totalDays?: number | null;
|
|
periode?: string | null;
|
|
[key: string]: unknown;
|
|
};
|
|
|
|
export type InsightGenerateParams = {
|
|
cycle_id: number;
|
|
kandang_id: number;
|
|
topic: InsightTopic | string;
|
|
report_type?: InsightReportType;
|
|
report_period?: string | null;
|
|
context: InsightContext;
|
|
force_refresh?: boolean;
|
|
};
|
|
|
|
export type InsightCachedParams = {
|
|
cycle_id: number;
|
|
kandang_id: number;
|
|
topic: InsightTopic | string;
|
|
report_type?: InsightReportType;
|
|
report_period?: string | null;
|
|
};
|
|
|
|
export type InsightStatusLabel = 'ok' | 'warning' | 'critical' | 'unknown';
|
|
|
|
export type InsightStructuredSection = {
|
|
status: InsightStatusLabel;
|
|
bullets: string[];
|
|
evidence: string[];
|
|
actions: string[];
|
|
};
|
|
|
|
export type InsightStructuredReport = {
|
|
summary: {
|
|
headline: string;
|
|
bullets: string[];
|
|
risks: string[];
|
|
actions: string[];
|
|
};
|
|
detailed?: Partial<
|
|
Record<
|
|
'hitung_ayam' | 'berat_ayam' | 'fcr' | 'eef' | 'panel_iot' | 'data_quality',
|
|
InsightStructuredSection
|
|
>
|
|
>;
|
|
};
|
|
|
|
/** Response from generate / cached insight endpoints. */
|
|
export type InsightApiResponse = {
|
|
success?: boolean;
|
|
insight_text: string;
|
|
summary?: string;
|
|
insight?: string;
|
|
structured?: InsightStructuredReport | null;
|
|
citations?: InsightCitation[];
|
|
message?: string;
|
|
};
|
|
|
|
export type KarungRequestResult = {
|
|
karung: Karung;
|
|
upstream: Record<string, unknown>;
|
|
};
|
|
|
|
export type CycleFilter = {
|
|
cycle_id?: number;
|
|
kandang_id?: number;
|
|
site_id?: number;
|
|
flock_id?: number;
|
|
date?: string;
|
|
status?: CycleStatus;
|
|
};
|
|
|
|
export type SiteWrite = { site_name: string; user: number };
|
|
export type KandangWrite = {
|
|
kandang_name: string;
|
|
site: string;
|
|
feed_in_button_urls?: FeedInButtonUrl[];
|
|
};
|
|
export type FlockWrite = {
|
|
flock_name: string;
|
|
kandang: number;
|
|
};
|
|
export type CycleWrite = {
|
|
kandang: number;
|
|
total_days?: number;
|
|
current_day?: number;
|
|
start_date: string;
|
|
chick_in_weight: number;
|
|
doc_in_count: number;
|
|
feed_initial_balance?: number;
|
|
feed_initial_balance_date?: string | null;
|
|
status?: CycleStatus;
|
|
};
|
|
|
|
export type InitialBalanceResult = {
|
|
cycle: number;
|
|
date: string;
|
|
feed_initial_balance: number;
|
|
feed_initial_balance_date: string | null;
|
|
manual: number;
|
|
manual_total: number;
|
|
iot: number | null;
|
|
accuracy: number | null;
|
|
sync_error: string | null;
|
|
};
|
|
export type CountingWrite = {
|
|
cycle: number;
|
|
date: string;
|
|
total_count?: number;
|
|
mortality_count?: number;
|
|
};
|
|
export type ManualInputWrite = {
|
|
cycle: number;
|
|
date?: string;
|
|
age_manual?: number;
|
|
mortality_manual?: number;
|
|
feed_in_manual?: number;
|
|
feed_use_manual?: number;
|
|
feed_out_manual?: number;
|
|
harvest_manual?: number;
|
|
harvest_weight_manual?: number;
|
|
manual_weight?: number;
|
|
};
|