@canva/intents 0.0.0-beta.2 → 2.0.0-beta.1

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.
package/data/beta.d.ts CHANGED
@@ -1,6 +1,46 @@
1
1
  /**
2
- * @beta
3
- * {@link FetchDataTableError} indicating custom error occurred in the app's implementation.
2
+ * @public
3
+ * A disclosure identifying if the app generated this asset using AI.
4
+ *
5
+ * @remarks
6
+ * Helps users make informed decisions about the content they interact with.
7
+ *
8
+ * AI is generally defined as any machine system that, given an objective, infers how to generate an output from an input.
9
+ * Some examples include "generative AI", "large language models", and "machine learning".
10
+ *
11
+ * **App Generated**
12
+ *
13
+ * 'app_generated' indicates when the app creates or significantly alters an asset using AI. Includes when
14
+ * the app makes a request to a third-party service to do so.
15
+ *
16
+ * A significantly altered asset means the AI changes key information or details, such as
17
+ * removing or replacing key components in the original content, which can include applying style transfer, or changing facial expressions.
18
+ *
19
+ * Label this asset as 'app_generated' under these conditions:
20
+ *
21
+ * The following is true:
22
+ *
23
+ * - The app generates the asset in response to a user's request (including past requests), for example, the asset is not from an asset library.
24
+ *
25
+ * And any of these conditions are also true:
26
+ *
27
+ * - The AI creates entirely new content from scratch.
28
+ * - The AI introduces new multimedia, details, or creative elements not originally present.
29
+ * - The AI removes and replaces the asset's key components.
30
+ * - The AI alters the asset's appearance, meaning, or context in a way that conveys a different message than the original.
31
+ *
32
+ * **None**
33
+ *
34
+ * 'none' indicates when the asset wasn't generated by the app as a part of any user's specific request, for example, a third-party
35
+ * request, or when the asset wasn't significantly altered by AI.
36
+ */
37
+ declare type AiDisclosure = "app_generated" | "none";
38
+
39
+ declare type AllOrNone<T> = T | Never<T>;
40
+
41
+ /**
42
+ * @public
43
+ * {@link GetDataTableError} indicating custom error occurred in the app's implementation.
4
44
  * This can be used to indicate specific issues that are not covered by other error types.
5
45
  */
