n8n-nodes-pixelvault 0.2.0 → 0.4.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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# n8n-nodes-pixelvault
|
|
2
2
|
|
|
3
|
-
An [n8n](https://n8n.io/) community node for [PixelVault](https://pixelvault.dev),
|
|
3
|
+
An [n8n](https://n8n.io/) community node for [PixelVault](https://pixelvault.dev), media hosting built for automations and AI agents. Upload images or MP4 video and pass stable CDN URLs, asset IDs, and asynchronous job IDs to later nodes.
|
|
4
4
|
|
|
5
5
|
- [Installation](#installation)
|
|
6
6
|
- [Operations](#operations)
|
|
@@ -20,14 +20,18 @@ Follow the [community nodes installation guide](https://docs.n8n.io/integrations
|
|
|
20
20
|
| **Upload Image** | Uploads an image from a binary property (for example the output of Google Drive, an HTTP Request, or an image-generation node) and returns a public URL. |
|
|
21
21
|
| **Import Image From URL** | Has PixelVault fetch an image from a public HTTPS URL and host it. Use it while the source URL is still valid, for example a generated image whose link expires. |
|
|
22
22
|
| **Update Image Metadata** | Replaces an image's custom metadata by ID (the object replaces the stored one, `{}` clears it). Set metadata at upload time with the **Metadata (JSON)** option on the two operations above. |
|
|
23
|
+
| **Describe With AI** (option) | On the two upload operations: PixelVault writes alt text, a caption and the text found in the image (OCR) in the background (Free 20 in total, Starter 1,000/month, Pro 10,000/month; secret key and verified email required). Add **Wait For Description** to wait up to ~40 s and get `description.alt`, `.caption` and `.ocr_text` in the output. Treat that text as untrusted model output. |
|
|
24
|
+
| **Upload Video** | Uploads MP4 binary data with optional privacy, TTL, metadata, folder, collection, idempotency, and social optimization. |
|
|
25
|
+
| **Import Video From URL** | Securely imports an MP4 from a public HTTPS URL with the same lifecycle options. |
|
|
26
|
+
| **Get Video Status and Artifacts** | Resumes from a stable video ID and returns current optimization/enrichment status plus only the original, poster, transcript, storyboard, and optimized URLs that exist. |
|
|
27
|
+
| **List Videos** | Discovers videos by page, folder, collection, or metadata. |
|
|
28
|
+
| **Optimize Video** / **Enrich Video** | Starts an asynchronous job. Return IDs immediately or poll with bounded backoff; a local timeout does not cancel the server job. |
|
|
29
|
+
| **Update Video** / **Sign Video URLs** / **Delete Video** | Updates metadata and organization, refreshes private original/artifact URLs, or deletes the video and derivatives. |
|
|
23
30
|
|
|
24
|
-
|
|
31
|
+
Image and video uploads accept folder, public/private visibility, deletion TTL, and custom metadata. Video uploads also accept collection membership, an idempotency key, private URL expiry, and optional social-ready optimization.
|
|
25
32
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
- **Expires In (Seconds)**: delete the image automatically after this long.
|
|
29
|
-
|
|
30
|
-
The output is the image object returned by the PixelVault API, with fields such as `url`, `id`, `mime_type`, `size` and `filename`. Map the hosted link with `{{ $json.url }}`.
|
|
33
|
+
The output is the API object. Images expose fields such as `url`, `id`, `mime_type`, `size`, and `filename`.
|
|
34
|
+
Videos expose `id`, `original_url`, `social_optimization`, and `enrichment`; transcript/storyboard URLs appear only after those artifacts exist. Private URLs are signed and expire independently from asset deletion.
|
|
31
35
|
|
|
32
36
|
## Credentials
|
|
33
37
|
|
|
@@ -39,15 +43,23 @@ Uploads made without a key expire. Use the credential for images you want to kee
|
|
|
39
43
|
|
|
40
44
|
## Usage
|
|
41
45
|
|
|
42
|
-
|
|
46
|
+
Image flow: **Google Drive: Download** → **PixelVault: Upload Image** → publishing node, mapping `{{ $json.url }}`.
|
|
47
|
+
|
|
48
|
+
Resume-safe asynchronous video flow:
|
|
49
|
+
|
|
50
|
+
1. **Upload Video** with an idempotency key such as `{{ $execution.id }}:{{ $itemIndex }}`. Store the returned `id`.
|
|
51
|
+
2. **Enrich Video** with **Wait For Completion** off. It returns `id` and `enrichment.job_id` immediately.
|
|
52
|
+
3. Persist those IDs in your normal durable workflow state. A later execution uses **Get Video Status and Artifacts** with the saved `id`.
|
|
53
|
+
4. If `{{ $json.enrichment.status }}` is `pending` or `processing`, use an n8n Wait node and call **Get Video Status and Artifacts** again. Route `complete` to transcript/storyboard consumers and `failed` to error handling.
|
|
43
54
|
|
|
44
|
-
|
|
45
|
-
- Hosted images are public unless you choose Private. Use images intended for publication.
|
|
46
|
-
- For Instagram, start with a JPEG that meets Meta's size and aspect-ratio requirements. Hosting does not convert or validate images for a destination.
|
|
47
|
-
- Supported formats and size limits are those of the PixelVault API (currently JPG, PNG, GIF, WebP, AVIF and SVG, up to 5 MB per file on the free plan).
|
|
48
|
-
- This node hosts images. It does not host video.
|
|
55
|
+
The node can also wait in one execution with bounded backoff. Keep IDs when using that mode: timeout only stops local polling.
|
|
49
56
|
|
|
50
|
-
|
|
57
|
+
- The binary field name defaults to `data`.
|
|
58
|
+
- Video binary upload supports MP4 files up to 100 MB. This node intentionally does not implement multipart upload; use a public source URL with **Import Video From URL** or an official SDK for larger hosting uploads.
|
|
59
|
+
- URL imports accept public HTTPS sources only. Download authenticated sources in n8n first.
|
|
60
|
+
- Optimization accepts sources up to 100 MB and 60 seconds; enrichment accepts sources from 1 second through 10 minutes and up to 100 MB. API quota and unsupported-source errors are returned without rewriting.
|
|
61
|
+
- Public assets are stable CDN URLs. Private assets never fall back to public; refresh their bearer URLs with **Sign Video URLs**.
|
|
62
|
+
- Hosting does not convert images for a destination. Video social optimization is explicit and asynchronous.
|
|
51
63
|
|
|
52
64
|
## Compatibility
|
|
53
65
|
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PixelVault = void 0;
|
|
4
|
+
const node_crypto_1 = require("node:crypto");
|
|
4
5
|
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
6
|
const IMAGES_URL = 'https://api.pixelvault.dev/v1/images';
|
|
7
|
+
const VIDEOS_URL = 'https://api.pixelvault.dev/v1/videos';
|
|
6
8
|
const MIN_EXPIRES_IN = 60;
|
|
7
9
|
const MAX_EXPIRES_IN = 2592000;
|
|
10
|
+
const DESCRIBE_POLL_MS = 2000;
|
|
11
|
+
const DESCRIBE_MAX_WAIT_MS = 40000;
|
|
12
|
+
const VIDEO_POLL_INITIAL_MS = 1000;
|
|
13
|
+
const VIDEO_POLL_MAX_MS = 5000;
|
|
8
14
|
function parseMetadata(value) {
|
|
9
15
|
if (value === undefined || value === null || value === '')
|
|
10
16
|
return {};
|
|
@@ -65,7 +71,7 @@ class PixelVault {
|
|
|
65
71
|
group: ['transform'],
|
|
66
72
|
version: 1,
|
|
67
73
|
subtitle: '={{$parameter["operation"]}}',
|
|
68
|
-
description: 'Host
|
|
74
|
+
description: 'Host images and videos and get CDN URLs',
|
|
69
75
|
defaults: {
|
|
70
76
|
name: 'PixelVault',
|
|
71
77
|
},
|
|
@@ -78,18 +84,24 @@ class PixelVault {
|
|
|
78
84
|
},
|
|
79
85
|
],
|
|
80
86
|
properties: [
|
|
87
|
+
{
|
|
88
|
+
displayName: 'Resource',
|
|
89
|
+
name: 'resource',
|
|
90
|
+
type: 'options',
|
|
91
|
+
noDataExpression: true,
|
|
92
|
+
options: [
|
|
93
|
+
{ name: 'Image', value: 'image' },
|
|
94
|
+
{ name: 'Video', value: 'video' },
|
|
95
|
+
],
|
|
96
|
+
default: 'image',
|
|
97
|
+
},
|
|
81
98
|
{
|
|
82
99
|
displayName: 'Operation',
|
|
83
100
|
name: 'operation',
|
|
84
101
|
type: 'options',
|
|
85
102
|
noDataExpression: true,
|
|
103
|
+
displayOptions: { show: { resource: ['image'] } },
|
|
86
104
|
options: [
|
|
87
|
-
{
|
|
88
|
-
name: 'Upload Image',
|
|
89
|
-
value: 'upload',
|
|
90
|
-
description: 'Upload an image from binary data and get a public URL',
|
|
91
|
-
action: 'Upload an image',
|
|
92
|
-
},
|
|
93
105
|
{
|
|
94
106
|
name: 'Import Image From URL',
|
|
95
107
|
value: 'importUrl',
|
|
@@ -102,17 +114,87 @@ class PixelVault {
|
|
|
102
114
|
description: "Replace an image's custom metadata (use {} to clear it)",
|
|
103
115
|
action: 'Update image metadata',
|
|
104
116
|
},
|
|
117
|
+
{
|
|
118
|
+
name: 'Upload Image',
|
|
119
|
+
value: 'upload',
|
|
120
|
+
description: 'Upload an image from binary data and get a CDN URL',
|
|
121
|
+
action: 'Upload an image',
|
|
122
|
+
},
|
|
105
123
|
],
|
|
106
124
|
default: 'upload',
|
|
107
125
|
},
|
|
126
|
+
{
|
|
127
|
+
displayName: 'Operation',
|
|
128
|
+
name: 'operation',
|
|
129
|
+
type: 'options',
|
|
130
|
+
noDataExpression: true,
|
|
131
|
+
displayOptions: { show: { resource: ['video'] } },
|
|
132
|
+
options: [
|
|
133
|
+
{
|
|
134
|
+
name: 'Delete Video',
|
|
135
|
+
value: 'deleteVideo',
|
|
136
|
+
description: 'Delete a video and its derived artifacts',
|
|
137
|
+
action: 'Delete a video',
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
name: 'Enrich Video',
|
|
141
|
+
value: 'enrichVideo',
|
|
142
|
+
description: 'Start transcript and storyboard enrichment, optionally waiting for completion',
|
|
143
|
+
action: 'Enrich a video',
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
name: 'Get Video Status and Artifacts',
|
|
147
|
+
value: 'getVideo',
|
|
148
|
+
description: 'Get the original, status, transcript, storyboard, poster, and optimized URL',
|
|
149
|
+
action: 'Get video status and artifacts',
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
name: 'Import Video From URL',
|
|
153
|
+
value: 'importVideo',
|
|
154
|
+
description: 'Securely import an MP4 from a public HTTPS URL',
|
|
155
|
+
action: 'Import a video from a URL',
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
name: 'List Videos',
|
|
159
|
+
value: 'listVideos',
|
|
160
|
+
description: 'List videos with optional folder, collection, and metadata filters',
|
|
161
|
+
action: 'List videos',
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
name: 'Optimize Video',
|
|
165
|
+
value: 'optimizeVideo',
|
|
166
|
+
description: 'Start social-ready optimization, optionally waiting for completion',
|
|
167
|
+
action: 'Optimize a video',
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
name: 'Sign Video URLs',
|
|
171
|
+
value: 'signVideo',
|
|
172
|
+
description: 'Mint fresh private original and available artifact URLs',
|
|
173
|
+
action: 'Create signed links for a video',
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
name: 'Update Video',
|
|
177
|
+
value: 'updateVideo',
|
|
178
|
+
description: 'Replace video metadata, folder, and collection membership',
|
|
179
|
+
action: 'Update a video',
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
name: 'Upload Video',
|
|
183
|
+
value: 'uploadVideo',
|
|
184
|
+
description: 'Upload an MP4 from binary data',
|
|
185
|
+
action: 'Upload a video',
|
|
186
|
+
},
|
|
187
|
+
],
|
|
188
|
+
default: 'uploadVideo',
|
|
189
|
+
},
|
|
108
190
|
{
|
|
109
191
|
displayName: 'Input Binary Field',
|
|
110
192
|
name: 'binaryPropertyName',
|
|
111
193
|
type: 'string',
|
|
112
194
|
default: 'data',
|
|
113
195
|
required: true,
|
|
114
|
-
displayOptions: { show: { operation: ['upload'] } },
|
|
115
|
-
description: 'Name of the binary property that holds the image to upload',
|
|
196
|
+
displayOptions: { show: { operation: ['upload', 'uploadVideo'] } },
|
|
197
|
+
description: 'Name of the binary property that holds the image or MP4 to upload',
|
|
116
198
|
},
|
|
117
199
|
{
|
|
118
200
|
displayName: 'Image URL',
|
|
@@ -134,14 +216,45 @@ class PixelVault {
|
|
|
134
216
|
displayOptions: { show: { operation: ['updateMetadata'] } },
|
|
135
217
|
description: 'ID of the image whose metadata to replace',
|
|
136
218
|
},
|
|
219
|
+
{
|
|
220
|
+
displayName: 'Video URL',
|
|
221
|
+
name: 'videoUrl',
|
|
222
|
+
type: 'string',
|
|
223
|
+
default: '',
|
|
224
|
+
required: true,
|
|
225
|
+
placeholder: 'https://example.com/video.mp4',
|
|
226
|
+
displayOptions: { show: { operation: ['importVideo'] } },
|
|
227
|
+
description: 'A public HTTPS URL that returns MP4 bytes. Authenticated sources must be downloaded in n8n first.',
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
displayName: 'Video ID',
|
|
231
|
+
name: 'videoId',
|
|
232
|
+
type: 'string',
|
|
233
|
+
default: '',
|
|
234
|
+
required: true,
|
|
235
|
+
placeholder: 'vid_abc123',
|
|
236
|
+
displayOptions: {
|
|
237
|
+
show: {
|
|
238
|
+
operation: [
|
|
239
|
+
'getVideo',
|
|
240
|
+
'optimizeVideo',
|
|
241
|
+
'enrichVideo',
|
|
242
|
+
'updateVideo',
|
|
243
|
+
'signVideo',
|
|
244
|
+
'deleteVideo',
|
|
245
|
+
],
|
|
246
|
+
},
|
|
247
|
+
},
|
|
248
|
+
description: 'Stable video asset ID. Reuse it to resume an asynchronous workflow.',
|
|
249
|
+
},
|
|
137
250
|
{
|
|
138
251
|
displayName: 'Metadata (JSON)',
|
|
139
252
|
name: 'metadata',
|
|
140
253
|
type: 'json',
|
|
141
254
|
default: '{}',
|
|
142
255
|
required: true,
|
|
143
|
-
displayOptions: { show: { operation: ['updateMetadata'] } },
|
|
144
|
-
description: 'The full metadata object to store. It replaces the existing metadata
|
|
256
|
+
displayOptions: { show: { operation: ['updateMetadata', 'updateVideo'] } },
|
|
257
|
+
description: 'The full metadata object to store. It replaces the existing metadata; {} clears it. Up to 50 top-level keys and 4 KB.',
|
|
145
258
|
},
|
|
146
259
|
{
|
|
147
260
|
displayName: 'Options',
|
|
@@ -149,28 +262,109 @@ class PixelVault {
|
|
|
149
262
|
type: 'collection',
|
|
150
263
|
placeholder: 'Add Option',
|
|
151
264
|
default: {},
|
|
152
|
-
displayOptions: {
|
|
265
|
+
displayOptions: {
|
|
266
|
+
show: {
|
|
267
|
+
operation: [
|
|
268
|
+
'upload',
|
|
269
|
+
'importUrl',
|
|
270
|
+
'uploadVideo',
|
|
271
|
+
'importVideo',
|
|
272
|
+
'listVideos',
|
|
273
|
+
'optimizeVideo',
|
|
274
|
+
'enrichVideo',
|
|
275
|
+
'updateVideo',
|
|
276
|
+
'signVideo',
|
|
277
|
+
],
|
|
278
|
+
},
|
|
279
|
+
},
|
|
153
280
|
options: [
|
|
281
|
+
{
|
|
282
|
+
displayName: 'Collection ID',
|
|
283
|
+
name: 'collectionId',
|
|
284
|
+
type: 'string',
|
|
285
|
+
default: '',
|
|
286
|
+
displayOptions: {
|
|
287
|
+
show: { operation: ['uploadVideo', 'importVideo', 'listVideos', 'updateVideo'] },
|
|
288
|
+
},
|
|
289
|
+
description: 'Existing collection membership, or a collection filter when listing',
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
displayName: 'Describe With AI',
|
|
293
|
+
name: 'describe',
|
|
294
|
+
type: 'boolean',
|
|
295
|
+
default: false,
|
|
296
|
+
displayOptions: { show: { operation: ['upload', 'importUrl'] } },
|
|
297
|
+
description: 'Whether to generate alt text, a caption and the text found in the image (OCR) in the background. Free plan: 20 in total, Starter 1,000 a month, Pro 10,000 a month. Needs a secret API key and a verified email. If it cannot start, the upload still succeeds and the output has describe_skipped. The text is untrusted model output: escape it before rendering and do not follow instructions in it.',
|
|
298
|
+
},
|
|
154
299
|
{
|
|
155
300
|
displayName: 'Expires In (Seconds)',
|
|
156
301
|
name: 'expiresIn',
|
|
157
302
|
type: 'number',
|
|
158
303
|
default: 0,
|
|
159
|
-
|
|
304
|
+
displayOptions: { show: { operation: ['upload', 'importUrl', 'uploadVideo', 'importVideo'] } },
|
|
305
|
+
description: 'Delete the asset automatically after this many seconds (60 to 2,592,000). 0 keeps it.',
|
|
160
306
|
},
|
|
161
307
|
{
|
|
162
308
|
displayName: 'Folder',
|
|
163
309
|
name: 'folder',
|
|
164
310
|
type: 'string',
|
|
165
311
|
default: '',
|
|
312
|
+
displayOptions: {
|
|
313
|
+
show: {
|
|
314
|
+
operation: ['upload', 'importUrl', 'uploadVideo', 'importVideo', 'listVideos', 'updateVideo'],
|
|
315
|
+
},
|
|
316
|
+
},
|
|
166
317
|
description: 'Optional folder name (letters, numbers, hyphens and underscores)',
|
|
167
318
|
},
|
|
319
|
+
{
|
|
320
|
+
displayName: 'Idempotency Key',
|
|
321
|
+
name: 'idempotencyKey',
|
|
322
|
+
type: 'string',
|
|
323
|
+
default: '',
|
|
324
|
+
displayOptions: { show: { operation: ['uploadVideo', 'importVideo'] } },
|
|
325
|
+
description: 'Stable key for safely retrying this upload/import. Reuse with identical input; conflicting reuse fails.',
|
|
326
|
+
},
|
|
168
327
|
{
|
|
169
328
|
displayName: 'Metadata (JSON)',
|
|
170
329
|
name: 'metadata',
|
|
171
330
|
type: 'json',
|
|
172
331
|
default: '',
|
|
173
|
-
|
|
332
|
+
displayOptions: {
|
|
333
|
+
show: { operation: ['upload', 'importUrl', 'uploadVideo', 'importVideo', 'listVideos'] },
|
|
334
|
+
},
|
|
335
|
+
description: 'Custom key/values to store or match, for example {"env": "prod"}. Up to 50 top-level keys and 4 KB.',
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
displayName: 'Optimize For Social',
|
|
339
|
+
name: 'socialReady',
|
|
340
|
+
type: 'boolean',
|
|
341
|
+
default: false,
|
|
342
|
+
displayOptions: { show: { operation: ['uploadVideo', 'importVideo'] } },
|
|
343
|
+
description: 'Whether to start social-ready H.264/AAC fast-start optimization after upload',
|
|
344
|
+
},
|
|
345
|
+
{
|
|
346
|
+
displayName: 'Page',
|
|
347
|
+
name: 'page',
|
|
348
|
+
type: 'number',
|
|
349
|
+
default: 1,
|
|
350
|
+
typeOptions: { minValue: 1 },
|
|
351
|
+
displayOptions: { show: { operation: ['listVideos'] } },
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
displayName: 'Per Page',
|
|
355
|
+
name: 'perPage',
|
|
356
|
+
type: 'number',
|
|
357
|
+
default: 20,
|
|
358
|
+
typeOptions: { minValue: 1, maxValue: 100 },
|
|
359
|
+
displayOptions: { show: { operation: ['listVideos'] } },
|
|
360
|
+
},
|
|
361
|
+
{
|
|
362
|
+
displayName: 'Signed URL Expiry (Seconds)',
|
|
363
|
+
name: 'signExpiresIn',
|
|
364
|
+
type: 'number',
|
|
365
|
+
default: 3600,
|
|
366
|
+
displayOptions: { show: { operation: ['uploadVideo', 'importVideo', 'signVideo'] } },
|
|
367
|
+
description: 'Private URL lifetime, from 60 to 2,592,000 seconds',
|
|
174
368
|
},
|
|
175
369
|
{
|
|
176
370
|
displayName: 'Visibility',
|
|
@@ -181,7 +375,33 @@ class PixelVault {
|
|
|
181
375
|
{ name: 'Private (Signed URL)', value: 'private' },
|
|
182
376
|
],
|
|
183
377
|
default: 'public',
|
|
184
|
-
|
|
378
|
+
displayOptions: { show: { operation: ['upload', 'importUrl', 'uploadVideo', 'importVideo'] } },
|
|
379
|
+
description: 'Private media is returned with time-limited signed URLs',
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
displayName: 'Wait For Completion',
|
|
383
|
+
name: 'waitForCompletion',
|
|
384
|
+
type: 'boolean',
|
|
385
|
+
default: false,
|
|
386
|
+
displayOptions: { show: { operation: ['optimizeVideo', 'enrichVideo'] } },
|
|
387
|
+
description: 'Whether to poll with bounded backoff. Leave off to return the asset and job IDs immediately and resume later with Get Video.',
|
|
388
|
+
},
|
|
389
|
+
{
|
|
390
|
+
displayName: 'Wait For Description',
|
|
391
|
+
name: 'waitForDescription',
|
|
392
|
+
type: 'boolean',
|
|
393
|
+
default: false,
|
|
394
|
+
displayOptions: { show: { operation: ['upload', 'importUrl'] } },
|
|
395
|
+
description: 'Whether to wait (up to about 40 seconds) for the AI description and include it in the output. Only used with Describe With AI.',
|
|
396
|
+
},
|
|
397
|
+
{
|
|
398
|
+
displayName: 'Wait Timeout (Seconds)',
|
|
399
|
+
name: 'waitTimeoutSeconds',
|
|
400
|
+
type: 'number',
|
|
401
|
+
default: 600,
|
|
402
|
+
typeOptions: { minValue: 1, maxValue: 3600 },
|
|
403
|
+
displayOptions: { show: { operation: ['optimizeVideo', 'enrichVideo'] } },
|
|
404
|
+
description: 'Local polling limit. Timing out does not cancel the server job.',
|
|
185
405
|
},
|
|
186
406
|
],
|
|
187
407
|
},
|
|
@@ -189,7 +409,7 @@ class PixelVault {
|
|
|
189
409
|
};
|
|
190
410
|
}
|
|
191
411
|
async execute() {
|
|
192
|
-
var _a, _b;
|
|
412
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
193
413
|
const items = this.getInputData();
|
|
194
414
|
const returnData = [];
|
|
195
415
|
const operation = this.getNodeParameter('operation', 0);
|
|
@@ -203,7 +423,7 @@ class PixelVault {
|
|
|
203
423
|
}
|
|
204
424
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), expiresError, { itemIndex: i });
|
|
205
425
|
}
|
|
206
|
-
const metadataSource = operation === 'updateMetadata'
|
|
426
|
+
const metadataSource = operation === 'updateMetadata' || operation === 'updateVideo'
|
|
207
427
|
? this.getNodeParameter('metadata', i, '{}')
|
|
208
428
|
: options.metadata;
|
|
209
429
|
const { metadata, error: metadataError } = parseMetadata(metadataSource);
|
|
@@ -228,6 +448,7 @@ class PixelVault {
|
|
|
228
448
|
...fieldsFromOptions(options),
|
|
229
449
|
...(expiresIn !== undefined && { expires_in: String(expiresIn) }),
|
|
230
450
|
...(metadata && Object.keys(metadata).length > 0 && { metadata: JSON.stringify(metadata) }),
|
|
451
|
+
...(options.describe && { describe: 'true' }),
|
|
231
452
|
});
|
|
232
453
|
requestOptions = {
|
|
233
454
|
method: 'POST',
|
|
@@ -243,6 +464,8 @@ class PixelVault {
|
|
|
243
464
|
body.expires_in = expiresIn;
|
|
244
465
|
if (metadata && Object.keys(metadata).length > 0)
|
|
245
466
|
body.metadata = metadata;
|
|
467
|
+
if (options.describe)
|
|
468
|
+
body.describe = true;
|
|
246
469
|
requestOptions = { method: 'POST', url: IMAGES_URL, body, json: true };
|
|
247
470
|
}
|
|
248
471
|
else if (operation === 'updateMetadata') {
|
|
@@ -254,17 +477,161 @@ class PixelVault {
|
|
|
254
477
|
json: true,
|
|
255
478
|
};
|
|
256
479
|
}
|
|
480
|
+
else if (operation === 'uploadVideo') {
|
|
481
|
+
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
|
|
482
|
+
const binaryData = this.helpers.assertBinaryData(i, binaryPropertyName);
|
|
483
|
+
const buffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
|
|
484
|
+
const headers = {
|
|
485
|
+
'Content-Type': 'video/mp4',
|
|
486
|
+
'Content-Length': String(buffer.length),
|
|
487
|
+
'X-PixelVault-Filename': encodeURIComponent((_b = binaryData.fileName) !== null && _b !== void 0 ? _b : 'video.mp4'),
|
|
488
|
+
};
|
|
489
|
+
if (options.visibility)
|
|
490
|
+
headers['X-PixelVault-Visibility'] = options.visibility;
|
|
491
|
+
if (expiresIn !== undefined)
|
|
492
|
+
headers['X-PixelVault-Expires-In'] = String(expiresIn);
|
|
493
|
+
if (options.folder)
|
|
494
|
+
headers['X-PixelVault-Folder'] = options.folder;
|
|
495
|
+
if (options.collectionId)
|
|
496
|
+
headers['X-PixelVault-Collection-Id'] = options.collectionId;
|
|
497
|
+
if (metadata && Object.keys(metadata).length > 0) {
|
|
498
|
+
headers['X-PixelVault-Metadata'] = JSON.stringify(metadata);
|
|
499
|
+
}
|
|
500
|
+
if (options.socialReady)
|
|
501
|
+
headers['X-PixelVault-Social-Ready'] = 'true';
|
|
502
|
+
if (options.signExpiresIn) {
|
|
503
|
+
headers['X-PixelVault-Sign-Expires-In'] = String(options.signExpiresIn);
|
|
504
|
+
}
|
|
505
|
+
if (options.idempotencyKey) {
|
|
506
|
+
headers['Idempotency-Key'] = options.idempotencyKey;
|
|
507
|
+
headers['X-PixelVault-Content-SHA256'] = (0, node_crypto_1.createHash)('sha256').update(buffer).digest('hex');
|
|
508
|
+
}
|
|
509
|
+
requestOptions = { method: 'POST', url: VIDEOS_URL, headers, body: buffer };
|
|
510
|
+
}
|
|
511
|
+
else if (operation === 'importVideo') {
|
|
512
|
+
const videoUrl = this.getNodeParameter('videoUrl', i);
|
|
513
|
+
const body = { url: videoUrl };
|
|
514
|
+
if (options.visibility)
|
|
515
|
+
body.visibility = options.visibility;
|
|
516
|
+
if (expiresIn !== undefined)
|
|
517
|
+
body.expires_in = expiresIn;
|
|
518
|
+
if (options.folder)
|
|
519
|
+
body.folder = options.folder;
|
|
520
|
+
if (options.collectionId)
|
|
521
|
+
body.collection_id = options.collectionId;
|
|
522
|
+
if (metadata && Object.keys(metadata).length > 0)
|
|
523
|
+
body.metadata = metadata;
|
|
524
|
+
if (options.socialReady)
|
|
525
|
+
body.social_ready = true;
|
|
526
|
+
if (options.signExpiresIn)
|
|
527
|
+
body.sign_expires_in = options.signExpiresIn;
|
|
528
|
+
requestOptions = {
|
|
529
|
+
method: 'POST',
|
|
530
|
+
url: VIDEOS_URL,
|
|
531
|
+
headers: options.idempotencyKey ? { 'Idempotency-Key': options.idempotencyKey } : {},
|
|
532
|
+
body,
|
|
533
|
+
json: true,
|
|
534
|
+
};
|
|
535
|
+
}
|
|
536
|
+
else if (operation === 'listVideos') {
|
|
537
|
+
const qs = {};
|
|
538
|
+
if (options.page)
|
|
539
|
+
qs.page = options.page;
|
|
540
|
+
if (options.perPage)
|
|
541
|
+
qs.per_page = options.perPage;
|
|
542
|
+
if (options.folder)
|
|
543
|
+
qs.folder = options.folder;
|
|
544
|
+
if (options.collectionId)
|
|
545
|
+
qs.collection_id = options.collectionId;
|
|
546
|
+
if (metadata && Object.keys(metadata).length > 0)
|
|
547
|
+
qs.metadata = JSON.stringify(metadata);
|
|
548
|
+
requestOptions = { method: 'GET', url: VIDEOS_URL, qs, json: true };
|
|
549
|
+
}
|
|
257
550
|
else {
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
551
|
+
const videoId = this.getNodeParameter('videoId', i, '');
|
|
552
|
+
const videoUrl = `${VIDEOS_URL}/${encodeURIComponent(videoId)}`;
|
|
553
|
+
if (operation === 'getVideo') {
|
|
554
|
+
requestOptions = { method: 'GET', url: videoUrl, json: true };
|
|
555
|
+
}
|
|
556
|
+
else if (operation === 'deleteVideo') {
|
|
557
|
+
requestOptions = { method: 'DELETE', url: videoUrl, json: true };
|
|
558
|
+
}
|
|
559
|
+
else if (operation === 'signVideo') {
|
|
560
|
+
requestOptions = {
|
|
561
|
+
method: 'POST',
|
|
562
|
+
url: `${videoUrl}/sign-url`,
|
|
563
|
+
body: options.signExpiresIn ? { expires_in: options.signExpiresIn } : {},
|
|
564
|
+
json: true,
|
|
565
|
+
};
|
|
566
|
+
}
|
|
567
|
+
else if (operation === 'updateVideo') {
|
|
568
|
+
const body = { metadata: metadata !== null && metadata !== void 0 ? metadata : {} };
|
|
569
|
+
if (options.folder !== undefined)
|
|
570
|
+
body.folder = options.folder || null;
|
|
571
|
+
if (options.collectionId !== undefined)
|
|
572
|
+
body.collection_id = options.collectionId || null;
|
|
573
|
+
requestOptions = { method: 'PATCH', url: videoUrl, body, json: true };
|
|
574
|
+
}
|
|
575
|
+
else if (operation === 'optimizeVideo' || operation === 'enrichVideo') {
|
|
576
|
+
const action = operation === 'optimizeVideo' ? 'optimize' : 'enrich';
|
|
577
|
+
requestOptions = { method: 'POST', url: `${videoUrl}/${action}`, json: true };
|
|
578
|
+
}
|
|
579
|
+
else {
|
|
580
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Unknown operation: ${operation}`, {
|
|
581
|
+
itemIndex: i,
|
|
582
|
+
});
|
|
583
|
+
}
|
|
261
584
|
}
|
|
262
585
|
const response = (await this.helpers.httpRequestWithAuthentication.call(this, 'pixelVaultApi', requestOptions));
|
|
263
586
|
const parsed = (typeof response === 'string' ? JSON.parse(response) : response);
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
}
|
|
587
|
+
let output;
|
|
588
|
+
if (operation === 'listVideos') {
|
|
589
|
+
output = { videos: (_c = parsed.data) !== null && _c !== void 0 ? _c : [], meta: (_d = parsed.meta) !== null && _d !== void 0 ? _d : {} };
|
|
590
|
+
}
|
|
591
|
+
else {
|
|
592
|
+
output = ((_e = parsed.data) !== null && _e !== void 0 ? _e : parsed);
|
|
593
|
+
}
|
|
594
|
+
const description = output.description;
|
|
595
|
+
if (options.describe &&
|
|
596
|
+
options.waitForDescription &&
|
|
597
|
+
operation !== 'updateMetadata' &&
|
|
598
|
+
typeof output.id === 'string' &&
|
|
599
|
+
(description === null || description === void 0 ? void 0 : description.status) === 'pending') {
|
|
600
|
+
const deadline = Date.now() + DESCRIBE_MAX_WAIT_MS;
|
|
601
|
+
for (;;) {
|
|
602
|
+
await (0, n8n_workflow_1.sleep)(DESCRIBE_POLL_MS);
|
|
603
|
+
const polled = (await this.helpers.httpRequestWithAuthentication.call(this, 'pixelVaultApi', { method: 'GET', url: `${IMAGES_URL}/${encodeURIComponent(output.id)}`, json: true }));
|
|
604
|
+
const polledData = (typeof polled === 'string' ? JSON.parse(polled) : polled).data;
|
|
605
|
+
output.description = (_f = polledData === null || polledData === void 0 ? void 0 : polledData.description) !== null && _f !== void 0 ? _f : null;
|
|
606
|
+
if (((_g = output.description) === null || _g === void 0 ? void 0 : _g.status) !== 'pending')
|
|
607
|
+
break;
|
|
608
|
+
if (Date.now() >= deadline)
|
|
609
|
+
break;
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
if ((operation === 'optimizeVideo' || operation === 'enrichVideo') &&
|
|
613
|
+
options.waitForCompletion &&
|
|
614
|
+
typeof output.id === 'string') {
|
|
615
|
+
const pollingVideoId = output.id;
|
|
616
|
+
const deadline = Date.now() + ((_h = options.waitTimeoutSeconds) !== null && _h !== void 0 ? _h : 600) * 1000;
|
|
617
|
+
let delay = VIDEO_POLL_INITIAL_MS;
|
|
618
|
+
const jobField = operation === 'enrichVideo' ? 'enrichment' : 'social_optimization';
|
|
619
|
+
for (;;) {
|
|
620
|
+
const job = output[jobField];
|
|
621
|
+
if ((job === null || job === void 0 ? void 0 : job.status) !== 'pending' && (job === null || job === void 0 ? void 0 : job.status) !== 'processing')
|
|
622
|
+
break;
|
|
623
|
+
const remaining = deadline - Date.now();
|
|
624
|
+
if (remaining <= 0) {
|
|
625
|
+
output.wait_timed_out = true;
|
|
626
|
+
break;
|
|
627
|
+
}
|
|
628
|
+
await (0, n8n_workflow_1.sleep)(Math.min(delay, remaining));
|
|
629
|
+
const polled = (await this.helpers.httpRequestWithAuthentication.call(this, 'pixelVaultApi', { method: 'GET', url: `${VIDEOS_URL}/${encodeURIComponent(pollingVideoId)}`, json: true }));
|
|
630
|
+
output = (typeof polled === 'string' ? JSON.parse(polled) : polled).data;
|
|
631
|
+
delay = Math.min(Math.ceil(delay * 1.5), VIDEO_POLL_MAX_MS);
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
returnData.push({ json: output, pairedItem: { item: i } });
|
|
268
635
|
}
|
|
269
636
|
catch (error) {
|
|
270
637
|
if (this.continueOnFail()) {
|