@canva/intents 2.0.1-beta.1 → 2.0.2-beta.3

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/asset/beta.d.ts CHANGED
@@ -1 +1,236 @@
1
+ /**
2
+ * @beta
3
+ * Union of all supported asset types.
4
+ */
5
+ export declare type Asset =
6
+ | ImageAsset
7
+ | VideoAsset
8
+ | AudioAsset
9
+ | DocumentAsset
10
+ | SheetAsset
11
+ | GenericAsset;
12
+
13
+ /**
14
+ * @beta
15
+ * Reference to an asset. Used as a unique identifier.
16
+ */
17
+ export declare type AssetRef = string & {
18
+ __assetRef: never;
19
+ };
20
+
21
+ /**
22
+ * @beta
23
+ * Audio asset result structure.
24
+ */
25
+ export declare type AudioAsset = BaseAsset & {
26
+ type: "audio";
27
+ mimeType:
28
+ | "audio/mpeg"
29
+ | "audio/mp4"
30
+ | "audio/x-m4a"
31
+ | "audio/mp3"
32
+ | "audio/ogg"
33
+ | "audio/wav"
34
+ | "audio/x-wav"
35
+ | "audio/x-pn-wav"
36
+ | "audio/wave"
37
+ | "audio/vnd.wave"
38
+ | "audio/webm";
39
+ };
40
+
41
+ /**
42
+ * @beta
43
+ * Base structure for an asset result.
44
+ */
45
+ export declare type BaseAsset = {
46
+ name: string;
47
+ url: string;
48
+ };
49
+
50
+ /**
51
+ * @beta
52
+ * Document asset result structure.
53
+ */
54
+ export declare type DocumentAsset = BaseAsset & {
55
+ type: "document";
56
+ parentRef?: AssetRef;
57
+ mimeType: DocumentMimeType;
58
+ };
59
+
60
+ /**
61
+ * @beta
62
+ * Supported mimetype for document assets.
63
+ */
64
+ export declare type DocumentMimeType =
65
+ | "application/pdf"
66
+ | "application/msword"
67
+ | "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
68
+ | "text/plain"
69
+ | "text/markdown";
70
+
71
+ /**
72
+ * @beta
73
+ * Request parameters for URL expansion.
74
+ */
75
+ export declare type ExpandUrlRequest = {
76
+ url: string;
77
+ requestConnection: () => Promise<void>;
78
+ };
79
+
80
+ /**
81
+ * @beta
82
+ * Response from URL expansion operation.
83
+ */
84
+ export declare type ExpandUrlResponse =
85
+ | {
86
+ status: "completed";
87
+ result: ExpandUrlResult;
88
+ }
89
+ | {
90
+ status: "not_found";
91
+ };
92
+
93
+ /**
94
+ * @beta
95
+ * Result of completed URL expansion.
96
+ */
97
+ export declare type ExpandUrlResult = {
98
+ ref: UrlExpanderAssetRef;
99
+ };
100
+
101
+ /**
102
+ * @beta
103
+ * Generic asset result structure.
104
+ * A generic asset is any file that is not already covered by other asset types such as ImageAsset etc.
105
+ * It is an error to pass a mime type that is covered by another asset type.
106
+ */
107
+ export declare type GenericAsset = BaseAsset & {
108
+ type: "generic";
109
+ mimeType: string;
110
+ };
111
+
112
+ /**
113
+ * @beta
114
+ * Completed response from content retrieval operation.
115
+ */
116
+ export declare type GetContentCompletedResponse = {
117
+ status: "completed";
118
+ result: {
119
+ type: "asset";
120
+ asset: Asset;
121
+ };
122
+ };
123
+
124
+ /**
125
+ * @beta
126
+ * Error response from content retrieval operation.
127
+ */
128
+ export declare type GetContentErrorResponse = {
129
+ status: "app_error";
130
+ message: string;
131
+ };
132
+
133
+ /**
134
+ * @beta
135
+ * Request parameters for content retrieval.
136
+ */
137
+ export declare type GetContentRequest = {
138
+ ref: UrlExpanderAssetRef;
139
+ requestConnection: () => Promise<void>;
140
+ };
141
+
142
+ /**
143
+ * @beta
144
+ * Response from content retrieval operation.
145
+ */
146
+ export declare type GetContentResponse =
147
+ | GetContentCompletedResponse
148
+ | GetContentErrorResponse;
149
+
150
+ /**
151
+ * @beta
152
+ * Image asset result structure.
153
+ */
154
+ export declare type ImageAsset = BaseAsset & {
155
+ type: "image";
156
+ thumbnailUrl: string;
157
+ parentRef?: AssetRef;
158
+ mimeType:
159
+ | "image/heic"
160
+ | "image/jpeg"
161
+ | "image/png"
162
+ | "image/svg+xml"
163
+ | "image/tiff"
164
+ | "image/webp";
165
+ };
166
+
167
+ /**
168
+ * @beta
169
+ *
170
+ * Prepares the `UrlExpanderIntent`.
171
+ */
172
+ export declare const prepareUrlExpander: (
173
+ implementation: UrlExpanderIntent,
174
+ ) => void;
175
+
176
+ /**
177
+ * @beta
178
+ * Sheet asset result structure.
179
+ */
180
+ export declare type SheetAsset = BaseAsset & {
181
+ type: "sheet";
182
+ parentRef?: AssetRef;
183
+ mimeType: SheetMimeType;
184
+ };
185
+
186
+ /**
187
+ * @beta
188
+ * Supported mimetype for sheet assets.
189
+ */
190
+ export declare type SheetMimeType =
191
+ | "text/csv"
192
+ | "application/vnd.ms-excel"
193
+ | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
194
+
195
+ /**
196
+ * @beta
197
+ * Reference to an asset with metadata.
198
+ */
199
+ export declare type UrlExpanderAssetRef = {
200
+ type: "asset";
201
+ id: string;
202
+ name: string;
203
+ iconUrl?: string;
204
+ description?: string;
205
+ };
206
+
207
+ /**
208
+ * @beta
209
+ * Intent interface for URL expansion and content retrieval operations.
210
+ */
211
+ export declare type UrlExpanderIntent = {
212
+ expandUrl(request: ExpandUrlRequest): Promise<ExpandUrlResponse>;
213
+ getContent(request: GetContentRequest): Promise<GetContentResponse>;
214
+ };
215
+
216
+ /**
217
+ * @beta
218
+ * Video asset result structure.
219
+ */
220
+ export declare type VideoAsset = BaseAsset & {
221
+ type: "video";
222
+ thumbnailImageUrl: string;
223
+ parentRef?: AssetRef;
224
+ mimeType:
225
+ | "video/avi"
226
+ | "video/x-msvideo"
227
+ | "image/gif"
228
+ | "video/x-m4v"
229
+ | "video/x-matroska"
230
+ | "video/quicktime"
231
+ | "video/mp4"
232
+ | "video/mpeg"
233
+ | "video/webm";
234
+ };
235
+
1
236
  export {};
