@canva/intents 2.2.1-beta.1 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -18
- package/asset/index.d.ts +1 -1
- package/content/index.d.ts +1618 -1
- package/data/index.d.ts +1229 -1
- package/design/index.d.ts +41 -1
- package/index.d.ts +2994 -1
- package/lib/cjs/sdk/intents/asset/index.js +1 -15
- package/lib/cjs/sdk/intents/fake/{create_beta.js → create.js} +6 -9
- package/lib/cjs/sdk/intents/index.js +4 -2
- package/lib/cjs/sdk/intents/test/index.js +14 -13
- package/lib/cjs/sdk/intents/version.js +1 -1
- package/lib/esm/sdk/intents/asset/index.js +1 -1
- package/lib/esm/sdk/intents/fake/{create_beta.js → create.js} +4 -7
- package/lib/esm/sdk/intents/index.js +3 -1
- package/lib/esm/sdk/intents/test/index.js +9 -1
- package/lib/esm/sdk/intents/version.js +1 -1
- package/package.json +23 -23
- package/test/index.d.ts +11 -1
- package/asset/beta.d.ts +0 -190
- package/beta.d.ts +0 -2963
- package/content/beta.d.ts +0 -1567
- package/data/beta.d.ts +0 -1229
- package/design/beta.d.ts +0 -41
- package/lib/cjs/sdk/intents/asset/beta.js +0 -13
- package/lib/cjs/sdk/intents/beta.js +0 -20
- package/lib/cjs/sdk/intents/content/beta.js +0 -27
- package/lib/cjs/sdk/intents/data/beta.js +0 -20
- package/lib/cjs/sdk/intents/design/beta.js +0 -20
- package/lib/cjs/sdk/intents/test/beta.js +0 -19
- package/lib/esm/sdk/intents/asset/beta.js +0 -3
- package/lib/esm/sdk/intents/beta.js +0 -3
- package/lib/esm/sdk/intents/content/beta.js +0 -4
- package/lib/esm/sdk/intents/data/beta.js +0 -3
- package/lib/esm/sdk/intents/design/beta.js +0 -3
- package/lib/esm/sdk/intents/test/beta.js +0 -9
- package/test/beta.d.ts +0 -11
|
@@ -1,18 +1,4 @@
|
|
|
1
|
-
"use strict"
|
|
1
|
+
"use strict"
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
_export_star(require("./beta"), exports);
|
|
6
|
-
function _export_star(from, to) {
|
|
7
|
-
Object.keys(from).forEach(function(k) {
|
|
8
|
-
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
9
|
-
Object.defineProperty(to, k, {
|
|
10
|
-
enumerable: true,
|
|
11
|
-
get: function() {
|
|
12
|
-
return from[k];
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
return from;
|
|
18
|
-
}
|
|
@@ -2,27 +2,24 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
Object.defineProperty(exports, "
|
|
5
|
+
Object.defineProperty(exports, "createFakeIntentsClients", {
|
|
6
6
|
enumerable: true,
|
|
7
7
|
get: function() {
|
|
8
|
-
return
|
|
8
|
+
return createFakeIntentsClients;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
-
function
|
|
11
|
+
function createFakeIntentsClients() {
|
|
12
12
|
return {
|
|
13
13
|
intents: {
|
|
14
14
|
v1: {
|
|
15
|
-
asset: {
|
|
16
|
-
prepareUrlExpander: ()=>{}
|
|
17
|
-
},
|
|
18
|
-
content: {
|
|
19
|
-
prepareContentPublisher: ()=>{}
|
|
20
|
-
},
|
|
21
15
|
design: {
|
|
22
16
|
prepareDesignEditor: ()=>{}
|
|
23
17
|
},
|
|
24
18
|
data: {
|
|
25
19
|
prepareDataConnector: ()=>{}
|
|
20
|
+
},
|
|
21
|
+
content: {
|
|
22
|
+
prepareContentPublisher: ()=>{}
|
|
26
23
|
}
|
|
27
24
|
}
|
|
28
25
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
"use strict"
|
|
1
|
+
"use strict"
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
|
|
5
|
+
const _version = require("./version");
|
|
6
|
+
_export_star(require("./public"), exports);
|
|
6
7
|
function _export_star(from, to) {
|
|
7
8
|
Object.keys(from).forEach(function(k) {
|
|
8
9
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
@@ -16,3 +17,4 @@ function _export_star(from, to) {
|
|
|
16
17
|
});
|
|
17
18
|
return from;
|
|
18
19
|
}
|
|
20
|
+
window.__canva__?.sdkRegistration?.registerPackageVersion('intents', _version.LATEST_VERSION, 'ga');
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
"use strict"
|
|
1
|
+
"use strict"
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
5
|
+
Object.defineProperty(exports, "initTestEnvironment", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return initTestEnvironment;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _create = require('../fake/create');
|
|
12
|
+
const _canva_sdk = require('../../utils/canva_sdk');
|
|
13
|
+
function initTestEnvironment() {
|
|
14
|
+
(0, _canva_sdk.assertIsTestCanvaSdk)();
|
|
15
|
+
const fakeClients = (0, _create.createFakeIntentsClients)();
|
|
16
|
+
(0, _canva_sdk.injectFakeAPIClients)({
|
|
17
|
+
intents: fakeClients.intents
|
|
16
18
|
});
|
|
17
|
-
return from;
|
|
18
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export {};
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
export function
|
|
1
|
+
export function createFakeIntentsClients() {
|
|
2
2
|
return {
|
|
3
3
|
intents: {
|
|
4
4
|
v1: {
|
|
5
|
-
asset: {
|
|
6
|
-
prepareUrlExpander: ()=>{}
|
|
7
|
-
},
|
|
8
|
-
content: {
|
|
9
|
-
prepareContentPublisher: ()=>{}
|
|
10
|
-
},
|
|
11
5
|
design: {
|
|
12
6
|
prepareDesignEditor: ()=>{}
|
|
13
7
|
},
|
|
14
8
|
data: {
|
|
15
9
|
prepareDataConnector: ()=>{}
|
|
10
|
+
},
|
|
11
|
+
content: {
|
|
12
|
+
prepareContentPublisher: ()=>{}
|
|
16
13
|
}
|
|
17
14
|
}
|
|
18
15
|
}
|
|
@@ -1 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import { createFakeIntentsClients } from '../fake/create';
|
|
2
|
+
import { assertIsTestCanvaSdk, injectFakeAPIClients } from '../../utils/canva_sdk';
|
|
3
|
+
export function initTestEnvironment() {
|
|
4
|
+
assertIsTestCanvaSdk();
|
|
5
|
+
const fakeClients = createFakeIntentsClients();
|
|
6
|
+
injectFakeAPIClients({
|
|
7
|
+
intents: fakeClients.intents
|
|
8
|
+
});
|
|
9
|
+
}
|
package/package.json
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canva/intents",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "The Canva Apps SDK Intents library",
|
|
5
5
|
"author": "Canva Pty Ltd.",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md FILE",
|
|
7
7
|
"peerDependencies": {
|
|
8
8
|
"@canva/error": "^2.0.0"
|
|
9
9
|
},
|
|
10
|
-
"main": "./lib/cjs/sdk/intents/
|
|
11
|
-
"module": "./lib/esm/sdk/intents/
|
|
10
|
+
"main": "./lib/cjs/sdk/intents/index.js",
|
|
11
|
+
"module": "./lib/esm/sdk/intents/index.js",
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|
|
14
|
-
"types": "./
|
|
15
|
-
"require": "./lib/cjs/sdk/intents/
|
|
16
|
-
"import": "./lib/esm/sdk/intents/
|
|
14
|
+
"types": "./index.d.ts",
|
|
15
|
+
"require": "./lib/cjs/sdk/intents/index.js",
|
|
16
|
+
"import": "./lib/esm/sdk/intents/index.js"
|
|
17
17
|
},
|
|
18
18
|
"./test": {
|
|
19
|
-
"types": "./test/
|
|
20
|
-
"require": "./lib/cjs/sdk/intents/test/
|
|
21
|
-
"import": "./lib/esm/sdk/intents/test/
|
|
19
|
+
"types": "./test/index.d.ts",
|
|
20
|
+
"require": "./lib/cjs/sdk/intents/test/index.js",
|
|
21
|
+
"import": "./lib/esm/sdk/intents/test/index.js"
|
|
22
22
|
},
|
|
23
23
|
"./data": {
|
|
24
|
-
"types": "./data/
|
|
25
|
-
"require": "./lib/cjs/sdk/intents/data/
|
|
26
|
-
"import": "./lib/esm/sdk/intents/data/
|
|
24
|
+
"types": "./data/index.d.ts",
|
|
25
|
+
"require": "./lib/cjs/sdk/intents/data/index.js",
|
|
26
|
+
"import": "./lib/esm/sdk/intents/data/index.js"
|
|
27
27
|
},
|
|
28
28
|
"./design": {
|
|
29
|
-
"types": "./design/
|
|
30
|
-
"require": "./lib/cjs/sdk/intents/design/
|
|
31
|
-
"import": "./lib/esm/sdk/intents/design/
|
|
29
|
+
"types": "./design/index.d.ts",
|
|
30
|
+
"require": "./lib/cjs/sdk/intents/design/index.js",
|
|
31
|
+
"import": "./lib/esm/sdk/intents/design/index.js"
|
|
32
32
|
},
|
|
33
33
|
"./asset": {
|
|
34
|
-
"types": "./asset/
|
|
35
|
-
"require": "./lib/cjs/sdk/intents/asset/
|
|
36
|
-
"import": "./lib/esm/sdk/intents/asset/
|
|
34
|
+
"types": "./asset/index.d.ts",
|
|
35
|
+
"require": "./lib/cjs/sdk/intents/asset/index.js",
|
|
36
|
+
"import": "./lib/esm/sdk/intents/asset/index.js"
|
|
37
37
|
},
|
|
38
38
|
"./content": {
|
|
39
|
-
"types": "./content/
|
|
40
|
-
"require": "./lib/cjs/sdk/intents/content/
|
|
41
|
-
"import": "./lib/esm/sdk/intents/content/
|
|
39
|
+
"types": "./content/index.d.ts",
|
|
40
|
+
"require": "./lib/cjs/sdk/intents/content/index.js",
|
|
41
|
+
"import": "./lib/esm/sdk/intents/content/index.js"
|
|
42
42
|
}
|
|
43
43
|
},
|
|
44
|
-
"typings": "./
|
|
45
|
-
}
|
|
44
|
+
"typings": "./index.d.ts"
|
|
45
|
+
}
|
package/test/index.d.ts
CHANGED
|
@@ -1 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @public
|
|
3
|
+
* Initializes a test environment for the `@canva/intents` package, enabling unit tests to mock Canva's APIs.
|
|
4
|
+
* @remarks
|
|
5
|
+
* This method should only be called once in a test environment, such as in a Jest setup file.
|
|
6
|
+
* @see
|
|
7
|
+
* https://www.canva.dev/docs/apps/testing/
|
|
8
|
+
*/
|
|
9
|
+
export declare function initTestEnvironment(): void;
|
|
10
|
+
|
|
11
|
+
export { }
|
package/asset/beta.d.ts
DELETED
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @beta
|
|
3
|
-
* Union of all supported asset types.
|
|
4
|
-
*/
|
|
5
|
-
export declare type Asset = ImageAsset | VideoAsset | AudioAsset | DocumentAsset | SheetAsset | GenericAsset;
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @beta
|
|
9
|
-
* Reference to an asset. Used as a unique identifier.
|
|
10
|
-
*/
|
|
11
|
-
export declare type AssetRef = string & {
|
|
12
|
-
__assetRef: never;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @beta
|
|
17
|
-
* Audio asset result structure.
|
|
18
|
-
*/
|
|
19
|
-
export declare type AudioAsset = BaseAsset & {
|
|
20
|
-
type: 'audio';
|
|
21
|
-
mimeType: 'audio/mpeg' | 'audio/mp4' | 'audio/x-m4a' | 'audio/mp3' | 'audio/ogg' | 'audio/wav' | 'audio/x-wav' | 'audio/x-pn-wav' | 'audio/wave' | 'audio/vnd.wave' | 'audio/webm';
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* @beta
|
|
26
|
-
* Base structure for an asset result.
|
|
27
|
-
*/
|
|
28
|
-
export declare type BaseAsset = {
|
|
29
|
-
name: string;
|
|
30
|
-
url: string;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* @beta
|
|
35
|
-
* Document asset result structure.
|
|
36
|
-
*/
|
|
37
|
-
export declare type DocumentAsset = BaseAsset & {
|
|
38
|
-
type: 'document';
|
|
39
|
-
parentRef?: AssetRef;
|
|
40
|
-
mimeType: DocumentMimeType;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* @beta
|
|
45
|
-
* Supported mimetype for document assets.
|
|
46
|
-
*/
|
|
47
|
-
export declare type DocumentMimeType = 'application/pdf' | 'application/msword' | 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' | 'text/plain' | 'text/markdown';
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* @beta
|
|
51
|
-
* Request parameters for URL expansion.
|
|
52
|
-
*/
|
|
53
|
-
export declare type ExpandUrlRequest = {
|
|
54
|
-
url: string;
|
|
55
|
-
requestConnection: () => Promise<void>;
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* @beta
|
|
60
|
-
* Response from URL expansion operation.
|
|
61
|
-
*/
|
|
62
|
-
export declare type ExpandUrlResponse = {
|
|
63
|
-
status: 'completed';
|
|
64
|
-
result: ExpandUrlResult;
|
|
65
|
-
} | {
|
|
66
|
-
status: 'not_found';
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* @beta
|
|
71
|
-
* Result of completed URL expansion.
|
|
72
|
-
*/
|
|
73
|
-
export declare type ExpandUrlResult = {
|
|
74
|
-
ref: UrlExpanderAssetRef;
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* @beta
|
|
79
|
-
* Generic asset result structure.
|
|
80
|
-
* A generic asset is any file that is not already covered by other asset types such as ImageAsset etc.
|
|
81
|
-
* It is an error to pass a mime type that is covered by another asset type.
|
|
82
|
-
*/
|
|
83
|
-
export declare type GenericAsset = BaseAsset & {
|
|
84
|
-
type: 'generic';
|
|
85
|
-
mimeType: string;
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* @beta
|
|
90
|
-
* Completed response from content retrieval operation.
|
|
91
|
-
*/
|
|
92
|
-
export declare type GetContentCompletedResponse = {
|
|
93
|
-
status: 'completed';
|
|
94
|
-
result: {
|
|
95
|
-
type: 'asset';
|
|
96
|
-
asset: Asset;
|
|
97
|
-
};
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* @beta
|
|
102
|
-
* Error response from content retrieval operation.
|
|
103
|
-
*/
|
|
104
|
-
export declare type GetContentErrorResponse = {
|
|
105
|
-
status: 'app_error';
|
|
106
|
-
message: string;
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* @beta
|
|
111
|
-
* Request parameters for content retrieval.
|
|
112
|
-
*/
|
|
113
|
-
export declare type GetContentRequest = {
|
|
114
|
-
ref: UrlExpanderAssetRef;
|
|
115
|
-
requestConnection: () => Promise<void>;
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* @beta
|
|
120
|
-
* Response from content retrieval operation.
|
|
121
|
-
*/
|
|
122
|
-
export declare type GetContentResponse = GetContentCompletedResponse | GetContentErrorResponse;
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* @beta
|
|
126
|
-
* Image asset result structure.
|
|
127
|
-
*/
|
|
128
|
-
export declare type ImageAsset = BaseAsset & {
|
|
129
|
-
type: 'image';
|
|
130
|
-
thumbnailUrl: string;
|
|
131
|
-
parentRef?: AssetRef;
|
|
132
|
-
mimeType: 'image/heic' | 'image/jpeg' | 'image/png' | 'image/svg+xml' | 'image/tiff' | 'image/webp';
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* @beta
|
|
137
|
-
*
|
|
138
|
-
* Prepares the `UrlExpanderIntent`.
|
|
139
|
-
*/
|
|
140
|
-
export declare const prepareUrlExpander: (implementation: UrlExpanderIntent) => void;
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* @beta
|
|
144
|
-
* Sheet asset result structure.
|
|
145
|
-
*/
|
|
146
|
-
export declare type SheetAsset = BaseAsset & {
|
|
147
|
-
type: 'sheet';
|
|
148
|
-
parentRef?: AssetRef;
|
|
149
|
-
mimeType: SheetMimeType;
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* @beta
|
|
154
|
-
* Supported mimetype for sheet assets.
|
|
155
|
-
*/
|
|
156
|
-
export declare type SheetMimeType = 'text/csv' | 'application/vnd.ms-excel' | 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* @beta
|
|
160
|
-
* Reference to an asset with metadata.
|
|
161
|
-
*/
|
|
162
|
-
export declare type UrlExpanderAssetRef = {
|
|
163
|
-
type: 'asset';
|
|
164
|
-
id: string;
|
|
165
|
-
name: string;
|
|
166
|
-
iconUrl?: string;
|
|
167
|
-
description?: string;
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* @beta
|
|
172
|
-
* Intent interface for URL expansion and content retrieval operations.
|
|
173
|
-
*/
|
|
174
|
-
export declare type UrlExpanderIntent = {
|
|
175
|
-
expandUrl(request: ExpandUrlRequest): Promise<ExpandUrlResponse>;
|
|
176
|
-
getContent(request: GetContentRequest): Promise<GetContentResponse>;
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* @beta
|
|
181
|
-
* Video asset result structure.
|
|
182
|
-
*/
|
|
183
|
-
export declare type VideoAsset = BaseAsset & {
|
|
184
|
-
type: 'video';
|
|
185
|
-
thumbnailImageUrl: string;
|
|
186
|
-
parentRef?: AssetRef;
|
|
187
|
-
mimeType: 'video/avi' | 'video/x-msvideo' | 'image/gif' | 'video/x-m4v' | 'video/x-matroska' | 'video/quicktime' | 'video/mp4' | 'video/mpeg' | 'video/webm';
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
export { }
|