@canva/intents 0.0.0-beta.2

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/beta.d.ts ADDED
@@ -0,0 +1,975 @@
1
+ /**
2
+ * @beta
3
+ * {@link FetchDataTableError} indicating custom error occurred in the app's implementation.
4
+ * This can be used to indicate specific issues that are not covered by other error types.
5
+ */
6
+ declare type AppError = {
7
+ /**
8
+ * A custom error occurred in your app.
9
+ *
10
+ * Return this for application-specific errors that don't fit
11
+ * the other categories. Include a descriptive message explaining
12
+ * the error to the user.
13
+ */
14
+ status: "app_error";
15
+ /**
16
+ * Optional message explaining the error.
17
+ */
18
+ message?: string;
19
+ };
20
+
21
+ /**
22
+ * @beta
23
+ * {@link InvocationContext} indicating a custom error occurred during data refresh.
24
+ * Triggered when fetchDataTable returned 'app_error' status.
25
+ * UI should display the error message and help users recover.
26
+ */
27
+ declare type AppErrorInvocationContext = {
28
+ /**
29
+ * A custom error occurred during data refresh.
30
+ *
31
+ * This occurs when `fetchDataTable` returned 'app_error' during a refresh attempt.
32
+ * Your UI should display the error message and help users recover from the specific
33
+ * issue.
34
+ */
35
+ reason: "app_error";
36
+ /**
37
+ * The data source reference that caused the error during refresh.
38
+ */
39
+ dataSourceRef?: DataSourceRef;
40
+ /**
41
+ * The error message to display to the user.
42
+ */
43
+ message?: string;
44
+ };
45
+
46
+ /**
47
+ * @beta
48
+ * Cell containing a boolean value.
49
+ *
50
+ * @example Creating a boolean cell
51
+ * ```ts
52
+ * import type { BooleanDataTableCell } from '@canva/intents/data';
53
+ *
54
+ * const isActiveCell: BooleanDataTableCell = {
55
+ * type: 'boolean',
56
+ * value: true
57
+ * };
58
+ * ```
59
+ *
60
+ * @example Creating a boolean cell with false value
61
+ * ```ts
62
+ * import type { BooleanDataTableCell } from '@canva/intents/data';
63
+ *
64
+ * const isCompleteCell: BooleanDataTableCell = {
65
+ * type: 'boolean',
66
+ * value: false
67
+ * };
68
+ * ```
69
+ *
70
+ * @example Creating an empty boolean cell
71
+ * ```ts
72
+ * import type { BooleanDataTableCell } from '@canva/intents/data';
73
+ *
74
+ * const emptyBooleanCell: BooleanDataTableCell = {
75
+ * type: 'boolean',
76
+ * value: undefined
77
+ * };
78
+ * ```
79
+ */
80
+ export declare type BooleanDataTableCell = {
81
+ /**
82
+ * Indicates this cell contains a boolean value.
83
+ */
84
+ type: "boolean";
85
+ /**
86
+ * Boolean value (true or false).
87
+ *
88
+ * Use `undefined` for an empty cell.
89
+ */
90
+ value: boolean | undefined;
91
+ };
92
+
93
+ /**
94
+ * @beta
95
+ * Configuration for a table column.
96
+ */
97
+ export declare type ColumnConfig = {
98
+ /**
99
+ * Name for the column, displayed as header text.
100
+ *
101
+ * If `undefined`, the column will have no header text.
102
+ */
103
+ name: string | undefined;
104
+ /**
105
+ * Expected data type for cells in this column.
106
+ *
107
+ * Use a specific `DataType` for columns with consistent types,
108
+ * or `'variant'` for columns that may contain mixed types.
109
+ */
110
+ type: DataType | "variant";
111
+ };
112
+
113
+ declare namespace data {
114
+ export {
115
+ prepareDataConnector,
116
+ DataConnectorIntent,
117
+ FetchDataTableParams,
118
+ RenderSelectionUiParams,
119
+ InvocationContext,
120
+ FetchDataTableResult,
121
+ FetchDataTableCompleted,
122
+ DataTableMetadata,
123
+ FetchDataTableError,
124
+ ValidationError,
125
+ InternalError,
126
+ UpdateDataRefResult,
127
+ DataSourceRef,
128
+ DataTableLimit,
129
+ DataType,
130
+ DataTable,
131
+ ColumnConfig,
132
+ DataTableRow,
133
+ DataTableCell,
134
+ DateDataTableCell,
135
+ StringDataTableCell,
136
+ NumberDataTableCell,
137
+ NumberCellMetadata,
138
+ BooleanDataTableCell,
139
+ };
140
+ }
141
+ export { data };
142
+
143
+ /**
144
+ * @beta
145
+ * Main interface for implementing the Data Connector intent.
146
+ *
147
+ * Implementing the Data Connector intent enables apps to import external data into Canva.
148
+ * This allows users to select, preview, and refresh data from external sources.
149
+ */
150
+ export declare type DataConnectorIntent = {
151
+ /**
152
+ * Fetches structured data from an external source.
153
+ *
154
+ * This action is called in two scenarios:
155
+ *
156
+ * - During data selection to preview data before import (when {@link RenderSelectionUiParams.updateDataRef} is called).
157
+ * - When refreshing previously imported data (when the user requests an update).
158
+ *
159
+ * @param params - Parameters for the data fetching operation.
160
+ * @returns A promise resolving to either a successful result with data or an error.
161
+ *
162
+ * @example Fetching data from an external source
163
+ * ```ts
164
+ * import type { FetchDataTableParams, FetchDataTableResult } from '@canva/intents/data';
165
+ *
166
+ * async function fetchDataTable(params: FetchDataTableParams): Promise<FetchDataTableResult> {
167
+ * const { dataSourceRef, limit, signal } = params;
168
+ *
169
+ * // Check if the operation has been aborted.
170
+ * if (signal.aborted) {
171
+ * return { status: 'app_error', message: 'The data fetch operation was cancelled.' };
172
+ * }
173
+ *
174
+ * // ... data fetching logic using dataSourceRef, limit, and signal ...
175
+ *
176
+ * // Placeholder for a successful result.
177
+ * return {
178
+ * status: 'completed',
179
+ * dataTable: { rows: [{ cells: [{ type: 'string', value: 'Fetched data' }] }] }
180
+ * };
181
+ * }
182
+ * ```
183
+ */
184
+ fetchDataTable: (
185
+ params: FetchDataTableParams,
186
+ ) => Promise<FetchDataTableResult>;
187
+ /**
188
+ * Renders a user interface for selecting and configuring data from your external sources.
189
+ *
190
+ * @param params - Configuration and callbacks for the data selection UI.
191
+ *
192
+ * @example Rendering a data selection UI
193
+ * ```ts
194
+ * import type { RenderSelectionUiParams } from '@canva/intents/data';
195
+ *
196
+ * async function renderSelectionUi(params: RenderSelectionUiParams): Promise<void> {
197
+ * // UI rendering logic.
198
+ * // Example: if user selects data 'ref123'.
199
+ * const selectedRef = { source: 'ref123', title: 'My Selected Table' };
200
+ * try {
201
+ * const result = await params.updateDataRef(selectedRef);
202
+ * if (result.status === 'completed') {
203
+ * console.log('Selection valid and preview updated.');
204
+ * } else {
205
+ * console.error('Selection error:', result.status);
206
+ * }
207
+ * } catch (error) {
208
+ * console.error('An unexpected error occurred during data ref update:', error);
209
+ * }
210
+ * }
211
+ * ```
212
+ */
213
+ renderSelectionUi: (params: RenderSelectionUiParams) => void;
214
+ };
215
+
216
+ /**
217
+ * @beta
218
+ * {@link InvocationContext} indicating initial data selection flow or edit of existing data.
219
+ */
220
+ declare type DataSelectionInvocationContext = {
221
+ /**
222
+ * Initial data selection or editing existing data.
223
+ *
224
+ * This is the standard flow when:
225
+ *
226
+ * - A user is selecting data for the first time
227
+ * - A user is editing a previous selection
228
+ *
229
+ * If `dataSourceRef` is provided, this indicates an edit flow, and you should
230
+ * pre-populate your UI with this selection.
231
+ */
232
+ reason: "data_selection";
233
+ /**
234
+ * If dataSourceRef is provided, this is an edit of existing data flow and UI should be pre-populated.
235
+ */
236
+ dataSourceRef?: DataSourceRef;
237
+ };
238
+
239
+ /**
240
+ * @beta
241
+ * Reference to an external data source that can be used to fetch data.
242
+ * Created by Data Connector apps and stored by Canva for data refresh operations.
243
+ *
244
+ * You create this object in your data selection UI and pass it to the
245
+ * `updateDataRef` callback. Canva stores this reference and uses it for
246
+ * future data refresh operations.
247
+ *
248
+ * Maximum size: 5KB
249
+ *
250
+ * @example Defining how to locate external data
251
+ * ```ts
252
+ * const dataSourceRef: DataSourceRef = {
253
+ * source: JSON.stringify({
254
+ * reportId: "monthly_sales_001",
255
+ * filters: { year: 2023, region: "NA" }
256
+ * }),
257
+ * title: "Monthly Sales Report (NA, 2023)"
258
+ * };
259
+ * ```
260
+ */
261
+ export declare type DataSourceRef = {
262
+ /**
263
+ * Information needed to identify and retrieve data from your source.
264
+ *
265
+ * This string should contain all the information your app needs to
266
+ * fetch the exact data selection later. Typically, this is a serialized
267
+ * object with query parameters, identifiers, or filters.
268
+ *
269
+ * You are responsible for encoding and decoding this value appropriately.
270
+ *
271
+ * Maximum size: 5KB
272
+ */
273
+ source: string;
274
+ /**
275
+ * A human-readable description of the data reference.
276
+ *
277
+ * This title may be displayed to users in the Canva interface to help
278
+ * them identify the data source.
279
+ *
280
+ * Maximum length: 255 characters
281
+ */
282
+ title?: string;
283
+ };
284
+
285
+ /**
286
+ * @beta
287
+ * {@link ValidationError} indicating the data source reference {@link DataSourceRef} exceeds the 5KB size limit.
288
+ */
289
+ declare type DataSourceRefLimitExceeded = {
290
+ /**
291
+ * The data source reference exceeds the 5KB size limit.
292
+ *
293
+ * Your app should reduce the size of the `DataSourceRef.source` string.
294
+ */
295
+ status: "data_source_ref_limit_exceeded";
296
+ };
297
+
298
+ /**
299
+ * @beta
300
+ * {@link ValidationError} indicating the data source title {@link DataSourceRef.title} exceeds the 255 character limit.
301
+ */
302
+ declare type DataSourceTitleLimitExceed = {
303
+ /**
304
+ * The data source title exceeds the 255 character limit.
305
+ *
306
+ * Your app should provide a shorter title for the data source.
307
+ */
308
+ status: "data_source_title_limit_exceeded";
309
+ };
310
+
311
+ /**
312
+ * @beta
313
+ * Structured tabular data for import into Canva.
314
+ *
315
+ * This format allows you to provide typed data with proper formatting
316
+ * to ensure it displays correctly in Canva designs.
317
+ *
318
+ * @example Creating a data table
319
+ * ```ts
320
+ * import type { ColumnConfig, DataTableCell, DataTable, DataTableRow } from '@canva/intents/data';
321
+ *
322
+ * const myTable: DataTable = {
323
+ * columnConfigs: [
324
+ * { name: 'Name', type: 'string' },
325
+ * { name: 'Age', type: 'number' },
326
+ * { name: 'Subscribed', type: 'boolean' },
327
+ * { name: 'Join Date', type: 'date' }
328
+ * ],
329
+ * rows: [
330
+ * {
331
+ * cells: [
332
+ * { type: 'string', value: 'Alice' },
333
+ * { type: 'number', value: 30 },
334
+ * { type: 'boolean', value: true },
335
+ * { type: 'date', value: Math.floor(new Date('2023-01-15').getTime() / 1000) }
336
+ * ]
337
+ * },
338
+ * {
339
+ * cells: [
340
+ * { type: 'string', value: 'Bob' },
341
+ * { type: 'number', value: 24 },
342
+ * { type: 'boolean', value: false },
343
+ * { type: 'date', value: Math.floor(new Date('2022-07-20').getTime() / 1000) }
344
+ * ]
345
+ * }
346
+ * ]
347
+ * };
348
+ * ```
349
+ */
350
+ export declare type DataTable = {
351
+ /**
352
+ * Column definitions with names and data types.
353
+ *
354
+ * These help Canva interpret and display your data correctly.
355
+ */
356
+ columnConfigs?: ColumnConfig[];
357
+ /**
358
+ * The data rows containing the actual values.
359
+ *
360
+ * Each row contains an array of cells with typed data values.
361
+ */
362
+ rows: DataTableRow[];
363
+ };
364
+
365
+ /**
366
+ * @beta
367
+ * Generic type for table cells that resolves to a specific cell type.
368
+ */
369
+ export declare type DataTableCell<T extends DataType = DataType> = {
370
+ date: DateDataTableCell;
371
+ string: StringDataTableCell;
372
+ number: NumberDataTableCell;
373
+ boolean: BooleanDataTableCell;
374
+ }[T];
375
+
376
+ /**
377
+ * @beta
378
+ * {@link ValidationError} indicating the data table format is invalid.
379
+ *
380
+ * This can happen due to:
381
+ *
382
+ * - {@link DataType} mismatches (e.g., a number in a string-typed column, a number value in a string cell type)
383
+ * - Unsupported cell types
384
+ * - Inconsistent column configurations (e.g., the number of columns in the data table does not match the number of {@link ColumnConfig})
385
+ */
386
+ declare type DataTableInvalidFormat = {
387
+ /**
388
+ * The data table format is invalid.
389
+ *
390
+ * This error occurs due to:
391
+ *
392
+ * - Data type mismatches (e.g., number in string column)
393
+ * - Unsupported cell types
394
+ * - Inconsistent column configurations
395
+ *
396
+ * Your app should ensure the data conforms to the expected format.
397
+ */
398
+ status: "data_table_invalid_format";
399
+ };
400
+
401
+ /**
402
+ * @beta
403
+ * Maximum dimensions for imported data tables.
404
+ */
405
+ export declare type DataTableLimit = {
406
+ /**
407
+ * The maximum number of rows allowed.
408
+ *
409
+ * Your app should ensure data does not exceed this limit.
410
+ */
411
+ row: number;
412
+ /**
413
+ * The maximum number of columns allowed.
414
+ *
415
+ * Your app should ensure data does not exceed this limit.
416
+ */
417
+ column: number;
418
+ };
419
+
420
+ /**
421
+ * @beta
422
+ * {@link ValidationError} indicating that the data table exceeds the allowed limits.
423
+ *
424
+ * This can happen when:
425
+ * - Number of rows exceeds the row limit
426
+ * - Number of columns exceeds the column limit
427
+ * - Total data size exceeds 200KB
428
+ */
429
+ declare type DataTableLimitExceeded = {
430
+ /**
431
+ * The data exceeds the maximum allowed limits.
432
+ *
433
+ * This error occurs when:
434
+ *
435
+ * - Number of rows exceeds the row limit
436
+ * - Number of columns exceeds the column limit
437
+ * - Total data size exceeds the allowed size limit
438
+ *
439
+ * Your app should help users select a subset of their data,
440
+ * or provide filtering options to reduce the data size.
441
+ */
442
+ status: "data_table_limit_exceeded";
443
+ };
444
+
445
+ /**
446
+ * @beta
447
+ * Metadata providing additional context about the imported data.
448
+ */
449
+ export declare type DataTableMetadata = {
450
+ /**
451
+ * A human-readable description of the dataset.
452
+ *
453
+ * This description helps users understand what data they are importing.
454
+ */
455
+ description?: string;
456
+ /**
457
+ * Information about the data provider or source.
458
+ */
459
+ providerInfo?: {
460
+ /**
461
+ * Name of the data provider.
462
+ */
463
+ name: string;
464
+ /**
465
+ * URL to the provider's website or related resource.
466
+ */
467
+ url?: string;
468
+ };
469
+ };
470
+
471
+ /**
472
+ * @beta
473
+ * {@link ValidationError} indicating the provided data table metadata is invalid (e.g not a valid OXML formatting string in {@link NumberCellMetadata.formatting}).
474
+ */
475
+ declare type DataTableMetadataInvalid = {
476
+ /**
477
+ * The provided metadata is invalid.
478
+ *
479
+ * This typically happens with invalid formatting patterns in {@link NumberCellMetadata.formatting} strings.
480
+ */
481
+ status: "data_table_metadata_invalid";
482
+ };
483
+
484
+ /**
485
+ * @beta
486
+ * A row in the data table.
487
+ *
488
+ * @example Creating a single row of data cells
489
+ * ```ts
490
+ * import type { DataTableCell, DataTableRow } from '@canva/intents/data';
491
+ *
492
+ * const row: DataTableRow = {
493
+ * cells: [
494
+ * { type: 'string', value: 'Product Alpha' },
495
+ * { type: 'number', value: 199.99 },
496
+ * { type: 'boolean', value: true }
497
+ * ]
498
+ * };
499
+ * ```
500
+ */
501
+ export declare type DataTableRow = {
502
+ /**
503
+ * Array of cells containing the data values.
504
+ *
505
+ * Each cell must have a type that matches the corresponding column definition (if provided).
506
+ */
507
+ cells: DataTableCell<DataType>[];
508
+ };
509
+
510
+ /**
511
+ * @beta
512
+ * Data types supported for table cells.
513
+ */
514
+ export declare type DataType = "string" | "number" | "date" | "boolean";
515
+
516
+ /**
517
+ * @beta
518
+ * Cell containing a date value.
519
+ *
520
+ * @example Creating a date cell
521
+ * ```ts
522
+ * import type { DateDataTableCell } from '@canva/intents/data';
523
+ *
524
+ * const todayCell: DateDataTableCell = {
525
+ * type: 'date',
526
+ * value: Math.floor(Date.now() / 1000) // Unix timestamp in seconds
527
+ * };
528
+ *
529
+ * const emptyDateCell: DateDataTableCell = {
530
+ * type: 'date',
531
+ * value: undefined
532
+ * };
533
+ * ```
534
+ */
535
+ export declare type DateDataTableCell = {
536
+ /**
537
+ * Indicates this cell contains a date value.
538
+ */
539
+ type: "date";
540
+ /**
541
+ * Unix timestamp in seconds representing the date.
542
+ *
543
+ * Use `undefined` for an empty cell.
544
+ */
545
+ value: number | undefined;
546
+ };
547
+
548
+ declare namespace design {
549
+ export { prepareDesignEditor, DesignEditorIntent };
550
+ }
551
+ export { design };
552
+
553
+ /**
554
+ * @beta
555
+ *
556
+ * Main interface for implementing the DesignEditor intent.
557
+ *
558
+ * Implementing the DesignEditor Intent enables apps to assist users in editing designs,
559
+ * by presenting interactive and creative tooling alongside the Canva design surface.
560
+ */
561
+ export declare type DesignEditorIntent = {
562
+ /**
563
+ * Renders the UI containing the app’s functionality.
564
+ *
565
+ * @example
566
+ * ```tsx
567
+ * function render() {
568
+ * // render your UI using your preferred framework
569
+ * }
570
+ * ```
571
+ */
572
+ render: () => void;
573
+ };
574
+
575
+ /**
576
+ * @beta
577
+ * Successful result from `fetchDataTable` action.
578
+ */
579
+ export declare type FetchDataTableCompleted = {
580
+ /**
581
+ * Indicates the fetch operation completed successfully
582
+ */
583
+ status: "completed";
584
+ /**
585
+ * The fetched data formatted as a data table.
586
+ */
587
+ dataTable: DataTable;
588
+ /**
589
+ * Optional metadata providing additional context about the data.
590
+ */
591
+ metadata?: DataTableMetadata;
592
+ };
593
+
594
+ /**
595
+ * @beta
596
+ * Error results that can be returned from `fetchDataTable` method.
597
+ */
598
+ export declare type FetchDataTableError =
599
+ | OutdatedSourceRefError
600
+ | RemoteRequestFailedError
601
+ | AppError;
602
+
603
+ /**
604
+ * @beta
605
+ * Parameters for the fetchDataTable action.
606
+ */
607
+ export declare type FetchDataTableParams = {
608
+ /**
609
+ * Reference to the data source to fetch.
610
+ *
611
+ * This contains the information needed to identify and retrieve the specific data
612
+ * that was previously selected by the user.
613
+ *
614
+ * Use this to query your external data service.
615
+ */
616
+ dataSourceRef: DataSourceRef;
617
+ /**
618
+ * Maximum row and column limits for the imported data.
619
+ *
620
+ * Your app must ensure the returned data does not exceed these limits.
621
+ *
622
+ * If the requested data would exceed these limits, either:
623
+ *
624
+ * - Truncate the data to fit within limits, or
625
+ * - Return a 'data_table_limit_exceeded' error
626
+ */
627
+ limit: DataTableLimit;
628
+ /**
629
+ * Standard DOM AbortSignal for cancellation support.
630
+ *
631
+ * Your app should monitor this signal and abort any ongoing operations if it becomes aborted.
632
+ */
633
+ signal: AbortSignal;
634
+ };
635
+
636
+ /**
637
+ * @beta
638
+ * Result returned from the `fetchDataTable` action.
639
+ */
640
+ export declare type FetchDataTableResult =
641
+ | FetchDataTableCompleted
642
+ | FetchDataTableError;
643
+
644
+ /**
645
+ * @beta
646
+ * System errors that may occur during data operations.
647
+ */
648
+ export declare type InternalError = {
649
+ /**
650
+ * An unexpected system error occurred.
651
+ *
652
+ * These errors are typically not related to your app's implementation
653
+ * but indicate issues with the platform.
654
+ */
655
+ status: "internal_error";
656
+ /**
657
+ * The cause of the error.
658
+ */
659
+ cause?: unknown;
660
+ };
661
+
662
+ /**
663
+ * @beta
664
+ * Information explaining why the data selection UI was launched.
665
+ */
666
+ export declare type InvocationContext =
667
+ | DataSelectionInvocationContext
668
+ | OutdatedSourceRefInvocationContext
669
+ | AppErrorInvocationContext;
670
+
671
+ /**
672
+ * @beta
673
+ * Formatting metadata for number cells.
674
+ *
675
+ * @example Formatting as currency
676
+ * ```ts
677
+ * import type { NumberDataTableCell } from '@canva/intents/data';
678
+ *
679
+ * const currencyCell: NumberDataTableCell = {
680
+ * type: 'number',
681
+ * value: 1234.57,
682
+ * metadata: { formatting: '[$$]#,##0.00' }
683
+ * };
684
+ * ```
685
+ *
686
+ * @example Formatting as a percentage
687
+ * ```ts
688
+ * import type { NumberDataTableCell } from '@canva/intents/data';
689
+ *
690
+ * const percentCell: NumberDataTableCell = {
691
+ * type: 'number',
692
+ * value: 0.1234,
693
+ * metadata: { formatting: '0.00%' }
694
+ * };
695
+ * ```
696
+ *
697
+ * @example Applying a thousands separator
698
+ * ```ts
699
+ * import type { NumberDataTableCell } from '@canva/intents/data';
700
+ *
701
+ * const largeNumberCell: NumberDataTableCell = {
702
+ * type: 'number',
703
+ * value: 1234567.89234,
704
+ * metadata: { formatting: '#,##0.00' }
705
+ * };
706
+ * ```
707
+ */
708
+ export declare type NumberCellMetadata = {
709
+ /**
710
+ * Formatting pattern using Office Open XML Format.
711
+ *
712
+ * These patterns control how numbers are displayed to users,
713
+ * including currency symbols, decimal places, and separators.
714
+ */
715
+ formatting?: string;
716
+ };
717
+
718
+ /**
719
+ * @beta
720
+ * Cell containing a numeric value.
721
+ *
722
+ * @example Creating a number cell
723
+ * ```ts
724
+ * import type { NumberCellMetadata, NumberDataTableCell } from '@canva/intents/data';
725
+ *
726
+ * const priceCell: NumberDataTableCell = {
727
+ * type: 'number',
728
+ * value: 29.99,
729
+ * metadata: { formatting: '[$$]#,##0.00' }
730
+ * };
731
+ *
732
+ * const quantityCell: NumberDataTableCell = {
733
+ * type: 'number',
734
+ * value: 150
735
+ * };
736
+ *
737
+ * const emptyNumberCell: NumberDataTableCell = {
738
+ * type: 'number',
739
+ * value: undefined
740
+ * };
741
+ * ```
742
+ */
743
+ export declare type NumberDataTableCell = {
744
+ /**
745
+ * Indicates this cell contains a number value.
746
+ */
747
+ type: "number";
748
+ /**
749
+ * Numeric value within safe integer range.
750
+ *
751
+ * Valid range: `Number.MIN_SAFE_INTEGER` to `Number.MAX_SAFE_INTEGER`
752
+ *
753
+ * Invalid values:
754
+ *
755
+ * - Infinity or -Infinity
756
+ * - NaN
757
+ * - Negative zero (-0)
758
+ * - Denormalized numbers
759
+ *
760
+ * Use `undefined` for an empty cell.
761
+ */
762
+ value: number | undefined;
763
+ /**
764
+ * Optional formatting information for displaying the number.
765
+ *
766
+ * @example Applying display formatting to a number
767
+ * ```ts
768
+ * import type { NumberCellMetadata } from '@canva/intents/data';
769
+ *
770
+ * const currencyFormatting: NumberCellMetadata = { formatting: '[$USD]#,##0.00' };
771
+ * const percentageFormatting: NumberCellMetadata = { formatting: '0.00%' };
772
+ * ```
773
+ */
774
+ metadata?: NumberCellMetadata;
775
+ };
776
+
777
+ /**
778
+ * @beta
779
+ * {@link FetchDataTableError} indicating the data source reference is no longer valid.
780
+ * This will trigger a re-selection flow for the user.
781
+ */
782
+ declare type OutdatedSourceRefError = {
783
+ /**
784
+ * The data source reference is no longer valid.
785
+ *
786
+ * Return this error when the DataSourceRef cannot be used to retrieve data,
787
+ * for example:
788
+ *
789
+ * - The referenced dataset has been deleted
790
+ * - Access permissions have changed
791
+ * - The structure of the data has fundamentally changed
792
+ *
793
+ * This will trigger a re-selection flow, allowing the user to choose a new
794
+ * data source.
795
+ */
796
+ status: "outdated_source_ref";
797
+ };
798
+
799
+ /**
800
+ * @beta
801
+ * {@link InvocationContext} indicating an error occurred because the previously selected data source reference is no longer valid.
802
+ * Triggered when fetchDataTable returned 'outdated_source_ref' during data refresh.
803
+ * UI should guide the user to reselect or reconfigure their data.
804
+ */
805
+ declare type OutdatedSourceRefInvocationContext = {
806
+ /**
807
+ * Previously selected data source reference is no longer valid.
808
+ *
809
+ * This occurs when `fetchDataTable` returned 'outdated_source_ref' during a
810
+ * refresh attempt. Your UI should guide the user to select a new data source
811
+ * or update their selection.
812
+ *
813
+ * The outdated reference is provided to help you suggest an appropriate replacement.
814
+ */
815
+ reason: "outdated_source_ref";
816
+ /**
817
+ * The outdated data source reference that caused the error during refresh.
818
+ */
819
+ dataSourceRef?: DataSourceRef;
820
+ };
821
+
822
+ /**
823
+ * @beta
824
+ *
825
+ * Prepares the `DataConnectorIntent`.
826
+ */
827
+ declare const prepareDataConnector: (
828
+ implementation: DataConnectorIntent,
829
+ ) => void;
830
+
831
+ /**
832
+ * @beta
833
+ *
834
+ * Prepares a {@link DesignEditorIntent|DesignEditor Intent}.
835
+ *
836
+ * @example
837
+ * ```tsx
838
+ * import { prepareDesignEditor } from '@canva/intents/design';
839
+ *
840
+ * function render() {
841
+ * // render your UI using your preferred framework
842
+ * }
843
+ *
844
+ * prepareDesignEditor({
845
+ * render,
846
+ * });
847
+ * ```
848
+ */
849
+ declare const prepareDesignEditor: (implementation: DesignEditorIntent) => void;
850
+
851
+ /**
852
+ * @beta
853
+ * {@link FetchDataTableError} indicating failure to fetch data from the external source.
854
+ * Typically due to network issues or API failures.
855
+ */
856
+ declare type RemoteRequestFailedError = {
857
+ /**
858
+ * Failed to fetch data from the external source.
859
+ *
860
+ * Return this error for network issues, API failures, or other
861
+ * connectivity problems that prevent data retrieval.
862
+ */
863
+ status: "remote_request_failed";
864
+ };
865
+
866
+ /**
867
+ * @beta
868
+ * Parameters for rendering the data selection UI.
869
+ */
870
+ export declare type RenderSelectionUiParams = {
871
+ /**
872
+ * Context information about why the data selection UI is being launched.
873
+ *
874
+ * Use this to adapt your UI for different scenarios:
875
+ *
876
+ * - 'data_selection': Initial data selection or editing existing data
877
+ * - 'outdated_source_ref': Previous reference is no longer valid, guide user to reselect
878
+ * - 'app_error': Custom error occurred, show error message and recovery options
879
+ *
880
+ * When `dataSourceRef` is provided, pre-populate your UI with this selection.
881
+ */
882
+ invocationContext: InvocationContext;
883
+ /**
884
+ * Maximum allowed rows and columns for the imported data.
885
+ *
886
+ * Your UI should inform users of these constraints and prevent or warn about
887
+ * selections that would exceed them. This helps users understand why certain
888
+ * data sets might not be available for selection.
889
+ */
890
+ limit: DataTableLimit;
891
+ /**
892
+ * Callback to preview selected data before finalizing import.
893
+ *
894
+ * Call this function when the user selects data to:
895
+ *
896
+ * 1. Show a preview of the selected data to the user
897
+ * 2. Validate that the selection meets system requirements
898
+ *
899
+ * Calling this function will trigger your `fetchDataTable` implementation.
900
+ * Wait for the promise to resolve to determine if the selection is valid.
901
+ *
902
+ * @param dataSourceRef - Reference object identifying the selected data
903
+ * @returns Promise resolving to success or an error result
904
+ */
905
+ updateDataRef: (dataSourceRef: DataSourceRef) => Promise<UpdateDataRefResult>;
906
+ };
907
+
908
+ /**
909
+ * @beta
910
+ * Cell containing a text value.
911
+ *
912
+ * @example Creating a string cell
913
+ * ```ts
914
+ * import type { StringDataTableCell } from '@canva/intents/data';
915
+ *
916
+ * const nameCell: StringDataTableCell = {
917
+ * type: 'string',
918
+ * value: 'John Doe'
919
+ * };
920
+ *
921
+ * const emptyStringCell: StringDataTableCell = {
922
+ * type: 'string',
923
+ * value: undefined
924
+ * };
925
+ * ```
926
+ */
927
+ export declare type StringDataTableCell = {
928
+ /**
929
+ * Indicates this cell contains a string value.
930
+ */
931
+ type: "string";
932
+ /**
933
+ * Text content of the cell.
934
+ *
935
+ * Maximum length: 10,000 characters
936
+ *
937
+ * Use `undefined` for an empty cell.
938
+ */
939
+ value: string | undefined;
940
+ };
941
+
942
+ /**
943
+ * @beta
944
+ * Successful result from the {@link RenderSelectionUiParams.updateDataRef} callback.
945
+ */
946
+ declare type UpdateDataRefCompleted = {
947
+ /**
948
+ * The data selection was successful and can be previewed.
949
+ */
950
+ status: "completed";
951
+ };
952
+
953
+ /**
954
+ * @beta
955
+ * Result returned from the {@link RenderSelectionUiParams.updateDataRef} callback.
956
+ * Indicates whether {@link DataSourceRef} update succeeded or failed.
957
+ */
958
+ export declare type UpdateDataRefResult =
959
+ | UpdateDataRefCompleted
960
+ | FetchDataTableError
961
+ | ValidationError
962
+ | InternalError;
963
+
964
+ /**
965
+ * @beta
966
+ * Validation errors that can occur when processing data.
967
+ */
968
+ export declare type ValidationError =
969
+ | DataTableLimitExceeded
970
+ | DataTableInvalidFormat
971
+ | DataTableMetadataInvalid
972
+ | DataSourceRefLimitExceeded
973
+ | DataSourceTitleLimitExceed;
974
+
975
+ export {};