@osdk/create-app 0.16.2 → 0.17.0-beta.1

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 (143) hide show
  1. package/CHANGELOG.md +12 -9
  2. package/bin/createOsdkApp.mjs +1 -1
  3. package/build/{js/index.browser.mjs → browser/index.js} +9 -3
  4. package/build/browser/index.js.map +1 -0
  5. package/build/{js → cjs}/index.cjs +8 -2
  6. package/build/cjs/index.cjs.map +1 -0
  7. package/build/{types → esm}/cli.d.ts.map +1 -1
  8. package/build/esm/consola.d.ts +3 -0
  9. package/build/esm/consola.d.ts.map +1 -0
  10. package/build/{types → esm}/highlight.d.ts.map +1 -1
  11. package/build/{js/index.mjs → esm/index.js} +9 -3
  12. package/build/esm/index.js.map +1 -0
  13. package/build/{types → esm}/run.d.ts.map +1 -1
  14. package/build/{types → esm}/templates.d.ts.map +1 -1
  15. package/package.json +13 -13
  16. package/templates/template-next-static-export/package.json.hbs +1 -1
  17. package/templates/template-next-static-export/src/app/login/page.tsx +2 -0
  18. package/templates/template-react/package.json.hbs +6 -6
  19. package/templates/template-react/src/Login.tsx +2 -0
  20. package/templates/template-tutorial-todo-aip-app/.eslintrc.cjs +18 -0
  21. package/templates/template-tutorial-todo-aip-app/README.md.hbs +34 -0
  22. package/templates/template-tutorial-todo-aip-app/index.html +15 -0
  23. package/templates/template-tutorial-todo-aip-app/package.json.hbs +31 -0
  24. package/templates/template-tutorial-todo-aip-app/public/aip-icon.svg +3 -0
  25. package/templates/template-tutorial-todo-aip-app/public/todo-aip-app.svg +19 -0
  26. package/templates/template-tutorial-todo-aip-app/src/AuthCallback.tsx +24 -0
  27. package/templates/template-tutorial-todo-aip-app/src/AuthenticatedRoute.tsx +33 -0
  28. package/templates/template-tutorial-todo-aip-app/src/CreateProjectButton.module.css +3 -0
  29. package/templates/template-tutorial-todo-aip-app/src/CreateProjectButton.tsx +36 -0
  30. package/templates/template-tutorial-todo-aip-app/src/CreateProjectDialog.module.css +15 -0
  31. package/templates/template-tutorial-todo-aip-app/src/CreateProjectDialog.tsx +74 -0
  32. package/templates/template-tutorial-todo-aip-app/src/CreateTaskButton.module.css +3 -0
  33. package/templates/template-tutorial-todo-aip-app/src/CreateTaskButton.tsx +38 -0
  34. package/templates/template-tutorial-todo-aip-app/src/CreateTaskDialog.module.css +66 -0
  35. package/templates/template-tutorial-todo-aip-app/src/CreateTaskDialog.tsx +140 -0
  36. package/templates/template-tutorial-todo-aip-app/src/DeleteProjectButton.module.css +3 -0
  37. package/templates/template-tutorial-todo-aip-app/src/DeleteProjectButton.tsx +37 -0
  38. package/templates/template-tutorial-todo-aip-app/src/DeleteProjectDialog.module.css +3 -0
  39. package/templates/template-tutorial-todo-aip-app/src/DeleteProjectDialog.tsx +57 -0
  40. package/templates/template-tutorial-todo-aip-app/src/Dialog.module.css +11 -0
  41. package/templates/template-tutorial-todo-aip-app/src/Dialog.tsx +19 -0
  42. package/templates/template-tutorial-todo-aip-app/src/Home.module.css +80 -0
  43. package/templates/template-tutorial-todo-aip-app/src/Home.tsx +133 -0
  44. package/templates/template-tutorial-todo-aip-app/src/Layout.module.css +16 -0
  45. package/templates/template-tutorial-todo-aip-app/src/Layout.tsx +23 -0
  46. package/templates/template-tutorial-todo-aip-app/src/Login.module.css +5 -0
  47. package/templates/template-tutorial-todo-aip-app/src/Login.tsx +44 -0
  48. package/templates/template-tutorial-todo-aip-app/src/ProjectSelect.tsx +40 -0
  49. package/templates/template-tutorial-todo-aip-app/src/TaskList.module.css +7 -0
  50. package/templates/template-tutorial-todo-aip-app/src/TaskList.tsx +44 -0
  51. package/templates/template-tutorial-todo-aip-app/src/TaskListItem.module.css +35 -0
  52. package/templates/template-tutorial-todo-aip-app/src/TaskListItem.tsx +59 -0
  53. package/templates/template-tutorial-todo-aip-app/src/client.ts.hbs +31 -0
  54. package/templates/template-tutorial-todo-aip-app/src/index.css +75 -0
  55. package/templates/template-tutorial-todo-aip-app/src/main.tsx +36 -0
  56. package/templates/template-tutorial-todo-aip-app/src/mocks.ts +187 -0
  57. package/templates/template-tutorial-todo-aip-app/src/useProjectTasks.ts +75 -0
  58. package/templates/template-tutorial-todo-aip-app/src/useProjects.ts +58 -0
  59. package/templates/template-tutorial-todo-aip-app/src/vite-env.d.ts +1 -0
  60. package/templates/template-tutorial-todo-aip-app/tsconfig.json +25 -0
  61. package/templates/template-tutorial-todo-aip-app/tsconfig.node.json +10 -0
  62. package/templates/template-tutorial-todo-aip-app/vite.config.ts.hbs +19 -0
  63. package/templates/template-tutorial-todo-app/README.md.hbs +1 -1
  64. package/templates/template-tutorial-todo-app/package.json.hbs +6 -6
  65. package/templates/template-tutorial-todo-app/src/CreateProjectDialog.tsx +3 -3
  66. package/templates/template-tutorial-todo-app/src/CreateTaskDialog.tsx +3 -3
  67. package/templates/template-tutorial-todo-app/src/DeleteProjectDialog.tsx +3 -3
  68. package/templates/template-tutorial-todo-app/src/Dialog.module.css +5 -0
  69. package/templates/template-tutorial-todo-app/src/Dialog.tsx +1 -1
  70. package/templates/template-tutorial-todo-app/src/Home.module.css +1 -2
  71. package/templates/template-tutorial-todo-app/src/Home.tsx +4 -3
  72. package/templates/template-tutorial-todo-app/src/Login.tsx +2 -0
  73. package/templates/template-tutorial-todo-app/src/TaskListItem.module.css +10 -0
  74. package/templates/template-tutorial-todo-app/src/TaskListItem.tsx +11 -8
  75. package/templates/template-tutorial-todo-app/src/index.css +0 -5
  76. package/templates/template-tutorial-todo-app/src/mocks.ts +3 -3
  77. package/templates/template-tutorial-todo-app/src/useProjectTasks.ts +5 -0
  78. package/templates/template-vue/package.json.hbs +1 -1
  79. package/build/js/index.browser.mjs.map +0 -1
  80. package/build/js/index.cjs.map +0 -1
  81. package/build/js/index.mjs.map +0 -1
  82. package/build/types/consola.d.ts +0 -2
  83. package/build/types/consola.d.ts.map +0 -1
  84. /package/build/{types → esm}/cli.d.ts +0 -0
  85. /package/build/{types → esm}/cli.test.d.ts +0 -0
  86. /package/build/{types → esm}/cli.test.d.ts.map +0 -0
  87. /package/build/{types → esm}/generate/generateEnv.d.ts +0 -0
  88. /package/build/{types → esm}/generate/generateEnv.d.ts.map +0 -0
  89. /package/build/{types → esm}/generate/generateEnv.test.d.ts +0 -0
  90. /package/build/{types → esm}/generate/generateEnv.test.d.ts.map +0 -0
  91. /package/build/{types → esm}/generate/generateFoundryConfigJson.d.ts +0 -0
  92. /package/build/{types → esm}/generate/generateFoundryConfigJson.d.ts.map +0 -0
  93. /package/build/{types → esm}/generate/generateFoundryConfigJson.test.d.ts +0 -0
  94. /package/build/{types → esm}/generate/generateFoundryConfigJson.test.d.ts.map +0 -0
  95. /package/build/{types → esm}/generate/generateNpmRc.d.ts +0 -0
  96. /package/build/{types → esm}/generate/generateNpmRc.d.ts.map +0 -0
  97. /package/build/{types → esm}/generate/generateNpmRc.test.d.ts +0 -0
  98. /package/build/{types → esm}/generate/generateNpmRc.test.d.ts.map +0 -0
  99. /package/build/{types → esm}/highlight.d.ts +0 -0
  100. /package/build/{types → esm}/index.d.ts +0 -0
  101. /package/build/{types → esm}/index.d.ts.map +0 -0
  102. /package/build/{types → esm}/prompts/promptApplicationRid.d.ts +0 -0
  103. /package/build/{types → esm}/prompts/promptApplicationRid.d.ts.map +0 -0
  104. /package/build/{types → esm}/prompts/promptApplicationRid.test.d.ts +0 -0
  105. /package/build/{types → esm}/prompts/promptApplicationRid.test.d.ts.map +0 -0
  106. /package/build/{types → esm}/prompts/promptApplicationUrl.d.ts +0 -0
  107. /package/build/{types → esm}/prompts/promptApplicationUrl.d.ts.map +0 -0
  108. /package/build/{types → esm}/prompts/promptApplicationUrl.test.d.ts +0 -0
  109. /package/build/{types → esm}/prompts/promptApplicationUrl.test.d.ts.map +0 -0
  110. /package/build/{types → esm}/prompts/promptClientId.d.ts +0 -0
  111. /package/build/{types → esm}/prompts/promptClientId.d.ts.map +0 -0
  112. /package/build/{types → esm}/prompts/promptClientId.test.d.ts +0 -0
  113. /package/build/{types → esm}/prompts/promptClientId.test.d.ts.map +0 -0
  114. /package/build/{types → esm}/prompts/promptCorsProxy.d.ts +0 -0
  115. /package/build/{types → esm}/prompts/promptCorsProxy.d.ts.map +0 -0
  116. /package/build/{types → esm}/prompts/promptCorsProxy.test.d.ts +0 -0
  117. /package/build/{types → esm}/prompts/promptCorsProxy.test.d.ts.map +0 -0
  118. /package/build/{types → esm}/prompts/promptFoundryUrl.d.ts +0 -0
  119. /package/build/{types → esm}/prompts/promptFoundryUrl.d.ts.map +0 -0
  120. /package/build/{types → esm}/prompts/promptFoundryUrl.test.d.ts +0 -0
  121. /package/build/{types → esm}/prompts/promptFoundryUrl.test.d.ts.map +0 -0
  122. /package/build/{types → esm}/prompts/promptOsdkPackage.d.ts +0 -0
  123. /package/build/{types → esm}/prompts/promptOsdkPackage.d.ts.map +0 -0
  124. /package/build/{types → esm}/prompts/promptOsdkPackage.test.d.ts +0 -0
  125. /package/build/{types → esm}/prompts/promptOsdkPackage.test.d.ts.map +0 -0
  126. /package/build/{types → esm}/prompts/promptOsdkRegistryUrl.d.ts +0 -0
  127. /package/build/{types → esm}/prompts/promptOsdkRegistryUrl.d.ts.map +0 -0
  128. /package/build/{types → esm}/prompts/promptOsdkRegistryUrl.test.d.ts +0 -0
  129. /package/build/{types → esm}/prompts/promptOsdkRegistryUrl.test.d.ts.map +0 -0
  130. /package/build/{types → esm}/prompts/promptOverwrite.d.ts +0 -0
  131. /package/build/{types → esm}/prompts/promptOverwrite.d.ts.map +0 -0
  132. /package/build/{types → esm}/prompts/promptOverwrite.test.d.ts +0 -0
  133. /package/build/{types → esm}/prompts/promptOverwrite.test.d.ts.map +0 -0
  134. /package/build/{types → esm}/prompts/promptProject.d.ts +0 -0
  135. /package/build/{types → esm}/prompts/promptProject.d.ts.map +0 -0
  136. /package/build/{types → esm}/prompts/promptProject.test.d.ts +0 -0
  137. /package/build/{types → esm}/prompts/promptProject.test.d.ts.map +0 -0
  138. /package/build/{types → esm}/prompts/promptTemplate.d.ts +0 -0
  139. /package/build/{types → esm}/prompts/promptTemplate.d.ts.map +0 -0
  140. /package/build/{types → esm}/prompts/promptTemplate.test.d.ts +0 -0
  141. /package/build/{types → esm}/prompts/promptTemplate.test.d.ts.map +0 -0
  142. /package/build/{types → esm}/run.d.ts +0 -0
  143. /package/build/{types → esm}/templates.d.ts +0 -0
