@canva/intents 2.1.1 → 2.1.3-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/CHANGELOG.md +13 -13
  2. package/asset/beta.d.ts +190 -0
  3. package/asset/index.d.ts +1 -1
  4. package/beta.d.ts +2995 -0
  5. package/content/beta.d.ts +1606 -0
  6. package/content/index.d.ts +1 -1440
  7. package/data/beta.d.ts +1229 -0
  8. package/data/index.d.ts +1 -1229
  9. package/design/beta.d.ts +41 -0
  10. package/design/index.d.ts +1 -41
  11. package/index.d.ts +1 -2821
  12. package/lib/cjs/sdk/intents/asset/beta.js +14 -0
  13. package/lib/cjs/sdk/intents/asset/index.js +15 -1
  14. package/lib/cjs/sdk/intents/beta.js +20 -0
  15. package/lib/cjs/sdk/intents/content/beta.js +20 -0
  16. package/lib/cjs/sdk/intents/data/beta.js +20 -0
  17. package/lib/cjs/sdk/intents/design/beta.js +20 -0
  18. package/lib/cjs/sdk/intents/fake/{create.js → create_beta.js} +9 -6
  19. package/lib/cjs/sdk/intents/index.js +2 -4
  20. package/lib/cjs/sdk/intents/test/beta.js +19 -0
  21. package/lib/cjs/sdk/intents/test/index.js +13 -14
  22. package/lib/cjs/sdk/intents/version.js +2 -2
  23. package/lib/esm/sdk/intents/asset/beta.js +4 -0
  24. package/lib/esm/sdk/intents/asset/index.js +1 -1
  25. package/lib/esm/sdk/intents/beta.js +3 -0
  26. package/lib/esm/sdk/intents/content/beta.js +3 -0
  27. package/lib/esm/sdk/intents/data/beta.js +3 -0
  28. package/lib/esm/sdk/intents/design/beta.js +3 -0
  29. package/lib/esm/sdk/intents/fake/{create.js → create_beta.js} +7 -4
  30. package/lib/esm/sdk/intents/index.js +1 -3
  31. package/lib/esm/sdk/intents/test/beta.js +9 -0
  32. package/lib/esm/sdk/intents/test/index.js +1 -9
  33. package/lib/esm/sdk/intents/version.js +2 -2
  34. package/package.json +23 -23
  35. package/test/beta.d.ts +11 -0
  36. package/test/index.d.ts +1 -11
