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