package/content/beta.d.ts CHANGED
@@ -59,6 +59,10 @@ export declare interface BaseOutputFile {
59
59
  * Your app should download from this URL and upload to your platform.
60
60
  */
61
61
  url: string;
62
+ /**
63
+ * Metadata about the source content used to create this exported file.
64
+ */
65
+ contentMetadata: ContentMetadata;
62
66
  }
63
67
 
64
68
  /**
@@ -92,6 +96,12 @@ export declare interface BasePreview {
92
96
  heightPx: number;
93
97
  }
94
98
 
99
+ /**
100
+ * @beta
101
+ * Metadata about the source content used to create an exported file.
102
+ */
103
+ export declare type ContentMetadata = DesignContentMetadata;
104
+
95
105
  /**
96
106
  * @beta
97
107
  * Main interface for implementing the ContentPublisher intent.
@@ -264,12 +274,132 @@ export declare type ContentPublisherIntent = {
264
274
  ) => Promise<PublishContentResponse>;
265
275
  };
266
276
 
277
+ /**
278
+ * @beta
279
+ * Metadata specific to design content.
280
+ */
281
+ export declare interface DesignContentMetadata {
282
+ type: "design";
283
+ /**
284
+ * A signed JWT token containing the design id
285
+ */
286
+ designToken: string;
287
+ /**
288
+ * The pages that make up the exported metadata
289
+ */
290
+ pages: OutputPageMetadata[];
291
+ }
292
+
267
293
  /**
268
294
  * @beta
269
295
  * A function that can be called to dispose of a callback.
270
296
  */
271
297
  export declare type Disposer = () => void;
272
298
 
