@canva/cli 1.11.0 → 1.12.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 (71) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +2 -0
  3. package/cli.js +593 -580
  4. package/package.json +7 -2
  5. package/templates/base/package.json +6 -6
  6. package/templates/common/jest.config.mjs +1 -1
  7. package/templates/dam/backend/server.ts +8 -0
  8. package/templates/dam/canva-app.json +4 -0
  9. package/templates/dam/package.json +6 -6
  10. package/templates/data_connector/README.md +1 -1
  11. package/templates/data_connector/package.json +6 -6
  12. package/templates/gen_ai/backend/server.ts +17 -0
  13. package/templates/gen_ai/package.json +6 -6
  14. package/templates/gen_ai/src/api/api.ts +4 -0
  15. package/templates/hello_world/package.json +6 -6
  16. package/templates/mls/README.md +81 -0
  17. package/templates/mls/canva-app.json +25 -0
  18. package/templates/mls/declarations/declarations.d.ts +29 -0
  19. package/templates/mls/eslint.config.mjs +14 -0
  20. package/templates/mls/jest.config.mjs +36 -0
  21. package/templates/mls/jest.setup.ts +37 -0
  22. package/templates/mls/package.json +117 -0
  23. package/templates/mls/scripts/copy_env.ts +13 -0
  24. package/templates/mls/scripts/ssl/ssl.ts +131 -0
  25. package/templates/mls/scripts/start/app_runner.ts +223 -0
  26. package/templates/mls/scripts/start/context.ts +171 -0
  27. package/templates/mls/scripts/start/start.ts +46 -0
  28. package/templates/mls/src/__tests__/app.tests.tsx +11 -0
  29. package/templates/mls/src/__tests__/office_selection_page.tests.tsx +72 -0
  30. package/templates/mls/src/__tests__/utils.tsx +19 -0
  31. package/templates/mls/src/adapter.ts +126 -0
  32. package/templates/mls/src/components/agent/agent_card.tsx +57 -0
  33. package/templates/mls/src/components/agent/agent_grid.tsx +37 -0
  34. package/templates/mls/src/components/agent/agent_list.tsx +17 -0
  35. package/templates/mls/src/components/agent/agent_search_filters.tsx +88 -0
  36. package/templates/mls/src/components/breadcrumb/breadcrumb.tsx +40 -0
  37. package/templates/mls/src/components/listing/listing_card.tsx +64 -0
  38. package/templates/mls/src/components/listing/listing_grid.tsx +37 -0
  39. package/templates/mls/src/components/listing/listing_list.tsx +21 -0
  40. package/templates/mls/src/components/listing/listing_search_filters.tsx +145 -0
  41. package/templates/mls/src/components/placeholders/placeholders.tsx +65 -0
  42. package/templates/mls/src/data.ts +359 -0
  43. package/templates/mls/src/index.tsx +4 -0
  44. package/templates/mls/src/intents/design_editor/app.tsx +44 -0
  45. package/templates/mls/src/intents/design_editor/index.tsx +25 -0
  46. package/templates/mls/src/pages/agent_details_page/agent_details_page.tsx +175 -0
  47. package/templates/mls/src/pages/list_page/agent_tab_panel.tsx +126 -0
  48. package/templates/mls/src/pages/list_page/list_page.tsx +67 -0
  49. package/templates/mls/src/pages/list_page/listing_tab_panel.tsx +135 -0
  50. package/templates/mls/src/pages/listing_details_page/listing_details_page.tsx +418 -0
  51. package/templates/mls/src/pages/loading_page/loading_page.tsx +152 -0
  52. package/templates/mls/src/pages/office_selection_page/office_selection_page.tsx +144 -0
  53. package/templates/mls/src/real_estate.type.ts +44 -0
  54. package/templates/mls/src/util/use_add_element.tsx +62 -0
  55. package/templates/mls/src/util/use_drag_element.tsx +68 -0
  56. package/templates/mls/styles/components.css +56 -0
  57. package/templates/mls/tsconfig.json +55 -0
  58. package/templates/mls/webpack.config.ts +254 -0
  59. package/templates/base/backend/routers/oauth.ts +0 -393
  60. package/templates/base/utils/backend/bearer_middleware/bearer_middleware.ts +0 -99
  61. package/templates/base/utils/backend/bearer_middleware/index.ts +0 -1
  62. package/templates/base/utils/backend/bearer_middleware/tests/bearer_middleware.tests.ts +0 -192
  63. package/templates/common/utils/backend/base_backend/create.ts +0 -104
  64. package/templates/gen_ai/backend/database/database.ts +0 -42
  65. package/templates/gen_ai/utils/backend/bearer_middleware/bearer_middleware.ts +0 -99
  66. package/templates/gen_ai/utils/backend/bearer_middleware/index.ts +0 -1
  67. /package/templates/base/{utils/backend → backend}/base_backend/create.ts +0 -0
  68. /package/templates/base/{utils/backend → backend}/jwt_middleware/index.ts +0 -0
  69. /package/templates/base/{utils/backend → backend}/jwt_middleware/jwt_middleware.ts +0 -0
  70. /package/templates/{common → gen_ai}/utils/backend/jwt_middleware/index.ts +0 -0
  71. /package/templates/{common → gen_ai}/utils/backend/jwt_middleware/jwt_middleware.ts +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canva/cli",
