@canva/cli 0.0.1-beta.12 → 0.0.1-beta.14

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canva/cli",
3
- "version": "0.0.1-beta.12",
3
+ "version": "0.0.1-beta.14",
4
4
  "description": "The official Canva CLI.",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "author": "Canva Pty Ltd.",
@@ -6,7 +6,7 @@
6
6
  "license": "SEE LICENSE IN LICENSE.md",
7
7
  "author": "Canva Pty Ltd.",
8
8
  "dependencies": {
9
- "@canva/app-ui-kit": "^4.4.0",
9
+ "@canva/app-ui-kit": "^4.5.0",
10
10
  "@canva/asset": "^2.1.0",
11
11
  "@canva/design": "^2.3.0",
12
12
  "@canva/error": "^2.1.0",
@@ -17,7 +17,7 @@
17
17
  "react-dom": "18.3.1"
18
18
  },
19
19
  "devDependencies": {
20
- "@canva/cli": "^0.0.1-beta.11",
20
+ "@canva/cli": ">= 0.0.1-beta.13 < 0.0.2",
21
21
  "@ngrok/ngrok": "1.4.1",
22
22
  "@svgr/webpack": "8.1.0",
23
23
  "@types/debug": "4.1.12",
@@ -17,3 +17,4 @@ jest.mock("@canva/asset");
17
17
  jest.mock("@canva/design");
18
18
  jest.mock("@canva/platform");
19
19
  jest.mock("@canva/user");
20
+ // n.b. @canva/error should not be mocked - use it to simulate API error responses from other mocks by throwing CanvaError
@@ -1,10 +1,6 @@
1
1
  import * as express from "express";
2
2
  import * as crypto from "crypto";
3
- import type {
4
- Container,
5
- FindResourcesRequest,
6
- Resource,
7
- } from "@canva/app-components";
3
+ import type { Container, Resource } from "@canva/app-components";
8
4
 
9
5
  /**
10
6
  * Generates a unique hash for a url.
@@ -33,15 +29,24 @@ export const createDamRouter = () => {
33
29
 
34
30
  /**
35
31
  * This endpoint returns the data for your app.
36
- *
37
- * TODO: you must change this path to `/api/resources/find` before
38
- * submitting to ensure a user is authenticated
39
32
  */
40
33
  router.post("/resources/find", async (req, res) => {
41
34
  // You should modify these lines to return data from your
42
35
  // digital asset manager (DAM) based on the findResourcesRequest
43
- const findResourcesRequest: FindResourcesRequest = req.body;
44
- const { types } = findResourcesRequest;
36
+ const {
37
+ types,
38
+ continuation,
39
+ locale,
40
+ // other available fields from the `FindResourcesRequest`
41
+ // containerTypes,
42
+ // limit,
43
+ // filters,
44
+ // query,
45
+ // sort,
46
+ // tab,
47
+ // containerId,
48
+ // parentContainerType,
49
+ } = req.body;
45
50
 
46
51
  let resources: Resource[] = [];
47
52
  if (types.includes("IMAGE")) {
@@ -49,7 +54,7 @@ export const createDamRouter = () => {
49
54
  Array.from({ length: 40 }, async (_, i) => ({
50
55
  id: await generateHash(imageUrls[i % imageUrls.length]),
51
56
  mimeType: "image/jpeg",
52
- name: "My new thing",
57
+ name: `My new thing in ${locale}`, // Use the `locale` value from the request if your backend supports i18n
53
58
  type: "IMAGE",
54
59
  thumbnail: {
55
60
  url: imageUrls[i % imageUrls.length],
@@ -78,7 +83,7 @@ export const createDamRouter = () => {
78
83
 
79
84
  res.send({
80
85
  resources,
81
- continuation: +(findResourcesRequest.continuation || 0) + 1,
86
+ continuation: +(continuation || 0) + 1,
82
87
  });
83
88
  });
84
89
 
@@ -17,9 +17,9 @@
17
17
  "postinstall": "ts-node ./scripts/copy-env.ts"
18
18
  },
19
19
  "dependencies": {
20
- "@canva/app-components": "^1.0.0-beta.29",
20
+ "@canva/app-components": "^1.1.0",
21
21
  "@canva/app-i18n-kit": "^1.0.2",
22
- "@canva/app-ui-kit": "^4.4.0",
22
+ "@canva/app-ui-kit": "^4.5.0",
23
23
  "@canva/asset": "^2.1.0",
24
24
  "@canva/design": "^2.3.0",
25
25
  "@canva/error": "^2.1.0",
@@ -32,7 +32,7 @@
32
32
  "react-intl": "6.8.7"
33
33
  },
34
34
  "devDependencies": {
35
- "@canva/cli": "^0.0.1-beta.11",
35
+ "@canva/cli": ">= 0.0.1-beta.13 < 0.0.2",
36
36
  "@eslint/eslintrc": "3.2.0",
37
37
  "@eslint/js": "9.16.0",
38
38
  "@formatjs/cli": "6.3.14",
@@ -1,14 +1,35 @@
1
1
  import { SearchableListView } from "@canva/app-components";
2
2
  import { Box } from "@canva/app-ui-kit";
3
+ import "@canva/app-ui-kit/styles.css";
4
+ import { useConfig } from "./config";
3
5
  import { findResources } from "./adapter";
4
- import { config } from "./config";
5
6
  import * as styles from "./index.css";
6
- import "@canva/app-ui-kit/styles.css";
7
7
 
8
8
  export function App() {
9
+ const config = useConfig();
9
10
  return (
10
11
  <Box className={styles.rootWrapper}>
11
- <SearchableListView config={config} findResources={findResources} />
12
+ <SearchableListView
13
+ config={config}
14
+ findResources={findResources}
15
+ // TODO remove `saveExportedDesign` and `config.export` if your app does not support exporting the Canva design into an external platform
16
+ saveExportedDesign={(
17
+ exportedDesignUrl: string,
18
+ containerId: string | undefined,
19
+ designTitle: string | undefined,
20
+ ) => {
21
+ // TODO update the function to save the design to your platform
22
+ return new Promise((resolve) => {
23
+ setTimeout(() => {
24
+ // eslint-disable-next-line no-console
25
+ console.info(
26
+ `Saving file "${designTitle}" from ${exportedDesignUrl} to ${config.serviceName} container id: ${containerId}`,
27
+ );
28
+ resolve({ success: true });
29
+ }, 1000);
30
+ });
31
+ }}
32
+ />
12
33
  </Box>
13
34
  );
14
35
  }
@@ -1,95 +1,217 @@
1
1
  import type { Config } from "@canva/app-components";
2
+ import { useIntl } from "react-intl";
2
3
 
3
4
  type ContainerTypes = "folder";
4
- export const config: Config<ContainerTypes> = {
5
- serviceName: "Example App",
6
- search: {
7
- enabled: true,
8
- filterFormConfig: {
9
- containerTypes: ["folder"],
10
- filters: [
11
- {
12
- filterType: "CHECKBOX",
13
- label: "File Type",
14
- key: "fileType",
15
- options: [
16
- { value: "mp4", label: "MP4" },
17
- { value: "png", label: "PNG" },
18
- { value: "jpeg", label: "JPEG" },
19
- ],
20
- allowCustomValue: true,
21
- },
22
- {
23
- filterType: "RADIO",
24
- label: "Size",
25
- key: "size",
26
- options: [
27
- {
28
- label: "Large (800+ px)",
29
- value: "large",
30
- },
31
- {
32
- label: "Medium (200-799px)",
33
- value: "medium",
34
- },
35
- ],
36
- allowCustomValue: true,
37
- customValueInputType: "SIZE_RANGE",
38
- },
39
- {
40
- filterType: "RADIO",
41
- label: "Update Date",
42
- key: "updateDate",
43
- options: [
44
- { value: ">now-30m", label: "Last 30 Minutes" },
45
- { value: ">now-7d", label: "Last 7 days" },
46
- ],
47
- allowCustomValue: true,
48
- customValueInputType: "DATE_RANGE",
49
- },
50
- {
51
- filterType: "RADIO",
52
- label: "Design Status",
53
- key: "designStatus",
54
- options: [
55
- { value: "approved", label: "Approved" },
56
- { value: "rejected", label: "Rejected" },
57
- { value: "draft", label: "Draft" },
58
- ],
59
- allowCustomValue: true,
60
- customValueInputType: "PLAIN_TEXT",
61
- },
62
- ],
5
+ export const useConfig = (): Config<ContainerTypes> => {
6
+ const intl = useIntl();
7
+ return {
8
+ serviceName: intl.formatMessage({
9
+ defaultMessage: "Example App",
10
+ description:
11
+ "Name of the service where the app will pull digital assets from",
12
+ }),
13
+ search: {
14
+ enabled: true,
15
+ filterFormConfig: {
16
+ containerTypes: ["folder"],
17
+ filters: [
18
+ {
19
+ filterType: "CHECKBOX",
20
+ label: intl.formatMessage({
21
+ defaultMessage: "File Type",
22
+ description: "Label of filters for file type",
23
+ }),
24
+ key: "fileType",
25
+ options: [
26
+ { value: "mp4", label: "MP4" },
27
+ { value: "png", label: "PNG" },
28
+ { value: "jpeg", label: "JPEG" },
29
+ ],
30
+ allowCustomValue: true,
31
+ },
32
+ {
33
+ filterType: "RADIO",
34
+ label: intl.formatMessage({
35
+ defaultMessage: "Size",
36
+ description: "Label of filters for asset size",
37
+ }),
38
+ key: "size",
39
+ options: [
40
+ {
41
+ label: intl.formatMessage({
42
+ defaultMessage: "Large (800+ px)",
43
+ description: "One of the filter options for asset size",
44
+ }),
45
+ value: "large",
46
+ },
47
+ {
48
+ label: intl.formatMessage({
49
+ defaultMessage: "Medium (200-799px)",
50
+ description: "One of the filter options for asset size",
51
+ }),
52
+ value: "medium",
53
+ },
54
+ ],
55
+ allowCustomValue: true,
56
+ customValueInputType: "SIZE_RANGE",
57
+ },
58
+ {
59
+ filterType: "RADIO",
60
+ label: intl.formatMessage({
61
+ defaultMessage: "Update Date",
62
+ description: "Label of the filters for asset's update date",
63
+ }),
64
+ key: "updateDate",
65
+ options: [
66
+ {
67
+ value: ">now-30m",
68
+ label: intl.formatMessage({
69
+ defaultMessage: "Last 30 Minutes",
70
+ description:
71
+ "One of the filter options for asset update date",
72
+ }),
73
+ },
74
+ {
75
+ value: ">now-7d",
76
+ label: intl.formatMessage({
77
+ defaultMessage: "Last 7 days",
78
+ description:
79
+ "One of the filter options for asset update date",
80
+ }),
81
+ },
82
+ ],
83
+ allowCustomValue: true,
84
+ customValueInputType: "DATE_RANGE",
85
+ },
86
+ {
87
+ filterType: "RADIO",
88
+ label: intl.formatMessage({
89
+ defaultMessage: "Design Status",
90
+ description: "Label of the filters for asset's design status",
91
+ }),
92
+ key: "designStatus",
93
+ options: [
94
+ {
95
+ value: "approved",
96
+ label: intl.formatMessage({
97
+ defaultMessage: "Approved",
98
+ description:
99
+ "One of the filter options for asset design status",
100
+ }),
101
+ },
102
+ {
103
+ value: "rejected",
104
+ label: intl.formatMessage({
105
+ defaultMessage: "Rejected",
106
+ description:
107
+ "One of the filter options for asset design status",
108
+ }),
109
+ },
110
+ {
111
+ value: "draft",
112
+ label: intl.formatMessage({
113
+ defaultMessage: "Draft",
114
+ description:
115
+ "One of the filter options for asset design status",
116
+ }),
117
+ },
118
+ ],
119
+ allowCustomValue: true,
120
+ customValueInputType: "PLAIN_TEXT",
121
+ },
122
+ ],
123
+ },
63
124
  },
64
- },
65
- containerTypes: [
66
- {
67
- value: "folder",
68
- label: "Folders",
69
- listingSurfaces: [
70
- { surface: "HOMEPAGE" },
71
- {
72
- surface: "CONTAINER",
73
- parentContainerTypes: ["folder"],
125
+ containerTypes: [
126
+ {
127
+ value: "folder",
128
+ label: intl.formatMessage({
129
+ defaultMessage: "Folders",
130
+ description: "Name of the asset container type",
131
+ }),
132
+ listingSurfaces: [
133
+ { surface: "HOMEPAGE" },
134
+ {
135
+ surface: "CONTAINER",
136
+ parentContainerTypes: ["folder"],
137
+ },
138
+ { surface: "SEARCH" },
139
+ ],
140
+ searchInsideContainer: {
141
+ enabled: true,
142
+ placeholder: intl.formatMessage({
143
+ defaultMessage: "Search for media inside this folder",
144
+ description: "Placeholder of a search input box",
145
+ }),
74
146
  },
75
- { surface: "SEARCH" },
76
- ],
77
- searchInsideContainer: {
78
- enabled: true,
79
- placeholder: "Search for resources inside this folder",
80
147
  },
148
+ ],
149
+ sortOptions: [
150
+ {
151
+ value: "created_at DESC",
152
+ label: intl.formatMessage({
153
+ defaultMessage: "Creation date (newest)",
154
+ description: "One of the sort options",
155
+ }),
156
+ },
157
+ {
158
+ value: "created_at ASC",
159
+ label: intl.formatMessage({
160
+ defaultMessage: "Creation date (oldest)",
161
+ description: "One of the sort options",
162
+ }),
163
+ },
164
+ {
165
+ value: "updated_at DESC",
166
+ label: intl.formatMessage({
167
+ defaultMessage: "Updated (newest)",
168
+ description: "One of the sort options",
169
+ }),
170
+ },
171
+ {
172
+ value: "updated_at ASC",
173
+ label: intl.formatMessage({
174
+ defaultMessage: "Updated (oldest)",
175
+ description: "One of the sort options",
176
+ }),
177
+ },
178
+ {
179
+ value: "name ASC",
180
+ label: intl.formatMessage({
181
+ defaultMessage: "Name (A-Z)",
182
+ description: "One of the sort options",
183
+ }),
184
+ },
185
+ {
186
+ value: "name DESC",
187
+ label: intl.formatMessage({
188
+ defaultMessage: "Name (Z-A)",
189
+ description: "One of the sort options",
190
+ }),
191
+ },
192
+ ],
193
+ layouts: ["MASONRY", "LIST"],
194
+ resourceTypes: ["IMAGE", "VIDEO", "EMBED"],
195
+ moreInfoMessage: intl.formatMessage({
196
+ defaultMessage:
197
+ "At the moment, we only support images and videos. Corrupted and unsupported files will not appear.",
198
+ description: "Helper text to explain why some assets are not visible",
199
+ }),
200
+ // TODO remove `export` if your app does not support exporting the Canva design into an external platform
201
+ export: {
202
+ enabled: true,
203
+ // TODO provide a container type that user can choose to save into, or remove this field if user doesn't need to choose a container
204
+ containerTypes: ["folder"],
205
+ // TODO remove file types that are not supported by your platform
206
+ acceptedFileTypes: [
207
+ "png",
208
+ "pdf_standard",
209
+ "jpg",
210
+ "gif",
211
+ "svg",
212
+ "video",
213
+ "pptx",
214
+ ],
81
215
  },
82
- ],
83
- sortOptions: [
84
- { value: "created_at DESC", label: "Creation date (newest)" },
85
- { value: "created_at ASC", label: "Creation date (oldest)" },
86
- { value: "updated_at DESC", label: "Updated (newest)" },
87
- { value: "updated_at ASC", label: "Updated (oldest)" },
88
- { value: "name ASC", label: "Name (A-Z)" },
89
- { value: "name DESC", label: "Name (Z-A)" },
90
- ],
91
- layouts: ["MASONRY", "LIST"],
92
- resourceTypes: ["IMAGE", "VIDEO", "EMBED"],
93
- moreInfoMessage:
94
- "At the moment, we only support images and videos. Corrupted and unsupported files will not appear.",
216
+ };
95
217
  };
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "@canva/app-i18n-kit": "^1.0.2",
21
- "@canva/app-ui-kit": "^4.4.0",
21
+ "@canva/app-ui-kit": "^4.5.0",
22
22
  "@canva/asset": "^2.1.0",
23
23
  "@canva/design": "^2.3.0",
24
24
  "@canva/error": "^2.1.0",
@@ -35,7 +35,7 @@
35
35
  "react-router-dom": "6.28.0"
36
36
  },
37
37
  "devDependencies": {
38
- "@canva/cli": "^0.0.1-beta.11",
38
+ "@canva/cli": ">= 0.0.1-beta.13 < 0.0.2",
39
39
  "@eslint/eslintrc": "3.2.0",
40
40
  "@eslint/js": "9.16.0",
41
41
  "@formatjs/cli": "6.3.14",
@@ -19,7 +19,7 @@
19
19
  },
20
20
  "dependencies": {
21
21
  "@canva/app-i18n-kit": "^1.0.2",
22
- "@canva/app-ui-kit": "^4.4.0",
22
+ "@canva/app-ui-kit": "^4.5.0",
23
23
  "@canva/asset": "^2.1.0",
24
24
  "@canva/design": "^2.3.0",
25
25
  "@canva/error": "^2.1.0",
@@ -30,7 +30,7 @@
30
30
  "react-intl": "6.8.7"
31
31
  },
32
32
  "devDependencies": {
33
- "@canva/cli": "^0.0.1-beta.11",
33
+ "@canva/cli": ">= 0.0.1-beta.13 < 0.0.2",
34
34
  "@eslint/eslintrc": "3.2.0",
35
35
  "@eslint/js": "9.16.0",
36
36
  "@formatjs/cli": "6.3.14",
@@ -10,7 +10,7 @@ exports[`Hello World Tests should have a consistent snapshot 1`] = `
10
10
  style="--NZu1Zw: 16px;"
11
11
  >
12
12
  <p
13
- class="fFOiLQ _5Ob_nQ fM_HdA"
13
+ class="D6xAvw E44aNA rU8RQQ"
14
14
  >
15
15
  To make changes to this app, edit the
16
16
  <code>
@@ -19,21 +19,21 @@ exports[`Hello World Tests should have a consistent snapshot 1`] = `
19
19
  file, then close and reopen the app in the editor to preview the changes.
20
20
  </p>
21
21
  <button
22
- class="_1QoxDw Qkd66A tYI0Vw o4TrkA zKTE_w Qkd66A tYI0Vw lsXp_w ubW6qw cwOZMg zQlusQ uRvRjQ"
22
+ class="_5KtATA LQzFZw xwTbNA _8ERLTg rV61VQ LQzFZw xwTbNA _4_iekA _3oHQrw j34Zww aqbYPg _3FvZZg"
23
23
  type="button"
24
24
  >
25
25
  <span
26
- class="_38oWvQ"
26
+ class="khPe7Q"
27
27
  >
28
28
  Do something cool
29
29
  </span>
30
30
  </button>
31
31
  <button
32
- class="_1QoxDw Qkd66A tYI0Vw o4TrkA NT2yCg Qkd66A tYI0Vw lsXp_w cwOZMg zQlusQ uRvRjQ"
32
+ class="_5KtATA LQzFZw xwTbNA _8ERLTg Z3nT2A LQzFZw xwTbNA _4_iekA j34Zww aqbYPg _3FvZZg"
33
33
  type="button"
34
34
  >
35
35
  <span
36
- class="_38oWvQ"
36
+ class="khPe7Q"
37
37
  >
38
38
  Open Canva Apps SDK docs
39
39
  </span>