299
+ /**
300
+ * @beta
301
+ * Exported PDF file ready for publishing.
302
+ *
303
+ * Contains the final PDF document that should be uploaded to your platform.
304
+ * The document format is `pdf_standard` and the file is ready to use.
305
+ */
306
+ export declare type DocumentOutputFile = BaseOutputFile;
307
+
308
+ /**
309
+ * @beta
310
+ * Document preview in various states.
311
+ *
312
+ * Documents transition through states: `"loading"` → `"thumbnail"`.
313
+ * Start with a lightweight thumbnail of the first page for quick preview rendering.
314
+ */
315
+ export declare type DocumentPreview =
316
+ | DocumentPreviewLoading
317
+ | DocumentPreviewThumbnail
318
+ | DocumentPreviewError;
319
+
320
+ /**
321
+ * @beta
322
+ * Document preview that failed to generate.
323
+ *
324
+ * Display an error state to the user.
325
+ */
326
+ export declare interface DocumentPreviewError extends BasePreview {
327
+ kind: "document";
328
+ status: "error";
329
+ /**
330
+ * The error message to display to the user.
331
+ */
332
+ message: string;
333
+ }
334
+
335
+ /**
336
+ * @beta
337
+ * Document preview that is currently being generated.
338
+ *
339
+ * Display a loading state until the preview transitions to `"thumbnail"` or `"error"`.
340
+ */
341
+ export declare interface DocumentPreviewLoading extends BasePreview {
342
+ kind: "document";
343
+ status: "loading";
344
+ }
345
+
346
+ /**
347
+ * @beta
348
+ * Document preview with first page thumbnail available.
349
+ *
350
+ * This is the initial state for document previews. Show the thumbnail image
351
+ * of the first page along with the page count to give users a preview of
352
+ * the document before publishing.
353
+ */
354
+ export declare interface DocumentPreviewThumbnail extends BasePreview {
355
+ kind: "document";
356
+ status: "thumbnail";
357
+ /**
358
+ * Format of the thumbnail image.
359
+ */
360
+ thumbnailFormat: "png" | "jpg";
361
+ /**
362
+ * URL to the first page thumbnail.
363
+ *
364
+ * Display this lightweight image to preview the document content.
365
+ */
366
+ thumbnailUrl: string;
367
+ }
368
+
369
+ /**
370
+ * @beta
371
+ * Document file requirements for a media slot.
372
+ *
373
+ * Note: Document output types use image previews (PNG thumbnails) in the preview UI.
374
+ * The actual document file is only generated for the final output in OutputMedia.
375
+ *
376
+ * @example Document requirements
377
+ * ```ts
378
+ * const documentReq: DocumentRequirement = {
379
+ * format: 'pdf_standard',
380
+ * size: 'a4',
381
+ * maxFileSizeMb: 50
382
+ * };
383
+ * ```
384
+ */
385
+ export declare interface DocumentRequirement extends BaseFileRequirement {
386
+ /**
387
+ * Supported document export format.
388
+ * Currently supports PDF standard format.
389
+ */
390
+ format: "pdf_standard";
391
+ /**
392
+ * The document size of the export file.
393
+ */
394
+ size: DocumentSize;
395
+ }
396
+
397
+ /**
398
+ * @beta
399
+ * Document size for document exports.
400
+ */
401
+ export declare type DocumentSize = "a4" | "a3" | "letter" | "legal";
402
+
273
403
  /**
274
404
  * @beta
275
405
  * Exact value range constraint.
@@ -345,9 +475,14 @@ export declare interface ImagePreviewError extends BasePreview {
345
475
  kind: "image";
346
476
  status: "error";
347
477
  /**
478
+ * @deprecated Use `message` instead.
348
479
  * Optional, user-facing error message to display in the preview UI.
349
480
  */
350
481
  userFacingErrorMessage?: string;
482
+ /**
483
+ * The error message to display to the user.
484
+ */
485
+ message: string;
351
486
  }
352
487
 
353
488
  /**
@@ -477,10 +612,12 @@ export declare type MediaSlot = {
477
612
  * must satisfy the corresponding requirement for its media type
478
613
  * - To restrict the slot to a single media type, provide only that requirement
479
614
  * - `fileCount` applies across all files accepted by the slot regardless of media type
615
+ * - Document output types will show image previews (PNG thumbnail) in preview UI
480
616
  */
481
617
  accepts: {
482
618
  image?: ImageRequirement;
483
619
  video?: VideoRequirement;
620
+ document?: DocumentRequirement;
484
621
  };
485
622
  };
486
623
 