3
- "version": "1.11.0",
3
+ "version": "1.12.0",
4
4
  "description": "The official Canva CLI.",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "author": "Canva Pty Ltd.",
@@ -32,6 +32,7 @@
32
32
  ],
33
33
  "dependencies": {
34
34
  "ink": "6.3.1",
35
+ "react": "^19.2.1",
35
36
  "@modelcontextprotocol/sdk": "1.17.4",
36
37
  "react-docgen-typescript": "2.4.0"
37
38
  },
@@ -49,8 +50,12 @@
49
50
  "react-infinite-scroller": {
50
51
  "react": "$react"
51
52
  },
53
+ "ink": {
54
+ "react": "$react"
55
+ },
52
56
  "@inkjs/ui": {
53
- "ink": "$ink"
57
+ "ink": "$ink",
58
+ "react": "$react"
54
59
  },
55
60
  "ink-gradient": {
56
61
  "ink": "$ink"
@@ -7,16 +7,16 @@
7
7
  "author": "Canva Pty Ltd.",
8
8
  "dependencies": {
9
9
  "@canva/app-hooks": "^0.0.0-beta.4",
10
- "@canva/app-i18n-kit": "^1.1.1",
11
- "@canva/app-ui-kit": "^5.2.1",
12
- "@canva/asset": "^2.2.1",
13
- "@canva/design": "^2.7.3",
10
+ "@canva/app-i18n-kit": "^1.2.0",
11
+ "@canva/app-ui-kit": "^5.3.0",
12
+ "@canva/asset": "^2.2.2",
13
+ "@canva/design": "^2.7.5",
14
14
  "@canva/error": "^2.1.0",
15
15
  "@canva/platform": "^2.2.0",
16
16
  "@canva/user": "^2.1.1",
17
17
  "cookie-parser": "1.4.7",
18
- "react": "^19.2.0",
19
- "react-dom": "^19.2.0",
18
+ "react": "^19.2.1",
19
+ "react-dom": "^19.2.1",
20
20
  "react-intl": "^7.1.11"
21
21
  },
22
22
  "devDependencies": {
@@ -11,7 +11,7 @@ export default {
11
11
  testRegex: "(/(tests|__tests__)/.*|(\\.|/)(tests))\\.tsx?$",
12
12
  modulePathIgnorePatterns: ["./internal/", "./node_modules/"],
13
13
  modulePaths: [compilerOptions.baseUrl],
14
- moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths),
14
+ moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths || {}),
15
15
  transform: {
16
16
  ".+\\.(css)$": "jest-css-modules-transform",
17
17
  "^.+\\.tsx?$": [
@@ -1,6 +1,7 @@
1
1
  import cors from "cors";
2
2
  import express from "express";
3
3
  import { createBaseServer } from "../utils/backend/base_backend/create";
4
+ import { createJwtMiddleware } from "../utils/backend/jwt_middleware";
4
5
  import { createDamRouter } from "./routers/dam";
5
6
 
6
7
  async function main() {
@@ -45,6 +46,13 @@ async function main() {
45
46
  */
46
47
  router.use(cors());
47
48
 
49
+ /**
50
+ * Initialize JWT middleware to verify Canva user tokens
51
+ * This middleware validates tokens sent from the frontend and extracts user information
52
+ */
53
+ const jwtMiddleware = createJwtMiddleware(APP_ID);
54
+ router.use(jwtMiddleware);
55
+
48
56
  /**
49
57
  * Add routes for digital asset management.
50
58
  */
@@ -3,6 +3,10 @@
3
3
  "manifest_schema_version": 1,
4
4
  "runtime": {
5
5
  "permissions": [
6
+ {
7
+ "name": "canva:asset:private:write",
8
+ "type": "mandatory"
9
+ },
6
10
  {
7
11
  "name": "canva:design:content:read",
8
12
  "type": "mandatory"
@@ -20,18 +20,18 @@
20
20
  "dependencies": {
21
21
  "@canva/app-hooks": "^0.0.0-beta.4",
22
22
  "@canva/app-components": "^2.1.0",
23
- "@canva/app-i18n-kit": "^1.1.1",
24
- "@canva/app-ui-kit": "^5.2.1",
25
- "@canva/asset": "^2.2.1",
26
- "@canva/design": "^2.7.3",
23
+ "@canva/app-i18n-kit": "^1.2.0",
24
+ "@canva/app-ui-kit": "^5.3.0",
25
+ "@canva/asset": "^2.2.2",
26
+ "@canva/design": "^2.7.5",
27
27
  "@canva/error": "^2.1.0",
28
28
  "@canva/intents": "^2.0.0",
29
29
  "@canva/platform": "^2.2.0",
30
30
  "@canva/user": "^2.1.1",
31
31
  "cookie-parser": "1.4.7",
32
32
  "cors": "2.8.5",
33
- "react": "^19.2.0",
34
- "react-dom": "^19.2.0",
33
+ "react": "^19.2.1",
34
+ "react-dom": "^19.2.1",
35
35
  "react-intl": "^7.1.11"
36
36
  },
37
37
  "devDependencies": {
@@ -44,7 +44,7 @@ To run it and authenticate with the Canva Connect API via OAuth you must first c
44
44
  ### 0. Set up an App
45
45
 
46
46
  - If not already handled by the Canva CLI, you need to create an app via the [Developer Portal](https://www.canva.com/developers/apps).
47
- - On the **Compatibility** page, enable the `Data Connector` intent.
47
+ - On the **Intents** page, enable the `Data Connector` intent.
48
48
 
49
49
  ### 1. Set up a Connect API Integration
50
50
 
@@ -20,16 +20,16 @@
20
20
  },
21
21
  "dependencies": {
22
22
  "@canva/app-hooks": "^0.0.0-beta.4",
23
- "@canva/app-i18n-kit": "^1.1.1",
24
- "@canva/app-ui-kit": "^5.2.1",
25
- "@canva/asset": "^2.2.1",
26
- "@canva/design": "^2.7.3",
23
+ "@canva/app-i18n-kit": "^1.2.0",
24
+ "@canva/app-ui-kit": "^5.3.0",
25
+ "@canva/asset": "^2.2.2",
26
+ "@canva/design": "^2.7.5",
27
27
  "@canva/error": "^2.1.0",
28
28
  "@canva/intents": "^2.0.0",
29
29
  "@canva/platform": "^2.2.0",
30
30
  "@canva/user": "^2.1.1",
31
- "react": "^19.2.0",
32
- "react-dom": "^19.2.0",
31
+ "react": "^19.2.1",
32
+ "react-dom": "^19.2.1",
33
33
  "react-error-boundary": "6.0.0",
34
34
  "react-intl": "^7.1.11",
35
35
  "react-router-dom": "7.8.2"
@@ -1,9 +1,19 @@
1
1
  import cors from "cors";
2
2
  import express from "express";
3
3
  import { createBaseServer } from "../utils/backend/base_backend/create";
4
+ import { createJwtMiddleware } from "../utils/backend/jwt_middleware/index";
4
5
  import { createImageRouter } from "./routers/image";
5
6
 
6
7
  async function main() {
8
+ // TODO: Set the CANVA_APP_ID environment variable in the project's .env file
9
+ const APP_ID = process.env.CANVA_APP_ID;
10
+
11
+ if (!APP_ID) {
12
+ throw new Error(
13
+ `The CANVA_APP_ID environment variable is undefined. Set the variable in the project's .env file.`,
14
+ );
15
+ }
16
+
7
17
  const router = express.Router();
8
18
 
9
19
  /**
@@ -36,6 +46,13 @@ async function main() {
36
46
  */
37
47
  router.use(cors());
38
48
 
49
+ /**
50
+ * Initialize JWT middleware to verify Canva user tokens
51
+ * This middleware validates tokens sent from the frontend and extracts user information
52
+ */
53
+ const jwtMiddleware = createJwtMiddleware(APP_ID);
54
+ router.use(jwtMiddleware);
55
+
39
56
  /**
40
57
  * Add routes for image generation.
41
58
  */
@@ -19,10 +19,10 @@
19
19
  },
20
20
  "dependencies": {
21
21
  "@canva/app-hooks": "^0.0.0-beta.4",
22
- "@canva/app-i18n-kit": "^1.1.1",
23
- "@canva/app-ui-kit": "^5.2.1",
24
- "@canva/asset": "^2.2.1",
25
- "@canva/design": "^2.7.3",
22
+ "@canva/app-i18n-kit": "^1.2.0",
23
+ "@canva/app-ui-kit": "^5.3.0",
24
+ "@canva/asset": "^2.2.2",
25
+ "@canva/design": "^2.7.5",
26
26
  "@canva/error": "^2.1.0",
27
27
  "@canva/intents": "^2.0.0",
28
28
  "@canva/platform": "^2.2.0",
@@ -31,8 +31,8 @@
31
31
  "cors": "2.8.5",
32
32
  "html-react-parser": "5.2.6",
33
33
  "obscenity": "0.4.4",
34
- "react": "^19.2.0",
35
- "react-dom": "^19.2.0",
34
+ "react": "^19.2.1",
35
+ "react-dom": "^19.2.1",
36
36
  "react-error-boundary": "6.0.0",
37
37
  "react-intl": "^7.1.11",
38
38
  "react-router-dom": "7.8.2"
@@ -1,3 +1,4 @@
1
+ import { auth } from "@canva/user";
1
2
  import { POLLING_INTERVAL_IN_SECONDS } from "src/config";
2
3
 
3
4
  /**
@@ -167,8 +168,11 @@ export const purchaseCredits = async (): Promise<RemainingCreditsResult> => {
167
168
  * @returns {Promise<Object>} - A promise that resolves to the response body.
168
169
  */
169
170
  const sendRequest = async <T>(url: URL, options?: RequestInit): Promise<T> => {
171
+ const userToken = await auth.getCanvaUserToken();
172
+
170
173
  const res = await fetch(url, {
171
174
  headers: {
175
+ Authorization: `Bearer ${userToken}`,
172
176
  ...options?.headers,
173
177
  },
174
178
  ...options,
@@ -20,16 +20,16 @@
20
20
  },
21
21
  "dependencies": {
22
22
  "@canva/app-hooks": "^0.0.0-beta.4",
23
- "@canva/app-i18n-kit": "^1.1.1",
24
- "@canva/app-ui-kit": "^5.2.1",
25
- "@canva/asset": "^2.2.1",
26
- "@canva/design": "^2.7.3",
23
+ "@canva/app-i18n-kit": "^1.2.0",
24
+ "@canva/app-ui-kit": "^5.3.0",
25
+ "@canva/asset": "^2.2.2",
26
+ "@canva/design": "^2.7.5",
27
27
  "@canva/error": "^2.1.0",
28
28
  "@canva/intents": "^2.0.0",
29
29
  "@canva/platform": "^2.2.0",
30
30
  "@canva/user": "^2.1.1",
31
- "react": "^19.2.0",
32
- "react-dom": "^19.2.0",
31
+ "react": "^19.2.1",
32
+ "react-dom": "^19.2.1",
33
33
  "react-intl": "^7.1.11"
34
34
  },
35
35
  "devDependencies": {
@@ -0,0 +1,81 @@
1
+ # Real Estate MLS App
2
+
3
+ ## Running this app
4
+
5
+ ### Step 1: Start the local development server
6
+
7
+ To start the development server, run the following command:
8
+
9
+ ```bash
10
+ npm install
11
+ npm start
12
+ ```
13
+
14
+ The server becomes available at <http://localhost:8080>.
15
+
16
+ The app's source code is in the `src/app.tsx` file.
17
+
18
+ ### Step 2: Preview the app
19
+
20
+ 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.
21
+
22
+ To preview an app:
23
+
24
+ 1. Create an app via the [Developer Portal](https://www.canva.com/developers/apps).
25
+ 2. Select **App source > Development URL**.
26
+ 3. In the **Development URL** field, enter the URL of the development server.
27
+ 4. Click **Preview**. This opens the Canva editor (and the app) in a new tab.
28
+ 5. Click **Open**. (This screen only appears when using an app for the first time.)
29
+
30
+ The app will appear in the side panel.
31
+
32
+ <details>
33
+ <summary>Previewing apps in Safari</summary>
34
+
35
+ 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.
36
+
37
+ **Why Safari requires the development server to be HTTPS-enabled?**
38
+
39
+ 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.
40
+
41
+ To learn more, see [Loading mixed-content resources](https://developer.mozilla.org/en-US/docs/Web/Security/Mixed_content#loading_mixed-content_resources).
42
+
43
+ To preview apps in Safari:
44
+
45
+ 1. Start the development server with HTTPS enabled:
46
+
47
+ ```bash
48
+ npm start --use-https
49
+ ```
50
+
51
+ 2. Navigate to <https://localhost:8080>.
52
+ 3. Bypass the invalid security certificate warning:
53
+ 1. Click **Show details**.
54
+ 2. Click **Visit website**.
55
+ 4. In the Developer Portal, set the app's **Development URL** to <https://localhost:8080>.
56
+ 5. Click preview (or refresh your app if it's already open).
57
+
58
+ 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.
59
+
60
+ </details>
61
+
62
+ ### Step 3 (Optional): Enable Hot Module Replacement
63
+
64
+ 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.
65
+
66
+ **Note:** HMR does **not** work while running the development server in a Docker container.
67
+
68
+ To enable HMR:
69
+
70
+ 1. Navigate to an app via the [Your apps](https://www.canva.com/developers/apps).
71
+ 1. Select **Security** -> **Credentials** -> **.env file**.
72
+ 1. Copy the `.env` file contents.
73
+ 1. Paste the contents into the starter kit's `.env` file. For example:
74
+
75
+ ```bash
76
+ CANVA_APP_ORIGIN=https://app-aabbccddeeff.canva-apps.com
77
+ CANVA_HMR_ENABLED=true
78
+ ```
79
+
80
+ 1. Restart the local development server.
81
+ 1. Reload the app manually to ensure that HMR takes effect.
@@ -0,0 +1,25 @@
1
+ {
2
+ "$schema": "https://www.canva.dev/schemas/app/v1/manifest-schema.json",
3
+ "manifest_schema_version": 1,
4
+ "runtime": {
5
+ "permissions": [
6
+ {
7
+ "name": "canva:design:content:read",
8
+ "type": "mandatory"
9
+ },
10
+ {
11
+ "name": "canva:design:content:write",
12
+ "type": "mandatory"
13
+ },
14
+ {
15
+ "name": "canva:asset:private:write",
16
+ "type": "mandatory"
17
+ }
18
+ ]
19
+ },
20
+ "intent": {
21
+ "design_editor": {
22
+ "enrolled": true
23
+ }
24
+ }
25
+ }
@@ -0,0 +1,29 @@
1
+ declare module "*.css" {
2
+ const styles: { [className: string]: string };
3
+ export = styles;
4
+ }
5
+
6
+ declare module "*.jpg" {
7
+ const content: string;
8
+ export default content;
9
+ }
10
+
11
+ declare module "*.jpeg" {
12
+ const content: string;
13
+ export default content;
14
+ }
15
+
16
+ declare module "*.png" {
17
+ const content: string;
18
+ export default content;
19
+ }
20
+
21
+ declare module "*.svg" {
22
+ const content: React.FunctionComponent<{
23
+ size?: "tiny" | "small" | "medium" | "large";
24
+ className?: string;
25
+ }>;
26
+ export default content;
27
+ }
28
+
29
+ declare const BACKEND_HOST: string;
@@ -0,0 +1,14 @@
1
+ import canvaPlugin from "@canva/app-eslint-plugin";
2
+
3
+ export default [
4
+ {
5
+ ignores: [
6
+ "**/node_modules/",
7
+ "**/dist",
8
+ "**/*.d.ts",
9
+ "**/*.d.tsx",
10
+ "**/*.config.*",
11
+ ],
12
+ },
13
+ ...canvaPlugin.configs.apps,
14
+ ];
@@ -0,0 +1,36 @@
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
+ setupFilesAfterEnv: ["@testing-library/jest-dom"],
36
+ };
@@ -0,0 +1,37 @@
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 platform from "@canva/platform/test";
8
+ import * as user from "@canva/user/test";
9
+ import { TextEncoder } from "util";
10
+
11
+ // jsdom doesn't provide TextEncoder by default, so we polyfill it from Node's util module
12
+ global.TextEncoder = TextEncoder as unknown as typeof global.TextEncoder;
13
+
14
+ /*
15
+ Initialize test environments for each Canva SDK package
16
+ This sets up the necessary test infrastructure before mocking the actual SDK methods
17
+ */
18
+ asset.initTestEnvironment();
19
+ design.initTestEnvironment();
20
+ error.initTestEnvironment();
21
+ platform.initTestEnvironment();
22
+ user.initTestEnvironment();
23
+
24
+ /*
25
+ Mock all Canva SDK packages except @canva/error
26
+ This allows tests to run without making real API calls to Canva's services
27
+ */
28
+ jest.mock("@canva/asset");
29
+ jest.mock("@canva/design");
30
+ jest.mock("@canva/platform");
31
+ jest.mock("@canva/user");
32
+
33
+ /*
34
+ Important: @canva/error should not be mocked
35
+ Use it to simulate API error responses from other mocks by throwing CanvaError instances
36
+ This allows testing of error handling scenarios
37
+ */
@@ -0,0 +1,117 @@
1
+ {
2
+ "private": true,
3
+ "name": "real_estate_mls",
4
+ "description": "A Real Estate MLS reference app built with the Canva Apps SDK.",
5
+ "license": "SEE LICENSE IN LICENSE.md",
6
+ "author": "Canva Pty Ltd.",
7
+ "scripts": {
8
+ "extract": "formatjs extract \"src/**/*.{ts,tsx}\" --out-file dist/messages_en.json",
9
+ "build": "webpack --config webpack.config.ts --mode production && npm run extract",
10
+ "format": "prettier '**/*.{css,ts,tsx}' --no-config --write",
11
+ "format:check": "prettier '**/*.{css,ts,tsx}' --no-config --check --ignore-path",
12
+ "format:file": "prettier $1 --no-config --write",
13
+ "lint": "eslint .",
14
+ "lint:fix": "eslint . --fix",
15
+ "lint:types": "tsc",
16
+ "start": "ts-node ./scripts/start/start.ts",
17
+ "start:preview": "npm run start -- --preview",
18
+ "test": "jest --no-cache",
19
+ "test:watch": "jest --watchAll",
20
+ "test:update": "npm run test -- -u",
21
+ "postinstall": "ts-node ./scripts/copy_env.ts"
22
+ },
23
+ "dependencies": {
24
+ "@canva/app-hooks": "^0.0.0-beta.4",
25
+ "@canva/app-i18n-kit": "^1.2.0",
26
+ "@canva/app-ui-kit": "^5.3.0",
27
+ "@canva/asset": "^2.2.2",
28
+ "@canva/design": "^2.7.5",
29
+ "@canva/error": "^2.1.0",
30
+ "@canva/intents": "^2.0.0",
31
+ "@canva/platform": "^2.2.0",
32
+ "@canva/user": "^2.1.1",
33
+ "@tanstack/react-query": "5.87.1",
34
+ "@types/react-infinite-scroller": "1.2.5",
35
+ "clsx": "2.1.1",
36
+ "loglevel": "1.9.2",
37
+ "react": "^19.2.1",
38
+ "react-dom": "^19.2.1",
39
+ "react-hook-form": "7.66.0",
40
+ "react-infinite-scroller": "1.2.6",
41
+ "react-intl": "^7.1.11",
42
+ "react-router-dom": "7.8.2"
43
+ },
44
+ "devDependencies": {
45
+ "@canva/app-eslint-plugin": "^1.0.0-beta.7",
46
+ "@canva/cli": ">= 0.0.1-beta.13",
47
+ "@formatjs/cli": "6.7.2",
48
+ "@formatjs/ts-transformer": "3.14.0",
49
+ "@ngrok/ngrok": "1.5.2",
50
+ "@pmmmwh/react-refresh-webpack-plugin": "0.6.1",
51
+ "@svgr/webpack": "8.1.0",
52
+ "@testing-library/jest-dom": "6.8.0",
53
+ "@testing-library/react": "16.3.0",
54
+ "@testing-library/user-event": "14.6.1",
55
+ "@types/express": "4.17.21",
56
+ "@types/express-serve-static-core": "5.0.7",
57
+ "@types/jest": "29.5.14",
58
+ "@types/jsonwebtoken": "9.0.10",
59
+ "@types/node": "20.19.2",
60
+ "@types/node-fetch": "2.6.13",
61
+ "@types/node-forge": "1.3.14",
62
+ "@types/nodemon": "1.19.6",
63
+ "@types/react": "19.2.2",
64
+ "@types/react-dom": "19.2.1",
65
+ "@types/webpack-env": "1.18.8",
66
+ "chalk": "4.1.2",
67
+ "cli-table3": "0.6.5",
68
+ "css-loader": "7.1.2",
69
+ "css-modules-typescript-loader": "4.0.1",
70
+ "cssnano": "7.1.1",
71
+ "debug": "4.4.1",
72
+ "dotenv": "16.6.0",
73
+ "express": "4.22.1",
74
+ "express-basic-auth": "1.2.1",
75
+ "jest": "29.7.0",
76
+ "jest-css-modules-transform": "4.4.2",
77
+ "jest-environment-jsdom": "29.7.0",
78
+ "jsonwebtoken": "9.0.2",
79
+ "jwks-rsa": "3.2.0",
80
+ "mini-css-extract-plugin": "2.9.4",
81
+ "node-fetch": "3.3.2",
82
+ "node-forge": "1.3.2",
83
+ "nodemon": "3.0.1",
84
+ "open": "8.4.2",
85
+ "postcss-loader": "8.1.1",
86
+ "prettier": "3.6.2",
87
+ "react-refresh": "0.17.0",
88
+ "style-loader": "4.0.0",
89
+ "terser-webpack-plugin": "5.3.14",
90
+ "tree-kill": "1.2.2",
91
+ "ts-jest": "29.4.1",
92
+ "ts-loader": "9.5.4",
93
+ "ts-node": "10.9.2",
94
+ "typescript": "5.9.2",
95
+ "url-loader": "4.1.1",
96
+ "webpack": "5.99.9",
97
+ "webpack-cli": "6.0.1",
98
+ "webpack-dev-server": "5.2.2",
99
+ "yargs": "17.7.2"
100
+ },
101
+ "overrides": {
102
+ "react-infinite-scroller": {
103
+ "react": "$react"
104
+ }
105
+ },
106
+ "keywords": [
107
+ "canva-apps-sdk"
108
+ ],
109
+ "engines": {
110
+ "node": "^18 || ^20.10.0",
111
+ "npm": "^9 || ^10"
112
+ },
113
+ "canvaCliMetadata": {
114
+ "name": "@canva/cli",
115
+ "version": "1.1.0"
116
+ }
117
+ }
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env node
2
+ /* eslint-disable no-console */
3
+ import fs from "fs";
4
+ import path from "path";
5
+
6
+ const envPath = path.resolve(__dirname, "..", ".env");
7
+ const templatePath = path.resolve(__dirname, "..", ".env.template");
8
+
9
+ if (!fs.existsSync(templatePath)) {
10
+ console.warn(".env.template file does not exist, skipping copy of .env file");
11
+ } else if (!fs.existsSync(envPath)) {
12
+ fs.copyFileSync(templatePath, envPath);
13
+ }