Additional drizzle cleanup. Move scrub transformation to server side.

This commit is contained in:
Patrick Fic
2026-01-20 11:59:39 -08:00
parent 8954147976
commit 27370bba6d
16 changed files with 1589 additions and 1653 deletions

View File

@@ -0,0 +1,243 @@
import { JobLine, RawJobDataObject } from "./raw-job-data.interface";
// ES Job Object with transformed fields
export interface ESJobObject extends Omit<
RawJobDataObject,
// Agent fields
| "cat_no"
| "ciecaid"
| "agt_co_id"
| "agt_co_nm"
| "agt_addr1"
| "agt_addr2"
| "agt_city"
| "agt_st"
| "agt_zip"
| "agt_ctry"
| "agt_ph1"
| "agt_ph1x"
| "agt_ph2"
| "agt_ph2x"
| "agt_fax"
| "agt_faxx"
| "agt_ct_ln"
| "agt_ct_fn"
| "agt_ct_ph"
| "agt_ct_phx"
| "agt_ea"
| "agt_lic_no"
// Adjustment fields
| "adj_g_disc"
| "adj_strdis"
| "adj_towdis"
// Assignment fields
| "asgn_date"
| "asgn_no"
| "asgn_type"
// Claim fields
| "clm_addr1"
| "clm_addr2"
| "clm_city"
| "clm_ct_fn"
| "clm_ct_ln"
| "clm_ct_ph"
| "clm_ct_phx"
| "clm_ctry"
| "clm_ea"
| "clm_fax"
| "clm_faxx"
| "clm_ofc_id"
| "clm_ofc_nm"
| "clm_ph1"
| "clm_ph1x"
| "clm_ph2"
| "clm_ph2x"
| "clm_st"
| "clm_title"
| "clm_zip"
| "clm_total"
// Misc fields
| "cust_pr"
| "date_estimated"
| "ded_status"
| "depreciation_taxes"
// Estimator fields
| "est_addr1"
| "est_addr2"
| "est_city"
| "est_co_nm"
| "est_ct_fn"
| "est_ct_ln"
| "est_ctry"
| "est_ea"
| "est_ph1"
| "est_st"
| "est_zip"
| "federal_tax_rate"
// Insurance fields
| "ins_addr1"
| "ins_addr2"
| "ins_city"
| "ins_co_id"
| "ins_ct_fn"
| "ins_ct_ln"
| "ins_ct_ph"
| "ins_ct_phx"
| "ins_ctry"
| "ins_ea"
| "ins_fax"
| "ins_faxx"
| "ins_ph1"
| "ins_ph1x"
| "ins_ph2"
| "ins_ph2x"
| "ins_st"
| "ins_title"
| "ins_zip"
| "insd_fax"
| "insd_faxx"
// Loss fields
| "kmin"
| "loss_cat"
| "loss_type"
// Owner fields
| "ownr_addr2"
| "ownr_co_nm"
| "ownr_ctry"
| "ownr_ea"
| "ownr_ph2"
| "ownr_st"
| "ownr_title"
| "ownr_zip"
// Payment fields
| "pay_amt"
| "pay_chknm"
| "pay_date"
| "pay_type"
| "payee_nms"
// Vehicle fields
| "plate_no"
| "plate_st"
| "policy_no"
// Rate fields
| "rate_la1"
| "rate_la2"
| "rate_la3"
| "rate_la4"
| "rate_laa"
| "rate_lab"
| "rate_lad"
| "rate_lae"
| "rate_laf"
| "rate_lag"
| "rate_lam"
| "rate_lar"
| "rate_las"
| "rate_lau"
| "rate_ma2s"
| "rate_ma2t"
| "rate_ma3s"
| "rate_mabl"
| "rate_macs"
| "rate_mahw"
| "rate_mapa"
| "rate_mash"
// Tax fields
| "tax_lbr_rt"
| "tax_levies_rt"
| "tax_paint_mat_rt"
| "tax_predis"
| "tax_prethr"
| "tax_pstthr"
| "tax_shop_mat_rt"
| "tax_str_rt"
| "tax_sub_rt"
| "tax_thramt"
| "tax_tow_rt"
// Additional vehicle fields
| "theft_ind"
| "v_color"
| "tlos_ind"
| "v_make_desc"
| "v_model_desc"
| "shopid"
| "est_system"
// Object fields
| "owner"
| "vehicle"
| "bodyshop"
| "area_of_damage"
| "joblines"
// CIECA fields
| "cieca_pft"
| "cieca_pfl"
| "cieca_pfm"
| "cieca_pfo"
| "cieca_stl"
| "cieca_ttl"
| "parts_tax_rates"
| "materials"
> {
// Fields added by the transformer
impact_1?: string;
impact_2?: string;
close_date: string | null;
created_at: string;
id: string;
group?: string;
group_verified?: boolean;
updated_at: string;
v_age: number;
v_type: string;
v_makedesc?: string;
v_model?: string;
supp_amt: number;
ro_number: string | null;
requires_reimport: boolean;
v_mileage: string;
id_pro_nam?: string;
g_ttl_amt: number;
source_system: string;
rf_ph1: string;
rf_zip: string;
association_switch: string;
sending_entity_id: string;
sending_entity_accept_terms_of_use: boolean;
// Transformed arrays
joblines: Omit<
JobLine,
| "lbr_tax"
| "lbr_typ_j"
| "line_ref"
| "misc_sublt"
| "misc_tax"
| "prt_dsmk_m"
| "prt_dsmk_p"
| "tran_code"
| "unq_seq"
| "alt_co_id"
| "alt_overrd"
| "alt_part_i"
| "alt_partm"
| "bett_type"
| "bett_pctg"
| "bett_amt"
| "bett_tax"
| "op_code_desc"
| "paint_stg"
| "paint_tone"
>[];
totals: Array<{
nt_hrs?: number;
t_amt?: number;
t_hrs?: number;
ttl_typecd?: string;
}>;
rates: Array<
| { cal_prethr?: number; mat_type?: string }
| { lbr_desc?: string; lbr_rate?: number; lbr_type?: string }
>;
}

