@canva/cli 1.19.0 → 1.20.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.
Files changed (231) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +1 -9
  3. package/cli.js +408 -409
  4. package/package.json +1 -2
  5. package/templates/base/backend/base_backend/create.ts +0 -114
  6. package/templates/base/backend/database/database.ts +0 -42
  7. package/templates/base/backend/routers/auth.ts +0 -288
  8. package/templates/base/declarations/declarations.d.ts +0 -29
  9. package/templates/base/eslint.config.mjs +0 -14
  10. package/templates/base/package.json +0 -91
  11. package/templates/base/scripts/copy_env.ts +0 -13
  12. package/templates/base/scripts/ssl/ssl.ts +0 -131
  13. package/templates/base/scripts/start/app_runner.ts +0 -223
  14. package/templates/base/scripts/start/context.ts +0 -171
  15. package/templates/base/scripts/start/start.ts +0 -46
  16. package/templates/base/scripts/start.tests.ts +0 -61
  17. package/templates/base/styles/components.css +0 -38
  18. package/templates/base/tsconfig.json +0 -56
  19. package/templates/base/webpack.config.ts +0 -247
  20. package/templates/common/.env.template +0 -6
  21. package/templates/common/.gitignore.template +0 -8
  22. package/templates/common/.nvmrc +0 -1
  23. package/templates/common/.prettierrc +0 -21
  24. package/templates/common/LICENSE.md +0 -48
  25. package/templates/common/README.md +0 -179
  26. package/templates/common/jest.config.mjs +0 -35
  27. package/templates/common/jest.setup.ts +0 -35
  28. package/templates/content_publisher/README.md +0 -58
  29. package/templates/content_publisher/canva-app.json +0 -17
  30. package/templates/content_publisher/declarations/declarations.d.ts +0 -29
  31. package/templates/content_publisher/eslint.config.mjs +0 -14
  32. package/templates/content_publisher/package.json +0 -90
  33. package/templates/content_publisher/scripts/copy_env.ts +0 -13
  34. package/templates/content_publisher/scripts/ssl/ssl.ts +0 -131
  35. package/templates/content_publisher/scripts/start/app_runner.ts +0 -223
  36. package/templates/content_publisher/scripts/start/context.ts +0 -171
  37. package/templates/content_publisher/scripts/start/start.ts +0 -46
  38. package/templates/content_publisher/src/index.tsx +0 -4
  39. package/templates/content_publisher/src/intents/content_publisher/index.tsx +0 -107
  40. package/templates/content_publisher/src/intents/content_publisher/post_preview.tsx +0 -240
  41. package/templates/content_publisher/src/intents/content_publisher/preview_ui.tsx +0 -62
  42. package/templates/content_publisher/src/intents/content_publisher/settings_ui.tsx +0 -81
  43. package/templates/content_publisher/src/intents/content_publisher/types.ts +0 -29
  44. package/templates/content_publisher/styles/components.css +0 -38
  45. package/templates/content_publisher/styles/preview_ui.css +0 -49
  46. package/templates/content_publisher/tsconfig.json +0 -56
  47. package/templates/content_publisher/webpack.config.ts +0 -247
  48. package/templates/dam/backend/routers/dam.ts +0 -108
  49. package/templates/dam/backend/server.ts +0 -65
  50. package/templates/dam/canva-app.json +0 -25
  51. package/templates/dam/declarations/declarations.d.ts +0 -29
  52. package/templates/dam/eslint.config.mjs +0 -14
  53. package/templates/dam/package.json +0 -97
  54. package/templates/dam/scripts/copy_env.ts +0 -13
  55. package/templates/dam/scripts/ssl/ssl.ts +0 -131
  56. package/templates/dam/scripts/start/app_runner.ts +0 -223
  57. package/templates/dam/scripts/start/context.ts +0 -171
  58. package/templates/dam/scripts/start/start.ts +0 -46
  59. package/templates/dam/src/index.tsx +0 -4
  60. package/templates/dam/src/intents/design_editor/adapter.ts +0 -44
  61. package/templates/dam/src/intents/design_editor/app.tsx +0 -35
  62. package/templates/dam/src/intents/design_editor/config.ts +0 -220
  63. package/templates/dam/src/intents/design_editor/index.css +0 -3
  64. package/templates/dam/src/intents/design_editor/index.tsx +0 -25
  65. package/templates/dam/tsconfig.json +0 -56
  66. package/templates/dam/utils/backend/base_backend/create.ts +0 -114
  67. package/templates/dam/webpack.config.ts +0 -247
  68. package/templates/data_connector/README.md +0 -84
  69. package/templates/data_connector/canva-app.json +0 -21
  70. package/templates/data_connector/declarations/declarations.d.ts +0 -29
  71. package/templates/data_connector/eslint.config.mjs +0 -14
  72. package/templates/data_connector/package.json +0 -92
  73. package/templates/data_connector/scripts/copy_env.ts +0 -13
  74. package/templates/data_connector/scripts/ssl/ssl.ts +0 -131
  75. package/templates/data_connector/scripts/start/app_runner.ts +0 -223
  76. package/templates/data_connector/scripts/start/context.ts +0 -171
  77. package/templates/data_connector/scripts/start/start.ts +0 -46
  78. package/templates/data_connector/src/api/connect_client.ts +0 -6
  79. package/templates/data_connector/src/api/data_source.ts +0 -97
  80. package/templates/data_connector/src/api/data_sources/designs.tsx +0 -296
  81. package/templates/data_connector/src/api/data_sources/index.ts +0 -4
  82. package/templates/data_connector/src/api/data_sources/templates.tsx +0 -328
  83. package/templates/data_connector/src/api/fetch_data_table.ts +0 -55
  84. package/templates/data_connector/src/api/index.ts +0 -4
  85. package/templates/data_connector/src/api/oauth.ts +0 -8
  86. package/templates/data_connector/src/api/tests/data_source.test.tsx +0 -99
  87. package/templates/data_connector/src/components/app_error.tsx +0 -15
  88. package/templates/data_connector/src/components/footer.tsx +0 -26
  89. package/templates/data_connector/src/components/header.tsx +0 -40
  90. package/templates/data_connector/src/components/index.ts +0 -3
  91. package/templates/data_connector/src/components/inputs/messages.tsx +0 -95
  92. package/templates/data_connector/src/components/inputs/search_filter.tsx +0 -109
  93. package/templates/data_connector/src/components/inputs/select_field.tsx +0 -26
  94. package/templates/data_connector/src/context/app_context.tsx +0 -125
  95. package/templates/data_connector/src/context/index.ts +0 -2
  96. package/templates/data_connector/src/context/use_app_context.ts +0 -17
  97. package/templates/data_connector/src/index.tsx +0 -4
  98. package/templates/data_connector/src/intents/data_connector/app.tsx +0 -20
  99. package/templates/data_connector/src/intents/data_connector/entrypoint.tsx +0 -70
  100. package/templates/data_connector/src/intents/data_connector/home.tsx +0 -21
  101. package/templates/data_connector/src/intents/data_connector/index.tsx +0 -56
  102. package/templates/data_connector/src/pages/data_source_config.tsx +0 -9
  103. package/templates/data_connector/src/pages/error.tsx +0 -37
  104. package/templates/data_connector/src/pages/index.ts +0 -4
  105. package/templates/data_connector/src/pages/login.tsx +0 -145
  106. package/templates/data_connector/src/pages/select_source.tsx +0 -24
  107. package/templates/data_connector/src/routes/index.ts +0 -2
  108. package/templates/data_connector/src/routes/paths.ts +0 -7
  109. package/templates/data_connector/src/routes/protected_route.tsx +0 -26
  110. package/templates/data_connector/src/routes/routes.tsx +0 -42
  111. package/templates/data_connector/src/utils/data_params.ts +0 -17
  112. package/templates/data_connector/src/utils/data_table.ts +0 -116
  113. package/templates/data_connector/src/utils/fetch_result.ts +0 -36
  114. package/templates/data_connector/src/utils/index.ts +0 -2
  115. package/templates/data_connector/src/utils/tests/data_table.test.ts +0 -133
  116. package/templates/data_connector/styles/components.css +0 -38
  117. package/templates/data_connector/tsconfig.json +0 -56
  118. package/templates/data_connector/webpack.config.ts +0 -247
  119. package/templates/gen_ai/README.md +0 -27
  120. package/templates/gen_ai/backend/routers/image.ts +0 -232
  121. package/templates/gen_ai/backend/server.ts +0 -65
  122. package/templates/gen_ai/canva-app.json +0 -25
  123. package/templates/gen_ai/declarations/declarations.d.ts +0 -29
  124. package/templates/gen_ai/eslint.config.mjs +0 -14
  125. package/templates/gen_ai/package.json +0 -101
  126. package/templates/gen_ai/scripts/copy_env.ts +0 -13
  127. package/templates/gen_ai/scripts/ssl/ssl.ts +0 -131
  128. package/templates/gen_ai/scripts/start/app_runner.ts +0 -223
  129. package/templates/gen_ai/scripts/start/context.ts +0 -171
  130. package/templates/gen_ai/scripts/start/start.ts +0 -46
  131. package/templates/gen_ai/src/api/api.ts +0 -194
  132. package/templates/gen_ai/src/api/index.ts +0 -1
  133. package/templates/gen_ai/src/components/app_error.tsx +0 -18
  134. package/templates/gen_ai/src/components/footer.messages.ts +0 -48
  135. package/templates/gen_ai/src/components/footer.tsx +0 -156
  136. package/templates/gen_ai/src/components/image_grid.tsx +0 -103
  137. package/templates/gen_ai/src/components/index.ts +0 -7
  138. package/templates/gen_ai/src/components/loading_results.tsx +0 -169
  139. package/templates/gen_ai/src/components/prompt_input.messages.ts +0 -14
  140. package/templates/gen_ai/src/components/prompt_input.tsx +0 -154
  141. package/templates/gen_ai/src/components/remaining_credits.tsx +0 -84
  142. package/templates/gen_ai/src/components/report_box.tsx +0 -54
  143. package/templates/gen_ai/src/components/tests/remaining_credit.tests.tsx +0 -47
  144. package/templates/gen_ai/src/config.ts +0 -21
  145. package/templates/gen_ai/src/context/app_context.tsx +0 -153
  146. package/templates/gen_ai/src/context/context.messages.ts +0 -30
  147. package/templates/gen_ai/src/context/index.ts +0 -2
  148. package/templates/gen_ai/src/context/use_app_context.ts +0 -17
  149. package/templates/gen_ai/src/index.tsx +0 -4
  150. package/templates/gen_ai/src/intents/design_editor/app.tsx +0 -19
  151. package/templates/gen_ai/src/intents/design_editor/home.tsx +0 -13
  152. package/templates/gen_ai/src/intents/design_editor/index.tsx +0 -17
  153. package/templates/gen_ai/src/pages/error.tsx +0 -41
  154. package/templates/gen_ai/src/pages/generate.tsx +0 -9
  155. package/templates/gen_ai/src/pages/index.ts +0 -3
  156. package/templates/gen_ai/src/pages/results.tsx +0 -31
  157. package/templates/gen_ai/src/routes/index.ts +0 -1
  158. package/templates/gen_ai/src/routes/paths.ts +0 -4
  159. package/templates/gen_ai/src/routes/routes.tsx +0 -24
  160. package/templates/gen_ai/src/utils/index.ts +0 -1
  161. package/templates/gen_ai/src/utils/obscenity_filter.ts +0 -33
  162. package/templates/gen_ai/styles/components.css +0 -38
  163. package/templates/gen_ai/styles/utils.css +0 -3
  164. package/templates/gen_ai/tsconfig.json +0 -56
  165. package/templates/gen_ai/utils/backend/base_backend/create.ts +0 -114
  166. package/templates/gen_ai/webpack.config.ts +0 -247
  167. package/templates/hello_world/canva-app.json +0 -21
  168. package/templates/hello_world/declarations/declarations.d.ts +0 -29
  169. package/templates/hello_world/eslint.config.mjs +0 -14
  170. package/templates/hello_world/package.json +0 -90
  171. package/templates/hello_world/scripts/copy_env.ts +0 -13
  172. package/templates/hello_world/scripts/ssl/ssl.ts +0 -131
  173. package/templates/hello_world/scripts/start/app_runner.ts +0 -223
  174. package/templates/hello_world/scripts/start/context.ts +0 -171
  175. package/templates/hello_world/scripts/start/start.ts +0 -46
  176. package/templates/hello_world/src/index.tsx +0 -4
  177. package/templates/hello_world/src/intents/design_editor/app.tsx +0 -86
  178. package/templates/hello_world/src/intents/design_editor/index.tsx +0 -25
  179. package/templates/hello_world/src/intents/design_editor/tests/__snapshots__/app.tests.tsx.snap +0 -45
  180. package/templates/hello_world/src/intents/design_editor/tests/app.tests.tsx +0 -92
  181. package/templates/hello_world/styles/components.css +0 -38
  182. package/templates/hello_world/tsconfig.json +0 -56
  183. package/templates/hello_world/webpack.config.ts +0 -247
  184. package/templates/mls/README.md +0 -81
  185. package/templates/mls/canva-app.json +0 -25
  186. package/templates/mls/declarations/declarations.d.ts +0 -29
  187. package/templates/mls/eslint.config.mjs +0 -14
  188. package/templates/mls/jest.config.mjs +0 -36
  189. package/templates/mls/jest.setup.ts +0 -39
  190. package/templates/mls/package.json +0 -117
  191. package/templates/mls/scripts/copy_env.ts +0 -13
  192. package/templates/mls/scripts/ssl/ssl.ts +0 -131
  193. package/templates/mls/scripts/start/app_runner.ts +0 -223
  194. package/templates/mls/scripts/start/context.ts +0 -171
  195. package/templates/mls/scripts/start/start.ts +0 -46
  196. package/templates/mls/src/__tests__/app.tests.tsx +0 -11
  197. package/templates/mls/src/__tests__/office_selection_page.tests.tsx +0 -72
  198. package/templates/mls/src/__tests__/utils.tsx +0 -19
  199. package/templates/mls/src/adapter.ts +0 -126
  200. package/templates/mls/src/components/agent/agent_card.tsx +0 -57
  201. package/templates/mls/src/components/agent/agent_grid.tsx +0 -37
  202. package/templates/mls/src/components/agent/agent_list.tsx +0 -17
  203. package/templates/mls/src/components/agent/agent_search_filters.tsx +0 -88
  204. package/templates/mls/src/components/breadcrumb/breadcrumb.tsx +0 -40
  205. package/templates/mls/src/components/listing/listing_card.tsx +0 -64
  206. package/templates/mls/src/components/listing/listing_grid.tsx +0 -37
  207. package/templates/mls/src/components/listing/listing_list.tsx +0 -21
  208. package/templates/mls/src/components/listing/listing_search_filters.tsx +0 -145
  209. package/templates/mls/src/components/placeholders/placeholders.tsx +0 -65
  210. package/templates/mls/src/data.ts +0 -359
  211. package/templates/mls/src/index.tsx +0 -4
  212. package/templates/mls/src/intents/design_editor/app.tsx +0 -44
  213. package/templates/mls/src/intents/design_editor/index.tsx +0 -25
  214. package/templates/mls/src/pages/agent_details_page/agent_details_page.tsx +0 -175
  215. package/templates/mls/src/pages/list_page/agent_tab_panel.tsx +0 -126
  216. package/templates/mls/src/pages/list_page/list_page.tsx +0 -67
  217. package/templates/mls/src/pages/list_page/listing_tab_panel.tsx +0 -135
  218. package/templates/mls/src/pages/listing_details_page/listing_details_page.tsx +0 -418
  219. package/templates/mls/src/pages/loading_page/loading_page.tsx +0 -152
  220. package/templates/mls/src/pages/office_selection_page/office_selection_page.tsx +0 -144
  221. package/templates/mls/src/real_estate.type.ts +0 -44
  222. package/templates/mls/src/util/use_add_element.tsx +0 -62
  223. package/templates/mls/src/util/use_drag_element.tsx +0 -68
  224. package/templates/mls/styles/components.css +0 -38
  225. package/templates/mls/tsconfig.json +0 -54
  226. package/templates/mls/webpack.config.ts +0 -248
  227. package/templates/optional/.cursor/mcp.json +0 -8
  228. package/templates/optional/.vscode/extensions.json +0 -6
  229. package/templates/optional/.vscode/mcp.json +0 -9
  230. package/templates/optional/AGENTS.md +0 -154
  231. package/templates/optional/CLAUDE.md +0 -154
