@pipedream/shopify_developer_app 0.2.5 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/shopify_developer_app",
3
- "version": "0.2.5",
3
+ "version": "0.4.0",
4
4
  "description": "Pipedream Shopify (Developer App) Components",
5
5
  "main": "shopify_developer_app.app.mjs",
6
6
  "keywords": [
@@ -13,7 +13,7 @@
13
13
  "access": "public"
14
14
  },
15
15
  "dependencies": {
16
- "@pipedream/platform": "^1.5.1",
16
+ "@pipedream/platform": "^3.0.0",
17
17
  "shopify-api-node": "^3.12.5"
18
18
  }
19
19
  }
@@ -0,0 +1,20 @@
1
+ import common from "./webhook.mjs";
2
+
3
+ export default {
4
+ ...common,
5
+ props: {
6
+ ...common.props,
7
+ metafieldNamespaces: {
8
+ type: "string[]",
9
+ label: "Metafield Namespaces",
10
+ description: "Array of namespaces for any metafields that should be included with each webhook. Metafield definitions can be found in your store's Settings -> Custom Data. Select a metafield to view its namespace under \"Namespace and key\". For example, if the value is `custom.test_metafield`, the namespace is `custom`.",
11
+ optional: true,
12
+ },
13
+ privateMetafieldNamespaces: {
14
+ type: "string[]",
15
+ label: "Private Metafield Namespaces",
16
+ description: "Array of namespaces for any private metafields that should be included with each webhook. Metafield definitions can be found in your store's Settings -> Custom Data. Select a metafield to view its namespace under \"Namespace and key\". For example, if the value is `custom.test_metafield`, the namespace is `custom`.",
17
+ optional: true,
18
+ },
19
+ },
20
+ };
@@ -9,18 +9,6 @@ export default {
9
9
  type: "$.interface.http",
10
10
  customResponse: true,
11
11
  },
12
- metafieldNamespaces: {
13
- type: "string[]",
14
- label: "Metafield Namespaces",
15
- description: "Array of namespaces for any metafields that should be included with each webhook",
16
- optional: true,
17
- },
18
- privateMetafieldNamespaces: {
19
- type: "string[]",
20
- label: "Private Metafield Namespaces",
21
- description: "Array of namespaces for any private metafields that should be included with each webhook",
22
- optional: true,
23
- },
24
12
  },
