@agnocon/piece-bigcommerce 0.1.11

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.
Files changed (157) hide show
  1. package/LICENSE.MIT-AP +24 -0
  2. package/dist/index.d.ts +6 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +86 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/lib/actions/create-a-product.d.ts +14 -0
  7. package/dist/lib/actions/create-a-product.d.ts.map +1 -0
  8. package/dist/lib/actions/create-a-product.js +80 -0
  9. package/dist/lib/actions/create-a-product.js.map +1 -0
  10. package/dist/lib/actions/create-blog-post.d.ts +16 -0
  11. package/dist/lib/actions/create-blog-post.d.ts.map +1 -0
  12. package/dist/lib/actions/create-blog-post.js +87 -0
  13. package/dist/lib/actions/create-blog-post.js.map +1 -0
  14. package/dist/lib/actions/create-customer-address.d.ts +25 -0
  15. package/dist/lib/actions/create-customer-address.d.ts.map +1 -0
  16. package/dist/lib/actions/create-customer-address.js +85 -0
  17. package/dist/lib/actions/create-customer-address.js.map +1 -0
  18. package/dist/lib/actions/create-customer.d.ts +13 -0
  19. package/dist/lib/actions/create-customer.d.ts.map +1 -0
  20. package/dist/lib/actions/create-customer.js +70 -0
  21. package/dist/lib/actions/create-customer.js.map +1 -0
  22. package/dist/lib/actions/delete-a-product.d.ts +8 -0
  23. package/dist/lib/actions/delete-a-product.d.ts.map +1 -0
  24. package/dist/lib/actions/delete-a-product.js +36 -0
  25. package/dist/lib/actions/delete-a-product.js.map +1 -0
  26. package/dist/lib/actions/find-or-create-customer.d.ts +13 -0
  27. package/dist/lib/actions/find-or-create-customer.d.ts.map +1 -0
  28. package/dist/lib/actions/find-or-create-customer.js +82 -0
  29. package/dist/lib/actions/find-or-create-customer.js.map +1 -0
  30. package/dist/lib/actions/find-or-create-customers-address.d.ts +25 -0
  31. package/dist/lib/actions/find-or-create-customers-address.d.ts.map +1 -0
  32. package/dist/lib/actions/find-or-create-customers-address.js +100 -0
  33. package/dist/lib/actions/find-or-create-customers-address.js.map +1 -0
  34. package/dist/lib/actions/find-or-create-product.d.ts +14 -0
  35. package/dist/lib/actions/find-or-create-product.d.ts.map +1 -0
  36. package/dist/lib/actions/find-or-create-product.js +84 -0
  37. package/dist/lib/actions/find-or-create-product.js.map +1 -0
  38. package/dist/lib/actions/get-order.d.ts +8 -0
  39. package/dist/lib/actions/get-order.d.ts.map +1 -0
  40. package/dist/lib/actions/get-order.js +36 -0
  41. package/dist/lib/actions/get-order.js.map +1 -0
  42. package/dist/lib/actions/list-categories.d.ts +8 -0
  43. package/dist/lib/actions/list-categories.d.ts.map +1 -0
  44. package/dist/lib/actions/list-categories.js +39 -0
  45. package/dist/lib/actions/list-categories.js.map +1 -0
  46. package/dist/lib/actions/list-orders.d.ts +9 -0
  47. package/dist/lib/actions/list-orders.d.ts.map +1 -0
  48. package/dist/lib/actions/list-orders.js +46 -0
  49. package/dist/lib/actions/list-orders.js.map +1 -0
  50. package/dist/lib/actions/search-customer-address.d.ts +17 -0
  51. package/dist/lib/actions/search-customer-address.d.ts.map +1 -0
  52. package/dist/lib/actions/search-customer-address.js +45 -0
  53. package/dist/lib/actions/search-customer-address.js.map +1 -0
  54. package/dist/lib/actions/search-customer.d.ts +10 -0
  55. package/dist/lib/actions/search-customer.d.ts.map +1 -0
  56. package/dist/lib/actions/search-customer.js +53 -0
  57. package/dist/lib/actions/search-customer.js.map +1 -0
  58. package/dist/lib/actions/search-product.d.ts +13 -0
  59. package/dist/lib/actions/search-product.d.ts.map +1 -0
  60. package/dist/lib/actions/search-product.js +77 -0
  61. package/dist/lib/actions/search-product.js.map +1 -0
  62. package/dist/lib/actions/update-a-product.d.ts +15 -0
  63. package/dist/lib/actions/update-a-product.d.ts.map +1 -0
  64. package/dist/lib/actions/update-a-product.js +81 -0
  65. package/dist/lib/actions/update-a-product.js.map +1 -0
  66. package/dist/lib/common/auth.d.ts +6 -0
  67. package/dist/lib/common/auth.d.ts.map +1 -0
  68. package/dist/lib/common/auth.js +50 -0
  69. package/dist/lib/common/auth.js.map +1 -0
  70. package/dist/lib/common/constants.d.ts +11 -0
  71. package/dist/lib/common/constants.d.ts.map +1 -0
  72. package/dist/lib/common/constants.js +14 -0
  73. package/dist/lib/common/constants.js.map +1 -0
  74. package/dist/lib/common/props.d.ts +23 -0
  75. package/dist/lib/common/props.d.ts.map +1 -0
  76. package/dist/lib/common/props.js +85 -0
  77. package/dist/lib/common/props.js.map +1 -0
  78. package/dist/lib/common/requests.d.ts +65 -0
  79. package/dist/lib/common/requests.d.ts.map +1 -0
  80. package/dist/lib/common/requests.js +179 -0
  81. package/dist/lib/common/requests.js.map +1 -0
  82. package/dist/lib/triggers/abandoned-cart.d.ts +19 -0
  83. package/dist/lib/triggers/abandoned-cart.d.ts.map +1 -0
  84. package/dist/lib/triggers/abandoned-cart.js +66 -0
  85. package/dist/lib/triggers/abandoned-cart.js.map +1 -0
  86. package/dist/lib/triggers/cart-created.d.ts +19 -0
  87. package/dist/lib/triggers/cart-created.d.ts.map +1 -0
  88. package/dist/lib/triggers/cart-created.js +68 -0
  89. package/dist/lib/triggers/cart-created.js.map +1 -0
  90. package/dist/lib/triggers/customer-address-created.d.ts +19 -0
  91. package/dist/lib/triggers/customer-address-created.d.ts.map +1 -0
  92. package/dist/lib/triggers/customer-address-created.js +68 -0
  93. package/dist/lib/triggers/customer-address-created.js.map +1 -0
  94. package/dist/lib/triggers/customer-address-updated.d.ts +19 -0
  95. package/dist/lib/triggers/customer-address-updated.d.ts.map +1 -0
  96. package/dist/lib/triggers/customer-address-updated.js +68 -0
  97. package/dist/lib/triggers/customer-address-updated.js.map +1 -0
  98. package/dist/lib/triggers/customer-created.d.ts +19 -0
  99. package/dist/lib/triggers/customer-created.d.ts.map +1 -0
  100. package/dist/lib/triggers/customer-created.js +70 -0
  101. package/dist/lib/triggers/customer-created.js.map +1 -0
  102. package/dist/lib/triggers/customer-updated.d.ts +19 -0
  103. package/dist/lib/triggers/customer-updated.d.ts.map +1 -0
  104. package/dist/lib/triggers/customer-updated.js +68 -0
  105. package/dist/lib/triggers/customer-updated.js.map +1 -0
  106. package/dist/lib/triggers/order-created.d.ts +19 -0
  107. package/dist/lib/triggers/order-created.d.ts.map +1 -0
  108. package/dist/lib/triggers/order-created.js +68 -0
  109. package/dist/lib/triggers/order-created.js.map +1 -0
  110. package/dist/lib/triggers/order-status-updated.d.ts +19 -0
  111. package/dist/lib/triggers/order-status-updated.d.ts.map +1 -0
  112. package/dist/lib/triggers/order-status-updated.js +68 -0
  113. package/dist/lib/triggers/order-status-updated.js.map +1 -0
  114. package/dist/lib/triggers/order-updated.d.ts +19 -0
  115. package/dist/lib/triggers/order-updated.d.ts.map +1 -0
  116. package/dist/lib/triggers/order-updated.js +68 -0
  117. package/dist/lib/triggers/order-updated.js.map +1 -0
  118. package/dist/lib/triggers/product-created.d.ts +19 -0
  119. package/dist/lib/triggers/product-created.d.ts.map +1 -0
  120. package/dist/lib/triggers/product-created.js +68 -0
  121. package/dist/lib/triggers/product-created.js.map +1 -0
  122. package/dist/lib/triggers/shipment-created.d.ts +19 -0
  123. package/dist/lib/triggers/shipment-created.d.ts.map +1 -0
  124. package/dist/lib/triggers/shipment-created.js +68 -0
  125. package/dist/lib/triggers/shipment-created.js.map +1 -0
  126. package/package.json +46 -0
  127. package/src/index.ts +81 -0
  128. package/src/lib/actions/create-a-product.ts +73 -0
  129. package/src/lib/actions/create-blog-post.ts +82 -0
  130. package/src/lib/actions/create-customer-address.ts +78 -0
  131. package/src/lib/actions/create-customer.ts +63 -0
  132. package/src/lib/actions/delete-a-product.ts +29 -0
  133. package/src/lib/actions/find-or-create-customer.ts +81 -0
  134. package/src/lib/actions/find-or-create-customers-address.ts +101 -0
  135. package/src/lib/actions/find-or-create-product.ts +81 -0
  136. package/src/lib/actions/get-order.ts +29 -0
  137. package/src/lib/actions/list-categories.ts +31 -0
  138. package/src/lib/actions/list-orders.ts +38 -0
  139. package/src/lib/actions/search-customer-address.ts +42 -0
  140. package/src/lib/actions/search-customer.ts +47 -0
  141. package/src/lib/actions/search-product.ts +69 -0
  142. package/src/lib/actions/update-a-product.ts +78 -0
  143. package/src/lib/common/auth.ts +44 -0
  144. package/src/lib/common/constants.ts +15 -0
  145. package/src/lib/common/props.ts +90 -0
  146. package/src/lib/common/requests.ts +252 -0
  147. package/src/lib/triggers/abandoned-cart.ts +58 -0
  148. package/src/lib/triggers/cart-created.ts +60 -0
  149. package/src/lib/triggers/customer-address-created.ts +60 -0
  150. package/src/lib/triggers/customer-address-updated.ts +60 -0
  151. package/src/lib/triggers/customer-created.ts +62 -0
  152. package/src/lib/triggers/customer-updated.ts +60 -0
  153. package/src/lib/triggers/order-created.ts +60 -0
  154. package/src/lib/triggers/order-status-updated.ts +60 -0
  155. package/src/lib/triggers/order-updated.ts +60 -0
  156. package/src/lib/triggers/product-created.ts +60 -0
  157. package/src/lib/triggers/shipment-created.ts +61 -0
