n8n-nodes-supermachine 0.1.0

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 (30) hide show
  1. package/credentials/SupermachineApi.credentials.ts +41 -0
  2. package/dist/credentials/SupermachineApi.credentials.js +38 -0
  3. package/dist/credentials/SupermachineApi.credentials.js.map +1 -0
  4. package/dist/nodes/Supermachine/Supermachine.node.js +428 -0
  5. package/dist/nodes/Supermachine/Supermachine.node.js.map +1 -0
  6. package/dist/nodes/Supermachine/SupermachineTrigger.node.js +157 -0
  7. package/dist/nodes/Supermachine/SupermachineTrigger.node.js.map +1 -0
  8. package/dist/nodes/Supermachine/descriptions/AccountDescription.js +73 -0
  9. package/dist/nodes/Supermachine/descriptions/AccountDescription.js.map +1 -0
  10. package/dist/nodes/Supermachine/descriptions/ImageDescription.js +355 -0
  11. package/dist/nodes/Supermachine/descriptions/ImageDescription.js.map +1 -0
  12. package/dist/nodes/Supermachine/descriptions/ToolsDescription.js +241 -0
  13. package/dist/nodes/Supermachine/descriptions/ToolsDescription.js.map +1 -0
  14. package/dist/nodes/Supermachine/descriptions/index.js +21 -0
  15. package/dist/nodes/Supermachine/descriptions/index.js.map +1 -0
  16. package/dist/nodes/Supermachine/index.js +5 -0
  17. package/dist/nodes/Supermachine/index.js.map +1 -0
  18. package/dist/nodes/Supermachine/supermachine.svg +132 -0
  19. package/gulpfile.js +58 -0
  20. package/index.ts +5 -0
  21. package/nodes/Supermachine/Supermachine.node.ts +508 -0
  22. package/nodes/Supermachine/SupermachineTrigger.node.ts +175 -0
  23. package/nodes/Supermachine/descriptions/AccountDescription.ts +72 -0
  24. package/nodes/Supermachine/descriptions/ImageDescription.ts +355 -0
  25. package/nodes/Supermachine/descriptions/ToolsDescription.ts +241 -0
  26. package/nodes/Supermachine/descriptions/index.ts +3 -0
  27. package/nodes/Supermachine/index.ts +3 -0
  28. package/nodes/Supermachine/supermachine.svg +132 -0
  29. package/package.json +47 -0
  30. package/tsconfig.json +15 -0
