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.
Files changed (34) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +37 -0
  3. package/assets/salla-logo.svg +7 -0
  4. package/dist/credentials/SallaActionsApi.credentials.d.ts +19 -0
  5. package/dist/credentials/SallaActionsApi.credentials.js +80 -0
  6. package/dist/data/salla_actions_map.json +9304 -0
  7. package/dist/index.d.ts +5 -0
  8. package/dist/index.js +317 -0
  9. package/dist/nodes/Actions/SallaActions.node.d.ts +14 -0
  10. package/dist/nodes/Actions/SallaActions.node.js +7992 -0
  11. package/dist/nodes/Actions/assets/salla-logo.svg +7 -0
  12. package/dist/nodes/Customers/DeleteCustomer.node.d.ts +8 -0
  13. package/dist/nodes/Customers/DeleteCustomer.node.js +304 -0
  14. package/dist/nodes/Customers/assets/salla-logo.svg +7 -0
  15. package/dist/nodes/Orders/UpdateOrderStatus.node.d.ts +8 -0
  16. package/dist/nodes/Orders/UpdateOrderStatus.node.js +359 -0
  17. package/dist/nodes/Orders/assets/salla-logo.svg +7 -0
  18. package/dist/nodes/Triggers/CustomerCreatedTrigger.node.d.ts +8 -0
  19. package/dist/nodes/Triggers/CustomerCreatedTrigger.node.js +150 -0
  20. package/dist/nodes/Triggers/OrderStatusUpdatedTrigger.node.d.ts +8 -0
  21. package/dist/nodes/Triggers/OrderStatusUpdatedTrigger.node.js +150 -0
  22. package/dist/nodes/Triggers/SallaTrigger.node.d.ts +3 -0
  23. package/dist/nodes/Triggers/SallaTrigger.node.js +30 -0
  24. package/dist/nodes/Triggers/SallaTriggers.node.d.ts +8 -0
  25. package/dist/nodes/Triggers/SallaTriggers.node.js +267 -0
  26. package/dist/nodes/Triggers/assets/salla-logo.svg +7 -0
  27. package/dist/shared/constants.d.ts +5 -0
  28. package/dist/shared/constants.js +36 -0
  29. package/dist/shared/eventStore.d.ts +4 -0
  30. package/dist/shared/eventStore.js +57 -0
  31. package/dist/shared/httpClient.d.ts +33 -0
  32. package/dist/shared/httpClient.js +439 -0
  33. package/dist/shared/sallaActionsMap.js +28 -0
  34. package/package.json +60 -0
@@ -0,0 +1,359 @@
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
+
@@ -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,8 @@
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 };
@@ -0,0 +1,150 @@
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
+ });
@@ -0,0 +1,8 @@
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 };
@@ -0,0 +1,150 @@
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
+ });
@@ -0,0 +1,3 @@
1
+ import type { INodeType } from 'n8n-workflow';
2
+ import { SallaTriggers } from './SallaTriggers.node';
3
+ export declare class SallaTrigger extends SallaTriggers implements INodeType {}