@canva/intents 2.2.1-beta.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/CHANGELOG.md +25 -13
  2. package/asset/index.d.ts +1 -1
  3. package/content/index.d.ts +1618 -1
  4. package/data/index.d.ts +1229 -1
  5. package/design/index.d.ts +41 -1
  6. package/index.d.ts +2994 -1
  7. package/lib/cjs/sdk/intents/asset/index.js +1 -15
  8. package/lib/cjs/sdk/intents/fake/{create_beta.js → create.js} +6 -9
  9. package/lib/cjs/sdk/intents/index.js +4 -2
  10. package/lib/cjs/sdk/intents/test/index.js +14 -13
  11. package/lib/cjs/sdk/intents/version.js +2 -2
  12. package/lib/esm/sdk/intents/asset/index.js +1 -1
  13. package/lib/esm/sdk/intents/fake/{create_beta.js → create.js} +4 -7
  14. package/lib/esm/sdk/intents/index.js +3 -1
  15. package/lib/esm/sdk/intents/test/index.js +9 -1
  16. package/lib/esm/sdk/intents/version.js +2 -2
  17. package/package.json +23 -23
  18. package/test/index.d.ts +11 -1
  19. package/asset/beta.d.ts +0 -190
  20. package/beta.d.ts +0 -2983
  21. package/content/beta.d.ts +0 -1608
  22. package/data/beta.d.ts +0 -1229
  23. package/design/beta.d.ts +0 -41
  24. package/lib/cjs/sdk/intents/asset/beta.js +0 -13
  25. package/lib/cjs/sdk/intents/beta.js +0 -20
  26. package/lib/cjs/sdk/intents/content/beta.js +0 -20
  27. package/lib/cjs/sdk/intents/data/beta.js +0 -20
  28. package/lib/cjs/sdk/intents/design/beta.js +0 -20
  29. package/lib/cjs/sdk/intents/test/beta.js +0 -19
  30. package/lib/esm/sdk/intents/asset/beta.js +0 -3
  31. package/lib/esm/sdk/intents/beta.js +0 -3
  32. package/lib/esm/sdk/intents/content/beta.js +0 -3
  33. package/lib/esm/sdk/intents/data/beta.js +0 -3
  34. package/lib/esm/sdk/intents/design/beta.js +0 -3
  35. package/lib/esm/sdk/intents/test/beta.js +0 -9
  36. package/test/beta.d.ts +0 -11
