Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions components/sibfly/actions/check-coverage/check-coverage.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import app from "../../sibfly.app.mjs";

export default {
key: "sibfly-check-coverage",
name: "Check Coverage",
description: "Free pre-flight: is a US address or point covered by SibFly, how stale is the data (`data_age_days`), and what would a report cost (`would_cost_usd`). Always free. [See the documentation](https://sibfly.com/docs).",
version: "0.0.1",
type: "action",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: true,
},
props: {
app,
address: {
propDefinition: [
app,
"address",
],
},
lat: {
propDefinition: [
app,
"lat",
],
},
lon: {
propDefinition: [
app,
"lon",
],
},
},
async run({ $ }) {
if (!this.address && (!this.lat || !this.lon)) {
throw new Error("Provide an Address, or both Latitude and Longitude.");
}
Comment on lines +36 to +38

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use ConfigurationError for pre-flight validation instead of generic Error.

This is a pre-call user-input validation check (missing address/lat/lon), which the repo convention handles via ConfigurationError from @pipedream/platform rather than a plain Error.

♻️ Proposed fix
-import app from "../../sibfly.app.mjs";
+import { ConfigurationError } from "`@pipedream/platform`";
+import app from "../../sibfly.app.mjs";
     if (!this.address && (!this.lat || !this.lon)) {
-      throw new Error("Provide an Address, or both Latitude and Longitude.");
+      throw new ConfigurationError("Provide an Address, or both Latitude and Longitude.");
     }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (!this.address && (!this.lat || !this.lon)) {
throw new Error("Provide an Address, or both Latitude and Longitude.");
}
import { ConfigurationError } from "`@pipedream/platform`";
import app from "../../sibfly.app.mjs";
if (!this.address && (!this.lat || !this.lon)) {
throw new ConfigurationError("Provide an Address, or both Latitude and Longitude.");
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@components/sibfly/actions/check-coverage/check-coverage.mjs` around lines 36
- 38, The pre-flight validation in checkCoverageAction is throwing a generic
Error for missing address/lat/lon input, but this repo expects user-input
validation failures to use ConfigurationError from `@pipedream/platform`. Update
the validation branch in checkCoverageAction to raise ConfigurationError instead
of Error, keeping the same message and preserving the existing address/lat/lon
check.

Source: Path instructions

const response = await this.app.checkCoverage({
$,
address: this.address,
lat: this.lat,
lon: this.lon,
});

const where = this.address ?? `${this.lat},${this.lon}`;
const summary = response.covered
? `${where}: covered, would cost $${response.would_cost_usd}, data ~${response.data_age_days} days old`
: `${where}: not covered (a report would be free)`;
$.export("$summary", summary);

return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import app from "../../sibfly.app.mjs";

export default {
key: "sibfly-check-ground-motion",
name: "Check Ground Motion",
description: "Measure how fast the ground is sinking or rising (mm/year, negative = sinking) under a US address, from NASA OPERA Sentinel-1 InSAR. Costs $0.40 for a covered report; out-of-coverage / low-quality results are free. Use Dry Run for a free coverage + price preview. [See the documentation](https://sibfly.com/docs).",
version: "0.0.1",
type: "action",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: true,
},
props: {
app,
address: {
propDefinition: [
app,
"address",
],
},
lat: {
propDefinition: [
app,
"lat",
],
},
lon: {
propDefinition: [
app,
"lon",
],
},
dryRun: {
propDefinition: [
app,
"dryRun",
],
},
},
async run({ $ }) {
if (!this.address && (!this.lat || !this.lon)) {
throw new Error("Provide an Address, or both Latitude and Longitude.");
}
Comment on lines +42 to +44

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Same ConfigurationError concern as check-coverage.mjs.

Same pre-flight validation pattern — should throw ConfigurationError instead of a generic Error.

♻️ Proposed fix
-import app from "../../sibfly.app.mjs";
+import { ConfigurationError } from "`@pipedream/platform`";
+import app from "../../sibfly.app.mjs";
     if (!this.address && (!this.lat || !this.lon)) {
-      throw new Error("Provide an Address, or both Latitude and Longitude.");
+      throw new ConfigurationError("Provide an Address, or both Latitude and Longitude.");
     }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (!this.address && (!this.lat || !this.lon)) {
throw new Error("Provide an Address, or both Latitude and Longitude.");
}
import { ConfigurationError } from "`@pipedream/platform`";
import app from "../../sibfly.app.mjs";
if (!this.address && (!this.lat || !this.lon)) {
throw new ConfigurationError("Provide an Address, or both Latitude and Longitude.");
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@components/sibfly/actions/check-ground-motion/check-ground-motion.mjs` around
lines 42 - 44, The pre-flight validation in checkGroundMotion should use the
same ConfigurationError pattern as check-coverage.mjs instead of throwing a
generic Error. Update the address/coordinate guard in the checkGroundMotion
logic to raise ConfigurationError with the same message, and keep the validation
flow consistent with the other action’s configuration checks. Use the existing
checkGroundMotion method and any imported ConfigurationError symbol to locate
and update the exception type.

Source: Path instructions

const response = await this.app.checkGroundMotion({
$,
address: this.address,
lat: this.lat,
lon: this.lon,
dryRun: this.dryRun,
});

const where = this.address ?? `${this.lat},${this.lon}`;
const summary = response.velocity_vertical_mm_yr != null
? `${where}: ${response.velocity_vertical_mm_yr} mm/yr (${response.assessment_code}), cost $${response.cost_usd}`
: `${where}: ${response.status ?? "no data"} (free, $0)`;
$.export("$summary", summary);

return response;
},
};
18 changes: 18 additions & 0 deletions components/sibfly/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "@pipedream/sibfly",
"version": "0.0.1",
"description": "Pipedream SibFly Components",
"main": "sibfly.app.mjs",
"keywords": [
"pipedream",
"sibfly"
],
"homepage": "https://pipedream.com/apps/sibfly",
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.0.3"
}
}
101 changes: 101 additions & 0 deletions components/sibfly/sibfly.app.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "sibfly",
propDefinitions: {
address: {
type: "string",
label: "Address",
description: "A US street address, for example `1100 Congress Ave, Austin, TX`. Provide this or latitude + longitude.",
optional: true,
},
lat: {
type: "string",
label: "Latitude",
description: "Latitude (use together with Longitude instead of Address).",
optional: true,
},
lon: {
type: "string",
label: "Longitude",
description: "Longitude (use together with Latitude instead of Address).",
optional: true,
},
dryRun: {
type: "boolean",
label: "Dry Run (Free Preview)",
description: "Return a free coverage + price preview (`would_cost_usd`) without buying the report or being charged.",
optional: true,
},
addresses: {
type: "string[]",
label: "Addresses",
description: "A list of US addresses to check in a single batch (up to 1000). Only covered rows are billed.",
},
},
methods: {
_baseUrl() {
return "https://sibfly.com/api/v1";
},
_headers(headers = {}) {
return {
"Authorization": `Bearer ${this.$auth.api_key}`,
"Content-Type": "application/json",
...headers,
};
},
_makeRequest({
$ = this, path, headers, ...args
}) {
return axios($, {
url: `${this._baseUrl()}${path}`,
headers: this._headers(headers),
...args,
});
},
_location({
address, lat, lon,
}) {
if (address) {
return { address };
}
return { lat, lon };
},
checkGroundMotion({
address, lat, lon, dryRun, ...args
} = {}) {
const params = this._location({ address, lat, lon });
if (dryRun) {
params.dry_run = 1;
}
return this._makeRequest({
path: "/motion",
params,
...args,
});
},
checkCoverage({
address, lat, lon, ...args
} = {}) {
return this._makeRequest({
path: "/coverage",
params: this._location({ address, lat, lon }),
...args,
});
},
checkPortfolio(args = {}) {
return this._makeRequest({
method: "POST",
path: "/motion/batch",
...args,
});
},
getBalance(args = {}) {
return this._makeRequest({
path: "/balance",
...args,
});
},
},
};