n8n-nodes-pixelvault 0.4.0 → 0.6.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), 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.
3
+ An [n8n](https://n8n.io/) community node for [PixelVault](https://pixelvault.dev), media hosting built for automations and AI agents. Upload images or video, or host and transcribe audio, then pass stable CDN URLs and asset/job IDs to later nodes.
4
4
 
5
5
  - [Installation](#installation)
6
6
  - [Operations](#operations)
@@ -27,11 +27,18 @@ Follow the [community nodes installation guide](https://docs.n8n.io/integrations
27
27
  | **List Videos** | Discovers videos by page, folder, collection, or metadata. |
28
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
29
  | **Update Video** / **Sign Video URLs** / **Delete Video** | Updates metadata and organization, refreshes private original/artifact URLs, or deletes the video and derivatives. |
30
+ | **Upload Audio** / **Import Audio From URL** | Hosts original MP3, PCM/float WAV, AAC M4A, or Opus/Vorbis OGG with byte validation, privacy, TTL, metadata, folder, collection, and retry safety. |
31
+ | **Enrich Audio** | Starts or resumes transcription. Return stable asset/job IDs immediately or poll with bounded backoff for text, WebVTT, and timestamped JSON. |
32
+ | **Get Audio Status and Artifacts** / **List Audio** / **Update Audio** / **Sign Audio URLs** / **Delete Audio** | Resumes, discovers, and manages audio plus transcript lifecycle by stable `aud_` ID. Private links never fall back to public. |
30
33
 
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.
34
+ Image, video, and audio uploads accept folder, public/private visibility, deletion TTL, and custom metadata. Video
35
+ and audio uploads also accept collection membership, an idempotency key, and private URL expiry.
32
36
 
33
37
  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.
38
+ Videos expose `id`, `original_url`, `social_optimization`, and `enrichment`; transcript/storyboard URLs appear
39
+ only after those artifacts exist. Audio exposes `id`, `original_url`, detected container/codec, duration, sample
40
+ rate, channels, `enrichment.job_id`, status, and only transcript URLs that exist. Private URLs are signed and expire
41
+ independently from asset deletion.
35
42
 
36
43
  ## Credentials
37
44
 
@@ -54,12 +61,22 @@ Resume-safe asynchronous video flow:
54
61
 
55
62
  The node can also wait in one execution with bounded backoff. Keep IDs when using that mode: timeout only stops local polling.
56
63
 
64
+ Resume-safe audio transcription flow:
65
+
66
+ 1. Download MP3/WAV/M4A/OGG into an n8n binary property, or retain a public HTTPS source URL.
67
+ 2. Run **Upload Audio** or **Import Audio From URL** with an idempotency key such as `{{ $execution.id }}:{{ $itemIndex }}`. Store the returned `aud_` ID.
68
+ 3. Run **Enrich Audio** with **Wait For Completion** off. Persist its `enrichment.job_id` with the asset ID.
69
+ 4. A later execution uses **Get Audio Status and Artifacts**. Wait and repeat while status is `pending` or `processing`; route `complete` to text/VTT/JSON consumers and `failed` to error handling.
70
+
71
+ The node can instead wait inside **Enrich Audio** with bounded backoff. A timeout adds `wait_timed_out: true`; it does not cancel the server job.
72
+
57
73
  - The binary field name defaults to `data`.
58
74
  - 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.
75
+ - Audio originals and enrichment sources are limited to the approved global maximum of 25,000,000 bytes; enrichment additionally accepts up to 10 minutes. The file ceiling is not a plan allowance. PixelVault validates actual container/codec bytes and preserves the original without transcoding.
59
76
  - 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.
77
+ - Video optimization accepts sources up to 100 MB and 60 seconds; video enrichment accepts sources from 1 second through 10 minutes and up to 100 MB. Audio and video enrichment share the existing allowance. API quota and unsupported-source errors are returned without rewriting.
78
+ - Public assets are stable CDN URLs. Private assets never fall back to public; refresh bearer URLs with **Sign Video URLs** or **Sign Audio URLs**.
79
+ - Hosting does not convert images or audio for a destination. Audio editing, conversion, HLS/DASH, summaries, chapters, show notes, promo copy, and storyboards remain unsupported.
63
80
 
64
81
  ## Compatibility
65
82
 
@@ -5,6 +5,8 @@ const node_crypto_1 = require("node:crypto");
5
5
  const n8n_workflow_1 = require("n8n-workflow");
6
6
  const IMAGES_URL = 'https://api.pixelvault.dev/v1/images';
7
7
  const VIDEOS_URL = 'https://api.pixelvault.dev/v1/videos';
8
+ const AUDIO_URL = 'https://api.pixelvault.dev/v1/audio';
9
+ const AUDIO_MAX_BYTES = 25000000;
8
10
  const MIN_EXPIRES_IN = 60;
9
11
  const MAX_EXPIRES_IN = 2592000;
10
12
  const DESCRIBE_POLL_MS = 2000;
@@ -34,7 +36,7 @@ function parseExpiresIn(value) {
34
36
  const seconds = Number(value);
35
37
  if (!Number.isInteger(seconds) || seconds < MIN_EXPIRES_IN || seconds > MAX_EXPIRES_IN) {
36
38
  return {
37
- error: `Expires In must be 0 (keep the image) or a whole number of seconds between ${MIN_EXPIRES_IN} and ${MAX_EXPIRES_IN}.`,
39
+ error: `Expires In must be 0 (keep the asset) or a whole number of seconds between ${MIN_EXPIRES_IN} and ${MAX_EXPIRES_IN}.`,
38
40
  };
39
41
  }
40
42
  return { seconds };
@@ -47,6 +49,28 @@ function fieldsFromOptions(options) {
47
49
  fields.visibility = options.visibility;
48
50
  return fields;
49
51
  }
52
+ function audioContentType(fileName, mimeType) {
53
+ const normalized = mimeType === null || mimeType === void 0 ? void 0 : mimeType.toLowerCase();
54
+ if (normalized === 'audio/mpeg' || normalized === 'audio/mp3')
55
+ return 'audio/mpeg';
56
+ if (normalized === 'audio/wav' || normalized === 'audio/x-wav')
57
+ return 'audio/wav';
58
+ if (normalized === 'audio/mp4' || normalized === 'audio/m4a' || normalized === 'audio/x-m4a') {
59
+ return 'audio/mp4';
60
+ }
61
+ if (normalized === 'audio/ogg' || normalized === 'application/ogg')
62
+ return 'audio/ogg';
63
+ const extension = fileName.slice(fileName.lastIndexOf('.') + 1).toLowerCase();
64
+ if (extension === 'mp3')
65
+ return 'audio/mpeg';
66
+ if (extension === 'wav')
67
+ return 'audio/wav';
68
+ if (extension === 'm4a')
69
+ return 'audio/mp4';
70
+ if (extension === 'ogg')
71
+ return 'audio/ogg';
72
+ return undefined;
73
+ }
50
74
  function buildMultipart(file, fields) {
51
75
  const boundary = `----n8nPixelVault${Date.now().toString(16)}${Math.random().toString(16).slice(2)}`;
52
76
  const safeName = file.fileName.replace(/["\r\n]/g, '_');
@@ -71,7 +95,7 @@ class PixelVault {
71
95
  group: ['transform'],
72
96
  version: 1,
73
97
  subtitle: '={{$parameter["operation"]}}',
74
- description: 'Host images and videos and get CDN URLs',
98
+ description: 'Host images, video, and audio and get CDN URLs',
75
99
  defaults: {
76
100
  name: 'PixelVault',
77
101
  },
@@ -90,6 +114,7 @@ class PixelVault {
90
114
  type: 'options',
91
115
  noDataExpression: true,
92
116
  options: [
117
+ { name: 'Audio', value: 'audio' },
93
118
  { name: 'Image', value: 'image' },
94
119
  { name: 'Video', value: 'video' },
95
120
  ],
@@ -123,6 +148,64 @@ class PixelVault {
123
148
  ],
124
149
  default: 'upload',
125
150
  },
151
+ {
152
+ displayName: 'Operation',
153
+ name: 'operation',
154
+ type: 'options',
155
+ noDataExpression: true,
156
+ displayOptions: { show: { resource: ['audio'] } },
157
+ options: [
158
+ {
159
+ name: 'Delete Audio',
160
+ value: 'deleteAudio',
161
+ description: 'Permanently delete an audio original',
162
+ action: 'Delete audio',
163
+ },
164
+ {
165
+ name: 'Enrich Audio',
166
+ value: 'enrichAudio',
167
+ description: 'Start or resume transcription, optionally waiting for text, WebVTT, and timestamped JSON',
168
+ action: 'Enrich audio',
169
+ },
170
+ {
171
+ name: 'Get Audio Status and Artifacts',
172
+ value: 'getAudio',
173
+ description: 'Resume from a stable ID and get the original, transcription status, and available transcript URLs',
174
+ action: 'Get audio status and artifacts',
175
+ },
176
+ {
177
+ name: 'Import Audio From URL',
178
+ value: 'importAudio',
179
+ description: 'Securely import MP3, WAV, M4A, or OGG from a public URL',
180
+ action: 'Import audio from a URL',
181
+ },
182
+ {
183
+ name: 'List Audio',
184
+ value: 'listAudio',
185
+ description: 'List audio with optional folder, collection, and metadata filters',
186
+ action: 'List audio',
187
+ },
188
+ {
189
+ name: 'Sign Audio URLs',
190
+ value: 'signAudio',
191
+ description: 'Mint fresh time-limited URLs for a private audio original and available transcripts',
192
+ action: 'Create signed audio links',
193
+ },
194
+ {
195
+ name: 'Update Audio',
196
+ value: 'updateAudio',
197
+ description: 'Replace audio metadata, folder, and collection membership',
198
+ action: 'Update audio',
199
+ },
200
+ {
201
+ name: 'Upload Audio',
202
+ value: 'uploadAudio',
203
+ description: 'Upload original MP3, WAV, M4A, or OGG binary data',
204
+ action: 'Upload audio',
205
+ },
206
+ ],
207
+ default: 'uploadAudio',
208
+ },
126
209
  {
127
210
  displayName: 'Operation',
128
211
  name: 'operation',
@@ -193,8 +276,8 @@ class PixelVault {
193
276
  type: 'string',
194
277
  default: 'data',
195
278
  required: true,
196
- displayOptions: { show: { operation: ['upload', 'uploadVideo'] } },
197
- description: 'Name of the binary property that holds the image or MP4 to upload',
279
+ displayOptions: { show: { operation: ['upload', 'uploadVideo', 'uploadAudio'] } },
280
+ description: 'Name of the binary property that holds the image, MP4, or audio file to upload',
198
281
  },
199
282
  {
200
283
  displayName: 'Image URL',
@@ -216,6 +299,30 @@ class PixelVault {
216
299
  displayOptions: { show: { operation: ['updateMetadata'] } },
217
300
  description: 'ID of the image whose metadata to replace',
218
301
  },
302
+ {
303
+ displayName: 'Audio URL',
304
+ name: 'audioUrl',
305
+ type: 'string',
306
+ default: '',
307
+ required: true,
308
+ placeholder: 'https://example.com/audio.mp3',
309
+ displayOptions: { show: { operation: ['importAudio'] } },
310
+ description: 'A public HTTP(S) URL that returns MP3, WAV, M4A, or OGG bytes. Authenticated sources must be downloaded in n8n first.',
311
+ },
312
+ {
313
+ displayName: 'Audio ID',
314
+ name: 'audioId',
315
+ type: 'string',
316
+ default: '',
317
+ required: true,
318
+ placeholder: 'aud_abc123',
319
+ displayOptions: {
320
+ show: {
321
+ operation: ['getAudio', 'enrichAudio', 'updateAudio', 'signAudio', 'deleteAudio'],
322
+ },
323
+ },
324
+ description: 'Stable audio asset ID',
325
+ },
219
326
  {
220
327
  displayName: 'Video URL',
221
328
  name: 'videoUrl',
@@ -253,7 +360,7 @@ class PixelVault {
253
360
  type: 'json',
254
361
  default: '{}',
255
362
  required: true,
256
- displayOptions: { show: { operation: ['updateMetadata', 'updateVideo'] } },
363
+ displayOptions: { show: { operation: ['updateMetadata', 'updateVideo', 'updateAudio'] } },
257
364
  description: 'The full metadata object to store. It replaces the existing metadata; {} clears it. Up to 50 top-level keys and 4 KB.',
258
365
  },
259
366
  {
@@ -268,6 +375,11 @@ class PixelVault {
268
375
  'upload',
269
376
  'importUrl',
270
377
  'uploadVideo',
378
+ 'uploadAudio',
379
+ 'importAudio',
380
+ 'listAudio',
381
+ 'updateAudio',
382
+ 'signAudio',
271
383
  'importVideo',
272
384
  'listVideos',
273
385
  'optimizeVideo',
@@ -284,7 +396,7 @@ class PixelVault {
284
396
  type: 'string',
285
397
  default: '',
286
398
  displayOptions: {
287
- show: { operation: ['uploadVideo', 'importVideo', 'listVideos', 'updateVideo'] },
399
+ show: { operation: ['uploadVideo', 'importVideo', 'listVideos', 'updateVideo', 'uploadAudio', 'importAudio', 'listAudio', 'updateAudio'] },
288
400
  },
289
401
  description: 'Existing collection membership, or a collection filter when listing',
290
402
  },
@@ -301,7 +413,7 @@ class PixelVault {
301
413
  name: 'expiresIn',
302
414
  type: 'number',
303
415
  default: 0,
304
- displayOptions: { show: { operation: ['upload', 'importUrl', 'uploadVideo', 'importVideo'] } },
416
+ displayOptions: { show: { operation: ['upload', 'importUrl', 'uploadVideo', 'importVideo', 'uploadAudio', 'importAudio'] } },
305
417
  description: 'Delete the asset automatically after this many seconds (60 to 2,592,000). 0 keeps it.',
306
418
  },
307
419
  {
@@ -311,7 +423,7 @@ class PixelVault {
311
423
  default: '',
312
424
  displayOptions: {
313
425
  show: {
314
- operation: ['upload', 'importUrl', 'uploadVideo', 'importVideo', 'listVideos', 'updateVideo'],
426
+ operation: ['upload', 'importUrl', 'uploadVideo', 'importVideo', 'listVideos', 'updateVideo', 'uploadAudio', 'importAudio', 'listAudio', 'updateAudio'],
315
427
  },
316
428
  },
317
429
  description: 'Optional folder name (letters, numbers, hyphens and underscores)',
@@ -321,7 +433,7 @@ class PixelVault {
321
433
  name: 'idempotencyKey',
322
434
  type: 'string',
323
435
  default: '',
324
- displayOptions: { show: { operation: ['uploadVideo', 'importVideo'] } },
436
+ displayOptions: { show: { operation: ['uploadVideo', 'importVideo', 'uploadAudio', 'importAudio'] } },
325
437
  description: 'Stable key for safely retrying this upload/import. Reuse with identical input; conflicting reuse fails.',
326
438
  },
327
439
  {
@@ -330,7 +442,7 @@ class PixelVault {
330
442
  type: 'json',
331
443
  default: '',
332
444
  displayOptions: {
333
- show: { operation: ['upload', 'importUrl', 'uploadVideo', 'importVideo', 'listVideos'] },
445
+ show: { operation: ['upload', 'importUrl', 'uploadVideo', 'importVideo', 'listVideos', 'uploadAudio', 'importAudio', 'listAudio'] },
334
446
  },
335
447
  description: 'Custom key/values to store or match, for example {"env": "prod"}. Up to 50 top-level keys and 4 KB.',
336
448
  },
@@ -348,7 +460,7 @@ class PixelVault {
348
460
  type: 'number',
349
461
  default: 1,
350
462
  typeOptions: { minValue: 1 },
351
- displayOptions: { show: { operation: ['listVideos'] } },
463
+ displayOptions: { show: { operation: ['listVideos', 'listAudio'] } },
352
464
  },
353
465
  {
354
466
  displayName: 'Per Page',
@@ -356,14 +468,14 @@ class PixelVault {
356
468
  type: 'number',
357
469
  default: 20,
358
470
  typeOptions: { minValue: 1, maxValue: 100 },
359
- displayOptions: { show: { operation: ['listVideos'] } },
471
+ displayOptions: { show: { operation: ['listVideos', 'listAudio'] } },
360
472
  },
361
473
  {
362
474
  displayName: 'Signed URL Expiry (Seconds)',
363
475
  name: 'signExpiresIn',
364
476
  type: 'number',
365
477
  default: 3600,
366
- displayOptions: { show: { operation: ['uploadVideo', 'importVideo', 'signVideo'] } },
478
+ displayOptions: { show: { operation: ['uploadVideo', 'importVideo', 'signVideo', 'uploadAudio', 'importAudio', 'signAudio'] } },
367
479
  description: 'Private URL lifetime, from 60 to 2,592,000 seconds',
368
480
  },
369
481
  {
@@ -375,7 +487,7 @@ class PixelVault {
375
487
  { name: 'Private (Signed URL)', value: 'private' },
376
488
  ],
377
489
  default: 'public',
378
- displayOptions: { show: { operation: ['upload', 'importUrl', 'uploadVideo', 'importVideo'] } },
490
+ displayOptions: { show: { operation: ['upload', 'importUrl', 'uploadVideo', 'importVideo', 'uploadAudio', 'importAudio'] } },
379
491
  description: 'Private media is returned with time-limited signed URLs',
380
492
  },
381
493
  {
@@ -383,8 +495,8 @@ class PixelVault {
383
495
  name: 'waitForCompletion',
384
496
  type: 'boolean',
385
497
  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.',
498
+ displayOptions: { show: { operation: ['optimizeVideo', 'enrichVideo', 'enrichAudio'] } },
499
+ description: 'Whether to poll with bounded backoff. Leave off to return asset/job IDs immediately and resume later with the corresponding Get operation.',
388
500
  },
389
501
  {
390
502
  displayName: 'Wait For Description',
@@ -400,7 +512,7 @@ class PixelVault {
400
512
  type: 'number',
401
513
  default: 600,
402
514
  typeOptions: { minValue: 1, maxValue: 3600 },
403
- displayOptions: { show: { operation: ['optimizeVideo', 'enrichVideo'] } },
515
+ displayOptions: { show: { operation: ['optimizeVideo', 'enrichVideo', 'enrichAudio'] } },
404
516
  description: 'Local polling limit. Timing out does not cancel the server job.',
405
517
  },
406
518
  ],
@@ -409,7 +521,7 @@ class PixelVault {
409
521
  };
410
522
  }
411
523
  async execute() {
412
- var _a, _b, _c, _d, _e, _f, _g, _h;
524
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
413
525
  const items = this.getInputData();
414
526
  const returnData = [];
415
527
  const operation = this.getNodeParameter('operation', 0);
@@ -423,7 +535,7 @@ class PixelVault {
423
535
  }
424
536
  throw new n8n_workflow_1.NodeOperationError(this.getNode(), expiresError, { itemIndex: i });
425
537
  }
426
- const metadataSource = operation === 'updateMetadata' || operation === 'updateVideo'
538
+ const metadataSource = operation === 'updateMetadata' || operation === 'updateVideo' || operation === 'updateAudio'
427
539
  ? this.getNodeParameter('metadata', i, '{}')
428
540
  : options.metadata;
429
541
  const { metadata, error: metadataError } = parseMetadata(metadataSource);
@@ -477,6 +589,113 @@ class PixelVault {
477
589
  json: true,
478
590
  };
479
591
  }
592
+ else if (operation === 'uploadAudio') {
593
+ const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
594
+ const binaryData = this.helpers.assertBinaryData(i, binaryPropertyName);
595
+ const buffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
596
+ if (buffer.length > AUDIO_MAX_BYTES) {
597
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Audio originals are limited to the approved global maximum of 25,000,000 bytes. This is not a plan allowance.', { itemIndex: i });
598
+ }
599
+ const filename = (_b = binaryData.fileName) !== null && _b !== void 0 ? _b : 'audio.mp3';
600
+ const contentType = audioContentType(filename, binaryData.mimeType);
601
+ if (!contentType) {
602
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Audio binary data must be MP3, WAV, M4A, or OGG. Set a supported filename or MIME type.', { itemIndex: i });
603
+ }
604
+ const headers = {
605
+ 'Content-Type': contentType,
606
+ 'Content-Length': String(buffer.length),
607
+ 'X-PixelVault-Filename': encodeURIComponent(filename),
608
+ };
609
+ if (options.visibility)
610
+ headers['X-PixelVault-Visibility'] = options.visibility;
611
+ if (expiresIn !== undefined)
612
+ headers['X-PixelVault-Expires-In'] = String(expiresIn);
613
+ if (options.folder)
614
+ headers['X-PixelVault-Folder'] = options.folder;
615
+ if (options.collectionId)
616
+ headers['X-PixelVault-Collection-Id'] = options.collectionId;
617
+ if (metadata && Object.keys(metadata).length > 0) {
618
+ headers['X-PixelVault-Metadata'] = JSON.stringify(metadata);
619
+ }
620
+ if (options.signExpiresIn) {
621
+ headers['X-PixelVault-Sign-Expires-In'] = String(options.signExpiresIn);
622
+ }
623
+ if (options.idempotencyKey) {
624
+ headers['Idempotency-Key'] = options.idempotencyKey;
625
+ headers['X-PixelVault-Content-SHA256'] = (0, node_crypto_1.createHash)('sha256').update(buffer).digest('hex');
626
+ }
627
+ requestOptions = { method: 'POST', url: AUDIO_URL, headers, body: buffer };
628
+ }
629
+ else if (operation === 'importAudio') {
630
+ const audioUrl = this.getNodeParameter('audioUrl', i);
631
+ const body = { url: audioUrl };
632
+ if (options.visibility)
633
+ body.visibility = options.visibility;
634
+ if (expiresIn !== undefined)
635
+ body.expires_in = expiresIn;
636
+ if (options.folder)
637
+ body.folder = options.folder;
638
+ if (options.collectionId)
639
+ body.collection_id = options.collectionId;
640
+ if (metadata && Object.keys(metadata).length > 0)
641
+ body.metadata = metadata;
642
+ if (options.signExpiresIn)
643
+ body.sign_expires_in = options.signExpiresIn;
644
+ requestOptions = {
645
+ method: 'POST',
646
+ url: AUDIO_URL,
647
+ headers: options.idempotencyKey ? { 'Idempotency-Key': options.idempotencyKey } : {},
648
+ body,
649
+ json: true,
650
+ };
651
+ }
652
+ else if (operation === 'listAudio') {
653
+ const qs = {};
654
+ if (options.page)
655
+ qs.page = options.page;
656
+ if (options.perPage)
657
+ qs.per_page = options.perPage;
658
+ if (options.folder)
659
+ qs.folder = options.folder;
660
+ if (options.collectionId)
661
+ qs.collection_id = options.collectionId;
662
+ if (metadata && Object.keys(metadata).length > 0)
663
+ qs.metadata = JSON.stringify(metadata);
664
+ requestOptions = { method: 'GET', url: AUDIO_URL, qs, json: true };
665
+ }
666
+ else if (operation === 'getAudio' ||
667
+ operation === 'deleteAudio' ||
668
+ operation === 'signAudio' ||
669
+ operation === 'updateAudio' ||
670
+ operation === 'enrichAudio') {
671
+ const audioId = this.getNodeParameter('audioId', i);
672
+ const audioUrl = `${AUDIO_URL}/${encodeURIComponent(audioId)}`;
673
+ if (operation === 'getAudio') {
674
+ requestOptions = { method: 'GET', url: audioUrl, json: true };
675
+ }
676
+ else if (operation === 'deleteAudio') {
677
+ requestOptions = { method: 'DELETE', url: audioUrl, json: true };
678
+ }
679
+ else if (operation === 'signAudio') {
680
+ requestOptions = {
681
+ method: 'POST',
682
+ url: `${audioUrl}/sign-url`,
683
+ body: options.signExpiresIn ? { expires_in: options.signExpiresIn } : {},
684
+ json: true,
685
+ };
686
+ }
687
+ else if (operation === 'enrichAudio') {
688
+ requestOptions = { method: 'POST', url: `${audioUrl}/enrich`, json: true };
689
+ }
690
+ else {
691
+ const body = { metadata: metadata !== null && metadata !== void 0 ? metadata : {} };
692
+ if (options.folder !== undefined)
693
+ body.folder = options.folder || null;
694
+ if (options.collectionId !== undefined)
695
+ body.collection_id = options.collectionId || null;
696
+ requestOptions = { method: 'PATCH', url: audioUrl, body, json: true };
697
+ }
698
+ }
480
699
  else if (operation === 'uploadVideo') {
481
700
  const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
482
701
  const binaryData = this.helpers.assertBinaryData(i, binaryPropertyName);
@@ -484,7 +703,7 @@ class PixelVault {
484
703
  const headers = {
485
704
  'Content-Type': 'video/mp4',
486
705
  'Content-Length': String(buffer.length),
487
- 'X-PixelVault-Filename': encodeURIComponent((_b = binaryData.fileName) !== null && _b !== void 0 ? _b : 'video.mp4'),
706
+ 'X-PixelVault-Filename': encodeURIComponent((_c = binaryData.fileName) !== null && _c !== void 0 ? _c : 'video.mp4'),
488
707
  };
489
708
  if (options.visibility)
490
709
  headers['X-PixelVault-Visibility'] = options.visibility;
@@ -586,10 +805,13 @@ class PixelVault {
586
805
  const parsed = (typeof response === 'string' ? JSON.parse(response) : response);
587
806
  let output;
588
807
  if (operation === 'listVideos') {
589
- output = { videos: (_c = parsed.data) !== null && _c !== void 0 ? _c : [], meta: (_d = parsed.meta) !== null && _d !== void 0 ? _d : {} };
808
+ output = { videos: (_d = parsed.data) !== null && _d !== void 0 ? _d : [], meta: (_e = parsed.meta) !== null && _e !== void 0 ? _e : {} };
809
+ }
810
+ else if (operation === 'listAudio') {
811
+ output = { audio: (_f = parsed.data) !== null && _f !== void 0 ? _f : [], meta: (_g = parsed.meta) !== null && _g !== void 0 ? _g : {} };
590
812
  }
591
813
  else {
592
- output = ((_e = parsed.data) !== null && _e !== void 0 ? _e : parsed);
814
+ output = ((_h = parsed.data) !== null && _h !== void 0 ? _h : parsed);
593
815
  }
594
816
  const description = output.description;
595
817
  if (options.describe &&
@@ -602,20 +824,22 @@ class PixelVault {
602
824
  await (0, n8n_workflow_1.sleep)(DESCRIBE_POLL_MS);
603
825
  const polled = (await this.helpers.httpRequestWithAuthentication.call(this, 'pixelVaultApi', { method: 'GET', url: `${IMAGES_URL}/${encodeURIComponent(output.id)}`, json: true }));
604
826
  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')
827
+ output.description = (_j = polledData === null || polledData === void 0 ? void 0 : polledData.description) !== null && _j !== void 0 ? _j : null;
828
+ if (((_k = output.description) === null || _k === void 0 ? void 0 : _k.status) !== 'pending')
607
829
  break;
608
830
  if (Date.now() >= deadline)
609
831
  break;
610
832
  }
611
833
  }
612
- if ((operation === 'optimizeVideo' || operation === 'enrichVideo') &&
834
+ if ((operation === 'optimizeVideo' || operation === 'enrichVideo' || operation === 'enrichAudio') &&
613
835
  options.waitForCompletion &&
614
836
  typeof output.id === 'string') {
615
- const pollingVideoId = output.id;
616
- const deadline = Date.now() + ((_h = options.waitTimeoutSeconds) !== null && _h !== void 0 ? _h : 600) * 1000;
837
+ const pollingId = output.id;
838
+ const deadline = Date.now() + ((_l = options.waitTimeoutSeconds) !== null && _l !== void 0 ? _l : 600) * 1000;
617
839
  let delay = VIDEO_POLL_INITIAL_MS;
618
- const jobField = operation === 'enrichVideo' ? 'enrichment' : 'social_optimization';
840
+ const isAudioEnrichment = operation === 'enrichAudio';
841
+ const jobField = operation === 'optimizeVideo' ? 'social_optimization' : 'enrichment';
842
+ const pollUrl = isAudioEnrichment ? AUDIO_URL : VIDEOS_URL;
619
843
  for (;;) {
620
844
  const job = output[jobField];
621
845
  if ((job === null || job === void 0 ? void 0 : job.status) !== 'pending' && (job === null || job === void 0 ? void 0 : job.status) !== 'processing')
@@ -626,7 +850,7 @@ class PixelVault {
626
850
  break;
627
851
  }
628
852
  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 }));
853
+ const polled = (await this.helpers.httpRequestWithAuthentication.call(this, 'pixelVaultApi', { method: 'GET', url: `${pollUrl}/${encodeURIComponent(pollingId)}`, json: true }));
630
854
  output = (typeof polled === 'string' ? JSON.parse(polled) : polled).data;
631
855
  delay = Math.min(Math.ceil(delay * 1.5), VIDEO_POLL_MAX_MS);
632
856
  }