@osdk/create-app 0.17.0-beta.2 → 0.17.0-beta.4
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.
- package/CHANGELOG.md +12 -0
- package/build/browser/index.js +9 -13
- package/build/browser/index.js.map +1 -1
- package/build/cjs/index.cjs +9 -14
- package/build/cjs/index.cjs.map +1 -1
- package/build/esm/index.js +9 -13
- package/build/esm/index.js.map +1 -1
- package/build/esm/run.d.ts.map +1 -1
- package/package.json +15 -6
- package/templates/template-next-static-export/.eslintrc.json +0 -4
- package/templates/template-next-static-export/README.md.hbs +0 -35
- package/templates/template-next-static-export/_gitignore +0 -36
- package/templates/template-next-static-export/next.config.js.hbs +0 -17
- package/templates/template-next-static-export/package.json.hbs +0 -25
- package/templates/template-next-static-export/public/next.svg +0 -20
- package/templates/template-next-static-export/public/palantir.svg +0 -3
- package/templates/template-next-static-export/src/app/auth/callback/page.tsx +0 -25
- package/templates/template-next-static-export/src/app/globals.css +0 -81
- package/templates/template-next-static-export/src/app/icon.svg +0 -20
- package/templates/template-next-static-export/src/app/layout.module.css +0 -11
- package/templates/template-next-static-export/src/app/layout.tsx +0 -51
- package/templates/template-next-static-export/src/app/login/page.tsx +0 -45
- package/templates/template-next-static-export/src/app/page.module.css +0 -7
- package/templates/template-next-static-export/src/app/page.tsx.hbs +0 -53
- package/templates/template-next-static-export/src/lib/client.ts.hbs +0 -31
- package/templates/template-next-static-export/src/lib/useAuthenticated.ts +0 -25
- package/templates/template-next-static-export/tsconfig.json +0 -27
- package/templates/template-react/.eslintrc.cjs +0 -18
- package/templates/template-react/README.md.hbs +0 -35
- package/templates/template-react/_gitignore +0 -24
- package/templates/template-react/index.html +0 -15
- package/templates/template-react/package.json.hbs +0 -30
- package/templates/template-react/public/palantir.svg +0 -3
- package/templates/template-react/public/react.svg +0 -1
- package/templates/template-react/src/AuthCallback.tsx +0 -24
- package/templates/template-react/src/AuthenticatedRoute.tsx +0 -33
- package/templates/template-react/src/Home.module.css +0 -7
- package/templates/template-react/src/Home.tsx.hbs +0 -47
- package/templates/template-react/src/Layout.module.css +0 -10
- package/templates/template-react/src/Layout.tsx +0 -29
- package/templates/template-react/src/Login.tsx +0 -42
- package/templates/template-react/src/client.ts.hbs +0 -31
- package/templates/template-react/src/index.css +0 -81
- package/templates/template-react/src/main.tsx +0 -36
- package/templates/template-react/src/vite-env.d.ts +0 -1
- package/templates/template-react/tsconfig.json +0 -25
- package/templates/template-react/tsconfig.node.json +0 -10
- package/templates/template-react/vite.config.ts.hbs +0 -19
- package/templates/template-tutorial-todo-aip-app/.eslintrc.cjs +0 -18
- package/templates/template-tutorial-todo-aip-app/README.md.hbs +0 -34
- package/templates/template-tutorial-todo-aip-app/index.html +0 -15
- package/templates/template-tutorial-todo-aip-app/package.json.hbs +0 -31
- package/templates/template-tutorial-todo-aip-app/public/aip-icon.svg +0 -3
- package/templates/template-tutorial-todo-aip-app/public/todo-aip-app.svg +0 -19
- package/templates/template-tutorial-todo-aip-app/src/AuthCallback.tsx +0 -24
- package/templates/template-tutorial-todo-aip-app/src/AuthenticatedRoute.tsx +0 -33
- package/templates/template-tutorial-todo-aip-app/src/CreateProjectButton.module.css +0 -3
- package/templates/template-tutorial-todo-aip-app/src/CreateProjectButton.tsx +0 -36
- package/templates/template-tutorial-todo-aip-app/src/CreateProjectDialog.module.css +0 -15
- package/templates/template-tutorial-todo-aip-app/src/CreateProjectDialog.tsx +0 -74
- package/templates/template-tutorial-todo-aip-app/src/CreateTaskButton.module.css +0 -3
- package/templates/template-tutorial-todo-aip-app/src/CreateTaskButton.tsx +0 -38
- package/templates/template-tutorial-todo-aip-app/src/CreateTaskDialog.module.css +0 -66
- package/templates/template-tutorial-todo-aip-app/src/CreateTaskDialog.tsx +0 -140
- package/templates/template-tutorial-todo-aip-app/src/DeleteProjectButton.module.css +0 -3
- package/templates/template-tutorial-todo-aip-app/src/DeleteProjectButton.tsx +0 -37
- package/templates/template-tutorial-todo-aip-app/src/DeleteProjectDialog.module.css +0 -3
- package/templates/template-tutorial-todo-aip-app/src/DeleteProjectDialog.tsx +0 -57
- package/templates/template-tutorial-todo-aip-app/src/Dialog.module.css +0 -11
- package/templates/template-tutorial-todo-aip-app/src/Dialog.tsx +0 -19
- package/templates/template-tutorial-todo-aip-app/src/Home.module.css +0 -80
- package/templates/template-tutorial-todo-aip-app/src/Home.tsx +0 -135
- package/templates/template-tutorial-todo-aip-app/src/Layout.module.css +0 -16
- package/templates/template-tutorial-todo-aip-app/src/Layout.tsx +0 -23
- package/templates/template-tutorial-todo-aip-app/src/Login.module.css +0 -5
- package/templates/template-tutorial-todo-aip-app/src/Login.tsx +0 -44
- package/templates/template-tutorial-todo-aip-app/src/ProjectSelect.tsx +0 -40
- package/templates/template-tutorial-todo-aip-app/src/TaskList.module.css +0 -7
- package/templates/template-tutorial-todo-aip-app/src/TaskList.tsx +0 -44
- package/templates/template-tutorial-todo-aip-app/src/TaskListItem.module.css +0 -35
- package/templates/template-tutorial-todo-aip-app/src/TaskListItem.tsx +0 -58
- package/templates/template-tutorial-todo-aip-app/src/client.ts.hbs +0 -31
- package/templates/template-tutorial-todo-aip-app/src/index.css +0 -75
- package/templates/template-tutorial-todo-aip-app/src/main.tsx +0 -36
- package/templates/template-tutorial-todo-aip-app/src/mocks.ts +0 -187
- package/templates/template-tutorial-todo-aip-app/src/useProjectTasks.ts +0 -75
- package/templates/template-tutorial-todo-aip-app/src/useProjects.ts +0 -58
- package/templates/template-tutorial-todo-aip-app/src/vite-env.d.ts +0 -1
- package/templates/template-tutorial-todo-aip-app/tsconfig.json +0 -25
- package/templates/template-tutorial-todo-aip-app/tsconfig.node.json +0 -10
- package/templates/template-tutorial-todo-aip-app/vite.config.ts.hbs +0 -19
- package/templates/template-tutorial-todo-app/.eslintrc.cjs +0 -18
- package/templates/template-tutorial-todo-app/README.md.hbs +0 -33
- package/templates/template-tutorial-todo-app/index.html +0 -15
- package/templates/template-tutorial-todo-app/package.json.hbs +0 -31
- package/templates/template-tutorial-todo-app/public/todo-app.svg +0 -4
- package/templates/template-tutorial-todo-app/src/AuthCallback.tsx +0 -24
- package/templates/template-tutorial-todo-app/src/AuthenticatedRoute.tsx +0 -33
- package/templates/template-tutorial-todo-app/src/CreateProjectButton.tsx +0 -33
- package/templates/template-tutorial-todo-app/src/CreateProjectDialog.tsx +0 -56
- package/templates/template-tutorial-todo-app/src/CreateTaskButton.tsx +0 -35
- package/templates/template-tutorial-todo-app/src/CreateTaskDialog.tsx +0 -52
- package/templates/template-tutorial-todo-app/src/DeleteProjectButton.tsx +0 -34
- package/templates/template-tutorial-todo-app/src/DeleteProjectDialog.tsx +0 -46
- package/templates/template-tutorial-todo-app/src/Dialog.module.css +0 -10
- package/templates/template-tutorial-todo-app/src/Dialog.tsx +0 -19
- package/templates/template-tutorial-todo-app/src/Home.module.css +0 -34
- package/templates/template-tutorial-todo-app/src/Home.tsx +0 -63
- package/templates/template-tutorial-todo-app/src/Layout.module.css +0 -16
- package/templates/template-tutorial-todo-app/src/Layout.tsx +0 -21
- package/templates/template-tutorial-todo-app/src/Login.module.css +0 -5
- package/templates/template-tutorial-todo-app/src/Login.tsx +0 -44
- package/templates/template-tutorial-todo-app/src/ProjectSelect.tsx +0 -40
- package/templates/template-tutorial-todo-app/src/TaskList.module.css +0 -6
- package/templates/template-tutorial-todo-app/src/TaskList.tsx +0 -38
- package/templates/template-tutorial-todo-app/src/TaskListItem.module.css +0 -13
- package/templates/template-tutorial-todo-app/src/TaskListItem.tsx +0 -40
- package/templates/template-tutorial-todo-app/src/client.ts.hbs +0 -31
- package/templates/template-tutorial-todo-app/src/index.css +0 -75
- package/templates/template-tutorial-todo-app/src/main.tsx +0 -36
- package/templates/template-tutorial-todo-app/src/mocks.ts +0 -137
- package/templates/template-tutorial-todo-app/src/useProjectTasks.ts +0 -60
- package/templates/template-tutorial-todo-app/src/useProjects.ts +0 -43
- package/templates/template-tutorial-todo-app/src/vite-env.d.ts +0 -1
- package/templates/template-tutorial-todo-app/tsconfig.json +0 -25
- package/templates/template-tutorial-todo-app/tsconfig.node.json +0 -10
- package/templates/template-tutorial-todo-app/vite.config.ts.hbs +0 -19
- package/templates/template-vue/.vscode/extensions.json +0 -3
- package/templates/template-vue/README.md.hbs +0 -35
- package/templates/template-vue/_gitignore +0 -24
- package/templates/template-vue/index.html +0 -15
- package/templates/template-vue/package.json.hbs +0 -22
- package/templates/template-vue/public/palantir.svg +0 -3
- package/templates/template-vue/public/vue.svg +0 -1
- package/templates/template-vue/src/AuthCallback.vue +0 -22
- package/templates/template-vue/src/Home.vue.hbs +0 -38
- package/templates/template-vue/src/Layout.vue +0 -26
- package/templates/template-vue/src/Login.vue +0 -36
- package/templates/template-vue/src/client.ts.hbs +0 -31
- package/templates/template-vue/src/main.ts +0 -35
- package/templates/template-vue/src/style.css +0 -81
- package/templates/template-vue/src/vite-env.d.ts +0 -1
- package/templates/template-vue/tsconfig.json +0 -25
- package/templates/template-vue/tsconfig.node.json +0 -10
- package/templates/template-vue/vite.config.ts.hbs +0 -24
|
@@ -1,75 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
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
|
-
);
|
|
@@ -1,187 +0,0 @@
|
|
|
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;
|
|
@@ -1,75 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
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;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/// <reference types="vite/client" />
|
|
@@ -1,25 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
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,18 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
root: true,
|
|
3
|
-
env: { browser: true, es2020: true },
|
|
4
|
-
extends: [
|
|
5
|
-
"eslint:recommended",
|
|
6
|
-
"plugin:@typescript-eslint/recommended",
|
|
7
|
-
"plugin:react-hooks/recommended",
|
|
8
|
-
],
|
|
9
|
-
ignorePatterns: ["dist", ".eslintrc.cjs"],
|
|
10
|
-
parser: "@typescript-eslint/parser",
|
|
11
|
-
plugins: ["react-refresh"],
|
|
12
|
-
rules: {
|
|
13
|
-
"react-refresh/only-export-components": [
|
|
14
|
-
"warn",
|
|
15
|
-
{ allowConstantExport: true },
|
|
16
|
-
],
|
|
17
|
-
},
|
|
18
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
# {{project}}
|
|
2
|
-
|
|
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
|
-
|
|
5
|
-
## Developing
|
|
6
|
-
|
|
7
|
-
Run the following command or equivalent with your preferred package manager to start a local development server on `http://localhost:8080`:
|
|
8
|
-
|
|
9
|
-
```sh
|
|
10
|
-
npm run dev
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
Development configuration is stored in `.env.development`.
|
|
14
|
-
|
|
15
|
-
{{#if corsProxy}}
|
|
16
|
-
In order to make API requests to Foundry, a CORS proxy has been set up for local development which may be removed if the stack is configured to allow `http://localhost:8080` to load resources. The configured OAuth client must also allow `http://localhost:8080/auth/callback` as a redirect URL.
|
|
17
|
-
{{else}}
|
|
18
|
-
In order to make API requests to Foundry, CORS must be configured for the stack to allow `http://localhost:8080` to load resources. The configured OAuth client must also allow `http://localhost:8080/auth/callback` as a redirect URL.
|
|
19
|
-
{{/if}}
|
|
20
|
-
|
|
21
|
-
## Deploying
|
|
22
|
-
|
|
23
|
-
Run the following command or equivalent with your preferred package manager to create a production build of your application:
|
|
24
|
-
|
|
25
|
-
```sh
|
|
26
|
-
npm run build
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
Production configuration is stored in `.env.production`.
|
|
30
|
-
|
|
31
|
-
If you did not fill in the URL your production application will be hosted on you will need to fill in the `VITE_FOUNDRY_REDIRECT_URL` in `.env.production`.
|
|
32
|
-
|
|
33
|
-
In order to make API requests to Foundry, CORS must be configured for the stack to allow the production origin to load resources. The configured OAuth client must also allow the production origin auth callback as a redirect URL.
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<link rel="icon" type="image/svg+xml" href="/todo-app.svg" />
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
-
<title>Ontology SDK Tutorial - Todo App</title>
|
|
8
|
-
</head>
|
|
9
|
-
<body>
|
|
10
|
-
<div id="root-container">
|
|
11
|
-
<div id="root"></div>
|
|
12
|
-
</div>
|
|
13
|
-
<script type="module" src="/src/main.tsx"></script>
|
|
14
|
-
</body>
|
|
15
|
-
</html>
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "{{project}}",
|
|
3
|
-
"private": true,
|
|
4
|
-
"version": "0.0.0",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"dev": "vite",
|
|
8
|
-
"build": "tsc && vite build",
|
|
9
|
-
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
|
10
|
-
"preview": "vite preview"
|
|
11
|
-
},
|
|
12
|
-
"dependencies": {
|
|
13
|
-
"{{osdkPackage}}": "latest",
|
|
14
|
-
"react": "^18",
|
|
15
|
-
"react-dom": "^18",
|
|
16
|
-
"react-router-dom": "^6.23.1",
|
|
17
|
-
"swr": "^2.2.5"
|
|
18
|
-
},
|
|
19
|
-
"devDependencies": {
|
|
20
|
-
"@types/react": "^18",
|
|
21
|
-
"@types/react-dom": "^18",
|
|
22
|
-
"@typescript-eslint/eslint-plugin": "^7.8.0",
|
|
23
|
-
"@typescript-eslint/parser": "^7.8.0",
|
|
24
|
-
"@vitejs/plugin-react": "^4.2.0",
|
|
25
|
-
"eslint": "^8.57.0",
|
|
26
|
-
"eslint-plugin-react-hooks": "^4.6.2",
|
|
27
|
-
"eslint-plugin-react-refresh": "^0.4.6",
|
|
28
|
-
"typescript": "^5.2.2",
|
|
29
|
-
"vite": "^5.2.11"
|
|
30
|
-
}
|
|
31
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
<svg width="128" height="128" viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
-
<rect width="128" height="128" rx="16" fill="#FBB360"/>
|
|
3
|
-
<path fill-rule="evenodd" clip-rule="evenodd" d="M28 82V94H40V82H28ZM22 70H46C49.3 70 52 72.7 52 76V100C52 103.3 49.3 106 46 106H22C18.7 106 16 103.3 16 100V76C16 72.7 18.7 70 22 70ZM76 34H106C109.3 34 112 36.7 112 40C112 43.3 109.3 46 106 46H76C72.7 46 70 43.3 70 40C70 36.7 72.7 34 76 34ZM52 22C55.3 22 58 24.7 58 28C58 29.68 57.34 31.18 56.26 32.26L38.26 56.26C37.18 57.34 35.68 58 34 58C32.32 58 30.82 57.34 29.74 56.26L17.74 44.26C16.66 43.18 16 41.68 16 40C16 36.7 18.7 34 22 34C23.68 34 25.18 34.66 26.26 35.74L34 43.54L47.74 23.74C48.82 22.66 50.32 22 52 22ZM76 82H106C109.3 82 112 84.7 112 88C112 91.3 109.3 94 106 94H76C72.7 94 70 91.3 70 88C70 84.7 72.7 82 76 82Z" fill="#77450D"/>
|
|
4
|
-
</svg>
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from "react";
|
|
2
|
-
import { useNavigate } from "react-router-dom";
|
|
3
|
-
import client from "./client";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Component to render at `/auth/callback`
|
|
7
|
-
* This calls signIn() again to save the token, and then navigates the user back to the home page.
|
|
8
|
-
*/
|
|
9
|
-
function AuthCallback() {
|
|
10
|
-
const [error, setError] = useState<string | undefined>(undefined);
|
|
11
|
-
const navigate = useNavigate();
|
|
12
|
-
|
|
13
|
-
// This effect conflicts with React 18 strict mode in development
|
|
14
|
-
// https://react.dev/learn/synchronizing-with-effects#how-to-handle-the-effect-firing-twice-in-development
|
|
15
|
-
useEffect(() => {
|
|
16
|
-
client.auth
|
|
17
|
-
.signIn()
|
|
18
|
-
.then(() => navigate("/", { replace: true }))
|
|
19
|
-
.catch((e: unknown) => setError((e as Error).message ?? e));
|
|
20
|
-
}, [navigate]);
|
|
21
|
-
return <div>{error != null ? error : "Authenticating…"}</div>;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export default AuthCallback;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from "react";
|
|
2
|
-
import { Outlet, useNavigate } from "react-router-dom";
|
|
3
|
-
import client from "./client";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* A component that can be used to wrap routes that require authentication.
|
|
7
|
-
* Nested routes may assume that a valid token is present.
|
|
8
|
-
*/
|
|
9
|
-
function AuthenticatedRoute() {
|
|
10
|
-
const navigate = useNavigate();
|
|
11
|
-
const [token, setToken] = useState(client.auth.token);
|
|
12
|
-
useEffect(() => {
|
|
13
|
-
if (client.auth.token == null || client.auth.token.isExpired) {
|
|
14
|
-
client.auth
|
|
15
|
-
.refresh()
|
|
16
|
-
.then(() => {
|
|
17
|
-
setToken(client.auth.token);
|
|
18
|
-
})
|
|
19
|
-
.catch(() => {
|
|
20
|
-
// If we cannot refresh the token (i.e. the user is not logged in) we redirect to the login page
|
|
21
|
-
navigate("/login");
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
}, [navigate]);
|
|
25
|
-
|
|
26
|
-
if (token == null || token.isExpired) {
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return <Outlet />;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export default AuthenticatedRoute;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { useCallback, useState } from "react";
|
|
2
|
-
import CreateProjectDialog from "./CreateProjectDialog";
|
|
3
|
-
import useProjects from "./useProjects";
|
|
4
|
-
|
|
5
|
-
interface CreateProjectButtonProps {
|
|
6
|
-
onProjectCreated?: (projectId: string) => void;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
function CreateProjectButton({ onProjectCreated }: CreateProjectButtonProps) {
|
|
10
|
-
const { isLoading: isLoadingProjects, isError: isErrorProjects } =
|
|
11
|
-
useProjects();
|
|
12
|
-
|
|
13
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
14
|
-
const handleOpen = useCallback(() => setIsOpen(true), []);
|
|
15
|
-
const handleClose = useCallback(() => setIsOpen(false), []);
|
|
16
|
-
|
|
17
|
-
if (isLoadingProjects || isErrorProjects) {
|
|
18
|
-
return null;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return (
|
|
22
|
-
<>
|
|
23
|
-
<button onClick={handleOpen}>Create Project</button>
|
|
24
|
-
<CreateProjectDialog
|
|
25
|
-
isOpen={isOpen}
|
|
26
|
-
onClose={handleClose}
|
|
27
|
-
onProjectCreated={onProjectCreated}
|
|
28
|
-
/>
|
|
29
|
-
</>
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export default CreateProjectButton;
|