@@ -0,0 +1,72 @@
1
+ // File 4: nodes/Supermachine/descriptions/AccountDescription.ts
2
+ import type { INodeProperties } from 'n8n-workflow';
3
+
4
+ export const getAccountOperations: INodeProperties[] = [
5
+ {
6
+ displayName: 'Operation',
7
+ name: 'operation',
8
+ type: 'options',
9
+ noDataExpression: true,
10
+ displayOptions: {
11
+ show: {
12
+ resource: ['account'],
13
+ },
14
+ },
15
+ options: [
16
+ {
17
+ name: 'Get Profile',
18
+ value: 'getProfile',
19
+ description: 'Lấy thông tin tài khoản và credit còn lại',
20
+ action: 'Get account profile',
21
+ },
22
+ {
23
+ name: 'List Models',
24
+ value: 'listModels',
25
+ description: 'Liệt kê tất cả models có sẵn',
26
+ action: 'List available models',
27
+ },
28
+ {
29
+ name: 'Get Model Categories',
30
+ value: 'listModelCategories',
31
+ description: 'Lấy danh mục models',
32
+ action: 'List model categories',
33
+ },
34
+ ],
35
+ default: 'getProfile',
36
+ },
37
+ ];
38
+
39
+ export const getAccountFields: INodeProperties[] = [
40
+ // Get Profile - không cần fields
41
+ {
42
+ displayName: 'Return All',
43
+ name: 'returnAll',
44
+ type: 'boolean',
45
+ displayOptions: {
46
+ show: {
47
+ resource: ['account'],
48
+ operation: ['listModels', 'listModelCategories'],
49
+ },
50
+ },
51
+ default: false,
52
+ description: 'Trả về tất cả kết quả hay chỉ giới hạn',
53
+ },
54
+ {
55
+ displayName: 'Limit',
56
+ name: 'limit',
57
+ type: 'number',
58
+ typeOptions: {
59
+ minValue: 1,
60
+ maxValue: 100,
61
+ },
62
+ displayOptions: {
63
+ show: {
64
+ resource: ['account'],
65
+ operation: ['listModels', 'listModelCategories'],
66
+ returnAll: [false],
67
+ },
68
+ },
69
+ default: 20,
70
+ description: 'Số lượng items trả về mỗi trang',
71
+ },
72
+ ];
@@ -0,0 +1,355 @@
1
+ import { INodeProperties } from 'n8n-workflow';
2
+
3
+ export const getImageOperations: INodeProperties[] = [
4
+ {
5
+ displayName: 'Operation',
6
+ name: 'operation',
7
+ type: 'options',
8
+ noDataExpression: true,
9
+ displayOptions: {
10
+ show: {
11
+ resource: ['image'],
12
+ },
13
+ },
14
+ options: [
15
+ {
16
+ name: 'Generate an Image',
17
+ value: 'generate',
18
+ description: 'Tạo ảnh mới từ text prompt',
19
+ action: 'Generate an image',
20
+ },
21
+ {
22
+ name: 'Get Image Job Status',
23
+ value: 'getStatus',
24
+ description: 'Lấy status và kết quả job theo batchId',
25
+ action: 'Get image job status',
26
+ },
27
+ {
28
+ name: 'List Generated Images',
29
+ value: 'listImages',
30
+ description: 'Liệt kê tất cả ảnh theo batchId',
31
+ action: 'List generated images',
32
+ },
33
+ ],
34
+ default: 'generate',
35
+ },
36
+ ];
37
+
38
+ export const getImageFields: INodeProperties[] = [
39
+ // ═══════════════════════════════════════════════════════════
40
+ // GENERATE OPERATION
41
+ // ═══════════════════════════════════════════════════════════
42
+ {
43
+ displayName: 'Model Name or ID',
44
+ name: 'model',
45
+ type: 'options',
46
+ typeOptions: {
47
+ loadOptionsMethod: 'getModels',
48
+ },
49
+ displayOptions: {
50
+ show: {
51
+ resource: ['image'],
52
+ operation: ['generate'],
53
+ },
54
+ },
55
+ default: '',
56
+ description:
57
+ 'Model AI dùng để generate ảnh. Chọn từ danh sách. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
58
+ required: true,
59
+ },
60
+ {
61
+ displayName: 'Prompt',
62
+ name: 'prompt',
63
+ type: 'string',
64
+ typeOptions: {
65
+ rows: 4,
66
+ },
67
+ displayOptions: {
68
+ show: {
69
+ resource: ['image'],
70
+ operation: ['generate'],
71
+ },
72
+ },
73
+ default: '',
74
+ placeholder: 'A beautiful sunset over mountains, photorealistic, 8k',
75
+ description: 'Mô tả ảnh muốn tạo (bằng tiếng Anh cho kết quả tốt nhất)',
76
+ required: true,
77
+ },
78
+ {
79
+ displayName: 'Width',
80
+ name: 'width',
81
+ type: 'number',
82
+ typeOptions: {
83
+ minValue: 256,
84
+ maxValue: 2048,
85
+ },
86
+ displayOptions: {
87
+ show: {
88
+ resource: ['image'],
89
+ operation: ['generate'],
90
+ },
91
+ },
92
+ default: 1024,
93
+ description: 'Chiều rộng ảnh tính bằng pixels (256-2048)',
94
+ },
95
+ {
96
+ displayName: 'Height',
97
+ name: 'height',
98
+ type: 'number',
99
+ typeOptions: {
100
+ minValue: 256,
101
+ maxValue: 2048,
102
+ },
103
+ displayOptions: {
104
+ show: {
105
+ resource: ['image'],
106
+ operation: ['generate'],
107
+ },
108
+ },
109
+ default: 768,
110
+ description: 'Chiều cao ảnh tính bằng pixels (256-2048)',
111
+ },
112
+ {
113
+ displayName: 'Additional Fields',
114
+ name: 'additionalFields',
115
+ type: 'collection',
116
+ placeholder: 'Add Field',
117
+ default: {},
118
+ displayOptions: {
119
+ show: {
120
+ resource: ['image'],
121
+ operation: ['generate'],
122
+ },
123
+ },
124
+ options: [
125
+ {
126
+ displayName: 'Negative Prompt',
127
+ name: 'negativePrompt',
128
+ type: 'string',
129
+ typeOptions: { rows: 2 },
130
+ default: '',
131
+ placeholder: 'blurry, low quality, distorted',
132
+ description: 'Những gì KHÔNG muốn xuất hiện trong ảnh',
133
+ },
134
+ {
135
+ displayName: 'Number of Results',
136
+ name: 'numberResults',
137
+ type: 'number',
138
+ typeOptions: { minValue: 1, maxValue: 4 },
139
+ default: 1,
140
+ description: 'Số ảnh tạo cùng lúc (1-4). Mỗi ảnh tốn 1 credit.',
141
+ },
142
+ {
143
+ displayName: 'Output Format',
144
+ name: 'outputFormat',
145
+ type: 'options',
146
+ options: [
147
+ { name: 'PNG', value: 'PNG' },
148
+ { name: 'WEBP', value: 'WEBP' },
149
+ { name: 'JPEG', value: 'JPEG' },
150
+ ],
151
+ default: 'PNG',
152
+ description: 'Định dạng file ảnh đầu ra',
153
+ },
154
+ {
155
+ displayName: 'Seed',
156
+ name: 'seed',
157
+ type: 'number',
158
+ typeOptions: { minValue: 0, maxValue: 2147483647 },
159
+ default: 0,
160
+ description: 'Seed cố định để tái tạo kết quả giống nhau (0 = random)',
161
+ },
162
+ {
163
+ displayName: 'Steps',
164
+ name: 'steps',
165
+ type: 'number',
166
+ typeOptions: { minValue: 1, maxValue: 80 },
167
+ default: 30,
168
+ description: 'Số bước inference. Nhiều hơn = chất lượng cao hơn nhưng chậm hơn (20-50 recommended).',
169
+ },
170
+ {
171
+ displayName: 'CFG Scale',
172
+ name: 'cfgScale',
173
+ type: 'number',
174
+ typeOptions: {
175
+ minValue: 1,
176
+ maxValue: 20,
177
+ numberPrecision: 1,
178
+ },
179
+ default: 7,
180
+ description: 'Độ tuân thủ prompt. Cao hơn = tuân thủ strict hơn (7-9 recommended).',
181
+ },
182
+ {
183
+ displayName: 'LoRAs',
184
+ name: 'loras',
185
+ type: 'fixedCollection',
186
+ typeOptions: {
187
+ multipleValues: true,
188
+ },
189
+ default: {},
190
+ description: 'Thêm LoRA để điều chỉnh style. ⚠️ Phải chọn Model trước!',
191
+ options: [
192
+ {
193
+ name: 'loraValues',
194
+ displayName: 'LoRA',
195
+ values: [
196
+ {
197
+ displayName: 'LoRA Name or ID',
198
+ name: 'loraId',
199
+ type: 'options',
200
+ typeOptions: {
201
+ loadOptionsMethod: 'getLoras',
202
+ loadOptionsDependsOn: ['model'],
203
+ },
204
+ default: '',
205
+ description: 'Chọn LoRA. Dropdown sẽ load sau khi chọn Model. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
206
+ },
207
+ {
208
+ displayName: 'Strength',
209
+ name: 'strength',
210
+ type: 'number',
211
+ typeOptions: {
212
+ minValue: 0,
213
+ maxValue: 2,
214
+ numberPrecision: 1,
215
+ },
216
+ default: 1,
217
+ description: 'Độ mạnh của LoRA (0-2). Default: 1.0',
218
+ },
219
+ ],
220
+ },
221
+ ],
222
+ },
223
+ {
224
+ displayName: 'Character Category',
225
+ name: 'characterCategory',
226
+ type: 'options',
227
+ typeOptions: {
228
+ loadOptionsMethod: 'getCharacterCategories',
229
+ },
230
+ default: '',
231
+ description: 'Chọn category để filter characters (Female, Male, Young Adult, Middle Aged). Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
232
+ },
233
+ {
234
+ displayName: 'Character',
235
+ name: 'characterId',
236
+ type: 'options',
237
+ typeOptions: {
238
+ loadOptionsMethod: 'getCharacters',
239
+ loadOptionsDependsOn: ['model', 'characterCategory'],
240
+ },
241
+ displayOptions: {
242
+ show: {
243
+ characterCategory: ['3', '4', '5', '6'],
244
+ },
245
+ },
246
+ default: '',
247
+ description: 'Chọn character. ⚠️ Phải chọn Model và Category trước! Embed code sẽ hiện trong description. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
248
+ },
249
+ {
250
+ displayName: 'Image to Image',
251
+ name: 'img2img',
252
+ type: 'fixedCollection',
253
+ default: {},
254
+ description: 'Dùng ảnh có sẵn làm base để generate',
255
+ options: [
256
+ {
257
+ name: 'img2imgValues',
258
+ displayName: 'Image to Image Settings',
259
+ values: [
260
+ {
261
+ displayName: 'Source Image URL',
262
+ name: 'sourceImageUrl',
263
+ type: 'string',
264
+ default: '',
265
+ placeholder: 'https://example.com/image.png',
266
+ description: 'URL của ảnh gốc dùng làm base',
267
+ },
268
+ {
269
+ displayName: 'Denoising Strength',
270
+ name: 'denoisingStrength',
271
+ type: 'number',
272
+ typeOptions: {
273
+ minValue: 0,
274
+ maxValue: 1,
275
+ numberPrecision: 2,
276
+ },
277
+ default: 0.75,
278
+ description: 'Mức độ thay đổi so với ảnh gốc (0=giữ nguyên, 1=thay đổi hoàn toàn)',
279
+ },
280
+ ],
281
+ },
282
+ ],
283
+ },
284
+ {
285
+ displayName: 'Callback URL',
286
+ name: 'callbackUrl',
287
+ type: 'string',
288
+ default: '',
289
+ placeholder: 'https://your-n8n.com/webhook/supermachine-callback',
290
+ description: 'Webhook URL để nhận kết quả async. Copy URL từ Supermachine Trigger node.',
291
+ },
292
+ ],
293
+ },
294
+
295
+ // ═══════════════════════════════════════════════════════════
296
+ // GET STATUS & LIST IMAGES OPERATIONS
297
+ // ═══════════════════════════════════════════════════════════
298
+ {
299
+ displayName: 'Batch ID',
300
+ name: 'batchId',
301
+ type: 'string',
302
+ displayOptions: {
303
+ show: {
304
+ resource: ['image'],
305
+ operation: ['getStatus', 'listImages'],
306
+ },
307
+ },
308
+ default: '',
309
+ placeholder: '1994761',
310
+ description: 'batchId nhận được từ Generate operation response',
311
+ required: true,
312
+ },
313
+ {
314
+ displayName: 'Return All',
315
+ name: 'returnAll',
316
+ type: 'boolean',
317
+ displayOptions: {
318
+ show: {
319
+ resource: ['image'],
320
+ operation: ['listImages'],
321
+ },
322
+ },
323
+ default: false,
324
+ description: 'Whether to return all results or only up to a given limit',
325
+ },
326
+ {
327
+ displayName: 'Limit',
328
+ name: 'limit',
329
+ type: 'number',
330
+ typeOptions: { minValue: 1, maxValue: 100 },
331
+ displayOptions: {
332
+ show: {
333
+ resource: ['image'],
334
+ operation: ['listImages'],
335
+ returnAll: [false],
336
+ },
337
+ },
338
+ default: 20,
339
+ description: 'Max number of results to return',
340
+ },
341
+ {
342
+ displayName: 'Page',
343
+ name: 'page',
344
+ type: 'number',
345
+ typeOptions: { minValue: 1 },
346
+ displayOptions: {
347
+ show: {
348
+ resource: ['image'],
349
+ operation: ['listImages'],
350
+ },
351
+ },
352
+ default: 1,
353
+ description: 'Số trang để fetch (bắt đầu từ 1)',
354
+ },
355
+ ];
@@ -0,0 +1,241 @@
1
+ import { INodeProperties } from 'n8n-workflow';
2
+
3
+ export const getToolsOperations: INodeProperties[] = [
4
+ {
5
+ displayName: 'Operation',
6
+ name: 'operation',
7
+ type: 'options',
8
+ noDataExpression: true,
9
+ displayOptions: {
10
+ show: {
11
+ resource: ['tools'],
12
+ },
13
+ },
14
+ options: [
15
+ {
16
+ name: 'Instruct Edit an Image',
17
+ value: 'instructEdit',
18
+ description: 'Chỉnh sửa ảnh theo text instruction',
19
+ action: 'Instruct edit an image',
20
+ },
21
+ {
22
+ name: 'Upscale an Image',
23
+ value: 'upscale',
24
+ description: 'Tăng độ phân giải ảnh',
25
+ action: 'Upscale an image',
26
+ },
27
+ {
28
+ name: 'Face Swap an Image',
29
+ value: 'faceSwap',
30
+ description: 'Hoán đổi khuôn mặt trong ảnh',
31
+ action: 'Face swap an image',
32
+ },
33
+ ],
34
+ default: 'instructEdit',
35
+ },
36
+ ];
37
+
38
+ export const getToolsFields: INodeProperties[] = [
39
+ // ─── INSTRUCT EDIT ───────────────────────────────────────
40
+ {
41
+ displayName: 'Input Image URL',
42
+ name: 'inputImageUrl',
43
+ type: 'string',
44
+ displayOptions: {
45
+ show: {
46
+ resource: ['tools'],
47
+ operation: ['instructEdit'],
48
+ },
49
+ },
50
+ default: '',
51
+ placeholder: 'https://riku-assets.com/generations/xxx.png',
52
+ description: 'URL ảnh gốc muốn chỉnh sửa (từ List Images hoặc URL ngoài)',
53
+ required: true,
54
+ },
55
+ {
56
+ displayName: 'Edit Instruction',
57
+ name: 'editPrompt',
58
+ type: 'string',
59
+ typeOptions: { rows: 3 },
60
+ displayOptions: {
61
+ show: {
62
+ resource: ['tools'],
63
+ operation: ['instructEdit'],
64
+ },
65
+ },
66
+ default: '',
67
+ placeholder: 'Add a red hat to the person, keep the background the same',
68
+ description: 'Mô tả thay đổi muốn áp dụng lên ảnh',
69
+ required: true,
70
+ },
71
+ {
72
+ displayName: 'Additional Fields',
73
+ name: 'additionalFields',
74
+ type: 'collection',
75
+ placeholder: 'Add Field',
76
+ default: {},
77
+ displayOptions: {
78
+ show: {
79
+ resource: ['tools'],
80
+ operation: ['instructEdit'],
81
+ },
82
+ },
83
+ options: [
84
+ {
85
+ displayName: 'Model Name or ID',
86
+ name: 'model',
87
+ type: 'options',
88
+ typeOptions: {
89
+ loadOptionsMethod: 'getModels',
90
+ },
91
+ default: '',
92
+ description: 'Model AI dùng để edit ảnh',
93
+ },
94
+ {
95
+ displayName: 'Steps',
96
+ name: 'steps',
97
+ type: 'number',
98
+ typeOptions: { minValue: 1, maxValue: 50 },
99
+ default: 20,
100
+ description: 'Số bước inference',
101
+ },
102
+ {
103
+ displayName: 'CFG Scale',
104
+ name: 'cfgScale',
105
+ type: 'number',
106
+ typeOptions: { minValue: 1, maxValue: 10 },
107
+ default: 7,
108
+ description: 'Độ tuân thủ instruction',
109
+ },
110
+ {
111
+ displayName: 'Callback URL',
112
+ name: 'callbackUrl',
113
+ type: 'string',
114
+ default: '',
115
+ placeholder: 'https://your-n8n.com/webhook/supermachine-callback',
116
+ description: 'Webhook URL nhận kết quả async',
117
+ },
118
+ ],
119
+ },
120
+
121
+ // ─── UPSCALE ─────────────────────────────────────────────
122
+ {
123
+ displayName: 'Input Image URL',
124
+ name: 'inputImageUrl',
125
+ type: 'string',
126
+ displayOptions: {
127
+ show: {
128
+ resource: ['tools'],
129
+ operation: ['upscale'],
130
+ },
131
+ },
132
+ default: '',
133
+ placeholder: 'https://riku-assets.com/generations/xxx.png',
134
+ description: 'URL ảnh muốn upscale',
135
+ required: true,
136
+ },
137
+ {
138
+ displayName: 'Upscale Factor',
139
+ name: 'upscaleFactor',
140
+ type: 'options',
141
+ displayOptions: {
142
+ show: {
143
+ resource: ['tools'],
144
+ operation: ['upscale'],
145
+ },
146
+ },
147
+ options: [
148
+ { name: '2x', value: 2 },
149
+ { name: '4x', value: 4 },
150
+ { name: '8x', value: 8 },
151
+ ],
152
+ default: 2,
153
+ description: 'Tăng kích thước ảnh bao nhiêu lần',
154
+ },
155
+ {
156
+ displayName: 'Additional Fields',
157
+ name: 'additionalFields',
158
+ type: 'collection',
159
+ placeholder: 'Add Field',
160
+ default: {},
161
+ displayOptions: {
162
+ show: {
163
+ resource: ['tools'],
164
+ operation: ['upscale'],
165
+ },
166
+ },
167
+ options: [
168
+ {
169
+ displayName: 'Callback URL',
170
+ name: 'callbackUrl',
171
+ type: 'string',
172
+ default: '',
173
+ placeholder: 'https://your-n8n.com/webhook/supermachine-callback',
174
+ description: 'Webhook URL nhận kết quả async',
175
+ },
176
+ ],
177
+ },
178
+
179
+ // ─── FACE SWAP ───────────────────────────────────────────
180
+ {
181
+ displayName: 'Target Image URL',
182
+ name: 'inputImageUrl',
183
+ type: 'string',
184
+ displayOptions: {
185
+ show: {
186
+ resource: ['tools'],
187
+ operation: ['faceSwap'],
188
+ },
189
+ },
190
+ default: '',
191
+ placeholder: 'https://riku-assets.com/generations/xxx.png',
192
+ description: 'URL ảnh đích (ảnh sẽ được swap khuôn mặt vào)',
193
+ required: true,
194
+ },
195
+ {
196
+ displayName: 'Face Image URL',
197
+ name: 'faceImageUrl',
198
+ type: 'string',
199
+ displayOptions: {
200
+ show: {
201
+ resource: ['tools'],
202
+ operation: ['faceSwap'],
203
+ },
204
+ },
205
+ default: '',
206
+ placeholder: 'https://example.com/face.png',
207
+ description: 'URL ảnh khuôn mặt nguồn muốn swap vào ảnh đích',
208
+ required: true,
209
+ },
210
+ {
211
+ displayName: 'Additional Fields',
212
+ name: 'additionalFields',
213
+ type: 'collection',
214
+ placeholder: 'Add Field',
215
+ default: {},
216
+ displayOptions: {
217
+ show: {
218
+ resource: ['tools'],
219
+ operation: ['faceSwap'],
220
+ },
221
+ },
222
+ options: [
223
+ {
224
+ displayName: 'Strength',
225
+ name: 'strength',
226
+ type: 'number',
227
+ typeOptions: { minValue: 0, maxValue: 1 },
228
+ default: 0.8,
229
+ description: 'Độ mạnh face swap (0.0 - 1.0)',
230
+ },
231
+ {
232
+ displayName: 'Callback URL',
233
+ name: 'callbackUrl',
234
+ type: 'string',
235
+ default: '',
236
+ placeholder: 'https://your-n8n.com/webhook/supermachine-callback',
237
+ description: 'Webhook URL nhận kết quả async',
238
+ },
239
+ ],
240
+ },
241
+ ];
@@ -0,0 +1,3 @@
1
+ export * from './AccountDescription';
2
+ export * from './ImageDescription';
3
+ export * from './ToolsDescription';
@@ -0,0 +1,3 @@
1
+ import { Supermachine } from './Supermachine.node';
2
+
3
+ export = Supermachine;