package/beta.d.ts ADDED
@@ -0,0 +1,2995 @@
1
+ /**
2
+ * @public
3
+ * A disclosure identifying if the app generated this asset using AI.
4
+ *
5
+ * @remarks
6
+ * Helps users make informed decisions about the content they interact with.
7
+ *
8
+ * AI is generally defined as any machine system that, given an objective, infers how to generate an output from an input.
9
+ * Some examples include "generative AI", "large language models", and "machine learning".
10
+ *
11
+ * **App Generated**
12
+ *
13
+ * 'app_generated' indicates when the app creates or significantly alters an asset using AI. Includes when
14
+ * the app makes a request to a third-party service to do so.
15
+ *
16
+ * A significantly altered asset means the AI changes key information or details, such as
17
+ * removing or replacing key components in the original content, which can include applying style transfer, or changing facial expressions.
18
+ *
19
+ * Label this asset as 'app_generated' under these conditions:
20
+ *
21
+ * The following is true:
22
+ *
23
+ * - The app generates the asset in response to a user's request (including past requests), for example, the asset is not from an asset library.
24
+ *
25
+ * And any of these conditions are also true:
26
+ *
27
+ * - The AI creates entirely new content from scratch.
28
+ * - The AI introduces new multimedia, details, or creative elements not originally present.
29
+ * - The AI removes and replaces the asset's key components.
30
+ * - The AI alters the asset's appearance, meaning, or context in a way that conveys a different message than the original.
31
+ *
32
+ * **None**
33
+ *
34
+ * 'none' indicates when the asset wasn't generated by the app as a part of any user's specific request, for example, a third-party
35
+ * request, or when the asset wasn't significantly altered by AI.
36
+ */
37
+ declare type AiDisclosure = 'app_generated' | 'none';
38
+
39
+ declare type AllOrNone<T> = T | Never<T>;
40
+
41
+ /**
42
+ * @public
43
+ * {@link GetDataTableError} indicating custom error occurred in the app's implementation.
44
+ * This can be used to indicate specific issues that are not covered by other error types.
45
+ */
46
+ declare type AppError = {
47
+ /**
48
+ * A custom error occurred in your app.
49
+ *
50
+ * Return this for application-specific errors that don't fit
51
+ * the other categories. Include a descriptive message explaining
52
+ * the error to the user.
53
+ */
54
+ status: 'app_error';
55
+ /**
56
+ * Optional message explaining the error.
57
+ */
58
+ message?: string;
59
+ };
60
+
61
+ /**
62
+ * @public
63
+ * {@link PublishContentError} indicating a custom error occurred in your app's implementation.
64
+ *
65
+ * Return this for application-specific errors such as:
66
+ *
67
+ * - Validation failures
68
+ * - Authentication errors
69
+ * - Rate limiting
70
+ * - Platform-specific restrictions
71
+ *
72
+ * @example Returning custom error with message
73
+ * ```ts
74
+ * if (userQuotaExceeded) {
75
+ * return {
76
+ * status: 'app_error',
77
+ * message: 'You have reached your monthly publish limit. Please upgrade your plan.'
78
+ * };
79
+ * }
80
+ * ```
81
+ */
82
+ declare type AppError_2 = {
83
+ status: 'app_error';
84
+ /**
85
+ * (required) The raw error message, for logging purposes. It will not display in the UI.
86
+ * To display custom error messages in the UI use `localizedMessageId`.
87
+ *
88
+ * This should typically be the javascript error.message or a REST JSON error message
89
+ * body passed without modification.
90
+ *
91
+ * WARNING: Do not include personally identifiable information (PII) in this
92
+ * message, such as names, emails, usernames, etc.
93
+ */
94
+ message: string;
95
+ /**
96
+ * (optional) Message ID of the translated error message that will be
97
+ * displayed to the user. The message ID should be present and uploaded in
98
+ * your translation file. If omitted, Canva will display a generic error
99
+ * message.
100
+ */
101
+ localizedMessageId?: string;
102
+ /** HTTP status code, if applicable */
103
+ httpCode?: number;
104
+ /**
105
+ * Used only by app developer. Canva does not use this value. Use this to pass
106
+ * additional information like JSON to your settings frame.
107
+ */
108
+ appDefinedPayload?: string;
109
+ /**
110
+ * (optional) Source of the error if it relates to a component on the Canva
111
+ * UI. When present, the error may render near a relevant Canva component.
112
+ * When omitted, the cause is considered unspecified or "generic".
113
+ */
114
+ errorCause?: ErrorCause;
115
+ };
116
+
117
+ /**
118
+ * @public
119
+ * {@link InvocationContext} indicating a custom error occurred during data refresh.
120
+ * Triggered when getDataTable returned 'app_error' status.
121
+ * UI should display the error message and help users recover.
122
+ */
123
+ declare type AppErrorInvocationContext = {
124
+ /**
125
+ * A custom error occurred during data refresh.
126
+ *
127
+ * This occurs when `getDataTable` returned 'app_error' during a refresh attempt.
128
+ * Your UI should display the error message and help users recover from the specific
129
+ * issue.
130
+ */
131
+ reason: 'app_error';
132
+ /**
133
+ * The data source reference that caused the error during refresh.
134
+ */
135
+ dataSourceRef?: DataSourceRef;
136
+ /**
137
+ * The error message to display to the user.
138
+ */
139
+ message?: string;
140
+ };
141
+
142
+ /**
143
+ * @public
144
+ * Base file requirement interface.
145
+ */
146
+ declare interface BaseFileRequirement {
147
+ /**
148
+ * File format for this requirement.
149
+ */
150
+ format: PublishFileFormat;
151
+
152
+ }
153
+
154
+ /**
155
+ * @public
156
+ * Base interface for exported files.
157
+ */
158
+ declare interface BaseOutputFile {
159
+ /**
160
+ * File format.
161
+ */
162
+ format: PublishFileFormat;
163
+ /**
164
+ * URL to download the exported file.
165
+ *
166
+ * Your app should download from this URL and upload to your platform.
167
+ */
168
+ url: string;
169
+ /**
170
+ * Metadata about the source content used to create this exported file.
171
+ */
172
+ contentMetadata: ContentMetadata;
173
+ }
174
+
175
+ /**
176
+ * @public
177
+ * Base interface for all preview types.
178
+ *
179
+ * Contains common properties shared by all preview types.
180
+ */
181
+ declare interface BasePreview {
182
+ /**
183
+ * Unique identifier for this preview.
184
+ *
185
+ * Use this ID with `requestPreviewUpgrade` to upgrade video thumbnails.
186
+ */
187
+ id: string;
188
+ /**
189
+ * Type of media in this preview.
190
+ */
191
+ kind: PreviewKind;
192
+ /**
193
+ * Current state of the preview.
194
+ */
195
+ status: PreviewStatus;
196
+ }
197
+
198
+ /**
199
+ * @beta
200
+ * Beta preview in various states.
201
+ */
202
+ declare type BetaPreview = ImagePreview | VideoPreview | DocumentPreview | EmailPreview;
203
+
204
+ /**
205
+ * @beta
206
+ * Preview media for a specific media slot.
207
+ *
208
+ * Contains preview URLs and metadata for images or videos in the design.
209
+ * Made for beta preview types.
210
+ */
211
+ declare type BetaPreviewMedia = {
212
+ mediaSlotId: string;
213
+ previews: BetaPreview[];
214
+ };
215
+
216
+ /**
217
+ * @public
218
+ * Cell containing a boolean value.
219
+ *
220
+ * @example Creating a boolean cell
221
+ * ```ts
222
+ * import type { BooleanDataTableCell } from '@canva/intents/data';
223
+ *
224
+ * const isActiveCell: BooleanDataTableCell = {
225
+ * type: 'boolean',
226
+ * value: true
227
+ * };
228
+ * ```
229
+ *
230
+ * @example Creating a boolean cell with false value
231
+ * ```ts
232
+ * import type { BooleanDataTableCell } from '@canva/intents/data';
233
+ *
234
+ * const isCompleteCell: BooleanDataTableCell = {
235
+ * type: 'boolean',
236
+ * value: false
237
+ * };
238
+ * ```
239
+ *
240
+ * @example Creating an empty boolean cell
241
+ * ```ts
242
+ * import type { BooleanDataTableCell } from '@canva/intents/data';
243
+ *
244
+ * const emptyBooleanCell: BooleanDataTableCell = {
245
+ * type: 'boolean',
246
+ * value: undefined
247
+ * };
248
+ * ```
249
+ */
250
+ declare type BooleanDataTableCell = {
251
+ /**
252
+ * Indicates this cell contains a boolean value.
253
+ */
254
+ type: 'boolean';
255
+ /**
256
+ * Boolean value (true or false).
257
+ *
258
+ * Use `undefined` for an empty cell.
259
+ */
260
+ value: boolean | undefined;
261
+ };
262
+
263
+ /**
264
+ * @public
265
+ * Configuration for a table column.
266
+ */
267
+ declare type ColumnConfig = {
268
+ /**
269
+ * Name for the column, displayed as header text.
270
+ *
271
+ * If `undefined`, the column will have no header text.
272
+ */
273
+ name: string | undefined;
274
+ /**
275
+ * Expected data type for cells in this column.
276
+ *
277
+ * Use a specific `DataType` for columns with consistent types,
278
+ * or `'variant'` for columns that may contain mixed types.
279
+ */
280
+ type: DataType | 'variant';
281
+ };
282
+
283
+ declare namespace content {
284
+ export {
285
+ prepareContentPublisher,
286
+ ContentPublisherIntent,
287
+ RenderPreviewUiInvocationContext,
288
+ PublishPreviewUiInvocationContext,
289
+ RenderPreviewUiRequest,
290
+ Disposer,
291
+ PublishContentRequest,
292
+ RenderSettingsUiInvocationContext,
293
+ PublishSettingsUiInvocationContext,
294
+ RenderSettingsUiRequest,
295
+ OnContextChange,
296
+ SettingsUiContext,
297
+ PublishSettingsSettingsUiContext,
298
+ PublishErrorSettingsUiContext,
299
+ PublishErrorClearedSettingsUiContext,
300
+ PublishError,
301
+ PublishSettings,
302
+ PublishRefValidityState,
303
+ UpdatePublishSettingsResponse,
304
+ UpdatePublishSettingsCompleted,
305
+ PublishContentResponse,
306
+ PublishContentCompleted,
307
+ PostPublishAction,
308
+ PostPublishActionRedirect,
309
+ PublishContentError,
310
+ RemoteRequestFailedError_2 as RemoteRequestFailedError,
311
+ AppError_2 as AppError,
312
+ ErrorCause,
313
+ GetPublishConfigurationResponse,
314
+ GetPublishConfigurationCompleted,
315
+ GetPublishConfigurationError,
316
+ OutputType,
317
+ MediaSlot,
318
+ ImageRequirement,
319
+ VideoRequirement,
320
+ DocumentRequirement,
321
+ EmailRequirement,
322
+ DocumentSize,
323
+ PublishFileFormat,
324
+ ExactValueRange,
325
+ MinValueRange,
326
+ MaxValueRange,
327
+ MinMaxValueRange,
328
+ ValueRange,
329
+ PreviewMedia,
330
+ BetaPreviewMedia,
331
+ Preview,
332
+ BetaPreview,
333
+ DocumentPreview,
334
+ DocumentPreviewLoading,
335
+ DocumentPreviewThumbnail,
336
+ DocumentPreviewError,
337
+ ImagePreview,
338
+ ImagePreviewLoading,
339
+ ImagePreviewReady,
340
+ ImagePreviewError,
341
+ VideoPreview,
342
+ VideoPreviewLoading,
343
+ VideoPreviewThumbnail,
344
+ VideoPreviewUpgrading,
345
+ VideoPreviewReady,
346
+ VideoPreviewError,
347
+ EmailPreview,
348
+ EmailPreviewLoading,
349
+ EmailPreviewReady,
350
+ EmailPreviewError,
351
+ BasePreview,
352
+ SizedPreview,
353
+ PreviewKind,
354
+ PreviewStatus,
355
+ OutputMedia,
356
+ OutputFile,
357
+ ImageOutputFile,
358
+ VideoOutputFile,
359
+ BaseOutputFile,
360
+ DocumentOutputFile,
361
+ EmailOutputFile,
362
+ ContentMetadata,
363
+ DesignContentMetadata,
364
+ OutputPageMetadata
365
+ }
366
+ }
367
+ export { content }
368
+
369
+ /**
370
+ * @public
371
+ * Metadata about the source content used to create an exported file.
372
+ */
373
+ declare type ContentMetadata = DesignContentMetadata;
374
+
375
+ /**
376
+ * @public
377
+ * Main interface for implementing the ContentPublisher intent.
378
+ *
379
+ * Implementing the ContentPublisher intent enables apps to publish contents to external platforms.
380
+ * This allows users to configure publish settings, preview their designs, and share with others.
381
+ *
382
+ * The publishing flow follows this process:
383
+ *
384
+ * 1. User initiates publish action
385
+ * 2. Your app provides publish configuration via `getPublishConfiguration`
386
+ * 3. User selects an output type
387
+ * 4. Your app renders settings UI via `renderSettingsUi`
388
+ * 5. Your app renders preview UI via `renderPreviewUi`
389
+ * 6. User reviews settings and preview
390
+ * 7. Your app publishes the content via `publishContent`
391
+ */
392
+ declare type ContentPublisherIntent = {
393
+ /**
394
+ * Provides the configuration for the publishing platform.
395
+ *
396
+ * This action is called when the user initiates the publish flow and needs to
397
+ * select an output type for the target platform.
398
+ *
399
+ * Use this to define different publishing configurations for your platform,
400
+ * such as social media posts, videos, or other output types.
401
+ *
402
+ * @returns A promise resolving to the publish configuration or an error
403
+ *
404
+ * @example Defining publish configuration for a social media platform
405
+ * ```ts
406
+ * import type { GetPublishConfigurationResponse } from '@canva/intents/content';
407
+ *
408
+ * async function getPublishConfiguration(): Promise<GetPublishConfigurationResponse> {
409
+ * return {
410
+ * status: 'completed',
411
+ * outputTypes: [
412
+ * {
413
+ * id: 'instagram_post',
414
+ * displayName: 'Instagram Post',
415
+ * mediaSlots: [
416
+ * {
417
+ * id: 'main_image',
418
+ * displayName: 'Post Image',
419
+ * fileCount: { min: 1, max: 10 },
420
+ * accepts: {
421
+ * image: { format: 'jpg', aspectRatio: { min: 0.8, max: 1.91 } }
422
+ * }
423
+ * }
424
+ * ]
425
+ * }
426
+ * ]
427
+ * };
428
+ * }
429
+ * ```
430
+ */
431
+ getPublishConfiguration: () => Promise<GetPublishConfigurationResponse>;
432
+
433
+ /**
434
+ * Renders a user interface for configuring publish settings.
435
+ *
436
+ * This action is called after the user selects an output type. Your UI should
437
+ * allow users to configure platform-specific settings such as captions, tags,
438
+ * privacy settings, or publishing destinations.
439
+ *
440
+ * Use the `updatePublishSettings` callback to save user settings and validate them.
441
+ * Settings are stored in the `publishRef` string (maximum 5KB).
442
+ *
443
+ * @param request - Configuration and callbacks for the publish settings UI.
444
+ *
445
+ * @example Rendering a settings UI with publish configuration
446
+ * ```ts
447
+ * import { createRoot } from 'react-dom/client';
448
+ * import type { RenderSettingsUiRequest } from '@canva/intents/content';
449
+ *
450
+ * function renderSettingsUi(request: RenderSettingsUiRequest): void {
451
+ * const SettingsUiApp = () => (
452
+ * <AppUiProvider>
453
+ * <SettingsUi request={request} />
454
+ * </AppUiProvider>
455
+ * );
456
+ *
457
+ * createRoot().render(<SettingsUiApp />)
458
+ * }
459
+ * ```
460
+ */
461
+ renderSettingsUi: (request: RenderSettingsUiRequest) => void;
462
+ /**
463
+ * Renders a user interface for previewing the content.
464
+ *
465
+ * This action is called after the settings UI is rendered. Your UI should display
466
+ * a preview of how the content will appear on the target platform.
467
+ *
468
+ * Previews update dynamically as users modify their content or settings. For videos,
469
+ * start with lightweight thumbnails and use `requestPreviewUpgrade` to load full
470
+ * video previews on demand to optimize performance.
471
+ *
472
+ * @param request - Configuration and callbacks for the preview UI.
473
+ *
474
+ * @example Rendering a preview UI with video optimization
475
+ * ```ts
476
+ * import { createRoot } from 'react-dom/client';
477
+ * import type { RenderPreviewUiRequest } from '@canva/intents/content';
478
+ *
479
+ * function renderPreviewUi(request: RenderPreviewUiRequest): void {
480
+ * const PreviewUiApp = () => (
481
+ * <AppUiProvider>
482
+ * <PreviewUi request={request} />
483
+ * </AppUiProvider>
484
+ * );
485
+ *
486
+ * createRoot().render(<PreviewUiApp />)
487
+ * }
488
+ * ```
489
+ */
490
+ renderPreviewUi: (request: RenderPreviewUiRequest) => void;
491
+ /**
492
+ * Publishes the content to the external platform.
493
+ *
494
+ * This action is called when the user confirms the publish action after reviewing
495
+ * settings and preview. Your implementation should send the exported files
496
+ * to your platform's API.
497
+ *
498
+ * The `outputMedia` contains production-ready files that match the requirements
499
+ * specified in your output types. The `publishRef` contains the user's settings
500
+ * from the settings UI.
501
+ *
502
+ * @param request - Parameters for the publish operation.
503
+ * @returns A promise resolving to either a successful result with the published content details or an error.
504
+ *
505
+ * @example Publishing content to an external platform
506
+ * ```ts
507
+ * import type { PublishContentRequest, PublishContentResponse } from '@canva/intents/content';
508
+ *
509
+ * async function publishContent(request: PublishContentRequest): Promise<PublishContentResponse> {
510
+ * const { publishRef, outputType, outputMedia } = request;
511
+ *
512
+ * try {
513
+ * // Parse settings from publishRef
514
+ * const settings = publishRef ? JSON.parse(publishRef) : {};
515
+ *
516
+ * // Upload files to your platform
517
+ * const uploadedFiles = await Promise.all(
518
+ * outputMedia.flatMap(media =>
519
+ * media.files.map(file => uploadFile(file.url))
520
+ * )
521
+ * );
522
+ *
523
+ * // Create post on your platform
524
+ * const result = await createPost({
525
+ * files: uploadedFiles,
526
+ * caption: settings.caption
527
+ * });
528
+ *
529
+ * return {
530
+ * status: 'completed',
531
+ * externalId: result.id,
532
+ * externalUrl: result.url
533
+ * };
534
+ * } catch (error) {
535
+ * return {
536
+ * status: 'remote_request_failed'
537
+ * };
538
+ * }
539
+ * }
540
+ * ```
541
+ */
542
+ publishContent: (request: PublishContentRequest) => Promise<PublishContentResponse>;
543
+
544
+ };
545
+
546
+ declare namespace data {
547
+ export {
548
+ prepareDataConnector,
549
+ DataConnectorIntent,
550
+ GetDataTableRequest,
551
+ RenderSelectionUiRequest,
552
+ InvocationContext,
553
+ GetDataTableResponse,
554
+ GetDataTableCompleted,
555
+ DataTableMetadata,
556
+ GetDataTableError,
557
+ UpdateDataRefResponse,
558
+ DataSourceRef,
559
+ DataTableLimit,
560
+ DataType,
561
+ DataTable,
562
+ ColumnConfig,
563
+ DataTableRow,
564
+ DataTableCell,
565
+ DateDataTableCell,
566
+ StringDataTableCell,
567
+ NumberDataTableCell,
568
+ NumberCellMetadata,
569
+ BooleanDataTableCell,
570
+ MediaCollectionDataTableCell,
571
+ DataTableImageUpload,
572
+ DataTableVideoUpload
573
+ }
574
+ }
575
+ export { data }
576
+
577
+ /**
578
+ * @public
579
+ * Main interface for implementing the Data Connector intent.
580
+ *
581
+ * Implementing the Data Connector intent enables apps to import external data into Canva.
582
+ * This allows users to select, preview, and refresh data from external sources.
583
+ */
584
+ declare type DataConnectorIntent = {
585
+ /**
586
+ * Gets structured data from an external source.
587
+ *
588
+ * This action is called in two scenarios:
589
+ *
590
+ * - During data selection to preview data before import (when {@link RenderSelectionUiRequest.updateDataRef} is called).
591
+ * - When refreshing previously imported data (when the user requests an update).
592
+ *
593
+ * @param request - Parameters for the data fetching operation.
594
+ * @returns A promise resolving to either a successful result with data or an error.
595
+ *
596
+ * @example Getting data from an external source
597
+ * ```ts
598
+ * import type { GetDataTableRequest, GetDataTableResponse } from '@canva/intents/data';
599
+ *
600
+ * async function getDataTable(request: GetDataTableRequest): Promise<GetDataTableResponse> {
601
+ * const { dataSourceRef, limit, signal } = request;
602
+ *
603
+ * // Check if the operation has been aborted.
604
+ * if (signal.aborted) {
605
+ * return { status: 'app_error', message: 'The data fetch operation was cancelled.' };
606
+ * }
607
+ *
608
+ * // ... data fetching logic using dataSourceRef, limit, and signal ...
609
+ *
610
+ * // Placeholder for a successful result.
611
+ * return {
612
+ * status: 'completed',
613
+ * dataTable: { rows: [{ cells: [{ type: 'string', value: 'Fetched data' }] }] }
614
+ * };
615
+ * }
616
+ * ```
617
+ */
618
+ getDataTable: (request: GetDataTableRequest) => Promise<GetDataTableResponse>;
619
+
620
+ /**
621
+ * Renders a user interface for selecting and configuring data from your external sources.
622
+ *
623
+ * @param request - Configuration and callbacks for the data selection UI.
624
+ *
625
+ * @example Rendering a data selection UI
626
+ * ```ts
627
+ * import type { RenderSelectionUiRequest } from '@canva/intents/data';
628
+ *
629
+ * async function renderSelectionUi(request: RenderSelectionUiRequest): Promise<void> {
630
+ * // UI rendering logic.
631
+ * // Example: if user selects data 'ref123'.
632
+ * const selectedRef = { source: 'ref123', title: 'My Selected Table' };
633
+ * try {
634
+ * const result = await request.updateDataRef(selectedRef);
635
+ * if (result.status === 'completed') {
636
+ * console.log('Selection valid and preview updated.');
637
+ * } else {
638
+ * console.error('Selection error:', result.status);
639
+ * }
640
+ * } catch (error) {
641
+ * console.error('An unexpected error occurred during data ref update:', error);
642
+ * }
643
+ * }
644
+ * ```
645
+ */
646
+ renderSelectionUi: (request: RenderSelectionUiRequest) => void;
647
+ };
648
+
649
+ /**
650
+ * @public
651
+ * {@link InvocationContext} indicating initial data selection flow or edit of existing data.
652
+ */
653
+ declare type DataSelectionInvocationContext = {
654
+ /**
655
+ * Initial data selection or editing existing data.
656
+ *
657
+ * This is the standard flow when:
658
+ *
659
+ * - A user is selecting data for the first time
660
+ * - A user is editing a previous selection
661
+ *
662
+ * If `dataSourceRef` is provided, this indicates an edit flow, and you should
663
+ * pre-populate your UI with this selection.
664
+ */
665
+ reason: 'data_selection';
666
+ /**
667
+ * If dataSourceRef is provided, this is an edit of existing data flow and UI should be pre-populated.
668
+ */
669
+ dataSourceRef?: DataSourceRef;
670
+ };
671
+
672
+ /**
673
+ * @public
674
+ * Reference to an external data source that can be used to fetch data.
675
+ * Created by Data Connector apps and stored by Canva for data refresh operations.
676
+ *
677
+ * You create this object in your data selection UI and pass it to the
678
+ * `updateDataRef` callback. Canva stores this reference and uses it for
679
+ * future data refresh operations.
680
+ *
681
+ * Maximum size: 5KB
682
+ *
683
+ * @example Defining how to locate external data
684
+ * ```ts
685
+ * const dataSourceRef: DataSourceRef = {
686
+ * source: JSON.stringify({
687
+ * reportId: "monthly_sales_001",
688
+ * filters: { year: 2023, region: "NA" }
689
+ * }),
690
+ * title: "Monthly Sales Report (NA, 2023)"
691
+ * };
692
+ * ```
693
+ */
694
+ declare type DataSourceRef = {
695
+ /**
696
+ * Information needed to identify and retrieve data from your source.
697
+ *
698
+ * This string should contain all the information your app needs to
699
+ * fetch the exact data selection later. Typically, this is a serialized
700
+ * object with query parameters, identifiers, or filters.
701
+ *
702
+ * You are responsible for encoding and decoding this value appropriately.
703
+ *
704
+ * Maximum size: 5KB
705
+ */
706
+ source: string;
707
+ /**
708
+ * A human-readable description of the data reference.
709
+ *
710
+ * This title may be displayed to users in the Canva interface to help
711
+ * them identify the data source.
712
+ *
713
+ * Maximum length: 255 characters
714
+ */
715
+ title?: string;
716
+ };
717
+
718
+ /**
719
+ * @public
720
+ * Structured tabular data for import into Canva.
721
+ *
722
+ * This format allows you to provide typed data with proper formatting
723
+ * to ensure it displays correctly in Canva designs.
724
+ *
725
+ * @example Creating a data table
726
+ * ```ts
727
+ * import type { ColumnConfig, DataTableCell, DataTable, DataTableRow } from '@canva/intents/data';
728
+ *
729
+ * const myTable: DataTable = {
730
+ * columnConfigs: [
731
+ * { name: 'Name', type: 'string' },
732
+ * { name: 'Age', type: 'number' },
733
+ * { name: 'Subscribed', type: 'boolean' },
734
+ * { name: 'Join Date', type: 'date' }
735
+ * ],
736
+ * rows: [
737
+ * {
738
+ * cells: [
739
+ * { type: 'string', value: 'Alice' },
740
+ * { type: 'number', value: 30 },
741
+ * { type: 'boolean', value: true },
742
+ * { type: 'date', value: Math.floor(new Date('2023-01-15').getTime() / 1000) }
743
+ * ]
744
+ * },
745
+ * {
746
+ * cells: [
747
+ * { type: 'string', value: 'Bob' },
748
+ * { type: 'number', value: 24 },
749
+ * { type: 'boolean', value: false },
750
+ * { type: 'date', value: Math.floor(new Date('2022-07-20').getTime() / 1000) }
751
+ * ]
752
+ * }
753
+ * ]
754
+ * };
755
+ * ```
756
+ */
757
+ declare type DataTable = {
758
+ /**
759
+ * Column definitions with names and data types.
760
+ *
761
+ * These help Canva interpret and display your data correctly.
762
+ */
763
+ columnConfigs?: ColumnConfig[];
764
+ /**
765
+ * The data rows containing the actual values.
766
+ *
767
+ * Each row contains an array of cells with typed data values.
768
+ */
769
+ rows: DataTableRow[];
770
+ };
771
+
772
+ /**
773
+ * @public
774
+ * Generic type for table cells that resolves to a specific cell type.
775
+ */
776
+ declare type DataTableCell<T extends DataType = DataType> = {
777
+ date: DateDataTableCell;
778
+ string: StringDataTableCell;
779
+ number: NumberDataTableCell;
780
+ boolean: BooleanDataTableCell;
781
+ media: MediaCollectionDataTableCell;
782
+ }[T];
783
+
784
+ /**
785
+ * @public
786
+ * Options for uploading an image asset to the user's private media library.
787
+ */
788
+ declare type DataTableImageUpload = Omit<ImageUploadOptions, 'type' | 'parentRef'> & {
789
+ /**
790
+ * Indicates this value contains options for image uploading.
791
+ */
792
+ type: 'image_upload';
793
+ };
794
+
795
+ /**
796
+ * @public
797
+ * Maximum dimensions for imported data tables.
798
+ */
799
+ declare type DataTableLimit = {
800
+ /**
801
+ * The maximum number of rows allowed.
802
+ *
803
+ * Your app should ensure data does not exceed this limit.
804
+ */
805
+ row: number;
806
+ /**
807
+ * The maximum number of columns allowed.
808
+ *
809
+ * Your app should ensure data does not exceed this limit.
810
+ */
811
+ column: number;
812
+ };
813
+
814
+ /**
815
+ * @public
816
+ * Metadata providing additional context about the imported data.
817
+ */
818
+ declare type DataTableMetadata = {
819
+ /**
820
+ * A human-readable description of the dataset.
821
+ *
822
+ * This description helps users understand what data they are importing.
823
+ */
824
+ description?: string;
825
+ /**
826
+ * Information about the data provider or source.
827
+ */
828
+ providerInfo?: {
829
+ /**
830
+ * Name of the data provider.
831
+ */
832
+ name: string;
833
+ /**
834
+ * URL to the provider's website or related resource.
835
+ */
836
+ url?: string;
837
+ };
838
+ };
839
+
840
+ /**
841
+ * @public
842
+ * A row in the data table.
843
+ *
844
+ * @example Creating a single row of data cells
845
+ * ```ts
846
+ * import type { DataTableCell, DataTableRow } from '@canva/intents/data';
847
+ *
848
+ * const row: DataTableRow = {
849
+ * cells: [
850
+ * { type: 'string', value: 'Product Alpha' },
851
+ * { type: 'number', value: 199.99 },
852
+ * { type: 'boolean', value: true }
853
+ * ]
854
+ * };
855
+ * ```
856
+ */
857
+ declare type DataTableRow = {
858
+ /**
859
+ * Array of cells containing the data values.
860
+ *
861
+ * Each cell must have a type that matches the corresponding column definition (if provided).
862
+ */
863
+ cells: DataTableCell<DataType>[];
864
+ };
865
+
866
+ /**
867
+ * @public
868
+ * Options for uploading a video asset to the user's private media library.
869
+ */
870
+ declare type DataTableVideoUpload = Omit<VideoUploadOptions, 'type' | 'parentRef'> & {
871
+ /**
872
+ * Indicates this value contains options for video uploading.
873
+ */
874
+ type: 'video_upload';
875
+ };
876
+
877
+ /**
878
+ * @public
879
+ * Data types supported for table cells.
880
+ */
881
+ declare type DataType = 'string' | 'number' | 'date' | 'boolean' | 'media';
882
+
883
+ /**
884
+ * @public
885
+ * Cell containing a date value.
886
+ *
887
+ * @example Creating a date cell
888
+ * ```ts
889
+ * import type { DateDataTableCell } from '@canva/intents/data';
890
+ *
891
+ * const todayCell: DateDataTableCell = {
892
+ * type: 'date',
893
+ * value: Math.floor(Date.now() / 1000) // Unix timestamp in seconds
894
+ * };
895
+ *
896
+ * const emptyDateCell: DateDataTableCell = {
897
+ * type: 'date',
898
+ * value: undefined
899
+ * };
900
+ * ```
901
+ */
902
+ declare type DateDataTableCell = {
903
+ /**
904
+ * Indicates this cell contains a date value.
905
+ */
906
+ type: 'date';
907
+ /**
908
+ * Unix timestamp in seconds representing the date.
909
+ *
910
+ * Use `undefined` for an empty cell.
911
+ */
912
+ value: number | undefined;
913
+ };
914
+
915
+ declare namespace design {
916
+ export {
917
+ prepareDesignEditor,
918
+ DesignEditorIntent
919
+ }
920
+ }
921
+ export { design }
922
+
923
+ /**
924
+ * @public
925
+ * Metadata specific to design content.
926
+ */
927
+ declare interface DesignContentMetadata {
928
+ type: 'design';
929
+ /**
930
+ * A signed JWT token containing the design id
931
+ */
932
+ designToken: string;
933
+ /**
934
+ * The user given title of the design
935
+ */
936
+ title: string | undefined;
937
+ /**
938
+ * The pages that make up the exported metadata
939
+ */
940
+ pages: OutputPageMetadata[];
941
+ }
942
+
943
+ /**
944
+ * @public
945
+ *
946
+ * Main interface for implementing the DesignEditor intent.
947
+ *
948
+ * Implementing the DesignEditor Intent enables apps to assist users in editing designs,
949
+ * by presenting interactive and creative tooling alongside the Canva design surface.
950
+ */
951
+ declare type DesignEditorIntent = {
952
+ /**
953
+ * Renders the UI containing the app’s functionality.
954
+ *
955
+ * @example
956
+ * ```tsx
957
+ * function render() {
958
+ * // render your UI using your preferred framework
959
+ * }
960
+ * ```
961
+ */
962
+ render: () => void;
963
+ };
964
+
965
+ /**
966
+ * @public
967
+ * A set of dimensions.
968
+ */
969
+ declare type Dimensions = {
970
+ /**
971
+ * A width, in pixels.
972
+ */
973
+ width: number;
974
+ /**
975
+ * A height, in pixels.
976
+ */
977
+ height: number;
978
+ };
979
+
980
+ /**
981
+ * @public
982
+ * A function that can be called to dispose of a callback.
983
+ */
984
+ declare type Disposer = () => void;
985
+
986
+ /**
987
+ * @public
988
+ * Exported PDF file ready for publishing.
989
+ *
990
+ * Contains the final PDF document that should be uploaded to your platform.
991
+ * The document format is `pdf_standard` and the file is ready to use.
992
+ */
993
+ declare type DocumentOutputFile = BaseOutputFile;
994
+
995
+ /**
996
+ * @public
997
+ * Document preview in various states.
998
+ *
999
+ * Documents transition through states: `"loading"` → `"thumbnail"`.
1000
+ * Start with a lightweight thumbnail of the first page for quick preview rendering.
1001
+ */
1002
+ declare type DocumentPreview = DocumentPreviewLoading | DocumentPreviewThumbnail | DocumentPreviewError;
1003
+
1004
+ /**
1005
+ * @public
1006
+ * Document preview that failed to generate.
1007
+ *
1008
+ * Display an error state to the user.
1009
+ */
1010
+ declare interface DocumentPreviewError extends SizedPreview {
1011
+ kind: 'document';
1012
+ status: 'error';
1013
+ /**
1014
+ * The error message to display to the user.
1015
+ */
1016
+ message: string;
1017
+ }
1018
+
1019
+ /**
1020
+ * @public
1021
+ * Document preview that is currently being generated.
1022
+ *
1023
+ * Display a loading state until the preview transitions to `"thumbnail"` or `"error"`.
1024
+ */
1025
+ declare interface DocumentPreviewLoading extends SizedPreview {
1026
+ kind: 'document';
1027
+ status: 'loading';
1028
+ }
1029
+
1030
+ /**
1031
+ * @public
1032
+ * Document preview with first page thumbnail available.
1033
+ *
1034
+ * This is the initial state for document previews. Show the thumbnail image
1035
+ * of the first page along with the page count to give users a preview of
1036
+ * the document before publishing.
1037
+ */
1038
+ declare interface DocumentPreviewThumbnail extends SizedPreview {
1039
+ kind: 'document';
1040
+ status: 'thumbnail';
1041
+ /**
1042
+ * Format of the thumbnail image.
1043
+ */
1044
+ thumbnailFormat: 'png' | 'jpg';
1045
+ /**
1046
+ * URL to the first page thumbnail.
1047
+ *
1048
+ * Display this lightweight image to preview the document content.
1049
+ */
1050
+ thumbnailUrl: string;
1051
+ }
1052
+
1053
+ /**
1054
+ * @public
1055
+ * Document file requirements for a media slot.
1056
+ *
1057
+ * Note: Document output types use image previews (PNG thumbnails) in the preview UI.
1058
+ * The actual document file is only generated for the final output in OutputMedia.
1059
+ *
1060
+ * @example Document requirements
1061
+ * ```ts
1062
+ * const documentReq: DocumentRequirement = {
1063
+ * format: 'pdf_standard',
1064
+ * size: 'a4',
1065
+ * };
1066
+ * ```
1067
+ */
1068
+ declare interface DocumentRequirement extends BaseFileRequirement {
1069
+ /**
1070
+ * Supported document export format.
1071
+ * Currently supports PDF standard format.
1072
+ */
1073
+ format: 'pdf_standard';
1074
+ /**
1075
+ * The document size of the export file.
1076
+ */
1077
+ size: DocumentSize;
1078
+ }
1079
+
1080
+ /**
1081
+ * @public
1082
+ * Document size for document exports.
1083
+ */
1084
+ declare type DocumentSize = 'a4' | 'a3' | 'letter' | 'legal';
1085
+
1086
+ /**
1087
+ * @beta
1088
+ * Exported email file ready for publishing.
1089
+ *
1090
+ * Contains the final HTML bundle that should be uploaded to your platform.
1091
+ */
1092
+ declare type EmailOutputFile = BaseOutputFile;
1093
+
1094
+ /**
1095
+ * @beta
1096
+ * Email preview in various states.
1097
+ *
1098
+ * Display a loading state until the preview transitions to `"ready"` or `"error"`.
1099
+ */
1100
+ declare type EmailPreview = EmailPreviewLoading | EmailPreviewReady | EmailPreviewError;
1101
+
1102
+ /**
1103
+ * @beta
1104
+ * Email preview in an error state.
1105
+ *
1106
+ * Display an error state to the user.
1107
+ */
1108
+ declare interface EmailPreviewError extends BasePreview {
1109
+ kind: 'email';
1110
+ status: 'error';
1111
+ message: string;
1112
+ }
1113
+
1114
+ /**
1115
+ * @beta
1116
+ * Email preview in a loading state.
1117
+ *
1118
+ * Display a loading spinner until the preview transitions to `"ready"` or `"error"`.
1119
+ */
1120
+ declare interface EmailPreviewLoading extends BasePreview {
1121
+ kind: 'email';
1122
+ status: 'loading';
1123
+ }
1124
+
1125
+ /**
1126
+ * @beta
1127
+ * Email preview in a ready state.
1128
+ *
1129
+ * Display the email preview.
1130
+ */
1131
+ declare interface EmailPreviewReady extends BasePreview {
1132
+ kind: 'email';
1133
+ status: 'ready';
1134
+ /**
1135
+ * URL to the single html file that represents the email.
1136
+ */
1137
+ url: string;
1138
+ }
1139
+
1140
+ /**
1141
+ * Email preview stub used before beta preview type is fully supported.
1142
+ */
1143
+ declare interface EmailPreviewStub extends BasePreview {
1144
+ kind: 'email';
1145
+ }
1146
+
1147
+ /**
1148
+ * @beta
1149
+ * Email file requirements for a media slot, currently only supports HTML bundle format.
1150
+ *
1151
+ *
1152
+ * @example Email bundle requirements
1153
+ * ```ts
1154
+ * const emailReq: EmailRequirement = {
1155
+ * format: 'html_bundle',
1156
+ * };
1157
+ * ```
1158
+ */
1159
+ declare interface EmailRequirement extends BaseFileRequirement {
1160
+ format: 'html_bundle';
1161
+ }
1162
+
1163
+ /**
1164
+ * @public
1165
+ *
1166
+ * The cause of an error
1167
+ */
1168
+ declare type ErrorCause = 'invalid_selection' | 'invalid_format';
1169
+
1170
+ /**
1171
+ * @public
1172
+ * Exact value range constraint.
1173
+ * @example Exact value range
1174
+ * ```ts
1175
+ * const exactValue: ValueRange = { exact: 1 }; // Must be exactly 1
1176
+ * ```
1177
+ */
1178
+ declare type ExactValueRange = {
1179
+ exact: number;
1180
+ };
1181
+
1182
+ /**
1183
+ * @public
1184
+ * Successful result from `getDataTable` action.
1185
+ */
1186
+ declare type GetDataTableCompleted = {
1187
+ /**
1188
+ * Indicates the operation completed successfully
1189
+ */
1190
+ status: 'completed';
1191
+ /**
1192
+ * The fetched data formatted as a data table.
1193
+ */
1194
+ dataTable: DataTable;
1195
+ /**
1196
+ * Optional metadata providing additional context about the data.
1197
+ */
1198
+ metadata?: DataTableMetadata;
1199
+ };
1200
+
1201
+ /**
1202
+ * @public
1203
+ * Error results that can be returned from `getDataTable` method.
1204
+ */
1205
+ declare type GetDataTableError = OutdatedSourceRefError | RemoteRequestFailedError | AppError;
1206
+
1207
+ /**
1208
+ * @public
1209
+ * Parameters for the getDataTable action.
1210
+ */
1211
+ declare type GetDataTableRequest = {
1212
+ /**
1213
+ * Reference to the data source to fetch.
1214
+ *
1215
+ * This contains the information needed to identify and retrieve the specific data
1216
+ * that was previously selected by the user.
1217
+ *
1218
+ * Use this to query your external data service.
1219
+ */
1220
+ dataSourceRef: DataSourceRef;
1221
+ /**
1222
+ * Maximum row and column limits for the imported data.
1223
+ *
1224
+ * Your app must ensure the returned data does not exceed these limits.
1225
+ *
1226
+ * If the requested data would exceed these limits, either:
1227
+ *
1228
+ * - Truncate the data to fit within limits, or
1229
+ * - Return a 'data_table_limit_exceeded' error
1230
+ */
1231
+ limit: DataTableLimit;
1232
+ /**
1233
+ * Standard DOM AbortSignal for cancellation support.
1234
+ *
1235
+ * Your app should monitor this signal and abort any ongoing operations if it becomes aborted.
1236
+ */
1237
+ signal: AbortSignal;
1238
+ };
1239
+
1240
+ /**
1241
+ * @public
1242
+ * Result returned from the `getDataTable` action.
1243
+ */
1244
+ declare type GetDataTableResponse = GetDataTableCompleted | GetDataTableError;
1245
+
1246
+ /**
1247
+ * @public
1248
+ * Successful response from getting publish configuration.
1249
+ */
1250
+ declare type GetPublishConfigurationCompleted = {
1251
+ status: 'completed';
1252
+ /**
1253
+ * Array of available output types for your platform.
1254
+ *
1255
+ * Define different output types for various content formats that
1256
+ * your platform supports (e.g., posts, stories, videos).
1257
+ */
1258
+ outputTypes: OutputType[];
1259
+ };
1260
+
1261
+ /**
1262
+ * @public
1263
+ * {@link GetPublishConfigurationError} error indicating a custom error occurred.
1264
+ */
1265
+ declare type GetPublishConfigurationError = AppError_2;
1266
+
1267
+ /**
1268
+ * @public
1269
+ * Response from getting publish configuration.
1270
+ */
1271
+ declare type GetPublishConfigurationResponse = GetPublishConfigurationCompleted | GetPublishConfigurationError;
1272
+
1273
+ /**
1274
+ * @public
1275
+ * The MIME type of an image file that's supported by Canva's backend.
1276
+ */
1277
+ declare type ImageMimeType = 'image/jpeg' | 'image/heic' | 'image/png' | 'image/svg+xml' | 'image/webp' | 'image/tiff';
1278
+
1279
+ /**
1280
+ * @public
1281
+ * Exported image file ready for publishing.
1282
+ */
1283
+ declare interface ImageOutputFile extends BaseOutputFile {
1284
+ /**
1285
+ * Width of the image in pixels.
1286
+ */
1287
+ widthPx: number;
1288
+ /**
1289
+ * Height of the image in pixels.
1290
+ */
1291
+ heightPx: number;
1292
+ }
1293
+
1294
+ /**
1295
+ * @public
1296
+ * Image preview in various states.
1297
+ */
1298
+ declare type ImagePreview = ImagePreviewLoading | ImagePreviewReady | ImagePreviewError;
1299
+
1300
+ /**
1301
+ * @public
1302
+ * Image preview that failed to generate.
1303
+ *
1304
+ * Display an error state to the user.
1305
+ */
1306
+ declare interface ImagePreviewError extends SizedPreview {
1307
+ kind: 'image';
1308
+ status: 'error';
1309
+
1310
+ /**
1311
+ * The error message to display to the user.
1312
+ */
1313
+ message: string;
1314
+ }
1315
+
1316
+ /**
1317
+ * @public
1318
+ * Image preview that is currently being generated.
1319
+ *
1320
+ * Display a loading state until the preview transitions to `"ready"` or `"error"`.
1321
+ */
1322
+ declare interface ImagePreviewLoading extends SizedPreview {
1323
+ kind: 'image';
1324
+ status: 'loading';
1325
+ }
1326
+
1327
+ /**
1328
+ * @public
1329
+ * Image preview that is ready to display.
1330
+ *
1331
+ * Contains the URL to the preview image.
1332
+ */
1333
+ declare interface ImagePreviewReady extends SizedPreview {
1334
+ kind: 'image';
1335
+ status: 'ready';
1336
+ /**
1337
+ * Image format of the preview.
1338
+ */
1339
+ format: 'png' | 'jpg';
1340
+ /**
1341
+ * URL to the preview image.
1342
+ *
1343
+ * Use this URL to display the preview to users.
1344
+ */
1345
+ url: string;
1346
+ }
1347
+
1348
+ /**
1349
+ * @public
1350
+ * A unique identifier that points to an image asset in Canva's backend.
1351
+ */
1352
+ declare type ImageRef = string & {
1353
+ __imageRef: never;
1354
+ };
1355
+
1356
+ /**
1357
+ * @public
1358
+ * Image file requirements for a media slot.
1359
+ *
1360
+ * Specifies format, aspect ratio, and size constraints for images.
1361
+ *
1362
+ * @example Image requirements for social media post
1363
+ * ```ts
1364
+ * const imageReq: ImageRequirement = {
1365
+ * format: 'jpg',
1366
+ * aspectRatio: { min: 0.8, max: 1.91 },
1367
+ * };
1368
+ * ```
1369
+ */
1370
+ declare interface ImageRequirement extends BaseFileRequirement {
1371
+ /**
1372
+ * Supported image format.
1373
+ */
1374
+ format: 'png' | 'jpg';
1375
+ /**
1376
+ * Aspect ratio constraint (width / height).
1377
+ *
1378
+ * Examples:
1379
+ * - `{ exact: 16/9 }`: Widescreen (16:9)
1380
+ * - `{ min: 0.8, max: 1.91 }`: Instagram range
1381
+ */
1382
+ aspectRatio?: ValueRange;
1383
+ }
1384
+
1385
+ /**
1386
+ * @public
1387
+ * Options for uploading an image asset to the user's private media library.
1388
+ */
1389
+ declare type ImageUploadOptions = {
1390
+ /**
1391
+ * The type of asset.
1392
+ */
1393
+ type: 'image';
1394
+ /**
1395
+ * A human-readable name for the image asset.
1396
+ *
1397
+ * @remarks
1398
+ * This name is displayed in the user's media library and helps users identify
1399
+ * and find the asset later. If not provided, Canva will generate a name based
1400
+ * on the asset's URL or a unique identifier.
1401
+ *
1402
+ * Requirements:
1403
+ * - Minimum length: 1 character (empty strings are not allowed)
1404
+ * - Maximum length: 255 characters
1405
+ */
1406
+ name?: string;
1407
+ /**
1408
+ * The ref of the original asset from which this new asset was derived.
1409
+ *
1410
+ * @remarks
1411
+ * For example, if an app applies an effect to an image, `parentRef` should contain the ref of the original image.
1412
+ */
1413
+ parentRef?: ImageRef;
1414
+ /**
1415
+ * The URL of the image file to upload.
1416
+ * This can be an external URL or a data URL.
1417
+ *
1418
+ * @remarks
1419
+ * Requirements for external URLs:
1420
+ *
1421
+ * - Must use HTTPS
1422
+ * - Must return a `200` status code
1423
+ * - `Content-Type` must match the file's MIME type
1424
+ * - Must be publicly accessible (i.e. not a localhost URL)
1425
+ * - Must not redirect
1426
+ * - Must not contain an IP address
1427
+ * - Maximum length: 4096 characters
1428
+ * - Must not contain whitespace
1429
+ * - Must not contain these characters: `>`, `<`, `{`, `}`, `^`, backticks
1430
+ * - Maximum file size: 50MB
1431
+ *
1432
+ * Requirements for data URLs:
1433
+ *
1434
+ * - Must include `;base64` for base64-encoded data
1435
+ * - Maximum size: 10MB (10 × 1024 × 1024 characters)
1436
+ *
1437
+ * Requirements for SVGs:
1438
+ *
1439
+ * - Disallowed elements:
1440
+ * - `a`
1441
+ * - `altglyph`
1442
+ * - `altglyphdef`
1443
+ * - `altglyphitem`
1444
+ * - `animate`
1445
+ * - `animatemotion`
1446
+ * - `animatetransform`
1447
+ * - `cursor`
1448
+ * - `discard`
1449
+ * - `font`
1450
+ * - `font-face`
1451
+ * - `font-face-format`
1452
+ * - `font-face-name`
1453
+ * - `font-face-src`
1454
+ * - `font-face-uri`
1455
+ * - `foreignobject`
1456
+ * - `glyph`
1457
+ * - `glyphref`
1458
+ * - `missing-glyph`
1459
+ * - `mpath`
1460
+ * - `script`
1461
+ * - `set`
1462
+ * - `switch`
1463
+ * - `tref`
1464
+ * - Disallowed attributes:
1465
+ * - `crossorigin`
1466
+ * - `lang`
1467
+ * - `media`
1468
+ * - `onload`
1469
+ * - `ping`
1470
+ * - `referrerpolicy`
1471
+ * - `rel`
1472
+ * - `rendering-intent`
1473
+ * - `requiredextensions`
1474
+ * - `requiredfeatures`
1475
+ * - `systemlanguage`
1476
+ * - `tabindex`
1477
+ * - `transform-origin`
1478
+ * - `unicode`
1479
+ * - `vector-effect`
1480
+ * - The `href` attribute of an `image` element only supports data URLs for PNG and JPEG images.
1481
+ * - The URL in the `href` attribute must not point to a location outside of the SVG.
1482
+ * - The `style` attribute must not use the `mix-blend-mode` property.
1483
+ */
1484
+ url: string;
1485
+ /**
1486
+ * The MIME type of the image file.
1487
+ */
1488
+ mimeType: ImageMimeType;
1489
+ /**
1490
+ * The URL of a thumbnail image to display while the image is queued for upload.
1491
+ * This can be an external URL or a data URL.
1492
+ *
1493
+ * @remarks
1494
+ * Requirements for external URLs:
1495
+ *
1496
+ * - Must use HTTPS
1497
+ * - Must support [Cross-Origin Resource Sharing](https://www.canva.dev/docs/apps/cross-origin-resource-sharing/)
1498
+ * - Must be a PNG, JPEG, or SVG file
1499
+ * - Maximum length: 4096 characters
1500
+ *
1501
+ * Requirements for data URLs:
1502
+ *
1503
+ * - Must include `;base64` for base64-encoded data
1504
+ * - Maximum size: 10MB (10 × 1024 × 1024 characters)
1505
+ */
1506
+ thumbnailUrl: string;
1507
+ /**
1508
+ * A disclosure identifying if the app generated this image using AI
1509
+ *
1510
+ * @remarks
1511
+ * Helps users make informed decisions about the content they interact with.
1512
+ * See {@link AiDisclosure} for the full definition.
1513
+ *
1514
+ * **App Generated**
1515
+ *
1516
+ * 'app_generated' indicates when the app creates or significantly alters an asset using AI. Includes when
1517
+ * the app requests a third-party service to take similar action on an image using AI.
1518
+ *
1519
+ * Required for the following cases (this list is not exhaustive):
1520
+ * | Case | Reason |
1521
+ * | -- | -- |
1522
+ * | AI generates a new image from scratch | Creates new creative content |
1523
+ * | AI changes the style of the image e.g. makes it cartoon | Significantly alters the style |
1524
+ * | AI removes an object and replaces it with new content | Creates new creative content |
1525
+ * | AI changes the facial expression of a person in an image | Can alter content's original meaning |
1526
+ * | AI composites multiple images together | Significantly alters context |
1527
+ * | AI expands an image by generating new content to fill the edges | Creates new creative content |
1528
+ * | AI replaces background by generating new content | Creates new creative content |
1529
+ *
1530
+ * **None**
1531
+ *
1532
+ * 'none' indicates when the app doesn't create or significantly alter an asset using AI, or as a part of a request
1533
+ * to third-party hosted content.
1534
+ *
1535
+ * Required for the following cases (this list is not exhaustive):
1536
+ * | Case | Reason |
1537
+ * | -- | -- |
1538
+ * | Asset comes from an asset library | Didn't generate the asset itself |
1539
+ * | AI corrects red eyes | A minor correction |
1540
+ * | AI removes background without replacement | Doesn't change original meaning by itself |
1541
+ * | AI changes the color of an object in an image | Doesn't change original meaning by itself |
1542
+ * | AI detects image defects and suggests manual fixes | Didn't change the asset itself |
1543
+ * | AI adjusts brightness and contrast on an image | Doesn't change original meaning by itself |
1544
+ * | AI upscales an image | Doesn't change original meaning by itself |
1545
+ */
1546
+ aiDisclosure: AiDisclosure;
1547
+
1548
+ } & AllOrNone<Dimensions>;
1549
+
1550
+ /**
1551
+ * @public
1552
+ * Information explaining why the data selection UI was launched.
1553
+ */
1554
+ declare type InvocationContext = DataSelectionInvocationContext | OutdatedSourceRefInvocationContext | AppErrorInvocationContext;
1555
+
1556
+ /**
1557
+ * @public
1558
+ * Maximum value range constraint.
1559
+ * @example Maximum value range
1560
+ * ```ts
1561
+ * const maxValue: ValueRange = { max: 10 }; // At most 10
1562
+ * ```
1563
+ */
1564
+ declare type MaxValueRange = {
1565
+ max: number;
1566
+ };
1567
+
1568
+ /**
1569
+ * @public
1570
+ * Cell containing a media collection (images) value.
1571
+ *
1572
+ * @example Creating a media cell with an image
1573
+ * ```ts
1574
+ * import type { MediaCollectionDataTableCell } from '@canva/intents/data';
1575
+ *
1576
+ * const mediaCell: MediaCollectionDataTableCell = {
1577
+ * type: 'media',
1578
+ * value: [{
1579
+ * type: 'image_upload',
1580
+ * url: 'https://www.canva.dev/example-assets/image-import/image.jpg',
1581
+ * mimeType: 'image/jpeg',
1582
+ * thumbnailUrl: 'https://www.canva.dev/example-assets/image-import/thumbnail.jpg',
1583
+ * aiDisclosure: 'none'
1584
+ * }]
1585
+ * };
1586
+ * ```
1587
+ *
1588
+ * @example Creating an empty media cell
1589
+ * ```ts
1590
+ * import type { MediaCollectionDataTableCell } from '@canva/intents/data';
1591
+ *
1592
+ * const emptyMediaCell: MediaCollectionDataTableCell = {
1593
+ * type: 'media',
1594
+ * value: []
1595
+ * };
1596
+ * ```
1597
+ */
1598
+ declare type MediaCollectionDataTableCell = {
1599
+ /**
1600
+ * Indicates this cell contains a media collection.
1601
+ */
1602
+ type: 'media';
1603
+ /**
1604
+ * Media collection values.
1605
+ *
1606
+ * Use empty array for an empty cell.
1607
+ */
1608
+ value: (DataTableImageUpload | DataTableVideoUpload)[];
1609
+ };
1610
+
1611
+ /**
1612
+ * @public
1613
+ * Configuration for a media slot within an output type.
1614
+ *
1615
+ * Defines what type of media is accepted, requirements, and constraints.
1616
+ *
1617
+ * @example Image slot with aspect ratio requirements
1618
+ * ```ts
1619
+ * const thumbnailSlot: MediaSlot = {
1620
+ * id: 'thumbnail',
1621
+ * displayName: 'Video Thumbnail',
1622
+ * fileCount: { exact: 1 },
1623
+ * accepts: {
1624
+ * image: {
1625
+ * format: 'jpg',
1626
+ * aspectRatio: { exact: 16/9 },
1627
+ * }
1628
+ * }
1629
+ * };
1630
+ * ```
1631
+ */
1632
+ declare type MediaSlot = {
1633
+ /**
1634
+ * Unique identifier for this media slot within the output type.
1635
+ */
1636
+ id: string;
1637
+ /**
1638
+ * User-facing name for this media slot.
1639
+ *
1640
+ * Examples: `"Post Image"`, `"Video Thumbnail"`, `"Main Video"`.
1641
+ */
1642
+ displayName: string;
1643
+ /**
1644
+ * Number of files accepted in this slot.
1645
+ *
1646
+ * Use this to specify single or multiple file requirements.
1647
+ * Examples:
1648
+ * - `{ exact: 1 }`: Exactly one file
1649
+ * - `{ min: 1, max: 10 }`: Between 1 and 10 files
1650
+ * - undefined: Any number of files
1651
+ */
1652
+ fileCount?: ValueRange;
1653
+ /**
1654
+ * File type requirements for this slot.
1655
+ *
1656
+ * Note the following behavior:
1657
+ *
1658
+ * - Provide at least one of `image` or `video`
1659
+ * - If both are provided, files for this slot may be either images or videos; each file
1660
+ * must satisfy the corresponding requirement for its media type
1661
+ * - To restrict the slot to a single media type, provide only that requirement
1662
+ * - `fileCount` applies across all files accepted by the slot regardless of media type
1663
+ * - Document output types will show image previews (PNG thumbnail) in preview UI
1664
+ */
1665
+ accepts: {
1666
+ image?: ImageRequirement;
1667
+ video?: VideoRequirement;
1668
+ document?: DocumentRequirement;
1669
+ /**
1670
+ * @beta
1671
+ * Email output types will show a single html file (canva hosted assets) preview in preview UI
1672
+ */
1673
+ email?: EmailRequirement;
1674
+ };
1675
+ };
1676
+
1677
+ /**
1678
+ * @public
1679
+ * Minimum and maximum value range constraint.
1680
+ * Ranges are inclusive `(min ≤ value ≤ max)`.
1681
+ * @example Minimum and maximum value range
1682
+ * ```ts
1683
+ * const minMaxValue: ValueRange = { min: 1, max: 10 }; // Between 1 and 10
1684
+ * ```
1685
+ */
1686
+ declare type MinMaxValueRange = {
1687
+ min: number;
1688
+ max: number;
1689
+ };
1690
+
1691
+ /**
1692
+ * @public
1693
+ * Minimum value range constraint.
1694
+ * @example Minimum value range
1695
+ * ```ts
1696
+ * const minValue: ValueRange = { min: 3 }; // At least 3
1697
+ * ```
1698
+ */
1699
+ declare type MinValueRange = {
1700
+ min: number;
1701
+ };
1702
+
1703
+ declare type Never<T> = {
1704
+ [key in keyof T]?: never;
1705
+ };
1706
+
1707
+ /**
1708
+ * @public
1709
+ * Formatting metadata for number cells.
1710
+ *
1711
+ * @example Formatting as currency
1712
+ * ```ts
1713
+ * import type { NumberDataTableCell } from '@canva/intents/data';
1714
+ *
1715
+ * const currencyCell: NumberDataTableCell = {
1716
+ * type: 'number',
1717
+ * value: 1234.57,
1718
+ * metadata: { formatting: '[$$]#,##0.00' }
1719
+ * };
1720
+ * ```
1721
+ *
1722
+ * @example Formatting as a percentage
1723
+ * ```ts
1724
+ * import type { NumberDataTableCell } from '@canva/intents/data';
1725
+ *
1726
+ * const percentCell: NumberDataTableCell = {
1727
+ * type: 'number',
1728
+ * value: 0.1234,
1729
+ * metadata: { formatting: '0.00%' }
1730
+ * };
1731
+ * ```
1732
+ *
1733
+ * @example Applying a thousands separator
1734
+ * ```ts
1735
+ * import type { NumberDataTableCell } from '@canva/intents/data';
1736
+ *
1737
+ * const largeNumberCell: NumberDataTableCell = {
1738
+ * type: 'number',
1739
+ * value: 1234567.89234,
1740
+ * metadata: { formatting: '#,##0.00' }
1741
+ * };
1742
+ * ```
1743
+ */
1744
+ declare type NumberCellMetadata = {
1745
+ /**
1746
+ * Formatting pattern using Office Open XML Format.
1747
+ *
1748
+ * These patterns control how numbers are displayed to users,
1749
+ * including currency symbols, decimal places, and separators.
1750
+ */
1751
+ formatting?: string;
1752
+ };
1753
+
1754
+ /**
1755
+ * @public
1756
+ * Cell containing a numeric value.
1757
+ *
1758
+ * @example Creating a number cell
1759
+ * ```ts
1760
+ * import type { NumberCellMetadata, NumberDataTableCell } from '@canva/intents/data';
1761
+ *
1762
+ * const priceCell: NumberDataTableCell = {
1763
+ * type: 'number',
1764
+ * value: 29.99,
1765
+ * metadata: { formatting: '[$$]#,##0.00' }
1766
+ * };
1767
+ *
1768
+ * const quantityCell: NumberDataTableCell = {
1769
+ * type: 'number',
1770
+ * value: 150
1771
+ * };
1772
+ *
1773
+ * const emptyNumberCell: NumberDataTableCell = {
1774
+ * type: 'number',
1775
+ * value: undefined
1776
+ * };
1777
+ * ```
1778
+ */
1779
+ declare type NumberDataTableCell = {
1780
+ /**
1781
+ * Indicates this cell contains a number value.
1782
+ */
1783
+ type: 'number';
1784
+ /**
1785
+ * Numeric value within safe integer range.
1786
+ *
1787
+ * Valid range: `Number.MIN_SAFE_INTEGER` to `Number.MAX_SAFE_INTEGER`
1788
+ *
1789
+ * Invalid values:
1790
+ *
1791
+ * - Infinity or -Infinity
1792
+ * - NaN
1793
+ * - Negative zero (-0)
1794
+ * - Denormalized numbers
1795
+ *
1796
+ * Use `undefined` for an empty cell.
1797
+ */
1798
+ value: number | undefined;
1799
+ /**
1800
+ * Optional formatting information for displaying the number.
1801
+ *
1802
+ * @example Applying display formatting to a number
1803
+ * ```ts
1804
+ * import type { NumberCellMetadata } from '@canva/intents/data';
1805
+ *
1806
+ * const currencyFormatting: NumberCellMetadata = { formatting: '[$USD]#,##0.00' };
1807
+ * const percentageFormatting: NumberCellMetadata = { formatting: '0.00%' };
1808
+ * ```
1809
+ */
1810
+ metadata?: NumberCellMetadata;
1811
+ };
1812
+
1813
+ /** @public */
1814
+ declare type OnContextChange = (context: SettingsUiContext) => void;
1815
+
1816
+ /**
1817
+ * @public
1818
+ * {@link GetDataTableError} indicating the data source reference is no longer valid.
1819
+ * This will trigger a re-selection flow for the user.
1820
+ */
1821
+ declare type OutdatedSourceRefError = {
1822
+ /**
1823
+ * The data source reference is no longer valid.
1824
+ *
1825
+ * Return this error when the DataSourceRef cannot be used to retrieve data,
1826
+ * for example:
1827
+ *
1828
+ * - The referenced dataset has been deleted
1829
+ * - Access permissions have changed
1830
+ * - The structure of the data has fundamentally changed
1831
+ *
1832
+ * This will trigger a re-selection flow, allowing the user to choose a new
1833
+ * data source.
1834
+ */
1835
+ status: 'outdated_source_ref';
1836
+ };
1837
+
1838
+ /**
1839
+ * @public
1840
+ * {@link InvocationContext} indicating an error occurred because the previously selected data source reference is no longer valid.
1841
+ * Triggered when getDataTable returned 'outdated_source_ref' during data refresh.
1842
+ * UI should guide the user to reselect or reconfigure their data.
1843
+ */
1844
+ declare type OutdatedSourceRefInvocationContext = {
1845
+ /**
1846
+ * Previously selected data source reference is no longer valid.
1847
+ *
1848
+ * This occurs when `getDataTable` returned 'outdated_source_ref' during a
1849
+ * refresh attempt. Your UI should guide the user to select a new data source
1850
+ * or update their selection.
1851
+ *
1852
+ * The outdated reference is provided to help you suggest an appropriate replacement.
1853
+ */
1854
+ reason: 'outdated_source_ref';
1855
+ /**
1856
+ * The outdated data source reference that caused the error during refresh.
1857
+ */
1858
+ dataSourceRef?: DataSourceRef;
1859
+ };
1860
+
1861
+ /**
1862
+ * @public
1863
+ * Exported file ready for publishing.
1864
+ */
1865
+ declare type OutputFile = ImageOutputFile | VideoOutputFile | DocumentOutputFile;
1866
+
1867
+ /**
1868
+ * @public
1869
+ * Production-ready exported files for a specific media slot.
1870
+ *
1871
+ * These are the final files that should be uploaded to your platform.
1872
+ */
1873
+ declare type OutputMedia = {
1874
+ /**
1875
+ * ID of the media slot these files belong to.
1876
+ *
1877
+ * Matches a media slot ID from your output type definition.
1878
+ */
1879
+ mediaSlotId: string;
1880
+ /**
1881
+ * Array of exported files for this media slot.
1882
+ *
1883
+ * Files match the requirements specified in your media slot configuration.
1884
+ */
1885
+ files: OutputFile[];
1886
+ };
1887
+
1888
+ /**
1889
+ * @public
1890
+ * Metadata about a specific page in the exported content.
1891
+ */
1892
+ declare type OutputPageMetadata = {
1893
+ /**
1894
+ * The unique identifier for the page.
1895
+ */
1896
+ pageId: string | undefined;
1897
+ /**
1898
+ * The position of the page within the design, starting from 1 for the first page.
1899
+ */
1900
+ pageNumber: number;
1901
+ };
1902
+
1903
+ /**
1904
+ * @public
1905
+ * Configuration for an output type.
1906
+ *
1907
+ * Defines a specific publishing format your platform supports,
1908
+ * including what media is required and accepted file types.
1909
+ *
1910
+ * @example Defining an Instagram post output type
1911
+ * ```ts
1912
+ * const instagramPost: OutputType = {
1913
+ * id: 'instagram_post',
1914
+ * displayName: 'Instagram Post',
1915
+ * mediaSlots: [
1916
+ * {
1917
+ * id: 'main_image',
1918
+ * displayName: 'Post Image',
1919
+ * fileCount: { min: 1, max: 10 },
1920
+ * accepts: {
1921
+ * image: {
1922
+ * format: 'jpg',
1923
+ * aspectRatio: { min: 0.8, max: 1.91 },
1924
+ * }
1925
+ * }
1926
+ * }
1927
+ * ]
1928
+ * };
1929
+ * ```
1930
+ */
1931
+ declare type OutputType = {
1932
+ /**
1933
+ * Unique identifier for this output type.
1934
+ *
1935
+ * Use descriptive IDs like `"instagram_post"` or `"youtube_video"`.
1936
+ */
1937
+ id: string;
1938
+ /**
1939
+ * User-facing name for this output type.
1940
+ *
1941
+ * This is displayed to users when selecting where to publish.
1942
+ * Examples: `"Instagram Post"`, `"YouTube Video"`, `"Twitter Post"`.
1943
+ */
1944
+ displayName: string;
1945
+ /**
1946
+ * Array of media slots defining what content is needed.
1947
+ *
1948
+ * Each slot represents a piece of media required for publishing,
1949
+ * such as a main image, thumbnail, or video.
1950
+ */
1951
+ mediaSlots: MediaSlot[];
1952
+ };
1953
+
1954
+ /**
1955
+ * @public
1956
+ * Action to be taken after publishing completes successfully.
1957
+ */
1958
+ declare type PostPublishAction = PostPublishActionRedirect;
1959
+
1960
+ /**
1961
+ * @public
1962
+ * Redirect action to navigate the user to a URL after publishing.
1963
+ *
1964
+ * @example Redirecting to content editor
1965
+ * ```ts
1966
+ * const postPublishAction: PostPublishActionRedirect = {
1967
+ * type: 'redirect',
1968
+ * url: 'https://example.com/posts/12345/edit'
1969
+ * };
1970
+ * ```
1971
+ */
1972
+ declare type PostPublishActionRedirect = {
1973
+ type: 'redirect';
1974
+ /**
1975
+ * The URL to redirect the user to after publishing.
1976
+ */
1977
+ url: string;
1978
+ };
1979
+
1980
+ /**
1981
+ * @public
1982
+ *
1983
+ * Prepares a {@link ContentPublisherIntent|Content Publisher Intent}.
1984
+ *
1985
+ * @example
1986
+ * ```tsx
1987
+ * import { prepareContentPublisher } from "@canva/intents/content";
1988
+ *
1989
+ * prepareContentPublisher({
1990
+ * getPublishConfiguration: async (params) => {
1991
+ * // Implement the logic to get the publish configuration
1992
+ * },
1993
+ * renderSettingsUi: (params) => {
1994
+ * // Implement the UI for settings view
1995
+ * },
1996
+ * renderPreviewUi: (params) => {
1997
+ * // Implement the UI for preview view
1998
+ * },
1999
+ * publishContent: async (params) => {
2000
+ * // Implement the logic to publish the content
2001
+ * },
2002
+ * });
2003
+ * ```
2004
+ */
2005
+ declare const prepareContentPublisher: (implementation: ContentPublisherIntent) => void;
2006
+
2007
+ /**
2008
+ * @public
2009
+ *
2010
+ * Prepares a {@link DataConnectorIntent|DataConnector Intent}.
2011
+ *
2012
+ * @example
2013
+ * ```tsx
2014
+ * import { prepareDataConnector } from "@canva/intents/data";
2015
+ *
2016
+ * prepareDataConnector({
2017
+ * getDataTable: async (params) => {
2018
+ * // Implement the logic to fetch the data table
2019
+ * },
2020
+ * renderSelectionUi: (params) => {
2021
+ * // Implement the UI for the data table selection
2022
+ * },
2023
+ * });
2024
+ * ```
2025
+ */
2026
+ declare const prepareDataConnector: (implementation: DataConnectorIntent) => void;
2027
+
2028
+ /**
2029
+ * @public
2030
+ *
2031
+ * Prepares a {@link DesignEditorIntent|DesignEditor Intent}.
2032
+ *
2033
+ * @example
2034
+ * ```tsx
2035
+ * import { prepareDesignEditor } from '@canva/intents/design';
2036
+ *
2037
+ * prepareDesignEditor({
2038
+ * render: async () => {
2039
+ * // TODO: Implement the logic to render your app's UI
2040
+ * },
2041
+ * });
2042
+ * ```
2043
+ */
2044
+ declare const prepareDesignEditor: (implementation: DesignEditorIntent) => void;
2045
+
2046
+ /**
2047
+ * @public
2048
+ * Preview item for an image or video.
2049
+ *
2050
+ * Check the `kind` and `status` properties to determine the type and state.
2051
+ */
2052
+ declare type Preview = ImagePreview | VideoPreview | DocumentPreview | EmailPreviewStub;
2053
+
2054
+ /**
2055
+ * @public
2056
+ * Type of preview media.
2057
+ */
2058
+ declare type PreviewKind = 'image' | 'video' | 'document' | 'email';
2059
+
2060
+ /**
2061
+ * @public
2062
+ * Preview media for a specific media slot.
2063
+ *
2064
+ * Contains preview URLs and metadata for images or videos in the design.
2065
+ */
2066
+ declare type PreviewMedia = {
2067
+ /**
2068
+ * ID of the media slot this preview belongs to.
2069
+ *
2070
+ * Matches a media slot ID from your output type definition.
2071
+ */
2072
+ mediaSlotId: string;
2073
+ /**
2074
+ * Array of preview items for this media slot.
2075
+ *
2076
+ * May contain multiple previews if the media slot accepts multiple files.
2077
+ */
2078
+ previews: Preview[];
2079
+ };
2080
+
2081
+ /**
2082
+ * @public
2083
+ * State of a preview item.
2084
+ */
2085
+ declare type PreviewStatus = 'loading' | 'thumbnail' | 'upgrading' | 'ready' | 'error';
2086
+
2087
+ /**
2088
+ * @public
2089
+ * Successful response from publishing a content.
2090
+ *
2091
+ * @example Basic successful publish
2092
+ * ```ts
2093
+ * return {
2094
+ * status: 'completed',
2095
+ * externalId: 'post_12345',
2096
+ * externalUrl: 'https://example.com/posts/12345'
2097
+ * };
2098
+ * ```
2099
+ *
2100
+ * @example Successful publish with redirect
2101
+ * ```ts
2102
+ * return {
2103
+ * status: 'completed',
2104
+ * externalId: 'video_67890',
2105
+ * externalUrl: 'https://example.com/videos/67890',
2106
+ * postPublishAction: {
2107
+ * type: 'redirect',
2108
+ * url: 'https://example.com/videos/67890/edit'
2109
+ * }
2110
+ * };
2111
+ * ```
2112
+ */
2113
+ declare type PublishContentCompleted = {
2114
+ status: 'completed';
2115
+ /**
2116
+ * Unique identifier returned from your external platform. You can use this for:
2117
+ *
2118
+ * - Tracking published content
2119
+ * - Fetching insights data for the published content
2120
+ * - Linking back to the content in future operations
2121
+ */
2122
+ externalId?: string;
2123
+ /**
2124
+ * Direct URL to the published content on your platform.
2125
+ *
2126
+ * Users can visit this URL to view their published content.
2127
+ * This may be displayed to users or used for sharing.
2128
+ */
2129
+ externalUrl?: string;
2130
+ /**
2131
+ * Optional action to perform after publishing completes.
2132
+ *
2133
+ * Currently supports redirecting users to a specific URL after publishing.
2134
+ */
2135
+ postPublishAction?: PostPublishAction;
2136
+ };
2137
+
2138
+ /**
2139
+ * @public
2140
+ * Error response from publishing a content.
2141
+ *
2142
+ * Return the appropriate error type based on the failure:
2143
+ *
2144
+ * - `"remote_request_failed"`: Network or API errors with your platform
2145
+ * - `"app_error"`: Custom application errors with optional message
2146
+ */
2147
+ declare type PublishContentError = RemoteRequestFailedError_2 | AppError_2;
2148
+
2149
+ /**
2150
+ * @public
2151
+ * Parameters required for publishing the content.
2152
+ * Contains all the information needed to send the content to your external platform.
2153
+ */
2154
+ declare type PublishContentRequest = {
2155
+ /**
2156
+ * Platform-specific settings reference containing user configurations.
2157
+ *
2158
+ * This is the same reference you saved via `updatePublishSettings` in the settings UI.
2159
+ * Parse this string to retrieve the user's publish settings (e.g., captions, tags, privacy).
2160
+ *
2161
+ * Maximum size: 5KB
2162
+ */
2163
+ publishRef?: string;
2164
+ /**
2165
+ * The output type selected by the user for this publish operation.
2166
+ *
2167
+ * This matches one of the output types you provided in `getPublishConfiguration`.
2168
+ */
2169
+ outputType: OutputType;
2170
+ /**
2171
+ * Production-ready exported files matching the requirements from your output type.
2172
+ *
2173
+ * These files are ready to upload to your platform and match the format, size,
2174
+ * and aspect ratio requirements specified in your media slots.
2175
+ */
2176
+ outputMedia: OutputMedia[];
2177
+ };
2178
+
2179
+ /**
2180
+ * @public
2181
+ * Response from a publish content operation.
2182
+ *
2183
+ * This can be either a successful completion or an error response.
2184
+ */
2185
+ declare type PublishContentResponse = PublishContentCompleted | PublishContentError;
2186
+
2187
+ /** @public */
2188
+ declare type PublishError = {
2189
+ appDefinedPayload?: string;
2190
+ };
2191
+
2192
+ /**
2193
+ * @public
2194
+ * Signals that the publish error was cleared.
2195
+ */
2196
+ declare type PublishErrorClearedSettingsUiContext = {
2197
+ reason: 'publish_error_cleared';
2198
+ };
2199
+
2200
+ /**
2201
+ * @public
2202
+ * Provides information about an error that occurred in publishContent.
2203
+ */
2204
+ declare type PublishErrorSettingsUiContext = {
2205
+ reason: 'publish_error';
2206
+ /**
2207
+ * The error that occurred. Undefined means no error occurred or the previous
2208
+ * error was cleared by Canva.
2209
+ */
2210
+ error: PublishError;
2211
+ };
2212
+
2213
+ /**
2214
+ * @public
2215
+ * Supported file formats for publishing.
2216
+ */
2217
+ declare type PublishFileFormat = 'png' | 'jpg' | 'mp4' | 'pdf_standard' | 'html_bundle';
2218
+
2219
+ /**
2220
+ * @beta
2221
+ * Initial payload provided from cache.
2222
+ */
2223
+ declare type PublishPreviewUiInvocationContext = {
2224
+ /**
2225
+ * Initial preview data and context provided when the preview UI is rendered.
2226
+ */
2227
+ reason: 'publish';
2228
+ /**
2229
+ * Initial preview media to display
2230
+ * This will only be used for scheduling and not caching
2231
+ */
2232
+ previewMedia?: PreviewMedia[];
2233
+ /** Information about the current output type being previewed */
2234
+ outputType?: OutputType;
2235
+ /** Current publish reference, if available */
2236
+ publishRef?: string;
2237
+ };
2238
+
2239
+ /**
2240
+ * @public
2241
+ * Validation state indicating whether publish settings are complete and valid.
2242
+ */
2243
+ declare type PublishRefValidityState = 'valid' | 'invalid_missing_required_fields' | 'invalid_authentication_required';
2244
+
2245
+ /**
2246
+ * @public
2247
+ * Configuration for publish settings.
2248
+ *
2249
+ * Contains the user's settings and their validation state. Use this to
2250
+ * control whether the publish button is enabled.
2251
+ */
2252
+ declare type PublishSettings = {
2253
+ /**
2254
+ * Serialized platform-specific settings for publishing.
2255
+ *
2256
+ * Store all information your app needs to publish the content in this string.
2257
+ * This might include:
2258
+ *
2259
+ * - Captions or descriptions
2260
+ * - Tags or hashtags
2261
+ * - Privacy settings
2262
+ * - Publishing destination (account, page, etc.)
2263
+ * - Scheduling information
2264
+ *
2265
+ * This reference will be provided to your `publishContent` method when publishing.
2266
+ *
2267
+ * Maximum size: 5KB
2268
+ *
2269
+ * @example Serializing settings
2270
+ * ```ts
2271
+ * const settings = {
2272
+ * caption: 'Check out my design!',
2273
+ * tags: ['design', 'creative'],
2274
+ * privacy: 'public'
2275
+ * };
2276
+ * const publishRef = JSON.stringify(settings);
2277
+ * ```
2278
+ */
2279
+ publishRef?: string;
2280
+ /**
2281
+ * Validation state of the publish settings.
2282
+ *
2283
+ * Controls whether the publish button is enabled:
2284
+ *
2285
+ * - `"valid"`: Settings are complete and valid, publish button is enabled
2286
+ * - `"invalid_missing_required_fields"`: Required settings are missing, publish button is disabled
2287
+ * - `"invalid_authentication_required"`: User must authenticate before publishing can proceed
2288
+ */
2289
+ validityState: PublishRefValidityState;
2290
+ };
2291
+
2292
+ /**
2293
+ * @public
2294
+ * Provides information about the current state of the settings UI to help
2295
+ * you adapt the interface based on the selected output type.
2296
+ */
2297
+ declare type PublishSettingsSettingsUiContext = {
2298
+ reason: 'publish_settings';
2299
+ /**
2300
+ * The currently selected output type.
2301
+ *
2302
+ * Use this to customize your settings UI based on the requirements
2303
+ * of different output types.
2304
+ */
2305
+ outputType: OutputType;
2306
+ };
2307
+
2308
+ /**
2309
+ * @beta
2310
+ * Initial payload provided from cache.
2311
+ */
2312
+ declare type PublishSettingsUiInvocationContext = {
2313
+ /**
2314
+ * Initial settings and context provided when the settings UI is rendered.
2315
+ */
2316
+ reason: 'publish';
2317
+ /** Current publish reference to populate the UI, if any exist */
2318
+ publishRef?: string;
2319
+ /** Information about the current output type being configured */
2320
+ outputType?: OutputType;
2321
+ };
2322
+
2323
+ /**
2324
+ * @public
2325
+ * {@link GetDataTableError} indicating failure to fetch data from the external source.
2326
+ * Typically due to network issues or API failures.
2327
+ */
2328
+ declare type RemoteRequestFailedError = {
2329
+ /**
2330
+ * Failed to fetch data from the external source.
2331
+ *
2332
+ * Return this error for network issues, API failures, or other
2333
+ * connectivity problems that prevent data retrieval.
2334
+ */
2335
+ status: 'remote_request_failed';
2336
+ };
2337
+
2338
+ /**
2339
+ * @public
2340
+ * {@link PublishContentError} indicating failure of the remote request to the external platform.
2341
+ *
2342
+ * Return this error for:
2343
+ *
2344
+ * - Network connectivity issues
2345
+ * - API endpoint failures
2346
+ * - HTTP errors from your platform
2347
+ * - Timeout errors
2348
+ *
2349
+ * @example Handling network errors
2350
+ * ```ts
2351
+ * try {
2352
+ * await uploadToExternalPlatform(file);
2353
+ * } catch (error) {
2354
+ * return { status: 'remote_request_failed' };
2355
+ * }
2356
+ * ```
2357
+ */
2358
+ declare type RemoteRequestFailedError_2 = {
2359
+ status: 'remote_request_failed';
2360
+ };
2361
+
2362
+ /**
2363
+ * @beta
2364
+ * Initial payload provided when the preview UI is rendered.
2365
+ * Contains the preview data and settings needed to initialize the preview interface.
2366
+ */
2367
+ declare type RenderPreviewUiInvocationContext = PublishPreviewUiInvocationContext;
2368
+
2369
+ /**
2370
+ * @public
2371
+ * Configuration required for rendering the preview UI.
2372
+ *
2373
+ * Provides callbacks for managing preview media and responding to preview updates.
2374
+ */
2375
+ declare type RenderPreviewUiRequest = {
2376
+ /**
2377
+ * @beta
2378
+ * The initial preview data and context provided when the preview UI is rendered.
2379
+ *
2380
+ * Contains the initial preview media, output type information, and any existing
2381
+ * publish settings needed to properly display the preview interface.
2382
+ */
2383
+ invocationContext: RenderPreviewUiInvocationContext;
2384
+ /**
2385
+ * Callback to upgrade video thumbnail previews to full video media.
2386
+ *
2387
+ * Call this function when you need full video previews instead of lightweight thumbnails.
2388
+ * This helps optimize performance by deferring full video loading until needed.
2389
+ *
2390
+ * Upgrades may complete asynchronously; listen to `registerOnPreviewChange` for updates
2391
+ * to receive the upgraded video previews.
2392
+ *
2393
+ * @param previewIds - Array of preview IDs to upgrade from thumbnail to full video
2394
+ *
2395
+ * @example Upgrading video previews on user interaction
2396
+ * ```ts
2397
+ * // When user clicks on a video thumbnail, upgrade to full video
2398
+ * if (preview.kind === 'video' && preview.status === 'thumbnail') {
2399
+ * requestPreviewUpgrade([preview.id]);
2400
+ * }
2401
+ * ```
2402
+ */
2403
+ requestPreviewUpgrade: (previewIds: string[]) => void;
2404
+ /**
2405
+ * Registers a callback to be invoked when preview data changes.
2406
+ *
2407
+ * This callback is triggered when:
2408
+ *
2409
+ * - The design content changes
2410
+ * - The output type changes
2411
+ * - Preview media is upgraded from thumbnail to full video
2412
+ * - Export settings are modified
2413
+ *
2414
+ * Use this to update your preview UI in real-time as users modify their design.
2415
+ *
2416
+ * @param callback - The callback invoked when preview data is updated
2417
+ * @returns A disposer function that cleans up the registered callback
2418
+ *
2419
+ * @example Handling preview updates
2420
+ * ```ts
2421
+ * const disposer = registerOnPreviewChange(({ previewMedia, outputType, publishRef }) => {
2422
+ * // Update your preview UI with the new preview media
2423
+ * previewMedia.forEach((media) => {
2424
+ * media.previews.forEach((preview) => {
2425
+ * if (preview.status === 'ready') {
2426
+ * displayPreview(preview);
2427
+ * }
2428
+ * });
2429
+ * });
2430
+ * });
2431
+ *
2432
+ * // Clean up when preview UI is unmounted
2433
+ * onUnmount(() => disposer());
2434
+ * ```
2435
+ */
2436
+ registerOnPreviewChange: (callback: (opts: {
2437
+ previewMedia: PreviewMedia[];
2438
+ /** The output type that the preview data is for */
2439
+ outputType: OutputType;
2440
+ /** The current publish settings reference, if available */
2441
+ publishRef?: string;
2442
+ }) => void) => Disposer;
2443
+ };
2444
+
2445
+ /**
2446
+ * @public
2447
+ * Parameters for rendering the data selection UI.
2448
+ */
2449
+ declare type RenderSelectionUiRequest = {
2450
+ /**
2451
+ * Context information about why the data selection UI is being launched.
2452
+ *
2453
+ * Use this to adapt your UI for different scenarios:
2454
+ *
2455
+ * - 'data_selection': Initial data selection or editing existing data
2456
+ * - 'outdated_source_ref': Previous reference is no longer valid, guide user to reselect
2457
+ * - 'app_error': Custom error occurred, show error message and recovery options
2458
+ *
2459
+ * When `dataSourceRef` is provided, pre-populate your UI with this selection.
2460
+ */
2461
+ invocationContext: InvocationContext;
2462
+ /**
2463
+ * Maximum allowed rows and columns for the imported data.
2464
+ *
2465
+ * Your UI should inform users of these constraints and prevent or warn about
2466
+ * selections that would exceed them. This helps users understand why certain
2467
+ * data sets might not be available for selection.
2468
+ */
2469
+ limit: DataTableLimit;
2470
+ /**
2471
+ * Callback to preview selected data before finalizing import.
2472
+ *
2473
+ * Call this function when the user selects data to:
2474
+ *
2475
+ * 1. Show a preview of the selected data to the user
2476
+ * 2. Validate that the selection meets system requirements
2477
+ *
2478
+ * Calling this function will trigger your `getDataTable` implementation.
2479
+ * Wait for the promise to resolve to determine if the selection is valid.
2480
+ *
2481
+ * @param dataSourceRef - Reference object identifying the selected data
2482
+ * @returns Promise resolving to success or an error result
2483
+ * @throws Will throw CanvaError('bad_request') if
2484
+ * 1. {@link DataSourceRef.source} exceeds 5kb.
2485
+ * 2. {@link DataSourceRef.title} exceeds 255 characters.
2486
+ * 3. {@link GetDataTableCompleted.dataTable} exceeds {@link DataTableLimit} or contains invalid data.
2487
+ */
2488
+ updateDataRef: (dataSourceRef: DataSourceRef) => Promise<UpdateDataRefResponse>;
2489
+ };
2490
+
2491
+ /**
2492
+ * @beta
2493
+ * Initial payload provided when the publish settings UI is rendered.
2494
+ * Contains the current settings state needed to initialize the settings interface.
2495
+ */
2496
+ declare type RenderSettingsUiInvocationContext = PublishSettingsUiInvocationContext;
2497
+
2498
+ /**
2499
+ * @public
2500
+ * Configuration for the publish settings UI.
2501
+ *
2502
+ * This type provides the necessary callbacks and configuration for rendering
2503
+ * a custom publish settings interface where users configure platform-specific options.
2504
+ */
2505
+ declare type RenderSettingsUiRequest = {
2506
+ /**
2507
+ * @beta
2508
+ * The initial settings and context provided when the settings UI is rendered.
2509
+ *
2510
+ * Contains any previously saved publish settings and information about the current output type being configured.
2511
+ * Use this to restore the UI to its previous state or initialise it with appropriate defaults.
2512
+ */
2513
+ invocationContext: RenderSettingsUiInvocationContext;
2514
+ /**
2515
+ * Callback to save and validate the user's publish settings.
2516
+ *
2517
+ * Call this function whenever the user modifies their settings to:
2518
+ *
2519
+ * - Save the settings for later use in `publishContent`
2520
+ * - Validate that required fields are filled
2521
+ * - Enable or disable the publish button based on validity
2522
+ *
2523
+ * Store all necessary publishing information in the `publishRef` string.
2524
+ * This will be provided to your `publishContent` method when the user publishes.
2525
+ *
2526
+ * @param settings - The new publish settings to save
2527
+ * @returns A promise that resolves when the settings are successfully saved
2528
+ * @throws Will throw `CanvaError('bad_request')` if {@link PublishSettings.publishRef} exceeds 5KB.
2529
+ *
2530
+ * @example Updating settings as user types
2531
+ * ```ts
2532
+ * // As user fills in form fields, update settings
2533
+ * function handleCaptionChange(caption: string) {
2534
+ * const settings = { caption, tags: currentTags };
2535
+ * const publishRef = JSON.stringify(settings);
2536
+ *
2537
+ * updatePublishSettings({
2538
+ * publishRef,
2539
+ * validityState: caption ? 'valid' : 'invalid_missing_required_fields'
2540
+ * });
2541
+ * }
2542
+ * ```
2543
+ */
2544
+ updatePublishSettings: (publishSettings: PublishSettings) => Promise<UpdatePublishSettingsResponse>;
2545
+
2546
+ /**
2547
+ * Registers a callback to be invoked when the settings UI context changes.
2548
+ *
2549
+ * This callback is triggered when:
2550
+ * - the user changes the output type in the publish flow.
2551
+ * - an error occurs in the publish flow.
2552
+ *
2553
+ * Use this to respond to Canva changes and update your settings UI accordingly.
2554
+ *
2555
+ * @param opts - The options for registering a callback.
2556
+ * @returns A disposer function that cleans up the registered callback.
2557
+ *
2558
+ * @example Adapting UI for different output types
2559
+ * ```ts
2560
+ * registerOnContextChange({
2561
+ * onContextChange: (ctx) => {
2562
+ * if (ctx.reason === 'publish_settings') {
2563
+ * if (ctx.outputType.id === 'instagram_post') {
2564
+ * showHashtagField();
2565
+ * }
2566
+ * }
2567
+ * if (ctx.reason === 'publish_error') {
2568
+ * setError(ctx.error);
2569
+ * }
2570
+ * }
2571
+ * });
2572
+ * ```
2573
+ */
2574
+ registerOnContextChange: (opts: {
2575
+ onContextChange: OnContextChange;
2576
+ }) => Disposer;
2577
+ };
2578
+
2579
+ /**
2580
+ * @public
2581
+ * Context information for the publish settings UI.
2582
+ */
2583
+ declare type SettingsUiContext = PublishSettingsSettingsUiContext | PublishErrorSettingsUiContext | PublishErrorClearedSettingsUiContext;
2584
+
2585
+ /**
2586
+ * @public
2587
+ * Base interface for all preview types that have a fixed width and height.
2588
+ */
2589
+ declare interface SizedPreview extends BasePreview {
2590
+ /**
2591
+ * Width of the preview in pixels.
2592
+ */
2593
+ widthPx: number;
2594
+ /**
2595
+ * Height of the preview in pixels.
2596
+ */
2597
+ heightPx: number;
2598
+ }
2599
+
2600
+ /**
2601
+ * @public
2602
+ * Cell containing a text value.
2603
+ *
2604
+ * @example Creating a string cell
2605
+ * ```ts
2606
+ * import type { StringDataTableCell } from '@canva/intents/data';
2607
+ *
2608
+ * const nameCell: StringDataTableCell = {
2609
+ * type: 'string',
2610
+ * value: 'John Doe'
2611
+ * };
2612
+ *
2613
+ * const emptyStringCell: StringDataTableCell = {
2614
+ * type: 'string',
2615
+ * value: undefined
2616
+ * };
2617
+ * ```
2618
+ */
2619
+ declare type StringDataTableCell = {
2620
+ /**
2621
+ * Indicates this cell contains a string value.
2622
+ */
2623
+ type: 'string';
2624
+ /**
2625
+ * Text content of the cell.
2626
+ *
2627
+ * Maximum length: 10,000 characters
2628
+ *
2629
+ * Use `undefined` for an empty cell.
2630
+ */
2631
+ value: string | undefined;
2632
+ };
2633
+
2634
+ /**
2635
+ * @public
2636
+ * Successful result from the {@link RenderSelectionUiRequest.updateDataRef} callback.
2637
+ */
2638
+ declare type UpdateDataRefCompleted = {
2639
+ /**
2640
+ * The data selection was successful and can be previewed.
2641
+ */
2642
+ status: 'completed';
2643
+ };
2644
+
2645
+ /**
2646
+ * @public
2647
+ * Result returned from the {@link RenderSelectionUiRequest.updateDataRef} callback.
2648
+ * Indicates whether {@link DataSourceRef} update succeeded or failed.
2649
+ */
2650
+ declare type UpdateDataRefResponse = UpdateDataRefCompleted | GetDataTableError;
2651
+
2652
+ /**
2653
+ * @public
2654
+ * Successful response from updating the publish settings.
2655
+ */
2656
+ declare type UpdatePublishSettingsCompleted = {
2657
+ status: 'completed';
2658
+ };
2659
+
2660
+ /**
2661
+ * @public
2662
+ * Response from updating the publish settings.
2663
+ */
2664
+ declare type UpdatePublishSettingsResponse = UpdatePublishSettingsCompleted;
2665
+
2666
+ /**
2667
+ * @public
2668
+ * Numeric value range constraint.
2669
+ * Used to specify requirements for aspect ratios, durations, file counts, etc.
2670
+ */
2671
+ declare type ValueRange = ExactValueRange | MinValueRange | MaxValueRange | MinMaxValueRange;
2672
+
2673
+ /**
2674
+ * @public
2675
+ * The MIME type of a video file that's supported by Canva's backend.
2676
+ *
2677
+ * @remarks
2678
+ * - GIFs are treated as videos, not images.
2679
+ * - `"application/json"` is only used for Lottie files.
2680
+ */
2681
+ declare type VideoMimeType = 'video/avi' | 'video/x-msvideo' | 'image/gif' | 'video/x-m4v' | 'video/x-matroska' | 'video/quicktime' | 'video/mp4' | 'video/mpeg' | 'video/webm' | 'application/json';
2682
+
2683
+ /**
2684
+ * @public
2685
+ * Exported video file ready for publishing.
2686
+ */
2687
+ declare interface VideoOutputFile extends BaseOutputFile {
2688
+ /**
2689
+ * Width of the video in pixels.
2690
+ */
2691
+ widthPx: number;
2692
+ /**
2693
+ * Height of the video in pixels.
2694
+ */
2695
+ heightPx: number;
2696
+ }
2697
+
2698
+ /**
2699
+ * @public
2700
+ * Video preview in various states.
2701
+ *
2702
+ * Videos transition through states: `"loading"` → `"thumbnail"` → `"upgrading"` → `"ready"`.
2703
+ * Start with thumbnails for better performance, then upgrade to full video using `requestPreviewUpgrade`.
2704
+ */
2705
+ declare type VideoPreview = VideoPreviewLoading | VideoPreviewThumbnail | VideoPreviewUpgrading | VideoPreviewReady | VideoPreviewError;
2706
+
2707
+ /**
2708
+ * @public
2709
+ * Video preview that failed to generate.
2710
+ *
2711
+ * Display an error state to the user.
2712
+ */
2713
+ declare interface VideoPreviewError extends SizedPreview {
2714
+ kind: 'video';
2715
+ status: 'error';
2716
+
2717
+ /**
2718
+ * The error message to display to the user.
2719
+ */
2720
+ message: string;
2721
+ }
2722
+
2723
+ /**
2724
+ * @public
2725
+ * Video preview that is currently being generated.
2726
+ *
2727
+ * Display a loading state until the preview transitions to `"thumbnail"` or `"error"`.
2728
+ */
2729
+ declare interface VideoPreviewLoading extends SizedPreview {
2730
+ kind: 'video';
2731
+ status: 'loading';
2732
+ /**
2733
+ * Video duration in milliseconds.
2734
+ */
2735
+ durationMs?: number;
2736
+ }
2737
+
2738
+ /**
2739
+ * @public
2740
+ * Video preview with full video ready to play.
2741
+ *
2742
+ * Contains URLs for both the video and thumbnail.
2743
+ */
2744
+ declare interface VideoPreviewReady extends SizedPreview {
2745
+ kind: 'video';
2746
+ status: 'ready';
2747
+ /**
2748
+ * Video format.
2749
+ */
2750
+ format: 'mp4';
2751
+ /**
2752
+ * URL to the full video.
2753
+ *
2754
+ * Use this URL in a video player.
2755
+ */
2756
+ url: string;
2757
+ /**
2758
+ * Format of the thumbnail image.
2759
+ */
2760
+ thumbnailFormat: 'png' | 'jpg';
2761
+ /**
2762
+ * URL to the thumbnail image.
2763
+ *
2764
+ * Can be used as a poster image for the video player.
2765
+ */
2766
+ thumbnailUrl: string;
2767
+ /**
2768
+ * Video duration in milliseconds.
2769
+ */
2770
+ durationMs?: number;
2771
+ }
2772
+
2773
+ /**
2774
+ * @public
2775
+ * Video preview with lightweight thumbnail available.
2776
+ *
2777
+ * This is the initial state for video previews. Show the thumbnail image
2778
+ * and call `requestPreviewUpgrade` when the user needs the full video.
2779
+ */
2780
+ declare interface VideoPreviewThumbnail extends SizedPreview {
2781
+ kind: 'video';
2782
+ status: 'thumbnail';
2783
+ /**
2784
+ * Format of the thumbnail image.
2785
+ */
2786
+ thumbnailFormat: 'png' | 'jpg';
2787
+ /**
2788
+ * URL to the thumbnail image.
2789
+ *
2790
+ * Display this lightweight image until full video is needed.
2791
+ */
2792
+ thumbnailUrl: string;
2793
+ /**
2794
+ * Video duration in milliseconds.
2795
+ */
2796
+ durationMs?: number;
2797
+ }
2798
+
2799
+ /**
2800
+ * @public
2801
+ * Video preview that is being upgraded from thumbnail to full video.
2802
+ *
2803
+ * Display the thumbnail with a loading indicator until the video is ready.
2804
+ */
2805
+ declare interface VideoPreviewUpgrading extends SizedPreview {
2806
+ kind: 'video';
2807
+ status: 'upgrading';
2808
+ /**
2809
+ * Format of the thumbnail image.
2810
+ */
2811
+ thumbnailFormat: 'png' | 'jpg';
2812
+ /**
2813
+ * URL to the thumbnail image.
2814
+ *
2815
+ * Continue showing the thumbnail while the full video loads.
2816
+ */
2817
+ thumbnailUrl: string;
2818
+ /**
2819
+ * Video duration in milliseconds.
2820
+ */
2821
+ durationMs?: number;
2822
+ }
2823
+
2824
+ /**
2825
+ * @public
2826
+ * A unique identifier that points to a video asset in Canva's backend.
2827
+ */
2828
+ declare type VideoRef = string & {
2829
+ __videoRef: never;
2830
+ };
2831
+
2832
+ /**
2833
+ * @public
2834
+ * Video file requirements for a media slot.
2835
+ *
2836
+ * Specifies format, aspect ratio, duration, and size constraints for videos.
2837
+ *
2838
+ * @example Video requirements for YouTube
2839
+ * ```ts
2840
+ * const videoReq: VideoRequirement = {
2841
+ * format: 'mp4',
2842
+ * aspectRatio: { exact: 16/9 },
2843
+ * durationMs: { min: 1000, max: 600000 },
2844
+ * };
2845
+ * ```
2846
+ */
2847
+ declare interface VideoRequirement extends BaseFileRequirement {
2848
+ /**
2849
+ * Supported video format.
2850
+ */
2851
+ format: 'mp4';
2852
+ /**
2853
+ * Aspect ratio constraint (width / height).
2854
+ *
2855
+ * Examples:
2856
+ * - `{ exact: 16/9 }`: Widescreen
2857
+ * - `{ exact: 9/16 }`: Vertical/Story format
2858
+ */
2859
+ aspectRatio?: ValueRange;
2860
+ /**
2861
+ * Duration constraint in milliseconds.
2862
+ *
2863
+ * Examples:
2864
+ * - `{ max: 60000 }`: Maximum 60 seconds
2865
+ * - `{ min: 3000, max: 600000 }`: Between 3 seconds and 10 minutes
2866
+ */
2867
+ durationMs?: ValueRange;
2868
+
2869
+ }
2870
+
2871
+ /**
2872
+ * @public
2873
+ * Options for uploading a video asset to the user's private media library.
2874
+ */
2875
+ declare type VideoUploadOptions = {
2876
+ /**
2877
+ * The type of asset.
2878
+ */
2879
+ type: 'video';
2880
+ /**
2881
+ * A human-readable name for the video asset.
2882
+ *
2883
+ * @remarks
2884
+ * This name is displayed in the user's media library and helps users identify
2885
+ * and find the asset later. If not provided, Canva will generate a name based
2886
+ * on the asset's URL or a unique identifier.
2887
+ *
2888
+ * Requirements:
2889
+ * - Minimum length: 1 character (empty strings are not allowed)
2890
+ * - Maximum length: 255 characters
2891
+ */
2892
+ name?: string;
2893
+ /**
2894
+ * The ref of the original asset from which this new asset was derived.
2895
+ *
2896
+ * @remarks
2897
+ * For example, if an app applies an effect to a video, `parentRef` should contain the ref of the original video.
2898
+ */
2899
+ parentRef?: VideoRef;
2900
+ /**
2901
+ * The URL of the video file to upload.
2902
+ *
2903
+ * @remarks
2904
+ * Requirements:
2905
+ *
2906
+ * - Must use HTTPS
2907
+ * - Must return a `200` status code
2908
+ * - `Content-Type` must match the file's MIME type
2909
+ * - Must be publicly accessible (i.e. not a localhost URL)
2910
+ * - Must not redirect
2911
+ * - Must not contain an IP address
2912
+ * - Maximum length: 4096 characters
2913
+ * - Must not contain whitespace
2914
+ * - Must not contain these characters: `>`, `<`, `{`, `}`, `^`, backticks
2915
+ * - Maximum file size: 1000MB (1GB)
2916
+ */
2917
+ url: string;
2918
+ /**
2919
+ * The MIME type of the video file.
2920
+ */
2921
+ mimeType: VideoMimeType;
2922
+ /**
2923
+ * The URL of a thumbnail video to display while the video is queued for upload.
2924
+ *
2925
+ * @remarks
2926
+ * Requirements:
2927
+ *
2928
+ * - Must use HTTPS
2929
+ * - Must support [Cross-Origin Resource Sharing](https://www.canva.dev/docs/apps/cross-origin-resource-sharing/)
2930
+ * - Maximum length: 4096 characters
2931
+ * - The dimensions of the thumbnail video must match the video's aspect ratio to prevent the thumbnail from appearing squashed or stretched
2932
+ * - Must not be an AVI file. Although our APIs support uploading AVI videos, Canva can't preview them because of native support of browsers
2933
+ */
2934
+ thumbnailVideoUrl?: string;
2935
+ /**
2936
+ * The URL of a thumbnail image to use as a fallback if `thumbnailVideoUrl` isn't provided.
2937
+ * This can be an external URL or a data URL.
2938
+ *
2939
+ * @remarks
2940
+ * Requirements for external URLs:
2941
+ *
2942
+ * - Must use HTTPS
2943
+ * - Must support [Cross-Origin Resource Sharing](https://www.canva.dev/docs/apps/cross-origin-resource-sharing/)
2944
+ * - Must be a PNG, JPEG, or SVG file
2945
+ * - Maximum length: 4096 characters
2946
+ *
2947
+ * Requirements for data URLs:
2948
+ *
2949
+ * - Must include `;base64` for base64-encoded data
2950
+ * - Maximum size: 10MB (10 × 1024 × 1024 characters)
2951
+ * - The dimensions of the thumbnail must match the video's aspect ratio to prevent the thumbnail from appearing squashed or stretched
2952
+ */
2953
+ thumbnailImageUrl: string;
2954
+ /**
2955
+ * A disclosure identifying if the app generated this video using AI.
2956
+ *
2957
+ * @remarks
2958
+ * Helps users make informed decisions about the content they interact with.
2959
+ * See {@link AiDisclosure} for the full definition.
2960
+ *
2961
+ * **App Generated**
2962
+ *
2963
+ * 'app_generated' indicates when the app creates or significantly alters an asset using AI. Includes when
2964
+ * the app requests a third-party service to take similar action on a video using AI.
2965
+ *
2966
+ * Required for the following cases (this list is not exhaustive):
2967
+ * | Case | Reason |
2968
+ * | -- | -- |
2969
+ * | AI generates a new video from scratch | Creates new creative content |
2970
+ * | AI changes the style of the video e.g. makes it cartoon | Significantly alters the style |
2971
+ * | AI adds subtitles that rely on subjective interpretation | Creates new creative content |
2972
+ * | AI expands a video by generating new content to fill the edges | Creates new creative content |
2973
+ * | AI animates an image | Creates new creative content |
2974
+ * | AI fixes defects e.g. blur in a video by generating details | Creates new creative content |
2975
+ * | AI generates a talking head presenter | Creates new creative content |
2976
+ *
2977
+ * **None**
2978
+ *
2979
+ * 'none' indicates when the app doesn't create or significantly alter an asset using AI, or as a part of
2980
+ * a request to third-party hosted content.
2981
+ *
2982
+ * Required for the following cases (this list is not exhaustive):
2983
+ * | Case | Reason |
2984
+ * | -- | -- |
2985
+ * | Asset comes from an asset library | Didn't generate the asset itself |
2986
+ * | AI corrects red eyes | A minor correction |
2987
+ * | AI adjusts brightness and contrast on a video | Doesn't change original meaning by itself |
2988
+ * | AI creates a slow motion effect in a video | Doesn't change original meaning by itself |
2989
+ * | AI adds AI word-by-word transcribed subtitles to a video | Doesn't change original meaning by itself |
2990
+ */
2991
+ aiDisclosure: AiDisclosure;
2992
+
2993
+ } & AllOrNone<Dimensions>;
2994
+
2995
+ export { }