@@ -1,46 +0,0 @@
1
- #!/usr/bin/env node
2
- import yargs from "yargs";
3
- import { hideBin } from "yargs/helpers";
4
- import { AppRunner } from "./app_runner";
5
- import { Context } from "./context";
6
-
7
- const appRunner = new AppRunner();
8
-
9
- yargs(hideBin(process.argv))
10
- .version(false)
11
- .help()
12
- .option("ngrok", {
13
- description: "Run backend server via ngrok.",
14
- type: "boolean",
15
- // npm swallows command line args instead of forwarding to the script
16
- default:
17
- process.env.npm_config_ngrok?.toLocaleLowerCase().trim() === "true",
18
- })
19
- .option("use-https", {
20
- description: "Start local development server on HTTPS.",
21
- type: "boolean",
22
- // npm swallows commands line args instead of forwarding to the script
23
- default:
24
- process.env.npm_config_use_https?.toLocaleLowerCase().trim() === "true",
25
- })
26
- .option("override-frontend-port", {
27
- description:
28
- "Port to run the local development server on. Overrides the frontend port set in the .env file.",
29
- type: "number",
30
- alias: "p",
31
- })
32
- .option("preview", {
33
- description: "Open the app in Canva.",
34
- type: "boolean",
35
- default: false,
36
- })
37
- .command(
38
- "$0",
39
- "Starts local development",
40
- () => {},
41
- (args) => {
42
- const ctx = new Context(process.env, args);
43
- appRunner.run(ctx);
44
- },
45
- )
46
- .parse();
@@ -1,4 +0,0 @@
1
- import { prepareDesignEditor } from "@canva/intents/design";
2
- import designEditor from "./intents/design_editor";
3
-
4
- prepareDesignEditor(designEditor);
@@ -1,44 +0,0 @@
1
- import type {
2
- FindResourcesRequest,
3
- FindResourcesResponse,
4
- } from "@canva/app-components";
5
- import { auth } from "@canva/user";
6
-
7
- export async function findResources(
8
- request: FindResourcesRequest<"folder">,
9
- ): Promise<FindResourcesResponse> {
10
- const userToken = await auth.getCanvaUserToken();
11
-
12
- // TODO: Update the API path to match your backend
13
- // If using the backend example, the URL should be updated to `${BACKEND_HOST}/api/resources/find` to ensure requests are authenticated in production
14
- const url = new URL(`${BACKEND_HOST}/resources/find`);
15
-
16
- try {
17
- const response = await fetch(url, {
18
- method: "POST",
19
- headers: {
20
- Authorization: `Bearer ${userToken}`,
21
- "Content-Type": "application/json",
22
- },
23
- body: JSON.stringify(request),
24
- });
25
- const body = await response.json();
26
-
27
- if (body.resources) {
28
- return {
29
- type: "SUCCESS",
30
- resources: body.resources,
31
- continuation: body.continuation,
32
- };
33
- }
34
- return {
35
- type: "ERROR",
36
- errorCode: body.errorCode || "INTERNAL_ERROR",
37
- };
38
- } catch {
39
- return {
40
- type: "ERROR",
41
- errorCode: "INTERNAL_ERROR",
42
- };
43
- }
44
- }
@@ -1,35 +0,0 @@
1
- import { SearchableListView } from "@canva/app-components";
2
- import { Box } from "@canva/app-ui-kit";
3
- import "@canva/app-ui-kit/styles.css";
4
- import { findResources } from "./adapter";
5
- import { useConfig } from "./config";
6
- import * as styles from "./index.css";
7
-
8
- export function App() {
9
- const config = useConfig();
10
- return (
11
- <Box className={styles.rootWrapper} height="full">
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
- />
33
- </Box>
34
- );
35
- }
@@ -1,220 +0,0 @@
1
- import type { Config } from "@canva/app-components";
2
- import { useIntl } from "react-intl";
3
-
4
- type ContainerTypes = "folder";
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
- // These options do not need to be translated as they are universal technical terms
26
- /* eslint-disable formatjs/no-literal-string-in-object */
27
- options: [
28
- { value: "mp4", label: "MP4" },
29
- { value: "png", label: "PNG" },
30
- { value: "jpeg", label: "JPEG" },
31
- ],
32
- /* eslint-enable formatjs/no-literal-string-in-object */
33
- allowCustomValue: true,
34
- },
35
- {
36
- filterType: "RADIO",
37
- label: intl.formatMessage({
38
- defaultMessage: "Size",
39
- description: "Label of filters for asset size",
40
- }),
41
- key: "size",
42
- options: [
43
- {
44
- label: intl.formatMessage({
45
- defaultMessage: "Large (800+ px)",
46
- description: "One of the filter options for asset size",
47
- }),
48
- value: "large",
49
- },
50
- {
51
- label: intl.formatMessage({
52
- defaultMessage: "Medium (200-799px)",
53
- description: "One of the filter options for asset size",
54
- }),
55
- value: "medium",
56
- },
57
- ],
58
- allowCustomValue: true,
59
- customValueInputType: "SIZE_RANGE",
60
- },
61
- {
62
- filterType: "RADIO",
63
- label: intl.formatMessage({
64
- defaultMessage: "Update Date",
65
- description: "Label of the filters for asset's update date",
66
- }),
67
- key: "updateDate",
68
- options: [
69
- {
70
- value: ">now-30m",
71
- label: intl.formatMessage({
72
- defaultMessage: "Last 30 Minutes",
73
- description:
74
- "One of the filter options for asset update date",
75
- }),
76
- },
77
- {
78
- value: ">now-7d",
79
- label: intl.formatMessage({
80
- defaultMessage: "Last 7 days",
81
- description:
82
- "One of the filter options for asset update date",
83
- }),
84
- },
85
- ],
86
- allowCustomValue: true,
87
- customValueInputType: "DATE_RANGE",
88
- },
89
- {
90
- filterType: "RADIO",
91
- label: intl.formatMessage({
92
- defaultMessage: "Design Status",
93
- description: "Label of the filters for asset's design status",
94
- }),
95
- key: "designStatus",
96
- options: [
97
- {
98
- value: "approved",
99
- label: intl.formatMessage({
100
- defaultMessage: "Approved",
101
- description:
102
- "One of the filter options for asset design status",
103
- }),
104
- },
105
- {
106
- value: "rejected",
107
- label: intl.formatMessage({
108
- defaultMessage: "Rejected",
109
- description:
110
- "One of the filter options for asset design status",
111
- }),
112
- },
113
- {
114
- value: "draft",
115
- label: intl.formatMessage({
116
- defaultMessage: "Draft",
117
- description:
118
- "One of the filter options for asset design status",
119
- }),
120
- },
121
- ],
122
- allowCustomValue: true,
123
- customValueInputType: "PLAIN_TEXT",
124
- },
125
- ],
126
- },
127
- },
128
- containerTypes: [
129
- {
130
- value: "folder",
131
- label: intl.formatMessage({
132
- defaultMessage: "Folders",
133
- description: "Name of the asset container type",
134
- }),
135
- listingSurfaces: [
136
- { surface: "HOMEPAGE" },
137
- {
138
- surface: "CONTAINER",
139
- parentContainerTypes: ["folder"],
140
- },
141
- { surface: "SEARCH" },
142
- ],
143
- searchInsideContainer: {
144
- enabled: true,
145
- placeholder: intl.formatMessage({
146
- defaultMessage: "Search for media inside this folder",
147
- description: "Placeholder of a search input box",
148
- }),
149
- },
150
- },
151
- ],
152
- sortOptions: [
153
- {
154
- value: "created_at DESC",
155
- label: intl.formatMessage({
156
- defaultMessage: "Creation date (newest)",
157
- description: "One of the sort options",
158
- }),
159
- },
160
- {
161
- value: "created_at ASC",
162
- label: intl.formatMessage({
163
- defaultMessage: "Creation date (oldest)",
164
- description: "One of the sort options",
165
- }),
166
- },
167
- {
168
- value: "updated_at DESC",
169
- label: intl.formatMessage({
170
- defaultMessage: "Updated (newest)",
171
- description: "One of the sort options",
172
- }),
173
- },
174
- {
175
- value: "updated_at ASC",
176
- label: intl.formatMessage({
177
- defaultMessage: "Updated (oldest)",
178
- description: "One of the sort options",
179
- }),
180
- },
181
- {
182
- value: "name ASC",
183
- label: intl.formatMessage({
184
- defaultMessage: "Name (A-Z)",
185
- description: "One of the sort options",
186
- }),
187
- },
188
- {
189
- value: "name DESC",
190
- label: intl.formatMessage({
191
- defaultMessage: "Name (Z-A)",
192
- description: "One of the sort options",
193
- }),
194
- },
195
- ],
196
- layouts: ["MASONRY", "LIST"],
197
- resourceTypes: ["IMAGE", "VIDEO", "EMBED"],
198
- moreInfoMessage: intl.formatMessage({
199
- defaultMessage:
200
- "At the moment, we only support images and videos. Corrupted and unsupported files will not appear.",
201
- description: "Helper text to explain why some assets are not visible",
202
- }),
203
- // TODO remove `export` if your app does not support exporting the Canva design into an external platform
204
- export: {
205
- enabled: true,
206
- // 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
207
- containerTypes: ["folder"],
208
- // TODO remove file types that are not supported by your platform
209
- acceptedFileTypes: [
210
- "png",
211
- "pdf_standard",
212
- "jpg",
213
- "gif",
214
- "svg",
215
- "video",
216
- "pptx",
217
- ],
218
- },
219
- };
220
- };
@@ -1,3 +0,0 @@
1
- .rootWrapper {
2
- overflow-y: hidden;
3
- }
@@ -1,25 +0,0 @@
1
- import "@canva/app-ui-kit/styles.css";
2
- import { AppI18nProvider } from "@canva/app-i18n-kit";
3
- import { AppUiProvider } from "@canva/app-ui-kit";
4
- import type { DesignEditorIntent } from "@canva/intents/design";
5
- import { createRoot } from "react-dom/client";
6
- import { App } from "./app";
7
-
8
- async function render() {
9
- const root = createRoot(document.getElementById("root") as Element);
10
-
11
- root.render(
12
- <AppI18nProvider>
13
- <AppUiProvider>
14
- <App />
15
- </AppUiProvider>
16
- </AppI18nProvider>,
17
- );
18
- }
19
-
20
- const designEditor: DesignEditorIntent = { render };
21
- export default designEditor;
22
-
23
- if (module.hot) {
24
- module.hot.accept("./app", render);
25
- }
@@ -1,56 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "jsx": "react-jsx",
4
- "lib": [
5
- "dom",
6
- "dom.iterable",
7
- "es2018",
8
- "es2019.array",
9
- "es2019.object",
10
- "es2019.string",
11
- "es2020.promise",
12
- "es2020.string"
13
- ],
14
- "types": ["node", "webpack-env", "jest"],
15
- "composite": false,
16
- "declaration": false,
17
- "declarationMap": false,
18
- "experimentalDecorators": true,
19
- "importHelpers": true,
20
- "noImplicitOverride": true,
21
- "moduleResolution": "bundler",
22
- "esModuleInterop": true,
23
- "rootDir": ".",
24
- "outDir": "dist",
25
- "strict": true,
26
- "skipLibCheck": true,
27
- "target": "ES2019",
28
- "sourceMap": true,
29
- "inlineSources": true,
30
- "module": "ESNext",
31
- "noImplicitAny": true,
32
- "noImplicitReturns": true,
33
- "noFallthroughCasesInSwitch": true,
34
- "noUncheckedIndexedAccess": true,
35
- "removeComments": true,
36
- "preserveConstEnums": true,
37
- "allowSyntheticDefaultImports": true,
38
- "baseUrl": "./",
39
- "paths": {
40
- "styles": ["./styles"]
41
- }
42
- },
43
- "include": [
44
- "./src/**/*",
45
- "./backend/**/*",
46
- "./utils/**/*",
47
- "./scripts/**/*",
48
- "./declarations/declarations.d.ts",
49
- "./styles/**/*"
50
- ],
51
- "ts-node": {
52
- "compilerOptions": {
53
- "module": "commonjs"
54
- }
55
- }
56
- }
@@ -1,114 +0,0 @@
1
- /* eslint-disable no-console */
2
- import { TokenVerificationError } from "@canva/app-middleware";
3
- import debug from "debug";
4
- import express from "express";
5
- import type { NextFunction, Request, Response } from "express";
6
- import fs from "fs";
7
- import http from "http";
8
- import https from "https";
9
-
10
- const serverDebug = debug("server");
11
-
12
- interface BaseServer {
13
- app: express.Express;
14
-
15
- /**
16
- * Starts the server on the address or port provided
17
- * @param address port number or string address or if left undefined express defaults to port 3000
18
- */
19
- start: (address: number | string | undefined) => void;
20
- }
21
-
22
- /**
23
- * createBaseServer instantiates a customised express server with:
24
- * - json body handling
25
- * - health check endpoint
26
- * - catchall endpoint
27
- * - error handler catch route
28
- * - process termination handling
29
- * - debug logging - prefix starting your server with `DEBUG=server npm run XXX`
30
- *
31
- * @returns BaseServer object containing the express app and a start function
32
- */
33
- export function createBaseServer(router: express.Router): BaseServer {
34
- const SHOULD_ENABLE_HTTPS = process.env?.SHOULD_ENABLE_HTTPS === "true";
35
- const HTTPS_CERT_FILE = process.env?.HTTPS_CERT_FILE;
36
- const HTTPS_KEY_FILE = process.env?.HTTPS_KEY_FILE;
37
-
38
- const app = express();
39
- app.use(express.json());
40
-
41
- // It can help to provide an extra layer of obsecurity to reduce server fingerprinting.
42
- app.disable("x-powered-by");
43
-
44
- // Health check endpoint
45
- app.get("/healthz", (req, res) => {
46
- res.sendStatus(200);
47
- });
48
-
49
- // logging middleware
50
- app.use((req, _res, next) => {
51
- serverDebug(`${new Date().toISOString()}: ${req.method} ${req.url}`);
52
- next();
53
- });
54
-
55
- // Custom routes router
56
- app.use(router);
57
-
58
- // catch all router
59
- app.all("*", (req, res) => {
60
- res.status(404).send({
61
- error: `unhandled '${req.method}' on '${req.url}'`,
62
- });
63
- });
64
-
65
- // default error handler
66
- app.use((err: Error, _req: Request, res: Response, _next: NextFunction) => {
67
- // Handle authentication errors from @canva/app-middleware
68
- if (err instanceof TokenVerificationError) {
69
- res.status(err.statusCode).json({
70
- error: err.code,
71
- message: err.message,
72
- });
73
- return;
74
- }
75
-
76
- console.error(err.stack);
77
- res.status(500).send({
78
- error: "something went wrong",
79
- });
80
- });
81
-
82
- let server;
83
- if (SHOULD_ENABLE_HTTPS) {
84
- if (!HTTPS_CERT_FILE || !HTTPS_KEY_FILE) {
85
- throw new Error(
86
- "Looks like you're running the example with --use-https flag, but SSL certificates haven't been generated. Please remove the .ssl/ folder and re-run the command again.",
87
- );
88
- }
89
-
90
- server = https.createServer(
91
- {
92
- key: fs.readFileSync(HTTPS_KEY_FILE),
93
- cert: fs.readFileSync(HTTPS_CERT_FILE),
94
- },
95
- app,
96
- );
97
- } else {
98
- server = http.createServer(app);
99
- }
100
-
101
- return {
102
- app,
103
- start: (address: number | string | undefined) => {
104
- console.log(`Listening on '${address}'`);
105
- server.listen(address);
106
- process.on("SIGTERM", () => {
107
- serverDebug("SIGTERM signal received: closing HTTP server");
108
- server.close(() => {
109
- serverDebug("HTTP server closed");
110
- });
111
- });
112
- },
113
- };
114
- }