n8n-nodes-sudomock 0.5.0 → 0.7.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.
- package/README.md +41 -7
- package/dist/nodes/SudoMock/SudoMock.node.js +147 -113
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -31,11 +31,12 @@ n8n community node for the SudoMock API. Integrate mockup rendering into your n8
|
|
|
31
31
|
|
|
32
32
|
- **Render Mockup**: Generate mockups with artwork, personalized text, or both. Text overrides support styled segments, fonts, size, color, stroke color, and overflow, shrink, or clip fitting. Optionally run asynchronously with the **Run Asynchronously** toggle, which returns a `job_id` to track with **Get Job**.
|
|
33
33
|
- **Render Video**: Turn a mockup (or an existing image URL) into a short product video (always asynchronous). Choose a supported duration, optional audio/motion, an optional one-off webhook, and optionally **Wait for Completion** to return the finished clip.
|
|
34
|
+
- **Remove Background**: Isolate the subject of an image onto a transparent background. The cutout remains stored, and the returned signed PNG URL is valid for 7 days. Costs 25 credits, refunded automatically if processing fails. The same cleanup is available inline on both render operations with the per-artwork **Remove Background** toggle.
|
|
34
35
|
|
|
35
36
|
### Fonts and Order Artwork
|
|
36
37
|
|
|
37
38
|
- **Fonts**: List available fonts, fetch one by UUID, upload a custom TTF or OTF from a public URL, and delete your custom fonts
|
|
38
|
-
- **
|
|
39
|
+
- **Artwork: Delete Stored Files**: Delete stored order artwork by URL or mockup UUID
|
|
39
40
|
|
|
40
41
|
### Async Jobs
|
|
41
42
|
|
|
@@ -238,6 +239,7 @@ Generate a mockup by filling smart objects with your designs.
|
|
|
238
239
|
- Fit Mode: `fill`, `contain`, or `cover` (recommended)
|
|
239
240
|
- **Additional Options** (optional):
|
|
240
241
|
- Rotation: -360 to 360 degrees
|
|
242
|
+
- Remove Background: clean the artwork before placing it (adds 25 credits per artwork)
|
|
241
243
|
- Color Overlay: Hex color code
|
|
242
244
|
- Color Blend Mode: Various blend modes
|
|
243
245
|
- Brightness: -150 to 150
|
|
@@ -284,6 +286,38 @@ Export Options:
|
|
|
284
286
|
|
|
285
287
|
---
|
|
286
288
|
|
|
289
|
+
### Remove Background
|
|
290
|
+
|
|
291
|
+
Isolate the subject of an image onto a transparent background. The cutout remains stored, and the returned signed PNG URL is valid for 7 days.
|
|
292
|
+
|
|
293
|
+
**Parameters:**
|
|
294
|
+
|
|
295
|
+
- **Image URL** (required): public URL of the image to process
|
|
296
|
+
|
|
297
|
+
**Example:**
|
|
298
|
+
|
|
299
|
+
```
|
|
300
|
+
Image URL: https://cdn.example.com/product-photo.jpg
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
**Output:**
|
|
304
|
+
|
|
305
|
+
```json
|
|
306
|
+
{
|
|
307
|
+
"success": true,
|
|
308
|
+
"data": {
|
|
309
|
+
"url": "https://cdn.sudomock.com/bg-cutouts/abc123.png",
|
|
310
|
+
"width": 2000,
|
|
311
|
+
"height": 2000,
|
|
312
|
+
"credits_charged": 25
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
The returned signed URL is valid for 7 days and can be fed straight into **Render Mockup** or **2D: Render Mockup** as artwork during that window. The cutout remains stored. Processing costs 25 credits per image and is refunded automatically if it fails. To clean artwork as part of a render instead, use the per-artwork **Remove Background** toggle on either render operation.
|
|
318
|
+
|
|
319
|
+
---
|
|
320
|
+
|
|
287
321
|
### Delete Mockup
|
|
288
322
|
|
|
289
323
|
Delete a specific mockup template.
|
|
@@ -307,11 +341,11 @@ Deletion confirmation
|
|
|
307
341
|
|
|
308
342
|
Create, prepare, render, and manage reusable mockups from product images without a PSD.
|
|
309
343
|
|
|
310
|
-
1. **2D: Create Mockup** accepts a public `source_url` or `source_base64`, plus an optional name.
|
|
311
|
-
2. **2D: Get Mockup** returns `draft`, `ready`, or `failed` status. Poll this operation until the mockup is `ready
|
|
312
|
-
3. **2D: List Mockups** returns your 2D mockups.
|
|
313
|
-
4. **2D: Set Print Areas**
|
|
314
|
-
5. **2D: Render Mockup** accepts the mockup UUID and one or more ready
|
|
344
|
+
1. **2D: Create Mockup** accepts a public `source_url` or `source_base64`, plus an optional name. By default it waits and returns the ready mockup detail unchanged. Enable **Run Asynchronously** to receive a 202 job with `job_id` and `status_url`, then use **Get Job** when needed.
|
|
345
|
+
2. **2D: Get Mockup** returns `draft`, `ready`, or `failed` status. Poll this operation until the mockup is `ready`. The ready response keeps saved areas in `data.quads` (addressed by `print_area_id`) and full surfaces in `data.surfaces` (addressed by `surface_uuid`).
|
|
346
|
+
3. **2D: List Mockups** returns your 2D mockups with limit, offset, and shopper-customizable filtering.
|
|
347
|
+
4. **2D: Set Print Areas** replaces saved areas with quads made from four `[x, y]` coordinate pairs. It can also send an empty list; the API remains authoritative and accepts that only when the mockup can remain renderable without saved areas.
|
|
348
|
+
5. **2D: Render Mockup** accepts the mockup UUID and one or more ready render targets. Each target sends exactly one identifier: `uuid` for a saved area or `surface_uuid` for a full surface. Each target also includes either an artwork URL or Base64 artwork, with optional background removal (adds 25 credits per artwork), color, public adjustments, and placement. Export options support PNG, JPG, or WebP from 100 to 10000 pixels, plus quality and optional DPI. Each render costs 5 credits and returns `print_files`, where `print_files[0]` is the CDN URL.
|
|
315
349
|
6. **2D: Delete Mockup** deletes the selected 2D mockup.
|
|
316
350
|
|
|
317
351
|
Create must reach `ready` through **2D: Get Mockup** before **2D: Render Mockup**.
|
|
@@ -330,7 +364,7 @@ Turn a mockup (or an existing image URL) into a short product video. Always asyn
|
|
|
330
364
|
- **Image URL** (required in Animate Image URL mode): public HTTPS image (`.png`, `.jpg`, `.jpeg`, `.webp`, `.gif`, `.avif`)
|
|
331
365
|
- **Webhook URL** (optional): one-off HTTPS URL notified when this job finishes
|
|
332
366
|
- **Video Options**:
|
|
333
|
-
- **Duration (Seconds)**: clip length (default 4; must be an allowed duration for the chosen model — the default model `veo-3.1-fast` allows 4
|
|
367
|
+
- **Duration (Seconds)**: clip length (default 4; must be an allowed duration for the chosen model — the default model `veo-3.1-fast` allows 4 or 6; max 15)
|
|
334
368
|
- **Audio**: include a generated audio track (default false; may cost extra credits depending on model)
|
|
335
369
|
- **Motion**: `ambient` (default) or `showcase`
|
|
336
370
|
- **Advanced Model**: optional override pinning a roster model (`veo-3.1-fast`, `kling-v3-pro`, `kling-2.6-pro`, `seedance-2.0`, `wan-2.5`); leave empty to auto-pick by plan tier
|
|
@@ -84,7 +84,7 @@ class SudoMock {
|
|
|
84
84
|
{
|
|
85
85
|
name: '2D: Get Mockup',
|
|
86
86
|
value: 'get2DMockup',
|
|
87
|
-
description: 'Get the status and
|
|
87
|
+
description: 'Get the status and addressable render targets of a 2D mockup',
|
|
88
88
|
action: 'Get a 2D mockup',
|
|
89
89
|
},
|
|
90
90
|
{
|
|
@@ -96,7 +96,7 @@ class SudoMock {
|
|
|
96
96
|
{
|
|
97
97
|
name: '2D: Set Print Areas',
|
|
98
98
|
value: 'set2DPrintAreas',
|
|
99
|
-
description: '
|
|
99
|
+
description: 'Replace or clear the saved print area quads for a 2D mockup',
|
|
100
100
|
action: 'Set 2D print areas',
|
|
101
101
|
},
|
|
102
102
|
{
|
|
@@ -117,12 +117,6 @@ class SudoMock {
|
|
|
117
117
|
description: 'Delete stored order artwork by URL or mockup UUID',
|
|
118
118
|
action: 'Delete stored artwork',
|
|
119
119
|
},
|
|
120
|
-
{
|
|
121
|
-
name: 'Artwork: Store Files',
|
|
122
|
-
value: 'storeArtworks',
|
|
123
|
-
description: 'Store customer artwork and an optional preview for order fulfillment',
|
|
124
|
-
action: 'Store artwork',
|
|
125
|
-
},
|
|
126
120
|
{
|
|
127
121
|
name: 'Delete Mockup',
|
|
128
122
|
value: 'deleteMockup',
|
|
@@ -183,6 +177,12 @@ class SudoMock {
|
|
|
183
177
|
description: 'List your async render, upload, and video jobs',
|
|
184
178
|
action: 'List jobs',
|
|
185
179
|
},
|
|
180
|
+
{
|
|
181
|
+
name: 'Remove Background',
|
|
182
|
+
value: 'removeBackground',
|
|
183
|
+
description: 'Remove the background from an image and get a transparent-PNG cutout through a signed URL valid for 7 days. The cutout remains stored. Costs 25 credits; auto-refunded on failure.',
|
|
184
|
+
action: 'Remove an image background',
|
|
185
|
+
},
|
|
186
186
|
{
|
|
187
187
|
name: 'Render Mockup',
|
|
188
188
|
value: 'render',
|
|
@@ -353,6 +353,32 @@ class SudoMock {
|
|
|
353
353
|
default: false,
|
|
354
354
|
description: 'Whether to queue creation and return a job_id (kind: 2d_create) immediately',
|
|
355
355
|
},
|
|
356
|
+
{
|
|
357
|
+
displayName: 'Limit',
|
|
358
|
+
name: 'twoDListLimit',
|
|
359
|
+
type: 'number',
|
|
360
|
+
typeOptions: { minValue: 1, maxValue: 100 },
|
|
361
|
+
displayOptions: { show: { operation: ['list2DMockups'] } },
|
|
362
|
+
default: 20,
|
|
363
|
+
description: 'Number of 2D mockups to return from 1 to 100',
|
|
364
|
+
},
|
|
365
|
+
{
|
|
366
|
+
displayName: 'Offset',
|
|
367
|
+
name: 'twoDListOffset',
|
|
368
|
+
type: 'number',
|
|
369
|
+
typeOptions: { minValue: 0 },
|
|
370
|
+
displayOptions: { show: { operation: ['list2DMockups'] } },
|
|
371
|
+
default: 0,
|
|
372
|
+
description: 'Number of 2D mockups to skip',
|
|
373
|
+
},
|
|
374
|
+
{
|
|
375
|
+
displayName: 'Customizable Only',
|
|
376
|
+
name: 'twoDListCustomizableOnly',
|
|
377
|
+
type: 'boolean',
|
|
378
|
+
displayOptions: { show: { operation: ['list2DMockups'] } },
|
|
379
|
+
default: false,
|
|
380
|
+
description: 'Whether to return only mockups ready for shopper customization',
|
|
381
|
+
},
|
|
356
382
|
{
|
|
357
383
|
displayName: 'Mockup UUID',
|
|
358
384
|
name: 'twoDMockupUuid',
|
|
@@ -381,7 +407,7 @@ class SudoMock {
|
|
|
381
407
|
},
|
|
382
408
|
default: {},
|
|
383
409
|
placeholder: 'Add Print Area',
|
|
384
|
-
description:
|
|
410
|
+
description: 'Optional during creation. Set Print Areas may send an empty list; the API decides whether the mockup can remain renderable without saved areas.',
|
|
385
411
|
options: [
|
|
386
412
|
{
|
|
387
413
|
name: 'items',
|
|
@@ -456,7 +482,7 @@ class SudoMock {
|
|
|
456
482
|
],
|
|
457
483
|
},
|
|
458
484
|
{
|
|
459
|
-
displayName: '
|
|
485
|
+
displayName: 'Render Targets',
|
|
460
486
|
name: 'twoDRenderPrintAreas',
|
|
461
487
|
type: 'fixedCollection',
|
|
462
488
|
typeOptions: {
|
|
@@ -469,20 +495,57 @@ class SudoMock {
|
|
|
469
495
|
},
|
|
470
496
|
},
|
|
471
497
|
default: {},
|
|
472
|
-
placeholder: 'Add
|
|
473
|
-
description: 'Artwork and options for each saved print area',
|
|
498
|
+
placeholder: 'Add Render Target',
|
|
499
|
+
description: 'Artwork and options for each target. Select exactly one saved print area UUID or full-surface UUID.',
|
|
474
500
|
options: [
|
|
475
501
|
{
|
|
476
502
|
name: 'items',
|
|
477
|
-
displayName: '
|
|
503
|
+
displayName: 'Render Target',
|
|
478
504
|
values: [
|
|
479
505
|
{
|
|
480
|
-
displayName: '
|
|
506
|
+
displayName: 'Target Type',
|
|
507
|
+
name: 'targetType',
|
|
508
|
+
type: 'options',
|
|
509
|
+
options: [
|
|
510
|
+
{
|
|
511
|
+
name: 'Saved Print Area',
|
|
512
|
+
value: 'savedPrintArea',
|
|
513
|
+
description: 'Target a saved print area returned in data.quads',
|
|
514
|
+
},
|
|
515
|
+
{
|
|
516
|
+
name: 'Full Surface',
|
|
517
|
+
value: 'fullSurface',
|
|
518
|
+
description: 'Target a full surface returned in data.surfaces',
|
|
519
|
+
},
|
|
520
|
+
],
|
|
521
|
+
default: 'savedPrintArea',
|
|
522
|
+
description: 'Whether this artwork targets a saved area or a full surface',
|
|
523
|
+
},
|
|
524
|
+
{
|
|
525
|
+
displayName: 'Saved Print Area UUID',
|
|
481
526
|
name: 'uuid',
|
|
482
527
|
type: 'string',
|
|
483
528
|
required: true,
|
|
529
|
+
displayOptions: {
|
|
530
|
+
show: {
|
|
531
|
+
targetType: ['savedPrintArea'],
|
|
532
|
+
},
|
|
533
|
+
},
|
|
534
|
+
default: '',
|
|
535
|
+
description: 'The print_area_id returned in data.quads by 2D: Get Mockup',
|
|
536
|
+
},
|
|
537
|
+
{
|
|
538
|
+
displayName: 'Full-Surface UUID',
|
|
539
|
+
name: 'surfaceUuid',
|
|
540
|
+
type: 'string',
|
|
541
|
+
required: true,
|
|
542
|
+
displayOptions: {
|
|
543
|
+
show: {
|
|
544
|
+
targetType: ['fullSurface'],
|
|
545
|
+
},
|
|
546
|
+
},
|
|
484
547
|
default: '',
|
|
485
|
-
description: '
|
|
548
|
+
description: 'The surface_uuid returned in data.surfaces by 2D: Get Mockup',
|
|
486
549
|
},
|
|
487
550
|
{
|
|
488
551
|
displayName: 'Artwork Type',
|
|
@@ -530,6 +593,13 @@ class SudoMock {
|
|
|
530
593
|
default: '',
|
|
531
594
|
description: 'Base64 artwork data for this print area',
|
|
532
595
|
},
|
|
596
|
+
{
|
|
597
|
+
displayName: 'Remove Background',
|
|
598
|
+
name: 'removeBackground',
|
|
599
|
+
type: 'boolean',
|
|
600
|
+
default: false,
|
|
601
|
+
description: 'Whether to remove the artwork background before placing it. Adds 25 credits per artwork.',
|
|
602
|
+
},
|
|
533
603
|
{
|
|
534
604
|
displayName: 'Color',
|
|
535
605
|
name: 'color',
|
|
@@ -605,30 +675,6 @@ class SudoMock {
|
|
|
605
675
|
default: 'multiply',
|
|
606
676
|
description: 'Artwork blend mode for the product surface',
|
|
607
677
|
},
|
|
608
|
-
{
|
|
609
|
-
displayName: 'Warp Strength',
|
|
610
|
-
name: 'warp_strength',
|
|
611
|
-
type: 'number',
|
|
612
|
-
typeOptions: { minValue: 0, maxValue: 2 },
|
|
613
|
-
default: 1.5,
|
|
614
|
-
description: 'Surface warp strength from 0 to 2',
|
|
615
|
-
},
|
|
616
|
-
{
|
|
617
|
-
displayName: 'Edge Expand',
|
|
618
|
-
name: 'edge_expand',
|
|
619
|
-
type: 'number',
|
|
620
|
-
typeOptions: { minValue: 0, maxValue: 50 },
|
|
621
|
-
default: 0,
|
|
622
|
-
description: 'Artwork edge expansion from 0 to 50',
|
|
623
|
-
},
|
|
624
|
-
{
|
|
625
|
-
displayName: 'Texture Strength',
|
|
626
|
-
name: 'texture_strength',
|
|
627
|
-
type: 'number',
|
|
628
|
-
typeOptions: { minValue: 0, maxValue: 100 },
|
|
629
|
-
default: 0,
|
|
630
|
-
description: 'Product texture strength from 0 to 100',
|
|
631
|
-
},
|
|
632
678
|
],
|
|
633
679
|
},
|
|
634
680
|
{
|
|
@@ -965,6 +1011,13 @@ class SudoMock {
|
|
|
965
1011
|
default: 0,
|
|
966
1012
|
description: 'Custom position left offset in pixels',
|
|
967
1013
|
},
|
|
1014
|
+
{
|
|
1015
|
+
displayName: 'Remove Background',
|
|
1016
|
+
name: 'removeBackground',
|
|
1017
|
+
type: 'boolean',
|
|
1018
|
+
default: false,
|
|
1019
|
+
description: 'Whether to remove the artwork background before placing it. Adds 25 credits per artwork.',
|
|
1020
|
+
},
|
|
968
1021
|
{
|
|
969
1022
|
displayName: 'Color Overlay (Hex)',
|
|
970
1023
|
name: 'colorHex',
|
|
@@ -1318,7 +1371,7 @@ class SudoMock {
|
|
|
1318
1371
|
maxValue: 15,
|
|
1319
1372
|
},
|
|
1320
1373
|
default: 4,
|
|
1321
|
-
description: "Length of the clip in seconds. Must be one of the chosen model's allowed durations (the default model veo-3.1-fast allows 4
|
|
1374
|
+
description: "Length of the clip in seconds. Must be one of the chosen model's allowed durations (the default model veo-3.1-fast allows 4 or 6). Longer clips cost more credits.",
|
|
1322
1375
|
},
|
|
1323
1376
|
{
|
|
1324
1377
|
displayName: 'Audio',
|
|
@@ -1564,58 +1617,21 @@ class SudoMock {
|
|
|
1564
1617
|
],
|
|
1565
1618
|
},
|
|
1566
1619
|
// ============================================
|
|
1567
|
-
//
|
|
1620
|
+
// BACKGROUND REMOVAL PARAMETERS
|
|
1568
1621
|
// ============================================
|
|
1569
1622
|
{
|
|
1570
|
-
displayName: '
|
|
1571
|
-
name: '
|
|
1623
|
+
displayName: 'Image URL',
|
|
1624
|
+
name: 'removeBackgroundImageUrl',
|
|
1572
1625
|
type: 'string',
|
|
1573
1626
|
required: true,
|
|
1574
|
-
displayOptions: { show: { operation: ['
|
|
1627
|
+
displayOptions: { show: { operation: ['removeBackground'] } },
|
|
1575
1628
|
default: '',
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
{
|
|
1579
|
-
displayName: 'Artwork Items',
|
|
1580
|
-
name: 'artworkItems',
|
|
1581
|
-
type: 'fixedCollection',
|
|
1582
|
-
typeOptions: { multipleValues: true },
|
|
1583
|
-
displayOptions: { show: { operation: ['storeArtworks'] } },
|
|
1584
|
-
default: {},
|
|
1585
|
-
placeholder: 'Add Artwork',
|
|
1586
|
-
description: 'Up to 10 artwork files to keep for order fulfillment',
|
|
1587
|
-
options: [
|
|
1588
|
-
{
|
|
1589
|
-
name: 'items',
|
|
1590
|
-
displayName: 'Artwork',
|
|
1591
|
-
values: [
|
|
1592
|
-
{
|
|
1593
|
-
displayName: 'Smart Object UUID',
|
|
1594
|
-
name: 'smartObjectUuid',
|
|
1595
|
-
type: 'string',
|
|
1596
|
-
required: true,
|
|
1597
|
-
default: '',
|
|
1598
|
-
},
|
|
1599
|
-
{
|
|
1600
|
-
displayName: 'Base64 Artwork',
|
|
1601
|
-
name: 'base64',
|
|
1602
|
-
type: 'string',
|
|
1603
|
-
required: true,
|
|
1604
|
-
default: '',
|
|
1605
|
-
description: 'Raw base64 image bytes without a data URL prefix',
|
|
1606
|
-
},
|
|
1607
|
-
],
|
|
1608
|
-
},
|
|
1609
|
-
],
|
|
1610
|
-
},
|
|
1611
|
-
{
|
|
1612
|
-
displayName: 'Preview URL',
|
|
1613
|
-
name: 'artworkPreviewUrl',
|
|
1614
|
-
type: 'string',
|
|
1615
|
-
displayOptions: { show: { operation: ['storeArtworks'] } },
|
|
1616
|
-
default: '',
|
|
1617
|
-
description: 'Optional render URL to keep with the order',
|
|
1629
|
+
placeholder: 'https://cdn.example.com/product-photo.jpg',
|
|
1630
|
+
description: 'Public URL of the image to isolate onto a transparent background',
|
|
1618
1631
|
},
|
|
1632
|
+
// ============================================
|
|
1633
|
+
// ARTWORK PARAMETERS
|
|
1634
|
+
// ============================================
|
|
1619
1635
|
{
|
|
1620
1636
|
displayName: 'Delete By',
|
|
1621
1637
|
name: 'artworkDeleteMode',
|
|
@@ -2101,9 +2117,17 @@ class SudoMock {
|
|
|
2101
2117
|
// 2D: LIST MOCKUPS
|
|
2102
2118
|
// ========================================
|
|
2103
2119
|
else if (operation === 'list2DMockups') {
|
|
2120
|
+
const limit = this.getNodeParameter('twoDListLimit', i, 20);
|
|
2121
|
+
const offset = this.getNodeParameter('twoDListOffset', i, 0);
|
|
2122
|
+
const customizableOnly = this.getNodeParameter('twoDListCustomizableOnly', i, false);
|
|
2104
2123
|
const response = await this.helpers.httpRequestWithAuthentication.call(this, 'sudoMockApi', {
|
|
2105
2124
|
method: 'GET',
|
|
2106
2125
|
url: 'https://api.sudomock.com/api/v1/sudoai/2d-mockups',
|
|
2126
|
+
qs: {
|
|
2127
|
+
limit,
|
|
2128
|
+
offset,
|
|
2129
|
+
customizable_only: customizableOnly,
|
|
2130
|
+
},
|
|
2107
2131
|
json: true,
|
|
2108
2132
|
});
|
|
2109
2133
|
returnData.push({
|
|
@@ -2117,9 +2141,6 @@ class SudoMock {
|
|
|
2117
2141
|
else if (operation === 'set2DPrintAreas') {
|
|
2118
2142
|
const mockupUuid = this.getNodeParameter('twoDMockupUuid', i);
|
|
2119
2143
|
const printAreas = this.getNodeParameter('twoDSetPrintAreas.items', i, []);
|
|
2120
|
-
if (printAreas.length === 0) {
|
|
2121
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Add at least one print area');
|
|
2122
|
-
}
|
|
2123
2144
|
const body = { print_areas: format2DPrintAreas(printAreas) };
|
|
2124
2145
|
const response = await this.helpers.httpRequestWithAuthentication.call(this, 'sudoMockApi', {
|
|
2125
2146
|
method: 'PUT',
|
|
@@ -2139,18 +2160,37 @@ class SudoMock {
|
|
|
2139
2160
|
const mockupUuid = this.getNodeParameter('twoDMockupUuid', i);
|
|
2140
2161
|
const printAreasData = this.getNodeParameter('twoDRenderPrintAreas.items', i, []);
|
|
2141
2162
|
const printAreas = printAreasData.map((area) => {
|
|
2142
|
-
const
|
|
2163
|
+
const targetType = area.targetType ?? 'savedPrintArea';
|
|
2164
|
+
const targetValue = targetType === 'fullSurface' ? area.surfaceUuid : area.uuid;
|
|
2165
|
+
if (!targetValue) {
|
|
2166
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), targetType === 'fullSurface'
|
|
2167
|
+
? 'Full-Surface UUID is required for a full-surface render target'
|
|
2168
|
+
: 'Saved Print Area UUID is required for a saved print-area render target');
|
|
2169
|
+
}
|
|
2170
|
+
const printArea = targetType === 'fullSurface' ? { surface_uuid: targetValue } : { uuid: targetValue };
|
|
2143
2171
|
if (area.artworkSource === 'base64') {
|
|
2144
2172
|
printArea.base64 = area.base64;
|
|
2145
2173
|
}
|
|
2146
2174
|
else {
|
|
2147
2175
|
printArea.artwork_url = area.artworkUrl;
|
|
2148
2176
|
}
|
|
2177
|
+
if (area.removeBackground) {
|
|
2178
|
+
printArea.remove_background = true;
|
|
2179
|
+
}
|
|
2149
2180
|
if (area.color) {
|
|
2150
2181
|
printArea.color = area.color;
|
|
2151
2182
|
}
|
|
2152
2183
|
if (area.adjustments && Object.keys(area.adjustments).length > 0) {
|
|
2153
|
-
|
|
2184
|
+
const { brightness, contrast, opacity, saturation, vibrance, blur, blend_mode } = area.adjustments;
|
|
2185
|
+
printArea.adjustments = Object.fromEntries(Object.entries({
|
|
2186
|
+
brightness,
|
|
2187
|
+
contrast,
|
|
2188
|
+
opacity,
|
|
2189
|
+
saturation,
|
|
2190
|
+
vibrance,
|
|
2191
|
+
blur,
|
|
2192
|
+
blend_mode,
|
|
2193
|
+
}).filter(([, value]) => value !== undefined));
|
|
2154
2194
|
}
|
|
2155
2195
|
if (area.placement && Object.keys(area.placement).length > 0) {
|
|
2156
2196
|
printArea.placement = area.placement;
|
|
@@ -2269,30 +2309,15 @@ class SudoMock {
|
|
|
2269
2309
|
});
|
|
2270
2310
|
}
|
|
2271
2311
|
// ========================================
|
|
2272
|
-
//
|
|
2312
|
+
// BACKGROUND REMOVAL
|
|
2273
2313
|
// ========================================
|
|
2274
|
-
else if (operation === '
|
|
2275
|
-
const items = this.getNodeParameter('artworkItems.items', i, []);
|
|
2276
|
-
const previewUrl = this.getNodeParameter('artworkPreviewUrl', i, '');
|
|
2277
|
-
if (items.length === 0 && !previewUrl) {
|
|
2278
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Add at least one artwork item or a preview URL');
|
|
2279
|
-
}
|
|
2280
|
-
if (items.length > 10) {
|
|
2281
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Artwork Items supports up to 10 files');
|
|
2282
|
-
}
|
|
2283
|
-
const body = {
|
|
2284
|
-
mockup_uuid: this.getNodeParameter('artworkMockupUuid', i),
|
|
2285
|
-
items: items.map((item) => ({
|
|
2286
|
-
smart_object_uuid: item.smartObjectUuid,
|
|
2287
|
-
base64: item.base64,
|
|
2288
|
-
})),
|
|
2289
|
-
};
|
|
2290
|
-
if (previewUrl)
|
|
2291
|
-
body.preview_url = previewUrl;
|
|
2314
|
+
else if (operation === 'removeBackground') {
|
|
2292
2315
|
const response = await this.helpers.httpRequestWithAuthentication.call(this, 'sudoMockApi', {
|
|
2293
2316
|
method: 'POST',
|
|
2294
|
-
url: 'https://api.sudomock.com/api/v1/
|
|
2295
|
-
body
|
|
2317
|
+
url: 'https://api.sudomock.com/api/v1/remove-background',
|
|
2318
|
+
body: {
|
|
2319
|
+
url: this.getNodeParameter('removeBackgroundImageUrl', i),
|
|
2320
|
+
},
|
|
2296
2321
|
json: true,
|
|
2297
2322
|
});
|
|
2298
2323
|
returnData.push({
|
|
@@ -2300,6 +2325,9 @@ class SudoMock {
|
|
|
2300
2325
|
pairedItem: { item: i },
|
|
2301
2326
|
});
|
|
2302
2327
|
}
|
|
2328
|
+
// ========================================
|
|
2329
|
+
// ARTWORKS
|
|
2330
|
+
// ========================================
|
|
2303
2331
|
else if (operation === 'deleteArtworks') {
|
|
2304
2332
|
const mode = this.getNodeParameter('artworkDeleteMode', i);
|
|
2305
2333
|
const body = {};
|
|
@@ -2356,6 +2384,10 @@ class SudoMock {
|
|
|
2356
2384
|
asset.content_type = opts.contentType;
|
|
2357
2385
|
}
|
|
2358
2386
|
}
|
|
2387
|
+
// Background removal surcharge, billed per unique artwork source
|
|
2388
|
+
if (opts.removeBackground) {
|
|
2389
|
+
asset.remove_background = true;
|
|
2390
|
+
}
|
|
2359
2391
|
// Custom size override
|
|
2360
2392
|
const size = {};
|
|
2361
2393
|
if (opts.sizeWidth !== undefined && opts.sizeWidth > 0) {
|
|
@@ -2984,7 +3016,9 @@ class SudoMock {
|
|
|
2984
3016
|
itemIndex: i,
|
|
2985
3017
|
});
|
|
2986
3018
|
}
|
|
2987
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error instanceof Error ? error : new Error('Unknown error'), {
|
|
3019
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error instanceof Error ? error : new Error('Unknown error'), {
|
|
3020
|
+
itemIndex: i,
|
|
3021
|
+
});
|
|
2988
3022
|
}
|
|
2989
3023
|
}
|
|
2990
3024
|
return [returnData];
|