@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,187 @@
1
+ export interface MockProject {
2
+ $apiName: string;
3
+ $primaryKey: string;
4
+ id: string;
5
+ name: string;
6
+ description: string;
7
+ tasks: MockTask[];
8
+ }
9
+
10
+ export interface MockTask {
11
+ $apiName: string;
12
+ $primaryKey: string;
13
+ id: string;
14
+ title: string;
15
+ description: string;
16
+ }
17
+
18
+ const projects: MockProject[] = [
19
+ {
20
+ $apiName: "MockProject",
21
+ $primaryKey: "1",
22
+ id: "1",
23
+ name: "Mock project",
24
+ description: "This is a mock description",
25
+ tasks: [
26
+ {
27
+ $apiName: "MockTask",
28
+ $primaryKey: "1",
29
+ id: "1",
30
+ title: "Try to",
31
+ description: "task description 1",
32
+ },
33
+ {
34
+ $apiName: "MockTask",
35
+ $primaryKey: "2",
36
+ id: "2",
37
+ title: "Implement this",
38
+ description: "task description 2",
39
+ },
40
+ {
41
+ $apiName: "MockTask",
42
+ $primaryKey: "3",
43
+ id: "3",
44
+ title: "With the Ontology SDK!",
45
+ description: "task description 3",
46
+ },
47
+ ],
48
+ },
49
+ {
50
+ $apiName: "MockProject",
51
+ $primaryKey: "2",
52
+ id: "2",
53
+ name: "Yet another mock project",
54
+ description: "This is another mock description",
55
+ tasks: [
56
+ {
57
+ $apiName: "MockTask",
58
+ $primaryKey: "4",
59
+ id: "4",
60
+ title: "More tasks here",
61
+ description: "More task description",
62
+ },
63
+ ],
64
+ },
65
+ ];
66
+
67
+ async function delay(): Promise<void> {
68
+ return new Promise((resolve) =>
69
+ setTimeout(() => resolve(), 500 + Math.random() * 1000)
70
+ );
71
+ }
72
+
73
+ // Good enough random id for mocks
74
+ function randomId(): string {
75
+ return `${Math.floor(Math.random() * 2 ** 31)}`;
76
+ }
77
+
78
+ async function getProjects(): Promise<MockProject[]> {
79
+ await delay();
80
+ const result = [...projects];
81
+ result.sort((p1, p2) => p1.name.localeCompare(p2.name));
82
+ return result;
83
+ }
84
+
85
+ async function createProject({
86
+ name,
87
+ description = "",
88
+ }: {
89
+ name: string;
90
+ description?: string;
91
+ }): Promise<MockProject["$primaryKey"]> {
92
+ await delay();
93
+ const id = randomId();
94
+ projects.push({
95
+ $apiName: "MockProject",
96
+ $primaryKey: id,
97
+ id,
98
+ name,
99
+ description,
100
+ tasks: [],
101
+ });
102
+ return id;
103
+ }
104
+
105
+ async function getRecommendedProjectDescription(
106
+ project: MockProject,
107
+ ): Promise<string> {
108
+ await delay();
109
+ if (project.tasks.length === 0) {
110
+ throw new Error("Project description recommendation requires tasks");
111
+ }
112
+ return `AIP Logic mock description for project`;
113
+ }
114
+
115
+ async function updateProjectDescription(
116
+ project: MockProject,
117
+ description: string,
118
+ ): Promise<void> {
119
+ await delay();
120
+ project.description = description;
121
+ }
122
+
123
+ async function deleteProject(id: string): Promise<void> {
124
+ await delay();
125
+ const idx = projects.findIndex((p) => p.id === id);
126
+ if (idx !== -1) {
127
+ projects.splice(idx, 1);
128
+ }
129
+ }
130
+
131
+ async function createTask({
132
+ title,
133
+ description = "",
134
+ projectId,
135
+ }: {
136
+ title: string;
137
+ description: string;
138
+ projectId: string;
139
+ }): Promise<MockTask["$primaryKey"]> {
140
+ await delay();
141
+ const project = projects.find((p) => p.id === projectId);
142
+ if (project == null) {
143
+ throw new Error(`Project ${projectId} not found!`);
144
+ }
145
+ const id = randomId();
146
+ project.tasks.unshift({
147
+ $apiName: "MockTask",
148
+ $primaryKey: id,
149
+ id,
150
+ title,
151
+ description,
152
+ });
153
+ return id;
154
+ }
155
+
156
+ async function getRecommendedTaskDescription(
157
+ taskName: string,
158
+ ): Promise<string> {
159
+ await delay();
160
+ if (taskName.length === 0) {
161
+ throw new Error("Task name must not be empty");
162
+ }
163
+ return `Mock AIP description for task`;
164
+ }
165
+
166
+ async function deleteTask(id: string): Promise<void> {
167
+ await delay();
168
+ for (const project of projects) {
169
+ const idx = project.tasks.findIndex((t) => t.id === id);
170
+ if (idx !== -1) {
171
+ project.tasks.splice(idx, 1);
172
+ }
173
+ }
174
+ }
175
+
176
+ const Mocks = {
177
+ getProjects,
178
+ createProject,
179
+ getRecommendedProjectDescription,
180
+ deleteProject,
181
+ createTask,
182
+ deleteTask,
183
+ getRecommendedTaskDescription,
184
+ updateProjectDescription,
185
+ };
186
+
187
+ export default Mocks;
@@ -0,0 +1,75 @@
1
+ import { useCallback } from "react";
2
+ import useSWR from "swr";
3
+ import Mocks, { MockProject, MockTask } from "./mocks";
4
+
5
+ export function useProjectTasks(project: MockProject | undefined) {
6
+ const { data, isLoading, isValidating, error, mutate } = useSWR<MockTask[]>(
7
+ project != null ? `projects/${project.id}/tasks` : null,
8
+ // Try to implement this with the Ontology SDK!
9
+ async () => {
10
+ if (project == null) {
11
+ return [];
12
+ }
13
+ return project.tasks;
14
+ },
15
+ );
16
+
17
+ const createTask: (
18
+ title: string,
19
+ description: string,
20
+ ) => Promise<MockTask["$primaryKey"] | undefined> = useCallback(
21
+ async (title: string, description: string) => {
22
+ if (project == null) {
23
+ return undefined;
24
+ }
25
+ // Try to implement this with the Ontology SDK!
26
+ const id = await Mocks.createTask({
27
+ title,
28
+ description,
29
+ projectId: project.$primaryKey,
30
+ });
31
+ await mutate();
32
+ return id;
33
+ },
34
+ [project, mutate],
35
+ );
36
+
37
+ const deleteTask: (task: MockTask) => Promise<void> = useCallback(
38
+ async (task) => {
39
+ if (project == null) {
40
+ return;
41
+ }
42
+ await sleep(1000);
43
+ // Try to implement this with the Ontology SDK!
44
+ await Mocks.deleteTask(task.$primaryKey);
45
+ await mutate();
46
+ },
47
+ [project, mutate],
48
+ );
49
+
50
+ const getRecommendedTaskDescription: (taskName: string) => Promise<string> =
51
+ useCallback(
52
+ async (taskName: string) => {
53
+ // Try to implement this with the Ontology SDK!
54
+ const recommendedTaskDescription = await Mocks
55
+ .getRecommendedTaskDescription(taskName);
56
+ await mutate();
57
+ return recommendedTaskDescription;
58
+ },
59
+ [mutate],
60
+ );
61
+
62
+ return {
63
+ tasks: data,
64
+ isLoading,
65
+ isValidating,
66
+ isError: error,
67
+ createTask,
68
+ deleteTask,
69
+ getRecommendedTaskDescription,
70
+ };
71
+ }
72
+
73
+ function sleep(ms: number) {
74
+ return new Promise(resolve => setTimeout(resolve, ms));
75
+ }
@@ -0,0 +1,58 @@
1
+ import { useCallback } from "react";
2
+ import useSWR from "swr";
3
+ import type { MockProject } from "./mocks";
4
+ import Mocks from "./mocks";
5
+
6
+ function useProjects() {
7
+ const { data, isLoading, isValidating, error, mutate } = useSWR<
8
+ MockProject[]
9
+ >("projects", async () => {
10
+ // Try to implement this with the Ontology SDK!
11
+ return Mocks.getProjects();
12
+ });
13
+
14
+ const createProject: (
15
+ name: string,
16
+ ) => Promise<MockProject["$primaryKey"]> = useCallback(
17
+ async (name: string) => {
18
+ // Try to implement this with the Ontology SDK!
19
+ const id = await Mocks.createProject({ name });
20
+ await mutate();
21
+ return id;
22
+ },
23
+ [mutate],
24
+ );
25
+
26
+ const updateProjectDescription: (
27
+ project: MockProject,
28
+ ) => Promise<void> = useCallback(
29
+ async (project) => {
30
+ // Try to implement this with the Ontology SDK!
31
+ const description = await Mocks.getRecommendedProjectDescription(project);
32
+ await Mocks.updateProjectDescription(project, description);
33
+ await mutate();
34
+ },
35
+ [mutate],
36
+ );
37
+
38
+ const deleteProject: (project: MockProject) => Promise<void> = useCallback(
39
+ async (project) => {
40
+ // Try to implement this with the Ontology SDK!
41
+ await Mocks.deleteProject(project.$primaryKey);
42
+ await mutate();
43
+ },
44
+ [mutate],
45
+ );
46
+
47
+ return {
48
+ projects: data,
49
+ isLoading,
50
+ isValidating,
51
+ isError: error,
52
+ createProject,
53
+ deleteProject,
54
+ updateProjectDescription,
55
+ };
56
+ }
57
+
58
+ export default useProjects;
@@ -0,0 +1 @@
1
+ /// <reference types="vite/client" />
@@ -0,0 +1,25 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "useDefineForClassFields": true,
5
+ "lib": ["ES2020", "DOM", "DOM.Iterable"],
6
+ "module": "ESNext",
7
+ "skipLibCheck": true,
8
+
9
+ /* Bundler mode */
10
+ "moduleResolution": "bundler",
11
+ "allowImportingTsExtensions": true,
12
+ "resolveJsonModule": true,
13
+ "isolatedModules": true,
14
+ "noEmit": true,
15
+ "jsx": "react-jsx",
16
+
17
+ /* Linting */
18
+ "strict": true,
19
+ "noUnusedLocals": true,
20
+ "noUnusedParameters": true,
21
+ "noFallthroughCasesInSwitch": true
22
+ },
23
+ "include": ["src"],
24
+ "references": [{ "path": "./tsconfig.node.json" }]
25
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "compilerOptions": {
3
+ "composite": true,
4
+ "skipLibCheck": true,
5
+ "module": "ESNext",
6
+ "moduleResolution": "bundler",
7
+ "allowSyntheticDefaultImports": true
8
+ },
9
+ "include": ["vite.config.ts"]
10
+ }
@@ -0,0 +1,19 @@
1
+ import react from "@vitejs/plugin-react";
2
+ import { defineConfig } from "vite";
3
+
4
+ // https://vitejs.dev/config/
5
+ export default defineConfig({
6
+ plugins: [react()],
7
+ server: {
8
+ port: 8080,
9
+ {{#if corsProxy}}
10
+ proxy: {
11
+ "^(/multipass/api|/api)": {
12
+ target: "{{foundryUrl}}",
13
+ changeOrigin: true,
14
+ secure: true,
15
+ },
16
+ },
17
+ {{/if}}
18
+ },
19
+ });
@@ -1,6 +1,6 @@
1
1
  # {{project}}
2
2
 
3
- This project was generated with `@osdk/create-app` and is intended to be used alongside the Developer Console tutorial for creating a Todo App against a reference Ontology.
3
+ This project was generated with `@osdk/create-app` and is intended to be used alongside the Developer Console tutorial for creating a To Do App against a reference Ontology.
4
4
 
5
5
  ## Developing
6
6
 
@@ -11,21 +11,21 @@
11
11
  },
12
12
  "dependencies": {
13
13
  "{{osdkPackage}}": "latest",
14
- "react": "^18.2.0",
15
- "react-dom": "^18.2.0",
16
- "react-router-dom": "^6.20.1",
14
+ "react": "^18",
15
+ "react-dom": "^18",
16
+ "react-router-dom": "^6.23.1",
17
17
  "swr": "^2.2.5"
18
18
  },
19
19
  "devDependencies": {
20
20
  "@types/react": "^18",
21
- "@types/react-dom": "^18.2.15",
21
+ "@types/react-dom": "^18",
22
22
  "@typescript-eslint/eslint-plugin": "^7.8.0",
23
23
  "@typescript-eslint/parser": "^7.8.0",
24
24
  "@vitejs/plugin-react": "^4.2.0",
25
25
  "eslint": "^8.57.0",
26
- "eslint-plugin-react-hooks": "^4.6.0",
26
+ "eslint-plugin-react-hooks": "^4.6.2",
27
27
  "eslint-plugin-react-refresh": "^0.4.6",
28
28
  "typescript": "^5.2.2",
29
- "vite": "^5.0.13"
29
+ "vite": "^5.2.11"
30
30
  }
31
31
  }