@@ -0,0 +1,19 @@
1
+ import { PropsWithChildren } from "react";
2
+ import css from "./Dialog.module.css";
3
+
4
+ interface DialogProps {
5
+ isOpen: boolean;
6
+ buttons?: React.ReactElement[];
7
+ }
8
+
9
+ function Dialog({ children, isOpen, buttons }: PropsWithChildren<DialogProps>) {
10
+ return (
11
+ <dialog open={isOpen} className={css.dialog}>
12
+ {children}
13
+ {buttons != null && buttons.length > 0 && (
14
+ <div className={css.buttons}>{buttons}</div>
15
+ )}
16
+ </dialog>
17
+ );
18
+ }
19
+ export default Dialog;
@@ -0,0 +1,80 @@
1
+ .tutorialBannerWrapper {
2
+ display: flex;
3
+ margin: 2em;
4
+ }
5
+
6
+ .tutorialBanner {
7
+ flex: 1;
8
+ width: 0;
9
+ background: rgba(121, 97, 219, 0.7);
10
+ color: #ffffff;
11
+ border-radius: 1em;
12
+ padding: 1em;
13
+ box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
14
+ }
15
+
16
+ .tutorialBannerTitle {
17
+ margin-top: 0;
18
+ font-weight: 600;
19
+ }
20
+
21
+ .projectSelect {
22
+ display: flex;
23
+ align-items: center;
24
+ gap: 1em;
25
+ margin: 2em;
26
+ font-weight: 600;
27
+ }
28
+
29
+ .projectCard {
30
+ margin: 2em;
31
+ padding: 0.5em;
32
+ border: 1px solid #ccc;
33
+ /* margin: 0.5em; */
34
+ gap: 0.5em;
35
+ border-radius: 5px;
36
+
37
+ }
38
+
39
+ .projectTitle {
40
+ font-size: 1.5em;
41
+ }
42
+
43
+ .description {
44
+ display: flex;
45
+ flex-direction: column;
46
+ }
47
+
48
+ .image {
49
+ height: 16px;
50
+ width: 16px;
51
+ }
52
+
53
+ .aip {
54
+ background-color: #7961DB;
55
+ color: #ffffff;
56
+ border: 1px solid #ccc;
57
+ padding: 2px;
58
+ gap: 10px;
59
+ height: 30px;
60
+ }
61
+
62
+ .processing {
63
+ cursor: progress;
64
+ }
65
+
66
+ .aipText {
67
+ display: flex;
68
+ justify-content: center;
69
+ gap: 10px;
70
+ align-items: center;
71
+ padding: 0 10px;
72
+ }
73
+
74
+ .textArea {
75
+ border: none;
76
+ color: gray;
77
+ resize: none;
78
+ overflow: hidden;
79
+ pointer-events: none;
80
+ }
@@ -0,0 +1,133 @@
1
+ import aipLogo from "/aip-icon.svg";
2
+ import { useCallback, useEffect, useRef, useState } from "react";
3
+ import CreateProjectButton from "./CreateProjectButton";
4
+ import CreateTaskButton from "./CreateTaskButton";
5
+ import DeleteProjectButton from "./DeleteProjectButton";
6
+ import css from "./Home.module.css";
7
+ import Layout from "./Layout";
8
+ import type { MockProject } from "./mocks";
9
+ import ProjectSelect from "./ProjectSelect";
10
+ import TaskList from "./TaskList";
11
+ import useProjects from "./useProjects";
12
+
13
+ function Home() {
14
+ const [projectId, setProjectId] = useState<string | undefined>(undefined);
15
+ const { projects, updateProjectDescription } = useProjects();
16
+ const [isProcessing, setIsProcessing] = useState<boolean>(false);
17
+ const [projectHasTasks, setProjectHasTasks] = useState<boolean>(false);
18
+
19
+ const textAreaRef = useRef<HTMLTextAreaElement>(null);
20
+ const project = projects?.find((p) => p.id === projectId);
21
+
22
+ const handleSelectProject = useCallback(
23
+ (p: MockProject) => setProjectId(p.id),
24
+ [],
25
+ );
26
+
27
+ const handleProjectDescriptionRecommendation = useCallback(async () => {
28
+ if (project == null) {
29
+ return;
30
+ }
31
+ setIsProcessing(true);
32
+ await updateProjectDescription(project);
33
+ setIsProcessing(false);
34
+ }, [project, updateProjectDescription]);
35
+
36
+ useEffect(() => {
37
+ if (project == null && projects != null && projects.length > 0) {
38
+ setProjectId(projects[0].id);
39
+ setProjectHasTasks(projects[0].tasks.length > 0);
40
+ }
41
+ }, [project, projects]);
42
+
43
+ useEffect(() => {
44
+ if (textAreaRef.current) {
45
+ const textArea = textAreaRef.current;
46
+ textArea.style.height = "auto";
47
+ textArea.style.height = `${textArea.scrollHeight}px`;
48
+ }
49
+ }, [project?.description]);
50
+
51
+ const handleOnTaskCreated = useCallback(() => {
52
+ setProjectHasTasks(true);
53
+ }, []);
54
+
55
+ const handleOnProjectCreated = useCallback(
56
+ (projectId: string | undefined) => {
57
+ setProjectId(projectId);
58
+ setProjectHasTasks(false);
59
+ },
60
+ [],
61
+ );
62
+
63
+ const handleOnTaskDeleted = useCallback(() => {
64
+ if (project != null && project.tasks.length === 0) {
65
+ setProjectHasTasks(false);
66
+ }
67
+ }, [project]);
68
+
69
+ return (
70
+ <Layout>
71
+ <div className={css.tutorialBannerWrapper}>
72
+ <div className={css.tutorialBanner}>
73
+ <p className={css.tutorialBannerTitle}>
74
+ 💡 Welcome to the To Do AIP App tutorial!
75
+ </p>
76
+ <p>
77
+ The application is implemented with mock in memory data.
78
+ <br />Can you solve how to change it to use the Ontology SDK
79
+ instead?
80
+ </p>
81
+ </div>
82
+ </div>
83
+ <div className={css.projectSelect}>
84
+ <span>Project:</span>
85
+ <ProjectSelect
86
+ project={project}
87
+ projects={projects ?? []}
88
+ onSelectProject={handleSelectProject}
89
+ />
90
+ <CreateProjectButton onProjectCreated={handleOnProjectCreated} />
91
+ {project != null && <DeleteProjectButton project={project} />}
92
+ </div>
93
+ {project != null && (
94
+ <div className={css.projectCard} key={project.id}>
95
+ <h1 className={css.projectTitle}>{project.name}</h1>
96
+ {projectHasTasks && (
97
+ <div className={css.description}>
98
+ <textarea
99
+ ref={textAreaRef}
100
+ readOnly
101
+ value={project.description}
102
+ className={css.textArea}
103
+ />
104
+ <button
105
+ disabled={isProcessing}
106
+ className={`${css.aip} ${isProcessing ? css.processing : ""}`}
107
+ title="Click here to update project description based on AIP Logic"
108
+ type="button"
109
+ onClick={handleProjectDescriptionRecommendation}
110
+ >
111
+ <div className={css.aipText}>
112
+ <img
113
+ src={aipLogo}
114
+ alt="AIP"
115
+ className={css.image}
116
+ />
117
+ Get description recommendation
118
+ </div>
119
+ </button>
120
+ </div>
121
+ )}
122
+ <TaskList project={project} onTaskDeleted={handleOnTaskDeleted} />
123
+ <CreateTaskButton
124
+ project={project}
125
+ onTaskCreated={handleOnTaskCreated}
126
+ />
127
+ </div>
128
+ )}
129
+ </Layout>
130
+ );
131
+ }
132
+
133
+ export default Home;
@@ -0,0 +1,16 @@
1
+ .header {
2
+ display: flex;
3
+ align-items: center;
4
+ margin: 2em;
5
+ }
6
+
7
+ .logo {
8
+ height: 4em;
9
+ align-items: center;
10
+ margin-right: 1em;
11
+ }
12
+
13
+ .title {
14
+ font-weight: 600;
15
+ font-size: 1.5em;
16
+ }
@@ -0,0 +1,23 @@
1
+ import todoAppLogo from "/todo-aip-app.svg";
2
+ import React from "react";
3
+ import css from "./Layout.module.css";
4
+
5
+ interface LayoutProps {
6
+ children?: React.ReactNode;
7
+ }
8
+
9
+ function Layout({ children }: LayoutProps) {
10
+ return (
11
+ <>
12
+ <div className={css.header}>
13
+ <img src={todoAppLogo} className={css.logo} alt="Todo App logo" />
14
+ <div className={css.title}>
15
+ Ontology SDK Tutorial - To Do App Powered by AIP
16
+ </div>
17
+ </div>
18
+ {children}
19
+ </>
20
+ );
21
+ }
22
+
23
+ export default Layout;
@@ -0,0 +1,5 @@
1
+ .loginButton {
2
+ display: flex;
3
+ justify-content: center;
4
+ margin: 2em;
5
+ }
@@ -0,0 +1,44 @@
1
+ import { useCallback, useState } from "react";
2
+ import { Navigate } from "react-router-dom";
3
+ import client from "./client";
4
+ import Layout from "./Layout";
5
+ import css from "./Login.module.css";
6
+
7
+ function Login() {
8
+ const [isLoggingIn, setIsLoggingIn] = useState(false);
9
+ const [error, setError] = useState<string | undefined>(undefined);
10
+ const token = client.auth.token;
11
+
12
+ const handleLogin = useCallback(async () => {
13
+ setIsLoggingIn(true);
14
+ try {
15
+ // Initiate the OAuth flow, which will redirect the user to log into Foundry
16
+ // Once the login has completed, the user will be redirected back to the route defined via the
17
+ // FOUNDRY_REDIRECT_URL variable in .env.development
18
+ await client.auth.signIn();
19
+ } catch (e: unknown) {
20
+ console.error(e);
21
+ setError((e as Error).message ?? e);
22
+ } finally {
23
+ setIsLoggingIn(false);
24
+ }
25
+ }, []);
26
+
27
+ // If the token exists but a user tries to load /login, redirect to the home page instead
28
+ if (token != null) {
29
+ return <Navigate to="/" replace={true} />;
30
+ }
31
+
32
+ return (
33
+ <Layout>
34
+ <div className={css.loginButton}>
35
+ <button onClick={handleLogin}>
36
+ {isLoggingIn ? "Logging in…" : "Log in "}
37
+ </button>
38
+ </div>
39
+ {error && <div>Unable to log in: {error}</div>}
40
+ </Layout>
41
+ );
42
+ }
43
+
44
+ export default Login;
@@ -0,0 +1,40 @@
1
+ import { ChangeEvent, useCallback } from "react";
2
+ import { MockProject } from "./mocks";
3
+
4
+ interface ProjectSelectProps {
5
+ project: MockProject | undefined;
6
+ projects: MockProject[];
7
+ onSelectProject: (project: MockProject) => void;
8
+ }
9
+
10
+ function ProjectSelect({
11
+ project,
12
+ projects,
13
+ onSelectProject,
14
+ }: ProjectSelectProps) {
15
+ const handleSelect = useCallback(
16
+ (e: ChangeEvent<HTMLSelectElement>) => {
17
+ const nextProject = projects.find((p) => `${p.id}` === e.target.value);
18
+ if (nextProject != null) {
19
+ onSelectProject(nextProject);
20
+ }
21
+ },
22
+ [projects, onSelectProject],
23
+ );
24
+
25
+ return (
26
+ <select value={project?.id} onChange={handleSelect}>
27
+ <option hidden disabled value="">
28
+ -- select a project --
29
+ </option>
30
+
31
+ {projects.map((p) => (
32
+ <option key={p.id} value={p.id}>
33
+ {p.name}
34
+ </option>
35
+ ))}
36
+ </select>
37
+ );
38
+ }
39
+
40
+ export default ProjectSelect;
@@ -0,0 +1,7 @@
1
+ .taskList {
2
+ list-style: none;
3
+ padding: 0;
4
+ margin-top: 1em;
5
+ margin-bottom: 1em;
6
+ width: 100%;
7
+ }
@@ -0,0 +1,44 @@
1
+ import type { MockProject } from "./mocks";
2
+ import css from "./TaskList.module.css";
3
+ import TaskListItem from "./TaskListItem";
4
+ import { useProjectTasks } from "./useProjectTasks";
5
+
6
+ interface TaskListProps {
7
+ project: MockProject;
8
+ onTaskDeleted: (taskId: string) => void;
9
+ }
10
+
11
+ function TaskList({ project, onTaskDeleted }: TaskListProps) {
12
+ const {
13
+ tasks,
14
+ isLoading: isLoadingTasks,
15
+ isError: isErrorTasks,
16
+ deleteTask,
17
+ } = useProjectTasks(project);
18
+
19
+ if (isErrorTasks) {
20
+ return <div className={css.taskList}>Error loading tasks!</div>;
21
+ } else if (isLoadingTasks) {
22
+ return null;
23
+ }
24
+
25
+ const data = tasks ?? [];
26
+ if (data.length === 0) {
27
+ return <div className={css.taskList}>No tasks found</div>;
28
+ }
29
+
30
+ return (
31
+ <ul className={css.taskList}>
32
+ {data.map((task) => (
33
+ <TaskListItem
34
+ key={task.id}
35
+ task={task}
36
+ deleteTask={deleteTask}
37
+ onTaskDeleted={onTaskDeleted}
38
+ />
39
+ ))}
40
+ </ul>
41
+ );
42
+ }
43
+
44
+ export default TaskList;
@@ -0,0 +1,35 @@
1
+ .li {
2
+ display: flex;
3
+ flex-direction: row;
4
+ align-items: flex-start;
5
+ padding: 5px;
6
+ border: 1px solid #ccc;
7
+ gap: 5px;
8
+ border-radius: 5px;
9
+ background-color: #f9f9f9;
10
+ margin: 10px 0;
11
+ }
12
+
13
+ .checked {
14
+ text-decoration: line-through;
15
+ }
16
+
17
+ .delete {
18
+ border: 1px solid #ccc;
19
+ padding: 2px;
20
+ }
21
+
22
+ .task {
23
+ display: flex;
24
+ flex-direction: column;
25
+ width: 100%;
26
+ }
27
+
28
+ .textArea {
29
+ border: none;
30
+ background-color: #f9f9f9;
31
+ color: gray;
32
+ resize: none;
33
+ overflow: hidden;
34
+ pointer-events: none;
35
+ }
@@ -0,0 +1,59 @@
1
+ import { useCallback, useEffect, useRef, useState } from "react";
2
+ import type { MockTask } from "./mocks";
3
+ import css from "./TaskListItem.module.css";
4
+ interface TaskListItemProps {
5
+ task: MockTask;
6
+ deleteTask: (task: MockTask) => Promise<void>;
7
+ onTaskDeleted: (taskId: string) => void;
8
+ }
9
+
10
+ function TaskListItem({ task, deleteTask, onTaskDeleted }: TaskListItemProps) {
11
+ const [isDeleting, setIsDeleting] = useState(false);
12
+ const textAreaRef = useRef<HTMLTextAreaElement>(null);
13
+
14
+ const handleClick = useCallback(async () => {
15
+ setIsDeleting(true);
16
+ try {
17
+ await deleteTask(task);
18
+ } finally {
19
+ onTaskDeleted(task.id);
20
+ setIsDeleting(false);
21
+ }
22
+ }, [deleteTask, task, onTaskDeleted]);
23
+
24
+ useEffect(() => {
25
+ if (textAreaRef.current) {
26
+ const textArea = textAreaRef.current;
27
+ textArea.style.height = "auto";
28
+ textArea.style.height = `${textArea.scrollHeight}px`;
29
+ }
30
+ }, [task.description]);
31
+ const cleanDescription = task.description.trim() === ""
32
+ ? null
33
+ : task.description.trim();
34
+ return (
35
+ <li className={css.li}>
36
+ <input
37
+ type="checkbox"
38
+ onChange={handleClick}
39
+ checked={isDeleting}
40
+ className={css.delete}
41
+ title="Delete task"
42
+ />
43
+ <div className={`${css.task} ${isDeleting ? css.checked : ""}`}>
44
+ <span>{task.title}</span>
45
+ {cleanDescription != null && (
46
+ <textarea
47
+ ref={textAreaRef}
48
+ readOnly
49
+ value={task.description}
50
+ className={css.textArea}
51
+ rows={1}
52
+ />
53
+ )}
54
+ </div>
55
+ </li>
56
+ );
57
+ }
58
+
59
+ export default TaskListItem;
@@ -0,0 +1,31 @@
1
+ import { FoundryClient, PublicClientAuth } from "{{osdkPackage}}";
2
+
3
+ const url = import.meta.env.VITE_FOUNDRY_API_URL;
4
+ const clientId = import.meta.env.VITE_FOUNDRY_CLIENT_ID;
5
+ const redirectUrl = import.meta.env.VITE_FOUNDRY_REDIRECT_URL;
6
+ checkEnv(url, "VITE_FOUNDRY_API_URL");
7
+ checkEnv(clientId, "VITE_FOUNDRY_CLIENT_ID");
8
+ checkEnv(redirectUrl, "VITE_FOUNDRY_REDIRECT_URL");
9
+
10
+ function checkEnv(
11
+ value: string | undefined,
12
+ name: string,
13
+ ): asserts value is string {
14
+ if (value == null) {
15
+ throw new Error(`Missing environment variable: ${name}`);
16
+ }
17
+ }
18
+
19
+ /**
20
+ * Initialize the client to interact with the Ontology SDK
21
+ */
22
+ const client = new FoundryClient({
23
+ url,
24
+ auth: new PublicClientAuth({
25
+ clientId,
26
+ url,
27
+ redirectUrl,
28
+ }),
29
+ });
30
+
31
+ export default client;
@@ -0,0 +1,75 @@
1
+ :root {
2
+ font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
3
+ line-height: 1.5;
4
+ font-weight: 400;
5
+
6
+ font-synthesis: none;
7
+ text-rendering: optimizeLegibility;
8
+ -webkit-font-smoothing: antialiased;
9
+ -moz-osx-font-smoothing: grayscale;
10
+ }
11
+
12
+ #root-container {
13
+ display: flex;
14
+ flex: 1;
15
+ align-items: center;
16
+ }
17
+
18
+ #root {
19
+ max-width: 1280px;
20
+ margin: 2rem auto;
21
+ padding: 2rem;
22
+ }
23
+
24
+ a {
25
+ font-weight: 500;
26
+ color: #646cff;
27
+ text-decoration: inherit;
28
+ }
29
+ a:hover {
30
+ color: #535bf2;
31
+ }
32
+
33
+ body {
34
+ margin: 0;
35
+ display: flex;
36
+ flex-direction: column;
37
+ min-width: 320px;
38
+ min-height: 100vh;
39
+ }
40
+
41
+ h1 {
42
+ font-size: 3.2em;
43
+ line-height: 1.1;
44
+ }
45
+
46
+ button {
47
+ border-radius: 8px;
48
+ border: 1px solid transparent;
49
+ padding: 0.6em 1.2em;
50
+ font-size: 1em;
51
+ font-weight: 500;
52
+ font-family: inherit;
53
+ cursor: pointer;
54
+ transition: border-color 0.25s;
55
+ }
56
+ button:hover {
57
+ border-color: #646cff;
58
+ }
59
+ button:focus,
60
+ button:focus-visible {
61
+ outline: 4px auto -webkit-focus-ring-color;
62
+ }
63
+
64
+ @media (prefers-color-scheme: light) {
65
+ :root {
66
+ color: #213547;
67
+ background-color: #ffffff;
68
+ }
69
+ a:hover {
70
+ color: #747bff;
71
+ }
72
+ button {
73
+ background-color: #f9f9f9;
74
+ }
75
+ }
@@ -0,0 +1,36 @@
1
+ import ReactDOM from "react-dom/client";
2
+ import { createBrowserRouter, RouterProvider } from "react-router-dom";
3
+ import AuthCallback from "./AuthCallback";
4
+ import AuthenticatedRoute from "./AuthenticatedRoute";
5
+ import Home from "./Home";
6
+ import Login from "./Login";
7
+ import "./index.css";
8
+
9
+ const router = createBrowserRouter(
10
+ [
11
+ {
12
+ path: "/",
13
+ element: <AuthenticatedRoute />,
14
+ children: [
15
+ {
16
+ path: "/",
17
+ element: <Home />,
18
+ },
19
+ ],
20
+ },
21
+ {
22
+ path: "/login",
23
+ element: <Login />,
24
+ },
25
+ {
26
+ // This is the route defined in your application's redirect URL
27
+ path: "/auth/callback",
28
+ element: <AuthCallback />,
29
+ },
30
+ ],
31
+ { basename: import.meta.env.BASE_URL },
32
+ );
33
+
34
+ ReactDOM.createRoot(document.getElementById("root")!).render(
35
+ <RouterProvider router={router} />,
36
+ );