@@ -1 +1,1618 @@
1
- export * from "./beta";
1
+ /**
2
+ * @public
3
+ * {@link PublishContentError} indicating a custom error occurred in your app's implementation.
4
+ *
5
+ * Return this for application-specific errors such as:
6
+ *
7
+ * - Validation failures
8
+ * - Authentication errors
9
+ * - Rate limiting
10
+ * - Platform-specific restrictions
11
+ *
12
+ * @example Returning custom error with message
13
+ * ```ts
14
+ * if (userQuotaExceeded) {
15
+ * return {
16
+ * status: 'app_error',
17
+ * message: 'You have reached your monthly publish limit. Please upgrade your plan.'
18
+ * };
19
+ * }
20
+ * ```
21
+ */
22
+ export declare type AppError = {
23
+ status: 'app_error';
24
+ /**
25
+ * (required) The raw error message, for logging purposes. It will not display in the UI.
26
+ * To display custom error messages in the UI use `localizedMessageId`.
27
+ *
28
+ * This should typically be the javascript error.message or a REST JSON error message
29
+ * body passed without modification.
30
+ *
31
+ * WARNING: Do not include personally identifiable information (PII) in this
32
+ * message, such as names, emails, usernames, etc.
33
+ */
34
+ message: string;
35
+ /**
36
+ * (optional) Message ID of the translated error message that will be
37
+ * displayed to the user. The message ID should be present and uploaded in
38
+ * your translation file. If omitted, Canva will display a generic error
39
+ * message.
40
+ */
41
+ localizedMessageId?: string;
42
+ /** HTTP status code, if applicable */
43
+ httpCode?: number;
44
+ /**
45
+ * Used only by app developer. Canva does not use this value. Use this to pass
46
+ * additional information like JSON to your settings frame.
47
+ */
48
+ appDefinedPayload?: string;
49
+ /**
50
+ * (optional) Source of the error if it relates to a component on the Canva
51
+ * UI. When present, the error may render near a relevant Canva component.
52
+ * When omitted, the cause is considered unspecified or "generic".
53
+ */
54
+ errorCause?: ErrorCause;
55
+ };
56
+
57
+ /**
58
+ * @public
59
+ * Base file requirement interface.
60
+ */
61
+ declare interface BaseFileRequirement {
62
+ /**
63
+ * File format for this requirement.
64
+ */
65
+ format: PublishFileFormat;
66
+
67
+ }
68
+
69
+ /**
70
+ * @public
71
+ * Base interface for exported files.
72
+ */
73
+ export declare interface BaseOutputFile {
74
+ /**
75
+ * File format.
76
+ */
77
+ format: PublishFileFormat;
78
+ /**
79
+ * URL to download the exported file.
80
+ *
81
+ * Your app should download from this URL and upload to your platform.
82
+ */
83
+ url: string;
84
+ /**
85
+ * Metadata about the source content used to create this exported file.
86
+ */
87
+ contentMetadata: ContentMetadata;
88
+ }
89
+
90
+ /**
91
+ * @public
92
+ * Base interface for all preview types.
93
+ *
94
+ * Contains common properties shared by all preview types.
95
+ */
96
+ export declare interface BasePreview {
97
+ /**
98
+ * Unique identifier for this preview.
99
+ *
100
+ * Use this ID with `requestPreviewUpgrade` to upgrade video thumbnails.
101
+ */
102
+ id: string;
103
+ /**
104
+ * Type of media in this preview.
105
+ */
106
+ kind: PreviewKind;
107
+ /**
108
+ * Current state of the preview.
109
+ */
110
+ status: PreviewStatus;
111
+ }
112
+
113
+ /**
114
+ * @public
115
+ * Metadata about the source content used to create an exported file.
116
+ */
117
+ export declare type ContentMetadata = DesignContentMetadata;
118
+
119
+ /**
120
+ * @public
121
+ * Main interface for implementing the ContentPublisher intent.
122
+ *
123
+ * Implementing the ContentPublisher intent enables apps to publish contents to external platforms.
124
+ * This allows users to configure publish settings, preview their designs, and share with others.
125
+ *
126
+ * The publishing flow follows this process:
127
+ *
128
+ * 1. User initiates publish action
129
+ * 2. Your app provides publish configuration via `getPublishConfiguration`
130
+ * 3. User selects an output type
131
+ * 4. Your app renders settings UI via `renderSettingsUi`
132
+ * 5. Your app renders preview UI via `renderPreviewUi`
133
+ * 6. User reviews settings and preview
134
+ * 7. Your app publishes the content via `publishContent`
135
+ */
136
+ export declare type ContentPublisherIntent = {
137
+ /**
138
+ * Provides the configuration for the publishing platform.
139
+ *
140
+ * This action is called when the user initiates the publish flow and needs to
141
+ * select an output type for the target platform.
142
+ *
143
+ * Use this to define different publishing configurations for your platform,
144
+ * such as social media posts, videos, or other output types.
145
+ *
146
+ * @returns A promise resolving to the publish configuration or an error
147
+ *
148
+ * @example Defining publish configuration for a social media platform
149
+ * ```ts
150
+ * import type { GetPublishConfigurationResponse } from '@canva/intents/content';
151
+ *
152
+ * async function getPublishConfiguration(): Promise<GetPublishConfigurationResponse> {
153
+ * return {
154
+ * status: 'completed',
155
+ * outputTypes: [
156
+ * {
157
+ * id: 'instagram_post',
158
+ * displayName: 'Instagram Post',
159
+ * mediaSlots: [
160
+ * {
161
+ * id: 'main_image',
162
+ * displayName: 'Post Image',
163
+ * fileCount: { min: 1, max: 10 },
164
+ * accepts: {
165
+ * image: { format: 'jpg', aspectRatio: { min: 0.8, max: 1.91 } }
166
+ * }
167
+ * }
168
+ * ]
169
+ * }
170
+ * ]
171
+ * };
172
+ * }
173
+ * ```
174
+ */
175
+ getPublishConfiguration: () => Promise<GetPublishConfigurationResponse>;
176
+
177
+ /**
178
+ * Renders a user interface for configuring publish settings.
179
+ *
180
+ * This action is called after the user selects an output type. Your UI should
181
+ * allow users to configure platform-specific settings such as captions, tags,
182
+ * privacy settings, or publishing destinations.
183
+ *
184
+ * Use the `updatePublishSettings` callback to save user settings and validate them.
185
+ * Settings are stored in the `publishRef` string (maximum 5KB).
186
+ *
187
+ * @param request - Configuration and callbacks for the publish settings UI.
188
+ *
189
+ * @example Rendering a settings UI with publish configuration
190
+ * ```ts
191
+ * import { createRoot } from 'react-dom/client';
192
+ * import type { RenderSettingsUiRequest } from '@canva/intents/content';
193
+ *
194
+ * function renderSettingsUi(request: RenderSettingsUiRequest): void {
195
+ * const SettingsUiApp = () => (
196
+ * <AppUiProvider>
197
+ * <SettingsUi request={request} />
198
+ * </AppUiProvider>
199
+ * );
200
+ *
201
+ * createRoot().render(<SettingsUiApp />)
202
+ * }
203
+ * ```
204
+ */
205
+ renderSettingsUi: (request: RenderSettingsUiRequest) => void;
206
+ /**
207
+ * Renders a user interface for previewing the content.
208
+ *
209
+ * This action is called after the settings UI is rendered. Your UI should display
210
+ * a preview of how the content will appear on the target platform.
211
+ *
212
+ * Previews update dynamically as users modify their content or settings. For videos,
213
+ * start with lightweight thumbnails and use `requestPreviewUpgrade` to load full
214
+ * video previews on demand to optimize performance.
215
+ *
216
+ * @param request - Configuration and callbacks for the preview UI.
217
+ *
218
+ * @example Rendering a preview UI with video optimization
219
+ * ```ts
220
+ * import { createRoot } from 'react-dom/client';
221
+ * import type { RenderPreviewUiRequest } from '@canva/intents/content';
222
+ *
223
+ * function renderPreviewUi(request: RenderPreviewUiRequest): void {
224
+ * const PreviewUiApp = () => (
225
+ * <AppUiProvider>
226
+ * <PreviewUi request={request} />
227
+ * </AppUiProvider>
228
+ * );
229
+ *
230
+ * createRoot().render(<PreviewUiApp />)
231
+ * }
232
+ * ```
233
+ */
234
+ renderPreviewUi: (request: RenderPreviewUiRequest) => void;
235
+ /**
236
+ * Publishes the content to the external platform.
237
+ *
238
+ * This action is called when the user confirms the publish action after reviewing
239
+ * settings and preview. Your implementation should send the exported files
240
+ * to your platform's API.
241
+ *
242
+ * The `outputMedia` contains production-ready files that match the requirements
243
+ * specified in your output types. The `publishRef` contains the user's settings
244
+ * from the settings UI.
245
+ *
246
+ * @param request - Parameters for the publish operation.
247
+ * @returns A promise resolving to either a successful result with the published content details or an error.
248
+ *
249
+ * @example Publishing content to an external platform
250
+ * ```ts
251
+ * import type { PublishContentRequest, PublishContentResponse } from '@canva/intents/content';
252
+ *
253
+ * async function publishContent(request: PublishContentRequest): Promise<PublishContentResponse> {
254
+ * const { publishRef, outputType, outputMedia } = request;
255
+ *
256
+ * try {
257
+ * // Parse settings from publishRef
258
+ * const settings = publishRef ? JSON.parse(publishRef) : {};
259
+ *
260
+ * // Upload files to your platform
261
+ * const uploadedFiles = await Promise.all(
262
+ * outputMedia.flatMap(media =>
263
+ * media.files.map(file => uploadFile(file.url))
264
+ * )
265
+ * );
266
+ *
267
+ * // Create post on your platform
268
+ * const result = await createPost({
269
+ * files: uploadedFiles,
270
+ * caption: settings.caption
271
+ * });
272
+ *
273
+ * return {
274
+ * status: 'completed',
275
+ * externalId: result.id,
276
+ * externalUrl: result.url
277
+ * };
278
+ * } catch (error) {
279
+ * return {
280
+ * status: 'remote_request_failed'
281
+ * };
282
+ * }
283
+ * }
284
+ * ```
285
+ */
286
+ publishContent: (request: PublishContentRequest) => Promise<PublishContentResponse>;
287
+
288
+ };
289
+
290
+ /**
291
+ * @public
292
+ * Metadata specific to design content.
293
+ */
294
+ export declare interface DesignContentMetadata {
295
+ type: 'design';
296
+ /**
297
+ * A signed JWT token containing the design id
298
+ */
299
+ designToken: string;
300
+ /**
301
+ * The user given title of the design
302
+ */
303
+ title: string | undefined;
304
+ /**
305
+ * The pages that make up the exported metadata
306
+ */
307
+ pages: OutputPageMetadata[];
308
+ }
309
+
310
+ /**
311
+ * @public
312
+ * A function that can be called to dispose of a callback.
313
+ */
314
+ export declare type Disposer = () => void;
315
+
316
+ /**
317
+ * @public
318
+ * Exported PDF file ready for publishing.
319
+ *
320
+ * Contains the final PDF document that should be uploaded to your platform.
321
+ * The document format is `pdf_standard` and the file is ready to use.
322
+ */
323
+ export declare type DocumentOutputFile = BaseOutputFile;
324
+
325
+ /**
326
+ * @public
327
+ * Document preview in various states.
328
+ *
329
+ * Documents transition through states: `"loading"` → `"thumbnail"`.
330
+ * Start with a lightweight thumbnail of the first page for quick preview rendering.
331
+ */
332
+ export declare type DocumentPreview = DocumentPreviewLoading | DocumentPreviewThumbnail | DocumentPreviewError;
333
+
334
+ /**
335
+ * @public
336
+ * Document preview that failed to generate.
337
+ *
338
+ * Display an error state to the user.
339
+ */
340
+ export declare interface DocumentPreviewError extends SizedPreview {
341
+ kind: 'document';
342
+ status: 'error';
343
+ /**
344
+ * The error message to display to the user.
345
+ */
346
+ message: string;
347
+ }
348
+
349
+ /**
350
+ * @public
351
+ * Document preview that is currently being generated.
352
+ *
353
+ * Display a loading state until the preview transitions to `"thumbnail"` or `"error"`.
354
+ */
355
+ export declare interface DocumentPreviewLoading extends SizedPreview {
356
+ kind: 'document';
357
+ status: 'loading';
358
+ }
359
+
360
+ /**
361
+ * @public
362
+ * Document preview with first page thumbnail available.
363
+ *
364
+ * This is the initial state for document previews. Show the thumbnail image
365
+ * of the first page along with the page count to give users a preview of
366
+ * the document before publishing.
367
+ */
368
+ export declare interface DocumentPreviewThumbnail extends SizedPreview {
369
+ kind: 'document';
370
+ status: 'thumbnail';
371
+ /**
372
+ * Format of the thumbnail image.
373
+ */
374
+ thumbnailFormat: 'png' | 'jpg';
375
+ /**
376
+ * URL to the first page thumbnail.
377
+ *
378
+ * Display this lightweight image to preview the document content.
379
+ */
380
+ thumbnailUrl: string;
381
+ }
382
+
383
+ /**
384
+ * @public
385
+ * Document file requirements for a media slot.
386
+ *
387
+ * Note: Document output types use image previews (PNG thumbnails) in the preview UI.
388
+ * The actual document file is only generated for the final output in OutputMedia.
389
+ *
390
+ * @example Document requirements
391
+ * ```ts
392
+ * const documentReq: DocumentRequirement = {
393
+ * format: 'pdf_standard',
394
+ * size: 'a4',
395
+ * };
396
+ * ```
397
+ */
398
+ export declare interface DocumentRequirement extends BaseFileRequirement {
399
+ /**
400
+ * Supported document export format.
401
+ * Currently supports PDF standard format.
402
+ */
403
+ format: 'pdf_standard';
404
+ /**
405
+ * The document size of the export file.
406
+ */
407
+ size: DocumentSize;
408
+ }
409
+
410
+ /**
411
+ * @public
412
+ * Selection metadata for a document media item.
413
+ */
414
+ export declare type DocumentSelection = {
415
+ kind: 'document';
416
+ };
417
+
418
+ /**
419
+ * @public
420
+ * Document size for document exports.
421
+ */
422
+ export declare type DocumentSize = 'a4' | 'a3' | 'letter' | 'legal';
423
+
424
+ /**
425
+ * Email preview stub used before beta preview type is fully supported.
426
+ */
427
+ declare interface EmailPreviewStub extends BasePreview {
428
+ kind: 'email';
429
+ }
430
+
431
+ /**
432
+ * @public
433
+ * Selection metadata for an email media item.
434
+ */
435
+ export declare type EmailSelection = {
436
+ kind: 'email';
437
+ };
438
+
439
+ /**
440
+ * @public
441
+ *
442
+ * The cause of an error
443
+ */
444
+ export declare type ErrorCause = 'invalid_selection' | 'invalid_format';
445
+
446
+ /**
447
+ * @public
448
+ * Exact value range constraint.
449
+ * @example Exact value range
450
+ * ```ts
451
+ * const exactValue: ValueRange = { exact: 1 }; // Must be exactly 1
452
+ * ```
453
+ */
454
+ export declare type ExactValueRange = {
455
+ exact: number;
456
+ };
457
+
458
+ /**
459
+ * @public
460
+ * Successful response from getting publish configuration.
461
+ */
462
+ export declare type GetPublishConfigurationCompleted = {
463
+ status: 'completed';
464
+ /**
465
+ * Array of available output types for your platform.
466
+ *
467
+ * Define different output types for various content formats that
468
+ * your platform supports (e.g., posts, stories, videos).
469
+ */
470
+ outputTypes: OutputTypeConfiguration[];
471
+ };
472
+
473
+ /**
474
+ * @public
475
+ * {@link GetPublishConfigurationError} error indicating a custom error occurred.
476
+ */
477
+ export declare type GetPublishConfigurationError = AppError;
478
+
479
+ /**
480
+ * @public
481
+ * Response from getting publish configuration.
482
+ */
483
+ export declare type GetPublishConfigurationResponse = GetPublishConfigurationCompleted | GetPublishConfigurationError;
484
+
485
+ /**
486
+ * @public
487
+ * Exported image file ready for publishing.
488
+ */
489
+ export declare interface ImageOutputFile extends BaseOutputFile {
490
+ /**
491
+ * Width of the image in pixels.
492
+ */
493
+ widthPx: number;
494
+ /**
495
+ * Height of the image in pixels.
496
+ */
497
+ heightPx: number;
498
+ }
499
+
500
+ /**
501
+ * @public
502
+ * Image preview in various states.
503
+ */
504
+ export declare type ImagePreview = ImagePreviewLoading | ImagePreviewReady | ImagePreviewError;
505
+
506
+ /**
507
+ * @public
508
+ * Image preview that failed to generate.
509
+ *
510
+ * Display an error state to the user.
511
+ */
512
+ export declare interface ImagePreviewError extends SizedPreview {
513
+ kind: 'image';
514
+ status: 'error';
515
+
516
+ /**
517
+ * The error message to display to the user.
518
+ */
519
+ message: string;
520
+ }
521
+
522
+ /**
523
+ * @public
524
+ * Image preview that is currently being generated.
525
+ *
526
+ * Display a loading state until the preview transitions to `"ready"` or `"error"`.
527
+ */
528
+ export declare interface ImagePreviewLoading extends SizedPreview {
529
+ kind: 'image';
530
+ status: 'loading';
531
+ }
532
+
533
+ /**
534
+ * @public
535
+ * Image preview that is ready to display.
536
+ *
537
+ * Contains the URL to the preview image.
538
+ */
539
+ export declare interface ImagePreviewReady extends SizedPreview {
540
+ kind: 'image';
541
+ status: 'ready';
542
+ /**
543
+ * Image format of the preview.
544
+ */
545
+ format: 'png' | 'jpg';
546
+ /**
547
+ * URL to the preview image.
548
+ *
549
+ * Use this URL to display the preview to users.
550
+ */
551
+ url: string;
552
+ }
553
+
554
+ /**
555
+ * @public
556
+ * Image file requirements for a media slot.
557
+ *
558
+ * Specifies format, aspect ratio, and size constraints for images.
559
+ *
560
+ * @example Image requirements for social media post
561
+ * ```ts
562
+ * const imageReq: ImageRequirement = {
563
+ * format: 'jpg',
564
+ * aspectRatio: { min: 0.8, max: 1.91 },
565
+ * };
566
+ * ```
567
+ */
568
+ export declare interface ImageRequirement extends BaseFileRequirement {
569
+ /**
570
+ * Supported image format.
571
+ */
572
+ format: 'png' | 'jpg';
573
+ /**
574
+ * Aspect ratio constraint (width / height).
575
+ *
576
+ * Examples:
577
+ * - `{ exact: 16/9 }`: Widescreen (16:9)
578
+ * - `{ min: 0.8, max: 1.91 }`: Instagram range
579
+ */
580
+ aspectRatio?: ValueRange;
581
+ }
582
+
583
+ /**
584
+ * @public
585
+ * Selection metadata for an image media item.
586
+ */
587
+ export declare type ImageSelection = {
588
+ kind: 'image';
589
+ };
590
+
591
+ /**
592
+ * @public
593
+ * Maximum value range constraint.
594
+ * @example Maximum value range
595
+ * ```ts
596
+ * const maxValue: ValueRange = { max: 10 }; // At most 10
597
+ * ```
598
+ */
599
+ export declare type MaxValueRange = {
600
+ max: number;
601
+ };
602
+
603
+ /**
604
+ * @public
605
+ * Configuration for a media slot within an output type.
606
+ *
607
+ * Defines what type of media is accepted, requirements, and constraints.
608
+ *
609
+ * @example Image slot with aspect ratio requirements
610
+ * ```ts
611
+ * const thumbnailSlot: MediaSlot = {
612
+ * id: 'thumbnail',
613
+ * displayName: 'Video Thumbnail',
614
+ * fileCount: { exact: 1 },
615
+ * accepts: {
616
+ * image: {
617
+ * format: 'jpg',
618
+ * aspectRatio: { exact: 16/9 },
619
+ * }
620
+ * }
621
+ * };
622
+ * ```
623
+ */
624
+ export declare type MediaSlot = {
625
+ /**
626
+ * Unique identifier for this media slot within the output type.
627
+ */
628
+ id: string;
629
+ /**
630
+ * User-facing name for this media slot.
631
+ *
632
+ * Examples: `"Post Image"`, `"Video Thumbnail"`, `"Main Video"`.
633
+ */
634
+ displayName: string;
635
+ /**
636
+ * Number of files accepted in this slot.
637
+ *
638
+ * Use this to specify single or multiple file requirements.
639
+ * Examples:
640
+ * - `{ exact: 1 }`: Exactly one file
641
+ * - `{ min: 1, max: 10 }`: Between 1 and 10 files
642
+ * - undefined: Any number of files
643
+ */
644
+ fileCount?: ValueRange;
645
+ /**
646
+ * File type requirements for this slot.
647
+ *
648
+ * Note the following behavior:
649
+ *
650
+ * - Provide at least one of `image` or `video`
651
+ * - If both are provided, files for this slot may be either images or videos; each file
652
+ * must satisfy the corresponding requirement for its media type
653
+ * - To restrict the slot to a single media type, provide only that requirement
654
+ * - `fileCount` applies across all files accepted by the slot regardless of media type
655
+ * - Document output types will show image previews (PNG thumbnail) in preview UI
656
+ */
657
+ accepts: {
658
+ image?: ImageRequirement;
659
+ video?: VideoRequirement;
660
+ document?: DocumentRequirement;
661
+
662
+ };
663
+ /**
664
+ * @public
665
+ * Current selection for this slot.
666
+ *
667
+ * Canva populates this only when returning {@link OutputType} in Settings UI contexts
668
+ * such as {@link RenderSettingsUiInvocationContext} and {@link PublishSettingsSettingsUiContext}.
669
+ * Apps should not set this value when defining output types in
670
+ * {@link ContentPublisherIntent.getPublishConfiguration}.
671
+ */
672
+ readonly selection?: readonly Selection_2[];
673
+ };
674
+
675
+ /**
676
+ * @public
677
+ * Minimum and maximum value range constraint.
678
+ * Ranges are inclusive `(min ≤ value ≤ max)`.
679
+ * @example Minimum and maximum value range
680
+ * ```ts
681
+ * const minMaxValue: ValueRange = { min: 1, max: 10 }; // Between 1 and 10
682
+ * ```
683
+ */
684
+ export declare type MinMaxValueRange = {
685
+ min: number;
686
+ max: number;
687
+ };
688
+
689
+ /**
690
+ * @public
691
+ * Minimum value range constraint.
692
+ * @example Minimum value range
693
+ * ```ts
694
+ * const minValue: ValueRange = { min: 3 }; // At least 3
695
+ * ```
696
+ */
697
+ export declare type MinValueRange = {
698
+ min: number;
699
+ };
700
+
701
+ /** @public */
702
+ export declare type OnContextChange = (context: SettingsUiContext) => void;
703
+
704
+ /**
705
+ * @public
706
+ * Exported file ready for publishing.
707
+ */
708
+ export declare type OutputFile = ImageOutputFile | VideoOutputFile | DocumentOutputFile;
709
+
710
+ /**
711
+ * @public
712
+ * Production-ready exported files for a specific media slot.
713
+ *
714
+ * These are the final files that should be uploaded to your platform.
715
+ */
716
+ export declare type OutputMedia = {
717
+ /**
718
+ * ID of the media slot these files belong to.
719
+ *
720
+ * Matches a media slot ID from your output type definition.
721
+ */
722
+ mediaSlotId: string;
723
+ /**
724
+ * Array of exported files for this media slot.
725
+ *
726
+ * Files match the requirements specified in your media slot configuration.
727
+ */
728
+ files: OutputFile[];
729
+ };
730
+
731
+ /**
732
+ * @public
733
+ * Metadata about a specific page in the exported content.
734
+ */
735
+ export declare type OutputPageMetadata = {
736
+ /**
737
+ * The unique identifier for the page.
738
+ */
739
+ pageId: string | undefined;
740
+ /**
741
+ * The position of the page within the design, starting from 1 for the first page.
742
+ */
743
+ pageNumber: number;
744
+ };
745
+
746
+ /**
747
+ * @public
748
+ * Configuration for an output type.
749
+ *
750
+ * Defines a specific publishing format your platform supports,
751
+ * including what media is required and accepted file types.
752
+ *
753
+ * @example Defining an Instagram post output type
754
+ * ```ts
755
+ * const instagramPost: OutputType = {
756
+ * id: 'instagram_post',
757
+ * displayName: 'Instagram Post',
758
+ * mediaSlots: [
759
+ * {
760
+ * id: 'main_image',
761
+ * displayName: 'Post Image',
762
+ * fileCount: { min: 1, max: 10 },
763
+ * accepts: {
764
+ * image: {
765
+ * format: 'jpg',
766
+ * aspectRatio: { min: 0.8, max: 1.91 },
767
+ * }
768
+ * }
769
+ * }
770
+ * ]
771
+ * };
772
+ * ```
773
+ */
774
+ export declare type OutputType = {
775
+ /**
776
+ * Unique identifier for this output type.
777
+ *
778
+ * Use descriptive IDs like `"instagram_post"` or `"youtube_video"`.
779
+ */
780
+ id: string;
781
+ /**
782
+ * User-facing name for this output type.
783
+ *
784
+ * This is displayed to users when selecting where to publish.
785
+ * Examples: `"Instagram Post"`, `"YouTube Video"`, `"Twitter Post"`.
786
+ */
787
+ displayName: string;
788
+ /**
789
+ * Array of media slots defining what content is needed.
790
+ *
791
+ * Each slot represents a piece of media required for publishing,
792
+ * such as a main image, thumbnail, or video.
793
+ */
794
+ mediaSlots: MediaSlot[];
795
+ };
796
+
797
+ /**
798
+ * @public
799
+ * Configuration for an output type as provided by apps in
800
+ * {@link ContentPublisherIntent.getPublishConfiguration}.
801
+ *
802
+ * This is the authored shape of an output type. It omits the
803
+ * {@link MediaSlot.selection} field which is populated by Canva
804
+ * when returning {@link OutputType} in Settings UI contexts.
805
+ *
806
+ * @example Defining output type configuration for a social media platform
807
+ * ```ts
808
+ * const outputType: OutputTypeConfiguration = {
809
+ * id: 'instagram_post',
810
+ * displayName: 'Instagram Post',
811
+ * mediaSlots: [
812
+ * {
813
+ * id: 'main_image',
814
+ * displayName: 'Post Image',
815
+ * fileCount: { min: 1, max: 10 },
816
+ * accepts: {
817
+ * image: { format: 'jpg', aspectRatio: { min: 0.8, max: 1.91 } }
818
+ * }
819
+ * }
820
+ * ]
821
+ * };
822
+ * ```
823
+ */
824
+ export declare type OutputTypeConfiguration = {
825
+ /**
826
+ * Unique identifier for this output type.
827
+ *
828
+ * Use descriptive IDs like `"instagram_post"` or `"youtube_video"`.
829
+ */
830
+ id: string;
831
+ /**
832
+ * User-facing name for this output type.
833
+ *
834
+ * This is displayed to users when selecting where to publish.
835
+ * Examples: `"Instagram Post"`, `"YouTube Video"`, `"Twitter Post"`.
836
+ */
837
+ displayName: string;
838
+ /**
839
+ * Array of media slots defining what content is needed.
840
+ *
841
+ * Each slot represents a piece of media required for publishing,
842
+ * such as a main image, thumbnail, or video.
843
+ * The {@link MediaSlot.selection} field is omitted here because apps
844
+ * do not provide selection data when defining output types.
845
+ */
846
+ mediaSlots: Omit<MediaSlot, 'selection'>[];
847
+ };
848
+
849
+ /**
850
+ * @public
851
+ * Action to be taken after publishing completes successfully.
852
+ */
853
+ export declare type PostPublishAction = PostPublishActionRedirect;
854
+
855
+ /**
856
+ * @public
857
+ * Redirect action to navigate the user to a URL after publishing.
858
+ *
859
+ * @example Redirecting to content editor
860
+ * ```ts
861
+ * const postPublishAction: PostPublishActionRedirect = {
862
+ * type: 'redirect',
863
+ * url: 'https://example.com/posts/12345/edit'
864
+ * };
865
+ * ```
866
+ */
867
+ export declare type PostPublishActionRedirect = {
868
+ type: 'redirect';
869
+ /**
870
+ * The URL to redirect the user to after publishing.
871
+ */
872
+ url: string;
873
+ };
874
+
875
+ /**
876
+ * @public
877
+ *
878
+ * Prepares a {@link ContentPublisherIntent|Content Publisher Intent}.
879
+ *
880
+ * @example
881
+ * ```tsx
882
+ * import { prepareContentPublisher } from "@canva/intents/content";
883
+ *
884
+ * prepareContentPublisher({
885
+ * getPublishConfiguration: async (params) => {
886
+ * // Implement the logic to get the publish configuration
887
+ * },
888
+ * renderSettingsUi: (params) => {
889
+ * // Implement the UI for settings view
890
+ * },
891
+ * renderPreviewUi: (params) => {
892
+ * // Implement the UI for preview view
893
+ * },
894
+ * publishContent: async (params) => {
895
+ * // Implement the logic to publish the content
896
+ * },
897
+ * });
898
+ * ```
899
+ */
900
+ export declare const prepareContentPublisher: (implementation: ContentPublisherIntent) => void;
901
+
902
+ /**
903
+ * @public
904
+ * Preview item for an image or video.
905
+ *
906
+ * Check the `kind` and `status` properties to determine the type and state.
907
+ */
908
+ export declare type Preview = ImagePreview | VideoPreview | DocumentPreview | EmailPreviewStub;
909
+
910
+ /**
911
+ * @public
912
+ * Type of preview media.
913
+ */
914
+ export declare type PreviewKind = 'image' | 'video' | 'document' | 'email';
915
+
916
+ /**
917
+ * @public
918
+ * Preview media for a specific media slot.
919
+ *
920
+ * Contains preview URLs and metadata for images or videos in the design.
921
+ */
922
+ export declare type PreviewMedia = {
923
+ /**
924
+ * ID of the media slot this preview belongs to.
925
+ *
926
+ * Matches a media slot ID from your output type definition.
927
+ */
928
+ mediaSlotId: string;
929
+ /**
930
+ * Array of preview items for this media slot.
931
+ *
932
+ * May contain multiple previews if the media slot accepts multiple files.
933
+ */
934
+ previews: Preview[];
935
+ };
936
+
937
+ /**
938
+ * @public
939
+ * State of a preview item.
940
+ */
941
+ export declare type PreviewStatus = 'loading' | 'thumbnail' | 'upgrading' | 'ready' | 'error';
942
+
943
+ /**
944
+ * @public
945
+ * Successful response from publishing a content.
946
+ *
947
+ * @example Basic successful publish
948
+ * ```ts
949
+ * return {
950
+ * status: 'completed',
951
+ * externalId: 'post_12345',
952
+ * externalUrl: 'https://example.com/posts/12345'
953
+ * };
954
+ * ```
955
+ *
956
+ * @example Successful publish with redirect
957
+ * ```ts
958
+ * return {
959
+ * status: 'completed',
960
+ * externalId: 'video_67890',
961
+ * externalUrl: 'https://example.com/videos/67890',
962
+ * postPublishAction: {
963
+ * type: 'redirect',
964
+ * url: 'https://example.com/videos/67890/edit'
965
+ * }
966
+ * };
967
+ * ```
968
+ */
969
+ export declare type PublishContentCompleted = {
970
+ status: 'completed';
971
+ /**
972
+ * Unique identifier returned from your external platform. You can use this for:
973
+ *
974
+ * - Tracking published content
975
+ * - Fetching insights data for the published content
976
+ * - Linking back to the content in future operations
977
+ */
978
+ externalId?: string;
979
+ /**
980
+ * Direct URL to the published content on your platform.
981
+ *
982
+ * Users can visit this URL to view their published content.
983
+ * This may be displayed to users or used for sharing.
984
+ */
985
+ externalUrl?: string;
986
+ /**
987
+ * Optional action to perform after publishing completes.
988
+ *
989
+ * Currently supports redirecting users to a specific URL after publishing.
990
+ */
991
+ postPublishAction?: PostPublishAction;
992
+ };
993
+
994
+ /**
995
+ * @public
996
+ * Error response from publishing a content.
997
+ *
998
+ * Return the appropriate error type based on the failure:
999
+ *
1000
+ * - `"remote_request_failed"`: Network or API errors with your platform
1001
+ * - `"app_error"`: Custom application errors with optional message
1002
+ */
1003
+ export declare type PublishContentError = RemoteRequestFailedError | AppError;
1004
+
1005
+ /**
1006
+ * @public
1007
+ * Parameters required for publishing the content.
1008
+ * Contains all the information needed to send the content to your external platform.
1009
+ */
1010
+ export declare type PublishContentRequest = {
1011
+ /**
1012
+ * Platform-specific settings reference containing user configurations.
1013
+ *
1014
+ * This is the same reference you saved via `updatePublishSettings` in the settings UI.
1015
+ * Parse this string to retrieve the user's publish settings (e.g., captions, tags, privacy).
1016
+ *
1017
+ * Maximum size: 5KB
1018
+ */
1019
+ publishRef?: string;
1020
+ /**
1021
+ * The output type selected by the user for this publish operation.
1022
+ *
1023
+ * This matches one of the output types you provided in `getPublishConfiguration`.
1024
+ */
1025
+ outputType: OutputTypeConfiguration;
1026
+ /**
1027
+ * Production-ready exported files matching the requirements from your output type.
1028
+ *
1029
+ * These files are ready to upload to your platform and match the format, size,
1030
+ * and aspect ratio requirements specified in your media slots.
1031
+ */
1032
+ outputMedia: OutputMedia[];
1033
+ };
1034
+
1035
+ /**
1036
+ * @public
1037
+ * Response from a publish content operation.
1038
+ *
1039
+ * This can be either a successful completion or an error response.
1040
+ */
1041
+ export declare type PublishContentResponse = PublishContentCompleted | PublishContentError;
1042
+
1043
+ /** @public */
1044
+ export declare type PublishError = {
1045
+ appDefinedPayload?: string;
1046
+ };
1047
+
1048
+ /**
1049
+ * @public
1050
+ * Signals that the publish error was cleared.
1051
+ */
1052
+ export declare type PublishErrorClearedSettingsUiContext = {
1053
+ reason: 'publish_error_cleared';
1054
+ };
1055
+
1056
+ /**
1057
+ * @public
1058
+ * Provides information about an error that occurred in publishContent.
1059
+ */
1060
+ export declare type PublishErrorSettingsUiContext = {
1061
+ reason: 'publish_error';
1062
+ /**
1063
+ * The error that occurred. Undefined means no error occurred or the previous
1064
+ * error was cleared by Canva.
1065
+ */
1066
+ error: PublishError;
1067
+ };
1068
+
1069
+ /**
1070
+ * @public
1071
+ * Supported file formats for publishing.
1072
+ */
1073
+ export declare type PublishFileFormat = 'png' | 'jpg' | 'mp4' | 'pdf_standard' | 'html_bundle' | 'html_standalone';
1074
+
1075
+ /**
1076
+ * @public
1077
+ * Initial payload provided from cache.
1078
+ */
1079
+ export declare type PublishPreviewUiInvocationContext = {
1080
+ /**
1081
+ * Initial preview data and context provided when the preview UI is rendered.
1082
+ */
1083
+ reason: 'publish';
1084
+ /**
1085
+ * Initial preview media to display
1086
+ * This will only be used for scheduling and not caching
1087
+ */
1088
+ previewMedia?: PreviewMedia[];
1089
+ /** Information about the current output type being previewed */
1090
+ outputType?: OutputType;
1091
+ /** Current publish reference, if available */
1092
+ publishRef?: string;
1093
+ };
1094
+
1095
+ /**
1096
+ * @public
1097
+ * Validation state indicating whether publish settings are complete and valid.
1098
+ */
1099
+ export declare type PublishRefValidityState = 'valid' | 'invalid_missing_required_fields' | 'invalid_authentication_required';
1100
+
1101
+ /**
1102
+ * @public
1103
+ * Configuration for publish settings.
1104
+ *
1105
+ * Contains the user's settings and their validation state. Use this to
1106
+ * control whether the publish button is enabled.
1107
+ */
1108
+ export declare type PublishSettings = {
1109
+ /**
1110
+ * Serialized platform-specific settings for publishing.
1111
+ *
1112
+ * Store all information your app needs to publish the content in this string.
1113
+ * This might include:
1114
+ *
1115
+ * - Captions or descriptions
1116
+ * - Tags or hashtags
1117
+ * - Privacy settings
1118
+ * - Publishing destination (account, page, etc.)
1119
+ * - Scheduling information
1120
+ *
1121
+ * This reference will be provided to your `publishContent` method when publishing.
1122
+ *
1123
+ * Maximum size: 5KB
1124
+ *
1125
+ * @example Serializing settings
1126
+ * ```ts
1127
+ * const settings = {
1128
+ * caption: 'Check out my design!',
1129
+ * tags: ['design', 'creative'],
1130
+ * privacy: 'public'
1131
+ * };
1132
+ * const publishRef = JSON.stringify(settings);
1133
+ * ```
1134
+ */
1135
+ publishRef?: string;
1136
+ /**
1137
+ * Validation state of the publish settings.
1138
+ *
1139
+ * Controls whether the publish button is enabled:
1140
+ *
1141
+ * - `"valid"`: Settings are complete and valid, publish button is enabled
1142
+ * - `"invalid_missing_required_fields"`: Required settings are missing, publish button is disabled
1143
+ * - `"invalid_authentication_required"`: User must authenticate before publishing can proceed
1144
+ */
1145
+ validityState: PublishRefValidityState;
1146
+ };
1147
+
1148
+ /**
1149
+ * @public
1150
+ * Provides information about the current state of the settings UI to help
1151
+ * you adapt the interface based on the selected output type.
1152
+ */
1153
+ export declare type PublishSettingsSettingsUiContext = {
1154
+ reason: 'publish_settings';
1155
+ /**
1156
+ * The currently selected output type.
1157
+ *
1158
+ * Use this to customize your settings UI based on the requirements
1159
+ * of different output types.
1160
+ */
1161
+ outputType: OutputType;
1162
+ };
1163
+
1164
+ /**
1165
+ * @public
1166
+ * Initial payload provided from cache.
1167
+ */
1168
+ export declare type PublishSettingsUiInvocationContext = {
1169
+ /**
1170
+ * Initial settings and context provided when the settings UI is rendered.
1171
+ */
1172
+ reason: 'publish';
1173
+ /** Current publish reference to populate the UI, if any exist */
1174
+ publishRef?: string;
1175
+ /** Information about the current output type being configured */
1176
+ outputType?: OutputType;
1177
+ };
1178
+
1179
+ /**
1180
+ * @public
1181
+ * {@link PublishContentError} indicating failure of the remote request to the external platform.
1182
+ *
1183
+ * Return this error for:
1184
+ *
1185
+ * - Network connectivity issues
1186
+ * - API endpoint failures
1187
+ * - HTTP errors from your platform
1188
+ * - Timeout errors
1189
+ *
1190
+ * @example Handling network errors
1191
+ * ```ts
1192
+ * try {
1193
+ * await uploadToExternalPlatform(file);
1194
+ * } catch (error) {
1195
+ * return { status: 'remote_request_failed' };
1196
+ * }
1197
+ * ```
1198
+ */
1199
+ export declare type RemoteRequestFailedError = {
1200
+ status: 'remote_request_failed';
1201
+ };
1202
+
1203
+ /**
1204
+ * @public
1205
+ * Initial payload provided when the preview UI is rendered.
1206
+ * Contains the preview data and settings needed to initialize the preview interface.
1207
+ */
1208
+ export declare type RenderPreviewUiInvocationContext = PublishPreviewUiInvocationContext;
1209
+
1210
+ /**
1211
+ * @public
1212
+ * Configuration required for rendering the preview UI.
1213
+ *
1214
+ * Provides callbacks for managing preview media and responding to preview updates.
1215
+ */
1216
+ export declare type RenderPreviewUiRequest = {
1217
+ /**
1218
+ * @public
1219
+ * The initial preview data and context provided when the preview UI is rendered.
1220
+ *
1221
+ * Contains the initial preview media, output type information, and any existing
1222
+ * publish settings needed to properly display the preview interface.
1223
+ */
1224
+ invocationContext: RenderPreviewUiInvocationContext;
1225
+ /**
1226
+ * Callback to upgrade video thumbnail previews to full video media.
1227
+ *
1228
+ * Call this function when you need full video previews instead of lightweight thumbnails.
1229
+ * This helps optimize performance by deferring full video loading until needed.
1230
+ *
1231
+ * Upgrades may complete asynchronously; listen to `registerOnPreviewChange` for updates
1232
+ * to receive the upgraded video previews.
1233
+ *
1234
+ * @param previewIds - Array of preview IDs to upgrade from thumbnail to full video
1235
+ *
1236
+ * @example Upgrading video previews on user interaction
1237
+ * ```ts
1238
+ * // When user clicks on a video thumbnail, upgrade to full video
1239
+ * if (preview.kind === 'video' && preview.status === 'thumbnail') {
1240
+ * requestPreviewUpgrade([preview.id]);
1241
+ * }
1242
+ * ```
1243
+ */
1244
+ requestPreviewUpgrade: (previewIds: string[]) => void;
1245
+ /**
1246
+ * Registers a callback to be invoked when preview data changes.
1247
+ *
1248
+ * This callback is triggered when:
1249
+ *
1250
+ * - The design content changes
1251
+ * - The output type changes
1252
+ * - Preview media is upgraded from thumbnail to full video
1253
+ * - Export settings are modified
1254
+ *
1255
+ * Use this to update your preview UI in real-time as users modify their design.
1256
+ *
1257
+ * @param callback - The callback invoked when preview data is updated
1258
+ * @returns A disposer function that cleans up the registered callback
1259
+ *
1260
+ * @example Handling preview updates
1261
+ * ```ts
1262
+ * const disposer = registerOnPreviewChange(({ previewMedia, outputType, publishRef }) => {
1263
+ * // Update your preview UI with the new preview media
1264
+ * previewMedia.forEach((media) => {
1265
+ * media.previews.forEach((preview) => {
1266
+ * if (preview.status === 'ready') {
1267
+ * displayPreview(preview);
1268
+ * }
1269
+ * });
1270
+ * });
1271
+ * });
1272
+ *
1273
+ * // Clean up when preview UI is unmounted
1274
+ * onUnmount(() => disposer());
1275
+ * ```
1276
+ */
1277
+ registerOnPreviewChange: (callback: (opts: {
1278
+ previewMedia: PreviewMedia[];
1279
+ /** The output type that the preview data is for */
1280
+ outputType: OutputType;
1281
+ /** The current publish settings reference, if available */
1282
+ publishRef?: string;
1283
+ }) => void) => Disposer;
1284
+ };
1285
+
1286
+ /**
1287
+ * @public
1288
+ * Initial payload provided when the publish settings UI is rendered.
1289
+ * Contains the current settings state needed to initialize the settings interface.
1290
+ */
1291
+ export declare type RenderSettingsUiInvocationContext = PublishSettingsUiInvocationContext;
1292
+
1293
+ /**
1294
+ * @public
1295
+ * Configuration for the publish settings UI.
1296
+ *
1297
+ * This type provides the necessary callbacks and configuration for rendering
1298
+ * a custom publish settings interface where users configure platform-specific options.
1299
+ */
1300
+ export declare type RenderSettingsUiRequest = {
1301
+ /**
1302
+ * @public
1303
+ * The initial settings and context provided when the settings UI is rendered.
1304
+ *
1305
+ * Contains any previously saved publish settings and information about the current output type being configured.
1306
+ * Use this to restore the UI to its previous state or initialise it with appropriate defaults.
1307
+ */
1308
+ invocationContext: RenderSettingsUiInvocationContext;
1309
+ /**
1310
+ * Callback to save and validate the user's publish settings.
1311
+ *
1312
+ * Call this function whenever the user modifies their settings to:
1313
+ *
1314
+ * - Save the settings for later use in `publishContent`
1315
+ * - Validate that required fields are filled
1316
+ * - Enable or disable the publish button based on validity
1317
+ *
1318
+ * Store all necessary publishing information in the `publishRef` string.
1319
+ * This will be provided to your `publishContent` method when the user publishes.
1320
+ *
1321
+ * @param settings - The new publish settings to save
1322
+ * @returns A promise that resolves when the settings are successfully saved
1323
+ * @throws Will throw `CanvaError('bad_request')` if {@link PublishSettings.publishRef} exceeds 5KB.
1324
+ *
1325
+ * @example Updating settings as user types
1326
+ * ```ts
1327
+ * // As user fills in form fields, update settings
1328
+ * function handleCaptionChange(caption: string) {
1329
+ * const settings = { caption, tags: currentTags };
1330
+ * const publishRef = JSON.stringify(settings);
1331
+ *
1332
+ * updatePublishSettings({
1333
+ * publishRef,
1334
+ * validityState: caption ? 'valid' : 'invalid_missing_required_fields'
1335
+ * });
1336
+ * }
1337
+ * ```
1338
+ */
1339
+ updatePublishSettings: (publishSettings: PublishSettings) => Promise<UpdatePublishSettingsResponse>;
1340
+
1341
+ /**
1342
+ * Registers a callback to be invoked when the settings UI context changes.
1343
+ *
1344
+ * This callback is triggered when:
1345
+ * - the user changes the output type in the publish flow.
1346
+ * - an error occurs in the publish flow.
1347
+ *
1348
+ * Use this to respond to Canva changes and update your settings UI accordingly.
1349
+ *
1350
+ * @param opts - The options for registering a callback.
1351
+ * @returns A disposer function that cleans up the registered callback.
1352
+ *
1353
+ * @example Adapting UI for different output types
1354
+ * ```ts
1355
+ * registerOnContextChange({
1356
+ * onContextChange: (ctx) => {
1357
+ * if (ctx.reason === 'publish_settings') {
1358
+ * if (ctx.outputType.id === 'instagram_post') {
1359
+ * showHashtagField();
1360
+ * }
1361
+ * }
1362
+ * if (ctx.reason === 'publish_error') {
1363
+ * setError(ctx.error);
1364
+ * }
1365
+ * }
1366
+ * });
1367
+ * ```
1368
+ */
1369
+ registerOnContextChange: (opts: {
1370
+ onContextChange: OnContextChange;
1371
+ }) => Disposer;
1372
+ };
1373
+
1374
+ /**
1375
+ * @public
1376
+ * Metadata about a selected media item in a media slot.
1377
+ *
1378
+ * Canva populates this when returning {@link OutputType} in Settings UI contexts.
1379
+ * Apps should not set this value.
1380
+ */
1381
+ declare type Selection_2 = ImageSelection | VideoSelection | DocumentSelection | EmailSelection;
1382
+ export { Selection_2 as Selection }
1383
+
1384
+ /**
1385
+ * @public
1386
+ * Context information for the publish settings UI.
1387
+ */
1388
+ export declare type SettingsUiContext = PublishSettingsSettingsUiContext | PublishErrorSettingsUiContext | PublishErrorClearedSettingsUiContext;
1389
+
1390
+ /**
1391
+ * @public
1392
+ * Base interface for all preview types that have a fixed width and height.
1393
+ */
1394
+ export declare interface SizedPreview extends BasePreview {
1395
+ /**
1396
+ * Width of the preview in pixels.
1397
+ */
1398
+ widthPx: number;
1399
+ /**
1400
+ * Height of the preview in pixels.
1401
+ */
1402
+ heightPx: number;
1403
+ }
1404
+
1405
+ /**
1406
+ * @public
1407
+ * Successful response from updating the publish settings.
1408
+ */
1409
+ export declare type UpdatePublishSettingsCompleted = {
1410
+ status: 'completed';
1411
+ };
1412
+
1413
+ /**
1414
+ * @public
1415
+ * Response from updating the publish settings.
1416
+ */
1417
+ export declare type UpdatePublishSettingsResponse = UpdatePublishSettingsCompleted;
1418
+
1419
+ /**
1420
+ * @public
1421
+ * Numeric value range constraint.
1422
+ * Used to specify requirements for aspect ratios, durations, file counts, etc.
1423
+ */
1424
+ export declare type ValueRange = ExactValueRange | MinValueRange | MaxValueRange | MinMaxValueRange;
1425
+
1426
+ /**
1427
+ * @public
1428
+ * Exported video file ready for publishing.
1429
+ */
1430
+ export declare interface VideoOutputFile extends BaseOutputFile {
1431
+ /**
1432
+ * Width of the video in pixels.
1433
+ */
1434
+ widthPx: number;
1435
+ /**
1436
+ * Height of the video in pixels.
1437
+ */
1438
+ heightPx: number;
1439
+ }
1440
+
1441
+ /**
1442
+ * @public
1443
+ * Video preview in various states.
1444
+ *
1445
+ * Videos transition through states: `"loading"` → `"thumbnail"` → `"upgrading"` → `"ready"`.
1446
+ * Start with thumbnails for better performance, then upgrade to full video using `requestPreviewUpgrade`.
1447
+ */
1448
+ export declare type VideoPreview = VideoPreviewLoading | VideoPreviewThumbnail | VideoPreviewUpgrading | VideoPreviewReady | VideoPreviewError;
1449
+
1450
+ /**
1451
+ * @public
1452
+ * Video preview that failed to generate.
1453
+ *
1454
+ * Display an error state to the user.
1455
+ */
1456
+ export declare interface VideoPreviewError extends SizedPreview {
1457
+ kind: 'video';
1458
+ status: 'error';
1459
+
1460
+ /**
1461
+ * The error message to display to the user.
1462
+ */
1463
+ message: string;
1464
+ }
1465
+
1466
+ /**
1467
+ * @public
1468
+ * Video preview that is currently being generated.
1469
+ *
1470
+ * Display a loading state until the preview transitions to `"thumbnail"` or `"error"`.
1471
+ */
1472
+ export declare interface VideoPreviewLoading extends SizedPreview {
1473
+ kind: 'video';
1474
+ status: 'loading';
1475
+ /**
1476
+ * Video duration in milliseconds.
1477
+ */
1478
+ durationMs?: number;
1479
+ }
1480
+
1481
+ /**
1482
+ * @public
1483
+ * Video preview with full video ready to play.
1484
+ *
1485
+ * Contains URLs for both the video and thumbnail.
1486
+ */
1487
+ export declare interface VideoPreviewReady extends SizedPreview {
1488
+ kind: 'video';
1489
+ status: 'ready';
1490
+ /**
1491
+ * Video format.
1492
+ */
1493
+ format: 'mp4';
1494
+ /**
1495
+ * URL to the full video.
1496
+ *
1497
+ * Use this URL in a video player.
1498
+ */
1499
+ url: string;
1500
+ /**
1501
+ * Format of the thumbnail image.
1502
+ */
1503
+ thumbnailFormat: 'png' | 'jpg';
1504
+ /**
1505
+ * URL to the thumbnail image.
1506
+ *
1507
+ * Can be used as a poster image for the video player.
1508
+ */
1509
+ thumbnailUrl: string;
1510
+ /**
1511
+ * Video duration in milliseconds.
1512
+ */
1513
+ durationMs?: number;
1514
+ }
1515
+
1516
+ /**
1517
+ * @public
1518
+ * Video preview with lightweight thumbnail available.
1519
+ *
1520
+ * This is the initial state for video previews. Show the thumbnail image
1521
+ * and call `requestPreviewUpgrade` when the user needs the full video.
1522
+ */
1523
+ export declare interface VideoPreviewThumbnail extends SizedPreview {
1524
+ kind: 'video';
1525
+ status: 'thumbnail';
1526
+ /**
1527
+ * Format of the thumbnail image.
1528
+ */
1529
+ thumbnailFormat: 'png' | 'jpg';
1530
+ /**
1531
+ * URL to the thumbnail image.
1532
+ *
1533
+ * Display this lightweight image until full video is needed.
1534
+ */
1535
+ thumbnailUrl: string;
1536
+ /**
1537
+ * Video duration in milliseconds.
1538
+ */
1539
+ durationMs?: number;
1540
+ }
1541
+
1542
+ /**
1543
+ * @public
1544
+ * Video preview that is being upgraded from thumbnail to full video.
1545
+ *
1546
+ * Display the thumbnail with a loading indicator until the video is ready.
1547
+ */
1548
+ export declare interface VideoPreviewUpgrading extends SizedPreview {
1549
+ kind: 'video';
1550
+ status: 'upgrading';
1551
+ /**
1552
+ * Format of the thumbnail image.
1553
+ */
1554
+ thumbnailFormat: 'png' | 'jpg';
1555
+ /**
1556
+ * URL to the thumbnail image.
1557
+ *
1558
+ * Continue showing the thumbnail while the full video loads.
1559
+ */
1560
+ thumbnailUrl: string;
1561
+ /**
1562
+ * Video duration in milliseconds.
1563
+ */
1564
+ durationMs?: number;
1565
+ }
1566
+
1567
+ /**
1568
+ * @public
1569
+ * Video file requirements for a media slot.
1570
+ *
1571
+ * Specifies format, aspect ratio, duration, and size constraints for videos.
1572
+ *
1573
+ * @example Video requirements for YouTube
1574
+ * ```ts
1575
+ * const videoReq: VideoRequirement = {
1576
+ * format: 'mp4',
1577
+ * aspectRatio: { exact: 16/9 },
1578
+ * durationMs: { min: 1000, max: 600000 },
1579
+ * };
1580
+ * ```
1581
+ */
1582
+ export declare interface VideoRequirement extends BaseFileRequirement {
1583
+ /**
1584
+ * Supported video format.
1585
+ */
1586
+ format: 'mp4';
1587
+ /**
1588
+ * Aspect ratio constraint (width / height).
1589
+ *
1590
+ * Examples:
1591
+ * - `{ exact: 16/9 }`: Widescreen
1592
+ * - `{ exact: 9/16 }`: Vertical/Story format
1593
+ */
1594
+ aspectRatio?: ValueRange;
1595
+ /**
1596
+ * Duration constraint in milliseconds.
1597
+ *
1598
+ * Examples:
1599
+ * - `{ max: 60000 }`: Maximum 60 seconds
1600
+ * - `{ min: 3000, max: 600000 }`: Between 3 seconds and 10 minutes
1601
+ */
1602
+ durationMs?: ValueRange;
1603
+
1604
+ }
1605
+
1606
+ /**
1607
+ * @public
1608
+ * Selection metadata for a video media item.
1609
+ */
1610
+ export declare type VideoSelection = {
1611
+ kind: 'video';
1612
+ /**
1613
+ * Duration of the selected video in milliseconds.
1614
+ */
1615
+ durationMs: number;
1616
+ };
1617
+
1618
+ export { }