@@ -514,7 +651,10 @@ export declare type MinValueRange = {
514
651
  * @beta
515
652
  * Exported file ready for publishing.
516
653
  */
517
- export declare type OutputFile = ImageOutputFile | VideoOutputFile;
654
+ export declare type OutputFile =
655
+ | ImageOutputFile
656
+ | VideoOutputFile
657
+ | DocumentOutputFile;
518
658
 
519
659
  /**
520
660
  * @beta
@@ -537,6 +677,21 @@ export declare type OutputMedia = {
537
677
  files: OutputFile[];
538
678
  };
539
679
 
680
+ /**
681
+ * @beta
682
+ * Metadata about a specific page in the exported content.
683
+ */
684
+ export declare type OutputPageMetadata = {
685
+ /**
686
+ * The unique identifier for the page.
687
+ */
688
+ pageId: string | undefined;
689
+ /**
690
+ * The position of the page within the design, starting from 1 for the first page.
691
+ */
692
+ pageNumber: number;
693
+ };
694
+
540
695
  /**
541
696
  * @beta
542
697
  * Configuration for an output type.
@@ -650,13 +805,13 @@ export declare const prepareContentPublisher: (
650
805
  *
651
806
  * Check the `kind` and `status` properties to determine the type and state.
652
807
  */
653
- export declare type Preview = ImagePreview | VideoPreview;
808
+ export declare type Preview = ImagePreview | VideoPreview | DocumentPreview;
654
809
 
655
810
  /**
656
811
  * @beta
657
812
  * Type of preview media.
658
813
  */
659
- export declare type PreviewKind = "image" | "video";
814
+ export declare type PreviewKind = "image" | "video" | "document";
660
815
 
661
816
  /**
662
817
  * @beta
@@ -796,7 +951,7 @@ export declare type PublishContentResponse =
796
951
  * @beta
797
952
  * Supported file formats for publishing.
798
953
  */
799
- export declare type PublishFileFormat = "png" | "jpg" | "mp4";
954
+ export declare type PublishFileFormat = "png" | "jpg" | "mp4" | "pdf_standard";
800
955
 
801
956
  /**
802
957
  * @beta
@@ -1098,9 +1253,14 @@ export declare interface VideoPreviewError extends BasePreview {
1098
1253
  kind: "video";
1099
1254
  status: "error";
1100
1255
  /**
1256
+ * @deprecated Use `message` instead.
1101
1257
  * Optional, user-facing error message to display in the preview UI.
1102
1258
  */
1103
1259
  userFacingErrorMessage?: string;
1260
+ /**
1261
+ * The error message to display to the user.
1262
+ */
1263
+ message: string;
1104
1264
  }
1105
1265
 
1106
1266
  /**
@@ -1112,6 +1272,10 @@ export declare interface VideoPreviewError extends BasePreview {
1112
1272
  export declare interface VideoPreviewLoading extends BasePreview {
1113
1273
  kind: "video";
1114
1274
  status: "loading";
1275
+ /**
1276
+ * Video duration in milliseconds.
1277
+ */
1278
+ durationMs?: number;
1115
1279
  }
1116
1280
 
