n8n-nodes-cloudinary 0.0.9 → 0.1.1

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 (118) hide show
  1. package/README.md +51 -0
  2. package/dist/credentials/CloudinaryApi.credentials.js +16 -0
  3. package/dist/credentials/CloudinaryApi.credentials.js.map +1 -1
  4. package/dist/nodes/Cloudinary/Cloudinary.node.d.ts +0 -1
  5. package/dist/nodes/Cloudinary/Cloudinary.node.js +26 -707
  6. package/dist/nodes/Cloudinary/Cloudinary.node.js.map +1 -1
  7. package/dist/nodes/Cloudinary/Cloudinary.node.json +5 -1
  8. package/dist/nodes/Cloudinary/cloudinary.utils.d.ts +34 -0
  9. package/dist/nodes/Cloudinary/cloudinary.utils.js +114 -3
  10. package/dist/nodes/Cloudinary/cloudinary.utils.js.map +1 -1
  11. package/dist/nodes/Cloudinary/descriptions/admin/getTags.fields.d.ts +2 -0
  12. package/dist/nodes/Cloudinary/descriptions/admin/getTags.fields.js +64 -0
  13. package/dist/nodes/Cloudinary/descriptions/admin/getTags.fields.js.map +1 -0
  14. package/dist/nodes/Cloudinary/descriptions/admin/search.fields.d.ts +2 -0
  15. package/dist/nodes/Cloudinary/descriptions/admin/search.fields.js +119 -0
  16. package/dist/nodes/Cloudinary/descriptions/admin/search.fields.js.map +1 -0
  17. package/dist/nodes/Cloudinary/descriptions/asset.fields.d.ts +2 -0
  18. package/dist/nodes/Cloudinary/descriptions/asset.fields.js +357 -0
  19. package/dist/nodes/Cloudinary/descriptions/asset.fields.js.map +1 -0
  20. package/dist/nodes/Cloudinary/descriptions/index.d.ts +2 -0
  21. package/dist/nodes/Cloudinary/descriptions/index.js +22 -0
  22. package/dist/nodes/Cloudinary/descriptions/index.js.map +1 -0
  23. package/dist/nodes/Cloudinary/descriptions/resource.d.ts +2 -0
  24. package/dist/nodes/Cloudinary/descriptions/resource.js +267 -0
  25. package/dist/nodes/Cloudinary/descriptions/resource.js.map +1 -0
  26. package/dist/nodes/Cloudinary/descriptions/transform.fields.d.ts +2 -0
  27. package/dist/nodes/Cloudinary/descriptions/transform.fields.js +742 -0
  28. package/dist/nodes/Cloudinary/descriptions/transform.fields.js.map +1 -0
  29. package/dist/nodes/Cloudinary/descriptions/updateAsset.fields.d.ts +2 -0
  30. package/dist/nodes/Cloudinary/descriptions/updateAsset.fields.js +262 -0
  31. package/dist/nodes/Cloudinary/descriptions/updateAsset.fields.js.map +1 -0
  32. package/dist/nodes/Cloudinary/descriptions/upload.fields.d.ts +2 -0
  33. package/dist/nodes/Cloudinary/descriptions/upload.fields.js +191 -0
  34. package/dist/nodes/Cloudinary/descriptions/upload.fields.js.map +1 -0
  35. package/dist/nodes/Cloudinary/descriptions/widget.fields.d.ts +2 -0
  36. package/dist/nodes/Cloudinary/descriptions/widget.fields.js +268 -0
  37. package/dist/nodes/Cloudinary/descriptions/widget.fields.js.map +1 -0
  38. package/dist/nodes/Cloudinary/operations/admin/getMetadataFields.d.ts +2 -0
  39. package/dist/nodes/Cloudinary/operations/admin/getMetadataFields.js +17 -0
  40. package/dist/nodes/Cloudinary/operations/admin/getMetadataFields.js.map +1 -0
  41. package/dist/nodes/Cloudinary/operations/admin/getTags.d.ts +2 -0
  42. package/dist/nodes/Cloudinary/operations/admin/getTags.js +28 -0
  43. package/dist/nodes/Cloudinary/operations/admin/getTags.js.map +1 -0
  44. package/dist/nodes/Cloudinary/operations/admin/search.d.ts +2 -0
  45. package/dist/nodes/Cloudinary/operations/admin/search.js +92 -0
  46. package/dist/nodes/Cloudinary/operations/admin/search.js.map +1 -0
  47. package/dist/nodes/Cloudinary/operations/asset/updateMetadata.d.ts +2 -0
  48. package/dist/nodes/Cloudinary/operations/asset/updateMetadata.js +25 -0
  49. package/dist/nodes/Cloudinary/operations/asset/updateMetadata.js.map +1 -0
  50. package/dist/nodes/Cloudinary/operations/asset/updateTags.d.ts +2 -0
  51. package/dist/nodes/Cloudinary/operations/asset/updateTags.js +30 -0
  52. package/dist/nodes/Cloudinary/operations/asset/updateTags.js.map +1 -0
  53. package/dist/nodes/Cloudinary/operations/index.d.ts +2 -0
  54. package/dist/nodes/Cloudinary/operations/index.js +50 -0
  55. package/dist/nodes/Cloudinary/operations/index.js.map +1 -0
  56. package/dist/nodes/Cloudinary/operations/tagAppend.d.ts +4 -0
  57. package/dist/nodes/Cloudinary/operations/tagAppend.js +44 -0
  58. package/dist/nodes/Cloudinary/operations/tagAppend.js.map +1 -0
  59. package/dist/nodes/Cloudinary/operations/transform/convertImage.d.ts +2 -0
  60. package/dist/nodes/Cloudinary/operations/transform/convertImage.js +23 -0
  61. package/dist/nodes/Cloudinary/operations/transform/convertImage.js.map +1 -0
  62. package/dist/nodes/Cloudinary/operations/transform/cropImage.d.ts +3 -0
  63. package/dist/nodes/Cloudinary/operations/transform/cropImage.js +31 -0
  64. package/dist/nodes/Cloudinary/operations/transform/cropImage.js.map +1 -0
  65. package/dist/nodes/Cloudinary/operations/transform/customTransformation.d.ts +2 -0
  66. package/dist/nodes/Cloudinary/operations/transform/customTransformation.js +28 -0
  67. package/dist/nodes/Cloudinary/operations/transform/customTransformation.js.map +1 -0
  68. package/dist/nodes/Cloudinary/operations/transform/multiStep.d.ts +2 -0
  69. package/dist/nodes/Cloudinary/operations/transform/multiStep.js +78 -0
  70. package/dist/nodes/Cloudinary/operations/transform/multiStep.js.map +1 -0
  71. package/dist/nodes/Cloudinary/operations/transform/optimizeImage.d.ts +2 -0
  72. package/dist/nodes/Cloudinary/operations/transform/optimizeImage.js +22 -0
  73. package/dist/nodes/Cloudinary/operations/transform/optimizeImage.js.map +1 -0
  74. package/dist/nodes/Cloudinary/operations/transform/optimizeVideo.d.ts +2 -0
  75. package/dist/nodes/Cloudinary/operations/transform/optimizeVideo.js +22 -0
  76. package/dist/nodes/Cloudinary/operations/transform/optimizeVideo.js.map +1 -0
  77. package/dist/nodes/Cloudinary/operations/transform/resizeImage.d.ts +3 -0
  78. package/dist/nodes/Cloudinary/operations/transform/resizeImage.js +28 -0
  79. package/dist/nodes/Cloudinary/operations/transform/resizeImage.js.map +1 -0
  80. package/dist/nodes/Cloudinary/operations/transform/shared.d.ts +47 -0
  81. package/dist/nodes/Cloudinary/operations/transform/shared.js +179 -0
  82. package/dist/nodes/Cloudinary/operations/transform/shared.js.map +1 -0
  83. package/dist/nodes/Cloudinary/operations/transform/trimVideo.d.ts +2 -0
  84. package/dist/nodes/Cloudinary/operations/transform/trimVideo.js +24 -0
  85. package/dist/nodes/Cloudinary/operations/transform/trimVideo.js.map +1 -0
  86. package/dist/nodes/Cloudinary/operations/transform/videoThumbnail.d.ts +2 -0
  87. package/dist/nodes/Cloudinary/operations/transform/videoThumbnail.js +34 -0
  88. package/dist/nodes/Cloudinary/operations/transform/videoThumbnail.js.map +1 -0
  89. package/dist/nodes/Cloudinary/operations/types.d.ts +10 -0
  90. package/dist/nodes/Cloudinary/operations/types.js +5 -0
  91. package/dist/nodes/Cloudinary/operations/types.js.map +1 -0
  92. package/dist/nodes/Cloudinary/operations/updateAsset/deleteAssets.d.ts +2 -0
  93. package/dist/nodes/Cloudinary/operations/updateAsset/deleteAssets.js +36 -0
  94. package/dist/nodes/Cloudinary/operations/updateAsset/deleteAssets.js.map +1 -0
  95. package/dist/nodes/Cloudinary/operations/updateAsset/getAsset.d.ts +2 -0
  96. package/dist/nodes/Cloudinary/operations/updateAsset/getAsset.js +20 -0
  97. package/dist/nodes/Cloudinary/operations/updateAsset/getAsset.js.map +1 -0
  98. package/dist/nodes/Cloudinary/operations/updateAsset/updateMetadata.d.ts +2 -0
  99. package/dist/nodes/Cloudinary/operations/updateAsset/updateMetadata.js +27 -0
  100. package/dist/nodes/Cloudinary/operations/updateAsset/updateMetadata.js.map +1 -0
  101. package/dist/nodes/Cloudinary/operations/updateAsset/updateTags.d.ts +2 -0
  102. package/dist/nodes/Cloudinary/operations/updateAsset/updateTags.js +32 -0
  103. package/dist/nodes/Cloudinary/operations/updateAsset/updateTags.js.map +1 -0
  104. package/dist/nodes/Cloudinary/operations/upload/uploadFile.d.ts +2 -0
  105. package/dist/nodes/Cloudinary/operations/upload/uploadFile.js +44 -0
  106. package/dist/nodes/Cloudinary/operations/upload/uploadFile.js.map +1 -0
  107. package/dist/nodes/Cloudinary/operations/upload/uploadUrl.d.ts +2 -0
  108. package/dist/nodes/Cloudinary/operations/upload/uploadUrl.js +34 -0
  109. package/dist/nodes/Cloudinary/operations/upload/uploadUrl.js.map +1 -0
  110. package/dist/nodes/Cloudinary/operations/widget/videoPlayer.d.ts +2 -0
  111. package/dist/nodes/Cloudinary/operations/widget/videoPlayer.js +170 -0
  112. package/dist/nodes/Cloudinary/operations/widget/videoPlayer.js.map +1 -0
  113. package/dist/package.json +7 -3
  114. package/dist/tsconfig.tsbuildinfo +1 -1
  115. package/package.json +7 -3
  116. package/dist/nodes/Cloudinary/sha1.utils.d.ts +0 -1
  117. package/dist/nodes/Cloudinary/sha1.utils.js +0 -68
  118. package/dist/nodes/Cloudinary/sha1.utils.js.map +0 -1
