@canva/intents 2.5.1-beta.0 → 2.5.1-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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 2.5.1-beta.1 - 2026-05-12
4
+
5
+ ### Added
6
+
7
+ - Promote requestAiContent from alpha to beta
8
+
3
9
  ## 2.5.1-beta.0 - 2026-04-10
4
10
 
5
11
  ### Changed
package/beta.d.ts CHANGED
@@ -1,3 +1,49 @@
1
+ /**
2
+ * @beta
3
+ * Cancelled response where the generation was not completed.
4
+ * We use only 'cancelled' since we don't expect app developers to handle any statuses further (e.g. blocked, failed).
5
+ * These will be handled on Canva's AI generation surface.
6
+ */
7
+ declare type AiContentCancelledResponse = {
8
+ status: 'cancelled';
9
+ };
10
+
11
+ /**
12
+ * @beta
13
+ * Completed response for AI content generation.
14
+ * The value is the AI content generated for the app.
15
+ */
16
+ declare type AiContentCompletedResponse = {
17
+ status: 'completed';
18
+ value: string;
19
+ };
20
+
21
+ /**
22
+ * @beta
23
+ * All possible AI content request types.
24
+ */
25
+ declare type AiContentRequest = SocialCaptionRequest;
26
+
27
+ /**
28
+ * @beta
29
+ * All possible AI content response types.
30
+ */
31
+ declare type AiContentResponse = AiContentCompletedResponse | AiContentCancelledResponse;
32
+
33
+ /**
34
+ * @beta
35
+ * All possible statuses for an AI content response.
36
+ *
37
+ */
38
+ declare type AiContentResponseStatus = 'completed' | 'cancelled';
39
+
40
+ /**
41
+ * @beta
42
+ * Possible content type for AI content generation.
43
+ * Future types will be added here, e.g. 'hashtags'.
44
+ */
45
+ declare type AiContentType = 'social_caption';
46
+
1
47
  /**
2
48
  * @public
3
49
  * A disclosure identifying if the app generated this asset using AI.
@@ -139,6 +185,31 @@ declare type AppErrorInvocationContext = {
139
185
  message?: string;
140
186
  };
141
187
 
188
+ /**
189
+ * @beta
190
+ * Base interface for AI content requests.
191
+ */
192
+ declare type BaseAiContentRequest = {
193
+ /**
194
+ * The type of AI content generation which determines
195
+ * the kind of content the AI will generate.
196
+ */
197
+ type: AiContentType;
198
+ /**
199
+ * If a current value exists in the field, the AI content generation
200
+ * will be an edit-first experience.
201
+ * i.e. When the user has already entered a value in the field, the AI will
202
+ * generate a new value using the existing value as a starting point.
203
+ */
204
+ currentValue?: string;
205
+ /**
206
+ * The label chosen by the app developer for the field.
207
+ * It will be used in the UI to customize the copy.
208
+ * Required since it is essential context for the AI to generate the content.
209
+ */
210
+ fieldLabel: string;
211
+ };
212
+
142
213
  /**
143
214
  * @public
144
215
  * Base file requirement interface.
@@ -364,7 +435,15 @@ declare namespace content {
364
435
  EmailOutputFile,
365
436
  ContentMetadata,
366
437
  DesignContentMetadata,
367
- OutputPageMetadata
438
+ OutputPageMetadata,
439
+ AiContentType,
440
+ SocialCaptionRequest,
441
+ AiContentRequest,
442
+ AiContentResponseStatus,
443
+ AiContentCompletedResponse,
444
+ AiContentCancelledResponse,
445
+ AiContentResponse,
446
+ RequestAiContent
368
447
  }
369
448
  }
370
449
  export { content }
@@ -2682,9 +2761,47 @@ declare type RenderSettingsUiRequest = {
2682
2761
  registerOnContextChange: (opts: {
2683
2762
  onContextChange: OnContextChange;
2684
2763
  }) => Disposer;
2685
-
2764
+ /**
2765
+ * @beta
2766
+ * Function to trigger a request for AI content.
2767
+ *
2768
+ * Use this function to trigger a request for AI content.
2769
+ *
2770
+ * @param request - The request for AI content.
2771
+ * @returns A promise resolving to the AI content response with a status of 'completed' or 'cancelled'.
2772
+ * @example Requesting AI content
2773
+ * ```ts
2774
+ * async function onGenerateCaption() {
2775
+ * const result = await requestAiContent({
2776
+ * type: 'social_caption',
2777
+ * currentValue: settings.caption,
2778
+ * fieldLabel: 'Caption',
2779
+ * hints: {
2780
+ * maxLength: 2200,
2781
+ * },
2782
+ * });
2783
+ *
2784
+ * if (result.status !== 'completed') {
2785
+ * return;
2786
+ * }
2787
+ * const nextSettings = { ...settings, caption: result.value };
2788
+ * // ... set local state
2789
+ * await updatePublishSettings({
2790
+ * publishRef: JSON.stringify(nextSettings),
2791
+ * validityState: 'valid',
2792
+ * });
2793
+ * }
2794
+ * ```
2795
+ */
2796
+ requestAiContent: RequestAiContent;
2686
2797
  };
