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