Skip to content

Commit f583b39

Browse files
author
Josselin Liebe
committed
fix(veille): address review feedback
- Keep response mappers with a single caller in that tool's file - Document the VeilleIcon export
1 parent 086492f commit f583b39

5 files changed

Lines changed: 64 additions & 60 deletions

File tree

‎apps/docs/components/icons.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10460,6 +10460,7 @@ export function PlaneIcon(props: SVGProps<SVGSVGElement>) {
1046010460
)
1046110461
}
1046210462

10463+
/** Veille logo, as used by the Veille block. */
1046310464
export function VeilleIcon(props: SVGProps<SVGSVGElement>) {
1046410465
return (
1046510466
<svg viewBox='-2.3 -0.3 20.6 20.6' fill='none' xmlns='http://www.w3.org/2000/svg' {...props}>

‎apps/sim/components/icons.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10460,6 +10460,7 @@ export function PlaneIcon(props: SVGProps<SVGSVGElement>) {
1046010460
)
1046110461
}
1046210462

10463+
/** Veille logo, as used by the Veille block. */
1046310464
export function VeilleIcon(props: SVGProps<SVGSVGElement>) {
1046410465
return (
1046510466
<svg viewBox='-2.3 -0.3 20.6 20.6' fill='none' xmlns='http://www.w3.org/2000/svg' {...props}>

‎apps/sim/tools/veille/check_domain.ts‎

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
11
import { toBooleanOrNull, toNumberOrNull, toStringOrNull } from '@sim/utils/coerce'
2-
import { toArray, toRecord } from '@sim/utils/object'
2+
import { toArray, toRecord, toRecordOrNull } from '@sim/utils/object'
33
import type { ToolConfig } from '@/tools/types'
4-
import type { VeilleCheckDomainParams, VeilleCheckDomainResponse } from '@/tools/veille/types'
4+
import type {
5+
VeilleCheckDomainParams,
6+
VeilleCheckDomainResponse,
7+
VeilleWhois,
8+
} from '@/tools/veille/types'
59
import { VEILLE_DNS_OUTPUT_PROPERTIES, VEILLE_WHOIS_OUTPUT_PROPERTIES } from '@/tools/veille/types'
6-
import { mapVeilleDns, mapVeilleWhois } from '@/tools/veille/utils'
10+
import { mapVeilleDns } from '@/tools/veille/utils'
11+
12+
/** Reads a `VeilleWhois` from an untyped Veille API payload. */
13+
function mapVeilleWhois(value: unknown): VeilleWhois | null {
14+
const record = toRecordOrNull(value)
15+
if (!record) return null
16+
return {
17+
registrar: toStringOrNull(record.registrar),
18+
creationDate: toStringOrNull(record.creation_date),
19+
updatedDate: toStringOrNull(record.updated_date),
20+
expirationDate: toStringOrNull(record.expiration_date),
21+
}
22+
}
723

824
export const veilleCheckDomainTool: ToolConfig<VeilleCheckDomainParams, VeilleCheckDomainResponse> =
925
{

‎apps/sim/tools/veille/check_ip.ts‎

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,51 @@
11
import { toBooleanOrNull, toNumberOrNull, toStringOrNull } from '@sim/utils/coerce'
2-
import { toRecord } from '@sim/utils/object'
2+
import { toRecord, toRecordOrNull } from '@sim/utils/object'
33
import type { ToolConfig } from '@/tools/types'
4-
import type { VeilleCheckIpParams, VeilleCheckIpResponse } from '@/tools/veille/types'
4+
import type {
5+
VeilleAsn,
6+
VeilleCheckIpParams,
7+
VeilleCheckIpResponse,
8+
VeilleIpLocation,
9+
} from '@/tools/veille/types'
510
import {
611
VEILLE_ASN_OUTPUT_PROPERTIES,
712
VEILLE_IP_LOCATION_OUTPUT_PROPERTIES,
813
} from '@/tools/veille/types'
9-
import { mapVeilleAsn, mapVeilleIpLocation } from '@/tools/veille/utils'
14+
15+
/** Reads a `VeilleAsn` from an untyped Veille API payload. */
16+
function mapVeilleAsn(value: unknown): VeilleAsn | null {
17+
const record = toRecordOrNull(value)
18+
if (!record) return null
19+
return {
20+
asn: toNumberOrNull(record.asn),
21+
org: toStringOrNull(record.org),
22+
type: toStringOrNull(record.type),
23+
route: toStringOrNull(record.route),
24+
domain: toStringOrNull(record.domain),
25+
country: toStringOrNull(record.country),
26+
abuse: toStringOrNull(record.abuse),
27+
active: toBooleanOrNull(record.active),
28+
}
29+
}
30+
31+
/** Reads a `VeilleIpLocation` from an untyped Veille API payload. */
32+
function mapVeilleIpLocation(value: unknown): VeilleIpLocation | null {
33+
const record = toRecordOrNull(value)
34+
if (!record) return null
35+
return {
36+
city: toStringOrNull(record.city),
37+
state: toStringOrNull(record.state),
38+
country: toStringOrNull(record.country),
39+
countryCode: toStringOrNull(record.country_code),
40+
continent: toStringOrNull(record.continent),
41+
zip: toStringOrNull(record.zip),
42+
latitude: toNumberOrNull(record.latitude),
43+
longitude: toNumberOrNull(record.longitude),
44+
timezone: toStringOrNull(record.timezone),
45+
isEuMember: toBooleanOrNull(record.is_eu_member),
46+
currencyCode: toStringOrNull(record.currency_code),
47+
}
48+
}
1049

1150
export const veilleCheckIpTool: ToolConfig<VeilleCheckIpParams, VeilleCheckIpResponse> = {
1251
id: 'veille_check_ip',

‎apps/sim/tools/veille/utils.ts‎

Lines changed: 1 addition & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
import { toBooleanOrNull, toNumberOrNull, toStringOrNull } from '@sim/utils/coerce'
22
import { 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. */
126
function 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

Comments
 (0)