@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,252 @@
1
+ import { HttpMethod, httpClient } from '@agnocon/pieces-common';
2
+ import { bigCommerceAuth, GET_BASE_URL } from './constants';
3
+
4
+ async function fireHttpRequest({
5
+ method,
6
+ path,
7
+ body,
8
+ auth,
9
+ filter = false,
10
+ }: {
11
+ method: HttpMethod;
12
+ path: string;
13
+ auth: bigCommerceAuth;
14
+ body?: unknown;
15
+ filter?: boolean;
16
+ }) {
17
+ const BASE_URL = GET_BASE_URL(auth.storeHash);
18
+
19
+ const cleanBody = filter && body ? (Array.isArray(body)
20
+ ? body.map(item => filterNulls(item))
21
+ : filterNulls(body)) : body;
22
+
23
+
24
+ return await httpClient
25
+ .sendRequest({
26
+ method,
27
+ url: `${BASE_URL}${path}`,
28
+ headers: {
29
+ 'X-Auth-Token': auth.accessToken,
30
+ 'Content-Type': 'application/json',
31
+ Accept: 'application/json',
32
+ },
33
+ body: cleanBody,
34
+ })
35
+ .then((res) => res.body)
36
+ .catch((err) => {
37
+ throw new Error(
38
+ `Error in request to ${path}: ${err.message || JSON.stringify(err)}`
39
+ );
40
+ });
41
+ }
42
+
43
+ export const bigCommerceApiService = {
44
+ async createWebhook({
45
+ auth,
46
+ payload,
47
+ }: {
48
+ auth: bigCommerceAuth;
49
+ payload: {
50
+ scope: string;
51
+ destination: string;
52
+ is_active: boolean;
53
+ };
54
+ }) {
55
+ return await fireHttpRequest({
56
+ auth,
57
+ path: '/v3/hooks',
58
+ method: HttpMethod.POST,
59
+ body: payload,
60
+ });
61
+ },
62
+ async createCustomer({
63
+ auth,
64
+ payload,
65
+ }: {
66
+ auth: bigCommerceAuth;
67
+ payload: unknown;
68
+ }) {
69
+ return await fireHttpRequest({
70
+ auth,
71
+ path: '/v3/customers',
72
+ method: HttpMethod.POST,
73
+ body: payload,
74
+ });
75
+ },
76
+ async fetchCustomers({
77
+ auth,
78
+ queryString,
79
+ }: {
80
+ auth: bigCommerceAuth;
81
+ queryString?: string;
82
+ }) {
83
+ return await fireHttpRequest({
84
+ auth,
85
+ path: `/v3/customers${queryString ? `?${queryString}` : ''}`,
86
+ method: HttpMethod.GET,
87
+ });
88
+ },
89
+ async fetchCustomerAddresses({
90
+ auth,
91
+ queryString,
92
+ }: {
93
+ auth: bigCommerceAuth;
94
+ queryString?: string;
95
+ }) {
96
+ return await fireHttpRequest({
97
+ auth,
98
+ path: `/v3/customers/addresses${queryString ? `?${queryString}` : ''}`,
99
+ method: HttpMethod.GET,
100
+ });
101
+ },
102
+ async fetchProducts({
103
+ auth,
104
+ queryString,
105
+ }: {
106
+ auth: bigCommerceAuth;
107
+ queryString?: string;
108
+ }) {
109
+ return await fireHttpRequest({
110
+ auth,
111
+ path: `/v3/catalog/products${queryString ? `?${queryString}` : ''}`,
112
+ method: HttpMethod.GET,
113
+ });
114
+ },
115
+ async createProduct({
116
+ auth,
117
+ payload,
118
+ }: {
119
+ auth: bigCommerceAuth;
120
+ payload: unknown;
121
+ }) {
122
+ return await fireHttpRequest({
123
+ auth,
124
+ path: '/v3/catalog/products',
125
+ method: HttpMethod.POST,
126
+ body: payload,
127
+ filter: true,
128
+ });
129
+ },
130
+ async updateProduct({
131
+ auth,
132
+ productId,
133
+ payload,
134
+ }: {
135
+ auth: bigCommerceAuth;
136
+ productId: string | number;
137
+ payload: unknown;
138
+ }) {
139
+ return await fireHttpRequest({
140
+ auth,
141
+ path: `/v3/catalog/products/${productId}`,
142
+ method: HttpMethod.PUT,
143
+ body: payload,
144
+ filter: true,
145
+ });
146
+ },
147
+ async deleteProduct({
148
+ auth,
149
+ productId,
150
+ }: {
151
+ auth: bigCommerceAuth;
152
+ productId: string | number;
153
+ }) {
154
+ return await fireHttpRequest({
155
+ auth,
156
+ path: `/v3/catalog/products/${productId}`,
157
+ method: HttpMethod.DELETE,
158
+ });
159
+ },
160
+ async fetchOrders({
161
+ auth,
162
+ queryString,
163
+ }: {
164
+ auth: bigCommerceAuth;
165
+ queryString?: string;
166
+ }) {
167
+ return await fireHttpRequest({
168
+ auth,
169
+ path: `/v2/orders${queryString ? `?${queryString}` : ''}`,
170
+ method: HttpMethod.GET,
171
+ });
172
+ },
173
+ async fetchOrder({
174
+ auth,
175
+ orderId,
176
+ }: {
177
+ auth: bigCommerceAuth;
178
+ orderId: string | number;
179
+ }) {
180
+ return await fireHttpRequest({
181
+ auth,
182
+ path: `/v2/orders/${orderId}`,
183
+ method: HttpMethod.GET,
184
+ });
185
+ },
186
+ async fetchCategories({
187
+ auth,
188
+ queryString,
189
+ }: {
190
+ auth: bigCommerceAuth;
191
+ queryString?: string;
192
+ }) {
193
+ return await fireHttpRequest({
194
+ auth,
195
+ path: `/v3/catalog/categories${queryString ? `?${queryString}` : ''}`,
196
+ method: HttpMethod.GET,
197
+ });
198
+ },
199
+ async createBlogPost({
200
+ auth,
201
+ payload,
202
+ }: {
203
+ auth: bigCommerceAuth;
204
+ payload: unknown;
205
+ }) {
206
+ return await fireHttpRequest({
207
+ auth,
208
+ path: '/v2/blog/posts',
209
+ method: HttpMethod.POST,
210
+ body: payload,
211
+ });
212
+ },
213
+ async createCustomerAddress({
214
+ auth,
215
+ payload,
216
+ }: {
217
+ auth: bigCommerceAuth;
218
+ payload: unknown;
219
+ }) {
220
+ return await fireHttpRequest({
221
+ auth,
222
+ path: '/v3/customers/addresses',
223
+ method: HttpMethod.POST,
224
+ body: payload,
225
+ });
226
+ },
227
+ async deleteWebhook({
228
+ auth,
229
+ webhookId,
230
+ }: {
231
+ auth: bigCommerceAuth;
232
+ webhookId: string;
233
+ }) {
234
+ return await fireHttpRequest({
235
+ auth,
236
+ path: `/v3/hooks/${webhookId}`,
237
+ method: HttpMethod.DELETE,
238
+ });
239
+ },
240
+ };
241
+
242
+ function filterNulls(obj: unknown): unknown {
243
+ if (obj === null || obj === undefined) return undefined;
244
+ if (typeof obj !== 'object') return obj;
245
+ if (Array.isArray(obj)) return obj.map(filterNulls);
246
+
247
+ return Object.fromEntries(
248
+ Object.entries(obj as Record<string, unknown>)
249
+ .filter(([_, v]) => v !== null && v !== undefined)
250
+ .map(([k, v]) => [k, filterNulls(v)])
251
+ );
252
+ }
@@ -0,0 +1,58 @@
1
+ import { createTrigger, TriggerStrategy } from '@agnocon/pieces-framework';
2
+ import { bigcommerceAuth } from '../common/auth';
3
+ import { bigCommerceApiService } from '../common/requests';
4
+
5
+ const TRIGGER_NAME = 'abandoned cart';
6
+ const CACHE_KEY = `${TRIGGER_NAME}-trigger-store-key`;
7
+ const TRIGGER_SCOPE = 'store/cart/abandoned';
8
+
9
+ export const abandonedCart = createTrigger({
10
+ auth: bigcommerceAuth,
11
+ name: 'abandonedCart',
12
+ displayName: 'Abandoned Cart',
13
+ description: 'Triggers when a cart is abandoned',
14
+ aiMetadata: {
15
+ description:
16
+ 'Fires when a shopper abandons a cart in the BigCommerce store (the cart sits inactive without checkout completing). The event identifies the affected cart; use it to drive abandoned-cart recovery flows.',
17
+ },
18
+ props: {},
19
+ sampleData:{
20
+ producer: 'stores/dxqdddcaklwsso',
21
+ hash: '3610addd127e330084ddddd7ddd09b78abfd1a85',
22
+ created_at: 1761809622,
23
+ store_id: '1003425529',
24
+ scope: 'store/cart/abandoned',
25
+ data: {
26
+ type: 'cart',
27
+ id: 'ss-598f-4c95-813b-0ess950562770d',
28
+ },
29
+ },
30
+ type: TriggerStrategy.WEBHOOK,
31
+ async onEnable(context) {
32
+ const webhook = await bigCommerceApiService.createWebhook({
33
+ auth: context.auth.props,
34
+ payload: {
35
+ scope: TRIGGER_SCOPE,
36
+ destination: context.webhookUrl,
37
+ is_active: true,
38
+ },
39
+ });
40
+
41
+ await context.store.put(CACHE_KEY, webhook.data.id);
42
+ },
43
+ async onDisable(context) {
44
+ const webhookId = await context.store.get(CACHE_KEY) as string;
45
+
46
+ if (webhookId) {
47
+ await bigCommerceApiService.deleteWebhook({
48
+ auth: context.auth.props,
49
+ webhookId,
50
+ }).then(async () => {
51
+ await context.store.delete(CACHE_KEY)
52
+ })
53
+ }
54
+ },
55
+ async run(context) {
56
+ return [context.payload.body];
57
+ },
58
+ });
@@ -0,0 +1,60 @@
1
+ import { createTrigger, TriggerStrategy } from '@agnocon/pieces-framework';
2
+ import { bigcommerceAuth } from '../common/auth';
3
+ import { bigCommerceApiService } from '../common/requests';
4
+
5
+ const TRIGGER_NAME = 'cart created';
6
+ const CACHE_KEY = `${TRIGGER_NAME}-trigger-store-key`;
7
+ const TRIGGER_SCOPE = 'store/cart/created';
8
+
9
+ export const cartCreated = createTrigger({
10
+ auth: bigcommerceAuth,
11
+ name: 'cartCreated',
12
+ displayName: 'Cart Created',
13
+ description: 'Triggers when a new cart is created',
14
+ aiMetadata: {
15
+ description:
16
+ 'Fires when a new shopping cart is created in the BigCommerce store (a shopper adds the first item to a fresh cart). The event identifies the new cart.',
17
+ },
18
+ props: {},
19
+ sampleData: {
20
+ producer: 'stores/dxqdddcaklwsso',
21
+ hash: '3610addd127e330084ddddd7ddd09b78abfd1a85',
22
+ created_at: 1761809622,
23
+ store_id: '1003425529',
24
+ scope: 'store/cart/created',
25
+ data: {
26
+ type: 'cart',
27
+ id: 'ss-598f-4c95-813b-0ess950562770d',
28
+ },
29
+ },
30
+ type: TriggerStrategy.WEBHOOK,
31
+ async onEnable(context) {
32
+ const webhook = await bigCommerceApiService.createWebhook({
33
+ auth: context.auth.props,
34
+ payload: {
35
+ scope: TRIGGER_SCOPE ,
36
+ destination: context.webhookUrl,
37
+ is_active: true,
38
+ },
39
+ });
40
+
41
+ await context.store.put(CACHE_KEY, webhook.data.id);
42
+ },
43
+ async onDisable(context) {
44
+ const webhookId = (await context.store.get(CACHE_KEY)) as string;
45
+
46
+ if (webhookId) {
47
+ await bigCommerceApiService
48
+ .deleteWebhook({
49
+ auth: context.auth.props,
50
+ webhookId,
51
+ })
52
+ .then(async () => {
53
+ await context.store.delete(CACHE_KEY);
54
+ });
55
+ }
56
+ },
57
+ async run(context) {
58
+ return [context.payload.body];
59
+ },
60
+ });
@@ -0,0 +1,60 @@
1
+ import { createTrigger, TriggerStrategy } from '@agnocon/pieces-framework';
2
+ import { bigcommerceAuth } from '../common/auth';
3
+ import { bigCommerceApiService } from '../common/requests';
4
+
5
+ const TRIGGER_NAME = 'customer address created';
6
+ const CACHE_KEY = `${TRIGGER_NAME}-trigger-store-key`;
7
+ const TRIGGER_SCOPE = 'store/customer/address/created';
8
+
9
+ export const customerAddressCreated = createTrigger({
10
+ auth: bigcommerceAuth,
11
+ name: 'customerAddressCreated',
12
+ displayName: 'Customer Address Created',
13
+ description: 'Triggers when a new customer address is created',
14
+ aiMetadata: {
15
+ description:
16
+ 'Fires when a new address is added to a customer in the BigCommerce store. The event identifies the affected customer.',
17
+ },
18
+ props: {},
19
+ sampleData: {
20
+ producer: 'stores/xqcaklwsso',
21
+ hash: 'd7b899890f5e0e98a3e074f018b14b07d5d89360',
22
+ created_at: 1761808595,
23
+ store_id: '1003425529',
24
+ scope: 'store/customer/address/created',
25
+ data: {
26
+ type: 'customer',
27
+ id: 2,
28
+ },
29
+ },
30
+ type: TriggerStrategy.WEBHOOK,
31
+ async onEnable(context) {
32
+ const webhook = await bigCommerceApiService.createWebhook({
33
+ auth: context.auth.props,
34
+ payload: {
35
+ scope: TRIGGER_SCOPE,
36
+ destination: context.webhookUrl,
37
+ is_active: true,
38
+ },
39
+ });
40
+
41
+ await context.store.put(CACHE_KEY, webhook.data.id);
42
+ },
43
+ async onDisable(context) {
44
+ const webhookId = (await context.store.get(CACHE_KEY)) as string;
45
+
46
+ if (webhookId) {
47
+ await bigCommerceApiService
48
+ .deleteWebhook({
49
+ auth: context.auth.props,
50
+ webhookId,
51
+ })
52
+ .then(async () => {
53
+ await context.store.delete(CACHE_KEY);
54
+ });
55
+ }
56
+ },
57
+ async run(context) {
58
+ return [context.payload.body];
59
+ },
60
+ });
@@ -0,0 +1,60 @@
1
+ import { createTrigger, TriggerStrategy } from '@agnocon/pieces-framework';
2
+ import { bigcommerceAuth } from '../common/auth';
3
+ import { bigCommerceApiService } from '../common/requests';
4
+
5
+ const TRIGGER_NAME = 'customer address updated';
6
+ const CACHE_KEY = `${TRIGGER_NAME}-trigger-store-key`;
7
+ const TRIGGER_SCOPE = 'store/customer/address/updated';
8
+
9
+ export const customerAddressUpdated = createTrigger({
10
+ auth: bigcommerceAuth,
11
+ name: 'customerAddressUpdated',
12
+ displayName: 'Customer Address Updated',
13
+ description: 'Triggers when a new customer address is updated',
14
+ aiMetadata: {
15
+ description:
16
+ 'Fires when an existing customer address is updated in the BigCommerce store. The event identifies the affected customer.',
17
+ },
18
+ props: {},
19
+ sampleData:{
20
+ producer: 'stores/xqcaklwsso',
21
+ hash: 'd7b899890f5e0e98a3e074f018b14b07d5d89360',
22
+ created_at: 1761808595,
23
+ store_id: '1003425529',
24
+ scope: 'store/customer/address/updated',
25
+ data: {
26
+ type: 'customer',
27
+ id: 2,
28
+ },
29
+ },
30
+ type: TriggerStrategy.WEBHOOK,
31
+ async onEnable(context) {
32
+ const webhook = await bigCommerceApiService.createWebhook({
33
+ auth: context.auth.props,
34
+ payload: {
35
+ scope: TRIGGER_SCOPE,
36
+ destination: context.webhookUrl,
37
+ is_active: true,
38
+ },
39
+ });
40
+
41
+ await context.store.put(CACHE_KEY, webhook.data.id);
42
+ },
43
+ async onDisable(context) {
44
+ const webhookId = (await context.store.get(CACHE_KEY)) as string;
45
+
46
+ if (webhookId) {
47
+ await bigCommerceApiService
48
+ .deleteWebhook({
49
+ auth: context.auth.props,
50
+ webhookId,
51
+ })
52
+ .then(async () => {
53
+ await context.store.delete(CACHE_KEY);
54
+ });
55
+ }
56
+ },
57
+ async run(context) {
58
+ return [context.payload.body];
59
+ },
60
+ });
@@ -0,0 +1,62 @@
1
+ import { createTrigger, TriggerStrategy } from '@agnocon/pieces-framework';
2
+ import { bigcommerceAuth } from '../common/auth';
3
+ import { bigCommerceApiService } from '../common/requests';
4
+
5
+ const TRIGGER_NAME = 'customer created';
6
+ const CACHE_KEY = `${TRIGGER_NAME}-trigger-store-key`;
7
+ const TRIGGER_SCOPE = 'store/customer/created';
8
+
9
+ export const customerCreated = createTrigger({
10
+ auth: bigcommerceAuth,
11
+ name: 'customerCreated',
12
+ displayName: 'Customer Created',
13
+ description: 'Triggers when a new customer is created',
14
+ aiMetadata: {
15
+ description:
16
+ 'Fires when a new customer is created in the BigCommerce store. The event identifies the new customer.',
17
+ },
18
+ props: {},
19
+ sampleData: {
20
+ producer: 'stores/xqcaklwsso',
21
+ hash: 'd7b899890f5e0e98a3e074f018b14b07d5d89360',
22
+ created_at: 1761808595,
23
+ store_id: '1003425529',
24
+ scope: 'store/customer/created',
25
+ data: {
26
+ type: 'customer',
27
+ id: 2,
28
+ origin_channel_id: 1,
29
+ channel_ids: [1],
30
+ },
31
+ },
32
+ type: TriggerStrategy.WEBHOOK,
33
+ async onEnable(context) {
34
+ const webhook = await bigCommerceApiService.createWebhook({
35
+ auth: context.auth.props,
36
+ payload: {
37
+ scope: TRIGGER_SCOPE,
38
+ destination: context.webhookUrl,
39
+ is_active: true,
40
+ },
41
+ });
42
+
43
+ await context.store.put(CACHE_KEY, webhook.data.id);
44
+ },
45
+ async onDisable(context) {
46
+ const webhookId = (await context.store.get(CACHE_KEY)) as string;
47
+
48
+ if (webhookId) {
49
+ await bigCommerceApiService
50
+ .deleteWebhook({
51
+ auth: context.auth.props,
52
+ webhookId,
53
+ })
54
+ .then(async () => {
55
+ await context.store.delete(CACHE_KEY);
56
+ });
57
+ }
58
+ },
59
+ async run(context) {
60
+ return [context.payload.body];
61
+ },
62
+ });
@@ -0,0 +1,60 @@
1
+ import { createTrigger, TriggerStrategy } from '@agnocon/pieces-framework';
2
+ import { bigcommerceAuth } from '../common/auth';
3
+ import { bigCommerceApiService } from '../common/requests';
4
+
5
+ const TRIGGER_NAME = 'customer updated';
6
+ const CACHE_KEY = `${TRIGGER_NAME}-trigger-store-key`;
7
+ const TRIGGER_SCOPE = 'store/customer/updated';
8
+
9
+ export const customerUpdated = createTrigger({
10
+ auth: bigcommerceAuth,
11
+ name: 'customerUpdated',
12
+ displayName: 'Customer Updated',
13
+ description: 'Triggers when a customer is updated',
14
+ aiMetadata: {
15
+ description:
16
+ 'Fires when an existing customer record is updated in the BigCommerce store. The event identifies the affected customer.',
17
+ },
18
+ props: {},
19
+ sampleData: {
20
+ producer: 'stores/xqcaklwsso',
21
+ hash: 'd7b899890f5e0e98a3e074f018b14b07d5d89360',
22
+ created_at: 1761808595,
23
+ store_id: '1003425529',
24
+ scope: 'store/customer/updated',
25
+ data: {
26
+ type: 'customer',
27
+ id: 2,
28
+ },
29
+ },
30
+ type: TriggerStrategy.WEBHOOK,
31
+ async onEnable(context) {
32
+ const webhook = await bigCommerceApiService.createWebhook({
33
+ auth: context.auth.props,
34
+ payload: {
35
+ scope: TRIGGER_SCOPE,
36
+ destination: context.webhookUrl,
37
+ is_active: true,
38
+ },
39
+ });
40
+
41
+ await context.store.put(CACHE_KEY, webhook.data.id);
42
+ },
43
+ async onDisable(context) {
44
+ const webhookId = (await context.store.get(CACHE_KEY)) as string;
45
+
46
+ if (webhookId) {
47
+ await bigCommerceApiService
48
+ .deleteWebhook({
49
+ auth: context.auth.props,
50
+ webhookId,
51
+ })
52
+ .then(async () => {
53
+ await context.store.delete(CACHE_KEY);
54
+ });
55
+ }
56
+ },
57
+ async run(context) {
58
+ return [context.payload.body];
59
+ },
60
+ });
@@ -0,0 +1,60 @@
1
+ import { createTrigger, TriggerStrategy } from '@agnocon/pieces-framework';
2
+ import { bigcommerceAuth } from '../common/auth';
3
+ import { bigCommerceApiService } from '../common/requests';
4
+
5
+ const TRIGGER_NAME = 'order created';
6
+ const CACHE_KEY = `${TRIGGER_NAME}-trigger-store-key`;
7
+ const TRIGGER_SCOPE = 'store/order/created';
8
+
9
+ export const orderCreated = createTrigger({
10
+ auth: bigcommerceAuth,
11
+ name: 'orderCreated',
12
+ displayName: 'Order Created',
13
+ description: 'Triggers when a new order is created',
14
+ aiMetadata: {
15
+ description:
16
+ 'Fires when a new order is created in the BigCommerce store. The event identifies the new order; pair with Get Order to fetch its full details.',
17
+ },
18
+ props: {},
19
+ sampleData: {
20
+ producer: 'stores/xqcaklwsso',
21
+ hash: 'd7b899890f5e0e98a3e074f018b14b07d5d89360',
22
+ created_at: 1761808595,
23
+ store_id: '1003425529',
24
+ scope: 'store/order/created',
25
+ data: {
26
+ type: 'order',
27
+ id: 2,
28
+ },
29
+ },
30
+ type: TriggerStrategy.WEBHOOK,
31
+ async onEnable(context) {
32
+ const webhook = await bigCommerceApiService.createWebhook({
33
+ auth: context.auth.props,
34
+ payload: {
35
+ scope: TRIGGER_SCOPE,
36
+ destination: context.webhookUrl,
37
+ is_active: true,
38
+ },
39
+ });
40
+
41
+ await context.store.put(CACHE_KEY, webhook.data.id);
42
+ },
43
+ async onDisable(context) {
44
+ const webhookId = (await context.store.get(CACHE_KEY)) as string;
45
+
46
+ if (webhookId) {
47
+ await bigCommerceApiService
48
+ .deleteWebhook({
49
+ auth: context.auth.props,
50
+ webhookId,
51
+ })
52
+ .then(async () => {
53
+ await context.store.delete(CACHE_KEY);
54
+ });
55
+ }
56
+ },
57
+ async run(context) {
58
+ return [context.payload.body];
59
+ },
60
+ });