n8n-nodes-n8ndesigner-salla-n8nai 0.3.160 → 0.3.162
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 +21 -21
- package/README.md +38 -140
- package/package.json +12 -16
- package/dist/nodes/Customers/DeleteCustomer.node.d.ts +0 -8
- package/dist/nodes/Customers/DeleteCustomer.node.js +0 -304
- package/dist/nodes/Orders/UpdateOrderStatus.node.d.ts +0 -8
- package/dist/nodes/Orders/UpdateOrderStatus.node.js +0 -359
- package/dist/nodes/Triggers/CustomerCreatedTrigger.node.d.ts +0 -8
- package/dist/nodes/Triggers/CustomerCreatedTrigger.node.js +0 -150
- package/dist/nodes/Triggers/OrderStatusUpdatedTrigger.node.d.ts +0 -8
- package/dist/nodes/Triggers/OrderStatusUpdatedTrigger.node.js +0 -150
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 n8n Designer
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,140 +1,38 @@
|
|
|
1
|
-
# n8n
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
npm
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
##
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
Updates a Salla order workflow state by slug or numeric status ID and supports an optional note (max 500 characters). Either slug or status_id is required; if both are present they are sent together.
|
|
41
|
-
|
|
42
|
-
Example curl equivalent (QA data):
|
|
43
|
-
|
|
44
|
-
`ash
|
|
45
|
-
curl -X PATCH 'https://app.n8ndesigner.com/api/actions/orders/562285006' \
|
|
46
|
-
-H 'Authorization: Bearer mak_xxxxxxxxxx' \
|
|
47
|
-
-H 'Content-Type: application/json' \
|
|
48
|
-
-d '{
|
|
49
|
-
salla_merchant_id: 1596416913,
|
|
50
|
-
slug: under_review,
|
|
51
|
-
note: Order triaged from n8n
|
|
52
|
-
}'
|
|
53
|
-
`
|
|
54
|
-
|
|
55
|
-
### Delete Customer
|
|
56
|
-
|
|
57
|
-
Permanently deletes a customer. The node sends the merchant ID in both the body and query string so it works with the current and future controllers.
|
|
58
|
-
|
|
59
|
-
`ash
|
|
60
|
-
curl -X DELETE 'https://app.n8ndesigner.com/api/actions/customers/1924459692?salla_merchant_id=1596416913' \
|
|
61
|
-
-H 'Authorization: Bearer mak_xxxxxxxxxx' \
|
|
62
|
-
-H 'Content-Type: application/json' \
|
|
63
|
-
-d '{
|
|
64
|
-
salla_merchant_id: 1596416913
|
|
65
|
-
}'
|
|
66
|
-
`
|
|
67
|
-
|
|
68
|
-
Both action nodes return a normalized payload:
|
|
69
|
-
|
|
70
|
-
`json
|
|
71
|
-
{
|
|
72
|
-
ok: true,
|
|
73
|
-
status: 200,
|
|
74
|
-
data: { ... },
|
|
75
|
-
raw: { ... }
|
|
76
|
-
}
|
|
77
|
-
`
|
|
78
|
-
|
|
79
|
-
Failures surface the backend-provided message (including Arabic validation strings) without additional wrapping, and each request times out after 12 seconds with up to two exponential retries on 429, 5xx, or transient network errors.
|
|
80
|
-
|
|
81
|
-
## Triggers
|
|
82
|
-
|
|
83
|
-
### Salla Triggers
|
|
84
|
-
|
|
85
|
-
One unified webhook node that subscribes to the full Salla event catalogue exposed by the merchant proxy. Pick the desired event from the **Trigger On** dropdown (orders, customers, products, shipping, offers, and more) and the node automatically listens on `/webhook/<auto-id>/salla/<event>`. Every delivery emits a normalized payload:
|
|
86
|
-
|
|
87
|
-
```json
|
|
88
|
-
{
|
|
89
|
-
"ok": true,
|
|
90
|
-
"event": "order.status.updated",
|
|
91
|
-
"merchant": "1596416913",
|
|
92
|
-
"created_at": "2025-10-26T17:49:35.000Z",
|
|
93
|
-
"data": { ... original body or body.data ... },
|
|
94
|
-
"raw": {
|
|
95
|
-
"headers": { "X-Salla-Event": "order.status.updated", ... },
|
|
96
|
-
"body": { ...full request body... },
|
|
97
|
-
"query": { ... }
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
Incoming notifications are validated against the selected event, de-duplicated by `X-Salla-Event-Id` (10 minute TTL), and acknowledgements for ignored or duplicate payloads return HTTP 200 with a descriptive body.
|
|
103
|
-
|
|
104
|
-
The **Webhook Path** field is optional—leave it blank to keep the default `/salla/<event>` suffix, or provide your own (it will be slugified and appended after `/webhook/<auto-id>/` when the workflow is saved).
|
|
105
|
-
|
|
106
|
-
### Deprecated triggers
|
|
107
|
-
|
|
108
|
-
- Customer Created (Salla) — **Deprecated** (use `Salla Triggers` with `customer.created`)
|
|
109
|
-
- Order Status Updated (Salla) — **Deprecated** (use `Salla Triggers` with `order.status.updated`)
|
|
110
|
-
|
|
111
|
-
Existing workflows keep working, but new automations should migrate to **Salla Triggers**.
|
|
112
|
-
|
|
113
|
-
## Proxy Fallback Helper
|
|
114
|
-
|
|
115
|
-
For QA you can call the legacy merchant proxy through the shared helper:
|
|
116
|
-
|
|
117
|
-
` s
|
|
118
|
-
const proxyResponse = await client.proxy({
|
|
119
|
-
method: 'GET',
|
|
120
|
-
path: '/v2/customers',
|
|
121
|
-
payload: { keyword: 'test@example.com' },
|
|
122
|
-
});
|
|
123
|
-
`
|
|
124
|
-
|
|
125
|
-
The helper automatically targets POST https://app.n8ndesigner.com/api/merchant/salla and reuses the timeout and retry policy.
|
|
126
|
-
|
|
127
|
-
## Testing Notes
|
|
128
|
-
|
|
129
|
-
QA references supplied by N8NDesigner:
|
|
130
|
-
|
|
131
|
-
- SALLA_MID=1596416913
|
|
132
|
-
- ORDER_ID=562285006
|
|
133
|
-
- customer_id=1924459692
|
|
134
|
-
|
|
135
|
-
Use the action nodes to update the order to under_review (expect HTTP 200 within ~2 seconds) and to delete the disposable customer (expect HTTP 204). Trigger payload samples live under ests/Fixtures/salla/*.json (add-ons for future test automation).
|
|
136
|
-
|
|
137
|
-
## Packaging
|
|
138
|
-
|
|
139
|
-
Run
|
|
140
|
-
pm pack to produce an npm tarball suitable for publishing or direct installation inside n8n.
|
|
1
|
+
# n8n Designer – Salla Nodes (Actions + Triggers)
|
|
2
|
+
|
|
3
|
+
A community node package that lets you **receive and handle Salla webhook events** and run **Salla Actions** inside n8n workflows, with support for multi-endpoint workflows and event-based routing.
|
|
4
|
+
|
|
5
|
+
This package is built for merchants and automation builders who want to connect Salla stores to n8n with a clean, workflow-first experience.
|
|
6
|
+
|
|
7
|
+
## Key Features
|
|
8
|
+
- **Salla Trigger**: Receive Salla events inside n8n and use them to start workflows.
|
|
9
|
+
- **Salla Actions**: Perform Salla operations through configurable nodes.
|
|
10
|
+
- **Workflow-friendly design**: Designed for multi-step automations and event-based routing patterns.
|
|
11
|
+
- **Consistent node UX**: Clear node naming and grouping for easier navigation in the node list.
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
### n8n Self-hosted
|
|
16
|
+
Install via npm in your n8n environment:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install n8n-nodes-n8ndesigner-salla-n8nai
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Then restart n8n.
|
|
23
|
+
|
|
24
|
+
> Note: Availability in n8n Cloud depends on n8n’s community node policies.
|
|
25
|
+
|
|
26
|
+
## Usage
|
|
27
|
+
1. Add the **Salla Trigger** node to start a workflow from Salla events.
|
|
28
|
+
2. Add **Salla Actions** nodes to perform operations as part of the same workflow.
|
|
29
|
+
3. Use standard n8n nodes (IF, Switch, HTTP Request, Set, Code, etc.) to route and transform data.
|
|
30
|
+
|
|
31
|
+
## Support & Contact
|
|
32
|
+
- Website: https://n8ndesigner.com/
|
|
33
|
+
- Email: support@n8ndesigner.com
|
|
34
|
+
- Telegram Community: t.me/+nrnxntkvDn1kNTBk
|
|
35
|
+
- News Channel: t.me/+QPFFnJNnnrM5NmVk
|
|
36
|
+
|
|
37
|
+
## License
|
|
38
|
+
MIT — Copyright (c) 2025 n8n Designer
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "n8n-nodes-n8ndesigner-salla-n8nai",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.162",
|
|
4
4
|
"description": "Salla nodes for n8n (Actions + Triggers)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -12,12 +12,13 @@
|
|
|
12
12
|
"README.md",
|
|
13
13
|
"LICENSE"
|
|
14
14
|
],
|
|
15
|
-
"keywords": [
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
|
|
15
|
+
"keywords": [
|
|
16
|
+
"n8ndesigner",
|
|
17
|
+
"salla-nodes",
|
|
18
|
+
"n8nai",
|
|
19
|
+
"n8n-salla",
|
|
20
|
+
"n8n-designer"
|
|
21
|
+
],
|
|
21
22
|
"author": "N8NDesigner",
|
|
22
23
|
"scripts": {
|
|
23
24
|
"build": "echo \"Skipping build; dist already compiled\"",
|
|
@@ -28,15 +29,10 @@
|
|
|
28
29
|
"n8n-workflow": "^1.116.0"
|
|
29
30
|
},
|
|
30
31
|
"n8n": {
|
|
31
|
-
"nodes": [
|
|
32
|
-
"dist/nodes/Actions/SallaActions.node.js",
|
|
33
|
-
"dist/nodes/
|
|
34
|
-
|
|
35
|
-
"dist/nodes/Triggers/OrderStatusUpdatedTrigger.node.js",
|
|
36
|
-
"dist/nodes/Triggers/CustomerCreatedTrigger.node.js",
|
|
37
|
-
"dist/nodes/Triggers/SallaTriggers.node.js",
|
|
38
|
-
"dist/nodes/Triggers/SallaTrigger.node.js"
|
|
39
|
-
],
|
|
32
|
+
"nodes": [
|
|
33
|
+
"dist/nodes/Actions/SallaActions.node.js",
|
|
34
|
+
"dist/nodes/Triggers/SallaTrigger.node.js"
|
|
35
|
+
],
|
|
40
36
|
"credentials": [
|
|
41
37
|
"dist/credentials/SallaActionsApi.credentials.js"
|
|
42
38
|
]
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { INodeType, INodeTypeDescription, IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';
|
|
2
|
-
|
|
3
|
-
declare class DeleteCustomer implements INodeType {
|
|
4
|
-
description: INodeTypeDescription;
|
|
5
|
-
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export { DeleteCustomer };
|
|
@@ -1,304 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// nodes/Customers/DeleteCustomer.node.ts
|
|
21
|
-
var DeleteCustomer_node_exports = {};
|
|
22
|
-
__export(DeleteCustomer_node_exports, {
|
|
23
|
-
DeleteCustomer: () => DeleteCustomer
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(DeleteCustomer_node_exports);
|
|
26
|
-
var import_n8n_workflow2 = require("n8n-workflow");
|
|
27
|
-
|
|
28
|
-
// shared/constants.ts
|
|
29
|
-
var SALLA_CREDENTIAL_NAME = "sallaActionsApi";
|
|
30
|
-
var DEFAULT_BASE_URL = "https://app.n8ndesigner.com";
|
|
31
|
-
var SALLA_BRAND_COLOR = "#00C58E";
|
|
32
|
-
|
|
33
|
-
// shared/httpClient.ts
|
|
34
|
-
var import_n8n_workflow = require("n8n-workflow");
|
|
35
|
-
var DEFAULT_TIMEOUT = 12e3;
|
|
36
|
-
var RETRY_DELAYS = [1e3, 3e3];
|
|
37
|
-
var RETRY_ERROR_CODES = /* @__PURE__ */ new Set(["ETIMEDOUT", "ECONNRESET"]);
|
|
38
|
-
function trimTrailingSlash(input) {
|
|
39
|
-
const value = input && input.trim() !== "" ? input : DEFAULT_BASE_URL;
|
|
40
|
-
return value.replace(/\/+$/, "");
|
|
41
|
-
}
|
|
42
|
-
function ensureLeadingSlash(path) {
|
|
43
|
-
if (!path.startsWith("/")) {
|
|
44
|
-
return "/" + path;
|
|
45
|
-
}
|
|
46
|
-
return path;
|
|
47
|
-
}
|
|
48
|
-
function buildActionsUrl(baseUrl, path) {
|
|
49
|
-
const normalizedBase = trimTrailingSlash(baseUrl);
|
|
50
|
-
return normalizedBase + "/api/actions" + ensureLeadingSlash(path);
|
|
51
|
-
}
|
|
52
|
-
function buildProxyUrl(baseUrl) {
|
|
53
|
-
const normalizedBase = trimTrailingSlash(baseUrl);
|
|
54
|
-
return normalizedBase + "/api/merchant/salla";
|
|
55
|
-
}
|
|
56
|
-
function normalizeResponse(rawBody, statusCode) {
|
|
57
|
-
const raw = rawBody ?? null;
|
|
58
|
-
if (rawBody === void 0 || rawBody === null || rawBody === "") {
|
|
59
|
-
return {
|
|
60
|
-
ok: statusCode >= 200 && statusCode < 300,
|
|
61
|
-
status: statusCode,
|
|
62
|
-
data: null,
|
|
63
|
-
error: statusCode >= 400 ? "Request failed with status " + statusCode : null,
|
|
64
|
-
raw
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
if (typeof rawBody !== "object") {
|
|
68
|
-
return {
|
|
69
|
-
ok: statusCode >= 200 && statusCode < 300,
|
|
70
|
-
status: statusCode,
|
|
71
|
-
data: rawBody,
|
|
72
|
-
error: statusCode >= 400 ? String(rawBody) : null,
|
|
73
|
-
raw
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
const body = rawBody;
|
|
77
|
-
const successFlag = typeof body.success === "boolean" ? body.success : void 0;
|
|
78
|
-
const okFlag = typeof body.ok === "boolean" ? body.ok : void 0;
|
|
79
|
-
const status = typeof body.status === "number" ? body.status : statusCode;
|
|
80
|
-
const ok = okFlag ?? successFlag ?? (status >= 200 && status < 300);
|
|
81
|
-
let data = null;
|
|
82
|
-
if (Object.prototype.hasOwnProperty.call(body, "data")) {
|
|
83
|
-
data = body.data ?? null;
|
|
84
|
-
}
|
|
85
|
-
const errors = body.errors;
|
|
86
|
-
if (errors) {
|
|
87
|
-
if (data && typeof data === "object") {
|
|
88
|
-
data = {
|
|
89
|
-
...data,
|
|
90
|
-
errors
|
|
91
|
-
};
|
|
92
|
-
} else {
|
|
93
|
-
data = { errors };
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
let error = null;
|
|
97
|
-
if (typeof body.error === "string") {
|
|
98
|
-
error = body.error;
|
|
99
|
-
} else if (!ok) {
|
|
100
|
-
if (typeof body.message === "string" && body.message.trim() !== "") {
|
|
101
|
-
error = body.message;
|
|
102
|
-
} else if (body.error && typeof body.error === "object") {
|
|
103
|
-
error = JSON.stringify(body.error);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
if (!ok && !error) {
|
|
107
|
-
error = "Request failed with status " + status;
|
|
108
|
-
}
|
|
109
|
-
return {
|
|
110
|
-
ok,
|
|
111
|
-
status,
|
|
112
|
-
data: data ?? null,
|
|
113
|
-
error,
|
|
114
|
-
raw
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
function shouldRetryStatus(status) {
|
|
118
|
-
return status === 429 || status >= 500;
|
|
119
|
-
}
|
|
120
|
-
function shouldRetryError(error) {
|
|
121
|
-
if (!error || typeof error !== "object") {
|
|
122
|
-
return false;
|
|
123
|
-
}
|
|
124
|
-
const err = error;
|
|
125
|
-
const status = err.statusCode ?? err.response?.statusCode;
|
|
126
|
-
if (typeof status === "number" && shouldRetryStatus(status)) {
|
|
127
|
-
return true;
|
|
128
|
-
}
|
|
129
|
-
const code = err.code ?? err.cause?.code;
|
|
130
|
-
return code ? RETRY_ERROR_CODES.has(code) : false;
|
|
131
|
-
}
|
|
132
|
-
async function executeWithRetry(caller, requestOptions) {
|
|
133
|
-
let lastError;
|
|
134
|
-
for (let attempt = 0; attempt <= RETRY_DELAYS.length; attempt++) {
|
|
135
|
-
try {
|
|
136
|
-
const response = await caller(requestOptions);
|
|
137
|
-
const normalized = normalizeResponse(response.body, response.statusCode);
|
|
138
|
-
if (shouldRetryStatus(normalized.status) && attempt < RETRY_DELAYS.length) {
|
|
139
|
-
await (0, import_n8n_workflow.sleep)(RETRY_DELAYS[attempt]);
|
|
140
|
-
continue;
|
|
141
|
-
}
|
|
142
|
-
return normalized;
|
|
143
|
-
} catch (error) {
|
|
144
|
-
lastError = error;
|
|
145
|
-
if (attempt < RETRY_DELAYS.length && shouldRetryError(error)) {
|
|
146
|
-
await (0, import_n8n_workflow.sleep)(RETRY_DELAYS[attempt]);
|
|
147
|
-
continue;
|
|
148
|
-
}
|
|
149
|
-
break;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
if (lastError && typeof lastError === "object") {
|
|
153
|
-
const err = lastError;
|
|
154
|
-
const status = err.statusCode ?? err.response?.statusCode ?? 0;
|
|
155
|
-
const body = err.response?.body;
|
|
156
|
-
const fallback = normalizeResponse(body, status || 0);
|
|
157
|
-
if (fallback.error && err.message && !fallback.error.includes(err.message)) {
|
|
158
|
-
fallback.error = fallback.error + ". " + err.message;
|
|
159
|
-
} else if (!fallback.error) {
|
|
160
|
-
fallback.error = err.message ?? "Request failed";
|
|
161
|
-
}
|
|
162
|
-
return fallback;
|
|
163
|
-
}
|
|
164
|
-
return {
|
|
165
|
-
ok: false,
|
|
166
|
-
status: 0,
|
|
167
|
-
data: null,
|
|
168
|
-
error: lastError instanceof Error ? lastError.message : "Request failed",
|
|
169
|
-
raw: null
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
function buildCaller(context, credentialType) {
|
|
173
|
-
return async (options) => {
|
|
174
|
-
const response = await context.helpers.requestWithAuthentication.call(
|
|
175
|
-
context,
|
|
176
|
-
credentialType,
|
|
177
|
-
options
|
|
178
|
-
);
|
|
179
|
-
return {
|
|
180
|
-
statusCode: response.statusCode,
|
|
181
|
-
body: response.body,
|
|
182
|
-
headers: response.headers
|
|
183
|
-
};
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
function createSallaActionsClient(context, credentials, credentialType = SALLA_CREDENTIAL_NAME) {
|
|
187
|
-
const caller = buildCaller(context, credentialType);
|
|
188
|
-
async function request(options) {
|
|
189
|
-
const requestOptions = {
|
|
190
|
-
method: options.method,
|
|
191
|
-
url: buildActionsUrl(credentials.baseUrl, options.path),
|
|
192
|
-
qs: options.qs,
|
|
193
|
-
body: options.body,
|
|
194
|
-
headers: options.headers,
|
|
195
|
-
json: true,
|
|
196
|
-
timeout: DEFAULT_TIMEOUT
|
|
197
|
-
};
|
|
198
|
-
const advanced = requestOptions;
|
|
199
|
-
advanced["returnFullResponse"] = true;
|
|
200
|
-
advanced["resolveWithFullResponse"] = true;
|
|
201
|
-
advanced["ignoreHttpStatusErrors"] = true;
|
|
202
|
-
return executeWithRetry(caller, requestOptions);
|
|
203
|
-
}
|
|
204
|
-
async function proxy(options) {
|
|
205
|
-
const requestOptions = {
|
|
206
|
-
method: "POST",
|
|
207
|
-
url: buildProxyUrl(credentials.baseUrl),
|
|
208
|
-
body: {
|
|
209
|
-
salla_merchant_id: credentials.salla_merchant_id,
|
|
210
|
-
method: options.method,
|
|
211
|
-
path: options.path,
|
|
212
|
-
payload: options.payload ?? null
|
|
213
|
-
},
|
|
214
|
-
json: true,
|
|
215
|
-
timeout: DEFAULT_TIMEOUT
|
|
216
|
-
};
|
|
217
|
-
const advanced = requestOptions;
|
|
218
|
-
advanced["returnFullResponse"] = true;
|
|
219
|
-
advanced["resolveWithFullResponse"] = true;
|
|
220
|
-
advanced["ignoreHttpStatusErrors"] = true;
|
|
221
|
-
return executeWithRetry(caller, requestOptions);
|
|
222
|
-
}
|
|
223
|
-
return {
|
|
224
|
-
request,
|
|
225
|
-
proxy
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
// nodes/Customers/DeleteCustomer.node.ts
|
|
230
|
-
var DeleteCustomer = class {
|
|
231
|
-
constructor() {
|
|
232
|
-
this.description = {
|
|
233
|
-
displayName: "Delete Customer (Deprecated)",
|
|
234
|
-
name: "sallaDeleteCustomer",
|
|
235
|
-
group: ["transform"],
|
|
236
|
-
version: 1,
|
|
237
|
-
icon: "file:assets/salla-logo.svg",
|
|
238
|
-
description: "Deprecated – use Salla Actions node instead.",
|
|
239
|
-
defaults: {
|
|
240
|
-
name: "Delete Customer (Deprecated)",
|
|
241
|
-
color: SALLA_BRAND_COLOR
|
|
242
|
-
},
|
|
243
|
-
inputs: ["main"],
|
|
244
|
-
outputs: ["main"],
|
|
245
|
-
credentials: [
|
|
246
|
-
{
|
|
247
|
-
name: SALLA_CREDENTIAL_NAME,
|
|
248
|
-
required: true
|
|
249
|
-
}
|
|
250
|
-
],
|
|
251
|
-
properties: [
|
|
252
|
-
{
|
|
253
|
-
displayName: "Customer ID",
|
|
254
|
-
name: "customerId",
|
|
255
|
-
type: "string",
|
|
256
|
-
required: true,
|
|
257
|
-
default: "",
|
|
258
|
-
description: "Numeric or string identifier of the customer to delete."
|
|
259
|
-
},
|
|
260
|
-
{
|
|
261
|
-
displayName: "Warning",
|
|
262
|
-
name: "deleteWarning",
|
|
263
|
-
type: "notice",
|
|
264
|
-
default: "This action permanently deletes the customer from Salla."
|
|
265
|
-
}
|
|
266
|
-
]
|
|
267
|
-
};
|
|
268
|
-
}
|
|
269
|
-
async execute() {
|
|
270
|
-
const items = this.getInputData();
|
|
271
|
-
const returnItems = [];
|
|
272
|
-
const credentials = await this.getCredentials(
|
|
273
|
-
SALLA_CREDENTIAL_NAME
|
|
274
|
-
);
|
|
275
|
-
const client = createSallaActionsClient(this, credentials);
|
|
276
|
-
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
|
|
277
|
-
const customerId = this.getNodeParameter("customerId", itemIndex);
|
|
278
|
-
const body = null;
|
|
279
|
-
const response = await client.request({
|
|
280
|
-
method: "DELETE",
|
|
281
|
-
path: "/customers/" + encodeURIComponent(String(customerId))});
|
|
282
|
-
if (!response.ok) {
|
|
283
|
-
throw new import_n8n_workflow2.NodeOperationError(this.getNode(), response.error ?? "Salla Actions request failed", {
|
|
284
|
-
itemIndex,
|
|
285
|
-
description: response.raw ? JSON.stringify(response.raw, null, 2) : void 0
|
|
286
|
-
});
|
|
287
|
-
}
|
|
288
|
-
returnItems.push({
|
|
289
|
-
json: {
|
|
290
|
-
ok: response.ok,
|
|
291
|
-
status: response.status,
|
|
292
|
-
data: response.data ?? null,
|
|
293
|
-
raw: response.raw ?? null
|
|
294
|
-
}
|
|
295
|
-
});
|
|
296
|
-
}
|
|
297
|
-
return [returnItems];
|
|
298
|
-
}
|
|
299
|
-
};
|
|
300
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
301
|
-
0 && (module.exports = {
|
|
302
|
-
DeleteCustomer
|
|
303
|
-
});
|
|
304
|
-
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { INodeType, INodeTypeDescription, IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';
|
|
2
|
-
|
|
3
|
-
declare class UpdateOrderStatus implements INodeType {
|
|
4
|
-
description: INodeTypeDescription;
|
|
5
|
-
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export { UpdateOrderStatus };
|
|
@@ -1,359 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// nodes/Orders/UpdateOrderStatus.node.ts
|
|
21
|
-
var UpdateOrderStatus_node_exports = {};
|
|
22
|
-
__export(UpdateOrderStatus_node_exports, {
|
|
23
|
-
UpdateOrderStatus: () => UpdateOrderStatus
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(UpdateOrderStatus_node_exports);
|
|
26
|
-
var import_n8n_workflow2 = require("n8n-workflow");
|
|
27
|
-
|
|
28
|
-
// shared/constants.ts
|
|
29
|
-
var SALLA_CREDENTIAL_NAME = "sallaActionsApi";
|
|
30
|
-
var DEFAULT_BASE_URL = "https://app.n8ndesigner.com";
|
|
31
|
-
var SALLA_BRAND_COLOR = "#00C58E";
|
|
32
|
-
|
|
33
|
-
// shared/httpClient.ts
|
|
34
|
-
var import_n8n_workflow = require("n8n-workflow");
|
|
35
|
-
var DEFAULT_TIMEOUT = 12e3;
|
|
36
|
-
var RETRY_DELAYS = [1e3, 3e3];
|
|
37
|
-
var RETRY_ERROR_CODES = /* @__PURE__ */ new Set(["ETIMEDOUT", "ECONNRESET"]);
|
|
38
|
-
function trimTrailingSlash(input) {
|
|
39
|
-
const value = input && input.trim() !== "" ? input : DEFAULT_BASE_URL;
|
|
40
|
-
return value.replace(/\/+$/, "");
|
|
41
|
-
}
|
|
42
|
-
function ensureLeadingSlash(path) {
|
|
43
|
-
if (!path.startsWith("/")) {
|
|
44
|
-
return "/" + path;
|
|
45
|
-
}
|
|
46
|
-
return path;
|
|
47
|
-
}
|
|
48
|
-
function buildActionsUrl(baseUrl, path) {
|
|
49
|
-
const normalizedBase = trimTrailingSlash(baseUrl);
|
|
50
|
-
return normalizedBase + "/api/actions" + ensureLeadingSlash(path);
|
|
51
|
-
}
|
|
52
|
-
function buildProxyUrl(baseUrl) {
|
|
53
|
-
const normalizedBase = trimTrailingSlash(baseUrl);
|
|
54
|
-
return normalizedBase + "/api/merchant/salla";
|
|
55
|
-
}
|
|
56
|
-
function normalizeResponse(rawBody, statusCode) {
|
|
57
|
-
const raw = rawBody ?? null;
|
|
58
|
-
if (rawBody === void 0 || rawBody === null || rawBody === "") {
|
|
59
|
-
return {
|
|
60
|
-
ok: statusCode >= 200 && statusCode < 300,
|
|
61
|
-
status: statusCode,
|
|
62
|
-
data: null,
|
|
63
|
-
error: statusCode >= 400 ? "Request failed with status " + statusCode : null,
|
|
64
|
-
raw
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
if (typeof rawBody !== "object") {
|
|
68
|
-
return {
|
|
69
|
-
ok: statusCode >= 200 && statusCode < 300,
|
|
70
|
-
status: statusCode,
|
|
71
|
-
data: rawBody,
|
|
72
|
-
error: statusCode >= 400 ? String(rawBody) : null,
|
|
73
|
-
raw
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
const body = rawBody;
|
|
77
|
-
const successFlag = typeof body.success === "boolean" ? body.success : void 0;
|
|
78
|
-
const okFlag = typeof body.ok === "boolean" ? body.ok : void 0;
|
|
79
|
-
const status = typeof body.status === "number" ? body.status : statusCode;
|
|
80
|
-
const ok = okFlag ?? successFlag ?? (status >= 200 && status < 300);
|
|
81
|
-
let data = null;
|
|
82
|
-
if (Object.prototype.hasOwnProperty.call(body, "data")) {
|
|
83
|
-
data = body.data ?? null;
|
|
84
|
-
}
|
|
85
|
-
const errors = body.errors;
|
|
86
|
-
if (errors) {
|
|
87
|
-
if (data && typeof data === "object") {
|
|
88
|
-
data = {
|
|
89
|
-
...data,
|
|
90
|
-
errors
|
|
91
|
-
};
|
|
92
|
-
} else {
|
|
93
|
-
data = { errors };
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
let error = null;
|
|
97
|
-
if (typeof body.error === "string") {
|
|
98
|
-
error = body.error;
|
|
99
|
-
} else if (!ok) {
|
|
100
|
-
if (typeof body.message === "string" && body.message.trim() !== "") {
|
|
101
|
-
error = body.message;
|
|
102
|
-
} else if (body.error && typeof body.error === "object") {
|
|
103
|
-
error = JSON.stringify(body.error);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
if (!ok && !error) {
|
|
107
|
-
error = "Request failed with status " + status;
|
|
108
|
-
}
|
|
109
|
-
return {
|
|
110
|
-
ok,
|
|
111
|
-
status,
|
|
112
|
-
data: data ?? null,
|
|
113
|
-
error,
|
|
114
|
-
raw
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
function shouldRetryStatus(status) {
|
|
118
|
-
return status === 429 || status >= 500;
|
|
119
|
-
}
|
|
120
|
-
function shouldRetryError(error) {
|
|
121
|
-
if (!error || typeof error !== "object") {
|
|
122
|
-
return false;
|
|
123
|
-
}
|
|
124
|
-
const err = error;
|
|
125
|
-
const status = err.statusCode ?? err.response?.statusCode;
|
|
126
|
-
if (typeof status === "number" && shouldRetryStatus(status)) {
|
|
127
|
-
return true;
|
|
128
|
-
}
|
|
129
|
-
const code = err.code ?? err.cause?.code;
|
|
130
|
-
return code ? RETRY_ERROR_CODES.has(code) : false;
|
|
131
|
-
}
|
|
132
|
-
async function executeWithRetry(caller, requestOptions) {
|
|
133
|
-
let lastError;
|
|
134
|
-
for (let attempt = 0; attempt <= RETRY_DELAYS.length; attempt++) {
|
|
135
|
-
try {
|
|
136
|
-
const response = await caller(requestOptions);
|
|
137
|
-
const normalized = normalizeResponse(response.body, response.statusCode);
|
|
138
|
-
if (shouldRetryStatus(normalized.status) && attempt < RETRY_DELAYS.length) {
|
|
139
|
-
await (0, import_n8n_workflow.sleep)(RETRY_DELAYS[attempt]);
|
|
140
|
-
continue;
|
|
141
|
-
}
|
|
142
|
-
return normalized;
|
|
143
|
-
} catch (error) {
|
|
144
|
-
lastError = error;
|
|
145
|
-
if (attempt < RETRY_DELAYS.length && shouldRetryError(error)) {
|
|
146
|
-
await (0, import_n8n_workflow.sleep)(RETRY_DELAYS[attempt]);
|
|
147
|
-
continue;
|
|
148
|
-
}
|
|
149
|
-
break;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
if (lastError && typeof lastError === "object") {
|
|
153
|
-
const err = lastError;
|
|
154
|
-
const status = err.statusCode ?? err.response?.statusCode ?? 0;
|
|
155
|
-
const body = err.response?.body;
|
|
156
|
-
const fallback = normalizeResponse(body, status || 0);
|
|
157
|
-
if (fallback.error && err.message && !fallback.error.includes(err.message)) {
|
|
158
|
-
fallback.error = fallback.error + ". " + err.message;
|
|
159
|
-
} else if (!fallback.error) {
|
|
160
|
-
fallback.error = err.message ?? "Request failed";
|
|
161
|
-
}
|
|
162
|
-
return fallback;
|
|
163
|
-
}
|
|
164
|
-
return {
|
|
165
|
-
ok: false,
|
|
166
|
-
status: 0,
|
|
167
|
-
data: null,
|
|
168
|
-
error: lastError instanceof Error ? lastError.message : "Request failed",
|
|
169
|
-
raw: null
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
function buildCaller(context, credentialType) {
|
|
173
|
-
return async (options) => {
|
|
174
|
-
const response = await context.helpers.requestWithAuthentication.call(
|
|
175
|
-
context,
|
|
176
|
-
credentialType,
|
|
177
|
-
options
|
|
178
|
-
);
|
|
179
|
-
return {
|
|
180
|
-
statusCode: response.statusCode,
|
|
181
|
-
body: response.body,
|
|
182
|
-
headers: response.headers
|
|
183
|
-
};
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
function createSallaActionsClient(context, credentials, credentialType = SALLA_CREDENTIAL_NAME) {
|
|
187
|
-
const caller = buildCaller(context, credentialType);
|
|
188
|
-
async function request(options) {
|
|
189
|
-
const requestOptions = {
|
|
190
|
-
method: options.method,
|
|
191
|
-
url: buildActionsUrl(credentials.baseUrl, options.path),
|
|
192
|
-
qs: options.qs,
|
|
193
|
-
body: options.body,
|
|
194
|
-
headers: options.headers,
|
|
195
|
-
json: true,
|
|
196
|
-
timeout: DEFAULT_TIMEOUT
|
|
197
|
-
};
|
|
198
|
-
const advanced = requestOptions;
|
|
199
|
-
advanced["returnFullResponse"] = true;
|
|
200
|
-
advanced["resolveWithFullResponse"] = true;
|
|
201
|
-
advanced["ignoreHttpStatusErrors"] = true;
|
|
202
|
-
return executeWithRetry(caller, requestOptions);
|
|
203
|
-
}
|
|
204
|
-
async function proxy(options) {
|
|
205
|
-
const requestOptions = {
|
|
206
|
-
method: "POST",
|
|
207
|
-
url: buildProxyUrl(credentials.baseUrl),
|
|
208
|
-
body: {
|
|
209
|
-
salla_merchant_id: credentials.salla_merchant_id,
|
|
210
|
-
method: options.method,
|
|
211
|
-
path: options.path,
|
|
212
|
-
payload: options.payload ?? null
|
|
213
|
-
},
|
|
214
|
-
json: true,
|
|
215
|
-
timeout: DEFAULT_TIMEOUT
|
|
216
|
-
};
|
|
217
|
-
const advanced = requestOptions;
|
|
218
|
-
advanced["returnFullResponse"] = true;
|
|
219
|
-
advanced["resolveWithFullResponse"] = true;
|
|
220
|
-
advanced["ignoreHttpStatusErrors"] = true;
|
|
221
|
-
return executeWithRetry(caller, requestOptions);
|
|
222
|
-
}
|
|
223
|
-
return {
|
|
224
|
-
request,
|
|
225
|
-
proxy
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
// nodes/Orders/UpdateOrderStatus.node.ts
|
|
230
|
-
var UpdateOrderStatus = class {
|
|
231
|
-
constructor() {
|
|
232
|
-
this.description = {
|
|
233
|
-
displayName: "Update Order Status (Deprecated)",
|
|
234
|
-
name: "sallaUpdateOrderStatus",
|
|
235
|
-
group: ["transform"],
|
|
236
|
-
version: 1,
|
|
237
|
-
icon: "file:assets/salla-logo.svg",
|
|
238
|
-
description: "Deprecated – use Salla Actions node instead.",
|
|
239
|
-
defaults: {
|
|
240
|
-
name: "Update Order Status (Deprecated)",
|
|
241
|
-
color: SALLA_BRAND_COLOR
|
|
242
|
-
},
|
|
243
|
-
inputs: ["main"],
|
|
244
|
-
outputs: ["main"],
|
|
245
|
-
credentials: [
|
|
246
|
-
{
|
|
247
|
-
name: SALLA_CREDENTIAL_NAME,
|
|
248
|
-
required: true
|
|
249
|
-
}
|
|
250
|
-
],
|
|
251
|
-
properties: [
|
|
252
|
-
{
|
|
253
|
-
displayName: "Order ID",
|
|
254
|
-
name: "orderId",
|
|
255
|
-
type: "string",
|
|
256
|
-
required: true,
|
|
257
|
-
default: "",
|
|
258
|
-
description: "Numeric or string identifier of the order to update."
|
|
259
|
-
},
|
|
260
|
-
{
|
|
261
|
-
displayName: "Status Slug",
|
|
262
|
-
name: "slug",
|
|
263
|
-
type: "string",
|
|
264
|
-
default: "",
|
|
265
|
-
required: false,
|
|
266
|
-
placeholder: "under_review",
|
|
267
|
-
description: "Workflow status slug (e.g. under_review, processing, in_progress). Provide either slug or status ID. If both are set, both will be sent."
|
|
268
|
-
},
|
|
269
|
-
{
|
|
270
|
-
displayName: "Status ID",
|
|
271
|
-
name: "status_id",
|
|
272
|
-
type: "number",
|
|
273
|
-
default: 0,
|
|
274
|
-
required: false,
|
|
275
|
-
typeOptions: {
|
|
276
|
-
minValue: 0
|
|
277
|
-
},
|
|
278
|
-
description: "Numeric workflow status ID. Provide either slug or status ID. If both are set, both will be sent."
|
|
279
|
-
},
|
|
280
|
-
{
|
|
281
|
-
displayName: "Note",
|
|
282
|
-
name: "note",
|
|
283
|
-
type: "string",
|
|
284
|
-
typeOptions: {
|
|
285
|
-
maxLength: 500
|
|
286
|
-
},
|
|
287
|
-
default: "",
|
|
288
|
-
description: "Optional note that will be persisted with the status change (max 500 characters)."
|
|
289
|
-
},
|
|
290
|
-
{
|
|
291
|
-
displayName: "Status Hint",
|
|
292
|
-
name: "statusHint",
|
|
293
|
-
type: "notice",
|
|
294
|
-
default: "Provide either slug or status_id. If both are set, both will be sent."
|
|
295
|
-
}
|
|
296
|
-
]
|
|
297
|
-
};
|
|
298
|
-
}
|
|
299
|
-
async execute() {
|
|
300
|
-
const items = this.getInputData();
|
|
301
|
-
const returnItems = [];
|
|
302
|
-
const credentials = await this.getCredentials(
|
|
303
|
-
SALLA_CREDENTIAL_NAME
|
|
304
|
-
);
|
|
305
|
-
const client = createSallaActionsClient(this, credentials);
|
|
306
|
-
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
|
|
307
|
-
const orderId = this.getNodeParameter("orderId", itemIndex);
|
|
308
|
-
const slug = this.getNodeParameter("slug", itemIndex);
|
|
309
|
-
const statusIdRaw = this.getNodeParameter("status_id", itemIndex);
|
|
310
|
-
const note = this.getNodeParameter("note", itemIndex);
|
|
311
|
-
if ((!slug || slug.trim() === "") && (!statusIdRaw || Number.isNaN(statusIdRaw))) {
|
|
312
|
-
throw new import_n8n_workflow2.NodeOperationError(this.getNode(), "Provide either a status slug or status ID.", {
|
|
313
|
-
itemIndex
|
|
314
|
-
});
|
|
315
|
-
}
|
|
316
|
-
if (note && note.length > 500) {
|
|
317
|
-
throw new import_n8n_workflow2.NodeOperationError(this.getNode(), "Note must be 500 characters or fewer.", {
|
|
318
|
-
itemIndex
|
|
319
|
-
});
|
|
320
|
-
}
|
|
321
|
-
const body = {};
|
|
322
|
-
if (slug && slug.trim() !== "") {
|
|
323
|
-
body.slug = slug.trim();
|
|
324
|
-
}
|
|
325
|
-
if (statusIdRaw && !Number.isNaN(statusIdRaw)) {
|
|
326
|
-
body.status_id = Number(statusIdRaw);
|
|
327
|
-
}
|
|
328
|
-
if (note && note.trim() !== "") {
|
|
329
|
-
body.note = note.trim();
|
|
330
|
-
}
|
|
331
|
-
const response = await client.request({
|
|
332
|
-
method: "POST",
|
|
333
|
-
path: "/orders/" + encodeURIComponent(String(orderId)) + "/status",
|
|
334
|
-
body
|
|
335
|
-
});
|
|
336
|
-
if (!response.ok) {
|
|
337
|
-
throw new import_n8n_workflow2.NodeOperationError(this.getNode(), response.error ?? "Salla Actions request failed", {
|
|
338
|
-
itemIndex,
|
|
339
|
-
description: response.raw ? JSON.stringify(response.raw, null, 2) : void 0
|
|
340
|
-
});
|
|
341
|
-
}
|
|
342
|
-
returnItems.push({
|
|
343
|
-
json: {
|
|
344
|
-
ok: response.ok,
|
|
345
|
-
status: response.status,
|
|
346
|
-
data: response.data ?? null,
|
|
347
|
-
raw: response.raw ?? null
|
|
348
|
-
}
|
|
349
|
-
});
|
|
350
|
-
}
|
|
351
|
-
return [returnItems];
|
|
352
|
-
}
|
|
353
|
-
};
|
|
354
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
355
|
-
0 && (module.exports = {
|
|
356
|
-
UpdateOrderStatus
|
|
357
|
-
});
|
|
358
|
-
|
|
359
|
-
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { INodeType, INodeTypeDescription, IWebhookFunctions, IWebhookResponseData } from 'n8n-workflow';
|
|
2
|
-
|
|
3
|
-
declare class CustomerCreatedTrigger implements INodeType {
|
|
4
|
-
description: INodeTypeDescription;
|
|
5
|
-
webhook(this: IWebhookFunctions): Promise<IWebhookResponseData>;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export { CustomerCreatedTrigger };
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// nodes/Triggers/CustomerCreatedTrigger.node.ts
|
|
21
|
-
var CustomerCreatedTrigger_node_exports = {};
|
|
22
|
-
__export(CustomerCreatedTrigger_node_exports, {
|
|
23
|
-
CustomerCreatedTrigger: () => CustomerCreatedTrigger
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(CustomerCreatedTrigger_node_exports);
|
|
26
|
-
|
|
27
|
-
// shared/constants.ts
|
|
28
|
-
var SALLA_BRAND_COLOR = "#00C58E";
|
|
29
|
-
|
|
30
|
-
// shared/eventStore.ts
|
|
31
|
-
var TTL_MS = 10 * 60 * 1e3;
|
|
32
|
-
var cache = /* @__PURE__ */ new Map();
|
|
33
|
-
function prune() {
|
|
34
|
-
const now = Date.now();
|
|
35
|
-
for (const [id, expiresAt] of cache.entries()) {
|
|
36
|
-
if (expiresAt <= now) {
|
|
37
|
-
cache.delete(id);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
function isDuplicateEvent(eventId) {
|
|
42
|
-
if (!eventId) {
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
|
-
prune();
|
|
46
|
-
const now = Date.now();
|
|
47
|
-
const expiresAt = cache.get(eventId);
|
|
48
|
-
if (expiresAt && expiresAt > now) {
|
|
49
|
-
return true;
|
|
50
|
-
}
|
|
51
|
-
cache.set(eventId, now + TTL_MS);
|
|
52
|
-
return false;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// nodes/Triggers/CustomerCreatedTrigger.node.ts
|
|
56
|
-
var HEADER_KEYS = [
|
|
57
|
-
{ key: "x-salla-event", canonical: "X-Salla-Event" },
|
|
58
|
-
{ key: "x-salla-event-id", canonical: "X-Salla-Event-Id" },
|
|
59
|
-
{ key: "x-salla-merchant-id", canonical: "X-Salla-Merchant-Id" },
|
|
60
|
-
{ key: "x-forwarded-by", canonical: "X-Forwarded-By" }
|
|
61
|
-
];
|
|
62
|
-
function extractHeaders(raw) {
|
|
63
|
-
const collected = {};
|
|
64
|
-
for (const entry of HEADER_KEYS) {
|
|
65
|
-
const value = raw[entry.key] ?? raw[entry.canonical] ?? raw[entry.key.toLowerCase()];
|
|
66
|
-
if (value !== void 0) {
|
|
67
|
-
collected[entry.canonical] = Array.isArray(value) ? value.join(",") : value;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return collected;
|
|
71
|
-
}
|
|
72
|
-
function preparePayload(body, headers) {
|
|
73
|
-
const payload = body && typeof body === "object" ? { ...body } : { rawBody: body ?? null };
|
|
74
|
-
payload.__sallaHeaders = headers;
|
|
75
|
-
return payload;
|
|
76
|
-
}
|
|
77
|
-
var CustomerCreatedTrigger = class {
|
|
78
|
-
constructor() {
|
|
79
|
-
this.description = {
|
|
80
|
-
displayName: "Customer Created (Salla) [Deprecated]",
|
|
81
|
-
name: "sallaCustomerCreatedTrigger",
|
|
82
|
-
group: ["trigger"],
|
|
83
|
-
version: 1,
|
|
84
|
-
icon: "file:assets/salla-logo.svg",
|
|
85
|
-
description: "Deprecated. Use the “Salla Triggers” node with Trigger On = customer.created.",
|
|
86
|
-
defaults: {
|
|
87
|
-
name: "Customer Created (Salla)",
|
|
88
|
-
color: SALLA_BRAND_COLOR
|
|
89
|
-
},
|
|
90
|
-
inputs: [],
|
|
91
|
-
outputs: ["main"],
|
|
92
|
-
credentials: [],
|
|
93
|
-
webhooks: [
|
|
94
|
-
{
|
|
95
|
-
name: "default",
|
|
96
|
-
httpMethod: "POST",
|
|
97
|
-
responseMode: "onReceived",
|
|
98
|
-
path: "salla/customer-created"
|
|
99
|
-
}
|
|
100
|
-
],
|
|
101
|
-
properties: [
|
|
102
|
-
{
|
|
103
|
-
displayName: "Webhook Secret",
|
|
104
|
-
name: "secret",
|
|
105
|
-
type: "string",
|
|
106
|
-
default: "",
|
|
107
|
-
description: "Optional shared secret reserved for future signature validation."
|
|
108
|
-
}
|
|
109
|
-
]
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
async webhook() {
|
|
113
|
-
const request = this.getRequestObject();
|
|
114
|
-
const rawHeaders = request.headers ?? {};
|
|
115
|
-
const headers = extractHeaders(rawHeaders);
|
|
116
|
-
const eventName = String(headers["X-Salla-Event"] ?? "").toLowerCase();
|
|
117
|
-
if (eventName !== "customer.created") {
|
|
118
|
-
return {
|
|
119
|
-
webhookResponse: {
|
|
120
|
-
message: "Ignored event"
|
|
121
|
-
},
|
|
122
|
-
workflowData: []
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
const eventIdRaw = headers["X-Salla-Event-Id"];
|
|
126
|
-
const eventId = Array.isArray(eventIdRaw) ? eventIdRaw[0] : eventIdRaw;
|
|
127
|
-
if (eventId && isDuplicateEvent(eventId)) {
|
|
128
|
-
return {
|
|
129
|
-
webhookResponse: {
|
|
130
|
-
message: "Duplicate event ignored"
|
|
131
|
-
},
|
|
132
|
-
workflowData: []
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
const payload = preparePayload(request.body, headers);
|
|
136
|
-
const item = {
|
|
137
|
-
json: payload
|
|
138
|
-
};
|
|
139
|
-
return {
|
|
140
|
-
webhookResponse: {
|
|
141
|
-
message: "Event received"
|
|
142
|
-
},
|
|
143
|
-
workflowData: [[item]]
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
148
|
-
0 && (module.exports = {
|
|
149
|
-
CustomerCreatedTrigger
|
|
150
|
-
});
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { INodeType, INodeTypeDescription, IWebhookFunctions, IWebhookResponseData } from 'n8n-workflow';
|
|
2
|
-
|
|
3
|
-
declare class OrderStatusUpdatedTrigger implements INodeType {
|
|
4
|
-
description: INodeTypeDescription;
|
|
5
|
-
webhook(this: IWebhookFunctions): Promise<IWebhookResponseData>;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export { OrderStatusUpdatedTrigger };
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// nodes/Triggers/OrderStatusUpdatedTrigger.node.ts
|
|
21
|
-
var OrderStatusUpdatedTrigger_node_exports = {};
|
|
22
|
-
__export(OrderStatusUpdatedTrigger_node_exports, {
|
|
23
|
-
OrderStatusUpdatedTrigger: () => OrderStatusUpdatedTrigger
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(OrderStatusUpdatedTrigger_node_exports);
|
|
26
|
-
|
|
27
|
-
// shared/constants.ts
|
|
28
|
-
var SALLA_BRAND_COLOR = "#00C58E";
|
|
29
|
-
|
|
30
|
-
// shared/eventStore.ts
|
|
31
|
-
var TTL_MS = 10 * 60 * 1e3;
|
|
32
|
-
var cache = /* @__PURE__ */ new Map();
|
|
33
|
-
function prune() {
|
|
34
|
-
const now = Date.now();
|
|
35
|
-
for (const [id, expiresAt] of cache.entries()) {
|
|
36
|
-
if (expiresAt <= now) {
|
|
37
|
-
cache.delete(id);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
function isDuplicateEvent(eventId) {
|
|
42
|
-
if (!eventId) {
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
|
-
prune();
|
|
46
|
-
const now = Date.now();
|
|
47
|
-
const expiresAt = cache.get(eventId);
|
|
48
|
-
if (expiresAt && expiresAt > now) {
|
|
49
|
-
return true;
|
|
50
|
-
}
|
|
51
|
-
cache.set(eventId, now + TTL_MS);
|
|
52
|
-
return false;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// nodes/Triggers/OrderStatusUpdatedTrigger.node.ts
|
|
56
|
-
var HEADER_KEYS = [
|
|
57
|
-
{ key: "x-salla-event", canonical: "X-Salla-Event" },
|
|
58
|
-
{ key: "x-salla-event-id", canonical: "X-Salla-Event-Id" },
|
|
59
|
-
{ key: "x-salla-merchant-id", canonical: "X-Salla-Merchant-Id" },
|
|
60
|
-
{ key: "x-forwarded-by", canonical: "X-Forwarded-By" }
|
|
61
|
-
];
|
|
62
|
-
function extractHeaders(raw) {
|
|
63
|
-
const collected = {};
|
|
64
|
-
for (const entry of HEADER_KEYS) {
|
|
65
|
-
const value = raw[entry.key] ?? raw[entry.canonical] ?? raw[entry.key.toLowerCase()];
|
|
66
|
-
if (value !== void 0) {
|
|
67
|
-
collected[entry.canonical] = Array.isArray(value) ? value.join(",") : value;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return collected;
|
|
71
|
-
}
|
|
72
|
-
function preparePayload(body, headers) {
|
|
73
|
-
const payload = body && typeof body === "object" ? { ...body } : { rawBody: body ?? null };
|
|
74
|
-
payload.__sallaHeaders = headers;
|
|
75
|
-
return payload;
|
|
76
|
-
}
|
|
77
|
-
var OrderStatusUpdatedTrigger = class {
|
|
78
|
-
constructor() {
|
|
79
|
-
this.description = {
|
|
80
|
-
displayName: "Order Status Updated (Salla) [Deprecated]",
|
|
81
|
-
name: "sallaOrderStatusUpdatedTrigger",
|
|
82
|
-
group: ["trigger"],
|
|
83
|
-
version: 1,
|
|
84
|
-
icon: "file:assets/salla-logo.svg",
|
|
85
|
-
description: "Deprecated. Use the “Salla Triggers” node with Trigger On = order.status.updated.",
|
|
86
|
-
defaults: {
|
|
87
|
-
name: "Order Status Updated (Salla)",
|
|
88
|
-
color: SALLA_BRAND_COLOR
|
|
89
|
-
},
|
|
90
|
-
inputs: [],
|
|
91
|
-
outputs: ["main"],
|
|
92
|
-
credentials: [],
|
|
93
|
-
webhooks: [
|
|
94
|
-
{
|
|
95
|
-
name: "default",
|
|
96
|
-
httpMethod: "POST",
|
|
97
|
-
responseMode: "onReceived",
|
|
98
|
-
path: "salla/order-status-updated"
|
|
99
|
-
}
|
|
100
|
-
],
|
|
101
|
-
properties: [
|
|
102
|
-
{
|
|
103
|
-
displayName: "Webhook Secret",
|
|
104
|
-
name: "secret",
|
|
105
|
-
type: "string",
|
|
106
|
-
default: "",
|
|
107
|
-
description: "Optional shared secret reserved for future signature validation."
|
|
108
|
-
}
|
|
109
|
-
]
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
async webhook() {
|
|
113
|
-
const request = this.getRequestObject();
|
|
114
|
-
const rawHeaders = request.headers ?? {};
|
|
115
|
-
const headers = extractHeaders(rawHeaders);
|
|
116
|
-
const eventName = String(headers["X-Salla-Event"] ?? "").toLowerCase();
|
|
117
|
-
if (eventName !== "order.status.updated") {
|
|
118
|
-
return {
|
|
119
|
-
webhookResponse: {
|
|
120
|
-
message: "Ignored event"
|
|
121
|
-
},
|
|
122
|
-
workflowData: []
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
const eventIdRaw = headers["X-Salla-Event-Id"];
|
|
126
|
-
const eventId = Array.isArray(eventIdRaw) ? eventIdRaw[0] : eventIdRaw;
|
|
127
|
-
if (eventId && isDuplicateEvent(eventId)) {
|
|
128
|
-
return {
|
|
129
|
-
webhookResponse: {
|
|
130
|
-
message: "Duplicate event ignored"
|
|
131
|
-
},
|
|
132
|
-
workflowData: []
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
const payload = preparePayload(request.body, headers);
|
|
136
|
-
const item = {
|
|
137
|
-
json: payload
|
|
138
|
-
};
|
|
139
|
-
return {
|
|
140
|
-
webhookResponse: {
|
|
141
|
-
message: "Event received"
|
|
142
|
-
},
|
|
143
|
-
workflowData: [[item]]
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
148
|
-
0 && (module.exports = {
|
|
149
|
-
OrderStatusUpdatedTrigger
|
|
150
|
-
});
|