n8n-nodes-n8ndesigner-salla-n8nai 0.3.158
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 -0
- package/README.md +37 -0
- package/assets/salla-logo.svg +7 -0
- package/dist/credentials/SallaActionsApi.credentials.d.ts +19 -0
- package/dist/credentials/SallaActionsApi.credentials.js +80 -0
- package/dist/data/salla_actions_map.json +9304 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +317 -0
- package/dist/nodes/Actions/SallaActions.node.d.ts +14 -0
- package/dist/nodes/Actions/SallaActions.node.js +7992 -0
- package/dist/nodes/Actions/assets/salla-logo.svg +7 -0
- package/dist/nodes/Customers/DeleteCustomer.node.d.ts +8 -0
- package/dist/nodes/Customers/DeleteCustomer.node.js +304 -0
- package/dist/nodes/Customers/assets/salla-logo.svg +7 -0
- package/dist/nodes/Orders/UpdateOrderStatus.node.d.ts +8 -0
- package/dist/nodes/Orders/UpdateOrderStatus.node.js +359 -0
- package/dist/nodes/Orders/assets/salla-logo.svg +7 -0
- package/dist/nodes/Triggers/CustomerCreatedTrigger.node.d.ts +8 -0
- package/dist/nodes/Triggers/CustomerCreatedTrigger.node.js +150 -0
- package/dist/nodes/Triggers/OrderStatusUpdatedTrigger.node.d.ts +8 -0
- package/dist/nodes/Triggers/OrderStatusUpdatedTrigger.node.js +150 -0
- package/dist/nodes/Triggers/SallaTrigger.node.d.ts +3 -0
- package/dist/nodes/Triggers/SallaTrigger.node.js +30 -0
- package/dist/nodes/Triggers/SallaTriggers.node.d.ts +8 -0
- package/dist/nodes/Triggers/SallaTriggers.node.js +267 -0
- package/dist/nodes/Triggers/assets/salla-logo.svg +7 -0
- package/dist/shared/constants.d.ts +5 -0
- package/dist/shared/constants.js +36 -0
- package/dist/shared/eventStore.d.ts +4 -0
- package/dist/shared/eventStore.js +57 -0
- package/dist/shared/httpClient.d.ts +33 -0
- package/dist/shared/httpClient.js +439 -0
- package/dist/shared/sallaActionsMap.js +28 -0
- package/package.json +60 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var import_SallaTriggers = require("./SallaTriggers.node.js");
|
|
3
|
+
class SallaTrigger extends import_SallaTriggers.SallaTriggers {
|
|
4
|
+
constructor() {
|
|
5
|
+
super();
|
|
6
|
+
this.description.displayName = "Salla Trigger";
|
|
7
|
+
this.description.name = "sallaActionsTrigger";
|
|
8
|
+
this.description.hidden = false;
|
|
9
|
+
this.description.defaults = {
|
|
10
|
+
...this.description.defaults,
|
|
11
|
+
name: "Salla Trigger"
|
|
12
|
+
};
|
|
13
|
+
this.description.codex = {
|
|
14
|
+
categories: ["Sales"],
|
|
15
|
+
subcategories: {
|
|
16
|
+
Sales: ["E-commerce"]
|
|
17
|
+
},
|
|
18
|
+
resources: {
|
|
19
|
+
primaryDocumentation: [
|
|
20
|
+
{
|
|
21
|
+
url: "https://github.com/alhabir/n8n-nodes-salla-n8nai"
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
module.exports = {
|
|
29
|
+
SallaTrigger
|
|
30
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { INodeType, INodeTypeDescription, IWebhookFunctions, IWebhookResponseData } from 'n8n-workflow';
|
|
2
|
+
|
|
3
|
+
declare class SallaTriggers implements INodeType {
|
|
4
|
+
description: INodeTypeDescription;
|
|
5
|
+
webhook(this: IWebhookFunctions): Promise<IWebhookResponseData>;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export { SallaTriggers };
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const { SALLA_BRAND_COLOR } = require("../../shared/constants");
|
|
3
|
+
const { isDuplicateEvent } = require("../../shared/eventStore");
|
|
4
|
+
|
|
5
|
+
const HEADER_KEYS = [
|
|
6
|
+
{ key: "x-salla-event", canonical: "X-Salla-Event" },
|
|
7
|
+
{ key: "x-salla-event-id", canonical: "X-Salla-Event-Id" },
|
|
8
|
+
{ key: "x-salla-merchant-id", canonical: "X-Salla-Merchant-Id" },
|
|
9
|
+
{ key: "x-forwarded-by", canonical: "X-Forwarded-By" },
|
|
10
|
+
];
|
|
11
|
+
|
|
12
|
+
const EVENT_GROUPS = {
|
|
13
|
+
"Abandoned Cart": ["abandoned.cart", "abandoned.cart.update"],
|
|
14
|
+
Brands: ["brand.created", "brand.deleted", "brand.updated"],
|
|
15
|
+
Categories: ["category.created", "category.updated"],
|
|
16
|
+
Customers: ["customer.created", "customer.login", "customer.otp.request", "customer.updated"],
|
|
17
|
+
Invoices: ["invoice.created"],
|
|
18
|
+
Orders: [
|
|
19
|
+
"order.cancelled",
|
|
20
|
+
"order.created",
|
|
21
|
+
"order.deleted",
|
|
22
|
+
"order.payment.updated",
|
|
23
|
+
"order.products.updated",
|
|
24
|
+
"order.refunded",
|
|
25
|
+
"order.shipment.creating",
|
|
26
|
+
"order.shipping.address.updated",
|
|
27
|
+
"order.status.updated",
|
|
28
|
+
"order.total.price.updated",
|
|
29
|
+
"order.updated",
|
|
30
|
+
],
|
|
31
|
+
Products: [
|
|
32
|
+
"product.available",
|
|
33
|
+
"product.category.updated",
|
|
34
|
+
"product.channels.changed",
|
|
35
|
+
"product.deleted",
|
|
36
|
+
"product.image.updated",
|
|
37
|
+
"product.option.updated",
|
|
38
|
+
"product.price.updated",
|
|
39
|
+
"product.status.updated",
|
|
40
|
+
"product.tags.updated",
|
|
41
|
+
"product.updated",
|
|
42
|
+
"product.variant.updated",
|
|
43
|
+
],
|
|
44
|
+
Shipments: ["shipment.creating"],
|
|
45
|
+
Shipping: [
|
|
46
|
+
"shipping.company.created",
|
|
47
|
+
"shipping.company.deleted",
|
|
48
|
+
"shipping.company.updated",
|
|
49
|
+
"shipping.zone.created",
|
|
50
|
+
"storetax.created",
|
|
51
|
+
],
|
|
52
|
+
Offers: ["specialoffer.created", "specialoffer.updated"],
|
|
53
|
+
"Store Branch": [
|
|
54
|
+
"store.branch.activated",
|
|
55
|
+
"store.branch.created",
|
|
56
|
+
"store.branch.deleted",
|
|
57
|
+
"store.branch.updated",
|
|
58
|
+
],
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const EVENT_OPTIONS = Object.entries(EVENT_GROUPS).flatMap(([category, events]) =>
|
|
62
|
+
events.map((event) => ({
|
|
63
|
+
name: `${category} — ${event}`,
|
|
64
|
+
value: event,
|
|
65
|
+
})),
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
function extractHeaders(rawHeaders) {
|
|
69
|
+
const collected = {};
|
|
70
|
+
if (!rawHeaders) {
|
|
71
|
+
return collected;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
for (const entry of HEADER_KEYS) {
|
|
75
|
+
const value =
|
|
76
|
+
rawHeaders[entry.key] ??
|
|
77
|
+
rawHeaders[entry.canonical] ??
|
|
78
|
+
rawHeaders[entry.key.toLowerCase()];
|
|
79
|
+
if (value !== undefined) {
|
|
80
|
+
collected[entry.canonical] = Array.isArray(value) ? value.join(",") : value;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return collected;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function normalizeEventName(value) {
|
|
87
|
+
return typeof value === "string" && value.trim() !== ""
|
|
88
|
+
? value.trim().toLowerCase()
|
|
89
|
+
: "";
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function slugify(value) {
|
|
93
|
+
return normalizeEventName(value).replace(/[^a-z0-9._-]/g, "-");
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function slugifyPathSegments(path) {
|
|
97
|
+
return path
|
|
98
|
+
.split("/")
|
|
99
|
+
.map((segment) => slugify(segment))
|
|
100
|
+
.filter((segment) => segment !== "")
|
|
101
|
+
.join("/");
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function resolveEventId(headers) {
|
|
105
|
+
const raw = headers["X-Salla-Event-Id"];
|
|
106
|
+
if (Array.isArray(raw)) {
|
|
107
|
+
return raw[0];
|
|
108
|
+
}
|
|
109
|
+
return raw ?? null;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function resolveMerchant(headers, body) {
|
|
113
|
+
const headerValue = headers["X-Salla-Merchant-Id"];
|
|
114
|
+
if (Array.isArray(headerValue)) {
|
|
115
|
+
return headerValue[0];
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (typeof headerValue === "string" && headerValue !== "") {
|
|
119
|
+
return headerValue;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (body && typeof body === "object") {
|
|
123
|
+
if (body.merchant) {
|
|
124
|
+
return body.merchant;
|
|
125
|
+
}
|
|
126
|
+
const storeId = body.data?.store?.id;
|
|
127
|
+
if (storeId) {
|
|
128
|
+
return storeId;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function stringifyData(body) {
|
|
136
|
+
if (body === undefined) {
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (body && typeof body === "object") {
|
|
141
|
+
try {
|
|
142
|
+
return JSON.parse(JSON.stringify(body));
|
|
143
|
+
} catch {
|
|
144
|
+
return body;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return body;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
class SallaTriggers {
|
|
152
|
+
constructor() {
|
|
153
|
+
this.description = {
|
|
154
|
+
displayName: "Salla Triggers (Legacy)",
|
|
155
|
+
name: "sallaTriggers",
|
|
156
|
+
group: ["trigger"],
|
|
157
|
+
version: 1,
|
|
158
|
+
icon: "file:assets/salla-logo.svg",
|
|
159
|
+
description: "Receive Salla webhook events forwarded by N8NProxy.",
|
|
160
|
+
subtitle: '={{$parameter["eventName"]}}',
|
|
161
|
+
defaults: {
|
|
162
|
+
name: "Salla Triggers (Legacy)",
|
|
163
|
+
color: SALLA_BRAND_COLOR,
|
|
164
|
+
},
|
|
165
|
+
hidden: true,
|
|
166
|
+
inputs: [],
|
|
167
|
+
outputs: ["main"],
|
|
168
|
+
credentials: [],
|
|
169
|
+
webhooks: [
|
|
170
|
+
{
|
|
171
|
+
name: "default",
|
|
172
|
+
httpMethod: "POST",
|
|
173
|
+
responseMode: "onReceived",
|
|
174
|
+
path: "salla",
|
|
175
|
+
},
|
|
176
|
+
],
|
|
177
|
+
properties: [
|
|
178
|
+
{
|
|
179
|
+
displayName: "Trigger On",
|
|
180
|
+
name: "eventName",
|
|
181
|
+
type: "options",
|
|
182
|
+
options: EVENT_OPTIONS,
|
|
183
|
+
default: "order.created",
|
|
184
|
+
required: true,
|
|
185
|
+
description:
|
|
186
|
+
"Select which Salla event should trigger this workflow.",
|
|
187
|
+
},
|
|
188
|
+
],
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
this.webhookMethods = {
|
|
192
|
+
default: {
|
|
193
|
+
getWebhookPath() {
|
|
194
|
+
const eventName = this.getNodeParameter("eventName");
|
|
195
|
+
return `salla/${slugify(eventName)}`;
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
async webhook() {
|
|
202
|
+
const request = this.getRequestObject();
|
|
203
|
+
const rawHeaders = request.headers ?? {};
|
|
204
|
+
const headers = extractHeaders(rawHeaders);
|
|
205
|
+
const selectedEvent = normalizeEventName(this.getNodeParameter("eventName"));
|
|
206
|
+
const incomingEvent =
|
|
207
|
+
normalizeEventName(headers["X-Salla-Event"]) ||
|
|
208
|
+
normalizeEventName(request.body?.event);
|
|
209
|
+
|
|
210
|
+
if (!incomingEvent) {
|
|
211
|
+
return {
|
|
212
|
+
webhookResponse: {
|
|
213
|
+
ok: false,
|
|
214
|
+
error: "missing_event",
|
|
215
|
+
},
|
|
216
|
+
workflowData: [],
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if (incomingEvent !== selectedEvent) {
|
|
221
|
+
return {
|
|
222
|
+
webhookResponse: {
|
|
223
|
+
ok: true,
|
|
224
|
+
ignored: true,
|
|
225
|
+
},
|
|
226
|
+
workflowData: [],
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
const eventId = resolveEventId(headers);
|
|
231
|
+
if (eventId && isDuplicateEvent(eventId)) {
|
|
232
|
+
return {
|
|
233
|
+
webhookResponse: {
|
|
234
|
+
ok: true,
|
|
235
|
+
duplicate: true,
|
|
236
|
+
},
|
|
237
|
+
workflowData: [],
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
const body = request.body ?? null;
|
|
242
|
+
const payload = {
|
|
243
|
+
ok: true,
|
|
244
|
+
event: incomingEvent,
|
|
245
|
+
merchant: resolveMerchant(headers, body),
|
|
246
|
+
created_at: new Date().toISOString(),
|
|
247
|
+
data: body && typeof body === "object" && Object.prototype.hasOwnProperty.call(body, "data")
|
|
248
|
+
? stringifyData(body.data)
|
|
249
|
+
: stringifyData(body),
|
|
250
|
+
raw: {
|
|
251
|
+
headers,
|
|
252
|
+
body: stringifyData(body),
|
|
253
|
+
query: stringifyData(request.query ?? null),
|
|
254
|
+
},
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
return {
|
|
258
|
+
webhookResponse: {
|
|
259
|
+
ok: true,
|
|
260
|
+
received: true,
|
|
261
|
+
},
|
|
262
|
+
workflowData: [[{ json: payload }]],
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
module.exports = { SallaTriggers };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="60" height="60">
|
|
3
|
+
<path d="M0 0 C19.8 0 39.6 0 60 0 C60 19.8 60 39.6 60 60 C40.2 60 20.4 60 0 60 C0 40.2 0 20.4 0 0 Z " fill="#F7F9F9" transform="translate(0,0)"/>
|
|
4
|
+
<path d="M0 0 C19.8 0 39.6 0 60 0 C60 19.8 60 39.6 60 60 C40.2 60 20.4 60 0 60 C0 40.2 0 20.4 0 0 Z M5.19921875 12.25390625 C3.66791981 15.76043117 3.18095818 19.16739851 2.8125 22.9375 C2.73499512 23.68169189 2.65749023 24.42588379 2.57763672 25.19262695 C0.72052858 37.88413585 0.72052858 37.88413585 3.75 49.75 C8.29760854 54.29760854 12.43722773 54.31880575 18.67578125 54.3359375 C19.94085762 54.3459227 19.94085762 54.3459227 21.23149109 54.35610962 C23.01424992 54.36622225 24.7970465 54.37092707 26.57983398 54.37060547 C29.29279831 54.37496832 32.00412133 54.41127234 34.71679688 54.44921875 C36.45311947 54.45508948 38.18944975 54.45905716 39.92578125 54.4609375 C40.73018143 54.47530853 41.5345816 54.48967957 42.36335754 54.50448608 C48.02701569 54.45907127 51.38770916 53.35030915 56 50 C58.27309322 46.96211691 58.20594951 44.39689614 58.046875 40.67578125 C58.00433594 39.64646484 57.96179687 38.61714844 57.91796875 37.55664062 C57.86253906 36.48607422 57.80710938 35.41550781 57.75 34.3125 C57.69005859 32.7356543 57.69005859 32.7356543 57.62890625 31.12695312 C57.28476265 18.44905311 57.28476265 18.44905311 51 8 C45.02188736 4.94531301 38.39660875 5.62798691 31.85327148 5.62939453 C29.57264616 5.62501946 27.29395559 5.5886589 25.01367188 5.55078125 C23.5520899 5.54491237 22.0904988 5.54094345 20.62890625 5.5390625 C19.30963135 5.53084473 17.99035645 5.52262695 16.63110352 5.51416016 C11.5459631 6.19454941 8.38265208 8.26943547 5.19921875 12.25390625 Z " fill="#F8FAFA" transform="translate(0,0)"/>
|
|
5
|
+
<path d="M0 0 C0.7111647 -0.00287018 1.42232941 -0.00574036 2.15504456 -0.00869751 C3.65358276 -0.01073157 5.15214792 -0.00524779 6.65063477 0.00732422 C8.93111251 0.02336509 11.20981188 0.0074672 13.49023438 -0.01171875 C14.95182679 -0.00973573 16.41341811 -0.00589085 17.875 0 C19.85391235 0.00507568 19.85391235 0.00507568 21.87280273 0.01025391 C27.02001927 0.56051776 30.28688423 2.08620628 33.80078125 5.875 C36.1768804 10.79069135 36.42330613 15.37363551 36.75390625 20.7734375 C36.83125 21.77632812 36.90859375 22.77921875 36.98828125 23.8125 C38.25013816 41.0278336 38.25013816 41.0278336 34.50390625 45.3984375 C29.46419289 48.56651818 25.36131438 48.85309472 19.59765625 48.83203125 C18.75473022 48.8372731 17.9118042 48.84251495 17.04333496 48.84791565 C15.26832171 48.85431426 13.49326594 48.85302695 11.71826172 48.84448242 C9.01192408 48.83596274 6.30769252 48.86477767 3.6015625 48.89648438 C1.87109438 48.89809645 0.14062254 48.89751873 -1.58984375 48.89453125 C-2.3931311 48.90576523 -3.19641846 48.91699921 -4.02404785 48.92857361 C-9.30418782 48.86348375 -12.289659 47.86805566 -16.49609375 44.3984375 C-21.3486439 37.74709721 -18.53928151 25.26421612 -17.74609375 17.3984375 C-17.65376465 16.34039917 -17.65376465 16.34039917 -17.55957031 15.26098633 C-16.99558708 10.34836472 -15.65074794 7.19284673 -12.49609375 3.3984375 C-8.34160684 0.25442571 -5.1469839 0.01321272 0 0 Z M-8.89746094 8.20117188 C-11.20461843 11.37228022 -11.42615646 14.60028293 -11.74609375 18.3984375 C-11.81981201 19.15012207 -11.89353027 19.90180664 -11.96948242 20.67626953 C-13.64550707 31.20503024 -13.64550707 31.20503024 -11.48876953 41.01855469 C-8.33657754 43.20137619 -4.95082506 42.82563993 -1.25 42.796875 C-0.44247787 42.79974518 0.36504425 42.80261536 1.19703674 42.80557251 C2.9042328 42.80761314 4.61145224 42.80208328 6.31860352 42.78955078 C8.92843118 42.77351721 11.53670536 42.7893879 14.14648438 42.80859375 C15.805993 42.80661091 17.46550065 42.80276638 19.125 42.796875 C19.90427353 42.80294769 20.68354706 42.80902039 21.48643494 42.8152771 C24.75633902 42.77296385 27.10926658 42.61670772 29.9987793 41.01855469 C32.71445441 38.09540464 31.90070638 34.86785451 31.76171875 31.078125 C31.67664062 29.86382812 31.5915625 28.64953125 31.50390625 27.3984375 C31.45459961 26.6859082 31.40529297 25.97337891 31.35449219 25.23925781 C31.18259658 22.95550188 30.97525617 20.67790186 30.75390625 18.3984375 C30.69251465 17.66866699 30.63112305 16.93889648 30.56787109 16.18701172 C30.21468237 13.04048779 29.78396565 10.78336947 27.90527344 8.20117188 C24.60710244 5.72519641 22.35148245 5.88147188 18.25390625 5.8671875 C17.21121582 5.86144714 17.21121582 5.86144714 16.14746094 5.85559082 C14.68162584 5.8528757 13.21574197 5.86020915 11.75 5.87695312 C9.5106165 5.89837331 7.27444038 5.87714307 5.03515625 5.8515625 C3.60806586 5.85420585 2.18097746 5.859331 0.75390625 5.8671875 C-1.18742187 5.87395508 -1.18742187 5.87395508 -3.16796875 5.88085938 C-6.54167462 6.13832468 -6.54167462 6.13832468 -8.89746094 8.20117188 Z " fill="#0E525F" transform="translate(20.49609375,5.6015625)"/>
|
|
6
|
+
<path d="M0 0 C3.254796 -0.28718788 4.83672129 -0.08906111 7.75 1.5 C12.40623983 3.64903377 17.04658098 4.02573834 21.95703125 2.3203125 C23.63967317 1.55047633 25.31992388 0.77541975 27 0 C29.9375 -0.1875 29.9375 -0.1875 32 0 C32 1.65 32 3.3 32 5 C30.730447 5.64834654 29.45930294 6.29357815 28.1875 6.9375 C27.47980469 7.29714844 26.77210937 7.65679687 26.04296875 8.02734375 C20.27160233 10.77508799 14.2584407 10.98469362 8.15625 9.140625 C1.50178571 6.50178571 1.50178571 6.50178571 0 5 C-0.04063832 3.33382885 -0.042721 1.66611905 0 0 Z " fill="#0E535F" transform="translate(14,32)"/>
|
|
7
|
+
</svg>
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
// shared/constants.ts
|
|
21
|
+
var constants_exports = {};
|
|
22
|
+
__export(constants_exports, {
|
|
23
|
+
DEFAULT_BASE_URL: () => DEFAULT_BASE_URL,
|
|
24
|
+
SALLA_BRAND_COLOR: () => SALLA_BRAND_COLOR,
|
|
25
|
+
SALLA_CREDENTIAL_NAME: () => SALLA_CREDENTIAL_NAME
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(constants_exports);
|
|
28
|
+
var SALLA_CREDENTIAL_NAME = "sallaActionsApi";
|
|
29
|
+
var DEFAULT_BASE_URL = "https://app.n8ndesigner.com";
|
|
30
|
+
var SALLA_BRAND_COLOR = "#00C58E";
|
|
31
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
32
|
+
0 && (module.exports = {
|
|
33
|
+
DEFAULT_BASE_URL,
|
|
34
|
+
SALLA_BRAND_COLOR,
|
|
35
|
+
SALLA_CREDENTIAL_NAME
|
|
36
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
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
|
+
// shared/eventStore.ts
|
|
21
|
+
var eventStore_exports = {};
|
|
22
|
+
__export(eventStore_exports, {
|
|
23
|
+
clearEventCache: () => clearEventCache,
|
|
24
|
+
isDuplicateEvent: () => isDuplicateEvent
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(eventStore_exports);
|
|
27
|
+
var TTL_MS = 10 * 60 * 1e3;
|
|
28
|
+
var cache = /* @__PURE__ */ new Map();
|
|
29
|
+
function prune() {
|
|
30
|
+
const now = Date.now();
|
|
31
|
+
for (const [id, expiresAt] of cache.entries()) {
|
|
32
|
+
if (expiresAt <= now) {
|
|
33
|
+
cache.delete(id);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function isDuplicateEvent(eventId) {
|
|
38
|
+
if (!eventId) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
prune();
|
|
42
|
+
const now = Date.now();
|
|
43
|
+
const expiresAt = cache.get(eventId);
|
|
44
|
+
if (expiresAt && expiresAt > now) {
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
cache.set(eventId, now + TTL_MS);
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
function clearEventCache() {
|
|
51
|
+
cache.clear();
|
|
52
|
+
}
|
|
53
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
54
|
+
0 && (module.exports = {
|
|
55
|
+
clearEventCache,
|
|
56
|
+
isDuplicateEvent
|
|
57
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { IHttpRequestOptions, IDataObject, IExecuteFunctions, IHookFunctions, IWebhookFunctions } from 'n8n-workflow';
|
|
2
|
+
|
|
3
|
+
interface SallaActionsCredentials {
|
|
4
|
+
baseUrl: string;
|
|
5
|
+
salla_merchant_id: string;
|
|
6
|
+
makKey: string;
|
|
7
|
+
}
|
|
8
|
+
interface SallaActionsRequestOptions {
|
|
9
|
+
method: Required<IHttpRequestOptions>['method'];
|
|
10
|
+
path: string;
|
|
11
|
+
body?: IDataObject | undefined;
|
|
12
|
+
qs?: IDataObject | undefined;
|
|
13
|
+
headers?: IDataObject | undefined;
|
|
14
|
+
}
|
|
15
|
+
interface SallaProxyRequestOptions {
|
|
16
|
+
method: string;
|
|
17
|
+
path: string;
|
|
18
|
+
payload?: IDataObject | undefined;
|
|
19
|
+
}
|
|
20
|
+
interface SallaActionsResponse<T = unknown> {
|
|
21
|
+
ok: boolean;
|
|
22
|
+
status: number;
|
|
23
|
+
data: T | null;
|
|
24
|
+
error: string | null;
|
|
25
|
+
raw: unknown;
|
|
26
|
+
}
|
|
27
|
+
type SallaRequestContext = IExecuteFunctions | IHookFunctions | IWebhookFunctions;
|
|
28
|
+
declare function createSallaActionsClient(context: SallaRequestContext, credentials: SallaActionsCredentials, credentialType?: string): {
|
|
29
|
+
request: (options: SallaActionsRequestOptions) => Promise<SallaActionsResponse>;
|
|
30
|
+
proxy: (options: SallaProxyRequestOptions) => Promise<SallaActionsResponse>;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export { type SallaActionsCredentials, type SallaActionsRequestOptions, type SallaActionsResponse, type SallaProxyRequestOptions, createSallaActionsClient };
|