@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/content/beta.d.ts DELETED
@@ -1,2069 +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
- export 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
- export declare type AiContentCompletedResponse = {
17
- status: 'completed';
18
- value: string;
19
- };
20
-
21
- /**
22
- * @beta
23
- * All possible AI content request types.
24
- */
25
- export declare type AiContentRequest = SocialCaptionRequest;
26
-
27
- /**
28
- * @beta
29
- * All possible AI content response types.
30
- */
31
- export declare type AiContentResponse = AiContentCompletedResponse | AiContentCancelledResponse;
32
-
33
- /**
34
- * @beta
35
- * All possible statuses for an AI content response.
36
- *
37
- */
38
- export 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
- export declare type AiContentType = 'social_caption';
46
-
47
- /**
48
- * @public
49
- * {@link PublishContentError} indicating a custom error occurred in your app's implementation.
50
- *
51
- * Return this for application-specific errors such as:
52
- *
53
- * - Validation failures
54
- * - Authentication errors
55
- * - Rate limiting
56
- * - Platform-specific restrictions
57
- *
58
- * @example Returning custom error with message
59
- * ```ts
60
- * if (userQuotaExceeded) {
61
- * return {
62
- * status: 'app_error',
63
- * message: 'You have reached your monthly publish limit. Please upgrade your plan.'
64
- * };
65
- * }
66
- * ```
67
- */
68
- export declare type AppError = {
69
- status: 'app_error';
70
- /**
71
- * (required) The raw error message, for logging purposes. It will not display in the UI.
72
- * To display custom error messages in the UI use `localizedMessageId`.
73
- *
74
- * This should typically be the javascript error.message or a REST JSON error message
75
- * body passed without modification.
76
- *
77
- * WARNING: Do not include personally identifiable information (PII) in this
78
- * message, such as names, emails, usernames, etc.
79
- */
80
- message: string;
81
- /**
82
- * (optional) Message ID of the translated error message that will be
83
- * displayed to the user. The message ID should be present and uploaded in
84
- * your translation file. If omitted, Canva will display a generic error
85
- * message.
86
- */
87
- localizedMessageId?: string;
88
- /** HTTP status code, if applicable */
89
- httpCode?: number;
90
- /**
91
- * Used only by app developer. Canva does not use this value. Use this to pass
92
- * additional information like JSON to your settings frame.
93
- */
94
- appDefinedPayload?: string;
95
- /**
96
- * (optional) Source of the error if it relates to a component on the Canva
97
- * UI. When present, the error may render near a relevant Canva component.
98
- * When omitted, the cause is considered unspecified or "generic".
99
- */
100
- errorCause?: ErrorCause;
101
- };
102
-
103
- /**
104
- * @beta
105
- * Content summary for file-destination apps (e.g. Google Drive, Dropbox).
106
- */
107
- export declare type AssetContentSummary = BaseContentSummary & {
108
- type: 'asset';
109
- /** Asset title or filename. */
110
- title: string;
111
- /** Folder path (e.g. "/My Projects/Designs"). */
112
- path?: string;
113
- };
114
-
115
- /**
116
- * @beta
117
- * Base interface for AI content requests.
118
- */
119
- declare type BaseAiContentRequest = {
120
- /**
121
- * The type of AI content generation which determines
122
- * the kind of content the AI will generate.
123
- */
124
- type: AiContentType;
125
- /**
126
- * If a current value exists in the field, the AI content generation
127
- * will be an edit-first experience.
128
- * i.e. When the user has already entered a value in the field, the AI will
129
- * generate a new value using the existing value as a starting point.
130
- */
131
- currentValue?: string;
132
- /**
133
- * The label chosen by the app developer for the field.
134
- * It will be used in the UI to customize the copy.
135
- * Required since it is essential context for the AI to generate the content.
136
- */
137
- fieldLabel: string;
138
- };
139
-
140
- /**
141
- * @beta
142
- * Base fields shared by all content summary variants.
143
- */
144
- declare type BaseContentSummary = {
145
- /**
146
- * The account, page, or list this post was published to.
147
- *
148
- * For example, a Facebook Page, a mailing list, or a personal profile.
149
- * Use the connected account's display name and icon when there is no distinct destination.
150
- */
151
- destination: Destination;
152
- };
153
-
154
- /**
155
- * @public
156
- * Base file requirement interface.
157
- */
158
- declare interface BaseFileRequirement {
159
- /**
160
- * File format for this requirement.
161
- */
162
- format: PublishFileFormat;
163
-
164
- }
165
-
166
- /**
167
- * @public
168
- * Base interface for exported files.
169
- */
170
- export declare interface BaseOutputFile {
171
- /**
172
- * File format.
173
- */
174
- format: PublishFileFormat;
175
- /**
176
- * URL to download the exported file.
177
- *
178
- * Your app should download from this URL and upload to your platform.
179
- */
180
- url: string;
181
- /**
182
- * Metadata about the source content used to create this exported file.
183
- */
184
- contentMetadata: ContentMetadata;
185
- }
186
-
187
- /**
188
- * @public
189
- * Base interface for all preview types.
190
- *
191
- * Contains common properties shared by all preview types.
192
- */
193
- export declare interface BasePreview {
194
- /**
195
- * Unique identifier for this preview.
196
- *
197
- * Use this ID with `requestPreviewUpgrade` to upgrade video thumbnails.
198
- */
199
- id: string;
200
- /**
201
- * Type of media in this preview.
202
- */
203
- kind: PreviewKind;
204
- /**
205
- * Current state of the preview.
206
- */
207
- status: PreviewStatus;
208
- }
209
-
210
- /**
211
- * @public
212
- * Base metadata available for a selected media item in a media slot.
213
- *
214
- * Canva populates this when returning {@link OutputType} in Settings UI contexts.
215
- * Apps should not set this value.
216
- */
217
- export declare interface BaseSelection {
218
- /**
219
- * Metadata about the source content represented by this selection.
220
- */
221
- selectionMetadata?: readonly SelectionMetadata[];
222
- }
223
-
224
- /**
225
- * @public
226
- * Metadata about the source content used to create an exported file.
227
- */
228
- export declare type ContentMetadata = DesignContentMetadata;
229
-
230
- /**
231
- * @beta
232
- * Describes what kind of content an output type produces. Canva uses this to tailor and improve
233
- * the publish experience.
234
- */
235
- export declare type ContentNoun = 'email' | 'post' | 'schedule' | 'asset' | 'draft' | 'publication' | 'content';
236
-
237
- /**
238
- * @beta
239
- * Main interface for implementing the ContentPublisher intent.
240
- *
241
- * Implementing the ContentPublisher intent enables apps to publish contents to external platforms.
242
- * This allows users to configure publish settings, preview their designs, and share with others.
243
- *
244
- * The publishing flow follows this process:
245
- *
246
- * 1. User initiates publish action
247
- * 2. Your app provides publish configuration via `getPublishConfiguration`
248
- * 3. User selects an output type
249
- * 4. Your app renders settings UI via `renderSettingsUi`
250
- * 5. Your app renders preview UI via `renderPreviewUi`
251
- * 6. User reviews settings and preview
252
- * 7. Your app publishes the content via `publishContent`
253
- */
254
- export declare type ContentPublisherIntent = {
255
- /**
256
- * Provides the configuration for the publishing platform.
257
- *
258
- * This action is called when the user initiates the publish flow and needs to
259
- * select an output type for the target platform.
260
- *
261
- * Use this to define different publishing configurations for your platform,
262
- * such as social media posts, videos, or other output types.
263
- *
264
- * @returns A promise resolving to the publish configuration or an error
265
- *
266
- * @example Defining publish configuration for a social media platform
267
- * ```ts
268
- * import type { GetPublishConfigurationResponse } from '@canva/intents/content';
269
- *
270
- * async function getPublishConfiguration(): Promise<GetPublishConfigurationResponse> {
271
- * return {
272
- * status: 'completed',
273
- * outputTypes: [
274
- * {
275
- * id: 'instagram_post',
276
- * displayName: 'Instagram Post',
277
- * mediaSlots: [
278
- * {
279
- * id: 'main_image',
280
- * displayName: 'Post Image',
281
- * fileCount: { min: 1, max: 10 },
282
- * accepts: {
283
- * image: { format: 'jpg', aspectRatio: { min: 0.8, max: 1.91 } }
284
- * }
285
- * }
286
- * ]
287
- * }
288
- * ]
289
- * };
290
- * }
291
- * ```
292
- */
293
- getPublishConfiguration: () => Promise<GetPublishConfigurationResponse>;
294
-
295
- /**
296
- * Renders a user interface for configuring publish settings.
297
- *
298
- * This action is called after the user selects an output type. Your UI should
299
- * allow users to configure platform-specific settings such as captions, tags,
300
- * privacy settings, or publishing destinations.
301
- *
302
- * Use the `updatePublishSettings` callback to save user settings and validate them.
303
- * Settings are stored in the `publishRef` string (maximum 32KB).
304
- *
305
- * @param request - Configuration and callbacks for the publish settings UI.
306
- *
307
- * @example Rendering a settings UI with publish configuration
308
- * ```ts
309
- * import { createRoot } from 'react-dom/client';
310
- * import type { RenderSettingsUiRequest } from '@canva/intents/content';
311
- *
312
- * function renderSettingsUi(request: RenderSettingsUiRequest): void {
313
- * const SettingsUiApp = () => (
314
- * <AppUiProvider>
315
- * <SettingsUi request={request} />
316
- * </AppUiProvider>
317
- * );
318
- *
319
- * createRoot().render(<SettingsUiApp />)
320
- * }
321
- * ```
322
- */
323
- renderSettingsUi: (request: RenderSettingsUiRequest) => void;
324
- /**
325
- * Renders a user interface for previewing the content.
326
- *
327
- * This action is called after the settings UI is rendered. Your UI should display
328
- * a preview of how the content will appear on the target platform.
329
- *
330
- * Previews update dynamically as users modify their content or settings. For videos
331
- * and documents, start with lightweight thumbnails and use `requestPreviewUpgrade`
332
- * to load full previews on demand to optimize performance.
333
- *
334
- * @param request - Configuration and callbacks for the preview UI.
335
- *
336
- * @example Rendering a preview UI with media optimization
337
- * ```ts
338
- * import { createRoot } from 'react-dom/client';
339
- * import type { RenderPreviewUiRequest } from '@canva/intents/content';
340
- *
341
- * function renderPreviewUi(request: RenderPreviewUiRequest): void {
342
- * const PreviewUiApp = () => (
343
- * <AppUiProvider>
344
- * <PreviewUi request={request} />
345
- * </AppUiProvider>
346
- * );
347
- *
348
- * createRoot().render(<PreviewUiApp />)
349
- * }
350
- * ```
351
- */
352
- renderPreviewUi: (request: RenderPreviewUiRequest) => void;
353
- /**
354
- * Publishes the content to the external platform.
355
- *
356
- * This action is called when the user confirms the publish action after reviewing
357
- * settings and preview. Your implementation should send the exported files
358
- * to your platform's API.
359
- *
360
- * The `outputMedia` contains production-ready files that match the requirements
361
- * specified in your output types. The `publishRef` contains the user's settings
362
- * from the settings UI.
363
- *
364
- * @param request - Parameters for the publish operation.
365
- * @returns A promise resolving to either a successful result with the published content details or an error.
366
- *
367
- * @example Publishing content to an external platform
368
- * ```ts
369
- * import type { PublishContentRequest, PublishContentResponse } from '@canva/intents/content';
370
- *
371
- * async function publishContent(request: PublishContentRequest): Promise<PublishContentResponse> {
372
- * const { publishRef, outputType, outputMedia } = request;
373
- *
374
- * try {
375
- * // Parse settings from publishRef
376
- * const settings = publishRef ? JSON.parse(publishRef) : {};
377
- *
378
- * // Upload files to your platform
379
- * const uploadedFiles = await Promise.all(
380
- * outputMedia.flatMap(media =>
381
- * media.files.map(file => uploadFile(file.url))
382
- * )
383
- * );
384
- *
385
- * // Create post on your platform
386
- * const result = await createPost({
387
- * files: uploadedFiles,
388
- * caption: settings.caption
389
- * });
390
- *
391
- * return {
392
- * status: 'completed',
393
- * externalId: result.id,
394
- * externalUrl: result.url
395
- * };
396
- * } catch (error) {
397
- * return {
398
- * status: 'remote_request_failed'
399
- * };
400
- * }
401
- * }
402
- * ```
403
- */
404
- publishContent: (request: PublishContentRequest) => Promise<PublishContentResponse>;
405
-
406
- /**
407
- * @beta
408
- * Extracts a structured summary of the post's content for historical display.
409
- *
410
- * Called at `createPost` / `updatePost` time while the app is loaded. The returned
411
- * snapshot is stored with the post and used to render historical post views in the
412
- * content planner (calendar, list views, insights) without re-invoking the app.
413
- *
414
- * The snapshot is frozen at write time — it reflects what was published, not the
415
- * app's current rendering logic. If the app's payload shape or output types change
416
- * later, historical views remain accurate.
417
- *
418
- * @param request - The `publishRef` and `outputType` for the post being published.
419
- * @returns A promise resolving to the `ContentSummary`, or an error.
420
- */
421
- getContentSummary?: (request: GetContentSummaryRequest) => Promise<GetContentSummaryResponse>;
422
- };
423
-
424
- /**
425
- * @beta
426
- * A structured snapshot of a post's content for historical display.
427
- * Discriminated by `type`.
428
- */
429
- export declare type ContentSummary = PostContentSummary | EmailContentSummary | AssetContentSummary | GenericContentSummary;
430
-
431
- /**
432
- * @public
433
- * Metadata specific to design content.
434
- */
435
- export declare interface DesignContentMetadata {
436
- type: 'design';
437
- /**
438
- * A signed JWT token containing the design id
439
- */
440
- designToken: string;
441
- /**
442
- * The user given title of the design
443
- */
444
- title: string | undefined;
445
- /**
446
- * The pages that make up the exported metadata
447
- */
448
- pages: OutputPageMetadata[];
449
-
450
- }
451
-
452
- /**
453
- * @beta
454
- * The publishing destination when distinct from the connected account.
455
- */
456
- export declare type Destination = {
457
- /** User-facing name (e.g. "Bob's Cool Page", "Product Newsletter"). */
458
- displayName: string;
459
- /** Avatar or icon URL for the destination. */
460
- iconUrl?: string;
461
- };
462
-
463
- /**
464
- * @public
465
- * A function that can be called to dispose of a callback.
466
- */
467
- export declare type Disposer = () => void;
468
-
469
- /**
470
- * @public
471
- * Exported PDF file ready for publishing.
472
- *
473
- * Contains the final PDF document that should be uploaded to your platform.
474
- * The document format is `pdf_standard` and the file is ready to use.
475
- */
476
- export declare type DocumentOutputFile = BaseOutputFile;
477
-
478
- /**
479
- * @beta
480
- * Document preview in various states.
481
- *
482
- * Documents transition through states: `"loading"` → `"thumbnail"` → `"upgrading"` → `"ready"`.
483
- * Start with a lightweight thumbnail of the first page, then upgrade to full multi-page
484
- * preview using `requestPreviewUpgrade`.
485
- */
486
- export declare type DocumentPreview = DocumentPreviewLoading | DocumentPreviewThumbnail | DocumentPreviewUpgrading | DocumentPreviewReady | DocumentPreviewError;
487
-
488
- /**
489
- * @public
490
- * Document preview that failed to generate.
491
- *
492
- * Display an error state to the user.
493
- */
494
- export declare interface DocumentPreviewError extends SizedPreview {
495
- kind: 'document';
496
- status: 'error';
497
- /**
498
- * The error message to display to the user.
499
- */
500
- message: string;
501
- }
502
-
503
- /**
504
- * @public
505
- * Document preview that is currently being generated.
506
- *
507
- * Display a loading state until the preview transitions to `"thumbnail"` or `"error"`.
508
- */
509
- export declare interface DocumentPreviewLoading extends SizedPreview {
510
- kind: 'document';
511
- status: 'loading';
512
- }
513
-
514
- /**
515
- * @beta
516
- * Thumbnail for a single page within a document preview.
517
- */
518
- export declare interface DocumentPreviewPage {
519
- /**
520
- * URL to the page thumbnail image.
521
- */
522
- url: string;
523
- /**
524
- * Width of the page thumbnail in pixels.
525
- */
526
- widthPx: number;
527
- /**
528
- * Height of the page thumbnail in pixels.
529
- */
530
- heightPx: number;
531
- }
532
-
533
- /**
534
- * @beta
535
- * Final state after a document preview has been upgraded. Contains thumbnail
536
- * URLs for every selected page in the document.
537
- */
538
- export declare interface DocumentPreviewReady extends BasePreview {
539
- kind: 'document';
540
- status: 'ready';
541
- /**
542
- * Format of the per-page thumbnails.
543
- */
544
- format: 'png' | 'jpg';
545
- /**
546
- * Thumbnail pages for each page. Index corresponds to the page number.
547
- */
548
- pages: DocumentPreviewPage[];
549
- }
550
-
551
- /**
552
- * @public
553
- * Document preview with first page thumbnail available.
554
- *
555
- * This is the initial state for document previews. Show the thumbnail image
556
- * of the first page along with the page count to give users a preview of
557
- * the document before publishing.
558
- */
559
- export declare interface DocumentPreviewThumbnail extends SizedPreview {
560
- kind: 'document';
561
- status: 'thumbnail';
562
- /**
563
- * Format of the thumbnail image.
564
- */
565
- thumbnailFormat: 'png' | 'jpg';
566
- /**
567
- * URL to the first page thumbnail.
568
- *
569
- * Display this lightweight image to preview the document content.
570
- */
571
- thumbnailUrl: string;
572
- }
573
-
574
- /**
575
- * @beta
576
- * Intermediate state while multi-page document thumbnails are being fetched
577
- * via {@link requestPreviewUpgrade}. The single-page thumbnail remains
578
- * available for display during the upgrade.
579
- */
580
- export declare interface DocumentPreviewUpgrading extends SizedPreview {
581
- kind: 'document';
582
- status: 'upgrading';
583
- thumbnailFormat: 'png' | 'jpg';
584
- /** The first-page thumbnail URL, available immediately. */
585
- thumbnailUrl: string;
586
- }
587
-
588
- /**
589
- * @public
590
- * Document file requirements for a media slot.
591
- *
592
- * Note: Document output types use image previews (PNG thumbnails) in the preview UI.
593
- * The actual document file is only generated for the final output in OutputMedia.
594
- *
595
- * @example Document requirements
596
- * ```ts
597
- * const documentReq: DocumentRequirement = {
598
- * format: 'pdf_standard',
599
- * size: 'a4',
600
- * };
601
- * ```
602
- */
603
- export declare interface DocumentRequirement extends BaseFileRequirement {
604
- /**
605
- * Supported document export format.
606
- * Currently supports PDF standard format.
607
- */
608
- format: 'pdf_standard';
609
- /**
610
- * The document size of the export file.
611
- */
612
- size: DocumentSize;
613
- }
614
-
615
- /**
616
- * @public
617
- * Selection metadata for a document media item.
618
- */
619
- export declare interface DocumentSelection extends BaseSelection {
620
- kind: 'document';
621
- }
622
-
623
- /**
624
- * @public
625
- * Document size for document exports.
626
- */
627
- export declare type DocumentSize = 'a4' | 'a3' | 'letter' | 'legal';
628
-
629
- /**
630
- * @beta
631
- * Content summary for email sends.
632
- */
633
- export declare type EmailContentSummary = BaseContentSummary & {
634
- type: 'email';
635
- /** Subject line. */
636
- subject?: string;
637
- /** Email body preview or preheader. */
638
- body?: string;
639
- };
640
-
641
- /**
642
- * @public
643
- * Exported email file ready for publishing.
644
- *
645
- * Contains the final HTML bundle that should be uploaded to your platform.
646
- */
647
- export declare type EmailOutputFile = BaseOutputFile;
648
-
649
- /**
650
- * @public
651
- * Email preview in various states.
652
- *
653
- * Display a loading state until the preview transitions to `"ready"` or `"error"`.
654
- */
655
- export declare type EmailPreview = EmailPreviewLoading | EmailPreviewReady | EmailPreviewError;
656
-
657
- /**
658
- * @public
659
- * Email preview in an error state.
660
- *
661
- * Display an error state to the user.
662
- */
663
- export declare interface EmailPreviewError extends BasePreview {
664
- kind: 'email';
665
- status: 'error';
666
- message: string;
667
- }
668
-
669
- /**
670
- * @public
671
- * Email preview in a loading state.
672
- *
673
- * Display a loading spinner until the preview transitions to `"ready"` or `"error"`.
674
- */
675
- export declare interface EmailPreviewLoading extends BasePreview {
676
- kind: 'email';
677
- status: 'loading';
678
- }
679
-
680
- /**
681
- * @public
682
- * Email preview in a ready state.
683
- *
684
- * Display the email preview.
685
- */
686
- export declare interface EmailPreviewReady extends BasePreview {
687
- kind: 'email';
688
- status: 'ready';
689
- /**
690
- * URL to the single html file that represents the email.
691
- */
692
- url: string;
693
- }
694
-
695
- /**
696
- * @public
697
- * Email file requirements for a media slot, currently only supports HTML bundle format.
698
- *
699
- * Note: Email output types use html_standalone previews in the preview UI.
700
- * The actual email file is only generated for the final output in OutputMedia.
701
- *
702
- * @example Email bundle requirements
703
- * ```ts
704
- * const emailReq: EmailRequirement = {
705
- * format: 'html_bundle',
706
- * };
707
- * ```
708
- */
709
- export declare interface EmailRequirement extends BaseFileRequirement {
710
- format: 'html_bundle' | 'html_standalone';
711
- }
712
-
713
- /**
714
- * @public
715
- * Selection metadata for an email media item.
716
- */
717
- export declare interface EmailSelection extends BaseSelection {
718
- kind: 'email';
719
- }
720
-
721
- /**
722
- * @public
723
- *
724
- * The cause of an error
725
- */
726
- export declare type ErrorCause = 'invalid_selection' | 'invalid_format';
727
-
728
- /**
729
- * @public
730
- * Exact value range constraint.
731
- * @example Exact value range
732
- * ```ts
733
- * const exactValue: ValueRange = { exact: 1 }; // Must be exactly 1
734
- * ```
735
- */
736
- export declare type ExactValueRange = {
737
- exact: number;
738
- };
739
-
740
- /**
741
- * @beta
742
- * Generic content summary for apps that don't fit a more specific type.
743
- */
744
- export declare type GenericContentSummary = BaseContentSummary & {
745
- type: 'content';
746
- /** Title or headline. */
747
- title?: string;
748
- /** Body text or description. */
749
- body?: string;
750
- };
751
-
752
- /**
753
- * @beta
754
- * Successful response from getContentSummary.
755
- */
756
- export declare type GetContentSummaryCompleted = {
757
- status: 'completed';
758
- contentSummary: ContentSummary;
759
- };
760
-
761
- /**
762
- * @beta
763
- * Error response from getContentSummary.
764
- */
765
- export declare type GetContentSummaryError = AppError;
766
-
767
- /**
768
- * @beta
769
- * Request payload for the getContentSummary action.
770
- */
771
- export declare type GetContentSummaryRequest = {
772
- /** The user's saved publish settings. Parse to retrieve app-specific state. */
773
- publishRef?: string;
774
- /**
775
- * The output type selected for this publish operation.
776
- *
777
- * Use `id` to distinguish between output types.
778
- */
779
- outputType: OutputType;
780
- };
781
-
782
- /**
783
- * @beta
784
- * Response from getContentSummary.
785
- */
786
- export declare type GetContentSummaryResponse = GetContentSummaryCompleted | GetContentSummaryError;
787
-
788
- /**
789
- * @public
790
- * Successful response from getting publish configuration.
791
- */
792
- export declare type GetPublishConfigurationCompleted = {
793
- status: 'completed';
794
- /**
795
- * Array of available output types for your platform.
796
- *
797
- * Define different output types for various content formats that
798
- * your platform supports (e.g., posts, stories, videos).
799
- */
800
- outputTypes: OutputTypeConfiguration[];
801
- };
802
-
803
- /**
804
- * @public
805
- * {@link GetPublishConfigurationError} error indicating a custom error occurred.
806
- */
807
- export declare type GetPublishConfigurationError = AppError;
808
-
809
- /**
810
- * @public
811
- * Response from getting publish configuration.
812
- */
813
- export declare type GetPublishConfigurationResponse = GetPublishConfigurationCompleted | GetPublishConfigurationError;
814
-
815
- /**
816
- * @public
817
- * Exported image file ready for publishing.
818
- */
819
- export declare interface ImageOutputFile extends BaseOutputFile {
820
- /**
821
- * Width of the image in pixels.
822
- */
823
- widthPx: number;
824
- /**
825
- * Height of the image in pixels.
826
- */
827
- heightPx: number;
828
- }
829
-
830
- /**
831
- * @public
832
- * Image preview in various states.
833
- */
834
- export declare type ImagePreview = ImagePreviewLoading | ImagePreviewReady | ImagePreviewError;
835
-
836
- /**
837
- * @public
838
- * Image preview that failed to generate.
839
- *
840
- * Display an error state to the user.
841
- */
842
- export declare interface ImagePreviewError extends SizedPreview {
843
- kind: 'image';
844
- status: 'error';
845
-
846
- /**
847
- * The error message to display to the user.
848
- */
849
- message: string;
850
- }
851
-
852
- /**
853
- * @public
854
- * Image preview that is currently being generated.
855
- *
856
- * Display a loading state until the preview transitions to `"ready"` or `"error"`.
857
- */
858
- export declare interface ImagePreviewLoading extends SizedPreview {
859
- kind: 'image';
860
- status: 'loading';
861
- }
862
-
863
- /**
864
- * @public
865
- * Image preview that is ready to display.
866
- *
867
- * Contains the URL to the preview image.
868
- */
869
- export declare interface ImagePreviewReady extends SizedPreview {
870
- kind: 'image';
871
- status: 'ready';
872
- /**
873
- * Image format of the preview.
874
- */
875
- format: 'png' | 'jpg';
876
- /**
877
- * URL to the preview image.
878
- *
879
- * Use this URL to display the preview to users.
880
- */
881
- url: string;
882
- }
883
-
884
- /**
885
- * @public
886
- * Image file requirements for a media slot.
887
- *
888
- * Specifies format, aspect ratio, and size constraints for images.
889
- *
890
- * @example Image requirements for social media post
891
- * ```ts
892
- * const imageReq: ImageRequirement = {
893
- * format: 'jpg',
894
- * aspectRatio: { min: 0.8, max: 1.91 },
895
- * };
896
- * ```
897
- */
898
- export declare type ImageRequirement = BaseFileRequirement & {
899
- /**
900
- * Aspect ratio constraint (width / height).
901
- *
902
- * Examples:
903
- * - `{ exact: 16/9 }`: Widescreen (16:9)
904
- * - `{ min: 0.8, max: 1.91 }`: Instagram range
905
- */
906
- aspectRatio?: ValueRange;
907
- } & ({
908
- /**
909
- * JPG image export.
910
- */
911
- format: 'jpg';
912
- } | {
913
- /**
914
- * PNG image export.
915
- */
916
- format: 'png';
917
- /**
918
- * Controls transparent-background support for PNG exports.
919
- *
920
- * @remarks
921
- * - Only applies when `format` is `'png'`
922
- * - If omitted or `false`, Canva exports a standard opaque PNG
923
- * - If `true`, Canva shows a `Transparent background` toggle in the publish flow
924
- * - Users without the required Canva entitlement may be prompted to upgrade before a transparent export is produced
925
- *
926
- * @defaultValue false
927
- */
928
- allowTransparentBackground?: boolean;
929
- });
930
-
931
- /**
932
- * @public
933
- * Selection metadata for an image media item.
934
- */
935
- export declare interface ImageSelection extends BaseSelection {
936
- kind: 'image';
937
- }
938
-
939
- /**
940
- * @public
941
- * Maximum value range constraint.
942
- * @example Maximum value range
943
- * ```ts
944
- * const maxValue: ValueRange = { max: 10 }; // At most 10
945
- * ```
946
- */
947
- export declare type MaxValueRange = {
948
- max: number;
949
- };
950
-
951
- /**
952
- * @public
953
- * Metadata about a selected media item in a media slot.
954
- */
955
- export declare type MediaSelection = ImageSelection | VideoSelection | DocumentSelection | EmailSelection;
956
-
957
- /**
958
- * @public
959
- * Configuration for a media slot within an output type.
960
- *
961
- * Defines what type of media is accepted, requirements, and constraints.
962
- *
963
- * @example Image slot with aspect ratio requirements
964
- * ```ts
965
- * const thumbnailSlot: MediaSlot = {
966
- * id: 'thumbnail',
967
- * displayName: 'Video Thumbnail',
968
- * fileCount: { exact: 1 },
969
- * accepts: {
970
- * image: {
971
- * format: 'jpg',
972
- * aspectRatio: { exact: 16/9 },
973
- * }
974
- * }
975
- * };
976
- * ```
977
- */
978
- export declare type MediaSlot = {
979
- /**
980
- * Unique identifier for this media slot within the output type.
981
- */
982
- id: string;
983
- /**
984
- * User-facing name for this media slot.
985
- *
986
- * Examples: `"Post Image"`, `"Video Thumbnail"`, `"Main Video"`.
987
- */
988
- displayName: string;
989
- /**
990
- * Number of files accepted in this slot.
991
- *
992
- * Use this to specify single or multiple file requirements.
993
- * Examples:
994
- * - `{ exact: 1 }`: Exactly one file
995
- * - `{ min: 1, max: 10 }`: Between 1 and 10 files
996
- * - undefined: Any number of files
997
- */
998
- fileCount?: ValueRange;
999
- /**
1000
- * File type requirements for this slot.
1001
- *
1002
- * Note the following behavior:
1003
- *
1004
- * - Provide at least one of `image` or `video`
1005
- * - If both are provided, files for this slot may be either images or videos; each file
1006
- * must satisfy the corresponding requirement for its media type
1007
- * - To restrict the slot to a single media type, provide only that requirement
1008
- * - `fileCount` applies across all files accepted by the slot regardless of media type
1009
- * - Document output types will show image previews (PNG thumbnail) in preview UI
1010
- */
1011
- accepts: {
1012
- image?: ImageRequirement;
1013
- video?: VideoRequirement;
1014
- document?: DocumentRequirement;
1015
- /**
1016
- * Email output types will show a single html file (canva hosted assets) preview in preview UI
1017
- */
1018
- email?: EmailRequirement;
1019
- };
1020
- /**
1021
- * @public
1022
- * Current selection for this slot.
1023
- *
1024
- * Canva populates this only when returning {@link OutputType} in Settings UI contexts
1025
- * such as {@link RenderSettingsUiInvocationContext} and {@link PublishSettingsSettingsUiContext}.
1026
- * Apps should not set this value when defining output types in
1027
- * {@link ContentPublisherIntent.getPublishConfiguration}.
1028
- */
1029
- readonly selection?: readonly MediaSelection[];
1030
- };
1031
-
1032
- /**
1033
- * @public
1034
- * Minimum and maximum value range constraint.
1035
- * Ranges are inclusive `(min ≤ value ≤ max)`.
1036
- * @example Minimum and maximum value range
1037
- * ```ts
1038
- * const minMaxValue: ValueRange = { min: 1, max: 10 }; // Between 1 and 10
1039
- * ```
1040
- */
1041
- export declare type MinMaxValueRange = {
1042
- min: number;
1043
- max: number;
1044
- };
1045
-
1046
- /**
1047
- * @public
1048
- * Minimum value range constraint.
1049
- * @example Minimum value range
1050
- * ```ts
1051
- * const minValue: ValueRange = { min: 3 }; // At least 3
1052
- * ```
1053
- */
1054
- export declare type MinValueRange = {
1055
- min: number;
1056
- };
1057
-
1058
- /** @public */
1059
- export declare type OnContextChange = (context: SettingsUiContext) => void;
1060
-
1061
- /**
1062
- * @public
1063
- * Exported file ready for publishing.
1064
- */
1065
- export declare type OutputFile = ImageOutputFile | VideoOutputFile | DocumentOutputFile;
1066
-
1067
- /**
1068
- * @public
1069
- * Production-ready exported files for a specific media slot.
1070
- *
1071
- * These are the final files that should be uploaded to your platform.
1072
- */
1073
- export declare type OutputMedia = {
1074
- /**
1075
- * ID of the media slot these files belong to.
1076
- *
1077
- * Matches a media slot ID from your output type definition.
1078
- */
1079
- mediaSlotId: string;
1080
- /**
1081
- * Array of exported files for this media slot.
1082
- *
1083
- * Files match the requirements specified in your media slot configuration.
1084
- */
1085
- files: OutputFile[];
1086
- };
1087
-
1088
- /**
1089
- * @public
1090
- * Metadata about a specific page in the exported content.
1091
- */
1092
- export declare type OutputPageMetadata = {
1093
- /**
1094
- * The unique identifier for the page.
1095
- */
1096
- pageId: string | undefined;
1097
- /**
1098
- * The position of the page within the design, starting from 1 for the first page.
1099
- */
1100
- pageNumber: number;
1101
- };
1102
-
1103
- /**
1104
- * @public
1105
- * Configuration for an output type.
1106
- *
1107
- * Defines a specific publishing format your platform supports,
1108
- * including what media is required and accepted file types.
1109
- *
1110
- * @example Defining an Instagram post output type
1111
- * ```ts
1112
- * const instagramPost: OutputType = {
1113
- * id: 'instagram_post',
1114
- * displayName: 'Instagram Post',
1115
- * mediaSlots: [
1116
- * {
1117
- * id: 'main_image',
1118
- * displayName: 'Post Image',
1119
- * fileCount: { min: 1, max: 10 },
1120
- * accepts: {
1121
- * image: {
1122
- * format: 'jpg',
1123
- * aspectRatio: { min: 0.8, max: 1.91 },
1124
- * }
1125
- * }
1126
- * }
1127
- * ]
1128
- * };
1129
- * ```
1130
- */
1131
- export declare type OutputType = {
1132
- /**
1133
- * Unique identifier for this output type.
1134
- *
1135
- * Use descriptive IDs like `"instagram_post"` or `"youtube_video"`.
1136
- */
1137
- id: string;
1138
- /**
1139
- * User-facing name for this output type.
1140
- *
1141
- * This is displayed to users when selecting where to publish.
1142
- * Examples: `"Instagram Post"`, `"YouTube Video"`, `"Twitter Post"`.
1143
- */
1144
- displayName: string;
1145
- /**
1146
- * Array of media slots defining what content is needed.
1147
- *
1148
- * Each slot represents a piece of media required for publishing,
1149
- * such as a main image, thumbnail, or video.
1150
- */
1151
- mediaSlots: MediaSlot[];
1152
- /**
1153
- * @beta
1154
- * The type of content being published. When set, Canva uses this to tailor and improve the
1155
- * publish experience. When omitted, defaults to `'content'` (generic behavior).
1156
- */
1157
- contentNoun?: ContentNoun;
1158
- };
1159
-
1160
- /**
1161
- * @public
1162
- * Configuration for an output type as provided by apps in
1163
- * {@link ContentPublisherIntent.getPublishConfiguration}.
1164
- *
1165
- * This is the authored shape of an output type. It omits the
1166
- * {@link MediaSlot.selection} field which is populated by Canva
1167
- * when returning {@link OutputType} in Settings UI contexts.
1168
- *
1169
- * @example Defining output type configuration for a social media platform
1170
- * ```ts
1171
- * const outputType: OutputTypeConfiguration = {
1172
- * id: 'instagram_post',
1173
- * displayName: 'Instagram Post',
1174
- * mediaSlots: [
1175
- * {
1176
- * id: 'main_image',
1177
- * displayName: 'Post Image',
1178
- * fileCount: { min: 1, max: 10 },
1179
- * accepts: {
1180
- * image: { format: 'jpg', aspectRatio: { min: 0.8, max: 1.91 } }
1181
- * }
1182
- * }
1183
- * ]
1184
- * };
1185
- * ```
1186
- */
1187
- export declare type OutputTypeConfiguration = {
1188
- /**
1189
- * Unique identifier for this output type.
1190
- *
1191
- * Use descriptive IDs like `"instagram_post"` or `"youtube_video"`.
1192
- */
1193
- id: string;
1194
- /**
1195
- * User-facing name for this output type.
1196
- *
1197
- * This is displayed to users when selecting where to publish.
1198
- * Examples: `"Instagram Post"`, `"YouTube Video"`, `"Twitter Post"`.
1199
- */
1200
- displayName: string;
1201
- /**
1202
- * Array of media slots defining what content is needed.
1203
- *
1204
- * Each slot represents a piece of media required for publishing,
1205
- * such as a main image, thumbnail, or video.
1206
- * The {@link MediaSlot.selection} field is omitted here because apps
1207
- * do not provide selection data when defining output types.
1208
- */
1209
- mediaSlots: Omit<MediaSlot, 'selection'>[];
1210
- /**
1211
- * @beta
1212
- * The type of content being published. When set, Canva uses this to tailor and improve the
1213
- * publish experience. When omitted, defaults to `'content'` (generic behavior).
1214
- */
1215
- contentNoun?: ContentNoun;
1216
- };
1217
-
1218
- /**
1219
- * @beta
1220
- * Content summary for social media posts (e.g. Instagram, Facebook, LinkedIn, YouTube).
1221
- */
1222
- export declare type PostContentSummary = BaseContentSummary & {
1223
- type: 'post';
1224
- /** Post heading (e.g. YouTube title, LinkedIn article headline). */
1225
- title?: string;
1226
- /** Post caption or body text. */
1227
- body?: string;
1228
- /** Hashtags without the leading `#` (e.g. `["fashion", "design"]`). */
1229
- hashtags?: string[];
1230
- };
1231
-
1232
- /**
1233
- * @public
1234
- * Action to be taken after publishing completes successfully.
1235
- */
1236
- export declare type PostPublishAction = PostPublishActionRedirect;
1237
-
1238
- /**
1239
- * @public
1240
- * Redirect action to navigate the user to a URL after publishing.
1241
- *
1242
- * @example Redirecting to content editor
1243
- * ```ts
1244
- * const postPublishAction: PostPublishActionRedirect = {
1245
- * type: 'redirect',
1246
- * url: 'https://example.com/posts/12345/edit'
1247
- * };
1248
- * ```
1249
- */
1250
- export declare type PostPublishActionRedirect = {
1251
- type: 'redirect';
1252
- /**
1253
- * The URL to redirect the user to after publishing.
1254
- */
1255
- url: string;
1256
- };
1257
-
1258
- /**
1259
- * @beta
1260
- *
1261
- * Prepares a `ContentPublisherIntent`.
1262
- *
1263
- * @example
1264
- * ```tsx
1265
- * import { prepareContentPublisher } from "@canva/intents/content";
1266
- *
1267
- * prepareContentPublisher({
1268
- * getPublishConfiguration: async (params) => {
1269
- * // Implement the logic to get the publish configuration
1270
- * },
1271
- * renderSettingsUi: (params) => {
1272
- * // Implement the UI for settings view
1273
- * },
1274
- * renderPreviewUi: (params) => {
1275
- * // Implement the UI for preview view
1276
- * },
1277
- * publishContent: async (params) => {
1278
- * // Implement the logic to publish the content
1279
- * },
1280
- * });
1281
- * ```
1282
- */
1283
- export declare const prepareContentPublisher: (implementation: ContentPublisherIntent) => void;
1284
-
1285
- /**
1286
- * @beta
1287
- * Preview item for an image, video, document, or email.
1288
- *
1289
- * Check the `kind` and `status` properties to determine the type and state.
1290
- */
1291
- export declare type Preview = ImagePreview | VideoPreview | DocumentPreview | EmailPreview;
1292
-
1293
- /**
1294
- * @public
1295
- * Type of preview media.
1296
- */
1297
- export declare type PreviewKind = 'image' | 'video' | 'document' | 'email';
1298
-
1299
- /**
1300
- * @beta
1301
- * Preview media for a specific media slot.
1302
- *
1303
- * Contains preview URLs and metadata for images, videos, documents, or emails in the design.
1304
- */
1305
- export declare type PreviewMedia = {
1306
- /**
1307
- * ID of the media slot this preview belongs to.
1308
- *
1309
- * Matches a media slot ID from your output type definition.
1310
- */
1311
- mediaSlotId: string;
1312
- /**
1313
- * Array of preview items for this media slot.
1314
- *
1315
- * May contain multiple previews if the media slot accepts multiple files.
1316
- */
1317
- previews: Preview[];
1318
- };
1319
-
1320
- /**
1321
- * @public
1322
- * State of a preview item.
1323
- */
1324
- export declare type PreviewStatus = 'loading' | 'thumbnail' | 'upgrading' | 'ready' | 'error';
1325
-
1326
- /**
1327
- * @public
1328
- * Successful response from publishing a content.
1329
- *
1330
- * @example Basic successful publish
1331
- * ```ts
1332
- * return {
1333
- * status: 'completed',
1334
- * externalId: 'post_12345',
1335
- * externalUrl: 'https://example.com/posts/12345'
1336
- * };
1337
- * ```
1338
- *
1339
- * @example Successful publish with redirect
1340
- * ```ts
1341
- * return {
1342
- * status: 'completed',
1343
- * externalId: 'video_67890',
1344
- * externalUrl: 'https://example.com/videos/67890',
1345
- * postPublishAction: {
1346
- * type: 'redirect',
1347
- * url: 'https://example.com/videos/67890/edit'
1348
- * }
1349
- * };
1350
- * ```
1351
- */
1352
- export declare type PublishContentCompleted = {
1353
- status: 'completed';
1354
- /**
1355
- * Unique identifier returned from your external platform. You can use this for:
1356
- *
1357
- * - Tracking published content
1358
- * - Fetching insights data for the published content
1359
- * - Linking back to the content in future operations
1360
- */
1361
- externalId?: string;
1362
- /**
1363
- * Direct URL to the published content on your platform.
1364
- *
1365
- * Users can visit this URL to view their published content.
1366
- * This may be displayed to users or used for sharing.
1367
- */
1368
- externalUrl?: string;
1369
- /**
1370
- * Optional action to perform after publishing completes.
1371
- *
1372
- * Currently supports redirecting users to a specific URL after publishing.
1373
- */
1374
- postPublishAction?: PostPublishAction;
1375
- };
1376
-
1377
- /**
1378
- * @public
1379
- * Error response from publishing a content.
1380
- *
1381
- * Return the appropriate error type based on the failure:
1382
- *
1383
- * - `"remote_request_failed"`: Network or API errors with your platform
1384
- * - `"app_error"`: Custom application errors with optional message
1385
- */
1386
- export declare type PublishContentError = RemoteRequestFailedError | AppError;
1387
-
1388
- /**
1389
- * @public
1390
- * Parameters required for publishing the content.
1391
- * Contains all the information needed to send the content to your external platform.
1392
- */
1393
- export declare type PublishContentRequest = {
1394
- /**
1395
- * Platform-specific settings reference containing user configurations.
1396
- *
1397
- * This is the same reference you saved via `updatePublishSettings` in the settings UI.
1398
- * Parse this string to retrieve the user's publish settings (e.g., captions, tags, privacy).
1399
- *
1400
- * Maximum size: 32KB
1401
- */
1402
- publishRef?: string;
1403
- /**
1404
- * The output type selected by the user for this publish operation.
1405
- *
1406
- * This matches one of the output types you provided in `getPublishConfiguration`.
1407
- */
1408
- outputType: OutputTypeConfiguration;
1409
- /**
1410
- * Production-ready exported files matching the requirements from your output type.
1411
- *
1412
- * These files are ready to upload to your platform and match the format, size,
1413
- * and aspect ratio requirements specified in your media slots.
1414
- */
1415
- outputMedia: OutputMedia[];
1416
- };
1417
-
1418
- /**
1419
- * @public
1420
- * Response from a publish content operation.
1421
- *
1422
- * This can be either a successful completion or an error response.
1423
- */
1424
- export declare type PublishContentResponse = PublishContentCompleted | PublishContentError;
1425
-
1426
- /** @public */
1427
- export declare type PublishError = {
1428
- appDefinedPayload?: string;
1429
- };
1430
-
1431
- /**
1432
- * @public
1433
- * Signals that the publish error was cleared.
1434
- */
1435
- export declare type PublishErrorClearedSettingsUiContext = {
1436
- reason: 'publish_error_cleared';
1437
- };
1438
-
1439
- /**
1440
- * @public
1441
- * Provides information about an error that occurred in publishContent.
1442
- */
1443
- export declare type PublishErrorSettingsUiContext = {
1444
- reason: 'publish_error';
1445
- /**
1446
- * The error that occurred. Undefined means no error occurred or the previous
1447
- * error was cleared by Canva.
1448
- */
1449
- error: PublishError;
1450
- };
1451
-
1452
- /**
1453
- * @public
1454
- * Supported file formats for publishing.
1455
- */
1456
- export declare type PublishFileFormat = 'png' | 'jpg' | 'mp4' | 'pdf_standard' | 'html_bundle' | 'html_standalone';
1457
-
1458
- /**
1459
- * @beta
1460
- * Initial payload provided from cache.
1461
- */
1462
- export declare type PublishPreviewUiInvocationContext = {
1463
- /**
1464
- * Initial preview data and context provided when the preview UI is rendered.
1465
- */
1466
- reason: 'publish';
1467
- /**
1468
- * Initial preview media to display
1469
- * This will only be used for scheduling and not caching
1470
- */
1471
- previewMedia?: PreviewMedia[];
1472
- /** Information about the current output type being previewed */
1473
- outputType?: OutputType;
1474
- /** Current publish reference, if available */
1475
- publishRef?: string;
1476
- };
1477
-
1478
- /**
1479
- * @public
1480
- * Validation state indicating whether publish settings are complete and valid.
1481
- */
1482
- export declare type PublishRefValidityState = 'valid' | 'invalid_missing_required_fields' | 'invalid_authentication_required';
1483
-
1484
- /**
1485
- * @public
1486
- * Configuration for publish settings.
1487
- *
1488
- * Contains the user's settings and their validation state. Use this to
1489
- * control whether the publish button is enabled.
1490
- */
1491
- export declare type PublishSettings = {
1492
- /**
1493
- * Serialized platform-specific settings for publishing.
1494
- *
1495
- * Store all information your app needs to publish the content in this string.
1496
- * This might include:
1497
- *
1498
- * - Captions or descriptions
1499
- * - Tags or hashtags
1500
- * - Privacy settings
1501
- * - Publishing destination (account, page, etc.)
1502
- * - Scheduling information
1503
- *
1504
- * This reference will be provided to your `publishContent` method when publishing.
1505
- *
1506
- * Maximum size: 32KB
1507
- *
1508
- * @example Serializing settings
1509
- * ```ts
1510
- * const settings = {
1511
- * caption: 'Check out my design!',
1512
- * tags: ['design', 'creative'],
1513
- * privacy: 'public'
1514
- * };
1515
- * const publishRef = JSON.stringify(settings);
1516
- * ```
1517
- */
1518
- publishRef?: string;
1519
- /**
1520
- * Validation state of the publish settings.
1521
- *
1522
- * Controls whether the publish button is enabled:
1523
- *
1524
- * - `"valid"`: Settings are complete and valid, publish button is enabled
1525
- * - `"invalid_missing_required_fields"`: Required settings are missing, publish button is disabled
1526
- * - `"invalid_authentication_required"`: User must authenticate before publishing can proceed
1527
- */
1528
- validityState: PublishRefValidityState;
1529
- };
1530
-
1531
- /**
1532
- * @public
1533
- * Provides information about the current state of the settings UI to help
1534
- * you adapt the interface based on the selected output type.
1535
- */
1536
- export declare type PublishSettingsSettingsUiContext = {
1537
- reason: 'publish_settings';
1538
- /**
1539
- * The currently selected output type.
1540
- *
1541
- * Use this to customize your settings UI based on the requirements
1542
- * of different output types.
1543
- */
1544
- outputType: OutputType;
1545
- };
1546
-
1547
- /**
1548
- * @public
1549
- * Initial payload provided from cache.
1550
- */
1551
- export declare type PublishSettingsUiInvocationContext = {
1552
- /**
1553
- * Initial settings and context provided when the settings UI is rendered.
1554
- */
1555
- reason: 'publish';
1556
- /** Current publish reference to populate the UI, if any exist */
1557
- publishRef?: string;
1558
- /** Information about the current output type being configured */
1559
- outputType?: OutputType;
1560
- };
1561
-
1562
- /**
1563
- * @public
1564
- * {@link PublishContentError} indicating failure of the remote request to the external platform.
1565
- *
1566
- * Return this error for:
1567
- *
1568
- * - Network connectivity issues
1569
- * - API endpoint failures
1570
- * - HTTP errors from your platform
1571
- * - Timeout errors
1572
- *
1573
- * @example Handling network errors
1574
- * ```ts
1575
- * try {
1576
- * await uploadToExternalPlatform(file);
1577
- * } catch (error) {
1578
- * return { status: 'remote_request_failed' };
1579
- * }
1580
- * ```
1581
- */
1582
- export declare type RemoteRequestFailedError = {
1583
- status: 'remote_request_failed';
1584
- };
1585
-
1586
- /**
1587
- * @beta
1588
- * Initial payload provided when the preview UI is rendered.
1589
- * Contains the preview data and settings needed to initialize the preview interface.
1590
- */
1591
- export declare type RenderPreviewUiInvocationContext = PublishPreviewUiInvocationContext;
1592
-
1593
- /**
1594
- * @beta
1595
- * Configuration required for rendering the preview UI.
1596
- *
1597
- * Provides callbacks for managing preview media and responding to preview updates.
1598
- */
1599
- export declare type RenderPreviewUiRequest = {
1600
- /**
1601
- * @beta
1602
- * The initial preview data and context provided when the preview UI is rendered.
1603
- *
1604
- * Contains the initial preview media, output type information, and any existing
1605
- * publish settings needed to properly display the preview interface.
1606
- */
1607
- invocationContext: RenderPreviewUiInvocationContext;
1608
- /**
1609
- * Callback to upgrade thumbnail previews to their full media variant.
1610
- *
1611
- * Call this function when you need full previews instead of lightweight thumbnails.
1612
- * This helps optimize performance by deferring full media loading until needed.
1613
- *
1614
- * Upgrades may complete asynchronously; listen to `registerOnPreviewChange` for updates
1615
- * to receive the upgraded previews.
1616
- *
1617
- * @param previewIds - Array of preview IDs to upgrade from thumbnail to full media
1618
- *
1619
- * @example Upgrading previews on user interaction
1620
- * ```ts
1621
- * // When user clicks on a video thumbnail, upgrade to full video
1622
- * if (preview.kind === 'video' && preview.status === 'thumbnail') {
1623
- * requestPreviewUpgrade([preview.id]);
1624
- * }
1625
- * ```
1626
- */
1627
- requestPreviewUpgrade: (previewIds: string[]) => void;
1628
- /**
1629
- * Registers a callback to be invoked when preview data changes.
1630
- *
1631
- * This callback is triggered when:
1632
- *
1633
- * - The design content changes
1634
- * - The output type changes
1635
- * - Preview media is upgraded from thumbnail to full media
1636
- * - Export settings are modified
1637
- *
1638
- * Use this to update your preview UI in real-time as users modify their design.
1639
- *
1640
- * @param callback - The callback invoked when preview data is updated
1641
- * @returns A disposer function that cleans up the registered callback
1642
- *
1643
- * @example Handling preview updates
1644
- * ```ts
1645
- * const disposer = registerOnPreviewChange(({ previewMedia, outputType, publishRef }) => {
1646
- * // Update your preview UI with the new preview media
1647
- * previewMedia.forEach((media) => {
1648
- * media.previews.forEach((preview) => {
1649
- * if (preview.status === 'ready') {
1650
- * displayPreview(preview);
1651
- * }
1652
- * });
1653
- * });
1654
- * });
1655
- *
1656
- * // Clean up when preview UI is unmounted
1657
- * onUnmount(() => disposer());
1658
- * ```
1659
- */
1660
- registerOnPreviewChange: (callback: (opts: {
1661
- previewMedia: PreviewMedia[];
1662
- /** The output type that the preview data is for */
1663
- outputType: OutputType;
1664
- /** The current publish settings reference, if available */
1665
- publishRef?: string;
1666
- }) => void) => Disposer;
1667
- };
1668
-
1669
- /**
1670
- * @public
1671
- * Initial payload provided when the publish settings UI is rendered.
1672
- * Contains the current settings state needed to initialize the settings interface.
1673
- */
1674
- export declare type RenderSettingsUiInvocationContext = PublishSettingsUiInvocationContext;
1675
-
1676
- /**
1677
- * @public
1678
- * Configuration for the publish settings UI.
1679
- *
1680
- * This type provides the necessary callbacks and configuration for rendering
1681
- * a custom publish settings interface where users configure platform-specific options.
1682
- */
1683
- export declare type RenderSettingsUiRequest = {
1684
- /**
1685
- * @public
1686
- * The initial settings and context provided when the settings UI is rendered.
1687
- *
1688
- * Contains any previously saved publish settings and information about the current output type being configured.
1689
- * Use this to restore the UI to its previous state or initialise it with appropriate defaults.
1690
- */
1691
- invocationContext: RenderSettingsUiInvocationContext;
1692
- /**
1693
- * Callback to save and validate the user's publish settings.
1694
- *
1695
- * Call this function whenever the user modifies their settings to:
1696
- *
1697
- * - Save the settings for later use in `publishContent`
1698
- * - Validate that required fields are filled
1699
- * - Enable or disable the publish button based on validity
1700
- *
1701
- * Store all necessary publishing information in the `publishRef` string.
1702
- * This will be provided to your `publishContent` method when the user publishes.
1703
- *
1704
- * @param settings - The new publish settings to save
1705
- * @returns A promise that resolves when the settings are successfully saved
1706
- * @throws Will throw `CanvaError('bad_request')` if {@link PublishSettings.publishRef} exceeds 32KB.
1707
- *
1708
- * @example Updating settings as user types
1709
- * ```ts
1710
- * // As user fills in form fields, update settings
1711
- * function handleCaptionChange(caption: string) {
1712
- * const settings = { caption, tags: currentTags };
1713
- * const publishRef = JSON.stringify(settings);
1714
- *
1715
- * updatePublishSettings({
1716
- * publishRef,
1717
- * validityState: caption ? 'valid' : 'invalid_missing_required_fields'
1718
- * });
1719
- * }
1720
- * ```
1721
- */
1722
- updatePublishSettings: (publishSettings: PublishSettings) => Promise<UpdatePublishSettingsResponse>;
1723
-
1724
- /**
1725
- * Registers a callback to be invoked when the settings UI context changes.
1726
- *
1727
- * This callback is triggered when:
1728
- * - the user changes the output type in the publish flow.
1729
- * - an error occurs in the publish flow.
1730
- *
1731
- * Use this to respond to Canva changes and update your settings UI accordingly.
1732
- *
1733
- * @param opts - The options for registering a callback.
1734
- * @returns A disposer function that cleans up the registered callback.
1735
- *
1736
- * @example Adapting UI for different output types
1737
- * ```ts
1738
- * registerOnContextChange({
1739
- * onContextChange: (ctx) => {
1740
- * if (ctx.reason === 'publish_settings') {
1741
- * if (ctx.outputType.id === 'instagram_post') {
1742
- * showHashtagField();
1743
- * }
1744
- * }
1745
- * if (ctx.reason === 'publish_error') {
1746
- * setError(ctx.error);
1747
- * }
1748
- * }
1749
- * });
1750
- * ```
1751
- */
1752
- registerOnContextChange: (opts: {
1753
- onContextChange: OnContextChange;
1754
- }) => Disposer;
1755
- /**
1756
- * @beta
1757
- * Function to trigger a request for AI content.
1758
- *
1759
- * Use this function to trigger a request for AI content.
1760
- *
1761
- * @param request - The request for AI content.
1762
- * @returns A promise resolving to the AI content response with a status of 'completed' or 'cancelled'.
1763
- * @example Requesting AI content
1764
- * ```ts
1765
- * async function onGenerateCaption() {
1766
- * const result = await requestAiContent({
1767
- * type: 'social_caption',
1768
- * currentValue: settings.caption,
1769
- * fieldLabel: 'Caption',
1770
- * hints: {
1771
- * maxLength: 2200,
1772
- * },
1773
- * });
1774
- *
1775
- * if (result.status !== 'completed') {
1776
- * return;
1777
- * }
1778
- * const nextSettings = { ...settings, caption: result.value };
1779
- * // ... set local state
1780
- * await updatePublishSettings({
1781
- * publishRef: JSON.stringify(nextSettings),
1782
- * validityState: 'valid',
1783
- * });
1784
- * }
1785
- * ```
1786
- */
1787
- requestAiContent: RequestAiContent;
1788
- };
1789
-
1790
- /**
1791
- * @beta
1792
- * Function to trigger a request for AI content.
1793
- */
1794
- export declare type RequestAiContent = (request: AiContentRequest) => Promise<AiContentResponse>;
1795
-
1796
- /**
1797
- * @public
1798
- * Metadata specific to design content represented by a media selection.
1799
- */
1800
- export declare interface SelectionDesignMetadata {
1801
- type: 'design';
1802
- /**
1803
- * A signed JWT token containing the design id
1804
- */
1805
- designToken: string;
1806
- /**
1807
- * The user given title of the design
1808
- */
1809
- title: string | undefined;
1810
- }
1811
-
1812
- /**
1813
- * @public
1814
- * Metadata about the source content represented by a media selection.
1815
- */
1816
- export declare type SelectionMetadata = SelectionDesignMetadata;
1817
-
1818
- /**
1819
- * @public
1820
- * Context information for the publish settings UI.
1821
- */
1822
- export declare type SettingsUiContext = PublishSettingsSettingsUiContext | PublishErrorSettingsUiContext | PublishErrorClearedSettingsUiContext;
1823
-
1824
- /**
1825
- * @public
1826
- * Base interface for all preview types that have a fixed width and height.
1827
- */
1828
- export declare interface SizedPreview extends BasePreview {
1829
- /**
1830
- * Width of the preview in pixels.
1831
- */
1832
- widthPx: number;
1833
- /**
1834
- * Height of the preview in pixels.
1835
- */
1836
- heightPx: number;
1837
- }
1838
-
1839
- /**
1840
- * @beta
1841
- * Request for social caption generation.
1842
- */
1843
- export declare type SocialCaptionRequest = BaseAiContentRequest & {
1844
- type: 'social_caption';
1845
- /**
1846
- * Hints for how the AI should generate the caption.
1847
- */
1848
- hints?: {
1849
- /**
1850
- * The maximum length of the caption.
1851
- */
1852
- maxLength?: number;
1853
- };
1854
- };
1855
-
1856
- /**
1857
- * @public
1858
- * Successful response from updating the publish settings.
1859
- */
1860
- export declare type UpdatePublishSettingsCompleted = {
1861
- status: 'completed';
1862
- };
1863
-
1864
- /**
1865
- * @public
1866
- * Response from updating the publish settings.
1867
- */
1868
- export declare type UpdatePublishSettingsResponse = UpdatePublishSettingsCompleted;
1869
-
1870
- /**
1871
- * @public
1872
- * Numeric value range constraint.
1873
- * Used to specify requirements for aspect ratios, durations, file counts, etc.
1874
- */
1875
- export declare type ValueRange = ExactValueRange | MinValueRange | MaxValueRange | MinMaxValueRange;
1876
-
1877
- /**
1878
- * @public
1879
- * Exported video file ready for publishing.
1880
- */
1881
- export declare interface VideoOutputFile extends BaseOutputFile {
1882
- /**
1883
- * Width of the video in pixels.
1884
- */
1885
- widthPx: number;
1886
- /**
1887
- * Height of the video in pixels.
1888
- */
1889
- heightPx: number;
1890
- }
1891
-
1892
- /**
1893
- * @public
1894
- * Video preview in various states.
1895
- *
1896
- * Videos transition through states: `"loading"` → `"thumbnail"` → `"upgrading"` → `"ready"`.
1897
- * Start with thumbnails for better performance, then upgrade to full video using `requestPreviewUpgrade`.
1898
- */
1899
- export declare type VideoPreview = VideoPreviewLoading | VideoPreviewThumbnail | VideoPreviewUpgrading | VideoPreviewReady | VideoPreviewError;
1900
-
1901
- /**
1902
- * @public
1903
- * Video preview that failed to generate.
1904
- *
1905
- * Display an error state to the user.
1906
- */
1907
- export declare interface VideoPreviewError extends SizedPreview {
1908
- kind: 'video';
1909
- status: 'error';
1910
-
1911
- /**
1912
- * The error message to display to the user.
1913
- */
1914
- message: string;
1915
- }
1916
-
1917
- /**
1918
- * @public
1919
- * Video preview that is currently being generated.
1920
- *
1921
- * Display a loading state until the preview transitions to `"thumbnail"` or `"error"`.
1922
- */
1923
- export declare interface VideoPreviewLoading extends SizedPreview {
1924
- kind: 'video';
1925
- status: 'loading';
1926
- /**
1927
- * Video duration in milliseconds.
1928
- */
1929
- durationMs?: number;
1930
- }
1931
-
1932
- /**
1933
- * @public
1934
- * Video preview with full video ready to play.
1935
- *
1936
- * Contains URLs for both the video and thumbnail.
1937
- */
1938
- export declare interface VideoPreviewReady extends SizedPreview {
1939
- kind: 'video';
1940
- status: 'ready';
1941
- /**
1942
- * Video format.
1943
- */
1944
- format: 'mp4';
1945
- /**
1946
- * URL to the full video.
1947
- *
1948
- * Use this URL in a video player.
1949
- */
1950
- url: string;
1951
- /**
1952
- * Format of the thumbnail image.
1953
- */
1954
- thumbnailFormat: 'png' | 'jpg';
1955
- /**
1956
- * URL to the thumbnail image.
1957
- *
1958
- * Can be used as a poster image for the video player.
1959
- */
1960
- thumbnailUrl: string;
1961
- /**
1962
- * Video duration in milliseconds.
1963
- */
1964
- durationMs?: number;
1965
- }
1966
-
1967
- /**
1968
- * @public
1969
- * Video preview with lightweight thumbnail available.
1970
- *
1971
- * This is the initial state for video previews. Show the thumbnail image
1972
- * and call `requestPreviewUpgrade` when the user needs the full video.
1973
- */
1974
- export declare interface VideoPreviewThumbnail extends SizedPreview {
1975
- kind: 'video';
1976
- status: 'thumbnail';
1977
- /**
1978
- * Format of the thumbnail image.
1979
- */
1980
- thumbnailFormat: 'png' | 'jpg';
1981
- /**
1982
- * URL to the thumbnail image.
1983
- *
1984
- * Display this lightweight image until full video is needed.
1985
- */
1986
- thumbnailUrl: string;
1987
- /**
1988
- * Video duration in milliseconds.
1989
- */
1990
- durationMs?: number;
1991
- }
1992
-
1993
- /**
1994
- * @public
1995
- * Video preview that is being upgraded from thumbnail to full video.
1996
- *
1997
- * Display the thumbnail with a loading indicator until the video is ready.
1998
- */
1999
- export declare interface VideoPreviewUpgrading extends SizedPreview {
2000
- kind: 'video';
2001
- status: 'upgrading';
2002
- /**
2003
- * Format of the thumbnail image.
2004
- */
2005
- thumbnailFormat: 'png' | 'jpg';
2006
- /**
2007
- * URL to the thumbnail image.
2008
- *
2009
- * Continue showing the thumbnail while the full video loads.
2010
- */
2011
- thumbnailUrl: string;
2012
- /**
2013
- * Video duration in milliseconds.
2014
- */
2015
- durationMs?: number;
2016
- }
2017
-
2018
- /**
2019
- * @public
2020
- * Video file requirements for a media slot.
2021
- *
2022
- * Specifies format, aspect ratio, duration, and size constraints for videos.
2023
- *
2024
- * @example Video requirements for YouTube
2025
- * ```ts
2026
- * const videoReq: VideoRequirement = {
2027
- * format: 'mp4',
2028
- * aspectRatio: { exact: 16/9 },
2029
- * durationMs: { min: 1000, max: 600000 },
2030
- * };
2031
- * ```
2032
- */
2033
- export declare interface VideoRequirement extends BaseFileRequirement {
2034
- /**
2035
- * Supported video format.
2036
- */
2037
- format: 'mp4';
2038
- /**
2039
- * Aspect ratio constraint (width / height).
2040
- *
2041
- * Examples:
2042
- * - `{ exact: 16/9 }`: Widescreen
2043
- * - `{ exact: 9/16 }`: Vertical/Story format
2044
- */
2045
- aspectRatio?: ValueRange;
2046
- /**
2047
- * Duration constraint in milliseconds.
2048
- *
2049
- * Examples:
2050
- * - `{ max: 60000 }`: Maximum 60 seconds
2051
- * - `{ min: 3000, max: 600000 }`: Between 3 seconds and 10 minutes
2052
- */
2053
- durationMs?: ValueRange;
2054
-
2055
- }
2056
-
2057
- /**
2058
- * @public
2059
- * Selection metadata for a video media item.
2060
- */
2061
- export declare interface VideoSelection extends BaseSelection {
2062
- kind: 'video';
2063
- /**
2064
- * Duration of the selected video in milliseconds.
2065
- */
2066
- durationMs: number;
2067
- }
2068
-
2069
- export { }