Skip to content

Commit d09891d

Browse files
mateen993coderabbitai[bot]michelle0927
authored
ipgeolocation_io: add app file and 12 actions (#20190)
* ipgeolocation_io: add app file and 12 actions * Update components/ipgeolocation_io/actions/get-abuse-contact/get-abuse-contact.mjs Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update components/ipgeolocation_io/actions/get-asn/get-asn.mjs Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update components/ipgeolocation_io/actions/get-bulk-geolocation/get-bulk-geolocation.mjs Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update components/ipgeolocation_io/actions/get-ip-security/get-ip-security.mjs Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update components/ipgeolocation_io/actions/parse-bulk-user-agents/parse-bulk-user-agents.mjs Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update components/ipgeolocation_io/ipgeolocation_io.app.mjs Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update components/ipgeolocation_io/README.md Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update components/ipgeolocation_io/README.md Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update components/ipgeolocation_io/actions/parse-user-agent/parse-user-agent.mjs Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * ipgeolocation_io: fix files path * ipgeolocation_io: fix: import + add: validation (convert-timezone) * ipgeolocation_io: add - validation (astronomy-time-series) * ipgeolocation_io: fix: apiKey input as props add * Update components/ipgeolocation_io/package.json Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * ipgeolocation_io: fix: auth + get-timezone * ipgeolocation_io: fix summary * ipgeolocation_io: add $ context * Update components/ipgeolocation_io/actions/get-astronomy/get-astronomy.mjs Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update components/ipgeolocation_io/actions/get-astronomy-time-series/get-astronomy-time-series.mjs Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * move ipgeolocation_io to ipgeolocation * move api call methods to app file * create common file for languages * update props to camelCase * pnpm-lock.yaml * fix key * update api key --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Michelle Bergeron <michelle.bergeron@gmail.com>
1 parent 696bf6d commit d09891d

File tree

16 files changed

+1091
-12
lines changed

16 files changed

+1091
-12
lines changed
Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
import ipgeolocation from "../../ipgeolocation.app.mjs";
2+
3+
export default {
4+
key: "ipgeolocation-convert-timezone",
5+
name: "Convert Timezone",
6+
description:
7+
"Convert a time between two timezones using timezone names, coordinates, city, IATA, ICAO, or UN/LOCODE. [See the documentation](https://ipgeolocation.io/documentation/timezone-api.html)",
8+
version: "0.0.1",
9+
type: "action",
10+
annotations: {
11+
destructiveHint: false,
12+
openWorldHint: true,
13+
readOnlyHint: true,
14+
},
15+
props: {
16+
ipgeolocation,
17+
tzFrom: {
18+
type: "string",
19+
label: "From Timezone",
20+
description: "Source timezone name (e.g. `America/New_York`). Must be used with `To Timezone`",
21+
optional: true,
22+
},
23+
tzTo: {
24+
type: "string",
25+
label: "To Timezone",
26+
description: "Target timezone name (e.g. `Asia/Tokyo`). Must be used with `From Timezone`",
27+
optional: true,
28+
},
29+
latFrom: {
30+
type: "string",
31+
label: "From Latitude",
32+
description: "Source latitude coordinate. Must be used with From Longitude",
33+
optional: true,
34+
},
35+
longFrom: {
36+
type: "string",
37+
label: "From Longitude",
38+
description: "Source longitude coordinate. Must be used with From Latitude",
39+
optional: true,
40+
},
41+
latTo: {
42+
type: "string",
43+
label: "To Latitude",
44+
description: "Target latitude coordinate. Must be used with To Longitude",
45+
optional: true,
46+
},
47+
longTo: {
48+
type: "string",
49+
label: "To Longitude",
50+
description: "Target longitude coordinate. Must be used with To Latitude",
51+
optional: true,
52+
},
53+
locationFrom: {
54+
type: "string",
55+
label: "From Location",
56+
description: "Source city or address (e.g. `New York, USA`). Must be used with To Location",
57+
optional: true,
58+
},
59+
locationTo: {
60+
type: "string",
61+
label: "To Location",
62+
description: "Target city or address (e.g. `London, UK`). Must be used with From Location",
63+
optional: true,
64+
},
65+
iataFrom: {
66+
type: "string",
67+
label: "From IATA Code",
68+
description: "Source airport IATA code (e.g. `JFK`). Must be used with To IATA Code",
69+
optional: true,
70+
},
71+
iataTo: {
72+
type: "string",
73+
label: "To IATA Code",
74+
description: "Target airport IATA code (e.g. `LHR`). Must be used with From IATA Code",
75+
optional: true,
76+
},
77+
icaoFrom: {
78+
type: "string",
79+
label: "From ICAO Code",
80+
description: "Source airport ICAO code (e.g. `KJFK`). Must be used with To ICAO Code",
81+
optional: true,
82+
},
83+
icaoTo: {
84+
type: "string",
85+
label: "To ICAO Code",
86+
description: "Target airport ICAO code (e.g. `EGLL`). Must be used with From ICAO Code",
87+
optional: true,
88+
},
89+
locodeFrom: {
90+
type: "string",
91+
label: "From UN/LOCODE",
92+
description: "Source UN/LOCODE (e.g. `USNYC`). Must be used with To UN/LOCODE",
93+
optional: true,
94+
},
95+
locodeTo: {
96+
type: "string",
97+
label: "To UN/LOCODE",
98+
description: "Target UN/LOCODE (e.g. `GBLON`). Must be used with From UN/LOCODE",
99+
optional: true,
100+
},
101+
time: {
102+
type: "string",
103+
label: "Time to Convert",
104+
description: "Time to convert in format `YYYY-MM-DD HH:mm` or `YYYY-MM-DD HH:mm:ss`. Leave blank to convert current time",
105+
optional: true,
106+
},
107+
},
108+
async run({ $ }) {
109+
const hasValue = (value) => value !== undefined && value !== null && value !== "";
110+
const hasPair = (from, to) => hasValue(from) && hasValue(to);
111+
const hasAnyCoord = [
112+
this.latFrom,
113+
this.longFrom,
114+
this.latTo,
115+
this.longTo,
116+
].some(hasValue);
117+
const hasFullCoordSet = [
118+
this.latFrom,
119+
this.longFrom,
120+
this.latTo,
121+
this.longTo,
122+
].every(hasValue);
123+
124+
if (
125+
(hasValue(this.tzFrom) !== hasValue(this.tzTo))
126+
|| (hasValue(this.locationFrom) !== hasValue(this.locationTo))
127+
|| (hasValue(this.iataFrom) !== hasValue(this.iataTo))
128+
|| (hasValue(this.icaoFrom) !== hasValue(this.icaoTo))
129+
|| (hasValue(this.locodeFrom) !== hasValue(this.locodeTo))
130+
|| (hasAnyCoord && !hasFullCoordSet)
131+
) {
132+
throw new Error("Provide complete source and target values for the selected conversion mode.");
133+
}
134+
135+
if (!(
136+
hasPair(this.tzFrom, this.tzTo)
137+
|| hasPair(this.locationFrom, this.locationTo)
138+
|| hasPair(this.iataFrom, this.iataTo)
139+
|| hasPair(this.icaoFrom, this.icaoTo)
140+
|| hasPair(this.locodeFrom, this.locodeTo)
141+
|| hasFullCoordSet
142+
)) {
143+
throw new Error("Provide a valid source and target using timezone names, coordinates, locations, IATA, ICAO, or UN/LOCODE.");
144+
}
145+
146+
const response = await this.ipgeolocation.convertTimezone({
147+
$,
148+
params: {
149+
tz_from: this.tzFrom,
150+
tz_to: this.tzTo,
151+
time: this.time,
152+
lat_from: this.latFrom,
153+
long_from: this.longFrom,
154+
lat_to: this.latTo,
155+
long_to: this.longTo,
156+
location_from: this.locationFrom,
157+
location_to: this.locationTo,
158+
iata_from: this.iataFrom,
159+
iata_to: this.iataTo,
160+
icao_from: this.icaoFrom,
161+
icao_to: this.icaoTo,
162+
locode_from: this.locodeFrom,
163+
locode_to: this.locodeTo,
164+
},
165+
});
166+
167+
let from, to;
168+
169+
if (hasPair(this.tzFrom, this.tzTo)) {
170+
from = this.tzFrom;
171+
to = this.tzTo;
172+
} else if (hasFullCoordSet) {
173+
from = `${this.latFrom},${this.longFrom}`;
174+
to = `${this.latTo},${this.longTo}`;
175+
} else if (hasPair(this.locationFrom, this.locationTo)) {
176+
from = this.locationFrom;
177+
to = this.locationTo;
178+
} else if (hasPair(this.iataFrom, this.iataTo)) {
179+
from = this.iataFrom;
180+
to = this.iataTo;
181+
} else if (hasPair(this.icaoFrom, this.icaoTo)) {
182+
from = this.icaoFrom;
183+
to = this.icaoTo;
184+
} else {
185+
from = this.locodeFrom;
186+
to = this.locodeTo;
187+
}
188+
189+
$.export("$summary", `Successfully converted time from ${from} to ${to}`);
190+
return response;
191+
},
192+
};
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import ipgeolocation from "../../ipgeolocation.app.mjs";
2+
3+
export default {
4+
key: "ipgeolocation-get-abuse-contact",
5+
name: "Get Abuse Contact",
6+
description:
7+
"Retrieve abuse contact information for an IPv4 or IPv6 address, including abuse emails, phone numbers, organization, and network route. Only available on paid plans. [See the documentation](https://ipgeolocation.io/documentation/ip-abuse-contact-api.html)",
8+
version: "0.0.1",
9+
type: "action",
10+
annotations: {
11+
destructiveHint: false,
12+
openWorldHint: true,
13+
readOnlyHint: true,
14+
},
15+
props: {
16+
ipgeolocation,
17+
ip: {
18+
type: "string",
19+
label: "IP Address",
20+
description: "The IPv4 or IPv6 address to retrieve abuse contact information for. Leave blank to retrieve abuse contact information for the caller's IP address",
21+
optional: true,
22+
},
23+
fields: {
24+
type: "string",
25+
label: "Fields",
26+
description: "Comma-separated list of fields to return (e.g. `abuse.emails,abuse.organization`). Reduces response size",
27+
optional: true,
28+
},
29+
excludes: {
30+
type: "string",
31+
label: "Exclude Fields",
32+
description: "Comma-separated list of fields to exclude from the response. The `ip` field is always returned",
33+
optional: true,
34+
},
35+
},
36+
async run({ $ }) {
37+
const response = await this.ipgeolocation.getAbuseContact({
38+
$,
39+
params: {
40+
ip: this.ip,
41+
fields: this.fields,
42+
excludes: this.excludes,
43+
},
44+
});
45+
$.export("$summary", `Successfully retrieved abuse contact for ${this.ip || `caller's IP: ${response.ip}`}`);
46+
return response;
47+
},
48+
};
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import ipgeolocation from "../../ipgeolocation.app.mjs";
2+
3+
export default {
4+
key: "ipgeolocation-get-asn",
5+
name: "Get ASN Details",
6+
description:
7+
"Retrieve detailed ASN information including peers, upstreams, downstreams, routes, and WHOIS data for an ASN number or IP address. Only available on paid plans. [See the documentation](https://ipgeolocation.io/documentation/asn-api.html)",
8+
version: "0.0.1",
9+
type: "action",
10+
annotations: {
11+
destructiveHint: false,
12+
openWorldHint: true,
13+
readOnlyHint: true,
14+
},
15+
props: {
16+
ipgeolocation,
17+
ip: {
18+
type: "string",
19+
label: "IP Address",
20+
description: "The IPv4/IPv6 address to look up. Leave blank to lookup ASN data for the caller's IP address",
21+
optional: true,
22+
},
23+
asn: {
24+
type: "string",
25+
label: "ASN",
26+
description: "The ASN number (e.g. `AS15169`). If both `ip` and `asn` are provided, `asn` will be used",
27+
optional: true,
28+
},
29+
include: {
30+
type: "string",
31+
label: "Include Additional Data",
32+
description: "Comma-separated list of extra modules to include in the response. Available values: `routes`, `peers`, `upstreams`, `downstreams`, `whois_response`. Use `*` to include all.",
33+
optional: true,
34+
},
35+
fields: {
36+
type: "string",
37+
label: "Fields",
38+
description: "Comma-separated list of fields to return (e.g. `asn.organization,asn.routes`). Reduces response size",
39+
optional: true,
40+
},
41+
excludes: {
42+
type: "string",
43+
label: "Exclude Fields",
44+
description: "Comma-separated list of fields to exclude from the response. The `ip` field is always returned if querying by IP address",
45+
optional: true,
46+
},
47+
},
48+
async run({ $ }) {
49+
const response = await this.ipgeolocation.getAsn({
50+
$,
51+
params: {
52+
asn: this.asn,
53+
ip: this.ip,
54+
include: this.include,
55+
fields: this.fields,
56+
excludes: this.excludes,
57+
},
58+
});
59+
$.export("$summary", `Successfully retrieved ASN details for ${this.asn || this.ip || `caller's IP: ${response.ip}`}`);
60+
return response;
61+
},
62+
};

0 commit comments

Comments
 (0)