6
46
  declare type AppError = {
@@ -19,16 +59,16 @@ declare type AppError = {
19
59
  };
20
60
 
21
61
  /**
22
- * @beta
62
+ * @public
23
63
  * {@link InvocationContext} indicating a custom error occurred during data refresh.
24
- * Triggered when fetchDataTable returned 'app_error' status.
64
+ * Triggered when getDataTable returned 'app_error' status.
25
65
  * UI should display the error message and help users recover.
26
66
  */
27
67
  declare type AppErrorInvocationContext = {
28
68
  /**
29
69
  * A custom error occurred during data refresh.
30
70
  *
31
- * This occurs when `fetchDataTable` returned 'app_error' during a refresh attempt.
71
+ * This occurs when `getDataTable` returned 'app_error' during a refresh attempt.
32
72
  * Your UI should display the error message and help users recover from the specific
33
73
  * issue.
34
74
  */
@@ -44,7 +84,7 @@ declare type AppErrorInvocationContext = {
44
84
  };
45
85
 
46
86
  /**
47
- * @beta
87
+ * @public
48
88
  * Cell containing a boolean value.
49
89
  *
50
90
  * @example Creating a boolean cell
@@ -91,7 +131,7 @@ export declare type BooleanDataTableCell = {
91
131
  };
92
132
 
93
133
  /**
94
- * @beta
134
+ * @public
95
135
  * Configuration for a table column.
96
136
  */
97
137
  export declare type ColumnConfig = {
@@ -111,7 +151,7 @@ export declare type ColumnConfig = {
111
151
  };
112
152
 
113
153
  /**
114
- * @beta
154
+ * @public
115
155
  * Main interface for implementing the Data Connector intent.
116
156
  *
117
157
  * Implementing the Data Connector intent enables apps to import external data into Canva.
@@ -119,22 +159,22 @@ export declare type ColumnConfig = {
119
159
  */
120
160
  export declare type DataConnectorIntent = {
121
161
  /**
122
- * Fetches structured data from an external source.
162
+ * Gets structured data from an external source.
123
163
  *
124
164
  * This action is called in two scenarios:
125
165
  *
126
- * - During data selection to preview data before import (when {@link RenderSelectionUiParams.updateDataRef} is called).
166
+ * - During data selection to preview data before import (when {@link RenderSelectionUiRequest.updateDataRef} is called).
127
167
  * - When refreshing previously imported data (when the user requests an update).
128
168
  *
129
- * @param params - Parameters for the data fetching operation.
169
+ * @param request - Parameters for the data fetching operation.
130
170
  * @returns A promise resolving to either a successful result with data or an error.
131
171
  *
132
- * @example Fetching data from an external source
172
+ * @example Getting data from an external source
133
173
  * ```ts
134
- * import type { FetchDataTableParams, FetchDataTableResult } from '@canva/intents/data';
174
+ * import type { GetDataTableRequest, GetDataTableResponse } from '@canva/intents/data';
135
175
  *
136
- * async function fetchDataTable(params: FetchDataTableParams): Promise<FetchDataTableResult> {
137
- * const { dataSourceRef, limit, signal } = params;
176
+ * async function getDataTable(request: GetDataTableRequest): Promise<GetDataTableResponse> {
177
+ * const { dataSourceRef, limit, signal } = request;
138
178
  *
139
179
  * // Check if the operation has been aborted.
140
180
  * if (signal.aborted) {
@@ -151,24 +191,23 @@ export declare type DataConnectorIntent = {
151
191
  * }
152
192
  * ```
153
193
  */
154
- fetchDataTable: (
155
- params: FetchDataTableParams,
156
- ) => Promise<FetchDataTableResult>;
194
+ getDataTable: (request: GetDataTableRequest) => Promise<GetDataTableResponse>;
195
+
157
196
  /**
158
197
  * Renders a user interface for selecting and configuring data from your external sources.
159
198
  *
160
- * @param params - Configuration and callbacks for the data selection UI.
199
+ * @param request - Configuration and callbacks for the data selection UI.
161
200
  *
162
201
  * @example Rendering a data selection UI
163
202
  * ```ts
164
- * import type { RenderSelectionUiParams } from '@canva/intents/data';
203
+ * import type { RenderSelectionUiRequest } from '@canva/intents/data';
165
204
  *
166
- * async function renderSelectionUi(params: RenderSelectionUiParams): Promise<void> {
205
+ * async function renderSelectionUi(request: RenderSelectionUiRequest): Promise<void> {
167
206
  * // UI rendering logic.
168
207
  * // Example: if user selects data 'ref123'.
169
208
  * const selectedRef = { source: 'ref123', title: 'My Selected Table' };
170
209
  * try {
171
- * const result = await params.updateDataRef(selectedRef);
210
+ * const result = await request.updateDataRef(selectedRef);
172
211
  * if (result.status === 'completed') {
173
212
  * console.log('Selection valid and preview updated.');
174
213
  * } else {
@@ -180,11 +219,11 @@ export declare type DataConnectorIntent = {
180
219
  * }
181
220
  * ```
182
221
  */
183
- renderSelectionUi: (params: RenderSelectionUiParams) => void;
222
+ renderSelectionUi: (request: RenderSelectionUiRequest) => void;
184
223
  };
185
224
 
186
225
  /**
187
- * @beta
226
+ * @public
188
227
  * {@link InvocationContext} indicating initial data selection flow or edit of existing data.
189
228
  */
190
229
  declare type DataSelectionInvocationContext = {
@@ -207,7 +246,7 @@ declare type DataSelectionInvocationContext = {
207
246
  };
208
247
 
209
248
  /**
210
- * @beta
249
+ * @public
211
250
  * Reference to an external data source that can be used to fetch data.
212
251
  * Created by Data Connector apps and stored by Canva for data refresh operations.
213
252
  *
@@ -253,33 +292,7 @@ export declare type DataSourceRef = {
253
292
  };
254
293
 
255
294
  /**
256
- * @beta
257
- * {@link ValidationError} indicating the data source reference {@link DataSourceRef} exceeds the 5KB size limit.
258
- */
259
- declare type DataSourceRefLimitExceeded = {
260
- /**
261
- * The data source reference exceeds the 5KB size limit.
262
- *
263
- * Your app should reduce the size of the `DataSourceRef.source` string.
264
- */
265
- status: "data_source_ref_limit_exceeded";
266
- };
267
-
268
- /**
269
- * @beta
270
- * {@link ValidationError} indicating the data source title {@link DataSourceRef.title} exceeds the 255 character limit.
271
- */
272
- declare type DataSourceTitleLimitExceed = {
273
- /**
274
- * The data source title exceeds the 255 character limit.
275
- *
276
- * Your app should provide a shorter title for the data source.
277
- */
278
- status: "data_source_title_limit_exceeded";
279
- };
280
-
281
- /**
282
- * @beta
295
+ * @public
283
296
  * Structured tabular data for import into Canva.
284
297
  *
285
298
  * This format allows you to provide typed data with proper formatting
@@ -333,7 +346,7 @@ export declare type DataTable = {
333
346
  };
334
347
 
335
348
  /**
336
- * @beta
349
+ * @public
337
350
  * Generic type for table cells that resolves to a specific cell type.
338
351
  */
339
352
  export declare type DataTableCell<T extends DataType = DataType> = {
@@ -341,35 +354,25 @@ export declare type DataTableCell<T extends DataType = DataType> = {
341
354
  string: StringDataTableCell;
342
355
  number: NumberDataTableCell;
343
356
  boolean: BooleanDataTableCell;
357
+ media: MediaCollectionDataTableCell;
344
358
  }[T];
345
359
 
346
360
  /**
347
- * @beta
348
- * {@link ValidationError} indicating the data table format is invalid.
349
- *
350
- * This can happen due to:
351
- *
352
- * - {@link DataType} mismatches (e.g., a number in a string-typed column, a number value in a string cell type)
353
- * - Unsupported cell types
354
- * - Inconsistent column configurations (e.g., the number of columns in the data table does not match the number of {@link ColumnConfig})
361
+ * @public
362
+ * Options for uploading an image asset to the user's private media library.
355
363
  */
356
- declare type DataTableInvalidFormat = {
364
+ export declare type DataTableImageUpload = Omit<
365
+ ImageUploadOptions,
366
+ "type" | "parentRef"
367
+ > & {
357
368
  /**
358
- * The data table format is invalid.
359
- *
360
- * This error occurs due to:
361
- *
362
- * - Data type mismatches (e.g., number in string column)
363
- * - Unsupported cell types
364
- * - Inconsistent column configurations
365
- *
366
- * Your app should ensure the data conforms to the expected format.
369
+ * Indicates this value contains options for image uploading.
367
370
  */
368
- status: "data_table_invalid_format";
371
+ type: "image_upload";
369
372
  };
370
373
 
371
374
  /**
372
- * @beta
375
+ * @public
373
376
  * Maximum dimensions for imported data tables.
374
377
  */
375
378
  export declare type DataTableLimit = {
@@ -388,32 +391,7 @@ export declare type DataTableLimit = {
388
391
  };
389
392
 
390
393
  /**
391
- * @beta
392
- * {@link ValidationError} indicating that the data table exceeds the allowed limits.
393
- *
394
- * This can happen when:
395
- * - Number of rows exceeds the row limit
396
- * - Number of columns exceeds the column limit
397
- * - Total data size exceeds 200KB
398
- */
399
- declare type DataTableLimitExceeded = {
400
- /**
401
- * The data exceeds the maximum allowed limits.
402
- *
403
- * This error occurs when:
404
- *
405
- * - Number of rows exceeds the row limit
406
- * - Number of columns exceeds the column limit
407
- * - Total data size exceeds the allowed size limit
408
- *
409
- * Your app should help users select a subset of their data,
410
- * or provide filtering options to reduce the data size.
411
- */
412
- status: "data_table_limit_exceeded";
413
- };
414
-
415
- /**
416
- * @beta
394
+ * @public
417
395
  * Metadata providing additional context about the imported data.
418
396
  */
419
397
  export declare type DataTableMetadata = {
@@ -439,20 +417,7 @@ export declare type DataTableMetadata = {
439
417
  };
440
418
 
441
419
  /**
442
- * @beta
443
- * {@link ValidationError} indicating the provided data table metadata is invalid (e.g not a valid OXML formatting string in {@link NumberCellMetadata.formatting}).
444
- */
445
- declare type DataTableMetadataInvalid = {
446
- /**
447
- * The provided metadata is invalid.
448
- *
449
- * This typically happens with invalid formatting patterns in {@link NumberCellMetadata.formatting} strings.
450
- */
451
- status: "data_table_metadata_invalid";
452
- };
453
-
454
- /**
455
- * @beta
420
+ * @public
456
421
  * A row in the data table.
457
422
  *
458
423
  * @example Creating a single row of data cells
@@ -478,13 +443,32 @@ export declare type DataTableRow = {
478
443
  };
479
444
 
480
445
  /**
481
- * @beta
446
+ * @public
447
+ * Options for uploading a video asset to the user's private media library.
448
+ */
449
+ export declare type DataTableVideoUpload = Omit<
450
+ VideoUploadOptions,
451
+ "type" | "parentRef"
452
+ > & {
453
+ /**
454
+ * Indicates this value contains options for video uploading.
455
+ */
456
+ type: "video_upload";
457
+ };
458
+
459
+ /**
460
+ * @public
482
461
  * Data types supported for table cells.
483
462
  */
484
- export declare type DataType = "string" | "number" | "date" | "boolean";
463
+ export declare type DataType =
464
+ | "string"
465
+ | "number"
466
+ | "date"
467
+ | "boolean"
468
+ | "media";
485
469
 
486
470
  /**
487
- * @beta
471
+ * @public
488
472
  * Cell containing a date value.
489
473
  *
490
474
  * @example Creating a date cell
@@ -516,12 +500,27 @@ export declare type DateDataTableCell = {
516
500
  };
517
501
 
518
502
  /**
519
- * @beta
520
- * Successful result from `fetchDataTable` action.
503
+ * @public
504
+ * A set of dimensions.
521
505
  */
522
- export declare type FetchDataTableCompleted = {
506
+ declare type Dimensions = {
507
+ /**
508
+ * A width, in pixels.
509
+ */
510
+ width: number;
523
511
  /**
524
- * Indicates the fetch operation completed successfully
512
+ * A height, in pixels.
513
+ */
514
+ height: number;
515
+ };
516
+
517
+ /**
518
+ * @public
519
+ * Successful result from `getDataTable` action.
520
+ */
521
+ export declare type GetDataTableCompleted = {
522
+ /**
523
+ * Indicates the operation completed successfully
525
524
  */
526
525
  status: "completed";
527
526
  /**
@@ -535,19 +534,19 @@ export declare type FetchDataTableCompleted = {
535
534
  };
536
535
 
537
536
  /**
538
- * @beta
539
- * Error results that can be returned from `fetchDataTable` method.
537
+ * @public
538
+ * Error results that can be returned from `getDataTable` method.
540
539
  */
541
- export declare type FetchDataTableError =
540
+ export declare type GetDataTableError =
542
541
  | OutdatedSourceRefError
543
542
  | RemoteRequestFailedError
544
543
  | AppError;
545
544
 
546
545
  /**
547
- * @beta
548
- * Parameters for the fetchDataTable action.
546
+ * @public
547
+ * Parameters for the getDataTable action.
549
548
  */
550
- export declare type FetchDataTableParams = {
549
+ export declare type GetDataTableRequest = {
551
550
  /**
552
551
  * Reference to the data source to fetch.
553
552
  *
@@ -577,33 +576,186 @@ export declare type FetchDataTableParams = {
577
576
  };
578
577
 
579
578
  /**
580
- * @beta
581
- * Result returned from the `fetchDataTable` action.
579
+ * @public
580
+ * Result returned from the `getDataTable` action.
581
+ */
582
+ export declare type GetDataTableResponse =
583
+ | GetDataTableCompleted
584
+ | GetDataTableError;
585
+
586
+ /**
587
+ * @public
588
+ * The MIME type of an image file that's supported by Canva's backend.
582
589
  */
583
- export declare type FetchDataTableResult =
584
- | FetchDataTableCompleted
585
- | FetchDataTableError;
590
+ declare type ImageMimeType =
591
+ | "image/jpeg"
592
+ | "image/heic"
593
+ | "image/png"
594
+ | "image/svg+xml"
595
+ | "image/webp"
596
+ | "image/tiff";
586
597
 
587
598
  /**
588
- * @beta
589
- * System errors that may occur during data operations.
599
+ * @public
600
+ * A unique identifier that points to an image asset in Canva's backend.
590
601
  */
591
- export declare type InternalError = {
602
+ declare type ImageRef = string & {
603
+ __imageRef: never;
604
+ };
605
+
606
+ /**
607
+ * @public
608
+ * Options for uploading an image asset to the user's private media library.
609
+ */
610
+ declare type ImageUploadOptions = {
592
611
  /**
593
- * An unexpected system error occurred.
612
+ * The type of asset.
613
+ */
614
+ type: "image";
615
+ /**
616
+ * The ref of the original asset from which this new asset was derived.
594
617
  *
595
- * These errors are typically not related to your app's implementation
596
- * but indicate issues with the platform.
618
+ * @remarks
619
+ * For example, if an app applies an effect to an image, `parentRef` should contain the ref of the original image.
597
620
  */
598
- status: "internal_error";
621
+ parentRef?: ImageRef;
599
622
  /**
600
- * The cause of the error.
623
+ * The URL of the image file to upload.
624
+ * This can be an external URL or a data URL.
625
+ *
626
+ * @remarks
627
+ * Requirements for external URLs:
628
+ *
629
+ * - Must use HTTPS
630
+ * - Must return a `200` status code
631
+ * - `Content-Type` must match the file's MIME type
632
+ * - Must be publicly accessible (i.e. not a localhost URL)
633
+ * - Must not redirect
634
+ * - Must not contain an IP address
635
+ * - Maximum length: 4096 characters
636
+ * - Must not contain whitespace
637
+ * - Must not contain these characters: `>`, `<`, `{`, `}`, `^`, backticks
638
+ * - Maximum file size: 50MB
639
+ *
640
+ * Requirements for data URLs:
641
+ *
642
+ * - Must include `;base64` for base64-encoded data
643
+ * - Maximum size: 10MB (10 × 1024 × 1024 characters)
644
+ *
645
+ * Requirements for SVGs:
646
+ *
647
+ * - Disallowed elements:
648
+ * - `a`
649
+ * - `altglyph`
650
+ * - `altglyphdef`
651
+ * - `altglyphitem`
652
+ * - `animate`
653
+ * - `animatemotion`
654
+ * - `animatetransform`
655
+ * - `cursor`
656
+ * - `discard`
657
+ * - `font`
658
+ * - `font-face`
659
+ * - `font-face-format`
660
+ * - `font-face-name`
661
+ * - `font-face-src`
662
+ * - `font-face-uri`
663
+ * - `foreignobject`
664
+ * - `glyph`
665
+ * - `glyphref`
666
+ * - `missing-glyph`
667
+ * - `mpath`
668
+ * - `script`
669
+ * - `set`
670
+ * - `switch`
671
+ * - `tref`
672
+ * - Disallowed attributes:
673
+ * - `crossorigin`
674
+ * - `lang`
675
+ * - `media`
676
+ * - `onload`
677
+ * - `ping`
678
+ * - `referrerpolicy`
679
+ * - `rel`
680
+ * - `rendering-intent`
681
+ * - `requiredextensions`
682
+ * - `requiredfeatures`
683
+ * - `systemlanguage`
684
+ * - `tabindex`
685
+ * - `transform-origin`
686
+ * - `unicode`
687
+ * - `vector-effect`
688
+ * - The `href` attribute of an `image` element only supports data URLs for PNG and JPEG images.
689
+ * - The URL in the `href` attribute must not point to a location outside of the SVG.
690
+ * - The `style` attribute must not use the `mix-blend-mode` property.
601
691
  */
602
- cause?: unknown;
603
- };
692
+ url: string;
693
+ /**
694
+ * The MIME type of the image file.
695
+ */
696
+ mimeType: ImageMimeType;
697
+ /**
698
+ * The URL of a thumbnail image to display while the image is queued for upload.
699
+ * This can be an external URL or a data URL.
700
+ *
701
+ * @remarks
702
+ * Requirements for external URLs:
703
+ *
704
+ * - Must use HTTPS
705
+ * - Must support [Cross-Origin Resource Sharing](https://www.canva.dev/docs/apps/cross-origin-resource-sharing/)
706
+ * - Must be a PNG, JPEG, or SVG file
707
+ * - Maximum length: 4096 characters
708
+ *
709
+ * Requirements for data URLs:
710
+ *
711
+ * - Must include `;base64` for base64-encoded data
712
+ * - Maximum size: 10MB (10 × 1024 × 1024 characters)
713
+ */
714
+ thumbnailUrl: string;
715
+ /**
716
+ * A disclosure identifying if the app generated this image using AI
717
+ *
718
+ * @remarks
719
+ * Helps users make informed decisions about the content they interact with.
720
+ * See {@link AiDisclosure} for the full definition.
721
+ *
722
+ * **App Generated**
723
+ *
724
+ * 'app_generated' indicates when the app creates or significantly alters an asset using AI. Includes when
725
+ * the app requests a third-party service to take similar action on an image using AI.
726
+ *
727
+ * Required for the following cases (this list is not exhaustive):
728
+ * | Case | Reason |
729
+ * | -- | -- |
730
+ * | AI generates a new image from scratch | Creates new creative content |
731
+ * | AI changes the style of the image e.g. makes it cartoon | Significantly alters the style |
732
+ * | AI removes an object and replaces it with new content | Creates new creative content |
733
+ * | AI changes the facial expression of a person in an image | Can alter content's original meaning |
734
+ * | AI composites multiple images together | Significantly alters context |
735
+ * | AI expands an image by generating new content to fill the edges | Creates new creative content |
736
+ * | AI replaces background by generating new content | Creates new creative content |
737
+ *
738
+ * **None**
739
+ *
740
+ * 'none' indicates when the app doesn't create or significantly alter an asset using AI, or as a part of a request
741
+ * to third-party hosted content.
742
+ *
743
+ * Required for the following cases (this list is not exhaustive):
744
+ * | Case | Reason |
745
+ * | -- | -- |
746
+ * | Asset comes from an asset library | Didn't generate the asset itself |
747
+ * | AI corrects red eyes | A minor correction |
748
+ * | AI removes background without replacement | Doesn't change original meaning by itself |
749
+ * | AI changes the color of an object in an image | Doesn't change original meaning by itself |
750
+ * | AI detects image defects and suggests manual fixes | Didn't change the asset itself |
751
+ * | AI adjusts brightness and contrast on an image | Doesn't change original meaning by itself |
752
+ * | AI upscales an image | Doesn't change original meaning by itself |
753
+ */
754
+ aiDisclosure: AiDisclosure;
755
+ } & AllOrNone<Dimensions>;
604
756
 
605
757
  /**
606
- * @beta
758
+ * @public
607
759
  * Information explaining why the data selection UI was launched.
608
760
  */
609
761
  export declare type InvocationContext =
@@ -612,7 +764,54 @@ export declare type InvocationContext =
612
764
  | AppErrorInvocationContext;
613
765
 
614
766
  /**
615
- * @beta
767
+ * @public
768
+ * Cell containing a media collection (images) value.
769
+ *
770
+ * @example Creating a media cell with an image
771
+ * ```ts
772
+ * import type { MediaCollectionDataTableCell } from '@canva/intents/data';
773
+ *
774
+ * const mediaCell: MediaCollectionDataTableCell = {
775
+ * type: 'media',
776
+ * value: [{
777
+ * type: 'image_upload',
778
+ * url: 'https://www.canva.dev/example-assets/image-import/image.jpg',
779
+ * mimeType: 'image/jpeg',
780
+ * thumbnailUrl: 'https://www.canva.dev/example-assets/image-import/thumbnail.jpg',
781
+ * aiDisclosure: 'none'
782
+ * }]
783
+ * };
784
+ * ```
785
+ *
786
+ * @example Creating an empty media cell
787
+ * ```ts
788
+ * import type { MediaCollectionDataTableCell } from '@canva/intents/data';
789
+ *
790
+ * const emptyMediaCell: MediaCollectionDataTableCell = {
791
+ * type: 'media',
792
+ * value: []
793
+ * };
794
+ * ```
795
+ */
796
+ export declare type MediaCollectionDataTableCell = {
797
+ /**
798
+ * Indicates this cell contains a media collection.
799
+ */
800
+ type: "media";
801
+ /**
802
+ * Media collection values.
803
+ *
804
+ * Use empty array for an empty cell.
805
+ */
806
+ value: (DataTableImageUpload | DataTableVideoUpload)[];
807
+ };
808
+
809
+ declare type Never<T> = {
810
+ [key in keyof T]?: never;
811
+ };
812
+
813
+ /**
814
+ * @public
616
815
  * Formatting metadata for number cells.
617
816
  *
618
817
  * @example Formatting as currency
@@ -659,7 +858,7 @@ export declare type NumberCellMetadata = {
659
858
  };
660
859
 
661
860
  /**
662
- * @beta
861
+ * @public
663
862
  * Cell containing a numeric value.
664
863
  *
665
864
  * @example Creating a number cell
@@ -718,8 +917,8 @@ export declare type NumberDataTableCell = {
718
917
  };
719
918
 
720
919
  /**
721
- * @beta
722
- * {@link FetchDataTableError} indicating the data source reference is no longer valid.
920
+ * @public
921
+ * {@link GetDataTableError} indicating the data source reference is no longer valid.
723
922
  * This will trigger a re-selection flow for the user.
724
923
  */
725
924
  declare type OutdatedSourceRefError = {
@@ -740,16 +939,16 @@ declare type OutdatedSourceRefError = {
740
939
  };
741
940
 
742
941
  /**
743
- * @beta
942
+ * @public
744
943
  * {@link InvocationContext} indicating an error occurred because the previously selected data source reference is no longer valid.
745
- * Triggered when fetchDataTable returned 'outdated_source_ref' during data refresh.
944
+ * Triggered when getDataTable returned 'outdated_source_ref' during data refresh.
746
945
  * UI should guide the user to reselect or reconfigure their data.
747
946
  */
748
947
  declare type OutdatedSourceRefInvocationContext = {
749
948
  /**
750
949
  * Previously selected data source reference is no longer valid.
751
950
  *
752
- * This occurs when `fetchDataTable` returned 'outdated_source_ref' during a
951
+ * This occurs when `getDataTable` returned 'outdated_source_ref' during a
753
952
  * refresh attempt. Your UI should guide the user to select a new data source
754
953
  * or update their selection.
755
954
  *
@@ -763,17 +962,31 @@ declare type OutdatedSourceRefInvocationContext = {
763
962
  };
764
963
 
765
964
  /**
766
- * @beta
965
+ * @public
966
+ *
967
+ * Prepares a {@link DataConnectorIntent|DataConnector Intent}.
968
+ *
969
+ * @example
970
+ * ```tsx
971
+ * import { prepareDataConnector } from "@canva/intents/data";
767
972
  *
768
- * Prepares the `DataConnectorIntent`.
973
+ * prepareDataConnector({
974
+ * getDataTable: async (params) => {
975
+ * // Implement the logic to fetch the data table
976
+ * },
977
+ * renderSelectionUi: (params) => {
978
+ * // Implement the UI for the data table selection
979
+ * },
980
+ * });
981
+ * ```
769
982
  */
770
983
  export declare const prepareDataConnector: (
771
984
  implementation: DataConnectorIntent,
772
985
  ) => void;
773
986
 
774
987
  /**
775
- * @beta
776
- * {@link FetchDataTableError} indicating failure to fetch data from the external source.
988
+ * @public
989
+ * {@link GetDataTableError} indicating failure to fetch data from the external source.
777
990
  * Typically due to network issues or API failures.
778
991
  */
779
992
  declare type RemoteRequestFailedError = {
@@ -787,10 +1000,10 @@ declare type RemoteRequestFailedError = {
787
1000
  };
788
1001
 
789
1002
  /**
790
- * @beta
1003
+ * @public
791
1004
  * Parameters for rendering the data selection UI.
792
1005
  */
793
- export declare type RenderSelectionUiParams = {
1006
+ export declare type RenderSelectionUiRequest = {
794
1007
  /**
795
1008
  * Context information about why the data selection UI is being launched.
796
1009
  *
@@ -819,17 +1032,23 @@ export declare type RenderSelectionUiParams = {
819
1032
  * 1. Show a preview of the selected data to the user
820
1033
  * 2. Validate that the selection meets system requirements
821
1034
  *
822
- * Calling this function will trigger your `fetchDataTable` implementation.
1035
+ * Calling this function will trigger your `getDataTable` implementation.
823
1036
  * Wait for the promise to resolve to determine if the selection is valid.
824
1037
  *
825
1038
  * @param dataSourceRef - Reference object identifying the selected data
826
1039
  * @returns Promise resolving to success or an error result
1040
+ * @throws Will throw CanvaError('bad_request') if
1041
+ * 1. {@link DataSourceRef.source} exceeds 5kb.
1042
+ * 2. {@link DataSourceRef.title} exceeds 255 characters.
1043
+ * 3. {@link GetDataTableCompleted.dataTable} exceeds {@link DataTableLimit} or contains invalid data.
827
1044
  */
828
- updateDataRef: (dataSourceRef: DataSourceRef) => Promise<UpdateDataRefResult>;
1045
+ updateDataRef: (
1046
+ dataSourceRef: DataSourceRef,
1047
+ ) => Promise<UpdateDataRefResponse>;
829
1048
  };
830
1049
 
831
1050
  /**
832
- * @beta
1051
+ * @public
833
1052
  * Cell containing a text value.
834
1053
  *
835
1054
  * @example Creating a string cell
@@ -863,8 +1082,8 @@ export declare type StringDataTableCell = {
863
1082
  };
864
1083
 
865
1084
  /**
866
- * @beta
867
- * Successful result from the {@link RenderSelectionUiParams.updateDataRef} callback.
1085
+ * @public
1086
+ * Successful result from the {@link RenderSelectionUiRequest.updateDataRef} callback.
868
1087
  */
869
1088
  declare type UpdateDataRefCompleted = {
870
1089
  /**
@@ -874,25 +1093,150 @@ declare type UpdateDataRefCompleted = {
874
1093
  };
875
1094
 
876
1095
  /**
877
- * @beta
878
- * Result returned from the {@link RenderSelectionUiParams.updateDataRef} callback.
1096
+ * @public
1097
+ * Result returned from the {@link RenderSelectionUiRequest.updateDataRef} callback.
879
1098
  * Indicates whether {@link DataSourceRef} update succeeded or failed.
880
1099
  */
881
- export declare type UpdateDataRefResult =
1100
+ export declare type UpdateDataRefResponse =
882
1101
  | UpdateDataRefCompleted
883
- | FetchDataTableError
884
- | ValidationError
885
- | InternalError;
1102
+ | GetDataTableError;
1103
+
1104
+ /**
1105
+ * @public
1106
+ * The MIME type of a video file that's supported by Canva's backend.
1107
+ *
1108
+ * @remarks
1109
+ * - GIFs are treated as videos, not images.
1110
+ * - `"application/json"` is only used for Lottie files.
1111
+ */
1112
+ declare type VideoMimeType =
1113
+ | "video/avi"
1114
+ | "video/x-msvideo"
1115
+ | "image/gif"
1116
+ | "video/x-m4v"
1117
+ | "video/x-matroska"
1118
+ | "video/quicktime"
1119
+ | "video/mp4"
1120
+ | "video/mpeg"
1121
+ | "video/webm"
1122
+ | "application/json";
1123
+
1124
+ /**
1125
+ * @public
1126
+ * A unique identifier that points to a video asset in Canva's backend.
1127
+ */
1128
+ declare type VideoRef = string & {
1129
+ __videoRef: never;
1130
+ };
886
1131
 
887
1132
  /**
888
- * @beta
889
- * Validation errors that can occur when processing data.
1133
+ * @public
1134
+ * Options for uploading a video asset to the user's private media library.
890
1135
  */
891
- export declare type ValidationError =
892
- | DataTableLimitExceeded
893
- | DataTableInvalidFormat
894
- | DataTableMetadataInvalid
895
- | DataSourceRefLimitExceeded
896
- | DataSourceTitleLimitExceed;
1136
+ declare type VideoUploadOptions = {
1137
+ /**
1138
+ * The type of asset.
1139
+ */
1140
+ type: "video";
1141
+ /**
1142
+ * The ref of the original asset from which this new asset was derived.
1143
+ *
1144
+ * @remarks
1145
+ * For example, if an app applies an effect to a video, `parentRef` should contain the ref of the original video.
1146
+ */
1147
+ parentRef?: VideoRef;
1148
+ /**
1149
+ * The URL of the video file to upload.
1150
+ *
1151
+ * @remarks
1152
+ * Requirements:
1153
+ *
1154
+ * - Must use HTTPS
1155
+ * - Must return a `200` status code
1156
+ * - `Content-Type` must match the file's MIME type
1157
+ * - Must be publicly accessible (i.e. not a localhost URL)
1158
+ * - Must not redirect
1159
+ * - Must not contain an IP address
1160
+ * - Maximum length: 4096 characters
1161
+ * - Must not contain whitespace
1162
+ * - Must not contain these characters: `>`, `<`, `{`, `}`, `^`, backticks
1163
+ * - Maximum file size: 100MB
1164
+ */
1165
+ url: string;
1166
+ /**
1167
+ * The MIME type of the video file.
1168
+ */
1169
+ mimeType: VideoMimeType;
1170
+ /**
1171
+ * The URL of a thumbnail video to display while the video is queued for upload.
1172
+ *
1173
+ * @remarks
1174
+ * Requirements:
1175
+ *
1176
+ * - Must use HTTPS
1177
+ * - Must support [Cross-Origin Resource Sharing](https://www.canva.dev/docs/apps/cross-origin-resource-sharing/)
1178
+ * - Maximum length: 4096 characters
1179
+ * - The dimensions of the thumbnail video must match the video's aspect ratio to prevent the thumbnail from appearing squashed or stretched
1180
+ * - Must not be an AVI file. Although our APIs support uploading AVI videos, Canva can't preview them because of native support of browsers
1181
+ */
1182
+ thumbnailVideoUrl?: string;
1183
+ /**
1184
+ * The URL of a thumbnail image to use as a fallback if `thumbnailVideoUrl` isn't provided.
1185
+ * This can be an external URL or a data URL.
1186
+ *
1187
+ * @remarks
1188
+ * Requirements for external URLs:
1189
+ *
1190
+ * - Must use HTTPS
1191
+ * - Must support [Cross-Origin Resource Sharing](https://www.canva.dev/docs/apps/cross-origin-resource-sharing/)
1192
+ * - Must be a PNG, JPEG, or SVG file
1193
+ * - Maximum length: 4096 characters
1194
+ *
1195
+ * Requirements for data URLs:
1196
+ *
1197
+ * - Must include `;base64` for base64-encoded data
1198
+ * - Maximum size: 10MB (10 × 1024 × 1024 characters)
1199
+ * - The dimensions of the thumbnail must match the video's aspect ratio to prevent the thumbnail from appearing squashed or stretched
1200
+ */
1201
+ thumbnailImageUrl: string;
1202
+ /**
1203
+ * A disclosure identifying if the app generated this video using AI.
1204
+ *
1205
+ * @remarks
1206
+ * Helps users make informed decisions about the content they interact with.
1207
+ * See {@link AiDisclosure} for the full definition.
1208
+ *
1209
+ * **App Generated**
1210
+ *
1211
+ * 'app_generated' indicates when the app creates or significantly alters an asset using AI. Includes when
1212
+ * the app requests a third-party service to take similar action on a video using AI.
1213
+ *
1214
+ * Required for the following cases (this list is not exhaustive):
1215
+ * | Case | Reason |
1216
+ * | -- | -- |
1217
+ * | AI generates a new video from scratch | Creates new creative content |
1218
+ * | AI changes the style of the video e.g. makes it cartoon | Significantly alters the style |
1219
+ * | AI adds subtitles that rely on subjective interpretation | Creates new creative content |
1220
+ * | AI expands a video by generating new content to fill the edges | Creates new creative content |
1221
+ * | AI animates an image | Creates new creative content |
1222
+ * | AI fixes defects e.g. blur in a video by generating details | Creates new creative content |
1223
+ * | AI generates a talking head presenter | Creates new creative content |
1224
+ *
1225
+ * **None**
1226
+ *
1227
+ * 'none' indicates when the app doesn't create or significantly alter an asset using AI, or as a part of
1228
+ * a request to third-party hosted content.
1229
+ *
1230
+ * Required for the following cases (this list is not exhaustive):
1231
+ * | Case | Reason |
1232
+ * | -- | -- |
1233
+ * | Asset comes from an asset library | Didn't generate the asset itself |
1234
+ * | AI corrects red eyes | A minor correction |
1235
+ * | AI adjusts brightness and contrast on a video | Doesn't change original meaning by itself |
1236
+ * | AI creates a slow motion effect in a video | Doesn't change original meaning by itself |
1237
+ * | AI adds AI word-by-word transcribed subtitles to a video | Doesn't change original meaning by itself |
1238
+ */
1239
+ aiDisclosure: AiDisclosure;
1240
+ } & AllOrNone<Dimensions>;
897
1241
 
898
1242
  export {};