@@ -0,0 +1,101 @@
1
+ import { createAction, Property } from '@agnocon/pieces-framework';
2
+ import { bigcommerceAuth } from '../common/auth';
3
+ import { customerDropdown } from '../common/props';
4
+ import { bigCommerceApiService } from '../common/requests';
5
+
6
+ export const findOrCreateCustomersAddress = createAction({
7
+ auth: bigcommerceAuth,
8
+ name: 'findOrCreateCustomersAddress',
9
+ displayName: 'Find or Create Customer’s Address',
10
+ description: 'Finds or creates a customer’s address',
11
+ audience: 'both',
12
+ aiMetadata: {
13
+ description:
14
+ 'For a given customer_id, looks up that customer’s addresses and returns the one matching the supplied address line 1, city, and postal code if it exists, otherwise creates a new address from the supplied details. Use instead of Create Customer Address when the address may already be on file, to avoid duplicates. Idempotent: repeated calls reuse the matching address rather than appending duplicates.',
15
+ idempotent: true,
16
+ },
17
+ props: {
18
+ customer_id: customerDropdown({
19
+ required: true,
20
+ }),
21
+ first_name: Property.ShortText({
22
+ displayName: 'First Name',
23
+ required: true,
24
+ }),
25
+ last_name: Property.ShortText({
26
+ displayName: 'Last Name',
27
+ required: true,
28
+ }),
29
+ address1: Property.ShortText({
30
+ displayName: 'Address Line 1',
31
+ required: true,
32
+ }),
33
+ address2: Property.ShortText({
34
+ displayName: 'Address Line 2',
35
+ required: false,
36
+ }),
37
+ city: Property.ShortText({
38
+ displayName: 'City',
39
+ required: true,
40
+ }),
41
+ state_or_province: Property.ShortText({
42
+ displayName: 'State/Province',
43
+ required: true,
44
+ }),
45
+ postal_code: Property.ShortText({
46
+ displayName: 'Postal Code',
47
+ required: true,
48
+ }),
49
+ country_code: Property.ShortText({
50
+ displayName: 'Country Code',
51
+ description: 'ISO 3166-1 alpha-2 country code',
52
+ required: true,
53
+ }),
54
+ phone: Property.ShortText({
55
+ displayName: 'Phone',
56
+ required: false,
57
+ }),
58
+ },
59
+ async run(context) {
60
+ const params = new URLSearchParams();
61
+ params.append('customer_id:in', context.propsValue.customer_id as string);
62
+
63
+ const response = await bigCommerceApiService.fetchCustomerAddresses({
64
+ auth: context.auth.props,
65
+ queryString: params.toString(),
66
+ });
67
+
68
+ if (response.data && response.data.length > 0) {
69
+ const existingAddress = response.data.find(
70
+ (addr: any) =>
71
+ addr.address1 === context.propsValue.address1 &&
72
+ addr.city === context.propsValue.city &&
73
+ addr.postal_code === context.propsValue.postal_code
74
+ );
75
+
76
+ if (existingAddress) {
77
+ return { found: true, data: existingAddress };
78
+ }
79
+ }
80
+
81
+ const newAddress = await bigCommerceApiService.createCustomerAddress({
82
+ auth: context.auth.props,
83
+ payload: [
84
+ {
85
+ customer_id: context.propsValue.customer_id,
86
+ first_name: context.propsValue.first_name,
87
+ last_name: context.propsValue.last_name,
88
+ address1: context.propsValue.address1,
89
+ address2: context.propsValue.address2,
90
+ city: context.propsValue.city,
91
+ state_or_province: context.propsValue.state_or_province,
92
+ postal_code: context.propsValue.postal_code,
93
+ country_code: context.propsValue.country_code,
94
+ phone: context.propsValue.phone,
95
+ },
96
+ ],
97
+ });
98
+
99
+ return { found: false, data: newAddress.data };
100
+ },
101
+ });
@@ -0,0 +1,81 @@
1
+ import { createAction, Property } from '@agnocon/pieces-framework';
2
+ import { bigcommerceAuth } from '../common/auth';
3
+ import { bigCommerceApiService } from '../common/requests';
4
+
5
+ export const findOrCreateProduct = createAction({
6
+ auth: bigcommerceAuth,
7
+ name: 'findOrCreateProduct',
8
+ displayName: 'Find or Create Product',
9
+ description: 'Finds or creates a product',
10
+ audience: 'both',
11
+ aiMetadata: {
12
+ description:
13
+ 'Looks up a catalog product by exact name and returns the match if found, otherwise creates a new product from the supplied details (type, weight, and price required). Use instead of Create a Product when the item may already exist, to avoid duplicates. Idempotent: repeated calls match the same existing product by name rather than creating duplicates.',
14
+ idempotent: true,
15
+ },
16
+ props: {
17
+ name: Property.ShortText({
18
+ displayName: 'Product Name',
19
+ required: true,
20
+ }),
21
+ sku: Property.ShortText({
22
+ displayName: 'SKU',
23
+ required: false,
24
+ }),
25
+ type: Property.StaticDropdown({
26
+ displayName: 'Product Type',
27
+ required: true,
28
+ options: {
29
+ options: [
30
+ { label: 'Physical', value: 'physical' },
31
+ { label: 'Digital', value: 'digital' },
32
+ ],
33
+ },
34
+ }),
35
+ weight: Property.Number({
36
+ displayName: 'Weight',
37
+ required: true,
38
+ }),
39
+ price: Property.Number({
40
+ displayName: 'Price',
41
+ required: true,
42
+ }),
43
+ description: Property.LongText({
44
+ displayName: 'Description',
45
+ required: false,
46
+ }),
47
+ brand_id: Property.Number({
48
+ displayName: 'Brand ID',
49
+ description: 'Brand ID',
50
+ required: false,
51
+ }),
52
+ },
53
+ async run(context) {
54
+ const params = new URLSearchParams();
55
+ params.append('name', context.propsValue.name);
56
+
57
+ const response = await bigCommerceApiService.fetchProducts({
58
+ auth: context.auth.props,
59
+ queryString: params.toString(),
60
+ });
61
+
62
+ if (response.data && response.data.length > 0) {
63
+ return { found: true, data: response.data };
64
+ }
65
+
66
+ const newProduct = await bigCommerceApiService.createProduct({
67
+ auth: context.auth.props,
68
+ payload: {
69
+ name: context.propsValue.name,
70
+ type: context.propsValue.type,
71
+ sku: context.propsValue.sku,
72
+ description: context.propsValue.description,
73
+ weight: context.propsValue.weight,
74
+ price: context.propsValue.price,
75
+ brand_id: context.propsValue.brand_id,
76
+ },
77
+ });
78
+
79
+ return { found: false, data: newProduct.data };
80
+ },
81
+ });
@@ -0,0 +1,29 @@
1
+ import { createAction, Property } from '@agnocon/pieces-framework';
2
+ import { bigcommerceAuth } from '../common/auth';
3
+ import { bigCommerceApiService } from '../common/requests';
4
+
5
+ export const getOrder = createAction({
6
+ auth: bigcommerceAuth,
7
+ name: 'getOrder',
8
+ displayName: 'Get Order',
9
+ description: 'Gets details of an order',
10
+ audience: 'both',
11
+ aiMetadata: {
12
+ description:
13
+ 'Retrieves the full details of a single BigCommerce order by its orderId. Use when you already have an order id (e.g. from an order trigger or List Orders) and need its data. Idempotent read-only lookup with no side effects.',
14
+ idempotent: true,
15
+ },
16
+ props: {
17
+ orderId: Property.ShortText({
18
+ displayName: 'Order ID',
19
+ description: 'The ID of the order to retrieve',
20
+ required: true,
21
+ }),
22
+ },
23
+ async run(context) {
24
+ return await bigCommerceApiService.fetchOrder({
25
+ auth: context.auth.props,
26
+ orderId: context.propsValue.orderId,
27
+ });
28
+ },
29
+ });
@@ -0,0 +1,31 @@
1
+ import { createAction, Property } from '@agnocon/pieces-framework';
2
+ import { bigcommerceAuth } from '../common/auth';
3
+ import { bigCommerceApiService } from '../common/requests';
4
+
5
+ export const listCategories = createAction({
6
+ auth: bigcommerceAuth,
7
+ name: 'listCategories',
8
+ displayName: 'List Categories',
9
+ description: 'Lists all categories',
10
+ audience: 'both',
11
+ aiMetadata: {
12
+ description:
13
+ 'Lists product categories from a BigCommerce store. With no name filter it returns all categories; provide a name to filter to matching categories. Use to discover category names or ids before assigning products. Idempotent read-only query with no side effects.',
14
+ idempotent: true,
15
+ },
16
+ props: {
17
+ name: Property.ShortText({
18
+ displayName: 'Category Name',
19
+ description: 'Filter by category name',
20
+ required: false,
21
+ }),
22
+ },
23
+ async run(context) {
24
+ const qParams = new URLSearchParams();
25
+ if (context.propsValue.name) qParams.append('name', context.propsValue.name);
26
+ return await bigCommerceApiService.fetchCategories({
27
+ auth: context.auth.props,
28
+ queryString: qParams.toString(),
29
+ });
30
+ },
31
+ });
@@ -0,0 +1,38 @@
1
+ import { createAction, Property } from '@agnocon/pieces-framework';
2
+ import { bigcommerceAuth } from '../common/auth';
3
+ import { bigCommerceApiService } from '../common/requests';
4
+
5
+ export const listOrders = createAction({
6
+ auth: bigcommerceAuth,
7
+ name: 'listOrders',
8
+ displayName: 'List Orders',
9
+ description: 'Lists all orders',
10
+ audience: 'both',
11
+ aiMetadata: {
12
+ description:
13
+ 'Lists orders from a BigCommerce store. With no filters it returns all orders; optionally narrow by customer_id and/or status_id to a subset. Use to browse or find orders when you do not have a specific order id. Idempotent read-only query with no side effects.',
14
+ idempotent: true,
15
+ },
16
+ props: {
17
+ customer_id: Property.Number({
18
+ displayName: 'Customer ID',
19
+ description: 'Filter by customer ID',
20
+ required: false,
21
+ }),
22
+ status_id: Property.Number({
23
+ displayName: 'Status ID',
24
+ description: 'Filter by status ID',
25
+ required: false,
26
+ }),
27
+ },
28
+ async run(context) {
29
+ const qParams = new URLSearchParams();
30
+ if (context.propsValue.customer_id !== undefined && context.propsValue.customer_id !== null) qParams.append('customer_id', context.propsValue.customer_id.toString());
31
+ if (context.propsValue.status_id !== undefined && context.propsValue.status_id !== null) qParams.append('status_id', context.propsValue.status_id.toString());
32
+
33
+ return await bigCommerceApiService.fetchOrders({
34
+ auth: context.auth.props,
35
+ queryString: qParams.toString(),
36
+ });
37
+ },
38
+ });
@@ -0,0 +1,42 @@
1
+ import { createAction, Property } from '@agnocon/pieces-framework';
2
+ import { bigCommerceApiService } from '../common/requests';
3
+ import { bigcommerceAuth } from '../common/auth';
4
+ import { multiCustomerDropdown } from '../common/props';
5
+
6
+ export const searchCustomerAddress = createAction({
7
+ auth: bigcommerceAuth,
8
+ name: 'searchCustomerAddress',
9
+ displayName: 'Search Customer Address',
10
+ description: 'Searches for a customer’s address',
11
+ audience: 'both',
12
+ aiMetadata: {
13
+ description:
14
+ 'Searches customer addresses in a BigCommerce store, optionally filtered by one or more customer ids and/or a name. With no filters it returns all addresses; supplying filters narrows to matches. Use to look up addresses belonging to specific customers. Idempotent read-only query with no side effects.',
15
+ idempotent: true,
16
+ },
17
+ props: {
18
+ customer_ids: multiCustomerDropdown({
19
+ required: false,
20
+ }),
21
+ name: Property.ShortText({
22
+ displayName: 'Name',
23
+ description: 'Customer name to search for',
24
+ required: false,
25
+ }),
26
+ },
27
+ async run(context) {
28
+ const params = new URLSearchParams();
29
+ if (context.propsValue.customer_ids)
30
+ params.append(
31
+ 'customer_ids:in',
32
+ (context.propsValue.customer_ids as string[]).join(',')
33
+ );
34
+ if (context.propsValue.name)
35
+ params.append('name:in', `${context.propsValue.name}`);
36
+
37
+ return await bigCommerceApiService.fetchCustomerAddresses({
38
+ auth: context.auth.props,
39
+ queryString: params.toString(),
40
+ });
41
+ },
42
+ });
@@ -0,0 +1,47 @@
1
+ import { createAction, Property } from '@agnocon/pieces-framework';
2
+ import { bigcommerceAuth } from '../common/auth';
3
+ import { bigCommerceApiService } from '../common/requests';
4
+
5
+ export const searchCustomer = createAction({
6
+ auth: bigcommerceAuth,
7
+ name: 'searchCustomer',
8
+ displayName: 'Search Customer',
9
+ description: 'Searches for a registered customer',
10
+ audience: 'both',
11
+ aiMetadata: {
12
+ description:
13
+ 'Searches registered customers in a BigCommerce store by email, phone, and/or name. With no filters it returns all customers; supplying any filter narrows to matches. Use to look up a customer or check whether one exists before creating it. Idempotent read-only query with no side effects.',
14
+ idempotent: true,
15
+ },
16
+ props: {
17
+ email: Property.ShortText({
18
+ displayName: 'Email',
19
+ description: 'Customer email to search for',
20
+ required: false,
21
+ }),
22
+ phone: Property.ShortText({
23
+ displayName: 'Phone Number',
24
+ description: 'Phone Number to search for',
25
+ required: false,
26
+ }),
27
+ name: Property.ShortText({
28
+ displayName: 'Name',
29
+ description: 'Customer name to search for',
30
+ required: false,
31
+ }),
32
+ },
33
+ async run(context) {
34
+ const params = new URLSearchParams();
35
+ if (context.propsValue.email)
36
+ params.append('email:in', context.propsValue.email);
37
+ if (context.propsValue.name)
38
+ params.append('name:in', `${context.propsValue.name}`);
39
+ if (context.propsValue.phone)
40
+ params.append('phone:in', context.propsValue.phone);
41
+
42
+ return await bigCommerceApiService.fetchCustomers({
43
+ auth: context.auth.props,
44
+ queryString: params.toString(),
45
+ });
46
+ },
47
+ });
@@ -0,0 +1,69 @@
1
+ import { createAction, Property } from '@agnocon/pieces-framework';
2
+ import { bigcommerceAuth } from '../common/auth';
3
+ import { bigCommerceApiService } from '../common/requests';
4
+
5
+ export const searchProduct = createAction({
6
+ auth: bigcommerceAuth,
7
+ name: 'searchProduct',
8
+ displayName: 'Search Product',
9
+ description: 'Searches for a product in the catalog',
10
+ audience: 'both',
11
+ aiMetadata: {
12
+ description:
13
+ 'Searches the BigCommerce product catalog by name, SKU, type, brand, weight, and/or price. With no filters it returns all products; supplying any filter narrows to matches. Use to find a product or its id, or to check whether one exists before creating it. Idempotent read-only query with no side effects.',
14
+ idempotent: true,
15
+ },
16
+ props: {
17
+ name: Property.ShortText({
18
+ displayName: 'Product Name',
19
+ description: 'Product name to search for',
20
+ required: false,
21
+ }),
22
+ sku: Property.ShortText({
23
+ displayName: 'SKU',
24
+ description: 'Product SKU to search for',
25
+ required: false,
26
+ }),
27
+ type: Property.StaticDropdown({
28
+ displayName: 'Product Type',
29
+ required: false,
30
+ options: {
31
+ options: [
32
+ { label: 'Physical', value: 'physical' },
33
+ { label: 'Digital', value: 'digital' },
34
+ ],
35
+ },
36
+ }),
37
+ brand_id: Property.ShortText({
38
+ displayName: 'Brand ID',
39
+ description: 'Brand ID to search for',
40
+ required: false,
41
+ }),
42
+ weight: Property.Number({
43
+ displayName: 'Weight',
44
+ required: false,
45
+ }),
46
+ price: Property.Number({
47
+ displayName: 'Price',
48
+ required: false,
49
+ }),
50
+ },
51
+ async run(context) {
52
+ const params = new URLSearchParams();
53
+ if (context.propsValue.name) params.append('name', context.propsValue.name);
54
+ if (context.propsValue.sku) params.append('sku', context.propsValue.sku);
55
+ if (context.propsValue.brand_id)
56
+ params.append('brand_id', context.propsValue.brand_id);
57
+ if (context.propsValue.type)
58
+ params.append('type', context.propsValue.type);
59
+ if (context.propsValue.price)
60
+ params.append('price', String(context.propsValue.price));
61
+ if (context.propsValue.weight)
62
+ params.append('weight', String(context.propsValue.weight));
63
+
64
+ return await bigCommerceApiService.fetchProducts({
65
+ auth: context.auth.props,
66
+ queryString: params.toString(),
67
+ });
68
+ },
69
+ });
@@ -0,0 +1,78 @@
1
+ import { createAction, Property } from '@agnocon/pieces-framework';
2
+ import { bigcommerceAuth } from '../common/auth';
3
+ import { bigCommerceApiService } from '../common/requests';
4
+
5
+ export const updateAProduct = createAction({
6
+ auth: bigcommerceAuth,
7
+ name: 'updateAProduct',
8
+ displayName: 'Update a Product',
9
+ description: 'Updates an existing Product',
10
+ audience: 'both',
11
+ aiMetadata: {
12
+ description:
13
+ 'Updates an existing catalog product in a BigCommerce store, identified by its productId. Only the fields you supply are sent (null/undefined values are dropped so existing data is preserved), so use it for partial edits to name, type, SKU, description, weight, price, or brand. Idempotent: re-applying the same field values leaves the product in the same state.',
14
+ idempotent: true,
15
+ },
16
+ props: {
17
+ productId: Property.ShortText({
18
+ displayName: 'Product ID',
19
+ description: 'The ID of the product to update',
20
+ required: true,
21
+ }),
22
+ name: Property.ShortText({
23
+ displayName: 'Product Name',
24
+ description: 'Name of the product',
25
+ required: false,
26
+ }),
27
+ type: Property.StaticDropdown({
28
+ displayName: 'Product Type',
29
+ description: 'Type of product',
30
+ required: false,
31
+ options: {
32
+ options: [
33
+ { label: 'Physical', value: 'physical' },
34
+ { label: 'Digital', value: 'digital' },
35
+ ],
36
+ },
37
+ }),
38
+ sku: Property.ShortText({
39
+ displayName: 'SKU',
40
+ description: 'Product SKU',
41
+ required: false,
42
+ }),
43
+ description: Property.LongText({
44
+ displayName: 'Description',
45
+ description: 'Product description',
46
+ required: false,
47
+ }),
48
+ weight: Property.Number({
49
+ displayName: 'Weight',
50
+ description: 'Product weight',
51
+ required: false,
52
+ }),
53
+ price: Property.Number({
54
+ displayName: 'Price',
55
+ description: 'Product price',
56
+ required: false,
57
+ }),
58
+ brand_id: Property.Number({
59
+ displayName: 'Brand ID',
60
+ description: 'Brand ID',
61
+ required: false,
62
+ }),
63
+ },
64
+ async run(context) {
65
+ const { productId, ...payload } = context.propsValue;
66
+
67
+ // Filter out null/undefined values to prevent overwriting existing data with nulls
68
+ const filteredPayload = Object.fromEntries(
69
+ Object.entries(payload).filter(([_, v]) => v !== null && v !== undefined)
70
+ );
71
+
72
+ return await bigCommerceApiService.updateProduct({
73
+ auth: context.auth.props,
74
+ productId,
75
+ payload: filteredPayload,
76
+ });
77
+ },
78
+ });
@@ -0,0 +1,44 @@
1
+ import { PieceAuth, Property } from '@agnocon/pieces-framework';
2
+ import { bigCommerceApiService } from './requests';
3
+
4
+ export const bigcommerceAuth = PieceAuth.CustomAuth({
5
+ description:
6
+ 'Enter your BigCommerce API credentials. ',
7
+
8
+ props: {
9
+ instruction: Property.MarkDown({
10
+ value: `1. Login to https://www.bigcommerce.com/essentials/
11
+ 2. Go to Settings
12
+ 3. Scroll down to API
13
+ 4. Click on "Store Level API Accounts"
14
+ 5. Click "Create API Account" button
15
+ 6. Enter a name and add required scopes
16
+ 7. Save - you will get a downloaded file containing your access token and store hash`,
17
+ }),
18
+ storeHash: Property.ShortText({
19
+ displayName: 'Store Hash',
20
+ description: 'Your BigCommerce store hash (e.g., abcd1234)',
21
+ required: true,
22
+ }),
23
+ accessToken: Property.ShortText({
24
+ displayName: 'Access Token',
25
+ description: 'Your BigCommerce API access token',
26
+ required: true,
27
+ }),
28
+ },
29
+ required: true,
30
+ async validate(context) {
31
+ try {
32
+ await bigCommerceApiService.fetchProducts({
33
+ auth: context.auth,
34
+ });
35
+ return { valid: true };
36
+ } catch {
37
+ return {
38
+ valid: false,
39
+ error:
40
+ 'Could not validate credentials. please check your credentials are correct.',
41
+ };
42
+ }
43
+ },
44
+ });
@@ -0,0 +1,15 @@
1
+ export type bigCommerceAuth = {
2
+ storeHash: string;
3
+ accessToken: string;
4
+ }
5
+
6
+ export const GET_BASE_URL = (storeHash: string) =>
7
+ `https://api.bigcommerce.com/stores/${storeHash}`;
8
+
9
+ export function handleDropdownError(msg: string) {
10
+ return {
11
+ disabled: true,
12
+ options: [],
13
+ placeholder: msg,
14
+ };
15
+ }
@@ -0,0 +1,90 @@
1
+ import { Property } from '@agnocon/pieces-framework';
2
+ import { handleDropdownError } from './constants';
3
+ import { bigCommerceApiService } from './requests';
4
+ import { bigcommerceAuth } from './auth';
5
+
6
+ export const customerDropdown = ({ required }: { required: boolean }) =>
7
+ Property.Dropdown({
8
+ auth: bigcommerceAuth,
9
+ displayName: 'Customer',
10
+ description: 'Select the customer',
11
+ required,
12
+ refreshers: ['auth'],
13
+ options: async ({ auth }) => {
14
+ if (!auth)
15
+ return handleDropdownError('Please connect your account first');
16
+
17
+ try {
18
+ const response = await bigCommerceApiService.fetchCustomers({ auth: auth.props });
19
+
20
+ const data = Array.isArray(response?.data) ? response.data : [];
21
+ if (data.length === 0) {
22
+ return handleDropdownError('No customers found');
23
+ }
24
+
25
+ const options = data.map((user: any) => {
26
+ const fullName =
27
+ [user.first_name, user.last_name]
28
+ .filter((p: any) => typeof p === 'string' && p.trim() !== '')
29
+ .join(' ') ||
30
+ user.email ||
31
+ user.id;
32
+
33
+ return {
34
+ label: fullName,
35
+ value: user.id,
36
+ };
37
+ });
38
+
39
+ return {
40
+ disabled: false,
41
+ options,
42
+ };
43
+ } catch (error) {
44
+ return handleDropdownError('Failed to load customers');
45
+ }
46
+ },
47
+ });
48
+
49
+ export const multiCustomerDropdown = ({ required }: { required: boolean }) =>
50
+ Property.MultiSelectDropdown({
51
+ auth: bigcommerceAuth,
52
+ displayName: 'Customers',
53
+ description: 'Select the customers',
54
+ required,
55
+ refreshers: ['auth'],
56
+ options: async ({ auth }) => {
57
+ if (!auth)
58
+ return handleDropdownError('Please connect your account first');
59
+
60
+ try {
61
+ const response = await bigCommerceApiService.fetchCustomers({ auth: auth.props });
62
+
63
+ const data = Array.isArray(response?.data) ? response.data : [];
64
+ if (data.length === 0) {
65
+ return handleDropdownError('No customers found');
66
+ }
67
+
68
+ const options = data.map((user: any) => {
69
+ const fullName =
70
+ [user.first_name, user.last_name]
71
+ .filter((p: any) => typeof p === 'string' && p.trim() !== '')
72
+ .join(' ') ||
73
+ user.email ||
74
+ user.id;
75
+
76
+ return {
77
+ label: fullName,
78
+ value: user.id,
79
+ };
80
+ });
81
+
82
+ return {
83
+ disabled: false,
84
+ options,
85
+ };
86
+ } catch (error) {
87
+ return handleDropdownError('Failed to load customers');
88
+ }
89
+ },
90
+ });