@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,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,247 +0,0 @@
1
- import type { Configuration } from "webpack";
2
- import { DefinePlugin, optimize } from "webpack";
3
- import path from "path";
4
- import TerserPlugin from "terser-webpack-plugin";
5
- import { transform } from "@formatjs/ts-transformer";
6
- import chalk from "chalk";
7
- import { config } from "dotenv";
8
- import { Configuration as DevServerConfiguration } from "webpack-dev-server";
9
-
10
- config();
11
-
12
- type DevConfig = {
13
- port: number;
14
- enableHmr: boolean;
15
- enableHttps: boolean;
16
- appOrigin?: string;
17
- appId?: string; // Deprecated in favour of appOrigin
18
- certFile?: string;
19
- keyFile?: string;
20
- };
21
-
22
- export function buildConfig({
23
- devConfig,
24
- appEntry = path.join(process.cwd(), "src", "index.tsx"),
25
- backendHost = process.env.CANVA_BACKEND_HOST,
26
- // For IN_HARNESS, refer to the following docs for more information: https://www.canva.dev/docs/apps/test-harness/
27
- inHarness = process.env.IN_HARNESS?.toLowerCase() === "true",
28
- }: {
29
- devConfig?: DevConfig;
30
- appEntry?: string;
31
- backendHost?: string;
32
- inHarness?: boolean;
33
- } = {}): Configuration & DevServerConfiguration {
34
- const mode = devConfig ? "development" : "production";
35
-
36
- if (!backendHost) {
37
- console.warn(
38
- chalk.yellow.bold("BACKEND_HOST is undefined."),
39
- `If your app requires a backend, refer to "Customizing the backend host" in the README.md for more information.`,
40
- );
41
- } else if (backendHost.includes("localhost") && mode === "production") {
42
- console.error(
43
- chalk.redBright.bold(
44
- "BACKEND_HOST should not be set to localhost for production builds!",
45
- ),
46
- `Refer to "Customizing the backend host" in the README.md for more information.`,
47
- );
48
- }
49
-
50
- return {
51
- mode,
52
- context: path.resolve(process.cwd(), "./"),
53
- entry: inHarness
54
- ? {
55
- harness: path.join(process.cwd(), "harness", "harness.tsx"),
56
- init: path.join(process.cwd(), "harness", "init.ts"),
57
- }
58
- : {
59
- app: appEntry,
60
- },
61
- target: "web",
62
- resolve: {
63
- alias: {
64
- styles: path.resolve(process.cwd(), "styles"),
65
- src: path.resolve(process.cwd(), "src"),
66
- },
67
- extensions: [".ts", ".tsx", ".js", ".css", ".svg", ".woff", ".woff2"],
68
- },
69
- infrastructureLogging: {
70
- level: inHarness ? "info" : "none",
71
- },
72
- module: {
73
- rules: [
74
- {
75
- test: /\.tsx?$/,
76
- exclude: /node_modules/,
77
- use: [
78
- {
79
- loader: "ts-loader",
80
- options: {
81
- transpileOnly: true,
82
- getCustomTransformers() {
83
- return {
84
- before: [
85
- transform({
86
- overrideIdFn: "[sha512:contenthash:base64:6]",
87
- }),
88
- ],
89
- };
90
- },
91
- },
92
- },
93
- ],
94
- },
95
- {
96
- test: /\.css$/,
97
- exclude: /node_modules/,
98
- use: [
99
- "style-loader",
100
- {
101
- loader: "css-loader",
102
- options: {
103
- modules: true,
104
- },
105
- },
106
- {
107
- loader: "postcss-loader",
108
- options: {
109
- postcssOptions: {
110
- plugins: [require("cssnano")({ preset: "default" })],
111
- },
112
- },
113
- },
114
- ],
115
- },
116
- {
117
- test: /\.(png|jpg|jpeg)$/i,
118
- type: "asset/inline",
119
- },
120
- {
121
- test: /\.(woff|woff2)$/,
122
- type: "asset/inline",
123
- },
124
- {
125
- test: /\.svg$/,
126
- oneOf: [
127
- {
128
- issuer: /\.[jt]sx?$/,
129
- resourceQuery: /react/, // *.svg?react
130
- use: ["@svgr/webpack", "url-loader"],
131
- },
132
- {
133
- type: "asset/resource",
134
- parser: {
135
- dataUrlCondition: {
136
- maxSize: 200,
137
- },
138
- },
139
- },
140
- ],
141
- },
142
- {
143
- test: /\.css$/,
144
- include: /node_modules/,
145
- use: [
146
- "style-loader",
147
- "css-loader",
148
- {
149
- loader: "postcss-loader",
150
- options: {
151
- postcssOptions: {
152
- plugins: [require("cssnano")({ preset: "default" })],
153
- },
154
- },
155
- },
156
- ],
157
- },
158
- ],
159
- },
160
- optimization: {
161
- minimizer: [
162
- new TerserPlugin({
163
- terserOptions: {
164
- format: {
165
- // Turned on because emoji and regex is not minified properly using default
166
- // https://github.com/facebook/create-react-app/issues/2488
167
- ascii_only: true,
168
- },
169
- },
170
- }),
171
- ],
172
- },
173
- output: {
174
- filename: `[name].js`,
175
- path: path.resolve(process.cwd(), "dist"),
176
- clean: true,
177
- },
178
- plugins: [
179
- new DefinePlugin({
180
- BACKEND_HOST: JSON.stringify(backendHost),
181
- }),
182
- // Apps can only submit a single JS file via the Developer Portal
183
- new optimize.LimitChunkCountPlugin({ maxChunks: 1 }),
184
- ].filter(Boolean),
185
- ...buildDevConfig(devConfig),
186
- };
187
- }
188
-
189
- function buildDevConfig(options?: DevConfig): {
190
- devtool?: string;
191
- devServer?: DevServerConfiguration;
192
- } {
193
- if (!options) {
194
- return {};
195
- }
196
-
197
- const { port, enableHmr, appOrigin, enableHttps, certFile, keyFile } =
198
- options;
199
- const host = "localhost";
200
-
201
- let devServer: DevServerConfiguration = {
202
- server: enableHttps
203
- ? {
204
- type: "https",
205
- options: {
206
- cert: certFile,
207
- key: keyFile,
208
- },
209
- }
210
- : "http",
211
- host,
212
- allowedHosts: [host],
213
- historyApiFallback: {
214
- rewrites: [{ from: /^\/$/, to: "/app.js" }],
215
- },
216
- port,
217
- client: {
218
- logging: "verbose",
219
- },
220
- };
221
-
222
- if (enableHmr && appOrigin) {
223
- devServer = {
224
- ...devServer,
225
- allowedHosts: [host, new URL(appOrigin).hostname],
226
- headers: {
227
- "Access-Control-Allow-Origin": appOrigin,
228
- "Access-Control-Allow-Credentials": "true",
229
- "Access-Control-Allow-Private-Network": "true",
230
- },
231
- };
232
- } else {
233
- if (enableHmr && !appOrigin) {
234
- console.warn(
235
- "Attempted to enable Hot Module Replacement (HMR) without configuring App Origin... Disabling HMR.",
236
- );
237
- }
238
- devServer.webSocketServer = false;
239
- }
240
-
241
- return {
242
- devtool: "source-map",
243
- devServer,
244
- };
245
- }
246
-
247
- export default buildConfig;
@@ -1,6 +0,0 @@
1
- CANVA_FRONTEND_PORT=8080
2
- CANVA_BACKEND_PORT=3001
3
- CANVA_BACKEND_HOST=http://localhost:3001 # TODO: replace this with your production URL before submitting your app
4
- CANVA_APP_ID=# TODO: Add your app's ID here to configure your backend for JWT verification
5
- CANVA_APP_ORIGIN=# TODO: Add your app's origin here from the "Developer Portal -> Settings -> Security" to enable HMR
6
- CANVA_HMR_ENABLED=FALSE # TODO: set to TRUE to enable HMR
@@ -1,8 +0,0 @@
1
- .DS_Store
2
- .env
3
- .idea
4
- .ssl
5
- *.log*
6
- **/*/db.json
7
- dist
8
- node_modules
@@ -1 +0,0 @@
1
- 20.10.0
@@ -1,21 +0,0 @@
1
- {
2
- "arrowParens": "always",
3
- "bracketSpacing": true,
4
- "endOfLine": "lf",
5
- "htmlWhitespaceSensitivity": "css",
6
- "insertPragma": false,
7
- "singleAttributePerLine": false,
8
- "bracketSameLine": false,
9
- "jsxSingleQuote": false,
10
- "printWidth": 80,
11
- "proseWrap": "preserve",
12
- "quoteProps": "as-needed",
13
- "requirePragma": false,
14
- "semi": true,
15
- "singleQuote": false,
16
- "tabWidth": 2,
17
- "trailingComma": "all",
18
- "useTabs": false,
19
- "embeddedLanguageFormatting": "auto",
20
- "experimentalTernaries": false
21
- }
@@ -1,48 +0,0 @@
1
- # A message from Canva
2
-
3
- By making these software components available to you, our goal is to give you
4
- the right to use the components to build your apps for Canva's ecosystem. See
5
- below for the specific licence terms that apply to your use.
6
-
7
- # Licence
8
-
9
- Canva Pty Ltd (ACN 158 929 938) ("Canva") owns the copyright in the software and
10
- associated documentation files to which this Licence relates (each a "Software
11
- Component"). Canva reserves all of its rights.
12
-
13
- Permission is hereby granted, free of charge, to any person obtaining a copy of
14
- the Software Components ("You"), to use the Software Components, but strictly
15
- subject to the following restrictions and conditions:
16
-
17
- 1. You must only use the Software Components and any Derivative on the Canva
18
- Platform.
19
-
20
- 2. You must only use the Software Components and any Derivative for the purpose
21
- of building or updating Permitted Apps, and for no other purpose.
22
-
23
- 3. You must include a copy of this Licence in all copies of any Software
24
- Component and Derivative.
25
-
26
- 4. To the fullest extent permitted by law, the Software Components are provided
27
- "as is", without warranty of any kind, express or implied, including but not
28
- limited to the warranties of merchantability, fitness for a particular
29
- purpose and non-infringement. To the fullest extent permitted by law, in no
30
- event shall the authors or copyright holders be liable for any claim,
31
- damages or other liability, whether in an action of contract, tort or
32
- otherwise, arising from, out of or in connection with the Software Components
33
- or any Derivative, or the use of or other dealings in the Software Components
34
- or any Derivative.
35
-
36
- 5. In this Licence:
37
-
38
- (a) "Canva Platform" means the visual communications platform owned and
39
- operated by Canva that is made available on Canva.com (as well as any
40
- sub-domains and international versions) and via mobile applications, desktop
41
- applications, and in other forms provided or made available by Canva;
42
-
43
- (b) "Derivative" means any software, document or other material that: (i)
44
- contains any Software Component; and/or (ii) comprises or contains a
45
- derivative, adaptation or substantial part of any Software Component; and
46
-
47
- (c) "Permitted App" means a software application that is solely offered to
48
- end-users on the Canva Platform.
@@ -1,179 +0,0 @@
1
- # Canva App
2
-
3
- Welcome to your Canva App! 🎉
4
-
5
- This is a starting point for your app using your chosen template. The complete documentation for the platform is at [canva.dev/docs/apps](https://www.canva.dev/docs/apps/).
6
-
7
- **Note:** This code and documentation assumes some experience with TypeScript and React.
8
-
9
- ## Requirements
10
-
11
- - Node.js `v18` or `v20.10.0`
12
- - npm `v9` or `v10`
13
-
14
- **Note:** To make sure you're running the correct version of Node.js, we recommend using a version manager, such as [nvm](https://github.com/nvm-sh/nvm#intro). The [.nvmrc](/.nvmrc) file in the root directory of this repo will ensure the correct version is used once you run `nvm install`.
15
-
16
- ## Quick start
17
-
18
- ```bash
19
- npm install
20
- ```
21
-
22
- ## Running your Canva App
23
-
24
- ### Step 1: Start the local development server
25
-
26
- To start the boilerplate's development server, run the following command:
27
-
28
- ```bash
29
- npm start
30
- ```
31
-
32
- The server becomes available at <http://localhost:8080>.
33
-
34
- The app's source code is in the `src/app.tsx` file.
35
-
36
- ### Step 2: Preview the app
37
-
38
- The local development server only exposes a JavaScript bundle, so you can't preview an app by visiting <http://localhost:8080>. You can only preview an app via the Canva editor.
39
-
40
- To preview an app:
41
-
42
- 1. Create an app via the [Developer Portal](https://www.canva.com/developers/apps).
43
- 2. Select **App source > Development URL**.
44
- 3. In the **Development URL** field, enter the URL of the development server.
45
- 4. Click **Preview**. This opens the Canva editor (and the app) in a new tab.
46
- 5. Click **Open**. (This screen only appears when using an app for the first time.)
47
-
48
- The app will appear in the side panel.
49
-
50
- <details>
51
- <summary>Previewing apps in Safari</summary>
52
-
53
- By default, the development server is not HTTPS-enabled. This is convenient, as there's no need for a security certificate, but it prevents apps from being previewed in Safari.
54
-
55
- **Why Safari requires the development server to be HTTPS-enabled?**
56
-
57
- Canva itself is served via HTTPS and most browsers prevent HTTPS pages from loading scripts via non-HTTPS connections. Chrome and Firefox make exceptions for local servers, such as `localhost`, but Safari does not, so if you're using Safari, the development server must be HTTPS-enabled.
58
-
59
- To learn more, see [Loading mixed-content resources](https://developer.mozilla.org/en-US/docs/Web/Security/Mixed_content#loading_mixed-content_resources).
60
-
61
- To preview apps in Safari:
62
-
63
- 1. Start the development server with HTTPS enabled:
64
-
65
- ```bash
66
- npm start --use-https
67
- ```
68
-
69
- 2. Navigate to <https://localhost:8080>.
70
- 3. Bypass the invalid security certificate warning:
71
- 1. Click **Show details**.
72
- 2. Click **Visit website**.
73
- 4. In the Developer Portal, set the app's **Development URL** to <https://localhost:8080>.
74
- 5. Click preview (or refresh your app if it's already open).
75
-
76
- You need to bypass the invalid security certificate warning every time you start the local server. A similar warning will appear in other browsers (and will need to be bypassed) whenever HTTPS is enabled.
77
-
78
- </details>
79
-
80
- ### Step 3 (Optional): Enable Hot Module Replacement
81
-
82
- By default, every time you make a change to an app, you have to reload the entire app to see the results of those changes. If you enable [Hot Module Replacement](https://webpack.js.org/concepts/hot-module-replacement/) (HMR), changes will be reflected without a full reload, which significantly speeds up the development loop.
83
-
84
- **Note:** HMR does **not** work while running the development server in a Docker container.
85
-
86
- To enable HMR:
87
-
88
- 1. Navigate to an app via the [Your apps](https://www.canva.com/developers/apps).
89
- 1. Select **Security** -> **Credentials** -> **.env file**.
90
- 1. Copy the `.env` file contents.
91
- 1. Paste the contents into the starter kit's `.env` file. For example:
92
-
93
- ```bash
94
- CANVA_APP_ORIGIN=https://app-aabbccddeeff.canva-apps.com
95
- CANVA_HMR_ENABLED=true
96
- ```
97
-
98
- 1. Restart the local development server.
99
- 1. Reload the app manually to ensure that HMR takes effect.
100
-
101
- ### Step 4 (Optional): Setup the Canva Dev MCP Server
102
-
103
- If you're using AI coding tools, such as Cursor or Claude Code, you can connect to the Canva Dev MCP Server to supercharge your development workflow. See this [setup guide](https://www.canva.dev/docs/apps/mcp-server/) to get started.
104
-
105
- ## Running an app's backend
106
-
107
- Some templates provide an example backend. This backend is defined in the template's `backend/server.ts` file, automatically starts when the `npm start` command is run, and becomes available at <http://localhost:3001>.
108
-
109
- To run templates that have a backend:
110
-
111
- 1. Navigate to the [Your apps](https://www.canva.com/developers/apps) page.
112
- 1. Select the app you want to run the example with.
113
- 1. Copy your environment variables from **Security** -> **Credentials** -> **.env file**.
114
- 1. Paste the contents into the starter kit's `.env` file.
115
-
116
- For example:
117
-
118
- ```bash
119
- CANVA_APP_ID=AABBccddeeff
120
- CANVA_APP_ORIGIN=https://app-aabbccddeeff.canva-apps.com
121
- CANVA_BACKEND_PORT=3001
122
- CANVA_FRONTEND_PORT=8080
123
- CANVA_BACKEND_HOST=http://localhost:3001
124
- CANVA_HMR_ENABLED=TRUE
125
- ```
126
-
127
- 1. Start the app:
128
-
129
- ```bash
130
- npm start
131
- ```
132
-
133
- The ID of the app must be explicitly defined because it's required to [send and verify HTTP requests](https://www.canva.dev/docs/apps/verifying-http-requests/). If you don't set up the ID in the `.env` file, an error will be thrown when attempting to run the example.
134
-
135
- ## Customizing the backend host
136
-
137
- If your app has a backend, the URL of the server likely depends on whether it's a development or production build. For example, during development, the backend is probably running on a localhost URL, but once the app's in production, the backend needs to be exposed to the internet.
138
-
139
- To more easily customize the URL of the server:
140
-
141
- 1. Open the `.env` file in the text editor of your choice.
142
- 2. Set the `CANVA_BACKEND_HOST` environment variable to the URL of the server.
143
- 3. When sending a request, use `BACKEND_HOST` as the base URL:
144
-
145
- ```ts
146
- const response = await fetch(`${BACKEND_HOST}/custom-route`);
147
- ```
148
-
149
- **Note:** `BACKEND_HOST` is a global constant that contains the value of the `CANVA_BACKEND_HOST` environment variable. The variable is made available to the app via webpack and does not need to be imported.
150
-
151
- 4. Before bundling the app for production, update `CANVA_BACKEND_HOST` to point to the production backend.
152
-
153
- ## Configure ngrok (optional)
154
-
155
- If your app requires authentication with a third party service, your server needs to be exposed via a publicly available URL, so that Canva can send requests to it.
156
- This step explains how to do this with [ngrok](https://ngrok.com/).
157
-
158
- **Note:** ngrok is a useful tool, but it has inherent security risks, such as someone figuring out the URL of your server and accessing proprietary information. Be mindful of the risks, and if you're working as part of an organization, talk to your IT department.
159
- You must replace ngrok urls with hosted API endpoints for production apps.
160
-
161
- To use ngrok, you'll need to do the following:
162
-
163
- 1. Sign up for a ngrok account at <https://ngrok.com/>.
164
- 2. Locate your ngrok [authtoken](https://dashboard.ngrok.com/get-started/your-authtoken).
165
- 3. Set an environment variable for your authtoken, using the command line. Replace `<YOUR_AUTH_TOKEN>` with your actual ngrok authtoken:
166
-
167
- For macOS and Linux:
168
-
169
- ```bash
170
- export NGROK_AUTHTOKEN=<YOUR_AUTH_TOKEN>
171
- ```
172
-
173
- For Windows PowerShell:
174
-
175
- ```shell
176
- $Env:NGROK_AUTHTOKEN = "<YOUR_AUTH_TOKEN>"
177
- ```
178
-
179
- This environment variable is available for the current terminal session, so the command must be re-run for each new session. Alternatively, you can add the variable to your terminal's default parameters.
@@ -1,35 +0,0 @@
1
- import { pathsToModuleNameMapper } from "ts-jest";
2
- import tsconfig from "./tsconfig.json" with { type: "json" };
3
-
4
- const { compilerOptions } = tsconfig;
5
-
6
- /** @type {import('ts-jest').JestConfigWithTsJest} */
7
-
8
- export default {
9
- preset: "ts-jest",
10
- testEnvironment: "jsdom",
11
- testRegex: "(/(tests|__tests__)/.*|(\\.|/)(tests))\\.tsx?$",
12
- modulePathIgnorePatterns: ["./internal/", "./node_modules/"],
13
- modulePaths: [compilerOptions.baseUrl],
14
- moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths || {}),
15
- transform: {
16
- ".+\\.(css)$": "jest-css-modules-transform",
17
- "^.+\\.tsx?$": [
18
- "ts-jest",
19
- {
20
- astTransformers: {
21
- before: [
22
- {
23
- path: "@formatjs/ts-transformer/ts-jest-integration",
24
- options: {
25
- overrideIdFn: "[sha512:contenthash:base64:6]",
26
- ast: true,
27
- },
28
- },
29
- ],
30
- },
31
- },
32
- ],
33
- },
34
- setupFiles: ["<rootDir>/jest.setup.ts"],
35
- };
@@ -1,35 +0,0 @@
1
- // For usage information, see the README.md file.
2
-
3
- // Import Canva SDK testing utilities
4
- import * as asset from "@canva/asset/test";
5
- import * as design from "@canva/design/test";
6
- import * as error from "@canva/error/test";
7
- import * as intents from "@canva/intents/test";
8
- import * as platform from "@canva/platform/test";
9
- import * as user from "@canva/user/test";
10
-
11
- /*
12
- Initialize test environments for each Canva SDK package
13
- This sets up the necessary test infrastructure before mocking the actual SDK methods
14
- */
15
- asset.initTestEnvironment();
16
- design.initTestEnvironment();
17
- error.initTestEnvironment();
18
- intents.initTestEnvironment();
19
- platform.initTestEnvironment();
20
- user.initTestEnvironment();
21
-
22
- /*
23
- Mock all Canva SDK packages except @canva/error
24
- This allows tests to run without making real API calls to Canva's services
25
- */
26
- jest.mock("@canva/asset");
27
- jest.mock("@canva/design");
28
- jest.mock("@canva/intents");
29
- jest.mock("@canva/platform");
30
- jest.mock("@canva/user");
31
- /*
32
- Important: @canva/error should not be mocked
33
- Use it to simulate API error responses from other mocks by throwing CanvaError instances
34
- This allows testing of error handling scenarios
35
- */