@@ -2,738 +2,58 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Cloudinary = void 0;
4
4
  const n8n_workflow_1 = require("n8n-workflow");
5
- const cloudinary_utils_1 = require("./cloudinary.utils");
5
+ const descriptions_1 = require("./descriptions");
6
+ const operations_1 = require("./operations");
7
+ const types_1 = require("./operations/types");
6
8
  class Cloudinary {
7
9
  constructor() {
8
10
  this.description = {
9
11
  displayName: 'Cloudinary',
10
12
  name: 'cloudinary',
11
13
  icon: 'file:cloudinary.svg',
12
- group: ['Cloudinary'],
14
+ group: ['transform'],
13
15
  version: 1,
14
16
  subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
15
- description: 'Upload to Cloudinary',
17
+ description: 'Upload images and videos, build optimized transformation and delivery URLs, generate video players, and manage, search, tag, and edit metadata in your Cloudinary media library',
18
+ documentationUrl: 'https://cloudinary.com/documentation/n8n_integration',
19
+ usableAsTool: true,
16
20
  defaults: {
17
21
  name: 'Cloudinary',
18
22
  },
19
- inputs: ["main"],
20
- outputs: ["main"],
23
+ inputs: ['main'],
24
+ outputs: ['main'],
21
25
  credentials: [
22
26
  {
23
- name: Cloudinary.CREDENTIAL_TYPE,
27
+ name: types_1.CREDENTIAL_TYPE,
24
28
  required: true,
25
29
  },
26
30
  ],
27
- properties: [
28
- {
29
- displayName: 'Resource',
30
- name: 'resource',
31
- type: 'options',
32
- noDataExpression: true,
33
- options: [
34
- {
35
- name: 'Upload',
36
- value: 'upload',
37
- },
38
- {
39
- name: 'Update Asset',
40
- value: 'updateAsset',
41
- },
42
- {
43
- name: 'Admin',
44
- value: 'admin',
45
- },
46
- ],
47
- default: 'upload',
48
- },
49
- {
50
- displayName: 'Operation',
51
- name: 'operation',
52
- type: 'options',
53
- noDataExpression: true,
54
- displayOptions: {
55
- show: {
56
- resource: ['upload'],
57
- },
58
- },
59
- options: [
60
- {
61
- name: 'Upload From URL',
62
- value: 'uploadUrl',
63
- description: 'Upload an asset from URL',
64
- action: 'Upload an asset from URL',
65
- },
66
- {
67
- name: 'Upload File',
68
- value: 'uploadFile',
69
- description: 'Upload an asset from file data',
70
- action: 'Upload an asset from file data',
71
- },
72
- ],
73
- default: 'uploadUrl',
74
- },
75
- {
76
- displayName: 'Operation',
77
- name: 'operation',
78
- type: 'options',
79
- noDataExpression: true,
80
- displayOptions: {
81
- show: {
82
- resource: ['updateAsset'],
83
- },
84
- },
85
- options: [
86
- {
87
- name: 'Update Asset Tags',
88
- value: 'updateTags',
89
- description: 'Update tags for an existing asset',
90
- action: 'Update asset tags',
91
- },
92
- {
93
- name: 'Update Asset Structured Metadata',
94
- value: 'updateMetadata',
95
- description: 'Update structured metadata for an existing asset',
96
- action: 'Update asset structured metadata',
97
- },
98
- ],
99
- default: 'updateTags',
100
- },
101
- {
102
- displayName: 'Operation',
103
- name: 'operation',
104
- type: 'options',
105
- noDataExpression: true,
106
- displayOptions: {
107
- show: {
108
- resource: ['admin'],
109
- },
110
- },
111
- options: [
112
- {
113
- name: 'Get Tags',
114
- value: 'getTags',
115
- description: 'Get all tags for a specific resource type',
116
- action: 'Get tags for a resource type',
117
- },
118
- {
119
- name: 'Get Metadata Fields',
120
- value: 'getMetadataFields',
121
- description: 'Get all metadata fields definitions',
122
- action: 'Get metadata fields definitions',
123
- },
124
- ],
125
- default: 'getTags',
126
- },
127
- {
128
- displayName: 'URL',
129
- name: 'url',
130
- type: 'string',
131
- default: '',
132
- description: 'URL of the image to upload',
133
- required: true,
134
- displayOptions: {
135
- show: {
136
- resource: ['upload'],
137
- operation: ['uploadUrl'],
138
- },
139
- },
140
- },
141
- {
142
- displayName: 'Resource Type',
143
- name: 'resource_type',
144
- type: 'options',
145
- options: [
146
- {
147
- name: 'Image',
148
- value: 'image',
149
- },
150
- {
151
- name: 'Video',
152
- value: 'video',
153
- },
154
- {
155
- name: 'Raw',
156
- value: 'raw',
157
- },
158
- ],
159
- default: 'image',
160
- description: 'The type of asset to upload',
161
- displayOptions: {
162
- show: {
163
- resource: ['upload'],
164
- operation: ['uploadUrl'],
165
- },
166
- },
167
- },
168
- {
169
- displayName: 'Additional Fields',
170
- name: 'additionalFields',
171
- type: 'collection',
172
- placeholder: 'Add Field',
173
- displayOptions: {
174
- show: {
175
- resource: ['upload'],
176
- operation: ['uploadUrl'],
177
- },
178
- },
179
- default: {},
180
- options: [
181
- {
182
- displayName: 'Folder',
183
- name: 'folder',
184
- type: 'string',
185
- default: '',
186
- description: 'Folder name where the asset will be stored',
187
- },
188
- {
189
- displayName: 'Public ID',
190
- name: 'public_id',
191
- type: 'string',
192
- default: '',
193
- description: 'The public ID of the resource',
194
- },
195
- {
196
- displayName: 'Structured Metadata',
197
- name: 'metadata',
198
- type: 'json',
199
- default: '{}',
200
- description: 'Structured metadata to attach to the asset as JSON. Example: {"field1": "value1", "field2": "value2"}.',
201
- },
202
- {
203
- displayName: 'Tags',
204
- name: 'tags',
205
- type: 'string',
206
- default: '',
207
- description: 'A comma-separated list of tag names to assign to the asset',
208
- },
209
- {
210
- displayName: 'Upload Preset',
211
- name: 'upload_preset',
212
- type: 'string',
213
- default: '',
214
- description: 'Name of an upload preset that you defined for your Cloudinary account',
215
- },
216
- ],
217
- },
218
- {
219
- displayName: 'Public ID',
220
- name: 'publicId',
221
- type: 'string',
222
- default: '',
223
- description: 'The public ID of the asset to update',
224
- required: true,
225
- displayOptions: {
226
- show: {
227
- resource: ['updateAsset'],
228
- operation: ['updateTags', 'updateMetadata'],
229
- },
230
- },
231
- },
232
- {
233
- displayName: 'Resource Type',
234
- name: 'resourceType',
235
- type: 'options',
236
- options: [
237
- {
238
- name: 'Image',
239
- value: 'image',
240
- },
241
- {
242
- name: 'Video',
243
- value: 'video',
244
- },
245
- {
246
- name: 'Raw',
247
- value: 'raw',
248
- },
249
- ],
250
- default: 'image',
251
- description: 'The type of asset to update',
252
- displayOptions: {
253
- show: {
254
- resource: ['updateAsset'],
255
- operation: ['updateTags', 'updateMetadata'],
256
- },
257
- },
258
- },
259
- {
260
- displayName: 'Type',
261
- name: 'type',
262
- type: 'options',
263
- options: [
264
- {
265
- name: 'Upload',
266
- value: 'upload',
267
- },
268
- {
269
- name: 'Private',
270
- value: 'private',
271
- },
272
- {
273
- name: 'Authenticated',
274
- value: 'authenticated',
275
- },
276
- {
277
- name: 'Fetch',
278
- value: 'fetch',
279
- },
280
- ],
281
- default: 'upload',
282
- description: 'The storage type of the asset',
283
- required: true,
284
- displayOptions: {
285
- show: {
286
- resource: ['updateAsset'],
287
- operation: ['updateTags', 'updateMetadata'],
288
- },
289
- },
290
- },
291
- {
292
- displayName: 'Tags',
293
- name: 'tags',
294
- type: 'string',
295
- default: '',
296
- description: 'A comma-separated list of tag names to assign to the asset',
297
- required: true,
298
- displayOptions: {
299
- show: {
300
- resource: ['updateAsset'],
301
- operation: ['updateTags'],
302
- },
303
- },
304
- },
305
- {
306
- displayName: 'Structured Metadata',
307
- name: 'structuredMetadata',
308
- type: 'json',
309
- default: '{}',
310
- description: 'Structured metadata to attach to the asset as JSON. Example: {"field1": "value1", "field2": "value2"}.',
311
- required: true,
312
- displayOptions: {
313
- show: {
314
- resource: ['updateAsset'],
315
- operation: ['updateMetadata'],
316
- },
317
- },
318
- },
319
- {
320
- displayName: 'Resource Type',
321
- name: 'getTagsResourceType',
322
- type: 'options',
323
- options: [
324
- {
325
- name: 'Image',
326
- value: 'image',
327
- },
328
- {
329
- name: 'Video',
330
- value: 'video',
331
- },
332
- {
333
- name: 'Raw',
334
- value: 'raw',
335
- },
336
- ],
337
- default: 'image',
338
- description: 'The type of resource to get tags for',
339
- required: true,
340
- displayOptions: {
341
- show: {
342
- resource: ['admin'],
343
- operation: ['getTags'],
344
- },
345
- },
346
- },
347
- {
348
- displayName: 'Prefix',
349
- name: 'tagsPrefix',
350
- type: 'string',
351
- default: '',
352
- description: 'Filter tags that start with this prefix',
353
- displayOptions: {
354
- show: {
355
- resource: ['admin'],
356
- operation: ['getTags'],
357
- },
358
- },
359
- },
360
- {
361
- displayName: 'Max Results',
362
- name: 'tagsMaxResults',
363
- type: 'number',
364
- default: 100,
365
- description: 'Maximum number of tags to return (1-500)',
366
- typeOptions: {
367
- minValue: 1,
368
- maxValue: 500,
369
- },
370
- displayOptions: {
371
- show: {
372
- resource: ['admin'],
373
- operation: ['getTags'],
374
- },
375
- },
376
- },
377
- {
378
- displayName: 'Update Fields',
379
- name: 'updateOptions',
380
- type: 'collection',
381
- placeholder: 'Add Option',
382
- displayOptions: {
383
- show: {
384
- resource: ['updateAsset'],
385
- operation: ['updateTags', 'updateMetadata'],
386
- },
387
- },
388
- default: {},
389
- options: [
390
- {
391
- displayName: 'Invalidate CDN',
392
- name: 'invalidate',
393
- type: 'boolean',
394
- default: false,
395
- description: 'Whether to invalidate CDN cache copies of the asset',
396
- },
397
- ],
398
- },
399
- {
400
- displayName: 'File',
401
- name: 'file',
402
- type: 'string',
403
- typeOptions: {
404
- propertyType: 'binary',
405
- },
406
- default: 'data',
407
- description: 'The file to upload',
408
- required: true,
409
- displayOptions: {
410
- show: {
411
- resource: ['upload'],
412
- operation: ['uploadFile'],
413
- },
414
- },
415
- },
416
- {
417
- displayName: 'Resource Type',
418
- name: 'resource_type_file',
419
- type: 'options',
420
- options: [
421
- {
422
- name: 'Image',
423
- value: 'image',
424
- },
425
- {
426
- name: 'Video',
427
- value: 'video',
428
- },
429
- {
430
- name: 'Raw',
431
- value: 'raw',
432
- },
433
- ],
434
- default: 'image',
435
- description: 'The type of asset to upload',
436
- displayOptions: {
437
- show: {
438
- resource: ['upload'],
439
- operation: ['uploadFile'],
440
- },
441
- },
442
- },
443
- {
444
- displayName: 'Additional Fields',
445
- name: 'additionalFieldsFile',
446
- type: 'collection',
447
- placeholder: 'Add Field',
448
- displayOptions: {
449
- show: {
450
- resource: ['upload'],
451
- operation: ['uploadFile'],
452
- },
453
- },
454
- default: {},
455
- options: [
456
- {
457
- displayName: 'Folder',
458
- name: 'folder',
459
- type: 'string',
460
- default: '',
461
- description: 'Folder name where the asset will be stored',
462
- },
463
- {
464
- displayName: 'Public ID',
465
- name: 'public_id',
466
- type: 'string',
467
- default: '',
468
- description: 'The public ID of the resource',
469
- },
470
- {
471
- displayName: 'Structured Metadata',
472
- name: 'metadata',
473
- type: 'json',
474
- default: '{}',
475
- description: 'Structured metadata to attach to the asset as JSON. Example: {"field1": "value1", "field2": "value2"}.',
476
- },
477
- {
478
- displayName: 'Tags',
479
- name: 'tags',
480
- type: 'string',
481
- default: '',
482
- description: 'A comma-separated list of tag names to assign to the asset',
483
- },
484
- {
485
- displayName: 'Upload Preset',
486
- name: 'upload_preset',
487
- type: 'string',
488
- default: '',
489
- description: 'Name of an upload preset that you defined for your Cloudinary account',
490
- },
491
- ],
492
- },
493
- ],
31
+ properties: descriptions_1.cloudinaryProperties,
494
32
  };
495
33
  }
496
34
  async execute() {
35
+ var _a, _b;
497
36
  const items = this.getInputData();
498
37
  const returnData = [];
499
- const credentials = await this.getCredentials(Cloudinary.CREDENTIAL_TYPE);
500
- const cloudName = credentials.cloudName;
501
- const apiKey = credentials.apiKey;
502
- const apiSecret = credentials.apiSecret;
38
+ const credentials = await this.getCredentials(types_1.CREDENTIAL_TYPE);
39
+ const creds = {
40
+ cloudName: credentials.cloudName,
41
+ apiKey: credentials.apiKey,
42
+ apiSecret: credentials.apiSecret,
43
+ privateCdn: (_a = credentials.privateCdn) !== null && _a !== void 0 ? _a : false,
44
+ secureDistribution: (_b = credentials.secureDistribution) !== null && _b !== void 0 ? _b : '',
45
+ };
503
46
  for (let i = 0; i < items.length; i++) {
504
47
  try {
505
48
  const resource = this.getNodeParameter('resource', i);
506
49
  const operation = this.getNodeParameter('operation', i);
507
- if (resource === 'upload' && operation === 'uploadUrl') {
508
- const url = this.getNodeParameter('url', i);
509
- const resourceType = this.getNodeParameter('resource_type', i);
510
- const additionalFields = this.getNodeParameter('additionalFields', i, {});
511
- if (additionalFields.metadata) {
512
- let metadata;
513
- try {
514
- metadata = typeof additionalFields.metadata === 'object'
515
- ? additionalFields.metadata
516
- : JSON.parse(additionalFields.metadata);
517
- }
518
- catch (error) {
519
- throw new n8n_workflow_1.ApplicationError('Invalid JSON for structured metadata');
520
- }
521
- const metadataString = Object.keys(metadata)
522
- .map((key) => {
523
- const value = metadata[key];
524
- const formattedValue = Array.isArray(value) ? JSON.stringify(value) : value;
525
- return `${key}=${formattedValue}`;
526
- })
527
- .join('|');
528
- additionalFields.metadata = metadataString;
529
- }
530
- const timestamp = Math.round(new Date().getTime() / 1000);
531
- const params = {
532
- timestamp,
533
- api_key: apiKey,
534
- file: url,
535
- ...additionalFields,
536
- };
537
- const signature = (0, cloudinary_utils_1.generateCloudinarySignature)(params, apiSecret);
538
- params.signature = signature;
539
- const uploadUrl = `https://api.cloudinary.com/v1_1/${cloudName}/${resourceType}/upload`;
540
- const options = {
541
- method: 'POST',
542
- url: uploadUrl,
543
- body: params,
544
- headers: {
545
- 'Content-Type': 'application/x-www-form-urlencoded',
546
- 'User-Agent': 'n8n/1.0',
547
- },
548
- };
549
- const response = await this.helpers.httpRequestWithAuthentication.call(this, Cloudinary.CREDENTIAL_TYPE, options);
550
- returnData.push({
551
- json: response,
552
- pairedItem: i,
553
- });
50
+ const handler = operations_1.operationHandlers[`${resource}:${operation}`];
51
+ if (!handler) {
52
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Unsupported operation: ${resource}/${operation}`, { itemIndex: i });
554
53
  }
555
- if (resource === 'upload' && operation === 'uploadFile') {
556
- const fileData = this.getNodeParameter('file', i);
557
- const resourceType = this.getNodeParameter('resource_type_file', i);
558
- const additionalFields = this.getNodeParameter('additionalFieldsFile', i, {});
559
- if (additionalFields.metadata) {
560
- let metadata;
561
- try {
562
- metadata = typeof additionalFields.metadata === 'object'
563
- ? additionalFields.metadata
564
- : JSON.parse(additionalFields.metadata);
565
- }
566
- catch (error) {
567
- throw new n8n_workflow_1.ApplicationError('Invalid JSON for structured metadata');
568
- }
569
- const metadataString = Object.keys(metadata)
570
- .map((key) => {
571
- const value = metadata[key];
572
- const formattedValue = Array.isArray(value) ? JSON.stringify(value) : value;
573
- return `${key}=${formattedValue}`;
574
- })
575
- .join('|');
576
- additionalFields.metadata = metadataString;
577
- }
578
- const binaryPropertyName = fileData;
579
- const binaryData = this.helpers.assertBinaryData(i, binaryPropertyName);
580
- const dataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
581
- const timestamp = Math.round(new Date().getTime() / 1000);
582
- const params = {
583
- timestamp,
584
- api_key: apiKey,
585
- ...additionalFields,
586
- };
587
- const signature = (0, cloudinary_utils_1.generateCloudinarySignature)(params, apiSecret);
588
- const uploadUrl = `https://api.cloudinary.com/v1_1/${cloudName}/${resourceType}/upload`;
589
- const fields = {
590
- api_key: apiKey,
591
- timestamp: timestamp.toString(),
592
- signature: signature,
593
- };
594
- for (const key in additionalFields) {
595
- fields[key] = additionalFields[key];
596
- }
597
- const { body, boundary } = (0, cloudinary_utils_1.createMultipartBody)(fields, dataBuffer, binaryData.fileName || 'file', binaryData.mimeType || 'application/octet-stream');
598
- const options = {
599
- method: 'POST',
600
- url: uploadUrl,
601
- body: body,
602
- headers: {
603
- 'Content-Type': `multipart/form-data; boundary=${boundary}`,
604
- 'User-Agent': 'n8n/1.0',
605
- },
606
- };
607
- const response = await this.helpers.httpRequestWithAuthentication.call(this, Cloudinary.CREDENTIAL_TYPE, options);
608
- returnData.push({
609
- json: response,
610
- pairedItem: i,
611
- });
612
- }
613
- if (resource === 'admin' && operation === 'getTags') {
614
- const resourceType = this.getNodeParameter('getTagsResourceType', i);
615
- const prefix = this.getNodeParameter('tagsPrefix', i, '');
616
- const maxResults = this.getNodeParameter('tagsMaxResults', i, 100);
617
- const tagsUrl = `https://api.cloudinary.com/v1_1/${cloudName}/tags/${resourceType}`;
618
- const queryParams = {};
619
- if (prefix) {
620
- queryParams.prefix = prefix;
621
- }
622
- if (maxResults) {
623
- queryParams.max_results = maxResults;
624
- }
625
- const options = {
626
- method: 'GET',
627
- url: tagsUrl,
628
- qs: queryParams,
629
- headers: {
630
- 'Content-Type': 'application/json',
631
- 'User-Agent': 'n8n/1.0',
632
- },
633
- auth: {
634
- username: apiKey,
635
- password: apiSecret,
636
- },
637
- };
638
- const response = await this.helpers.httpRequestWithAuthentication.call(this, Cloudinary.CREDENTIAL_TYPE, options);
639
- returnData.push({
640
- json: response,
641
- pairedItem: i,
642
- });
643
- }
644
- if (resource === 'admin' && operation === 'getMetadataFields') {
645
- const metadataUrl = `https://api.cloudinary.com/v1_1/${cloudName}/metadata_fields`;
646
- const options = {
647
- method: 'GET',
648
- url: metadataUrl,
649
- headers: {
650
- 'Content-Type': 'application/json',
651
- 'User-Agent': 'n8n/1.0',
652
- },
653
- auth: {
654
- username: apiKey,
655
- password: apiSecret,
656
- },
657
- };
658
- const response = await this.helpers.httpRequestWithAuthentication.call(this, Cloudinary.CREDENTIAL_TYPE, options);
659
- returnData.push({
660
- json: response,
661
- pairedItem: i,
662
- });
663
- }
664
- if (resource === 'updateAsset' && operation === 'updateTags') {
665
- const publicId = this.getNodeParameter('publicId', i);
666
- const resourceType = this.getNodeParameter('resourceType', i);
667
- const type = this.getNodeParameter('type', i);
668
- const tags = this.getNodeParameter('tags', i);
669
- const updateOptions = this.getNodeParameter('updateOptions', i, {});
670
- const body = {
671
- tags: tags,
672
- ...updateOptions,
673
- };
674
- const updateUrl = `https://api.cloudinary.com/v1_1/${cloudName}/resources/${resourceType}/${type}/${publicId}`;
675
- const options = {
676
- method: 'POST',
677
- url: updateUrl,
678
- body: body,
679
- headers: {
680
- 'Content-Type': 'application/json',
681
- 'User-Agent': 'n8n/1.0',
682
- },
683
- auth: {
684
- username: apiKey,
685
- password: apiSecret,
686
- },
687
- };
688
- const response = await this.helpers.httpRequestWithAuthentication.call(this, Cloudinary.CREDENTIAL_TYPE, options);
689
- returnData.push({
690
- json: response,
691
- pairedItem: i,
692
- });
693
- }
694
- if (resource === 'updateAsset' && operation === 'updateMetadata') {
695
- const publicId = this.getNodeParameter('publicId', i);
696
- const resourceType = this.getNodeParameter('resourceType', i);
697
- const type = this.getNodeParameter('type', i);
698
- const structuredMetadata = this.getNodeParameter('structuredMetadata', i);
699
- const updateOptions = this.getNodeParameter('updateOptions', i, {});
700
- let metadata;
701
- try {
702
- metadata = typeof structuredMetadata === 'object' ? structuredMetadata : JSON.parse(structuredMetadata);
703
- }
704
- catch (error) {
705
- throw new n8n_workflow_1.ApplicationError('Invalid JSON for structured metadata');
706
- }
707
- const metadataString = Object.keys(metadata)
708
- .map((key) => {
709
- const value = metadata[key];
710
- const formattedValue = Array.isArray(value) ? JSON.stringify(value) : value;
711
- return `${key}=${formattedValue}`;
712
- })
713
- .join('|');
714
- const body = {
715
- metadata: metadataString,
716
- ...updateOptions,
717
- };
718
- const updateUrl = `https://api.cloudinary.com/v1_1/${cloudName}/resources/${resourceType}/${type}/${publicId}`;
719
- const options = {
720
- method: 'POST',
721
- url: updateUrl,
722
- body: body,
723
- headers: {
724
- 'Content-Type': 'application/json',
725
- 'User-Agent': 'n8n/1.0',
726
- },
727
- auth: {
728
- username: apiKey,
729
- password: apiSecret,
730
- },
731
- };
732
- const response = await this.helpers.httpRequestWithAuthentication.call(this, Cloudinary.CREDENTIAL_TYPE, options);
733
- returnData.push({
734
- json: response,
735
- pairedItem: i,
736
- });
54
+ const results = await handler(this, i, creds);
55
+ for (const json of results) {
56
+ returnData.push({ json, pairedItem: i });
737
57
  }
738
58
  }
739
59
  catch (error) {
@@ -753,5 +73,4 @@ class Cloudinary {
753
73
  }
754
74
  }
755
75
  exports.Cloudinary = Cloudinary;
756
- Cloudinary.CREDENTIAL_TYPE = 'cloudinaryApi';
757
76
  //# sourceMappingURL=Cloudinary.node.js.map