n8n-nodes-frameio-v4 0.1.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/LICENSE.md +21 -0
- package/README.md +128 -0
- package/dist/credentials/FrameIoV4LegacyTokenApi.credentials.d.ts +10 -0
- package/dist/credentials/FrameIoV4LegacyTokenApi.credentials.js +45 -0
- package/dist/credentials/FrameIoV4LegacyTokenApi.credentials.js.map +1 -0
- package/dist/credentials/FrameIoV4OAuth2Api.credentials.d.ts +9 -0
- package/dist/credentials/FrameIoV4OAuth2Api.credentials.js +54 -0
- package/dist/credentials/FrameIoV4OAuth2Api.credentials.js.map +1 -0
- package/dist/credentials/FrameIoV4ServerToServerApi.credentials.d.ts +13 -0
- package/dist/credentials/FrameIoV4ServerToServerApi.credentials.js +82 -0
- package/dist/credentials/FrameIoV4ServerToServerApi.credentials.js.map +1 -0
- package/dist/icons/frameio.dark.svg +5 -0
- package/dist/icons/frameio.svg +5 -0
- package/dist/nodes/FrameIoV4/FrameIoV4.node.d.ts +13 -0
- package/dist/nodes/FrameIoV4/FrameIoV4.node.js +672 -0
- package/dist/nodes/FrameIoV4/FrameIoV4.node.js.map +1 -0
- package/dist/nodes/FrameIoV4/FrameIoV4.node.json +18 -0
- package/dist/nodes/FrameIoV4/GenericFunctions.d.ts +14 -0
- package/dist/nodes/FrameIoV4/GenericFunctions.js +156 -0
- package/dist/nodes/FrameIoV4/GenericFunctions.js.map +1 -0
- package/dist/nodes/FrameIoV4/descriptions/AccountDescription.d.ts +3 -0
- package/dist/nodes/FrameIoV4/descriptions/AccountDescription.js +86 -0
- package/dist/nodes/FrameIoV4/descriptions/AccountDescription.js.map +1 -0
- package/dist/nodes/FrameIoV4/descriptions/CommentDescription.d.ts +3 -0
- package/dist/nodes/FrameIoV4/descriptions/CommentDescription.js +337 -0
- package/dist/nodes/FrameIoV4/descriptions/CommentDescription.js.map +1 -0
- package/dist/nodes/FrameIoV4/descriptions/FileDescription.d.ts +3 -0
- package/dist/nodes/FrameIoV4/descriptions/FileDescription.js +464 -0
- package/dist/nodes/FrameIoV4/descriptions/FileDescription.js.map +1 -0
- package/dist/nodes/FrameIoV4/descriptions/FolderDescription.d.ts +3 -0
- package/dist/nodes/FrameIoV4/descriptions/FolderDescription.js +218 -0
- package/dist/nodes/FrameIoV4/descriptions/FolderDescription.js.map +1 -0
- package/dist/nodes/FrameIoV4/descriptions/ProjectDescription.d.ts +3 -0
- package/dist/nodes/FrameIoV4/descriptions/ProjectDescription.js +250 -0
- package/dist/nodes/FrameIoV4/descriptions/ProjectDescription.js.map +1 -0
- package/dist/nodes/FrameIoV4/descriptions/ShareDescription.d.ts +3 -0
- package/dist/nodes/FrameIoV4/descriptions/ShareDescription.js +342 -0
- package/dist/nodes/FrameIoV4/descriptions/ShareDescription.js.map +1 -0
- package/dist/nodes/FrameIoV4/descriptions/UserDescription.d.ts +3 -0
- package/dist/nodes/FrameIoV4/descriptions/UserDescription.js +27 -0
- package/dist/nodes/FrameIoV4/descriptions/UserDescription.js.map +1 -0
- package/dist/nodes/FrameIoV4/descriptions/VersionStackDescription.d.ts +3 -0
- package/dist/nodes/FrameIoV4/descriptions/VersionStackDescription.js +153 -0
- package/dist/nodes/FrameIoV4/descriptions/VersionStackDescription.js.map +1 -0
- package/dist/nodes/FrameIoV4/descriptions/WorkspaceDescription.d.ts +3 -0
- package/dist/nodes/FrameIoV4/descriptions/WorkspaceDescription.js +185 -0
- package/dist/nodes/FrameIoV4/descriptions/WorkspaceDescription.js.map +1 -0
- package/dist/nodes/FrameIoV4Trigger/FrameIoV4Trigger.node.d.ts +19 -0
- package/dist/nodes/FrameIoV4Trigger/FrameIoV4Trigger.node.js +335 -0
- package/dist/nodes/FrameIoV4Trigger/FrameIoV4Trigger.node.js.map +1 -0
- package/dist/nodes/FrameIoV4Trigger/FrameIoV4Trigger.node.json +18 -0
- package/dist/package.json +60 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +60 -0
|
@@ -0,0 +1,672 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FrameIoV4 = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
const AccountDescription_1 = require("./descriptions/AccountDescription");
|
|
6
|
+
const CommentDescription_1 = require("./descriptions/CommentDescription");
|
|
7
|
+
const FileDescription_1 = require("./descriptions/FileDescription");
|
|
8
|
+
const FolderDescription_1 = require("./descriptions/FolderDescription");
|
|
9
|
+
const ProjectDescription_1 = require("./descriptions/ProjectDescription");
|
|
10
|
+
const ShareDescription_1 = require("./descriptions/ShareDescription");
|
|
11
|
+
const UserDescription_1 = require("./descriptions/UserDescription");
|
|
12
|
+
const VersionStackDescription_1 = require("./descriptions/VersionStackDescription");
|
|
13
|
+
const WorkspaceDescription_1 = require("./descriptions/WorkspaceDescription");
|
|
14
|
+
const GenericFunctions_1 = require("./GenericFunctions");
|
|
15
|
+
function buildCommentBody(target, fields) {
|
|
16
|
+
if (fields.annotation !== undefined && fields.annotation !== '') {
|
|
17
|
+
target.annotation = fields.annotation;
|
|
18
|
+
}
|
|
19
|
+
if (fields.completed !== undefined) {
|
|
20
|
+
target.completed = fields.completed;
|
|
21
|
+
}
|
|
22
|
+
if (fields.duration !== undefined && fields.duration !== '') {
|
|
23
|
+
target.duration = fields.duration;
|
|
24
|
+
}
|
|
25
|
+
if (fields.page !== undefined && fields.page !== '') {
|
|
26
|
+
target.page = fields.page;
|
|
27
|
+
}
|
|
28
|
+
if (fields.timestamp !== undefined && fields.timestamp !== '') {
|
|
29
|
+
const timestamp = String(fields.timestamp);
|
|
30
|
+
target.timestamp = /^\d+$/.test(timestamp) ? Number.parseInt(timestamp, 10) : timestamp;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function splitIds(value) {
|
|
34
|
+
return value
|
|
35
|
+
.split(',')
|
|
36
|
+
.map((id) => id.trim())
|
|
37
|
+
.filter((id) => id.length > 0);
|
|
38
|
+
}
|
|
39
|
+
function includeToQs(qs, include) {
|
|
40
|
+
if (Array.isArray(include) && include.length > 0) {
|
|
41
|
+
qs.include = include.join(',');
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
async function waitForUploadCompletion(accountId, fileId, maxWaitTime, itemIndex) {
|
|
45
|
+
var _a;
|
|
46
|
+
const deadline = Date.now() + maxWaitTime * 1000;
|
|
47
|
+
for (;;) {
|
|
48
|
+
const response = await GenericFunctions_1.frameIoApiRequest.call(this, 'GET', `/v4/accounts/${accountId}/files/${fileId}/status`);
|
|
49
|
+
const status = ((_a = response.data) !== null && _a !== void 0 ? _a : {});
|
|
50
|
+
if (status.upload_failed === true) {
|
|
51
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Frame.io reported the file upload as failed', {
|
|
52
|
+
itemIndex,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
if (status.upload_complete === true) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (Date.now() >= deadline) {
|
|
59
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `The file upload did not complete within ${maxWaitTime} seconds`, { itemIndex });
|
|
60
|
+
}
|
|
61
|
+
await (0, n8n_workflow_1.sleep)(3000);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
class FrameIoV4 {
|
|
65
|
+
constructor() {
|
|
66
|
+
this.description = {
|
|
67
|
+
displayName: 'Frame.io V4',
|
|
68
|
+
name: 'frameIoV4',
|
|
69
|
+
icon: { light: 'file:../../icons/frameio.svg', dark: 'file:../../icons/frameio.dark.svg' },
|
|
70
|
+
group: ['transform'],
|
|
71
|
+
version: 1,
|
|
72
|
+
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
|
73
|
+
description: 'Interact with the Frame.io V4 API (Adobe)',
|
|
74
|
+
defaults: {
|
|
75
|
+
name: 'Frame.io V4',
|
|
76
|
+
},
|
|
77
|
+
inputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
78
|
+
outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
79
|
+
usableAsTool: true,
|
|
80
|
+
credentials: [
|
|
81
|
+
{
|
|
82
|
+
name: 'frameIoV4OAuth2Api',
|
|
83
|
+
required: true,
|
|
84
|
+
displayOptions: {
|
|
85
|
+
show: {
|
|
86
|
+
authentication: ['oAuth2'],
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
name: 'frameIoV4ServerToServerApi',
|
|
92
|
+
required: true,
|
|
93
|
+
displayOptions: {
|
|
94
|
+
show: {
|
|
95
|
+
authentication: ['serverToServer'],
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
name: 'frameIoV4LegacyTokenApi',
|
|
101
|
+
required: true,
|
|
102
|
+
displayOptions: {
|
|
103
|
+
show: {
|
|
104
|
+
authentication: ['legacyToken'],
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
],
|
|
109
|
+
properties: [
|
|
110
|
+
{
|
|
111
|
+
displayName: 'Authentication',
|
|
112
|
+
name: 'authentication',
|
|
113
|
+
type: 'options',
|
|
114
|
+
options: [
|
|
115
|
+
{
|
|
116
|
+
name: 'Legacy Developer Token',
|
|
117
|
+
value: 'legacyToken',
|
|
118
|
+
description: 'Transitional option for V4-migrated accounts not yet administered via the Adobe Admin Console',
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
name: 'OAuth2',
|
|
122
|
+
value: 'oAuth2',
|
|
123
|
+
description: 'OAuth2 user authentication via Adobe IMS (recommended)',
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
name: 'Server-to-Server',
|
|
127
|
+
value: 'serverToServer',
|
|
128
|
+
description: 'Adobe IMS client credentials — only for accounts administered via the Adobe Admin Console',
|
|
129
|
+
},
|
|
130
|
+
],
|
|
131
|
+
default: 'oAuth2',
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
displayName: 'Resource',
|
|
135
|
+
name: 'resource',
|
|
136
|
+
type: 'options',
|
|
137
|
+
noDataExpression: true,
|
|
138
|
+
options: [
|
|
139
|
+
{ name: 'Account', value: 'account' },
|
|
140
|
+
{ name: 'Comment', value: 'comment' },
|
|
141
|
+
{ name: 'File', value: 'file' },
|
|
142
|
+
{ name: 'Folder', value: 'folder' },
|
|
143
|
+
{ name: 'Project', value: 'project' },
|
|
144
|
+
{ name: 'Share', value: 'share' },
|
|
145
|
+
{ name: 'User', value: 'user' },
|
|
146
|
+
{ name: 'Version Stack', value: 'versionStack' },
|
|
147
|
+
{ name: 'Workspace', value: 'workspace' },
|
|
148
|
+
],
|
|
149
|
+
default: 'file',
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
displayName: 'Account Name or ID',
|
|
153
|
+
name: 'accountId',
|
|
154
|
+
type: 'options',
|
|
155
|
+
typeOptions: {
|
|
156
|
+
loadOptionsMethod: 'getAccounts',
|
|
157
|
+
},
|
|
158
|
+
required: true,
|
|
159
|
+
default: '',
|
|
160
|
+
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>',
|
|
161
|
+
displayOptions: {
|
|
162
|
+
hide: {
|
|
163
|
+
resource: ['account', 'user'],
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
...AccountDescription_1.accountOperations,
|
|
168
|
+
...AccountDescription_1.accountFields,
|
|
169
|
+
...CommentDescription_1.commentOperations,
|
|
170
|
+
...CommentDescription_1.commentFields,
|
|
171
|
+
...FileDescription_1.fileOperations,
|
|
172
|
+
...FileDescription_1.fileFields,
|
|
173
|
+
...FolderDescription_1.folderOperations,
|
|
174
|
+
...FolderDescription_1.folderFields,
|
|
175
|
+
...ProjectDescription_1.projectOperations,
|
|
176
|
+
...ProjectDescription_1.projectFields,
|
|
177
|
+
...ShareDescription_1.shareOperations,
|
|
178
|
+
...ShareDescription_1.shareFields,
|
|
179
|
+
...UserDescription_1.userOperations,
|
|
180
|
+
...UserDescription_1.userFields,
|
|
181
|
+
...VersionStackDescription_1.versionStackOperations,
|
|
182
|
+
...VersionStackDescription_1.versionStackFields,
|
|
183
|
+
...WorkspaceDescription_1.workspaceOperations,
|
|
184
|
+
...WorkspaceDescription_1.workspaceFields,
|
|
185
|
+
],
|
|
186
|
+
};
|
|
187
|
+
this.methods = {
|
|
188
|
+
loadOptions: {
|
|
189
|
+
getAccounts: GenericFunctions_1.getAccounts,
|
|
190
|
+
getWorkspaces: GenericFunctions_1.getWorkspaces,
|
|
191
|
+
getProjects: GenericFunctions_1.getProjects,
|
|
192
|
+
},
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
async execute() {
|
|
196
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
197
|
+
const items = this.getInputData();
|
|
198
|
+
const returnData = [];
|
|
199
|
+
const resource = this.getNodeParameter('resource', 0);
|
|
200
|
+
const operation = this.getNodeParameter('operation', 0);
|
|
201
|
+
for (let i = 0; i < items.length; i++) {
|
|
202
|
+
try {
|
|
203
|
+
let responseData;
|
|
204
|
+
if (resource === 'account') {
|
|
205
|
+
if (operation === 'getAll') {
|
|
206
|
+
const options = this.getNodeParameter('options', i, {});
|
|
207
|
+
const qs = {};
|
|
208
|
+
if (options.sort) {
|
|
209
|
+
qs.sort = options.sort;
|
|
210
|
+
}
|
|
211
|
+
responseData = await GenericFunctions_1.frameIoApiListRequest.call(this, i, '/v4/accounts', qs);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
else if (resource === 'user') {
|
|
215
|
+
if (operation === 'getCurrentUser') {
|
|
216
|
+
const response = await GenericFunctions_1.frameIoApiRequest.call(this, 'GET', '/v4/me');
|
|
217
|
+
responseData = response.data;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
const accountId = this.getNodeParameter('accountId', i);
|
|
222
|
+
if (resource === 'workspace') {
|
|
223
|
+
if (operation === 'create') {
|
|
224
|
+
const name = this.getNodeParameter('name', i);
|
|
225
|
+
const response = await GenericFunctions_1.frameIoApiRequest.call(this, 'POST', `/v4/accounts/${accountId}/workspaces`, { data: { name } });
|
|
226
|
+
responseData = response.data;
|
|
227
|
+
}
|
|
228
|
+
else if (operation === 'delete') {
|
|
229
|
+
const workspaceId = this.getNodeParameter('workspaceId', i);
|
|
230
|
+
await GenericFunctions_1.frameIoApiRequest.call(this, 'DELETE', `/v4/accounts/${accountId}/workspaces/${workspaceId}`);
|
|
231
|
+
responseData = { success: true };
|
|
232
|
+
}
|
|
233
|
+
else if (operation === 'get') {
|
|
234
|
+
const workspaceId = this.getNodeParameter('workspaceId', i);
|
|
235
|
+
const options = this.getNodeParameter('options', i, {});
|
|
236
|
+
const qs = {};
|
|
237
|
+
if (options.includeCreator === true) {
|
|
238
|
+
qs.include = 'creator';
|
|
239
|
+
}
|
|
240
|
+
const response = await GenericFunctions_1.frameIoApiRequest.call(this, 'GET', `/v4/accounts/${accountId}/workspaces/${workspaceId}`, undefined, qs);
|
|
241
|
+
responseData = response.data;
|
|
242
|
+
}
|
|
243
|
+
else if (operation === 'getAll') {
|
|
244
|
+
const options = this.getNodeParameter('options', i, {});
|
|
245
|
+
const qs = {};
|
|
246
|
+
if (options.includeCreator === true) {
|
|
247
|
+
qs.include = 'creator';
|
|
248
|
+
}
|
|
249
|
+
if (options.sort) {
|
|
250
|
+
qs.sort = options.sort;
|
|
251
|
+
}
|
|
252
|
+
responseData = await GenericFunctions_1.frameIoApiListRequest.call(this, i, `/v4/accounts/${accountId}/workspaces`, qs);
|
|
253
|
+
}
|
|
254
|
+
else if (operation === 'update') {
|
|
255
|
+
const workspaceId = this.getNodeParameter('workspaceId', i);
|
|
256
|
+
const name = this.getNodeParameter('name', i);
|
|
257
|
+
const response = await GenericFunctions_1.frameIoApiRequest.call(this, 'PATCH', `/v4/accounts/${accountId}/workspaces/${workspaceId}`, { data: { name } });
|
|
258
|
+
responseData = response.data;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
else if (resource === 'project') {
|
|
262
|
+
if (operation === 'create') {
|
|
263
|
+
const workspaceId = this.getNodeParameter('workspaceId', i);
|
|
264
|
+
const name = this.getNodeParameter('name', i);
|
|
265
|
+
const additionalFields = this.getNodeParameter('additionalFields', i, {});
|
|
266
|
+
const data = { name };
|
|
267
|
+
if (additionalFields.restricted !== undefined) {
|
|
268
|
+
data.restricted = additionalFields.restricted;
|
|
269
|
+
}
|
|
270
|
+
const response = await GenericFunctions_1.frameIoApiRequest.call(this, 'POST', `/v4/accounts/${accountId}/workspaces/${workspaceId}/projects`, { data });
|
|
271
|
+
responseData = response.data;
|
|
272
|
+
}
|
|
273
|
+
else if (operation === 'delete') {
|
|
274
|
+
const projectId = this.getNodeParameter('projectId', i);
|
|
275
|
+
await GenericFunctions_1.frameIoApiRequest.call(this, 'DELETE', `/v4/accounts/${accountId}/projects/${projectId}`);
|
|
276
|
+
responseData = { success: true };
|
|
277
|
+
}
|
|
278
|
+
else if (operation === 'get') {
|
|
279
|
+
const projectId = this.getNodeParameter('projectId', i);
|
|
280
|
+
const options = this.getNodeParameter('options', i, {});
|
|
281
|
+
const qs = {};
|
|
282
|
+
if (options.includeOwner === true) {
|
|
283
|
+
qs.include = 'owner';
|
|
284
|
+
}
|
|
285
|
+
const response = await GenericFunctions_1.frameIoApiRequest.call(this, 'GET', `/v4/accounts/${accountId}/projects/${projectId}`, undefined, qs);
|
|
286
|
+
responseData = response.data;
|
|
287
|
+
}
|
|
288
|
+
else if (operation === 'getAll') {
|
|
289
|
+
const workspaceId = this.getNodeParameter('workspaceId', i);
|
|
290
|
+
const options = this.getNodeParameter('options', i, {});
|
|
291
|
+
const qs = {};
|
|
292
|
+
if (options.includeOwner === true) {
|
|
293
|
+
qs.include = 'owner';
|
|
294
|
+
}
|
|
295
|
+
if (options.sort) {
|
|
296
|
+
qs.sort = options.sort;
|
|
297
|
+
}
|
|
298
|
+
responseData = await GenericFunctions_1.frameIoApiListRequest.call(this, i, `/v4/accounts/${accountId}/workspaces/${workspaceId}/projects`, qs);
|
|
299
|
+
}
|
|
300
|
+
else if (operation === 'update') {
|
|
301
|
+
const projectId = this.getNodeParameter('projectId', i);
|
|
302
|
+
const updateFields = this.getNodeParameter('updateFields', i, {});
|
|
303
|
+
const data = {};
|
|
304
|
+
if (updateFields.name) {
|
|
305
|
+
data.name = updateFields.name;
|
|
306
|
+
}
|
|
307
|
+
if (updateFields.restricted !== undefined) {
|
|
308
|
+
data.restricted = updateFields.restricted;
|
|
309
|
+
}
|
|
310
|
+
if (updateFields.status) {
|
|
311
|
+
data.status = updateFields.status;
|
|
312
|
+
}
|
|
313
|
+
const response = await GenericFunctions_1.frameIoApiRequest.call(this, 'PATCH', `/v4/accounts/${accountId}/projects/${projectId}`, { data });
|
|
314
|
+
responseData = response.data;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
else if (resource === 'folder') {
|
|
318
|
+
if (operation === 'create') {
|
|
319
|
+
const folderId = this.getNodeParameter('folderId', i);
|
|
320
|
+
const name = this.getNodeParameter('name', i);
|
|
321
|
+
const response = await GenericFunctions_1.frameIoApiRequest.call(this, 'POST', `/v4/accounts/${accountId}/folders/${folderId}/folders`, { data: { name } });
|
|
322
|
+
responseData = response.data;
|
|
323
|
+
}
|
|
324
|
+
else if (operation === 'delete') {
|
|
325
|
+
const folderId = this.getNodeParameter('folderId', i);
|
|
326
|
+
await GenericFunctions_1.frameIoApiRequest.call(this, 'DELETE', `/v4/accounts/${accountId}/folders/${folderId}`);
|
|
327
|
+
responseData = { success: true };
|
|
328
|
+
}
|
|
329
|
+
else if (operation === 'get') {
|
|
330
|
+
const folderId = this.getNodeParameter('folderId', i);
|
|
331
|
+
const options = this.getNodeParameter('options', i, {});
|
|
332
|
+
const qs = {};
|
|
333
|
+
includeToQs(qs, options.include);
|
|
334
|
+
const response = await GenericFunctions_1.frameIoApiRequest.call(this, 'GET', `/v4/accounts/${accountId}/folders/${folderId}`, undefined, qs);
|
|
335
|
+
responseData = response.data;
|
|
336
|
+
}
|
|
337
|
+
else if (operation === 'getAll') {
|
|
338
|
+
const folderId = this.getNodeParameter('folderId', i);
|
|
339
|
+
const types = this.getNodeParameter('types', i, []);
|
|
340
|
+
const options = this.getNodeParameter('options', i, {});
|
|
341
|
+
const qs = {};
|
|
342
|
+
if (types.length > 0) {
|
|
343
|
+
qs.type = types.join(',');
|
|
344
|
+
}
|
|
345
|
+
includeToQs(qs, options.include);
|
|
346
|
+
responseData = await GenericFunctions_1.frameIoApiListRequest.call(this, i, `/v4/accounts/${accountId}/folders/${folderId}/children`, qs);
|
|
347
|
+
}
|
|
348
|
+
else if (operation === 'update') {
|
|
349
|
+
const folderId = this.getNodeParameter('folderId', i);
|
|
350
|
+
const name = this.getNodeParameter('name', i);
|
|
351
|
+
const response = await GenericFunctions_1.frameIoApiRequest.call(this, 'PATCH', `/v4/accounts/${accountId}/folders/${folderId}`, { data: { name } });
|
|
352
|
+
responseData = response.data;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
else if (resource === 'file') {
|
|
356
|
+
if (operation === 'copy') {
|
|
357
|
+
const fileId = this.getNodeParameter('fileId', i);
|
|
358
|
+
const targetFolderId = this.getNodeParameter('targetFolderId', i, '');
|
|
359
|
+
const options = this.getNodeParameter('options', i, {});
|
|
360
|
+
const qs = {};
|
|
361
|
+
if (options.copyComments && options.copyComments !== 'none') {
|
|
362
|
+
qs.copy_comments = options.copyComments;
|
|
363
|
+
}
|
|
364
|
+
if (options.copyMetadata === true) {
|
|
365
|
+
qs.copy_metadata = true;
|
|
366
|
+
}
|
|
367
|
+
const body = targetFolderId ? { data: { parent_id: targetFolderId } } : undefined;
|
|
368
|
+
const response = await GenericFunctions_1.frameIoApiRequest.call(this, 'POST', `/v4/accounts/${accountId}/files/${fileId}/copy`, body, qs);
|
|
369
|
+
responseData = response.data;
|
|
370
|
+
}
|
|
371
|
+
else if (operation === 'delete') {
|
|
372
|
+
const fileId = this.getNodeParameter('fileId', i);
|
|
373
|
+
await GenericFunctions_1.frameIoApiRequest.call(this, 'DELETE', `/v4/accounts/${accountId}/files/${fileId}`);
|
|
374
|
+
responseData = { success: true };
|
|
375
|
+
}
|
|
376
|
+
else if (operation === 'download') {
|
|
377
|
+
const fileId = this.getNodeParameter('fileId', i);
|
|
378
|
+
const rendition = this.getNodeParameter('rendition', i);
|
|
379
|
+
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
|
|
380
|
+
const response = await GenericFunctions_1.frameIoApiRequest.call(this, 'GET', `/v4/accounts/${accountId}/files/${fileId}`, undefined, { include: `media_links.${rendition}` });
|
|
381
|
+
const file = ((_a = response.data) !== null && _a !== void 0 ? _a : {});
|
|
382
|
+
const mediaLinks = ((_b = file.media_links) !== null && _b !== void 0 ? _b : {});
|
|
383
|
+
const link = ((_c = mediaLinks[rendition]) !== null && _c !== void 0 ? _c : {});
|
|
384
|
+
const downloadUrl = ((_d = link.download_url) !== null && _d !== void 0 ? _d : link.url);
|
|
385
|
+
if (!downloadUrl) {
|
|
386
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `The "${rendition}" rendition is not available for this file (file status: ${(_e = file.status) !== null && _e !== void 0 ? _e : 'unknown'}). Transcoded renditions require the file to be fully processed, and some renditions do not exist for every media type.`, { itemIndex: i });
|
|
387
|
+
}
|
|
388
|
+
const downloadResponse = await this.helpers.httpRequest({
|
|
389
|
+
method: 'GET',
|
|
390
|
+
url: downloadUrl,
|
|
391
|
+
encoding: 'arraybuffer',
|
|
392
|
+
returnFullResponse: true,
|
|
393
|
+
});
|
|
394
|
+
const responseHeaders = ((_f = downloadResponse.headers) !== null && _f !== void 0 ? _f : {});
|
|
395
|
+
const contentType = (_h = (_g = responseHeaders['content-type']) !== null && _g !== void 0 ? _g : file.media_type) !== null && _h !== void 0 ? _h : undefined;
|
|
396
|
+
let fileName = (_j = file.name) !== null && _j !== void 0 ? _j : 'file';
|
|
397
|
+
if (rendition !== 'original') {
|
|
398
|
+
const dotIndex = fileName.lastIndexOf('.');
|
|
399
|
+
const baseName = dotIndex > 0 ? fileName.slice(0, dotIndex) : fileName;
|
|
400
|
+
fileName = `${baseName}_${rendition}`;
|
|
401
|
+
}
|
|
402
|
+
const binaryData = await this.helpers.prepareBinaryData(Buffer.from(downloadResponse.body), fileName, contentType);
|
|
403
|
+
returnData.push({
|
|
404
|
+
json: file,
|
|
405
|
+
binary: { [binaryPropertyName]: binaryData },
|
|
406
|
+
pairedItem: { item: i },
|
|
407
|
+
});
|
|
408
|
+
continue;
|
|
409
|
+
}
|
|
410
|
+
else if (operation === 'get') {
|
|
411
|
+
const fileId = this.getNodeParameter('fileId', i);
|
|
412
|
+
const options = this.getNodeParameter('options', i, {});
|
|
413
|
+
const qs = {};
|
|
414
|
+
includeToQs(qs, options.include);
|
|
415
|
+
const response = await GenericFunctions_1.frameIoApiRequest.call(this, 'GET', `/v4/accounts/${accountId}/files/${fileId}`, undefined, qs);
|
|
416
|
+
responseData = response.data;
|
|
417
|
+
}
|
|
418
|
+
else if (operation === 'getAll') {
|
|
419
|
+
const folderId = this.getNodeParameter('folderId', i);
|
|
420
|
+
const options = this.getNodeParameter('options', i, {});
|
|
421
|
+
const qs = {};
|
|
422
|
+
includeToQs(qs, options.include);
|
|
423
|
+
if (options.sort) {
|
|
424
|
+
qs.sort = options.sort;
|
|
425
|
+
}
|
|
426
|
+
responseData = await GenericFunctions_1.frameIoApiListRequest.call(this, i, `/v4/accounts/${accountId}/folders/${folderId}/files`, qs);
|
|
427
|
+
}
|
|
428
|
+
else if (operation === 'getUploadStatus') {
|
|
429
|
+
const fileId = this.getNodeParameter('fileId', i);
|
|
430
|
+
const response = await GenericFunctions_1.frameIoApiRequest.call(this, 'GET', `/v4/accounts/${accountId}/files/${fileId}/status`);
|
|
431
|
+
responseData = response.data;
|
|
432
|
+
}
|
|
433
|
+
else if (operation === 'move') {
|
|
434
|
+
const fileId = this.getNodeParameter('fileId', i);
|
|
435
|
+
const targetFolderId = this.getNodeParameter('targetFolderId', i);
|
|
436
|
+
const response = await GenericFunctions_1.frameIoApiRequest.call(this, 'PATCH', `/v4/accounts/${accountId}/files/${fileId}/move`, { data: { parent_id: targetFolderId } });
|
|
437
|
+
responseData = response.data;
|
|
438
|
+
}
|
|
439
|
+
else if (operation === 'update') {
|
|
440
|
+
const fileId = this.getNodeParameter('fileId', i);
|
|
441
|
+
const name = this.getNodeParameter('name', i);
|
|
442
|
+
const response = await GenericFunctions_1.frameIoApiRequest.call(this, 'PATCH', `/v4/accounts/${accountId}/files/${fileId}`, { data: { name } });
|
|
443
|
+
responseData = response.data;
|
|
444
|
+
}
|
|
445
|
+
else if (operation === 'upload') {
|
|
446
|
+
const folderId = this.getNodeParameter('folderId', i);
|
|
447
|
+
const uploadFrom = this.getNodeParameter('uploadFrom', i);
|
|
448
|
+
const options = this.getNodeParameter('options', i, {});
|
|
449
|
+
let file;
|
|
450
|
+
if (uploadFrom === 'url') {
|
|
451
|
+
const name = this.getNodeParameter('fileName', i);
|
|
452
|
+
const sourceUrl = this.getNodeParameter('sourceUrl', i);
|
|
453
|
+
const response = await GenericFunctions_1.frameIoApiRequest.call(this, 'POST', `/v4/accounts/${accountId}/folders/${folderId}/files/remote_upload`, { data: { name, source_url: sourceUrl } });
|
|
454
|
+
file = ((_k = response.data) !== null && _k !== void 0 ? _k : {});
|
|
455
|
+
}
|
|
456
|
+
else {
|
|
457
|
+
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
|
|
458
|
+
const binaryData = this.helpers.assertBinaryData(i, binaryPropertyName);
|
|
459
|
+
const buffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
|
|
460
|
+
const name = this.getNodeParameter('fileName', i, '') ||
|
|
461
|
+
binaryData.fileName ||
|
|
462
|
+
'unnamed';
|
|
463
|
+
const response = await GenericFunctions_1.frameIoApiRequest.call(this, 'POST', `/v4/accounts/${accountId}/folders/${folderId}/files/local_upload`, { data: { name, file_size: buffer.length } });
|
|
464
|
+
file = ((_l = response.data) !== null && _l !== void 0 ? _l : {});
|
|
465
|
+
const uploadUrls = ((_m = file.upload_urls) !== null && _m !== void 0 ? _m : []);
|
|
466
|
+
if (uploadUrls.length === 0) {
|
|
467
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Frame.io did not return any upload URLs for the file', { itemIndex: i });
|
|
468
|
+
}
|
|
469
|
+
await GenericFunctions_1.uploadFileParts.call(this, uploadUrls, buffer, (_o = file.media_type) !== null && _o !== void 0 ? _o : 'application/octet-stream');
|
|
470
|
+
}
|
|
471
|
+
if (options.waitForUpload === true) {
|
|
472
|
+
const maxWaitTime = (_p = options.maxWaitTime) !== null && _p !== void 0 ? _p : 120;
|
|
473
|
+
await waitForUploadCompletion.call(this, accountId, file.id, maxWaitTime, i);
|
|
474
|
+
const response = await GenericFunctions_1.frameIoApiRequest.call(this, 'GET', `/v4/accounts/${accountId}/files/${file.id}`);
|
|
475
|
+
responseData = response.data;
|
|
476
|
+
}
|
|
477
|
+
else {
|
|
478
|
+
responseData = file;
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
else if (resource === 'comment') {
|
|
483
|
+
if (operation === 'create') {
|
|
484
|
+
const fileId = this.getNodeParameter('fileId', i);
|
|
485
|
+
const text = this.getNodeParameter('text', i);
|
|
486
|
+
const additionalFields = this.getNodeParameter('additionalFields', i, {});
|
|
487
|
+
const data = { text };
|
|
488
|
+
buildCommentBody(data, additionalFields);
|
|
489
|
+
const response = await GenericFunctions_1.frameIoApiRequest.call(this, 'POST', `/v4/accounts/${accountId}/files/${fileId}/comments`, { data });
|
|
490
|
+
responseData = response.data;
|
|
491
|
+
}
|
|
492
|
+
else if (operation === 'delete') {
|
|
493
|
+
const commentId = this.getNodeParameter('commentId', i);
|
|
494
|
+
await GenericFunctions_1.frameIoApiRequest.call(this, 'DELETE', `/v4/accounts/${accountId}/comments/${commentId}`);
|
|
495
|
+
responseData = { success: true };
|
|
496
|
+
}
|
|
497
|
+
else if (operation === 'get') {
|
|
498
|
+
const commentId = this.getNodeParameter('commentId', i);
|
|
499
|
+
const options = this.getNodeParameter('options', i, {});
|
|
500
|
+
const qs = {};
|
|
501
|
+
includeToQs(qs, options.include);
|
|
502
|
+
if (options.timestampAsTimecode === true) {
|
|
503
|
+
qs.timestamp_as_timecode = true;
|
|
504
|
+
}
|
|
505
|
+
const response = await GenericFunctions_1.frameIoApiRequest.call(this, 'GET', `/v4/accounts/${accountId}/comments/${commentId}`, undefined, qs);
|
|
506
|
+
responseData = response.data;
|
|
507
|
+
}
|
|
508
|
+
else if (operation === 'getAll') {
|
|
509
|
+
const fileId = this.getNodeParameter('fileId', i);
|
|
510
|
+
const options = this.getNodeParameter('options', i, {});
|
|
511
|
+
const qs = {};
|
|
512
|
+
includeToQs(qs, options.include);
|
|
513
|
+
if (options.sort) {
|
|
514
|
+
qs.sort = options.sort;
|
|
515
|
+
}
|
|
516
|
+
if (options.timestampAsTimecode === true) {
|
|
517
|
+
qs.timestamp_as_timecode = true;
|
|
518
|
+
}
|
|
519
|
+
responseData = await GenericFunctions_1.frameIoApiListRequest.call(this, i, `/v4/accounts/${accountId}/files/${fileId}/comments`, qs);
|
|
520
|
+
}
|
|
521
|
+
else if (operation === 'update') {
|
|
522
|
+
const commentId = this.getNodeParameter('commentId', i);
|
|
523
|
+
const text = this.getNodeParameter('text', i);
|
|
524
|
+
const updateFields = this.getNodeParameter('updateFields', i, {});
|
|
525
|
+
const data = { text };
|
|
526
|
+
buildCommentBody(data, updateFields);
|
|
527
|
+
const response = await GenericFunctions_1.frameIoApiRequest.call(this, 'PATCH', `/v4/accounts/${accountId}/comments/${commentId}`, { data });
|
|
528
|
+
responseData = response.data;
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
else if (resource === 'share') {
|
|
532
|
+
if (operation === 'addAsset') {
|
|
533
|
+
const shareId = this.getNodeParameter('shareId', i);
|
|
534
|
+
const assetId = this.getNodeParameter('assetId', i);
|
|
535
|
+
const response = await GenericFunctions_1.frameIoApiRequest.call(this, 'POST', `/v4/accounts/${accountId}/shares/${shareId}/assets`, { data: { asset_id: assetId } });
|
|
536
|
+
responseData = response.data;
|
|
537
|
+
}
|
|
538
|
+
else if (operation === 'create') {
|
|
539
|
+
const projectId = this.getNodeParameter('projectId', i);
|
|
540
|
+
const name = this.getNodeParameter('name', i);
|
|
541
|
+
const access = this.getNodeParameter('access', i);
|
|
542
|
+
const additionalFields = this.getNodeParameter('additionalFields', i, {});
|
|
543
|
+
const data = { type: 'asset', name, access };
|
|
544
|
+
if (additionalFields.assetIds) {
|
|
545
|
+
data.asset_ids = splitIds(additionalFields.assetIds);
|
|
546
|
+
}
|
|
547
|
+
if (additionalFields.description) {
|
|
548
|
+
data.description = additionalFields.description;
|
|
549
|
+
}
|
|
550
|
+
if (additionalFields.downloadingEnabled !== undefined) {
|
|
551
|
+
data.downloading_enabled = additionalFields.downloadingEnabled;
|
|
552
|
+
}
|
|
553
|
+
if (additionalFields.expiration) {
|
|
554
|
+
data.expiration = additionalFields.expiration;
|
|
555
|
+
}
|
|
556
|
+
if (additionalFields.passphrase) {
|
|
557
|
+
data.passphrase = additionalFields.passphrase;
|
|
558
|
+
}
|
|
559
|
+
const response = await GenericFunctions_1.frameIoApiRequest.call(this, 'POST', `/v4/accounts/${accountId}/projects/${projectId}/shares`, { data });
|
|
560
|
+
responseData = response.data;
|
|
561
|
+
}
|
|
562
|
+
else if (operation === 'delete') {
|
|
563
|
+
const shareId = this.getNodeParameter('shareId', i);
|
|
564
|
+
await GenericFunctions_1.frameIoApiRequest.call(this, 'DELETE', `/v4/accounts/${accountId}/shares/${shareId}`);
|
|
565
|
+
responseData = { success: true };
|
|
566
|
+
}
|
|
567
|
+
else if (operation === 'get') {
|
|
568
|
+
const shareId = this.getNodeParameter('shareId', i);
|
|
569
|
+
const response = await GenericFunctions_1.frameIoApiRequest.call(this, 'GET', `/v4/accounts/${accountId}/shares/${shareId}`);
|
|
570
|
+
responseData = response.data;
|
|
571
|
+
}
|
|
572
|
+
else if (operation === 'getAll') {
|
|
573
|
+
const projectId = this.getNodeParameter('projectId', i);
|
|
574
|
+
const options = this.getNodeParameter('options', i, {});
|
|
575
|
+
const qs = {};
|
|
576
|
+
if (options.sort) {
|
|
577
|
+
qs.sort = options.sort;
|
|
578
|
+
}
|
|
579
|
+
responseData = await GenericFunctions_1.frameIoApiListRequest.call(this, i, `/v4/accounts/${accountId}/projects/${projectId}/shares`, qs);
|
|
580
|
+
}
|
|
581
|
+
else if (operation === 'removeAsset') {
|
|
582
|
+
const shareId = this.getNodeParameter('shareId', i);
|
|
583
|
+
const assetId = this.getNodeParameter('assetId', i);
|
|
584
|
+
const response = await GenericFunctions_1.frameIoApiRequest.call(this, 'DELETE', `/v4/accounts/${accountId}/shares/${shareId}/assets/${assetId}`);
|
|
585
|
+
responseData = response.data;
|
|
586
|
+
}
|
|
587
|
+
else if (operation === 'update') {
|
|
588
|
+
const shareId = this.getNodeParameter('shareId', i);
|
|
589
|
+
const updateFields = this.getNodeParameter('updateFields', i, {});
|
|
590
|
+
const data = {};
|
|
591
|
+
if (updateFields.access) {
|
|
592
|
+
data.access = updateFields.access;
|
|
593
|
+
}
|
|
594
|
+
if (updateFields.description) {
|
|
595
|
+
data.description = updateFields.description;
|
|
596
|
+
}
|
|
597
|
+
if (updateFields.downloadingEnabled !== undefined) {
|
|
598
|
+
data.downloading_enabled = updateFields.downloadingEnabled;
|
|
599
|
+
}
|
|
600
|
+
if (updateFields.expiration) {
|
|
601
|
+
data.expiration = updateFields.expiration;
|
|
602
|
+
}
|
|
603
|
+
if (updateFields.name) {
|
|
604
|
+
data.name = updateFields.name;
|
|
605
|
+
}
|
|
606
|
+
if (updateFields.passphrase) {
|
|
607
|
+
data.passphrase = updateFields.passphrase;
|
|
608
|
+
}
|
|
609
|
+
if (Object.keys(data).length === 0) {
|
|
610
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Please add at least one field to update', { itemIndex: i });
|
|
611
|
+
}
|
|
612
|
+
const response = await GenericFunctions_1.frameIoApiRequest.call(this, 'PATCH', `/v4/accounts/${accountId}/shares/${shareId}`, { data });
|
|
613
|
+
responseData = response.data;
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
else if (resource === 'versionStack') {
|
|
617
|
+
if (operation === 'create') {
|
|
618
|
+
const folderId = this.getNodeParameter('folderId', i);
|
|
619
|
+
const fileIds = this.getNodeParameter('fileIds', i);
|
|
620
|
+
const response = await GenericFunctions_1.frameIoApiRequest.call(this, 'POST', `/v4/accounts/${accountId}/folders/${folderId}/version_stacks`, { data: { file_ids: splitIds(fileIds) } });
|
|
621
|
+
responseData = response.data;
|
|
622
|
+
}
|
|
623
|
+
else if (operation === 'get') {
|
|
624
|
+
const versionStackId = this.getNodeParameter('versionStackId', i);
|
|
625
|
+
const options = this.getNodeParameter('options', i, {});
|
|
626
|
+
const qs = {};
|
|
627
|
+
includeToQs(qs, options.include);
|
|
628
|
+
const response = await GenericFunctions_1.frameIoApiRequest.call(this, 'GET', `/v4/accounts/${accountId}/version_stacks/${versionStackId}`, undefined, qs);
|
|
629
|
+
responseData = response.data;
|
|
630
|
+
}
|
|
631
|
+
else if (operation === 'getChildren') {
|
|
632
|
+
const versionStackId = this.getNodeParameter('versionStackId', i);
|
|
633
|
+
const options = this.getNodeParameter('options', i, {});
|
|
634
|
+
const qs = {};
|
|
635
|
+
includeToQs(qs, options.include);
|
|
636
|
+
responseData = await GenericFunctions_1.frameIoApiListRequest.call(this, i, `/v4/accounts/${accountId}/version_stacks/${versionStackId}/children`, qs);
|
|
637
|
+
}
|
|
638
|
+
else if (operation === 'getAll') {
|
|
639
|
+
const folderId = this.getNodeParameter('folderId', i);
|
|
640
|
+
const options = this.getNodeParameter('options', i, {});
|
|
641
|
+
const qs = {};
|
|
642
|
+
includeToQs(qs, options.include);
|
|
643
|
+
responseData = await GenericFunctions_1.frameIoApiListRequest.call(this, i, `/v4/accounts/${accountId}/folders/${folderId}/version_stacks`, qs);
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
if (responseData === undefined) {
|
|
648
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `The operation "${operation}" is not supported for resource "${resource}"`, { itemIndex: i });
|
|
649
|
+
}
|
|
650
|
+
const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
|
|
651
|
+
returnData.push(...executionData);
|
|
652
|
+
}
|
|
653
|
+
catch (error) {
|
|
654
|
+
if (this.continueOnFail()) {
|
|
655
|
+
returnData.push({
|
|
656
|
+
json: { error: error.message },
|
|
657
|
+
pairedItem: { item: i },
|
|
658
|
+
});
|
|
659
|
+
continue;
|
|
660
|
+
}
|
|
661
|
+
if (error instanceof n8n_workflow_1.NodeApiError || error instanceof n8n_workflow_1.NodeOperationError) {
|
|
662
|
+
const alreadyWrapped = error;
|
|
663
|
+
throw alreadyWrapped;
|
|
664
|
+
}
|
|
665
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error, { itemIndex: i });
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
return [returnData];
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
exports.FrameIoV4 = FrameIoV4;
|
|
672
|
+
//# sourceMappingURL=FrameIoV4.node.js.map
|