Skip to content

Commit d84c16b

Browse files
committed
remove __version property
1 parent 0aceb0b commit d84c16b

File tree

21 files changed

+16
-1332
lines changed

21 files changed

+16
-1332
lines changed

apps/events/src/components/todo/todos-local.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ export const TodosLocal = () => {
3030
/>
3131
{/* @ts-expect-error */}
3232
<div className="text-xs">{todo.__deleted ? 'deleted' : 'not deleted'}</div>
33-
{/* @ts-expect-error */}
34-
<div className="text-xs">{todo.__version}</div>
3533
<Button variant="secondary" size="sm" onClick={() => hardDeleteEntity(todo.id)}>
3634
Hard Delete
3735
</Button>

apps/events/src/components/todos2.tsx

Lines changed: 2 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,4 @@
1-
import type { PublishDiffInfo } from '@graphprotocol/hypergraph-react';
2-
import {
3-
PublishDiff,
4-
publishOps,
5-
useCreateEntity,
6-
useDeleteEntity,
7-
useHypergraphApp,
8-
useQuery,
9-
useSpace,
10-
useUpdateEntity,
11-
} from '@graphprotocol/hypergraph-react';
12-
import { useQueryClient } from '@tanstack/react-query';
1+
import { useCreateEntity, useDeleteEntity, useQuery, useSpace, useUpdateEntity } from '@graphprotocol/hypergraph-react';
132
import { useEffect, useState } from 'react';
143
import Select from 'react-select';
154
import { cn } from '@/lib/utils';
@@ -19,7 +8,6 @@ import { TodosLocal } from './todo/todos-local';
198
import { TodosPublic } from './todo/todos-public';
209
import { Button } from './ui/button';
2110
import { Input } from './ui/input';
22-
import { Modal } from './ui/modal';
2311

2412
export const Todos2 = () => {
2513
const {
@@ -34,20 +22,14 @@ export const Todos2 = () => {
3422
isError: isErrorUsers,
3523
// preparePublish: preparePublishUsers,
3624
} = useQuery(User, { mode: 'private' });
37-
const { ready: spaceReady, id: spaceId } = useSpace({ mode: 'private' });
38-
const { getSmartSessionClient } = useHypergraphApp();
25+
const { ready: spaceReady } = useSpace({ mode: 'private' });
3926
const createTodo = useCreateEntity(Todo2);
4027
const updateTodo = useUpdateEntity(Todo2);
4128
const createUser = useCreateEntity(User);
4229
const deleteEntity = useDeleteEntity();
4330
const [newTodoName, setNewTodoName] = useState('');
4431
const [newTodoAssignees, setNewTodoAssignees] = useState<{ value: string; label: string }[]>([]);
4532
const [newUserName, setNewUserName] = useState('');
46-
const queryClient = useQueryClient();
47-
const [publishData, setPublishData] = useState<PublishDiffInfo | null>(null);
48-
const [isPublishDiffModalOpen, setIsPublishDiffModalOpen] = useState(false);
49-
const [isPreparingPublish, setIsPreparingPublish] = useState(false);
50-
const [isPublishing, setIsPublishing] = useState(false);
5133

5234
useEffect(() => {
5335
setNewTodoAssignees((prevFilteredAssignees) => {
@@ -74,8 +56,6 @@ export const Todos2 = () => {
7456
<div key={user.id} className="flex flex-row items-center gap-2">
7557
<h2>{user.name}</h2>
7658
<div className="text-xs">{user.id}</div>
77-
{/* @ts-expect-error */}
78-
<div className="text-xs">{user.__version}</div>
7959
<Button variant="outline" size="sm" onClick={() => deleteEntity(user.id)}>
8060
Delete
8161
</Button>
@@ -140,8 +120,6 @@ export const Todos2 = () => {
140120
))}
141121
</span>
142122
)}
143-
{/* @ts-expect-error */}
144-
<div className="text-xs">{todo.__version}</div>
145123
<Button variant="outline" size="sm" onClick={() => deleteEntity(todo.id)}>
146124
Delete
147125
</Button>
@@ -179,92 +157,6 @@ export const Todos2 = () => {
179157
</Button>
180158
</div>
181159

182-
<Button
183-
onClick={async () => {
184-
try {
185-
setIsPreparingPublish(true);
186-
// const usersResult = await preparePublishUsers();
187-
// console.log('users ops & diff', usersResult);
188-
// const todosResult = await preparePublishTodos();
189-
// console.log('todos ops & diff', todosResult);
190-
191-
// if (todosResult && usersResult) {
192-
// setPublishData({
193-
// newEntities: [...todosResult.newEntities, ...usersResult.newEntities],
194-
// deletedEntities: [...todosResult.deletedEntities, ...usersResult.deletedEntities],
195-
// updatedEntities: [...todosResult.updatedEntities, ...usersResult.updatedEntities],
196-
// });
197-
// setIsPublishDiffModalOpen(true);
198-
// } else {
199-
// console.error('preparing publishing error', todosResult, usersResult);
200-
// throw new Error('Failed to prepare the publishing operations');
201-
// }
202-
} catch (error) {
203-
console.error('preparing publishing error', error);
204-
alert('Failed to prepare the publishing operations');
205-
} finally {
206-
setIsPreparingPublish(false);
207-
}
208-
}}
209-
disabled={isPreparingPublish}
210-
>
211-
{isPreparingPublish ? 'Preparing …' : 'Prepare Publish'}
212-
</Button>
213-
214-
<Modal isOpen={isPublishDiffModalOpen} onOpenChange={setIsPublishDiffModalOpen}>
215-
<div className="p-4 flex flex-col gap-4 min-w-96">
216-
<PublishDiff
217-
newEntities={publishData?.newEntities ?? []}
218-
deletedEntities={publishData?.deletedEntities ?? []}
219-
updatedEntities={publishData?.updatedEntities ?? []}
220-
/>
221-
<Button
222-
onClick={async () => {
223-
try {
224-
const smartSessionClient = await getSmartSessionClient();
225-
if (!smartSessionClient) {
226-
throw new Error('Missing smartSessionClient');
227-
}
228-
if (publishData) {
229-
setIsPublishing(true);
230-
const ops = [
231-
...publishData.newEntities.map((entity) => entity.ops),
232-
...publishData.updatedEntities.map((entity) => entity.ops),
233-
...publishData.deletedEntities.map((entity) => entity.ops),
234-
].flat();
235-
const publishOpsResult = await publishOps({
236-
ops,
237-
walletClient: smartSessionClient,
238-
space: spaceId,
239-
name: 'Update users and todos',
240-
});
241-
console.log('publishOpsResult', publishOpsResult);
242-
setIsPublishDiffModalOpen(false);
243-
setPublishData(null);
244-
setTimeout(() => {
245-
queryClient.invalidateQueries({
246-
queryKey: ['hypergraph-public-entities', Todo2.name],
247-
});
248-
}, 1000);
249-
}
250-
} catch (error) {
251-
console.error('publishing error', error);
252-
} finally {
253-
setIsPublishing(false);
254-
}
255-
}}
256-
disabled={
257-
(publishData?.newEntities.length === 0 &&
258-
publishData?.updatedEntities.length === 0 &&
259-
publishData?.deletedEntities.length === 0) ||
260-
isPublishing
261-
}
262-
>
263-
{isPublishing ? 'Publishing …' : 'Publish'}
264-
</Button>
265-
</div>
266-
</Modal>
267-
268160
<TodosLocal />
269161

270162
<TodosPublic />

apps/events/src/components/users/users-local.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ export const UsersLocal = () => {
1515
<div className="text-xs">{user.id}</div>
1616
{/* @ts-expect-error */}
1717
<div className="text-xs">{user.__deleted ? 'deleted' : 'not deleted'}</div>
18-
{/* @ts-expect-error */}
19-
<div className="text-xs">{user.__version}</div>
2018
<Button variant="secondary" size="sm" onClick={() => hardDeleteEntity(user.id)}>
2119
Hard Delete
2220
</Button>

apps/privy-login-example/src/components/todo/todos-local.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ export const TodosLocal = () => {
3030
/>
3131
{/* @ts-expect-error */}
3232
<div className="text-xs">{todo.__deleted ? 'deleted' : 'not deleted'}</div>
33-
{/* @ts-expect-error */}
34-
<div className="text-xs">{todo.__version}</div>
3533
<Button variant="secondary" size="sm" onClick={() => hardDeleteEntity(todo.id)}>
3634
Hard Delete
3735
</Button>

apps/privy-login-example/src/components/todos2.tsx

Lines changed: 3 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,4 @@
1-
import type { PublishDiffInfo } from '@graphprotocol/hypergraph-react';
2-
import {
3-
PublishDiff,
4-
publishOps,
5-
useCreateEntity,
6-
useDeleteEntity,
7-
useHypergraphApp,
8-
useQuery,
9-
useSpace,
10-
useUpdateEntity,
11-
} from '@graphprotocol/hypergraph-react';
12-
import { useQueryClient } from '@tanstack/react-query';
1+
import { useCreateEntity, useDeleteEntity, useQuery, useSpace, useUpdateEntity } from '@graphprotocol/hypergraph-react';
132
import { useEffect, useState } from 'react';
143
import Select from 'react-select';
154
import { cn } from '@/lib/utils';
@@ -19,7 +8,6 @@ import { TodosLocal } from './todo/todos-local';
198
import { TodosPublic } from './todo/todos-public';
209
import { Button } from './ui/button';
2110
import { Input } from './ui/input';
22-
import { Modal } from './ui/modal';
2311

2412
export const Todos2 = () => {
2513
const {
@@ -34,20 +22,15 @@ export const Todos2 = () => {
3422
isError: isErrorUsers,
3523
// preparePublish: preparePublishUsers,
3624
} = useQuery(User, { mode: 'private' });
37-
const { ready: spaceReady, id: spaceId } = useSpace({ mode: 'private' });
38-
const { getSmartSessionClient } = useHypergraphApp();
25+
const { ready: spaceReady } = useSpace({ mode: 'private' });
3926
const createTodo = useCreateEntity(Todo2);
4027
const updateTodo = useUpdateEntity(Todo2);
4128
const createUser = useCreateEntity(User);
4229
const deleteEntity = useDeleteEntity();
4330
const [newTodoName, setNewTodoName] = useState('');
4431
const [newTodoAssignees, setNewTodoAssignees] = useState<{ value: string; label: string }[]>([]);
4532
const [newUserName, setNewUserName] = useState('');
46-
const queryClient = useQueryClient();
47-
const [publishData, setPublishData] = useState<PublishDiffInfo | null>(null);
48-
const [isPublishDiffModalOpen, setIsPublishDiffModalOpen] = useState(false);
49-
const [isPreparingPublish, setIsPreparingPublish] = useState(false);
50-
const [isPublishing, setIsPublishing] = useState(false);
33+
const [_isPreparingPublish, _setIsPreparingPublish] = useState(false);
5134

5235
useEffect(() => {
5336
setNewTodoAssignees((prevFilteredAssignees) => {
@@ -74,8 +57,6 @@ export const Todos2 = () => {
7457
<div key={user.id} className="flex flex-row items-center gap-2">
7558
<h2>{user.name}</h2>
7659
<div className="text-xs">{user.id}</div>
77-
{/* @ts-expect-error */}
78-
<div className="text-xs">{user.__version}</div>
7960
<Button variant="outline" size="sm" onClick={() => deleteEntity(user.id)}>
8061
Delete
8162
</Button>
@@ -140,8 +121,6 @@ export const Todos2 = () => {
140121
))}
141122
</span>
142123
)}
143-
{/* @ts-expect-error */}
144-
<div className="text-xs">{todo.__version}</div>
145124
<Button variant="outline" size="sm" onClick={() => deleteEntity(todo.id)}>
146125
Delete
147126
</Button>
@@ -179,92 +158,6 @@ export const Todos2 = () => {
179158
</Button>
180159
</div>
181160

182-
<Button
183-
onClick={async () => {
184-
try {
185-
setIsPreparingPublish(true);
186-
// const usersResult = await preparePublishUsers();
187-
// console.log('users ops & diff', usersResult);
188-
// const todosResult = await preparePublishTodos();
189-
// console.log('todos ops & diff', todosResult);
190-
191-
// if (todosResult && usersResult) {
192-
// setPublishData({
193-
// newEntities: [...todosResult.newEntities, ...usersResult.newEntities],
194-
// deletedEntities: [...todosResult.deletedEntities, ...usersResult.deletedEntities],
195-
// updatedEntities: [...todosResult.updatedEntities, ...usersResult.updatedEntities],
196-
// });
197-
// setIsPublishDiffModalOpen(true);
198-
// } else {
199-
// console.error('preparing publishing error', todosResult, usersResult);
200-
// throw new Error('Failed to prepare the publishing operations');
201-
// }
202-
} catch (error) {
203-
console.error('preparing publishing error', error);
204-
alert('Failed to prepare the publishing operations');
205-
} finally {
206-
setIsPreparingPublish(false);
207-
}
208-
}}
209-
disabled={isPreparingPublish}
210-
>
211-
{isPreparingPublish ? 'Preparing …' : 'Prepare Publish'}
212-
</Button>
213-
214-
<Modal isOpen={isPublishDiffModalOpen} onOpenChange={setIsPublishDiffModalOpen}>
215-
<div className="p-4 flex flex-col gap-4 min-w-96">
216-
<PublishDiff
217-
newEntities={publishData?.newEntities ?? []}
218-
deletedEntities={publishData?.deletedEntities ?? []}
219-
updatedEntities={publishData?.updatedEntities ?? []}
220-
/>
221-
<Button
222-
onClick={async () => {
223-
try {
224-
const smartSessionClient = await getSmartSessionClient();
225-
if (!smartSessionClient) {
226-
throw new Error('Missing smartSessionClient');
227-
}
228-
if (publishData) {
229-
setIsPublishing(true);
230-
const ops = [
231-
...publishData.newEntities.map((entity) => entity.ops),
232-
...publishData.updatedEntities.map((entity) => entity.ops),
233-
...publishData.deletedEntities.map((entity) => entity.ops),
234-
].flat();
235-
const publishOpsResult = await publishOps({
236-
ops,
237-
walletClient: smartSessionClient,
238-
space: spaceId,
239-
name: 'Update users and todos',
240-
});
241-
console.log('publishOpsResult', publishOpsResult);
242-
setIsPublishDiffModalOpen(false);
243-
setPublishData(null);
244-
setTimeout(() => {
245-
queryClient.invalidateQueries({
246-
queryKey: ['hypergraph-public-entities', Todo2.name],
247-
});
248-
}, 1000);
249-
}
250-
} catch (error) {
251-
console.error('publishing error', error);
252-
} finally {
253-
setIsPublishing(false);
254-
}
255-
}}
256-
disabled={
257-
(publishData?.newEntities.length === 0 &&
258-
publishData?.updatedEntities.length === 0 &&
259-
publishData?.deletedEntities.length === 0) ||
260-
isPublishing
261-
}
262-
>
263-
{isPublishing ? 'Publishing …' : 'Publish'}
264-
</Button>
265-
</div>
266-
</Modal>
267-
268161
<TodosLocal />
269162

270163
<TodosPublic />

apps/privy-login-example/src/components/users/users-local.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ export const UsersLocal = () => {
1515
<div className="text-xs">{user.id}</div>
1616
{/* @ts-expect-error */}
1717
<div className="text-xs">{user.__deleted ? 'deleted' : 'not deleted'}</div>
18-
{/* @ts-expect-error */}
19-
<div className="text-xs">{user.__version}</div>
2018
<Button variant="secondary" size="sm" onClick={() => hardDeleteEntity(user.id)}>
2119
Hard Delete
2220
</Button>

biome.jsonc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"!**/routeTree.gen.ts",
1616
"!**/tsconfig.json",
1717
"!**/tsconfig.*.json",
18-
"!**/variant-schema.ts",
1918
"!**/apps/template-*",
2019
"!**/*.css",
2120
"!**/packages/typesync-studio/src/generated/**/*.ts"

packages/hypergraph-react/src/components/publish-diff/constants.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)