@canva/cli 1.10.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 (126) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/README.md +2 -0
  3. package/cli.js +596 -574
  4. package/lib/cjs/index.cjs +2 -2
  5. package/lib/esm/index.mjs +2 -2
  6. package/lib/index.d.ts +2 -0
  7. package/package.json +7 -2
  8. package/templates/base/package.json +9 -8
  9. package/templates/base/styles/components.css +18 -0
  10. package/templates/common/.env.template +1 -1
  11. package/templates/common/jest.config.mjs +1 -1
  12. package/templates/dam/backend/server.ts +8 -0
  13. package/templates/dam/canva-app.json +9 -0
  14. package/templates/dam/package.json +10 -8
  15. package/templates/dam/src/index.tsx +3 -21
  16. package/templates/dam/src/intents/design_editor/index.tsx +25 -0
  17. package/templates/data_connector/README.md +1 -1
  18. package/templates/data_connector/package.json +9 -8
  19. package/templates/data_connector/src/api/data_sources/designs.tsx +1 -1
  20. package/templates/data_connector/src/api/data_sources/templates.tsx +1 -1
  21. package/templates/data_connector/src/components/header.tsx +1 -1
  22. package/templates/data_connector/src/index.tsx +2 -66
  23. package/templates/data_connector/src/{app.tsx → intents/data_connector/app.tsx} +3 -3
  24. package/templates/data_connector/src/{entrypoint.tsx → intents/data_connector/entrypoint.tsx} +5 -5
  25. package/templates/data_connector/src/{home.tsx → intents/data_connector/home.tsx} +1 -1
  26. package/templates/data_connector/src/intents/data_connector/index.tsx +56 -0
  27. package/templates/data_connector/src/pages/error.tsx +1 -1
  28. package/templates/data_connector/src/pages/login.tsx +1 -1
  29. package/templates/data_connector/src/routes/protected_route.tsx +1 -1
  30. package/templates/data_connector/src/routes/routes.tsx +3 -3
  31. package/templates/data_connector/styles/components.css +18 -0
  32. package/templates/gen_ai/backend/server.ts +17 -0
  33. package/templates/gen_ai/canva-app.json +5 -0
  34. package/templates/gen_ai/package.json +10 -8
  35. package/templates/gen_ai/src/api/api.ts +4 -0
  36. package/templates/gen_ai/src/components/footer.tsx +1 -1
  37. package/templates/gen_ai/src/components/loading_results.tsx +1 -1
  38. package/templates/gen_ai/src/components/prompt_input.tsx +1 -1
  39. package/templates/gen_ai/src/index.tsx +3 -14
  40. package/templates/gen_ai/src/{app.tsx → intents/design_editor/app.tsx} +3 -3
  41. package/templates/gen_ai/src/{home.tsx → intents/design_editor/home.tsx} +1 -1
  42. package/templates/gen_ai/src/intents/design_editor/index.tsx +17 -0
  43. package/templates/gen_ai/src/pages/error.tsx +1 -1
  44. package/templates/gen_ai/src/routes/routes.tsx +2 -2
  45. package/templates/gen_ai/styles/components.css +18 -0
  46. package/templates/hello_world/canva-app.json +5 -0
  47. package/templates/hello_world/package.json +10 -8
  48. package/templates/hello_world/src/index.tsx +3 -21
  49. package/templates/hello_world/src/{app.tsx → intents/design_editor/app.tsx} +26 -3
  50. package/templates/hello_world/src/intents/design_editor/index.tsx +25 -0
  51. package/templates/hello_world/src/{tests → intents/design_editor/tests}/app.tests.tsx +19 -13
  52. package/templates/hello_world/styles/components.css +18 -0
  53. package/templates/mls/README.md +81 -0
  54. package/templates/mls/canva-app.json +25 -0
  55. package/templates/mls/declarations/declarations.d.ts +29 -0
  56. package/templates/mls/eslint.config.mjs +14 -0
  57. package/templates/mls/jest.config.mjs +36 -0
  58. package/templates/mls/jest.setup.ts +37 -0
  59. package/templates/mls/package.json +117 -0
  60. package/templates/mls/scripts/copy_env.ts +13 -0
  61. package/templates/mls/scripts/ssl/ssl.ts +131 -0
  62. package/templates/mls/scripts/start/app_runner.ts +223 -0
  63. package/templates/mls/scripts/start/context.ts +171 -0
  64. package/templates/mls/scripts/start/start.ts +46 -0
  65. package/templates/mls/src/__tests__/app.tests.tsx +11 -0
  66. package/templates/mls/src/__tests__/office_selection_page.tests.tsx +72 -0
  67. package/templates/mls/src/__tests__/utils.tsx +19 -0
  68. package/templates/mls/src/adapter.ts +126 -0
  69. package/templates/mls/src/components/agent/agent_card.tsx +57 -0
  70. package/templates/mls/src/components/agent/agent_grid.tsx +37 -0
  71. package/templates/mls/src/components/agent/agent_list.tsx +17 -0
  72. package/templates/mls/src/components/agent/agent_search_filters.tsx +88 -0
  73. package/templates/mls/src/components/breadcrumb/breadcrumb.tsx +40 -0
  74. package/templates/mls/src/components/listing/listing_card.tsx +64 -0
  75. package/templates/mls/src/components/listing/listing_grid.tsx +37 -0
  76. package/templates/mls/src/components/listing/listing_list.tsx +21 -0
  77. package/templates/mls/src/components/listing/listing_search_filters.tsx +145 -0
  78. package/templates/mls/src/components/placeholders/placeholders.tsx +65 -0
  79. package/templates/mls/src/data.ts +359 -0
  80. package/templates/mls/src/index.tsx +4 -0
  81. package/templates/mls/src/intents/design_editor/app.tsx +44 -0
  82. package/templates/mls/src/intents/design_editor/index.tsx +25 -0
  83. package/templates/mls/src/pages/agent_details_page/agent_details_page.tsx +175 -0
  84. package/templates/mls/src/pages/list_page/agent_tab_panel.tsx +126 -0
  85. package/templates/mls/src/pages/list_page/list_page.tsx +67 -0
  86. package/templates/mls/src/pages/list_page/listing_tab_panel.tsx +135 -0
  87. package/templates/mls/src/pages/listing_details_page/listing_details_page.tsx +418 -0
  88. package/templates/mls/src/pages/loading_page/loading_page.tsx +152 -0
  89. package/templates/mls/src/pages/office_selection_page/office_selection_page.tsx +144 -0
  90. package/templates/mls/src/real_estate.type.ts +44 -0
  91. package/templates/mls/src/util/use_add_element.tsx +62 -0
  92. package/templates/mls/src/util/use_drag_element.tsx +68 -0
  93. package/templates/mls/styles/components.css +56 -0
  94. package/templates/mls/tsconfig.json +55 -0
  95. package/templates/mls/webpack.config.ts +254 -0
  96. package/templates/optional/AGENTS.md +80 -2
  97. package/templates/optional/CLAUDE.md +80 -2
  98. package/templates/base/backend/routers/oauth.ts +0 -393
  99. package/templates/base/utils/backend/bearer_middleware/bearer_middleware.ts +0 -99
  100. package/templates/base/utils/backend/bearer_middleware/index.ts +0 -1
  101. package/templates/base/utils/backend/bearer_middleware/tests/bearer_middleware.tests.ts +0 -192
  102. package/templates/base/utils/use_add_element.ts +0 -58
  103. package/templates/base/utils/use_feature_support.ts +0 -28
  104. package/templates/common/utils/backend/base_backend/create.ts +0 -104
  105. package/templates/common/utils/table_wrapper.ts +0 -520
  106. package/templates/common/utils/use_add_element.ts +0 -58
  107. package/templates/common/utils/use_feature_support.ts +0 -28
  108. package/templates/common/utils/use_overlay_hook.ts +0 -76
  109. package/templates/common/utils/use_selection_hook.ts +0 -37
  110. package/templates/gen_ai/backend/database/database.ts +0 -42
  111. package/templates/gen_ai/utils/backend/bearer_middleware/bearer_middleware.ts +0 -99
  112. package/templates/gen_ai/utils/backend/bearer_middleware/index.ts +0 -1
  113. package/templates/hello_world/utils/use_add_element.ts +0 -58
  114. package/templates/hello_world/utils/use_feature_support.ts +0 -28
  115. /package/templates/base/{utils/backend → backend}/base_backend/create.ts +0 -0
  116. /package/templates/base/{utils/backend → backend}/jwt_middleware/index.ts +0 -0
  117. /package/templates/base/{utils/backend → backend}/jwt_middleware/jwt_middleware.ts +0 -0
  118. /package/templates/dam/src/{adapter.ts → intents/design_editor/adapter.ts} +0 -0
  119. /package/templates/dam/src/{app.tsx → intents/design_editor/app.tsx} +0 -0
  120. /package/templates/dam/src/{config.ts → intents/design_editor/config.ts} +0 -0
  121. /package/templates/dam/src/{index.css → intents/design_editor/index.css} +0 -0
  122. /package/templates/data_connector/src/{paths.ts → routes/paths.ts} +0 -0
  123. /package/templates/gen_ai/src/{paths.ts → routes/paths.ts} +0 -0
  124. /package/templates/{common → gen_ai}/utils/backend/jwt_middleware/index.ts +0 -0
  125. /package/templates/{common → gen_ai}/utils/backend/jwt_middleware/jwt_middleware.ts +0 -0
  126. /package/templates/hello_world/src/{tests → intents/design_editor/tests}/__snapshots__/app.tests.tsx.snap +0 -0