25
13
  hooks: {
26
14
  async activate() {
@@ -59,6 +47,39 @@ export default {
59
47
  return this.app.getShopId() === shopId
60
48
  && this.getTopic() === topic;
61
49
  },
50
+ checkMetaFields({
51
+ metafields = [], private_metafields: privateMetafields = [],
52
+ } = {}) {
53
+ let validateMetafield = true;
54
+ let validatePrivateMetafield = true;
55
+ if (this.metafieldNamespaces?.length) {
56
+ validateMetafield = false;
57
+ for (const metafieldNamespace of this.metafieldNamespaces) {
58
+ for (const metafieldObj of metafields) {
59
+ if (metafieldObj.namespace === metafieldNamespace) {
60
+ validateMetafield = true;
61
+ break;
62
+ }
63
+ }
64
+ if (validateMetafield) break;
65
+ }
66
+ }
67
+
68
+ if (this.privateMetafieldNamespaces?.length) {
69
+ validatePrivateMetafield = false;
70
+ for (const privateMetafieldNamespace of this.privateMetafieldNamespaces) {
71
+ for (const privateMetafieldObj of privateMetafields) {
72
+ if (privateMetafieldObj.namespace === privateMetafieldNamespace) {
73
+ validatePrivateMetafield = true;
74
+ break;
75
+ }
76
+ }
77
+ if (validatePrivateMetafield) break;
78
+ }
79
+ }
80
+
81
+ return validateMetafield && validatePrivateMetafield;
82
+ },
62
83
  isRelevant() {
63
84
  return true;
64
85
  },
@@ -89,7 +110,7 @@ export default {
89
110
  status: 200,
90
111
  });
91
112
 
92
- if (this.isRelevant(resource)) {
113
+ if (this.isRelevant(resource) && this.checkMetaFields(resource)) {
93
114
  this.$emit(resource, this.generateMeta(resource));
94
115
  }
95
116
  },
@@ -1,5 +1,5 @@
1
- import common from "../common/webhook.mjs";
2
1
  import constants from "../common/constants.mjs";
2
+ import common from "../common/webhook-metafields.mjs";
3
3
 
4
4
  export default {
5
5
  ...common,
@@ -7,7 +7,7 @@ export default {
7
7
  name: "New Cancelled Order (Instant)",
8
8
  type: "source",
9
9
  description: "Emit new event each time a new order is cancelled.",
10
- version: "0.0.2",
10
+ version: "0.0.4",
11
11
  dedupe: "unique",
12
12
  methods: {
13
13
  ...common.methods,
@@ -1,5 +1,5 @@
1
- import common from "../common/webhook.mjs";
2
1
  import constants from "../common/constants.mjs";
2
+ import common from "../common/webhook-metafields.mjs";
3
3
 
4
4
  export default {
5
5
  ...common,
@@ -7,7 +7,7 @@ export default {
7
7
  name: "New Customer Created (Instant)",
8
8
  type: "source",
9
9
  description: "Emit new event for each new customer added to a store.",
10
- version: "0.0.2",
10
+ version: "0.0.4",
11
11
  dedupe: "unique",
12
12
  methods: {
13
13
  ...common.methods,
@@ -1,5 +1,5 @@
1
- import common from "../common/webhook.mjs";
2
1
  import constants from "../common/constants.mjs";
2
+ import common from "../common/webhook-metafields.mjs";
3
3
 
4
4
  export default {
5
5
  ...common,
@@ -7,7 +7,7 @@ export default {
7
7
  name: "New Draft Order (Instant)",
8
8
  type: "source",
9
9
  description: "Emit new event for each new draft order submitted to a store.",
10
- version: "0.0.2",
10
+ version: "0.0.4",
11
11
  dedupe: "unique",
12
12
  methods: {
13
13
  ...common.methods,
@@ -1,5 +1,5 @@
1
- import common from "../common/webhook.mjs";
2
1
  import constants from "../common/constants.mjs";
2
+ import common from "../common/webhook-metafields.mjs";
3
3
 
4
4
  export default {
5
5
  ...common,
@@ -7,7 +7,7 @@ export default {
7
7
  name: "New Event Emitted (Instant)",
8
8
  type: "source",
9
9
  description: "Emit new event for each new Shopify event.",
10
- version: "0.0.2",
10
+ version: "0.0.4",
11
11
  dedupe: "unique",
12
12
  props: {
13
13
  ...common.props,
@@ -1,5 +1,5 @@
1
- import common from "../common/webhook.mjs";
2
1
  import constants from "../common/constants.mjs";
2
+ import common from "../common/webhook-metafields.mjs";
3
3
 
4
4
  export default {
5
5
  ...common,
@@ -7,7 +7,7 @@ export default {
7
7
  name: "New Order Created (Instant)",
8
8
  type: "source",
9
9
  description: "Emit new event for each new order submitted to a store.",
10
- version: "0.0.2",
10
+ version: "0.0.4",
11
11
  dedupe: "unique",
12
12
  methods: {
13
13
  ...common.methods,
@@ -1,5 +1,5 @@
1
- import common from "../common/webhook.mjs";
2
1
  import constants from "../common/constants.mjs";
2
+ import common from "../common/webhook-metafields.mjs";
3
3
 
4
4
  export default {
5
5
  ...common,
@@ -7,7 +7,7 @@ export default {
7
7
  name: "New Paid Order (Instant)",
8
8
  type: "source",
9
9
  description: "Emit new event each time a new order is paid.",
10
- version: "0.0.2",
10
+ version: "0.0.4",
11
11
  dedupe: "unique",
12
12
  methods: {
13
13
  ...common.methods,
@@ -1,5 +1,5 @@
1
- import common from "../common/webhook.mjs";
2
1
  import constants from "../common/constants.mjs";
2
+ import common from "../common/webhook-metafields.mjs";
3
3
 
4
4
  export default {
5
5
  ...common,
@@ -7,7 +7,7 @@ export default {
7
7
  name: "New Product Created (Instant)",
8
8
  type: "source",
9
9
  description: "Emit new event for each product added to a store.",
10
- version: "0.0.2",
10
+ version: "0.0.4",
11
11
  dedupe: "unique",
12
12
  methods: {
13
13
  ...common.methods,
@@ -0,0 +1,55 @@
1
+ import constants from "../common/constants.mjs";
2
+ import common from "../common/webhook-metafields.mjs";
3
+
4
+ export default {
5
+ ...common,
6
+ key: "shopify_developer_app-new-product-updated",
7
+ name: "New Product Updated (Instant)",
8
+ description: "Emit new event for each product updated in a store.",
9
+ version: "0.0.2",
10
+ type: "source",
11
+ dedupe: "unique",
12
+ props: {
13
+ ...common.props,
14
+ productType: {
15
+ type: "string",
16
+ label: "Product Type",
17
+ description: "Filter results by product type",
18
+ optional: true,
19
+ },
20
+ tags: {
21
+ type: "string[]",
22
+ label: "Tags",
23
+ description: "Filter results by product tag(s)",
24
+ optional: true,
25
+ },
26
+ },
27
+ methods: {
28
+ ...common.methods,
29
+ getTopic() {
30
+ return constants.EVENT_TOPIC.PRODUCTS_UPDATE;
31
+ },
32
+ isRelevant(resource) {
33
+ let relevant = true;
34
+ if (this.productType && resource.product_type !== this.productType) {
35
+ relevant = false;
36
+ }
37
+ if (this.tags?.length) {
38
+ this.tags.forEach((tag) => {
39
+ if (!resource.tags?.includes(tag)) {
40
+ relevant = false;
41
+ }
42
+ });
43
+ }
44
+ return relevant;
45
+ },
46
+ generateMeta(resource) {
47
+ const ts = Date.parse(resource.updated_at);
48
+ return {
49
+ id: `${resource.id}-${ts}`,
50
+ summary: `Product Updated ${resource.id}`,
51
+ ts,
52
+ };
53
+ },
54
+ },
55
+ };
@@ -0,0 +1,64 @@
1
+ export default {
2
+ "admin_graphql_api_id": "gid://shopify/Product/8416570474776",
3
+ "body_html": null,
4
+ "created_at": "2023-06-30T13:38:03-04:00",
5
+ "handle": "best-product-ever",
6
+ "id": 8416570474776,
7
+ "product_type": "",
8
+ "published_at": "2023-06-30T13:38:03-04:00",
9
+ "template_suffix": null,
10
+ "title": "product",
11
+ "updated_at": "2024-06-18T14:37:58-04:00",
12
+ "vendor": "Testing",
13
+ "status": "active",
14
+ "published_scope": "web",
15
+ "tags": "abc, def",
16
+ "variants": [
17
+ {
18
+ "admin_graphql_api_id": "gid://shopify/ProductVariant/45612961333528",
19
+ "barcode": null,
20
+ "compare_at_price": null,
21
+ "created_at": "2023-06-30T13:38:03-04:00",
22
+ "fulfillment_service": "manual",
23
+ "id": 45612961333528,
24
+ "inventory_management": null,
25
+ "inventory_policy": "deny",
26
+ "position": 1,
27
+ "price": "0.00",
28
+ "product_id": 8416570474776,
29
+ "sku": "",
30
+ "taxable": true,
31
+ "title": "Default Title",
32
+ "updated_at": "2023-10-27T10:08:17-04:00",
33
+ "option1": "Default Title",
34
+ "option2": null,
35
+ "option3": null,
36
+ "grams": 0,
37
+ "image_id": null,
38
+ "weight": 0,
39
+ "weight_unit": "lb",
40
+ "inventory_item_id": 47661178487064,
41
+ "inventory_quantity": 0,
42
+ "old_inventory_quantity": 0,
43
+ "requires_shipping": true
44
+ },
45
+ ],
46
+ "options": [
47
+ {
48
+ "name": "Title",
49
+ "id": 10664239726872,
50
+ "product_id": 8416570474776,
51
+ "position": 1,
52
+ "values": [
53
+ "Default Title",
54
+ ]
55
+ }
56
+ ],
57
+ "images": [],
58
+ "image": null,
59
+ "variant_ids": [
60
+ {
61
+ "id": 45612961333528
62
+ }
63
+ ]
64
+ }
@@ -0,0 +1,26 @@
1
+ import constants from "../common/constants.mjs";
2
+ import common from "../common/webhook.mjs";
3
+
4
+ export default {
5
+ ...common,
6
+ key: "shopify_developer_app-new-refund-created",
7
+ name: "New Refund Created (Instant)",
8
+ description: "Emit new event when a new refund is created.",
9
+ version: "0.0.1",
10
+ type: "source",
11
+ dedupe: "unique",
12
+ methods: {
13
+ ...common.methods,
14
+ getTopic() {
15
+ return constants.EVENT_TOPIC.REFUNDS_CREATE;
16
+ },
17
+ generateMeta(resource) {
18
+ const ts = Date.parse(resource.created_at);
19
+ return {
20
+ id: `${resource.id}-${ts}`,
21
+ summary: `Refund Created ${resource.id}`,
22
+ ts,
23
+ };
24
+ },
25
+ },
26
+ };
@@ -0,0 +1,155 @@
1
+ export default {
2
+ "id": 1002961240349,
3
+ "order_id": 6273085767965,
4
+ "created_at": "2024-08-20T11:19:18-04:00",
5
+ "note": "",
6
+ "user_id": 90630848797,
7
+ "processed_at": "2024-08-20T11:19:18-04:00",
8
+ "restock": true,
9
+ "duties": [],
10
+ "total_duties_set": {
11
+ "shop_money": {
12
+ "amount": "0",
13
+ "currency_code": "VND"
14
+ },
15
+ "presentment_money": {
16
+ "amount": "0",
17
+ "currency_code": "VND"
18
+ }
19
+ },
20
+ "return": null,
21
+ "refund_shipping_lines": [],
22
+ "admin_graphql_api_id": "gid://shopify/Refund/1002961240349",
23
+ "order_adjustments": [],
24
+ "refund_line_items": [
25
+ {
26
+ "id": 665556615453,
27
+ "quantity": 1,
28
+ "line_item_id": 16014782595357,
29
+ "location_id": 76683084061,
30
+ "restock_type": "cancel",
31
+ "subtotal": 20,
32
+ "total_tax": 0,
33
+ "subtotal_set": {
34
+ "shop_money": {
35
+ "amount": "20",
36
+ "currency_code": "VND"
37
+ },
38
+ "presentment_money": {
39
+ "amount": "20",
40
+ "currency_code": "VND"
41
+ }
42
+ },
43
+ "total_tax_set": {
44
+ "shop_money": {
45
+ "amount": "0",
46
+ "currency_code": "VND"
47
+ },
48
+ "presentment_money": {
49
+ "amount": "0",
50
+ "currency_code": "VND"
51
+ }
52
+ },
53
+ "line_item": {
54
+ "id": 16014782595357,
55
+ "variant_id": 44392954495261,
56
+ "title": "T-shirt 1",
57
+ "quantity": 1,
58
+ "sku": "",
59
+ "variant_title": "Pipedream1003",
60
+ "vendor": "Pipedream0930",
61
+ "fulfillment_service": "manual",
62
+ "product_id": 8137104785693,
63
+ "requires_shipping": true,
64
+ "taxable": false,
65
+ "gift_card": false,
66
+ "name": "T-shirt 1 - Pipedream1003",
67
+ "variant_inventory_management": "shopify",
68
+ "properties": [],
69
+ "product_exists": true,
70
+ "fulfillable_quantity": 0,
71
+ "grams": 0,
72
+ "price": "20",
73
+ "total_discount": "0",
74
+ "fulfillment_status": null,
75
+ "price_set": {
76
+ "shop_money": {
77
+ "amount": "20",
78
+ "currency_code": "VND"
79
+ },
80
+ "presentment_money": {
81
+ "amount": "20",
82
+ "currency_code": "VND"
83
+ }
84
+ },
85
+ "total_discount_set": {
86
+ "shop_money": {
87
+ "amount": "0",
88
+ "currency_code": "VND"
89
+ },
90
+ "presentment_money": {
91
+ "amount": "0",
92
+ "currency_code": "VND"
93
+ }
94
+ },
95
+ "discount_allocations": [],
96
+ "duties": [],
97
+ "admin_graphql_api_id": "gid://shopify/LineItem/16014782595357",
98
+ "tax_lines": [
99
+ {
100
+ "title": "VAT",
101
+ "price": "0",
102
+ "rate": 0.1,
103
+ "channel_liable": false,
104
+ "price_set": {
105
+ "shop_money": {
106
+ "amount": "0",
107
+ "currency_code": "VND"
108
+ },
109
+ "presentment_money": {
110
+ "amount": "0",
111
+ "currency_code": "VND"
112
+ }
113
+ }
114
+ }
115
+ ]
116
+ }
117
+ }
118
+ ],
119
+ "transactions": [
120
+ {
121
+ "id": 7582534205725,
122
+ "order_id": 6273085767965,
123
+ "kind": "refund",
124
+ "gateway": "manual",
125
+ "status": "success",
126
+ "message": "Refunded 20.00 from manual gateway",
127
+ "created_at": "2024-08-20T11:19:18-04:00",
128
+ "test": false,
129
+ "authorization": null,
130
+ "location_id": null,
131
+ "user_id": 90630848797,
132
+ "parent_id": 7582533648669,
133
+ "processed_at": "2024-08-20T11:19:18-04:00",
134
+ "device_id": null,
135
+ "error_code": null,
136
+ "source_name": "1830279",
137
+ "receipt": {},
138
+ "amount": "20",
139
+ "currency": "VND",
140
+ "payment_id": "#1031.2",
141
+ "total_unsettled_set": {
142
+ "presentment_money": {
143
+ "amount": "0.0",
144
+ "currency": "VND"
145
+ },
146
+ "shop_money": {
147
+ "amount": "0.0",
148
+ "currency": "VND"
149
+ }
150
+ },
151
+ "manual_payment_gateway": true,
152
+ "admin_graphql_api_id": "gid://shopify/OrderTransaction/7582534205725"
153
+ }
154
+ ]
155
+ }
@@ -1,5 +1,5 @@
1
- import common from "../common/webhook.mjs";
2
1
  import constants from "../common/constants.mjs";
2
+ import common from "../common/webhook-metafields.mjs";
3
3
 
4
4
  export default {
5
5
  ...common,
@@ -7,7 +7,7 @@ export default {
7
7
  name: "New Shipment (Instant)",
8
8
  type: "source",
9
9
  description: "Emit new event for each new fulfillment event for a store.",
10
- version: "0.0.2",
10
+ version: "0.0.4",
11
11
  dedupe: "unique",
12
12
  methods: {
13
13
  ...common.methods,
@@ -1,5 +1,5 @@
1
- import common from "../common/webhook.mjs";
2
1
  import constants from "../common/constants.mjs";
2
+ import common from "../common/webhook-metafields.mjs";
3
3
 
4
4
  export default {
5
5
  ...common,
@@ -7,7 +7,7 @@ export default {
7
7
  name: "New Updated Customer (Instant)",
8
8
  type: "source",
9
9
  description: "Emit new event each time a customer's information is updated.",
10
- version: "0.0.2",
10
+ version: "0.0.4",
11
11
  dedupe: "unique",
12
12
  methods: {
13
13
  ...common.methods,
@@ -1,5 +1,5 @@
1
- import common from "../common/webhook.mjs";
2
1
  import constants from "../common/constants.mjs";
2
+ import common from "../common/webhook-metafields.mjs";
3
3
 
4
4
  export default {
5
5
  ...common,
@@ -7,7 +7,7 @@ export default {
7
7
  name: "New Updated Order (Instant)",
8
8
  type: "source",
9
9
  description: "Emit new event each time an order is updated.",
10
- version: "0.0.2",
10
+ version: "0.0.4",
11
11
  dedupe: "unique",
12
12
  methods: {
13
13
  ...common.methods,