n8n-nodes-commercetools 0.1.6 → 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/README.md +129 -38
- 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 +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -22,16 +22,17 @@ This will start n8n with the Commercetools node loaded and hot reload enabled.
|
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
|
|
25
|
+
|
|
25
26
|
## Configuration Options
|
|
26
27
|
|
|
27
|
-
Below are the main configuration options and parameters available for the Commercetools node (resource: product):
|
|
28
|
+
Below are the main configuration options and parameters available for the Commercetools node (resource: product or category):
|
|
28
29
|
|
|
29
30
|
### Common Parameters
|
|
30
|
-
- **resource**: Select 'product' to access
|
|
31
|
-
- **operation**: Choose the desired
|
|
31
|
+
- **resource**: Select 'product' or 'category' to access respective operations.
|
|
32
|
+
- **operation**: Choose the desired operation (e.g., create, query, get, update, delete, etc.).
|
|
32
33
|
- **Credentials**: Select your configured Commercetools OAuth2 credentials.
|
|
33
34
|
|
|
34
|
-
### Operation-Specific Parameters
|
|
35
|
+
### Product Operation-Specific Parameters
|
|
35
36
|
|
|
36
37
|
#### Create Product
|
|
37
38
|
- **productDraft**: JSON object with product details (name, slug, productType, masterVariant, etc.).
|
|
@@ -72,6 +73,34 @@ Below are the main configuration options and parameters available for the Commer
|
|
|
72
73
|
- **binaryPropertyName**: Name of the binary property containing the image.
|
|
73
74
|
- **additionalFieldsUpload**: Optional fields (variantId, sku, staged, filename, externalUrl, label, customParameters).
|
|
74
75
|
|
|
76
|
+
### Category Operation-Specific Parameters
|
|
77
|
+
|
|
78
|
+
#### Create Category
|
|
79
|
+
- **categoryDraft**: JSON object with category details (name, slug, parent, orderHint, etc.).
|
|
80
|
+
- **additionalFieldsCreate**: Optional fields for additional category properties.
|
|
81
|
+
|
|
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.
|
|
87
|
+
|
|
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.
|
|
91
|
+
|
|
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.).
|
|
98
|
+
|
|
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.).
|
|
103
|
+
|
|
75
104
|
Refer to the node UI in n8n for detailed descriptions and validation for each parameter.
|
|
76
105
|
|
|
77
106
|
Below is a sample workflow using the Commercetools node in n8n to create and query a product.
|
|
@@ -97,6 +126,7 @@ Below is a sample workflow using the Commercetools node in n8n to create and que
|
|
|
97
126
|
}
|
|
98
127
|
```
|
|
99
128
|
|
|
129
|
+
|
|
100
130
|
### Example: Query Products
|
|
101
131
|
|
|
102
132
|
1. Add the **Commercetools** node to your workflow.
|
|
@@ -111,50 +141,90 @@ Below is a sample workflow using the Commercetools node in n8n to create and que
|
|
|
111
141
|
{
|
|
112
142
|
"id": "product-id-1",
|
|
113
143
|
"name": { "en": "Sample Product" },
|
|
114
|
-
"slug": { "en": "sample-product" }
|
|
144
|
+
"slug": { "en": "sample-product" }
|
|
115
145
|
// ...other product fields
|
|
116
|
-
}
|
|
146
|
+
}
|
|
117
147
|
// ...more products
|
|
118
148
|
]
|
|
119
149
|
```
|
|
120
150
|
|
|
121
|
-
|
|
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
|
+
```
|
|
167
|
+
|
|
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
|
+
```
|
|
188
|
+
|
|
189
|
+
You can chain Commercetools node operations with other n8n nodes to build advanced workflows for product and category management, automation, and integration.
|
|
190
|
+
|
|
122
191
|
|
|
123
192
|
## Credential Setup
|
|
124
193
|
|
|
125
|
-
To use the Commercetools node, you must configure OAuth2 credentials for your Commercetools project in n8n. Follow these steps:
|
|
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:**
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
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`)
|
|
136
205
|
|
|
137
206
|
2. **Add credentials in n8n:**
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
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.
|
|
147
216
|
|
|
148
217
|
3. **Use credentials in your workflow:**
|
|
149
|
-
|
|
218
|
+
- When adding the Commercetools node to your workflow, select the credentials you just created from the credentials dropdown.
|
|
150
219
|
|
|
151
|
-
Your Commercetools node is now authenticated and ready to use in n8n workflows.
|
|
220
|
+
Your Commercetools node is now authenticated and ready to use for both product and category operations in n8n workflows.
|
|
152
221
|
|
|
153
222
|
|
|
154
223
|
## Features & Supported Operations
|
|
155
224
|
|
|
156
|
-
The Commercetools node for n8n enables you to interact with the Commercetools API for product management. The following operations are supported:
|
|
225
|
+
The Commercetools node for n8n enables you to interact with the Commercetools API for product and category management. The following operations are supported:
|
|
157
226
|
|
|
227
|
+
### Product Operations
|
|
158
228
|
- **Create Product**
|
|
159
229
|
Create a new product in your Commercetools project.
|
|
160
230
|
|
|
@@ -179,11 +249,26 @@ The Commercetools node for n8n enables you to interact with the Commercetools AP
|
|
|
179
249
|
- **Upload Product Image**
|
|
180
250
|
Upload an image to a product, either from binary data or an external URL.
|
|
181
251
|
|
|
182
|
-
###
|
|
252
|
+
### Category Operations
|
|
253
|
+
- **Create Category**
|
|
254
|
+
Create a new category in your Commercetools project.
|
|
255
|
+
|
|
256
|
+
- **Query Categories**
|
|
257
|
+
Retrieve a list of categories with support for pagination, sorting, and filtering.
|
|
183
258
|
|
|
184
|
-
- **
|
|
185
|
-
|
|
186
|
-
|
|
259
|
+
- **Get Category (by ID or Key)**
|
|
260
|
+
Retrieve detailed information for a specific category by its ID or key.
|
|
261
|
+
|
|
262
|
+
- **Update Category (by ID or Key)**
|
|
263
|
+
Update an existing category using one or more update actions.
|
|
264
|
+
|
|
265
|
+
- **Delete Category (by ID or Key)**
|
|
266
|
+
Delete a category from your project.
|
|
267
|
+
|
|
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.
|
|
187
272
|
|
|
188
273
|
Each operation supports additional parameters for fine-tuned control, such as staged changes, data erasure, dry run, and more.
|
|
189
274
|
|
|
@@ -240,30 +325,33 @@ Each operation supports additional parameters for fine-tuned control, such as st
|
|
|
240
325
|
|
|
241
326
|
|
|
242
327
|
|
|
328
|
+
|
|
243
329
|
## Error Handling & Troubleshooting
|
|
244
330
|
|
|
245
|
-
Here are common errors and troubleshooting tips for the Commercetools node:
|
|
331
|
+
Here are common errors and troubleshooting tips for the Commercetools node (products and categories):
|
|
246
332
|
|
|
247
333
|
- **Authentication Errors:**
|
|
248
334
|
- Ensure your OAuth2 credentials (Client ID, Client Secret, Project Key, Region, Scopes) are correct and have the required permissions.
|
|
249
335
|
- If you see an authentication error, re-authorize or recreate your credentials in n8n.
|
|
250
336
|
|
|
251
337
|
- **Missing or Invalid Parameters:**
|
|
252
|
-
- Double-check required fields for each operation
|
|
338
|
+
- Double-check required fields for each operation:
|
|
339
|
+
- For products: productDraft, productId/productKey, version, etc.
|
|
340
|
+
- For categories: categoryDraft, categoryId/categoryKey, version, etc.
|
|
253
341
|
- The node will display a clear error if a required parameter is missing or invalid.
|
|
254
342
|
|
|
255
343
|
- **API Errors:**
|
|
256
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.
|
|
257
345
|
- Review the error message for details and check your input data.
|
|
258
346
|
|
|
259
|
-
- **
|
|
260
|
-
- For get, update, delete, or existence checks, ensure the productId or
|
|
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.
|
|
261
349
|
|
|
262
350
|
- **Version Mismatch:**
|
|
263
|
-
- For update and delete operations, the
|
|
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).
|
|
264
352
|
|
|
265
353
|
- **Binary Data Issues (Image Upload):**
|
|
266
|
-
- Ensure the binary property name matches the uploaded file and the file is present in the workflow.
|
|
354
|
+
- Ensure the binary property name matches the uploaded file and the file is present in the workflow (product image upload only).
|
|
267
355
|
|
|
268
356
|
- **General Node Issues:**
|
|
269
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.
|
|
@@ -289,7 +377,10 @@ Contributions and suggestions for improving the Commercetools node are welcome.
|
|
|
289
377
|
|
|
290
378
|
All notable changes to this project will be documented in the `CHANGELOG.md` file. Below is a summary of recent updates:
|
|
291
379
|
|
|
380
|
+
|
|
292
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
|
|
293
384
|
- Documentation improvements and structure updates
|
|
294
385
|
- Added detailed usage examples and troubleshooting section
|
|
295
386
|
- Enhanced configuration options and parameter documentation
|
|
@@ -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;QACl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