n8n-nodes-commandos-image 0.1.5 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -31,13 +31,14 @@ const mapRatio = (model, ratio) => {
31
31
  * Maps standard formats to specific model requirements (jpeg vs jpg)
32
32
  */
33
33
  const mapFormat = (model, format) => {
34
+ const f = String(format || 'png').toLowerCase().trim();
34
35
  if (model === 'nano-banana-pro') {
35
- return format === 'jpeg' ? 'jpg' : format;
36
+ return (f === 'jpeg' || f === 'jpg') ? 'jpg' : f;
36
37
  }
37
38
  if (model.includes('google/nano-banana')) {
38
- return format === 'jpg' ? 'jpeg' : format;
39
+ return (f === 'jpeg' || f === 'jpg') ? 'jpeg' : f;
39
40
  }
40
- return format;
41
+ return f;
41
42
  };
42
43
  const buildGenerationRequest = ({ model, prompt, ratio, references, outputFormat = 'png', quality = 'basic', resolution = '1K', }) => {
43
44
  const hasReferences = references.length > 0;
@@ -371,22 +372,16 @@ class CommandosImage {
371
372
  const prompt = String(this.getNodeParameter('prompt', i) || '').trim();
372
373
  const ratio = String(this.getNodeParameter('ratio', i));
373
374
  const references = extractReferences(this.getNodeParameter('references', i, {}), model);
374
- // Get optional parameters with safe fallback
375
- let outputFormat = 'png';
376
- try {
377
- outputFormat = String(this.getNodeParameter('outputFormat', i));
378
- }
379
- catch (e) { }
380
- let quality = 'basic';
381
- try {
382
- quality = String(this.getNodeParameter('quality', i));
383
- }
384
- catch (e) { }
385
- let resolution = '1K';
386
- try {
387
- resolution = String(this.getNodeParameter('resolution', i));
388
- }
389
- catch (e) { }
375
+ // Get optional parameters safely
376
+ const outputFormat = ['nano-banana', 'nano-banana-pro'].includes(model)
377
+ ? String(this.getNodeParameter('outputFormat', i, 'png'))
378
+ : 'png';
379
+ const quality = ['seedream', 'gpt4o-image', 'flux-pro'].includes(model)
380
+ ? String(this.getNodeParameter('quality', i, 'basic'))
381
+ : 'basic';
382
+ const resolution = ['flux-pro', 'nano-banana-pro'].includes(model)
383
+ ? String(this.getNodeParameter('resolution', i, '1K'))
384
+ : '1K';
390
385
  if (!prompt) {
391
386
  throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Prompt is required', { itemIndex: i });
392
387
  }
@@ -410,6 +405,11 @@ class CommandosImage {
410
405
  ratio: request.ratio,
411
406
  references: request.references,
412
407
  hasReferences: request.hasReferences,
408
+ _debug: {
409
+ model,
410
+ outputFormat,
411
+ version: '0.1.7',
412
+ }
413
413
  };
414
414
  const response = await this.helpers.request({
415
415
  method: 'POST',
@@ -57,13 +57,14 @@ const mapRatio = (model: string, ratio: string): string => {
57
57
  * Maps standard formats to specific model requirements (jpeg vs jpg)
58
58
  */
59
59
  const mapFormat = (model: string, format: string): string => {
60
+ const f = String(format || 'png').toLowerCase().trim();
60
61
  if (model === 'nano-banana-pro') {
61
- return format === 'jpeg' ? 'jpg' : format;
62
+ return (f === 'jpeg' || f === 'jpg') ? 'jpg' : f;
62
63
  }
63
64
  if (model.includes('google/nano-banana')) {
64
- return format === 'jpg' ? 'jpeg' : format;
65
+ return (f === 'jpeg' || f === 'jpg') ? 'jpeg' : f;
65
66
  }
66
- return format;
67
+ return f;
67
68
  };
68
69
 
69
70
  const buildGenerationRequest = ({
@@ -93,9 +94,9 @@ const buildGenerationRequest = ({
93
94
  // Fallback for MJ or generic seedream
94
95
  if (!hasReferences && (requestedModel === 'seedream' || requestedModel === 'midjourney')) {
95
96
  if (requestedModel === 'seedream') {
96
- // Handled above for 4.5
97
+ // Handled above for 4.5
97
98
  } else if (requestedModel === 'midjourney') {
98
- resolvedModel = 'midjourney';
99
+ resolvedModel = 'midjourney';
99
100
  }
100
101
  }
101
102
 
@@ -188,7 +189,7 @@ const extractReferences = (raw: unknown, model: string): string[] => {
188
189
  }
189
190
  const collection = raw as { reference?: Array<{ url?: string }> };
190
191
  const items = Array.isArray(collection.reference) ? collection.reference : [];
191
-
192
+
192
193
  // Dynamic limit based on model docs
193
194
  let limit = 8;
194
195
  if (model === 'seedream') limit = 14;
@@ -405,30 +406,33 @@ export class CommandosImage implements INodeType {
405
406
  const ratio = String(this.getNodeParameter('ratio', i));
406
407
  const references = extractReferences(this.getNodeParameter('references', i, {}), model);
407
408
 
408
- // Get optional parameters with safe fallback
409
- let outputFormat = 'png';
410
- try { outputFormat = String(this.getNodeParameter('outputFormat', i)); } catch (e) {}
409
+ // Get optional parameters safely
410
+ const outputFormat = ['nano-banana', 'nano-banana-pro'].includes(model)
411
+ ? String(this.getNodeParameter('outputFormat', i, 'png'))
412
+ : 'png';
411
413
 
412
- let quality = 'basic';
413
- try { quality = String(this.getNodeParameter('quality', i)); } catch (e) {}
414
+ const quality = ['seedream', 'gpt4o-image', 'flux-pro'].includes(model)
415
+ ? String(this.getNodeParameter('quality', i, 'basic'))
416
+ : 'basic';
414
417
 
415
- let resolution = '1K';
416
- try { resolution = String(this.getNodeParameter('resolution', i)); } catch (e) {}
418
+ const resolution = ['flux-pro', 'nano-banana-pro'].includes(model)
419
+ ? String(this.getNodeParameter('resolution', i, '1K'))
420
+ : '1K';
417
421
 
418
422
  if (!prompt) {
419
423
  throw new NodeOperationError(this.getNode(), 'Prompt is required', { itemIndex: i });
420
424
  }
421
425
 
422
- const request = buildGenerationRequest({
423
- model,
424
- prompt,
425
- ratio,
426
+ const request = buildGenerationRequest({
427
+ model,
428
+ prompt,
429
+ ratio,
426
430
  references,
427
431
  outputFormat,
428
432
  quality,
429
433
  resolution
430
434
  });
431
-
435
+
432
436
  if (!request.url) {
433
437
  throw new NodeOperationError(
434
438
  this.getNode(),
@@ -445,6 +449,11 @@ export class CommandosImage implements INodeType {
445
449
  ratio: request.ratio,
446
450
  references: request.references,
447
451
  hasReferences: request.hasReferences,
452
+ _debug: {
453
+ model,
454
+ outputFormat,
455
+ version: '0.1.7',
456
+ }
448
457
  };
449
458
 
450
459
  const response = await this.helpers.request({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-commandos-image",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "Commandos Image custom node",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",