n8n-nodes-commercetools 0.1.5 → 0.1.7
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/LICENSE.md +1 -1
- package/README.md +299 -149
- package/dist/nodes/Commercetools/Commercetools.node.js +22 -11
- package/dist/nodes/Commercetools/Commercetools.node.js.map +1 -1
- package/dist/nodes/Commercetools/descriptions/Commercetools.description.js +476 -5
- package/dist/nodes/Commercetools/descriptions/Commercetools.description.js.map +1 -1
- package/dist/nodes/Commercetools/operations/category.operations.d.ts +8 -0
- package/dist/nodes/Commercetools/operations/category.operations.js +217 -0
- package/dist/nodes/Commercetools/operations/category.operations.js.map +1 -0
- package/dist/package.json +3 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
package/LICENSE.md
CHANGED
package/README.md
CHANGED
|
@@ -1,247 +1,397 @@
|
|
|
1
1
|

|
|
2
2
|
|
|
3
|
-
# n8n-nodes-starter
|
|
4
3
|
|
|
5
|
-
|
|
4
|
+
# n8n-nodes-commercetools
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
> [!TIP]
|
|
10
|
-
> **New to building n8n nodes?** The fastest way to get started is with `npm create @n8n/node`. This command scaffolds a complete node package for you using the [@n8n/node-cli](https://www.npmjs.com/package/@n8n/node-cli).
|
|
6
|
+
This repository provides a custom [n8n](https://n8n.io) node for integrating with [Commercetools](https://commercetools.com). It includes all required credentials, node definitions, and utilities to interact with the Commercetools API.
|
|
11
7
|
|
|
12
|
-
**To create a new node package from scratch:**
|
|
13
8
|
|
|
14
|
-
|
|
15
|
-
npm create @n8n/node
|
|
16
|
-
```
|
|
9
|
+
## Quick Start
|
|
17
10
|
|
|
18
|
-
**
|
|
11
|
+
**To start developing and testing the Commercetools node:**
|
|
19
12
|
|
|
20
13
|
```bash
|
|
14
|
+
npm install
|
|
21
15
|
npm run dev
|
|
22
16
|
```
|
|
23
17
|
|
|
24
|
-
This
|
|
18
|
+
This will start n8n with the Commercetools node loaded and hot reload enabled.
|
|
25
19
|
|
|
26
|
-
## What's Included
|
|
27
20
|
|
|
28
|
-
This starter repository includes two example nodes to learn from:
|
|
29
21
|
|
|
30
|
-
- **[Example Node](nodes/Example/)** - A simple starter node that shows the basic structure with a custom `execute` method
|
|
31
|
-
- **[GitHub Issues Node](nodes/GithubIssues/)** - A complete, production-ready example built using the **declarative style**:
|
|
32
|
-
- **Low-code approach** - Define operations declaratively without writing request logic
|
|
33
|
-
- Multiple resources (Issues, Comments)
|
|
34
|
-
- Multiple operations (Get, Get All, Create)
|
|
35
|
-
- Two authentication methods (OAuth2 and Personal Access Token)
|
|
36
|
-
- List search functionality for dynamic dropdowns
|
|
37
|
-
- Proper error handling and typing
|
|
38
|
-
- Ideal for HTTP API-based integrations
|
|
39
22
|
|
|
40
|
-
> [!TIP]
|
|
41
|
-
> The declarative/low-code style (used in GitHub Issues) is the recommended approach for building nodes that interact with HTTP APIs. It significantly reduces boilerplate code and handles requests automatically.
|
|
42
23
|
|
|
43
|
-
Browse these examples to understand both approaches, then modify them or create your own.
|
|
44
24
|
|
|
45
|
-
## Finding Inspiration
|
|
46
25
|
|
|
47
|
-
|
|
26
|
+
## Configuration Options
|
|
48
27
|
|
|
49
|
-
|
|
50
|
-
- **[n8n Built-in Nodes](https://github.com/n8n-io/n8n/tree/master/packages/nodes-base/nodes)** - Study the source code of n8n's official nodes for production-ready patterns and best practices
|
|
51
|
-
- **[n8n Credentials](https://github.com/n8n-io/n8n/tree/master/packages/nodes-base/credentials)** - See how authentication is implemented for various services
|
|
28
|
+
Below are the main configuration options and parameters available for the Commercetools node (resource: product or category):
|
|
52
29
|
|
|
53
|
-
|
|
30
|
+
### Common Parameters
|
|
31
|
+
- **resource**: Select 'product' or 'category' to access respective operations.
|
|
32
|
+
- **operation**: Choose the desired operation (e.g., create, query, get, update, delete, etc.).
|
|
33
|
+
- **Credentials**: Select your configured Commercetools OAuth2 credentials.
|
|
54
34
|
|
|
55
|
-
|
|
35
|
+
### Product Operation-Specific Parameters
|
|
56
36
|
|
|
57
|
-
|
|
37
|
+
#### Create Product
|
|
38
|
+
- **productDraft**: JSON object with product details (name, slug, productType, masterVariant, etc.).
|
|
39
|
+
- **additionalFieldsCreate**: Optional fields for additional product properties.
|
|
58
40
|
|
|
59
|
-
|
|
41
|
+
#### Query Products
|
|
42
|
+
- **returnAll**: Boolean to return all products (up to 500 per request).
|
|
43
|
+
- **limit**: Number of products to return per request.
|
|
44
|
+
- **offset**: Pagination offset.
|
|
45
|
+
- **additionalFields**: Optional filters, sorting, and predicate variables.
|
|
60
46
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
- **[git](https://git-scm.com/downloads)**
|
|
47
|
+
#### Search Products
|
|
48
|
+
- **searchRequest**: JSON object for advanced search queries.
|
|
49
|
+
- **additionalFieldsSearch**: Optional search parameters (limit, offset, staged, etc.).
|
|
65
50
|
|
|
66
|
-
|
|
51
|
+
#### Get Product / Get By Key
|
|
52
|
+
- **productId** or **productKey**: ID or key of the product to retrieve.
|
|
53
|
+
- **additionalFieldsGet**: Optional fields for expanded data.
|
|
67
54
|
|
|
68
|
-
|
|
55
|
+
#### Update Product / Update By Key
|
|
56
|
+
- **productId** or **productKey**: ID or key of the product to update.
|
|
57
|
+
- **version**: Product version (required for updates).
|
|
58
|
+
- **actions**: Array of update actions (JSON).
|
|
59
|
+
- **actionsUi**: UI-based update actions.
|
|
60
|
+
- **additionalFieldsUpdate**: Optional fields (dataErasure, dryRun, etc.).
|
|
69
61
|
|
|
70
|
-
|
|
71
|
-
|
|
62
|
+
#### Delete Product / Delete By Key
|
|
63
|
+
- **productId** or **productKey**: ID or key of the product to delete.
|
|
64
|
+
- **version**: Product version (required for deletion).
|
|
65
|
+
- **additionalFieldsDelete**: Optional fields (dataErasure, etc.).
|
|
72
66
|
|
|
73
|
-
|
|
67
|
+
#### Query Product Selections
|
|
68
|
+
- **productId** or **productKey**: ID or key of the product.
|
|
69
|
+
- **additionalFieldsSelections**: Optional fields (expand, limit, offset, withTotal, customParameters).
|
|
74
70
|
|
|
75
|
-
|
|
71
|
+
#### Upload Product Image
|
|
72
|
+
- **productId**: ID of the product to upload the image to.
|
|
73
|
+
- **binaryPropertyName**: Name of the binary property containing the image.
|
|
74
|
+
- **additionalFieldsUpload**: Optional fields (variantId, sku, staged, filename, externalUrl, label, customParameters).
|
|
76
75
|
|
|
77
|
-
###
|
|
76
|
+
### Category Operation-Specific Parameters
|
|
78
77
|
|
|
79
|
-
|
|
78
|
+
#### Create Category
|
|
79
|
+
- **categoryDraft**: JSON object with category details (name, slug, parent, orderHint, etc.).
|
|
80
|
+
- **additionalFieldsCreate**: Optional fields for additional category properties.
|
|
80
81
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
#### Query Categories
|
|
83
|
+
- **returnAll**: Boolean to return all categories (up to 500 per request).
|
|
84
|
+
- **limit**: Number of categories to return per request.
|
|
85
|
+
- **offset**: Pagination offset.
|
|
86
|
+
- **additionalFields**: Optional filters, sorting, and predicate variables.
|
|
85
87
|
|
|
86
|
-
|
|
88
|
+
#### Get Category / Get By Key
|
|
89
|
+
- **categoryId** or **categoryKey**: ID or key of the category to retrieve.
|
|
90
|
+
- **additionalFieldsGet**: Optional fields for expanded data.
|
|
87
91
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
92
|
+
#### Update Category / Update By Key
|
|
93
|
+
- **categoryId** or **categoryKey**: ID or key of the category to update.
|
|
94
|
+
- **version**: Category version (required for updates).
|
|
95
|
+
- **actions**: Array of update actions (JSON).
|
|
96
|
+
- **actionsUi**: UI-based update actions.
|
|
97
|
+
- **additionalFieldsUpdate**: Optional fields (dataErasure, dryRun, etc.).
|
|
91
98
|
|
|
92
|
-
|
|
99
|
+
#### Delete Category / Delete By Key
|
|
100
|
+
- **categoryId** or **categoryKey**: ID or key of the category to delete.
|
|
101
|
+
- **version**: Category version (required for deletion).
|
|
102
|
+
- **additionalFieldsDelete**: Optional fields (dataErasure, etc.).
|
|
93
103
|
|
|
94
|
-
|
|
104
|
+
Refer to the node UI in n8n for detailed descriptions and validation for each parameter.
|
|
95
105
|
|
|
96
|
-
|
|
106
|
+
Below is a sample workflow using the Commercetools node in n8n to create and query a product.
|
|
97
107
|
|
|
98
|
-
|
|
99
|
-
- Study [nodes/GithubIssues/](nodes/GithubIssues/) for a real-world implementation
|
|
108
|
+
### Example: Create a Product
|
|
100
109
|
|
|
101
|
-
|
|
110
|
+
1. Add the **Commercetools** node to your workflow.
|
|
111
|
+
2. Select the **Create Product** operation.
|
|
112
|
+
3. Fill in the required product draft fields (e.g., name, slug, product type, etc.).
|
|
113
|
+
4. Select your configured Commercetools credentials.
|
|
114
|
+
5. Run the workflow to create a new product in your Commercetools project.
|
|
102
115
|
|
|
103
|
-
|
|
116
|
+
**Sample Input (Product Draft):**
|
|
117
|
+
```json
|
|
118
|
+
{
|
|
119
|
+
"name": { "en": "Sample Product" },
|
|
120
|
+
"slug": { "en": "sample-product" },
|
|
121
|
+
"productType": { "id": "your-product-type-id" },
|
|
122
|
+
"masterVariant": {
|
|
123
|
+
"sku": "SKU123",
|
|
124
|
+
"prices": [ { "value": { "currencyCode": "USD", "centAmount": 1000 } } ]
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
```
|
|
104
128
|
|
|
105
|
-
> [!TIP]
|
|
106
|
-
> If you want to scaffold a completely new node package, use `npm create @n8n/node` to start fresh with the CLI's interactive generator.
|
|
107
129
|
|
|
108
|
-
###
|
|
130
|
+
### Example: Query Products
|
|
131
|
+
|
|
132
|
+
1. Add the **Commercetools** node to your workflow.
|
|
133
|
+
2. Select the **Query Products** operation.
|
|
134
|
+
3. Optionally set filters, sorting, and pagination parameters.
|
|
135
|
+
4. Select your configured Commercetools credentials.
|
|
136
|
+
5. Run the workflow to retrieve products from your Commercetools project.
|
|
137
|
+
|
|
138
|
+
**Sample Output:**
|
|
139
|
+
```json
|
|
140
|
+
[
|
|
141
|
+
{
|
|
142
|
+
"id": "product-id-1",
|
|
143
|
+
"name": { "en": "Sample Product" },
|
|
144
|
+
"slug": { "en": "sample-product" }
|
|
145
|
+
// ...other product fields
|
|
146
|
+
}
|
|
147
|
+
// ...more products
|
|
148
|
+
]
|
|
149
|
+
```
|
|
109
150
|
|
|
110
|
-
|
|
151
|
+
### Example: Create a Category
|
|
152
|
+
|
|
153
|
+
1. Add the **Commercetools** node to your workflow.
|
|
154
|
+
2. Select the **Create Category** operation.
|
|
155
|
+
3. Fill in the required category draft fields (e.g., name, slug, parent, orderHint, etc.).
|
|
156
|
+
4. Select your configured Commercetools credentials.
|
|
157
|
+
5. Run the workflow to create a new category in your Commercetools project.
|
|
158
|
+
|
|
159
|
+
**Sample Input (Category Draft):**
|
|
160
|
+
```json
|
|
161
|
+
{
|
|
162
|
+
"name": { "en": "Sample Category" },
|
|
163
|
+
"slug": { "en": "sample-category" },
|
|
164
|
+
"orderHint": "0.1"
|
|
165
|
+
}
|
|
166
|
+
```
|
|
111
167
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
168
|
+
### Example: Query Categories
|
|
169
|
+
|
|
170
|
+
1. Add the **Commercetools** node to your workflow.
|
|
171
|
+
2. Select the **Query Categories** operation.
|
|
172
|
+
3. Optionally set filters, sorting, and pagination parameters.
|
|
173
|
+
4. Select your configured Commercetools credentials.
|
|
174
|
+
5. Run the workflow to retrieve categories from your Commercetools project.
|
|
175
|
+
|
|
176
|
+
**Sample Output:**
|
|
177
|
+
```json
|
|
178
|
+
[
|
|
179
|
+
{
|
|
180
|
+
"id": "category-id-1",
|
|
181
|
+
"name": { "en": "Sample Category" },
|
|
182
|
+
"slug": { "en": "sample-category" }
|
|
183
|
+
// ...other category fields
|
|
184
|
+
}
|
|
185
|
+
// ...more categories
|
|
186
|
+
]
|
|
187
|
+
```
|
|
116
188
|
|
|
117
|
-
|
|
189
|
+
You can chain Commercetools node operations with other n8n nodes to build advanced workflows for product and category management, automation, and integration.
|
|
118
190
|
|
|
119
|
-
### 6. Develop and Test Locally
|
|
120
191
|
|
|
121
|
-
|
|
192
|
+
## Credential Setup
|
|
122
193
|
|
|
123
|
-
|
|
124
|
-
npm run dev
|
|
125
|
-
```
|
|
194
|
+
To use the Commercetools node for both product and category operations, you must configure OAuth2 credentials for your Commercetools project in n8n. Follow these steps:
|
|
126
195
|
|
|
127
|
-
|
|
196
|
+
1. **Obtain Commercetools API credentials:**
|
|
197
|
+
- Log in to your Commercetools Merchant Center.
|
|
198
|
+
- Go to the API Clients section and create a new API client.
|
|
199
|
+
- Note the following values:
|
|
200
|
+
- `Client ID`
|
|
201
|
+
- `Client Secret`
|
|
202
|
+
- `Project Key`
|
|
203
|
+
- `Scopes` (ensure you have the required scopes for product and category operations)
|
|
204
|
+
- `Region` (e.g., `australia-southeast1.gcp`)
|
|
128
205
|
|
|
129
|
-
|
|
130
|
-
-
|
|
131
|
-
-
|
|
132
|
-
-
|
|
206
|
+
2. **Add credentials in n8n:**
|
|
207
|
+
- In n8n, go to **Credentials** > **Create New**.
|
|
208
|
+
- Search for and select **Commercetools OAuth2 API**.
|
|
209
|
+
- Fill in the required fields:
|
|
210
|
+
- **Client ID**
|
|
211
|
+
- **Client Secret**
|
|
212
|
+
- **Project Key**
|
|
213
|
+
- **Region**
|
|
214
|
+
- **Scopes**
|
|
215
|
+
- Save the credentials.
|
|
133
216
|
|
|
134
|
-
|
|
217
|
+
3. **Use credentials in your workflow:**
|
|
218
|
+
- When adding the Commercetools node to your workflow, select the credentials you just created from the credentials dropdown.
|
|
135
219
|
|
|
136
|
-
|
|
137
|
-
> Learn more about CLI commands in the [@n8n/node-cli documentation](https://www.npmjs.com/package/@n8n/node-cli).
|
|
220
|
+
Your Commercetools node is now authenticated and ready to use for both product and category operations in n8n workflows.
|
|
138
221
|
|
|
139
|
-
### 7. Lint Your Code
|
|
140
222
|
|
|
141
|
-
|
|
223
|
+
## Features & Supported Operations
|
|
142
224
|
|
|
143
|
-
|
|
144
|
-
npm run lint
|
|
145
|
-
```
|
|
225
|
+
The Commercetools node for n8n enables you to interact with the Commercetools API for product and category management. The following operations are supported:
|
|
146
226
|
|
|
147
|
-
|
|
227
|
+
### Product Operations
|
|
228
|
+
- **Create Product**
|
|
229
|
+
Create a new product in your Commercetools project.
|
|
148
230
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
```
|
|
231
|
+
- **Query Products**
|
|
232
|
+
Retrieve a list of products with support for pagination, sorting, filtering, and predicate variables.
|
|
152
233
|
|
|
153
|
-
|
|
234
|
+
- **Search Products**
|
|
235
|
+
Perform advanced product searches using the Commercetools search endpoint.
|
|
154
236
|
|
|
155
|
-
|
|
237
|
+
- **Get Product (by ID or Key)**
|
|
238
|
+
Retrieve detailed information for a specific product by its ID or key.
|
|
156
239
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
```
|
|
240
|
+
- **Update Product (by ID or Key)**
|
|
241
|
+
Update an existing product using one or more update actions.
|
|
160
242
|
|
|
161
|
-
|
|
243
|
+
- **Delete Product (by ID or Key)**
|
|
244
|
+
Delete a product from your project.
|
|
162
245
|
|
|
163
|
-
|
|
246
|
+
- **Query Product Selections (by ID or Key)**
|
|
247
|
+
Retrieve product selection assignments for a product.
|
|
164
248
|
|
|
165
|
-
|
|
249
|
+
- **Upload Product Image**
|
|
250
|
+
Upload an image to a product, either from binary data or an external URL.
|
|
166
251
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
252
|
+
### Category Operations
|
|
253
|
+
- **Create Category**
|
|
254
|
+
Create a new category in your Commercetools project.
|
|
170
255
|
|
|
171
|
-
|
|
256
|
+
- **Query Categories**
|
|
257
|
+
Retrieve a list of categories with support for pagination, sorting, and filtering.
|
|
172
258
|
|
|
173
|
-
|
|
259
|
+
- **Get Category (by ID or Key)**
|
|
260
|
+
Retrieve detailed information for a specific category by its ID or key.
|
|
174
261
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
```
|
|
262
|
+
- **Update Category (by ID or Key)**
|
|
263
|
+
Update an existing category using one or more update actions.
|
|
178
264
|
|
|
179
|
-
|
|
265
|
+
- **Delete Category (by ID or Key)**
|
|
266
|
+
Delete a category from your project.
|
|
180
267
|
|
|
181
|
-
###
|
|
268
|
+
### Check Product & Category Existence
|
|
269
|
+
- **By ID:** Use the "HEAD" operation with a product or category ID to check if it exists.
|
|
270
|
+
- **By Key:** Use the "HEAD by Key" operation with a product or category key.
|
|
271
|
+
- **By Query:** Use the "HEAD by Query" operation to check if any product or category matches a specific query.
|
|
182
272
|
|
|
183
|
-
|
|
273
|
+
Each operation supports additional parameters for fine-tuned control, such as staged changes, data erasure, dry run, and more.
|
|
184
274
|
|
|
185
|
-
|
|
186
|
-
- Uses MIT license ✅ (included in this starter)
|
|
187
|
-
- No external package dependencies
|
|
188
|
-
- Follows n8n's design guidelines
|
|
189
|
-
- Passes quality and security review
|
|
275
|
+
## What's Included
|
|
190
276
|
|
|
191
|
-
|
|
277
|
+
- **Commercetools Node**: Located in `nodes/Commercetools/`, this node provides operations for interacting with the Commercetools API, including product management and authentication via OAuth2.
|
|
278
|
+
- **Credentials**: OAuth2 credentials for Commercetools in `credentials/CommerceToolsOAuth2Api.credentials.ts`.
|
|
279
|
+
- **Utilities and Descriptions**: Helper functions and operation definitions for Commercetools API requests.
|
|
192
280
|
|
|
193
|
-
**Benefits of verification:**
|
|
194
281
|
|
|
195
|
-
- Available directly in n8n Cloud
|
|
196
|
-
- Discoverable in the n8n nodes panel
|
|
197
|
-
- Verified badge for quality assurance
|
|
198
|
-
- Increased visibility in the n8n community
|
|
199
282
|
|
|
200
|
-
##
|
|
283
|
+
## Prerequisites
|
|
284
|
+
|
|
285
|
+
- **[Node.js](https://nodejs.org/)** (v22 or higher) and npm
|
|
286
|
+
- **[git](https://git-scm.com/downloads)**
|
|
287
|
+
|
|
201
288
|
|
|
202
|
-
|
|
289
|
+
## Usage
|
|
290
|
+
|
|
291
|
+
1. **Install dependencies**
|
|
292
|
+
```bash
|
|
293
|
+
npm install
|
|
294
|
+
```
|
|
295
|
+
2. **Start development server**
|
|
296
|
+
```bash
|
|
297
|
+
npm run dev
|
|
298
|
+
```
|
|
299
|
+
This will build the node and launch n8n locally with hot reload enabled. Access n8n at [http://localhost:5678](http://localhost:5678).
|
|
300
|
+
3. **Configure Commercetools credentials**
|
|
301
|
+
- Go to n8n's credentials section and add your Commercetools OAuth2 credentials.
|
|
302
|
+
4. **Use the Commercetools node in your workflow**
|
|
303
|
+
- Add the Commercetools node to your workflow and select the desired operation (e.g., product management).
|
|
304
|
+
5. **Lint and build**
|
|
305
|
+
- Lint: `npm run lint`
|
|
306
|
+
- Auto-fix: `npm run lint:fix`
|
|
307
|
+
- Build: `npm run build`
|
|
308
|
+
6. **Publish**
|
|
309
|
+
- When ready, publish your package to npm:
|
|
310
|
+
```bash
|
|
311
|
+
npm publish
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
## Available Scripts
|
|
203
316
|
|
|
204
317
|
| Script | Description |
|
|
205
318
|
| --------------------- | ---------------------------------------------------------------- |
|
|
206
|
-
| `npm run dev` | Start n8n with
|
|
207
|
-
| `npm run build` | Compile TypeScript to JavaScript for production
|
|
319
|
+
| `npm run dev` | Start n8n with the Commercetools node and watch for changes |
|
|
320
|
+
| `npm run build` | Compile TypeScript to JavaScript for production |
|
|
208
321
|
| `npm run build:watch` | Build in watch mode (auto-rebuild on changes) |
|
|
209
|
-
| `npm run lint` | Check your code for errors and style issues
|
|
210
|
-
| `npm run lint:fix` | Automatically fix linting issues when possible
|
|
211
|
-
| `npm run release` | Create a new release
|
|
322
|
+
| `npm run lint` | Check your code for errors and style issues |
|
|
323
|
+
| `npm run lint:fix` | Automatically fix linting issues when possible |
|
|
324
|
+
| `npm run release` | Create a new release |
|
|
325
|
+
|
|
326
|
+
|
|
212
327
|
|
|
213
|
-
> [!TIP]
|
|
214
|
-
> These scripts use the [@n8n/node-cli](https://www.npmjs.com/package/@n8n/node-cli) under the hood. You can also run CLI commands directly, e.g., `npx n8n-node dev`.
|
|
215
328
|
|
|
216
|
-
## Troubleshooting
|
|
329
|
+
## Error Handling & Troubleshooting
|
|
217
330
|
|
|
218
|
-
|
|
331
|
+
Here are common errors and troubleshooting tips for the Commercetools node (products and categories):
|
|
219
332
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
4. Check the console for any error messages
|
|
333
|
+
- **Authentication Errors:**
|
|
334
|
+
- Ensure your OAuth2 credentials (Client ID, Client Secret, Project Key, Region, Scopes) are correct and have the required permissions.
|
|
335
|
+
- If you see an authentication error, re-authorize or recreate your credentials in n8n.
|
|
224
336
|
|
|
225
|
-
|
|
337
|
+
- **Missing or Invalid Parameters:**
|
|
338
|
+
- Double-check required fields for each operation:
|
|
339
|
+
- For products: productDraft, productId/productKey, version, etc.
|
|
340
|
+
- For categories: categoryDraft, categoryId/categoryKey, version, etc.
|
|
341
|
+
- The node will display a clear error if a required parameter is missing or invalid.
|
|
226
342
|
|
|
227
|
-
|
|
343
|
+
- **API Errors:**
|
|
344
|
+
- Errors from the Commercetools API (e.g., 404 Not Found, 400 Bad Request) will be shown in the node output or n8n error panel.
|
|
345
|
+
- Review the error message for details and check your input data.
|
|
228
346
|
|
|
229
|
-
|
|
347
|
+
- **Not Found (Product/Category):**
|
|
348
|
+
- For get, update, delete, or existence checks, ensure the productId/productKey or categoryId/categoryKey is correct and the item exists in your project.
|
|
349
|
+
|
|
350
|
+
- **Version Mismatch:**
|
|
351
|
+
- For update and delete operations, the version must match the current version in Commercetools. Retrieve the latest version before updating or deleting (applies to both products and categories).
|
|
352
|
+
|
|
353
|
+
- **Binary Data Issues (Image Upload):**
|
|
354
|
+
- Ensure the binary property name matches the uploaded file and the file is present in the workflow (product image upload only).
|
|
355
|
+
|
|
356
|
+
- **General Node Issues:**
|
|
357
|
+
- If the node does not appear in n8n, ensure dependencies are installed, the node is registered in `package.json`, and the dev server is running.
|
|
358
|
+
- Check the n8n console and logs for error details.
|
|
359
|
+
|
|
360
|
+
For linting or TypeScript errors, use the provided scripts or consult the [n8n node development guidelines](https://docs.n8n.io/integrations/creating-nodes/).
|
|
230
361
|
|
|
231
|
-
Make sure you're using Node.js v22 or higher and have run `npm install` to get all type definitions.
|
|
232
362
|
|
|
233
363
|
## Resources
|
|
234
364
|
|
|
235
|
-
- **[n8n Node Documentation](https://docs.n8n.io/integrations/creating-nodes/)**
|
|
236
|
-
- **[n8n Community Forum](https://community.n8n.io/)**
|
|
237
|
-
- **[@n8n/node-cli Documentation](https://www.npmjs.com/package/@n8n/node-cli)**
|
|
238
|
-
|
|
239
|
-
- **[Submit Community Nodes Guide](https://docs.n8n.io/integrations/creating-nodes/deploy/submit-community-nodes/)** - Verification requirements and process
|
|
365
|
+
- **[n8n Node Documentation](https://docs.n8n.io/integrations/creating-nodes/)**
|
|
366
|
+
- **[n8n Community Forum](https://community.n8n.io/)**
|
|
367
|
+
- **[@n8n/node-cli Documentation](https://www.npmjs.com/package/@n8n/node-cli)**
|
|
368
|
+
|
|
240
369
|
|
|
241
370
|
## Contributing
|
|
242
371
|
|
|
243
|
-
|
|
372
|
+
Contributions and suggestions for improving the Commercetools node are welcome. Please open an issue or submit a pull request.
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
## Changelog
|
|
377
|
+
|
|
378
|
+
All notable changes to this project will be documented in the `CHANGELOG.md` file. Below is a summary of recent updates:
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
### [Unreleased]
|
|
382
|
+
- Added category-related APIs to Commercetools node (create, query, get, update, delete, existence checks)
|
|
383
|
+
- Updated documentation to include category operations in features, configuration, usage examples, credential setup, and troubleshooting
|
|
384
|
+
- Documentation improvements and structure updates
|
|
385
|
+
- Added detailed usage examples and troubleshooting section
|
|
386
|
+
- Enhanced configuration options and parameter documentation
|
|
387
|
+
|
|
388
|
+
### v1.0.0
|
|
389
|
+
- Initial release of the Commercetools node for n8n
|
|
390
|
+
- Supports product management operations: create, query, search, get, update, delete, product selections, image upload, and existence checks
|
|
391
|
+
- OAuth2 credential integration
|
|
392
|
+
|
|
393
|
+
Refer to `CHANGELOG.md` for a complete version history and details.
|
|
244
394
|
|
|
245
395
|
## License
|
|
246
396
|
|
|
247
|
-
[MIT](
|
|
397
|
+
[MIT](LICENSE.md)
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Commercetools = void 0;
|
|
4
4
|
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
5
|
const Commercetools_description_1 = require("./descriptions/Commercetools.description");
|
|
6
|
+
const category_operations_1 = require("./operations/category.operations");
|
|
6
7
|
const product_operations_1 = require("./operations/product.operations");
|
|
7
8
|
class Commercetools {
|
|
8
9
|
constructor() {
|
|
@@ -19,11 +20,6 @@ class Commercetools {
|
|
|
19
20
|
try {
|
|
20
21
|
const resource = this.getNodeParameter('resource', itemIndex);
|
|
21
22
|
const operation = this.getNodeParameter('operation', itemIndex);
|
|
22
|
-
if (resource !== 'product') {
|
|
23
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Unsupported resource: ${resource}`, {
|
|
24
|
-
itemIndex,
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
23
|
const credentials = (await this.getCredentials('commerceToolsOAuth2Api'));
|
|
28
24
|
const projectKey = credentials.projectKey;
|
|
29
25
|
const region = credentials.region || 'australia-southeast1.gcp';
|
|
@@ -33,12 +29,27 @@ class Commercetools {
|
|
|
33
29
|
});
|
|
34
30
|
}
|
|
35
31
|
const baseUrl = `https://api.${region}.commercetools.com/${projectKey}`;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
32
|
+
let results = [];
|
|
33
|
+
if (resource === 'product') {
|
|
34
|
+
results = await product_operations_1.executeProductOperation.call(this, {
|
|
35
|
+
operation,
|
|
36
|
+
itemIndex,
|
|
37
|
+
baseUrl,
|
|
38
|
+
items,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
else if (resource === 'category') {
|
|
42
|
+
results = await category_operations_1.executeCategoryOperation.call(this, {
|
|
43
|
+
operation,
|
|
44
|
+
itemIndex,
|
|
45
|
+
baseUrl,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Unsupported resource: ${resource}`, {
|
|
50
|
+
itemIndex,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
42
53
|
returnData.push(...results);
|
|
43
54
|
}
|
|
44
55
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Commercetools.node.js","sourceRoot":"","sources":["../../../nodes/Commercetools/Commercetools.node.ts"],"names":[],"mappings":";;;AAOA,+CAAkD;AAElD,wFAAoF;AACpF,wEAA0E;AAE1E,MAAa,aAAa;IAA1B;QACC,gBAAW,GAAyB;YACnC,GAAG,oDAAwB;YAC3B,IAAI,EAAE,wBAAwB;YAC9B,YAAY,EAAE,IAAI;SAClB,CAAC;
|
|
1
|
+
{"version":3,"file":"Commercetools.node.js","sourceRoot":"","sources":["../../../nodes/Commercetools/Commercetools.node.ts"],"names":[],"mappings":";;;AAOA,+CAAkD;AAElD,wFAAoF;AACpF,0EAA4E;AAC5E,wEAA0E;AAE1E,MAAa,aAAa;IAA1B;QACC,gBAAW,GAAyB;YACnC,GAAG,oDAAwB;YAC3B,IAAI,EAAE,wBAAwB;YAC9B,YAAY,EAAE,IAAI;SAClB,CAAC;IAmEH,CAAC;IAhEA,KAAK,CAAC,OAAO;QACZ,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QAClC,MAAM,UAAU,GAAyB,EAAE,CAAC;QAE5C,KAAK,IAAI,SAAS,GAAG,CAAC,EAAE,SAAS,GAAG,KAAK,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,CAAC;YAC/D,IAAI,CAAC;gBACJ,MAAM,QAAQ,GAAG,IAAI,CAAC,gBAAgB,CAAC,UAAU,EAAE,SAAS,CAAW,CAAC;gBACxE,MAAM,SAAS,GAAG,IAAI,CAAC,gBAAgB,CAAC,WAAW,EAAE,SAAS,CAAW,CAAC;gBAE1E,MAAM,WAAW,GAAG,CAAC,MAAM,IAAI,CAAC,cAAc,CAAC,wBAAwB,CAAC,CAAgB,CAAC;gBACzF,MAAM,UAAU,GAAG,WAAW,CAAC,UAAoB,CAAC;gBACpD,MAAM,MAAM,GAAI,WAAW,CAAC,MAAiB,IAAI,0BAA0B,CAAC;gBAE5E,IAAI,CAAC,UAAU,EAAE,CAAC;oBACjB,MAAM,IAAI,iCAAkB,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,2CAA2C,EAAE;wBACzF,SAAS;qBACT,CAAC,CAAC;gBACJ,CAAC;gBAED,MAAM,OAAO,GAAG,eAAe,MAAM,sBAAsB,UAAU,EAAE,CAAC;gBAExE,IAAI,OAAO,GAAyB,EAAE,CAAC;gBAEvC,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;oBAC5B,OAAO,GAAG,MAAM,4CAAuB,CAAC,IAAI,CAAC,IAAI,EAAE;wBAClD,SAAS;wBACT,SAAS;wBACT,OAAO;wBACP,KAAK;qBACL,CAAC,CAAC;gBACJ,CAAC;qBAAM,IAAI,QAAQ,KAAK,UAAU,EAAE,CAAC;oBACpC,OAAO,GAAG,MAAM,8CAAwB,CAAC,IAAI,CAAC,IAAI,EAAE;wBACnD,SAAS;wBACT,SAAS;wBACT,OAAO;qBACP,CAAC,CAAC;gBACJ,CAAC;qBAAM,CAAC;oBACP,MAAM,IAAI,iCAAkB,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,yBAAyB,QAAQ,EAAE,EAAE;wBACjF,SAAS;qBACT,CAAC,CAAC;gBACJ,CAAC;gBAED,UAAU,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC;YAC7B,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,IAAI,IAAI,CAAC,cAAc,EAAE,EAAE,CAAC;oBAC3B,UAAU,CAAC,IAAI,CAAC;wBACf,IAAI,EAAE;4BACL,KAAK,EAAG,KAAe,CAAC,OAAO;4BAC/B,SAAS;yBACT;qBACD,CAAC,CAAC;oBACH,SAAS;gBACV,CAAC;gBAED,IAAI,KAAK,YAAY,iCAAkB,EAAE,CAAC;oBACzC,MAAM,KAAK,CAAC;gBACb,CAAC;gBAED,MAAM,IAAI,iCAAkB,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,KAAc,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC;YAC7E,CAAC;QACF,CAAC;QAED,OAAO,CAAC,UAAU,CAAC,CAAC;IACrB,CAAC;CACD;AAxED,sCAwEC"}
|