@@ -19,15 +19,17 @@
19
19
  "postinstall": "ts-node ./scripts/copy_env.ts"
20
20
  },
21
21
  "dependencies": {
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-hooks": "^0.0.0-beta.4",
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",
26
27
  "@canva/error": "^2.1.0",
28
+ "@canva/intents": "^2.0.0",
27
29
  "@canva/platform": "^2.2.0",
28
30
  "@canva/user": "^2.1.1",
29
- "react": "^19.2.0",
30
- "react-dom": "^19.2.0",
31
+ "react": "^19.2.1",
32
+ "react-dom": "^19.2.1",
31
33
  "react-intl": "^7.1.11"
32
34
  },
33
35
  "devDependencies": {
@@ -57,7 +59,7 @@
57
59
  "cssnano": "7.1.1",
58
60
  "debug": "4.4.1",
59
61
  "dotenv": "16.6.0",
60
- "express": "4.21.2",
62
+ "express": "4.22.1",
61
63
  "express-basic-auth": "1.2.1",
62
64
  "jest": "29.7.0",
63
65
  "jest-css-modules-transform": "4.4.2",
@@ -66,7 +68,7 @@
66
68
  "jwks-rsa": "3.2.0",
67
69
  "mini-css-extract-plugin": "2.9.4",
68
70
  "node-fetch": "3.3.2",
69
- "node-forge": "1.3.1",
71
+ "node-forge": "1.3.2",
70
72
  "nodemon": "3.0.1",
71
73
  "open": "8.4.2",
72
74
  "postcss-loader": "8.1.1",
@@ -1,22 +1,4 @@
1
- import { AppI18nProvider } from "@canva/app-i18n-kit";
2
- import { AppUiProvider } from "@canva/app-ui-kit";
3
- import { createRoot } from "react-dom/client";
4
- import { App } from "./app";
5
- import "@canva/app-ui-kit/styles.css";
1
+ import { prepareDesignEditor } from "@canva/intents/design";
2
+ import designEditor from "./intents/design_editor";
6
3
 
7
- const root = createRoot(document.getElementById("root") as Element);
8
- function render() {
9
- root.render(
10
- <AppI18nProvider>
11
- <AppUiProvider>
12
- <App />
13
- </AppUiProvider>
14
- </AppI18nProvider>,
15
- );
16
- }
17
-
18
- render();
19
-
20
- if (module.hot) {
21
- module.hot.accept("./app", render);
22
- }
4
+ prepareDesignEditor(designEditor);
@@ -1,15 +1,23 @@
1
+ import { useFeatureSupport } from "@canva/app-hooks";
1
2
  import { Button, Rows, Text } from "@canva/app-ui-kit";
3
+ import { addElementAtCursor, addElementAtPoint } from "@canva/design";
2
4
  import { requestOpenExternalUrl } from "@canva/platform";
3
5
  import { FormattedMessage, useIntl } from "react-intl";
4
- import { useAddElement } from "utils/use_add_element";
5
6
  import * as styles from "styles/components.css";
6
7
 
7
8
  export const DOCS_URL = "https://www.canva.dev/docs/apps/";
8
9
 
9
10
  export const App = () => {
10
- const addElement = useAddElement();
11
+ const isSupported = useFeatureSupport();
12
+ const addElement = [addElementAtPoint, addElementAtCursor].find((fn) =>
13
+ isSupported(fn),
14
+ );
11
15
 
12
16
  const onClick = () => {
17
+ if (!addElement) {
18
+ return;
19
+ }
20
+
13
21
  addElement({
14
22
  type: "text",
15
23
  children: ["Hello world!"],
@@ -43,7 +51,22 @@ export const App = () => {
43
51
  }}
44
52
  />
45
53
  </Text>
46
- <Button variant="primary" onClick={onClick} stretch>
54
+ <Button
55
+ variant="primary"
56
+ onClick={onClick}
57
+ disabled={!addElement}
58
+ tooltipLabel={
59
+ !addElement
60
+ ? intl.formatMessage({
61
+ defaultMessage:
62
+ "This feature is not supported in the current page",
63
+ description:
64
+ "Tooltip label for when a feature is not supported in the current design",
65
+ })
66
+ : undefined
67
+ }
68
+ stretch
69
+ >
47
70
  {intl.formatMessage({
48
71
  defaultMessage: "Do something cool",
49
72
  description:
@@ -0,0 +1,25 @@
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,11 +1,13 @@
1
1
  /* eslint-disable formatjs/no-literal-string-in-jsx */
2
+ import { useFeatureSupport } from "@canva/app-hooks";
2
3
  import { TestAppI18nProvider } from "@canva/app-i18n-kit";
3
4
  import { TestAppUiProvider } from "@canva/app-ui-kit";
5
+ import { addElementAtCursor, addElementAtPoint } from "@canva/design";
6
+ import type { Feature } from "@canva/platform";
4
7
  import { requestOpenExternalUrl } from "@canva/platform";
5
8
  import { fireEvent, render } from "@testing-library/react";
6
9
  import type { RenderResult } from "@testing-library/react";
7
10
  import type { ReactNode } from "react";
8
- import { useAddElement } from "utils/use_add_element";
9
11
  import { App, DOCS_URL } from "../app";
10
12
 
11
13
  function renderInTestProvider(node: ReactNode): RenderResult {
@@ -17,33 +19,35 @@ function renderInTestProvider(node: ReactNode): RenderResult {
17
19
  );
18
20
  }
19
21
 
20
- jest.mock("utils/use_add_element");
22
+ jest.mock("@canva/app-hooks");
21
23
 
22
24
  // This test demonstrates how to test code that uses functions from the Canva Apps SDK
23
25
  // For more information on testing with the Canva Apps SDK, see https://www.canva.dev/docs/apps/testing/
24
26
  describe("Hello World Tests", () => {
25
- // Mocking the useAddElement hook
26
- const mockAddElement = jest.fn();
27
- const mockAddUseElement = jest.mocked(useAddElement);
27
+ const mockIsSupported = jest.fn();
28
+ const mockUseFeatureSupport = jest.mocked(useFeatureSupport);
28
29
  const mockRequestOpenExternalUrl = jest.mocked(requestOpenExternalUrl);
29
30
 
30
31
  beforeEach(() => {
31
32
  jest.resetAllMocks();
32
- mockAddUseElement.mockReturnValue(mockAddElement);
33
+ mockIsSupported.mockImplementation(
34
+ (fn: Feature) => fn === addElementAtPoint,
35
+ );
36
+ mockUseFeatureSupport.mockReturnValue(mockIsSupported);
33
37
  mockRequestOpenExternalUrl.mockResolvedValue({ status: "completed" });
34
38
  });
35
39
 
36
- // this test uses a mock in place of the useAddElement hook
40
+ // this test uses a mock in place of the useFeatureSupport hook
37
41
  it("should add a text element when the button is clicked", () => {
38
42
  // assert that the mocks are in the expected clean state
39
- expect(mockAddUseElement).not.toHaveBeenCalled();
40
- expect(mockAddElement).not.toHaveBeenCalled();
43
+ expect(mockUseFeatureSupport).not.toHaveBeenCalled();
44
+ expect(addElementAtPoint).not.toHaveBeenCalled();
41
45
 
42
46
  const result = renderInTestProvider(<App />);
43
47
 
44
48
  // the hook should have been called in the render process but not the callback
45
- expect(mockAddUseElement).toHaveBeenCalled();
46
- expect(mockAddElement).not.toHaveBeenCalled();
49
+ expect(mockUseFeatureSupport).toHaveBeenCalled();
50
+ expect(addElementAtPoint).not.toHaveBeenCalled();
47
51
 
48
52
  // get a reference to the do something cool button element
49
53
  const doSomethingCoolBtn = result.getByRole("button", {
@@ -53,8 +57,10 @@ describe("Hello World Tests", () => {
53
57
  // programmatically simulate clicking the button
54
58
  fireEvent.click(doSomethingCoolBtn);
55
59
 
56
- // we expect that addElement has been called by the button's click handler
57
- expect(mockAddElement).toHaveBeenCalled();
60
+ // we expect that addElementAtPoint has been called by the button's click handler
61
+ expect(mockIsSupported).toHaveBeenCalledWith(addElementAtPoint);
62
+ expect(mockIsSupported).not.toHaveBeenCalledWith(addElementAtCursor);
63
+ expect(addElementAtPoint).toHaveBeenCalled();
58
64
  });
59
65
 
60
66
  // this test uses a mock in place of the @canva/platform requestOpenExternalUrl function
@@ -36,3 +36,21 @@
36
36
  .scrollContainer:focus-within::-webkit-scrollbar-thumb {
37
37
  visibility: visible;
38
38
  }
39
+
40
+ /* Main container for the content publisher preview UI */
41
+ .previewContainer {
42
+ display: flex;
43
+ align-items: center;
44
+ justify-content: center;
45
+ flex-direction: column;
46
+ width: 100%;
47
+ height: 100%;
48
+ }
49
+
50
+ /* Wrapper for the content publisher post preview */
51
+ .previewWrapper {
52
+ display: flex;
53
+ align-items: center;
54
+ justify-content: center;
55
+ width: calc(400px + 32px + 2px); /* Image width + padding + border */
56
+ }
@@ -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
+ }