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