2
shared/types/index.ts Normal file
View File

@@ -0,0 +1,2 @@
export * from "./raw-job-data.interface";
export * from "./es-job-object.interface";

View File

@@ -0,0 +1,312 @@
import { UUID } from "crypto";
// Re-export interfaces needed for RawJobDataObject
// Note: The decoder interfaces would need to be moved to shared as well
// or we define the minimal structure here
export interface RawJobDataObject {
// From DecodedEnv
insp_date?: string;
loss_date?: string;
rf_city?: string;
rf_zip?: string;
rf_st?: string;
rf_ln?: string;
rf_fn?: string;
rf_ph1?: string;
rf_ph2?: string;
rf_addr1?: string;
rf_ctry?: string;
ins_co_nm?: string;
clm_no?: string;
est_system?: string;
// From other decoders
cat_no?: string;
ciecaid?: string;
agt_co_id?: string;
agt_co_nm?: string;
agt_addr1?: string;
agt_addr2?: string;
agt_city?: string;
agt_st?: string;
agt_zip?: string;
agt_ctry?: string;
agt_ph1?: string;
agt_ph1x?: string;
agt_ph2?: string;
agt_ph2x?: string;
agt_fax?: string;
agt_faxx?: string;
agt_ct_ln?: string;
agt_ct_fn?: string;
agt_ct_ph?: string;
agt_ct_phx?: string;
agt_ea?: string;
agt_lic_no?: string;
adj_g_disc?: number;
adj_strdis?: number;
adj_towdis?: number;
asgn_date?: string;
asgn_no?: string;
asgn_type?: string;
clm_addr1?: string;
clm_addr2?: string;
clm_city?: string;
clm_ct_fn?: string;
clm_ct_ln?: string;
clm_ct_ph?: string;
clm_ct_phx?: string;
clm_ctry?: string;
clm_ea?: string;
clm_fax?: string;
clm_faxx?: string;
clm_ofc_id?: string;
clm_ofc_nm?: string;
clm_ph1?: string;
clm_ph1x?: string;
clm_ph2?: string;
clm_ph2x?: string;
clm_st?: string;
clm_title?: string;
clm_zip?: string;
cust_pr?: string;
date_estimated?: string;
ded_status?: string;
depreciation_taxes?: number;
est_addr1?: string;
est_addr2?: string;
est_city?: string;
est_co_nm?: string;
est_ct_fn?: string;
est_ct_ln?: string;
est_ctry?: string;
est_ea?: string;
est_ph1?: string;
est_st?: string;
est_zip?: string;
federal_tax_rate?: number;
ins_addr1?: string;
ins_addr2?: string;
ins_city?: string;
ins_co_id?: string;
ins_ct_fn?: string;
ins_ct_ln?: string;
ins_ct_ph?: string;
ins_ct_phx?: string;
ins_ctry?: string;
ins_ea?: string;
ins_fax?: string;
ins_faxx?: string;
ins_ph1?: string;
ins_ph1x?: string;
ins_ph2?: string;
ins_ph2x?: string;
ins_st?: string;
ins_title?: string;
ins_zip?: string;
insd_fax?: string;
insd_faxx?: string;
kmin?: number;
loss_cat?: string;
loss_type?: string;
ownr_addr1?: string;
ownr_addr2?: string;
ownr_co_nm?: string;
ownr_ctry?: string;
ownr_ea?: string;
ownr_ph1?: string;
ownr_ph2?: string;
ownr_st?: string;
ownr_title?: string;
ownr_zip?: string;
ownr_ln?: string;
ownr_fn?: string;
ownr_city?: string;
pay_amt?: number;
pay_chknm?: string;
pay_date?: string;
pay_type?: string;
payee_nms?: string;
plate_no?: string;
plate_st?: string;
policy_no?: string;
rate_la1?: number;
rate_la2?: number;
rate_la3?: number;
rate_la4?: number;
rate_laa?: number;
rate_lab?: number;
rate_lad?: number;
rate_lae?: number;
rate_laf?: number;
rate_lag?: number;
rate_lam?: number;
rate_lar?: number;
rate_las?: number;
rate_lau?: number;
rate_ma2s?: number;
rate_ma2t?: number;
rate_ma3s?: number;
rate_mabl?: number;
rate_macs?: number;
rate_mahw?: number;
rate_mapa?: number;
rate_mash?: number;
tax_lbr_rt?: number;
tax_levies_rt?: number;
tax_paint_mat_rt?: number;
tax_predis?: number;
tax_prethr?: number;
tax_pstthr?: number;
tax_shop_mat_rt?: number;
tax_str_rt?: number;
tax_sub_rt?: number;
tax_thramt?: number;
tax_tow_rt?: number;
theft_ind?: boolean;
v_color?: string;
tlos_ind?: boolean;
v_make_desc?: string;
v_model_desc?: string;
v_year?: string;
// Claimant fields
clmt_ln?: string;
clmt_fn?: string;
clmt_title?: string;
clmt_co_nm?: string;
clmt_addr1?: string;
clmt_addr2?: string;
clmt_city?: string;
clmt_st?: string;
clmt_zip?: string;
clmt_ctry?: string;
clmt_ph1?: string;
clmt_ph2?: string;
clmt_ea?: string;
// Insured fields
insd_ln?: string;
insd_fn?: string;
insd_title?: string;
insd_co_nm?: string;
insd_addr1?: string;
insd_addr2?: string;
insd_city?: string;
insd_st?: string;
insd_zip?: string;
insd_ctry?: string;
insd_ph1?: string;
insd_ph2?: string;
insd_ea?: string;
// Object fields
owner?: {
data?: Record<string, unknown>;
};
vehicle?: Record<string, unknown>;
bodyshop?: Record<string, unknown>;
area_of_damage?: {
impact1?: string;
impact2?: string;
};
joblines?: {
data?: JobLine[];
};
clm_total?: number;
// CIECA fields
cieca_pft?: CiecaPft;
cieca_pfl?: Record<string, CiecaPfl>;
cieca_pfm?: CiecaPfm[];
cieca_pfo?: CiecaPfo;
cieca_stl?: CiecaStl;
cieca_ttl?: CiecaTtl;
parts_tax_rates?: Record<string, unknown>;
materials?: Record<string, unknown>;
vehicleid?: UUID;
shopid?: UUID;
}
export interface JobLine {
line_no?: string;
line_ind?: string;
line_ref?: string;
tran_code?: string;
db_ref?: string;
unq_seq?: string;
line_desc?: string;
part_type?: string;
glass_flag?: boolean;
oem_partno?: string;
price_inc?: boolean;
alt_part_i?: boolean;
tax_part?: boolean;
db_price?: number;
act_price?: number;
price_j?: boolean;
cert_part?: boolean;
part_qty?: number;
alt_co_id?: string;
alt_partno?: string;
alt_overrd?: boolean;
alt_partm?: string;
prt_dsmk_p?: string;
prt_dsmk_m?: string;
mod_lbr_ty?: string;
db_hrs?: number;
mod_lb_hrs?: number;
lbr_inc?: boolean;
lbr_op?: string;
lbr_hrs_j?: boolean;
lbr_typ_j?: boolean;
lbr_op_j?: boolean;
paint_stg?: string;
paint_tone?: string;
lbr_tax?: boolean;
lbr_amt?: number;
misc_amt?: number;
misc_sublt?: string;
misc_tax?: boolean;
bett_type?: string;
bett_pctg?: string | number;
bett_amt?: number;
bett_tax?: boolean;
op_code_desc?: string;
}
export interface CiecaPft {
data?: Record<string, unknown>;
}
export interface CiecaPfl {
lbr_desc?: string;
lbr_rate?: number;
lbr_type?: string;
}
export interface CiecaPfm {
cal_prethr?: number;
matl_type?: string;
}
export interface CiecaPfo {
data?: Record<string, unknown>;
}
export interface CiecaStl {
data?: Array<{
nt_hrs?: number;
t_amt?: number;
t_hrs?: number;
ttl_typecd?: string;
}>;
}
export interface CiecaTtl {
data?: {
supp_amt?: number;
};
}