@@ -39,12 +39,12 @@ function CreateProjectDialog({
39
39
  <Dialog
40
40
  isOpen={isOpen}
41
41
  buttons={[
42
- <button disabled={isCreating} onClick={handleSubmit} key="create">
43
- Create project
44
- </button>,
45
42
  <button disabled={isCreating} onClick={onClose} key="cancel">
46
43
  Cancel
47
44
  </button>,
45
+ <button disabled={isCreating} onClick={handleSubmit} key="create">
46
+ Create project
47
+ </button>,
48
48
  ]}
49
49
  >
50
50
  <label>
@@ -35,12 +35,12 @@ function CreateTaskDialog({ project, isOpen, onClose }: CreateTaskDialogProps) {
35
35
  <Dialog
36
36
  isOpen={isOpen}
37
37
  buttons={[
38
- <button disabled={isCreating} onClick={handleSubmit} key="create">
39
- Create task
40
- </button>,
41
38
  <button disabled={isCreating} onClick={onClose} key="cancel">
42
39
  Cancel
43
40
  </button>,
41
+ <button disabled={isCreating} onClick={handleSubmit} key="create">
42
+ Create task
43
+ </button>,
44
44
  ]}
45
45
  >
46
46
  <label>
@@ -31,12 +31,12 @@ function DeleteProjectDialog({
31
31
  <Dialog
32
32
  isOpen={isOpen}
33
33
  buttons={[
34
- <button disabled={isDeleting} onClick={handleSubmit} key="delete">
35
- Delete
36
- </button>,
37
34
  <button disabled={isDeleting} onClick={onClose} key="cancel">
38
35
  Cancel
39
36
  </button>,
37
+ <button disabled={isDeleting} onClick={handleSubmit} key="delete">
38
+ Delete
39
+ </button>,
40
40
  ]}
41
41
  >
42
42
  Are you sure you want to delete this project?
@@ -3,3 +3,8 @@
3
3
  gap: 1em;
4
4
  margin-top: 1em;
5
5
  }
6
+
7
+ .dialog {
8
+ border: 1px solid black;
9
+ border-radius: 10px;
10
+ }
@@ -8,7 +8,7 @@ interface DialogProps {
8
8
 
9
9
  function Dialog({ children, isOpen, buttons }: PropsWithChildren<DialogProps>) {
10
10
  return (
11
- <dialog open={isOpen}>
11
+ <dialog open={isOpen} className={css.dialog}>
12
12
  {children}
13
13
  {buttons != null && buttons.length > 0 && (
14
14
  <div className={css.buttons}>{buttons}</div>
@@ -6,8 +6,7 @@
6
6
  .tutorialBanner {
7
7
  flex: 1;
8
8
  width: 0;
9
- background: #646cff;
10
- color: #ffffff;
9
+ background: hsl(35, 100%, 70%);
11
10
  border-radius: 1em;
12
11
  padding: 1em;
13
12
  box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
@@ -30,11 +30,12 @@ function Home() {
30
30
  <div className={css.tutorialBannerWrapper}>
31
31
  <div className={css.tutorialBanner}>
32
32
  <p className={css.tutorialBannerTitle}>
33
- 💡 Welcome to this tutorial!
33
+ 💡 Welcome to To Do app tutorial!
34
34
  </p>
35
35
  <p>
36
- The Todo App below has been implemented with fake in memory data.
37
- Can you solve how to switch it to use the Ontology SDK instead?
36
+ The To Do App is implemented with mock in-memory data.
37
+ <br />Can you solve how to switch it to use the Ontology SDK
38
+ instead?
38
39
  </p>
39
40
  </div>
40
41
  </div>
@@ -19,6 +19,8 @@ function Login() {
19
19
  } catch (e: unknown) {
20
20
  console.error(e);
21
21
  setError((e as Error).message ?? e);
22
+ } finally {
23
+ setIsLoggingIn(false);
22
24
  }
23
25
  }, []);
24
26
 
@@ -1,3 +1,13 @@
1
1
  .label {
2
2
  margin-left: 0.5em;
3
3
  }
4
+
5
+ .checked {
6
+ text-decoration: line-through;
7
+ }
8
+
9
+ .delete {
10
+ border: 1px solid #ccc;
11
+ padding: 2px;
12
+ }
13
+
@@ -20,14 +20,17 @@ function TaskListItem({ task, deleteTask }: TaskListItemProps) {
20
20
 
21
21
  return (
22
22
  <li>
23
- <input
24
- id={`${task.id}`}
25
- type="checkbox"
26
- onClick={handleClick}
27
- checked={isDeleting}
28
- disabled={isDeleting}
29
- />
30
- <label className={css.label} htmlFor={`${task.id}`}>
23
+ <label
24
+ className={`${css.label} ${isDeleting ? css.checked : ""}`}
25
+ htmlFor={`${task.id}`}
26
+ >
27
+ <input
28
+ type="checkbox"
29
+ onChange={handleClick}
30
+ checked={isDeleting}
31
+ className={css.delete}
32
+ title="Delete task"
33
+ />
31
34
  {task.title}
32
35
  </label>
33
36
  </li>
@@ -3,10 +3,6 @@
3
3
  line-height: 1.5;
4
4
  font-weight: 400;
5
5
 
6
- color-scheme: light dark;
7
- color: rgba(255, 255, 255, 0.87);
8
- background-color: #242424;
9
-
10
6
  font-synthesis: none;
11
7
  text-rendering: optimizeLegibility;
12
8
  -webkit-font-smoothing: antialiased;
@@ -54,7 +50,6 @@ button {
54
50
  font-size: 1em;
55
51
  font-weight: 500;
56
52
  font-family: inherit;
57
- background-color: #1a1a1a;
58
53
  cursor: pointer;
59
54
  transition: border-color 0.25s;
60
55
  }
@@ -18,7 +18,7 @@ const projects: MockProject[] = [
18
18
  $apiName: "MockProject",
19
19
  $primaryKey: "1",
20
20
  id: "1",
21
- name: "Fake Project",
21
+ name: "Mock project",
22
22
  tasks: [
23
23
  {
24
24
  $apiName: "MockTask",
@@ -44,7 +44,7 @@ const projects: MockProject[] = [
44
44
  $apiName: "MockProject",
45
45
  $primaryKey: "2",
46
46
  id: "2",
47
- name: "Yet Another Fake Project",
47
+ name: "Yet another mock project",
48
48
  tasks: [
49
49
  {
50
50
  $apiName: "MockTask",
@@ -78,7 +78,7 @@ async function createProject({
78
78
  name,
79
79
  }: {
80
80
  name: string;
81
- }): Promise<MockTask["$primaryKey"]> {
81
+ }): Promise<MockProject["$primaryKey"]> {
82
82
  await delay();
83
83
  const id = randomId();
84
84
  projects.push({
@@ -37,6 +37,7 @@ export function useProjectTasks(project: MockProject | undefined) {
37
37
  if (project == null) {
38
38
  return;
39
39
  }
40
+ await sleep(1000);
40
41
  // Try to implement this with the Ontology SDK!
41
42
  await Mocks.deleteTask(task.$primaryKey);
42
43
  await mutate();
@@ -53,3 +54,7 @@ export function useProjectTasks(project: MockProject | undefined) {
53
54
  deleteTask,
54
55
  };
55
56
  }
57
+
58
+ function sleep(ms: number) {
59
+ return new Promise(resolve => setTimeout(resolve, ms));
60
+ }
@@ -16,7 +16,7 @@
16
16
  "devDependencies": {
17
17
  "@vitejs/plugin-vue": "^4.5.0",
18
18
  "typescript": "^5.2.2",
19
- "vite": "^5.0.13",
19
+ "vite": "^5.2.11",
20
20
  "vue-tsc": "^1.8.22"
21
21
  }
22
22
  }