2687
2798
 
2799
+ /**
2800
+ * @beta
2801
+ * Function to trigger a request for AI content.
2802
+ */
2803
+ declare type RequestAiContent = (request: AiContentRequest) => Promise<AiContentResponse>;
2804
+
2688
2805
  /**
2689
2806
  * @public
2690
2807
  * Metadata specific to design content represented by a media selection.
@@ -2728,6 +2845,23 @@ declare interface SizedPreview extends BasePreview {
2728
2845
  heightPx: number;
2729
2846
  }
2730
2847
 
2848
+ /**
2849
+ * @beta
2850
+ * Request for social caption generation.
2851
+ */
2852
+ declare type SocialCaptionRequest = BaseAiContentRequest & {
2853
+ type: 'social_caption';
2854
+ /**
2855
+ * Hints for how the AI should generate the caption.
2856
+ */
2857
+ hints?: {
2858
+ /**
2859
+ * The maximum length of the caption.
2860
+ */
2861
+ maxLength?: number;
2862
+ };
2863
+ };
2864
+
2731
2865
  /**
2732
2866
  * @public
2733
2867
  * Cell containing a text value.
package/content/beta.d.ts CHANGED
@@ -1,3 +1,49 @@
1
+ /**
2
+ * @beta
3
+ * Cancelled response where the generation was not completed.
4
+ * We use only 'cancelled' since we don't expect app developers to handle any statuses further (e.g. blocked, failed).
5
+ * These will be handled on Canva's AI generation surface.
6
+ */
7
+ export declare type AiContentCancelledResponse = {
8
+ status: 'cancelled';
9
+ };
10
+
11
+ /**
12
+ * @beta
13
+ * Completed response for AI content generation.
14
+ * The value is the AI content generated for the app.
15
+ */
16
+ export declare type AiContentCompletedResponse = {
17
+ status: 'completed';
18
+ value: string;
19
+ };
20
+
21
+ /**
22
+ * @beta
23
+ * All possible AI content request types.
24
+ */
25
+ export declare type AiContentRequest = SocialCaptionRequest;
26
+
27
+ /**
28
+ * @beta
29
+ * All possible AI content response types.
30
+ */
31
+ export declare type AiContentResponse = AiContentCompletedResponse | AiContentCancelledResponse;
32
+
33
+ /**
34
+ * @beta
35
+ * All possible statuses for an AI content response.
36
+ *
37
+ */
38
+ export declare type AiContentResponseStatus = 'completed' | 'cancelled';
39
+
40
+ /**
41
+ * @beta
42
+ * Possible content type for AI content generation.
43
+ * Future types will be added here, e.g. 'hashtags'.
44
+ */
45
+ export declare type AiContentType = 'social_caption';
46
+
1
47
  /**
2
48
  * @public
3
49
  * {@link PublishContentError} indicating a custom error occurred in your app's implementation.
@@ -54,6 +100,31 @@ export declare type AppError = {
54
100
  errorCause?: ErrorCause;
55
101
  };
56
102
 
103
+ /**
104
+ * @beta
105
+ * Base interface for AI content requests.
106
+ */
107
+ declare type BaseAiContentRequest = {
108
+ /**
109
+ * The type of AI content generation which determines
110
+ * the kind of content the AI will generate.
111
+ */
112
+ type: AiContentType;
113
+ /**
114
+ * If a current value exists in the field, the AI content generation
115
+ * will be an edit-first experience.
116
+ * i.e. When the user has already entered a value in the field, the AI will
117
+ * generate a new value using the existing value as a starting point.
118
+ */
119
+ currentValue?: string;
120
+ /**
121
+ * The label chosen by the app developer for the field.
122
+ * It will be used in the UI to customize the copy.
123
+ * Required since it is essential context for the AI to generate the content.
124
+ */
125
+ fieldLabel: string;
126
+ };
127
+
57
128
  /**
58
129
  * @public
59
130
  * Base file requirement interface.
@@ -1476,9 +1547,47 @@ export declare type RenderSettingsUiRequest = {
1476
1547
  registerOnContextChange: (opts: {
1477
1548
  onContextChange: OnContextChange;
1478
1549
  }) => Disposer;
1479
-
1550
+ /**
1551
+ * @beta
1552
+ * Function to trigger a request for AI content.
1553
+ *
1554
+ * Use this function to trigger a request for AI content.
1555
+ *
1556
+ * @param request - The request for AI content.
1557
+ * @returns A promise resolving to the AI content response with a status of 'completed' or 'cancelled'.
1558
+ * @example Requesting AI content
1559
+ * ```ts
1560
+ * async function onGenerateCaption() {
1561
+ * const result = await requestAiContent({
1562
+ * type: 'social_caption',
1563
+ * currentValue: settings.caption,
1564
+ * fieldLabel: 'Caption',
1565
+ * hints: {
1566
+ * maxLength: 2200,
1567
+ * },
1568
+ * });
1569
+ *
1570
+ * if (result.status !== 'completed') {
1571
+ * return;
1572
+ * }
1573
+ * const nextSettings = { ...settings, caption: result.value };
1574
+ * // ... set local state
1575
+ * await updatePublishSettings({
1576
+ * publishRef: JSON.stringify(nextSettings),
1577
+ * validityState: 'valid',
1578
+ * });
1579
+ * }
1580
+ * ```
1581
+ */
1582
+ requestAiContent: RequestAiContent;
1480
1583
  };
