@prismatic-io/components-frontify 0.0.0-stage → 0.0.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.
@@ -0,0 +1,4513 @@
1
+ let _prismatic_io_spectral = require("@prismatic-io/spectral");
2
+ let graphql_request = require("graphql-request");
3
+ //#region src/utils/cleanUrl.ts
4
+ const cleanUrl = (value, defaultValue = "") => {
5
+ const stringValue = _prismatic_io_spectral.util.types.toString(value || defaultValue);
6
+ return stringValue.endsWith("/") ? stringValue.slice(0, -1) : stringValue;
7
+ };
8
+ //#endregion
9
+ //#region src/connections.ts
10
+ const personalDeveloperToken = (0, _prismatic_io_spectral.connection)({
11
+ key: "personalDeveloperToken",
12
+ display: {
13
+ label: "Personal Developer Token",
14
+ description: "Personal Developer Tokens are used for private applications or during development to skip the OAuth2 process."
15
+ },
16
+ inputs: {
17
+ baseUrl: {
18
+ label: "Base URL",
19
+ type: "string",
20
+ comments: "The base URL of the Frontify API. This URL should be provided by the service provider.",
21
+ placeholder: "https://my-example-domain.frontify.com/",
22
+ example: "https://my-example-domain.frontify.com",
23
+ required: true
24
+ },
25
+ personalDeveloperToken: {
26
+ label: "Token",
27
+ type: "password",
28
+ required: true,
29
+ comments: "The personal developer token is used to authenticate with the Frontify API. This token should be provided by the service provider."
30
+ }
31
+ }
32
+ });
33
+ var connections_default = [(0, _prismatic_io_spectral.oauth2Connection)({
34
+ key: "frontifyOAuth2",
35
+ display: {
36
+ label: "OAuth 2.0",
37
+ description: "Connection to Frontify using OAuth 2.0"
38
+ },
39
+ oauth2Type: _prismatic_io_spectral.OAuth2Type.AuthorizationCode,
40
+ oauth2PkceMethod: _prismatic_io_spectral.OAuth2PkceMethod.S256,
41
+ inputs: {
42
+ baseUrl: {
43
+ label: "Base URL",
44
+ type: "string",
45
+ comments: "The base URL of the Frontify API. This URL should be provided by the service provider.",
46
+ example: "https://my-example-domain.frontify.com",
47
+ required: true
48
+ },
49
+ authorizeUrl: {
50
+ label: "Authorize URL",
51
+ type: "string",
52
+ required: true,
53
+ comments: "The Authorization URL for Frontify.",
54
+ example: "https://my-example-domain.frontify.com/api/oauth/authorize"
55
+ },
56
+ tokenUrl: {
57
+ label: "Token URL",
58
+ type: "string",
59
+ required: true,
60
+ comments: "The Token URL for Frontify.",
61
+ example: "https://my-example-domain.frontify.com/api/oauth/accesstoken"
62
+ },
63
+ scopes: {
64
+ label: "Scopes",
65
+ type: "string",
66
+ required: true,
67
+ comments: "A list of scopes, combined by a space. At least `basic:read` must be specified within scopes. A full list of scopes can be found here: https://help.frontify.com/en/articles/5402354-overview-of-frontify-developer-tools",
68
+ placeholder: "basic:read"
69
+ },
70
+ clientId: {
71
+ label: "Client ID",
72
+ placeholder: "Client Identifier",
73
+ type: "password",
74
+ required: true
75
+ },
76
+ clientSecret: {
77
+ label: "Client Secret",
78
+ placeholder: "Client Secret",
79
+ type: "password",
80
+ required: true
81
+ },
82
+ state: {
83
+ label: "State",
84
+ type: "string",
85
+ comments: "The state is a parameter controlled by you and used to preserves some state objects set by the client in the Authorization request and makes it available to the client in the response.",
86
+ example: "testStateA@s432!"
87
+ }
88
+ }
89
+ }), personalDeveloperToken];
90
+ //#endregion
91
+ //#region src/utils/validateConnections.ts
92
+ const validateConnection = (connection) => {
93
+ if (!connections_default.map((c) => c.key).includes(connection.key)) throw new _prismatic_io_spectral.ConnectionError(connection, `Unsupported connection ${connection.key}.`);
94
+ };
95
+ //#endregion
96
+ //#region src/client.ts
97
+ const createClient = ({ connection, debug = false }) => {
98
+ try {
99
+ validateConnection(connection);
100
+ return new graphql_request.GraphQLClient(`${cleanUrl(connection.fields.baseUrl)}/graphql`, {
101
+ headers: {
102
+ Authorization: `Bearer ${connection.token?.access_token || connection.fields.personalDeveloperToken}`,
103
+ "Content-Type": "application/json"
104
+ },
105
+ requestMiddleware: (request) => {
106
+ if (debug) console.log(request);
107
+ return request;
108
+ },
109
+ responseMiddleware: (response) => {
110
+ if (debug) console.log(response);
111
+ }
112
+ });
113
+ } catch (error) {
114
+ console.log(error);
115
+ throw error;
116
+ }
117
+ };
118
+ //#endregion
119
+ //#region src/examplePayloads.ts
120
+ const getAccountIdExamplePayload = { data: { account: { id: "eyJpZGVudGl..." } } };
121
+ const listUserGroupsExamplePayload = { data: { account: {
122
+ id: "eyJpZGVudGlmaWVyIjoyNjczMDcsInR5cGUiOiJhY2NvdW50In0=",
123
+ userGroups: {
124
+ total: 0,
125
+ page: 1,
126
+ limit: 25,
127
+ hasNextPage: false,
128
+ items: []
129
+ }
130
+ } } };
131
+ const listUsersExamplePayload = { data: { account: { users: {
132
+ total: 1,
133
+ page: 1,
134
+ limit: 25,
135
+ hasNextPage: false,
136
+ items: [{
137
+ id: "eyJpZGVudGlmaWVyIjo2NjIyODcsInR5cGUiOiJ1c2VyIn0=",
138
+ email: "example@company.com",
139
+ name: "Jane Anderson",
140
+ avatar: null
141
+ }]
142
+ } } } };
143
+ const createAssetExamplePayload = { data: { createAsset: { job: { assetId: "eyJpZGVudGl..." } } } };
144
+ const uploadFileExamplePayload = { data: { uploadFile: {
145
+ id: "eyJpZGVudGl...",
146
+ urls: ["https://s3.amazonaws.com/frontify-cloud-files-us/frontify/file..."]
147
+ } } };
148
+ const createAttachmentExamplePayload = { data: { createAttachment: { job: { attachmentId: "eyJpZGVudGl..." } } } };
149
+ const deleteAssetExamplePayload = { data: { deleteAsset: { id: "eyJpZGVud..." } } };
150
+ const getAssetExamplePayload = { data: { asset: {
151
+ id: "eyJpZGVudGlma...",
152
+ creator: {
153
+ id: "eyJpZGVudGlma...",
154
+ name: "John Doe",
155
+ email: "example@example.com"
156
+ },
157
+ createdAt: "2024-09-17T23:54:57.000+00:00",
158
+ modifier: {
159
+ id: "eyJpZGVudGlma...",
160
+ name: "John Doe",
161
+ email: "example@example.com"
162
+ },
163
+ modifiedAt: "2024-09-17T23:54:57.000+00:00",
164
+ title: "Example Asset",
165
+ description: "This is a sample description",
166
+ attachments: [],
167
+ externalId: null,
168
+ tags: [],
169
+ copyright: {
170
+ status: "UNKNOWN",
171
+ notice: ""
172
+ },
173
+ expiresAt: null,
174
+ licenses: [],
175
+ status: "PROCESSING",
176
+ relatedAssets: { total: 0 },
177
+ comments: { total: 0 },
178
+ customMetadata: [],
179
+ location: {
180
+ brand: {
181
+ id: "eyJpZGVudGlma...",
182
+ name: "Example Brand"
183
+ },
184
+ library: null,
185
+ workspaceProject: {
186
+ id: "eyJpZGVudGlma...",
187
+ name: "Sample Project: Example Cats"
188
+ },
189
+ folder: null
190
+ }
191
+ } } };
192
+ const deleteAttachmentExamplePayload = { data: { deleteAttachment: { id: "eyJpZGVudGlmaWVyIjo5NDA3ODksInR5cGUiOiJhdHRhY2htZW50In0=" } } };
193
+ const getAssetsByIdsExamplePayload = { data: { assets: [{
194
+ id: "eyJpZGVudGlma...",
195
+ creator: {
196
+ id: "eyJpZGVudGlma...",
197
+ name: "John Doe",
198
+ email: "example@example.com"
199
+ },
200
+ createdAt: "2024-09-05T19:49:25.000+00:00",
201
+ modifier: {
202
+ id: "eyJpZGVudGlma...",
203
+ name: "John Doe",
204
+ email: "example@example.com"
205
+ },
206
+ modifiedAt: "2024-09-05T19:49:27.000+00:00",
207
+ title: "Example Title 2",
208
+ description: null,
209
+ attachments: [{
210
+ id: "eyJpZGVudGlma...",
211
+ creator: {
212
+ id: "eyJpZGVudGlma...",
213
+ name: "John Doe",
214
+ email: "example@example.com"
215
+ },
216
+ createdAt: "2024-09-17T23:42:43.000+00:00",
217
+ modifier: null,
218
+ modifiedAt: null,
219
+ name: "Sample Attachment 1",
220
+ filename: "example.png",
221
+ type: "",
222
+ externalId: null,
223
+ extension: "png",
224
+ size: 585728,
225
+ downloadUrl: "https://example.com/example.png"
226
+ }, {
227
+ id: "eyJpZGVudGlma...",
228
+ creator: {
229
+ id: "eyJpZGVudGlma...",
230
+ name: "John Doe",
231
+ email: "example@example.com"
232
+ },
233
+ createdAt: "2024-09-18T17:20:22.000+00:00",
234
+ modifier: null,
235
+ modifiedAt: null,
236
+ name: "Sample Attachment 2",
237
+ filename: "example.png",
238
+ type: "",
239
+ externalId: "512",
240
+ extension: "png",
241
+ size: 585728,
242
+ downloadUrl: "https://example.com/example.png"
243
+ }],
244
+ externalId: null,
245
+ tags: [],
246
+ copyright: {
247
+ status: "UNKNOWN",
248
+ notice: ""
249
+ },
250
+ expiresAt: null,
251
+ licenses: [],
252
+ status: "FINISHED",
253
+ relatedAssets: { total: 0 },
254
+ comments: { total: 0 },
255
+ customMetadata: [],
256
+ location: {
257
+ brand: {
258
+ id: "eyJpZGVudGlma...",
259
+ name: "Example Brand"
260
+ },
261
+ library: {
262
+ id: "eyJpZGVudGlma...",
263
+ name: "Logos"
264
+ },
265
+ workspaceProject: null,
266
+ folder: null
267
+ }
268
+ }] } };
269
+ const listAssetCommentsExamplePayload = { data: { asset: {
270
+ id: "eyJpZGV...",
271
+ externalId: null,
272
+ comments: {
273
+ total: 1,
274
+ page: 1,
275
+ limit: 25,
276
+ hasNextPage: false,
277
+ items: [{
278
+ id: "eyJpZGV...",
279
+ creator: {
280
+ id: "eyJpZGV...",
281
+ email: "example@email.com",
282
+ name: "John Doe"
283
+ },
284
+ createdAt: "2024-09-06T15:49:47.000+00:00",
285
+ modifier: null,
286
+ modifiedAt: null,
287
+ content: "Test comment \n\n",
288
+ mentionedUsers: [],
289
+ isResolved: false,
290
+ replies: {
291
+ total: 0,
292
+ hasNextPage: false,
293
+ page: 1,
294
+ limit: 50,
295
+ items: []
296
+ },
297
+ marking: null
298
+ }]
299
+ }
300
+ } } };
301
+ const listRelatedAssetsExamplePayload = { data: { asset: {
302
+ id: "eyJpZGV...",
303
+ externalId: null,
304
+ relatedAssets: {
305
+ total: 0,
306
+ hasNextPage: false,
307
+ page: 1,
308
+ limit: 25,
309
+ items: []
310
+ }
311
+ } } };
312
+ const moveAssetsExamplePayload = { data: { moveAssets: { assets: [{ id: "eyJpZGV..." }] } } };
313
+ const updateAssetExamplePayload = { data: { updateAsset: { asset: { id: "eyJpZGVudGlmaWVyIjoxMDEzOTI0MSwidHlwZSI6ImFzc2V0In0=" } } } };
314
+ const getBrandExamplePayload = { data: { brand: {
315
+ id: "eyJpZGVudGlmaWVyIjoyNjE1MDUsInR5cGUiOiJicmFuZCJ9",
316
+ name: "Monobrand",
317
+ rgbaColor: {
318
+ red: 130,
319
+ green: 95,
320
+ blue: 255,
321
+ alpha: 1
322
+ },
323
+ avatar: null,
324
+ slug: "monobrand",
325
+ customMetadataProperties: []
326
+ } } };
327
+ const listBrandLibrariesExamplePayload = { data: { brand: {
328
+ id: "eyJpZGV...",
329
+ name: "Monobrand",
330
+ libraries: {
331
+ total: 4,
332
+ hasNextPage: false,
333
+ page: 1,
334
+ limit: 25,
335
+ items: [{
336
+ id: "eyJpZGV...",
337
+ name: "Logos"
338
+ }]
339
+ }
340
+ } } };
341
+ const listBrandsExamplePayload = { data: { brands: [getBrandExamplePayload.data.brand] } };
342
+ const listBrandWorkspaceProjectsExamplePayload = { data: { brand: {
343
+ id: "eyJpZGV...",
344
+ name: "Monobrand",
345
+ workspaceProjects: {
346
+ total: 2,
347
+ limit: 25,
348
+ page: 1,
349
+ hasNextPage: false,
350
+ items: [{
351
+ id: "eyJpZGV...",
352
+ name: "Test Project: Siamese Cats"
353
+ }]
354
+ }
355
+ } } };
356
+ const createCollectionExamplePayload = { data: { createCollection: { collection: { id: "eyJpZGV..." } } } };
357
+ const deleteCollectionExamplePayload = { data: { deleteCollection: { id: "eyJpZGV..." } } };
358
+ const getLibraryExamplePayload = { data: { library: {
359
+ __typename: "LogoLibrary",
360
+ id: "eyJpZGV...",
361
+ name: "Logos",
362
+ color: null,
363
+ licenses: [],
364
+ customMetadataProperties: []
365
+ } } };
366
+ const listLibraryAssetsExamplePayload = { data: { library: {
367
+ id: "eyJpZGV...",
368
+ name: "Example Library",
369
+ assets: {
370
+ limit: 25,
371
+ page: 1,
372
+ total: 1,
373
+ hasNextPage: false,
374
+ items: [{
375
+ id: "eyJpZGV...",
376
+ creator: {
377
+ id: "eyJpZGV...",
378
+ name: "John Doe",
379
+ email: "john@example.com"
380
+ },
381
+ createdAt: "2024-09-05T19:49:25.000+00:00",
382
+ modifier: {
383
+ id: "eyJpZGV...",
384
+ name: "John Doe",
385
+ email: "john@example.com"
386
+ },
387
+ modifiedAt: "2024-09-05T19:49:27.000+00:00",
388
+ title: "example_title_1",
389
+ description: null,
390
+ attachments: [{
391
+ id: "eyJpZGV...",
392
+ creator: {
393
+ id: "eyJpZGV...",
394
+ name: "John Doe",
395
+ email: "john@example.com"
396
+ },
397
+ createdAt: "2024-09-17T23:42:43.000+00:00",
398
+ modifier: null,
399
+ modifiedAt: null,
400
+ name: "Example attachment",
401
+ filename: "example.png",
402
+ type: "",
403
+ externalId: null,
404
+ extension: "png",
405
+ size: 585728,
406
+ downloadUrl: "https://example.com/file1.png"
407
+ }],
408
+ externalId: null,
409
+ tags: [],
410
+ copyright: {
411
+ status: "UNKNOWN",
412
+ notice: ""
413
+ },
414
+ expiresAt: null,
415
+ licenses: [],
416
+ status: "FINISHED",
417
+ relatedAssets: { total: 0 },
418
+ comments: { total: 0 },
419
+ customMetadata: [],
420
+ location: {
421
+ brand: {
422
+ id: "eyJpZGV...",
423
+ name: "ExampleBrand"
424
+ },
425
+ library: {
426
+ id: "eyJpZGV...",
427
+ name: "Example Library"
428
+ },
429
+ workspaceProject: null,
430
+ folder: null
431
+ }
432
+ }]
433
+ }
434
+ } } };
435
+ const listLibraryCollaboratorsExamplePayload = { data: { library: {
436
+ id: "eyJpZGV...",
437
+ name: "Example Library",
438
+ collaborators: { users: {
439
+ total: 1,
440
+ page: 1,
441
+ limit: 25,
442
+ hasNextPage: false,
443
+ items: [{
444
+ id: "eyJpZGV...",
445
+ email: "john@example.com",
446
+ name: "John Doe"
447
+ }]
448
+ } }
449
+ } } };
450
+ const listLibraryCollectionsExamplePayload = { data: { library: {
451
+ id: "eyJpZGV...",
452
+ name: "Logos",
453
+ collections: {
454
+ total: 1,
455
+ page: 1,
456
+ limit: 25,
457
+ hasNextPage: false,
458
+ items: [{
459
+ id: "eyJpZGV...",
460
+ name: "Main Logos",
461
+ assets: {
462
+ total: 4,
463
+ page: 1,
464
+ limit: 25,
465
+ hasNextPage: false,
466
+ items: [{ id: "eyJpZGV..." }]
467
+ }
468
+ }]
469
+ }
470
+ } } };
471
+ const listLibraryFoldersExamplePayload = { data: { library: {
472
+ id: "eyJpZGV...",
473
+ name: "Logos",
474
+ browse: { folders: {
475
+ limit: 25,
476
+ page: 1,
477
+ hasNextPage: false,
478
+ total: 0,
479
+ items: []
480
+ } }
481
+ } } };
482
+ const updateCollectionExamplePayload = { data: { updateCollection: { collection: { id: "eyJpZGV..." } } } };
483
+ const installWebhookExamplePayload = { data: { installProjectWebhook: { webhook: {
484
+ id: "eyJpZGVudGlmaWVyIjo4OSwidHlwZSI6IndlYmhvb2sifQ==",
485
+ creator: {
486
+ id: "eyJpZGVudGlmaWVyIjoxMjMsInR5cGUiOiJ1c2VyIn0=",
487
+ email: "example@example.com",
488
+ name: "John Doe"
489
+ },
490
+ createdAt: "2024-09-19T13:18:52.000+00:00",
491
+ name: "Example Webhook",
492
+ notificationUrl: "https://hooks.example.io/trigger/SW5zdGFuY2VGbG93Q29uZmlnOjEyMzQ1NmUyLWM1M2QtNGUzOC04ZGY3LTE2ODRjYTJmZmVkZA==",
493
+ secret: "AbcD123SecretKeyExample"
494
+ } } } };
495
+ const listWebhooksExamplePayload = { data: { webhooks: {
496
+ total: 1,
497
+ page: 1,
498
+ limit: 25,
499
+ hasNextPage: false,
500
+ items: [{
501
+ id: "abc123...",
502
+ creator: {
503
+ id: "user456...",
504
+ name: "John Doe",
505
+ email: "john.doe@example.com"
506
+ },
507
+ createdAt: "2024-09-19T13:18:52.000+00:00",
508
+ name: "Sample Webhook",
509
+ notificationUrl: "https://example.com/trigger/webhook...",
510
+ secret: "sampleSecretKey...",
511
+ __typename: "ProjectWebhook",
512
+ project: { id: "proj789..." }
513
+ }]
514
+ } } };
515
+ const uninstallWebhookExamplePayload = { data: { uninstallWebhook: { webhook: { id: "eyJpZGV..." } } } };
516
+ const getWorkspaceProjectExamplePayload = { data: { workspaceProject: {
517
+ id: "eyJpZGVudGlmaWVyIjo0Mzk2MDUsInR5cGUiOiJwcm9qZWN0In0=",
518
+ name: "Test Project: Siamese Cats",
519
+ color: {
520
+ red: 225,
521
+ green: 255,
522
+ blue: 191,
523
+ alpha: 1
524
+ },
525
+ licenses: [],
526
+ collaborators: { users: {
527
+ total: 1,
528
+ hasNextPage: false,
529
+ page: 1,
530
+ limit: 25,
531
+ items: [{
532
+ id: "eyJpZGVudGlmaWVyIjo2NjIyODcsInR5cGUiOiJ1c2VyIn0=",
533
+ name: "Jane Anderson",
534
+ email: "example@company.com"
535
+ }]
536
+ } },
537
+ customMetadata: []
538
+ } } };
539
+ const listWorkspaceProjectAssetsExamplePayload = { data: { workspaceProject: {
540
+ id: "eyJpZG...==",
541
+ name: "Example Project: Dogs",
542
+ assets: {
543
+ limit: 25,
544
+ page: 1,
545
+ total: 1,
546
+ hasNextPage: false,
547
+ items: [{
548
+ id: "eyJpZG...==",
549
+ creator: {
550
+ id: "eyJpZG...==",
551
+ name: "John Doe",
552
+ email: "john.doe@example.com"
553
+ },
554
+ createdAt: "2024-09-17T23:36:00.000+00:00",
555
+ modifier: {
556
+ id: "eyJpZG...==",
557
+ name: "John Doe",
558
+ email: "john.doe@example.com"
559
+ },
560
+ modifiedAt: "2024-09-19T10:49:21.000+00:00",
561
+ title: "Sample Asset",
562
+ description: "Sample description",
563
+ attachments: [],
564
+ externalId: null,
565
+ tags: [],
566
+ copyright: {
567
+ status: "UNKNOWN",
568
+ notice: ""
569
+ },
570
+ expiresAt: null,
571
+ licenses: [],
572
+ status: "FINISHED",
573
+ relatedAssets: { total: 0 },
574
+ comments: { total: 0 },
575
+ customMetadata: [],
576
+ location: {
577
+ brand: {
578
+ id: "eyJpZG...==",
579
+ name: "ExampleBrand"
580
+ },
581
+ library: null,
582
+ workspaceProject: {
583
+ id: "eyJpZG...==",
584
+ name: "Example Project: Dogs"
585
+ },
586
+ folder: {
587
+ id: "eyJpZG...==",
588
+ name: "Sample Folder"
589
+ }
590
+ }
591
+ }]
592
+ }
593
+ } } };
594
+ const listWorkspaceProjectFoldersExamplePayload = { data: { workspaceProject: {
595
+ id: "eyJpZGV...",
596
+ name: "Test Project",
597
+ browse: { folders: {
598
+ limit: 25,
599
+ page: 1,
600
+ hasNextPage: false,
601
+ total: 1,
602
+ items: [{
603
+ id: "eyJpZGV...",
604
+ name: "A Parent Folder",
605
+ creator: {
606
+ id: "eyJpZGV...",
607
+ name: "John Doe",
608
+ email: "example@email.com"
609
+ },
610
+ createdAt: "2024-09-06T13:18:00.000+00:00",
611
+ modifier: null,
612
+ modifiedAt: null,
613
+ breadcrumbs: [],
614
+ folders: { total: 0 }
615
+ }]
616
+ } }
617
+ } } };
618
+ const createFolderExamplePayload = { data: { createFolder: { folder: { id: "eyJpZGV..." } } } };
619
+ const deleteFoldersExamplePayload = { data: { deleteFolders: { ids: ["eyJpZGV..."] } } };
620
+ const moveFoldersExamplePayload = { data: { moveFolders: { ids: ["eyJpZGV..."] } } };
621
+ const updateFolderExamplePayload = { data: { updateFolder: { folder: { id: "eyJpZGV..." } } } };
622
+ const getCurrentUserExamplePayload = { data: { currentUser: {
623
+ id: "eyJpZGV...",
624
+ email: "example@email.com",
625
+ name: "John Doe",
626
+ avatar: null
627
+ } } };
628
+ const page = (0, _prismatic_io_spectral.input)({
629
+ label: "Page",
630
+ type: "string",
631
+ required: false,
632
+ comments: "Page number",
633
+ default: "1",
634
+ example: "1",
635
+ placeholder: "1",
636
+ clean: _prismatic_io_spectral.util.types.toInt
637
+ });
638
+ const limit = (0, _prismatic_io_spectral.input)({
639
+ label: "Page Size",
640
+ type: "string",
641
+ required: false,
642
+ comments: "How many items to show per page.",
643
+ default: 25 .toString(),
644
+ example: "25",
645
+ placeholder: "25",
646
+ clean: _prismatic_io_spectral.util.types.toInt
647
+ });
648
+ const fetchAll = (0, _prismatic_io_spectral.input)({
649
+ label: "Fetch All",
650
+ type: "boolean",
651
+ required: false,
652
+ comments: "If true, it will fetch all records and ignore parameters like page and page size.",
653
+ clean: _prismatic_io_spectral.util.types.toBool
654
+ });
655
+ //#endregion
656
+ //#region src/utils/cleanStringInput.ts
657
+ const cleanStringInput = (value) => value ? _prismatic_io_spectral.util.types.toString(value) : void 0;
658
+ //#endregion
659
+ //#region src/inputs/sharedInputs.ts
660
+ const connection = (0, _prismatic_io_spectral.input)({
661
+ label: "Frontify Connection",
662
+ type: "connection",
663
+ required: true
664
+ });
665
+ const libraryId$2 = (0, _prismatic_io_spectral.input)({
666
+ label: "Library ID",
667
+ type: "string",
668
+ required: true,
669
+ comments: "ID of the Library entity.",
670
+ example: "eyJpZG...",
671
+ placeholder: "eyJpZG...",
672
+ clean: _prismatic_io_spectral.util.types.toString,
673
+ dataSource: "libraryDataSource"
674
+ });
675
+ const projectId$1 = (0, _prismatic_io_spectral.input)({
676
+ label: "Workspace Project ID",
677
+ type: "string",
678
+ required: true,
679
+ comments: "ID of the Workspace Project entity.",
680
+ example: "eyJpZG...",
681
+ placeholder: "eyJpZG...",
682
+ clean: _prismatic_io_spectral.util.types.toString,
683
+ dataSource: "workspaceProjectDatasource"
684
+ });
685
+ const brandId = (0, _prismatic_io_spectral.input)({
686
+ label: "Brand ID",
687
+ type: "string",
688
+ required: true,
689
+ comments: "ID of the Brand entity.",
690
+ example: "eyJpZG...",
691
+ placeholder: "eyJpZG...",
692
+ clean: _prismatic_io_spectral.util.types.toString,
693
+ dataSource: "brandDataSource"
694
+ });
695
+ const assetSearch = (0, _prismatic_io_spectral.input)({
696
+ label: "Search Query",
697
+ comments: "Limit the result set by the search term.",
698
+ type: "string",
699
+ required: false,
700
+ example: "some search term",
701
+ placeholder: "some search term",
702
+ clean: cleanStringInput
703
+ });
704
+ const assetExternalId = (0, _prismatic_io_spectral.input)({
705
+ label: "External ID",
706
+ comments: "Limit the result set by the external ID of an Asset.",
707
+ type: "string",
708
+ required: false,
709
+ example: "123456",
710
+ placeholder: "123456",
711
+ clean: cleanStringInput
712
+ });
713
+ //#endregion
714
+ //#region src/inputs/account.ts
715
+ const getAccountIdInputs = { connection };
716
+ const listUserGroupsInputs = {
717
+ connection,
718
+ fetchAll: (0, _prismatic_io_spectral.input)({
719
+ label: "Fetch All",
720
+ type: "boolean",
721
+ required: false,
722
+ comments: "If true, it will fetch all UserGroups and ignore parameters like page and page size. This toggle will not affect the User pagination within each UserGroup.",
723
+ clean: _prismatic_io_spectral.util.types.toBool
724
+ }),
725
+ pagination: (0, _prismatic_io_spectral.structuredObjectInput)({
726
+ label: "Pagination",
727
+ required: false,
728
+ comments: "Page navigation controls.",
729
+ inputs: {
730
+ page,
731
+ limit,
732
+ userPage: (0, _prismatic_io_spectral.input)({
733
+ label: "Page (users)",
734
+ comments: "For paging through users belonging to a userGroup.",
735
+ type: "string",
736
+ default: "1",
737
+ example: "1",
738
+ placeholder: "1",
739
+ clean: _prismatic_io_spectral.util.types.toInt
740
+ }),
741
+ userPageLimit: (0, _prismatic_io_spectral.input)({
742
+ label: "Limit (user pages)",
743
+ comments: "How many records to show per page of users.",
744
+ type: "string",
745
+ default: "25",
746
+ example: "25",
747
+ placeholder: "25",
748
+ clean: _prismatic_io_spectral.util.types.toInt
749
+ })
750
+ }
751
+ })
752
+ };
753
+ const listUsersInputs = {
754
+ connection,
755
+ fetchAll,
756
+ pagination: (0, _prismatic_io_spectral.structuredObjectInput)({
757
+ label: "Pagination",
758
+ required: false,
759
+ comments: "Page navigation controls.",
760
+ inputs: {
761
+ page,
762
+ limit
763
+ }
764
+ })
765
+ };
766
+ //#endregion
767
+ //#region src/actions/account/getAccountId.ts
768
+ const getAccountId = (0, _prismatic_io_spectral.action)({
769
+ display: {
770
+ label: "Get Account ID",
771
+ description: "Retrieve current Account ID."
772
+ },
773
+ perform: async (context, { connection }) => {
774
+ const query = graphql_request.gql`
775
+ query GetAccountId {
776
+ account {
777
+ id
778
+ }
779
+ }
780
+ `;
781
+ return { data: await createClient({
782
+ connection,
783
+ debug: context.debug.enabled
784
+ }).request(query) };
785
+ },
786
+ inputs: getAccountIdInputs,
787
+ examplePayload: getAccountIdExamplePayload
788
+ });
789
+ //#endregion
790
+ //#region src/constants.ts
791
+ const LIST_BRAND_LIBRARIES_QUERY = graphql_request.gql`
792
+ query listBrandLibraries($brandId: ID!, $limit: Int, $page: Int) {
793
+ brand(id: $brandId) {
794
+ id
795
+ name
796
+ libraries(limit: $limit, page: $page) {
797
+ total
798
+ hasNextPage
799
+ page
800
+ limit
801
+ items {
802
+ id
803
+ name
804
+ }
805
+ }
806
+ }
807
+ }
808
+ `;
809
+ const LOOK_BACK_DATE_PATTERN = /^(\d{4})-(\d{2})-(\d{2})$/;
810
+ //#endregion
811
+ //#region src/utils/graphqlFetchAll.ts
812
+ const graphqlFetchAll = async ({ client, query, params = {}, hasNextPath = ["hasNextPage"] }) => {
813
+ const responses = [];
814
+ let hasNext = true;
815
+ let page = 1;
816
+ while (hasNext) {
817
+ const response = await client.request(query, {
818
+ page,
819
+ limit: 25,
820
+ ...params
821
+ });
822
+ hasNext = hasNextPath.reduce((obj, key) => typeof obj === "object" && obj !== null ? obj[key] : false, response);
823
+ page += 1;
824
+ responses.push(response);
825
+ }
826
+ return responses;
827
+ };
828
+ //#endregion
829
+ //#region src/actions/account/index.ts
830
+ var account_default = {
831
+ getAccountId,
832
+ listUserGroups: (0, _prismatic_io_spectral.action)({
833
+ display: {
834
+ label: "List User Groups",
835
+ description: "Retrieve UserGroups list for the current Account."
836
+ },
837
+ perform: async (context, { connection, pagination, fetchAll }) => {
838
+ const client = createClient({
839
+ connection,
840
+ debug: context.debug.enabled
841
+ });
842
+ const query = graphql_request.gql`
843
+ query ListUserGroups(
844
+ $page: Int
845
+ $limit: Int
846
+ $userPage: Int
847
+ $userPageLimit: Int
848
+ ) {
849
+ account {
850
+ id
851
+ userGroups(page: $page, limit: $limit) {
852
+ total
853
+ page
854
+ limit
855
+ hasNextPage
856
+ items {
857
+ id
858
+ name
859
+ users(page: $userPage, limit: $userPageLimit) {
860
+ total
861
+ page
862
+ limit
863
+ hasNextPage
864
+ items {
865
+ id
866
+ email
867
+ name
868
+ avatar
869
+ }
870
+ }
871
+ }
872
+ }
873
+ }
874
+ }
875
+ `;
876
+ if (fetchAll) {
877
+ const responses = await graphqlFetchAll({
878
+ client,
879
+ query,
880
+ params: {
881
+ userPage: 1,
882
+ userPageLimit: 50
883
+ },
884
+ hasNextPath: [
885
+ "account",
886
+ "userGroups",
887
+ "hasNextPage"
888
+ ]
889
+ });
890
+ if (responses.length === 1) return { data: responses[0] };
891
+ const baseResponse = responses.slice(-1)[0];
892
+ const combinedUserGroups = responses.flatMap((response) => response.account.userGroups.items);
893
+ return { data: { account: {
894
+ ...baseResponse.account,
895
+ userGroups: {
896
+ ...baseResponse.account.userGroups,
897
+ items: combinedUserGroups
898
+ }
899
+ } } };
900
+ }
901
+ return { data: await client.request(query, {
902
+ limit: pagination.limit,
903
+ page: pagination.page,
904
+ userPage: pagination.userPage,
905
+ userPageLimit: pagination.userPageLimit
906
+ }) };
907
+ },
908
+ inputs: listUserGroupsInputs,
909
+ examplePayload: listUserGroupsExamplePayload
910
+ }),
911
+ listUsers: (0, _prismatic_io_spectral.action)({
912
+ display: {
913
+ label: "List Users",
914
+ description: "Retrieve Users list for the current Account."
915
+ },
916
+ perform: async (context, { connection, pagination, fetchAll }) => {
917
+ const client = createClient({
918
+ connection,
919
+ debug: context.debug.enabled
920
+ });
921
+ const query = graphql_request.gql`
922
+ query GetAccountUsers($page: Int, $limit: Int) {
923
+ account {
924
+ users(page: $page, limit: $limit) {
925
+ total
926
+ page
927
+ limit
928
+ hasNextPage
929
+ items {
930
+ id
931
+ email
932
+ name
933
+ avatar
934
+ }
935
+ }
936
+ }
937
+ }
938
+ `;
939
+ if (fetchAll) {
940
+ const responses = await graphqlFetchAll({
941
+ client,
942
+ query,
943
+ hasNextPath: [
944
+ "account",
945
+ "users",
946
+ "hasNextPage"
947
+ ]
948
+ });
949
+ if (responses.length === 1) return { data: responses[0] };
950
+ const baseResponse = responses.slice(-1)[0];
951
+ const combinedUsers = responses.flatMap((response) => response.account.users.items);
952
+ return { data: { account: {
953
+ ...baseResponse.account,
954
+ users: {
955
+ ...baseResponse.account.users,
956
+ items: combinedUsers
957
+ }
958
+ } } };
959
+ }
960
+ return { data: await client.request(query, {
961
+ limit: pagination.limit,
962
+ page: pagination.page
963
+ }) };
964
+ },
965
+ inputs: listUsersInputs,
966
+ examplePayload: listUsersExamplePayload
967
+ })
968
+ };
969
+ //#endregion
970
+ //#region src/utils/cleanNumberInput.ts
971
+ const cleanNumberInput = (value) => value ? _prismatic_io_spectral.util.types.toNumber(value) : void 0;
972
+ //#endregion
973
+ //#region src/utils/cleanTagsInput.ts
974
+ const cleanTagsInput = (tags) => {
975
+ if (Array.isArray(tags)) {
976
+ const tagObjects = tags.map((tag) => {
977
+ return { value: tag };
978
+ });
979
+ return tagObjects.length > 0 ? tagObjects : void 0;
980
+ }
981
+ };
982
+ //#endregion
983
+ //#region src/utils/cleanValueListInput.ts
984
+ const cleanValueListInput = (value) => {
985
+ if (Array.isArray(value)) return value.length > 0 ? value : void 0;
986
+ };
987
+ //#endregion
988
+ //#region src/inputs/assets.ts
989
+ const description = (0, _prismatic_io_spectral.input)({
990
+ label: "Description",
991
+ comments: "Asset description.",
992
+ type: "string",
993
+ placeholder: "Some description",
994
+ example: "Some description",
995
+ required: false,
996
+ clean: cleanStringInput
997
+ });
998
+ const copyrightStatus = (0, _prismatic_io_spectral.input)({
999
+ label: "Copyright Status",
1000
+ comments: "Asset copyright status.",
1001
+ example: "UNKNOWN",
1002
+ placeholder: "UNKNOWN",
1003
+ required: false,
1004
+ model: [
1005
+ {
1006
+ label: "Unknown",
1007
+ value: "UNKNOWN"
1008
+ },
1009
+ {
1010
+ label: "Copyrighted",
1011
+ value: "COPYRIGHTED"
1012
+ },
1013
+ {
1014
+ label: "Public",
1015
+ value: "PUBLIC"
1016
+ }
1017
+ ],
1018
+ type: "string",
1019
+ clean: cleanStringInput
1020
+ });
1021
+ const copyrightNotice = (0, _prismatic_io_spectral.input)({
1022
+ label: "Copyright Notice",
1023
+ comments: "Asset copyright notice. Supports medium text length.",
1024
+ type: "text",
1025
+ required: false,
1026
+ placeholder: "© 2021 My Company",
1027
+ example: "© 2021 My Company",
1028
+ clean: cleanStringInput
1029
+ });
1030
+ const expiresAt = (0, _prismatic_io_spectral.input)({
1031
+ label: "Expires At",
1032
+ comments: "Asset will expire once the defined date is reached.",
1033
+ type: "string",
1034
+ required: false,
1035
+ example: "2001-12-31T22:10:30.000+00:00",
1036
+ placeholder: "2001-12-31T22:10:30.000+00:00",
1037
+ clean: cleanStringInput
1038
+ });
1039
+ const author = (0, _prismatic_io_spectral.input)({
1040
+ label: "Author",
1041
+ comments: "Represents the Author of the Asset.",
1042
+ example: "Photographer Name",
1043
+ placeholder: "Photographer Name",
1044
+ type: "string",
1045
+ required: false,
1046
+ clean: cleanStringInput
1047
+ });
1048
+ const createAssetInputs = {
1049
+ connection,
1050
+ fileId: (0, _prismatic_io_spectral.input)({
1051
+ label: "File ID",
1052
+ comments: "A file's Signed ID, returned by the Upload File action.",
1053
+ type: "string",
1054
+ required: true,
1055
+ example: "eyJpZG...",
1056
+ placeholder: "eyJpZG...",
1057
+ clean: _prismatic_io_spectral.util.types.toString
1058
+ }),
1059
+ title: (0, _prismatic_io_spectral.input)({
1060
+ label: "Title",
1061
+ comments: "Asset title or display name.",
1062
+ type: "string",
1063
+ required: true,
1064
+ placeholder: "My Asset",
1065
+ example: "My Asset",
1066
+ clean: _prismatic_io_spectral.util.types.toString
1067
+ }),
1068
+ parentId: (0, _prismatic_io_spectral.input)({
1069
+ label: "Parent ID",
1070
+ comments: "The parent Id, where the Asset should be located in. Should either be a Library, WorkspaceProject or Folder Id. Important: Cannot be used in conjunction with directory if the Id is from a Folder.",
1071
+ type: "string",
1072
+ required: true,
1073
+ example: "eyJpZG...",
1074
+ placeholder: "eyJpZG...",
1075
+ clean: cleanStringInput
1076
+ }),
1077
+ externalId: (0, _prismatic_io_spectral.input)({
1078
+ label: "External ID",
1079
+ comments: "Asset external ID.",
1080
+ type: "string",
1081
+ required: false,
1082
+ placeholder: "12345",
1083
+ example: "12345",
1084
+ clean: cleanStringInput
1085
+ }),
1086
+ tags: (0, _prismatic_io_spectral.input)({
1087
+ label: "Tags",
1088
+ comments: "List of tags to create with the Asset.",
1089
+ collection: "valuelist",
1090
+ type: "string",
1091
+ required: false,
1092
+ example: "tag1",
1093
+ placeholder: "tag1",
1094
+ clean: cleanTagsInput
1095
+ }),
1096
+ directory: (0, _prismatic_io_spectral.input)({
1097
+ label: "Directory",
1098
+ comments: "An array of strings representing the directory, if a folder does not exist, it is created. Important: Cannot be used in conjunction with parentId that is from a Folder.",
1099
+ example: "My Folder",
1100
+ collection: "valuelist",
1101
+ required: false,
1102
+ type: "string",
1103
+ clean: cleanValueListInput
1104
+ }),
1105
+ additionalFields: (0, _prismatic_io_spectral.structuredObjectInput)({
1106
+ label: "Additional Fields",
1107
+ required: false,
1108
+ comments: "Additional optional fields: includes Description, Copyright Status, Copyright Notice, Skip File Metadata, Expires At, and Author.",
1109
+ inputs: {
1110
+ description,
1111
+ copyrightStatus,
1112
+ copyrightNotice,
1113
+ skipFileMetadata: (0, _prismatic_io_spectral.input)({
1114
+ label: "Skip File Metadata",
1115
+ comments: "Skip file's EXIF metadata. When true, it will ignore all file metadata contents.",
1116
+ type: "boolean",
1117
+ default: "false",
1118
+ clean: _prismatic_io_spectral.util.types.toBool
1119
+ }),
1120
+ expiresAt,
1121
+ author
1122
+ }
1123
+ })
1124
+ };
1125
+ const uploadFileInputs = {
1126
+ connection,
1127
+ filename: (0, _prismatic_io_spectral.input)({
1128
+ label: "File Name",
1129
+ comments: "File name.",
1130
+ type: "string",
1131
+ required: true,
1132
+ example: "my-file.jpg",
1133
+ placeholder: "my-file.jpg",
1134
+ clean: _prismatic_io_spectral.util.types.toString
1135
+ }),
1136
+ size: (0, _prismatic_io_spectral.input)({
1137
+ label: "Size",
1138
+ comments: "File size in bytes.",
1139
+ type: "string",
1140
+ example: "104857600",
1141
+ placeholder: "104857600",
1142
+ required: true,
1143
+ clean: _prismatic_io_spectral.util.types.toNumber
1144
+ }),
1145
+ chunkSize: (0, _prismatic_io_spectral.input)({
1146
+ label: "Chunk Size",
1147
+ comments: "File chunk size in bytes. Value must be integer between 5MB and 1GB. See the [Frontify uploadFile mutation](https://frontify.github.io/graphql-reference/mutations/uploadFile) for full upload documentation.",
1148
+ type: "string",
1149
+ example: "104857600",
1150
+ placeholder: "104857600",
1151
+ required: false,
1152
+ clean: cleanNumberInput
1153
+ })
1154
+ };
1155
+ const createAttachmentInputs = {
1156
+ connection,
1157
+ parentId: (0, _prismatic_io_spectral.input)({
1158
+ label: "Parent ID",
1159
+ type: "string",
1160
+ comments: "The parent ID of the attachment. For parents of Asset type only.",
1161
+ example: "eyJpZG...",
1162
+ placeholder: "eyJpZG...",
1163
+ required: true,
1164
+ clean: _prismatic_io_spectral.util.types.toString
1165
+ }),
1166
+ fileId: (0, _prismatic_io_spectral.input)({
1167
+ label: "File ID",
1168
+ comments: "The signed ID returned by the Upload File action.",
1169
+ example: "eyJpZG...",
1170
+ placeholder: "eyJpZG...",
1171
+ type: "string",
1172
+ required: true,
1173
+ clean: _prismatic_io_spectral.util.types.toString
1174
+ }),
1175
+ name: (0, _prismatic_io_spectral.input)({
1176
+ label: "Name",
1177
+ comments: "Attachment name or display name.",
1178
+ type: "string",
1179
+ required: true,
1180
+ example: "My Attachment",
1181
+ placeholder: "My Attachment",
1182
+ clean: _prismatic_io_spectral.util.types.toString
1183
+ }),
1184
+ externalId: (0, _prismatic_io_spectral.input)({
1185
+ label: "External ID",
1186
+ comments: "Attachment external ID.",
1187
+ type: "string",
1188
+ required: false,
1189
+ placeholder: "12345",
1190
+ example: "12345",
1191
+ clean: cleanStringInput
1192
+ })
1193
+ };
1194
+ const deleteAssetInputs = {
1195
+ connection,
1196
+ assetId: (0, _prismatic_io_spectral.input)({
1197
+ label: "Asset ID",
1198
+ comments: "ID of the Asset to delete.",
1199
+ type: "string",
1200
+ required: true,
1201
+ example: "eyJpZG...",
1202
+ placeholder: "eyJpZG...",
1203
+ clean: _prismatic_io_spectral.util.types.toString,
1204
+ dataSource: "libraryAssetDataSource"
1205
+ })
1206
+ };
1207
+ const getAssetInputs = {
1208
+ connection,
1209
+ assetId: (0, _prismatic_io_spectral.input)({
1210
+ label: "Asset ID",
1211
+ type: "string",
1212
+ required: true,
1213
+ comments: "ID of the Asset to retrieve.",
1214
+ example: "eyJpZG...",
1215
+ placeholder: "eyJpZG...",
1216
+ clean: _prismatic_io_spectral.util.types.toString,
1217
+ dataSource: "libraryAssetDataSource"
1218
+ })
1219
+ };
1220
+ const deleteAttachmentInputs = {
1221
+ connection,
1222
+ attachmentId: (0, _prismatic_io_spectral.input)({
1223
+ label: "Attachment ID",
1224
+ comments: "ID of the Attachment to delete.",
1225
+ type: "string",
1226
+ required: true,
1227
+ example: "eyJpZG...",
1228
+ placeholder: "eyJpZG...",
1229
+ clean: _prismatic_io_spectral.util.types.toString
1230
+ })
1231
+ };
1232
+ const getAssetsByIdsInputs = {
1233
+ connection,
1234
+ assetIds: (0, _prismatic_io_spectral.input)({
1235
+ label: "Asset IDs",
1236
+ collection: "valuelist",
1237
+ comments: "List of Asset IDs to retrieve.",
1238
+ type: "string",
1239
+ required: true,
1240
+ example: "eyJpZG...",
1241
+ placeholder: "eyJpZG...",
1242
+ clean: cleanValueListInput,
1243
+ dataSource: "libraryAssetDataSource"
1244
+ })
1245
+ };
1246
+ const listAssetCommentsInputs = {
1247
+ connection,
1248
+ assetId: (0, _prismatic_io_spectral.input)({
1249
+ label: "Asset ID",
1250
+ type: "string",
1251
+ required: true,
1252
+ comments: "ID of the Asset to retrieve comments for.",
1253
+ example: "eyJpZG...",
1254
+ placeholder: "eyJpZG...",
1255
+ clean: _prismatic_io_spectral.util.types.toString,
1256
+ dataSource: "libraryAssetDataSource"
1257
+ }),
1258
+ fetchAll,
1259
+ pagination: (0, _prismatic_io_spectral.structuredObjectInput)({
1260
+ label: "Pagination",
1261
+ required: false,
1262
+ comments: "Page navigation controls.",
1263
+ inputs: {
1264
+ page,
1265
+ limit,
1266
+ replyLimit: (0, _prismatic_io_spectral.input)({
1267
+ label: "Reply Limit",
1268
+ comments: "The limit of how may replies to show per comment.",
1269
+ type: "string",
1270
+ default: "50",
1271
+ required: false,
1272
+ example: "50",
1273
+ placeholder: "50",
1274
+ clean: _prismatic_io_spectral.util.types.toInt
1275
+ })
1276
+ }
1277
+ })
1278
+ };
1279
+ const listRelatedAssetsInputs = {
1280
+ connection,
1281
+ assetId: (0, _prismatic_io_spectral.input)({
1282
+ label: "Asset ID",
1283
+ type: "string",
1284
+ required: true,
1285
+ comments: "ID of the Asset to retrieve related assets for.",
1286
+ example: "eyJpZG...",
1287
+ placeholder: "eyJpZG...",
1288
+ clean: _prismatic_io_spectral.util.types.toString,
1289
+ dataSource: "libraryAssetDataSource"
1290
+ }),
1291
+ fetchAll,
1292
+ pagination: (0, _prismatic_io_spectral.structuredObjectInput)({
1293
+ label: "Pagination",
1294
+ required: false,
1295
+ comments: "Page navigation controls.",
1296
+ inputs: {
1297
+ page,
1298
+ limit
1299
+ }
1300
+ })
1301
+ };
1302
+ const moveAssetsInputs = {
1303
+ connection,
1304
+ assetIds: (0, _prismatic_io_spectral.input)({
1305
+ label: "Asset IDs",
1306
+ comments: "IDs of the Assets to move.",
1307
+ collection: "valuelist",
1308
+ type: "string",
1309
+ required: true,
1310
+ example: "eyJpZG...",
1311
+ placeholder: "eyJpZG...",
1312
+ clean: cleanValueListInput,
1313
+ dataSource: "libraryAssetDataSource"
1314
+ }),
1315
+ destinationId: (0, _prismatic_io_spectral.input)({
1316
+ label: "Destination ID",
1317
+ comments: "Only allows Library, Workspace, or Folder IDs.",
1318
+ type: "string",
1319
+ required: true,
1320
+ example: "eyJpZG...",
1321
+ placeholder: "eyJpZG...",
1322
+ clean: _prismatic_io_spectral.util.types.toString
1323
+ })
1324
+ };
1325
+ const updateAssetInputs = {
1326
+ connection,
1327
+ assetId: (0, _prismatic_io_spectral.input)({
1328
+ label: "Asset ID",
1329
+ comments: "ID of the Asset to update.",
1330
+ required: true,
1331
+ type: "string",
1332
+ example: "eyJpZG...",
1333
+ placeholder: "eyJpZG...",
1334
+ clean: _prismatic_io_spectral.util.types.toString,
1335
+ dataSource: "libraryAssetDataSource"
1336
+ }),
1337
+ filename: (0, _prismatic_io_spectral.input)({
1338
+ label: "File Name",
1339
+ comments: "Asset filename, including extension.",
1340
+ type: "string",
1341
+ required: false,
1342
+ example: "my-file.jpg",
1343
+ placeholder: "my-file.jpg",
1344
+ clean: cleanStringInput
1345
+ }),
1346
+ title: (0, _prismatic_io_spectral.input)({
1347
+ ...createAssetInputs.title,
1348
+ required: false,
1349
+ clean: cleanStringInput
1350
+ }),
1351
+ additionalFields: (0, _prismatic_io_spectral.structuredObjectInput)({
1352
+ label: "Additional Fields",
1353
+ required: false,
1354
+ comments: "Additional optional fields: includes Description, Copyright Status, Copyright Notice, Expires At, and Author.",
1355
+ inputs: {
1356
+ description,
1357
+ copyrightStatus,
1358
+ copyrightNotice,
1359
+ expiresAt,
1360
+ author
1361
+ }
1362
+ })
1363
+ };
1364
+ //#endregion
1365
+ //#region src/actions/assets/index.ts
1366
+ var assets_default = {
1367
+ createAsset: (0, _prismatic_io_spectral.action)({
1368
+ display: {
1369
+ label: "Create Asset",
1370
+ description: "Create an Asset."
1371
+ },
1372
+ perform: async (context, { connection, tags, directory, externalId, fileId, parentId, title, additionalFields: { copyrightNotice, copyrightStatus, author, description, expiresAt, skipFileMetadata } }) => {
1373
+ const input = {
1374
+ author,
1375
+ description,
1376
+ directory,
1377
+ externalId,
1378
+ fileId,
1379
+ parentId,
1380
+ skipFileMetadata,
1381
+ title,
1382
+ expiresAt: expiresAt || null,
1383
+ copyright: {
1384
+ notice: copyrightNotice,
1385
+ status: copyrightStatus
1386
+ },
1387
+ tags
1388
+ };
1389
+ const mutation = graphql_request.gql`
1390
+ mutation createAsset($input: CreateAssetInput!) {
1391
+ createAsset(input: $input) {
1392
+ job {
1393
+ assetId
1394
+ }
1395
+ }
1396
+ }
1397
+ `;
1398
+ return { data: await createClient({
1399
+ connection,
1400
+ debug: context.debug.enabled
1401
+ }).request(mutation, { input }) };
1402
+ },
1403
+ inputs: createAssetInputs,
1404
+ examplePayload: createAssetExamplePayload
1405
+ }),
1406
+ createAttachment: (0, _prismatic_io_spectral.action)({
1407
+ display: {
1408
+ label: "Create Attachment",
1409
+ description: "Create a new Attachment."
1410
+ },
1411
+ perform: async (context, { connection, ...input }) => {
1412
+ const mutation = graphql_request.gql`
1413
+ mutation createAttachment($input: CreateAttachmentInput!) {
1414
+ createAttachment(input: $input) {
1415
+ job {
1416
+ attachmentId
1417
+ }
1418
+ }
1419
+ }
1420
+ `;
1421
+ return { data: await createClient({
1422
+ connection,
1423
+ debug: context.debug.enabled
1424
+ }).request(mutation, { input: { ...input } }) };
1425
+ },
1426
+ inputs: createAttachmentInputs,
1427
+ examplePayload: createAttachmentExamplePayload
1428
+ }),
1429
+ deleteAsset: (0, _prismatic_io_spectral.action)({
1430
+ display: {
1431
+ label: "Delete Asset",
1432
+ description: "Delete an Asset."
1433
+ },
1434
+ perform: async (context, { connection, ...configVars }) => {
1435
+ const mutation = graphql_request.gql`
1436
+ mutation deleteAsset($input: DeleteAssetInput!) {
1437
+ deleteAsset(input: $input) {
1438
+ id
1439
+ }
1440
+ }
1441
+ `;
1442
+ return { data: await createClient({
1443
+ connection,
1444
+ debug: context.debug.enabled
1445
+ }).request(mutation, { input: { id: configVars.assetId } }) };
1446
+ },
1447
+ inputs: deleteAssetInputs,
1448
+ examplePayload: deleteAssetExamplePayload
1449
+ }),
1450
+ deleteAttachment: (0, _prismatic_io_spectral.action)({
1451
+ display: {
1452
+ label: "Delete Attachment",
1453
+ description: "Delete an existing Attachment."
1454
+ },
1455
+ perform: async (context, { connection, attachmentId }) => {
1456
+ const mutation = graphql_request.gql`
1457
+ mutation deleteAttachment($input: DeleteAttachmentInput!) {
1458
+ deleteAttachment(input: $input) {
1459
+ id
1460
+ }
1461
+ }
1462
+ `;
1463
+ return { data: await createClient({
1464
+ connection,
1465
+ debug: context.debug.enabled
1466
+ }).request(mutation, { input: { id: attachmentId } }) };
1467
+ },
1468
+ inputs: deleteAttachmentInputs,
1469
+ examplePayload: deleteAttachmentExamplePayload
1470
+ }),
1471
+ getAsset: (0, _prismatic_io_spectral.action)({
1472
+ display: {
1473
+ label: "Get Asset",
1474
+ description: "Retrieve an Asset by ID."
1475
+ },
1476
+ perform: async (context, { connection, assetId }) => {
1477
+ const query = graphql_request.gql`
1478
+ query getAsset($assetId: ID!) {
1479
+ asset(id: $assetId) {
1480
+ id
1481
+ creator {
1482
+ id
1483
+ name
1484
+ email
1485
+ }
1486
+ createdAt
1487
+ modifier {
1488
+ id
1489
+ name
1490
+ email
1491
+ }
1492
+ modifiedAt
1493
+ title
1494
+ description
1495
+ attachments {
1496
+ id
1497
+ creator {
1498
+ id
1499
+ name
1500
+ email
1501
+ }
1502
+ createdAt
1503
+ modifier {
1504
+ id
1505
+ name
1506
+ email
1507
+ }
1508
+ modifiedAt
1509
+ name
1510
+ filename
1511
+ type
1512
+ externalId
1513
+ extension
1514
+ size
1515
+ downloadUrl
1516
+ }
1517
+ externalId
1518
+ tags {
1519
+ value
1520
+ source
1521
+ }
1522
+ copyright {
1523
+ status
1524
+ notice
1525
+ }
1526
+ expiresAt
1527
+ licenses {
1528
+ id
1529
+ title
1530
+ license
1531
+ addByDefault
1532
+ requireConsensus
1533
+ }
1534
+ status
1535
+ relatedAssets {
1536
+ total
1537
+ }
1538
+ comments {
1539
+ total
1540
+ }
1541
+ customMetadata {
1542
+ ... on CustomMetadataValue {
1543
+ value
1544
+ }
1545
+ ... on CustomMetadataValues {
1546
+ values
1547
+ }
1548
+ property {
1549
+ id
1550
+ creator {
1551
+ id
1552
+ name
1553
+ email
1554
+ }
1555
+ createdAt
1556
+ modifier {
1557
+ id
1558
+ name
1559
+ email
1560
+ }
1561
+ modifiedAt
1562
+ name
1563
+ type {
1564
+ name
1565
+ }
1566
+ helpText
1567
+ isRequired
1568
+ defaultValue
1569
+ }
1570
+ }
1571
+ location {
1572
+ brand {
1573
+ id
1574
+ name
1575
+ }
1576
+ library {
1577
+ id
1578
+ name
1579
+ }
1580
+ workspaceProject {
1581
+ id
1582
+ name
1583
+ }
1584
+ folder {
1585
+ id
1586
+ name
1587
+ }
1588
+ }
1589
+ }
1590
+ }
1591
+ `;
1592
+ return { data: await createClient({
1593
+ connection,
1594
+ debug: context.debug.enabled
1595
+ }).request(query, { assetId }) };
1596
+ },
1597
+ inputs: getAssetInputs,
1598
+ examplePayload: getAssetExamplePayload
1599
+ }),
1600
+ getAssetsByIds: (0, _prismatic_io_spectral.action)({
1601
+ display: {
1602
+ label: "Get Assets by IDs",
1603
+ description: "Retrieve a list of Assets by IDs."
1604
+ },
1605
+ perform: async (context, { connection, assetIds }) => {
1606
+ const query = graphql_request.gql`
1607
+ query listAssets($assetIds: [ID!]!) {
1608
+ assets(ids: $assetIds) {
1609
+ id
1610
+ creator {
1611
+ id
1612
+ name
1613
+ email
1614
+ }
1615
+ createdAt
1616
+ modifier {
1617
+ id
1618
+ name
1619
+ email
1620
+ }
1621
+ modifiedAt
1622
+ title
1623
+ description
1624
+ attachments {
1625
+ id
1626
+ creator {
1627
+ id
1628
+ name
1629
+ email
1630
+ }
1631
+ createdAt
1632
+ modifier {
1633
+ id
1634
+ name
1635
+ email
1636
+ }
1637
+ modifiedAt
1638
+ name
1639
+ filename
1640
+ type
1641
+ externalId
1642
+ extension
1643
+ size
1644
+ downloadUrl
1645
+ }
1646
+ externalId
1647
+ tags {
1648
+ value
1649
+ source
1650
+ }
1651
+ copyright {
1652
+ status
1653
+ notice
1654
+ }
1655
+ expiresAt
1656
+ licenses {
1657
+ id
1658
+ title
1659
+ license
1660
+ addByDefault
1661
+ requireConsensus
1662
+ }
1663
+ status
1664
+ relatedAssets {
1665
+ total
1666
+ }
1667
+ comments {
1668
+ total
1669
+ }
1670
+ customMetadata {
1671
+ ... on CustomMetadataValue {
1672
+ value
1673
+ }
1674
+ ... on CustomMetadataValues {
1675
+ values
1676
+ }
1677
+ property {
1678
+ id
1679
+ creator {
1680
+ id
1681
+ name
1682
+ email
1683
+ }
1684
+ createdAt
1685
+ modifier {
1686
+ id
1687
+ name
1688
+ email
1689
+ }
1690
+ modifiedAt
1691
+ name
1692
+ type {
1693
+ name
1694
+ }
1695
+ helpText
1696
+ isRequired
1697
+ defaultValue
1698
+ }
1699
+ }
1700
+ location {
1701
+ brand {
1702
+ id
1703
+ name
1704
+ }
1705
+ library {
1706
+ id
1707
+ name
1708
+ }
1709
+ workspaceProject {
1710
+ id
1711
+ name
1712
+ }
1713
+ folder {
1714
+ id
1715
+ name
1716
+ }
1717
+ }
1718
+ }
1719
+ }
1720
+ `;
1721
+ return { data: await createClient({
1722
+ connection,
1723
+ debug: context.debug.enabled
1724
+ }).request(query, { assetIds }) };
1725
+ },
1726
+ inputs: getAssetsByIdsInputs,
1727
+ examplePayload: getAssetsByIdsExamplePayload
1728
+ }),
1729
+ listAssetComments: (0, _prismatic_io_spectral.action)({
1730
+ display: {
1731
+ label: "List Asset Comments",
1732
+ description: "Retrieve a list of Comments relating to a given Asset."
1733
+ },
1734
+ perform: async (context, { connection, assetId, pagination, fetchAll }) => {
1735
+ const client = createClient({
1736
+ connection,
1737
+ debug: context.debug.enabled
1738
+ });
1739
+ const query = graphql_request.gql`
1740
+ query listAssetComments(
1741
+ $assetId: ID!
1742
+ $page: Int
1743
+ $limit: Int
1744
+ $query: AssetCommentQueryInput
1745
+ $replyLimit: Int
1746
+ ) {
1747
+ asset(id: $assetId) {
1748
+ id
1749
+ externalId
1750
+ comments(page: $page, limit: $limit, query: $query) {
1751
+ total
1752
+ page
1753
+ limit
1754
+ hasNextPage
1755
+ items {
1756
+ id
1757
+ creator {
1758
+ id
1759
+ email
1760
+ name
1761
+ }
1762
+ createdAt
1763
+ modifier {
1764
+ id
1765
+ email
1766
+ name
1767
+ }
1768
+ modifiedAt
1769
+ content
1770
+ mentionedUsers {
1771
+ id
1772
+ email
1773
+ name
1774
+ }
1775
+ isResolved
1776
+ replies(limit: $replyLimit) {
1777
+ total
1778
+ hasNextPage
1779
+ page
1780
+ limit
1781
+ items {
1782
+ id
1783
+ creator {
1784
+ id
1785
+ name
1786
+ email
1787
+ }
1788
+ createdAt
1789
+ modifier {
1790
+ id
1791
+ name
1792
+ email
1793
+ }
1794
+ modifiedAt
1795
+ content
1796
+ mentionedUsers {
1797
+ email
1798
+ }
1799
+ }
1800
+ }
1801
+ marking {
1802
+ position {
1803
+ x
1804
+ y
1805
+ }
1806
+ dimensions {
1807
+ width
1808
+ height
1809
+ }
1810
+
1811
+ ... on MultiPageMarking {
1812
+ page
1813
+ }
1814
+
1815
+ ... on VideoMarking {
1816
+ timeframe {
1817
+ start
1818
+ end
1819
+ }
1820
+ }
1821
+ }
1822
+ }
1823
+ }
1824
+ }
1825
+ }
1826
+ `;
1827
+ if (fetchAll) {
1828
+ const responses = await graphqlFetchAll({
1829
+ client,
1830
+ query,
1831
+ params: {
1832
+ assetId,
1833
+ replyLimit: pagination.replyLimit
1834
+ },
1835
+ hasNextPath: [
1836
+ "asset",
1837
+ "comments",
1838
+ "hasNextPage"
1839
+ ]
1840
+ });
1841
+ if (responses.length === 1) return { data: responses[0] };
1842
+ const baseResponse = responses.slice(-1)[0];
1843
+ const combinedAssetComments = responses.flatMap((response) => response.asset.comments.items);
1844
+ return { data: { asset: {
1845
+ ...baseResponse.asset,
1846
+ comments: {
1847
+ ...baseResponse.asset.comments,
1848
+ items: combinedAssetComments
1849
+ }
1850
+ } } };
1851
+ }
1852
+ return { data: await client.request(query, {
1853
+ assetId,
1854
+ page: pagination.page,
1855
+ limit: pagination.limit,
1856
+ replyLimit: pagination.replyLimit
1857
+ }) };
1858
+ },
1859
+ inputs: listAssetCommentsInputs,
1860
+ examplePayload: listAssetCommentsExamplePayload
1861
+ }),
1862
+ listRelatedAssets: (0, _prismatic_io_spectral.action)({
1863
+ display: {
1864
+ label: "List Related Assets",
1865
+ description: "Retrieve a list of assets that relate to a specific Asset."
1866
+ },
1867
+ perform: async (context, { connection, assetId, pagination, fetchAll }) => {
1868
+ const client = createClient({
1869
+ connection,
1870
+ debug: context.debug.enabled
1871
+ });
1872
+ const query = graphql_request.gql`
1873
+ query listRelatedAssets($assetId: ID!, $page: Int, $limit: Int) {
1874
+ asset(id: $assetId) {
1875
+ id
1876
+ externalId
1877
+ relatedAssets(page: $page, limit: $limit) {
1878
+ total
1879
+ hasNextPage
1880
+ page
1881
+ limit
1882
+ items {
1883
+ id
1884
+ creator {
1885
+ id
1886
+ name
1887
+ email
1888
+ }
1889
+ createdAt
1890
+ modifier {
1891
+ id
1892
+ name
1893
+ email
1894
+ }
1895
+ modifiedAt
1896
+ title
1897
+ description
1898
+ attachments {
1899
+ id
1900
+ creator {
1901
+ id
1902
+ name
1903
+ email
1904
+ }
1905
+ createdAt
1906
+ modifier {
1907
+ id
1908
+ name
1909
+ email
1910
+ }
1911
+ modifiedAt
1912
+ name
1913
+ filename
1914
+ type
1915
+ externalId
1916
+ extension
1917
+ size
1918
+ downloadUrl
1919
+ }
1920
+ externalId
1921
+ tags {
1922
+ value
1923
+ source
1924
+ }
1925
+ copyright {
1926
+ status
1927
+ notice
1928
+ }
1929
+ expiresAt
1930
+ licenses {
1931
+ id
1932
+ title
1933
+ license
1934
+ addByDefault
1935
+ requireConsensus
1936
+ }
1937
+ status
1938
+ relatedAssets {
1939
+ total
1940
+ }
1941
+ comments {
1942
+ total
1943
+ }
1944
+ customMetadata {
1945
+ ... on CustomMetadataValue {
1946
+ value
1947
+ }
1948
+ ... on CustomMetadataValues {
1949
+ values
1950
+ }
1951
+ property {
1952
+ id
1953
+ creator {
1954
+ id
1955
+ name
1956
+ email
1957
+ }
1958
+ createdAt
1959
+ modifier {
1960
+ id
1961
+ name
1962
+ email
1963
+ }
1964
+ modifiedAt
1965
+ name
1966
+ type {
1967
+ name
1968
+ }
1969
+ helpText
1970
+ isRequired
1971
+ defaultValue
1972
+ }
1973
+ }
1974
+ location {
1975
+ brand {
1976
+ id
1977
+ name
1978
+ }
1979
+ library {
1980
+ id
1981
+ name
1982
+ }
1983
+ workspaceProject {
1984
+ id
1985
+ name
1986
+ }
1987
+ folder {
1988
+ id
1989
+ name
1990
+ }
1991
+ }
1992
+ }
1993
+ }
1994
+ }
1995
+ }
1996
+ `;
1997
+ if (fetchAll) {
1998
+ const responses = await graphqlFetchAll({
1999
+ client,
2000
+ query,
2001
+ params: { assetId },
2002
+ hasNextPath: [
2003
+ "asset",
2004
+ "relatedAssets",
2005
+ "hasNextPage"
2006
+ ]
2007
+ });
2008
+ if (responses.length === 1) return { data: responses[0] };
2009
+ const baseResponse = responses.slice(-1)[0];
2010
+ const combinedRelatedAssets = responses.flatMap((response) => response.asset.relatedAssets.items);
2011
+ return { data: { asset: {
2012
+ ...baseResponse.asset,
2013
+ relatedAssets: {
2014
+ ...baseResponse.asset.relatedAssets,
2015
+ items: combinedRelatedAssets
2016
+ }
2017
+ } } };
2018
+ }
2019
+ return { data: await client.request(query, {
2020
+ assetId,
2021
+ page: pagination.page,
2022
+ limit: pagination.limit
2023
+ }) };
2024
+ },
2025
+ inputs: listRelatedAssetsInputs,
2026
+ examplePayload: listRelatedAssetsExamplePayload
2027
+ }),
2028
+ moveAssets: (0, _prismatic_io_spectral.action)({
2029
+ display: {
2030
+ label: "Move Assets",
2031
+ description: "Move existing Asset item(s) to the given Library, Workspace or Folder destination. Only moves within the same Library/Workspace are supported by this operation."
2032
+ },
2033
+ perform: async (context, { connection, ...input }) => {
2034
+ const mutation = graphql_request.gql`
2035
+ mutation moveAssets($input: MoveAssetsInput!) {
2036
+ moveAssets(input: $input) {
2037
+ assets {
2038
+ id
2039
+ }
2040
+ }
2041
+ }
2042
+ `;
2043
+ return { data: await createClient({
2044
+ connection,
2045
+ debug: context.debug.enabled
2046
+ }).request(mutation, { input }) };
2047
+ },
2048
+ inputs: moveAssetsInputs,
2049
+ examplePayload: moveAssetsExamplePayload
2050
+ }),
2051
+ updateAsset: (0, _prismatic_io_spectral.action)({
2052
+ display: {
2053
+ label: "Update Asset",
2054
+ description: "Update an existing Asset."
2055
+ },
2056
+ perform: async (context, { connection, filename, title, assetId, additionalFields: { description, author, copyrightNotice, copyrightStatus, expiresAt } }) => {
2057
+ const mutation = graphql_request.gql`
2058
+ mutation updateAsset($input: UpdateAssetInput!) {
2059
+ updateAsset(input: $input) {
2060
+ asset {
2061
+ id
2062
+ }
2063
+ }
2064
+ }
2065
+ `;
2066
+ const createCopyrightInput = copyrightNotice && copyrightStatus ? {
2067
+ notice: copyrightNotice,
2068
+ status: copyrightStatus
2069
+ } : void 0;
2070
+ return { data: await createClient({
2071
+ connection,
2072
+ debug: context.debug.enabled
2073
+ }).request(mutation, { input: {
2074
+ id: assetId,
2075
+ data: {
2076
+ filename,
2077
+ title,
2078
+ description,
2079
+ author,
2080
+ copyright: createCopyrightInput,
2081
+ expiresAt
2082
+ }
2083
+ } }) };
2084
+ },
2085
+ inputs: updateAssetInputs,
2086
+ examplePayload: updateAssetExamplePayload
2087
+ }),
2088
+ uploadFile: (0, _prismatic_io_spectral.action)({
2089
+ display: {
2090
+ label: "Upload File",
2091
+ description: "Upload a new file."
2092
+ },
2093
+ perform: async (context, { connection, filename, size, chunkSize }) => {
2094
+ const mutation = graphql_request.gql`
2095
+ mutation uploadFile($input: UploadFileInput!) {
2096
+ uploadFile(input: $input) {
2097
+ id
2098
+ urls
2099
+ }
2100
+ }
2101
+ `;
2102
+ return { data: await createClient({
2103
+ connection,
2104
+ debug: context.debug.enabled
2105
+ }).request(mutation, { input: {
2106
+ filename,
2107
+ size,
2108
+ chunkSize
2109
+ } }) };
2110
+ },
2111
+ inputs: uploadFileInputs,
2112
+ examplePayload: uploadFileExamplePayload
2113
+ })
2114
+ };
2115
+ //#endregion
2116
+ //#region src/inputs/brands.ts
2117
+ const getBrandInputs = {
2118
+ connection,
2119
+ brandId: {
2120
+ ...brandId,
2121
+ comments: "ID of the Brand to retrieve."
2122
+ }
2123
+ };
2124
+ const listBrandLibrariesInputs = {
2125
+ connection,
2126
+ brandId: {
2127
+ ...brandId,
2128
+ comments: "ID of the Brand to retrieve Libraries for."
2129
+ },
2130
+ fetchAll,
2131
+ pagination: (0, _prismatic_io_spectral.structuredObjectInput)({
2132
+ label: "Pagination",
2133
+ required: false,
2134
+ comments: "Page navigation controls.",
2135
+ inputs: {
2136
+ page,
2137
+ limit
2138
+ }
2139
+ })
2140
+ };
2141
+ const listBrandsInputs = { connection };
2142
+ const listBrandWorkspaceProjectsInputs = {
2143
+ connection,
2144
+ brandId: {
2145
+ ...brandId,
2146
+ comments: "ID of the Brand to retrieve Workspace Projects for."
2147
+ },
2148
+ fetchAll,
2149
+ pagination: (0, _prismatic_io_spectral.structuredObjectInput)({
2150
+ label: "Pagination",
2151
+ required: false,
2152
+ comments: "Page navigation controls.",
2153
+ inputs: {
2154
+ page,
2155
+ limit
2156
+ }
2157
+ })
2158
+ };
2159
+ //#endregion
2160
+ //#region src/actions/brands/getBrand.ts
2161
+ const getBrand = (0, _prismatic_io_spectral.action)({
2162
+ display: {
2163
+ label: "Get Brand",
2164
+ description: "Retrieve a Brand by its ID."
2165
+ },
2166
+ perform: async (context, { connection, brandId }) => {
2167
+ const query = graphql_request.gql`
2168
+ query getBrand($brandId: ID!) {
2169
+ brand(id: $brandId) {
2170
+ id
2171
+ name
2172
+ rgbaColor {
2173
+ red
2174
+ green
2175
+ blue
2176
+ alpha
2177
+ }
2178
+ avatar
2179
+ slug
2180
+ customMetadataProperties {
2181
+ id
2182
+ creator {
2183
+ id
2184
+ name
2185
+ email
2186
+ }
2187
+ createdAt
2188
+ modifier {
2189
+ id
2190
+ name
2191
+ email
2192
+ }
2193
+ modifiedAt
2194
+ name
2195
+ type {
2196
+ name
2197
+ }
2198
+ isRequired
2199
+ defaultValue
2200
+ }
2201
+ }
2202
+ }
2203
+ `;
2204
+ return { data: await createClient({
2205
+ connection,
2206
+ debug: context.debug.enabled
2207
+ }).request(query, { brandId }) };
2208
+ },
2209
+ inputs: getBrandInputs,
2210
+ examplePayload: getBrandExamplePayload
2211
+ });
2212
+ //#endregion
2213
+ //#region src/actions/brands/listBrandLibraries.ts
2214
+ const listBrandLibraries = (0, _prismatic_io_spectral.action)({
2215
+ display: {
2216
+ label: "List Brand Libraries",
2217
+ description: "Retrieve list of Libraries belonging to a Brand. For full Library details, please use the 'Get Library' action."
2218
+ },
2219
+ perform: async (context, { connection, pagination, brandId, fetchAll }) => {
2220
+ const client = createClient({
2221
+ connection,
2222
+ debug: context.debug.enabled
2223
+ });
2224
+ if (fetchAll) {
2225
+ const responses = await graphqlFetchAll({
2226
+ client,
2227
+ query: LIST_BRAND_LIBRARIES_QUERY,
2228
+ params: { brandId },
2229
+ hasNextPath: [
2230
+ "brand",
2231
+ "libraries",
2232
+ "hasNextPage"
2233
+ ]
2234
+ });
2235
+ if (responses.length === 1) return { data: responses[0] };
2236
+ const baseResponse = responses.slice(-1)[0];
2237
+ const combinedLibraries = responses.flatMap((response) => response.brand.libraries.items);
2238
+ return { data: { brand: {
2239
+ ...baseResponse.brand,
2240
+ libraries: {
2241
+ ...baseResponse.brand.libraries,
2242
+ items: combinedLibraries
2243
+ }
2244
+ } } };
2245
+ }
2246
+ return { data: await client.request(LIST_BRAND_LIBRARIES_QUERY, {
2247
+ page: pagination.page,
2248
+ limit: pagination.limit,
2249
+ brandId
2250
+ }) };
2251
+ },
2252
+ inputs: listBrandLibrariesInputs,
2253
+ examplePayload: listBrandLibrariesExamplePayload
2254
+ });
2255
+ //#endregion
2256
+ //#region src/actions/brands/listBrands.ts
2257
+ const listBrandsQuery = graphql_request.gql`
2258
+ query listBrands {
2259
+ brands {
2260
+ id
2261
+ name
2262
+ rgbaColor {
2263
+ red
2264
+ green
2265
+ blue
2266
+ alpha
2267
+ }
2268
+ avatar
2269
+ slug
2270
+ customMetadataProperties {
2271
+ id
2272
+ creator {
2273
+ id
2274
+ name
2275
+ email
2276
+ }
2277
+ createdAt
2278
+ modifier {
2279
+ id
2280
+ name
2281
+ email
2282
+ }
2283
+ modifiedAt
2284
+ name
2285
+ type {
2286
+ name
2287
+ }
2288
+ isRequired
2289
+ defaultValue
2290
+ }
2291
+ }
2292
+ }
2293
+ `;
2294
+ const listBrands = (0, _prismatic_io_spectral.action)({
2295
+ display: {
2296
+ label: "List Brands",
2297
+ description: "Retrieve Brand list for current Account."
2298
+ },
2299
+ perform: async (context, { connection }) => {
2300
+ return { data: await createClient({
2301
+ connection,
2302
+ debug: context.debug.enabled
2303
+ }).request(listBrandsQuery) };
2304
+ },
2305
+ inputs: listBrandsInputs,
2306
+ examplePayload: listBrandsExamplePayload
2307
+ });
2308
+ //#endregion
2309
+ //#region src/actions/brands/listBrandWorkspaceProjects.ts
2310
+ const listBrandWorkspaceProjectsQuery = graphql_request.gql`
2311
+ query listBrandWorkspaceProjects($brandId: ID!, $limit: Int, $page: Int) {
2312
+ brand(id: $brandId) {
2313
+ id
2314
+ name
2315
+ workspaceProjects(limit: $limit, page: $page) {
2316
+ total
2317
+ limit
2318
+ page
2319
+ hasNextPage
2320
+ items {
2321
+ id
2322
+ name
2323
+ }
2324
+ }
2325
+ }
2326
+ }
2327
+ `;
2328
+ //#endregion
2329
+ //#region src/actions/brands/index.ts
2330
+ var brands_default = {
2331
+ getBrand,
2332
+ listBrandLibraries,
2333
+ listBrands,
2334
+ listBrandWorkspaceProjects: (0, _prismatic_io_spectral.action)({
2335
+ display: {
2336
+ label: "List Brand Workspace Projects",
2337
+ description: "Retrieve list of Workspace Projects belonging to a Brand. For full details, please use the 'Get Workspace Project' action."
2338
+ },
2339
+ perform: async (context, { connection, pagination, brandId, fetchAll }) => {
2340
+ const client = createClient({
2341
+ connection,
2342
+ debug: context.debug.enabled
2343
+ });
2344
+ if (fetchAll) {
2345
+ const responses = await graphqlFetchAll({
2346
+ client,
2347
+ query: listBrandWorkspaceProjectsQuery,
2348
+ params: { brandId },
2349
+ hasNextPath: [
2350
+ "brand",
2351
+ "workspaceProjects",
2352
+ "hasNextPage"
2353
+ ]
2354
+ });
2355
+ if (responses.length === 1) return { data: responses[0] };
2356
+ const baseResponse = responses.slice(-1)[0];
2357
+ const combinedWorkspaceProjects = responses.flatMap((response) => response.brand.workspaceProjects.items);
2358
+ return { data: { brand: {
2359
+ ...baseResponse.brand,
2360
+ workspaceProjects: {
2361
+ ...baseResponse.brand.workspaceProjects,
2362
+ items: combinedWorkspaceProjects
2363
+ }
2364
+ } } };
2365
+ }
2366
+ return { data: await client.request(listBrandWorkspaceProjectsQuery, {
2367
+ page: pagination.page,
2368
+ limit: pagination.limit,
2369
+ brandId
2370
+ }) };
2371
+ },
2372
+ inputs: listBrandWorkspaceProjectsInputs,
2373
+ examplePayload: listBrandWorkspaceProjectsExamplePayload
2374
+ })
2375
+ };
2376
+ //#endregion
2377
+ //#region src/inputs/folder.ts
2378
+ const createFolderInputs = {
2379
+ connection,
2380
+ parentId: (0, _prismatic_io_spectral.input)({
2381
+ label: "Parent ID",
2382
+ type: "string",
2383
+ required: true,
2384
+ comments: "ID of the parent.",
2385
+ example: "eyJpZGVud...",
2386
+ placeholder: "eyJpZGVud...",
2387
+ clean: _prismatic_io_spectral.util.types.toString
2388
+ }),
2389
+ name: (0, _prismatic_io_spectral.input)({
2390
+ label: "Name",
2391
+ comments: "Folder name.",
2392
+ example: "My Folder",
2393
+ placeholder: "My Folder",
2394
+ type: "string",
2395
+ required: true,
2396
+ clean: _prismatic_io_spectral.util.types.toString
2397
+ }),
2398
+ description: (0, _prismatic_io_spectral.input)({
2399
+ label: "Description",
2400
+ comments: "Folder description.",
2401
+ type: "string",
2402
+ example: "This is my folder.",
2403
+ placeholder: "This is my folder.",
2404
+ required: false,
2405
+ clean: cleanStringInput
2406
+ })
2407
+ };
2408
+ const deleteFoldersInputs = {
2409
+ connection,
2410
+ brandId: {
2411
+ ...brandId,
2412
+ required: false
2413
+ },
2414
+ libraryId: {
2415
+ ...libraryId$2,
2416
+ required: false
2417
+ },
2418
+ folderIds: (0, _prismatic_io_spectral.input)({
2419
+ label: "Folder IDs",
2420
+ comments: "ID of the Folder to delete.",
2421
+ collection: "valuelist",
2422
+ type: "string",
2423
+ required: true,
2424
+ placeholder: "eyJpZGVud...",
2425
+ example: "eyJpZGVud...",
2426
+ clean: cleanValueListInput,
2427
+ dataSource: "selectLibraryFolder"
2428
+ })
2429
+ };
2430
+ const moveFoldersInputs = {
2431
+ connection,
2432
+ brandId: {
2433
+ ...brandId,
2434
+ required: false
2435
+ },
2436
+ libraryId: {
2437
+ ...libraryId$2,
2438
+ required: false
2439
+ },
2440
+ folderIds: (0, _prismatic_io_spectral.input)({
2441
+ ...deleteFoldersInputs.folderIds,
2442
+ comments: "ID of the Folder items to move."
2443
+ }),
2444
+ destinationId: (0, _prismatic_io_spectral.input)({
2445
+ label: "Destination ID",
2446
+ comments: "Only allows Library, Workspace, or Folder IDs.",
2447
+ type: "string",
2448
+ required: true,
2449
+ placeholder: "eyJpZGVud...",
2450
+ example: "eyJpZGVud...",
2451
+ clean: _prismatic_io_spectral.util.types.toString
2452
+ })
2453
+ };
2454
+ const updateFolderInputs = {
2455
+ connection,
2456
+ brandId: {
2457
+ ...brandId,
2458
+ required: false
2459
+ },
2460
+ libraryId: {
2461
+ ...libraryId$2,
2462
+ required: false
2463
+ },
2464
+ folderId: (0, _prismatic_io_spectral.input)({
2465
+ label: "Folder ID",
2466
+ type: "string",
2467
+ required: true,
2468
+ comments: "ID of the Folder to update.",
2469
+ example: "eyJpZGVud...",
2470
+ placeholder: "eyJpZGVud...",
2471
+ clean: _prismatic_io_spectral.util.types.toString,
2472
+ dataSource: "selectLibraryFolder"
2473
+ }),
2474
+ name: (0, _prismatic_io_spectral.input)({
2475
+ ...createFolderInputs.name,
2476
+ required: false,
2477
+ clean: cleanStringInput
2478
+ }),
2479
+ description: createFolderInputs.description
2480
+ };
2481
+ //#endregion
2482
+ //#region src/actions/folder/index.ts
2483
+ var folder_default = {
2484
+ createFolder: (0, _prismatic_io_spectral.action)({
2485
+ display: {
2486
+ label: "Create Folder",
2487
+ description: "Create a new Folder."
2488
+ },
2489
+ perform: async (context, { connection, ...input }) => {
2490
+ const mutation = graphql_request.gql`
2491
+ mutation createFolder($input: CreateFolderInput!) {
2492
+ createFolder(input: $input) {
2493
+ folder {
2494
+ id
2495
+ }
2496
+ }
2497
+ }
2498
+ `;
2499
+ return { data: await createClient({
2500
+ connection,
2501
+ debug: context.debug.enabled
2502
+ }).request(mutation, { input }) };
2503
+ },
2504
+ inputs: createFolderInputs,
2505
+ examplePayload: createFolderExamplePayload
2506
+ }),
2507
+ deleteFolders: (0, _prismatic_io_spectral.action)({
2508
+ display: {
2509
+ label: "Delete Folders",
2510
+ description: "Delete existing Folders."
2511
+ },
2512
+ perform: async (context, { connection, folderIds }) => {
2513
+ const mutation = graphql_request.gql`
2514
+ mutation deleteFolders($input: DeleteFoldersInput!) {
2515
+ deleteFolders(input: $input) {
2516
+ ids
2517
+ }
2518
+ }
2519
+ `;
2520
+ return { data: await createClient({
2521
+ connection,
2522
+ debug: context.debug.enabled
2523
+ }).request(mutation, { input: { ids: folderIds } }) };
2524
+ },
2525
+ inputs: deleteFoldersInputs,
2526
+ examplePayload: deleteFoldersExamplePayload
2527
+ }),
2528
+ moveFolders: (0, _prismatic_io_spectral.action)({
2529
+ display: {
2530
+ label: "Move Folders",
2531
+ description: "Move existing Folder item(s) to the given Library, Workspace or Folder destination. Only moves within the same Library/Workspace are supported by this operation."
2532
+ },
2533
+ perform: async (context, { connection, ...input }) => {
2534
+ const mutation = graphql_request.gql`
2535
+ mutation moveFolders($input: MoveFoldersInput!) {
2536
+ moveFolders(input: $input) {
2537
+ ids
2538
+ }
2539
+ }
2540
+ `;
2541
+ return { data: await createClient({
2542
+ connection,
2543
+ debug: context.debug.enabled
2544
+ }).request(mutation, { input }) };
2545
+ },
2546
+ inputs: moveFoldersInputs,
2547
+ examplePayload: moveFoldersExamplePayload
2548
+ }),
2549
+ updateFolder: (0, _prismatic_io_spectral.action)({
2550
+ display: {
2551
+ label: "Update Folder",
2552
+ description: "Update an existing Folder."
2553
+ },
2554
+ perform: async (context, { connection, folderId, name, description }) => {
2555
+ const input = {
2556
+ id: folderId,
2557
+ data: {
2558
+ name,
2559
+ description
2560
+ }
2561
+ };
2562
+ const mutation = graphql_request.gql`
2563
+ mutation updateFolder($input: UpdateFolderInput!) {
2564
+ updateFolder(input: $input) {
2565
+ folder {
2566
+ id
2567
+ }
2568
+ }
2569
+ }
2570
+ `;
2571
+ return { data: await createClient({
2572
+ connection,
2573
+ debug: context.debug.enabled
2574
+ }).request(mutation, { input }) };
2575
+ },
2576
+ inputs: updateFolderInputs,
2577
+ examplePayload: updateFolderExamplePayload
2578
+ })
2579
+ };
2580
+ //#endregion
2581
+ //#region src/inputs/libraries.ts
2582
+ const createCollectionInputs = {
2583
+ connection,
2584
+ parentId: (0, _prismatic_io_spectral.input)({
2585
+ label: "Parent ID",
2586
+ type: "string",
2587
+ required: true,
2588
+ comments: "ID of the parent Library entity.",
2589
+ example: "eyJpZG...",
2590
+ placeholder: "eyJpZG...",
2591
+ clean: _prismatic_io_spectral.util.types.toString,
2592
+ dataSource: "libraryDataSource"
2593
+ }),
2594
+ name: (0, _prismatic_io_spectral.input)({
2595
+ label: "Name",
2596
+ comments: "Collection name.",
2597
+ type: "string",
2598
+ required: true,
2599
+ example: "My Collection",
2600
+ placeholder: "My Collection",
2601
+ clean: _prismatic_io_spectral.util.types.toString
2602
+ })
2603
+ };
2604
+ const deleteCollectionInputs = {
2605
+ connection,
2606
+ brandId: {
2607
+ ...brandId,
2608
+ required: false
2609
+ },
2610
+ libraryId: {
2611
+ ...libraryId$2,
2612
+ required: false
2613
+ },
2614
+ collectionId: (0, _prismatic_io_spectral.input)({
2615
+ label: "Collection ID",
2616
+ comments: "ID of the Collection to delete.",
2617
+ type: "string",
2618
+ required: true,
2619
+ example: "eyJpZG...",
2620
+ placeholder: "eyJpZG...",
2621
+ clean: _prismatic_io_spectral.util.types.toString,
2622
+ dataSource: "selectLibraryCollection"
2623
+ })
2624
+ };
2625
+ const getLibraryInputs = {
2626
+ connection,
2627
+ brandId: {
2628
+ ...brandId,
2629
+ required: false
2630
+ },
2631
+ libraryId: libraryId$2
2632
+ };
2633
+ const listLibraryAssetsInputs = {
2634
+ connection,
2635
+ libraryId: libraryId$2,
2636
+ brandId: {
2637
+ ...brandId,
2638
+ required: false
2639
+ },
2640
+ assetSearch,
2641
+ assetExternalId,
2642
+ fetchAll,
2643
+ pagination: (0, _prismatic_io_spectral.structuredObjectInput)({
2644
+ label: "Pagination",
2645
+ required: false,
2646
+ comments: "Page navigation controls.",
2647
+ inputs: {
2648
+ page,
2649
+ limit
2650
+ }
2651
+ })
2652
+ };
2653
+ const listLibraryCollaboratorsInputs = {
2654
+ connection,
2655
+ libraryId: libraryId$2,
2656
+ brandId: {
2657
+ ...brandId,
2658
+ required: false
2659
+ },
2660
+ fetchAll,
2661
+ pagination: (0, _prismatic_io_spectral.structuredObjectInput)({
2662
+ label: "Pagination",
2663
+ required: false,
2664
+ comments: "Page navigation controls.",
2665
+ inputs: {
2666
+ page,
2667
+ limit
2668
+ }
2669
+ })
2670
+ };
2671
+ const listLibraryCollectionsInputs = {
2672
+ connection,
2673
+ libraryId: libraryId$2,
2674
+ brandId: {
2675
+ ...brandId,
2676
+ required: false
2677
+ },
2678
+ fetchAll: (0, _prismatic_io_spectral.input)({
2679
+ label: "Fetch All",
2680
+ type: "boolean",
2681
+ required: false,
2682
+ comments: "If true, it will fetch all top-level Collections records and ignore parameters like page and page size. This toggle will not affect the Asset pagination within each Collection.",
2683
+ clean: _prismatic_io_spectral.util.types.toBool
2684
+ }),
2685
+ pagination: (0, _prismatic_io_spectral.structuredObjectInput)({
2686
+ label: "Pagination",
2687
+ required: false,
2688
+ comments: "Page navigation controls.",
2689
+ inputs: {
2690
+ page,
2691
+ limit,
2692
+ assetPage: (0, _prismatic_io_spectral.input)({
2693
+ label: "Page (Assets)",
2694
+ comments: "Assets are paginated within collections. Use this to control the nested Asset pagination.",
2695
+ type: "string",
2696
+ default: "1",
2697
+ example: "1",
2698
+ placeholder: "1",
2699
+ clean: _prismatic_io_spectral.util.types.toInt
2700
+ }),
2701
+ assetLimit: (0, _prismatic_io_spectral.input)({
2702
+ label: "Page Size (Assets)",
2703
+ comments: "Assets are paginated within collections. Use this to control the nested Asset pagination.",
2704
+ type: "string",
2705
+ default: "50",
2706
+ example: "50",
2707
+ placeholder: "50",
2708
+ clean: _prismatic_io_spectral.util.types.toInt
2709
+ })
2710
+ }
2711
+ })
2712
+ };
2713
+ const listLibraryFoldersInputs = {
2714
+ connection,
2715
+ libraryId: libraryId$2,
2716
+ brandId: {
2717
+ ...brandId,
2718
+ required: false
2719
+ },
2720
+ fetchAll,
2721
+ pagination: (0, _prismatic_io_spectral.structuredObjectInput)({
2722
+ label: "Pagination",
2723
+ required: false,
2724
+ comments: "Page navigation controls.",
2725
+ inputs: {
2726
+ page,
2727
+ limit
2728
+ }
2729
+ })
2730
+ };
2731
+ const updateCollectionInputs = {
2732
+ connection,
2733
+ brandId: {
2734
+ ...brandId,
2735
+ required: false
2736
+ },
2737
+ libraryId: {
2738
+ ...libraryId$2,
2739
+ required: false
2740
+ },
2741
+ collectionId: (0, _prismatic_io_spectral.input)({
2742
+ label: "Collection ID",
2743
+ type: "string",
2744
+ required: true,
2745
+ comments: "ID of the Collection to update.",
2746
+ example: "eyJpZG...",
2747
+ placeholder: "eyJpZG...",
2748
+ clean: _prismatic_io_spectral.util.types.toString,
2749
+ dataSource: "selectLibraryCollection"
2750
+ }),
2751
+ name: (0, _prismatic_io_spectral.input)({
2752
+ label: "Name",
2753
+ comments: "Collection name.",
2754
+ type: "string",
2755
+ required: true,
2756
+ example: "My Collection",
2757
+ placeholder: "My Collection",
2758
+ clean: _prismatic_io_spectral.util.types.toString
2759
+ })
2760
+ };
2761
+ //#endregion
2762
+ //#region src/actions/libraries/createCollection.ts
2763
+ const createCollection = (0, _prismatic_io_spectral.action)({
2764
+ display: {
2765
+ label: "Create Collection",
2766
+ description: "Create a new Collection. Currently supported for Library type parent entities only."
2767
+ },
2768
+ perform: async (context, { connection, ...input }) => {
2769
+ const mutation = graphql_request.gql`
2770
+ mutation createCollection($input: CreateCollectionInput!) {
2771
+ createCollection(input: $input) {
2772
+ collection {
2773
+ id
2774
+ }
2775
+ }
2776
+ }
2777
+ `;
2778
+ return { data: await createClient({
2779
+ connection,
2780
+ debug: context.debug.enabled
2781
+ }).request(mutation, { input }) };
2782
+ },
2783
+ inputs: createCollectionInputs,
2784
+ examplePayload: createCollectionExamplePayload
2785
+ });
2786
+ //#endregion
2787
+ //#region src/actions/libraries/deleteCollection.ts
2788
+ const deleteCollection = (0, _prismatic_io_spectral.action)({
2789
+ display: {
2790
+ label: "Delete Collection",
2791
+ description: "Delete an existing Collection."
2792
+ },
2793
+ perform: async (context, { connection, ...input }) => {
2794
+ const mutation = graphql_request.gql`
2795
+ mutation deleteCollection($input: DeleteCollectionInput!) {
2796
+ deleteCollection(input: $input) {
2797
+ id
2798
+ }
2799
+ }
2800
+ `;
2801
+ return { data: await createClient({
2802
+ connection,
2803
+ debug: context.debug.enabled
2804
+ }).request(mutation, { input }) };
2805
+ },
2806
+ inputs: deleteCollectionInputs,
2807
+ examplePayload: deleteCollectionExamplePayload
2808
+ });
2809
+ //#endregion
2810
+ //#region src/actions/libraries/getLibrary.ts
2811
+ const getLibrary = (0, _prismatic_io_spectral.action)({
2812
+ display: {
2813
+ label: "Get Library",
2814
+ description: "Retrieve a Library by its ID."
2815
+ },
2816
+ perform: async (context, { connection, libraryId }) => {
2817
+ const query = graphql_request.gql`
2818
+ query getLibrary($libraryId: ID!) {
2819
+ library(id: $libraryId) {
2820
+ __typename
2821
+ id
2822
+ name
2823
+ color {
2824
+ red
2825
+ green
2826
+ blue
2827
+ alpha
2828
+ }
2829
+ licenses {
2830
+ id
2831
+ title
2832
+ license
2833
+ addByDefault
2834
+ requireConsensus
2835
+ }
2836
+ customMetadataProperties {
2837
+ id
2838
+ creator {
2839
+ id
2840
+ name
2841
+ email
2842
+ }
2843
+ createdAt
2844
+ modifier {
2845
+ id
2846
+ name
2847
+ email
2848
+ }
2849
+ modifiedAt
2850
+ name
2851
+ type {
2852
+ name
2853
+ }
2854
+ isRequired
2855
+ defaultValue
2856
+ }
2857
+ }
2858
+ }
2859
+ `;
2860
+ return { data: await createClient({
2861
+ connection,
2862
+ debug: context.debug.enabled
2863
+ }).request(query, { libraryId }) };
2864
+ },
2865
+ inputs: getLibraryInputs,
2866
+ examplePayload: getLibraryExamplePayload
2867
+ });
2868
+ //#endregion
2869
+ //#region src/actions/libraries/listLibraryAssets.ts
2870
+ const listLibraryAssetsQuery = graphql_request.gql`
2871
+ query listLibraryAssets(
2872
+ $libraryId: ID!
2873
+ $page: Int
2874
+ $limit: Int
2875
+ $query: AssetQueryInput
2876
+ ) {
2877
+ library(id: $libraryId) {
2878
+ id
2879
+ name
2880
+ assets(page: $page, limit: $limit, query: $query) {
2881
+ limit
2882
+ page
2883
+ total
2884
+ hasNextPage
2885
+ items {
2886
+ id
2887
+ creator {
2888
+ id
2889
+ name
2890
+ email
2891
+ }
2892
+ createdAt
2893
+ modifier {
2894
+ id
2895
+ name
2896
+ email
2897
+ }
2898
+ modifiedAt
2899
+ title
2900
+ description
2901
+ attachments {
2902
+ id
2903
+ creator {
2904
+ id
2905
+ name
2906
+ email
2907
+ }
2908
+ createdAt
2909
+ modifier {
2910
+ id
2911
+ name
2912
+ email
2913
+ }
2914
+ modifiedAt
2915
+ name
2916
+ filename
2917
+ type
2918
+ externalId
2919
+ extension
2920
+ size
2921
+ downloadUrl
2922
+ }
2923
+ externalId
2924
+ tags {
2925
+ value
2926
+ source
2927
+ }
2928
+ copyright {
2929
+ status
2930
+ notice
2931
+ }
2932
+ expiresAt
2933
+ licenses {
2934
+ id
2935
+ title
2936
+ license
2937
+ addByDefault
2938
+ requireConsensus
2939
+ }
2940
+ status
2941
+ relatedAssets {
2942
+ total
2943
+ }
2944
+ comments {
2945
+ total
2946
+ }
2947
+ customMetadata {
2948
+ ... on CustomMetadataValue {
2949
+ value
2950
+ }
2951
+ ... on CustomMetadataValues {
2952
+ values
2953
+ }
2954
+ property {
2955
+ id
2956
+ creator {
2957
+ id
2958
+ name
2959
+ email
2960
+ }
2961
+ createdAt
2962
+ modifier {
2963
+ id
2964
+ name
2965
+ email
2966
+ }
2967
+ modifiedAt
2968
+ name
2969
+ type {
2970
+ name
2971
+ }
2972
+ helpText
2973
+ isRequired
2974
+ defaultValue
2975
+ }
2976
+ }
2977
+ location {
2978
+ brand {
2979
+ id
2980
+ name
2981
+ }
2982
+ library {
2983
+ id
2984
+ name
2985
+ }
2986
+ workspaceProject {
2987
+ id
2988
+ name
2989
+ }
2990
+ folder {
2991
+ id
2992
+ name
2993
+ }
2994
+ }
2995
+ }
2996
+ }
2997
+ }
2998
+ }
2999
+ `;
3000
+ //#endregion
3001
+ //#region src/actions/libraries/index.ts
3002
+ var libraries_default = {
3003
+ createCollection,
3004
+ deleteCollection,
3005
+ getLibrary,
3006
+ listLibraryAssets: (0, _prismatic_io_spectral.action)({
3007
+ display: {
3008
+ label: "List Library Assets",
3009
+ description: "Retrieve a list of Assets belonging to a Library."
3010
+ },
3011
+ perform: async (context, { connection, libraryId, pagination, fetchAll, assetExternalId, assetSearch }) => {
3012
+ const query = {
3013
+ externalId: assetExternalId,
3014
+ search: assetSearch
3015
+ };
3016
+ const client = createClient({
3017
+ connection,
3018
+ debug: context.debug.enabled
3019
+ });
3020
+ if (fetchAll) {
3021
+ const responses = await graphqlFetchAll({
3022
+ client,
3023
+ query: listLibraryAssetsQuery,
3024
+ params: {
3025
+ libraryId,
3026
+ query
3027
+ },
3028
+ hasNextPath: [
3029
+ "library",
3030
+ "assets",
3031
+ "hasNextPage"
3032
+ ]
3033
+ });
3034
+ if (responses.length === 1) return { data: responses[0] };
3035
+ const baseResponse = responses.slice(-1)[0];
3036
+ const combinedAssets = responses.flatMap((response) => response.library.assets.items);
3037
+ return { data: { library: {
3038
+ ...baseResponse.library,
3039
+ assets: {
3040
+ ...baseResponse.library.assets,
3041
+ items: combinedAssets
3042
+ }
3043
+ } } };
3044
+ }
3045
+ return { data: await client.request(listLibraryAssetsQuery, {
3046
+ libraryId,
3047
+ page: pagination.page,
3048
+ limit: pagination.limit,
3049
+ query
3050
+ }) };
3051
+ },
3052
+ inputs: listLibraryAssetsInputs,
3053
+ examplePayload: listLibraryAssetsExamplePayload
3054
+ }),
3055
+ listLibraryCollaborators: (0, _prismatic_io_spectral.action)({
3056
+ display: {
3057
+ label: "List Library Collaborators",
3058
+ description: "Retrieve a list of Collaborators belonging to a Library."
3059
+ },
3060
+ perform: async (context, { connection, libraryId, pagination, fetchAll }) => {
3061
+ const client = createClient({
3062
+ connection,
3063
+ debug: context.debug.enabled
3064
+ });
3065
+ const query = graphql_request.gql`
3066
+ query listLibraryCollaborators($libraryId: ID!, $page: Int, $limit: Int) {
3067
+ library(id: $libraryId) {
3068
+ id
3069
+ name
3070
+ collaborators {
3071
+ users(limit: $limit, page: $page) {
3072
+ total
3073
+ page
3074
+ limit
3075
+ hasNextPage
3076
+ items {
3077
+ id
3078
+ email
3079
+ name
3080
+ }
3081
+ }
3082
+ }
3083
+ }
3084
+ }
3085
+ `;
3086
+ if (fetchAll) {
3087
+ const responses = await graphqlFetchAll({
3088
+ client,
3089
+ query,
3090
+ params: { libraryId },
3091
+ hasNextPath: [
3092
+ "library",
3093
+ "collaborators",
3094
+ "users",
3095
+ "hasNextPage"
3096
+ ]
3097
+ });
3098
+ if (responses.length === 1) return { data: responses[0] };
3099
+ const baseResponse = responses.slice(-1)[0];
3100
+ const combinedCollaborators = responses.flatMap((response) => response.library.collaborators.users.items);
3101
+ return { data: { library: {
3102
+ ...baseResponse.library,
3103
+ collaborators: {
3104
+ ...baseResponse.library.collaborators,
3105
+ users: {
3106
+ ...baseResponse.library.collaborators.users,
3107
+ items: combinedCollaborators
3108
+ }
3109
+ }
3110
+ } } };
3111
+ }
3112
+ return { data: await client.request(query, {
3113
+ libraryId,
3114
+ page: pagination.page,
3115
+ limit: pagination.limit
3116
+ }) };
3117
+ },
3118
+ inputs: listLibraryCollaboratorsInputs,
3119
+ examplePayload: listLibraryCollaboratorsExamplePayload
3120
+ }),
3121
+ listLibraryCollections: (0, _prismatic_io_spectral.action)({
3122
+ display: {
3123
+ label: "List Library Collections",
3124
+ description: "Retrieve a list of Collections belonging to a Library."
3125
+ },
3126
+ perform: async (context, { connection, libraryId, pagination, fetchAll }) => {
3127
+ const client = createClient({
3128
+ connection,
3129
+ debug: context.debug.enabled
3130
+ });
3131
+ const query = graphql_request.gql`
3132
+ query listLibraryCollections(
3133
+ $libraryId: ID!
3134
+ $page: Int
3135
+ $limit: Int
3136
+ $assetPage: Int
3137
+ $assetLimit: Int
3138
+ ) {
3139
+ library(id: $libraryId) {
3140
+ id
3141
+ name
3142
+ collections(page: $page, limit: $limit) {
3143
+ total
3144
+ page
3145
+ limit
3146
+ hasNextPage
3147
+ items {
3148
+ id
3149
+ name
3150
+ assets(page: $assetPage, limit: $assetLimit) {
3151
+ total
3152
+ page
3153
+ limit
3154
+ hasNextPage
3155
+ items {
3156
+ id
3157
+ }
3158
+ }
3159
+ }
3160
+ }
3161
+ }
3162
+ }
3163
+ `;
3164
+ if (fetchAll) {
3165
+ const responses = await graphqlFetchAll({
3166
+ client,
3167
+ query,
3168
+ params: {
3169
+ libraryId,
3170
+ assetPage: pagination.assetPage,
3171
+ assetLimit: pagination.assetLimit
3172
+ },
3173
+ hasNextPath: [
3174
+ "library",
3175
+ "collections",
3176
+ "hasNextPage"
3177
+ ]
3178
+ });
3179
+ if (responses.length === 1) return { data: responses[0] };
3180
+ const baseResponse = responses.slice(-1)[0];
3181
+ const combinedCollections = responses.flatMap((response) => response.library.collections.items);
3182
+ return { data: { library: {
3183
+ ...baseResponse.library,
3184
+ collections: {
3185
+ ...baseResponse.library.collections,
3186
+ items: combinedCollections
3187
+ }
3188
+ } } };
3189
+ }
3190
+ return { data: await client.request(query, {
3191
+ libraryId,
3192
+ page: pagination.page,
3193
+ limit: pagination.limit
3194
+ }) };
3195
+ },
3196
+ inputs: listLibraryCollectionsInputs,
3197
+ examplePayload: listLibraryCollectionsExamplePayload
3198
+ }),
3199
+ listLibraryFolders: (0, _prismatic_io_spectral.action)({
3200
+ display: {
3201
+ label: "List Library Folders",
3202
+ description: "Retrieve a list of the top-level folders in a Library. To browse further, use the Raw Request action."
3203
+ },
3204
+ perform: async (context, { connection, libraryId, pagination, fetchAll }) => {
3205
+ const client = createClient({
3206
+ connection,
3207
+ debug: context.debug.enabled
3208
+ });
3209
+ const query = graphql_request.gql`
3210
+ query listLibraryFolders($libraryId: ID!) {
3211
+ library(id: $libraryId) {
3212
+ id
3213
+ name
3214
+ browse {
3215
+ folders {
3216
+ limit
3217
+ page
3218
+ hasNextPage
3219
+ total
3220
+ items {
3221
+ id
3222
+ name
3223
+ creator {
3224
+ id
3225
+ name
3226
+ email
3227
+ }
3228
+ createdAt
3229
+ modifier {
3230
+ id
3231
+ name
3232
+ email
3233
+ }
3234
+ modifiedAt
3235
+ breadcrumbs {
3236
+ id
3237
+ name
3238
+ }
3239
+ folders {
3240
+ total
3241
+ }
3242
+ }
3243
+ }
3244
+ }
3245
+ }
3246
+ }
3247
+ `;
3248
+ if (fetchAll) {
3249
+ const responses = await graphqlFetchAll({
3250
+ client,
3251
+ query,
3252
+ params: { libraryId },
3253
+ hasNextPath: [
3254
+ "library",
3255
+ "browse",
3256
+ "folders",
3257
+ "hasNextPage"
3258
+ ]
3259
+ });
3260
+ if (responses.length === 1) return { data: responses[0] };
3261
+ const baseResponse = responses.slice(-1)[0];
3262
+ const combinedFolders = responses.flatMap((response) => response.library.browse.folders.items);
3263
+ return { data: { library: {
3264
+ ...baseResponse.library,
3265
+ browse: {
3266
+ ...baseResponse.library.browse,
3267
+ folders: {
3268
+ ...baseResponse.library.browse.folders,
3269
+ items: combinedFolders
3270
+ }
3271
+ }
3272
+ } } };
3273
+ }
3274
+ return { data: await client.request(query, {
3275
+ libraryId,
3276
+ page: pagination.page,
3277
+ limit: pagination.limit
3278
+ }) };
3279
+ },
3280
+ inputs: listLibraryFoldersInputs,
3281
+ examplePayload: listLibraryFoldersExamplePayload
3282
+ }),
3283
+ updateCollection: (0, _prismatic_io_spectral.action)({
3284
+ display: {
3285
+ label: "Update Collection",
3286
+ description: "Update an existing Collection."
3287
+ },
3288
+ perform: async (context, { connection, collectionId, name }) => {
3289
+ const mutation = graphql_request.gql`
3290
+ mutation updateCollection($input: UpdateCollectionInput!) {
3291
+ updateCollection(input: $input) {
3292
+ collection {
3293
+ id
3294
+ }
3295
+ }
3296
+ }
3297
+ `;
3298
+ const input = {
3299
+ collectionId,
3300
+ data: { name }
3301
+ };
3302
+ return { data: await createClient({
3303
+ connection,
3304
+ debug: context.debug.enabled
3305
+ }).request(mutation, { input }) };
3306
+ },
3307
+ inputs: updateCollectionInputs,
3308
+ examplePayload: updateCollectionExamplePayload
3309
+ })
3310
+ };
3311
+ //#endregion
3312
+ //#region src/utils/cleanVariablesInput.ts
3313
+ const cleanVariablesInput = (value) => {
3314
+ if (Array.isArray(value)) return _prismatic_io_spectral.util.types.keyValPairListToObject(value);
3315
+ return {};
3316
+ };
3317
+ //#endregion
3318
+ //#region src/inputs/misc.ts
3319
+ const getCurrentUserInputs = { connection };
3320
+ const rawRequestInputs = {
3321
+ connection,
3322
+ query: (0, _prismatic_io_spectral.input)({
3323
+ label: "Query or Mutation",
3324
+ comments: "Provide a query or mutation for the GraphQL request.",
3325
+ type: "code",
3326
+ required: true,
3327
+ language: "graphql",
3328
+ example: `
3329
+ query getCurrentUser {
3330
+ currentUser {
3331
+ id
3332
+ email
3333
+ name
3334
+ }
3335
+ }
3336
+ `,
3337
+ clean: _prismatic_io_spectral.util.types.toString
3338
+ }),
3339
+ variableMap: (0, _prismatic_io_spectral.input)({
3340
+ label: "GraphQL Variables",
3341
+ comments: "These should match the variables of your query or mutation.",
3342
+ type: "string",
3343
+ collection: "keyvaluelist",
3344
+ required: false,
3345
+ example: JSON.stringify({
3346
+ key: "libraryId",
3347
+ value: "eyJpZGVudGl..."
3348
+ }),
3349
+ clean: cleanVariablesInput
3350
+ })
3351
+ };
3352
+ //#endregion
3353
+ //#region src/actions/misc/index.ts
3354
+ var misc_default = {
3355
+ getCurrentUser: (0, _prismatic_io_spectral.action)({
3356
+ display: {
3357
+ label: "Get Current User",
3358
+ description: "Get the current User."
3359
+ },
3360
+ perform: async (context, { connection }) => {
3361
+ const query = graphql_request.gql`
3362
+ query getCurrentUser {
3363
+ currentUser {
3364
+ id
3365
+ email
3366
+ name
3367
+ avatar
3368
+ }
3369
+ }
3370
+ `;
3371
+ return { data: await createClient({
3372
+ connection,
3373
+ debug: context.debug.enabled
3374
+ }).request(query) };
3375
+ },
3376
+ inputs: getCurrentUserInputs,
3377
+ examplePayload: getCurrentUserExamplePayload
3378
+ }),
3379
+ rawRequest: (0, _prismatic_io_spectral.action)({
3380
+ display: {
3381
+ label: "Raw GraphQL Request",
3382
+ description: "Send a raw GraphQL request to Frontify."
3383
+ },
3384
+ perform: async (context, { connection, query, variableMap }) => {
3385
+ return { data: await createClient({
3386
+ connection,
3387
+ debug: context.debug.enabled
3388
+ }).request(query, variableMap) };
3389
+ },
3390
+ inputs: rawRequestInputs
3391
+ })
3392
+ };
3393
+ //#endregion
3394
+ //#region src/inputs/webhooks.ts
3395
+ const installWebhookInputs = {
3396
+ connection,
3397
+ projectId: (0, _prismatic_io_spectral.input)({
3398
+ label: "Workspace Project ID or Library ID",
3399
+ type: "string",
3400
+ required: true,
3401
+ comments: "The ID of the Workspace Project or Library to attach the Webhook to.",
3402
+ example: "eyJpZGV...",
3403
+ placeholder: "eyJpZGV...",
3404
+ clean: _prismatic_io_spectral.util.types.toString
3405
+ }),
3406
+ name: (0, _prismatic_io_spectral.input)({
3407
+ label: "Webhook Name",
3408
+ type: "string",
3409
+ required: true,
3410
+ comments: "The name of the Webhook.",
3411
+ example: "My Webhook",
3412
+ placeholder: "My Webhook",
3413
+ clean: _prismatic_io_spectral.util.types.toString
3414
+ }),
3415
+ notificationUrl: (0, _prismatic_io_spectral.input)({
3416
+ label: "Notification URL",
3417
+ type: "string",
3418
+ required: true,
3419
+ comments: "The URL that the Webhook will send notifications to when triggered.",
3420
+ example: "https://example.com/webhook",
3421
+ placeholder: "https://example.com/webhook",
3422
+ clean: _prismatic_io_spectral.util.types.toString
3423
+ })
3424
+ };
3425
+ const listWebhooksInputs = {
3426
+ connection,
3427
+ fetchAll,
3428
+ pagination: (0, _prismatic_io_spectral.structuredObjectInput)({
3429
+ label: "Pagination",
3430
+ required: false,
3431
+ comments: "Page navigation controls.",
3432
+ inputs: {
3433
+ page,
3434
+ limit
3435
+ }
3436
+ })
3437
+ };
3438
+ const uninstallWebhookInputs = {
3439
+ connection,
3440
+ webhookId: (0, _prismatic_io_spectral.input)({
3441
+ label: "Webhook ID",
3442
+ type: "string",
3443
+ required: true,
3444
+ comments: "The ID of the Webhook to uninstall.",
3445
+ example: "eyJpZGV...",
3446
+ placeholder: "eyJpZGV...",
3447
+ clean: _prismatic_io_spectral.util.types.toString,
3448
+ dataSource: "selectWebhook"
3449
+ })
3450
+ };
3451
+ //#endregion
3452
+ //#region src/actions/webhooks/installWebhook.ts
3453
+ const installWebhook = (0, _prismatic_io_spectral.action)({
3454
+ display: {
3455
+ label: "Install Webhook",
3456
+ description: "Install a Webhook onto a Workspace Project or Library."
3457
+ },
3458
+ perform: async (context, { connection, ...input }) => {
3459
+ const mutation = graphql_request.gql`
3460
+ mutation installWebhook($input: InstallProjectWebhookInput!) {
3461
+ installProjectWebhook(input: $input) {
3462
+ webhook {
3463
+ id
3464
+ creator {
3465
+ id
3466
+ email
3467
+ name
3468
+ }
3469
+ createdAt
3470
+ name
3471
+ notificationUrl
3472
+ secret
3473
+ }
3474
+ }
3475
+ }
3476
+ `;
3477
+ return { data: await createClient({
3478
+ connection,
3479
+ debug: context.debug.enabled
3480
+ }).request(mutation, { input }) };
3481
+ },
3482
+ inputs: installWebhookInputs,
3483
+ examplePayload: installWebhookExamplePayload
3484
+ });
3485
+ //#endregion
3486
+ //#region src/actions/webhooks/index.ts
3487
+ var webhooks_default = {
3488
+ listWebhooks: (0, _prismatic_io_spectral.action)({
3489
+ display: {
3490
+ label: "List Webhooks",
3491
+ description: "Retrieve WebhookItems related to current Account."
3492
+ },
3493
+ perform: async (context, { connection, pagination, fetchAll }) => {
3494
+ const query = graphql_request.gql`
3495
+ query listWebhooks($limit: Int, $page: Int) {
3496
+ webhooks(limit: $limit, page: $page) {
3497
+ total
3498
+ page
3499
+ limit
3500
+ hasNextPage
3501
+ items {
3502
+ id
3503
+ creator {
3504
+ id
3505
+ name
3506
+ email
3507
+ }
3508
+ createdAt
3509
+ name
3510
+ notificationUrl
3511
+ secret
3512
+ ... on ProjectWebhook {
3513
+ __typename
3514
+ project {
3515
+ ... on MediaLibrary {
3516
+ id
3517
+ }
3518
+ ... on IconLibrary {
3519
+ id
3520
+ }
3521
+ ... on LogoLibrary {
3522
+ id
3523
+ }
3524
+ ... on DocumentLibrary {
3525
+ id
3526
+ }
3527
+ ... on Workspace {
3528
+ id
3529
+ }
3530
+ }
3531
+ }
3532
+ }
3533
+ }
3534
+ }
3535
+ `;
3536
+ const client = createClient({
3537
+ connection,
3538
+ debug: context.debug.enabled
3539
+ });
3540
+ if (fetchAll) {
3541
+ const responses = await graphqlFetchAll({
3542
+ client,
3543
+ query,
3544
+ hasNextPath: ["webhooks", "hasNextPage"]
3545
+ });
3546
+ if (responses.length === 1) return { data: responses[0] };
3547
+ const baseResponse = responses.slice(-1)[0];
3548
+ const combinedWebhooks = responses.flatMap((response) => response.webhooks.items);
3549
+ return { data: { webhooks: {
3550
+ ...baseResponse.webhooks,
3551
+ items: combinedWebhooks
3552
+ } } };
3553
+ }
3554
+ return { data: await client.request(query, {
3555
+ page: pagination.page,
3556
+ limit: pagination.limit
3557
+ }) };
3558
+ },
3559
+ inputs: listWebhooksInputs,
3560
+ examplePayload: listWebhooksExamplePayload
3561
+ }),
3562
+ installWebhook,
3563
+ uninstallWebhook: (0, _prismatic_io_spectral.action)({
3564
+ display: {
3565
+ label: "Uninstall Webhook",
3566
+ description: "Uninstall a Webhook."
3567
+ },
3568
+ perform: async (context, { connection, webhookId }) => {
3569
+ const mutation = graphql_request.gql`
3570
+ mutation uninstallWebhook($input: UninstallWebhookInput!) {
3571
+ uninstallWebhook(input: $input) {
3572
+ webhook {
3573
+ id
3574
+ }
3575
+ }
3576
+ }
3577
+ `;
3578
+ return { data: await createClient({
3579
+ connection,
3580
+ debug: context.debug.enabled
3581
+ }).request(mutation, { input: { id: webhookId } }) };
3582
+ },
3583
+ inputs: uninstallWebhookInputs,
3584
+ examplePayload: uninstallWebhookExamplePayload
3585
+ })
3586
+ };
3587
+ //#endregion
3588
+ //#region src/inputs/workspaceProjects.ts
3589
+ const getWorkspaceProjectInputs = {
3590
+ connection,
3591
+ projectId: projectId$1
3592
+ };
3593
+ const listWorkspaceProjectAssetsInputs = {
3594
+ connection,
3595
+ projectId: projectId$1,
3596
+ assetSearch,
3597
+ assetExternalId,
3598
+ fetchAll,
3599
+ pagination: (0, _prismatic_io_spectral.structuredObjectInput)({
3600
+ label: "Pagination",
3601
+ required: false,
3602
+ comments: "Page navigation controls.",
3603
+ inputs: {
3604
+ page,
3605
+ limit
3606
+ }
3607
+ })
3608
+ };
3609
+ const listWorkspaceProjectFoldersInputs = {
3610
+ connection,
3611
+ projectId: projectId$1,
3612
+ fetchAll,
3613
+ pagination: (0, _prismatic_io_spectral.structuredObjectInput)({
3614
+ label: "Pagination",
3615
+ required: false,
3616
+ comments: "Page navigation controls.",
3617
+ inputs: {
3618
+ page,
3619
+ limit
3620
+ }
3621
+ })
3622
+ };
3623
+ //#endregion
3624
+ //#region src/actions/workspaceProjects/getWorkspaceProject.ts
3625
+ const getWorkspaceProject = (0, _prismatic_io_spectral.action)({
3626
+ display: {
3627
+ label: "Get Workspace Project",
3628
+ description: "Retrieve a Workspace Project by its ID."
3629
+ },
3630
+ perform: async (context, { connection, projectId }) => {
3631
+ const query = graphql_request.gql`
3632
+ query getWorkspaceProject($projectId: ID!) {
3633
+ workspaceProject(id: $projectId) {
3634
+ id
3635
+ name
3636
+ color {
3637
+ red
3638
+ green
3639
+ blue
3640
+ alpha
3641
+ }
3642
+ licenses {
3643
+ id
3644
+ title
3645
+ license
3646
+ addByDefault
3647
+ requireConsensus
3648
+ }
3649
+ collaborators {
3650
+ users {
3651
+ total
3652
+ hasNextPage
3653
+ page
3654
+ limit
3655
+ items {
3656
+ id
3657
+ name
3658
+ email
3659
+ }
3660
+ }
3661
+ }
3662
+ customMetadata {
3663
+ ... on CustomMetadataValue {
3664
+ value
3665
+ }
3666
+ ... on CustomMetadataValues {
3667
+ values
3668
+ }
3669
+
3670
+ property {
3671
+ id
3672
+ creator {
3673
+ id
3674
+ name
3675
+ email
3676
+ }
3677
+ createdAt
3678
+ modifier {
3679
+ id
3680
+ name
3681
+ email
3682
+ }
3683
+ modifiedAt
3684
+ name
3685
+ type {
3686
+ name
3687
+ }
3688
+ helpText
3689
+ isRequired
3690
+ defaultValue
3691
+ }
3692
+ }
3693
+ }
3694
+ }
3695
+ `;
3696
+ return { data: await createClient({
3697
+ connection,
3698
+ debug: context.debug.enabled
3699
+ }).request(query, { projectId }) };
3700
+ },
3701
+ inputs: getWorkspaceProjectInputs,
3702
+ examplePayload: getWorkspaceProjectExamplePayload
3703
+ });
3704
+ //#endregion
3705
+ //#region src/actions/workspaceProjects/listWorkspaceProjectAssets.ts
3706
+ const listWorkspaceProjectAssetsQuery = graphql_request.gql`
3707
+ query listWorkspaceProjectAssets(
3708
+ $projectId: ID!
3709
+ $page: Int
3710
+ $limit: Int
3711
+ $query: AssetQueryInput
3712
+ ) {
3713
+ workspaceProject(id: $projectId) {
3714
+ id
3715
+ name
3716
+ assets(page: $page, limit: $limit, query: $query) {
3717
+ limit
3718
+ page
3719
+ total
3720
+ hasNextPage
3721
+ items {
3722
+ id
3723
+ creator {
3724
+ id
3725
+ name
3726
+ email
3727
+ }
3728
+ createdAt
3729
+ modifier {
3730
+ id
3731
+ name
3732
+ email
3733
+ }
3734
+ modifiedAt
3735
+ title
3736
+ description
3737
+ attachments {
3738
+ id
3739
+ creator {
3740
+ id
3741
+ name
3742
+ email
3743
+ }
3744
+ createdAt
3745
+ modifier {
3746
+ id
3747
+ name
3748
+ email
3749
+ }
3750
+ modifiedAt
3751
+ name
3752
+ filename
3753
+ type
3754
+ externalId
3755
+ extension
3756
+ size
3757
+ downloadUrl
3758
+ }
3759
+ externalId
3760
+ tags {
3761
+ value
3762
+ source
3763
+ }
3764
+ copyright {
3765
+ status
3766
+ notice
3767
+ }
3768
+ expiresAt
3769
+ licenses {
3770
+ id
3771
+ title
3772
+ license
3773
+ addByDefault
3774
+ requireConsensus
3775
+ }
3776
+ status
3777
+ relatedAssets {
3778
+ total
3779
+ }
3780
+ comments {
3781
+ total
3782
+ }
3783
+ customMetadata {
3784
+ ... on CustomMetadataValue {
3785
+ value
3786
+ }
3787
+ ... on CustomMetadataValues {
3788
+ values
3789
+ }
3790
+
3791
+ property {
3792
+ id
3793
+ creator {
3794
+ id
3795
+ name
3796
+ email
3797
+ }
3798
+ createdAt
3799
+ modifier {
3800
+ id
3801
+ name
3802
+ email
3803
+ }
3804
+ modifiedAt
3805
+ name
3806
+ type {
3807
+ name
3808
+ }
3809
+ helpText
3810
+ isRequired
3811
+ defaultValue
3812
+ }
3813
+ }
3814
+ location {
3815
+ brand {
3816
+ id
3817
+ name
3818
+ }
3819
+ library {
3820
+ id
3821
+ name
3822
+ }
3823
+ workspaceProject {
3824
+ id
3825
+ name
3826
+ }
3827
+ folder {
3828
+ id
3829
+ name
3830
+ }
3831
+ }
3832
+ }
3833
+ }
3834
+ }
3835
+ }
3836
+ `;
3837
+ //#endregion
3838
+ //#region src/actions/workspaceProjects/index.ts
3839
+ var workspaceProjects_default = {
3840
+ getWorkspaceProject,
3841
+ listWorkspaceProjectAssets: (0, _prismatic_io_spectral.action)({
3842
+ display: {
3843
+ label: "List Workspace Project Assets",
3844
+ description: "Retrieve a list of Assets belonging to a Workspace Project."
3845
+ },
3846
+ perform: async (context, { connection, projectId, pagination, fetchAll, assetSearch, assetExternalId }) => {
3847
+ const query = {
3848
+ search: assetSearch,
3849
+ externalId: assetExternalId
3850
+ };
3851
+ const client = createClient({
3852
+ connection,
3853
+ debug: context.debug.enabled
3854
+ });
3855
+ if (fetchAll) {
3856
+ const responses = await graphqlFetchAll({
3857
+ client,
3858
+ query: listWorkspaceProjectAssetsQuery,
3859
+ params: {
3860
+ projectId,
3861
+ query
3862
+ },
3863
+ hasNextPath: [
3864
+ "workspaceProject",
3865
+ "assets",
3866
+ "hasNextPage"
3867
+ ]
3868
+ });
3869
+ if (responses.length === 1) return { data: responses[0] };
3870
+ const baseResponse = responses.slice(-1)[0];
3871
+ const combinedAssets = responses.flatMap((response) => response.workspaceProject.assets.items);
3872
+ return { data: { workspaceProject: {
3873
+ ...baseResponse.workspaceProject,
3874
+ assets: {
3875
+ ...baseResponse.workspaceProject.assets,
3876
+ items: combinedAssets
3877
+ }
3878
+ } } };
3879
+ }
3880
+ return { data: await client.request(listWorkspaceProjectAssetsQuery, {
3881
+ projectId,
3882
+ page: pagination.page,
3883
+ limit: pagination.limit,
3884
+ query
3885
+ }) };
3886
+ },
3887
+ inputs: listWorkspaceProjectAssetsInputs,
3888
+ examplePayload: listWorkspaceProjectAssetsExamplePayload
3889
+ }),
3890
+ listWorkspaceProjectFolders: (0, _prismatic_io_spectral.action)({
3891
+ display: {
3892
+ label: "List Workspace Project Folders",
3893
+ description: "Retrieve a list of the top-level folders in a Workspace Project. To browse further, use the Raw Request action."
3894
+ },
3895
+ perform: async (context, { connection, ...configVars }) => {
3896
+ const { projectId, pagination, fetchAll } = configVars;
3897
+ const client = createClient({
3898
+ connection,
3899
+ debug: context.debug.enabled
3900
+ });
3901
+ const query = graphql_request.gql`
3902
+ query listWorkspaceProjectFolders($projectId: ID!) {
3903
+ workspaceProject(id: $projectId) {
3904
+ id
3905
+ name
3906
+ browse {
3907
+ folders {
3908
+ limit
3909
+ page
3910
+ hasNextPage
3911
+ total
3912
+ items {
3913
+ id
3914
+ name
3915
+ creator {
3916
+ id
3917
+ name
3918
+ email
3919
+ }
3920
+ createdAt
3921
+ modifier {
3922
+ id
3923
+ name
3924
+ email
3925
+ }
3926
+ modifiedAt
3927
+ breadcrumbs {
3928
+ id
3929
+ name
3930
+ }
3931
+ folders {
3932
+ total
3933
+ }
3934
+ }
3935
+ }
3936
+ }
3937
+ }
3938
+ }
3939
+ `;
3940
+ if (fetchAll) {
3941
+ const responses = await graphqlFetchAll({
3942
+ client,
3943
+ query,
3944
+ params: { projectId },
3945
+ hasNextPath: [
3946
+ "workspaceProject",
3947
+ "browse",
3948
+ "folders",
3949
+ "hasNextPage"
3950
+ ]
3951
+ });
3952
+ if (responses.length === 1) return { data: responses[0] };
3953
+ const baseResponse = responses.slice(-1)[0];
3954
+ const combinedFolders = responses.flatMap((response) => response.workspaceProject.browse.folders.items);
3955
+ return { data: { workspaceProject: {
3956
+ ...baseResponse.workspaceProject,
3957
+ browse: {
3958
+ ...baseResponse.workspaceProject.browse,
3959
+ folders: {
3960
+ ...baseResponse.workspaceProject.browse.folders,
3961
+ items: combinedFolders
3962
+ }
3963
+ }
3964
+ } } };
3965
+ }
3966
+ return { data: await client.request(query, {
3967
+ projectId,
3968
+ page: pagination.page,
3969
+ limit: pagination.limit
3970
+ }) };
3971
+ },
3972
+ inputs: listWorkspaceProjectFoldersInputs,
3973
+ examplePayload: listWorkspaceProjectFoldersExamplePayload
3974
+ })
3975
+ };
3976
+ //#endregion
3977
+ //#region src/actions/index.ts
3978
+ var actions_default = {
3979
+ ...account_default,
3980
+ ...assets_default,
3981
+ ...brands_default,
3982
+ ...libraries_default,
3983
+ ...webhooks_default,
3984
+ ...workspaceProjects_default,
3985
+ ...folder_default,
3986
+ ...misc_default
3987
+ };
3988
+ //#endregion
3989
+ //#region src/inputs/dataSources.ts
3990
+ const brandsInputs = { connection };
3991
+ const libraryAssetsInputs = {
3992
+ connection,
3993
+ libraryId: {
3994
+ ...libraryId$2,
3995
+ dataSource: void 0
3996
+ }
3997
+ };
3998
+ const libraryInputs = {
3999
+ connection,
4000
+ brandId: {
4001
+ ...brandId,
4002
+ dataSource: void 0
4003
+ }
4004
+ };
4005
+ const workspaceProjectInputs = {
4006
+ connection,
4007
+ brandId: {
4008
+ ...brandId,
4009
+ dataSource: void 0
4010
+ }
4011
+ };
4012
+ const workspaceProjectAssetInputs = {
4013
+ connection,
4014
+ projectId: {
4015
+ ...projectId$1,
4016
+ dataSource: void 0
4017
+ }
4018
+ };
4019
+ //#endregion
4020
+ //#region src/dataSources/brands.ts
4021
+ const brandDataSource = (0, _prismatic_io_spectral.dataSource)({
4022
+ display: {
4023
+ label: "Select Brand",
4024
+ description: "Select a Brand belonging to the current Account."
4025
+ },
4026
+ perform: async (_context, { connection }) => {
4027
+ return { result: (await createClient({
4028
+ connection,
4029
+ debug: false
4030
+ }).request(listBrandsQuery)).brands.map((brand) => {
4031
+ return {
4032
+ key: brand.id,
4033
+ label: brand.name
4034
+ };
4035
+ }) };
4036
+ },
4037
+ inputs: brandsInputs,
4038
+ dataSourceType: "picklist"
4039
+ });
4040
+ //#endregion
4041
+ //#region src/dataSources/libaryAssets.ts
4042
+ const libraryAssetDataSource = (0, _prismatic_io_spectral.dataSource)({
4043
+ display: {
4044
+ label: "Select Library Asset",
4045
+ description: "Select an Asset that belongs to a given Library."
4046
+ },
4047
+ perform: async (_context, { connection, libraryId }) => {
4048
+ return { result: (await createClient({
4049
+ connection,
4050
+ debug: false
4051
+ }).request(listLibraryAssetsQuery, { libraryId })).library.assets.items.map((asset) => {
4052
+ return {
4053
+ key: asset.id,
4054
+ label: asset.title
4055
+ };
4056
+ }) };
4057
+ },
4058
+ inputs: libraryAssetsInputs,
4059
+ dataSourceType: "picklist"
4060
+ });
4061
+ //#endregion
4062
+ //#region src/dataSources/library.ts
4063
+ const libraryDataSource = (0, _prismatic_io_spectral.dataSource)({
4064
+ display: {
4065
+ label: "Select Library",
4066
+ description: "Select a Library belonging to a certain Brand."
4067
+ },
4068
+ perform: async (_context, { connection, brandId }) => {
4069
+ return { result: (await createClient({
4070
+ connection,
4071
+ debug: false
4072
+ }).request(LIST_BRAND_LIBRARIES_QUERY, { brandId })).brand.libraries.items.map((library) => {
4073
+ return {
4074
+ key: library.id,
4075
+ label: library.name
4076
+ };
4077
+ }) };
4078
+ },
4079
+ inputs: libraryInputs,
4080
+ dataSourceType: "picklist"
4081
+ });
4082
+ //#endregion
4083
+ //#region src/dataSources/libraryCollections.ts
4084
+ const libraryId$1 = (0, _prismatic_io_spectral.input)({
4085
+ label: "Library ID",
4086
+ type: "string",
4087
+ required: true,
4088
+ comments: "ID of the Library entity.",
4089
+ example: "eyJpZG...",
4090
+ placeholder: "eyJpZG...",
4091
+ clean: _prismatic_io_spectral.util.types.toString
4092
+ });
4093
+ const query$4 = graphql_request.gql`
4094
+ query listLibraryCollections($libraryId: ID!) {
4095
+ library(id: $libraryId) {
4096
+ collections {
4097
+ items {
4098
+ id
4099
+ name
4100
+ }
4101
+ }
4102
+ }
4103
+ }
4104
+ `;
4105
+ const selectLibraryCollection = (0, _prismatic_io_spectral.dataSource)({
4106
+ display: {
4107
+ label: "Select Library Collection",
4108
+ description: "A picklist of collections belonging to a Library."
4109
+ },
4110
+ inputs: {
4111
+ connection,
4112
+ libraryId: libraryId$1
4113
+ },
4114
+ perform: async (_context, { connection, libraryId }) => {
4115
+ return { result: ((await createClient({
4116
+ connection,
4117
+ debug: false
4118
+ }).request(query$4, { libraryId }))?.library?.collections?.items ?? []).map((item) => ({
4119
+ key: item.id,
4120
+ label: item.name
4121
+ })) };
4122
+ },
4123
+ dataSourceType: "picklist",
4124
+ examplePayload: { result: [{
4125
+ label: "My Collection",
4126
+ key: "eyJpZGVudGlmaWVyIjoiMSJ9"
4127
+ }] }
4128
+ });
4129
+ //#endregion
4130
+ //#region src/dataSources/libraryFolders.ts
4131
+ const libraryId = (0, _prismatic_io_spectral.input)({
4132
+ label: "Library ID",
4133
+ type: "string",
4134
+ required: true,
4135
+ comments: "ID of the Library entity.",
4136
+ example: "eyJpZG...",
4137
+ placeholder: "eyJpZG...",
4138
+ clean: _prismatic_io_spectral.util.types.toString
4139
+ });
4140
+ const query$3 = graphql_request.gql`
4141
+ query listLibraryFolders($libraryId: ID!) {
4142
+ library(id: $libraryId) {
4143
+ browse {
4144
+ folders {
4145
+ items {
4146
+ id
4147
+ name
4148
+ }
4149
+ }
4150
+ }
4151
+ }
4152
+ }
4153
+ `;
4154
+ const selectLibraryFolder = (0, _prismatic_io_spectral.dataSource)({
4155
+ display: {
4156
+ label: "Select Library Folder",
4157
+ description: "A picklist of top-level folders in a Library."
4158
+ },
4159
+ inputs: {
4160
+ connection,
4161
+ libraryId
4162
+ },
4163
+ perform: async (_context, { connection, libraryId }) => {
4164
+ return { result: ((await createClient({
4165
+ connection,
4166
+ debug: false
4167
+ }).request(query$3, { libraryId }))?.library?.browse?.folders?.items ?? []).map((item) => ({
4168
+ key: item.id,
4169
+ label: item.name
4170
+ })) };
4171
+ },
4172
+ dataSourceType: "picklist",
4173
+ examplePayload: { result: [{
4174
+ label: "My Folder",
4175
+ key: "eyJpZGVudGlmaWVyIjoiMSJ9"
4176
+ }] }
4177
+ });
4178
+ //#endregion
4179
+ //#region src/dataSources/relatedAssets.ts
4180
+ const assetId = (0, _prismatic_io_spectral.input)({
4181
+ label: "Asset ID",
4182
+ type: "string",
4183
+ required: true,
4184
+ comments: "ID of the Asset entity.",
4185
+ example: "eyJpZG...",
4186
+ placeholder: "eyJpZG...",
4187
+ clean: _prismatic_io_spectral.util.types.toString
4188
+ });
4189
+ const query$2 = graphql_request.gql`
4190
+ query listRelatedAssets($assetId: ID!) {
4191
+ asset(id: $assetId) {
4192
+ relatedAssets {
4193
+ items {
4194
+ id
4195
+ title
4196
+ }
4197
+ }
4198
+ }
4199
+ }
4200
+ `;
4201
+ const selectRelatedAsset = (0, _prismatic_io_spectral.dataSource)({
4202
+ display: {
4203
+ label: "Select Related Asset",
4204
+ description: "A picklist of assets related to a specific asset."
4205
+ },
4206
+ inputs: {
4207
+ connection,
4208
+ assetId
4209
+ },
4210
+ perform: async (_context, { connection, assetId }) => {
4211
+ return { result: ((await createClient({
4212
+ connection,
4213
+ debug: false
4214
+ }).request(query$2, { assetId }))?.asset?.relatedAssets?.items ?? []).map((item) => ({
4215
+ key: item.id,
4216
+ label: item.title
4217
+ })) };
4218
+ },
4219
+ dataSourceType: "picklist",
4220
+ examplePayload: { result: [{
4221
+ label: "My Asset",
4222
+ key: "eyJpZGVudGlmaWVyIjoiMSJ9"
4223
+ }] }
4224
+ });
4225
+ //#endregion
4226
+ //#region src/dataSources/webhooks.ts
4227
+ const query$1 = graphql_request.gql`
4228
+ query listWebhooks {
4229
+ webhooks {
4230
+ items {
4231
+ id
4232
+ name
4233
+ }
4234
+ }
4235
+ }
4236
+ `;
4237
+ const selectWebhook = (0, _prismatic_io_spectral.dataSource)({
4238
+ display: {
4239
+ label: "Select Webhook",
4240
+ description: "A picklist of webhooks in the current account."
4241
+ },
4242
+ inputs: { connection },
4243
+ perform: async (_context, { connection }) => {
4244
+ return { result: ((await createClient({
4245
+ connection,
4246
+ debug: false
4247
+ }).request(query$1))?.webhooks?.items ?? []).map((item) => ({
4248
+ key: item.id,
4249
+ label: item.name
4250
+ })) };
4251
+ },
4252
+ dataSourceType: "picklist",
4253
+ examplePayload: { result: [{
4254
+ label: "My Webhook",
4255
+ key: "eyJpZGVudGlmaWVyIjoiMSJ9"
4256
+ }] }
4257
+ });
4258
+ //#endregion
4259
+ //#region src/dataSources/workspaceProject.ts
4260
+ const workspaceProjectDatasource = (0, _prismatic_io_spectral.dataSource)({
4261
+ display: {
4262
+ label: "Select Workspace Project",
4263
+ description: "Select a Workspace Project belonging to a certain Brand."
4264
+ },
4265
+ perform: async (_context, { connection, brandId }) => {
4266
+ return { result: (await createClient({
4267
+ connection,
4268
+ debug: false
4269
+ }).request(listBrandWorkspaceProjectsQuery, { brandId })).brand.workspaceProjects.items.map((project) => {
4270
+ return {
4271
+ key: project.id,
4272
+ label: project.name
4273
+ };
4274
+ }) };
4275
+ },
4276
+ inputs: workspaceProjectInputs,
4277
+ dataSourceType: "picklist"
4278
+ });
4279
+ //#endregion
4280
+ //#region src/dataSources/workspaceProjectAssets.ts
4281
+ const workspaceProjectAssetDataSource = (0, _prismatic_io_spectral.dataSource)({
4282
+ display: {
4283
+ label: "Select Workspace Project Asset",
4284
+ description: "Select an Asset that belongs to a given Workspace Project."
4285
+ },
4286
+ perform: async (_context, { connection, projectId }) => {
4287
+ return { result: (await createClient({
4288
+ connection,
4289
+ debug: false
4290
+ }).request(listWorkspaceProjectAssetsQuery, { projectId })).workspaceProject.assets.items.map((asset) => {
4291
+ return {
4292
+ key: asset.id,
4293
+ label: asset.title
4294
+ };
4295
+ }) };
4296
+ },
4297
+ inputs: workspaceProjectAssetInputs,
4298
+ dataSourceType: "picklist"
4299
+ });
4300
+ //#endregion
4301
+ //#region src/dataSources/workspaceProjectFolders.ts
4302
+ const projectId = (0, _prismatic_io_spectral.input)({
4303
+ label: "Workspace Project ID",
4304
+ type: "string",
4305
+ required: true,
4306
+ comments: "ID of the Workspace Project entity.",
4307
+ example: "eyJpZG...",
4308
+ placeholder: "eyJpZG...",
4309
+ clean: _prismatic_io_spectral.util.types.toString
4310
+ });
4311
+ const query = graphql_request.gql`
4312
+ query listWorkspaceProjectFolders($projectId: ID!) {
4313
+ workspaceProject(id: $projectId) {
4314
+ browse {
4315
+ folders {
4316
+ items {
4317
+ id
4318
+ name
4319
+ }
4320
+ }
4321
+ }
4322
+ }
4323
+ }
4324
+ `;
4325
+ //#endregion
4326
+ //#region src/dataSources/index.ts
4327
+ var dataSources_default = {
4328
+ brandDataSource,
4329
+ libraryDataSource,
4330
+ libraryAssetDataSource,
4331
+ workspaceProjectDatasource,
4332
+ workspaceProjectAssetDataSource,
4333
+ selectWorkspaceProjectFolder: (0, _prismatic_io_spectral.dataSource)({
4334
+ display: {
4335
+ label: "Select Workspace Project Folder",
4336
+ description: "A picklist of top-level folders in a Workspace Project."
4337
+ },
4338
+ inputs: {
4339
+ connection,
4340
+ projectId
4341
+ },
4342
+ perform: async (_context, { connection, projectId }) => {
4343
+ return { result: ((await createClient({
4344
+ connection,
4345
+ debug: false
4346
+ }).request(query, { projectId }))?.workspaceProject?.browse?.folders?.items ?? []).map((item) => ({
4347
+ key: item.id,
4348
+ label: item.name
4349
+ })) };
4350
+ },
4351
+ dataSourceType: "picklist",
4352
+ examplePayload: { result: [{
4353
+ label: "My Folder",
4354
+ key: "eyJpZGVudGlmaWVyIjoiMSJ9"
4355
+ }] }
4356
+ }),
4357
+ selectWebhook,
4358
+ selectRelatedAsset,
4359
+ selectLibraryFolder,
4360
+ selectLibraryCollection
4361
+ };
4362
+ //#endregion
4363
+ //#region src/utils/polling.ts
4364
+ const lookBackDateClean = (value) => {
4365
+ const str = _prismatic_io_spectral.util.types.toString(value).trim();
4366
+ if (!str) return "";
4367
+ if (!LOOK_BACK_DATE_PATTERN.test(str)) throw new Error("Look-back Date must be in YYYY-MM-DD format.");
4368
+ const parts = str.split("-");
4369
+ const year = _prismatic_io_spectral.util.types.toNumber(parts[0]);
4370
+ const month = _prismatic_io_spectral.util.types.toNumber(parts[1]);
4371
+ const day = _prismatic_io_spectral.util.types.toNumber(parts[2]);
4372
+ const parsed = new Date(year, month - 1, day);
4373
+ if (parsed.getFullYear() !== year || parsed.getMonth() !== month - 1 || parsed.getDate() !== day) throw new Error(`Look-back Date "${str}" is not a valid calendar date.`);
4374
+ if (parsed > /* @__PURE__ */ new Date()) throw new Error("Look-back Date cannot be a future date.");
4375
+ return str;
4376
+ };
4377
+ const resolvePollingRecordChanges = (data) => {
4378
+ if (!data) return [];
4379
+ const changes = [];
4380
+ for (const record of data.created ?? []) changes.push({
4381
+ changeType: "created",
4382
+ record
4383
+ });
4384
+ for (const record of data.updated ?? []) changes.push({
4385
+ changeType: "updated",
4386
+ record
4387
+ });
4388
+ return changes;
4389
+ };
4390
+ //#endregion
4391
+ //#region src/inputs/triggers.ts
4392
+ const showNewRecords = (0, _prismatic_io_spectral.input)({
4393
+ label: "Show New Records",
4394
+ type: "boolean",
4395
+ required: false,
4396
+ default: "true",
4397
+ comments: "When true, assets created since the last poll are included in the trigger output.",
4398
+ clean: _prismatic_io_spectral.util.types.toBool
4399
+ });
4400
+ const showUpdatedRecords = (0, _prismatic_io_spectral.input)({
4401
+ label: "Show Updated Records",
4402
+ type: "boolean",
4403
+ required: false,
4404
+ default: "true",
4405
+ comments: "When true, assets modified since the last poll are included in the trigger output.",
4406
+ clean: _prismatic_io_spectral.util.types.toBool
4407
+ });
4408
+ const pollLibraryAssetsInputs = {
4409
+ connection,
4410
+ libraryId: libraryId$2,
4411
+ lookBackDate: (0, _prismatic_io_spectral.input)({
4412
+ label: "Look-back Date",
4413
+ placeholder: "Enter look-back date (YYYY-MM-DD)",
4414
+ type: "string",
4415
+ required: false,
4416
+ comments: "The date the initial sync starts from, in YYYY-MM-DD format. Cannot be a future date. Leave empty to start from the first recurrence with no backfill. When set, the initial sync seeds each record modified on or after this date once, ignoring the field and visibility filters.",
4417
+ example: "2026-01-01",
4418
+ clean: lookBackDateClean
4419
+ }),
4420
+ showNewRecords,
4421
+ showUpdatedRecords
4422
+ };
4423
+ //#endregion
4424
+ //#region src/utils/classifyAssets.ts
4425
+ const classifyAssetsByPollDate = (assets, lastPolledAt) => {
4426
+ const lastPolledAtMs = new Date(lastPolledAt).getTime();
4427
+ const created = [];
4428
+ const updated = [];
4429
+ for (const asset of assets) {
4430
+ const createdMs = asset.createdAt ? new Date(asset.createdAt).getTime() : NaN;
4431
+ const modifiedMs = asset.modifiedAt ? new Date(asset.modifiedAt).getTime() : NaN;
4432
+ const isNew = !Number.isNaN(createdMs) && createdMs > lastPolledAtMs;
4433
+ const isUpdated = !isNew && !Number.isNaN(modifiedMs) && modifiedMs > lastPolledAtMs;
4434
+ if (isNew) created.push(asset);
4435
+ else if (isUpdated) updated.push(asset);
4436
+ }
4437
+ return {
4438
+ created,
4439
+ updated
4440
+ };
4441
+ };
4442
+ //#endregion
4443
+ //#region src/triggers/index.ts
4444
+ var triggers_default = { pollChangesTrigger: (0, _prismatic_io_spectral.pollingTrigger)({
4445
+ display: {
4446
+ label: "New and Updated Assets",
4447
+ description: "Retrieves existing and ongoing Assets from Frontify. Load history once, check for changes on a schedule, or both."
4448
+ },
4449
+ inputs: pollLibraryAssetsInputs,
4450
+ triggerResolverSupport: "valid",
4451
+ batchConfig: { batchSize: 50 },
4452
+ triggerResolver: { resolveItems: (_context, { payload }) => resolvePollingRecordChanges(payload.body.data) },
4453
+ perform: async (context, payload, params) => {
4454
+ const pollState = context.polling.getState();
4455
+ const now = (/* @__PURE__ */ new Date()).toISOString();
4456
+ const lastPolledAt = pollState?.lastPolledAt ?? (params.lookBackDate || now);
4457
+ const isBackfill = !pollState?.lastPolledAt && Boolean(params.lookBackDate);
4458
+ const assets = (await graphqlFetchAll({
4459
+ client: createClient({
4460
+ connection: params.connection,
4461
+ debug: context.debug.enabled
4462
+ }),
4463
+ query: listLibraryAssetsQuery,
4464
+ params: {
4465
+ libraryId: params.libraryId,
4466
+ query: {}
4467
+ },
4468
+ hasNextPath: [
4469
+ "library",
4470
+ "assets",
4471
+ "hasNextPage"
4472
+ ]
4473
+ })).flatMap((response) => response.library?.assets?.items ?? []);
4474
+ const { created, updated } = classifyAssetsByPollDate(assets, lastPolledAt);
4475
+ const emittedCreated = isBackfill || params.showNewRecords ? created : [];
4476
+ const emittedUpdated = isBackfill || params.showUpdatedRecords ? updated : [];
4477
+ const totalMatched = emittedCreated.length + emittedUpdated.length;
4478
+ context.polling.setState({ lastPolledAt: now });
4479
+ if (context.debug.enabled) context.logger.debug(`Polled Frontify assets: ${assets.length} fetched, ${emittedCreated.length} created, ${emittedUpdated.length} updated`);
4480
+ return {
4481
+ payload: {
4482
+ ...payload,
4483
+ body: { data: {
4484
+ created: emittedCreated,
4485
+ updated: emittedUpdated
4486
+ } }
4487
+ },
4488
+ polledNoChanges: totalMatched === 0
4489
+ };
4490
+ }
4491
+ }) };
4492
+ //#endregion
4493
+ //#region src/index.ts
4494
+ var src_default = (0, _prismatic_io_spectral.component)({
4495
+ key: "frontify",
4496
+ public: true,
4497
+ documentationUrl: "https://prismatic.io/docs/components/frontify/",
4498
+ display: {
4499
+ label: "Frontify",
4500
+ description: "Frontify is a comprehensive brand management platform that enables organizations to create, manage, and distribute brand assets, guidelines, and digital content across teams and channels, streamlining brand consistency and collaboration.",
4501
+ iconPath: "icon.png",
4502
+ category: "Application Connectors"
4503
+ },
4504
+ actions: actions_default,
4505
+ triggers: triggers_default,
4506
+ dataSources: dataSources_default,
4507
+ connections: connections_default
4508
+ });
4509
+ //#endregion
4510
+ //#region npm-dist/.entry.ts
4511
+ var _entry_default = (0, _prismatic_io_spectral.callableComponent)(src_default);
4512
+ //#endregion
4513
+ module.exports = _entry_default;