11import { toBooleanOrNull , toNumberOrNull , toStringOrNull } from '@sim/utils/coerce'
22import { toArray , toRecordOrNull } from '@sim/utils/object'
3- import type {
4- VeilleAsn ,
5- VeilleDns ,
6- VeilleIpLocation ,
7- VeilleMxRecord ,
8- VeilleWhois ,
9- } from '@/tools/veille/types'
3+ import type { VeilleDns , VeilleMxRecord } from '@/tools/veille/types'
104
115/** Reads a `VeilleMxRecord` from an untyped Veille API payload. */
126function mapVeilleMxRecord ( value : unknown ) : VeilleMxRecord | null {
@@ -33,50 +27,3 @@ export function mapVeilleDns(value: unknown): VeilleDns | null {
3327 . filter ( ( item ) : item is VeilleMxRecord => item !== null ) ,
3428 }
3529}
36-
37- /** Reads a `VeilleAsn` from an untyped Veille API payload. */
38- export function mapVeilleAsn ( value : unknown ) : VeilleAsn | null {
39- const record = toRecordOrNull ( value )
40- if ( ! record ) return null
41- return {
42- asn : toNumberOrNull ( record . asn ) ,
43- org : toStringOrNull ( record . org ) ,
44- type : toStringOrNull ( record . type ) ,
45- route : toStringOrNull ( record . route ) ,
46- domain : toStringOrNull ( record . domain ) ,
47- country : toStringOrNull ( record . country ) ,
48- abuse : toStringOrNull ( record . abuse ) ,
49- active : toBooleanOrNull ( record . active ) ,
50- }
51- }
52-
53- /** Reads a `VeilleIpLocation` from an untyped Veille API payload. */
54- export function mapVeilleIpLocation ( value : unknown ) : VeilleIpLocation | null {
55- const record = toRecordOrNull ( value )
56- if ( ! record ) return null
57- return {
58- city : toStringOrNull ( record . city ) ,
59- state : toStringOrNull ( record . state ) ,
60- country : toStringOrNull ( record . country ) ,
61- countryCode : toStringOrNull ( record . country_code ) ,
62- continent : toStringOrNull ( record . continent ) ,
63- zip : toStringOrNull ( record . zip ) ,
64- latitude : toNumberOrNull ( record . latitude ) ,
65- longitude : toNumberOrNull ( record . longitude ) ,
66- timezone : toStringOrNull ( record . timezone ) ,
67- isEuMember : toBooleanOrNull ( record . is_eu_member ) ,
68- currencyCode : toStringOrNull ( record . currency_code ) ,
69- }
70- }
71-
72- /** Reads a `VeilleWhois` from an untyped Veille API payload. */
73- export function mapVeilleWhois ( value : unknown ) : VeilleWhois | null {
74- const record = toRecordOrNull ( value )
75- if ( ! record ) return null
76- return {
77- registrar : toStringOrNull ( record . registrar ) ,
78- creationDate : toStringOrNull ( record . creation_date ) ,
79- updatedDate : toStringOrNull ( record . updated_date ) ,
80- expirationDate : toStringOrNull ( record . expiration_date ) ,
81- }
82- }
0 commit comments