1481
1584
 
1585
+ /**
1586
+ * @beta
1587
+ * Function to trigger a request for AI content.
1588
+ */
1589
+ export declare type RequestAiContent = (request: AiContentRequest) => Promise<AiContentResponse>;
1590
+
1482
1591
  /**
1483
1592
  * @public
1484
1593
  * Metadata specific to design content represented by a media selection.
@@ -1522,6 +1631,23 @@ export declare interface SizedPreview extends BasePreview {
1522
1631
  heightPx: number;
1523
1632
  }
1524
1633
 
1634
+ /**
1635
+ * @beta
1636
+ * Request for social caption generation.
1637
+ */
1638
+ export declare type SocialCaptionRequest = BaseAiContentRequest & {
1639
+ type: 'social_caption';
1640
+ /**
1641
+ * Hints for how the AI should generate the caption.
1642
+ */
1643
+ hints?: {
1644
+ /**
1645
+ * The maximum length of the caption.
1646
+ */
1647
+ maxLength?: number;
1648
+ };
1649
+ };
1650
+
1525
1651
  /**
1526
1652
  * @public
1527
1653
  * Successful response from updating the publish settings.
@@ -20,5 +20,5 @@ _export(exports, {
20
20
  }
21
21
  });
22
22
  const LATEST_VERSION = '2.5.0';
23
- const LATEST_VERSION_BETA = '2.5.1-beta.0';
23
+ const LATEST_VERSION_BETA = '2.5.1-beta.1';
24
24
  const LATEST_VERSION_ALPHA = 'NONE';
@@ -1,3 +1,3 @@
1
1
  export const LATEST_VERSION = '2.5.0';
2
- export const LATEST_VERSION_BETA = '2.5.1-beta.0';
2
+ export const LATEST_VERSION_BETA = '2.5.1-beta.1';
3
3
  export const LATEST_VERSION_ALPHA = 'NONE';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canva/intents",
3
- "version": "2.5.1-beta.0",
3
+ "version": "2.5.1-beta.1",
4
4
  "description": "The Canva Apps SDK Intents library",
5
5
  "author": "Canva Pty Ltd.",
6
6
  "license": "SEE LICENSE IN LICENSE.md FILE",