@canva/intents 2.5.1-beta.2 → 2.6.0

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