1117
1281
  /**
@@ -2,3 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
+ Object.defineProperty(exports, "prepareUrlExpander", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return prepareUrlExpander;
9
+ }
10
+ });
11
+ const _version = require("../version");
12
+ const { canva_sdk } = window;
13
+ const prepareUrlExpander = canva_sdk.intents.v1.asset.prepareUrlExpander;
14
+ window.__canva__?.sdkRegistration?.registerPackageVersion('intents/asset', _version.LATEST_VERSION, 'beta');
@@ -8,6 +8,7 @@ Object.defineProperty(exports, "prepareContentPublisher", {
8
8
  return prepareContentPublisher;
9
9
  }
10
10
  });
11
+ const _version = require("../version");
11
12
  const { canva_sdk } = window;
12
13
  const prepareContentPublisher = canva_sdk.intents.v1.content.prepareContentPublisher;
13
- window.__canva__?.sdkRegistration?.registerPackageVersion('intents/content', '2.0.1', 'beta');
14
+ window.__canva__?.sdkRegistration?.registerPackageVersion('intents/content', _version.LATEST_VERSION, 'beta');
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
+ const _version = require("../version");
5
6
  _export_star(require("./public"), exports);
6
7
  function _export_star(from, to) {
7
8
  Object.keys(from).forEach(function(k) {
@@ -16,4 +17,4 @@ function _export_star(from, to) {
16
17
  });
17
18
  return from;
18
19
  }
19
- window.__canva__?.sdkRegistration?.registerPackageVersion('intents/data', '2.0.1', 'beta');
20
+ window.__canva__?.sdkRegistration?.registerPackageVersion('intents/data', _version.LATEST_VERSION, 'beta');
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
+ const _version = require("../version");
5
6
  _export_star(require("./public"), exports);
6
7
  function _export_star(from, to) {
7
8
  Object.keys(from).forEach(function(k) {
@@ -16,4 +17,4 @@ function _export_star(from, to) {
16
17
  });
17
18
  return from;
18
19
  }
19
- window.__canva__?.sdkRegistration?.registerPackageVersion('intents/data', '2.0.0', 'ga');
20
+ window.__canva__?.sdkRegistration?.registerPackageVersion('intents/data', _version.LATEST_VERSION, 'ga');
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
+ const _version = require("../version");
5
6
  _export_star(require("./public"), exports);
6
7
  function _export_star(from, to) {
7
8
  Object.keys(from).forEach(function(k) {
@@ -16,4 +17,4 @@ function _export_star(from, to) {
16
17
  });
17
18
  return from;
18
19
  }
19
- window.__canva__?.sdkRegistration?.registerPackageVersion('intents/design', '2.0.1', 'beta');
20
+ window.__canva__?.sdkRegistration?.registerPackageVersion('intents/design', _version.LATEST_VERSION, 'beta');
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
+ const _version = require("../version");
5
6
  _export_star(require("./public"), exports);
6
7
  function _export_star(from, to) {
7
8
  Object.keys(from).forEach(function(k) {
@@ -16,4 +17,4 @@ function _export_star(from, to) {
16
17
  });
17
18
  return from;
18
19
  }
19
- window.__canva__?.sdkRegistration?.registerPackageVersion('intents/design', '2.0.0', 'ga');
20
+ window.__canva__?.sdkRegistration?.registerPackageVersion('intents/design', _version.LATEST_VERSION, 'ga');
@@ -8,4 +8,4 @@ Object.defineProperty(exports, "LATEST_VERSION", {
8
8
  return LATEST_VERSION;
9
9
  }
10
10
  });
11
- const LATEST_VERSION = '2.0.0';
11
+ const LATEST_VERSION = '2.0.2';
@@ -1 +1,4 @@
1
- export { };
1
+ import { LATEST_VERSION } from '../version';
2
+ const { canva_sdk } = window;
3
+ export const prepareUrlExpander = canva_sdk.intents.v1.asset.prepareUrlExpander;
4
+ window.__canva__?.sdkRegistration?.registerPackageVersion('intents/asset', LATEST_VERSION, 'beta');
@@ -1,3 +1,4 @@
1
+ import { LATEST_VERSION } from '../version';
1
2
  const { canva_sdk } = window;
2
3
  export const prepareContentPublisher = canva_sdk.intents.v1.content.prepareContentPublisher;
3
- window.__canva__?.sdkRegistration?.registerPackageVersion('intents/content', '2.0.1', 'beta');
4
+ window.__canva__?.sdkRegistration?.registerPackageVersion('intents/content', LATEST_VERSION, 'beta');
@@ -1,2 +1,3 @@
1
+ import { LATEST_VERSION } from '../version';
1
2
  export * from './public';
2
- window.__canva__?.sdkRegistration?.registerPackageVersion('intents/data', '2.0.1', 'beta');
3
+ window.__canva__?.sdkRegistration?.registerPackageVersion('intents/data', LATEST_VERSION, 'beta');
@@ -1,2 +1,3 @@
1
+ import { LATEST_VERSION } from '../version';
1
2
  export * from './public';
2
- window.__canva__?.sdkRegistration?.registerPackageVersion('intents/data', '2.0.0', 'ga');
3
+ window.__canva__?.sdkRegistration?.registerPackageVersion('intents/data', LATEST_VERSION, 'ga');
@@ -1,2 +1,3 @@
1
+ import { LATEST_VERSION } from '../version';
1
2
  export * from './public';
2
- window.__canva__?.sdkRegistration?.registerPackageVersion('intents/design', '2.0.1', 'beta');
3
+ window.__canva__?.sdkRegistration?.registerPackageVersion('intents/design', LATEST_VERSION, 'beta');
@@ -1,2 +1,3 @@
1
+ import { LATEST_VERSION } from '../version';
1
2
  export * from './public';
2
- window.__canva__?.sdkRegistration?.registerPackageVersion('intents/design', '2.0.0', 'ga');
3
+ window.__canva__?.sdkRegistration?.registerPackageVersion('intents/design', LATEST_VERSION, 'ga');
@@ -1 +1 @@
1
- export const LATEST_VERSION = '2.0.0';
1
+ export const LATEST_VERSION = '2.0.2';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canva/intents",
3
- "version": "2.0.1-beta.1",
3
+ "version": "2.0.2-beta.3",
4
4
  "description": "The Canva Apps SDK Intents library",
5
5
  "author": "Canva Pty Ltd.",
6
6
  "license": "SEE LICENSE IN LICENSE.md FILE",
@@ -42,4 +42,4 @@
42
42
  }
43
43
  },
44
44
  "typings": "./beta.d.ts"
45
- }
45
+ }