Skip to content

Commit 7239580

Browse files
authored
get-order validate orderId (#18978)
1 parent 9462baa commit 7239580

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

components/shopify_developer_app/actions/get-order/get-order.mjs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { MAX_LIMIT } from "@pipedream/shopify/common/constants.mjs";
22
import shopify from "../../shopify_developer_app.app.mjs";
3+
import { ConfigurationError } from "@pipedream/platform";
34

45
export default {
56
key: "shopify_developer_app-get-order",
67
name: "Get Order",
78
description: "Retrieve an order by specifying the order ID. [See the documentation](https://shopify.dev/docs/api/admin-graphql/latest/queries/order)",
8-
version: "0.0.9",
9+
version: "0.0.10",
910
annotations: {
1011
destructiveHint: false,
1112
openWorldHint: true,
@@ -21,12 +22,27 @@ export default {
2122
],
2223
},
2324
},
25+
methods: {
26+
validateOrderId(orderId) {
27+
const prefix = "gid://shopify/Order/";
28+
const value = String(orderId).trim();
29+
if (value.startsWith(prefix)) {
30+
return value;
31+
}
32+
if (/^\d+$/.test(value)) {
33+
return `${prefix}${value}`;
34+
}
35+
throw new ConfigurationError(`Invalid order ID: ${orderId}`);
36+
},
37+
},
2438
async run({ $ }) {
39+
const orderId = this.validateOrderId(this.orderId);
40+
2541
const response = await this.shopify.getOrder({
26-
id: this.orderId,
42+
id: orderId,
2743
first: MAX_LIMIT,
2844
});
29-
$.export("$summary", `Successfully retrieved order with ID: ${this.orderId}`);
45+
$.export("$summary", `Successfully retrieved order with ID: ${orderId}`);
3046
return response;
3147
},
3248
};

components/shopify_developer_app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/shopify_developer_app",
3-
"version": "0.10.0",
3+
"version": "0.10.1",
44
"description": "Pipedream Shopify (Developer App) Components",
55
"main": "shopify_developer_app.app.mjs",
66
"keywords": [

0 commit comments

Comments
 (0)